@telia/teddy 0.0.24 → 0.0.26
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-content.cjs +32 -0
- package/dist/components/accordion/accordion-header.cjs +33 -0
- package/dist/components/accordion/accordion-indicator.cjs +16 -0
- package/dist/components/accordion/accordion-item.cjs +32 -0
- package/dist/components/accordion/accordion-root.cjs +56 -0
- package/dist/components/accordion/accordion-root.js +11 -11
- package/dist/components/accordion/accordion-title.cjs +15 -0
- package/dist/components/accordion/accordion-trigger.cjs +37 -0
- package/dist/components/accordion/index.cjs +25 -0
- package/dist/components/accordion/index.js +7 -0
- package/dist/components/badge/badge.cjs +43 -0
- package/dist/components/badge/index.cjs +4 -0
- package/dist/components/box/box.cjs +17 -0
- package/dist/components/box/index.cjs +4 -0
- package/dist/components/button/button.cjs +130 -0
- package/dist/components/button/button.js +24 -24
- package/dist/components/button/index.cjs +4 -0
- package/dist/components/card/card.cjs +219 -0
- package/dist/components/card/index.cjs +4 -0
- package/dist/components/chip/chip-indicator.cjs +16 -0
- package/dist/components/chip/chip-item.cjs +45 -0
- package/dist/components/chip/chip.cjs +48 -0
- package/dist/components/chip/index.cjs +10 -0
- package/dist/components/drawer/drawer-close.cjs +39 -0
- package/dist/components/drawer/drawer-close.d.ts +0 -3
- package/dist/components/drawer/drawer-close.js +1 -1
- package/dist/components/drawer/drawer-content.cjs +42 -0
- package/dist/components/drawer/drawer-content.d.ts +0 -3
- package/dist/components/drawer/drawer-content.js +1 -1
- package/dist/components/drawer/drawer-description.cjs +36 -0
- package/dist/components/drawer/drawer-description.d.ts +0 -3
- package/dist/components/drawer/drawer-description.js +1 -1
- package/dist/components/drawer/drawer-footer.cjs +16 -0
- package/dist/components/drawer/drawer-footer.d.ts +0 -3
- package/dist/components/drawer/drawer-footer.js +1 -1
- package/dist/components/drawer/drawer-overlay.cjs +43 -0
- package/dist/components/drawer/drawer-overlay.d.ts +0 -3
- package/dist/components/drawer/drawer-overlay.js +1 -1
- package/dist/components/drawer/drawer-root.cjs +28 -0
- package/dist/components/drawer/drawer-root.d.ts +1 -1
- package/dist/components/drawer/drawer-title.cjs +34 -0
- package/dist/components/drawer/drawer-title.d.ts +4 -3
- package/dist/components/drawer/drawer-title.js +1 -1
- package/dist/components/drawer/drawer-trigger.cjs +27 -0
- package/dist/components/drawer/drawer-trigger.d.ts +5 -3
- package/dist/components/drawer/index.cjs +28 -0
- package/dist/components/drawer/index.d.ts +28 -0
- package/dist/components/drawer/index.js +8 -0
- package/dist/components/field-error-text/field-error-text.cjs +30 -0
- package/dist/components/field-error-text/index.cjs +4 -0
- package/dist/components/flex/flex.cjs +19 -0
- package/dist/components/flex/index.cjs +4 -0
- package/dist/components/grid/grid.cjs +19 -0
- package/dist/components/grid/index.cjs +4 -0
- package/dist/components/heading/heading.cjs +55 -0
- package/dist/components/heading/index.cjs +4 -0
- package/dist/components/helper-text/helper-text.cjs +21 -0
- package/dist/components/helper-text/helper-text.d.ts +2 -4
- package/dist/components/helper-text/index.cjs +4 -0
- package/dist/components/icon/AllIcons.cjs +1091 -0
- package/dist/components/icon/AllIcons.d.ts +2 -0
- package/dist/components/icon/AllIcons.js +1092 -0
- package/dist/components/icon/icon.cjs +29 -0
- package/dist/components/icon/index.cjs +8 -0
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/icon/index.js +2 -0
- package/dist/components/image/image.cjs +17 -0
- package/dist/components/image/index.cjs +4 -0
- package/dist/components/index.cjs +66 -0
- package/dist/components/index.js +6 -3
- package/dist/components/input/index.cjs +14 -0
- package/dist/components/input/index.d.ts +27 -2
- package/dist/components/input/index.js +10 -1
- package/dist/components/input/input-clear-button.cjs +43 -0
- package/dist/components/input/input-clear-button.d.ts +6 -0
- package/dist/components/input/input-clear-button.js +43 -0
- package/dist/components/input/input-group.cjs +132 -0
- package/dist/components/input/input-group.d.ts +16 -0
- package/dist/components/input/input-group.js +132 -0
- package/dist/components/input/input-indicator.cjs +10 -0
- package/dist/components/input/input-indicator.d.ts +23 -0
- package/dist/components/input/input-indicator.js +10 -0
- package/dist/components/input/input.cjs +9 -0
- package/dist/components/input/input.d.ts +4 -28
- package/dist/components/input/input.js +7 -114
- package/dist/components/label/index.cjs +4 -0
- package/dist/components/label/label.cjs +44 -0
- package/dist/components/link/index.cjs +4 -0
- package/dist/components/link/link.cjs +37 -0
- package/dist/components/link/link.js +10 -10
- package/dist/components/modal/index.cjs +4 -0
- package/dist/components/modal/modal.cjs +210 -0
- package/dist/components/modal/modal.js +17 -16
- package/dist/components/navigation-menu/index.cjs +4 -0
- package/dist/components/navigation-menu/navigation-menu.cjs +412 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +2 -0
- package/dist/components/navigation-menu/navigation-menu.js +24 -22
- package/dist/components/notification/index.cjs +4 -0
- package/dist/components/notification/notification.cjs +116 -0
- package/dist/components/notification/notification.js +8 -8
- package/dist/components/radio-group/index.cjs +4 -0
- package/dist/components/radio-group/radio-group.cjs +110 -0
- package/dist/components/scroll-area/index.cjs +9 -0
- package/dist/components/scroll-area/scroll-area-bar.cjs +175 -0
- package/dist/components/scroll-area/scroll-area-bar.js +8 -8
- package/dist/components/scroll-area/scroll-area-button.cjs +11 -0
- package/dist/components/scroll-area/scroll-area-corner.cjs +8 -0
- package/dist/components/scroll-area/scroll-area-item.cjs +42 -0
- package/dist/components/scroll-area/scroll-area-item.js +2 -1
- package/dist/components/scroll-area/scroll-area-root.cjs +11 -0
- package/dist/components/scroll-area/scroll-area-thumb.cjs +8 -0
- package/dist/components/spinner/index.cjs +4 -0
- package/dist/components/spinner/spinner.cjs +57 -0
- package/dist/components/tabs/index.cjs +16 -0
- package/dist/components/tabs/tabs-content.cjs +32 -0
- package/dist/components/tabs/tabs-list.cjs +39 -0
- package/dist/components/tabs/tabs-list.js +6 -4
- package/dist/components/tabs/tabs-root.cjs +75 -0
- package/dist/components/tabs/tabs-root.d.ts +4 -7
- package/dist/components/tabs/tabs-root.js +25 -8
- package/dist/components/tabs/tabs-scroll-button.cjs +15 -0
- package/dist/components/tabs/tabs-scroll.cjs +22 -0
- package/dist/components/tabs/tabs-trigger.cjs +55 -0
- package/dist/components/tabs/tabs-trigger.js +19 -9
- package/dist/components/text/index.cjs +4 -0
- package/dist/components/text/text.cjs +49 -0
- package/dist/components/text-field/index.cjs +31 -0
- package/dist/components/text-field/index.d.ts +63 -2
- package/dist/components/text-field/index.js +28 -1
- package/dist/components/text-field/text-field-button.cjs +31 -0
- package/dist/components/text-field/text-field-button.d.ts +27 -0
- package/dist/components/text-field/text-field-button.js +31 -0
- package/dist/components/text-field/text-field-clear-button.cjs +12 -0
- package/dist/components/text-field/text-field-clear-button.d.ts +6 -0
- package/dist/components/text-field/text-field-clear-button.js +12 -0
- package/dist/components/text-field/text-field-error-list.cjs +28 -0
- package/dist/components/text-field/text-field-error-list.d.ts +9 -0
- package/dist/components/text-field/text-field-error-list.js +28 -0
- package/dist/components/text-field/text-field-helper-text.cjs +19 -0
- package/dist/components/text-field/text-field-helper-text.d.ts +5 -0
- package/dist/components/text-field/text-field-helper-text.js +19 -0
- package/dist/components/text-field/text-field-indicator.cjs +14 -0
- package/dist/components/text-field/text-field-indicator.d.ts +6 -0
- package/dist/components/text-field/text-field-indicator.js +14 -0
- package/dist/components/text-field/text-field-input-group.cjs +11 -0
- package/dist/components/text-field/text-field-input-group.d.ts +7 -0
- package/dist/components/text-field/text-field-input-group.js +11 -0
- package/dist/components/text-field/text-field-input.cjs +27 -0
- package/dist/components/text-field/text-field-input.d.ts +5 -0
- package/dist/components/text-field/text-field-input.js +27 -0
- package/dist/components/text-field/text-field-label.cjs +27 -0
- package/dist/components/text-field/text-field-label.d.ts +8 -0
- package/dist/components/text-field/text-field-label.js +27 -0
- package/dist/components/text-field/text-field.cjs +54 -0
- package/dist/components/text-field/text-field.d.ts +12 -58
- package/dist/components/text-field/text-field.js +17 -101
- package/dist/components/text-field/util.cjs +4 -0
- package/dist/components/text-field/util.d.ts +1 -0
- package/dist/components/text-field/util.js +4 -0
- package/dist/components/text-spacing/index.cjs +4 -0
- package/dist/components/text-spacing/text-spacing.cjs +19 -0
- package/dist/components/toggle/index.cjs +4 -0
- package/dist/components/toggle/toggle.cjs +104 -0
- package/dist/components/visually-hidden/index.cjs +4 -0
- package/dist/components/visually-hidden/visually-hidden.cjs +26 -0
- package/dist/drawer.module-BxsrDZFu.js +14 -0
- package/dist/drawer.module-CWDhohQm.cjs +13 -0
- package/dist/icons/category.cjs +335 -0
- package/dist/icons/name.cjs +335 -0
- package/dist/icons/name.d.cjs +1 -0
- package/dist/main.cjs +374 -0
- package/dist/main.js +6 -3
- package/dist/style.css +573 -492
- package/dist/tokens/border/variables.cjs +20 -0
- package/dist/tokens/breakpoint/variables.cjs +10 -0
- package/dist/tokens/color/variables.cjs +454 -0
- package/dist/tokens/index.cjs +310 -0
- package/dist/tokens/motion/variables.cjs +24 -0
- package/dist/tokens/shadow/variables.cjs +10 -0
- package/dist/tokens/spacing/variables.cjs +48 -0
- package/dist/tokens/typography/variables.cjs +50 -0
- package/dist/utils/action.cjs +21 -0
- package/dist/utils/component-props-as.cjs +1 -0
- package/dist/utils/composeEventHandlers.cjs +11 -0
- package/dist/utils/composeRefs.cjs +18 -0
- package/dist/utils/generate-styling/align.cjs +32 -0
- package/dist/utils/generate-styling/color.cjs +12 -0
- package/dist/utils/generate-styling/flex.cjs +67 -0
- package/dist/utils/generate-styling/gap.cjs +22 -0
- package/dist/utils/generate-styling/grid.cjs +123 -0
- package/dist/utils/generate-styling/height.cjs +51 -0
- package/dist/utils/generate-styling/index.cjs +97 -0
- package/dist/utils/generate-styling/inset.cjs +33 -0
- package/dist/utils/generate-styling/justify.cjs +18 -0
- package/dist/utils/generate-styling/margin.cjs +33 -0
- package/dist/utils/generate-styling/object-fit.cjs +18 -0
- package/dist/utils/generate-styling/padding.cjs +33 -0
- package/dist/utils/generate-styling/position.cjs +21 -0
- package/dist/utils/generate-styling/util.cjs +33 -0
- package/dist/utils/generate-styling/width.cjs +26 -0
- package/dist/vite-env.d.cjs +1 -0
- package/package.json +6 -4
- package/dist/components/text-field/tex-field-label.d.ts +0 -0
- package/dist/components/text-field/tex-field-label.js +0 -1
- package/dist/drawer.module-B3QhrxH1.js +0 -14
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const clsx = require("clsx");
|
|
6
|
+
const NavigationMenuPrimitive = require("@radix-ui/react-navigation-menu");
|
|
7
|
+
const utils_composeRefs = require("../../utils/composeRefs.cjs");
|
|
8
|
+
const components_visuallyHidden_visuallyHidden = require("../visually-hidden/visually-hidden.cjs");
|
|
9
|
+
const utils_composeEventHandlers = require("../../utils/composeEventHandlers.cjs");
|
|
10
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
11
|
+
function _interopNamespaceDefault(e) {
|
|
12
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
|
+
if (e) {
|
|
14
|
+
for (const k in e) {
|
|
15
|
+
if (k !== "default") {
|
|
16
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: () => e[k]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
const NavigationMenuPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(NavigationMenuPrimitive);
|
|
28
|
+
const enterFromLeft = "_enterFromLeft_959s3_1";
|
|
29
|
+
const enterFromRight = "_enterFromRight_959s3_1";
|
|
30
|
+
const exitToLeft = "_exitToLeft_959s3_1";
|
|
31
|
+
const exitToRight = "_exitToRight_959s3_1";
|
|
32
|
+
const scaleIn = "_scaleIn_959s3_1";
|
|
33
|
+
const scaleOut = "_scaleOut_959s3_1";
|
|
34
|
+
const styles = {
|
|
35
|
+
"teddy-navigation-menu": "_teddy-navigation-menu_959s3_1",
|
|
36
|
+
"teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_959s3_33",
|
|
37
|
+
"teddy-navigation-menu__list": "_teddy-navigation-menu__list_959s3_36",
|
|
38
|
+
"teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_959s3_55",
|
|
39
|
+
"teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_959s3_75",
|
|
40
|
+
"teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_959s3_92",
|
|
41
|
+
"teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_959s3_97",
|
|
42
|
+
"teddy-navigation-menu__content": "_teddy-navigation-menu__content_959s3_169",
|
|
43
|
+
enterFromLeft,
|
|
44
|
+
enterFromRight,
|
|
45
|
+
exitToLeft,
|
|
46
|
+
exitToRight,
|
|
47
|
+
"teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_959s3_213",
|
|
48
|
+
"teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_959s3_231",
|
|
49
|
+
"teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_959s3_236",
|
|
50
|
+
"teddy-navigation-menu__link": "_teddy-navigation-menu__link_959s3_301",
|
|
51
|
+
"teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_959s3_319",
|
|
52
|
+
"teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_959s3_324",
|
|
53
|
+
scaleIn,
|
|
54
|
+
scaleOut
|
|
55
|
+
};
|
|
56
|
+
const rootClassName = "teddy-navigation-menu";
|
|
57
|
+
const NavigationMenuContext = React.createContext({
|
|
58
|
+
selectedTopMenu: void 0,
|
|
59
|
+
setSelectedTopMenu: () => {
|
|
60
|
+
},
|
|
61
|
+
contentRef: { current: null },
|
|
62
|
+
focusProxyRef: { current: null },
|
|
63
|
+
topMenuRef: { current: null },
|
|
64
|
+
id: "",
|
|
65
|
+
dir: "ltr",
|
|
66
|
+
orientation: "horizontal",
|
|
67
|
+
onEntryKeyDown: () => {
|
|
68
|
+
},
|
|
69
|
+
onFocusProxyEnter: () => {
|
|
70
|
+
},
|
|
71
|
+
onContentFocusOutside: () => {
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const Root = React.forwardRef(
|
|
75
|
+
({ className, defaultTopMenuValue, ...props }, forwardRef) => {
|
|
76
|
+
const [selectedTopMenu, setSelectedTopMenu] = React.useState(defaultTopMenuValue);
|
|
77
|
+
const contentRef = React.useRef(null);
|
|
78
|
+
const restoreContentTabOrderRef = React.useRef(() => {
|
|
79
|
+
});
|
|
80
|
+
const focusProxyRef = React.useRef(null);
|
|
81
|
+
const topMenuRef = React.useRef(null);
|
|
82
|
+
const id = React.useId();
|
|
83
|
+
const handleContentEntry = React.useCallback((side = "start") => {
|
|
84
|
+
if (contentRef.current) {
|
|
85
|
+
restoreContentTabOrderRef.current();
|
|
86
|
+
const candidates = getTabbableCandidates(contentRef.current);
|
|
87
|
+
if (candidates.length)
|
|
88
|
+
focusFirst(side === "start" ? candidates : candidates.reverse());
|
|
89
|
+
}
|
|
90
|
+
}, []);
|
|
91
|
+
const handleContentExit = React.useCallback(() => {
|
|
92
|
+
if (contentRef.current) {
|
|
93
|
+
const candidates = getTabbableCandidates(contentRef.current);
|
|
94
|
+
if (candidates.length)
|
|
95
|
+
restoreContentTabOrderRef.current = removeFromTabOrder(candidates);
|
|
96
|
+
}
|
|
97
|
+
}, []);
|
|
98
|
+
const classes = clsx([styles[`${rootClassName}`]], className);
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
100
|
+
NavigationMenuContext.Provider,
|
|
101
|
+
{
|
|
102
|
+
value: {
|
|
103
|
+
contentRef,
|
|
104
|
+
focusProxyRef,
|
|
105
|
+
topMenuRef,
|
|
106
|
+
id,
|
|
107
|
+
dir: props.dir || "ltr",
|
|
108
|
+
orientation: props.orientation || "horizontal",
|
|
109
|
+
onEntryKeyDown: handleContentEntry,
|
|
110
|
+
onFocusProxyEnter: handleContentEntry,
|
|
111
|
+
onContentFocusOutside: handleContentExit,
|
|
112
|
+
selectedTopMenu,
|
|
113
|
+
setSelectedTopMenu
|
|
114
|
+
},
|
|
115
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(NavigationMenuPrimitive__namespace.Root, { ...props, ref: forwardRef, className: classes })
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
Root.displayName = "NavigationMenu";
|
|
121
|
+
const TopMenuList = React.forwardRef(
|
|
122
|
+
({ className, ...props }, forwardRef) => {
|
|
123
|
+
const classes = clsx([styles[`${rootClassName}__top-menu-list`]], className);
|
|
124
|
+
const context = React.useContext(NavigationMenuContext);
|
|
125
|
+
const ref = utils_composeRefs.useComposedRefs(context.topMenuRef, forwardRef);
|
|
126
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { ...props, ref, className: classes });
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
TopMenuList.displayName = "NavigationMenu.TopMenuList";
|
|
130
|
+
const TopMenuItem = React.forwardRef(
|
|
131
|
+
({ className, ...props }, forwardRef) => {
|
|
132
|
+
const classes = clsx([styles[`${rootClassName}__top-menu-item`]], className);
|
|
133
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { ...props, ref: forwardRef, className: classes });
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
const TopMenuTrigger = React.forwardRef(
|
|
137
|
+
({ className, asChild, active, ...props }, forwardRef) => {
|
|
138
|
+
const classes = clsx(
|
|
139
|
+
[styles[`${rootClassName}__top-menu-trigger`], styles[`${rootClassName}__top-menu-trigger--small`]],
|
|
140
|
+
className
|
|
141
|
+
);
|
|
142
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
143
|
+
const context = React.useContext(NavigationMenuContext);
|
|
144
|
+
const innerRef = React.useRef(null);
|
|
145
|
+
const ref = utils_composeRefs.useComposedRefs(innerRef, forwardRef);
|
|
146
|
+
const isOpen = context.selectedTopMenu === props.value;
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
149
|
+
Comp,
|
|
150
|
+
{
|
|
151
|
+
...props,
|
|
152
|
+
ref,
|
|
153
|
+
className: classes,
|
|
154
|
+
"data-state": isOpen ? "open" : "closed",
|
|
155
|
+
"data-active": active ? "true" : void 0,
|
|
156
|
+
"aria-expanded": isOpen,
|
|
157
|
+
"aria-controls": makeContentId({ value: props.value, baseId: context.id }),
|
|
158
|
+
...{ [ITEM_DATA_ATTR]: "" },
|
|
159
|
+
onClick: utils_composeEventHandlers.composeEventHandlers(props.onClick, () => {
|
|
160
|
+
context.setSelectedTopMenu(props.value);
|
|
161
|
+
}),
|
|
162
|
+
onKeyDown: utils_composeEventHandlers.composeEventHandlers(props.onKeyDown, (event) => {
|
|
163
|
+
var _a;
|
|
164
|
+
const verticalEntryKey = context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
165
|
+
const entryKey = { horizontal: "ArrowDown", vertical: verticalEntryKey }[context.orientation];
|
|
166
|
+
if (isOpen && event.key === entryKey) {
|
|
167
|
+
context.onEntryKeyDown();
|
|
168
|
+
return event.preventDefault();
|
|
169
|
+
}
|
|
170
|
+
const isFocusNavigationKey = ["Home", "End", ...ARROW_KEYS].includes(event.key);
|
|
171
|
+
if (isFocusNavigationKey) {
|
|
172
|
+
const triggers = (_a = context.topMenuRef.current) == null ? void 0 : _a.querySelectorAll(`[${ITEM_DATA_ATTR}]`);
|
|
173
|
+
if (!triggers)
|
|
174
|
+
return;
|
|
175
|
+
let candidateNodes = Array.from(triggers == null ? void 0 : triggers.values());
|
|
176
|
+
const prevItemKey = context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
177
|
+
const prevKeys = [prevItemKey, "ArrowUp", "End"];
|
|
178
|
+
if (prevKeys.includes(event.key))
|
|
179
|
+
candidateNodes.reverse();
|
|
180
|
+
if (ARROW_KEYS.includes(event.key)) {
|
|
181
|
+
const currentIndex = candidateNodes.indexOf(event.currentTarget);
|
|
182
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
183
|
+
focusFirst(candidateNodes);
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
191
|
+
components_visuallyHidden_visuallyHidden.VisuallyHidden,
|
|
192
|
+
{
|
|
193
|
+
"aria-hidden": true,
|
|
194
|
+
tabIndex: 0,
|
|
195
|
+
ref: context.focusProxyRef,
|
|
196
|
+
onFocus: (event) => {
|
|
197
|
+
const content = context.contentRef.current;
|
|
198
|
+
const prevFocusedElement = event.relatedTarget;
|
|
199
|
+
const wasTriggerFocused = prevFocusedElement === innerRef.current;
|
|
200
|
+
const wasFocusFromContent = content == null ? void 0 : content.contains(prevFocusedElement);
|
|
201
|
+
if (wasTriggerFocused || !wasFocusFromContent) {
|
|
202
|
+
context.onFocusProxyEnter(wasTriggerFocused ? "start" : "end");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] });
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
const List = React.forwardRef(
|
|
211
|
+
({ className, variant, value, ...props }, forwardRef) => {
|
|
212
|
+
const classes = clsx([styles[`${rootClassName}__list`]], [styles[`${rootClassName}__list--${variant}`]], className);
|
|
213
|
+
const context = React.useContext(NavigationMenuContext);
|
|
214
|
+
const refOnOpen = utils_composeRefs.useComposedRefs(context.contentRef, forwardRef);
|
|
215
|
+
const hasTopMenu = context.selectedTopMenu !== void 0;
|
|
216
|
+
const isOpen = context.selectedTopMenu === value;
|
|
217
|
+
if (!isOpen)
|
|
218
|
+
return null;
|
|
219
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
220
|
+
NavigationMenuPrimitive__namespace.List,
|
|
221
|
+
{
|
|
222
|
+
ref: hasTopMenu ? refOnOpen : forwardRef,
|
|
223
|
+
id: value && makeContentId({ value, baseId: context.id }),
|
|
224
|
+
...props,
|
|
225
|
+
onKeyDown: utils_composeEventHandlers.composeEventHandlers(props.onKeyDown, (event) => {
|
|
226
|
+
var _a;
|
|
227
|
+
if (!value)
|
|
228
|
+
return;
|
|
229
|
+
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
230
|
+
const isTabKey = event.key === "Tab" && !isMetaKey;
|
|
231
|
+
if (isTabKey) {
|
|
232
|
+
const candidates = getTabbableCandidates(event.currentTarget);
|
|
233
|
+
const focusedElement = document.activeElement;
|
|
234
|
+
const index = candidates.findIndex((candidate) => candidate === focusedElement);
|
|
235
|
+
const isMovingBackwards = event.shiftKey;
|
|
236
|
+
const nextCandidates = isMovingBackwards ? candidates.slice(0, index).reverse() : candidates.slice(index + 1, candidates.length);
|
|
237
|
+
if (focusFirst(nextCandidates)) {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
} else {
|
|
240
|
+
(_a = context.focusProxyRef.current) == null ? void 0 : _a.focus();
|
|
241
|
+
context.onContentFocusOutside();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}),
|
|
245
|
+
className: classes
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
List.displayName = "NavigationMenu.List";
|
|
251
|
+
const Item = React.forwardRef(
|
|
252
|
+
({ className, ...props }, forwardRef) => {
|
|
253
|
+
const classes = clsx([styles[`${rootClassName}__item`]], className);
|
|
254
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenuPrimitive__namespace.Item, { ...props, ref: forwardRef, className: classes });
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
Item.displayName = "NavigationMenu.Item";
|
|
258
|
+
const Trigger = React.forwardRef(
|
|
259
|
+
({ className, active, variant = "default", ...props }, forwardRef) => {
|
|
260
|
+
const classes = clsx(
|
|
261
|
+
[styles[`${rootClassName}__trigger`]],
|
|
262
|
+
[styles[`${rootClassName}__trigger--${variant}`]],
|
|
263
|
+
className
|
|
264
|
+
);
|
|
265
|
+
const innerRef = React.useRef(null);
|
|
266
|
+
const ref = utils_composeRefs.useComposedRefs(forwardRef, innerRef);
|
|
267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
268
|
+
NavigationMenuPrimitive__namespace.Trigger,
|
|
269
|
+
{
|
|
270
|
+
onPointerEnter: (e) => e.preventDefault(),
|
|
271
|
+
onPointerMove: (e) => e.preventDefault(),
|
|
272
|
+
onPointerLeave: (e) => e.preventDefault(),
|
|
273
|
+
...props,
|
|
274
|
+
ref,
|
|
275
|
+
"data-active": active ? "true" : void 0,
|
|
276
|
+
className: classes,
|
|
277
|
+
"data-text": getLabelFromChildren(props.children)
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
Trigger.displayName = "NavigationMenu.Trigger";
|
|
283
|
+
const Content = React.forwardRef(
|
|
284
|
+
({ className, variant = "default", ...props }, forwardRef) => {
|
|
285
|
+
const classes = clsx(
|
|
286
|
+
[styles[`${rootClassName}__content`]],
|
|
287
|
+
[styles[`${rootClassName}__content--${variant}`]],
|
|
288
|
+
className
|
|
289
|
+
);
|
|
290
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
291
|
+
NavigationMenuPrimitive__namespace.Content,
|
|
292
|
+
{
|
|
293
|
+
onPointerEnter: (e) => e.preventDefault(),
|
|
294
|
+
onPointerLeave: (e) => e.preventDefault(),
|
|
295
|
+
...props,
|
|
296
|
+
ref: forwardRef,
|
|
297
|
+
className: classes
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
const Link = React.forwardRef(
|
|
303
|
+
({ className, variant = "default", ...props }, forwardRef) => {
|
|
304
|
+
const classes = clsx([styles[`${rootClassName}__link`]], [styles[`${rootClassName}__link--${variant}`]], className);
|
|
305
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
306
|
+
NavigationMenuPrimitive__namespace.Link,
|
|
307
|
+
{
|
|
308
|
+
...props,
|
|
309
|
+
ref: forwardRef,
|
|
310
|
+
className: classes,
|
|
311
|
+
"data-text": getLabelFromChildren(props.children)
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
Link.displayName = "NavigationMenu.Link";
|
|
317
|
+
const Indicator = React.forwardRef(
|
|
318
|
+
({ className, ...props }, forwardRef) => {
|
|
319
|
+
const classes = clsx([styles[`${rootClassName}__indicator`]], className);
|
|
320
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenuPrimitive__namespace.Indicator, { ...props, ref: forwardRef, className: classes });
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
Indicator.displayName = "NavigationMenu.Indicator";
|
|
324
|
+
const Viewport = React.forwardRef(
|
|
325
|
+
({ className, ...props }, forwardRef) => {
|
|
326
|
+
const classes = clsx([styles[`${rootClassName}__viewport`]], className);
|
|
327
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenuPrimitive__namespace.Viewport, { ...props, ref: forwardRef, className: classes });
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
Viewport.displayName = "NavigationMenu.Viewport";
|
|
331
|
+
const Sub = React.forwardRef(
|
|
332
|
+
({ className, ...props }, forwardRef) => {
|
|
333
|
+
const classes = clsx([styles[`${rootClassName}__sub`]], className);
|
|
334
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenuPrimitive__namespace.Sub, { ...props, ref: forwardRef, className: classes });
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
Sub.displayName = "NavigationMenu.Sub";
|
|
338
|
+
function getLabelFromChildren(children) {
|
|
339
|
+
function findLabel(node) {
|
|
340
|
+
if (typeof node === "string") {
|
|
341
|
+
return node;
|
|
342
|
+
}
|
|
343
|
+
if (React.isValidElement(node) && node.props.children) {
|
|
344
|
+
return findLabel(node.props.children);
|
|
345
|
+
}
|
|
346
|
+
if (Array.isArray(node)) {
|
|
347
|
+
for (let i = node.length - 1; i >= 0; i--) {
|
|
348
|
+
const label = findLabel(node[i]);
|
|
349
|
+
if (label) {
|
|
350
|
+
return label;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return void 0;
|
|
355
|
+
}
|
|
356
|
+
return findLabel(children);
|
|
357
|
+
}
|
|
358
|
+
function getTabbableCandidates(container) {
|
|
359
|
+
const nodes = [];
|
|
360
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
361
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
362
|
+
acceptNode: (node) => {
|
|
363
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
364
|
+
if (node.disabled || node.hidden || isHiddenInput)
|
|
365
|
+
return NodeFilter.FILTER_SKIP;
|
|
366
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
while (walker.nextNode())
|
|
370
|
+
nodes.push(walker.currentNode);
|
|
371
|
+
return nodes;
|
|
372
|
+
}
|
|
373
|
+
function focusFirst(candidates) {
|
|
374
|
+
const previouslyFocusedElement = document.activeElement;
|
|
375
|
+
return candidates.some((candidate) => {
|
|
376
|
+
if (candidate === previouslyFocusedElement)
|
|
377
|
+
return true;
|
|
378
|
+
candidate.focus();
|
|
379
|
+
return document.activeElement !== previouslyFocusedElement;
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function removeFromTabOrder(candidates) {
|
|
383
|
+
candidates.forEach((candidate) => {
|
|
384
|
+
candidate.dataset.tabindex = candidate.getAttribute("tabindex") || "";
|
|
385
|
+
candidate.setAttribute("tabindex", "-1");
|
|
386
|
+
});
|
|
387
|
+
return () => {
|
|
388
|
+
candidates.forEach((candidate) => {
|
|
389
|
+
const prevTabIndex = candidate.dataset.tabindex;
|
|
390
|
+
candidate.setAttribute("tabindex", prevTabIndex);
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
const ITEM_DATA_ATTR = "data-teddy-top-selector-trigger";
|
|
395
|
+
const ARROW_KEYS = ["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"];
|
|
396
|
+
function makeContentId(args) {
|
|
397
|
+
return `teddy-navigation-menu-${args.baseId}-${args.value}-content`;
|
|
398
|
+
}
|
|
399
|
+
const NavigationMenu = Object.assign(Root, {
|
|
400
|
+
List,
|
|
401
|
+
Item,
|
|
402
|
+
Trigger,
|
|
403
|
+
Content,
|
|
404
|
+
Link,
|
|
405
|
+
Indicator,
|
|
406
|
+
Viewport,
|
|
407
|
+
Sub,
|
|
408
|
+
TopMenuList,
|
|
409
|
+
TopMenuItem,
|
|
410
|
+
TopMenuTrigger
|
|
411
|
+
});
|
|
412
|
+
exports.NavigationMenu = NavigationMenu;
|
|
@@ -24,6 +24,7 @@ type TopMenuItemProps = React.ComponentPropsWithoutRef<'li'>;
|
|
|
24
24
|
type TopMenuTriggerProps = React.ComponentPropsWithoutRef<'button'> & {
|
|
25
25
|
value: string;
|
|
26
26
|
active?: boolean;
|
|
27
|
+
asChild?: boolean;
|
|
27
28
|
};
|
|
28
29
|
/** -------------------------------------------------------------------------------------------------
|
|
29
30
|
* NavigationMenuList
|
|
@@ -110,6 +111,7 @@ declare const NavigationMenu: React.ForwardRefExoticComponent<Omit<NavigationMen
|
|
|
110
111
|
TopMenuTrigger: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
111
112
|
value: string;
|
|
112
113
|
active?: boolean | undefined;
|
|
114
|
+
asChild?: boolean | undefined;
|
|
113
115
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
114
116
|
};
|
|
115
117
|
type NavigationMenuProps = {
|
|
@@ -5,31 +5,32 @@ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
|
5
5
|
import { useComposedRefs } from "../../utils/composeRefs.js";
|
|
6
6
|
import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
|
|
7
7
|
import { composeEventHandlers } from "../../utils/composeEventHandlers.js";
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
8
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
9
|
+
const enterFromLeft = "_enterFromLeft_959s3_1";
|
|
10
|
+
const enterFromRight = "_enterFromRight_959s3_1";
|
|
11
|
+
const exitToLeft = "_exitToLeft_959s3_1";
|
|
12
|
+
const exitToRight = "_exitToRight_959s3_1";
|
|
13
|
+
const scaleIn = "_scaleIn_959s3_1";
|
|
14
|
+
const scaleOut = "_scaleOut_959s3_1";
|
|
14
15
|
const styles = {
|
|
15
|
-
"teddy-navigation-menu": "_teddy-navigation-
|
|
16
|
-
"teddy-navigation-menu__viewport": "_teddy-navigation-
|
|
17
|
-
"teddy-navigation-menu__list": "_teddy-navigation-
|
|
18
|
-
"teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-
|
|
19
|
-
"teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-
|
|
20
|
-
"teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--
|
|
21
|
-
"teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--
|
|
22
|
-
"teddy-navigation-menu__content": "_teddy-navigation-
|
|
16
|
+
"teddy-navigation-menu": "_teddy-navigation-menu_959s3_1",
|
|
17
|
+
"teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_959s3_33",
|
|
18
|
+
"teddy-navigation-menu__list": "_teddy-navigation-menu__list_959s3_36",
|
|
19
|
+
"teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_959s3_55",
|
|
20
|
+
"teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_959s3_75",
|
|
21
|
+
"teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_959s3_92",
|
|
22
|
+
"teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_959s3_97",
|
|
23
|
+
"teddy-navigation-menu__content": "_teddy-navigation-menu__content_959s3_169",
|
|
23
24
|
enterFromLeft,
|
|
24
25
|
enterFromRight,
|
|
25
26
|
exitToLeft,
|
|
26
27
|
exitToRight,
|
|
27
|
-
"teddy-navigation-menu__trigger": "_teddy-navigation-
|
|
28
|
-
"teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--
|
|
29
|
-
"teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--
|
|
30
|
-
"teddy-navigation-menu__link": "_teddy-navigation-
|
|
31
|
-
"teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--
|
|
32
|
-
"teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--
|
|
28
|
+
"teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_959s3_213",
|
|
29
|
+
"teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_959s3_231",
|
|
30
|
+
"teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_959s3_236",
|
|
31
|
+
"teddy-navigation-menu__link": "_teddy-navigation-menu__link_959s3_301",
|
|
32
|
+
"teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_959s3_319",
|
|
33
|
+
"teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_959s3_324",
|
|
33
34
|
scaleIn,
|
|
34
35
|
scaleOut
|
|
35
36
|
};
|
|
@@ -114,18 +115,19 @@ const TopMenuItem = React__default.forwardRef(
|
|
|
114
115
|
}
|
|
115
116
|
);
|
|
116
117
|
const TopMenuTrigger = React__default.forwardRef(
|
|
117
|
-
({ className, active, ...props }, forwardRef) => {
|
|
118
|
+
({ className, asChild, active, ...props }, forwardRef) => {
|
|
118
119
|
const classes = clsx(
|
|
119
120
|
[styles[`${rootClassName}__top-menu-trigger`], styles[`${rootClassName}__top-menu-trigger--small`]],
|
|
120
121
|
className
|
|
121
122
|
);
|
|
123
|
+
const Comp = asChild ? Slot : "button";
|
|
122
124
|
const context = React__default.useContext(NavigationMenuContext);
|
|
123
125
|
const innerRef = React__default.useRef(null);
|
|
124
126
|
const ref = useComposedRefs(innerRef, forwardRef);
|
|
125
127
|
const isOpen = context.selectedTopMenu === props.value;
|
|
126
128
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
129
|
/* @__PURE__ */ jsx(
|
|
128
|
-
|
|
130
|
+
Comp,
|
|
129
131
|
{
|
|
130
132
|
...props,
|
|
131
133
|
ref,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const clsx = require("clsx");
|
|
6
|
+
const Collapsible = require("@radix-ui/react-collapsible");
|
|
7
|
+
const reactUseControllableState = require("@radix-ui/react-use-controllable-state");
|
|
8
|
+
const components_text_text = require("../text/text.cjs");
|
|
9
|
+
const components_button_button = require("../button/button.cjs");
|
|
10
|
+
require("../../assets/sprite.5636ec8e-teddy.svg");
|
|
11
|
+
const components_icon_icon = require("../icon/icon.cjs");
|
|
12
|
+
const components_heading_heading = require("../heading/heading.cjs");
|
|
13
|
+
const components_card_card = require("../card/card.cjs");
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
15
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
16
|
+
if (e) {
|
|
17
|
+
for (const k in e) {
|
|
18
|
+
if (k !== "default") {
|
|
19
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: () => e[k]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
const Collapsible__namespace = /* @__PURE__ */ _interopNamespaceDefault(Collapsible);
|
|
31
|
+
const styles = {
|
|
32
|
+
"teddy-notification": "_teddy-notification_1ref8_3",
|
|
33
|
+
"teddy-notification__dismiss": "_teddy-notification__dismiss_1ref8_12",
|
|
34
|
+
"teddy-notification--success": "_teddy-notification--success_1ref8_16",
|
|
35
|
+
"teddy-notification--warning": "_teddy-notification--warning_1ref8_21",
|
|
36
|
+
"teddy-notification--error": "_teddy-notification--error_1ref8_26",
|
|
37
|
+
"teddy-notification--information": "_teddy-notification--information_1ref8_31",
|
|
38
|
+
"teddy-notification__heading": "_teddy-notification__heading_1ref8_36",
|
|
39
|
+
"teddy-notification__icon": "_teddy-notification__icon_1ref8_41"
|
|
40
|
+
};
|
|
41
|
+
const rootClassName = "teddy-notification";
|
|
42
|
+
const NotificationContext = React.createContext(void 0);
|
|
43
|
+
const Root = React.forwardRef(
|
|
44
|
+
({ className, open: openProp, defaultOpen, onOpenChange, variant, ...props }, forwardRef) => {
|
|
45
|
+
const classes = clsx([styles[`${rootClassName}`]], styles[`${rootClassName}--${variant}`], className);
|
|
46
|
+
const [open = true, setOpen] = reactUseControllableState.useControllableState({
|
|
47
|
+
prop: openProp,
|
|
48
|
+
defaultProp: defaultOpen,
|
|
49
|
+
onChange: onOpenChange
|
|
50
|
+
});
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NotificationContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible__namespace.Root, { open, onOpenChange: setOpen, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible__namespace.Content, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(components_card_card.Card, { variant: "white", as: void 0, bordered: true, ...props, ref: forwardRef, className: classes }) }) }) });
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
Root.displayName = "Notification";
|
|
55
|
+
function getVariantIcon(variant) {
|
|
56
|
+
switch (variant) {
|
|
57
|
+
case "success":
|
|
58
|
+
return "check-circle-filled";
|
|
59
|
+
case "error":
|
|
60
|
+
return "error-filled";
|
|
61
|
+
case "warning":
|
|
62
|
+
return "alert-filled";
|
|
63
|
+
case "information":
|
|
64
|
+
return "info-filled";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const Icon = React.forwardRef(
|
|
68
|
+
({ className, ...props }, forwardRef) => {
|
|
69
|
+
const classes = clsx([styles[`${rootClassName}__icon`]], className);
|
|
70
|
+
const context = React.useContext(NotificationContext);
|
|
71
|
+
const name = props.name || getVariantIcon(context == null ? void 0 : context.variant);
|
|
72
|
+
if (!name)
|
|
73
|
+
return null;
|
|
74
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { size: "md", ...props, name, ref: forwardRef, className: classes });
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
Icon.displayName = "Notification.Icon";
|
|
78
|
+
const Heading = React.forwardRef(
|
|
79
|
+
({ className, ...props }, forwardRef) => {
|
|
80
|
+
const classes = clsx([styles[`${rootClassName}__heading`]], className);
|
|
81
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components_heading_heading.Heading, { ...props, variant: "subsection-100", asChild: false, ref: forwardRef, className: classes });
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
Heading.displayName = "Notification.Heading";
|
|
85
|
+
const Text = React.forwardRef(
|
|
86
|
+
({ className, ...props }, forwardRef) => {
|
|
87
|
+
const classes = clsx([styles[`${rootClassName}__text`]], className);
|
|
88
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components_text_text.Text, { ...props, ref: forwardRef, className: classes });
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
Text.displayName = "Notification.Text";
|
|
92
|
+
const Dismiss = React.forwardRef(
|
|
93
|
+
({ className, children, ...props }, forwardRef) => {
|
|
94
|
+
const classes = clsx([styles[`${rootClassName}__dismiss`]], className);
|
|
95
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Collapsible__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
96
|
+
components_button_button.Button,
|
|
97
|
+
{
|
|
98
|
+
iconOnly: true,
|
|
99
|
+
"aria-label": "Lukk",
|
|
100
|
+
variant: "tertiary-purple",
|
|
101
|
+
...props,
|
|
102
|
+
ref: forwardRef,
|
|
103
|
+
className: classes,
|
|
104
|
+
children: children || /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "close" })
|
|
105
|
+
}
|
|
106
|
+
) });
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
Dismiss.displayName = "Notification.Dismiss";
|
|
110
|
+
const Notification = Object.assign(Root, {
|
|
111
|
+
Text,
|
|
112
|
+
Heading,
|
|
113
|
+
Icon,
|
|
114
|
+
Dismiss
|
|
115
|
+
});
|
|
116
|
+
exports.Notification = Notification;
|
|
@@ -10,14 +10,14 @@ import { Icon as Icon$1 } from "../icon/icon.js";
|
|
|
10
10
|
import { Heading as Heading$1 } from "../heading/heading.js";
|
|
11
11
|
import { Card } from "../card/card.js";
|
|
12
12
|
const styles = {
|
|
13
|
-
"teddy-notification": "_teddy-
|
|
14
|
-
"teddy-notification__dismiss": "_teddy-
|
|
15
|
-
"teddy-notification--success": "_teddy-notification--
|
|
16
|
-
"teddy-notification--warning": "_teddy-notification--
|
|
17
|
-
"teddy-notification--error": "_teddy-notification--
|
|
18
|
-
"teddy-notification--information": "_teddy-notification--
|
|
19
|
-
"teddy-notification__heading": "_teddy-
|
|
20
|
-
"teddy-notification__icon": "_teddy-
|
|
13
|
+
"teddy-notification": "_teddy-notification_1ref8_3",
|
|
14
|
+
"teddy-notification__dismiss": "_teddy-notification__dismiss_1ref8_12",
|
|
15
|
+
"teddy-notification--success": "_teddy-notification--success_1ref8_16",
|
|
16
|
+
"teddy-notification--warning": "_teddy-notification--warning_1ref8_21",
|
|
17
|
+
"teddy-notification--error": "_teddy-notification--error_1ref8_26",
|
|
18
|
+
"teddy-notification--information": "_teddy-notification--information_1ref8_31",
|
|
19
|
+
"teddy-notification__heading": "_teddy-notification__heading_1ref8_36",
|
|
20
|
+
"teddy-notification__icon": "_teddy-notification__icon_1ref8_41"
|
|
21
21
|
};
|
|
22
22
|
const rootClassName = "teddy-notification";
|
|
23
23
|
const NotificationContext = React__default.createContext(void 0);
|