@bsol-oss/react-datatable5 12.0.0-beta.9 → 12.0.0-beta.91
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 +225 -5
- package/dist/index.d.ts +896 -258
- package/dist/index.js +5157 -1630
- package/dist/index.mjs +5147 -1628
- package/dist/types/components/DataTable/DataTable.d.ts +12 -7
- package/dist/types/components/DataTable/DataTableServer.d.ts +6 -4
- package/dist/types/components/DataTable/DefaultTable.d.ts +12 -14
- package/dist/types/components/DataTable/DefaultTableServer.d.ts +23 -0
- package/dist/types/components/DataTable/context/DataTableContext.d.ts +21 -3
- package/dist/types/components/DataTable/context/useDataTableContext.d.ts +2 -2
- package/dist/types/components/DataTable/controls/DensityFeature.d.ts +3 -3
- package/dist/types/components/DataTable/controls/ReloadButton.d.ts +1 -2
- package/dist/types/components/DataTable/controls/ResetFilteringButton.d.ts +1 -4
- package/dist/types/components/DataTable/controls/ResetSelectionButton.d.ts +1 -4
- package/dist/types/components/DataTable/controls/ResetSortingButton.d.ts +1 -4
- package/dist/types/components/DataTable/controls/SelectAllRowsToggle.d.ts +1 -1
- package/dist/types/components/DataTable/controls/TableControls.d.ts +10 -2
- package/dist/types/components/DataTable/display/DataDisplay.d.ts +2 -2
- package/dist/types/components/DataTable/display/Table.d.ts +4 -3
- package/dist/types/components/DataTable/display/TableBody.d.ts +2 -3
- package/dist/types/components/DataTable/display/TableBodySkeleton.d.ts +5 -0
- package/dist/types/components/DataTable/display/TableCardContainer.d.ts +6 -3
- package/dist/types/components/DataTable/display/TableCards.d.ts +3 -3
- package/dist/types/components/DataTable/display/TableDataDisplay.d.ts +3 -1
- package/dist/types/components/DataTable/display/TableFooter.d.ts +1 -5
- package/dist/types/components/DataTable/display/TableHeader.d.ts +46 -8
- package/dist/types/components/DataTable/display/TextCell.d.ts +11 -4
- package/dist/types/components/DataTable/display/TextWithCopy.d.ts +8 -0
- package/dist/types/components/DataTable/hooks/useResponsiveColumnVisibility.d.ts +13 -0
- package/dist/types/components/DataTable/useDataTableServer.d.ts +55 -3
- package/dist/types/components/DataTable/utils/selectors.d.ts +53 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +23 -0
- package/dist/types/components/DatePicker/DatePickerInput.d.ts +18 -0
- package/dist/types/components/DatePicker/DateTimePicker.d.ts +15 -0
- package/dist/types/components/DatePicker/DurationPicker.d.ts +12 -0
- package/dist/types/components/DatePicker/IsoTimePicker.d.ts +20 -0
- package/dist/types/components/DatePicker/PickerDemo.d.ts +1 -0
- package/dist/types/components/DatePicker/RangeDatePicker.d.ts +61 -5
- package/dist/types/components/DatePicker/UniversalPicker.d.ts +9 -0
- package/dist/types/components/DatePicker/index.d.ts +8 -0
- package/dist/types/components/Filter/TagFilter.d.ts +6 -2
- package/dist/types/components/Form/SchemaFormContext.d.ts +23 -6
- package/dist/types/components/Form/components/FileDropzone.d.ts +2 -2
- package/dist/types/components/Form/components/MediaLibraryBrowser.d.ts +22 -0
- package/dist/types/components/Form/components/core/DefaultForm.d.ts +1 -0
- package/dist/types/components/Form/components/core/FormBody.d.ts +2 -1
- package/dist/types/components/Form/components/core/FormRoot.d.ts +22 -8
- package/dist/types/components/Form/components/fields/BooleanPicker.d.ts +1 -1
- package/dist/types/components/Form/components/fields/ColumnRenderer.d.ts +3 -2
- package/dist/types/components/Form/components/fields/CustomInput.d.ts +8 -0
- package/dist/types/components/Form/components/fields/DatePicker.d.ts +2 -7
- package/dist/types/components/Form/components/fields/DateRangePicker.d.ts +2 -0
- package/dist/types/components/Form/components/fields/DateTimePicker.d.ts +2 -0
- package/dist/types/components/Form/components/fields/EnumPicker.d.ts +3 -2
- package/dist/types/components/Form/components/fields/FilePicker.d.ts +18 -5
- package/dist/types/components/Form/components/fields/FormMediaLibraryBrowser.d.ts +2 -0
- package/dist/types/components/Form/components/fields/IdPicker.d.ts +1 -1
- package/dist/types/components/Form/components/fields/NumberInputField.d.ts +1 -1
- package/dist/types/components/Form/components/fields/ObjectInput.d.ts +1 -1
- package/dist/types/components/Form/components/fields/RecordInput.d.ts +1 -1
- package/dist/types/components/Form/components/fields/SchemaRenderer.d.ts +1 -1
- package/dist/types/components/Form/components/fields/StringInputField.d.ts +23 -5
- package/dist/types/components/Form/components/fields/TextAreaInput.d.ts +12 -0
- package/dist/types/components/Form/components/{DatePicker.d.ts → fields/TimePicker.d.ts} +2 -2
- package/dist/types/components/Form/components/fields/types.d.ts +6 -0
- package/dist/types/components/Form/components/types/CustomJSONSchema7.d.ts +83 -4
- package/dist/types/components/Form/components/viewers/CustomViewer.d.ts +8 -0
- package/dist/types/components/Form/components/viewers/DateTimeViewer.d.ts +7 -0
- package/dist/types/components/Form/components/viewers/NumberViewer.d.ts +1 -1
- package/dist/types/components/Form/components/viewers/SchemaViewer.d.ts +1 -1
- package/dist/types/components/Form/components/viewers/TextAreaViewer.d.ts +12 -0
- package/dist/types/components/Form/components/viewers/TimeViewer.d.ts +7 -0
- package/dist/types/components/Form/useForm.d.ts +6 -3
- package/dist/types/components/Form/utils/ajvResolver.d.ts +13 -0
- package/dist/types/components/Form/utils/buildErrorMessages.d.ts +223 -0
- package/dist/types/components/Form/utils/formatBytes.d.ts +6 -0
- package/dist/types/components/Form/utils/getFieldError.d.ts +6 -0
- package/dist/types/components/Form/utils/useFormI18n.d.ts +53 -0
- package/dist/types/components/Form/utils/validateData.d.ts +9 -0
- package/dist/types/components/TextArea/TextArea.d.ts +22 -0
- package/dist/types/components/TimePicker/TimePicker.d.ts +24 -0
- package/dist/types/components/ui/field.d.ts +3 -3
- package/dist/types/index.d.ts +82 -55
- package/package.json +24 -13
- package/dist/types/components/Controls/DensityFeature.d.ts +0 -23
- package/dist/types/components/Controls/DensityToggleButton.d.ts +0 -6
- package/dist/types/components/Controls/EditFilterButton.d.ts +0 -9
- package/dist/types/components/Controls/EditOrderButton.d.ts +0 -7
- package/dist/types/components/Controls/EditSortingButton.d.ts +0 -7
- package/dist/types/components/Controls/EditViewButton.d.ts +0 -7
- package/dist/types/components/Controls/FilterDialog.d.ts +0 -5
- package/dist/types/components/Controls/PageSizeControl.d.ts +0 -4
- package/dist/types/components/Controls/Pagination.d.ts +0 -1
- package/dist/types/components/Controls/ResetFilteringButton.d.ts +0 -4
- package/dist/types/components/Controls/ResetSelectionButton.d.ts +0 -4
- package/dist/types/components/Controls/ResetSortingButton.d.ts +0 -4
- package/dist/types/components/Controls/RowCountText.d.ts +0 -1
- package/dist/types/components/Controls/SelectAllRowsToggle.d.ts +0 -8
- package/dist/types/components/Controls/TablePagination.d.ts +0 -1
- package/dist/types/components/Controls/ViewDialog.d.ts +0 -5
- package/dist/types/components/DataTable/CardHeader.d.ts +0 -13
- package/dist/types/components/DataTable/DataDisplay.d.ts +0 -6
- package/dist/types/components/DataTable/ReloadButton.d.ts +0 -5
- package/dist/types/components/DataTable/Table.d.ts +0 -10
- package/dist/types/components/DataTable/TableBody.d.ts +0 -21
- package/dist/types/components/DataTable/TableCardContainer.d.ts +0 -7
- package/dist/types/components/DataTable/TableCards.d.ts +0 -11
- package/dist/types/components/DataTable/TableComponent.d.ts +0 -6
- package/dist/types/components/DataTable/TableControls.d.ts +0 -21
- package/dist/types/components/DataTable/TableFilter.d.ts +0 -1
- package/dist/types/components/DataTable/TableFilterTags.d.ts +0 -1
- package/dist/types/components/DataTable/TableFilters.d.ts +0 -1
- package/dist/types/components/DataTable/TableFooter.d.ts +0 -9
- package/dist/types/components/DataTable/TableHeader.d.ts +0 -13
- package/dist/types/components/DataTable/TableLoadingComponent.d.ts +0 -5
- package/dist/types/components/DataTable/TableOrderer.d.ts +0 -1
- package/dist/types/components/DataTable/TableSelector.d.ts +0 -1
- package/dist/types/components/DataTable/TableSorter.d.ts +0 -1
- package/dist/types/components/DataTable/TableViewer.d.ts +0 -1
- package/dist/types/components/DataTable/TextCell.d.ts +0 -10
- package/dist/types/components/DataTable/components/EmptyState.d.ts +0 -5
- package/dist/types/components/DataTable/components/ErrorAlert.d.ts +0 -4
- package/dist/types/components/DataTable/components/RecordDisplay.d.ts +0 -9
- package/dist/types/components/DataTable/components/TextCell.d.ts +0 -10
- package/dist/types/components/Filter/DateRangeFilter.d.ts +0 -9
- package/dist/types/components/Filter/FilterOptions.d.ts +0 -4
- package/dist/types/components/Form/Form.d.ts +0 -36
- package/dist/types/components/Form/components/ArrayRenderer.d.ts +0 -7
- package/dist/types/components/Form/components/BooleanPicker.d.ts +0 -7
- package/dist/types/components/Form/components/ColumnRenderer.d.ts +0 -7
- package/dist/types/components/Form/components/EnumPicker.d.ts +0 -8
- package/dist/types/components/Form/components/FilePicker.d.ts +0 -5
- package/dist/types/components/Form/components/IdPicker.d.ts +0 -8
- package/dist/types/components/Form/components/IdViewer.d.ts +0 -5
- package/dist/types/components/Form/components/NumberInputField.d.ts +0 -7
- package/dist/types/components/Form/components/ObjectInput.d.ts +0 -7
- package/dist/types/components/Form/components/RecordInput.d.ts +0 -7
- package/dist/types/components/Form/components/SchemaRenderer.d.ts +0 -7
- package/dist/types/components/Form/components/StringInputField.d.ts +0 -20
- package/dist/types/components/Form/components/TagPicker.d.ts +0 -30
- package/dist/types/components/ui/popover.d.ts +0 -17
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@ The datetable package is built on top of `@tanstack/react-table` and `chakra-ui`
|
|
|
8
8
|
npm install @tanstack/react-table @chakra-ui/react @emotion/react @bsol-oss/react-datatable5
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
For form validation features with internationalization support, also install:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install ajv ajv-formats ajv-i18n
|
|
15
|
+
```
|
|
16
|
+
|
|
11
17
|
## Usage
|
|
12
18
|
|
|
13
19
|
### Hook
|
|
@@ -16,7 +22,7 @@ The `DataTable` and `DataTableServer` utilize hook to add props.
|
|
|
16
22
|
|
|
17
23
|
```tsx
|
|
18
24
|
const datatable = useDataTable();
|
|
19
|
-
const datatableServer = useDataTableServer({ url:
|
|
25
|
+
const datatableServer = useDataTableServer({ url: '<some-url>' });
|
|
20
26
|
```
|
|
21
27
|
|
|
22
28
|
### DataTable
|
|
@@ -60,9 +66,9 @@ GET http://localhost:8081/api/g/core_people?offset=0&limit=10&sorting[0][id]=id&
|
|
|
60
66
|
<DefaultCard
|
|
61
67
|
{...{
|
|
62
68
|
row: row,
|
|
63
|
-
imageColumnId:
|
|
64
|
-
titleColumnId:
|
|
65
|
-
tagColumnId:
|
|
69
|
+
imageColumnId: 'thumbnail',
|
|
70
|
+
titleColumnId: 'title',
|
|
71
|
+
tagColumnId: 'rating',
|
|
66
72
|
tagIcon: MdStarRate,
|
|
67
73
|
}}
|
|
68
74
|
/>
|
|
@@ -82,6 +88,213 @@ GET http://localhost:8081/api/g/core_people?offset=0&limit=10&sorting[0][id]=id&
|
|
|
82
88
|
</DataTable>
|
|
83
89
|
```
|
|
84
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
|
+
|
|
85
298
|
For more details of props and examples, please review the stories in storybook platform.
|
|
86
299
|
|
|
87
300
|
## Development
|
|
@@ -89,4 +302,11 @@ For more details of props and examples, please review the stories in storybook p
|
|
|
89
302
|
```
|
|
90
303
|
npm install
|
|
91
304
|
npm run storybook
|
|
92
|
-
```
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## deployment
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
npm version prerelease --preid=beta
|
|
311
|
+
npm publish
|
|
312
|
+
```
|