@imperium/layout 9.0.0 → 9.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/commonItems.js +9 -0
- package/dist/esm/commonItems.js.map +1 -0
- package/dist/esm/content/components/ActionForm.js +62 -0
- package/dist/esm/content/components/ActionForm.js.map +1 -0
- package/dist/esm/content/components/ActionFormSidebarItemComponent.js +36 -0
- package/dist/esm/content/components/ActionFormSidebarItemComponent.js.map +1 -0
- package/dist/esm/content/components/ActionSidebarItemComponent.js +20 -0
- package/dist/esm/content/components/ActionSidebarItemComponent.js.map +1 -0
- package/dist/esm/content/components/ContentComponent.js +63 -0
- package/dist/esm/content/components/ContentComponent.js.map +1 -0
- package/dist/esm/content/components/CustomSidebarItemComponent.js +8 -0
- package/dist/esm/content/components/CustomSidebarItemComponent.js.map +1 -0
- package/dist/esm/content/components/Header.js +26 -0
- package/dist/esm/content/components/Header.js.map +1 -0
- package/dist/esm/content/components/PlainSidebarItem.js +20 -0
- package/dist/esm/content/components/PlainSidebarItem.js.map +1 -0
- package/dist/esm/content/components/SidebarItemWrapper.js +58 -0
- package/dist/esm/content/components/SidebarItemWrapper.js.map +1 -0
- package/dist/esm/content/components/styles.module.css.js +8 -0
- package/dist/esm/content/components/styles.module.css.js.map +1 -0
- package/dist/esm/content/createPages.js +32 -0
- package/dist/esm/content/createPages.js.map +1 -0
- package/dist/esm/content/dividerSidebarItem.js +7 -0
- package/dist/esm/content/dividerSidebarItem.js.map +1 -0
- package/dist/esm/content/hooks/useBuildContentData.js +18 -0
- package/dist/esm/content/hooks/useBuildContentData.js.map +1 -0
- package/dist/esm/content/types.js +18 -0
- package/dist/esm/content/types.js.map +1 -0
- package/dist/esm/content/utils.js +29 -0
- package/dist/esm/content/utils.js.map +1 -0
- package/dist/esm/datahooks/DataHooks.js +39 -0
- package/dist/esm/datahooks/DataHooks.js.map +1 -0
- package/dist/esm/datahooks/ExecuteDataHook.js +9 -0
- package/dist/esm/datahooks/ExecuteDataHook.js.map +1 -0
- package/dist/esm/datahooks/ExecutePermissionHook.js +17 -0
- package/dist/esm/datahooks/ExecutePermissionHook.js.map +1 -0
- package/dist/esm/datahooks/PermissionHooks.js +16 -0
- package/dist/esm/datahooks/PermissionHooks.js.map +1 -0
- package/dist/esm/external/style-inject/dist/style-inject.es.js +29 -0
- package/dist/esm/external/style-inject/dist/style-inject.es.js.map +1 -0
- package/dist/esm/hooks/useBuildData.js +28 -0
- package/dist/esm/hooks/useBuildData.js.map +1 -0
- package/dist/esm/hooks/useIsActiveRoute.js +22 -0
- package/dist/esm/hooks/useIsActiveRoute.js.map +1 -0
- package/dist/esm/hooks/useSelectPermission.js +12 -0
- package/dist/esm/hooks/useSelectPermission.js.map +1 -0
- package/dist/esm/hooks/useSelectState.js +12 -0
- package/dist/esm/hooks/useSelectState.js.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/layout/components/CustomLayoutItemComponent.js +8 -0
- package/dist/esm/layout/components/CustomLayoutItemComponent.js.map +1 -0
- package/dist/esm/layout/components/DropdownItem.js +40 -0
- package/dist/esm/layout/components/DropdownItem.js.map +1 -0
- package/dist/esm/layout/components/Layout.js +74 -0
- package/dist/esm/layout/components/Layout.js.map +1 -0
- package/dist/esm/layout/components/LayoutItemBar.js +29 -0
- package/dist/esm/layout/components/LayoutItemBar.js.map +1 -0
- package/dist/esm/layout/components/LayoutItemWrapper.js +72 -0
- package/dist/esm/layout/components/LayoutItemWrapper.js.map +1 -0
- package/dist/esm/layout/components/MenuItem.js +11 -0
- package/dist/esm/layout/components/MenuItem.js.map +1 -0
- package/dist/esm/layout/components/PlainItem.js +14 -0
- package/dist/esm/layout/components/PlainItem.js.map +1 -0
- package/dist/esm/layout/components/SecondaryMenuToggleItem.js +16 -0
- package/dist/esm/layout/components/SecondaryMenuToggleItem.js.map +1 -0
- package/dist/esm/layout/components/styles.module.css.js +8 -0
- package/dist/esm/layout/components/styles.module.css.js.map +1 -0
- package/dist/esm/layout/hooks/useMobileLayout.js +21 -0
- package/dist/esm/layout/hooks/useMobileLayout.js.map +1 -0
- package/dist/esm/layout/moveItems.js +65 -0
- package/dist/esm/layout/moveItems.js.map +1 -0
- package/dist/esm/layout/types.js +12 -0
- package/dist/esm/layout/types.js.map +1 -0
- package/dist/esm/layout/utils.js +41 -0
- package/dist/esm/layout/utils.js.map +1 -0
- package/dist/esm/layout/withLayout.js +52 -0
- package/dist/esm/layout/withLayout.js.map +1 -0
- package/dist/esm/state.js +25 -0
- package/dist/esm/state.js.map +1 -0
- package/dist/esm/types.js +7 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.js +9 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/stats.html +2689 -0
- package/dist/{commonItems.d.ts → types/commonItems.d.ts} +0 -0
- package/dist/{content → types/content}/components/ActionForm.d.ts +0 -0
- package/dist/{content → types/content}/components/ActionFormSidebarItemComponent.d.ts +0 -0
- package/dist/{content → types/content}/components/ActionSidebarItemComponent.d.ts +0 -0
- package/dist/{content → types/content}/components/ContentComponent.d.ts +0 -0
- package/dist/{content → types/content}/components/CustomSidebarItemComponent.d.ts +0 -0
- package/dist/{content → types/content}/components/Header.d.ts +0 -0
- package/dist/{content → types/content}/components/PlainSidebarItem.d.ts +0 -0
- package/dist/{content → types/content}/components/SidebarItemWrapper.d.ts +0 -0
- package/dist/{content → types/content}/createPages.d.ts +0 -0
- package/dist/{content → types/content}/dividerSidebarItem.d.ts +0 -0
- package/dist/{content → types/content}/hooks/useBuildContentData.d.ts +0 -0
- package/dist/{content → types/content}/types.d.ts +0 -0
- package/dist/{content → types/content}/utils.d.ts +0 -0
- package/dist/{datahooks → types/datahooks}/DataHooks.d.ts +0 -0
- package/dist/{datahooks → types/datahooks}/ExecuteDataHook.d.ts +0 -0
- package/dist/{datahooks → types/datahooks}/ExecutePermissionHook.d.ts +0 -0
- package/dist/{datahooks → types/datahooks}/PermissionHooks.d.ts +0 -0
- package/dist/{datahooks → types/datahooks}/types.d.ts +0 -0
- package/dist/{hooks → types/hooks}/useBuildData.d.ts +0 -0
- package/dist/{hooks → types/hooks}/useIsActiveRoute.d.ts +0 -0
- package/dist/{hooks → types/hooks}/useSelectPermission.d.ts +0 -0
- package/dist/{hooks → types/hooks}/useSelectState.d.ts +0 -0
- package/dist/{index.d.ts → types/index.d.ts} +0 -0
- package/dist/{layout → types/layout}/components/CustomLayoutItemComponent.d.ts +0 -0
- package/dist/{layout → types/layout}/components/DropdownItem.d.ts +0 -0
- package/dist/{layout → types/layout}/components/Layout.d.ts +0 -0
- package/dist/{layout → types/layout}/components/LayoutItemBar.d.ts +0 -0
- package/dist/{layout → types/layout}/components/LayoutItemWrapper.d.ts +0 -0
- package/dist/{layout → types/layout}/components/MenuItem.d.ts +0 -0
- package/dist/{layout → types/layout}/components/PlainItem.d.ts +0 -0
- package/dist/{layout → types/layout}/components/SecondaryMenuToggleItem.d.ts +0 -0
- package/dist/{layout → types/layout}/hooks/useMobileLayout.d.ts +0 -0
- package/dist/{layout → types/layout}/moveItems.d.ts +0 -0
- package/dist/{layout → types/layout}/types.d.ts +0 -0
- package/dist/{layout → types/layout}/utils.d.ts +0 -0
- package/dist/{layout → types/layout}/withLayout.d.ts +0 -0
- package/dist/{state.d.ts → types/state.d.ts} +0 -0
- package/dist/{types.d.ts → types/types.d.ts} +0 -0
- package/dist/types/utils.d.ts +3 -0
- package/package.json +18 -18
- package/client.js +0 -7
- package/dist/client.js +0 -3620
- package/dist/client.min.js +0 -2
- package/dist/client.min.js.map +0 -1
- package/dist/utils.d.ts +0 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function isHorizontalPositionedItem(value) {
|
|
2
|
+
return !!(value.position || value.stickOnMobile);
|
|
3
|
+
}
|
|
4
|
+
function isRouteItem(value) {
|
|
5
|
+
return !!(value.to || value.exact || value.strict || value.sensitive);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { isHorizontalPositionedItem, isRouteItem };
|
|
9
|
+
//# sourceMappingURL=commonItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonItems.js","sources":["../../src/commonItems.ts"],"sourcesContent":["import type {PermissionSelectorHook, StateSelectorHook, VisibilityQueryFn} from './types';\n\n/**\n * Describes an item that can hide itself based on redux state\n */\nexport interface VisibilityItem {\n\tstateSelectorHook?: StateSelectorHook | StateSelectorHook[]; // Hook or array of hooks that select state\n\tpermissionSelectorHook?: PermissionSelectorHook | PermissionSelectorHook[]; // Hook or array of hooks that select permissions\n\tvisible?: Record<string, unknown> | VisibilityQueryFn;\n}\n\n/**\n * Describes an item with optional weight\n */\nexport interface WeightedItem {\n\tweight?: number; // Larger numbers move right/down\n}\n\n/**\n * Describes an item that links to a route\n */\nexport interface RouteItem<T> {\n\tto?: string | ((data: T) => string);\n\texact?: boolean;\n\tstrict?: boolean;\n\tsensitive?: boolean;\n}\n\n/**\n * Describes an item that can be positioned horizontally left or right\n */\nexport interface HorizontalPositionedItem {\n\tposition?: 'left' | 'right'; // Default is left\n\tstickOnMobile?: boolean; // If true, will not be hidden when in mobile mode\n}\n\nexport function isHorizontalPositionedItem(value: any): value is HorizontalPositionedItem {\n\treturn !!((value as HorizontalPositionedItem).position || (value as HorizontalPositionedItem).stickOnMobile);\n}\n\nexport function isRouteItem<T>(value: any): value is RouteItem<T> {\n\treturn !!((value as RouteItem<T>).to || (value as RouteItem<T>).exact || (value as RouteItem<T>).strict || (value as RouteItem<T>).sensitive);\n}\n"],"names":[],"mappings":"AAoCO,SAAA,0BAAA,CAAoC,KAA+C,EAAA;AACzF,EAAA,OAAO,CAAC,EAAsC,KAAA,CAAA,QAAA,IAAa,KAAmC,CAAA,aAAA,CAAA,CAAA;AAC/F,CAAA;AAEO,SAAA,WAAA,CAAwB,KAAmC,EAAA;AACjE,EAAO,OAAA,CAAC,EAA0B,KAAA,CAAA,EAAA,IAAO,MAAuB,KAAU,IAAA,KAAA,CAAuB,UAAW,KAAuB,CAAA,SAAA,CAAA,CAAA;AACpI;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTForm } from '@thx/controls';
|
|
3
|
+
import debug from 'debug';
|
|
4
|
+
import { Popup, Button, Icon, Message, Form } from 'semantic-ui-react';
|
|
5
|
+
|
|
6
|
+
debug("imperium.layout.content.components.ActionForm");
|
|
7
|
+
function ActionForm({ item, data, onHideForm }) {
|
|
8
|
+
let initialValues = {};
|
|
9
|
+
if (item.initialValues) {
|
|
10
|
+
if (typeof item.initialValues === "function") {
|
|
11
|
+
initialValues = item.initialValues(data);
|
|
12
|
+
} else {
|
|
13
|
+
initialValues = item.initialValues;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const { hasErrors, hasWarnings, handleSubmit, handleChange, values, resetForm, errors, fieldError } = useTForm({
|
|
17
|
+
initialValues,
|
|
18
|
+
onSubmit: (submitValues) => {
|
|
19
|
+
if (item.onSubmit) {
|
|
20
|
+
item.onSubmit(submitValues, data);
|
|
21
|
+
}
|
|
22
|
+
onHideForm();
|
|
23
|
+
},
|
|
24
|
+
enableReinitialize: true,
|
|
25
|
+
validationSchema: item.validationSchema
|
|
26
|
+
});
|
|
27
|
+
const saveButton = hasWarnings ? /* @__PURE__ */ React.createElement(Popup, {
|
|
28
|
+
trigger: /* @__PURE__ */ React.createElement(Button, {
|
|
29
|
+
positive: true,
|
|
30
|
+
type: "submit",
|
|
31
|
+
floated: "right",
|
|
32
|
+
icon: true,
|
|
33
|
+
labelPosition: "left"
|
|
34
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
35
|
+
name: "exclamation circle",
|
|
36
|
+
color: "red"
|
|
37
|
+
}), "Save"),
|
|
38
|
+
content: /* @__PURE__ */ React.createElement(Message, {
|
|
39
|
+
error: true,
|
|
40
|
+
list: Object.values(errors)
|
|
41
|
+
}),
|
|
42
|
+
on: "hover"
|
|
43
|
+
}) : /* @__PURE__ */ React.createElement(Button, {
|
|
44
|
+
positive: true,
|
|
45
|
+
type: "submit",
|
|
46
|
+
floated: "right"
|
|
47
|
+
}, "Save");
|
|
48
|
+
return /* @__PURE__ */ React.createElement(Form, {
|
|
49
|
+
error: hasErrors,
|
|
50
|
+
warning: hasWarnings,
|
|
51
|
+
onSubmit: handleSubmit
|
|
52
|
+
}, item.form({ handleChange, values, data, fieldError }), saveButton, /* @__PURE__ */ React.createElement(Button, {
|
|
53
|
+
type: "button",
|
|
54
|
+
onClick: () => {
|
|
55
|
+
resetForm();
|
|
56
|
+
onHideForm();
|
|
57
|
+
}
|
|
58
|
+
}, "Cancel"));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { ActionForm };
|
|
62
|
+
//# sourceMappingURL=ActionForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionForm.js","sources":["../../../../src/content/components/ActionForm.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport {useTForm} from '@thx/controls';\nimport debug from 'debug';\nimport {Button, Form, Icon, Message, Popup} from 'semantic-ui-react';\nimport type {ActionFormSidebarItem, ContentData} from '../types';\n\nconst d = debug('imperium.layout.content.components.ActionForm');\n\ninterface ActionFormProps<T extends DefineRouteOptions, K extends keyof T> {\n\titem: ActionFormSidebarItem<T, K>;\n\tdata: ContentData<T, K>;\n\tonHideForm: () => void;\n}\n\nexport function ActionForm<T extends DefineRouteOptions, K extends keyof T>({item, data, onHideForm}: ActionFormProps<T, K>) {\n\t// Get initial values\n\tlet initialValues = {};\n\tif (item.initialValues) {\n\t\tif (typeof item.initialValues === 'function') {\n\t\t\tinitialValues = item.initialValues(data);\n\t\t} else {\n\t\t\tinitialValues = item.initialValues;\n\t\t}\n\t}\n\n\t// TForm\n\tconst {hasErrors, hasWarnings, handleSubmit, handleChange, values, resetForm, errors, fieldError} = useTForm({\n\t\tinitialValues,\n\t\tonSubmit: submitValues => {\n\t\t\tif (item.onSubmit) {\n\t\t\t\titem.onSubmit(submitValues, data);\n\t\t\t}\n\t\t\tonHideForm();\n\t\t},\n\t\tenableReinitialize: true,\n\t\tvalidationSchema: item.validationSchema,\n\t});\n\n\tconst saveButton = hasWarnings ? (\n\t\t<Popup\n\t\t\ttrigger={\n\t\t\t\t<Button positive type=\"submit\" floated=\"right\" icon labelPosition=\"left\">\n\t\t\t\t\t<Icon name=\"exclamation circle\" color=\"red\" />\n\t\t\t\t\tSave\n\t\t\t\t</Button>\n\t\t\t}\n\t\t\tcontent={<Message error list={Object.values(errors)} />}\n\t\t\ton=\"hover\"\n\t\t/>\n\t) : (\n\t\t<Button positive type=\"submit\" floated=\"right\">\n\t\t\tSave\n\t\t</Button>\n\t);\n\n\t// Render form\n\treturn (\n\t\t<Form error={hasErrors} warning={hasWarnings} onSubmit={handleSubmit}>\n\t\t\t{item.form({handleChange, values, data, fieldError})}\n\t\t\t{saveButton}\n\t\t\t<Button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={() => {\n\t\t\t\t\tresetForm();\n\t\t\t\t\tonHideForm();\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\tCancel\n\t\t\t</Button>\n\t\t</Form>\n\t);\n}\n"],"names":[],"mappings":";;;;;AAMU,MAAM,+CAA+C,EAAA;AAQa,SAAA,UAAA,CAAA,EAAC,IAAM,EAAA,IAAA,EAAM,UAAoC,EAAA,EAAA;AAE5H,EAAA,IAAI,gBAAgB,EAAC,CAAA;AACrB,EAAA,IAAI,KAAK,aAAe,EAAA;AACvB,IAAI,IAAA,OAAO,IAAK,CAAA,aAAA,KAAkB,UAAY,EAAA;AAC7C,MAAgB,aAAA,GAAA,IAAA,CAAK,cAAc,IAAI,CAAA,CAAA;AAAA,KACjC,MAAA;AACN,MAAA,aAAA,GAAgB,IAAK,CAAA,aAAA,CAAA;AAAA,KACtB;AAAA,GACD;AAGA,EAAM,MAAA,EAAC,WAAW,WAAa,EAAA,YAAA,EAAc,cAAc,MAAQ,EAAA,SAAA,EAAW,MAAQ,EAAA,UAAA,EAAA,GAAc,QAAS,CAAA;AAAA,IAC5G,aAAA;AAAA,IACA,UAAU,CAAgB,YAAA,KAAA;AACzB,MAAA,IAAI,KAAK,QAAU,EAAA;AAClB,QAAK,IAAA,CAAA,QAAA,CAAS,cAAc,IAAI,CAAA,CAAA;AAAA,OACjC;AACA,MAAW,UAAA,EAAA,CAAA;AAAA,KACZ;AAAA,IACA,kBAAoB,EAAA,IAAA;AAAA,IACpB,kBAAkB,IAAK,CAAA,gBAAA;AAAA,GACvB,CAAA,CAAA;AAED,EAAM,MAAA,UAAA,GAAa,8BACjB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IACA,yBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,MAAO,QAAQ,EAAA,IAAA;AAAA,MAAC,IAAK,EAAA,QAAA;AAAA,MAAS,OAAQ,EAAA,OAAA;AAAA,MAAQ,IAAI,EAAA,IAAA;AAAA,MAAC,aAAc,EAAA,MAAA;AAAA,KAAA,kBAChE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,MAAK,IAAK,EAAA,oBAAA;AAAA,MAAqB,KAAM,EAAA,KAAA;AAAA,KAAM,GAAE,MAE/C,CAAA;AAAA,IAED,yBAAU,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA;AAAA,MAAQ,KAAK,EAAA,IAAA;AAAA,MAAC,IAAA,EAAM,MAAO,CAAA,MAAA,CAAO,MAAM,CAAA;AAAA,KAAG,CAAA;AAAA,IACrD,EAAG,EAAA,OAAA;AAAA,GACJ,oBAEC,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IAAO,QAAQ,EAAA,IAAA;AAAA,IAAC,IAAK,EAAA,QAAA;AAAA,IAAS,OAAQ,EAAA,OAAA;AAAA,GAAA,EAAQ,MAE/C,CAAA,CAAA;AAID,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,IAAK,KAAO,EAAA,SAAA;AAAA,IAAW,OAAS,EAAA,WAAA;AAAA,IAAa,QAAU,EAAA,YAAA;AAAA,GACtD,EAAA,IAAA,CAAK,IAAK,CAAA,EAAC,YAAc,EAAA,MAAA,EAAQ,MAAM,UAAU,EAAC,CAClD,EAAA,UAAA,kBACA,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IACA,IAAK,EAAA,QAAA;AAAA,IACL,SAAS,MAAM;AACd,MAAU,SAAA,EAAA,CAAA;AACV,MAAW,UAAA,EAAA,CAAA;AAAA,KACZ;AAAA,GAAA,EACA,QAED,CACD,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { Button } from 'semantic-ui-react';
|
|
4
|
+
import { getIcon, getColor, getText } from '../utils.js';
|
|
5
|
+
import { ActionForm } from './ActionForm.js';
|
|
6
|
+
|
|
7
|
+
debug("imperium.layout.content.components.ActionFormSidebarItemComponent");
|
|
8
|
+
function ActionFormSidebarItemComponent({
|
|
9
|
+
item,
|
|
10
|
+
data
|
|
11
|
+
}) {
|
|
12
|
+
const [isEdit, setIsEdit] = useState(false);
|
|
13
|
+
if (isEdit) {
|
|
14
|
+
return /* @__PURE__ */ React.createElement(ActionForm, {
|
|
15
|
+
item,
|
|
16
|
+
data,
|
|
17
|
+
onHideForm: () => {
|
|
18
|
+
setIsEdit(false);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const icon = getIcon(item, data);
|
|
23
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
24
|
+
fluid: true,
|
|
25
|
+
compact: true,
|
|
26
|
+
color: getColor(item, data),
|
|
27
|
+
icon: !!icon,
|
|
28
|
+
labelPosition: icon ? "left" : void 0,
|
|
29
|
+
onClick: () => {
|
|
30
|
+
setIsEdit(true);
|
|
31
|
+
}
|
|
32
|
+
}, icon, getText(item, data));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { ActionFormSidebarItemComponent };
|
|
36
|
+
//# sourceMappingURL=ActionFormSidebarItemComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionFormSidebarItemComponent.js","sources":["../../../../src/content/components/ActionFormSidebarItemComponent.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport debug from 'debug';\nimport {useState} from 'react';\nimport {Button} from 'semantic-ui-react';\nimport type {ActionFormSidebarItem, ContentData} from '../types';\nimport {getColor, getIcon, getText} from '../utils';\nimport {ActionForm} from './ActionForm';\n\nconst d = debug('imperium.layout.content.components.ActionFormSidebarItemComponent');\n\ninterface ActionFormSidebarItemComponentProps<T extends DefineRouteOptions, K extends keyof T> {\n\titem: ActionFormSidebarItem<T, K>;\n\tdata: ContentData<T, K>;\n}\n\nexport function ActionFormSidebarItemComponent<T extends DefineRouteOptions, K extends keyof T>({\n\titem,\n\tdata,\n}: ActionFormSidebarItemComponentProps<T, K>) {\n\tconst [isEdit, setIsEdit] = useState(false);\n\n\tif (isEdit) {\n\t\treturn (\n\t\t\t<ActionForm\n\t\t\t\titem={item}\n\t\t\t\tdata={data}\n\t\t\t\tonHideForm={() => {\n\t\t\t\t\tsetIsEdit(false);\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst icon = getIcon(item, data);\n\n\t// Render action button\n\treturn (\n\t\t<Button\n\t\t\tfluid\n\t\t\tcompact\n\t\t\tcolor={getColor(item, data)}\n\t\t\ticon={!!icon}\n\t\t\tlabelPosition={icon ? 'left' : undefined}\n\t\t\tonClick={() => {\n\t\t\t\tsetIsEdit(true);\n\t\t\t}}\n\t\t>\n\t\t\t{icon}\n\t\t\t{getText(item, data)}\n\t\t</Button>\n\t);\n}\n"],"names":[],"mappings":";;;;;;AAQU,MAAM,mEAAmE,EAAA;AAOa,SAAA,8BAAA,CAAA;AAAA,EAC/F,IAAA;AAAA,EACA,IAAA;AAAA,CAC6C,EAAA;AAC7C,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAa,CAAA,GAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAE1C,EAAA,IAAI,MAAQ,EAAA;AACX,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,MACA,IAAA;AAAA,MACA,IAAA;AAAA,MACA,YAAY,MAAM;AACjB,QAAA,SAAA,CAAU,KAAK,CAAA,CAAA;AAAA,OAChB;AAAA,KACD,CAAA,CAAA;AAAA,GAEF;AAEA,EAAM,MAAA,IAAA,GAAO,OAAQ,CAAA,IAAA,EAAM,IAAI,CAAA,CAAA;AAG/B,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IACA,KAAK,EAAA,IAAA;AAAA,IACL,OAAO,EAAA,IAAA;AAAA,IACP,KAAA,EAAO,QAAS,CAAA,IAAA,EAAM,IAAI,CAAA;AAAA,IAC1B,IAAA,EAAM,CAAC,CAAC,IAAA;AAAA,IACR,aAAA,EAAe,OAAO,MAAS,GAAA,KAAA,CAAA;AAAA,IAC/B,SAAS,MAAM;AACd,MAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAAA,KACf;AAAA,GAAA,EAEC,IACA,EAAA,OAAA,CAAQ,IAAM,EAAA,IAAI,CACpB,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from 'semantic-ui-react';
|
|
3
|
+
import { getIcon, getColor, getText } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
function ActionSidebarItemComponent({ item, data }) {
|
|
6
|
+
const icon = getIcon(item, data);
|
|
7
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
8
|
+
fluid: true,
|
|
9
|
+
compact: true,
|
|
10
|
+
color: getColor(item, data),
|
|
11
|
+
icon: !!icon,
|
|
12
|
+
labelPosition: icon ? "left" : void 0,
|
|
13
|
+
onClick: () => {
|
|
14
|
+
item.onClick(data);
|
|
15
|
+
}
|
|
16
|
+
}, icon, getText(item, data));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { ActionSidebarItemComponent };
|
|
20
|
+
//# sourceMappingURL=ActionSidebarItemComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionSidebarItemComponent.js","sources":["../../../../src/content/components/ActionSidebarItemComponent.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport {Button} from 'semantic-ui-react';\nimport type {ActionSidebarItem, ContentData} from '../types';\nimport {getColor, getIcon, getText} from '../utils';\n\ninterface ActionSidebarItemComponentProps<T extends DefineRouteOptions, K extends keyof T> {\n\titem: ActionSidebarItem<T, K>;\n\tdata: ContentData<T, K>;\n}\n\nexport function ActionSidebarItemComponent<T extends DefineRouteOptions, K extends keyof T>({item, data}: ActionSidebarItemComponentProps<T, K>) {\n\tconst icon = getIcon(item, data);\n\n\treturn (\n\t\t<Button\n\t\t\tfluid\n\t\t\tcompact\n\t\t\tcolor={getColor(item, data)}\n\t\t\ticon={!!icon}\n\t\t\tlabelPosition={icon ? 'left' : undefined}\n\t\t\tonClick={() => {\n\t\t\t\titem.onClick(data);\n\t\t\t}}\n\t\t>\n\t\t\t{icon}\n\t\t\t{getText(item, data)}\n\t\t</Button>\n\t);\n}\n"],"names":[],"mappings":";;;;AAU4F,SAAA,0BAAA,CAAA,EAAC,MAAM,IAA8C,EAAA,EAAA;AAChJ,EAAM,MAAA,IAAA,GAAO,OAAQ,CAAA,IAAA,EAAM,IAAI,CAAA,CAAA;AAE/B,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IACA,KAAK,EAAA,IAAA;AAAA,IACL,OAAO,EAAA,IAAA;AAAA,IACP,KAAA,EAAO,QAAS,CAAA,IAAA,EAAM,IAAI,CAAA;AAAA,IAC1B,IAAA,EAAM,CAAC,CAAC,IAAA;AAAA,IACR,aAAA,EAAe,OAAO,MAAS,GAAA,KAAA,CAAA;AAAA,IAC/B,SAAS,MAAM;AACd,MAAA,IAAA,CAAK,QAAQ,IAAI,CAAA,CAAA;AAAA,KAClB;AAAA,GAAA,EAEC,IACA,EAAA,OAAA,CAAQ,IAAM,EAAA,IAAI,CACpB,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { isEqual } from 'lodash-es';
|
|
4
|
+
import { useDispatch } from 'react-redux';
|
|
5
|
+
import { DataHooks } from '../../datahooks/DataHooks.js';
|
|
6
|
+
import { actions } from '../../state.js';
|
|
7
|
+
import { sortWeightedItems } from '../../utils.js';
|
|
8
|
+
import { useBuildContentData } from '../hooks/useBuildContentData.js';
|
|
9
|
+
import { Header } from './Header.js';
|
|
10
|
+
import { SidebarItemWrapper } from './SidebarItemWrapper.js';
|
|
11
|
+
import styles from './styles.module.css.js';
|
|
12
|
+
|
|
13
|
+
debug("imperium.layout.content.components.ContentComponent");
|
|
14
|
+
function useDeepCompareMemoize(value) {
|
|
15
|
+
const ref = useRef();
|
|
16
|
+
if (!value && !ref.current)
|
|
17
|
+
return ref.current;
|
|
18
|
+
if (!isEqual(value, ref.current)) {
|
|
19
|
+
ref.current = value;
|
|
20
|
+
}
|
|
21
|
+
return ref.current;
|
|
22
|
+
}
|
|
23
|
+
function useDeepCompareEffect(callback, deps) {
|
|
24
|
+
useEffect(callback, deps.map(useDeepCompareMemoize));
|
|
25
|
+
}
|
|
26
|
+
function ContentComponent({ page, params }) {
|
|
27
|
+
const dispatch = useDispatch();
|
|
28
|
+
const data = useBuildContentData({ stateSelectorHook: page.stateSelectorHook, permissionSelectorHook: page.permissionSelectorHook, params });
|
|
29
|
+
useDeepCompareEffect(() => {
|
|
30
|
+
dispatch(actions.setParams(params));
|
|
31
|
+
}, [dispatch, params]);
|
|
32
|
+
const content = page.content(data);
|
|
33
|
+
const sidebarItems = sortWeightedItems(page.sidebar || []);
|
|
34
|
+
const sidebar = sidebarItems.length > 0 ? /* @__PURE__ */ React.createElement("div", {
|
|
35
|
+
className: `${styles.sidebar} imperiumContentSidebar`
|
|
36
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
37
|
+
className: `${styles.actionsHeader} imperiumContentSidebarHeader`
|
|
38
|
+
}, /* @__PURE__ */ React.createElement("h3", null, "Actions")), sidebarItems.map((sb, index) => {
|
|
39
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
40
|
+
className: styles.sidebarItem,
|
|
41
|
+
key: index
|
|
42
|
+
}, /* @__PURE__ */ React.createElement(SidebarItemWrapper, {
|
|
43
|
+
item: sb,
|
|
44
|
+
params,
|
|
45
|
+
data
|
|
46
|
+
}));
|
|
47
|
+
})) : null;
|
|
48
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
49
|
+
className: `${styles.parent} imperiumContentWrapperParent`
|
|
50
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
51
|
+
className: `${styles.wrapper} imperiumContentWrapper`
|
|
52
|
+
}, /* @__PURE__ */ React.createElement(Header, {
|
|
53
|
+
header: page.header,
|
|
54
|
+
data
|
|
55
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
56
|
+
className: `${styles.content} imperiumContent ${page.full && styles.contentFull}`
|
|
57
|
+
}, content)), sidebar, /* @__PURE__ */ React.createElement(DataHooks, {
|
|
58
|
+
dataHooks: page.dataHooks || []
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { ContentComponent };
|
|
63
|
+
//# sourceMappingURL=ContentComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentComponent.js","sources":["../../../../src/content/components/ContentComponent.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport debug from 'debug';\nimport {isEqual} from 'lodash-es';\nimport {DependencyList, EffectCallback, useEffect, useRef} from 'react';\nimport {useDispatch} from 'react-redux';\nimport {DataHooks} from '../../datahooks/DataHooks';\nimport {actions} from '../../state';\nimport {sortWeightedItems} from '../../utils';\nimport {useBuildContentData} from '../hooks/useBuildContentData';\nimport type {Page, RouteParameters, SidebarItem} from '../types';\nimport {Header} from './Header';\nimport {SidebarItemWrapper} from './SidebarItemWrapper';\nimport styles from './styles.module.css';\n\nconst d = debug('imperium.layout.content.components.ContentComponent');\n\ninterface ContentComponentProps<T extends DefineRouteOptions, K extends keyof T> {\n\tpage: Page<T, K>;\n\tparams: RouteParameters<T[K]['params']>;\n}\n\nfunction useDeepCompareMemoize(value: any) {\n\tconst ref = useRef();\n\tif (!value && !ref.current) return ref.current;\n\tif (!isEqual(value, ref.current)) {\n\t\tref.current = value;\n\t}\n\treturn ref.current;\n}\n\nfunction useDeepCompareEffect(callback: EffectCallback, deps: DependencyList) {\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect(callback, deps.map(useDeepCompareMemoize));\n}\n\nexport function ContentComponent<T extends DefineRouteOptions, K extends keyof T>({page, params}: ContentComponentProps<T, K>) {\n\tconst dispatch = useDispatch();\n\tconst data = useBuildContentData({stateSelectorHook: page.stateSelectorHook, permissionSelectorHook: page.permissionSelectorHook, params});\n\n\tuseDeepCompareEffect(() => {\n\t\tdispatch(actions.setParams(params));\n\t}, [dispatch, params]);\n\n\tconst content = page.content(data);\n\tconst sidebarItems = sortWeightedItems(page.sidebar || []);\n\n\tconst sidebar =\n\t\tsidebarItems.length > 0 ? (\n\t\t\t<div className={`${styles.sidebar} imperiumContentSidebar`}>\n\t\t\t\t<div className={`${styles.actionsHeader} imperiumContentSidebarHeader`}>\n\t\t\t\t\t<h3>Actions</h3>\n\t\t\t\t</div>\n\t\t\t\t{sidebarItems.map((sb, index) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\t\t<div className={styles.sidebarItem} key={index}>\n\t\t\t\t\t\t\t<SidebarItemWrapper item={sb as SidebarItem<T, K>} params={params} data={data} />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t) : null;\n\n\treturn (\n\t\t<div className={`${styles.parent} imperiumContentWrapperParent`}>\n\t\t\t<div className={`${styles.wrapper} imperiumContentWrapper`}>\n\t\t\t\t<Header header={page.header} data={data} />\n\t\t\t\t<div className={`${styles.content} imperiumContent ${page.full && styles.contentFull}`}>{content}</div>\n\t\t\t</div>\n\t\t\t{sidebar}\n\t\t\t<DataHooks dataHooks={page.dataHooks || []} />\n\t\t</div>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAcU,MAAM,qDAAqD,EAAA;AAOrE,SAAA,qBAAA,CAA+B,KAAY,EAAA;AAC1C,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAI,IAAA,CAAC,KAAS,IAAA,CAAC,GAAI,CAAA,OAAA;AAAS,IAAA,OAAO,GAAI,CAAA,OAAA,CAAA;AACvC,EAAA,IAAI,CAAC,OAAA,CAAQ,KAAO,EAAA,GAAA,CAAI,OAAO,CAAG,EAAA;AACjC,IAAA,GAAA,CAAI,OAAU,GAAA,KAAA,CAAA;AAAA,GACf;AACA,EAAA,OAAO,GAAI,CAAA,OAAA,CAAA;AACZ,CAAA;AAEA,SAAA,oBAAA,CAA8B,UAA0B,IAAsB,EAAA;AAE7E,EAAA,SAAA,CAAU,QAAU,EAAA,IAAA,CAAK,GAAI,CAAA,qBAAqB,CAAC,CAAA,CAAA;AACpD,CAAA;AAEkF,SAAA,gBAAA,CAAA,EAAC,MAAM,MAAsC,EAAA,EAAA;AAC9H,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,IAAA,GAAO,mBAAoB,CAAA,EAAC,iBAAmB,EAAA,IAAA,CAAK,mBAAmB,sBAAwB,EAAA,IAAA,CAAK,sBAAwB,EAAA,MAAA,EAAO,CAAA,CAAA;AAEzI,EAAA,oBAAA,CAAqB,MAAM;AAC1B,IAAS,QAAA,CAAA,OAAA,CAAQ,SAAU,CAAA,MAAM,CAAC,CAAA,CAAA;AAAA,GAChC,EAAA,CAAC,QAAU,EAAA,MAAM,CAAC,CAAA,CAAA;AAErB,EAAM,MAAA,OAAA,GAAU,IAAK,CAAA,OAAA,CAAQ,IAAI,CAAA,CAAA;AACjC,EAAA,MAAM,YAAe,GAAA,iBAAA,CAAkB,IAAK,CAAA,OAAA,IAAW,EAAE,CAAA,CAAA;AAEzD,EAAA,MAAM,OACL,GAAA,YAAA,CAAa,MAAS,GAAA,CAAA,mBACpB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAI,SAAA,EAAW,GAAG,MAAO,CAAA,OAAA,CAAA,uBAAA,CAAA;AAAA,GAAA,kBACxB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAI,SAAA,EAAW,GAAG,MAAO,CAAA,aAAA,CAAA,6BAAA,CAAA;AAAA,GACzB,kBAAA,KAAA,CAAA,aAAA,CAAC,YAAG,SAAO,CACZ,GACC,YAAa,CAAA,GAAA,CAAI,CAAC,EAAA,EAAI,KAAU,KAAA;AAChC,IAAA,uBAEE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,WAAW,MAAO,CAAA,WAAA;AAAA,MAAa,GAAK,EAAA,KAAA;AAAA,KAAA,kBACvC,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA;AAAA,MAAmB,IAAM,EAAA,EAAA;AAAA,MAAyB,MAAA;AAAA,MAAgB,IAAA;AAAA,KAAY,CAChF,CAAA,CAAA;AAAA,GAED,CACF,CACG,GAAA,IAAA,CAAA;AAEL,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAI,SAAA,EAAW,GAAG,MAAO,CAAA,MAAA,CAAA,6BAAA,CAAA;AAAA,GAAA,kBACxB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAI,SAAA,EAAW,GAAG,MAAO,CAAA,OAAA,CAAA,uBAAA,CAAA;AAAA,GAAA,kBACxB,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IAAO,QAAQ,IAAK,CAAA,MAAA;AAAA,IAAQ,IAAA;AAAA,GAAY,mBACxC,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAI,WAAW,CAAG,EAAA,MAAA,CAAO,OAA2B,CAAA,iBAAA,EAAA,IAAA,CAAK,QAAQ,MAAO,CAAA,WAAA,CAAA,CAAA;AAAA,GAAA,EAAgB,OAAQ,CAClG,CACC,EAAA,OAAA,kBACA,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA;AAAA,IAAU,SAAA,EAAW,IAAK,CAAA,SAAA,IAAa,EAAC;AAAA,GAAG,CAC7C,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomSidebarItemComponent.js","sources":["../../../../src/content/components/CustomSidebarItemComponent.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport type {ContentData, CustomSidebarItem} from '../types';\n\ninterface CustomSidebarItemComponentProps<T extends DefineRouteOptions, K extends keyof T> {\n\titem: CustomSidebarItem<T, K>;\n\tdata: ContentData<T, K>;\n}\n\nexport function CustomSidebarItemComponent<T extends DefineRouteOptions, K extends keyof T>({item, data}: CustomSidebarItemComponentProps<T, K>) {\n\treturn item.render(data);\n}\n"],"names":[],"mappings":";;AAQ4F,SAAA,0BAAA,CAAA,EAAC,MAAM,IAA8C,EAAA,EAAA;AAChJ,EAAO,OAAA,IAAA,CAAK,OAAO,IAAI,CAAA,CAAA;AACxB;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import styles from './styles.module.css.js';
|
|
4
|
+
|
|
5
|
+
debug("imperium.layout.content.components.Header");
|
|
6
|
+
function Header({ data, header }) {
|
|
7
|
+
if (header) {
|
|
8
|
+
let headerInfo = {
|
|
9
|
+
title: ""
|
|
10
|
+
};
|
|
11
|
+
if (typeof header === "string") {
|
|
12
|
+
headerInfo.title = header;
|
|
13
|
+
} else if (typeof header === "function") {
|
|
14
|
+
headerInfo = header(data);
|
|
15
|
+
} else {
|
|
16
|
+
headerInfo = header;
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
19
|
+
className: `${styles.header} imperiumContentHeader`
|
|
20
|
+
}, /* @__PURE__ */ React.createElement("h2", null, headerInfo.title));
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Header };
|
|
26
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.js","sources":["../../../../src/content/components/Header.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport debug from 'debug';\nimport type {ContentData, ContentHeader} from '../types';\nimport styles from './styles.module.css';\n\nconst d = debug('imperium.layout.content.components.Header');\n\ninterface HeaderProps<T extends DefineRouteOptions, K extends keyof T> {\n\theader: ContentHeader<T, K>;\n\tdata: ContentData<T, K>;\n}\n\nexport function Header<T extends DefineRouteOptions, K extends keyof T>({data, header}: HeaderProps<T, K>) {\n\tif (header) {\n\t\tlet headerInfo = {\n\t\t\ttitle: '',\n\t\t};\n\t\tif (typeof header === 'string') {\n\t\t\theaderInfo.title = header;\n\t\t} else if (typeof header === 'function') {\n\t\t\theaderInfo = header(data);\n\t\t} else {\n\t\t\theaderInfo = header;\n\t\t}\n\t\treturn (\n\t\t\t<div className={`${styles.header} imperiumContentHeader`}>\n\t\t\t\t<h2>{headerInfo.title}</h2>\n\t\t\t</div>\n\t\t);\n\t}\n\treturn null;\n}\n"],"names":[],"mappings":";;;;AAKU,MAAM,2CAA2C,EAAA;AAOa,SAAA,MAAA,CAAA,EAAC,MAAM,MAA4B,EAAA,EAAA;AAC1G,EAAA,IAAI,MAAQ,EAAA;AACX,IAAA,IAAI,UAAa,GAAA;AAAA,MAChB,KAAO,EAAA,EAAA;AAAA,KACR,CAAA;AACA,IAAI,IAAA,OAAO,WAAW,QAAU,EAAA;AAC/B,MAAA,UAAA,CAAW,KAAQ,GAAA,MAAA,CAAA;AAAA,KACpB,MAAA,IAAW,OAAO,MAAA,KAAW,UAAY,EAAA;AACxC,MAAA,UAAA,GAAa,OAAO,IAAI,CAAA,CAAA;AAAA,KAClB,MAAA;AACN,MAAa,UAAA,GAAA,MAAA,CAAA;AAAA,KACd;AACA,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,SAAA,EAAW,GAAG,MAAO,CAAA,MAAA,CAAA,sBAAA,CAAA;AAAA,KAAA,kBACxB,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAI,UAAW,CAAA,KAAM,CACvB,CAAA,CAAA;AAAA,GAEF;AACA,EAAO,OAAA,IAAA,CAAA;AACR;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { Button } from 'semantic-ui-react';
|
|
4
|
+
import { getIcon, getColor, getRouteTo, getText } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
function PlainSidebarItem({ item, data }) {
|
|
7
|
+
const icon = getIcon(item, data);
|
|
8
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
9
|
+
fluid: true,
|
|
10
|
+
compact: true,
|
|
11
|
+
color: getColor(item, data),
|
|
12
|
+
icon: !!icon,
|
|
13
|
+
labelPosition: icon ? "left" : void 0,
|
|
14
|
+
as: Link,
|
|
15
|
+
to: getRouteTo(item, data)
|
|
16
|
+
}, icon, getText(item, data));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { PlainSidebarItem };
|
|
20
|
+
//# sourceMappingURL=PlainSidebarItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlainSidebarItem.js","sources":["../../../../src/content/components/PlainSidebarItem.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport {Link} from 'react-router-dom';\nimport {Button} from 'semantic-ui-react';\nimport type {ActionFormSidebarItem, ActionSidebarItem, ContentData, CustomSidebarItem, DividerSidebarItem, SidebarItem} from '../types';\nimport {getColor, getIcon, getRouteTo, getText} from '../utils';\n\ninterface PlainSidebarItemProps<T extends DefineRouteOptions, K extends keyof T> {\n\titem: Exclude<SidebarItem<T, K>, CustomSidebarItem<T, K> | ActionSidebarItem<T, K> | ActionFormSidebarItem<T, K> | DividerSidebarItem<T, K>>;\n\tdata: ContentData<T, K>;\n}\n\nexport function PlainSidebarItem<T extends DefineRouteOptions, K extends keyof T>({item, data}: PlainSidebarItemProps<T, K>) {\n\tconst icon = getIcon(item, data);\n\n\treturn (\n\t\t<Button fluid compact color={getColor(item, data)} icon={!!icon} labelPosition={icon ? 'left' : undefined} as={Link} to={getRouteTo(item, data)}>\n\t\t\t{icon}\n\t\t\t{getText(item, data)}\n\t\t</Button>\n\t);\n}\n"],"names":[],"mappings":";;;;;AAWkF,SAAA,gBAAA,CAAA,EAAC,MAAM,IAAoC,EAAA,EAAA;AAC5H,EAAM,MAAA,IAAA,GAAO,OAAQ,CAAA,IAAA,EAAM,IAAI,CAAA,CAAA;AAE/B,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IAAO,KAAK,EAAA,IAAA;AAAA,IAAC,OAAO,EAAA,IAAA;AAAA,IAAC,KAAA,EAAO,QAAS,CAAA,IAAA,EAAM,IAAI,CAAA;AAAA,IAAG,IAAA,EAAM,CAAC,CAAC,IAAA;AAAA,IAAM,aAAA,EAAe,OAAO,MAAS,GAAA,KAAA,CAAA;AAAA,IAAW,EAAI,EAAA,IAAA;AAAA,IAAM,EAAA,EAAI,UAAW,CAAA,IAAA,EAAM,IAAI,CAAA;AAAA,GAAA,EAC5I,IACA,EAAA,OAAA,CAAQ,IAAM,EAAA,IAAI,CACpB,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { Query } from 'mingo';
|
|
4
|
+
import { Divider } from 'semantic-ui-react';
|
|
5
|
+
import { useBuildContentData } from '../hooks/useBuildContentData.js';
|
|
6
|
+
import { isCustomSidebarItem, isActionSidebarItem, isActionFormSidebarItem, isDividerSidebarItem } from '../types.js';
|
|
7
|
+
import { ActionFormSidebarItemComponent } from './ActionFormSidebarItemComponent.js';
|
|
8
|
+
import { ActionSidebarItemComponent } from './ActionSidebarItemComponent.js';
|
|
9
|
+
import { CustomSidebarItemComponent } from './CustomSidebarItemComponent.js';
|
|
10
|
+
import { PlainSidebarItem } from './PlainSidebarItem.js';
|
|
11
|
+
|
|
12
|
+
debug("imperium.layout.content.components.SidebarItemWrapper");
|
|
13
|
+
function SidebarItemWrapper({ item, data: parentData, params }) {
|
|
14
|
+
const data = useBuildContentData({
|
|
15
|
+
data: parentData,
|
|
16
|
+
stateSelectorHook: item.stateSelectorHook,
|
|
17
|
+
permissionSelectorHook: item.permissionSelectorHook,
|
|
18
|
+
params
|
|
19
|
+
});
|
|
20
|
+
if (item.visible) {
|
|
21
|
+
if (typeof item.visible === "function") {
|
|
22
|
+
if (!item.visible(data))
|
|
23
|
+
return null;
|
|
24
|
+
} else {
|
|
25
|
+
const q = new Query(item.visible || {});
|
|
26
|
+
if (!q.test(data))
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (isCustomSidebarItem(item)) {
|
|
31
|
+
return /* @__PURE__ */ React.createElement(CustomSidebarItemComponent, {
|
|
32
|
+
item,
|
|
33
|
+
data
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (isActionSidebarItem(item)) {
|
|
37
|
+
return /* @__PURE__ */ React.createElement(ActionSidebarItemComponent, {
|
|
38
|
+
item,
|
|
39
|
+
data
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (isActionFormSidebarItem(item)) {
|
|
43
|
+
return /* @__PURE__ */ React.createElement(ActionFormSidebarItemComponent, {
|
|
44
|
+
item,
|
|
45
|
+
data
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (isDividerSidebarItem(item)) {
|
|
49
|
+
return /* @__PURE__ */ React.createElement(Divider, null);
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ React.createElement(PlainSidebarItem, {
|
|
52
|
+
item,
|
|
53
|
+
data
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { SidebarItemWrapper };
|
|
58
|
+
//# sourceMappingURL=SidebarItemWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarItemWrapper.js","sources":["../../../../src/content/components/SidebarItemWrapper.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport debug from 'debug';\nimport {Query} from 'mingo';\nimport {Divider} from 'semantic-ui-react';\nimport {useBuildContentData} from '../hooks/useBuildContentData';\nimport type {ContentData, RouteParameters, SidebarItem} from '../types';\nimport {isActionFormSidebarItem, isActionSidebarItem, isCustomSidebarItem, isDividerSidebarItem} from '../types';\nimport {ActionFormSidebarItemComponent} from './ActionFormSidebarItemComponent';\nimport {ActionSidebarItemComponent} from './ActionSidebarItemComponent';\nimport {CustomSidebarItemComponent} from './CustomSidebarItemComponent';\nimport {PlainSidebarItem} from './PlainSidebarItem';\n\nconst d = debug('imperium.layout.content.components.SidebarItemWrapper');\n\ninterface SidebarItemWrapperProps<T extends DefineRouteOptions, K extends keyof T> {\n\titem: SidebarItem<T, K>;\n\tdata?: ContentData<T, K>;\n\tparams: RouteParameters<T[K]['params']>;\n}\n\nexport function SidebarItemWrapper<T extends DefineRouteOptions, K extends keyof T>({item, data: parentData, params}: SidebarItemWrapperProps<T, K>) {\n\tconst data = useBuildContentData({\n\t\tdata: parentData,\n\t\tstateSelectorHook: item.stateSelectorHook,\n\t\tpermissionSelectorHook: item.permissionSelectorHook,\n\t\tparams,\n\t});\n\n\t// Check if visible\n\tif (item.visible) {\n\t\tif (typeof item.visible === 'function') {\n\t\t\tif (!item.visible(data)) return null;\n\t\t} else {\n\t\t\tconst q = new Query(item.visible || {});\n\t\t\tif (!q.test(data)) return null;\n\t\t}\n\t}\n\n\tif (isCustomSidebarItem(item)) {\n\t\treturn <CustomSidebarItemComponent item={item} data={data} />;\n\t}\n\n\tif (isActionSidebarItem(item)) {\n\t\t// @ts-ignore I'm not sure why this error is occurring -mk\n\t\treturn <ActionSidebarItemComponent item={item} data={data} />;\n\t}\n\n\tif (isActionFormSidebarItem(item)) {\n\t\t// @ts-ignore I'm not sure why this error is occurring -mk\n\t\treturn <ActionFormSidebarItemComponent item={item} data={data} />;\n\t}\n\n\tif (isDividerSidebarItem(item)) {\n\t\treturn <Divider />;\n\t}\n\n\t// @ts-ignore These types should work, not sure why it's not. Runtime code is fine.\n\treturn <PlainSidebarItem item={item} data={data} />;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAYU,MAAM,uDAAuD,EAAA;AAQhE,SAAA,kBAAA,CAA6E,EAAC,IAAA,EAAM,IAAM,EAAA,UAAA,EAAY,MAAwC,EAAA,EAAA;AACpJ,EAAA,MAAM,OAAO,mBAAoB,CAAA;AAAA,IAChC,IAAM,EAAA,UAAA;AAAA,IACN,mBAAmB,IAAK,CAAA,iBAAA;AAAA,IACxB,wBAAwB,IAAK,CAAA,sBAAA;AAAA,IAC7B,MAAA;AAAA,GACA,CAAA,CAAA;AAGD,EAAA,IAAI,KAAK,OAAS,EAAA;AACjB,IAAI,IAAA,OAAO,IAAK,CAAA,OAAA,KAAY,UAAY,EAAA;AACvC,MAAI,IAAA,CAAC,IAAK,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAG,QAAO,OAAA,IAAA,CAAA;AAAA,KAC1B,MAAA;AACN,MAAA,MAAM,IAAI,IAAI,KAAA,CAAM,IAAK,CAAA,OAAA,IAAW,EAAE,CAAA,CAAA;AACtC,MAAI,IAAA,CAAC,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA;AAAG,QAAO,OAAA,IAAA,CAAA;AAAA,KAC3B;AAAA,GACD;AAEA,EAAI,IAAA,mBAAA,CAAoB,IAAI,CAAG,EAAA;AAC9B,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,0BAAA,EAAA;AAAA,MAA2B,IAAA;AAAA,MAAY,IAAA;AAAA,KAAY,CAAA,CAAA;AAAA,GAC5D;AAEA,EAAI,IAAA,mBAAA,CAAoB,IAAI,CAAG,EAAA;AAE9B,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,0BAAA,EAAA;AAAA,MAA2B,IAAA;AAAA,MAAY,IAAA;AAAA,KAAY,CAAA,CAAA;AAAA,GAC5D;AAEA,EAAI,IAAA,uBAAA,CAAwB,IAAI,CAAG,EAAA;AAElC,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,8BAAA,EAAA;AAAA,MAA+B,IAAA;AAAA,MAAY,IAAA;AAAA,KAAY,CAAA,CAAA;AAAA,GAChE;AAEA,EAAI,IAAA,oBAAA,CAAqB,IAAI,CAAG,EAAA;AAC/B,IAAA,2CAAQ,OAAQ,EAAA,IAAA,CAAA,CAAA;AAAA,GACjB;AAGA,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA;AAAA,IAAiB,IAAA;AAAA,IAAY,IAAA;AAAA,GAAY,CAAA,CAAA;AAClD;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import styleInject from './../../external/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".styles-module_parent__OuBHK {\n\tflex: 1;\n\tdisplay: flex;\n\tflex-direction: row;\n\theight: 100%;\n}\n\n.styles-module_wrapper__2DEM0 {\n\tflex: 1;\n\tflex-basis: calc(65%);\n}\n\n.styles-module_content__PWtmR {\n\tmargin: 0 0.8rem 0.8rem 0.8rem;\n}\n\n.styles-module_contentFull__q2jrq {\n\theight: 100%;\n\tmargin: 0 0;\n}\n\n.styles-module_header__4mpgB {\n\tpadding: 0.8rem 0.8rem 0 0.8rem;\n\tmargin-bottom: 0.8rem;\n}\n\n.styles-module_sidebar__H9Cuy {\n\tmin-width: 250px;\n\tpadding: 10px;\n\toverflow-y: auto;\n\toverflow-x: hidden;\n}\n\n.styles-module_sidebarItem__-JRCt {\n\tmargin-bottom: 5px;\n}\n\n.styles-module_actionsHeader__Ke2ht {\n\tdisplay: none;\n}\n\n@media only screen and (max-width: 768px) {\n\t.styles-module_parent__OuBHK {\n\t\tflex-direction: column;\n\t\theight: auto;\n\t}\n\t.styles-module_wrapper__2DEM0 {\n\t\tborder-right: none;\n\t\tpadding-bottom: 20px;\n\t}\n\t.styles-module_sidebar__H9Cuy {\n\t\tmin-width: auto;\n\t}\n\t.styles-module_actionsHeader__Ke2ht {\n\t\tdisplay: block;\n\t\tmargin-bottom: 5px;\n\t}\n}\n";
|
|
4
|
+
var styles = {"parent":"styles-module_parent__OuBHK","wrapper":"styles-module_wrapper__2DEM0","content":"styles-module_content__PWtmR","contentFull":"styles-module_contentFull__q2jrq","header":"styles-module_header__4mpgB","sidebar":"styles-module_sidebar__H9Cuy","sidebarItem":"styles-module_sidebarItem__-JRCt","actionsHeader":"styles-module_actionsHeader__Ke2ht"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
8
|
+
//# sourceMappingURL=styles.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,wBAAwB,uDAAyD;AACjF;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { ContentComponent } from './components/ContentComponent.js';
|
|
4
|
+
import { isPage } from './types.js';
|
|
5
|
+
|
|
6
|
+
debug("imperium.layout.content.createPages");
|
|
7
|
+
function createPages(routes, pages) {
|
|
8
|
+
const renderRoutePropsObj = Object.keys(routes.types).reduce((memo, key) => {
|
|
9
|
+
return {
|
|
10
|
+
...memo,
|
|
11
|
+
[key]: (params) => {
|
|
12
|
+
const pg = pages[key];
|
|
13
|
+
if (isPage(pg)) {
|
|
14
|
+
return /* @__PURE__ */ React.createElement(ContentComponent, {
|
|
15
|
+
page: pg,
|
|
16
|
+
params
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ React.createElement(ContentComponent, {
|
|
20
|
+
page: {
|
|
21
|
+
content: pg
|
|
22
|
+
},
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, {});
|
|
28
|
+
return routes.renderRouteProps(renderRoutePropsObj);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { createPages };
|
|
32
|
+
//# sourceMappingURL=createPages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPages.js","sources":["../../../src/content/createPages.tsx"],"sourcesContent":["import type {Routes, DefineRouteOptions, KeyedRouteRenderFns} from '@imperium/router';\nimport debug from 'debug';\nimport {ContentComponent} from './components/ContentComponent';\nimport type {Pages, RouteParameters} from './types';\nimport {isPage} from './types';\n\nconst d = debug('imperium.layout.content.createPages');\n\nexport function createPages<T extends DefineRouteOptions>(routes: Routes<T>, pages: Pages<T>) {\n\tconst renderRoutePropsObj = Object.keys(routes.types).reduce((memo, key) => {\n\t\treturn {\n\t\t\t...memo,\n\t\t\t[key]: (params: RouteParameters<T[typeof key]['params']>) => {\n\t\t\t\tconst pg = pages[key];\n\t\t\t\tif (isPage(pg)) {\n\t\t\t\t\treturn <ContentComponent page={pg} params={params} />;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<ContentComponent\n\t\t\t\t\t\tpage={{\n\t\t\t\t\t\t\tcontent: pg,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tparams={params}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}, {} as KeyedRouteRenderFns<T>);\n\n\treturn routes.renderRouteProps(renderRoutePropsObj);\n}\n"],"names":[],"mappings":";;;;;AAMU,MAAM,qCAAqC,EAAA;AAE9C,SAAA,WAAA,CAAmD,QAAmB,KAAiB,EAAA;AAC7F,EAAM,MAAA,mBAAA,GAAsB,OAAO,IAAK,CAAA,MAAA,CAAO,KAAK,CAAE,CAAA,MAAA,CAAO,CAAC,IAAA,EAAM,GAAQ,KAAA;AAC3E,IAAO,OAAA;AAAA,MACH,GAAA,IAAA;AAAA,MACF,CAAA,GAAA,GAAM,CAAC,MAAqD,KAAA;AAC5D,QAAA,MAAM,KAAK,KAAM,CAAA,GAAA,CAAA,CAAA;AACjB,QAAI,IAAA,MAAA,CAAO,EAAE,CAAG,EAAA;AACf,UAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA;AAAA,YAAiB,IAAM,EAAA,EAAA;AAAA,YAAI,MAAA;AAAA,WAAgB,CAAA,CAAA;AAAA,SACpD;AACA,QAAA,uBACE,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA;AAAA,UACA,IAAM,EAAA;AAAA,YACL,OAAS,EAAA,EAAA;AAAA,WACV;AAAA,UACA,MAAA;AAAA,SACD,CAAA,CAAA;AAAA,OAEF;AAAA,KACD,CAAA;AAAA,GACD,EAAG,EAA4B,CAAA,CAAA;AAE/B,EAAO,OAAA,MAAA,CAAO,iBAAiB,mBAAmB,CAAA,CAAA;AACnD;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dividerSidebarItem.js","sources":["../../../src/content/dividerSidebarItem.ts"],"sourcesContent":["import type {DividerSidebarItem} from './types';\n\nexport const dividerSidebarItem: DividerSidebarItem<any, any> = {\n\ttext: '',\n\tdivider: true,\n};\n"],"names":[],"mappings":"AAEO,MAAM,kBAAmD,GAAA;AAAA,EAC/D,IAAM,EAAA,EAAA;AAAA,EACN,OAAS,EAAA,IAAA;AACV;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useBuildData } from '../../hooks/useBuildData.js';
|
|
2
|
+
|
|
3
|
+
function useBuildContentData({
|
|
4
|
+
data,
|
|
5
|
+
stateSelectorHook,
|
|
6
|
+
permissionSelectorHook,
|
|
7
|
+
routeItem,
|
|
8
|
+
params
|
|
9
|
+
}) {
|
|
10
|
+
const buildData = useBuildData({ data, stateSelectorHook, permissionSelectorHook, routeItem });
|
|
11
|
+
return {
|
|
12
|
+
...buildData,
|
|
13
|
+
params
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { useBuildContentData };
|
|
18
|
+
//# sourceMappingURL=useBuildContentData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBuildContentData.js","sources":["../../../../src/content/hooks/useBuildContentData.ts"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport type {UseBuildDataParams} from '../../hooks/useBuildData';\nimport {useBuildData} from '../../hooks/useBuildData';\nimport type {ContentData, RouteParameters} from '../types';\n\ninterface UseBuildContentDataParams<T extends DefineRouteOptions, K extends keyof T> extends UseBuildDataParams {\n\tdata?: ContentData<T, K>;\n\tparams: RouteParameters<T[K]['params']>;\n}\n\nexport function useBuildContentData<T extends DefineRouteOptions, K extends keyof T>({\n\tdata,\n\tstateSelectorHook,\n\tpermissionSelectorHook,\n\trouteItem,\n\tparams,\n}: UseBuildContentDataParams<T, K>) {\n\tconst buildData = useBuildData({data, stateSelectorHook, permissionSelectorHook, routeItem});\n\treturn {\n\t\t...buildData,\n\t\tparams,\n\t};\n}\n"],"names":[],"mappings":";;AAUqF,SAAA,mBAAA,CAAA;AAAA,EACpF,IAAA;AAAA,EACA,iBAAA;AAAA,EACA,sBAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,CACmC,EAAA;AACnC,EAAA,MAAM,YAAY,YAAa,CAAA,EAAC,MAAM,iBAAmB,EAAA,sBAAA,EAAwB,WAAU,CAAA,CAAA;AAC3F,EAAO,OAAA;AAAA,IACH,GAAA,SAAA;AAAA,IACH,MAAA;AAAA,GACD,CAAA;AACD;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function isPage(value) {
|
|
2
|
+
return !!value.content;
|
|
3
|
+
}
|
|
4
|
+
function isActionSidebarItem(value) {
|
|
5
|
+
return !!value.onClick;
|
|
6
|
+
}
|
|
7
|
+
function isActionFormSidebarItem(value) {
|
|
8
|
+
return !!value.form;
|
|
9
|
+
}
|
|
10
|
+
function isCustomSidebarItem(value) {
|
|
11
|
+
return !!value.render;
|
|
12
|
+
}
|
|
13
|
+
function isDividerSidebarItem(value) {
|
|
14
|
+
return value.divider;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { isActionFormSidebarItem, isActionSidebarItem, isCustomSidebarItem, isDividerSidebarItem, isPage };
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/content/types.ts"],"sourcesContent":["import type {DefineRouteOptions, ParametersFromAssertion} from '@imperium/router';\nimport type React from 'react';\nimport type {SemanticCOLORS, SemanticICONS} from 'semantic-ui-react';\nimport type {RouteItem, VisibilityItem, WeightedItem} from '../commonItems';\nimport type {DataHookItem} from '../datahooks/types';\nimport type {Data, PermissionSelectorHook, StateSelectorHook} from '../types';\n\nexport type RouteParameters<T extends readonly string[] | undefined> = T extends readonly string[] ? ParametersFromAssertion<T> : never;\n\nexport interface ContentData<T extends DefineRouteOptions, K extends keyof T> extends Data {\n\tparams: RouteParameters<T[K]['params']>;\n}\n\nexport type Content<T extends DefineRouteOptions, K extends keyof T> = (data: ContentData<T, K>) => JSX.Element;\n\nexport interface BaseSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends WeightedItem, VisibilityItem {\n\ttext: string | ((data: ContentData<T, K>) => string);\n\ticon?: SemanticICONS | ((data: ContentData<T, K>) => SemanticICONS);\n\tcolor?: SemanticCOLORS | ((data: ContentData<T, K>) => SemanticCOLORS);\n}\n\nexport interface DividerSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends BaseSidebarItem<T, K> {\n\tdivider: boolean;\n}\n\nexport interface ActionSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends BaseSidebarItem<T, K> {\n\tonClick: (data: ContentData<T, K>) => void;\n}\n\ninterface ActionFormSidebarItemFormParams<T extends DefineRouteOptions, K extends keyof T> {\n\tvalues: Record<string, any>;\n\thandleChange: (e: React.ChangeEvent<any>) => void;\n\tfieldError: (fieldName: string | number) => boolean;\n\tdata: ContentData<T, K>;\n}\nexport interface ActionFormSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends BaseSidebarItem<T, K> {\n\tform: (params: ActionFormSidebarItemFormParams<T, K>) => JSX.Element | null;\n\tinitialValues?: Record<string, any> | ((data: ContentData<T, K>) => Record<string, any>);\n\tonSubmit?: (values: Record<string, any>, data: ContentData<T, K>) => void;\n\tvalidationSchema?: any;\n}\n\nexport interface CustomSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends WeightedItem, VisibilityItem {\n\trender: (data: ContentData<T, K>) => JSX.Element | null;\n}\n\nexport type SidebarItem<T extends DefineRouteOptions, K extends keyof T> =\n\t| (BaseSidebarItem<T, K> & RouteItem<ContentData<T, K>>)\n\t| ActionSidebarItem<T, K>\n\t| CustomSidebarItem<T, K>\n\t| ActionFormSidebarItem<T, K>\n\t| DividerSidebarItem<T, K>;\n\nexport type ContentHeader<T extends DefineRouteOptions, K extends keyof T> =\n\t| string\n\t| {title: string; icon?: string} // TODO icon should probably be SemanticICONS\n\t| ((data: ContentData<T, K>) => {title: string; icon?: string})\n\t| undefined;\n\nexport interface Page<T extends DefineRouteOptions, K extends keyof T> {\n\tdataHooks?: DataHookItem[];\n\tstateSelectorHook?: StateSelectorHook | StateSelectorHook[];\n\tpermissionSelectorHook?: PermissionSelectorHook | PermissionSelectorHook[];\n\tcontent: Content<T, K>;\n\theader?: ContentHeader<T, K>;\n\tsidebar?: SidebarItem<T, K>[];\n\tfull?: boolean;\n}\n\nexport type Pages<T extends DefineRouteOptions> = {\n\t[key in keyof T]: Page<T, key> | Content<T, key>;\n};\n\nexport function isPage<T extends DefineRouteOptions, K extends keyof T>(value: any): value is Page<T, K> {\n\treturn !!(value as Page<T, K>).content;\n}\n\nexport function isActionSidebarItem<T extends DefineRouteOptions, K extends keyof T>(value: any): value is ActionSidebarItem<T, K> {\n\treturn !!(value as ActionSidebarItem<T, K>).onClick;\n}\n\nexport function isActionFormSidebarItem<T extends DefineRouteOptions, K extends keyof T>(value: any): value is ActionFormSidebarItem<T, K> {\n\treturn !!(value as ActionFormSidebarItem<T, K>).form;\n}\n\nexport function isCustomSidebarItem<T extends DefineRouteOptions, K extends keyof T>(value: any): value is CustomSidebarItem<T, K> {\n\treturn !!(value as CustomSidebarItem<T, K>).render;\n}\n\nexport function isDividerSidebarItem<T extends DefineRouteOptions, K extends keyof T>(value: any): value is DividerSidebarItem<T, K> {\n\treturn (value as DividerSidebarItem<T, K>).divider;\n}\n"],"names":[],"mappings":"AAyEO,SAAA,MAAA,CAAiE,KAAiC,EAAA;AACxG,EAAO,OAAA,CAAC,CAAE,KAAqB,CAAA,OAAA,CAAA;AAChC,CAAA;AAEO,SAAA,mBAAA,CAA8E,KAA8C,EAAA;AAClI,EAAO,OAAA,CAAC,CAAE,KAAkC,CAAA,OAAA,CAAA;AAC7C,CAAA;AAEO,SAAA,uBAAA,CAAkF,KAAkD,EAAA;AAC1I,EAAO,OAAA,CAAC,CAAE,KAAsC,CAAA,IAAA,CAAA;AACjD,CAAA;AAEO,SAAA,mBAAA,CAA8E,KAA8C,EAAA;AAClI,EAAO,OAAA,CAAC,CAAE,KAAkC,CAAA,MAAA,CAAA;AAC7C,CAAA;AAEO,SAAA,oBAAA,CAA+E,KAA+C,EAAA;AACpI,EAAA,OAAQ,KAAmC,CAAA,OAAA,CAAA;AAC5C;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from 'semantic-ui-react';
|
|
3
|
+
|
|
4
|
+
function getIcon(item, data) {
|
|
5
|
+
if (item.icon) {
|
|
6
|
+
const iconName = typeof item.icon === "function" ? item.icon(data) : item.icon;
|
|
7
|
+
return /* @__PURE__ */ React.createElement(Icon, {
|
|
8
|
+
name: iconName
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function getRouteTo(item, data) {
|
|
14
|
+
if (item.to) {
|
|
15
|
+
return typeof item.to === "function" ? item.to(data) : item.to;
|
|
16
|
+
}
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
function getText(item, data) {
|
|
20
|
+
return typeof item.text === "function" ? item.text(data) : item.text;
|
|
21
|
+
}
|
|
22
|
+
function getColor(item, data) {
|
|
23
|
+
if (!item.color)
|
|
24
|
+
return "blue";
|
|
25
|
+
return typeof item.color === "function" ? item.color(data) : item.color;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { getColor, getIcon, getRouteTo, getText };
|
|
29
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/content/utils.tsx"],"sourcesContent":["import type {DefineRouteOptions} from '@imperium/router';\nimport {Icon, SemanticCOLORS} from 'semantic-ui-react';\nimport type {RouteItem} from '../commonItems';\nimport type {BaseSidebarItem, ContentData} from './types';\n\nexport function getIcon<T extends DefineRouteOptions, K extends keyof T>(item: BaseSidebarItem<T, K>, data: ContentData<T, K>) {\n\tif (item.icon) {\n\t\tconst iconName = typeof item.icon === 'function' ? item.icon(data) : item.icon;\n\t\treturn <Icon name={iconName} />;\n\t}\n\treturn null;\n}\n\nexport function getRouteTo<T extends DefineRouteOptions, K extends keyof T>(item: RouteItem<ContentData<T, K>>, data: ContentData<T, K>) {\n\tif (item.to) {\n\t\treturn typeof item.to === 'function' ? item.to(data) : item.to;\n\t}\n\treturn '';\n}\n\nexport function getText<T extends DefineRouteOptions, K extends keyof T>(item: BaseSidebarItem<T, K>, data: ContentData<T, K>) {\n\treturn typeof item.text === 'function' ? item.text(data) : item.text;\n}\n\nexport function getColor<T extends DefineRouteOptions, K extends keyof T>(item: BaseSidebarItem<T, K>, data: ContentData<T, K>): SemanticCOLORS {\n\tif (!item.color) return 'blue';\n\treturn typeof item.color === 'function' ? item.color(data) : item.color;\n}\n"],"names":[],"mappings":";;;AAKO,SAAA,OAAA,CAAkE,MAA6B,IAAyB,EAAA;AAC9H,EAAA,IAAI,KAAK,IAAM,EAAA;AACd,IAAM,MAAA,QAAA,GAAW,OAAO,IAAK,CAAA,IAAA,KAAS,aAAa,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA,GAAI,IAAK,CAAA,IAAA,CAAA;AAC1E,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,MAAK,IAAM,EAAA,QAAA;AAAA,KAAU,CAAA,CAAA;AAAA,GAC9B;AACA,EAAO,OAAA,IAAA,CAAA;AACR,CAAA;AAEO,SAAA,UAAA,CAAqE,MAAoC,IAAyB,EAAA;AACxI,EAAA,IAAI,KAAK,EAAI,EAAA;AACZ,IAAO,OAAA,OAAO,KAAK,EAAO,KAAA,UAAA,GAAa,KAAK,EAAG,CAAA,IAAI,IAAI,IAAK,CAAA,EAAA,CAAA;AAAA,GAC7D;AACA,EAAO,OAAA,EAAA,CAAA;AACR,CAAA;AAEO,SAAA,OAAA,CAAkE,MAA6B,IAAyB,EAAA;AAC9H,EAAO,OAAA,OAAO,KAAK,IAAS,KAAA,UAAA,GAAa,KAAK,IAAK,CAAA,IAAI,IAAI,IAAK,CAAA,IAAA,CAAA;AACjE,CAAA;AAEO,SAAA,QAAA,CAAmE,MAA6B,IAAyC,EAAA;AAC/I,EAAA,IAAI,CAAC,IAAK,CAAA,KAAA;AAAO,IAAO,OAAA,MAAA,CAAA;AACxB,EAAO,OAAA,OAAO,KAAK,KAAU,KAAA,UAAA,GAAa,KAAK,KAAM,CAAA,IAAI,IAAI,IAAK,CAAA,KAAA,CAAA;AACnE;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import compose from 'lodash/fp/compose.js';
|
|
4
|
+
import { useLocation } from 'react-router-dom';
|
|
5
|
+
import { ExecuteDataHook } from './ExecuteDataHook.js';
|
|
6
|
+
|
|
7
|
+
debug("imperium.layout.datahooks.DataHooks");
|
|
8
|
+
function DataHooks({ dataHooks }) {
|
|
9
|
+
const { pathname } = useLocation();
|
|
10
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, dataHooks.map((hook, index) => {
|
|
11
|
+
if (typeof hook === "function") {
|
|
12
|
+
return /* @__PURE__ */ React.createElement(ExecuteDataHook, {
|
|
13
|
+
key: index,
|
|
14
|
+
dataHook: hook
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const fn = Array.isArray(hook.routeMatch) ? compose(hook.routeMatch) : hook.routeMatch;
|
|
18
|
+
const routeParams = fn(pathname);
|
|
19
|
+
if (Array.isArray(hook.dataHook)) {
|
|
20
|
+
return /* @__PURE__ */ React.createElement(Fragment, {
|
|
21
|
+
key: index
|
|
22
|
+
}, hook.dataHook.map((dh, index2) => {
|
|
23
|
+
return /* @__PURE__ */ React.createElement(ExecuteDataHook, {
|
|
24
|
+
key: index2,
|
|
25
|
+
dataHook: dh,
|
|
26
|
+
routeParams
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ React.createElement(ExecuteDataHook, {
|
|
31
|
+
dataHook: hook.dataHook,
|
|
32
|
+
key: index,
|
|
33
|
+
routeParams
|
|
34
|
+
});
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { DataHooks };
|
|
39
|
+
//# sourceMappingURL=DataHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataHooks.js","sources":["../../../src/datahooks/DataHooks.tsx"],"sourcesContent":["import debug from 'debug';\nimport compose from 'lodash/fp/compose.js';\nimport {Fragment} from 'react';\nimport {useLocation} from 'react-router-dom';\nimport {ExecuteDataHook} from './ExecuteDataHook';\nimport type {DataHookItem} from './types';\n\nconst d = debug('imperium.layout.datahooks.DataHooks');\n\ninterface DataHooksProps {\n\tdataHooks: DataHookItem[];\n}\n\n/**\n * Renders layout data hooks. These hooks should return nothing. All interaction should be in side effects, usually retrieving data and setting Redux state.\n * @param dataHooks\n * @constructor\n */\nexport function DataHooks({dataHooks}: DataHooksProps) {\n\tconst {pathname} = useLocation();\n\n\treturn (\n\t\t<>\n\t\t\t{dataHooks.map((hook, index) => {\n\t\t\t\tif (typeof hook === 'function') {\n\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\treturn <ExecuteDataHook key={index} dataHook={hook} />;\n\t\t\t\t}\n\t\t\t\tconst fn = Array.isArray(hook.routeMatch) ? compose(hook.routeMatch) : hook.routeMatch;\n\t\t\t\tconst routeParams = fn(pathname);\n\t\t\t\tif (Array.isArray(hook.dataHook)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\t\t<Fragment key={index}>\n\t\t\t\t\t\t\t{hook.dataHook.map((dh, index2) => {\n\t\t\t\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\t\t\t\treturn <ExecuteDataHook key={index2} dataHook={dh} routeParams={routeParams} />;\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\treturn <ExecuteDataHook dataHook={hook.dataHook} key={index} routeParams={routeParams} />;\n\t\t\t})}\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;;;;AAOU,MAAM,qCAAqC,EAAA;AAW9C,SAAA,SAAA,CAAmB,EAAC,SAA4B,EAAA,EAAA;AACtD,EAAM,MAAA,EAAC,aAAY,WAAY,EAAA,CAAA;AAE/B,EAAA,uBAEG,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,SAAA,CAAU,GAAI,CAAA,CAAC,MAAM,KAAU,KAAA;AAC/B,IAAI,IAAA,OAAO,SAAS,UAAY,EAAA;AAE/B,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,QAAgB,GAAK,EAAA,KAAA;AAAA,QAAO,QAAU,EAAA,IAAA;AAAA,OAAM,CAAA,CAAA;AAAA,KACrD;AACA,IAAM,MAAA,EAAA,GAAK,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,UAAU,IAAI,OAAQ,CAAA,IAAA,CAAK,UAAU,CAAA,GAAI,IAAK,CAAA,UAAA,CAAA;AAC5E,IAAM,MAAA,WAAA,GAAc,GAAG,QAAQ,CAAA,CAAA;AAC/B,IAAA,IAAI,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,QAAQ,CAAG,EAAA;AACjC,MAAA,uBAEE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,QAAS,GAAK,EAAA,KAAA;AAAA,OAAA,EACb,IAAK,CAAA,QAAA,CAAS,GAAI,CAAA,CAAC,IAAI,MAAW,KAAA;AAElC,QAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,UAAgB,GAAK,EAAA,MAAA;AAAA,UAAQ,QAAU,EAAA,EAAA;AAAA,UAAI,WAAA;AAAA,SAA0B,CAAA,CAAA;AAAA,OAC7E,CACF,CAAA,CAAA;AAAA,KAEF;AAEA,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,MAAgB,UAAU,IAAK,CAAA,QAAA;AAAA,MAAU,GAAK,EAAA,KAAA;AAAA,MAAO,WAAA;AAAA,KAA0B,CAAA,CAAA;AAAA,GACvF,CACF,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecuteDataHook.js","sources":["../../../src/datahooks/ExecuteDataHook.tsx"],"sourcesContent":["import type {DataHook} from './types';\n\ninterface ExecuteDataHookProps {\n\tdataHook: DataHook;\n\trouteParams?: any;\n}\n\nexport function ExecuteDataHook({dataHook, routeParams}: ExecuteDataHookProps) {\n\tdataHook(routeParams);\n\treturn null;\n}\n"],"names":[],"mappings":";;AAOgC,SAAA,eAAA,CAAA,EAAC,UAAU,WAAoC,EAAA,EAAA;AAC9E,EAAA,QAAA,CAAS,WAAW,CAAA,CAAA;AACpB,EAAO,OAAA,IAAA,CAAA;AACR;;;;"}
|