@bsol-oss/react-datatable5 13.0.1-beta.28 → 13.0.1-beta.29

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 CHANGED
@@ -487,27 +487,6 @@ interface DataTableContextProps<TData = unknown> extends Omit<DataTableProps, 't
487
487
 
488
488
  declare const useDataTableContext: <TData>() => DataTableContextProps<TData>;
489
489
 
490
- interface CustomQueryFnResponse {
491
- /**
492
- * The data of the query
493
- */
494
- data: any;
495
- /**
496
- * The id map of the data
497
- */
498
- idMap: Record<string, any>;
499
- }
500
- interface CustomQueryFnParams {
501
- searching: string;
502
- limit: number;
503
- offset: number;
504
- where?: Array<{
505
- id: string;
506
- value: string | string[];
507
- }>;
508
- }
509
- type CustomQueryFn = (params: CustomQueryFnParams) => Promise<CustomQueryFnResponse>;
510
-
511
490
  type ValidationErrorType = 'minLength' | 'maxLength' | 'pattern' | 'minimum' | 'maximum' | 'multipleOf' | 'format' | 'type' | 'enum' | 'required' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minProperties' | 'maxProperties' | 'anyOf' | 'oneOf' | 'allOf' | 'const' | 'additionalProperties' | 'dependencies';
512
491
  interface DateTimePickerLabels {
513
492
  monthNamesShort?: string[];
@@ -574,23 +553,23 @@ interface TimePickerLabels {
574
553
  emptyMessage?: string;
575
554
  selectTimeLabel?: string;
576
555
  }
577
- interface LoadInitialValuesParams {
556
+ interface LoadInitialValuesParams<TRecord = unknown> {
578
557
  ids: string[];
579
- customQueryFn: CustomQueryFn;
580
- setIdMap: React__default.Dispatch<React__default.SetStateAction<Record<string, object>>>;
558
+ customQueryFn: CustomQueryFn<TRecord>;
559
+ setIdMap: React__default.Dispatch<React__default.SetStateAction<Record<string, TRecord>>>;
581
560
  }
582
- interface LoadInitialValuesResult {
561
+ interface LoadInitialValuesResult<TRecord = unknown> {
583
562
  data: {
584
- data: Record<string, any>[];
563
+ data: TRecord[];
585
564
  count: number;
586
565
  };
587
- idMap: Record<string, object>;
566
+ idMap: Record<string, TRecord>;
588
567
  }
589
568
  interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'additionalItems' | 'properties' | 'additionalProperties' | 'definitions' | 'patternProperties' | 'dependencies' | 'allOf' | 'anyOf' | 'oneOf' | 'not' | 'if' | 'then' | 'else' | 'contains'> {
590
569
  gridColumn?: string;
591
570
  gridRow?: string;
592
571
  customQueryFn?: CustomQueryFn;
593
- variant?: 'custom-input' | 'id-picker' | 'text-area' | 'media-library-browser' | 'tag-picker' | 'file-picker' | 'date-range' | 'enum-picker' | 'radio';
572
+ variant?: 'custom-input' | 'id-picker' | 'text-area' | 'media-library-browser' | 'file-picker' | 'date-range' | 'enum-picker' | 'radio';
594
573
  renderDisplay?: (item: unknown) => ReactNode;
595
574
  itemToValue?: (item: unknown) => string;
596
575
  loadInitialValues?: (params: LoadInitialValuesParams) => Promise<LoadInitialValuesResult>;
@@ -615,23 +594,6 @@ interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'additionalItems
615
594
  numberStorageType?: 'string' | 'number';
616
595
  errorMessage?: Record<Partial<ValidationErrorType> | string, string | Record<string, string>>;
617
596
  filePicker?: FilePickerProps;
618
- tagPicker?: {
619
- queryFn?: (params: {
620
- where?: {
621
- id: string;
622
- value: string[];
623
- }[];
624
- limit?: number;
625
- offset?: number;
626
- searching?: string;
627
- }) => Promise<{
628
- data: {
629
- data: any[];
630
- count: number;
631
- };
632
- idMap?: Record<string, object>;
633
- }>;
634
- };
635
597
  dateTimePicker?: {
636
598
  showQuickActions?: boolean;
637
599
  quickActionLabels?: {
@@ -667,11 +629,6 @@ interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'additionalItems
667
629
  contains?: CustomJSONSchema7;
668
630
  }
669
631
  declare const defaultRenderDisplay: (item: unknown) => ReactNode;
670
- interface TagPickerProps {
671
- column: string;
672
- schema: CustomJSONSchema7;
673
- prefix: string;
674
- }
675
632
  interface FilePickerMediaFile {
676
633
  id: string;
677
634
  name: string;
@@ -687,6 +644,29 @@ interface FilePickerProps {
687
644
  enableUpload?: boolean;
688
645
  onUploadFile?: (file: File) => Promise<string>;
689
646
  }
647
+ interface CustomQueryFnResponse<TRecord = unknown> {
648
+ /**
649
+ * The data of the query
650
+ */
651
+ data: {
652
+ data: TRecord[];
653
+ count: number;
654
+ };
655
+ /**
656
+ * The id map of the data
657
+ */
658
+ idMap: Record<string, TRecord>;
659
+ }
660
+ interface CustomQueryFnParams {
661
+ searching: string;
662
+ limit: number;
663
+ offset: number;
664
+ where?: Array<{
665
+ id: string;
666
+ value: string | string[];
667
+ }>;
668
+ }
669
+ type CustomQueryFn<TRecord = unknown> = (params: CustomQueryFnParams) => Promise<CustomQueryFnResponse<TRecord>>;
690
670
 
691
671
  interface FormRootProps<TData extends FieldValues> {
692
672
  /**
@@ -715,8 +695,8 @@ interface FormRootProps<TData extends FieldValues> {
715
695
  * }
716
696
  */
717
697
  schema: CustomJSONSchema7;
718
- idMap: Record<string, object>;
719
- setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
698
+ idMap: Record<string, unknown>;
699
+ setIdMap: Dispatch<SetStateAction<Record<string, unknown>>>;
720
700
  form: UseFormReturn<TData, any, TData>;
721
701
  children: ReactNode;
722
702
  onSubmit?: SubmitHandler<TData>;
@@ -775,12 +755,12 @@ declare const MediaLibraryBrowser: ({ onFetchFiles, filterImageOnly, labels, ena
775
755
 
776
756
  interface UseFormProps<T> {
777
757
  preLoadedValues?: T | undefined;
778
- schema?: CustomJSONSchema7;
758
+ schema: CustomJSONSchema7;
779
759
  }
780
760
  declare function useForm<T extends FieldValues = any>({ preLoadedValues, schema, }: UseFormProps<T>): {
781
761
  form: react_hook_form.UseFormReturn<T, any, T>;
782
- idMap: Record<string, object>;
783
- setIdMap: React$1.Dispatch<React$1.SetStateAction<Record<string, object>>>;
762
+ idMap: Record<string, unknown>;
763
+ setIdMap: React$1.Dispatch<React$1.SetStateAction<Record<string, unknown>>>;
784
764
  };
785
765
 
786
766
  interface CalendarDate {
@@ -1244,4 +1224,4 @@ declare module '@tanstack/react-table' {
1244
1224
  }
1245
1225
  }
1246
1226
 
1247
- export { CalendarDisplay, type CalendarDisplayProps, type CalendarEvent, type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, 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, FormTitle, 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, type TagPickerProps, TextCell, type TextCellProps, type TimePickerLabels, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type ValidationErrorType, ViewDialog, defaultRenderDisplay, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm };
1227
+ 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, FormTitle, 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, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type ValidationErrorType, ViewDialog, defaultRenderDisplay, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm };
package/dist/index.js CHANGED
@@ -4987,7 +4987,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
4987
4987
  }) }) }) }));
4988
4988
  }
4989
4989
  return (jsxRuntime.jsxs(Field, { label: formI18n.label(), required: isRequired, alignItems: 'stretch', gridColumn,
4990
- gridRow, errorText: undefined, invalid: !!errors[colLabel], children: [isMultiple && currentValue.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: 'wrap', gap: 1, mb: 2, children: currentValue.map((enumValue) => {
4990
+ gridRow, errorText: jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldError }), invalid: !!fieldError, children: [isMultiple && currentValue.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: 'wrap', gap: 1, mb: 2, children: currentValue.map((enumValue) => {
4991
4991
  if (!enumValue) {
4992
4992
  return null;
4993
4993
  }
@@ -4995,7 +4995,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
4995
4995
  const newValue = currentValue.filter((val) => val !== enumValue);
4996
4996
  setValue(colLabel, newValue);
4997
4997
  }, children: renderEnumValue(enumValue) }, enumValue));
4998
- }) })), jsxRuntime.jsxs(react.Combobox.Root, { collection: collection, value: currentValue, onValueChange: handleValueChange, onInputValueChange: handleInputValueChange, multiple: isMultiple, closeOnSelect: !isMultiple, openOnClick: true, invalid: !!errors[colLabel], width: "100%", positioning: insideDialog
4998
+ }) })), jsxRuntime.jsxs(react.Combobox.Root, { collection: collection, value: currentValue, onValueChange: handleValueChange, onInputValueChange: handleInputValueChange, multiple: isMultiple, closeOnSelect: !isMultiple, openOnClick: true, invalid: !!fieldError, width: "100%", positioning: insideDialog
4999
4999
  ? { strategy: 'fixed', hideWhenDetached: true }
5000
5000
  : undefined, children: [jsxRuntime.jsxs(react.Combobox.Control, { position: "relative", children: [!isMultiple &&
5001
5001
  selectedSingleValue &&
@@ -5018,7 +5018,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
5018
5018
  : undefined,
5019
5019
  } }), jsxRuntime.jsxs(react.Combobox.IndicatorGroup, { children: [!isMultiple && currentValue.length > 0 && (jsxRuntime.jsx(react.Combobox.ClearTrigger, { onClick: () => {
5020
5020
  setValue(colLabel, '');
5021
- } })), jsxRuntime.jsx(react.Combobox.Trigger, {})] })] }), insideDialog ? (jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsxs(react.Combobox.Content, { children: [showTotalAndLimit && (jsxRuntime.jsx(react.Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) })) : (jsxRuntime.jsx(react.Portal, { children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsxs(react.Combobox.Content, { children: [showTotalAndLimit && (jsxRuntime.jsx(react.Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) }) }))] })] }));
5021
+ } })), jsxRuntime.jsx(react.Combobox.Trigger, {})] })] }), jsxRuntime.jsx(react.Portal, { disabled: insideDialog, children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsxs(react.Combobox.Content, { children: [showTotalAndLimit && (jsxRuntime.jsx(react.Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) }) })] })] }));
5022
5022
  };
5023
5023
 
5024
5024
  function isEnteringWindow(_ref) {
@@ -5978,13 +5978,14 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
5978
5978
  return fallbackLabel;
5979
5979
  };
5980
5980
  const itemsFromDataList = dataList.map((item) => {
5981
- const rendered = renderFn(item);
5982
- const label = typeof rendered === 'string' ? rendered : JSON.stringify(item); // Use string for filtering
5981
+ const typedItem = item;
5982
+ const rendered = renderFn(typedItem);
5983
+ const label = typeof rendered === 'string' ? rendered : JSON.stringify(typedItem); // Use string for filtering
5983
5984
  return {
5984
5985
  label, // Use string for filtering
5985
5986
  displayLabel: getDisplayString(rendered, label), // String representation for input display
5986
- value: itemToValueFn(item),
5987
- raw: item,
5987
+ value: itemToValueFn(typedItem),
5988
+ raw: typedItem,
5988
5989
  };
5989
5990
  });
5990
5991
  // Add items from idMap that match currentValue but aren't in dataList
@@ -6303,94 +6304,6 @@ const StringInputField = ({ column, schema, prefix, }) => {
6303
6304
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(Field, { label: formI18n.label(), required: isRequired, gridColumn: gridColumn, gridRow: gridRow, errorText: jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldError }), invalid: !!fieldError, children: jsxRuntime.jsx(react.Input, { ...register(`${colLabel}`, { required: isRequired }), autoComplete: "off" }) }) }));
6304
6305
  };
6305
6306
 
6306
- const RadioCardItem = React__namespace.forwardRef(function RadioCardItem(props, ref) {
6307
- const { inputProps, label, description, addon, icon, indicator = jsxRuntime.jsx(react.RadioCard.ItemIndicator, {}), indicatorPlacement = "end", ...rest } = props;
6308
- const hasContent = label || description || icon;
6309
- const ContentWrapper = indicator ? react.RadioCard.ItemContent : React__namespace.Fragment;
6310
- 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 })] }));
6311
- });
6312
- const RadioCardRoot = react.RadioCard.Root;
6313
- react.RadioCard.Label;
6314
- react.RadioCard.ItemIndicator;
6315
-
6316
- const TagPicker = ({ column, schema }) => {
6317
- const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
6318
- if (schema.properties == undefined) {
6319
- throw new Error('schema properties undefined when using DatePicker');
6320
- }
6321
- const { gridColumn, gridRow, tagPicker } = schema;
6322
- if (!tagPicker?.queryFn) {
6323
- throw new Error('tagPicker.queryFn is required in schema. serverUrl has been removed.');
6324
- }
6325
- const query = reactQuery.useQuery({
6326
- queryKey: [`tagpicker`],
6327
- queryFn: async () => {
6328
- const result = await tagPicker.queryFn({
6329
- where: [],
6330
- limit: 100,
6331
- offset: 0,
6332
- searching: '',
6333
- });
6334
- return result.data || { data: [] };
6335
- },
6336
- staleTime: 10000,
6337
- });
6338
- const object_id = watch(column);
6339
- const existingTagsQuery = reactQuery.useQuery({
6340
- queryKey: [`existing`, object_id],
6341
- queryFn: async () => {
6342
- const result = await tagPicker.queryFn({
6343
- where: [
6344
- {
6345
- id: column,
6346
- value: [object_id[0]],
6347
- },
6348
- ],
6349
- limit: 100,
6350
- offset: 0,
6351
- searching: '',
6352
- });
6353
- return result.data || { data: [] };
6354
- },
6355
- enabled: object_id != undefined,
6356
- staleTime: 10000,
6357
- });
6358
- const { isLoading, isFetching, data, isPending, isError } = query;
6359
- const dataList = data?.data ?? [];
6360
- const existingTagList = existingTagsQuery.data?.data ?? [];
6361
- if (!!object_id === false) {
6362
- return jsxRuntime.jsx(jsxRuntime.Fragment, {});
6363
- }
6364
- return (jsxRuntime.jsxs(react.Flex, { flexFlow: 'column', gap: 4, gridColumn,
6365
- 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 }) => {
6366
- 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) => {
6367
- const existedTags = Object.values(all_tags)
6368
- .filter(({ id }) => {
6369
- return existingTagList.some(({ tag_id }) => tag_id === id);
6370
- })
6371
- .map(({ id }) => {
6372
- return id;
6373
- });
6374
- setValue(`${column}.${parent_tag_name}.current`, [
6375
- tagIds.value,
6376
- ]);
6377
- setValue(`${column}.${parent_tag_name}.old`, existedTags);
6378
- }, children: jsxRuntime.jsx(react.Flex, { flexFlow: 'wrap', gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
6379
- if (existingTagList.some(({ tag_id }) => tag_id === id)) {
6380
- return (jsxRuntime.jsx(RadioCardItem, { label: tagName, value: id, flex: '0 0 0%', disabled: true }, `${tagName}-${id}`));
6381
- }
6382
- return (jsxRuntime.jsx(RadioCardItem, { label: tagName, value: id, flex: '0 0 0%', colorPalette: 'blue' }, `${tagName}-${id}`));
6383
- }) }) })), !is_mutually_exclusive && (jsxRuntime.jsx(react.CheckboxGroup, { onValueChange: (tagIds) => {
6384
- setValue(`${column}.${parent_tag_name}.current`, tagIds);
6385
- }, children: jsxRuntime.jsx(react.Flex, { flexFlow: 'wrap', gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
6386
- if (existingTagList.some(({ tag_id }) => tag_id === id)) {
6387
- return (jsxRuntime.jsx(CheckboxCard, { label: tagName, value: id, flex: '0 0 0%', disabled: true, colorPalette: 'blue' }, `${tagName}-${id}`));
6388
- }
6389
- return (jsxRuntime.jsx(CheckboxCard, { label: tagName, value: id, flex: '0 0 0%' }, `${tagName}-${id}`));
6390
- }) }) }))] }, `tag-${parent_tag_name}`));
6391
- }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: 'red.400', children: (errors[`${column}`]?.message ?? 'No error message') }))] }));
6392
- };
6393
-
6394
6307
  const Textarea = React__namespace.forwardRef(function Textarea({ value, onChange, ...props }, ref) {
6395
6308
  const handleChange = React__namespace.useCallback((e) => {
6396
6309
  if (onChange) {
@@ -7962,9 +7875,6 @@ const SchemaRenderer = ({ schema, prefix, column, }) => {
7962
7875
  if (variant === 'id-picker') {
7963
7876
  return jsxRuntime.jsx(IdPickerMultiple, { schema: colSchema, prefix, column });
7964
7877
  }
7965
- if (variant === 'tag-picker') {
7966
- return jsxRuntime.jsx(TagPicker, { schema: colSchema, prefix, column });
7967
- }
7968
7878
  if (variant === 'file-picker') {
7969
7879
  return jsxRuntime.jsx(FilePicker, { schema: colSchema, prefix, column });
7970
7880
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, CheckboxCard as CheckboxCard$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, Tooltip as Tooltip$1, Group, InputElement, Tag as Tag$1, Checkbox as Checkbox$1, Icon, VStack, Heading, EmptyState as EmptyState$2, List, Table as Table$1, Card, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Clipboard, Badge, Link, Image, Alert, Field as Field$1, Popover, useFilter, useListCollection, Combobox, Tabs, useCombobox, Show, Skeleton, NumberInput, RadioCard, CheckboxGroup, Textarea as Textarea$1, InputGroup as InputGroup$1, Select, Stack } from '@chakra-ui/react';
2
+ import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, CheckboxCard as CheckboxCard$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, Tooltip as Tooltip$1, Group, InputElement, Tag as Tag$1, Checkbox as Checkbox$1, Icon, VStack, Heading, EmptyState as EmptyState$2, List, Table as Table$1, Card, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Clipboard, Badge, Link, Image, Alert, Field as Field$1, Popover, useFilter, useListCollection, Combobox, Tabs, useCombobox, Show, Skeleton, NumberInput, Textarea as Textarea$1, InputGroup as InputGroup$1, Select, Stack } from '@chakra-ui/react';
3
3
  import { AiOutlineColumnWidth } from 'react-icons/ai';
4
4
  import * as React from 'react';
5
5
  import { createContext, useContext, useState, useMemo, useCallback, useEffect, useRef } from 'react';
@@ -4967,7 +4967,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
4967
4967
  }) }) }) }));
4968
4968
  }
4969
4969
  return (jsxs(Field, { label: formI18n.label(), required: isRequired, alignItems: 'stretch', gridColumn,
4970
- gridRow, errorText: undefined, invalid: !!errors[colLabel], children: [isMultiple && currentValue.length > 0 && (jsx(Flex, { flexFlow: 'wrap', gap: 1, mb: 2, children: currentValue.map((enumValue) => {
4970
+ gridRow, errorText: jsx(Fragment, { children: fieldError }), invalid: !!fieldError, children: [isMultiple && currentValue.length > 0 && (jsx(Flex, { flexFlow: 'wrap', gap: 1, mb: 2, children: currentValue.map((enumValue) => {
4971
4971
  if (!enumValue) {
4972
4972
  return null;
4973
4973
  }
@@ -4975,7 +4975,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
4975
4975
  const newValue = currentValue.filter((val) => val !== enumValue);
4976
4976
  setValue(colLabel, newValue);
4977
4977
  }, children: renderEnumValue(enumValue) }, enumValue));
4978
- }) })), jsxs(Combobox.Root, { collection: collection, value: currentValue, onValueChange: handleValueChange, onInputValueChange: handleInputValueChange, multiple: isMultiple, closeOnSelect: !isMultiple, openOnClick: true, invalid: !!errors[colLabel], width: "100%", positioning: insideDialog
4978
+ }) })), jsxs(Combobox.Root, { collection: collection, value: currentValue, onValueChange: handleValueChange, onInputValueChange: handleInputValueChange, multiple: isMultiple, closeOnSelect: !isMultiple, openOnClick: true, invalid: !!fieldError, width: "100%", positioning: insideDialog
4979
4979
  ? { strategy: 'fixed', hideWhenDetached: true }
4980
4980
  : undefined, children: [jsxs(Combobox.Control, { position: "relative", children: [!isMultiple &&
4981
4981
  selectedSingleValue &&
@@ -4998,7 +4998,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
4998
4998
  : undefined,
4999
4999
  } }), jsxs(Combobox.IndicatorGroup, { children: [!isMultiple && currentValue.length > 0 && (jsx(Combobox.ClearTrigger, { onClick: () => {
5000
5000
  setValue(colLabel, '');
5001
- } })), jsx(Combobox.Trigger, {})] })] }), insideDialog ? (jsx(Combobox.Positioner, { children: jsxs(Combobox.Content, { children: [showTotalAndLimit && (jsx(Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsx(Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) })) : (jsx(Portal, { children: jsx(Combobox.Positioner, { children: jsxs(Combobox.Content, { children: [showTotalAndLimit && (jsx(Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsx(Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) }) }))] })] }));
5001
+ } })), jsx(Combobox.Trigger, {})] })] }), jsx(Portal, { disabled: insideDialog, children: jsx(Combobox.Positioner, { children: jsxs(Combobox.Content, { children: [showTotalAndLimit && (jsx(Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsx(Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) }) })] })] }));
5002
5002
  };
5003
5003
 
5004
5004
  function isEnteringWindow(_ref) {
@@ -5958,13 +5958,14 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
5958
5958
  return fallbackLabel;
5959
5959
  };
5960
5960
  const itemsFromDataList = dataList.map((item) => {
5961
- const rendered = renderFn(item);
5962
- const label = typeof rendered === 'string' ? rendered : JSON.stringify(item); // Use string for filtering
5961
+ const typedItem = item;
5962
+ const rendered = renderFn(typedItem);
5963
+ const label = typeof rendered === 'string' ? rendered : JSON.stringify(typedItem); // Use string for filtering
5963
5964
  return {
5964
5965
  label, // Use string for filtering
5965
5966
  displayLabel: getDisplayString(rendered, label), // String representation for input display
5966
- value: itemToValueFn(item),
5967
- raw: item,
5967
+ value: itemToValueFn(typedItem),
5968
+ raw: typedItem,
5968
5969
  };
5969
5970
  });
5970
5971
  // Add items from idMap that match currentValue but aren't in dataList
@@ -6283,94 +6284,6 @@ const StringInputField = ({ column, schema, prefix, }) => {
6283
6284
  return (jsx(Fragment, { children: jsx(Field, { label: formI18n.label(), required: isRequired, gridColumn: gridColumn, gridRow: gridRow, errorText: jsx(Fragment, { children: fieldError }), invalid: !!fieldError, children: jsx(Input, { ...register(`${colLabel}`, { required: isRequired }), autoComplete: "off" }) }) }));
6284
6285
  };
6285
6286
 
6286
- const RadioCardItem = React.forwardRef(function RadioCardItem(props, ref) {
6287
- const { inputProps, label, description, addon, icon, indicator = jsx(RadioCard.ItemIndicator, {}), indicatorPlacement = "end", ...rest } = props;
6288
- const hasContent = label || description || icon;
6289
- const ContentWrapper = indicator ? RadioCard.ItemContent : React.Fragment;
6290
- return (jsxs(RadioCard.Item, { ...rest, children: [jsx(RadioCard.ItemHiddenInput, { ref: ref, ...inputProps }), jsxs(RadioCard.ItemControl, { children: [indicatorPlacement === "start" && indicator, hasContent && (jsxs(ContentWrapper, { children: [icon, label && jsx(RadioCard.ItemText, { children: label }), description && (jsx(RadioCard.ItemDescription, { children: description })), indicatorPlacement === "inside" && indicator] })), indicatorPlacement === "end" && indicator] }), addon && jsx(RadioCard.ItemAddon, { children: addon })] }));
6291
- });
6292
- const RadioCardRoot = RadioCard.Root;
6293
- RadioCard.Label;
6294
- RadioCard.ItemIndicator;
6295
-
6296
- const TagPicker = ({ column, schema }) => {
6297
- const { watch, formState: { errors }, setValue, } = useFormContext();
6298
- if (schema.properties == undefined) {
6299
- throw new Error('schema properties undefined when using DatePicker');
6300
- }
6301
- const { gridColumn, gridRow, tagPicker } = schema;
6302
- if (!tagPicker?.queryFn) {
6303
- throw new Error('tagPicker.queryFn is required in schema. serverUrl has been removed.');
6304
- }
6305
- const query = useQuery({
6306
- queryKey: [`tagpicker`],
6307
- queryFn: async () => {
6308
- const result = await tagPicker.queryFn({
6309
- where: [],
6310
- limit: 100,
6311
- offset: 0,
6312
- searching: '',
6313
- });
6314
- return result.data || { data: [] };
6315
- },
6316
- staleTime: 10000,
6317
- });
6318
- const object_id = watch(column);
6319
- const existingTagsQuery = useQuery({
6320
- queryKey: [`existing`, object_id],
6321
- queryFn: async () => {
6322
- const result = await tagPicker.queryFn({
6323
- where: [
6324
- {
6325
- id: column,
6326
- value: [object_id[0]],
6327
- },
6328
- ],
6329
- limit: 100,
6330
- offset: 0,
6331
- searching: '',
6332
- });
6333
- return result.data || { data: [] };
6334
- },
6335
- enabled: object_id != undefined,
6336
- staleTime: 10000,
6337
- });
6338
- const { isLoading, isFetching, data, isPending, isError } = query;
6339
- const dataList = data?.data ?? [];
6340
- const existingTagList = existingTagsQuery.data?.data ?? [];
6341
- if (!!object_id === false) {
6342
- return jsx(Fragment, {});
6343
- }
6344
- return (jsxs(Flex, { flexFlow: 'column', gap: 4, gridColumn,
6345
- gridRow, children: [isFetching && jsx(Fragment, { children: "isFetching" }), isLoading && jsx(Fragment, { children: "isLoading" }), isPending && jsx(Fragment, { children: "isPending" }), isError && jsx(Fragment, { children: "isError" }), dataList.map(({ parent_tag_name, all_tags, is_mutually_exclusive }) => {
6346
- return (jsxs(Flex, { flexFlow: 'column', gap: 2, children: [jsx(Text, { children: parent_tag_name }), is_mutually_exclusive && (jsx(RadioCardRoot, { defaultValue: "next", variant: 'surface', onValueChange: (tagIds) => {
6347
- const existedTags = Object.values(all_tags)
6348
- .filter(({ id }) => {
6349
- return existingTagList.some(({ tag_id }) => tag_id === id);
6350
- })
6351
- .map(({ id }) => {
6352
- return id;
6353
- });
6354
- setValue(`${column}.${parent_tag_name}.current`, [
6355
- tagIds.value,
6356
- ]);
6357
- setValue(`${column}.${parent_tag_name}.old`, existedTags);
6358
- }, children: jsx(Flex, { flexFlow: 'wrap', gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
6359
- if (existingTagList.some(({ tag_id }) => tag_id === id)) {
6360
- return (jsx(RadioCardItem, { label: tagName, value: id, flex: '0 0 0%', disabled: true }, `${tagName}-${id}`));
6361
- }
6362
- return (jsx(RadioCardItem, { label: tagName, value: id, flex: '0 0 0%', colorPalette: 'blue' }, `${tagName}-${id}`));
6363
- }) }) })), !is_mutually_exclusive && (jsx(CheckboxGroup, { onValueChange: (tagIds) => {
6364
- setValue(`${column}.${parent_tag_name}.current`, tagIds);
6365
- }, children: jsx(Flex, { flexFlow: 'wrap', gap: 2, children: Object.entries(all_tags).map(([tagName, { id }]) => {
6366
- if (existingTagList.some(({ tag_id }) => tag_id === id)) {
6367
- return (jsx(CheckboxCard, { label: tagName, value: id, flex: '0 0 0%', disabled: true, colorPalette: 'blue' }, `${tagName}-${id}`));
6368
- }
6369
- return (jsx(CheckboxCard, { label: tagName, value: id, flex: '0 0 0%' }, `${tagName}-${id}`));
6370
- }) }) }))] }, `tag-${parent_tag_name}`));
6371
- }), errors[`${column}`] && (jsx(Text, { color: 'red.400', children: (errors[`${column}`]?.message ?? 'No error message') }))] }));
6372
- };
6373
-
6374
6287
  const Textarea = React.forwardRef(function Textarea({ value, onChange, ...props }, ref) {
6375
6288
  const handleChange = React.useCallback((e) => {
6376
6289
  if (onChange) {
@@ -7942,9 +7855,6 @@ const SchemaRenderer = ({ schema, prefix, column, }) => {
7942
7855
  if (variant === 'id-picker') {
7943
7856
  return jsx(IdPickerMultiple, { schema: colSchema, prefix, column });
7944
7857
  }
7945
- if (variant === 'tag-picker') {
7946
- return jsx(TagPicker, { schema: colSchema, prefix, column });
7947
- }
7948
7858
  if (variant === 'file-picker') {
7949
7859
  return jsx(FilePicker, { schema: colSchema, prefix, column });
7950
7860
  }
@@ -4,8 +4,8 @@ import { CustomJSONSchema7, DateTimePickerLabels, EnumPickerLabels, FilePickerLa
4
4
  export interface SchemaFormContext<TData extends FieldValues> {
5
5
  schema: CustomJSONSchema7;
6
6
  onSubmit?: (data: TData) => Promise<void>;
7
- idMap: Record<string, object>;
8
- setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
7
+ idMap: Record<string, unknown>;
8
+ setIdMap: Dispatch<SetStateAction<Record<string, unknown>>>;
9
9
  timezone?: string;
10
10
  displayConfig: {
11
11
  showSubmitButton?: boolean;
@@ -29,8 +29,8 @@ export interface FormRootProps<TData extends FieldValues> {
29
29
  * }
30
30
  */
31
31
  schema: CustomJSONSchema7;
32
- idMap: Record<string, object>;
33
- setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
32
+ idMap: Record<string, unknown>;
33
+ setIdMap: Dispatch<SetStateAction<Record<string, unknown>>>;
34
34
  form: UseFormReturn<TData, any, TData>;
35
35
  children: ReactNode;
36
36
  onSubmit?: SubmitHandler<TData>;
@@ -1,24 +1,4 @@
1
1
  import { InputDefaultProps } from './types';
2
2
  export interface StringInputFieldProps extends InputDefaultProps {
3
3
  }
4
- export interface CustomQueryFnResponse {
5
- /**
6
- * The data of the query
7
- */
8
- data: any;
9
- /**
10
- * The id map of the data
11
- */
12
- idMap: Record<string, any>;
13
- }
14
- export interface CustomQueryFnParams {
15
- searching: string;
16
- limit: number;
17
- offset: number;
18
- where?: Array<{
19
- id: string;
20
- value: string | string[];
21
- }>;
22
- }
23
- export type CustomQueryFn = (params: CustomQueryFnParams) => Promise<CustomQueryFnResponse>;
24
4
  export declare const StringInputField: ({ column, schema, prefix, }: StringInputFieldProps) => import("react/jsx-runtime").JSX.Element;
@@ -38,7 +38,7 @@ export interface UseIdPickerDataReturn {
38
38
  value: string;
39
39
  raw: RecordType;
40
40
  }>) => void;
41
- idMap: Record<string, object>;
41
+ idMap: Record<string, unknown>;
42
42
  idPickerLabels?: IdPickerLabels;
43
43
  insideDialog: boolean;
44
44
  renderDisplay: ((item: RecordType) => React.ReactNode) | undefined;
@@ -1,6 +1,5 @@
1
1
  import { JSONSchema7 } from 'json-schema';
2
2
  import { ReactNode } from 'react';
3
- import { CustomQueryFn } from '../fields/StringInputField';
4
3
  import { UseFormReturn } from 'react-hook-form';
5
4
  import React from 'react';
6
5
  export type ValidationErrorType = 'minLength' | 'maxLength' | 'pattern' | 'minimum' | 'maximum' | 'multipleOf' | 'format' | 'type' | 'enum' | 'required' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minProperties' | 'maxProperties' | 'anyOf' | 'oneOf' | 'allOf' | 'const' | 'additionalProperties' | 'dependencies';
@@ -69,23 +68,23 @@ export interface TimePickerLabels {
69
68
  emptyMessage?: string;
70
69
  selectTimeLabel?: string;
71
70
  }
72
- export interface LoadInitialValuesParams {
71
+ export interface LoadInitialValuesParams<TRecord = unknown> {
73
72
  ids: string[];
74
- customQueryFn: CustomQueryFn;
75
- setIdMap: React.Dispatch<React.SetStateAction<Record<string, object>>>;
73
+ customQueryFn: CustomQueryFn<TRecord>;
74
+ setIdMap: React.Dispatch<React.SetStateAction<Record<string, TRecord>>>;
76
75
  }
77
- export interface LoadInitialValuesResult {
76
+ export interface LoadInitialValuesResult<TRecord = unknown> {
78
77
  data: {
79
- data: Record<string, any>[];
78
+ data: TRecord[];
80
79
  count: number;
81
80
  };
82
- idMap: Record<string, object>;
81
+ idMap: Record<string, TRecord>;
83
82
  }
84
83
  export interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'additionalItems' | 'properties' | 'additionalProperties' | 'definitions' | 'patternProperties' | 'dependencies' | 'allOf' | 'anyOf' | 'oneOf' | 'not' | 'if' | 'then' | 'else' | 'contains'> {
85
84
  gridColumn?: string;
86
85
  gridRow?: string;
87
86
  customQueryFn?: CustomQueryFn;
88
- variant?: 'custom-input' | 'id-picker' | 'text-area' | 'media-library-browser' | 'tag-picker' | 'file-picker' | 'date-range' | 'enum-picker' | 'radio';
87
+ variant?: 'custom-input' | 'id-picker' | 'text-area' | 'media-library-browser' | 'file-picker' | 'date-range' | 'enum-picker' | 'radio';
89
88
  renderDisplay?: (item: unknown) => ReactNode;
90
89
  itemToValue?: (item: unknown) => string;
91
90
  loadInitialValues?: (params: LoadInitialValuesParams) => Promise<LoadInitialValuesResult>;
@@ -110,23 +109,6 @@ export interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'addition
110
109
  numberStorageType?: 'string' | 'number';
111
110
  errorMessage?: Record<Partial<ValidationErrorType> | string, string | Record<string, string>>;
112
111
  filePicker?: FilePickerProps;
113
- tagPicker?: {
114
- queryFn?: (params: {
115
- where?: {
116
- id: string;
117
- value: string[];
118
- }[];
119
- limit?: number;
120
- offset?: number;
121
- searching?: string;
122
- }) => Promise<{
123
- data: {
124
- data: any[];
125
- count: number;
126
- };
127
- idMap?: Record<string, object>;
128
- }>;
129
- };
130
112
  dateTimePicker?: {
131
113
  showQuickActions?: boolean;
132
114
  quickActionLabels?: {
@@ -162,11 +144,6 @@ export interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'addition
162
144
  contains?: CustomJSONSchema7;
163
145
  }
164
146
  export declare const defaultRenderDisplay: (item: unknown) => ReactNode;
165
- export interface TagPickerProps {
166
- column: string;
167
- schema: CustomJSONSchema7;
168
- prefix: string;
169
- }
170
147
  export interface FilePickerMediaFile {
171
148
  id: string;
172
149
  name: string;
@@ -182,3 +159,26 @@ export interface FilePickerProps {
182
159
  enableUpload?: boolean;
183
160
  onUploadFile?: (file: File) => Promise<string>;
184
161
  }
162
+ export interface CustomQueryFnResponse<TRecord = unknown> {
163
+ /**
164
+ * The data of the query
165
+ */
166
+ data: {
167
+ data: TRecord[];
168
+ count: number;
169
+ };
170
+ /**
171
+ * The id map of the data
172
+ */
173
+ idMap: Record<string, TRecord>;
174
+ }
175
+ export interface CustomQueryFnParams {
176
+ searching: string;
177
+ limit: number;
178
+ offset: number;
179
+ where?: Array<{
180
+ id: string;
181
+ value: string | string[];
182
+ }>;
183
+ }
184
+ export type CustomQueryFn<TRecord = unknown> = (params: CustomQueryFnParams) => Promise<CustomQueryFnResponse<TRecord>>;
@@ -3,10 +3,10 @@ import { FieldValues } from 'react-hook-form';
3
3
  import { CustomJSONSchema7 } from './components/types/CustomJSONSchema7';
4
4
  export interface UseFormProps<T> {
5
5
  preLoadedValues?: T | undefined;
6
- schema?: CustomJSONSchema7;
6
+ schema: CustomJSONSchema7;
7
7
  }
8
8
  export declare function useForm<T extends FieldValues = any>({ preLoadedValues, schema, }: UseFormProps<T>): {
9
9
  form: import("react-hook-form").UseFormReturn<T, any, T>;
10
- idMap: Record<string, object>;
11
- setIdMap: import("react").Dispatch<import("react").SetStateAction<Record<string, object>>>;
10
+ idMap: Record<string, unknown>;
11
+ setIdMap: import("react").Dispatch<import("react").SetStateAction<Record<string, unknown>>>;
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "13.0.1-beta.28",
3
+ "version": "13.0.1-beta.29",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,25 +0,0 @@
1
- import { TagPickerProps } from '../types/CustomJSONSchema7';
2
- export interface Tag {
3
- id: string;
4
- name: string;
5
- comment: string | null;
6
- extra_info: string | null;
7
- created_at: string;
8
- updated_at: string;
9
- table_id: string | null;
10
- parent_id: string;
11
- }
12
- export interface AllTags {
13
- [tagName: string]: Tag;
14
- }
15
- export interface TagData {
16
- table_name: string;
17
- parent_tag_name: string;
18
- parent_tag_id: string;
19
- all_tags: AllTags;
20
- is_mutually_exclusive: boolean;
21
- }
22
- export interface TagResponse {
23
- data: TagData[];
24
- }
25
- export declare const TagPicker: ({ column, schema }: TagPickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,30 +0,0 @@
1
- import { CustomJSONSchema7 } from '../types/CustomJSONSchema7';
2
- export interface Tag {
3
- id: string;
4
- name: string;
5
- comment: string | null;
6
- extra_info: string | null;
7
- created_at: string;
8
- updated_at: string;
9
- table_id: string | null;
10
- parent_id: string;
11
- }
12
- export interface AllTags {
13
- [tagName: string]: Tag;
14
- }
15
- export interface TagData {
16
- table_name: string;
17
- parent_tag_name: string;
18
- parent_tag_id: string;
19
- all_tags: AllTags;
20
- is_mutually_exclusive: boolean;
21
- }
22
- export interface TagResponse {
23
- data: TagData[];
24
- }
25
- export interface TagViewerProps {
26
- column: string;
27
- schema: CustomJSONSchema7;
28
- prefix: string;
29
- }
30
- export declare const TagViewer: ({ column, schema }: TagViewerProps) => import("react/jsx-runtime").JSX.Element;