@saas-ui/forms 2.6.1 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/base-field.tsx +3 -1
- package/src/create-field.tsx +1 -0
- package/src/layout.tsx +11 -2
- package/src/number-input/number-input.test.tsx +3 -1
- package/src/select/select.test.tsx +4 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@saas-ui/forms",
|
3
|
-
"version": "2.6.
|
3
|
+
"version": "2.6.3",
|
4
4
|
"description": "Fully functional forms for Chakra UI.",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"exports": {
|
@@ -104,7 +104,7 @@
|
|
104
104
|
"@chakra-ui/react-utils": "^2.0.12",
|
105
105
|
"@chakra-ui/utils": "^2.0.15",
|
106
106
|
"@hookform/resolvers": "^3.3.4",
|
107
|
-
"@saas-ui/core": "2.5.
|
107
|
+
"@saas-ui/core": "2.5.2",
|
108
108
|
"react-hook-form": "^7.50.1"
|
109
109
|
},
|
110
110
|
"peerDependencies": {
|
package/src/base-field.tsx
CHANGED
@@ -57,8 +57,10 @@ export const useBaseField = (props: BaseFieldProps) => {
|
|
57
57
|
export const BaseField: React.FC<BaseFieldProps> = (props) => {
|
58
58
|
const { controlProps, label, help, hideLabel, error } = useBaseField(props)
|
59
59
|
|
60
|
+
const isInvalid = !!error || controlProps.isInvalid
|
61
|
+
|
60
62
|
return (
|
61
|
-
<FormControl {...controlProps} isInvalid={
|
63
|
+
<FormControl {...controlProps} isInvalid={isInvalid}>
|
62
64
|
{label && !hideLabel ? <FormLabel>{label}</FormLabel> : null}
|
63
65
|
<Box>
|
64
66
|
{props.children}
|
package/src/create-field.tsx
CHANGED
package/src/layout.tsx
CHANGED
@@ -5,11 +5,15 @@ import {
|
|
5
5
|
omitThemingProps,
|
6
6
|
SimpleGrid,
|
7
7
|
SimpleGridProps,
|
8
|
+
ThemingProps,
|
9
|
+
useStyleConfig,
|
8
10
|
useTheme,
|
9
11
|
} from '@chakra-ui/react'
|
10
12
|
import { cx } from '@chakra-ui/utils'
|
11
13
|
|
12
|
-
export interface FormLayoutProps
|
14
|
+
export interface FormLayoutProps
|
15
|
+
extends ThemingProps<'SuiFormLayout'>,
|
16
|
+
SimpleGridProps {}
|
13
17
|
|
14
18
|
interface FormLayoutItemProps {
|
15
19
|
children: React.ReactNode
|
@@ -24,7 +28,6 @@ FormLayoutItem.displayName = 'FormLayoutItem'
|
|
24
28
|
/**
|
25
29
|
* Create consistent field spacing and positioning.
|
26
30
|
*
|
27
|
-
*
|
28
31
|
* Renders form items in a `SimpleGrid`
|
29
32
|
* @see https://chakra-ui.com/docs/layout/simple-grid
|
30
33
|
*
|
@@ -37,6 +40,8 @@ export const FormLayout = ({ children, ...props }: FormLayoutProps) => {
|
|
37
40
|
spacing: 4,
|
38
41
|
}
|
39
42
|
|
43
|
+
const styles = useStyleConfig('SuiFormLayout', props)
|
44
|
+
|
40
45
|
const gridProps = omitThemingProps({
|
41
46
|
...defaultProps,
|
42
47
|
...props,
|
@@ -46,6 +51,10 @@ export const FormLayout = ({ children, ...props }: FormLayoutProps) => {
|
|
46
51
|
<SimpleGrid
|
47
52
|
{...gridProps}
|
48
53
|
className={cx('sui-form__layout', props.className)}
|
54
|
+
sx={{
|
55
|
+
...styles,
|
56
|
+
...props.sx,
|
57
|
+
}}
|
49
58
|
>
|
50
59
|
{children}
|
51
60
|
</SimpleGrid>
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import * as React from 'react'
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { testStories } from '@saas-ui/test-utils'
|
4
4
|
import * as stories from './select.stories'
|
5
5
|
|
6
6
|
const { MaxHeight, ...rest } = stories
|
7
7
|
|
8
|
-
testStories
|
8
|
+
testStories(rest, {
|
9
|
+
a11y: false,
|
10
|
+
})
|