@italia/popover 1.0.0-alpha.4 → 1.0.0-alpha.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.
- package/README.md +57 -9
- package/custom-elements.json +155 -0
- package/dist/src/it-popover.d.ts +4 -1
- package/dist/src/it-popover.d.ts.map +1 -1
- package/dist/src/it-popover.js +39 -4
- package/dist/src/it-popover.js.map +1 -1
- package/package.json +6 -5
- package/styles/globals.scss +19 -0
package/README.md
CHANGED
|
@@ -1,19 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# \<it-popover>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
4
|
|
|
5
|
-
##
|
|
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
|
-
##
|
|
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
|
-
|
|
14
|
-
- Test: web-test-runner
|
|
15
|
-
- Storie: Storybook
|
|
63
|
+
## Tooling configs
|
|
16
64
|
|
|
17
|
-
|
|
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
|
-
|
|
67
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
package/custom-elements.json
CHANGED
|
@@ -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', docs: { source: { excludeDecorators: true }, }, }, } 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
|
}
|
package/dist/src/it-popover.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
|
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"}
|
package/dist/src/it-popover.js
CHANGED
|
@@ -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.
|
|
1081
|
+
version: '1.0.0-alpha.5',
|
|
1082
1082
|
};
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
@@ -2799,13 +2799,14 @@ var styles = css`/***************************** 1 ******************************
|
|
|
2799
2799
|
/***************************** NEUTRAL 2 ****************************************/
|
|
2800
2800
|
/***************************** NEUTRAL 2 / 3 ****************************************/
|
|
2801
2801
|
:host {
|
|
2802
|
-
--
|
|
2802
|
+
--bsi-dropdown-background: var(--bsi-color-background-inverse);
|
|
2803
2803
|
}`;
|
|
2804
2804
|
|
|
2805
2805
|
let ItPopover = class ItPopover extends BaseComponent {
|
|
2806
2806
|
constructor() {
|
|
2807
2807
|
super(...arguments);
|
|
2808
2808
|
this.open = false;
|
|
2809
|
+
this.controlled = false;
|
|
2809
2810
|
this.placement = 'bottom-start';
|
|
2810
2811
|
this._onDocumentClick = (event) => {
|
|
2811
2812
|
if (!this.open)
|
|
@@ -2824,27 +2825,57 @@ let ItPopover = class ItPopover extends BaseComponent {
|
|
|
2824
2825
|
}
|
|
2825
2826
|
_setChildrenProperties() {
|
|
2826
2827
|
if (this._triggerElement && this._triggerElement.tagName === 'IT-BUTTON') {
|
|
2828
|
+
if (this._triggerElement.disabled) {
|
|
2829
|
+
this._triggerElement.removeAttribute('it-aria-haspopup');
|
|
2830
|
+
this._triggerElement.expanded = undefined;
|
|
2831
|
+
return;
|
|
2832
|
+
}
|
|
2827
2833
|
if (!this._triggerElement.hasAttribute('it-aria-haspopup')) {
|
|
2828
2834
|
this._triggerElement?.setAttribute('it-aria-haspopup', 'true');
|
|
2829
2835
|
}
|
|
2830
2836
|
this._triggerElement.expanded = this.open;
|
|
2831
2837
|
}
|
|
2832
2838
|
else {
|
|
2839
|
+
if (this._triggerElement?.hasAttribute('disabled')) {
|
|
2840
|
+
this._triggerElement.removeAttribute('aria-haspopup');
|
|
2841
|
+
this._triggerElement.removeAttribute('aria-expanded');
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2833
2844
|
if (!this._triggerElement?.hasAttribute('aria-haspopup')) {
|
|
2834
2845
|
this._triggerElement?.setAttribute('aria-haspopup', 'true');
|
|
2835
2846
|
}
|
|
2836
2847
|
this._triggerElement?.setAttribute('aria-expanded', String(this.open));
|
|
2837
2848
|
}
|
|
2838
2849
|
}
|
|
2839
|
-
|
|
2840
|
-
super.connectedCallback?.();
|
|
2850
|
+
setupStandardEvents() {
|
|
2841
2851
|
document.addEventListener('click', this._onDocumentClick);
|
|
2852
|
+
this._triggerElement?.addEventListener('click', (e) => {
|
|
2853
|
+
e.preventDefault();
|
|
2854
|
+
this.toggle();
|
|
2855
|
+
});
|
|
2856
|
+
this._triggerElement?.addEventListener('keydown', (e) => {
|
|
2857
|
+
if (e.key === 'Escape' && this.open) {
|
|
2858
|
+
this.closePopover();
|
|
2859
|
+
this._triggerElement?.focus();
|
|
2860
|
+
}
|
|
2861
|
+
});
|
|
2862
|
+
this._contentElement?.addEventListener('keydown', (e) => {
|
|
2863
|
+
if (e.key === 'Escape' && this.open) {
|
|
2864
|
+
this.closePopover();
|
|
2865
|
+
this._triggerElement?.focus();
|
|
2866
|
+
}
|
|
2867
|
+
});
|
|
2842
2868
|
}
|
|
2843
2869
|
disconnectedCallback() {
|
|
2844
2870
|
super.disconnectedCallback?.();
|
|
2845
2871
|
document.removeEventListener('click', this._onDocumentClick);
|
|
2846
2872
|
this._cleanup?.();
|
|
2847
2873
|
}
|
|
2874
|
+
firstUpdated(_changedProperties) {
|
|
2875
|
+
super.firstUpdated(_changedProperties);
|
|
2876
|
+
if (!this.controlled)
|
|
2877
|
+
this.setupStandardEvents();
|
|
2878
|
+
}
|
|
2848
2879
|
updated(changedProps) {
|
|
2849
2880
|
this._setChildrenProperties();
|
|
2850
2881
|
if (changedProps.has('open')) {
|
|
@@ -2944,6 +2975,10 @@ __decorate([
|
|
|
2944
2975
|
property({ type: Boolean, reflect: true }),
|
|
2945
2976
|
__metadata("design:type", Object)
|
|
2946
2977
|
], ItPopover.prototype, "open", void 0);
|
|
2978
|
+
__decorate([
|
|
2979
|
+
property({ type: Boolean }),
|
|
2980
|
+
__metadata("design:type", Object)
|
|
2981
|
+
], ItPopover.prototype, "controlled", void 0);
|
|
2947
2982
|
__decorate([
|
|
2948
2983
|
property({ type: String }),
|
|
2949
2984
|
__metadata("design:type", String)
|