@react-fabric/form 1.0.0-beta.14 → 1.0.0-beta.17

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.
@@ -32,6 +32,9 @@ var Form = function Form(_ref) {
32
32
  resolver: schema && yup.yupResolver(schema),
33
33
  defaultValues: defaultValues
34
34
  });
35
+ react.useEffect(function () {
36
+ form.reset();
37
+ }, []);
35
38
  var _useTransition = react.useTransition(),
36
39
  _useTransition2 = _slicedToArray(_useTransition, 2),
37
40
  startTransition = _useTransition2[1];
@@ -138,7 +138,7 @@ var ArrayInput = function ArrayInput(_ref) {
138
138
  children: [typeof children === "function" ? children({
139
139
  index: index,
140
140
  name: "".concat(name, ".").concat(index)
141
- }) : react.Children.map(children, function (child) {
141
+ }) : utilities$1.cloneChildren(children, function (child) {
142
142
  return /*#__PURE__*/react.cloneElement(child, Object.assign({
143
143
  disabled: disabled,
144
144
  readOnly: readOnly,
@@ -1 +1 @@
1
- @layer comp{.colorPicker{--color-shadow:theme(borderColor.base);& input{@apply bg-base text-base !border !border-solid !rounded-sm !border-base focus:!border-primary !shadow-none;line-height:2;padding:0 4px!important}& label{@apply !text-base}& :global(.flexbox-fix){@apply !border-t-muted justify-center;&>div>div{@apply text-center}& span>div{box-shadow:inset 0 0 1px 1px theme(borderColor.base)!important}}}}
1
+ @layer comp{.colorPicker{--color-shadow:theme(borderColor.base);& input{background-color:theme(backgroundColor.base);border:1px solid theme(borderColor.base);border-radius:theme(borderRadius.sm);box-shadow:none;color:theme(textColor.base);line-height:2;padding:0 4px!important;&:focus{border-color:theme(borderColor.primary.DEFAULT)}}& label{color:theme(textColor.base)}& :global(.flexbox-fix){border-color:theme(borderColor.muted);justify-content:center;&>div>div{text-align:center}& span>div{box-shadow:inset 0 0 1px 1px theme(borderColor.base)!important}}}}
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var utilities = require('@react-fabric/utilities');
5
6
  var classNames = require('classnames');
6
7
  var react = require('react');
7
8
  var Field_module = require('../internal/Field.module.css');
@@ -20,8 +21,8 @@ var Field = function Field(_ref) {
20
21
  return /*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
21
22
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
22
23
  className: classNames(Field_module.fieldGroup, !plain && !noOutline && "outline", !plain && "bg-base", "flex-1 rounded", !vertical && "flex flex-nowrap"),
23
- children: react.Children.map(children, function (child) {
24
- return child && /*#__PURE__*/react.cloneElement(child, {
24
+ children: utilities.cloneChildren(children, function (child) {
25
+ return /*#__PURE__*/react.cloneElement(child, {
25
26
  "data-inner": true
26
27
  });
27
28
  })
@@ -1 +1 @@
1
- @layer comp{.fileInput{&::-webkit-file-upload-button{@apply bg-primary-500 opacity-80 hover:opacity-90 text-white rounded border-none py-0 cursor-pointer}&[aria-invalid=true]::-webkit-file-upload-button{@apply bg-danger-500}&:disabled::-webkit-file-upload-button{@apply bg-muted pointer-events-none}&[readOnly]{@apply pointer-events-none}}}
1
+ @layer comp{.fileInput{&::-webkit-file-upload-button{background-color:theme(backgroundColor.primary.500);border:0;border-radius:theme(borderRadius.DEFAULT);color:theme(textColor.white);cursor:pointer;opacity:.8;padding-block:0;&:hover{opacity:.9}}&[aria-invalid=true]::-webkit-file-upload-button{background-color:theme(backgroundColor.danger.500)}&:disabled::-webkit-file-upload-button{background-color:theme(backgroundColor.muted);pointer-events:none}&[readOnly]{pointer-events:none}}}
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var utilities = require('@react-fabric/utilities');
5
6
  var react = require('react');
6
7
  var FieldWrapper = require('../internal/FieldWrapper.js');
7
8
  var jsxRuntime = require('react/jsx-runtime');
@@ -19,7 +20,7 @@ var RadioGroup = function RadioGroup(_ref) {
19
20
  return /*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
20
21
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
21
22
  className: className,
22
- children: react.Children.map(children, function (child) {
23
+ children: utilities.cloneChildren(children, function (child) {
23
24
  return /*#__PURE__*/react.cloneElement(child, {
24
25
  name: name,
25
26
  onChange: onChange,
@@ -7,7 +7,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
7
7
  import _regeneratorRuntime from '@babel/runtime/regenerator';
8
8
  import { yupResolver } from '@hookform/resolvers/yup';
9
9
  import { useDebounce } from '@react-fabric/core';
10
- import { useRef, useTransition, useEffect, useCallback, useImperativeHandle } from 'react';
10
+ import { useRef, useEffect, useTransition, useCallback, useImperativeHandle } from 'react';
11
11
  import { useForm, FormProvider } from 'react-hook-form';
12
12
  import { jsx, jsxs } from 'react/jsx-runtime';
13
13
 
@@ -32,6 +32,9 @@ var Form = function Form(_ref) {
32
32
  resolver: schema && yupResolver(schema),
33
33
  defaultValues: defaultValues
34
34
  });
35
+ useEffect(function () {
36
+ form.reset();
37
+ }, []);
35
38
  var _useTransition = useTransition(),
36
39
  _useTransition2 = _slicedToArray(_useTransition, 2),
37
40
  startTransition = _useTransition2[1];
@@ -5,9 +5,9 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
5
5
  import { DndContext } from '@dnd-kit/core';
6
6
  import { SortableContext, useSortable } from '@dnd-kit/sortable';
7
7
  import { Icon, CoreIcons, Button, Tooltip } from '@react-fabric/core';
8
- import { isString } from '@react-fabric/utilities';
8
+ import { cloneChildren, isString } from '@react-fabric/utilities';
9
9
  import classNames from 'classnames';
10
- import { useMemo, useCallback, useImperativeHandle, Children, cloneElement } from 'react';
10
+ import { useMemo, useCallback, useImperativeHandle, cloneElement } from 'react';
11
11
  import { useFormContext, useFieldArray } from 'react-hook-form';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { FieldWrapper } from '../internal/FieldWrapper.js';
@@ -138,7 +138,7 @@ var ArrayInput = function ArrayInput(_ref) {
138
138
  children: [typeof children === "function" ? children({
139
139
  index: index,
140
140
  name: "".concat(name, ".").concat(index)
141
- }) : Children.map(children, function (child) {
141
+ }) : cloneChildren(children, function (child) {
142
142
  return /*#__PURE__*/cloneElement(child, Object.assign({
143
143
  disabled: disabled,
144
144
  readOnly: readOnly,
@@ -1 +1 @@
1
- @layer comp{.colorPicker{--color-shadow:theme(borderColor.base);& input{@apply bg-base text-base !border !border-solid !rounded-sm !border-base focus:!border-primary !shadow-none;line-height:2;padding:0 4px!important}& label{@apply !text-base}& :global(.flexbox-fix){@apply !border-t-muted justify-center;&>div>div{@apply text-center}& span>div{box-shadow:inset 0 0 1px 1px theme(borderColor.base)!important}}}}
1
+ @layer comp{.colorPicker{--color-shadow:theme(borderColor.base);& input{background-color:theme(backgroundColor.base);border:1px solid theme(borderColor.base);border-radius:theme(borderRadius.sm);box-shadow:none;color:theme(textColor.base);line-height:2;padding:0 4px!important;&:focus{border-color:theme(borderColor.primary.DEFAULT)}}& label{color:theme(textColor.base)}& :global(.flexbox-fix){border-color:theme(borderColor.muted);justify-content:center;&>div>div{text-align:center}& span>div{box-shadow:inset 0 0 1px 1px theme(borderColor.base)!important}}}}
@@ -2,8 +2,9 @@
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { cloneChildren } from '@react-fabric/utilities';
5
6
  import classNames from 'classnames';
6
- import { Children, cloneElement } from 'react';
7
+ import { cloneElement } from 'react';
7
8
  import classes from '../internal/Field.module.css';
8
9
  import { FieldWrapper } from '../internal/FieldWrapper.js';
9
10
  import { jsx } from 'react/jsx-runtime';
@@ -20,8 +21,8 @@ var Field = function Field(_ref) {
20
21
  return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
21
22
  children: /*#__PURE__*/jsx("div", {
22
23
  className: classNames(classes.fieldGroup, !plain && !noOutline && "outline", !plain && "bg-base", "flex-1 rounded", !vertical && "flex flex-nowrap"),
23
- children: Children.map(children, function (child) {
24
- return child && /*#__PURE__*/cloneElement(child, {
24
+ children: cloneChildren(children, function (child) {
25
+ return /*#__PURE__*/cloneElement(child, {
25
26
  "data-inner": true
26
27
  });
27
28
  })
@@ -1 +1 @@
1
- @layer comp{.fileInput{&::-webkit-file-upload-button{@apply bg-primary-500 opacity-80 hover:opacity-90 text-white rounded border-none py-0 cursor-pointer}&[aria-invalid=true]::-webkit-file-upload-button{@apply bg-danger-500}&:disabled::-webkit-file-upload-button{@apply bg-muted pointer-events-none}&[readOnly]{@apply pointer-events-none}}}
1
+ @layer comp{.fileInput{&::-webkit-file-upload-button{background-color:theme(backgroundColor.primary.500);border:0;border-radius:theme(borderRadius.DEFAULT);color:theme(textColor.white);cursor:pointer;opacity:.8;padding-block:0;&:hover{opacity:.9}}&[aria-invalid=true]::-webkit-file-upload-button{background-color:theme(backgroundColor.danger.500)}&:disabled::-webkit-file-upload-button{background-color:theme(backgroundColor.muted);pointer-events:none}&[readOnly]{pointer-events:none}}}
@@ -2,7 +2,8 @@
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
- import { Children, cloneElement } from 'react';
5
+ import { cloneChildren } from '@react-fabric/utilities';
6
+ import { cloneElement } from 'react';
6
7
  import { FieldWrapper } from '../internal/FieldWrapper.js';
7
8
  import { jsx } from 'react/jsx-runtime';
8
9
 
@@ -19,7 +20,7 @@ var RadioGroup = function RadioGroup(_ref) {
19
20
  return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
20
21
  children: /*#__PURE__*/jsx("div", {
21
22
  className: className,
22
- children: Children.map(children, function (child) {
23
+ children: cloneChildren(children, function (child) {
23
24
  return /*#__PURE__*/cloneElement(child, {
24
25
  name: name,
25
26
  onChange: onChange,
@@ -1,4 +1,4 @@
1
- import { type ReactNode, type RefObject } from "react";
1
+ import { type ReactNode, type Ref } from "react";
2
2
  export interface ArrayInputProps {
3
3
  /**
4
4
  * input label
@@ -52,7 +52,7 @@ export interface ArrayInputProps {
52
52
  * fixed length list
53
53
  */
54
54
  fixedList?: boolean;
55
- arrayRef?: RefObject<{
55
+ arrayRef?: Ref<{
56
56
  addItem: (item: AnyObject) => void;
57
57
  removeItem: (idx: number) => void;
58
58
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/form",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.17",
4
4
  "description": "RUF: Form package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -37,10 +37,10 @@
37
37
  "@dnd-kit/modifiers": "^7.0.0",
38
38
  "@dnd-kit/sortable": "^8.0.0",
39
39
  "@dnd-kit/utilities": "^3.2.2",
40
- "@floating-ui/react": "0.26.24",
40
+ "@floating-ui/react": "^0.26.24",
41
41
  "@hookform/resolvers": "^3.9.0",
42
- "@react-fabric/core": "^1.0.0-beta.14",
43
- "@react-fabric/utilities": "^1.0.0-beta.14",
42
+ "@react-fabric/core": "^1.0.0-beta.17",
43
+ "@react-fabric/utilities": "^1.0.0-beta.17",
44
44
  "classnames": "^2.5.1",
45
45
  "color": "^4.2.3",
46
46
  "react-color": "^2.19.3",
@@ -60,5 +60,5 @@
60
60
  "node": ">=18.12.0",
61
61
  "npm": ">=8.19.0"
62
62
  },
63
- "gitHead": "105e7af06bb2ef8f47e0bfbf29fa890c7856f7d8"
63
+ "gitHead": "a2a0f20255da48d1cbcbcfe100fd3fbd4d13da67"
64
64
  }
package/src/form/Form.tsx CHANGED
@@ -89,6 +89,10 @@ export const Form = <K extends KeyValue>({
89
89
  defaultValues: defaultValues as DefaultValues<K>,
90
90
  });
91
91
 
92
+ useEffect(() => {
93
+ form.reset();
94
+ }, []);
95
+
92
96
  const [, startTransition] = useTransition();
93
97
  const changeHandler = useDebounce(onChange, [onChange]);
94
98
  useEffect(() => {
@@ -24,17 +24,16 @@
24
24
  import { DndContext, type DragEndEvent } from "@dnd-kit/core";
25
25
  import { SortableContext, useSortable } from "@dnd-kit/sortable";
26
26
  import { Button, CoreIcons, Icon, Tooltip } from "@react-fabric/core";
27
- import { isString } from "@react-fabric/utilities";
27
+ import { cloneChildren, isString } from "@react-fabric/utilities";
28
28
  import classNames from "classnames";
29
29
  import {
30
- Children,
31
30
  cloneElement,
32
31
  useCallback,
33
32
  useImperativeHandle,
34
33
  useMemo,
35
34
  type PropsWithChildren,
36
35
  type ReactNode,
37
- type RefObject,
36
+ type Ref,
38
37
  } from "react";
39
38
  import { useFieldArray, useFormContext } from "react-hook-form";
40
39
  import { useTranslation } from "react-i18next";
@@ -96,7 +95,7 @@ export interface ArrayInputProps {
96
95
  * fixed length list
97
96
  */
98
97
  fixedList?: boolean;
99
- arrayRef?: RefObject<{
98
+ arrayRef?: Ref<{
100
99
  addItem: (item: AnyObject) => void;
101
100
  removeItem: (idx: number) => void;
102
101
  }>;
@@ -255,7 +254,7 @@ export const ArrayInput = ({
255
254
  index,
256
255
  name: `${name}.${index}`,
257
256
  })
258
- : Children.map(children, (child: AnyObject) =>
257
+ : cloneChildren(children, (child: AnyObject) =>
259
258
  cloneElement(
260
259
  child,
261
260
  Object.assign(
@@ -26,21 +26,31 @@
26
26
  --color-shadow: theme(borderColor.base);
27
27
 
28
28
  & input {
29
- @apply bg-base text-base !border !border-solid !rounded-sm !border-base focus:!border-primary !shadow-none;
30
-
31
29
  padding: 0 4px !important;
30
+
32
31
  line-height: 2;
32
+ color: theme(textColor.base);
33
+
34
+ background-color: theme(backgroundColor.base);
35
+ border: 1px solid theme(borderColor.base);
36
+ border-radius: theme(borderRadius.sm);
37
+ box-shadow: none;
38
+
39
+ &:focus {
40
+ border-color: theme(borderColor.primary.DEFAULT);
41
+ }
33
42
  }
34
43
 
35
44
  & label {
36
- @apply !text-base;
45
+ color: theme(textColor.base);
37
46
  }
38
47
 
39
48
  & :global(.flexbox-fix) {
40
- @apply !border-t-muted justify-center;
49
+ justify-content: center;
50
+ border-color: theme(borderColor.muted);
41
51
 
42
52
  & > div > div {
43
- @apply text-center;
53
+ text-align: center;
44
54
  }
45
55
 
46
56
  & span > div {
@@ -25,8 +25,9 @@ import {
25
25
  type ChildrenProp,
26
26
  type CssProp,
27
27
  } from "@react-fabric/core/dist/types/types";
28
+ import { cloneChildren } from "@react-fabric/utilities";
28
29
  import classNames from "classnames";
29
- import { Children, cloneElement } from "react";
30
+ import { cloneElement } from "react";
30
31
  import classes from "../internal/Field.module.css";
31
32
  import { FieldWrapper } from "../internal/FieldWrapper";
32
33
 
@@ -90,13 +91,10 @@ export const Field = ({
90
91
  !vertical && "flex flex-nowrap",
91
92
  )}
92
93
  >
93
- {Children.map(
94
- children,
95
- (child) =>
96
- child &&
97
- cloneElement(child as AnyObject, {
98
- "data-inner": true,
99
- }),
94
+ {cloneChildren(children, (child: AnyObject) =>
95
+ cloneElement(child, {
96
+ "data-inner": true,
97
+ }),
100
98
  )}
101
99
  </div>
102
100
  </FieldWrapper>
@@ -24,19 +24,33 @@
24
24
  @layer comp {
25
25
  .fileInput {
26
26
  &::-webkit-file-upload-button {
27
- @apply bg-primary-500 opacity-80 hover:opacity-90 text-white rounded border-none py-0 cursor-pointer;
27
+ cursor: pointer;
28
+
29
+ padding-block: 0;
30
+
31
+ color: theme(textColor.white);
32
+
33
+ opacity: 0.8;
34
+ background-color: theme(backgroundColor.primary.500);
35
+ border: 0;
36
+ border-radius: theme(borderRadius.DEFAULT);
37
+
38
+ &:hover {
39
+ opacity: 0.9;
40
+ }
28
41
  }
29
42
 
30
43
  &[aria-invalid="true"]::-webkit-file-upload-button {
31
- @apply bg-danger-500;
44
+ background-color: theme(backgroundColor.danger.500);
32
45
  }
33
46
 
34
47
  &:disabled::-webkit-file-upload-button {
35
- @apply bg-muted pointer-events-none;
48
+ pointer-events: none;
49
+ background-color: theme(backgroundColor.muted);
36
50
  }
37
51
 
38
52
  &[readOnly] {
39
- @apply pointer-events-none;
53
+ pointer-events: none;
40
54
  }
41
55
  }
42
56
  }
@@ -25,7 +25,8 @@ import {
25
25
  type ChildrenProp,
26
26
  type CssProp,
27
27
  } from "@react-fabric/core/dist/types/types";
28
- import { Children, cloneElement } from "react";
28
+ import { cloneChildren } from "@react-fabric/utilities";
29
+ import { cloneElement } from "react";
29
30
  import { FieldWrapper } from "../internal/FieldWrapper";
30
31
  import { type Radio } from "./Radio";
31
32
 
@@ -84,8 +85,8 @@ export const RadioGroup = ({
84
85
  return (
85
86
  <FieldWrapper {...rest}>
86
87
  <div className={className}>
87
- {Children.map(children, (child) =>
88
- cloneElement(child as AnyObject, {
88
+ {cloneChildren(children, (child: AnyObject) =>
89
+ cloneElement(child, {
89
90
  name,
90
91
  onChange,
91
92
  width: optionWidth,