@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,780 @@
|
|
1
|
+
import { html } from "lit-html";
|
2
|
+
|
3
|
+
const defaultArgs = {
|
4
|
+
disabled: false,
|
5
|
+
["full-width"]: false,
|
6
|
+
["helper-text"]: "Select one option from the list",
|
7
|
+
["hide-label"]: false,
|
8
|
+
loading: false,
|
9
|
+
loadingLabel: "Loading...",
|
10
|
+
label: "What is your favourite coffee?",
|
11
|
+
placeholder: "Select an option",
|
12
|
+
readonly: false,
|
13
|
+
required: false,
|
14
|
+
size: "default",
|
15
|
+
["validation-status"]: "none",
|
16
|
+
["validation-text"]: "",
|
17
|
+
["show-clear-button"]: false,
|
18
|
+
};
|
19
|
+
|
20
|
+
export default {
|
21
|
+
title: "Web Components/Select/Single",
|
22
|
+
component: "ic-select",
|
23
|
+
};
|
24
|
+
|
25
|
+
export const Default = {
|
26
|
+
render: (args) =>
|
27
|
+
html`<ic-select
|
28
|
+
id="select-default"
|
29
|
+
label="What is your favourite coffee?"
|
30
|
+
></ic-select>
|
31
|
+
<script>
|
32
|
+
var select = document.querySelector("#select-default");
|
33
|
+
select.options = [
|
34
|
+
{ label: "Cappuccino", value: "Cap" },
|
35
|
+
{ label: "Latte", value: "Lat" },
|
36
|
+
{ label: "Americano", value: "Ame" },
|
37
|
+
];
|
38
|
+
select.addEventListener("icChange", function (event) {
|
39
|
+
console.log("icChange: " + event.detail.value);
|
40
|
+
});
|
41
|
+
select.addEventListener("icOptionSelect", function (event) {
|
42
|
+
console.log("icOptionSelect: " + event.detail.value);
|
43
|
+
});
|
44
|
+
select.addEventListener("icOpen", function () {
|
45
|
+
console.log("select dropdown opened");
|
46
|
+
});
|
47
|
+
select.addEventListener("icClose", function () {
|
48
|
+
console.log("select dropdown closed");
|
49
|
+
});
|
50
|
+
</script>`,
|
51
|
+
|
52
|
+
name: "Default",
|
53
|
+
};
|
54
|
+
|
55
|
+
export const AsyncDefault = {
|
56
|
+
render: (args) =>
|
57
|
+
html`<ic-select
|
58
|
+
label="What is your favourite coffee?"
|
59
|
+
loading
|
60
|
+
id="select-async"
|
61
|
+
></ic-select>
|
62
|
+
<script>
|
63
|
+
var select = document.querySelector("#select-async");
|
64
|
+
select.options = [];
|
65
|
+
setTimeout(() => {
|
66
|
+
select.options = [
|
67
|
+
{ label: "Cappuccino", value: "Cap" },
|
68
|
+
{ label: "Latte", value: "Lat" },
|
69
|
+
{ label: "Americano", value: "Ame" },
|
70
|
+
{ label: "Filter", value: "Fil" },
|
71
|
+
{ label: "Flat white", value: "Fla" },
|
72
|
+
{ label: "Mocha", value: "Moc" },
|
73
|
+
{ label: "Macchiato", value: "Mac" },
|
74
|
+
];
|
75
|
+
}, 5000);
|
76
|
+
select.addEventListener("icChange", function (event) {
|
77
|
+
console.log("icChange: " + event.detail.value);
|
78
|
+
});
|
79
|
+
</script>`,
|
80
|
+
|
81
|
+
name: "Async default",
|
82
|
+
};
|
83
|
+
|
84
|
+
export const DefaultValue = {
|
85
|
+
render: (args) =>
|
86
|
+
html`<ic-select
|
87
|
+
id="select-default-value"
|
88
|
+
label="What is your favourite coffee?"
|
89
|
+
></ic-select>
|
90
|
+
<script>
|
91
|
+
var select = document.querySelector("#select-default-value");
|
92
|
+
select.value = "Cap";
|
93
|
+
select.options = [
|
94
|
+
{ label: "Cappuccino", value: "Cap" },
|
95
|
+
{ label: "Latte", value: "Lat" },
|
96
|
+
{ label: "Americano", value: "Ame" },
|
97
|
+
];
|
98
|
+
select.addEventListener("icChange", function (event) {
|
99
|
+
console.log("icChange: " + event.detail.value);
|
100
|
+
});
|
101
|
+
</script>`,
|
102
|
+
|
103
|
+
name: "Default value",
|
104
|
+
};
|
105
|
+
|
106
|
+
export const WithClearButton = {
|
107
|
+
render: (args) =>
|
108
|
+
html`<ic-select
|
109
|
+
id="select-clear"
|
110
|
+
label="What is your favourite coffee?"
|
111
|
+
show-clear-button
|
112
|
+
></ic-select>
|
113
|
+
<script>
|
114
|
+
var select = document.querySelector("#select-clear");
|
115
|
+
select.options = [
|
116
|
+
{ label: "Cappuccino", value: "Cap" },
|
117
|
+
{ label: "Latte", value: "Lat" },
|
118
|
+
{ label: "Americano", value: "Ame" },
|
119
|
+
];
|
120
|
+
select.addEventListener("icChange", function (event) {
|
121
|
+
console.log("icChange: " + event.detail.value);
|
122
|
+
});
|
123
|
+
</script>`,
|
124
|
+
|
125
|
+
name: "With clear button",
|
126
|
+
};
|
127
|
+
|
128
|
+
export const WithDescriptions = {
|
129
|
+
render: (args) =>
|
130
|
+
html`<ic-select
|
131
|
+
id="select-descriptions"
|
132
|
+
label="What is your favourite coffee?"
|
133
|
+
></ic-select>
|
134
|
+
<script>
|
135
|
+
var select = document.querySelector("#select-descriptions");
|
136
|
+
select.options = [
|
137
|
+
{
|
138
|
+
label: "Cappuccino",
|
139
|
+
value: "Cap",
|
140
|
+
description: "Coffee frothed up with pressurised steam",
|
141
|
+
},
|
142
|
+
{
|
143
|
+
label: "Latte",
|
144
|
+
value: "Lat",
|
145
|
+
description: "A milkier coffee than a cappuccino",
|
146
|
+
},
|
147
|
+
{
|
148
|
+
label: "Americano",
|
149
|
+
value: "Ame",
|
150
|
+
description: "Espresso coffee diluted with hot water",
|
151
|
+
},
|
152
|
+
];
|
153
|
+
select.addEventListener("icChange", function (event) {
|
154
|
+
console.log("icChange: " + event.detail.value);
|
155
|
+
});
|
156
|
+
</script>`,
|
157
|
+
|
158
|
+
name: "With descriptions",
|
159
|
+
};
|
160
|
+
|
161
|
+
export const HelperText = {
|
162
|
+
render: (args) =>
|
163
|
+
html`<ic-select
|
164
|
+
id="select-helper"
|
165
|
+
label="What is your favourite coffee?"
|
166
|
+
helper-text="Select one option from the list"
|
167
|
+
></ic-select>
|
168
|
+
<script>
|
169
|
+
var select = document.querySelector("#select-helper");
|
170
|
+
select.options = [
|
171
|
+
{ label: "Cappuccino", value: "Cap" },
|
172
|
+
{ label: "Latte", value: "Lat" },
|
173
|
+
{ label: "Americano", value: "Ame" },
|
174
|
+
];
|
175
|
+
select.addEventListener("icChange", function (event) {
|
176
|
+
console.log("icChange: " + event.detail.value);
|
177
|
+
});
|
178
|
+
</script>`,
|
179
|
+
|
180
|
+
name: "Helper text",
|
181
|
+
};
|
182
|
+
|
183
|
+
export const CustomPlaceholder = {
|
184
|
+
render: (args) =>
|
185
|
+
html`<ic-select
|
186
|
+
id="select-7"
|
187
|
+
label="What is your favourite coffee?"
|
188
|
+
placeholder="Placeholder goes here"
|
189
|
+
></ic-select>
|
190
|
+
<script>
|
191
|
+
var select = document.querySelector("#select-7");
|
192
|
+
select.options = [
|
193
|
+
{ label: "Cappuccino", value: "Cap" },
|
194
|
+
{ label: "Latte", value: "Lat" },
|
195
|
+
{ label: "Americano", value: "Ame" },
|
196
|
+
];
|
197
|
+
select.addEventListener("icChange", function (event) {
|
198
|
+
console.log("icChange: " + event.detail.value);
|
199
|
+
});
|
200
|
+
</script>`,
|
201
|
+
|
202
|
+
name: "Custom placeholder",
|
203
|
+
};
|
204
|
+
|
205
|
+
export const CustomComponents = {
|
206
|
+
render: (args) =>
|
207
|
+
html`<ic-select
|
208
|
+
id="select-1"
|
209
|
+
label="What is your favourite coffee?"
|
210
|
+
></ic-select>
|
211
|
+
<script>
|
212
|
+
var select = document.querySelector("#select-1");
|
213
|
+
select.options = [
|
214
|
+
{ label: "Cappuccino", value: "Cap" },
|
215
|
+
{
|
216
|
+
label: "Latte",
|
217
|
+
value: "Lat",
|
218
|
+
description: "A milkier coffee than a cappuccino",
|
219
|
+
element: {
|
220
|
+
component: \`<ic-status-tag label="Neutral status"></ic-status-tag>\`,
|
221
|
+
ariaLabel: "Neutral status tag",
|
222
|
+
},
|
223
|
+
icon: \`<svg aria-labelledby="warning-title" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000000"><g id="warning"><path id="Vector" d="M4.47 20.5037H19.53C21.07 20.5037 22.03 18.8337 21.26 17.5037L13.73 4.49375C12.96 3.16375 11.04 3.16375 10.27 4.49375L2.74 17.5037C1.97 18.8337 2.93 20.5037 4.47 20.5037ZM12 13.5037C11.45 13.5037 11 13.0537 11 12.5037V10.5037C11 9.95375 11.45 9.50375 12 9.50375C12.55 9.50375 13 9.95375 13 10.5037V12.5037C13 13.0537 12.55 13.5037 12 13.5037ZM13 17.5037H11V15.5037H13V17.5037Z" /></g></svg>\`,
|
224
|
+
},
|
225
|
+
{
|
226
|
+
label: "Americano",
|
227
|
+
value: "Ame",
|
228
|
+
icon: \`<svg aria-labelledby="warning-title" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000000">
|
229
|
+
<g id="warning">
|
230
|
+
<path id="Vector" d="M4.47 20.5037H19.53C21.07 20.5037 22.03 18.8337 21.26 17.5037L13.73 4.49375C12.96 3.16375 11.04 3.16375 10.27 4.49375L2.74 17.5037C1.97 18.8337 2.93 20.5037 4.47 20.5037ZM12 13.5037C11.45 13.5037 11 13.0537 11 12.5037V10.5037C11 9.95375 11.45 9.50375 12 9.50375C12.55 9.50375 13 9.95375 13 10.5037V12.5037C13 13.0537 12.55 13.5037 12 13.5037ZM13 17.5037H11V15.5037H13V17.5037Z" />
|
231
|
+
</g>
|
232
|
+
</svg>\`,
|
233
|
+
},
|
234
|
+
];
|
235
|
+
select.addEventListener("icChange", function (event) {
|
236
|
+
console.log("icChange: " + event.detail.value);
|
237
|
+
});
|
238
|
+
</script>`,
|
239
|
+
|
240
|
+
name: "Custom components",
|
241
|
+
};
|
242
|
+
|
243
|
+
export const Sizes = {
|
244
|
+
render: (args) =>
|
245
|
+
html`<div style="display: flex; flex-direction: column; gap: 16px;">
|
246
|
+
<ic-select
|
247
|
+
id="select-size-small"
|
248
|
+
label="What is your favourite coffee?"
|
249
|
+
size="small"
|
250
|
+
></ic-select>
|
251
|
+
<script>
|
252
|
+
var select = document.querySelector("#select-size-small");
|
253
|
+
select.options = [
|
254
|
+
{ label: "Cappuccino", value: "Cap" },
|
255
|
+
{ label: "Latte", value: "Lat" },
|
256
|
+
{ label: "Americano", value: "Ame" },
|
257
|
+
{ label: "Filter", value: "Fil" },
|
258
|
+
{ label: "Flat white", value: "Fla" },
|
259
|
+
{ label: "Mocha", value: "Moc" },
|
260
|
+
{ label: "Macchiato", value: "Mac" },
|
261
|
+
];
|
262
|
+
select.addEventListener("icChange", function (event) {
|
263
|
+
console.log("icChange: " + event.detail.value);
|
264
|
+
});
|
265
|
+
</script>
|
266
|
+
<ic-select
|
267
|
+
id="select-size-default"
|
268
|
+
label="What is your favourite coffee?"
|
269
|
+
></ic-select>
|
270
|
+
<script>
|
271
|
+
var select = document.querySelector("#select-size-default");
|
272
|
+
select.options = [
|
273
|
+
{ label: "Cappuccino", value: "Cap" },
|
274
|
+
{ label: "Latte", value: "Lat" },
|
275
|
+
{ label: "Americano", value: "Ame" },
|
276
|
+
{ label: "Filter", value: "Fil" },
|
277
|
+
{ label: "Flat white", value: "Fla" },
|
278
|
+
{ label: "Mocha", value: "Moc" },
|
279
|
+
{ label: "Macchiato", value: "Mac" },
|
280
|
+
];
|
281
|
+
select.addEventListener("icChange", function (event) {
|
282
|
+
console.log("icChange: " + event.detail.value);
|
283
|
+
});
|
284
|
+
</script>
|
285
|
+
<ic-select
|
286
|
+
id="select-size-large"
|
287
|
+
label="What is your favourite coffee?"
|
288
|
+
size="large"
|
289
|
+
></ic-select>
|
290
|
+
<script>
|
291
|
+
var select = document.querySelector("#select-size-large");
|
292
|
+
select.options = [
|
293
|
+
{ label: "Cappuccino", value: "Cap" },
|
294
|
+
{ label: "Latte", value: "Lat" },
|
295
|
+
{ label: "Americano", value: "Ame" },
|
296
|
+
{ label: "Filter", value: "Fil" },
|
297
|
+
{ label: "Flat white", value: "Fla" },
|
298
|
+
{ label: "Mocha", value: "Moc" },
|
299
|
+
{ label: "Macchiato", value: "Mac" },
|
300
|
+
];
|
301
|
+
select.addEventListener("icChange", function (event) {
|
302
|
+
console.log("icChange: " + event.detail.value);
|
303
|
+
});
|
304
|
+
</script>
|
305
|
+
</div>`,
|
306
|
+
|
307
|
+
name: "Sizes",
|
308
|
+
};
|
309
|
+
|
310
|
+
export const Disabled = {
|
311
|
+
render: (args) =>
|
312
|
+
html`<ic-select
|
313
|
+
id="select-disabled"
|
314
|
+
label="What is your favourite coffee?"
|
315
|
+
disabled
|
316
|
+
></ic-select>
|
317
|
+
<script>
|
318
|
+
var select = document.querySelector("#select-disabled");
|
319
|
+
select.options = [
|
320
|
+
{ label: "Cappuccino", value: "Cap" },
|
321
|
+
{ label: "Latte", value: "Lat" },
|
322
|
+
{ label: "Americano", value: "Ame" },
|
323
|
+
];
|
324
|
+
select.addEventListener("icChange", function (event) {
|
325
|
+
console.log("icChange: " + event.detail.value);
|
326
|
+
});
|
327
|
+
</script>`,
|
328
|
+
|
329
|
+
name: "Disabled",
|
330
|
+
};
|
331
|
+
|
332
|
+
export const DisabledOptions = {
|
333
|
+
render: (args) =>
|
334
|
+
html`<ic-select
|
335
|
+
id="select-disabled-options"
|
336
|
+
label="What is your favourite coffee?"
|
337
|
+
></ic-select>
|
338
|
+
<script>
|
339
|
+
var select = document.querySelector("#select-disabled-options");
|
340
|
+
select.options = [
|
341
|
+
{ label: "Cappuccino", value: "Cap" },
|
342
|
+
{ label: "Latte", value: "Lat", disabled: true },
|
343
|
+
{ label: "Americano", value: "Ame" },
|
344
|
+
];
|
345
|
+
select.addEventListener("icChange", function (event) {
|
346
|
+
console.log("icChange: " + event.detail.value);
|
347
|
+
});
|
348
|
+
</script>`,
|
349
|
+
|
350
|
+
name: "Disabled options",
|
351
|
+
};
|
352
|
+
|
353
|
+
export const FullWidth = {
|
354
|
+
render: (args) =>
|
355
|
+
html`<ic-select
|
356
|
+
id="select-full-width"
|
357
|
+
label="What is your favourite coffee?"
|
358
|
+
full-width
|
359
|
+
></ic-select>
|
360
|
+
<script>
|
361
|
+
var select = document.querySelector("#select-full-width");
|
362
|
+
select.options = [
|
363
|
+
{ label: "Cappuccino", value: "Cap" },
|
364
|
+
{ label: "Latte", value: "Lat" },
|
365
|
+
{ label: "Americano", value: "Ame" },
|
366
|
+
];
|
367
|
+
select.addEventListener("icChange", function (event) {
|
368
|
+
console.log("icChange: " + event.detail.value);
|
369
|
+
});
|
370
|
+
</script>`,
|
371
|
+
|
372
|
+
name: "Full width",
|
373
|
+
};
|
374
|
+
|
375
|
+
export const HiddenLabel = {
|
376
|
+
render: (args) =>
|
377
|
+
html`<ic-select
|
378
|
+
id="select-hidden-label"
|
379
|
+
label="What is your favourite coffee?"
|
380
|
+
hide-label
|
381
|
+
></ic-select>
|
382
|
+
<script>
|
383
|
+
var select = document.querySelector("#select-hidden-label");
|
384
|
+
select.options = [
|
385
|
+
{ label: "Cappuccino", value: "Cap" },
|
386
|
+
{ label: "Latte", value: "Lat" },
|
387
|
+
{ label: "Americano", value: "Ame" },
|
388
|
+
];
|
389
|
+
select.addEventListener("icChange", function (event) {
|
390
|
+
console.log("icChange: " + event.detail.value);
|
391
|
+
});
|
392
|
+
</script>`,
|
393
|
+
|
394
|
+
name: "Hidden label",
|
395
|
+
};
|
396
|
+
|
397
|
+
export const Required = {
|
398
|
+
render: (args) =>
|
399
|
+
html`<ic-select
|
400
|
+
id="select-required"
|
401
|
+
label="What is your favourite coffee?"
|
402
|
+
required
|
403
|
+
></ic-select>
|
404
|
+
<script>
|
405
|
+
var select = document.querySelector("#select-required");
|
406
|
+
select.options = [
|
407
|
+
{ label: "Cappuccino", value: "Cap" },
|
408
|
+
{ label: "Latte", value: "Lat" },
|
409
|
+
{ label: "Americano", value: "Ame" },
|
410
|
+
];
|
411
|
+
select.addEventListener("icChange", function (event) {
|
412
|
+
console.log("icChange: " + event.detail.value);
|
413
|
+
});
|
414
|
+
</script>`,
|
415
|
+
|
416
|
+
name: "Required",
|
417
|
+
};
|
418
|
+
|
419
|
+
export const ReadOnly = {
|
420
|
+
render: () =>
|
421
|
+
html`<ic-select
|
422
|
+
id="select-read-only"
|
423
|
+
label="What is your favourite coffee?"
|
424
|
+
readonly
|
425
|
+
value="Cap"
|
426
|
+
></ic-select>
|
427
|
+
<script>
|
428
|
+
var select = document.querySelector("#select-read-only");
|
429
|
+
select.options = [
|
430
|
+
{ label: "Cappuccino", value: "Cap" },
|
431
|
+
{ label: "Latte", value: "Lat" },
|
432
|
+
{ label: "Americano", value: "Ame" },
|
433
|
+
];
|
434
|
+
select.addEventListener("icChange", function (event) {
|
435
|
+
console.log("icChange: " + event.detail.value);
|
436
|
+
});
|
437
|
+
</script>`,
|
438
|
+
|
439
|
+
name: "Read-only",
|
440
|
+
};
|
441
|
+
|
442
|
+
export const Groups = {
|
443
|
+
render: (args) =>
|
444
|
+
html`<ic-select
|
445
|
+
id="select-groups"
|
446
|
+
label="What is your favourite coffee?"
|
447
|
+
></ic-select>
|
448
|
+
<script>
|
449
|
+
var select = document.querySelector("#select-groups");
|
450
|
+
select.options = [
|
451
|
+
{
|
452
|
+
label: "Fancy",
|
453
|
+
children: [
|
454
|
+
{ label: "Cappuccino", value: "Cap" },
|
455
|
+
{ label: "Flat white", value: "Fla" },
|
456
|
+
],
|
457
|
+
},
|
458
|
+
{
|
459
|
+
label: "Boring",
|
460
|
+
children: [
|
461
|
+
{ label: "Filter", value: "Fil" },
|
462
|
+
{ label: "Latte", value: "Lat" },
|
463
|
+
],
|
464
|
+
},
|
465
|
+
];
|
466
|
+
select.value = "Lat";
|
467
|
+
select.addEventListener("icChange", function (event) {
|
468
|
+
console.log("icChange: " + event.detail.value);
|
469
|
+
});
|
470
|
+
</script>`,
|
471
|
+
|
472
|
+
name: "Groups",
|
473
|
+
};
|
474
|
+
|
475
|
+
export const Recommended = {
|
476
|
+
render: (args) =>
|
477
|
+
html`<ic-select
|
478
|
+
id="select-recommended"
|
479
|
+
label="What is your favourite coffee?"
|
480
|
+
></ic-select>
|
481
|
+
<script>
|
482
|
+
var select = document.querySelector("#select-recommended");
|
483
|
+
select.options = [
|
484
|
+
{ label: "Cappuccino", value: "Cappuccino" },
|
485
|
+
{ label: "Flat white", value: "Flat white", recommended: true },
|
486
|
+
{ label: "Latte", value: "Latte" },
|
487
|
+
{ label: "Americano", value: "Americano", recommended: true },
|
488
|
+
{ label: "Filter", value: "Fil" },
|
489
|
+
];
|
490
|
+
select.addEventListener("icChange", function (event) {
|
491
|
+
console.log("icChange: " + event.detail.value);
|
492
|
+
});
|
493
|
+
</script>`,
|
494
|
+
|
495
|
+
name: "Recommended",
|
496
|
+
};
|
497
|
+
|
498
|
+
export const Validation = {
|
499
|
+
render: (args) =>
|
500
|
+
html`<ic-select
|
501
|
+
id="select-success"
|
502
|
+
label="What is your favourite coffee?"
|
503
|
+
validation-status="success"
|
504
|
+
validation-text="Coffee available"
|
505
|
+
></ic-select>
|
506
|
+
<script>
|
507
|
+
var select1 = document.querySelector("#select-success");
|
508
|
+
var option1 = "Cappuccino";
|
509
|
+
select1.options = [
|
510
|
+
{ label: "Cappuccino", value: "Cap" },
|
511
|
+
{ label: "Latte", value: "Lat" },
|
512
|
+
{ label: "Americano", value: "Ame" },
|
513
|
+
];
|
514
|
+
select1.addEventListener("icChange", function (event) {
|
515
|
+
console.log("icChange: " + event.detail.value);
|
516
|
+
});
|
517
|
+
</script>
|
518
|
+
<ic-select
|
519
|
+
id="select-warning"
|
520
|
+
label="What is your favourite coffee?"
|
521
|
+
validation-status="warning"
|
522
|
+
validation-text="Only a few left"
|
523
|
+
></ic-select>
|
524
|
+
<script>
|
525
|
+
var select2 = document.querySelector("#select-warning");
|
526
|
+
var option2 = "Cappuccino";
|
527
|
+
select2.options = [
|
528
|
+
{ label: "Cappuccino", value: "Cap" },
|
529
|
+
{ label: "Latte", value: "Lat" },
|
530
|
+
{ label: "Americano", value: "Ame" },
|
531
|
+
];
|
532
|
+
select2.addEventListener("icChange", function (event) {
|
533
|
+
console.log("icChange: " + event.detail.value);
|
534
|
+
});
|
535
|
+
</script>
|
536
|
+
<ic-select
|
537
|
+
id="select-error"
|
538
|
+
label="What is your favourite coffee?"
|
539
|
+
validation-status="error"
|
540
|
+
validation-text="Coffee unavailable"
|
541
|
+
></ic-select>
|
542
|
+
<script>
|
543
|
+
var select3 = document.querySelector("#select-error");
|
544
|
+
var option3 = "Cappuccino";
|
545
|
+
select3.options = [
|
546
|
+
{ label: "Cappuccino", value: "Cap" },
|
547
|
+
{ label: "Latte", value: "Lat" },
|
548
|
+
{ label: "Americano", value: "Ame" },
|
549
|
+
];
|
550
|
+
select3.addEventListener("icChange", function (event) {
|
551
|
+
console.log("icChange: " + event.detail.value);
|
552
|
+
});
|
553
|
+
</script>`,
|
554
|
+
|
555
|
+
name: "Validation",
|
556
|
+
};
|
557
|
+
|
558
|
+
export const ScrollBehaviour = {
|
559
|
+
render: (args) =>
|
560
|
+
html`<ic-select
|
561
|
+
id="select-scroll"
|
562
|
+
label="What is your favourite coffee?"
|
563
|
+
></ic-select>
|
564
|
+
<script>
|
565
|
+
var select = document.querySelector("#select-scroll");
|
566
|
+
select.options = [
|
567
|
+
{ label: "Cappuccino", value: "Cap" },
|
568
|
+
{ label: "Latte", value: "Lat" },
|
569
|
+
{ label: "Americano", value: "Ame" },
|
570
|
+
{ label: "Filter", value: "Fil" },
|
571
|
+
{ label: "Flat white", value: "Fla" },
|
572
|
+
{ label: "Mocha", value: "Moc" },
|
573
|
+
{ label: "Macchiato", value: "Mac" },
|
574
|
+
{ label: "Café au lait", value: "Caf" },
|
575
|
+
{ label: "Espresso", value: "Esp" },
|
576
|
+
{ label: "Cortado", value: "Cor" },
|
577
|
+
{ label: "Ristretto", value: "Ris" },
|
578
|
+
{ label: "Latte macchiato", value: "Lam" },
|
579
|
+
];
|
580
|
+
select.addEventListener("icChange", function (event) {
|
581
|
+
console.log("icChange: " + event.detail.value);
|
582
|
+
});
|
583
|
+
</script>`,
|
584
|
+
|
585
|
+
name: "Scroll behaviour",
|
586
|
+
};
|
587
|
+
|
588
|
+
export const LoadingWithError = {
|
589
|
+
render: (args) =>
|
590
|
+
html`<ic-select
|
591
|
+
id="select-loading"
|
592
|
+
label="What is your favourite coffee?"
|
593
|
+
loading
|
594
|
+
timeout="1000"
|
595
|
+
></ic-select>
|
596
|
+
<script>
|
597
|
+
var select = document.querySelector("#select-loading");
|
598
|
+
select.addEventListener("icChange", function (event) {
|
599
|
+
console.log("icChange: " + event.detail.value);
|
600
|
+
});
|
601
|
+
select.addEventListener("icRetryLoad", function (event) {
|
602
|
+
select.loading = "true";
|
603
|
+
});
|
604
|
+
</script>`,
|
605
|
+
|
606
|
+
name: "Loading with error",
|
607
|
+
};
|
608
|
+
|
609
|
+
export const InForm = {
|
610
|
+
render: (args) => html`
|
611
|
+
<form>
|
612
|
+
<ic-select
|
613
|
+
id="select-form"
|
614
|
+
label="What is your favourite coffee?"
|
615
|
+
></ic-select>
|
616
|
+
<br />
|
617
|
+
<br />
|
618
|
+
<input type="submit" value="Submit" />
|
619
|
+
<input type="reset" value="Reset" />
|
620
|
+
</form>
|
621
|
+
<script>
|
622
|
+
var select = document.querySelector("#select-form");
|
623
|
+
select.options = [
|
624
|
+
{ label: "Cappuccino", value: "Cap" },
|
625
|
+
{ label: "Latte", value: "Lat" },
|
626
|
+
{ label: "Americano", value: "Ame" },
|
627
|
+
];
|
628
|
+
select.addEventListener("icChange", function (event) {
|
629
|
+
console.log("icChange: " + event.detail.value);
|
630
|
+
});
|
631
|
+
document.querySelector("form").addEventListener("submit", (ev) => {
|
632
|
+
ev.preventDefault();
|
633
|
+
console.log(document.querySelector("input.ic-input").value);
|
634
|
+
});
|
635
|
+
</script>
|
636
|
+
`,
|
637
|
+
|
638
|
+
name: "In form",
|
639
|
+
};
|
640
|
+
|
641
|
+
export const EmittingIcOptionSelectOnEnter = {
|
642
|
+
render: (args) =>
|
643
|
+
html`<ic-select
|
644
|
+
id="select-icoptionselect"
|
645
|
+
label="What is your favourite coffee?"
|
646
|
+
select-on-enter
|
647
|
+
></ic-select>
|
648
|
+
<script>
|
649
|
+
var select = document.querySelector("#select-icoptionselect");
|
650
|
+
select.options = [
|
651
|
+
{ label: "Cappuccino", value: "Cap" },
|
652
|
+
{ label: "Latte", value: "Lat" },
|
653
|
+
{ label: "Americano", value: "Ame" },
|
654
|
+
];
|
655
|
+
select.addEventListener("icOptionSelect", function (event) {
|
656
|
+
console.log("icOptionSelect: " + event.detail.value);
|
657
|
+
});
|
658
|
+
</script>`,
|
659
|
+
|
660
|
+
name: "Emitting icOptionSelect on enter",
|
661
|
+
};
|
662
|
+
|
663
|
+
export const Playground = {
|
664
|
+
render: (args) =>
|
665
|
+
html` <ic-select
|
666
|
+
id="select-playground"
|
667
|
+
disabled=${args.disabled}
|
668
|
+
full-width=${args["full-width"]}
|
669
|
+
helper-text=${args["helper-text"]}
|
670
|
+
hide-label=${args["hide-label"]}
|
671
|
+
loading=${args.loading}
|
672
|
+
loading-label=${args["loading-label"]}
|
673
|
+
label=${args.label}
|
674
|
+
placeholder=${args.placeholder}
|
675
|
+
readonly=${args.readonly}
|
676
|
+
required=${args.required}
|
677
|
+
show-clear-button=${args["show-clear-button"]}
|
678
|
+
size=${args.size}
|
679
|
+
validation-status=${args["validation-status"]}
|
680
|
+
validation-text=${args["validation-text"]}
|
681
|
+
>
|
682
|
+
${args.showIcon &&
|
683
|
+
html` <svg
|
684
|
+
slot="icon"
|
685
|
+
xmlns="http://www.w3.org/2000/svg"
|
686
|
+
height="24px"
|
687
|
+
viewBox="0 0 24 24"
|
688
|
+
width="24px"
|
689
|
+
fill="#000000"
|
690
|
+
>
|
691
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
692
|
+
<path
|
693
|
+
d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"
|
694
|
+
/>
|
695
|
+
</svg>`}
|
696
|
+
</ic-select>
|
697
|
+
<script>
|
698
|
+
var select = document.querySelector("#select-playground");
|
699
|
+
select.options = [
|
700
|
+
{
|
701
|
+
label: "Cappuccino",
|
702
|
+
value: "Cap",
|
703
|
+
description: "Coffee frothed up with pressurised steam",
|
704
|
+
},
|
705
|
+
{
|
706
|
+
label: "Boring",
|
707
|
+
children: [
|
708
|
+
{
|
709
|
+
label: "Latte",
|
710
|
+
value: "Lat",
|
711
|
+
description: "A milkier coffee than a cappuccino",
|
712
|
+
},
|
713
|
+
{
|
714
|
+
label: "Filter",
|
715
|
+
value: "Fil",
|
716
|
+
description: "Coffee filtered using paper or a mesh",
|
717
|
+
},
|
718
|
+
],
|
719
|
+
},
|
720
|
+
{
|
721
|
+
label: "Fancy",
|
722
|
+
children: [
|
723
|
+
{
|
724
|
+
label: "Flat white",
|
725
|
+
value: "Fla",
|
726
|
+
description:
|
727
|
+
"Coffee without froth made with espresso and hot steamed milk",
|
728
|
+
},
|
729
|
+
{
|
730
|
+
label: "Macchiato",
|
731
|
+
value: "Mac",
|
732
|
+
description:
|
733
|
+
"Espresso coffee with a dash of frothy steamed milk",
|
734
|
+
},
|
735
|
+
],
|
736
|
+
},
|
737
|
+
{
|
738
|
+
label: "Americano",
|
739
|
+
value: "Ame",
|
740
|
+
description: "Espresso coffee diluted with hot water",
|
741
|
+
},
|
742
|
+
{
|
743
|
+
label: "Mocha",
|
744
|
+
value: "Moc",
|
745
|
+
description: "A mixture of coffee and chocolate",
|
746
|
+
},
|
747
|
+
];
|
748
|
+
select.addEventListener("icChange", function (event) {
|
749
|
+
console.log("icChange: " + event.detail.value);
|
750
|
+
});
|
751
|
+
</script>`,
|
752
|
+
|
753
|
+
name: "Playground",
|
754
|
+
args: defaultArgs,
|
755
|
+
|
756
|
+
argTypes: {
|
757
|
+
["validation-status"]: {
|
758
|
+
defaultValue: "",
|
759
|
+
options: ["", "error", "success", "warning"],
|
760
|
+
|
761
|
+
control: {
|
762
|
+
type: "select",
|
763
|
+
},
|
764
|
+
},
|
765
|
+
|
766
|
+
size: {
|
767
|
+
options: ["small", "default", "large"],
|
768
|
+
|
769
|
+
control: {
|
770
|
+
type: "inline-radio",
|
771
|
+
},
|
772
|
+
},
|
773
|
+
|
774
|
+
showIcon: {
|
775
|
+
control: {
|
776
|
+
type: "boolean",
|
777
|
+
},
|
778
|
+
},
|
779
|
+
},
|
780
|
+
};
|