@cscfi/csc-ui 1.3.0 → 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.
Files changed (61) hide show
  1. package/dist/cjs/c-autocomplete_34.cjs.entry.js +32 -13
  2. package/dist/cjs/c-autocomplete_34.cjs.entry.js.map +1 -1
  3. package/dist/cjs/csc-ui.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/collection/components/c-autocomplete/c-autocomplete.js +57 -0
  6. package/dist/collection/components/c-autocomplete/c-autocomplete.js.map +1 -1
  7. package/dist/collection/components/c-dropdown/c-dropdown.css +1 -1
  8. package/dist/collection/components/c-dropdown/c-dropdown.js +29 -13
  9. package/dist/collection/components/c-dropdown/c-dropdown.js.map +1 -1
  10. package/dist/components/c-autocomplete.js +6 -0
  11. package/dist/components/c-autocomplete.js.map +1 -1
  12. package/dist/components/c-dropdown2.js +30 -14
  13. package/dist/components/c-dropdown2.js.map +1 -1
  14. package/dist/csc-ui/csc-ui.esm.js +1 -1
  15. package/dist/csc-ui/csc-ui.esm.js.map +1 -1
  16. package/dist/csc-ui/{p-d72364b9.js → p-1c767310.js} +2 -2
  17. package/dist/csc-ui/{p-6733b506.entry.js → p-49a7a96d.entry.js} +2 -2
  18. package/dist/csc-ui/p-6a6a89ef.entry.js +2 -0
  19. package/dist/csc-ui/{p-30edfff8.entry.js.map → p-6a6a89ef.entry.js.map} +1 -1
  20. package/dist/csc-ui/{p-e90ac550.entry.js → p-7f97a326.entry.js} +2 -2
  21. package/dist/csc-ui/{p-765ae162.entry.js → p-a7aa8fcf.entry.js} +2 -2
  22. package/dist/csc-ui/{p-6a54587f.entry.js → p-aae874cf.entry.js} +2 -2
  23. package/dist/csc-ui/{p-30bf678d.entry.js → p-c2767e00.entry.js} +2 -2
  24. package/dist/csc-ui/p-ddff8326.entry.js +2 -0
  25. package/dist/csc-ui/{p-9bf601bb.entry.js.map → p-ddff8326.entry.js.map} +1 -1
  26. package/dist/csc-ui/p-df913633.entry.js +2 -0
  27. package/dist/csc-ui/p-df913633.entry.js.map +1 -0
  28. package/dist/csc-ui/{p-dfe321ae.entry.js → p-e7b91787.entry.js} +2 -2
  29. package/dist/csc-ui/{p-7ca9b5ff.entry.js → p-fc47b970.entry.js} +2 -2
  30. package/dist/esm/c-accordion-item.entry.js +1 -1
  31. package/dist/esm/c-alert.entry.js +1 -1
  32. package/dist/esm/c-autocomplete_34.entry.js +33 -14
  33. package/dist/esm/c-autocomplete_34.entry.js.map +1 -1
  34. package/dist/esm/c-data-table.entry.js +1 -1
  35. package/dist/esm/c-menu_2.entry.js +1 -1
  36. package/dist/esm/c-pagination.entry.js +1 -1
  37. package/dist/esm/c-swiper.entry.js +1 -1
  38. package/dist/esm/c-tabs.entry.js +1 -1
  39. package/dist/esm/c-tag.entry.js +1 -1
  40. package/dist/esm/c-toast.entry.js +1 -1
  41. package/dist/esm/csc-ui.js +1 -1
  42. package/dist/esm/loader.js +1 -1
  43. package/dist/esm/{mdi-d1289d08.js → mdi-e10c3ab4.js} +2 -2
  44. package/dist/esm/{mdi-d1289d08.js.map → mdi-e10c3ab4.js.map} +1 -1
  45. package/dist/types/components/c-autocomplete/c-autocomplete.d.ts +3 -0
  46. package/dist/types/components/c-dropdown/c-dropdown.d.ts +3 -0
  47. package/dist/types/components.d.ts +24 -0
  48. package/package.json +1 -1
  49. package/vscode-data.json +12 -0
  50. package/dist/csc-ui/p-30edfff8.entry.js +0 -2
  51. package/dist/csc-ui/p-48a5469a.entry.js +0 -2
  52. package/dist/csc-ui/p-48a5469a.entry.js.map +0 -1
  53. package/dist/csc-ui/p-9bf601bb.entry.js +0 -2
  54. /package/dist/csc-ui/{p-d72364b9.js.map → p-1c767310.js.map} +0 -0
  55. /package/dist/csc-ui/{p-6733b506.entry.js.map → p-49a7a96d.entry.js.map} +0 -0
  56. /package/dist/csc-ui/{p-e90ac550.entry.js.map → p-7f97a326.entry.js.map} +0 -0
  57. /package/dist/csc-ui/{p-765ae162.entry.js.map → p-a7aa8fcf.entry.js.map} +0 -0
  58. /package/dist/csc-ui/{p-6a54587f.entry.js.map → p-aae874cf.entry.js.map} +0 -0
  59. /package/dist/csc-ui/{p-30bf678d.entry.js.map → p-c2767e00.entry.js.map} +0 -0
  60. /package/dist/csc-ui/{p-dfe321ae.entry.js.map → p-e7b91787.entry.js.map} +0 -0
  61. /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{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)}}";
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) {
@@ -658,6 +661,7 @@ const CDropdown = class {
658
661
  this._debounce = null;
659
662
  this._isMobile = false;
660
663
  this._listItems = [];
664
+ this._isOpening = false;
661
665
  this._inputSize = {
662
666
  height: 0,
663
667
  width: 0,
@@ -681,9 +685,10 @@ const CDropdown = class {
681
685
  });
682
686
  }
683
687
  async stateWatcher(isOpen) {
688
+ if (isOpen)
689
+ this._handleOpen();
684
690
  this.dropdownStateChange.emit(isOpen);
685
691
  this._scrollParent = this._scrollParent || (await getScrollParent.getScrollParent(this.el));
686
- this._scrollParent.style.overflow = isOpen ? 'hidden' : null;
687
692
  }
688
693
  handleIndexChange(index) {
689
694
  requestAnimationFrame(() => {
@@ -707,7 +712,7 @@ const CDropdown = class {
707
712
  if (this._dialog.open)
708
713
  return;
709
714
  this._outsideClickFn = this._handleOutsideClick.bind(this);
710
- window.addEventListener('click', this._outsideClickFn);
715
+ this._dialog.addEventListener('click', this._outsideClickFn);
711
716
  requestAnimationFrame(() => {
712
717
  this.isOpen = true;
713
718
  this._positionMenu();
@@ -726,6 +731,12 @@ const CDropdown = class {
726
731
  _setIsMobile() {
727
732
  this._isMobile = window.matchMedia('only screen and (max-width: 760px)').matches;
728
733
  }
734
+ _handleOpen() {
735
+ this._isOpening = true;
736
+ setTimeout(() => {
737
+ this._isOpening = false;
738
+ }, 500);
739
+ }
729
740
  componentDidLoad() {
730
741
  this._setIsMobile();
731
742
  this._hideDetails = this.parent.hideDetails;
@@ -734,7 +745,7 @@ const CDropdown = class {
734
745
  if (!this._dialog.open)
735
746
  return;
736
747
  requestAnimationFrame(() => {
737
- if (!Array.isArray(entries) || !entries.length)
748
+ if (!Array.isArray(entries) || !entries.length || this._isOpening)
738
749
  return;
739
750
  this._setIsMobile();
740
751
  this.close();
@@ -758,12 +769,10 @@ const CDropdown = class {
758
769
  this.renderedList = this._renderList();
759
770
  });
760
771
  }
761
- _handleOutsideClick(event) {
772
+ _handleOutsideClick() {
762
773
  if (!this.isOpen)
763
774
  return;
764
- if (!event.composedPath().includes(this._dialog)) {
765
- this.close();
766
- }
775
+ this.close();
767
776
  }
768
777
  _highlightMatchingText(value) {
769
778
  const { query } = this.parent;
@@ -826,11 +835,18 @@ const CDropdown = class {
826
835
  input.focus();
827
836
  });
828
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
+ }
829
844
  _emptyItem() {
830
- const { query, loading } = this.parent;
845
+ const { query, loading, noMatchingItemsMessage } = this
846
+ .parent;
831
847
  if (!query || loading)
832
848
  return;
833
- return (index.h("li", null, index.h("c-icon", { path: mdi.mdiAlert, size: 18, color: "var(--c-warning-600)" }), "No suggestions found"));
849
+ return (index.h("li", null, index.h("c-icon", { path: mdi.mdiAlert, size: 18, color: "var(--c-warning-600)" }), noMatchingItemsMessage));
834
850
  }
835
851
  _renderList() {
836
852
  return this.itemType === 'option'
@@ -839,7 +855,7 @@ const CDropdown = class {
839
855
  }
840
856
  _renderOptionsList() {
841
857
  if (!this.items.length)
842
- return this._emptyItem();
858
+ return this._minimumQueryItem() || this._emptyItem();
843
859
  const options = Array.from(this.items);
844
860
  this._listItems.length = 0;
845
861
  return options.map((option, index$1) => {
@@ -858,7 +874,7 @@ const CDropdown = class {
858
874
  }
859
875
  _renderItemsList() {
860
876
  if (!this.items.length)
861
- return this._emptyItem();
877
+ return this._minimumQueryItem() || this._emptyItem();
862
878
  this._listItems.length = 0;
863
879
  return this.items.map((item, index$1) => {
864
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) => {
@@ -906,7 +922,10 @@ const CDropdown = class {
906
922
  this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';
907
923
  this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';
908
924
  }
909
- 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" })))));
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" }))))));
910
929
  }
911
930
  get el() { return index.getElement(this); }
912
931
  static get watchers() { return {