@telia/teddy 0.0.15 → 0.0.16
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/dist/components/accordion/accordion.d.ts +2 -1
- package/dist/components/accordion/accordion.js +90 -24
- package/dist/components/accordion/index.js +2 -2
- package/dist/components/badge/badge.js +40 -24
- package/dist/components/badge/index.js +2 -2
- package/dist/components/box/box.js +14 -10
- package/dist/components/box/index.js +2 -2
- package/dist/components/button/button.js +60 -52
- package/dist/components/button/index.js +2 -2
- package/dist/components/card/card.d.ts +29 -3
- package/dist/components/card/card.js +202 -25
- package/dist/components/card/index.js +2 -2
- package/dist/components/field-error-text/field-error-text.js +21 -19
- package/dist/components/field-error-text/index.js +2 -2
- package/dist/components/flex/flex.js +15 -12
- package/dist/components/flex/index.js +2 -2
- package/dist/components/grid/grid.js +15 -12
- package/dist/components/grid/index.js +2 -2
- package/dist/components/heading/heading.js +22 -19
- package/dist/components/heading/index.js +2 -2
- package/dist/components/helper-text/helper-text.js +14 -13
- package/dist/components/helper-text/index.js +2 -2
- package/dist/components/icon/icon.js +16 -14
- package/dist/components/icon/index.js +4 -4
- package/dist/components/index.js +51 -46
- package/dist/components/input/index.js +3 -3
- package/dist/components/input/input.js +79 -66
- package/dist/components/label/index.js +2 -2
- package/dist/components/label/label.js +17 -23
- package/dist/components/link/index.js +2 -2
- package/dist/components/link/link.js +20 -19
- package/dist/components/modal/index.js +2 -2
- package/dist/components/modal/modal.js +173 -14
- package/dist/components/navigation-menu/index.js +2 -2
- package/dist/components/navigation-menu/navigation-menu.js +391 -8
- package/dist/components/notification/index.js +2 -2
- package/dist/components/notification/notification.d.ts +8 -7
- package/dist/components/notification/notification.js +96 -24
- package/dist/components/radio-group/index.js +2 -2
- package/dist/components/radio-group/radio-group.js +91 -8
- package/dist/components/spinner/index.js +2 -2
- package/dist/components/spinner/spinner.js +36 -29
- package/dist/components/text/index.js +2 -2
- package/dist/components/text/text.js +18 -17
- package/dist/components/text-field/index.js +2 -2
- package/dist/components/text-field/text-field.js +110 -90
- package/dist/components/text-spacing/index.js +2 -2
- package/dist/components/text-spacing/text-spacing.js +14 -12
- package/dist/components/toggle/index.js +2 -2
- package/dist/components/toggle/toggle.d.ts +1 -1
- package/dist/components/toggle/toggle.js +84 -23
- package/dist/components/visually-hidden/index.js +2 -2
- package/dist/components/visually-hidden/visually-hidden.js +17 -15
- package/dist/icons/category.js +2 -2
- package/dist/icons/name.js +2 -2
- package/dist/main.js +359 -61
- package/dist/style.css +3402 -0
- package/dist/tokens/border/variables.js +18 -10
- package/dist/tokens/breakpoint/variables.js +8 -5
- package/dist/tokens/color/variables.js +452 -227
- package/dist/tokens/index.d.ts +7 -7
- package/dist/tokens/index.js +308 -14
- package/dist/tokens/motion/variables.js +22 -12
- package/dist/tokens/shadow/variables.js +8 -5
- package/dist/tokens/spacing/variables.js +46 -24
- package/dist/tokens/typography/variables.js +48 -25
- package/dist/utils/action.js +10 -7
- package/dist/utils/composeEventHandlers.js +7 -5
- package/dist/utils/composeRefs.js +13 -9
- package/dist/utils/layout/align.js +5 -4
- package/dist/utils/layout/flex.js +25 -18
- package/dist/utils/layout/gap.js +7 -6
- package/dist/utils/layout/grid.js +31 -24
- package/dist/utils/layout/height.js +12 -11
- package/dist/utils/layout/index.js +76 -59
- package/dist/utils/layout/inset.js +10 -9
- package/dist/utils/layout/justify.js +6 -5
- package/dist/utils/layout/margin.js +10 -9
- package/dist/utils/layout/padding.js +10 -9
- package/dist/utils/layout/position.js +6 -5
- package/dist/utils/layout/util.js +7 -6
- package/dist/utils/layout/width.js +8 -7
- package/package.json +21 -14
- package/dist/assets/badge.css +0 -1
- package/dist/assets/button.css +0 -1
- package/dist/assets/field-error-text.css +0 -1
- package/dist/assets/flex.css +0 -1
- package/dist/assets/grid.css +0 -1
- package/dist/assets/heading.css +0 -1
- package/dist/assets/helper-text.css +0 -1
- package/dist/assets/icon.css +0 -1
- package/dist/assets/input.css +0 -1
- package/dist/assets/label.css +0 -1
- package/dist/assets/link.css +0 -1
- package/dist/assets/main.css +0 -1
- package/dist/assets/navigation-menu.css +0 -1
- package/dist/assets/radio-group.css +0 -1
- package/dist/assets/spinner.css +0 -1
- package/dist/assets/text-field.css +0 -1
- package/dist/assets/text-spacing.css +0 -1
- package/dist/assets/text.css +0 -1
- package/dist/assets/visually-hidden.css +0 -1
- package/dist/badge-Cnug5TzH.js +0 -1855
- package/dist/clsx-DB4S2d7J.js +0 -22
- package/dist/index-DM5e-Whg.js +0 -43
- package/dist/index-DpfSJps6.js +0 -75
- package/dist/index-FPIZOCcD.js +0 -305
- package/dist/navigation-menu-DKuyW8zE.js +0 -1036
- package/dist/radio-group-B--zT3OL.js +0 -440
- package/dist/variables-BKiPmtHY.js +0 -458
- package/dist/variables-BkY5b0io.js +0 -14
- package/dist/variables-Bq0YUbLS.js +0 -14
- package/dist/variables-CDK515QX.js +0 -52
- package/dist/variables-CMRTN8qo.js +0 -28
- package/dist/variables-Dmoh9YtD.js +0 -54
- package/dist/variables-IczXZ5CN.js +0 -24
package/dist/components/index.js
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
1
|
+
import { Modal } from "./modal/modal.js";
|
|
2
|
+
import { Notification } from "./notification/notification.js";
|
|
3
|
+
import { RadioGroup } from "./radio-group/radio-group.js";
|
|
4
|
+
import { Box } from "./box/box.js";
|
|
5
|
+
import { Flex } from "./flex/flex.js";
|
|
6
|
+
import { Card } from "./card/card.js";
|
|
7
|
+
import { Grid } from "./grid/grid.js";
|
|
8
|
+
import { NavigationMenu } from "./navigation-menu/navigation-menu.js";
|
|
9
|
+
import { Toggle } from "./toggle/toggle.js";
|
|
10
|
+
import { Accordion } from "./accordion/accordion.js";
|
|
11
|
+
import { Link } from "./link/link.js";
|
|
12
|
+
import { Badge } from "./badge/badge.js";
|
|
13
|
+
import { Button } from "./button/button.js";
|
|
14
|
+
import { FieldErrorText } from "./field-error-text/field-error-text.js";
|
|
15
|
+
import { HelperText } from "./helper-text/helper-text.js";
|
|
16
|
+
import { default as default2 } from "../assets/4bbd022cee9b0f06.svg";
|
|
17
|
+
import { Icon } from "./icon/icon.js";
|
|
18
|
+
import { Input, InputGroup } from "./input/input.js";
|
|
19
|
+
import { Label } from "./label/label.js";
|
|
20
|
+
import { Spinner } from "./spinner/spinner.js";
|
|
21
|
+
import { Text } from "./text/text.js";
|
|
22
|
+
import { TextField } from "./text-field/text-field.js";
|
|
23
|
+
import { Heading } from "./heading/heading.js";
|
|
24
|
+
import { VisuallyHidden } from "./visually-hidden/visually-hidden.js";
|
|
25
|
+
import { TextSpacing } from "./text-spacing/text-spacing.js";
|
|
21
26
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
Accordion,
|
|
28
|
+
Badge,
|
|
29
|
+
Box,
|
|
30
|
+
Button,
|
|
31
|
+
Card,
|
|
32
|
+
FieldErrorText,
|
|
33
|
+
Flex,
|
|
34
|
+
Grid,
|
|
35
|
+
Heading,
|
|
36
|
+
HelperText,
|
|
37
|
+
Icon,
|
|
38
|
+
Input,
|
|
39
|
+
InputGroup,
|
|
40
|
+
Label,
|
|
41
|
+
Link,
|
|
42
|
+
Modal,
|
|
43
|
+
NavigationMenu,
|
|
44
|
+
Notification,
|
|
45
|
+
RadioGroup,
|
|
46
|
+
Spinner,
|
|
47
|
+
Text,
|
|
48
|
+
TextField,
|
|
49
|
+
TextSpacing,
|
|
50
|
+
Toggle,
|
|
51
|
+
VisuallyHidden,
|
|
52
|
+
default2 as iconsHref
|
|
48
53
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import a from "react";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import React__default from "react";
|
|
5
4
|
import "../../assets/4bbd022cee9b0f06.svg";
|
|
6
|
-
import { Icon
|
|
7
|
-
import { Spinner
|
|
8
|
-
const
|
|
5
|
+
import { Icon } from "../icon/icon.js";
|
|
6
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
7
|
+
const fadeInAnimation = "_fadeInAnimation_1o9uu_1";
|
|
8
|
+
const scaleInAnimation = "_scaleInAnimation_1o9uu_1";
|
|
9
|
+
const styles = {
|
|
9
10
|
"teddy-input": "_teddy-input_1o9uu_17",
|
|
10
11
|
"teddy-input__frame": "_teddy-input__frame_1o9uu_24",
|
|
11
12
|
"teddy-input__input": "_teddy-input__input_1o9uu_31",
|
|
@@ -13,91 +14,103 @@ const C = "_fadeInAnimation_1o9uu_1", G = "_scaleInAnimation_1o9uu_1", s = {
|
|
|
13
14
|
"teddy-input__input--invalid": "_teddy-input__input--invalid_1o9uu_66",
|
|
14
15
|
"teddy-input__indicator": "_teddy-input__indicator_1o9uu_72",
|
|
15
16
|
"teddy-input__input--error": "_teddy-input__input--error_1o9uu_75",
|
|
16
|
-
fadeInAnimation
|
|
17
|
-
scaleInAnimation
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
fadeInAnimation,
|
|
18
|
+
scaleInAnimation
|
|
19
|
+
};
|
|
20
|
+
const rootClassName = "teddy-input";
|
|
21
|
+
function setCursorOnInput(e) {
|
|
22
|
+
const target = e == null ? void 0 : e.target;
|
|
23
|
+
if (target.closest("input, button, a"))
|
|
22
24
|
return;
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
+
const input = [...e.currentTarget.getElementsByTagName("input")].find((input2) => input2);
|
|
26
|
+
if (!input)
|
|
25
27
|
return;
|
|
26
|
-
const
|
|
28
|
+
const position = input.compareDocumentPosition(target);
|
|
29
|
+
const targetIsBeforeInput = (position & Node.DOCUMENT_POSITION_PRECEDING) !== 0;
|
|
30
|
+
const cursorPosition = targetIsBeforeInput ? 0 : input.value.length;
|
|
27
31
|
requestAnimationFrame(() => {
|
|
28
32
|
try {
|
|
29
|
-
|
|
33
|
+
input.setSelectionRange(cursorPosition, cursorPosition);
|
|
30
34
|
} finally {
|
|
31
|
-
|
|
35
|
+
input.focus();
|
|
32
36
|
}
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/* @__PURE__ */
|
|
39
|
+
const InputGroupContext = React__default.createContext(void 0);
|
|
40
|
+
const InputGroupRoot = React__default.forwardRef(
|
|
41
|
+
({ className, children, ...props }, forwardRef) => {
|
|
42
|
+
const classes = clsx([styles[`${rootClassName}`]], className);
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", { ...props, onPointerDown: setCursorOnInput, ref: forwardRef, className: classes, children: [
|
|
44
|
+
/* @__PURE__ */ jsx(InputGroupContext.Provider, { value: true, children }),
|
|
45
|
+
/* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__frame`] })
|
|
41
46
|
] });
|
|
42
47
|
}
|
|
43
48
|
);
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
({ className
|
|
47
|
-
const
|
|
49
|
+
InputGroupRoot.displayName = "InputGroup";
|
|
50
|
+
const Input = React__default.forwardRef(
|
|
51
|
+
({ className, onValueChange, isLoading, validationState, ...props }, forwardRef) => {
|
|
52
|
+
const groupContext = React__default.useContext(InputGroupContext);
|
|
53
|
+
const classes = clsx(
|
|
48
54
|
[
|
|
49
|
-
|
|
55
|
+
styles[`${rootClassName}__input`],
|
|
50
56
|
{
|
|
51
|
-
[
|
|
52
|
-
[
|
|
57
|
+
[styles[`${rootClassName}__input--valid`]]: validationState === "valid",
|
|
58
|
+
[styles[`${rootClassName}__input--error`]]: validationState === "invalid"
|
|
53
59
|
}
|
|
54
60
|
],
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
className
|
|
62
|
+
);
|
|
63
|
+
const hasInputGroup = groupContext === true;
|
|
64
|
+
function onChange(e) {
|
|
65
|
+
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
66
|
+
if (props.onChange)
|
|
67
|
+
props.onChange(e);
|
|
68
|
+
}
|
|
69
|
+
if (hasInputGroup) {
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
"input",
|
|
72
|
+
{
|
|
73
|
+
"aria-invalid": validationState === "invalid",
|
|
74
|
+
...props,
|
|
75
|
+
onChange,
|
|
76
|
+
className: classes,
|
|
77
|
+
ref: forwardRef
|
|
78
|
+
}
|
|
79
|
+
);
|
|
59
80
|
}
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
"aria-invalid": e === "invalid",
|
|
64
|
-
...o,
|
|
65
|
-
onChange: f,
|
|
66
|
-
className: m,
|
|
67
|
-
ref: u
|
|
68
|
-
}
|
|
69
|
-
) : /* @__PURE__ */ y(p, { children: [
|
|
70
|
-
/* @__PURE__ */ r(
|
|
81
|
+
return /* @__PURE__ */ jsxs(InputGroupRoot, { children: [
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
71
83
|
"input",
|
|
72
84
|
{
|
|
73
|
-
"aria-invalid":
|
|
74
|
-
...
|
|
75
|
-
onChange
|
|
76
|
-
className:
|
|
77
|
-
ref:
|
|
85
|
+
"aria-invalid": validationState === "invalid",
|
|
86
|
+
...props,
|
|
87
|
+
onChange,
|
|
88
|
+
className: classes,
|
|
89
|
+
ref: forwardRef
|
|
78
90
|
}
|
|
79
91
|
),
|
|
80
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ jsx(InputIndicator, { isValid: validationState === "valid", isLoading })
|
|
81
93
|
] });
|
|
82
94
|
}
|
|
83
95
|
);
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
({ className
|
|
87
|
-
if (!
|
|
96
|
+
Input.displayName = "Input";
|
|
97
|
+
const InputIndicator = React__default.forwardRef(
|
|
98
|
+
({ className, isLoading, isValid, ...props }, forwardRef) => {
|
|
99
|
+
if (!isValid && !isLoading)
|
|
88
100
|
return null;
|
|
89
|
-
if (!
|
|
90
|
-
return /* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
if (!isValid && isLoading) {
|
|
102
|
+
return /* @__PURE__ */ jsx(Spinner, { className, size: "xs", ...props, ref: forwardRef });
|
|
103
|
+
}
|
|
104
|
+
const classes = clsx([styles[`${rootClassName}__indicator`]], className);
|
|
105
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, size: "md", name: "check-circle-filled", className: classes, ref: forwardRef });
|
|
93
106
|
}
|
|
94
107
|
);
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
Input
|
|
98
|
-
Indicator:
|
|
108
|
+
InputIndicator.displayName = "InputIndicator";
|
|
109
|
+
const InputGroup = Object.assign(InputGroupRoot, {
|
|
110
|
+
Input,
|
|
111
|
+
Indicator: InputIndicator
|
|
99
112
|
});
|
|
100
113
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
Input,
|
|
115
|
+
InputGroup
|
|
103
116
|
};
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { c as $ } from "../../clsx-DB4S2d7J.js";
|
|
7
|
-
const u = /* @__PURE__ */ i((a, d) => /* @__PURE__ */ m(_.label, b({}, a, {
|
|
8
|
-
ref: d,
|
|
9
|
-
onMouseDown: (e) => {
|
|
10
|
-
var l;
|
|
11
|
-
(l = a.onMouseDown) === null || l === void 0 || l.call(a, e), !e.defaultPrevented && e.detail > 1 && e.preventDefault();
|
|
12
|
-
}
|
|
13
|
-
}))), p = u, o = {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import React__default from "react";
|
|
5
|
+
const styles = {
|
|
14
6
|
"teddy-label": "_teddy-label_1hc8e_1",
|
|
15
7
|
"teddy-label--disabled": "_teddy-label--disabled_1hc8e_8",
|
|
16
8
|
"teddy-label--required": "_teddy-label--required_1hc8e_12"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
};
|
|
10
|
+
const rootClassName = "teddy-label";
|
|
11
|
+
const Label = React__default.forwardRef(
|
|
12
|
+
({ className, disabled, isRequired, children, ...props }, ref) => {
|
|
13
|
+
const classes = clsx(
|
|
14
|
+
[styles[rootClassName]],
|
|
21
15
|
{
|
|
22
|
-
[
|
|
23
|
-
[
|
|
16
|
+
[styles[`${rootClassName}--disabled`]]: disabled,
|
|
17
|
+
[styles[`${rootClassName}--required`]]: isRequired
|
|
24
18
|
},
|
|
25
|
-
|
|
19
|
+
className
|
|
26
20
|
);
|
|
27
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ jsx(LabelPrimitive.Root, { ...props, ref, className: classes, children });
|
|
28
22
|
}
|
|
29
23
|
);
|
|
30
|
-
|
|
24
|
+
Label.displayName = "Label";
|
|
31
25
|
export {
|
|
32
|
-
|
|
26
|
+
Label
|
|
33
27
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const e = {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import React__default from "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
const styles = {
|
|
7
6
|
"teddy-link": "_teddy-link_1jza5_1",
|
|
8
7
|
"teddy-link--text": "_teddy-link--text_1jza5_15",
|
|
9
8
|
"teddy-link--standalone": "_teddy-link--standalone_1jza5_15",
|
|
@@ -14,23 +13,25 @@ const e = {
|
|
|
14
13
|
"teddy-link--navigation-negative": "_teddy-link--navigation-negative_1jza5_28",
|
|
15
14
|
"teddy-link--ensure-target-area": "_teddy-link--ensure-target-area_1jza5_56",
|
|
16
15
|
"teddy-link--silent": "_teddy-link--silent_1jza5_62"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
};
|
|
17
|
+
const rootClassName = "teddy-link";
|
|
18
|
+
const Link = React__default.forwardRef(
|
|
19
|
+
({ className, variant, silent, disableVisited, ensureTargetArea, asChild, children, ...props }, forwardRef) => {
|
|
20
|
+
const classes = clsx(
|
|
21
|
+
[styles[`${rootClassName}`]],
|
|
22
|
+
styles[`${rootClassName}--${variant}`],
|
|
22
23
|
{
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
24
|
+
[styles[`${rootClassName}--silent`]]: silent,
|
|
25
|
+
[styles[`${rootClassName}--negative`]]: variant.endsWith("negative"),
|
|
26
|
+
[styles[`${rootClassName}--disable-visited`]]: disableVisited ?? silent,
|
|
27
|
+
[styles[`${rootClassName}--ensure-target-area`]]: ensureTargetArea
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
+
className
|
|
29
30
|
);
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ jsx(Slot, { ...props, ref: forwardRef, className: classes, children: asChild ? children : /* @__PURE__ */ jsx("a", { href: props.href, children }) });
|
|
31
32
|
}
|
|
32
33
|
);
|
|
33
|
-
|
|
34
|
+
Link.displayName = "Link";
|
|
34
35
|
export {
|
|
35
|
-
|
|
36
|
+
Link
|
|
36
37
|
};
|
|
@@ -1,28 +1,187 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React__default, { useEffect } from "react";
|
|
3
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
4
|
+
import "../notification/notification.js";
|
|
5
|
+
import "../radio-group/radio-group.js";
|
|
5
6
|
import "../box/box.js";
|
|
6
|
-
import "../flex/flex.js";
|
|
7
|
+
import { Flex } from "../flex/flex.js";
|
|
8
|
+
import "../card/card.js";
|
|
7
9
|
import "../grid/grid.js";
|
|
8
|
-
import "
|
|
10
|
+
import "../navigation-menu/navigation-menu.js";
|
|
11
|
+
import "../toggle/toggle.js";
|
|
12
|
+
import "../accordion/accordion.js";
|
|
9
13
|
import "../link/link.js";
|
|
10
|
-
import "../
|
|
14
|
+
import "../badge/badge.js";
|
|
15
|
+
import { Button } from "../button/button.js";
|
|
11
16
|
import "../field-error-text/field-error-text.js";
|
|
12
17
|
import "../helper-text/helper-text.js";
|
|
13
18
|
import "../../assets/4bbd022cee9b0f06.svg";
|
|
14
|
-
import "../icon/icon.js";
|
|
19
|
+
import { Icon } from "../icon/icon.js";
|
|
15
20
|
import "../input/input.js";
|
|
16
21
|
import "../label/label.js";
|
|
17
22
|
import "../spinner/spinner.js";
|
|
18
|
-
import "../text/text.js";
|
|
23
|
+
import { Text } from "../text/text.js";
|
|
19
24
|
import "../text-field/text-field.js";
|
|
20
|
-
import "../heading/heading.js";
|
|
25
|
+
import { Heading } from "../heading/heading.js";
|
|
21
26
|
import "../visually-hidden/visually-hidden.js";
|
|
22
27
|
import "../text-spacing/text-spacing.js";
|
|
23
|
-
import "
|
|
24
|
-
import "
|
|
25
|
-
import "../../utils/composeRefs.js";
|
|
28
|
+
import clsx from "clsx";
|
|
29
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
30
|
+
import { composeRefs } from "../../utils/composeRefs.js";
|
|
31
|
+
const styles = {
|
|
32
|
+
"teddy-modal__overlay": "_teddy-modal__overlay_vfo5b_17",
|
|
33
|
+
"teddy-modal__content": "_teddy-modal__content_vfo5b_29",
|
|
34
|
+
"teddy-modal__scroll": "_teddy-modal__scroll_vfo5b_47",
|
|
35
|
+
"teddy-modal__image": "_teddy-modal__image_vfo5b_51",
|
|
36
|
+
"teddy-modal__close--floating": "_teddy-modal__close--floating_vfo5b_61",
|
|
37
|
+
"teddy-modal__group": "_teddy-modal__group_vfo5b_66",
|
|
38
|
+
"teddy-modal__group--title": "_teddy-modal__group--title_vfo5b_70",
|
|
39
|
+
"teddy-modal__group--scroll": "_teddy-modal__group--scroll_vfo5b_76",
|
|
40
|
+
"teddy-modal__group--action": "_teddy-modal__group--action_vfo5b_85",
|
|
41
|
+
"modal-overlay-no-op": "_modal-overlay-no-op_vfo5b_1",
|
|
42
|
+
"teddy-fade-in": "_teddy-fade-in_vfo5b_1",
|
|
43
|
+
"teddy-fade-out": "_teddy-fade-out_vfo5b_1",
|
|
44
|
+
"modal-content-show": "_modal-content-show_vfo5b_1",
|
|
45
|
+
"modal-content-hide": "_modal-content-hide_vfo5b_1"
|
|
46
|
+
};
|
|
47
|
+
const rootClassName = "teddy-modal";
|
|
48
|
+
const RootContext = React__default.createContext({
|
|
49
|
+
imageRef: null,
|
|
50
|
+
actionGroupRef: null,
|
|
51
|
+
scrollRef: null
|
|
52
|
+
});
|
|
53
|
+
const Root = (props) => {
|
|
54
|
+
const imageRef = React__default.useRef(null);
|
|
55
|
+
const actionGroupRef = React__default.useRef(null);
|
|
56
|
+
const scrollRef = React__default.useRef(null);
|
|
57
|
+
return /* @__PURE__ */ jsx(RootContext.Provider, { value: { imageRef, actionGroupRef, scrollRef }, children: /* @__PURE__ */ jsx(DialogPrimitive.Root, { ...props, modal: true }) });
|
|
58
|
+
};
|
|
59
|
+
Root.displayName = "Dialog.Root";
|
|
60
|
+
const Trigger = React__default.forwardRef(
|
|
61
|
+
({ children, ...props }, forwardedRef) => /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { ...props, ref: forwardedRef, asChild: true, children })
|
|
62
|
+
);
|
|
63
|
+
Trigger.displayName = "Dialog.Trigger";
|
|
64
|
+
const OverlayContext = React__default.createContext(false);
|
|
65
|
+
const Overlay = React__default.forwardRef(
|
|
66
|
+
({ className, forceMount, container, ...rest }, forwardedRef) => {
|
|
67
|
+
const classes = clsx([styles[`${rootClassName}__overlay`]], className);
|
|
68
|
+
return /* @__PURE__ */ jsx(OverlayContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DialogPrimitive.Portal, { container, forceMount, children: /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: classes, ref: forwardedRef, ...rest }) }) });
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
Overlay.displayName = "Dialog.Content";
|
|
72
|
+
const InnerContent = React__default.forwardRef(
|
|
73
|
+
function InnerContent2({ asChild, children, className, ...props }, forwardedRef) {
|
|
74
|
+
const classes = clsx([styles[`${rootClassName}__scroll`]], className);
|
|
75
|
+
const context = React__default.useContext(RootContext);
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
DialogPrimitive.Content,
|
|
78
|
+
{
|
|
79
|
+
...props,
|
|
80
|
+
ref: forwardedRef,
|
|
81
|
+
className: clsx([styles[`${rootClassName}__content`]]),
|
|
82
|
+
asChild: true,
|
|
83
|
+
children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
|
|
84
|
+
Flex,
|
|
85
|
+
{
|
|
86
|
+
...asChild ? { as: void 0, asChild } : {},
|
|
87
|
+
direction: "column",
|
|
88
|
+
align: "start",
|
|
89
|
+
maxWidth: { md: "600px" },
|
|
90
|
+
className: classes,
|
|
91
|
+
ref: context.scrollRef,
|
|
92
|
+
children
|
|
93
|
+
}
|
|
94
|
+
) })
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
const Content = React__default.forwardRef(
|
|
100
|
+
({ forceMount, ...contentProps }, forwardedRef) => {
|
|
101
|
+
const hasOverlay = React__default.useContext(OverlayContext);
|
|
102
|
+
if (!hasOverlay)
|
|
103
|
+
return /* @__PURE__ */ jsx(Overlay, { forceMount, children: /* @__PURE__ */ jsx(InnerContent, { ref: forwardedRef, ...contentProps }) });
|
|
104
|
+
return /* @__PURE__ */ jsx(InnerContent, { ref: forwardedRef, ...contentProps });
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
Content.displayName = "Dialog.Content";
|
|
108
|
+
const GroupContext = React__default.createContext(false);
|
|
109
|
+
const Group = React__default.forwardRef(
|
|
110
|
+
({ className, variant, ...props }, forwardedRef) => {
|
|
111
|
+
const strollerRef = React__default.useContext(RootContext).scrollRef;
|
|
112
|
+
const [isOverflowing, setIsOverflowing] = React__default.useState(false);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (strollerRef == null ? void 0 : strollerRef.current) {
|
|
115
|
+
const hasOverflow = strollerRef.current.scrollHeight > strollerRef.current.clientHeight;
|
|
116
|
+
setIsOverflowing(hasOverflow);
|
|
117
|
+
}
|
|
118
|
+
}, [strollerRef]);
|
|
119
|
+
const classes = clsx(
|
|
120
|
+
[styles[`${rootClassName}__group`]],
|
|
121
|
+
{
|
|
122
|
+
[styles[`${rootClassName}__group--action`]]: variant === "action",
|
|
123
|
+
[styles[`${rootClassName}__group--title`]]: variant === "title",
|
|
124
|
+
[styles[`${rootClassName}__group--scroll`]]: isOverflowing
|
|
125
|
+
},
|
|
126
|
+
className
|
|
127
|
+
);
|
|
128
|
+
return /* @__PURE__ */ jsx(GroupContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
129
|
+
Flex,
|
|
130
|
+
{
|
|
131
|
+
...variant === "action" ? {
|
|
132
|
+
gap: "200",
|
|
133
|
+
justify: { md: "end" },
|
|
134
|
+
align: { sm: "stretch", md: "end" },
|
|
135
|
+
direction: { sm: "column-reverse", md: "row" }
|
|
136
|
+
} : { direction: "column" },
|
|
137
|
+
ref: forwardedRef,
|
|
138
|
+
...props,
|
|
139
|
+
className: classes
|
|
140
|
+
}
|
|
141
|
+
) });
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
Group.displayName = "Dialog.Group";
|
|
145
|
+
const TitleInner = React__default.forwardRef(
|
|
146
|
+
function TitleInner2(props, forwardedRef) {
|
|
147
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { variant: "title-200", as: "h2", ...props, asChild: false, ref: forwardedRef }) });
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
const Title = React__default.forwardRef((props, forwardedRef) => {
|
|
151
|
+
const isInsideGroup = React__default.useContext(GroupContext);
|
|
152
|
+
if (!isInsideGroup) {
|
|
153
|
+
return /* @__PURE__ */ jsx(Group, { variant: "title", children: /* @__PURE__ */ jsx(TitleInner, { ...props, ref: forwardedRef }) });
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsx(TitleInner, { ...props, ref: forwardedRef });
|
|
156
|
+
});
|
|
157
|
+
Title.displayName = "Dialog.Title";
|
|
158
|
+
const Description = React__default.forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { as: "p", variant: "paragraph-100", ...props, asChild: false, ref: forwardedRef }) }));
|
|
159
|
+
Description.displayName = "Dialog.Description";
|
|
160
|
+
const Image = React__default.forwardRef(({ asChild, ...props }, forwardedRef) => {
|
|
161
|
+
const classes = clsx([styles[`${rootClassName}__image`]], props.className);
|
|
162
|
+
const context = React__default.useContext(RootContext);
|
|
163
|
+
const Comp = asChild ? Slot : "img";
|
|
164
|
+
return /* @__PURE__ */ jsx(Comp, { ...props, className: classes, ref: composeRefs(context.imageRef, forwardedRef) });
|
|
165
|
+
});
|
|
166
|
+
Image.displayName = "Dialog.Image";
|
|
167
|
+
const Close = React__default.forwardRef(
|
|
168
|
+
({ className, ...props }, forwardedRef) => {
|
|
169
|
+
const classes = clsx([styles[`${rootClassName}__close`]], {
|
|
170
|
+
[styles[`${rootClassName}__close--floating`]]: props.slot === "floating",
|
|
171
|
+
className
|
|
172
|
+
});
|
|
173
|
+
const imageRef = React__default.useContext(RootContext).imageRef;
|
|
174
|
+
const [hasImage, setHasImage] = React__default.useState(false);
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (imageRef == null ? void 0 : imageRef.current) {
|
|
177
|
+
setHasImage(true);
|
|
178
|
+
}
|
|
179
|
+
}, [imageRef]);
|
|
180
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Close, { ...props, className: classes, ref: forwardedRef, asChild: true, children: props.children || /* @__PURE__ */ jsx(Button, { variant: hasImage ? "primary-negative" : "tertiary-purple", iconOnly: true, "aria-label": props["aria-label"], children: /* @__PURE__ */ jsx(Icon, { name: "close" }) }) });
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
Close.displayName = "Dialog.Close";
|
|
184
|
+
const Modal = Object.assign(Root, { Trigger, Content, Title, Overlay, Description, Close, Image, Group });
|
|
26
185
|
export {
|
|
27
|
-
|
|
186
|
+
Modal
|
|
28
187
|
};
|