@haiilo/catalyst 0.10.8 → 0.11.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/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/{p-e5c5e21d.entry.js → p-aa382647.entry.js} +4 -4
- package/dist/catalyst/p-aa382647.entry.js.map +1 -0
- package/dist/catalyst/scss/index.scss +1 -1
- package/dist/cjs/cat-alert_21.cjs.entry.js +74 -92
- package/dist/cjs/cat-alert_21.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/cat-badge/cat-badge.css +15 -15
- package/dist/collection/components/cat-input/cat-input.js +1 -1
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +1 -0
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +5 -4
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +84 -205
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/scss/index.scss +1 -1
- package/dist/components/cat-badge.js +1 -1
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-radio-group.js +0 -2
- package/dist/components/cat-radio-group.js.map +1 -1
- package/dist/components/cat-radio.js +1 -1
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-select.js +77 -97
- package/dist/components/cat-select.js.map +1 -1
- package/dist/esm/cat-alert_21.entry.js +74 -92
- package/dist/esm/cat-alert_21.entry.js.map +1 -1
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/cat-input/cat-input.d.ts +1 -1
- package/dist/types/components/cat-radio-group/cat-radio-group.d.ts +9 -0
- package/dist/types/components/cat-select/cat-select.d.ts +13 -28
- package/dist/types/components.d.ts +30 -37
- package/package.json +2 -2
- package/dist/catalyst/p-e5c5e21d.entry.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Component, Element, Event, h, Host,
|
|
1
|
+
import { Component, Element, Event, h, Host, Prop, State, Watch } from '@stencil/core';
|
|
2
2
|
import Choices from 'choices.js';
|
|
3
|
-
import { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';
|
|
4
3
|
import log from 'loglevel';
|
|
5
4
|
import { CatFormHint } from '../cat-form-hint/cat-form-hint';
|
|
5
|
+
import { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';
|
|
6
6
|
let nextUniqueId = 0;
|
|
7
7
|
const getOptionTemplate = (data) => {
|
|
8
8
|
var _a;
|
|
@@ -29,6 +29,7 @@ export class CatSelect {
|
|
|
29
29
|
constructor() {
|
|
30
30
|
this.i18n = CatI18nRegistry.getInstance();
|
|
31
31
|
this.id = `cat-select-${nextUniqueId++}`;
|
|
32
|
+
this.resetItemsOnNextValueChange = true;
|
|
32
33
|
this.hasSlottedLabel = false;
|
|
33
34
|
/**
|
|
34
35
|
* The label for the select.
|
|
@@ -45,7 +46,7 @@ export class CatSelect {
|
|
|
45
46
|
/**
|
|
46
47
|
* The available options for the input.
|
|
47
48
|
*/
|
|
48
|
-
this.
|
|
49
|
+
this.items = [];
|
|
49
50
|
/**
|
|
50
51
|
* Disable the select.
|
|
51
52
|
*/
|
|
@@ -67,17 +68,39 @@ export class CatSelect {
|
|
|
67
68
|
/**
|
|
68
69
|
* Enable search for the select.
|
|
69
70
|
*/
|
|
70
|
-
this.
|
|
71
|
+
this.search = false;
|
|
71
72
|
}
|
|
72
|
-
setChoicesHandler(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
setChoicesHandler(items) {
|
|
74
|
+
var _a, _b, _c, _d;
|
|
75
|
+
const isSelected = (item) => { var _a; return (_a = this.value) === null || _a === void 0 ? void 0 : _a.includes(item.value); };
|
|
76
|
+
const choices = items.map(item => (Object.assign(Object.assign({}, item), { selected: isSelected(item) })));
|
|
77
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, 'value', 'label', true);
|
|
78
|
+
const vItems = ((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue()) || [];
|
|
79
|
+
const vItemsArray = (Array.isArray(vItems) ? vItems : [vItems]);
|
|
80
|
+
const vItemValues = [...this.value];
|
|
81
|
+
// remove duplicate items
|
|
82
|
+
(_c = this.choice) === null || _c === void 0 ? void 0 : _c.unhighlightAll();
|
|
83
|
+
vItemsArray.forEach(vItem => {
|
|
84
|
+
var _a;
|
|
85
|
+
const index = vItemValues.indexOf(vItem.value);
|
|
86
|
+
if (index > -1) {
|
|
87
|
+
vItemValues.splice(index, 1);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
vItem.choiceId = -1; // disconnect item from choice
|
|
91
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.highlightItem(vItem, false);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
(_d = this.choice) === null || _d === void 0 ? void 0 : _d.removeHighlightedItems(false);
|
|
76
95
|
}
|
|
77
96
|
setValueHandler(value) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
var _a, _b;
|
|
98
|
+
if (this.resetItemsOnNextValueChange) {
|
|
99
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
|
|
100
|
+
}
|
|
101
|
+
this.resetItemsOnNextValueChange = true;
|
|
102
|
+
(_b = this.choice) === null || _b === void 0 ? void 0 : _b.setChoiceByValue(value);
|
|
103
|
+
this.multiple && this.updateRemoveItemButtonVisibility();
|
|
81
104
|
}
|
|
82
105
|
componentWillRender() {
|
|
83
106
|
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
@@ -86,74 +109,35 @@ export class CatSelect {
|
|
|
86
109
|
}
|
|
87
110
|
}
|
|
88
111
|
componentDidLoad() {
|
|
89
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
112
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
90
113
|
this.init();
|
|
91
114
|
const attachedInternals = (_b = (_a = this.hostElement).attachInternals) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
92
115
|
if (attachedInternals) {
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
|
|
116
|
+
const root = attachedInternals.shadowRoot;
|
|
117
|
+
this.choiceInner = (root === null || root === void 0 ? void 0 : root.querySelector('.choices__inner')) || undefined;
|
|
118
|
+
this.choiceDropdown = ((_c = root === null || root === void 0 ? void 0 : root.querySelector('.choices__list--dropdown')) === null || _c === void 0 ? void 0 : _c.firstElementChild) || undefined;
|
|
96
119
|
}
|
|
97
|
-
(
|
|
98
|
-
(
|
|
99
|
-
(
|
|
100
|
-
(
|
|
101
|
-
(_k = this.choiceDropdown) === null || _k === void 0 ? void 0 : _k.addEventListener('scroll', this.onScrolledBottom.bind(this));
|
|
120
|
+
(_d = this.choiceInner) === null || _d === void 0 ? void 0 : _d.addEventListener('click', this.showDropdownHandler.bind(this));
|
|
121
|
+
(_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.addEventListener('change', this.onChange.bind(this));
|
|
122
|
+
(_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.addEventListener('search', this.onSearch.bind(this));
|
|
123
|
+
(_g = this.choiceDropdown) === null || _g === void 0 ? void 0 : _g.addEventListener('scroll', this.onScrolledBottom.bind(this));
|
|
102
124
|
if (this.multiple) {
|
|
103
|
-
(
|
|
125
|
+
(_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('choice', this.onChoice.bind(this));
|
|
104
126
|
this.createRemoveItemButton();
|
|
105
127
|
}
|
|
106
128
|
}
|
|
107
129
|
disconnectedCallback() {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f
|
|
130
|
+
var _a, _b, _c, _d, _e, _f;
|
|
109
131
|
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
110
132
|
this.choice = undefined;
|
|
111
133
|
(_b = this.choiceInner) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.showDropdownHandler.bind(this));
|
|
112
|
-
(_c = this.selectElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('
|
|
113
|
-
(_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('
|
|
114
|
-
(_e = this.
|
|
115
|
-
(_f = this.choiceDropdown) === null || _f === void 0 ? void 0 : _f.removeEventListener('scroll', this.onScrolledBottom.bind(this));
|
|
134
|
+
(_c = this.selectElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('change', this.onChange.bind(this));
|
|
135
|
+
(_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('search', this.onSearch.bind(this));
|
|
136
|
+
(_e = this.choiceDropdown) === null || _e === void 0 ? void 0 : _e.removeEventListener('scroll', this.onScrolledBottom.bind(this));
|
|
116
137
|
if (this.multiple) {
|
|
117
|
-
(
|
|
118
|
-
(_h = this.removeElement) === null || _h === void 0 ? void 0 : _h.removeEventListener('click', this.onRemoveItemButtonClick.bind(this));
|
|
138
|
+
(_f = this.removeElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('choice', this.onChoice.bind(this));
|
|
119
139
|
}
|
|
120
140
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Set value of input based on an array of objects or strings. This behaves
|
|
123
|
-
* exactly the same as passing items via the items option but can be called
|
|
124
|
-
* after initialisation.
|
|
125
|
-
*/
|
|
126
|
-
async setValue(args) {
|
|
127
|
-
var _a;
|
|
128
|
-
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.setValue(args);
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Set choices of select input via an array of objects (or function that
|
|
133
|
-
* returns array of object or promise of it), a value field name and a label
|
|
134
|
-
* field name.
|
|
135
|
-
*/
|
|
136
|
-
async setChoices(choices, value, label, replaceChoices) {
|
|
137
|
-
var _a;
|
|
138
|
-
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, value, label, replaceChoices);
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Clear all choices from select.
|
|
143
|
-
*/
|
|
144
|
-
async clearChoices() {
|
|
145
|
-
var _a;
|
|
146
|
-
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.clearChoices();
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Clear input of any user inputted text.
|
|
151
|
-
*/
|
|
152
|
-
async clearInput() {
|
|
153
|
-
var _a;
|
|
154
|
-
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.clearInput();
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
141
|
render() {
|
|
158
142
|
return (h(Host, null,
|
|
159
143
|
(this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
@@ -167,16 +151,15 @@ export class CatSelect {
|
|
|
167
151
|
this.hintSection));
|
|
168
152
|
}
|
|
169
153
|
init() {
|
|
170
|
-
const
|
|
154
|
+
const component = this; // eslint-disable-line @typescript-eslint/no-this-alias
|
|
171
155
|
const removeItemText = (value) => this.i18n.t('select.removeItem', { value });
|
|
172
156
|
const config = {
|
|
173
157
|
allowHTML: true,
|
|
174
|
-
items: Array.isArray(value) ? value : [value],
|
|
175
158
|
removeItemButton: true,
|
|
176
159
|
duplicateItemsAllowed: false,
|
|
177
160
|
delimiter: '',
|
|
178
161
|
paste: false,
|
|
179
|
-
searchEnabled:
|
|
162
|
+
searchEnabled: this.search,
|
|
180
163
|
searchChoices: false,
|
|
181
164
|
position: this.position,
|
|
182
165
|
resetScrollPosition: false,
|
|
@@ -191,7 +174,12 @@ export class CatSelect {
|
|
|
191
174
|
addItemText: (value) => this.i18n.t('select.addItem', { value }),
|
|
192
175
|
maxItemText: (maxItemCount) => this.i18n.t('select.maxItem', { maxItemCount }),
|
|
193
176
|
uniqueItemText: this.i18n.t('select.uniqueItem'),
|
|
194
|
-
customAddItemText: this.i18n.t('select.customAddItem')
|
|
177
|
+
customAddItemText: this.i18n.t('select.customAddItem'),
|
|
178
|
+
callbackOnInit: function () {
|
|
179
|
+
const choice = this;
|
|
180
|
+
choice.setChoices(component.items, 'value', 'label', true);
|
|
181
|
+
choice.setChoiceByValue(component.value);
|
|
182
|
+
}
|
|
195
183
|
};
|
|
196
184
|
const configSingle = {
|
|
197
185
|
callbackOnCreateTemplates: (strToEl) => {
|
|
@@ -257,18 +245,24 @@ export class CatSelect {
|
|
|
257
245
|
const settings = this.multiple
|
|
258
246
|
? Object.assign(Object.assign({}, config), configMultiple) : Object.assign(Object.assign({}, config), configSingle);
|
|
259
247
|
this.choice = new Choices(this.selectElement, settings);
|
|
260
|
-
this.choice.setChoices(this.choices);
|
|
261
248
|
}
|
|
262
249
|
get hintSection() {
|
|
263
250
|
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
264
251
|
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
265
252
|
}
|
|
266
253
|
onChange() {
|
|
267
|
-
var _a
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
270
|
-
|
|
271
|
-
|
|
254
|
+
var _a;
|
|
255
|
+
this.resetItemsOnNextValueChange = false;
|
|
256
|
+
this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue(true);
|
|
257
|
+
this.catChange.emit(this.value);
|
|
258
|
+
}
|
|
259
|
+
onChoice(event) {
|
|
260
|
+
var _a;
|
|
261
|
+
const customEvent = event;
|
|
262
|
+
const coice = customEvent.detail.choice;
|
|
263
|
+
if (coice.selected) {
|
|
264
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItemsByValue(coice.value);
|
|
265
|
+
this.onChange();
|
|
272
266
|
}
|
|
273
267
|
}
|
|
274
268
|
onSearch(event) {
|
|
@@ -283,20 +277,9 @@ export class CatSelect {
|
|
|
283
277
|
this.catScrolledBottom.emit();
|
|
284
278
|
}
|
|
285
279
|
}
|
|
286
|
-
onChoice(event) {
|
|
287
|
-
var _a, _b;
|
|
288
|
-
const customEvent = event;
|
|
289
|
-
const items = Array.from((_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue());
|
|
290
|
-
const item = items.find(value => value.choiceId === customEvent.detail.choice.id);
|
|
291
|
-
if (item) {
|
|
292
|
-
(_b = this.choice) === null || _b === void 0 ? void 0 : _b._removeItem(item);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
280
|
showDropdownHandler() {
|
|
296
281
|
var _a;
|
|
297
|
-
|
|
298
|
-
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown();
|
|
299
|
-
}
|
|
282
|
+
!this.disabled && ((_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown());
|
|
300
283
|
}
|
|
301
284
|
createRemoveItemButton() {
|
|
302
285
|
var _a;
|
|
@@ -314,7 +297,7 @@ export class CatSelect {
|
|
|
314
297
|
if (items.length) {
|
|
315
298
|
(_b = this.removeElement) === null || _b === void 0 ? void 0 : _b.removeAttribute('hidden');
|
|
316
299
|
}
|
|
317
|
-
else
|
|
300
|
+
else {
|
|
318
301
|
(_c = this.removeElement) === null || _c === void 0 ? void 0 : _c.setAttribute('hidden', 'true');
|
|
319
302
|
}
|
|
320
303
|
}
|
|
@@ -322,6 +305,7 @@ export class CatSelect {
|
|
|
322
305
|
var _a;
|
|
323
306
|
event.stopPropagation();
|
|
324
307
|
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
|
|
308
|
+
this.updateRemoveItemButtonVisibility();
|
|
325
309
|
}
|
|
326
310
|
static get is() { return "cat-select"; }
|
|
327
311
|
static get encapsulation() { return "shadow"; }
|
|
@@ -386,16 +370,15 @@ export class CatSelect {
|
|
|
386
370
|
"reflect": false,
|
|
387
371
|
"defaultValue": "false"
|
|
388
372
|
},
|
|
389
|
-
"
|
|
373
|
+
"items": {
|
|
390
374
|
"type": "unknown",
|
|
391
375
|
"mutable": false,
|
|
392
376
|
"complexType": {
|
|
393
|
-
"original": "
|
|
394
|
-
"resolved": "
|
|
377
|
+
"original": "CatSelectItem[]",
|
|
378
|
+
"resolved": "CatSelectItem[]",
|
|
395
379
|
"references": {
|
|
396
|
-
"
|
|
397
|
-
"location": "
|
|
398
|
-
"path": "choices.js"
|
|
380
|
+
"CatSelectItem": {
|
|
381
|
+
"location": "local"
|
|
399
382
|
}
|
|
400
383
|
}
|
|
401
384
|
},
|
|
@@ -408,23 +391,18 @@ export class CatSelect {
|
|
|
408
391
|
"defaultValue": "[]"
|
|
409
392
|
},
|
|
410
393
|
"value": {
|
|
411
|
-
"type": "
|
|
394
|
+
"type": "any",
|
|
412
395
|
"mutable": true,
|
|
413
396
|
"complexType": {
|
|
414
|
-
"original": "
|
|
415
|
-
"resolved": "
|
|
416
|
-
"references": {
|
|
417
|
-
"Choice": {
|
|
418
|
-
"location": "import",
|
|
419
|
-
"path": "choices.js"
|
|
420
|
-
}
|
|
421
|
-
}
|
|
397
|
+
"original": "any",
|
|
398
|
+
"resolved": "any",
|
|
399
|
+
"references": {}
|
|
422
400
|
},
|
|
423
401
|
"required": false,
|
|
424
402
|
"optional": true,
|
|
425
403
|
"docs": {
|
|
426
404
|
"tags": [],
|
|
427
|
-
"text": "The
|
|
405
|
+
"text": "The value of the select."
|
|
428
406
|
},
|
|
429
407
|
"attribute": "value",
|
|
430
408
|
"reflect": false
|
|
@@ -501,7 +479,7 @@ export class CatSelect {
|
|
|
501
479
|
"reflect": false,
|
|
502
480
|
"defaultValue": "'auto'"
|
|
503
481
|
},
|
|
504
|
-
"
|
|
482
|
+
"search": {
|
|
505
483
|
"type": "boolean",
|
|
506
484
|
"mutable": false,
|
|
507
485
|
"complexType": {
|
|
@@ -515,7 +493,7 @@ export class CatSelect {
|
|
|
515
493
|
"tags": [],
|
|
516
494
|
"text": "Enable search for the select."
|
|
517
495
|
},
|
|
518
|
-
"attribute": "
|
|
496
|
+
"attribute": "search",
|
|
519
497
|
"reflect": false,
|
|
520
498
|
"defaultValue": "false"
|
|
521
499
|
},
|
|
@@ -586,108 +564,9 @@ export class CatSelect {
|
|
|
586
564
|
"references": {}
|
|
587
565
|
}
|
|
588
566
|
}]; }
|
|
589
|
-
static get methods() { return {
|
|
590
|
-
"setValue": {
|
|
591
|
-
"complexType": {
|
|
592
|
-
"signature": "(args: Array<string> | Array<Item>) => Promise<this>",
|
|
593
|
-
"parameters": [{
|
|
594
|
-
"tags": [],
|
|
595
|
-
"text": ""
|
|
596
|
-
}],
|
|
597
|
-
"references": {
|
|
598
|
-
"Promise": {
|
|
599
|
-
"location": "global"
|
|
600
|
-
},
|
|
601
|
-
"Array": {
|
|
602
|
-
"location": "global"
|
|
603
|
-
},
|
|
604
|
-
"Item": {
|
|
605
|
-
"location": "import",
|
|
606
|
-
"path": "choices.js"
|
|
607
|
-
}
|
|
608
|
-
},
|
|
609
|
-
"return": "Promise<this>"
|
|
610
|
-
},
|
|
611
|
-
"docs": {
|
|
612
|
-
"text": "Set value of input based on an array of objects or strings. This behaves\nexactly the same as passing items via the items option but can be called\nafter initialisation.",
|
|
613
|
-
"tags": []
|
|
614
|
-
}
|
|
615
|
-
},
|
|
616
|
-
"setChoices": {
|
|
617
|
-
"complexType": {
|
|
618
|
-
"signature": "(choices: Array<Choice> | Array<Group>, value?: string | undefined, label?: string | undefined, replaceChoices?: boolean | undefined) => Promise<this>",
|
|
619
|
-
"parameters": [{
|
|
620
|
-
"tags": [],
|
|
621
|
-
"text": ""
|
|
622
|
-
}, {
|
|
623
|
-
"tags": [],
|
|
624
|
-
"text": ""
|
|
625
|
-
}, {
|
|
626
|
-
"tags": [],
|
|
627
|
-
"text": ""
|
|
628
|
-
}, {
|
|
629
|
-
"tags": [],
|
|
630
|
-
"text": ""
|
|
631
|
-
}],
|
|
632
|
-
"references": {
|
|
633
|
-
"Promise": {
|
|
634
|
-
"location": "global"
|
|
635
|
-
},
|
|
636
|
-
"Array": {
|
|
637
|
-
"location": "global"
|
|
638
|
-
},
|
|
639
|
-
"Choice": {
|
|
640
|
-
"location": "import",
|
|
641
|
-
"path": "choices.js"
|
|
642
|
-
},
|
|
643
|
-
"Group": {
|
|
644
|
-
"location": "import",
|
|
645
|
-
"path": "choices.js"
|
|
646
|
-
}
|
|
647
|
-
},
|
|
648
|
-
"return": "Promise<this>"
|
|
649
|
-
},
|
|
650
|
-
"docs": {
|
|
651
|
-
"text": "Set choices of select input via an array of objects (or function that\nreturns array of object or promise of it), a value field name and a label\nfield name.",
|
|
652
|
-
"tags": []
|
|
653
|
-
}
|
|
654
|
-
},
|
|
655
|
-
"clearChoices": {
|
|
656
|
-
"complexType": {
|
|
657
|
-
"signature": "() => Promise<this>",
|
|
658
|
-
"parameters": [],
|
|
659
|
-
"references": {
|
|
660
|
-
"Promise": {
|
|
661
|
-
"location": "global"
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
|
-
"return": "Promise<this>"
|
|
665
|
-
},
|
|
666
|
-
"docs": {
|
|
667
|
-
"text": "Clear all choices from select.",
|
|
668
|
-
"tags": []
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
"clearInput": {
|
|
672
|
-
"complexType": {
|
|
673
|
-
"signature": "() => Promise<this>",
|
|
674
|
-
"parameters": [],
|
|
675
|
-
"references": {
|
|
676
|
-
"Promise": {
|
|
677
|
-
"location": "global"
|
|
678
|
-
}
|
|
679
|
-
},
|
|
680
|
-
"return": "Promise<this>"
|
|
681
|
-
},
|
|
682
|
-
"docs": {
|
|
683
|
-
"text": "Clear input of any user inputted text.",
|
|
684
|
-
"tags": []
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
}; }
|
|
688
567
|
static get elementRef() { return "hostElement"; }
|
|
689
568
|
static get watchers() { return [{
|
|
690
|
-
"propName": "
|
|
569
|
+
"propName": "items",
|
|
691
570
|
"methodName": "setChoicesHandler"
|
|
692
571
|
}, {
|
|
693
572
|
"propName": "value",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-select.js","sourceRoot":"","sources":["../../../src/components/cat-select/cat-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,OAAqD,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAU,EAAE;;EAC/C,IAAI,MAAA,IAAI,CAAC,gBAAgB,0CAAE,QAAQ,EAAE;IACnC,OAAO;;8CAEmC,IAAI,CAAC,gBAAgB,CAAC,QAAQ;QACpE,IAAI,CAAC,KAAK;;KAEb,CAAC;GACH;EACD,OAAO,wBAAwB,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,QAAQ,mBAAmB,CAAC;AAC1F,CAAC,CAAC;AAEF;;;;;;;;GAQG;AAMH,MAAM,OAAO,SAAS;EALtB;IAMmB,SAAI,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IACrC,OAAE,GAAG,cAAc,YAAY,EAAE,EAAE,CAAC;IAU5C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAE5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,YAAO,GAAa,EAAE,CAAC;IAO/B;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, Watch, State } from '@stencil/core';\nimport Choices, { Choice, ClassNames, Group, Item, Options } from 'choices.js';\nimport { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\nconst getOptionTemplate = (data: Item): string => {\n if (data.customProperties?.imageUrl) {\n return `\n <div class=\"d-flex align-items-center\">\n <img class=\"choices-option-icon\" src=\"${data.customProperties.imageUrl}\" style=\"margin-right: 0.5rem\" />\n ${data.label}\n </div>\n `;\n }\n return `<cat-checkbox label=\"${data.label}\" checked=\"${data.selected}\"></cat-checkbox>`;\n};\n\n/**\n * Select lets user choose one option from an options menu. Consider using\n * select when you have 6 or more options. Select component supports any content\n * type.\n *\n * @slot hint - Optional hint element to be displayed with the select.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-select',\n styleUrl: 'cat-select.scss',\n shadow: true\n})\nexport class CatSelect {\n private readonly i18n = CatI18nRegistry.getInstance();\n private readonly id = `cat-select-${nextUniqueId++}`;\n\n private choice?: Choices;\n private choiceInner?: Element;\n private choiceDropdown?: Element;\n private selectElement?: HTMLSelectElement;\n private removeElement?: HTMLCatButtonElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * The label for the select.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The available options for the input.\n */\n @Prop() choices: Choice[] = [];\n\n /**\n * The pre-selected items for the input.\n */\n @Prop({ mutable: true }) value?: string | string[] | Choice | Choice[];\n\n /**\n * Disable the select.\n */\n @Prop() disabled = false;\n\n /**\n * Enable multiple selection.\n */\n @Prop() multiple = false;\n\n /**\n * The placeholder for the select.\n */\n @Prop() placeholder = '';\n\n /**\n * Whether the dropdown should appear above `(top)` or below `(bottom)` the\n * input. By default, if there is not enough space within the window the\n * dropdown will appear above the input, otherwise below it.\n */\n @Prop() position: 'auto' | 'top' | 'bottom' = 'auto';\n\n /**\n * Enable search for the select.\n */\n @Prop() noSearch = false;\n\n /**\n * Optional hint text(s) to be displayed with the select.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the search is triggered.\n */\n @Event() catSearch!: EventEmitter;\n\n /**\n * Emitted when scrolled to the bottom.\n */\n @Event() catScrolledBottom!: EventEmitter;\n\n @Watch('choices')\n setChoicesHandler(choices: Choice[]) {\n if (!choices?.length) return;\n\n this.setChoices(choices, 'value', 'label', true);\n }\n\n @Watch('value')\n setValueHandler(value?: string[] | Choice[]) {\n if (this.multiple) return;\n\n this.setValue(value || []);\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on select', this);\n }\n }\n\n componentDidLoad(): void {\n this.init();\n const attachedInternals: ElementInternals | undefined = this.hostElement.attachInternals?.();\n if (attachedInternals) {\n this.choiceInner = attachedInternals.shadowRoot?.querySelector('.choices__inner') || undefined;\n this.choiceDropdown =\n attachedInternals.shadowRoot?.querySelector('.choices__list--dropdown')?.firstElementChild || undefined;\n }\n this.choiceInner?.addEventListener('click', this.showDropdownHandler.bind(this));\n this.selectElement?.addEventListener('addItem', this.onChange.bind(this));\n this.selectElement?.addEventListener('removeItem', this.onChange.bind(this));\n this.selectElement?.addEventListener('search', this.onSearch.bind(this));\n this.choiceDropdown?.addEventListener('scroll', this.onScrolledBottom.bind(this));\n if (this.multiple) {\n this.selectElement?.addEventListener('choice', this.onChoice.bind(this));\n this.createRemoveItemButton();\n }\n }\n\n disconnectedCallback(): void {\n this.choice?.destroy();\n this.choice = undefined;\n this.choiceInner?.removeEventListener('click', this.showDropdownHandler.bind(this));\n this.selectElement?.removeEventListener('addItem', this.onChange.bind(this));\n this.selectElement?.removeEventListener('removeItem', this.onChange.bind(this));\n this.selectElement?.removeEventListener('search', this.onSearch.bind(this));\n this.choiceDropdown?.removeEventListener('scroll', this.onScrolledBottom.bind(this));\n if (this.multiple) {\n this.selectElement?.removeEventListener('choice', this.onChoice.bind(this));\n this.removeElement?.removeEventListener('click', this.onRemoveItemButtonClick.bind(this));\n }\n }\n\n /**\n * Set value of input based on an array of objects or strings. This behaves\n * exactly the same as passing items via the items option but can be called\n * after initialisation.\n */\n @Method()\n async setValue(args: Array<string> | Array<Item>) {\n this.choice?.setValue(args);\n\n return this;\n }\n\n /**\n * Set choices of select input via an array of objects (or function that\n * returns array of object or promise of it), a value field name and a label\n * field name.\n */\n @Method()\n async setChoices(choices: Array<Choice> | Array<Group>, value?: string, label?: string, replaceChoices?: boolean) {\n this.choice?.setChoices(choices, value, label, replaceChoices);\n\n return this;\n }\n\n /**\n * Clear all choices from select.\n */\n @Method()\n async clearChoices() {\n this.choice?.clearChoices();\n\n return this;\n }\n\n /**\n * Clear input of any user inputted text.\n */\n @Method()\n async clearInput() {\n this.choice?.clearInput();\n\n return this;\n }\n\n render() {\n return (\n <Host>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n {!this.required && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n ({this.i18n.t('input.optional')})\n </span>\n )}\n </span>\n </label>\n )}\n <select\n id={this.id}\n ref={el => (this.selectElement = el)}\n multiple={this.multiple}\n disabled={this.disabled}\n ></select>\n {this.hintSection}\n </Host>\n );\n }\n\n private init() {\n const value = this.value || [];\n const removeItemText = (value: string) => this.i18n.t('select.removeItem', { value });\n const config = {\n allowHTML: true,\n items: Array.isArray(value) ? value : ([value] as string[] | Choice[]),\n removeItemButton: true,\n duplicateItemsAllowed: false,\n delimiter: '',\n paste: false,\n searchEnabled: !this.noSearch,\n searchChoices: false,\n position: this.position,\n resetScrollPosition: false,\n placeholder: !!this.placeholder,\n placeholderValue: this.placeholder || '',\n searchPlaceholderValue: this.i18n.t('select.searchPlaceholder'),\n renderSelectedChoices: 'always' as 'auto' | 'always',\n loadingText: this.i18n.t('select.loading'),\n noResultsText: this.i18n.t('select.noResults'),\n noChoicesText: this.i18n.t('select.noChoices'),\n itemSelectText: this.i18n.t('select.selectItem'),\n addItemText: (value: string) => this.i18n.t('select.addItem', { value }),\n maxItemText: (maxItemCount: number) => this.i18n.t('select.maxItem', { maxItemCount }),\n uniqueItemText: this.i18n.t('select.uniqueItem'),\n customAddItemText: this.i18n.t('select.customAddItem')\n };\n\n const configSingle = {\n callbackOnCreateTemplates: (strToEl: (str: string) => HTMLElement) => {\n return {\n item: ({ classNames }: { classNames: ClassNames }, data: Item) => {\n const template = data.customProperties?.imageUrl\n ? `<img class=\"choices-option-icon\" src=\"${data.customProperties.imageUrl}\" style=\"margin-right: 0.5rem\" />`\n : '';\n return strToEl(\n `\n <div class=\"${classNames.item} ${\n data.highlighted ? classNames.highlightedState : classNames.itemSelectable\n } ${data.placeholder ? classNames.placeholder : ''}\" data-item data-id=\"${data.id}\" data-value=\"${\n data.value\n }\" ${data.active ? 'aria-selected=\"true\"' : ''} ${data.disabled ? 'aria-disabled=\"true\"' : ''}>\n <span>${template}</span> ${data.label}\n <button type=\"button\"\n class=\"${classNames.button}\"\n aria-label=\"${removeItemText(data.label)}\"\n data-button>${removeItemText(data.label)}</button>\n </div>\n `\n );\n }\n };\n }\n };\n\n const configMultiple = {\n callbackOnCreateTemplates: (strToEl: (str: string) => HTMLElement) => {\n const itemSelectText = config.itemSelectText;\n return {\n item: ({ classNames }: { classNames: ClassNames }, data: Item) => {\n const template = data.customProperties?.imageUrl\n ? `<img class=\"choices-option-icon\" src=\"${data.customProperties.imageUrl}\" style=\"margin-right: 0.5rem;\" />`\n : '';\n return strToEl(\n `<div class=\"\n ${classNames.item}\n ${data.highlighted ? classNames.highlightedState : classNames.itemSelectable}\n ${data.placeholder ? classNames.placeholder : ''}\"\n data-item data-id=\"${data.id}\" data-value=\"${data.value}\"\n ${data.active ? 'aria-selected=\"true\"' : ''}\n ${data.disabled ? 'aria-disabled=\"true\"' : ''}>\n ${template}\n ${data.label}\n <button type=\"button\"\n class=\"${classNames.button}\"\n aria-label=\"${removeItemText(data.label)}\"\n data-button>${removeItemText(data.label)}</button>\n </div>`\n );\n },\n choice: function ({ classNames }: { classNames: ClassNames }, data: Item) {\n const template = getOptionTemplate(data);\n const className = `${String(classNames.item)} ${String(classNames.itemChoice)}\n ${String(data.disabled ? classNames.itemDisabled : classNames.itemSelectable)}\n ${data.selected ? 'choices__item--selected' : ''}`;\n return strToEl(\n `<div class=\"${className}\"\n data-select-text=\"${itemSelectText}\"\n data-choice data-id=\"${String(data.id)}\" data-value=\"${String(data.value)}\"\n ${data.disabled ? 'data-choice-disabled aria-disabled=\"true\"' : 'data-choice-selectable'}\n ${data.groupId && data.groupId > 0 ? 'role=\"treeitem\"' : 'role=\"option\"'}>\n ${template}\n </div>`\n );\n }\n };\n }\n };\n\n const settings: Partial<Options> = this.multiple\n ? { ...config, ...configMultiple }\n : { ...config, ...configSingle };\n this.choice = new Choices(this.selectElement, settings);\n this.choice.setChoices(this.choices);\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onChange() {\n this.value = this.choice?.getValue();\n this.catChange.emit(this.choice?.getValue());\n if (this.multiple) {\n this.updateRemoveItemButtonVisibility();\n }\n }\n\n private onSearch(event: Event) {\n const customEvent = event as CustomEvent<{ value: string }>;\n this.catSearch.emit(customEvent.detail.value);\n }\n\n private onScrolledBottom() {\n const scrolledBottom: boolean =\n this.choiceDropdown?.scrollHeight ===\n (this.choiceDropdown?.scrollTop || 0) + (this.choiceDropdown?.clientHeight || 0);\n\n if (scrolledBottom) {\n this.catScrolledBottom.emit();\n }\n }\n\n private onChoice(event: Event) {\n const customEvent = event as CustomEvent<{ choice: Choice }>;\n const items = Array.from(this.choice?.getValue() as Item[]);\n const item = items.find(value => value.choiceId === customEvent.detail.choice.id);\n if (item) {\n this.choice?._removeItem(item);\n }\n }\n\n private showDropdownHandler() {\n if (!this.disabled) {\n this.choice?.showDropdown();\n }\n }\n\n private createRemoveItemButton() {\n this.removeElement = document.createElement('cat-button') as HTMLCatButtonElement;\n this.removeElement.icon = 'cross-circle-outlined';\n this.removeElement.iconOnly = true;\n this.removeElement.a11yLabel = this.i18n.t('select.removeItem');\n this.updateRemoveItemButtonVisibility();\n this.removeElement.addEventListener('click', this.onRemoveItemButtonClick.bind(this));\n this.choiceInner?.appendChild(this.removeElement);\n }\n\n private updateRemoveItemButtonVisibility() {\n const items = Array.from(this.choice?.getValue() as Item[]);\n if (items.length) {\n this.removeElement?.removeAttribute('hidden');\n } else if (!items.length) {\n this.removeElement?.setAttribute('hidden', 'true');\n }\n }\n\n private onRemoveItemButtonClick(event: Event) {\n event.stopPropagation();\n this.choice?.removeActiveItems(-1);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cat-select.js","sourceRoot":"","sources":["../../../src/components/cat-select/cat-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,OAA8C,MAAM,YAAY,CAAC;AACxE,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,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tC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAA,IAAI,CAAC,MAAM,0CAAE,QAAQ,EAAY,CAAC,CAAC;IAC5D,IAAI,KAAK,CAAC,MAAM,EAAE;MAChB,MAAA,IAAI,CAAC,aAAa,0CAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;KAC/C;SAAM;MACL,MAAA,IAAI,CAAC,aAAa,0CAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;KACpD;EACH,CAAC;EAEO,uBAAuB,CAAC,KAAY;;IAC1C,KAAK,CAAC,eAAe,EAAE,CAAC;IACxB,MAAA,IAAI,CAAC,MAAM,0CAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,CAAC,gCAAgC,EAAE,CAAC;EAC1C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Prop, State, Watch } from '@stencil/core';\nimport Choices, { Choice, ClassNames, Item, Options } from 'choices.js';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\nimport { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';\n\nlet nextUniqueId = 0;\n\nconst getOptionTemplate = (data: Item): string => {\n if (data.customProperties?.imageUrl) {\n return `\n <div class=\"d-flex align-items-center\">\n <img class=\"choices-option-icon\" src=\"${data.customProperties.imageUrl}\" style=\"margin-right: 0.5rem\" />\n ${data.label}\n </div>\n `;\n }\n return `<cat-checkbox label=\"${data.label}\" checked=\"${data.selected}\"></cat-checkbox>`;\n};\n\n/**\n * A single option in the select.\n */\nexport type CatSelectItem = Pick<Choice, 'label' | 'value' | 'customProperties'>;\n\n/**\n * Select lets user choose one option from an options menu. Consider using\n * select when you have 6 or more options. Select component supports any content\n * type.\n *\n * @slot hint - Optional hint element to be displayed with the select.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-select',\n styleUrl: 'cat-select.scss',\n shadow: true\n})\nexport class CatSelect {\n private readonly i18n = CatI18nRegistry.getInstance();\n private readonly id = `cat-select-${nextUniqueId++}`;\n private resetItemsOnNextValueChange = true;\n\n private choice?: Choices;\n private choiceInner?: Element;\n private choiceDropdown?: Element;\n private selectElement?: HTMLSelectElement;\n private removeElement?: HTMLCatButtonElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * The label for the select.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The available options for the input.\n */\n @Prop() items: CatSelectItem[] = [];\n\n /**\n * The value of the select.\n */\n @Prop({ mutable: true }) value?: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /**\n * Disable the select.\n */\n @Prop() disabled = false;\n\n /**\n * Enable multiple selection.\n */\n @Prop() multiple = false;\n\n /**\n * The placeholder for the select.\n */\n @Prop() placeholder = '';\n\n /**\n * Whether the dropdown should appear above `(top)` or below `(bottom)` the\n * input. By default, if there is not enough space within the window the\n * dropdown will appear above the input, otherwise below it.\n */\n @Prop() position: 'auto' | 'top' | 'bottom' = 'auto';\n\n /**\n * Enable search for the select.\n */\n @Prop() search = false;\n\n /**\n * Optional hint text(s) to be displayed with the select.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the search is triggered.\n */\n @Event() catSearch!: EventEmitter;\n\n /**\n * Emitted when scrolled to the bottom.\n */\n @Event() catScrolledBottom!: EventEmitter;\n\n @Watch('items')\n setChoicesHandler(items: CatSelectItem[]) {\n const isSelected = (item: CatSelectItem) => this.value?.includes(item.value);\n const choices = items.map(item => ({ ...item, selected: isSelected(item) }));\n this.choice?.setChoices(choices, 'value', 'label', true);\n\n const vItems = this.choice?.getValue() || [];\n const vItemsArray = (Array.isArray(vItems) ? vItems : [vItems]) as Item[];\n const vItemValues = [...this.value];\n\n // remove duplicate items\n this.choice?.unhighlightAll();\n vItemsArray.forEach(vItem => {\n const index = vItemValues.indexOf(vItem.value);\n if (index > -1) {\n vItemValues.splice(index, 1);\n } else {\n vItem.choiceId = -1; // disconnect item from choice\n this.choice?.highlightItem(vItem, false);\n }\n });\n this.choice?.removeHighlightedItems(false);\n }\n\n @Watch('value')\n setValueHandler(value?: any) { // eslint-disable-line @typescript-eslint/no-explicit-any\n if (this.resetItemsOnNextValueChange) {\n this.choice?.removeActiveItems(-1);\n }\n this.resetItemsOnNextValueChange = true;\n this.choice?.setChoiceByValue(value);\n this.multiple && this.updateRemoveItemButtonVisibility();\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on select', this);\n }\n }\n\n componentDidLoad(): void {\n this.init();\n const attachedInternals: ElementInternals | undefined = this.hostElement.attachInternals?.();\n if (attachedInternals) {\n const root = attachedInternals.shadowRoot;\n this.choiceInner = root?.querySelector('.choices__inner') || undefined;\n this.choiceDropdown = root?.querySelector('.choices__list--dropdown')?.firstElementChild || undefined;\n }\n this.choiceInner?.addEventListener('click', this.showDropdownHandler.bind(this));\n this.selectElement?.addEventListener('change', this.onChange.bind(this));\n this.selectElement?.addEventListener('search', this.onSearch.bind(this));\n this.choiceDropdown?.addEventListener('scroll', this.onScrolledBottom.bind(this));\n if (this.multiple) {\n this.selectElement?.addEventListener('choice', this.onChoice.bind(this));\n this.createRemoveItemButton();\n }\n }\n\n disconnectedCallback(): void {\n this.choice?.destroy();\n this.choice = undefined;\n this.choiceInner?.removeEventListener('click', this.showDropdownHandler.bind(this));\n this.selectElement?.removeEventListener('change', this.onChange.bind(this));\n this.selectElement?.removeEventListener('search', this.onSearch.bind(this));\n this.choiceDropdown?.removeEventListener('scroll', this.onScrolledBottom.bind(this));\n if (this.multiple) {\n this.removeElement?.removeEventListener('choice', this.onChoice.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n {!this.required && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n ({this.i18n.t('input.optional')})\n </span>\n )}\n </span>\n </label>\n )}\n <select\n id={this.id}\n ref={el => (this.selectElement = el)}\n multiple={this.multiple}\n disabled={this.disabled}\n ></select>\n {this.hintSection}\n </Host>\n );\n }\n\n private init() {\n const component = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const removeItemText = (value: string) => this.i18n.t('select.removeItem', { value });\n const config = {\n allowHTML: true,\n removeItemButton: true,\n duplicateItemsAllowed: false,\n delimiter: '',\n paste: false,\n searchEnabled: this.search,\n searchChoices: false,\n position: this.position,\n resetScrollPosition: false,\n placeholder: !!this.placeholder,\n placeholderValue: this.placeholder || '',\n searchPlaceholderValue: this.i18n.t('select.searchPlaceholder'),\n renderSelectedChoices: 'always' as 'auto' | 'always',\n loadingText: this.i18n.t('select.loading'),\n noResultsText: this.i18n.t('select.noResults'),\n noChoicesText: this.i18n.t('select.noChoices'),\n itemSelectText: this.i18n.t('select.selectItem'),\n addItemText: (value: string) => this.i18n.t('select.addItem', { value }),\n maxItemText: (maxItemCount: number) => this.i18n.t('select.maxItem', { maxItemCount }),\n uniqueItemText: this.i18n.t('select.uniqueItem'),\n customAddItemText: this.i18n.t('select.customAddItem'),\n callbackOnInit: function () {\n const choice = this as unknown as Choices;\n choice.setChoices(component.items, 'value', 'label', true);\n choice.setChoiceByValue(component.value);\n }\n };\n\n const configSingle = {\n callbackOnCreateTemplates: (strToEl: (str: string) => HTMLElement) => {\n return {\n item: ({ classNames }: { classNames: ClassNames }, data: Item) => {\n const template = data.customProperties?.imageUrl\n ? `<img class=\"choices-option-icon\" src=\"${data.customProperties.imageUrl}\" style=\"margin-right: 0.5rem\" />`\n : '';\n return strToEl(\n `\n <div class=\"${classNames.item} ${\n data.highlighted ? classNames.highlightedState : classNames.itemSelectable\n } ${data.placeholder ? classNames.placeholder : ''}\" data-item data-id=\"${data.id}\" data-value=\"${\n data.value\n }\" ${data.active ? 'aria-selected=\"true\"' : ''} ${data.disabled ? 'aria-disabled=\"true\"' : ''}>\n <span>${template}</span> ${data.label}\n <button type=\"button\"\n class=\"${classNames.button}\"\n aria-label=\"${removeItemText(data.label)}\"\n data-button>${removeItemText(data.label)}</button>\n </div>\n `\n );\n }\n };\n }\n };\n\n const configMultiple = {\n callbackOnCreateTemplates: (strToEl: (str: string) => HTMLElement) => {\n const itemSelectText = config.itemSelectText;\n return {\n item: ({ classNames }: { classNames: ClassNames }, data: Item) => {\n const template = data.customProperties?.imageUrl\n ? `<img class=\"choices-option-icon\" src=\"${data.customProperties.imageUrl}\" style=\"margin-right: 0.5rem;\" />`\n : '';\n return strToEl(\n `<div class=\"\n ${classNames.item}\n ${data.highlighted ? classNames.highlightedState : classNames.itemSelectable}\n ${data.placeholder ? classNames.placeholder : ''}\"\n data-item data-id=\"${data.id}\" data-value=\"${data.value}\"\n ${data.active ? 'aria-selected=\"true\"' : ''}\n ${data.disabled ? 'aria-disabled=\"true\"' : ''}>\n ${template}\n ${data.label}\n <button type=\"button\"\n class=\"${classNames.button}\"\n aria-label=\"${removeItemText(data.label)}\"\n data-button>${removeItemText(data.label)}</button>\n </div>`\n );\n },\n choice: function ({ classNames }: { classNames: ClassNames }, data: Item) {\n const template = getOptionTemplate(data);\n const className = `${String(classNames.item)} ${String(classNames.itemChoice)}\n ${String(data.disabled ? classNames.itemDisabled : classNames.itemSelectable)}\n ${data.selected ? 'choices__item--selected' : ''}`;\n return strToEl(\n `<div class=\"${className}\"\n data-select-text=\"${itemSelectText}\"\n data-choice data-id=\"${String(data.id)}\" data-value=\"${String(data.value)}\"\n ${data.disabled ? 'data-choice-disabled aria-disabled=\"true\"' : 'data-choice-selectable'}\n ${data.groupId && data.groupId > 0 ? 'role=\"treeitem\"' : 'role=\"option\"'}>\n ${template}\n </div>`\n );\n }\n };\n }\n };\n\n const settings: Partial<Options> = this.multiple\n ? { ...config, ...configMultiple }\n : { ...config, ...configSingle };\n this.choice = new Choices(this.selectElement, settings);\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onChange() {\n this.resetItemsOnNextValueChange = false;\n this.value = this.choice?.getValue(true);\n this.catChange.emit(this.value);\n }\n\n private onChoice(event: Event) {\n const customEvent = event as CustomEvent<{ choice: Choice }>;\n const coice = customEvent.detail.choice;\n if (coice.selected) {\n this.choice?.removeActiveItemsByValue(coice.value);\n this.onChange();\n }\n }\n\n private onSearch(event: Event) {\n const customEvent = event as CustomEvent<{ value: string }>;\n this.catSearch.emit(customEvent.detail.value);\n }\n\n private onScrolledBottom() {\n const scrolledBottom =\n this.choiceDropdown?.scrollHeight ===\n (this.choiceDropdown?.scrollTop || 0) + (this.choiceDropdown?.clientHeight || 0);\n if (scrolledBottom) {\n this.catScrolledBottom.emit();\n }\n }\n\n private showDropdownHandler() {\n !this.disabled && this.choice?.showDropdown();\n }\n\n private createRemoveItemButton() {\n this.removeElement = document.createElement('cat-button') as HTMLCatButtonElement;\n this.removeElement.icon = 'cross-circle-outlined';\n this.removeElement.iconOnly = true;\n this.removeElement.a11yLabel = this.i18n.t('select.removeItem');\n this.updateRemoveItemButtonVisibility();\n this.removeElement.addEventListener('click', this.onRemoveItemButtonClick.bind(this));\n this.choiceInner?.appendChild(this.removeElement);\n }\n\n private updateRemoveItemButtonVisibility() {\n const items = Array.from(this.choice?.getValue() as Item[]);\n if (items.length) {\n this.removeElement?.removeAttribute('hidden');\n } else {\n this.removeElement?.setAttribute('hidden', 'true');\n }\n }\n\n private onRemoveItemButtonClick(event: Event) {\n event.stopPropagation();\n this.choice?.removeActiveItems(-1);\n this.updateRemoveItemButtonVisibility();\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
2
|
|
|
3
|
-
const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.badge-round{border-radius:10rem}.badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.badge-xs{height:
|
|
3
|
+
const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.badge-round{border-radius:10rem}.badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.badge-xs{height:1rem;min-width:0.75rem;font-size:12px;padding:0 0.25rem}.badge-s{height:1.5rem;min-width:1rem;font-size:12px;padding:0 0.5rem}.badge-m{height:2rem;min-width:1.25rem;font-size:13px;padding:0 0.75rem}.badge-l{height:2.5rem;min-width:1.5rem;font-size:15px;padding:0 1rem}.badge-xl{height:3rem;min-width:1.75rem;font-size:18px;padding:0 1rem}.badge-pulse.badge-filled{animation:1.5s ease 0s infinite normal none running pulse}.badge-pulse.badge-outlined{animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
|
|
4
4
|
|
|
5
5
|
const CatBadge$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
6
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"cat-badge.js","mappings":";;AAAA,MAAM,WAAW,GAAG,
|
|
1
|
+
{"file":"cat-badge.js","mappings":";;AAAA,MAAM,WAAW,GAAG,woEAAwoE;;MCa/oEA,UAAQ;EALrB;;;;;;;IASU,YAAO,GAA0B,QAAQ,CAAC;;;;IAK1C,UAAK,GAA+D,SAAS,CAAC;;;;IAK9E,SAAI,GAAkC,GAAG,CAAC;;;;IAK1C,UAAK,GAAG,KAAK,CAAC;;;;IAKd,UAAK,GAAG,KAAK,CAAC;GAmBvB;EAjBC,MAAM;IACJ,QACE,YACE,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE;QACL,KAAK,EAAE,IAAI;QACX,aAAa,EAAE,IAAI,CAAC,KAAK;QACzB,aAAa,EAAE,IAAI,CAAC,KAAK;QACzB,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QAChD,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5C,CAAC,SAAS,IAAI,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;OAC3C,IAED,eAAa,CACR,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatBadge"],"sources":["./src/components/cat-badge/cat-badge.scss?tag=cat-badge&encapsulation=shadow","./src/components/cat-badge/cat-badge.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: inline-flex;\n max-width: 100%;\n vertical-align: baseline;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.badge {\n font: inherit;\n flex: 1 1 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border-radius: cat-border-radius('s');\n text-decoration: none;\n width: 100%;\n box-sizing: border-box;\n line-height: 1;\n white-space: nowrap;\n\n slot {\n display: inline-block;\n @include cat-ellipsis;\n }\n}\n\n// ----- round\n\n.badge-round {\n border-radius: 10rem;\n}\n\n// ----- theme\n\n.badge-filled {\n background-color: cat-token-wrap(var(--bg));\n color: cat-token-wrap(var(--fill));\n font-weight: 600;\n @include cat-font-smooth;\n}\n\n$-outline: inset 0 0 0 1px cat-token-wrap(var(--border), $alpha: 0.2);\n\n.badge-outlined {\n background-color: cat-token('color.ui.background.body');\n box-shadow: $-outline;\n color: cat-token-wrap(var(--text));\n}\n\n@mixin theme($theme) {\n .badge-#{$theme} {\n --bg: #{cat-token('color.theme.#{$theme}.bg', $wrap: false)};\n --fill: #{cat-token('color.theme.#{$theme}.fill', $wrap: false)};\n --text: #{cat-token('color.theme.#{$theme}.text', $wrap: false)};\n @if $theme == 'secondary' {\n --border: #{cat-token('color.theme.#{$theme}.bg', $wrap: false)};\n } @else {\n --border: #{cat-token('color.theme.#{$theme}.text', $wrap: false)};\n }\n }\n}\n\n@include theme('primary');\n@include theme('secondary');\n@include theme('success');\n@include theme('warning');\n@include theme('danger');\n\n// ----- size\n\n@mixin size($size, $fontSize) {\n .badge-#{$size} {\n height: cat-token('size.badge.height.#{$size}');\n min-width: cat-size($size) * 0.5;\n font-size: cat-token('size.badge.font.#{$size}');\n padding: 0 cat-token('size.badge.padding.horizontal.#{$size}');\n }\n}\n\n@include size('xs', 'xs');\n@include size('s', 's');\n@include size('m', 'm');\n@include size('l', 'l');\n@include size('xl', 'xl');\n\n// ----- pulse\n\n$-pulse-0: 0 0 0 0 cat-token-wrap(var(--bg));\n$-pulse-70: transparent 0 0 0 0.5rem;\n$-pulse-100: transparent 0 0 0 0;\n\n.badge-pulse {\n &.badge-filled {\n animation: 1.5s ease 0s infinite normal none running pulse;\n }\n\n &.badge-outlined {\n animation: 1.5s ease 0s infinite normal none running pulse-outlined;\n }\n}\n\n@keyframes pulse {\n 0% {\n box-shadow: $-pulse-0;\n }\n\n 70% {\n box-shadow: $-pulse-70;\n }\n\n 100% {\n box-shadow: $-pulse-100;\n }\n}\n\n@keyframes pulse-outlined {\n 0% {\n box-shadow: $-pulse-0, $-outline;\n }\n\n 70% {\n box-shadow: $-pulse-70, $-outline;\n }\n\n 100% {\n box-shadow: $-pulse-100, $-outline;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * Badges are used to inform users of the status of an object or of an action\n * that’s been taken.\n *\n * @part badge - The badge element.\n */\n@Component({\n tag: 'cat-badge',\n styleUrl: 'cat-badge.scss',\n shadow: true\n})\nexport class CatBadge {\n /**\n * The rendering style of the badge.\n */\n @Prop() variant: 'filled' | 'outlined' = 'filled';\n\n /**\n * The color palette of the badge.\n */\n @Prop() color: 'primary' | 'secondary' | 'danger' | 'success' | 'warning' = 'primary';\n\n /**\n * The size of the badge.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' = 'm';\n\n /**\n * Use round badge edges.\n */\n @Prop() round = false;\n\n /**\n * Draw attention to the badge with a subtle animation.\n */\n @Prop() pulse = false;\n\n render() {\n return (\n <span\n part=\"badge\"\n class={{\n badge: true,\n 'badge-round': this.round,\n 'badge-pulse': this.pulse,\n [`badge-${this.variant}`]: Boolean(this.variant),\n [`badge-${this.color}`]: Boolean(this.color),\n [`badge-${this.size}`]: Boolean(this.size)\n }}\n >\n <slot></slot>\n </span>\n );\n }\n}\n"],"version":3}
|