@react-fabric/form 1.0.0-beta.3 → 1.0.0-beta.30

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.
Files changed (66) hide show
  1. package/dist/cjs/form/Form.js +12 -5
  2. package/dist/cjs/input/ArrayInput.js +35 -23
  3. package/dist/cjs/input/ColorInput.js +68 -26
  4. package/dist/cjs/input/ColorPicker.js +0 -33
  5. package/dist/cjs/input/ColorPicker.module.css +1 -1
  6. package/dist/cjs/input/Field.js +3 -2
  7. package/dist/cjs/input/File.module.css +1 -1
  8. package/dist/cjs/input/Hidden.js +3 -1
  9. package/dist/cjs/input/RadioGroup.js +6 -3
  10. package/dist/cjs/input/Switch.js +25 -4
  11. package/dist/cjs/input/Textarea.js +6 -2
  12. package/dist/cjs/internal/FieldWrapper.js +3 -1
  13. package/dist/cjs/internal/InputWrapper.js +7 -10
  14. package/dist/cjs/select/List.js +41 -20
  15. package/dist/cjs/select/Options.js +2 -2
  16. package/dist/cjs/select/Select.js +10 -7
  17. package/dist/cjs/select/useSelect.js +12 -7
  18. package/dist/cjs/utils/getColor.js +6 -0
  19. package/dist/esm/form/Form.js +13 -6
  20. package/dist/esm/input/ArrayInput.js +37 -25
  21. package/dist/esm/input/ColorInput.js +70 -28
  22. package/dist/esm/input/ColorPicker.js +0 -33
  23. package/dist/esm/input/ColorPicker.module.css +1 -1
  24. package/dist/esm/input/Field.js +4 -3
  25. package/dist/esm/input/File.module.css +1 -1
  26. package/dist/esm/input/Hidden.js +3 -1
  27. package/dist/esm/input/RadioGroup.js +7 -4
  28. package/dist/esm/input/Switch.js +27 -6
  29. package/dist/esm/input/Textarea.js +6 -2
  30. package/dist/esm/internal/FieldWrapper.js +3 -1
  31. package/dist/esm/internal/InputWrapper.js +7 -10
  32. package/dist/esm/select/List.js +42 -21
  33. package/dist/esm/select/Options.js +2 -2
  34. package/dist/esm/select/Select.js +10 -7
  35. package/dist/esm/select/useSelect.js +13 -8
  36. package/dist/esm/utils/getColor.js +6 -1
  37. package/dist/types/input/ArrayInput.d.ts +20 -3
  38. package/dist/types/input/RadioGroup.d.ts +18 -2
  39. package/dist/types/input/Switch.d.ts +7 -3
  40. package/dist/types/input/Textarea.d.ts +5 -1
  41. package/dist/types/internal/InputWrapper.d.ts +1 -1
  42. package/dist/types/select/List.d.ts +1 -1
  43. package/dist/types/types/index.d.ts +2 -2
  44. package/package.json +7 -7
  45. package/src/form/Form.tsx +13 -5
  46. package/src/input/ArrayInput.tsx +78 -40
  47. package/src/input/ColorInput.tsx +96 -31
  48. package/src/input/ColorPicker.module.css +19 -5
  49. package/src/input/ColorPicker.tsx +0 -33
  50. package/src/input/Field.tsx +6 -8
  51. package/src/input/File.module.css +18 -4
  52. package/src/input/Hidden.tsx +3 -1
  53. package/src/input/Input.tsx +1 -1
  54. package/src/input/Number.tsx +1 -1
  55. package/src/input/Password.tsx +1 -1
  56. package/src/input/RadioGroup.tsx +27 -4
  57. package/src/input/Search.tsx +1 -1
  58. package/src/input/Switch.tsx +40 -6
  59. package/src/input/Textarea.tsx +10 -2
  60. package/src/internal/FieldWrapper.tsx +2 -1
  61. package/src/internal/InputWrapper.tsx +8 -11
  62. package/src/select/List.tsx +34 -7
  63. package/src/select/Options.tsx +1 -1
  64. package/src/select/Select.tsx +4 -1
  65. package/src/select/useSelect.tsx +27 -18
  66. package/src/types/index.ts +5 -2
@@ -32,6 +32,9 @@ var Form = function Form(_ref) {
32
32
  resolver: schema && yup.yupResolver(schema),
33
33
  defaultValues: defaultValues
34
34
  });
35
+ react.useEffect(function () {
36
+ form.reset();
37
+ }, []);
35
38
  var _useTransition = react.useTransition(),
36
39
  _useTransition2 = _slicedToArray(_useTransition, 2),
37
40
  startTransition = _useTransition2[1];
@@ -89,13 +92,17 @@ var Form = function Form(_ref) {
89
92
  return form.getValues();
90
93
  },
91
94
  setValues: function setValues(v) {
92
- return form.reset(v);
95
+ return setTimeout(function () {
96
+ return form.reset(v);
97
+ }, 50);
93
98
  },
94
99
  setValue: function setValue(k, v) {
95
- return form.setValue(k, v, {
96
- shouldDirty: false,
97
- shouldTouch: false
98
- });
100
+ return setTimeout(function () {
101
+ return form.setValue(k, v, {
102
+ shouldDirty: false,
103
+ shouldTouch: false
104
+ });
105
+ }, 50);
99
106
  }
100
107
  };
101
108
  }, [onSubmit, form, form.formState, defaultValues]);
@@ -16,17 +16,18 @@ var modifiers = require('@dnd-kit/modifiers');
16
16
  var utilities = require('@dnd-kit/utilities');
17
17
  var jsxRuntime = require('react/jsx-runtime');
18
18
 
19
- var _excluded = ["name", "children", "addLabel", "fixedList", "focusName", "onAdd", "arrayRef", "enableSorting", "disabled", "readOnly", "minItems"];
19
+ var _excluded = ["name", "children", "addLabel", "fixedList", "focusName", "buttonPosition", "onAdd", "arrayRef", "enableSorting", "disabled", "readOnly", "minItems", "maxItems"];
20
20
  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; }
21
21
  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; }
22
22
  var ArrayInput = function ArrayInput(_ref) {
23
- var _error$values$label, _error$values, _error$values2;
24
23
  var name = _ref.name,
25
24
  children = _ref.children,
26
25
  addLabel = _ref.addLabel,
27
26
  fixedList = _ref.fixedList,
28
27
  _ref$focusName = _ref.focusName,
29
28
  focusName = _ref$focusName === void 0 ? "" : _ref$focusName,
29
+ _ref$buttonPosition = _ref.buttonPosition,
30
+ buttonPosition = _ref$buttonPosition === void 0 ? "bottom" : _ref$buttonPosition,
30
31
  onAdd = _ref.onAdd,
31
32
  arrayRef = _ref.arrayRef,
32
33
  enableSorting = _ref.enableSorting,
@@ -36,6 +37,8 @@ var ArrayInput = function ArrayInput(_ref) {
36
37
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
37
38
  _ref$minItems = _ref.minItems,
38
39
  minItems = _ref$minItems === void 0 ? 0 : _ref$minItems,
40
+ _ref$maxItems = _ref.maxItems,
41
+ maxItems = _ref$maxItems === void 0 ? Number.MAX_SAFE_INTEGER : _ref$maxItems,
39
42
  rest = _objectWithoutProperties(_ref, _excluded);
40
43
  var _useTranslation = reactI18next.useTranslation("form"),
41
44
  t = _useTranslation.t;
@@ -127,9 +130,37 @@ var ArrayInput = function ArrayInput(_ref) {
127
130
  }, [enableSorting]);
128
131
  // @ts-expect-error ignore
129
132
  SortableItem.displayName = "SortableItem";
133
+ var addButton = react.useMemo(function () {
134
+ var _error$values$label, _error$values, _error$values2;
135
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
136
+ className: "flex justify-end",
137
+ children: /*#__PURE__*/jsxRuntime.jsx(core$1.Tooltip, {
138
+ color: "danger",
139
+ content: utilities$1.isString(error) ? "".concat(error) : t(error === null || error === void 0 ? void 0 : error.key, error !== null && error !== void 0 && error.values ? _objectSpread(_objectSpread({}, error === null || error === void 0 ? void 0 : error.values), {}, {
140
+ 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)
141
+ }) : {}),
142
+ children: /*#__PURE__*/jsxRuntime.jsx(core$1.Button, {
143
+ size: "sm",
144
+ "aria-label": "Add item",
145
+ icon: core$1.CoreIcons.insert,
146
+ onClick: function onClick() {
147
+ return handleAdd(onAdd === null || onAdd === void 0 ? void 0 : onAdd());
148
+ },
149
+ "data-invalid": !!error,
150
+ disabled: !!disabled || readOnly || fields.length > maxItems,
151
+ className: classNames(ArrayInput_module.addButton, "me-10"),
152
+ children: addLabel !== null && addLabel !== void 0 ? addLabel : t("addArray")
153
+ })
154
+ })
155
+ });
156
+ }, [error, fields, handleAdd, disabled, readOnly, addLabel, maxItems]);
130
157
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
131
158
  className: ArrayInput_module.arrayInput,
132
159
  children: [/*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
160
+ appendLabel: /*#__PURE__*/jsxRuntime.jsx("div", {
161
+ className: "-me-2",
162
+ children: !fixedList && onAdd && buttonPosition !== "bottom" && addButton
163
+ }),
133
164
  children: /*#__PURE__*/jsxRuntime.jsx(Wrapper, {
134
165
  children: fields.map(function (item, index) {
135
166
  return /*#__PURE__*/jsxRuntime.jsxs(SortableItem, {
@@ -138,7 +169,7 @@ var ArrayInput = function ArrayInput(_ref) {
138
169
  children: [typeof children === "function" ? children({
139
170
  index: index,
140
171
  name: "".concat(name, ".").concat(index)
141
- }) : react.Children.map(children, function (child) {
172
+ }) : core$1.cloneChildren(children, function (child) {
142
173
  return /*#__PURE__*/react.cloneElement(child, Object.assign({
143
174
  disabled: disabled,
144
175
  readOnly: readOnly,
@@ -163,26 +194,7 @@ var ArrayInput = function ArrayInput(_ref) {
163
194
  }, item.id);
164
195
  })
165
196
  })
166
- })), !fixedList && onAdd && /*#__PURE__*/jsxRuntime.jsx("div", {
167
- className: "flex justify-end",
168
- children: /*#__PURE__*/jsxRuntime.jsx(core$1.Tooltip, {
169
- color: "danger",
170
- content: utilities$1.isString(error) ? "".concat(error) : t(error === null || error === void 0 ? void 0 : error.key, error !== null && error !== void 0 && error.values ? _objectSpread(_objectSpread({}, error === null || error === void 0 ? void 0 : error.values), {}, {
171
- 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)
172
- }) : {}),
173
- children: /*#__PURE__*/jsxRuntime.jsx(core$1.Button, {
174
- "aria-label": "Add item",
175
- icon: core$1.CoreIcons.insert,
176
- onClick: function onClick() {
177
- return handleAdd(onAdd());
178
- },
179
- "data-invalid": !!error,
180
- disabled: !!disabled || readOnly,
181
- className: classNames(ArrayInput_module.addButton, "me-10"),
182
- children: addLabel !== null && addLabel !== void 0 ? addLabel : t("addArray")
183
- })
184
- })
185
- })]
197
+ })), !fixedList && onAdd && buttonPosition !== "top" && addButton]
186
198
  });
187
199
  };
188
200
 
@@ -3,6 +3,7 @@
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
5
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
+ var react$1 = require('@floating-ui/react');
6
7
  var core = require('@react-fabric/core');
7
8
  var utilities = require('@react-fabric/utilities');
8
9
  var classNames = require('classnames');
@@ -43,41 +44,82 @@ var ColorInput = function ColorInput(_ref) {
43
44
  return onChange(e);
44
45
  });
45
46
  }, [onChange]);
47
+ var arrowRef = react.useRef(null);
48
+ var _useState3 = react.useState(false),
49
+ _useState4 = _slicedToArray(_useState3, 2),
50
+ isOpen = _useState4[0],
51
+ setIsOpen = _useState4[1];
52
+ var _useFloating = react$1.useFloating({
53
+ open: isOpen,
54
+ onOpenChange: function onOpenChange(open, _, reason) {
55
+ if (reason === "reference-press") return;
56
+ setIsOpen(open);
57
+ },
58
+ strategy: "fixed",
59
+ placement: "bottom",
60
+ whileElementsMounted: react$1.autoUpdate,
61
+ middleware: [react$1.shift({
62
+ padding: 8
63
+ }), react$1.flip(), react$1.offset(9), react$1.arrow({
64
+ element: arrowRef
65
+ })]
66
+ }),
67
+ refs = _useFloating.refs,
68
+ floatingStyles = _useFloating.floatingStyles,
69
+ context = _useFloating.context;
70
+ var click = react$1.useClick(context, {
71
+ enabled: !disabled
72
+ });
73
+ var dismiss = react$1.useDismiss(context, {
74
+ referencePress: true
75
+ });
76
+ var _useInteractions = react$1.useInteractions([dismiss, click]),
77
+ getReferenceProps = _useInteractions.getReferenceProps,
78
+ getFloatingProps = _useInteractions.getFloatingProps;
46
79
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
47
80
  className: classNames("flex-content min-h-[1.5em] min-w-[3.5em] self-stretch flex items-center outline-tint-200 rounded", !disabled && "bg-base", !noOutline && "bg-[var(--fabric-input)] outline overflow-hidden"),
48
81
  children: [decorateStart && /*#__PURE__*/jsxRuntime.jsx("div", {
49
82
  className: classNames("text-muted leading-none flex-content", utilities.isString(decorateStart) && "px-2"),
50
83
  children: decorateStart
51
- }), /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
52
- showArrow: true,
53
- disabled: disabled,
54
- children: [/*#__PURE__*/jsxRuntime.jsx("button", {
55
- "data-ref": "button",
56
- className: "flex-1 flex items-center",
57
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
58
- role: "none",
59
- className: "h-[1.5em] min-w-[1.5em] flex-1 flex items-center justify-center self-stretch cursor-pointer m-[0.25em] rounded outline outline-tint-100",
60
- style: {
61
- backgroundColor: actualValue,
62
- opacity: disabled ? 0.65 : 1,
63
- pointerEvents: disabled ? "none" : undefined
64
- },
65
- onClick: function onClick(e) {
66
- var _e$currentTarget$next;
67
- return (_e$currentTarget$next = e.currentTarget.nextElementSibling) === null || _e$currentTarget$next === void 0 ? void 0 : _e$currentTarget$next.focus();
68
- },
69
- children: !actualValue && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
70
- size: "md",
71
- className: "text-muted",
72
- icon: core.CoreIcons.colorSwatch
73
- })
84
+ }), /*#__PURE__*/jsxRuntime.jsx("button", _objectSpread(_objectSpread({
85
+ "data-ref": "button",
86
+ className: "flex-1 flex items-center",
87
+ ref: refs.setReference
88
+ }, getReferenceProps()), {}, {
89
+ "data-inner-clickable": "true",
90
+ "data-dropdown-open": isOpen ? true : undefined,
91
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
92
+ role: "none",
93
+ className: "h-[1.5em] min-w-[1.5em] flex-1 flex items-center justify-center self-stretch cursor-pointer m-[0.25em] rounded outline outline-tint-100",
94
+ style: {
95
+ backgroundColor: actualValue,
96
+ opacity: disabled ? 0.65 : 1,
97
+ pointerEvents: disabled ? "none" : undefined
98
+ },
99
+ children: !actualValue && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
100
+ size: "md",
101
+ className: "text-muted",
102
+ icon: core.CoreIcons.colorSwatch
74
103
  })
75
- }), /*#__PURE__*/jsxRuntime.jsx(ColorPicker.ColorPicker, _objectSpread(_objectSpread({}, rest), {}, {
104
+ })
105
+ })), isOpen && /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
106
+ ref: refs.setFloating,
107
+ style: _objectSpread({
108
+ zIndex: "var(--z-popover)"
109
+ }, floatingStyles),
110
+ "data-ref": "dropdownBody"
111
+ }, getFloatingProps()), {}, {
112
+ children: [/*#__PURE__*/jsxRuntime.jsx(ColorPicker.ColorPicker, _objectSpread(_objectSpread({}, rest), {}, {
76
113
  onChange: handleChange,
77
114
  defaultColor: defaultColor,
78
115
  value: actualValue
79
- }))]
80
- }), !disabled && showPicker && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
116
+ })), /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingArrow, {
117
+ ref: arrowRef,
118
+ context: context,
119
+ strokeWidth: 0.5,
120
+ className: "fill-base stroke-muted"
121
+ })]
122
+ })), !disabled && showPicker && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
81
123
  icon: core.CoreIcons.colorPicker,
82
124
  onClick: function onClick() {
83
125
  return window.EyeDropper && new window.EyeDropper().open().then(function (resp) {
@@ -41,12 +41,9 @@ var ColorPicker = /*#__PURE__*/react.memo(function (_ref) {
41
41
  styles: {
42
42
  "default": {
43
43
  hue: {
44
- borderRadius: "99px",
45
44
  boxShadow: "0 0 1px 1px var(--color-shadow)"
46
45
  },
47
46
  alpha: {
48
- height: "1rem",
49
- borderRadius: "99px",
50
47
  backgroundColor: "var(--fabric-bg)",
51
48
  boxShadow: "0 0 1px 1px var(--color-shadow)"
52
49
  },
@@ -63,36 +60,6 @@ var ColorPicker = /*#__PURE__*/react.memo(function (_ref) {
63
60
  backgroundColor: "var(--fabric-bg)",
64
61
  boxShadow: "0 0 0 1px var(--color-shadow), 0 0 8px var(--fabric-shadow)"
65
62
  },
66
- Alpha: {
67
- alpha: {
68
- paddingRight: "calc(1rem - 2px)"
69
- },
70
- slider: {
71
- width: "calc(1rem - 2px)",
72
- borderRadius: "99px",
73
- height: "calc(1rem - 2px)",
74
- transform: "none"
75
- }
76
- },
77
- Hue: {
78
- hue: {
79
- paddingRight: "calc(1rem - 2px)"
80
- },
81
- slider: {
82
- width: "calc(1rem - 2px)",
83
- borderRadius: "99px",
84
- height: "calc(1rem - 2px)",
85
- transform: "none"
86
- }
87
- },
88
- Saturation: {
89
- circle: {
90
- width: "0.5rem",
91
- borderRadius: "99px",
92
- height: "0.5rem",
93
- transform: "translate(-0.25rem, -0.25rem)"
94
- }
95
- },
96
63
  checkboard: {
97
64
  white: "transparent",
98
65
  black: "red"
@@ -1 +1 @@
1
- @layer comp{.colorPicker{--color-shadow:theme(borderColor.base);& input{@apply bg-base text-base !border !border-solid !rounded-sm !border-base focus:!border-primary !shadow-none;line-height:2;padding:0 4px!important}& label{@apply !text-base}& :global(.flexbox-fix){@apply !border-t-muted justify-center;&>div>div{@apply text-center}& span>div{box-shadow:inset 0 0 1px 1px theme(borderColor.base)!important}}}}
1
+ @layer comp{.colorPicker{--color-shadow:theme(borderColor.base);& input{background-color:theme(backgroundColor.base);border:1px solid theme(borderColor.base);border-radius:theme(borderRadius.sm);box-shadow:none;color:theme(textColor.base);line-height:2;padding:0 4px!important;&:focus{border-color:theme(borderColor.primary.DEFAULT)}}& label{color:theme(textColor.base)}& :global(.flexbox-fix){border-color:theme(borderColor.muted);justify-content:center;&>div>div{text-align:center}& span>div{box-shadow:inset 0 0 1px 1px theme(borderColor.base)!important}}& :global(.saturation-black)~div{pointer-events:none}}}
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var core = require('@react-fabric/core');
5
6
  var classNames = require('classnames');
6
7
  var react = require('react');
7
8
  var Field_module = require('../internal/Field.module.css');
@@ -20,8 +21,8 @@ var Field = function Field(_ref) {
20
21
  return /*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
21
22
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
22
23
  className: classNames(Field_module.fieldGroup, !plain && !noOutline && "outline", !plain && "bg-base", "flex-1 rounded", !vertical && "flex flex-nowrap"),
23
- children: react.Children.map(children, function (child) {
24
- return child && /*#__PURE__*/react.cloneElement(child, {
24
+ children: core.cloneChildren(children, function (child) {
25
+ return /*#__PURE__*/react.cloneElement(child, {
25
26
  "data-inner": true
26
27
  });
27
28
  })
@@ -1 +1 @@
1
- @layer comp{.fileInput{&::-webkit-file-upload-button{@apply bg-primary-500 opacity-80 hover:opacity-90 text-white rounded border-none py-0 cursor-pointer}&[aria-invalid=true]::-webkit-file-upload-button{@apply bg-danger-500}&:disabled::-webkit-file-upload-button{@apply bg-muted pointer-events-none}&[readOnly]{@apply pointer-events-none}}}
1
+ @layer comp{.fileInput{&::-webkit-file-upload-button{background-color:theme(backgroundColor.primary.500);border:0;border-radius:theme(borderRadius.DEFAULT);color:theme(textColor.white);cursor:pointer;opacity:.8;padding-block:0;&:hover{opacity:.9}}&[aria-invalid=true]::-webkit-file-upload-button{background-color:theme(backgroundColor.danger.500)}&:disabled::-webkit-file-upload-button{background-color:theme(backgroundColor.muted);pointer-events:none}&[readOnly]{pointer-events:none}}}
@@ -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
  react.useEffect(function () {
39
- onChange === null || onChange === void 0 || onChange(hiddenValue);
39
+ setTimeout(function () {
40
+ onChange === null || onChange === void 0 || onChange(hiddenValue);
41
+ }, 50);
40
42
  }, [hiddenValue]);
41
43
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
42
44
  children: [/*#__PURE__*/jsxRuntime.jsx("input", {
@@ -2,26 +2,29 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var core = require('@react-fabric/core');
5
6
  var react = require('react');
6
7
  var FieldWrapper = require('../internal/FieldWrapper.js');
7
8
  var jsxRuntime = require('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__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
19
21
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
20
22
  className: className,
21
- children: react.Children.map(children, function (child) {
23
+ children: core.cloneChildren(children, function (child) {
22
24
  return /*#__PURE__*/react.cloneElement(child, {
23
25
  name: name,
24
- onChange: onChange
26
+ onChange: onChange,
27
+ width: optionWidth
25
28
  });
26
29
  })
27
30
  })
@@ -10,7 +10,7 @@ require('@react-fabric/utilities');
10
10
  var getColor = require('../utils/getColor.js');
11
11
  var jsxRuntime = require('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", "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,7 +23,11 @@ var Switch = function Switch(_ref) {
23
23
  width = _ref.width,
24
24
  color = _ref.color;
25
25
  _ref.name;
26
- var defaultColor = _ref.defaultColor,
26
+ var onLabel = _ref.onLabel,
27
+ offLabel = _ref.offLabel,
28
+ onLabelColor = _ref.onLabelColor,
29
+ offLabelColor = _ref.offLabelColor,
30
+ defaultColor = _ref.defaultColor,
27
31
  onChange = _ref.onChange,
28
32
  rest = _objectWithoutProperties(_ref, _excluded);
29
33
  var _useState = react.useState(false),
@@ -45,7 +49,7 @@ var Switch = function Switch(_ref) {
45
49
  width: width
46
50
  },
47
51
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
48
- className: classNames(actualValue && getColor.getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getColor.getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative flex h-6 w-10 cursor-pointer rounded-full p-1 transition-colors duration-200 ease-in-out"),
52
+ className: classNames(actualValue && getColor.getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getColor.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
53
  style: {
50
54
  backgroundColor: actualValue ? getColor.getColor(color) : getColor.getColor(defaultColor)
51
55
  },
@@ -64,7 +68,24 @@ var Switch = function Switch(_ref) {
64
68
  onChange: handleChange
65
69
  }, rest)), /*#__PURE__*/jsxRuntime.jsx("span", {
66
70
  "aria-hidden": "true",
67
- className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-4" : "translate-x-0", "pointer-events-none inline-block size-4 rounded-full bg-white ring-0 transition duration-200 ease-in-out")
71
+ 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"),
72
+ style: {
73
+ width: "calc(50% - 0.25rem)"
74
+ }
75
+ }), (!!onLabel || !!offLabel) && /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
76
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
77
+ className: "whitespace-nowrap text-xs px-1 ".concat(getColor.getColorClass(onLabelColor !== null && onLabelColor !== void 0 ? onLabelColor : "white")),
78
+ style: {
79
+ color: getColor.getColor(onLabelColor)
80
+ },
81
+ children: onLabel !== null && onLabel !== void 0 ? onLabel : " "
82
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
83
+ className: "whitespace-nowrap text-xs px-1 ".concat(getColor.getColorClass(offLabelColor !== null && offLabelColor !== void 0 ? offLabelColor : "base")),
84
+ style: {
85
+ color: getColor.getColor(offLabelColor)
86
+ },
87
+ children: offLabel !== null && offLabel !== void 0 ? offLabel : " "
88
+ })]
68
89
  })]
69
90
  }), /*#__PURE__*/jsxRuntime.jsx(ErrorIcon.ErrorIcon, {
70
91
  invalid: invalid,
@@ -9,7 +9,7 @@ var eventHandlers = require('../utils/eventHandlers.js');
9
9
  require('@react-fabric/utilities');
10
10
  var jsxRuntime = require('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);
@@ -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__*/jsxRuntime.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: eventHandlers.handleEnter(onEnterPressed)
88
+ onKeyDown: eventHandlers.handleEnter(onEnterPressed, {
89
+ preventDefault: !!onEnterPressed
90
+ })
87
91
  })
88
92
  }));
89
93
  };
@@ -49,7 +49,7 @@ var FieldWrapper = function FieldWrapper(_ref) {
49
49
  flexBasis: width
50
50
  },
51
51
  children: [!isInner && /*#__PURE__*/jsxRuntime.jsxs("div", {
52
- className: "flex flex-nowrap flex-content gap-1 py-0.5 px-2",
52
+ className: "flex flex-nowrap flex-content items-end gap-1 py-0.5 px-2",
53
53
  style: {
54
54
  width: inline ? labelWidth : undefined
55
55
  },
@@ -64,6 +64,8 @@ var FieldWrapper = function FieldWrapper(_ref) {
64
64
  }), required && /*#__PURE__*/jsxRuntime.jsx("span", {
65
65
  className: "text-danger-500 select-none flex-content text-[10px]",
66
66
  children: "\u273D"
67
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
68
+ className: "flex-1"
67
69
  }), appendLabel && /*#__PURE__*/jsxRuntime.jsx("span", {
68
70
  className: "flex-content",
69
71
  children: appendLabel
@@ -3,7 +3,6 @@
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
5
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
- var react$1 = require('@floating-ui/react');
7
6
  var core = require('@react-fabric/core');
8
7
  var utilities = require('@react-fabric/utilities');
9
8
  var classNames = require('classnames');
@@ -13,11 +12,10 @@ var ErrorIcon = require('./ErrorIcon.js');
13
12
  var Field_module = require('./Field.module.css');
14
13
  var FieldWrapper = require('./FieldWrapper.js');
15
14
 
16
- var _excluded = ["invalid", "error", "allowClear", "showClear", "decorateStart", "decorateEnd", "children", "onClear", "noOutline", "noBorder", "textarea", "data-inner", "data-open", "floatingExpand", "wrapperRef", "width"];
15
+ var _excluded = ["invalid", "error", "allowClear", "showClear", "decorateStart", "decorateEnd", "children", "onClear", "noOutline", "noBorder", "textarea", "textareaExpandable", "data-inner", "data-open", "floatingExpand", "wrapperRef", "width"];
17
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; }
18
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; }
19
18
  var InputWrapper = function InputWrapper(_ref) {
20
- var _elRef$current;
21
19
  var invalid = _ref.invalid,
22
20
  error = _ref.error,
23
21
  allowClear = _ref.allowClear,
@@ -30,6 +28,8 @@ var InputWrapper = function InputWrapper(_ref) {
30
28
  noBorder = _ref.noBorder,
31
29
  _ref$textarea = _ref.textarea,
32
30
  textarea = _ref$textarea === void 0 ? false : _ref$textarea,
31
+ _ref$textareaExpandab = _ref.textareaExpandable,
32
+ textareaExpandable = _ref$textareaExpandab === void 0 ? false : _ref$textareaExpandab,
33
33
  isInner = _ref["data-inner"];
34
34
  _ref["data-open"];
35
35
  var floatingExpand = _ref.floatingExpand,
@@ -69,7 +69,7 @@ var InputWrapper = function InputWrapper(_ref) {
69
69
  ref: wrapperRef,
70
70
  className: classNames(Field_module.inputWrapper, invalid && Field_module.invalidWrapper, !noOutline && !noBorder && "bg-[var(--fabric-input)] outline overflow-hidden", "flex flex-nowrap items-center", 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
71
  onKeyDown: function onKeyDown(e) {
72
- return e.key === "Escape" && setExpanded(false);
72
+ return e.key === "Escape" && isExpanded && (setExpanded(false), e.stopPropagation());
73
73
  },
74
74
  children: [decorateStart && /*#__PURE__*/jsxRuntime.jsx("div", {
75
75
  onClickCapture: doFocus,
@@ -86,7 +86,7 @@ var InputWrapper = function InputWrapper(_ref) {
86
86
  onClickCapture: doFocus,
87
87
  className: classNames(Field_module.decorate, "text-muted leading-none flex-content", utilities.isString(decorateEnd) && "px-1"),
88
88
  children: decorateEnd
89
- }), textarea && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
89
+ }), textareaExpandable && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
90
90
  onClick: function onClick() {
91
91
  return setExpanded(!isExpanded);
92
92
  },
@@ -95,17 +95,14 @@ var InputWrapper = function InputWrapper(_ref) {
95
95
  })]
96
96
  });
97
97
  return /*#__PURE__*/jsxRuntime.jsx(Wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
98
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
98
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
99
99
  ref: elRef,
100
100
  className: "flex-1 relative min-h-8",
101
101
  style: {
102
102
  width: width,
103
103
  flexBasis: width
104
104
  },
105
- children: [!isExpanded && el, isExpanded && /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingPortal, {
106
- root: (_elRef$current = elRef.current) === null || _elRef$current === void 0 ? void 0 : _elRef$current.closest(".theme-base"),
107
- children: el
108
- })]
105
+ children: el
109
106
  })
110
107
  }));
111
108
  };