@tsed/react-formio 3.0.0-alpha.10 → 3.0.0-alpha.12
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/atoms/icon/Icon.js.map +1 -1
- package/dist/chunks/index.js +33 -30
- package/dist/chunks/index.js.map +1 -1
- package/dist/chunks/index.module.js +16 -16
- package/dist/chunks/index.module.js.map +1 -1
- package/dist/chunks/react-select-animated.esm.js +1204 -1101
- package/dist/chunks/react-select-animated.esm.js.map +1 -1
- package/dist/hooks/keyboard.constants.d.ts +38 -0
- package/dist/hooks/keyboard.constants.js +7 -0
- package/dist/hooks/keyboard.constants.js.map +1 -0
- package/dist/hooks/useKeyboardControls.d.ts +12 -0
- package/dist/hooks/useKeyboardControls.js +35 -0
- package/dist/hooks/useKeyboardControls.js.map +1 -0
- package/dist/hooks/useTooltip.js.map +1 -1
- package/dist/interfaces/Operation.d.ts +12 -2
- package/dist/molecules/alert/Alert.js.map +1 -1
- package/dist/molecules/button/Button.d.ts +18 -5
- package/dist/molecules/button/Button.js +22 -26
- package/dist/molecules/button/Button.js.map +1 -1
- package/dist/molecules/card/Card.js +7 -5
- package/dist/molecules/card/Card.js.map +1 -1
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/InputTags.js +14 -14
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +26 -26
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ReactTags.js +289 -300
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -1
- package/dist/molecules/forms/input-text/InputText.js +3 -3
- package/dist/molecules/forms/input-text/InputText.js.map +1 -1
- package/dist/molecules/forms/select/Select.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +71 -73
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.js +13 -14
- package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/choices.template.js +2340 -2257
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
- package/dist/molecules/loader/Loader.js.map +1 -1
- package/dist/molecules/modal/Modal.js +23 -24
- package/dist/molecules/modal/Modal.js.map +1 -1
- package/dist/molecules/pagination/Pagination.js +19 -19
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/pagination/PaginationButton.js.map +1 -1
- package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -1
- package/dist/molecules/table/Table.d.ts +11 -3
- package/dist/molecules/table/Table.js +31 -32
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -1
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellFooter.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellOperations.d.ts +12 -4
- package/dist/molecules/table/components/DefaultCellOperations.js +13 -7
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.d.ts +12 -4
- package/dist/molecules/table/components/DefaultOperationButton.js +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/RangeFilter.js +23 -24
- package/dist/molecules/table/filters/RangeFilter.js.map +1 -1
- package/dist/molecules/table/filters/SelectFilter.js +11 -13
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
- package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +12 -4
- package/dist/molecules/table/hooks/useTable.js +7 -7
- package/dist/molecules/table/hooks/useTable.js.map +1 -1
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +20 -21
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/Tab.d.ts +13 -0
- package/dist/molecules/tabs/Tab.js +66 -0
- package/dist/molecules/tabs/Tab.js.map +1 -0
- package/dist/molecules/tabs/TabList.d.ts +2 -0
- package/dist/molecules/tabs/TabList.js +23 -0
- package/dist/molecules/tabs/TabList.js.map +1 -0
- package/dist/molecules/tabs/TabPanel.d.ts +9 -0
- package/dist/molecules/tabs/TabPanel.js +27 -0
- package/dist/molecules/tabs/TabPanel.js.map +1 -0
- package/dist/molecules/tabs/Tabs.d.ts +4 -16
- package/dist/molecules/tabs/Tabs.js +7 -67
- package/dist/molecules/tabs/Tabs.js.map +1 -1
- package/dist/molecules/tabs/TabsBody.d.ts +1 -0
- package/dist/molecules/tabs/TabsBody.js +10 -0
- package/dist/molecules/tabs/TabsBody.js.map +1 -0
- package/dist/molecules/tabs/TabsLegacy.d.ts +17 -0
- package/dist/molecules/tabs/TabsLegacy.js +49 -0
- package/dist/molecules/tabs/TabsLegacy.js.map +1 -0
- package/dist/molecules/tabs/all.d.ts +5 -0
- package/dist/molecules/tabs/all.js +13 -0
- package/dist/molecules/tabs/all.js.map +1 -0
- package/dist/molecules/tabs/context/TabControl.d.ts +52 -0
- package/dist/molecules/tabs/context/TabControl.js +85 -0
- package/dist/molecules/tabs/context/TabControl.js.map +1 -0
- package/dist/molecules/tabs/hooks/tabControl.d.ts +44 -0
- package/dist/molecules/tabs/hooks/tabControl.js +34 -0
- package/dist/molecules/tabs/hooks/tabControl.js.map +1 -0
- package/dist/organisms/form/Form.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.js +41 -41
- package/dist/organisms/form/access/FormAccess.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.schema.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.utils.js +2 -2
- package/dist/organisms/form/access/FormAccess.utils.js.map +1 -1
- package/dist/organisms/form/{action → actions}/FormAction.js +7 -8
- package/dist/organisms/form/actions/FormAction.js.map +1 -0
- package/dist/organisms/form/builder/FormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.d.ts +3 -1
- package/dist/organisms/form/builder/FormEdit.js +38 -35
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.reducer.js.map +1 -1
- package/dist/organisms/form/builder/FormEditCtas.js +34 -34
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
- package/dist/organisms/form/builder/FormParameters.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.js +41 -38
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.js +1 -1
- package/dist/organisms/form/builder/useFormEdit.js.map +1 -1
- package/dist/organisms/form/exports/FormExport.d.ts +5 -0
- package/dist/organisms/form/exports/FormExport.js +55 -0
- package/dist/organisms/form/exports/FormExport.js.map +1 -0
- package/dist/organisms/form/preview/FormPreview.d.ts +6 -0
- package/dist/organisms/form/preview/FormPreview.js +11 -0
- package/dist/organisms/form/preview/FormPreview.js.map +1 -0
- package/dist/organisms/form/settings/FormSettings.js +24 -24
- package/dist/organisms/form/settings/FormSettings.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -1
- package/dist/organisms/form/useForm.js +664 -661
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/modal/RemoveModal.js +16 -17
- package/dist/organisms/modal/RemoveModal.js.map +1 -1
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
- package/dist/organisms/table/forms/FormsTable.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js.map +1 -1
- package/dist/organisms/table/submissions/SubmissionsTable.d.ts +11 -3
- package/dist/organisms/table/submissions/SubmissionsTable.js +4 -1
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
- package/dist/organisms/views/FormViews.d.ts +24 -0
- package/dist/organisms/views/FormViews.js +96 -0
- package/dist/organisms/views/FormViews.js.map +1 -0
- package/dist/registries/components.js.map +1 -1
- package/dist/utils/getEventValue.js.map +1 -1
- package/dist/utils/iconClass.js.map +1 -1
- package/dist/utils/mapPagination.js.map +1 -1
- package/dist/utils/stopPropagationWrapper.js.map +1 -1
- package/package.json +7 -7
- package/src/atoms/icon/Icon.stories.tsx +1 -1
- package/src/hooks/keyboard.constants.ts +40 -0
- package/src/hooks/useKeyboardControls.spec.tsx +208 -0
- package/src/hooks/useKeyboardControls.ts +84 -0
- package/src/interfaces/Operation.ts +9 -3
- package/src/molecules/button/Button.stories.tsx +1 -1
- package/src/molecules/button/Button.tsx +43 -24
- package/src/molecules/card/Card.tsx +4 -0
- package/src/molecules/forms/form-control/FormControl.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/InputTags.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +1 -1
- package/src/molecules/forms/input-text/InputText.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +2 -2
- package/src/molecules/loader/Loader.stories.tsx +1 -1
- package/src/molecules/modal/Modal.stories.tsx +1 -1
- package/src/molecules/pagination/Pagination.stories.tsx +1 -8
- package/src/molecules/pagination/Pagination.tsx +0 -1
- package/src/molecules/table/Table.stories.tsx +36 -3
- package/src/molecules/table/Table.tsx +12 -6
- package/src/molecules/table/components/DefaultCellOperations.tsx +13 -7
- package/src/molecules/table/components/DefaultOperationButton.tsx +5 -4
- package/src/molecules/table/filters/SelectFilter.tsx +1 -1
- package/src/molecules/table/hooks/useTable.tsx +5 -5
- package/src/molecules/tabs/Tab.tsx +106 -0
- package/src/molecules/tabs/TabList.tsx +37 -0
- package/src/molecules/tabs/TabPanel.tsx +37 -0
- package/src/molecules/tabs/Tabs.spec.tsx +126 -73
- package/src/molecules/tabs/Tabs.stories.tsx +298 -65
- package/src/molecules/tabs/Tabs.tsx +10 -81
- package/src/molecules/tabs/TabsBody.tsx +11 -0
- package/src/molecules/tabs/TabsLegacy.stories.tsx +103 -0
- package/src/molecules/tabs/TabsLegacy.tsx +84 -0
- package/src/molecules/tabs/all.ts +5 -0
- package/src/molecules/tabs/context/TabControl.tsx +166 -0
- package/src/molecules/tabs/hooks/tabControl.spec.tsx +388 -0
- package/src/molecules/tabs/hooks/tabControl.ts +52 -0
- package/src/organisms/__fixtures__/form-firstname.fixture.json +1 -0
- package/src/organisms/__fixtures__/form.fixture.json +1 -0
- package/src/organisms/form/Form.stories.tsx +94 -118
- package/src/organisms/form/access/FormAccess.stories.tsx +2 -2
- package/src/organisms/form/actions/FormAction.stories.tsx +422 -0
- package/src/organisms/form/builder/FormBuilder.stories.tsx +4 -1
- package/src/organisms/form/builder/FormEdit.stories.tsx +1 -1
- package/src/organisms/form/builder/FormEdit.tsx +7 -1
- package/src/organisms/form/builder/useFormBuilder.ts +5 -1
- package/src/organisms/form/builder/useFormEdit.ts +1 -1
- package/src/organisms/form/exports/FormExport.stories.tsx +71 -0
- package/src/organisms/form/exports/FormExport.tsx +58 -0
- package/src/organisms/form/preview/FormPreview.stories.tsx +61 -0
- package/src/organisms/form/preview/FormPreview.tsx +21 -0
- package/src/organisms/modal/RemoveModal.stories.tsx +1 -1
- package/src/organisms/table/actions/ActionsTable.stories.tsx +38 -36
- package/src/organisms/table/submissions/SubmissionsTable.stories.tsx +103 -57
- package/src/organisms/table/submissions/SubmissionsTable.tsx +10 -4
- package/src/organisms/views/FormViews.stories.tsx +224 -0
- package/src/organisms/views/FormViews.tsx +146 -0
- package/vite.config.mts +2 -2
- package/dist/organisms/form/action/FormAction.js.map +0 -1
- package/src/organisms/form/action/FormAction.stories.tsx +0 -364
- package/tsconfig.app.json +0 -11
- package/tsconfig.json +0 -21
- package/tsconfig.node.json +0 -13
- package/tsconfig.spec.json +0 -14
- /package/dist/organisms/form/{action → actions}/FormAction.d.ts +0 -0
- /package/src/organisms/form/{action → actions}/FormAction.tsx +0 -0
|
@@ -1,72 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { c as i } from "../../chunks/index.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
title: "button-wrapper",
|
|
9
|
-
className: i("tw-tabs__button-wrapper", b ? "-active" : "", s ? "-back" : "", n),
|
|
10
|
-
children: [
|
|
11
|
-
/* @__PURE__ */ e(
|
|
12
|
-
"button",
|
|
13
|
-
{
|
|
14
|
-
title: "button-tab",
|
|
15
|
-
className: i("tw-tabs__button", l ? "-reverse" : "", b ? "-active" : "", s ? "-back" : ""),
|
|
16
|
-
onClick: r,
|
|
17
|
-
children: [
|
|
18
|
-
c && /* @__PURE__ */ t("i", { className: i(p(void 0, c), "tw-tabs__button-icon") }),
|
|
19
|
-
/* @__PURE__ */ t("span", { className: "tw-tabs__button-label", children: o }),
|
|
20
|
-
_
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
),
|
|
24
|
-
/* @__PURE__ */ t("div", { className: i("tw-tabs__button-border", b ? "-active" : "") })
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
function x({
|
|
30
|
-
style: c,
|
|
31
|
-
current: s,
|
|
32
|
-
items: r = [],
|
|
33
|
-
children: b,
|
|
34
|
-
HeaderChildren: l,
|
|
35
|
-
AddButton: o,
|
|
36
|
-
Button: n = N,
|
|
37
|
-
className: _,
|
|
38
|
-
onClick: w,
|
|
39
|
-
i18n: m = (a) => a,
|
|
40
|
-
...d
|
|
41
|
-
}) {
|
|
42
|
-
return /* @__PURE__ */ e("div", { "data-testid": "tabs-comp", className: `tw-tabs ${_}`, style: c, children: [
|
|
43
|
-
/* @__PURE__ */ e("div", { children: [
|
|
44
|
-
/* @__PURE__ */ t("nav", { className: "tw-tabs__header", children: /* @__PURE__ */ e("div", { className: "tw-tabs__header-wrapper", children: [
|
|
45
|
-
/* @__PURE__ */ t("div", { className: "tw-tabs__header-border" }),
|
|
46
|
-
r.filter((a) => a.label || a.icon).map((a, v) => /* @__PURE__ */ t(
|
|
47
|
-
n,
|
|
48
|
-
{
|
|
49
|
-
back: a.back,
|
|
50
|
-
isActive: (s == null ? void 0 : s.action) === a.action,
|
|
51
|
-
exact: a.exact,
|
|
52
|
-
onClick: () => {
|
|
53
|
-
w && w(a);
|
|
54
|
-
},
|
|
55
|
-
...d,
|
|
56
|
-
...a,
|
|
57
|
-
children: m(a.label || "")
|
|
58
|
-
},
|
|
59
|
-
v
|
|
60
|
-
)),
|
|
61
|
-
o && /* @__PURE__ */ t(o, { ...d, current: s })
|
|
62
|
-
] }) }),
|
|
63
|
-
l && /* @__PURE__ */ t(l, { ...d, current: s })
|
|
64
|
-
] }),
|
|
65
|
-
/* @__PURE__ */ t("div", { title: "tab-body", className: "tw-tabs__body", children: b })
|
|
66
|
-
] });
|
|
3
|
+
import { registerComponent as m } from "../../registries/components.js";
|
|
4
|
+
import { TabsProvider as e } from "./context/TabControl.js";
|
|
5
|
+
function n({ style: t, selected: o, children: s, className: a }) {
|
|
6
|
+
return /* @__PURE__ */ r("div", { "data-testid": "Tabs", className: i("tw-tabs", a), style: t, children: /* @__PURE__ */ r(e, { selected: o, children: s }) });
|
|
67
7
|
}
|
|
8
|
+
m("Tabs", n);
|
|
68
9
|
export {
|
|
69
|
-
|
|
70
|
-
x as Tabs
|
|
10
|
+
n as Tabs
|
|
71
11
|
};
|
|
72
12
|
//# sourceMappingURL=Tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../src/molecules/tabs/Tabs.tsx"],"sourcesContent":["import classnames from \"classnames\";\nimport { PropsWithChildren } from \"react\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../src/molecules/tabs/Tabs.tsx"],"sourcesContent":["import classnames from \"classnames\";\nimport type { CSSProperties, PropsWithChildren } from \"react\";\n\nimport { registerComponent } from \"../../registries/components.js\";\nimport { TabsProvider } from \"./context/TabControl.js\";\n\nexport interface TabsProps extends Record<string, any> {\n style?: CSSProperties;\n className?: string;\n selected?: number;\n}\n\nexport function Tabs({ style, selected, children, className }: PropsWithChildren<TabsProps>) {\n return (\n <div data-testid={\"Tabs\"} className={classnames(\"tw-tabs\", className)} style={style}>\n <TabsProvider selected={selected}>{children}</TabsProvider>\n </div>\n );\n}\n\nregisterComponent(\"Tabs\", Tabs);\n"],"names":["Tabs","style","selected","children","className","jsx","classnames","TabsProvider","registerComponent"],"mappings":";;;;AAYO,SAASA,EAAK,EAAE,OAAAC,GAAO,UAAAC,GAAU,UAAAC,GAAU,WAAAC,KAA2C;AAC3F,SACE,gBAAAC,EAAC,OAAA,EAAI,eAAa,QAAQ,WAAWC,EAAW,WAAWF,CAAS,GAAG,OAAAH,GACrE,UAAA,gBAAAI,EAACE,GAAA,EAAa,UAAAL,GAAqB,UAAAC,GAAS,GAC9C;AAEJ;AAEAK,EAAkB,QAAQR,CAAI;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TabsBody(props: React.PropsWithChildren<{}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { registerComponent as r } from "../../registries/components.js";
|
|
3
|
+
function d(t) {
|
|
4
|
+
return /* @__PURE__ */ o("div", { title: "tabs-body", "data-testid": "TabsBody", className: "tw-tabs__body", children: t.children });
|
|
5
|
+
}
|
|
6
|
+
r("TabsBody", d);
|
|
7
|
+
export {
|
|
8
|
+
d as TabsBody
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=TabsBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabsBody.js","sources":["../../../src/molecules/tabs/TabsBody.tsx"],"sourcesContent":["import { registerComponent } from \"../../registries/components.js\";\n\nexport function TabsBody(props: React.PropsWithChildren<{}>) {\n return (\n <div title={\"tabs-body\"} data-testid={\"TabsBody\"} className={\"tw-tabs__body\"}>\n {props.children}\n </div>\n );\n}\n\nregisterComponent(\"TabsBody\", TabsBody);\n"],"names":["TabsBody","props","jsx","registerComponent"],"mappings":";;AAEO,SAASA,EAASC,GAAoC;AAC3D,SACE,gBAAAC,EAAC,SAAI,OAAO,aAAa,eAAa,YAAY,WAAW,iBAC1D,UAAAD,EAAM,SAAA,CACT;AAEJ;AAEAE,EAAkB,YAAYH,CAAQ;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export interface TabsItemProps extends Record<string, any> {
|
|
3
|
+
label?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface TabsLegacyProps extends Record<string, any> {
|
|
8
|
+
AddButton?: any;
|
|
9
|
+
current?: TabsItemProps;
|
|
10
|
+
items?: TabsItemProps[];
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
reverse?: boolean;
|
|
14
|
+
onClick?: (item: TabsItemProps) => void;
|
|
15
|
+
i18n?: (f: string) => string;
|
|
16
|
+
}
|
|
17
|
+
export declare function TabsLegacy({ style, current, items, HeaderChildren, AddButton, className, onClick, i18n, reverse, after, ...additionalProps }: TabsLegacyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import "./Tab.js";
|
|
3
|
+
import "./TabList.js";
|
|
4
|
+
import "./TabPanel.js";
|
|
5
|
+
import "./Tabs.js";
|
|
6
|
+
import "./TabsBody.js";
|
|
7
|
+
import { getComponent as a } from "../../registries/components.js";
|
|
8
|
+
function w({
|
|
9
|
+
style: p,
|
|
10
|
+
current: t,
|
|
11
|
+
items: m = [],
|
|
12
|
+
HeaderChildren: e,
|
|
13
|
+
AddButton: l,
|
|
14
|
+
className: h,
|
|
15
|
+
onClick: b,
|
|
16
|
+
i18n: f = (c) => c,
|
|
17
|
+
reverse: u,
|
|
18
|
+
after: v,
|
|
19
|
+
...i
|
|
20
|
+
}) {
|
|
21
|
+
const c = a("Tab"), y = a("TabsBody"), L = a("TabList"), d = a("TabPanel"), g = a("Tabs"), T = m.filter((o) => o.label || o.icon);
|
|
22
|
+
return /* @__PURE__ */ s(g, { className: h, style: p, children: [
|
|
23
|
+
/* @__PURE__ */ s("div", { children: [
|
|
24
|
+
/* @__PURE__ */ s(L, { children: [
|
|
25
|
+
T.map((o, n) => /* @__PURE__ */ r(
|
|
26
|
+
c,
|
|
27
|
+
{
|
|
28
|
+
onClick: () => {
|
|
29
|
+
b && b(o);
|
|
30
|
+
},
|
|
31
|
+
icon: o.icon,
|
|
32
|
+
value: n,
|
|
33
|
+
className: u ? "-reverse" : "",
|
|
34
|
+
after: v,
|
|
35
|
+
children: f(o.label || "")
|
|
36
|
+
},
|
|
37
|
+
n
|
|
38
|
+
)),
|
|
39
|
+
l && /* @__PURE__ */ r(l, { ...i, current: t })
|
|
40
|
+
] }),
|
|
41
|
+
e && /* @__PURE__ */ r(e, { ...i, current: t })
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ r(y, { children: T.map((o, n) => /* @__PURE__ */ r(d, { value: n, children: o.children || o.content }, n)) })
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
w as TabsLegacy
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=TabsLegacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabsLegacy.js","sources":["../../../src/molecules/tabs/TabsLegacy.tsx"],"sourcesContent":["import \"./all.js\";\n\nimport { CSSProperties, ReactNode } from \"react\";\n\nimport { getComponent } from \"../../registries/components.js\";\nimport type { Tab as DefaultTab } from \"./Tab.js\";\nimport type { TabList as DefaultTabList } from \"./TabList.js\";\nimport type { TabPanel as DefaultTabPanel } from \"./TabPanel.js\";\nimport type { Tabs as DefaultTabs } from \"./Tabs.js\";\nimport type { TabsBody as DefaultTabsBody } from \"./TabsBody.js\";\n\nexport interface TabsItemProps extends Record<string, any> {\n label?: string;\n icon?: string;\n children?: ReactNode;\n}\n\nexport interface TabsLegacyProps extends Record<string, any> {\n AddButton?: any;\n current?: TabsItemProps;\n items?: TabsItemProps[];\n style?: CSSProperties;\n className?: string;\n reverse?: boolean;\n onClick?: (item: TabsItemProps) => void;\n i18n?: (f: string) => string;\n}\n\nexport function TabsLegacy({\n style,\n current,\n items = [],\n HeaderChildren,\n AddButton,\n className,\n onClick,\n i18n = (f) => f,\n reverse,\n after,\n ...additionalProps\n}: TabsLegacyProps) {\n const Tab = getComponent<typeof DefaultTab>(\"Tab\");\n const TabsBody = getComponent<typeof DefaultTabsBody>(\"TabsBody\");\n const TabList = getComponent<typeof DefaultTabList>(\"TabList\");\n const TabPanel = getComponent<typeof DefaultTabPanel>(\"TabPanel\");\n const Tabs = getComponent<typeof DefaultTabs>(\"Tabs\");\n const tabs = items.filter((item) => item.label || item.icon);\n\n return (\n <Tabs className={className} style={style}>\n <div>\n <TabList>\n {tabs.map((item, index) => {\n return (\n <Tab\n key={index}\n onClick={() => {\n onClick && onClick(item);\n }}\n icon={item.icon}\n value={index}\n className={reverse ? \"-reverse\" : \"\"}\n after={after}\n >\n {i18n(item.label || \"\")}\n </Tab>\n );\n })}\n {AddButton && <AddButton {...additionalProps} current={current} />}\n </TabList>\n {HeaderChildren && <HeaderChildren {...additionalProps} current={current} />}\n </div>\n <TabsBody>\n {tabs.map((item, index) => {\n return (\n <TabPanel key={index} value={index}>\n {item.children || item.content}\n </TabPanel>\n );\n })}\n </TabsBody>\n </Tabs>\n );\n}\n"],"names":["TabsLegacy","style","current","items","HeaderChildren","AddButton","className","onClick","i18n","f","reverse","after","additionalProps","Tab","getComponent","TabsBody","TabList","TabPanel","Tabs","tabs","item","jsxs","index","jsx"],"mappings":";;;;;;;AA4BO,SAASA,EAAW;AAAA,EACzB,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC,IAAQ,CAAA;AAAA,EACR,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO,CAACC,MAAMA;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAAoB;AAClB,QAAMC,IAAMC,EAAgC,KAAK,GAC3CC,IAAWD,EAAqC,UAAU,GAC1DE,IAAUF,EAAoC,SAAS,GACvDG,IAAWH,EAAqC,UAAU,GAC1DI,IAAOJ,EAAiC,MAAM,GAC9CK,IAAOhB,EAAM,OAAO,CAACiB,MAASA,EAAK,SAASA,EAAK,IAAI;AAE3D,SACE,gBAAAC,EAACH,GAAA,EAAK,WAAAZ,GAAsB,OAAAL,GAC1B,UAAA;AAAA,IAAA,gBAAAoB,EAAC,OAAA,EACC,UAAA;AAAA,MAAA,gBAAAA,EAACL,GAAA,EACE,UAAA;AAAA,QAAAG,EAAK,IAAI,CAACC,GAAME,MAEb,gBAAAC;AAAA,UAACV;AAAA,UAAA;AAAA,YAEC,SAAS,MAAM;AACb,cAAAN,KAAWA,EAAQa,CAAI;AAAA,YACzB;AAAA,YACA,MAAMA,EAAK;AAAA,YACX,OAAOE;AAAA,YACP,WAAWZ,IAAU,aAAa;AAAA,YAClC,OAAAC;AAAA,YAEC,UAAAH,EAAKY,EAAK,SAAS,EAAE;AAAA,UAAA;AAAA,UATjBE;AAAA,QAAA,CAYV;AAAA,QACAjB,KAAa,gBAAAkB,EAAClB,GAAA,EAAW,GAAGO,GAAiB,SAAAV,EAAA,CAAkB;AAAA,MAAA,GAClE;AAAA,MACCE,KAAkB,gBAAAmB,EAACnB,GAAA,EAAgB,GAAGQ,GAAiB,SAAAV,EAAA,CAAkB;AAAA,IAAA,GAC5E;AAAA,sBACCa,GAAA,EACE,UAAAI,EAAK,IAAI,CAACC,GAAME,MAEb,gBAAAC,EAACN,KAAqB,OAAOK,GAC1B,YAAK,YAAYF,EAAK,WADVE,CAEf,CAEH,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Tab as a } from "./Tab.js";
|
|
2
|
+
import { TabList as t } from "./TabList.js";
|
|
3
|
+
import { TabPanel as f } from "./TabPanel.js";
|
|
4
|
+
import { Tabs as p } from "./Tabs.js";
|
|
5
|
+
import { TabsBody as T } from "./TabsBody.js";
|
|
6
|
+
export {
|
|
7
|
+
a as Tab,
|
|
8
|
+
t as TabList,
|
|
9
|
+
f as TabPanel,
|
|
10
|
+
p as Tabs,
|
|
11
|
+
T as TabsBody
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=all.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Dispatch, PropsWithChildren, RefObject } from 'react';
|
|
2
|
+
type RefTab<T extends HTMLElement = HTMLElement> = RefObject<T>;
|
|
3
|
+
type RefTabs<T extends HTMLElement = HTMLElement> = Map<number, RefTab<T>>;
|
|
4
|
+
type TabsUpdateAction = {
|
|
5
|
+
type: "update";
|
|
6
|
+
payload: number;
|
|
7
|
+
};
|
|
8
|
+
type TabsRegisterAction<T extends HTMLElement = HTMLElement> = {
|
|
9
|
+
type: "register";
|
|
10
|
+
payload: {
|
|
11
|
+
value: number;
|
|
12
|
+
ref: RefObject<T>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type TabsUnregisterAction = {
|
|
16
|
+
type: "unregister";
|
|
17
|
+
payload: {
|
|
18
|
+
value: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type TabsAction<T extends HTMLElement = HTMLElement> = {
|
|
22
|
+
type: "start" | "end" | "previous" | "next";
|
|
23
|
+
} | TabsUpdateAction | TabsRegisterAction<T> | TabsUnregisterAction;
|
|
24
|
+
interface TabsState<T extends HTMLElement = HTMLElement> {
|
|
25
|
+
uid: string;
|
|
26
|
+
value: number;
|
|
27
|
+
refs: RefTabs<T>;
|
|
28
|
+
}
|
|
29
|
+
interface TabControl<T extends HTMLElement = HTMLElement> extends TabsState<T> {
|
|
30
|
+
uid: string;
|
|
31
|
+
value: number;
|
|
32
|
+
refs: RefTabs<T>;
|
|
33
|
+
dispatch: Dispatch<TabsAction>;
|
|
34
|
+
register: (value: number, ref: RefTab<T>) => void;
|
|
35
|
+
unregister: (value: number) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare const TabControlContext: import('react').Context<TabControl<HTMLElement>>;
|
|
38
|
+
export interface TabsProviderProps {
|
|
39
|
+
selected?: number;
|
|
40
|
+
/**
|
|
41
|
+
* The selected tab value
|
|
42
|
+
* @deprecated Min props as no effect on the Tabs component and will be removed in future versions
|
|
43
|
+
*/
|
|
44
|
+
min?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The selected tab value
|
|
47
|
+
* @deprecated Max props as no effect on the Tabs component and will be removed in future versions
|
|
48
|
+
*/
|
|
49
|
+
max?: number;
|
|
50
|
+
}
|
|
51
|
+
export declare function TabsProvider({ selected, children }: PropsWithChildren<TabsProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as p, useId as x, useReducer as y, useCallback as u } from "react";
|
|
4
|
+
function v(e) {
|
|
5
|
+
const n = [...e.refs.keys()], o = (n.findIndex((t) => t === e.value) + 1) % n.length;
|
|
6
|
+
return { ...e, value: n[o] };
|
|
7
|
+
}
|
|
8
|
+
function g(e) {
|
|
9
|
+
const n = [...e.refs.keys()], o = (n.findIndex((t) => t === e.value) - 1 + n.length) % n.length;
|
|
10
|
+
return { ...e, value: n[o] };
|
|
11
|
+
}
|
|
12
|
+
function C(e) {
|
|
13
|
+
const r = [...e.refs.keys()][0];
|
|
14
|
+
return {
|
|
15
|
+
...e,
|
|
16
|
+
value: r
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function k(e) {
|
|
20
|
+
const n = [...e.refs.keys()], r = n[n.length - 1];
|
|
21
|
+
return {
|
|
22
|
+
...e,
|
|
23
|
+
value: r
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function b(e, n) {
|
|
27
|
+
const r = new Map(e.refs);
|
|
28
|
+
return r.delete(n.payload.value), {
|
|
29
|
+
...e,
|
|
30
|
+
refs: r
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function h(e, n) {
|
|
34
|
+
return {
|
|
35
|
+
...e,
|
|
36
|
+
refs: new Map(e.refs).set(n.payload.value, n.payload.ref)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function w(e, n) {
|
|
40
|
+
return { ...e, value: n.payload };
|
|
41
|
+
}
|
|
42
|
+
const i = {
|
|
43
|
+
next: v,
|
|
44
|
+
previous: g,
|
|
45
|
+
start: C,
|
|
46
|
+
end: k,
|
|
47
|
+
register: h,
|
|
48
|
+
unregister: b,
|
|
49
|
+
update: w
|
|
50
|
+
};
|
|
51
|
+
function I(e, n) {
|
|
52
|
+
if (n.type in i) {
|
|
53
|
+
const r = i[n.type];
|
|
54
|
+
return r(e, n);
|
|
55
|
+
}
|
|
56
|
+
return e;
|
|
57
|
+
}
|
|
58
|
+
const d = p({
|
|
59
|
+
uid: "",
|
|
60
|
+
value: 0,
|
|
61
|
+
refs: /* @__PURE__ */ new Map(),
|
|
62
|
+
dispatch: () => {
|
|
63
|
+
console.warn("Tab Controller Context dispatch used outside of Provider");
|
|
64
|
+
},
|
|
65
|
+
register: () => {
|
|
66
|
+
console.warn("Tab Controller Context register used outside of Provider");
|
|
67
|
+
},
|
|
68
|
+
unregister: () => {
|
|
69
|
+
console.warn("Tab Controller Context unregister used outside of Provider");
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
d.displayName = "TabControlContext";
|
|
73
|
+
function P({ selected: e = 0, children: n }) {
|
|
74
|
+
const r = x(), [o, t] = y(I, { uid: r, value: e, refs: /* @__PURE__ */ new Map() }), a = u((s, c) => {
|
|
75
|
+
t({ type: "register", payload: { value: s, ref: c } });
|
|
76
|
+
}, []), l = u((s) => {
|
|
77
|
+
t({ type: "unregister", payload: { value: s } });
|
|
78
|
+
}, []);
|
|
79
|
+
return /* @__PURE__ */ f(d.Provider, { value: { ...o, dispatch: t, register: a, unregister: l }, children: n });
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
d as TabControlContext,
|
|
83
|
+
P as TabsProvider
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=TabControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabControl.js","sources":["../../../../src/molecules/tabs/context/TabControl.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type Dispatch, type PropsWithChildren, type RefObject, useCallback, useId, useReducer } from \"react\";\n\ntype RefTab<T extends HTMLElement = HTMLElement> = RefObject<T>;\ntype RefTabs<T extends HTMLElement = HTMLElement> = Map<number, RefTab<T>>;\n\ntype TabsUpdateAction = {\n type: \"update\";\n payload: number;\n};\n\ntype TabsRegisterAction<T extends HTMLElement = HTMLElement> = {\n type: \"register\";\n payload: { value: number; ref: RefObject<T> };\n};\n\ntype TabsUnregisterAction = {\n type: \"unregister\";\n payload: { value: number };\n};\n\ntype TabsAction<T extends HTMLElement = HTMLElement> =\n | { type: \"start\" | \"end\" | \"previous\" | \"next\" }\n | TabsUpdateAction\n | TabsRegisterAction<T>\n | TabsUnregisterAction;\n\ninterface TabsState<T extends HTMLElement = HTMLElement> {\n uid: string;\n value: number;\n refs: RefTabs<T>;\n}\n\ninterface TabControl<T extends HTMLElement = HTMLElement> extends TabsState<T> {\n uid: string;\n value: number;\n refs: RefTabs<T>;\n dispatch: Dispatch<TabsAction>;\n register: (value: number, ref: RefTab<T>) => void;\n unregister: (value: number) => void;\n}\n\nfunction next(state: TabsState) {\n const keys = [...state.refs.keys()];\n const index = keys.findIndex((value) => value === state.value);\n const nextIndex = (index + 1) % keys.length;\n\n return { ...state, value: keys[nextIndex] };\n}\n\nfunction previous(state: TabsState) {\n const keys = [...state.refs.keys()];\n const index = keys.findIndex((value) => value === state.value);\n const previousIndex = (index - 1 + keys.length) % keys.length;\n\n return { ...state, value: keys[previousIndex] };\n}\n\nfunction start(state: TabsState) {\n const keys = [...state.refs.keys()];\n const firstIndex = keys[0];\n\n return {\n ...state,\n value: firstIndex\n };\n}\n\nfunction end(state: TabsState) {\n const keys = [...state.refs.keys()];\n const lastIndex = keys[keys.length - 1];\n\n return {\n ...state,\n value: lastIndex\n };\n}\n\nfunction unregister(state: TabsState, action: TabsUnregisterAction) {\n const deletedRefs = new Map(state.refs);\n deletedRefs.delete(action.payload.value);\n\n return {\n ...state,\n refs: deletedRefs\n };\n}\n\nfunction register(state: TabsState, action: TabsRegisterAction) {\n return {\n ...state,\n refs: new Map(state.refs).set(action.payload.value, action.payload.ref)\n };\n}\n\nfunction update(state: TabsState, action: TabsUpdateAction) {\n return { ...state, value: action.payload };\n}\n\nconst actions = {\n next,\n previous,\n start,\n end,\n register,\n unregister,\n update\n};\n\nfunction tabsReducer(state: TabsState, action: TabsAction): TabsState {\n if (action.type in actions) {\n const actionFunction = actions[action.type as keyof typeof actions] as (state: TabsState, action: TabsAction) => TabsState;\n\n return actionFunction(state, action);\n }\n\n return state;\n}\n\nexport const TabControlContext = createContext<TabControl>({\n uid: \"\",\n value: 0,\n refs: new Map(),\n dispatch: () => {\n console.warn(\"Tab Controller Context dispatch used outside of Provider\");\n },\n register: () => {\n console.warn(\"Tab Controller Context register used outside of Provider\");\n },\n unregister: () => {\n console.warn(\"Tab Controller Context unregister used outside of Provider\");\n }\n});\n\nTabControlContext.displayName = \"TabControlContext\";\n\nexport interface TabsProviderProps {\n selected?: number;\n /**\n * The selected tab value\n * @deprecated Min props as no effect on the Tabs component and will be removed in future versions\n */\n min?: number;\n\n /**\n * The selected tab value\n * @deprecated Max props as no effect on the Tabs component and will be removed in future versions\n */\n max?: number;\n}\n\nexport function TabsProvider({ selected = 0, children }: PropsWithChildren<TabsProviderProps>) {\n const uid = useId();\n const [state, dispatch] = useReducer(tabsReducer, { uid, value: selected, refs: new Map() });\n\n const register = useCallback(<T extends HTMLElement>(value: number, ref: RefTab<T>) => {\n dispatch({ type: \"register\", payload: { value, ref } });\n }, []);\n\n const unregister = useCallback((value: number) => {\n dispatch({ type: \"unregister\", payload: { value } });\n }, []);\n\n return <TabControlContext.Provider value={{ ...state, dispatch, register, unregister }}>{children}</TabControlContext.Provider>;\n}\n"],"names":["next","state","keys","nextIndex","value","previous","previousIndex","start","firstIndex","end","lastIndex","unregister","action","deletedRefs","register","update","actions","tabsReducer","actionFunction","TabControlContext","createContext","TabsProvider","selected","children","uid","useId","dispatch","useReducer","useCallback","ref","jsx"],"mappings":"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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export declare const useActiveTab: () => number;
|
|
3
|
+
export declare const useTabDispatch: () => import('react').Dispatch<{
|
|
4
|
+
type: "update";
|
|
5
|
+
payload: number;
|
|
6
|
+
} | {
|
|
7
|
+
type: "unregister";
|
|
8
|
+
payload: {
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
type: "start" | "end" | "previous" | "next";
|
|
13
|
+
} | {
|
|
14
|
+
type: "register";
|
|
15
|
+
payload: {
|
|
16
|
+
value: number;
|
|
17
|
+
ref: RefObject<HTMLElement>;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
export declare const useTabsUid: () => string;
|
|
21
|
+
interface Props<T extends HTMLElement> {
|
|
22
|
+
value: number;
|
|
23
|
+
ref: RefObject<T>;
|
|
24
|
+
}
|
|
25
|
+
export declare function useRegisterTabControl<T extends HTMLElement>({ value, ref }: Props<T>): import('react').Dispatch<{
|
|
26
|
+
type: "update";
|
|
27
|
+
payload: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: "unregister";
|
|
30
|
+
payload: {
|
|
31
|
+
value: number;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
type: "start" | "end" | "previous" | "next";
|
|
35
|
+
} | {
|
|
36
|
+
type: "register";
|
|
37
|
+
payload: {
|
|
38
|
+
value: number;
|
|
39
|
+
ref: RefObject<HTMLElement>;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
export declare const useTabControls: () => Map<number, RefObject<HTMLElement>>;
|
|
43
|
+
export declare const useActiveTabControl: () => readonly [number, RefObject<HTMLElement> | undefined];
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useContext as e, useEffect as u } from "react";
|
|
2
|
+
import { TabControlContext as r } from "../context/TabControl.js";
|
|
3
|
+
const b = () => {
|
|
4
|
+
const { value: t } = e(r);
|
|
5
|
+
return t;
|
|
6
|
+
}, T = () => {
|
|
7
|
+
const { dispatch: t } = e(r);
|
|
8
|
+
return t;
|
|
9
|
+
}, f = () => {
|
|
10
|
+
const { uid: t } = e(r);
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
function p({ value: t, ref: s }) {
|
|
14
|
+
const { dispatch: c, register: n, unregister: o } = e(r);
|
|
15
|
+
return u(() => (n(t, s), () => {
|
|
16
|
+
o(t);
|
|
17
|
+
}), [t, s, n, o]), c;
|
|
18
|
+
}
|
|
19
|
+
const C = () => {
|
|
20
|
+
const { refs: t } = e(r);
|
|
21
|
+
return t;
|
|
22
|
+
}, d = () => {
|
|
23
|
+
const { value: t, refs: s } = e(r);
|
|
24
|
+
return [t, s.get(t)];
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
b as useActiveTab,
|
|
28
|
+
d as useActiveTabControl,
|
|
29
|
+
p as useRegisterTabControl,
|
|
30
|
+
C as useTabControls,
|
|
31
|
+
T as useTabDispatch,
|
|
32
|
+
f as useTabsUid
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=tabControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabControl.js","sources":["../../../../src/molecules/tabs/hooks/tabControl.ts"],"sourcesContent":["import { type RefObject, useContext, useEffect } from \"react\";\n\nimport { TabControlContext } from \"../context/TabControl\";\n\nexport const useActiveTab = () => {\n const { value } = useContext(TabControlContext);\n\n return value;\n};\n\nexport const useTabDispatch = () => {\n const { dispatch } = useContext(TabControlContext);\n\n return dispatch;\n};\n\nexport const useTabsUid = () => {\n const { uid } = useContext(TabControlContext);\n\n return uid;\n};\n\ninterface Props<T extends HTMLElement> {\n value: number;\n ref: RefObject<T>;\n}\n\nexport function useRegisterTabControl<T extends HTMLElement>({ value, ref }: Props<T>) {\n const { dispatch, register, unregister } = useContext(TabControlContext);\n\n useEffect(() => {\n register(value, ref);\n\n return () => {\n unregister(value);\n };\n }, [value, ref, register, unregister]);\n\n return dispatch;\n}\n\nexport const useTabControls = () => {\n const { refs } = useContext(TabControlContext);\n\n return refs;\n};\n\nexport const useActiveTabControl = () => {\n const { value, refs } = useContext(TabControlContext);\n\n return [value, refs.get(value)] as const;\n};\n"],"names":["useActiveTab","value","useContext","TabControlContext","useTabDispatch","dispatch","useTabsUid","uid","useRegisterTabControl","ref","register","unregister","useEffect","useTabControls","refs","useActiveTabControl"],"mappings":";;AAIO,MAAMA,IAAe,MAAM;AAChC,QAAM,EAAE,OAAAC,EAAA,IAAUC,EAAWC,CAAiB;AAE9C,SAAOF;AACT,GAEaG,IAAiB,MAAM;AAClC,QAAM,EAAE,UAAAC,EAAA,IAAaH,EAAWC,CAAiB;AAEjD,SAAOE;AACT,GAEaC,IAAa,MAAM;AAC9B,QAAM,EAAE,KAAAC,EAAA,IAAQL,EAAWC,CAAiB;AAE5C,SAAOI;AACT;AAOO,SAASC,EAA6C,EAAE,OAAAP,GAAO,KAAAQ,KAAiB;AACrF,QAAM,EAAE,UAAAJ,GAAU,UAAAK,GAAU,YAAAC,EAAA,IAAeT,EAAWC,CAAiB;AAEvE,SAAAS,EAAU,OACRF,EAAST,GAAOQ,CAAG,GAEZ,MAAM;AACX,IAAAE,EAAWV,CAAK;AAAA,EAClB,IACC,CAACA,GAAOQ,GAAKC,GAAUC,CAAU,CAAC,GAE9BN;AACT;AAEO,MAAMQ,IAAiB,MAAM;AAClC,QAAM,EAAE,MAAAC,EAAA,IAASZ,EAAWC,CAAiB;AAE7C,SAAOW;AACT,GAEaC,IAAsB,MAAM;AACvC,QAAM,EAAE,OAAAd,GAAO,MAAAa,MAASZ,EAAWC,CAAiB;AAEpD,SAAO,CAACF,GAAOa,EAAK,IAAIb,CAAK,CAAC;AAChC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../src/organisms/form/Form.tsx"],"sourcesContent":["import { JSON } from \"../../interfaces\";\nimport { useForm, UseFormProps } from \"./useForm\";\n\nclass CSSProperties {}\n\nexport interface FormProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> extends UseFormProps<Data> {\n [\"data-testid\"]?: string;\n /**\n *\n */\n className?: string;\n\n style?: CSSProperties;\n}\n\nexport function Form<Data extends { [key: string]: JSON } = { [key: string]: JSON }>({\n style,\n className,\n \"data-testid\": dataTestId = \"formio-container\",\n ...props\n}: Partial<FormProps<Data>>) {\n const { element } = useForm<Data>(props);\n\n return (\n <div>\n <div data-testid={dataTestId} style={style} className={className} ref={element} />\n </div>\n );\n}\n"],"names":["Form","style","className","dataTestId","props","element","useForm","jsx"],"mappings":";;AAeO,SAASA,EAAqE;AAAA,EACnF,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAeC,IAAa;AAAA,EAC5B,GAAGC;AACL,GAA6B;AAC3B,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAcF,CAAK;
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../src/organisms/form/Form.tsx"],"sourcesContent":["import { JSON } from \"../../interfaces\";\nimport { useForm, UseFormProps } from \"./useForm\";\n\nclass CSSProperties {}\n\nexport interface FormProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> extends UseFormProps<Data> {\n [\"data-testid\"]?: string;\n /**\n *\n */\n className?: string;\n\n style?: CSSProperties;\n}\n\nexport function Form<Data extends { [key: string]: JSON } = { [key: string]: JSON }>({\n style,\n className,\n \"data-testid\": dataTestId = \"formio-container\",\n ...props\n}: Partial<FormProps<Data>>) {\n const { element } = useForm<Data>(props);\n\n return (\n <div>\n <div data-testid={dataTestId} style={style} className={className} ref={element} />\n </div>\n );\n}\n"],"names":["Form","style","className","dataTestId","props","element","useForm","jsx"],"mappings":";;AAeO,SAASA,EAAqE;AAAA,EACnF,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAeC,IAAa;AAAA,EAC5B,GAAGC;AACL,GAA6B;AAC3B,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAcF,CAAK;AAEvC,SACE,gBAAAG,EAAC,OAAA,EACC,UAAA,gBAAAA,EAAC,OAAA,EAAI,eAAaJ,GAAY,OAAAF,GAAc,WAAAC,GAAsB,KAAKG,EAAA,CAAS,EAAA,CAClF;AAEJ;"}
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { Card as
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as y, useState as w, useCallback as A, useEffect as N } from "react";
|
|
3
|
+
import { Card as m } from "../../../molecules/card/Card.js";
|
|
4
4
|
import { Form as v } from "../Form.js";
|
|
5
|
-
import { getFormAccess as S, dataAccessToSubmissions as b, updateSubmissions as x, shouldUpdate as
|
|
6
|
-
function T({ form: s, roles:
|
|
7
|
-
const
|
|
8
|
-
(
|
|
9
|
-
x(
|
|
5
|
+
import { getFormAccess as S, dataAccessToSubmissions as b, updateSubmissions as x, shouldUpdate as f, submissionsToDataAccess as F } from "./FormAccess.utils.js";
|
|
6
|
+
function T({ form: s, roles: l, onSubmit: a, options: c }) {
|
|
7
|
+
const n = y(() => S(l), [l]), [i, r] = w(() => b(s, n)), d = A(
|
|
8
|
+
(t, h) => {
|
|
9
|
+
x(t, h, i, r);
|
|
10
10
|
},
|
|
11
11
|
[i]
|
|
12
12
|
);
|
|
13
13
|
return N(() => {
|
|
14
|
-
const
|
|
15
|
-
s
|
|
16
|
-
}, [s
|
|
17
|
-
options:
|
|
18
|
-
form:
|
|
14
|
+
const t = b(s, n);
|
|
15
|
+
s?._id && (f("access", i.access, t) || f("submissionAccess", i.submissionAccess, t)) && r(t);
|
|
16
|
+
}, [s?._id]), {
|
|
17
|
+
options: c,
|
|
18
|
+
form: n,
|
|
19
19
|
type: s.type,
|
|
20
20
|
submissions: i,
|
|
21
|
-
onChange:
|
|
21
|
+
onChange: d,
|
|
22
22
|
onSubmit: () => {
|
|
23
|
-
|
|
23
|
+
a && a(F(s, i));
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const [
|
|
29
|
-
return /* @__PURE__ */
|
|
27
|
+
function p({ name: s, form: l, submissions: a, options: c, onChange: n, onSubmit: i, children: r }) {
|
|
28
|
+
const [d, t] = w(!0);
|
|
29
|
+
return /* @__PURE__ */ o(g, { children: [
|
|
30
30
|
/* @__PURE__ */ e(
|
|
31
31
|
v,
|
|
32
32
|
{
|
|
33
|
-
form:
|
|
34
|
-
submission:
|
|
33
|
+
form: l[s],
|
|
34
|
+
submission: a[s],
|
|
35
35
|
onChange: ({ data: h, isValid: u }) => {
|
|
36
|
-
u &&
|
|
36
|
+
u && n(s, { data: h }), t(u);
|
|
37
37
|
},
|
|
38
|
-
options:
|
|
38
|
+
options: c
|
|
39
39
|
}
|
|
40
40
|
),
|
|
41
|
-
/* @__PURE__ */ e("button", { disabled: !
|
|
42
|
-
|
|
41
|
+
/* @__PURE__ */ e("button", { disabled: !d, className: "mt-5 btn btn-primary", onClick: i, children: "Save access" }),
|
|
42
|
+
r,
|
|
43
43
|
/* @__PURE__ */ e("div", { className: "alert alert-warning mt-5", children: "Elevated permissions allow users to access and modify other user's entities. Assign with caution." })
|
|
44
44
|
] });
|
|
45
45
|
}
|
|
46
46
|
function O(s) {
|
|
47
|
-
const { type:
|
|
48
|
-
return /* @__PURE__ */
|
|
47
|
+
const { type: l, form: a, submissions: c, options: n, onChange: i, onSubmit: r } = T(s);
|
|
48
|
+
return /* @__PURE__ */ o("div", { children: [
|
|
49
49
|
s.children,
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */ e(
|
|
52
|
-
|
|
50
|
+
/* @__PURE__ */ o("div", { className: "flex mb-5", children: [
|
|
51
|
+
/* @__PURE__ */ e(m, { label: "Manage submission access", className: "flex-1", children: /* @__PURE__ */ e(
|
|
52
|
+
p,
|
|
53
53
|
{
|
|
54
54
|
name: "submissionAccess",
|
|
55
|
-
form:
|
|
56
|
-
submissions:
|
|
55
|
+
form: a,
|
|
56
|
+
submissions: c,
|
|
57
57
|
onChange: i,
|
|
58
|
-
onSubmit:
|
|
59
|
-
options:
|
|
58
|
+
onSubmit: r,
|
|
59
|
+
options: n,
|
|
60
60
|
children: s.children
|
|
61
61
|
}
|
|
62
62
|
) }),
|
|
63
|
-
/* @__PURE__ */ e("div", { className: "w-1/4 pl-4", children: /* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ e("div", { className: "w-1/4 pl-4", children: /* @__PURE__ */ o(m, { label: "About Submission Data Permissions", children: [
|
|
64
64
|
/* @__PURE__ */ e("p", { children: "Submission Data Permissions allow you to control who can create, view, and modify form submission data." }),
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ o("ul", { className: "mt-5 pl-7 list-disc", children: [
|
|
66
|
+
/* @__PURE__ */ o("li", { className: "pb-2", children: [
|
|
67
67
|
/* @__PURE__ */ e("strong", { children: "Own Permissions" }),
|
|
68
68
|
" - These permissions apply if the user is the original creator of the submission data and is listed as the owner of the submission in submission.owner. This allows users to create and edit their own submission data without seeing other user's data."
|
|
69
69
|
] }),
|
|
70
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ o("li", { children: [
|
|
71
71
|
/* @__PURE__ */ e("strong", { children: "All Permissions" }),
|
|
72
72
|
" - These permissions apply to all submission data regardless of who owns it."
|
|
73
73
|
] })
|
|
74
74
|
] })
|
|
75
75
|
] }) })
|
|
76
76
|
] }),
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */ e(
|
|
79
|
-
/* @__PURE__ */ e("div", { className: "w-1/4 pl-4", children: /* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ o("div", { className: "flex mb-5", children: [
|
|
78
|
+
/* @__PURE__ */ e(m, { label: `Manage ${l} definition access`, className: "flex-1", children: /* @__PURE__ */ e(p, { name: "access", form: a, submissions: c, onChange: i, onSubmit: r, options: n, children: s.children }) }),
|
|
79
|
+
/* @__PURE__ */ e("div", { className: "w-1/4 pl-4", children: /* @__PURE__ */ o(m, { label: "About Form Definition Access", children: [
|
|
80
80
|
/* @__PURE__ */ e("p", { children: "These permissions allow you to give access to a single form's JSON definition so they can render the form." }),
|
|
81
81
|
/* @__PURE__ */ e("p", { children: "Typically you will want to allow all of your roles to be able to Read the form definition." }),
|
|
82
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ o("p", { children: [
|
|
83
83
|
"Each form also has an owner at ",
|
|
84
84
|
/* @__PURE__ */ e("strong", { children: "form.owner" }),
|
|
85
85
|
" which is the user who created the form. In some applications users are allowed to create their own forms. In those cases it is helpful to have Owner based permissions as well."
|