@usecapsule/core-components 3.6.0-dev.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16581,7 +16581,7 @@ const CpslPill = class {
16581
16581
  };
16582
16582
  CpslPill.style = CpslPillStyle0;
16583
16583
 
16584
- const cpslPopoverCss = ":host{position:fixed;display:block;z-index:-1;overflow:auto}:host(.open){z-index:10006}.container{visibility:hidden;height:0px}.open{visibility:visible;height:auto;z-index:10006}:host(.transform-h-left){transform:translateX(0)}:host(.transform-h-center){transform:translateX(-50%)}:host(.transform-h-right){transform:translateX(-100%)}:host(.transform-v-top){transform:translateY(0)}:host(.transform-v-center){transform:translateY(-50%)}:host(.transform-v-bottom){transform:translateY(-100%)}";
16584
+ const cpslPopoverCss = ":host{position:fixed;display:block;z-index:-1;overflow:auto;transform:var(--th, ) var(--tv, )}:host(.open){z-index:10006}.container{visibility:hidden;height:0px}.open{visibility:visible;height:auto;z-index:10006}:host(.transform-h-left){--th:translateX(0)}:host(.transform-h-center){--th:translateX(-50%)}:host(.transform-h-right){--th:translateX(-100%)}:host(.transform-v-top){--tv:translateY(0)}:host(.transform-v-center){--tv:translateY(-50%)}:host(.transform-v-bottom){--tv:translateY(-100%)}";
16585
16585
  const CpslPopoverStyle0 = cpslPopoverCss;
16586
16586
 
16587
16587
  var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -16608,7 +16608,8 @@ const CpslPopover = class {
16608
16608
  index.registerInstance(this, hostRef);
16609
16609
  this.cpslOpen = index.createEvent(this, "cpslOpen", 7);
16610
16610
  this.cpslClose = index.createEvent(this, "cpslClose", 7);
16611
- this.triggerClicked = false;
16611
+ this.startedInside = false;
16612
+ this.startedWhenMounted = false;
16612
16613
  this.configureTriggerInteraction = () => {
16613
16614
  const { trigger, triggerAction, destroyTriggerInteraction } = this;
16614
16615
  if (destroyTriggerInteraction) {
@@ -16668,6 +16669,15 @@ const CpslPopover = class {
16668
16669
  this.present();
16669
16670
  },
16670
16671
  },
16672
+ {
16673
+ eventName: 'touchstart',
16674
+ callback: e => {
16675
+ if (this.preventBlur) {
16676
+ e.preventDefault();
16677
+ }
16678
+ this.present();
16679
+ },
16680
+ },
16671
16681
  ];
16672
16682
  break;
16673
16683
  }
@@ -16727,12 +16737,19 @@ const CpslPopover = class {
16727
16737
  }
16728
16738
  }
16729
16739
  };
16740
+ this.validateEventStart = event => {
16741
+ this.startedWhenMounted = !!this.triggerEl;
16742
+ this.startedInside = this.triggerEl.contains(event.target);
16743
+ this.present();
16744
+ };
16730
16745
  this.handleClickOutside = (event) => {
16731
- if (!this.triggerClicked && this.triggerEl.contains(event.target)) {
16732
- this.triggerClicked = true;
16746
+ // Do nothing if `mousedown` or `touchstart` started inside ref element
16747
+ if (this.startedInside || !this.startedWhenMounted)
16733
16748
  return;
16734
- }
16735
- if (this.open && !this.el.contains(event.target)) {
16749
+ // Do nothing if clicking ref's element or descendent elements
16750
+ if (!this.triggerEl || this.triggerEl.contains(event.target))
16751
+ return;
16752
+ if (this.open) {
16736
16753
  event.preventDefault();
16737
16754
  this.close();
16738
16755
  }
@@ -16749,7 +16766,7 @@ const CpslPopover = class {
16749
16766
  };
16750
16767
  this.close = () => {
16751
16768
  this.open = false;
16752
- this.triggerClicked = false;
16769
+ this.startedInside = false;
16753
16770
  this.cpslClose.emit();
16754
16771
  };
16755
16772
  this.open = false;
@@ -16783,11 +16800,15 @@ const CpslPopover = class {
16783
16800
  }
16784
16801
  onOpenChange() {
16785
16802
  if (this.open) {
16803
+ window.addEventListener('mousedown', this.validateEventStart);
16804
+ window.addEventListener('touchstart', this.validateEventStart);
16786
16805
  window.addEventListener('click', this.handleClickOutside);
16787
16806
  window.addEventListener('scroll', () => this.setPosition(), true);
16788
16807
  window.addEventListener('resize', () => this.setPosition(), true);
16789
16808
  }
16790
16809
  else {
16810
+ window.removeEventListener('mousedown', this.validateEventStart);
16811
+ window.removeEventListener('touchstart', this.validateEventStart);
16791
16812
  window.removeEventListener('click', this.handleClickOutside);
16792
16813
  window.removeEventListener('scroll', () => this.setPosition(), true);
16793
16814
  window.removeEventListener('resize', () => this.setPosition(), true);
@@ -16802,7 +16823,7 @@ const CpslPopover = class {
16802
16823
  }
16803
16824
  render() {
16804
16825
  var _a;
16805
- return (index.h(index.Host, { key: '6128da20f003b95925bf27a6d30dfd402bcc9e82', class: {
16826
+ return (index.h(index.Host, { key: '18d133c7b3b9130f4119aa1502fc22a0edba0adf', class: {
16806
16827
  'open': this.open,
16807
16828
  'transform-h-left': this.transformOriginHorizontal === 'left',
16808
16829
  'transform-h-center': this.transformOriginHorizontal === 'center',
@@ -16810,7 +16831,7 @@ const CpslPopover = class {
16810
16831
  'transform-v-top': this.transformOriginVertical === 'top',
16811
16832
  'transform-v-center': this.transformOriginVertical === 'center',
16812
16833
  'transform-v-bottom': this.transformOriginVertical === 'bottom',
16813
- }, style: { top: `${this.positionY}px`, left: `${this.positionX}px`, width: !this.open ? '0px' : this.autoWidth ? 'auto' : `${(_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.clientWidth}px` } }, index.h("div", { key: '8245c2e3184150d41de74d203f548c71578e7c5e', id: "container", class: { container: true, open: this.open } }, index.h("slot", { key: 'b5900e3d8b1f80e604e7c7eb63ec9a345ffe2f31' }))));
16834
+ }, style: { top: `${this.positionY}px`, left: `${this.positionX}px`, width: !this.open ? '0px' : this.autoWidth ? 'auto' : `${(_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.clientWidth}px` } }, index.h("div", { key: '0c86d612a066ac39a37c0291ab96e518f6e2cd32', id: "container", class: { container: true, open: this.open } }, index.h("slot", { key: '616112bb261563452b94256d3f7a8ed563e1cf65' }))));
16814
16835
  }
16815
16836
  get el() { return index.getElement(this); }
16816
16837
  static get watchers() { return {
@@ -21077,10 +21098,10 @@ const CpslSelect = class {
21077
21098
  }
21078
21099
  render() {
21079
21100
  var _a, _b, _c, _d, _e;
21080
- return (index.h(index.Host, { key: '07196d4cfb2df16bc25e70eca2e70c075ec192d9', id: this.id, class: { 'disabled': this.disabled, 'focused': this.hasFocus, 'has-value': Boolean(this.selectedValue) } }, this.label && (index.h("label", { key: '0d5f157c22dcbe6cb804f95c86fccf09be5f2db1', class: "label", htmlFor: this.inputId }, this.label, this.required ? '*' : ' ', !this.required && this.showOptionalLabel ? index.h("span", { class: "optional-label" }, "(optional)") : '')), index.h("div", { key: 'f1717a5a7acf3834b1fabbe960c0951a8bef0156', part: "select-container", id: "select-container", class: { 'select-container': true, 'error-container': Boolean(this.errorText) }, onMouseDown: this.handleClick }, this.hasSelectedItem && this.showFormattedSelectedItem && index.h("slot", { key: 'c4031550e20504d14d091a36af499e09f948399c', name: "selected-item" }), index.h("div", { key: 'f46cdd6d89995c29730c5143b8b094a551db095e', class: { 'selected-container-content': true, 'hidden': this.hasSelectedItem && this.showFormattedSelectedItem }, id: "selected-container-content", style: {} }, (!this.hasSelectedItem || !this.showFormattedSelectedItem) && (index.h("cpsl-text", { key: 'cfa104452575ee2075436fbd2d03e4ec8b7744ea', class: { 'selected-text': true, 'placeholder': !this.selectedValue } }, !this.selectedValue ? ((_a = this.placeholder) !== null && _a !== void 0 ? _a : 'Select') : ((_c = (_b = this.formatValue) === null || _b === void 0 ? void 0 : _b.call(this, this.selectedValue)) !== null && _c !== void 0 ? _c : this.selectedValue)))), index.h("cpsl-icon", { key: '3f573b3bd0d083e36a32661bfbefdeebf0c1c1e3', part: "icon", class: { 'chevron': true, 'open': !this.noIconAnimation && this.popoverOpen, 'has-value': Boolean(this.selectedValue) }, icon: this.icon }), index.h("input", { key: 'c8160d5dd425d1d34420699040226d7a5fa96788', id: this.inputId, disabled: this.disabled, class: { disabled: this.disabled }, value: this.selectedValue, onFocus: this.onFocus, onBlur: this.onBlur, onKeyPress: this.handleEnterPress, inputmode: "none" })), (this.errorText || this.helperText) && (index.h("div", { key: '02089e440f2547e82ec5348480def12b92a24e04', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, index.h("span", { key: '7190858324cf9b375c909c7271e23578e0d5b939' }, (_d = this.errorText) !== null && _d !== void 0 ? _d : this.helperText))), index.h("cpsl-popover", { key: 'b82c8894e19f651952815626647808989ad5d18e', part: "popover", autoWidth: this.autoWidth, trigger: this.id, preventBlur: this.hasFocus, disabled: this.disabled, anchorEl: this.anchorEl }, index.h("div", { key: '0db22395753a0b9fe95b56138ca2d56bcbfd0b66', part: "dropdown", class: "dropdown" }, this.showSearch && (index.h("div", { key: '18a6ea58a3043f3e836aa5a567148c5a3a62806d', class: "search-container" }, index.h("cpsl-input", { key: 'f6ad7bef0382ce98cd09deb6cbca183dba26490d', onClick: e => e.stopPropagation(), placeholder: (_e = this.searchPlaceholder) !== null && _e !== void 0 ? _e : 'Search', value: "", onCpslInput: e => {
21101
+ return (index.h(index.Host, { key: '07196d4cfb2df16bc25e70eca2e70c075ec192d9', id: this.id, class: { 'disabled': this.disabled, 'focused': this.hasFocus, 'has-value': Boolean(this.selectedValue) } }, this.label && (index.h("label", { key: '0d5f157c22dcbe6cb804f95c86fccf09be5f2db1', class: "label", htmlFor: this.inputId }, this.label, this.required ? '*' : ' ', !this.required && this.showOptionalLabel ? index.h("span", { class: "optional-label" }, "(optional)") : '')), index.h("div", { key: 'f1717a5a7acf3834b1fabbe960c0951a8bef0156', part: "select-container", id: "select-container", class: { 'select-container': true, 'error-container': Boolean(this.errorText) }, onMouseDown: this.handleClick }, this.hasSelectedItem && this.showFormattedSelectedItem && index.h("slot", { key: 'c4031550e20504d14d091a36af499e09f948399c', name: "selected-item" }), index.h("div", { key: 'f46cdd6d89995c29730c5143b8b094a551db095e', class: { 'selected-container-content': true, 'hidden': this.hasSelectedItem && this.showFormattedSelectedItem }, id: "selected-container-content", style: {} }, (!this.hasSelectedItem || !this.showFormattedSelectedItem) && (index.h("cpsl-text", { key: 'cfa104452575ee2075436fbd2d03e4ec8b7744ea', class: { 'selected-text': true, 'placeholder': !this.selectedValue } }, !this.selectedValue ? ((_a = this.placeholder) !== null && _a !== void 0 ? _a : 'Select') : ((_c = (_b = this.formatValue) === null || _b === void 0 ? void 0 : _b.call(this, this.selectedValue)) !== null && _c !== void 0 ? _c : this.selectedValue)))), index.h("cpsl-icon", { key: '3f573b3bd0d083e36a32661bfbefdeebf0c1c1e3', part: "icon", class: { 'chevron': true, 'open': !this.noIconAnimation && this.popoverOpen, 'has-value': Boolean(this.selectedValue) }, icon: this.icon }), index.h("input", { key: 'c8160d5dd425d1d34420699040226d7a5fa96788', id: this.inputId, disabled: this.disabled, class: { disabled: this.disabled }, value: this.selectedValue, onFocus: this.onFocus, onBlur: this.onBlur, onKeyPress: this.handleEnterPress, inputmode: "none" }), index.h("cpsl-popover", { key: '67c237d3559c8b1c87668017adb494394f8892f7', part: "popover", autoWidth: this.autoWidth, trigger: this.id, preventBlur: this.hasFocus, disabled: this.disabled, anchorEl: this.anchorEl }, index.h("div", { key: 'e7d06e0286caba81b827880f93b9f3fd0562c920', part: "dropdown", class: "dropdown" }, this.showSearch && (index.h("div", { key: '6b90fb7f145061e255b7a5fefe9135939da451cd', class: "search-container" }, index.h("cpsl-input", { key: 'de22c0f8e4e54b53ba2d01735d9f3b5b701de49e', onClick: e => e.stopPropagation(), placeholder: (_d = this.searchPlaceholder) !== null && _d !== void 0 ? _d : 'Search', value: "", onCpslInput: e => {
21081
21102
  e.stopPropagation();
21082
21103
  this.cpslSearchChange.emit(e.detail.value);
21083
- } }))), index.h("div", { key: '124c5c09b116c513053dff8e6159272d7063fee5', class: "dropdown-inner", style: { maxHeight: `${this.dropdownMaxHeight}px` } }, index.h("slot", { key: '1944f3fd800325225bb7f48a609f8c85dba4db6a', name: "items" }))))));
21104
+ } }))), index.h("div", { key: '53640295e97e86c68978cb5269c13a2f87a89bd0', class: "dropdown-inner", style: { maxHeight: `${this.dropdownMaxHeight}px` } }, index.h("slot", { key: 'e338a82fe28a6e9cfc035f238964252652aae6e0', name: "items" }))))), (this.errorText || this.helperText) && (index.h("div", { key: '9dc72e327dda99f54959ea6656c5eb23d3f38b51', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, index.h("span", { key: '19e164fa3fa038f6423d98b79d161c6161bc7160' }, (_e = this.errorText) !== null && _e !== void 0 ? _e : this.helperText)))));
21084
21105
  }
21085
21106
  get el() { return index.getElement(this); }
21086
21107
  static get watchers() { return {