@react-fabric/form 1.0.0-beta.45 → 1.0.0-beta.47

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 (56) 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/ArrayInput.js +27 -10
  5. package/dist/cjs/input/ColorInput.js +23 -31
  6. package/dist/cjs/input/DateInput.js +1 -1
  7. package/dist/cjs/input/Field.js +1 -0
  8. package/dist/cjs/input/File.js +1 -1
  9. package/dist/cjs/input/Input.js +5 -3
  10. package/dist/cjs/input/Number.js +1 -1
  11. package/dist/cjs/input/Password.js +1 -1
  12. package/dist/cjs/input/RangeSlider.js +2 -2
  13. package/dist/cjs/input/Search.js +1 -1
  14. package/dist/cjs/input/Slider.js +2 -2
  15. package/dist/cjs/input/Textarea.js +1 -1
  16. package/dist/cjs/internal/InputWrapper.js +2 -2
  17. package/dist/cjs/select/useSelect.js +1 -1
  18. package/dist/esm/form/Form.js +1 -1
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/input/ArrayInput.js +24 -7
  21. package/dist/esm/input/ColorInput.js +23 -31
  22. package/dist/esm/input/DateInput.js +1 -1
  23. package/dist/esm/input/Field.js +1 -0
  24. package/dist/esm/input/File.js +1 -1
  25. package/dist/esm/input/Input.js +5 -3
  26. package/dist/esm/input/Number.js +1 -1
  27. package/dist/esm/input/Password.js +1 -1
  28. package/dist/esm/input/RangeSlider.js +2 -2
  29. package/dist/esm/input/Search.js +1 -1
  30. package/dist/esm/input/Slider.js +2 -2
  31. package/dist/esm/input/Textarea.js +1 -1
  32. package/dist/esm/internal/InputWrapper.js +2 -2
  33. package/dist/esm/select/useSelect.js +1 -1
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/types/input/ArrayInput.d.ts +20 -4
  36. package/dist/types/input/ColorInput.d.ts +1 -1
  37. package/dist/types/input/Input.d.ts +1 -1
  38. package/dist/types/types/index.d.ts +1 -0
  39. package/package.json +5 -5
  40. package/src/form/Form.tsx +1 -1
  41. package/src/index.ts +1 -0
  42. package/src/input/ArrayInput.tsx +50 -12
  43. package/src/input/ColorInput.tsx +13 -42
  44. package/src/input/DateInput.tsx +1 -1
  45. package/src/input/Field.tsx +1 -0
  46. package/src/input/File.tsx +1 -1
  47. package/src/input/Input.tsx +7 -2
  48. package/src/input/Number.tsx +1 -1
  49. package/src/input/Password.tsx +1 -1
  50. package/src/input/RangeSlider.tsx +2 -2
  51. package/src/input/Search.tsx +1 -1
  52. package/src/input/Slider.tsx +2 -2
  53. package/src/input/Textarea.tsx +1 -1
  54. package/src/internal/InputWrapper.tsx +6 -3
  55. package/src/select/useSelect.tsx +1 -0
  56. package/src/types/index.ts +2 -0
@@ -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
  */