@redvars/peacock 3.2.7 → 3.2.9

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 (145) hide show
  1. package/dist/PeacockComponent-CxJc63xj.js +73 -0
  2. package/dist/PeacockComponent-CxJc63xj.js.map +1 -0
  3. package/dist/assets/styles.css +1 -1
  4. package/dist/assets/styles.css.map +1 -1
  5. package/dist/button-2MeDq0Yy.js +898 -0
  6. package/dist/button-2MeDq0Yy.js.map +1 -0
  7. package/dist/button-group.js +7 -5
  8. package/dist/button-group.js.map +1 -1
  9. package/dist/button.js +7 -0
  10. package/dist/button.js.map +1 -0
  11. package/dist/{class-map-BmCohX9p.js → class-map-BvQRv7eW.js} +2 -2
  12. package/dist/{class-map-BmCohX9p.js.map → class-map-BvQRv7eW.js.map} +1 -1
  13. package/dist/clock.js +26 -24
  14. package/dist/clock.js.map +1 -1
  15. package/dist/code-editor.js +43877 -0
  16. package/dist/code-editor.js.map +1 -0
  17. package/dist/code-highlighter.js +9 -7
  18. package/dist/code-highlighter.js.map +1 -1
  19. package/dist/custom-elements-jsdocs.json +561 -0
  20. package/dist/custom-elements.json +838 -227
  21. package/dist/{utils-DGMeCC48.js → dispatch-event-utils-vbdiOSeC.js} +19 -2
  22. package/dist/dispatch-event-utils-vbdiOSeC.js.map +1 -0
  23. package/dist/image-DK6VQW7N.js +7042 -0
  24. package/dist/image-DK6VQW7N.js.map +1 -0
  25. package/dist/index.js +10 -33
  26. package/dist/index.js.map +1 -1
  27. package/dist/number-counter.js +7 -5
  28. package/dist/number-counter.js.map +1 -1
  29. package/dist/observe-theme-change-NneLARW8.js +51 -0
  30. package/dist/observe-theme-change-NneLARW8.js.map +1 -0
  31. package/dist/peacock-loader.js +973 -37
  32. package/dist/peacock-loader.js.map +1 -1
  33. package/dist/src/PeacockComponent.d.ts +1 -0
  34. package/dist/src/code-editor/code-editor.d.ts +45 -0
  35. package/dist/src/code-editor/index.d.ts +2 -0
  36. package/dist/src/image/image.d.ts +45 -0
  37. package/dist/src/image/index.d.ts +1 -0
  38. package/dist/src/index.d.ts +2 -0
  39. package/dist/src/utils/dispatch-event-utils.d.ts +72 -0
  40. package/dist/src/utils/observe-theme-change.d.ts +3 -0
  41. package/dist/src/utils.d.ts +1 -72
  42. package/dist/{state-CV1fRmOT.js → state-B09bP3XH.js} +2 -2
  43. package/dist/{state-CV1fRmOT.js.map → state-B09bP3XH.js.map} +1 -1
  44. package/dist/{style-map-CdmclYgz.js → style-map-B8xgVEc9.js} +2 -2
  45. package/dist/{style-map-CdmclYgz.js.map → style-map-B8xgVEc9.js.map} +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/dist/{unsafe-html-BS8X6Gto.js → unsafe-html-B-dV3Jps.js} +2 -2
  48. package/dist/{unsafe-html-BS8X6Gto.js.map → unsafe-html-B-dV3Jps.js.map} +1 -1
  49. package/package.json +5 -3
  50. package/readme.md +2 -2
  51. package/scss/styles.scss +57 -1
  52. package/scss/tokens.css +1 -0
  53. package/src/PeacockComponent.ts +3 -0
  54. package/src/accordion/accordion-item/accordion-item.scss +1 -1
  55. package/src/button/BaseButton.ts +1 -1
  56. package/src/button/button/button.ts +3 -1
  57. package/src/button/button-group/button-group.ts +2 -0
  58. package/src/clock/clock.ts +4 -1
  59. package/src/code-editor/code-editor.scss +52 -0
  60. package/src/code-editor/code-editor.ts +215 -0
  61. package/src/code-editor/demo/index.html +37 -0
  62. package/src/code-editor/index.ts +3 -0
  63. package/src/code-highlighter/code-highlighter.ts +2 -0
  64. package/src/container/container.scss +1 -1
  65. package/src/date-picker/date-picker.ts +1 -1
  66. package/src/image/image.scss +49 -0
  67. package/src/image/image.ts +135 -0
  68. package/src/image/index.ts +1 -0
  69. package/src/index.ts +2 -0
  70. package/src/input/input.ts +1 -2
  71. package/src/menu/menu-item/menu-item.scss +5 -4
  72. package/src/menu/menu-list/menu-list.scss +1 -0
  73. package/src/number-counter/number-counter.ts +2 -0
  74. package/src/number-field/number-field.ts +1 -1
  75. package/src/peacock-loader.ts +7 -0
  76. package/src/textarea/textarea.ts +1 -1
  77. package/src/time-picker/time-picker.ts +1 -1
  78. package/src/utils/dispatch-event-utils.ts +131 -0
  79. package/src/utils/observe-theme-change.ts +30 -0
  80. package/src/utils.ts +5 -131
  81. package/dist/BaseButton.js +0 -209
  82. package/dist/BaseButton.js.map +0 -1
  83. package/dist/BaseInput.js +0 -27
  84. package/dist/BaseInput.js.map +0 -1
  85. package/dist/accordion-item.js +0 -191
  86. package/dist/accordion-item.js.map +0 -1
  87. package/dist/accordion.js +0 -142
  88. package/dist/accordion.js.map +0 -1
  89. package/dist/avatar.js +0 -106
  90. package/dist/avatar.js.map +0 -1
  91. package/dist/badge.js +0 -84
  92. package/dist/badge.js.map +0 -1
  93. package/dist/base-progress.js +0 -33
  94. package/dist/base-progress.js.map +0 -1
  95. package/dist/breadcrumb-item.js +0 -160
  96. package/dist/breadcrumb-item.js.map +0 -1
  97. package/dist/breadcrumb.js +0 -84
  98. package/dist/breadcrumb.js.map +0 -1
  99. package/dist/checkbox.js +0 -530
  100. package/dist/checkbox.js.map +0 -1
  101. package/dist/chip.js +0 -303
  102. package/dist/chip.js.map +0 -1
  103. package/dist/container.js +0 -135
  104. package/dist/container.js.map +0 -1
  105. package/dist/divider.js +0 -126
  106. package/dist/divider.js.map +0 -1
  107. package/dist/elevation.js +0 -79
  108. package/dist/elevation.js.map +0 -1
  109. package/dist/empty-state.js +0 -171
  110. package/dist/empty-state.js.map +0 -1
  111. package/dist/field.js +0 -416
  112. package/dist/field.js.map +0 -1
  113. package/dist/focus-ring.js +0 -107
  114. package/dist/focus-ring.js.map +0 -1
  115. package/dist/icon.js +0 -183
  116. package/dist/icon.js.map +0 -1
  117. package/dist/link.js +0 -91
  118. package/dist/link.js.map +0 -1
  119. package/dist/lit-element-CA46RFZ_.js +0 -28
  120. package/dist/lit-element-CA46RFZ_.js.map +0 -1
  121. package/dist/menu-item.js +0 -232
  122. package/dist/menu-item.js.map +0 -1
  123. package/dist/menu-list.js +0 -108
  124. package/dist/menu-list.js.map +0 -1
  125. package/dist/menu.js +0 -117
  126. package/dist/menu.js.map +0 -1
  127. package/dist/property-DNVWDdPC.js +0 -45
  128. package/dist/property-DNVWDdPC.js.map +0 -1
  129. package/dist/query-QBcUV-L_.js +0 -15
  130. package/dist/query-QBcUV-L_.js.map +0 -1
  131. package/dist/ripple.js +0 -128
  132. package/dist/ripple.js.map +0 -1
  133. package/dist/skeleton.js +0 -113
  134. package/dist/skeleton.js.map +0 -1
  135. package/dist/spinner.js +0 -93
  136. package/dist/spinner.js.map +0 -1
  137. package/dist/spread-axRTFMoH.js +0 -32
  138. package/dist/spread-axRTFMoH.js.map +0 -1
  139. package/dist/switch-DqxIiVsB.js +0 -2738
  140. package/dist/switch-DqxIiVsB.js.map +0 -1
  141. package/dist/tag.js +0 -323
  142. package/dist/tag.js.map +0 -1
  143. package/dist/tooltip.js +0 -1857
  144. package/dist/tooltip.js.map +0 -1
  145. package/dist/utils-DGMeCC48.js.map +0 -1
@@ -1,2738 +0,0 @@
1
- import { _ as __decorate, n, a as __classPrivateFieldGet } from './property-DNVWDdPC.js';
2
- import { i, b, A } from './lit-element-CA46RFZ_.js';
3
- import { r } from './state-CV1fRmOT.js';
4
- import { e } from './class-map-BmCohX9p.js';
5
- import { t as throttle, o as observerSlotChangesWithCallback, r as redispatchEvent } from './utils-DGMeCC48.js';
6
- import { s as spread } from './spread-axRTFMoH.js';
7
- import { BaseButton } from './BaseButton.js';
8
- import { o } from './style-map-CdmclYgz.js';
9
- import { BaseProgress } from './base-progress.js';
10
- import { e as e$1 } from './query-QBcUV-L_.js';
11
- import BaseInput from './BaseInput.js';
12
-
13
- var css_248z$b = i`* {
14
- box-sizing: border-box;
15
- }
16
-
17
- .screen-reader-only {
18
- display: none !important;
19
- }
20
-
21
- :host {
22
- display: inline-flex;
23
- --z-index-button: 0;
24
- --button-height: unset;
25
- --button-icon-size: unset;
26
- --button-container-shape: unset;
27
- --button-container-shape-start-start: unset;
28
- --button-container-shape-start-end: unset;
29
- --button-container-shape-end-start: unset;
30
- --button-container-shape-end-end: unset;
31
- --button-container-shape-variant: unset;
32
- }
33
-
34
- /**
35
- * Private CSS Variables
36
- * These variables are used internally within the button component
37
- */
38
- slot::slotted(*) {
39
- --icon-size: var(--button-icon-size, var(--_button-icon-size));
40
- --icon-color: var(--_label-text-color);
41
- }
42
-
43
- /*
44
- * Reset native button/link styles
45
- */
46
- .button.button-element {
47
- background: transparent;
48
- border: none;
49
- appearance: none;
50
- margin: 0;
51
- outline: none;
52
- text-decoration: none;
53
- }
54
-
55
- .button {
56
- position: relative;
57
- display: inline-flex;
58
- flex-direction: column;
59
- align-items: center;
60
- justify-content: center;
61
- height: var(--button-height, var(--_button-height));
62
- padding: 0 var(--_container-padding);
63
- width: 100%;
64
- font-family: var(--font-family-sans) !important;
65
- cursor: pointer;
66
- --_container-shape-start-start: var(--button-container-shape-start-start, var(--button-container-shape, var(--shape-corner-medium)));
67
- --_container-shape-start-end: var(--button-container-shape-start-end, var(--button-container-shape, var(--shape-corner-medium)));
68
- --_container-shape-end-start: var(--button-container-shape-end-start, var(--button-container-shape, var(--shape-corner-medium)));
69
- --_container-shape-end-end: var(--button-container-shape-end-end, var(--button-container-shape, var(--shape-corner-medium)));
70
- --_container-corner-shape-variant: var(--button-container-shape-variant, squircle);
71
- }
72
- .button .button-content {
73
- display: flex;
74
- align-items: center;
75
- justify-content: center;
76
- gap: var(--_button-icon-label-spacing);
77
- width: 100%;
78
- z-index: 1;
79
- color: var(--_label-text-color);
80
- opacity: var(--_label-text-opacity, 1);
81
- --icon-size: var(--button-icon-size, var(--_button-icon-size));
82
- --icon-color: var(--_label-text-color);
83
- }
84
- .button .button-content .slot-container {
85
- display: none;
86
- }
87
- .button.disabled {
88
- cursor: not-allowed;
89
- }
90
- .button {
91
- /*
92
- Background layers
93
- */
94
- }
95
- .button .focus-ring {
96
- z-index: 2;
97
- --focus-ring-container-shape-start-start: var(--_container-shape-start-start);
98
- --focus-ring-container-shape-start-end: var(--_container-shape-start-end);
99
- --focus-ring-container-shape-end-start: var(--_container-shape-end-start);
100
- --focus-ring-container-shape-end-end: var(--_container-shape-end-end);
101
- --focus-ring-container-shape-variant: var(--_container-corner-shape-variant);
102
- }
103
- .button .ripple {
104
- border-start-start-radius: var(--_container-shape-start-start);
105
- border-start-end-radius: var(--_container-shape-start-end);
106
- border-end-start-radius: var(--_container-shape-end-start);
107
- border-end-end-radius: var(--_container-shape-end-end);
108
- corner-shape: var(--_container-corner-shape-variant);
109
- --ripple-state-opacity: var(--_container-state-opacity, 0);
110
- --ripple-pressed-color: var(--_container-state-color);
111
- }
112
- .button .background {
113
- display: block;
114
- position: absolute;
115
- left: 0;
116
- width: 100%;
117
- height: 100%;
118
- background-color: var(--_container-color);
119
- opacity: var(--_container-opacity, 1);
120
- border-start-start-radius: var(--_container-shape-start-start);
121
- border-start-end-radius: var(--_container-shape-start-end);
122
- border-end-start-radius: var(--_container-shape-end-start);
123
- border-end-end-radius: var(--_container-shape-end-end);
124
- corner-shape: var(--_container-corner-shape-variant);
125
- pointer-events: none;
126
- }
127
- .button .skeleton {
128
- display: none;
129
- width: 100%;
130
- height: 100%;
131
- z-index: 2;
132
- position: absolute;
133
- top: 0;
134
- left: 0;
135
- --skeleton-container-shape-start-start: var(--_container-shape-start-start);
136
- --skeleton-container-shape-start-end: var(--_container-shape-start-end);
137
- --skeleton-container-shape-end-start: var(--_container-shape-end-start);
138
- --skeleton-container-shape-end-end: var(--_container-shape-end-end);
139
- --skeleton-container-shape-variant: var(--_container-corner-shape-variant);
140
- }
141
- .button .elevation {
142
- --elevation-level: var(--_container-elevation-level);
143
- transition-duration: 280ms;
144
- --elevation-container-shape-start-start: var(--_container-shape-start-start);
145
- --elevation-container-shape-start-end: var(--_container-shape-start-end);
146
- --elevation-container-shape-end-start: var(--_container-shape-end-start);
147
- --elevation-container-shape-end-end: var(--_container-shape-end-end);
148
- --elevation-container-shape-variant: var(--_container-corner-shape-variant);
149
- }
150
- .button .neo-background {
151
- display: none;
152
- position: absolute;
153
- background: var(--color-inverse-surface);
154
- border-start-start-radius: var(--_container-shape-start-start);
155
- border-start-end-radius: var(--_container-shape-start-end);
156
- border-end-start-radius: var(--_container-shape-end-start);
157
- border-end-end-radius: var(--_container-shape-end-end);
158
- corner-shape: var(--_container-corner-shape-variant);
159
- width: 100%;
160
- height: 100%;
161
- pointer-events: none;
162
- transform: translateX(0.25rem) translateY(0.25rem);
163
- }
164
- .button .neo-background:before {
165
- z-index: 0;
166
- content: "";
167
- position: absolute;
168
- pointer-events: none;
169
- border-start-start-radius: var(--_container-shape-start-start);
170
- border-start-end-radius: var(--_container-shape-start-end);
171
- border-end-start-radius: var(--_container-shape-end-start);
172
- border-end-end-radius: var(--_container-shape-end-end);
173
- corner-shape: var(--_container-corner-shape-variant);
174
- width: 100%;
175
- height: 100%;
176
- background: white;
177
- left: 0;
178
- transform: translateX(-0.25rem) translateY(-0.25rem);
179
- }
180
- .button .outline {
181
- z-index: 0;
182
- display: none;
183
- position: absolute;
184
- left: 0;
185
- width: 100%;
186
- height: 100%;
187
- pointer-events: none;
188
- border: var(--_outline-width) solid var(--_outline-color);
189
- opacity: var(--_outline-opacity, 1);
190
- border-start-start-radius: var(--_container-shape-start-start);
191
- border-start-end-radius: var(--_container-shape-start-end);
192
- border-end-start-radius: var(--_container-shape-end-start);
193
- border-end-end-radius: var(--_container-shape-end-end);
194
- corner-shape: var(--_container-corner-shape-variant);
195
- }
196
- .button.has-content .slot-container {
197
- display: flex;
198
- flex: none;
199
- justify-content: center;
200
- }
201
- .button.show-skeleton .background {
202
- display: none;
203
- }
204
- .button.show-skeleton .neo-background {
205
- display: none;
206
- }
207
- .button.show-skeleton .neo-background:before {
208
- display: none;
209
- }
210
- .button.show-skeleton .ripple {
211
- display: none;
212
- }
213
- .button.show-skeleton .skeleton {
214
- display: block;
215
- }
216
- .button.icon-align-start .button-content {
217
- flex-direction: row-reverse;
218
- }
219
- .button.icon-align-end .button-content {
220
- flex-direction: row;
221
- }
222
-
223
- /**
224
- * Button variant definitions
225
- */
226
- .button.variant-elevated {
227
- --_container-color: var(--elevated-button-container-color);
228
- --_label-text-color: var(--elevated-button-label-text-color);
229
- --_container-elevation-level: 1;
230
- --_container-state-color: var(--_label-text-color);
231
- }
232
- .button.variant-elevated:hover:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
233
- --_container-elevation-level: 2;
234
- --_container-state-opacity: 0.08;
235
- }
236
- .button.variant-elevated.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
237
- --_container-elevation-level: 1;
238
- --_container-state-opacity: 0.12;
239
- }
240
- .button.variant-elevated.disabled {
241
- --_container-color: var(--color-on-surface);
242
- --_container-opacity: 0.1;
243
- --_label-text-color: var(--color-on-surface);
244
- --_label-text-opacity: 0.38;
245
- }
246
- .button.variant-elevated.disabled .ripple {
247
- display: none;
248
- }
249
-
250
- .button.variant-filled {
251
- --_container-color: var(--filled-button-container-color);
252
- --_label-text-color: var(--filled-button-label-text-color);
253
- --_container-state-color: var(--_label-text-color);
254
- }
255
- .button.variant-filled:hover:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
256
- --_container-elevation-level: 1;
257
- --_container-state-opacity: 0.08;
258
- }
259
- .button.variant-filled.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
260
- --_container-elevation-level: 0;
261
- --_container-state-opacity: 0.1;
262
- }
263
- .button.variant-filled.disabled {
264
- --_container-color: var(--color-on-surface);
265
- --_container-opacity: 0.1;
266
- --_label-text-color: var(--color-on-surface);
267
- --_label-text-opacity: 0.38;
268
- }
269
- .button.variant-filled.disabled .ripple {
270
- display: none;
271
- }
272
-
273
- .button.variant-tonal {
274
- --_container-color: var(--tonal-button-container-color);
275
- --_label-text-color: var(--tonal-button-label-text-color);
276
- --_container-state-color: var(--_label-text-color);
277
- }
278
- .button.variant-tonal:hover:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
279
- --_container-elevation-level: 1;
280
- --_container-state-opacity: 0.08;
281
- }
282
- .button.variant-tonal.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
283
- --_container-elevation-level: 0;
284
- --_container-state-opacity: 0.12;
285
- }
286
- .button.variant-tonal.disabled {
287
- --_container-color: var(--color-on-surface);
288
- --_container-opacity: 0.1;
289
- --_label-text-color: var(--color-on-surface);
290
- --_label-text-opacity: 0.38;
291
- }
292
- .button.variant-tonal.disabled .ripple {
293
- display: none;
294
- }
295
-
296
- .button.variant-outlined {
297
- --_outline-width: var(--outlined-button-outline-width, 0.0675rem);
298
- --_outline-color: var(--outlined-button-outline-color);
299
- --_label-text-color: var(--outlined-button-label-text-color);
300
- --_container-state-color: var(--_label-text-color);
301
- }
302
- .button.variant-outlined .outline {
303
- display: block;
304
- }
305
- .button.variant-outlined:hover:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
306
- --_container-state-opacity: 0.08;
307
- }
308
- .button.variant-outlined.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
309
- --_container-state-opacity: 0.12;
310
- }
311
- .button.variant-outlined.disabled {
312
- --_outline-color: var(--color-on-surface);
313
- --_label-text-color: var(--color-on-surface);
314
- --_label-text-opacity: 0.38;
315
- --_outline-opacity: 0.12;
316
- }
317
- .button.variant-outlined.disabled .ripple {
318
- display: none;
319
- }
320
-
321
- .button.variant-text {
322
- --_label-text-color: var(--text-button-label-text-color);
323
- --_container-state-color: var(--_label-text-color);
324
- }
325
- .button.variant-text:hover:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
326
- --_container-state-opacity: 0.08;
327
- }
328
- .button.variant-text.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) {
329
- --_container-state-opacity: 0.12;
330
- }
331
- .button.variant-text.disabled {
332
- --_label-text-color: var(--color-on-surface);
333
- --_label-text-opacity: 0.38;
334
- }
335
- .button.variant-text.disabled .ripple {
336
- display: none;
337
- }
338
-
339
- .button.variant-neo {
340
- --_container-color: var(--neo-button-container-color);
341
- --_label-text-color: var(--neo-button-label-text-color);
342
- --_outline-width: var(--outlined-button-outline-width, 0.125rem);
343
- --_outline-color: var(--color-inverse-surface);
344
- }
345
- .button.variant-neo .outline {
346
- display: block;
347
- }
348
- .button.variant-neo .neo-background {
349
- display: block;
350
- }
351
- .button.variant-neo .ripple {
352
- display: none;
353
- }
354
- .button.variant-neo.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) .background, .button.variant-neo.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) .button-content, .button.variant-neo.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) .outline {
355
- transform: translateX(0.25rem) translateY(0.25rem);
356
- }
357
- .button.variant-neo.pressed:not(:where(.disabled, .soft-disabled, .show-skeleton)) .neo-background:before {
358
- transform: translateX(0) translateY(0);
359
- }
360
- .button.variant-neo.disabled {
361
- --_container-color: var(--color-on-surface);
362
- --_container-opacity: 0.1;
363
- --_label-text-color: var(--color-on-surface);
364
- --_label-text-opacity: 0.38;
365
- --_outline-opacity: 0.12;
366
- }
367
- .button.variant-neo.disabled .ripple {
368
- display: none;
369
- }
370
-
371
- :host([block]) {
372
- width: 100%;
373
- }`;
374
-
375
- var css_248z$a = i`:host([color=primary]) {
376
- --filled-button-container-color: var(--color-primary);
377
- --filled-button-label-text-color: var(--color-on-primary);
378
- --tonal-button-container-color: var(--color-primary-container);
379
- --tonal-button-label-text-color: var(--color-on-primary-container);
380
- --elevated-button-container-color: var(--color-surface-container-low);
381
- --elevated-button-label-text-color: var(--color-primary);
382
- --outlined-button-outline-color: var(--color-primary);
383
- --outlined-button-label-text-color: var(--color-primary);
384
- --text-button-label-text-color: var(--color-primary);
385
- --neo-button-container-color: var(--color-primary);
386
- --neo-button-label-text-color: var(--color-on-primary);
387
- }
388
-
389
- :host([color=secondary]) {
390
- --filled-button-container-color: var(--color-secondary);
391
- --filled-button-label-text-color: var(--color-on-secondary);
392
- --tonal-button-container-color: var(--color-secondary-container);
393
- --tonal-button-label-text-color: var(--color-on-secondary-container);
394
- --elevated-button-container-color: var(--color-surface-container-low);
395
- --elevated-button-label-text-color: var(--color-secondary);
396
- --outlined-button-outline-color: var(--color-secondary);
397
- --outlined-button-label-text-color: var(--color-secondary);
398
- --text-button-label-text-color: var(--color-secondary);
399
- --neo-button-container-color: var(--color-secondary);
400
- --neo-button-label-text-color: var(--color-on-secondary);
401
- }
402
-
403
- :host([color=tertiary]) {
404
- --filled-button-container-color: var(--color-tertiary);
405
- --filled-button-label-text-color: var(--color-on-tertiary);
406
- --tonal-button-container-color: var(--color-tertiary-container);
407
- --tonal-button-label-text-color: var(--color-on-tertiary-container);
408
- --elevated-button-container-color: var(--color-surface-container-low);
409
- --elevated-button-label-text-color: var(--color-tertiary);
410
- --outlined-button-outline-color: var(--color-tertiary);
411
- --outlined-button-label-text-color: var(--color-tertiary);
412
- --text-button-label-text-color: var(--color-tertiary);
413
- --neo-button-container-color: var(--color-tertiary);
414
- --neo-button-label-text-color: var(--color-on-tertiary);
415
- }
416
-
417
- :host([color=success]) {
418
- --filled-button-container-color: var(--color-success);
419
- --filled-button-label-text-color: var(--color-on-success);
420
- --tonal-button-container-color: var(--color-success-container);
421
- --tonal-button-label-text-color: var(--color-on-success-container);
422
- --elevated-button-container-color: var(--color-surface-container-low);
423
- --elevated-button-label-text-color: var(--color-success);
424
- --outlined-button-outline-color: var(--color-success);
425
- --outlined-button-label-text-color: var(--color-success);
426
- --text-button-label-text-color: var(--color-success);
427
- --neo-button-container-color: var(--color-success);
428
- --neo-button-label-text-color: var(--color-on-success);
429
- }
430
-
431
- :host([color=danger]) {
432
- --filled-button-container-color: var(--color-error);
433
- --filled-button-label-text-color: var(--color-on-error);
434
- --tonal-button-container-color: var(--color-error-container);
435
- --tonal-button-label-text-color: var(--color-on-error-container);
436
- --elevated-button-container-color: var(--color-surface-container-low);
437
- --elevated-button-label-text-color: var(--color-error);
438
- --outlined-button-outline-color: var(--color-error);
439
- --outlined-button-label-text-color: var(--color-error);
440
- --text-button-label-text-color: var(--color-error);
441
- --neo-button-container-color: var(--color-error);
442
- --neo-button-label-text-color: var(--color-on-error);
443
- }
444
-
445
- :host([color=dark]) {
446
- --filled-button-container-color: var(--color-on-surface);
447
- --filled-button-label-text-color: var(--color-surface);
448
- --tonal-button-container-color: var(--color-surface-container);
449
- --tonal-button-label-text-color: var(--color-on-surface-container);
450
- --elevated-button-container-color: var(--color-surface-container-low);
451
- --elevated-button-label-text-color: var(--color-on-surface);
452
- --outlined-button-outline-color: var(--color-on-surface);
453
- --outlined-button-label-text-color: var(--color-on-surface);
454
- --text-button-label-text-color: var(--color-on-surface);
455
- --neo-button-container-color: var(--color-on-surface);
456
- --neo-button-label-text-color: var(--color-surface);
457
- }
458
-
459
- :host([color=light]) {
460
- --filled-button-container-color: var(--color-surface);
461
- --filled-button-label-text-color: var(--color-on-surface);
462
- --tonal-button-container-color: var(--color-on-surface-container);
463
- --tonal-button-label-text-color: var(--color-surface-container);
464
- --elevated-button-container-color: var(--color-surface-container-low);
465
- --elevated-button-label-text-color: var(--color-white);
466
- --outlined-button-outline-color: var(--color-surface);
467
- --outlined-button-label-text-color: var(--color-surface);
468
- --text-button-label-text-color: var(--color-surface);
469
- --neo-button-container-color: var(--color-surface);
470
- --neo-button-label-text-color: var(--color-on-surface);
471
- }`;
472
-
473
- var css_248z$9 = i`.button.size-xs,
474
- .button.size-extra-small {
475
- --_button-height: 2rem;
476
- --_button-icon-size: 1rem;
477
- --_container-padding: 0.75rem;
478
- font-size: 0.875rem !important;
479
- font-weight: var(--font-weight-medium) !important;
480
- line-height: 1.25rem !important;
481
- letter-spacing: 0.1px !important;
482
- }
483
-
484
- .button.size-sm,
485
- .button.size-small {
486
- --_button-height: 2.5rem;
487
- --_button-icon-size: 1.25rem;
488
- --_container-padding: 1rem;
489
- --_button-icon-label-spacing: 0.5rem;
490
- font-size: 0.875rem !important;
491
- font-weight: var(--font-weight-medium) !important;
492
- line-height: 1.25rem !important;
493
- letter-spacing: 0.1px !important;
494
- }
495
-
496
- .button.size-md,
497
- .button.size-medium {
498
- --_button-height: 3.5rem;
499
- --_button-icon-size: 1.5rem;
500
- --_container-padding: 1.5rem;
501
- font-size: 1rem !important;
502
- font-weight: var(--font-weight-medium) !important;
503
- line-height: 1.5rem !important;
504
- letter-spacing: 0.15px !important;
505
- }
506
-
507
- .button.size-lg,
508
- .button.size-large {
509
- --_button-height: 6rem;
510
- --_button-icon-size: 2rem;
511
- --_container-padding: 3rem;
512
- font-size: 1.5rem !important;
513
- font-weight: var(--font-weight-regular) !important;
514
- line-height: 2rem !important;
515
- letter-spacing: 0 !important;
516
- }
517
-
518
- .button.size-xl {
519
- --_button-height: 8.5rem;
520
- --_button-icon-size: 2.5rem;
521
- --_container-padding: 4rem;
522
- font-size: 2rem !important;
523
- font-weight: var(--font-weight-regular) !important;
524
- line-height: 2.5rem !important;
525
- letter-spacing: 0 !important;
526
- }`;
527
-
528
- var _Button_tabindex;
529
- /**
530
- * @label Button
531
- * @tag base-button
532
- * @rawTag button
533
- *
534
- * @summary Buttons help people initiate actions, from sending an email, to sharing a document, to liking a post.
535
- * @overview
536
- * <p>Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.</p>
537
- *
538
- * @cssprop --button-container-shape: Defines the border radius of the button container shape.
539
- *
540
- * @cssprop --button-container-shape-start-start: Defines the start position of the button container shape.
541
- * @cssprop --button-container-shape-start-end: Defines the end position of the button container shape.
542
- * @cssprop --button-container-shape-end-start: Defines the start position of the button container shape.
543
- * @cssprop --button-container-shape-end-end: Defines the end position of the button container shape.
544
- *
545
- *
546
- * @cssprop --filled-button-container-color: Color of the filled button container.
547
- * @cssprop --filled-button-label-text-color: Text color of the filled button label.
548
- *
549
- * @cssprop --outlined-button-container-color: Color of the outlined button container.
550
- * @cssprop --outlined-button-label-text-color: Text color of the outlined button label.
551
- *
552
- * @cssprop --text-button-label-text-color: Text color of the text button label.
553
- *
554
- * @cssprop --tonal-button-container-color: Color of the tonal button container.
555
- * @cssprop --tonal-button-label-text-color: Text color of the tonal button label.
556
- *
557
- * @cssprop --elevated-button-container-color: Color of the elevated button container.
558
- * @cssprop --elevated-button-label-text-color: Text color of the elevated button label.
559
- *
560
- * @cssprop --neo-button-container-color: Color of the neo button container.
561
- * @cssprop --neo-button-label-text-color: Text color of the neo button label.
562
- *
563
- * @fires {MouseEvent} click - Dispatched when the button is clicked.
564
- *
565
- * @example
566
- * ```html
567
- * <base-button>Button</base-button>
568
- * ```
569
- * @tags display
570
- */
571
- class Button extends BaseButton {
572
- constructor() {
573
- super(...arguments);
574
- _Button_tabindex.set(this, 0);
575
- /**
576
- * Icon alignment.
577
- * Possible values are `"start"`, `"end"`. Defaults to `"end"`.
578
- */
579
- this.iconAlign = 'end';
580
- this.slotHasContent = false;
581
- }
582
- firstUpdated() {
583
- this.__dispatchClickWithThrottle = throttle(this.__dispatchClick, this.throttleDelay);
584
- observerSlotChangesWithCallback(this.renderRoot.querySelector('slot'), hasContent => {
585
- this.slotHasContent = hasContent;
586
- this.requestUpdate();
587
- });
588
- this.__convertTypeToVariantAndColor();
589
- }
590
- render() {
591
- const isLink = this.__isLink();
592
- const cssClasses = {
593
- button: true,
594
- 'button-element': true,
595
- [`size-${this.size}`]: true,
596
- [`variant-${this.variant}`]: true,
597
- [`color-${this.color}`]: true,
598
- disabled: this.disabled || this.softDisabled,
599
- pressed: this.isPressed,
600
- 'has-content': this.slotHasContent,
601
- 'show-skeleton': this.skeleton,
602
- [`icon-align-${this.iconAlign}`]: true,
603
- };
604
- if (!isLink) {
605
- return b `<button
606
- class=${e(cssClasses)}
607
- id="button"
608
- tabindex=${__classPrivateFieldGet(this, _Button_tabindex, "f")}
609
- type=${this.htmlType}
610
- @mousedown=${this.__handlePress}
611
- @keydown=${this.__handlePress}
612
- @keyup=${this.__handlePress}
613
- ?aria-describedby=${this.__getDisabledReasonID()}
614
- aria-disabled=${`${this.disabled || this.softDisabled}`}
615
- ?disabled=${this.disabled}
616
- ${spread(this.configAria)}
617
- >
618
- ${this.renderButtonContent()}
619
- </button>
620
- ${this.__renderTooltip()}`;
621
- }
622
- return b `<a
623
- class=${e(cssClasses)}
624
- id="button"
625
- tabindex=${__classPrivateFieldGet(this, _Button_tabindex, "f")}
626
- href=${this.href}
627
- target=${this.target}
628
- @mousedown=${this.__handlePress}
629
- @keydown=${this.__handlePress}
630
- @keyup=${this.__handlePress}
631
- role="button"
632
- ?aria-describedby=${this.__getDisabledReasonID()}
633
- aria-disabled=${`${this.disabled}`}
634
- ${spread(this.configAria)}
635
- >
636
- ${this.renderButtonContent()}
637
- </a>
638
- ${this.__renderTooltip()}`;
639
- }
640
- renderButtonContent() {
641
- return b `
642
- <focus-ring class="focus-ring" .control=${this} element="buttonElement"></focus-ring>
643
- <base-elevation class="elevation"></base-elevation>
644
- <div class="neo-background"></div>
645
- <div class="background"></div>
646
- <div class="outline"></div>
647
- <base-ripple class="ripple"></base-ripple>
648
- <base-skeleton class="skeleton"></base-skeleton>
649
-
650
- <div class="button-content">
651
- <div class="slot-container">
652
- <slot></slot>
653
- </div>
654
-
655
- <slot name="icon"></slot>
656
- </div>
657
-
658
- ${this.__renderDisabledReason()}
659
- `;
660
- }
661
- }
662
- _Button_tabindex = new WeakMap();
663
- Button.styles = [css_248z$b, css_248z$a, css_248z$9];
664
- __decorate([
665
- n({ attribute: 'icon-align' })
666
- ], Button.prototype, "iconAlign", void 0);
667
- __decorate([
668
- r()
669
- ], Button.prototype, "slotHasContent", void 0);
670
-
671
- var css_248z$8 = i`.button {
672
- --_container-padding: 0.75rem;
673
- width: var(--_button-height);
674
- --_container-padding: 0;
675
- }
676
-
677
- .button.size-xs,
678
- .button.size-extra-small {
679
- --_button-height: 2rem;
680
- --_button-icon-size: 1rem;
681
- }
682
-
683
- .button.size-sm,
684
- .button.size-small {
685
- --_button-height: 2.5rem;
686
- --_button-icon-size: 1.25rem;
687
- --_button-icon-label-spacing: 0.5rem;
688
- }
689
-
690
- .button.size-md,
691
- .button.size-medium {
692
- --_button-height: 3.5rem;
693
- --_button-icon-size: 1.5rem;
694
- }
695
-
696
- .button.size-lg,
697
- .button.size-large {
698
- --_button-height: 6rem;
699
- --_button-icon-size: 2rem;
700
- }
701
-
702
- .button.size-xl {
703
- --_button-height: 8.5rem;
704
- --_button-icon-size: 2.5rem;
705
- }`;
706
-
707
- var _IconButton_id, _IconButton_tabindex;
708
- /**
709
- * @label Icon Button
710
- * @tag icon-button
711
- * @rawTag icon-button
712
- *
713
- * @summary Icon buttons allow users to take actions, and make choices, with a single tap.
714
- *
715
- * @overview
716
- * <p>Icon buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. IconButton labels express what action will occur when the user interacts with it.</p>
717
- *
718
- * @cssprop --button-container-shape: Defines the border radius of the button container shape.
719
- *
720
- * @cssprop --button-container-shape-start-start: Defines the start position of the button container shape.
721
- * @cssprop --button-container-shape-start-end: Defines the end position of the button container shape.
722
- * @cssprop --button-container-shape-end-start: Defines the start position of the button container shape.
723
- * @cssprop --button-container-shape-end-end: Defines the end position of the button container shape.
724
- *
725
- *
726
- * @cssprop --filled-button-container-color: Color of the filled button container.
727
- * @cssprop --filled-button-label-text-color: Text color of the filled button label.
728
- *
729
- * @cssprop --outlined-button-container-color: Color of the outlined button container.
730
- * @cssprop --outlined-button-label-text-color: Text color of the outlined button label.
731
- *
732
- * @cssprop --text-button-label-text-color: Text color of the text button label.
733
- *
734
- * @cssprop --tonal-button-container-color: Color of the tonal button container.
735
- * @cssprop --tonal-button-label-text-color: Text color of the tonal button label.
736
- *
737
- * @cssprop --elevated-button-container-color: Color of the elevated button container.
738
- * @cssprop --elevated-button-label-text-color: Text color of the elevated button label.
739
- *
740
- * @cssprop --neo-button-container-color: Color of the neo button container.
741
- * @cssprop --neo-button-label-text-color: Text color of the neo button label.
742
- *
743
- * @fires {CustomEvent} button:click - Dispatched when the button is clicked.
744
- *
745
- * @example
746
- * ```html
747
- * <icon-button name="home"></icon-button>
748
- * ```
749
- * @tags display
750
- */
751
- class IconButton extends BaseButton {
752
- constructor() {
753
- super(...arguments);
754
- _IconButton_id.set(this, crypto.randomUUID());
755
- _IconButton_tabindex.set(this, 0);
756
- this.provider = 'material-symbols';
757
- }
758
- firstUpdated() {
759
- this.__dispatchClickWithThrottle = throttle(this.__dispatchClick, this.throttleDelay);
760
- this.__convertTypeToVariantAndColor();
761
- }
762
- render() {
763
- const isLink = this.__isLink();
764
- const cssClasses = {
765
- button: true,
766
- 'button-element': true,
767
- [`size-${this.size}`]: true,
768
- [`variant-${this.variant}`]: true,
769
- [`color-${this.color}`]: true,
770
- disabled: this.disabled || this.softDisabled,
771
- pressed: this.isPressed,
772
- skeleton: this.skeleton,
773
- };
774
- if (!isLink) {
775
- return b `<button
776
- class=${e(cssClasses)}
777
- id="button"
778
- tabindex=${__classPrivateFieldGet(this, _IconButton_tabindex, "f")}
779
- type=${this.htmlType}
780
- @click=${this.__dispatchClickWithThrottle}
781
- @mousedown=${this.__handlePress}
782
- @keydown=${this.__handlePress}
783
- @keyup=${this.__handlePress}
784
- ?aria-describedby=${(this.disabled || this.softDisabled) &&
785
- this.disabledReason
786
- ? `disabled-reason-${__classPrivateFieldGet(this, _IconButton_id, "f")}`
787
- : null}
788
- aria-disabled=${`${this.disabled || this.softDisabled}`}
789
- ?disabled=${this.disabled}
790
- ${spread(this.configAria)}
791
- >
792
- ${this.renderButtonContent()}
793
- </button>
794
- ${this.__renderTooltip()}`;
795
- }
796
- return b `<a
797
- class=${e(cssClasses)}
798
- id="button"
799
- tabindex=${__classPrivateFieldGet(this, _IconButton_tabindex, "f")}
800
- href=${this.href}
801
- target=${this.target}
802
- @click=${this.__dispatchClickWithThrottle}
803
- @mousedown=${this.__handlePress}
804
- @keydown=${this.__handlePress}
805
- @keyup=${this.__handlePress}
806
- role="button"
807
- aria-describedby=${this.disabled && this.disabledReason
808
- ? `disabled-reason-${__classPrivateFieldGet(this, _IconButton_id, "f")}`
809
- : null}
810
- aria-disabled=${`${this.disabled}`}
811
- ${spread(this.configAria)}
812
- >
813
- ${this.renderButtonContent()}
814
- </a>
815
- ${this.__renderTooltip()}`;
816
- }
817
- renderButtonContent() {
818
- return b `
819
- <focus-ring class="focus-ring" .control=${this} element="buttonElement"></focus-ring>
820
- <base-elevation class="elevation"></base-elevation>
821
- <div class="neo-background"></div>
822
- <div class="background"></div>
823
- <div class="outline"></div>
824
- <base-ripple class="ripple"></base-ripple>
825
- <base-skeleton class="skeleton"></base-skeleton>
826
-
827
- <div class="button-content">
828
- <base-icon
829
- name=${this.name}
830
- src=${this.src}
831
- provider=${this.provider}
832
- ></base-icon>
833
- </div>
834
-
835
- ${this.__renderDisabledReason()}
836
- `;
837
- }
838
- }
839
- _IconButton_id = new WeakMap(), _IconButton_tabindex = new WeakMap();
840
- IconButton.styles = [css_248z$b, css_248z$a, css_248z$8];
841
- __decorate([
842
- n({ type: String, reflect: true })
843
- ], IconButton.prototype, "name", void 0);
844
- __decorate([
845
- n({ type: String, reflect: true })
846
- ], IconButton.prototype, "src", void 0);
847
- __decorate([
848
- n({ type: String })
849
- ], IconButton.prototype, "provider", void 0);
850
-
851
- var css_248z$7 = i`:host {
852
- display: block;
853
- --progress-height: 0.25rem;
854
- --progress-container-color: var(--color-primary);
855
- --progress-track-color: var(--color-secondary-container);
856
- min-width: 2.5rem;
857
- }
858
-
859
- .linear-progress {
860
- display: flex;
861
- flex-direction: column;
862
- }
863
- .linear-progress .progress-header {
864
- display: flex;
865
- align-items: center;
866
- }
867
- .linear-progress .progress-header .progress-label {
868
- font-family: var(--typography-label-medium-font-family) !important;
869
- font-size: var(--typography-label-medium-font-size) !important;
870
- font-weight: var(--typography-label-medium-font-weight) !important;
871
- line-height: var(--typography-label-medium-line-height) !important;
872
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
873
- color: var(--color-on-surface);
874
- flex: 1;
875
- }
876
- .linear-progress .progress-body {
877
- display: flex;
878
- flex-direction: column;
879
- }
880
- .linear-progress .progress-body .linear-progress-container {
881
- position: relative;
882
- display: flex;
883
- align-items: flex-start;
884
- width: 100%;
885
- margin: var(--spacing-100) 0;
886
- }
887
- .linear-progress .progress-body .linear-progress-container .track {
888
- position: relative;
889
- }
890
- .linear-progress .progress-body .linear-progress-container .track:after {
891
- content: "";
892
- position: absolute;
893
- display: block;
894
- top: 0;
895
- left: 0;
896
- width: calc(100% - 0.25rem);
897
- height: var(--progress-height);
898
- background: var(--progress-track-color);
899
- border-radius: var(--shape-corner-full);
900
- }
901
- .linear-progress .progress-body .linear-progress-container .track-start:after {
902
- margin-inline-end: 0.25rem;
903
- }
904
- .linear-progress .progress-body .linear-progress-container .active-indicator {
905
- height: var(--progress-height);
906
- background: var(--progress-container-color);
907
- border-radius: var(--shape-corner-full);
908
- }
909
- .linear-progress .progress-body .linear-progress-container .track-end {
910
- flex: 1;
911
- }
912
- .linear-progress .progress-body .linear-progress-container .track-end:after {
913
- margin-inline-start: 0.25rem;
914
- }
915
- .linear-progress .progress-body .progress-helper {
916
- font-family: var(--typography-body-small-font-family) !important;
917
- font-size: var(--typography-body-small-font-size) !important;
918
- font-weight: var(--typography-body-small-font-weight) !important;
919
- line-height: var(--typography-body-small-line-height) !important;
920
- letter-spacing: var(--typography-body-small-letter-spacing) !important;
921
- color: var(--color-on-surface-variant);
922
- }
923
- .linear-progress:not(.indeterminate) .track-start {
924
- transition: width var(--duration-medium2) var(--easing-standard);
925
- }
926
- .linear-progress:not(.indeterminate) .active-indicator {
927
- transition: width var(--duration-medium2) var(--easing-standard);
928
- }
929
- .linear-progress.indeterminate .linear-progress-container .track-start {
930
- animation-duration: 3s;
931
- animation-iteration-count: infinite;
932
- animation-name: track-start-indeterminate;
933
- animation-timing-function: var(--easing-linear);
934
- }
935
- .linear-progress.indeterminate .linear-progress-container .active-indicator {
936
- animation-duration: 3s;
937
- animation-iteration-count: infinite;
938
- animation-name: active-indicator-indeterminate;
939
- animation-timing-function: var(--easing-linear);
940
- }
941
- .linear-progress.inline {
942
- flex-direction: row;
943
- gap: var(--spacing-200);
944
- }
945
- .linear-progress.inline .progress-body {
946
- flex: 1;
947
- }
948
-
949
- @keyframes track-start-indeterminate {
950
- 0% {
951
- width: 0;
952
- }
953
- 50% {
954
- width: 33%;
955
- }
956
- 80%, to {
957
- width: 100%;
958
- padding-inline-end: 0;
959
- }
960
- }
961
- @keyframes active-indicator-indeterminate {
962
- 0% {
963
- width: 0;
964
- }
965
- 50% {
966
- width: 33%;
967
- }
968
- 80%, to {
969
- width: 0;
970
- }
971
- }`;
972
-
973
- /**
974
- * @label Linear Progress
975
- * @tag linear-progress
976
- * @rawTag linear-progress
977
- *
978
- * @summary A linear progress indicator is a visual representation of progress toward a specific goal.
979
- *
980
- * @example
981
- * ```html
982
- * <linear-progress value="30" style="width:10rem"></linear-progress>
983
- * ```
984
- */
985
- class LinearProgress extends BaseProgress {
986
- render() {
987
- return b `
988
- <div
989
- class="${e({
990
- 'linear-progress': true,
991
- indeterminate: this.indeterminate,
992
- inline: this.inline,
993
- })}"
994
- >
995
- ${this.label
996
- ? b `<div class="progress-header">
997
- <label class="progress-label">${this.label}</label>
998
- </div>`
999
- : ''}
1000
-
1001
- <div class="progress-body">
1002
- <div
1003
- class="linear-progress-container"
1004
- title=${this.label}
1005
- ?aria-valuenow="${this.__getPercentageValue()}"
1006
- aria-valuemin="0"
1007
- aria-valuemax="100"
1008
- role="progressbar"
1009
- >
1010
- <div class="track track-start"></div>
1011
- <div
1012
- class="active-indicator"
1013
- style="${o({
1014
- width: `${this.__getPercentageValue()}%`,
1015
- })}"
1016
- ></div>
1017
- <div class="track track-end"></div>
1018
- </div>
1019
-
1020
- ${this.helperText
1021
- ? b `<div class="progress-helper">${this.helperText}</div>`
1022
- : ''}
1023
- </div>
1024
- </div>
1025
- `;
1026
- }
1027
- }
1028
- // Lit components use static styles for better performance
1029
- LinearProgress.styles = [css_248z$7];
1030
-
1031
- var css_248z$6 = i`:host {
1032
- display: inline-block;
1033
- --progress-height: 1.5rem;
1034
- --progress-line-thickness: 4px;
1035
- --progress-container-color: var(--color-primary);
1036
- --progress-track-color: var(--color-secondary-container);
1037
- }
1038
-
1039
- .circular-progress {
1040
- display: flex;
1041
- flex-direction: column;
1042
- }
1043
- .circular-progress .circular-progress-container {
1044
- position: relative;
1045
- width: 100%;
1046
- --_container-height: clamp(0rem, var(--progress-height), 15rem);
1047
- height: var(--_container-height);
1048
- }
1049
- .circular-progress .circular-progress-container .progress-label {
1050
- font-family: var(--typography-label-large-emphasized-font-family) !important;
1051
- font-size: var(--typography-label-large-emphasized-font-size) !important;
1052
- font-weight: var(--typography-label-large-emphasized-font-weight) !important;
1053
- line-height: var(--typography-label-large-emphasized-line-height) !important;
1054
- letter-spacing: var(--typography-label-large-emphasized-letter-spacing) !important;
1055
- color: var(--color-on-surface);
1056
- flex: 1;
1057
- width: 100%;
1058
- height: 100%;
1059
- display: flex;
1060
- align-items: center;
1061
- justify-content: center;
1062
- }
1063
- .circular-progress .circular-progress-container svg {
1064
- transform: rotate(-90deg);
1065
- width: 100%;
1066
- height: 100%;
1067
- }
1068
- .circular-progress .circular-progress-container circle {
1069
- fill: none;
1070
- stroke-linecap: round;
1071
- transition: stroke-dashoffset var(--duration-medium2) var(--easing-standard);
1072
- }
1073
- .circular-progress .circular-progress-container .track {
1074
- stroke: var(--progress-track-color);
1075
- stroke-width: calc(var(--progress-line-thickness) / (tan(atan2(var(--_container-height), 1px)) / 16));
1076
- }
1077
- .circular-progress .circular-progress-container .active-indicator {
1078
- stroke: var(--progress-container-color);
1079
- stroke-width: calc(var(--progress-line-thickness) / (tan(atan2(var(--_container-height), 1px)) / 16));
1080
- }
1081
- .circular-progress.indeterminate .active-indicator {
1082
- animation: arc-indeterminate 1.5s ease-in-out infinite;
1083
- }
1084
- .circular-progress .progress-label {
1085
- font-family: var(--typography-label-medium-font-family) !important;
1086
- font-size: var(--typography-label-medium-font-size) !important;
1087
- font-weight: var(--typography-label-medium-font-weight) !important;
1088
- line-height: var(--typography-label-medium-line-height) !important;
1089
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
1090
- color: var(--color-on-surface);
1091
- }
1092
- .circular-progress .progress-helper {
1093
- font-family: var(--typography-label-small-font-family) !important;
1094
- font-size: var(--typography-label-small-font-size) !important;
1095
- font-weight: var(--typography-label-small-font-weight) !important;
1096
- line-height: var(--typography-label-small-line-height) !important;
1097
- letter-spacing: var(--typography-label-small-letter-spacing) !important;
1098
- color: var(--color-on-surface-variant);
1099
- text-align: center;
1100
- }
1101
- .circular-progress.inline {
1102
- flex-direction: row;
1103
- align-items: center;
1104
- gap: var(--spacing-200);
1105
- }
1106
- .circular-progress.inline .progress-footer {
1107
- flex: 1;
1108
- }
1109
- .circular-progress.inline .progress-helper {
1110
- text-align: right;
1111
- }
1112
-
1113
- @keyframes rotate-container {
1114
- 100% {
1115
- transform: rotate(360deg);
1116
- }
1117
- }
1118
- @keyframes arc-indeterminate {
1119
- 0% {
1120
- stroke-dasharray: 1, 150;
1121
- stroke-dashoffset: 0;
1122
- }
1123
- 50% {
1124
- stroke-dasharray: 90, 150;
1125
- stroke-dashoffset: -35;
1126
- }
1127
- 100% {
1128
- stroke-dasharray: 90, 150;
1129
- stroke-dashoffset: -124;
1130
- }
1131
- }`;
1132
-
1133
- /**
1134
- * @label Circular Progress
1135
- * @tag circular-progress
1136
- * @rawTag circular-progress
1137
- *
1138
- * @summary A circular progress indicator is a visual representation of progress toward a specific goal.
1139
- *
1140
- * @example
1141
- * ```html
1142
- * <circular-progress value="30"></circular-progress>
1143
- * ```
1144
- */
1145
- class CircularProgress extends BaseProgress {
1146
- render() {
1147
- const percentage = this.__getPercentageValue();
1148
- // Radius of 18 with stroke 4 fits nicely in a 40x40 viewBox
1149
- const radius = 6;
1150
- const circumference = 2 * Math.PI * radius;
1151
- const offset = circumference - (percentage / 100) * circumference;
1152
- return b `
1153
- <div
1154
- class="${e({
1155
- 'circular-progress': true,
1156
- indeterminate: this.indeterminate,
1157
- inline: this.inline,
1158
- })}"
1159
- title=${this.label}
1160
- role="progressbar"
1161
- aria-valuenow="${this.indeterminate ? undefined : percentage}"
1162
- aria-valuemin="0"
1163
- aria-valuemax="100"
1164
- >
1165
- <div class="circular-progress-container">
1166
- <svg viewBox="0 0 16 16">
1167
- <circle class="track" cx="8" cy="8" r="6"></circle>
1168
- <circle
1169
- class="active-indicator"
1170
- cx="8"
1171
- cy="8"
1172
- r="6"
1173
- style="${o({
1174
- strokeDasharray: `${circumference}`,
1175
- strokeDashoffset: this.indeterminate ? undefined : `${offset}`,
1176
- })}"
1177
- ></circle>
1178
- </svg>
1179
- </div>
1180
-
1181
- <div class="progress-footer">
1182
- ${this.label
1183
- ? b `<div class="progress-label">${this.label}</div>`
1184
- : ''}
1185
- ${this.helperText
1186
- ? b `<div class="progress-helper">${this.helperText}</div>`
1187
- : ''}
1188
- </div>
1189
- </div>
1190
- `;
1191
- }
1192
- }
1193
- // Lit components use static styles for better performance
1194
- CircularProgress.styles = [css_248z$6];
1195
-
1196
- var css_248z$5 = i`* {
1197
- box-sizing: border-box;
1198
- }
1199
-
1200
- .screen-reader-only {
1201
- display: none !important;
1202
- }
1203
-
1204
- :host {
1205
- display: block;
1206
- width: 100%;
1207
- }
1208
-
1209
- .input-element {
1210
- border: none;
1211
- outline: none;
1212
- margin: 0;
1213
- padding: 0;
1214
- }
1215
-
1216
- .input-wrapper .input {
1217
- flex: 1;
1218
- width: 100%;
1219
- background: none;
1220
- cursor: inherit;
1221
- }
1222
- .input-wrapper .password-toggle {
1223
- --button-container-shape: var(--shape-corner-full);
1224
- }`;
1225
-
1226
- /**
1227
- * @label Input
1228
- * @tag input-field
1229
- * @rawTag input
1230
- *
1231
- * @summary The Input component is used to capture user input.
1232
- *
1233
- * @example
1234
- * ```html
1235
- * <input-field label="Name" required placeholder="Enter your name"></input-field>
1236
- * ```
1237
- */
1238
- class Input extends BaseInput {
1239
- constructor() {
1240
- super(...arguments);
1241
- this.value = '';
1242
- this.name = '';
1243
- this.placeholder = '';
1244
- this.label = '';
1245
- this.inline = false;
1246
- this.size = 'md';
1247
- this.type = 'text';
1248
- this.autocomplete = 'off';
1249
- this.configAria = {};
1250
- this.variant = 'default';
1251
- /**
1252
- * Helper text to display below the input.
1253
- */
1254
- this.helperText = '';
1255
- this.error = false;
1256
- this.errorText = '';
1257
- this.warning = false;
1258
- this.warningText = '';
1259
- this.focused = false;
1260
- this.passwordVisible = false;
1261
- /**
1262
- * Returns true when the text field has been interacted with. Native
1263
- * validation errors only display in response to user interactions.
1264
- */
1265
- this.dirty = false;
1266
- }
1267
- connectedCallback() {
1268
- super.connectedCallback();
1269
- this.handleInitialAttributes();
1270
- }
1271
- handleInitialAttributes() {
1272
- if (this.hasAttribute('tabindex')) {
1273
- this.tabindex = this.getAttribute('tabindex') || undefined;
1274
- this.removeAttribute('tabindex');
1275
- }
1276
- Array.from(this.attributes).forEach(attr => {
1277
- if (attr.name.startsWith('aria-')) {
1278
- this.configAria[attr.name] = attr.value;
1279
- this.removeAttribute(attr.name);
1280
- }
1281
- });
1282
- }
1283
- __handleInput(event) {
1284
- this.dirty = true;
1285
- this.value = event.target.value;
1286
- }
1287
- focus() {
1288
- this.inputElement?.focus();
1289
- }
1290
- blur() {
1291
- this.inputElement?.blur();
1292
- }
1293
- __handleFocusChange() {
1294
- // When calling focus() or reportValidity() during change, it's possible
1295
- // for blur to be called after the new focus event. Rather than set
1296
- // `this.focused` to true/false on focus/blur, we always set it to whether
1297
- // or not the input itself is focused.
1298
- this.focused = this.inputElement?.matches(':focus') ?? false;
1299
- }
1300
- __redispatchEvent(event) {
1301
- redispatchEvent(this, event);
1302
- }
1303
- render() {
1304
- const displayType = this.type === 'password' && this.passwordVisible ? 'text' : this.type;
1305
- return b `
1306
- <base-field
1307
- ?required=${this.required}
1308
- ?disabled=${this.disabled}
1309
- ?readonly=${this.readonly}
1310
- ?skeleton=${this.skeleton}
1311
- helper-text=${this.helperText}
1312
- ?error=${this.error}
1313
- error-text=${this.errorText}
1314
- ?warning=${this.warning}
1315
- variant=${this.variant}
1316
- ?populated=${!!this.value}
1317
- warning-text=${this.warningText}
1318
- label=${this.label}
1319
- ?focused=${this.focused}
1320
- .host=${this}
1321
- class="input-wrapper"
1322
- >
1323
- <slot name="start" slot="field-start"></slot>
1324
-
1325
- <input
1326
- class="input input-element"
1327
- name=${this.name}
1328
- type=${displayType}
1329
- placeholder=${this.placeholder}
1330
- autocomplete=${this.autocomplete}
1331
- .value=${this.value}
1332
- ?tabindex=${this.tabindex}
1333
- ?readonly=${this.readonly}
1334
- ?required=${this.required}
1335
- ?disabled=${this.disabled}
1336
- @input=${this.__handleInput}
1337
- @change=${this.__redispatchEvent}
1338
- @focus=${this.__handleFocusChange}
1339
- @blur=${this.__handleFocusChange}
1340
- ${spread(this.configAria)}
1341
- />
1342
-
1343
- ${this.type === 'password'
1344
- ? b `
1345
- <pc-tooltip
1346
- slot="field-end"
1347
- content=${this.passwordVisible
1348
- ? 'Hide password'
1349
- : 'Show password'}
1350
- >
1351
- <icon-button
1352
- class="password-toggle"
1353
- variant="text"
1354
- name=${this.passwordVisible ? 'visibility_off' : 'visibility'}
1355
- @click=${() => {
1356
- this.passwordVisible = !this.passwordVisible;
1357
- }}
1358
- >
1359
- </icon-button>
1360
- </pc-tooltip>
1361
- `
1362
- : A}
1363
-
1364
- <slot name="end" slot="field-end"></slot>
1365
- </base-field>
1366
- `;
1367
- }
1368
- }
1369
- Input.styles = [css_248z$5];
1370
- __decorate([
1371
- n({ type: String })
1372
- ], Input.prototype, "value", void 0);
1373
- __decorate([
1374
- n({ type: String })
1375
- ], Input.prototype, "name", void 0);
1376
- __decorate([
1377
- n({ type: String })
1378
- ], Input.prototype, "placeholder", void 0);
1379
- __decorate([
1380
- n({ type: String })
1381
- ], Input.prototype, "label", void 0);
1382
- __decorate([
1383
- n({ type: Boolean, reflect: true })
1384
- ], Input.prototype, "inline", void 0);
1385
- __decorate([
1386
- n({ type: String, reflect: true })
1387
- ], Input.prototype, "size", void 0);
1388
- __decorate([
1389
- n({ type: String })
1390
- ], Input.prototype, "type", void 0);
1391
- __decorate([
1392
- n({ type: String })
1393
- ], Input.prototype, "autocomplete", void 0);
1394
- __decorate([
1395
- n({ type: Object })
1396
- ], Input.prototype, "configAria", void 0);
1397
- __decorate([
1398
- n({ type: String })
1399
- ], Input.prototype, "variant", void 0);
1400
- __decorate([
1401
- n({ type: String, attribute: 'helper-text' })
1402
- ], Input.prototype, "helperText", void 0);
1403
- __decorate([
1404
- n({ type: Boolean })
1405
- ], Input.prototype, "error", void 0);
1406
- __decorate([
1407
- n({ type: String, attribute: 'error-text' })
1408
- ], Input.prototype, "errorText", void 0);
1409
- __decorate([
1410
- n({ type: Boolean })
1411
- ], Input.prototype, "warning", void 0);
1412
- __decorate([
1413
- n({ type: String, attribute: 'warning-text' })
1414
- ], Input.prototype, "warningText", void 0);
1415
- __decorate([
1416
- r()
1417
- ], Input.prototype, "focused", void 0);
1418
- __decorate([
1419
- r()
1420
- ], Input.prototype, "passwordVisible", void 0);
1421
- __decorate([
1422
- r()
1423
- ], Input.prototype, "dirty", void 0);
1424
- __decorate([
1425
- e$1('.input-element')
1426
- ], Input.prototype, "inputElement", void 0);
1427
-
1428
- var css_248z$4 = i`* {
1429
- box-sizing: border-box;
1430
- }
1431
-
1432
- .screen-reader-only {
1433
- display: none !important;
1434
- }
1435
-
1436
- :host {
1437
- display: block;
1438
- width: 100%;
1439
- }
1440
-
1441
- .input-element {
1442
- border: none;
1443
- outline: none;
1444
- margin: 0;
1445
- padding: 0;
1446
- }
1447
-
1448
- .input-wrapper .input {
1449
- flex: 1;
1450
- width: 100%;
1451
- background: none;
1452
- cursor: inherit;
1453
- }
1454
- .input-wrapper .password-toggle {
1455
- --button-container-shape: var(--shape-corner-full);
1456
- }
1457
-
1458
- .stepper {
1459
- /* Chrome, Safari, Edge, Opera */
1460
- }
1461
- .stepper input::-webkit-outer-spin-button,
1462
- .stepper input::-webkit-inner-spin-button {
1463
- -webkit-appearance: none;
1464
- margin: 0;
1465
- }
1466
- .stepper {
1467
- /* Firefox */
1468
- }
1469
- .stepper input[type=number] {
1470
- -moz-appearance: textfield;
1471
- }`;
1472
-
1473
- var _NumberField_id;
1474
- /**
1475
- * @label Number Field
1476
- * @tag number-field
1477
- * @rawTag number
1478
- *
1479
- * @summary The Number Field component is used to capture numeric user input.
1480
- *
1481
- * @example
1482
- * ```html
1483
- * <number-field label="Age" placeholder="Enter your age"></number-field>
1484
- * ```
1485
- */
1486
- class NumberField extends BaseInput {
1487
- constructor() {
1488
- super(...arguments);
1489
- _NumberField_id.set(this, crypto.randomUUID());
1490
- this.name = '';
1491
- this.placeholder = '';
1492
- this.label = '';
1493
- this.inline = false;
1494
- this.size = 'md';
1495
- this.autocomplete = 'off';
1496
- this.configAria = {};
1497
- /**
1498
- * Helper text to display below the input.
1499
- */
1500
- this.helperText = '';
1501
- this.error = false;
1502
- this.errorText = '';
1503
- this.warning = false;
1504
- this.warningText = '';
1505
- this.stepper = false;
1506
- this.focused = false;
1507
- /**
1508
- * Returns true when the text field has been interacted with. Native
1509
- * validation errors only display in response to user interactions.
1510
- */
1511
- this.dirty = false;
1512
- }
1513
- connectedCallback() {
1514
- super.connectedCallback();
1515
- this.handleInitialAttributes();
1516
- }
1517
- handleInitialAttributes() {
1518
- if (this.hasAttribute('tabindex')) {
1519
- this.tabindex = this.getAttribute('tabindex') || undefined;
1520
- this.removeAttribute('tabindex');
1521
- }
1522
- Array.from(this.attributes).forEach(attr => {
1523
- if (attr.name.startsWith('aria-')) {
1524
- this.configAria[attr.name] = attr.value;
1525
- this.removeAttribute(attr.name);
1526
- }
1527
- });
1528
- }
1529
- __handleInput(event) {
1530
- this.dirty = true;
1531
- this.value = Number(event.target.value);
1532
- }
1533
- focus() {
1534
- this.inputElement?.focus();
1535
- }
1536
- blur() {
1537
- this.inputElement?.blur();
1538
- }
1539
- __handleFocusChange() {
1540
- // When calling focus() or reportValidity() during change, it's possible
1541
- // for blur to be called after the new focus event. Rather than set
1542
- // `this.focused` to true/false on focus/blur, we always set it to whether
1543
- // or not the input itself is focused.
1544
- this.focused = this.inputElement?.matches(':focus') ?? false;
1545
- }
1546
- __redispatchEvent(event) {
1547
- redispatchEvent(this, event);
1548
- }
1549
- stepUp() {
1550
- this.inputElement?.stepUp();
1551
- }
1552
- stepDown() {
1553
- this.inputElement?.stepDown();
1554
- }
1555
- render() {
1556
- const classes = {
1557
- 'input-wrapper': true,
1558
- stepper: this.stepper,
1559
- };
1560
- return b `
1561
- <base-field
1562
- ?required=${this.required}
1563
- ?disabled=${this.disabled}
1564
- ?readonly=${this.readonly}
1565
- ?skeleton=${this.skeleton}
1566
- helper-text=${this.helperText}
1567
- ?error=${this.error}
1568
- error-text=${this.errorText}
1569
- ?warning=${this.warning}
1570
- warning-text=${this.warningText}
1571
- label=${this.label}
1572
- ?focused=${this.focused}
1573
- .host=${this}
1574
- class=${e(classes)}
1575
- >
1576
- ${this.stepper && !this.disabled
1577
- ? b `<icon-button
1578
- class="stepper"
1579
- name="remove"
1580
- variant="text"
1581
- slot="field-start"
1582
- @click=${this.stepDown}
1583
- ></icon-button>`
1584
- : A}
1585
-
1586
- <slot name="start" slot="field-start"></slot>
1587
-
1588
- <input
1589
- class="input input-element"
1590
- name=${this.name}
1591
- type="number"
1592
- placeholder=${this.placeholder}
1593
- autocomplete=${this.autocomplete}
1594
- .value=${this.value}
1595
- ?tabindex=${this.tabindex}
1596
- ?readonly=${this.readonly}
1597
- ?required=${this.required}
1598
- ?disabled=${this.disabled}
1599
- min=${this.min}
1600
- max=${this.max}
1601
- step=${this.step}
1602
- @input=${this.__handleInput}
1603
- @change=${this.__redispatchEvent}
1604
- @focus=${this.__handleFocusChange}
1605
- @blur=${this.__handleFocusChange}
1606
- ${spread(this.configAria)}
1607
- />
1608
-
1609
- <slot name="end" slot="field-end"></slot>
1610
-
1611
- ${this.stepper && !this.disabled
1612
- ? b `<icon-button
1613
- class="stepper"
1614
- variant="text"
1615
- name="add"
1616
- slot="field-end"
1617
- @click=${this.stepUp}
1618
- ></icon-button>`
1619
- : A}
1620
- </base-field>
1621
- `;
1622
- }
1623
- }
1624
- _NumberField_id = new WeakMap();
1625
- NumberField.styles = [css_248z$4];
1626
- __decorate([
1627
- n({ type: Number })
1628
- ], NumberField.prototype, "value", void 0);
1629
- __decorate([
1630
- n({ type: String })
1631
- ], NumberField.prototype, "name", void 0);
1632
- __decorate([
1633
- n({ type: String })
1634
- ], NumberField.prototype, "placeholder", void 0);
1635
- __decorate([
1636
- n({ type: String })
1637
- ], NumberField.prototype, "label", void 0);
1638
- __decorate([
1639
- n({ type: Boolean, reflect: true })
1640
- ], NumberField.prototype, "inline", void 0);
1641
- __decorate([
1642
- n({ type: String, reflect: true })
1643
- ], NumberField.prototype, "size", void 0);
1644
- __decorate([
1645
- n({ type: Number })
1646
- ], NumberField.prototype, "max", void 0);
1647
- __decorate([
1648
- n({ type: Number })
1649
- ], NumberField.prototype, "min", void 0);
1650
- __decorate([
1651
- n({ type: Number })
1652
- ], NumberField.prototype, "step", void 0);
1653
- __decorate([
1654
- n({ type: String })
1655
- ], NumberField.prototype, "autocomplete", void 0);
1656
- __decorate([
1657
- n({ type: Object })
1658
- ], NumberField.prototype, "configAria", void 0);
1659
- __decorate([
1660
- n({ type: String, attribute: 'helper-text' })
1661
- ], NumberField.prototype, "helperText", void 0);
1662
- __decorate([
1663
- n({ type: Boolean })
1664
- ], NumberField.prototype, "error", void 0);
1665
- __decorate([
1666
- n({ type: String, attribute: 'error-text' })
1667
- ], NumberField.prototype, "errorText", void 0);
1668
- __decorate([
1669
- n({ type: Boolean })
1670
- ], NumberField.prototype, "warning", void 0);
1671
- __decorate([
1672
- n({ type: String, attribute: 'warning-text' })
1673
- ], NumberField.prototype, "warningText", void 0);
1674
- __decorate([
1675
- n({ type: Boolean })
1676
- ], NumberField.prototype, "stepper", void 0);
1677
- __decorate([
1678
- r()
1679
- ], NumberField.prototype, "focused", void 0);
1680
- __decorate([
1681
- r()
1682
- ], NumberField.prototype, "dirty", void 0);
1683
- __decorate([
1684
- e$1('.input-element')
1685
- ], NumberField.prototype, "inputElement", void 0);
1686
-
1687
- var css_248z$3 = i`* {
1688
- box-sizing: border-box;
1689
- }
1690
-
1691
- .screen-reader-only {
1692
- display: none !important;
1693
- }
1694
-
1695
- :host {
1696
- display: block;
1697
- width: 100%;
1698
- }
1699
-
1700
- .input-element {
1701
- border: none;
1702
- outline: none;
1703
- margin: 0;
1704
- padding: 0;
1705
- }
1706
-
1707
- .input-wrapper .input {
1708
- flex: 1;
1709
- width: 100%;
1710
- background: none;
1711
- cursor: inherit;
1712
- }
1713
- .input-wrapper .input::-webkit-inner-spin-button,
1714
- .input-wrapper .input::-webkit-calendar-picker-indicator {
1715
- display: none;
1716
- -webkit-appearance: none;
1717
- }`;
1718
-
1719
- /**
1720
- * @label Date Picker
1721
- * @tag date-picker
1722
- * @rawTag date-picker
1723
- *
1724
- * @summary The Date Picker component is used to capture date user input.
1725
- *
1726
- * @example
1727
- * ```html
1728
- * <date-picker label="Name" required placeholder="Enter your name"></date-picker>
1729
- * ```
1730
- */
1731
- class DatePicker extends BaseInput {
1732
- constructor() {
1733
- super(...arguments);
1734
- this.value = '';
1735
- this.name = '';
1736
- this.placeholder = '';
1737
- this.label = '';
1738
- this.inline = false;
1739
- this.size = 'md';
1740
- this.autocomplete = 'off';
1741
- this.configAria = {};
1742
- this.variant = 'default';
1743
- /**
1744
- * Helper text to display below the input.
1745
- */
1746
- this.helperText = '';
1747
- this.error = false;
1748
- this.errorText = '';
1749
- this.warning = false;
1750
- this.warningText = '';
1751
- this.focused = false;
1752
- this.passwordVisible = false;
1753
- /**
1754
- * Returns true when the text field has been interacted with. Native
1755
- * validation errors only display in response to user interactions.
1756
- */
1757
- this.dirty = false;
1758
- }
1759
- connectedCallback() {
1760
- super.connectedCallback();
1761
- this.handleInitialAttributes();
1762
- }
1763
- handleInitialAttributes() {
1764
- if (this.hasAttribute('tabindex')) {
1765
- this.tabindex = this.getAttribute('tabindex') || undefined;
1766
- this.removeAttribute('tabindex');
1767
- }
1768
- Array.from(this.attributes).forEach(attr => {
1769
- if (attr.name.startsWith('aria-')) {
1770
- this.configAria[attr.name] = attr.value;
1771
- this.removeAttribute(attr.name);
1772
- }
1773
- });
1774
- }
1775
- __handleInput(event) {
1776
- this.dirty = true;
1777
- this.value = event.target.value;
1778
- }
1779
- focus() {
1780
- this.inputElement?.focus();
1781
- }
1782
- blur() {
1783
- this.inputElement?.blur();
1784
- }
1785
- __handleFocusChange() {
1786
- // When calling focus() or reportValidity() during change, it's possible
1787
- // for blur to be called after the new focus event. Rather than set
1788
- // `this.focused` to true/false on focus/blur, we always set it to whether
1789
- // or not the input itself is focused.
1790
- this.focused = this.inputElement?.matches(':focus') ?? false;
1791
- }
1792
- __redispatchEvent(event) {
1793
- redispatchEvent(this, event);
1794
- }
1795
- render() {
1796
- return b `
1797
- <base-field
1798
- ?required=${this.required}
1799
- ?disabled=${this.disabled}
1800
- ?readonly=${this.readonly}
1801
- ?skeleton=${this.skeleton}
1802
- helper-text=${this.helperText}
1803
- ?error=${this.error}
1804
- error-text=${this.errorText}
1805
- ?warning=${this.warning}
1806
- variant=${this.variant}
1807
- ?populated=${!!this.value}
1808
- warning-text=${this.warningText}
1809
- label=${this.label}
1810
- ?focused=${this.focused}
1811
- .host=${this}
1812
- class="input-wrapper"
1813
- >
1814
- <slot name="start" slot="field-start"></slot>
1815
-
1816
- <input
1817
- class="input input-element"
1818
- name=${this.name}
1819
- type="date"
1820
- placeholder=${this.placeholder}
1821
- autocomplete=${this.autocomplete}
1822
- .value=${this.value}
1823
- ?tabindex=${this.tabindex}
1824
- ?readonly=${this.readonly}
1825
- ?required=${this.required}
1826
- ?disabled=${this.disabled}
1827
- @input=${this.__handleInput}
1828
- @change=${this.__redispatchEvent}
1829
- @focus=${this.__handleFocusChange}
1830
- @blur=${this.__handleFocusChange}
1831
- ${spread(this.configAria)}
1832
- />
1833
-
1834
- <slot name="end" slot="field-end"></slot>
1835
-
1836
- <icon-button
1837
- slot="field-end"
1838
- color="secondary"
1839
- variant="text"
1840
- name="calendar_today"
1841
- ?disabled=${this.disabled}
1842
- @click=${() => {
1843
- setTimeout(() => {
1844
- // @ts-ignore
1845
- this.inputElement.showPicker();
1846
- });
1847
- }}
1848
- >
1849
- </icon-button>
1850
- </base-field>
1851
- `;
1852
- }
1853
- }
1854
- DatePicker.styles = [css_248z$3];
1855
- __decorate([
1856
- n({ type: String })
1857
- ], DatePicker.prototype, "value", void 0);
1858
- __decorate([
1859
- n({ type: String })
1860
- ], DatePicker.prototype, "name", void 0);
1861
- __decorate([
1862
- n({ type: String })
1863
- ], DatePicker.prototype, "placeholder", void 0);
1864
- __decorate([
1865
- n({ type: String })
1866
- ], DatePicker.prototype, "label", void 0);
1867
- __decorate([
1868
- n({ type: Boolean, reflect: true })
1869
- ], DatePicker.prototype, "inline", void 0);
1870
- __decorate([
1871
- n({ type: String, reflect: true })
1872
- ], DatePicker.prototype, "size", void 0);
1873
- __decorate([
1874
- n({ type: String })
1875
- ], DatePicker.prototype, "autocomplete", void 0);
1876
- __decorate([
1877
- n({ type: Object })
1878
- ], DatePicker.prototype, "configAria", void 0);
1879
- __decorate([
1880
- n({ type: String })
1881
- ], DatePicker.prototype, "variant", void 0);
1882
- __decorate([
1883
- n({ type: String, attribute: 'helper-text' })
1884
- ], DatePicker.prototype, "helperText", void 0);
1885
- __decorate([
1886
- n({ type: Boolean })
1887
- ], DatePicker.prototype, "error", void 0);
1888
- __decorate([
1889
- n({ type: String, attribute: 'error-text' })
1890
- ], DatePicker.prototype, "errorText", void 0);
1891
- __decorate([
1892
- n({ type: Boolean })
1893
- ], DatePicker.prototype, "warning", void 0);
1894
- __decorate([
1895
- n({ type: String, attribute: 'warning-text' })
1896
- ], DatePicker.prototype, "warningText", void 0);
1897
- __decorate([
1898
- r()
1899
- ], DatePicker.prototype, "focused", void 0);
1900
- __decorate([
1901
- r()
1902
- ], DatePicker.prototype, "passwordVisible", void 0);
1903
- __decorate([
1904
- r()
1905
- ], DatePicker.prototype, "dirty", void 0);
1906
- __decorate([
1907
- e$1('.input-element')
1908
- ], DatePicker.prototype, "inputElement", void 0);
1909
-
1910
- var css_248z$2 = i`* {
1911
- box-sizing: border-box;
1912
- }
1913
-
1914
- .screen-reader-only {
1915
- display: none !important;
1916
- }
1917
-
1918
- :host {
1919
- display: block;
1920
- width: 100%;
1921
- }
1922
-
1923
- .input-element {
1924
- border: none;
1925
- outline: none;
1926
- margin: 0;
1927
- padding: 0;
1928
- }
1929
-
1930
- .input-wrapper .input {
1931
- flex: 1;
1932
- width: 100%;
1933
- background: none;
1934
- cursor: inherit;
1935
- }
1936
- .input-wrapper .input::-webkit-inner-spin-button,
1937
- .input-wrapper .input::-webkit-calendar-picker-indicator {
1938
- display: none;
1939
- -webkit-appearance: none;
1940
- }`;
1941
-
1942
- /**
1943
- * @label Time Picker
1944
- * @tag time-picker
1945
- * @rawTag time-picker
1946
- *
1947
- * @summary The Time Picker component is used to capture time user input.
1948
- *
1949
- * @example
1950
- * ```html
1951
- * <time-picker label="Name" required placeholder="Enter your name"></time-picker>
1952
- * ```
1953
- */
1954
- class TimePicker extends BaseInput {
1955
- constructor() {
1956
- super(...arguments);
1957
- this.value = '';
1958
- this.name = '';
1959
- this.placeholder = '';
1960
- this.label = '';
1961
- this.inline = false;
1962
- this.size = 'md';
1963
- this.autocomplete = 'off';
1964
- this.configAria = {};
1965
- this.variant = 'default';
1966
- /**
1967
- * Helper text to display below the input.
1968
- */
1969
- this.helperText = '';
1970
- this.error = false;
1971
- this.errorText = '';
1972
- this.warning = false;
1973
- this.warningText = '';
1974
- this.focused = false;
1975
- this.passwordVisible = false;
1976
- /**
1977
- * Returns true when the text field has been interacted with. Native
1978
- * validation errors only display in response to user interactions.
1979
- */
1980
- this.dirty = false;
1981
- }
1982
- connectedCallback() {
1983
- super.connectedCallback();
1984
- this.handleInitialAttributes();
1985
- }
1986
- handleInitialAttributes() {
1987
- if (this.hasAttribute('tabindex')) {
1988
- this.tabindex = this.getAttribute('tabindex') || undefined;
1989
- this.removeAttribute('tabindex');
1990
- }
1991
- Array.from(this.attributes).forEach(attr => {
1992
- if (attr.name.startsWith('aria-')) {
1993
- this.configAria[attr.name] = attr.value;
1994
- this.removeAttribute(attr.name);
1995
- }
1996
- });
1997
- }
1998
- __handleInput(event) {
1999
- this.dirty = true;
2000
- this.value = event.target.value;
2001
- }
2002
- focus() {
2003
- this.inputElement?.focus();
2004
- }
2005
- blur() {
2006
- this.inputElement?.blur();
2007
- }
2008
- __handleFocusChange() {
2009
- // When calling focus() or reportValidity() during change, it's possible
2010
- // for blur to be called after the new focus event. Rather than set
2011
- // `this.focused` to true/false on focus/blur, we always set it to whether
2012
- // or not the input itself is focused.
2013
- this.focused = this.inputElement?.matches(':focus') ?? false;
2014
- }
2015
- __redispatchEvent(event) {
2016
- redispatchEvent(this, event);
2017
- }
2018
- render() {
2019
- return b `
2020
- <base-field
2021
- ?required=${this.required}
2022
- ?disabled=${this.disabled}
2023
- ?readonly=${this.readonly}
2024
- ?skeleton=${this.skeleton}
2025
- helper-text=${this.helperText}
2026
- ?error=${this.error}
2027
- error-text=${this.errorText}
2028
- ?warning=${this.warning}
2029
- variant=${this.variant}
2030
- ?populated=${!!this.value}
2031
- warning-text=${this.warningText}
2032
- label=${this.label}
2033
- ?focused=${this.focused}
2034
- .host=${this}
2035
- class="input-wrapper"
2036
- >
2037
- <slot name="start" slot="field-start"></slot>
2038
-
2039
- <input
2040
- class="input input-element"
2041
- name=${this.name}
2042
- type="time"
2043
- placeholder=${this.placeholder}
2044
- autocomplete=${this.autocomplete}
2045
- .value=${this.value}
2046
- ?tabindex=${this.tabindex}
2047
- ?readonly=${this.readonly}
2048
- ?required=${this.required}
2049
- ?disabled=${this.disabled}
2050
- @input=${this.__handleInput}
2051
- @change=${this.__redispatchEvent}
2052
- @focus=${this.__handleFocusChange}
2053
- @blur=${this.__handleFocusChange}
2054
- ${spread(this.configAria)}
2055
- />
2056
-
2057
- <slot name="end" slot="field-end"></slot>
2058
-
2059
- <icon-button
2060
- slot="field-end"
2061
- color="secondary"
2062
- variant="text"
2063
- name="calendar_today"
2064
- ?disabled=${this.disabled}
2065
- @click=${() => {
2066
- setTimeout(() => {
2067
- // @ts-ignore
2068
- this.inputElement.showPicker();
2069
- });
2070
- }}
2071
- >
2072
- </icon-button>
2073
- </base-field>
2074
- `;
2075
- }
2076
- }
2077
- TimePicker.styles = [css_248z$2];
2078
- __decorate([
2079
- n({ type: String })
2080
- ], TimePicker.prototype, "value", void 0);
2081
- __decorate([
2082
- n({ type: String })
2083
- ], TimePicker.prototype, "name", void 0);
2084
- __decorate([
2085
- n({ type: String })
2086
- ], TimePicker.prototype, "placeholder", void 0);
2087
- __decorate([
2088
- n({ type: String })
2089
- ], TimePicker.prototype, "label", void 0);
2090
- __decorate([
2091
- n({ type: Boolean, reflect: true })
2092
- ], TimePicker.prototype, "inline", void 0);
2093
- __decorate([
2094
- n({ type: String, reflect: true })
2095
- ], TimePicker.prototype, "size", void 0);
2096
- __decorate([
2097
- n({ type: String })
2098
- ], TimePicker.prototype, "autocomplete", void 0);
2099
- __decorate([
2100
- n({ type: Object })
2101
- ], TimePicker.prototype, "configAria", void 0);
2102
- __decorate([
2103
- n({ type: String })
2104
- ], TimePicker.prototype, "variant", void 0);
2105
- __decorate([
2106
- n({ type: String, attribute: 'helper-text' })
2107
- ], TimePicker.prototype, "helperText", void 0);
2108
- __decorate([
2109
- n({ type: Boolean })
2110
- ], TimePicker.prototype, "error", void 0);
2111
- __decorate([
2112
- n({ type: String, attribute: 'error-text' })
2113
- ], TimePicker.prototype, "errorText", void 0);
2114
- __decorate([
2115
- n({ type: Boolean })
2116
- ], TimePicker.prototype, "warning", void 0);
2117
- __decorate([
2118
- n({ type: String, attribute: 'warning-text' })
2119
- ], TimePicker.prototype, "warningText", void 0);
2120
- __decorate([
2121
- r()
2122
- ], TimePicker.prototype, "focused", void 0);
2123
- __decorate([
2124
- r()
2125
- ], TimePicker.prototype, "passwordVisible", void 0);
2126
- __decorate([
2127
- r()
2128
- ], TimePicker.prototype, "dirty", void 0);
2129
- __decorate([
2130
- e$1('.input-element')
2131
- ], TimePicker.prototype, "inputElement", void 0);
2132
-
2133
- var css_248z$1 = i`* {
2134
- box-sizing: border-box;
2135
- }
2136
-
2137
- .screen-reader-only {
2138
- display: none !important;
2139
- }
2140
-
2141
- :host {
2142
- display: block;
2143
- width: 100%;
2144
- }
2145
-
2146
- .input-element {
2147
- border: none;
2148
- outline: none;
2149
- margin: 0;
2150
- padding: 0;
2151
- }
2152
-
2153
- .input-wrapper .input {
2154
- flex: 1;
2155
- width: 100%;
2156
- background: none;
2157
- cursor: inherit;
2158
- }
2159
-
2160
- .textarea {
2161
- height: 100%;
2162
- position: relative;
2163
- align-items: flex-start;
2164
- --field-height: auto;
2165
- --field-padding-block: var(--spacing-100);
2166
- }
2167
- .textarea .input {
2168
- height: 100%;
2169
- resize: vertical;
2170
- }`;
2171
-
2172
- /**
2173
- * @label Textarea
2174
- * @tag textarea-field
2175
- * @rawTag textarea
2176
- *
2177
- * @summary The Textarea component is used to capture user input.
2178
- *
2179
- * @example
2180
- * ```html
2181
- * <textarea-field label="Name" required placeholder="Enter your name"></textarea-field>
2182
- * ```
2183
- */
2184
- class Textarea extends BaseInput {
2185
- constructor() {
2186
- super(...arguments);
2187
- this.value = '';
2188
- this.name = '';
2189
- this.placeholder = '';
2190
- this.label = '';
2191
- this.inline = false;
2192
- this.size = 'md';
2193
- this.autocomplete = 'off';
2194
- this.configAria = {};
2195
- this.variant = 'default';
2196
- /**
2197
- * Helper text to display below the input.
2198
- */
2199
- this.helperText = '';
2200
- this.error = false;
2201
- this.errorText = '';
2202
- this.warning = false;
2203
- this.warningText = '';
2204
- this.rows = '3';
2205
- this.focused = false;
2206
- this.passwordVisible = false;
2207
- /**
2208
- * Returns true when the text field has been interacted with. Native
2209
- * validation errors only display in response to user interactions.
2210
- */
2211
- this.dirty = false;
2212
- }
2213
- connectedCallback() {
2214
- super.connectedCallback();
2215
- this.handleInitialAttributes();
2216
- }
2217
- handleInitialAttributes() {
2218
- if (this.hasAttribute('tabindex')) {
2219
- this.tabindex = this.getAttribute('tabindex') || undefined;
2220
- this.removeAttribute('tabindex');
2221
- }
2222
- Array.from(this.attributes).forEach(attr => {
2223
- if (attr.name.startsWith('aria-')) {
2224
- this.configAria[attr.name] = attr.value;
2225
- this.removeAttribute(attr.name);
2226
- }
2227
- });
2228
- }
2229
- __handleInput(event) {
2230
- this.dirty = true;
2231
- this.value = event.target.value;
2232
- }
2233
- focus() {
2234
- this.inputElement?.focus();
2235
- }
2236
- blur() {
2237
- this.inputElement?.blur();
2238
- }
2239
- __handleFocusChange() {
2240
- // When calling focus() or reportValidity() during change, it's possible
2241
- // for blur to be called after the new focus event. Rather than set
2242
- // `this.focused` to true/false on focus/blur, we always set it to whether
2243
- // or not the input itself is focused.
2244
- this.focused = this.inputElement?.matches(':focus') ?? false;
2245
- }
2246
- __redispatchEvent(event) {
2247
- redispatchEvent(this, event);
2248
- }
2249
- render() {
2250
- return b `
2251
- <base-field
2252
- ?required=${this.required}
2253
- ?disabled=${this.disabled}
2254
- ?readonly=${this.readonly}
2255
- ?skeleton=${this.skeleton}
2256
- helper-text=${this.helperText}
2257
- ?error=${this.error}
2258
- error-text=${this.errorText}
2259
- ?warning=${this.warning}
2260
- variant=${this.variant}
2261
- ?populated=${!!this.value}
2262
- warning-text=${this.warningText}
2263
- label=${this.label}
2264
- ?focused=${this.focused}
2265
- .host=${this}
2266
- class="input-wrapper textarea"
2267
- >
2268
- <slot name="start" slot="field-start"></slot>
2269
-
2270
- <textarea
2271
- class="input input-element"
2272
- rows=${this.rows}
2273
- name=${this.name}
2274
- placeholder=${this.placeholder}
2275
- autocomplete=${this.autocomplete}
2276
- .value=${this.value}
2277
- ?tabindex=${this.tabindex}
2278
- ?readonly=${this.readonly}
2279
- ?required=${this.required}
2280
- ?disabled=${this.disabled}
2281
- @input=${this.__handleInput}
2282
- @change=${this.__redispatchEvent}
2283
- @focus=${this.__handleFocusChange}
2284
- @blur=${this.__handleFocusChange}
2285
- ${spread(this.configAria)}
2286
- ></textarea>
2287
-
2288
- <slot name="end" slot="field-end"></slot>
2289
- </base-field>
2290
- `;
2291
- }
2292
- }
2293
- Textarea.styles = [css_248z$1];
2294
- __decorate([
2295
- n({ type: String })
2296
- ], Textarea.prototype, "value", void 0);
2297
- __decorate([
2298
- n({ type: String })
2299
- ], Textarea.prototype, "name", void 0);
2300
- __decorate([
2301
- n({ type: String })
2302
- ], Textarea.prototype, "placeholder", void 0);
2303
- __decorate([
2304
- n({ type: String })
2305
- ], Textarea.prototype, "label", void 0);
2306
- __decorate([
2307
- n({ type: Boolean, reflect: true })
2308
- ], Textarea.prototype, "inline", void 0);
2309
- __decorate([
2310
- n({ type: String, reflect: true })
2311
- ], Textarea.prototype, "size", void 0);
2312
- __decorate([
2313
- n({ type: String })
2314
- ], Textarea.prototype, "autocomplete", void 0);
2315
- __decorate([
2316
- n({ type: Object })
2317
- ], Textarea.prototype, "configAria", void 0);
2318
- __decorate([
2319
- n({ type: String })
2320
- ], Textarea.prototype, "variant", void 0);
2321
- __decorate([
2322
- n({ type: String, attribute: 'helper-text' })
2323
- ], Textarea.prototype, "helperText", void 0);
2324
- __decorate([
2325
- n({ type: Boolean })
2326
- ], Textarea.prototype, "error", void 0);
2327
- __decorate([
2328
- n({ type: String, attribute: 'error-text' })
2329
- ], Textarea.prototype, "errorText", void 0);
2330
- __decorate([
2331
- n({ type: Boolean })
2332
- ], Textarea.prototype, "warning", void 0);
2333
- __decorate([
2334
- n({ type: String, attribute: 'warning-text' })
2335
- ], Textarea.prototype, "warningText", void 0);
2336
- __decorate([
2337
- n({ type: String })
2338
- ], Textarea.prototype, "rows", void 0);
2339
- __decorate([
2340
- r()
2341
- ], Textarea.prototype, "focused", void 0);
2342
- __decorate([
2343
- r()
2344
- ], Textarea.prototype, "passwordVisible", void 0);
2345
- __decorate([
2346
- r()
2347
- ], Textarea.prototype, "dirty", void 0);
2348
- __decorate([
2349
- e$1('.input-element')
2350
- ], Textarea.prototype, "inputElement", void 0);
2351
-
2352
- var css_248z = i`* {
2353
- box-sizing: border-box;
2354
- }
2355
-
2356
- .screen-reader-only {
2357
- display: none !important;
2358
- }
2359
-
2360
- :host {
2361
- display: inline-block;
2362
- --switch-track-color: var(--color-primary);
2363
- --switch-track-off-color: var(--color-surface-container-highest);
2364
- }
2365
-
2366
- .switch {
2367
- position: relative;
2368
- display: flex;
2369
- align-items: center;
2370
- }
2371
- .switch .input-native {
2372
- position: absolute;
2373
- width: 1px;
2374
- height: 1px;
2375
- padding: 0;
2376
- margin: -1px;
2377
- overflow: hidden;
2378
- clip: rect(0, 0, 0, 0);
2379
- border: 0;
2380
- }
2381
- .switch .label {
2382
- font-family: var(--typography-label-medium-font-family) !important;
2383
- font-size: var(--typography-label-medium-font-size) !important;
2384
- font-weight: var(--typography-label-medium-font-weight) !important;
2385
- line-height: var(--typography-label-medium-line-height) !important;
2386
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
2387
- }
2388
- .switch.has-content {
2389
- gap: var(--spacing-150);
2390
- }
2391
- .switch .track {
2392
- position: relative;
2393
- background: var(--switch-track-off-color);
2394
- border: 2px solid var(--color-outline);
2395
- border-radius: var(--shape-corner-full);
2396
- cursor: pointer;
2397
- display: flex;
2398
- transition: background-color var(--duration-short2) var(--easing-standard);
2399
- align-items: center;
2400
- width: var(--_container-width);
2401
- height: var(--_container-height);
2402
- padding: 0 4px;
2403
- }
2404
- .switch .track .handle {
2405
- display: flex;
2406
- align-items: center;
2407
- justify-content: center;
2408
- border-radius: var(--shape-corner-full);
2409
- transition: all var(--duration-short2) var(--easing-standard);
2410
- background: white;
2411
- height: var(--switch-handle-radius);
2412
- width: var(--switch-handle-radius);
2413
- background: var(--switch-handle-color);
2414
- }
2415
- .switch .track .handle .icon {
2416
- --icon-size: .75rem;
2417
- --icon-color: var(--switch-track-off-color);
2418
- }
2419
- .switch.has-focus:not(.active) .track {
2420
- outline: 3px solid var(--color-primary);
2421
- outline-offset: 2px;
2422
- border-color: var(--color-white);
2423
- }
2424
- .switch.has-focus:not(.active):not(.state-checked) .handle {
2425
- border-color: var(--icon-01);
2426
- }
2427
-
2428
- .switch.state-checked .track {
2429
- background: var(--switch-track-color);
2430
- border-color: transparent;
2431
- }
2432
- .switch.state-checked .handle {
2433
- margin-inline-start: calc(100% - var(--switch-handle-radius));
2434
- }
2435
- .switch.state-checked .handle .icon {
2436
- --icon-size: 1rem;
2437
- --icon-color: var(--switch-track-color);
2438
- }
2439
- .switch.state-checked.active .track {
2440
- border-color: var(--switch-track-color);
2441
- }
2442
- .switch.state-checked.has-focus:not(.active) .track {
2443
- outline: 3px solid var(--color-primary);
2444
- outline-offset: 2px;
2445
- border-color: var(--color-white);
2446
- }
2447
-
2448
- .switch {
2449
- --_container-width: 3.25rem;
2450
- --_container-height: 2rem;
2451
- --switch-handle-radius: 16px;
2452
- --switch-handle-color: var(--color-outline);
2453
- }
2454
- .switch.state-checked {
2455
- --switch-handle-radius: 22px;
2456
- --switch-handle-color: var(--color-surface-container-lowest);
2457
- }
2458
-
2459
- .switch.readonly {
2460
- cursor: default;
2461
- }
2462
- .switch.readonly .track {
2463
- border-color: var(--color-outline);
2464
- background: var(--switch-track-off-color);
2465
- opacity: 0.38;
2466
- }
2467
- .switch.readonly .track .handle {
2468
- background: var(--color-outline) !important;
2469
- }
2470
-
2471
- .switch.disabled {
2472
- cursor: not-allowed;
2473
- }
2474
- .switch.disabled .track {
2475
- border-color: var(--color-on-surface);
2476
- background: var(--switch-track-off-color);
2477
- opacity: 0.38;
2478
- }
2479
- .switch.disabled .track .handle {
2480
- background: var(--color-on-surface) !important;
2481
- }`;
2482
-
2483
- /**
2484
- * @label Switch
2485
- * @tag base-switch
2486
- * @rawTag switch
2487
- *
2488
- * @summary Captures boolean input with an on/off switch interaction.
2489
- * @overview
2490
- * <p>Toggles are used to enable or disable a single option. They provide immediate feedback about whether an option is active or inactive.</p>
2491
- *
2492
- * @cssprop --switch-track-color: Color of the switch track when checked.
2493
- * @cssprop --switch-track-off-color: Color of the switch track when unchecked.
2494
- * @cssprop --switch-width: Width of the switch track.
2495
- * @cssprop --switch-height: Height of the switch track.
2496
- * @cssprop --switch-handle-radius: Size of the switch handle.
2497
- * @cssprop --switch-handle-color: Color of the switch handle.
2498
- *
2499
- * @fires {CustomEvent} change - Dispatched when the switch value changes.
2500
- * @fires {CustomEvent} blur - Dispatched when the switch loses focus.
2501
- * @fires {CustomEvent} focus - Dispatched when the switch receives focus.
2502
- *
2503
- * @example
2504
- * ```html
2505
- * <base-switch value="true"></base-switch>
2506
- * ```
2507
- * @tags input, form
2508
- */
2509
- class Switch extends BaseInput {
2510
- constructor() {
2511
- super(...arguments);
2512
- this.value = false;
2513
- /**
2514
- * The input field name.
2515
- */
2516
- this.name = '';
2517
- /**
2518
- * The switch label.
2519
- */
2520
- this.label = '';
2521
- /**
2522
- * If true, the toggle has rounded corners. Defaults to `true`.
2523
- */
2524
- this.rounded = true;
2525
- /**
2526
- * If true, required icon is shown. Defaults to `false`.
2527
- */
2528
- this.required = false;
2529
- /**
2530
- * If true, the toggle is readonly. Defaults to `false`.
2531
- */
2532
- this.readonly = false;
2533
- /**
2534
- * If true, the user cannot interact with the toggle. Defaults to `false`.
2535
- */
2536
- this.disabled = false;
2537
- this.withIcon = false;
2538
- /**
2539
- * Configuration object for aria attributes.
2540
- */
2541
- this.configAria = {};
2542
- this.hasFocus = false;
2543
- this.isActive = false;
2544
- this.slotHasContent = false;
2545
- this.windowMouseUp = () => {
2546
- if (this.isActive) {
2547
- this.isActive = false;
2548
- }
2549
- };
2550
- this.windowKeyUp = (evt) => {
2551
- if (this.isActive && evt.key === ' ') {
2552
- this.isActive = false;
2553
- }
2554
- };
2555
- this.mouseDownHandler = () => {
2556
- this.isActive = true;
2557
- };
2558
- this.keyDownHandler = (evt) => {
2559
- if (evt.key === ' ') {
2560
- evt.preventDefault();
2561
- this.isActive = true;
2562
- this.clickHandler(evt);
2563
- }
2564
- };
2565
- this.clickHandler = (ev) => {
2566
- if (!this.disabled && !this.readonly) {
2567
- this.value = !this.value;
2568
- this.dispatchEvent(new CustomEvent('change', {
2569
- detail: { value: this.value, originalEvent: ev },
2570
- bubbles: true,
2571
- composed: true,
2572
- }));
2573
- this.trackElement?.focus();
2574
- }
2575
- };
2576
- this.blurHandler = (ev) => {
2577
- this.hasFocus = false;
2578
- this.dispatchEvent(new CustomEvent('blur', {
2579
- detail: ev,
2580
- bubbles: true,
2581
- composed: true,
2582
- }));
2583
- };
2584
- this.focusHandler = (ev) => {
2585
- this.hasFocus = true;
2586
- this.dispatchEvent(new CustomEvent('focus', {
2587
- detail: ev,
2588
- bubbles: true,
2589
- composed: true,
2590
- }));
2591
- };
2592
- this.handleKeyUp = (evt) => {
2593
- if (evt.key === 'Enter') {
2594
- this.clickHandler(evt);
2595
- }
2596
- };
2597
- }
2598
- connectedCallback() {
2599
- super.connectedCallback();
2600
- this.handleInitialAttributes();
2601
- window.addEventListener('mouseup', this.windowMouseUp);
2602
- window.addEventListener('keyup', this.windowKeyUp);
2603
- }
2604
- disconnectedCallback() {
2605
- super.disconnectedCallback();
2606
- window.removeEventListener('mouseup', this.windowMouseUp);
2607
- window.removeEventListener('keyup', this.windowKeyUp);
2608
- }
2609
- firstUpdated() {
2610
- this.slotHasContent = this.hasChildNodes();
2611
- }
2612
- handleInitialAttributes() {
2613
- if (this.hasAttribute('tabindex')) {
2614
- this.tabindex = this.getAttribute('tabindex') || undefined;
2615
- this.removeAttribute('tabindex');
2616
- }
2617
- Array.from(this.attributes).forEach(attr => {
2618
- if (attr.name.startsWith('aria-')) {
2619
- this.configAria[attr.name] = attr.value;
2620
- this.removeAttribute(attr.name);
2621
- }
2622
- });
2623
- }
2624
- /**
2625
- * Sets focus on the toggle.
2626
- */
2627
- focus() {
2628
- this.trackElement?.focus();
2629
- }
2630
- /**
2631
- * Removes focus from the toggle.
2632
- */
2633
- blur() {
2634
- this.trackElement?.blur();
2635
- }
2636
- __renderIcon() {
2637
- if (this.withIcon) {
2638
- if (this.value)
2639
- return b `<base-icon name="check" class="icon"></base-icon>`;
2640
- return b `<base-icon name="close" class="icon"></base-icon>`;
2641
- }
2642
- return A;
2643
- }
2644
- render() {
2645
- const cssClasses = {
2646
- switch: true,
2647
- 'state-checked': this.value,
2648
- 'has-focus': this.hasFocus,
2649
- active: this.isActive,
2650
- disabled: this.disabled,
2651
- readonly: this.readonly,
2652
- required: this.required,
2653
- rounded: this.rounded,
2654
- 'has-content': this.slotHasContent,
2655
- };
2656
- return b `
2657
- <label class=${e(cssClasses)}>
2658
- <div
2659
- class="track"
2660
- tabindex=${this.tabindex || 0}
2661
- @keyup=${this.handleKeyUp}
2662
- @mousedown=${this.mouseDownHandler}
2663
- @keydown=${this.keyDownHandler}
2664
- @blur=${this.blurHandler}
2665
- @focus=${this.focusHandler}
2666
- role="checkbox"
2667
- aria-disabled=${this.disabled}
2668
- aria-required=${this.required}
2669
- aria-checked=${this.value}
2670
- ${spread(this.configAria)}
2671
- >
2672
- <div class="handle">${this.__renderIcon()}</div>
2673
- </div>
2674
-
2675
- <input
2676
- type="checkbox"
2677
- class="input-native"
2678
- name=${this.name}
2679
- .checked=${this.value}
2680
- aria-hidden="true"
2681
- ?required=${this.required}
2682
- tabindex="-1"
2683
- @click=${this.clickHandler}
2684
- />
2685
-
2686
- ${this.label
2687
- ? b `<div class="label">${this.label}</div>`
2688
- : b `<div class="slot-container"><slot></slot></div>`}
2689
- </label>
2690
- `;
2691
- }
2692
- }
2693
- Switch.styles = [css_248z];
2694
- __decorate([
2695
- n({ type: Boolean })
2696
- ], Switch.prototype, "value", void 0);
2697
- __decorate([
2698
- n({ type: String })
2699
- ], Switch.prototype, "name", void 0);
2700
- __decorate([
2701
- n({ type: String })
2702
- ], Switch.prototype, "label", void 0);
2703
- __decorate([
2704
- n({ type: Boolean })
2705
- ], Switch.prototype, "rounded", void 0);
2706
- __decorate([
2707
- n({ type: Boolean, reflect: true })
2708
- ], Switch.prototype, "required", void 0);
2709
- __decorate([
2710
- n({ type: Boolean, reflect: true })
2711
- ], Switch.prototype, "readonly", void 0);
2712
- __decorate([
2713
- n({ type: Boolean, reflect: true })
2714
- ], Switch.prototype, "disabled", void 0);
2715
- __decorate([
2716
- n({ type: Boolean, reflect: true, attribute: 'with-icon' })
2717
- ], Switch.prototype, "withIcon", void 0);
2718
- __decorate([
2719
- n({ type: Object })
2720
- ], Switch.prototype, "configAria", void 0);
2721
- __decorate([
2722
- r()
2723
- ], Switch.prototype, "hasFocus", void 0);
2724
- __decorate([
2725
- r()
2726
- ], Switch.prototype, "isActive", void 0);
2727
- __decorate([
2728
- r()
2729
- ], Switch.prototype, "slotHasContent", void 0);
2730
- __decorate([
2731
- e$1('.track')
2732
- ], Switch.prototype, "trackElement", void 0);
2733
- __decorate([
2734
- e$1('.input-native')
2735
- ], Switch.prototype, "nativeElement", void 0);
2736
-
2737
- export { Button as B, CircularProgress as C, DatePicker as D, IconButton as I, LinearProgress as L, NumberField as N, Switch as S, Textarea as T, Input as a, TimePicker as b };
2738
- //# sourceMappingURL=switch-DqxIiVsB.js.map