@phcdevworks/spectre-components 1.20.0 → 1.21.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 (350) hide show
  1. package/README.md +672 -49
  2. package/dist/accordion-item.cjs +540 -0
  3. package/dist/accordion-item.cjs.map +1 -0
  4. package/dist/accordion-item.d.cts +59 -0
  5. package/dist/accordion-item.d.ts +59 -0
  6. package/dist/accordion-item.js +537 -0
  7. package/dist/accordion-item.js.map +1 -0
  8. package/dist/accordion.cjs +468 -0
  9. package/dist/accordion.cjs.map +1 -0
  10. package/dist/accordion.d.cts +38 -0
  11. package/dist/accordion.d.ts +38 -0
  12. package/dist/accordion.js +465 -0
  13. package/dist/accordion.js.map +1 -0
  14. package/dist/alert.cjs +166 -65
  15. package/dist/alert.cjs.map +1 -1
  16. package/dist/alert.d.cts +41 -8
  17. package/dist/alert.d.ts +41 -8
  18. package/dist/alert.js +168 -67
  19. package/dist/alert.js.map +1 -1
  20. package/dist/avatar.cjs +27 -1
  21. package/dist/avatar.cjs.map +1 -1
  22. package/dist/avatar.d.cts +19 -3
  23. package/dist/avatar.d.ts +19 -3
  24. package/dist/avatar.js +27 -1
  25. package/dist/avatar.js.map +1 -1
  26. package/dist/badge.cjs +35 -2
  27. package/dist/badge.cjs.map +1 -1
  28. package/dist/badge.d.cts +31 -3
  29. package/dist/badge.d.ts +31 -3
  30. package/dist/badge.js +35 -2
  31. package/dist/badge.js.map +1 -1
  32. package/dist/breadcrumb.cjs +464 -0
  33. package/dist/breadcrumb.cjs.map +1 -0
  34. package/dist/breadcrumb.d.cts +32 -0
  35. package/dist/breadcrumb.d.ts +32 -0
  36. package/dist/breadcrumb.js +461 -0
  37. package/dist/breadcrumb.js.map +1 -0
  38. package/dist/button.cjs +32 -2
  39. package/dist/button.cjs.map +1 -1
  40. package/dist/button.d.cts +19 -3
  41. package/dist/button.d.ts +19 -3
  42. package/dist/button.js +32 -2
  43. package/dist/button.js.map +1 -1
  44. package/dist/card-bleed.cjs +458 -0
  45. package/dist/card-bleed.cjs.map +1 -0
  46. package/dist/card-bleed.d.cts +37 -0
  47. package/dist/card-bleed.d.ts +37 -0
  48. package/dist/card-bleed.js +455 -0
  49. package/dist/card-bleed.js.map +1 -0
  50. package/dist/card.cjs +27 -1
  51. package/dist/card.cjs.map +1 -1
  52. package/dist/card.d.cts +19 -3
  53. package/dist/card.d.ts +19 -3
  54. package/dist/card.js +27 -1
  55. package/dist/card.js.map +1 -1
  56. package/dist/carousel.cjs +655 -0
  57. package/dist/carousel.cjs.map +1 -0
  58. package/dist/carousel.d.cts +79 -0
  59. package/dist/carousel.d.ts +79 -0
  60. package/dist/carousel.js +652 -0
  61. package/dist/carousel.js.map +1 -0
  62. package/dist/checkbox.cjs +3 -1
  63. package/dist/checkbox.cjs.map +1 -1
  64. package/dist/checkbox.js +3 -1
  65. package/dist/checkbox.js.map +1 -1
  66. package/dist/choice-card.cjs +524 -0
  67. package/dist/choice-card.cjs.map +1 -0
  68. package/dist/choice-card.d.cts +81 -0
  69. package/dist/choice-card.d.ts +81 -0
  70. package/dist/choice-card.js +521 -0
  71. package/dist/choice-card.js.map +1 -0
  72. package/dist/container.cjs +23 -6
  73. package/dist/container.cjs.map +1 -1
  74. package/dist/container.d.cts +9 -3
  75. package/dist/container.d.ts +9 -3
  76. package/dist/container.js +23 -7
  77. package/dist/container.js.map +1 -1
  78. package/dist/datepicker.cjs +580 -0
  79. package/dist/datepicker.cjs.map +1 -0
  80. package/dist/datepicker.d.cts +78 -0
  81. package/dist/datepicker.d.ts +78 -0
  82. package/dist/datepicker.js +577 -0
  83. package/dist/datepicker.js.map +1 -0
  84. package/dist/dom-CX9bgbcQ.d.cts +3 -0
  85. package/dist/dom-CX9bgbcQ.d.ts +3 -0
  86. package/dist/dropdown.cjs +24 -0
  87. package/dist/dropdown.cjs.map +1 -1
  88. package/dist/dropdown.d.cts +3 -2
  89. package/dist/dropdown.d.ts +3 -2
  90. package/dist/dropdown.js +25 -1
  91. package/dist/dropdown.js.map +1 -1
  92. package/dist/external-auth-button.cjs +494 -0
  93. package/dist/external-auth-button.cjs.map +1 -0
  94. package/dist/external-auth-button.d.cts +71 -0
  95. package/dist/external-auth-button.d.ts +71 -0
  96. package/dist/external-auth-button.js +491 -0
  97. package/dist/external-auth-button.js.map +1 -0
  98. package/dist/fieldset.cjs +3 -1
  99. package/dist/fieldset.cjs.map +1 -1
  100. package/dist/fieldset.js +3 -1
  101. package/dist/fieldset.js.map +1 -1
  102. package/dist/file-input.cjs +371 -0
  103. package/dist/file-input.cjs.map +1 -0
  104. package/dist/file-input.d.cts +96 -0
  105. package/dist/file-input.d.ts +96 -0
  106. package/dist/file-input.js +367 -0
  107. package/dist/file-input.js.map +1 -0
  108. package/dist/footer-chip.cjs +22 -2
  109. package/dist/footer-chip.cjs.map +1 -1
  110. package/dist/footer-chip.d.cts +12 -1
  111. package/dist/footer-chip.d.ts +12 -1
  112. package/dist/footer-chip.js +22 -2
  113. package/dist/footer-chip.js.map +1 -1
  114. package/dist/footer-link.cjs +19 -1
  115. package/dist/footer-link.cjs.map +1 -1
  116. package/dist/footer-link.d.cts +12 -1
  117. package/dist/footer-link.d.ts +12 -1
  118. package/dist/footer-link.js +19 -1
  119. package/dist/footer-link.js.map +1 -1
  120. package/dist/footer.cjs +30 -1
  121. package/dist/footer.cjs.map +1 -1
  122. package/dist/footer.d.cts +2 -1
  123. package/dist/footer.d.ts +2 -1
  124. package/dist/footer.js +31 -2
  125. package/dist/footer.js.map +1 -1
  126. package/dist/{form-DpPtizpY.d.cts → form-CVO7mlDa.d.cts} +38 -9
  127. package/dist/{form-DpPtizpY.d.ts → form-CVO7mlDa.d.ts} +38 -9
  128. package/dist/grid.cjs +35 -1
  129. package/dist/grid.cjs.map +1 -1
  130. package/dist/grid.d.cts +9 -3
  131. package/dist/grid.d.ts +9 -3
  132. package/dist/grid.js +35 -2
  133. package/dist/grid.js.map +1 -1
  134. package/dist/icon-box.cjs +27 -1
  135. package/dist/icon-box.cjs.map +1 -1
  136. package/dist/icon-box.d.cts +19 -3
  137. package/dist/icon-box.d.ts +19 -3
  138. package/dist/icon-box.js +27 -1
  139. package/dist/icon-box.js.map +1 -1
  140. package/dist/index.cjs +3654 -107
  141. package/dist/index.cjs.map +1 -1
  142. package/dist/index.d.cts +26 -1
  143. package/dist/index.d.ts +26 -1
  144. package/dist/index.js +3594 -110
  145. package/dist/index.js.map +1 -1
  146. package/dist/input-group.cjs +471 -0
  147. package/dist/input-group.cjs.map +1 -0
  148. package/dist/input-group.d.cts +31 -0
  149. package/dist/input-group.d.ts +31 -0
  150. package/dist/input-group.js +468 -0
  151. package/dist/input-group.js.map +1 -0
  152. package/dist/input.cjs +96 -4
  153. package/dist/input.cjs.map +1 -1
  154. package/dist/input.d.cts +45 -6
  155. package/dist/input.d.ts +45 -6
  156. package/dist/input.js +98 -6
  157. package/dist/input.js.map +1 -1
  158. package/dist/label.cjs +3 -1
  159. package/dist/label.cjs.map +1 -1
  160. package/dist/label.js +3 -1
  161. package/dist/label.js.map +1 -1
  162. package/dist/list-group-item.cjs +367 -0
  163. package/dist/list-group-item.cjs.map +1 -0
  164. package/dist/list-group-item.d.cts +73 -0
  165. package/dist/list-group-item.d.ts +73 -0
  166. package/dist/list-group-item.js +364 -0
  167. package/dist/list-group-item.js.map +1 -0
  168. package/dist/list-group.cjs +610 -0
  169. package/dist/list-group.cjs.map +1 -0
  170. package/dist/list-group.d.cts +58 -0
  171. package/dist/list-group.d.ts +58 -0
  172. package/dist/list-group.js +607 -0
  173. package/dist/list-group.js.map +1 -0
  174. package/dist/modal.cjs +38 -35
  175. package/dist/modal.cjs.map +1 -1
  176. package/dist/modal.d.cts +1 -3
  177. package/dist/modal.d.ts +1 -3
  178. package/dist/modal.js +38 -35
  179. package/dist/modal.js.map +1 -1
  180. package/dist/nav-item.cjs +107 -4
  181. package/dist/nav-item.cjs.map +1 -1
  182. package/dist/nav-item.d.cts +52 -2
  183. package/dist/nav-item.d.ts +52 -2
  184. package/dist/nav-item.js +108 -5
  185. package/dist/nav-item.js.map +1 -1
  186. package/dist/nav.cjs +25 -1
  187. package/dist/nav.cjs.map +1 -1
  188. package/dist/nav.d.cts +2 -1
  189. package/dist/nav.d.ts +2 -1
  190. package/dist/nav.js +26 -2
  191. package/dist/nav.js.map +1 -1
  192. package/dist/offcanvas.cjs +621 -0
  193. package/dist/offcanvas.cjs.map +1 -0
  194. package/dist/offcanvas.d.cts +61 -0
  195. package/dist/offcanvas.d.ts +61 -0
  196. package/dist/offcanvas.js +617 -0
  197. package/dist/offcanvas.js.map +1 -0
  198. package/dist/pagination.cjs +452 -0
  199. package/dist/pagination.cjs.map +1 -0
  200. package/dist/pagination.d.cts +69 -0
  201. package/dist/pagination.d.ts +69 -0
  202. package/dist/pagination.js +448 -0
  203. package/dist/pagination.js.map +1 -0
  204. package/dist/popover.cjs +534 -0
  205. package/dist/popover.cjs.map +1 -0
  206. package/dist/popover.d.cts +59 -0
  207. package/dist/popover.d.ts +59 -0
  208. package/dist/popover.js +530 -0
  209. package/dist/popover.js.map +1 -0
  210. package/dist/pricing-card.cjs +121 -64
  211. package/dist/pricing-card.cjs.map +1 -1
  212. package/dist/pricing-card.d.cts +21 -7
  213. package/dist/pricing-card.d.ts +21 -7
  214. package/dist/pricing-card.js +122 -65
  215. package/dist/pricing-card.js.map +1 -1
  216. package/dist/progress.cjs +403 -0
  217. package/dist/progress.cjs.map +1 -0
  218. package/dist/progress.d.cts +70 -0
  219. package/dist/progress.d.ts +70 -0
  220. package/dist/progress.js +398 -0
  221. package/dist/progress.js.map +1 -0
  222. package/dist/prose.cjs +425 -0
  223. package/dist/prose.cjs.map +1 -0
  224. package/dist/prose.d.cts +21 -0
  225. package/dist/prose.d.ts +21 -0
  226. package/dist/prose.js +422 -0
  227. package/dist/prose.js.map +1 -0
  228. package/dist/radio.cjs +3 -1
  229. package/dist/radio.cjs.map +1 -1
  230. package/dist/radio.js +3 -1
  231. package/dist/radio.js.map +1 -1
  232. package/dist/range.cjs +381 -0
  233. package/dist/range.cjs.map +1 -0
  234. package/dist/range.d.cts +76 -0
  235. package/dist/range.d.ts +76 -0
  236. package/dist/range.js +378 -0
  237. package/dist/range.js.map +1 -0
  238. package/dist/rating.cjs +33 -0
  239. package/dist/rating.cjs.map +1 -1
  240. package/dist/rating.d.cts +38 -3
  241. package/dist/rating.d.ts +38 -3
  242. package/dist/rating.js +33 -0
  243. package/dist/rating.js.map +1 -1
  244. package/dist/section.cjs +27 -3
  245. package/dist/section.cjs.map +1 -1
  246. package/dist/section.d.cts +16 -1
  247. package/dist/section.d.ts +16 -1
  248. package/dist/section.js +27 -4
  249. package/dist/section.js.map +1 -1
  250. package/dist/select.cjs +6 -1
  251. package/dist/select.cjs.map +1 -1
  252. package/dist/select.d.cts +7 -1
  253. package/dist/select.d.ts +7 -1
  254. package/dist/select.js +6 -1
  255. package/dist/select.js.map +1 -1
  256. package/dist/sidebar-link.cjs +19 -1
  257. package/dist/sidebar-link.cjs.map +1 -1
  258. package/dist/sidebar-link.d.cts +13 -2
  259. package/dist/sidebar-link.d.ts +13 -2
  260. package/dist/sidebar-link.js +19 -1
  261. package/dist/sidebar-link.js.map +1 -1
  262. package/dist/sidebar-toggle.cjs +3 -1
  263. package/dist/sidebar-toggle.cjs.map +1 -1
  264. package/dist/sidebar-toggle.js +3 -1
  265. package/dist/sidebar-toggle.js.map +1 -1
  266. package/dist/sidebar.cjs +33 -1
  267. package/dist/sidebar.cjs.map +1 -1
  268. package/dist/sidebar.d.cts +1 -0
  269. package/dist/sidebar.d.ts +1 -0
  270. package/dist/sidebar.js +34 -2
  271. package/dist/sidebar.js.map +1 -1
  272. package/dist/spinner.cjs +2 -1
  273. package/dist/spinner.cjs.map +1 -1
  274. package/dist/spinner.d.cts +2 -2
  275. package/dist/spinner.d.ts +2 -2
  276. package/dist/spinner.js +2 -1
  277. package/dist/spinner.js.map +1 -1
  278. package/dist/stack.cjs +4 -2
  279. package/dist/stack.cjs.map +1 -1
  280. package/dist/stack.d.cts +2 -2
  281. package/dist/stack.d.ts +2 -2
  282. package/dist/stack.js +4 -2
  283. package/dist/stack.js.map +1 -1
  284. package/dist/states-Bgzwu_XZ.d.cts +9 -0
  285. package/dist/states-Bgzwu_XZ.d.ts +9 -0
  286. package/dist/stepper.cjs +495 -0
  287. package/dist/stepper.cjs.map +1 -0
  288. package/dist/stepper.d.cts +40 -0
  289. package/dist/stepper.d.ts +40 -0
  290. package/dist/stepper.js +491 -0
  291. package/dist/stepper.js.map +1 -0
  292. package/dist/switch.cjs +492 -0
  293. package/dist/switch.cjs.map +1 -0
  294. package/dist/switch.d.cts +82 -0
  295. package/dist/switch.d.ts +82 -0
  296. package/dist/switch.js +488 -0
  297. package/dist/switch.js.map +1 -0
  298. package/dist/tab-panel.cjs +465 -0
  299. package/dist/tab-panel.cjs.map +1 -0
  300. package/dist/tab-panel.d.cts +48 -0
  301. package/dist/tab-panel.d.ts +48 -0
  302. package/dist/tab-panel.js +462 -0
  303. package/dist/tab-panel.js.map +1 -0
  304. package/dist/table.cjs +506 -0
  305. package/dist/table.cjs.map +1 -0
  306. package/dist/table.d.cts +54 -0
  307. package/dist/table.d.ts +54 -0
  308. package/dist/table.js +501 -0
  309. package/dist/table.js.map +1 -0
  310. package/dist/tabs.cjs +596 -0
  311. package/dist/tabs.cjs.map +1 -0
  312. package/dist/tabs.d.cts +65 -0
  313. package/dist/tabs.d.ts +65 -0
  314. package/dist/tabs.js +592 -0
  315. package/dist/tabs.js.map +1 -0
  316. package/dist/tag.cjs +27 -1
  317. package/dist/tag.cjs.map +1 -1
  318. package/dist/tag.d.cts +19 -3
  319. package/dist/tag.d.ts +19 -3
  320. package/dist/tag.js +27 -1
  321. package/dist/tag.js.map +1 -1
  322. package/dist/testimonial.cjs +130 -64
  323. package/dist/testimonial.cjs.map +1 -1
  324. package/dist/testimonial.d.cts +23 -8
  325. package/dist/testimonial.d.ts +23 -8
  326. package/dist/testimonial.js +131 -65
  327. package/dist/testimonial.js.map +1 -1
  328. package/dist/text.cjs +65 -6
  329. package/dist/text.cjs.map +1 -1
  330. package/dist/text.d.cts +24 -3
  331. package/dist/text.d.ts +24 -3
  332. package/dist/text.js +64 -8
  333. package/dist/text.js.map +1 -1
  334. package/dist/textarea.cjs +3 -0
  335. package/dist/textarea.cjs.map +1 -1
  336. package/dist/textarea.d.cts +7 -1
  337. package/dist/textarea.d.ts +7 -1
  338. package/dist/textarea.js +3 -0
  339. package/dist/textarea.js.map +1 -1
  340. package/dist/toast.cjs +2 -1
  341. package/dist/toast.cjs.map +1 -1
  342. package/dist/toast.d.cts +2 -2
  343. package/dist/toast.d.ts +2 -2
  344. package/dist/toast.js +2 -1
  345. package/dist/toast.js.map +1 -1
  346. package/dist/tooltip.cjs.map +1 -1
  347. package/dist/tooltip.d.cts +2 -2
  348. package/dist/tooltip.d.ts +2 -2
  349. package/dist/tooltip.js.map +1 -1
  350. package/package.json +126 -11
@@ -0,0 +1,652 @@
1
+ import { svg, LitElement, nothing, html } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { getCarouselCaptionClasses, getCarouselClasses, getCarouselViewportClasses, getCarouselSlideClasses, getCarouselControlClasses, getCarouselIndicatorsClasses, getCarouselIndicatorClasses } from '@phcdevworks/spectre-ui';
4
+
5
+ // src/components/carousel/sp-carousel.ts
6
+ var SpectreBaseElement = class extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this._ariaLabel = null;
10
+ this._ariaLabelledBy = null;
11
+ this._ariaDescribedBy = null;
12
+ this._autocapitalize = "";
13
+ this._autofocus = false;
14
+ this._spellcheck = null;
15
+ this._title = "";
16
+ this._id = "";
17
+ }
18
+ get ariaLabel() {
19
+ return this._ariaLabel;
20
+ }
21
+ set ariaLabel(value) {
22
+ if (this._ariaLabel === value) {
23
+ return;
24
+ }
25
+ this._ariaLabel = value;
26
+ this._removeHostAttribute("aria-label");
27
+ this.requestUpdate();
28
+ }
29
+ get ariaLabelledBy() {
30
+ return this._ariaLabelledBy;
31
+ }
32
+ set ariaLabelledBy(value) {
33
+ if (this._ariaLabelledBy === value) {
34
+ return;
35
+ }
36
+ this._ariaLabelledBy = value;
37
+ this._removeHostAttribute("aria-labelledby");
38
+ this.requestUpdate();
39
+ }
40
+ get ariaDescribedBy() {
41
+ return this._ariaDescribedBy;
42
+ }
43
+ set ariaDescribedBy(value) {
44
+ if (this._ariaDescribedBy === value) {
45
+ return;
46
+ }
47
+ this._ariaDescribedBy = value;
48
+ this._removeHostAttribute("aria-describedby");
49
+ this.requestUpdate();
50
+ }
51
+ get autocapitalize() {
52
+ return this._autocapitalize;
53
+ }
54
+ set autocapitalize(value) {
55
+ const normalizedValue = value ?? "";
56
+ if (this._autocapitalize === normalizedValue) {
57
+ return;
58
+ }
59
+ this._autocapitalize = normalizedValue;
60
+ this._removeHostAttribute("autocapitalize");
61
+ this.requestUpdate();
62
+ }
63
+ get spellcheck() {
64
+ return this._spellcheck ?? super.spellcheck;
65
+ }
66
+ set spellcheck(value) {
67
+ if (this._spellcheck === value) {
68
+ return;
69
+ }
70
+ this._spellcheck = value ?? null;
71
+ this._removeHostAttribute("spellcheck");
72
+ this.requestUpdate();
73
+ }
74
+ get title() {
75
+ return this._title;
76
+ }
77
+ set title(value) {
78
+ const normalizedValue = value ?? "";
79
+ if (this._title === normalizedValue) {
80
+ return;
81
+ }
82
+ this._title = normalizedValue;
83
+ this._removeHostAttribute("title");
84
+ this.requestUpdate();
85
+ }
86
+ get id() {
87
+ return this._id;
88
+ }
89
+ set id(value) {
90
+ const normalizedValue = value ?? "";
91
+ if (this._id === normalizedValue) {
92
+ return;
93
+ }
94
+ this._id = normalizedValue;
95
+ this._removeHostAttribute("id");
96
+ this.requestUpdate();
97
+ }
98
+ get autofocus() {
99
+ return this._autofocus;
100
+ }
101
+ set autofocus(value) {
102
+ const normalizedValue = !!value;
103
+ if (this._autofocus === normalizedValue) {
104
+ return;
105
+ }
106
+ this._autofocus = normalizedValue;
107
+ this._removeHostAttribute("autofocus");
108
+ this.requestUpdate();
109
+ }
110
+ // Spectre components intentionally render in light DOM so the global
111
+ // `@phcdevworks/spectre-ui` styling contract can apply directly.
112
+ createRenderRoot() {
113
+ return this;
114
+ }
115
+ connectedCallback() {
116
+ super.connectedCallback();
117
+ const proxiedAttributes = [
118
+ "id",
119
+ "title",
120
+ "autocapitalize",
121
+ "autofocus",
122
+ "spellcheck",
123
+ "aria-label",
124
+ "aria-labelledby",
125
+ "aria-describedby"
126
+ ];
127
+ proxiedAttributes.forEach((attr) => {
128
+ const value = super.getAttribute(attr);
129
+ if (value !== null) {
130
+ this.setAttribute(attr, value);
131
+ }
132
+ });
133
+ }
134
+ getAttribute(qualifiedName) {
135
+ switch (qualifiedName) {
136
+ case "id":
137
+ return this.id || null;
138
+ case "title":
139
+ return this.title || null;
140
+ case "autocapitalize":
141
+ return this.autocapitalize || null;
142
+ case "autofocus":
143
+ return this.autofocus ? "" : null;
144
+ case "spellcheck":
145
+ return this._spellcheck !== null ? String(this._spellcheck) : null;
146
+ case "aria-label":
147
+ return this.ariaLabel;
148
+ case "aria-labelledby":
149
+ return this.ariaLabelledBy;
150
+ case "aria-describedby":
151
+ return this.ariaDescribedBy;
152
+ default:
153
+ return super.getAttribute(qualifiedName);
154
+ }
155
+ }
156
+ hasAttribute(qualifiedName) {
157
+ switch (qualifiedName) {
158
+ case "id":
159
+ return this.id !== "";
160
+ case "title":
161
+ return this.title !== "";
162
+ case "autocapitalize":
163
+ return this.autocapitalize !== "";
164
+ case "autofocus":
165
+ return this.autofocus;
166
+ case "spellcheck":
167
+ return this._spellcheck !== null;
168
+ case "aria-label":
169
+ return this.ariaLabel !== null;
170
+ case "aria-labelledby":
171
+ return this.ariaLabelledBy !== null;
172
+ case "aria-describedby":
173
+ return this.ariaDescribedBy !== null;
174
+ default:
175
+ return super.hasAttribute(qualifiedName);
176
+ }
177
+ }
178
+ setAttribute(qualifiedName, value) {
179
+ switch (qualifiedName) {
180
+ case "id":
181
+ this.id = value;
182
+ break;
183
+ case "title":
184
+ this.title = value;
185
+ break;
186
+ case "autocapitalize":
187
+ this.autocapitalize = value;
188
+ break;
189
+ case "autofocus":
190
+ this.autofocus = true;
191
+ break;
192
+ case "spellcheck":
193
+ this.spellcheck = value !== "false";
194
+ break;
195
+ case "aria-label":
196
+ this.ariaLabel = value;
197
+ break;
198
+ case "aria-labelledby":
199
+ this.ariaLabelledBy = value;
200
+ break;
201
+ case "aria-describedby":
202
+ this.ariaDescribedBy = value;
203
+ break;
204
+ default:
205
+ super.setAttribute(qualifiedName, value);
206
+ }
207
+ }
208
+ removeAttribute(qualifiedName) {
209
+ switch (qualifiedName) {
210
+ case "id":
211
+ this.id = "";
212
+ break;
213
+ case "title":
214
+ this.title = "";
215
+ break;
216
+ case "autocapitalize":
217
+ this.autocapitalize = "";
218
+ break;
219
+ case "autofocus":
220
+ this.autofocus = false;
221
+ break;
222
+ case "spellcheck":
223
+ this.spellcheck = null;
224
+ break;
225
+ case "aria-label":
226
+ this.ariaLabel = null;
227
+ break;
228
+ case "aria-labelledby":
229
+ this.ariaLabelledBy = null;
230
+ break;
231
+ case "aria-describedby":
232
+ this.ariaDescribedBy = null;
233
+ break;
234
+ default:
235
+ super.removeAttribute(qualifiedName);
236
+ }
237
+ }
238
+ _removeHostAttribute(name) {
239
+ const host = this;
240
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
241
+ HTMLElement.prototype.removeAttribute.call(host, name);
242
+ }
243
+ }
244
+ get forwardedAriaLabel() {
245
+ const value = this.ariaLabel?.trim();
246
+ return value ? value : void 0;
247
+ }
248
+ get forwardedAriaLabelledBy() {
249
+ const value = this.ariaLabelledBy?.trim();
250
+ return value ? value : void 0;
251
+ }
252
+ get forwardedAriaDescribedBy() {
253
+ const value = this.ariaDescribedBy?.trim();
254
+ return value ? value : void 0;
255
+ }
256
+ // Subclasses that expose `disabled`/`loading` properties get this disabled
257
+ // calculation for free instead of redeclaring it per component.
258
+ get isDisabled() {
259
+ const self = this;
260
+ return (self.disabled ?? false) || (self.loading ?? false);
261
+ }
262
+ // Subclasses get this for free instead of redeclaring it per component.
263
+ get hasForwardedLabel() {
264
+ return Boolean(this.forwardedAriaLabel || this.forwardedAriaLabelledBy);
265
+ }
266
+ };
267
+ SpectreBaseElement.properties = {};
268
+ function normalizeInt(value, fallback, min = 0) {
269
+ if (value == null || typeof value !== "number" || !Number.isInteger(value) || value < min) {
270
+ return fallback;
271
+ }
272
+ return value;
273
+ }
274
+ var paths = {
275
+ check: svg`<path d="M3 8.5l3 3 7-7" />`,
276
+ chevronDown: svg`<path d="M4 6l4 4 4-4" />`,
277
+ chevronLeft: svg`<path d="M10 4l-4 4 4 4" />`,
278
+ chevronRight: svg`<path d="M6 4l4 4-4 4" />`,
279
+ close: svg`<path d="M4 4l8 8M12 4l-8 8" />`
280
+ };
281
+ function renderIcon(name, sizeClass = "sp-icon-sm") {
282
+ return html`<svg
283
+ aria-hidden="true"
284
+ class="${sizeClass}"
285
+ fill="none"
286
+ focusable="false"
287
+ stroke="currentColor"
288
+ stroke-linecap="round"
289
+ stroke-linejoin="round"
290
+ stroke-width="2"
291
+ viewBox="0 0 16 16"
292
+ >
293
+ ${paths[name]}
294
+ </svg>`;
295
+ }
296
+
297
+ // src/utils/parts.ts
298
+ function applyPartClasses(elements, parts) {
299
+ for (const element of elements) {
300
+ const part = element.getAttribute("slot");
301
+ const classes = part ? parts[part] : void 0;
302
+ if (classes) {
303
+ element.classList.add(...classes.split(/\s+/).filter(Boolean));
304
+ }
305
+ }
306
+ }
307
+
308
+ // src/utils/dom.ts
309
+ function hasMeaningfulContent(nodes) {
310
+ return nodes.some((node) => {
311
+ if (node.nodeType === Node.ELEMENT_NODE) {
312
+ return true;
313
+ }
314
+ if (node.nodeType === Node.TEXT_NODE) {
315
+ return (node.textContent?.trim().length ?? 0) > 0;
316
+ }
317
+ return false;
318
+ });
319
+ }
320
+
321
+ // src/utils/projection.ts
322
+ function slotOf(node) {
323
+ if (node.nodeType !== Node.ELEMENT_NODE) {
324
+ return void 0;
325
+ }
326
+ return node.getAttribute("slot") ?? void 0;
327
+ }
328
+ var ProjectionController = class {
329
+ constructor(host, internalAttributes) {
330
+ this.host = host;
331
+ this.internalAttributes = internalAttributes;
332
+ this.projected = [];
333
+ host.addController(this);
334
+ }
335
+ hostConnected() {
336
+ this.sync();
337
+ this.observe();
338
+ }
339
+ hostDisconnected() {
340
+ this.disconnect();
341
+ }
342
+ hostUpdate() {
343
+ this.sync();
344
+ this.disconnect();
345
+ }
346
+ hostUpdated() {
347
+ this.observe();
348
+ }
349
+ // Every projected node in authored order, regardless of slot.
350
+ all() {
351
+ return [...this.projected];
352
+ }
353
+ // Omitting `slot` returns the nodes without a slot attribute.
354
+ nodes(slot) {
355
+ return this.projected.filter((node) => slotOf(node) === slot);
356
+ }
357
+ elements(slot) {
358
+ return this.nodes(slot).filter(
359
+ (node) => node.nodeType === Node.ELEMENT_NODE
360
+ );
361
+ }
362
+ has(slot) {
363
+ return hasMeaningfulContent(this.nodes(slot));
364
+ }
365
+ isInternalNode(node) {
366
+ return node.nodeType === Node.ELEMENT_NODE && this.internalAttributes.some(
367
+ (name) => node.hasAttribute(name)
368
+ );
369
+ }
370
+ isProjectable(node) {
371
+ if (node.nodeType === Node.COMMENT_NODE || this.isInternalNode(node)) {
372
+ return false;
373
+ }
374
+ if (node.nodeType === Node.TEXT_NODE && this.hostHasRendered) {
375
+ return Boolean(node.textContent?.trim());
376
+ }
377
+ return true;
378
+ }
379
+ get hostHasRendered() {
380
+ return this.host.hasUpdated;
381
+ }
382
+ sync() {
383
+ const next = [
384
+ .../* @__PURE__ */ new Set([
385
+ ...this.projected.filter((node) => this.host.contains(node)),
386
+ ...Array.from(this.host.childNodes).filter(
387
+ (node) => this.isProjectable(node)
388
+ )
389
+ ])
390
+ ];
391
+ const changed = next.length !== this.projected.length || next.some((node, index) => node !== this.projected[index]);
392
+ if (changed) {
393
+ this.projected = next;
394
+ }
395
+ return changed;
396
+ }
397
+ observe() {
398
+ if (this.observer || !this.host.isConnected) {
399
+ return;
400
+ }
401
+ this.observer = new MutationObserver(() => {
402
+ if (this.sync()) {
403
+ this.host.requestUpdate();
404
+ }
405
+ });
406
+ this.observer.observe(this.host, { childList: true });
407
+ }
408
+ disconnect() {
409
+ this.observer?.disconnect();
410
+ this.observer = void 0;
411
+ }
412
+ };
413
+ var SpectreCarouselElement = class extends SpectreBaseElement {
414
+ constructor() {
415
+ super(...arguments);
416
+ this.fade = false;
417
+ this.hideControls = false;
418
+ this.hideIndicators = false;
419
+ this.index = 0;
420
+ this.loop = false;
421
+ this.nextLabel = "Next slide";
422
+ this.previousLabel = "Previous slide";
423
+ this.indexFromScroll = false;
424
+ this.projection = new ProjectionController(this, [
425
+ "data-sp-carousel-native"
426
+ ]);
427
+ this.handleKeydown = (event) => {
428
+ if (event.key === "ArrowLeft") {
429
+ event.preventDefault();
430
+ this.goTo(this.activeIndex - 1);
431
+ } else if (event.key === "ArrowRight") {
432
+ event.preventDefault();
433
+ this.goTo(this.activeIndex + 1);
434
+ }
435
+ };
436
+ // Native swipes and scroll-snap move the viewport directly; follow them so
437
+ // the indicators and controls stay in sync.
438
+ this.handleScroll = (event) => {
439
+ const viewport = event.currentTarget;
440
+ if (this.fade || viewport.clientWidth === 0) {
441
+ return;
442
+ }
443
+ const target = Math.round(viewport.scrollLeft / viewport.clientWidth);
444
+ if (target === this.activeIndex || target >= this.slides.length) {
445
+ return;
446
+ }
447
+ this.indexFromScroll = true;
448
+ this.index = target;
449
+ this.dispatchEvent(
450
+ new CustomEvent("sp-change", { bubbles: true, detail: { index: target } })
451
+ );
452
+ };
453
+ }
454
+ get id() {
455
+ return super.id;
456
+ }
457
+ set id(value) {
458
+ super.id = value;
459
+ }
460
+ get title() {
461
+ return super.title;
462
+ }
463
+ set title(value) {
464
+ super.title = value;
465
+ }
466
+ connectedCallback() {
467
+ var _a;
468
+ super.connectedCallback();
469
+ (_a = this.style).display || (_a.display = "block");
470
+ }
471
+ willUpdate(changedProperties) {
472
+ if (changedProperties.has("fade") && this.fade == null) {
473
+ this.fade = false;
474
+ }
475
+ if (changedProperties.has("hideControls") && this.hideControls == null) {
476
+ this.hideControls = false;
477
+ }
478
+ if (changedProperties.has("hideIndicators") && this.hideIndicators == null) {
479
+ this.hideIndicators = false;
480
+ }
481
+ if (changedProperties.has("index")) {
482
+ this.index = normalizeInt(this.index, 0);
483
+ }
484
+ if (changedProperties.has("loop") && this.loop == null) {
485
+ this.loop = false;
486
+ }
487
+ if (changedProperties.has("nextLabel") && !this.nextLabel) {
488
+ this.nextLabel = "Next slide";
489
+ }
490
+ if (changedProperties.has("previousLabel") && !this.previousLabel) {
491
+ this.previousLabel = "Previous slide";
492
+ }
493
+ }
494
+ updated(changedProperties) {
495
+ super.updated(changedProperties);
496
+ this.slides.forEach((slide2) => {
497
+ applyPartClasses(slide2.querySelectorAll("[slot]"), {
498
+ caption: getCarouselCaptionClasses()
499
+ });
500
+ });
501
+ const scrolledByUser = this.indexFromScroll;
502
+ this.indexFromScroll = false;
503
+ if (this.fade || scrolledByUser || !changedProperties.has("index")) {
504
+ return;
505
+ }
506
+ const slide = this.slideWrappers[this.activeIndex];
507
+ if (slide && typeof this.viewport?.scrollTo === "function") {
508
+ this.viewport.scrollTo({ left: slide.offsetLeft });
509
+ }
510
+ }
511
+ get slides() {
512
+ return this.projection.elements();
513
+ }
514
+ get activeIndex() {
515
+ const last = this.slides.length - 1;
516
+ return Math.max(0, Math.min(this.index ?? 0, last));
517
+ }
518
+ get viewport() {
519
+ return this.querySelector("[data-sp-carousel-viewport]");
520
+ }
521
+ get slideWrappers() {
522
+ const viewport = this.viewport;
523
+ if (!viewport) {
524
+ return [];
525
+ }
526
+ return Array.from(viewport.children).filter(
527
+ (child) => child.hasAttribute("data-sp-carousel-slide")
528
+ );
529
+ }
530
+ goTo(target) {
531
+ const count = this.slides.length;
532
+ if (count === 0) {
533
+ return;
534
+ }
535
+ let next = target;
536
+ if (this.loop) {
537
+ next = (target % count + count) % count;
538
+ } else if (target < 0 || target >= count) {
539
+ return;
540
+ }
541
+ if (next === this.activeIndex) {
542
+ return;
543
+ }
544
+ this.index = next;
545
+ this.dispatchEvent(
546
+ new CustomEvent("sp-change", { bubbles: true, detail: { index: next } })
547
+ );
548
+ }
549
+ get regionLabel() {
550
+ if (this.forwardedAriaLabel) {
551
+ return this.forwardedAriaLabel;
552
+ }
553
+ return this.forwardedAriaLabelledBy ? void 0 : "Carousel";
554
+ }
555
+ render() {
556
+ const slides = this.slides;
557
+ const count = slides.length;
558
+ const active = this.activeIndex;
559
+ const loop = this.loop ?? false;
560
+ return html`<div
561
+ aria-label="${ifDefined(this.regionLabel)}"
562
+ aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
563
+ aria-roledescription="carousel"
564
+ class="${getCarouselClasses({ fade: this.fade ?? false })}"
565
+ data-sp-carousel-native
566
+ id="${ifDefined(this.id || void 0)}"
567
+ role="region"
568
+ title="${ifDefined(this.title || void 0)}"
569
+ @keydown="${this.handleKeydown}"
570
+ >
571
+ <div
572
+ aria-live="polite"
573
+ class="${getCarouselViewportClasses()}"
574
+ data-sp-carousel-viewport
575
+ @scroll="${this.handleScroll}"
576
+ >
577
+ ${slides.map(
578
+ (slide, index) => html`<div
579
+ aria-label="${index + 1} of ${count}"
580
+ aria-roledescription="slide"
581
+ class="${getCarouselSlideClasses({ active: index === active })}"
582
+ data-sp-carousel-slide
583
+ role="group"
584
+ >
585
+ ${slide}
586
+ </div>`
587
+ )}
588
+ </div>
589
+ ${!this.hideControls && count > 1 ? html`<button
590
+ aria-label="${this.previousLabel ?? "Previous slide"}"
591
+ class="${getCarouselControlClasses({ direction: "prev" })}"
592
+ data-sp-carousel-prev
593
+ ?disabled="${!loop && active === 0}"
594
+ type="button"
595
+ @click="${() => this.goTo(active - 1)}"
596
+ >
597
+ ${renderIcon("chevronLeft", "sp-icon-md")}
598
+ </button>
599
+ <button
600
+ aria-label="${this.nextLabel ?? "Next slide"}"
601
+ class="${getCarouselControlClasses({ direction: "next" })}"
602
+ data-sp-carousel-next
603
+ ?disabled="${!loop && active === count - 1}"
604
+ type="button"
605
+ @click="${() => this.goTo(active + 1)}"
606
+ >
607
+ ${renderIcon("chevronRight", "sp-icon-md")}
608
+ </button>` : nothing}
609
+ ${!this.hideIndicators && count > 1 ? html`<div class="${getCarouselIndicatorsClasses()}">
610
+ ${slides.map(
611
+ (_, index) => html`<button
612
+ aria-current="${ifDefined(
613
+ index === active ? "true" : void 0
614
+ )}"
615
+ aria-label="Go to slide ${index + 1}"
616
+ class="${getCarouselIndicatorClasses({
617
+ active: index === active
618
+ })}"
619
+ data-sp-carousel-indicator
620
+ type="button"
621
+ @click="${() => this.goTo(index)}"
622
+ ></button>`
623
+ )}
624
+ </div>` : nothing}
625
+ </div>`;
626
+ }
627
+ };
628
+ SpectreCarouselElement.properties = {
629
+ fade: { type: Boolean, reflect: true },
630
+ hideControls: { attribute: "hide-controls", type: Boolean, reflect: true },
631
+ hideIndicators: {
632
+ attribute: "hide-indicators",
633
+ type: Boolean,
634
+ reflect: true
635
+ },
636
+ index: { type: Number, reflect: true },
637
+ loop: { type: Boolean, reflect: true },
638
+ nextLabel: { attribute: "next-label", type: String },
639
+ previousLabel: { attribute: "previous-label", type: String }
640
+ };
641
+ function defineSpectreCarousel(tagName = "sp-carousel") {
642
+ const existingElement = customElements.get(tagName);
643
+ if (existingElement) {
644
+ return existingElement;
645
+ }
646
+ customElements.define(tagName, SpectreCarouselElement);
647
+ return SpectreCarouselElement;
648
+ }
649
+
650
+ export { SpectreCarouselElement, defineSpectreCarousel };
651
+ //# sourceMappingURL=carousel.js.map
652
+ //# sourceMappingURL=carousel.js.map