@saas-ui/forms 2.0.0-next.11 → 2.0.0-next.13

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.0.0-next.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Bump version
8
+ - 6c63217c: object and array field props can now be overridden using the fields prop
9
+ - Updated dependencies
10
+ - @saas-ui/core@2.0.0-next.11
11
+
12
+ ## 2.0.0-next.12
13
+
14
+ ### Patch Changes
15
+
16
+ - a7ef6dd9: Fixed issue where types for exports were not detected
17
+ - Updated dependencies [a7ef6dd9]
18
+ - @saas-ui/core@2.0.0-next.10
19
+
3
20
  ## 2.0.0-next.11
4
21
 
5
22
  ### Patch Changes
@@ -110,6 +127,38 @@
110
127
  - Updated dependencies [3a15e8c8]
111
128
  - @saas-ui/core@2.0.0-next.0
112
129
 
130
+ ## 1.5.5
131
+
132
+ ### Patch Changes
133
+
134
+ - Fix types path
135
+ - Updated dependencies
136
+ - @saas-ui/button@1.4.2
137
+ - @saas-ui/input-right-button@1.4.2
138
+ - @saas-ui/number-input@1.4.2
139
+ - @saas-ui/password-input@1.4.2
140
+ - @saas-ui/pin-input@1.4.2
141
+ - @saas-ui/radio@1.4.3
142
+ - @saas-ui/react-utils@1.2.2
143
+ - @saas-ui/select@1.4.2
144
+ - @saas-ui/stepper@1.4.2
145
+
146
+ ## 1.5.4
147
+
148
+ ### Patch Changes
149
+
150
+ - b2302a3: Add types to package.json exports
151
+ - Updated dependencies [b2302a3]
152
+ - @saas-ui/button@1.4.1
153
+ - @saas-ui/input-right-button@1.4.1
154
+ - @saas-ui/number-input@1.4.1
155
+ - @saas-ui/password-input@1.4.1
156
+ - @saas-ui/pin-input@1.4.1
157
+ - @saas-ui/radio@1.4.2
158
+ - @saas-ui/react-utils@1.2.1
159
+ - @saas-ui/select@1.4.1
160
+ - @saas-ui/stepper@1.4.1
161
+
113
162
  ## 1.5.3
114
163
 
115
164
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -289,7 +289,7 @@ interface DisplayIfProps<TFieldValues extends FieldValues = FieldValues, TName e
289
289
  * @see Docs https://saas-ui.dev/docs/components/forms/form
290
290
  */
291
291
  declare const DisplayIf: {
292
- <TFieldValues extends FieldValues = FieldValues, TName extends react_hook_form.Path<TFieldValues> = react_hook_form.Path<TFieldValues>>({ children, name, defaultValue, isDisabled, isExact, condition, }: DisplayIfProps<TFieldValues, TName>): React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>> | null;
292
+ <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ children, name, defaultValue, isDisabled, isExact, condition, }: DisplayIfProps<TFieldValues, TName>): React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>> | null;
293
293
  displayName: string;
294
294
  };
295
295
 
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ var useFieldProps = (name) => {
46
46
  var _a;
47
47
  const parsedName = name == null ? void 0 : name.replace(/\.[0-9]/g, ".$");
48
48
  const context = useFormContext();
49
- return (_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName];
49
+ return ((_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName]) || {};
50
50
  };
51
51
  var FormProvider = (props) => {
52
52
  const { children, fieldResolver, schema, fields, ...rest } = props;
@@ -301,6 +301,7 @@ var SelectButton = react.forwardRef(
301
301
  {
302
302
  as: react.Button,
303
303
  id: id || React13__namespace.useId(),
304
+ ...buttonStyles,
304
305
  ...rest,
305
306
  onFocus,
306
307
  onBlur,
@@ -311,7 +312,6 @@ var SelectButton = react.forwardRef(
311
312
  "data-required": utils.dataAttr(isRequired),
312
313
  rightIcon,
313
314
  ref,
314
- sx: buttonStyles,
315
315
  children: renderValue(displayValue) || placeholder
316
316
  }
317
317
  );
@@ -765,15 +765,16 @@ var ArrayFieldContainer = React13__namespace.forwardRef(
765
765
  children,
766
766
  ...fieldProps
767
767
  }, ref) => {
768
+ const overrides = useFieldProps(name);
768
769
  const context = useArrayField({
769
770
  name,
770
771
  defaultValue,
771
772
  keyName,
772
- min,
773
- max
773
+ min: min || (overrides == null ? void 0 : overrides.min),
774
+ max: max || (overrides == null ? void 0 : overrides.max)
774
775
  });
775
776
  React13__namespace.useImperativeHandle(ref, () => context, [ref, context]);
776
- return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(BaseField, { name, ...fieldProps, children }) });
777
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(BaseField, { name, ...fieldProps, ...overrides, children }) });
777
778
  }
778
779
  );
779
780
  ArrayFieldContainer.displayName = "ArrayFieldContainer";
@@ -782,10 +783,28 @@ var FormLegend = (props) => {
782
783
  return /* @__PURE__ */ jsxRuntime.jsx(react.FormLabel, { as: "legend", sx: styles, ...props });
783
784
  };
784
785
  var ObjectField = (props) => {
785
- const { name, label, hideLabel, children, columns, spacing, ...fieldProps } = props;
786
- return /* @__PURE__ */ jsxRuntime.jsxs(react.FormControl, { name, as: "fieldset", ...fieldProps, children: [
787
- /* @__PURE__ */ jsxRuntime.jsx(FormLegend, { display: hideLabel ? "none" : "block", children: label }),
788
- /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { columns, gridGap: spacing, children: mapNestedFields(name, children) })
786
+ const {
787
+ name,
788
+ label,
789
+ hideLabel: hideLabelProp,
790
+ children,
791
+ columns: columnsProp,
792
+ spacing: spacingProp,
793
+ ...fieldProps
794
+ } = props;
795
+ const { hideLabel, columns, spacing, ...overrides } = useFieldProps(
796
+ name
797
+ );
798
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.FormControl, { name, as: "fieldset", ...fieldProps, ...overrides, children: [
799
+ /* @__PURE__ */ jsxRuntime.jsx(FormLegend, { display: hideLabelProp || hideLabel ? "none" : "block", children: label }),
800
+ /* @__PURE__ */ jsxRuntime.jsx(
801
+ FormLayout,
802
+ {
803
+ columns: columnsProp || columns,
804
+ gridGap: spacingProp || spacing,
805
+ children: mapNestedFields(name, children)
806
+ }
807
+ )
789
808
  ] });
790
809
  };
791
810
  ObjectField.displayName = "ObjectField";