@saas-ui/forms 2.3.12 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -14
- package/dist/index.mjs.map +1 -1
- package/dist/yup/index.d.ts +9 -1
- package/dist/zod/index.d.ts +9 -1
- package/package.json +2 -2
- package/src/auto-form.tsx +6 -3
- package/src/default-fields.tsx +3 -0
- package/src/field-resolver.ts +26 -7
- package/src/number-input/number-input.stories.tsx +37 -16
- package/src/number-input/number-input.tsx +29 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @saas-ui/forms
|
2
2
|
|
3
|
+
## 2.4.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 73d09d9: Added support for leftAddon and rightAddon on number input types
|
8
|
+
- efca417: Improved ObjectSchema type definitions to be more strict and inherit correct field type props
|
9
|
+
|
10
|
+
### Patch Changes
|
11
|
+
|
12
|
+
- Updated dependencies [4a95712]
|
13
|
+
- Updated dependencies [4a95712]
|
14
|
+
- @saas-ui/core@2.4.0
|
15
|
+
|
3
16
|
## 2.3.12
|
4
17
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
@@ -12,7 +12,7 @@ import * as _chakra_ui_system_dist_system_types from '@chakra-ui/system/dist/sys
|
|
12
12
|
|
13
13
|
interface NumberInputOptions {
|
14
14
|
/**
|
15
|
-
* Hide the stepper.
|
15
|
+
* Hide the stepper. This will be true when `rightAddon` is provided.
|
16
16
|
*/
|
17
17
|
hideStepper?: boolean;
|
18
18
|
/**
|
@@ -31,6 +31,14 @@ interface NumberInputOptions {
|
|
31
31
|
* Props to pass to the NumberInputField component.
|
32
32
|
*/
|
33
33
|
fieldProps?: NumberInputFieldProps$1;
|
34
|
+
/**
|
35
|
+
* Either `InputLeftAddon` or `InputLeftElement`
|
36
|
+
*/
|
37
|
+
leftAddon?: React$1.ReactNode;
|
38
|
+
/**
|
39
|
+
* Either `InputRightAddon` or `InputRightElement`
|
40
|
+
*/
|
41
|
+
rightAddon?: React$1.ReactNode;
|
34
42
|
}
|
35
43
|
interface NumberInputProps extends NumberInputProps$1, NumberInputOptions {
|
36
44
|
}
|
@@ -521,11 +529,19 @@ type FieldResolver = {
|
|
521
529
|
getNestedFields(name: string): BaseFieldProps[];
|
522
530
|
};
|
523
531
|
type GetFieldResolver<TSchema = any> = (schema: TSchema) => FieldResolver;
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
}
|
528
|
-
|
532
|
+
type FieldTypes<FieldDefs = DefaultFields> = ValueOf<{
|
533
|
+
[K in keyof FieldDefs]: FieldDefs[K] extends React.FC<infer Props> ? {
|
534
|
+
type?: K;
|
535
|
+
} & Omit<Props, 'name'> : never;
|
536
|
+
}>;
|
537
|
+
type SchemaField<FieldDefs = DefaultFields> = FieldTypes<FieldDefs> | (Omit<ObjectFieldProps, 'name' | 'children'> & {
|
538
|
+
type: 'object';
|
539
|
+
properties?: Record<string, SchemaField<FieldDefs>>;
|
540
|
+
}) | (Omit<ArrayFieldProps, 'name' | 'children'> & {
|
541
|
+
type: 'array';
|
542
|
+
items?: SchemaField<FieldDefs>;
|
543
|
+
});
|
544
|
+
type ObjectSchema<FieldDefs = DefaultFields> = Record<string, SchemaField<FieldDefs>>;
|
529
545
|
declare const objectFieldResolver: GetFieldResolver<ObjectSchema>;
|
530
546
|
|
531
547
|
interface DisplayIfProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
|
package/dist/index.js
CHANGED
@@ -164,22 +164,31 @@ var import_react13 = require("@chakra-ui/react");
|
|
164
164
|
var import_react2 = require("@chakra-ui/react");
|
165
165
|
var import_core = require("@saas-ui/core");
|
166
166
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
167
|
+
var Input = (0, import_react2.forwardRef)((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberInputField, { ref, ...props }));
|
168
|
+
Input.displayName = "NumberInputField";
|
169
|
+
Input.id = "Input";
|
167
170
|
var NumberInput = (0, import_react2.forwardRef)((props, ref) => {
|
168
171
|
const {
|
169
172
|
hideStepper = false,
|
170
173
|
incrementIcon = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.ChevronUpIcon, {}),
|
171
174
|
decrementIcon = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.ChevronDownIcon, {}),
|
175
|
+
leftAddon,
|
176
|
+
rightAddon,
|
172
177
|
placeholder,
|
173
178
|
fieldProps: _fieldProps,
|
174
179
|
...rest
|
175
180
|
} = props;
|
176
181
|
const fieldProps = { placeholder, ..._fieldProps };
|
177
182
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.NumberInput, { ...rest, ref, children: [
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
179
|
-
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.InputGroup, { children: [
|
184
|
+
leftAddon,
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, { ...fieldProps }),
|
186
|
+
rightAddon
|
187
|
+
] }),
|
188
|
+
!hideStepper && !rightAddon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.NumberInputStepper, { children: [
|
180
189
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberIncrementStepper, { children: incrementIcon }),
|
181
190
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberDecrementStepper, { children: decrementIcon })
|
182
|
-
] })
|
191
|
+
] }) : null
|
183
192
|
] });
|
184
193
|
});
|
185
194
|
NumberInput.displayName = "NumberInput";
|
@@ -1334,7 +1343,8 @@ NextButton.displayName = "NextButton";
|
|
1334
1343
|
|
1335
1344
|
// src/field-resolver.ts
|
1336
1345
|
var import_utils10 = require("@chakra-ui/utils");
|
1337
|
-
var mapFields = (schema) => schema && Object.entries(schema).map(([name,
|
1346
|
+
var mapFields = (schema) => schema && Object.entries(schema).map(([name, props]) => {
|
1347
|
+
const { items, label, title, ...field } = props;
|
1338
1348
|
return {
|
1339
1349
|
...field,
|
1340
1350
|
name,
|