@ukic/web-components 2.35.0 → 2.35.2
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/core.cjs.js +1 -1
- package/dist/cjs/ic-badge.cjs.entry.js +23 -0
- package/dist/cjs/ic-badge.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-button.cjs.entry.js +2 -2
- package/dist/cjs/ic-navigation-button.cjs.entry.js.map +1 -1
- 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/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +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.js +39 -1
- package/dist/collection/components/ic-badge/ic-badge.js.map +1 -1
- package/dist/collection/components/ic-badge/ic-badge.stories.js +1082 -0
- package/dist/collection/components/ic-badge/test/basic/ic-badge.spec.js +194 -0
- package/dist/collection/components/ic-badge/test/basic/ic-badge.spec.js.map +1 -1
- 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-button/ic-navigation-button.css +4 -0
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.js +1 -1
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.js.map +1 -1
- 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.js +2 -5
- package/dist/collection/components/ic-tooltip/ic-tooltip.js.map +1 -1
- 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-badge.js +25 -2
- package/dist/components/ic-badge.js.map +1 -1
- package/dist/components/ic-navigation-button.js +2 -2
- package/dist/components/ic-navigation-button.js.map +1 -1
- 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/components/ic-tooltip2.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +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-ba06cc95.entry.js.map +1 -1
- 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/core/p-c05474f3.entry.js +2 -0
- package/dist/core/p-c05474f3.entry.js.map +1 -0
- package/dist/core/{p-5d3c6ea1.entry.js → p-d0299926.entry.js} +2 -2
- package/dist/core/p-d0299926.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/ic-badge.entry.js +23 -0
- package/dist/esm/ic-badge.entry.js.map +1 -1
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-navigation-button.entry.js +2 -2
- package/dist/esm/ic-navigation-button.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/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-badge/ic-badge.d.ts +5 -0
- package/dist/types/components/ic-tooltip/ic-tooltip.d.ts +1 -1
- package/dist/types/components.d.ts +7 -0
- package/hydrate/index.js +30 -7
- package/package.json +17 -12
- package/vscode-data.json +4 -0
- package/dist/core/p-405d89bb.entry.js +0 -2
- package/dist/core/p-405d89bb.entry.js.map +0 -1
- package/dist/core/p-5d3c6ea1.entry.js.map +0 -1
- package/dist/core/p-dfb3e76e.entry.js +0 -2
- package/dist/core/p-dfb3e76e.entry.js.map +0 -1
@@ -0,0 +1,591 @@
|
|
1
|
+
import { html } from "lit-html";
|
2
|
+
|
3
|
+
const defaultArgs = {
|
4
|
+
autocapitalize: "off",
|
5
|
+
autocorrect: "off",
|
6
|
+
autofocus: false,
|
7
|
+
disabled: false,
|
8
|
+
fullWidth: false,
|
9
|
+
focusOnLoad: true,
|
10
|
+
helperText: "",
|
11
|
+
hideLabel: false,
|
12
|
+
label: "What is your favourite coffee?",
|
13
|
+
placeholder: "Search",
|
14
|
+
readonly: false,
|
15
|
+
required: false,
|
16
|
+
size: "default",
|
17
|
+
spellcheck: false,
|
18
|
+
};
|
19
|
+
|
20
|
+
export default {
|
21
|
+
title: "Web Components/Search bar",
|
22
|
+
component: "ic-search-bar",
|
23
|
+
};
|
24
|
+
|
25
|
+
export const Default = {
|
26
|
+
render: (args) =>
|
27
|
+
html` <ic-search-bar label="What is your favourite coffee?">
|
28
|
+
</ic-search-bar>`,
|
29
|
+
|
30
|
+
name: "Default",
|
31
|
+
};
|
32
|
+
|
33
|
+
export const Basic = {
|
34
|
+
render: (args) =>
|
35
|
+
html` <ic-search-bar label="What is your favourite coffee?"></ic-search-bar>
|
36
|
+
<script>
|
37
|
+
document.querySelector("ic-search-bar").options = [
|
38
|
+
{ label: "Espresso", value: "espresso" },
|
39
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
40
|
+
{ label: "Flat White", value: "flatwhite" },
|
41
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
42
|
+
{ label: "Americano", value: "americano" },
|
43
|
+
{ label: "Ameno", value: "ameno" },
|
44
|
+
{ label: "Aicano", value: "acano" },
|
45
|
+
{ label: "Mocha", value: "mocha" },
|
46
|
+
];
|
47
|
+
</script>`,
|
48
|
+
|
49
|
+
name: "Basic",
|
50
|
+
};
|
51
|
+
|
52
|
+
export const WithCustomLabelAndValueFields = {
|
53
|
+
render: (args) =>
|
54
|
+
html` <ic-search-bar
|
55
|
+
label="What is your favourite coffee?"
|
56
|
+
label-field="urn"
|
57
|
+
value-field="reference"
|
58
|
+
></ic-search-bar>
|
59
|
+
<script>
|
60
|
+
document.querySelector("ic-search-bar").options = [
|
61
|
+
{ urn: "Espresso", reference: "espresso" },
|
62
|
+
{ urn: "Double Espresso", reference: "doubleespresso" },
|
63
|
+
{ urn: "Flat White", reference: "flatwhite" },
|
64
|
+
{ urn: "Cappuccino", reference: "cappuccino" },
|
65
|
+
{ urn: "Americano", reference: "americano" },
|
66
|
+
{ urn: "Ameno", reference: "ameno" },
|
67
|
+
{ urn: "Aicano", reference: "acano" },
|
68
|
+
{ urn: "Mocha", reference: "mocha" },
|
69
|
+
];
|
70
|
+
</script>`,
|
71
|
+
|
72
|
+
name: "With custom label and value fields",
|
73
|
+
};
|
74
|
+
|
75
|
+
export const WithOptions = {
|
76
|
+
render: (args) =>
|
77
|
+
html` <ic-search-bar
|
78
|
+
label="What is your favourite coffee?"
|
79
|
+
value="Flat White"
|
80
|
+
></ic-search-bar>
|
81
|
+
<br />
|
82
|
+
<ic-typography
|
83
|
+
>Suggested search options: Espresso, Double Espresso, Flat White,
|
84
|
+
Cappuccino, Americano, Mocha</ic-typography
|
85
|
+
>
|
86
|
+
<script>
|
87
|
+
document.querySelector("ic-search-bar").options = [
|
88
|
+
{ label: "Espresso", value: "espresso" },
|
89
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
90
|
+
{ label: "Flat White", value: "flatwhite" },
|
91
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
92
|
+
{ label: "Americano", value: "americano", disabled: true },
|
93
|
+
{ label: "Cafe au lait", value: "cafe" },
|
94
|
+
{ label: "Mocha", value: "mocha" },
|
95
|
+
];
|
96
|
+
</script>`,
|
97
|
+
|
98
|
+
name: "With options",
|
99
|
+
};
|
100
|
+
|
101
|
+
export const WithOptionsNoFiltering = {
|
102
|
+
render: (args) =>
|
103
|
+
html` <ic-search-bar
|
104
|
+
label="What is your favourite coffee?"
|
105
|
+
disable-filter
|
106
|
+
></ic-search-bar>
|
107
|
+
<br />
|
108
|
+
<ic-typography> All options will be displayed as you type </ic-typography>
|
109
|
+
<script>
|
110
|
+
document.querySelector("ic-search-bar").options = [
|
111
|
+
{ label: "Espresso", value: "espresso" },
|
112
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
113
|
+
{ label: "Flat White", value: "flatwhite" },
|
114
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
115
|
+
{ label: "Americano", value: "americano", disabled: true },
|
116
|
+
{ label: "Mocha", value: "mocha" },
|
117
|
+
];
|
118
|
+
</script>`,
|
119
|
+
|
120
|
+
name: "With options (no filtering)",
|
121
|
+
};
|
122
|
+
|
123
|
+
export const InAForm = {
|
124
|
+
render: (args) =>
|
125
|
+
html` <form>
|
126
|
+
<ic-search-bar
|
127
|
+
name="search-01"
|
128
|
+
label="What is your favourite coffee?"
|
129
|
+
></ic-search-bar>
|
130
|
+
</form>`,
|
131
|
+
|
132
|
+
name: "In a form",
|
133
|
+
};
|
134
|
+
|
135
|
+
export const HelperText = {
|
136
|
+
render: (args) =>
|
137
|
+
html` <ic-search-bar
|
138
|
+
label="What is your favourite coffee?"
|
139
|
+
helper-text="Some helper text"
|
140
|
+
></ic-search-bar>
|
141
|
+
<script>
|
142
|
+
document.querySelector("ic-search-bar").options = [
|
143
|
+
{ label: "Espresso", value: "espresso" },
|
144
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
145
|
+
{ label: "Flat White", value: "flatwhite" },
|
146
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
147
|
+
{ label: "Americano", value: "americano" },
|
148
|
+
{ label: "Mocha", value: "mocha" },
|
149
|
+
];
|
150
|
+
</script>`,
|
151
|
+
|
152
|
+
name: "Helper text",
|
153
|
+
};
|
154
|
+
|
155
|
+
export const Small = {
|
156
|
+
render: (args) =>
|
157
|
+
html` <ic-search-bar
|
158
|
+
label="What is your favourite coffee?"
|
159
|
+
size="small"
|
160
|
+
></ic-search-bar>`,
|
161
|
+
|
162
|
+
name: "Small",
|
163
|
+
};
|
164
|
+
|
165
|
+
export const DeprecatedSmall = {
|
166
|
+
render: (args) =>
|
167
|
+
html` <ic-search-bar
|
168
|
+
label="What is your favourite coffee?"
|
169
|
+
small
|
170
|
+
></ic-search-bar>`,
|
171
|
+
|
172
|
+
name: "Deprecated - small",
|
173
|
+
};
|
174
|
+
|
175
|
+
export const HiddenLabel = {
|
176
|
+
render: (args) =>
|
177
|
+
html` <ic-search-bar
|
178
|
+
label="What is your favourite coffee?"
|
179
|
+
hide-label
|
180
|
+
></ic-search-bar>`,
|
181
|
+
|
182
|
+
name: "Hidden label",
|
183
|
+
};
|
184
|
+
|
185
|
+
export const Disabled = {
|
186
|
+
render: (args) =>
|
187
|
+
html` <ic-search-bar
|
188
|
+
label="What is your favourite coffee?"
|
189
|
+
disabled
|
190
|
+
></ic-search-bar>`,
|
191
|
+
|
192
|
+
name: "Disabled",
|
193
|
+
};
|
194
|
+
|
195
|
+
export const FullWidth = {
|
196
|
+
render: (args) =>
|
197
|
+
html` <ic-search-bar
|
198
|
+
label="What is your favourite coffee?"
|
199
|
+
full-width
|
200
|
+
id="search2"
|
201
|
+
></ic-search-bar>
|
202
|
+
<br />
|
203
|
+
<ic-typography
|
204
|
+
>Suggested search options: Espresso, Double Espresso, Flat White,
|
205
|
+
Cappuccino, Americano, Mocha</ic-typography
|
206
|
+
>
|
207
|
+
<script>
|
208
|
+
document.querySelector("#search2").options = [
|
209
|
+
{ label: "Espresso", value: "espresso" },
|
210
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
211
|
+
{ label: "Flat White", value: "flatwhite" },
|
212
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
213
|
+
{ label: "Americano", value: "americano" },
|
214
|
+
{ label: "Mocha", value: "mocha" },
|
215
|
+
];
|
216
|
+
</script>`,
|
217
|
+
|
218
|
+
name: "Full width",
|
219
|
+
};
|
220
|
+
|
221
|
+
export const ExternalFiltering = {
|
222
|
+
render: (args) =>
|
223
|
+
html` <ic-search-bar
|
224
|
+
label="Search for coffee"
|
225
|
+
placeholder="Type to search"
|
226
|
+
debounce="300"
|
227
|
+
disable-filter="true"
|
228
|
+
id="external-filter-search"
|
229
|
+
></ic-search-bar>
|
230
|
+
<br />
|
231
|
+
<ic-typography
|
232
|
+
>Suggested search options: Espresso, Double Espresso, Flat White,
|
233
|
+
Cappuccino, Americano, Mocha</ic-typography
|
234
|
+
>
|
235
|
+
<br />
|
236
|
+
<ic-typography
|
237
|
+
>The IcChange event will trigger 300ms after you finish
|
238
|
+
typing.</ic-typography
|
239
|
+
>
|
240
|
+
<script>
|
241
|
+
var mockData = [
|
242
|
+
{ label: "Espresso", value: "espresso" },
|
243
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
244
|
+
{ label: "Flat White", value: "flatwhite" },
|
245
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
246
|
+
{ label: "Americano", value: "americano" },
|
247
|
+
{ label: "Mocha", value: "mocha" },
|
248
|
+
];
|
249
|
+
var select = document.querySelector("#external-filter-search");
|
250
|
+
var optionSelected = false;
|
251
|
+
function handleFilter(event) {
|
252
|
+
query = event.detail.value;
|
253
|
+
if (query !== optionSelected) {
|
254
|
+
if (query.length > 1) {
|
255
|
+
optionSelected = false;
|
256
|
+
mockAPI = (query) => {
|
257
|
+
filteredResults = mockData.filter((m) =>
|
258
|
+
m.label.toLowerCase().includes(query.toLowerCase())
|
259
|
+
);
|
260
|
+
return new Promise((resolve) =>
|
261
|
+
setTimeout(
|
262
|
+
() => resolve(filteredResults),
|
263
|
+
event.type === "icChange" ? 2000 : 1000
|
264
|
+
)
|
265
|
+
);
|
266
|
+
};
|
267
|
+
mockAPI(query).then((results) => (select.options = results));
|
268
|
+
} else {
|
269
|
+
select.options = [];
|
270
|
+
}
|
271
|
+
}
|
272
|
+
optionSelected = "";
|
273
|
+
}
|
274
|
+
function handleSelect(event) {
|
275
|
+
optionSelected = true;
|
276
|
+
}
|
277
|
+
select.addEventListener("icOptionSelect", handleSelect);
|
278
|
+
select.addEventListener("icChange", handleFilter);
|
279
|
+
select.addEventListener("icRetryLoad", handleFilter);
|
280
|
+
</script>`,
|
281
|
+
|
282
|
+
name: "External filtering",
|
283
|
+
};
|
284
|
+
|
285
|
+
export const ExternalFilteringWithLoading = {
|
286
|
+
render: (args) =>
|
287
|
+
html` <ic-search-bar
|
288
|
+
label="Search for coffee"
|
289
|
+
placeholder="Type to search"
|
290
|
+
debounce="300"
|
291
|
+
disable-filter="true"
|
292
|
+
id="external-filter-search"
|
293
|
+
timeout="1000"
|
294
|
+
></ic-search-bar>
|
295
|
+
<br />
|
296
|
+
<ic-typography
|
297
|
+
>Suggested search options: Espresso, Double Espresso, Flat White,
|
298
|
+
Cappuccino, Americano, Mocha</ic-typography
|
299
|
+
>
|
300
|
+
<br />
|
301
|
+
<ic-typography
|
302
|
+
>The IcChange event will trigger 300ms after you finish typing. 1 second
|
303
|
+
later, the options in the searchbar menu will be updated.</ic-typography
|
304
|
+
>
|
305
|
+
<script>
|
306
|
+
var mockData = [
|
307
|
+
{ label: "Espresso", value: "espresso" },
|
308
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
309
|
+
{ label: "Flat White", value: "flatwhite" },
|
310
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
311
|
+
{ label: "Americano", value: "americano" },
|
312
|
+
{ label: "Mocha", value: "mocha" },
|
313
|
+
];
|
314
|
+
var select = document.querySelector("#external-filter-search");
|
315
|
+
var optionSelected = false;
|
316
|
+
function handleFilter(event) {
|
317
|
+
query = event.detail.value;
|
318
|
+
if (query !== optionSelected) {
|
319
|
+
if (query.length > 1) {
|
320
|
+
if (!optionSelected) {
|
321
|
+
select.loading = true;
|
322
|
+
}
|
323
|
+
optionSelected = false;
|
324
|
+
mockAPI = (query) => {
|
325
|
+
filteredResults = mockData.filter((m) =>
|
326
|
+
m.label.toLowerCase().includes(query.toLowerCase())
|
327
|
+
);
|
328
|
+
return new Promise((resolve) =>
|
329
|
+
setTimeout(
|
330
|
+
() => resolve(filteredResults),
|
331
|
+
event.type === "icChange" ? 2000 : 1000
|
332
|
+
)
|
333
|
+
);
|
334
|
+
};
|
335
|
+
mockAPI(query).then((results) => (select.options = results));
|
336
|
+
} else {
|
337
|
+
select.options = [];
|
338
|
+
}
|
339
|
+
}
|
340
|
+
optionSelected = "";
|
341
|
+
}
|
342
|
+
function handleSelect(event) {
|
343
|
+
optionSelected = true;
|
344
|
+
}
|
345
|
+
select.addEventListener("icOptionSelect", handleSelect);
|
346
|
+
select.addEventListener("icChange", handleFilter);
|
347
|
+
select.addEventListener("icRetryLoad", handleFilter);
|
348
|
+
</script>`,
|
349
|
+
|
350
|
+
name: "External filtering with loading",
|
351
|
+
};
|
352
|
+
|
353
|
+
export const ExternalFilteringWithCustomLoadingMessages = {
|
354
|
+
render: (args) =>
|
355
|
+
html` <ic-search-bar
|
356
|
+
label="Search for coffee"
|
357
|
+
placeholder="Type to search"
|
358
|
+
debounce="300"
|
359
|
+
disable-filter="true"
|
360
|
+
id="external-filter-search"
|
361
|
+
timeout="1000"
|
362
|
+
loading-label="Loading time"
|
363
|
+
loading-error-label="Oops error"
|
364
|
+
></ic-search-bar>
|
365
|
+
<br />
|
366
|
+
<ic-typography
|
367
|
+
>Suggested search options: Espresso, Double Espresso, Flat White,
|
368
|
+
Cappuccino, Americano, Mocha</ic-typography
|
369
|
+
>
|
370
|
+
<br />
|
371
|
+
<ic-typography
|
372
|
+
>The IcChange event will trigger 300ms after you finish typing. 1 second
|
373
|
+
later, the options in the searchbar menu will be updated.</ic-typography
|
374
|
+
>
|
375
|
+
<script>
|
376
|
+
var mockData = [
|
377
|
+
{ label: "Espresso", value: "espresso" },
|
378
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
379
|
+
{ label: "Flat White", value: "flatwhite" },
|
380
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
381
|
+
{ label: "Americano", value: "americano" },
|
382
|
+
{ label: "Mocha", value: "mocha" },
|
383
|
+
];
|
384
|
+
var select = document.querySelector("#external-filter-search");
|
385
|
+
var optionSelected = false;
|
386
|
+
function handleFilter(event) {
|
387
|
+
query = event.detail.value;
|
388
|
+
if (query !== optionSelected) {
|
389
|
+
if (query.length > 1) {
|
390
|
+
if (!optionSelected) {
|
391
|
+
select.loading = true;
|
392
|
+
}
|
393
|
+
optionSelected = false;
|
394
|
+
mockAPI = (query) => {
|
395
|
+
filteredResults = mockData.filter((m) =>
|
396
|
+
m.label.toLowerCase().includes(query.toLowerCase())
|
397
|
+
);
|
398
|
+
return new Promise((resolve) =>
|
399
|
+
setTimeout(
|
400
|
+
() => resolve(filteredResults),
|
401
|
+
event.type === "icChange" ? 2000 : 1000
|
402
|
+
)
|
403
|
+
);
|
404
|
+
};
|
405
|
+
mockAPI(query).then((results) => (select.options = results));
|
406
|
+
} else {
|
407
|
+
select.options = [];
|
408
|
+
}
|
409
|
+
}
|
410
|
+
optionSelected = "";
|
411
|
+
}
|
412
|
+
function handleSelect(event) {
|
413
|
+
optionSelected = true;
|
414
|
+
}
|
415
|
+
select.addEventListener("icOptionSelect", handleSelect);
|
416
|
+
select.addEventListener("icChange", handleFilter);
|
417
|
+
select.addEventListener("icRetryLoad", handleFilter);
|
418
|
+
</script>`,
|
419
|
+
|
420
|
+
name: "External filtering with custom loading messages",
|
421
|
+
};
|
422
|
+
|
423
|
+
export const QuerySearchMode = {
|
424
|
+
render: (args) =>
|
425
|
+
html` <ic-search-bar
|
426
|
+
label="What is your favourite coffee?"
|
427
|
+
search-mode="query"
|
428
|
+
>
|
429
|
+
</ic-search-bar>
|
430
|
+
<script>
|
431
|
+
document.querySelector("ic-search-bar").options = [
|
432
|
+
{ label: "Espresso", value: "espresso" },
|
433
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
434
|
+
{ label: "Flat White", value: "flatwhite" },
|
435
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
436
|
+
{ label: "Americano", value: "americano" },
|
437
|
+
{ label: "Mocha", value: "mocha" },
|
438
|
+
];
|
439
|
+
</script>`,
|
440
|
+
|
441
|
+
name: "Query search mode",
|
442
|
+
};
|
443
|
+
|
444
|
+
export const EmptyOptionListText = {
|
445
|
+
render: (args) =>
|
446
|
+
html` <ic-search-bar
|
447
|
+
label="What is your favourite coffee?"
|
448
|
+
empty-option-list-text="There's nothing here"
|
449
|
+
>
|
450
|
+
</ic-search-bar>
|
451
|
+
<script>
|
452
|
+
document.querySelector("ic-search-bar").options = [
|
453
|
+
{ label: "Espresso", value: "espresso" },
|
454
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
455
|
+
{ label: "Flat White", value: "flatwhite" },
|
456
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
457
|
+
{ label: "Americano", value: "americano" },
|
458
|
+
{ label: "Mocha", value: "mocha" },
|
459
|
+
];
|
460
|
+
</script>`,
|
461
|
+
|
462
|
+
name: "Empty option list text",
|
463
|
+
};
|
464
|
+
|
465
|
+
export const CharactersUntilSuggestion = {
|
466
|
+
render: (args) =>
|
467
|
+
html` <ic-search-bar
|
468
|
+
label="What is your favourite coffee?"
|
469
|
+
characters-until-suggestion="5"
|
470
|
+
>
|
471
|
+
</ic-search-bar>
|
472
|
+
<script>
|
473
|
+
document.querySelector("ic-search-bar").options = [
|
474
|
+
{ label: "Espresso", value: "espresso" },
|
475
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
476
|
+
{ label: "Flat White", value: "flatwhite" },
|
477
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
478
|
+
{ label: "Americano", value: "americano" },
|
479
|
+
{ label: "Mocha", value: "mocha" },
|
480
|
+
];
|
481
|
+
</script>`,
|
482
|
+
|
483
|
+
name: "Characters until suggestion",
|
484
|
+
};
|
485
|
+
|
486
|
+
export const HintText = {
|
487
|
+
render: (args) =>
|
488
|
+
html` <ic-search-bar
|
489
|
+
label="What is your favourite coffee?"
|
490
|
+
hint-text="You can use up and down arrows to navigate the options when they are available, and press enter to select an option."
|
491
|
+
></ic-search-bar>
|
492
|
+
<script>
|
493
|
+
document.querySelector("ic-search-bar").options = [
|
494
|
+
{ label: "Espresso", value: "espresso" },
|
495
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
496
|
+
{ label: "Flat White", value: "flatwhite" },
|
497
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
498
|
+
{ label: "Americano", value: "americano" },
|
499
|
+
{ label: "Ameno", value: "ameno" },
|
500
|
+
{ label: "Aicano", value: "acano" },
|
501
|
+
{ label: "Mocha", value: "mocha" },
|
502
|
+
];
|
503
|
+
</script>`,
|
504
|
+
|
505
|
+
name: "Hint text",
|
506
|
+
};
|
507
|
+
|
508
|
+
export const LongOptionLabels = {
|
509
|
+
render: (args) =>
|
510
|
+
html` <ic-search-bar label="What is your favourite coffee?"></ic-search-bar>
|
511
|
+
<script>
|
512
|
+
document.querySelector("ic-search-bar").options = [
|
513
|
+
{
|
514
|
+
label: "Espresso because it tastes like coffee",
|
515
|
+
value: "espresso",
|
516
|
+
},
|
517
|
+
{
|
518
|
+
label:
|
519
|
+
"Double Espresso because it tastes like double the amount of coffee",
|
520
|
+
value: "doubleespresso",
|
521
|
+
},
|
522
|
+
{
|
523
|
+
label: "Reallylongonewordanswerthatcouldbethenameofacoffee",
|
524
|
+
value: "flatwhite",
|
525
|
+
},
|
526
|
+
];
|
527
|
+
</script>`,
|
528
|
+
|
529
|
+
name: "Long option labels",
|
530
|
+
};
|
531
|
+
|
532
|
+
export const Playground = {
|
533
|
+
render: (args) =>
|
534
|
+
html`<ic-search-bar
|
535
|
+
autocapitalize=${args.autocapitalize}
|
536
|
+
autocorrect=${args.autocorrect}
|
537
|
+
autofocus=${args.autofocus}
|
538
|
+
label=${args.label}
|
539
|
+
required=${args.required}
|
540
|
+
readonly=${args.readonly}
|
541
|
+
spellcheck=${args.spellcheck}
|
542
|
+
disabled=${args.disabled}
|
543
|
+
full-width=${args.fullWidth}
|
544
|
+
focus-on-load=${args.focusOnLoad}
|
545
|
+
helper-text=${args.helperText}
|
546
|
+
hide-label=${args.hideLabel}
|
547
|
+
placeholder=${args.placeholder}
|
548
|
+
size=${args.size}
|
549
|
+
>
|
550
|
+
</ic-search-bar>
|
551
|
+
<script>
|
552
|
+
document.querySelector("ic-search-bar").options = [
|
553
|
+
{ label: "Espresso", value: "espresso" },
|
554
|
+
{ label: "Double Espresso", value: "doubleespresso" },
|
555
|
+
{ label: "Flat White", value: "flatwhite" },
|
556
|
+
{ label: "Cappuccino", value: "cappuccino" },
|
557
|
+
{ label: "Americano", value: "americano" },
|
558
|
+
{ label: "Mocha", value: "mocha" },
|
559
|
+
];
|
560
|
+
</script>`,
|
561
|
+
|
562
|
+
args: defaultArgs,
|
563
|
+
|
564
|
+
argTypes: {
|
565
|
+
autocapitalize: {
|
566
|
+
options: ["off", "none", "on", "sentences", "words", "characters"],
|
567
|
+
|
568
|
+
control: {
|
569
|
+
type: "select",
|
570
|
+
},
|
571
|
+
},
|
572
|
+
|
573
|
+
autocorrect: {
|
574
|
+
options: ["on", "off"],
|
575
|
+
|
576
|
+
control: {
|
577
|
+
type: "inline-radio",
|
578
|
+
},
|
579
|
+
},
|
580
|
+
|
581
|
+
size: {
|
582
|
+
options: ["default", "small"],
|
583
|
+
|
584
|
+
control: {
|
585
|
+
type: "inline-radio",
|
586
|
+
},
|
587
|
+
},
|
588
|
+
},
|
589
|
+
|
590
|
+
name: "Playground",
|
591
|
+
};
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { html } from "lit-html";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: "Web Components/Section container",
|
5
|
+
component: "ic-section-container",
|
6
|
+
};
|
7
|
+
|
8
|
+
export const LeftAligned = {
|
9
|
+
render: () =>
|
10
|
+
html`<ic-section-container>
|
11
|
+
<main>
|
12
|
+
<div style="display: flex; justify-content: space-between">
|
13
|
+
<button>Start</button>
|
14
|
+
<button>End</button>
|
15
|
+
</div>
|
16
|
+
</main>
|
17
|
+
</ic-section-container>`,
|
18
|
+
|
19
|
+
name: "Left aligned",
|
20
|
+
};
|
21
|
+
|
22
|
+
export const CenterAlignment = {
|
23
|
+
render: () =>
|
24
|
+
html`<ic-section-container aligned="center">
|
25
|
+
<main>
|
26
|
+
<div style="display: flex; justify-content: space-between">
|
27
|
+
<button>Start</button>
|
28
|
+
<button>End</button>
|
29
|
+
</div>
|
30
|
+
</main>
|
31
|
+
</ic-section-container>`,
|
32
|
+
|
33
|
+
name: "Center alignment",
|
34
|
+
};
|
35
|
+
|
36
|
+
export const FullWidthAlignment = {
|
37
|
+
render: () =>
|
38
|
+
html`<ic-section-container aligned="full-width">
|
39
|
+
<main>
|
40
|
+
<div style="display: flex; justify-content: space-between">
|
41
|
+
<button>Start</button>
|
42
|
+
<button>End</button>
|
43
|
+
</div>
|
44
|
+
</main>
|
45
|
+
</ic-section-container>`,
|
46
|
+
|
47
|
+
name: "Full-width alignment",
|
48
|
+
};
|
49
|
+
|
50
|
+
export const FullHeight = {
|
51
|
+
render: () =>
|
52
|
+
html`<ic-section-container aligned="full-width" full-height>
|
53
|
+
<main>
|
54
|
+
<div style="display: flex; justify-content: space-between">
|
55
|
+
<button>Start</button>
|
56
|
+
<button>End</button>
|
57
|
+
</div>
|
58
|
+
</main>
|
59
|
+
</ic-section-container>`,
|
60
|
+
|
61
|
+
name: "Full-height",
|
62
|
+
};
|