@bsol-oss/react-datatable5 8.0.1 → 8.1.1
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 +10 -2
- package/dist/index.js +255 -274
- package/dist/index.mjs +250 -270
- package/dist/types/components/Form/Form.d.ts +2 -0
- package/dist/types/components/Form/SchemaFormContext.d.ts +4 -2
- package/dist/types/components/Form/components/IdViewer.d.ts +3 -1
- package/dist/types/components/Form/components/StringInputField.d.ts +8 -5
- package/dist/types/components/Form/useSchemaContext.d.ts +4 -2
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -371,7 +371,7 @@ const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
|
371
371
|
}, children: text }));
|
|
372
372
|
};
|
|
373
373
|
|
|
374
|
-
const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
|
|
374
|
+
const EditFilterButton$1 = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
|
|
375
375
|
const filterModal = react.useDisclosure();
|
|
376
376
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: title }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "1rem", children: [jsxRuntime.jsx(TableFilter, {}), jsxRuntime.jsx(ResetFilteringButton, { text: resetText })] }) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(DialogActionTrigger, { asChild: true, children: jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, children: closeText }) }), jsxRuntime.jsx(react.Button, { children: "Save" })] }), jsxRuntime.jsx(DialogCloseTrigger, {})] })] }) }) }));
|
|
377
377
|
};
|
|
@@ -2450,7 +2450,7 @@ const TableViewer = () => {
|
|
|
2450
2450
|
}) }));
|
|
2451
2451
|
};
|
|
2452
2452
|
|
|
2453
|
-
const EditViewButton = ({ text, icon = jsxRuntime.jsx(io.IoMdEye, {}), title = "Edit View", }) => {
|
|
2453
|
+
const EditViewButton$1 = ({ text, icon = jsxRuntime.jsx(io.IoMdEye, {}), title = "Edit View", }) => {
|
|
2454
2454
|
const viewModel = react.useDisclosure();
|
|
2455
2455
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: 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, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsx(DialogTitle, {}), title] }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }) }));
|
|
2456
2456
|
};
|
|
@@ -2605,7 +2605,6 @@ const snakeToLabel = (str) => {
|
|
|
2605
2605
|
};
|
|
2606
2606
|
|
|
2607
2607
|
const RecordDisplay = ({ object, boxProps }) => {
|
|
2608
|
-
console.log(object, "dkfos");
|
|
2609
2608
|
if (object === null) {
|
|
2610
2609
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "null" });
|
|
2611
2610
|
}
|
|
@@ -3198,7 +3197,7 @@ const useDataTableServerContext = () => {
|
|
|
3198
3197
|
return { ...context, isEmpty };
|
|
3199
3198
|
};
|
|
3200
3199
|
|
|
3201
|
-
const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
|
|
3200
|
+
const ReloadButton$1 = ({ text = "Reload", variant = "icon", }) => {
|
|
3202
3201
|
const { url } = useDataTableServerContext();
|
|
3203
3202
|
const queryClient = reactQuery.useQueryClient();
|
|
3204
3203
|
if (variant === "icon") {
|
|
@@ -3243,7 +3242,7 @@ const TableComponent = ({ render = () => {
|
|
|
3243
3242
|
return render(table);
|
|
3244
3243
|
};
|
|
3245
3244
|
|
|
3246
|
-
const TableFilterTags = () => {
|
|
3245
|
+
const TableFilterTags$1 = () => {
|
|
3247
3246
|
const { table } = useDataTableContext();
|
|
3248
3247
|
return (jsxRuntime.jsx(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }) => {
|
|
3249
3248
|
return (jsxRuntime.jsx(Tag, { gap: "0.5rem", closable: true, cursor: "pointer", onClick: () => {
|
|
@@ -3478,7 +3477,7 @@ const ErrorAlert = ({ showMessage = true }) => {
|
|
|
3478
3477
|
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 }))] })] })) }));
|
|
3479
3478
|
};
|
|
3480
3479
|
|
|
3481
|
-
const FilterOptions = ({ column }) => {
|
|
3480
|
+
const FilterOptions$1 = ({ column }) => {
|
|
3482
3481
|
const { table } = useDataTableContext();
|
|
3483
3482
|
const tableColumn = table.getColumn(column);
|
|
3484
3483
|
const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
|
|
@@ -3510,7 +3509,7 @@ const InputGroup = React__namespace.forwardRef(function InputGroup(props, ref) {
|
|
|
3510
3509
|
}), endElement && (jsxRuntime.jsx(react.InputElement, { placement: "end", ...endElementProps, children: endElement }))] }));
|
|
3511
3510
|
});
|
|
3512
3511
|
|
|
3513
|
-
const GlobalFilter = () => {
|
|
3512
|
+
const GlobalFilter$1 = () => {
|
|
3514
3513
|
const { table } = useDataTableContext();
|
|
3515
3514
|
const [searchTerm, setSearchTerm] = React.useState("");
|
|
3516
3515
|
const debouncedSearchTerm = usehooks.useDebounce(searchTerm, 500);
|
|
@@ -3560,16 +3559,17 @@ const Field = React__namespace.forwardRef(function Field(props, ref) {
|
|
|
3560
3559
|
});
|
|
3561
3560
|
|
|
3562
3561
|
const useSchemaContext = () => {
|
|
3563
|
-
const { schema, serverUrl, order, ignore, onSubmit,
|
|
3562
|
+
const { schema, serverUrl, order, ignore, onSubmit, rowNumber, displayText, idMap, setIdMap, } = React.useContext(SchemaFormContext);
|
|
3564
3563
|
return {
|
|
3565
3564
|
schema,
|
|
3566
3565
|
serverUrl,
|
|
3567
3566
|
order,
|
|
3568
3567
|
ignore,
|
|
3569
3568
|
onSubmit,
|
|
3570
|
-
preLoadedValues,
|
|
3571
3569
|
rowNumber,
|
|
3572
3570
|
displayText,
|
|
3571
|
+
idMap,
|
|
3572
|
+
setIdMap,
|
|
3573
3573
|
};
|
|
3574
3574
|
};
|
|
3575
3575
|
|
|
@@ -3607,7 +3607,7 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
|
|
|
3607
3607
|
|
|
3608
3608
|
const IdPicker = ({ column, isMultiple = false }) => {
|
|
3609
3609
|
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
3610
|
-
const { schema, serverUrl, displayText } = useSchemaContext();
|
|
3610
|
+
const { schema, serverUrl, displayText, idMap, setIdMap } = useSchemaContext();
|
|
3611
3611
|
const { fieldRequired } = displayText;
|
|
3612
3612
|
const { required } = schema;
|
|
3613
3613
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -3617,21 +3617,20 @@ const IdPicker = ({ column, isMultiple = false }) => {
|
|
|
3617
3617
|
const { total, showing, typeToSearch } = displayText;
|
|
3618
3618
|
const { gridColumn, gridRow, title, renderDisplay, foreign_key } = schema
|
|
3619
3619
|
.properties[column];
|
|
3620
|
-
const { table
|
|
3620
|
+
const { table, column: column_ref, display_column, } = foreign_key;
|
|
3621
3621
|
const [searchText, setSearchText] = React.useState();
|
|
3622
3622
|
const [limit, setLimit] = React.useState(10);
|
|
3623
3623
|
const [openSearchResult, setOpenSearchResult] = React.useState();
|
|
3624
3624
|
const [page, setPage] = React.useState(0);
|
|
3625
|
-
const [idMap, setIdMap] = React.useState({});
|
|
3626
3625
|
const ref = React.useRef(null);
|
|
3627
3626
|
const selectedIds = watch(column) ?? [];
|
|
3628
3627
|
const query = reactQuery.useQuery({
|
|
3629
|
-
queryKey: [`idpicker`, { searchText, limit, page }],
|
|
3628
|
+
queryKey: [`idpicker`, { column, searchText, limit, page }],
|
|
3630
3629
|
queryFn: async () => {
|
|
3631
3630
|
const data = await getTableData({
|
|
3632
3631
|
serverUrl,
|
|
3633
3632
|
searching: searchText ?? "",
|
|
3634
|
-
in_table:
|
|
3633
|
+
in_table: table,
|
|
3635
3634
|
limit: limit,
|
|
3636
3635
|
offset: page * 10,
|
|
3637
3636
|
});
|
|
@@ -3651,33 +3650,8 @@ const IdPicker = ({ column, isMultiple = false }) => {
|
|
|
3651
3650
|
enabled: (searchText ?? "")?.length > 0,
|
|
3652
3651
|
staleTime: 300000,
|
|
3653
3652
|
});
|
|
3654
|
-
reactQuery.useQuery({
|
|
3655
|
-
queryKey: [`idpicker`, { selectedIds }],
|
|
3656
|
-
queryFn: async () => {
|
|
3657
|
-
const data = await getTableData({
|
|
3658
|
-
serverUrl,
|
|
3659
|
-
in_table: in_table,
|
|
3660
|
-
limit: 1,
|
|
3661
|
-
where: [{ id: column_ref, value: watchId }],
|
|
3662
|
-
});
|
|
3663
|
-
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
3664
|
-
return [
|
|
3665
|
-
item[column_ref],
|
|
3666
|
-
{
|
|
3667
|
-
...item,
|
|
3668
|
-
},
|
|
3669
|
-
];
|
|
3670
|
-
}));
|
|
3671
|
-
setIdMap((state) => {
|
|
3672
|
-
return { ...state, ...newMap };
|
|
3673
|
-
});
|
|
3674
|
-
return data;
|
|
3675
|
-
},
|
|
3676
|
-
enabled: (selectedIds ?? []).length > 0,
|
|
3677
|
-
staleTime: 300000,
|
|
3678
|
-
});
|
|
3679
3653
|
const { isLoading, isFetching, data, isPending, isError } = query;
|
|
3680
|
-
const dataList =
|
|
3654
|
+
const dataList = data?.data ?? [];
|
|
3681
3655
|
const count = data?.count ?? 0;
|
|
3682
3656
|
const isDirty = (searchText?.length ?? 0) > 0;
|
|
3683
3657
|
const onSearchChange = async (event) => {
|
|
@@ -3753,32 +3727,16 @@ const DataListItem = React__namespace.forwardRef(function DataListItem(props, re
|
|
|
3753
3727
|
return (jsxRuntime.jsxs(react.DataList.Item, { ref: ref, ...rest, children: [jsxRuntime.jsxs(react.DataList.ItemLabel, { flex: grow ? "1" : undefined, children: [label, info && jsxRuntime.jsx(InfoTip, { children: info })] }), jsxRuntime.jsx(react.DataList.ItemValue, { flex: grow ? "1" : undefined, children: value }), children] }));
|
|
3754
3728
|
});
|
|
3755
3729
|
|
|
3756
|
-
const IdViewer = ({ value, column }) => {
|
|
3757
|
-
const { schema,
|
|
3730
|
+
const IdViewer = ({ value, column, dataListItemProps, }) => {
|
|
3731
|
+
const { schema, idMap } = useSchemaContext();
|
|
3758
3732
|
if (schema.properties == undefined) {
|
|
3759
3733
|
throw new Error("schema properties when using DatePicker");
|
|
3760
3734
|
}
|
|
3761
3735
|
const { title, foreign_key } = schema.properties[column];
|
|
3762
3736
|
if (foreign_key === undefined) {
|
|
3763
|
-
throw new Error(
|
|
3737
|
+
throw new Error("foreign_key when variant is id-picker");
|
|
3764
3738
|
}
|
|
3765
|
-
const {
|
|
3766
|
-
const query = reactQuery.useQuery({
|
|
3767
|
-
queryKey: [`idpicker`, table, value],
|
|
3768
|
-
queryFn: async () => {
|
|
3769
|
-
return await getTableData({
|
|
3770
|
-
serverUrl,
|
|
3771
|
-
in_table: foreginKeyColumn ?? '',
|
|
3772
|
-
where: [
|
|
3773
|
-
{
|
|
3774
|
-
id: column,
|
|
3775
|
-
value: value,
|
|
3776
|
-
},
|
|
3777
|
-
],
|
|
3778
|
-
});
|
|
3779
|
-
},
|
|
3780
|
-
staleTime: 10000,
|
|
3781
|
-
});
|
|
3739
|
+
const { display_column } = foreign_key;
|
|
3782
3740
|
const getDataListProps = (value) => {
|
|
3783
3741
|
if (value == undefined || value.length <= 0) {
|
|
3784
3742
|
return {
|
|
@@ -3790,7 +3748,10 @@ const IdViewer = ({ value, column }) => {
|
|
|
3790
3748
|
value: value,
|
|
3791
3749
|
};
|
|
3792
3750
|
};
|
|
3793
|
-
|
|
3751
|
+
if (value === undefined) {
|
|
3752
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
3753
|
+
}
|
|
3754
|
+
return (jsxRuntime.jsx(DataListItem, { label: `${title ?? snakeToLabel(column)}`, ...getDataListProps(idMap[value][display_column]), ...dataListItemProps }));
|
|
3794
3755
|
};
|
|
3795
3756
|
|
|
3796
3757
|
const NumberInputRoot = React__namespace.forwardRef(function NumberInput(props, ref) {
|
|
@@ -3948,156 +3909,71 @@ const DatePicker = ({ column }) => {
|
|
|
3948
3909
|
} })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
3949
3910
|
};
|
|
3950
3911
|
|
|
3951
|
-
|
|
3952
|
-
|
|
3912
|
+
function filterArray(array, searchTerm) {
|
|
3913
|
+
// Convert the search term to lower case for case-insensitive comparison
|
|
3914
|
+
const lowerCaseSearchTerm = searchTerm.toLowerCase();
|
|
3915
|
+
// Use the filter method to return an array of matching items
|
|
3916
|
+
return array.filter((item) => {
|
|
3917
|
+
// Convert each item to a string and check if it includes the search term
|
|
3918
|
+
return item.toString().toLowerCase().includes(lowerCaseSearchTerm);
|
|
3919
|
+
});
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
const EnumPicker = ({ column, isMultiple = false }) => {
|
|
3923
|
+
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
3953
3924
|
const { schema, displayText } = useSchemaContext();
|
|
3954
|
-
const {
|
|
3925
|
+
const { fieldRequired, total, showing, typeToSearch } = displayText;
|
|
3955
3926
|
const { required } = schema;
|
|
3956
3927
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3957
|
-
const entries = Object.entries(getValues(column) ?? {});
|
|
3958
|
-
const [showNewEntries, setShowNewEntries] = React.useState(false);
|
|
3959
|
-
const [newKey, setNewKey] = React.useState();
|
|
3960
|
-
const [newValue, setNewValue] = React.useState();
|
|
3961
3928
|
if (schema.properties == undefined) {
|
|
3962
3929
|
throw new Error("schema properties when using DatePicker");
|
|
3963
3930
|
}
|
|
3964
|
-
const { gridColumn, gridRow, title } = schema.properties[column];
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
const hasContent = label || description || icon;
|
|
4011
|
-
const ContentWrapper = indicator ? react.RadioCard.ItemContent : React__namespace.Fragment;
|
|
4012
|
-
return (jsxRuntime.jsxs(react.RadioCard.Item, { ...rest, children: [jsxRuntime.jsx(react.RadioCard.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsxs(react.RadioCard.ItemControl, { children: [indicatorPlacement === "start" && indicator, hasContent && (jsxRuntime.jsxs(ContentWrapper, { children: [icon, label && jsxRuntime.jsx(react.RadioCard.ItemText, { children: label }), description && (jsxRuntime.jsx(react.RadioCard.ItemDescription, { children: description })), indicatorPlacement === "inside" && indicator] })), indicatorPlacement === "end" && indicator] }), addon && jsxRuntime.jsx(react.RadioCard.ItemAddon, { children: addon })] }));
|
|
4013
|
-
});
|
|
4014
|
-
const RadioCardRoot = react.RadioCard.Root;
|
|
4015
|
-
react.RadioCard.Label;
|
|
4016
|
-
react.RadioCard.ItemIndicator;
|
|
4017
|
-
|
|
4018
|
-
const TagPicker = ({ column }) => {
|
|
4019
|
-
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
4020
|
-
const { schema, serverUrl } = useSchemaContext();
|
|
4021
|
-
if (schema.properties == undefined) {
|
|
4022
|
-
throw new Error("schema properties undefined when using DatePicker");
|
|
4023
|
-
}
|
|
4024
|
-
const { gridColumn, gridRow, in_table, object_id_column } = schema.properties[column];
|
|
4025
|
-
if (in_table === undefined) {
|
|
4026
|
-
throw new Error("in_table is undefined when using TagPicker");
|
|
4027
|
-
}
|
|
4028
|
-
if (object_id_column === undefined) {
|
|
4029
|
-
throw new Error("object_id_column is undefined when using TagPicker");
|
|
4030
|
-
}
|
|
4031
|
-
const query = reactQuery.useQuery({
|
|
4032
|
-
queryKey: [`tagpicker`, in_table],
|
|
4033
|
-
queryFn: async () => {
|
|
4034
|
-
return await getTableData({
|
|
4035
|
-
serverUrl,
|
|
4036
|
-
in_table: "tables_tags_view",
|
|
4037
|
-
where: [
|
|
4038
|
-
{
|
|
4039
|
-
id: "table_name",
|
|
4040
|
-
value: [in_table],
|
|
4041
|
-
},
|
|
4042
|
-
],
|
|
4043
|
-
limit: 100,
|
|
4044
|
-
});
|
|
4045
|
-
},
|
|
4046
|
-
staleTime: 10000,
|
|
4047
|
-
});
|
|
4048
|
-
const object_id = watch(object_id_column);
|
|
4049
|
-
const existingTagsQuery = reactQuery.useQuery({
|
|
4050
|
-
queryKey: [`existing`, in_table, object_id_column, object_id],
|
|
4051
|
-
queryFn: async () => {
|
|
4052
|
-
return await getTableData({
|
|
4053
|
-
serverUrl,
|
|
4054
|
-
in_table: in_table,
|
|
4055
|
-
where: [
|
|
4056
|
-
{
|
|
4057
|
-
id: object_id_column,
|
|
4058
|
-
value: object_id[0],
|
|
4059
|
-
},
|
|
4060
|
-
],
|
|
4061
|
-
limit: 100,
|
|
4062
|
-
});
|
|
4063
|
-
},
|
|
4064
|
-
enabled: object_id != undefined,
|
|
4065
|
-
staleTime: 10000,
|
|
4066
|
-
});
|
|
4067
|
-
const { isLoading, isFetching, data, isPending, isError } = query;
|
|
4068
|
-
const dataList = data?.data ?? [];
|
|
4069
|
-
const existingTagList = existingTagsQuery.data?.data ?? [];
|
|
4070
|
-
if (!!object_id === false) {
|
|
4071
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
4072
|
-
}
|
|
4073
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 4, gridColumn,
|
|
4074
|
-
gridRow, children: [isFetching && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isFetching" }), isLoading && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isLoading" }), isPending && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isPending" }), isError && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isError" }), dataList.map(({ parent_tag_name, all_tags, is_mutually_exclusive }) => {
|
|
4075
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsx(react.Text, { children: parent_tag_name }), is_mutually_exclusive && (jsxRuntime.jsx(RadioCardRoot, { defaultValue: "next", variant: "surface", onValueChange: (tagIds) => {
|
|
4076
|
-
const existedTags = Object.values(all_tags)
|
|
4077
|
-
.filter(({ id }) => {
|
|
4078
|
-
return existingTagList.some(({ tag_id }) => tag_id === id);
|
|
4079
|
-
})
|
|
4080
|
-
.map(({ id }) => {
|
|
4081
|
-
return id;
|
|
4082
|
-
});
|
|
4083
|
-
setValue(`${column}.${parent_tag_name}.current`, [
|
|
4084
|
-
tagIds.value,
|
|
4085
|
-
]);
|
|
4086
|
-
setValue(`${column}.${parent_tag_name}.old`, existedTags);
|
|
4087
|
-
}, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
|
|
4088
|
-
if (existingTagList.some(({ tag_id }) => tag_id === id)) {
|
|
4089
|
-
return (jsxRuntime.jsx(RadioCardItem, { label: tagName, value: id, flex: "0 0 0%", disabled: true }, `${tagName}-${id}`));
|
|
4090
|
-
}
|
|
4091
|
-
return (jsxRuntime.jsx(RadioCardItem, { label: tagName, value: id, flex: "0 0 0%", colorPalette: "blue" }, `${tagName}-${id}`));
|
|
4092
|
-
}) }) })), !is_mutually_exclusive && (jsxRuntime.jsx(react.CheckboxGroup, { onValueChange: (tagIds) => {
|
|
4093
|
-
setValue(`${column}.${parent_tag_name}.current`, tagIds);
|
|
4094
|
-
}, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
|
|
4095
|
-
if (existingTagList.some(({ tag_id }) => tag_id === id)) {
|
|
4096
|
-
return (jsxRuntime.jsx(CheckboxCard, { label: tagName, value: id, flex: "0 0 0%", disabled: true, colorPalette: "blue" }, `${tagName}-${id}`));
|
|
4097
|
-
}
|
|
4098
|
-
return (jsxRuntime.jsx(CheckboxCard, { label: tagName, value: id, flex: "0 0 0%" }, `${tagName}-${id}`));
|
|
4099
|
-
}) }) }))] }, `tag-${parent_tag_name}`));
|
|
4100
|
-
}), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
3931
|
+
const { gridColumn, gridRow, title, renderDisplay } = schema.properties[column];
|
|
3932
|
+
const [searchText, setSearchText] = React.useState();
|
|
3933
|
+
const [limit, setLimit] = React.useState(10);
|
|
3934
|
+
const [openSearchResult, setOpenSearchResult] = React.useState();
|
|
3935
|
+
const ref = React.useRef(null);
|
|
3936
|
+
const watchEnum = watch(column);
|
|
3937
|
+
const watchEnums = (watch(column) ?? []);
|
|
3938
|
+
const properties = (schema.properties[column] ?? {});
|
|
3939
|
+
const dataList = properties.enum ?? [];
|
|
3940
|
+
const count = properties.enum?.length ?? 0;
|
|
3941
|
+
const isDirty = (searchText?.length ?? 0) > 0;
|
|
3942
|
+
const onSearchChange = async (event) => {
|
|
3943
|
+
setSearchText(event.target.value);
|
|
3944
|
+
setLimit(10);
|
|
3945
|
+
};
|
|
3946
|
+
return (jsxRuntime.jsxs(Field, { label: `${title ?? snakeToLabel(column)}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3947
|
+
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3948
|
+
const item = enumValue;
|
|
3949
|
+
if (item === undefined) {
|
|
3950
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
3951
|
+
}
|
|
3952
|
+
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
3953
|
+
setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3954
|
+
setValue(column, watchEnums.filter((id) => id != item));
|
|
3955
|
+
}, children: !!renderDisplay === true ? renderDisplay(item) : item }));
|
|
3956
|
+
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3957
|
+
setOpenSearchResult(true);
|
|
3958
|
+
}, children: "Add" })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
3959
|
+
setOpenSearchResult(true);
|
|
3960
|
+
}, children: watchEnum })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsxRuntime.jsx(react.Input, { placeholder: typeToSearch ?? "Type to search", onChange: (event) => {
|
|
3961
|
+
onSearchChange(event);
|
|
3962
|
+
setOpenSearchResult(true);
|
|
3963
|
+
}, autoComplete: "off", ref: ref }), jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(react.Text, { children: `${total ?? "Total"}: ${count}, ${showing ?? "Showing"} ${limit}` }), jsxRuntime.jsxs(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children: filterArray(dataList, searchText ?? "").map((item) => {
|
|
3964
|
+
const selected = isMultiple
|
|
3965
|
+
? watchEnums.some((enumValue) => item === enumValue)
|
|
3966
|
+
: watchEnum == item;
|
|
3967
|
+
return (jsxRuntime.jsx(react.Box, { cursor: "pointer", onClick: () => {
|
|
3968
|
+
if (!isMultiple) {
|
|
3969
|
+
setOpenSearchResult(false);
|
|
3970
|
+
setValue(column, item);
|
|
3971
|
+
return;
|
|
3972
|
+
}
|
|
3973
|
+
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3974
|
+
setValue(column, [...newSet]);
|
|
3975
|
+
}, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true ? renderDisplay(item) : item }, `${column}-${item}`));
|
|
3976
|
+
}) }), isDirty && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [dataList.length <= 0 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "Empty Search Result" }), " "] }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
4101
3977
|
};
|
|
4102
3978
|
|
|
4103
3979
|
function isEnteringWindow(_ref) {
|
|
@@ -4475,71 +4351,156 @@ const FilePicker = ({ column }) => {
|
|
|
4475
4351
|
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
4476
4352
|
};
|
|
4477
4353
|
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
const lowerCaseSearchTerm = searchTerm.toLowerCase();
|
|
4481
|
-
// Use the filter method to return an array of matching items
|
|
4482
|
-
return array.filter((item) => {
|
|
4483
|
-
// Convert each item to a string and check if it includes the search term
|
|
4484
|
-
return item.toString().toLowerCase().includes(lowerCaseSearchTerm);
|
|
4485
|
-
});
|
|
4486
|
-
}
|
|
4487
|
-
|
|
4488
|
-
const EnumPicker = ({ column, isMultiple = false }) => {
|
|
4489
|
-
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
4354
|
+
const ObjectInput = ({ column }) => {
|
|
4355
|
+
const { formState: { errors }, setValue, getValues, } = reactHookForm.useFormContext();
|
|
4490
4356
|
const { schema, displayText } = useSchemaContext();
|
|
4491
|
-
const {
|
|
4357
|
+
const { addNew, fieldRequired, save } = displayText;
|
|
4492
4358
|
const { required } = schema;
|
|
4493
4359
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4360
|
+
const entries = Object.entries(getValues(column) ?? {});
|
|
4361
|
+
const [showNewEntries, setShowNewEntries] = React.useState(false);
|
|
4362
|
+
const [newKey, setNewKey] = React.useState();
|
|
4363
|
+
const [newValue, setNewValue] = React.useState();
|
|
4494
4364
|
if (schema.properties == undefined) {
|
|
4495
4365
|
throw new Error("schema properties when using DatePicker");
|
|
4496
4366
|
}
|
|
4497
|
-
const { gridColumn, gridRow, title
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4367
|
+
const { gridColumn, gridRow, title } = schema.properties[column];
|
|
4368
|
+
return (jsxRuntime.jsxs(Field, { label: `${title ?? snakeToLabel(column)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4369
|
+
return (jsxRuntime.jsxs(react.Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsxRuntime.jsx(react.Input, { value: key, onChange: (e) => {
|
|
4370
|
+
const filtered = entries.filter(([target]) => {
|
|
4371
|
+
return target !== key;
|
|
4372
|
+
});
|
|
4373
|
+
setValue(column, Object.fromEntries([...filtered, [e.target.value, value]]));
|
|
4374
|
+
}, autoComplete: "off" }), jsxRuntime.jsx(react.Input, { value: value, onChange: (e) => {
|
|
4375
|
+
setValue(column, {
|
|
4376
|
+
...getValues(column),
|
|
4377
|
+
[key]: e.target.value,
|
|
4378
|
+
});
|
|
4379
|
+
}, autoComplete: "off" }), jsxRuntime.jsx(react.IconButton, { variant: "ghost", onClick: () => {
|
|
4380
|
+
const filtered = entries.filter(([target]) => {
|
|
4381
|
+
return target !== key;
|
|
4382
|
+
});
|
|
4383
|
+
setValue(column, Object.fromEntries([...filtered]));
|
|
4384
|
+
}, children: jsxRuntime.jsx(cg.CgClose, {}) })] }));
|
|
4385
|
+
}), jsxRuntime.jsx(react.Show, { when: showNewEntries, children: jsxRuntime.jsxs(react.Card.Root, { children: [jsxRuntime.jsx(react.Card.Body, { gap: "2", children: jsxRuntime.jsxs(react.Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsxRuntime.jsx(react.Input, { value: newKey, onChange: (e) => {
|
|
4386
|
+
setNewKey(e.target.value);
|
|
4387
|
+
}, autoComplete: "off" }), jsxRuntime.jsx(react.Input, { value: newValue, onChange: (e) => {
|
|
4388
|
+
setNewValue(e.target.value);
|
|
4389
|
+
}, autoComplete: "off" })] }) }), jsxRuntime.jsxs(react.Card.Footer, { justifyContent: "flex-end", children: [jsxRuntime.jsx(react.IconButton, { variant: "subtle", onClick: () => {
|
|
4390
|
+
setShowNewEntries(false);
|
|
4391
|
+
setNewKey(undefined);
|
|
4392
|
+
setNewValue(undefined);
|
|
4393
|
+
}, children: jsxRuntime.jsx(cg.CgClose, {}) }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
4394
|
+
if (!!newKey === false) {
|
|
4395
|
+
setShowNewEntries(false);
|
|
4396
|
+
setNewKey(undefined);
|
|
4397
|
+
setNewValue(undefined);
|
|
4398
|
+
return;
|
|
4399
|
+
}
|
|
4400
|
+
setValue(column, Object.fromEntries([...entries, [newKey, newValue]]));
|
|
4401
|
+
setShowNewEntries(false);
|
|
4402
|
+
setNewKey(undefined);
|
|
4403
|
+
setNewValue(undefined);
|
|
4404
|
+
}, children: save ?? "Save" })] })] }) }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
4405
|
+
setShowNewEntries(true);
|
|
4406
|
+
setNewKey(undefined);
|
|
4407
|
+
setNewValue(undefined);
|
|
4408
|
+
}, children: addNew ?? "Add New" }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
4409
|
+
};
|
|
4410
|
+
|
|
4411
|
+
const RadioCardItem = React__namespace.forwardRef(function RadioCardItem(props, ref) {
|
|
4412
|
+
const { inputProps, label, description, addon, icon, indicator = jsxRuntime.jsx(react.RadioCard.ItemIndicator, {}), indicatorPlacement = "end", ...rest } = props;
|
|
4413
|
+
const hasContent = label || description || icon;
|
|
4414
|
+
const ContentWrapper = indicator ? react.RadioCard.ItemContent : React__namespace.Fragment;
|
|
4415
|
+
return (jsxRuntime.jsxs(react.RadioCard.Item, { ...rest, children: [jsxRuntime.jsx(react.RadioCard.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsxs(react.RadioCard.ItemControl, { children: [indicatorPlacement === "start" && indicator, hasContent && (jsxRuntime.jsxs(ContentWrapper, { children: [icon, label && jsxRuntime.jsx(react.RadioCard.ItemText, { children: label }), description && (jsxRuntime.jsx(react.RadioCard.ItemDescription, { children: description })), indicatorPlacement === "inside" && indicator] })), indicatorPlacement === "end" && indicator] }), addon && jsxRuntime.jsx(react.RadioCard.ItemAddon, { children: addon })] }));
|
|
4416
|
+
});
|
|
4417
|
+
const RadioCardRoot = react.RadioCard.Root;
|
|
4418
|
+
react.RadioCard.Label;
|
|
4419
|
+
react.RadioCard.ItemIndicator;
|
|
4420
|
+
|
|
4421
|
+
const TagPicker = ({ column }) => {
|
|
4422
|
+
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
4423
|
+
const { schema, serverUrl } = useSchemaContext();
|
|
4424
|
+
if (schema.properties == undefined) {
|
|
4425
|
+
throw new Error("schema properties undefined when using DatePicker");
|
|
4426
|
+
}
|
|
4427
|
+
const { gridColumn, gridRow, in_table, object_id_column } = schema.properties[column];
|
|
4428
|
+
if (in_table === undefined) {
|
|
4429
|
+
throw new Error("in_table is undefined when using TagPicker");
|
|
4430
|
+
}
|
|
4431
|
+
if (object_id_column === undefined) {
|
|
4432
|
+
throw new Error("object_id_column is undefined when using TagPicker");
|
|
4433
|
+
}
|
|
4434
|
+
const query = reactQuery.useQuery({
|
|
4435
|
+
queryKey: [`tagpicker`, in_table],
|
|
4436
|
+
queryFn: async () => {
|
|
4437
|
+
return await getTableData({
|
|
4438
|
+
serverUrl,
|
|
4439
|
+
in_table: "tables_tags_view",
|
|
4440
|
+
where: [
|
|
4441
|
+
{
|
|
4442
|
+
id: "table_name",
|
|
4443
|
+
value: [in_table],
|
|
4444
|
+
},
|
|
4445
|
+
],
|
|
4446
|
+
limit: 100,
|
|
4447
|
+
});
|
|
4448
|
+
},
|
|
4449
|
+
staleTime: 10000,
|
|
4450
|
+
});
|
|
4451
|
+
const object_id = watch(object_id_column);
|
|
4452
|
+
const existingTagsQuery = reactQuery.useQuery({
|
|
4453
|
+
queryKey: [`existing`, in_table, object_id_column, object_id],
|
|
4454
|
+
queryFn: async () => {
|
|
4455
|
+
return await getTableData({
|
|
4456
|
+
serverUrl,
|
|
4457
|
+
in_table: in_table,
|
|
4458
|
+
where: [
|
|
4459
|
+
{
|
|
4460
|
+
id: object_id_column,
|
|
4461
|
+
value: object_id[0],
|
|
4462
|
+
},
|
|
4463
|
+
],
|
|
4464
|
+
limit: 100,
|
|
4465
|
+
});
|
|
4466
|
+
},
|
|
4467
|
+
enabled: object_id != undefined,
|
|
4468
|
+
staleTime: 10000,
|
|
4469
|
+
});
|
|
4470
|
+
const { isLoading, isFetching, data, isPending, isError } = query;
|
|
4471
|
+
const dataList = data?.data ?? [];
|
|
4472
|
+
const existingTagList = existingTagsQuery.data?.data ?? [];
|
|
4473
|
+
if (!!object_id === false) {
|
|
4474
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
4475
|
+
}
|
|
4476
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 4, gridColumn,
|
|
4477
|
+
gridRow, children: [isFetching && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isFetching" }), isLoading && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isLoading" }), isPending && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isPending" }), isError && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isError" }), dataList.map(({ parent_tag_name, all_tags, is_mutually_exclusive }) => {
|
|
4478
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsx(react.Text, { children: parent_tag_name }), is_mutually_exclusive && (jsxRuntime.jsx(RadioCardRoot, { defaultValue: "next", variant: "surface", onValueChange: (tagIds) => {
|
|
4479
|
+
const existedTags = Object.values(all_tags)
|
|
4480
|
+
.filter(({ id }) => {
|
|
4481
|
+
return existingTagList.some(({ tag_id }) => tag_id === id);
|
|
4482
|
+
})
|
|
4483
|
+
.map(({ id }) => {
|
|
4484
|
+
return id;
|
|
4485
|
+
});
|
|
4486
|
+
setValue(`${column}.${parent_tag_name}.current`, [
|
|
4487
|
+
tagIds.value,
|
|
4488
|
+
]);
|
|
4489
|
+
setValue(`${column}.${parent_tag_name}.old`, existedTags);
|
|
4490
|
+
}, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
|
|
4491
|
+
if (existingTagList.some(({ tag_id }) => tag_id === id)) {
|
|
4492
|
+
return (jsxRuntime.jsx(RadioCardItem, { label: tagName, value: id, flex: "0 0 0%", disabled: true }, `${tagName}-${id}`));
|
|
4493
|
+
}
|
|
4494
|
+
return (jsxRuntime.jsx(RadioCardItem, { label: tagName, value: id, flex: "0 0 0%", colorPalette: "blue" }, `${tagName}-${id}`));
|
|
4495
|
+
}) }) })), !is_mutually_exclusive && (jsxRuntime.jsx(react.CheckboxGroup, { onValueChange: (tagIds) => {
|
|
4496
|
+
setValue(`${column}.${parent_tag_name}.current`, tagIds);
|
|
4497
|
+
}, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
|
|
4498
|
+
if (existingTagList.some(({ tag_id }) => tag_id === id)) {
|
|
4499
|
+
return (jsxRuntime.jsx(CheckboxCard, { label: tagName, value: id, flex: "0 0 0%", disabled: true, colorPalette: "blue" }, `${tagName}-${id}`));
|
|
4500
|
+
}
|
|
4501
|
+
return (jsxRuntime.jsx(CheckboxCard, { label: tagName, value: id, flex: "0 0 0%" }, `${tagName}-${id}`));
|
|
4502
|
+
}) }) }))] }, `tag-${parent_tag_name}`));
|
|
4503
|
+
}), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4543
4504
|
};
|
|
4544
4505
|
|
|
4545
4506
|
const idPickerSanityCheck = (column, foreign_key) => {
|
|
@@ -4558,7 +4519,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
|
|
|
4558
4519
|
}
|
|
4559
4520
|
};
|
|
4560
4521
|
const FormInternal = () => {
|
|
4561
|
-
const { schema, serverUrl, displayText, order, ignore, onSubmit, rowNumber } = useSchemaContext();
|
|
4522
|
+
const { schema, serverUrl, displayText, order, ignore, onSubmit, rowNumber, idMap, } = useSchemaContext();
|
|
4562
4523
|
const { title, submit, empty, cancel, submitSuccess, submitAgain, confirm } = displayText;
|
|
4563
4524
|
const methods = reactHookForm.useFormContext();
|
|
4564
4525
|
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
@@ -4665,8 +4626,7 @@ const FormInternal = () => {
|
|
|
4665
4626
|
if (variant === "id-picker") {
|
|
4666
4627
|
idPickerSanityCheck(column, foreign_key);
|
|
4667
4628
|
return (jsxRuntime.jsx(IdViewer, { value: (validatedData ?? {})[column], column,
|
|
4668
|
-
gridColumn,
|
|
4669
|
-
gridRow }, `form-${key}`));
|
|
4629
|
+
dataListItemProps: { gridColumn, gridRow } }, `form-${key}`));
|
|
4670
4630
|
}
|
|
4671
4631
|
if (variant === "date-picker") {
|
|
4672
4632
|
const value = (validatedData ?? {})[column];
|
|
@@ -4704,6 +4664,22 @@ const FormInternal = () => {
|
|
|
4704
4664
|
});
|
|
4705
4665
|
return (jsxRuntime.jsx(DataListItem, { gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 4", label: `${snakeToLabel(column)}`, ...getDataListProps(JSON.stringify(fileNames)) }, `form-${key}`));
|
|
4706
4666
|
}
|
|
4667
|
+
if (variant === "id-picker") {
|
|
4668
|
+
const value = (validatedData ?? {})[column];
|
|
4669
|
+
if (schema.properties == undefined) {
|
|
4670
|
+
throw new Error("schema properties when using DatePicker");
|
|
4671
|
+
}
|
|
4672
|
+
const { foreign_key } = schema.properties[column];
|
|
4673
|
+
if (foreign_key === undefined) {
|
|
4674
|
+
throw new Error("foreign_key when variant is id-picker");
|
|
4675
|
+
}
|
|
4676
|
+
const { display_column } = foreign_key;
|
|
4677
|
+
const mapped = value.map((item) => {
|
|
4678
|
+
return idMap[item][display_column];
|
|
4679
|
+
});
|
|
4680
|
+
return (jsxRuntime.jsxs(react.Grid, { flexFlow: "column", gridColumn,
|
|
4681
|
+
gridRow, children: [jsxRuntime.jsx(react.Text, { children: snakeToLabel(column) }), jsxRuntime.jsx(RecordDisplay, { object: mapped })] }, `form-${key}`));
|
|
4682
|
+
}
|
|
4707
4683
|
const objectString = JSON.stringify((validatedData ?? {})[column]);
|
|
4708
4684
|
return (jsxRuntime.jsx(DataListItem, { gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 4", label: `${snakeToLabel(column)}`, ...getDataListProps(objectString) }, `form-${key}`));
|
|
4709
4685
|
}
|
|
@@ -4730,8 +4706,9 @@ const FormInternal = () => {
|
|
|
4730
4706
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
4731
4707
|
}
|
|
4732
4708
|
//@ts-expect-error TODO: add more fields to support form-creation
|
|
4733
|
-
const { type, variant,
|
|
4709
|
+
const { type, variant, foreign_key } = values;
|
|
4734
4710
|
if (type === "string") {
|
|
4711
|
+
// @ts-expect-error enum should exists
|
|
4735
4712
|
if ((values.enum ?? []).length > 0) {
|
|
4736
4713
|
return jsxRuntime.jsx(EnumPicker, { column: key }, `form-${key}`);
|
|
4737
4714
|
}
|
|
@@ -4777,6 +4754,7 @@ const FormInternal = () => {
|
|
|
4777
4754
|
const Form = ({ schema, serverUrl, order = [], ignore = [], onSubmit = undefined, preLoadedValues = {}, rowNumber = undefined, displayText = {}, }) => {
|
|
4778
4755
|
const queryClient = new reactQuery.QueryClient();
|
|
4779
4756
|
const methods = reactHookForm.useForm({ values: preLoadedValues });
|
|
4757
|
+
const [idMap, setIdMap] = React.useState({});
|
|
4780
4758
|
const { properties } = schema;
|
|
4781
4759
|
idListSanityCheck("order", order, properties);
|
|
4782
4760
|
idListSanityCheck("ignore", ignore, properties);
|
|
@@ -4790,6 +4768,8 @@ const Form = ({ schema, serverUrl, order = [], ignore = [], onSubmit = undefined
|
|
|
4790
4768
|
// @ts-expect-error TODO: find appropriate types
|
|
4791
4769
|
onSubmit,
|
|
4792
4770
|
rowNumber,
|
|
4771
|
+
idMap,
|
|
4772
|
+
setIdMap,
|
|
4793
4773
|
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children: jsxRuntime.jsx(FormInternal, {}) }) }) }));
|
|
4794
4774
|
};
|
|
4795
4775
|
|
|
@@ -4816,17 +4796,18 @@ exports.DataTableServer = DataTableServer;
|
|
|
4816
4796
|
exports.DefaultCardTitle = DefaultCardTitle;
|
|
4817
4797
|
exports.DefaultTable = DefaultTable;
|
|
4818
4798
|
exports.DensityToggleButton = DensityToggleButton;
|
|
4819
|
-
exports.EditFilterButton = EditFilterButton;
|
|
4799
|
+
exports.EditFilterButton = EditFilterButton$1;
|
|
4820
4800
|
exports.EditOrderButton = EditOrderButton;
|
|
4821
4801
|
exports.EditSortingButton = EditSortingButton;
|
|
4822
|
-
exports.EditViewButton = EditViewButton;
|
|
4802
|
+
exports.EditViewButton = EditViewButton$1;
|
|
4823
4803
|
exports.EmptyState = EmptyState;
|
|
4824
4804
|
exports.ErrorAlert = ErrorAlert;
|
|
4825
|
-
exports.FilterOptions = FilterOptions;
|
|
4805
|
+
exports.FilterOptions = FilterOptions$1;
|
|
4826
4806
|
exports.Form = Form;
|
|
4827
|
-
exports.GlobalFilter = GlobalFilter;
|
|
4807
|
+
exports.GlobalFilter = GlobalFilter$1;
|
|
4828
4808
|
exports.PageSizeControl = PageSizeControl;
|
|
4829
|
-
exports.
|
|
4809
|
+
exports.RecordDisplay = RecordDisplay;
|
|
4810
|
+
exports.ReloadButton = ReloadButton$1;
|
|
4830
4811
|
exports.ResetFilteringButton = ResetFilteringButton;
|
|
4831
4812
|
exports.ResetSelectionButton = ResetSelectionButton;
|
|
4832
4813
|
exports.ResetSortingButton = ResetSortingButton;
|
|
@@ -4838,7 +4819,7 @@ exports.TableCards = TableCards;
|
|
|
4838
4819
|
exports.TableComponent = TableComponent;
|
|
4839
4820
|
exports.TableControls = TableControls;
|
|
4840
4821
|
exports.TableFilter = TableFilter;
|
|
4841
|
-
exports.TableFilterTags = TableFilterTags;
|
|
4822
|
+
exports.TableFilterTags = TableFilterTags$1;
|
|
4842
4823
|
exports.TableFooter = TableFooter;
|
|
4843
4824
|
exports.TableHeader = TableHeader;
|
|
4844
4825
|
exports.TableLoadingComponent = TableLoadingComponent;
|