@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.
Files changed (122) hide show
  1. package/dist/accordion.js +240 -1
  2. package/dist/accordion.styles.js +13 -7
  3. package/dist/button-group.button.js +143 -1
  4. package/dist/button-group.button.styles.js +43 -15
  5. package/dist/button-group.js +249 -1
  6. package/dist/button-group.styles.js +10 -5
  7. package/dist/button.js +206 -1
  8. package/dist/button.styles.js +12 -7
  9. package/dist/checkbox-group.js +479 -14
  10. package/dist/checkbox-group.styles.js +5 -2
  11. package/dist/checkbox.js +519 -32
  12. package/dist/checkbox.styles.js +10 -5
  13. package/dist/drawer.js +168 -1
  14. package/dist/drawer.styles.js +5 -2
  15. package/dist/dropdown.js +2423 -123
  16. package/dist/dropdown.option.js +536 -1
  17. package/dist/dropdown.option.styles.js +5 -2
  18. package/dist/dropdown.styles.js +15 -8
  19. package/dist/form-controls-layout.js +102 -1
  20. package/dist/form-controls-layout.styles.js +5 -2
  21. package/dist/icon-button.js +139 -1
  22. package/dist/icon-button.styles.js +19 -7
  23. package/dist/icons/checked.js +28 -1
  24. package/dist/icons/chevron.js +21 -1
  25. package/dist/icons/magnifying-glass.js +23 -1
  26. package/dist/icons/pencil.js +21 -1
  27. package/dist/icons/severity-critical.js +20 -1
  28. package/dist/icons/severity-informational.js +20 -1
  29. package/dist/icons/severity-medium.js +20 -1
  30. package/dist/icons/x.js +21 -1
  31. package/dist/inline-alert.js +118 -1
  32. package/dist/inline-alert.styles.js +5 -2
  33. package/dist/input.d.ts +8 -2
  34. package/dist/input.js +505 -41
  35. package/dist/input.styles.js +25 -4
  36. package/dist/label.js +303 -1
  37. package/dist/label.styles.js +11 -5
  38. package/dist/library/assert-slot.js +136 -1
  39. package/dist/library/expect-unhandled-rejection.js +14 -1
  40. package/dist/library/expect-window-error.js +26 -1
  41. package/dist/library/final.js +18 -1
  42. package/dist/library/form-control.js +1 -1
  43. package/dist/library/localize.js +10 -1
  44. package/dist/library/mouse.js +35 -1
  45. package/dist/library/on-resize.js +24 -1
  46. package/dist/library/required.js +35 -1
  47. package/dist/library/shadow-root-mode.js +4 -1
  48. package/dist/library/unique-id.js +3 -1
  49. package/dist/link.js +92 -1
  50. package/dist/link.styles.js +10 -5
  51. package/dist/menu.d.ts +3 -2
  52. package/dist/menu.js +1259 -1
  53. package/dist/menu.styles.js +35 -19
  54. package/dist/modal.d.ts +4 -0
  55. package/dist/modal.icon-button.js +60 -1
  56. package/dist/modal.icon-button.styles.js +5 -2
  57. package/dist/modal.js +473 -1
  58. package/dist/modal.styles.js +71 -22
  59. package/dist/option.d.ts +74 -0
  60. package/dist/option.js +498 -0
  61. package/dist/option.styles.js +140 -0
  62. package/dist/{menu.options.d.ts → options.d.ts} +5 -6
  63. package/dist/options.js +130 -0
  64. package/dist/options.styles.js +21 -0
  65. package/dist/popover.js +620 -1
  66. package/dist/popover.styles.js +11 -5
  67. package/dist/radio-group.js +624 -17
  68. package/dist/radio-group.radio.js +211 -1
  69. package/dist/radio-group.radio.styles.js +9 -4
  70. package/dist/radio-group.styles.js +5 -2
  71. package/dist/slider.js +1040 -61
  72. package/dist/slider.styles.js +9 -4
  73. package/dist/spinner.js +60 -1
  74. package/dist/spinner.styles.js +5 -2
  75. package/dist/split-button.js +116 -1
  76. package/dist/split-button.primary-button.js +100 -1
  77. package/dist/split-button.primary-button.styles.js +13 -6
  78. package/dist/split-button.primary-link.js +102 -1
  79. package/dist/split-button.secondary-button.d.ts +2 -3
  80. package/dist/split-button.secondary-button.js +121 -1
  81. package/dist/split-button.secondary-button.styles.js +12 -7
  82. package/dist/split-button.styles.js +9 -4
  83. package/dist/styles/focus-outline.js +9 -3
  84. package/dist/styles/fonts.css +6 -1
  85. package/dist/styles/opacity-and-scale-animation.js +6 -3
  86. package/dist/styles/skeleton.js +6 -3
  87. package/dist/styles/variables.css +410 -1
  88. package/dist/styles/visually-hidden.js +6 -3
  89. package/dist/tab.group.js +386 -1
  90. package/dist/tab.group.styles.js +5 -2
  91. package/dist/tab.js +133 -1
  92. package/dist/tab.panel.js +93 -1
  93. package/dist/tab.panel.styles.js +11 -5
  94. package/dist/tab.styles.js +9 -4
  95. package/dist/tag.js +207 -1
  96. package/dist/tag.styles.js +10 -5
  97. package/dist/textarea.js +353 -19
  98. package/dist/textarea.styles.js +23 -4
  99. package/dist/toast.js +130 -1
  100. package/dist/toast.toasts.js +248 -25
  101. package/dist/toast.toasts.styles.js +9 -4
  102. package/dist/toggle.js +178 -1
  103. package/dist/toggle.styles.js +25 -5
  104. package/dist/tooltip.container.js +130 -1
  105. package/dist/tooltip.container.styles.js +5 -2
  106. package/dist/tooltip.js +484 -1
  107. package/dist/tooltip.styles.js +21 -5
  108. package/dist/translations/en.js +36 -1
  109. package/dist/translations/fr.js +37 -1
  110. package/dist/translations/ja.js +37 -1
  111. package/package.json +8 -12
  112. package/dist/menu.button.d.ts +0 -42
  113. package/dist/menu.button.js +0 -1
  114. package/dist/menu.button.styles.js +0 -32
  115. package/dist/menu.link.d.ts +0 -44
  116. package/dist/menu.link.js +0 -1
  117. package/dist/menu.link.styles.js +0 -35
  118. package/dist/menu.options.js +0 -1
  119. package/dist/menu.options.styles.d.ts +0 -2
  120. package/dist/menu.options.styles.js +0 -20
  121. /package/dist/{menu.button.styles.d.ts → option.styles.d.ts} +0 -0
  122. /package/dist/{menu.link.styles.d.ts → options.styles.d.ts} +0 -0
package/dist/checkbox.js CHANGED
@@ -1,14 +1,220 @@
1
- var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(r<3?a(o):r>3?a(t,i,o):a(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};import"./label.js";import"./tooltip.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{styleMap}from"lit/directives/style-map.js";import{when}from"lit/directives/when.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import packageJson from"../package.json"with{type:"json"};import checkedIcon from"./icons/checked.js";import styles from"./checkbox.styles.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let Checkbox=class Checkbox extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get label(){return this.#e}set label(e){this.#e=e,setTimeout((()=>{this.#t()}))}get checked(){return this.#i}set checked(e){const t=e!==this.#i;this.#i=e,t&&this.dispatchEvent(new Event("private-checked-change",{bubbles:!0}))}get disabled(){return this.#s}set disabled(e){this.#s=e,this.dispatchEvent(new Event("private-disabled-change",{bubbles:!0}))}get value(){return this.#a}set value(e){const t=this.#a;this.#a=e,this.dispatchEvent(new CustomEvent("private-value-change",{bubbles:!0,detail:{old:t,new:e}}))}get form(){return this.#r.form}checkValidity(){this.isCheckingValidity=!0;const e=this.#r.checkValidity();return this.isCheckingValidity=!1,e}click(){this.#o.value?.click()}connectedCallback(){super.connectedCallback(),this.#l=new IntersectionObserver((()=>{this.checkVisibility()&&this.#t()})),this.#l.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#n),this.#l?.disconnect()}get validity(){return"minimal"===this.privateVariant?this.#r.validity:this.required&&!this.checked?(this.#r.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.#o.value),this.#r.validity):this.required&&this.#r.validity.valueMissing&&this.checked?(this.#r.setValidity({}),this.#r.validity):(this.required||!this.#r.validity.valueMissing||this.checked||this.#r.setValidity({}),this.#r.validity)}focus(e){this.#o.value?.focus(e)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#n)}formResetCallback(){this.checked=""===this.getAttribute("checked"),this.indeterminate=""===this.getAttribute("indeterminate")}render(){return html`<div class="component" data-test="component">
2
- ${when("minimal"===this.privateVariant,(()=>html`
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 './label.js';
8
+ import './tooltip.js';
9
+ import { html, LitElement } from 'lit';
10
+ import { classMap } from 'lit/directives/class-map.js';
11
+ import { createRef, ref } from 'lit/directives/ref.js';
12
+ import { customElement, property, state } from 'lit/decorators.js';
13
+ import { ifDefined } from 'lit/directives/if-defined.js';
14
+ import { styleMap } from 'lit/directives/style-map.js';
15
+ import { when } from 'lit/directives/when.js';
16
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
17
+ import packageJson from '../package.json' with { type: 'json' };
18
+ import checkedIcon from './icons/checked.js';
19
+ import styles from './checkbox.styles.js';
20
+ import shadowRootMode from './library/shadow-root-mode.js';
21
+ import final from './library/final.js';
22
+ import required from './library/required.js';
23
+ /**
24
+ * @attr {string} label
25
+ * @attr {boolean} [checked=false]
26
+ * @attr {boolean} [disabled=false]
27
+ * @attr {boolean} [hide-label=false]
28
+ * @attr {boolean} [indeterminate=false]
29
+ * @attr {string} [name='']
30
+ * @attr {'horizontal'|'vertical'} [orientation='horizontal']
31
+ * @attr {boolean} [required=false]
32
+ * @attr {string} [summary]
33
+ * @attr {string} [tooltip]
34
+ * @attr {string} [value='']
35
+ *
36
+ * @readonly
37
+ * @attr {string} [version]
38
+ *
39
+ * @slot {Element | string} [description] - Additional information or context
40
+ * @slot {Element} [private-icon]
41
+ *
42
+ * @fires {Event} change
43
+ * @fires {Event} invalid
44
+ *
45
+ * @readonly
46
+ * @prop {HTMLFormElement | null} form
47
+ *
48
+ * @readonly
49
+ * @prop {ValidityState} validity
50
+ *
51
+ * @method checkValidity
52
+ * @returns boolean
53
+ *
54
+ * @method formAssociatedCallback
55
+ * @method formResetCallback
56
+ *
57
+ * @method reportValidity
58
+ * @returns boolean
59
+ *
60
+ * @method resetValidityFeedback
61
+ *
62
+ * @method setCustomValidity
63
+ * @param {string} message
64
+ *
65
+ * @method setValidity
66
+ * @param {ValidityStateFlags} [flags]
67
+ * @param {string} [message]
68
+ */
69
+ let Checkbox = class Checkbox extends LitElement {
70
+ static { this.formAssociated = true; }
71
+ static { this.shadowRootOptions = {
72
+ ...LitElement.shadowRootOptions,
73
+ mode: shadowRootMode,
74
+ }; }
75
+ static { this.styles = styles; }
76
+ /**
77
+ * @default undefined
78
+ */
79
+ get label() {
80
+ return this.#label;
81
+ }
82
+ set label(label) {
83
+ this.#label = label;
84
+ // Wait for the label to render. A rerender won't be scheduled by Lit
85
+ // until after this setter finishes. So awaiting `this.updateComplete`
86
+ // won't fly.
87
+ setTimeout(() => {
88
+ this.#updateLabelOverflow();
89
+ });
90
+ }
91
+ /**
92
+ @default false
93
+ */
94
+ get checked() {
95
+ return this.#isChecked;
96
+ }
97
+ set checked(isChecked) {
98
+ const hasChanged = isChecked !== this.#isChecked;
99
+ this.#isChecked = isChecked;
100
+ if (hasChanged) {
101
+ this.dispatchEvent(new Event('private-checked-change', { bubbles: true }));
102
+ }
103
+ }
104
+ /**
105
+ * @default false
106
+ */
107
+ get disabled() {
108
+ return this.#isDisabled;
109
+ }
110
+ set disabled(isDisabled) {
111
+ this.#isDisabled = isDisabled;
112
+ this.dispatchEvent(new Event('private-disabled-change', { bubbles: true }));
113
+ }
114
+ /**
115
+ * @default ''
116
+ */
117
+ get value() {
118
+ return this.#value;
119
+ }
120
+ set value(value) {
121
+ const old = this.#value;
122
+ this.#value = value;
123
+ // `this.value` can be set programmatically. Checkbox Group needs to know when
124
+ // that happens so it can update its own `this.value`.
125
+ this.dispatchEvent(new CustomEvent('private-value-change', {
126
+ bubbles: true,
127
+ detail: {
128
+ // Without knowing what the old value was, Checkbox Group would be unable to
129
+ // find the value in its `this.value` array and remove it.
130
+ old,
131
+ new: value,
132
+ },
133
+ }));
134
+ }
135
+ get form() {
136
+ return this.#internals.form;
137
+ }
138
+ checkValidity() {
139
+ this.isCheckingValidity = true;
140
+ const isValid = this.#internals.checkValidity();
141
+ this.isCheckingValidity = false;
142
+ return isValid;
143
+ }
144
+ click() {
145
+ this.#inputElementRef.value?.click();
146
+ }
147
+ connectedCallback() {
148
+ super.connectedCallback();
149
+ // Checkbox can be arbitrarily shown and hidden as it is in Dropdown. So calling
150
+ // `#updateLabelOverflow` in the `label` setter isn't sufficient because the
151
+ // label's `scrollWidth` and `clientWidth` will both be zero until Checkbox is
152
+ // visible. So, rather than Checkbox expose a pseudo-private method, Checkbox
153
+ // simply monitors its own visibility.
154
+ this.#intersectionObserver = new IntersectionObserver(() => {
155
+ if (this.checkVisibility()) {
156
+ this.#updateLabelOverflow();
157
+ }
158
+ });
159
+ this.#intersectionObserver.observe(this);
160
+ }
161
+ disconnectedCallback() {
162
+ super.disconnectedCallback();
163
+ this.form?.removeEventListener('formdata', this.#onFormdata);
164
+ this.#intersectionObserver?.disconnect();
165
+ }
166
+ get validity() {
167
+ // If we're in a Checkbox Group, `disabled`, `required`, and whether or not
168
+ // the form has been submitted don't apply because Checkbox Group handles those
169
+ // states for the group as a whole.
170
+ if (this.privateVariant === 'minimal') {
171
+ return this.#internals.validity;
172
+ }
173
+ if (this.required && !this.checked) {
174
+ // A validation message is required but unused because we disable native validation
175
+ // feedback. And an empty string isn't allowed. Thus a single space.
176
+ this.#internals.setValidity({ customError: Boolean(this.validityMessage), valueMissing: true }, ' ', this.#inputElementRef.value);
177
+ return this.#internals.validity;
178
+ }
179
+ if (this.required &&
180
+ this.#internals.validity.valueMissing &&
181
+ this.checked) {
182
+ this.#internals.setValidity({});
183
+ return this.#internals.validity;
184
+ }
185
+ if (!this.required &&
186
+ this.#internals.validity.valueMissing &&
187
+ !this.checked) {
188
+ this.#internals.setValidity({});
189
+ return this.#internals.validity;
190
+ }
191
+ return this.#internals.validity;
192
+ }
193
+ focus(options) {
194
+ this.#inputElementRef.value?.focus(options);
195
+ }
196
+ formAssociatedCallback() {
197
+ this.form?.addEventListener('formdata', this.#onFormdata);
198
+ }
199
+ formResetCallback() {
200
+ this.checked = this.getAttribute('checked') === '';
201
+ this.indeterminate = this.getAttribute('indeterminate') === '';
202
+ }
203
+ render() {
204
+ return html `<div class="component" data-test="component">
205
+ ${when(this.privateVariant === 'minimal', () => html `
3
206
  <label
4
207
  class="label-and-input-and-checkbox"
5
208
  part="private-label-and-input-and-checkbox"
6
209
  >
7
210
  <div
8
- class=${classMap({"input-and-checkbox":!0,disabled:this.disabled})}
211
+ class=${classMap({
212
+ 'input-and-checkbox': true,
213
+ disabled: this.disabled,
214
+ })}
9
215
  >
10
216
  <input
11
- aria-invalid=${this.#d}
217
+ aria-invalid=${this.#isShowValidationFeedback}
12
218
  class="input"
13
219
  data-test="input"
14
220
  type="checkbox"
@@ -16,14 +222,17 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
16
222
  .inert=${this.privateInternallyInert}
17
223
  ?disabled=${this.disabled}
18
224
  ?required=${this.required}
19
- @change=${this.#h}
20
- @input=${this.#h}
21
- @keydown=${this.#c}
22
- ${ref(this.#o)}
225
+ @change=${this.#onInputChangeOrInput}
226
+ @input=${this.#onInputChangeOrInput}
227
+ @keydown=${this.#onInputKeydown}
228
+ ${ref(this.#inputElementRef)}
23
229
  />
24
230
 
25
231
  <div
26
- class=${classMap({checkbox:!0,disabled:this.disabled})}
232
+ class=${classMap({
233
+ checkbox: true,
234
+ disabled: this.disabled,
235
+ })}
27
236
  >
28
237
  <div class="checked-icon">${checkedIcon}</div>
29
238
  ${icons.indeterminate}
@@ -40,27 +249,31 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
40
249
  data-test="label-tooltip"
41
250
  label=${ifDefined(this.label)}
42
251
  offset=${this.privateLabelTooltipOffset}
43
- ?disabled=${!this.isLabelOverflow||this.privateDisableLabelTooltip}
252
+ ?disabled=${!this.isLabelOverflow ||
253
+ this.privateDisableLabelTooltip}
44
254
  ?open=${this.privateShowLabelTooltip}
45
255
  screenreader-hidden
46
256
  >
47
257
  <div
48
- class=${classMap({label:!0,disabled:this.disabled})}
258
+ class=${classMap({
259
+ label: true,
260
+ disabled: this.disabled,
261
+ })}
49
262
  slot="target"
50
- ${ref(this.#p)}
263
+ ${ref(this.#labelElementRef)}
51
264
  >
52
265
  ${this.label}
53
266
  </div>
54
267
  </glide-core-tooltip>
55
268
  </div>
56
269
  </label>
57
- `),(()=>html`<glide-core-private-label
270
+ `, () => html `<glide-core-private-label
58
271
  label=${ifDefined(this.label)}
59
272
  orientation=${this.orientation}
60
- split=${ifDefined(this.privateSplit??void 0)}
273
+ split=${ifDefined(this.privateSplit ?? undefined)}
61
274
  tooltip=${ifDefined(this.tooltip)}
62
275
  ?disabled=${this.disabled}
63
- ?error=${this.#d}
276
+ ?error=${this.#isShowValidationFeedback}
64
277
  ?hide=${this.hideLabel}
65
278
  ?required=${this.required}
66
279
  >
@@ -74,7 +287,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
74
287
  <div class="input-and-checkbox" slot="control">
75
288
  <input
76
289
  aria-describedby="summary description"
77
- aria-invalid=${this.#d}
290
+ aria-invalid=${this.#isShowValidationFeedback}
78
291
  class="input"
79
292
  data-test="input"
80
293
  id="input"
@@ -82,28 +295,32 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
82
295
  .checked=${this.checked}
83
296
  ?disabled=${this.disabled}
84
297
  ?required=${this.required}
85
- @blur=${this.#b}
86
- @change=${this.#h}
87
- @input=${this.#h}
88
- @keydown=${this.#c}
89
- ${ref(this.#o)}
298
+ @blur=${this.#onBlur}
299
+ @change=${this.#onInputChangeOrInput}
300
+ @input=${this.#onInputChangeOrInput}
301
+ @keydown=${this.#onInputKeydown}
302
+ ${ref(this.#inputElementRef)}
90
303
  />
91
304
 
92
305
  <div
93
- class=${classMap({checkbox:!0,disabled:this.disabled,error:this.#d})}
306
+ class=${classMap({
307
+ checkbox: true,
308
+ disabled: this.disabled,
309
+ error: this.#isShowValidationFeedback,
310
+ })}
94
311
  >
95
312
  <div class="checked-icon">${checkedIcon}</div>
96
313
  ${icons.indeterminate}
97
314
  </div>
98
315
  </div>
99
316
 
100
- ${when(this.summary,(()=>html`<div
101
- class=${classMap({summary:!0,disabled:this.disabled})}
317
+ ${when(this.summary, () => html `<div
318
+ class=${classMap({ summary: true, disabled: this.disabled })}
102
319
  id="summary"
103
320
  slot="summary"
104
321
  >
105
322
  ${this.summary}
106
- </div>`))}
323
+ </div>`)}
107
324
 
108
325
  <div id="description" slot="description">
109
326
  <!--
@@ -111,7 +328,10 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
111
328
  @type {Element | string}
112
329
  -->
113
330
  <slot
114
- class=${classMap({description:!0,hidden:Boolean(this.#d&&this.validityMessage)})}
331
+ class=${classMap({
332
+ description: true,
333
+ hidden: Boolean(this.#isShowValidationFeedback && this.validityMessage),
334
+ })}
115
335
  name="description"
116
336
  >
117
337
  <!--
@@ -120,17 +340,283 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
120
340
  -->
121
341
  </slot>
122
342
 
123
- ${when(this.#d&&this.validityMessage,(()=>html`<span
343
+ ${when(this.#isShowValidationFeedback && this.validityMessage, () => html `<span
124
344
  class="validity-message"
125
345
  data-test="validity-message"
126
346
  >${unsafeHTML(this.validityMessage)}</span
127
- >`))}
347
+ >`)}
128
348
  </div>
129
- </glide-core-private-label>`))}
130
- </div>`}reportValidity(){this.privateIsReportValidityOrSubmit=!0;const e=this.#r.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.privateIsReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#r.setValidity({customError:!1},"",this.#o.value):this.#r.setValidity({customError:!0,valueMissing:this.#r.validity.valueMissing}," ",this.#o.value)}setValidity(e,t){this.validityMessage=t,this.#r.setValidity(e," ",this.#o.value)}updated(){this.#o.value&&(this.#o.value.indeterminate=this.indeterminate)}constructor(){super(),this.privateInternallyInert=!1,this.hideLabel=!1,this.indeterminate=!1,this.orientation="horizontal",this.name="",this.privateLabelTooltipOffset=4,this.privateShowLabelTooltip=!1,this.privateDisableLabelTooltip=!1,this.required=!1,this.privateIsReportValidityOrSubmit=!1,this.version=packageJson.version,this.isBlurring=!1,this.isCheckingValidity=!1,this.isLabelOverflow=!1,this.#o=createRef(),this.#i=!1,this.#s=!1,this.#p=createRef(),this.#a="",this.#n=({formData:e})=>{this.checked&&this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#r=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.privateIsReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#o;#r;#l;#i;#s;#e;#p;#a;#n;get#d(){return"minimal"===this.privateVariant?!this.validity.valid&&this.privateIsReportValidityOrSubmit:!this.disabled&&!this.validity.valid&&this.privateIsReportValidityOrSubmit}#b(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#h(e){e.target instanceof HTMLInputElement&&(this.checked=e.target.checked),this.indeterminate=!1,"change"===e.type&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}#c(e){"Enter"===e.key&&this.form?.requestSubmit()}#t(){this.#p.value&&(this.isLabelOverflow=this.#p.value.scrollWidth>this.#p.value.clientWidth)}};__decorate([property({reflect:!0}),required],Checkbox.prototype,"label",null),__decorate([property({type:Boolean})],Checkbox.prototype,"checked",null),__decorate([property({attribute:"private-internally-inert",type:Boolean})],Checkbox.prototype,"privateInternallyInert",void 0),__decorate([property({reflect:!0,type:Boolean})],Checkbox.prototype,"disabled",null),__decorate([property({attribute:"hide-label",type:Boolean})],Checkbox.prototype,"hideLabel",void 0),__decorate([property({type:Boolean})],Checkbox.prototype,"indeterminate",void 0),__decorate([property({reflect:!0,useDefault:!0})],Checkbox.prototype,"orientation",void 0),__decorate([property({reflect:!0,useDefault:!0})],Checkbox.prototype,"name",void 0),__decorate([property({attribute:"private-label-tooltip-offset",reflect:!0,useDefault:!0,type:Number})],Checkbox.prototype,"privateLabelTooltipOffset",void 0),__decorate([property({attribute:"private-show-label-tooltip",reflect:!0,type:Boolean})],Checkbox.prototype,"privateShowLabelTooltip",void 0),__decorate([property({attribute:"private-disable-label-tooltip",reflect:!0,type:Boolean})],Checkbox.prototype,"privateDisableLabelTooltip",void 0),__decorate([property()],Checkbox.prototype,"privateSplit",void 0),__decorate([property({attribute:"private-variant"})],Checkbox.prototype,"privateVariant",void 0),__decorate([property({reflect:!0,type:Boolean})],Checkbox.prototype,"required",void 0),__decorate([property({reflect:!0})],Checkbox.prototype,"summary",void 0),__decorate([property({reflect:!0})],Checkbox.prototype,"tooltip",void 0),__decorate([property({reflect:!0})],Checkbox.prototype,"value",null),__decorate([property({type:Boolean})],Checkbox.prototype,"privateIsReportValidityOrSubmit",void 0),__decorate([property({reflect:!0})],Checkbox.prototype,"version",void 0),__decorate([state()],Checkbox.prototype,"isBlurring",void 0),__decorate([state()],Checkbox.prototype,"isCheckingValidity",void 0),__decorate([state()],Checkbox.prototype,"isLabelOverflow",void 0),__decorate([state()],Checkbox.prototype,"validityMessage",void 0),Checkbox=__decorate([customElement("glide-core-checkbox"),final],Checkbox);export default Checkbox;const icons={indeterminate:html`
349
+ </glide-core-private-label>`)}
350
+ </div>`;
351
+ }
352
+ reportValidity() {
353
+ this.privateIsReportValidityOrSubmit = true;
354
+ const isValid = this.#internals.reportValidity();
355
+ // Ensures that getters referencing `this.validity.valid` are updated.
356
+ this.requestUpdate();
357
+ return isValid;
358
+ }
359
+ resetValidityFeedback() {
360
+ this.privateIsReportValidityOrSubmit = false;
361
+ }
362
+ setCustomValidity(message) {
363
+ this.validityMessage = message;
364
+ if (message === '') {
365
+ this.#internals.setValidity({ customError: false }, '', this.#inputElementRef.value);
366
+ }
367
+ else {
368
+ // A validation message is required but unused because we disable native validation
369
+ // feedback. And an empty string isn't allowed. Thus a single space.
370
+ this.#internals.setValidity({
371
+ customError: true,
372
+ valueMissing: this.#internals.validity.valueMissing,
373
+ }, ' ', this.#inputElementRef.value);
374
+ }
375
+ }
376
+ setValidity(flags, message) {
377
+ this.validityMessage = message;
378
+ this.#internals.setValidity(flags, ' ', this.#inputElementRef.value);
379
+ }
380
+ updated() {
381
+ if (this.#inputElementRef.value) {
382
+ // `indeterminate` needs to be updated both on initial render and after it has
383
+ // changed. This handles both cases.
384
+ this.#inputElementRef.value.indeterminate = this.indeterminate;
385
+ }
386
+ }
387
+ constructor() {
388
+ super();
389
+ this.privateInternallyInert = false;
390
+ this.hideLabel = false;
391
+ this.indeterminate = false;
392
+ this.orientation = 'horizontal';
393
+ this.name = '';
394
+ // Private because it's only meant to be used by Dropdown Option to offset the
395
+ // tooltip by the option's padding.
396
+ this.privateLabelTooltipOffset = 4;
397
+ // Private because it's only meant to be used by Dropdown Option.
398
+ this.privateShowLabelTooltip = false;
399
+ // Private because it's only meant to be used by Dropdown Option.
400
+ this.privateDisableLabelTooltip = false;
401
+ this.required = false;
402
+ // Used by Checkbox Group.
403
+ this.privateIsReportValidityOrSubmit = false;
404
+ this.version = packageJson.version;
405
+ this.isBlurring = false;
406
+ this.isCheckingValidity = false;
407
+ this.isLabelOverflow = false;
408
+ this.#inputElementRef = createRef();
409
+ this.#isChecked = false;
410
+ this.#isDisabled = false;
411
+ this.#labelElementRef = createRef();
412
+ this.#value = '';
413
+ // An arrow function field instead of a method so `this` is closed over and
414
+ // set to the component instead of `document`.
415
+ this.#onFormdata = ({ formData }) => {
416
+ if (this.checked && this.name && this.value && !this.disabled) {
417
+ formData.append(this.name, this.value);
418
+ }
419
+ };
420
+ this.#internals = this.attachInternals();
421
+ // Event handlers on the host aren't great because consumers can remove them.
422
+ // Unfortunately, the host is the only thing on which this event is dispatched
423
+ // because it's the host that is form-associated.
424
+ this.addEventListener('invalid', (event) => {
425
+ event?.preventDefault(); // Canceled so a native validation message isn't shown.
426
+ // We only want to focus the input if the "invalid" event resulted from either:
427
+ //
428
+ // 1. A form submission.
429
+ // 2. A call of `reportValidity()` that did not result from the input's "blur"
430
+ // event.
431
+ if (this.isCheckingValidity || this.isBlurring) {
432
+ return;
433
+ }
434
+ this.privateIsReportValidityOrSubmit = true;
435
+ const isFirstInvalidFormElement = this.form?.querySelector(':invalid') === this;
436
+ if (isFirstInvalidFormElement) {
437
+ // - `this.#internals.delegatesFocus` is preferred because it's declarative. But
438
+ // it's limited to focusing the first focusable element. That doesn't work for
439
+ // us because our first focusable element is the tooltip when it's present.
440
+ //
441
+ // - Canceling this event means the input won't get focus, even if we were to use
442
+ // `this.#internals.delegatesFocus`.
443
+ //
444
+ // - The browser will ignore this if Checkbox isn't the first invalid form control.
445
+ //
446
+ // TODO
447
+ // Try passing `focusVisible` after browsers support it. It may prevent the issue
448
+ // where the checkbox itself has a focus outline after this call.
449
+ //
450
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#focusvisible
451
+ this.focus();
452
+ }
453
+ });
454
+ }
455
+ #inputElementRef;
456
+ #internals;
457
+ #intersectionObserver;
458
+ #isChecked;
459
+ #isDisabled;
460
+ #label;
461
+ #labelElementRef;
462
+ #value;
463
+ // An arrow function field instead of a method so `this` is closed over and
464
+ // set to the component instead of `document`.
465
+ #onFormdata;
466
+ get #isShowValidationFeedback() {
467
+ // If minimal, `disabled`, `required`, and whether the form has been submitted
468
+ // don't apply because the parent component handles those states itself.
469
+ if (this.privateVariant === 'minimal') {
470
+ return !this.validity.valid && this.privateIsReportValidityOrSubmit;
471
+ }
472
+ return (!this.disabled &&
473
+ !this.validity.valid &&
474
+ this.privateIsReportValidityOrSubmit);
475
+ }
476
+ #onBlur() {
477
+ this.isBlurring = true;
478
+ this.reportValidity();
479
+ this.isBlurring = false;
480
+ }
481
+ // Only "change" would need to be handled if not for some consumers needing
482
+ // to force Checkbox checked or unchecked until the user has completed some action.
483
+ //
484
+ // The way to force Checkbox checked or unchecked is to add an "input" or
485
+ // "change" handler and then immediately set `checked` back to its desired
486
+ // state inside that handler.
487
+ //
488
+ // To do that, consumers need to await `this.updateComplete` so `checked` isn't
489
+ // immediately reverted after Checkbox updates, which happens asynchronously and
490
+ // so would happen after their handler runs.
491
+ //
492
+ // To await `this.updateComplete`, however, an update has to be pending. That's
493
+ // why we're handling "input" as well: so that "input", like "change", results
494
+ // in an update that can be awaited.
495
+ //
496
+ // If "input" events were dispatched after "change" events, only handling
497
+ // "change" here would suffice because an update from "change" would already
498
+ // be pending by the time "input" is dispatched.
499
+ #onInputChangeOrInput(event) {
500
+ if (event.target instanceof HTMLInputElement) {
501
+ this.checked = event.target.checked;
502
+ }
503
+ // If the input is interacted with it's no longer indeterminate.
504
+ this.indeterminate = false;
505
+ if (event.type === 'change') {
506
+ // Unlike "input" events, "change" events aren't composed. So we have to
507
+ // manually dispatch them.
508
+ this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
509
+ }
510
+ }
511
+ #onInputKeydown(event) {
512
+ if (event.key === 'Enter') {
513
+ this.form?.requestSubmit();
514
+ }
515
+ }
516
+ #updateLabelOverflow() {
517
+ if (this.#labelElementRef.value) {
518
+ this.isLabelOverflow =
519
+ this.#labelElementRef.value.scrollWidth >
520
+ this.#labelElementRef.value.clientWidth;
521
+ }
522
+ }
523
+ };
524
+ __decorate([
525
+ property({ reflect: true }),
526
+ required
527
+ ], Checkbox.prototype, "label", null);
528
+ __decorate([
529
+ property({ type: Boolean })
530
+ ], Checkbox.prototype, "checked", null);
531
+ __decorate([
532
+ property({ attribute: 'private-internally-inert', type: Boolean })
533
+ ], Checkbox.prototype, "privateInternallyInert", void 0);
534
+ __decorate([
535
+ property({ reflect: true, type: Boolean })
536
+ ], Checkbox.prototype, "disabled", null);
537
+ __decorate([
538
+ property({ attribute: 'hide-label', type: Boolean })
539
+ ], Checkbox.prototype, "hideLabel", void 0);
540
+ __decorate([
541
+ property({ type: Boolean })
542
+ ], Checkbox.prototype, "indeterminate", void 0);
543
+ __decorate([
544
+ property({ reflect: true, useDefault: true })
545
+ ], Checkbox.prototype, "orientation", void 0);
546
+ __decorate([
547
+ property({ reflect: true, useDefault: true })
548
+ ], Checkbox.prototype, "name", void 0);
549
+ __decorate([
550
+ property({
551
+ attribute: 'private-label-tooltip-offset',
552
+ reflect: true,
553
+ useDefault: true,
554
+ type: Number,
555
+ })
556
+ ], Checkbox.prototype, "privateLabelTooltipOffset", void 0);
557
+ __decorate([
558
+ property({
559
+ attribute: 'private-show-label-tooltip',
560
+ reflect: true,
561
+ type: Boolean,
562
+ })
563
+ ], Checkbox.prototype, "privateShowLabelTooltip", void 0);
564
+ __decorate([
565
+ property({
566
+ attribute: 'private-disable-label-tooltip',
567
+ reflect: true,
568
+ type: Boolean,
569
+ })
570
+ ], Checkbox.prototype, "privateDisableLabelTooltip", void 0);
571
+ __decorate([
572
+ property()
573
+ ], Checkbox.prototype, "privateSplit", void 0);
574
+ __decorate([
575
+ property({ attribute: 'private-variant' })
576
+ ], Checkbox.prototype, "privateVariant", void 0);
577
+ __decorate([
578
+ property({ reflect: true, type: Boolean })
579
+ ], Checkbox.prototype, "required", void 0);
580
+ __decorate([
581
+ property({ reflect: true })
582
+ ], Checkbox.prototype, "summary", void 0);
583
+ __decorate([
584
+ property({ reflect: true })
585
+ ], Checkbox.prototype, "tooltip", void 0);
586
+ __decorate([
587
+ property({ reflect: true })
588
+ ], Checkbox.prototype, "value", null);
589
+ __decorate([
590
+ property({ type: Boolean })
591
+ ], Checkbox.prototype, "privateIsReportValidityOrSubmit", void 0);
592
+ __decorate([
593
+ property({ reflect: true })
594
+ ], Checkbox.prototype, "version", void 0);
595
+ __decorate([
596
+ state()
597
+ ], Checkbox.prototype, "isBlurring", void 0);
598
+ __decorate([
599
+ state()
600
+ ], Checkbox.prototype, "isCheckingValidity", void 0);
601
+ __decorate([
602
+ state()
603
+ ], Checkbox.prototype, "isLabelOverflow", void 0);
604
+ __decorate([
605
+ state()
606
+ ], Checkbox.prototype, "validityMessage", void 0);
607
+ Checkbox = __decorate([
608
+ customElement('glide-core-checkbox'),
609
+ final
610
+ ], Checkbox);
611
+ export default Checkbox;
612
+ const icons = {
613
+ indeterminate: html `
131
614
  <svg
132
615
  aria-hidden="true"
133
- style=${styleMap({height:"0.875rem",width:"0.875rem"})}
616
+ style=${styleMap({
617
+ height: '0.875rem',
618
+ width: '0.875rem',
619
+ })}
134
620
  viewBox="0 0 14 14"
135
621
  fill="none"
136
622
  class="indeterminate-icon"
@@ -141,4 +627,5 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var a,r=arguments.length
141
627
  fill="currentColor"
142
628
  />
143
629
  </svg>
144
- `};
630
+ `,
631
+ };
@@ -1,7 +1,11 @@
1
- import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export default[css`
2
- ${focusOutline(".input:focus-visible ~ .checkbox")}
3
- ${focusOutline(".input:focus ~ .checkbox.error")}
4
- `,css`
1
+ import { css } from 'lit';
2
+ import focusOutline from './styles/focus-outline.js';
3
+ export default [
4
+ css `
5
+ ${focusOutline('.input:focus-visible ~ .checkbox')}
6
+ ${focusOutline('.input:focus ~ .checkbox.error')}
7
+ `,
8
+ css `
5
9
  .label-and-input-and-checkbox {
6
10
  align-items: center;
7
11
  column-gap: var(--glide-core-spacing-base-xs);
@@ -208,4 +212,5 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
208
212
  .validity-message {
209
213
  display: block;
210
214
  }
211
- `];
215
+ `,
216
+ ];