@italia/popover 1.0.0-beta.3 → 1.0.0-beta.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"it-popover.d.ts","sourceRoot":"","sources":["../../src/it-popover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,EAA2D,KAAK,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAGxH,KAAK,gBAAgB,GAAG,SAAS,CAAC;AAElC,qBACa,SAAU,SAAQ,aAAa;IAC1C,MAAM,CAAC,MAAM,+BAAU;IAEqB,IAAI,UAAS;IAE5B,UAAU,UAAS;IAEpB,SAAS,EAAE,gBAAgB,CAAkB;IAE7C,MAAM,EAAE,MAAM,CAAM;IAEY,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,MAAM,EAAE,OAAO,CAAS;IAE3E,qGAAqG;IAC7C,WAAW,EAAE,OAAO,CAAS;IAEtD,OAAO,CAAC,YAAY,CAAmB;IAEvC,OAAO,CAAC,YAAY,CAAmB;IAEtE,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,CAAC,aAAa,CAAC,CAAc;IAEpC,OAAO,CAAC,QAAQ,CAAC,CAAa;IAE9B,OAAO,CAAC,sBAAsB;IAwB9B,SAAS,CAAC,mBAAmB;IAoB7B,oBAAoB;IAMpB,SAAS,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAKhE,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAatC,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,KAAK;IA0Eb,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,aAAa;IAId,M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;IAId,MAAM;IAIN,WAAW;IAIX,YAAY;IAInB,MAAM;CAMP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
@@ -1176,7 +1176,7 @@ if (typeof window !== 'undefined') {
1176
1176
  window._itAnalytics = window._itAnalytics || {};
1177
1177
  window._itAnalytics = {
1178
1178
  ...window._itAnalytics,
1179
- version: '1.0.0-beta.3',
1179
+ version: '1.0.0-beta.5',
1180
1180
  };
1181
1181
  }
1182
1182
 
@@ -2806,8 +2806,17 @@ const computePosition = (reference, floating, options) => {
2806
2806
 
2807
2807
  var styles = css`:host {
2808
2808
  --bsi-dropdown-background: var(--bsi-color-background-inverse);
2809
+ --bsi-popover-notch-offset: -8px;
2809
2810
  }`;
2810
2811
 
2812
+ // Design-system default for --bsi-popover-notch-size (1.125rem @ 16px root
2813
+ // font-size) and for --bsi-popover-notch-offset (see :host in
2814
+ // it-popover.scss). There's no way to query a custom property's "default"
2815
+ // at runtime, only its current value, so these are the reference baseline
2816
+ // the compensation math is measured against — kept in sync by hand with
2817
+ // the :host defaults.
2818
+ const DEFAULT_NOTCH_SIZE_PX = 18;
2819
+ const DEFAULT_NOTCH_OFFSET_PX = -8;
2811
2820
  let ItPopover = class ItPopover extends BaseComponent {
2812
2821
  constructor() {
2813
2822
  super(...arguments);
@@ -2943,12 +2952,13 @@ let ItPopover = class ItPopover extends BaseComponent {
2943
2952
  if (middlewareData.arrow) {
2944
2953
  const { x: arrowX, y: arrowY } = middlewareData.arrow;
2945
2954
  const placementSide = placement.split('-')[0];
2946
- const staticSide = {
2955
+ const staticSide = ({
2947
2956
  top: 'bottom',
2948
2957
  right: 'left',
2949
2958
  bottom: 'top',
2950
2959
  left: 'right',
2951
- }[placementSide];
2960
+ }[placementSide] ?? 'top');
2961
+ this._arrowElement.dataset.side = placementSide;
2952
2962
  const triggerRect = this._triggerElement.getBoundingClientRect();
2953
2963
  const contentRect = this._contentElement.getBoundingClientRect();
2954
2964
  const triggerCenter = triggerRect.left + triggerRect.width / 2;
@@ -2959,12 +2969,28 @@ let ItPopover = class ItPopover extends BaseComponent {
2959
2969
  const left = this.centerArrow ? arrowX : arrowLeft + (this.crossAxisOffset ?? 0);
2960
2970
  const isLeftOrRight = ['left', 'right'].includes(placementSide);
2961
2971
  const additionalOffsetTop = isLeftOrRight ? (this.crossAxisOffset ?? 0) : 0;
2972
+ // The arrow's border (if any) is set by the consumer's CSS keyed off
2973
+ // data-side, above; its size comes from whatever notch-size token the
2974
+ // consumer uses (dropdown/megamenu each have their own). Compensate
2975
+ // --bsi-popover-notch-offset — the arrow's own default distance from
2976
+ // the panel edge — for that border width and for the notch size
2977
+ // deviating from its 1.125rem (18px) default, so the point stays
2978
+ // flush against the panel edge whatever those consumer tokens end up
2979
+ // set to.
2980
+ const notchOffsetDefault = parseFloat(getComputedStyle(this._arrowElement).getPropertyValue('--bsi-popover-notch-offset')) ||
2981
+ DEFAULT_NOTCH_OFFSET_PX;
2982
+ const arrowComputedStyle = getComputedStyle(this._arrowElement);
2983
+ const borderProp = `border${staticSide[0].toUpperCase()}${staticSide.slice(1)}Width`;
2984
+ const staticSideBorderWidth = parseFloat(arrowComputedStyle[borderProp]) || 0;
2985
+ const notchSize = parseFloat(arrowComputedStyle.width) || DEFAULT_NOTCH_SIZE_PX;
2986
+ const notchSizeCompensation = (notchSize - DEFAULT_NOTCH_SIZE_PX) / 2;
2987
+ const staticSideOffset = notchOffsetDefault - staticSideBorderWidth - notchSizeCompensation;
2962
2988
  Object.assign(this._arrowElement.style, {
2963
2989
  left: arrowX != null ? `${left}px` : '',
2964
2990
  top: arrowY != null ? `${arrowY + additionalOffsetTop}px` : '',
2965
2991
  right: '',
2966
2992
  bottom: '',
2967
- [staticSide]: `-8px`,
2993
+ [staticSide]: `${staticSideOffset}px`,
2968
2994
  position: 'absolute',
2969
2995
  transform: 'rotate(45deg)',
2970
2996
  });