@telia/teddy 0.0.15 → 0.0.17

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 (117) hide show
  1. package/dist/components/accordion/accordion.d.ts +2 -1
  2. package/dist/components/accordion/accordion.js +90 -24
  3. package/dist/components/accordion/index.js +2 -2
  4. package/dist/components/badge/badge.js +40 -24
  5. package/dist/components/badge/index.js +2 -2
  6. package/dist/components/box/box.js +14 -10
  7. package/dist/components/box/index.js +2 -2
  8. package/dist/components/button/button.js +60 -52
  9. package/dist/components/button/index.js +2 -2
  10. package/dist/components/card/card.d.ts +35 -3
  11. package/dist/components/card/card.js +209 -25
  12. package/dist/components/card/index.js +2 -2
  13. package/dist/components/field-error-text/field-error-text.js +21 -19
  14. package/dist/components/field-error-text/index.js +2 -2
  15. package/dist/components/flex/flex.js +15 -12
  16. package/dist/components/flex/index.js +2 -2
  17. package/dist/components/grid/grid.js +15 -12
  18. package/dist/components/grid/index.js +2 -2
  19. package/dist/components/heading/heading.js +22 -19
  20. package/dist/components/heading/index.js +2 -2
  21. package/dist/components/helper-text/helper-text.js +14 -13
  22. package/dist/components/helper-text/index.js +2 -2
  23. package/dist/components/icon/icon.js +16 -14
  24. package/dist/components/icon/index.js +4 -4
  25. package/dist/components/index.js +51 -46
  26. package/dist/components/input/index.js +3 -3
  27. package/dist/components/input/input.js +79 -66
  28. package/dist/components/label/index.js +2 -2
  29. package/dist/components/label/label.js +17 -23
  30. package/dist/components/link/index.js +2 -2
  31. package/dist/components/link/link.js +20 -19
  32. package/dist/components/modal/index.js +2 -2
  33. package/dist/components/modal/modal.js +173 -14
  34. package/dist/components/navigation-menu/index.js +2 -2
  35. package/dist/components/navigation-menu/navigation-menu.js +391 -8
  36. package/dist/components/notification/index.js +2 -2
  37. package/dist/components/notification/notification.d.ts +8 -7
  38. package/dist/components/notification/notification.js +96 -24
  39. package/dist/components/radio-group/index.js +2 -2
  40. package/dist/components/radio-group/radio-group.js +91 -8
  41. package/dist/components/spinner/index.js +2 -2
  42. package/dist/components/spinner/spinner.js +36 -29
  43. package/dist/components/text/index.js +2 -2
  44. package/dist/components/text/text.js +18 -17
  45. package/dist/components/text-field/index.js +2 -2
  46. package/dist/components/text-field/text-field.js +110 -90
  47. package/dist/components/text-spacing/index.js +2 -2
  48. package/dist/components/text-spacing/text-spacing.js +14 -12
  49. package/dist/components/toggle/index.js +2 -2
  50. package/dist/components/toggle/toggle.d.ts +1 -1
  51. package/dist/components/toggle/toggle.js +84 -23
  52. package/dist/components/visually-hidden/index.js +2 -2
  53. package/dist/components/visually-hidden/visually-hidden.js +17 -15
  54. package/dist/icons/category.js +2 -2
  55. package/dist/icons/name.js +2 -2
  56. package/dist/main.js +359 -61
  57. package/dist/style.css +3406 -0
  58. package/dist/tokens/border/variables.js +18 -10
  59. package/dist/tokens/breakpoint/variables.js +8 -5
  60. package/dist/tokens/color/variables.js +452 -227
  61. package/dist/tokens/index.d.ts +7 -7
  62. package/dist/tokens/index.js +308 -14
  63. package/dist/tokens/motion/variables.js +22 -12
  64. package/dist/tokens/shadow/variables.js +8 -5
  65. package/dist/tokens/spacing/variables.js +46 -24
  66. package/dist/tokens/typography/variables.js +48 -25
  67. package/dist/utils/action.js +10 -7
  68. package/dist/utils/composeEventHandlers.js +7 -5
  69. package/dist/utils/composeRefs.js +13 -9
  70. package/dist/utils/layout/align.js +5 -4
  71. package/dist/utils/layout/flex.js +25 -18
  72. package/dist/utils/layout/gap.js +7 -6
  73. package/dist/utils/layout/grid.js +31 -24
  74. package/dist/utils/layout/height.js +12 -11
  75. package/dist/utils/layout/index.d.ts +1863 -0
  76. package/dist/utils/layout/index.js +77 -59
  77. package/dist/utils/layout/inset.js +10 -9
  78. package/dist/utils/layout/justify.js +6 -5
  79. package/dist/utils/layout/margin.js +10 -9
  80. package/dist/utils/layout/padding.js +10 -9
  81. package/dist/utils/layout/position.js +6 -5
  82. package/dist/utils/layout/util.js +7 -6
  83. package/dist/utils/layout/width.js +8 -7
  84. package/package.json +22 -14
  85. package/dist/assets/badge.css +0 -1
  86. package/dist/assets/button.css +0 -1
  87. package/dist/assets/field-error-text.css +0 -1
  88. package/dist/assets/flex.css +0 -1
  89. package/dist/assets/grid.css +0 -1
  90. package/dist/assets/heading.css +0 -1
  91. package/dist/assets/helper-text.css +0 -1
  92. package/dist/assets/icon.css +0 -1
  93. package/dist/assets/input.css +0 -1
  94. package/dist/assets/label.css +0 -1
  95. package/dist/assets/link.css +0 -1
  96. package/dist/assets/main.css +0 -1
  97. package/dist/assets/navigation-menu.css +0 -1
  98. package/dist/assets/radio-group.css +0 -1
  99. package/dist/assets/spinner.css +0 -1
  100. package/dist/assets/text-field.css +0 -1
  101. package/dist/assets/text-spacing.css +0 -1
  102. package/dist/assets/text.css +0 -1
  103. package/dist/assets/visually-hidden.css +0 -1
  104. package/dist/badge-Cnug5TzH.js +0 -1855
  105. package/dist/clsx-DB4S2d7J.js +0 -22
  106. package/dist/index-DM5e-Whg.js +0 -43
  107. package/dist/index-DpfSJps6.js +0 -75
  108. package/dist/index-FPIZOCcD.js +0 -305
  109. package/dist/navigation-menu-DKuyW8zE.js +0 -1036
  110. package/dist/radio-group-B--zT3OL.js +0 -440
  111. package/dist/variables-BKiPmtHY.js +0 -458
  112. package/dist/variables-BkY5b0io.js +0 -14
  113. package/dist/variables-Bq0YUbLS.js +0 -14
  114. package/dist/variables-CDK515QX.js +0 -52
  115. package/dist/variables-CMRTN8qo.js +0 -28
  116. package/dist/variables-Dmoh9YtD.js +0 -54
  117. package/dist/variables-IczXZ5CN.js +0 -24
@@ -1,10 +1,393 @@
1
- import "react/jsx-runtime";
2
- import "react";
3
- import "../../clsx-DB4S2d7J.js";
4
- import { N as n } from "../../navigation-menu-DKuyW8zE.js";
5
- import "../../utils/composeRefs.js";
6
- import "../visually-hidden/visually-hidden.js";
7
- import "../../utils/composeEventHandlers.js";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import React__default from "react";
3
+ import clsx from "clsx";
4
+ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
5
+ import { useComposedRefs } from "../../utils/composeRefs.js";
6
+ import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
7
+ import { composeEventHandlers } from "../../utils/composeEventHandlers.js";
8
+ const enterFromLeft = "_enterFromLeft_139wf_1";
9
+ const enterFromRight = "_enterFromRight_139wf_1";
10
+ const exitToLeft = "_exitToLeft_139wf_1";
11
+ const exitToRight = "_exitToRight_139wf_1";
12
+ const scaleIn = "_scaleIn_139wf_1";
13
+ const scaleOut = "_scaleOut_139wf_1";
14
+ const styles = {
15
+ "teddy-navigation-menu": "_teddy-navigation-menu_139wf_1",
16
+ "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_139wf_33",
17
+ "teddy-navigation-menu__list": "_teddy-navigation-menu__list_139wf_36",
18
+ "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_139wf_55",
19
+ "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_139wf_75",
20
+ "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_139wf_93",
21
+ "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_139wf_98",
22
+ "teddy-navigation-menu__content": "_teddy-navigation-menu__content_139wf_163",
23
+ enterFromLeft,
24
+ enterFromRight,
25
+ exitToLeft,
26
+ exitToRight,
27
+ "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_139wf_208",
28
+ "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_139wf_226",
29
+ "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_139wf_231",
30
+ "teddy-navigation-menu__link": "_teddy-navigation-menu__link_139wf_296",
31
+ "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_139wf_314",
32
+ "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_139wf_319",
33
+ scaleIn,
34
+ scaleOut
35
+ };
36
+ const rootClassName = "teddy-navigation-menu";
37
+ const NavigationMenuContext = React__default.createContext({
38
+ selectedTopMenu: void 0,
39
+ setSelectedTopMenu: () => {
40
+ },
41
+ contentRef: { current: null },
42
+ focusProxyRef: { current: null },
43
+ topMenuRef: { current: null },
44
+ id: "",
45
+ dir: "ltr",
46
+ orientation: "horizontal",
47
+ onEntryKeyDown: () => {
48
+ },
49
+ onFocusProxyEnter: () => {
50
+ },
51
+ onContentFocusOutside: () => {
52
+ }
53
+ });
54
+ const Root = React__default.forwardRef(
55
+ ({ className, defaultTopMenuValue, ...props }, forwardRef) => {
56
+ const [selectedTopMenu, setSelectedTopMenu] = React__default.useState(defaultTopMenuValue);
57
+ const contentRef = React__default.useRef(null);
58
+ const restoreContentTabOrderRef = React__default.useRef(() => {
59
+ });
60
+ const focusProxyRef = React__default.useRef(null);
61
+ const topMenuRef = React__default.useRef(null);
62
+ const id = React__default.useId();
63
+ const handleContentEntry = React__default.useCallback((side = "start") => {
64
+ if (contentRef.current) {
65
+ restoreContentTabOrderRef.current();
66
+ const candidates = getTabbableCandidates(contentRef.current);
67
+ if (candidates.length)
68
+ focusFirst(side === "start" ? candidates : candidates.reverse());
69
+ }
70
+ }, []);
71
+ const handleContentExit = React__default.useCallback(() => {
72
+ if (contentRef.current) {
73
+ const candidates = getTabbableCandidates(contentRef.current);
74
+ if (candidates.length)
75
+ restoreContentTabOrderRef.current = removeFromTabOrder(candidates);
76
+ }
77
+ }, []);
78
+ const classes = clsx([styles[`${rootClassName}`]], className);
79
+ return /* @__PURE__ */ jsx(
80
+ NavigationMenuContext.Provider,
81
+ {
82
+ value: {
83
+ contentRef,
84
+ focusProxyRef,
85
+ topMenuRef,
86
+ id,
87
+ dir: props.dir || "ltr",
88
+ orientation: props.orientation || "horizontal",
89
+ onEntryKeyDown: handleContentEntry,
90
+ onFocusProxyEnter: handleContentEntry,
91
+ onContentFocusOutside: handleContentExit,
92
+ selectedTopMenu,
93
+ setSelectedTopMenu
94
+ },
95
+ children: /* @__PURE__ */ jsx(NavigationMenuPrimitive.Root, { ...props, ref: forwardRef, className: classes })
96
+ }
97
+ );
98
+ }
99
+ );
100
+ Root.displayName = "NavigationMenu";
101
+ const TopMenuList = React__default.forwardRef(
102
+ ({ className, ...props }, forwardRef) => {
103
+ const classes = clsx([styles[`${rootClassName}__top-menu-list`]], className);
104
+ const context = React__default.useContext(NavigationMenuContext);
105
+ const ref = useComposedRefs(context.topMenuRef, forwardRef);
106
+ return /* @__PURE__ */ jsx("ul", { ...props, ref, className: classes });
107
+ }
108
+ );
109
+ TopMenuList.displayName = "NavigationMenu.TopMenuList";
110
+ const TopMenuItem = React__default.forwardRef(
111
+ ({ className, ...props }, forwardRef) => {
112
+ const classes = clsx([styles[`${rootClassName}__top-menu-item`]], className);
113
+ return /* @__PURE__ */ jsx("li", { ...props, ref: forwardRef, className: classes });
114
+ }
115
+ );
116
+ const TopMenuTrigger = React__default.forwardRef(
117
+ ({ className, active, ...props }, forwardRef) => {
118
+ const classes = clsx(
119
+ [styles[`${rootClassName}__top-menu-trigger`], styles[`${rootClassName}__top-menu-trigger--small`]],
120
+ className
121
+ );
122
+ const context = React__default.useContext(NavigationMenuContext);
123
+ const innerRef = React__default.useRef(null);
124
+ const ref = useComposedRefs(innerRef, forwardRef);
125
+ const isOpen = context.selectedTopMenu === props.value;
126
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
127
+ /* @__PURE__ */ jsx(
128
+ "button",
129
+ {
130
+ ...props,
131
+ ref,
132
+ className: classes,
133
+ "data-state": isOpen ? "open" : "closed",
134
+ "data-active": active ? "true" : void 0,
135
+ "aria-expanded": isOpen,
136
+ "aria-controls": makeContentId({ value: props.value, baseId: context.id }),
137
+ ...{ [ITEM_DATA_ATTR]: "" },
138
+ onClick: composeEventHandlers(props.onClick, () => {
139
+ context.setSelectedTopMenu(props.value);
140
+ }),
141
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
142
+ var _a;
143
+ const verticalEntryKey = context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
144
+ const entryKey = { horizontal: "ArrowDown", vertical: verticalEntryKey }[context.orientation];
145
+ if (isOpen && event.key === entryKey) {
146
+ context.onEntryKeyDown();
147
+ return event.preventDefault();
148
+ }
149
+ const isFocusNavigationKey = ["Home", "End", ...ARROW_KEYS].includes(event.key);
150
+ if (isFocusNavigationKey) {
151
+ const triggers = (_a = context.topMenuRef.current) == null ? void 0 : _a.querySelectorAll(`[${ITEM_DATA_ATTR}]`);
152
+ if (!triggers)
153
+ return;
154
+ let candidateNodes = Array.from(triggers == null ? void 0 : triggers.values());
155
+ const prevItemKey = context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
156
+ const prevKeys = [prevItemKey, "ArrowUp", "End"];
157
+ if (prevKeys.includes(event.key))
158
+ candidateNodes.reverse();
159
+ if (ARROW_KEYS.includes(event.key)) {
160
+ const currentIndex = candidateNodes.indexOf(event.currentTarget);
161
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
162
+ focusFirst(candidateNodes);
163
+ event.preventDefault();
164
+ }
165
+ }
166
+ })
167
+ }
168
+ ),
169
+ isOpen && /* @__PURE__ */ jsx(
170
+ VisuallyHidden,
171
+ {
172
+ "aria-hidden": true,
173
+ tabIndex: 0,
174
+ ref: context.focusProxyRef,
175
+ onFocus: (event) => {
176
+ const content = context.contentRef.current;
177
+ const prevFocusedElement = event.relatedTarget;
178
+ const wasTriggerFocused = prevFocusedElement === innerRef.current;
179
+ const wasFocusFromContent = content == null ? void 0 : content.contains(prevFocusedElement);
180
+ if (wasTriggerFocused || !wasFocusFromContent) {
181
+ context.onFocusProxyEnter(wasTriggerFocused ? "start" : "end");
182
+ }
183
+ }
184
+ }
185
+ )
186
+ ] });
187
+ }
188
+ );
189
+ const List = React__default.forwardRef(
190
+ ({ className, variant, value, ...props }, forwardRef) => {
191
+ const classes = clsx([styles[`${rootClassName}__list`]], [styles[`${rootClassName}__list--${variant}`]], className);
192
+ const context = React__default.useContext(NavigationMenuContext);
193
+ const refOnOpen = useComposedRefs(context.contentRef, forwardRef);
194
+ const hasTopMenu = context.selectedTopMenu !== void 0;
195
+ const isOpen = context.selectedTopMenu === value;
196
+ if (!isOpen)
197
+ return null;
198
+ return /* @__PURE__ */ jsx(
199
+ NavigationMenuPrimitive.List,
200
+ {
201
+ ref: hasTopMenu ? refOnOpen : forwardRef,
202
+ id: value && makeContentId({ value, baseId: context.id }),
203
+ ...props,
204
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
205
+ var _a;
206
+ if (!value)
207
+ return;
208
+ const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
209
+ const isTabKey = event.key === "Tab" && !isMetaKey;
210
+ if (isTabKey) {
211
+ const candidates = getTabbableCandidates(event.currentTarget);
212
+ const focusedElement = document.activeElement;
213
+ const index = candidates.findIndex((candidate) => candidate === focusedElement);
214
+ const isMovingBackwards = event.shiftKey;
215
+ const nextCandidates = isMovingBackwards ? candidates.slice(0, index).reverse() : candidates.slice(index + 1, candidates.length);
216
+ if (focusFirst(nextCandidates)) {
217
+ event.preventDefault();
218
+ } else {
219
+ (_a = context.focusProxyRef.current) == null ? void 0 : _a.focus();
220
+ context.onContentFocusOutside();
221
+ }
222
+ }
223
+ }),
224
+ className: classes
225
+ }
226
+ );
227
+ }
228
+ );
229
+ List.displayName = "NavigationMenu.List";
230
+ const Item = React__default.forwardRef(
231
+ ({ className, ...props }, forwardRef) => {
232
+ const classes = clsx([styles[`${rootClassName}__item`]], className);
233
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Item, { ...props, ref: forwardRef, className: classes });
234
+ }
235
+ );
236
+ Item.displayName = "NavigationMenu.Item";
237
+ const Trigger = React__default.forwardRef(
238
+ ({ className, active, variant = "default", ...props }, forwardRef) => {
239
+ const classes = clsx(
240
+ [styles[`${rootClassName}__trigger`]],
241
+ [styles[`${rootClassName}__trigger--${variant}`]],
242
+ className
243
+ );
244
+ const innerRef = React__default.useRef(null);
245
+ const ref = useComposedRefs(forwardRef, innerRef);
246
+ return /* @__PURE__ */ jsx(
247
+ NavigationMenuPrimitive.Trigger,
248
+ {
249
+ onPointerEnter: (e) => e.preventDefault(),
250
+ onPointerMove: (e) => e.preventDefault(),
251
+ onPointerLeave: (e) => e.preventDefault(),
252
+ ...props,
253
+ ref,
254
+ "data-active": active ? "true" : void 0,
255
+ className: classes,
256
+ "data-text": getLabelFromChildren(props.children)
257
+ }
258
+ );
259
+ }
260
+ );
261
+ Trigger.displayName = "NavigationMenu.Trigger";
262
+ const Content = React__default.forwardRef(
263
+ ({ className, variant = "default", ...props }, forwardRef) => {
264
+ const classes = clsx(
265
+ [styles[`${rootClassName}__content`]],
266
+ [styles[`${rootClassName}__content--${variant}`]],
267
+ className
268
+ );
269
+ return /* @__PURE__ */ jsx(
270
+ NavigationMenuPrimitive.Content,
271
+ {
272
+ onPointerEnter: (e) => e.preventDefault(),
273
+ onPointerLeave: (e) => e.preventDefault(),
274
+ ...props,
275
+ ref: forwardRef,
276
+ className: classes
277
+ }
278
+ );
279
+ }
280
+ );
281
+ const Link = React__default.forwardRef(
282
+ ({ className, variant = "default", ...props }, forwardRef) => {
283
+ const classes = clsx([styles[`${rootClassName}__link`]], [styles[`${rootClassName}__link--${variant}`]], className);
284
+ return /* @__PURE__ */ jsx(
285
+ NavigationMenuPrimitive.Link,
286
+ {
287
+ ...props,
288
+ ref: forwardRef,
289
+ className: classes,
290
+ "data-text": getLabelFromChildren(props.children)
291
+ }
292
+ );
293
+ }
294
+ );
295
+ Link.displayName = "NavigationMenu.Link";
296
+ const Indicator = React__default.forwardRef(
297
+ ({ className, ...props }, forwardRef) => {
298
+ const classes = clsx([styles[`${rootClassName}__indicator`]], className);
299
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Indicator, { ...props, ref: forwardRef, className: classes });
300
+ }
301
+ );
302
+ Indicator.displayName = "NavigationMenu.Indicator";
303
+ const Viewport = React__default.forwardRef(
304
+ ({ className, ...props }, forwardRef) => {
305
+ const classes = clsx([styles[`${rootClassName}__viewport`]], className);
306
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Viewport, { ...props, ref: forwardRef, className: classes });
307
+ }
308
+ );
309
+ Viewport.displayName = "NavigationMenu.Viewport";
310
+ const Sub = React__default.forwardRef(
311
+ ({ className, ...props }, forwardRef) => {
312
+ const classes = clsx([styles[`${rootClassName}__sub`]], className);
313
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Sub, { ...props, ref: forwardRef, className: classes });
314
+ }
315
+ );
316
+ Sub.displayName = "NavigationMenu.Sub";
317
+ function getLabelFromChildren(children) {
318
+ function findLabel(node) {
319
+ if (typeof node === "string") {
320
+ return node;
321
+ }
322
+ if (React__default.isValidElement(node) && node.props.children) {
323
+ return findLabel(node.props.children);
324
+ }
325
+ if (Array.isArray(node)) {
326
+ for (let i = node.length - 1; i >= 0; i--) {
327
+ const label = findLabel(node[i]);
328
+ if (label) {
329
+ return label;
330
+ }
331
+ }
332
+ }
333
+ return void 0;
334
+ }
335
+ return findLabel(children);
336
+ }
337
+ function getTabbableCandidates(container) {
338
+ const nodes = [];
339
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
340
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
341
+ acceptNode: (node) => {
342
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
343
+ if (node.disabled || node.hidden || isHiddenInput)
344
+ return NodeFilter.FILTER_SKIP;
345
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
346
+ }
347
+ });
348
+ while (walker.nextNode())
349
+ nodes.push(walker.currentNode);
350
+ return nodes;
351
+ }
352
+ function focusFirst(candidates) {
353
+ const previouslyFocusedElement = document.activeElement;
354
+ return candidates.some((candidate) => {
355
+ if (candidate === previouslyFocusedElement)
356
+ return true;
357
+ candidate.focus();
358
+ return document.activeElement !== previouslyFocusedElement;
359
+ });
360
+ }
361
+ function removeFromTabOrder(candidates) {
362
+ candidates.forEach((candidate) => {
363
+ candidate.dataset.tabindex = candidate.getAttribute("tabindex") || "";
364
+ candidate.setAttribute("tabindex", "-1");
365
+ });
366
+ return () => {
367
+ candidates.forEach((candidate) => {
368
+ const prevTabIndex = candidate.dataset.tabindex;
369
+ candidate.setAttribute("tabindex", prevTabIndex);
370
+ });
371
+ };
372
+ }
373
+ const ITEM_DATA_ATTR = "data-teddy-top-selector-trigger";
374
+ const ARROW_KEYS = ["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"];
375
+ function makeContentId(args) {
376
+ return `teddy-navigation-menu-${args.baseId}-${args.value}-content`;
377
+ }
378
+ const NavigationMenu = Object.assign(Root, {
379
+ List,
380
+ Item,
381
+ Trigger,
382
+ Content,
383
+ Link,
384
+ Indicator,
385
+ Viewport,
386
+ Sub,
387
+ TopMenuList,
388
+ TopMenuItem,
389
+ TopMenuTrigger
390
+ });
8
391
  export {
9
- n as NavigationMenu
392
+ NavigationMenu
10
393
  };
@@ -1,4 +1,4 @@
1
- import { N as t } from "../../badge-Cnug5TzH.js";
1
+ import { Notification } from "./notification.js";
2
2
  export {
3
- t as Notification
3
+ Notification
4
4
  };
@@ -1,4 +1,8 @@
1
- import { Text as TextPrimitives, Heading as HeadingPrimitives, Card, Icon as IconPrimitives, Button as ButtonPrimitives } from '..';
1
+ import { Card } from '../card';
2
+ import { Heading as HeadingPrimitives } from '../heading';
3
+ import { Icon as IconPrimitives } from '../icon';
4
+ import { Button as ButtonPrimitives } from '../button';
5
+ import { Text as TextPrimitives } from '../text';
2
6
  import { default as React } from 'react';
3
7
 
4
8
  /** -------------------------------------------------------------------------------------------------
@@ -35,7 +39,7 @@ declare const Notification: React.ForwardRefExoticComponent<Omit<Omit<Omit<Omit<
35
39
  as?: undefined;
36
40
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & {
37
41
  asChild?: boolean | undefined;
38
- variant?: "purple-light" | "purple-dark" | "gray" | "white" | "beige" | undefined;
42
+ variant?: "beige" | "gray" | "white" | "purple-light" | "purple-dark" | undefined;
39
43
  bordered?: boolean | undefined;
40
44
  backgroundImageSrc?: string | undefined;
41
45
  } & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('../../utils/layout/flex').FlexChildren & import('../../utils/layout/grid').GridChildren & import('../../utils/layout/position').PositionProps & import('../../utils/layout/inset').InsetProps & import('../../utils/layout/margin').MarginProps & import('../../utils/layout/padding').PaddingProps & import('../../utils/layout/width').WidthProps & import('../../utils/layout/height').HeightProps & import('../../utils/layout/gap').GapProps & {
@@ -46,7 +50,7 @@ declare const Notification: React.ForwardRefExoticComponent<Omit<Omit<Omit<Omit<
46
50
  asChild?: false | undefined;
47
51
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & {
48
52
  asChild?: boolean | undefined;
49
- variant?: "purple-light" | "purple-dark" | "gray" | "white" | "beige" | undefined;
53
+ variant?: "beige" | "gray" | "white" | "purple-light" | "purple-dark" | undefined;
50
54
  bordered?: boolean | undefined;
51
55
  backgroundImageSrc?: string | undefined;
52
56
  } & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('../../utils/layout/flex').FlexChildren & import('../../utils/layout/grid').GridChildren & import('../../utils/layout/position').PositionProps & import('../../utils/layout/inset').InsetProps & import('../../utils/layout/margin').MarginProps & import('../../utils/layout/padding').PaddingProps & import('../../utils/layout/width').WidthProps & import('../../utils/layout/height').HeightProps & import('../../utils/layout/gap').GapProps & {
@@ -57,7 +61,7 @@ declare const Notification: React.ForwardRefExoticComponent<Omit<Omit<Omit<Omit<
57
61
  asChild?: false | undefined;
58
62
  } & React.RefAttributes<HTMLDivElement>, "ref"> & {
59
63
  asChild?: boolean | undefined;
60
- variant?: "purple-light" | "purple-dark" | "gray" | "white" | "beige" | undefined;
64
+ variant?: "beige" | "gray" | "white" | "purple-light" | "purple-dark" | undefined;
61
65
  bordered?: boolean | undefined;
62
66
  backgroundImageSrc?: string | undefined;
63
67
  } & React.RefAttributes<HTMLDivElement>, "ref">, "as" | "variant"> & {
@@ -71,9 +75,6 @@ declare const Notification: React.ForwardRefExoticComponent<Omit<Omit<Omit<Omit<
71
75
  Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
72
76
  Icon: React.ForwardRefExoticComponent<Partial<Omit<React.SVGProps<SVGSVGElement> & {
73
77
  name: "link" | "map" | "menu" | "search" | "summary" | "time" | "video" | "filter" | "image" | "stop" | "key" | "x" | "download" | "split" | "alert" | "radio" | "email" | "copy" | "sync" | "alarm-off" | "alarm-on" | "attachment" | "bookmark-filled" | "bookmark" | "copy-filled" | "dislike" | "edit" | "heart-filled" | "heart" | "invisible" | "like" | "lock-open" | "lock" | "login" | "logout" | "maximize" | "minimize" | "mute" | "password-invisible" | "password-visible" | "play-filled" | "play" | "remove-filled" | "remove" | "save" | "send" | "settings" | "share" | "shuffle" | "skip-back-10sec" | "skip-back-30sec" | "skip-forward-10sec" | "skip-forward-30sec" | "star-filled" | "star" | "switch-arrows" | "tv-next" | "tv-pause" | "tv-previous" | "tv-stop" | "upload" | "visible" | "volume" | "zoom-out" | "zoom" | "connected-building" | "home" | "hospital" | "industry" | "premises-datacenter" | "premises-large" | "premises-medium" | "premises-small" | "premises" | "store" | "address-book" | "b2b-customer" | "care" | "chat-robot" | "chat" | "child-1" | "child-2" | "conversation" | "customer-dialogue" | "dsl-hub" | "end-user" | "handshake" | "headphones" | "letter" | "mms" | "new-contact" | "new-group" | "news" | "parental-guide" | "people-hub" | "people" | "portal" | "signature" | "smiley-happy" | "smiley-sad" | "sms" | "support" | "user-admin" | "vcard" | "voicemail" | "battery" | "bluetooth" | "broadband" | "broken-phone" | "cast" | "cloud-connect" | "connected" | "core-router" | "daas-device" | "data-transfer" | "desktop" | "devices" | "esim-simcard" | "esim" | "face-id" | "fiber" | "fingerprint" | "fiveg" | "fourg" | "home-installation" | "industrial-iot" | "internet" | "it-service" | "laptop" | "mobile-broadband" | "network" | "phone-recycling" | "phone-ringing" | "phone" | "rack" | "refill-card" | "remote-control" | "repair" | "roaming" | "router" | "secure-device" | "sense-car" | "server" | "service-device" | "service-supervision" | "slow-wifi" | "smart-wifi" | "smartphone" | "smartwatch" | "tablet" | "trade-phone" | "tv" | "usb" | "voice-switch" | "wallplug" | "wireless-off" | "wireless-weak" | "wireless" | "world-alert" | "world-off" | "world-question" | "bar-chart" | "doc" | "document-doc" | "document-edit" | "document-pdf" | "document-ppt" | "excel" | "folder-copy" | "folder-new" | "folder" | "gif" | "graph" | "media-content" | "org-chart" | "pie-chart" | "print" | "register" | "report" | "simcard" | "spell-check" | "credit-card" | "euro" | "invoice" | "kontantkort" | "kr" | "late-payment" | "money-back-euro" | "money-back-kr" | "money-euro" | "money-kr" | "pay-monthly-euro" | "pay-monthly-kr" | "pay-once-euro" | "pay-once-kr" | "payment-success" | "savings" | "wallet" | "airplay" | "camera" | "entertainment" | "external" | "film" | "games" | "megaphone" | "microphone" | "music" | "player-settings" | "record" | "stream" | "trailer" | "video-conference" | "activity-level" | "add" | "ai-robot" | "bag" | "basketball" | "blood-pressure" | "bulb" | "business-continuity" | "business-intelligence" | "calendar" | "cart" | "close-circle" | "cloud" | "coffee" | "compass" | "construction" | "cookie" | "delivery" | "drone" | "education" | "efficiency" | "environment" | "facemask" | "flag" | "focus" | "food" | "fraud" | "getting-started" | "home-care" | "infinite" | "job-search" | "layers" | "measuring-health" | "moisture" | "offering" | "offshore" | "optimization" | "pebble" | "pet-dog" | "pin" | "plane" | "plus-minus" | "police" | "power-grid" | "present" | "press-button" | "price" | "pulse" | "recycle" | "reservation" | "reverse" | "route" | "ruler" | "satellite" | "secured-1" | "secured-2" | "security-camera" | "shopping" | "snowflake" | "speedometer" | "spyware" | "suitcase" | "sustainability" | "tag" | "temperature" | "thinking" | "train" | "transfer" | "undo" | "wavelength" | "weather" | "world" | "android" | "apple" | "bankid-norway" | "bankid" | "facebook" | "instagram" | "youtube" | "linkedin" | "snapchat" | "whatsapp" | "windows" | "alert-filled" | "check-circle-filled" | "check-circle" | "error-filled" | "error" | "help" | "info-filled" | "info" | "question-filled" | "question" | "warning" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-subdirectory" | "arrow-up" | "card-view" | "checkmark-bold" | "checkmark" | "chevron-down" | "chevron-left" | "chevron-right" | "chevron-up" | "close" | "grid-view" | "list-view" | "minus-bold" | "minus" | "more-horizontal" | "more-vertical" | "plus" | "services" | "sorter" | "table-view";
74
- /** -------------------------------------------------------------------------------------------------
75
- * Root
76
- * -----------------------------------------------------------------------------------------------*/
77
78
  size?: ("sm" | "md" | "lg" | "xl" | "font" | "xxs" | "xs") | undefined;
78
79
  children?: React.ReactNode;
79
80
  }, "ref">> & React.RefAttributes<SVGSVGElement>>;
@@ -1,27 +1,99 @@
1
- import "react/jsx-runtime";
2
- import "react";
3
- import "../../clsx-DB4S2d7J.js";
4
- import { N as y } from "../../badge-Cnug5TzH.js";
5
- import "../../index-FPIZOCcD.js";
6
- import "../../radio-group-B--zT3OL.js";
7
- import "../box/box.js";
8
- import "../flex/flex.js";
9
- import "../grid/grid.js";
10
- import "../../navigation-menu-DKuyW8zE.js";
11
- import "../link/link.js";
12
- import "../button/button.js";
13
- import "../field-error-text/field-error-text.js";
14
- import "../helper-text/helper-text.js";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import React__default from "react";
3
+ import clsx from "clsx";
4
+ import * as Collapsible from "@radix-ui/react-collapsible";
5
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
6
+ import { Text as Text$1 } from "../text/text.js";
7
+ import { Button } from "../button/button.js";
15
8
  import "../../assets/4bbd022cee9b0f06.svg";
16
- import "../icon/icon.js";
17
- import "../input/input.js";
18
- import "../label/label.js";
19
- import "../spinner/spinner.js";
20
- import "../text/text.js";
21
- import "../text-field/text-field.js";
22
- import "../heading/heading.js";
23
- import "../visually-hidden/visually-hidden.js";
24
- import "../text-spacing/text-spacing.js";
9
+ import { Icon as Icon$1 } from "../icon/icon.js";
10
+ import { Heading as Heading$1 } from "../heading/heading.js";
11
+ import { Card } from "../card/card.js";
12
+ const styles = {
13
+ "teddy-notification": "_teddy-notification_q80ka_3",
14
+ "teddy-notification__dismiss": "_teddy-notification__dismiss_q80ka_14",
15
+ "teddy-notification--success": "_teddy-notification--success_q80ka_18",
16
+ "teddy-notification--warning": "_teddy-notification--warning_q80ka_23",
17
+ "teddy-notification--error": "_teddy-notification--error_q80ka_28",
18
+ "teddy-notification--information": "_teddy-notification--information_q80ka_33",
19
+ "teddy-notification__heading": "_teddy-notification__heading_q80ka_38",
20
+ "teddy-notification__icon": "_teddy-notification__icon_q80ka_43"
21
+ };
22
+ const rootClassName = "teddy-notification";
23
+ const NotificationContext = React__default.createContext(void 0);
24
+ const Root = React__default.forwardRef(
25
+ ({ className, open: openProp, defaultOpen, onOpenChange, variant, ...props }, forwardRef) => {
26
+ const classes = clsx([styles[`${rootClassName}`]], styles[`${rootClassName}--${variant}`], className);
27
+ const [open = true, setOpen] = useControllableState({
28
+ prop: openProp,
29
+ defaultProp: defaultOpen,
30
+ onChange: onOpenChange
31
+ });
32
+ return /* @__PURE__ */ jsx(NotificationContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsx(Collapsible.Root, { open, onOpenChange: setOpen, asChild: true, children: /* @__PURE__ */ jsx(Collapsible.Content, { asChild: true, children: /* @__PURE__ */ jsx(Card, { variant: "white", as: void 0, bordered: true, ...props, ref: forwardRef, className: classes }) }) }) });
33
+ }
34
+ );
35
+ Root.displayName = "Notification";
36
+ function getVariantIcon(variant) {
37
+ switch (variant) {
38
+ case "success":
39
+ return "check-circle-filled";
40
+ case "error":
41
+ return "error-filled";
42
+ case "warning":
43
+ return "alert-filled";
44
+ case "information":
45
+ return "info-filled";
46
+ }
47
+ }
48
+ const Icon = React__default.forwardRef(
49
+ ({ className, ...props }, forwardRef) => {
50
+ const classes = clsx([styles[`${rootClassName}__icon`]], className);
51
+ const context = React__default.useContext(NotificationContext);
52
+ const name = props.name || getVariantIcon(context == null ? void 0 : context.variant);
53
+ if (!name)
54
+ return null;
55
+ return /* @__PURE__ */ jsx(Icon$1, { size: "md", ...props, name, ref: forwardRef, className: classes });
56
+ }
57
+ );
58
+ Icon.displayName = "Notification.Icon";
59
+ const Heading = React__default.forwardRef(
60
+ ({ className, ...props }, forwardRef) => {
61
+ const classes = clsx([styles[`${rootClassName}__heading`]], className);
62
+ return /* @__PURE__ */ jsx(Heading$1, { ...props, variant: "subsection-100", asChild: false, ref: forwardRef, className: classes });
63
+ }
64
+ );
65
+ Heading.displayName = "Notification.Heading";
66
+ const Text = React__default.forwardRef(
67
+ ({ className, ...props }, forwardRef) => {
68
+ const classes = clsx([styles[`${rootClassName}__text`]], className);
69
+ return /* @__PURE__ */ jsx(Text$1, { ...props, ref: forwardRef, className: classes });
70
+ }
71
+ );
72
+ Text.displayName = "Notification.Text";
73
+ const Dismiss = React__default.forwardRef(
74
+ ({ className, children, ...props }, forwardRef) => {
75
+ const classes = clsx([styles[`${rootClassName}__dismiss`]], className);
76
+ return /* @__PURE__ */ jsx(Collapsible.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
77
+ Button,
78
+ {
79
+ iconOnly: true,
80
+ "aria-label": "Lukk",
81
+ variant: "tertiary-purple",
82
+ ...props,
83
+ ref: forwardRef,
84
+ className: classes,
85
+ children: children || /* @__PURE__ */ jsx(Icon$1, { name: "close" })
86
+ }
87
+ ) });
88
+ }
89
+ );
90
+ Dismiss.displayName = "Notification.Dismiss";
91
+ const Notification = Object.assign(Root, {
92
+ Text,
93
+ Heading,
94
+ Icon,
95
+ Dismiss
96
+ });
25
97
  export {
26
- y as Notification
98
+ Notification
27
99
  };
@@ -1,4 +1,4 @@
1
- import { R as a } from "../../radio-group-B--zT3OL.js";
1
+ import { RadioGroup } from "./radio-group.js";
2
2
  export {
3
- a as RadioGroup
3
+ RadioGroup
4
4
  };