@ukic/web-components 2.35.0 → 2.35.1
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/README.md +1 -0
- package/dist/cjs/ic-navigation-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-item.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-toast.cjs.entry.js +2 -2
- package/dist/cjs/ic-toast.cjs.entry.js.map +1 -1
- package/dist/collection/components/ic-accordion/ic-accordion.stories.js +635 -0
- package/dist/collection/components/ic-alert/ic-alert.stories.js +257 -0
- package/dist/collection/components/ic-back-to-top/ic-back-to-top.stories.js +162 -0
- package/dist/collection/components/ic-badge/ic-badge.stories.js +1082 -0
- package/dist/collection/components/ic-breadcrumb-group/ic-breadcrumb-group.stories.js +502 -0
- package/dist/collection/components/ic-button/ic-button.stories.js +2218 -0
- package/dist/collection/components/ic-card/ic-card.stories.js +1034 -0
- package/dist/collection/components/ic-checkbox-group/ic-checkbox-group.stories.js +687 -0
- package/dist/collection/components/ic-chip/ic-chip.stories.js +670 -0
- package/dist/collection/components/ic-classification-banner/ic-classification-banner.stories.js +131 -0
- package/dist/collection/components/ic-data-entity/ic-data-entity.stories.js +487 -0
- package/dist/collection/components/ic-dialog/ic-dialog.stories.js +1256 -0
- package/dist/collection/components/ic-empty-state/ic-empty-state.stories.js +397 -0
- package/dist/collection/components/ic-footer/ic-footer.stories.js +383 -0
- package/dist/collection/components/ic-hero/ic-hero.stories.js +489 -0
- package/dist/collection/components/ic-link/ic-link.stories.js +114 -0
- package/dist/collection/components/ic-loading-indicator/ic-loading-indicator.stories.js +416 -0
- package/dist/collection/components/ic-navigation-item/ic-navigation-item.css +7 -35
- package/dist/collection/components/ic-page-header/ic-page-header.stories.js +557 -0
- package/dist/collection/components/ic-pagination/ic-pagination.stories.js +125 -0
- package/dist/collection/components/ic-popover-menu/ic-popover-menu.stories.js +486 -0
- package/dist/collection/components/ic-radio-group/ic-radio-group.stories.js +450 -0
- package/dist/collection/components/ic-search-bar/ic-search-bar.stories.js +591 -0
- package/dist/collection/components/ic-section-container/ic-section-container.stories.js +62 -0
- package/dist/collection/components/ic-select/ic-select-searchable.stories.js +953 -0
- package/dist/collection/components/ic-select/ic-select-single.stories.js +780 -0
- package/dist/collection/components/ic-side-navigation/ic-side-navigation.stories.js +2526 -0
- package/dist/collection/components/ic-skeleton/ic-skeleton.stories.js +141 -0
- package/dist/collection/components/ic-status-tag/ic-status-tag.stories.js +161 -0
- package/dist/collection/components/ic-stepper/ic-stepper.stories.js +327 -0
- package/dist/collection/components/ic-switch/ic-switch.stories.js +171 -0
- package/dist/collection/components/ic-tab-context/ic-tabs.stories.js +388 -0
- package/dist/collection/components/ic-text-field/ic-text-field.stories.js +1083 -0
- package/dist/collection/components/ic-theme/ic-theme.stories.js +171 -0
- package/dist/collection/components/ic-toast/ic-toast.js +2 -2
- package/dist/collection/components/ic-toast/ic-toast.js.map +1 -1
- package/dist/collection/components/ic-toast/ic-toast.stories.js +413 -0
- package/dist/collection/components/ic-toast/test/basic/ic-toast.spec.js +3 -3
- package/dist/collection/components/ic-toast/test/basic/ic-toast.spec.js.map +1 -1
- package/dist/collection/components/ic-toggle-button/ic-toggle-button.stories.js +537 -0
- package/dist/collection/components/ic-toggle-button-group/ic-toggle-button-group.stories.js +610 -0
- package/dist/collection/components/ic-tooltip/ic-tooltip.stories.js +356 -0
- package/dist/collection/components/ic-top-navigation/ic-top-navigation.stories.js +1083 -0
- package/dist/collection/components/ic-typography/ic-typography.stories.js +437 -0
- package/dist/collection/patterns/top-nav-content-footer.stories.js +109 -0
- package/dist/collection/patterns/z-index.stories.js +474 -0
- package/dist/components/ic-navigation-item.js +1 -1
- package/dist/components/ic-navigation-item.js.map +1 -1
- package/dist/components/ic-toast.js +2 -2
- package/dist/components/ic-toast.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/p-3e8023ff.entry.js +2 -0
- package/dist/core/p-3e8023ff.entry.js.map +1 -0
- package/dist/core/{p-7e8a4abd.entry.js → p-bfaa257c.entry.js} +2 -2
- package/dist/core/{p-7e8a4abd.entry.js.map → p-bfaa257c.entry.js.map} +1 -1
- package/dist/esm/ic-navigation-item.entry.js +1 -1
- package/dist/esm/ic-navigation-item.entry.js.map +1 -1
- package/dist/esm/ic-toast.entry.js +2 -2
- package/dist/esm/ic-toast.entry.js.map +1 -1
- package/hydrate/index.js +3 -3
- package/package.json +15 -11
- package/dist/core/p-dfb3e76e.entry.js +0 -2
- package/dist/core/p-dfb3e76e.entry.js.map +0 -1
@@ -0,0 +1,687 @@
|
|
1
|
+
import { useArgs } from "@storybook/preview-api";
|
2
|
+
import { html } from "lit-html";
|
3
|
+
|
4
|
+
const defaultArgs = {
|
5
|
+
additionalFieldDisplay: "dynamic",
|
6
|
+
additionalFieldSlot: "additional-field",
|
7
|
+
checked: false,
|
8
|
+
disabled: false,
|
9
|
+
dynamicText: "Dynamic text",
|
10
|
+
groupLabel: "Checkbox group label",
|
11
|
+
helperText: "Helper text",
|
12
|
+
hideLabel: false,
|
13
|
+
hideGroupLabel: false,
|
14
|
+
indeterminate: false,
|
15
|
+
label: "Checkbox label",
|
16
|
+
nativeIndeterminateBehaviour: false,
|
17
|
+
required: false,
|
18
|
+
size: "default",
|
19
|
+
validationStatus: "",
|
20
|
+
validationText: "",
|
21
|
+
value: "checkbox-value",
|
22
|
+
};
|
23
|
+
|
24
|
+
export default {
|
25
|
+
title: "Web Components/Checkbox",
|
26
|
+
component: "Checkbox",
|
27
|
+
};
|
28
|
+
|
29
|
+
export const Default = {
|
30
|
+
render: (args) => html`
|
31
|
+
<ic-checkbox-group label="This is a label" name="group1">
|
32
|
+
<ic-checkbox
|
33
|
+
value="valueName1"
|
34
|
+
label="Unselected / Default"
|
35
|
+
></ic-checkbox>
|
36
|
+
<ic-checkbox
|
37
|
+
value="valueName2"
|
38
|
+
label="Selected / Default"
|
39
|
+
checked
|
40
|
+
></ic-checkbox>
|
41
|
+
<ic-checkbox
|
42
|
+
value="valueName3"
|
43
|
+
label="Unselected / Disabled"
|
44
|
+
Disabled
|
45
|
+
></ic-checkbox>
|
46
|
+
</ic-checkbox-group>
|
47
|
+
`,
|
48
|
+
|
49
|
+
name: "Default",
|
50
|
+
};
|
51
|
+
|
52
|
+
export const Required = {
|
53
|
+
render: (args) => html`
|
54
|
+
<ic-checkbox-group label="This is a label" required name="group1">
|
55
|
+
<ic-checkbox
|
56
|
+
value="valueName1"
|
57
|
+
label="Unselected / Default"
|
58
|
+
></ic-checkbox>
|
59
|
+
<ic-checkbox
|
60
|
+
value="valueName2"
|
61
|
+
label="Selected / Default"
|
62
|
+
checked
|
63
|
+
></ic-checkbox>
|
64
|
+
<ic-checkbox
|
65
|
+
value="valueName3"
|
66
|
+
label="Unselected / Disabled"
|
67
|
+
Disabled
|
68
|
+
></ic-checkbox>
|
69
|
+
</ic-checkbox-group>
|
70
|
+
`,
|
71
|
+
|
72
|
+
name: "Required",
|
73
|
+
};
|
74
|
+
|
75
|
+
export const Disabled = {
|
76
|
+
render: (args) => html`
|
77
|
+
<ic-checkbox-group label="This is a label" name="group1" Disabled>
|
78
|
+
<ic-checkbox
|
79
|
+
value="valueName1"
|
80
|
+
label="Unselected / Disabled 1"
|
81
|
+
Disabled
|
82
|
+
></ic-checkbox>
|
83
|
+
<ic-checkbox
|
84
|
+
value="valueName2"
|
85
|
+
label="Unselected / Disabled 2"
|
86
|
+
Disabled
|
87
|
+
></ic-checkbox>
|
88
|
+
<ic-checkbox
|
89
|
+
value="valueName3"
|
90
|
+
label="Unselected / Disabled 3"
|
91
|
+
Disabled
|
92
|
+
></ic-checkbox>
|
93
|
+
<ic-checkbox
|
94
|
+
value="valueName4"
|
95
|
+
label="Selected / Disabled"
|
96
|
+
Disabled
|
97
|
+
checked
|
98
|
+
></ic-checkbox>
|
99
|
+
</ic-checkbox-group>
|
100
|
+
`,
|
101
|
+
|
102
|
+
name: "Disabled",
|
103
|
+
};
|
104
|
+
|
105
|
+
export const Sizes = {
|
106
|
+
render: (args) => html`
|
107
|
+
<ic-checkbox-group
|
108
|
+
size="large"
|
109
|
+
label="These are checkboxes with the 'size' attribute set on them individually"
|
110
|
+
name="group1"
|
111
|
+
>
|
112
|
+
<ic-checkbox
|
113
|
+
size="small"
|
114
|
+
value="valueName1"
|
115
|
+
label="Unselected / Default"
|
116
|
+
></ic-checkbox>
|
117
|
+
<ic-checkbox
|
118
|
+
size="default"
|
119
|
+
value="valueName2"
|
120
|
+
label="Selected / Default"
|
121
|
+
checked
|
122
|
+
></ic-checkbox>
|
123
|
+
<ic-checkbox
|
124
|
+
size="large"
|
125
|
+
value="valueName3"
|
126
|
+
label="Unselected / Disabled"
|
127
|
+
disabled
|
128
|
+
></ic-checkbox>
|
129
|
+
</ic-checkbox-group>
|
130
|
+
<ic-checkbox-group
|
131
|
+
size="small"
|
132
|
+
label="This is a checkbox group with small checkboxes"
|
133
|
+
name="group1"
|
134
|
+
>
|
135
|
+
<ic-checkbox
|
136
|
+
value="valueName1"
|
137
|
+
label="Unselected / Default"
|
138
|
+
></ic-checkbox>
|
139
|
+
<ic-checkbox
|
140
|
+
value="valueName2"
|
141
|
+
label="Selected / Default"
|
142
|
+
checked
|
143
|
+
></ic-checkbox>
|
144
|
+
<ic-checkbox
|
145
|
+
value="valueName3"
|
146
|
+
label="Unselected / Disabled"
|
147
|
+
disabled
|
148
|
+
></ic-checkbox>
|
149
|
+
</ic-checkbox-group>
|
150
|
+
<ic-checkbox-group
|
151
|
+
size="default"
|
152
|
+
label="This is a checkbox group with default-sized checkboxes"
|
153
|
+
name="group1"
|
154
|
+
>
|
155
|
+
<ic-checkbox
|
156
|
+
value="valueName1"
|
157
|
+
label="Unselected / Default"
|
158
|
+
></ic-checkbox>
|
159
|
+
<ic-checkbox
|
160
|
+
value="valueName2"
|
161
|
+
label="Selected / Default"
|
162
|
+
checked
|
163
|
+
></ic-checkbox>
|
164
|
+
<ic-checkbox
|
165
|
+
value="valueName3"
|
166
|
+
label="Unselected / Disabled"
|
167
|
+
disabled
|
168
|
+
></ic-checkbox>
|
169
|
+
</ic-checkbox-group>
|
170
|
+
<ic-checkbox-group
|
171
|
+
size="large"
|
172
|
+
label="This is a checkbox group with large checkboxes"
|
173
|
+
name="group1"
|
174
|
+
>
|
175
|
+
<ic-checkbox
|
176
|
+
value="valueName1"
|
177
|
+
label="Unselected / Default"
|
178
|
+
></ic-checkbox>
|
179
|
+
<ic-checkbox
|
180
|
+
value="valueName2"
|
181
|
+
label="Selected / Default"
|
182
|
+
checked
|
183
|
+
></ic-checkbox>
|
184
|
+
<ic-checkbox
|
185
|
+
value="valueName3"
|
186
|
+
label="Unselected / Disabled"
|
187
|
+
disabled
|
188
|
+
></ic-checkbox>
|
189
|
+
</ic-checkbox-group>
|
190
|
+
`,
|
191
|
+
|
192
|
+
name: "Sizes",
|
193
|
+
};
|
194
|
+
|
195
|
+
export const HiddenGroupLabel = {
|
196
|
+
render: (args) => html`
|
197
|
+
<ic-checkbox-group label="This is a label" hide-label name="group1">
|
198
|
+
<ic-checkbox
|
199
|
+
value="valueName1"
|
200
|
+
label="Unselected / Default"
|
201
|
+
></ic-checkbox>
|
202
|
+
<ic-checkbox
|
203
|
+
value="valueName2"
|
204
|
+
label="Selected / Default"
|
205
|
+
checked
|
206
|
+
></ic-checkbox>
|
207
|
+
<ic-checkbox
|
208
|
+
value="valueName3"
|
209
|
+
label="Unselected / Disabled"
|
210
|
+
Disabled
|
211
|
+
></ic-checkbox>
|
212
|
+
</ic-checkbox-group>
|
213
|
+
`,
|
214
|
+
|
215
|
+
name: "Hidden group label",
|
216
|
+
};
|
217
|
+
|
218
|
+
export const HiddenCheckboxLabel = {
|
219
|
+
render: (args) => html`
|
220
|
+
<ic-checkbox-group label="This is a label" name="group1">
|
221
|
+
<ic-checkbox
|
222
|
+
value="valueName1"
|
223
|
+
label="Unselected / Default"
|
224
|
+
hide-label
|
225
|
+
></ic-checkbox>
|
226
|
+
<ic-checkbox
|
227
|
+
value="valueName2"
|
228
|
+
label="Selected / Default"
|
229
|
+
checked
|
230
|
+
hide-label
|
231
|
+
></ic-checkbox>
|
232
|
+
<ic-checkbox
|
233
|
+
value="valueName3"
|
234
|
+
label="Unselected / Disabled"
|
235
|
+
Disabled
|
236
|
+
hide-label
|
237
|
+
></ic-checkbox>
|
238
|
+
</ic-checkbox-group>
|
239
|
+
`,
|
240
|
+
|
241
|
+
name: "Hidden checkbox label",
|
242
|
+
};
|
243
|
+
|
244
|
+
export const ConditionalDynamic = {
|
245
|
+
render: (args) => html`
|
246
|
+
<script>
|
247
|
+
function handleIcChange(ev) {
|
248
|
+
console.log(
|
249
|
+
ev.detail.selectedOption.label,
|
250
|
+
ev.detail.selectedOption.checked
|
251
|
+
);
|
252
|
+
}
|
253
|
+
document
|
254
|
+
.querySelector("ic-checkbox-group")
|
255
|
+
.addEventListener("icChange", handleIcChange);
|
256
|
+
</script>
|
257
|
+
<ic-checkbox-group label="This is a label" name="group1">
|
258
|
+
<ic-checkbox
|
259
|
+
additional-field-display="dynamic"
|
260
|
+
value="valueName1"
|
261
|
+
label="option1"
|
262
|
+
>
|
263
|
+
<ic-text-field
|
264
|
+
slot="additional-field"
|
265
|
+
placeholder="Placeholder"
|
266
|
+
label="What's your favourite type of coffee?"
|
267
|
+
></ic-text-field>
|
268
|
+
</ic-checkbox>
|
269
|
+
<ic-checkbox
|
270
|
+
additional-field-display="dynamic"
|
271
|
+
value="valueName2"
|
272
|
+
label="option2 - error example"
|
273
|
+
>
|
274
|
+
<ic-text-field
|
275
|
+
validation-status="error"
|
276
|
+
validation-text="now it has really gone to (coffee) pot"
|
277
|
+
slot="additional-field"
|
278
|
+
placeholder="Placeholder"
|
279
|
+
label="What's your favourite type of coffee?"
|
280
|
+
>
|
281
|
+
</ic-text-field>
|
282
|
+
</ic-checkbox>
|
283
|
+
<ic-checkbox
|
284
|
+
additional-field-display="dynamic"
|
285
|
+
value="valueName3"
|
286
|
+
label="option3"
|
287
|
+
>
|
288
|
+
<ic-text-field
|
289
|
+
slot="additional-field"
|
290
|
+
placeholder="Placeholder"
|
291
|
+
label="What's your favourite type of coffee?"
|
292
|
+
></ic-text-field>
|
293
|
+
</ic-checkbox>
|
294
|
+
</ic-checkbox-group>
|
295
|
+
`,
|
296
|
+
|
297
|
+
name: "Conditional dynamic",
|
298
|
+
};
|
299
|
+
|
300
|
+
export const ConditionalStatic = {
|
301
|
+
render: (args) => html`
|
302
|
+
<ic-checkbox-group label="This is a label" name="group1">
|
303
|
+
<ic-checkbox value="valueName1" label="option1">
|
304
|
+
<ic-text-field
|
305
|
+
slot="additional-field"
|
306
|
+
label="What's your favourite type of coffee?"
|
307
|
+
></ic-text-field>
|
308
|
+
</ic-checkbox>
|
309
|
+
<ic-checkbox value="valueName2" label="option2"> </ic-checkbox>
|
310
|
+
</ic-checkbox-group>
|
311
|
+
`,
|
312
|
+
|
313
|
+
name: "Conditional static",
|
314
|
+
};
|
315
|
+
|
316
|
+
export const HelperText = {
|
317
|
+
render: (args) => html`
|
318
|
+
<ic-checkbox-group
|
319
|
+
label="This is a label"
|
320
|
+
name="group1"
|
321
|
+
helper-text="Helper text"
|
322
|
+
>
|
323
|
+
<ic-checkbox
|
324
|
+
value="valueName1"
|
325
|
+
label="Unselected / Default"
|
326
|
+
></ic-checkbox>
|
327
|
+
<ic-checkbox
|
328
|
+
value="valueName2"
|
329
|
+
label="Selected / Default"
|
330
|
+
checked
|
331
|
+
></ic-checkbox>
|
332
|
+
<ic-checkbox
|
333
|
+
value="valueName3"
|
334
|
+
label="Unselected / Disabled"
|
335
|
+
Disabled
|
336
|
+
></ic-checkbox>
|
337
|
+
</ic-checkbox-group>
|
338
|
+
`,
|
339
|
+
|
340
|
+
name: "Helper text",
|
341
|
+
};
|
342
|
+
|
343
|
+
export const Validation = {
|
344
|
+
render: (args) => html`
|
345
|
+
<ic-checkbox-group
|
346
|
+
label="This is a label"
|
347
|
+
name="group1"
|
348
|
+
validation-status="error"
|
349
|
+
validation-text="Error message"
|
350
|
+
>
|
351
|
+
<ic-checkbox
|
352
|
+
value="valueName1"
|
353
|
+
label="Unselected / Default"
|
354
|
+
></ic-checkbox>
|
355
|
+
<ic-checkbox
|
356
|
+
value="valueName2"
|
357
|
+
label="Selected / Default"
|
358
|
+
checked
|
359
|
+
></ic-checkbox>
|
360
|
+
<ic-checkbox
|
361
|
+
value="valueName3"
|
362
|
+
label="Unselected / Disabled"
|
363
|
+
Disabled
|
364
|
+
></ic-checkbox>
|
365
|
+
</ic-checkbox-group>
|
366
|
+
`,
|
367
|
+
|
368
|
+
name: "Validation",
|
369
|
+
};
|
370
|
+
|
371
|
+
export const Form = {
|
372
|
+
render: (args) => html`
|
373
|
+
<form>
|
374
|
+
<ic-checkbox-group label="This is a label" name="group1">
|
375
|
+
<ic-checkbox
|
376
|
+
name="checkbox1"
|
377
|
+
value="valueName1"
|
378
|
+
label="Unselected / Default"
|
379
|
+
></ic-checkbox>
|
380
|
+
<ic-checkbox
|
381
|
+
name="checkbox2"
|
382
|
+
value="valueName2"
|
383
|
+
label="Selected / Default"
|
384
|
+
checked
|
385
|
+
></ic-checkbox>
|
386
|
+
<ic-checkbox
|
387
|
+
name="checkbox3"
|
388
|
+
value="valueName3"
|
389
|
+
label="Unselected / Disabled"
|
390
|
+
Disabled
|
391
|
+
></ic-checkbox>
|
392
|
+
</ic-checkbox-group>
|
393
|
+
<input type="submit" value="Submit" />
|
394
|
+
<input type="reset" value="Reset" />
|
395
|
+
</form>
|
396
|
+
<script>
|
397
|
+
document.querySelector("form").addEventListener("submit", (ev) => {
|
398
|
+
ev.preventDefault();
|
399
|
+
console.log(
|
400
|
+
document.querySelector('ic-checkbox[name="checkbox1"]').checked
|
401
|
+
);
|
402
|
+
console.log(
|
403
|
+
document.querySelector('ic-checkbox[name="checkbox2"]').checked
|
404
|
+
);
|
405
|
+
console.log(
|
406
|
+
document.querySelector('ic-checkbox[name="checkbox3"]').checked
|
407
|
+
);
|
408
|
+
});
|
409
|
+
</script>
|
410
|
+
`,
|
411
|
+
|
412
|
+
name: "Form",
|
413
|
+
};
|
414
|
+
|
415
|
+
export const Indeterminate = {
|
416
|
+
render: (args) => html`
|
417
|
+
<script>
|
418
|
+
var indeterminate = true;
|
419
|
+
var nativeIndeterminate = true;
|
420
|
+
var indeterminateTextEl = document.querySelector("#indeterminate-text");
|
421
|
+
indeterminateTextEl.innerHTML = indeterminate;
|
422
|
+
var checkedTextEl = document.querySelector("#checked-text");
|
423
|
+
checkedTextEl.innerHTML = true;
|
424
|
+
var nativeIndeterminateTextEl = document.querySelector(
|
425
|
+
"#native-indeterminate-text"
|
426
|
+
);
|
427
|
+
nativeIndeterminateTextEl.innerHTML = nativeIndeterminate;
|
428
|
+
var nativeCheckedTextEl = document.querySelector("#native-checked-text");
|
429
|
+
nativeCheckedTextEl.innerHTML = true;
|
430
|
+
function toggleIndeterminate() {
|
431
|
+
indeterminate = !indeterminate;
|
432
|
+
document.querySelector("#indeterminate-checkbox").indeterminate =
|
433
|
+
indeterminate;
|
434
|
+
indeterminateTextEl.innerHTML = indeterminate;
|
435
|
+
}
|
436
|
+
function toggleNativeIndeterminate() {
|
437
|
+
nativeIndeterminate = !nativeIndeterminate;
|
438
|
+
document.querySelector("#native-indeterminate-checkbox").indeterminate =
|
439
|
+
nativeIndeterminate;
|
440
|
+
nativeIndeterminateTextEl.innerHTML = nativeIndeterminate;
|
441
|
+
}
|
442
|
+
function icCheckHandler(ev) {
|
443
|
+
document.querySelector("#checked-text").innerHTML = ev.target.checked;
|
444
|
+
}
|
445
|
+
function icCheckHandlerNative(ev) {
|
446
|
+
document.querySelector("#native-checked-text").innerHTML =
|
447
|
+
ev.target.checked;
|
448
|
+
}
|
449
|
+
document
|
450
|
+
.querySelector("#indeterminate-button")
|
451
|
+
.addEventListener("click", toggleIndeterminate);
|
452
|
+
document
|
453
|
+
.querySelector("#indeterminate-checkbox")
|
454
|
+
.addEventListener("icCheck", icCheckHandler);
|
455
|
+
document
|
456
|
+
.querySelector("#native-indeterminate-button")
|
457
|
+
.addEventListener("click", toggleNativeIndeterminate);
|
458
|
+
document
|
459
|
+
.querySelector("#native-indeterminate-checkbox")
|
460
|
+
.addEventListener("icCheck", icCheckHandlerNative);
|
461
|
+
</script>
|
462
|
+
<div style="display:flex;gap:16px;flex-wrap:wrap">
|
463
|
+
<div style="border:1px solid gray;padding:8px;">
|
464
|
+
<ic-checkbox-group
|
465
|
+
label="'native-indeterminate-behavior'=false"
|
466
|
+
name="indeterminate"
|
467
|
+
>
|
468
|
+
<ic-checkbox
|
469
|
+
id="indeterminate-checkbox"
|
470
|
+
value="indeterminate"
|
471
|
+
label="Indeterminate checkbox"
|
472
|
+
checked="true"
|
473
|
+
indeterminate="true"
|
474
|
+
>
|
475
|
+
</ic-checkbox>
|
476
|
+
</ic-checkbox-group>
|
477
|
+
<br />
|
478
|
+
<ic-button id="indeterminate-button">Toggle indeterminate</ic-button>
|
479
|
+
<br />
|
480
|
+
<br />
|
481
|
+
<span>Indeterminate: <span id="indeterminate-text"></span></span>
|
482
|
+
<br />
|
483
|
+
<span>Checked: <span id="checked-text"></span></span>
|
484
|
+
</div>
|
485
|
+
<div style="border:1px solid gray;padding:8px;">
|
486
|
+
<ic-checkbox-group
|
487
|
+
label="'native-indeterminate-behavior'=true"
|
488
|
+
name="native_indeterminate"
|
489
|
+
>
|
490
|
+
<ic-checkbox
|
491
|
+
id="native-indeterminate-checkbox"
|
492
|
+
value="indeterminate"
|
493
|
+
label="Indeterminate checkbox"
|
494
|
+
checked="true"
|
495
|
+
indeterminate="true"
|
496
|
+
native-indeterminate-behaviour="true"
|
497
|
+
>
|
498
|
+
</ic-checkbox>
|
499
|
+
</ic-checkbox-group>
|
500
|
+
<br />
|
501
|
+
<ic-button id="native-indeterminate-button"
|
502
|
+
>Toggle indeterminate</ic-button
|
503
|
+
>
|
504
|
+
<br />
|
505
|
+
<br />
|
506
|
+
<span>Indeterminate: <span id="native-indeterminate-text"></span></span>
|
507
|
+
<br />
|
508
|
+
<span>Checked: <span id="native-checked-text"></span></span>
|
509
|
+
</div>
|
510
|
+
</div>
|
511
|
+
`,
|
512
|
+
|
513
|
+
name: "Indeterminate",
|
514
|
+
};
|
515
|
+
|
516
|
+
export const IndeterminateWithChildren = {
|
517
|
+
render: (args) => html`
|
518
|
+
<script>
|
519
|
+
var drinksCheckbox = document.querySelector("#drinks-checkbox");
|
520
|
+
var teaCheckbox = document.querySelector("#tea-checkbox");
|
521
|
+
var coffeeCheckbox = document.querySelector("#coffee-checkbox");
|
522
|
+
var juiceCheckbox = document.querySelector("#juice-checkbox");
|
523
|
+
var drinksGroup = document.querySelector("#drinks-group");
|
524
|
+
drinksCheckbox.addEventListener("icCheck", function (ev) {
|
525
|
+
if (ev.target === drinksCheckbox) {
|
526
|
+
teaCheckbox.checked = drinksCheckbox.checked;
|
527
|
+
coffeeCheckbox.checked = drinksCheckbox.checked;
|
528
|
+
juiceCheckbox.checked = drinksCheckbox.checked;
|
529
|
+
}
|
530
|
+
});
|
531
|
+
drinksGroup.addEventListener("icChange", function (ev) {
|
532
|
+
if (ev.detail.checkedOptions.length === 3) {
|
533
|
+
drinksCheckbox.indeterminate = false;
|
534
|
+
drinksCheckbox.checked = true;
|
535
|
+
} else if (ev.detail.checkedOptions.length === 0) {
|
536
|
+
drinksCheckbox.indeterminate = false;
|
537
|
+
drinksCheckbox.checked = false;
|
538
|
+
} else {
|
539
|
+
drinksCheckbox.indeterminate = true;
|
540
|
+
drinksCheckbox.checked = false;
|
541
|
+
}
|
542
|
+
});
|
543
|
+
coffeeCheckbox.checked = true;
|
544
|
+
drinksCheckbox.indeterminate = true;
|
545
|
+
</script>
|
546
|
+
<ic-checkbox-group label="Liked things" name="1">
|
547
|
+
<ic-checkbox
|
548
|
+
id="drinks-checkbox"
|
549
|
+
value="drinks"
|
550
|
+
label="Drinks"
|
551
|
+
indeterminate="false"
|
552
|
+
native-indeterminate-behaviour
|
553
|
+
>
|
554
|
+
<ic-checkbox-group
|
555
|
+
id="drinks-group"
|
556
|
+
name="2"
|
557
|
+
label="Drinks"
|
558
|
+
hide-label
|
559
|
+
slot="additional-field"
|
560
|
+
>
|
561
|
+
<ic-checkbox id="tea-checkbox" value="tea" label="Tea"></ic-checkbox>
|
562
|
+
<ic-checkbox
|
563
|
+
id="coffee-checkbox"
|
564
|
+
value="coffee"
|
565
|
+
label="Coffee"
|
566
|
+
></ic-checkbox>
|
567
|
+
<ic-checkbox
|
568
|
+
id="juice-checkbox"
|
569
|
+
value="juice"
|
570
|
+
label="Juice"
|
571
|
+
></ic-checkbox>
|
572
|
+
</ic-checkbox-group>
|
573
|
+
</ic-checkbox>
|
574
|
+
</ic-checkbox-group>
|
575
|
+
`,
|
576
|
+
|
577
|
+
name: "Indeterminate with children",
|
578
|
+
};
|
579
|
+
|
580
|
+
export const TextFieldValueChange = {
|
581
|
+
render: (args) => html`
|
582
|
+
<script>
|
583
|
+
var textOutputEl = document.querySelector("#value-text");
|
584
|
+
function handleIcChange(ev) {
|
585
|
+
textOutputEl.innerHTML = ev.target.value;
|
586
|
+
}
|
587
|
+
document
|
588
|
+
.querySelector("ic-text-field")
|
589
|
+
.addEventListener("icChange", handleIcChange);
|
590
|
+
</script>
|
591
|
+
<div>
|
592
|
+
<ic-checkbox-group label="This is a label" name="group1">
|
593
|
+
<ic-checkbox
|
594
|
+
value="valueName1"
|
595
|
+
label="Unselected / Default"
|
596
|
+
additional-field-display="static"
|
597
|
+
>
|
598
|
+
<ic-text-field
|
599
|
+
slot="additional-field"
|
600
|
+
placeholder="Placeholder"
|
601
|
+
label="What's your favourite type of coffee?"
|
602
|
+
></ic-text-field>
|
603
|
+
</ic-checkbox>
|
604
|
+
</ic-checkbox-group>
|
605
|
+
<br />
|
606
|
+
<span>textfield value: </span>
|
607
|
+
<span id="value-text"></span>
|
608
|
+
<div></div>
|
609
|
+
</div>
|
610
|
+
`,
|
611
|
+
|
612
|
+
name: "TextField value change",
|
613
|
+
};
|
614
|
+
|
615
|
+
export const Playground = {
|
616
|
+
render: (args) => {
|
617
|
+
const [{ checked }, updateArgs] = useArgs();
|
618
|
+
|
619
|
+
return html` <ic-checkbox-group
|
620
|
+
disabled=${args.disabled}
|
621
|
+
label=${args.groupLabel}
|
622
|
+
size=${args.size}
|
623
|
+
helper-text=${args.helperText}
|
624
|
+
hide-label=${args.hideGroupLabel}
|
625
|
+
required=${args.required}
|
626
|
+
validation-status=${args.validationStatus}
|
627
|
+
validation-text=${args.validationText}
|
628
|
+
>
|
629
|
+
<ic-checkbox
|
630
|
+
disabled=${args.disabled}
|
631
|
+
label=${args.label}
|
632
|
+
value=${args.value}
|
633
|
+
size=${args.size}
|
634
|
+
hide-label=${args.hideLabel}
|
635
|
+
indeterminate=${args.indeterminate}
|
636
|
+
checked=${checked}
|
637
|
+
additional-field-display=${args.additionalFieldDisplay}
|
638
|
+
dynamic-text=${args.dynamicText}
|
639
|
+
native-indeterminate-behaviour=${args.nativeIndeterminateBehaviour}
|
640
|
+
>
|
641
|
+
<ic-text-field
|
642
|
+
slot=${args.additionalFieldSlot}
|
643
|
+
placeholder="Placeholder"
|
644
|
+
label="What's your favourite type of coffee?"
|
645
|
+
></ic-text-field>
|
646
|
+
</ic-checkbox>
|
647
|
+
</ic-checkbox-group>`;
|
648
|
+
},
|
649
|
+
|
650
|
+
args: defaultArgs,
|
651
|
+
|
652
|
+
argTypes: {
|
653
|
+
additionalFieldDisplay: {
|
654
|
+
options: ["dynamic", "static"],
|
655
|
+
|
656
|
+
control: {
|
657
|
+
type: "inline-radio",
|
658
|
+
},
|
659
|
+
},
|
660
|
+
|
661
|
+
additionalFieldSlot: {
|
662
|
+
options: ["additional-field", ""],
|
663
|
+
|
664
|
+
control: {
|
665
|
+
type: "select",
|
666
|
+
},
|
667
|
+
},
|
668
|
+
|
669
|
+
size: {
|
670
|
+
options: ["default", "large", "small"],
|
671
|
+
|
672
|
+
control: {
|
673
|
+
type: "inline-radio",
|
674
|
+
},
|
675
|
+
},
|
676
|
+
|
677
|
+
validationStatus: {
|
678
|
+
options: ["warning", "error", "success", ""],
|
679
|
+
|
680
|
+
control: {
|
681
|
+
type: "select",
|
682
|
+
},
|
683
|
+
},
|
684
|
+
},
|
685
|
+
|
686
|
+
name: "Playground",
|
687
|
+
};
|