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

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/README.md CHANGED
@@ -1,19 +1,67 @@
1
- # Popover Web Component
1
+ # \<it-popover>
2
2
 
3
- Questo package contiene il web component `<it-popover>`, conforme agli standard del progetto e con stili Bootstrap Italia.
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
4
 
5
- ## Utilizzo
5
+ ## Installation
6
6
 
7
+ ```bash
8
+ npm i @italia/popover
7
9
  ```
8
10
 
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@italia/popover';
16
+ </script>
17
+
18
+ <it-popover></it-popover>
19
+ ```
20
+
21
+ ## Linting and formatting
22
+
23
+ To scan the project for linting and formatting errors, run
24
+
25
+ ```bash
26
+ npm run lint
27
+ ```
28
+
29
+ To automatically fix linting and formatting errors, run
30
+
31
+ ```bash
32
+ npm run format
33
+ ```
34
+
35
+ ## Testing with Web Test Runner
36
+
37
+ To execute a single test run:
38
+
39
+ ```bash
40
+ npm run test
41
+ ```
42
+
43
+ To run the tests in interactive watch mode run:
44
+
45
+ ```bash
46
+ npm run test:watch
9
47
  ```
10
48
 
11
- ## Sviluppo
49
+ ## Demoing with Storybook
50
+
51
+ To run a local instance of Storybook for your component, run
52
+
53
+ ```bash
54
+ npm run storybook
55
+ ```
56
+
57
+ To build a production version of Storybook, run
58
+
59
+ ```bash
60
+ npm run storybook:build
61
+ ```
12
62
 
13
- - Stili: solo SCSS, no CSS inline
14
- - Test: web-test-runner
15
- - Storie: Storybook
63
+ ## Tooling configs
16
64
 
17
- ## License
65
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
18
66
 
19
- Vedi LICENSE.
67
+ If you customize the configuration a lot, you can consider moving them to individual files.
@@ -36,6 +36,15 @@
36
36
  "attribute": "open",
37
37
  "reflects": true
38
38
  },
39
+ {
40
+ "kind": "field",
41
+ "name": "controlled",
42
+ "type": {
43
+ "text": "boolean"
44
+ },
45
+ "default": "false",
46
+ "attribute": "controlled"
47
+ },
39
48
  {
40
49
  "kind": "field",
41
50
  "name": "placement",
@@ -94,6 +103,11 @@
94
103
  "name": "_setChildrenProperties",
95
104
  "privacy": "private"
96
105
  },
106
+ {
107
+ "kind": "method",
108
+ "name": "setupStandardEvents",
109
+ "privacy": "protected"
110
+ },
97
111
  {
98
112
  "kind": "method",
99
113
  "name": "_createArrow",
@@ -158,6 +172,14 @@
158
172
  "default": "false",
159
173
  "fieldName": "open"
160
174
  },
175
+ {
176
+ "name": "controlled",
177
+ "type": {
178
+ "text": "boolean"
179
+ },
180
+ "default": "false",
181
+ "fieldName": "controlled"
182
+ },
161
183
  {
162
184
  "name": "placement",
163
185
  "type": {
@@ -193,6 +215,139 @@
193
215
  }
194
216
  }
195
217
  ]
218
+ },
219
+ {
220
+ "kind": "javascript-module",
221
+ "path": "stories/it-popover.stories.ts",
222
+ "declarations": [
223
+ {
224
+ "kind": "variable",
225
+ "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>"
227
+ },
228
+ {
229
+ "kind": "variable",
230
+ "name": "Base",
231
+ "type": {
232
+ "text": "Story"
233
+ },
234
+ "default": "{ ...meta, render: (args) => html` <it-popover placement=${ifDefined(args.placement)}> <it-button slot=\"trigger\" variant=\"primary\"> Opzioni utente, clicca per aprire </it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> `, tags: ['!autodocs', '!dev'], }"
235
+ },
236
+ {
237
+ "kind": "variable",
238
+ "name": "Posizione",
239
+ "type": {
240
+ "text": "Story"
241
+ },
242
+ "default": "{ ...meta, render: () => html` <it-popover placement=\"bottom-start\" style=\"grid-column:2\"> <it-button slot=\"trigger\" variant=\"primary\">Giù</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> <it-popover placement=\"top-start\" style=\"grid-row:3;grid-column:2\"> <it-button slot=\"trigger\" variant=\"primary\">Su</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> <it-popover placement=\"left\" style=\"grid-row:2;grid-column:3\"> <it-button slot=\"trigger\" variant=\"primary\">Sinistra</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> <it-popover placement=\"right\" style=\"grid-row:2;grid-column:1\"> <it-button slot=\"trigger\" variant=\"primary\">Destra</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> `, decorators: [(Story) => html`<div style=\"display:grid;gap:.5rem;grid:1fr 1fr 1fr/1fr 1fr 1fr;\">${Story()}</div>`], argTypes: { ...disabledControls() }, }"
243
+ },
244
+ {
245
+ "kind": "variable",
246
+ "name": "ConIconaELink",
247
+ "type": {
248
+ "text": "Story"
249
+ },
250
+ "default": "{ ...meta, name: 'Titolo con icona e link', render: () => { const handleLinkClick = (e: Event) => { e.preventDefault(); }; return html` <it-popover> <it-button slot=\"trigger\" variant=\"primary\"> Popover con icona e link </it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\"> <it-icon name=\"it-help-circle\" size=\"sm\"></it-icon> Titolo con icona </h4> <div class=\"popover-body\"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue. <a href=\"#\" class=\"popover-inner-link\" @click=${handleLinkClick}> Leggi tutto <it-icon name=\"it-arrow-right\" size=\"xs\" color=\"primary\"></it-icon> </a> </div> </div> </it-popover> `; }, decorators: [(Story) => html`<div style=\"height:200px\">${Story()}</div>`], argTypes: { ...disabledControls() }, }"
251
+ },
252
+ {
253
+ "kind": "variable",
254
+ "name": "ElementiDisabilitati",
255
+ "type": {
256
+ "text": "Story"
257
+ },
258
+ "default": "{ ...meta, name: 'Elementi disabilitati', render: () => html` <it-popover placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\" disabled> Pulsante disabilitato, il popover non si apre </it-button> <div slot=\"content\" class=\"popover\"> <div class=\"popover-body\">Popover disabilitato</div> </div> </it-popover> `, argTypes: { ...disabledControls() }, }"
259
+ },
260
+ {
261
+ "kind": "variable",
262
+ "name": "ElementiDisabilitatiConHover",
263
+ "type": {
264
+ "text": "Story"
265
+ },
266
+ "default": "{ ...meta, name: 'Elementi disabilitati con hover', render: () => { const handleMouseEnter = (e: Event) => { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.openPopover(); }; const handleMouseLeave = (e: Event) => { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.closePopover(); }; const handleFocus = (e: Event) => { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.openPopover(); }; const handleBlur = (e: FocusEvent) => { const target = e.relatedTarget as HTMLElement; if (!target?.closest?.('it-popover')) { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.closePopover(); } }; return html` <it-popover placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\" disabled @mouseenter=${handleMouseEnter} @mouseleave=${handleMouseLeave} @focus=${handleFocus} @blur=${handleBlur} > Pulsante disabilitato </it-button> <div slot=\"content\" class=\"popover\" @blur=${handleBlur}> <div class=\"popover-body\">Pulsante disabilitato, qui puoi spiegare il perché</div> </div> </it-popover> `; }, argTypes: { ...disabledControls() }, }"
267
+ },
268
+ {
269
+ "kind": "variable",
270
+ "name": "AttivazioneControllata",
271
+ "type": {
272
+ "text": "Story"
273
+ },
274
+ "default": "{ ...meta, name: 'Attivazione controllata', tags: ['!dev'], render: () => html` <it-popover controlled placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\" id=\"controlled-trigger\"> Popover controllato </it-button> <div slot=\"content\" class=\"popover\"> <div class=\"popover-inner\"> <div class=\"popover-body\">Questo popover non si aprirà e questo testo non si vedrà.</div> </div> </div> </it-popover> `, argTypes: { ...disabledControls() }, }"
275
+ },
276
+ {
277
+ "kind": "variable",
278
+ "name": "Eventi",
279
+ "type": {
280
+ "text": "Story"
281
+ },
282
+ "default": "{ ...meta, render: () => { const handleOpen = (e: CustomEvent) => { console.log('Popover aperto', e); }; const handleClose = (e: CustomEvent) => { console.log('Popover chiuso', e); }; return html` <it-popover @it-popover-open=${handleOpen} @it-popover-close=${handleClose} placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\">Popover con eventi</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Eventi del Popover</h4> <div class=\"popover-body\">Apri e chiudi questo popover per vedere gli eventi nella console.</div> </div> </it-popover> `; }, argTypes: { ...disabledControls() }, }"
283
+ }
284
+ ],
285
+ "exports": [
286
+ {
287
+ "kind": "js",
288
+ "name": "default",
289
+ "declaration": {
290
+ "name": "meta",
291
+ "module": "stories/it-popover.stories.ts"
292
+ }
293
+ },
294
+ {
295
+ "kind": "js",
296
+ "name": "Base",
297
+ "declaration": {
298
+ "name": "Base",
299
+ "module": "stories/it-popover.stories.ts"
300
+ }
301
+ },
302
+ {
303
+ "kind": "js",
304
+ "name": "Posizione",
305
+ "declaration": {
306
+ "name": "Posizione",
307
+ "module": "stories/it-popover.stories.ts"
308
+ }
309
+ },
310
+ {
311
+ "kind": "js",
312
+ "name": "ConIconaELink",
313
+ "declaration": {
314
+ "name": "ConIconaELink",
315
+ "module": "stories/it-popover.stories.ts"
316
+ }
317
+ },
318
+ {
319
+ "kind": "js",
320
+ "name": "ElementiDisabilitati",
321
+ "declaration": {
322
+ "name": "ElementiDisabilitati",
323
+ "module": "stories/it-popover.stories.ts"
324
+ }
325
+ },
326
+ {
327
+ "kind": "js",
328
+ "name": "ElementiDisabilitatiConHover",
329
+ "declaration": {
330
+ "name": "ElementiDisabilitatiConHover",
331
+ "module": "stories/it-popover.stories.ts"
332
+ }
333
+ },
334
+ {
335
+ "kind": "js",
336
+ "name": "AttivazioneControllata",
337
+ "declaration": {
338
+ "name": "AttivazioneControllata",
339
+ "module": "stories/it-popover.stories.ts"
340
+ }
341
+ },
342
+ {
343
+ "kind": "js",
344
+ "name": "Eventi",
345
+ "declaration": {
346
+ "name": "Eventi",
347
+ "module": "stories/it-popover.stories.ts"
348
+ }
349
+ }
350
+ ]
196
351
  }
197
352
  ]
198
353
  }
@@ -1,9 +1,11 @@
1
1
  import { BaseComponent } from '@italia/globals';
2
+ import { PropertyValues } from 'lit';
2
3
  import { type Placement } from '@floating-ui/dom';
3
4
  type PopoverPlacement = Placement;
4
5
  export declare class ItPopover extends BaseComponent {
5
6
  static styles: import("lit").CSSResultGroup;
6
7
  open: boolean;
8
+ controlled: boolean;
7
9
  placement: PopoverPlacement;
8
10
  private _triggerSlot;
9
11
  private _contentSlot;
@@ -12,8 +14,9 @@ export declare class ItPopover extends BaseComponent {
12
14
  private _arrowElement?;
13
15
  private _cleanup?;
14
16
  private _setChildrenProperties;
15
- connectedCallback(): void;
17
+ protected setupStandardEvents(): void;
16
18
  disconnectedCallback(): void;
19
+ protected firstUpdated(_changedProperties: PropertyValues): void;
17
20
  updated(changedProps: Map<string, any>): void;
18
21
  private _createArrow;
19
22
  private _show;
@@ -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;AAGhD,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;IAE7B,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;IAc9B,iBAAiB;IAKjB,oBAAoB;IAMpB,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAatC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,KAAK;IAuDb,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,aAAa;IAId,MAAM;IAIN,WAAW;IAIX,YAAY;IAInB,MAAM;CAMP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
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,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,aAAa;IAId,MAAM;IAIN,WAAW;IAIX,YAAY;IAInB,MAAM;CAMP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
@@ -1078,7 +1078,7 @@ if (typeof window !== 'undefined') {
1078
1078
  window._itAnalytics = window._itAnalytics || {};
1079
1079
  window._itAnalytics = {
1080
1080
  ...window._itAnalytics,
1081
- version: '1.0.0-alpha.4',
1081
+ version: '1.0.0-alpha.6',
1082
1082
  };
1083
1083
  }
1084
1084
 
@@ -1273,6 +1273,71 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
1273
1273
  return coords;
1274
1274
  }
1275
1275
 
1276
+ /**
1277
+ * Resolves with an object of overflow side offsets that determine how much the
1278
+ * element is overflowing a given clipping boundary on each side.
1279
+ * - positive = overflowing the boundary by that number of pixels
1280
+ * - negative = how many pixels left before it will overflow
1281
+ * - 0 = lies flush with the boundary
1282
+ * @see https://floating-ui.com/docs/detectOverflow
1283
+ */
1284
+ async function detectOverflow(state, options) {
1285
+ var _await$platform$isEle;
1286
+ if (options === void 0) {
1287
+ options = {};
1288
+ }
1289
+ const {
1290
+ x,
1291
+ y,
1292
+ platform,
1293
+ rects,
1294
+ elements,
1295
+ strategy
1296
+ } = state;
1297
+ const {
1298
+ boundary = 'clippingAncestors',
1299
+ rootBoundary = 'viewport',
1300
+ elementContext = 'floating',
1301
+ altBoundary = false,
1302
+ padding = 0
1303
+ } = evaluate(options, state);
1304
+ const paddingObject = getPaddingObject(padding);
1305
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1306
+ const element = elements[altBoundary ? altContext : elementContext];
1307
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1308
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1309
+ boundary,
1310
+ rootBoundary,
1311
+ strategy
1312
+ }));
1313
+ const rect = elementContext === 'floating' ? {
1314
+ x,
1315
+ y,
1316
+ width: rects.floating.width,
1317
+ height: rects.floating.height
1318
+ } : rects.reference;
1319
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1320
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1321
+ x: 1,
1322
+ y: 1
1323
+ } : {
1324
+ x: 1,
1325
+ y: 1
1326
+ };
1327
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1328
+ elements,
1329
+ rect,
1330
+ offsetParent,
1331
+ strategy
1332
+ }) : rect);
1333
+ return {
1334
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1335
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1336
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1337
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1338
+ };
1339
+ }
1340
+
1276
1341
  /**
1277
1342
  * Computes the `x` and `y` coordinates that will place the floating element
1278
1343
  * next to a given reference element.
@@ -1302,6 +1367,7 @@ const computePosition$1 = async (reference, floating, config) => {
1302
1367
  let middlewareData = {};
1303
1368
  let resetCount = 0;
1304
1369
  for (let i = 0; i < validMiddleware.length; i++) {
1370
+ var _platform$detectOverf;
1305
1371
  const {
1306
1372
  name,
1307
1373
  fn
@@ -1319,7 +1385,10 @@ const computePosition$1 = async (reference, floating, config) => {
1319
1385
  strategy,
1320
1386
  middlewareData,
1321
1387
  rects,
1322
- platform,
1388
+ platform: {
1389
+ ...platform,
1390
+ detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
1391
+ },
1323
1392
  elements: {
1324
1393
  reference,
1325
1394
  floating
@@ -1364,71 +1433,6 @@ const computePosition$1 = async (reference, floating, config) => {
1364
1433
  };
1365
1434
  };
1366
1435
 
1367
- /**
1368
- * Resolves with an object of overflow side offsets that determine how much the
1369
- * element is overflowing a given clipping boundary on each side.
1370
- * - positive = overflowing the boundary by that number of pixels
1371
- * - negative = how many pixels left before it will overflow
1372
- * - 0 = lies flush with the boundary
1373
- * @see https://floating-ui.com/docs/detectOverflow
1374
- */
1375
- async function detectOverflow(state, options) {
1376
- var _await$platform$isEle;
1377
- if (options === void 0) {
1378
- options = {};
1379
- }
1380
- const {
1381
- x,
1382
- y,
1383
- platform,
1384
- rects,
1385
- elements,
1386
- strategy
1387
- } = state;
1388
- const {
1389
- boundary = 'clippingAncestors',
1390
- rootBoundary = 'viewport',
1391
- elementContext = 'floating',
1392
- altBoundary = false,
1393
- padding = 0
1394
- } = evaluate(options, state);
1395
- const paddingObject = getPaddingObject(padding);
1396
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1397
- const element = elements[altBoundary ? altContext : elementContext];
1398
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1399
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1400
- boundary,
1401
- rootBoundary,
1402
- strategy
1403
- }));
1404
- const rect = elementContext === 'floating' ? {
1405
- x,
1406
- y,
1407
- width: rects.floating.width,
1408
- height: rects.floating.height
1409
- } : rects.reference;
1410
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1411
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1412
- x: 1,
1413
- y: 1
1414
- } : {
1415
- x: 1,
1416
- y: 1
1417
- };
1418
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1419
- elements,
1420
- rect,
1421
- offsetParent,
1422
- strategy
1423
- }) : rect);
1424
- return {
1425
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1426
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1427
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1428
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1429
- };
1430
- }
1431
-
1432
1436
  /**
1433
1437
  * Provides data to position an inner element of the floating element so that it
1434
1438
  * appears centered to the reference element.
@@ -1561,7 +1565,7 @@ const flip$1 = function (options) {
1561
1565
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1562
1566
  }
1563
1567
  const placements = [initialPlacement, ...fallbackPlacements];
1564
- const overflow = await detectOverflow(state, detectOverflowOptions);
1568
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
1565
1569
  const overflows = [];
1566
1570
  let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1567
1571
  if (checkMainAxis) {
@@ -1745,7 +1749,8 @@ const shift$1 = function (options) {
1745
1749
  const {
1746
1750
  x,
1747
1751
  y,
1748
- placement
1752
+ placement,
1753
+ platform
1749
1754
  } = state;
1750
1755
  const {
1751
1756
  mainAxis: checkMainAxis = true,
@@ -1768,7 +1773,7 @@ const shift$1 = function (options) {
1768
1773
  x,
1769
1774
  y
1770
1775
  };
1771
- const overflow = await detectOverflow(state, detectOverflowOptions);
1776
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
1772
1777
  const crossAxis = getSideAxis(getSide(placement));
1773
1778
  const mainAxis = getOppositeAxis(crossAxis);
1774
1779
  let mainAxisCoord = coords[mainAxis];
@@ -1832,7 +1837,7 @@ const size$1 = function (options) {
1832
1837
  apply = () => {},
1833
1838
  ...detectOverflowOptions
1834
1839
  } = evaluate(options, state);
1835
- const overflow = await detectOverflow(state, detectOverflowOptions);
1840
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
1836
1841
  const side = getSide(placement);
1837
1842
  const alignment = getAlignment(placement);
1838
1843
  const isYAxis = getSideAxis(placement) === 'y';
@@ -2799,13 +2804,14 @@ var styles = css`/***************************** 1 ******************************
2799
2804
  /***************************** NEUTRAL 2 ****************************************/
2800
2805
  /***************************** NEUTRAL 2 / 3 ****************************************/
2801
2806
  :host {
2802
- --bs-dropdown-background: var(--bs-color-background-inverse);
2807
+ --bsi-dropdown-background: var(--bsi-color-background-inverse);
2803
2808
  }`;
2804
2809
 
2805
2810
  let ItPopover = class ItPopover extends BaseComponent {
2806
2811
  constructor() {
2807
2812
  super(...arguments);
2808
2813
  this.open = false;
2814
+ this.controlled = false;
2809
2815
  this.placement = 'bottom-start';
2810
2816
  this._onDocumentClick = (event) => {
2811
2817
  if (!this.open)
@@ -2824,27 +2830,57 @@ let ItPopover = class ItPopover extends BaseComponent {
2824
2830
  }
2825
2831
  _setChildrenProperties() {
2826
2832
  if (this._triggerElement && this._triggerElement.tagName === 'IT-BUTTON') {
2833
+ if (this._triggerElement.disabled) {
2834
+ this._triggerElement.removeAttribute('it-aria-haspopup');
2835
+ this._triggerElement.expanded = undefined;
2836
+ return;
2837
+ }
2827
2838
  if (!this._triggerElement.hasAttribute('it-aria-haspopup')) {
2828
2839
  this._triggerElement?.setAttribute('it-aria-haspopup', 'true');
2829
2840
  }
2830
2841
  this._triggerElement.expanded = this.open;
2831
2842
  }
2832
2843
  else {
2844
+ if (this._triggerElement?.hasAttribute('disabled')) {
2845
+ this._triggerElement.removeAttribute('aria-haspopup');
2846
+ this._triggerElement.removeAttribute('aria-expanded');
2847
+ return;
2848
+ }
2833
2849
  if (!this._triggerElement?.hasAttribute('aria-haspopup')) {
2834
2850
  this._triggerElement?.setAttribute('aria-haspopup', 'true');
2835
2851
  }
2836
2852
  this._triggerElement?.setAttribute('aria-expanded', String(this.open));
2837
2853
  }
2838
2854
  }
2839
- connectedCallback() {
2840
- super.connectedCallback?.();
2855
+ setupStandardEvents() {
2841
2856
  document.addEventListener('click', this._onDocumentClick);
2857
+ this._triggerElement?.addEventListener('click', (e) => {
2858
+ e.preventDefault();
2859
+ this.toggle();
2860
+ });
2861
+ this._triggerElement?.addEventListener('keydown', (e) => {
2862
+ if (e.key === 'Escape' && this.open) {
2863
+ this.closePopover();
2864
+ this._triggerElement?.focus();
2865
+ }
2866
+ });
2867
+ this._contentElement?.addEventListener('keydown', (e) => {
2868
+ if (e.key === 'Escape' && this.open) {
2869
+ this.closePopover();
2870
+ this._triggerElement?.focus();
2871
+ }
2872
+ });
2842
2873
  }
2843
2874
  disconnectedCallback() {
2844
2875
  super.disconnectedCallback?.();
2845
2876
  document.removeEventListener('click', this._onDocumentClick);
2846
2877
  this._cleanup?.();
2847
2878
  }
2879
+ firstUpdated(_changedProperties) {
2880
+ super.firstUpdated(_changedProperties);
2881
+ if (!this.controlled)
2882
+ this.setupStandardEvents();
2883
+ }
2848
2884
  updated(changedProps) {
2849
2885
  this._setChildrenProperties();
2850
2886
  if (changedProps.has('open')) {
@@ -2944,6 +2980,10 @@ __decorate([
2944
2980
  property({ type: Boolean, reflect: true }),
2945
2981
  __metadata("design:type", Object)
2946
2982
  ], ItPopover.prototype, "open", void 0);
2983
+ __decorate([
2984
+ property({ type: Boolean }),
2985
+ __metadata("design:type", Object)
2986
+ ], ItPopover.prototype, "controlled", void 0);
2947
2987
  __decorate([
2948
2988
  property({ type: String }),
2949
2989
  __metadata("design:type", String)