@bsol-oss/react-datatable5 13.0.1-beta.3 → 13.0.1-beta.30

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 (47) hide show
  1. package/README.md +5 -326
  2. package/dist/index.d.ts +173 -367
  3. package/dist/index.js +2449 -2934
  4. package/dist/index.mjs +2456 -2934
  5. package/dist/types/components/DataTable/context/DataTableContext.d.ts +3 -0
  6. package/dist/types/components/DataTable/controls/ColumnFilterMenu.d.ts +20 -0
  7. package/dist/types/components/DataTable/controls/MobileTableControls.d.ts +1 -1
  8. package/dist/types/components/DataTable/controls/TableControls.d.ts +1 -3
  9. package/dist/types/components/DataTable/controls/TableFilterTags.d.ts +10 -1
  10. package/dist/types/components/DataTable/display/DataDisplay.d.ts +1 -1
  11. package/dist/types/components/DataTable/display/TableCardContainer.d.ts +5 -5
  12. package/dist/types/components/DataTable/hooks/useResponsiveColumnVisibility.d.ts +1 -1
  13. package/dist/types/components/DataTable/useDataTableServer.d.ts +1 -1
  14. package/dist/types/components/DataTable/utils/selectors.d.ts +1 -1
  15. package/dist/types/components/DatePicker/Calendar.d.ts +2 -0
  16. package/dist/types/components/DatePicker/DatePicker.d.ts +27 -0
  17. package/dist/types/components/DatePicker/DateTimePicker.d.ts +20 -4
  18. package/dist/types/components/DatePicker/UniversalPicker.d.ts +2 -3
  19. package/dist/types/components/DatePicker/index.d.ts +1 -2
  20. package/dist/types/components/Form/SchemaFormContext.d.ts +6 -35
  21. package/dist/types/components/Form/components/core/FormRoot.d.ts +31 -27
  22. package/dist/types/components/Form/components/fields/FilePicker.d.ts +1 -1
  23. package/dist/types/components/Form/components/fields/StringInputField.d.ts +0 -25
  24. package/dist/types/components/Form/components/fields/useIdPickerData.d.ts +7 -4
  25. package/dist/types/components/Form/components/types/CustomJSONSchema7.d.ts +75 -34
  26. package/dist/types/components/Form/components/viewers/EnumViewer.d.ts +1 -1
  27. package/dist/types/components/Form/components/viewers/FileViewer.d.ts +7 -5
  28. package/dist/types/components/Form/useForm.d.ts +8 -16
  29. package/dist/types/components/Form/utils/ajvResolver.d.ts +4 -0
  30. package/dist/types/components/Form/utils/getNestedError.d.ts +12 -0
  31. package/dist/types/components/Form/utils/getTableData.d.ts +1 -2
  32. package/dist/types/components/Form/utils/useFormLabel.d.ts +12 -0
  33. package/dist/types/components/TextArea/TextArea.d.ts +4 -19
  34. package/dist/types/components/TimePicker/TimePicker.d.ts +9 -8
  35. package/dist/types/index.d.ts +10 -3
  36. package/package.json +10 -4
  37. package/dist/types/components/DataTable/utils/getColumns.d.ts +0 -14
  38. package/dist/types/components/DatePicker/DatePickerInput.d.ts +0 -18
  39. package/dist/types/components/DatePicker/IsoTimePicker.d.ts +0 -24
  40. package/dist/types/components/DatePicker/PickerDemo.d.ts +0 -1
  41. package/dist/types/components/Form/components/fields/TagPicker.d.ts +0 -25
  42. package/dist/types/components/Form/components/viewers/TagViewer.d.ts +0 -30
  43. package/dist/types/components/Form/utils/buildErrorMessages.d.ts +0 -223
  44. package/dist/types/components/Form/utils/getFieldError.d.ts +0 -6
  45. package/dist/types/components/Form/utils/idListSanityCheck.d.ts +0 -1
  46. package/dist/types/components/Form/utils/useFormI18n.d.ts +0 -57
  47. package/dist/types/components/ui/number-input.d.ts +0 -8
package/README.md CHANGED
@@ -1,330 +1,9 @@
1
- # React Datatable
1
+ # @bsol-oss/react-datatable5
2
2
 
3
- The datetable package is built on top of `@tanstack/react-table` and `chakra-ui` to create a datatable. This hook simplifies to initialize the state management for controlling the datatable, and it offers several predefined tables and controls in to enhance data visualization.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @tanstack/react-table @chakra-ui/react @emotion/react @bsol-oss/react-datatable5
9
- ```
10
-
11
- For form validation features with internationalization support, also install:
12
-
13
- ```bash
14
- npm install ajv ajv-formats ajv-i18n
15
- ```
16
-
17
- ## Usage
18
-
19
- ### Hook
20
-
21
- The `DataTable` and `DataTableServer` utilize hook to add props.
22
-
23
- ```tsx
24
- const datatable = useDataTable();
25
- const datatableServer = useDataTableServer({ url: '<some-url>' });
26
- ```
27
-
28
- ### DataTable
29
-
30
- ```tsx
31
- <DataTable columns={columns} data={data} {...datatable}>
32
- <DataDisplay />
33
- </DataTable>
34
- ```
35
-
36
- ### DataTableServer
37
-
38
- ```tsx
39
- <DataTableServer columns={columns} {...datatable}>
40
- <DataDisplay />
41
- </DataTableServer>
42
- ```
43
-
44
- Example Url generated by the DataTableServer
45
-
46
- ```
47
- GET http://localhost:8081/api/g/core_people?offset=0&limit=10&sorting[0][id]=id&sorting[0][desc]=false&where[0][id]=last_name&where[0][value]=nicenice&searching=good
48
- ```
49
-
50
- ### DefaultTable
51
-
52
- ```tsx
53
- <DataTable columns={columns} data={data} {...datatable}>
54
- <DefaultTable />
55
- </DataTable>
56
- ```
57
-
58
- ### TableCardContainer, TableCards, DefaultCard
59
-
60
- ```tsx
61
- <DataTable columns={columns} data={data} {...datatable}>
62
- <TableCardContainer>
63
- <TableCards<Product>
64
- renderTitle={(row) => {
65
- return (
66
- <DefaultCard
67
- {...{
68
- row: row,
69
- imageColumnId: 'thumbnail',
70
- titleColumnId: 'title',
71
- tagColumnId: 'rating',
72
- tagIcon: MdStarRate,
73
- }}
74
- />
75
- );
76
- }}
77
- />
78
- </TableCardContainer>
79
- <TablePagination />
80
- </DataTable>
81
- ```
82
-
83
- ### DataDisplay
84
-
85
- ```tsx
86
- <DataTable columns={columns} data={data} {...datatable}>
87
- <DataDisplay />
88
- </DataTable>
89
- ```
90
-
91
- ### Form Validation with AJV and Internationalization
92
-
93
- The package now includes built-in JSON Schema validation using AJV (Another JSON Schema Validator) with format support and comprehensive internationalization (i18n) capabilities, including full Traditional Chinese (Hong Kong/Taiwan) support.
94
-
95
- #### Features
96
-
97
- - **JSON Schema Validation**: Full JSON Schema Draft 7 support
98
- - **Format Validation**: Built-in support for date, time, email, UUID, and other formats via `ajv-formats`
99
- - **Multi-language Support**: Complete i18n support with Traditional Chinese (Hong Kong/Taiwan) and Simplified Chinese
100
- - **Enhanced Error Messages**: Culturally appropriate error messages in multiple languages
101
- - **Automatic Validation**: Validation occurs before form submission and confirmation
102
- - **Custom Error Display**: Collapsible error panels with localized validation feedback
103
-
104
- #### Supported Languages
105
-
106
- - **🇺🇸 English (en)** - Default language
107
- - **🇭🇰 Traditional Chinese - Hong Kong (zh-HK)** - 繁體中文(香港)
108
- - **🇹🇼 Traditional Chinese - Taiwan (zh-TW)** - 繁體中文(台灣)
109
- - **🇨🇳 Simplified Chinese (zh-CN, zh)** - 简体中文
110
-
111
- #### Basic Usage with Internationalization
112
-
113
- ```tsx
114
- import {
115
- FormRoot,
116
- FormBody,
117
- validateData,
118
- SupportedLocale,
119
- } from '@bsol-oss/react-datatable5';
120
-
121
- const schema = {
122
- type: 'object',
123
- required: ['email', 'age'],
124
- properties: {
125
- email: {
126
- type: 'string',
127
- format: 'email',
128
- },
129
- age: {
130
- type: 'integer',
131
- minimum: 18,
132
- maximum: 120,
133
- },
134
- name: {
135
- type: 'string',
136
- minLength: 2,
137
- maxLength: 50,
138
- },
139
- },
140
- };
141
-
142
- // Use Traditional Chinese (Hong Kong) for validation errors
143
- <FormRoot
144
- schema={schema}
145
- validationLocale="zh-HK"
146
- /* other props */
147
- >
148
- <FormBody />
149
- </FormRoot>;
150
- ```
151
-
152
- #### Language-specific Examples
153
-
154
- **Traditional Chinese (Hong Kong):**
155
-
156
- ```tsx
157
- <FormRoot
158
- schema={schema}
159
- validationLocale="zh-HK"
160
- /* other props */
161
- >
162
- <FormBody />
163
- </FormRoot>
164
- ```
165
-
166
- **Traditional Chinese (Taiwan):**
167
-
168
- ```tsx
169
- <FormRoot
170
- schema={schema}
171
- validationLocale="zh-TW"
172
- /* other props */
173
- >
174
- <FormBody />
175
- </FormRoot>
176
- ```
177
-
178
- **Simplified Chinese:**
179
-
180
- ```tsx
181
- <FormRoot
182
- schema={schema}
183
- validationLocale="zh-CN"
184
- /* other props */
185
- >
186
- <FormBody />
187
- </FormRoot>
188
- ```
189
-
190
- #### Manual Validation with Internationalization
191
-
192
- You can also use the validation utilities directly with language support:
193
-
194
- ```tsx
195
- import {
196
- validateData,
197
- ValidationResult,
198
- SupportedLocale,
199
- } from '@bsol-oss/react-datatable5';
200
-
201
- // Validate with Traditional Chinese (Hong Kong) error messages
202
- const result: ValidationResult = validateData(formData, schema, {
203
- locale: 'zh-HK',
204
- });
205
-
206
- if (!result.isValid) {
207
- console.log('驗證錯誤:', result.errors);
208
- // Error messages will be in Traditional Chinese
209
- }
210
-
211
- // Check supported locales
212
- import {
213
- getSupportedLocales,
214
- isLocaleSupported,
215
- } from '@bsol-oss/react-datatable5';
216
-
217
- const supportedLocales = getSupportedLocales(); // ['en', 'zh-HK', 'zh-TW', 'zh-CN', 'zh']
218
- const isSupported = isLocaleSupported('zh-HK'); // true
219
- ```
220
-
221
- #### Validation Error Structure
222
-
223
- ```tsx
224
- interface ValidationError {
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
229
- }
230
- ```
231
-
232
- #### Dynamic Language Switching
233
-
234
- ```tsx
235
- import { SupportedLocale } from '@bsol-oss/react-datatable5';
236
-
237
- const MyForm = () => {
238
- const [locale, setLocale] = useState<SupportedLocale>('zh-HK');
239
-
240
- return (
241
- <div>
242
- {/* Language selector */}
243
- <select
244
- value={locale}
245
- onChange={(e) => setLocale(e.target.value as SupportedLocale)}
246
- >
247
- <option value="en">English</option>
248
- <option value="zh-HK">繁體中文(香港)</option>
249
- <option value="zh-TW">繁體中文(台灣)</option>
250
- <option value="zh-CN">简体中文</option>
251
- </select>
252
-
253
- {/* Form with dynamic locale */}
254
- <FormRoot
255
- schema={schema}
256
- validationLocale={locale}
257
- /* other props */
258
- >
259
- <FormBody />
260
- </FormRoot>
261
- </div>
262
- );
263
- };
264
- ```
265
-
266
- #### Example Validation Messages
267
-
268
- **English:**
269
-
270
- - "email is required"
271
- - "Invalid email format"
272
- - "Must be at least 18"
273
-
274
- **Traditional Chinese (Hong Kong/Taiwan):**
275
-
276
- - "email 為必填"
277
- - "無效的 email 格式"
278
- - "必須至少為 18"
279
-
280
- **Simplified Chinese:**
281
-
282
- - "email 为必填"
283
- - "无效的 email 格式"
284
- - "必须至少为 18"
285
-
286
- #### Supported Validation Types
287
-
288
- - **Type validation**: string, number, integer, boolean, object, array
289
- - **Format validation**: email, date, time, date-time, uuid, uri, etc.
290
- - **String constraints**: minLength, maxLength, pattern (regex)
291
- - **Numeric constraints**: minimum, maximum, multipleOf
292
- - **Array constraints**: minItems, maxItems, uniqueItems
293
- - **Object constraints**: required properties, additionalProperties
294
- - **Enum validation**: restricted value sets
295
-
296
- All validation types are fully supported across all languages with culturally appropriate translations.
297
-
298
- For more details of props and examples, please review the stories in storybook platform.
3
+ A React component library built on top of `@tanstack/react-table` and `@chakra-ui/react` v3 that provides advanced data table and form components with built-in filtering, sorting, pagination, and JSON Schema validation.
299
4
 
300
5
  ## Documentation
301
6
 
302
- Additional documentation is available in the `docs/` directory:
303
-
304
- ### General Guides
305
-
306
- - **[DataTable Server Usage](./docs/DATATABLE_SERVER_USAGE.md)** - Server-side DataTable integration guide
307
- - **[DefaultForm Usage](./docs/DEFAULTFORM_USAGE.md)** - Comprehensive form component guide
308
- - **[Validation & i18n](./docs/VALIDATION_I18N.md)** - Validation and internationalization setup
309
- - **[i18n Migration Guide](./docs/I18N_MIGRATION_GUIDE.md)** - Migrate from react-i18next to label objects
310
- - **[Deployment Guide](./docs/deployment.md)** - Deployment instructions
311
-
312
- ### IdPicker Customization
313
-
314
- - **[IdPicker Quick Reference](./docs/IDPICKER_QUICK_REFERENCE.md)** - ⚡ Quick guide to IdPicker customization
315
- - **[IdPicker Custom Display](./docs/IDPICKER_CUSTOM_DISPLAY.md)** - Customize how items appear in the combobox
316
- - **[IdPicker Labels](./docs/IDPICKER_LABELS.md)** - Customize UI labels (buttons, placeholders, messages)
317
-
318
- ## Development
319
-
320
- ```
321
- npm install
322
- npm run storybook
323
- ```
324
-
325
- ## deployment
326
-
327
- ```
328
- npm version prerelease --preid=beta
329
- npm publish
330
- ```
7
+ - [Error Messages Guide](./docs/ERROR_MESSAGES_GUIDE.md) - Learn how to set custom validation error messages
8
+ - [DataTable Server Usage](./docs/DATATABLE_SERVER_USAGE.md) - Guide for server-side data tables
9
+ - [ID Picker Guide](./docs/IDPICKER_GUIDE.md) - Guide for ID picker components