@bsol-oss/react-datatable5 12.0.0-beta.2 → 12.0.0-beta.4
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/index.d.ts +47 -35
- package/dist/index.js +414 -384
- package/dist/index.mjs +412 -385
- package/dist/types/components/Form/SchemaFormContext.d.ts +13 -0
- package/dist/types/components/Form/components/core/DefaultForm.d.ts +6 -0
- package/dist/types/components/Form/components/core/FormBody.d.ts +1 -0
- package/dist/types/components/Form/components/core/FormRoot.d.ts +39 -0
- package/dist/types/components/Form/components/core/FormTitle.d.ts +1 -0
- package/dist/types/components/Form/components/core/SubmitButton.d.ts +1 -0
- package/dist/types/index.d.ts +10 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,12 +4,13 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var react = require('@chakra-ui/react');
|
|
5
5
|
var ai = require('react-icons/ai');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var md = require('react-icons/md');
|
|
8
7
|
var lu = require('react-icons/lu');
|
|
9
|
-
var
|
|
8
|
+
var md = require('react-icons/md');
|
|
10
9
|
var fa6 = require('react-icons/fa6');
|
|
11
10
|
var bi = require('react-icons/bi');
|
|
12
11
|
var cg = require('react-icons/cg');
|
|
12
|
+
var Dayzed = require('@bsol-oss/dayzed-react19');
|
|
13
|
+
var hi2 = require('react-icons/hi2');
|
|
13
14
|
var io = require('react-icons/io');
|
|
14
15
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
15
16
|
var bindEventListener = require('bind-event-listener');
|
|
@@ -17,7 +18,7 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
17
18
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
18
19
|
var rafSchd = require('raf-schd');
|
|
19
20
|
var invariant = require('tiny-invariant');
|
|
20
|
-
var
|
|
21
|
+
var hi = require('react-icons/hi');
|
|
21
22
|
var reactTable = require('@tanstack/react-table');
|
|
22
23
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
23
24
|
var bs = require('react-icons/bs');
|
|
@@ -25,7 +26,6 @@ var usehooks = require('@uidotdev/usehooks');
|
|
|
25
26
|
var reactQuery = require('@tanstack/react-query');
|
|
26
27
|
var io5 = require('react-icons/io5');
|
|
27
28
|
var gr = require('react-icons/gr');
|
|
28
|
-
var hi = require('react-icons/hi');
|
|
29
29
|
var reactI18next = require('react-i18next');
|
|
30
30
|
var axios = require('axios');
|
|
31
31
|
var reactHookForm = require('react-hook-form');
|
|
@@ -98,6 +98,89 @@ react.Dialog.Description;
|
|
|
98
98
|
const DialogTrigger = react.Dialog.Trigger;
|
|
99
99
|
react.Dialog.ActionTrigger;
|
|
100
100
|
|
|
101
|
+
const ColumnOrderChanger = ({ columns }) => {
|
|
102
|
+
const [order, setOrder] = React.useState([]);
|
|
103
|
+
const [originalOrder, setOriginalOrder] = React.useState([]);
|
|
104
|
+
const { table } = useDataTableContext();
|
|
105
|
+
const handleChangeOrder = (startIndex, endIndex) => {
|
|
106
|
+
const newOrder = Array.from(order);
|
|
107
|
+
const [removed] = newOrder.splice(startIndex, 1);
|
|
108
|
+
newOrder.splice(endIndex, 0, removed);
|
|
109
|
+
setOrder(newOrder);
|
|
110
|
+
};
|
|
111
|
+
React.useEffect(() => {
|
|
112
|
+
setOrder(columns);
|
|
113
|
+
}, [columns]);
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
if (originalOrder.length > 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (columns.length <= 0) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
setOriginalOrder(columns);
|
|
122
|
+
}, [columns]);
|
|
123
|
+
return (jsxRuntime.jsxs(react.Flex, { gap: 2, flexFlow: "column", children: [jsxRuntime.jsx(react.Flex, { gap: 2, flexFlow: "column", children: order.map((columnId, index) => (jsxRuntime.jsxs(react.Flex, { gap: 2, alignItems: "center", justifyContent: "space-between", children: [jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
124
|
+
const prevIndex = index - 1;
|
|
125
|
+
if (prevIndex >= 0) {
|
|
126
|
+
handleChangeOrder(index, prevIndex);
|
|
127
|
+
}
|
|
128
|
+
}, disabled: index === 0, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowUpward, {}) }), table
|
|
129
|
+
.getAllFlatColumns()
|
|
130
|
+
.filter((column) => {
|
|
131
|
+
return column.id === columnId;
|
|
132
|
+
})
|
|
133
|
+
.map((column) => {
|
|
134
|
+
const displayName = column.columnDef.meta === undefined
|
|
135
|
+
? column.id
|
|
136
|
+
: column.columnDef.meta.displayName;
|
|
137
|
+
return jsxRuntime.jsx("span", { children: displayName }, column.id);
|
|
138
|
+
}), jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
139
|
+
const nextIndex = index + 1;
|
|
140
|
+
if (nextIndex < order.length) {
|
|
141
|
+
handleChangeOrder(index, nextIndex);
|
|
142
|
+
}
|
|
143
|
+
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] }, columnId))) }), jsxRuntime.jsxs(react.Flex, { gap: "0.25rem", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
144
|
+
table.setColumnOrder(order);
|
|
145
|
+
}, children: "Apply" }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
146
|
+
table.setColumnOrder(originalOrder);
|
|
147
|
+
}, children: "Reset" })] })] }));
|
|
148
|
+
};
|
|
149
|
+
const TableOrderer = () => {
|
|
150
|
+
const { table } = useDataTableContext();
|
|
151
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const EditOrderButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineMoveDown, {}), title = "Change Order", }) => {
|
|
155
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(DialogRoot, { size: "cover", children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsx(DialogTitle, {}), title] }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.25rem", children: jsxRuntime.jsx(TableOrderer, {}) }) }), jsxRuntime.jsx(DialogFooter, {})] })] }) }));
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const TableSorter = () => {
|
|
159
|
+
const { table } = useDataTableContext();
|
|
160
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: headerGroup.headers.map((header) => {
|
|
161
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
162
|
+
? header.column.id
|
|
163
|
+
: header.column.columnDef.meta.displayName;
|
|
164
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: header.column.getCanSort() && (jsxRuntime.jsxs(react.Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsxs(react.Button, { variant: "ghost", onClick: () => {
|
|
165
|
+
header.column.toggleSorting();
|
|
166
|
+
}, children: [header.column.getIsSorted() === false && jsxRuntime.jsx(fa6.FaUpDown, {}), header.column.getIsSorted() === "asc" && jsxRuntime.jsx(bi.BiDownArrow, {}), header.column.getIsSorted() === "desc" && jsxRuntime.jsx(bi.BiUpArrow, {})] }), header.column.getIsSorted() && (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
167
|
+
header.column.clearSorting();
|
|
168
|
+
}, children: jsxRuntime.jsx(cg.CgClose, {}) }))] })) }));
|
|
169
|
+
}) }))) }));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
173
|
+
const { table } = useDataTableContext();
|
|
174
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
175
|
+
table.resetSorting();
|
|
176
|
+
}, children: text }));
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const EditSortingButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
180
|
+
const sortingModal = react.useDisclosure();
|
|
181
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(DialogRoot, { size: ["full", "full", "md", "md"], children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { children: jsxRuntime.jsxs(react.Button, { as: "div", variant: "ghost", onClick: sortingModal.onOpen, children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsx(DialogTitle, {}), title] }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(TableSorter, {}), jsxRuntime.jsx(ResetSortingButton, {})] }) }), jsxRuntime.jsx(DialogFooter, {})] })] }) }));
|
|
182
|
+
};
|
|
183
|
+
|
|
101
184
|
const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
102
185
|
const { children, inputProps, rootRef, ...rest } = props;
|
|
103
186
|
return (jsxRuntime.jsxs(react.RadioGroup.Item, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.RadioGroup.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.RadioGroup.ItemIndicator, {}), children && (jsxRuntime.jsx(react.RadioGroup.ItemText, { children: children }))] }));
|
|
@@ -380,87 +463,138 @@ const FilterDialog = ({ icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
|
|
|
380
463
|
return (jsxRuntime.jsxs(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", translate.t("filterDialog.buttonText")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("filterDialog.title") }) }), jsxRuntime.jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsxRuntime.jsx(TableFilter, {}) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(ResetFilteringButton, { text: translate.t("filterDialog.reset") }), jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, variant: "subtle", children: translate.t("filterDialog.close") })] }), jsxRuntime.jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
|
|
381
464
|
};
|
|
382
465
|
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
.map((column) => {
|
|
416
|
-
const displayName = column.columnDef.meta === undefined
|
|
417
|
-
? column.id
|
|
418
|
-
: column.columnDef.meta.displayName;
|
|
419
|
-
return jsxRuntime.jsx("span", { children: displayName }, column.id);
|
|
420
|
-
}), jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
421
|
-
const nextIndex = index + 1;
|
|
422
|
-
if (nextIndex < order.length) {
|
|
423
|
-
handleChangeOrder(index, nextIndex);
|
|
424
|
-
}
|
|
425
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] }, columnId))) }), jsxRuntime.jsxs(react.Flex, { gap: "0.25rem", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
426
|
-
table.setColumnOrder(order);
|
|
427
|
-
}, children: "Apply" }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
428
|
-
table.setColumnOrder(originalOrder);
|
|
429
|
-
}, children: "Reset" })] })] }));
|
|
430
|
-
};
|
|
431
|
-
const TableOrderer = () => {
|
|
466
|
+
const MenuContent = React__namespace.forwardRef(function MenuContent(props, ref) {
|
|
467
|
+
const { portalled = true, portalRef, ...rest } = props;
|
|
468
|
+
return (jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Menu.Positioner, { children: jsxRuntime.jsx(react.Menu.Content, { ref: ref, ...rest }) }) }));
|
|
469
|
+
});
|
|
470
|
+
React__namespace.forwardRef(function MenuArrow(props, ref) {
|
|
471
|
+
return (jsxRuntime.jsx(react.Menu.Arrow, { ref: ref, ...props, children: jsxRuntime.jsx(react.Menu.ArrowTip, {}) }));
|
|
472
|
+
});
|
|
473
|
+
React__namespace.forwardRef(function MenuCheckboxItem(props, ref) {
|
|
474
|
+
return (jsxRuntime.jsxs(react.Menu.CheckboxItem, { ref: ref, ...props, children: [jsxRuntime.jsx(react.Menu.ItemIndicator, { hidden: false, children: jsxRuntime.jsx(lu.LuCheck, {}) }), props.children] }));
|
|
475
|
+
});
|
|
476
|
+
React__namespace.forwardRef(function MenuRadioItem(props, ref) {
|
|
477
|
+
const { children, ...rest } = props;
|
|
478
|
+
return (jsxRuntime.jsxs(react.Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsxRuntime.jsx(react.AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsxRuntime.jsx(react.Menu.ItemIndicator, { children: jsxRuntime.jsx(lu.LuCheck, {}) }) }), jsxRuntime.jsx(react.Menu.ItemText, { children: children })] }));
|
|
479
|
+
});
|
|
480
|
+
React__namespace.forwardRef(function MenuItemGroup(props, ref) {
|
|
481
|
+
const { title, children, ...rest } = props;
|
|
482
|
+
return (jsxRuntime.jsxs(react.Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsxRuntime.jsx(react.Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
483
|
+
});
|
|
484
|
+
React__namespace.forwardRef(function MenuTriggerItem(props, ref) {
|
|
485
|
+
const { startIcon, children, ...rest } = props;
|
|
486
|
+
return (jsxRuntime.jsxs(react.Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsxRuntime.jsx(lu.LuChevronRight, {})] }));
|
|
487
|
+
});
|
|
488
|
+
react.Menu.RadioItemGroup;
|
|
489
|
+
react.Menu.ContextTrigger;
|
|
490
|
+
const MenuRoot = react.Menu.Root;
|
|
491
|
+
react.Menu.Separator;
|
|
492
|
+
const MenuItem = react.Menu.Item;
|
|
493
|
+
react.Menu.ItemText;
|
|
494
|
+
react.Menu.ItemCommand;
|
|
495
|
+
const MenuTrigger = react.Menu.Trigger;
|
|
496
|
+
|
|
497
|
+
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
432
498
|
const { table } = useDataTableContext();
|
|
433
|
-
return (jsxRuntime.
|
|
499
|
+
return (jsxRuntime.jsxs(MenuRoot, { children: [jsxRuntime.jsx(MenuTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsxRuntime.jsx(bi.BiDownArrow, {})] }) }), jsxRuntime.jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsxRuntime.jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
|
|
500
|
+
table.setPageSize(Number(pageSize));
|
|
501
|
+
}, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }));
|
|
434
502
|
};
|
|
435
503
|
|
|
436
|
-
const
|
|
437
|
-
|
|
504
|
+
const { withContext } = react.createRecipeContext({ key: "button" });
|
|
505
|
+
// Replace "a" with your framework's link component
|
|
506
|
+
const LinkButton = withContext("a");
|
|
507
|
+
|
|
508
|
+
const [RootPropsProvider, useRootProps] = react.createContext({
|
|
509
|
+
name: "RootPropsProvider",
|
|
510
|
+
});
|
|
511
|
+
const variantMap = {
|
|
512
|
+
outline: { default: "ghost", ellipsis: "plain", current: "outline" },
|
|
513
|
+
solid: { default: "outline", ellipsis: "outline", current: "solid" },
|
|
514
|
+
subtle: { default: "ghost", ellipsis: "plain", current: "subtle" },
|
|
438
515
|
};
|
|
516
|
+
const PaginationRoot = React__namespace.forwardRef(function PaginationRoot(props, ref) {
|
|
517
|
+
const { size = "sm", variant = "outline", getHref, ...rest } = props;
|
|
518
|
+
return (jsxRuntime.jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsxRuntime.jsx(react.Pagination.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
|
|
519
|
+
});
|
|
520
|
+
const PaginationEllipsis = React__namespace.forwardRef(function PaginationEllipsis(props, ref) {
|
|
521
|
+
const { size, variantMap } = useRootProps();
|
|
522
|
+
return (jsxRuntime.jsx(react.Pagination.Ellipsis, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { as: "span", variant: variantMap.ellipsis, size: size, children: jsxRuntime.jsx(hi2.HiMiniEllipsisHorizontal, {}) }) }));
|
|
523
|
+
});
|
|
524
|
+
const PaginationItem = React__namespace.forwardRef(function PaginationItem(props, ref) {
|
|
525
|
+
const { page } = react.usePaginationContext();
|
|
526
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
527
|
+
const current = page === props.value;
|
|
528
|
+
const variant = current ? variantMap.current : variantMap.default;
|
|
529
|
+
if (getHref) {
|
|
530
|
+
return (jsxRuntime.jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
|
|
531
|
+
}
|
|
532
|
+
return (jsxRuntime.jsx(react.Pagination.Item, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { variant: variant, size: size, children: props.value }) }));
|
|
533
|
+
});
|
|
534
|
+
const PaginationPrevTrigger = React__namespace.forwardRef(function PaginationPrevTrigger(props, ref) {
|
|
535
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
536
|
+
const { previousPage } = react.usePaginationContext();
|
|
537
|
+
if (getHref) {
|
|
538
|
+
return (jsxRuntime.jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }));
|
|
539
|
+
}
|
|
540
|
+
return (jsxRuntime.jsx(react.Pagination.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }) }));
|
|
541
|
+
});
|
|
542
|
+
const PaginationNextTrigger = React__namespace.forwardRef(function PaginationNextTrigger(props, ref) {
|
|
543
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
544
|
+
const { nextPage } = react.usePaginationContext();
|
|
545
|
+
if (getHref) {
|
|
546
|
+
return (jsxRuntime.jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }));
|
|
547
|
+
}
|
|
548
|
+
return (jsxRuntime.jsx(react.Pagination.NextTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }) }));
|
|
549
|
+
});
|
|
550
|
+
const PaginationItems = (props) => {
|
|
551
|
+
return (jsxRuntime.jsx(react.Pagination.Context, { children: ({ pages }) => pages.map((page, index) => {
|
|
552
|
+
return page.type === "ellipsis" ? (jsxRuntime.jsx(PaginationEllipsis, { index: index, ...props }, index)) : (jsxRuntime.jsx(PaginationItem, { type: "page", value: page.value, ...props }, index));
|
|
553
|
+
}) }));
|
|
554
|
+
};
|
|
555
|
+
const PaginationPageText = React__namespace.forwardRef(function PaginationPageText(props, ref) {
|
|
556
|
+
const { format = "compact", ...rest } = props;
|
|
557
|
+
const { page, totalPages, pageRange, count } = react.usePaginationContext();
|
|
558
|
+
const content = React__namespace.useMemo(() => {
|
|
559
|
+
if (format === "short")
|
|
560
|
+
return `${page} / ${totalPages}`;
|
|
561
|
+
if (format === "compact")
|
|
562
|
+
return `${page} / ${totalPages}`;
|
|
563
|
+
return `${pageRange.start + 1} - ${Math.min(pageRange.end, count)} / ${count}`;
|
|
564
|
+
}, [format, page, totalPages, pageRange, count]);
|
|
565
|
+
return (jsxRuntime.jsx(react.Text, { fontWeight: "medium", ref: ref, ...rest, children: content }));
|
|
566
|
+
});
|
|
439
567
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
568
|
+
// TODO: not working in client side
|
|
569
|
+
const Pagination = () => {
|
|
570
|
+
const { table, type } = useDataTableContext();
|
|
571
|
+
const getCount = () => {
|
|
572
|
+
if (type === "client") {
|
|
573
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
574
|
+
}
|
|
575
|
+
return table.getRowCount();
|
|
576
|
+
};
|
|
577
|
+
return (jsxRuntime.jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
578
|
+
table.setPageIndex(e.page - 1);
|
|
579
|
+
}, children: jsxRuntime.jsxs(react.HStack, { children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), jsxRuntime.jsx(PaginationItems, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) }));
|
|
452
580
|
};
|
|
453
581
|
|
|
454
|
-
const
|
|
582
|
+
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
455
583
|
const { table } = useDataTableContext();
|
|
456
584
|
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
457
|
-
table.
|
|
585
|
+
table.resetRowSelection();
|
|
458
586
|
}, children: text }));
|
|
459
587
|
};
|
|
460
588
|
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
|
|
589
|
+
const RowCountText = () => {
|
|
590
|
+
const { table, type } = useDataTableContext();
|
|
591
|
+
const getCount = () => {
|
|
592
|
+
if (type === "client") {
|
|
593
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
594
|
+
}
|
|
595
|
+
return table.getRowCount();
|
|
596
|
+
};
|
|
597
|
+
return jsxRuntime.jsx(react.Text, { children: getCount() });
|
|
464
598
|
};
|
|
465
599
|
|
|
466
600
|
// pulling this into a separate file so adapter(s) that don't
|
|
@@ -2379,220 +2513,86 @@ function ColumnCard({ columnId }) {
|
|
|
2379
2513
|
onDragStart: () => setDragging(true), // NEW
|
|
2380
2514
|
onDrop: () => setDragging(false), // NEW
|
|
2381
2515
|
});
|
|
2382
|
-
}, [columnId, table]);
|
|
2383
|
-
return (jsxRuntime.jsxs(react.Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsxRuntime.jsx(react.Flex, { alignItems: "center", padding: "0", cursor: 'grab', children: jsxRuntime.jsx(fa6.FaGripLinesVertical, { color: "gray.400" }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "space-between", alignItems: "center", children: jsxRuntime.jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
|
|
2384
|
-
}
|
|
2385
|
-
function CardContainer({ location, children }) {
|
|
2386
|
-
const ref = React.useRef(null);
|
|
2387
|
-
const [isDraggedOver, setIsDraggedOver] = React.useState(false);
|
|
2388
|
-
React.useEffect(() => {
|
|
2389
|
-
const el = ref.current;
|
|
2390
|
-
invariant(el);
|
|
2391
|
-
return dropTargetForElements({
|
|
2392
|
-
element: el,
|
|
2393
|
-
getData: () => ({ location }),
|
|
2394
|
-
onDragEnter: () => setIsDraggedOver(true),
|
|
2395
|
-
onDragLeave: () => setIsDraggedOver(false),
|
|
2396
|
-
onDrop: () => setIsDraggedOver(false),
|
|
2397
|
-
});
|
|
2398
|
-
}, [location]);
|
|
2399
|
-
// const isDark = (location + location) % 2 === 1;
|
|
2400
|
-
function getColor(isDraggedOver) {
|
|
2401
|
-
if (isDraggedOver) {
|
|
2402
|
-
return {
|
|
2403
|
-
backgroundColor: "blue.400",
|
|
2404
|
-
_dark: {
|
|
2405
|
-
backgroundColor: "blue.400",
|
|
2406
|
-
},
|
|
2407
|
-
};
|
|
2408
|
-
}
|
|
2409
|
-
// return isDark ? "lightgrey" : "white";
|
|
2410
|
-
return {
|
|
2411
|
-
backgroundColor: undefined,
|
|
2412
|
-
_dark: {
|
|
2413
|
-
backgroundColor: undefined,
|
|
2414
|
-
},
|
|
2415
|
-
};
|
|
2416
|
-
}
|
|
2417
|
-
return (jsxRuntime.jsx(react.Box, { ...getColor(isDraggedOver), ref: ref, children: children }));
|
|
2418
|
-
}
|
|
2419
|
-
const TableViewer = () => {
|
|
2420
|
-
const { table } = useDataTableContext();
|
|
2421
|
-
const order = table.getState().columnOrder.length > 0
|
|
2422
|
-
? table.getState().columnOrder
|
|
2423
|
-
: table.getAllLeafColumns().map(({ id }) => {
|
|
2424
|
-
return id;
|
|
2425
|
-
});
|
|
2426
|
-
React.useEffect(() => {
|
|
2427
|
-
return monitorForElements({
|
|
2428
|
-
onDrop({ source, location }) {
|
|
2429
|
-
const destination = location.current.dropTargets[0];
|
|
2430
|
-
if (!destination) {
|
|
2431
|
-
return;
|
|
2432
|
-
}
|
|
2433
|
-
const destinationLocation = destination.data.location;
|
|
2434
|
-
// const sourceLocation = source.data.location;
|
|
2435
|
-
const sourceColumn = source.data.column;
|
|
2436
|
-
const columnOrder = order.map((id) => {
|
|
2437
|
-
if (id == sourceColumn.id) {
|
|
2438
|
-
return "<marker>";
|
|
2439
|
-
}
|
|
2440
|
-
return id;
|
|
2441
|
-
});
|
|
2442
|
-
const columnBefore = columnOrder.slice(0, destinationLocation + 1);
|
|
2443
|
-
const columnAfter = columnOrder.slice(destinationLocation + 1, columnOrder.length);
|
|
2444
|
-
const newOrder = [
|
|
2445
|
-
...columnBefore,
|
|
2446
|
-
sourceColumn.id,
|
|
2447
|
-
...columnAfter,
|
|
2448
|
-
].filter((id) => id != "<marker>");
|
|
2449
|
-
table.setColumnOrder(newOrder);
|
|
2450
|
-
},
|
|
2451
|
-
});
|
|
2452
|
-
}, [table]);
|
|
2453
|
-
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.25rem", children: order.map((columnId, index) => {
|
|
2454
|
-
return (jsxRuntime.jsx(CardContainer, { location: index, children: jsxRuntime.jsx(ColumnCard, { columnId: columnId }) }));
|
|
2455
|
-
}) }));
|
|
2456
|
-
};
|
|
2457
|
-
|
|
2458
|
-
const ViewDialog = ({ icon = jsxRuntime.jsx(io.IoMdEye, {}) }) => {
|
|
2459
|
-
const viewModel = react.useDisclosure();
|
|
2460
|
-
const { translate } = useDataTableContext();
|
|
2461
|
-
return (jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", translate.t("viewDialog.buttonText")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("viewDialog.title") }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }));
|
|
2462
|
-
};
|
|
2463
|
-
|
|
2464
|
-
const MenuContent = React__namespace.forwardRef(function MenuContent(props, ref) {
|
|
2465
|
-
const { portalled = true, portalRef, ...rest } = props;
|
|
2466
|
-
return (jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Menu.Positioner, { children: jsxRuntime.jsx(react.Menu.Content, { ref: ref, ...rest }) }) }));
|
|
2467
|
-
});
|
|
2468
|
-
React__namespace.forwardRef(function MenuArrow(props, ref) {
|
|
2469
|
-
return (jsxRuntime.jsx(react.Menu.Arrow, { ref: ref, ...props, children: jsxRuntime.jsx(react.Menu.ArrowTip, {}) }));
|
|
2470
|
-
});
|
|
2471
|
-
React__namespace.forwardRef(function MenuCheckboxItem(props, ref) {
|
|
2472
|
-
return (jsxRuntime.jsxs(react.Menu.CheckboxItem, { ref: ref, ...props, children: [jsxRuntime.jsx(react.Menu.ItemIndicator, { hidden: false, children: jsxRuntime.jsx(lu.LuCheck, {}) }), props.children] }));
|
|
2473
|
-
});
|
|
2474
|
-
React__namespace.forwardRef(function MenuRadioItem(props, ref) {
|
|
2475
|
-
const { children, ...rest } = props;
|
|
2476
|
-
return (jsxRuntime.jsxs(react.Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsxRuntime.jsx(react.AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsxRuntime.jsx(react.Menu.ItemIndicator, { children: jsxRuntime.jsx(lu.LuCheck, {}) }) }), jsxRuntime.jsx(react.Menu.ItemText, { children: children })] }));
|
|
2477
|
-
});
|
|
2478
|
-
React__namespace.forwardRef(function MenuItemGroup(props, ref) {
|
|
2479
|
-
const { title, children, ...rest } = props;
|
|
2480
|
-
return (jsxRuntime.jsxs(react.Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsxRuntime.jsx(react.Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
2481
|
-
});
|
|
2482
|
-
React__namespace.forwardRef(function MenuTriggerItem(props, ref) {
|
|
2483
|
-
const { startIcon, children, ...rest } = props;
|
|
2484
|
-
return (jsxRuntime.jsxs(react.Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsxRuntime.jsx(lu.LuChevronRight, {})] }));
|
|
2485
|
-
});
|
|
2486
|
-
react.Menu.RadioItemGroup;
|
|
2487
|
-
react.Menu.ContextTrigger;
|
|
2488
|
-
const MenuRoot = react.Menu.Root;
|
|
2489
|
-
react.Menu.Separator;
|
|
2490
|
-
const MenuItem = react.Menu.Item;
|
|
2491
|
-
react.Menu.ItemText;
|
|
2492
|
-
react.Menu.ItemCommand;
|
|
2493
|
-
const MenuTrigger = react.Menu.Trigger;
|
|
2494
|
-
|
|
2495
|
-
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
2496
|
-
const { table } = useDataTableContext();
|
|
2497
|
-
return (jsxRuntime.jsxs(MenuRoot, { children: [jsxRuntime.jsx(MenuTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsxRuntime.jsx(bi.BiDownArrow, {})] }) }), jsxRuntime.jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsxRuntime.jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
|
|
2498
|
-
table.setPageSize(Number(pageSize));
|
|
2499
|
-
}, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }));
|
|
2500
|
-
};
|
|
2501
|
-
|
|
2502
|
-
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
2503
|
-
const { table } = useDataTableContext();
|
|
2504
|
-
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
2505
|
-
table.resetRowSelection();
|
|
2506
|
-
}, children: text }));
|
|
2507
|
-
};
|
|
2508
|
-
|
|
2509
|
-
const RowCountText = () => {
|
|
2510
|
-
const { table, type } = useDataTableContext();
|
|
2511
|
-
const getCount = () => {
|
|
2512
|
-
if (type === "client") {
|
|
2513
|
-
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
2514
|
-
}
|
|
2515
|
-
return table.getRowCount();
|
|
2516
|
-
};
|
|
2517
|
-
return jsxRuntime.jsx(react.Text, { children: getCount() });
|
|
2518
|
-
};
|
|
2519
|
-
|
|
2520
|
-
const { withContext } = react.createRecipeContext({ key: "button" });
|
|
2521
|
-
// Replace "a" with your framework's link component
|
|
2522
|
-
const LinkButton = withContext("a");
|
|
2523
|
-
|
|
2524
|
-
const [RootPropsProvider, useRootProps] = react.createContext({
|
|
2525
|
-
name: "RootPropsProvider",
|
|
2526
|
-
});
|
|
2527
|
-
const variantMap = {
|
|
2528
|
-
outline: { default: "ghost", ellipsis: "plain", current: "outline" },
|
|
2529
|
-
solid: { default: "outline", ellipsis: "outline", current: "solid" },
|
|
2530
|
-
subtle: { default: "ghost", ellipsis: "plain", current: "subtle" },
|
|
2531
|
-
};
|
|
2532
|
-
const PaginationRoot = React__namespace.forwardRef(function PaginationRoot(props, ref) {
|
|
2533
|
-
const { size = "sm", variant = "outline", getHref, ...rest } = props;
|
|
2534
|
-
return (jsxRuntime.jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsxRuntime.jsx(react.Pagination.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
|
|
2535
|
-
});
|
|
2536
|
-
const PaginationEllipsis = React__namespace.forwardRef(function PaginationEllipsis(props, ref) {
|
|
2537
|
-
const { size, variantMap } = useRootProps();
|
|
2538
|
-
return (jsxRuntime.jsx(react.Pagination.Ellipsis, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { as: "span", variant: variantMap.ellipsis, size: size, children: jsxRuntime.jsx(hi2.HiMiniEllipsisHorizontal, {}) }) }));
|
|
2539
|
-
});
|
|
2540
|
-
const PaginationItem = React__namespace.forwardRef(function PaginationItem(props, ref) {
|
|
2541
|
-
const { page } = react.usePaginationContext();
|
|
2542
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2543
|
-
const current = page === props.value;
|
|
2544
|
-
const variant = current ? variantMap.current : variantMap.default;
|
|
2545
|
-
if (getHref) {
|
|
2546
|
-
return (jsxRuntime.jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
|
|
2547
|
-
}
|
|
2548
|
-
return (jsxRuntime.jsx(react.Pagination.Item, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { variant: variant, size: size, children: props.value }) }));
|
|
2549
|
-
});
|
|
2550
|
-
const PaginationPrevTrigger = React__namespace.forwardRef(function PaginationPrevTrigger(props, ref) {
|
|
2551
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2552
|
-
const { previousPage } = react.usePaginationContext();
|
|
2553
|
-
if (getHref) {
|
|
2554
|
-
return (jsxRuntime.jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }));
|
|
2555
|
-
}
|
|
2556
|
-
return (jsxRuntime.jsx(react.Pagination.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }) }));
|
|
2557
|
-
});
|
|
2558
|
-
const PaginationNextTrigger = React__namespace.forwardRef(function PaginationNextTrigger(props, ref) {
|
|
2559
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2560
|
-
const { nextPage } = react.usePaginationContext();
|
|
2561
|
-
if (getHref) {
|
|
2562
|
-
return (jsxRuntime.jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }));
|
|
2516
|
+
}, [columnId, table]);
|
|
2517
|
+
return (jsxRuntime.jsxs(react.Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsxRuntime.jsx(react.Flex, { alignItems: "center", padding: "0", cursor: 'grab', children: jsxRuntime.jsx(fa6.FaGripLinesVertical, { color: "gray.400" }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "space-between", alignItems: "center", children: jsxRuntime.jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
|
|
2518
|
+
}
|
|
2519
|
+
function CardContainer({ location, children }) {
|
|
2520
|
+
const ref = React.useRef(null);
|
|
2521
|
+
const [isDraggedOver, setIsDraggedOver] = React.useState(false);
|
|
2522
|
+
React.useEffect(() => {
|
|
2523
|
+
const el = ref.current;
|
|
2524
|
+
invariant(el);
|
|
2525
|
+
return dropTargetForElements({
|
|
2526
|
+
element: el,
|
|
2527
|
+
getData: () => ({ location }),
|
|
2528
|
+
onDragEnter: () => setIsDraggedOver(true),
|
|
2529
|
+
onDragLeave: () => setIsDraggedOver(false),
|
|
2530
|
+
onDrop: () => setIsDraggedOver(false),
|
|
2531
|
+
});
|
|
2532
|
+
}, [location]);
|
|
2533
|
+
// const isDark = (location + location) % 2 === 1;
|
|
2534
|
+
function getColor(isDraggedOver) {
|
|
2535
|
+
if (isDraggedOver) {
|
|
2536
|
+
return {
|
|
2537
|
+
backgroundColor: "blue.400",
|
|
2538
|
+
_dark: {
|
|
2539
|
+
backgroundColor: "blue.400",
|
|
2540
|
+
},
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
// return isDark ? "lightgrey" : "white";
|
|
2544
|
+
return {
|
|
2545
|
+
backgroundColor: undefined,
|
|
2546
|
+
_dark: {
|
|
2547
|
+
backgroundColor: undefined,
|
|
2548
|
+
},
|
|
2549
|
+
};
|
|
2563
2550
|
}
|
|
2564
|
-
return (jsxRuntime.jsx(react.
|
|
2565
|
-
}
|
|
2566
|
-
const
|
|
2567
|
-
|
|
2568
|
-
|
|
2551
|
+
return (jsxRuntime.jsx(react.Box, { ...getColor(isDraggedOver), ref: ref, children: children }));
|
|
2552
|
+
}
|
|
2553
|
+
const TableViewer = () => {
|
|
2554
|
+
const { table } = useDataTableContext();
|
|
2555
|
+
const order = table.getState().columnOrder.length > 0
|
|
2556
|
+
? table.getState().columnOrder
|
|
2557
|
+
: table.getAllLeafColumns().map(({ id }) => {
|
|
2558
|
+
return id;
|
|
2559
|
+
});
|
|
2560
|
+
React.useEffect(() => {
|
|
2561
|
+
return monitorForElements({
|
|
2562
|
+
onDrop({ source, location }) {
|
|
2563
|
+
const destination = location.current.dropTargets[0];
|
|
2564
|
+
if (!destination) {
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
const destinationLocation = destination.data.location;
|
|
2568
|
+
// const sourceLocation = source.data.location;
|
|
2569
|
+
const sourceColumn = source.data.column;
|
|
2570
|
+
const columnOrder = order.map((id) => {
|
|
2571
|
+
if (id == sourceColumn.id) {
|
|
2572
|
+
return "<marker>";
|
|
2573
|
+
}
|
|
2574
|
+
return id;
|
|
2575
|
+
});
|
|
2576
|
+
const columnBefore = columnOrder.slice(0, destinationLocation + 1);
|
|
2577
|
+
const columnAfter = columnOrder.slice(destinationLocation + 1, columnOrder.length);
|
|
2578
|
+
const newOrder = [
|
|
2579
|
+
...columnBefore,
|
|
2580
|
+
sourceColumn.id,
|
|
2581
|
+
...columnAfter,
|
|
2582
|
+
].filter((id) => id != "<marker>");
|
|
2583
|
+
table.setColumnOrder(newOrder);
|
|
2584
|
+
},
|
|
2585
|
+
});
|
|
2586
|
+
}, [table]);
|
|
2587
|
+
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.25rem", children: order.map((columnId, index) => {
|
|
2588
|
+
return (jsxRuntime.jsx(CardContainer, { location: index, children: jsxRuntime.jsx(ColumnCard, { columnId: columnId }) }));
|
|
2569
2589
|
}) }));
|
|
2570
2590
|
};
|
|
2571
|
-
const PaginationPageText = React__namespace.forwardRef(function PaginationPageText(props, ref) {
|
|
2572
|
-
const { format = "compact", ...rest } = props;
|
|
2573
|
-
const { page, totalPages, pageRange, count } = react.usePaginationContext();
|
|
2574
|
-
const content = React__namespace.useMemo(() => {
|
|
2575
|
-
if (format === "short")
|
|
2576
|
-
return `${page} / ${totalPages}`;
|
|
2577
|
-
if (format === "compact")
|
|
2578
|
-
return `${page} / ${totalPages}`;
|
|
2579
|
-
return `${pageRange.start + 1} - ${Math.min(pageRange.end, count)} / ${count}`;
|
|
2580
|
-
}, [format, page, totalPages, pageRange, count]);
|
|
2581
|
-
return (jsxRuntime.jsx(react.Text, { fontWeight: "medium", ref: ref, ...rest, children: content }));
|
|
2582
|
-
});
|
|
2583
2591
|
|
|
2584
|
-
|
|
2585
|
-
const
|
|
2586
|
-
const {
|
|
2587
|
-
|
|
2588
|
-
if (type === "client") {
|
|
2589
|
-
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
2590
|
-
}
|
|
2591
|
-
return table.getRowCount();
|
|
2592
|
-
};
|
|
2593
|
-
return (jsxRuntime.jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
2594
|
-
table.setPageIndex(e.page - 1);
|
|
2595
|
-
}, children: jsxRuntime.jsxs(react.HStack, { children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), jsxRuntime.jsx(PaginationItems, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) }));
|
|
2592
|
+
const ViewDialog = ({ icon = jsxRuntime.jsx(io.IoMdEye, {}) }) => {
|
|
2593
|
+
const viewModel = react.useDisclosure();
|
|
2594
|
+
const { translate } = useDataTableContext();
|
|
2595
|
+
return (jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", translate.t("viewDialog.buttonText")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("viewDialog.title") }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }));
|
|
2596
2596
|
};
|
|
2597
2597
|
|
|
2598
2598
|
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
@@ -2603,6 +2603,28 @@ const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined,
|
|
|
2603
2603
|
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto auto", gap: "1rem", children: [!!imageColumnId && (jsxRuntime.jsx(react.Image, { width: "100%", src: row.original[imageColumnId], ...imageProps })), isShowFirstColumn && (jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: [!!titleColumnId && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] })), showTag && (jsxRuntime.jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] }))] }));
|
|
2604
2604
|
};
|
|
2605
2605
|
|
|
2606
|
+
const DataTableServerContext = React.createContext({
|
|
2607
|
+
url: "",
|
|
2608
|
+
});
|
|
2609
|
+
|
|
2610
|
+
const useDataTableServerContext = () => {
|
|
2611
|
+
const context = React.useContext(DataTableServerContext);
|
|
2612
|
+
const { query } = context;
|
|
2613
|
+
const isEmpty = (query.data?.count ?? 0) <= 0;
|
|
2614
|
+
return { ...context, isEmpty };
|
|
2615
|
+
};
|
|
2616
|
+
|
|
2617
|
+
const EmptyState$1 = ({ title = "No records", description = "Add a new events to get started or refine your search", }) => {
|
|
2618
|
+
const { isEmpty } = useDataTableServerContext();
|
|
2619
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isEmpty && (jsxRuntime.jsx(react.EmptyState.Root, { children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [jsxRuntime.jsx(react.EmptyState.Indicator, { children: jsxRuntime.jsx(hi.HiColorSwatch, {}) }), jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })] }) })) }));
|
|
2620
|
+
};
|
|
2621
|
+
|
|
2622
|
+
const ErrorAlert = ({ showMessage = true }) => {
|
|
2623
|
+
const { query } = useDataTableServerContext();
|
|
2624
|
+
const { isError, error } = query;
|
|
2625
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isError && (jsxRuntime.jsxs(react.Alert.Root, { status: "error", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsxs(react.Alert.Content, { children: [jsxRuntime.jsx(react.Alert.Title, { children: error.name }), showMessage && (jsxRuntime.jsx(react.Alert.Description, { children: error.message }))] })] })) }));
|
|
2626
|
+
};
|
|
2627
|
+
|
|
2606
2628
|
const snakeToLabel = (str) => {
|
|
2607
2629
|
return str
|
|
2608
2630
|
.split("_") // Split by underscore
|
|
@@ -2849,10 +2871,6 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2849
2871
|
}, children: children }));
|
|
2850
2872
|
}
|
|
2851
2873
|
|
|
2852
|
-
const DataTableServerContext = React.createContext({
|
|
2853
|
-
url: "",
|
|
2854
|
-
});
|
|
2855
|
-
|
|
2856
2874
|
/**
|
|
2857
2875
|
* DataTableServer will create a context to hold all values to
|
|
2858
2876
|
* help the render of the DataTable in serverside
|
|
@@ -3036,13 +3054,6 @@ const GlobalFilter = () => {
|
|
|
3036
3054
|
} }) }) }));
|
|
3037
3055
|
};
|
|
3038
3056
|
|
|
3039
|
-
const useDataTableServerContext = () => {
|
|
3040
|
-
const context = React.useContext(DataTableServerContext);
|
|
3041
|
-
const { query } = context;
|
|
3042
|
-
const isEmpty = (query.data?.count ?? 0) <= 0;
|
|
3043
|
-
return { ...context, isEmpty };
|
|
3044
|
-
};
|
|
3045
|
-
|
|
3046
3057
|
const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
|
|
3047
3058
|
const { url } = useDataTableServerContext();
|
|
3048
3059
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -3256,12 +3267,12 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3256
3267
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3257
3268
|
};
|
|
3258
3269
|
|
|
3259
|
-
const EmptyState
|
|
3270
|
+
const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
3260
3271
|
const { title, description, icon, children, ...rest } = props;
|
|
3261
3272
|
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
3262
3273
|
});
|
|
3263
3274
|
|
|
3264
|
-
const EmptyResult = (jsxRuntime.jsx(EmptyState
|
|
3275
|
+
const EmptyResult = (jsxRuntime.jsx(EmptyState, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
3265
3276
|
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3266
3277
|
const { table } = useDataTableContext();
|
|
3267
3278
|
if (table.getRowModel().rows.length <= 0) {
|
|
@@ -3530,16 +3541,15 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3530
3541
|
return columns;
|
|
3531
3542
|
};
|
|
3532
3543
|
|
|
3533
|
-
const
|
|
3534
|
-
const {
|
|
3535
|
-
return (jsxRuntime.
|
|
3536
|
-
};
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
};
|
|
3544
|
+
const AccordionItemTrigger = React__namespace.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3545
|
+
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3546
|
+
return (jsxRuntime.jsxs(react.Accordion.ItemTrigger, { ...rest, ref: ref, children: [indicatorPlacement === "start" && (jsxRuntime.jsx(react.Accordion.ItemIndicator, { rotate: { base: "-90deg", _open: "0deg" }, children: jsxRuntime.jsx(lu.LuChevronDown, {}) })), jsxRuntime.jsx(react.HStack, { gap: "4", flex: "1", textAlign: "start", width: "full", children: children }), indicatorPlacement === "end" && (jsxRuntime.jsx(react.Accordion.ItemIndicator, { children: jsxRuntime.jsx(lu.LuChevronDown, {}) }))] }));
|
|
3547
|
+
});
|
|
3548
|
+
const AccordionItemContent = React__namespace.forwardRef(function AccordionItemContent(props, ref) {
|
|
3549
|
+
return (jsxRuntime.jsx(react.Accordion.ItemContent, { children: jsxRuntime.jsx(react.Accordion.ItemBody, { ...props, ref: ref }) }));
|
|
3550
|
+
});
|
|
3551
|
+
const AccordionRoot = react.Accordion.Root;
|
|
3552
|
+
const AccordionItem = react.Accordion.Item;
|
|
3543
3553
|
|
|
3544
3554
|
//@ts-expect-error TODO: find appropriate type
|
|
3545
3555
|
const SchemaFormContext = React.createContext({
|
|
@@ -3562,15 +3572,56 @@ const clearEmptyString = (object) => {
|
|
|
3562
3572
|
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== ""));
|
|
3563
3573
|
};
|
|
3564
3574
|
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
}
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3571
|
-
});
|
|
3572
|
-
|
|
3573
|
-
|
|
3575
|
+
const idPickerSanityCheck = (column, foreign_key) => {
|
|
3576
|
+
if (!!foreign_key == false) {
|
|
3577
|
+
throw new Error(`The key foreign_key does not exist in properties of column ${column} when using id-picker.`);
|
|
3578
|
+
}
|
|
3579
|
+
const { table, column: foreignKeyColumn, display_column } = foreign_key;
|
|
3580
|
+
if (!!table == false) {
|
|
3581
|
+
throw new Error(`The key table does not exist in properties of column ${table} when using id-picker.`);
|
|
3582
|
+
}
|
|
3583
|
+
if (!!display_column == false) {
|
|
3584
|
+
throw new Error(`The key display_column does not exist in properties of column ${column} when using id-picker.`);
|
|
3585
|
+
}
|
|
3586
|
+
if (!!foreignKeyColumn == false) {
|
|
3587
|
+
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
3588
|
+
}
|
|
3589
|
+
};
|
|
3590
|
+
const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, children, order = [], ignore = [], include = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, getUpdatedData = () => { }, }) => {
|
|
3591
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
3592
|
+
const [isError, setIsError] = React.useState(false);
|
|
3593
|
+
const [isSubmiting, setIsSubmiting] = React.useState(false);
|
|
3594
|
+
const [isConfirming, setIsConfirming] = React.useState(false);
|
|
3595
|
+
const [validatedData, setValidatedData] = React.useState();
|
|
3596
|
+
const [error, setError] = React.useState();
|
|
3597
|
+
return (jsxRuntime.jsx(SchemaFormContext.Provider, { value: {
|
|
3598
|
+
schema,
|
|
3599
|
+
serverUrl,
|
|
3600
|
+
order,
|
|
3601
|
+
ignore,
|
|
3602
|
+
include,
|
|
3603
|
+
// @ts-expect-error TODO: find appropriate types
|
|
3604
|
+
onSubmit,
|
|
3605
|
+
rowNumber,
|
|
3606
|
+
idMap,
|
|
3607
|
+
setIdMap,
|
|
3608
|
+
translate,
|
|
3609
|
+
requestOptions,
|
|
3610
|
+
isSuccess,
|
|
3611
|
+
setIsSuccess,
|
|
3612
|
+
isError,
|
|
3613
|
+
setIsError,
|
|
3614
|
+
isSubmiting,
|
|
3615
|
+
setIsSubmiting,
|
|
3616
|
+
isConfirming,
|
|
3617
|
+
setIsConfirming,
|
|
3618
|
+
validatedData,
|
|
3619
|
+
setValidatedData,
|
|
3620
|
+
error,
|
|
3621
|
+
setError,
|
|
3622
|
+
getUpdatedData,
|
|
3623
|
+
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: children }) }));
|
|
3624
|
+
};
|
|
3574
3625
|
|
|
3575
3626
|
function removeIndex(str) {
|
|
3576
3627
|
return str.replace(/\.\d+\./g, '.');
|
|
@@ -3721,10 +3772,11 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3721
3772
|
const colLabel = `${prefix}${column}`;
|
|
3722
3773
|
const [open, setOpen] = React.useState(false);
|
|
3723
3774
|
const selectedDate = watch(colLabel);
|
|
3775
|
+
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3724
3776
|
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.fieldLabel`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3725
3777
|
gridRow, children: [jsxRuntime.jsxs(PopoverRoot, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: jsxRuntime.jsx(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
3726
3778
|
setOpen(true);
|
|
3727
|
-
}, children: selectedDate !== undefined ?
|
|
3779
|
+
}, children: selectedDate !== undefined ? `${formatedDate}` : "" }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(DatePicker$1
|
|
3728
3780
|
// @ts-expect-error TODO: find appropriate types
|
|
3729
3781
|
, {
|
|
3730
3782
|
// @ts-expect-error TODO: find appropriate types
|
|
@@ -4927,30 +4979,23 @@ const ColumnViewer = ({ column, properties, prefix, }) => {
|
|
|
4927
4979
|
return jsxRuntime.jsx(SchemaViewer, { schema: colSchema, prefix, column });
|
|
4928
4980
|
};
|
|
4929
4981
|
|
|
4930
|
-
const
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
const
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
4943
|
-
}
|
|
4982
|
+
const SubmitButton = () => {
|
|
4983
|
+
const { translate, setValidatedData, setIsError, setIsConfirming } = useSchemaContext();
|
|
4984
|
+
const methods = reactHookForm.useFormContext();
|
|
4985
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4986
|
+
const onValid = (data) => {
|
|
4987
|
+
setValidatedData(data);
|
|
4988
|
+
setIsError(false);
|
|
4989
|
+
setIsConfirming(true);
|
|
4990
|
+
};
|
|
4991
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
4992
|
+
methods.handleSubmit(onValid)();
|
|
4993
|
+
}, formNoValidate: true, children: translate.t("submit") }));
|
|
4944
4994
|
};
|
|
4945
|
-
|
|
4946
|
-
|
|
4995
|
+
|
|
4996
|
+
const FormBody = () => {
|
|
4997
|
+
const { schema, requestUrl, order, ignore, include, onSubmit, rowNumber, translate, requestOptions, isSuccess, setIsSuccess, isError, setIsError, isSubmiting, setIsSubmiting, isConfirming, setIsConfirming, validatedData, setValidatedData, error, setError, getUpdatedData, } = useSchemaContext();
|
|
4947
4998
|
const methods = reactHookForm.useFormContext();
|
|
4948
|
-
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
4949
|
-
const [isError, setIsError] = React.useState(false);
|
|
4950
|
-
const [isSubmiting, setIsSubmiting] = React.useState(false);
|
|
4951
|
-
const [isConfirming, setIsConfirming] = React.useState(false);
|
|
4952
|
-
const [validatedData, setValidatedData] = React.useState();
|
|
4953
|
-
const [error, setError] = React.useState();
|
|
4954
4999
|
const { properties } = schema;
|
|
4955
5000
|
const onBeforeSubmit = () => {
|
|
4956
5001
|
setIsSubmiting(true);
|
|
@@ -4958,8 +5003,9 @@ const FormInternal = () => {
|
|
|
4958
5003
|
const onAfterSubmit = () => {
|
|
4959
5004
|
setIsSubmiting(false);
|
|
4960
5005
|
};
|
|
4961
|
-
const onSubmitError = () => {
|
|
5006
|
+
const onSubmitError = (error) => {
|
|
4962
5007
|
setIsError(true);
|
|
5008
|
+
setError(error);
|
|
4963
5009
|
};
|
|
4964
5010
|
const onSubmitSuccess = () => {
|
|
4965
5011
|
setIsSuccess(true);
|
|
@@ -4971,9 +5017,7 @@ const FormInternal = () => {
|
|
|
4971
5017
|
onSubmitSuccess();
|
|
4972
5018
|
}
|
|
4973
5019
|
catch (error) {
|
|
4974
|
-
|
|
4975
|
-
setError(error);
|
|
4976
|
-
onSubmitError();
|
|
5020
|
+
onSubmitError(error);
|
|
4977
5021
|
}
|
|
4978
5022
|
finally {
|
|
4979
5023
|
onAfterSubmit();
|
|
@@ -4996,12 +5040,6 @@ const FormInternal = () => {
|
|
|
4996
5040
|
}
|
|
4997
5041
|
await defaultOnSubmit(onSubmit(data));
|
|
4998
5042
|
};
|
|
4999
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5000
|
-
const onValid = (data) => {
|
|
5001
|
-
setValidatedData(data);
|
|
5002
|
-
setIsError(false);
|
|
5003
|
-
setIsConfirming(true);
|
|
5004
|
-
};
|
|
5005
5043
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
5006
5044
|
const included = include.length > 0 ? include : keys;
|
|
5007
5045
|
const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
|
|
@@ -5016,58 +5054,47 @@ const FormInternal = () => {
|
|
|
5016
5054
|
include,
|
|
5017
5055
|
});
|
|
5018
5056
|
if (isSuccess) {
|
|
5019
|
-
return (jsxRuntime.jsxs(react.
|
|
5057
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsxs(react.Alert.Root, { status: "success", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsx(react.Alert.Title, { children: translate.t("submitSuccess") })] }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(react.Button, { onClick: async () => {
|
|
5020
5058
|
setIsError(false);
|
|
5021
5059
|
setIsSubmiting(false);
|
|
5022
5060
|
setIsSuccess(false);
|
|
5023
5061
|
setIsConfirming(false);
|
|
5024
5062
|
setValidatedData(undefined);
|
|
5025
|
-
|
|
5063
|
+
const data = await getUpdatedData();
|
|
5064
|
+
methods.reset(data);
|
|
5026
5065
|
}, formNoValidate: true, children: translate.t("submitAgain") }) })] }));
|
|
5027
5066
|
}
|
|
5028
5067
|
if (isConfirming) {
|
|
5029
|
-
return (jsxRuntime.jsxs(react.
|
|
5068
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsx(react.Grid, { gap: 4, gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat(${rowNumber ?? "auto-fit"}, auto)`, children: ordered.map((column) => {
|
|
5030
5069
|
return (jsxRuntime.jsx(ColumnViewer
|
|
5031
5070
|
// @ts-expect-error find suitable types
|
|
5032
5071
|
, {
|
|
5033
5072
|
// @ts-expect-error find suitable types
|
|
5034
5073
|
properties: properties, prefix: ``, column }, `form-viewer-${column}`));
|
|
5035
|
-
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
5074
|
+
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5036
5075
|
setIsConfirming(false);
|
|
5037
|
-
}, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
5076
|
+
}, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5038
5077
|
onFormSubmit(validatedData);
|
|
5039
|
-
}, children: translate.t("confirm") })] }), isSubmiting && (jsxRuntime.jsx(react.Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsxRuntime.jsx(react.Center, { h: "full", children: jsxRuntime.jsx(react.Spinner, { color: "teal.500" }) }) })), isError && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react.Alert.Root, { status: "error", children: jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [
|
|
5078
|
+
}, children: translate.t("confirm") })] }), isSubmiting && (jsxRuntime.jsx(react.Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsxRuntime.jsx(react.Center, { h: "full", children: jsxRuntime.jsx(react.Spinner, { color: "teal.500" }) }) })), isError && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react.Alert.Root, { status: "error", children: jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "b", children: [jsxRuntime.jsxs(AccordionItemTrigger, { children: [jsxRuntime.jsx(react.Alert.Indicator, {}), `${error}`] }), jsxRuntime.jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) }) }))] }));
|
|
5040
5079
|
}
|
|
5041
|
-
return (jsxRuntime.
|
|
5042
|
-
|
|
5080
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsx(react.Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat(${rowNumber ?? "auto-fit"}, auto)`, children: ordered.map((column) => {
|
|
5081
|
+
return (jsxRuntime.jsx(ColumnRenderer
|
|
5082
|
+
// @ts-expect-error find suitable types
|
|
5083
|
+
, {
|
|
5043
5084
|
// @ts-expect-error find suitable types
|
|
5044
|
-
, {
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
methods.reset();
|
|
5049
|
-
}, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
5050
|
-
methods.handleSubmit(onValid)();
|
|
5051
|
-
}, formNoValidate: true, children: translate.t("submit") })] })] }) }));
|
|
5085
|
+
properties: properties, prefix: ``, column }, `form-input-${column}`));
|
|
5086
|
+
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5087
|
+
methods.reset();
|
|
5088
|
+
}, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(SubmitButton, {})] })] }));
|
|
5052
5089
|
};
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
ignore,
|
|
5062
|
-
include,
|
|
5063
|
-
// @ts-expect-error TODO: find appropriate types
|
|
5064
|
-
onSubmit,
|
|
5065
|
-
rowNumber,
|
|
5066
|
-
idMap,
|
|
5067
|
-
setIdMap,
|
|
5068
|
-
translate,
|
|
5069
|
-
requestOptions,
|
|
5070
|
-
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FormInternal, {}) }) }));
|
|
5090
|
+
|
|
5091
|
+
const FormTitle = () => {
|
|
5092
|
+
const { translate } = useSchemaContext();
|
|
5093
|
+
return jsxRuntime.jsx(react.Heading, { children: translate.t("title") });
|
|
5094
|
+
};
|
|
5095
|
+
|
|
5096
|
+
const DefaultForm = ({ formConfig, }) => {
|
|
5097
|
+
return (jsxRuntime.jsx(FormRoot, { ...formConfig, children: jsxRuntime.jsxs(react.Grid, { gap: "2", children: [jsxRuntime.jsx(FormTitle, {}), jsxRuntime.jsx(FormBody, {})] }) }));
|
|
5071
5098
|
};
|
|
5072
5099
|
|
|
5073
5100
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5105,15 +5132,18 @@ exports.DataDisplay = DataDisplay;
|
|
|
5105
5132
|
exports.DataTable = DataTable;
|
|
5106
5133
|
exports.DataTableServer = DataTableServer;
|
|
5107
5134
|
exports.DefaultCardTitle = DefaultCardTitle;
|
|
5135
|
+
exports.DefaultForm = DefaultForm;
|
|
5108
5136
|
exports.DefaultTable = DefaultTable;
|
|
5109
5137
|
exports.DensityToggleButton = DensityToggleButton;
|
|
5110
5138
|
exports.EditOrderButton = EditOrderButton;
|
|
5111
5139
|
exports.EditSortingButton = EditSortingButton;
|
|
5112
|
-
exports.EmptyState = EmptyState;
|
|
5140
|
+
exports.EmptyState = EmptyState$1;
|
|
5113
5141
|
exports.ErrorAlert = ErrorAlert;
|
|
5114
5142
|
exports.FilterDialog = FilterDialog;
|
|
5115
5143
|
exports.FilterOptions = FilterOptions;
|
|
5116
|
-
exports.
|
|
5144
|
+
exports.FormBody = FormBody;
|
|
5145
|
+
exports.FormRoot = FormRoot;
|
|
5146
|
+
exports.FormTitle = FormTitle;
|
|
5117
5147
|
exports.GlobalFilter = GlobalFilter;
|
|
5118
5148
|
exports.PageSizeControl = PageSizeControl;
|
|
5119
5149
|
exports.Pagination = Pagination;
|