@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.
Files changed (52) hide show
  1. package/css/_field.css +38 -14
  2. package/dist/cjs/form/Form.js +1 -1
  3. package/dist/cjs/index.js +2 -0
  4. package/dist/cjs/input/ColorInput.js +23 -31
  5. package/dist/cjs/input/DateInput.js +1 -1
  6. package/dist/cjs/input/Field.js +1 -0
  7. package/dist/cjs/input/File.js +1 -1
  8. package/dist/cjs/input/Input.js +5 -3
  9. package/dist/cjs/input/Number.js +1 -1
  10. package/dist/cjs/input/Password.js +1 -1
  11. package/dist/cjs/input/RangeSlider.js +2 -2
  12. package/dist/cjs/input/Search.js +1 -1
  13. package/dist/cjs/input/Slider.js +2 -2
  14. package/dist/cjs/input/Textarea.js +1 -1
  15. package/dist/cjs/internal/InputWrapper.js +2 -2
  16. package/dist/cjs/select/useSelect.js +1 -1
  17. package/dist/esm/form/Form.js +1 -1
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/input/ColorInput.js +23 -31
  20. package/dist/esm/input/DateInput.js +1 -1
  21. package/dist/esm/input/Field.js +1 -0
  22. package/dist/esm/input/File.js +1 -1
  23. package/dist/esm/input/Input.js +5 -3
  24. package/dist/esm/input/Number.js +1 -1
  25. package/dist/esm/input/Password.js +1 -1
  26. package/dist/esm/input/RangeSlider.js +2 -2
  27. package/dist/esm/input/Search.js +1 -1
  28. package/dist/esm/input/Slider.js +2 -2
  29. package/dist/esm/input/Textarea.js +1 -1
  30. package/dist/esm/internal/InputWrapper.js +2 -2
  31. package/dist/esm/select/useSelect.js +1 -1
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/input/ColorInput.d.ts +1 -1
  34. package/dist/types/input/Input.d.ts +1 -1
  35. package/dist/types/types/index.d.ts +1 -0
  36. package/package.json +5 -5
  37. package/src/form/Form.tsx +1 -1
  38. package/src/index.ts +1 -0
  39. package/src/input/ColorInput.tsx +13 -42
  40. package/src/input/DateInput.tsx +1 -1
  41. package/src/input/Field.tsx +1 -0
  42. package/src/input/File.tsx +1 -1
  43. package/src/input/Input.tsx +7 -2
  44. package/src/input/Number.tsx +1 -1
  45. package/src/input/Password.tsx +1 -1
  46. package/src/input/RangeSlider.tsx +2 -2
  47. package/src/input/Search.tsx +1 -1
  48. package/src/input/Slider.tsx +2 -2
  49. package/src/input/Textarea.tsx +1 -1
  50. package/src/internal/InputWrapper.tsx +6 -3
  51. package/src/select/useSelect.tsx +1 -0
  52. 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
- > :not(:first-child) {
131
- &,
132
- & > div,
133
- & > [role="button"],
134
- & > [data-ref="button"] > [role="button"] {
135
- border-start-start-radius: 0;
136
- border-end-start-radius: 0;
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
- > :not(:last-child) {
141
- &,
142
- & > div,
143
- & > [role="button"],
144
- & > [data-ref="button"] > [role="button"] {
145
- border-start-end-radius: 0;
146
- border-end-end-radius: 0;
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
  }
@@ -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", "allowClear", "invalid", "error", "value", "showPicker", "defaultColor", "decorateEnd", "decorateStart", "onBlur", "onFocus", "onChange", "noOutline"];
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
- var disabled = _ref.disabled,
21
- allowClear = _ref.allowClear;
22
- _ref.invalid;
23
- _ref.error;
24
- var value = _ref.value,
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
- noOutline = _ref.noOutline,
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("div", {
82
- 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-(--fabric-input) outline overflow-hidden"),
83
- children: [decorateStart && /*#__PURE__*/jsxRuntime.jsx("div", {
84
- className: classNames("text-muted leading-none flex-content", utilities.isString(decorateStart) && "px-2"),
85
- children: decorateStart
86
- }), /*#__PURE__*/jsxRuntime.jsx("button", _objectSpread(_objectSpread({
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,
@@ -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
@@ -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,
@@ -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,
@@ -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-auto order-3 flex items-center select-none z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
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-auto relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
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
  },
@@ -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,
@@ -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-auto order-3 flex items-center select-none relative z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
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-auto relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
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 -outline-offset-1 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-[2px] after:bg-primary-500 after:mx-auto"),
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: "flex-1 relative min-h-8 flex flex-col flex-nowrap",
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
@@ -249,7 +249,7 @@ var useSelect = function useSelect(_ref) {
249
249
  setActive: true
250
250
  });
251
251
  });
252
- }, [onQuery]);
252
+ }, [onQuery], 300);
253
253
 
254
254
  // handlers
255
255
  var handleQuery = react.useCallback(function (query) {
@@ -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", "allowClear", "invalid", "error", "value", "showPicker", "defaultColor", "decorateEnd", "decorateStart", "onBlur", "onFocus", "onChange", "noOutline"];
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
- var disabled = _ref.disabled,
21
- allowClear = _ref.allowClear;
22
- _ref.invalid;
23
- _ref.error;
24
- var value = _ref.value,
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
- noOutline = _ref.noOutline,
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("div", {
82
- 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-(--fabric-input) outline overflow-hidden"),
83
- children: [decorateStart && /*#__PURE__*/jsx("div", {
84
- className: classNames("text-muted leading-none flex-content", isString(decorateStart) && "px-2"),
85
- children: decorateStart
86
- }), /*#__PURE__*/jsx("button", _objectSpread(_objectSpread({
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,
@@ -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
@@ -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,
@@ -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,
@@ -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-auto order-3 flex items-center select-none z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
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-auto relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
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
  },
@@ -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,
@@ -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-auto order-3 flex items-center select-none relative z-0", vertical && "flex-col w-8", invalid ? "text-danger-500" : "text-primary-600"),
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-auto relative flex items-center", vertical ? "my-2 w-8" : "mx-2 h-8"),
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 -outline-offset-1 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-[2px] after:bg-primary-500 after:mx-auto"),
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: "flex-1 relative min-h-8 flex flex-col flex-nowrap",
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
@@ -249,7 +249,7 @@ var useSelect = function useSelect(_ref) {
249
249
  setActive: true
250
250
  });
251
251
  });
252
- }, [onQuery]);
252
+ }, [onQuery], 300);
253
253
 
254
254
  // handlers
255
255
  var handleQuery = useCallback(function (query) {
@@ -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, allowClear, invalid, error, value, showPicker, defaultColor, decorateEnd, decorateStart, onBlur, onFocus, onChange, noOutline, ...rest }: ColorInputProps) => import("react/jsx-runtime").JSX.Element;
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;
@@ -51,6 +51,7 @@ export interface InputProps<V = string> extends TestProps {
51
51
  * info label at bottom
52
52
  */
53
53
  info?: string;
54
+ monospace?: boolean;
54
55
  /**
55
56
  * required
56
57
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/form",
3
- "version": "1.0.0-beta.45",
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",
45
- "@react-fabric/date": "^1.0.0-beta.45",
46
- "@react-fabric/utilities": "^1.0.0-beta.45",
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": "37d7cbcd99da40553f4ac775c3332d5281565936"
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";
@@ -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
- allowClear,
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
- <div
129
- className={classNames(
130
- "flex-content min-h-[1.5em] min-w-[3.5em] self-stretch flex items-center outline-tint-200 rounded",
131
- !disabled && "bg-base",
132
- !noOutline && "bg-(--fabric-input) outline overflow-hidden",
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
- {decorateEnd && (
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
  };
@@ -186,7 +186,7 @@ export const DateInput = ({
186
186
 
187
187
  return (
188
188
  <InputWrapper
189
- showClear={!!actualValue}
189
+ showClear={!!actualValue && !disabled && !readOnly}
190
190
  onClear={handleChange}
191
191
  invalid={invalid}
192
192
  readOnly={readOnly}
@@ -90,6 +90,7 @@ export const Field = ({
90
90
  "flex-1 rounded",
91
91
  !vertical && "flex",
92
92
  )}
93
+ data-vertical={!!vertical}
93
94
  >
94
95
  {cloneChildren(children, (child: AnyObject) =>
95
96
  cloneElement(child, {
@@ -151,7 +151,7 @@ export const FileInput = ({
151
151
 
152
152
  return (
153
153
  <InputWrapper
154
- showClear={!isEmpty(actualValue)}
154
+ showClear={!isEmpty(actualValue) && !disabled && !readOnly}
155
155
  onClear={handleChange}
156
156
  invalid={invalid}
157
157
  readOnly={readOnly}
@@ -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="appearance-none bg-transparent py-1 px-2 flex-1 border-none outline-none ring-0 peer"
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}
@@ -93,7 +93,7 @@ export const Number = ({
93
93
 
94
94
  return (
95
95
  <InputWrapper
96
- showClear={!!actualValue}
96
+ showClear={!!actualValue && !disabled && !readOnly}
97
97
  onClear={handleChange}
98
98
  invalid={invalid}
99
99
  readOnly={readOnly}
@@ -92,7 +92,7 @@ export const Password = ({
92
92
 
93
93
  return (
94
94
  <InputWrapper
95
- showClear={!!actualValue}
95
+ showClear={!!actualValue && !disabled && !readOnly}
96
96
  onClear={handleChange}
97
97
  invalid={invalid}
98
98
  readOnly={readOnly}
@@ -190,7 +190,7 @@ export const RangeSlider = ({
190
190
  >
191
191
  <div
192
192
  className={classNames(
193
- "flex-auto order-3 flex items-center select-none z-0",
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-auto relative flex items-center",
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 }}
@@ -113,7 +113,7 @@ export const Search = ({
113
113
 
114
114
  return (
115
115
  <InputWrapper
116
- showClear={!!actualValue}
116
+ showClear={!!actualValue && !disabled && !readOnly}
117
117
  onClear={handleChange}
118
118
  allowClear={allowClear}
119
119
  invalid={invalid}
@@ -194,7 +194,7 @@ export const Slider = ({
194
194
  >
195
195
  <div
196
196
  className={classNames(
197
- "flex-auto order-3 flex items-center select-none relative z-0",
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-auto relative flex items-center",
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 }}
@@ -104,7 +104,7 @@ export const Textarea = ({
104
104
 
105
105
  return (
106
106
  <InputWrapper
107
- showClear={!!actualValue}
107
+ showClear={!!actualValue && !disabled && !readOnly}
108
108
  onClear={handleChange}
109
109
  invalid={invalid}
110
110
  readOnly={readOnly}
@@ -108,7 +108,7 @@ export const InputWrapper = ({
108
108
  invalid && "fabric-invalidWrapper",
109
109
  !noOutline &&
110
110
  !noBorder &&
111
- "bg-(--fabric-input) outline -outline-offset-1 overflow-hidden",
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-[2px] after:bg-primary-500 after:mx-auto",
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="flex-1 relative min-h-8 flex flex-col flex-nowrap"
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}
@@ -338,6 +338,7 @@ export const useSelect = ({
338
338
  });
339
339
  },
340
340
  [onQuery],
341
+ 300,
341
342
  );
342
343
 
343
344
  // handlers
@@ -80,6 +80,8 @@ export interface InputProps<V = string> extends TestProps {
80
80
  */
81
81
  info?: string;
82
82
 
83
+ monospace?: boolean;
84
+
83
85
  /**
84
86
  * required
85
87
  */