@haiilo/catalyst 0.8.0 → 0.8.3

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.
@@ -19,7 +19,7 @@ const patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(options => {
21
21
  appGlobals.globalScripts();
22
- return index.bootstrapLazy([["cat-textarea.cjs",[[1,"cat-textarea",{"disabled":[4],"hint":[1],"label":[1],"labelHidden":[4,"label-hidden"],"maxLength":[2,"max-length"],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"readonly":[4],"required":[4],"rows":[2],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64]}]]],["cat-alert_20.cjs",[[1,"cat-input",{"autoComplete":[1,"auto-complete"],"clearable":[4],"disabled":[4],"hint":[1],"icon":[1],"iconRight":[4,"icon-right"],"label":[1],"labelHidden":[4,"label-hidden"],"max":[2],"maxLength":[2,"max-length"],"min":[2],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"textPrefix":[1,"text-prefix"],"textSuffix":[1,"text-suffix"],"readonly":[4],"required":[4],"round":[4],"type":[1],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64],"clear":[64]}],[1,"cat-modal",{"size":[1],"isVisible":[32],"show":[64]}],[1,"cat-select",{"choices":[16],"items":[16],"disabled":[4],"multiple":[4],"placeholder":[1],"position":[1],"noSearch":[4,"no-search"],"setValue":[64],"setChoices":[64],"clearChoices":[64],"clearInput":[64]}],[1,"cat-tabs",{"activeTab":[1,"active-tab"],"tabsAlign":[1,"tabs-align"],"activeTabId":[32]},[[0,"keydown","onKeydown"]]],[0,"cat-toast-demo"],[1,"cat-avatar",{"size":[1],"round":[4],"label":[1],"initials":[1],"src":[1],"icon":[1],"url":[1],"urlTarget":[1,"url-target"],"backgroundImage":[32]}],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-card"],[1,"cat-checkbox",{"checked":[4],"disabled":[4],"indeterminate":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-radio",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-scrollable",{"noShadowX":[4,"no-shadow-x"],"noShadowY":[4,"no-shadow-y"],"noOverflowX":[4,"no-overflow-x"],"noOverflowY":[4,"no-overflow-y"],"noOverscroll":[4,"no-overscroll"],"noScrolledInit":[4,"no-scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-tab",{"label":[1],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"url":[1],"urlTarget":[1,"url-target"],"deactivated":[4]},[[0,"click","onClick"]]],[1,"cat-toggle",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-tooltip",{"content":[1],"disabled":[4],"placement":[1],"showDelay":[2,"show-delay"],"hideDelay":[2,"hide-delay"],"longTouchDuration":[2,"long-touch-duration"]},[[0,"keydown","handleKeyDown"]]],[1,"cat-button",{"variant":[1],"color":[1],"active":[4],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"noEllipsis":[4,"no-ellipsis"],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
22
+ return index.bootstrapLazy([["cat-textarea.cjs",[[1,"cat-textarea",{"disabled":[4],"hint":[1],"label":[1],"labelHidden":[4,"label-hidden"],"maxLength":[2,"max-length"],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"readonly":[4],"required":[4],"rows":[2],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64]}]]],["cat-alert_20.cjs",[[1,"cat-input",{"autoComplete":[1,"auto-complete"],"clearable":[4],"disabled":[4],"hint":[1],"icon":[1],"iconRight":[4,"icon-right"],"label":[1],"labelHidden":[4,"label-hidden"],"max":[2],"maxLength":[2,"max-length"],"min":[2],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"textPrefix":[1,"text-prefix"],"textSuffix":[1,"text-suffix"],"readonly":[4],"required":[4],"round":[4],"type":[1],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64],"clear":[64]}],[1,"cat-modal",{"size":[1],"isVisible":[32],"show":[64]}],[1,"cat-select",{"label":[1],"labelHidden":[4,"label-hidden"],"required":[4],"choices":[16],"value":[1025],"disabled":[4],"multiple":[4],"placeholder":[1],"position":[1],"noSearch":[4,"no-search"],"hint":[1],"hasSlottedLabel":[32],"setValue":[64],"setChoices":[64],"clearChoices":[64],"clearInput":[64]}],[1,"cat-tabs",{"activeTab":[1,"active-tab"],"tabsAlign":[1,"tabs-align"],"activeTabId":[32]},[[0,"keydown","onKeydown"]]],[0,"cat-toast-demo"],[1,"cat-avatar",{"size":[1],"round":[4],"label":[1],"initials":[1],"src":[1],"icon":[1],"url":[1],"urlTarget":[1,"url-target"],"backgroundImage":[32]}],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-card"],[1,"cat-checkbox",{"checked":[4],"disabled":[4],"indeterminate":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-radio",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-scrollable",{"noShadowX":[4,"no-shadow-x"],"noShadowY":[4,"no-shadow-y"],"noOverflowX":[4,"no-overflow-x"],"noOverflowY":[4,"no-overflow-y"],"noOverscroll":[4,"no-overscroll"],"noScrolledInit":[4,"no-scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-tab",{"label":[1],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"url":[1],"urlTarget":[1,"url-target"],"deactivated":[4]},[[0,"click","onClick"]]],[1,"cat-toggle",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-tooltip",{"content":[1],"disabled":[4],"placement":[1],"showDelay":[2,"show-delay"],"hideDelay":[2,"hide-delay"],"longTouchDuration":[2,"long-touch-duration"]},[[0,"keydown","handleKeyDown"]]],[1,"cat-button",{"variant":[1],"color":[1],"active":[4],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"noEllipsis":[4,"no-ellipsis"],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
23
23
  });
24
24
 
25
25
  //# sourceMappingURL=catalyst.cjs.js.map
@@ -18,7 +18,7 @@ const defineCustomElements = (win, options) => {
18
18
  if (typeof window === 'undefined') return Promise.resolve();
19
19
  return patchEsm().then(() => {
20
20
  appGlobals.globalScripts();
21
- return index.bootstrapLazy([["cat-textarea.cjs",[[1,"cat-textarea",{"disabled":[4],"hint":[1],"label":[1],"labelHidden":[4,"label-hidden"],"maxLength":[2,"max-length"],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"readonly":[4],"required":[4],"rows":[2],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64]}]]],["cat-alert_20.cjs",[[1,"cat-input",{"autoComplete":[1,"auto-complete"],"clearable":[4],"disabled":[4],"hint":[1],"icon":[1],"iconRight":[4,"icon-right"],"label":[1],"labelHidden":[4,"label-hidden"],"max":[2],"maxLength":[2,"max-length"],"min":[2],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"textPrefix":[1,"text-prefix"],"textSuffix":[1,"text-suffix"],"readonly":[4],"required":[4],"round":[4],"type":[1],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64],"clear":[64]}],[1,"cat-modal",{"size":[1],"isVisible":[32],"show":[64]}],[1,"cat-select",{"choices":[16],"items":[16],"disabled":[4],"multiple":[4],"placeholder":[1],"position":[1],"noSearch":[4,"no-search"],"setValue":[64],"setChoices":[64],"clearChoices":[64],"clearInput":[64]}],[1,"cat-tabs",{"activeTab":[1,"active-tab"],"tabsAlign":[1,"tabs-align"],"activeTabId":[32]},[[0,"keydown","onKeydown"]]],[0,"cat-toast-demo"],[1,"cat-avatar",{"size":[1],"round":[4],"label":[1],"initials":[1],"src":[1],"icon":[1],"url":[1],"urlTarget":[1,"url-target"],"backgroundImage":[32]}],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-card"],[1,"cat-checkbox",{"checked":[4],"disabled":[4],"indeterminate":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-radio",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-scrollable",{"noShadowX":[4,"no-shadow-x"],"noShadowY":[4,"no-shadow-y"],"noOverflowX":[4,"no-overflow-x"],"noOverflowY":[4,"no-overflow-y"],"noOverscroll":[4,"no-overscroll"],"noScrolledInit":[4,"no-scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-tab",{"label":[1],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"url":[1],"urlTarget":[1,"url-target"],"deactivated":[4]},[[0,"click","onClick"]]],[1,"cat-toggle",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-tooltip",{"content":[1],"disabled":[4],"placement":[1],"showDelay":[2,"show-delay"],"hideDelay":[2,"hide-delay"],"longTouchDuration":[2,"long-touch-duration"]},[[0,"keydown","handleKeyDown"]]],[1,"cat-button",{"variant":[1],"color":[1],"active":[4],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"noEllipsis":[4,"no-ellipsis"],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
21
+ return index.bootstrapLazy([["cat-textarea.cjs",[[1,"cat-textarea",{"disabled":[4],"hint":[1],"label":[1],"labelHidden":[4,"label-hidden"],"maxLength":[2,"max-length"],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"readonly":[4],"required":[4],"rows":[2],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64]}]]],["cat-alert_20.cjs",[[1,"cat-input",{"autoComplete":[1,"auto-complete"],"clearable":[4],"disabled":[4],"hint":[1],"icon":[1],"iconRight":[4,"icon-right"],"label":[1],"labelHidden":[4,"label-hidden"],"max":[2],"maxLength":[2,"max-length"],"min":[2],"minLength":[2,"min-length"],"name":[1],"placeholder":[1],"textPrefix":[1,"text-prefix"],"textSuffix":[1,"text-suffix"],"readonly":[4],"required":[4],"round":[4],"type":[1],"value":[1032],"hasSlottedLabel":[32],"setFocus":[64],"clear":[64]}],[1,"cat-modal",{"size":[1],"isVisible":[32],"show":[64]}],[1,"cat-select",{"label":[1],"labelHidden":[4,"label-hidden"],"required":[4],"choices":[16],"value":[1025],"disabled":[4],"multiple":[4],"placeholder":[1],"position":[1],"noSearch":[4,"no-search"],"hint":[1],"hasSlottedLabel":[32],"setValue":[64],"setChoices":[64],"clearChoices":[64],"clearInput":[64]}],[1,"cat-tabs",{"activeTab":[1,"active-tab"],"tabsAlign":[1,"tabs-align"],"activeTabId":[32]},[[0,"keydown","onKeydown"]]],[0,"cat-toast-demo"],[1,"cat-avatar",{"size":[1],"round":[4],"label":[1],"initials":[1],"src":[1],"icon":[1],"url":[1],"urlTarget":[1,"url-target"],"backgroundImage":[32]}],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-card"],[1,"cat-checkbox",{"checked":[4],"disabled":[4],"indeterminate":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-radio",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-scrollable",{"noShadowX":[4,"no-shadow-x"],"noShadowY":[4,"no-shadow-y"],"noOverflowX":[4,"no-overflow-x"],"noOverflowY":[4,"no-overflow-y"],"noOverscroll":[4,"no-overscroll"],"noScrolledInit":[4,"no-scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-tab",{"label":[1],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"url":[1],"urlTarget":[1,"url-target"],"deactivated":[4]},[[0,"click","onClick"]]],[1,"cat-toggle",{"checked":[4],"disabled":[4],"label":[1],"labelHidden":[4,"label-hidden"],"name":[1],"required":[4],"value":[1025],"hint":[1],"hasSlottedLabel":[32],"setFocus":[64]}],[1,"cat-tooltip",{"content":[1],"disabled":[4],"placement":[1],"showDelay":[2,"show-delay"],"hideDelay":[2,"hide-delay"],"longTouchDuration":[2,"long-touch-duration"]},[[0,"keydown","handleKeyDown"]]],[1,"cat-button",{"variant":[1],"color":[1],"active":[4],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"noEllipsis":[4,"no-ellipsis"],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconRight":[4,"icon-right"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
22
22
  });
23
23
  };
24
24
 
@@ -183,18 +183,59 @@ label + p {
183
183
  }
184
184
 
185
185
  /* ===== End of Section comment block ====== */
186
+ .hint-section {
187
+ display: flex;
188
+ gap: 0.5rem;
189
+ flex-direction: column;
190
+ }
191
+ .hint-section .input-hint,
192
+ .hint-section ::slotted([slot=hint]) {
193
+ font-size: 0.875rem;
194
+ line-height: 1rem;
195
+ margin: 0;
196
+ }
197
+
186
198
  :host {
187
- display: block;
199
+ display: flex;
200
+ flex-direction: column;
201
+ gap: 0.5rem;
202
+ font-size: 0.9375rem;
203
+ line-height: 1.25rem;
204
+ margin-bottom: 1rem;
188
205
  }
189
206
 
190
207
  :host([hidden]) {
191
208
  display: none;
192
209
  }
193
210
 
211
+ label {
212
+ align-self: flex-start;
213
+ font-size: inherit;
214
+ font-weight: inherit;
215
+ margin: 0;
216
+ }
217
+ label.hidden {
218
+ position: absolute !important;
219
+ width: 1px !important;
220
+ height: 1px !important;
221
+ padding: 0 !important;
222
+ margin: -1px !important;
223
+ overflow: hidden !important;
224
+ clip: rect(0, 0, 0, 0) !important;
225
+ white-space: nowrap !important;
226
+ border: 0 !important;
227
+ }
228
+
229
+ .input-optional {
230
+ margin-left: 0.25rem;
231
+ font-size: 0.75rem;
232
+ line-height: 1rem;
233
+ color: rgb(var(--cat-font-color-muted, 105, 118, 135));
234
+ }
235
+
194
236
  .choices {
195
237
  position: relative;
196
238
  overflow: hidden;
197
- margin-bottom: 24px;
198
239
  font-size: 16px;
199
240
  }
200
241
  .choices:focus {
@@ -599,4 +640,9 @@ label + p {
599
640
 
600
641
  .align-items-center {
601
642
  align-items: center;
643
+ }
644
+
645
+ .choices-option-icon {
646
+ width: 20px;
647
+ aspect-ratio: 1;
602
648
  }
@@ -1,12 +1,15 @@
1
- import { Component, Element, Event, h, Host, Method, Prop } from '@stencil/core';
1
+ import { Component, Element, Event, h, Host, Method, Prop, Watch, State } from '@stencil/core';
2
2
  import Choices from 'choices.js';
3
3
  import { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';
4
+ import log from 'loglevel';
5
+ import { CatFormHint } from '../cat-form-hint/cat-form-hint';
6
+ let nextUniqueId = 0;
4
7
  const getOptionTemplate = (data) => {
5
8
  var _a;
6
9
  if ((_a = data.customProperties) === null || _a === void 0 ? void 0 : _a.imageUrl) {
7
10
  return `
8
11
  <div class="d-flex align-items-center">
9
- <img src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem" />
12
+ <img class="choices-option-icon" src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem" />
10
13
  ${data.label}
11
14
  </div>
12
15
  `;
@@ -17,18 +20,32 @@ const getOptionTemplate = (data) => {
17
20
  * Select lets user choose one option from an options menu. Consider using
18
21
  * select when you have 6 or more options. Select component supports any content
19
22
  * type.
23
+ *
24
+ * @slot hint - Optional hint element to be displayed with the select.
25
+ * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.
26
+ * @part label - The label content.
20
27
  */
21
28
  export class CatSelect {
22
29
  constructor() {
23
30
  this.i18n = CatI18nRegistry.getInstance();
31
+ this.id = `cat-select-${nextUniqueId++}`;
32
+ this.hasSlottedLabel = false;
24
33
  /**
25
- * The available options for the input.
34
+ * The label for the select.
26
35
  */
27
- this.choices = [];
36
+ this.label = '';
37
+ /**
38
+ * Visually hide the label, but still show it to assistive technologies like screen readers.
39
+ */
40
+ this.labelHidden = false;
41
+ /**
42
+ * A value is required or must be check for the form to be submittable.
43
+ */
44
+ this.required = false;
28
45
  /**
29
- * The pre-selected items for the input.
46
+ * The available options for the input.
30
47
  */
31
- this.items = [];
48
+ this.choices = [];
32
49
  /**
33
50
  * Disable the select.
34
51
  */
@@ -52,6 +69,17 @@ export class CatSelect {
52
69
  */
53
70
  this.noSearch = false;
54
71
  }
72
+ setChoicesHandler(choices) {
73
+ if (!(choices === null || choices === void 0 ? void 0 : choices.length))
74
+ return;
75
+ this.setChoices(choices, 'value', 'label', true);
76
+ }
77
+ componentWillRender() {
78
+ this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
79
+ if (!this.label && !this.hasSlottedLabel) {
80
+ log.error('[A11y] Missing ARIA label on select', this);
81
+ }
82
+ }
55
83
  componentDidLoad() {
56
84
  var _a, _b, _c, _d, _e, _f, _g, _h;
57
85
  this.init();
@@ -116,11 +144,21 @@ export class CatSelect {
116
144
  }
117
145
  render() {
118
146
  return (h(Host, null,
119
- h("select", { ref: el => (this.selectElement = el), multiple: this.multiple, disabled: this.disabled })));
147
+ (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
148
+ h("span", { part: "label" },
149
+ (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label,
150
+ !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" },
151
+ "(",
152
+ this.i18n.t('input.optional'),
153
+ ")"))))),
154
+ h("select", { id: this.id, ref: el => (this.selectElement = el), multiple: this.multiple, disabled: this.disabled }),
155
+ this.hintSection));
120
156
  }
121
157
  init() {
158
+ const value = this.value || [];
122
159
  const config = {
123
- items: this.items,
160
+ allowHTML: true,
161
+ items: Array.isArray(value) ? value : [value],
124
162
  removeItemButton: true,
125
163
  duplicateItemsAllowed: false,
126
164
  delimiter: '',
@@ -148,7 +186,7 @@ export class CatSelect {
148
186
  item: ({ classNames }, data) => {
149
187
  var _a;
150
188
  const template = ((_a = data.customProperties) === null || _a === void 0 ? void 0 : _a.imageUrl)
151
- ? `<img src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem" />`
189
+ ? `<img class="choices-option-icon" src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem" />`
152
190
  : '';
153
191
  return strToEl(`
154
192
  <div class="${classNames.item} ${data.highlighted ? classNames.highlightedState : classNames.itemSelectable} ${data.placeholder ? classNames.placeholder : ''}" data-item data-id="${data.id}" data-value="${data.value}" ${data.active ? 'aria-selected="true"' : ''} ${data.disabled ? 'aria-disabled="true"' : ''}>
@@ -166,7 +204,7 @@ export class CatSelect {
166
204
  item: ({ classNames }, data) => {
167
205
  var _a;
168
206
  const template = ((_a = data.customProperties) === null || _a === void 0 ? void 0 : _a.imageUrl)
169
- ? `<img src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem;" />`
207
+ ? `<img class="choices-option-icon" src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem;" />`
170
208
  : '';
171
209
  return strToEl(`<div class="
172
210
  ${classNames.item}
@@ -200,9 +238,14 @@ export class CatSelect {
200
238
  this.choice = new Choices(this.selectElement, settings);
201
239
  this.choice.setChoices(this.choices);
202
240
  }
241
+ get hintSection() {
242
+ const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
243
+ return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
244
+ }
203
245
  onChange() {
204
- var _a;
205
- this.catChange.emit((_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue());
246
+ var _a, _b;
247
+ this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue();
248
+ this.catChange.emit((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue());
206
249
  if (this.multiple) {
207
250
  this.updateRemoveItemButtonVisibility();
208
251
  }
@@ -260,6 +303,60 @@ export class CatSelect {
260
303
  "$": ["cat-select.css"]
261
304
  }; }
262
305
  static get properties() { return {
306
+ "label": {
307
+ "type": "string",
308
+ "mutable": false,
309
+ "complexType": {
310
+ "original": "string",
311
+ "resolved": "string",
312
+ "references": {}
313
+ },
314
+ "required": false,
315
+ "optional": false,
316
+ "docs": {
317
+ "tags": [],
318
+ "text": "The label for the select."
319
+ },
320
+ "attribute": "label",
321
+ "reflect": false,
322
+ "defaultValue": "''"
323
+ },
324
+ "labelHidden": {
325
+ "type": "boolean",
326
+ "mutable": false,
327
+ "complexType": {
328
+ "original": "boolean",
329
+ "resolved": "boolean",
330
+ "references": {}
331
+ },
332
+ "required": false,
333
+ "optional": false,
334
+ "docs": {
335
+ "tags": [],
336
+ "text": "Visually hide the label, but still show it to assistive technologies like screen readers."
337
+ },
338
+ "attribute": "label-hidden",
339
+ "reflect": false,
340
+ "defaultValue": "false"
341
+ },
342
+ "required": {
343
+ "type": "boolean",
344
+ "mutable": false,
345
+ "complexType": {
346
+ "original": "boolean",
347
+ "resolved": "boolean",
348
+ "references": {}
349
+ },
350
+ "required": false,
351
+ "optional": false,
352
+ "docs": {
353
+ "tags": [],
354
+ "text": "A value is required or must be check for the form to be submittable."
355
+ },
356
+ "attribute": "required",
357
+ "reflect": false,
358
+ "defaultValue": "false"
359
+ },
263
360
  "choices": {
264
361
  "type": "unknown",
265
362
  "mutable": false,
@@ -281,12 +378,12 @@ export class CatSelect {
281
378
  },
282
379
  "defaultValue": "[]"
283
380
  },
284
- "items": {
285
- "type": "unknown",
286
- "mutable": false,
381
+ "value": {
382
+ "type": "string",
383
+ "mutable": true,
287
384
  "complexType": {
288
- "original": "Choice[] | string[]",
289
- "resolved": "Choice[] | string[]",
385
+ "original": "string | string[] | Choice | Choice[]",
386
+ "resolved": "Choice | Choice[] | string | string[] | undefined",
290
387
  "references": {
291
388
  "Choice": {
292
389
  "location": "import",
@@ -295,12 +392,13 @@ export class CatSelect {
295
392
  }
296
393
  },
297
394
  "required": false,
298
- "optional": false,
395
+ "optional": true,
299
396
  "docs": {
300
397
  "tags": [],
301
398
  "text": "The pre-selected items for the input."
302
399
  },
303
- "defaultValue": "[]"
400
+ "attribute": "value",
401
+ "reflect": false
304
402
  },
305
403
  "disabled": {
306
404
  "type": "boolean",
@@ -391,8 +489,28 @@ export class CatSelect {
391
489
  "attribute": "no-search",
392
490
  "reflect": false,
393
491
  "defaultValue": "false"
492
+ },
493
+ "hint": {
494
+ "type": "string",
495
+ "mutable": false,
496
+ "complexType": {
497
+ "original": "string | string[]",
498
+ "resolved": "string | string[] | undefined",
499
+ "references": {}
500
+ },
501
+ "required": false,
502
+ "optional": true,
503
+ "docs": {
504
+ "tags": [],
505
+ "text": "Optional hint text(s) to be displayed with the select."
506
+ },
507
+ "attribute": "hint",
508
+ "reflect": false
394
509
  }
395
510
  }; }
511
+ static get states() { return {
512
+ "hasSlottedLabel": {}
513
+ }; }
396
514
  static get events() { return [{
397
515
  "method": "catChange",
398
516
  "name": "catChange",
@@ -453,7 +571,7 @@ export class CatSelect {
453
571
  },
454
572
  "setChoices": {
455
573
  "complexType": {
456
- "signature": "(choices: Array<Choice> | Array<Group>, value: string, label: string, replaceChoices?: boolean | undefined) => Promise<this>",
574
+ "signature": "(choices: Array<Choice> | Array<Group>, value?: string | undefined, label?: string | undefined, replaceChoices?: boolean | undefined) => Promise<this>",
457
575
  "parameters": [{
458
576
  "tags": [],
459
577
  "text": ""
@@ -524,5 +642,9 @@ export class CatSelect {
524
642
  }
525
643
  }; }
526
644
  static get elementRef() { return "hostElement"; }
645
+ static get watchers() { return [{
646
+ "propName": "choices",
647
+ "methodName": "setChoicesHandler"
648
+ }]; }
527
649
  }
528
650
  //# sourceMappingURL=cat-select.js.map
@@ -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,MAAM,eAAe,CAAC;AAC/F,OAAO,OAAqD,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAU,EAAE;;EAC/C,IAAI,MAAA,IAAI,CAAC,gBAAgB,0CAAE,QAAQ,EAAE;IACnC,OAAO;;kBAEO,IAAI,CAAC,gBAAgB,CAAC,QAAQ;QACxC,IAAI,CAAC,KAAK;;KAEb,CAAC;GACH;EACD,OAAO,wBAAwB,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,QAAQ,mBAAmB,CAAC;AAC1F,CAAC,CAAC;AAEF;;;;GAIG;AAMH,MAAM,OAAO,SAAS;EALtB;IAMmB,SAAI,GAAG,eAAe,CAA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AgC;;IACtC,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,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;MACxB,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;EACrC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop } from '@stencil/core';\nimport Choices, { Choice, ClassNames, Group, Item, Options } from 'choices.js';\nimport { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';\n\nconst getOptionTemplate = (data: Item): string => {\n if (data.customProperties?.imageUrl) {\n return `\n <div class=\"d-flex align-items-center\">\n <img 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@Component({\n tag: 'cat-select',\n styleUrl: 'cat-select.scss',\n shadow: true\n})\nexport class CatSelect {\n private readonly i18n = CatI18nRegistry.getInstance();\n\n private choice?: Choices;\n private choiceInner?: Element;\n private selectElement?: HTMLSelectElement;\n private removeElement?: HTMLCatButtonElement;\n\n @Element() hostElement!: HTMLElement;\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() items: Choice[] | string[] = [];\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 * 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 componentDidLoad(): void {\n this.init();\n this.choiceInner = this.hostElement.attachInternals?.().shadowRoot?.querySelector('.choices__inner') || undefined;\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 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 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 <select ref={el => (this.selectElement = el)} multiple={this.multiple} disabled={this.disabled}></select>\n </Host>\n );\n }\n\n private init() {\n const config = {\n items: this.items,\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 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 </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 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 </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 onChange() {\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 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,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,OAAq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EAAE;MAChB,MAAA,IAAI,CAAC,aAAa,0CAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;KAC/C;SAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;MACxB,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;EACrC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 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 @Watch('choices')\n setChoicesHandler(choices: Choice[]) {\n if (!choices?.length) return;\n\n this.setChoices(choices, 'value', 'label', true);\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 this.choiceInner = this.hostElement.attachInternals?.().shadowRoot?.querySelector('.choices__inner') || undefined;\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 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 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 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 </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 </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 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"]}