@react-fabric/form 1.0.0-beta.55 → 1.0.0-beta.57
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/css/_field.css +1 -1
- package/dist/cjs/builder/FileField.js +2 -2
- package/dist/cjs/input/AvatarInput.js +18 -16
- package/dist/cjs/input/ColorInput.js +6 -3
- package/dist/cjs/input/DateInput.js +6 -4
- package/dist/cjs/input/Hidden.js +4 -3
- package/dist/cjs/input/Input.js +6 -4
- package/dist/cjs/input/Number.js +6 -4
- package/dist/cjs/input/Password.js +6 -4
- package/dist/cjs/input/Search.js +6 -4
- package/dist/cjs/input/Slider.js +2 -2
- package/dist/cjs/input/Textarea.js +7 -5
- package/dist/cjs/select/AutoComplete.js +1 -2
- package/dist/cjs/select/List.js +5 -2
- package/dist/cjs/select/Options.js +49 -42
- package/dist/cjs/select/Select.js +4 -2
- package/dist/cjs/select/useSelect.js +14 -7
- package/dist/esm/builder/FileField.js +3 -3
- package/dist/esm/input/AvatarInput.js +19 -17
- package/dist/esm/input/ColorInput.js +6 -3
- package/dist/esm/input/DateInput.js +6 -4
- package/dist/esm/input/Hidden.js +4 -3
- package/dist/esm/input/Input.js +6 -4
- package/dist/esm/input/Number.js +6 -4
- package/dist/esm/input/Password.js +6 -4
- package/dist/esm/input/Search.js +6 -4
- package/dist/esm/input/Slider.js +2 -2
- package/dist/esm/input/Textarea.js +7 -5
- package/dist/esm/select/AutoComplete.js +1 -2
- package/dist/esm/select/List.js +5 -2
- package/dist/esm/select/Options.js +49 -42
- package/dist/esm/select/Select.js +4 -2
- package/dist/esm/select/useSelect.js +14 -7
- package/dist/types/input/AvatarInput.d.ts +5 -1
- package/dist/types/input/DateInput.d.ts +1 -1
- package/dist/types/input/Hidden.d.ts +5 -1
- package/dist/types/input/Input.d.ts +1 -1
- package/dist/types/input/Number.d.ts +1 -1
- package/dist/types/input/Password.d.ts +1 -1
- package/dist/types/input/RangeSlider.d.ts +1 -1
- package/dist/types/input/Search.d.ts +1 -1
- package/dist/types/input/Slider.d.ts +1 -1
- package/dist/types/input/Textarea.d.ts +1 -1
- package/dist/types/select/List.d.ts +1 -1
- package/dist/types/select/Options.d.ts +2 -1
- package/dist/types/select/Select.d.ts +1 -1
- package/dist/types/select/useSelect.d.ts +4 -1
- package/dist/types/types/index.d.ts +8 -0
- package/package.json +4 -4
- package/src/builder/FileField.tsx +9 -3
- package/src/input/AvatarInput.tsx +23 -11
- package/src/input/ColorInput.tsx +6 -3
- package/src/input/DateInput.tsx +4 -3
- package/src/input/Hidden.tsx +9 -5
- package/src/input/Input.tsx +4 -3
- package/src/input/Number.tsx +4 -3
- package/src/input/Password.tsx +4 -3
- package/src/input/RangeSlider.tsx +1 -1
- package/src/input/Search.tsx +4 -3
- package/src/input/Slider.tsx +8 -5
- package/src/input/Textarea.tsx +5 -4
- package/src/select/AutoComplete.tsx +1 -1
- package/src/select/List.tsx +3 -0
- package/src/select/Options.tsx +47 -43
- package/src/select/Select.tsx +2 -0
- package/src/select/useSelect.tsx +15 -6
- package/src/types/index.ts +8 -0
|
@@ -7,7 +7,7 @@ import classNames from 'classnames';
|
|
|
7
7
|
import { Trans } from 'react-i18next';
|
|
8
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
|
-
var _excluded = ["ref", "style", "items", "active", "className", "itemRef", "empty", "valueProperty", "labelProperty", "itemProps", "children"];
|
|
10
|
+
var _excluded = ["ref", "style", "items", "active", "className", "itemRef", "empty", "info", "valueProperty", "labelProperty", "itemProps", "children"];
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
13
|
var Options = function Options(_ref) {
|
|
@@ -17,7 +17,8 @@ var Options = function Options(_ref) {
|
|
|
17
17
|
active = _ref.active,
|
|
18
18
|
className = _ref.className,
|
|
19
19
|
itemRef = _ref.itemRef,
|
|
20
|
-
empty = _ref.empty
|
|
20
|
+
empty = _ref.empty,
|
|
21
|
+
info = _ref.info;
|
|
21
22
|
_ref.valueProperty;
|
|
22
23
|
var _ref$labelProperty = _ref.labelProperty,
|
|
23
24
|
labelProperty = _ref$labelProperty === void 0 ? "label" : _ref$labelProperty,
|
|
@@ -26,49 +27,55 @@ var Options = function Options(_ref) {
|
|
|
26
27
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
28
|
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
28
29
|
ref: ref,
|
|
29
|
-
className: classNames("bg-base select-none
|
|
30
|
+
className: classNames("bg-base select-none flex flex-col", className),
|
|
30
31
|
style: style
|
|
31
32
|
}, rest), {}, {
|
|
32
|
-
children: [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _item$value, _item$labelProperty;
|
|
38
|
-
if (item.___group___) return /*#__PURE__*/jsx("p", {
|
|
39
|
-
className: "px-2 py-1 text-muted text-xs sticky -top-px z-2 bg-base border-t",
|
|
40
|
-
children: item.label
|
|
41
|
-
}, index);
|
|
42
|
-
if (item.___create___) return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
43
|
-
role: "none",
|
|
44
|
-
tabIndex: active === index ? 0 : -1,
|
|
45
|
-
ref: function ref(el) {
|
|
46
|
-
return itemRef(index, el);
|
|
47
|
-
},
|
|
48
|
-
"data-active": active === index ? true : undefined,
|
|
49
|
-
className: classNames("block text-start truncate px-2 py-1 leading-normal cursor-pointer select-none", "data-[active]:bg-primary-200 data-[selected]:bg-primary-600 data-[selected]:text-white data-[active]:data-[selected]:underline")
|
|
50
|
-
}, itemProps(item)), {}, {
|
|
51
|
-
children: /*#__PURE__*/jsx(Trans, {
|
|
52
|
-
i18nKey: "form:select.createOption",
|
|
53
|
-
values: {
|
|
54
|
-
query: (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item
|
|
55
|
-
},
|
|
56
|
-
components: [/*#__PURE__*/jsx("strong", {
|
|
57
|
-
children: "query"
|
|
58
|
-
}, "t0")]
|
|
33
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
34
|
+
className: classNames("overflow-x-hidden overflow-y-auto flex-1"),
|
|
35
|
+
children: [items.length === 0 && (empty !== null && empty !== void 0 ? empty : /*#__PURE__*/jsx(EmptyContent, {
|
|
36
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
37
|
+
i18nKey: "form:select.emptyList"
|
|
59
38
|
})
|
|
60
|
-
}), index)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
39
|
+
})), items.map(function (item, index) {
|
|
40
|
+
var _item$value, _item$labelProperty;
|
|
41
|
+
if (item.___group___) return /*#__PURE__*/jsx("p", {
|
|
42
|
+
className: "px-2 py-1 text-muted text-xs sticky -top-px z-2 bg-base border-t",
|
|
43
|
+
children: item.label
|
|
44
|
+
}, index);
|
|
45
|
+
if (item.___create___) return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
46
|
+
role: "none",
|
|
47
|
+
tabIndex: active === index ? 0 : -1,
|
|
48
|
+
ref: function ref(el) {
|
|
49
|
+
return itemRef(index, el);
|
|
50
|
+
},
|
|
51
|
+
"data-active": active === index ? true : undefined,
|
|
52
|
+
className: classNames("block text-start truncate px-2 py-1 leading-normal cursor-pointer select-none", "data-[active]:bg-primary-200 data-[selected]:bg-primary-600 data-[selected]:text-white data-[active]:data-[selected]:underline")
|
|
53
|
+
}, itemProps(item)), {}, {
|
|
54
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
55
|
+
i18nKey: "form:select.createOption",
|
|
56
|
+
values: {
|
|
57
|
+
query: (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item
|
|
58
|
+
},
|
|
59
|
+
components: [/*#__PURE__*/jsx("strong", {
|
|
60
|
+
children: "query"
|
|
61
|
+
}, "t0")]
|
|
62
|
+
})
|
|
63
|
+
}), index);
|
|
64
|
+
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
65
|
+
role: "none",
|
|
66
|
+
tabIndex: active === index ? 0 : -1,
|
|
67
|
+
ref: function ref(el) {
|
|
68
|
+
return itemRef(index, el);
|
|
69
|
+
},
|
|
70
|
+
"data-active": active === index ? true : undefined,
|
|
71
|
+
className: classNames("block text-start truncate px-2 py-1 leading-normal cursor-pointer", "data-[active]:bg-primary-200 data-[selected]:bg-primary-600 data-[selected]:text-white data-[active]:data-[selected]:underline")
|
|
72
|
+
}, itemProps(item)), {}, {
|
|
73
|
+
children: children(item, (_item$labelProperty = item[labelProperty]) !== null && _item$labelProperty !== void 0 ? _item$labelProperty : item)
|
|
74
|
+
}), index);
|
|
75
|
+
})]
|
|
76
|
+
}), info && /*#__PURE__*/jsx("div", {
|
|
77
|
+
className: "px-2 py-1 text-sm bg-dimmed text-muted",
|
|
78
|
+
children: info
|
|
72
79
|
})]
|
|
73
80
|
}));
|
|
74
81
|
};
|
|
@@ -12,11 +12,11 @@ import { Options } from './Options.js';
|
|
|
12
12
|
import { useSelect } from './useSelect.js';
|
|
13
13
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
|
-
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "options", "defaultOpen", "hideHandle", "groupProperty", "labelProperty", "valueProperty", "sortProperty", "multiple", "searchable", "allowCreate", "emptyDisplay", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed"];
|
|
15
|
+
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "options", "defaultOpen", "hideHandle", "groupProperty", "labelProperty", "valueProperty", "sortProperty", "infoProperty", "multiple", "searchable", "allowCreate", "emptyDisplay", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed"];
|
|
16
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
18
|
var Select = function Select(_ref) {
|
|
19
|
-
var _state$query, _refs$reference$curre;
|
|
19
|
+
var _state$query, _refs$reference$curre, _state$activeItem;
|
|
20
20
|
var ref = _ref.ref,
|
|
21
21
|
name = _ref.name,
|
|
22
22
|
value = _ref.value,
|
|
@@ -36,6 +36,7 @@ var Select = function Select(_ref) {
|
|
|
36
36
|
_ref$valueProperty = _ref.valueProperty,
|
|
37
37
|
valueProperty = _ref$valueProperty === void 0 ? "id" : _ref$valueProperty,
|
|
38
38
|
sortProperty = _ref.sortProperty,
|
|
39
|
+
infoProperty = _ref.infoProperty,
|
|
39
40
|
multiple = _ref.multiple,
|
|
40
41
|
searchable = _ref.searchable,
|
|
41
42
|
allowCreate = _ref.allowCreate,
|
|
@@ -280,6 +281,7 @@ var Select = function Select(_ref) {
|
|
|
280
281
|
itemRef: setItemRef,
|
|
281
282
|
itemProps: makeItemProps,
|
|
282
283
|
empty: emptyDisplay,
|
|
284
|
+
info: (_state$activeItem = state.activeItem) === null || _state$activeItem === void 0 ? void 0 : _state$activeItem[infoProperty !== null && infoProperty !== void 0 ? infoProperty : "info"],
|
|
283
285
|
children: function children(item, label) {
|
|
284
286
|
var _renderer3;
|
|
285
287
|
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
@@ -14,9 +14,11 @@ 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
|
+
autoComplete = _ref.autoComplete,
|
|
18
|
+
_ref$alwaysOpen = _ref.alwaysOpen,
|
|
19
|
+
alwaysOpen = _ref$alwaysOpen === void 0 ? false : _ref$alwaysOpen,
|
|
17
20
|
_ref$defaultOpen = _ref.defaultOpen,
|
|
18
21
|
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
19
|
-
autoComplete = _ref.autoComplete,
|
|
20
22
|
_ref$multiple = _ref.multiple,
|
|
21
23
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
22
24
|
_ref$allowCreate = _ref.allowCreate,
|
|
@@ -66,13 +68,16 @@ var useSelect = function useSelect(_ref) {
|
|
|
66
68
|
if (action.type === "close") {
|
|
67
69
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
68
70
|
activeIndex: null,
|
|
71
|
+
activeItem: null,
|
|
69
72
|
open: false
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
if (action.type === "active" && state.open) {
|
|
76
|
+
var _action$index;
|
|
73
77
|
if (autoComplete && action.index !== null) state.query = state.items[action.index];
|
|
74
78
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
75
|
-
activeIndex: action.index
|
|
79
|
+
activeIndex: action.index,
|
|
80
|
+
activeItem: state.items[(_action$index = action.index) !== null && _action$index !== void 0 ? _action$index : -1]
|
|
76
81
|
});
|
|
77
82
|
}
|
|
78
83
|
if (action.type === "setValue") {
|
|
@@ -86,6 +91,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
86
91
|
var newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
87
92
|
value: state.emptyValue,
|
|
88
93
|
activeIndex: null,
|
|
94
|
+
activeItem: null,
|
|
89
95
|
selectedIndex: autoComplete ? state.multiple ? (_action$value = action.value) === null || _action$value === void 0 ? void 0 : _action$value.length : 0 : state.items.indexOf(action.value)
|
|
90
96
|
});
|
|
91
97
|
if (action.value !== undefined) {
|
|
@@ -103,16 +109,16 @@ var useSelect = function useSelect(_ref) {
|
|
|
103
109
|
newState.value = action.value;
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
|
-
if (!state.multiple) newState.open =
|
|
112
|
+
if (!state.multiple) newState.open = alwaysOpen;
|
|
107
113
|
fireChange(newState.value);
|
|
108
114
|
return newState;
|
|
109
115
|
}
|
|
110
116
|
if (action.type === "removeItem") {
|
|
111
117
|
var newValue = state.value;
|
|
112
118
|
if (state.multiple) {
|
|
113
|
-
var _action$
|
|
119
|
+
var _action$index2;
|
|
114
120
|
newValue = _toConsumableArray(newValue);
|
|
115
|
-
newValue.splice((_action$
|
|
121
|
+
newValue.splice((_action$index2 = action.index) !== null && _action$index2 !== void 0 ? _action$index2 : -1, 1);
|
|
116
122
|
} else {
|
|
117
123
|
newValue = "";
|
|
118
124
|
}
|
|
@@ -173,9 +179,10 @@ var useSelect = function useSelect(_ref) {
|
|
|
173
179
|
}, {
|
|
174
180
|
multiple: multiple,
|
|
175
181
|
emptyValue: emptyValue,
|
|
176
|
-
open: defaultOpen,
|
|
182
|
+
open: alwaysOpen || defaultOpen,
|
|
177
183
|
loading: false,
|
|
178
184
|
activeIndex: null,
|
|
185
|
+
activeItem: null,
|
|
179
186
|
selectedIndex: null,
|
|
180
187
|
value: emptyValue,
|
|
181
188
|
// filter
|
|
@@ -320,7 +327,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
320
327
|
});
|
|
321
328
|
}, []);
|
|
322
329
|
var setActiveIndex = useCallback(function (index) {
|
|
323
|
-
dispatch({
|
|
330
|
+
index && index > -1 && dispatch({
|
|
324
331
|
type: "active",
|
|
325
332
|
index: index
|
|
326
333
|
});
|
|
@@ -9,6 +9,10 @@ export interface Props extends RefProp {
|
|
|
9
9
|
* actual avatar storage path
|
|
10
10
|
*/
|
|
11
11
|
value?: string;
|
|
12
|
+
/**
|
|
13
|
+
* default avatar image
|
|
14
|
+
*/
|
|
15
|
+
defaultValue?: string;
|
|
12
16
|
/**
|
|
13
17
|
* avatar name
|
|
14
18
|
*/
|
|
@@ -39,4 +43,4 @@ export interface Props extends RefProp {
|
|
|
39
43
|
* @param {Props} props - The properties for the AvatarInput component.
|
|
40
44
|
* @returns {JSX.Element} - The rendered AvatarInput component.
|
|
41
45
|
*/
|
|
42
|
-
export declare const AvatarInput: ({ size, avatarName, value, fileUrl, uploadHandler, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const AvatarInput: ({ size, avatarName, value, defaultValue, fileUrl, uploadHandler, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -25,4 +25,4 @@ export interface DateProps extends InputProps<string>, RefProp<HTMLInputElement>
|
|
|
25
25
|
* @param {DateProps} props - The properties for the DateInput component.
|
|
26
26
|
* @returns {JSX.Element} - The rendered DateInput component.
|
|
27
27
|
*/
|
|
28
|
-
export declare const DateInput: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, type, onBlur, onFocus, onChange, onEnterPressed, format, min, max, ...rest }: DateProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const DateInput: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, error, type, onBlur, onFocus, onChange, onEnterPressed, format, min, max, ...rest }: DateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,6 +7,10 @@ interface Props {
|
|
|
7
7
|
* hidden value will fire change for form update
|
|
8
8
|
*/
|
|
9
9
|
hiddenValue?: AnyObject;
|
|
10
|
+
/**
|
|
11
|
+
* default avatar image
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: string;
|
|
10
14
|
/**
|
|
11
15
|
* form onChange handler
|
|
12
16
|
*/
|
|
@@ -20,5 +24,5 @@ interface Props {
|
|
|
20
24
|
* @param {Object} props - Component properties.
|
|
21
25
|
* @returns {JSX.Element} The rendered hidden input field and error icon.
|
|
22
26
|
*/
|
|
23
|
-
export declare const HiddenInput: ({ hiddenValue, onChange, invalid, error, value, name, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const HiddenInput: ({ hiddenValue, defaultValue, onChange, invalid, error, value, name, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
24
28
|
export {};
|
|
@@ -14,4 +14,4 @@ export interface TextInputProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
14
14
|
* @param {TextInputProps} props - The properties for the text input component.
|
|
15
15
|
* @returns {JSX.Element} - A JSX element representing the text input field.
|
|
16
16
|
*/
|
|
17
|
-
export declare const Input: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, monospace, type, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const Input: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, error, monospace, type, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,4 +22,4 @@ export interface NumberProps extends InputProps<number>, RefProp<HTMLInputElemen
|
|
|
22
22
|
* @param {NumberProps} props - The properties for the Number input component.
|
|
23
23
|
* @returns {JSX.Element} The rendered Number input component.
|
|
24
24
|
*/
|
|
25
|
-
export declare const Number: ({ ref, value, invalid, readOnly, disabled, required, placeholder, autoFocus, name, min, max, step, onBlur, onFocus, onChange, onEnterPressed, ...rest }: NumberProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const Number: ({ ref, value, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, name, min, max, step, onBlur, onFocus, onChange, onEnterPressed, ...rest }: NumberProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,4 +16,4 @@ export interface PasswordProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
16
16
|
* @param {PasswordProps} props - The properties for the Password component.
|
|
17
17
|
* @returns {JSX.Element} The rendered Password input component.
|
|
18
18
|
*/
|
|
19
|
-
export declare const Password: ({ ref, value, name, strength, invalid, readOnly, disabled, required, placeholder, autoFocus, showToggle, onBlur, onFocus, onChange, onEnterPressed, ...rest }: PasswordProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const Password: ({ ref, value, name, strength, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, showToggle, onBlur, onFocus, onChange, onEnterPressed, ...rest }: PasswordProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InputProps } from "../types";
|
|
2
|
-
export interface RangeProps extends Omit<InputProps<[number, number]>, "placeholder" | "allowClear" | "children"> {
|
|
2
|
+
export interface RangeProps extends Omit<InputProps<[number, number]>, "placeholder" | "allowClear" | "children" | "defaultValue"> {
|
|
3
3
|
/**
|
|
4
4
|
* min value
|
|
5
5
|
*/
|
|
@@ -27,4 +27,4 @@ export interface SearchProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
27
27
|
* @param {SearchProps} props - The properties for the Search component.
|
|
28
28
|
* @returns {JSX.Element} The rendered Search input component.
|
|
29
29
|
*/
|
|
30
|
-
export declare const Search: ({ ref, value, name, invalid, readOnly, disabled, required, searching, placeholder, autoFocus, hideHandle, allowClear, searchOnChange, onBlur, onFocus, onSearch, onChange, onEnterPressed, ...rest }: SearchProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare const Search: ({ ref, value, name, invalid, readOnly, disabled, required, searching, placeholder, defaultValue, autoFocus, hideHandle, allowClear, searchOnChange, onBlur, onFocus, onSearch, onChange, onEnterPressed, ...rest }: SearchProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InputProps } from "../types";
|
|
2
|
-
export interface SliderProps extends Omit<InputProps<number>, "placeholder" | "allowClear" | "children"> {
|
|
2
|
+
export interface SliderProps extends Omit<InputProps<number>, "placeholder" | "allowClear" | "children" | "defaultValue"> {
|
|
3
3
|
/**
|
|
4
4
|
* min value
|
|
5
5
|
*/
|
|
@@ -28,4 +28,4 @@ export interface TextareaProps extends InputProps, RefProp<HTMLTextAreaElement>
|
|
|
28
28
|
* @param {TextareaProps} props - The properties for the Textarea component.
|
|
29
29
|
* @returns {JSX.Element} The rendered Textarea component.
|
|
30
30
|
*/
|
|
31
|
-
export declare const Textarea: ({ ref, value, name, invalid, readOnly, disabled, required, placeholder, autoFocus, rows, maxRows, variableRows, expandable, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const Textarea: ({ ref, value, name, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, rows, maxRows, variableRows, expandable, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,6 +7,6 @@ import { type SelectProps } from "../types";
|
|
|
7
7
|
* @param {SelectProps<T>} props - The properties for the List component.
|
|
8
8
|
* @returns {JSX.Element} The rendered List component.
|
|
9
9
|
*/
|
|
10
|
-
export declare const List: <T extends AnyObject = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, sortProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, emptyDisplay, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: Omit<SelectProps<T>, "defaultOpen" | "hideHandle"> & {
|
|
10
|
+
export declare const List: <T extends AnyObject = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, infoProperty, sortProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, emptyDisplay, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: Omit<SelectProps<T>, "defaultOpen" | "hideHandle"> & {
|
|
11
11
|
height?: string | number;
|
|
12
12
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
-
export declare const Options: ({ ref, style, items, active, className, itemRef, empty, valueProperty, labelProperty, itemProps, children, ...rest }: {
|
|
2
|
+
export declare const Options: ({ ref, style, items, active, className, itemRef, empty, info, valueProperty, labelProperty, itemProps, children, ...rest }: {
|
|
3
3
|
ref: AnyObject;
|
|
4
|
+
info?: AnyObject;
|
|
4
5
|
itemRef: AnyObject;
|
|
5
6
|
style?: AnyObject;
|
|
6
7
|
items: AnyObject[];
|
|
@@ -7,4 +7,4 @@ import { type SelectProps } from "../types";
|
|
|
7
7
|
* @param {SelectProps<T>} props - The properties for the Select component.
|
|
8
8
|
* @returns {JSX.Element} The rendered Select component.
|
|
9
9
|
*/
|
|
10
|
-
export declare const Select: <T extends AnyObject = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, defaultOpen, hideHandle, groupProperty, labelProperty, valueProperty, sortProperty, multiple, searchable, allowCreate, emptyDisplay, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const Select: <T extends AnyObject = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, defaultOpen, hideHandle, groupProperty, labelProperty, valueProperty, sortProperty, infoProperty, multiple, searchable, allowCreate, emptyDisplay, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,15 +4,17 @@ interface State {
|
|
|
4
4
|
open: boolean;
|
|
5
5
|
loading: boolean;
|
|
6
6
|
activeIndex: number | null;
|
|
7
|
+
activeItem: AnyObject;
|
|
7
8
|
selectedIndex: number | null;
|
|
8
9
|
value: AnyObject;
|
|
9
10
|
query?: string;
|
|
10
11
|
items: AnyObject[];
|
|
11
12
|
}
|
|
12
|
-
export declare const useSelect: ({ options, value,
|
|
13
|
+
export declare const useSelect: ({ options, value, autoComplete, alwaysOpen, defaultOpen, multiple, allowCreate, groupProperty, valueProperty, labelProperty, sortProperty, createOption, matcher, onQuery, onChange, onSelect, }: {
|
|
13
14
|
value?: AnyObject;
|
|
14
15
|
options?: AnyObject[];
|
|
15
16
|
multiple?: boolean;
|
|
17
|
+
alwaysOpen?: boolean;
|
|
16
18
|
defaultOpen?: boolean;
|
|
17
19
|
allowCreate?: boolean;
|
|
18
20
|
groupProperty?: AnyObject;
|
|
@@ -29,6 +31,7 @@ export declare const useSelect: ({ options, value, defaultOpen, autoComplete, mu
|
|
|
29
31
|
state: State | {
|
|
30
32
|
value: any;
|
|
31
33
|
activeIndex: null;
|
|
34
|
+
activeItem: null;
|
|
32
35
|
selectedIndex: any;
|
|
33
36
|
multiple: boolean;
|
|
34
37
|
emptyValue: AnyObject;
|
|
@@ -5,6 +5,10 @@ export interface InputProps<V = string> extends TestProps {
|
|
|
5
5
|
* value
|
|
6
6
|
*/
|
|
7
7
|
value?: V | null;
|
|
8
|
+
/**
|
|
9
|
+
* default value
|
|
10
|
+
*/
|
|
11
|
+
defaultValue?: V | null;
|
|
8
12
|
/**
|
|
9
13
|
* change handler
|
|
10
14
|
*/
|
|
@@ -118,6 +122,10 @@ export interface BaseSelectProps<T extends AnyObject = string> {
|
|
|
118
122
|
* value property name
|
|
119
123
|
*/
|
|
120
124
|
valueProperty?: keyof T;
|
|
125
|
+
/**
|
|
126
|
+
* value property name
|
|
127
|
+
*/
|
|
128
|
+
infoProperty?: keyof T;
|
|
121
129
|
/**
|
|
122
130
|
* value property name
|
|
123
131
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/form",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.57",
|
|
4
4
|
"description": "RUF: Form package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@dnd-kit/utilities": "^3.2.2",
|
|
42
42
|
"@floating-ui/react": "^0.27.9",
|
|
43
43
|
"@hookform/resolvers": "^3.9.0",
|
|
44
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
45
|
-
"@react-fabric/date": "^1.0.0-beta.
|
|
44
|
+
"@react-fabric/core": "^1.0.0-beta.57",
|
|
45
|
+
"@react-fabric/date": "^1.0.0-beta.57",
|
|
46
46
|
"@react-fabric/utilities": "^1.0.0-beta.52",
|
|
47
47
|
"classnames": "^2.5.1",
|
|
48
48
|
"color": "^4.2.3",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"node": ">=18.12.0",
|
|
64
64
|
"npm": ">=8.19.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "9b596a0a8d6cecaa8479f80c495b64fb42ce739f"
|
|
67
67
|
}
|
|
@@ -21,7 +21,13 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
Button,
|
|
26
|
+
CoreIcons,
|
|
27
|
+
Icon,
|
|
28
|
+
ProgressBar,
|
|
29
|
+
Tooltip,
|
|
30
|
+
} from "@react-fabric/core";
|
|
25
31
|
import { FileUtil, Format, isString } from "@react-fabric/utilities";
|
|
26
32
|
import { Fragment } from "react";
|
|
27
33
|
import { useTranslation } from "react-i18next";
|
|
@@ -118,7 +124,7 @@ export const FileField = ({
|
|
|
118
124
|
</div>
|
|
119
125
|
{file.progress && (
|
|
120
126
|
<Icon
|
|
121
|
-
icon=
|
|
127
|
+
icon={CoreIcons.stop}
|
|
122
128
|
bg="danger"
|
|
123
129
|
color="white"
|
|
124
130
|
size="sm"
|
|
@@ -129,7 +135,7 @@ export const FileField = ({
|
|
|
129
135
|
)}
|
|
130
136
|
{!file.progress && (
|
|
131
137
|
<Icon
|
|
132
|
-
icon=
|
|
138
|
+
icon={CoreIcons.trash}
|
|
133
139
|
color="danger"
|
|
134
140
|
size="sm"
|
|
135
141
|
aria-label="remove"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { Avatar, Icon, ProgressBar } from "@react-fabric/core";
|
|
24
|
+
import { Avatar, CoreIcons, Icon, ProgressBar } from "@react-fabric/core";
|
|
25
25
|
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
26
26
|
import { useEffect, useState } from "react";
|
|
27
27
|
import { useFileUploader, type UploadHandler } from "../hooks/useFileUploader";
|
|
@@ -36,6 +36,10 @@ export interface Props extends RefProp {
|
|
|
36
36
|
* actual avatar storage path
|
|
37
37
|
*/
|
|
38
38
|
value?: string;
|
|
39
|
+
/**
|
|
40
|
+
* default avatar image
|
|
41
|
+
*/
|
|
42
|
+
defaultValue?: string;
|
|
39
43
|
/**
|
|
40
44
|
* avatar name
|
|
41
45
|
*/
|
|
@@ -71,6 +75,7 @@ export const AvatarInput = ({
|
|
|
71
75
|
size = "6rem",
|
|
72
76
|
avatarName,
|
|
73
77
|
value,
|
|
78
|
+
defaultValue,
|
|
74
79
|
fileUrl,
|
|
75
80
|
uploadHandler,
|
|
76
81
|
...rest
|
|
@@ -99,16 +104,19 @@ export const AvatarInput = ({
|
|
|
99
104
|
})
|
|
100
105
|
);
|
|
101
106
|
} else {
|
|
102
|
-
setBase64("");
|
|
107
|
+
setBase64(fileUrl?.(defaultValue ?? "") ?? defaultValue ?? "");
|
|
103
108
|
}
|
|
104
|
-
}, [files, list]);
|
|
109
|
+
}, [files, list, defaultValue]);
|
|
105
110
|
|
|
106
111
|
useEffect(() => {
|
|
112
|
+
!value &&
|
|
113
|
+
defaultValue &&
|
|
114
|
+
setBase64(fileUrl?.(defaultValue) ?? defaultValue);
|
|
107
115
|
value && setBase64(fileUrl?.(value) ?? value);
|
|
108
|
-
}, [value]);
|
|
116
|
+
}, [value, defaultValue]);
|
|
109
117
|
|
|
110
118
|
return (
|
|
111
|
-
<div className="flex flex-nowrap items-end">
|
|
119
|
+
<div className="flex flex-nowrap items-end overflow-hidden">
|
|
112
120
|
<div className="inline-block leading-none rounded-full relative outline overflow-hidden">
|
|
113
121
|
<Avatar name={avatarName ?? "temp"} size={size} avatar={base64} />
|
|
114
122
|
<div className="absolute inset-x-0 bottom-0 cursor-pointer bg-black/20 hover:bg-black/50 text-white text-xs text-center py-1">
|
|
@@ -121,11 +129,14 @@ export const AvatarInput = ({
|
|
|
121
129
|
/>
|
|
122
130
|
</div>
|
|
123
131
|
</div>
|
|
124
|
-
<HiddenInput
|
|
132
|
+
<HiddenInput
|
|
133
|
+
hiddenValue={list?.[0]?.path}
|
|
134
|
+
defaultValue={defaultValue}
|
|
135
|
+
{...rest}
|
|
136
|
+
/>
|
|
125
137
|
{files.map((file, idx) => (
|
|
126
|
-
<div key={idx} className="px-2 py-1 flex-1">
|
|
138
|
+
<div key={idx} className="px-2 py-1 flex-1 overflow-hidden">
|
|
127
139
|
<div className="flex flex-nowrap gap-1 items-center">
|
|
128
|
-
<div className="flex-initial truncate pe-2">{file.filename}</div>
|
|
129
140
|
{file.error && (
|
|
130
141
|
<div className="flex-1 truncate px-2">
|
|
131
142
|
<span className="text-danger-600">{file.error}</span>
|
|
@@ -133,20 +144,21 @@ export const AvatarInput = ({
|
|
|
133
144
|
)}
|
|
134
145
|
{file.progress && (
|
|
135
146
|
<Icon
|
|
136
|
-
icon=
|
|
147
|
+
icon={CoreIcons.stop}
|
|
137
148
|
bg="danger"
|
|
138
149
|
color="white"
|
|
139
150
|
size="sm"
|
|
140
|
-
className="p-[2px]"
|
|
151
|
+
className="p-[2px] flex-content"
|
|
141
152
|
aria-label="abort"
|
|
142
153
|
onClick={() => file.abort?.()}
|
|
143
154
|
/>
|
|
144
155
|
)}
|
|
145
156
|
{!file.progress && (
|
|
146
157
|
<Icon
|
|
147
|
-
icon=
|
|
158
|
+
icon={CoreIcons.trash}
|
|
148
159
|
color="danger"
|
|
149
160
|
size="sm"
|
|
161
|
+
className="flex-content"
|
|
150
162
|
aria-label="remove"
|
|
151
163
|
onClick={() => remove(file.key)}
|
|
152
164
|
/>
|
package/src/input/ColorInput.tsx
CHANGED
|
@@ -96,10 +96,11 @@ export const ColorInput = ({
|
|
|
96
96
|
|
|
97
97
|
const handleChange = useCallback(
|
|
98
98
|
(e?: string) => {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
const value = e ?? defaultColor;
|
|
100
|
+
setActualValue(value);
|
|
101
|
+
onChange != null && startTransition(() => onChange(value ?? null));
|
|
101
102
|
},
|
|
102
|
-
[onChange],
|
|
103
|
+
[onChange, defaultColor],
|
|
103
104
|
);
|
|
104
105
|
|
|
105
106
|
const arrowRef = useRef(null);
|
|
@@ -147,6 +148,7 @@ export const ColorInput = ({
|
|
|
147
148
|
>
|
|
148
149
|
<button
|
|
149
150
|
data-ref="button"
|
|
151
|
+
type="button"
|
|
150
152
|
className="flex-1 flex items-center"
|
|
151
153
|
ref={refs.setReference}
|
|
152
154
|
{...getReferenceProps({
|
|
@@ -200,6 +202,7 @@ export const ColorInput = ({
|
|
|
200
202
|
)}
|
|
201
203
|
{!disabled && showPicker && (
|
|
202
204
|
<Icon
|
|
205
|
+
className="flex-content p-1"
|
|
203
206
|
icon={CoreIcons.colorPicker}
|
|
204
207
|
onClick={() =>
|
|
205
208
|
(window as AnyObject).EyeDropper &&
|
package/src/input/DateInput.tsx
CHANGED
|
@@ -88,6 +88,7 @@ export const DateInput = ({
|
|
|
88
88
|
disabled,
|
|
89
89
|
required,
|
|
90
90
|
placeholder,
|
|
91
|
+
defaultValue,
|
|
91
92
|
autoFocus,
|
|
92
93
|
error,
|
|
93
94
|
type = "date",
|
|
@@ -102,7 +103,7 @@ export const DateInput = ({
|
|
|
102
103
|
}: DateProps) => {
|
|
103
104
|
const [actualValue, setActualValue] = useState("");
|
|
104
105
|
const [inputValue, setInputValue] = useState("");
|
|
105
|
-
const deferred = useDeferredValue(value);
|
|
106
|
+
const deferred = useDeferredValue(value ?? defaultValue);
|
|
106
107
|
|
|
107
108
|
const inputFormat = useMemo(
|
|
108
109
|
() => (type === "datetime" ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd"),
|
|
@@ -118,7 +119,7 @@ export const DateInput = ({
|
|
|
118
119
|
|
|
119
120
|
const handleChange = useCallback(
|
|
120
121
|
(e?: ChangeEvent<HTMLInputElement>) => {
|
|
121
|
-
const value = e?.currentTarget.value;
|
|
122
|
+
const value = e?.currentTarget.value ?? defaultValue;
|
|
122
123
|
if (value) {
|
|
123
124
|
const parsed = DateUtil.parseDate(value);
|
|
124
125
|
setActualValue(parsed?.toISOString?.());
|
|
@@ -131,7 +132,7 @@ export const DateInput = ({
|
|
|
131
132
|
onChange != null && startTransition(() => onChange(null));
|
|
132
133
|
}
|
|
133
134
|
},
|
|
134
|
-
[onChange, inputFormat],
|
|
135
|
+
[onChange, inputFormat, defaultValue],
|
|
135
136
|
);
|
|
136
137
|
|
|
137
138
|
const handleDateChange = useCallback(
|