@react-fabric/form 1.0.0-beta.4 → 1.0.0-beta.40
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 +1 -1
- package/dist/cjs/select/List.js +41 -20
- package/dist/cjs/select/Options.js +2 -2
- package/dist/cjs/select/Select.js +11 -8
- package/dist/cjs/select/useSelect.js +12 -7
- 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 +1 -1
- package/dist/esm/select/List.js +42 -21
- package/dist/esm/select/Options.js +2 -2
- package/dist/esm/select/Select.js +11 -8
- package/dist/esm/select/useSelect.js +13 -8
- 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/List.d.ts +1 -1
- package/dist/types/types/index.d.ts +9 -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 +1 -1
- package/src/select/List.tsx +34 -7
- package/src/select/Options.tsx +1 -1
- package/src/select/Select.tsx +5 -2
- package/src/select/useSelect.tsx +27 -18
- package/src/types/index.ts +14 -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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
|
+
import { useFloating, autoUpdate, shift, flip, offset, arrow, useFocus, useClick, useDismiss, useInteractions, FloatingArrow } from '@floating-ui/react';
|
|
7
|
+
import { DateUtil, DatePanel } from '@react-fabric/date';
|
|
8
|
+
import { mergeRefs } from '@react-fabric/utilities';
|
|
9
|
+
import { useState, useDeferredValue, useMemo, useEffect, useCallback, startTransition, useRef } from 'react';
|
|
10
|
+
import { InputWrapper } from '../internal/InputWrapper.js';
|
|
11
|
+
import { handleEnter } from '../utils/eventHandlers.js';
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
14
|
+
|
|
15
|
+
var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "type", "onChange", "onEnterPressed", "format", "min", "max"];
|
|
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
|
+
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
|
+
var DateInput = function DateInput(_ref) {
|
|
19
|
+
var ref = _ref.ref,
|
|
20
|
+
name = _ref.name,
|
|
21
|
+
value = _ref.value,
|
|
22
|
+
invalid = _ref.invalid,
|
|
23
|
+
readOnly = _ref.readOnly,
|
|
24
|
+
disabled = _ref.disabled,
|
|
25
|
+
required = _ref.required,
|
|
26
|
+
placeholder = _ref.placeholder,
|
|
27
|
+
autoFocus = _ref.autoFocus,
|
|
28
|
+
error = _ref.error,
|
|
29
|
+
_ref$type = _ref.type,
|
|
30
|
+
type = _ref$type === void 0 ? "date" : _ref$type,
|
|
31
|
+
onChange = _ref.onChange,
|
|
32
|
+
onEnterPressed = _ref.onEnterPressed;
|
|
33
|
+
_ref.format;
|
|
34
|
+
var min = _ref.min,
|
|
35
|
+
max = _ref.max,
|
|
36
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
var _useState = useState(""),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
actualValue = _useState2[0],
|
|
40
|
+
setActualValue = _useState2[1];
|
|
41
|
+
var _useState3 = useState(""),
|
|
42
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
+
inputValue = _useState4[0],
|
|
44
|
+
setInputValue = _useState4[1];
|
|
45
|
+
var deferred = useDeferredValue(value);
|
|
46
|
+
var inputFormat = useMemo(function () {
|
|
47
|
+
return type === "datetime" ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd";
|
|
48
|
+
}, [type]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
setActualValue(deferred !== null && deferred !== void 0 ? deferred : "");
|
|
51
|
+
setInputValue(deferred ? DateUtil.format(deferred, inputFormat) : "");
|
|
52
|
+
}, [deferred, inputFormat]);
|
|
53
|
+
var handleEnterPressed = useMemo(function () {
|
|
54
|
+
return handleEnter(onEnterPressed);
|
|
55
|
+
}, [onEnterPressed]);
|
|
56
|
+
var handleChange = useCallback(function (e) {
|
|
57
|
+
var value = e === null || e === void 0 ? void 0 : e.currentTarget.value;
|
|
58
|
+
if (value) {
|
|
59
|
+
var _parsed$toISOString;
|
|
60
|
+
var parsed = DateUtil.parseDate(value);
|
|
61
|
+
setActualValue(parsed === null || parsed === void 0 || (_parsed$toISOString = parsed.toISOString) === null || _parsed$toISOString === void 0 ? void 0 : _parsed$toISOString.call(parsed));
|
|
62
|
+
setInputValue(DateUtil.format(parsed, inputFormat));
|
|
63
|
+
onChange != null && startTransition(function () {
|
|
64
|
+
var _parsed$toISOString2;
|
|
65
|
+
return onChange(parsed === null || parsed === void 0 || (_parsed$toISOString2 = parsed.toISOString) === null || _parsed$toISOString2 === void 0 ? void 0 : _parsed$toISOString2.call(parsed));
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
setActualValue("");
|
|
69
|
+
setInputValue("");
|
|
70
|
+
onChange != null && startTransition(function () {
|
|
71
|
+
return onChange(null);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, [onChange, inputFormat]);
|
|
75
|
+
var handleDateChange = useCallback(function (value) {
|
|
76
|
+
if (value) {
|
|
77
|
+
var _parsed$toISOString3;
|
|
78
|
+
var parsed = DateUtil.parseDate(value);
|
|
79
|
+
setActualValue(parsed === null || parsed === void 0 || (_parsed$toISOString3 = parsed.toISOString) === null || _parsed$toISOString3 === void 0 ? void 0 : _parsed$toISOString3.call(parsed));
|
|
80
|
+
setInputValue(DateUtil.format(parsed, inputFormat));
|
|
81
|
+
onChange != null && startTransition(function () {
|
|
82
|
+
var _parsed$toISOString4;
|
|
83
|
+
return onChange(parsed === null || parsed === void 0 || (_parsed$toISOString4 = parsed.toISOString) === null || _parsed$toISOString4 === void 0 ? void 0 : _parsed$toISOString4.call(parsed));
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
setActualValue("");
|
|
87
|
+
setInputValue("");
|
|
88
|
+
onChange != null && startTransition(function () {
|
|
89
|
+
return onChange(null);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, [onChange, inputFormat]);
|
|
93
|
+
var arrowRef = useRef(null);
|
|
94
|
+
var _useState5 = useState(false),
|
|
95
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
96
|
+
isOpen = _useState6[0],
|
|
97
|
+
setIsOpen = _useState6[1];
|
|
98
|
+
var _useFloating = useFloating({
|
|
99
|
+
open: isOpen,
|
|
100
|
+
onOpenChange: function onOpenChange(open, _, reason) {
|
|
101
|
+
console.log(reason);
|
|
102
|
+
if (reason === "reference-press") return;
|
|
103
|
+
setIsOpen(open);
|
|
104
|
+
},
|
|
105
|
+
strategy: "fixed",
|
|
106
|
+
placement: "bottom-start",
|
|
107
|
+
whileElementsMounted: autoUpdate,
|
|
108
|
+
middleware: [shift({
|
|
109
|
+
padding: 8
|
|
110
|
+
}), flip(), offset(9), arrow({
|
|
111
|
+
element: arrowRef
|
|
112
|
+
})]
|
|
113
|
+
}),
|
|
114
|
+
refs = _useFloating.refs,
|
|
115
|
+
floatingStyles = _useFloating.floatingStyles,
|
|
116
|
+
context = _useFloating.context;
|
|
117
|
+
var focus = useFocus(context, {
|
|
118
|
+
enabled: !disabled
|
|
119
|
+
});
|
|
120
|
+
var click = useClick(context, {
|
|
121
|
+
enabled: !disabled,
|
|
122
|
+
toggle: false
|
|
123
|
+
});
|
|
124
|
+
var dismiss = useDismiss(context, {
|
|
125
|
+
referencePress: true
|
|
126
|
+
});
|
|
127
|
+
var _useInteractions = useInteractions([dismiss, click, focus]),
|
|
128
|
+
getReferenceProps = _useInteractions.getReferenceProps,
|
|
129
|
+
getFloatingProps = _useInteractions.getFloatingProps;
|
|
130
|
+
return /*#__PURE__*/jsxs(InputWrapper, _objectSpread(_objectSpread({
|
|
131
|
+
showClear: !!actualValue,
|
|
132
|
+
onClear: handleChange,
|
|
133
|
+
invalid: invalid,
|
|
134
|
+
readOnly: readOnly,
|
|
135
|
+
disabled: disabled,
|
|
136
|
+
required: required,
|
|
137
|
+
error: error
|
|
138
|
+
}, rest), {}, {
|
|
139
|
+
children: [/*#__PURE__*/jsx("input", _objectSpread(_objectSpread({
|
|
140
|
+
className: classNames("appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer", !value && "empty"),
|
|
141
|
+
"aria-invalid": invalid,
|
|
142
|
+
"aria-disabled": disabled,
|
|
143
|
+
"aria-readonly": readOnly,
|
|
144
|
+
"aria-errormessage": error,
|
|
145
|
+
placeholder: placeholder,
|
|
146
|
+
disabled: disabled,
|
|
147
|
+
readOnly: readOnly,
|
|
148
|
+
"data-testid": name,
|
|
149
|
+
name: name,
|
|
150
|
+
size: 1,
|
|
151
|
+
type: type === "datetime" ? "datetime-local" : "date",
|
|
152
|
+
autoComplete: "off",
|
|
153
|
+
autoFocus: autoFocus,
|
|
154
|
+
value: inputValue,
|
|
155
|
+
ref: mergeRefs(ref, refs.setReference)
|
|
156
|
+
}, getReferenceProps()), {}, {
|
|
157
|
+
onChange: handleChange,
|
|
158
|
+
onKeyDown: handleEnterPressed
|
|
159
|
+
})), isOpen && /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
160
|
+
ref: refs.setFloating,
|
|
161
|
+
style: _objectSpread({
|
|
162
|
+
zIndex: "var(--z-popover)"
|
|
163
|
+
}, floatingStyles),
|
|
164
|
+
className: "shadow-lg bg-base ring-1 ring-tint-100",
|
|
165
|
+
"data-ref": "dropdownBody"
|
|
166
|
+
}, getFloatingProps()), {}, {
|
|
167
|
+
children: [/*#__PURE__*/jsx(DatePanel, {
|
|
168
|
+
withTime: type === "datetime",
|
|
169
|
+
value: actualValue,
|
|
170
|
+
max: max,
|
|
171
|
+
min: min,
|
|
172
|
+
onChange: handleDateChange
|
|
173
|
+
}), /*#__PURE__*/jsx(FloatingArrow, {
|
|
174
|
+
ref: arrowRef,
|
|
175
|
+
context: context,
|
|
176
|
+
strokeWidth: 0.5,
|
|
177
|
+
className: "fill-base stroke-muted"
|
|
178
|
+
})]
|
|
179
|
+
}))]
|
|
180
|
+
}));
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export { DateInput };
|
package/dist/esm/input/Field.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
+
import { cloneChildren } from '@react-fabric/core';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
|
-
import {
|
|
7
|
-
import classes from '../internal/Field.module.css';
|
|
7
|
+
import { cloneElement } from 'react';
|
|
8
8
|
import { FieldWrapper } from '../internal/FieldWrapper.js';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
10
|
|
|
@@ -19,9 +19,9 @@ var Field = function Field(_ref) {
|
|
|
19
19
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
20
|
return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
21
21
|
children: /*#__PURE__*/jsx("div", {
|
|
22
|
-
className: classNames(
|
|
23
|
-
children:
|
|
24
|
-
return
|
|
22
|
+
className: classNames("fabric-fieldGroup", !plain && !noOutline && "outline", !plain && "bg-base", plain && "flex-wrap", "flex-1 rounded", !vertical && "flex"),
|
|
23
|
+
children: cloneChildren(children, function (child) {
|
|
24
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
25
25
|
"data-inner": true
|
|
26
26
|
});
|
|
27
27
|
})
|
package/dist/esm/input/File.js
CHANGED
|
@@ -9,7 +9,6 @@ import classNames from 'classnames';
|
|
|
9
9
|
import { useRef, useState, useDeferredValue, useMemo, useEffect, useCallback, Fragment } from 'react';
|
|
10
10
|
import { InputWrapper } from '../internal/InputWrapper.js';
|
|
11
11
|
import { handleEnter } from '../utils/eventHandlers.js';
|
|
12
|
-
import classes from './File.module.css';
|
|
13
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
14
13
|
|
|
15
14
|
var _excluded = ["ref", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "name", "accept", "showList", "multiple", "onChange", "onEnterPressed"];
|
|
@@ -90,7 +89,7 @@ var FileInput = function FileInput(_ref) {
|
|
|
90
89
|
} else {
|
|
91
90
|
var _e$target$files, _e$target$files$item, _e$target$files2;
|
|
92
91
|
setActualValue(e === null || e === void 0 || (_e$target$files = e.target.files) === null || _e$target$files === void 0 ? void 0 : _e$target$files.item(0));
|
|
93
|
-
onChange === null || onChange === void 0 || onChange((_e$target$files$item = e === null || e === void 0 || (_e$target$files2 = e.target.files) === null || _e$target$files2 === void 0 ? void 0 : _e$target$files2.item(0)) !== null && _e$target$files$item !== void 0 ? _e$target$files$item :
|
|
92
|
+
onChange === null || onChange === void 0 || onChange((_e$target$files$item = e === null || e === void 0 || (_e$target$files2 = e.target.files) === null || _e$target$files2 === void 0 ? void 0 : _e$target$files2.item(0)) !== null && _e$target$files$item !== void 0 ? _e$target$files$item : null);
|
|
94
93
|
if (!e && inputRef.current) inputRef.current.value = "";
|
|
95
94
|
}
|
|
96
95
|
}, [onChange, multiple, showList]);
|
|
@@ -139,7 +138,7 @@ var FileInput = function FileInput(_ref) {
|
|
|
139
138
|
})
|
|
140
139
|
}, rest), {}, {
|
|
141
140
|
children: /*#__PURE__*/jsx("input", {
|
|
142
|
-
className: classNames("appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0",
|
|
141
|
+
className: classNames("appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0", "fabric-fileInput", isArray(actualValue) && (actualValue === null || actualValue === void 0 ? void 0 : actualValue.length) && "text-(--fabric-bg)"),
|
|
143
142
|
"aria-invalid": invalid,
|
|
144
143
|
"aria-disabled": disabled,
|
|
145
144
|
"aria-readonly": readOnly,
|
package/dist/esm/input/Hidden.js
CHANGED
|
@@ -36,7 +36,9 @@ var HiddenInput = function HiddenInput(_ref) {
|
|
|
36
36
|
value = _ref$value === void 0 ? "" : _ref$value,
|
|
37
37
|
name = _ref.name;
|
|
38
38
|
useEffect(function () {
|
|
39
|
-
|
|
39
|
+
hiddenValue && setTimeout(function () {
|
|
40
|
+
onChange === null || onChange === void 0 || onChange(hiddenValue);
|
|
41
|
+
}, 50);
|
|
40
42
|
}, [hiddenValue]);
|
|
41
43
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
42
44
|
children: [/*#__PURE__*/jsx("input", {
|
package/dist/esm/input/Input.js
CHANGED
|
@@ -42,7 +42,7 @@ var Input = function Input(_ref) {
|
|
|
42
42
|
var handleChange = useCallback(function (e) {
|
|
43
43
|
var value = e === null || e === void 0 ? void 0 : e.target.value;
|
|
44
44
|
setActualValue(value !== null && value !== void 0 ? value : "");
|
|
45
|
-
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value :
|
|
45
|
+
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
46
46
|
}, [onchange]);
|
|
47
47
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
48
48
|
showClear: !!actualValue,
|
package/dist/esm/input/Number.js
CHANGED
|
@@ -42,7 +42,7 @@ var Number = function Number(_ref) {
|
|
|
42
42
|
var handleChange = useCallback(function (e) {
|
|
43
43
|
var number = e === null || e === void 0 ? void 0 : e.target.valueAsNumber;
|
|
44
44
|
setActualValue(number !== null && number !== void 0 ? number : "");
|
|
45
|
-
onChange === null || onChange === void 0 || onChange(number !== null && number !== void 0 ? number :
|
|
45
|
+
onChange === null || onChange === void 0 || onChange(number !== null && number !== void 0 ? number : null);
|
|
46
46
|
}, [onChange]);
|
|
47
47
|
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
48
48
|
showClear: !!actualValue,
|
|
@@ -50,7 +50,7 @@ var Password = function Password(_ref) {
|
|
|
50
50
|
var handleChange = useCallback(function (e) {
|
|
51
51
|
var value = e === null || e === void 0 ? void 0 : e.target.value;
|
|
52
52
|
setActualValue(value !== null && value !== void 0 ? value : "");
|
|
53
|
-
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value :
|
|
53
|
+
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
54
54
|
}, [onChange]);
|
|
55
55
|
return /*#__PURE__*/jsxs(InputWrapper, _objectSpread(_objectSpread({
|
|
56
56
|
showClear: !!actualValue,
|
package/dist/esm/input/Radio.js
CHANGED
|
@@ -51,7 +51,7 @@ var Radio = function Radio(_ref) {
|
|
|
51
51
|
autoComplete: "off",
|
|
52
52
|
onChange: handleChange
|
|
53
53
|
}, rest)), /*#__PURE__*/jsx(Icon, {
|
|
54
|
-
className: classNames("p-0.5 hidden peer-checked:inline-block", icon && !iconChecked && "bg-primary-500 text-white"),
|
|
54
|
+
className: classNames("p-0.5 hidden peer-checked:inline-block", icon && !iconChecked && "bg-primary-500 text-white!"),
|
|
55
55
|
color: invalid ? "danger" : "primary",
|
|
56
56
|
size: "1.25em",
|
|
57
57
|
icon: iconOn
|
|
@@ -2,26 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import {
|
|
5
|
+
import { cloneChildren } from '@react-fabric/core';
|
|
6
|
+
import { cloneElement } from 'react';
|
|
6
7
|
import { FieldWrapper } from '../internal/FieldWrapper.js';
|
|
7
8
|
import { jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
|
9
|
-
var _excluded = ["children", "name", "className", "onChange"];
|
|
10
|
+
var _excluded = ["children", "name", "className", "optionWidth", "onChange"];
|
|
10
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; }
|
|
11
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; }
|
|
12
13
|
var RadioGroup = function RadioGroup(_ref) {
|
|
13
14
|
var children = _ref.children,
|
|
14
15
|
name = _ref.name,
|
|
15
16
|
className = _ref.className,
|
|
17
|
+
optionWidth = _ref.optionWidth,
|
|
16
18
|
onChange = _ref.onChange,
|
|
17
19
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
18
20
|
return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
19
21
|
children: /*#__PURE__*/jsx("div", {
|
|
20
22
|
className: className,
|
|
21
|
-
children:
|
|
23
|
+
children: cloneChildren(children, function (child) {
|
|
22
24
|
return /*#__PURE__*/cloneElement(child, {
|
|
23
25
|
name: name,
|
|
24
|
-
onChange: onChange
|
|
26
|
+
onChange: onChange,
|
|
27
|
+
width: optionWidth
|
|
25
28
|
});
|
|
26
29
|
})
|
|
27
30
|
})
|
|
@@ -16,7 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
16
16
|
/**
|
|
17
17
|
* Number Range input
|
|
18
18
|
*/
|
|
19
|
-
var
|
|
19
|
+
var RangeSlider = function RangeSlider(_ref) {
|
|
20
20
|
var error = _ref.error;
|
|
21
21
|
_ref.name;
|
|
22
22
|
var value = _ref.value,
|
|
@@ -71,7 +71,7 @@ var Range = function Range(_ref) {
|
|
|
71
71
|
}, [showValue]);
|
|
72
72
|
var handleChange = useCallback(function (val) {
|
|
73
73
|
setActualValue(val !== null && val !== void 0 ? val : [min, max]);
|
|
74
|
-
onChange === null || onChange === void 0 || onChange(val !== null && val !== void 0 ? val :
|
|
74
|
+
onChange === null || onChange === void 0 || onChange(val !== null && val !== void 0 ? val : null);
|
|
75
75
|
}, [onChange, min, max]);
|
|
76
76
|
var minDisplay = useMemo(function () {
|
|
77
77
|
return /*#__PURE__*/jsx("span", {
|
|
@@ -166,4 +166,4 @@ var Range = function Range(_ref) {
|
|
|
166
166
|
}));
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
export {
|
|
169
|
+
export { RangeSlider };
|
package/dist/esm/input/Search.js
CHANGED
|
@@ -53,7 +53,7 @@ var Search = function Search(_ref) {
|
|
|
53
53
|
var value = e === null || e === void 0 ? void 0 : e.target.value;
|
|
54
54
|
refValue.current = value !== null && value !== void 0 ? value : "";
|
|
55
55
|
setActualValue(value !== null && value !== void 0 ? value : "");
|
|
56
|
-
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value :
|
|
56
|
+
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
57
57
|
|
|
58
58
|
// value was cleared so force fire onSearch
|
|
59
59
|
if (searchOnChange) {
|
package/dist/esm/input/Slider.js
CHANGED
|
@@ -73,7 +73,7 @@ var Slider = function Slider(_ref) {
|
|
|
73
73
|
var handleChange = useCallback(function (value) {
|
|
74
74
|
var val = useInfinity && value === max ? Infinity : value;
|
|
75
75
|
setActualValue(val !== null && val !== void 0 ? val : 0);
|
|
76
|
-
onChange === null || onChange === void 0 || onChange(val !== null && val !== void 0 ? val :
|
|
76
|
+
onChange === null || onChange === void 0 || onChange(val !== null && val !== void 0 ? val : null);
|
|
77
77
|
}, [onChange, max, useInfinity]);
|
|
78
78
|
var minDisplay = useMemo(function () {
|
|
79
79
|
return /*#__PURE__*/jsx("span", {
|
package/dist/esm/input/Switch.js
CHANGED
|
@@ -4,13 +4,13 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
4
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
5
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import { useState, useDeferredValue, useEffect, useCallback } from 'react';
|
|
7
|
+
import { useState, useDeferredValue, useEffect, useCallback, Fragment } from 'react';
|
|
8
8
|
import { ErrorIcon } from '../internal/ErrorIcon.js';
|
|
9
9
|
import '@react-fabric/utilities';
|
|
10
|
-
import { getBgClass, getColor } from '../utils/getColor.js';
|
|
10
|
+
import { getBgClass, getColor, getColorClass } from '../utils/getColor.js';
|
|
11
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
12
|
|
|
13
|
-
var _excluded = ["ref", "label", "checked", "invalid", "disabled", "error", "width", "color", "name", "defaultColor", "onChange"];
|
|
13
|
+
var _excluded = ["ref", "label", "checked", "invalid", "disabled", "error", "width", "color", "name", "onLabel", "offLabel", "onLabelColor", "offLabelColor", "defaultColor", "required", "onChange"];
|
|
14
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; }
|
|
15
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; }
|
|
16
16
|
var Switch = function Switch(_ref) {
|
|
@@ -23,8 +23,13 @@ var Switch = function Switch(_ref) {
|
|
|
23
23
|
width = _ref.width,
|
|
24
24
|
color = _ref.color;
|
|
25
25
|
_ref.name;
|
|
26
|
-
var
|
|
27
|
-
|
|
26
|
+
var onLabel = _ref.onLabel,
|
|
27
|
+
offLabel = _ref.offLabel,
|
|
28
|
+
onLabelColor = _ref.onLabelColor,
|
|
29
|
+
offLabelColor = _ref.offLabelColor,
|
|
30
|
+
defaultColor = _ref.defaultColor;
|
|
31
|
+
_ref.required;
|
|
32
|
+
var onChange = _ref.onChange,
|
|
28
33
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
34
|
var _useState = useState(false),
|
|
30
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -45,7 +50,7 @@ var Switch = function Switch(_ref) {
|
|
|
45
50
|
width: width
|
|
46
51
|
},
|
|
47
52
|
children: [/*#__PURE__*/jsxs("div", {
|
|
48
|
-
className: classNames(actualValue && getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative
|
|
53
|
+
className: classNames(actualValue && getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative grid grid-cols-2 items-center h-6 min-w-10 cursor-pointer rounded-full p-1 transition-colors duration-200 ease-in-out"),
|
|
49
54
|
style: {
|
|
50
55
|
backgroundColor: actualValue ? getColor(color) : getColor(defaultColor)
|
|
51
56
|
},
|
|
@@ -64,7 +69,24 @@ var Switch = function Switch(_ref) {
|
|
|
64
69
|
onChange: handleChange
|
|
65
70
|
}, rest)), /*#__PURE__*/jsx("span", {
|
|
66
71
|
"aria-hidden": "true",
|
|
67
|
-
className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-
|
|
72
|
+
className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-[100%]" : "translate-x-0", "pointer-events-none inline-block h-4 start-1 absolute rounded-full bg-white ring-0 transition duration-200 ease-in-out"),
|
|
73
|
+
style: {
|
|
74
|
+
width: "calc(50% - 0.25rem)"
|
|
75
|
+
}
|
|
76
|
+
}), (!!onLabel || !!offLabel) && /*#__PURE__*/jsxs(Fragment, {
|
|
77
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
78
|
+
className: "whitespace-nowrap text-xs px-1 ".concat(getColorClass(onLabelColor !== null && onLabelColor !== void 0 ? onLabelColor : "white")),
|
|
79
|
+
style: {
|
|
80
|
+
color: getColor(onLabelColor)
|
|
81
|
+
},
|
|
82
|
+
children: onLabel !== null && onLabel !== void 0 ? onLabel : " "
|
|
83
|
+
}), /*#__PURE__*/jsx("span", {
|
|
84
|
+
className: "whitespace-nowrap text-xs px-1 ".concat(getColorClass(offLabelColor !== null && offLabelColor !== void 0 ? offLabelColor : "base")),
|
|
85
|
+
style: {
|
|
86
|
+
color: getColor(offLabelColor)
|
|
87
|
+
},
|
|
88
|
+
children: offLabel !== null && offLabel !== void 0 ? offLabel : " "
|
|
89
|
+
})]
|
|
68
90
|
})]
|
|
69
91
|
}), /*#__PURE__*/jsx(ErrorIcon, {
|
|
70
92
|
invalid: invalid,
|
|
@@ -9,7 +9,7 @@ import { handleEnter } from '../utils/eventHandlers.js';
|
|
|
9
9
|
import '@react-fabric/utilities';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
11
|
|
|
12
|
-
var _excluded = ["ref", "value", "name", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "rows", "maxRows", "variableRows", "onChange", "onEnterPressed"];
|
|
12
|
+
var _excluded = ["ref", "value", "name", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "rows", "maxRows", "variableRows", "expandable", "onChange", "onEnterPressed"];
|
|
13
13
|
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
14
|
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
15
|
var Textarea = function Textarea(_ref) {
|
|
@@ -27,6 +27,7 @@ var Textarea = function Textarea(_ref) {
|
|
|
27
27
|
_ref$maxRows = _ref.maxRows,
|
|
28
28
|
maxRows = _ref$maxRows === void 0 ? 12 : _ref$maxRows,
|
|
29
29
|
variableRows = _ref.variableRows,
|
|
30
|
+
expandable = _ref.expandable,
|
|
30
31
|
onChange = _ref.onChange,
|
|
31
32
|
onEnterPressed = _ref.onEnterPressed,
|
|
32
33
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -46,7 +47,7 @@ var Textarea = function Textarea(_ref) {
|
|
|
46
47
|
var handleChange = useCallback(function (e) {
|
|
47
48
|
var value = e === null || e === void 0 ? void 0 : e.target.value;
|
|
48
49
|
setActualValue(value !== null && value !== void 0 ? value : "");
|
|
49
|
-
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value :
|
|
50
|
+
onChange === null || onChange === void 0 || onChange(value !== null && value !== void 0 ? value : null);
|
|
50
51
|
}, [onChange]);
|
|
51
52
|
useEffect(function () {
|
|
52
53
|
if (variableRows) {
|
|
@@ -65,6 +66,7 @@ var Textarea = function Textarea(_ref) {
|
|
|
65
66
|
disabled: disabled,
|
|
66
67
|
required: required,
|
|
67
68
|
wrapperRef: wrapperRef,
|
|
69
|
+
textareaExpandable: expandable,
|
|
68
70
|
textarea: true
|
|
69
71
|
}, rest), {}, {
|
|
70
72
|
children: /*#__PURE__*/jsx("textarea", {
|
|
@@ -83,7 +85,9 @@ var Textarea = function Textarea(_ref) {
|
|
|
83
85
|
autoFocus: autoFocus,
|
|
84
86
|
value: actualValue,
|
|
85
87
|
onChange: handleChange,
|
|
86
|
-
onKeyDown: handleEnter(onEnterPressed
|
|
88
|
+
onKeyDown: handleEnter(onEnterPressed, {
|
|
89
|
+
preventDefault: !!onEnterPressed
|
|
90
|
+
})
|
|
87
91
|
})
|
|
88
92
|
}));
|
|
89
93
|
};
|
|
@@ -20,7 +20,7 @@ var ErrorIcon = function ErrorIcon(_ref) {
|
|
|
20
20
|
label: t((_error$values$label = (_error$values = error.values) === null || _error$values === void 0 ? void 0 : _error$values.label) !== null && _error$values$label !== void 0 ? _error$values$label : "form:badkey", (_error$values2 = error.values) === null || _error$values2 === void 0 ? void 0 : _error$values2.path)
|
|
21
21
|
}) : {}),
|
|
22
22
|
placement: "bottom",
|
|
23
|
-
color: "danger",
|
|
23
|
+
color: "danger-200",
|
|
24
24
|
children: /*#__PURE__*/jsx(Icon, {
|
|
25
25
|
className: "flex-content first:ms-2 self-center",
|
|
26
26
|
color: "danger",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import classes from './Field.module.css';
|
|
5
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
5
|
|
|
7
6
|
/*
|
|
@@ -42,14 +41,14 @@ var FieldWrapper = function FieldWrapper(_ref) {
|
|
|
42
41
|
className = _ref.className,
|
|
43
42
|
isInner = _ref["data-inner"];
|
|
44
43
|
return /*#__PURE__*/jsxs("div", {
|
|
45
|
-
className: classNames(
|
|
44
|
+
className: classNames("fabric-fieldWrapper", className, inline ? "flex flex-nowrap gap-1" : "block"),
|
|
46
45
|
"data-ref": "fieldWrapper",
|
|
47
46
|
style: {
|
|
48
47
|
width: width,
|
|
49
48
|
flexBasis: width
|
|
50
49
|
},
|
|
51
50
|
children: [!isInner && /*#__PURE__*/jsxs("div", {
|
|
52
|
-
className: "flex flex-nowrap flex-content gap-1 py-0.5 px-2",
|
|
51
|
+
className: "flex flex-nowrap flex-content items-end gap-1 py-0.5 px-2",
|
|
53
52
|
style: {
|
|
54
53
|
width: inline ? labelWidth : undefined
|
|
55
54
|
},
|
|
@@ -64,6 +63,8 @@ var FieldWrapper = function FieldWrapper(_ref) {
|
|
|
64
63
|
}), required && /*#__PURE__*/jsx("span", {
|
|
65
64
|
className: "text-danger-500 select-none flex-content text-[10px]",
|
|
66
65
|
children: "\u273D"
|
|
66
|
+
}), /*#__PURE__*/jsx("div", {
|
|
67
|
+
className: "flex-1"
|
|
67
68
|
}), appendLabel && /*#__PURE__*/jsx("span", {
|
|
68
69
|
className: "flex-content",
|
|
69
70
|
children: appendLabel
|
|
@@ -3,33 +3,34 @@
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
5
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
|
-
import { FloatingPortal } from '@floating-ui/react';
|
|
7
6
|
import { Icon, CoreIcons } from '@react-fabric/core';
|
|
8
7
|
import { isString } from '@react-fabric/utilities';
|
|
9
8
|
import classNames from 'classnames';
|
|
10
9
|
import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
|
|
11
10
|
import { Fragment, jsxs, jsx } from 'react/jsx-runtime';
|
|
12
11
|
import { ErrorIcon } from './ErrorIcon.js';
|
|
13
|
-
import classes from './Field.module.css';
|
|
14
12
|
import { FieldWrapper } from './FieldWrapper.js';
|
|
15
13
|
|
|
16
|
-
var _excluded = ["invalid", "error", "allowClear", "showClear", "decorateStart", "decorateEnd", "children", "onClear", "noOutline", "noBorder", "textarea", "data-inner", "data-open", "floatingExpand", "wrapperRef", "width"];
|
|
14
|
+
var _excluded = ["invalid", "error", "allowClear", "showClear", "decorateStart", "decorateEnd", "decorateEndShowWhenEmpty", "decorateEndHideWhenEmpty", "children", "onClear", "noOutline", "noBorder", "textarea", "textareaExpandable", "data-inner", "data-open", "floatingExpand", "wrapperRef", "width"];
|
|
17
15
|
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; }
|
|
18
16
|
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; }
|
|
19
17
|
var InputWrapper = function InputWrapper(_ref) {
|
|
20
|
-
var _elRef$current;
|
|
21
18
|
var invalid = _ref.invalid,
|
|
22
19
|
error = _ref.error,
|
|
23
20
|
allowClear = _ref.allowClear,
|
|
24
21
|
showClear = _ref.showClear,
|
|
25
22
|
decorateStart = _ref.decorateStart,
|
|
26
23
|
decorateEnd = _ref.decorateEnd,
|
|
24
|
+
decorateEndShowWhenEmpty = _ref.decorateEndShowWhenEmpty,
|
|
25
|
+
decorateEndHideWhenEmpty = _ref.decorateEndHideWhenEmpty,
|
|
27
26
|
children = _ref.children,
|
|
28
27
|
onClear = _ref.onClear,
|
|
29
28
|
noOutline = _ref.noOutline,
|
|
30
29
|
noBorder = _ref.noBorder,
|
|
31
30
|
_ref$textarea = _ref.textarea,
|
|
32
31
|
textarea = _ref$textarea === void 0 ? false : _ref$textarea,
|
|
32
|
+
_ref$textareaExpandab = _ref.textareaExpandable,
|
|
33
|
+
textareaExpandable = _ref$textareaExpandab === void 0 ? false : _ref$textareaExpandab,
|
|
33
34
|
isInner = _ref["data-inner"];
|
|
34
35
|
_ref["data-open"];
|
|
35
36
|
var floatingExpand = _ref.floatingExpand,
|
|
@@ -67,13 +68,13 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
67
68
|
var el = /*#__PURE__*/jsxs("div", {
|
|
68
69
|
role: "none",
|
|
69
70
|
ref: wrapperRef,
|
|
70
|
-
className: classNames(
|
|
71
|
+
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"),
|
|
71
72
|
onKeyDown: function onKeyDown(e) {
|
|
72
|
-
return e.key === "Escape" && setExpanded(false);
|
|
73
|
+
return e.key === "Escape" && isExpanded && (setExpanded(false), e.stopPropagation());
|
|
73
74
|
},
|
|
74
75
|
children: [decorateStart && /*#__PURE__*/jsx("div", {
|
|
75
76
|
onClickCapture: doFocus,
|
|
76
|
-
className: classNames(
|
|
77
|
+
className: classNames("fabric-decorate", "text-muted leading-none flex-content", isString(decorateStart) && "px-1"),
|
|
77
78
|
children: decorateStart
|
|
78
79
|
}), /*#__PURE__*/jsx(ErrorIcon, {
|
|
79
80
|
invalid: invalid,
|
|
@@ -81,12 +82,12 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
81
82
|
}), children, allowClear && showClear && /*#__PURE__*/jsx(Icon, {
|
|
82
83
|
icon: CoreIcons.close,
|
|
83
84
|
onClick: handleClear,
|
|
84
|
-
className: classNames("text-tint-500 hover:text-tint-700 p-1 z-1 flex-content",
|
|
85
|
+
className: classNames("text-tint-500 hover:text-tint-700 p-1 z-1 flex-content", "fabric-inputClear", textarea && "self-start mt-1 me-1")
|
|
85
86
|
}), decorateEnd && /*#__PURE__*/jsx("div", {
|
|
86
87
|
onClickCapture: doFocus,
|
|
87
|
-
className: classNames(
|
|
88
|
+
className: classNames("fabric-decorate", "text-muted leading-none flex-content", isString(decorateEnd) && "px-1", decorateEndHideWhenEmpty && "peer-placeholder-shown:hidden", decorateEndShowWhenEmpty && "hidden peer-placeholder-shown:inline-block"),
|
|
88
89
|
children: decorateEnd
|
|
89
|
-
}),
|
|
90
|
+
}), textareaExpandable && /*#__PURE__*/jsx(Icon, {
|
|
90
91
|
onClick: function onClick() {
|
|
91
92
|
return setExpanded(!isExpanded);
|
|
92
93
|
},
|
|
@@ -95,17 +96,14 @@ var InputWrapper = function InputWrapper(_ref) {
|
|
|
95
96
|
})]
|
|
96
97
|
});
|
|
97
98
|
return /*#__PURE__*/jsx(Wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
|
|
98
|
-
children: /*#__PURE__*/
|
|
99
|
+
children: /*#__PURE__*/jsx("div", {
|
|
99
100
|
ref: elRef,
|
|
100
|
-
className: "flex-1 relative min-h-8",
|
|
101
|
+
className: "flex-1 relative min-h-8 flex flex-col flex-nowrap",
|
|
101
102
|
style: {
|
|
102
103
|
width: width,
|
|
103
104
|
flexBasis: width
|
|
104
105
|
},
|
|
105
|
-
children:
|
|
106
|
-
root: (_elRef$current = elRef.current) === null || _elRef$current === void 0 ? void 0 : _elRef$current.closest(".theme-base"),
|
|
107
|
-
children: el
|
|
108
|
-
})]
|
|
106
|
+
children: el
|
|
109
107
|
})
|
|
110
108
|
}));
|
|
111
109
|
};
|
|
@@ -243,7 +243,7 @@ var AutoComplete = function AutoComplete(_ref) {
|
|
|
243
243
|
visuallyHiddenDismiss: true,
|
|
244
244
|
children: /*#__PURE__*/jsx(Options, _objectSpread(_objectSpread({
|
|
245
245
|
ref: refs.setFloating,
|
|
246
|
-
className: "outline shadow-lg max-h-[40vh] z-
|
|
246
|
+
className: "outline shadow-lg max-h-[40vh] z-(--z-popover)",
|
|
247
247
|
style: _objectSpread({
|
|
248
248
|
width: (_refs$reference$curre = refs.reference.current) === null || _refs$reference$curre === void 0 ? void 0 : _refs$reference$curre.getBoundingClientRect().width
|
|
249
249
|
}, floatingStyles)
|