@react-fabric/form 1.0.0-beta.60 → 1.0.0-beta.62

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 (91) hide show
  1. package/dist/cjs/builder/FileField.js +10 -7
  2. package/dist/cjs/builder/components/AddSchemaFields.js +2 -1
  3. package/dist/cjs/builder/components/SchemaArrayForm.js +4 -4
  4. package/dist/cjs/builder/components/SchemaField.js +4 -4
  5. package/dist/cjs/form/Form.js +44 -22
  6. package/dist/cjs/hooks/useFileUploader.js +40 -28
  7. package/dist/cjs/hooks/useFormBuilder.js +10 -3
  8. package/dist/cjs/i18n/index.js +4 -4
  9. package/dist/cjs/input/ArrayInput.js +3 -3
  10. package/dist/cjs/input/AvatarInput.js +17 -12
  11. package/dist/cjs/input/Checkbox.js +2 -2
  12. package/dist/cjs/input/ColorInput.js +2 -2
  13. package/dist/cjs/input/File.js +1 -1
  14. package/dist/cjs/input/Hidden.js +1 -10
  15. package/dist/cjs/input/Password.js +1 -1
  16. package/dist/cjs/input/Radio.js +2 -2
  17. package/dist/cjs/input/RadioGroup.js +3 -1
  18. package/dist/cjs/input/Search.js +2 -3
  19. package/dist/cjs/internal/ErrorIcon.js +1 -1
  20. package/dist/cjs/internal/InputWrapper.js +3 -3
  21. package/dist/cjs/select/AutoComplete.js +1 -2
  22. package/dist/cjs/select/DualList.js +5 -5
  23. package/dist/cjs/select/List.js +8 -24
  24. package/dist/cjs/select/Select.js +9 -28
  25. package/dist/esm/builder/FileField.js +11 -8
  26. package/dist/esm/builder/components/AddSchemaFields.js +2 -1
  27. package/dist/esm/builder/components/SchemaArrayForm.js +5 -5
  28. package/dist/esm/builder/components/SchemaField.js +5 -5
  29. package/dist/esm/form/Form.js +44 -22
  30. package/dist/esm/hooks/useFileUploader.js +41 -29
  31. package/dist/esm/hooks/useFormBuilder.js +10 -3
  32. package/dist/esm/i18n/index.js +2 -2
  33. package/dist/esm/input/ArrayInput.js +4 -4
  34. package/dist/esm/input/AvatarInput.js +18 -13
  35. package/dist/esm/input/Checkbox.js +3 -3
  36. package/dist/esm/input/ColorInput.js +3 -3
  37. package/dist/esm/input/File.js +2 -2
  38. package/dist/esm/input/Hidden.js +2 -11
  39. package/dist/esm/input/Password.js +2 -2
  40. package/dist/esm/input/Radio.js +3 -3
  41. package/dist/esm/input/RadioGroup.js +3 -1
  42. package/dist/esm/input/Search.js +3 -4
  43. package/dist/esm/internal/ErrorIcon.js +2 -2
  44. package/dist/esm/internal/InputWrapper.js +4 -4
  45. package/dist/esm/select/AutoComplete.js +2 -3
  46. package/dist/esm/select/DualList.js +6 -6
  47. package/dist/esm/select/List.js +8 -24
  48. package/dist/esm/select/Select.js +10 -29
  49. package/dist/types/builder/FileField.d.ts +2 -1
  50. package/dist/types/form/Form.d.ts +11 -10
  51. package/dist/types/hooks/useFileUploader.d.ts +4 -2
  52. package/dist/types/hooks/useFormBuilder.d.ts +6 -0
  53. package/dist/types/input/AvatarInput.d.ts +2 -2
  54. package/dist/types/input/Hidden.d.ts +3 -11
  55. package/dist/types/input/RadioGroup.d.ts +5 -1
  56. package/dist/types/select/DualList.d.ts +5 -6
  57. package/dist/types/select/Options.d.ts +1 -1
  58. package/dist/types/types/index.d.ts +7 -8
  59. package/package.json +5 -5
  60. package/src/builder/FileField.tsx +8 -12
  61. package/src/builder/components/AddSchemaFields.tsx +2 -1
  62. package/src/builder/components/SchemaArrayForm.tsx +5 -11
  63. package/src/builder/components/SchemaField.tsx +4 -5
  64. package/src/form/Form.tsx +30 -24
  65. package/src/hooks/useFileUploader.ts +41 -29
  66. package/src/hooks/useFormBuilder.tsx +12 -4
  67. package/src/i18n/index.ts +2 -2
  68. package/src/input/ArrayInput.tsx +4 -10
  69. package/src/input/AvatarInput.tsx +16 -16
  70. package/src/input/Checkbox.tsx +6 -3
  71. package/src/input/ColorInput.tsx +3 -7
  72. package/src/input/File.tsx +2 -2
  73. package/src/input/Hidden.tsx +4 -22
  74. package/src/input/Password.tsx +4 -2
  75. package/src/input/Radio.tsx +3 -3
  76. package/src/input/RadioGroup.tsx +6 -0
  77. package/src/input/Search.tsx +3 -3
  78. package/src/internal/ErrorIcon.tsx +2 -2
  79. package/src/internal/InputWrapper.tsx +8 -4
  80. package/src/select/AutoComplete.tsx +2 -3
  81. package/src/select/DualList.tsx +15 -12
  82. package/src/select/List.tsx +3 -3
  83. package/src/select/Options.tsx +1 -1
  84. package/src/select/Select.tsx +7 -8
  85. package/src/types/index.ts +8 -7
  86. /package/dist/cjs/i18n/{ar.json.js → ar/form.json.js} +0 -0
  87. /package/dist/cjs/i18n/{en.json.js → en/form.json.js} +0 -0
  88. /package/dist/esm/i18n/{ar.json.js → ar/form.json.js} +0 -0
  89. /package/dist/esm/i18n/{en.json.js → en/form.json.js} +0 -0
  90. /package/src/i18n/{ar.json → ar/form.json} +0 -0
  91. /package/src/i18n/{en.json → en/form.json} +0 -0
@@ -21,7 +21,7 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- import { CoreIcons, Icon } from "@react-fabric/core";
24
+ import { Icon } from "@react-fabric/core";
25
25
  import { isString } from "@react-fabric/utilities";
26
26
  import classNames from "classnames";
27
27
  import {
@@ -147,7 +147,7 @@ export const InputWrapper = ({
147
147
  {children}
148
148
  {allowClear && showClear && (
149
149
  <Icon
150
- icon={CoreIcons.close}
150
+ icon="icon-[mdi--close]"
151
151
  onClick={handleClear}
152
152
  className={classNames(
153
153
  "text-tint-500 hover:text-tint-700 p-1 z-1 flex-content",
@@ -185,7 +185,11 @@ export const InputWrapper = ({
185
185
  {textareaExpandable && (
186
186
  <Icon
187
187
  onClick={() => setExpanded(!isExpanded)}
188
- icon={isExpanded ? CoreIcons.arrowCollapse : CoreIcons.arrowExpand}
188
+ icon={
189
+ isExpanded
190
+ ? "icon-[mdi--arrow-collapse]"
191
+ : "icon-[mdi--arrow-expand]"
192
+ }
189
193
  className="hidden group-hover:block absolute top-0 end-0 bg-base hover:bg-tint-200 p-1 opacity-65 rounded-capped"
190
194
  />
191
195
  )}
@@ -198,7 +202,7 @@ export const InputWrapper = ({
198
202
  ref={elRef}
199
203
  className={classNames(
200
204
  "relative min-h-8 flex flex-col flex-nowrap",
201
- width ? "flex-auto" : "flex-1",
205
+ width ? "flex-content" : "flex-1",
202
206
  )}
203
207
  style={{ width, flexBasis: width }}
204
208
  >
@@ -34,7 +34,7 @@ import {
34
34
  useListNavigation,
35
35
  useTypeahead,
36
36
  } from "@floating-ui/react";
37
- import { Chip, CoreIcons, Icon } from "@react-fabric/core";
37
+ import { Chip, Icon } from "@react-fabric/core";
38
38
  import { isArray, isEmpty } from "@react-fabric/utilities";
39
39
  import classNames from "classnames";
40
40
  import { useCallback, useId, useLayoutEffect, useMemo, useRef } from "react";
@@ -323,11 +323,10 @@ export const AutoComplete = ({
323
323
  </div>
324
324
  {state.loading && (
325
325
  <Icon
326
- animate="spin"
327
326
  className={classNames(
328
327
  "flex-content p-2 z-0 order-9 text-muted pointer-events-none",
329
328
  )}
330
- icon={CoreIcons.spinner}
329
+ icon="icon-[svg-spinners--eclipse]"
331
330
  />
332
331
  )}
333
332
  {state.open && !state.loading && (
@@ -28,11 +28,14 @@ import {
28
28
  useDroppable,
29
29
  } from "@dnd-kit/core";
30
30
  import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
31
- import { Button, ButtonGroup, CoreIcons } from "@react-fabric/core";
32
- import { type RefProp } from "@react-fabric/core/dist/types/types";
33
- import { mergeRefs } from "@react-fabric/utilities";
31
+ import { Button, ButtonGroup } from "@react-fabric/core";
34
32
  import {
33
+ type NestedKeys,
35
34
  type ReactElement,
35
+ type RefProp,
36
+ } from "@react-fabric/core/dist/types/types";
37
+ import { mergeRefs } from "@react-fabric/utilities";
38
+ import {
36
39
  useCallback,
37
40
  useDeferredValue,
38
41
  useEffect,
@@ -60,15 +63,15 @@ export interface DualListProps<T>
60
63
  /**
61
64
  * group by property name
62
65
  */
63
- groupProperty?: keyof T;
66
+ groupProperty?: NestedKeys<T>;
64
67
  /**
65
68
  * label property name
66
69
  */
67
- labelProperty?: keyof T;
70
+ labelProperty?: NestedKeys<T>;
68
71
  /**
69
72
  * value property name
70
73
  */
71
- valueProperty?: keyof T;
74
+ valueProperty?: NestedKeys<T>;
72
75
  /**
73
76
  * empty list display
74
77
  */
@@ -76,7 +79,7 @@ export interface DualListProps<T>
76
79
  /**
77
80
  * item renderer
78
81
  */
79
- renderer?: (option: T) => React.ReactNode;
82
+ renderer?: (option: T) => ReactElement;
80
83
  /**
81
84
  * change handler
82
85
  */
@@ -102,7 +105,7 @@ export const DualList = <T extends AnyObject = string>({
102
105
  groupProperty,
103
106
  height = "18rem",
104
107
  labelProperty = "label" as AnyObject,
105
- valueProperty = "id" as AnyObject,
108
+ valueProperty = "value" as AnyObject,
106
109
  renderer,
107
110
  onChange,
108
111
  // @ts-expect-error ignore
@@ -244,7 +247,7 @@ export const DualList = <T extends AnyObject = string>({
244
247
  variant="link"
245
248
  aria-label="scroll to top"
246
249
  onClick={moveAllLeft}
247
- icon={{ icon: CoreIcons.chevronsLeft, rtlFlip: true }}
250
+ icon={{ icon: "icon-[mdi--chevron-double-left]", rtlFlip: true }}
248
251
  disabled={!rightOptions.length}
249
252
  />
250
253
  <Button
@@ -252,7 +255,7 @@ export const DualList = <T extends AnyObject = string>({
252
255
  variant="link"
253
256
  aria-label="scroll up"
254
257
  onClick={moveRightSelected}
255
- icon={{ icon: CoreIcons.chevronLeft, rtlFlip: true }}
258
+ icon={{ icon: "icon-[mdi--chevron-left]", rtlFlip: true }}
256
259
  disabled={!rightSelected.length}
257
260
  />
258
261
  <Button
@@ -260,7 +263,7 @@ export const DualList = <T extends AnyObject = string>({
260
263
  variant="link"
261
264
  aria-label="scroll down"
262
265
  onClick={moveLeftSelected}
263
- icon={{ icon: CoreIcons.chevronRight, rtlFlip: true }}
266
+ icon={{ icon: "icon-[mdi--chevron-right]", rtlFlip: true }}
264
267
  disabled={!leftSelected.length}
265
268
  />
266
269
  <Button
@@ -268,7 +271,7 @@ export const DualList = <T extends AnyObject = string>({
268
271
  variant="link"
269
272
  aria-label="scroll to bottom"
270
273
  onClick={moveAllRight}
271
- icon={{ icon: CoreIcons.chevronsRight, rtlFlip: true }}
274
+ icon={{ icon: "icon-[mdi--chevron-double-right]", rtlFlip: true }}
272
275
  disabled={!leftOptions.length}
273
276
  />
274
277
  </ButtonGroup>
@@ -59,8 +59,8 @@ export const List = <T extends AnyObject = string>({
59
59
  options,
60
60
  height,
61
61
  groupProperty,
62
- labelProperty,
63
- valueProperty,
62
+ labelProperty = "label" as AnyObject,
63
+ valueProperty = "value" as AnyObject,
64
64
  infoProperty,
65
65
  sortProperty,
66
66
  multiple,
@@ -324,7 +324,7 @@ export const List = <T extends AnyObject = string>({
324
324
  empty={emptyDisplay}
325
325
  info={state.activeItem?.[infoProperty ?? "info"]}
326
326
  >
327
- {async (item, label) => await (renderer?.(item) ?? label)}
327
+ {(item, label) => renderer?.(item) ?? label}
328
328
  </Options>
329
329
  </FloatingFocusManager>
330
330
  </Wrapper>
@@ -22,8 +22,8 @@
22
22
  */
23
23
 
24
24
  import { EmptyContent } from "@react-fabric/core";
25
+ import { type ReactElement } from "@react-fabric/core/dist/types/types";
25
26
  import classNames from "classnames";
26
- import { type ReactElement } from "react";
27
27
  import { Trans } from "react-i18next";
28
28
 
29
29
  export const Options = ({
@@ -35,7 +35,7 @@ import {
35
35
  useListNavigation,
36
36
  useTypeahead,
37
37
  } from "@floating-ui/react";
38
- import { Chip, CoreIcons, Icon } from "@react-fabric/core";
38
+ import { Chip, Icon } from "@react-fabric/core";
39
39
  import { isArray, isEmpty } from "@react-fabric/utilities";
40
40
  import classNames from "classnames";
41
41
  import { useCallback, useId, useLayoutEffect, useMemo } from "react";
@@ -68,7 +68,7 @@ export const Select = <T extends AnyObject = string>({
68
68
  hideHandle,
69
69
  groupProperty,
70
70
  labelProperty = "label" as AnyObject,
71
- valueProperty = "id" as AnyObject,
71
+ valueProperty = "value" as AnyObject,
72
72
  sortProperty,
73
73
  infoProperty,
74
74
  multiple,
@@ -249,7 +249,7 @@ export const Select = <T extends AnyObject = string>({
249
249
  ));
250
250
  } else if (!isEmpty(state.value) && !state.query) {
251
251
  return (
252
- <span className="self-center pointer-events-none select-none">
252
+ <span className="self-center pointer-events-none select-none truncate leading-tight">
253
253
  {renderer?.(state.value) ?? state.value[labelProperty] ?? state.value}
254
254
  </span>
255
255
  );
@@ -310,7 +310,7 @@ export const Select = <T extends AnyObject = string>({
310
310
  className={classNames(
311
311
  "appearance-none bg-transparent outline-none border-none ring-0 flex-1 peer",
312
312
  disabled && "cursor-not-allowed pointer-events-none",
313
- multiple && "min-w-24",
313
+ multiple ? "min-w-24" : "min-w-2",
314
314
  )}
315
315
  placeholder={isEmpty(state.value) ? placeholder : ""}
316
316
  onChange={(evt) => handleQuery(evt.target.value)}
@@ -324,16 +324,15 @@ export const Select = <T extends AnyObject = string>({
324
324
  disabled && "pointer-events-none",
325
325
  )}
326
326
  onClick={() => !disabled && openDropdown()}
327
- icon={CoreIcons.chevronDown}
327
+ icon="icon-[mdi--chevron-down]"
328
328
  />
329
329
  )}
330
330
  {state.loading && (
331
331
  <Icon
332
- animate="spin"
333
332
  className={classNames(
334
333
  "flex-content p-2 z-0 order-9 text-muted pointer-events-none",
335
334
  )}
336
- icon={CoreIcons.spinner}
335
+ icon="icon-[svg-spinners--eclipse]"
337
336
  />
338
337
  )}
339
338
  {state.open && !state.loading && (
@@ -360,7 +359,7 @@ export const Select = <T extends AnyObject = string>({
360
359
  empty={emptyDisplay}
361
360
  info={state.activeItem?.[infoProperty ?? "info"]}
362
361
  >
363
- {async (item, label) => await (renderer?.(item) ?? label)}
362
+ {(item, label) => renderer?.(item) ?? label}
364
363
  </Options>
365
364
  </FloatingFocusManager>
366
365
  </FloatingPortal>
@@ -22,10 +22,11 @@
22
22
  */
23
23
 
24
24
  import {
25
+ type NestedKeys,
26
+ type ReactElement,
25
27
  type RefProp,
26
28
  type TestProps,
27
29
  } from "@react-fabric/core/dist/types/types";
28
- import { type ReactElement } from "react";
29
30
 
30
31
  export interface InputProps<V = string> extends TestProps {
31
32
  /**
@@ -145,23 +146,23 @@ export interface BaseSelectProps<T extends AnyObject = string> {
145
146
  /**
146
147
  * group by property name
147
148
  */
148
- groupProperty?: keyof T;
149
+ groupProperty?: NestedKeys<T>;
149
150
  /**
150
151
  * label property name
151
152
  */
152
- labelProperty?: keyof T;
153
+ labelProperty?: NestedKeys<T>;
153
154
  /**
154
155
  * value property name
155
156
  */
156
- valueProperty?: keyof T;
157
+ valueProperty?: NestedKeys<T>;
157
158
  /**
158
159
  * value property name
159
160
  */
160
- infoProperty?: keyof T;
161
+ infoProperty?: NestedKeys<T>;
161
162
  /**
162
163
  * value property name
163
164
  */
164
- sortProperty?: keyof T | true;
165
+ sortProperty?: NestedKeys<T> | true;
165
166
  /**
166
167
  * searchable list
167
168
  */
@@ -185,7 +186,7 @@ export interface BaseSelectProps<T extends AnyObject = string> {
185
186
  /**
186
187
  * item renderer
187
188
  */
188
- renderer?: (option: T) => React.ReactNode;
189
+ renderer?: (option: T) => ReactElement;
189
190
  /**
190
191
  * item matcher
191
192
  */
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes