@redvars/peacock 3.10.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/dist/BaseInput-CV0pZgSb.js +58 -0
  2. package/dist/BaseInput-CV0pZgSb.js.map +1 -0
  3. package/dist/app-bar.js +16 -16
  4. package/dist/assets/styles.css +1 -1
  5. package/dist/assets/styles.css.map +1 -1
  6. package/dist/assets/theme.d.ts +66 -0
  7. package/dist/assets/theme.js +134 -0
  8. package/dist/assets/tokens.css +1 -1
  9. package/dist/assets/tokens.css.map +1 -1
  10. package/dist/base-progress-CLZTRveO.js +33 -0
  11. package/dist/base-progress-CLZTRveO.js.map +1 -0
  12. package/dist/bottom-sheet.js +1 -1
  13. package/dist/button-group.js +9 -7
  14. package/dist/button-group.js.map +1 -1
  15. package/dist/button.js +225 -187
  16. package/dist/button.js.map +1 -1
  17. package/dist/cb-divider.js +7 -6
  18. package/dist/cb-divider.js.map +1 -1
  19. package/dist/cb-group-base-D9gv7SDY.js +114 -0
  20. package/dist/cb-group-base-D9gv7SDY.js.map +1 -0
  21. package/dist/cb-group-base-DsX_2aFl.js +325 -0
  22. package/dist/cb-group-base-DsX_2aFl.js.map +1 -0
  23. package/dist/cb-group.js +96 -0
  24. package/dist/cb-group.js.map +1 -0
  25. package/dist/cb-rule.js +212 -0
  26. package/dist/cb-rule.js.map +1 -0
  27. package/dist/{chart-bar-CapLbc2e.js → chart-bar-D5dGFJfK.js} +2 -2
  28. package/dist/{chart-bar-CapLbc2e.js.map → chart-bar-D5dGFJfK.js.map} +1 -1
  29. package/dist/chart-bar.js +1 -1
  30. package/dist/chart-stacked-bar.js +1 -1
  31. package/dist/checkbox.js +78 -53
  32. package/dist/checkbox.js.map +1 -1
  33. package/dist/chip-set.js +52 -0
  34. package/dist/chip-set.js.map +1 -0
  35. package/dist/chip.js +8 -6
  36. package/dist/chip.js.map +1 -1
  37. package/dist/circular-progress.js +177 -0
  38. package/dist/circular-progress.js.map +1 -0
  39. package/dist/code-editor.js +129 -72
  40. package/dist/code-editor.js.map +1 -1
  41. package/dist/code-highlighter.js +2 -38
  42. package/dist/code-highlighter.js.map +1 -1
  43. package/dist/color-field.js +309 -0
  44. package/dist/color-field.js.map +1 -0
  45. package/dist/color-picker.js +26 -15
  46. package/dist/color-picker.js.map +1 -1
  47. package/dist/condition-builder.js +90 -35
  48. package/dist/condition-builder.js.map +1 -1
  49. package/dist/copy-to-clipboard-upGx-Ueo.js +39 -0
  50. package/dist/copy-to-clipboard-upGx-Ueo.js.map +1 -0
  51. package/dist/custom-elements-jsdocs.json +1140 -398
  52. package/dist/custom-elements.json +9065 -3989
  53. package/dist/date-picker.js +241 -0
  54. package/dist/date-picker.js.map +1 -0
  55. package/dist/{element-internals-2CMts_0M.js → delegate-py-Ets8N.js} +2 -43
  56. package/dist/delegate-py-Ets8N.js.map +1 -0
  57. package/dist/element-internals-QME0yEz4.js +43 -0
  58. package/dist/element-internals-QME0yEz4.js.map +1 -0
  59. package/dist/fab.js +51 -49
  60. package/dist/fab.js.map +1 -1
  61. package/dist/field.js +27 -0
  62. package/dist/field.js.map +1 -1
  63. package/dist/flow.js +5 -5
  64. package/dist/form-associated-Bhwwr6dT.js +162 -0
  65. package/dist/form-associated-Bhwwr6dT.js.map +1 -0
  66. package/dist/{form-associated-BXADnjOB.js → form-submitter-DPI4L6gj.js} +3 -159
  67. package/dist/form-submitter-DPI4L6gj.js.map +1 -0
  68. package/dist/html-editor.js +3 -1
  69. package/dist/html-editor.js.map +1 -1
  70. package/dist/icon-button.js +195 -156
  71. package/dist/icon-button.js.map +1 -1
  72. package/dist/image.js +2 -2
  73. package/dist/index.js +36 -11
  74. package/dist/index.js.map +1 -1
  75. package/dist/input.js +259 -0
  76. package/dist/input.js.map +1 -0
  77. package/dist/item.js +2 -1
  78. package/dist/item.js.map +1 -1
  79. package/dist/linear-progress.js +192 -0
  80. package/dist/linear-progress.js.map +1 -0
  81. package/dist/{list-AdO-PUq_.js → list-item.js} +12 -222
  82. package/dist/list-item.js.map +1 -0
  83. package/dist/list.js +225 -6
  84. package/dist/list.js.map +1 -1
  85. package/dist/loader-full.js +31 -8
  86. package/dist/loader-full.js.map +1 -1
  87. package/dist/loader.js +58 -25
  88. package/dist/loader.js.map +1 -1
  89. package/dist/markdown-editor.js +5 -3
  90. package/dist/markdown-editor.js.map +1 -1
  91. package/dist/menu-item.js +30 -30
  92. package/dist/navigation-bar-item.js +41 -0
  93. package/dist/navigation-bar-item.js.map +1 -0
  94. package/dist/navigation-bar.js +128 -0
  95. package/dist/navigation-bar.js.map +1 -0
  96. package/dist/navigation-drawer-item.js +236 -0
  97. package/dist/navigation-drawer-item.js.map +1 -0
  98. package/dist/navigation-drawer.js +293 -0
  99. package/dist/navigation-drawer.js.map +1 -0
  100. package/dist/navigation-rail.js +1 -1
  101. package/dist/number-field.js +280 -0
  102. package/dist/number-field.js.map +1 -0
  103. package/dist/pagination.js +1 -1
  104. package/dist/radio-group.js +209 -0
  105. package/dist/radio-group.js.map +1 -0
  106. package/dist/radio.js +47 -37
  107. package/dist/radio.js.map +1 -1
  108. package/dist/segmented-button-group.js +12 -0
  109. package/dist/segmented-button-group.js.map +1 -1
  110. package/dist/segmented-button.js +10 -6
  111. package/dist/segmented-button.js.map +1 -1
  112. package/dist/select.js +653 -0
  113. package/dist/select.js.map +1 -0
  114. package/dist/side-sheet.js +1 -1
  115. package/dist/sidebar-menu-item.js +273 -0
  116. package/dist/sidebar-menu-item.js.map +1 -0
  117. package/dist/sidebar-menu.js +193 -0
  118. package/dist/sidebar-menu.js.map +1 -0
  119. package/dist/sidebar-sub-menu.js +301 -0
  120. package/dist/sidebar-sub-menu.js.map +1 -0
  121. package/dist/slider.js +76 -24
  122. package/dist/slider.js.map +1 -1
  123. package/dist/snackbar.js +3 -3
  124. package/dist/snackbar.js.map +1 -1
  125. package/dist/split-button.js +2 -2
  126. package/dist/src/__internal/utils/size.d.ts +9 -0
  127. package/dist/src/button/ButtonTypes.d.ts +1 -1
  128. package/dist/src/checkbox/checkbox.d.ts +28 -22
  129. package/dist/src/chip/chip/chip.d.ts +3 -0
  130. package/dist/src/chip/tag/tag.d.ts +5 -1
  131. package/dist/src/code-editor/code-editor.d.ts +37 -10
  132. package/dist/src/color-field/color-field.d.ts +55 -0
  133. package/dist/src/color-field/index.d.ts +1 -0
  134. package/dist/src/color-picker/color-picker.d.ts +1 -1
  135. package/dist/src/condition-builder/cb-divider.d.ts +3 -1
  136. package/dist/src/condition-builder/cb-drag.d.ts +10 -0
  137. package/dist/src/condition-builder/cb-group-base.d.ts +59 -0
  138. package/dist/src/condition-builder/cb-group.d.ts +34 -0
  139. package/dist/src/condition-builder/cb-rule.d.ts +32 -0
  140. package/dist/src/condition-builder/cb-types.d.ts +13 -0
  141. package/dist/src/condition-builder/condition-builder.d.ts +35 -14
  142. package/dist/src/condition-builder/index.d.ts +3 -3
  143. package/dist/src/date-picker/date-picker.d.ts +0 -1
  144. package/dist/src/index.d.ts +6 -4
  145. package/dist/src/input/BaseInput.d.ts +21 -3
  146. package/dist/src/input/input.d.ts +15 -7
  147. package/dist/src/navigation-bar/index.d.ts +2 -0
  148. package/dist/src/navigation-bar/navigation-bar-item.d.ts +23 -0
  149. package/dist/src/navigation-bar/navigation-bar.d.ts +44 -0
  150. package/dist/src/navigation-drawer/index.d.ts +2 -0
  151. package/dist/src/navigation-drawer/navigation-drawer-item.d.ts +48 -0
  152. package/dist/src/navigation-drawer/navigation-drawer.d.ts +70 -0
  153. package/dist/src/number-field/number-field.d.ts +0 -1
  154. package/dist/src/radio/index.d.ts +1 -0
  155. package/dist/src/radio/radio-group.d.ts +50 -0
  156. package/dist/src/radio/radio.d.ts +18 -18
  157. package/dist/src/segmented-button/segmented-button-group.d.ts +5 -0
  158. package/dist/src/segmented-button/segmented-button.d.ts +2 -1
  159. package/dist/src/select/select.d.ts +6 -0
  160. package/dist/src/slider/slider.d.ts +14 -5
  161. package/dist/src/switch/switch.d.ts +22 -26
  162. package/dist/src/tabs/tabs.d.ts +3 -0
  163. package/dist/src/textarea/textarea.d.ts +0 -1
  164. package/dist/src/time-picker/time-picker.d.ts +0 -1
  165. package/dist/src/toolbar/toolbar.d.ts +7 -4
  166. package/dist/src/url-field/url-field.d.ts +0 -1
  167. package/dist/svg.js +5 -5
  168. package/dist/switch.js +413 -0
  169. package/dist/switch.js.map +1 -0
  170. package/dist/tab.js +2 -1
  171. package/dist/tab.js.map +1 -1
  172. package/dist/tabs.js +10 -8
  173. package/dist/tabs.js.map +1 -1
  174. package/dist/tag.js +349 -0
  175. package/dist/tag.js.map +1 -0
  176. package/dist/test/code-editor.test.d.ts +1 -0
  177. package/dist/test/color-field.test.d.ts +1 -0
  178. package/dist/test/color-picker.test.d.ts +1 -0
  179. package/dist/test/condition-builder.test.d.ts +1 -0
  180. package/dist/test/field.test.d.ts +1 -0
  181. package/dist/test/form-controls.test.d.ts +1 -0
  182. package/dist/test/icon.test.d.ts +1 -1
  183. package/dist/test/input.test.d.ts +1 -0
  184. package/dist/test/navigation.test.d.ts +1 -0
  185. package/dist/test/segmented-button.test.d.ts +1 -0
  186. package/dist/test/slider.test.d.ts +1 -0
  187. package/dist/textarea.js +237 -0
  188. package/dist/textarea.js.map +1 -0
  189. package/dist/time-picker.js +241 -0
  190. package/dist/time-picker.js.map +1 -0
  191. package/dist/toolbar.js +26 -9
  192. package/dist/toolbar.js.map +1 -1
  193. package/dist/tsconfig.tsbuildinfo +1 -1
  194. package/dist/url-field.js +298 -0
  195. package/dist/url-field.js.map +1 -0
  196. package/package.json +29 -8
  197. package/readme.md +2 -2
  198. package/scss/tokens.css +175 -18
  199. package/src/__internal/utils/size.ts +23 -0
  200. package/src/app-bar/app-bar.scss +4 -16
  201. package/src/bottom-sheet/bottom-sheet.scss +1 -1
  202. package/src/button/ButtonTypes.ts +2 -0
  203. package/src/button/button/button-base.scss +84 -84
  204. package/src/button/button/button-colors.scss +14 -2
  205. package/src/button/button/button-layers.scss +71 -71
  206. package/src/button/button/button-shapes.scss +2 -2
  207. package/src/button/button/button-sizes.scss +35 -35
  208. package/src/button/button/button.scss +1 -1
  209. package/src/button/button/button.ts +1 -2
  210. package/src/button/button-group/button-group.scss +5 -5
  211. package/src/button/fab/fab-sizes.scss +15 -15
  212. package/src/button/fab/fab.scss +32 -32
  213. package/src/button/icon-button/icon-button-sizes.scss +7 -7
  214. package/src/chart-bar/chart-bar.scss +1 -1
  215. package/src/checkbox/checkbox.scss +7 -6
  216. package/src/checkbox/checkbox.ts +92 -40
  217. package/src/chip/chip/chip.ts +8 -5
  218. package/src/chip/chip-set/chip-set.ts +2 -0
  219. package/src/chip/tag/tag-colors.scss +1 -1
  220. package/src/chip/tag/tag-sizes.scss +9 -0
  221. package/src/chip/tag/tag.scss +1 -1
  222. package/src/chip/tag/tag.ts +20 -9
  223. package/src/code-editor/code-editor.scss +8 -3
  224. package/src/code-editor/code-editor.ts +148 -79
  225. package/src/code-highlighter/code-highlighter.scss +1 -1
  226. package/src/color-field/color-field.scss +48 -0
  227. package/src/color-field/color-field.ts +239 -0
  228. package/src/color-field/index.ts +1 -0
  229. package/src/color-picker/color-picker.scss +33 -15
  230. package/src/color-picker/color-picker.ts +2 -1
  231. package/src/condition-builder/cb-divider.scss +4 -5
  232. package/src/condition-builder/cb-divider.ts +3 -1
  233. package/src/condition-builder/cb-drag.ts +35 -0
  234. package/src/condition-builder/cb-group-base.scss +97 -0
  235. package/src/condition-builder/cb-group-base.ts +335 -0
  236. package/src/condition-builder/cb-group.scss +21 -0
  237. package/src/condition-builder/cb-group.ts +72 -0
  238. package/src/condition-builder/cb-rule.scss +90 -0
  239. package/src/condition-builder/cb-rule.ts +129 -0
  240. package/src/condition-builder/cb-types.ts +16 -0
  241. package/src/condition-builder/condition-builder.scss +12 -9
  242. package/src/condition-builder/condition-builder.ts +77 -17
  243. package/src/condition-builder/index.ts +7 -3
  244. package/src/date-picker/date-picker.ts +2 -3
  245. package/src/field/field.scss +34 -0
  246. package/src/flow/flow.scss +5 -5
  247. package/src/image/image.scss +2 -2
  248. package/src/index.ts +14 -6
  249. package/src/input/BaseInput.ts +54 -4
  250. package/src/input/input.ts +104 -79
  251. package/src/list/list-item.ts +2 -0
  252. package/src/loader.ts +34 -19
  253. package/src/markdown-editor/markdown-editor.scss +2 -2
  254. package/src/menu/menu-item/menu-item.scss +30 -30
  255. package/src/navigation-bar/index.ts +2 -0
  256. package/src/navigation-bar/navigation-bar-item.ts +25 -0
  257. package/src/navigation-bar/navigation-bar.scss +27 -0
  258. package/src/navigation-bar/navigation-bar.ts +96 -0
  259. package/src/navigation-drawer/index.ts +2 -0
  260. package/src/navigation-drawer/navigation-drawer-item.scss +82 -0
  261. package/src/navigation-drawer/navigation-drawer-item.ts +133 -0
  262. package/src/navigation-drawer/navigation-drawer.scss +99 -0
  263. package/src/navigation-drawer/navigation-drawer.ts +196 -0
  264. package/src/navigation-rail/navigation-rail.scss +1 -1
  265. package/src/number-field/number-field.ts +2 -3
  266. package/src/pagination/pagination.scss +1 -1
  267. package/src/progress/circular-progress/circular-progress.ts +2 -0
  268. package/src/progress/linear-progress/linear-progress.ts +2 -0
  269. package/src/radio/index.ts +1 -0
  270. package/src/radio/radio-group.scss +39 -0
  271. package/src/radio/radio-group.ts +167 -0
  272. package/src/radio/radio.ts +74 -31
  273. package/src/segmented-button/segmented-button-group.ts +12 -0
  274. package/src/segmented-button/segmented-button.ts +12 -6
  275. package/src/select/select.ts +21 -1
  276. package/src/side-sheet/side-sheet.scss +1 -1
  277. package/src/sidebar-menu/sidebar-menu-item.scss +1 -1
  278. package/src/sidebar-menu/sidebar-menu-item.ts +2 -0
  279. package/src/sidebar-menu/sidebar-menu.ts +2 -0
  280. package/src/sidebar-menu/sidebar-sub-menu.scss +1 -1
  281. package/src/sidebar-menu/sidebar-sub-menu.ts +2 -0
  282. package/src/slider/slider.scss +3 -3
  283. package/src/slider/slider.ts +119 -31
  284. package/src/snackbar/snackbar.ts +3 -3
  285. package/src/split-button/split-button-colors.scss +2 -2
  286. package/src/svg/svg.scss +5 -5
  287. package/src/switch/switch.scss +0 -1
  288. package/src/switch/switch.ts +82 -47
  289. package/src/tabs/tab.scss +2 -1
  290. package/src/tabs/tabs.ts +14 -8
  291. package/src/textarea/textarea.ts +2 -3
  292. package/src/time-picker/time-picker.ts +2 -3
  293. package/src/toolbar/toolbar.scss +4 -4
  294. package/src/toolbar/toolbar.ts +12 -5
  295. package/src/url-field/url-field.ts +2 -3
  296. package/dist/BaseInput-CU1zZYKc.js +0 -27
  297. package/dist/BaseInput-CU1zZYKc.js.map +0 -1
  298. package/dist/brand-loader.js +0 -358
  299. package/dist/brand-loader.js.map +0 -1
  300. package/dist/cb-compound-expression.js +0 -133
  301. package/dist/cb-compound-expression.js.map +0 -1
  302. package/dist/cb-expression.js +0 -78
  303. package/dist/cb-expression.js.map +0 -1
  304. package/dist/cb-predicate.js +0 -141
  305. package/dist/cb-predicate.js.map +0 -1
  306. package/dist/element-internals-2CMts_0M.js.map +0 -1
  307. package/dist/form-associated-BXADnjOB.js.map +0 -1
  308. package/dist/list-AdO-PUq_.js.map +0 -1
  309. package/dist/select-DkyRqUTI.js +0 -3955
  310. package/dist/select-DkyRqUTI.js.map +0 -1
  311. package/dist/src/brand-loader/brand-loader.d.ts +0 -33
  312. package/dist/src/brand-loader/index.d.ts +0 -2
  313. package/dist/src/condition-builder/cb-compound-expression.d.ts +0 -30
  314. package/dist/src/condition-builder/cb-expression.d.ts +0 -30
  315. package/dist/src/condition-builder/cb-predicate.d.ts +0 -29
  316. package/src/brand-loader/brand-loader.scss +0 -270
  317. package/src/brand-loader/brand-loader.ts +0 -115
  318. package/src/brand-loader/index.ts +0 -2
  319. package/src/condition-builder/cb-compound-expression.scss +0 -41
  320. package/src/condition-builder/cb-compound-expression.ts +0 -79
  321. package/src/condition-builder/cb-expression.scss +0 -13
  322. package/src/condition-builder/cb-expression.ts +0 -48
  323. package/src/condition-builder/cb-predicate.scss +0 -35
  324. package/src/condition-builder/cb-predicate.ts +0 -101
  325. /package/dist/test/{brand-loader.test.d.ts → button.test.d.ts} +0 -0
@@ -1,3955 +0,0 @@
1
- import { i, _ as __decorate, a as i$1, b, A } from './IndividualComponent-Bdwyrvd6.js';
2
- import { n } from './property-B49QQ8pS.js';
3
- import { e } from './class-map-DG7CA1et.js';
4
- import { o } from './style-map-BQD5Et1D.js';
5
- import { r } from './state-DkTK9EGF.js';
6
- import { e as e$1 } from './query-CHb9Ft_d.js';
7
- import { r as redispatchEvent } from './dispatch-event-utils-CuEqjlPT.js';
8
- import { s as spread } from './spread-B5cgadZl.js';
9
- import { B as BaseInput } from './BaseInput-CU1zZYKc.js';
10
- import { SelectOptionElement } from './option.js';
11
-
12
- var css_248z$g = i`* {
13
- box-sizing: border-box;
14
- -webkit-tap-highlight-color: transparent;
15
- }
16
-
17
- .screen-reader-only {
18
- display: none !important;
19
- }
20
-
21
- [hidden] {
22
- display: none !important;
23
- }
24
-
25
- :host {
26
- display: inline-block;
27
- --tag-container-shape: inherit;
28
- }
29
-
30
- .tag {
31
- position: relative;
32
- display: inline-flex;
33
- flex-direction: column;
34
- align-items: center;
35
- justify-content: center;
36
- height: var(--tag-height, var(--_chip-height, 2rem));
37
- padding-inline: calc(var(--_container-padding) / 2);
38
- width: 100%;
39
- --_container-shape: var(--tag-container-shape, var(--shape-corner-medium));
40
- --_container-corner-shape-variant: squircle;
41
- }
42
- .tag .tag-content {
43
- position: relative;
44
- z-index: 1;
45
- overflow: hidden;
46
- text-overflow: ellipsis;
47
- white-space: nowrap;
48
- max-width: 100%;
49
- display: flex;
50
- align-items: center;
51
- justify-content: center;
52
- color: var(--_input-text-color);
53
- --icon-color: currentColor;
54
- }
55
- .tag .tag-content .slot-content {
56
- padding-inline: calc(var(--_container-padding) / 2);
57
- }
58
- .tag .dismiss-button {
59
- position: relative;
60
- border-radius: 12px;
61
- padding: 0;
62
- margin: 0;
63
- border: none;
64
- background: transparent;
65
- line-height: 0;
66
- cursor: pointer;
67
- }
68
- .tag .dismiss-button .dismiss-button-icon {
69
- --icon-size: var(--tag-icon-size, var(--_tag-icon-size));
70
- --icon-color: var(--_input-text-color);
71
- }
72
- .tag .dismiss-button .ripple {
73
- --ripple-state-opacity: var(--_container-state-opacity, 0);
74
- --ripple-pressed-color: var(--_container-state-color);
75
- }
76
- .tag {
77
- /**
78
- * Tag background layers
79
- */
80
- }
81
- .tag .background {
82
- display: block;
83
- position: absolute;
84
- width: 100%;
85
- height: 100%;
86
- background: var(--_container-color);
87
- border-radius: var(--_container-shape);
88
- corner-shape: var(--_container-corner-shape-variant);
89
- pointer-events: none;
90
- }
91
- .tag .outline {
92
- display: block;
93
- position: absolute;
94
- width: 100%;
95
- height: 100%;
96
- border-radius: var(--_container-shape);
97
- corner-shape: var(--_container-corner-shape-variant);
98
- border: 1px solid var(--_outline-color);
99
- }
100
- .tag .elevation {
101
- --elevation-level: 0;
102
- transition-duration: 280ms;
103
- border-radius: var(--_container-shape);
104
- corner-shape: var(--_container-corner-shape-variant);
105
- }
106
- .tag.dismissible .tag-content {
107
- padding-inline-end: 0.25rem;
108
- }
109
-
110
- slot::slotted(*) {
111
- --icon-size: var(--tag-icon-size, var(--_tag-icon-size));
112
- }
113
-
114
- /**
115
- * IconButton variant definitions
116
- */
117
- .tag.variant-elevated {
118
- --_container-color: var(--elevated-tag-container-color);
119
- --_input-text-color: var(--elevated-tag-label-text-color);
120
- --_container-elevation-level: 1;
121
- --_container-state-color: var(--_input-text-color);
122
- }
123
- .tag.variant-elevated .dismiss-button:hover {
124
- --_container-state-opacity: 0.08;
125
- }
126
-
127
- .tag.variant-filled {
128
- --_container-color: var(--filled-tag-container-color);
129
- --_input-text-color: var(--filled-tag-label-text-color);
130
- --_container-state-color: var(--_input-text-color);
131
- }
132
- .tag.variant-filled .dismiss-button:hover {
133
- --_container-state-opacity: 0.08;
134
- }
135
-
136
- .tag.variant-tonal {
137
- --_container-color: var(--tonal-tag-container-color);
138
- --_input-text-color: var(--tonal-tag-label-text-color);
139
- --_container-state-color: var(--_input-text-color);
140
- }
141
- .tag.variant-tonal .dismiss-button:hover {
142
- --_container-state-opacity: 0.08;
143
- }
144
-
145
- .tag.variant-outlined {
146
- --_outline-color: var(--outlined-tag-outline-color);
147
- --_input-text-color: var(--outlined-tag-label-text-color);
148
- --_container-state-color: var(--_input-text-color);
149
- }
150
- .tag.variant-outlined .dismiss-button:hover {
151
- --_container-state-opacity: 0.08;
152
- }`;
153
-
154
- var css_248z$f = i`:host([color=default]) {
155
- --filled-tag-container-color: var(--color-surface);
156
- --filled-tag-label-text-color: var(--color-on-surface);
157
- --tonal-tag-container-color: var(--color-surface-container);
158
- --tonal-tag-label-text-color: var(--color-on-surface-container);
159
- --elevated-tag-container-color: var(--color-surface-container-low);
160
- --elevated-tag-label-text-color: var(--color-on-surface);
161
- --outlined-tag-outline-color: var(--color-on-surface);
162
- --outlined-tag-label-text-color: var(--color-on-surface);
163
- }
164
-
165
- :host([color=red]) {
166
- --filled-tag-container-color: var(--color-red);
167
- --filled-tag-label-text-color: var(--color-on-red);
168
- --tonal-tag-container-color: var(--color-red-container);
169
- --tonal-tag-label-text-color: var(--color-on-red-container);
170
- --elevated-tag-container-color: var(--color-surface-container-low);
171
- --elevated-tag-label-text-color: var(--color-red);
172
- --outlined-tag-outline-color: var(--color-red);
173
- --outlined-tag-label-text-color: var(--color-red);
174
- }
175
-
176
- :host([color=green]) {
177
- --filled-tag-container-color: var(--color-green);
178
- --filled-tag-label-text-color: var(--color-on-green);
179
- --tonal-tag-container-color: var(--color-green-container);
180
- --tonal-tag-label-text-color: var(--color-on-green-container);
181
- --elevated-tag-container-color: var(--color-surface-container-low);
182
- --elevated-tag-label-text-color: var(--color-green);
183
- --outlined-tag-outline-color: var(--color-green);
184
- --outlined-tag-label-text-color: var(--color-green);
185
- }
186
-
187
- :host([color=blue]) {
188
- --filled-tag-container-color: var(--color-blue);
189
- --filled-tag-label-text-color: var(--color-on-blue);
190
- --tonal-tag-container-color: var(--color-blue-container);
191
- --tonal-tag-label-text-color: var(--color-on-blue-container);
192
- --elevated-tag-container-color: var(--color-surface-container-low);
193
- --elevated-tag-label-text-color: var(--color-blue);
194
- --outlined-tag-outline-color: var(--color-blue);
195
- --outlined-tag-label-text-color: var(--color-blue);
196
- }
197
-
198
- :host([color=yellow]) {
199
- --filled-tag-container-color: var(--color-yellow);
200
- --filled-tag-label-text-color: var(--color-on-yellow);
201
- --tonal-tag-container-color: var(--color-yellow-container);
202
- --tonal-tag-label-text-color: var(--color-on-yellow-container);
203
- --elevated-tag-container-color: var(--color-surface-container-low);
204
- --elevated-tag-label-text-color: var(--color-yellow);
205
- --outlined-tag-outline-color: var(--color-yellow);
206
- --outlined-tag-label-text-color: var(--color-yellow);
207
- }
208
-
209
- :host([color=purple]) {
210
- --filled-tag-container-color: var(--color-purple);
211
- --filled-tag-label-text-color: var(--color-on-purple);
212
- --tonal-tag-container-color: var(--color-purple-container);
213
- --tonal-tag-label-text-color: var(--color-on-purple-container);
214
- --elevated-tag-container-color: var(--color-surface-container-low);
215
- --elevated-tag-label-text-color: var(--color-purple);
216
- --outlined-tag-outline-color: var(--color-purple);
217
- --outlined-tag-label-text-color: var(--color-purple);
218
- }`;
219
-
220
- var css_248z$e = i`.tag {
221
- font-family: var(--font-family-sans) !important;
222
- }
223
-
224
- .tag.size-sm,
225
- .tag.size-small {
226
- --_chip-height: 1.5rem;
227
- --_tag-icon-size: 1rem;
228
- --_container-padding: 0.75rem;
229
- font-family: var(--typography-label-medium-font-family) !important;
230
- font-size: var(--typography-label-medium-font-size) !important;
231
- font-weight: var(--typography-label-medium-font-weight) !important;
232
- line-height: var(--typography-label-medium-line-height) !important;
233
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
234
- }
235
-
236
- .tag.size-md,
237
- .tag.size-medium {
238
- --_chip-height: 2rem;
239
- --_tag-icon-size: 1.125rem;
240
- --_container-padding: 1rem;
241
- font-family: var(--typography-label-large-font-family) !important;
242
- font-size: var(--typography-label-large-font-size) !important;
243
- font-weight: var(--typography-label-large-font-weight) !important;
244
- line-height: var(--typography-label-large-line-height) !important;
245
- letter-spacing: var(--typography-label-large-letter-spacing) !important;
246
- }`;
247
-
248
- /**
249
- * @label Tag
250
- * @tag wc-tag
251
- * @rawTag tag
252
- * @summary Tag component for displaying labels or values with optional dismiss functionality.
253
- * @tags display
254
- *
255
- * @example
256
- * ```html
257
- * <wc-tag color="red">Tag</wc-tag>
258
- * ```
259
- */
260
- class Tag extends i$1 {
261
- constructor() {
262
- super(...arguments);
263
- /** If true, the tag will have a close icon. */
264
- this.dismissible = false;
265
- this.variant = 'tonal';
266
- /** Tag color. */
267
- this.color = 'default';
268
- this.size = 'md';
269
- }
270
- _dismissClickHandler(e) {
271
- e.stopPropagation();
272
- // Custom Event: tag--dismiss
273
- this.dispatchEvent(new CustomEvent('tag--dismiss', {
274
- bubbles: true,
275
- }));
276
- }
277
- __renderDismissButton() {
278
- if (!this.dismissible)
279
- return null;
280
- return b `
281
- <button
282
- class="dismiss-button"
283
- @click=${this._dismissClickHandler}
284
- aria-label="Dismiss"
285
- >
286
- <wc-ripple class="ripple"></wc-ripple>
287
- <wc-icon class="dismiss-button-icon" name="close"></wc-icon>
288
- </button>
289
- `;
290
- }
291
- render() {
292
- const classes = {
293
- tag: true,
294
- dismissible: this.dismissible,
295
- [`color-${this.color}`]: true,
296
- [`variant-${this.variant}`]: true,
297
- [`size-${this.size}`]: true,
298
- };
299
- return b `
300
- <div class="${e(classes)}">
301
- <wc-elevation class="elevation"></wc-elevation>
302
- <div class="background"></div>
303
- <div class="outline"></div>
304
-
305
- <div class="tag-content">
306
- <slot name="icon"></slot>
307
-
308
- <div class="slot-content">
309
- <slot></slot>
310
- </div>
311
- ${this.__renderDismissButton()}
312
- </div>
313
- </div>
314
- `;
315
- }
316
- }
317
- // Define styles (Lit handles Scoping via Shadow DOM by default)
318
- // You would typically import your tag.scss.js here or use the css tag
319
- Tag.styles = [css_248z$g, css_248z$f, css_248z$e];
320
- __decorate([
321
- n({ type: Boolean })
322
- ], Tag.prototype, "dismissible", void 0);
323
- __decorate([
324
- n()
325
- ], Tag.prototype, "variant", void 0);
326
- __decorate([
327
- n({ type: String, reflect: true })
328
- ], Tag.prototype, "color", void 0);
329
- __decorate([
330
- n()
331
- ], Tag.prototype, "size", void 0);
332
-
333
- var css_248z$d = i`* {
334
- box-sizing: border-box;
335
- -webkit-tap-highlight-color: transparent;
336
- }
337
-
338
- .screen-reader-only {
339
- display: none !important;
340
- }
341
-
342
- [hidden] {
343
- display: none !important;
344
- }
345
-
346
- :host {
347
- display: block;
348
- }
349
-
350
- slot {
351
- display: flex;
352
- flex-wrap: wrap;
353
- gap: 8px;
354
- }`;
355
-
356
- /**
357
- * @label Chip Set
358
- * @tag wc-chip-set
359
- * @rawTag chip-set
360
- * @summary A layout container for wrapping chips.
361
- * @tags layout
362
- *
363
- * @example
364
- * ```html
365
- * <wc-chip-set>
366
- * <wc-chip>One</wc-chip>
367
- * <wc-chip>Two</wc-chip>
368
- * </wc-chip-set>
369
- * ```
370
- */
371
- class ChipSet extends i$1 {
372
- render() {
373
- return b `<slot></slot>`;
374
- }
375
- }
376
- ChipSet.styles = [css_248z$d];
377
-
378
- var css_248z$c = i`:host {
379
- display: block;
380
- --progress-height: 0.25rem;
381
- --progress-container-color: var(--color-primary);
382
- --progress-track-color: var(--color-secondary-container);
383
- min-width: 2.5rem;
384
- }
385
-
386
- .linear-progress {
387
- display: flex;
388
- flex-direction: column;
389
- }
390
- .linear-progress .progress-header {
391
- display: flex;
392
- align-items: center;
393
- }
394
- .linear-progress .progress-header .progress-label {
395
- font-family: var(--typography-label-medium-font-family) !important;
396
- font-size: var(--typography-label-medium-font-size) !important;
397
- font-weight: var(--typography-label-medium-font-weight) !important;
398
- line-height: var(--typography-label-medium-line-height) !important;
399
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
400
- color: var(--color-on-surface);
401
- flex: 1;
402
- }
403
- .linear-progress .progress-body {
404
- display: flex;
405
- flex-direction: column;
406
- }
407
- .linear-progress .progress-body .linear-progress-container {
408
- position: relative;
409
- display: flex;
410
- align-items: flex-start;
411
- width: 100%;
412
- margin: var(--spacing-100) 0;
413
- }
414
- .linear-progress .progress-body .linear-progress-container .track {
415
- position: relative;
416
- }
417
- .linear-progress .progress-body .linear-progress-container .track:after {
418
- content: "";
419
- position: absolute;
420
- display: block;
421
- top: 0;
422
- left: 0;
423
- width: calc(100% - 0.25rem);
424
- height: var(--progress-height);
425
- background: var(--progress-track-color);
426
- border-radius: var(--shape-corner-full);
427
- }
428
- .linear-progress .progress-body .linear-progress-container .track-start:after {
429
- margin-inline-end: 0.25rem;
430
- }
431
- .linear-progress .progress-body .linear-progress-container .active-indicator {
432
- height: var(--progress-height);
433
- background: var(--progress-container-color);
434
- border-radius: var(--shape-corner-full);
435
- }
436
- .linear-progress .progress-body .linear-progress-container .track-end {
437
- flex: 1;
438
- }
439
- .linear-progress .progress-body .linear-progress-container .track-end:after {
440
- margin-inline-start: 0.25rem;
441
- }
442
- .linear-progress .progress-body .progress-helper {
443
- font-family: var(--typography-body-small-font-family) !important;
444
- font-size: var(--typography-body-small-font-size) !important;
445
- font-weight: var(--typography-body-small-font-weight) !important;
446
- line-height: var(--typography-body-small-line-height) !important;
447
- letter-spacing: var(--typography-body-small-letter-spacing) !important;
448
- color: var(--color-on-surface-variant);
449
- }
450
- .linear-progress:not(.indeterminate) .track-start {
451
- transition: width var(--duration-medium2) var(--easing-standard);
452
- }
453
- .linear-progress:not(.indeterminate) .active-indicator {
454
- transition: width var(--duration-medium2) var(--easing-standard);
455
- }
456
- .linear-progress.indeterminate .linear-progress-container .track-start {
457
- animation-duration: 3s;
458
- animation-iteration-count: infinite;
459
- animation-name: track-start-indeterminate;
460
- animation-timing-function: var(--easing-linear);
461
- }
462
- .linear-progress.indeterminate .linear-progress-container .active-indicator {
463
- animation-duration: 3s;
464
- animation-iteration-count: infinite;
465
- animation-name: active-indicator-indeterminate;
466
- animation-timing-function: var(--easing-linear);
467
- }
468
- .linear-progress.inline {
469
- flex-direction: row;
470
- gap: var(--spacing-200);
471
- }
472
- .linear-progress.inline .progress-body {
473
- flex: 1;
474
- }
475
-
476
- @keyframes track-start-indeterminate {
477
- 0% {
478
- width: 0;
479
- }
480
- 50% {
481
- width: 33%;
482
- }
483
- 80%, to {
484
- width: 100%;
485
- padding-inline-end: 0;
486
- }
487
- }
488
- @keyframes active-indicator-indeterminate {
489
- 0% {
490
- width: 0;
491
- }
492
- 50% {
493
- width: 33%;
494
- }
495
- 80%, to {
496
- width: 0;
497
- }
498
- }`;
499
-
500
- class BaseProgress extends i$1 {
501
- constructor() {
502
- super(...arguments);
503
- this.indeterminate = false;
504
- this.inline = false;
505
- }
506
- __getPercentageValue() {
507
- if (!this.value)
508
- return 0;
509
- return this.value;
510
- }
511
- }
512
- __decorate([
513
- n({ type: Number })
514
- ], BaseProgress.prototype, "value", void 0);
515
- __decorate([
516
- n({ type: Boolean })
517
- ], BaseProgress.prototype, "indeterminate", void 0);
518
- __decorate([
519
- n({ type: String })
520
- ], BaseProgress.prototype, "label", void 0);
521
- __decorate([
522
- n({ type: String, attribute: 'helper-text' })
523
- ], BaseProgress.prototype, "helperText", void 0);
524
- __decorate([
525
- n({ type: Boolean })
526
- ], BaseProgress.prototype, "inline", void 0);
527
-
528
- /**
529
- * @label Linear Progress
530
- * @tag wc-linear-progress
531
- * @rawTag linear-progress
532
- * @summary A linear progress indicator is a visual representation of progress toward a specific goal.
533
- * @tags display
534
- *
535
- * @example
536
- * ```html
537
- * <wc-linear-progress value="30" style="width:10rem"></wc-linear-progress>
538
- * ```
539
- */
540
- class LinearProgress extends BaseProgress {
541
- render() {
542
- return b `
543
- <div
544
- class="${e({
545
- 'linear-progress': true,
546
- indeterminate: this.indeterminate,
547
- inline: this.inline,
548
- })}"
549
- >
550
- ${this.label
551
- ? b `<div class="progress-header">
552
- <label class="progress-label">${this.label}</label>
553
- </div>`
554
- : ''}
555
-
556
- <div class="progress-body">
557
- <div
558
- class="linear-progress-container"
559
- title=${this.label}
560
- ?aria-valuenow="${this.__getPercentageValue()}"
561
- aria-valuemin="0"
562
- aria-valuemax="100"
563
- role="progressbar"
564
- >
565
- <div class="track track-start"></div>
566
- <div
567
- class="active-indicator"
568
- style="${o({
569
- width: `${this.__getPercentageValue()}%`,
570
- })}"
571
- ></div>
572
- <div class="track track-end"></div>
573
- </div>
574
-
575
- ${this.helperText
576
- ? b `<div class="progress-helper">${this.helperText}</div>`
577
- : ''}
578
- </div>
579
- </div>
580
- `;
581
- }
582
- }
583
- // Lit components use static styles for better performance
584
- LinearProgress.styles = [css_248z$c];
585
-
586
- var css_248z$b = i`:host {
587
- display: inline-block;
588
- --progress-height: 1.5rem;
589
- --progress-line-thickness: 4px;
590
- --progress-container-color: var(--color-primary);
591
- --progress-track-color: var(--color-secondary-container);
592
- }
593
-
594
- .circular-progress {
595
- display: flex;
596
- flex-direction: column;
597
- }
598
- .circular-progress .circular-progress-container {
599
- position: relative;
600
- width: 100%;
601
- --_container-height: clamp(0rem, var(--progress-height), 15rem);
602
- height: var(--_container-height);
603
- }
604
- .circular-progress .circular-progress-container .progress-label {
605
- font-family: var(--typography-label-large-emphasized-font-family) !important;
606
- font-size: var(--typography-label-large-emphasized-font-size) !important;
607
- font-weight: var(--typography-label-large-emphasized-font-weight) !important;
608
- line-height: var(--typography-label-large-emphasized-line-height) !important;
609
- letter-spacing: var(--typography-label-large-emphasized-letter-spacing) !important;
610
- color: var(--color-on-surface);
611
- flex: 1;
612
- width: 100%;
613
- height: 100%;
614
- display: flex;
615
- align-items: center;
616
- justify-content: center;
617
- }
618
- .circular-progress .circular-progress-container svg {
619
- transform: rotate(-90deg);
620
- width: 100%;
621
- height: 100%;
622
- }
623
- .circular-progress .circular-progress-container circle {
624
- fill: none;
625
- stroke-linecap: round;
626
- transition: stroke-dashoffset var(--duration-medium2) var(--easing-standard);
627
- }
628
- .circular-progress .circular-progress-container .track {
629
- stroke: var(--progress-track-color);
630
- stroke-width: calc(var(--progress-line-thickness) / (tan(atan2(var(--_container-height), 1px)) / 16));
631
- }
632
- .circular-progress .circular-progress-container .active-indicator {
633
- stroke: var(--progress-container-color);
634
- stroke-width: calc(var(--progress-line-thickness) / (tan(atan2(var(--_container-height), 1px)) / 16));
635
- }
636
- .circular-progress.indeterminate .active-indicator {
637
- animation: arc-indeterminate 1.5s ease-in-out infinite;
638
- }
639
- .circular-progress .progress-label {
640
- font-family: var(--typography-label-medium-font-family) !important;
641
- font-size: var(--typography-label-medium-font-size) !important;
642
- font-weight: var(--typography-label-medium-font-weight) !important;
643
- line-height: var(--typography-label-medium-line-height) !important;
644
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
645
- color: var(--color-on-surface);
646
- }
647
- .circular-progress .progress-helper {
648
- font-family: var(--typography-label-small-font-family) !important;
649
- font-size: var(--typography-label-small-font-size) !important;
650
- font-weight: var(--typography-label-small-font-weight) !important;
651
- line-height: var(--typography-label-small-line-height) !important;
652
- letter-spacing: var(--typography-label-small-letter-spacing) !important;
653
- color: var(--color-on-surface-variant);
654
- text-align: center;
655
- }
656
- .circular-progress.inline {
657
- flex-direction: row;
658
- align-items: center;
659
- gap: var(--spacing-200);
660
- }
661
- .circular-progress.inline .progress-footer {
662
- flex: 1;
663
- }
664
- .circular-progress.inline .progress-helper {
665
- text-align: start;
666
- }
667
-
668
- @keyframes rotate-container {
669
- 100% {
670
- transform: rotate(360deg);
671
- }
672
- }
673
- @keyframes arc-indeterminate {
674
- 0% {
675
- stroke-dasharray: 1, 150;
676
- stroke-dashoffset: 0;
677
- }
678
- 50% {
679
- stroke-dasharray: 90, 150;
680
- stroke-dashoffset: -35;
681
- }
682
- 100% {
683
- stroke-dasharray: 90, 150;
684
- stroke-dashoffset: -124;
685
- }
686
- }`;
687
-
688
- /**
689
- * @label Circular Progress
690
- * @tag wc-circular-progress
691
- * @rawTag circular-progress
692
- * @summary A circular progress indicator is a visual representation of progress toward a specific goal.
693
- * @tags display
694
- *
695
- * @example
696
- * ```html
697
- * <wc-circular-progress value="30"></wc-circular-progress>
698
- * ```
699
- */
700
- class CircularProgress extends BaseProgress {
701
- render() {
702
- const percentage = this.__getPercentageValue();
703
- // Radius of 18 with stroke 4 fits nicely in a 40x40 viewBox
704
- const radius = 6;
705
- const circumference = 2 * Math.PI * radius;
706
- const offset = circumference - (percentage / 100) * circumference;
707
- return b `
708
- <div
709
- class="${e({
710
- 'circular-progress': true,
711
- indeterminate: this.indeterminate,
712
- inline: this.inline,
713
- })}"
714
- title=${this.label}
715
- role="progressbar"
716
- aria-valuenow="${this.indeterminate ? undefined : percentage}"
717
- aria-valuemin="0"
718
- aria-valuemax="100"
719
- >
720
- <div class="circular-progress-container">
721
- <svg viewBox="0 0 16 16">
722
- <circle class="track" cx="8" cy="8" r="6"></circle>
723
- <circle
724
- class="active-indicator"
725
- cx="8"
726
- cy="8"
727
- r="6"
728
- style="${o({
729
- strokeDasharray: `${circumference}`,
730
- strokeDashoffset: this.indeterminate ? undefined : `${offset}`,
731
- })}"
732
- ></circle>
733
- </svg>
734
- </div>
735
-
736
- <div class="progress-footer">
737
- ${this.label
738
- ? b `<div class="progress-label">${this.label}</div>`
739
- : ''}
740
- ${this.helperText
741
- ? b `<div class="progress-helper">${this.helperText}</div>`
742
- : ''}
743
- </div>
744
- </div>
745
- `;
746
- }
747
- }
748
- // Lit components use static styles for better performance
749
- CircularProgress.styles = [css_248z$b];
750
-
751
- var css_248z$a = i`* {
752
- box-sizing: border-box;
753
- -webkit-tap-highlight-color: transparent;
754
- }
755
-
756
- .screen-reader-only {
757
- display: none !important;
758
- }
759
-
760
- [hidden] {
761
- display: none !important;
762
- }
763
-
764
- :host {
765
- display: block;
766
- width: 100%;
767
- }
768
-
769
- .input-element {
770
- border: none;
771
- outline: none;
772
- margin: 0;
773
- padding: 0;
774
- }
775
-
776
- .input-wrapper .input {
777
- flex: 1;
778
- width: 100%;
779
- background: none;
780
- cursor: inherit;
781
- }
782
- .input-wrapper .password-toggle {
783
- --button-container-shape: var(--shape-corner-full);
784
- }`;
785
-
786
- /**
787
- * @label Input
788
- * @tag wc-input
789
- * @rawTag input
790
- *
791
- * @summary The Input component is used to capture user input.
792
- *
793
- * @example
794
- * ```html
795
- * <wc-input label="Name" required placeholder="Enter your name"></wc-input>
796
- * ```
797
- */
798
- class Input extends BaseInput {
799
- constructor() {
800
- super(...arguments);
801
- this.value = "";
802
- this.name = "";
803
- this.placeholder = "";
804
- this.label = "";
805
- this.inline = false;
806
- this.size = "md";
807
- this.type = "text";
808
- this.autocomplete = "off";
809
- this.configAria = {};
810
- this.variant = "default";
811
- /**
812
- * Helper text to display below the input.
813
- */
814
- this.helperText = "";
815
- this.error = false;
816
- this.errorText = "";
817
- this.warning = false;
818
- this.warningText = "";
819
- this.focused = false;
820
- this.passwordVisible = false;
821
- /**
822
- * Returns true when the text field has been interacted with. Native
823
- * validation errors only display in response to user interactions.
824
- */
825
- this.dirty = false;
826
- this.__handleFocusChange = (event) => {
827
- this.focused = event.type === "focus";
828
- };
829
- }
830
- async focus() {
831
- await Promise.all([
832
- customElements.whenDefined("wc-input"),
833
- customElements.whenDefined("wc-field"),
834
- ]);
835
- await this.updateComplete;
836
- this.inputElement?.focus();
837
- }
838
- connectedCallback() {
839
- super.connectedCallback();
840
- this.handleInitialAttributes();
841
- }
842
- handleInitialAttributes() {
843
- Array.from(this.attributes).forEach((attr) => {
844
- if (attr.name.startsWith("aria-")) {
845
- this.configAria[attr.name] = attr.value;
846
- this.removeAttribute(attr.name);
847
- }
848
- });
849
- }
850
- __handleInput(event) {
851
- this.dirty = true;
852
- this.value = event.target.value;
853
- }
854
- __redispatchEvent(event) {
855
- redispatchEvent(this, event);
856
- }
857
- render() {
858
- const displayType = this.type === "password" && this.passwordVisible
859
- ? "text"
860
- : this.type;
861
- return b `
862
- <wc-field
863
- ?required="${this.required}"
864
- ?disabled="${this.disabled}"
865
- ?readonly="${this.readonly}"
866
- ?skeleton="${this.skeleton}"
867
- helper-text="${this.helperText}"
868
- ?error="${this.error}"
869
- error-text="${this.errorText}"
870
- ?warning="${this.warning}"
871
- variant="${this.variant}"
872
- ?populated="${!!this.value}"
873
- warning-text="${this.warningText}"
874
- label="${this.label}"
875
- ?focused="${this.focused}"
876
- .host="${this}"
877
- class="input-wrapper"
878
- >
879
- <slot name="start" slot="field-start"></slot>
880
-
881
- <input
882
- class="input input-element"
883
- name="${this.name}"
884
- type="${displayType}"
885
- placeholder="${this.placeholder}"
886
- autocomplete="${this.autocomplete}"
887
- .value="${this.value}"
888
- ?readonly="${this.readonly}"
889
- ?required="${this.required}"
890
- ?disabled="${this.disabled}"
891
- @input="${this.__handleInput}"
892
- @change="${this.__redispatchEvent}"
893
- @focus="${this.__handleFocusChange}"
894
- @blur="${this.__handleFocusChange}"
895
- ${spread(this.configAria)}
896
- />
897
-
898
- <slot name="end" slot="field-end"></slot>
899
-
900
- ${this.type === "password"
901
- ? b `
902
- <wc-icon-button
903
- class="password-toggle"
904
- variant="text"
905
- slot="field-end"
906
- tooltip="${this.passwordVisible
907
- ? "Hide password"
908
- : "Show password"}"
909
- @click="${() => {
910
- this.passwordVisible = !this.passwordVisible;
911
- }}"
912
- >
913
- <wc-icon
914
- name="${this.passwordVisible ? "visibility_off" : "visibility"}"
915
- ></wc-icon>
916
- </wc-icon-button>
917
- `
918
- : A}
919
- </wc-field>
920
- `;
921
- }
922
- }
923
- Input.styles = [css_248z$a];
924
- __decorate([
925
- n({ type: String })
926
- ], Input.prototype, "value", void 0);
927
- __decorate([
928
- n({ type: String })
929
- ], Input.prototype, "name", void 0);
930
- __decorate([
931
- n({ type: String })
932
- ], Input.prototype, "placeholder", void 0);
933
- __decorate([
934
- n({ type: String })
935
- ], Input.prototype, "label", void 0);
936
- __decorate([
937
- n({ type: Boolean, reflect: true })
938
- ], Input.prototype, "inline", void 0);
939
- __decorate([
940
- n({ type: String, reflect: true })
941
- ], Input.prototype, "size", void 0);
942
- __decorate([
943
- n({ type: String })
944
- ], Input.prototype, "type", void 0);
945
- __decorate([
946
- n({ type: String })
947
- ], Input.prototype, "autocomplete", void 0);
948
- __decorate([
949
- n({ type: Object })
950
- ], Input.prototype, "configAria", void 0);
951
- __decorate([
952
- n({ type: String })
953
- ], Input.prototype, "variant", void 0);
954
- __decorate([
955
- n({ type: String, attribute: "helper-text" })
956
- ], Input.prototype, "helperText", void 0);
957
- __decorate([
958
- n({ type: Boolean })
959
- ], Input.prototype, "error", void 0);
960
- __decorate([
961
- n({ type: String, attribute: "error-text" })
962
- ], Input.prototype, "errorText", void 0);
963
- __decorate([
964
- n({ type: Boolean })
965
- ], Input.prototype, "warning", void 0);
966
- __decorate([
967
- n({ type: String, attribute: "warning-text" })
968
- ], Input.prototype, "warningText", void 0);
969
- __decorate([
970
- r()
971
- ], Input.prototype, "focused", void 0);
972
- __decorate([
973
- r()
974
- ], Input.prototype, "passwordVisible", void 0);
975
- __decorate([
976
- r()
977
- ], Input.prototype, "dirty", void 0);
978
- __decorate([
979
- e$1(".input-element")
980
- ], Input.prototype, "inputElement", void 0);
981
-
982
- var css_248z$9 = i`* {
983
- box-sizing: border-box;
984
- -webkit-tap-highlight-color: transparent;
985
- }
986
-
987
- .screen-reader-only {
988
- display: none !important;
989
- }
990
-
991
- [hidden] {
992
- display: none !important;
993
- }
994
-
995
- :host {
996
- display: block;
997
- width: 100%;
998
- }
999
-
1000
- .url-input {
1001
- flex: 1;
1002
- width: 100%;
1003
- border: none;
1004
- outline: none;
1005
- margin: 0;
1006
- padding: 0;
1007
- background: none;
1008
- cursor: inherit;
1009
- font: inherit;
1010
- color: inherit;
1011
- }
1012
-
1013
- .url-display {
1014
- flex: 1;
1015
- display: flex;
1016
- align-items: center;
1017
- overflow: hidden;
1018
- }
1019
-
1020
- .url-link {
1021
- flex: 1;
1022
- overflow: hidden;
1023
- text-overflow: ellipsis;
1024
- white-space: nowrap;
1025
- color: var(--color-primary);
1026
- text-decoration: none;
1027
- }
1028
- .url-link:hover {
1029
- text-decoration: underline;
1030
- }
1031
-
1032
- .url-placeholder {
1033
- color: var(--color-on-surface-variant);
1034
- opacity: 0.6;
1035
- }
1036
-
1037
- .edit-button {
1038
- --button-container-shape: var(--shape-corner-full);
1039
- }`;
1040
-
1041
- /**
1042
- * @label URL Field
1043
- * @tag wc-url-field
1044
- * @rawTag url-field
1045
- *
1046
- * @summary A field for entering and displaying URLs with validation.
1047
- * @overview
1048
- * <p>URL Field wraps an input with URL validation, showing a clickable link preview when not in edit mode.</p>
1049
- *
1050
- * @example
1051
- * ```html
1052
- * <wc-url-field label="Website" value="https://example.com"></wc-url-field>
1053
- * ```
1054
- * @tags form
1055
- */
1056
- class UrlField extends BaseInput {
1057
- constructor() {
1058
- super(...arguments);
1059
- this.value = '';
1060
- this.name = '';
1061
- this.placeholder = '';
1062
- this.label = '';
1063
- this.editing = false;
1064
- this.debounce = 300;
1065
- this.size = 'md';
1066
- this.variant = 'default';
1067
- this.helperText = '';
1068
- this.error = false;
1069
- this.errorText = '';
1070
- this.warning = false;
1071
- this.warningText = '';
1072
- this.focused = false;
1073
- this.isValid = true;
1074
- }
1075
- disconnectedCallback() {
1076
- super.disconnectedCallback();
1077
- if (this.debounceTimer) {
1078
- clearTimeout(this.debounceTimer);
1079
- }
1080
- }
1081
- focus() {
1082
- if (!this.editing && !this.disabled && !this.readonly) {
1083
- this.startEditing();
1084
- return;
1085
- }
1086
- this.inputElement?.focus();
1087
- }
1088
- blur() {
1089
- this.inputElement?.blur();
1090
- }
1091
- startEditing() {
1092
- if (this.disabled || this.readonly)
1093
- return;
1094
- this.editing = true;
1095
- setTimeout(() => this.inputElement?.focus(), 80);
1096
- }
1097
- closeEditing() {
1098
- this.isValid = this.validateUrl(this.value);
1099
- this.dispatchEvent(new CustomEvent('input-invalid', {
1100
- detail: !this.isValid,
1101
- bubbles: true,
1102
- composed: true,
1103
- }));
1104
- if (this.isValid) {
1105
- this.editing = false;
1106
- }
1107
- }
1108
- validateUrl(url) {
1109
- if (!url)
1110
- return true;
1111
- try {
1112
- new URL(url);
1113
- return true;
1114
- }
1115
- catch {
1116
- return false;
1117
- }
1118
- }
1119
- handleInput(event) {
1120
- this.value = event.target.value;
1121
- this.isValid = true;
1122
- if (this.debounceTimer) {
1123
- clearTimeout(this.debounceTimer);
1124
- }
1125
- this.debounceTimer = setTimeout(() => {
1126
- this.dispatchEvent(new CustomEvent('value-change', {
1127
- detail: this.value,
1128
- bubbles: true,
1129
- composed: true,
1130
- }));
1131
- }, this.debounce);
1132
- }
1133
- handleFocusChange() {
1134
- this.focused = this.inputElement?.matches(':focus') ?? false;
1135
- }
1136
- handleBlur() {
1137
- this.focused = false;
1138
- this.closeEditing();
1139
- }
1140
- handleChange(event) {
1141
- redispatchEvent(this, event);
1142
- }
1143
- renderDisplayValue() {
1144
- if (!this.value) {
1145
- return b `<span class="url-placeholder">${this.placeholder}</span>`;
1146
- }
1147
- return b `
1148
- <a
1149
- class="url-link"
1150
- href=${this.value}
1151
- target="_blank"
1152
- rel="noopener noreferrer"
1153
- >
1154
- ${this.value}
1155
- </a>
1156
- `;
1157
- }
1158
- render() {
1159
- const hasValue = !!this.value;
1160
- const showInvalidState = this.error || !this.isValid;
1161
- const resolvedErrorText = !this.isValid
1162
- ? 'Please enter a valid URL'
1163
- : this.errorText;
1164
- return b `
1165
- <wc-field
1166
- label=${this.label}
1167
- ?required=${this.required}
1168
- ?disabled=${this.disabled}
1169
- ?readonly=${this.readonly}
1170
- ?skeleton=${this.skeleton}
1171
- helper-text=${this.helperText}
1172
- ?error=${showInvalidState}
1173
- error-text=${resolvedErrorText}
1174
- ?warning=${this.warning}
1175
- warning-text=${this.warningText}
1176
- variant=${this.variant}
1177
- ?populated=${hasValue || this.editing}
1178
- ?focused=${this.focused}
1179
- .host=${this}
1180
- class="url-field-wrapper"
1181
- >
1182
- ${this.editing
1183
- ? b `
1184
- <input
1185
- class="url-input"
1186
- name=${this.name}
1187
- type="url"
1188
- placeholder=${this.placeholder}
1189
- .value=${this.value}
1190
- ?readonly=${this.readonly}
1191
- ?required=${this.required}
1192
- ?disabled=${this.disabled}
1193
- @input=${this.handleInput}
1194
- @change=${this.handleChange}
1195
- @focus=${this.handleFocusChange}
1196
- @blur=${this.handleBlur}
1197
- />
1198
- `
1199
- : b `<div class="url-display">${this.renderDisplayValue()}</div>`}
1200
- ${!this.editing && !this.disabled && !this.readonly
1201
- ? b `
1202
- <wc-icon-button
1203
- class="edit-button"
1204
- slot="field-end"
1205
- variant="text"
1206
- @click=${(event) => {
1207
- event.stopPropagation();
1208
- this.startEditing();
1209
- }}
1210
- >
1211
- <wc-icon name="edit"></wc-icon>
1212
- </wc-icon-button>
1213
- `
1214
- : A}
1215
- </wc-field>
1216
- `;
1217
- }
1218
- }
1219
- UrlField.styles = [css_248z$9];
1220
- __decorate([
1221
- n({ type: String })
1222
- ], UrlField.prototype, "value", void 0);
1223
- __decorate([
1224
- n({ type: String })
1225
- ], UrlField.prototype, "name", void 0);
1226
- __decorate([
1227
- n({ type: String })
1228
- ], UrlField.prototype, "placeholder", void 0);
1229
- __decorate([
1230
- n({ type: String })
1231
- ], UrlField.prototype, "label", void 0);
1232
- __decorate([
1233
- n({ type: Boolean, reflect: true })
1234
- ], UrlField.prototype, "editing", void 0);
1235
- __decorate([
1236
- n({ type: Number })
1237
- ], UrlField.prototype, "debounce", void 0);
1238
- __decorate([
1239
- n({ type: String, reflect: true })
1240
- ], UrlField.prototype, "size", void 0);
1241
- __decorate([
1242
- n({ type: String })
1243
- ], UrlField.prototype, "variant", void 0);
1244
- __decorate([
1245
- n({ type: String, attribute: 'helper-text' })
1246
- ], UrlField.prototype, "helperText", void 0);
1247
- __decorate([
1248
- n({ type: Boolean })
1249
- ], UrlField.prototype, "error", void 0);
1250
- __decorate([
1251
- n({ type: String, attribute: 'error-text' })
1252
- ], UrlField.prototype, "errorText", void 0);
1253
- __decorate([
1254
- n({ type: Boolean })
1255
- ], UrlField.prototype, "warning", void 0);
1256
- __decorate([
1257
- n({ type: String, attribute: 'warning-text' })
1258
- ], UrlField.prototype, "warningText", void 0);
1259
- __decorate([
1260
- r()
1261
- ], UrlField.prototype, "focused", void 0);
1262
- __decorate([
1263
- r()
1264
- ], UrlField.prototype, "isValid", void 0);
1265
- __decorate([
1266
- e$1('.url-input')
1267
- ], UrlField.prototype, "inputElement", void 0);
1268
-
1269
- var css_248z$8 = i`* {
1270
- box-sizing: border-box;
1271
- -webkit-tap-highlight-color: transparent;
1272
- }
1273
-
1274
- .screen-reader-only {
1275
- display: none !important;
1276
- }
1277
-
1278
- [hidden] {
1279
- display: none !important;
1280
- }
1281
-
1282
- :host {
1283
- display: block;
1284
- width: 100%;
1285
- }
1286
-
1287
- .input-element {
1288
- border: none;
1289
- outline: none;
1290
- margin: 0;
1291
- padding: 0;
1292
- }
1293
-
1294
- .input-wrapper .input {
1295
- flex: 1;
1296
- width: 100%;
1297
- background: none;
1298
- cursor: inherit;
1299
- }
1300
- .input-wrapper .password-toggle {
1301
- --button-container-shape: var(--shape-corner-full);
1302
- }
1303
-
1304
- .stepper {
1305
- /* Chrome, Safari, Edge, Opera */
1306
- }
1307
- .stepper input::-webkit-outer-spin-button,
1308
- .stepper input::-webkit-inner-spin-button {
1309
- -webkit-appearance: none;
1310
- margin: 0;
1311
- }
1312
- .stepper {
1313
- /* Firefox */
1314
- }
1315
- .stepper input[type=number] {
1316
- -moz-appearance: textfield;
1317
- }`;
1318
-
1319
- var _NumberField_id;
1320
- /**
1321
- * @label Number Field
1322
- * @tag wc-number-field
1323
- * @rawTag number-field
1324
- *
1325
- * @summary The Number Field component is used to capture numeric user input.
1326
- *
1327
- * @example
1328
- * ```html
1329
- * <wc-number-field label="Age" placeholder="Enter your age"></wc-number-field>
1330
- * ```
1331
- */
1332
- class NumberField extends BaseInput {
1333
- constructor() {
1334
- super(...arguments);
1335
- _NumberField_id.set(this, crypto.randomUUID());
1336
- this.name = '';
1337
- this.placeholder = '';
1338
- this.label = '';
1339
- this.inline = false;
1340
- this.size = 'md';
1341
- this.autocomplete = 'off';
1342
- this.configAria = {};
1343
- /**
1344
- * Helper text to display below the input.
1345
- */
1346
- this.helperText = '';
1347
- this.error = false;
1348
- this.errorText = '';
1349
- this.warning = false;
1350
- this.warningText = '';
1351
- this.stepper = false;
1352
- this.focused = false;
1353
- /**
1354
- * Returns true when the text field has been interacted with. Native
1355
- * validation errors only display in response to user interactions.
1356
- */
1357
- this.dirty = false;
1358
- }
1359
- connectedCallback() {
1360
- super.connectedCallback();
1361
- this.handleInitialAttributes();
1362
- }
1363
- handleInitialAttributes() {
1364
- if (this.hasAttribute('tabindex')) {
1365
- this.tabindex = this.getAttribute('tabindex') || undefined;
1366
- this.removeAttribute('tabindex');
1367
- }
1368
- Array.from(this.attributes).forEach(attr => {
1369
- if (attr.name.startsWith('aria-')) {
1370
- this.configAria[attr.name] = attr.value;
1371
- this.removeAttribute(attr.name);
1372
- }
1373
- });
1374
- }
1375
- __handleInput(event) {
1376
- this.dirty = true;
1377
- this.value = Number(event.target.value);
1378
- }
1379
- focus() {
1380
- this.inputElement?.focus();
1381
- }
1382
- blur() {
1383
- this.inputElement?.blur();
1384
- }
1385
- __handleFocusChange() {
1386
- // When calling focus() or reportValidity() during change, it's possible
1387
- // for blur to be called after the new focus event. Rather than set
1388
- // `this.focused` to true/false on focus/blur, we always set it to whether
1389
- // or not the input itself is focused.
1390
- this.focused = this.inputElement?.matches(':focus') ?? false;
1391
- }
1392
- __redispatchEvent(event) {
1393
- redispatchEvent(this, event);
1394
- }
1395
- stepUp() {
1396
- this.inputElement?.stepUp();
1397
- }
1398
- stepDown() {
1399
- this.inputElement?.stepDown();
1400
- }
1401
- render() {
1402
- const classes = {
1403
- 'input-wrapper': true,
1404
- stepper: this.stepper,
1405
- };
1406
- return b `
1407
- <wc-field
1408
- ?required=${this.required}
1409
- ?disabled=${this.disabled}
1410
- ?readonly=${this.readonly}
1411
- ?skeleton=${this.skeleton}
1412
- helper-text=${this.helperText}
1413
- ?error=${this.error}
1414
- error-text=${this.errorText}
1415
- ?warning=${this.warning}
1416
- warning-text=${this.warningText}
1417
- label=${this.label}
1418
- ?focused=${this.focused}
1419
- .host=${this}
1420
- class=${e(classes)}
1421
- >
1422
- ${this.stepper && !this.disabled
1423
- ? b `<wc-icon-button
1424
- class="stepper"
1425
- variant="text"
1426
- slot="field-start"
1427
- @click=${this.stepDown}
1428
- >
1429
- <wc-icon name="remove"></wc-icon>
1430
- </wc-icon-button>`
1431
- : A}
1432
-
1433
- <slot name="start" slot="field-start"></slot>
1434
-
1435
- <input
1436
- class="input input-element"
1437
- name=${this.name}
1438
- type="number"
1439
- placeholder=${this.placeholder}
1440
- autocomplete=${this.autocomplete}
1441
- .value=${this.value}
1442
- ?tabindex=${this.tabindex}
1443
- ?readonly=${this.readonly}
1444
- ?required=${this.required}
1445
- ?disabled=${this.disabled}
1446
- min=${this.min}
1447
- max=${this.max}
1448
- step=${this.step}
1449
- @input=${this.__handleInput}
1450
- @change=${this.__redispatchEvent}
1451
- @focus=${this.__handleFocusChange}
1452
- @blur=${this.__handleFocusChange}
1453
- ${spread(this.configAria)}
1454
- />
1455
-
1456
- <slot name="end" slot="field-end"></slot>
1457
-
1458
- ${this.stepper && !this.disabled
1459
- ? b `<wc-icon-button
1460
- class="stepper"
1461
- variant="text"
1462
- slot="field-end"
1463
- @click=${this.stepUp}
1464
- >
1465
- <wc-icon name="add"></wc-icon>
1466
- </wc-icon-button>`
1467
- : A}
1468
- </wc-field>
1469
- `;
1470
- }
1471
- }
1472
- _NumberField_id = new WeakMap();
1473
- NumberField.styles = [css_248z$8];
1474
- __decorate([
1475
- n({ type: Number })
1476
- ], NumberField.prototype, "value", void 0);
1477
- __decorate([
1478
- n({ type: String })
1479
- ], NumberField.prototype, "name", void 0);
1480
- __decorate([
1481
- n({ type: String })
1482
- ], NumberField.prototype, "placeholder", void 0);
1483
- __decorate([
1484
- n({ type: String })
1485
- ], NumberField.prototype, "label", void 0);
1486
- __decorate([
1487
- n({ type: Boolean, reflect: true })
1488
- ], NumberField.prototype, "inline", void 0);
1489
- __decorate([
1490
- n({ type: String, reflect: true })
1491
- ], NumberField.prototype, "size", void 0);
1492
- __decorate([
1493
- n({ type: Number })
1494
- ], NumberField.prototype, "max", void 0);
1495
- __decorate([
1496
- n({ type: Number })
1497
- ], NumberField.prototype, "min", void 0);
1498
- __decorate([
1499
- n({ type: Number })
1500
- ], NumberField.prototype, "step", void 0);
1501
- __decorate([
1502
- n({ type: String })
1503
- ], NumberField.prototype, "autocomplete", void 0);
1504
- __decorate([
1505
- n({ type: Object })
1506
- ], NumberField.prototype, "configAria", void 0);
1507
- __decorate([
1508
- n({ type: String, attribute: 'helper-text' })
1509
- ], NumberField.prototype, "helperText", void 0);
1510
- __decorate([
1511
- n({ type: Boolean })
1512
- ], NumberField.prototype, "error", void 0);
1513
- __decorate([
1514
- n({ type: String, attribute: 'error-text' })
1515
- ], NumberField.prototype, "errorText", void 0);
1516
- __decorate([
1517
- n({ type: Boolean })
1518
- ], NumberField.prototype, "warning", void 0);
1519
- __decorate([
1520
- n({ type: String, attribute: 'warning-text' })
1521
- ], NumberField.prototype, "warningText", void 0);
1522
- __decorate([
1523
- n({ type: Boolean })
1524
- ], NumberField.prototype, "stepper", void 0);
1525
- __decorate([
1526
- r()
1527
- ], NumberField.prototype, "focused", void 0);
1528
- __decorate([
1529
- r()
1530
- ], NumberField.prototype, "dirty", void 0);
1531
- __decorate([
1532
- e$1('.input-element')
1533
- ], NumberField.prototype, "inputElement", void 0);
1534
-
1535
- var css_248z$7 = i`* {
1536
- box-sizing: border-box;
1537
- -webkit-tap-highlight-color: transparent;
1538
- }
1539
-
1540
- .screen-reader-only {
1541
- display: none !important;
1542
- }
1543
-
1544
- [hidden] {
1545
- display: none !important;
1546
- }
1547
-
1548
- :host {
1549
- display: block;
1550
- width: 100%;
1551
- }
1552
-
1553
- .input-element {
1554
- border: none;
1555
- outline: none;
1556
- margin: 0;
1557
- padding: 0;
1558
- }
1559
-
1560
- .input-wrapper .input {
1561
- flex: 1;
1562
- width: 100%;
1563
- background: none;
1564
- cursor: inherit;
1565
- }
1566
- .input-wrapper .input::-webkit-inner-spin-button,
1567
- .input-wrapper .input::-webkit-calendar-picker-indicator {
1568
- display: none;
1569
- -webkit-appearance: none;
1570
- }`;
1571
-
1572
- /**
1573
- * @label Date Picker
1574
- * @tag wc-date-picker
1575
- * @rawTag date-picker
1576
- * @summary The Date Picker component is used to capture date user input.
1577
- * @tags input
1578
- *
1579
- * @example
1580
- * ```html
1581
- * <wc-date-picker label="Date" placeholder="Select a date"></wc-date-picker>
1582
- * ```
1583
- */
1584
- class DatePicker extends BaseInput {
1585
- constructor() {
1586
- super(...arguments);
1587
- this.value = '';
1588
- this.name = '';
1589
- this.placeholder = '';
1590
- this.label = '';
1591
- this.inline = false;
1592
- this.size = 'md';
1593
- this.autocomplete = 'off';
1594
- this.configAria = {};
1595
- this.variant = 'default';
1596
- /**
1597
- * Helper text to display below the input.
1598
- */
1599
- this.helperText = '';
1600
- this.error = false;
1601
- this.errorText = '';
1602
- this.warning = false;
1603
- this.warningText = '';
1604
- this.focused = false;
1605
- this.passwordVisible = false;
1606
- /**
1607
- * Returns true when the text field has been interacted with. Native
1608
- * validation errors only display in response to user interactions.
1609
- */
1610
- this.dirty = false;
1611
- }
1612
- connectedCallback() {
1613
- super.connectedCallback();
1614
- this.handleInitialAttributes();
1615
- }
1616
- handleInitialAttributes() {
1617
- if (this.hasAttribute('tabindex')) {
1618
- this.tabindex = this.getAttribute('tabindex') || undefined;
1619
- this.removeAttribute('tabindex');
1620
- }
1621
- Array.from(this.attributes).forEach(attr => {
1622
- if (attr.name.startsWith('aria-')) {
1623
- this.configAria[attr.name] = attr.value;
1624
- this.removeAttribute(attr.name);
1625
- }
1626
- });
1627
- }
1628
- __handleInput(event) {
1629
- this.dirty = true;
1630
- this.value = event.target.value;
1631
- }
1632
- focus() {
1633
- this.inputElement?.focus();
1634
- }
1635
- blur() {
1636
- this.inputElement?.blur();
1637
- }
1638
- __handleFocusChange() {
1639
- // When calling focus() or reportValidity() during change, it's possible
1640
- // for blur to be called after the new focus event. Rather than set
1641
- // `this.focused` to true/false on focus/blur, we always set it to whether
1642
- // or not the input itself is focused.
1643
- this.focused = this.inputElement?.matches(':focus') ?? false;
1644
- }
1645
- __redispatchEvent(event) {
1646
- redispatchEvent(this, event);
1647
- }
1648
- render() {
1649
- return b `
1650
- <wc-field
1651
- ?required=${this.required}
1652
- ?disabled=${this.disabled}
1653
- ?readonly=${this.readonly}
1654
- ?skeleton=${this.skeleton}
1655
- helper-text=${this.helperText}
1656
- ?error=${this.error}
1657
- error-text=${this.errorText}
1658
- ?warning=${this.warning}
1659
- variant=${this.variant}
1660
- ?populated=${!!this.value}
1661
- warning-text=${this.warningText}
1662
- label=${this.label}
1663
- ?focused=${this.focused}
1664
- .host=${this}
1665
- class="input-wrapper"
1666
- >
1667
- <slot name="start" slot="field-start"></slot>
1668
-
1669
- <input
1670
- class="input input-element"
1671
- name=${this.name}
1672
- type="date"
1673
- placeholder=${this.placeholder}
1674
- autocomplete=${this.autocomplete}
1675
- .value=${this.value}
1676
- ?tabindex=${this.tabindex}
1677
- ?readonly=${this.readonly}
1678
- ?required=${this.required}
1679
- ?disabled=${this.disabled}
1680
- @input=${this.__handleInput}
1681
- @change=${this.__redispatchEvent}
1682
- @focus=${this.__handleFocusChange}
1683
- @blur=${this.__handleFocusChange}
1684
- ${spread(this.configAria)}
1685
- />
1686
-
1687
- <slot name="end" slot="field-end"></slot>
1688
-
1689
- <wc-icon-button
1690
- slot="field-end"
1691
- color="secondary"
1692
- variant="text"
1693
- ?disabled=${this.disabled}
1694
- @click=${() => {
1695
- setTimeout(() => {
1696
- // @ts-ignore
1697
- this.inputElement.showPicker();
1698
- });
1699
- }}
1700
- >
1701
- <wc-icon name="calendar_today"></wc-icon>
1702
- </wc-icon-button>
1703
- </wc-field>
1704
- `;
1705
- }
1706
- }
1707
- DatePicker.styles = [css_248z$7];
1708
- __decorate([
1709
- n({ type: String })
1710
- ], DatePicker.prototype, "value", void 0);
1711
- __decorate([
1712
- n({ type: String })
1713
- ], DatePicker.prototype, "name", void 0);
1714
- __decorate([
1715
- n({ type: String })
1716
- ], DatePicker.prototype, "placeholder", void 0);
1717
- __decorate([
1718
- n({ type: String })
1719
- ], DatePicker.prototype, "label", void 0);
1720
- __decorate([
1721
- n({ type: Boolean, reflect: true })
1722
- ], DatePicker.prototype, "inline", void 0);
1723
- __decorate([
1724
- n({ type: String, reflect: true })
1725
- ], DatePicker.prototype, "size", void 0);
1726
- __decorate([
1727
- n({ type: String })
1728
- ], DatePicker.prototype, "autocomplete", void 0);
1729
- __decorate([
1730
- n({ type: Object })
1731
- ], DatePicker.prototype, "configAria", void 0);
1732
- __decorate([
1733
- n({ type: String })
1734
- ], DatePicker.prototype, "variant", void 0);
1735
- __decorate([
1736
- n({ type: String, attribute: 'helper-text' })
1737
- ], DatePicker.prototype, "helperText", void 0);
1738
- __decorate([
1739
- n({ type: Boolean })
1740
- ], DatePicker.prototype, "error", void 0);
1741
- __decorate([
1742
- n({ type: String, attribute: 'error-text' })
1743
- ], DatePicker.prototype, "errorText", void 0);
1744
- __decorate([
1745
- n({ type: Boolean })
1746
- ], DatePicker.prototype, "warning", void 0);
1747
- __decorate([
1748
- n({ type: String, attribute: 'warning-text' })
1749
- ], DatePicker.prototype, "warningText", void 0);
1750
- __decorate([
1751
- r()
1752
- ], DatePicker.prototype, "focused", void 0);
1753
- __decorate([
1754
- r()
1755
- ], DatePicker.prototype, "passwordVisible", void 0);
1756
- __decorate([
1757
- r()
1758
- ], DatePicker.prototype, "dirty", void 0);
1759
- __decorate([
1760
- e$1('.input-element')
1761
- ], DatePicker.prototype, "inputElement", void 0);
1762
-
1763
- var css_248z$6 = i`* {
1764
- box-sizing: border-box;
1765
- -webkit-tap-highlight-color: transparent;
1766
- }
1767
-
1768
- .screen-reader-only {
1769
- display: none !important;
1770
- }
1771
-
1772
- [hidden] {
1773
- display: none !important;
1774
- }
1775
-
1776
- :host {
1777
- display: block;
1778
- width: 100%;
1779
- }
1780
-
1781
- .input-element {
1782
- border: none;
1783
- outline: none;
1784
- margin: 0;
1785
- padding: 0;
1786
- }
1787
-
1788
- .input-wrapper .input {
1789
- flex: 1;
1790
- width: 100%;
1791
- background: none;
1792
- cursor: inherit;
1793
- }
1794
- .input-wrapper .input::-webkit-inner-spin-button,
1795
- .input-wrapper .input::-webkit-calendar-picker-indicator {
1796
- display: none;
1797
- -webkit-appearance: none;
1798
- }`;
1799
-
1800
- /**
1801
- * @label Time Picker
1802
- * @tag wc-time-picker
1803
- * @rawTag time-picker
1804
- * @summary The Time Picker component is used to capture time user input.
1805
- * @tags input
1806
- *
1807
- * @example
1808
- * ```html
1809
- * <wc-time-picker label="Time" placeholder="Select a time"></wc-time-picker>
1810
- * ```
1811
- */
1812
- class TimePicker extends BaseInput {
1813
- constructor() {
1814
- super(...arguments);
1815
- this.value = '';
1816
- this.name = '';
1817
- this.placeholder = '';
1818
- this.label = '';
1819
- this.inline = false;
1820
- this.size = 'md';
1821
- this.autocomplete = 'off';
1822
- this.configAria = {};
1823
- this.variant = 'default';
1824
- /**
1825
- * Helper text to display below the input.
1826
- */
1827
- this.helperText = '';
1828
- this.error = false;
1829
- this.errorText = '';
1830
- this.warning = false;
1831
- this.warningText = '';
1832
- this.focused = false;
1833
- this.passwordVisible = false;
1834
- /**
1835
- * Returns true when the text field has been interacted with. Native
1836
- * validation errors only display in response to user interactions.
1837
- */
1838
- this.dirty = false;
1839
- }
1840
- connectedCallback() {
1841
- super.connectedCallback();
1842
- this.handleInitialAttributes();
1843
- }
1844
- handleInitialAttributes() {
1845
- if (this.hasAttribute('tabindex')) {
1846
- this.tabindex = this.getAttribute('tabindex') || undefined;
1847
- this.removeAttribute('tabindex');
1848
- }
1849
- Array.from(this.attributes).forEach(attr => {
1850
- if (attr.name.startsWith('aria-')) {
1851
- this.configAria[attr.name] = attr.value;
1852
- this.removeAttribute(attr.name);
1853
- }
1854
- });
1855
- }
1856
- __handleInput(event) {
1857
- this.dirty = true;
1858
- this.value = event.target.value;
1859
- }
1860
- focus() {
1861
- this.inputElement?.focus();
1862
- }
1863
- blur() {
1864
- this.inputElement?.blur();
1865
- }
1866
- __handleFocusChange() {
1867
- // When calling focus() or reportValidity() during change, it's possible
1868
- // for blur to be called after the new focus event. Rather than set
1869
- // `this.focused` to true/false on focus/blur, we always set it to whether
1870
- // or not the input itself is focused.
1871
- this.focused = this.inputElement?.matches(':focus') ?? false;
1872
- }
1873
- __redispatchEvent(event) {
1874
- redispatchEvent(this, event);
1875
- }
1876
- render() {
1877
- return b `
1878
- <wc-field
1879
- ?required=${this.required}
1880
- ?disabled=${this.disabled}
1881
- ?readonly=${this.readonly}
1882
- ?skeleton=${this.skeleton}
1883
- helper-text=${this.helperText}
1884
- ?error=${this.error}
1885
- error-text=${this.errorText}
1886
- ?warning=${this.warning}
1887
- variant=${this.variant}
1888
- ?populated=${!!this.value}
1889
- warning-text=${this.warningText}
1890
- label=${this.label}
1891
- ?focused=${this.focused}
1892
- .host=${this}
1893
- class="input-wrapper"
1894
- >
1895
- <slot name="start" slot="field-start"></slot>
1896
-
1897
- <input
1898
- class="input input-element"
1899
- name=${this.name}
1900
- type="time"
1901
- placeholder=${this.placeholder}
1902
- autocomplete=${this.autocomplete}
1903
- .value=${this.value}
1904
- ?tabindex=${this.tabindex}
1905
- ?readonly=${this.readonly}
1906
- ?required=${this.required}
1907
- ?disabled=${this.disabled}
1908
- @input=${this.__handleInput}
1909
- @change=${this.__redispatchEvent}
1910
- @focus=${this.__handleFocusChange}
1911
- @blur=${this.__handleFocusChange}
1912
- ${spread(this.configAria)}
1913
- />
1914
-
1915
- <slot name="end" slot="field-end"></slot>
1916
-
1917
- <wc-icon-button
1918
- slot="field-end"
1919
- color="secondary"
1920
- variant="text"
1921
- ?disabled=${this.disabled}
1922
- @click=${() => {
1923
- setTimeout(() => {
1924
- // @ts-ignore
1925
- this.inputElement.showPicker();
1926
- });
1927
- }}
1928
- >
1929
- <wc-icon name="calendar_today"></wc-icon>
1930
- </wc-icon-button>
1931
- </wc-field>
1932
- `;
1933
- }
1934
- }
1935
- TimePicker.styles = [css_248z$6];
1936
- __decorate([
1937
- n({ type: String })
1938
- ], TimePicker.prototype, "value", void 0);
1939
- __decorate([
1940
- n({ type: String })
1941
- ], TimePicker.prototype, "name", void 0);
1942
- __decorate([
1943
- n({ type: String })
1944
- ], TimePicker.prototype, "placeholder", void 0);
1945
- __decorate([
1946
- n({ type: String })
1947
- ], TimePicker.prototype, "label", void 0);
1948
- __decorate([
1949
- n({ type: Boolean, reflect: true })
1950
- ], TimePicker.prototype, "inline", void 0);
1951
- __decorate([
1952
- n({ type: String, reflect: true })
1953
- ], TimePicker.prototype, "size", void 0);
1954
- __decorate([
1955
- n({ type: String })
1956
- ], TimePicker.prototype, "autocomplete", void 0);
1957
- __decorate([
1958
- n({ type: Object })
1959
- ], TimePicker.prototype, "configAria", void 0);
1960
- __decorate([
1961
- n({ type: String })
1962
- ], TimePicker.prototype, "variant", void 0);
1963
- __decorate([
1964
- n({ type: String, attribute: 'helper-text' })
1965
- ], TimePicker.prototype, "helperText", void 0);
1966
- __decorate([
1967
- n({ type: Boolean })
1968
- ], TimePicker.prototype, "error", void 0);
1969
- __decorate([
1970
- n({ type: String, attribute: 'error-text' })
1971
- ], TimePicker.prototype, "errorText", void 0);
1972
- __decorate([
1973
- n({ type: Boolean })
1974
- ], TimePicker.prototype, "warning", void 0);
1975
- __decorate([
1976
- n({ type: String, attribute: 'warning-text' })
1977
- ], TimePicker.prototype, "warningText", void 0);
1978
- __decorate([
1979
- r()
1980
- ], TimePicker.prototype, "focused", void 0);
1981
- __decorate([
1982
- r()
1983
- ], TimePicker.prototype, "passwordVisible", void 0);
1984
- __decorate([
1985
- r()
1986
- ], TimePicker.prototype, "dirty", void 0);
1987
- __decorate([
1988
- e$1('.input-element')
1989
- ], TimePicker.prototype, "inputElement", void 0);
1990
-
1991
- var css_248z$5 = i`* {
1992
- box-sizing: border-box;
1993
- -webkit-tap-highlight-color: transparent;
1994
- }
1995
-
1996
- .screen-reader-only {
1997
- display: none !important;
1998
- }
1999
-
2000
- [hidden] {
2001
- display: none !important;
2002
- }
2003
-
2004
- :host {
2005
- display: block;
2006
- width: 100%;
2007
- }
2008
-
2009
- .input-element {
2010
- border: none;
2011
- outline: none;
2012
- margin: 0;
2013
- padding: 0;
2014
- }
2015
-
2016
- .input-wrapper .input {
2017
- flex: 1;
2018
- width: 100%;
2019
- background: none;
2020
- cursor: inherit;
2021
- }
2022
-
2023
- .textarea {
2024
- height: 100%;
2025
- position: relative;
2026
- align-items: flex-start;
2027
- --field-height: auto;
2028
- --field-padding-block: var(--spacing-100);
2029
- }
2030
- .textarea .input {
2031
- height: 100%;
2032
- resize: vertical;
2033
- }`;
2034
-
2035
- /**
2036
- * @label Textarea
2037
- * @tag wc-textarea
2038
- * @rawTag textarea
2039
- * @summary The Textarea component is used to capture user input.
2040
- * @tags input
2041
- *
2042
- * @example
2043
- * ```html
2044
- * <wc-textarea label="Description" placeholder="Enter text"></wc-textarea>
2045
- * ```
2046
- */
2047
- class Textarea extends BaseInput {
2048
- constructor() {
2049
- super(...arguments);
2050
- this.value = '';
2051
- this.name = '';
2052
- this.placeholder = '';
2053
- this.label = '';
2054
- this.inline = false;
2055
- this.size = 'md';
2056
- this.autocomplete = 'off';
2057
- this.configAria = {};
2058
- this.variant = 'default';
2059
- /**
2060
- * Helper text to display below the input.
2061
- */
2062
- this.helperText = '';
2063
- this.error = false;
2064
- this.errorText = '';
2065
- this.warning = false;
2066
- this.warningText = '';
2067
- this.rows = '3';
2068
- this.focused = false;
2069
- this.passwordVisible = false;
2070
- /**
2071
- * Returns true when the text field has been interacted with. Native
2072
- * validation errors only display in response to user interactions.
2073
- */
2074
- this.dirty = false;
2075
- }
2076
- connectedCallback() {
2077
- super.connectedCallback();
2078
- this.handleInitialAttributes();
2079
- }
2080
- handleInitialAttributes() {
2081
- if (this.hasAttribute('tabindex')) {
2082
- this.tabindex = this.getAttribute('tabindex') || undefined;
2083
- this.removeAttribute('tabindex');
2084
- }
2085
- Array.from(this.attributes).forEach(attr => {
2086
- if (attr.name.startsWith('aria-')) {
2087
- this.configAria[attr.name] = attr.value;
2088
- this.removeAttribute(attr.name);
2089
- }
2090
- });
2091
- }
2092
- __handleInput(event) {
2093
- this.dirty = true;
2094
- this.value = event.target.value;
2095
- }
2096
- focus() {
2097
- this.inputElement?.focus();
2098
- }
2099
- blur() {
2100
- this.inputElement?.blur();
2101
- }
2102
- __handleFocusChange() {
2103
- // When calling focus() or reportValidity() during change, it's possible
2104
- // for blur to be called after the new focus event. Rather than set
2105
- // `this.focused` to true/false on focus/blur, we always set it to whether
2106
- // or not the input itself is focused.
2107
- this.focused = this.inputElement?.matches(':focus') ?? false;
2108
- }
2109
- __redispatchEvent(event) {
2110
- redispatchEvent(this, event);
2111
- }
2112
- render() {
2113
- return b `
2114
- <wc-field
2115
- ?required=${this.required}
2116
- ?disabled=${this.disabled}
2117
- ?readonly=${this.readonly}
2118
- ?skeleton=${this.skeleton}
2119
- helper-text=${this.helperText}
2120
- ?error=${this.error}
2121
- error-text=${this.errorText}
2122
- ?warning=${this.warning}
2123
- variant=${this.variant}
2124
- ?populated=${!!this.value}
2125
- warning-text=${this.warningText}
2126
- label=${this.label}
2127
- ?focused=${this.focused}
2128
- .host=${this}
2129
- class="input-wrapper textarea"
2130
- >
2131
- <slot name="start" slot="field-start"></slot>
2132
-
2133
- <textarea
2134
- class="input input-element"
2135
- rows=${this.rows}
2136
- name=${this.name}
2137
- placeholder=${this.placeholder}
2138
- autocomplete=${this.autocomplete}
2139
- .value=${this.value}
2140
- ?tabindex=${this.tabindex}
2141
- ?readonly=${this.readonly}
2142
- ?required=${this.required}
2143
- ?disabled=${this.disabled}
2144
- @input=${this.__handleInput}
2145
- @change=${this.__redispatchEvent}
2146
- @focus=${this.__handleFocusChange}
2147
- @blur=${this.__handleFocusChange}
2148
- ${spread(this.configAria)}
2149
- ></textarea>
2150
-
2151
- <slot name="end" slot="field-end"></slot>
2152
- </wc-field>
2153
- `;
2154
- }
2155
- }
2156
- Textarea.styles = [css_248z$5];
2157
- __decorate([
2158
- n({ type: String })
2159
- ], Textarea.prototype, "value", void 0);
2160
- __decorate([
2161
- n({ type: String })
2162
- ], Textarea.prototype, "name", void 0);
2163
- __decorate([
2164
- n({ type: String })
2165
- ], Textarea.prototype, "placeholder", void 0);
2166
- __decorate([
2167
- n({ type: String })
2168
- ], Textarea.prototype, "label", void 0);
2169
- __decorate([
2170
- n({ type: Boolean, reflect: true })
2171
- ], Textarea.prototype, "inline", void 0);
2172
- __decorate([
2173
- n({ type: String, reflect: true })
2174
- ], Textarea.prototype, "size", void 0);
2175
- __decorate([
2176
- n({ type: String })
2177
- ], Textarea.prototype, "autocomplete", void 0);
2178
- __decorate([
2179
- n({ type: Object })
2180
- ], Textarea.prototype, "configAria", void 0);
2181
- __decorate([
2182
- n({ type: String })
2183
- ], Textarea.prototype, "variant", void 0);
2184
- __decorate([
2185
- n({ type: String, attribute: 'helper-text' })
2186
- ], Textarea.prototype, "helperText", void 0);
2187
- __decorate([
2188
- n({ type: Boolean })
2189
- ], Textarea.prototype, "error", void 0);
2190
- __decorate([
2191
- n({ type: String, attribute: 'error-text' })
2192
- ], Textarea.prototype, "errorText", void 0);
2193
- __decorate([
2194
- n({ type: Boolean })
2195
- ], Textarea.prototype, "warning", void 0);
2196
- __decorate([
2197
- n({ type: String, attribute: 'warning-text' })
2198
- ], Textarea.prototype, "warningText", void 0);
2199
- __decorate([
2200
- n({ type: String })
2201
- ], Textarea.prototype, "rows", void 0);
2202
- __decorate([
2203
- r()
2204
- ], Textarea.prototype, "focused", void 0);
2205
- __decorate([
2206
- r()
2207
- ], Textarea.prototype, "passwordVisible", void 0);
2208
- __decorate([
2209
- r()
2210
- ], Textarea.prototype, "dirty", void 0);
2211
- __decorate([
2212
- e$1('.input-element')
2213
- ], Textarea.prototype, "inputElement", void 0);
2214
-
2215
- var css_248z$4 = i`* {
2216
- box-sizing: border-box;
2217
- -webkit-tap-highlight-color: transparent;
2218
- }
2219
-
2220
- .screen-reader-only {
2221
- display: none !important;
2222
- }
2223
-
2224
- [hidden] {
2225
- display: none !important;
2226
- }
2227
-
2228
- :host {
2229
- display: inline-block;
2230
- --switch-track-color: var(--color-primary);
2231
- --switch-track-off-color: var(--color-surface-container-highest);
2232
- }
2233
-
2234
- .switch {
2235
- position: relative;
2236
- display: flex;
2237
- align-items: center;
2238
- }
2239
- .switch .input-native {
2240
- position: absolute;
2241
- width: 1px;
2242
- height: 1px;
2243
- padding: 0;
2244
- margin: -1px;
2245
- overflow: hidden;
2246
- clip: rect(0, 0, 0, 0);
2247
- border: 0;
2248
- }
2249
- .switch .label {
2250
- font-family: var(--typography-label-medium-font-family) !important;
2251
- font-size: var(--typography-label-medium-font-size) !important;
2252
- font-weight: var(--typography-label-medium-font-weight) !important;
2253
- line-height: var(--typography-label-medium-line-height) !important;
2254
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
2255
- }
2256
- .switch.has-content {
2257
- gap: var(--spacing-150);
2258
- }
2259
- .switch .track {
2260
- position: relative;
2261
- background: var(--switch-track-off-color);
2262
- border: 2px solid var(--color-outline);
2263
- border-radius: var(--shape-corner-full);
2264
- cursor: pointer;
2265
- display: flex;
2266
- transition: background-color var(--duration-short2) var(--easing-standard);
2267
- align-items: center;
2268
- width: var(--_container-width);
2269
- height: var(--_container-height);
2270
- padding: 0 4px;
2271
- }
2272
- .switch .track .handle {
2273
- display: flex;
2274
- align-items: center;
2275
- justify-content: center;
2276
- border-radius: var(--shape-corner-full);
2277
- transition: all var(--duration-short2) var(--easing-standard);
2278
- background: white;
2279
- height: var(--switch-handle-radius);
2280
- width: var(--switch-handle-radius);
2281
- background: var(--switch-handle-color);
2282
- }
2283
- .switch .track .handle .icon {
2284
- --icon-size: .75rem;
2285
- --icon-color: var(--switch-track-off-color);
2286
- }
2287
- .switch.has-focus:not(.active) .track {
2288
- outline: 3px solid var(--color-primary);
2289
- outline-offset: 2px;
2290
- border-color: var(--color-white);
2291
- }
2292
- .switch.has-focus:not(.active):not(.state-checked) .handle {
2293
- border-color: var(--icon-01);
2294
- }
2295
-
2296
- .switch.state-checked .track {
2297
- background: var(--switch-track-color);
2298
- border-color: transparent;
2299
- }
2300
- .switch.state-checked .handle {
2301
- margin-inline-start: calc(100% - var(--switch-handle-radius));
2302
- }
2303
- .switch.state-checked .handle .icon {
2304
- --icon-size: 1rem;
2305
- --icon-color: var(--switch-track-color);
2306
- }
2307
- .switch.state-checked.active .track {
2308
- border-color: var(--switch-track-color);
2309
- }
2310
- .switch.state-checked.has-focus:not(.active) .track {
2311
- outline: 3px solid var(--color-primary);
2312
- outline-offset: 2px;
2313
- border-color: var(--color-white);
2314
- }
2315
-
2316
- .switch {
2317
- --_container-width: 3.25rem;
2318
- --_container-height: 2rem;
2319
- --switch-handle-radius: 16px;
2320
- --switch-handle-color: var(--color-outline);
2321
- }
2322
- .switch.state-checked {
2323
- --switch-handle-radius: 22px;
2324
- --switch-handle-color: var(--color-surface-container-lowest);
2325
- }
2326
-
2327
- .switch.readonly {
2328
- cursor: default;
2329
- }
2330
- .switch.readonly .track {
2331
- border-color: var(--color-outline);
2332
- background: var(--switch-track-off-color);
2333
- opacity: 0.38;
2334
- }
2335
- .switch.readonly .track .handle {
2336
- background: var(--color-outline) !important;
2337
- }
2338
-
2339
- .switch.disabled {
2340
- cursor: not-allowed;
2341
- }
2342
- .switch.disabled .track {
2343
- border-color: var(--color-on-surface);
2344
- background: var(--switch-track-off-color);
2345
- opacity: 0.38;
2346
- }
2347
- .switch.disabled .track .handle {
2348
- background: var(--color-on-surface) !important;
2349
- }`;
2350
-
2351
- /**
2352
- * @label Switch
2353
- * @tag wc-switch
2354
- * @rawTag switch
2355
- *
2356
- * @summary Captures boolean input with an on/off switch interaction.
2357
- * @overview
2358
- * <p>Toggles are used to enable or disable a single option. They provide immediate feedback about whether an option is active or inactive.</p>
2359
- *
2360
- * @cssprop --switch-track-color: Color of the switch track when checked.
2361
- * @cssprop --switch-track-off-color: Color of the switch track when unchecked.
2362
- * @cssprop --switch-width: Width of the switch track.
2363
- * @cssprop --switch-height: Height of the switch track.
2364
- * @cssprop --switch-handle-radius: Size of the switch handle.
2365
- * @cssprop --switch-handle-color: Color of the switch handle.
2366
- *
2367
- * @fires {CustomEvent} change - Dispatched when the switch value changes.
2368
- * @fires {CustomEvent} blur - Dispatched when the switch loses focus.
2369
- * @fires {CustomEvent} focus - Dispatched when the switch receives focus.
2370
- *
2371
- * @example
2372
- * ```html
2373
- * <wc-switch value="true"></wc-switch>
2374
- * ```
2375
- * @tags input, form
2376
- */
2377
- class Switch extends BaseInput {
2378
- constructor() {
2379
- super(...arguments);
2380
- this.value = false;
2381
- /**
2382
- * The input field name.
2383
- */
2384
- this.name = '';
2385
- /**
2386
- * The switch label.
2387
- */
2388
- this.label = '';
2389
- /**
2390
- * If true, the toggle has rounded corners. Defaults to `true`.
2391
- */
2392
- this.rounded = true;
2393
- /**
2394
- * If true, required icon is shown. Defaults to `false`.
2395
- */
2396
- this.required = false;
2397
- /**
2398
- * If true, the toggle is readonly. Defaults to `false`.
2399
- */
2400
- this.readonly = false;
2401
- /**
2402
- * If true, the user cannot interact with the toggle. Defaults to `false`.
2403
- */
2404
- this.disabled = false;
2405
- this.withIcon = false;
2406
- /**
2407
- * Configuration object for aria attributes.
2408
- */
2409
- this.configAria = {};
2410
- this.hasFocus = false;
2411
- this.isActive = false;
2412
- this.slotHasContent = false;
2413
- this.windowMouseUp = () => {
2414
- if (this.isActive) {
2415
- this.isActive = false;
2416
- }
2417
- };
2418
- this.windowKeyUp = (evt) => {
2419
- if (this.isActive && evt.key === ' ') {
2420
- this.isActive = false;
2421
- }
2422
- };
2423
- this.mouseDownHandler = () => {
2424
- this.isActive = true;
2425
- };
2426
- this.keyDownHandler = (evt) => {
2427
- if (evt.key === ' ') {
2428
- evt.preventDefault();
2429
- this.isActive = true;
2430
- this.clickHandler(evt);
2431
- }
2432
- };
2433
- this.clickHandler = (ev) => {
2434
- if (!this.disabled && !this.readonly) {
2435
- this.value = !this.value;
2436
- this.dispatchEvent(new CustomEvent('change', {
2437
- detail: { value: this.value, originalEvent: ev },
2438
- bubbles: true,
2439
- composed: true,
2440
- }));
2441
- this.trackElement?.focus();
2442
- }
2443
- };
2444
- this.blurHandler = (ev) => {
2445
- this.hasFocus = false;
2446
- this.dispatchEvent(new CustomEvent('blur', {
2447
- detail: ev,
2448
- bubbles: true,
2449
- composed: true,
2450
- }));
2451
- };
2452
- this.focusHandler = (ev) => {
2453
- this.hasFocus = true;
2454
- this.dispatchEvent(new CustomEvent('focus', {
2455
- detail: ev,
2456
- bubbles: true,
2457
- composed: true,
2458
- }));
2459
- };
2460
- this.handleKeyUp = (evt) => {
2461
- if (evt.key === 'Enter') {
2462
- this.clickHandler(evt);
2463
- }
2464
- };
2465
- }
2466
- connectedCallback() {
2467
- super.connectedCallback();
2468
- this.handleInitialAttributes();
2469
- window.addEventListener('mouseup', this.windowMouseUp);
2470
- window.addEventListener('keyup', this.windowKeyUp);
2471
- }
2472
- disconnectedCallback() {
2473
- super.disconnectedCallback();
2474
- window.removeEventListener('mouseup', this.windowMouseUp);
2475
- window.removeEventListener('keyup', this.windowKeyUp);
2476
- }
2477
- firstUpdated() {
2478
- this.slotHasContent = this.hasChildNodes();
2479
- }
2480
- handleInitialAttributes() {
2481
- if (this.hasAttribute('tabindex')) {
2482
- this.tabindex = this.getAttribute('tabindex') || undefined;
2483
- this.removeAttribute('tabindex');
2484
- }
2485
- Array.from(this.attributes).forEach(attr => {
2486
- if (attr.name.startsWith('aria-')) {
2487
- this.configAria[attr.name] = attr.value;
2488
- this.removeAttribute(attr.name);
2489
- }
2490
- });
2491
- }
2492
- /**
2493
- * Sets focus on the toggle.
2494
- */
2495
- focus() {
2496
- this.trackElement?.focus();
2497
- }
2498
- /**
2499
- * Removes focus from the toggle.
2500
- */
2501
- blur() {
2502
- this.trackElement?.blur();
2503
- }
2504
- __renderIcon() {
2505
- if (this.withIcon) {
2506
- if (this.value)
2507
- return b `<wc-icon name="check" class="icon"></wc-icon>`;
2508
- return b `<wc-icon name="close" class="icon"></wc-icon>`;
2509
- }
2510
- return A;
2511
- }
2512
- render() {
2513
- const cssClasses = {
2514
- switch: true,
2515
- 'state-checked': this.value,
2516
- 'has-focus': this.hasFocus,
2517
- active: this.isActive,
2518
- disabled: this.disabled,
2519
- readonly: this.readonly,
2520
- required: this.required,
2521
- rounded: this.rounded,
2522
- 'has-content': this.slotHasContent,
2523
- };
2524
- return b `
2525
- <label class=${e(cssClasses)}>
2526
- <div
2527
- class="track"
2528
- tabindex=${this.tabindex || 0}
2529
- @keyup=${this.handleKeyUp}
2530
- @mousedown=${this.mouseDownHandler}
2531
- @keydown=${this.keyDownHandler}
2532
- @blur=${this.blurHandler}
2533
- @focus=${this.focusHandler}
2534
- role="checkbox"
2535
- aria-disabled=${this.disabled}
2536
- aria-required=${this.required}
2537
- aria-checked=${this.value}
2538
- ${spread(this.configAria)}
2539
- >
2540
- <div class="handle">${this.__renderIcon()}</div>
2541
- </div>
2542
-
2543
- <input
2544
- type="checkbox"
2545
- class="input-native"
2546
- name=${this.name}
2547
- .checked=${this.value}
2548
- aria-hidden="true"
2549
- ?required=${this.required}
2550
- tabindex="-1"
2551
- @click=${this.clickHandler}
2552
- />
2553
-
2554
- ${this.label
2555
- ? b `<div class="label">${this.label}</div>`
2556
- : b `<div class="slot-container"><slot></slot></div>`}
2557
- </label>
2558
- `;
2559
- }
2560
- }
2561
- Switch.styles = [css_248z$4];
2562
- __decorate([
2563
- n({ type: Boolean })
2564
- ], Switch.prototype, "value", void 0);
2565
- __decorate([
2566
- n({ type: String })
2567
- ], Switch.prototype, "name", void 0);
2568
- __decorate([
2569
- n({ type: String })
2570
- ], Switch.prototype, "label", void 0);
2571
- __decorate([
2572
- n({ type: Boolean })
2573
- ], Switch.prototype, "rounded", void 0);
2574
- __decorate([
2575
- n({ type: Boolean, reflect: true })
2576
- ], Switch.prototype, "required", void 0);
2577
- __decorate([
2578
- n({ type: Boolean, reflect: true })
2579
- ], Switch.prototype, "readonly", void 0);
2580
- __decorate([
2581
- n({ type: Boolean, reflect: true })
2582
- ], Switch.prototype, "disabled", void 0);
2583
- __decorate([
2584
- n({ type: Boolean, reflect: true, attribute: 'with-icon' })
2585
- ], Switch.prototype, "withIcon", void 0);
2586
- __decorate([
2587
- n({ type: Object })
2588
- ], Switch.prototype, "configAria", void 0);
2589
- __decorate([
2590
- r()
2591
- ], Switch.prototype, "hasFocus", void 0);
2592
- __decorate([
2593
- r()
2594
- ], Switch.prototype, "isActive", void 0);
2595
- __decorate([
2596
- r()
2597
- ], Switch.prototype, "slotHasContent", void 0);
2598
- __decorate([
2599
- e$1('.track')
2600
- ], Switch.prototype, "trackElement", void 0);
2601
- __decorate([
2602
- e$1('.input-native')
2603
- ], Switch.prototype, "nativeElement", void 0);
2604
-
2605
- var css_248z$3 = i`* {
2606
- box-sizing: border-box;
2607
- -webkit-tap-highlight-color: transparent;
2608
- }
2609
-
2610
- .screen-reader-only {
2611
- display: none !important;
2612
- }
2613
-
2614
- [hidden] {
2615
- display: none !important;
2616
- }
2617
-
2618
- :host {
2619
- display: block;
2620
- --sidebar-menu-item-height: 3rem;
2621
- --sidebar-menu-item-icon-size: 1.25rem;
2622
- --sidebar-menu-item-border-radius: var(--global-shape-corner-full, 9999px);
2623
- --sidebar-menu-item-label-color: var(--color-on-surface);
2624
- --sidebar-menu-item-icon-color: var(--color-on-surface-variant);
2625
- --sidebar-menu-item-selected-background: var(--color-secondary-container);
2626
- --sidebar-menu-item-selected-label-color: var(--color-on-secondary-container);
2627
- --sidebar-menu-item-focus-ring-color: var(--color-primary);
2628
- --sidebar-menu-item-transition-duration: 200ms;
2629
- --sidebar-menu-item-transition-easing: cubic-bezier(0.4, 0, 0.2, 1);
2630
- }
2631
-
2632
- .sidebar-menu-item {
2633
- position: relative;
2634
- display: flex;
2635
- align-items: center;
2636
- min-height: var(--sidebar-menu-item-height);
2637
- border-radius: var(--sidebar-menu-item-border-radius);
2638
- color: var(--_label-color);
2639
- cursor: pointer;
2640
- user-select: none;
2641
- text-decoration: none;
2642
- outline: none;
2643
- --_container-color: transparent;
2644
- --_container-opacity: 1;
2645
- --_label-color: var(--sidebar-menu-item-label-color);
2646
- font-family: var(--typography-label-large-font-family) !important;
2647
- font-size: var(--typography-label-large-font-size) !important;
2648
- font-weight: var(--typography-label-large-font-weight) !important;
2649
- line-height: var(--typography-label-large-line-height) !important;
2650
- letter-spacing: var(--typography-label-large-letter-spacing) !important;
2651
- }
2652
- .sidebar-menu-item.selected {
2653
- --_container-color: var(--sidebar-menu-item-selected-background);
2654
- --_label-color: var(--sidebar-menu-item-selected-label-color);
2655
- font-weight: var(--font-weight-bold) !important;
2656
- }
2657
- .sidebar-menu-item.disabled {
2658
- cursor: not-allowed;
2659
- opacity: 0.6;
2660
- }
2661
- .sidebar-menu-item.disabled .ripple {
2662
- display: none;
2663
- }
2664
-
2665
- .sidebar-menu-item-content {
2666
- display: flex;
2667
- align-items: center;
2668
- gap: 0.25rem;
2669
- flex: 1;
2670
- min-height: var(--sidebar-menu-item-height);
2671
- padding-inline: var(--sidebar-menu-item-content-padding, 0.75rem);
2672
- color: inherit;
2673
- z-index: 1;
2674
- overflow: hidden;
2675
- }
2676
-
2677
- .background {
2678
- position: absolute;
2679
- inset: 0;
2680
- background-color: var(--_container-color);
2681
- opacity: var(--_container-opacity);
2682
- border-radius: inherit;
2683
- pointer-events: none;
2684
- }
2685
-
2686
- .focus-ring {
2687
- z-index: 2;
2688
- --focus-ring-color: var(--sidebar-menu-item-focus-ring-color);
2689
- --focus-ring-container-shape-start-start: var(
2690
- --sidebar-menu-item-border-radius
2691
- );
2692
- --focus-ring-container-shape-start-end: var(
2693
- --sidebar-menu-item-border-radius
2694
- );
2695
- --focus-ring-container-shape-end-start: var(
2696
- --sidebar-menu-item-border-radius
2697
- );
2698
- --focus-ring-container-shape-end-end: var(--sidebar-menu-item-border-radius);
2699
- }
2700
-
2701
- .ripple {
2702
- --ripple-pressed-color: var(--color-on-surface);
2703
- border-radius: inherit;
2704
- }
2705
-
2706
- .sidebar-menu-item.selected .ripple {
2707
- --ripple-pressed-color: var(--sidebar-menu-item-selected-color);
2708
- }
2709
-
2710
- .sidebar-menu-item-label {
2711
- flex: 1;
2712
- overflow: hidden;
2713
- text-overflow: ellipsis;
2714
- white-space: nowrap;
2715
- }`;
2716
-
2717
- /**
2718
- * @label Sidebar Menu Item
2719
- * @tag wc-sidebar-menu-item
2720
- * @rawTag sidebar-menu-item
2721
- * @summary A sidebar menu item represents a selectable leaf item in the sidebar navigation tree.
2722
- *
2723
- * @example
2724
- * ```html
2725
- * <wc-sidebar-menu>
2726
- * <wc-sidebar-sub-menu label="Parent" expanded>
2727
- * <wc-sidebar-menu-item label="Child"></wc-sidebar-menu-item>
2728
- * </wc-sidebar-sub-menu>
2729
- * </wc-sidebar-menu>
2730
- * ```
2731
- * @tags navigation
2732
- */
2733
- class SidebarMenuItem extends i$1 {
2734
- constructor() {
2735
- super(...arguments);
2736
- /**
2737
- * The value used to identify this item when selected.
2738
- */
2739
- this.value = '';
2740
- /**
2741
- * The display label for this item.
2742
- */
2743
- this.label = '';
2744
- /**
2745
- * Optional icon name to display before the label.
2746
- */
2747
- this.icon = '';
2748
- /**
2749
- * Optional hyperlink to navigate to on click.
2750
- */
2751
- this.href = '';
2752
- /**
2753
- * Sets or retrieves the window or frame at which to target content.
2754
- */
2755
- this.target = '_self';
2756
- /**
2757
- * If true, the user cannot interact with the item.
2758
- */
2759
- this.disabled = false;
2760
- /**
2761
- * Whether the item is currently selected.
2762
- */
2763
- this.selected = false;
2764
- /**
2765
- * The nesting depth level (set automatically by the parent sidebar-menu).
2766
- */
2767
- this.level = 0;
2768
- this._onClick = () => {
2769
- if (this.disabled)
2770
- return;
2771
- this.dispatchEvent(new CustomEvent('sidebar-menu-item:click', {
2772
- bubbles: true,
2773
- composed: true,
2774
- detail: { value: this.value, label: this.label },
2775
- }));
2776
- };
2777
- }
2778
- focus() {
2779
- this._nativeElement?.focus();
2780
- }
2781
- blur() {
2782
- this._nativeElement?.blur();
2783
- }
2784
- render() {
2785
- const classes = e({
2786
- 'sidebar-menu-item': true,
2787
- disabled: this.disabled,
2788
- selected: this.selected,
2789
- });
2790
- const content = b `
2791
- <wc-focus-ring class="focus-ring" for="item"></wc-focus-ring>
2792
- <div class="background"></div>
2793
- <wc-ripple class="ripple"></wc-ripple>
2794
- <div class="sidebar-menu-item-content">
2795
- ${this.icon ? b `<wc-icon name="${this.icon}"></wc-icon>` : ''}
2796
- <span class="sidebar-menu-item-label">${this.label}</span>
2797
- </div>
2798
- `;
2799
- if (this.href) {
2800
- return b `
2801
- <a
2802
- id="item"
2803
- href="${this.href}"
2804
- target="${this.target}"
2805
- class="${classes}"
2806
- ?aria-disabled=${this.disabled}
2807
- tabindex="${this.disabled ? -1 : 0}"
2808
- @click="${this._onClick}"
2809
- >
2810
- ${content}
2811
- </a>
2812
- `;
2813
- }
2814
- return b `
2815
- <div
2816
- id="item"
2817
- class="${classes}"
2818
- role="treeitem"
2819
- aria-label="${this.label}"
2820
- aria-selected="${String(this.selected)}"
2821
- ?aria-disabled=${this.disabled}
2822
- ?disabled=${this.disabled}
2823
- tabindex="${this.disabled ? -1 : 0}"
2824
- @click="${this._onClick}"
2825
- @keydown="${(e) => {
2826
- if (e.key === 'Enter' || e.key === ' ') {
2827
- e.preventDefault();
2828
- this._onClick();
2829
- }
2830
- }}"
2831
- >
2832
- ${content}
2833
- </div>
2834
- `;
2835
- }
2836
- }
2837
- SidebarMenuItem.styles = [css_248z$3];
2838
- __decorate([
2839
- n({ type: String, reflect: true })
2840
- ], SidebarMenuItem.prototype, "value", void 0);
2841
- __decorate([
2842
- n({ type: String, reflect: true })
2843
- ], SidebarMenuItem.prototype, "label", void 0);
2844
- __decorate([
2845
- n({ type: String, reflect: true })
2846
- ], SidebarMenuItem.prototype, "icon", void 0);
2847
- __decorate([
2848
- n({ type: String, reflect: true })
2849
- ], SidebarMenuItem.prototype, "href", void 0);
2850
- __decorate([
2851
- n({ type: String, reflect: true })
2852
- ], SidebarMenuItem.prototype, "target", void 0);
2853
- __decorate([
2854
- n({ type: Boolean, reflect: true })
2855
- ], SidebarMenuItem.prototype, "disabled", void 0);
2856
- __decorate([
2857
- n({ type: Boolean, reflect: true })
2858
- ], SidebarMenuItem.prototype, "selected", void 0);
2859
- __decorate([
2860
- n({ type: Number, reflect: true })
2861
- ], SidebarMenuItem.prototype, "level", void 0);
2862
- __decorate([
2863
- e$1('.sidebar-menu-item-content')
2864
- ], SidebarMenuItem.prototype, "_nativeElement", void 0);
2865
-
2866
- var css_248z$2 = i`* {
2867
- box-sizing: border-box;
2868
- -webkit-tap-highlight-color: transparent;
2869
- }
2870
-
2871
- .screen-reader-only {
2872
- display: none !important;
2873
- }
2874
-
2875
- [hidden] {
2876
- display: none !important;
2877
- }
2878
-
2879
- :host {
2880
- display: block;
2881
- --sidebar-menu-item-height: 3rem;
2882
- --sidebar-menu-item-border-radius: var(--global-shape-corner-full, 9999px);
2883
- --sidebar-menu-item-label-color: var(--color-on-surface);
2884
- --sidebar-menu-item-icon-color: var(--color-on-surface-variant);
2885
- --sidebar-menu-item-selected-background: var(--color-secondary-container);
2886
- --sidebar-menu-item-selected-color: var(--color-on-secondary-container);
2887
- --sidebar-menu-item-focus-ring-color: var(--color-primary);
2888
- }
2889
-
2890
- .sidebar-sub-menu {
2891
- display: block;
2892
- }
2893
-
2894
- .sidebar-sub-menu-inner {
2895
- position: relative;
2896
- display: flex;
2897
- align-items: center;
2898
- gap: 0.5rem;
2899
- min-height: var(--sidebar-menu-item-height);
2900
- cursor: pointer;
2901
- border-radius: var(--sidebar-menu-item-border-radius);
2902
- outline: none;
2903
- padding-inline-end: 0.75rem;
2904
- color: var(--_label-color);
2905
- --_container-color: transparent;
2906
- --_container-opacity: 1;
2907
- --_label-color: var(--sidebar-menu-item-label-color);
2908
- font-family: var(--typography-label-large-font-family) !important;
2909
- font-size: var(--typography-label-large-font-size) !important;
2910
- font-weight: var(--typography-label-large-font-weight) !important;
2911
- line-height: var(--typography-label-large-line-height) !important;
2912
- letter-spacing: var(--typography-label-large-letter-spacing) !important;
2913
- }
2914
- .sidebar-sub-menu-inner.selected {
2915
- --_container-color: var(--sidebar-menu-item-selected-background);
2916
- --_label-color: var(--sidebar-menu-item-selected-color);
2917
- }
2918
- .sidebar-sub-menu-inner.disabled {
2919
- cursor: not-allowed;
2920
- opacity: 0.6;
2921
- }
2922
- .sidebar-sub-menu-inner.disabled .ripple {
2923
- display: none;
2924
- }
2925
-
2926
- .sidebar-sub-menu-content {
2927
- display: flex;
2928
- align-items: center;
2929
- gap: 0.25rem;
2930
- flex: 1;
2931
- min-height: var(--sidebar-menu-item-height);
2932
- color: inherit;
2933
- user-select: none;
2934
- text-decoration: none;
2935
- outline: none;
2936
- padding-inline: 0.75rem;
2937
- z-index: 1;
2938
- }
2939
-
2940
- .background {
2941
- position: absolute;
2942
- inset: 0;
2943
- background-color: var(--_container-color);
2944
- opacity: var(--_container-opacity);
2945
- border-radius: inherit;
2946
- pointer-events: none;
2947
- }
2948
-
2949
- .focus-ring {
2950
- z-index: 2;
2951
- --focus-ring-color: var(--sidebar-menu-item-focus-ring-color);
2952
- --focus-ring-container-shape-start-start: var(--sidebar-menu-item-border-radius);
2953
- --focus-ring-container-shape-start-end: var(--sidebar-menu-item-border-radius);
2954
- --focus-ring-container-shape-end-start: var(--sidebar-menu-item-border-radius);
2955
- --focus-ring-container-shape-end-end: var(--sidebar-menu-item-border-radius);
2956
- }
2957
-
2958
- .ripple {
2959
- --ripple-pressed-color: var(--color-on-surface);
2960
- border-radius: inherit;
2961
- }
2962
-
2963
- .sidebar-sub-menu-inner.selected .ripple {
2964
- --ripple-pressed-color: var(--sidebar-menu-item-selected-color);
2965
- }
2966
-
2967
- .sidebar-sub-menu-label {
2968
- flex: 1;
2969
- overflow: hidden;
2970
- text-overflow: ellipsis;
2971
- white-space: nowrap;
2972
- }
2973
-
2974
- .expand-icon {
2975
- display: flex;
2976
- align-items: center;
2977
- justify-content: center;
2978
- color: var(--sidebar-menu-item-icon-color);
2979
- flex-shrink: 0;
2980
- width: var(--sidebar-menu-item-height);
2981
- height: var(--sidebar-menu-item-height);
2982
- transition: transform var(--duration-medium1) var(--easing-standard);
2983
- }
2984
-
2985
- :host([expanded]) .expand-icon {
2986
- transform: rotate(180deg);
2987
- }
2988
-
2989
- .sidebar-sub-menu-children {
2990
- display: block;
2991
- overflow: hidden;
2992
- margin-left: var(--spacing-200);
2993
- max-height: 9999px;
2994
- opacity: 1;
2995
- transition: max-height var(--duration-medium1) var(--easing-standard), opacity var(--duration-medium1) var(--easing-standard);
2996
- }
2997
-
2998
- .sidebar-sub-menu-children.hidden {
2999
- max-height: 0;
3000
- opacity: 0;
3001
- }`;
3002
-
3003
- /**
3004
- * @label Sidebar Sub Menu
3005
- * @tag wc-sidebar-sub-menu
3006
- * @rawTag sidebar-sub-menu
3007
- * @summary A sidebar sub menu groups sidebar menu items and handles expand/collapse behavior.
3008
- *
3009
- * @example
3010
- * ```html
3011
- * <wc-sidebar-sub-menu label="Parent" expanded>
3012
- * <wc-sidebar-menu-item label="Child"></wc-sidebar-menu-item>
3013
- * </wc-sidebar-sub-menu>
3014
- * ```
3015
- * @tags navigation
3016
- */
3017
- class SidebarSubMenu extends i$1 {
3018
- constructor() {
3019
- super(...arguments);
3020
- this.value = '';
3021
- this.label = '';
3022
- this.icon = '';
3023
- this.disabled = false;
3024
- this.selected = false;
3025
- this.expanded = false;
3026
- this.level = 0;
3027
- this._updateChildLevels = () => {
3028
- this._getChildNodes().forEach(child => {
3029
- if ('level' in child) {
3030
- // eslint-disable-next-line no-param-reassign
3031
- child.level = this.level + 1;
3032
- }
3033
- });
3034
- };
3035
- this._onClick = () => {
3036
- if (this.disabled)
3037
- return;
3038
- if (this._getChildNodes().length > 0) {
3039
- this.expanded = !this.expanded;
3040
- }
3041
- this.dispatchEvent(new CustomEvent('sidebar-menu-item:click', {
3042
- bubbles: true,
3043
- composed: true,
3044
- detail: { value: this.value, label: this.label },
3045
- }));
3046
- };
3047
- }
3048
- focus() {
3049
- this._nativeElement?.focus();
3050
- }
3051
- blur() {
3052
- this._nativeElement?.blur();
3053
- }
3054
- connectedCallback() {
3055
- super.connectedCallback();
3056
- this._updateChildLevels();
3057
- }
3058
- updated(changedProps) {
3059
- super.updated(changedProps);
3060
- if (changedProps.has('expanded')) {
3061
- this.setAttribute('aria-expanded', String(this.expanded));
3062
- if (this.expanded) {
3063
- this.setAttribute('data-expanded', '');
3064
- }
3065
- else {
3066
- this.removeAttribute('data-expanded');
3067
- }
3068
- }
3069
- }
3070
- _getChildNodes() {
3071
- return Array.from(this.children).filter(el => {
3072
- const tag = el.tagName.toLowerCase();
3073
- return tag === 'wc-sidebar-menu-item' || tag === 'wc-sidebar-sub-menu';
3074
- });
3075
- }
3076
- render() {
3077
- const hasChildren = this._getChildNodes().length > 0;
3078
- const wrapperClasses = e({
3079
- 'sidebar-sub-menu': true,
3080
- });
3081
- const innerClasses = e({
3082
- 'sidebar-sub-menu-inner': true,
3083
- disabled: this.disabled,
3084
- selected: this.selected,
3085
- });
3086
- const inlineStyles = o({
3087
- paddingLeft: `calc(var(--sidebar-menu-item-height, 2.5rem) * ${this.level})`,
3088
- });
3089
- return b `
3090
- <div class="${wrapperClasses}" style="${inlineStyles}">
3091
- <div
3092
- id="item"
3093
- class="${innerClasses}"
3094
- role="treeitem"
3095
- aria-label="${this.label}"
3096
- aria-selected="${String(this.selected)}"
3097
- aria-disabled="${this.disabled}"
3098
- aria-expanded="${this.expanded}"
3099
- @click="${this._onClick}"
3100
- @keydown="${(e) => {
3101
- if (e.key === 'Enter' || e.key === ' ') {
3102
- e.preventDefault();
3103
- this._onClick();
3104
- }
3105
- }}"
3106
- tabindex="${this.disabled ? -1 : 0}"
3107
- >
3108
- <wc-focus-ring class="focus-ring" for="item"></wc-focus-ring>
3109
- <div class="background"></div>
3110
- <wc-ripple class="ripple"></wc-ripple>
3111
- <div class="sidebar-sub-menu-content">
3112
- ${this.icon ? b `<wc-icon name="${this.icon}"></wc-icon>` : ''}
3113
- <span class="sidebar-sub-menu-label">${this.label}</span>
3114
- </div>
3115
- ${hasChildren
3116
- ? b `
3117
- <wc-icon class="expand-icon" name="arrow_drop_down" aria-hidden="true"></wc-icon>
3118
- `
3119
- : ''}
3120
- </div>
3121
- <div class="sidebar-sub-menu-children ${(!hasChildren || !this.expanded) ? 'hidden' : ''}">
3122
- <slot @slotchange="${this._updateChildLevels}"></slot>
3123
- </div>
3124
- </div>
3125
- `;
3126
- }
3127
- }
3128
- SidebarSubMenu.styles = [css_248z$2];
3129
- __decorate([
3130
- n({ type: String, reflect: true })
3131
- ], SidebarSubMenu.prototype, "value", void 0);
3132
- __decorate([
3133
- n({ type: String, reflect: true })
3134
- ], SidebarSubMenu.prototype, "label", void 0);
3135
- __decorate([
3136
- n({ type: String, reflect: true })
3137
- ], SidebarSubMenu.prototype, "icon", void 0);
3138
- __decorate([
3139
- n({ type: Boolean, reflect: true })
3140
- ], SidebarSubMenu.prototype, "disabled", void 0);
3141
- __decorate([
3142
- n({ type: Boolean, reflect: true })
3143
- ], SidebarSubMenu.prototype, "selected", void 0);
3144
- __decorate([
3145
- n({ type: Boolean, reflect: true })
3146
- ], SidebarSubMenu.prototype, "expanded", void 0);
3147
- __decorate([
3148
- n({ type: Number, reflect: true })
3149
- ], SidebarSubMenu.prototype, "level", void 0);
3150
- __decorate([
3151
- e$1('.sidebar-sub-menu-inner')
3152
- ], SidebarSubMenu.prototype, "_nativeElement", void 0);
3153
-
3154
- var css_248z$1 = i`* {
3155
- box-sizing: border-box;
3156
- -webkit-tap-highlight-color: transparent;
3157
- }
3158
-
3159
- .screen-reader-only {
3160
- display: none !important;
3161
- }
3162
-
3163
- [hidden] {
3164
- display: none !important;
3165
- }
3166
-
3167
- :host {
3168
- display: block;
3169
- }
3170
-
3171
- .sidebar-menu {
3172
- display: block;
3173
- padding: var(--spacing-100, 0.5rem) 0;
3174
- }`;
3175
-
3176
- /**
3177
- * @label Sidebar Menu
3178
- * @tag wc-sidebar-menu
3179
- * @rawTag sidebar-menu
3180
- * @summary A sidebar menu is a hierarchical structure that provides nested levels of navigation. It supports keyboard navigation, single/multi select, and expandable items.
3181
- *
3182
- * @example
3183
- * ```html
3184
- * <wc-sidebar-menu>
3185
- * <wc-sidebar-sub-menu label="Parent" expanded>
3186
- * <wc-sidebar-menu-item label="Child 1"></wc-sidebar-menu-item>
3187
- * <wc-sidebar-menu-item label="Child 2"></wc-sidebar-menu-item>
3188
- * </wc-sidebar-sub-menu>
3189
- * </wc-sidebar-menu>
3190
- * ```
3191
- * @tags navigation
3192
- */
3193
- class SidebarMenu extends i$1 {
3194
- constructor() {
3195
- super(...arguments);
3196
- /**
3197
- * The value of the currently selected item.
3198
- */
3199
- this.selectedItem = '';
3200
- this._onItemClick = (event) => {
3201
- const item = event.target;
3202
- if (item.disabled)
3203
- return;
3204
- const value = event.detail?.value ?? item.value ?? item.label;
3205
- this.selectedItem = value;
3206
- // Update selected state on all items
3207
- this._updateSelectedState(value);
3208
- this.dispatchEvent(new CustomEvent('sidebar-menu:change', {
3209
- bubbles: true,
3210
- composed: true,
3211
- detail: { value, item },
3212
- }));
3213
- };
3214
- this._onKeyDown = (event) => {
3215
- const allVisible = this._getAllVisibleItems();
3216
- const currentElement = event.composedPath().find(target => target instanceof SidebarMenuItem || target instanceof SidebarSubMenu);
3217
- if (!currentElement) {
3218
- return;
3219
- }
3220
- if (!allVisible.includes(currentElement)) {
3221
- return;
3222
- }
3223
- const currentIndex = allVisible.indexOf(currentElement);
3224
- if (event.key === 'ArrowDown') {
3225
- event.preventDefault();
3226
- const nextIndex = (currentIndex + 1) % allVisible.length;
3227
- allVisible[nextIndex].focus();
3228
- }
3229
- else if (event.key === 'ArrowUp') {
3230
- event.preventDefault();
3231
- const prevIndex = currentIndex === 0 ? allVisible.length - 1 : currentIndex - 1;
3232
- allVisible[prevIndex].focus();
3233
- }
3234
- else if (event.key === 'Enter' || event.key === ' ') {
3235
- event.preventDefault();
3236
- currentElement.click();
3237
- }
3238
- else if (event.key === 'ArrowRight') {
3239
- event.preventDefault();
3240
- if (currentElement instanceof SidebarSubMenu && !currentElement.expanded) {
3241
- currentElement.expanded = true;
3242
- }
3243
- else if (currentElement instanceof SidebarSubMenu) {
3244
- const children = this._getChildNodes(currentElement);
3245
- if (children.length > 0) {
3246
- children[0].focus();
3247
- }
3248
- }
3249
- }
3250
- else if (event.key === 'ArrowLeft') {
3251
- event.preventDefault();
3252
- if (currentElement instanceof SidebarSubMenu && currentElement.expanded) {
3253
- currentElement.expanded = false;
3254
- }
3255
- }
3256
- };
3257
- }
3258
- connectedCallback() {
3259
- super.connectedCallback();
3260
- this.addEventListener('sidebar-menu-item:click', this._onItemClick);
3261
- this.addEventListener('keydown', this._onKeyDown);
3262
- this.setAttribute('role', 'tree');
3263
- }
3264
- updated(changedProps) {
3265
- super.updated(changedProps);
3266
- if (changedProps.has('selectedItem')) {
3267
- this._syncSelectedStateFromProperty();
3268
- }
3269
- }
3270
- disconnectedCallback() {
3271
- super.disconnectedCallback();
3272
- this.removeEventListener('sidebar-menu-item:click', this._onItemClick);
3273
- this.removeEventListener('keydown', this._onKeyDown);
3274
- }
3275
- _isSidebarNode(element) {
3276
- const tag = element.tagName.toLowerCase();
3277
- return tag === 'wc-sidebar-menu-item' || tag === 'wc-sidebar-sub-menu';
3278
- }
3279
- _getTopLevelItems() {
3280
- return Array.from(this.children).filter(el => this._isSidebarNode(el));
3281
- }
3282
- _getChildNodes(item) {
3283
- return Array.from(item.children).filter(child => this._isSidebarNode(child));
3284
- }
3285
- _getAllVisibleItems() {
3286
- const result = [];
3287
- const collect = (items) => {
3288
- items.forEach(item => {
3289
- result.push(item);
3290
- if (item instanceof SidebarSubMenu && item.expanded) {
3291
- collect(this._getChildNodes(item));
3292
- }
3293
- });
3294
- };
3295
- collect(this._getTopLevelItems());
3296
- return result;
3297
- }
3298
- _updateSelectedState(selectedValue) {
3299
- const allItems = this._collectAllItems(this._getTopLevelItems());
3300
- allItems.forEach(item => {
3301
- const itemValue = item.value || item.label;
3302
- // eslint-disable-next-line no-param-reassign
3303
- item.selected = itemValue === selectedValue;
3304
- });
3305
- }
3306
- _collectAllItems(items) {
3307
- const result = [];
3308
- items.forEach(item => {
3309
- result.push(item);
3310
- if (item instanceof SidebarSubMenu) {
3311
- result.push(...this._collectAllItems(this._getChildNodes(item)));
3312
- }
3313
- });
3314
- return result;
3315
- }
3316
- _syncSelectedStateFromProperty() {
3317
- const allItems = this._collectAllItems(this._getTopLevelItems());
3318
- allItems.forEach(item => {
3319
- const itemValue = item.value || item.label;
3320
- item.selected = itemValue === this.selectedItem;
3321
- });
3322
- }
3323
- render() {
3324
- return b ` <div class="sidebar-menu"><slot></slot></div> `;
3325
- }
3326
- }
3327
- SidebarMenu.styles = [css_248z$1];
3328
- __decorate([
3329
- n({ type: String, attribute: 'selected-item', reflect: true })
3330
- ], SidebarMenu.prototype, "selectedItem", void 0);
3331
-
3332
- var css_248z = i`@charset "UTF-8";
3333
- * {
3334
- box-sizing: border-box;
3335
- -webkit-tap-highlight-color: transparent;
3336
- }
3337
-
3338
- .screen-reader-only {
3339
- display: none !important;
3340
- }
3341
-
3342
- [hidden] {
3343
- display: none !important;
3344
- }
3345
-
3346
- :host {
3347
- display: block;
3348
- width: 100%;
3349
- }
3350
-
3351
- /* Make the field wrapper behave as a select (pointer cursor) */
3352
- .select-field {
3353
- cursor: pointer;
3354
- }
3355
-
3356
- .select-trigger {
3357
- flex: 1;
3358
- display: flex;
3359
- align-items: center;
3360
- min-height: 1.5rem;
3361
- outline: none;
3362
- cursor: pointer;
3363
- user-select: none;
3364
- overflow: hidden;
3365
- min-width: 0;
3366
- }
3367
- .select-trigger:focus-visible {
3368
- outline: none;
3369
- }
3370
-
3371
- .display-value {
3372
- font-family: var(--typography-body-large-font-family) !important;
3373
- font-size: var(--typography-body-large-font-size) !important;
3374
- font-weight: var(--typography-body-large-font-weight) !important;
3375
- line-height: var(--typography-body-large-line-height) !important;
3376
- letter-spacing: var(--typography-body-large-letter-spacing) !important;
3377
- color: var(--color-on-surface);
3378
- overflow: hidden;
3379
- text-overflow: ellipsis;
3380
- white-space: nowrap;
3381
- }
3382
-
3383
- .placeholder {
3384
- font-family: var(--typography-body-large-font-family) !important;
3385
- font-size: var(--typography-body-large-font-size) !important;
3386
- font-weight: var(--typography-body-large-font-weight) !important;
3387
- line-height: var(--typography-body-large-line-height) !important;
3388
- letter-spacing: var(--typography-body-large-letter-spacing) !important;
3389
- color: var(--color-on-surface-variant);
3390
- overflow: hidden;
3391
- text-overflow: ellipsis;
3392
- white-space: nowrap;
3393
- }
3394
-
3395
- /* Typeahead search input */
3396
- .search-input {
3397
- flex: 1;
3398
- width: 100%;
3399
- border: none;
3400
- outline: none;
3401
- background: transparent;
3402
- margin: 0;
3403
- padding: 0;
3404
- font-family: var(--typography-body-large-font-family) !important;
3405
- font-size: var(--typography-body-large-font-size) !important;
3406
- font-weight: var(--typography-body-large-font-weight) !important;
3407
- line-height: var(--typography-body-large-line-height) !important;
3408
- letter-spacing: var(--typography-body-large-letter-spacing) !important;
3409
- color: var(--color-on-surface);
3410
- cursor: pointer;
3411
- }
3412
- .search-input::placeholder {
3413
- color: var(--color-on-surface-variant);
3414
- }
3415
- .search-input:focus {
3416
- cursor: text;
3417
- }
3418
-
3419
- /* Field end slot wrapper */
3420
- .field-end-wrapper {
3421
- display: flex;
3422
- align-items: center;
3423
- gap: var(--spacing-050);
3424
- }
3425
-
3426
- .select-empty-state {
3427
- display: block;
3428
- inline-size: min(22rem, 100%);
3429
- }
3430
-
3431
- /* Dropdown chevron icon */
3432
- .dropdown-icon {
3433
- --icon-size: 1.5rem;
3434
- --icon-color: var(--color-on-surface-variant);
3435
- transition: transform 200ms ease;
3436
- flex-shrink: 0;
3437
- }
3438
- .dropdown-icon.dropdown-icon--open {
3439
- transform: rotate(180deg);
3440
- }
3441
-
3442
- /* Clear button */
3443
- .clear-btn {
3444
- --button-container-shape: var(--shape-corner-full);
3445
- }
3446
-
3447
- /* Multi-select chips area — single scrollable row, no vertical growth */
3448
- .chips-container {
3449
- display: flex;
3450
- align-items: center;
3451
- flex: 1;
3452
- padding-block: 0.5rem;
3453
- }
3454
-
3455
- /* Disabled state */
3456
- :host([disabled]) .select-trigger,
3457
- :host([disabled]) .select-field {
3458
- cursor: not-allowed;
3459
- }
3460
-
3461
- /* Readonly state */
3462
- :host([readonly]) .select-trigger,
3463
- :host([readonly]) .select-field {
3464
- cursor: default;
3465
- }`;
3466
-
3467
- /**
3468
- * @label Select
3469
- * @tag wc-select
3470
- * @rawTag select
3471
- *
3472
- * @summary A dropdown select component supporting single and multi-select with optional typeahead search.
3473
- * @overview
3474
- * Select builds on wc-field and wc-menu to provide a fully-featured dropdown picker.
3475
- *
3476
- * - Single and multi-select modes
3477
- * - Client-side typeahead with `search="contains"`
3478
- * - Server-side typeahead with `search="managed"`
3479
- * - Multi-select chips display
3480
- *
3481
- * @example
3482
- * ```html
3483
- * <wc-select label="Fruit" placeholder="Pick a fruit...">
3484
- * <wc-option value="apple">Apple</wc-option>
3485
- * <wc-option value="banana">Banana</wc-option>
3486
- * </wc-select>
3487
- * ```
3488
- * @tags form
3489
- */
3490
- class Select extends BaseInput {
3491
- constructor() {
3492
- super(...arguments);
3493
- this._menuId = `wc-select-menu-${Math.random().toString(36).slice(2, 9)}`;
3494
- /**
3495
- * Array of options to display in the dropdown.
3496
- * Setting this property creates matching `<wc-option>` children automatically.
3497
- */
3498
- this.options = [];
3499
- /**
3500
- * The selected value. For multi-select, a comma-separated list of values.
3501
- */
3502
- this.value = '';
3503
- /**
3504
- * Enable multi-select mode.
3505
- */
3506
- this.multiple = false;
3507
- /**
3508
- * Enable typeahead search.
3509
- * - `'contains'`: filters options client-side.
3510
- * - `'managed'`: emits a `select-search` event for server-controlled filtering.
3511
- */
3512
- this.search = '';
3513
- /**
3514
- * Placeholder text shown when no value is selected.
3515
- */
3516
- this.placeholder = '';
3517
- /**
3518
- * Label displayed above the field.
3519
- */
3520
- this.label = '';
3521
- /**
3522
- * Visual variant of the field.
3523
- */
3524
- this.variant = 'default';
3525
- /**
3526
- * Helper text displayed below the field.
3527
- */
3528
- this.helperText = '';
3529
- this.error = false;
3530
- this.errorText = '';
3531
- this.warning = false;
3532
- this.warningText = '';
3533
- this._open = false;
3534
- this._focused = false;
3535
- this._searchQuery = '';
3536
- /** True when all options are filtered out by the current search query. */
3537
- this._noOptionsVisible = false;
3538
- }
3539
- get _menu() {
3540
- return this.renderRoot?.querySelector('wc-menu') ?? null;
3541
- }
3542
- focus() {
3543
- this._triggerEl?.focus();
3544
- }
3545
- blur() {
3546
- this._triggerEl?.blur();
3547
- }
3548
- // ── Lifecycle ─────────────────────────────────────────────────────────────
3549
- updated(changedProperties) {
3550
- if (changedProperties.has('options')) {
3551
- this._syncProgrammaticOptions();
3552
- }
3553
- this._syncOptionStates();
3554
- }
3555
- // ── Programmatic options ───────────────────────────────────────────────────
3556
- /**
3557
- * Reconciles the `options` property with auto-generated `<wc-option>` light-DOM
3558
- * children (marked `data-generated`). Declarative children placed by the
3559
- * consumer are left untouched.
3560
- */
3561
- _syncProgrammaticOptions() {
3562
- this.querySelectorAll('wc-option[data-generated]').forEach(el => el.remove());
3563
- for (const opt of this.options) {
3564
- const el = new SelectOptionElement();
3565
- el.value = opt.value;
3566
- if (opt.icon)
3567
- el.icon = opt.icon;
3568
- el.textContent = opt.label || (opt.value === '' ? 'None' : '');
3569
- el.dataset.generated = '';
3570
- this.appendChild(el);
3571
- }
3572
- }
3573
- // ── Option state sync ──────────────────────────────────────────────────────
3574
- /**
3575
- * Pushes `selected`, `keepOpen`, and `filtered` state onto every `<wc-option>`
3576
- * child element so each one can render itself correctly.
3577
- */
3578
- _syncOptionStates() {
3579
- const optEls = Array.from(this.querySelectorAll('wc-option'));
3580
- let visibleCount = 0;
3581
- for (const opt of optEls) {
3582
- opt.selected = this._isSelected(opt.value);
3583
- opt.keepOpen = this.multiple;
3584
- if (this.search && this.search !== 'managed' && this._searchQuery) {
3585
- const q = this._searchQuery.toLowerCase();
3586
- const label = opt.textContent?.trim() ?? '';
3587
- opt.filtered = !label.toLowerCase().includes(q);
3588
- if (!opt.filtered)
3589
- visibleCount += 1;
3590
- }
3591
- else {
3592
- opt.filtered = false;
3593
- visibleCount += 1;
3594
- }
3595
- }
3596
- this._noOptionsVisible = visibleCount === 0;
3597
- }
3598
- // ── Helpers ────────────────────────────────────────────────────────────────
3599
- get _selectedValues() {
3600
- if (!this.value)
3601
- return [];
3602
- return this.value
3603
- .split(',')
3604
- .map(v => v.trim())
3605
- .filter(Boolean);
3606
- }
3607
- _isSelected(value) {
3608
- if (!this.multiple) {
3609
- return this.value === value;
3610
- }
3611
- return this._selectedValues.includes(value);
3612
- }
3613
- /** Returns the display label for a given option value. */
3614
- _getLabelForValue(val) {
3615
- for (const opt of this.querySelectorAll('wc-option')) {
3616
- if (opt.value === val) {
3617
- const label = opt.textContent?.trim();
3618
- if (label)
3619
- return label;
3620
- return val === '' ? 'None' : val;
3621
- }
3622
- }
3623
- // Fallback to options array (before wc-option children are created)
3624
- const programmaticLabel = this.options.find(o => o.value === val)?.label;
3625
- if (programmaticLabel)
3626
- return programmaticLabel;
3627
- return val === '' ? 'None' : val;
3628
- }
3629
- get _displayLabel() {
3630
- if (!this.value)
3631
- return '';
3632
- const firstValue = this._selectedValues[0];
3633
- if (!firstValue)
3634
- return '';
3635
- return this._getLabelForValue(firstValue);
3636
- }
3637
- get _isPopulated() {
3638
- return !!this.value;
3639
- }
3640
- // ── Menu open/close ────────────────────────────────────────────────────────
3641
- _openMenu() {
3642
- if (this.disabled || this.readonly)
3643
- return;
3644
- this._open = true;
3645
- this._focused = true;
3646
- this._triggerEl?.focus();
3647
- const menu = this._menu;
3648
- if (menu && this._triggerEl) {
3649
- // Anchor to the field's bordered box so the menu lines up with its edge
3650
- // and is at least as wide as the field.
3651
- const anchor = this._fieldEl?.fieldBodyElement ?? this._triggerEl;
3652
- menu.anchorElement = anchor;
3653
- menu.style.setProperty('--menu-min-width', `${Math.ceil(anchor.getBoundingClientRect().width)}px`);
3654
- menu.show();
3655
- }
3656
- if (this.search) {
3657
- this._searchQuery = '';
3658
- // Use rAF so that the search input receives focus *after* wc-menu has
3659
- // finished showing and potentially focused a menu item.
3660
- this.updateComplete.then(() => {
3661
- requestAnimationFrame(() => {
3662
- this._searchInputEl?.focus();
3663
- });
3664
- });
3665
- }
3666
- }
3667
- _closeMenu() {
3668
- if (!this._open)
3669
- return;
3670
- this._open = false;
3671
- this._focused = false;
3672
- this._searchQuery = '';
3673
- this._menu?.close();
3674
- }
3675
- // ── Event handlers ─────────────────────────────────────────────────────────
3676
- _handleTriggerClick(event) {
3677
- event.stopPropagation();
3678
- // Ignore clicks that originated inside the search input — those should not
3679
- // toggle the menu (the input needs to stay open so the user can type).
3680
- if (event.target instanceof HTMLInputElement) {
3681
- return;
3682
- }
3683
- if (this._open) {
3684
- this._closeMenu();
3685
- }
3686
- else {
3687
- this._openMenu();
3688
- }
3689
- }
3690
- _handleFieldClick(event) {
3691
- const eventPath = event.composedPath();
3692
- if (eventPath.includes(this._triggerEl) ||
3693
- eventPath.some(target => target instanceof HTMLInputElement ||
3694
- (target instanceof HTMLElement &&
3695
- (target.closest('.clear-btn') != null ||
3696
- target.matches('wc-icon-button'))))) {
3697
- return;
3698
- }
3699
- if (this._open) {
3700
- this._closeMenu();
3701
- }
3702
- else {
3703
- this._openMenu();
3704
- }
3705
- }
3706
- _handleTriggerKeyDown(event) {
3707
- // When the typeahead search input is active, let the input handle its own
3708
- // keys (Space, Enter, etc.). Only intercept Escape to close the menu.
3709
- if (event.target instanceof HTMLInputElement) {
3710
- if (event.key === 'Escape') {
3711
- event.preventDefault();
3712
- this._closeMenu();
3713
- }
3714
- return;
3715
- }
3716
- switch (event.key) {
3717
- case 'Enter':
3718
- case ' ':
3719
- case 'ArrowDown':
3720
- event.preventDefault();
3721
- if (!this._open)
3722
- this._openMenu();
3723
- break;
3724
- case 'Escape':
3725
- if (this._open) {
3726
- event.preventDefault();
3727
- this._closeMenu();
3728
- }
3729
- break;
3730
- }
3731
- }
3732
- _handleMenuClosed() {
3733
- this._open = false;
3734
- this._focused = false;
3735
- this._searchQuery = '';
3736
- }
3737
- _handleMenuItemActivate(event) {
3738
- const item = event.detail?.item;
3739
- if (!item)
3740
- return;
3741
- const val = item.value;
3742
- if (val === undefined)
3743
- return;
3744
- if (this.multiple) {
3745
- if (val === '')
3746
- return;
3747
- const values = this._selectedValues;
3748
- const idx = values.indexOf(val);
3749
- if (idx >= 0) {
3750
- values.splice(idx, 1);
3751
- }
3752
- else {
3753
- values.push(val);
3754
- }
3755
- this.value = values.join(',');
3756
- }
3757
- else {
3758
- this.value = val;
3759
- this._closeMenu();
3760
- }
3761
- this._dispatchChange();
3762
- }
3763
- _dispatchChange() {
3764
- this.dispatchEvent(new CustomEvent('change', {
3765
- detail: { value: this.value },
3766
- bubbles: true,
3767
- composed: true,
3768
- }));
3769
- }
3770
- _handleSearchInput(event) {
3771
- this._searchQuery = event.target.value;
3772
- if (this.search === 'managed') {
3773
- this.dispatchEvent(new CustomEvent('select-search', {
3774
- detail: { value: this._searchQuery },
3775
- bubbles: true,
3776
- composed: true,
3777
- }));
3778
- }
3779
- }
3780
- _handleChipDismiss(event, chipValue) {
3781
- event.stopPropagation();
3782
- const values = this._selectedValues.filter(v => v !== chipValue);
3783
- this.value = values.join(',');
3784
- this._dispatchChange();
3785
- }
3786
- _renderEmptyState() {
3787
- const hasSearchQuery = this._searchQuery.trim().length > 0;
3788
- return b `
3789
- <wc-empty-state
3790
- class="select-empty-state content-center"
3791
- illustration="no-document"
3792
- headline=${hasSearchQuery ? 'No results found' : 'No options available'}
3793
- description=${hasSearchQuery
3794
- ? 'Try a different search term.'
3795
- : 'There is nothing to select right now.'}
3796
- ></wc-empty-state>
3797
- `;
3798
- }
3799
- // ── Render helpers ─────────────────────────────────────────────────────────
3800
- _renderTriggerContent() {
3801
- // Typeahead: when open, show a text input for filtering
3802
- if (this.search && this._open) {
3803
- return b `<input
3804
- class="search-input"
3805
- .value=${this._searchQuery}
3806
- placeholder=${this._displayLabel || this.placeholder}
3807
- @input=${this._handleSearchInput}
3808
- />`;
3809
- }
3810
- // Multi-select: show chips for selected items
3811
- if (this.multiple && this._selectedValues.length > 0) {
3812
- return b `<div class="chips-container">
3813
- <wc-chip-set>
3814
- ${this._selectedValues.map(val => b `
3815
- <wc-chip
3816
- dismissible
3817
- value=${val}
3818
- @tag--dismiss=${(e) => this._handleChipDismiss(e, val)}
3819
- >${this._getLabelForValue(val)}</wc-chip
3820
- >
3821
- `)}
3822
- </wc-chip-set>
3823
- </div>`;
3824
- }
3825
- // Single select: show selected label or placeholder
3826
- const label = this._displayLabel;
3827
- if (!label) {
3828
- return b `<span class="placeholder">${this.placeholder}</span>`;
3829
- }
3830
- return b `<span class="display-value">${label}</span>`;
3831
- }
3832
- _renderFieldEnd() {
3833
- return b `
3834
- <wc-icon
3835
- class=${e({
3836
- 'dropdown-icon': true,
3837
- 'dropdown-icon--open': this._open,
3838
- })}
3839
- name="arrow_drop_down"
3840
- ></wc-icon>
3841
- `;
3842
- }
3843
- render() {
3844
- return b `
3845
- <wc-field
3846
- label=${this.label}
3847
- ?required=${this.required}
3848
- ?disabled=${this.disabled}
3849
- ?readonly=${this.readonly}
3850
- ?skeleton=${this.skeleton}
3851
- helper-text=${this.helperText}
3852
- ?error=${this.error}
3853
- error-text=${this.errorText}
3854
- ?warning=${this.warning}
3855
- warning-text=${this.warningText}
3856
- variant=${this.variant}
3857
- ?populated=${this._isPopulated || this._open}
3858
- ?focused=${this._focused}
3859
- .host=${this}
3860
- class="select-field"
3861
- @click=${this._handleFieldClick}
3862
- >
3863
- <div
3864
- class="select-trigger"
3865
- tabindex=${this.disabled ? -1 : 0}
3866
- role="combobox"
3867
- aria-label=${this.label || this.placeholder || 'Select option'}
3868
- aria-controls=${this._menuId}
3869
- aria-expanded=${String(this._open)}
3870
- aria-haspopup="listbox"
3871
- @click=${this._handleTriggerClick}
3872
- @keydown=${this._handleTriggerKeyDown}
3873
- >
3874
- ${this._renderTriggerContent()}
3875
- </div>
3876
-
3877
- <div slot="field-end" class="field-end-wrapper">
3878
- ${this._renderFieldEnd()}
3879
- </div>
3880
- </wc-field>
3881
-
3882
- <wc-menu
3883
- id=${this._menuId}
3884
- placement="bottom-start"
3885
- aria-label=${this.label || 'Options'}
3886
- @closed=${this._handleMenuClosed}
3887
- @menu-item-activate=${(e) => this._handleMenuItemActivate(e)}
3888
- >
3889
- <slot></slot>
3890
- ${this._noOptionsVisible ? this._renderEmptyState() : A}
3891
- </wc-menu>
3892
- `;
3893
- }
3894
- }
3895
- Select.styles = [css_248z];
3896
- __decorate([
3897
- n({ type: Array })
3898
- ], Select.prototype, "options", void 0);
3899
- __decorate([
3900
- n({ type: String, reflect: true })
3901
- ], Select.prototype, "value", void 0);
3902
- __decorate([
3903
- n({ type: Boolean, reflect: true })
3904
- ], Select.prototype, "multiple", void 0);
3905
- __decorate([
3906
- n({ type: String })
3907
- ], Select.prototype, "search", void 0);
3908
- __decorate([
3909
- n({ type: String })
3910
- ], Select.prototype, "placeholder", void 0);
3911
- __decorate([
3912
- n({ type: String })
3913
- ], Select.prototype, "label", void 0);
3914
- __decorate([
3915
- n({ type: String })
3916
- ], Select.prototype, "variant", void 0);
3917
- __decorate([
3918
- n({ type: String, attribute: 'helper-text' })
3919
- ], Select.prototype, "helperText", void 0);
3920
- __decorate([
3921
- n({ type: Boolean })
3922
- ], Select.prototype, "error", void 0);
3923
- __decorate([
3924
- n({ type: String, attribute: 'error-text' })
3925
- ], Select.prototype, "errorText", void 0);
3926
- __decorate([
3927
- n({ type: Boolean })
3928
- ], Select.prototype, "warning", void 0);
3929
- __decorate([
3930
- n({ type: String, attribute: 'warning-text' })
3931
- ], Select.prototype, "warningText", void 0);
3932
- __decorate([
3933
- r()
3934
- ], Select.prototype, "_open", void 0);
3935
- __decorate([
3936
- r()
3937
- ], Select.prototype, "_focused", void 0);
3938
- __decorate([
3939
- r()
3940
- ], Select.prototype, "_searchQuery", void 0);
3941
- __decorate([
3942
- r()
3943
- ], Select.prototype, "_noOptionsVisible", void 0);
3944
- __decorate([
3945
- e$1('.select-trigger')
3946
- ], Select.prototype, "_triggerEl", void 0);
3947
- __decorate([
3948
- e$1('wc-field')
3949
- ], Select.prototype, "_fieldEl", void 0);
3950
- __decorate([
3951
- e$1('.search-input')
3952
- ], Select.prototype, "_searchInputEl", void 0);
3953
-
3954
- export { ChipSet as C, DatePicker as D, Input as I, LinearProgress as L, NumberField as N, Select as S, Tag as T, UrlField as U, CircularProgress as a, SidebarMenu as b, SidebarMenuItem as c, SidebarSubMenu as d, Switch as e, Textarea as f, TimePicker as g };
3955
- //# sourceMappingURL=select-DkyRqUTI.js.map