@haiilo/catalyst 0.10.8 → 0.13.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.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/p-4ced6c7c.entry.js +12 -0
- package/dist/catalyst/p-4ced6c7c.entry.js.map +1 -0
- package/dist/catalyst/p-f88f8914.js +10 -0
- package/dist/catalyst/p-f88f8914.js.map +1 -0
- package/dist/catalyst/scss/core/_base.scss +0 -1
- package/dist/catalyst/scss/index.scss +1 -1
- package/dist/catalyst/scss/utils/_layout.scss +4 -4
- package/dist/catalyst/scss/utils/_sizing.mixins.scss +0 -4
- package/dist/catalyst/scss/utils/_typography.mixins.scss +3 -3
- package/dist/cjs/{cat-alert_21.cjs.entry.js → cat-alert_22.cjs.entry.js} +245 -130
- package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -0
- package/dist/cjs/{cat-notification-c2859ed7.js → cat-notification-444c9ea0.js} +331 -14
- package/dist/cjs/cat-notification-444c9ea0.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +1 -2
- package/dist/cjs/index.cjs.js.map +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-button/cat-button.css +185 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +16 -9
- package/dist/collection/components/cat-input/cat-input.css +3 -0
- 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 +4 -0
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +35 -4
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.css +4 -2
- package/dist/collection/components/cat-select/cat-select.js +136 -200
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +3 -0
- package/dist/collection/components/cat-toggle/cat-toggle.css +9 -9
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +2 -3
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/scss/core/_base.scss +0 -1
- package/dist/collection/scss/index.scss +1 -1
- package/dist/collection/scss/utils/_layout.scss +4 -4
- package/dist/collection/scss/utils/_sizing.mixins.scss +0 -4
- package/dist/collection/scss/utils/_typography.mixins.scss +3 -3
- package/dist/components/cat-avatar.js.map +1 -1
- package/dist/components/cat-badge.js +1 -1
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox.js +1 -1
- package/dist/components/cat-checkbox.js.map +1 -1
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +1 -1
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-radio-group.js +7 -3
- 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 +112 -100
- package/dist/components/cat-select.js.map +1 -1
- package/dist/components/cat-skeleton.js.map +1 -1
- package/dist/components/cat-spinner2.js.map +1 -1
- package/dist/components/cat-textarea.js +1 -1
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +1 -1
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +1 -1
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/esm/{cat-alert_21.entry.js → cat-alert_22.entry.js} +230 -116
- package/dist/esm/cat-alert_22.entry.js.map +1 -0
- package/dist/esm/{cat-notification-3da6ddb1.js → cat-notification-953c785d.js} +317 -3
- package/dist/esm/cat-notification-953c785d.js.map +1 -0
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +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 +14 -0
- package/dist/types/components/cat-select/cat-select.d.ts +22 -28
- package/dist/types/components.d.ts +36 -35
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/catalyst/p-2ad6f8d8.js +0 -2
- package/dist/catalyst/p-2ad6f8d8.js.map +0 -1
- package/dist/catalyst/p-6fce43dd.js +0 -2
- package/dist/catalyst/p-6fce43dd.js.map +0 -1
- package/dist/catalyst/p-8121572a.js +0 -10
- package/dist/catalyst/p-8121572a.js.map +0 -1
- package/dist/catalyst/p-c0b4200d.entry.js +0 -2
- package/dist/catalyst/p-c0b4200d.entry.js.map +0 -1
- package/dist/catalyst/p-e5c5e21d.entry.js +0 -12
- package/dist/catalyst/p-e5c5e21d.entry.js.map +0 -1
- package/dist/cjs/cat-alert_21.cjs.entry.js.map +0 -1
- package/dist/cjs/cat-form-hint-25fdfed5.js +0 -22
- package/dist/cjs/cat-form-hint-25fdfed5.js.map +0 -1
- package/dist/cjs/cat-notification-c2859ed7.js.map +0 -1
- package/dist/cjs/cat-textarea.cjs.entry.js +0 -92
- package/dist/cjs/cat-textarea.cjs.entry.js.map +0 -1
- package/dist/cjs/loglevel-b5d158ad.js +0 -324
- package/dist/cjs/loglevel-b5d158ad.js.map +0 -1
- package/dist/esm/cat-alert_21.entry.js.map +0 -1
- package/dist/esm/cat-form-hint-790d1e46.js +0 -20
- package/dist/esm/cat-form-hint-790d1e46.js.map +0 -1
- package/dist/esm/cat-notification-3da6ddb1.js.map +0 -1
- package/dist/esm/cat-textarea.entry.js +0 -88
- package/dist/esm/cat-textarea.entry.js.map +0 -1
- package/dist/esm/loglevel-c8b59c3a.js +0 -319
- package/dist/esm/loglevel-c8b59c3a.js.map +0 -1
|
@@ -192,6 +192,7 @@ label + p {
|
|
|
192
192
|
.hint-section ::slotted([slot=hint]) {
|
|
193
193
|
font-size: 0.875rem;
|
|
194
194
|
line-height: 1rem;
|
|
195
|
+
font-weight: var(--cat-font-weight-body, 400);
|
|
195
196
|
margin: 0;
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -201,6 +202,7 @@ label + p {
|
|
|
201
202
|
gap: 0.5rem;
|
|
202
203
|
font-size: 0.9375rem;
|
|
203
204
|
line-height: 1.25rem;
|
|
205
|
+
font-weight: var(--cat-font-weight-body, 400);
|
|
204
206
|
margin-bottom: 1rem;
|
|
205
207
|
}
|
|
206
208
|
|
|
@@ -230,6 +232,7 @@ label.hidden {
|
|
|
230
232
|
margin-left: 0.25rem;
|
|
231
233
|
font-size: 0.75rem;
|
|
232
234
|
line-height: 1rem;
|
|
235
|
+
font-weight: var(--cat-font-weight-body, 400);
|
|
233
236
|
color: rgb(var(--cat-font-color-muted, 105, 118, 135));
|
|
234
237
|
}
|
|
235
238
|
|
|
@@ -238,7 +241,7 @@ label.hidden {
|
|
|
238
241
|
overflow: hidden;
|
|
239
242
|
font-size: 16px;
|
|
240
243
|
}
|
|
241
|
-
.choices:focus {
|
|
244
|
+
.choices.is-focused, .choices:focus {
|
|
242
245
|
outline: none;
|
|
243
246
|
box-shadow: 0 1px 4px 0 #101d3033;
|
|
244
247
|
}
|
|
@@ -247,7 +250,6 @@ label.hidden {
|
|
|
247
250
|
}
|
|
248
251
|
.choices.is-open {
|
|
249
252
|
overflow: visible;
|
|
250
|
-
box-shadow: 0 1px 4px 0 #101d3033;
|
|
251
253
|
}
|
|
252
254
|
.choices.is-disabled .choices__inner,
|
|
253
255
|
.choices.is-disabled .choices__input {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Component, Element, Event, h, Host,
|
|
1
|
+
import { Component, Element, Event, h, Host, Prop, State, Watch, Listen } 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,41 @@ 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 value = this.value || [];
|
|
81
|
+
const vItemValues = [...value];
|
|
82
|
+
// remove duplicate items
|
|
83
|
+
(_c = this.choice) === null || _c === void 0 ? void 0 : _c.unhighlightAll();
|
|
84
|
+
vItemsArray.forEach(vItem => {
|
|
85
|
+
var _a;
|
|
86
|
+
const index = vItemValues.indexOf(vItem.value);
|
|
87
|
+
if (index > -1) {
|
|
88
|
+
vItemValues.splice(index, 1);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
vItem.choiceId = -1; // disconnect item from choice
|
|
92
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.highlightItem(vItem, false);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
(_d = this.choice) === null || _d === void 0 ? void 0 : _d.removeHighlightedItems(false);
|
|
76
96
|
}
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
98
|
setValueHandler(value) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
var _a, _b;
|
|
100
|
+
if (this.resetItemsOnNextValueChange) {
|
|
101
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
|
|
102
|
+
}
|
|
103
|
+
this.resetItemsOnNextValueChange = true;
|
|
104
|
+
(_b = this.choice) === null || _b === void 0 ? void 0 : _b.setChoiceByValue(value);
|
|
105
|
+
this.multiple && this.updateRemoveItemButtonVisibility();
|
|
81
106
|
}
|
|
82
107
|
componentWillRender() {
|
|
83
108
|
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
@@ -86,73 +111,46 @@ export class CatSelect {
|
|
|
86
111
|
}
|
|
87
112
|
}
|
|
88
113
|
componentDidLoad() {
|
|
89
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
90
115
|
this.init();
|
|
91
116
|
const attachedInternals = (_b = (_a = this.hostElement).attachInternals) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
92
117
|
if (attachedInternals) {
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
|
|
118
|
+
const root = attachedInternals.shadowRoot;
|
|
119
|
+
this.choicesElement = (root === null || root === void 0 ? void 0 : root.querySelector('.choices')) || undefined;
|
|
120
|
+
this.choiceInner = (root === null || root === void 0 ? void 0 : root.querySelector('.choices__inner')) || undefined;
|
|
121
|
+
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
122
|
}
|
|
97
|
-
(
|
|
98
|
-
(
|
|
99
|
-
(
|
|
100
|
-
(
|
|
101
|
-
(
|
|
123
|
+
(_d = this.choicesElement) === null || _d === void 0 ? void 0 : _d.addEventListener('click', this.resetFocus.bind(this));
|
|
124
|
+
(_e = this.choiceInner) === null || _e === void 0 ? void 0 : _e.addEventListener('click', this.showDropdownHandler.bind(this));
|
|
125
|
+
(_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.addEventListener('hideDropdown', this.showMultipleFocus.bind(this));
|
|
126
|
+
(_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.addEventListener('showDropdown', this.showMultipleFocus.bind(this));
|
|
127
|
+
(_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('removeItem', this.resetFocus.bind(this));
|
|
128
|
+
(_j = this.selectElement) === null || _j === void 0 ? void 0 : _j.addEventListener('change', this.onChange.bind(this));
|
|
129
|
+
(_k = this.selectElement) === null || _k === void 0 ? void 0 : _k.addEventListener('search', this.onSearch.bind(this));
|
|
130
|
+
(_l = this.choiceDropdown) === null || _l === void 0 ? void 0 : _l.addEventListener('scroll', this.onScrolledBottom.bind(this));
|
|
102
131
|
if (this.multiple) {
|
|
103
|
-
(
|
|
132
|
+
(_m = this.selectElement) === null || _m === void 0 ? void 0 : _m.addEventListener('choice', this.onChoice.bind(this));
|
|
104
133
|
this.createRemoveItemButton();
|
|
105
134
|
}
|
|
106
135
|
}
|
|
107
136
|
disconnectedCallback() {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
109
138
|
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
110
139
|
this.choice = undefined;
|
|
111
|
-
(_b = this.
|
|
112
|
-
(_c = this.
|
|
113
|
-
(_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('
|
|
114
|
-
(_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.removeEventListener('
|
|
115
|
-
(_f = this.
|
|
140
|
+
(_b = this.choicesElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.resetFocus.bind(this));
|
|
141
|
+
(_c = this.choiceInner) === null || _c === void 0 ? void 0 : _c.removeEventListener('click', this.showDropdownHandler.bind(this));
|
|
142
|
+
(_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('hideDropdown', this.showMultipleFocus.bind(this));
|
|
143
|
+
(_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.removeEventListener('showDropdown', this.showMultipleFocus.bind(this));
|
|
144
|
+
(_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('removeItem', this.resetFocus.bind(this));
|
|
145
|
+
(_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.removeEventListener('change', this.onChange.bind(this));
|
|
146
|
+
(_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.removeEventListener('search', this.onSearch.bind(this));
|
|
147
|
+
(_j = this.choiceDropdown) === null || _j === void 0 ? void 0 : _j.removeEventListener('scroll', this.onScrolledBottom.bind(this));
|
|
116
148
|
if (this.multiple) {
|
|
117
|
-
(
|
|
118
|
-
(_h = this.removeElement) === null || _h === void 0 ? void 0 : _h.removeEventListener('click', this.onRemoveItemButtonClick.bind(this));
|
|
149
|
+
(_k = this.removeElement) === null || _k === void 0 ? void 0 : _k.removeEventListener('choice', this.onChoice.bind(this));
|
|
119
150
|
}
|
|
120
151
|
}
|
|
121
|
-
|
|
122
|
-
|
|
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;
|
|
152
|
+
onBlur(event) {
|
|
153
|
+
this.catBlur.emit(event);
|
|
156
154
|
}
|
|
157
155
|
render() {
|
|
158
156
|
return (h(Host, null,
|
|
@@ -167,16 +165,15 @@ export class CatSelect {
|
|
|
167
165
|
this.hintSection));
|
|
168
166
|
}
|
|
169
167
|
init() {
|
|
170
|
-
const
|
|
168
|
+
const component = this; // eslint-disable-line @typescript-eslint/no-this-alias
|
|
171
169
|
const removeItemText = (value) => this.i18n.t('select.removeItem', { value });
|
|
172
170
|
const config = {
|
|
173
171
|
allowHTML: true,
|
|
174
|
-
items: Array.isArray(value) ? value : [value],
|
|
175
172
|
removeItemButton: true,
|
|
176
173
|
duplicateItemsAllowed: false,
|
|
177
174
|
delimiter: '',
|
|
178
175
|
paste: false,
|
|
179
|
-
searchEnabled:
|
|
176
|
+
searchEnabled: this.search,
|
|
180
177
|
searchChoices: false,
|
|
181
178
|
position: this.position,
|
|
182
179
|
resetScrollPosition: false,
|
|
@@ -191,7 +188,12 @@ export class CatSelect {
|
|
|
191
188
|
addItemText: (value) => this.i18n.t('select.addItem', { value }),
|
|
192
189
|
maxItemText: (maxItemCount) => this.i18n.t('select.maxItem', { maxItemCount }),
|
|
193
190
|
uniqueItemText: this.i18n.t('select.uniqueItem'),
|
|
194
|
-
customAddItemText: this.i18n.t('select.customAddItem')
|
|
191
|
+
customAddItemText: this.i18n.t('select.customAddItem'),
|
|
192
|
+
callbackOnInit: function () {
|
|
193
|
+
const choice = this;
|
|
194
|
+
choice.setChoices(component.items, 'value', 'label', true);
|
|
195
|
+
choice.setChoiceByValue(component.value);
|
|
196
|
+
}
|
|
195
197
|
};
|
|
196
198
|
const configSingle = {
|
|
197
199
|
callbackOnCreateTemplates: (strToEl) => {
|
|
@@ -257,18 +259,42 @@ export class CatSelect {
|
|
|
257
259
|
const settings = this.multiple
|
|
258
260
|
? Object.assign(Object.assign({}, config), configMultiple) : Object.assign(Object.assign({}, config), configSingle);
|
|
259
261
|
this.choice = new Choices(this.selectElement, settings);
|
|
260
|
-
this.choice.setChoices(this.choices);
|
|
261
262
|
}
|
|
262
263
|
get hintSection() {
|
|
263
264
|
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
264
265
|
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
265
266
|
}
|
|
266
267
|
onChange() {
|
|
268
|
+
var _a;
|
|
269
|
+
this.resetItemsOnNextValueChange = false;
|
|
270
|
+
this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue(true);
|
|
271
|
+
this.catChange.emit(this.value);
|
|
272
|
+
}
|
|
273
|
+
showMultipleFocus() {
|
|
267
274
|
var _a, _b;
|
|
268
|
-
this.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
if (this.multiple && this.isFocused() && !((_a = this.choicesElement) === null || _a === void 0 ? void 0 : _a.classList.contains('is-focused'))) {
|
|
276
|
+
(_b = this.choicesElement) === null || _b === void 0 ? void 0 : _b.classList.add('is-focused');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
resetFocus() {
|
|
280
|
+
var _a, _b, _c;
|
|
281
|
+
if (!this.isFocused()) {
|
|
282
|
+
if (!((_a = this.choicesElement) === null || _a === void 0 ? void 0 : _a.hasAttribute('tabindex'))) {
|
|
283
|
+
(_b = this.choicesElement) === null || _b === void 0 ? void 0 : _b.setAttribute('tabindex', '0');
|
|
284
|
+
}
|
|
285
|
+
(_c = this.choicesElement) === null || _c === void 0 ? void 0 : _c.focus();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
isFocused() {
|
|
289
|
+
return document.activeElement === this.hostElement;
|
|
290
|
+
}
|
|
291
|
+
onChoice(event) {
|
|
292
|
+
var _a;
|
|
293
|
+
const customEvent = event;
|
|
294
|
+
const choice = customEvent.detail.choice;
|
|
295
|
+
if (choice.selected) {
|
|
296
|
+
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItemsByValue(choice.value);
|
|
297
|
+
this.onChange();
|
|
272
298
|
}
|
|
273
299
|
}
|
|
274
300
|
onSearch(event) {
|
|
@@ -283,20 +309,9 @@ export class CatSelect {
|
|
|
283
309
|
this.catScrolledBottom.emit();
|
|
284
310
|
}
|
|
285
311
|
}
|
|
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
312
|
showDropdownHandler() {
|
|
296
313
|
var _a;
|
|
297
|
-
|
|
298
|
-
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown();
|
|
299
|
-
}
|
|
314
|
+
!this.disabled && ((_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown());
|
|
300
315
|
}
|
|
301
316
|
createRemoveItemButton() {
|
|
302
317
|
var _a;
|
|
@@ -310,11 +325,10 @@ export class CatSelect {
|
|
|
310
325
|
}
|
|
311
326
|
updateRemoveItemButtonVisibility() {
|
|
312
327
|
var _a, _b, _c;
|
|
313
|
-
|
|
314
|
-
if (items.length) {
|
|
328
|
+
if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) {
|
|
315
329
|
(_b = this.removeElement) === null || _b === void 0 ? void 0 : _b.removeAttribute('hidden');
|
|
316
330
|
}
|
|
317
|
-
else
|
|
331
|
+
else {
|
|
318
332
|
(_c = this.removeElement) === null || _c === void 0 ? void 0 : _c.setAttribute('hidden', 'true');
|
|
319
333
|
}
|
|
320
334
|
}
|
|
@@ -322,6 +336,7 @@ export class CatSelect {
|
|
|
322
336
|
var _a;
|
|
323
337
|
event.stopPropagation();
|
|
324
338
|
(_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
|
|
339
|
+
this.onChange();
|
|
325
340
|
}
|
|
326
341
|
static get is() { return "cat-select"; }
|
|
327
342
|
static get encapsulation() { return "shadow"; }
|
|
@@ -386,16 +401,15 @@ export class CatSelect {
|
|
|
386
401
|
"reflect": false,
|
|
387
402
|
"defaultValue": "false"
|
|
388
403
|
},
|
|
389
|
-
"
|
|
404
|
+
"items": {
|
|
390
405
|
"type": "unknown",
|
|
391
406
|
"mutable": false,
|
|
392
407
|
"complexType": {
|
|
393
|
-
"original": "
|
|
394
|
-
"resolved": "
|
|
408
|
+
"original": "CatSelectItem[]",
|
|
409
|
+
"resolved": "CatSelectItem[]",
|
|
395
410
|
"references": {
|
|
396
|
-
"
|
|
397
|
-
"location": "
|
|
398
|
-
"path": "choices.js"
|
|
411
|
+
"CatSelectItem": {
|
|
412
|
+
"location": "local"
|
|
399
413
|
}
|
|
400
414
|
}
|
|
401
415
|
},
|
|
@@ -408,23 +422,18 @@ export class CatSelect {
|
|
|
408
422
|
"defaultValue": "[]"
|
|
409
423
|
},
|
|
410
424
|
"value": {
|
|
411
|
-
"type": "
|
|
425
|
+
"type": "any",
|
|
412
426
|
"mutable": true,
|
|
413
427
|
"complexType": {
|
|
414
|
-
"original": "
|
|
415
|
-
"resolved": "
|
|
416
|
-
"references": {
|
|
417
|
-
"Choice": {
|
|
418
|
-
"location": "import",
|
|
419
|
-
"path": "choices.js"
|
|
420
|
-
}
|
|
421
|
-
}
|
|
428
|
+
"original": "any",
|
|
429
|
+
"resolved": "any",
|
|
430
|
+
"references": {}
|
|
422
431
|
},
|
|
423
432
|
"required": false,
|
|
424
433
|
"optional": true,
|
|
425
434
|
"docs": {
|
|
426
435
|
"tags": [],
|
|
427
|
-
"text": "The
|
|
436
|
+
"text": "The value of the select."
|
|
428
437
|
},
|
|
429
438
|
"attribute": "value",
|
|
430
439
|
"reflect": false
|
|
@@ -501,7 +510,7 @@ export class CatSelect {
|
|
|
501
510
|
"reflect": false,
|
|
502
511
|
"defaultValue": "'auto'"
|
|
503
512
|
},
|
|
504
|
-
"
|
|
513
|
+
"search": {
|
|
505
514
|
"type": "boolean",
|
|
506
515
|
"mutable": false,
|
|
507
516
|
"complexType": {
|
|
@@ -515,7 +524,7 @@ export class CatSelect {
|
|
|
515
524
|
"tags": [],
|
|
516
525
|
"text": "Enable search for the select."
|
|
517
526
|
},
|
|
518
|
-
"attribute": "
|
|
527
|
+
"attribute": "search",
|
|
519
528
|
"reflect": false,
|
|
520
529
|
"defaultValue": "false"
|
|
521
530
|
},
|
|
@@ -585,113 +594,40 @@ export class CatSelect {
|
|
|
585
594
|
"resolved": "any",
|
|
586
595
|
"references": {}
|
|
587
596
|
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
"
|
|
592
|
-
|
|
593
|
-
|
|
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
|
-
},
|
|
597
|
+
}, {
|
|
598
|
+
"method": "catBlur",
|
|
599
|
+
"name": "catBlur",
|
|
600
|
+
"bubbles": true,
|
|
601
|
+
"cancelable": true,
|
|
602
|
+
"composed": true,
|
|
650
603
|
"docs": {
|
|
651
|
-
"
|
|
652
|
-
"
|
|
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>"
|
|
604
|
+
"tags": [],
|
|
605
|
+
"text": "Emitted when the select loses focus."
|
|
665
606
|
},
|
|
666
|
-
"docs": {
|
|
667
|
-
"text": "Clear all choices from select.",
|
|
668
|
-
"tags": []
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
"clearInput": {
|
|
672
607
|
"complexType": {
|
|
673
|
-
"
|
|
674
|
-
"
|
|
608
|
+
"original": "FocusEvent",
|
|
609
|
+
"resolved": "FocusEvent",
|
|
675
610
|
"references": {
|
|
676
|
-
"
|
|
611
|
+
"FocusEvent": {
|
|
677
612
|
"location": "global"
|
|
678
613
|
}
|
|
679
|
-
}
|
|
680
|
-
"return": "Promise<this>"
|
|
681
|
-
},
|
|
682
|
-
"docs": {
|
|
683
|
-
"text": "Clear input of any user inputted text.",
|
|
684
|
-
"tags": []
|
|
614
|
+
}
|
|
685
615
|
}
|
|
686
|
-
}
|
|
687
|
-
}; }
|
|
616
|
+
}]; }
|
|
688
617
|
static get elementRef() { return "hostElement"; }
|
|
689
618
|
static get watchers() { return [{
|
|
690
|
-
"propName": "
|
|
619
|
+
"propName": "items",
|
|
691
620
|
"methodName": "setChoicesHandler"
|
|
692
621
|
}, {
|
|
693
622
|
"propName": "value",
|
|
694
623
|
"methodName": "setValueHandler"
|
|
695
624
|
}]; }
|
|
625
|
+
static get listeners() { return [{
|
|
626
|
+
"name": "blur",
|
|
627
|
+
"method": "onBlur",
|
|
628
|
+
"target": undefined,
|
|
629
|
+
"capture": true,
|
|
630
|
+
"passive": false
|
|
631
|
+
}]; }
|
|
696
632
|
}
|
|
697
633
|
//# sourceMappingURL=cat-select.js.map
|