@react-fabric/form 1.0.0-beta.44 → 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 (64) 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/DualList.js +4 -1
  17. package/dist/cjs/select/List.js +3 -1
  18. package/dist/cjs/select/Select.js +3 -1
  19. package/dist/cjs/select/useSelect.js +1 -1
  20. package/dist/esm/form/Form.js +1 -1
  21. package/dist/esm/index.js +1 -0
  22. package/dist/esm/input/ColorInput.js +23 -31
  23. package/dist/esm/input/DateInput.js +1 -1
  24. package/dist/esm/input/Field.js +1 -0
  25. package/dist/esm/input/File.js +1 -1
  26. package/dist/esm/input/Input.js +5 -3
  27. package/dist/esm/input/Number.js +1 -1
  28. package/dist/esm/input/Password.js +1 -1
  29. package/dist/esm/input/RangeSlider.js +2 -2
  30. package/dist/esm/input/Search.js +1 -1
  31. package/dist/esm/input/Slider.js +2 -2
  32. package/dist/esm/input/Textarea.js +1 -1
  33. package/dist/esm/internal/InputWrapper.js +2 -2
  34. package/dist/esm/select/DualList.js +4 -1
  35. package/dist/esm/select/List.js +3 -1
  36. package/dist/esm/select/Select.js +3 -1
  37. package/dist/esm/select/useSelect.js +1 -1
  38. package/dist/types/index.d.ts +1 -0
  39. package/dist/types/input/ColorInput.d.ts +1 -1
  40. package/dist/types/input/Input.d.ts +1 -1
  41. package/dist/types/select/DualList.d.ts +6 -2
  42. package/dist/types/select/List.d.ts +1 -1
  43. package/dist/types/select/Select.d.ts +1 -1
  44. package/dist/types/types/index.d.ts +6 -1
  45. package/package.json +5 -5
  46. package/src/form/Form.tsx +1 -1
  47. package/src/index.ts +1 -0
  48. package/src/input/ColorInput.tsx +13 -42
  49. package/src/input/DateInput.tsx +1 -1
  50. package/src/input/Field.tsx +1 -0
  51. package/src/input/File.tsx +1 -1
  52. package/src/input/Input.tsx +7 -2
  53. package/src/input/Number.tsx +1 -1
  54. package/src/input/Password.tsx +1 -1
  55. package/src/input/RangeSlider.tsx +2 -2
  56. package/src/input/Search.tsx +1 -1
  57. package/src/input/Slider.tsx +2 -2
  58. package/src/input/Textarea.tsx +1 -1
  59. package/src/internal/InputWrapper.tsx +6 -3
  60. package/src/select/DualList.tsx +8 -0
  61. package/src/select/List.tsx +2 -0
  62. package/src/select/Select.tsx +2 -0
  63. package/src/select/useSelect.tsx +1 -0
  64. package/src/types/index.ts +7 -0
@@ -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
@@ -13,13 +13,14 @@ import { useDraggable, useDroppable, DndContext, DragOverlay } from '@dnd-kit/co
13
13
  import { mergeRefs } from '@react-fabric/utilities';
14
14
  import { jsx, jsxs } from 'react/jsx-runtime';
15
15
 
16
- var _excluded = ["ref", "value", "options", "groupProperty", "height", "labelProperty", "valueProperty", "renderer", "onChange", "name", "invalid", "readOnly", "disabled", "placeholder", "autoFocus", "error"];
16
+ var _excluded = ["ref", "value", "options", "emptyDisplay", "groupProperty", "height", "labelProperty", "valueProperty", "renderer", "onChange", "name", "invalid", "readOnly", "disabled", "placeholder", "autoFocus", "error"];
17
17
  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
18
  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
19
  var DualList = function DualList(_ref) {
20
20
  var ref = _ref.ref,
21
21
  value = _ref.value,
22
22
  options = _ref.options,
23
+ emptyDisplay = _ref.emptyDisplay,
23
24
  groupProperty = _ref.groupProperty,
24
25
  _ref$height = _ref.height,
25
26
  height = _ref$height === void 0 ? "18rem" : _ref$height,
@@ -163,6 +164,7 @@ var DualList = function DualList(_ref) {
163
164
  error: error,
164
165
  height: height,
165
166
  options: leftOptions,
167
+ emptyDisplay: emptyDisplay,
166
168
  groupProperty: groupProperty,
167
169
  labelProperty: labelProperty,
168
170
  valueProperty: valueProperty,
@@ -218,6 +220,7 @@ var DualList = function DualList(_ref) {
218
220
  allowClear: true,
219
221
  height: height,
220
222
  options: rightOptions,
223
+ emptyDisplay: emptyDisplay,
221
224
  groupProperty: groupProperty,
222
225
  labelProperty: labelProperty,
223
226
  valueProperty: valueProperty,
@@ -13,7 +13,7 @@ import { Options } from './Options.js';
13
13
  import { useSelect } from './useSelect.js';
14
14
  import { jsx, jsxs } from 'react/jsx-runtime';
15
15
 
16
- var _excluded = ["ref", "name", "value", "readOnly", "disabled", "required", "placeholder", "autoFocus", "options", "height", "groupProperty", "labelProperty", "valueProperty", "multiple", "allowCreate", "searchable", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed", "invalid", "error", "allowClear", "decorateStart", "decorateEnd", "data-inner", "data-hide-selected"];
16
+ var _excluded = ["ref", "name", "value", "readOnly", "disabled", "required", "placeholder", "autoFocus", "options", "height", "groupProperty", "labelProperty", "valueProperty", "multiple", "allowCreate", "searchable", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed", "emptyDisplay", "invalid", "error", "allowClear", "decorateStart", "decorateEnd", "data-inner", "data-hide-selected"];
17
17
  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
18
  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
19
  var List = function List(_ref) {
@@ -41,6 +41,7 @@ var List = function List(_ref) {
41
41
  onChange = _ref.onChange,
42
42
  onSelect = _ref.onSelect,
43
43
  onEnterPressed = _ref.onEnterPressed,
44
+ emptyDisplay = _ref.emptyDisplay,
44
45
  invalid = _ref.invalid,
45
46
  error = _ref.error;
46
47
  _ref.allowClear;
@@ -250,6 +251,7 @@ var List = function List(_ref) {
250
251
  labelProperty: labelProperty,
251
252
  itemRef: setItemRef,
252
253
  itemProps: makeItemProps,
254
+ empty: emptyDisplay,
253
255
  children: function children(item, label) {
254
256
  var _renderer3;
255
257
  return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
@@ -12,7 +12,7 @@ import { Options } from './Options.js';
12
12
  import { useSelect } from './useSelect.js';
13
13
  import { jsx, jsxs } from 'react/jsx-runtime';
14
14
 
15
- var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "options", "defaultOpen", "hideHandle", "groupProperty", "labelProperty", "valueProperty", "multiple", "searchable", "allowCreate", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed"];
15
+ var _excluded = ["ref", "name", "value", "invalid", "readOnly", "disabled", "required", "placeholder", "autoFocus", "error", "options", "defaultOpen", "hideHandle", "groupProperty", "labelProperty", "valueProperty", "multiple", "searchable", "allowCreate", "emptyDisplay", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed"];
16
16
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
18
  var Select = function Select(_ref) {
@@ -38,6 +38,7 @@ var Select = function Select(_ref) {
38
38
  multiple = _ref.multiple,
39
39
  searchable = _ref.searchable,
40
40
  allowCreate = _ref.allowCreate,
41
+ emptyDisplay = _ref.emptyDisplay,
41
42
  createOption = _ref.createOption,
42
43
  matcher = _ref.matcher,
43
44
  renderer = _ref.renderer,
@@ -276,6 +277,7 @@ var Select = function Select(_ref) {
276
277
  labelProperty: labelProperty,
277
278
  itemRef: setItemRef,
278
279
  itemProps: makeItemProps,
280
+ empty: emptyDisplay,
279
281
  children: function children(item, label) {
280
282
  var _renderer3;
281
283
  return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
@@ -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;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { type RefProp } from "@react-fabric/core/dist/types/types";
2
+ import { type ReactElement } from "react";
3
3
  import { type FieldProps } from "../input/Field";
4
4
  export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<HTMLInputElement> {
5
5
  /**
@@ -26,6 +26,10 @@ export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<
26
26
  * value property name
27
27
  */
28
28
  valueProperty?: keyof T;
29
+ /**
30
+ * empty list display
31
+ */
32
+ emptyDisplay?: ReactElement;
29
33
  /**
30
34
  * item renderer
31
35
  */
@@ -35,4 +39,4 @@ export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<
35
39
  */
36
40
  onChange?: (value?: string[]) => void;
37
41
  }
38
- export declare const DualList: <T extends unknown = string>({ ref, value, options, groupProperty, height, labelProperty, valueProperty, renderer, onChange, name, invalid, readOnly, disabled, placeholder, autoFocus, error, ...rest }: DualListProps<T>) => import("react/jsx-runtime").JSX.Element;
42
+ export declare const DualList: <T extends unknown = string>({ ref, value, options, emptyDisplay, groupProperty, height, labelProperty, valueProperty, renderer, onChange, name, invalid, readOnly, disabled, placeholder, autoFocus, error, ...rest }: DualListProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import { type SelectProps } from "../types";
2
- export declare const List: <T extends unknown = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: Omit<SelectProps<T>, "defaultOpen" | "hideHandle"> & {
2
+ export declare const List: <T extends unknown = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, emptyDisplay, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: Omit<SelectProps<T>, "defaultOpen" | "hideHandle"> & {
3
3
  height?: string | number;
4
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { type SelectProps } from "../types";
2
- export declare const Select: <T extends unknown = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, defaultOpen, hideHandle, groupProperty, labelProperty, valueProperty, multiple, searchable, allowCreate, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Select: <T extends unknown = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, defaultOpen, hideHandle, groupProperty, labelProperty, valueProperty, multiple, searchable, allowCreate, emptyDisplay, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
2
+ import { type ReactElement } from "react";
3
3
  export interface InputProps<V = string> extends TestProps {
4
4
  /**
5
5
  * value
@@ -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
  */
@@ -125,6 +126,10 @@ export interface BaseSelectProps<T extends AnyObject = string> {
125
126
  * allow create item
126
127
  */
127
128
  allowCreate?: boolean;
129
+ /**
130
+ * empty list display
131
+ */
132
+ emptyDisplay?: ReactElement;
128
133
  /**
129
134
  * create new item object
130
135
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/form",
3
- "version": "1.0.0-beta.44",
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.44",
45
- "@react-fabric/date": "^1.0.0-beta.44",
46
- "@react-fabric/utilities": "^1.0.0-beta.44",
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": "5c05c100917811fa40b30c98b94fd396b1f68ea9"
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}