@haiilo/catalyst 0.1.0 → 0.2.1
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/dist/catalyst/catalyst.css +1 -1403
- package/dist/catalyst/catalyst.esm.js +1 -126
- package/dist/catalyst/index.esm.js +0 -1
- package/dist/catalyst/p-22fac0fb.js +1 -0
- package/dist/catalyst/p-2dc28db3.entry.js +11 -0
- package/dist/catalyst/{p-f3fad7a0.js → p-e08f13c7.js} +1 -1
- package/dist/cjs/{app-globals-8908fe44.js → app-globals-814f34aa.js} +5 -2
- package/dist/cjs/cat-alert_7.cjs.entry.js +3115 -0
- package/dist/cjs/{cat-icon-registry-da00f7d6.js → cat-icon-registry-909e38e7.js} +65 -1
- package/dist/cjs/catalyst.cjs.js +7 -114
- package/dist/cjs/loader.cjs.js +5 -20
- package/dist/collection/collection-manifest.json +6 -2
- package/dist/collection/components/cat-alert/cat-alert.css +57 -0
- package/dist/collection/components/cat-alert/cat-alert.js +49 -0
- package/dist/collection/components/cat-badge/cat-badge.css +154 -0
- package/dist/collection/components/cat-badge/cat-badge.js +141 -0
- package/dist/collection/components/cat-button/cat-button.css +43 -8
- package/dist/collection/components/cat-button/cat-button.js +28 -6
- package/dist/collection/components/cat-icon/cat-icon.css +2 -1
- package/dist/collection/components/cat-menu/cat-menu.css +33 -0
- package/dist/collection/components/cat-menu/cat-menu.js +185 -0
- package/dist/collection/components/cat-skeleton/cat-skeleton.css +177 -0
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +130 -0
- package/dist/components/cat-alert.d.ts +11 -0
- package/dist/components/cat-alert.js +42 -0
- package/dist/components/cat-badge.d.ts +11 -0
- package/dist/components/cat-badge.js +66 -0
- package/dist/components/cat-button.js +14 -42
- package/dist/components/cat-icon2.js +4 -5
- package/dist/components/cat-menu.d.ts +11 -0
- package/dist/components/cat-menu.js +2377 -0
- package/dist/components/cat-skeleton.d.ts +11 -0
- package/dist/components/cat-skeleton.js +76 -0
- package/dist/components/cat-spinner2.js +3 -4
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +4 -575
- package/dist/esm/{app-globals-000601ea.js → app-globals-e1679c2d.js} +5 -2
- package/dist/esm/cat-alert_7.entry.js +3105 -0
- package/dist/esm/{cat-icon-registry-b66e3f57.js → cat-icon-registry-4d02ee6c.js} +65 -2
- package/dist/esm/catalyst.js +6 -113
- package/dist/esm/loader.js +4 -19
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/types/components/cat-alert/cat-alert.d.ts +12 -0
- package/dist/types/components/cat-badge/cat-badge.d.ts +28 -0
- package/dist/types/components/cat-button/cat-button.d.ts +5 -0
- package/dist/types/components/cat-menu/cat-menu.d.ts +32 -0
- package/dist/types/components/cat-skeleton/cat-skeleton.d.ts +28 -0
- package/dist/types/components.d.ts +153 -0
- package/package.json +12 -9
- package/dist/catalyst/app-globals-622e4f87.js +0 -704
- package/dist/catalyst/cat-button.entry.js +0 -629
- package/dist/catalyst/cat-icon-registry-59da2e37.js +0 -43
- package/dist/catalyst/cat-icon.entry.js +0 -27
- package/dist/catalyst/cat-spinner.entry.js +0 -21
- package/dist/catalyst/css-shim-20dbffa5.js +0 -4
- package/dist/catalyst/dom-c5ed0ba5.js +0 -73
- package/dist/catalyst/index-72a1bbba.js +0 -3031
- package/dist/catalyst/p-17a20657.js +0 -1
- package/dist/catalyst/p-582935bb.entry.js +0 -1
- package/dist/catalyst/shadow-css-8c625855.js +0 -388
- package/dist/cjs/app-globals-fe9ff8ba.js +0 -706
- package/dist/cjs/cat-button.cjs.entry.js +0 -633
- package/dist/cjs/cat-button_3.cjs.entry.js +0 -645
- package/dist/cjs/cat-icon-registry-850c538c.js +0 -45
- package/dist/cjs/cat-icon.cjs.entry.js +0 -31
- package/dist/cjs/cat-spinner.cjs.entry.js +0 -25
- package/dist/cjs/css-shim-3bfdba4f.js +0 -6
- package/dist/cjs/dom-8ac1ad03.js +0 -75
- package/dist/cjs/index-083488c8.js +0 -3065
- package/dist/cjs/shadow-css-41d9783d.js +0 -390
- package/dist/esm/app-globals-622e4f87.js +0 -704
- package/dist/esm/cat-button.entry.js +0 -629
- package/dist/esm/cat-button_3.entry.js +0 -639
- package/dist/esm/cat-icon-registry-59da2e37.js +0 -43
- package/dist/esm/cat-icon.entry.js +0 -27
- package/dist/esm/cat-spinner.entry.js +0 -21
- package/dist/esm/css-shim-20dbffa5.js +0 -4
- package/dist/esm/dom-c5ed0ba5.js +0 -73
- package/dist/esm/index-72a1bbba.js +0 -3031
- package/dist/esm/shadow-css-8c625855.js +0 -388
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Component, h, Prop } from '@stencil/core';
|
|
2
|
+
/**
|
|
3
|
+
* Badges are used to draw attention and display statuses or counts.
|
|
4
|
+
*
|
|
5
|
+
* @part badge - The content of the badge.
|
|
6
|
+
*/
|
|
7
|
+
export class CatBadge {
|
|
8
|
+
constructor() {
|
|
9
|
+
/**
|
|
10
|
+
* The rendering style of the badge.
|
|
11
|
+
*/
|
|
12
|
+
this.variant = 'filled';
|
|
13
|
+
/**
|
|
14
|
+
* The color palette of the badge.
|
|
15
|
+
*/
|
|
16
|
+
this.color = 'primary';
|
|
17
|
+
/**
|
|
18
|
+
* The size of the badge.
|
|
19
|
+
*/
|
|
20
|
+
this.size = 'm';
|
|
21
|
+
/**
|
|
22
|
+
* Use round badge edges.
|
|
23
|
+
*/
|
|
24
|
+
this.round = false;
|
|
25
|
+
/**
|
|
26
|
+
* Draw attention to the badge with a subtle animation.
|
|
27
|
+
*/
|
|
28
|
+
this.pulse = false;
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
return (h("span", { part: "badge", class: {
|
|
32
|
+
'cat-badge': true,
|
|
33
|
+
'cat-badge-round': this.round,
|
|
34
|
+
'cat-badge-pulse': this.pulse,
|
|
35
|
+
[`cat-badge-${this.variant}`]: Boolean(this.variant),
|
|
36
|
+
[`cat-badge-${this.color}`]: Boolean(this.color),
|
|
37
|
+
[`cat-badge-${this.size}`]: Boolean(this.size)
|
|
38
|
+
} },
|
|
39
|
+
h("slot", null)));
|
|
40
|
+
}
|
|
41
|
+
static get is() { return "cat-badge"; }
|
|
42
|
+
static get encapsulation() { return "shadow"; }
|
|
43
|
+
static get originalStyleUrls() { return {
|
|
44
|
+
"$": ["cat-badge.scss"]
|
|
45
|
+
}; }
|
|
46
|
+
static get styleUrls() { return {
|
|
47
|
+
"$": ["cat-badge.css"]
|
|
48
|
+
}; }
|
|
49
|
+
static get properties() { return {
|
|
50
|
+
"variant": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"mutable": false,
|
|
53
|
+
"complexType": {
|
|
54
|
+
"original": "'filled' | 'outlined'",
|
|
55
|
+
"resolved": "\"filled\" | \"outlined\"",
|
|
56
|
+
"references": {}
|
|
57
|
+
},
|
|
58
|
+
"required": false,
|
|
59
|
+
"optional": false,
|
|
60
|
+
"docs": {
|
|
61
|
+
"tags": [],
|
|
62
|
+
"text": "The rendering style of the badge."
|
|
63
|
+
},
|
|
64
|
+
"attribute": "variant",
|
|
65
|
+
"reflect": false,
|
|
66
|
+
"defaultValue": "'filled'"
|
|
67
|
+
},
|
|
68
|
+
"color": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"mutable": false,
|
|
71
|
+
"complexType": {
|
|
72
|
+
"original": "'primary' | 'secondary' | 'danger' | 'success' | 'warning'",
|
|
73
|
+
"resolved": "\"danger\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"",
|
|
74
|
+
"references": {}
|
|
75
|
+
},
|
|
76
|
+
"required": false,
|
|
77
|
+
"optional": false,
|
|
78
|
+
"docs": {
|
|
79
|
+
"tags": [],
|
|
80
|
+
"text": "The color palette of the badge."
|
|
81
|
+
},
|
|
82
|
+
"attribute": "color",
|
|
83
|
+
"reflect": false,
|
|
84
|
+
"defaultValue": "'primary'"
|
|
85
|
+
},
|
|
86
|
+
"size": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"mutable": false,
|
|
89
|
+
"complexType": {
|
|
90
|
+
"original": "'xs' | 's' | 'm' | 'l' | 'xl'",
|
|
91
|
+
"resolved": "\"l\" | \"m\" | \"s\" | \"xl\" | \"xs\"",
|
|
92
|
+
"references": {}
|
|
93
|
+
},
|
|
94
|
+
"required": false,
|
|
95
|
+
"optional": false,
|
|
96
|
+
"docs": {
|
|
97
|
+
"tags": [],
|
|
98
|
+
"text": "The size of the badge."
|
|
99
|
+
},
|
|
100
|
+
"attribute": "size",
|
|
101
|
+
"reflect": false,
|
|
102
|
+
"defaultValue": "'m'"
|
|
103
|
+
},
|
|
104
|
+
"round": {
|
|
105
|
+
"type": "boolean",
|
|
106
|
+
"mutable": false,
|
|
107
|
+
"complexType": {
|
|
108
|
+
"original": "boolean",
|
|
109
|
+
"resolved": "boolean",
|
|
110
|
+
"references": {}
|
|
111
|
+
},
|
|
112
|
+
"required": false,
|
|
113
|
+
"optional": false,
|
|
114
|
+
"docs": {
|
|
115
|
+
"tags": [],
|
|
116
|
+
"text": "Use round badge edges."
|
|
117
|
+
},
|
|
118
|
+
"attribute": "round",
|
|
119
|
+
"reflect": false,
|
|
120
|
+
"defaultValue": "false"
|
|
121
|
+
},
|
|
122
|
+
"pulse": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"mutable": false,
|
|
125
|
+
"complexType": {
|
|
126
|
+
"original": "boolean",
|
|
127
|
+
"resolved": "boolean",
|
|
128
|
+
"references": {}
|
|
129
|
+
},
|
|
130
|
+
"required": false,
|
|
131
|
+
"optional": false,
|
|
132
|
+
"docs": {
|
|
133
|
+
"tags": [],
|
|
134
|
+
"text": "Draw attention to the badge with a subtle animation."
|
|
135
|
+
},
|
|
136
|
+
"attribute": "pulse",
|
|
137
|
+
"reflect": false,
|
|
138
|
+
"defaultValue": "false"
|
|
139
|
+
}
|
|
140
|
+
}; }
|
|
141
|
+
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
user-select: none;
|
|
14
14
|
/* stylelint-enable property-no-vendor-prefix */
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
:host([hidden]) {
|
|
17
18
|
display: none;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -114,19 +115,19 @@
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
.cat-button-secondary {
|
|
117
|
-
--bg:
|
|
118
|
-
--fill:
|
|
118
|
+
--bg: 105, 118, 135;
|
|
119
|
+
--fill: 255, 255, 255;
|
|
119
120
|
--text: 0, 0, 0;
|
|
120
|
-
--base:
|
|
121
|
+
--base: 105, 118, 135;
|
|
121
122
|
}
|
|
122
123
|
.cat-button-secondary:hover:not(.cat-button-disabled):not(.cat-button-loading) {
|
|
123
|
-
--bg:
|
|
124
|
-
--fill:
|
|
124
|
+
--bg: 105, 118, 135;
|
|
125
|
+
--fill: 255, 255, 255;
|
|
125
126
|
--text: 0, 0, 0;
|
|
126
127
|
}
|
|
127
128
|
.cat-button-secondary:active:not(.cat-button-disabled):not(.cat-button-loading) {
|
|
128
|
-
--bg:
|
|
129
|
-
--fill:
|
|
129
|
+
--bg: 105, 118, 135;
|
|
130
|
+
--fill: 255, 255, 255;
|
|
130
131
|
--text: 0, 0, 0;
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -198,6 +199,10 @@
|
|
|
198
199
|
padding-left: 0;
|
|
199
200
|
padding-right: 0;
|
|
200
201
|
}
|
|
202
|
+
:host-context(nav) .cat-button-xs {
|
|
203
|
+
padding-left: 1rem;
|
|
204
|
+
padding-right: 1rem;
|
|
205
|
+
}
|
|
201
206
|
|
|
202
207
|
.cat-button-s {
|
|
203
208
|
min-width: 2rem;
|
|
@@ -220,6 +225,10 @@
|
|
|
220
225
|
padding-left: 0;
|
|
221
226
|
padding-right: 0;
|
|
222
227
|
}
|
|
228
|
+
:host-context(nav) .cat-button-s {
|
|
229
|
+
padding-left: 1rem;
|
|
230
|
+
padding-right: 1rem;
|
|
231
|
+
}
|
|
223
232
|
|
|
224
233
|
.cat-button-m {
|
|
225
234
|
min-width: 2.5rem;
|
|
@@ -242,6 +251,10 @@
|
|
|
242
251
|
padding-left: 0;
|
|
243
252
|
padding-right: 0;
|
|
244
253
|
}
|
|
254
|
+
:host-context(nav) .cat-button-m {
|
|
255
|
+
padding-left: 1rem;
|
|
256
|
+
padding-right: 1rem;
|
|
257
|
+
}
|
|
245
258
|
|
|
246
259
|
.cat-button-l {
|
|
247
260
|
min-width: 3rem;
|
|
@@ -264,6 +277,10 @@
|
|
|
264
277
|
padding-left: 0;
|
|
265
278
|
padding-right: 0;
|
|
266
279
|
}
|
|
280
|
+
:host-context(nav) .cat-button-l {
|
|
281
|
+
padding-left: 1rem;
|
|
282
|
+
padding-right: 1rem;
|
|
283
|
+
}
|
|
267
284
|
|
|
268
285
|
.cat-button-xl {
|
|
269
286
|
min-width: 3.5rem;
|
|
@@ -281,4 +298,22 @@
|
|
|
281
298
|
width: 3.5rem;
|
|
282
299
|
padding-left: 0;
|
|
283
300
|
padding-right: 0;
|
|
301
|
+
}
|
|
302
|
+
:host-context(nav) .cat-button-xl {
|
|
303
|
+
padding-left: 1rem;
|
|
304
|
+
padding-right: 1rem;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
:host-context(nav) {
|
|
308
|
+
width: 100%;
|
|
309
|
+
}
|
|
310
|
+
:host-context(nav) .cat-button {
|
|
311
|
+
box-shadow: none;
|
|
312
|
+
border-radius: 0;
|
|
313
|
+
}
|
|
314
|
+
:host-context(nav) .cat-button:focus-visible {
|
|
315
|
+
outline-offset: -2px;
|
|
316
|
+
}
|
|
317
|
+
:host-context(nav) .cat-button-content {
|
|
318
|
+
text-align: left;
|
|
284
319
|
}
|
|
@@ -16,11 +16,11 @@ export class CatButton {
|
|
|
16
16
|
/**
|
|
17
17
|
* The rendering style of the button.
|
|
18
18
|
*/
|
|
19
|
-
this.variant = '
|
|
19
|
+
this.variant = 'outlined';
|
|
20
20
|
/**
|
|
21
21
|
* The color palette of the button.
|
|
22
22
|
*/
|
|
23
|
-
this.color = '
|
|
23
|
+
this.color = 'secondary';
|
|
24
24
|
/**
|
|
25
25
|
* The size of the button.
|
|
26
26
|
*/
|
|
@@ -112,7 +112,7 @@ export class CatButton {
|
|
|
112
112
|
[`cat-button-${this.variant}`]: Boolean(this.variant),
|
|
113
113
|
[`cat-button-${this.color}`]: Boolean(this.color),
|
|
114
114
|
[`cat-button-${this.size}`]: Boolean(this.size)
|
|
115
|
-
}, onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
115
|
+
}, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
return (h("button", { ref: el => (this.button = el), type: this.submit ? 'submit' : 'button', name: this.name, value: this.value, disabled: this.disabled, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
|
|
@@ -125,7 +125,7 @@ export class CatButton {
|
|
|
125
125
|
[`cat-button-${this.variant}`]: Boolean(this.variant),
|
|
126
126
|
[`cat-button-${this.color}`]: Boolean(this.color),
|
|
127
127
|
[`cat-button-${this.size}`]: Boolean(this.size)
|
|
128
|
-
}, onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
128
|
+
}, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
get iconSize() {
|
|
@@ -162,6 +162,9 @@ export class CatButton {
|
|
|
162
162
|
this.loading ? h("cat-spinner", { size: this.spinnerSize }) : null
|
|
163
163
|
];
|
|
164
164
|
}
|
|
165
|
+
onClick(event) {
|
|
166
|
+
this.catClick.emit(event);
|
|
167
|
+
}
|
|
165
168
|
onFocus(event) {
|
|
166
169
|
this.catFocus.emit(event);
|
|
167
170
|
}
|
|
@@ -193,7 +196,7 @@ export class CatButton {
|
|
|
193
196
|
},
|
|
194
197
|
"attribute": "variant",
|
|
195
198
|
"reflect": false,
|
|
196
|
-
"defaultValue": "'
|
|
199
|
+
"defaultValue": "'outlined'"
|
|
197
200
|
},
|
|
198
201
|
"color": {
|
|
199
202
|
"type": "string",
|
|
@@ -211,7 +214,7 @@ export class CatButton {
|
|
|
211
214
|
},
|
|
212
215
|
"attribute": "color",
|
|
213
216
|
"reflect": false,
|
|
214
|
-
"defaultValue": "'
|
|
217
|
+
"defaultValue": "'secondary'"
|
|
215
218
|
},
|
|
216
219
|
"size": {
|
|
217
220
|
"type": "string",
|
|
@@ -486,6 +489,25 @@ export class CatButton {
|
|
|
486
489
|
"_iconOnly": {}
|
|
487
490
|
}; }
|
|
488
491
|
static get events() { return [{
|
|
492
|
+
"method": "catClick",
|
|
493
|
+
"name": "catClick",
|
|
494
|
+
"bubbles": true,
|
|
495
|
+
"cancelable": true,
|
|
496
|
+
"composed": true,
|
|
497
|
+
"docs": {
|
|
498
|
+
"tags": [],
|
|
499
|
+
"text": "Emitted when the button is clicked."
|
|
500
|
+
},
|
|
501
|
+
"complexType": {
|
|
502
|
+
"original": "MouseEvent",
|
|
503
|
+
"resolved": "MouseEvent",
|
|
504
|
+
"references": {
|
|
505
|
+
"MouseEvent": {
|
|
506
|
+
"location": "global"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}, {
|
|
489
511
|
"method": "catFocus",
|
|
490
512
|
"name": "catFocus",
|
|
491
513
|
"bubbles": true,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated file. Do not edit directly.
|
|
3
|
+
*/
|
|
4
|
+
/* stylelint-disable value-keyword-case */
|
|
5
|
+
/* stylelint-enable value-keyword-case */
|
|
6
|
+
/**
|
|
7
|
+
* Auto-generated file. Do not edit directly.
|
|
8
|
+
*/
|
|
9
|
+
/* stylelint-disable value-keyword-case */
|
|
10
|
+
/* stylelint-enable value-keyword-case */
|
|
11
|
+
:host {
|
|
12
|
+
display: inline-block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host([hidden]) {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.content {
|
|
20
|
+
padding-top: 0.5rem;
|
|
21
|
+
padding-bottom: 0.5rem;
|
|
22
|
+
position: absolute;
|
|
23
|
+
background: white;
|
|
24
|
+
display: none;
|
|
25
|
+
overflow: auto;
|
|
26
|
+
-webkit-overflow-scrolling: touch;
|
|
27
|
+
min-width: 8rem;
|
|
28
|
+
max-width: 16rem;
|
|
29
|
+
min-height: 2rem;
|
|
30
|
+
max-height: calc(100vh - 48px);
|
|
31
|
+
box-shadow: 0 1px 4px 0 rgba(16, 29, 48, 0.2);
|
|
32
|
+
border-radius: 0.25rem;
|
|
33
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
|
|
2
|
+
import { Component, Event, h, Host, Listen, Prop } from '@stencil/core';
|
|
3
|
+
import * as focusTrap from 'focus-trap';
|
|
4
|
+
import { tabbable } from 'tabbable';
|
|
5
|
+
let nextUniqueId = 0;
|
|
6
|
+
export class CatMenu {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.id = nextUniqueId++;
|
|
9
|
+
/**
|
|
10
|
+
* The placement of the menu.
|
|
11
|
+
*/
|
|
12
|
+
this.placement = 'bottom-start';
|
|
13
|
+
}
|
|
14
|
+
clickHandler(event) {
|
|
15
|
+
var _a;
|
|
16
|
+
// hide menu on button click
|
|
17
|
+
if (this.content && event.composedPath().includes(this.content)) {
|
|
18
|
+
(_a = this.trap) === null || _a === void 0 ? void 0 : _a.deactivate();
|
|
19
|
+
this.hide();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
componentDidLoad() {
|
|
23
|
+
var _a, _b, _c, _d, _e;
|
|
24
|
+
this.trigger = this.firstTabbable(this.triggerSlot);
|
|
25
|
+
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
|
|
26
|
+
(_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
|
|
27
|
+
(_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
|
|
28
|
+
(_d = this.content) === null || _d === void 0 ? void 0 : _d.setAttribute('id', this.contentId);
|
|
29
|
+
if (this.trigger && this.content) {
|
|
30
|
+
(_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => this.show());
|
|
31
|
+
autoUpdate(this.trigger, this.content, () => this.update());
|
|
32
|
+
}
|
|
33
|
+
this.keyListener = event => {
|
|
34
|
+
if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
35
|
+
const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
|
|
36
|
+
const activeElement = this.firstTabbable(document.activeElement);
|
|
37
|
+
const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
|
|
38
|
+
const activeOff = event.key === 'ArrowDown' ? 1 : -1;
|
|
39
|
+
const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
|
|
40
|
+
targetElements[targetIdx].focus();
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
document.addEventListener('keydown', this.keyListener);
|
|
45
|
+
}
|
|
46
|
+
disconnectedCallback() {
|
|
47
|
+
if (this.keyListener) {
|
|
48
|
+
document.removeEventListener('keydown', this.keyListener);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
return (h(Host, null,
|
|
53
|
+
h("slot", { name: "trigger", ref: el => (this.triggerSlot = el) }),
|
|
54
|
+
h("div", { class: "content", ref: el => (this.content = el) },
|
|
55
|
+
h("slot", { name: "content" }))));
|
|
56
|
+
}
|
|
57
|
+
get contentId() {
|
|
58
|
+
return `cat-menu-${this.id}`;
|
|
59
|
+
}
|
|
60
|
+
show() {
|
|
61
|
+
var _a;
|
|
62
|
+
if (this.content) {
|
|
63
|
+
this.content.style.display = 'block';
|
|
64
|
+
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
|
|
65
|
+
this.catOpen.emit();
|
|
66
|
+
this.trap = this.trap
|
|
67
|
+
? this.trap.updateContainerElements(this.content)
|
|
68
|
+
: focusTrap.createFocusTrap(this.content, {
|
|
69
|
+
tabbableOptions: {
|
|
70
|
+
getShadowRoot: true
|
|
71
|
+
},
|
|
72
|
+
allowOutsideClick: true,
|
|
73
|
+
clickOutsideDeactivates: event => !this.content || !event.composedPath().includes(this.content),
|
|
74
|
+
onPostDeactivate: () => this.hide()
|
|
75
|
+
});
|
|
76
|
+
this.trap.activate();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
hide() {
|
|
80
|
+
var _a;
|
|
81
|
+
if (this.content) {
|
|
82
|
+
this.content.style.display = '';
|
|
83
|
+
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
|
|
84
|
+
this.catClose.emit();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
update() {
|
|
88
|
+
if (this.trigger && this.content) {
|
|
89
|
+
computePosition(this.trigger, this.content, {
|
|
90
|
+
placement: this.placement,
|
|
91
|
+
middleware: [offset(CatMenu.OFFSET), flip()]
|
|
92
|
+
}).then(({ x, y }) => {
|
|
93
|
+
if (this.content) {
|
|
94
|
+
Object.assign(this.content.style, {
|
|
95
|
+
left: `${x}px`,
|
|
96
|
+
top: `${y}px`
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
firstTabbable(container) {
|
|
103
|
+
return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
|
|
104
|
+
}
|
|
105
|
+
static get is() { return "cat-menu"; }
|
|
106
|
+
static get encapsulation() { return "shadow"; }
|
|
107
|
+
static get originalStyleUrls() { return {
|
|
108
|
+
"$": ["cat-menu.scss"]
|
|
109
|
+
}; }
|
|
110
|
+
static get styleUrls() { return {
|
|
111
|
+
"$": ["cat-menu.css"]
|
|
112
|
+
}; }
|
|
113
|
+
static get properties() { return {
|
|
114
|
+
"placement": {
|
|
115
|
+
"type": "string",
|
|
116
|
+
"mutable": false,
|
|
117
|
+
"complexType": {
|
|
118
|
+
"original": "Placement",
|
|
119
|
+
"resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
|
|
120
|
+
"references": {
|
|
121
|
+
"Placement": {
|
|
122
|
+
"location": "import",
|
|
123
|
+
"path": "@floating-ui/dom"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"required": false,
|
|
128
|
+
"optional": false,
|
|
129
|
+
"docs": {
|
|
130
|
+
"tags": [],
|
|
131
|
+
"text": "The placement of the menu."
|
|
132
|
+
},
|
|
133
|
+
"attribute": "placement",
|
|
134
|
+
"reflect": false,
|
|
135
|
+
"defaultValue": "'bottom-start'"
|
|
136
|
+
}
|
|
137
|
+
}; }
|
|
138
|
+
static get events() { return [{
|
|
139
|
+
"method": "catOpen",
|
|
140
|
+
"name": "catOpen",
|
|
141
|
+
"bubbles": true,
|
|
142
|
+
"cancelable": true,
|
|
143
|
+
"composed": true,
|
|
144
|
+
"docs": {
|
|
145
|
+
"tags": [],
|
|
146
|
+
"text": "Emitted when the menu is opened."
|
|
147
|
+
},
|
|
148
|
+
"complexType": {
|
|
149
|
+
"original": "FocusEvent",
|
|
150
|
+
"resolved": "FocusEvent",
|
|
151
|
+
"references": {
|
|
152
|
+
"FocusEvent": {
|
|
153
|
+
"location": "global"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
"method": "catClose",
|
|
159
|
+
"name": "catClose",
|
|
160
|
+
"bubbles": true,
|
|
161
|
+
"cancelable": true,
|
|
162
|
+
"composed": true,
|
|
163
|
+
"docs": {
|
|
164
|
+
"tags": [],
|
|
165
|
+
"text": "Emitted when the menu is closed."
|
|
166
|
+
},
|
|
167
|
+
"complexType": {
|
|
168
|
+
"original": "FocusEvent",
|
|
169
|
+
"resolved": "FocusEvent",
|
|
170
|
+
"references": {
|
|
171
|
+
"FocusEvent": {
|
|
172
|
+
"location": "global"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}]; }
|
|
177
|
+
static get listeners() { return [{
|
|
178
|
+
"name": "catClick",
|
|
179
|
+
"method": "clickHandler",
|
|
180
|
+
"target": undefined,
|
|
181
|
+
"capture": false,
|
|
182
|
+
"passive": false
|
|
183
|
+
}]; }
|
|
184
|
+
}
|
|
185
|
+
CatMenu.OFFSET = 4;
|