@bonniernews/dn-design-system-web 32.7.35 → 32.7.37

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 (43) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/assets/types/teaser-props.ts +1 -1
  3. package/components/group-header/README.md +1 -1
  4. package/components/teaser-card/README.md +1 -1
  5. package/components/teaser-large/README.md +1 -1
  6. package/components/teaser-list-swipe/README.md +64 -47
  7. package/components/teaser-swipe-card/README.md +42 -40
  8. package/components/teaser-tipsa/README.md +1 -1
  9. package/components/text-input/README.md +1 -1
  10. package/package.json +1 -1
  11. package/preact/assets/types/teaser-props.d.ts +1 -1
  12. package/preact/components/factbox/factbox.d.ts +29 -0
  13. package/preact/components/factbox/factbox.js +505 -0
  14. package/preact/components/factbox/factbox.js.map +7 -0
  15. package/preact/components/group-header/group-header.d.ts +2 -1
  16. package/preact/components/group-header/group-header.js +1 -1
  17. package/preact/components/group-header/group-header.js.map +2 -2
  18. package/preact/components/link-box/link-box.js +1 -1
  19. package/preact/components/link-box/link-box.js.map +2 -2
  20. package/preact/components/teaser-card/teaser-card.d.ts +2 -2
  21. package/preact/components/teaser-card/teaser-card.js.map +2 -2
  22. package/preact/components/teaser-counter/teaser-counter.js.map +2 -2
  23. package/preact/components/teaser-large/teaser-large.js +1 -1
  24. package/preact/components/teaser-large/teaser-large.js.map +2 -2
  25. package/preact/components/teaser-list-swipe/teaser-list-swipe.d.ts +38 -0
  26. package/preact/components/teaser-list-swipe/teaser-list-swipe.js +447 -0
  27. package/preact/components/teaser-list-swipe/teaser-list-swipe.js.map +7 -0
  28. package/preact/components/teaser-list-vertical/teaser-list-vertical.js +1 -1
  29. package/preact/components/teaser-list-vertical/teaser-list-vertical.js.map +2 -2
  30. package/preact/components/teaser-longlife/teaser-longlife.js.map +2 -2
  31. package/preact/components/teaser-native/teaser-native.js.map +2 -2
  32. package/preact/components/teaser-onsite/teaser-onsite.js.map +2 -2
  33. package/preact/components/teaser-right-now/teaser-right-now.js.map +2 -2
  34. package/preact/components/teaser-slideshow/teaser-slideshow.js.map +2 -2
  35. package/preact/components/teaser-split/teaser-split.js.map +2 -2
  36. package/preact/components/teaser-swipe-card/teaser-swipe-card.d.ts +13 -0
  37. package/preact/components/teaser-swipe-card/teaser-swipe-card.js +95 -0
  38. package/preact/components/teaser-swipe-card/teaser-swipe-card.js.map +7 -0
  39. package/preact/components/teaser-tipsa/teaser-tipsa.js.map +2 -2
  40. package/preact/foundations/icons/grade-icon.d.ts +9 -0
  41. package/components/factbox/README-UXD.md +0 -0
  42. package/components/teaser-list-swipe/README-UXD.md +0 -0
  43. /package/components/factbox/{README.md → README-NJK.md} +0 -0
@@ -0,0 +1,447 @@
1
+ // ../src/helpers/formatClassString.ts
2
+ var formatClassString = (classesArray) => {
3
+ return classesArray.filter((x) => !!x).join(" ");
4
+ };
5
+
6
+ // ../src/foundations/icons/sprite.svg
7
+ import { h } from "preact";
8
+ import { jsx, jsxs } from "preact/jsx-runtime";
9
+
10
+ // ../src/components/icon-sprite/icon-sprite.tsx
11
+ import { jsx as jsx2 } from "preact/jsx-runtime";
12
+ var IconUse = ({ iconName, classNames, attributes }) => {
13
+ const componentClassName = "ds-icon";
14
+ const classes = formatClassString([
15
+ componentClassName,
16
+ `${componentClassName}--sprite`,
17
+ `${componentClassName}--${iconName}`,
18
+ classNames
19
+ ]);
20
+ return /* @__PURE__ */ jsx2("i", { className: classes, ...attributes, children: /* @__PURE__ */ jsx2("svg", { children: /* @__PURE__ */ jsx2("use", { xlinkHref: `#ds-${iconName}` }) }) });
21
+ };
22
+
23
+ // ../src/components/spinner/spinner.tsx
24
+ import { jsx as jsx3 } from "preact/jsx-runtime";
25
+ var Spinner = ({ variant = "primary", size = "large", forcePx, classNames, attributes }) => {
26
+ const componentClassName = "ds-spinner";
27
+ const classes = formatClassString([
28
+ `${componentClassName}`,
29
+ `${componentClassName}--${variant}`,
30
+ `${componentClassName}--${size}`,
31
+ forcePx && "ds-force-px",
32
+ classNames
33
+ ]);
34
+ return /* @__PURE__ */ jsx3("span", { className: classes, ...attributes, children: /* @__PURE__ */ jsx3("span", { className: `${componentClassName}__inner` }) });
35
+ };
36
+
37
+ // ../src/components/button/button-base.tsx
38
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "preact/jsx-runtime";
39
+ var InnerButton = ({ text, isIconButton = false, attributes, icon, loadingHtml }) => {
40
+ let optionalHtml;
41
+ if (!isIconButton && attributes["aria-label"]) {
42
+ optionalHtml = /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: text });
43
+ } else if (!isIconButton) {
44
+ optionalHtml = /* @__PURE__ */ jsx4("span", { children: text });
45
+ }
46
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
47
+ optionalHtml,
48
+ icon,
49
+ loadingHtml
50
+ ] });
51
+ };
52
+ var ToggleWrapper = ({
53
+ selected = false,
54
+ disabled = false,
55
+ attributes,
56
+ classes,
57
+ onChild,
58
+ offChild,
59
+ loadingHtml
60
+ }) => {
61
+ return /* @__PURE__ */ jsxs2("button", { type: "button", role: "switch", "aria-checked": selected, className: classes, ...attributes, disabled, children: [
62
+ /* @__PURE__ */ jsx4("span", { className: "ds-btn__off", "aria-hidden": "true", children: onChild }),
63
+ /* @__PURE__ */ jsx4("span", { className: "ds-btn__on", "aria-hidden": "true", children: offChild }),
64
+ loadingHtml
65
+ ] });
66
+ };
67
+ var ButtonBase = ({
68
+ text,
69
+ disabled = false,
70
+ variant = "primary",
71
+ size = "md",
72
+ fullWidth = false,
73
+ mobileFullWidth = false,
74
+ iconPosition = "none",
75
+ iconName,
76
+ loading = false,
77
+ type = "button",
78
+ href,
79
+ classNames,
80
+ attributes = {},
81
+ forcePx = false,
82
+ isIconButton = false,
83
+ selected = false,
84
+ isToggle = false,
85
+ selectedIconName,
86
+ selectedText
87
+ }) => {
88
+ if (isIconButton && text && !attributes["aria-label"]) {
89
+ attributes["aria-label"] = text;
90
+ } else if (isToggle && text && selectedText && !attributes["aria-label"]) {
91
+ attributes["aria-label"] = selected ? selectedText : text;
92
+ }
93
+ let spinnerVariant = "secondary";
94
+ if (variant === "staticWhite" || variant === "transparent") {
95
+ spinnerVariant = "staticBlack";
96
+ } else if (variant === "secondaryFilled" || variant === "secondaryOutline") {
97
+ spinnerVariant = "primary";
98
+ }
99
+ const loadingHtml = /* @__PURE__ */ jsx4(Spinner, { ...{ size: "small", variant: spinnerVariant, forcePx, attributes: { "aria-hidden": "true" } } });
100
+ let icon;
101
+ if (iconName && (iconPosition != "none" || isIconButton == true)) {
102
+ icon = /* @__PURE__ */ jsx4(IconUse, { ...{ iconName, attributes: { "aria-hidden": "true" } } });
103
+ }
104
+ const classNamePrefix = "ds-btn--";
105
+ const classes = formatClassString([
106
+ "ds-btn",
107
+ `${classNamePrefix}${variant}`,
108
+ `${classNamePrefix}${size}`,
109
+ isToggle && selected && `${classNamePrefix}selected`,
110
+ fullWidth && `${classNamePrefix}full-width`,
111
+ mobileFullWidth && `${classNamePrefix}mobile-full-width`,
112
+ icon && !isIconButton && `${classNamePrefix}icon-${iconPosition}`,
113
+ isIconButton && `${classNamePrefix}icon-only`,
114
+ isToggle && `${classNamePrefix}toggle`,
115
+ loading && "ds-loading",
116
+ forcePx && "ds-force-px",
117
+ classNames
118
+ ]);
119
+ let buttonToRender;
120
+ if (isToggle) {
121
+ let onChild, offChild;
122
+ if (isIconButton && iconName && selectedIconName) {
123
+ onChild = /* @__PURE__ */ jsx4(IconUse, { iconName });
124
+ offChild = /* @__PURE__ */ jsx4(IconUse, { iconName: selectedIconName });
125
+ } else {
126
+ onChild = /* @__PURE__ */ jsx4("span", { children: text });
127
+ offChild = /* @__PURE__ */ jsxs2(Fragment, { children: [
128
+ /* @__PURE__ */ jsx4(IconUse, { iconName: "check" }),
129
+ /* @__PURE__ */ jsx4("span", { children: selectedText })
130
+ ] });
131
+ }
132
+ buttonToRender = /* @__PURE__ */ jsx4(ToggleWrapper, { ...{ selected, classes, attributes, disabled, onChild, offChild, loadingHtml } });
133
+ } else {
134
+ const buttonParams = { isIconButton, text, icon, loadingHtml, attributes };
135
+ if (href) {
136
+ const params = { ...buttonParams, loadingHtml: null };
137
+ buttonToRender = /* @__PURE__ */ jsx4("a", { href, className: classes, ...attributes, children: /* @__PURE__ */ jsx4(InnerButton, { ...params }) });
138
+ } else {
139
+ buttonToRender = /* @__PURE__ */ jsx4("button", { type, className: classes, ...attributes, disabled, children: /* @__PURE__ */ jsx4(InnerButton, { ...buttonParams }) });
140
+ }
141
+ }
142
+ return /* @__PURE__ */ jsx4(Fragment, { children: buttonToRender });
143
+ };
144
+
145
+ // ../src/components/button/button.tsx
146
+ import { jsx as jsx5 } from "preact/jsx-runtime";
147
+ var Button = ({
148
+ text,
149
+ disabled = false,
150
+ variant = "primary",
151
+ size = "md",
152
+ fullWidth = false,
153
+ mobileFullWidth = false,
154
+ iconPosition = "none",
155
+ iconName,
156
+ loading = false,
157
+ type = "button",
158
+ href,
159
+ isIconButton = false,
160
+ classNames,
161
+ attributes,
162
+ forcePx = false
163
+ }) => {
164
+ return /* @__PURE__ */ jsx5(ButtonBase, { ...{
165
+ text,
166
+ disabled,
167
+ variant,
168
+ size,
169
+ fullWidth,
170
+ mobileFullWidth,
171
+ iconPosition,
172
+ iconName,
173
+ loading,
174
+ type,
175
+ href,
176
+ isIconButton,
177
+ classNames,
178
+ attributes,
179
+ forcePx
180
+ } });
181
+ };
182
+ var button_default = Button;
183
+
184
+ // ../src/components/teaser-card/teaser-card.tsx
185
+ import { jsx as jsx6 } from "preact/jsx-runtime";
186
+ var TeaserCard = ({ areaType, targetLink, theme = "nyheter", classNames, attributes, children }) => {
187
+ const componentClassName = "ds-teaser";
188
+ const classes = formatClassString([
189
+ componentClassName,
190
+ areaType && `${componentClassName}--${areaType}`,
191
+ areaType == "bauta" && "ds-dark",
192
+ `ds-theme--${theme}`,
193
+ classNames
194
+ ]);
195
+ if (targetLink) {
196
+ return /* @__PURE__ */ jsx6("a", { className: classes, href: targetLink, ...attributes, children });
197
+ }
198
+ return /* @__PURE__ */ jsx6("div", { className: classes, ...attributes, children });
199
+ };
200
+
201
+ // ../src/components/button-toggle/button-toggle.tsx
202
+ import { jsx as jsx7 } from "preact/jsx-runtime";
203
+ var ButtonToggle = ({
204
+ selected = false,
205
+ text,
206
+ selectedText,
207
+ disabled = false,
208
+ variant = "primary",
209
+ size = "md",
210
+ fullWidth = false,
211
+ mobileFullWidth = false,
212
+ isIconButton = false,
213
+ iconName,
214
+ selectedIconName,
215
+ loading = false,
216
+ attributes = {},
217
+ classNames,
218
+ forcePx = false
219
+ }) => {
220
+ return /* @__PURE__ */ jsx7(
221
+ ButtonBase,
222
+ {
223
+ ...{
224
+ selected,
225
+ text,
226
+ disabled,
227
+ variant,
228
+ size,
229
+ fullWidth,
230
+ mobileFullWidth,
231
+ isIconButton,
232
+ iconName,
233
+ selectedIconName,
234
+ loading,
235
+ classNames,
236
+ attributes,
237
+ forcePx,
238
+ isToggle: true,
239
+ selectedText,
240
+ type: "button"
241
+ }
242
+ }
243
+ );
244
+ };
245
+ var button_toggle_default = ButtonToggle;
246
+
247
+ // ../src/components/group-header/group-header.tsx
248
+ import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs3 } from "preact/jsx-runtime";
249
+ function GroupHeader({
250
+ title,
251
+ type = "icon",
252
+ variant,
253
+ media,
254
+ href,
255
+ linkText,
256
+ showBottomBorder = false,
257
+ toggleText,
258
+ toggleSelectedText,
259
+ toggleSelected = false,
260
+ toggleLoading = false,
261
+ toggleClassNames,
262
+ toggleAttributes = {},
263
+ classNames,
264
+ attributes = {}
265
+ }) {
266
+ const componentClassName = "ds-group-header";
267
+ const classes = formatClassString([
268
+ componentClassName,
269
+ type && `${componentClassName}--${type}`,
270
+ variant && `${componentClassName}--${variant}`,
271
+ showBottomBorder && `${componentClassName}--bottom-border`,
272
+ variant === "bauta" && "ds-dark",
273
+ classNames
274
+ ]);
275
+ const groupHeaderInner = /* @__PURE__ */ jsxs3(Fragment2, { children: [
276
+ media && /* @__PURE__ */ jsx8("div", { className: `${componentClassName}__image`, children: media }),
277
+ /* @__PURE__ */ jsx8("h2", { className: `${componentClassName}__title`, children: title }),
278
+ type === "link" && linkText && href && /* @__PURE__ */ jsx8("span", { className: `${componentClassName}__right-link`, children: linkText }),
279
+ type === "icon" && href && /* @__PURE__ */ jsx8(IconUse, { iconName: "arrow_forward", classNames: `${componentClassName}__icon` }),
280
+ type === "arrows" && href && linkText && /* @__PURE__ */ jsx8("span", { className: `${componentClassName}__right-link hidden-desktop`, children: linkText }),
281
+ type === "arrows" && href && !linkText && /* @__PURE__ */ jsx8(IconUse, { iconName: "arrow_forward", classNames: `${componentClassName}__icon hidden-desktop` })
282
+ ] });
283
+ const buttonVariant = variant ? "staticWhite" : "secondaryOutline";
284
+ return /* @__PURE__ */ jsxs3("div", { className: classes, ...attributes, children: [
285
+ href && /* @__PURE__ */ jsx8("a", { className: `${componentClassName}__href`, href, children: groupHeaderInner }),
286
+ !href && groupHeaderInner,
287
+ type === "toggle" && !variant && /* @__PURE__ */ jsx8(
288
+ button_toggle_default,
289
+ {
290
+ isIconButton: false,
291
+ variant: "primary",
292
+ size: "sm",
293
+ text: toggleText,
294
+ selectedText: toggleSelectedText || toggleText || "",
295
+ selected: toggleSelected,
296
+ loading: toggleLoading,
297
+ classNames: toggleClassNames,
298
+ attributes: toggleAttributes
299
+ }
300
+ ),
301
+ type === "arrows" && /* @__PURE__ */ jsxs3("div", { className: `${componentClassName}__arrows hidden-mobile hidden-tablet`, children: [
302
+ /* @__PURE__ */ jsx8(
303
+ button_default,
304
+ {
305
+ variant: buttonVariant,
306
+ size: "sm",
307
+ isIconButton: true,
308
+ iconName: "arrow_back",
309
+ classNames: `${componentClassName}__arrow ${componentClassName}__arrow--left`,
310
+ attributes: { "aria-label": "F\xF6reg\xE5ende" }
311
+ }
312
+ ),
313
+ /* @__PURE__ */ jsx8(
314
+ button_default,
315
+ {
316
+ variant: buttonVariant,
317
+ size: "sm",
318
+ isIconButton: true,
319
+ iconName: "arrow_forward",
320
+ classNames: `${componentClassName}__arrow ${componentClassName}__arrow--right`,
321
+ attributes: { "aria-label": "N\xE4sta" }
322
+ }
323
+ )
324
+ ] })
325
+ ] });
326
+ }
327
+
328
+ // ../src/components/teaser-dot/teaser-dot.tsx
329
+ import { jsx as jsx9 } from "preact/jsx-runtime";
330
+
331
+ // ../src/helpers/teaser.tsx
332
+ import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs4 } from "preact/jsx-runtime";
333
+ var Title = ({ title, highlight }) => {
334
+ return title ? /* @__PURE__ */ jsxs4("h2", { className: "ds-teaser__title", children: [
335
+ highlight && /* @__PURE__ */ jsxs4("span", { className: "ds-teaser__highlight", children: [
336
+ highlight,
337
+ " ",
338
+ " "
339
+ ] }),
340
+ title
341
+ ] }) : null;
342
+ };
343
+ var Vignette = ({ vignette, variant }) => {
344
+ return vignette ? /* @__PURE__ */ jsxs4("div", { className: "ds-teaser__vignette", children: [
345
+ variant === "podcast" && /* @__PURE__ */ jsx10(IconUse, { iconName: "headphones" }),
346
+ vignette
347
+ ] }) : null;
348
+ };
349
+
350
+ // ../src/components/teaser-swipe-card/teaser-swipe-card.tsx
351
+ import { jsx as jsx11, jsxs as jsxs5 } from "preact/jsx-runtime";
352
+ var TeaserSwipeCard = ({
353
+ title,
354
+ targetLink,
355
+ highlight,
356
+ theme,
357
+ time,
358
+ media,
359
+ vignette,
360
+ variant,
361
+ classNames,
362
+ attributes
363
+ }) => {
364
+ const componentClassName = "ds-teaser-swipe-card";
365
+ const classes = formatClassString([
366
+ "ds-teaser",
367
+ componentClassName,
368
+ variant && variant !== "default" && `${componentClassName}--${variant}`,
369
+ classNames
370
+ ]);
371
+ return /* @__PURE__ */ jsxs5(TeaserCard, { theme, targetLink, classNames: classes, attributes, children: [
372
+ media && variant !== "direkt" && /* @__PURE__ */ jsx11("div", { className: "ds-teaser-image", children: media }),
373
+ /* @__PURE__ */ jsxs5("div", { className: "ds-teaser__text", children: [
374
+ variant === "direkt" ? /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__time`, children: time }) : /* @__PURE__ */ jsx11(Vignette, { vignette, variant }),
375
+ /* @__PURE__ */ jsx11(Title, { title, highlight }),
376
+ variant !== "direkt" && /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__time`, children: time })
377
+ ] })
378
+ ] });
379
+ };
380
+
381
+ // ../src/components/teaser-list-swipe/teaser-list-swipe.tsx
382
+ import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs6 } from "preact/jsx-runtime";
383
+ var TeaserListSwipe = ({
384
+ title,
385
+ titleHref,
386
+ areaType,
387
+ arrowPosition = "header",
388
+ theme,
389
+ teasers = [],
390
+ groupHeaderType,
391
+ groupHeaderToggleText,
392
+ groupHeaderToggleSelectedText,
393
+ groupHeaderToggleSelected = false,
394
+ groupHeaderToggleClassNames,
395
+ groupHeaderToggleAttributes = {},
396
+ classNames,
397
+ attributes = {}
398
+ }) => {
399
+ const componentClassName = "ds-teaser";
400
+ const classes = formatClassString(["ds-teaser--list-swipe", classNames]);
401
+ const headerType = groupHeaderType || arrowPosition === "header" && "arrows" || "link";
402
+ return /* @__PURE__ */ jsxs6(TeaserCard, { areaType, theme, classNames: classes, attributes, children: [
403
+ /* @__PURE__ */ jsx12(
404
+ GroupHeader,
405
+ {
406
+ title,
407
+ href: titleHref,
408
+ type: headerType,
409
+ linkText: "Visa alla",
410
+ toggleText: groupHeaderToggleText,
411
+ toggleSelectedText: groupHeaderToggleSelectedText,
412
+ toggleSelected: groupHeaderToggleSelected,
413
+ toggleClassNames: groupHeaderToggleClassNames,
414
+ toggleAttributes: groupHeaderToggleAttributes
415
+ }
416
+ ),
417
+ /* @__PURE__ */ jsx12("div", { className: `${componentClassName}__carousel`, children: teasers.map((teaser, index) => /* @__PURE__ */ jsx12(TeaserSwipeCard, { ...teaser }, index)) }),
418
+ arrowPosition === "floating" && /* @__PURE__ */ jsxs6(Fragment4, { children: [
419
+ /* @__PURE__ */ jsx12(
420
+ Button,
421
+ {
422
+ iconName: "arrow_back",
423
+ variant: "staticWhite",
424
+ size: "sm",
425
+ isIconButton: true,
426
+ attributes: { "aria-label": "F\xF6reg\xE5ende" },
427
+ classNames: `${componentClassName}__swipe-arrow ${componentClassName}__swipe-arrow--back hidden-mobile hidden-tablet`
428
+ }
429
+ ),
430
+ /* @__PURE__ */ jsx12(
431
+ Button,
432
+ {
433
+ iconName: "arrow_forward",
434
+ variant: "staticWhite",
435
+ size: "sm",
436
+ isIconButton: true,
437
+ attributes: { "aria-label": "N\xE4sta" },
438
+ classNames: `${componentClassName}__swipe-arrow ${componentClassName}__swipe-arrow--forward hidden-mobile hidden-tablet`
439
+ }
440
+ )
441
+ ] })
442
+ ] });
443
+ };
444
+ export {
445
+ TeaserListSwipe
446
+ };
447
+ //# sourceMappingURL=teaser-list-swipe.js.map