@vygruppen/spor-react 12.6.4 → 12.7.1

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,16 +1,17 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "12.6.4",
3
+ "type": "module",
4
+ "version": "12.7.1",
4
5
  "exports": {
5
6
  ".": {
6
7
  "types": "./dist/index.d.ts",
7
8
  "import": "./dist/index.mjs",
8
- "require": "./dist/index.js"
9
+ "require": "./dist/index.cjs"
9
10
  },
10
11
  "./icons": {
11
12
  "types": "./dist/icons/index.d.ts",
12
13
  "import": "./dist/icons/index.mjs",
13
- "require": "./dist/icons/index.js"
14
+ "require": "./dist/icons/index.cjs"
14
15
  }
15
16
  },
16
17
  "license": "MIT",
@@ -18,7 +19,7 @@
18
19
  "homepage": "https://github.com/nsbno/spor/tree/main/packages/spor-react",
19
20
  "repository": {
20
21
  "type": "git",
21
- "url": "https://github.com/nsbno/spor.git",
22
+ "url": "git+https://github.com/nsbno/spor.git",
22
23
  "directory": "packages/spor-react"
23
24
  },
24
25
  "dependencies": {
@@ -47,7 +48,7 @@
47
48
  "usehooks-ts": "^3.1.0",
48
49
  "@vygruppen/spor-design-tokens": "4.0.7",
49
50
  "@vygruppen/spor-icon-react": "4.2.1",
50
- "@vygruppen/spor-loader": "0.6.0"
51
+ "@vygruppen/spor-loader": "0.7.0"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@react-types/datepicker": "^3.10.0",
@@ -67,7 +68,7 @@
67
68
  "vitest-axe": "^0.1.0",
68
69
  "vitest-canvas-mock": "^0.2.2",
69
70
  "@vygruppen/eslint-config": "1.1.1",
70
- "@vygruppen/tsconfig": "0.1.0"
71
+ "@vygruppen/tsconfig": "0.1.1"
71
72
  },
72
73
  "peerDependencies": {
73
74
  "react": ">=18.0.0 <19.0.0",
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  import {
4
- chakra,
5
4
  Group as ChakraGroup,
6
5
  type GroupProps as ChakraGroupProps,
7
6
  type RecipeVariantProps,
7
+ useRecipe,
8
8
  } from "@chakra-ui/react";
9
9
  import { forwardRef, PropsWithChildren } from "react";
10
10
 
@@ -48,23 +48,13 @@ export type ButtonGroupProps = ChakraGroupProps &
48
48
  * </ButtonGroup>
49
49
  */
50
50
 
51
- const Group = chakra(ChakraGroup, groupRecipe);
52
-
53
51
  export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
54
52
  (props, ref) => {
55
- const { children, disabled, grow, attached, ...rest } = props;
53
+ const recipe = useRecipe({ key: "buttonGroup" });
54
+ const [recipeProps, restProps] = recipe.splitVariantProps(props);
55
+ const styles = recipe(recipeProps);
56
56
 
57
- return (
58
- <Group
59
- {...rest}
60
- ref={ref}
61
- attached={attached}
62
- grow={grow}
63
- disabled={disabled}
64
- >
65
- {children}
66
- </Group>
67
- );
57
+ return <ChakraGroup {...restProps} ref={ref} css={styles} />;
68
58
  },
69
59
  );
70
60
  ButtonGroup.displayName = "ButtonGroup";
@@ -41,7 +41,7 @@ export const DialogCloseTrigger = React.forwardRef<
41
41
  ChakraDialog.CloseTriggerProps
42
42
  >(function DialogCloseTrigger(props, ref) {
43
43
  return (
44
- <ChakraDialog.CloseTrigger ref={ref} {...props} asChild>
44
+ <ChakraDialog.CloseTrigger ref={ref} position="absolute" {...props} asChild>
45
45
  <CloseButton size="md" />
46
46
  </ChakraDialog.CloseTrigger>
47
47
  );
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  import {
4
- chakra,
5
4
  Group,
6
5
  GroupProps,
7
6
  RecipeVariantProps,
7
+ useRecipe,
8
8
  } from "@chakra-ui/react";
9
9
  import { forwardRef } from "react";
10
10
 
@@ -28,11 +28,13 @@ export type AttachedInputsProps = RecipeVariantProps<
28
28
  > &
29
29
  GroupProps;
30
30
 
31
- const StyledGroup = chakra(Group, attachedInputsRecipe);
32
-
33
31
  export const AttachedInputs = forwardRef<HTMLDivElement, AttachedInputsProps>(
34
32
  (props, ref) => {
35
- return <StyledGroup ref={ref} attached {...props} />;
33
+ const recipe = useRecipe({ key: "attachedInputs" });
34
+ const [recipeProps, restProps] = recipe.splitVariantProps(props);
35
+ const styles = recipe(recipeProps);
36
+
37
+ return <Group ref={ref} css={styles} attached {...restProps} />;
36
38
  },
37
39
  );
38
40
  AttachedInputs.displayName = "AttachedInputs";
@@ -2,17 +2,15 @@
2
2
 
3
3
  import {
4
4
  Box,
5
- chakra,
6
5
  Flex,
7
6
  Input as ChakraInput,
8
7
  InputElement,
8
+ useRecipe,
9
9
  } from "@chakra-ui/react";
10
10
  import React, { ComponentProps, forwardRef, ReactNode } from "react";
11
11
 
12
12
  type ChakraInputProps = ComponentProps<typeof ChakraInput>;
13
13
 
14
- import { inputRecipe } from "@/theme/recipes/input";
15
-
16
14
  import { Field, FieldProps } from "./Field";
17
15
 
18
16
  export type InputProps = FieldProps &
@@ -21,7 +19,7 @@ export type InputProps = FieldProps &
21
19
  "size" | "label" | "colorPalette" | "placeholder"
22
20
  > & {
23
21
  /** The input's label */
24
- label: ReactNode;
22
+ label?: ReactNode;
25
23
  /** Element that shows up to the left */
26
24
  startElement?: React.ReactNode;
27
25
  /** Element that shows up to the right */
@@ -57,8 +55,6 @@ export type InputProps = FieldProps &
57
55
  * @see https://spor.vy.no/components/input
58
56
  */
59
57
 
60
- const StyledInput = chakra(ChakraInput, inputRecipe);
61
-
62
58
  export const Input = forwardRef<HTMLInputElement, InputProps>(
63
59
  (
64
60
  {
@@ -72,6 +68,10 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
72
68
  },
73
69
  ref,
74
70
  ) => {
71
+ const recipe = useRecipe({ key: "input" });
72
+ const [recipeProps, restProps] = recipe.splitVariantProps(props);
73
+ const styles = recipe(recipeProps);
74
+
75
75
  return (
76
76
  <Field
77
77
  invalid={invalid}
@@ -91,16 +91,17 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
91
91
  {startElement}
92
92
  </InputElement>
93
93
  )}
94
- <StyledInput
94
+ <ChakraInput
95
95
  data-attachable
96
96
  ref={ref}
97
97
  focusVisibleRing="outside"
98
98
  overflow="hidden"
99
99
  paddingLeft={startElement ? "2.6rem" : undefined}
100
100
  paddingRight={endElement ? "2.6rem" : undefined}
101
- {...props}
101
+ {...restProps}
102
102
  className={`peer ${props.className}`}
103
103
  placeholder=""
104
+ css={styles}
104
105
  />
105
106
  {endElement && (
106
107
  <InputElement placement="end" paddingX={2}>
@@ -1,5 +1,10 @@
1
1
  "use client";
2
- import { ButtonProps, chakra, RecipeVariantProps } from "@chakra-ui/react";
2
+ import {
3
+ ButtonProps,
4
+ chakra,
5
+ RecipeVariantProps,
6
+ useRecipe,
7
+ } from "@chakra-ui/react";
3
8
  import { forwardRef } from "react";
4
9
 
5
10
  import { pressableCardRecipe } from "../theme/recipes/pressable-card";
@@ -34,14 +39,16 @@ import { pressableCardRecipe } from "../theme/recipes/pressable-card";
34
39
  * @see StaticCard
35
40
  */
36
41
 
37
- const PressableCardButton = chakra("button", pressableCardRecipe);
38
-
39
42
  type PressableCardProps = RecipeVariantProps<typeof pressableCardRecipe> &
40
43
  ButtonProps;
41
44
 
42
- export const PressableCard = forwardRef<HTMLDivElement, PressableCardProps>(
45
+ export const PressableCard = forwardRef<HTMLButtonElement, PressableCardProps>(
43
46
  (props, ref) => {
44
- return <PressableCardButton {...props} ref={ref} />;
47
+ const recipe = useRecipe({ key: "pressableCard" });
48
+ const [recipeProps, restProps] = recipe.splitVariantProps(props);
49
+ const styles = recipe(recipeProps);
50
+
51
+ return <chakra.button {...restProps} css={styles} ref={ref} />;
45
52
  },
46
53
  );
47
54
  PressableCard.displayName = "PressableCard";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { BoxProps, chakra, RecipeVariantProps } from "@chakra-ui/react";
2
+ import { Box, BoxProps, RecipeVariantProps, useRecipe } from "@chakra-ui/react";
3
3
  import { forwardRef } from "react";
4
4
 
5
5
  import { staticCardRecipe } from "../theme/recipes/static-card";
@@ -41,14 +41,16 @@ import { staticCardRecipe } from "../theme/recipes/static-card";
41
41
  * @see PressableCard
42
42
  */
43
43
 
44
- const StyledCardBox = chakra("div", staticCardRecipe);
45
-
46
44
  export type StaticCardProps = RecipeVariantProps<typeof staticCardRecipe> &
47
45
  BoxProps;
48
46
 
49
47
  export const StaticCard = forwardRef<HTMLDivElement, StaticCardProps>(
50
48
  (props, ref) => {
51
- return <StyledCardBox {...props} ref={ref}></StyledCardBox>;
49
+ const recipe = useRecipe({ key: "staticCard" });
50
+ const [recipeProps, restProps] = recipe.splitVariantProps(props);
51
+ const styles = recipe(recipeProps);
52
+
53
+ return <Box css={styles} {...restProps} ref={ref}></Box>;
52
54
  },
53
55
  );
54
56
  StaticCard.displayName = "StaticCard";
@@ -3,6 +3,7 @@ import { badgeRecipie } from "./badge";
3
3
  import { buttonRecipe } from "./button";
4
4
  import { closeButtonRecipe } from "./close-button";
5
5
  import { codeRecipie } from "./code";
6
+ import { groupRecipe } from "./group";
6
7
  import { inputRecipe } from "./input";
7
8
  import { linkRecipe } from "./link";
8
9
  import { pressableCardRecipe } from "./pressable-card";
@@ -16,6 +17,7 @@ export const recipes = {
16
17
  attachedInputs: attachedInputsRecipe,
17
18
  badge: badgeRecipie,
18
19
  button: buttonRecipe,
20
+ buttonGroup: groupRecipe,
19
21
  closeButton: closeButtonRecipe,
20
22
  code: codeRecipie,
21
23
  input: inputRecipe,
@@ -277,3 +277,5 @@ export const checkboxCardAnatomy = createAnatomy("checkbox-card", [
277
277
  "indicator",
278
278
  "content",
279
279
  ]);
280
+
281
+ export { collapsibleAnatomy } from "@ark-ui/react/collapsible";
@@ -0,0 +1,21 @@
1
+ import { defineSlotRecipe } from "@chakra-ui/react";
2
+
3
+ import { collapsibleAnatomy } from "./anatomy";
4
+
5
+ export const collapsibleSlotRecipe = defineSlotRecipe({
6
+ slots: collapsibleAnatomy.keys(),
7
+ className: "chakra-collapsible",
8
+ base: {
9
+ content: {
10
+ overflow: "hidden",
11
+ _open: {
12
+ animationName: "expand-height, fade-in",
13
+ animationDuration: "moderate",
14
+ },
15
+ _closed: {
16
+ animationName: "collapse-height, fade-out",
17
+ animationDuration: "moderate",
18
+ },
19
+ },
20
+ },
21
+ });
@@ -5,6 +5,7 @@ import { alertServiceSlotRecipe } from "./alert-service";
5
5
  import { breadcrumbSlotRecipe } from "./breadcrumb";
6
6
  import { checkboxSlotRecipe } from "./checkbox";
7
7
  import { choiceChipSlotRecipe } from "./choice-chip";
8
+ import { collapsibleSlotRecipe } from "./collapsible";
8
9
  import { datePickerSlotRecipe } from "./datepicker";
9
10
  import { dialogSlotRecipe } from "./dialog";
10
11
  import { drawerSlotRecipe } from "./drawer";
@@ -64,4 +65,5 @@ export const slotRecipes = {
64
65
  travelTag: travelTagSlotRecipe,
65
66
  toast: toastSlotRecipe,
66
67
  checkboxCard: choiceChipSlotRecipe,
68
+ collapsible: collapsibleSlotRecipe,
67
69
  };
package/tsup.config.ts CHANGED
@@ -1,9 +1,15 @@
1
1
  import { defineConfig } from "tsup";
2
2
 
3
- export default defineConfig({
3
+ export default defineConfig(({ watch }) => ({
4
4
  entry: ["src/index.tsx", "src/icons/index.tsx"],
5
- format: ["cjs", "esm"],
5
+ format: ["esm", "cjs"],
6
6
  dts: true,
7
7
  treeshake: true,
8
8
  sourcemap: true,
9
- });
9
+ splitting: false,
10
+ clean: !watch, // avoid deleting ./dist when dev/watch starts
11
+ outDir: "dist",
12
+ outExtension: ({ format }) => ({
13
+ js: format === "esm" ? ".mjs" : ".cjs",
14
+ }),
15
+ }));