@bonniernews/dn-design-system-web 22.2.2 → 22.3.0
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/CHANGELOG.md +14 -0
- package/components/button/README.md +3 -3
- package/components/button-toggle/README.md +1 -1
- package/components/checkbox/README-NJK.md +43 -0
- package/components/checkbox/README.md +26 -43
- package/components/divider/README.md +1 -1
- package/components/footer/footer.scss +1 -1
- package/components/icon-button/README.md +1 -1
- package/components/icon-button-toggle/README.md +1 -1
- package/components/list-item/list-item-types.ts +113 -0
- package/components/list-item/list-item.js +1 -1
- package/components/radio-button/README-NJK.md +49 -0
- package/components/radio-button/README.md +35 -49
- package/components/switch/README-NJK.md +42 -0
- package/components/switch/README.md +28 -42
- package/package.json +1 -1
- package/preact/assets/form-field/form-field.d.ts +12 -0
- package/preact/components/button/button-types.d.ts +73 -0
- package/preact/components/checkbox/checkbox.d.ts +23 -0
- package/preact/components/checkbox/checkbox.js +94 -0
- package/preact/components/checkbox/checkbox.js.map +7 -0
- package/preact/components/list-item/list-item-types.d.ts +82 -0
- package/preact/components/list-item/list-item.d.ts +2 -0
- package/preact/components/list-item/list-item.js +573 -0
- package/preact/components/list-item/list-item.js.map +7 -0
- package/preact/components/radio-button/radio-button.d.ts +30 -0
- package/preact/components/radio-button/radio-button.js +94 -0
- package/preact/components/radio-button/radio-button.js.map +7 -0
- package/preact/components/switch/switch.d.ts +26 -0
- package/preact/components/switch/switch.js +68 -0
- package/preact/components/switch/switch.js.map +7 -0
- package/preact/components/teaser-card/teaser-card.d.ts +2 -1
- package/preact/components/teaser-card/teaser-card.js.map +2 -2
- package/preact/components/teaser-onsite/teaser-onsite.js.map +2 -2
- package/tsconfig.json +2 -1
- /package/components/list-item/{README.md → README-NJK.md} +0 -0
|
@@ -0,0 +1,573 @@
|
|
|
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/assets/form-field/form-field.tsx
|
|
24
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
25
|
+
var FormField = ({ errorMessage, wrapperClasses, helpHtml, helpText, type, children }) => {
|
|
26
|
+
const classes = formatClassString([
|
|
27
|
+
"ds-form-field",
|
|
28
|
+
wrapperClasses,
|
|
29
|
+
errorMessage && `ds-form-field__error`,
|
|
30
|
+
type === "hidden" && "hidden"
|
|
31
|
+
]);
|
|
32
|
+
const showHelp = helpHtml || helpText;
|
|
33
|
+
return /* @__PURE__ */ jsxs2("div", { className: classes, children: [
|
|
34
|
+
children,
|
|
35
|
+
errorMessage && /* @__PURE__ */ jsxs2("div", { className: "ds-form-field__error-message js-field-error", children: [
|
|
36
|
+
/* @__PURE__ */ jsx3(IconUse, { iconName: "info-filled" }),
|
|
37
|
+
/* @__PURE__ */ jsx3("span", { children: errorMessage })
|
|
38
|
+
] }),
|
|
39
|
+
showHelp && /* @__PURE__ */ jsx3("p", { className: "ds-form-field__help-text", children: helpHtml ? helpHtml : helpText })
|
|
40
|
+
] });
|
|
41
|
+
};
|
|
42
|
+
var form_field_default = FormField;
|
|
43
|
+
|
|
44
|
+
// ../src/components/checkbox/checkbox.tsx
|
|
45
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "preact/jsx-runtime";
|
|
46
|
+
var Checkbox = ({
|
|
47
|
+
error,
|
|
48
|
+
errorMessage,
|
|
49
|
+
label,
|
|
50
|
+
stripLabel,
|
|
51
|
+
name = "ds-checkbox",
|
|
52
|
+
validation,
|
|
53
|
+
checked,
|
|
54
|
+
required,
|
|
55
|
+
disabled,
|
|
56
|
+
forcePx,
|
|
57
|
+
classNames,
|
|
58
|
+
attributes
|
|
59
|
+
}) => {
|
|
60
|
+
const componentClassName = "ds-checkbox";
|
|
61
|
+
const wrapperClasses = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
|
|
62
|
+
return /* @__PURE__ */ jsxs3(form_field_default, { error, errorMessage: label && errorMessage, wrapperClasses, children: [
|
|
63
|
+
/* @__PURE__ */ jsx4(
|
|
64
|
+
"input",
|
|
65
|
+
{
|
|
66
|
+
type: "checkbox",
|
|
67
|
+
id: name,
|
|
68
|
+
name,
|
|
69
|
+
className: `${componentClassName}__input js-field-error`,
|
|
70
|
+
"data-validation": validation,
|
|
71
|
+
...attributes,
|
|
72
|
+
defaultChecked: checked,
|
|
73
|
+
disabled,
|
|
74
|
+
required
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
stripLabel ? /* @__PURE__ */ jsx4("div", { className: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx4(CheckboxIcons, { componentClassName }) }) : /* @__PURE__ */ jsxs3("label", { className: `${componentClassName}__inner`, htmlFor: name, children: [
|
|
78
|
+
/* @__PURE__ */ jsx4(CheckboxIcons, { componentClassName }),
|
|
79
|
+
label && /* @__PURE__ */ jsx4("span", { className: `${componentClassName}__text`, children: label })
|
|
80
|
+
] })
|
|
81
|
+
] });
|
|
82
|
+
};
|
|
83
|
+
var CheckboxIcons = ({ componentClassName }) => {
|
|
84
|
+
return /* @__PURE__ */ jsxs3("span", { className: `${componentClassName}__icon`, children: [
|
|
85
|
+
/* @__PURE__ */ jsx4(IconUse, { iconName: "check_box_outline_blank" }),
|
|
86
|
+
/* @__PURE__ */ jsx4(IconUse, { iconName: "check_box-filled" })
|
|
87
|
+
] });
|
|
88
|
+
};
|
|
89
|
+
var checkbox_default = Checkbox;
|
|
90
|
+
|
|
91
|
+
// ../src/components/radio-button/radio-button.tsx
|
|
92
|
+
import { Fragment } from "preact";
|
|
93
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "preact/jsx-runtime";
|
|
94
|
+
var RadioButton = ({
|
|
95
|
+
buttons,
|
|
96
|
+
error,
|
|
97
|
+
name,
|
|
98
|
+
errorMessage,
|
|
99
|
+
required,
|
|
100
|
+
stripLabel,
|
|
101
|
+
disabled,
|
|
102
|
+
forcePx,
|
|
103
|
+
classNames
|
|
104
|
+
}) => {
|
|
105
|
+
const componentClassName = "ds-radio-btn";
|
|
106
|
+
const wrapperClasses = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
|
|
107
|
+
return /* @__PURE__ */ jsx5(form_field_default, { error, errorMessage, wrapperClasses, children: buttons?.map((button) => {
|
|
108
|
+
const { id, selected, value, label, attributes } = button;
|
|
109
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
110
|
+
/* @__PURE__ */ jsx5(
|
|
111
|
+
"input",
|
|
112
|
+
{
|
|
113
|
+
type: "radio",
|
|
114
|
+
id,
|
|
115
|
+
name,
|
|
116
|
+
defaultChecked: selected,
|
|
117
|
+
disabled,
|
|
118
|
+
required,
|
|
119
|
+
value,
|
|
120
|
+
...attributes
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
stripLabel ? /* @__PURE__ */ jsx5("div", { className: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx5(RadioButtonIcons, { componentClassName }) }) : /* @__PURE__ */ jsxs4("label", { className: `${componentClassName}__inner`, htmlFor: id, children: [
|
|
124
|
+
/* @__PURE__ */ jsx5(RadioButtonIcons, { componentClassName }),
|
|
125
|
+
label && /* @__PURE__ */ jsx5("span", { className: `${componentClassName}__text`, children: label })
|
|
126
|
+
] })
|
|
127
|
+
] }, id);
|
|
128
|
+
}) });
|
|
129
|
+
};
|
|
130
|
+
var RadioButtonIcons = ({ componentClassName }) => {
|
|
131
|
+
return /* @__PURE__ */ jsxs4("span", { className: `${componentClassName}__icon`, children: [
|
|
132
|
+
/* @__PURE__ */ jsx5(IconUse, { iconName: "radio_button_unchecked" }),
|
|
133
|
+
/* @__PURE__ */ jsx5(IconUse, { iconName: "radio_button_checked" })
|
|
134
|
+
] });
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// ../src/components/switch/switch.tsx
|
|
138
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "preact/jsx-runtime";
|
|
139
|
+
var Switch = ({
|
|
140
|
+
name = "ds-switch",
|
|
141
|
+
checked,
|
|
142
|
+
showMeta = false,
|
|
143
|
+
metaOn = "P\xE5",
|
|
144
|
+
metaOff = "Av",
|
|
145
|
+
disabled,
|
|
146
|
+
stripLabel,
|
|
147
|
+
forcePx,
|
|
148
|
+
classNames,
|
|
149
|
+
attributes
|
|
150
|
+
}) => {
|
|
151
|
+
const componentClassName = "ds-switch";
|
|
152
|
+
const classes = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
|
|
153
|
+
return /* @__PURE__ */ jsxs5("div", { className: classes, children: [
|
|
154
|
+
/* @__PURE__ */ jsx6(
|
|
155
|
+
"input",
|
|
156
|
+
{
|
|
157
|
+
type: "checkbox",
|
|
158
|
+
id: name,
|
|
159
|
+
name,
|
|
160
|
+
defaultChecked: checked,
|
|
161
|
+
disabled,
|
|
162
|
+
...attributes
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
stripLabel ? /* @__PURE__ */ jsx6("div", { className: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx6(
|
|
166
|
+
SwitchInner,
|
|
167
|
+
{
|
|
168
|
+
...{
|
|
169
|
+
checked,
|
|
170
|
+
showMeta,
|
|
171
|
+
metaOn,
|
|
172
|
+
metaOff,
|
|
173
|
+
componentClassName
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
) }) : /* @__PURE__ */ jsx6("label", { className: `${componentClassName}__inner`, tabIndex: 0, htmlFor: name, children: /* @__PURE__ */ jsx6(
|
|
177
|
+
SwitchInner,
|
|
178
|
+
{
|
|
179
|
+
...{
|
|
180
|
+
checked,
|
|
181
|
+
showMeta,
|
|
182
|
+
metaOn,
|
|
183
|
+
metaOff,
|
|
184
|
+
componentClassName
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
) })
|
|
188
|
+
] });
|
|
189
|
+
};
|
|
190
|
+
var SwitchInner = ({ showMeta, checked, metaOn, metaOff, componentClassName }) => {
|
|
191
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
192
|
+
showMeta && /* @__PURE__ */ jsx6("div", { className: `${componentClassName}__meta`, children: /* @__PURE__ */ jsx6("span", { children: checked ? metaOn : metaOff }) }),
|
|
193
|
+
/* @__PURE__ */ jsx6("span", { className: `${componentClassName}__box`, children: /* @__PURE__ */ jsx6("span", { className: `${componentClassName}__knob` }) })
|
|
194
|
+
] });
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// ../src/components/spinner/spinner.tsx
|
|
198
|
+
import { jsx as jsx7 } from "preact/jsx-runtime";
|
|
199
|
+
var Spinner = ({ variant = "primary", size = "large", forcePx, classNames, attributes }) => {
|
|
200
|
+
const componentClassName = "ds-spinner";
|
|
201
|
+
const classes = formatClassString([
|
|
202
|
+
`${componentClassName}`,
|
|
203
|
+
`${componentClassName}--${variant}`,
|
|
204
|
+
`${componentClassName}--${size}`,
|
|
205
|
+
forcePx && "ds-force-px",
|
|
206
|
+
classNames
|
|
207
|
+
]);
|
|
208
|
+
return /* @__PURE__ */ jsx7("span", { className: classes, ...attributes, children: /* @__PURE__ */ jsx7("span", { className: `${componentClassName}__inner` }) });
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// ../src/foundations/a11y/visually-hidden.tsx
|
|
212
|
+
import { jsx as jsx8 } from "preact/jsx-runtime";
|
|
213
|
+
var VisuallyHidden = ({ text }) => {
|
|
214
|
+
return /* @__PURE__ */ jsx8("span", { className: "visually-hidden", dangerouslySetInnerHTML: { __html: text } });
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// ../src/components/button/button-base.tsx
|
|
218
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs6 } from "preact/jsx-runtime";
|
|
219
|
+
var InnerButton = ({ text, isIconButton = false, attributes, a11y, icon, loadingHtml }) => {
|
|
220
|
+
let optionalHtml;
|
|
221
|
+
if (!isIconButton) {
|
|
222
|
+
optionalHtml = /* @__PURE__ */ jsx9("span", { "aria-hidden": "true", children: text });
|
|
223
|
+
} else if (!attributes["aria-label"] && a11y?.visuallyHidden) {
|
|
224
|
+
optionalHtml = /* @__PURE__ */ jsx9(VisuallyHidden, { text: a11y.visuallyHidden });
|
|
225
|
+
}
|
|
226
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
227
|
+
optionalHtml,
|
|
228
|
+
icon,
|
|
229
|
+
loadingHtml
|
|
230
|
+
] });
|
|
231
|
+
};
|
|
232
|
+
var ToggleWrapper = ({
|
|
233
|
+
selected = false,
|
|
234
|
+
disabled = false,
|
|
235
|
+
attributes,
|
|
236
|
+
classes,
|
|
237
|
+
onChild,
|
|
238
|
+
offChild,
|
|
239
|
+
loadingHtml
|
|
240
|
+
}) => {
|
|
241
|
+
return /* @__PURE__ */ jsxs6("button", { type: "button", role: "switch", "aria-checked": selected, className: classes, ...attributes, disabled, children: [
|
|
242
|
+
/* @__PURE__ */ jsx9("span", { className: "ds-btn__off", "aria-hidden": "true", children: onChild }),
|
|
243
|
+
/* @__PURE__ */ jsx9("span", { className: "ds-btn__on", "aria-hidden": "true", children: offChild }),
|
|
244
|
+
loadingHtml
|
|
245
|
+
] });
|
|
246
|
+
};
|
|
247
|
+
var ButtonBase = ({
|
|
248
|
+
text,
|
|
249
|
+
disabled = false,
|
|
250
|
+
variant = "primary",
|
|
251
|
+
emphasis = "default",
|
|
252
|
+
rounded = false,
|
|
253
|
+
size = "medium",
|
|
254
|
+
fullWidth = false,
|
|
255
|
+
mobileFullWidth = false,
|
|
256
|
+
iconPosition = "none",
|
|
257
|
+
iconName,
|
|
258
|
+
loading = false,
|
|
259
|
+
type = "button",
|
|
260
|
+
href,
|
|
261
|
+
classNames,
|
|
262
|
+
attributes = {},
|
|
263
|
+
forcePx = false,
|
|
264
|
+
isIconButton = false,
|
|
265
|
+
a11y = {},
|
|
266
|
+
selected = false,
|
|
267
|
+
isToggle = false,
|
|
268
|
+
selectedIconName,
|
|
269
|
+
selectedText
|
|
270
|
+
}) => {
|
|
271
|
+
if (text && !href && !attributes["aria-label"]) {
|
|
272
|
+
attributes["aria-label"] = text;
|
|
273
|
+
}
|
|
274
|
+
let spinnerVariant = "secondary";
|
|
275
|
+
if (variant === "staticWhite") {
|
|
276
|
+
if (emphasis === "transparent" || emphasis === "outline") {
|
|
277
|
+
spinnerVariant = "staticWhite";
|
|
278
|
+
} else {
|
|
279
|
+
spinnerVariant = "staticBlack";
|
|
280
|
+
}
|
|
281
|
+
} else if (emphasis === "transparent" || emphasis === "outline" || variant === "secondary") {
|
|
282
|
+
spinnerVariant = "primary";
|
|
283
|
+
}
|
|
284
|
+
const loadingHtml = /* @__PURE__ */ jsx9(Spinner, { ...{ size: "small", variant: spinnerVariant, forcePx, attributes: { "aria-hidden": "true" } } });
|
|
285
|
+
let icon;
|
|
286
|
+
if (iconName && (iconPosition != "none" || isIconButton == true)) {
|
|
287
|
+
icon = /* @__PURE__ */ jsx9(IconUse, { ...{ iconName, attributes: { "aria-hidden": "true" } } });
|
|
288
|
+
}
|
|
289
|
+
const classNamePrefix = "ds-btn--";
|
|
290
|
+
const classes = formatClassString([
|
|
291
|
+
"ds-btn",
|
|
292
|
+
`${classNamePrefix}${variant}`,
|
|
293
|
+
`${classNamePrefix}${emphasis}`,
|
|
294
|
+
`${classNamePrefix}${size}`,
|
|
295
|
+
isToggle && selected && `${classNamePrefix}selected`,
|
|
296
|
+
fullWidth && `${classNamePrefix}full-width`,
|
|
297
|
+
mobileFullWidth && `${classNamePrefix}mobile-full-width`,
|
|
298
|
+
icon && !isIconButton && `${classNamePrefix}icon-${iconPosition}`,
|
|
299
|
+
isIconButton && `${classNamePrefix}icon-only`,
|
|
300
|
+
rounded && `${classNamePrefix}rounded`,
|
|
301
|
+
isToggle && `${classNamePrefix}toggle`,
|
|
302
|
+
loading && "ds-loading",
|
|
303
|
+
forcePx && "ds-force-px",
|
|
304
|
+
classNames
|
|
305
|
+
]);
|
|
306
|
+
let buttonToRender;
|
|
307
|
+
if (isToggle) {
|
|
308
|
+
let onChild, offChild;
|
|
309
|
+
if (isIconButton && iconName && selectedIconName) {
|
|
310
|
+
onChild = /* @__PURE__ */ jsx9(IconUse, { iconName });
|
|
311
|
+
offChild = /* @__PURE__ */ jsx9(IconUse, { iconName: selectedIconName });
|
|
312
|
+
} else {
|
|
313
|
+
onChild = /* @__PURE__ */ jsx9("span", { children: text });
|
|
314
|
+
offChild = /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
315
|
+
/* @__PURE__ */ jsx9(IconUse, { iconName: "check" }),
|
|
316
|
+
/* @__PURE__ */ jsx9("span", { children: selectedText })
|
|
317
|
+
] });
|
|
318
|
+
}
|
|
319
|
+
buttonToRender = /* @__PURE__ */ jsx9(ToggleWrapper, { ...{ selected, classes, attributes, disabled, onChild, offChild, loadingHtml } });
|
|
320
|
+
} else {
|
|
321
|
+
const buttonParams = { isIconButton, a11y, text, icon, loadingHtml, attributes };
|
|
322
|
+
if (href) {
|
|
323
|
+
buttonToRender = /* @__PURE__ */ jsx9("a", { href, className: classes, ...attributes, children: /* @__PURE__ */ jsx9(InnerButton, { ...buttonParams }) });
|
|
324
|
+
} else {
|
|
325
|
+
buttonToRender = /* @__PURE__ */ jsx9("button", { type, className: classes, ...attributes, disabled, children: /* @__PURE__ */ jsx9(InnerButton, { ...buttonParams }) });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return /* @__PURE__ */ jsx9(Fragment3, { children: buttonToRender });
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// ../src/components/button-toggle/button-toggle.tsx
|
|
332
|
+
import { jsx as jsx10 } from "preact/jsx-runtime";
|
|
333
|
+
var ButtonToggle = ({
|
|
334
|
+
selected = false,
|
|
335
|
+
text,
|
|
336
|
+
selectedText,
|
|
337
|
+
disabled = false,
|
|
338
|
+
variant = "primary",
|
|
339
|
+
size = "medium",
|
|
340
|
+
fullWidth = false,
|
|
341
|
+
mobileFullWidth = false,
|
|
342
|
+
loading = false,
|
|
343
|
+
attributes = {},
|
|
344
|
+
classNames,
|
|
345
|
+
forcePx = false
|
|
346
|
+
}) => {
|
|
347
|
+
return /* @__PURE__ */ jsx10(
|
|
348
|
+
ButtonBase,
|
|
349
|
+
{
|
|
350
|
+
...{
|
|
351
|
+
selected,
|
|
352
|
+
text,
|
|
353
|
+
disabled,
|
|
354
|
+
variant,
|
|
355
|
+
rounded: true,
|
|
356
|
+
size,
|
|
357
|
+
fullWidth,
|
|
358
|
+
mobileFullWidth,
|
|
359
|
+
loading,
|
|
360
|
+
classNames,
|
|
361
|
+
attributes,
|
|
362
|
+
forcePx,
|
|
363
|
+
isToggle: true,
|
|
364
|
+
selectedText,
|
|
365
|
+
type: "button"
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
};
|
|
370
|
+
var button_toggle_default = ButtonToggle;
|
|
371
|
+
|
|
372
|
+
// ../src/components/list-item/list-item.tsx
|
|
373
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs7 } from "preact/jsx-runtime";
|
|
374
|
+
var ListItem = (props) => {
|
|
375
|
+
const {
|
|
376
|
+
listItemType,
|
|
377
|
+
title,
|
|
378
|
+
subtitle,
|
|
379
|
+
meta,
|
|
380
|
+
border = false,
|
|
381
|
+
fontWeight = "regular",
|
|
382
|
+
attributes,
|
|
383
|
+
forcePx,
|
|
384
|
+
classNames
|
|
385
|
+
} = props;
|
|
386
|
+
const componentClassName = "ds-list-item";
|
|
387
|
+
const classes = formatClassString([
|
|
388
|
+
componentClassName,
|
|
389
|
+
border && `${componentClassName}--border`,
|
|
390
|
+
forcePx && "ds-force-px",
|
|
391
|
+
classNames
|
|
392
|
+
]);
|
|
393
|
+
let iconLeftSvg;
|
|
394
|
+
if (listItemType === "accordion" || listItemType === "switch" || listItemType === "standard") {
|
|
395
|
+
const { leadingIcon } = props;
|
|
396
|
+
if (leadingIcon) {
|
|
397
|
+
iconLeftSvg = IconUse({ iconName: leadingIcon });
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
let iconRightSvg;
|
|
401
|
+
if (listItemType === "standard" || listItemType === "image") {
|
|
402
|
+
const { trailingIcon } = props;
|
|
403
|
+
if (trailingIcon) {
|
|
404
|
+
iconRightSvg = IconUse({ iconName: trailingIcon });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const mediaHtml = (listItemType === "image" || listItemType === "byline") && props.mediaHtml;
|
|
408
|
+
return /* @__PURE__ */ jsx11("li", { className: classes, children: /* @__PURE__ */ jsxs7(ListItemInner, { ...{ ...props, componentClassName }, children: [
|
|
409
|
+
iconLeftSvg && /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__icon-left`, children: iconLeftSvg }),
|
|
410
|
+
mediaHtml && /* @__PURE__ */ jsx11(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
className: getImageClass(componentClassName, listItemType),
|
|
414
|
+
dangerouslySetInnerHTML: { __html: mediaHtml }
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
title && /* @__PURE__ */ jsx11(
|
|
418
|
+
Title,
|
|
419
|
+
{
|
|
420
|
+
title,
|
|
421
|
+
subtitle,
|
|
422
|
+
fontWeight,
|
|
423
|
+
componentClassName,
|
|
424
|
+
attributes
|
|
425
|
+
}
|
|
426
|
+
),
|
|
427
|
+
meta && /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__meta`, children: meta }),
|
|
428
|
+
iconRightSvg && /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__icon-right`, children: iconRightSvg })
|
|
429
|
+
] }) });
|
|
430
|
+
};
|
|
431
|
+
var ListItemInner = ({
|
|
432
|
+
listItemType,
|
|
433
|
+
href,
|
|
434
|
+
disabled,
|
|
435
|
+
attributes,
|
|
436
|
+
checked,
|
|
437
|
+
selected,
|
|
438
|
+
value,
|
|
439
|
+
variant,
|
|
440
|
+
toggleText,
|
|
441
|
+
toggleSelectedText,
|
|
442
|
+
name = "ds-list-item",
|
|
443
|
+
id = "ds-list-item",
|
|
444
|
+
forcePx,
|
|
445
|
+
componentClassName,
|
|
446
|
+
accordionContent,
|
|
447
|
+
children
|
|
448
|
+
}) => {
|
|
449
|
+
const classes = formatClassString([
|
|
450
|
+
`${componentClassName}__content`,
|
|
451
|
+
`${componentClassName}--${listItemType}`,
|
|
452
|
+
disabled && `${componentClassName}--disabled`
|
|
453
|
+
]);
|
|
454
|
+
switch (listItemType) {
|
|
455
|
+
case "standard":
|
|
456
|
+
case "image":
|
|
457
|
+
const hasLink = href && !disabled;
|
|
458
|
+
return /* @__PURE__ */ jsx11(Fragment4, { children: hasLink ? /* @__PURE__ */ jsx11("a", { className: classes, href, ...attributes, children }) : /* @__PURE__ */ jsx11("button", { className: classes, disabled, ...attributes, children }) });
|
|
459
|
+
case "checkbox":
|
|
460
|
+
return /* @__PURE__ */ jsxs7("label", { className: classes, htmlFor: name, ...attributes, children: [
|
|
461
|
+
/* @__PURE__ */ jsx11(ListItemIconWrapper, { placement: "left", componentClassName, children: /* @__PURE__ */ jsx11(
|
|
462
|
+
checkbox_default,
|
|
463
|
+
{
|
|
464
|
+
...{
|
|
465
|
+
name,
|
|
466
|
+
checked,
|
|
467
|
+
stripLabel: true,
|
|
468
|
+
disabled,
|
|
469
|
+
forcePx,
|
|
470
|
+
attributes
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
) }),
|
|
474
|
+
children
|
|
475
|
+
] });
|
|
476
|
+
case "radio":
|
|
477
|
+
return /* @__PURE__ */ jsxs7("label", { className: classes, htmlFor: id, ...attributes, children: [
|
|
478
|
+
/* @__PURE__ */ jsx11(ListItemIconWrapper, { placement: "left", componentClassName, children: /* @__PURE__ */ jsx11(
|
|
479
|
+
RadioButton,
|
|
480
|
+
{
|
|
481
|
+
...{
|
|
482
|
+
id,
|
|
483
|
+
name,
|
|
484
|
+
disabled,
|
|
485
|
+
selected,
|
|
486
|
+
forcePx,
|
|
487
|
+
buttons: [{ id, selected, value: value || "" }],
|
|
488
|
+
attributes
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
) }),
|
|
492
|
+
children
|
|
493
|
+
] });
|
|
494
|
+
case "switch":
|
|
495
|
+
return /* @__PURE__ */ jsxs7("label", { className: classes, htmlFor: name, ...attributes, children: [
|
|
496
|
+
children,
|
|
497
|
+
/* @__PURE__ */ jsx11(ListItemIconWrapper, { placement: "right", componentClassName, children: /* @__PURE__ */ jsx11(
|
|
498
|
+
Switch,
|
|
499
|
+
{
|
|
500
|
+
...{
|
|
501
|
+
name,
|
|
502
|
+
showMeta: true,
|
|
503
|
+
checked,
|
|
504
|
+
disabled,
|
|
505
|
+
forcePx,
|
|
506
|
+
stripLabel: true,
|
|
507
|
+
attributes
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
) })
|
|
511
|
+
] });
|
|
512
|
+
case "accordion":
|
|
513
|
+
return /* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
514
|
+
/* @__PURE__ */ jsxs7("button", { className: classes, disabled, ...attributes, children: [
|
|
515
|
+
children,
|
|
516
|
+
/* @__PURE__ */ jsxs7(ListItemIconWrapper, { placement: "right", componentClassName, children: [
|
|
517
|
+
/* @__PURE__ */ jsx11(IconUse, { iconName: "expand_less" }),
|
|
518
|
+
/* @__PURE__ */ jsx11(IconUse, { iconName: "expand_more" })
|
|
519
|
+
] })
|
|
520
|
+
] }),
|
|
521
|
+
accordionContent && /* @__PURE__ */ jsx11("div", { className: `${componentClassName}__accordion-inner`, children: accordionContent })
|
|
522
|
+
] });
|
|
523
|
+
case "toggle":
|
|
524
|
+
case "byline":
|
|
525
|
+
const buttonComponent = /* @__PURE__ */ jsx11(
|
|
526
|
+
button_toggle_default,
|
|
527
|
+
{
|
|
528
|
+
...{
|
|
529
|
+
text: toggleText,
|
|
530
|
+
selectedText: toggleSelectedText || "",
|
|
531
|
+
variant: variant || "secondary",
|
|
532
|
+
size: "small",
|
|
533
|
+
selected,
|
|
534
|
+
disabled,
|
|
535
|
+
forcePx,
|
|
536
|
+
attributes
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
return /* @__PURE__ */ jsxs7("div", { className: classes, ...attributes, children: [
|
|
541
|
+
children,
|
|
542
|
+
buttonComponent
|
|
543
|
+
] });
|
|
544
|
+
default:
|
|
545
|
+
return /* @__PURE__ */ jsx11("div", { className: classes, ...attributes, children });
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
var Title = ({ title, subtitle, fontWeight, attributes }) => {
|
|
549
|
+
const componentClassName = "ds-list-item";
|
|
550
|
+
const titleClasses = formatClassString([
|
|
551
|
+
`${componentClassName}__title`,
|
|
552
|
+
`${componentClassName}__title--${fontWeight}`
|
|
553
|
+
]);
|
|
554
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${componentClassName}__titles`, children: [
|
|
555
|
+
/* @__PURE__ */ jsx11("span", { className: titleClasses, ...attributes, children: title }),
|
|
556
|
+
subtitle && /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__subtitle`, children: subtitle })
|
|
557
|
+
] });
|
|
558
|
+
};
|
|
559
|
+
var ListItemIconWrapper = ({
|
|
560
|
+
placement,
|
|
561
|
+
componentClassName,
|
|
562
|
+
children
|
|
563
|
+
}) => {
|
|
564
|
+
return /* @__PURE__ */ jsx11("span", { className: `${componentClassName}__icon-${placement}`, children });
|
|
565
|
+
};
|
|
566
|
+
var getImageClass = (componentClassName, listItemType) => {
|
|
567
|
+
const imageType = listItemType === "byline" ? "portrait" : "image";
|
|
568
|
+
return `${componentClassName}__${imageType}`;
|
|
569
|
+
};
|
|
570
|
+
export {
|
|
571
|
+
ListItem
|
|
572
|
+
};
|
|
573
|
+
//# sourceMappingURL=list-item.js.map
|