@react-fabric/form 1.0.0-beta.4 → 1.0.0-beta.41
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/{src/input/ArrayInput.module.css → css/_arrayInput.css} +8 -8
- package/css/_colorPicker.css +65 -0
- package/{src/internal/Field.module.css → css/_field.css} +26 -15
- package/{src/input/File.module.css → css/_file.css} +20 -6
- package/css/styles.css +27 -0
- package/dist/cjs/builder/FileField.js +37 -25
- package/dist/cjs/builder/FormField.js +44 -34
- package/dist/cjs/builder/SchemaEditor.js +72 -0
- package/dist/cjs/builder/components/AddSchemaFields.js +62 -0
- package/dist/cjs/builder/components/SchemaArrayForm.js +143 -0
- package/dist/cjs/builder/components/SchemaField.js +413 -0
- package/dist/cjs/form/Controller.js +1 -1
- package/dist/cjs/form/Form.js +19 -10
- package/dist/cjs/hooks/useFormBuilder.js +27 -15
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/input/ArrayInput.js +36 -25
- package/dist/cjs/input/AvatarInput.js +1 -1
- package/dist/cjs/input/Checkbox.js +5 -4
- package/dist/cjs/input/ColorInput.js +70 -28
- package/dist/cjs/input/ColorPicker.js +1 -35
- package/dist/cjs/input/DateInput.js +183 -0
- package/dist/cjs/input/Field.js +4 -4
- package/dist/cjs/input/File.js +2 -3
- package/dist/cjs/input/Hidden.js +3 -1
- package/dist/cjs/input/Input.js +1 -1
- package/dist/cjs/input/Number.js +1 -1
- package/dist/cjs/input/Password.js +1 -1
- package/dist/cjs/input/Radio.js +1 -1
- package/dist/cjs/input/RadioGroup.js +6 -3
- package/dist/cjs/input/{Range.js → RangeSlider.js} +3 -3
- package/dist/cjs/input/Search.js +1 -1
- package/dist/cjs/input/Slider.js +1 -1
- package/dist/cjs/input/Switch.js +27 -5
- package/dist/cjs/input/Textarea.js +7 -3
- package/dist/cjs/internal/ErrorIcon.js +1 -1
- package/dist/cjs/internal/FieldWrapper.js +4 -3
- package/dist/cjs/internal/InputWrapper.js +14 -16
- package/dist/cjs/select/AutoComplete.js +9 -6
- package/dist/cjs/select/List.js +41 -20
- package/dist/cjs/select/Options.js +2 -2
- package/dist/cjs/select/Select.js +15 -9
- package/dist/cjs/select/useSelect.js +15 -8
- package/{src/input/ColorPicker.module.css → dist/cjs/types/schema.js} +18 -27
- package/dist/cjs/utils/getColor.js +6 -0
- package/dist/esm/builder/FileField.js +39 -27
- package/dist/esm/builder/FormField.js +44 -34
- package/dist/esm/builder/SchemaEditor.js +72 -0
- package/dist/esm/builder/components/AddSchemaFields.js +62 -0
- package/dist/esm/builder/components/SchemaArrayForm.js +143 -0
- package/dist/esm/builder/components/SchemaField.js +413 -0
- package/dist/esm/form/Controller.js +1 -1
- package/dist/esm/form/Form.js +19 -10
- package/dist/esm/hooks/useFormBuilder.js +25 -13
- package/dist/esm/index.js +4 -1
- package/dist/esm/input/ArrayInput.js +38 -27
- package/dist/esm/input/AvatarInput.js +1 -1
- package/dist/esm/input/Checkbox.js +5 -4
- package/dist/esm/input/ColorInput.js +72 -30
- package/dist/esm/input/ColorPicker.js +1 -35
- package/dist/esm/input/DateInput.js +183 -0
- package/dist/esm/input/Field.js +5 -5
- package/dist/esm/input/File.js +2 -3
- package/dist/esm/input/Hidden.js +3 -1
- package/dist/esm/input/Input.js +1 -1
- package/dist/esm/input/Number.js +1 -1
- package/dist/esm/input/Password.js +1 -1
- package/dist/esm/input/Radio.js +1 -1
- package/dist/esm/input/RadioGroup.js +7 -4
- package/dist/esm/input/{Range.js → RangeSlider.js} +3 -3
- package/dist/esm/input/Search.js +1 -1
- package/dist/esm/input/Slider.js +1 -1
- package/dist/esm/input/Switch.js +29 -7
- package/dist/esm/input/Textarea.js +7 -3
- package/dist/esm/internal/ErrorIcon.js +1 -1
- package/dist/esm/internal/FieldWrapper.js +4 -3
- package/dist/esm/internal/InputWrapper.js +14 -16
- package/dist/esm/select/AutoComplete.js +9 -6
- package/dist/esm/select/List.js +42 -21
- package/dist/esm/select/Options.js +2 -2
- package/dist/esm/select/Select.js +15 -9
- package/dist/esm/select/useSelect.js +16 -9
- package/dist/esm/types/schema.js +41 -0
- package/dist/esm/utils/getColor.js +6 -1
- package/dist/types/builder/FileField.d.ts +4 -2
- package/dist/types/builder/FormField.d.ts +3 -1
- package/dist/types/builder/SchemaEditor.d.ts +2 -0
- package/dist/types/builder/components/AddSchemaFields.d.ts +2 -0
- package/dist/types/builder/components/SchemaArrayForm.d.ts +2 -0
- package/dist/types/builder/components/SchemaField.d.ts +10 -0
- package/dist/types/form/Controller.d.ts +1 -1
- package/dist/types/hooks/useFormBuilder.d.ts +3 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/input/ArrayInput.d.ts +20 -3
- package/dist/types/input/Checkbox.d.ts +4 -3
- package/dist/types/input/ColorInput.d.ts +1 -1
- package/dist/types/input/DateInput.d.ts +19 -0
- package/dist/types/input/RadioGroup.d.ts +18 -2
- package/dist/types/input/{Range.d.ts → RangeSlider.d.ts} +1 -1
- package/dist/types/input/Switch.d.ts +7 -3
- package/dist/types/input/Textarea.d.ts +5 -1
- package/dist/types/internal/InputWrapper.d.ts +1 -1
- package/dist/types/select/AutoComplete.d.ts +1 -1
- package/dist/types/select/List.d.ts +1 -1
- package/dist/types/select/Select.d.ts +1 -1
- package/dist/types/select/useSelect.d.ts +2 -1
- package/dist/types/types/index.d.ts +17 -5
- package/dist/types/types/schema.d.ts +79 -33
- package/package.json +10 -7
- package/src/builder/FileField.tsx +53 -27
- package/src/builder/FormField.tsx +45 -32
- package/src/builder/SchemaEditor.tsx +72 -0
- package/src/builder/components/AddSchemaFields.tsx +74 -0
- package/src/builder/components/SchemaArrayForm.tsx +158 -0
- package/src/builder/components/SchemaField.tsx +435 -0
- package/src/form/Controller.tsx +2 -2
- package/src/form/Form.tsx +15 -8
- package/src/hooks/useFormBuilder.tsx +29 -15
- package/src/index.ts +10 -2
- package/src/input/ArrayInput.tsx +80 -42
- package/src/input/AvatarInput.tsx +1 -1
- package/src/input/Checkbox.tsx +5 -4
- package/src/input/ColorInput.tsx +102 -34
- package/src/input/ColorPicker.tsx +1 -35
- package/src/input/DateInput.tsx +248 -0
- package/src/input/Field.tsx +9 -11
- package/src/input/File.tsx +3 -6
- package/src/input/Hidden.tsx +4 -1
- package/src/input/Input.tsx +2 -2
- package/src/input/Number.tsx +2 -2
- package/src/input/Password.tsx +2 -2
- package/src/input/Radio.tsx +1 -1
- package/src/input/RadioGroup.tsx +27 -4
- package/src/input/{Range.tsx → RangeSlider.tsx} +2 -2
- package/src/input/Search.tsx +2 -2
- package/src/input/Slider.tsx +1 -1
- package/src/input/Switch.tsx +42 -6
- package/src/input/Textarea.tsx +11 -3
- package/src/internal/ErrorIcon.tsx +1 -1
- package/src/internal/FieldWrapper.tsx +3 -3
- package/src/internal/InputWrapper.tsx +21 -20
- package/src/select/AutoComplete.tsx +4 -1
- package/src/select/List.tsx +37 -8
- package/src/select/Options.tsx +1 -1
- package/src/select/Select.tsx +9 -3
- package/src/select/useSelect.tsx +30 -19
- package/src/types/index.ts +22 -7
- package/src/types/schema.ts +96 -41
- package/dist/cjs/input/ArrayInput.module.css +0 -1
- package/dist/cjs/input/ColorPicker.module.css +0 -1
- package/dist/cjs/input/File.module.css +0 -1
- package/dist/cjs/internal/Field.module.css +0 -1
- package/dist/esm/input/ArrayInput.module.css +0 -1
- package/dist/esm/input/ColorPicker.module.css +0 -1
- package/dist/esm/input/File.module.css +0 -1
- package/dist/esm/internal/Field.module.css +0 -1
|
@@ -4,7 +4,7 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
4
4
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
6
|
import { useDebounce } from '@react-fabric/core';
|
|
7
|
-
import { matchString, dedupe, groupBy, isArray, EMPTY_ARRAY } from '@react-fabric/utilities';
|
|
7
|
+
import { matchString, isString, dedupe, compareValues, groupBy, isArray, EMPTY_ARRAY } from '@react-fabric/utilities';
|
|
8
8
|
import { useMemo, useDeferredValue, useRef, useCallback, useReducer, useEffect } from 'react';
|
|
9
9
|
import { getSelectedValue, makeOption } from './helpers.js';
|
|
10
10
|
|
|
@@ -14,6 +14,8 @@ var useSelect = function useSelect(_ref) {
|
|
|
14
14
|
var _ref$options = _ref.options,
|
|
15
15
|
options = _ref$options === void 0 ? EMPTY_ARRAY : _ref$options,
|
|
16
16
|
value = _ref.value,
|
|
17
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
18
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
17
19
|
autoComplete = _ref.autoComplete,
|
|
18
20
|
_ref$multiple = _ref.multiple,
|
|
19
21
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
@@ -88,7 +90,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
88
90
|
if (action.value !== undefined) {
|
|
89
91
|
if (multiple) {
|
|
90
92
|
var values = [];
|
|
91
|
-
if (action.value
|
|
93
|
+
if (isString(action.value)) values.push.apply(values, _toConsumableArray(action.value.split(/,\s?/)));else values.push(action.value);
|
|
92
94
|
newState.value = _toConsumableArray(state.value);
|
|
93
95
|
values.forEach(function (value) {
|
|
94
96
|
var _newState$value$inclu, _newState$value;
|
|
@@ -133,13 +135,14 @@ var useSelect = function useSelect(_ref) {
|
|
|
133
135
|
if (autoComplete && action.query !== undefined) {
|
|
134
136
|
optionList = dedupe([action.query].concat(_toConsumableArray(optionList)));
|
|
135
137
|
}
|
|
138
|
+
optionList = optionList.sort(compareValues("asc", labelProperty));
|
|
136
139
|
var grouped = groupBy(optionList, groupProperty, "");
|
|
137
140
|
if (action.open) _newState.open = true;
|
|
138
141
|
_newState.items = [];
|
|
139
142
|
// add new item if allowCreate
|
|
140
143
|
if (allowCreate && action.query) _newState.items.push({
|
|
141
144
|
___create___: true,
|
|
142
|
-
value:
|
|
145
|
+
value: action.query
|
|
143
146
|
});
|
|
144
147
|
Object.entries(grouped).forEach(function (_ref2) {
|
|
145
148
|
var _newState$items;
|
|
@@ -169,7 +172,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
169
172
|
}, {
|
|
170
173
|
multiple: multiple,
|
|
171
174
|
emptyValue: emptyValue,
|
|
172
|
-
open:
|
|
175
|
+
open: defaultOpen,
|
|
173
176
|
loading: false,
|
|
174
177
|
activeIndex: null,
|
|
175
178
|
selectedIndex: null,
|
|
@@ -201,22 +204,22 @@ var useSelect = function useSelect(_ref) {
|
|
|
201
204
|
});
|
|
202
205
|
dispatch({
|
|
203
206
|
type: "setValue",
|
|
204
|
-
value: (_ref4 = hasValue !== null && hasValue !== void 0 ? hasValue : newOption) !== null && _ref4 !== void 0 ? _ref4 :
|
|
207
|
+
value: (_ref4 = hasValue !== null && hasValue !== void 0 ? hasValue : newOption) !== null && _ref4 !== void 0 ? _ref4 : deferred
|
|
205
208
|
});
|
|
206
209
|
}
|
|
207
210
|
if (multiple) {
|
|
208
211
|
optionsRef.current = [];
|
|
209
|
-
var _value = (deferred
|
|
212
|
+
var _value = (isArray(deferred) ? deferred : []).map(function (item) {
|
|
210
213
|
var _ref5;
|
|
211
214
|
var newOption = (allowCreate || autoComplete) && item ? createOption(item) : undefined;
|
|
212
215
|
var hasValue = options.find(function (opt) {
|
|
213
216
|
var _opt$valueProperty2;
|
|
214
|
-
return ((_opt$valueProperty2 = opt[valueProperty]) !== null && _opt$valueProperty2 !== void 0 ? _opt$valueProperty2 : opt) ===
|
|
217
|
+
return ((_opt$valueProperty2 = opt[valueProperty]) !== null && _opt$valueProperty2 !== void 0 ? _opt$valueProperty2 : opt) === item;
|
|
215
218
|
});
|
|
216
219
|
if (!hasValue && newOption) {
|
|
217
220
|
optionsRef.current.push(newOption);
|
|
218
221
|
}
|
|
219
|
-
return (_ref5 = hasValue !== null && hasValue !== void 0 ? hasValue : newOption) !== null && _ref5 !== void 0 ? _ref5 :
|
|
222
|
+
return (_ref5 = hasValue !== null && hasValue !== void 0 ? hasValue : newOption) !== null && _ref5 !== void 0 ? _ref5 : item;
|
|
220
223
|
});
|
|
221
224
|
optionsRef.current = [].concat(_toConsumableArray(optionsRef.current), _toConsumableArray(options !== null && options !== void 0 ? options : []));
|
|
222
225
|
dispatch({
|
|
@@ -285,7 +288,11 @@ var useSelect = function useSelect(_ref) {
|
|
|
285
288
|
value: value !== null && value !== void 0 && value.___create___ ? value.value : value
|
|
286
289
|
});
|
|
287
290
|
if (value !== null && value !== void 0 && value.___create___) {
|
|
288
|
-
|
|
291
|
+
var val = [value.value];
|
|
292
|
+
if (multiple) {
|
|
293
|
+
val = value.value.split(/,\s?/);
|
|
294
|
+
}
|
|
295
|
+
optionsRef.current = [].concat(_toConsumableArray(optionsRef.current), _toConsumableArray(val.map(createOption)));
|
|
289
296
|
}
|
|
290
297
|
if (autoComplete) {
|
|
291
298
|
optionsRef.current = dedupe([].concat(_toConsumableArray(isArray(values) ? values : [values]), _toConsumableArray(optionsRef.current)));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* React Fabric
|
|
5
|
+
* @version: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
14
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
* subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
18
|
+
* portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
21
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
var DATA_TYPES = /*#__PURE__*/function (DATA_TYPES) {
|
|
27
|
+
DATA_TYPES["TEXT"] = "text";
|
|
28
|
+
DATA_TYPES["COLOR"] = "color";
|
|
29
|
+
DATA_TYPES["BOOL"] = "bool";
|
|
30
|
+
DATA_TYPES["DATE"] = "date";
|
|
31
|
+
DATA_TYPES["STRING"] = "string";
|
|
32
|
+
DATA_TYPES["NUMBER"] = "number";
|
|
33
|
+
DATA_TYPES["RANGE"] = "range";
|
|
34
|
+
DATA_TYPES["FILE"] = "file";
|
|
35
|
+
DATA_TYPES["AVATAR"] = "avatar";
|
|
36
|
+
DATA_TYPES["SCHEMA"] = "schema";
|
|
37
|
+
return DATA_TYPES;
|
|
38
|
+
}({});
|
|
39
|
+
var SCHEMA_CUSTOM_LIST = "--CUSTOM--";
|
|
40
|
+
|
|
41
|
+
export { DATA_TYPES, SCHEMA_CUSTOM_LIST };
|
|
@@ -35,5 +35,10 @@ var getBgClass = function getBgClass(bg) {
|
|
|
35
35
|
return "bg-".concat(bg);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var getColorClass = function getColorClass(color) {
|
|
39
|
+
if (color && !isColor(color)) {
|
|
40
|
+
return "text-".concat(color);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
38
43
|
|
|
39
|
-
export { getBgClass, getColor };
|
|
44
|
+
export { getBgClass, getColor, getColorClass };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type UploadHandler } from "../hooks/useFileUploader";
|
|
2
|
-
import { type FileSchema } from "../types/schema";
|
|
3
|
-
export declare const FileField: ({ uploadHandler, inline, label, accept, multiple,
|
|
2
|
+
import { type FileSchema, type ValueType } from "../types/schema";
|
|
3
|
+
export declare const FileField: ({ uploadHandler, inline, label, accept, value, fileUrl, multiple, invalid, error, ...rest }: Partial<FileSchema & ValueType> & {
|
|
4
4
|
value?: AnyObject;
|
|
5
5
|
inline?: boolean;
|
|
6
|
+
invalid?: boolean;
|
|
7
|
+
error?: AnyObject;
|
|
6
8
|
fileUrl?: (path: string) => string;
|
|
7
9
|
uploadHandler: UploadHandler;
|
|
8
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type UploadHandler } from "../hooks/useFileUploader";
|
|
2
|
+
import { type BaseSelectProps } from "../types";
|
|
2
3
|
import { type SchemaType } from "../types/schema";
|
|
3
|
-
export declare const FormField: ({ id, label, required, inline, prefix, autoFocus,
|
|
4
|
+
export declare const FormField: ({ id, label, required, inline, prefix, autoFocus, optionLists, fileUrl, uploadHandler, ...rest }: SchemaType & {
|
|
4
5
|
inline?: boolean;
|
|
5
6
|
prefix?: string;
|
|
6
7
|
autoFocus?: boolean;
|
|
8
|
+
optionLists?: KeyValue<BaseSelectProps<any>>;
|
|
7
9
|
fileUrl?: (path: string) => string;
|
|
8
10
|
uploadHandler?: UploadHandler;
|
|
9
11
|
}) => import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SchemaEditorProps } from "../../types/schema";
|
|
2
|
+
export declare const SchemaField: ({ id, field, fieldId, getModel, onRemove, defaultOpen, optionLists, dynamic, onTypeChange, acceptableTypes, }: {
|
|
3
|
+
id: string;
|
|
4
|
+
field: string;
|
|
5
|
+
fieldId: string;
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
onRemove: () => void;
|
|
8
|
+
getModel: () => KeyValue;
|
|
9
|
+
onTypeChange: (val: KeyValue) => void;
|
|
10
|
+
} & Omit<SchemaEditorProps, "schemaDef" | "onChange">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,7 +14,7 @@ export interface ControllerProps {
|
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
onBlur: () => void;
|
|
16
16
|
onChange: (value: AnyObject) => void;
|
|
17
|
-
|
|
17
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
18
18
|
}) => ReactElement);
|
|
19
19
|
}
|
|
20
20
|
export declare const Controller: ({ name, children, ...rest }: ControllerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { yup } from "@react-fabric/utilities";
|
|
2
|
+
import { type BaseSelectProps } from "../types";
|
|
2
3
|
import { type FormSchema } from "../types/schema";
|
|
3
4
|
import { type UploadHandler } from "./useFileUploader";
|
|
4
|
-
export declare const useFormBuilder: (schema: FormSchema
|
|
5
|
+
export declare const useFormBuilder: <T extends unknown = string>(schema: FormSchema, options?: {
|
|
5
6
|
prefix?: string;
|
|
6
7
|
inline?: boolean;
|
|
7
8
|
fileUrl?: (path: string) => string;
|
|
8
9
|
uploadHandler?: UploadHandler;
|
|
10
|
+
optionLists?: KeyValue<BaseSelectProps<T>>;
|
|
9
11
|
}) => {
|
|
10
12
|
formDef: import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
schemaDef: yup.ObjectSchema<{
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import "./i18n";
|
|
2
2
|
export { Controller } from "./form/Controller";
|
|
3
3
|
export { Form, type FormRef } from "./form/Form";
|
|
4
|
+
export { SchemaEditor } from "./builder/SchemaEditor";
|
|
4
5
|
export { useFileUploader } from "./hooks/useFileUploader";
|
|
5
6
|
export { useFormBuilder } from "./hooks/useFormBuilder";
|
|
6
|
-
export { type FormSchema } from "./types/schema";
|
|
7
|
+
export { DATA_TYPES, SCHEMA_CUSTOM_LIST, type FormSchema, type SchemaDef, } from "./types/schema";
|
|
7
8
|
export { ArrayInput } from "./input/ArrayInput";
|
|
8
9
|
export { Checkbox } from "./input/Checkbox";
|
|
9
10
|
export { ColorInput } from "./input/ColorInput";
|
|
10
11
|
export { ColorPicker } from "./input/ColorPicker";
|
|
12
|
+
export { DateInput } from "./input/DateInput";
|
|
11
13
|
export { Field } from "./input/Field";
|
|
12
14
|
export { FileInput } from "./input/File";
|
|
13
15
|
export { HiddenInput } from "./input/Hidden";
|
|
@@ -16,7 +18,7 @@ export { Number } from "./input/Number";
|
|
|
16
18
|
export { Password } from "./input/Password";
|
|
17
19
|
export { Radio } from "./input/Radio";
|
|
18
20
|
export { RadioGroup } from "./input/RadioGroup";
|
|
19
|
-
export {
|
|
21
|
+
export { RangeSlider } from "./input/RangeSlider";
|
|
20
22
|
export { Search } from "./input/Search";
|
|
21
23
|
export { Slider } from "./input/Slider";
|
|
22
24
|
export { Switch } from "./input/Switch";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode, type
|
|
1
|
+
import { type ReactNode, type Ref } from "react";
|
|
2
2
|
export interface ArrayInputProps {
|
|
3
3
|
/**
|
|
4
4
|
* input label
|
|
@@ -32,6 +32,10 @@ export interface ArrayInputProps {
|
|
|
32
32
|
* minimum required length
|
|
33
33
|
*/
|
|
34
34
|
minItems?: number;
|
|
35
|
+
/**
|
|
36
|
+
* maximum length
|
|
37
|
+
*/
|
|
38
|
+
maxItems?: number;
|
|
35
39
|
/**
|
|
36
40
|
* field name to focus on add
|
|
37
41
|
*/
|
|
@@ -48,11 +52,12 @@ export interface ArrayInputProps {
|
|
|
48
52
|
* add item button label
|
|
49
53
|
*/
|
|
50
54
|
addLabel?: string;
|
|
55
|
+
buttonPosition?: "top" | "bottom" | "both";
|
|
51
56
|
/**
|
|
52
57
|
* fixed length list
|
|
53
58
|
*/
|
|
54
59
|
fixedList?: boolean;
|
|
55
|
-
arrayRef?:
|
|
60
|
+
arrayRef?: Ref<{
|
|
56
61
|
addItem: (item: AnyObject) => void;
|
|
57
62
|
removeItem: (idx: number) => void;
|
|
58
63
|
}>;
|
|
@@ -60,5 +65,17 @@ export interface ArrayInputProps {
|
|
|
60
65
|
* Add item
|
|
61
66
|
*/
|
|
62
67
|
onAdd?: () => AnyObject;
|
|
68
|
+
/**
|
|
69
|
+
* field width
|
|
70
|
+
*/
|
|
71
|
+
width?: number | string;
|
|
72
|
+
/**
|
|
73
|
+
* inline label and input
|
|
74
|
+
*/
|
|
75
|
+
inline?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* label width for inline
|
|
78
|
+
*/
|
|
79
|
+
labelWidth?: string;
|
|
63
80
|
}
|
|
64
|
-
export declare const ArrayInput: ({ name, children, addLabel, fixedList, focusName, onAdd, arrayRef, enableSorting, disabled, readOnly, minItems, ...rest }: ArrayInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
export declare const ArrayInput: ({ name, children, addLabel, fixedList, focusName, buttonPosition, onAdd, arrayRef, enableSorting, disabled, readOnly, minItems, maxItems, ...rest }: ArrayInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
3
|
-
|
|
3
|
+
interface CheckboxProps extends RefProp<HTMLInputElement> {
|
|
4
4
|
/**
|
|
5
5
|
* checkbox label
|
|
6
6
|
*/
|
|
@@ -16,7 +16,7 @@ export interface CheckboxProps extends RefProp<HTMLInputElement> {
|
|
|
16
16
|
/**
|
|
17
17
|
* on checked change
|
|
18
18
|
*/
|
|
19
|
-
onChange?: (checked: boolean
|
|
19
|
+
onChange?: (checked: boolean) => void;
|
|
20
20
|
/**
|
|
21
21
|
* disabled input
|
|
22
22
|
*/
|
|
@@ -43,4 +43,5 @@ export interface CheckboxProps extends RefProp<HTMLInputElement> {
|
|
|
43
43
|
iconChecked?: string;
|
|
44
44
|
name?: string;
|
|
45
45
|
}
|
|
46
|
-
export declare const Checkbox: ({ ref, label, value, name, checked, invalid, disabled, error, width, icon, iconChecked, onChange, ...rest }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const Checkbox: ({ ref, label, value, name, checked, invalid, disabled, error, width, icon, iconChecked, required, onChange, ...rest }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
2
2
|
import { type InputProps } from "../types";
|
|
3
3
|
import { type ColorProps } from "./ColorPicker";
|
|
4
|
-
export interface ColorInputProps extends InputProps, ColorProps, RefProp {
|
|
4
|
+
export interface ColorInputProps extends InputProps, Omit<ColorProps, "onChange">, RefProp {
|
|
5
5
|
/**
|
|
6
6
|
* show eydrop picker
|
|
7
7
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
2
|
+
import { type DateLike } from "@react-fabric/date";
|
|
3
|
+
import { type InputProps } from "../types";
|
|
4
|
+
export interface DateProps extends InputProps<string>, RefProp<HTMLInputElement> {
|
|
5
|
+
type?: "date" | "datetime";
|
|
6
|
+
/**
|
|
7
|
+
* date format
|
|
8
|
+
*/
|
|
9
|
+
format?: string;
|
|
10
|
+
/**
|
|
11
|
+
* minimum value
|
|
12
|
+
*/
|
|
13
|
+
min?: DateLike;
|
|
14
|
+
/**
|
|
15
|
+
* maximum value
|
|
16
|
+
*/
|
|
17
|
+
max?: DateLike;
|
|
18
|
+
}
|
|
19
|
+
export declare const DateInput: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, type, onChange, onEnterPressed, format, min, max, ...rest }: DateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type
|
|
2
|
+
import { type ChildrenProp, type CssProp } from "@react-fabric/core/dist/types/types";
|
|
3
3
|
import { type Radio } from "./Radio";
|
|
4
4
|
export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
5
5
|
/**
|
|
@@ -14,6 +14,22 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
14
14
|
* field info
|
|
15
15
|
*/
|
|
16
16
|
info?: string;
|
|
17
|
+
/**
|
|
18
|
+
* field width
|
|
19
|
+
*/
|
|
20
|
+
width?: number | string;
|
|
21
|
+
/**
|
|
22
|
+
* inline label and input
|
|
23
|
+
*/
|
|
24
|
+
inline?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* label width for inline
|
|
27
|
+
*/
|
|
28
|
+
labelWidth?: string;
|
|
29
|
+
/**
|
|
30
|
+
* label width for inline
|
|
31
|
+
*/
|
|
32
|
+
optionWidth?: string;
|
|
17
33
|
/**
|
|
18
34
|
* field name
|
|
19
35
|
*/
|
|
@@ -27,4 +43,4 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
27
43
|
*/
|
|
28
44
|
onChange?: (value: AnyObject) => void;
|
|
29
45
|
}
|
|
30
|
-
export declare const RadioGroup: ({ children, name, className, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const RadioGroup: ({ children, name, className, optionWidth, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -56,4 +56,4 @@ export interface RangeProps extends Omit<InputProps<[number, number]>, "placehol
|
|
|
56
56
|
/**
|
|
57
57
|
* Number Range input
|
|
58
58
|
*/
|
|
59
|
-
export declare const
|
|
59
|
+
export declare const RangeSlider: ({ error, name, value, step, min, max, height, color, vertical, showLabels, showValue, minLabel, maxLabel, ranges, format, autoFocus, disabled, readOnly, onBlur, onChange, onEnterPressed, onFocus, onSlide, invalid, ...rest }: RangeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -32,11 +32,15 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
|
32
32
|
/**
|
|
33
33
|
* cutom Switch icon
|
|
34
34
|
*/
|
|
35
|
-
color?: ColorType;
|
|
35
|
+
color?: string | ColorType;
|
|
36
36
|
/**
|
|
37
37
|
* cutom Switch icon
|
|
38
38
|
*/
|
|
39
|
-
defaultColor?: ColorType;
|
|
39
|
+
defaultColor?: string | ColorType;
|
|
40
40
|
name?: string;
|
|
41
|
+
onLabel?: string;
|
|
42
|
+
onLabelColor?: string | ColorType;
|
|
43
|
+
offLabel?: string;
|
|
44
|
+
offLabelColor?: string | ColorType;
|
|
41
45
|
}
|
|
42
|
-
export declare const Switch: ({ ref, label, checked, invalid, disabled, error, width, color, name, defaultColor, onChange, ...rest }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const Switch: ({ ref, label, checked, invalid, disabled, error, width, color, name, onLabel, offLabel, onLabelColor, offLabelColor, defaultColor, required, onChange, ...rest }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,5 +13,9 @@ export interface TextareaProps extends InputProps, RefProp<HTMLTextAreaElement>
|
|
|
13
13
|
* increment rows on value change
|
|
14
14
|
*/
|
|
15
15
|
variableRows?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* expandable textarea
|
|
18
|
+
*/
|
|
19
|
+
expandable?: boolean;
|
|
16
20
|
}
|
|
17
|
-
export declare const Textarea: ({ ref, value, name, invalid, readOnly, disabled, required, placeholder, autoFocus, rows, maxRows, variableRows, onChange, onEnterPressed, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const Textarea: ({ ref, value, name, invalid, readOnly, disabled, required, placeholder, autoFocus, rows, maxRows, variableRows, expandable, onChange, onEnterPressed, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const InputWrapper: ({ invalid, error, allowClear, showClear, decorateStart, decorateEnd, children, onClear, noOutline, noBorder, textarea, "data-inner": isInner, "data-open": isOpen, floatingExpand, wrapperRef, width, ...rest }: KeyValue) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare const InputWrapper: ({ invalid, error, allowClear, showClear, decorateStart, decorateEnd, decorateEndShowWhenEmpty, decorateEndHideWhenEmpty, children, onClear, noOutline, noBorder, textarea, textareaExpandable, "data-inner": isInner, "data-open": isOpen, floatingExpand, wrapperRef, width, ...rest }: KeyValue) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,5 +13,5 @@ type AutoCompleteProps = Omit<SelectProps<string>, "options" | "allowCreate" | "
|
|
|
13
13
|
*/
|
|
14
14
|
onInput?: (query: string) => void;
|
|
15
15
|
};
|
|
16
|
-
export declare const AutoComplete: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, expandOnEdit, error, history, multiple, onChange, onSelect, onInput, onFocus, onBlur, onEnterPressed, ...rest }: AutoCompleteProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const AutoComplete: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, expandOnEdit, error, history, multiple, onChange, onSelect, onInput, onFocus, onBlur, onQuery, onEnterPressed, ...rest }: AutoCompleteProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type SelectProps } from "../types";
|
|
2
|
-
export declare const List: <T extends unknown = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, multiple, allowCreate, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: SelectProps<T> & {
|
|
2
|
+
export declare const List: <T extends unknown = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: Omit<SelectProps<T>, "defaultOpen" | "hideHandle"> & {
|
|
3
3
|
height?: string | number;
|
|
4
4
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type SelectProps } from "../types";
|
|
2
|
-
export declare const Select: <T extends unknown = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, groupProperty, labelProperty, valueProperty, multiple, searchable, allowCreate, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Select: <T extends unknown = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, defaultOpen, hideHandle, groupProperty, labelProperty, valueProperty, multiple, searchable, allowCreate, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,10 +10,11 @@ interface State {
|
|
|
10
10
|
query?: string;
|
|
11
11
|
items: AnyObject[];
|
|
12
12
|
}
|
|
13
|
-
export declare const useSelect: ({ options, value, autoComplete, multiple, allowCreate, groupProperty, valueProperty, labelProperty, createOption, matcher, onQuery, onChange, onSelect, }: {
|
|
13
|
+
export declare const useSelect: ({ options, value, defaultOpen, autoComplete, multiple, allowCreate, groupProperty, valueProperty, labelProperty, createOption, matcher, onQuery, onChange, onSelect, }: {
|
|
14
14
|
value?: AnyObject;
|
|
15
15
|
options?: AnyObject[];
|
|
16
16
|
multiple?: boolean;
|
|
17
|
+
defaultOpen?: boolean;
|
|
17
18
|
allowCreate?: boolean;
|
|
18
19
|
groupProperty?: AnyObject;
|
|
19
20
|
valueProperty?: AnyObject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
3
|
-
export interface InputProps<V = string> {
|
|
2
|
+
import { type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
|
+
export interface InputProps<V = string> extends TestProps {
|
|
4
4
|
/**
|
|
5
5
|
* value
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ export interface InputProps<V = string> {
|
|
|
8
8
|
/**
|
|
9
9
|
* change handler
|
|
10
10
|
*/
|
|
11
|
-
onChange?: (value
|
|
11
|
+
onChange?: (value: V | null) => void;
|
|
12
12
|
/**
|
|
13
13
|
* on focus event handler
|
|
14
14
|
*/
|
|
@@ -45,6 +45,8 @@ export interface InputProps<V = string> {
|
|
|
45
45
|
*
|
|
46
46
|
*/
|
|
47
47
|
decorateEnd?: JSX.Element | string | number | boolean;
|
|
48
|
+
decorateEndShowWhenEmpty?: boolean;
|
|
49
|
+
decorateEndHideWhenEmpty?: boolean;
|
|
48
50
|
/**
|
|
49
51
|
* info label at bottom
|
|
50
52
|
*/
|
|
@@ -90,7 +92,15 @@ export interface InputProps<V = string> {
|
|
|
90
92
|
*/
|
|
91
93
|
labelWidth?: string;
|
|
92
94
|
}
|
|
93
|
-
export interface BaseSelectProps<T
|
|
95
|
+
export interface BaseSelectProps<T extends AnyObject = string> {
|
|
96
|
+
/**
|
|
97
|
+
* open dropdown by default
|
|
98
|
+
*/
|
|
99
|
+
defaultOpen?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* hide dropdown handle
|
|
102
|
+
*/
|
|
103
|
+
hideHandle?: boolean;
|
|
94
104
|
/**
|
|
95
105
|
* list options
|
|
96
106
|
*/
|
|
@@ -132,7 +142,8 @@ export interface BaseSelectProps<T> extends RefProp<HTMLInputElement>, Omit<Inpu
|
|
|
132
142
|
*/
|
|
133
143
|
matcher?: (option: T, query: string) => boolean;
|
|
134
144
|
}
|
|
135
|
-
|
|
145
|
+
type BaseSelectType<T> = BaseSelectProps<T> & RefProp<HTMLInputElement> & Omit<InputProps, "value" | "onChange">;
|
|
146
|
+
export type SelectProps<T> = BaseSelectType<T> & ({
|
|
136
147
|
/**
|
|
137
148
|
* is multiple selection
|
|
138
149
|
*/
|
|
@@ -167,3 +178,4 @@ export type SelectProps<T> = BaseSelectProps<T> & ({
|
|
|
167
178
|
*/
|
|
168
179
|
onChange?: (value?: string[]) => void;
|
|
169
180
|
});
|
|
181
|
+
export {};
|