@phcdevworks/spectre-components 1.19.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 (352) hide show
  1. package/README.md +770 -125
  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 +83 -3
  27. package/dist/badge.cjs.map +1 -1
  28. package/dist/badge.d.cts +51 -3
  29. package/dist/badge.d.ts +51 -3
  30. package/dist/badge.js +83 -3
  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 +61 -1
  51. package/dist/card.cjs.map +1 -1
  52. package/dist/card.d.cts +33 -4
  53. package/dist/card.d.ts +33 -4
  54. package/dist/card.js +60 -2
  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 +66 -3
  87. package/dist/dropdown.cjs.map +1 -1
  88. package/dist/dropdown.d.cts +22 -2
  89. package/dist/dropdown.d.ts +22 -2
  90. package/dist/dropdown.js +67 -4
  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 +62 -1
  121. package/dist/footer.cjs.map +1 -1
  122. package/dist/footer.d.cts +15 -0
  123. package/dist/footer.d.ts +15 -0
  124. package/dist/footer.js +63 -2
  125. package/dist/footer.js.map +1 -1
  126. package/dist/{form-TvtLcoW0.d.cts → form-CVO7mlDa.d.cts} +42 -9
  127. package/dist/{form-TvtLcoW0.d.ts → form-CVO7mlDa.d.ts} +42 -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 +3849 -109
  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 +3787 -112
  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 +70 -35
  175. package/dist/modal.cjs.map +1 -1
  176. package/dist/modal.d.cts +14 -2
  177. package/dist/modal.d.ts +14 -2
  178. package/dist/modal.js +70 -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 +57 -1
  187. package/dist/nav.cjs.map +1 -1
  188. package/dist/nav.d.cts +15 -1
  189. package/dist/nav.d.ts +15 -1
  190. package/dist/nav.js +58 -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 +153 -64
  211. package/dist/pricing-card.cjs.map +1 -1
  212. package/dist/pricing-card.d.cts +34 -6
  213. package/dist/pricing-card.d.ts +34 -6
  214. package/dist/pricing-card.js +154 -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 +162 -64
  323. package/dist/testimonial.cjs.map +1 -1
  324. package/dist/testimonial.d.cts +36 -8
  325. package/dist/testimonial.d.ts +36 -8
  326. package/dist/testimonial.js +163 -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 +34 -1
  341. package/dist/toast.cjs.map +1 -1
  342. package/dist/toast.d.cts +15 -2
  343. package/dist/toast.d.ts +15 -2
  344. package/dist/toast.js +34 -1
  345. package/dist/toast.js.map +1 -1
  346. package/dist/tooltip.cjs +32 -0
  347. package/dist/tooltip.cjs.map +1 -1
  348. package/dist/tooltip.d.cts +15 -2
  349. package/dist/tooltip.d.ts +15 -2
  350. package/dist/tooltip.js +32 -0
  351. package/dist/tooltip.js.map +1 -1
  352. package/package.json +130 -15
@@ -0,0 +1,621 @@
1
+ 'use strict';
2
+
3
+ var lit = require('lit');
4
+ var ifDefined_js = require('lit/directives/if-defined.js');
5
+ var spectreUi = require('@phcdevworks/spectre-ui');
6
+
7
+ // src/components/offcanvas/sp-offcanvas.ts
8
+ var SpectreBaseElement = class extends lit.LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._ariaLabel = null;
12
+ this._ariaLabelledBy = null;
13
+ this._ariaDescribedBy = null;
14
+ this._autocapitalize = "";
15
+ this._autofocus = false;
16
+ this._spellcheck = null;
17
+ this._title = "";
18
+ this._id = "";
19
+ }
20
+ get ariaLabel() {
21
+ return this._ariaLabel;
22
+ }
23
+ set ariaLabel(value) {
24
+ if (this._ariaLabel === value) {
25
+ return;
26
+ }
27
+ this._ariaLabel = value;
28
+ this._removeHostAttribute("aria-label");
29
+ this.requestUpdate();
30
+ }
31
+ get ariaLabelledBy() {
32
+ return this._ariaLabelledBy;
33
+ }
34
+ set ariaLabelledBy(value) {
35
+ if (this._ariaLabelledBy === value) {
36
+ return;
37
+ }
38
+ this._ariaLabelledBy = value;
39
+ this._removeHostAttribute("aria-labelledby");
40
+ this.requestUpdate();
41
+ }
42
+ get ariaDescribedBy() {
43
+ return this._ariaDescribedBy;
44
+ }
45
+ set ariaDescribedBy(value) {
46
+ if (this._ariaDescribedBy === value) {
47
+ return;
48
+ }
49
+ this._ariaDescribedBy = value;
50
+ this._removeHostAttribute("aria-describedby");
51
+ this.requestUpdate();
52
+ }
53
+ get autocapitalize() {
54
+ return this._autocapitalize;
55
+ }
56
+ set autocapitalize(value) {
57
+ const normalizedValue = value ?? "";
58
+ if (this._autocapitalize === normalizedValue) {
59
+ return;
60
+ }
61
+ this._autocapitalize = normalizedValue;
62
+ this._removeHostAttribute("autocapitalize");
63
+ this.requestUpdate();
64
+ }
65
+ get spellcheck() {
66
+ return this._spellcheck ?? super.spellcheck;
67
+ }
68
+ set spellcheck(value) {
69
+ if (this._spellcheck === value) {
70
+ return;
71
+ }
72
+ this._spellcheck = value ?? null;
73
+ this._removeHostAttribute("spellcheck");
74
+ this.requestUpdate();
75
+ }
76
+ get title() {
77
+ return this._title;
78
+ }
79
+ set title(value) {
80
+ const normalizedValue = value ?? "";
81
+ if (this._title === normalizedValue) {
82
+ return;
83
+ }
84
+ this._title = normalizedValue;
85
+ this._removeHostAttribute("title");
86
+ this.requestUpdate();
87
+ }
88
+ get id() {
89
+ return this._id;
90
+ }
91
+ set id(value) {
92
+ const normalizedValue = value ?? "";
93
+ if (this._id === normalizedValue) {
94
+ return;
95
+ }
96
+ this._id = normalizedValue;
97
+ this._removeHostAttribute("id");
98
+ this.requestUpdate();
99
+ }
100
+ get autofocus() {
101
+ return this._autofocus;
102
+ }
103
+ set autofocus(value) {
104
+ const normalizedValue = !!value;
105
+ if (this._autofocus === normalizedValue) {
106
+ return;
107
+ }
108
+ this._autofocus = normalizedValue;
109
+ this._removeHostAttribute("autofocus");
110
+ this.requestUpdate();
111
+ }
112
+ // Spectre components intentionally render in light DOM so the global
113
+ // `@phcdevworks/spectre-ui` styling contract can apply directly.
114
+ createRenderRoot() {
115
+ return this;
116
+ }
117
+ connectedCallback() {
118
+ super.connectedCallback();
119
+ const proxiedAttributes = [
120
+ "id",
121
+ "title",
122
+ "autocapitalize",
123
+ "autofocus",
124
+ "spellcheck",
125
+ "aria-label",
126
+ "aria-labelledby",
127
+ "aria-describedby"
128
+ ];
129
+ proxiedAttributes.forEach((attr) => {
130
+ const value = super.getAttribute(attr);
131
+ if (value !== null) {
132
+ this.setAttribute(attr, value);
133
+ }
134
+ });
135
+ }
136
+ getAttribute(qualifiedName) {
137
+ switch (qualifiedName) {
138
+ case "id":
139
+ return this.id || null;
140
+ case "title":
141
+ return this.title || null;
142
+ case "autocapitalize":
143
+ return this.autocapitalize || null;
144
+ case "autofocus":
145
+ return this.autofocus ? "" : null;
146
+ case "spellcheck":
147
+ return this._spellcheck !== null ? String(this._spellcheck) : null;
148
+ case "aria-label":
149
+ return this.ariaLabel;
150
+ case "aria-labelledby":
151
+ return this.ariaLabelledBy;
152
+ case "aria-describedby":
153
+ return this.ariaDescribedBy;
154
+ default:
155
+ return super.getAttribute(qualifiedName);
156
+ }
157
+ }
158
+ hasAttribute(qualifiedName) {
159
+ switch (qualifiedName) {
160
+ case "id":
161
+ return this.id !== "";
162
+ case "title":
163
+ return this.title !== "";
164
+ case "autocapitalize":
165
+ return this.autocapitalize !== "";
166
+ case "autofocus":
167
+ return this.autofocus;
168
+ case "spellcheck":
169
+ return this._spellcheck !== null;
170
+ case "aria-label":
171
+ return this.ariaLabel !== null;
172
+ case "aria-labelledby":
173
+ return this.ariaLabelledBy !== null;
174
+ case "aria-describedby":
175
+ return this.ariaDescribedBy !== null;
176
+ default:
177
+ return super.hasAttribute(qualifiedName);
178
+ }
179
+ }
180
+ setAttribute(qualifiedName, value) {
181
+ switch (qualifiedName) {
182
+ case "id":
183
+ this.id = value;
184
+ break;
185
+ case "title":
186
+ this.title = value;
187
+ break;
188
+ case "autocapitalize":
189
+ this.autocapitalize = value;
190
+ break;
191
+ case "autofocus":
192
+ this.autofocus = true;
193
+ break;
194
+ case "spellcheck":
195
+ this.spellcheck = value !== "false";
196
+ break;
197
+ case "aria-label":
198
+ this.ariaLabel = value;
199
+ break;
200
+ case "aria-labelledby":
201
+ this.ariaLabelledBy = value;
202
+ break;
203
+ case "aria-describedby":
204
+ this.ariaDescribedBy = value;
205
+ break;
206
+ default:
207
+ super.setAttribute(qualifiedName, value);
208
+ }
209
+ }
210
+ removeAttribute(qualifiedName) {
211
+ switch (qualifiedName) {
212
+ case "id":
213
+ this.id = "";
214
+ break;
215
+ case "title":
216
+ this.title = "";
217
+ break;
218
+ case "autocapitalize":
219
+ this.autocapitalize = "";
220
+ break;
221
+ case "autofocus":
222
+ this.autofocus = false;
223
+ break;
224
+ case "spellcheck":
225
+ this.spellcheck = null;
226
+ break;
227
+ case "aria-label":
228
+ this.ariaLabel = null;
229
+ break;
230
+ case "aria-labelledby":
231
+ this.ariaLabelledBy = null;
232
+ break;
233
+ case "aria-describedby":
234
+ this.ariaDescribedBy = null;
235
+ break;
236
+ default:
237
+ super.removeAttribute(qualifiedName);
238
+ }
239
+ }
240
+ _removeHostAttribute(name) {
241
+ const host = this;
242
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
243
+ HTMLElement.prototype.removeAttribute.call(host, name);
244
+ }
245
+ }
246
+ get forwardedAriaLabel() {
247
+ const value = this.ariaLabel?.trim();
248
+ return value ? value : void 0;
249
+ }
250
+ get forwardedAriaLabelledBy() {
251
+ const value = this.ariaLabelledBy?.trim();
252
+ return value ? value : void 0;
253
+ }
254
+ get forwardedAriaDescribedBy() {
255
+ const value = this.ariaDescribedBy?.trim();
256
+ return value ? value : void 0;
257
+ }
258
+ // Subclasses that expose `disabled`/`loading` properties get this disabled
259
+ // calculation for free instead of redeclaring it per component.
260
+ get isDisabled() {
261
+ const self = this;
262
+ return (self.disabled ?? false) || (self.loading ?? false);
263
+ }
264
+ // Subclasses get this for free instead of redeclaring it per component.
265
+ get hasForwardedLabel() {
266
+ return Boolean(this.forwardedAriaLabel || this.forwardedAriaLabelledBy);
267
+ }
268
+ };
269
+ SpectreBaseElement.properties = {};
270
+
271
+ // src/utils/dom.ts
272
+ function hasMeaningfulContent(nodes) {
273
+ return nodes.some((node) => {
274
+ if (node.nodeType === Node.ELEMENT_NODE) {
275
+ return true;
276
+ }
277
+ if (node.nodeType === Node.TEXT_NODE) {
278
+ return (node.textContent?.trim().length ?? 0) > 0;
279
+ }
280
+ return false;
281
+ });
282
+ }
283
+ var idCounter = 0;
284
+ function createUniqueId(prefix) {
285
+ idCounter += 1;
286
+ return `${prefix}-${idCounter}`;
287
+ }
288
+
289
+ // src/utils/focus.ts
290
+ var FOCUSABLE_SELECTOR = [
291
+ "a[href]",
292
+ "button:not([disabled])",
293
+ "input:not([disabled])",
294
+ "select:not([disabled])",
295
+ "textarea:not([disabled])",
296
+ '[tabindex]:not([tabindex="-1"])'
297
+ ].join(",");
298
+ function getFocusableElements(root) {
299
+ if (!root) {
300
+ return [];
301
+ }
302
+ return Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR));
303
+ }
304
+ function trapFocus(event, root) {
305
+ const focusable = getFocusableElements(root);
306
+ if (focusable.length === 0) {
307
+ event.preventDefault();
308
+ return;
309
+ }
310
+ const first = focusable[0];
311
+ const last = focusable[focusable.length - 1];
312
+ const active = document.activeElement;
313
+ if (event.shiftKey && active === first) {
314
+ event.preventDefault();
315
+ last?.focus();
316
+ } else if (!event.shiftKey && active === last) {
317
+ event.preventDefault();
318
+ first?.focus();
319
+ }
320
+ }
321
+ var spectreOffcanvasPlacements = [
322
+ "start",
323
+ "end",
324
+ "top",
325
+ "bottom"
326
+ ];
327
+ function isOffcanvasPlacement(value) {
328
+ return spectreOffcanvasPlacements.includes(
329
+ value
330
+ );
331
+ }
332
+ var paths = {
333
+ check: lit.svg`<path d="M3 8.5l3 3 7-7" />`,
334
+ chevronDown: lit.svg`<path d="M4 6l4 4 4-4" />`,
335
+ chevronLeft: lit.svg`<path d="M10 4l-4 4 4 4" />`,
336
+ chevronRight: lit.svg`<path d="M6 4l4 4-4 4" />`,
337
+ close: lit.svg`<path d="M4 4l8 8M12 4l-8 8" />`
338
+ };
339
+ function renderIcon(name, sizeClass = "sp-icon-sm") {
340
+ return lit.html`<svg
341
+ aria-hidden="true"
342
+ class="${sizeClass}"
343
+ fill="none"
344
+ focusable="false"
345
+ stroke="currentColor"
346
+ stroke-linecap="round"
347
+ stroke-linejoin="round"
348
+ stroke-width="2"
349
+ viewBox="0 0 16 16"
350
+ >
351
+ ${paths[name]}
352
+ </svg>`;
353
+ }
354
+
355
+ // src/utils/projection.ts
356
+ function slotOf(node) {
357
+ if (node.nodeType !== Node.ELEMENT_NODE) {
358
+ return void 0;
359
+ }
360
+ return node.getAttribute("slot") ?? void 0;
361
+ }
362
+ var ProjectionController = class {
363
+ constructor(host, internalAttributes) {
364
+ this.host = host;
365
+ this.internalAttributes = internalAttributes;
366
+ this.projected = [];
367
+ host.addController(this);
368
+ }
369
+ hostConnected() {
370
+ this.sync();
371
+ this.observe();
372
+ }
373
+ hostDisconnected() {
374
+ this.disconnect();
375
+ }
376
+ hostUpdate() {
377
+ this.sync();
378
+ this.disconnect();
379
+ }
380
+ hostUpdated() {
381
+ this.observe();
382
+ }
383
+ // Every projected node in authored order, regardless of slot.
384
+ all() {
385
+ return [...this.projected];
386
+ }
387
+ // Omitting `slot` returns the nodes without a slot attribute.
388
+ nodes(slot) {
389
+ return this.projected.filter((node) => slotOf(node) === slot);
390
+ }
391
+ elements(slot) {
392
+ return this.nodes(slot).filter(
393
+ (node) => node.nodeType === Node.ELEMENT_NODE
394
+ );
395
+ }
396
+ has(slot) {
397
+ return hasMeaningfulContent(this.nodes(slot));
398
+ }
399
+ isInternalNode(node) {
400
+ return node.nodeType === Node.ELEMENT_NODE && this.internalAttributes.some(
401
+ (name) => node.hasAttribute(name)
402
+ );
403
+ }
404
+ isProjectable(node) {
405
+ if (node.nodeType === Node.COMMENT_NODE || this.isInternalNode(node)) {
406
+ return false;
407
+ }
408
+ if (node.nodeType === Node.TEXT_NODE && this.hostHasRendered) {
409
+ return Boolean(node.textContent?.trim());
410
+ }
411
+ return true;
412
+ }
413
+ get hostHasRendered() {
414
+ return this.host.hasUpdated;
415
+ }
416
+ sync() {
417
+ const next = [
418
+ .../* @__PURE__ */ new Set([
419
+ ...this.projected.filter((node) => this.host.contains(node)),
420
+ ...Array.from(this.host.childNodes).filter(
421
+ (node) => this.isProjectable(node)
422
+ )
423
+ ])
424
+ ];
425
+ const changed = next.length !== this.projected.length || next.some((node, index) => node !== this.projected[index]);
426
+ if (changed) {
427
+ this.projected = next;
428
+ }
429
+ return changed;
430
+ }
431
+ observe() {
432
+ if (this.observer || !this.host.isConnected) {
433
+ return;
434
+ }
435
+ this.observer = new MutationObserver(() => {
436
+ if (this.sync()) {
437
+ this.host.requestUpdate();
438
+ }
439
+ });
440
+ this.observer.observe(this.host, { childList: true });
441
+ }
442
+ disconnect() {
443
+ this.observer?.disconnect();
444
+ this.observer = void 0;
445
+ }
446
+ };
447
+ var SpectreOffcanvasElement = class extends SpectreBaseElement {
448
+ constructor() {
449
+ super(...arguments);
450
+ this.closeLabel = "Close";
451
+ this.label = void 0;
452
+ this.open = false;
453
+ this.placement = "start";
454
+ this.previouslyFocusedElement = null;
455
+ this.titleId = `${createUniqueId("sp-offcanvas")}-title`;
456
+ this.projection = new ProjectionController(this, [
457
+ "data-sp-offcanvas-backdrop",
458
+ "data-sp-offcanvas-native"
459
+ ]);
460
+ this.handleDocumentKeydown = (event) => {
461
+ if (!this.open) {
462
+ return;
463
+ }
464
+ if (event.key === "Escape") {
465
+ this.close();
466
+ } else if (event.key === "Tab") {
467
+ trapFocus(event, this.panelElement);
468
+ }
469
+ };
470
+ }
471
+ get id() {
472
+ return super.id;
473
+ }
474
+ set id(value) {
475
+ super.id = value;
476
+ }
477
+ get title() {
478
+ return super.title;
479
+ }
480
+ set title(value) {
481
+ super.title = value;
482
+ }
483
+ connectedCallback() {
484
+ super.connectedCallback();
485
+ document.addEventListener("keydown", this.handleDocumentKeydown);
486
+ }
487
+ disconnectedCallback() {
488
+ document.removeEventListener("keydown", this.handleDocumentKeydown);
489
+ super.disconnectedCallback();
490
+ }
491
+ willUpdate(changedProperties) {
492
+ if (changedProperties.has("closeLabel") && !this.closeLabel) {
493
+ this.closeLabel = "Close";
494
+ }
495
+ if (changedProperties.has("open") && this.open == null) {
496
+ this.open = false;
497
+ }
498
+ if (changedProperties.has("placement") && (this.placement == null || !isOffcanvasPlacement(this.placement))) {
499
+ this.placement = "start";
500
+ }
501
+ }
502
+ updated(changedProperties) {
503
+ super.updated(changedProperties);
504
+ if (!changedProperties.has("open")) {
505
+ return;
506
+ }
507
+ if (this.open) {
508
+ this.previouslyFocusedElement = document.activeElement;
509
+ this.focusPanel();
510
+ } else if (this.previouslyFocusedElement) {
511
+ this.previouslyFocusedElement.focus();
512
+ this.previouslyFocusedElement = null;
513
+ }
514
+ }
515
+ get panelElement() {
516
+ return this.querySelector("[data-sp-offcanvas-native]");
517
+ }
518
+ // The panel's `visibility` transitions in from `hidden`, so it cannot take
519
+ // focus until the slide-in finishes unless motion is disabled.
520
+ focusPanel() {
521
+ const panel = this.panelElement;
522
+ const focusFirst = () => {
523
+ const [first] = getFocusableElements(panel);
524
+ (first ?? panel)?.focus();
525
+ };
526
+ focusFirst();
527
+ if (panel && !panel.contains(document.activeElement)) {
528
+ panel.addEventListener(
529
+ "transitionend",
530
+ () => {
531
+ if (this.open) {
532
+ focusFirst();
533
+ }
534
+ },
535
+ { once: true }
536
+ );
537
+ }
538
+ }
539
+ close() {
540
+ if (!this.open) {
541
+ return;
542
+ }
543
+ this.open = false;
544
+ this.dispatchEvent(new CustomEvent("sp-close", { bubbles: true }));
545
+ }
546
+ get hasHeading() {
547
+ return this.projection.has("header") || Boolean(this.label);
548
+ }
549
+ get labelledBy() {
550
+ if (this.forwardedAriaLabelledBy) {
551
+ return this.forwardedAriaLabelledBy;
552
+ }
553
+ return this.hasHeading && !this.forwardedAriaLabel ? this.titleId : void 0;
554
+ }
555
+ render() {
556
+ const open = this.open ?? false;
557
+ return lit.html`<div
558
+ aria-hidden="true"
559
+ class="${spectreUi.getOffcanvasBackdropClasses({ open })}"
560
+ data-sp-offcanvas-backdrop
561
+ @click="${() => this.close()}"
562
+ ></div>
563
+ <div
564
+ aria-describedby="${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}"
565
+ aria-label="${ifDefined_js.ifDefined(this.forwardedAriaLabel)}"
566
+ aria-labelledby="${ifDefined_js.ifDefined(this.labelledBy)}"
567
+ aria-modal="true"
568
+ class="${spectreUi.getOffcanvasClasses({
569
+ open,
570
+ placement: this.placement
571
+ })}"
572
+ data-sp-offcanvas-native
573
+ id="${ifDefined_js.ifDefined(this.id || void 0)}"
574
+ ?inert="${!open}"
575
+ role="dialog"
576
+ tabindex="-1"
577
+ title="${ifDefined_js.ifDefined(this.title || void 0)}"
578
+ >
579
+ <div class="${spectreUi.getOffcanvasHeaderClasses()}">
580
+ <div id="${ifDefined_js.ifDefined(this.hasHeading ? this.titleId : void 0)}">
581
+ ${this.projection.has("header") ? this.projection.nodes("header") : this.label ?? lit.nothing}
582
+ </div>
583
+ <button
584
+ aria-label="${this.closeLabel ?? "Close"}"
585
+ class="${spectreUi.getButtonClasses({ size: "sm", variant: "ghost" })}"
586
+ data-sp-offcanvas-close
587
+ type="button"
588
+ @click="${() => this.close()}"
589
+ >
590
+ ${renderIcon("close")}
591
+ </button>
592
+ </div>
593
+ <div class="${spectreUi.getOffcanvasBodyClasses()}">
594
+ ${this.projection.nodes()}
595
+ </div>
596
+ ${this.projection.has("footer") ? lit.html`<div class="${spectreUi.getOffcanvasFooterClasses()}">
597
+ ${this.projection.nodes("footer")}
598
+ </div>` : lit.nothing}
599
+ </div>`;
600
+ }
601
+ };
602
+ SpectreOffcanvasElement.properties = {
603
+ closeLabel: { attribute: "close-label", type: String },
604
+ label: { type: String },
605
+ open: { type: Boolean, reflect: true },
606
+ placement: { type: String, reflect: true }
607
+ };
608
+ function defineSpectreOffcanvas(tagName = "sp-offcanvas") {
609
+ const existingElement = customElements.get(tagName);
610
+ if (existingElement) {
611
+ return existingElement;
612
+ }
613
+ customElements.define(tagName, SpectreOffcanvasElement);
614
+ return SpectreOffcanvasElement;
615
+ }
616
+
617
+ exports.SpectreOffcanvasElement = SpectreOffcanvasElement;
618
+ exports.defineSpectreOffcanvas = defineSpectreOffcanvas;
619
+ exports.spectreOffcanvasPlacements = spectreOffcanvasPlacements;
620
+ //# sourceMappingURL=offcanvas.cjs.map
621
+ //# sourceMappingURL=offcanvas.cjs.map