@bsol-oss/react-datatable5 11.0.0-beta.0 → 11.0.0-beta.10

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.
Files changed (51) hide show
  1. package/README.md +1 -187
  2. package/dist/index.d.ts +12 -5
  3. package/dist/index.js +841 -561
  4. package/dist/index.mjs +844 -565
  5. package/dist/types/components/DataTable/DataDisplay.d.ts +1 -1
  6. package/dist/types/components/DataTable/utils/getColumns.d.ts +2 -1
  7. package/dist/types/components/Form/Form.d.ts +8 -2
  8. package/dist/types/components/Form/SchemaFormContext.d.ts +1 -0
  9. package/dist/types/components/Form/components/ArrayRenderer.d.ts +7 -0
  10. package/dist/types/components/Form/components/BooleanPicker.d.ts +4 -1
  11. package/dist/types/components/Form/components/ColumnRenderer.d.ts +7 -0
  12. package/dist/types/components/Form/components/DatePicker.d.ts +4 -1
  13. package/dist/types/components/Form/components/EnumPicker.d.ts +4 -1
  14. package/dist/types/components/Form/components/FilePicker.d.ts +3 -1
  15. package/dist/types/components/Form/components/IdPicker.d.ts +4 -1
  16. package/dist/types/components/Form/components/NumberInputField.d.ts +4 -1
  17. package/dist/types/components/Form/components/ObjectInput.d.ts +5 -2
  18. package/dist/types/components/Form/components/RecordInput.d.ts +7 -0
  19. package/dist/types/components/Form/components/SchemaRenderer.d.ts +7 -0
  20. package/dist/types/components/Form/components/StringInputField.d.ts +4 -4
  21. package/dist/types/components/Form/components/TagPicker.d.ts +4 -1
  22. package/dist/types/components/Form/components/fields/ArrayRenderer.d.ts +7 -0
  23. package/dist/types/components/Form/components/fields/BooleanPicker.d.ts +7 -0
  24. package/dist/types/components/Form/components/fields/ColumnRenderer.d.ts +7 -0
  25. package/dist/types/components/Form/components/fields/DatePicker.d.ts +7 -0
  26. package/dist/types/components/Form/components/fields/EnumPicker.d.ts +8 -0
  27. package/dist/types/components/Form/components/fields/FilePicker.d.ts +5 -0
  28. package/dist/types/components/Form/components/fields/IdPicker.d.ts +8 -0
  29. package/dist/types/components/Form/components/fields/NumberInputField.d.ts +7 -0
  30. package/dist/types/components/Form/components/fields/ObjectInput.d.ts +7 -0
  31. package/dist/types/components/Form/components/fields/RecordInput.d.ts +7 -0
  32. package/dist/types/components/Form/components/fields/SchemaRenderer.d.ts +7 -0
  33. package/dist/types/components/Form/components/fields/StringInputField.d.ts +12 -0
  34. package/dist/types/components/Form/components/fields/TagPicker.d.ts +25 -0
  35. package/dist/types/components/Form/components/types/CustomJSONSchema7.d.ts +15 -0
  36. package/dist/types/components/Form/components/viewers/ArrayViewer.d.ts +7 -0
  37. package/dist/types/components/Form/components/viewers/BooleanViewer.d.ts +7 -0
  38. package/dist/types/components/Form/components/viewers/ColumnViewer.d.ts +7 -0
  39. package/dist/types/components/Form/components/viewers/DateViewer.d.ts +7 -0
  40. package/dist/types/components/Form/components/viewers/EnumViewer.d.ts +8 -0
  41. package/dist/types/components/Form/components/viewers/FileViewer.d.ts +5 -0
  42. package/dist/types/components/Form/components/viewers/IdViewer.d.ts +8 -0
  43. package/dist/types/components/Form/components/viewers/NumberViewer.d.ts +7 -0
  44. package/dist/types/components/Form/components/viewers/ObjectViewer.d.ts +7 -0
  45. package/dist/types/components/Form/components/viewers/RecordViewer.d.ts +7 -0
  46. package/dist/types/components/Form/components/viewers/SchemaViewer.d.ts +7 -0
  47. package/dist/types/components/Form/components/viewers/StringViewer.d.ts +12 -0
  48. package/dist/types/components/Form/components/viewers/TagViewer.d.ts +30 -0
  49. package/dist/types/components/Form/useSchemaContext.d.ts +2 -14
  50. package/dist/types/components/Form/utils/removeIndex.d.ts +1 -0
  51. package/package.json +3 -4
package/README.md CHANGED
@@ -89,190 +89,4 @@ For more details of props and examples, please review the stories in storybook p
89
89
  ```
90
90
  npm install
91
91
  npm run storybook
92
- ```
93
-
94
- # Form
95
-
96
- Form component can help create a object to submit an network request.
97
-
98
- - Wrap form with confirmation, submit success and error handling ui by default
99
- - Use `i18next` by default to display `column_id` and text in form in multiple language.
100
- - Use `axios` by default to submit a request.
101
-
102
-
103
- ## Usage
104
-
105
- ```tsx
106
- <Form
107
- schema={someSchema as JSONSchema7}
108
- serverUrl={"http://localhost:8081"}
109
- />
110
- ```
111
-
112
- ## Set up
113
-
114
- ### Providers
115
-
116
- You MUST provide all three provider from packages `i18next`, `@tanstack/react-query`, and `@chakra-ui/react`
117
-
118
- ```tsx
119
- <Provider>
120
- <QueryClientProvider client={queryClient}>
121
- <I18nextProvider i18n={i18n}>
122
- <SomeForm />
123
- </I18nextProvider>
124
- </QueryClientProvider>
125
- </Provider>
126
- ```
127
-
128
- ### Schema
129
-
130
- You MUST provide a `schema` props to specify the inputs in a form. You MUST specify the keyword `type` as `object`.
131
-
132
- Currently, The `Form` component provide LIMITED json schema attributes in this release. Please check the below list to acknowledge the supported Keywords, and the intended keywords to support future releases.
133
-
134
- The example of a valid `schema` object
135
-
136
- ```tsx
137
- const schema = {
138
- type: "object",
139
- title: "core_memberships",
140
- required: ["id"],
141
- properties: {
142
- id: {
143
- type: "string",
144
- },
145
- remarks: {
146
- type: "string",
147
- },
148
- }
149
- }
150
- const SomeForm = () => {
151
- return (
152
- <Form
153
- schema={schema as JSONSchema7}
154
- serverUrl={"http://localhost:8081"}
155
- />
156
- )
157
- }
158
- ```
159
-
160
- ## Supported Keywords
161
-
162
- ### `title`
163
-
164
- You MUST provide the `title` keyword to specifies the string id that will be used in `i18n` translate.
165
-
166
- The value must be in type `string`.
167
-
168
- ### `required`
169
-
170
- You MAY provide the `required` keyword to specifies the input that are required to fill before confirmation.
171
-
172
- The value must be in type `array` of `string`.
173
-
174
- ### `properties`
175
-
176
- You MUST provide the `properties` keywords to specifies the fields that the form should appear.
177
-
178
- The value must be in type `object`. The keys in this object specifies the column id and the values its related properties. Check the sections **Column Keywords** show the supported column keywords.
179
-
180
-
181
- ## Column Keywords
182
-
183
- ### `type`
184
-
185
- You MUST provide the `type` keywords to specifies the value type that the column should create. Some value types may include different inputs by specify the `variant` keywords.
186
-
187
- Check the sections **Value types** show the supported keywords and input variants for each value type.
188
-
189
- Supported value types: `array`, `string`, `number`, `boolean`, `integer`, `object`;
190
-
191
- ## Value types
192
-
193
- This sections show the supported keywords and input variants for each value type.
194
-
195
- ### `string`
196
-
197
- For input types `string`, it will generate a string input by default.
198
-
199
- If you specify the `variant` keyword, it will render a picker to fill a string that requires a format.
200
-
201
- Supported variants in `string`: `id-picker`, `date_picker`
202
-
203
- #### `id-picker`
204
-
205
- For string input variant `id-picker`, it will generate a selector that can pop up a search to help the selection. After the user select a options, the input will show the selected record, and save its correspond string value in the form object.
206
-
207
- You MUST include the keyword `foreign_key` and a object with keys `display_column`, `table`, `column`. The `display_column` key is the column that show the label for that value to user, and `column` key is the column that its value should set in this input.
208
-
209
- You MUST include a `/api/g` api that could accept the following request in order to search for a record.
210
-
211
- ```ts
212
- const requestConfig = {
213
- method: "GET",
214
- url: `${serverUrl}/api/g/${table}`,
215
- params: {
216
- searching,
217
- where,
218
- limit,
219
- offset
220
- },
221
- }
222
- ```
223
-
224
- The example valid schema that use `id=picker` variant.
225
-
226
- ```tsx
227
- const eventsFilesSchema = {
228
- type: "object",
229
- title: "events_files",
230
- required: ["event_id", "file_id"],
231
- properties: {
232
- file_id: {
233
- type: "array",
234
- variant: "file-picker",
235
- },
236
- event_id: {
237
- type: "string",
238
- variant: "id-picker",
239
- foreign_key: {
240
- display_column: "event_name",
241
- table: "core_events",
242
- column: "id",
243
- },
244
- },
245
- },
246
- }
247
- ```
248
-
249
- ### `number`
250
-
251
- For value type `number`, it will generate a number input by default.
252
-
253
- Currently no supported variants.
254
-
255
- ### `boolean`
256
-
257
- For value type `boolean`, it will generate a checkbox by default.
258
-
259
- Currently no supported variants.
260
-
261
-
262
- ### `array`
263
-
264
- For value type `array`, by default it will generate NO input.
265
-
266
- You MUST specify the `variant` keyword to display a relevant input.
267
-
268
- Supported variant in `array`: `id-picker`, `file-picker`
269
-
270
- ### `object`
271
-
272
- For value type `object`, by default it will generate a input that can input key value pairs.
273
-
274
- It is NOT RECOMMENDED to use the default input, Later release may include a json editor by default.
275
-
276
- ### Intented Support Keywords in Future Release
277
-
278
- (TBC)
92
+ ```
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ import { UseTranslationResponse } from 'react-i18next';
10
10
  import { RankingInfo } from '@tanstack/match-sorter-utils';
11
11
  import { UseQueryResult } from '@tanstack/react-query';
12
12
  import { JSONSchema7 } from 'json-schema';
13
- import { ForeignKeyProps } from '@/components/Form/components/StringInputField';
13
+ import { ForeignKeyProps } from '@/components/Form/components/fields/StringInputField';
14
14
  import { AxiosRequestConfig } from 'axios';
15
15
  import * as react_hook_form from 'react-hook-form';
16
16
  import { FieldValues, UseFormReturn, SubmitHandler } from 'react-hook-form';
@@ -85,7 +85,7 @@ interface DataDisplayProps {
85
85
  variant?: "horizontal" | "stats" | "";
86
86
  translate?: UseTranslationResponse<any, any>;
87
87
  }
88
- declare const DataDisplay: ({ variant, translate }: DataDisplayProps) => react_jsx_runtime.JSX.Element;
88
+ declare const DataDisplay: ({ variant }: DataDisplayProps) => react_jsx_runtime.JSX.Element;
89
89
 
90
90
  type DensityState = "sm" | "md" | "lg";
91
91
  interface DensityTableState {
@@ -427,6 +427,7 @@ declare const useDataTableContext: <TData>() => DataTableContext<TData>;
427
427
 
428
428
  interface GetColumnsConfigs<K extends RowData> {
429
429
  schema: JSONSchema7;
430
+ include?: K[];
430
431
  ignore?: K[];
431
432
  width?: number[];
432
433
  meta?: {
@@ -436,7 +437,7 @@ interface GetColumnsConfigs<K extends RowData> {
436
437
  translate?: UseTranslationResponse<any, any>;
437
438
  }
438
439
  declare const widthSanityCheck: <K extends unknown>(widthList: number[], ignoreList: K[], properties: { [key in K as string]?: object | undefined; }) => void;
439
- declare const getColumns: <TData extends unknown>({ schema, ignore, width, meta, defaultWidth, translate, }: GetColumnsConfigs<TData>) => ColumnDef<TData>[];
440
+ declare const getColumns: <TData extends unknown>({ schema, include, ignore, width, meta, defaultWidth, translate, }: GetColumnsConfigs<TData>) => ColumnDef<TData>[];
440
441
 
441
442
  interface EmptyStateProps {
442
443
  title?: string;
@@ -466,6 +467,7 @@ interface FormProps<TData extends FieldValues> {
466
467
  translate: UseTranslationResponse<any, any>;
467
468
  order?: string[];
468
469
  ignore?: string[];
470
+ include?: string[];
469
471
  onSubmit?: SubmitHandler<TData>;
470
472
  rowNumber?: number | string;
471
473
  requestOptions?: AxiosRequestConfig;
@@ -479,7 +481,12 @@ interface CustomJSONSchema7Definition extends JSONSchema7 {
479
481
  gridRow: string;
480
482
  foreign_key: ForeignKeyProps;
481
483
  }
482
- declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit, preLoadedValues, rowNumber, requestOptions, }: FormProps<TData>) => react_jsx_runtime.JSX.Element;
484
+ declare const idPickerSanityCheck: (column: string, foreign_key?: {
485
+ table?: string | undefined;
486
+ column?: string | undefined;
487
+ display_column?: string | undefined;
488
+ } | undefined) => void;
489
+ declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, include, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => react_jsx_runtime.JSX.Element;
483
490
 
484
491
  interface UseFormProps {
485
492
  preLoadedValues?: FieldValues | undefined;
@@ -602,4 +609,4 @@ declare module "@tanstack/react-table" {
602
609
  }
603
610
  }
604
611
 
605
- export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerProps, DefaultCardTitle, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, FilterDialog, FilterOptions, type FilterOptionsProps, Form, type FormProps, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, Pagination, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, TableOrderer, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, ViewDialog, getColumns, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
612
+ export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerProps, DefaultCardTitle, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, FilterDialog, FilterOptions, type FilterOptionsProps, Form, type FormProps, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, Pagination, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, TableOrderer, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };