@react-fabric/form 1.0.0-beta.45 → 1.0.0-beta.46
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 +38 -14
- package/dist/cjs/form/Form.js +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/input/ColorInput.js +23 -31
- package/dist/cjs/input/DateInput.js +1 -1
- package/dist/cjs/input/Field.js +1 -0
- package/dist/cjs/input/File.js +1 -1
- package/dist/cjs/input/Input.js +5 -3
- package/dist/cjs/input/Number.js +1 -1
- package/dist/cjs/input/Password.js +1 -1
- package/dist/cjs/input/RangeSlider.js +2 -2
- package/dist/cjs/input/Search.js +1 -1
- package/dist/cjs/input/Slider.js +2 -2
- package/dist/cjs/input/Textarea.js +1 -1
- package/dist/cjs/internal/InputWrapper.js +2 -2
- package/dist/cjs/select/useSelect.js +1 -1
- package/dist/esm/form/Form.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/input/ColorInput.js +23 -31
- package/dist/esm/input/DateInput.js +1 -1
- package/dist/esm/input/Field.js +1 -0
- package/dist/esm/input/File.js +1 -1
- package/dist/esm/input/Input.js +5 -3
- package/dist/esm/input/Number.js +1 -1
- package/dist/esm/input/Password.js +1 -1
- package/dist/esm/input/RangeSlider.js +2 -2
- package/dist/esm/input/Search.js +1 -1
- package/dist/esm/input/Slider.js +2 -2
- package/dist/esm/input/Textarea.js +1 -1
- package/dist/esm/internal/InputWrapper.js +2 -2
- package/dist/esm/select/useSelect.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/input/ColorInput.d.ts +1 -1
- package/dist/types/input/Input.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/package.json +5 -5
- package/src/form/Form.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/input/ColorInput.tsx +13 -42
- package/src/input/DateInput.tsx +1 -1
- package/src/input/Field.tsx +1 -0
- package/src/input/File.tsx +1 -1
- package/src/input/Input.tsx +7 -2
- package/src/input/Number.tsx +1 -1
- package/src/input/Password.tsx +1 -1
- package/src/input/RangeSlider.tsx +2 -2
- package/src/input/Search.tsx +1 -1
- package/src/input/Slider.tsx +2 -2
- package/src/input/Textarea.tsx +1 -1
- package/src/internal/InputWrapper.tsx +6 -3
- package/src/select/useSelect.tsx +1 -0
- package/src/types/index.ts +2 -0
package/css/_field.css
CHANGED
|
@@ -127,23 +127,47 @@
|
|
|
127
127
|
line-height: 1;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
&[data-vertical="false"] {
|
|
131
|
+
> :not(:first-child) {
|
|
132
|
+
&,
|
|
133
|
+
& > div,
|
|
134
|
+
& > [role="button"],
|
|
135
|
+
& > [data-ref="button"] > [role="button"] {
|
|
136
|
+
border-start-start-radius: 0;
|
|
137
|
+
border-end-start-radius: 0;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
> :not(:last-child) {
|
|
142
|
+
&,
|
|
143
|
+
& > div,
|
|
144
|
+
& > [role="button"],
|
|
145
|
+
& > [data-ref="button"] > [role="button"] {
|
|
146
|
+
border-start-end-radius: 0;
|
|
147
|
+
border-end-end-radius: 0;
|
|
148
|
+
}
|
|
137
149
|
}
|
|
138
150
|
}
|
|
139
151
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
&[data-vertical="true"] {
|
|
153
|
+
> :not(:first-child) {
|
|
154
|
+
&,
|
|
155
|
+
& > div,
|
|
156
|
+
& > [role="button"],
|
|
157
|
+
& > [data-ref="button"] > [role="button"] {
|
|
158
|
+
border-start-start-radius: 0;
|
|
159
|
+
border-start-end-radius: 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
> :not(:last-child) {
|
|
164
|
+
&,
|
|
165
|
+
& > div,
|
|
166
|
+
& > [role="button"],
|
|
167
|
+
& > [data-ref="button"] > [role="button"] {
|
|
168
|
+
border-end-start-radius: 0;
|
|
169
|
+
border-end-end-radius: 0;
|
|
170
|
+
}
|
|
147
171
|
}
|
|
148
172
|
}
|
|
149
173
|
}
|
package/dist/cjs/form/Form.js
CHANGED
|
@@ -37,7 +37,7 @@ var Form = function Form(_ref) {
|
|
|
37
37
|
var _useTransition = react.useTransition(),
|
|
38
38
|
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
39
39
|
startTransition = _useTransition2[1];
|
|
40
|
-
var changeHandler = core.useDebounce(onChange, [onChange]);
|
|
40
|
+
var changeHandler = core.useDebounce(onChange, [onChange], 300);
|
|
41
41
|
react.useEffect(function () {
|
|
42
42
|
var subscription = form.watch(function (value) {
|
|
43
43
|
startTransition(function () {
|
package/dist/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var useFileUploader = require('./hooks/useFileUploader.js');
|
|
|
8
8
|
var useFormBuilder = require('./hooks/useFormBuilder.js');
|
|
9
9
|
var schema = require('./types/schema.js');
|
|
10
10
|
var ArrayInput = require('./input/ArrayInput.js');
|
|
11
|
+
var AvatarInput = require('./input/AvatarInput.js');
|
|
11
12
|
var Checkbox = require('./input/Checkbox.js');
|
|
12
13
|
var ColorInput = require('./input/ColorInput.js');
|
|
13
14
|
var ColorPicker = require('./input/ColorPicker.js');
|
|
@@ -40,6 +41,7 @@ exports.useFormBuilder = useFormBuilder.useFormBuilder;
|
|
|
40
41
|
exports.DATA_TYPES = schema.DATA_TYPES;
|
|
41
42
|
exports.SCHEMA_CUSTOM_LIST = schema.SCHEMA_CUSTOM_LIST;
|
|
42
43
|
exports.ArrayInput = ArrayInput.ArrayInput;
|
|
44
|
+
exports.AvatarInput = AvatarInput.AvatarInput;
|
|
43
45
|
exports.Checkbox = Checkbox.Checkbox;
|
|
44
46
|
exports.ColorInput = ColorInput.ColorInput;
|
|
45
47
|
exports.ColorPicker = ColorPicker.ColorPicker;
|
|
@@ -5,33 +5,30 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
|
5
5
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
6
6
|
var react$1 = require('@floating-ui/react');
|
|
7
7
|
var core = require('@react-fabric/core');
|
|
8
|
-
var utilities = require('@react-fabric/utilities');
|
|
9
|
-
var classNames = require('classnames');
|
|
10
8
|
var react = require('react');
|
|
9
|
+
var InputWrapper = require('../internal/InputWrapper.js');
|
|
11
10
|
var ColorPicker = require('./ColorPicker.js');
|
|
12
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
12
|
|
|
14
|
-
var _excluded = ["ref", "required", "disabled", "
|
|
13
|
+
var _excluded = ["ref", "required", "disabled", "readOnly", "invalid", "error", "value", "showPicker", "defaultColor", "onBlur", "onFocus", "onChange", "noOutline"];
|
|
15
14
|
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; }
|
|
16
15
|
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; }
|
|
17
16
|
var ColorInput = function ColorInput(_ref) {
|
|
18
17
|
_ref.ref;
|
|
19
|
-
_ref.required
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_ref.invalid
|
|
23
|
-
_ref.error
|
|
24
|
-
|
|
18
|
+
var required = _ref.required,
|
|
19
|
+
disabled = _ref.disabled,
|
|
20
|
+
readOnly = _ref.readOnly,
|
|
21
|
+
invalid = _ref.invalid,
|
|
22
|
+
error = _ref.error,
|
|
23
|
+
value = _ref.value,
|
|
25
24
|
showPicker = _ref.showPicker,
|
|
26
25
|
_ref$defaultColor = _ref.defaultColor,
|
|
27
26
|
defaultColor = _ref$defaultColor === void 0 ? "" : _ref$defaultColor,
|
|
28
|
-
decorateEnd = _ref.decorateEnd,
|
|
29
|
-
decorateStart = _ref.decorateStart,
|
|
30
27
|
onBlur = _ref.onBlur,
|
|
31
28
|
onFocus = _ref.onFocus,
|
|
32
|
-
onChange = _ref.onChange
|
|
33
|
-
|
|
34
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
onChange = _ref.onChange;
|
|
30
|
+
_ref.noOutline;
|
|
31
|
+
var rest = _objectWithoutProperties(_ref, _excluded);
|
|
35
32
|
var _useState = react.useState(""),
|
|
36
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
34
|
actualValue = _useState2[0],
|
|
@@ -70,7 +67,7 @@ var ColorInput = function ColorInput(_ref) {
|
|
|
70
67
|
floatingStyles = _useFloating.floatingStyles,
|
|
71
68
|
context = _useFloating.context;
|
|
72
69
|
var click = react$1.useClick(context, {
|
|
73
|
-
enabled: !disabled
|
|
70
|
+
enabled: !disabled && !readOnly
|
|
74
71
|
});
|
|
75
72
|
var dismiss = react$1.useDismiss(context, {
|
|
76
73
|
referencePress: true
|
|
@@ -78,12 +75,16 @@ var ColorInput = function ColorInput(_ref) {
|
|
|
78
75
|
var _useInteractions = react$1.useInteractions([dismiss, click]),
|
|
79
76
|
getReferenceProps = _useInteractions.getReferenceProps,
|
|
80
77
|
getFloatingProps = _useInteractions.getFloatingProps;
|
|
81
|
-
return /*#__PURE__*/jsxRuntime.jsxs(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
return /*#__PURE__*/jsxRuntime.jsxs(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
79
|
+
showClear: actualValue !== defaultColor && !disabled && !readOnly,
|
|
80
|
+
onClear: handleChange,
|
|
81
|
+
invalid: invalid,
|
|
82
|
+
readOnly: readOnly,
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
required: required,
|
|
85
|
+
error: error
|
|
86
|
+
}, rest), {}, {
|
|
87
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("button", _objectSpread(_objectSpread({
|
|
87
88
|
"data-ref": "button",
|
|
88
89
|
className: "flex-1 flex items-center",
|
|
89
90
|
ref: refs.setReference
|
|
@@ -131,17 +132,8 @@ var ColorInput = function ColorInput(_ref) {
|
|
|
131
132
|
return handleChange(resp.sRGBHex);
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
|
-
}), decorateEnd && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
135
|
-
className: classNames("text-muted leading-none flex-content", utilities.isString(decorateEnd) && "px-2"),
|
|
136
|
-
children: decorateEnd
|
|
137
|
-
}), !disabled && allowClear && actualValue !== defaultColor && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
138
|
-
icon: core.CoreIcons.close,
|
|
139
|
-
onClick: function onClick() {
|
|
140
|
-
return handleChange();
|
|
141
|
-
},
|
|
142
|
-
className: classNames("text-tint-500 hover:text-tint-700 p-[0.25em] flex-content")
|
|
143
135
|
})]
|
|
144
|
-
});
|
|
136
|
+
}));
|
|
145
137
|
};
|
|
146
138
|
|
|
147
139
|
exports.ColorInput = ColorInput;
|
|
@@ -130,7 +130,7 @@ var DateInput = function DateInput(_ref) {
|
|
|
130
130
|
getReferenceProps = _useInteractions.getReferenceProps,
|
|
131
131
|
getFloatingProps = _useInteractions.getFloatingProps;
|
|
132
132
|
return /*#__PURE__*/jsxRuntime.jsxs(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
133
|
-
showClear: !!actualValue,
|
|
133
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
134
134
|
onClear: handleChange,
|
|
135
135
|
invalid: invalid,
|
|
136
136
|
readOnly: readOnly,
|
package/dist/cjs/input/Field.js
CHANGED
|
@@ -20,6 +20,7 @@ var Field = function Field(_ref) {
|
|
|
20
20
|
return /*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
21
21
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
22
22
|
className: classNames("fabric-fieldGroup", !plain && !noOutline && "outline", !plain && "bg-base", plain && "flex-wrap", "flex-1 rounded", !vertical && "flex"),
|
|
23
|
+
"data-vertical": !!vertical,
|
|
23
24
|
children: core.cloneChildren(children, function (child) {
|
|
24
25
|
return /*#__PURE__*/react.cloneElement(child, {
|
|
25
26
|
"data-inner": true
|
package/dist/cjs/input/File.js
CHANGED
|
@@ -99,7 +99,7 @@ var FileInput = function FileInput(_ref) {
|
|
|
99
99
|
onChange === null || onChange === void 0 || onChange(listRef.current);
|
|
100
100
|
}, [onChange]);
|
|
101
101
|
return /*#__PURE__*/jsxRuntime.jsx(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
102
|
-
showClear: !utilities.isEmpty(actualValue),
|
|
102
|
+
showClear: !utilities.isEmpty(actualValue) && !disabled && !readOnly,
|
|
103
103
|
onClear: handleChange,
|
|
104
104
|
invalid: invalid,
|
|
105
105
|
readOnly: readOnly,
|
package/dist/cjs/input/Input.js
CHANGED
|
@@ -7,9 +7,10 @@ var react = require('react');
|
|
|
7
7
|
var InputWrapper = require('../internal/InputWrapper.js');
|
|
8
8
|
var eventHandlers = require('../utils/eventHandlers.js');
|
|
9
9
|
require('@react-fabric/utilities');
|
|
10
|
+
var classNames = require('classnames');
|
|
10
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
12
|
|
|
12
|
-
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "type", "onBlur", "onFocus", "onChange", "onEnterPressed"];
|
|
13
|
+
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "monospace", "type", "onBlur", "onFocus", "onChange", "onEnterPressed"];
|
|
13
14
|
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; }
|
|
14
15
|
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; }
|
|
15
16
|
var Input = function Input(_ref) {
|
|
@@ -23,6 +24,7 @@ var Input = function Input(_ref) {
|
|
|
23
24
|
placeholder = _ref.placeholder,
|
|
24
25
|
autoFocus = _ref.autoFocus,
|
|
25
26
|
error = _ref.error,
|
|
27
|
+
monospace = _ref.monospace,
|
|
26
28
|
_ref$type = _ref.type,
|
|
27
29
|
type = _ref$type === void 0 ? "text" : _ref$type,
|
|
28
30
|
onBlur = _ref.onBlur,
|
|
@@ -47,7 +49,7 @@ var Input = function Input(_ref) {
|
|
|
47
49
|
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
48
50
|
}, [onchange]);
|
|
49
51
|
return /*#__PURE__*/jsxRuntime.jsx(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
50
|
-
showClear: !!actualValue,
|
|
52
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
51
53
|
onClear: handleChange,
|
|
52
54
|
invalid: invalid,
|
|
53
55
|
readOnly: readOnly,
|
|
@@ -56,7 +58,7 @@ var Input = function Input(_ref) {
|
|
|
56
58
|
error: error
|
|
57
59
|
}, rest), {}, {
|
|
58
60
|
children: /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
59
|
-
className: "appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer",
|
|
61
|
+
className: classNames("appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer", monospace && "font-mono text-sm"),
|
|
60
62
|
"aria-invalid": invalid,
|
|
61
63
|
"aria-disabled": disabled,
|
|
62
64
|
"aria-readonly": readOnly,
|
package/dist/cjs/input/Number.js
CHANGED
|
@@ -47,7 +47,7 @@ var Number = function Number(_ref) {
|
|
|
47
47
|
onChange === null || onChange === void 0 || onChange(number !== null && number !== void 0 ? number : null);
|
|
48
48
|
}, [onChange]);
|
|
49
49
|
return /*#__PURE__*/jsxRuntime.jsx(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
50
|
-
showClear: !!actualValue,
|
|
50
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
51
51
|
onClear: handleChange,
|
|
52
52
|
invalid: invalid,
|
|
53
53
|
readOnly: readOnly,
|
|
@@ -55,7 +55,7 @@ var Password = function Password(_ref) {
|
|
|
55
55
|
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
56
56
|
}, [onChange]);
|
|
57
57
|
return /*#__PURE__*/jsxRuntime.jsxs(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
58
|
-
showClear: !!actualValue,
|
|
58
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
59
59
|
onClear: handleChange,
|
|
60
60
|
invalid: invalid,
|
|
61
61
|
readOnly: readOnly,
|
|
@@ -114,14 +114,14 @@ var RangeSlider = function RangeSlider(_ref) {
|
|
|
114
114
|
isReadOnly: readOnly,
|
|
115
115
|
canClear: !!actualValue,
|
|
116
116
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
117
|
-
className: classNames("flex-
|
|
117
|
+
className: classNames("flex-1 order-3 flex items-center select-none z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
|
|
118
118
|
"data-vertical": !!vertical,
|
|
119
119
|
style: invalid ? undefined : {
|
|
120
120
|
color: color
|
|
121
121
|
},
|
|
122
122
|
children: [showLabels && (vertical ? maxDisplay : minDisplay), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
123
123
|
ref: rangerInstance.trackElRef,
|
|
124
|
-
className: classNames("flex-
|
|
124
|
+
className: classNames("flex-1 relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
|
|
125
125
|
style: {
|
|
126
126
|
height: vertical ? height : undefined
|
|
127
127
|
},
|
package/dist/cjs/input/Search.js
CHANGED
|
@@ -62,7 +62,7 @@ var Search = function Search(_ref) {
|
|
|
62
62
|
}
|
|
63
63
|
}, [onChange, searchOnChange, handleSearch]);
|
|
64
64
|
return /*#__PURE__*/jsxRuntime.jsx(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
65
|
-
showClear: !!actualValue,
|
|
65
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
66
66
|
onClear: handleChange,
|
|
67
67
|
allowClear: allowClear,
|
|
68
68
|
invalid: invalid,
|
package/dist/cjs/input/Slider.js
CHANGED
|
@@ -116,14 +116,14 @@ var Slider = function Slider(_ref) {
|
|
|
116
116
|
isReadOnly: readOnly,
|
|
117
117
|
canClear: !!actualValue,
|
|
118
118
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
119
|
-
className: classNames("flex-
|
|
119
|
+
className: classNames("flex-1 order-3 flex items-center select-none relative z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
|
|
120
120
|
"data-vertical": !!vertical,
|
|
121
121
|
style: invalid ? undefined : {
|
|
122
122
|
color: color
|
|
123
123
|
},
|
|
124
124
|
children: [showLabels && (vertical ? maxDisplay : minDisplay), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
125
125
|
ref: rangerInstance.trackElRef,
|
|
126
|
-
className: classNames("flex-
|
|
126
|
+
className: classNames("flex-1 relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
|
|
127
127
|
style: {
|
|
128
128
|
height: vertical ? height : undefined
|
|
129
129
|
},
|
|
@@ -61,7 +61,7 @@ var Textarea = function Textarea(_ref) {
|
|
|
61
61
|
}
|
|
62
62
|
}, [actualValue, variableRows, rows, maxRows]);
|
|
63
63
|
return /*#__PURE__*/jsxRuntime.jsx(InputWrapper.InputWrapper, _objectSpread(_objectSpread({
|
|
64
|
-
showClear: !!actualValue,
|
|
64
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
65
65
|
onClear: handleChange,
|
|
66
66
|
invalid: invalid,
|
|
67
67
|
readOnly: readOnly,
|
|
@@ -69,7 +69,7 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
69
69
|
var el = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
70
70
|
role: "none",
|
|
71
71
|
ref: wrapperRef,
|
|
72
|
-
className: classNames("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !noOutline && !noBorder && "bg-(--fabric-input) outline
|
|
72
|
+
className: classNames("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !noOutline && !noBorder && "bg-(--fabric-input) outline overflow-hidden", "flex flex-nowrap items-center flex-1", textarea ? "rounded-capped group" : "rounded", isExpanded ? "fixed inset-4 z-[99]" : floatingExpand ? "absolute inset-x-0" : "relative", !noOutline && "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto"),
|
|
73
73
|
onKeyDown: function onKeyDown(e) {
|
|
74
74
|
return e.key === "Escape" && isExpanded && (setExpanded(false), e.stopPropagation());
|
|
75
75
|
},
|
|
@@ -103,7 +103,7 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
103
103
|
return /*#__PURE__*/jsxRuntime.jsx(Wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
|
|
104
104
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
105
105
|
ref: elRef,
|
|
106
|
-
className: "
|
|
106
|
+
className: classNames("relative min-h-8 flex flex-col flex-nowrap", width ? "flex-auto" : "flex-1"),
|
|
107
107
|
style: {
|
|
108
108
|
width: width,
|
|
109
109
|
flexBasis: width
|
package/dist/esm/form/Form.js
CHANGED
|
@@ -37,7 +37,7 @@ var Form = function Form(_ref) {
|
|
|
37
37
|
var _useTransition = useTransition(),
|
|
38
38
|
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
39
39
|
startTransition = _useTransition2[1];
|
|
40
|
-
var changeHandler = useDebounce(onChange, [onChange]);
|
|
40
|
+
var changeHandler = useDebounce(onChange, [onChange], 300);
|
|
41
41
|
useEffect(function () {
|
|
42
42
|
var subscription = form.watch(function (value) {
|
|
43
43
|
startTransition(function () {
|
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { useFileUploader } from './hooks/useFileUploader.js';
|
|
|
8
8
|
export { useFormBuilder } from './hooks/useFormBuilder.js';
|
|
9
9
|
export { DATA_TYPES, SCHEMA_CUSTOM_LIST } from './types/schema.js';
|
|
10
10
|
export { ArrayInput } from './input/ArrayInput.js';
|
|
11
|
+
export { AvatarInput } from './input/AvatarInput.js';
|
|
11
12
|
export { Checkbox } from './input/Checkbox.js';
|
|
12
13
|
export { ColorInput } from './input/ColorInput.js';
|
|
13
14
|
export { ColorPicker } from './input/ColorPicker.js';
|
|
@@ -5,33 +5,30 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
5
5
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
6
|
import { useFloating, autoUpdate, shift, flip, offset, arrow, useClick, useDismiss, useInteractions, FloatingArrow } from '@floating-ui/react';
|
|
7
7
|
import { Icon, CoreIcons } from '@react-fabric/core';
|
|
8
|
-
import { isString } from '@react-fabric/utilities';
|
|
9
|
-
import classNames from 'classnames';
|
|
10
8
|
import { useState, useDeferredValue, useEffect, useCallback, startTransition, useRef } from 'react';
|
|
9
|
+
import { InputWrapper } from '../internal/InputWrapper.js';
|
|
11
10
|
import { ColorPicker } from './ColorPicker.js';
|
|
12
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
13
12
|
|
|
14
|
-
var _excluded = ["ref", "required", "disabled", "
|
|
13
|
+
var _excluded = ["ref", "required", "disabled", "readOnly", "invalid", "error", "value", "showPicker", "defaultColor", "onBlur", "onFocus", "onChange", "noOutline"];
|
|
15
14
|
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; }
|
|
16
15
|
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; }
|
|
17
16
|
var ColorInput = function ColorInput(_ref) {
|
|
18
17
|
_ref.ref;
|
|
19
|
-
_ref.required
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_ref.invalid
|
|
23
|
-
_ref.error
|
|
24
|
-
|
|
18
|
+
var required = _ref.required,
|
|
19
|
+
disabled = _ref.disabled,
|
|
20
|
+
readOnly = _ref.readOnly,
|
|
21
|
+
invalid = _ref.invalid,
|
|
22
|
+
error = _ref.error,
|
|
23
|
+
value = _ref.value,
|
|
25
24
|
showPicker = _ref.showPicker,
|
|
26
25
|
_ref$defaultColor = _ref.defaultColor,
|
|
27
26
|
defaultColor = _ref$defaultColor === void 0 ? "" : _ref$defaultColor,
|
|
28
|
-
decorateEnd = _ref.decorateEnd,
|
|
29
|
-
decorateStart = _ref.decorateStart,
|
|
30
27
|
onBlur = _ref.onBlur,
|
|
31
28
|
onFocus = _ref.onFocus,
|
|
32
|
-
onChange = _ref.onChange
|
|
33
|
-
|
|
34
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
onChange = _ref.onChange;
|
|
30
|
+
_ref.noOutline;
|
|
31
|
+
var rest = _objectWithoutProperties(_ref, _excluded);
|
|
35
32
|
var _useState = useState(""),
|
|
36
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
34
|
actualValue = _useState2[0],
|
|
@@ -70,7 +67,7 @@ var ColorInput = function ColorInput(_ref) {
|
|
|
70
67
|
floatingStyles = _useFloating.floatingStyles,
|
|
71
68
|
context = _useFloating.context;
|
|
72
69
|
var click = useClick(context, {
|
|
73
|
-
enabled: !disabled
|
|
70
|
+
enabled: !disabled && !readOnly
|
|
74
71
|
});
|
|
75
72
|
var dismiss = useDismiss(context, {
|
|
76
73
|
referencePress: true
|
|
@@ -78,12 +75,16 @@ var ColorInput = function ColorInput(_ref) {
|
|
|
78
75
|
var _useInteractions = useInteractions([dismiss, click]),
|
|
79
76
|
getReferenceProps = _useInteractions.getReferenceProps,
|
|
80
77
|
getFloatingProps = _useInteractions.getFloatingProps;
|
|
81
|
-
return /*#__PURE__*/jsxs(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
return /*#__PURE__*/jsxs(InputWrapper, _objectSpread(_objectSpread({
|
|
79
|
+
showClear: actualValue !== defaultColor && !disabled && !readOnly,
|
|
80
|
+
onClear: handleChange,
|
|
81
|
+
invalid: invalid,
|
|
82
|
+
readOnly: readOnly,
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
required: required,
|
|
85
|
+
error: error
|
|
86
|
+
}, rest), {}, {
|
|
87
|
+
children: [/*#__PURE__*/jsx("button", _objectSpread(_objectSpread({
|
|
87
88
|
"data-ref": "button",
|
|
88
89
|
className: "flex-1 flex items-center",
|
|
89
90
|
ref: refs.setReference
|
|
@@ -131,17 +132,8 @@ var ColorInput = function ColorInput(_ref) {
|
|
|
131
132
|
return handleChange(resp.sRGBHex);
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
|
-
}), decorateEnd && /*#__PURE__*/jsx("div", {
|
|
135
|
-
className: classNames("text-muted leading-none flex-content", isString(decorateEnd) && "px-2"),
|
|
136
|
-
children: decorateEnd
|
|
137
|
-
}), !disabled && allowClear && actualValue !== defaultColor && /*#__PURE__*/jsx(Icon, {
|
|
138
|
-
icon: CoreIcons.close,
|
|
139
|
-
onClick: function onClick() {
|
|
140
|
-
return handleChange();
|
|
141
|
-
},
|
|
142
|
-
className: classNames("text-tint-500 hover:text-tint-700 p-[0.25em] flex-content")
|
|
143
135
|
})]
|
|
144
|
-
});
|
|
136
|
+
}));
|
|
145
137
|
};
|
|
146
138
|
|
|
147
139
|
export { ColorInput };
|
|
@@ -130,7 +130,7 @@ var DateInput = function DateInput(_ref) {
|
|
|
130
130
|
getReferenceProps = _useInteractions.getReferenceProps,
|
|
131
131
|
getFloatingProps = _useInteractions.getFloatingProps;
|
|
132
132
|
return /*#__PURE__*/jsxs(InputWrapper, _objectSpread(_objectSpread({
|
|
133
|
-
showClear: !!actualValue,
|
|
133
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
134
134
|
onClear: handleChange,
|
|
135
135
|
invalid: invalid,
|
|
136
136
|
readOnly: readOnly,
|
package/dist/esm/input/Field.js
CHANGED
|
@@ -20,6 +20,7 @@ var Field = function Field(_ref) {
|
|
|
20
20
|
return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
21
21
|
children: /*#__PURE__*/jsx("div", {
|
|
22
22
|
className: classNames("fabric-fieldGroup", !plain && !noOutline && "outline", !plain && "bg-base", plain && "flex-wrap", "flex-1 rounded", !vertical && "flex"),
|
|
23
|
+
"data-vertical": !!vertical,
|
|
23
24
|
children: cloneChildren(children, function (child) {
|
|
24
25
|
return /*#__PURE__*/cloneElement(child, {
|
|
25
26
|
"data-inner": true
|
package/dist/esm/input/File.js
CHANGED
|
@@ -99,7 +99,7 @@ var FileInput = function FileInput(_ref) {
|
|
|
99
99
|
onChange === null || onChange === void 0 || onChange(listRef.current);
|
|
100
100
|
}, [onChange]);
|
|
101
101
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
102
|
-
showClear: !isEmpty(actualValue),
|
|
102
|
+
showClear: !isEmpty(actualValue) && !disabled && !readOnly,
|
|
103
103
|
onClear: handleChange,
|
|
104
104
|
invalid: invalid,
|
|
105
105
|
readOnly: readOnly,
|
package/dist/esm/input/Input.js
CHANGED
|
@@ -7,9 +7,10 @@ import { useState, useDeferredValue, useMemo, useEffect, useCallback } from 'rea
|
|
|
7
7
|
import { InputWrapper } from '../internal/InputWrapper.js';
|
|
8
8
|
import { handleEnter } from '../utils/eventHandlers.js';
|
|
9
9
|
import '@react-fabric/utilities';
|
|
10
|
+
import classNames from 'classnames';
|
|
10
11
|
import { jsx } from 'react/jsx-runtime';
|
|
11
12
|
|
|
12
|
-
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "type", "onBlur", "onFocus", "onChange", "onEnterPressed"];
|
|
13
|
+
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "monospace", "type", "onBlur", "onFocus", "onChange", "onEnterPressed"];
|
|
13
14
|
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; }
|
|
14
15
|
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; }
|
|
15
16
|
var Input = function Input(_ref) {
|
|
@@ -23,6 +24,7 @@ var Input = function Input(_ref) {
|
|
|
23
24
|
placeholder = _ref.placeholder,
|
|
24
25
|
autoFocus = _ref.autoFocus,
|
|
25
26
|
error = _ref.error,
|
|
27
|
+
monospace = _ref.monospace,
|
|
26
28
|
_ref$type = _ref.type,
|
|
27
29
|
type = _ref$type === void 0 ? "text" : _ref$type,
|
|
28
30
|
onBlur = _ref.onBlur,
|
|
@@ -47,7 +49,7 @@ var Input = function Input(_ref) {
|
|
|
47
49
|
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
48
50
|
}, [onchange]);
|
|
49
51
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
50
|
-
showClear: !!actualValue,
|
|
52
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
51
53
|
onClear: handleChange,
|
|
52
54
|
invalid: invalid,
|
|
53
55
|
readOnly: readOnly,
|
|
@@ -56,7 +58,7 @@ var Input = function Input(_ref) {
|
|
|
56
58
|
error: error
|
|
57
59
|
}, rest), {}, {
|
|
58
60
|
children: /*#__PURE__*/jsx("input", {
|
|
59
|
-
className: "appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer",
|
|
61
|
+
className: classNames("appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer", monospace && "font-mono text-sm"),
|
|
60
62
|
"aria-invalid": invalid,
|
|
61
63
|
"aria-disabled": disabled,
|
|
62
64
|
"aria-readonly": readOnly,
|
package/dist/esm/input/Number.js
CHANGED
|
@@ -47,7 +47,7 @@ var Number = function Number(_ref) {
|
|
|
47
47
|
onChange === null || onChange === void 0 || onChange(number !== null && number !== void 0 ? number : null);
|
|
48
48
|
}, [onChange]);
|
|
49
49
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
50
|
-
showClear: !!actualValue,
|
|
50
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
51
51
|
onClear: handleChange,
|
|
52
52
|
invalid: invalid,
|
|
53
53
|
readOnly: readOnly,
|
|
@@ -55,7 +55,7 @@ var Password = function Password(_ref) {
|
|
|
55
55
|
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
56
56
|
}, [onChange]);
|
|
57
57
|
return /*#__PURE__*/jsxs(InputWrapper, _objectSpread(_objectSpread({
|
|
58
|
-
showClear: !!actualValue,
|
|
58
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
59
59
|
onClear: handleChange,
|
|
60
60
|
invalid: invalid,
|
|
61
61
|
readOnly: readOnly,
|
|
@@ -114,14 +114,14 @@ var RangeSlider = function RangeSlider(_ref) {
|
|
|
114
114
|
isReadOnly: readOnly,
|
|
115
115
|
canClear: !!actualValue,
|
|
116
116
|
children: /*#__PURE__*/jsxs("div", {
|
|
117
|
-
className: classNames("flex-
|
|
117
|
+
className: classNames("flex-1 order-3 flex items-center select-none z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
|
|
118
118
|
"data-vertical": !!vertical,
|
|
119
119
|
style: invalid ? undefined : {
|
|
120
120
|
color: color
|
|
121
121
|
},
|
|
122
122
|
children: [showLabels && (vertical ? maxDisplay : minDisplay), /*#__PURE__*/jsxs("div", {
|
|
123
123
|
ref: rangerInstance.trackElRef,
|
|
124
|
-
className: classNames("flex-
|
|
124
|
+
className: classNames("flex-1 relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
|
|
125
125
|
style: {
|
|
126
126
|
height: vertical ? height : undefined
|
|
127
127
|
},
|
package/dist/esm/input/Search.js
CHANGED
|
@@ -62,7 +62,7 @@ var Search = function Search(_ref) {
|
|
|
62
62
|
}
|
|
63
63
|
}, [onChange, searchOnChange, handleSearch]);
|
|
64
64
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
65
|
-
showClear: !!actualValue,
|
|
65
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
66
66
|
onClear: handleChange,
|
|
67
67
|
allowClear: allowClear,
|
|
68
68
|
invalid: invalid,
|
package/dist/esm/input/Slider.js
CHANGED
|
@@ -116,14 +116,14 @@ var Slider = function Slider(_ref) {
|
|
|
116
116
|
isReadOnly: readOnly,
|
|
117
117
|
canClear: !!actualValue,
|
|
118
118
|
children: /*#__PURE__*/jsxs("div", {
|
|
119
|
-
className: classNames("flex-
|
|
119
|
+
className: classNames("flex-1 order-3 flex items-center select-none relative z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
|
|
120
120
|
"data-vertical": !!vertical,
|
|
121
121
|
style: invalid ? undefined : {
|
|
122
122
|
color: color
|
|
123
123
|
},
|
|
124
124
|
children: [showLabels && (vertical ? maxDisplay : minDisplay), /*#__PURE__*/jsxs("div", {
|
|
125
125
|
ref: rangerInstance.trackElRef,
|
|
126
|
-
className: classNames("flex-
|
|
126
|
+
className: classNames("flex-1 relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
|
|
127
127
|
style: {
|
|
128
128
|
height: vertical ? height : undefined
|
|
129
129
|
},
|
|
@@ -61,7 +61,7 @@ var Textarea = function Textarea(_ref) {
|
|
|
61
61
|
}
|
|
62
62
|
}, [actualValue, variableRows, rows, maxRows]);
|
|
63
63
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
64
|
-
showClear: !!actualValue,
|
|
64
|
+
showClear: !!actualValue && !disabled && !readOnly,
|
|
65
65
|
onClear: handleChange,
|
|
66
66
|
invalid: invalid,
|
|
67
67
|
readOnly: readOnly,
|
|
@@ -69,7 +69,7 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
69
69
|
var el = /*#__PURE__*/jsxs("div", {
|
|
70
70
|
role: "none",
|
|
71
71
|
ref: wrapperRef,
|
|
72
|
-
className: classNames("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !noOutline && !noBorder && "bg-(--fabric-input) outline
|
|
72
|
+
className: classNames("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !noOutline && !noBorder && "bg-(--fabric-input) outline overflow-hidden", "flex flex-nowrap items-center flex-1", textarea ? "rounded-capped group" : "rounded", isExpanded ? "fixed inset-4 z-[99]" : floatingExpand ? "absolute inset-x-0" : "relative", !noOutline && "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto"),
|
|
73
73
|
onKeyDown: function onKeyDown(e) {
|
|
74
74
|
return e.key === "Escape" && isExpanded && (setExpanded(false), e.stopPropagation());
|
|
75
75
|
},
|
|
@@ -103,7 +103,7 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
103
103
|
return /*#__PURE__*/jsx(Wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
|
|
104
104
|
children: /*#__PURE__*/jsx("div", {
|
|
105
105
|
ref: elRef,
|
|
106
|
-
className: "
|
|
106
|
+
className: classNames("relative min-h-8 flex flex-col flex-nowrap", width ? "flex-auto" : "flex-1"),
|
|
107
107
|
style: {
|
|
108
108
|
width: width,
|
|
109
109
|
flexBasis: width
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { useFileUploader } from "./hooks/useFileUploader";
|
|
|
6
6
|
export { useFormBuilder } from "./hooks/useFormBuilder";
|
|
7
7
|
export { DATA_TYPES, SCHEMA_CUSTOM_LIST, type FormSchema, type SchemaDef, } from "./types/schema";
|
|
8
8
|
export { ArrayInput } from "./input/ArrayInput";
|
|
9
|
+
export { AvatarInput } from "./input/AvatarInput";
|
|
9
10
|
export { Checkbox } from "./input/Checkbox";
|
|
10
11
|
export { ColorInput } from "./input/ColorInput";
|
|
11
12
|
export { ColorPicker } from "./input/ColorPicker";
|
|
@@ -7,4 +7,4 @@ export interface ColorInputProps extends InputProps, Omit<ColorProps, "onChange"
|
|
|
7
7
|
*/
|
|
8
8
|
showPicker?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const ColorInput: ({ ref, required, disabled,
|
|
10
|
+
export declare const ColorInput: ({ ref, required, disabled, readOnly, invalid, error, value, showPicker, defaultColor, onBlur, onFocus, onChange, noOutline, ...rest }: ColorInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,4 +6,4 @@ export interface TextInputProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
6
6
|
*/
|
|
7
7
|
type?: "email" | "file" | "search" | "tel" | "text" | "url";
|
|
8
8
|
}
|
|
9
|
-
export declare const Input: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, type, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
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;
|
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.46",
|
|
4
4
|
"description": "RUF: Form package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@dnd-kit/utilities": "^3.2.2",
|
|
42
42
|
"@floating-ui/react": "^0.26.24",
|
|
43
43
|
"@hookform/resolvers": "^3.9.0",
|
|
44
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
45
|
-
"@react-fabric/date": "^1.0.0-beta.
|
|
46
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
44
|
+
"@react-fabric/core": "^1.0.0-beta.46",
|
|
45
|
+
"@react-fabric/date": "^1.0.0-beta.46",
|
|
46
|
+
"@react-fabric/utilities": "^1.0.0-beta.46",
|
|
47
47
|
"classnames": "^2.5.1",
|
|
48
48
|
"color": "^4.2.3",
|
|
49
49
|
"react-color": "^2.19.3",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"node": ">=18.12.0",
|
|
64
64
|
"npm": ">=8.19.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "0dfc20b9c84712bb1cb5205c22464e8a1eb2341c"
|
|
67
67
|
}
|
package/src/form/Form.tsx
CHANGED
|
@@ -90,7 +90,7 @@ export const Form = <K extends KeyValue>({
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
const [, startTransition] = useTransition();
|
|
93
|
-
const changeHandler = useDebounce(onChange, [onChange]);
|
|
93
|
+
const changeHandler = useDebounce(onChange, [onChange], 300);
|
|
94
94
|
useEffect(() => {
|
|
95
95
|
const subscription = form.watch((value) => {
|
|
96
96
|
startTransition(() => changeHandler?.(value as K));
|
package/src/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ export {
|
|
|
39
39
|
} from "./types/schema";
|
|
40
40
|
|
|
41
41
|
export { ArrayInput } from "./input/ArrayInput";
|
|
42
|
+
export { AvatarInput } from "./input/AvatarInput";
|
|
42
43
|
export { Checkbox } from "./input/Checkbox";
|
|
43
44
|
export { ColorInput } from "./input/ColorInput";
|
|
44
45
|
export { ColorPicker } from "./input/ColorPicker";
|
package/src/input/ColorInput.tsx
CHANGED
|
@@ -35,8 +35,6 @@ import {
|
|
|
35
35
|
} from "@floating-ui/react";
|
|
36
36
|
import { CoreIcons, Icon } from "@react-fabric/core";
|
|
37
37
|
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
38
|
-
import { isString } from "@react-fabric/utilities";
|
|
39
|
-
import classNames from "classnames";
|
|
40
38
|
import {
|
|
41
39
|
startTransition,
|
|
42
40
|
useCallback,
|
|
@@ -45,6 +43,7 @@ import {
|
|
|
45
43
|
useRef,
|
|
46
44
|
useState,
|
|
47
45
|
} from "react";
|
|
46
|
+
import { InputWrapper } from "../internal/InputWrapper";
|
|
48
47
|
import { type InputProps } from "../types";
|
|
49
48
|
import { ColorPicker, type ColorProps } from "./ColorPicker";
|
|
50
49
|
|
|
@@ -62,14 +61,12 @@ export const ColorInput = ({
|
|
|
62
61
|
ref,
|
|
63
62
|
required,
|
|
64
63
|
disabled,
|
|
65
|
-
|
|
64
|
+
readOnly,
|
|
66
65
|
invalid,
|
|
67
66
|
error,
|
|
68
67
|
value,
|
|
69
68
|
showPicker,
|
|
70
69
|
defaultColor = "",
|
|
71
|
-
decorateEnd,
|
|
72
|
-
decorateStart,
|
|
73
70
|
onBlur,
|
|
74
71
|
onFocus,
|
|
75
72
|
onChange,
|
|
@@ -113,7 +110,7 @@ export const ColorInput = ({
|
|
|
113
110
|
],
|
|
114
111
|
});
|
|
115
112
|
const click = useClick(context, {
|
|
116
|
-
enabled: !disabled,
|
|
113
|
+
enabled: !disabled && !readOnly,
|
|
117
114
|
});
|
|
118
115
|
const dismiss = useDismiss(context, {
|
|
119
116
|
referencePress: true,
|
|
@@ -125,23 +122,16 @@ export const ColorInput = ({
|
|
|
125
122
|
]);
|
|
126
123
|
|
|
127
124
|
return (
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
<InputWrapper
|
|
126
|
+
showClear={actualValue !== defaultColor && !disabled && !readOnly}
|
|
127
|
+
onClear={handleChange}
|
|
128
|
+
invalid={invalid}
|
|
129
|
+
readOnly={readOnly}
|
|
130
|
+
disabled={disabled}
|
|
131
|
+
required={required}
|
|
132
|
+
error={error}
|
|
133
|
+
{...rest}
|
|
134
134
|
>
|
|
135
|
-
{decorateStart && (
|
|
136
|
-
<div
|
|
137
|
-
className={classNames(
|
|
138
|
-
"text-muted leading-none flex-content",
|
|
139
|
-
isString(decorateStart) && "px-2",
|
|
140
|
-
)}
|
|
141
|
-
>
|
|
142
|
-
{decorateStart}
|
|
143
|
-
</div>
|
|
144
|
-
)}
|
|
145
135
|
<button
|
|
146
136
|
data-ref="button"
|
|
147
137
|
className="flex-1 flex items-center"
|
|
@@ -206,25 +196,6 @@ export const ColorInput = ({
|
|
|
206
196
|
}
|
|
207
197
|
/>
|
|
208
198
|
)}
|
|
209
|
-
|
|
210
|
-
<div
|
|
211
|
-
className={classNames(
|
|
212
|
-
"text-muted leading-none flex-content",
|
|
213
|
-
isString(decorateEnd) && "px-2",
|
|
214
|
-
)}
|
|
215
|
-
>
|
|
216
|
-
{decorateEnd}
|
|
217
|
-
</div>
|
|
218
|
-
)}
|
|
219
|
-
{!disabled && allowClear && actualValue !== defaultColor && (
|
|
220
|
-
<Icon
|
|
221
|
-
icon={CoreIcons.close}
|
|
222
|
-
onClick={() => handleChange()}
|
|
223
|
-
className={classNames(
|
|
224
|
-
"text-tint-500 hover:text-tint-700 p-[0.25em] flex-content",
|
|
225
|
-
)}
|
|
226
|
-
/>
|
|
227
|
-
)}
|
|
228
|
-
</div>
|
|
199
|
+
</InputWrapper>
|
|
229
200
|
);
|
|
230
201
|
};
|
package/src/input/DateInput.tsx
CHANGED
package/src/input/Field.tsx
CHANGED
package/src/input/File.tsx
CHANGED
package/src/input/Input.tsx
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import { InputWrapper } from "../internal/InputWrapper";
|
|
34
34
|
import { type InputProps } from "../types";
|
|
35
35
|
import { handleEnter } from "../utils";
|
|
36
|
+
import classNames from "classnames";
|
|
36
37
|
|
|
37
38
|
export interface TextInputProps extends InputProps, RefProp<HTMLInputElement> {
|
|
38
39
|
/**
|
|
@@ -52,6 +53,7 @@ export const Input = ({
|
|
|
52
53
|
placeholder,
|
|
53
54
|
autoFocus,
|
|
54
55
|
error,
|
|
56
|
+
monospace,
|
|
55
57
|
type = "text",
|
|
56
58
|
onBlur,
|
|
57
59
|
onFocus,
|
|
@@ -82,7 +84,7 @@ export const Input = ({
|
|
|
82
84
|
|
|
83
85
|
return (
|
|
84
86
|
<InputWrapper
|
|
85
|
-
showClear={!!actualValue}
|
|
87
|
+
showClear={!!actualValue && !disabled && !readOnly}
|
|
86
88
|
onClear={handleChange}
|
|
87
89
|
invalid={invalid}
|
|
88
90
|
readOnly={readOnly}
|
|
@@ -92,7 +94,10 @@ export const Input = ({
|
|
|
92
94
|
{...rest}
|
|
93
95
|
>
|
|
94
96
|
<input
|
|
95
|
-
className=
|
|
97
|
+
className={classNames(
|
|
98
|
+
"appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer",
|
|
99
|
+
monospace && "font-mono text-sm",
|
|
100
|
+
)}
|
|
96
101
|
aria-invalid={invalid}
|
|
97
102
|
aria-disabled={disabled}
|
|
98
103
|
aria-readonly={readOnly}
|
package/src/input/Number.tsx
CHANGED
package/src/input/Password.tsx
CHANGED
|
@@ -190,7 +190,7 @@ export const RangeSlider = ({
|
|
|
190
190
|
>
|
|
191
191
|
<div
|
|
192
192
|
className={classNames(
|
|
193
|
-
"flex-
|
|
193
|
+
"flex-1 order-3 flex items-center select-none z-0",
|
|
194
194
|
vertical && "flex-col w-8",
|
|
195
195
|
invalid ? "text-danger-500" : "text-primary-600",
|
|
196
196
|
)}
|
|
@@ -201,7 +201,7 @@ export const RangeSlider = ({
|
|
|
201
201
|
<div
|
|
202
202
|
ref={rangerInstance.trackElRef}
|
|
203
203
|
className={classNames(
|
|
204
|
-
"flex-
|
|
204
|
+
"flex-1 relative flex items-center",
|
|
205
205
|
vertical ? "my-2 w-8" : "mx-2 h-8",
|
|
206
206
|
)}
|
|
207
207
|
style={{ height: vertical ? height : undefined }}
|
package/src/input/Search.tsx
CHANGED
package/src/input/Slider.tsx
CHANGED
|
@@ -194,7 +194,7 @@ export const Slider = ({
|
|
|
194
194
|
>
|
|
195
195
|
<div
|
|
196
196
|
className={classNames(
|
|
197
|
-
"flex-
|
|
197
|
+
"flex-1 order-3 flex items-center select-none relative z-0",
|
|
198
198
|
vertical && "flex-col w-8",
|
|
199
199
|
invalid ? "text-danger-500" : "text-primary-600",
|
|
200
200
|
)}
|
|
@@ -205,7 +205,7 @@ export const Slider = ({
|
|
|
205
205
|
<div
|
|
206
206
|
ref={rangerInstance.trackElRef}
|
|
207
207
|
className={classNames(
|
|
208
|
-
"flex-
|
|
208
|
+
"flex-1 relative flex items-center",
|
|
209
209
|
vertical ? "my-2 w-8" : "mx-2 h-8",
|
|
210
210
|
)}
|
|
211
211
|
style={{ height: vertical ? height : undefined }}
|
package/src/input/Textarea.tsx
CHANGED
|
@@ -108,7 +108,7 @@ export const InputWrapper = ({
|
|
|
108
108
|
invalid && "fabric-invalidWrapper",
|
|
109
109
|
!noOutline &&
|
|
110
110
|
!noBorder &&
|
|
111
|
-
"bg-(--fabric-input) outline
|
|
111
|
+
"bg-(--fabric-input) outline overflow-hidden",
|
|
112
112
|
"flex flex-nowrap items-center flex-1",
|
|
113
113
|
textarea ? "rounded-capped group" : "rounded",
|
|
114
114
|
isExpanded
|
|
@@ -117,7 +117,7 @@ export const InputWrapper = ({
|
|
|
117
117
|
? "absolute inset-x-0"
|
|
118
118
|
: "relative",
|
|
119
119
|
!noOutline &&
|
|
120
|
-
"after:absolute after:bottom-0 after:h-
|
|
120
|
+
"after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto",
|
|
121
121
|
)}
|
|
122
122
|
onKeyDown={(e) =>
|
|
123
123
|
e.key === "Escape" &&
|
|
@@ -190,7 +190,10 @@ export const InputWrapper = ({
|
|
|
190
190
|
<Wrapper {...wrapperProps}>
|
|
191
191
|
<div
|
|
192
192
|
ref={elRef}
|
|
193
|
-
className=
|
|
193
|
+
className={classNames(
|
|
194
|
+
"relative min-h-8 flex flex-col flex-nowrap",
|
|
195
|
+
width ? "flex-auto" : "flex-1",
|
|
196
|
+
)}
|
|
194
197
|
style={{ width, flexBasis: width }}
|
|
195
198
|
>
|
|
196
199
|
{el}
|
package/src/select/useSelect.tsx
CHANGED