@telia/teddy 0.0.9 → 0.0.10

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.
Files changed (45) hide show
  1. package/dist/assets/badge.css +1 -1
  2. package/dist/assets/heading.css +1 -1
  3. package/dist/assets/main.css +1 -1
  4. package/dist/assets/navigation-menu.css +1 -1
  5. package/dist/badge-cOFoFJw0.js +798 -0
  6. package/dist/components/accordion/accordion.d.ts +1 -1
  7. package/dist/components/accordion/accordion.js +2 -2
  8. package/dist/components/accordion/index.js +1 -1
  9. package/dist/components/badge/badge.js +2 -2
  10. package/dist/components/badge/index.js +1 -1
  11. package/dist/components/box/box.js +1 -1
  12. package/dist/components/card/card.js +2 -2
  13. package/dist/components/card/index.js +1 -1
  14. package/dist/components/flex/flex.js +1 -1
  15. package/dist/components/grid/grid.js +1 -1
  16. package/dist/components/heading/heading.d.ts +7 -35
  17. package/dist/components/heading/heading.js +28 -28
  18. package/dist/components/index.d.ts +1 -0
  19. package/dist/components/index.js +34 -33
  20. package/dist/components/navigation-menu/navigation-menu.js +121 -121
  21. package/dist/components/notification/index.d.ts +2 -0
  22. package/dist/components/notification/index.js +4 -0
  23. package/dist/components/notification/notification.d.ts +59 -0
  24. package/dist/components/notification/notification.js +27 -0
  25. package/dist/components/radio-group/index.js +1 -1
  26. package/dist/components/radio-group/radio-group.js +1 -1
  27. package/dist/components/toggle/index.js +1 -1
  28. package/dist/components/toggle/toggle.d.ts +2 -2
  29. package/dist/components/toggle/toggle.js +2 -2
  30. package/dist/{index-0Eg2mucA.js → index-DPFZO9xk.js} +96 -95
  31. package/dist/main.js +48 -47
  32. package/dist/{radio-group-BR5SMJXJ.js → radio-group-DN1IYZdr.js} +1 -1
  33. package/dist/utils/layout/flex.d.ts +23 -0
  34. package/dist/utils/layout/flex.js +24 -0
  35. package/dist/utils/{layout.d.ts → layout/index.d.ts} +6 -38
  36. package/dist/utils/layout/index.js +156 -0
  37. package/dist/utils/layout/margin.d.ts +46 -0
  38. package/dist/utils/layout/margin.js +32 -0
  39. package/dist/utils/layout/util.d.ts +8 -0
  40. package/dist/utils/layout/util.js +33 -0
  41. package/dist/utils/layout/width.d.ts +33 -0
  42. package/dist/utils/layout/width.js +21 -0
  43. package/package.json +4 -1
  44. package/dist/badge-9vHb0-Jo.js +0 -721
  45. package/dist/utils/layout.js +0 -221
@@ -1,13 +1,11 @@
1
- import { breakpoint } from '../tokens/breakpoint/variables.json';
1
+ import { WidthProps } from './width';
2
+ import { FlexChildProps } from './flex';
3
+ import { MarginProps } from './margin';
4
+ import { Responsive } from './util';
2
5
 
3
- type Breakpoint = keyof typeof breakpoint;
4
- export type Responsive<T> = {
5
- [key in Breakpoint]?: T;
6
- } | T;
7
6
  export declare const displayGridValues: readonly ["none", "inline-grid", "grid"];
8
7
  export declare const displayFlexValues: readonly ["none", "inline-flex", "flex"];
9
8
  export declare const displayValues: readonly ["none", "inline-flex", "flex", "none", "inline-grid", "grid"];
10
- export declare const marginValues: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
11
9
  export declare const alignValues: readonly ["start", "center", "end", "baseline", "stretch"];
12
10
  export declare const justifyValues: readonly ["start", "center", "end", "between"];
13
11
  export declare const gapValues: ("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[];
@@ -21,36 +19,7 @@ export declare const gridRowStartValues: readonly ["1", "2", "3", "4", "5", "6",
21
19
  export declare const gridRowEndValues: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
22
20
  export declare const flexDirectionValues: readonly ["row", "column", "row-reverse", "column-reverse"];
23
21
  export declare const flexWrapValues: readonly ["nowrap", "wrap", "wrap-reverse"];
24
- export declare const flexGrowValues: readonly ["0", "1"];
25
- export declare const flexShrinkValues: readonly ["0", "1"];
26
- export declare const flexBasisValues: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto", "100%", "50%"];
27
- export type CommonChildrenLayoutProps = {
28
- /**
29
- * The margin of the element.
30
- */
31
- m?: Responsive<(typeof marginValues)[number]>;
32
- /**
33
- * The margin-top of the element.
34
- */
35
- mt?: Responsive<(typeof marginValues)[number]>;
36
- /**
37
- * The margin-bottom of the element.
38
- */
39
- mb?: Responsive<(typeof marginValues)[number]>;
40
- /**
41
- * The margin-right of the element.
42
- */
43
- mr?: Responsive<(typeof marginValues)[number]>;
44
- /**
45
- * The margin-left of the element.
46
- */
47
- ml?: Responsive<(typeof marginValues)[number]>;
48
- };
49
- export type FlexChildProps = {
50
- flexBasis?: Responsive<(typeof flexBasisValues)[number]>;
51
- flexGrow?: Responsive<(typeof flexGrowValues)[number]>;
52
- flexShrink?: Responsive<(typeof flexShrinkValues)[number]>;
53
- };
22
+ export type CommonChildrenLayoutProps = MarginProps & WidthProps;
54
23
  export type GridChildProps = {
55
24
  gridColumnStart?: Responsive<(typeof gridColumnStartValues)[number]>;
56
25
  gridColumnEnd?: Responsive<(typeof gridColumnEndValues)[number]>;
@@ -140,11 +109,10 @@ export type LayoutGridProps = CommonFlexGridLayoutProps & {
140
109
  export type LayoutProps = Omit<LayoutGridProps, 'display'> & Omit<LayoutFlexProps, 'display'> & {
141
110
  display?: (typeof displayValues)[number];
142
111
  };
143
- export declare function extractPropsResponsiveLayout<T extends LayoutProps>(args: T): Omit<T, "direction" | "display" | "align" | "rows" | "wrap" | "columns" | "flow" | "justify" | "gap" | "gapX" | "gapY" | keyof FlexChildProps | keyof GridChildProps | keyof CommonChildrenLayoutProps> & {
112
+ export declare function extractPropsResponsiveLayout<T extends LayoutProps>(args: T): Omit<T, "direction" | "display" | "align" | "rows" | "wrap" | "columns" | "flow" | "justify" | "gap" | "gapX" | "gapY" | keyof FlexChildProps | keyof GridChildProps | keyof MarginProps | keyof WidthProps> & {
144
113
  className: string;
145
114
  };
146
115
  export declare function extractResponsiveClassName<T>({ responsiveValue, rootClassName, }: {
147
116
  responsiveValue: Responsive<T>;
148
117
  rootClassName: string;
149
118
  }): string[] | string[][];
150
- export {};
@@ -0,0 +1,156 @@
1
+ import { c as m } from "../../clsx-DB4S2d7J.js";
2
+ import { spacingValues as y, numberIterator as n } from "./util.js";
3
+ import { margins as p } from "./margin.js";
4
+ import { flexLayout as g } from "./flex.js";
5
+ import { widths as f } from "./width.js";
6
+ const N = ["none", "inline-grid", "grid"], w = ["none", "inline-flex", "flex"], v = [...w, ...N], V = ["start", "center", "end", "baseline", "stretch"], k = ["start", "center", "end", "between"], o = y, x = [...n, "none"], C = [...n, "none"], $ = ["row", "column", "dense", "row-dense", "column-dense"], R = n, b = n, j = [
7
+ ...n,
8
+ "span-2",
9
+ "span-3",
10
+ "span-4",
11
+ "span-5",
12
+ "span-6",
13
+ "span-7",
14
+ "span-8",
15
+ "span-9",
16
+ "span-10",
17
+ "span-11",
18
+ "span-12"
19
+ ], E = n, S = n, h = ["row", "column", "row-reverse", "column-reverse"], P = ["nowrap", "wrap", "wrap-reverse"], A = [
20
+ {
21
+ key: "display",
22
+ className: "teddy-display",
23
+ values: v
24
+ },
25
+ {
26
+ key: "columns",
27
+ className: "teddy-gtc",
28
+ values: x
29
+ },
30
+ {
31
+ key: "rows",
32
+ className: "teddy-gtr",
33
+ values: C
34
+ },
35
+ {
36
+ key: "flow",
37
+ className: "teddy-gaf",
38
+ values: $
39
+ },
40
+ {
41
+ key: "align",
42
+ className: "teddy-ai",
43
+ values: V
44
+ },
45
+ {
46
+ key: "justify",
47
+ className: "teddy-jc",
48
+ values: k
49
+ },
50
+ {
51
+ key: "gap",
52
+ className: "teddy-gap",
53
+ values: o
54
+ },
55
+ {
56
+ key: "gapX",
57
+ className: "teddy-cg",
58
+ values: o
59
+ },
60
+ {
61
+ key: "gapY",
62
+ className: "teddy-rg",
63
+ values: o
64
+ },
65
+ {
66
+ key: "wrap",
67
+ className: "teddy-fw",
68
+ values: P
69
+ },
70
+ {
71
+ key: "direction",
72
+ className: "teddy-fd",
73
+ values: h
74
+ },
75
+ {
76
+ key: "gridColumnStart",
77
+ className: "teddy-gcs",
78
+ values: R
79
+ },
80
+ {
81
+ key: "gridColumnEnd",
82
+ className: "teddy-gce",
83
+ values: b
84
+ },
85
+ {
86
+ key: "gridRowStart",
87
+ className: "teddy-grs",
88
+ values: E
89
+ },
90
+ {
91
+ key: "gridRowEnd",
92
+ className: "teddy-gre",
93
+ values: S
94
+ },
95
+ {
96
+ key: "gridColumn",
97
+ className: "teddy-gc",
98
+ values: j
99
+ },
100
+ ...p,
101
+ ...g,
102
+ ...f
103
+ ];
104
+ function I(e) {
105
+ const t = { className: "" };
106
+ return Object.entries(e).map(([a, s]) => {
107
+ const r = A.find((l) => l.key === a);
108
+ return s !== null && r ? [
109
+ "className",
110
+ F({
111
+ responsiveValue: s,
112
+ rootClassName: `${r.className}`
113
+ })
114
+ ] : [a, s];
115
+ }).reduce(
116
+ (a, [s, r]) => typeof s != "string" ? a : s === "className" ? { ...a, [s]: m(a.className, r) } : { ...a, [s]: r },
117
+ t
118
+ );
119
+ }
120
+ function F({
121
+ responsiveValue: e,
122
+ rootClassName: t
123
+ }) {
124
+ if (!e)
125
+ return [];
126
+ if (typeof e == "object" && e !== null)
127
+ return Object.entries(e).map(([l, d]) => {
128
+ const i = `${t}`, u = `${l}:${t}--${c(d)}`;
129
+ return [i, u];
130
+ });
131
+ const a = `${t}`, s = `${t}--${c(e)}`;
132
+ return [a, s];
133
+ }
134
+ function c(e) {
135
+ return typeof e == "string" && e.endsWith("%") ? e.replace("%", "p") : e;
136
+ }
137
+ export {
138
+ V as alignValues,
139
+ w as displayFlexValues,
140
+ N as displayGridValues,
141
+ v as displayValues,
142
+ I as extractPropsResponsiveLayout,
143
+ F as extractResponsiveClassName,
144
+ h as flexDirectionValues,
145
+ P as flexWrapValues,
146
+ o as gapValues,
147
+ b as gridColumnEndValues,
148
+ R as gridColumnStartValues,
149
+ j as gridColumnValues,
150
+ x as gridColumnsValues,
151
+ $ as gridFlowValues,
152
+ S as gridRowEndValues,
153
+ E as gridRowStartValues,
154
+ C as gridRowsValues,
155
+ k as justifyValues
156
+ };
@@ -0,0 +1,46 @@
1
+ import { Responsive } from './util';
2
+
3
+ export declare const marginValues: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
4
+ export type MarginProps = {
5
+ /**
6
+ * The margin of the element.
7
+ */
8
+ m?: Responsive<(typeof marginValues)[number]>;
9
+ /**
10
+ * The margin-top of the element.
11
+ */
12
+ mt?: Responsive<(typeof marginValues)[number]>;
13
+ /**
14
+ * The margin-bottom of the element.
15
+ */
16
+ mb?: Responsive<(typeof marginValues)[number]>;
17
+ /**
18
+ * The margin-right of the element.
19
+ */
20
+ mr?: Responsive<(typeof marginValues)[number]>;
21
+ /**
22
+ * The margin-left of the element.s
23
+ */
24
+ ml?: Responsive<(typeof marginValues)[number]>;
25
+ };
26
+ export declare const margins: readonly [{
27
+ readonly key: "m";
28
+ readonly className: "teddy-m";
29
+ readonly values: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
30
+ }, {
31
+ readonly key: "mt";
32
+ readonly className: "teddy-mt";
33
+ readonly values: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
34
+ }, {
35
+ readonly key: "mb";
36
+ readonly className: "teddy-mb";
37
+ readonly values: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
38
+ }, {
39
+ readonly key: "ml";
40
+ readonly className: "teddy-ml";
41
+ readonly values: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
42
+ }, {
43
+ readonly key: "mr";
44
+ readonly className: "teddy-mr";
45
+ readonly values: readonly [...("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[], "auto"];
46
+ }];
@@ -0,0 +1,32 @@
1
+ import { spacingValues as a } from "./util.js";
2
+ const e = [...a, "auto"], m = [
3
+ {
4
+ key: "m",
5
+ className: "teddy-m",
6
+ values: e
7
+ },
8
+ {
9
+ key: "mt",
10
+ className: "teddy-mt",
11
+ values: e
12
+ },
13
+ {
14
+ key: "mb",
15
+ className: "teddy-mb",
16
+ values: e
17
+ },
18
+ {
19
+ key: "ml",
20
+ className: "teddy-ml",
21
+ values: e
22
+ },
23
+ {
24
+ key: "mr",
25
+ className: "teddy-mr",
26
+ values: e
27
+ }
28
+ ];
29
+ export {
30
+ e as marginValues,
31
+ m as margins
32
+ };
@@ -0,0 +1,8 @@
1
+ import { breakpoint } from '../../tokens/breakpoint/variables.json';
2
+
3
+ export type Breakpoint = keyof typeof breakpoint;
4
+ export type Responsive<T> = {
5
+ [key in Breakpoint]?: T;
6
+ } | T;
7
+ export declare const spacingValues: ("0" | "10" | "25" | "50" | "100" | "150" | "200" | "250" | "300" | "400" | "600" | "800" | "1000" | "1200" | "1600")[];
8
+ export declare const numberIterator: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
@@ -0,0 +1,33 @@
1
+ const e = {
2
+ 0: "0rem",
3
+ 10: "0.0625rem",
4
+ 25: "0.125rem",
5
+ 50: "0.25rem",
6
+ 100: "0.5rem",
7
+ 150: "0.75rem",
8
+ 200: "1rem",
9
+ 250: "1.25rem",
10
+ 300: "1.5rem",
11
+ 400: "2rem",
12
+ 600: "3rem",
13
+ 800: "4rem",
14
+ 1e3: "5rem",
15
+ 1200: "6rem",
16
+ 1600: "8rem",
17
+ gutter: {
18
+ sm: "1rem",
19
+ md: "1.5rem",
20
+ lg: "1.5rem",
21
+ xl: "1.5rem"
22
+ },
23
+ "page-padding": {
24
+ sm: "1rem",
25
+ md: "1.5rem",
26
+ lg: "3rem",
27
+ xl: "3rem"
28
+ }
29
+ }, m = Object.keys(e), r = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
30
+ export {
31
+ r as numberIterator,
32
+ m as spacingValues
33
+ };
@@ -0,0 +1,33 @@
1
+ import { Responsive } from './util';
2
+
3
+ export declare const widthValues: readonly ["bp-sm", "bp-md", "bp-lg", "bp-xl", "auto", "100%", "50%"];
4
+ export type WidthProps = {
5
+ /**
6
+ * Static width.
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/width
8
+ */
9
+ width?: Responsive<(typeof widthValues)[number]>;
10
+ /**
11
+ * Min width.
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/min-width
13
+ */
14
+ minWidth?: Responsive<(typeof widthValues)[number]>;
15
+ /**
16
+ * Max width.
17
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/max-width
18
+ */
19
+ maxWidth?: Responsive<(typeof widthValues)[number]>;
20
+ };
21
+ export declare const widths: readonly [{
22
+ readonly key: "width";
23
+ readonly className: "teddy-w";
24
+ readonly values: readonly ["bp-sm", "bp-md", "bp-lg", "bp-xl", "auto", "100%", "50%"];
25
+ }, {
26
+ readonly key: "minWidth";
27
+ readonly className: "teddy-min-w";
28
+ readonly values: readonly ["bp-sm", "bp-md", "bp-lg", "bp-xl", "auto", "100%", "50%"];
29
+ }, {
30
+ readonly key: "maxWidth";
31
+ readonly className: "teddy-max-w";
32
+ readonly values: readonly ["bp-sm", "bp-md", "bp-lg", "bp-xl", "auto", "100%", "50%"];
33
+ }];
@@ -0,0 +1,21 @@
1
+ const e = ["bp-sm", "bp-md", "bp-lg", "bp-xl", "auto", "100%", "50%"], s = [
2
+ {
3
+ key: "width",
4
+ className: "teddy-w",
5
+ values: e
6
+ },
7
+ {
8
+ key: "minWidth",
9
+ className: "teddy-min-w",
10
+ values: e
11
+ },
12
+ {
13
+ key: "maxWidth",
14
+ className: "teddy-max-w",
15
+ values: e
16
+ }
17
+ ];
18
+ export {
19
+ e as widthValues,
20
+ s as widths
21
+ };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "pnpm": ">=8"
12
12
  },
13
13
  "private": false,
14
- "version": "0.0.9",
14
+ "version": "0.0.10",
15
15
  "sideEffects": [
16
16
  "**/*.css"
17
17
  ],
@@ -28,6 +28,7 @@
28
28
  "@storybook/addon-links": "^8.0.9",
29
29
  "@storybook/addon-storysource": "^8.0.9",
30
30
  "@storybook/blocks": "^8.0.9",
31
+ "@storybook/client-api": "^7.6.17",
31
32
  "@storybook/manager-api": "^8.0.9",
32
33
  "@storybook/react": "^8.0.9",
33
34
  "@storybook/react-vite": "^8.0.9",
@@ -70,12 +71,14 @@
70
71
  },
71
72
  "dependencies": {
72
73
  "@radix-ui/react-accordion": "^1.1.2",
74
+ "@radix-ui/react-collapsible": "^1.0.3",
73
75
  "@radix-ui/react-label": "^2.0.2",
74
76
  "@radix-ui/react-navigation-menu": "^1.1.4",
75
77
  "@radix-ui/react-radio-group": "^1.1.3",
76
78
  "@radix-ui/react-slot": "^1.0.2",
77
79
  "@radix-ui/react-switch": "^1.0.3",
78
80
  "@radix-ui/react-toast": "^1.1.5",
81
+ "@radix-ui/react-use-controllable-state": "^1.0.1",
79
82
  "@react-spring/web": "^9.7.3",
80
83
  "clsx": "^2.1.0"
81
84
  },