@crowdstrike/glide-core 0.27.0 → 0.28.0
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/dropdown.d.ts +11 -10
- package/dist/dropdown.js +94 -97
- package/dist/dropdown.option.d.ts +7 -6
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.styles.js +59 -58
- package/dist/form-controls-layout.d.ts +1 -1
- package/dist/form-controls-layout.js +1 -1
- package/dist/icons/checked.js +1 -1
- package/dist/input.styles.js +9 -7
- package/dist/library/form-control.d.ts +1 -1
- package/dist/library/localize.d.ts +5 -0
- package/dist/menu.button.styles.js +3 -3
- package/dist/menu.link.styles.js +3 -3
- package/dist/menu.options.styles.js +0 -4
- package/dist/slider.d.ts +116 -0
- package/dist/slider.js +168 -0
- package/dist/slider.styles.d.ts +2 -0
- package/dist/slider.styles.js +168 -0
- package/dist/styles/variables.css +1 -1
- package/dist/textarea.styles.js +15 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.d.ts +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.d.ts +1 -1
- package/dist/translations/ja.js +1 -1
- package/package.json +17 -16
package/dist/dropdown.styles.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import{css}from"lit";import
|
2
|
-
${
|
3
|
-
${opacityAndScaleAnimation(".options-and-footer:popover-open")}
|
1
|
+
import{css}from"lit";import opacityAndScaleAnimation from"./styles/opacity-and-scale-animation.js";import visuallyHidden from"./styles/visually-hidden.js";import skeleton from"./styles/skeleton.js";export default[css`
|
2
|
+
${opacityAndScaleAnimation(".options-and-feedback:popover-open")}
|
4
3
|
${skeleton(".loading-feedback")}
|
5
4
|
${visuallyHidden(".item-count")}
|
6
5
|
${visuallyHidden(".selected-option-labels")}
|
@@ -112,8 +111,9 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
112
111
|
}
|
113
112
|
}
|
114
113
|
|
115
|
-
.options-and-
|
114
|
+
.options-and-feedback {
|
116
115
|
--private-border-width: 1px;
|
116
|
+
--private-option-height: 1.75rem;
|
117
117
|
|
118
118
|
background-color: var(
|
119
119
|
--glide-core-private-color-dialog-and-modal-surface-container
|
@@ -140,15 +140,16 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
140
140
|
}
|
141
141
|
|
142
142
|
.options {
|
143
|
-
--private-option-height: 1.75rem;
|
144
|
-
|
145
143
|
box-sizing: border-box;
|
146
144
|
max-block-size: calc(
|
147
145
|
var(--private-option-height) * 9 + var(--glide-core-spacing-base-xxxs) *
|
148
146
|
2 + var(--private-border-width) * 2
|
149
147
|
);
|
150
148
|
overflow: auto;
|
151
|
-
|
149
|
+
|
150
|
+
@media (prefers-reduced-motion: no-preference) {
|
151
|
+
scroll-behavior: smooth;
|
152
|
+
}
|
152
153
|
|
153
154
|
&.hidden {
|
154
155
|
display: none;
|
@@ -157,58 +158,9 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
157
158
|
|
158
159
|
.default-slot {
|
159
160
|
display: block;
|
160
|
-
padding: var(--glide-core-spacing-base-xxxs);
|
161
|
-
}
|
162
|
-
|
163
|
-
.footer {
|
164
|
-
background-color: var(--glide-core-color-static-surface-header);
|
165
|
-
display: none;
|
166
|
-
inline-size: calc(100% - var(--glide-core-spacing-base-xxxs) * 2);
|
167
|
-
inset-block-end: 0;
|
168
|
-
padding: var(--glide-core-spacing-base-xxxs);
|
169
|
-
|
170
|
-
/*
|
171
|
-
"sticky" is a little hack so that footer is absolutely positioned but
|
172
|
-
its space in layout is preserved, so it doesn't overlap the last option.
|
173
|
-
*/
|
174
|
-
position: sticky;
|
175
|
-
|
176
|
-
&.visible {
|
177
|
-
display: block;
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
.add-button {
|
182
|
-
--private-size: 1rem;
|
183
|
-
|
184
|
-
align-items: center;
|
185
|
-
background-color: transparent;
|
186
|
-
border: none;
|
187
|
-
border-radius: var(--glide-core-rounding-base-radius-md);
|
188
|
-
column-gap: 0.625rem;
|
189
|
-
display: flex;
|
190
|
-
font-family: var(--glide-core-typography-family-primary);
|
191
|
-
font-size: var(--glide-core-typography-size-body-default);
|
192
|
-
font-weight: var(--glide-core-typography-weight-regular);
|
193
|
-
inline-size: 100%;
|
194
|
-
line-height: 100%;
|
195
|
-
padding-block: 0.375rem;
|
196
|
-
padding-inline: var(--glide-core-spacing-base-sm);
|
197
|
-
text-align: start;
|
198
|
-
|
199
|
-
&:focus {
|
200
|
-
outline: none;
|
201
|
-
}
|
202
161
|
|
203
|
-
&:
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
&:focus,
|
208
|
-
&:hover {
|
209
|
-
background-color: var(
|
210
|
-
--glide-core-color-interactive-surface-container--hover
|
211
|
-
);
|
162
|
+
&:not(.optionless) {
|
163
|
+
padding: var(--glide-core-spacing-base-xxxs);
|
212
164
|
}
|
213
165
|
}
|
214
166
|
|
@@ -374,6 +326,55 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
374
326
|
}
|
375
327
|
}
|
376
328
|
|
329
|
+
.add-button-container {
|
330
|
+
padding: var(--glide-core-spacing-base-xxxs);
|
331
|
+
|
332
|
+
/*
|
333
|
+
"sticky" is a little hack so it's absolutely positioned but its space
|
334
|
+
in layout is preserved, so it doesn't overlap the last option.
|
335
|
+
*/
|
336
|
+
position: sticky;
|
337
|
+
|
338
|
+
&.bordered {
|
339
|
+
border-block-start: 1px solid
|
340
|
+
var(--glide-core-color-static-stroke-secondary);
|
341
|
+
padding-block-start: var(--glide-core-spacing-base-xxxs);
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
.add-button {
|
346
|
+
align-items: center;
|
347
|
+
background-color: transparent;
|
348
|
+
block-size: var(--private-option-height);
|
349
|
+
border-radius: var(--glide-core-spacing-base-sm);
|
350
|
+
border-width: 0;
|
351
|
+
display: flex;
|
352
|
+
font-family: var(--glide-core-typography-family-primary);
|
353
|
+
font-size: var(--glide-core-typography-size-body-default);
|
354
|
+
inline-size: 100%;
|
355
|
+
max-inline-size: 21.875rem;
|
356
|
+
padding-inline: 0.625rem;
|
357
|
+
transition: background-color 100ms ease-in-out;
|
358
|
+
user-select: none;
|
359
|
+
white-space: nowrap;
|
360
|
+
|
361
|
+
&.active {
|
362
|
+
background-color: var(
|
363
|
+
--glide-core-color-interactive-surface-container--hover
|
364
|
+
);
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
.add-button-label {
|
369
|
+
font-weight: var(--glide-core-typography-weight-bold);
|
370
|
+
overflow-x: hidden;
|
371
|
+
text-overflow: ellipsis;
|
372
|
+
}
|
373
|
+
|
374
|
+
.add-button-description {
|
375
|
+
color: var(--glide-core-color-interactive-text-placeholder);
|
376
|
+
}
|
377
|
+
|
377
378
|
.description {
|
378
379
|
display: block;
|
379
380
|
|
@@ -10,7 +10,7 @@ declare global {
|
|
10
10
|
* @readonly
|
11
11
|
* @attr {string} [version]
|
12
12
|
*
|
13
|
-
* @slot {Checkbox | CheckboxGroup | Dropdown | RadioGroup |
|
13
|
+
* @slot {Checkbox | CheckboxGroup | Dropdown | Input | RadioGroup | Slider | TextArea}
|
14
14
|
*/
|
15
15
|
export default class FormControlsLayout extends LitElement {
|
16
16
|
#private;
|
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(t,o,e,r){var s,i=arguments.length,l=i<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,o,e,r);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(l=(i<3?s(l):i>3?s(o,e,l):s(o,e))||l);return i>3&&l&&Object.defineProperty(o,e,l),l};import{html,LitElement}from"lit";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import packageJson from"../package.json"with{type:"json"};import Checkbox from"./checkbox.js";import CheckboxGroup from"./checkbox-group.js";import Dropdown from"./dropdown.js";import RadioGroup from"./radio-group.js";import
|
1
|
+
var __decorate=this&&this.__decorate||function(t,o,e,r){var s,i=arguments.length,l=i<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,o,e,r);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(l=(i<3?s(l):i>3?s(o,e,l):s(o,e))||l);return i>3&&l&&Object.defineProperty(o,e,l),l};import{html,LitElement}from"lit";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import packageJson from"../package.json"with{type:"json"};import Checkbox from"./checkbox.js";import CheckboxGroup from"./checkbox-group.js";import Dropdown from"./dropdown.js";import Input from"./input.js";import RadioGroup from"./radio-group.js";import Slider from"./slider.js";import TextArea from"./textarea.js";import styles from"./form-controls-layout.styles.js";import assertSlot from"./library/assert-slot.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";let FormControlsLayout=class FormControlsLayout extends LitElement{constructor(){super(...arguments),this.version=packageJson.version,this.#t=createRef(),this.#o="left"}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get split(){return this.#o}set split(t){if(this.#o=t,this.#t.value)for(const t of this.#t.value.assignedElements())"privateSplit"in t&&(t.privateSplit=this.split)}render(){return html`<div class="component"><slot @slotchange="${this.#e}" ${assertSlot([Checkbox,CheckboxGroup,Dropdown,Input,RadioGroup,Slider,TextArea])} ${ref(this.#t)}></slot></div>`}#t;#o;#e(){if(this.#t.value)for(const t of this.#t.value.assignedElements())if("privateSplit"in t&&(t.privateSplit=this.split),"orientation"in t&&"horizontal"!==t.orientation)throw new TypeError("Only horizontal controls are supported.")}};__decorate([property({reflect:!0})],FormControlsLayout.prototype,"split",null),__decorate([property({reflect:!0})],FormControlsLayout.prototype,"version",void 0),FormControlsLayout=__decorate([customElement("glide-core-form-controls-layout"),final],FormControlsLayout);export default FormControlsLayout;
|
package/dist/icons/checked.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{html}from"lit";import{styleMap}from"lit/directives/style-map.js";export default html`<svg aria-hidden="true" fill="none" viewBox="0 0 24 24" style="${styleMap({height:"var(--private-size, 0.875rem)",width:"var(--private-size, 0.875rem)"})}"><path class="check" d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
1
|
+
import{html}from"lit";import{styleMap}from"lit/directives/style-map.js";export default html`<svg aria-hidden="true" fill="none" viewBox="0 0 24 24" style="${styleMap({height:"var(--private-size, 0.875rem)",width:"var(--private-size, 0.875rem)"})}"><path class="check" data-test="check" d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
package/dist/input.styles.js
CHANGED
@@ -42,17 +42,19 @@ import{css}from"lit";import visuallyHidden from"./styles/visually-hidden.js";exp
|
|
42
42
|
display: flex;
|
43
43
|
min-inline-size: 3.75rem;
|
44
44
|
padding-inline: var(--glide-core-spacing-base-sm);
|
45
|
+
transition: border-color 200ms ease-in-out;
|
45
46
|
|
46
|
-
&.focused
|
47
|
-
&:has(.input:hover) {
|
47
|
+
&.focused {
|
48
48
|
border-color: var(--glide-core-color-interactive-stroke-focus);
|
49
|
-
transition: border-color 200ms ease-in-out;
|
50
49
|
}
|
51
50
|
|
52
|
-
&:
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
&:not(.disabled, .error, .readonly) {
|
52
|
+
&:hover,
|
53
|
+
&:has(.input:hover) {
|
54
|
+
border-color: var(
|
55
|
+
--glide-core-color-interactive-stroke-primary--hover
|
56
|
+
);
|
57
|
+
}
|
56
58
|
}
|
57
59
|
|
58
60
|
&.error {
|
@@ -10,7 +10,7 @@ export default interface FormControl {
|
|
10
10
|
summary?: string;
|
11
11
|
tooltip?: string;
|
12
12
|
validity: ValidityState;
|
13
|
-
value: string | string[];
|
13
|
+
value: string | string[] | number[];
|
14
14
|
checkValidity(): boolean;
|
15
15
|
formAssociatedCallback(): void;
|
16
16
|
formResetCallback(): void;
|
@@ -22,6 +22,7 @@ export interface Translation extends DefaultTranslation {
|
|
22
22
|
error: string;
|
23
23
|
informational: string;
|
24
24
|
loading: string;
|
25
|
+
add: string;
|
25
26
|
announcedCharacterCount: (current: number, maximum: number) => string;
|
26
27
|
displayedCharacterCount: (current: number, maximum: number) => string;
|
27
28
|
clearEntry: (label: string) => string;
|
@@ -29,4 +30,8 @@ export interface Translation extends DefaultTranslation {
|
|
29
30
|
editTag: (name: string) => string;
|
30
31
|
removeTag: (name: string) => string;
|
31
32
|
itemCount: (count: string) => string;
|
33
|
+
maximum: (label: string) => string;
|
34
|
+
setMaximum: (label: string) => string;
|
35
|
+
minimum: (label: string) => string;
|
36
|
+
setMinimum: (label: string) => string;
|
32
37
|
}
|
@@ -6,10 +6,10 @@ import{css}from"lit";export default[css`
|
|
6
6
|
border-radius: var(--glide-core-spacing-base-sm);
|
7
7
|
display: flex;
|
8
8
|
font: inherit;
|
9
|
-
gap: var(--
|
9
|
+
gap: var(--glide-core-spacing-base-sm);
|
10
10
|
inline-size: 100%;
|
11
|
-
padding-block: var(--
|
12
|
-
padding-inline: var(--
|
11
|
+
padding-block: var(--glide-core-spacing-base-xxs);
|
12
|
+
padding-inline: var(--glide-core-spacing-base-sm);
|
13
13
|
transition: background-color 100ms ease-in-out;
|
14
14
|
user-select: none;
|
15
15
|
|
package/dist/menu.link.styles.js
CHANGED
@@ -7,10 +7,10 @@ import{css}from"lit";export default[css`
|
|
7
7
|
box-sizing: border-box;
|
8
8
|
display: flex;
|
9
9
|
font: inherit;
|
10
|
-
gap: var(--
|
10
|
+
gap: var(--glide-core-spacing-base-sm);
|
11
11
|
inline-size: 100%;
|
12
|
-
padding-block: var(--
|
13
|
-
padding-inline: var(--
|
12
|
+
padding-block: var(--glide-core-spacing-base-xxs);
|
13
|
+
padding-inline: var(--glide-core-spacing-base-sm);
|
14
14
|
text-decoration: none;
|
15
15
|
transition: background-color 100ms ease-in-out;
|
16
16
|
user-select: none;
|
@@ -7,10 +7,6 @@ import{css}from"lit";import skeleton from"./styles/skeleton.js";export default[c
|
|
7
7
|
}
|
8
8
|
|
9
9
|
.component {
|
10
|
-
--private-gap: var(--glide-core-spacing-base-sm);
|
11
|
-
--private-padding-inline: var(--glide-core-spacing-base-sm);
|
12
|
-
--private-padding-block: var(--glide-core-spacing-base-xxs);
|
13
|
-
|
14
10
|
font-family: var(--glide-core-typography-family-primary);
|
15
11
|
font-size: var(--glide-core-typography-size-body-default);
|
16
12
|
font-weight: var(--glide-core-typography-weight-regular);
|
package/dist/slider.d.ts
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
import './label.js';
|
2
|
+
import { LitElement } from 'lit';
|
3
|
+
import type FormControl from './library/form-control.js';
|
4
|
+
declare global {
|
5
|
+
interface HTMLElementTagNameMap {
|
6
|
+
'glide-core-slider': Slider;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* @attr {string} label
|
11
|
+
* @attr {boolean} [disabled=false]
|
12
|
+
* @attr {boolean} [hide-label=false]
|
13
|
+
* @attr {number} [max=100]
|
14
|
+
* @attr {number} [min=0]
|
15
|
+
* @attr {boolean} [multiple=false]
|
16
|
+
* @attr {string} [name='']
|
17
|
+
* @attr {'horizontal'|'vertical'} [orientation='horizontal']
|
18
|
+
* @attr {boolean} [readonly=false]
|
19
|
+
* @attr {boolean} [required=false]
|
20
|
+
* @attr {number} [step=1]
|
21
|
+
* @attr {string} [tooltip]
|
22
|
+
* @attr {number[]} [value=[]]
|
23
|
+
*
|
24
|
+
* @readonly
|
25
|
+
* @attr {string} [version]
|
26
|
+
*
|
27
|
+
* @slot {Element | string} [description] - Additional information or context
|
28
|
+
*
|
29
|
+
* @fires {Event} change
|
30
|
+
* @fires {Event} input
|
31
|
+
* @fires {Event} invalid
|
32
|
+
*
|
33
|
+
* @readonly
|
34
|
+
* @prop {HTMLFormElement | null} form
|
35
|
+
*
|
36
|
+
* @readonly
|
37
|
+
* @prop {ValidityState} validity
|
38
|
+
*
|
39
|
+
* @method checkValidity
|
40
|
+
* @returns boolean
|
41
|
+
*
|
42
|
+
* @method formAssociatedCallback
|
43
|
+
* @method formResetCallback
|
44
|
+
*
|
45
|
+
* @method reportValidity
|
46
|
+
* @returns boolean
|
47
|
+
*
|
48
|
+
* @method resetValidityFeedback
|
49
|
+
*
|
50
|
+
* @method setCustomValidity
|
51
|
+
* @param {string} message
|
52
|
+
*
|
53
|
+
* @method setValidity
|
54
|
+
* @param {ValidityStateFlags} [flags]
|
55
|
+
* @param {string} [message]
|
56
|
+
*/
|
57
|
+
export default class Slider extends LitElement implements FormControl {
|
58
|
+
#private;
|
59
|
+
static formAssociated: boolean;
|
60
|
+
static shadowRootOptions: ShadowRootInit;
|
61
|
+
static styles: import("lit").CSSResult[];
|
62
|
+
name: string;
|
63
|
+
/**
|
64
|
+
* @default []
|
65
|
+
*/
|
66
|
+
get value(): number[];
|
67
|
+
set value(value: number[]);
|
68
|
+
label?: string;
|
69
|
+
orientation: 'horizontal' | 'vertical';
|
70
|
+
hideLabel: boolean;
|
71
|
+
required: boolean;
|
72
|
+
readonly: boolean;
|
73
|
+
disabled: boolean;
|
74
|
+
/**
|
75
|
+
* @default 100
|
76
|
+
*/
|
77
|
+
get max(): number;
|
78
|
+
set max(max: number);
|
79
|
+
/**
|
80
|
+
* @default 0
|
81
|
+
*/
|
82
|
+
get min(): number;
|
83
|
+
set min(min: number);
|
84
|
+
/**
|
85
|
+
* @default false
|
86
|
+
*/
|
87
|
+
get multiple(): boolean;
|
88
|
+
set multiple(multiple: boolean);
|
89
|
+
/**
|
90
|
+
* @default 1
|
91
|
+
*/
|
92
|
+
get step(): number;
|
93
|
+
set step(step: number);
|
94
|
+
privateSplit?: 'left' | 'middle';
|
95
|
+
readonly version: string;
|
96
|
+
tooltip?: string;
|
97
|
+
get form(): HTMLFormElement | null;
|
98
|
+
get validity(): ValidityState;
|
99
|
+
checkValidity(): boolean;
|
100
|
+
disconnectedCallback(): void;
|
101
|
+
firstUpdated(): void;
|
102
|
+
formAssociatedCallback(): void;
|
103
|
+
formResetCallback(): void;
|
104
|
+
render(): import("lit").TemplateResult<1>;
|
105
|
+
reportValidity(): boolean;
|
106
|
+
resetValidityFeedback(): void;
|
107
|
+
setCustomValidity(message: string): void;
|
108
|
+
setValidity(flags?: ValidityStateFlags, message?: string): void;
|
109
|
+
constructor();
|
110
|
+
private isBlurring;
|
111
|
+
private isCheckingValidity;
|
112
|
+
private isReportValidityOrSubmit;
|
113
|
+
private maximumValue?;
|
114
|
+
private minimumValue?;
|
115
|
+
private validityMessage?;
|
116
|
+
}
|
package/dist/slider.js
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,i,t,a){var s,n=arguments.length,l=n<3?i:null===a?a=Object.getOwnPropertyDescriptor(i,t):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,i,t,a);else for(var m=e.length-1;m>=0;m--)(s=e[m])&&(l=(n<3?s(l):n>3?s(i,t,l):s(i,t))||l);return n>3&&l&&Object.defineProperty(i,t,l),l};import"./label.js";import{html,LitElement}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{when}from"lit/directives/when.js";import packageJson from"../package.json"with{type:"json"};import{LocalizeController}from"./library/localize.js";import styles from"./slider.styles.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let Slider=class Slider extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode,delegatesFocus:!0}}static{this.styles=styles}get value(){return this.multiple&&void 0!==this.minimumValue&&void 0!==this.maximumValue?[this.minimumValue,this.maximumValue]:void 0!==this.minimumValue?[this.minimumValue]:[]}set value(e){if(0===e.length){const e=this.max-this.min;return this.minimumValue=this.min+Math.floor(.25*e),this.maximumValue=this.multiple?this.min+Math.ceil(.75*e):void 0,void this.#e()}if(this.multiple&&2===e.length&&void 0!==e[0]&&void 0!==e[1]){if(e[0]>e[1])throw new Error("The first value must be less than the second.");const i=Math.round(e[0]/this.step)*this.step,t=Math.round(e[1]/this.step)*this.step;return this.minimumValue=Math.max(i,this.min),this.maximumValue=Math.min(t,this.max),void this.#e()}if(this.multiple&&e.length>2)throw new Error("Only two values are allowed when `multiple`.");if(!this.multiple&&e.length>0&&void 0!==e[0]){const i=Math.round(e[0]/this.step)*this.step;return this.minimumValue=Math.max(Math.min(i,this.max),this.min),this.maximumValue=void 0,void this.#e()}}get max(){return this.#i}set max(e){this.#i=e,this.maximumValue=Math.min(this.maximumValue??this.#i,e),void 0!==this.minimumValue&&this.minimumValue>e&&(this.minimumValue=this.multiple&&void 0!==this.maximumValue?Math.min(e,this.maximumValue-this.step):e),this.#e()}get min(){return this.#t}set min(e){this.#t=e,this.minimumValue=Math.max(this.minimumValue??this.#t,e),this.multiple?void 0!==this.maximumValue&&this.maximumValue<e&&(this.maximumValue=Math.max(e,this.minimumValue+this.step)):this.maximumValue=void 0,this.#e()}get multiple(){return this.#a}set multiple(e){const i=this.#a;if(this.#a=e,i&&!e)return this.maximumValue=void 0,void this.updateComplete.then((()=>{this.#e()}));if(!i&&e&&void 0!==this.minimumValue){const e=this.max-this.min,i=this.min+Math.ceil(.75*e);this.minimumValue>=i?(this.maximumValue=this.max,this.minimumValue>=this.maximumValue&&(this.minimumValue=this.maximumValue-this.step)):this.maximumValue=i,this.updateComplete.then((()=>{this.#e()}))}}get step(){return this.#s}set step(e){this.#s=e>0?e:1}get form(){return this.#n.form}get validity(){return this.#n.validity}checkValidity(){this.isCheckingValidity=!0;const e=this.#n.checkValidity();return this.isCheckingValidity=!1,e}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#l),document.removeEventListener("mousemove",this.#m),document.removeEventListener("mouseup",this.#h)}firstUpdated(){if(!this.multiple&&1===this.value.length)return this.minimumValue=this.value.at(0),this.#d=this.value,void this.#e();if(this.multiple&&2===this.value.length)return this.minimumValue=this.value.at(0),this.maximumValue=this.value.at(1),void 0!==this.minimumValue&&void 0!==this.maximumValue&&(this.#d=[this.minimumValue,this.maximumValue]),void this.#e();if(!this.value||0===this.value.length){const e=this.max-this.min;this.minimumValue=this.min+Math.floor(.25*e),this.maximumValue=this.multiple?this.min+Math.ceil(.75*e):void 0,this.#d=this.multiple&&void 0!==this.maximumValue?[this.minimumValue,this.maximumValue]:[this.minimumValue],this.#e()}}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#l.bind(this))}formResetCallback(){this.value=this.#d}render(){return html`
|
2
|
+
<glide-core-private-label
|
3
|
+
class=${classMap({left:"left"===this.privateSplit,middle:"middle"===this.privateSplit})}
|
4
|
+
label=${ifDefined(this.label)}
|
5
|
+
orientation=${this.orientation}
|
6
|
+
split=${ifDefined(this.privateSplit??void 0)}
|
7
|
+
tooltip=${ifDefined(this.tooltip)}
|
8
|
+
?disabled=${this.disabled}
|
9
|
+
?error=${this.#u}
|
10
|
+
?hide=${this.hideLabel}
|
11
|
+
?required=${this.required}
|
12
|
+
>
|
13
|
+
<label>${this.label}</label>
|
14
|
+
|
15
|
+
<div
|
16
|
+
class=${classMap({"slider-container":!0,disabled:this.disabled,readonly:this.readonly&&!this.disabled,error:this.#u})}
|
17
|
+
slot="control"
|
18
|
+
>
|
19
|
+
${when(this.multiple,(()=>html`<input
|
20
|
+
aria-describedby="meta"
|
21
|
+
aria-label=${this.#r.term("setMinimum",this.label)}
|
22
|
+
aria-invalid=${this.#u}
|
23
|
+
class=${classMap({input:!0,disabled:this.disabled,error:this.#u,readonly:this.readonly&&!this.disabled})}
|
24
|
+
data-test="minimum-input"
|
25
|
+
max=${ifDefined(this.maximumValue?this.maximumValue-this.step:void 0)}
|
26
|
+
min=${this.min}
|
27
|
+
step=${this.step}
|
28
|
+
type="number"
|
29
|
+
.value=${this.minimumValue?.toString()??""}
|
30
|
+
?disabled=${this.disabled}
|
31
|
+
?readonly=${this.readonly}
|
32
|
+
@change=${this.#o.bind(this)}
|
33
|
+
@input=${this.#p}
|
34
|
+
@keydown=${this.#c}
|
35
|
+
${ref(this.#v)}
|
36
|
+
/>
|
37
|
+
|
38
|
+
<div class="track-container">
|
39
|
+
<div
|
40
|
+
class=${classMap({"unfilled-track":!0,disabled:this.disabled})}
|
41
|
+
data-test="slider"
|
42
|
+
role="group"
|
43
|
+
@click=${this.#f.bind(this)}
|
44
|
+
${ref(this.#b)}
|
45
|
+
>
|
46
|
+
<div
|
47
|
+
class=${classMap({"filled-track":!0,disabled:this.disabled})}
|
48
|
+
${ref(this.#g)}
|
49
|
+
></div>
|
50
|
+
|
51
|
+
<div
|
52
|
+
aria-disabled=${this.disabled}
|
53
|
+
aria-label=${this.#r.term("minimum",this.label)}
|
54
|
+
aria-readonly=${this.readonly}
|
55
|
+
aria-valuemin=${this.min}
|
56
|
+
aria-valuemax=${this.max}
|
57
|
+
aria-valuenow=${ifDefined(this.minimumValue)}
|
58
|
+
class=${classMap({handle:!0,disabled:this.disabled,readonly:this.readonly&&!this.disabled})}
|
59
|
+
data-test="minimum-handle"
|
60
|
+
role="slider"
|
61
|
+
tabindex="0"
|
62
|
+
@mousedown=${this.#y.bind(this)}
|
63
|
+
@keydown=${this.#V.bind(this)}
|
64
|
+
${ref(this.#x)}
|
65
|
+
></div>
|
66
|
+
|
67
|
+
<div
|
68
|
+
aria-disabled=${this.disabled}
|
69
|
+
aria-label=${this.#r.term("maximum",this.label)}
|
70
|
+
aria-readonly=${this.readonly}
|
71
|
+
aria-valuemin=${this.min}
|
72
|
+
aria-valuemax=${this.max}
|
73
|
+
aria-valuenow=${ifDefined(this.maximumValue)}
|
74
|
+
class=${classMap({handle:!0,disabled:this.disabled,readonly:this.readonly&&!this.disabled})}
|
75
|
+
data-test="maximum-handle"
|
76
|
+
role="slider"
|
77
|
+
tabindex="0"
|
78
|
+
@mousedown=${this.#E.bind(this)}
|
79
|
+
@keydown=${this.#M.bind(this)}
|
80
|
+
${ref(this.#$)}
|
81
|
+
></div>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<input
|
86
|
+
aria-label=${this.#r.term("setMaximum",this.label)}
|
87
|
+
aria-invalid=${this.#u}
|
88
|
+
class=${classMap({input:!0,disabled:this.disabled,error:this.#u,readonly:this.readonly&&!this.disabled})}
|
89
|
+
data-test="maximum-input"
|
90
|
+
max=${this.max}
|
91
|
+
min=${ifDefined(this.minimumValue?this.minimumValue+this.step:void 0)}
|
92
|
+
step=${this.step}
|
93
|
+
type="number"
|
94
|
+
.value=${this.maximumValue?.toString()??""}
|
95
|
+
?disabled=${this.disabled}
|
96
|
+
?readonly=${this.readonly}
|
97
|
+
@change=${this.#R.bind(this)}
|
98
|
+
@input=${this.#w}
|
99
|
+
@keydown=${this.#c}
|
100
|
+
${ref(this.#k)}
|
101
|
+
/>`),(()=>html`<div class="track-container single">
|
102
|
+
<div
|
103
|
+
class=${classMap({"unfilled-track":!0,disabled:this.disabled})}
|
104
|
+
data-test="slider"
|
105
|
+
role="group"
|
106
|
+
@click=${this.#f.bind(this)}
|
107
|
+
${ref(this.#b)}
|
108
|
+
>
|
109
|
+
<div
|
110
|
+
class=${classMap({"filled-track":!0,disabled:this.disabled})}
|
111
|
+
${ref(this.#g)}
|
112
|
+
></div>
|
113
|
+
|
114
|
+
<div
|
115
|
+
aria-describedby="meta"
|
116
|
+
aria-disabled=${this.disabled}
|
117
|
+
aria-label=${ifDefined(this.label)}
|
118
|
+
aria-readonly=${this.readonly}
|
119
|
+
aria-valuemin=${this.min}
|
120
|
+
aria-valuemax=${this.max}
|
121
|
+
aria-valuenow=${ifDefined(this.minimumValue)}
|
122
|
+
class=${classMap({handle:!0,disabled:this.disabled,readonly:this.readonly&&!this.disabled})}
|
123
|
+
data-test="single-handle"
|
124
|
+
role="slider"
|
125
|
+
tabindex="0"
|
126
|
+
@mousedown=${this.#H.bind(this)}
|
127
|
+
@keydown=${this.#S.bind(this)}
|
128
|
+
${ref(this.#D)}
|
129
|
+
></div>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<input
|
134
|
+
aria-label=${ifDefined(this.label)}
|
135
|
+
aria-invalid=${this.#u}
|
136
|
+
class=${classMap({input:!0,disabled:this.disabled,error:this.#u,readonly:this.readonly&&!this.disabled})}
|
137
|
+
data-test="single-input"
|
138
|
+
max=${this.max}
|
139
|
+
min=${this.min}
|
140
|
+
step=${this.step}
|
141
|
+
type="number"
|
142
|
+
.value=${this.minimumValue?.toString()??""}
|
143
|
+
?disabled=${this.disabled}
|
144
|
+
?readonly=${this.readonly}
|
145
|
+
@change=${this.#_.bind(this)}
|
146
|
+
@input=${this.#I.bind(this)}
|
147
|
+
@keydown=${this.#c}
|
148
|
+
${ref(this.#A)}
|
149
|
+
/>`))}
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div class="meta" id="meta" slot="description">
|
153
|
+
<slot
|
154
|
+
class=${classMap({description:!0,hidden:Boolean(this.#u&&this.validityMessage)})}
|
155
|
+
name="description"
|
156
|
+
>
|
157
|
+
<!--
|
158
|
+
Additional information or context
|
159
|
+
@type {Element | string}
|
160
|
+
-->
|
161
|
+
</slot>
|
162
|
+
|
163
|
+
${when(this.#u&&this.validityMessage,(()=>html`<span class="validity-message" data-test="validity-message"
|
164
|
+
>${unsafeHTML(this.validityMessage)}</span
|
165
|
+
>`))}
|
166
|
+
</div>
|
167
|
+
</glide-core-private-label>
|
168
|
+
`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#n.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.isReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#n.setValidity({customError:!1},"",this.#C.value):this.#n.setValidity({customError:!0,patternMismatch:this.#n.validity.patternMismatch,valueMissing:this.#n.validity.valueMissing}," ",this.#C.value)}setValidity(e,i){this.validityMessage=i,this.#n.setValidity(e," ",this.#C.value)}constructor(){super(),this.name="",this.orientation="horizontal",this.hideLabel=!1,this.required=!1,this.readonly=!1,this.disabled=!1,this.version=packageJson.version,this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.#T=!1,this.#d=[],this.#C=createRef(),this.#r=new LocalizeController(this),this.#i=100,this.#$=createRef(),this.#k=createRef(),this.#t=0,this.#x=createRef(),this.#v=createRef(),this.#a=!1,this.#D=createRef(),this.#A=createRef(),this.#b=createRef(),this.#g=createRef(),this.#s=1,this.#m=e=>{e.preventDefault();const i=this.#b.value;if(i&&this.#F){const{clientX:t}=e;if(void 0!==t){const e=i.getBoundingClientRect();this.#L(t,this.#F,e)}}},this.#h=()=>{this.#F&&(document.removeEventListener("mousemove",this.#m),document.removeEventListener("mouseup",this.#h),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.#T=!0,this.#F=void 0,setTimeout((()=>{this.#T=!1})))},this.#n=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#F;#T;#d;#C;#n;#r;#i;#$;#k;#t;#x;#v;#a;#D;#A;#b;#g;#s;get#u(){return!this.disabled&&!this.validity?.valid&&this.isReportValidityOrSubmit}#m;#h;#L(e,i,t){const a=(e-t.left)/t.width*(this.max-this.min)+this.min,s=Math.round(a/this.step)*this.step;if(this.multiple){if(i===this.#x.value&&void 0!==this.maximumValue){const e=Math.min(Math.max(s,this.min),this.maximumValue-this.step);if(e!==this.minimumValue)return this.minimumValue=e,this.#e(),void this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}if(i===this.#$.value&&void 0!==this.minimumValue){const e=Math.min(Math.max(s,this.minimumValue+this.step),this.max);if(e!==this.maximumValue)return this.maximumValue=e,this.#e(),void this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}}else{const e=Math.min(Math.max(s,this.min),this.max);e!==this.minimumValue&&(this.minimumValue=e,this.#e(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))}}#l(e){this.name&&this.value&&!this.disabled&&e.formData.append(this.name,JSON.stringify(this.value))}#c(e){"Enter"===e.key&&this.form?.requestSubmit()}#M(e){this.#$.value&&this.#j(e,this.#$.value)}#E(e){this.#$.value&&this.#K(e,this.#$.value)}#R(){if(this.#k.value&&void 0!==this.minimumValue){const e=Number(this.#k.value.value),i=Math.round(e/this.step)*this.step;this.maximumValue=Math.min(Math.max(i,this.minimumValue+this.step),this.max),this.#e(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}#w(){if(this.#k.value){const e=Number(this.#k.value.value);void 0!==this.minimumValue&&e>=this.minimumValue&&(this.maximumValue=Math.min(e,this.max),this.#e())}}#V(e){this.#x.value&&this.#j(e,this.#x.value)}#y(e){this.#x.value&&this.#K(e,this.#x.value)}#o(){if(this.#v.value&&void 0!==this.maximumValue){const e=Number(this.#v.value.value),i=Math.round(e/this.step)*this.step;this.minimumValue=Math.min(Math.max(i,this.min),this.maximumValue-this.step),this.#e(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}#p(){if(this.#v.value){const e=Number(this.#v.value.value);void 0!==this.maximumValue&&e<=this.maximumValue&&(this.minimumValue=Math.max(e,this.min),this.#e())}}#j(e,i){if(!this.disabled&&!this.readonly&&void 0!==this.minimumValue&&void 0!==this.maximumValue){const t=i===this.#x.value;let a=t?this.minimumValue:this.maximumValue;switch(e.key){case"ArrowLeft":case"ArrowDown":a-=this.step;break;case"ArrowRight":case"ArrowUp":a+=this.step;break;case"PageDown":a-=10*this.step;break;case"PageUp":a+=10*this.step;break;case"Home":a=t?this.min:this.minimumValue+this.step;break;case"End":a=t?this.maximumValue-this.step:this.max;break;case"Enter":return void this.form?.requestSubmit();default:return}e.preventDefault(),t?this.minimumValue=Math.min(Math.max(a,this.min),this.maximumValue-this.step):this.maximumValue=Math.min(Math.max(a,this.minimumValue+this.step),this.max),this.#e(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}#S(e){if(this.disabled||this.readonly)return;if(this.#D.value&&void 0!==this.minimumValue){let i=this.minimumValue;switch(e.key){case"ArrowLeft":case"ArrowDown":i-=this.step;break;case"ArrowRight":case"ArrowUp":i+=this.step;break;case"PageDown":i-=10*this.step;break;case"PageUp":i+=10*this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"Enter":return void this.form?.requestSubmit();default:return}e.preventDefault(),this.minimumValue=Math.min(Math.max(i,this.min),this.max),this.#e(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}#H(e){this.#D.value&&this.#K(e,this.#D.value)}#_(){if(this.#A.value){const e=Number(this.#A.value.value),i=Math.round(e/this.step)*this.step;this.minimumValue=Math.min(Math.max(i,this.min),this.max),this.#e(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}#I(){if(this.#A.value){const e=Number(this.#A.value.value);e>=0&&(this.minimumValue=Math.min(e,this.max),this.#e())}}#f(e){if(this.disabled||this.readonly)return;if(e.target===this.#x.value||e.target===this.#$.value||e.target===this.#D.value||this.#T)return;const i=this.#b.value;if(i){const t=i.getBoundingClientRect(),a=(e.clientX-t.left)/t.width*(this.max-this.min)+this.min,s=Math.round(a/this.step)*this.step;if(this.multiple&&void 0!==this.minimumValue&&void 0!==this.maximumValue){return Math.abs(s-this.minimumValue)<=Math.abs(s-this.maximumValue)?this.minimumValue=Math.min(Math.max(s,this.min),this.maximumValue-this.step):this.maximumValue=Math.min(Math.max(s,this.minimumValue+this.step),this.max),this.#e(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}this.minimumValue=Math.min(Math.max(s,this.min),this.max),this.#e(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}#K(e,i){if(this.disabled||this.readonly)return;e.preventDefault();const t=this.#b.value;t&&(this.#F=i,document.addEventListener("mousemove",this.#m),document.addEventListener("mouseup",this.#h),this.#L(e.clientX,i,t.getBoundingClientRect()))}#e(){const e=this.#g.value,i=this.#D.value,t=this.#x.value,a=this.#$.value;if(e&&void 0!==this.minimumValue){if(!this.multiple&&i){const t=this.max-this.min,a=(this.minimumValue-this.min)/t*100;return i.style.left=`${a}%`,e.style.left="0",void(e.style.width=`${a}%`)}if(void 0!==this.maximumValue&&t&&a){const i=this.max-this.min,s=(this.minimumValue-this.min)/i*100,n=(this.maximumValue-this.min)/i*100;t.style.left=`${s}%`,a.style.left=`${n}%`,e.style.left=`${s}%`,e.style.width=n-s+"%"}}}};__decorate([property({reflect:!0,useDefault:!0})],Slider.prototype,"name",void 0),__decorate([property({type:Array})],Slider.prototype,"value",null),__decorate([property({reflect:!0}),required],Slider.prototype,"label",void 0),__decorate([property({reflect:!0,useDefault:!0})],Slider.prototype,"orientation",void 0),__decorate([property({attribute:"hide-label",type:Boolean})],Slider.prototype,"hideLabel",void 0),__decorate([property({reflect:!0,type:Boolean})],Slider.prototype,"required",void 0),__decorate([property({type:Boolean})],Slider.prototype,"readonly",void 0),__decorate([property({reflect:!0,type:Boolean})],Slider.prototype,"disabled",void 0),__decorate([property({reflect:!0,type:Number})],Slider.prototype,"max",null),__decorate([property({reflect:!0,type:Number})],Slider.prototype,"min",null),__decorate([property({type:Boolean})],Slider.prototype,"multiple",null),__decorate([property({reflect:!0,type:Number,useDefault:!0})],Slider.prototype,"step",null),__decorate([property()],Slider.prototype,"privateSplit",void 0),__decorate([property({reflect:!0})],Slider.prototype,"version",void 0),__decorate([property({reflect:!0})],Slider.prototype,"tooltip",void 0),__decorate([state()],Slider.prototype,"isBlurring",void 0),__decorate([state()],Slider.prototype,"isCheckingValidity",void 0),__decorate([state()],Slider.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],Slider.prototype,"maximumValue",void 0),__decorate([state()],Slider.prototype,"minimumValue",void 0),__decorate([state()],Slider.prototype,"validityMessage",void 0),Slider=__decorate([customElement("glide-core-slider"),final],Slider);export default Slider;
|