@vygruppen/spor-react 12.8.7 → 12.8.9
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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-postinstall.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/index.cjs +55 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +55 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/datepicker/DatePicker.tsx +1 -0
- package/src/datepicker/DateRangePicker.tsx +1 -0
- package/src/input/Field.tsx +14 -2
- package/src/input/Input.tsx +3 -0
- package/src/input/NativeSelect.tsx +1 -0
- package/src/input/NumericStepper.tsx +1 -1
- package/src/input/Select.tsx +7 -1
- package/src/input/Switch.tsx +2 -0
- package/src/theme/slot-recipes/field.ts +3 -0
- package/src/typography/Heading.tsx +13 -6
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "12.8.
|
4
|
+
"version": "12.8.9",
|
5
5
|
"exports": {
|
6
6
|
".": {
|
7
7
|
"types": "./dist/index.d.ts",
|
@@ -67,8 +67,8 @@
|
|
67
67
|
"vitest": "^0.26.3",
|
68
68
|
"vitest-axe": "^0.1.0",
|
69
69
|
"vitest-canvas-mock": "^0.2.2",
|
70
|
-
"@vygruppen/
|
71
|
-
"@vygruppen/
|
70
|
+
"@vygruppen/eslint-config": "1.1.1",
|
71
|
+
"@vygruppen/tsconfig": "0.1.1"
|
72
72
|
},
|
73
73
|
"peerDependencies": {
|
74
74
|
"react": ">=18.0.0 <19.0.0",
|
package/src/input/Field.tsx
CHANGED
@@ -65,6 +65,7 @@ export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
|
|
65
65
|
readOnly,
|
66
66
|
required,
|
67
67
|
direction,
|
68
|
+
id,
|
68
69
|
...rest
|
69
70
|
} = props;
|
70
71
|
const recipe = useSlotRecipe({ key: "field" });
|
@@ -79,12 +80,23 @@ export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
|
|
79
80
|
required={required}
|
80
81
|
css={styles.root}
|
81
82
|
direction={direction}
|
83
|
+
id={id}
|
82
84
|
>
|
83
|
-
{label && !floatingLabel &&
|
85
|
+
{label && !floatingLabel && (
|
86
|
+
<Label>
|
87
|
+
{label}
|
88
|
+
<ChakraField.RequiredIndicator />
|
89
|
+
</Label>
|
90
|
+
)}
|
84
91
|
|
85
92
|
{children}
|
86
93
|
|
87
|
-
{label && floatingLabel &&
|
94
|
+
{label && floatingLabel && (
|
95
|
+
<FloatingLabel>
|
96
|
+
{label}
|
97
|
+
<ChakraField.RequiredIndicator />
|
98
|
+
</FloatingLabel>
|
99
|
+
)}
|
88
100
|
{errorText && (
|
89
101
|
<ChakraField.ErrorText>{errorText}</ChakraField.ErrorText>
|
90
102
|
)}
|
package/src/input/Input.tsx
CHANGED
@@ -64,6 +64,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
64
64
|
invalid,
|
65
65
|
helperText,
|
66
66
|
errorText,
|
67
|
+
required,
|
67
68
|
...props
|
68
69
|
},
|
69
70
|
ref,
|
@@ -76,7 +77,9 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
76
77
|
<Field
|
77
78
|
invalid={invalid}
|
78
79
|
helperText={helperText}
|
80
|
+
required={required}
|
79
81
|
errorText={errorText}
|
82
|
+
id={props.id}
|
80
83
|
label={
|
81
84
|
// Render startElement invisibly to align label text with input content when an icon is present
|
82
85
|
<Flex>
|
@@ -101,7 +101,7 @@ export const NumericStepper = React.forwardRef<
|
|
101
101
|
};
|
102
102
|
|
103
103
|
return (
|
104
|
-
<Field css={styles.root} width="auto" {...rest} ref={ref}>
|
104
|
+
<Field css={styles.root} width="auto" {...rest} id={idProp} ref={ref}>
|
105
105
|
<VerySmallButton
|
106
106
|
icon={<SubtractIcon stepLabel={clampedStepSize} />}
|
107
107
|
aria-label={t(
|
package/src/input/Select.tsx
CHANGED
@@ -72,7 +72,13 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>(
|
|
72
72
|
const styles = recipe({ variant });
|
73
73
|
|
74
74
|
return (
|
75
|
-
<Field
|
75
|
+
<Field
|
76
|
+
errorText={errorText}
|
77
|
+
invalid={invalid}
|
78
|
+
helperText={helperText}
|
79
|
+
required={props.required}
|
80
|
+
id={rest.id}
|
81
|
+
>
|
76
82
|
<ChakraSelect.Root
|
77
83
|
{...rest}
|
78
84
|
ref={ref}
|
package/src/input/Switch.tsx
CHANGED
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
HeadingProps as ChakraHeadingProps,
|
5
5
|
Text,
|
6
6
|
} from "@chakra-ui/react";
|
7
|
-
import { forwardRef } from "react";
|
7
|
+
import { forwardRef, useId } from "react";
|
8
8
|
|
9
9
|
import { slugify } from "..";
|
10
10
|
|
@@ -52,11 +52,18 @@ export const Heading = forwardRef<HTMLHeadingElement, HeadingProps>(
|
|
52
52
|
...rest
|
53
53
|
} = props;
|
54
54
|
|
55
|
-
const
|
56
|
-
(externalId ?? (autoId && typeof rest.children === "string"))
|
57
|
-
? slugify(rest.children as string)
|
58
|
-
: undefined;
|
55
|
+
const reactId = useId();
|
59
56
|
|
60
|
-
|
57
|
+
function getId() {
|
58
|
+
if (externalId !== undefined) return externalId;
|
59
|
+
if (!autoId) return;
|
60
|
+
return typeof rest.children === "string"
|
61
|
+
? slugify(rest.children)
|
62
|
+
: reactId;
|
63
|
+
}
|
64
|
+
|
65
|
+
return (
|
66
|
+
<Text as={as} textStyle={variant} id={getId()} ref={ref} {...rest} />
|
67
|
+
);
|
61
68
|
},
|
62
69
|
);
|