@cscfi/csc-ui 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{c-badge_12.cjs.entry.js → c-autocomplete_16.cjs.entry.js} +1174 -52
- package/dist/cjs/c-autocomplete_16.cjs.entry.js.map +1 -0
- package/dist/cjs/{c-checkbox_2.cjs.entry.js → c-checkbox_3.cjs.entry.js} +14 -1
- package/dist/cjs/c-checkbox_3.cjs.entry.js.map +1 -0
- package/dist/cjs/c-csc-logo.cjs.entry.js +23 -0
- package/dist/cjs/c-csc-logo.cjs.entry.js.map +1 -0
- package/dist/cjs/c-main.cjs.entry.js +21 -0
- package/dist/cjs/c-main.cjs.entry.js.map +1 -0
- package/dist/cjs/c-menu_2.cjs.entry.js +2 -23
- package/dist/cjs/c-menu_2.cjs.entry.js.map +1 -1
- package/dist/cjs/c-row.cjs.entry.js +35 -0
- package/dist/cjs/c-row.cjs.entry.js.map +1 -0
- package/dist/cjs/c-slider.cjs.entry.js +6 -6
- package/dist/cjs/c-slider.cjs.entry.js.map +1 -1
- package/dist/cjs/c-toolbar.cjs.entry.js +21 -0
- package/dist/cjs/c-toolbar.cjs.entry.js.map +1 -0
- package/dist/cjs/csc-ui.cjs.js +1 -1
- package/dist/cjs/getScrollParent-5d488045.js +28 -0
- package/dist/cjs/getScrollParent-5d488045.js.map +1 -0
- package/dist/cjs/index-91ba22ab.js +14 -30
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/c-autocomplete/c-autocomplete.js +27 -3
- package/dist/collection/components/c-autocomplete/c-autocomplete.js.map +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.css +6 -1
- package/dist/collection/components/c-dropdown/c-dropdown.js +18 -19
- package/dist/collection/components/c-dropdown/c-dropdown.js.map +1 -1
- package/dist/collection/components/c-menu-items/c-menu-items.js +2 -23
- package/dist/collection/components/c-menu-items/c-menu-items.js.map +1 -1
- package/dist/collection/components/c-select/c-select.js +58 -23
- package/dist/collection/components/c-select/c-select.js.map +1 -1
- package/dist/collection/components/c-slider/c-slider.css +70 -68
- package/dist/collection/components/c-slider/c-slider.js +7 -7
- package/dist/collection/components/c-slider/c-slider.js.map +1 -1
- package/dist/collection/utils/getScrollParent.js +23 -0
- package/dist/collection/utils/getScrollParent.js.map +1 -0
- package/dist/collection/utils/index.js +2 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/components/c-autocomplete.js +28 -4
- package/dist/components/c-autocomplete.js.map +1 -1
- package/dist/components/c-dropdown2.js +19 -20
- package/dist/components/c-dropdown2.js.map +1 -1
- package/dist/components/c-menu-items2.js +2 -23
- package/dist/components/c-menu-items2.js.map +1 -1
- package/dist/components/c-select.js +59 -24
- package/dist/components/c-select.js.map +1 -1
- package/dist/components/c-slider.js +7 -7
- package/dist/components/c-slider.js.map +1 -1
- package/dist/components/getScrollParent.js +26 -0
- package/dist/components/getScrollParent.js.map +1 -0
- package/dist/csc-ui/csc-ui.esm.js +1 -1
- package/dist/csc-ui/csc-ui.esm.js.map +1 -1
- package/dist/csc-ui/p-040ed3e2.entry.js +2 -0
- package/dist/csc-ui/p-040ed3e2.entry.js.map +1 -0
- package/dist/csc-ui/{p-bf01d3ef.entry.js → p-1d6c84df.entry.js} +2 -2
- package/dist/csc-ui/p-39df362b.entry.js +2 -0
- package/dist/csc-ui/p-39df362b.entry.js.map +1 -0
- package/dist/csc-ui/{p-27904068.entry.js → p-3bb67f38.entry.js} +2 -2
- package/dist/csc-ui/p-3f0e51ff.js +2 -0
- package/dist/csc-ui/p-3f0e51ff.js.map +1 -0
- package/dist/csc-ui/{p-0569fc3e.entry.js → p-468d9583.entry.js} +2 -2
- package/dist/csc-ui/{p-16098e94.entry.js → p-56b1e1ea.entry.js} +2 -2
- package/dist/csc-ui/p-682782b1.entry.js +2 -0
- package/dist/csc-ui/p-682782b1.entry.js.map +1 -0
- package/dist/csc-ui/{p-958cf6ed.entry.js → p-6e046723.entry.js} +2 -2
- package/dist/csc-ui/p-9c5488fc.entry.js +2 -0
- package/dist/csc-ui/p-9c5488fc.entry.js.map +1 -0
- package/dist/csc-ui/{p-862486aa.entry.js → p-9c80f35e.entry.js} +2 -2
- package/dist/csc-ui/{p-873aa915.entry.js → p-ab62f9b5.entry.js} +2 -2
- package/dist/csc-ui/{p-45641e3d.entry.js → p-ae16b1f4.entry.js} +2 -2
- package/dist/csc-ui/{p-7af82ab9.entry.js → p-b0fa27b6.entry.js} +2 -2
- package/dist/csc-ui/{p-2a622e79.entry.js → p-b83651f8.entry.js} +2 -2
- package/dist/csc-ui/p-b83651f8.entry.js.map +1 -0
- package/dist/csc-ui/p-ba475561.entry.js +2 -0
- package/dist/csc-ui/p-ba475561.entry.js.map +1 -0
- package/dist/csc-ui/{p-64bcde03.entry.js → p-bda722d5.entry.js} +2 -2
- package/dist/csc-ui/{p-47ca0a95.entry.js → p-c8a7a751.entry.js} +2 -2
- package/dist/csc-ui/{p-c291cbe2.entry.js → p-ccef8a49.entry.js} +2 -2
- package/dist/csc-ui/p-ee753bac.entry.js +2 -0
- package/dist/csc-ui/p-ee753bac.entry.js.map +1 -0
- package/dist/csc-ui/{p-5461ca29.js → p-f24b9d97.js} +2 -2
- package/dist/csc-ui/p-fa83a615.entry.js +2 -0
- package/dist/csc-ui/p-fa83a615.entry.js.map +1 -0
- package/dist/esm/c-accordion-item.entry.js +1 -1
- package/dist/esm/c-alert.entry.js +1 -1
- package/dist/esm/{c-badge_12.entry.js → c-autocomplete_16.entry.js} +1168 -50
- package/dist/esm/c-autocomplete_16.entry.js.map +1 -0
- package/dist/esm/{c-checkbox_2.entry.js → c-checkbox_3.entry.js} +15 -3
- package/dist/esm/c-checkbox_3.entry.js.map +1 -0
- package/dist/esm/c-csc-logo.entry.js +19 -0
- package/dist/esm/c-csc-logo.entry.js.map +1 -0
- package/dist/esm/c-data-table.entry.js +1 -1
- package/dist/esm/c-main.entry.js +17 -0
- package/dist/esm/c-main.entry.js.map +1 -0
- package/dist/esm/c-menu_2.entry.js +3 -24
- package/dist/esm/c-menu_2.entry.js.map +1 -1
- package/dist/esm/c-navigation-button.entry.js +1 -1
- package/dist/esm/c-radio-group.entry.js +1 -1
- package/dist/esm/c-row.entry.js +31 -0
- package/dist/esm/c-row.entry.js.map +1 -0
- package/dist/esm/c-side-navigation-item.entry.js +1 -1
- package/dist/esm/c-side-navigation.entry.js +1 -1
- package/dist/esm/c-slider.entry.js +6 -6
- package/dist/esm/c-slider.entry.js.map +1 -1
- package/dist/esm/c-swiper.entry.js +1 -1
- package/dist/esm/c-tabs.entry.js +1 -1
- package/dist/esm/c-tag.entry.js +1 -1
- package/dist/esm/c-text-field.entry.js +1 -1
- package/dist/esm/c-toast.entry.js +1 -1
- package/dist/esm/c-toolbar.entry.js +17 -0
- package/dist/esm/c-toolbar.entry.js.map +1 -0
- package/dist/esm/csc-ui.js +1 -1
- package/dist/esm/getScrollParent-f876ad1b.js +26 -0
- package/dist/esm/getScrollParent-f876ad1b.js.map +1 -0
- package/dist/esm/index-47956d53.js +14 -30
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mdi-e92c0e44.js → mdi-8656e74a.js} +2 -2
- package/dist/esm/{mdi-e92c0e44.js.map → mdi-8656e74a.js.map} +1 -1
- package/dist/types/components/c-autocomplete/c-autocomplete.d.ts +1 -0
- package/dist/types/components/c-dropdown/c-dropdown.d.ts +2 -1
- package/dist/types/components/c-menu-items/c-menu-items.d.ts +0 -1
- package/dist/types/components/c-select/c-select.d.ts +3 -0
- package/dist/types/components/c-slider/c-slider.d.ts +1 -1
- package/dist/types/components.d.ts +8 -8
- package/dist/types/utils/getScrollParent.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/vscode-data.json +4 -4
- package/dist/cjs/c-autocomplete.cjs.entry.js +0 -251
- package/dist/cjs/c-autocomplete.cjs.entry.js.map +0 -1
- package/dist/cjs/c-badge_12.cjs.entry.js.map +0 -1
- package/dist/cjs/c-card-actions.cjs.entry.js +0 -28
- package/dist/cjs/c-card-actions.cjs.entry.js.map +0 -1
- package/dist/cjs/c-card-content.cjs.entry.js +0 -21
- package/dist/cjs/c-card-content.cjs.entry.js.map +0 -1
- package/dist/cjs/c-card-title.cjs.entry.js +0 -21
- package/dist/cjs/c-card-title.cjs.entry.js.map +0 -1
- package/dist/cjs/c-checkbox_2.cjs.entry.js.map +0 -1
- package/dist/cjs/c-dropdown_2.cjs.entry.js +0 -512
- package/dist/cjs/c-dropdown_2.cjs.entry.js.map +0 -1
- package/dist/cjs/c-message.cjs.entry.js +0 -67
- package/dist/cjs/c-message.cjs.entry.js.map +0 -1
- package/dist/cjs/c-option.cjs.entry.js +0 -25
- package/dist/cjs/c-option.cjs.entry.js.map +0 -1
- package/dist/cjs/c-select.cjs.entry.js +0 -276
- package/dist/cjs/c-select.cjs.entry.js.map +0 -1
- package/dist/csc-ui/p-019c6898.entry.js +0 -2
- package/dist/csc-ui/p-019c6898.entry.js.map +0 -1
- package/dist/csc-ui/p-0666f12d.entry.js +0 -2
- package/dist/csc-ui/p-0666f12d.entry.js.map +0 -1
- package/dist/csc-ui/p-088b9c5e.entry.js +0 -2
- package/dist/csc-ui/p-088b9c5e.entry.js.map +0 -1
- package/dist/csc-ui/p-2a622e79.entry.js.map +0 -1
- package/dist/csc-ui/p-4e1d8f5d.entry.js +0 -2
- package/dist/csc-ui/p-4e1d8f5d.entry.js.map +0 -1
- package/dist/csc-ui/p-6c5e538b.entry.js +0 -2
- package/dist/csc-ui/p-6c5e538b.entry.js.map +0 -1
- package/dist/csc-ui/p-bbe8423c.entry.js +0 -2
- package/dist/csc-ui/p-bbe8423c.entry.js.map +0 -1
- package/dist/csc-ui/p-bddd9153.entry.js +0 -2
- package/dist/csc-ui/p-bddd9153.entry.js.map +0 -1
- package/dist/csc-ui/p-d1089126.entry.js +0 -2
- package/dist/csc-ui/p-d1089126.entry.js.map +0 -1
- package/dist/csc-ui/p-d2fc8cb4.entry.js +0 -2
- package/dist/csc-ui/p-d2fc8cb4.entry.js.map +0 -1
- package/dist/csc-ui/p-ec167606.entry.js +0 -2
- package/dist/csc-ui/p-ec167606.entry.js.map +0 -1
- package/dist/csc-ui/p-f148aad1.entry.js +0 -2
- package/dist/csc-ui/p-f148aad1.entry.js.map +0 -1
- package/dist/esm/c-autocomplete.entry.js +0 -247
- package/dist/esm/c-autocomplete.entry.js.map +0 -1
- package/dist/esm/c-badge_12.entry.js.map +0 -1
- package/dist/esm/c-card-actions.entry.js +0 -24
- package/dist/esm/c-card-actions.entry.js.map +0 -1
- package/dist/esm/c-card-content.entry.js +0 -17
- package/dist/esm/c-card-content.entry.js.map +0 -1
- package/dist/esm/c-card-title.entry.js +0 -17
- package/dist/esm/c-card-title.entry.js.map +0 -1
- package/dist/esm/c-checkbox_2.entry.js.map +0 -1
- package/dist/esm/c-dropdown_2.entry.js +0 -507
- package/dist/esm/c-dropdown_2.entry.js.map +0 -1
- package/dist/esm/c-message.entry.js +0 -63
- package/dist/esm/c-message.entry.js.map +0 -1
- package/dist/esm/c-option.entry.js +0 -21
- package/dist/esm/c-option.entry.js.map +0 -1
- package/dist/esm/c-select.entry.js +0 -272
- package/dist/esm/c-select.entry.js.map +0 -1
- /package/dist/csc-ui/{p-bf01d3ef.entry.js.map → p-1d6c84df.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-27904068.entry.js.map → p-3bb67f38.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-0569fc3e.entry.js.map → p-468d9583.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-16098e94.entry.js.map → p-56b1e1ea.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-958cf6ed.entry.js.map → p-6e046723.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-862486aa.entry.js.map → p-9c80f35e.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-873aa915.entry.js.map → p-ab62f9b5.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-45641e3d.entry.js.map → p-ae16b1f4.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-7af82ab9.entry.js.map → p-b0fa27b6.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-64bcde03.entry.js.map → p-bda722d5.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-47ca0a95.entry.js.map → p-c8a7a751.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-c291cbe2.entry.js.map → p-ccef8a49.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-5461ca29.js.map → p-f24b9d97.js.map} +0 -0
|
@@ -4,6 +4,278 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-91ba22ab.js');
|
|
6
6
|
const mdi = require('./mdi-16842afc.js');
|
|
7
|
+
const getScrollParent = require('./getScrollParent-5d488045.js');
|
|
8
|
+
|
|
9
|
+
const cAutocompleteCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host(c-autocomplete){--_c-autocomplete-option-background-color:var(\n --c-autocomplete-option-background-color,\n var(--c-white)\n );--_c-autocomplete-option-background-hover-color:var(\n --c-autocomplete-option-background-hover-color,\n var(--c-primary-100)\n );--_c-autocomplete-active-color:var(\n --c-autocomplete-active-color,\n var(--c-primary-600)\n );--_c-autocomplete-inactive-color:var(\n --c-autocomplete-inactive-color,\n var(--c-tertiary-600)\n );--_c-autocomplete-background-color:var(\n --c-autocomplete-background-color,\n var(--c-transparent)\n );--_c-autocomplete-text-color:var(\n --c-autocomplete-text-color,\n var(--c-text-body)\n );--_c-autocomplete-option-text-color:var(\n --c-autocomplete-option-text-color,\n var(--c-text-body)\n );--_c-autocomplete-placeholder-color:var(\n --c-autocomplete-placeholder-color,\n var(--c-tertiary-500)\n );--c-select-option-background-color:var(\n --_c-autocomplete-option-background-color\n );--c-select-option-background-color-hover:var(\n --_c-autocomplete-option-background-hover-color\n );--c-select-option-text-color:var(--_c-autocomplete-option-text-color);--_c-input-active-color:var(--_c-autocomplete-active-color);--_c-input-inactive-color:var(--_c-autocomplete-inactive-color);--_c-input-background-color:var(--_c-autocomplete-background-color);--_c-input-text-color:var(--_c-autocomplete-text-color);--_c-input-placeholder-color:var(--_c-autocomplete-placeholder-color)}:host{display:block;cursor:text}.c-input-menu__chevron{fill:currentColor;transform:rotate(0deg);transition:transform 0.3s ease-in-out}.c-input-menu__chevron--active{transform:rotate(180deg)}.c-input-menu__input{width:100%;display:flex;justify-items:stretch}.c-input-menu__selection{display:none;pointer-events:none}.c-input-menu__selection--show{align-items:center;display:flex;width:100%;color:var(--_c-select-active-color)}.c-input-menu__item-wrapper{position:absolute;width:100%;top:44px;z-index:10;margin-left:calc(var(--_c-input-label-position) * -1)}.c-input-menu__item-wrapper--shadow{top:47px}.c-input-menu__items{position:absolute;background-color:var(--_c-select-option-background-color);min-width:calc(100% + 24px);box-shadow:0 8px 16px 0 rgba(0, 0, 0, 0.2);z-index:10;user-select:none;border-radius:4px;margin:0 -12px;overflow-y:scroll;list-style:none;padding:0}.c-input-menu__items--hidden{display:none}.c-input-menu__items li{cursor:pointer;display:flex;min-height:48px;padding:0 12px;transition:background-color 0.3s;font-size:14px;align-items:center;justify-content:flex-start;color:var(--_c-select-option-text-color)}.c-input-menu__items li.disabled{background-color:var(--c-tertiary-100);filter:grayscale(1) opacity(0.6);cursor:default}.c-input-menu__items li.disabled:hover{background-color:var(--c-tertiary-100)}.c-input-menu__items li.dense{padding:10px 14px}.c-input-menu__items li:hover{background-color:var(--_c-select-option-background-color-hover)}.c-input-menu__items li[aria-selected=true]{background-color:var(--_c-select-option-background-color-hover);box-shadow:inset 0 0 0 1px var(--_c-select-active-color);border-radius:4px;backface-visibility:hidden;transform:translate3d(0, 0, 0)}.c-input-menu__items li.none{color:rgba(0, 0, 0, 0.5)}.c-input-menu__items--empty li{color:var(--c-text-system);cursor:default;gap:8px;pointer-events:none}.c-input-menu__items--empty li svg{fill:var(--c-warning-600);height:18px;width:18px}input{max-height:32px;padding:8px 0;background-color:transparent;border:none;color:var(--c-text-body);flex:1 1 auto;font-family:var(--c-font-family);font-size:16px;line-height:20px;max-width:100%;min-width:0;width:100%;pointer-events:none}input:focus,input:active{outline:none}input::-ms-reveal{display:none}svg{fill:currentColor;height:22px;width:22px}.c-input--disabled{color:var(--c-tertiary-400)}.c-input:focus-within{color:var(--c-primary-600)}.c-input--error{color:var(--c-error-600)}.c-input--error:focus-within{color:var(--c-error-600)}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}";
|
|
10
|
+
|
|
11
|
+
const CAutocomplete = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
this.changeQuery = index.createEvent(this, "changeQuery", 7);
|
|
15
|
+
this.changeValue = index.createEvent(this, "changeValue", 3);
|
|
16
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
17
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
21
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
22
|
+
}
|
|
23
|
+
this._preventDialogOpen = false;
|
|
24
|
+
this._debounce = null;
|
|
25
|
+
this._handleSlotChange = () => {
|
|
26
|
+
this.optionElements = this.el.querySelectorAll('c-option');
|
|
27
|
+
const selection = Array.from(this.optionElements).find((option) => option.selected);
|
|
28
|
+
if (selection) {
|
|
29
|
+
this.value = this.returnObject
|
|
30
|
+
? { name: selection.name, value: selection.value }
|
|
31
|
+
: selection.value;
|
|
32
|
+
this.changeValue.emit(this.value);
|
|
33
|
+
this.query = selection.name.toString();
|
|
34
|
+
this.changeQuery.emit(selection.value);
|
|
35
|
+
this.internals.setFormValue(selection.value.toString());
|
|
36
|
+
}
|
|
37
|
+
if (this.optionElements.length && !this.optionElementsExist) {
|
|
38
|
+
this.optionElementsExist = true;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
this._toggleDropdown = (event) => {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
if (this.dropdownVisible) {
|
|
44
|
+
this._dropdownElement.close();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this._dropdownElement.open();
|
|
48
|
+
};
|
|
49
|
+
this._onButtonKeyDown = (src, event) => {
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
if (event.key !== 'Tab')
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
if (['Enter', ' '].includes(event.key)) {
|
|
54
|
+
if (src === 'chevron') {
|
|
55
|
+
this._toggleDropdown(event);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this._reset(event);
|
|
59
|
+
this._preventDialogOpen = true;
|
|
60
|
+
this._inputElement.focus();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this._reset = (event) => {
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
this.query = '';
|
|
66
|
+
this.value = null;
|
|
67
|
+
this.changeValue.emit(null);
|
|
68
|
+
this.internals.setFormValue(null);
|
|
69
|
+
this.changeQuery.emit('');
|
|
70
|
+
this._preventDialogOpen = true;
|
|
71
|
+
this._cInputElement.reset();
|
|
72
|
+
this._inputElement.focus();
|
|
73
|
+
this._dropdownElement.updateList();
|
|
74
|
+
};
|
|
75
|
+
this._onInputFocus = () => {
|
|
76
|
+
if (!this._preventDialogOpen) {
|
|
77
|
+
this._dropdownElement.open();
|
|
78
|
+
}
|
|
79
|
+
this._updateStatusText();
|
|
80
|
+
this._preventDialogOpen = false;
|
|
81
|
+
};
|
|
82
|
+
this.items = [];
|
|
83
|
+
this.value = null;
|
|
84
|
+
this.query = null;
|
|
85
|
+
this.hostId = undefined;
|
|
86
|
+
this.disabled = false;
|
|
87
|
+
this.label = undefined;
|
|
88
|
+
this.name = undefined;
|
|
89
|
+
this.placeholder = '';
|
|
90
|
+
this.hideDetails = false;
|
|
91
|
+
this.hint = '';
|
|
92
|
+
this.loading = false;
|
|
93
|
+
this.required = false;
|
|
94
|
+
this.valid = true;
|
|
95
|
+
this.validate = false;
|
|
96
|
+
this.validateOnBlur = false;
|
|
97
|
+
this.validation = 'Required field';
|
|
98
|
+
this.shadow = false;
|
|
99
|
+
this.returnObject = false;
|
|
100
|
+
this.itemsPerPage = 6;
|
|
101
|
+
this.optionElements = undefined;
|
|
102
|
+
this.currentIndex = null;
|
|
103
|
+
this.dropdownVisible = false;
|
|
104
|
+
this.statusText = '';
|
|
105
|
+
this.optionElementsExist = false;
|
|
106
|
+
}
|
|
107
|
+
get _id() {
|
|
108
|
+
return this.hostId || `autocomplete_${CAutocomplete._uniqueId}`;
|
|
109
|
+
}
|
|
110
|
+
async reset() {
|
|
111
|
+
this.query = '';
|
|
112
|
+
this.changeValue.emit(null);
|
|
113
|
+
this.internals.setFormValue(null);
|
|
114
|
+
this.changeQuery.emit('');
|
|
115
|
+
this._dropdownElement.updateList();
|
|
116
|
+
}
|
|
117
|
+
handleKeyDown(event) {
|
|
118
|
+
const alphanumeric = /^[0-9a-zA-Z ]+$/;
|
|
119
|
+
if (event.key.match(alphanumeric) && event.key.length === 1) {
|
|
120
|
+
if (!this.dropdownVisible) {
|
|
121
|
+
this._dropdownElement.open();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this._inputElement.focus();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (event.key === 'Escape') {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
this._preventDialogOpen = true;
|
|
130
|
+
this._dropdownElement.close();
|
|
131
|
+
requestAnimationFrame(() => {
|
|
132
|
+
this._inputElement.focus();
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (event.key === 'Tab') {
|
|
137
|
+
this._inputElement.focus();
|
|
138
|
+
requestAnimationFrame(() => {
|
|
139
|
+
this._dropdownElement.close();
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (event.key === 'ArrowDown') {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
if (!this._items.length)
|
|
146
|
+
return;
|
|
147
|
+
if (!this.dropdownVisible || this.currentIndex === null) {
|
|
148
|
+
this.currentIndex = 0;
|
|
149
|
+
this._dropdownElement.open();
|
|
150
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.currentIndex = Math.min(this.currentIndex + 1, this._items.length - 1);
|
|
154
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (event.key === 'ArrowUp') {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
if (this.currentIndex === 0) {
|
|
160
|
+
this._dropdownElement.close();
|
|
161
|
+
this._inputElement.focus();
|
|
162
|
+
}
|
|
163
|
+
if (!this.dropdownVisible || this.currentIndex === null) {
|
|
164
|
+
this.currentIndex = this._items.length - 1;
|
|
165
|
+
this._dropdownElement.open();
|
|
166
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.currentIndex = Math.max(this.currentIndex - 1, 0);
|
|
170
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
171
|
+
}
|
|
172
|
+
if (event.key === 'Enter') {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
if (this.currentIndex === null)
|
|
175
|
+
return;
|
|
176
|
+
this._dropdownElement.selectItem(this.currentIndex);
|
|
177
|
+
}
|
|
178
|
+
if (event.key === 'Home' && this.dropdownVisible) {
|
|
179
|
+
this.currentIndex = 0;
|
|
180
|
+
}
|
|
181
|
+
if (event.key === 'End' && this.dropdownVisible) {
|
|
182
|
+
this.currentIndex = this._items.length - 1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
onDropdownStateChange(event) {
|
|
186
|
+
const isOpen = event.detail;
|
|
187
|
+
this.dropdownVisible = isOpen;
|
|
188
|
+
if (!isOpen) {
|
|
189
|
+
requestAnimationFrame(() => {
|
|
190
|
+
this.currentIndex = null;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
onSelectOption(event) {
|
|
195
|
+
this._dropdownElement.close();
|
|
196
|
+
const { name, value } = event.detail;
|
|
197
|
+
this.value = this.returnObject ? event.detail : value;
|
|
198
|
+
this.changeValue.emit(this.value);
|
|
199
|
+
this.internals.setFormValue(value);
|
|
200
|
+
this.query = name;
|
|
201
|
+
this.changeQuery.emit(name);
|
|
202
|
+
this._preventDialogOpen = true;
|
|
203
|
+
if (this.optionElementsExist) {
|
|
204
|
+
Array.from(this.optionElements).forEach((item) => {
|
|
205
|
+
item.selected = item.value === value && item.name === name;
|
|
206
|
+
});
|
|
207
|
+
this._dropdownElement.updateList();
|
|
208
|
+
}
|
|
209
|
+
this._inputElement.focus();
|
|
210
|
+
}
|
|
211
|
+
handleQueryChange() {
|
|
212
|
+
this._updateStatusText();
|
|
213
|
+
}
|
|
214
|
+
_updateInput(event) {
|
|
215
|
+
this._dropdownElement.open();
|
|
216
|
+
this.query = event.target.value;
|
|
217
|
+
this.changeQuery.emit(this.query);
|
|
218
|
+
this._dropdownElement.updateList();
|
|
219
|
+
}
|
|
220
|
+
_renderLoader() {
|
|
221
|
+
return index.h("c-spinner", { color: "var(--_c-autocomplete-active-color)", size: 20 });
|
|
222
|
+
}
|
|
223
|
+
_renderChevron() {
|
|
224
|
+
const classes = {
|
|
225
|
+
'c-input-menu__chevron': true,
|
|
226
|
+
'c-input-menu__chevron--active': this.dropdownVisible,
|
|
227
|
+
};
|
|
228
|
+
return (index.h("c-icon-button", { size: "x-small", class: classes, text: true, onClick: (event) => this._toggleDropdown(event), onKeyDown: (event) => this._onButtonKeyDown('chevron', event) }, index.h("c-icon", { path: mdi.mdiChevronDown, size: 24 })));
|
|
229
|
+
}
|
|
230
|
+
_renderReset() {
|
|
231
|
+
return (index.h("c-icon-button", { "aria-label": "", size: "x-small", text: true, onClick: (event) => this._reset(event), onKeyDown: (event) => this._onButtonKeyDown('reset', event) }, index.h("c-icon", { path: mdi.mdiClose, size: 20 })));
|
|
232
|
+
}
|
|
233
|
+
_renderInputElement() {
|
|
234
|
+
var _a;
|
|
235
|
+
return (index.h("div", { class: "c-input-menu__input" }, index.h("input", { type: "text", ref: (el) => (this._inputElement = el), "aria-expanded": this.dropdownVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this.query, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: (event) => this._updateInput(event), onFocus: () => this._onInputFocus() })));
|
|
236
|
+
}
|
|
237
|
+
componentWillLoad() {
|
|
238
|
+
CAutocomplete._uniqueId += 1;
|
|
239
|
+
this._inputId =
|
|
240
|
+
'input_' +
|
|
241
|
+
(this.hostId || this.label || this.placeholder).replace(/[^a-zA-Z0-9-_]/g, '');
|
|
242
|
+
}
|
|
243
|
+
get _items() {
|
|
244
|
+
return this.optionElementsExist ? this.optionElements : this.items;
|
|
245
|
+
}
|
|
246
|
+
_updateStatusText() {
|
|
247
|
+
if (this._debounce !== null) {
|
|
248
|
+
clearTimeout(this._debounce);
|
|
249
|
+
this._debounce = null;
|
|
250
|
+
}
|
|
251
|
+
this._debounce = window.setTimeout(() => {
|
|
252
|
+
const ending = !!this._items.length
|
|
253
|
+
? ' or navigate using the up and down arrows'
|
|
254
|
+
: '';
|
|
255
|
+
if (this.currentIndex === null) {
|
|
256
|
+
this.statusText = this._items.length
|
|
257
|
+
? `${this._items.length} result${this._items.length !== 1 ? 's' : ''} available`
|
|
258
|
+
: 'No search results available';
|
|
259
|
+
}
|
|
260
|
+
if (this.query !== null && this._items.length) {
|
|
261
|
+
this.statusText += ', input a search query to filter the results';
|
|
262
|
+
}
|
|
263
|
+
this._dropdownElement.setStatusText(this.statusText + ending);
|
|
264
|
+
this._debounce = null;
|
|
265
|
+
}, 1400);
|
|
266
|
+
}
|
|
267
|
+
render() {
|
|
268
|
+
const itemType = this.optionElementsExist ? 'option' : 'item';
|
|
269
|
+
return (index.h(index.Host, null, index.h("c-dropdown", { ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "item-type": itemType, items: this._items, parent: this.el, type: "autocomplete" }, index.h("c-input", { slot: "default", ref: (el) => (this._cInputElement = el), active: this.dropdownVisible, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, shadow: this.shadow, valid: this.valid, validate: this.validate, "validate-on-blur": this.validateOnBlur, validation: this.validation, value: this.query, variant: "select" }, index.h("slot", { name: "pre", slot: "pre" }), index.h("div", { class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading && this.value && this._renderReset(), !this.loading && !this.value && this._renderChevron(), index.h("slot", { onSlotchange: () => this._handleSlotChange() })), index.h("slot", { name: "post", slot: "post" })))));
|
|
270
|
+
}
|
|
271
|
+
static get formAssociated() { return true; }
|
|
272
|
+
get el() { return index.getElement(this); }
|
|
273
|
+
static get watchers() { return {
|
|
274
|
+
"query": ["handleQueryChange"]
|
|
275
|
+
}; }
|
|
276
|
+
};
|
|
277
|
+
CAutocomplete._uniqueId = 0;
|
|
278
|
+
CAutocomplete.style = cAutocompleteCss;
|
|
7
279
|
|
|
8
280
|
const cBadgeCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-badge-background-color:var(--c-badge-background-color, var(--c-warning-600));--_c-badge-text-color:var(--c-badge-text-color, var(--c-white));--_c-badge-border-color:var(--c-badge-border-color, var(--c-white));align-items:center;background-color:var(--_c-badge-background-color);border-radius:16px;box-shadow:0 0 0 2px var(--_c-badge-border-color);color:var(--_c-badge-text-color);display:flex;font-size:12px;height:16px;justify-content:center;justify-items:center;line-height:1;min-width:16px;padding:0 4px;pointer-events:none;position:absolute;right:-6px;top:-6px;z-index:2}";
|
|
9
281
|
|
|
@@ -215,19 +487,318 @@ const CCard = class {
|
|
|
215
487
|
};
|
|
216
488
|
CCard.style = cCardCss;
|
|
217
489
|
|
|
218
|
-
const
|
|
490
|
+
const cCardActionsCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{padding:0 var(--_c-card-gap, 24px);display:block}:host menu{margin:0;padding:0}.c-card-actions{align-items:center;display:flex;gap:8px}.c-card-actions ::slotted(c-button[fit]){flex:1}.c-card-actions--align-center{align-items:center}.c-card-actions--align-start{align-items:flex-start}.c-card-actions--align-end{align-items:flex-end}.c-card-actions--justify-center{justify-content:center}.c-card-actions--justify-end{justify-content:flex-end}.c-card-actions--justify-start{justify-content:flex-start}.c-card-actions--justify-stretch{justify-content:stretch}.c-card-actions--justify-stretch ::slotted(*){flex:1}.c-card-actions--justify-space-between{justify-content:space-between}.c-card-actions--justify-space-around{justify-content:space-around}";
|
|
219
491
|
|
|
220
|
-
const
|
|
492
|
+
const CCardActions = class {
|
|
221
493
|
constructor(hostRef) {
|
|
222
494
|
index.registerInstance(this, hostRef);
|
|
223
|
-
this.
|
|
495
|
+
this.align = 'center';
|
|
496
|
+
this.justify = 'start';
|
|
224
497
|
}
|
|
225
498
|
render() {
|
|
226
|
-
const
|
|
227
|
-
|
|
499
|
+
const classes = {
|
|
500
|
+
'c-card-actions': true,
|
|
501
|
+
[`c-card-actions--align-${this.align}`]: true,
|
|
502
|
+
[`c-card-actions--justify-${this.justify}`]: true,
|
|
503
|
+
};
|
|
504
|
+
return (index.h("footer", null, index.h("menu", { class: classes }, index.h("slot", null))));
|
|
228
505
|
}
|
|
229
506
|
};
|
|
230
|
-
|
|
507
|
+
CCardActions.style = cCardActionsCss;
|
|
508
|
+
|
|
509
|
+
const cCardContentCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{display:block;padding:0 var(--_c-card-gap, 24px)}.c-card-content{display:flex;flex-direction:column;gap:var(--_c-card-gap)}.c-card-content ::slotted(*){max-width:100%}";
|
|
510
|
+
|
|
511
|
+
const CCardContent = class {
|
|
512
|
+
constructor(hostRef) {
|
|
513
|
+
index.registerInstance(this, hostRef);
|
|
514
|
+
}
|
|
515
|
+
render() {
|
|
516
|
+
return (index.h("article", { class: "c-card-content" }, index.h("slot", null)));
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
CCardContent.style = cCardContentCss;
|
|
520
|
+
|
|
521
|
+
const cCardTitleCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-card-title-color:var(--c-card-title-color, var(--c-text-system));--_c-card-title-underline-color:var(--c-card-title-underline-color, var(--c-primary-600));color:var(--_c-card-title-color);padding-inline:var(--_c-card-gap, 24px);display:block;font-family:var(--c-font-family);font-size:1rem;font-weight:500;text-transform:uppercase}.c-card-title__underline{background-color:var(--_c-card-title-underline-color);border-radius:4px;height:4px;margin-top:10px;width:44px}";
|
|
522
|
+
|
|
523
|
+
const CCardTitle = class {
|
|
524
|
+
constructor(hostRef) {
|
|
525
|
+
index.registerInstance(this, hostRef);
|
|
526
|
+
}
|
|
527
|
+
render() {
|
|
528
|
+
return (index.h("header", { class: "c-card-title" }, index.h("slot", null), index.h("div", { class: "c-card-title__underline" })));
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
CCardTitle.style = cCardTitleCss;
|
|
532
|
+
|
|
533
|
+
const cDropdownCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host(c-dropdown){--_c-dropdown-background-color:var(\n --c-dropdown-background-color,\n var(--c-white)\n );--_c-dropdown-background-color-hover:var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );--_c-dropdown-text-color:var(--c-dropdown-text-color, var(--c-text-body));--_c-dropdown-text-color-active:var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );--_c-dropdown-font-size:14px;--_c-dropdown-height:42px;display:block;position:relative}:host(c-dropdown) mark{background-color:transparent;box-shadow:0 2px 0 0 var(--_c-dropdown-text-color-active);color:inherit}:host(c-dropdown) dialog{border-radius:4px;background-color:transparent;border:none;margin:-4px 0 0;overflow:visible;padding:4px 0 0;position:fixed}:host(c-dropdown) dialog::backdrop{display:none}:host(c-dropdown) dialog[open].mobile{background-color:var(--_c-dropdown-background-color);width:100vw;max-width:100vw;height:100vh;max-height:100svh;inset:0}:host(c-dropdown) dialog[open].mobile .input-top-wrapper{padding:8px}:host(c-dropdown) dialog .input-bottom-wrapper.active{padding-top:8px}:host(c-dropdown) .dummy{display:none}:host(c-dropdown) ul{background-color:var(--_c-dropdown-background-color);box-shadow:2px 4px 10px rgba(0, 0, 0, 0.1607843137);border-radius:4px;list-style:none;margin:0;outline:none;padding:0;pointer-events:auto;visibility:hidden;width:100%;height:max-content;overflow-y:scroll}:host(c-dropdown) ul.active{visibility:visible;animation:0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1)}:host(c-dropdown) ul.active.mobile{width:100vw;max-width:100vw;height:100vh;max-height:calc(100svh - 60px)}:host(c-dropdown) li{align-items:center;column-gap:12px;cursor:pointer;display:flex;flex-wrap:nowrap;font-size:var(--_c-dropdown-font-size);min-height:var(--_c-dropdown-height);outline:none;padding-left:10px;padding-right:10px;pointer-events:auto;white-space:nowrap;width:100%;border-radius:4px}:host(c-dropdown) li span,:host(c-dropdown) li c-option-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}:host(c-dropdown) li:hover,:host(c-dropdown) li:focus,:host(c-dropdown) li.active{background:var(--_c-dropdown-background-color-hover);color:var(--_c-dropdown-text-color-active);box-shadow:inset 0 0 0 1px var(--_c-dropdown-text-color-active)}:host(c-dropdown) li:not(.disabled,:hover,:focus)[aria-selected=true]{background:var(--_c-dropdown-background-color-hover);color:var(--_c-dropdown-text-color-active);border-radius:0}:host(c-dropdown) li.disabled{background-color:rgba(var(--c-tertiary-rgb), 0.05);cursor:default;filter:grayscale(1) opacity(0.75)}:host(c-dropdown) .visuallyhidden{border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}@keyframes fade-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}";
|
|
534
|
+
|
|
535
|
+
const CDropdown = class {
|
|
536
|
+
constructor(hostRef) {
|
|
537
|
+
index.registerInstance(this, hostRef);
|
|
538
|
+
this.selectOption = index.createEvent(this, "selectOption", 7);
|
|
539
|
+
this.dropdownStateChange = index.createEvent(this, "dropdownStateChange", 7);
|
|
540
|
+
this._debounce = null;
|
|
541
|
+
this._isMobile = false;
|
|
542
|
+
this._listItems = [];
|
|
543
|
+
this._inputSize = {
|
|
544
|
+
height: 0,
|
|
545
|
+
width: 0,
|
|
546
|
+
};
|
|
547
|
+
this._openedOnTop = false;
|
|
548
|
+
this._hideDetails = false;
|
|
549
|
+
this.itemsPerPage = undefined;
|
|
550
|
+
this.parent = undefined;
|
|
551
|
+
this.items = undefined;
|
|
552
|
+
this.index = undefined;
|
|
553
|
+
this.hostId = undefined;
|
|
554
|
+
this.type = undefined;
|
|
555
|
+
this.itemType = undefined;
|
|
556
|
+
this.renderedList = null;
|
|
557
|
+
this.isOpen = false;
|
|
558
|
+
this.statusText = '';
|
|
559
|
+
}
|
|
560
|
+
optionsWatcher() {
|
|
561
|
+
requestAnimationFrame(() => {
|
|
562
|
+
this.renderedList = this._renderList();
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
async stateWatcher(isOpen) {
|
|
566
|
+
this.dropdownStateChange.emit(isOpen);
|
|
567
|
+
this._scrollParent = this._scrollParent || (await getScrollParent.getScrollParent(this.el));
|
|
568
|
+
this._scrollParent.style.overflow = isOpen ? 'hidden' : null;
|
|
569
|
+
}
|
|
570
|
+
handleIndexChange(index) {
|
|
571
|
+
requestAnimationFrame(() => {
|
|
572
|
+
var _a;
|
|
573
|
+
this._updateStatusText();
|
|
574
|
+
(_a = this._listItems[index]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
async setStatusText(text) {
|
|
578
|
+
requestAnimationFrame(() => {
|
|
579
|
+
this.statusText = text;
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
async focusItem(index) {
|
|
583
|
+
requestAnimationFrame(() => {
|
|
584
|
+
var _a;
|
|
585
|
+
(_a = this._listItems[index]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
async open() {
|
|
589
|
+
if (this._dialog.open)
|
|
590
|
+
return;
|
|
591
|
+
this._outsideClickFn = this._handleOutsideClick.bind(this);
|
|
592
|
+
window.addEventListener('click', this._outsideClickFn);
|
|
593
|
+
requestAnimationFrame(() => {
|
|
594
|
+
this.isOpen = true;
|
|
595
|
+
this._positionMenu();
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
async close() {
|
|
599
|
+
this._dialog.close();
|
|
600
|
+
this.isOpen = false;
|
|
601
|
+
this._inputElement.slot = 'default';
|
|
602
|
+
this._inputElement.hideDetails = this._hideDetails;
|
|
603
|
+
this._dummyElement.style.width = '0';
|
|
604
|
+
this._dummyElement.style.display = 'none';
|
|
605
|
+
this._dialog.style.width = '0';
|
|
606
|
+
window.removeEventListener('click', this._outsideClickFn);
|
|
607
|
+
}
|
|
608
|
+
_setIsMobile() {
|
|
609
|
+
this._isMobile = window.matchMedia('only screen and (max-width: 760px)').matches;
|
|
610
|
+
}
|
|
611
|
+
componentDidLoad() {
|
|
612
|
+
this._setIsMobile();
|
|
613
|
+
this._hideDetails = this.parent.hideDetails;
|
|
614
|
+
this._inputElement = this.el.querySelector('c-input');
|
|
615
|
+
this._resizeObserver = new ResizeObserver((entries) => {
|
|
616
|
+
if (!this._dialog.open)
|
|
617
|
+
return;
|
|
618
|
+
requestAnimationFrame(() => {
|
|
619
|
+
if (!Array.isArray(entries) || !entries.length)
|
|
620
|
+
return;
|
|
621
|
+
this._setIsMobile();
|
|
622
|
+
this.close();
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
this._resizeObserver.observe(window.document.body);
|
|
626
|
+
requestAnimationFrame(() => {
|
|
627
|
+
this.renderedList = this._renderList();
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
async selectItem(index) {
|
|
631
|
+
const item = this._listItems[index];
|
|
632
|
+
if (item.classList.contains('disabled')) {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
this._listItems[index].click();
|
|
636
|
+
return false;
|
|
637
|
+
}
|
|
638
|
+
async updateList() {
|
|
639
|
+
requestAnimationFrame(() => {
|
|
640
|
+
this.renderedList = this._renderList();
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
_handleOutsideClick(event) {
|
|
644
|
+
if (!this.isOpen)
|
|
645
|
+
return;
|
|
646
|
+
if (!event.composedPath().includes(this._dialog)) {
|
|
647
|
+
this.close();
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
_highlightMatchingText(value) {
|
|
651
|
+
const { query } = this.parent;
|
|
652
|
+
if (this.parent.tagName === 'C-SELECT' || query === '')
|
|
653
|
+
return value;
|
|
654
|
+
const regex = new RegExp(query, 'gi');
|
|
655
|
+
const highlighted = value
|
|
656
|
+
.replace(/(<([^>]+)>)/gi, '')
|
|
657
|
+
.replace(regex, (match) => `<mark>${match}</mark>`);
|
|
658
|
+
return highlighted;
|
|
659
|
+
}
|
|
660
|
+
_getParentPosition() {
|
|
661
|
+
return this.parent.shadowRoot
|
|
662
|
+
.querySelector('.c-input__slot')
|
|
663
|
+
.getBoundingClientRect();
|
|
664
|
+
}
|
|
665
|
+
_positionMenu() {
|
|
666
|
+
const { innerWidth, innerHeight } = window;
|
|
667
|
+
this._dialog.style.width = 'auto';
|
|
668
|
+
this._dialog.style.opacity = '0';
|
|
669
|
+
this._dialog.showModal();
|
|
670
|
+
requestAnimationFrame(() => {
|
|
671
|
+
let inputSlot = 'input-top';
|
|
672
|
+
const { top: parentTop, width } = this._getParentPosition();
|
|
673
|
+
const inputSize = this.el.getBoundingClientRect();
|
|
674
|
+
this._inputSize = {
|
|
675
|
+
height: inputSize.height,
|
|
676
|
+
width: inputSize.width,
|
|
677
|
+
};
|
|
678
|
+
if (!this._isMobile) {
|
|
679
|
+
this._dialog.style.width = `${width}px`;
|
|
680
|
+
this._dialog.style.top = `${inputSize.top}px`;
|
|
681
|
+
this._dialog.style.bottom = 'auto';
|
|
682
|
+
this._dialog.style.left = `${inputSize.left}px`;
|
|
683
|
+
const { bottom, right, height } = this._dialog.getBoundingClientRect();
|
|
684
|
+
const isInView = {
|
|
685
|
+
x: right < innerWidth,
|
|
686
|
+
y: bottom < innerHeight,
|
|
687
|
+
};
|
|
688
|
+
const fitsOnTop = parentTop - height > 0;
|
|
689
|
+
if (!fitsOnTop && !isInView.y) {
|
|
690
|
+
this._dialog.style.maxHeight = `${parentTop}px`;
|
|
691
|
+
}
|
|
692
|
+
if (!isInView.y || this._openedOnTop) {
|
|
693
|
+
this._openedOnTop = true;
|
|
694
|
+
this._inputElement.hideDetails = true;
|
|
695
|
+
inputSlot = 'input-bottom';
|
|
696
|
+
this._dialog.style.top = 'auto';
|
|
697
|
+
this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;
|
|
698
|
+
this._inputElement.scrollIntoView();
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
this._dummyElement.style.width = `${this._getParentPosition().width}px`;
|
|
702
|
+
this._dummyElement.style.height = `${this._inputSize.height}px`;
|
|
703
|
+
this._dummyElement.style.display = 'block';
|
|
704
|
+
this._dummyElement.slot = 'default';
|
|
705
|
+
this._inputElement.slot = inputSlot;
|
|
706
|
+
this._inputElement.hideDetails = true;
|
|
707
|
+
this._dialog.style.opacity = '1';
|
|
708
|
+
const input = this.parent.shadowRoot.querySelector('input');
|
|
709
|
+
input.focus();
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
_emptyItem() {
|
|
713
|
+
const { query, loading } = this.parent;
|
|
714
|
+
if (!query || loading)
|
|
715
|
+
return;
|
|
716
|
+
return (index.h("li", null, index.h("c-icon", { path: mdi.mdiAlert, size: 18, color: "var(--c-warning-600)" }), "No suggestions found"));
|
|
717
|
+
}
|
|
718
|
+
_renderList() {
|
|
719
|
+
return this.itemType === 'option'
|
|
720
|
+
? this._renderOptionsList()
|
|
721
|
+
: this._renderItemsList();
|
|
722
|
+
}
|
|
723
|
+
_renderOptionsList() {
|
|
724
|
+
if (!this.items.length)
|
|
725
|
+
return this._emptyItem();
|
|
726
|
+
const options = Array.from(this.items);
|
|
727
|
+
this._listItems.length = 0;
|
|
728
|
+
return options.map((option, index$1) => {
|
|
729
|
+
const optionValue = option.querySelector('c-option-value');
|
|
730
|
+
if (optionValue) {
|
|
731
|
+
optionValue.innerHTML = this._highlightMatchingText(optionValue.textContent);
|
|
732
|
+
}
|
|
733
|
+
return (index.h("li", { ref: (el) => this._listItems.push(el), id: `${this.hostId}-option-${option.value}`, tabindex: "-1", role: "option", "aria-set-size": this.items.length.toString(), "aria-pos-in-set": (index$1 + 1).toString(), "aria-selected": (!!option.selected).toString(), class: { disabled: !!option.disabled }, "data-name": option.name, onClick: (event) => {
|
|
734
|
+
if (option.disabled) {
|
|
735
|
+
event.preventDefault();
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
this.selectOption.emit({ name: option.name, value: option.value });
|
|
739
|
+
}, innerHTML: option.outerHTML }));
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
_renderItemsList() {
|
|
743
|
+
if (!this.items.length)
|
|
744
|
+
return this._emptyItem();
|
|
745
|
+
this._listItems.length = 0;
|
|
746
|
+
return this.items.map((item, index$1) => {
|
|
747
|
+
return (index.h("li", { ref: (el) => this._listItems.push(el), id: `${this.hostId}-option-${item.value}`, tabindex: "-1", role: "option", "aria-set-size": this.items.length.toString(), "aria-pos-in-set": (index$1 + 1).toString(), "aria-selected": (this.index === index$1).toString(), class: { disabled: !!item.disabled }, "data-name": item.name, onClick: (event) => {
|
|
748
|
+
if (item.disabled) {
|
|
749
|
+
event.preventDefault();
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
this.selectOption.emit({ name: item.name, value: item.value });
|
|
753
|
+
} }, index.h("span", { innerHTML: this._highlightMatchingText(item.name) })));
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
_updateStatusText() {
|
|
757
|
+
if (this._debounce !== null) {
|
|
758
|
+
clearTimeout(this._debounce);
|
|
759
|
+
this._debounce = null;
|
|
760
|
+
}
|
|
761
|
+
this._debounce = window.setTimeout(() => {
|
|
762
|
+
var _a;
|
|
763
|
+
const selection = this._listItems[this.index];
|
|
764
|
+
const ending = !!this.items.length
|
|
765
|
+
? ', to navigate use up and down arrows'
|
|
766
|
+
: '';
|
|
767
|
+
const total = this._listItems.length;
|
|
768
|
+
const position = this.index + 1;
|
|
769
|
+
const isDisabled = !!((_a = selection === null || selection === void 0 ? void 0 : selection.classList) === null || _a === void 0 ? void 0 : _a.contains('disabled'));
|
|
770
|
+
const beginning = isDisabled ? 'Disabled option - ' : '';
|
|
771
|
+
let selectionText = !!selection
|
|
772
|
+
? `${beginning}${selection.dataset.name} - ${position} of ${total} is highlighted`
|
|
773
|
+
: null;
|
|
774
|
+
if (this.index === null && this.type === 'autocomplete') {
|
|
775
|
+
selectionText = this.items.length
|
|
776
|
+
? `${this.items.length} result${this.items.length !== 1 ? 's' : ''} available`
|
|
777
|
+
: 'No search results available';
|
|
778
|
+
}
|
|
779
|
+
this.statusText = `${selectionText || ending}`;
|
|
780
|
+
this._debounce = null;
|
|
781
|
+
}, 1400);
|
|
782
|
+
}
|
|
783
|
+
render() {
|
|
784
|
+
if (!this._isMobile &&
|
|
785
|
+
this._dialog &&
|
|
786
|
+
this.itemsPerPage &&
|
|
787
|
+
this.itemsPerPage > 0 &&
|
|
788
|
+
this.items.length > this.itemsPerPage) {
|
|
789
|
+
this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';
|
|
790
|
+
this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';
|
|
791
|
+
}
|
|
792
|
+
return (index.h(index.Host, null, index.h("slot", { name: "default" }), index.h("div", { class: "dummy", ref: (el) => (this._dummyElement = el) }), index.h("dialog", { tabindex: "-1", ref: (el) => (this._dialog = el), class: { mobile: this._isMobile }, onCancel: () => this.close() }, index.h("div", { id: 'announce-' + this.hostId, class: "visuallyhidden", "aria-live": "polite", "aria-atomic": "true" }, this.statusText), index.h("div", { class: "input-top-wrapper" }, index.h("slot", { name: "input-top" })), index.h("ul", { ref: (el) => (this._list = el), id: `${this.hostId}--results`, role: "listbox", "aria-expanded": this.isOpen.toString(), class: { active: this.isOpen, mobile: this._isMobile }, tabindex: "-1" }, this.renderedList), index.h("div", { class: { active: this._openedOnTop, 'input-bottom-wrapper': true } }, index.h("slot", { name: "input-bottom" })))));
|
|
793
|
+
}
|
|
794
|
+
get el() { return index.getElement(this); }
|
|
795
|
+
static get watchers() { return {
|
|
796
|
+
"items": ["optionsWatcher"],
|
|
797
|
+
"isOpen": ["stateWatcher"],
|
|
798
|
+
"index": ["handleIndexChange"]
|
|
799
|
+
}; }
|
|
800
|
+
};
|
|
801
|
+
CDropdown.style = cDropdownCss;
|
|
231
802
|
|
|
232
803
|
const cIconCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host(c-icon){--_c-icon-color:var(\n --c-icon-color,\n var(--_c-icon-default-color, curentColor)\n );--_c-icon-size:var(--c-icon-size, 24px);display:inline-flex;align-items:center;height:var(--_c-icon-size);width:var(--_c-icon-size)}:host(c-icon) svg{height:var(--_c-icon-size);width:var(--_c-icon-size)}:host(c-icon) svg path{fill:var(--_c-icon-color)}";
|
|
233
804
|
|
|
@@ -294,17 +865,307 @@ const CIconButton = class {
|
|
|
294
865
|
};
|
|
295
866
|
CIconButton.style = cIconButtonCss;
|
|
296
867
|
|
|
297
|
-
const
|
|
868
|
+
const cInputCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host(c-input){--_c-input-inactive-color:var(--c-tertiary-600);--_c-input-active-color:var(--c-primary-600);--_c-input-background-color:var(--c-transparent);--_c-input-text-color:var(--c-text-body);--_c-input-placeholder-color:var(--c-tertiary-500);--_c-input-shadow-active-color:var(--_c-input-active-color);--_c-input-shadow-background-color:var(--c-white);--_c-input-shadow-text-color:var(--_c-input-text-color);--_c-input-shadow-placeholder-color:var(--_c-input-placeholder-color);--_c-input-error-color:var(--c-error-600)}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.c-input{--_c-input-border-width:1px;align-items:flex-start;border-radius:4px;display:flex;flex:1 1 auto;font-family:var(--c-font-family);font-size:16px;letter-spacing:normal;max-width:100%;text-align:left}.c-input input,.c-input select,.c-input textarea{background:none;border:0;display:inline-block;font-family:var(--c-font-family);font-size:16px;line-height:1;margin:0;padding:0;vertical-align:middle;white-space:normal}.c-input input,.c-input textarea{box-sizing:content-box;background-color:transparent;border:none;color:var(--_c-input-text-color);flex:1 1 auto;font-family:var(--c-font-family);font-size:16px;line-height:20px;max-width:100%;min-width:0;width:100%}.c-input input[type=checkbox],.c-input input[type=radio],.c-input select{box-sizing:border-box}.c-input input[type=search]{appearance:textfield;box-sizing:content-box}.c-input ::-webkit-search-decoration{display:none}.c-input textarea{margin-top:4px;min-height:44px;overflow:auto;padding:8px 12px 8px 0;resize:vertical;vertical-align:top}.c-input input{max-height:32px;padding:8px 0}.c-input input:focus,.c-input input:active,.c-input input[aria-expanded=true],.c-input textarea:focus,.c-input textarea:active{outline:none}.c-input .c-input__content{align-items:center;display:flex;width:100%}.c-input .c-input__content slot{display:none}.c-input .c-input__content c-icon-button{aspect-ratio:1;margin-right:-6px}.c-input__control{border-radius:inherit;color:currentColor;display:flex;flex-flow:column wrap;flex-grow:1;gap:8px;height:auto;min-width:0;width:100%;position:relative}.c-input__slot{align-items:stretch;background:transparent;border-radius:inherit;color:inherit;cursor:text;display:flex;min-height:44px;padding:0 12px;position:relative;transition:0.3s cubic-bezier(0.25, 0.8, 0.5, 1);width:100%}.c-input__field{align-items:center;display:flex;flex:1 1 auto;gap:8px;position:relative}.c-input__field input,.c-input__field textarea{flex:1;outline:0}.c-input__field label{font-size:16px;height:20px;left:0;letter-spacing:normal;line-height:20px;max-width:90%;min-height:8px;overflow:hidden;pointer-events:none;position:absolute;right:auto;text-overflow:ellipsis;top:12px;transform-origin:top left;transform:translateX(var(--_c-input-label-position)) translateY(0) scale(1);transition:0.3s cubic-bezier(0.25, 0.8, 0.5, 1) 0.08s;white-space:nowrap}.c-input__field label.active{transform:translateY(-18px) scale(0.75)}.c-input__field label span{color:var(--c-error-600)}.c-input--select input{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.c-input--select .c-input__slot{cursor:pointer}.c-input fieldset{background-color:var(--_c-input-background-color);border-collapse:collapse;border-color:var(--_c-input-inactive-color);border-radius:inherit;border-style:solid;border-width:var(--_c-input-border-width);inset:0;margin:0;padding:0 0 0 8px;pointer-events:none;position:absolute;transition-duration:0.15s;transition-property:color;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1)}.c-input fieldset legend{float:none;line-height:11px;margin-left:-1px;padding:0;text-align:left;transition:width 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);width:0}.c-input fieldset legend.active{width:var(--_c-input-legend-width)}.c-input--shadow .c-input__slot{background-color:var(--_c-input-shadow-background-color);box-shadow:rgba(0, 0, 0, 0.15) 0 5px 15px 0}.c-input--shadow .c-input__slot input,.c-input--shadow .c-input__slot textarea{color:var(--_c-input-shadow-text-color)}.c-input--shadow .c-input__slot:focus-within{outline:2px var(--_c-input-active-color) solid}.c-input--shadow .c-input__slot:focus-within c-icon{--c-icon-color:var(--_c-input-shadow-active-color) !important}.c-input--shadow input::placeholder,.c-input--shadow textarea::placeholder{color:var(--_c-input-shadow-placeholder-color);opacity:1}.c-input--disabled input,.c-input--disabled textarea,.c-input--disabled fieldset,.c-input--disabled label{--_c-input-error-color:var(--c-tertiary-500);color:var(--c-tertiary-500)}.c-input--textarea .c-input__field{margin-right:-12px}.c-input ::placeholder{color:var(--_c-input-placeholder-color);opacity:1}.c-input:focus-within,.c-input--active,.c-input:not(.c-input--disabled):active{--_c-input-border-width:2px;color:var(--_c-input-active-color)}.c-input:focus-within fieldset,.c-input--active fieldset,.c-input:not(.c-input--disabled):active fieldset{border-color:var(--_c-input-active-color)}.c-input:focus-within label,.c-input--active label,.c-input:not(.c-input--disabled):active label{color:var(--_c-input-active-color);transform:translateX(0) translateY(-18px) scale(0.75)}.c-input:focus-within legend,.c-input--active legend,.c-input:not(.c-input--disabled):active legend{width:var(--_c-input-legend-width)}.c-input.active:not(.filled) .c-input-menu__input{position:relative}.c-input.active:not(.filled) .c-input-menu__input::after{display:flex;align-items:center;position:absolute;inset:0;content:attr(data-placeholder);pointer-events:none;color:var(--_c-input-placeholder-color)}.c-input--error{color:var(--c-error-600)}.c-input--error fieldset{border-color:var(--c-error-600) !important}.c-input--error label{color:var(--c-error-600) !important}.c-input--error:focus-within{color:var(--c-error-600)}";
|
|
869
|
+
|
|
870
|
+
const CInput = class {
|
|
871
|
+
constructor(hostRef) {
|
|
872
|
+
index.registerInstance(this, hostRef);
|
|
873
|
+
this.changeValue = index.createEvent(this, "changeValue", 3);
|
|
874
|
+
this.itemClick = index.createEvent(this, "itemClick", 3);
|
|
875
|
+
this.dropdownClose = index.createEvent(this, "dropdownClose", 3);
|
|
876
|
+
this._hasBlurred = false;
|
|
877
|
+
this._debounce = null;
|
|
878
|
+
this._observer = new IntersectionObserver((entries, observer) => {
|
|
879
|
+
entries.forEach((entry) => {
|
|
880
|
+
if (entry.isIntersecting) {
|
|
881
|
+
this._calculateElementWidths();
|
|
882
|
+
observer.unobserve(entry.target);
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
}, { threshold: 1 });
|
|
886
|
+
this._onBlur = () => {
|
|
887
|
+
setTimeout(() => {
|
|
888
|
+
if (!this.active) {
|
|
889
|
+
this.isFocused = false;
|
|
890
|
+
this._hasBlurred = true;
|
|
891
|
+
}
|
|
892
|
+
this._onReset();
|
|
893
|
+
}, 100);
|
|
894
|
+
};
|
|
895
|
+
this._onFocus = (click = true) => {
|
|
896
|
+
var _a, _b;
|
|
897
|
+
if (this.disabled)
|
|
898
|
+
return;
|
|
899
|
+
this.isFocused = true;
|
|
900
|
+
(_a = this.inputField) === null || _a === void 0 ? void 0 : _a.focus();
|
|
901
|
+
if (click) {
|
|
902
|
+
(_b = this.inputField) === null || _b === void 0 ? void 0 : _b.click();
|
|
903
|
+
if (this.variant === 'select') {
|
|
904
|
+
this.itemClick.emit();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (this.inputField) {
|
|
908
|
+
this.inputField.placeholder =
|
|
909
|
+
!!this.value || !this.placeholder ? '' : this.placeholder;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
this.active = false;
|
|
913
|
+
this.autofocus = false;
|
|
914
|
+
this.disabled = false;
|
|
915
|
+
this.form = false;
|
|
916
|
+
this.hideDetails = false;
|
|
917
|
+
this.hint = '';
|
|
918
|
+
this.hostId = undefined;
|
|
919
|
+
this.inputId = undefined;
|
|
920
|
+
this.items = undefined;
|
|
921
|
+
this.itemsPerPage = 6;
|
|
922
|
+
this.label = undefined;
|
|
923
|
+
this.max = null;
|
|
924
|
+
this.min = null;
|
|
925
|
+
this.name = undefined;
|
|
926
|
+
this.placeholder = undefined;
|
|
927
|
+
this.readonly = false;
|
|
928
|
+
this.required = false;
|
|
929
|
+
this.rows = 1;
|
|
930
|
+
this.shadow = false;
|
|
931
|
+
this.step = null;
|
|
932
|
+
this.type = undefined;
|
|
933
|
+
this.valid = true;
|
|
934
|
+
this.validate = false;
|
|
935
|
+
this.validateOnBlur = false;
|
|
936
|
+
this.validation = 'Required field';
|
|
937
|
+
this.value = undefined;
|
|
938
|
+
this.variant = 'text';
|
|
939
|
+
this.isFocused = false;
|
|
940
|
+
this.labelWidth = 0;
|
|
941
|
+
this.preSlotWidth = 0;
|
|
942
|
+
this.statusText = '';
|
|
943
|
+
this.currentIndex = null;
|
|
944
|
+
}
|
|
945
|
+
onValidChange() {
|
|
946
|
+
if (this.validateOnBlur && !this._hasBlurred)
|
|
947
|
+
return;
|
|
948
|
+
this._setAriaDescriptionId();
|
|
949
|
+
}
|
|
950
|
+
onValidationMessageChange() {
|
|
951
|
+
this._updateStatusText();
|
|
952
|
+
}
|
|
953
|
+
onValueChange(value) {
|
|
954
|
+
if (!value) {
|
|
955
|
+
this._onReset();
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
onPlaceholderChange(placeholder) {
|
|
959
|
+
if (placeholder)
|
|
960
|
+
this._onReset();
|
|
961
|
+
}
|
|
962
|
+
async reset() {
|
|
963
|
+
this._onReset();
|
|
964
|
+
}
|
|
965
|
+
componentDidLoad() {
|
|
966
|
+
var _a, _b, _c, _d;
|
|
967
|
+
if (this.autofocus) {
|
|
968
|
+
setTimeout(() => {
|
|
969
|
+
this._onFocus(false);
|
|
970
|
+
}, 500);
|
|
971
|
+
}
|
|
972
|
+
this._calculateElementWidths();
|
|
973
|
+
this._setAriaDescriptionId();
|
|
974
|
+
if (this.label) {
|
|
975
|
+
this._observer.observe(this._labelRef);
|
|
976
|
+
}
|
|
977
|
+
(_a = this.inputField) === null || _a === void 0 ? void 0 : _a.addEventListener('focus', () => this._onFocus(false));
|
|
978
|
+
(_b = this.inputField) === null || _b === void 0 ? void 0 : _b.addEventListener('blur', () => this._onBlur());
|
|
979
|
+
(_c = this.inputField) === null || _c === void 0 ? void 0 : _c.addEventListener('keypress', this._preventNonNumericalInput);
|
|
980
|
+
if (this.inputField) {
|
|
981
|
+
this.inputField.placeholder =
|
|
982
|
+
!!this.label || !this.placeholder ? '' : this.placeholder;
|
|
983
|
+
this.inputField.title = (_d = this.label) !== null && _d !== void 0 ? _d : this.placeholder;
|
|
984
|
+
requestAnimationFrame(() => {
|
|
985
|
+
const container = this.inputField.closest('.c-input-menu__input');
|
|
986
|
+
if (!container)
|
|
987
|
+
return;
|
|
988
|
+
container.dataset.placeholder = this.placeholder;
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
disconnectedCallback() {
|
|
993
|
+
var _a, _b, _c, _d;
|
|
994
|
+
(_a = this.inputField) === null || _a === void 0 ? void 0 : _a.removeEventListener('focus', () => this._onFocus(false));
|
|
995
|
+
(_b = this.inputField) === null || _b === void 0 ? void 0 : _b.removeEventListener('blur', () => this._onBlur());
|
|
996
|
+
(_c = this.inputField) === null || _c === void 0 ? void 0 : _c.removeEventListener('keypress', this._preventNonNumericalInput);
|
|
997
|
+
this._observer.disconnect();
|
|
998
|
+
(_d = this._dropdownElement) === null || _d === void 0 ? void 0 : _d.remove();
|
|
999
|
+
}
|
|
1000
|
+
get isActive() {
|
|
1001
|
+
return !!this.value || typeof this.value === 'boolean' || this.isFocused;
|
|
1002
|
+
}
|
|
1003
|
+
_setAriaDescriptionId() {
|
|
1004
|
+
this.inputField.removeAttribute('aria-describedby');
|
|
1005
|
+
let type = null;
|
|
1006
|
+
if (this.valid && !this.value && this.hint) {
|
|
1007
|
+
type = 'hint';
|
|
1008
|
+
}
|
|
1009
|
+
if (!this.valid) {
|
|
1010
|
+
type = 'error';
|
|
1011
|
+
}
|
|
1012
|
+
if (type) {
|
|
1013
|
+
this.inputField.setAttribute('aria-describedby', `${type}-${this.inputId}`);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
_calculateElementWidths() {
|
|
1017
|
+
this.labelWidth = !!this.label ? this._labelRef.scrollWidth * 0.75 + 6 : 0;
|
|
1018
|
+
this.preSlotWidth = this.inputField.offsetLeft;
|
|
1019
|
+
}
|
|
1020
|
+
_onReset() {
|
|
1021
|
+
if (this.inputField) {
|
|
1022
|
+
if (!!this.placeholder &&
|
|
1023
|
+
!this.value &&
|
|
1024
|
+
(this.active || this.isFocused)) {
|
|
1025
|
+
this.inputField.placeholder = this.placeholder;
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
this.inputField.placeholder =
|
|
1029
|
+
!this.label && !this.value && !!this.placeholder
|
|
1030
|
+
? this.placeholder
|
|
1031
|
+
: '';
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
_preventNonNumericalInput(event) {
|
|
1035
|
+
if (this.type !== 'number')
|
|
1036
|
+
return;
|
|
1037
|
+
if (!event.key.match(/^[0-9,\.]+$/))
|
|
1038
|
+
event.preventDefault();
|
|
1039
|
+
}
|
|
1040
|
+
_renderBorders() {
|
|
1041
|
+
if (this.shadow)
|
|
1042
|
+
return;
|
|
1043
|
+
const classes = {
|
|
1044
|
+
active: this.isActive || this.active,
|
|
1045
|
+
};
|
|
1046
|
+
return (index.h("fieldset", { "aria-hidden": "true" }, index.h("legend", { class: classes, style: {
|
|
1047
|
+
'--_c-input-legend-width': this.labelWidth + 'px',
|
|
1048
|
+
} }, index.h("span", { class: "notranslate" }))));
|
|
1049
|
+
}
|
|
1050
|
+
_renderLabel() {
|
|
1051
|
+
if (!this.label)
|
|
1052
|
+
return;
|
|
1053
|
+
const classes = {
|
|
1054
|
+
active: this.isActive,
|
|
1055
|
+
};
|
|
1056
|
+
return (index.h("label", { htmlFor: this.inputId, ref: (el) => (this._labelRef = el), class: classes }, this.label, this.required && index.h("span", null, "\u00A0*")));
|
|
1057
|
+
}
|
|
1058
|
+
get inputField() {
|
|
1059
|
+
var _a;
|
|
1060
|
+
return (_a = this.el) === null || _a === void 0 ? void 0 : _a.querySelector('.c-input__input');
|
|
1061
|
+
}
|
|
1062
|
+
_updateStatusText() {
|
|
1063
|
+
if (this._debounce !== null) {
|
|
1064
|
+
clearTimeout(this._debounce);
|
|
1065
|
+
this._debounce = null;
|
|
1066
|
+
}
|
|
1067
|
+
this._debounce = window.setTimeout(() => {
|
|
1068
|
+
this.statusText = this.valid ? '' : `Error: ${this.validation}`;
|
|
1069
|
+
this._debounce = null;
|
|
1070
|
+
}, 1400);
|
|
1071
|
+
}
|
|
1072
|
+
render() {
|
|
1073
|
+
const containerClasses = {
|
|
1074
|
+
'c-input': true,
|
|
1075
|
+
'c-input--disabled': this.disabled,
|
|
1076
|
+
'c-input--shadow': this.shadow,
|
|
1077
|
+
'c-input--textarea': this.rows > 1,
|
|
1078
|
+
'c-input--error': !this.valid,
|
|
1079
|
+
'c-input--active': this.isFocused || this.active,
|
|
1080
|
+
filled: !!this.value,
|
|
1081
|
+
[`c-input--${this.variant}`]: true,
|
|
1082
|
+
};
|
|
1083
|
+
return (index.h(index.Host, { disabled: this.disabled }, index.h("div", { id: 'announce-' + this.inputId, class: "visuallyhidden", "aria-live": "polite", "aria-atomic": "true" }, this.statusText), index.h("div", { class: containerClasses }, index.h("div", { class: "c-input__control" }, index.h("div", { class: "c-input__slot", onClick: () => this._onFocus() }, this._renderBorders(), index.h("div", { class: "c-input__field", style: {
|
|
1084
|
+
'--_c-input-label-position': this.preSlotWidth + 'px',
|
|
1085
|
+
} }, index.h("slot", { name: "pre" }), this._renderLabel(), index.h("slot", null))), this.variant === 'select' && index.h("slot", { name: "dropdown" }), !this.hideDetails && (index.h("c-message", { hint: this.hint, inputId: this.inputId, valid: this.valid, validation: this.validation }))))));
|
|
1086
|
+
}
|
|
1087
|
+
get el() { return index.getElement(this); }
|
|
1088
|
+
static get watchers() { return {
|
|
1089
|
+
"valid": ["onValidChange"],
|
|
1090
|
+
"validation": ["onValidationMessageChange"],
|
|
1091
|
+
"value": ["onValueChange"],
|
|
1092
|
+
"placeholder": ["onPlaceholderChange"]
|
|
1093
|
+
}; }
|
|
1094
|
+
};
|
|
1095
|
+
CInput.style = cInputCss;
|
|
1096
|
+
|
|
1097
|
+
const cMessageCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-message-error-color:var(--c-error-600);--_c-message-hint-color:var(--c-text-system);display:block;line-height:1;padding:0 12px}.c-message--active .c-message-item{opacity:1;transform:translateY(0)}.c-message-item{font-size:12px;min-height:16px;opacity:0;transform:translateY(-4px);transition:all 0.2s cubic-bezier(0.25, 0.8, 0.5, 1)}.c-message-item--hint{color:var(--_c-message-hint-color)}.c-message-item--error{color:var(--_c-message-error-color)}.c-message-item span{align-items:flex-start;color:currentColor;display:flex;gap:4px;min-height:16px}.c-message-item svg{fill:currentColor;height:16px;width:16px;position:relative;top:-2px}.c-message .visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}";
|
|
298
1098
|
|
|
299
|
-
const
|
|
1099
|
+
const CMessage = class {
|
|
300
1100
|
constructor(hostRef) {
|
|
301
1101
|
index.registerInstance(this, hostRef);
|
|
1102
|
+
this._validationIcon = (index.h("svg", { height: "16px", width: "16px", viewBox: "0 0 24 24" }, index.h("path", { d: mdi.mdiCloseCircle })));
|
|
1103
|
+
this.hint = '';
|
|
1104
|
+
this.inputId = undefined;
|
|
1105
|
+
this.valid = true;
|
|
1106
|
+
this.validation = 'Required field';
|
|
1107
|
+
this.messageOptions = {
|
|
1108
|
+
show: true,
|
|
1109
|
+
type: 'hint',
|
|
1110
|
+
content: '',
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
onValidChange(valid) {
|
|
1114
|
+
this._handleValidation(valid);
|
|
1115
|
+
}
|
|
1116
|
+
onValidationMessageChange(message) {
|
|
1117
|
+
if (this.valid || !message)
|
|
1118
|
+
return;
|
|
1119
|
+
this.messageOptions = Object.assign(Object.assign({}, this.messageOptions), { content: (index.h("span", null, index.h("span", { class: "visuallyhidden" }, "Error: "), this._validationIcon, " ", message)) });
|
|
1120
|
+
}
|
|
1121
|
+
onHintMessageChange(message) {
|
|
1122
|
+
if (!this.valid || !message)
|
|
1123
|
+
return;
|
|
1124
|
+
this.messageOptions = Object.assign(Object.assign({}, this.messageOptions), { content: (index.h("span", null, index.h("span", { class: "visuallyhidden" }, "Hint: "), message)) });
|
|
1125
|
+
}
|
|
1126
|
+
_handleValidation(valid, timeout = 200) {
|
|
1127
|
+
this.messageOptions = Object.assign(Object.assign({}, this.messageOptions), { show: false });
|
|
1128
|
+
setTimeout(() => {
|
|
1129
|
+
this.messageOptions = Object.assign(Object.assign({}, this.messageOptions), { type: valid ? 'hint' : 'error', show: true, content: valid ? (index.h("span", { id: `hint-${this.inputId}` }, index.h("span", { class: "visuallyhidden" }, "Hint: "), this.hint)) : (index.h("span", { id: `error-${this.inputId}` }, this._validationIcon, index.h("span", { class: "visuallyhidden" }, "Error: "), this.validation)) });
|
|
1130
|
+
}, timeout);
|
|
1131
|
+
}
|
|
1132
|
+
componentDidLoad() {
|
|
1133
|
+
this._handleValidation(this.valid, 0);
|
|
302
1134
|
}
|
|
303
1135
|
render() {
|
|
304
|
-
|
|
1136
|
+
const classes = {
|
|
1137
|
+
'c-message': true,
|
|
1138
|
+
'c-message--active': this.messageOptions.show,
|
|
1139
|
+
};
|
|
1140
|
+
const messageClasses = {
|
|
1141
|
+
'c-message-item': true,
|
|
1142
|
+
[`c-message-item--${this.messageOptions.type}`]: true,
|
|
1143
|
+
};
|
|
1144
|
+
return (index.h(index.Host, null, index.h("div", { class: classes }, index.h("div", { class: messageClasses }, this.messageOptions.content))));
|
|
1145
|
+
}
|
|
1146
|
+
static get watchers() { return {
|
|
1147
|
+
"valid": ["onValidChange"],
|
|
1148
|
+
"validation": ["onValidationMessageChange"],
|
|
1149
|
+
"hint": ["onHintMessageChange"]
|
|
1150
|
+
}; }
|
|
1151
|
+
};
|
|
1152
|
+
CMessage.style = cMessageCss;
|
|
1153
|
+
|
|
1154
|
+
const cOptionCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{display:block;width:100%;padding:8px 0}";
|
|
1155
|
+
|
|
1156
|
+
const COption = class {
|
|
1157
|
+
constructor(hostRef) {
|
|
1158
|
+
index.registerInstance(this, hostRef);
|
|
1159
|
+
this.selected = false;
|
|
1160
|
+
this.disabled = false;
|
|
1161
|
+
this.name = undefined;
|
|
1162
|
+
this.value = undefined;
|
|
1163
|
+
}
|
|
1164
|
+
render() {
|
|
1165
|
+
return (index.h(index.Host, { tabindex: "-1" }, index.h("slot", null)));
|
|
305
1166
|
}
|
|
306
1167
|
};
|
|
307
|
-
|
|
1168
|
+
COption.style = cOptionCss;
|
|
308
1169
|
|
|
309
1170
|
const cRippleCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{pointer-events:none;user-select:none;display:block;overflow:hidden;position:absolute;top:0;left:0;border-radius:inherit;z-index:1}.c-ripple{position:absolute;pointer-events:none;border-radius:50%;transform:scale(0);background:currentColor;opacity:0}.c-ripple.animate{animation:ripple 0.5s backwards linear;opacity:0.3}@keyframes ripple{100%{opacity:0;transform:scale(5)}}";
|
|
310
1171
|
|
|
@@ -352,43 +1213,312 @@ const CRipple = class {
|
|
|
352
1213
|
};
|
|
353
1214
|
CRipple.style = cRippleCss;
|
|
354
1215
|
|
|
355
|
-
const
|
|
1216
|
+
const cSelectCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-select-active-color:var(--c-select-active-color, var(--c-primary-600));--_c-select-inactive-color:var(--c-select-inactive-color, var(--c-tertiary-600));--_c-select-background-color:var(--c-select-background-color, var(--c-transparent));--_c-select-text-color:var(--c-select-text-color, var(--c-text-body));--_c-select-placeholder-color:var(--c-select-placeholder-color, var(--c-tertiary-500));--_c-select-option-background-color:var(--c-select-option-background-color, var(--c-white));--_c-select-option-background-color-hover:var(--c-select-option-background-color-hover, var(--c-primary-100));--_c-select-option-text-color:var(--c-select-option-text-color, var(--c-text-body));--_c-select-shadow-active-color:var(--c-select-shadow-active-color, var(--_c-select-active-color));--_c-select-shadow-background-color:var(--c-select-shadow-background-color, var(--c-white));--_c-select-shadow-text-color:var(--c-select-shadow-text-color, var(--_c-select-text-color));--_c-select-shadow-placeholder-color:var(--c-select-shadow-placeholder-color, var(--_c-select-placeholder-color));--_c-input-active-color:var(--_c-select-active-color);--_c-input-inactive-color:var(--_c-select-inactive-color);--_c-input-background-color:var(--_c-select-background-color);--_c-input-text-color:var(--_c-select-text-color);--_c-input-placeholder-color:var(--_c-select-placeholder-color);--_c-input-shadow-active-color:var(--_c-select-shadow-active-color);--_c-input-shadow-background-color:var(--_c-select-shadow-background-color);--_c-input-shadow-text-color:var(--_c-select-shadow-text-color);--_c-input-shadow-placeholder-color:var(--_c-select-shadow-placeholder-color)}:host{display:block;cursor:text}.c-input-menu__chevron{fill:currentColor;transform:rotate(0deg);transition:transform 0.3s ease-in-out}.c-input-menu__chevron--active{transform:rotate(180deg)}.c-input-menu__input{width:100%;display:flex;justify-items:stretch}.c-input-menu__selection{display:none;pointer-events:none}.c-input-menu__selection--show{align-items:center;display:flex;width:100%;color:var(--_c-select-active-color)}.c-input-menu__item-wrapper{position:absolute;width:100%;top:44px;z-index:10;margin-left:calc(var(--_c-input-label-position) * -1)}.c-input-menu__item-wrapper--shadow{top:47px}.c-input-menu__items{position:absolute;background-color:var(--_c-select-option-background-color);min-width:calc(100% + 24px);box-shadow:0 8px 16px 0 rgba(0, 0, 0, 0.2);z-index:10;user-select:none;border-radius:4px;margin:0 -12px;overflow-y:scroll;list-style:none;padding:0}.c-input-menu__items--hidden{display:none}.c-input-menu__items li{cursor:pointer;display:flex;min-height:48px;padding:0 12px;transition:background-color 0.3s;font-size:14px;align-items:center;justify-content:flex-start;color:var(--_c-select-option-text-color)}.c-input-menu__items li.disabled{background-color:var(--c-tertiary-100);filter:grayscale(1) opacity(0.6);cursor:default}.c-input-menu__items li.disabled:hover{background-color:var(--c-tertiary-100)}.c-input-menu__items li.dense{padding:10px 14px}.c-input-menu__items li:hover{background-color:var(--_c-select-option-background-color-hover)}.c-input-menu__items li[aria-selected=true]{background-color:var(--_c-select-option-background-color-hover);box-shadow:inset 0 0 0 1px var(--_c-select-active-color);border-radius:4px;backface-visibility:hidden;transform:translate3d(0, 0, 0)}.c-input-menu__items li.none{color:rgba(0, 0, 0, 0.5)}.c-input-menu__items--empty li{color:var(--c-text-system);cursor:default;gap:8px;pointer-events:none}.c-input-menu__items--empty li svg{fill:var(--c-warning-600);height:18px;width:18px}input{max-height:32px;padding:8px 0;background-color:transparent;border:none;color:var(--c-text-body);flex:1 1 auto;font-family:var(--c-font-family);font-size:16px;line-height:20px;max-width:100%;min-width:0;width:100%;pointer-events:none}input:focus,input:active{outline:none}input::-ms-reveal{display:none}svg{fill:currentColor;height:22px;width:22px}.c-input--disabled{color:var(--c-tertiary-400)}.c-input:focus-within{color:var(--c-primary-600)}.c-input--error{color:var(--c-error-600)}.c-input--error:focus-within{color:var(--c-error-600)}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}";
|
|
356
1217
|
|
|
357
|
-
const
|
|
1218
|
+
const CSelect = class {
|
|
358
1219
|
constructor(hostRef) {
|
|
359
1220
|
index.registerInstance(this, hostRef);
|
|
360
|
-
this.
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
1221
|
+
this.changeValue = index.createEvent(this, "changeValue", 3);
|
|
1222
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
1223
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1226
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
1227
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
1228
|
+
}
|
|
1229
|
+
this._preventDialogOpen = false;
|
|
1230
|
+
this._debounce = null;
|
|
1231
|
+
this._lastKeyPressTime = null;
|
|
1232
|
+
this._searchString = '';
|
|
1233
|
+
this._toggleDropdown = (event) => {
|
|
1234
|
+
event.stopPropagation();
|
|
1235
|
+
if (this.dropdownVisible) {
|
|
1236
|
+
this._dropdownElement.close();
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
this._dropdownElement.open();
|
|
1240
|
+
};
|
|
1241
|
+
this._onButtonKeyDown = (src, event) => {
|
|
1242
|
+
event.stopPropagation();
|
|
1243
|
+
if (event.key !== 'Tab')
|
|
1244
|
+
event.preventDefault();
|
|
1245
|
+
if (['Enter', ' '].includes(event.key)) {
|
|
1246
|
+
if (src === 'chevron') {
|
|
1247
|
+
this._toggleDropdown(event);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
this._onReset(event);
|
|
1251
|
+
this._preventDialogOpen = true;
|
|
1252
|
+
requestAnimationFrame(() => {
|
|
1253
|
+
this._inputElement.focus();
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
this._onSlotChange = () => {
|
|
1258
|
+
this.optionElements = this.el.querySelectorAll('c-option');
|
|
1259
|
+
if (this.optionElements.length && !this.optionElementsExist) {
|
|
1260
|
+
this.optionElementsExist = true;
|
|
1261
|
+
}
|
|
1262
|
+
const selection = Array.from(this.optionElements).find((option) => option.selected);
|
|
1263
|
+
if (selection) {
|
|
1264
|
+
this.value = this.returnObject
|
|
1265
|
+
? { name: selection.name, value: selection.value }
|
|
1266
|
+
: selection.value;
|
|
1267
|
+
this.changeValue.emit(this.value);
|
|
1268
|
+
this.internals.setFormValue(selection.value.toString());
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
this._onReset = (event) => {
|
|
1272
|
+
event.stopPropagation();
|
|
1273
|
+
this.changeValue.emit(null);
|
|
1274
|
+
this.internals.setFormValue(null);
|
|
1275
|
+
this._selectionElement.classList.remove('c-input-menu__selection--show');
|
|
1276
|
+
this._selectionElement.replaceChildren(null);
|
|
1277
|
+
this._preventDialogOpen = true;
|
|
1278
|
+
this._cInputElement.reset();
|
|
1279
|
+
this._inputElement.focus();
|
|
1280
|
+
this._dropdownElement.updateList();
|
|
1281
|
+
};
|
|
1282
|
+
this._onInputFocus = () => {
|
|
1283
|
+
if (!this._preventDialogOpen) {
|
|
1284
|
+
this._dropdownElement.open();
|
|
1285
|
+
}
|
|
1286
|
+
this._updateStatusText();
|
|
1287
|
+
this._preventDialogOpen = false;
|
|
1288
|
+
};
|
|
1289
|
+
this.items = [];
|
|
1290
|
+
this.value = null;
|
|
1291
|
+
this.hostId = undefined;
|
|
1292
|
+
this.clearable = false;
|
|
1293
|
+
this.disabled = false;
|
|
1294
|
+
this.label = undefined;
|
|
1295
|
+
this.name = undefined;
|
|
1296
|
+
this.placeholder = '';
|
|
1297
|
+
this.hideDetails = false;
|
|
1298
|
+
this.hint = '';
|
|
1299
|
+
this.loading = false;
|
|
1300
|
+
this.required = false;
|
|
1301
|
+
this.valid = true;
|
|
1302
|
+
this.validate = false;
|
|
1303
|
+
this.validateOnBlur = false;
|
|
1304
|
+
this.validation = 'Required field';
|
|
1305
|
+
this.shadow = false;
|
|
1306
|
+
this.returnObject = false;
|
|
1307
|
+
this.itemsPerPage = 6;
|
|
1308
|
+
this.optionAsSelection = undefined;
|
|
1309
|
+
this.optionElements = undefined;
|
|
1310
|
+
this.currentIndex = null;
|
|
1311
|
+
this.dropdownVisible = false;
|
|
1312
|
+
this.statusText = '';
|
|
1313
|
+
this.optionElementsExist = false;
|
|
1314
|
+
}
|
|
1315
|
+
get _id() {
|
|
1316
|
+
return this.hostId || `select_${CSelect._uniqueId}`;
|
|
1317
|
+
}
|
|
1318
|
+
get _items() {
|
|
1319
|
+
return this.optionElementsExist ? this.optionElements : this.items;
|
|
1320
|
+
}
|
|
1321
|
+
get _value() {
|
|
1322
|
+
var _a, _b, _c, _d;
|
|
1323
|
+
if (!this.value)
|
|
1324
|
+
return '';
|
|
1325
|
+
if (!this.returnObject &&
|
|
1326
|
+
!['number', 'string'].includes(typeof this.value)) {
|
|
1327
|
+
console.warn(`[C-SELECT] The value should be of type 'number' or 'string' when return-object is not used.`);
|
|
1328
|
+
return '';
|
|
1329
|
+
}
|
|
1330
|
+
if (!this.returnObject &&
|
|
1331
|
+
['number', 'string'].includes(typeof this.value)) {
|
|
1332
|
+
return (_b = (_a = Array.from(this._items)) === null || _a === void 0 ? void 0 : _a.find((item) => item.value === this.value)) === null || _b === void 0 ? void 0 : _b.name;
|
|
1333
|
+
}
|
|
1334
|
+
return (_d = (_c = Array.from(this._items)) === null || _c === void 0 ? void 0 : _c.find((item) => item.value === this.value.value)) === null || _d === void 0 ? void 0 : _d.name;
|
|
1335
|
+
}
|
|
1336
|
+
async reset() {
|
|
1337
|
+
this.changeValue.emit(null);
|
|
1338
|
+
this.internals.setFormValue(null);
|
|
1339
|
+
this._dropdownElement.updateList();
|
|
1340
|
+
}
|
|
1341
|
+
handleKeyDown(event) {
|
|
1342
|
+
const alphanumeric = /^[0-9a-zA-Z ]+$/;
|
|
1343
|
+
if (event.key.match(alphanumeric) && event.key.length === 1) {
|
|
1344
|
+
if (this.dropdownVisible)
|
|
1345
|
+
return;
|
|
1346
|
+
if (Date.now() - this._lastKeyPressTime > 3000) {
|
|
1347
|
+
this._searchString = event.key;
|
|
1348
|
+
}
|
|
1349
|
+
else {
|
|
1350
|
+
this._searchString += event.key;
|
|
1351
|
+
}
|
|
1352
|
+
this._lastKeyPressTime = Date.now();
|
|
1353
|
+
const selectionIndex = Array.from(this._items).findIndex((i) => i.name.toLowerCase().startsWith(this._searchString));
|
|
1354
|
+
this.currentIndex = selectionIndex >= 0 ? selectionIndex : null;
|
|
1355
|
+
if (this.currentIndex !== null) {
|
|
1356
|
+
this._dropdownElement.selectItem(this.currentIndex);
|
|
1357
|
+
}
|
|
1358
|
+
return;
|
|
1359
|
+
}
|
|
1360
|
+
if (event.key === 'Escape') {
|
|
1361
|
+
this._preventDialogOpen = true;
|
|
1362
|
+
this._dropdownElement.close();
|
|
1363
|
+
this._inputElement.focus();
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
if (event.key === 'Tab') {
|
|
1367
|
+
this._dropdownElement.close();
|
|
1368
|
+
}
|
|
1369
|
+
if (event.key === 'ArrowDown') {
|
|
1370
|
+
event.preventDefault();
|
|
1371
|
+
if (!this._items.length)
|
|
1372
|
+
return;
|
|
1373
|
+
if (!this.dropdownVisible) {
|
|
1374
|
+
this._dropdownElement.open();
|
|
1375
|
+
}
|
|
1376
|
+
this.currentIndex =
|
|
1377
|
+
this.currentIndex === null
|
|
1378
|
+
? 0
|
|
1379
|
+
: Math.min(this.currentIndex + 1, this._items.length - 1);
|
|
1380
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
1381
|
+
}
|
|
1382
|
+
if (event.key === 'ArrowUp') {
|
|
1383
|
+
event.preventDefault();
|
|
1384
|
+
if (this.currentIndex === 0) {
|
|
1385
|
+
this._dropdownElement.close();
|
|
1386
|
+
this._inputElement.focus();
|
|
1387
|
+
}
|
|
1388
|
+
if (!this.dropdownVisible) {
|
|
1389
|
+
this._dropdownElement.open();
|
|
1390
|
+
}
|
|
1391
|
+
this.currentIndex =
|
|
1392
|
+
this.currentIndex === null
|
|
1393
|
+
? this._items.length - 1
|
|
1394
|
+
: Math.max(this.currentIndex - 1, 0);
|
|
1395
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
1396
|
+
}
|
|
1397
|
+
if (event.key === ' ') {
|
|
1398
|
+
event.preventDefault();
|
|
1399
|
+
}
|
|
1400
|
+
if (event.key === 'Enter') {
|
|
1401
|
+
event.preventDefault();
|
|
1402
|
+
if (this.currentIndex === null)
|
|
1403
|
+
return;
|
|
1404
|
+
this._dropdownElement.selectItem(this.currentIndex);
|
|
1405
|
+
}
|
|
1406
|
+
if (event.key === 'Home' && this.dropdownVisible) {
|
|
1407
|
+
this.currentIndex = 0;
|
|
1408
|
+
}
|
|
1409
|
+
if (event.key === 'End' && this.dropdownVisible) {
|
|
1410
|
+
this.currentIndex = this._items.length - 1;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
onDropdownStateChange(event) {
|
|
1414
|
+
const isOpen = event.detail;
|
|
1415
|
+
this.dropdownVisible = isOpen;
|
|
1416
|
+
}
|
|
1417
|
+
onSelectOption(event) {
|
|
1418
|
+
this._dropdownElement.close();
|
|
1419
|
+
const { name, value } = event.detail;
|
|
1420
|
+
const selection = this._setCurrentIndex({ name, value });
|
|
1421
|
+
if (this.optionElementsExist && this.optionAsSelection && selection) {
|
|
1422
|
+
const clone = selection.cloneNode(true);
|
|
1423
|
+
this._selectionElement.classList.add('c-input-menu__selection--show');
|
|
1424
|
+
this._selectionElement.replaceChildren(clone);
|
|
1425
|
+
}
|
|
1426
|
+
this._dropdownElement.updateList();
|
|
1427
|
+
this.value = this.returnObject ? event.detail : value;
|
|
1428
|
+
this.changeValue.emit(this.value);
|
|
1429
|
+
this.internals.setFormValue(value);
|
|
1430
|
+
this._preventDialogOpen = true;
|
|
1431
|
+
this._inputElement.focus();
|
|
1432
|
+
}
|
|
1433
|
+
_setCurrentIndex({ value, name }) {
|
|
1434
|
+
let selection = null;
|
|
1435
|
+
Array.from(this._items).forEach((item, index) => {
|
|
1436
|
+
const selected = item.value === value && item.name === name;
|
|
1437
|
+
if (this.optionElementsExist) {
|
|
1438
|
+
item.selected = selected;
|
|
1439
|
+
}
|
|
1440
|
+
if (selected) {
|
|
1441
|
+
this.currentIndex = index;
|
|
1442
|
+
selection = item;
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
return selection;
|
|
1446
|
+
}
|
|
1447
|
+
_updateInput() {
|
|
1448
|
+
this._dropdownElement.open();
|
|
1449
|
+
this._dropdownElement.updateList();
|
|
1450
|
+
}
|
|
1451
|
+
_updateStatusText() {
|
|
1452
|
+
if (this._debounce !== null) {
|
|
1453
|
+
clearTimeout(this._debounce);
|
|
1454
|
+
this._debounce = null;
|
|
1455
|
+
}
|
|
1456
|
+
this._debounce = window.setTimeout(() => {
|
|
1457
|
+
this.statusText = '';
|
|
1458
|
+
if (this.currentIndex === null) {
|
|
1459
|
+
this.statusText = this._items.length
|
|
1460
|
+
? `${this._items.length} option${this._items.length !== 1 ? 's' : ''} available`
|
|
1461
|
+
: 'No options available';
|
|
1462
|
+
}
|
|
1463
|
+
const ending = !!this._items.length
|
|
1464
|
+
? ', navigate using the up and down arrows'
|
|
1465
|
+
: '';
|
|
1466
|
+
this._dropdownElement.setStatusText(this.statusText + ending);
|
|
1467
|
+
this._debounce = null;
|
|
1468
|
+
}, 1400);
|
|
1469
|
+
}
|
|
1470
|
+
componentWillLoad() {
|
|
1471
|
+
CSelect._uniqueId += 1;
|
|
1472
|
+
this._inputId =
|
|
1473
|
+
'input_' +
|
|
1474
|
+
(this.hostId || this.label || this.placeholder).replace(/[^a-zA-Z0-9-_]/g, '');
|
|
364
1475
|
}
|
|
365
1476
|
componentDidLoad() {
|
|
366
|
-
|
|
1477
|
+
if (!this.value)
|
|
1478
|
+
return;
|
|
1479
|
+
const selection = Array.from(this._items).find((item) => {
|
|
1480
|
+
if (this.returnObject) {
|
|
1481
|
+
return (item.name === this.value.name &&
|
|
1482
|
+
item.value === this.value.value);
|
|
1483
|
+
}
|
|
1484
|
+
return item.value === this.value;
|
|
1485
|
+
});
|
|
1486
|
+
this._setCurrentIndex({
|
|
1487
|
+
name: selection.name,
|
|
1488
|
+
value: selection.value.toString(),
|
|
1489
|
+
});
|
|
367
1490
|
}
|
|
368
|
-
|
|
1491
|
+
_renderLoader() {
|
|
1492
|
+
return index.h("c-spinner", { color: "var(--_c-autocomplete-active-color)", size: 20 });
|
|
1493
|
+
}
|
|
1494
|
+
_renderChevron() {
|
|
369
1495
|
const classes = {
|
|
370
|
-
'c-
|
|
371
|
-
'c-
|
|
372
|
-
[`c-row--align-${this.align}`]: !!this.align,
|
|
373
|
-
[`c-row--justify-${this.justify}`]: !!this.justify,
|
|
1496
|
+
'c-input-menu__chevron': true,
|
|
1497
|
+
'c-input-menu__chevron--active': this.dropdownVisible,
|
|
374
1498
|
};
|
|
375
|
-
return (index.h(
|
|
1499
|
+
return (index.h("c-icon-button", { size: "x-small", class: classes, text: true, onClick: (event) => this._toggleDropdown(event), onKeyDown: (event) => this._onButtonKeyDown('chevron', event) }, index.h("c-icon", { path: mdi.mdiChevronDown, size: 24 })));
|
|
376
1500
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const CSpacer = class {
|
|
384
|
-
constructor(hostRef) {
|
|
385
|
-
index.registerInstance(this, hostRef);
|
|
1501
|
+
_renderInputElement() {
|
|
1502
|
+
var _a;
|
|
1503
|
+
return (index.h("div", { class: "c-input-menu__input" }, index.h("input", { type: "text", readonly: true, ref: (el) => (this._inputElement = el), "aria-expanded": this.dropdownVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this._value, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: () => this._updateInput(), onFocus: () => this._onInputFocus() }), index.h("div", { ref: (el) => (this._selectionElement = el), class: "c-input-menu__selection" })));
|
|
1504
|
+
}
|
|
1505
|
+
_renderReset() {
|
|
1506
|
+
return (index.h("c-icon-button", { "aria-label": "", size: "x-small", text: true, onClick: (event) => this._onReset(event), onKeyDown: (event) => this._onButtonKeyDown('reset', event) }, index.h("c-icon", { path: mdi.mdiClose, size: 20 })));
|
|
386
1507
|
}
|
|
387
1508
|
render() {
|
|
388
|
-
|
|
1509
|
+
const itemType = this.optionElementsExist ? 'option' : 'item';
|
|
1510
|
+
return (index.h(index.Host, null, index.h("c-dropdown", { ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "item-type": itemType, items: this._items, parent: this.el, type: "select" }, index.h("c-input", { slot: "default", ref: (el) => (this._cInputElement = el), active: this.dropdownVisible, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, shadow: this.shadow, valid: this.valid, validate: this.validate, "validate-on-blur": this.validateOnBlur, validation: this.validation, value: this.value, variant: "select", onClick: () => this._dropdownElement.open() }, index.h("slot", { name: "pre", slot: "pre" }), index.h("div", { class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading &&
|
|
1511
|
+
this.value &&
|
|
1512
|
+
this.clearable &&
|
|
1513
|
+
this._renderReset(), !this.loading &&
|
|
1514
|
+
(!this.value || !this.clearable) &&
|
|
1515
|
+
this._renderChevron(), index.h("slot", { onSlotchange: () => this._onSlotChange() })), index.h("slot", { name: "post", slot: "post" })))));
|
|
389
1516
|
}
|
|
1517
|
+
static get formAssociated() { return true; }
|
|
1518
|
+
get el() { return index.getElement(this); }
|
|
390
1519
|
};
|
|
391
|
-
|
|
1520
|
+
CSelect._uniqueId = 0;
|
|
1521
|
+
CSelect.style = cSelectCss;
|
|
392
1522
|
|
|
393
1523
|
const cSpinnerCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-spinner-color:var(--c-spinner-color, var(--c-color));--_c-spinner-size:var(--c-size);--_c-spinner-width:var(--c-width);display:block;height:var(--_c-spinner-size);width:var(--_c-spinner-size)}:host(.c-spinner) svg{fill:var(--_c-spinner-color);height:var(--_c-spinner-size);overflow:visible;width:var(--_c-spinner-size)}:host(.c-spinner) svg circle{animation:spinner 2.5s linear infinite;fill:transparent;stroke-dasharray:calc(3.14 * var(--_c-spinner-size));stroke-linecap:round;stroke-width:var(--_c-spinner-width);stroke:var(--_c-spinner-color);transform-origin:calc(0.5px * var(--_c-spinner-size)) calc(0.5px * var(--_c-spinner-size)) 0}@keyframes spinner{0%{transform:rotate(0deg);stroke-dashoffset:calc(0.66 * var(--_c-spinner-size))}50%{transform:rotate(720deg);stroke-dashoffset:calc(3.14 * var(--_c-spinner-size))}100%{transform:rotate(1080deg);stroke-dashoffset:calc(0.66 * var(--_c-spinner-size))}}";
|
|
394
1524
|
|
|
@@ -415,29 +1545,21 @@ const CSpinner = class {
|
|
|
415
1545
|
};
|
|
416
1546
|
CSpinner.style = cSpinnerCss;
|
|
417
1547
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const CToolbar = class {
|
|
421
|
-
constructor(hostRef) {
|
|
422
|
-
index.registerInstance(this, hostRef);
|
|
423
|
-
}
|
|
424
|
-
render() {
|
|
425
|
-
return (index.h(index.Host, null, index.h("div", { class: "c-toolbar" }, index.h("slot", null)), index.h("div", { class: "spacer" })));
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
CToolbar.style = cToolbarCss;
|
|
429
|
-
|
|
1548
|
+
exports.c_autocomplete = CAutocomplete;
|
|
430
1549
|
exports.c_badge = CBadge;
|
|
431
1550
|
exports.c_button = CButton;
|
|
432
1551
|
exports.c_card = CCard;
|
|
433
|
-
exports.
|
|
1552
|
+
exports.c_card_actions = CCardActions;
|
|
1553
|
+
exports.c_card_content = CCardContent;
|
|
1554
|
+
exports.c_card_title = CCardTitle;
|
|
1555
|
+
exports.c_dropdown = CDropdown;
|
|
434
1556
|
exports.c_icon = CIcon;
|
|
435
1557
|
exports.c_icon_button = CIconButton;
|
|
436
|
-
exports.
|
|
1558
|
+
exports.c_input = CInput;
|
|
1559
|
+
exports.c_message = CMessage;
|
|
1560
|
+
exports.c_option = COption;
|
|
437
1561
|
exports.c_ripple = CRipple;
|
|
438
|
-
exports.
|
|
439
|
-
exports.c_spacer = CSpacer;
|
|
1562
|
+
exports.c_select = CSelect;
|
|
440
1563
|
exports.c_spinner = CSpinner;
|
|
441
|
-
exports.c_toolbar = CToolbar;
|
|
442
1564
|
|
|
443
|
-
//# sourceMappingURL=c-
|
|
1565
|
+
//# sourceMappingURL=c-autocomplete_16.cjs.entry.js.map
|