@bsol-oss/react-datatable5 13.0.1-beta.36 → 13.0.1-beta.38
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 +4 -13
- package/dist/index.js +10 -89
- package/dist/index.mjs +11 -89
- package/dist/types/components/Form/SchemaFormContext.d.ts +0 -5
- package/dist/types/components/Form/components/core/DefaultForm.d.ts +3 -4
- package/dist/types/components/Form/components/core/FormRoot.d.ts +2 -8
- package/dist/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/types/components/Form/components/core/FormTitle.d.ts +0 -1
- package/dist/types/components/Form/components/core/SubmitButton.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { UseQueryResult } from '@tanstack/react-query';
|
|
|
9
9
|
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
10
10
|
import { JSONSchema7 } from 'json-schema';
|
|
11
11
|
import * as react_hook_form from 'react-hook-form';
|
|
12
|
-
import { UseFormReturn, FieldValues
|
|
12
|
+
import { UseFormReturn, FieldValues } from 'react-hook-form';
|
|
13
13
|
import dayjs from 'dayjs';
|
|
14
14
|
|
|
15
15
|
interface TableHeaderTexts {
|
|
@@ -700,12 +700,6 @@ interface FormRootProps<TData extends FieldValues> {
|
|
|
700
700
|
setIdMap: Dispatch<SetStateAction<Record<string, unknown>>>;
|
|
701
701
|
form: UseFormReturn<TData, any, TData>;
|
|
702
702
|
children: ReactNode;
|
|
703
|
-
onSubmit?: SubmitHandler<TData>;
|
|
704
|
-
displayConfig?: {
|
|
705
|
-
showSubmitButton?: boolean;
|
|
706
|
-
showResetButton?: boolean;
|
|
707
|
-
showTitle?: boolean;
|
|
708
|
-
};
|
|
709
703
|
dateTimePickerLabels?: DateTimePickerLabels;
|
|
710
704
|
idPickerLabels?: IdPickerLabels;
|
|
711
705
|
enumPickerLabels?: EnumPickerLabels;
|
|
@@ -721,16 +715,13 @@ interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
|
721
715
|
customQueryFn: any;
|
|
722
716
|
children: ReactNode;
|
|
723
717
|
}
|
|
724
|
-
declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, children,
|
|
718
|
+
declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, children, dateTimePickerLabels, idPickerLabels, enumPickerLabels, filePickerLabels, formButtonLabels, timePickerLabels, insideDialog, }: FormRootProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
725
719
|
|
|
726
720
|
interface DefaultFormProps<TData extends FieldValues> {
|
|
727
|
-
formConfig: Omit<FormRootProps<TData>,
|
|
728
|
-
showTitle?: boolean;
|
|
721
|
+
formConfig: Omit<FormRootProps<TData>, 'children'>;
|
|
729
722
|
}
|
|
730
723
|
declare const DefaultForm: <TData extends FieldValues>({ formConfig, }: DefaultFormProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
731
724
|
|
|
732
|
-
declare const FormTitle: () => react_jsx_runtime.JSX.Element;
|
|
733
|
-
|
|
734
725
|
declare const FormBody: () => react_jsx_runtime.JSX.Element;
|
|
735
726
|
|
|
736
727
|
type MediaLibraryBrowserPropsBase = {
|
|
@@ -1478,4 +1469,4 @@ declare module '@tanstack/react-table' {
|
|
|
1478
1469
|
}
|
|
1479
1470
|
}
|
|
1480
1471
|
|
|
1481
|
-
export { CalendarDisplay, type CalendarDisplayProps, type CalendarEvent, type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, type CustomQueryFn, type CustomQueryFnParams, type CustomQueryFnResponse, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, DatePickerContext, DatePickerInput, type DatePickerInputProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DefaultTableServer, type DefaultTableServerProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, type EnumPickerLabels, ErrorAlert, type ErrorAlertProps, type FilePickerLabels, type FilePickerMediaFile, type FilePickerProps, FilterDialog, FormBody, type FormButtonLabels, FormRoot, type FormRootProps,
|
|
1472
|
+
export { CalendarDisplay, type CalendarDisplayProps, type CalendarEvent, type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, type CustomQueryFn, type CustomQueryFnParams, type CustomQueryFnResponse, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, DatePickerContext, DatePickerInput, type DatePickerInputProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DefaultTableServer, type DefaultTableServerProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, type EnumPickerLabels, ErrorAlert, type ErrorAlertProps, type FilePickerLabels, type FilePickerMediaFile, type FilePickerProps, FilterDialog, FormBody, type FormButtonLabels, FormRoot, type FormRootProps, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, type IdPickerLabels, type LoadInitialValuesParams, type LoadInitialValuesResult, MediaLibraryBrowser, type MediaLibraryBrowserProps, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerLabels, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, SelectAllRowsToggle, type SelectAllRowsToggleProps, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, type TableFilterTagsProps, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, type TableHeaderTexts, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type TimePickerLabels, TimeRangeZoom, type TimeRangeZoomLabels, type TimeRangeZoomProps, TimeViewportBlock, type TimeViewportBlockItem, type TimeViewportBlockProps, type TimeViewportBlockRenderArgs, TimeViewportBlocks, type TimeViewportBlocksProps, TimeViewportGrid, type TimeViewportGridProps, TimeViewportHeader, type TimeViewportHeaderProps, type TimeViewportHeaderTick, TimeViewportMarkerLine, type TimeViewportMarkerLineProps, TimeViewportRoot, type TimeViewportRootProps, type TimeViewportTrackRenderArgs, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type UseTimeRangeZoomResult, type UseTimeViewportBlockGeometryResult, type UseTimeViewportDerivedResult, type UseTimeViewportTicksResult, type ValidationErrorType, ViewDialog, type ViewableTimeRange, defaultRenderDisplay, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm, useTimeRangeZoom, useTimeViewport, useTimeViewportBlockGeometry, useTimeViewportHeader, useTimeViewportTicks };
|
package/dist/index.js
CHANGED
|
@@ -4190,11 +4190,6 @@ const SchemaFormContext = React.createContext({
|
|
|
4190
4190
|
schema: {},
|
|
4191
4191
|
onSubmit: async () => { },
|
|
4192
4192
|
timezone: 'Asia/Hong_Kong',
|
|
4193
|
-
displayConfig: {
|
|
4194
|
-
showSubmitButton: false,
|
|
4195
|
-
showResetButton: false,
|
|
4196
|
-
showTitle: true,
|
|
4197
|
-
},
|
|
4198
4193
|
});
|
|
4199
4194
|
|
|
4200
4195
|
const useSchemaContext = () => {
|
|
@@ -7087,34 +7082,6 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7087
7082
|
}
|
|
7088
7083
|
};
|
|
7089
7084
|
// Display text for buttons
|
|
7090
|
-
React.useMemo(() => {
|
|
7091
|
-
if (!selectedDate)
|
|
7092
|
-
return labels?.selectDateLabel ?? 'Select date';
|
|
7093
|
-
return dayjs(selectedDate).tz(tz).format('YYYY-MM-DD');
|
|
7094
|
-
}, [selectedDate, tz, labels]);
|
|
7095
|
-
React.useMemo(() => {
|
|
7096
|
-
const selectTimeLabel = timePickerLabels?.selectTimeLabel ?? 'Select time';
|
|
7097
|
-
if (hour === null || minute === null)
|
|
7098
|
-
return selectTimeLabel;
|
|
7099
|
-
if (is24Hour) {
|
|
7100
|
-
// 24-hour format: never show meridiem, always use 24-hour format (0-23)
|
|
7101
|
-
const hour24 = hour >= 0 && hour <= 23 ? hour : hour % 24;
|
|
7102
|
-
const s = second ?? 0;
|
|
7103
|
-
if (showSeconds) {
|
|
7104
|
-
return `${hour24.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
|
|
7105
|
-
}
|
|
7106
|
-
return `${hour24.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
7107
|
-
}
|
|
7108
|
-
else {
|
|
7109
|
-
// 12-hour format: always show meridiem (AM/PM)
|
|
7110
|
-
const hour12 = hour >= 1 && hour <= 12 ? hour : hour % 12;
|
|
7111
|
-
if (meridiem === null)
|
|
7112
|
-
return selectTimeLabel;
|
|
7113
|
-
const hourDisplay = hour12.toString();
|
|
7114
|
-
const minuteDisplay = minute.toString().padStart(2, '0');
|
|
7115
|
-
return `${hourDisplay}:${minuteDisplay} ${meridiem.toUpperCase()}`;
|
|
7116
|
-
}
|
|
7117
|
-
}, [hour, minute, second, meridiem, is24Hour, showSeconds, timePickerLabels]);
|
|
7118
7085
|
const timezoneDisplayText = React.useMemo(() => {
|
|
7119
7086
|
if (!showTimezoneSelector)
|
|
7120
7087
|
return '';
|
|
@@ -7876,68 +7843,24 @@ const ColumnRenderer = ({ column, properties, prefix, parentRequired, }) => {
|
|
|
7876
7843
|
return jsxRuntime.jsx(SchemaRenderer, { schema: schemaWithRequired, prefix, column });
|
|
7877
7844
|
};
|
|
7878
7845
|
|
|
7879
|
-
const SubmitButton = () => {
|
|
7880
|
-
const { onSubmit, formButtonLabels } = useSchemaContext();
|
|
7881
|
-
const methods = reactHookForm.useFormContext();
|
|
7882
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7883
|
-
const onValid = async (data) => {
|
|
7884
|
-
// Validation is handled by react-hook-form
|
|
7885
|
-
// This function will only be called if validation passes
|
|
7886
|
-
if (onSubmit) {
|
|
7887
|
-
await onSubmit(data);
|
|
7888
|
-
}
|
|
7889
|
-
};
|
|
7890
|
-
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
7891
|
-
methods.handleSubmit(onValid)();
|
|
7892
|
-
}, formNoValidate: true, children: formButtonLabels?.submit ?? 'Submit' }));
|
|
7893
|
-
};
|
|
7894
|
-
|
|
7895
7846
|
const FormBody = () => {
|
|
7896
|
-
const { schema
|
|
7897
|
-
const { showSubmitButton, showResetButton } = displayConfig;
|
|
7898
|
-
const methods = reactHookForm.useFormContext();
|
|
7899
|
-
console.log('errors', methods.formState.errors);
|
|
7847
|
+
const { schema } = useSchemaContext();
|
|
7900
7848
|
const { properties } = schema;
|
|
7901
7849
|
const ordered = Object.keys(properties);
|
|
7902
|
-
return (jsxRuntime.
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
methods.reset();
|
|
7910
|
-
}, variant: 'subtle', children: formButtonLabels?.reset ?? 'Reset' })), showSubmitButton && jsxRuntime.jsx(SubmitButton, {})] }))] }));
|
|
7911
|
-
};
|
|
7912
|
-
|
|
7913
|
-
const FormTitle = () => {
|
|
7914
|
-
const { schema } = useSchemaContext();
|
|
7915
|
-
// Debug log when form title is missing
|
|
7916
|
-
if (!schema.title) {
|
|
7917
|
-
console.debug('[Form Title] Missing title in root schema. Add title property to schema.', {
|
|
7918
|
-
schema: {
|
|
7919
|
-
type: schema.type,
|
|
7920
|
-
properties: schema.properties
|
|
7921
|
-
? Object.keys(schema.properties)
|
|
7922
|
-
: undefined,
|
|
7923
|
-
},
|
|
7924
|
-
});
|
|
7925
|
-
}
|
|
7926
|
-
return jsxRuntime.jsx(react.Heading, { children: schema.title ?? 'Form' });
|
|
7850
|
+
return (jsxRuntime.jsx(react.Flex, { flexFlow: 'column', gap: "2", children: jsxRuntime.jsx(react.Grid, { gap: "4", gridTemplateColumns: 'repeat(12, 1fr)', autoFlow: 'row', children: ordered.map((column) => {
|
|
7851
|
+
if (!properties) {
|
|
7852
|
+
console.error('properties is undefined when using FormBody', schema);
|
|
7853
|
+
return null;
|
|
7854
|
+
}
|
|
7855
|
+
return (jsxRuntime.jsx(ColumnRenderer, { properties: properties, prefix: ``, parentRequired: schema.required, column }, `form-input-${column}`));
|
|
7856
|
+
}) }) }));
|
|
7927
7857
|
};
|
|
7928
7858
|
|
|
7929
|
-
const FormRoot = ({ schema, idMap, setIdMap, form, children,
|
|
7930
|
-
showSubmitButton: true,
|
|
7931
|
-
showResetButton: true,
|
|
7932
|
-
showTitle: true,
|
|
7933
|
-
}, dateTimePickerLabels, idPickerLabels, enumPickerLabels, filePickerLabels, formButtonLabels, timePickerLabels, insideDialog = false, }) => {
|
|
7859
|
+
const FormRoot = ({ schema, idMap, setIdMap, form, children, dateTimePickerLabels, idPickerLabels, enumPickerLabels, filePickerLabels, formButtonLabels, timePickerLabels, insideDialog = false, }) => {
|
|
7934
7860
|
return (jsxRuntime.jsx(SchemaFormContext.Provider, { value: {
|
|
7935
7861
|
schema,
|
|
7936
|
-
// @ts-expect-error TODO: find appropriate types
|
|
7937
|
-
onSubmit,
|
|
7938
7862
|
idMap,
|
|
7939
7863
|
setIdMap,
|
|
7940
|
-
displayConfig,
|
|
7941
7864
|
dateTimePickerLabels,
|
|
7942
7865
|
idPickerLabels,
|
|
7943
7866
|
enumPickerLabels,
|
|
@@ -7949,8 +7872,7 @@ const FormRoot = ({ schema, idMap, setIdMap, form, children, onSubmit = undefine
|
|
|
7949
7872
|
};
|
|
7950
7873
|
|
|
7951
7874
|
const DefaultForm = ({ formConfig, }) => {
|
|
7952
|
-
|
|
7953
|
-
return (jsxRuntime.jsx(FormRoot, { ...formConfig, children: jsxRuntime.jsxs(react.Grid, { gap: "2", children: [showTitle && jsxRuntime.jsx(FormTitle, {}), jsxRuntime.jsx(FormBody, {})] }) }));
|
|
7875
|
+
return (jsxRuntime.jsx(FormRoot, { ...formConfig, children: jsxRuntime.jsx(react.Grid, { gap: "2", children: jsxRuntime.jsx(FormBody, {}) }) }));
|
|
7954
7876
|
};
|
|
7955
7877
|
|
|
7956
7878
|
function useForm({ preLoadedValues, schema, }) {
|
|
@@ -9530,7 +9452,6 @@ exports.ErrorAlert = ErrorAlert;
|
|
|
9530
9452
|
exports.FilterDialog = FilterDialog;
|
|
9531
9453
|
exports.FormBody = FormBody;
|
|
9532
9454
|
exports.FormRoot = FormRoot;
|
|
9533
|
-
exports.FormTitle = FormTitle;
|
|
9534
9455
|
exports.GlobalFilter = GlobalFilter;
|
|
9535
9456
|
exports.MediaLibraryBrowser = MediaLibraryBrowser;
|
|
9536
9457
|
exports.PageSizeControl = PageSizeControl;
|
package/dist/index.mjs
CHANGED
|
@@ -4170,11 +4170,6 @@ const SchemaFormContext = createContext({
|
|
|
4170
4170
|
schema: {},
|
|
4171
4171
|
onSubmit: async () => { },
|
|
4172
4172
|
timezone: 'Asia/Hong_Kong',
|
|
4173
|
-
displayConfig: {
|
|
4174
|
-
showSubmitButton: false,
|
|
4175
|
-
showResetButton: false,
|
|
4176
|
-
showTitle: true,
|
|
4177
|
-
},
|
|
4178
4173
|
});
|
|
4179
4174
|
|
|
4180
4175
|
const useSchemaContext = () => {
|
|
@@ -7067,34 +7062,6 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7067
7062
|
}
|
|
7068
7063
|
};
|
|
7069
7064
|
// Display text for buttons
|
|
7070
|
-
useMemo(() => {
|
|
7071
|
-
if (!selectedDate)
|
|
7072
|
-
return labels?.selectDateLabel ?? 'Select date';
|
|
7073
|
-
return dayjs(selectedDate).tz(tz).format('YYYY-MM-DD');
|
|
7074
|
-
}, [selectedDate, tz, labels]);
|
|
7075
|
-
useMemo(() => {
|
|
7076
|
-
const selectTimeLabel = timePickerLabels?.selectTimeLabel ?? 'Select time';
|
|
7077
|
-
if (hour === null || minute === null)
|
|
7078
|
-
return selectTimeLabel;
|
|
7079
|
-
if (is24Hour) {
|
|
7080
|
-
// 24-hour format: never show meridiem, always use 24-hour format (0-23)
|
|
7081
|
-
const hour24 = hour >= 0 && hour <= 23 ? hour : hour % 24;
|
|
7082
|
-
const s = second ?? 0;
|
|
7083
|
-
if (showSeconds) {
|
|
7084
|
-
return `${hour24.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
|
|
7085
|
-
}
|
|
7086
|
-
return `${hour24.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
7087
|
-
}
|
|
7088
|
-
else {
|
|
7089
|
-
// 12-hour format: always show meridiem (AM/PM)
|
|
7090
|
-
const hour12 = hour >= 1 && hour <= 12 ? hour : hour % 12;
|
|
7091
|
-
if (meridiem === null)
|
|
7092
|
-
return selectTimeLabel;
|
|
7093
|
-
const hourDisplay = hour12.toString();
|
|
7094
|
-
const minuteDisplay = minute.toString().padStart(2, '0');
|
|
7095
|
-
return `${hourDisplay}:${minuteDisplay} ${meridiem.toUpperCase()}`;
|
|
7096
|
-
}
|
|
7097
|
-
}, [hour, minute, second, meridiem, is24Hour, showSeconds, timePickerLabels]);
|
|
7098
7065
|
const timezoneDisplayText = useMemo(() => {
|
|
7099
7066
|
if (!showTimezoneSelector)
|
|
7100
7067
|
return '';
|
|
@@ -7856,68 +7823,24 @@ const ColumnRenderer = ({ column, properties, prefix, parentRequired, }) => {
|
|
|
7856
7823
|
return jsx(SchemaRenderer, { schema: schemaWithRequired, prefix, column });
|
|
7857
7824
|
};
|
|
7858
7825
|
|
|
7859
|
-
const SubmitButton = () => {
|
|
7860
|
-
const { onSubmit, formButtonLabels } = useSchemaContext();
|
|
7861
|
-
const methods = useFormContext();
|
|
7862
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7863
|
-
const onValid = async (data) => {
|
|
7864
|
-
// Validation is handled by react-hook-form
|
|
7865
|
-
// This function will only be called if validation passes
|
|
7866
|
-
if (onSubmit) {
|
|
7867
|
-
await onSubmit(data);
|
|
7868
|
-
}
|
|
7869
|
-
};
|
|
7870
|
-
return (jsx(Button$1, { onClick: () => {
|
|
7871
|
-
methods.handleSubmit(onValid)();
|
|
7872
|
-
}, formNoValidate: true, children: formButtonLabels?.submit ?? 'Submit' }));
|
|
7873
|
-
};
|
|
7874
|
-
|
|
7875
7826
|
const FormBody = () => {
|
|
7876
|
-
const { schema
|
|
7877
|
-
const { showSubmitButton, showResetButton } = displayConfig;
|
|
7878
|
-
const methods = useFormContext();
|
|
7879
|
-
console.log('errors', methods.formState.errors);
|
|
7827
|
+
const { schema } = useSchemaContext();
|
|
7880
7828
|
const { properties } = schema;
|
|
7881
7829
|
const ordered = Object.keys(properties);
|
|
7882
|
-
return (
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
methods.reset();
|
|
7890
|
-
}, variant: 'subtle', children: formButtonLabels?.reset ?? 'Reset' })), showSubmitButton && jsx(SubmitButton, {})] }))] }));
|
|
7891
|
-
};
|
|
7892
|
-
|
|
7893
|
-
const FormTitle = () => {
|
|
7894
|
-
const { schema } = useSchemaContext();
|
|
7895
|
-
// Debug log when form title is missing
|
|
7896
|
-
if (!schema.title) {
|
|
7897
|
-
console.debug('[Form Title] Missing title in root schema. Add title property to schema.', {
|
|
7898
|
-
schema: {
|
|
7899
|
-
type: schema.type,
|
|
7900
|
-
properties: schema.properties
|
|
7901
|
-
? Object.keys(schema.properties)
|
|
7902
|
-
: undefined,
|
|
7903
|
-
},
|
|
7904
|
-
});
|
|
7905
|
-
}
|
|
7906
|
-
return jsx(Heading, { children: schema.title ?? 'Form' });
|
|
7830
|
+
return (jsx(Flex, { flexFlow: 'column', gap: "2", children: jsx(Grid, { gap: "4", gridTemplateColumns: 'repeat(12, 1fr)', autoFlow: 'row', children: ordered.map((column) => {
|
|
7831
|
+
if (!properties) {
|
|
7832
|
+
console.error('properties is undefined when using FormBody', schema);
|
|
7833
|
+
return null;
|
|
7834
|
+
}
|
|
7835
|
+
return (jsx(ColumnRenderer, { properties: properties, prefix: ``, parentRequired: schema.required, column }, `form-input-${column}`));
|
|
7836
|
+
}) }) }));
|
|
7907
7837
|
};
|
|
7908
7838
|
|
|
7909
|
-
const FormRoot = ({ schema, idMap, setIdMap, form, children,
|
|
7910
|
-
showSubmitButton: true,
|
|
7911
|
-
showResetButton: true,
|
|
7912
|
-
showTitle: true,
|
|
7913
|
-
}, dateTimePickerLabels, idPickerLabels, enumPickerLabels, filePickerLabels, formButtonLabels, timePickerLabels, insideDialog = false, }) => {
|
|
7839
|
+
const FormRoot = ({ schema, idMap, setIdMap, form, children, dateTimePickerLabels, idPickerLabels, enumPickerLabels, filePickerLabels, formButtonLabels, timePickerLabels, insideDialog = false, }) => {
|
|
7914
7840
|
return (jsx(SchemaFormContext.Provider, { value: {
|
|
7915
7841
|
schema,
|
|
7916
|
-
// @ts-expect-error TODO: find appropriate types
|
|
7917
|
-
onSubmit,
|
|
7918
7842
|
idMap,
|
|
7919
7843
|
setIdMap,
|
|
7920
|
-
displayConfig,
|
|
7921
7844
|
dateTimePickerLabels,
|
|
7922
7845
|
idPickerLabels,
|
|
7923
7846
|
enumPickerLabels,
|
|
@@ -7929,8 +7852,7 @@ const FormRoot = ({ schema, idMap, setIdMap, form, children, onSubmit = undefine
|
|
|
7929
7852
|
};
|
|
7930
7853
|
|
|
7931
7854
|
const DefaultForm = ({ formConfig, }) => {
|
|
7932
|
-
|
|
7933
|
-
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [showTitle && jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
7855
|
+
return (jsx(FormRoot, { ...formConfig, children: jsx(Grid, { gap: "2", children: jsx(FormBody, {}) }) }));
|
|
7934
7856
|
};
|
|
7935
7857
|
|
|
7936
7858
|
function useForm({ preLoadedValues, schema, }) {
|
|
@@ -9492,4 +9414,4 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
9492
9414
|
}, children: jsx(DataTableServerContext.Provider, { value: { url: url ?? '', query }, children: children }) }));
|
|
9493
9415
|
}
|
|
9494
9416
|
|
|
9495
|
-
export { CalendarDisplay, CardHeader, DataDisplay, DataTable, DataTableServer, DatePickerContext, DatePickerInput, DefaultCardTitle, DefaultForm, DefaultTable, DefaultTableServer, DensityToggleButton, EditSortingButton, EmptyState, ErrorAlert, FilterDialog, FormBody, FormRoot,
|
|
9417
|
+
export { CalendarDisplay, CardHeader, DataDisplay, DataTable, DataTableServer, DatePickerContext, DatePickerInput, DefaultCardTitle, DefaultForm, DefaultTable, DefaultTableServer, DensityToggleButton, EditSortingButton, EmptyState, ErrorAlert, FilterDialog, FormBody, FormRoot, GlobalFilter, MediaLibraryBrowser, PageSizeControl, Pagination, RecordDisplay, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, SelectAllRowsToggle, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableDataDisplay, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableSelector, TableSorter, TableViewer, TextCell, TimeRangeZoom, TimeViewportBlock, TimeViewportBlocks, TimeViewportGrid, TimeViewportHeader, TimeViewportMarkerLine, TimeViewportRoot, ViewDialog, defaultRenderDisplay, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm, useTimeRangeZoom, useTimeViewport, useTimeViewportBlockGeometry, useTimeViewportHeader, useTimeViewportTicks };
|
|
@@ -7,11 +7,6 @@ export interface SchemaFormContext<TData extends FieldValues> {
|
|
|
7
7
|
idMap: Record<string, unknown>;
|
|
8
8
|
setIdMap: Dispatch<SetStateAction<Record<string, unknown>>>;
|
|
9
9
|
timezone?: string;
|
|
10
|
-
displayConfig: {
|
|
11
|
-
showSubmitButton?: boolean;
|
|
12
|
-
showResetButton?: boolean;
|
|
13
|
-
showTitle?: boolean;
|
|
14
|
-
};
|
|
15
10
|
dateTimePickerLabels?: DateTimePickerLabels;
|
|
16
11
|
idPickerLabels?: IdPickerLabels;
|
|
17
12
|
enumPickerLabels?: EnumPickerLabels;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { FormRootProps } from
|
|
2
|
-
import { FieldValues } from
|
|
1
|
+
import { FormRootProps } from './FormRoot';
|
|
2
|
+
import { FieldValues } from 'react-hook-form';
|
|
3
3
|
export interface DefaultFormProps<TData extends FieldValues> {
|
|
4
|
-
formConfig: Omit<FormRootProps<TData>,
|
|
5
|
-
showTitle?: boolean;
|
|
4
|
+
formConfig: Omit<FormRootProps<TData>, 'children'>;
|
|
6
5
|
}
|
|
7
6
|
export declare const DefaultForm: <TData extends FieldValues>({ formConfig, }: DefaultFormProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
|
2
2
|
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
3
|
-
import { FieldValues,
|
|
3
|
+
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
4
4
|
import { CustomJSONSchema7, DateTimePickerLabels, EnumPickerLabels, FilePickerLabels, FormButtonLabels, IdPickerLabels, TimePickerLabels } from '../types/CustomJSONSchema7';
|
|
5
5
|
export interface FormRootProps<TData extends FieldValues> {
|
|
6
6
|
/**
|
|
@@ -33,12 +33,6 @@ export interface FormRootProps<TData extends FieldValues> {
|
|
|
33
33
|
setIdMap: Dispatch<SetStateAction<Record<string, unknown>>>;
|
|
34
34
|
form: UseFormReturn<TData, any, TData>;
|
|
35
35
|
children: ReactNode;
|
|
36
|
-
onSubmit?: SubmitHandler<TData>;
|
|
37
|
-
displayConfig?: {
|
|
38
|
-
showSubmitButton?: boolean;
|
|
39
|
-
showResetButton?: boolean;
|
|
40
|
-
showTitle?: boolean;
|
|
41
|
-
};
|
|
42
36
|
dateTimePickerLabels?: DateTimePickerLabels;
|
|
43
37
|
idPickerLabels?: IdPickerLabels;
|
|
44
38
|
enumPickerLabels?: EnumPickerLabels;
|
|
@@ -54,4 +48,4 @@ export interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
|
54
48
|
customQueryFn: any;
|
|
55
49
|
children: ReactNode;
|
|
56
50
|
}
|
|
57
|
-
export declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, children,
|
|
51
|
+
export declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, children, dateTimePickerLabels, idPickerLabels, enumPickerLabels, filePickerLabels, formButtonLabels, timePickerLabels, insideDialog, }: FormRootProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -125,7 +125,6 @@ export * from './components/DataTable/useDataTableServer';
|
|
|
125
125
|
export * from './components/DataTable/context/useDataTableContext';
|
|
126
126
|
export * from './components/Form/components/core/DefaultForm';
|
|
127
127
|
export * from './components/Form/components/core/FormRoot';
|
|
128
|
-
export * from './components/Form/components/core/FormTitle';
|
|
129
128
|
export * from './components/Form/components/core/FormBody';
|
|
130
129
|
export * from './components/Form/components/types/CustomJSONSchema7';
|
|
131
130
|
export * from './components/Form/components/MediaLibraryBrowser';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const FormTitle: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SubmitButton: () => import("react/jsx-runtime").JSX.Element;
|