@webtides/element-library 0.1.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 (238) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/LICENSE +21 -0
  3. package/README.md +125 -0
  4. package/all.js +26 -0
  5. package/custom-elements.json +7683 -0
  6. package/index.js +3 -0
  7. package/package.json +132 -0
  8. package/patches/@glidejs+glide+3.6.2.patch +11 -0
  9. package/src/components/accordion/accordion.changelog.md +47 -0
  10. package/src/components/accordion/accordion.define.js +3 -0
  11. package/src/components/accordion/accordion.events.js +3 -0
  12. package/src/components/accordion/accordion.js +144 -0
  13. package/src/components/accordion/accordion.readme.md +71 -0
  14. package/src/components/accordion/accordion.style.js +64 -0
  15. package/src/components/accordion-group/accordion-group.changelog.md +35 -0
  16. package/src/components/accordion-group/accordion-group.define.js +3 -0
  17. package/src/components/accordion-group/accordion-group.js +63 -0
  18. package/src/components/accordion-group/accordion-group.readme.md +56 -0
  19. package/src/components/amount-field/amount-field.changelog.md +40 -0
  20. package/src/components/amount-field/amount-field.define.js +3 -0
  21. package/src/components/amount-field/amount-field.js +91 -0
  22. package/src/components/amount-field/amount-field.readme.md +65 -0
  23. package/src/components/amount-field/amount-field.style.js +58 -0
  24. package/src/components/button/button.changelog.md +19 -0
  25. package/src/components/button/button.define.js +3 -0
  26. package/src/components/button/button.js +174 -0
  27. package/src/components/button/button.readme.md +91 -0
  28. package/src/components/button/button.style.js +251 -0
  29. package/src/components/carousel/carousel.changelog.md +58 -0
  30. package/src/components/carousel/carousel.define.js +3 -0
  31. package/src/components/carousel/carousel.events.js +3 -0
  32. package/src/components/carousel/carousel.js +232 -0
  33. package/src/components/carousel/carousel.readme.md +78 -0
  34. package/src/components/carousel/carousel.style.js +142 -0
  35. package/src/components/carousel/glide/components/ShadowAnchors.js +12 -0
  36. package/src/components/carousel/glide/components/ShadowClones.js +41 -0
  37. package/src/components/carousel/glide/components/ShadowGaps.js +28 -0
  38. package/src/components/carousel/glide/components/ShadowHtml.js +32 -0
  39. package/src/components/checkbox-field/checkbox-field.changelog.md +47 -0
  40. package/src/components/checkbox-field/checkbox-field.define.js +3 -0
  41. package/src/components/checkbox-field/checkbox-field.js +102 -0
  42. package/src/components/checkbox-field/checkbox-field.readme.md +66 -0
  43. package/src/components/checkbox-field/checkbox-field.style.js +69 -0
  44. package/src/components/dialog/dialog.changelog.md +24 -0
  45. package/src/components/dialog/dialog.define.js +3 -0
  46. package/src/components/dialog/dialog.events.js +8 -0
  47. package/src/components/dialog/dialog.js +271 -0
  48. package/src/components/dialog/dialog.readme.md +122 -0
  49. package/src/components/dialog/dialog.style.js +124 -0
  50. package/src/components/dropdown/dropdown.changelog.md +39 -0
  51. package/src/components/dropdown/dropdown.define.js +3 -0
  52. package/src/components/dropdown/dropdown.js +98 -0
  53. package/src/components/dropdown/dropdown.readme.md +69 -0
  54. package/src/components/dropdown/dropdown.style.js +17 -0
  55. package/src/components/form-field/form-field.changelog.md +35 -0
  56. package/src/components/form-field/form-field.define.js +3 -0
  57. package/src/components/form-field/form-field.events.js +4 -0
  58. package/src/components/form-field/form-field.js +210 -0
  59. package/src/components/form-field/form-field.readme.md +80 -0
  60. package/src/components/form-field/form-field.style.js +25 -0
  61. package/src/components/input-field/input-field.changelog.md +39 -0
  62. package/src/components/input-field/input-field.define.js +3 -0
  63. package/src/components/input-field/input-field.js +71 -0
  64. package/src/components/input-field/input-field.readme.md +90 -0
  65. package/src/components/input-field/input-field.style.js +33 -0
  66. package/src/components/lazy-src/lazy-src.changelog.md +57 -0
  67. package/src/components/lazy-src/lazy-src.define.js +3 -0
  68. package/src/components/lazy-src/lazy-src.events.js +5 -0
  69. package/src/components/lazy-src/lazy-src.js +100 -0
  70. package/src/components/lazy-src/lazy-src.readme.md +63 -0
  71. package/src/components/notification/notification.changelog.md +22 -0
  72. package/src/components/notification/notification.define.js +3 -0
  73. package/src/components/notification/notification.events.js +6 -0
  74. package/src/components/notification/notification.js +280 -0
  75. package/src/components/notification/notification.readme.md +98 -0
  76. package/src/components/notification/notification.style.js +113 -0
  77. package/src/components/password-field/password-field.changelog.md +22 -0
  78. package/src/components/password-field/password-field.define.js +3 -0
  79. package/src/components/password-field/password-field.js +113 -0
  80. package/src/components/password-field/password-field.readme.md +60 -0
  81. package/src/components/password-field/password-field.style.js +62 -0
  82. package/src/components/radio-field/radio-field.changelog.md +21 -0
  83. package/src/components/radio-field/radio-field.define.js +3 -0
  84. package/src/components/radio-field/radio-field.js +140 -0
  85. package/src/components/radio-field/radio-field.readme.md +72 -0
  86. package/src/components/radio-field/radio-field.style.js +108 -0
  87. package/src/components/scroll-to/scroll-to.changelog.md +39 -0
  88. package/src/components/scroll-to/scroll-to.define.js +3 -0
  89. package/src/components/scroll-to/scroll-to.js +40 -0
  90. package/src/components/scroll-to/scroll-to.readme.md +50 -0
  91. package/src/components/scroll-to-top/scroll-to-top.changelog.md +39 -0
  92. package/src/components/scroll-to-top/scroll-to-top.define.js +3 -0
  93. package/src/components/scroll-to-top/scroll-to-top.js +78 -0
  94. package/src/components/scroll-to-top/scroll-to-top.readme.md +48 -0
  95. package/src/components/scroll-to-top/scroll-to-top.style.js +9 -0
  96. package/src/components/select-field/select-field.changelog.md +30 -0
  97. package/src/components/select-field/select-field.define.js +3 -0
  98. package/src/components/select-field/select-field.js +83 -0
  99. package/src/components/select-field/select-field.readme.md +131 -0
  100. package/src/components/select-field/select-field.style.js +24 -0
  101. package/src/components/slider/slider.changelog.md +177 -0
  102. package/src/components/slider/slider.define.js +3 -0
  103. package/src/components/slider/slider.events.js +4 -0
  104. package/src/components/slider/slider.js +338 -0
  105. package/src/components/slider/slider.readme.md +87 -0
  106. package/src/components/slider/slider.style.js +107 -0
  107. package/src/components/sticky/sticky.changelog.md +43 -0
  108. package/src/components/sticky/sticky.define.js +3 -0
  109. package/src/components/sticky/sticky.js +105 -0
  110. package/src/components/sticky/sticky.readme.md +63 -0
  111. package/src/components/sticky/sticky.style.js +21 -0
  112. package/src/components/svg-use/svg-use.changelog.md +41 -0
  113. package/src/components/svg-use/svg-use.define.js +3 -0
  114. package/src/components/svg-use/svg-use.js +39 -0
  115. package/src/components/svg-use/svg-use.readme.md +50 -0
  116. package/src/components/svg-use/svg-use.style.js +20 -0
  117. package/src/components/switch-field/switch-field.changelog.md +21 -0
  118. package/src/components/switch-field/switch-field.define.js +3 -0
  119. package/src/components/switch-field/switch-field.js +99 -0
  120. package/src/components/switch-field/switch-field.readme.md +58 -0
  121. package/src/components/switch-field/switch-field.style.js +98 -0
  122. package/src/components/tab-group/tab-group.changelog.md +35 -0
  123. package/src/components/tab-group/tab-group.define.js +3 -0
  124. package/src/components/tab-group/tab-group.js +109 -0
  125. package/src/components/tab-group/tab-group.readme.md +61 -0
  126. package/src/components/tab-group/tab-group.style.js +7 -0
  127. package/src/components/tab-link/tab-link.changelog.md +35 -0
  128. package/src/components/tab-link/tab-link.define.js +3 -0
  129. package/src/components/tab-link/tab-link.js +50 -0
  130. package/src/components/tab-link/tab-link.readme.md +66 -0
  131. package/src/components/tab-link/tab-link.style.js +32 -0
  132. package/src/components/tab-panel/tab-panel.changelog.md +39 -0
  133. package/src/components/tab-panel/tab-panel.define.js +3 -0
  134. package/src/components/tab-panel/tab-panel.js +30 -0
  135. package/src/components/tab-panel/tab-panel.readme.md +57 -0
  136. package/src/components/tab-panel/tab-panel.style.js +7 -0
  137. package/src/components/textarea-field/textarea-field.changelog.md +39 -0
  138. package/src/components/textarea-field/textarea-field.define.js +3 -0
  139. package/src/components/textarea-field/textarea-field.js +62 -0
  140. package/src/components/textarea-field/textarea-field.readme.md +102 -0
  141. package/src/components/textarea-field/textarea-field.style.js +7 -0
  142. package/src/components/transition-classes/transition-classes.changelog.md +39 -0
  143. package/src/components/transition-classes/transition-classes.define.js +3 -0
  144. package/src/components/transition-classes/transition-classes.js +154 -0
  145. package/src/components/transition-classes/transition-classes.readme.md +71 -0
  146. package/src/themes/default.css +165 -0
  147. package/src/themes/high-contrast.css +147 -0
  148. package/src/themes/sketchy.css +238 -0
  149. package/types/all.d.ts +1 -0
  150. package/types/index.d.ts +1 -0
  151. package/types/src/components/accordion/accordion.d.ts +60 -0
  152. package/types/src/components/accordion/accordion.define.d.ts +1 -0
  153. package/types/src/components/accordion/accordion.events.d.ts +4 -0
  154. package/types/src/components/accordion/accordion.style.d.ts +2 -0
  155. package/types/src/components/accordion-group/accordion-group.d.ts +28 -0
  156. package/types/src/components/accordion-group/accordion-group.define.d.ts +1 -0
  157. package/types/src/components/amount-field/amount-field.d.ts +53 -0
  158. package/types/src/components/amount-field/amount-field.define.d.ts +1 -0
  159. package/types/src/components/amount-field/amount-field.style.d.ts +2 -0
  160. package/types/src/components/button/button.d.ts +73 -0
  161. package/types/src/components/button/button.define.d.ts +1 -0
  162. package/types/src/components/button/button.style.d.ts +2 -0
  163. package/types/src/components/carousel/carousel.d.ts +79 -0
  164. package/types/src/components/carousel/carousel.define.d.ts +1 -0
  165. package/types/src/components/carousel/carousel.events.d.ts +4 -0
  166. package/types/src/components/carousel/carousel.style.d.ts +2 -0
  167. package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -0
  168. package/types/src/components/carousel/glide/components/ShadowClones.d.ts +1 -0
  169. package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -0
  170. package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -0
  171. package/types/src/components/checkbox-field/checkbox-field.d.ts +69 -0
  172. package/types/src/components/checkbox-field/checkbox-field.define.d.ts +1 -0
  173. package/types/src/components/checkbox-field/checkbox-field.style.d.ts +2 -0
  174. package/types/src/components/dialog/dialog.d.ts +103 -0
  175. package/types/src/components/dialog/dialog.define.d.ts +1 -0
  176. package/types/src/components/dialog/dialog.events.d.ts +9 -0
  177. package/types/src/components/dialog/dialog.style.d.ts +2 -0
  178. package/types/src/components/dropdown/dropdown.d.ts +45 -0
  179. package/types/src/components/dropdown/dropdown.define.d.ts +1 -0
  180. package/types/src/components/dropdown/dropdown.style.d.ts +2 -0
  181. package/types/src/components/form-field/form-field.d.ts +110 -0
  182. package/types/src/components/form-field/form-field.define.d.ts +1 -0
  183. package/types/src/components/form-field/form-field.events.d.ts +5 -0
  184. package/types/src/components/form-field/form-field.style.d.ts +2 -0
  185. package/types/src/components/input-field/input-field.d.ts +38 -0
  186. package/types/src/components/input-field/input-field.define.d.ts +1 -0
  187. package/types/src/components/input-field/input-field.style.d.ts +2 -0
  188. package/types/src/components/lazy-src/lazy-src.d.ts +46 -0
  189. package/types/src/components/lazy-src/lazy-src.define.d.ts +1 -0
  190. package/types/src/components/lazy-src/lazy-src.events.d.ts +6 -0
  191. package/types/src/components/notification/notification.d.ts +92 -0
  192. package/types/src/components/notification/notification.define.d.ts +1 -0
  193. package/types/src/components/notification/notification.events.d.ts +7 -0
  194. package/types/src/components/notification/notification.style.d.ts +2 -0
  195. package/types/src/components/password-field/password-field.d.ts +66 -0
  196. package/types/src/components/password-field/password-field.define.d.ts +1 -0
  197. package/types/src/components/password-field/password-field.style.d.ts +2 -0
  198. package/types/src/components/radio-field/radio-field.d.ts +62 -0
  199. package/types/src/components/radio-field/radio-field.define.d.ts +1 -0
  200. package/types/src/components/radio-field/radio-field.style.d.ts +2 -0
  201. package/types/src/components/scroll-to/scroll-to.d.ts +24 -0
  202. package/types/src/components/scroll-to/scroll-to.define.d.ts +1 -0
  203. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +32 -0
  204. package/types/src/components/scroll-to-top/scroll-to-top.define.d.ts +1 -0
  205. package/types/src/components/scroll-to-top/scroll-to-top.style.d.ts +2 -0
  206. package/types/src/components/select-field/select-field.d.ts +39 -0
  207. package/types/src/components/select-field/select-field.define.d.ts +1 -0
  208. package/types/src/components/select-field/select-field.style.d.ts +2 -0
  209. package/types/src/components/slider/slider.d.ts +129 -0
  210. package/types/src/components/slider/slider.define.d.ts +1 -0
  211. package/types/src/components/slider/slider.events.d.ts +5 -0
  212. package/types/src/components/slider/slider.style.d.ts +2 -0
  213. package/types/src/components/sticky/sticky.d.ts +47 -0
  214. package/types/src/components/sticky/sticky.define.d.ts +1 -0
  215. package/types/src/components/sticky/sticky.style.d.ts +2 -0
  216. package/types/src/components/svg-use/svg-use.d.ts +18 -0
  217. package/types/src/components/svg-use/svg-use.define.d.ts +1 -0
  218. package/types/src/components/svg-use/svg-use.style.d.ts +2 -0
  219. package/types/src/components/switch-field/switch-field.d.ts +67 -0
  220. package/types/src/components/switch-field/switch-field.define.d.ts +1 -0
  221. package/types/src/components/switch-field/switch-field.style.d.ts +2 -0
  222. package/types/src/components/tab-group/tab-group.d.ts +48 -0
  223. package/types/src/components/tab-group/tab-group.define.d.ts +1 -0
  224. package/types/src/components/tab-group/tab-group.style.d.ts +2 -0
  225. package/types/src/components/tab-link/tab-link.d.ts +30 -0
  226. package/types/src/components/tab-link/tab-link.define.d.ts +1 -0
  227. package/types/src/components/tab-link/tab-link.style.d.ts +2 -0
  228. package/types/src/components/tab-panel/tab-panel.d.ts +18 -0
  229. package/types/src/components/tab-panel/tab-panel.define.d.ts +1 -0
  230. package/types/src/components/tab-panel/tab-panel.style.d.ts +2 -0
  231. package/types/src/components/textarea-field/textarea-field.d.ts +34 -0
  232. package/types/src/components/textarea-field/textarea-field.define.d.ts +1 -0
  233. package/types/src/components/textarea-field/textarea-field.style.d.ts +2 -0
  234. package/types/src/components/transition-classes/transition-classes.d.ts +52 -0
  235. package/types/src/components/transition-classes/transition-classes.define.d.ts +1 -0
  236. package/types/src/utils/body-scroll.d.ts +4 -0
  237. package/types/src/utils/transitions.d.ts +9 -0
  238. package/web-types.json +3956 -0
@@ -0,0 +1,251 @@
1
+ const css = String.raw;
2
+
3
+ export default css`
4
+ :host {
5
+ display: inline-block;
6
+ vertical-align: middle;
7
+ }
8
+
9
+ /* ── Base control ─────────────────────────────────────────────────────── */
10
+
11
+ .button {
12
+ /* Tokens with headless fallbacks: an unthemed button still renders as a usable
13
+ native-ish control rather than disappearing. */
14
+ position: relative;
15
+ display: inline-flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ gap: var(--el-space-2, 0.5em);
19
+ box-sizing: border-box;
20
+ width: 100%;
21
+ min-height: var(--el-control-height, 2.5rem);
22
+ padding: var(--el-space-2, 0.5em) var(--el-space-4, 1em);
23
+ border: var(--el-border-width, 1px) solid transparent;
24
+ border-radius: var(--el-radius-md, 4px);
25
+ background: var(--el-color-bg-muted, #e5e7eb);
26
+ color: var(--el-color-fg, currentColor);
27
+ font-family: var(--el-font-family, inherit);
28
+ font-size: var(--el-font-size-md, 1rem);
29
+ font-weight: 600;
30
+ line-height: var(--el-line-height, 1.5);
31
+ text-align: center;
32
+ text-decoration: none;
33
+ white-space: nowrap;
34
+ cursor: pointer;
35
+ user-select: none;
36
+ transition:
37
+ background var(--el-duration-md, 0s) var(--el-ease, linear),
38
+ border-color var(--el-duration-md, 0s) var(--el-ease, linear),
39
+ color var(--el-duration-md, 0s) var(--el-ease, linear);
40
+ }
41
+
42
+ /* display:contents promotes the slotted content to be the flex items directly, so empty
43
+ prefix/suffix slots contribute no box (and no phantom gap) when nothing is slotted. */
44
+ [part='label'],
45
+ [part='prefix'],
46
+ [part='suffix'] {
47
+ display: contents;
48
+ }
49
+
50
+ .button:hover {
51
+ /* Subtle, token-free hover that works on any background fill. */
52
+ filter: brightness(0.95);
53
+ }
54
+
55
+ .button:focus-visible {
56
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
57
+ outline-offset: var(--el-focus-ring-offset, 2px);
58
+ }
59
+
60
+ /* ── Sizes ────────────────────────────────────────────────────────────── */
61
+
62
+ .button--small {
63
+ min-height: calc(var(--el-control-height, 2.5rem) * 0.8);
64
+ padding: var(--el-space-1, 0.25em) var(--el-space-3, 0.75em);
65
+ font-size: var(--el-font-size-sm, 0.875rem);
66
+ }
67
+
68
+ .button--large {
69
+ min-height: calc(var(--el-control-height, 2.5rem) * 1.25);
70
+ padding: var(--el-space-3, 0.75em) var(--el-space-5, 1.5em);
71
+ font-size: calc(var(--el-font-size-md, 1rem) * 1.125);
72
+ }
73
+
74
+ /* ── Solid variants ───────────────────────────────────────────────────── */
75
+
76
+ /* Filled buttons read the label against the surface color, the same contrast trick the
77
+ checkbox checkmark uses: in light schemes bg is light → light text on a colored fill,
78
+ in dark schemes bg is dark → dark text. So a single token works in both. */
79
+ .button--primary {
80
+ background: var(--el-color-accent, #2563eb);
81
+ border-color: var(--el-color-accent, #2563eb);
82
+ color: var(--el-color-bg, #fff);
83
+ }
84
+
85
+ .button--success {
86
+ background: var(--el-color-success, #16a34a);
87
+ border-color: var(--el-color-success, #16a34a);
88
+ color: var(--el-color-bg, #fff);
89
+ }
90
+
91
+ .button--danger {
92
+ background: var(--el-color-danger, #dc2626);
93
+ border-color: var(--el-color-danger, #dc2626);
94
+ color: var(--el-color-bg, #fff);
95
+ }
96
+
97
+ .button--neutral {
98
+ background: var(--el-color-fg, #374151);
99
+ border-color: var(--el-color-fg, #374151);
100
+ color: var(--el-color-bg, #fff);
101
+ }
102
+
103
+ /* No dedicated warning token exists yet; fall back to amber. Amber stays light in both
104
+ color schemes, so dark text keeps the label readable regardless of theme. */
105
+ .button--warning {
106
+ background: var(--el-color-warning, #f59e0b);
107
+ border-color: var(--el-color-warning, #f59e0b);
108
+ color: #1c1917;
109
+ }
110
+
111
+ /* default keeps the muted surface but gains a themed border for definition. */
112
+ .button--default {
113
+ border-color: var(--el-color-border, transparent);
114
+ }
115
+
116
+ /* text — no chrome, color-only, like a link that behaves as a button. */
117
+ .button--text {
118
+ background: transparent;
119
+ border-color: transparent;
120
+ color: var(--el-color-accent, currentColor);
121
+ }
122
+
123
+ .button--text:hover {
124
+ filter: none;
125
+ text-decoration: underline;
126
+ }
127
+
128
+ /* ── Outline ──────────────────────────────────────────────────────────── */
129
+
130
+ .button--outline {
131
+ background: transparent;
132
+ }
133
+
134
+ .button--outline.button--default {
135
+ border-color: var(--el-color-border, currentColor);
136
+ color: var(--el-color-fg, currentColor);
137
+ }
138
+
139
+ .button--outline.button--primary {
140
+ border-color: var(--el-color-accent, currentColor);
141
+ color: var(--el-color-accent, currentColor);
142
+ }
143
+
144
+ .button--outline.button--success {
145
+ border-color: var(--el-color-success, currentColor);
146
+ color: var(--el-color-success, currentColor);
147
+ }
148
+
149
+ .button--outline.button--danger {
150
+ border-color: var(--el-color-danger, currentColor);
151
+ color: var(--el-color-danger, currentColor);
152
+ }
153
+
154
+ .button--outline.button--neutral {
155
+ border-color: var(--el-color-fg, currentColor);
156
+ color: var(--el-color-fg, currentColor);
157
+ }
158
+
159
+ .button--outline.button--warning {
160
+ border-color: var(--el-color-warning, #f59e0b);
161
+ color: var(--el-color-warning, #b45309);
162
+ }
163
+
164
+ .button--outline:hover {
165
+ /* Fill on hover by lifting the brightness of a faint tint of the current text color. */
166
+ background: color-mix(in srgb, currentColor 12%, transparent);
167
+ filter: none;
168
+ }
169
+
170
+ /* ── Shapes ───────────────────────────────────────────────────────────── */
171
+
172
+ .button--pill {
173
+ border-radius: 999px;
174
+ }
175
+
176
+ .button--circle {
177
+ width: var(--el-control-height, 2.5rem);
178
+ height: var(--el-control-height, 2.5rem);
179
+ min-height: 0;
180
+ padding: 0;
181
+ border-radius: 50%;
182
+ aspect-ratio: 1;
183
+ }
184
+
185
+ .button--circle.button--small {
186
+ width: calc(var(--el-control-height, 2.5rem) * 0.8);
187
+ height: calc(var(--el-control-height, 2.5rem) * 0.8);
188
+ }
189
+
190
+ .button--circle.button--large {
191
+ width: calc(var(--el-control-height, 2.5rem) * 1.25);
192
+ height: calc(var(--el-control-height, 2.5rem) * 1.25);
193
+ }
194
+
195
+ /* ── Caret ────────────────────────────────────────────────────────────── */
196
+
197
+ .caret {
198
+ display: inline-flex;
199
+ line-height: 1;
200
+ }
201
+
202
+ /* ── Loading ──────────────────────────────────────────────────────────── */
203
+
204
+ /* Keep the label in the layout (so the button doesn't resize) but hide it under the
205
+ spinner, which is centered over the whole control. */
206
+ .button--loading {
207
+ cursor: wait;
208
+ }
209
+
210
+ .button--loading [part='label'],
211
+ .button--loading [part='prefix'],
212
+ .button--loading [part='suffix'],
213
+ .button--loading .caret {
214
+ visibility: hidden;
215
+ }
216
+
217
+ .spinner {
218
+ position: absolute;
219
+ top: 50%;
220
+ left: 50%;
221
+ width: 1em;
222
+ height: 1em;
223
+ margin: -0.5em 0 0 -0.5em;
224
+ border: 2px solid currentColor;
225
+ border-top-color: transparent;
226
+ border-radius: 50%;
227
+ animation: el-button-spin 0.7s linear infinite;
228
+ }
229
+
230
+ @keyframes el-button-spin {
231
+ to {
232
+ transform: rotate(360deg);
233
+ }
234
+ }
235
+
236
+ @media (prefers-reduced-motion: reduce) {
237
+ .spinner {
238
+ animation-duration: 1.4s;
239
+ }
240
+ }
241
+
242
+ /* ── Disabled ─────────────────────────────────────────────────────────── */
243
+
244
+ .button[disabled],
245
+ .button[aria-disabled='true'] {
246
+ opacity: 0.55;
247
+ cursor: not-allowed;
248
+ pointer-events: none;
249
+ filter: none;
250
+ }
251
+ `;
@@ -0,0 +1,58 @@
1
+ # Change Log
2
+
3
+ All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ <!--
8
+ When your PR touches this component, add an entry under Unreleased and
9
+ mirror it (prefixed with the component name) in root CHANGELOG.md.
10
+ Uncomment headings as needed.
11
+ -->
12
+
13
+ ## Unreleased
14
+
15
+ ## [0.1.0] - 2026-06-03
16
+
17
+ ### Changed
18
+
19
+ - BREAKING: renamed the component — tag `el-carousel-element` → `el-carousel`, import subpaths `@webtides/element-library/carousel-element` → `/carousel` (and `/carousel-element/define` → `/carousel/define`), and exported class `CarouselElement` → `Carousel`.
20
+
21
+ ### Fixed
22
+
23
+ - The shadow-DOM `Html` component (`ShadowHtml`) now forwards Glide's `Events` argument to the wrapped `@glidejs/glide` html component, matching the sibling `ShadowAnchors` / `ShadowClones` / `ShadowGaps` wrappers. Previously it called the factory with only `(Glide, Components)`, so the underlying component's `Events.on('update', …)` threw `Cannot read properties of undefined (reading 'on')` on every mount.
24
+ - Glide's core + theme CSS is now inlined in `carousel.style.js` instead of being pulled in with `@import '@glidejs/glide/dist/css/…'`. The `@import` was silently dropped because element-js applies component styles as constructed/adopted stylesheets, where `@import` is not allowed — so `.glide__track` lost `overflow: hidden` and the arrows/bullets lost their absolute positioning and fell into a strip below the slides instead of overlaying them.
25
+
26
+ ## Legacy (pre-merge)
27
+
28
+ The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
29
+
30
+ ## [0.1.4] - 2021-07-21
31
+
32
+ ### Changed
33
+
34
+ update element-js version
35
+
36
+ ## [0.1.3] - 2020-10-09
37
+
38
+ ### FIXED
39
+
40
+ - fix glide dependecy
41
+
42
+ ## [0.1.2] - 2020-10-09
43
+
44
+ ### Added
45
+
46
+ - part marker to glide template for better themability
47
+
48
+ ## [0.1.1] - 2020-09-28
49
+
50
+ ### Fixed
51
+
52
+ - disabled state
53
+
54
+ ## [0.1.0] - 2020-09-17
55
+
56
+ ### Added
57
+
58
+ - initial release
@@ -0,0 +1,3 @@
1
+ import { define } from './carousel.js';
2
+
3
+ define();
@@ -0,0 +1,3 @@
1
+ export default {
2
+ CAROUSEL_RUN: 'CarouselRun',
3
+ };
@@ -0,0 +1,232 @@
1
+ import { TemplateElement, html, defineElement } from '@webtides/element-js';
2
+ import Glide from '@glidejs/glide';
3
+ import style from './carousel.style.js';
4
+ import CarouselEvents from './carousel.events.js';
5
+
6
+ import ShadowHtml from './glide/components/ShadowHtml.js';
7
+ import ShadowAnchors from './glide/components/ShadowAnchors.js';
8
+ import ShadowGaps from './glide/components/ShadowGaps.js';
9
+ import ShadowClones from './glide/components/ShadowClones.js';
10
+
11
+ const DEFAULT_OPTIONS = {
12
+ type: 'carousel',
13
+ perView: 1,
14
+ startAt: 0,
15
+ keyboard: false,
16
+ };
17
+
18
+ /**
19
+ * Carousel/slider component backed by Glide.js. Direct children of the host element are
20
+ * treated as slides; the component renders Glide's controls (navigation arrows and bullet
21
+ * pager) inside the shadow DOM around them.
22
+ *
23
+ * @element el-carousel
24
+ *
25
+ * @fires {CustomEvent<number>} CarouselRun - Fired on every Glide `run` (slide change).
26
+ * `detail` is the new active slide index.
27
+ *
28
+ * @slot - Default slot. Direct children become slides (unless they have a `slot`
29
+ * attribute or are Glide clones).
30
+ * @slot arrow-left - Content of the "previous" navigation button.
31
+ * @slot arrow-right - Content of the "next" navigation button.
32
+ *
33
+ * @csspart track - The Glide track wrapper.
34
+ * @csspart slides - The slides container.
35
+ * @csspart arrows - The navigation arrows wrapper.
36
+ * @csspart arrow - Applied to both arrow buttons.
37
+ * @csspart arrow-left - Applied to the previous-slide button (in addition to `arrow`).
38
+ * @csspart arrow-right - Applied to the next-slide button (in addition to `arrow`).
39
+ * @csspart dots - The bullet pager wrapper.
40
+ * @csspart dot - Applied to each bullet.
41
+ * @csspart selected-dot - Added to the bullet representing the active slide.
42
+ *
43
+ * @property {object} options - Options forwarded to the Glide constructor. Merged on top of
44
+ * the component's defaults (`type: 'carousel'`, `perView: 1`, `startAt: 0`,
45
+ * `keyboard: false`).
46
+ * @property {boolean} disabled - When `true`, Glide is not mounted and slides render as a
47
+ * plain list (useful for SSR or feature-flagging the carousel off).
48
+ * @property {string} slidePrefix - Prefix used when generating per-slide identifiers.
49
+ * @property {boolean} bullets - Whether to render the bullet pager.
50
+ * @property {boolean} arrows - Whether to render the previous/next navigation arrows.
51
+ */
52
+ export default class Carousel extends TemplateElement {
53
+ #glide = null;
54
+ #uniqueChildren = [];
55
+
56
+ constructor() {
57
+ super({
58
+ styles: [style],
59
+ shadowRender: true,
60
+ deferUpdate: true,
61
+ autoUpdate: false,
62
+ mutationObserverOptions: { childList: false },
63
+ });
64
+ }
65
+
66
+ /**
67
+ * Returns the underlying Glide instance for external navigation/configuration. Falls
68
+ * back to a no-op `{ go() }` stub while Glide is not mounted (e.g. when `disabled`).
69
+ */
70
+ get api() {
71
+ return (
72
+ this.#glide || {
73
+ go: () => {},
74
+ }
75
+ );
76
+ }
77
+
78
+ properties() {
79
+ return {
80
+ options: {},
81
+ disabled: false,
82
+ slidePrefix: 'slide',
83
+ bullets: true,
84
+ arrows: true,
85
+ };
86
+ }
87
+
88
+ connected() {
89
+ this.requestUpdate();
90
+ }
91
+
92
+ beforeUpdate() {
93
+ this.destroyGlide();
94
+ //this assumes that childrens are always added as direct children
95
+ this.#uniqueChildren = this.getUniqueChildren();
96
+ }
97
+
98
+ afterUpdate() {
99
+ this.mountGlide();
100
+ }
101
+
102
+ disconnected() {
103
+ this.destroyGlide();
104
+ }
105
+
106
+ /** @private */
107
+ getUniqueChildren() {
108
+ return Array.from(this.children).filter(
109
+ (item) => !item.classList.contains('glide__slide--clone') && !item.hasAttribute('slot'),
110
+ );
111
+ }
112
+
113
+ /** @private */
114
+ mountGlide() {
115
+ if (this.disabled) {
116
+ return;
117
+ }
118
+ this.#glide = new Glide(this.$refs.glide, { ...DEFAULT_OPTIONS, ...this.options }).mount({
119
+ Html: ShadowHtml,
120
+ Clones: ShadowClones,
121
+ Gaps: ShadowGaps,
122
+ Anchors: ShadowAnchors,
123
+ });
124
+ this.#glide.on('run', () => {
125
+ this.dispatch(CarouselEvents.CAROUSEL_RUN, this.#glide.index);
126
+ this.updateBulletClasses();
127
+ });
128
+ this.updateBulletClasses();
129
+ }
130
+
131
+ /** @private */
132
+ destroyGlide() {
133
+ if (this.#glide) {
134
+ this.#glide.destroy();
135
+ this.#glide = null;
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Advance to the next slide.
141
+ * @returns {void}
142
+ */
143
+ next() {
144
+ this.api.go('>');
145
+ }
146
+
147
+ /**
148
+ * Move to the previous slide.
149
+ * @returns {void}
150
+ */
151
+ prev() {
152
+ this.api.go('<');
153
+ }
154
+
155
+ /** @private */
156
+ updateBulletClasses() {
157
+ const bullets = Array.from(this.getRoot().querySelectorAll('.glide__bullet'));
158
+ bullets.forEach((bullet, index) => {
159
+ if (index === this.#glide.index) {
160
+ bullet.part.add('selected-dot');
161
+ } else {
162
+ bullet.part.remove('selected-dot');
163
+ }
164
+ });
165
+ }
166
+
167
+ /** @private */
168
+ renderBullets() {
169
+ let bullets = [];
170
+ for (let i = 0; i < this.#uniqueChildren.length; i++) {
171
+ bullets.push(html` <div part="dot" class="glide__bullet" data-glide-dir="=${i}"></div> `);
172
+ }
173
+ return bullets;
174
+ }
175
+
176
+ /** @private */
177
+ renderSlides() {
178
+ let slides = [];
179
+ for (let i = 0; i < this.#uniqueChildren.length; i++) {
180
+ slides.push(html` ${this.#uniqueChildren[i]} `);
181
+ }
182
+ return slides;
183
+ }
184
+
185
+ template() {
186
+ if (this.disabled) {
187
+ return this._options.shadowRender ? html` <slot></slot> ` : this.renderSlides();
188
+ }
189
+ return html`
190
+ <div class="glide" ref="glide">
191
+ <div class="glide__track" data-glide-el="track" part="track">
192
+ <div class="glide__slides" part="slides">
193
+ ${this._options.shadowRender ? html` <slot></slot> ` : this.renderSlides()}
194
+ </div>
195
+ </div>
196
+ ${this.arrows
197
+ ? html`
198
+ <div part="arrows" class="glide__arrows" data-glide-el="controls">
199
+ <button
200
+ part="arrow arrow-left"
201
+ class="glide__arrow glide__arrow--left"
202
+ data-glide-dir="<"
203
+ >
204
+ <slot name="arrow-left"></slot>
205
+ </button>
206
+ <button
207
+ part="arrow arrow-right"
208
+ class="glide__arrow glide__arrow--right"
209
+ data-glide-dir=">"
210
+ >
211
+ <slot name="arrow-right"></slot>
212
+ </button>
213
+ </div>
214
+ `
215
+ : ''}
216
+ ${this.bullets
217
+ ? html`
218
+ <div part="dots" class="glide__bullets" data-glide-el="controls[nav]">
219
+ ${this.renderBullets()}
220
+ </div>
221
+ `
222
+ : ''}
223
+ </div>
224
+ `;
225
+ }
226
+ }
227
+
228
+ export function define() {
229
+ defineElement('el-carousel', Carousel);
230
+ }
231
+
232
+ export { html, defineElement, CarouselEvents };
@@ -0,0 +1,78 @@
1
+ # Carousel
2
+
3
+ `carousel` is a carousel/slider component backed by [Glide.js](https://glidejs.com/). Direct children of the host element are treated as slides; the component renders Glide's controls (navigation arrows and bullet pager) inside the shadow DOM around them.
4
+
5
+ ## How to use
6
+
7
+ #### Install
8
+
9
+ ```sh
10
+ npm i --save @webtides/element-library
11
+ ```
12
+
13
+ #### Use
14
+
15
+ ```js
16
+ import '@webtides/element-library/carousel/define';
17
+ ```
18
+
19
+ ```html
20
+ <el-carousel>
21
+ <div>1</div>
22
+ <div>2</div>
23
+ <div>3</div>
24
+ <div>4</div>
25
+ </el-carousel>
26
+ ```
27
+
28
+ ## API
29
+
30
+ #### Properties/Attributes
31
+
32
+ | Name | Type | Default | Description |
33
+ | --- | --- | --- | --- |
34
+ | `options` | `object` | `{}` | Options forwarded to the Glide constructor. Merged on top of the component's defaults (`type: 'carousel'`, `perView: 1`, `startAt: 0`, `keyboard: false`). See the [Glide options](https://glidejs.com/docs/options/). |
35
+ | `disabled` | `boolean` | `false` | When `true`, Glide is not mounted and slides render as a plain list (useful for SSR or feature-flagging the carousel off). |
36
+ | `slidePrefix` | `string` | `'slide'` | Prefix used when generating per-slide identifiers. |
37
+ | `bullets` | `boolean` | `true` | Whether to render the bullet pager. |
38
+ | `arrows` | `boolean` | `true` | Whether to render the previous/next navigation arrows. |
39
+
40
+ #### Methods
41
+
42
+ | Name | Parameters | Description |
43
+ | --- | --- | --- |
44
+ | `next()` | None | Advance to the next slide. |
45
+ | `prev()` | None | Move to the previous slide. |
46
+ | `api` _(getter)_ | None | Returns the underlying Glide instance for external navigation/configuration. Falls back to a no-op `{ go() }` stub while Glide is not mounted (e.g. when `disabled`). |
47
+
48
+ #### Events
49
+
50
+ | Name | Detail | Description |
51
+ | ------------- | -------- | ------------------------------------------------------------------------------------ |
52
+ | `CarouselRun` | `number` | Fired on every Glide `run` (slide change). The detail is the new active slide index. |
53
+
54
+ #### Slots
55
+
56
+ | Name | Description |
57
+ | ------------- | ---------------------------------------------------------------------------------------- |
58
+ | _(default)_ | Direct children become slides (unless they have a `slot` attribute or are Glide clones). |
59
+ | `arrow-left` | Content of the "previous" navigation button. |
60
+ | `arrow-right` | Content of the "next" navigation button. |
61
+
62
+ #### CSS Parts
63
+
64
+ | Name | Description |
65
+ | -------------- | -------------------------------------------------------------- |
66
+ | `track` | The Glide track wrapper. |
67
+ | `slides` | The slides container. |
68
+ | `arrows` | The navigation arrows wrapper. |
69
+ | `arrow` | Applied to both arrow buttons. |
70
+ | `arrow-left` | Applied to the previous-slide button (in addition to `arrow`). |
71
+ | `arrow-right` | Applied to the next-slide button (in addition to `arrow`). |
72
+ | `dots` | The bullet pager wrapper. |
73
+ | `dot` | Applied to each bullet. |
74
+ | `selected-dot` | Added to the bullet representing the active slide. |
75
+
76
+ #### CSS Custom Properties
77
+
78
+ _None_