@saas-ui/forms 2.6.3 → 2.6.4
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.
- package/CHANGELOG.md +12 -5
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/base-field.tsx +9 -1
- package/src/types.ts +4 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# @saas-ui/forms
|
2
2
|
|
3
|
+
## 2.6.4
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 4c03ddb: Added support for horizontal form fields
|
8
|
+
- @saas-ui/core@2.5.3
|
9
|
+
|
3
10
|
## 2.6.3
|
4
11
|
|
5
12
|
### Patch Changes
|
@@ -1203,12 +1210,12 @@
|
|
1203
1210
|
Add this somewhere in the root of your project.
|
1204
1211
|
|
1205
1212
|
```ts
|
1206
|
-
import { Form } from
|
1207
|
-
import { yupResolver, yupFieldResolver } from
|
1208
|
-
import { AnyObjectSchema } from
|
1213
|
+
import { Form } from "@saas-ui/react";
|
1214
|
+
import { yupResolver, yupFieldResolver } from "@saas-ui/forms/yup"; // yupResolver is exported from here as well for convenience.
|
1215
|
+
import { AnyObjectSchema } from "yup";
|
1209
1216
|
|
1210
|
-
Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema) // @hookform/resolvers
|
1211
|
-
Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema) // AutoForm field resolver
|
1217
|
+
Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema); // @hookform/resolvers
|
1218
|
+
Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema); // AutoForm field resolver
|
1212
1219
|
```
|
1213
1220
|
|
1214
1221
|
- 9391c44: Fixed peer dependency issues.
|
package/dist/index.d.mts
CHANGED
@@ -491,6 +491,10 @@ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName e
|
|
491
491
|
* The input placeholder
|
492
492
|
*/
|
493
493
|
placeholder?: string;
|
494
|
+
/**
|
495
|
+
* Whether the label is positioned vertically or horizontally
|
496
|
+
*/
|
497
|
+
direction?: 'row' | 'column';
|
494
498
|
}
|
495
499
|
type GetBaseField<TProps extends object = object> = () => {
|
496
500
|
extraProps: string[];
|
@@ -871,7 +875,7 @@ type InputRightButtonProps = ButtonProps;
|
|
871
875
|
declare const InputRightButton: _chakra_ui_react.ComponentWithAs<"div", ButtonProps>;
|
872
876
|
|
873
877
|
declare const useBaseField: (props: BaseFieldProps) => {
|
874
|
-
controlProps: Pick<BaseFieldProps<react_hook_form.FieldValues, string>, "id" | "isRequired" | "isDisabled" | "isInvalid" | "isReadOnly">;
|
878
|
+
controlProps: Pick<BaseFieldProps<react_hook_form.FieldValues, string>, "id" | "direction" | "isRequired" | "isDisabled" | "isInvalid" | "isReadOnly">;
|
875
879
|
error: any;
|
876
880
|
touched: any;
|
877
881
|
name: string;
|
package/dist/index.d.ts
CHANGED
@@ -491,6 +491,10 @@ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName e
|
|
491
491
|
* The input placeholder
|
492
492
|
*/
|
493
493
|
placeholder?: string;
|
494
|
+
/**
|
495
|
+
* Whether the label is positioned vertically or horizontally
|
496
|
+
*/
|
497
|
+
direction?: 'row' | 'column';
|
494
498
|
}
|
495
499
|
type GetBaseField<TProps extends object = object> = () => {
|
496
500
|
extraProps: string[];
|
@@ -871,7 +875,7 @@ type InputRightButtonProps = ButtonProps;
|
|
871
875
|
declare const InputRightButton: _chakra_ui_react.ComponentWithAs<"div", ButtonProps>;
|
872
876
|
|
873
877
|
declare const useBaseField: (props: BaseFieldProps) => {
|
874
|
-
controlProps: Pick<BaseFieldProps<react_hook_form.FieldValues, string>, "id" | "isRequired" | "isDisabled" | "isInvalid" | "isReadOnly">;
|
878
|
+
controlProps: Pick<BaseFieldProps<react_hook_form.FieldValues, string>, "id" | "direction" | "isRequired" | "isDisabled" | "isInvalid" | "isReadOnly">;
|
875
879
|
error: any;
|
876
880
|
touched: any;
|
877
881
|
name: string;
|
package/dist/index.js
CHANGED
@@ -561,6 +561,7 @@ var useBaseField = (props) => {
|
|
561
561
|
const [fieldProps] = (0, import_core3.splitProps)(props, ["name", "label", "help", "hideLabel"]);
|
562
562
|
const [controlProps] = (0, import_core3.splitProps)(props, [
|
563
563
|
"id",
|
564
|
+
"direction",
|
564
565
|
"isDisabled",
|
565
566
|
"isInvalid",
|
566
567
|
"isReadOnly",
|
@@ -579,14 +580,23 @@ var useBaseField = (props) => {
|
|
579
580
|
var BaseField = (props) => {
|
580
581
|
const { controlProps, label, help, hideLabel, error } = useBaseField(props);
|
581
582
|
const isInvalid = !!error || controlProps.isInvalid;
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
583
|
+
const { direction, ...rest } = controlProps;
|
584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
585
|
+
import_react12.FormControl,
|
586
|
+
{
|
587
|
+
...rest,
|
588
|
+
isInvalid,
|
589
|
+
variant: direction === "row" ? "horizontal" : void 0,
|
590
|
+
children: [
|
591
|
+
label && !hideLabel ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.FormLabel, { children: label }) : null,
|
592
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react12.Box, { children: [
|
593
|
+
props.children,
|
594
|
+
help && !(error == null ? void 0 : error.message) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.FormHelperText, { children: help }) : null,
|
595
|
+
(error == null ? void 0 : error.message) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.FormErrorMessage, { children: error == null ? void 0 : error.message })
|
596
|
+
] })
|
597
|
+
]
|
598
|
+
}
|
599
|
+
);
|
590
600
|
};
|
591
601
|
BaseField.displayName = "BaseField";
|
592
602
|
|