@cscfi/csc-ui 1.3.1 → 1.3.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-autocomplete_34.cjs.entry.js +22 -12
- package/dist/cjs/c-autocomplete_34.cjs.entry.js.map +1 -1
- package/dist/cjs/csc-ui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/c-autocomplete/c-autocomplete.js +57 -0
- package/dist/collection/components/c-autocomplete/c-autocomplete.js.map +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.css +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.js +19 -12
- package/dist/collection/components/c-dropdown/c-dropdown.js.map +1 -1
- package/dist/components/c-autocomplete.js +6 -0
- package/dist/components/c-autocomplete.js.map +1 -1
- package/dist/components/c-dropdown2.js +20 -13
- package/dist/components/c-dropdown2.js.map +1 -1
- 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-d72364b9.js → p-1c767310.js} +2 -2
- package/dist/csc-ui/{p-6733b506.entry.js → p-49a7a96d.entry.js} +2 -2
- package/dist/csc-ui/p-6a6a89ef.entry.js +2 -0
- package/dist/csc-ui/{p-30edfff8.entry.js.map → p-6a6a89ef.entry.js.map} +1 -1
- package/dist/csc-ui/{p-e90ac550.entry.js → p-7f97a326.entry.js} +2 -2
- package/dist/csc-ui/{p-765ae162.entry.js → p-a7aa8fcf.entry.js} +2 -2
- package/dist/csc-ui/{p-6a54587f.entry.js → p-aae874cf.entry.js} +2 -2
- package/dist/csc-ui/{p-30bf678d.entry.js → p-c2767e00.entry.js} +2 -2
- package/dist/csc-ui/p-ddff8326.entry.js +2 -0
- package/dist/csc-ui/{p-9bf601bb.entry.js.map → p-ddff8326.entry.js.map} +1 -1
- package/dist/csc-ui/p-df913633.entry.js +2 -0
- package/dist/csc-ui/{p-4f54f704.entry.js.map → p-df913633.entry.js.map} +1 -1
- package/dist/csc-ui/{p-dfe321ae.entry.js → p-e7b91787.entry.js} +2 -2
- package/dist/csc-ui/{p-7ca9b5ff.entry.js → p-fc47b970.entry.js} +2 -2
- package/dist/esm/c-accordion-item.entry.js +1 -1
- package/dist/esm/c-alert.entry.js +1 -1
- package/dist/esm/c-autocomplete_34.entry.js +23 -13
- package/dist/esm/c-autocomplete_34.entry.js.map +1 -1
- package/dist/esm/c-data-table.entry.js +1 -1
- package/dist/esm/c-menu_2.entry.js +1 -1
- package/dist/esm/c-pagination.entry.js +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-toast.entry.js +1 -1
- package/dist/esm/csc-ui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mdi-d1289d08.js → mdi-e10c3ab4.js} +2 -2
- package/dist/esm/{mdi-d1289d08.js.map → mdi-e10c3ab4.js.map} +1 -1
- package/dist/types/components/c-autocomplete/c-autocomplete.d.ts +3 -0
- package/dist/types/components/c-dropdown/c-dropdown.d.ts +1 -0
- package/dist/types/components.d.ts +24 -0
- package/package.json +1 -1
- package/vscode-data.json +12 -0
- package/dist/csc-ui/p-30edfff8.entry.js +0 -2
- package/dist/csc-ui/p-4f54f704.entry.js +0 -2
- package/dist/csc-ui/p-9bf601bb.entry.js +0 -2
- /package/dist/csc-ui/{p-d72364b9.js.map → p-1c767310.js.map} +0 -0
- /package/dist/csc-ui/{p-6733b506.entry.js.map → p-49a7a96d.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-e90ac550.entry.js.map → p-7f97a326.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-765ae162.entry.js.map → p-a7aa8fcf.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-6a54587f.entry.js.map → p-aae874cf.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-30bf678d.entry.js.map → p-c2767e00.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-dfe321ae.entry.js.map → p-e7b91787.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-7ca9b5ff.entry.js.map → p-fc47b970.entry.js.map} +0 -0
|
@@ -97,6 +97,9 @@ const CAutocomplete = class {
|
|
|
97
97
|
this.shadow = false;
|
|
98
98
|
this.returnObject = false;
|
|
99
99
|
this.itemsPerPage = 6;
|
|
100
|
+
this.minimumQueryLength = 0;
|
|
101
|
+
this.minimumQueryLengthMessage = 'Type at least {n} characters';
|
|
102
|
+
this.noMatchingItemsMessage = 'No suggestions found';
|
|
100
103
|
this.optionElements = undefined;
|
|
101
104
|
this.currentIndex = null;
|
|
102
105
|
this.dropdownVisible = false;
|
|
@@ -648,7 +651,7 @@ const CCscLogo = class {
|
|
|
648
651
|
};
|
|
649
652
|
CCscLogo.style = cCscLogoCss;
|
|
650
653
|
|
|
651
|
-
const cDropdownCss = "html{box-sizing:border-box}body{margin:0}*,*: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{
|
|
654
|
+
const cDropdownCss = "html{box-sizing:border-box}body{margin:0}*,*: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{opacity:0}: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)}}";
|
|
652
655
|
|
|
653
656
|
const CDropdown = class {
|
|
654
657
|
constructor(hostRef) {
|
|
@@ -686,7 +689,6 @@ const CDropdown = class {
|
|
|
686
689
|
this._handleOpen();
|
|
687
690
|
this.dropdownStateChange.emit(isOpen);
|
|
688
691
|
this._scrollParent = this._scrollParent || (await getScrollParent.getScrollParent(this.el));
|
|
689
|
-
this._scrollParent.style.overflow = isOpen ? 'hidden' : null;
|
|
690
692
|
}
|
|
691
693
|
handleIndexChange(index) {
|
|
692
694
|
requestAnimationFrame(() => {
|
|
@@ -710,7 +712,7 @@ const CDropdown = class {
|
|
|
710
712
|
if (this._dialog.open)
|
|
711
713
|
return;
|
|
712
714
|
this._outsideClickFn = this._handleOutsideClick.bind(this);
|
|
713
|
-
|
|
715
|
+
this._dialog.addEventListener('click', this._outsideClickFn);
|
|
714
716
|
requestAnimationFrame(() => {
|
|
715
717
|
this.isOpen = true;
|
|
716
718
|
this._positionMenu();
|
|
@@ -767,12 +769,10 @@ const CDropdown = class {
|
|
|
767
769
|
this.renderedList = this._renderList();
|
|
768
770
|
});
|
|
769
771
|
}
|
|
770
|
-
_handleOutsideClick(
|
|
772
|
+
_handleOutsideClick() {
|
|
771
773
|
if (!this.isOpen)
|
|
772
774
|
return;
|
|
773
|
-
|
|
774
|
-
this.close();
|
|
775
|
-
}
|
|
775
|
+
this.close();
|
|
776
776
|
}
|
|
777
777
|
_highlightMatchingText(value) {
|
|
778
778
|
const { query } = this.parent;
|
|
@@ -835,11 +835,18 @@ const CDropdown = class {
|
|
|
835
835
|
input.focus();
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
|
+
_minimumQueryItem() {
|
|
839
|
+
const { query, loading, minimumQueryLength, minimumQueryLengthMessage } = this.parent;
|
|
840
|
+
if (query.length > minimumQueryLength || loading)
|
|
841
|
+
return;
|
|
842
|
+
return (index.h("li", null, index.h("c-icon", { path: mdi.mdiInformation, size: 18, color: "var(--c-info-600)" }), minimumQueryLengthMessage.replace('{n}', minimumQueryLength.toString())));
|
|
843
|
+
}
|
|
838
844
|
_emptyItem() {
|
|
839
|
-
const { query, loading } = this
|
|
845
|
+
const { query, loading, noMatchingItemsMessage } = this
|
|
846
|
+
.parent;
|
|
840
847
|
if (!query || loading)
|
|
841
848
|
return;
|
|
842
|
-
return (index.h("li", null, index.h("c-icon", { path: mdi.mdiAlert, size: 18, color: "var(--c-warning-600)" }),
|
|
849
|
+
return (index.h("li", null, index.h("c-icon", { path: mdi.mdiAlert, size: 18, color: "var(--c-warning-600)" }), noMatchingItemsMessage));
|
|
843
850
|
}
|
|
844
851
|
_renderList() {
|
|
845
852
|
return this.itemType === 'option'
|
|
@@ -848,7 +855,7 @@ const CDropdown = class {
|
|
|
848
855
|
}
|
|
849
856
|
_renderOptionsList() {
|
|
850
857
|
if (!this.items.length)
|
|
851
|
-
return this._emptyItem();
|
|
858
|
+
return this._minimumQueryItem() || this._emptyItem();
|
|
852
859
|
const options = Array.from(this.items);
|
|
853
860
|
this._listItems.length = 0;
|
|
854
861
|
return options.map((option, index$1) => {
|
|
@@ -867,7 +874,7 @@ const CDropdown = class {
|
|
|
867
874
|
}
|
|
868
875
|
_renderItemsList() {
|
|
869
876
|
if (!this.items.length)
|
|
870
|
-
return this._emptyItem();
|
|
877
|
+
return this._minimumQueryItem() || this._emptyItem();
|
|
871
878
|
this._listItems.length = 0;
|
|
872
879
|
return this.items.map((item, index$1) => {
|
|
873
880
|
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) => {
|
|
@@ -915,7 +922,10 @@ const CDropdown = class {
|
|
|
915
922
|
this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';
|
|
916
923
|
this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';
|
|
917
924
|
}
|
|
918
|
-
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: {
|
|
925
|
+
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", { onClick: (event) => event.stopPropagation() }, 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: {
|
|
926
|
+
active: this._openedOnTop,
|
|
927
|
+
'input-bottom-wrapper': true,
|
|
928
|
+
} }, index.h("slot", { name: "input-bottom" }))))));
|
|
919
929
|
}
|
|
920
930
|
get el() { return index.getElement(this); }
|
|
921
931
|
static get watchers() { return {
|