@vygruppen/spor-react 12.3.4 → 12.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "12.3.4",
3
+ "version": "12.4.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./src/index.d.ts",
@@ -15,7 +15,8 @@
15
15
  "dependencies": {
16
16
  "@ark-ui/react": "^4.9.2",
17
17
  "@chakra-ui/anatomy": "^2.3.4",
18
- "@chakra-ui/react": "^3.9.0",
18
+ "@chakra-ui/react": "^3.19.1",
19
+ "@chakra-ui/cli": "^3.8.0",
19
20
  "@chakra-ui/react-use-size": "^2.1.0",
20
21
  "@chakra-ui/styled-system": "^2.12.0",
21
22
  "@chakra-ui/system": "^2.6.2",
@@ -36,11 +37,10 @@
36
37
  "react-swipeable": "^7.0.1",
37
38
  "usehooks-ts": "^3.1.0",
38
39
  "@vygruppen/spor-design-tokens": "4.0.6",
39
- "@vygruppen/spor-icon-react": "4.0.4",
40
+ "@vygruppen/spor-icon-react": "4.1.0",
40
41
  "@vygruppen/spor-loader": "0.6.0"
41
42
  },
42
43
  "devDependencies": {
43
- "@chakra-ui/cli": "^3.8.0",
44
44
  "@react-types/datepicker": "^3.10.0",
45
45
  "@react-types/shared": "^3.27.0",
46
46
  "@testing-library/jest-dom": "^6.4.5",
@@ -2,13 +2,14 @@
2
2
 
3
3
  import type {
4
4
  CollectionItem,
5
- RecipeVariantProps,
5
+ SelectLabelProps,
6
6
  SelectRootProps as ChakraSelectRootProps,
7
7
  } from "@chakra-ui/react";
8
8
  import {
9
9
  Box,
10
10
  Portal,
11
11
  Select as ChakraSelect,
12
+ useSelectContext,
12
13
  useSlotRecipe,
13
14
  } from "@chakra-ui/react";
14
15
  import {
@@ -16,18 +17,13 @@ import {
16
17
  DropdownDownFill24Icon,
17
18
  } from "@vygruppen/spor-icon-react";
18
19
  import * as React from "react";
19
- import { PropsWithChildren } from "react";
20
20
 
21
21
  import { CloseButton } from "@/button";
22
- import { selectSlotRecipe } from "@/theme/slot-recipes/select";
23
22
 
24
23
  import { Field, FieldProps } from "./Field";
25
24
 
26
- type SelectVariantProps = RecipeVariantProps<typeof selectSlotRecipe>;
27
-
28
25
  export type SelectProps = ChakraSelectRootProps &
29
- FieldProps &
30
- PropsWithChildren<SelectVariantProps> & {
26
+ FieldProps & {
31
27
  label?: string;
32
28
  };
33
29
 
@@ -94,13 +90,24 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>(
94
90
  );
95
91
  },
96
92
  );
93
+
94
+ export const SelectLabel = (props: SelectLabelProps) => {
95
+ const { value } = useSelectContext();
96
+
97
+ return (
98
+ <ChakraSelect.Label
99
+ {...props}
100
+ data-selected={value.length > 0 ? true : undefined}
101
+ />
102
+ );
103
+ };
104
+
97
105
  Select.displayName = "Select";
98
106
 
99
- type SelectItemProps = ChakraSelect.ItemProps &
100
- React.PropsWithChildren<SelectVariantProps> & {
101
- children: React.ReactNode;
102
- description?: React.ReactNode;
103
- };
107
+ type SelectItemProps = ChakraSelect.ItemProps & {
108
+ children: React.ReactNode;
109
+ description?: React.ReactNode;
110
+ };
104
111
 
105
112
  export const SelectItem = React.forwardRef<HTMLDivElement, SelectItemProps>(
106
113
  (props, ref) => {
@@ -109,7 +116,7 @@ export const SelectItem = React.forwardRef<HTMLDivElement, SelectItemProps>(
109
116
  const styles = recipe();
110
117
  return (
111
118
  <ChakraSelect.Item item={item} {...rest} ref={ref} css={styles.item}>
112
- <Box>
119
+ <Box width="100%">
113
120
  <ChakraSelect.ItemText display="flex">
114
121
  {children}
115
122
  </ChakraSelect.ItemText>
@@ -125,11 +132,10 @@ export const SelectItem = React.forwardRef<HTMLDivElement, SelectItemProps>(
125
132
  );
126
133
  SelectItem.displayName = "SelectItem";
127
134
 
128
- type SelectItemGroupProps = ChakraSelect.ItemGroupProps &
129
- React.PropsWithChildren<SelectVariantProps> & {
130
- label: React.ReactNode;
131
- children: React.ReactNode;
132
- };
135
+ type SelectItemGroupProps = ChakraSelect.ItemGroupProps & {
136
+ label: React.ReactNode;
137
+ children: React.ReactNode;
138
+ };
133
139
 
134
140
  export const SelectItemGroup = React.forwardRef<
135
141
  HTMLDivElement,
@@ -144,11 +150,10 @@ export const SelectItemGroup = React.forwardRef<
144
150
  );
145
151
  });
146
152
 
147
- type SelectTriggerProps = ChakraSelect.ControlProps &
148
- React.PropsWithChildren<SelectVariantProps> & {
149
- clearable?: boolean;
150
- children?: React.ReactNode;
151
- };
153
+ type SelectTriggerProps = ChakraSelect.ControlProps & {
154
+ clearable?: boolean;
155
+ children?: React.ReactNode;
156
+ };
152
157
 
153
158
  export const SelectTrigger = React.forwardRef<
154
159
  HTMLButtonElement,
@@ -172,10 +177,9 @@ export const SelectTrigger = React.forwardRef<
172
177
  );
173
178
  });
174
179
 
175
- type SelectClearTriggerProps = ChakraSelect.ClearTriggerProps &
176
- React.PropsWithChildren<SelectVariantProps> & {
177
- children?: React.ReactNode;
178
- };
180
+ type SelectClearTriggerProps = ChakraSelect.ClearTriggerProps & {
181
+ children?: React.ReactNode;
182
+ };
179
183
 
180
184
  const SelectClearTrigger = React.forwardRef<
181
185
  HTMLButtonElement,
@@ -193,11 +197,10 @@ const SelectClearTrigger = React.forwardRef<
193
197
  );
194
198
  });
195
199
 
196
- type SelectContentProps = ChakraSelect.ContentProps &
197
- React.PropsWithChildren<SelectVariantProps> & {
198
- portalled?: boolean;
199
- portalRef?: React.RefObject<HTMLElement>;
200
- };
200
+ type SelectContentProps = ChakraSelect.ContentProps & {
201
+ portalled?: boolean;
202
+ portalRef?: React.RefObject<HTMLElement>;
203
+ };
201
204
 
202
205
  export const SelectContent = React.forwardRef<
203
206
  HTMLDivElement,
@@ -213,12 +216,11 @@ export const SelectContent = React.forwardRef<
213
216
  );
214
217
  });
215
218
 
216
- type SelectValueTextProps = Omit<ChakraSelect.ValueTextProps, "children"> &
217
- React.PropsWithChildren<SelectVariantProps> & {
218
- children?(items: CollectionItem[]): React.ReactNode;
219
- placeholder?: string;
220
- withPlaceholder?: boolean;
221
- };
219
+ type SelectValueTextProps = Omit<ChakraSelect.ValueTextProps, "children"> & {
220
+ children?(items: CollectionItem[]): React.ReactNode;
221
+ placeholder?: string;
222
+ withPlaceholder?: boolean;
223
+ };
222
224
 
223
225
  export const SelectValueText = React.forwardRef<
224
226
  HTMLSpanElement,
@@ -253,6 +255,5 @@ export const SelectValueText = React.forwardRef<
253
255
  );
254
256
  });
255
257
 
256
- export const SelectLabel = ChakraSelect.Label;
257
258
  export const SelectItemText = ChakraSelect.ItemText;
258
259
  export const SelectRoot = ChakraSelect.Root;
@@ -40,9 +40,6 @@ export const alertSlotRecipe = defineSlotRecipe({
40
40
  border: "sm",
41
41
  },
42
42
  description: {
43
- display: "flex",
44
- alignItems: "flex-start",
45
- gap: 1.5,
46
43
  color: "text",
47
44
  },
48
45
  content: {
@@ -54,6 +51,7 @@ export const alertSlotRecipe = defineSlotRecipe({
54
51
  title: {
55
52
  fontWeight: "bold",
56
53
  },
54
+ closeButton: {},
57
55
  },
58
56
  variants: {
59
57
  variant: {
@@ -12,16 +12,6 @@ export const selectSlotRecipe = defineSlotRecipe({
12
12
  position: "relative",
13
13
  cursor: "pointer",
14
14
  zIndex: "dropdown",
15
- "& [data-state='open']": {
16
- "& + label": {
17
- transform: ["scale(0.825) translateY(-10px)"],
18
- },
19
- },
20
- "&:has(button span:not(:empty))": {
21
- "& label": {
22
- transform: ["scale(0.825) translateY(-10px)"],
23
- },
24
- },
25
15
  },
26
16
  label: {
27
17
  fontSize: ["mobile.sm", "desktop.sm"],
@@ -29,7 +19,13 @@ export const selectSlotRecipe = defineSlotRecipe({
29
19
  left: 3,
30
20
  zIndex: 0,
31
21
  position: "absolute",
22
+ color: "text",
32
23
  marginY: 2,
24
+
25
+ _selected: {
26
+ transform: ["scale(0.825) translateY(-10px)"],
27
+ },
28
+
33
29
  transitionProperty: "transform",
34
30
  transitionDuration: "fast",
35
31
  transformOrigin: "top left",
@@ -41,8 +37,10 @@ export const selectSlotRecipe = defineSlotRecipe({
41
37
  appearance: "none",
42
38
  width: "100%",
43
39
  height: 8,
40
+ color: "text",
44
41
  paddingY: 1.5,
45
42
  paddingX: 3,
43
+
46
44
  justifyContent: "space-between",
47
45
  alignItems: "center",
48
46
  fontSize: "mobile.md",
@@ -64,6 +62,7 @@ export const selectSlotRecipe = defineSlotRecipe({
64
62
  top: "0",
65
63
  bottom: "0",
66
64
  paddingX: 2,
65
+
67
66
  pointerEvents: "none",
68
67
  },
69
68
  indicator: {