@crowdstrike/glide-core 0.29.2 → 0.30.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/accordion.js +240 -1
- package/dist/accordion.styles.js +13 -7
- package/dist/button-group.button.js +143 -1
- package/dist/button-group.button.styles.js +43 -15
- package/dist/button-group.js +249 -1
- package/dist/button-group.styles.js +10 -5
- package/dist/button.js +206 -1
- package/dist/button.styles.js +12 -7
- package/dist/checkbox-group.js +479 -14
- package/dist/checkbox-group.styles.js +5 -2
- package/dist/checkbox.js +519 -32
- package/dist/checkbox.styles.js +10 -5
- package/dist/drawer.js +168 -1
- package/dist/drawer.styles.js +5 -2
- package/dist/dropdown.js +2423 -123
- package/dist/dropdown.option.js +536 -1
- package/dist/dropdown.option.styles.js +5 -2
- package/dist/dropdown.styles.js +15 -8
- package/dist/form-controls-layout.js +102 -1
- package/dist/form-controls-layout.styles.js +5 -2
- package/dist/icon-button.js +139 -1
- package/dist/icon-button.styles.js +19 -7
- package/dist/icons/checked.js +28 -1
- package/dist/icons/chevron.js +21 -1
- package/dist/icons/magnifying-glass.js +23 -1
- package/dist/icons/pencil.js +21 -1
- package/dist/icons/severity-critical.js +20 -1
- package/dist/icons/severity-informational.js +20 -1
- package/dist/icons/severity-medium.js +20 -1
- package/dist/icons/x.js +21 -1
- package/dist/inline-alert.js +118 -1
- package/dist/inline-alert.styles.js +5 -2
- package/dist/input.d.ts +8 -2
- package/dist/input.js +505 -41
- package/dist/input.styles.js +25 -4
- package/dist/label.js +303 -1
- package/dist/label.styles.js +11 -5
- package/dist/library/assert-slot.js +136 -1
- package/dist/library/expect-unhandled-rejection.js +14 -1
- package/dist/library/expect-window-error.js +26 -1
- package/dist/library/final.js +18 -1
- package/dist/library/form-control.js +1 -1
- package/dist/library/localize.js +10 -1
- package/dist/library/mouse.js +35 -1
- package/dist/library/on-resize.js +24 -1
- package/dist/library/required.js +35 -1
- package/dist/library/shadow-root-mode.js +4 -1
- package/dist/library/unique-id.js +3 -1
- package/dist/link.js +92 -1
- package/dist/link.styles.js +10 -5
- package/dist/menu.d.ts +3 -2
- package/dist/menu.js +1259 -1
- package/dist/menu.styles.js +35 -19
- package/dist/modal.d.ts +4 -0
- package/dist/modal.icon-button.js +60 -1
- package/dist/modal.icon-button.styles.js +5 -2
- package/dist/modal.js +473 -1
- package/dist/modal.styles.js +71 -22
- package/dist/option.d.ts +74 -0
- package/dist/option.js +498 -0
- package/dist/option.styles.js +140 -0
- package/dist/{menu.options.d.ts → options.d.ts} +5 -6
- package/dist/options.js +130 -0
- package/dist/options.styles.js +21 -0
- package/dist/popover.js +620 -1
- package/dist/popover.styles.js +11 -5
- package/dist/radio-group.js +624 -17
- package/dist/radio-group.radio.js +211 -1
- package/dist/radio-group.radio.styles.js +9 -4
- package/dist/radio-group.styles.js +5 -2
- package/dist/slider.js +1040 -61
- package/dist/slider.styles.js +9 -4
- package/dist/spinner.js +60 -1
- package/dist/spinner.styles.js +5 -2
- package/dist/split-button.js +116 -1
- package/dist/split-button.primary-button.js +100 -1
- package/dist/split-button.primary-button.styles.js +13 -6
- package/dist/split-button.primary-link.js +102 -1
- package/dist/split-button.secondary-button.d.ts +2 -3
- package/dist/split-button.secondary-button.js +121 -1
- package/dist/split-button.secondary-button.styles.js +12 -7
- package/dist/split-button.styles.js +9 -4
- package/dist/styles/focus-outline.js +9 -3
- package/dist/styles/fonts.css +6 -1
- package/dist/styles/opacity-and-scale-animation.js +6 -3
- package/dist/styles/skeleton.js +6 -3
- package/dist/styles/variables.css +410 -1
- package/dist/styles/visually-hidden.js +6 -3
- package/dist/tab.group.js +386 -1
- package/dist/tab.group.styles.js +5 -2
- package/dist/tab.js +133 -1
- package/dist/tab.panel.js +93 -1
- package/dist/tab.panel.styles.js +11 -5
- package/dist/tab.styles.js +9 -4
- package/dist/tag.js +207 -1
- package/dist/tag.styles.js +10 -5
- package/dist/textarea.js +353 -19
- package/dist/textarea.styles.js +23 -4
- package/dist/toast.js +130 -1
- package/dist/toast.toasts.js +248 -25
- package/dist/toast.toasts.styles.js +9 -4
- package/dist/toggle.js +178 -1
- package/dist/toggle.styles.js +25 -5
- package/dist/tooltip.container.js +130 -1
- package/dist/tooltip.container.styles.js +5 -2
- package/dist/tooltip.js +484 -1
- package/dist/tooltip.styles.js +21 -5
- package/dist/translations/en.js +36 -1
- package/dist/translations/fr.js +37 -1
- package/dist/translations/ja.js +37 -1
- package/package.json +8 -12
- package/dist/menu.button.d.ts +0 -42
- package/dist/menu.button.js +0 -1
- package/dist/menu.button.styles.js +0 -32
- package/dist/menu.link.d.ts +0 -44
- package/dist/menu.link.js +0 -1
- package/dist/menu.link.styles.js +0 -35
- package/dist/menu.options.js +0 -1
- package/dist/menu.options.styles.d.ts +0 -2
- package/dist/menu.options.styles.js +0 -20
- /package/dist/{menu.button.styles.d.ts → option.styles.d.ts} +0 -0
- /package/dist/{menu.link.styles.d.ts → options.styles.d.ts} +0 -0
package/dist/button-group.js
CHANGED
@@ -1 +1,249 @@
|
|
1
|
-
var __decorate
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
import { html, LitElement } from 'lit';
|
8
|
+
import { classMap } from 'lit/directives/class-map.js';
|
9
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
10
|
+
import { customElement, property } from 'lit/decorators.js';
|
11
|
+
import packageJson from '../package.json' with { type: 'json' };
|
12
|
+
import ButtonGroupButton from './button-group.button.js';
|
13
|
+
import styles from './button-group.styles.js';
|
14
|
+
import assertSlot from './library/assert-slot.js';
|
15
|
+
import shadowRootMode from './library/shadow-root-mode.js';
|
16
|
+
import final from './library/final.js';
|
17
|
+
import required from './library/required.js';
|
18
|
+
/**
|
19
|
+
* @attr {string} label - For screenreaders
|
20
|
+
* @attr {'horizontal'|'vertical'} [orientation='horizontal']
|
21
|
+
* @attr {'icon-only'} [variant]
|
22
|
+
*
|
23
|
+
* @readonly
|
24
|
+
* @attr {string} [version]
|
25
|
+
*
|
26
|
+
* @slot {ButtonGroupButton}
|
27
|
+
*/
|
28
|
+
let ButtonGroup = class ButtonGroup extends LitElement {
|
29
|
+
constructor() {
|
30
|
+
super(...arguments);
|
31
|
+
this.version = packageJson.version;
|
32
|
+
this.#defaultSlotElementRef = createRef();
|
33
|
+
this.#orientation = 'horizontal';
|
34
|
+
}
|
35
|
+
static { this.shadowRootOptions = {
|
36
|
+
...LitElement.shadowRootOptions,
|
37
|
+
mode: shadowRootMode,
|
38
|
+
}; }
|
39
|
+
static { this.styles = styles; }
|
40
|
+
/**
|
41
|
+
* @default undefined
|
42
|
+
*/
|
43
|
+
get variant() {
|
44
|
+
return this.#variant;
|
45
|
+
}
|
46
|
+
set variant(variant) {
|
47
|
+
for (const button of this.#buttonElements) {
|
48
|
+
button.privateVariant = variant;
|
49
|
+
}
|
50
|
+
this.#variant = variant;
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* @default 'horizontal'
|
54
|
+
*/
|
55
|
+
get orientation() {
|
56
|
+
return this.#orientation;
|
57
|
+
}
|
58
|
+
set orientation(orientation) {
|
59
|
+
for (const button of this.#buttonElements) {
|
60
|
+
button.privateOrientation = orientation;
|
61
|
+
}
|
62
|
+
this.#orientation = orientation;
|
63
|
+
}
|
64
|
+
render() {
|
65
|
+
return html `
|
66
|
+
<div
|
67
|
+
class=${classMap({
|
68
|
+
component: true,
|
69
|
+
horizontal: this.orientation === 'horizontal',
|
70
|
+
vertical: this.orientation === 'vertical',
|
71
|
+
})}
|
72
|
+
>
|
73
|
+
<div class="label" id="label" data-test="label">${this.label}</div>
|
74
|
+
|
75
|
+
<div
|
76
|
+
aria-labelledby="label"
|
77
|
+
role="radiogroup"
|
78
|
+
class=${classMap({
|
79
|
+
container: true,
|
80
|
+
vertical: this.orientation === 'vertical',
|
81
|
+
})}
|
82
|
+
>
|
83
|
+
<slot
|
84
|
+
@click=${this.#onDefaultSlotClick}
|
85
|
+
@keydown=${this.#onDefaultSlotKeydown}
|
86
|
+
@private-selected=${this.#onDefaultSlotSelected}
|
87
|
+
@slotchange=${this.#onDefaultSlotChange}
|
88
|
+
${assertSlot([ButtonGroupButton])}
|
89
|
+
${ref(this.#defaultSlotElementRef)}
|
90
|
+
>
|
91
|
+
<!--
|
92
|
+
@required
|
93
|
+
@type {ButtonGroupButton}
|
94
|
+
-->
|
95
|
+
</slot>
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
`;
|
99
|
+
}
|
100
|
+
#defaultSlotElementRef;
|
101
|
+
#orientation;
|
102
|
+
#variant;
|
103
|
+
get #buttonElements() {
|
104
|
+
return [...this.querySelectorAll('glide-core-button-group-button')];
|
105
|
+
}
|
106
|
+
#onDefaultSlotChange() {
|
107
|
+
const areMultipleButtonsSelected = this.#buttonElements.filter(({ selected }) => selected).length > 1;
|
108
|
+
if (areMultipleButtonsSelected) {
|
109
|
+
// With form controls where only one control should be selected, like Radio Group
|
110
|
+
// or single-select Dropdown, we allow consumers to set multiple options as
|
111
|
+
// selected: both to match native and because we're able to avoid negative
|
112
|
+
// outcomes, at the form level, by ensuring the `value` of those components only
|
113
|
+
// includes one value.
|
114
|
+
//
|
115
|
+
// Button Group is different because its state doesn't end at a form. Its state is
|
116
|
+
// always represented somewhere else in the application. And, if the data or logic
|
117
|
+
// used to produce Button Group's state results in multiple selected buttons, then
|
118
|
+
// the same data or logic may also produce multiple selected tables or panes, for
|
119
|
+
// example.
|
120
|
+
//
|
121
|
+
// We could easily account for multiple selected buttons, like we do in other
|
122
|
+
// components, by leaving every button selected and only showing the last one as
|
123
|
+
// selected visually. But there's no guarantee that the logic responsible for
|
124
|
+
// showing one table or pane instead of another is the same as Button Group. Maybe
|
125
|
+
// the first selected table or pane is shown. Then there would be a mismatch
|
126
|
+
// between Button Group and another part of the application.
|
127
|
+
//
|
128
|
+
// Long story short, that's why we throw. Because multiple selected buttons
|
129
|
+
// indicates bad downstream data or logic that's likely to have consequences
|
130
|
+
// outside of Button Group.
|
131
|
+
throw new Error('Only one selected Button Group Button is allowed.');
|
132
|
+
}
|
133
|
+
const isButtonAlreadySelected = this.#buttonElements.find(({ disabled, selected }) => !disabled && selected);
|
134
|
+
if (!isButtonAlreadySelected) {
|
135
|
+
const firstEnabledButton = this.#buttonElements.find(({ disabled }) => !disabled);
|
136
|
+
if (firstEnabledButton) {
|
137
|
+
firstEnabledButton.selected = true;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
for (const button of this.#buttonElements) {
|
141
|
+
button.privateVariant = this.variant;
|
142
|
+
if (this.orientation) {
|
143
|
+
button.privateOrientation = this.orientation;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
// This handler could just as well go in Button Group Button. It's here for
|
148
|
+
// consistency, so that Button Group alone manages the state of `selected`.
|
149
|
+
#onDefaultSlotClick(event) {
|
150
|
+
if (event.target instanceof HTMLElement) {
|
151
|
+
const button = event.target.closest('glide-core-button-group-button');
|
152
|
+
// Guards against `button.selected` to prevent duplicate "change" and
|
153
|
+
// "input" events.
|
154
|
+
if (button && !button.disabled && !button.selected) {
|
155
|
+
button.privateSelect();
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
#onDefaultSlotKeydown(event) {
|
160
|
+
const selectedButtonElement = this.querySelector('glide-core-button-group-button[selected]');
|
161
|
+
switch (event.key) {
|
162
|
+
case 'ArrowUp':
|
163
|
+
case 'ArrowLeft': {
|
164
|
+
// Prevent page scroll.
|
165
|
+
event.preventDefault();
|
166
|
+
let previousButton = selectedButtonElement?.previousElementSibling ??
|
167
|
+
this.#buttonElements.at(-1);
|
168
|
+
while (previousButton instanceof ButtonGroupButton) {
|
169
|
+
if (previousButton.disabled) {
|
170
|
+
previousButton =
|
171
|
+
previousButton.previousElementSibling ??
|
172
|
+
this.#buttonElements.at(-1);
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
if (previousButton instanceof ButtonGroupButton) {
|
179
|
+
previousButton.privateSelect();
|
180
|
+
}
|
181
|
+
break;
|
182
|
+
}
|
183
|
+
case 'ArrowDown':
|
184
|
+
case 'ArrowRight': {
|
185
|
+
// Prevent page scroll.
|
186
|
+
event.preventDefault();
|
187
|
+
let nextButton = selectedButtonElement?.nextElementSibling ??
|
188
|
+
this.#buttonElements.at(0);
|
189
|
+
while (nextButton instanceof ButtonGroupButton) {
|
190
|
+
if (nextButton.disabled) {
|
191
|
+
nextButton =
|
192
|
+
nextButton.nextElementSibling ?? this.#buttonElements.at(0);
|
193
|
+
}
|
194
|
+
else {
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
if (nextButton instanceof ButtonGroupButton) {
|
199
|
+
nextButton.privateSelect();
|
200
|
+
}
|
201
|
+
break;
|
202
|
+
}
|
203
|
+
// This is specifically so the VoiceOver user can select and deselect buttons.
|
204
|
+
// Normally only the selected button is tabbable. But VoiceOver can focus
|
205
|
+
// programmatically anything with a `tabindex`.
|
206
|
+
case ' ': {
|
207
|
+
// Prevent page scroll.
|
208
|
+
event.preventDefault();
|
209
|
+
if (event.target instanceof HTMLElement) {
|
210
|
+
const button = event.target.closest('glide-core-button-group-button');
|
211
|
+
if (button && !button.disabled && !button.selected) {
|
212
|
+
button.privateSelect();
|
213
|
+
}
|
214
|
+
}
|
215
|
+
break;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
}
|
219
|
+
#onDefaultSlotSelected(event) {
|
220
|
+
// Guards against the button not being selected so an event for every
|
221
|
+
// deselected button isn't dispatched.
|
222
|
+
if (event.target instanceof ButtonGroupButton && event.target.selected) {
|
223
|
+
for (const button of this.#buttonElements) {
|
224
|
+
if (button !== event.target) {
|
225
|
+
button.selected = false;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
event.target.focus();
|
229
|
+
}
|
230
|
+
}
|
231
|
+
};
|
232
|
+
__decorate([
|
233
|
+
property({ reflect: true }),
|
234
|
+
required
|
235
|
+
], ButtonGroup.prototype, "label", void 0);
|
236
|
+
__decorate([
|
237
|
+
property({ reflect: true })
|
238
|
+
], ButtonGroup.prototype, "variant", null);
|
239
|
+
__decorate([
|
240
|
+
property({ reflect: true, useDefault: true })
|
241
|
+
], ButtonGroup.prototype, "orientation", null);
|
242
|
+
__decorate([
|
243
|
+
property({ reflect: true })
|
244
|
+
], ButtonGroup.prototype, "version", void 0);
|
245
|
+
ButtonGroup = __decorate([
|
246
|
+
customElement('glide-core-button-group'),
|
247
|
+
final
|
248
|
+
], ButtonGroup);
|
249
|
+
export default ButtonGroup;
|
@@ -1,9 +1,13 @@
|
|
1
|
-
import{css}from
|
2
|
-
|
3
|
-
|
1
|
+
import { css } from 'lit';
|
2
|
+
import visuallyHidden from './styles/visually-hidden.js';
|
3
|
+
export default [
|
4
|
+
css `
|
5
|
+
${visuallyHidden('.label')}
|
6
|
+
`,
|
7
|
+
css `
|
4
8
|
.component {
|
5
9
|
border: 1px solid var(--glide-core-color-interactive-stroke-primary);
|
6
|
-
border-radius: var(--glide-core-
|
10
|
+
border-radius: var(--glide-core-rounding-base-radius-sm);
|
7
11
|
display: inline-block;
|
8
12
|
}
|
9
13
|
|
@@ -27,4 +31,5 @@ import{css}from"lit";import visuallyHidden from"./styles/visually-hidden.js";exp
|
|
27
31
|
flex-direction: column;
|
28
32
|
}
|
29
33
|
}
|
30
|
-
|
34
|
+
`,
|
35
|
+
];
|
package/dist/button.js
CHANGED
@@ -1 +1,206 @@
|
|
1
|
-
var __decorate
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
import './tooltip.js';
|
8
|
+
import { html, LitElement } from 'lit';
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
10
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
11
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
12
|
+
import packageJson from '../package.json' with { type: 'json' };
|
13
|
+
import styles from './button.styles.js';
|
14
|
+
import shadowRootMode from './library/shadow-root-mode.js';
|
15
|
+
import final from './library/final.js';
|
16
|
+
import required from './library/required.js';
|
17
|
+
/**
|
18
|
+
* @attr {string} label
|
19
|
+
* @attr {string|null} [aria-description=null]
|
20
|
+
* @attr {boolean} [disabled=false]
|
21
|
+
* @attr {string} [name='']
|
22
|
+
* @attr {'large'|'small'} [size='large']
|
23
|
+
* @attr {string} [tooltip]
|
24
|
+
* @attr {'button'|'submit'|'reset'} [type='button']
|
25
|
+
* @attr {string} [value='']
|
26
|
+
* @attr {'primary'|'secondary'|'tertiary'} [variant='primary']
|
27
|
+
*
|
28
|
+
* @readonly
|
29
|
+
* @attr {string} [version]
|
30
|
+
*
|
31
|
+
* @slot {Element} [prefix-icon] - An icon before the label
|
32
|
+
* @slot {Element} [suffix-icon] - An icon after the label
|
33
|
+
*
|
34
|
+
* @readonly
|
35
|
+
* @prop {HTMLFormElement | null} form
|
36
|
+
*/
|
37
|
+
let Button = class Button extends LitElement {
|
38
|
+
static { this.formAssociated = true; }
|
39
|
+
static { this.shadowRootOptions = {
|
40
|
+
...LitElement.shadowRootOptions,
|
41
|
+
delegatesFocus: true,
|
42
|
+
mode: shadowRootMode,
|
43
|
+
}; }
|
44
|
+
static { this.styles = styles; }
|
45
|
+
// A getter and setter because Lit Analzyer doesn't recognize "aria-description"
|
46
|
+
// as a valid attribute on the `<button>` and doesn't provide a way to selectively
|
47
|
+
// disable rules.
|
48
|
+
/**
|
49
|
+
* @default null
|
50
|
+
*/
|
51
|
+
get ariaDescription() {
|
52
|
+
return this.#ariaDescription;
|
53
|
+
}
|
54
|
+
set ariaDescription(description) {
|
55
|
+
this.#ariaDescription = description;
|
56
|
+
if (this.#buttonElementRef.value) {
|
57
|
+
this.#buttonElementRef.value.ariaDescription = description;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
get form() {
|
61
|
+
return this.#internals.form;
|
62
|
+
}
|
63
|
+
click() {
|
64
|
+
this.#buttonElementRef.value?.click();
|
65
|
+
}
|
66
|
+
firstUpdated() {
|
67
|
+
if (this.#buttonElementRef.value && this.ariaDescription) {
|
68
|
+
this.#buttonElementRef.value.ariaDescription = this.ariaDescription;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
render() {
|
72
|
+
return html `<glide-core-tooltip
|
73
|
+
label=${this.tooltip ?? ''}
|
74
|
+
?disabled=${!this.disabled || !this.tooltip}
|
75
|
+
>
|
76
|
+
<button
|
77
|
+
aria-disabled=${this.disabled ? 'true' : 'false'}
|
78
|
+
class=${classMap({
|
79
|
+
component: true,
|
80
|
+
primary: this.variant === 'primary',
|
81
|
+
secondary: this.variant === 'secondary',
|
82
|
+
tertiary: this.variant === 'tertiary',
|
83
|
+
large: this.size === 'large',
|
84
|
+
small: this.size === 'small',
|
85
|
+
disabled: this.disabled,
|
86
|
+
'prefix-icon': this.hasPrefixIcon,
|
87
|
+
'suffix-icon': this.hasSuffixIcon,
|
88
|
+
})}
|
89
|
+
data-test="button"
|
90
|
+
slot="target"
|
91
|
+
@click=${this.#onClick}
|
92
|
+
${ref(this.#buttonElementRef)}
|
93
|
+
>
|
94
|
+
<slot
|
95
|
+
name="prefix-icon"
|
96
|
+
@slotchange=${this.#onPrefixIconSlotChange}
|
97
|
+
${ref(this.#prefixIconSlotElementRef)}
|
98
|
+
>
|
99
|
+
<!--
|
100
|
+
An icon before the label
|
101
|
+
@type {Element}
|
102
|
+
-->
|
103
|
+
</slot>
|
104
|
+
|
105
|
+
${this.label}
|
106
|
+
|
107
|
+
<slot
|
108
|
+
name="suffix-icon"
|
109
|
+
@slotchange=${this.#onSuffixIconSlotChange}
|
110
|
+
${ref(this.#suffixIconSlotElementRef)}
|
111
|
+
>
|
112
|
+
<!--
|
113
|
+
An icon after the label
|
114
|
+
@type {Element}
|
115
|
+
-->
|
116
|
+
</slot>
|
117
|
+
</button>
|
118
|
+
</glide-core-tooltip>`;
|
119
|
+
}
|
120
|
+
constructor() {
|
121
|
+
super();
|
122
|
+
this.disabled = false;
|
123
|
+
this.name = '';
|
124
|
+
this.size = 'large';
|
125
|
+
this.type = 'button';
|
126
|
+
this.value = '';
|
127
|
+
this.variant = 'primary';
|
128
|
+
this.version = packageJson.version;
|
129
|
+
this.hasPrefixIcon = false;
|
130
|
+
this.hasSuffixIcon = false;
|
131
|
+
this.#ariaDescription = null;
|
132
|
+
this.#buttonElementRef = createRef();
|
133
|
+
this.#prefixIconSlotElementRef = createRef();
|
134
|
+
this.#suffixIconSlotElementRef = createRef();
|
135
|
+
this.#internals = this.attachInternals();
|
136
|
+
}
|
137
|
+
#ariaDescription;
|
138
|
+
#buttonElementRef;
|
139
|
+
#internals;
|
140
|
+
#prefixIconSlotElementRef;
|
141
|
+
#suffixIconSlotElementRef;
|
142
|
+
#onClick(event) {
|
143
|
+
if (this.disabled) {
|
144
|
+
event.stopPropagation();
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
if (this.type === 'submit') {
|
148
|
+
this.form?.requestSubmit();
|
149
|
+
return;
|
150
|
+
}
|
151
|
+
if (this.type === 'reset') {
|
152
|
+
this.form?.reset();
|
153
|
+
return;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
#onPrefixIconSlotChange() {
|
157
|
+
const assignedNodes = this.#prefixIconSlotElementRef.value?.assignedNodes();
|
158
|
+
this.hasPrefixIcon = Boolean(assignedNodes && assignedNodes.length > 0);
|
159
|
+
}
|
160
|
+
#onSuffixIconSlotChange() {
|
161
|
+
const assignedNodes = this.#suffixIconSlotElementRef.value?.assignedNodes();
|
162
|
+
this.hasSuffixIcon = Boolean(assignedNodes && assignedNodes.length > 0);
|
163
|
+
}
|
164
|
+
};
|
165
|
+
__decorate([
|
166
|
+
property({ reflect: true }),
|
167
|
+
required
|
168
|
+
], Button.prototype, "label", void 0);
|
169
|
+
__decorate([
|
170
|
+
property({ attribute: 'aria-description', reflect: true })
|
171
|
+
], Button.prototype, "ariaDescription", null);
|
172
|
+
__decorate([
|
173
|
+
property({ type: Boolean, reflect: true })
|
174
|
+
], Button.prototype, "disabled", void 0);
|
175
|
+
__decorate([
|
176
|
+
property({ reflect: true, useDefault: true })
|
177
|
+
], Button.prototype, "name", void 0);
|
178
|
+
__decorate([
|
179
|
+
property({ reflect: true, useDefault: true })
|
180
|
+
], Button.prototype, "size", void 0);
|
181
|
+
__decorate([
|
182
|
+
property({ reflect: true })
|
183
|
+
], Button.prototype, "tooltip", void 0);
|
184
|
+
__decorate([
|
185
|
+
property({ reflect: true, useDefault: true })
|
186
|
+
], Button.prototype, "type", void 0);
|
187
|
+
__decorate([
|
188
|
+
property({ reflect: true, useDefault: true })
|
189
|
+
], Button.prototype, "value", void 0);
|
190
|
+
__decorate([
|
191
|
+
property({ reflect: true, useDefault: true })
|
192
|
+
], Button.prototype, "variant", void 0);
|
193
|
+
__decorate([
|
194
|
+
property({ reflect: true })
|
195
|
+
], Button.prototype, "version", void 0);
|
196
|
+
__decorate([
|
197
|
+
state()
|
198
|
+
], Button.prototype, "hasPrefixIcon", void 0);
|
199
|
+
__decorate([
|
200
|
+
state()
|
201
|
+
], Button.prototype, "hasSuffixIcon", void 0);
|
202
|
+
Button = __decorate([
|
203
|
+
customElement('glide-core-button'),
|
204
|
+
final
|
205
|
+
], Button);
|
206
|
+
export default Button;
|
package/dist/button.styles.js
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
import{css}from
|
2
|
-
|
3
|
-
|
1
|
+
import { css } from 'lit';
|
2
|
+
import focusOutline from './styles/focus-outline.js';
|
3
|
+
export default [
|
4
|
+
css `
|
5
|
+
${focusOutline('.component:focus-visible')}
|
6
|
+
`,
|
7
|
+
css `
|
4
8
|
:host {
|
5
9
|
/* Contains elements with "padding" and "width". Inline by default. */
|
6
10
|
display: inline-block;
|
@@ -9,7 +13,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
9
13
|
.component {
|
10
14
|
align-items: center;
|
11
15
|
border-color: transparent;
|
12
|
-
border-radius: var(--glide-core-rounding-base-radius-
|
16
|
+
border-radius: var(--glide-core-rounding-base-radius-sm);
|
13
17
|
border-style: solid;
|
14
18
|
border-width: 1px;
|
15
19
|
cursor: pointer;
|
@@ -20,9 +24,9 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
20
24
|
justify-content: center;
|
21
25
|
padding-block: var(--glide-core-spacing-base-xs);
|
22
26
|
padding-inline: var(--glide-core-spacing-base-md);
|
23
|
-
transition-duration:
|
27
|
+
transition-duration: var(--glide-core-duration-moderate-02);
|
24
28
|
transition-property: color, background-color, border-color, fill, stroke;
|
25
|
-
transition-timing-function:
|
29
|
+
transition-timing-function: var(--glide-core-animation-swoop-in);
|
26
30
|
user-select: none;
|
27
31
|
|
28
32
|
&:focus {
|
@@ -143,4 +147,5 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
143
147
|
min-inline-size: 2.5625rem;
|
144
148
|
}
|
145
149
|
}
|
146
|
-
|
150
|
+
`,
|
151
|
+
];
|