@bsol-oss/react-datatable5 11.0.0-beta.0 → 11.0.0-beta.1
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 +1 -187
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/index.mjs +1 -2
- package/dist/types/components/Form/Form.d.ts +1 -1
- package/package.json +1 -1
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
|
@@ -479,7 +479,7 @@ interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
|
479
479
|
gridRow: string;
|
|
480
480
|
foreign_key: ForeignKeyProps;
|
|
481
481
|
}
|
|
482
|
-
declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit,
|
|
482
|
+
declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
483
483
|
|
|
484
484
|
interface UseFormProps {
|
|
485
485
|
preLoadedValues?: FieldValues | undefined;
|
package/dist/index.js
CHANGED
|
@@ -4768,11 +4768,10 @@ const FormInternal = () => {
|
|
|
4768
4768
|
methods.handleSubmit(onValid)();
|
|
4769
4769
|
}, formNoValidate: true, children: translate.t("submit") })] }), isError && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["isError", jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" ", `${error}`] })] }))] }));
|
|
4770
4770
|
};
|
|
4771
|
-
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined,
|
|
4771
|
+
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
|
|
4772
4772
|
const { properties } = schema;
|
|
4773
4773
|
idListSanityCheck("order", order, properties);
|
|
4774
4774
|
idListSanityCheck("ignore", ignore, properties);
|
|
4775
|
-
idListSanityCheck("preLoadedValues", Object.keys(preLoadedValues), properties);
|
|
4776
4775
|
return (jsxRuntime.jsx(SchemaFormContext.Provider, { value: {
|
|
4777
4776
|
schema,
|
|
4778
4777
|
serverUrl,
|
package/dist/index.mjs
CHANGED
|
@@ -4748,11 +4748,10 @@ const FormInternal = () => {
|
|
|
4748
4748
|
methods.handleSubmit(onValid)();
|
|
4749
4749
|
}, formNoValidate: true, children: translate.t("submit") })] }), isError && (jsxs(Fragment, { children: ["isError", jsxs(Fragment, { children: [" ", `${error}`] })] }))] }));
|
|
4750
4750
|
};
|
|
4751
|
-
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined,
|
|
4751
|
+
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
|
|
4752
4752
|
const { properties } = schema;
|
|
4753
4753
|
idListSanityCheck("order", order, properties);
|
|
4754
4754
|
idListSanityCheck("ignore", ignore, properties);
|
|
4755
|
-
idListSanityCheck("preLoadedValues", Object.keys(preLoadedValues), properties);
|
|
4756
4755
|
return (jsx(SchemaFormContext.Provider, { value: {
|
|
4757
4756
|
schema,
|
|
4758
4757
|
serverUrl,
|
|
@@ -27,4 +27,4 @@ export interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
|
27
27
|
gridRow: string;
|
|
28
28
|
foreign_key: ForeignKeyProps;
|
|
29
29
|
}
|
|
30
|
-
export declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit,
|
|
30
|
+
export declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => import("react/jsx-runtime").JSX.Element;
|