@bsol-oss/react-datatable5 12.0.0-beta.72 → 12.0.0-beta.74

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/README.md CHANGED
@@ -22,7 +22,7 @@ The `DataTable` and `DataTableServer` utilize hook to add props.
22
22
 
23
23
  ```tsx
24
24
  const datatable = useDataTable();
25
- const datatableServer = useDataTableServer({ url: "<some-url>" });
25
+ const datatableServer = useDataTableServer({ url: '<some-url>' });
26
26
  ```
27
27
 
28
28
  ### DataTable
@@ -66,9 +66,9 @@ GET http://localhost:8081/api/g/core_people?offset=0&limit=10&sorting[0][id]=id&
66
66
  <DefaultCard
67
67
  {...{
68
68
  row: row,
69
- imageColumnId: "thumbnail",
70
- titleColumnId: "title",
71
- tagColumnId: "rating",
69
+ imageColumnId: 'thumbnail',
70
+ titleColumnId: 'title',
71
+ tagColumnId: 'rating',
72
72
  tagIcon: MdStarRate,
73
73
  }}
74
74
  />
@@ -111,45 +111,51 @@ The package now includes built-in JSON Schema validation using AJV (Another JSON
111
111
  #### Basic Usage with Internationalization
112
112
 
113
113
  ```tsx
114
- import { FormRoot, FormBody, validateData, SupportedLocale } from "@bsol-oss/react-datatable5";
114
+ import {
115
+ FormRoot,
116
+ FormBody,
117
+ validateData,
118
+ SupportedLocale,
119
+ } from '@bsol-oss/react-datatable5';
115
120
 
116
121
  const schema = {
117
- type: "object",
118
- required: ["email", "age"],
122
+ type: 'object',
123
+ required: ['email', 'age'],
119
124
  properties: {
120
125
  email: {
121
- type: "string",
122
- format: "email"
126
+ type: 'string',
127
+ format: 'email',
123
128
  },
124
129
  age: {
125
- type: "integer",
130
+ type: 'integer',
126
131
  minimum: 18,
127
- maximum: 120
132
+ maximum: 120,
128
133
  },
129
134
  name: {
130
- type: "string",
135
+ type: 'string',
131
136
  minLength: 2,
132
- maxLength: 50
133
- }
134
- }
137
+ maxLength: 50,
138
+ },
139
+ },
135
140
  };
136
141
 
137
142
  // Use Traditional Chinese (Hong Kong) for validation errors
138
- <FormRoot
139
- schema={schema}
143
+ <FormRoot
144
+ schema={schema}
140
145
  validationLocale="zh-HK"
141
146
  /* other props */
142
147
  >
143
148
  <FormBody />
144
- </FormRoot>
149
+ </FormRoot>;
145
150
  ```
146
151
 
147
152
  #### Language-specific Examples
148
153
 
149
154
  **Traditional Chinese (Hong Kong):**
155
+
150
156
  ```tsx
151
- <FormRoot
152
- schema={schema}
157
+ <FormRoot
158
+ schema={schema}
153
159
  validationLocale="zh-HK"
154
160
  /* other props */
155
161
  >
@@ -158,9 +164,10 @@ const schema = {
158
164
  ```
159
165
 
160
166
  **Traditional Chinese (Taiwan):**
167
+
161
168
  ```tsx
162
- <FormRoot
163
- schema={schema}
169
+ <FormRoot
170
+ schema={schema}
164
171
  validationLocale="zh-TW"
165
172
  /* other props */
166
173
  >
@@ -169,9 +176,10 @@ const schema = {
169
176
  ```
170
177
 
171
178
  **Simplified Chinese:**
179
+
172
180
  ```tsx
173
- <FormRoot
174
- schema={schema}
181
+ <FormRoot
182
+ schema={schema}
175
183
  validationLocale="zh-CN"
176
184
  /* other props */
177
185
  >
@@ -184,20 +192,27 @@ const schema = {
184
192
  You can also use the validation utilities directly with language support:
185
193
 
186
194
  ```tsx
187
- import { validateData, ValidationResult, SupportedLocale } from "@bsol-oss/react-datatable5";
195
+ import {
196
+ validateData,
197
+ ValidationResult,
198
+ SupportedLocale,
199
+ } from '@bsol-oss/react-datatable5';
188
200
 
189
201
  // Validate with Traditional Chinese (Hong Kong) error messages
190
- const result: ValidationResult = validateData(formData, schema, {
191
- locale: 'zh-HK'
202
+ const result: ValidationResult = validateData(formData, schema, {
203
+ locale: 'zh-HK',
192
204
  });
193
205
 
194
206
  if (!result.isValid) {
195
- console.log("驗證錯誤:", result.errors);
207
+ console.log('驗證錯誤:', result.errors);
196
208
  // Error messages will be in Traditional Chinese
197
209
  }
198
210
 
199
211
  // Check supported locales
200
- import { getSupportedLocales, isLocaleSupported } from "@bsol-oss/react-datatable5";
212
+ import {
213
+ getSupportedLocales,
214
+ isLocaleSupported,
215
+ } from '@bsol-oss/react-datatable5';
201
216
 
202
217
  const supportedLocales = getSupportedLocales(); // ['en', 'zh-HK', 'zh-TW', 'zh-CN', 'zh']
203
218
  const isSupported = isLocaleSupported('zh-HK'); // true
@@ -207,34 +222,37 @@ const isSupported = isLocaleSupported('zh-HK'); // true
207
222
 
208
223
  ```tsx
209
224
  interface ValidationError {
210
- field: string; // The field that failed validation
211
- message: string; // User-friendly error message (localized)
212
- value?: unknown; // The current value that failed
213
- schemaPath?: string; // JSON Schema path for debugging
225
+ field: string; // The field that failed validation
226
+ message: string; // User-friendly error message (localized)
227
+ value?: unknown; // The current value that failed
228
+ schemaPath?: string; // JSON Schema path for debugging
214
229
  }
215
230
  ```
216
231
 
217
232
  #### Dynamic Language Switching
218
233
 
219
234
  ```tsx
220
- import { SupportedLocale } from "@bsol-oss/react-datatable5";
235
+ import { SupportedLocale } from '@bsol-oss/react-datatable5';
221
236
 
222
237
  const MyForm = () => {
223
238
  const [locale, setLocale] = useState<SupportedLocale>('zh-HK');
224
-
239
+
225
240
  return (
226
241
  <div>
227
242
  {/* Language selector */}
228
- <select value={locale} onChange={(e) => setLocale(e.target.value as SupportedLocale)}>
243
+ <select
244
+ value={locale}
245
+ onChange={(e) => setLocale(e.target.value as SupportedLocale)}
246
+ >
229
247
  <option value="en">English</option>
230
248
  <option value="zh-HK">繁體中文(香港)</option>
231
249
  <option value="zh-TW">繁體中文(台灣)</option>
232
250
  <option value="zh-CN">简体中文</option>
233
251
  </select>
234
-
252
+
235
253
  {/* Form with dynamic locale */}
236
- <FormRoot
237
- schema={schema}
254
+ <FormRoot
255
+ schema={schema}
238
256
  validationLocale={locale}
239
257
  /* other props */
240
258
  >
@@ -248,16 +266,19 @@ const MyForm = () => {
248
266
  #### Example Validation Messages
249
267
 
250
268
  **English:**
269
+
251
270
  - "email is required"
252
271
  - "Invalid email format"
253
272
  - "Must be at least 18"
254
273
 
255
274
  **Traditional Chinese (Hong Kong/Taiwan):**
275
+
256
276
  - "email 為必填"
257
277
  - "無效的 email 格式"
258
278
  - "必須至少為 18"
259
279
 
260
280
  **Simplified Chinese:**
281
+
261
282
  - "email 为必填"
262
283
  - "无效的 email 格式"
263
284
  - "必须至少为 18"
@@ -281,4 +302,10 @@ For more details of props and examples, please review the stories in storybook p
281
302
  ```
282
303
  npm install
283
304
  npm run storybook
284
- ```
305
+ ```
306
+
307
+ ## deployment
308
+
309
+ ```
310
+ npm version prerelease --preid=beta
311
+ ```
package/dist/index.d.ts CHANGED
@@ -589,6 +589,16 @@ interface IdPickerLabels {
589
589
  emptySearchResult?: string;
590
590
  initialResults?: string;
591
591
  }
592
+ interface EnumPickerLabels {
593
+ undefined?: string;
594
+ addMore?: string;
595
+ typeToSearch?: string;
596
+ total?: string;
597
+ showing?: string;
598
+ perPage?: string;
599
+ emptySearchResult?: string;
600
+ initialResults?: string;
601
+ }
592
602
  interface CustomJSONSchema7 extends JSONSchema7 {
593
603
  gridColumn?: string;
594
604
  gridRow?: string;
@@ -612,6 +622,7 @@ interface CustomJSONSchema7 extends JSONSchema7 {
612
622
  timeFormat?: string;
613
623
  displayTimeFormat?: string;
614
624
  showLabel?: boolean;
625
+ formatOptions?: Intl.NumberFormatOptions;
615
626
  }
616
627
  interface TagPickerProps {
617
628
  column: string;
@@ -642,8 +653,10 @@ interface FormRootProps<TData extends FieldValues> {
642
653
  showResetButton?: boolean;
643
654
  showTitle?: boolean;
644
655
  };
656
+ requireConfirmation?: boolean;
645
657
  dateTimePickerLabels?: DateTimePickerLabels;
646
658
  idPickerLabels?: IdPickerLabels;
659
+ enumPickerLabels?: EnumPickerLabels;
647
660
  }
648
661
  interface CustomJSONSchema7Definition extends JSONSchema7 {
649
662
  variant: string;
@@ -660,7 +673,7 @@ declare const idPickerSanityCheck: (column: string, foreign_key?: {
660
673
  column?: string | undefined;
661
674
  display_column?: string | undefined;
662
675
  } | undefined) => void;
663
- declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, children, order, ignore, include, onSubmit, rowNumber, requestOptions, getUpdatedData, customErrorRenderer, customSuccessRenderer, displayConfig, dateTimePickerLabels, idPickerLabels, }: FormRootProps<TData>) => react_jsx_runtime.JSX.Element;
676
+ declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, children, order, ignore, include, onSubmit, rowNumber, requestOptions, getUpdatedData, customErrorRenderer, customSuccessRenderer, displayConfig, requireConfirmation, dateTimePickerLabels, idPickerLabels, enumPickerLabels, }: FormRootProps<TData>) => react_jsx_runtime.JSX.Element;
664
677
 
665
678
  interface DefaultFormProps<TData extends FieldValues> {
666
679
  formConfig: Omit<FormRootProps<TData>, "children">;
@@ -1051,4 +1064,4 @@ declare module "@tanstack/react-table" {
1051
1064
  }
1052
1065
  }
1053
1066
 
1054
- export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type ErrorMessageConfig, type ErrorMessageResult, type FieldErrorConfig, FilterDialog, FormBody, FormRoot, type FormRootProps, FormTitle, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, type IdPickerLabels, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, 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 UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type ValidationErrorType, ViewDialog, buildErrorMessages, buildFieldErrors, buildRequiredErrors, createErrorMessage, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
1067
+ export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, type EnumPickerLabels, ErrorAlert, type ErrorAlertProps, type ErrorMessageConfig, type ErrorMessageResult, type FieldErrorConfig, FilterDialog, FormBody, FormRoot, type FormRootProps, FormTitle, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, type IdPickerLabels, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, 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 UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type ValidationErrorType, ViewDialog, buildErrorMessages, buildFieldErrors, buildRequiredErrors, createErrorMessage, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };