PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / admin / src / inc / Route.jsx

Route.jsx in Tableberg – Simple Gutenberg Table Block 1.1.5, at admin/src/inc/Route.jsx

61 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from "react";
2
3 /**
4 * Route default options.
5 *
6 * @type {Object}
7 */
8 export const defaultRouteOptions = {
9 path: null,
10 title: "no_title",
11 element: null,
12 };
13
14 /**
15 * Route object.
16 *
17 * @param {Object} options route options
18 * @class
19 */
20 function Route(options) {
21 const { path, title, element } = { ...defaultRouteOptions, ...options };
22 /**
23 * Get route path.
24 *
25 * @return {string} path
26 */
27 this.getPath = () => path;
28
29 /**
30 * Get route title.
31 *
32 * @return {string} title
33 */
34 this.getTitle = () => title;
35
36 /**
37 * Get route element.
38 *
39 * @return {Function} element
40 */
41 this.getElement = () =>
42 element ?? <div>no element defined for route [{this.getPath()}]</div>;
43 }
44
45 /**
46 * Generate options array from settings objects.
47 *
48 * These settings objects should correspond to Route default options.
49 *
50 * @param {Array<Object>} optionsArray options array
51 * @return {Array<Route>} route object array
52 */
53 export const generateRouteArray = optionsArray => {
54 return optionsArray.map(options => new Route(options));
55 };
56
57 /**
58 * @module Route
59 */
60 export default Route;
61