@italia/popover 1.0.0-alpha.6 → 1.0.0-alpha.7

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.
@@ -54,6 +54,24 @@
54
54
  "default": "'bottom-start'",
55
55
  "attribute": "placement"
56
56
  },
57
+ {
58
+ "kind": "field",
59
+ "name": "offset",
60
+ "type": {
61
+ "text": "number"
62
+ },
63
+ "default": "12",
64
+ "attribute": "offset"
65
+ },
66
+ {
67
+ "kind": "field",
68
+ "name": "noFlip",
69
+ "type": {
70
+ "text": "boolean"
71
+ },
72
+ "default": "false",
73
+ "attribute": "no-flip"
74
+ },
57
75
  {
58
76
  "kind": "field",
59
77
  "name": "_triggerSlot",
@@ -187,6 +205,22 @@
187
205
  },
188
206
  "default": "'bottom-start'",
189
207
  "fieldName": "placement"
208
+ },
209
+ {
210
+ "name": "offset",
211
+ "type": {
212
+ "text": "number"
213
+ },
214
+ "default": "12",
215
+ "fieldName": "offset"
216
+ },
217
+ {
218
+ "name": "no-flip",
219
+ "type": {
220
+ "text": "boolean"
221
+ },
222
+ "default": "false",
223
+ "fieldName": "noFlip"
190
224
  }
191
225
  ],
192
226
  "superclass": {
@@ -223,7 +257,7 @@
223
257
  {
224
258
  "kind": "variable",
225
259
  "name": "meta",
226
- "default": "{ title: 'Componenti/Popover', component: 'it-popover', tags: ['alpha', 'web-component', 'a11y-ok'], args: { placement: 'right', }, argTypes: { placement: { control: 'select', options: [ 'top', 'right', 'bottom', 'left', 'top-start', 'top-end', 'right-start', 'right-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', ], table: { defaultValue: { summary: 'bottom-start' }, }, }, }, parameters: { layout: 'padded', }, } satisfies Meta<PopoverProps>"
260
+ "default": "{ title: 'Componenti/Popover', component: 'it-popover', tags: ['new', 'web-component', 'a11y-ok'], args: { placement: 'right', }, argTypes: { placement: { control: 'select', options: [ 'top', 'right', 'bottom', 'left', 'top-start', 'top-end', 'right-start', 'right-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', ], table: { defaultValue: { summary: 'bottom-start' }, }, }, }, parameters: { layout: 'padded', }, } satisfies Meta<PopoverProps>"
227
261
  },
228
262
  {
229
263
  "kind": "variable",
@@ -7,6 +7,8 @@ export declare class ItPopover extends BaseComponent {
7
7
  open: boolean;
8
8
  controlled: boolean;
9
9
  placement: PopoverPlacement;
10
+ offset: number;
11
+ noFlip: boolean;
10
12
  private _triggerSlot;
11
13
  private _contentSlot;
12
14
  private get _triggerElement();
@@ -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,EAAQ,MAAM,kBAAkB,CAAC;AAGjH,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;IAE1C,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;IAUpB,OAAO,CAAC,KAAK;IAuDb,OAAO,CAAC,KAAK;IAKb,OAAO,C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Y;IAInB,MAAM;CAMP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
@@ -459,6 +459,7 @@ class FormControlController {
459
459
  }
460
460
  break;
461
461
  case 'it-checkbox':
462
+ case 'it-toggle':
462
463
  if (this.host.checked) {
463
464
  if (event.formData.getAll(name).indexOf(value) < 0) {
464
465
  // handle group checkbox
@@ -467,6 +468,7 @@ class FormControlController {
467
468
  }
468
469
  break;
469
470
  case 'it-checkbox-group':
471
+ case 'it-toggle-group':
470
472
  // non settare valori in formData, perchè ogni singola checkbox setta il suo valore
471
473
  break;
472
474
  default:
@@ -1078,7 +1080,7 @@ if (typeof window !== 'undefined') {
1078
1080
  window._itAnalytics = window._itAnalytics || {};
1079
1081
  window._itAnalytics = {
1080
1082
  ...window._itAnalytics,
1081
- version: '1.0.0-alpha.6',
1083
+ version: '1.0.0-alpha.7',
1082
1084
  };
1083
1085
  }
1084
1086
 
@@ -2813,6 +2815,8 @@ let ItPopover = class ItPopover extends BaseComponent {
2813
2815
  this.open = false;
2814
2816
  this.controlled = false;
2815
2817
  this.placement = 'bottom-start';
2818
+ this.offset = 12;
2819
+ this.noFlip = false;
2816
2820
  this._onDocumentClick = (event) => {
2817
2821
  if (!this.open)
2818
2822
  return;
@@ -2913,8 +2917,8 @@ let ItPopover = class ItPopover extends BaseComponent {
2913
2917
  computePosition(this._triggerElement, this._contentElement, {
2914
2918
  placement: this.placement,
2915
2919
  middleware: [
2916
- offset(12),
2917
- flip(),
2920
+ offset(this.offset),
2921
+ flip({ mainAxis: !this.noFlip, crossAxis: !this.noFlip }),
2918
2922
  shift({ padding: 8 }),
2919
2923
  size({
2920
2924
  apply({ rects, elements }) {
@@ -2938,8 +2942,12 @@ let ItPopover = class ItPopover extends BaseComponent {
2938
2942
  bottom: 'top',
2939
2943
  left: 'right',
2940
2944
  }[placement.split('-')[0]];
2945
+ const triggerRect = this._triggerElement.getBoundingClientRect();
2946
+ const contentRect = this._contentElement.getBoundingClientRect();
2947
+ const triggerCenter = triggerRect.left + triggerRect.width / 2;
2948
+ const arrowLeft = triggerCenter - contentRect.left - this._triggerElement.offsetWidth / 2 + 20;
2941
2949
  Object.assign(this._arrowElement.style, {
2942
- left: arrowX != null ? '20px' : '',
2950
+ left: arrowX != null ? `${arrowLeft}px` : '',
2943
2951
  top: arrowY != null ? `${arrowY}px` : '',
2944
2952
  right: '',
2945
2953
  bottom: '',
@@ -2988,6 +2996,14 @@ __decorate([
2988
2996
  property({ type: String }),
2989
2997
  __metadata("design:type", String)
2990
2998
  ], ItPopover.prototype, "placement", void 0);
2999
+ __decorate([
3000
+ property({ type: Number }),
3001
+ __metadata("design:type", Number)
3002
+ ], ItPopover.prototype, "offset", void 0);
3003
+ __decorate([
3004
+ property({ type: Boolean, attribute: 'no-flip' }),
3005
+ __metadata("design:type", Boolean)
3006
+ ], ItPopover.prototype, "noFlip", void 0);
2991
3007
  __decorate([
2992
3008
  query('slot[name="trigger"]'),
2993
3009
  __metadata("design:type", HTMLSlotElement)