fulldev-ui 0.22.2 → 0.23.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 (251) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +6 -2
  3. package/liquid/LICENSE-DATA-SLOT.md +21 -0
  4. package/liquid/LICENSE-FULLDEV.txt +21 -0
  5. package/liquid/LICENSE-SHADCN.md +21 -0
  6. package/liquid/README.md +17 -0
  7. package/liquid/components/accordion.liquid +5 -0
  8. package/liquid/components/alert-dialog.liquid +116 -0
  9. package/liquid/components/alert.liquid +45 -0
  10. package/liquid/components/aspect-ratio.liquid +28 -0
  11. package/liquid/components/attachment.liquid +134 -0
  12. package/liquid/components/avatar.liquid +52 -0
  13. package/liquid/components/badge.liquid +86 -0
  14. package/liquid/components/banner.liquid +40 -0
  15. package/liquid/components/base.liquid +112 -0
  16. package/liquid/components/breadcrumb.liquid +46 -0
  17. package/liquid/components/button-group.liquid +56 -0
  18. package/liquid/components/button.liquid +232 -0
  19. package/liquid/components/card.liquid +5 -0
  20. package/liquid/components/carousel.liquid +5 -0
  21. package/liquid/components/checkbox.liquid +54 -0
  22. package/liquid/components/collapsible.liquid +3 -0
  23. package/liquid/components/combobox.liquid +87 -0
  24. package/liquid/components/command.liquid +86 -0
  25. package/liquid/components/dialog.liquid +80 -0
  26. package/liquid/components/drawer.liquid +97 -0
  27. package/liquid/components/dropdown-menu.liquid +3 -0
  28. package/liquid/components/empty.liquid +77 -0
  29. package/liquid/components/field.liquid +5 -0
  30. package/liquid/components/form.liquid +5 -0
  31. package/liquid/components/header.liquid +33 -0
  32. package/liquid/components/hover-card.liquid +3 -0
  33. package/liquid/components/icon.liquid +5 -0
  34. package/liquid/components/input-group.liquid +53 -0
  35. package/liquid/components/input.liquid +84 -0
  36. package/liquid/components/invalid-controls.liquid +18 -0
  37. package/liquid/components/item.liquid +114 -0
  38. package/liquid/components/kbd.liquid +20 -0
  39. package/liquid/components/logo.liquid +33 -0
  40. package/liquid/components/marquee.liquid +5 -0
  41. package/liquid/components/navigation-menu.liquid +5 -0
  42. package/liquid/components/pagination.liquid +32 -0
  43. package/liquid/components/popover.liquid +3 -0
  44. package/liquid/components/popup.liquid +189 -0
  45. package/liquid/components/price.liquid +5 -0
  46. package/liquid/components/radio-group.liquid +53 -0
  47. package/liquid/components/rating.liquid +5 -0
  48. package/liquid/components/section.liquid +5 -0
  49. package/liquid/components/select.liquid +51 -0
  50. package/liquid/components/separator.liquid +19 -0
  51. package/liquid/components/sheet.liquid +68 -0
  52. package/liquid/components/skeleton.liquid +17 -0
  53. package/liquid/components/slider.liquid +50 -0
  54. package/liquid/components/spinner.liquid +28 -0
  55. package/liquid/components/switch.liquid +54 -0
  56. package/liquid/components/table.liquid +64 -0
  57. package/liquid/components/tabs.liquid +88 -0
  58. package/liquid/components/toast.liquid +5 -0
  59. package/liquid/components/toc.liquid +45 -0
  60. package/liquid/components/toggle-group.liquid +77 -0
  61. package/liquid/components/toggle.liquid +61 -0
  62. package/liquid/components/tooltip.liquid +45 -0
  63. package/liquid/components/triggers.liquid +20 -0
  64. package/liquid/components/typography.liquid +5 -0
  65. package/liquid/components/video.liquid +5 -0
  66. package/liquid/contracts.json +428 -0
  67. package/liquid/examples/accordion.liquid +10 -0
  68. package/liquid/examples/alert-dialog.liquid +40 -0
  69. package/liquid/examples/alert.liquid +4 -0
  70. package/liquid/examples/aspect-ratio.liquid +1 -0
  71. package/liquid/examples/attachment.liquid +22 -0
  72. package/liquid/examples/avatar.liquid +1 -0
  73. package/liquid/examples/badge.liquid +5 -0
  74. package/liquid/examples/banner.liquid +3 -0
  75. package/liquid/examples/breadcrumb.liquid +7 -0
  76. package/liquid/examples/button-group.liquid +6 -0
  77. package/liquid/examples/button.liquid +8 -0
  78. package/liquid/examples/card.liquid +11 -0
  79. package/liquid/examples/carousel.liquid +12 -0
  80. package/liquid/examples/checkbox.liquid +4 -0
  81. package/liquid/examples/collapsible.liquid +29 -0
  82. package/liquid/examples/combobox.liquid +13 -0
  83. package/liquid/examples/command.liquid +10 -0
  84. package/liquid/examples/dependencies.json +60 -0
  85. package/liquid/examples/dialog.liquid +11 -0
  86. package/liquid/examples/drawer.liquid +18 -0
  87. package/liquid/examples/dropdown-menu.liquid +88 -0
  88. package/liquid/examples/empty.liquid +9 -0
  89. package/liquid/examples/field.liquid +105 -0
  90. package/liquid/examples/form.liquid +9 -0
  91. package/liquid/examples/header.liquid +8 -0
  92. package/liquid/examples/hover-card.liquid +16 -0
  93. package/liquid/examples/icon.liquid +3 -0
  94. package/liquid/examples/input-group.liquid +6 -0
  95. package/liquid/examples/input.liquid +4 -0
  96. package/liquid/examples/item.liquid +72 -0
  97. package/liquid/examples/kbd.liquid +1 -0
  98. package/liquid/examples/label.liquid +3 -0
  99. package/liquid/examples/logo.liquid +3 -0
  100. package/liquid/examples/marquee.liquid +5 -0
  101. package/liquid/examples/native-select.liquid +8 -0
  102. package/liquid/examples/navigation-menu.liquid +11 -0
  103. package/liquid/examples/pagination.liquid +11 -0
  104. package/liquid/examples/popover.liquid +14 -0
  105. package/liquid/examples/price.liquid +1 -0
  106. package/liquid/examples/radio-group.liquid +62 -0
  107. package/liquid/examples/rating.liquid +17 -0
  108. package/liquid/examples/section.liquid +9 -0
  109. package/liquid/examples/select.liquid +105 -0
  110. package/liquid/examples/separator.liquid +3 -0
  111. package/liquid/examples/sheet.liquid +11 -0
  112. package/liquid/examples/skeleton.liquid +5 -0
  113. package/liquid/examples/slider.liquid +46 -0
  114. package/liquid/examples/spinner.liquid +11 -0
  115. package/liquid/examples/switch.liquid +7 -0
  116. package/liquid/examples/table.liquid +37 -0
  117. package/liquid/examples/tabs.liquid +21 -0
  118. package/liquid/examples/textarea.liquid +9 -0
  119. package/liquid/examples/toast.liquid +47 -0
  120. package/liquid/examples/toc.liquid +11 -0
  121. package/liquid/examples/toggle-group.liquid +50 -0
  122. package/liquid/examples/toggle.liquid +21 -0
  123. package/liquid/examples/tooltip.liquid +33 -0
  124. package/liquid/examples/typography.liquid +9 -0
  125. package/liquid/examples/video.liquid +7 -0
  126. package/liquid/licenses.json +14 -0
  127. package/liquid/manifest.json +110 -0
  128. package/liquid/registry.json +1295 -0
  129. package/liquid/runtime/ui-carousel.js +44 -0
  130. package/liquid/runtime/ui-controls.js +195 -0
  131. package/liquid/runtime/ui-lifecycle.js +107 -0
  132. package/liquid/runtime/ui-motion.js +45 -0
  133. package/liquid/runtime/ui-start.js +37 -0
  134. package/liquid/snippets/init.liquid +6 -0
  135. package/liquid/snippets/runtime.liquid +9 -0
  136. package/liquid/snippets/ui.liquid +68 -0
  137. package/liquid/styles/accordion.css +66 -0
  138. package/liquid/styles/card.css +114 -0
  139. package/liquid/styles/carousel.css +58 -0
  140. package/liquid/styles/field.css +70 -0
  141. package/liquid/styles/form.css +14 -0
  142. package/liquid/styles/icon.css +32 -0
  143. package/liquid/styles/marquee.css +65 -0
  144. package/liquid/styles/navigation-menu.css +235 -0
  145. package/liquid/styles/price.css +41 -0
  146. package/liquid/styles/primitives.css +53 -0
  147. package/liquid/styles/rating.css +23 -0
  148. package/liquid/styles/section.css +92 -0
  149. package/liquid/styles/toast.css +125 -0
  150. package/liquid/styles/tokens.css +118 -0
  151. package/liquid/styles/typography.css +670 -0
  152. package/liquid/styles/video.css +10 -0
  153. package/liquid/vendor/data-slot-accordion.js +1 -0
  154. package/liquid/vendor/data-slot-alert-dialog.js +1 -0
  155. package/liquid/vendor/data-slot-carousel.js +1 -0
  156. package/liquid/vendor/data-slot-collapsible.js +1 -0
  157. package/liquid/vendor/data-slot-combobox.js +1 -0
  158. package/liquid/vendor/data-slot-command.js +1 -0
  159. package/liquid/vendor/data-slot-core.js +1 -0
  160. package/liquid/vendor/data-slot-dialog.js +1 -0
  161. package/liquid/vendor/data-slot-drawer.js +1 -0
  162. package/liquid/vendor/data-slot-dropdown-menu.js +1 -0
  163. package/liquid/vendor/data-slot-hover-card.js +1 -0
  164. package/liquid/vendor/data-slot-navigation-menu.js +1 -0
  165. package/liquid/vendor/data-slot-popover.js +1 -0
  166. package/liquid/vendor/data-slot-radio-group.js +1 -0
  167. package/liquid/vendor/data-slot-select.js +1 -0
  168. package/liquid/vendor/data-slot-slider.js +1 -0
  169. package/liquid/vendor/data-slot-switch.js +1 -0
  170. package/liquid/vendor/data-slot-tabs.js +1 -0
  171. package/liquid/vendor/data-slot-toast.js +8 -0
  172. package/liquid/vendor/data-slot-toggle-group.js +1 -0
  173. package/liquid/vendor/data-slot-toggle.js +1 -0
  174. package/liquid/vendor/data-slot-tooltip.js +1 -0
  175. package/liquid/vendor.json +180 -0
  176. package/package.json +16 -10
  177. package/public/r/liquid/accordion.json +25 -0
  178. package/public/r/liquid/alert-dialog.json +21 -0
  179. package/public/r/liquid/alert.json +18 -0
  180. package/public/r/liquid/aspect-ratio.json +18 -0
  181. package/public/r/liquid/attachment.json +20 -0
  182. package/public/r/liquid/avatar.json +18 -0
  183. package/public/r/liquid/badge.json +18 -0
  184. package/public/r/liquid/banner.json +18 -0
  185. package/public/r/liquid/breadcrumb.json +18 -0
  186. package/public/r/liquid/button-group.json +19 -0
  187. package/public/r/liquid/button.json +18 -0
  188. package/public/r/liquid/card.json +25 -0
  189. package/public/r/liquid/carousel.json +26 -0
  190. package/public/r/liquid/checkbox.json +19 -0
  191. package/public/r/liquid/collapsible.json +19 -0
  192. package/public/r/liquid/combobox.json +21 -0
  193. package/public/r/liquid/command.json +19 -0
  194. package/public/r/liquid/components.json +83 -0
  195. package/public/r/liquid/dialog.json +19 -0
  196. package/public/r/liquid/drawer.json +21 -0
  197. package/public/r/liquid/dropdown-menu.json +21 -0
  198. package/public/r/liquid/empty.json +18 -0
  199. package/public/r/liquid/field.json +25 -0
  200. package/public/r/liquid/form.json +25 -0
  201. package/public/r/liquid/header.json +19 -0
  202. package/public/r/liquid/hover-card.json +20 -0
  203. package/public/r/liquid/icon.json +24 -0
  204. package/public/r/liquid/init.json +34 -0
  205. package/public/r/liquid/input-group.json +20 -0
  206. package/public/r/liquid/input.json +18 -0
  207. package/public/r/liquid/invalid-controls.json +18 -0
  208. package/public/r/liquid/item.json +18 -0
  209. package/public/r/liquid/kbd.json +18 -0
  210. package/public/r/liquid/label.json +11 -0
  211. package/public/r/liquid/logo.json +18 -0
  212. package/public/r/liquid/marquee.json +25 -0
  213. package/public/r/liquid/native-select.json +11 -0
  214. package/public/r/liquid/navigation-menu.json +26 -0
  215. package/public/r/liquid/pagination.json +18 -0
  216. package/public/r/liquid/popover.json +21 -0
  217. package/public/r/liquid/popup.json +18 -0
  218. package/public/r/liquid/price.json +24 -0
  219. package/public/r/liquid/radio-group.json +20 -0
  220. package/public/r/liquid/rating.json +24 -0
  221. package/public/r/liquid/registry.json +1295 -0
  222. package/public/r/liquid/runtime.json +180 -0
  223. package/public/r/liquid/section.json +24 -0
  224. package/public/r/liquid/select.json +22 -0
  225. package/public/r/liquid/separator.json +18 -0
  226. package/public/r/liquid/sheet.json +20 -0
  227. package/public/r/liquid/skeleton.json +18 -0
  228. package/public/r/liquid/slider.json +19 -0
  229. package/public/r/liquid/spinner.json +18 -0
  230. package/public/r/liquid/switch.json +20 -0
  231. package/public/r/liquid/table.json +18 -0
  232. package/public/r/liquid/tabs.json +20 -0
  233. package/public/r/liquid/textarea.json +11 -0
  234. package/public/r/liquid/toast.json +27 -0
  235. package/public/r/liquid/toc.json +18 -0
  236. package/public/r/liquid/toggle-group.json +21 -0
  237. package/public/r/liquid/toggle.json +20 -0
  238. package/public/r/liquid/tooltip.json +20 -0
  239. package/public/r/liquid/triggers.json +18 -0
  240. package/public/r/liquid/typography.json +24 -0
  241. package/public/r/liquid/video.json +25 -0
  242. package/public/r/styles/base-luma/theme-toggle.json +1 -1
  243. package/public/r/styles/base-lyra/theme-toggle.json +1 -1
  244. package/public/r/styles/base-maia/theme-toggle.json +1 -1
  245. package/public/r/styles/base-mira/theme-toggle.json +1 -1
  246. package/public/r/styles/base-nova/theme-toggle.json +1 -1
  247. package/public/r/styles/base-rhea/theme-toggle.json +1 -1
  248. package/public/r/styles/base-sera/theme-toggle.json +1 -1
  249. package/public/r/styles/base-vega/theme-toggle.json +1 -1
  250. package/public/r/theme-toggle.json +1 -1
  251. package/src/components/ui/theme-toggle/theme-provider.astro +14 -0
@@ -0,0 +1,44 @@
1
+ import { createCarousel } from '@data-slot/carousel';
2
+
3
+ // @data-slot/carousel owns scrolling, snapping, dragging, the arrow keys and the previous and next
4
+ // buttons, and keeps every visible card interactive. It writes English ARIA descriptions and slide
5
+ // labels, so the translated ones from Liquid are put back after binding and slide updates.
6
+ export function initializeCarousel(root) {
7
+ const content = root.querySelector('[data-slot="carousel-content"]');
8
+ const items = () => [...content.children].filter((item) => item.matches('[data-slot="carousel-item"]'));
9
+ const rootDescription = root.getAttribute('aria-roledescription');
10
+ const descriptions = new WeakMap(items().map((item) => [item, item.getAttribute('aria-roledescription')]));
11
+ let destroyed = false;
12
+ const translate = () => {
13
+ if (destroyed) return;
14
+ if (rootDescription) root.setAttribute('aria-roledescription', rootDescription);
15
+ const slides = items();
16
+ const template = root.dataset.slideLabel;
17
+ slides.forEach((item, index) => {
18
+ const description = descriptions.get(item);
19
+ if (description) item.setAttribute('aria-roledescription', description);
20
+ if (template)
21
+ item.setAttribute('aria-label', template.replace('[index]', index + 1).replace('[total]', slides.length));
22
+ });
23
+ };
24
+ // Observe first to capture authored descriptions before data-slot rewrites them.
25
+ const observer = new MutationObserver((mutations) => {
26
+ for (const mutation of mutations)
27
+ for (const node of mutation.addedNodes)
28
+ if (node instanceof Element && node.matches('[data-slot="carousel-item"]'))
29
+ descriptions.set(node, node.getAttribute('aria-roledescription'));
30
+ queueMicrotask(translate);
31
+ });
32
+ observer.observe(content, { childList: true });
33
+ const carousel = createCarousel(root, { slides: 'multiple', drag: true, loop: false });
34
+ translate();
35
+ for (const button of root.querySelectorAll('[data-slot="carousel-previous"], [data-slot="carousel-next"]'))
36
+ button.hidden = false;
37
+ const destroy = carousel.destroy.bind(carousel);
38
+ carousel.destroy = () => {
39
+ destroyed = true;
40
+ observer.disconnect();
41
+ destroy();
42
+ };
43
+ return carousel;
44
+ }
@@ -0,0 +1,195 @@
1
+ // The data-slot controllers that few pages use, imported when theme.js finds their markup. Each
2
+ // entry starts one root and returns its controller with destroy(). Behavior is the vendored
3
+ // controller's; the adapters here only connect it to native forms and theme state.
4
+
5
+ // A composite input renders hidden after its native fallback, such as a select or radio inputs,
6
+ // which the form submits until the controller runs. Then the fallback leaves the document, so
7
+ // labels and the form see only the field the controller generates, and the fallback's id moves to
8
+ // the labelled element, so a label[for] still reaches the control. start() creates the controller
9
+ // with the fallback's reset default and the value a shopper chose while it loaded; its destroy()
10
+ // writes the current value back, and the fallback returns with its own reset default.
11
+ function replaceFallback(root, labelled, start) {
12
+ const fallback = root.previousElementSibling?.matches('[data-fallback]') ? root.previousElementSibling : null;
13
+ const attributes = ['id', 'aria-labelledby'].map((name) => [name, labelled.getAttribute(name)]);
14
+ const restore = () => {
15
+ root.hidden = true;
16
+ for (const [name, value] of attributes) {
17
+ if (value === null) labelled.removeAttribute(name);
18
+ else labelled.setAttribute(name, value);
19
+ }
20
+ if (fallback) root.before(fallback);
21
+ };
22
+ fallback?.remove();
23
+ if (fallback?.id) labelled.id = fallback.id;
24
+ root.hidden = false;
25
+ let controller;
26
+ try {
27
+ controller = start(fallback);
28
+ } catch (error) {
29
+ restore();
30
+ throw error;
31
+ }
32
+ return {
33
+ destroy() {
34
+ controller.destroy();
35
+ restore();
36
+ },
37
+ };
38
+ }
39
+
40
+ function initializeSelect({ createSelect }, root) {
41
+ return replaceFallback(root, root.querySelector('[data-slot="select-trigger"]'), (select) => {
42
+ const options = [...(select?.options ?? [])];
43
+ const initial = options.find((option) => option.defaultSelected) ?? options.find((option) => !option.disabled);
44
+ const controller = createSelect(root, { mountStrategy: 'eager', defaultValue: initial?.value || undefined });
45
+ const value = select?.value || null;
46
+ if (select && value !== controller.value) root.dispatchEvent(new CustomEvent('select:set', { detail: { value } }));
47
+ return {
48
+ destroy() {
49
+ if (select) select.value = controller.value ?? '';
50
+ controller.destroy();
51
+ },
52
+ };
53
+ });
54
+ }
55
+
56
+ function initializeRadioGroup({ createRadioGroup }, root) {
57
+ return replaceFallback(root, root, (fallback) => {
58
+ const inputs = [...(fallback?.querySelectorAll('input[type="radio"]') ?? [])];
59
+ const initial = inputs.find((input) => input.defaultChecked)?.value ?? '';
60
+ const controller = createRadioGroup(root, fallback ? { defaultValue: initial } : {});
61
+ const value = inputs.find((input) => input.checked)?.value ?? null;
62
+ if (fallback && value !== controller.value) {
63
+ if (value === null) controller.clear();
64
+ else controller.select(value);
65
+ }
66
+ return {
67
+ destroy() {
68
+ for (const input of inputs) input.checked = input.value === controller.value;
69
+ controller.destroy();
70
+ },
71
+ };
72
+ });
73
+ }
74
+
75
+ function initializeSwitch({ createSwitch }, root) {
76
+ return replaceFallback(root, root, (checkbox) => {
77
+ const controller = createSwitch(root, checkbox ? { defaultChecked: checkbox.defaultChecked } : {});
78
+ if (checkbox) controller.setChecked(checkbox.checked);
79
+ return {
80
+ destroy() {
81
+ if (checkbox) checkbox.checked = controller.checked;
82
+ controller.destroy();
83
+ },
84
+ };
85
+ });
86
+ }
87
+
88
+ // The slider has no form field of its own, so its native range inputs stay in the form, hidden,
89
+ // and follow its value. A form reset moves the slider back to the inputs' reset values.
90
+ function initializeSlider({ createSlider }, root) {
91
+ const fallback = root.previousElementSibling?.matches('[data-fallback]') ? root.previousElementSibling : null;
92
+ const inputs = fallback ? [...fallback.querySelectorAll('input[type="range"]')] : [];
93
+ const read = () => (inputs.length > 1 ? inputs.map((input) => Number(input.value)) : Number(inputs[0]?.value));
94
+ const write = (value) => {
95
+ [value].flat().forEach((number, index) => {
96
+ if (!inputs[index] || inputs[index].value === String(number)) return;
97
+ inputs[index].value = String(number);
98
+ inputs[index].dispatchEvent(new Event('input', { bubbles: true }));
99
+ });
100
+ };
101
+ const slider = createSlider(root, {
102
+ ...(inputs.length ? { defaultValue: read() } : {}),
103
+ onValueChange: write,
104
+ onValueCommit: () => inputs.forEach((input) => input.dispatchEvent(new Event('change', { bubbles: true }))),
105
+ });
106
+ const events = new AbortController();
107
+ inputs[0]?.form?.addEventListener('reset', () => setTimeout(() => slider.setValue(read())), {
108
+ signal: events.signal,
109
+ });
110
+ if (fallback) fallback.hidden = true;
111
+ root.hidden = false;
112
+ return {
113
+ destroy() {
114
+ events.abort();
115
+ slider.destroy();
116
+ root.hidden = true;
117
+ if (fallback) fallback.hidden = false;
118
+ },
119
+ };
120
+ }
121
+
122
+ // The action of an alert dialog is a native link or submit or reset button, and the controller
123
+ // leaves closing to the caller. A link closes the dialog on click; a submit or reset button once its
124
+ // form submits or resets, so an invalid form keeps its native validation and the dialog stays open.
125
+ function initializeAlertDialog({ createAlertDialog }, root) {
126
+ const dialog = createAlertDialog(root);
127
+ const events = new AbortController();
128
+ for (const action of root.querySelectorAll('[data-slot="alert-dialog-action"]')) {
129
+ action.addEventListener(
130
+ 'click',
131
+ () => {
132
+ const form = ['submit', 'reset'].includes(action.type) ? action.form : null;
133
+ if (form) form.addEventListener(action.type, () => dialog.close(), { once: true, signal: events.signal });
134
+ else dialog.close();
135
+ },
136
+ { signal: events.signal },
137
+ );
138
+ }
139
+ return {
140
+ destroy() {
141
+ events.abort();
142
+ dialog.destroy();
143
+ },
144
+ };
145
+ }
146
+
147
+ // Buttons inside a toaster show a toast with their translated title and description. Like other
148
+ // triggers that only open a popup, they show once the component has started (data-enhanced).
149
+ function initializeToaster({ createToast }, root) {
150
+ const toaster = createToast(root);
151
+ const events = new AbortController();
152
+ for (const button of root.querySelectorAll('[data-toast-title]')) {
153
+ button.addEventListener(
154
+ 'click',
155
+ () => toaster.show({ title: button.dataset.toastTitle, description: button.dataset.toastDescription }),
156
+ { signal: events.signal },
157
+ );
158
+ }
159
+ return {
160
+ destroy() {
161
+ events.abort();
162
+ toaster.destroy();
163
+ },
164
+ };
165
+ }
166
+
167
+ // Each entry loads its data-slot package, then starts one root with it and returns a controller
168
+ // with destroy(). theme.js starts the root only if it is still current once the package has
169
+ // loaded. Select, tooltip and hover card keep their closed content connected (eager), so nested
170
+ // components and the lifecycle in theme.js never see it leave the document.
171
+ export const controls = {
172
+ select: [() => import('@data-slot/select'), initializeSelect],
173
+ 'radio-group': [() => import('@data-slot/radio-group'), initializeRadioGroup],
174
+ switch: [() => import('@data-slot/switch'), initializeSwitch],
175
+ slider: [() => import('@data-slot/slider'), initializeSlider],
176
+ toggle: [() => import('@data-slot/toggle'), ({ createToggle }, root) => createToggle(root)],
177
+ 'toggle-group': [() => import('@data-slot/toggle-group'), ({ createToggleGroup }, root) => createToggleGroup(root)],
178
+ collapsible: [() => import('@data-slot/collapsible'), ({ createCollapsible }, root) => createCollapsible(root)],
179
+ popover: [() => import('@data-slot/popover'), ({ createPopover }, root) => createPopover(root)],
180
+ 'hover-card': [
181
+ () => import('@data-slot/hover-card'),
182
+ ({ createHoverCard }, root) => createHoverCard(root, { mountStrategy: 'eager' }),
183
+ ],
184
+ tooltip: [
185
+ () => import('@data-slot/tooltip'),
186
+ ({ createTooltip }, root) => createTooltip(root, { mountStrategy: 'eager' }),
187
+ ],
188
+ 'dropdown-menu': [
189
+ () => import('@data-slot/dropdown-menu'),
190
+ ({ createDropdownMenu }, root) => createDropdownMenu(root),
191
+ ],
192
+ 'alert-dialog': [() => import('@data-slot/alert-dialog'), initializeAlertDialog],
193
+ drawer: [() => import('@data-slot/drawer'), ({ createDrawer }, root) => createDrawer(root)],
194
+ toast: [() => import('@data-slot/toast'), initializeToaster],
195
+ };
@@ -0,0 +1,107 @@
1
+ // One owner per root, including asynchronous imports and Shopify editor replacements.
2
+ export function createLifecycle(factories, scope = document) {
3
+ const components = new Map();
4
+ const events = new AbortController();
5
+
6
+ function initialize(parent) {
7
+ for (const [selector, factory] of factories) {
8
+ const roots = [...parent.querySelectorAll(selector)];
9
+ if (parent.matches?.(selector)) roots.unshift(parent);
10
+ for (const root of roots) {
11
+ if (components.has(root) || !root.isConnected) continue;
12
+ try {
13
+ const controller = factory(root);
14
+ components.set(root, controller);
15
+ if (!controller.ready) root.dataset.enhanced = '';
16
+ controller.ready?.then(
17
+ () => {
18
+ if (components.get(root) === controller) root.dataset.enhanced = '';
19
+ },
20
+ (error) => {
21
+ console.error(error);
22
+ if (components.get(root) === controller) components.delete(root);
23
+ },
24
+ );
25
+ } catch (error) {
26
+ console.error(error);
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ function destroy(predicate) {
33
+ for (const [root, controller] of components) {
34
+ if (!predicate(root)) continue;
35
+ // Drop ownership before a fallback is restored and the observer sees it.
36
+ components.delete(root);
37
+ controller.destroy?.();
38
+ delete root.dataset.enhanced;
39
+ }
40
+ }
41
+
42
+ function reveal(root, method, value) {
43
+ const owner = components.get(root);
44
+ const apply = (controller) => {
45
+ if (owner && components.get(root) === owner) controller?.[method]?.(value);
46
+ };
47
+ // A selected block can arrive while its controller is still loading.
48
+ if (owner?.ready)
49
+ owner.ready.then(
50
+ (controller) => apply(controller ?? owner),
51
+ () => {},
52
+ );
53
+ else apply(owner);
54
+ }
55
+
56
+ initialize(scope);
57
+ const observer = new MutationObserver((mutations) => {
58
+ for (const mutation of mutations) {
59
+ for (const node of mutation.addedNodes) {
60
+ if (node.nodeType === Node.ELEMENT_NODE && node.isConnected) initialize(node);
61
+ }
62
+ }
63
+ if (mutations.some((mutation) => mutation.removedNodes.length)) destroy((root) => !root.isConnected);
64
+ });
65
+ observer.observe(scope === document ? document.body : scope, { childList: true, subtree: true });
66
+ document.addEventListener('shopify:section:load', (event) => initialize(event.target), { signal: events.signal });
67
+ document.addEventListener('shopify:section:unload', (event) => destroy((root) => event.target.contains(root)), {
68
+ signal: events.signal,
69
+ });
70
+ document.addEventListener(
71
+ 'shopify:block:select',
72
+ (event) => {
73
+ const item = event.target.closest('[data-slot="accordion-item"]');
74
+ if (item) reveal(item.closest('[data-slot="accordion"]'), 'expand', item.dataset.value);
75
+ const slide = event.target.closest('[data-slot="carousel-item"]');
76
+ if (slide)
77
+ reveal(slide.closest('[data-slot="carousel"]'), 'goTo', [...slide.parentElement.children].indexOf(slide));
78
+ },
79
+ { signal: events.signal },
80
+ );
81
+ return {
82
+ components,
83
+ initialize,
84
+ destroy() {
85
+ observer.disconnect();
86
+ events.abort();
87
+ destroy(() => true);
88
+ },
89
+ };
90
+ }
91
+
92
+ export function deferred(load, start) {
93
+ return (root) => {
94
+ let controller;
95
+ let destroyed = false;
96
+ const ready = load().then((module) => {
97
+ if (!destroyed && root.isConnected) return (controller = start(module, root));
98
+ });
99
+ return {
100
+ ready,
101
+ destroy() {
102
+ destroyed = true;
103
+ controller?.destroy();
104
+ },
105
+ };
106
+ };
107
+ }
@@ -0,0 +1,45 @@
1
+ const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)');
2
+
3
+ // A pause button for a CSS animation that runs on its own, such as a marquee. Its label stays Pause
4
+ // and aria-pressed carries the state: pressed while the animation is paused.
5
+ export function initializeMotionPause(button) {
6
+ const root = button.closest('[data-motion]');
7
+ const events = new AbortController();
8
+ // CSS animates the root only from here on, so it never moves without a working pause button.
9
+ root.dataset.motionReady = '';
10
+ const sync = () => {
11
+ button.hidden = reducedMotion.matches;
12
+ };
13
+ button.addEventListener(
14
+ 'click',
15
+ () => {
16
+ const paused = button.getAttribute('aria-pressed') !== 'true';
17
+ button.setAttribute('aria-pressed', String(paused));
18
+ root.toggleAttribute('data-paused', paused);
19
+ },
20
+ { signal: events.signal },
21
+ );
22
+ reducedMotion.addEventListener('change', sync, { signal: events.signal });
23
+ sync();
24
+ return {
25
+ destroy() {
26
+ events.abort();
27
+ delete root.dataset.motionReady;
28
+ },
29
+ };
30
+ }
31
+
32
+ // Muted autoplay videos stay still for visitors who prefer reduced motion; they keep their controls.
33
+ export function initializeAutoplayVideo(video) {
34
+ const events = new AbortController();
35
+ const sync = () => {
36
+ if (reducedMotion.matches) video.pause();
37
+ };
38
+ reducedMotion.addEventListener('change', sync, { signal: events.signal });
39
+ sync();
40
+ return {
41
+ destroy() {
42
+ events.abort();
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,37 @@
1
+ import { controls } from '@fulldev/controls';
2
+ import { createLifecycle, deferred } from '@fulldev/lifecycle';
3
+ import { initializeAutoplayVideo, initializeMotionPause } from '@fulldev/motion';
4
+
5
+ const simple = [
6
+ ['accordion', () => import('@data-slot/accordion'), 'createAccordion'],
7
+ ['tabs', () => import('@data-slot/tabs'), 'createTabs'],
8
+ ['dialog', () => import('@data-slot/dialog'), 'createDialog'],
9
+ ['combobox', () => import('@data-slot/combobox'), 'createCombobox'],
10
+ ['command', () => import('@data-slot/command'), 'createCommand'],
11
+ ['navigation-menu', () => import('@data-slot/navigation-menu'), 'createNavigationMenu'],
12
+ ];
13
+
14
+ export const lifecycle = createLifecycle([
15
+ ['[data-motion-pause]', initializeMotionPause],
16
+ ['video[autoplay]', initializeAutoplayVideo],
17
+ ...simple.map(([name, load, factory]) => [
18
+ `[data-slot="${name}"]`,
19
+ deferred(load, (module, root) =>
20
+ module[factory](root, {
21
+ mountStrategy: 'eager',
22
+ ...(name === 'accordion' ? { multiple: root.dataset.multiple !== 'false' } : {}),
23
+ }),
24
+ ),
25
+ ]),
26
+ [
27
+ '[data-slot="carousel"]',
28
+ deferred(
29
+ () => import('@fulldev/carousel'),
30
+ (module, root) => module.initializeCarousel(root),
31
+ ),
32
+ ],
33
+ ...Object.entries(controls).map(([name, [load, start]]) => [
34
+ name === 'toggle' ? 'button[data-slot="toggle"]' : `[data-slot="${name}"]`,
35
+ deferred(load, start),
36
+ ]),
37
+ ]);
@@ -0,0 +1,6 @@
1
+ {% doc %}
2
+ Fulldev UI tokens and native base. Render once in the head before theme overrides.
3
+ {% enddoc %}
4
+
5
+ {{ 'ui-tokens.css' | asset_url | stylesheet_tag: preload: true }}
6
+ {% render 'ui-base' %}
@@ -0,0 +1,9 @@
1
+ {% doc %}
2
+ Default Fulldev UI runtime. Render once in the head, before other module scripts.
3
+ Use your own import map and createLifecycle when the theme supplies Shopify adapters.
4
+ {% enddoc %}
5
+
6
+ <script type='importmap'>
7
+ {"imports": {"@fulldev/motion":{{ 'ui-motion.js' | asset_url | json }},"@fulldev/lifecycle":{{ 'ui-lifecycle.js' | asset_url | json }},"@fulldev/controls":{{ 'ui-controls.js' | asset_url | json }},"@fulldev/carousel":{{ 'ui-carousel.js' | asset_url | json }},"@data-slot/core":{{ 'data-slot-core.js' | asset_url | json }},"@data-slot/dialog":{{ 'data-slot-dialog.js' | asset_url | json }},"@data-slot/command":{{ 'data-slot-command.js' | asset_url | json }},"@data-slot/navigation-menu":{{ 'data-slot-navigation-menu.js' | asset_url | json }},"@data-slot/accordion":{{ 'data-slot-accordion.js' | asset_url | json }},"@data-slot/tabs":{{ 'data-slot-tabs.js' | asset_url | json }},"@data-slot/combobox":{{ 'data-slot-combobox.js' | asset_url | json }},"@data-slot/carousel":{{ 'data-slot-carousel.js' | asset_url | json }},"@data-slot/alert-dialog":{{ 'data-slot-alert-dialog.js' | asset_url | json }},"@data-slot/collapsible":{{ 'data-slot-collapsible.js' | asset_url | json }},"@data-slot/drawer":{{ 'data-slot-drawer.js' | asset_url | json }},"@data-slot/dropdown-menu":{{ 'data-slot-dropdown-menu.js' | asset_url | json }},"@data-slot/hover-card":{{ 'data-slot-hover-card.js' | asset_url | json }},"@data-slot/popover":{{ 'data-slot-popover.js' | asset_url | json }},"@data-slot/radio-group":{{ 'data-slot-radio-group.js' | asset_url | json }},"@data-slot/select":{{ 'data-slot-select.js' | asset_url | json }},"@data-slot/slider":{{ 'data-slot-slider.js' | asset_url | json }},"@data-slot/switch":{{ 'data-slot-switch.js' | asset_url | json }},"@data-slot/toast":{{ 'data-slot-toast.js' | asset_url | json }},"@data-slot/toggle":{{ 'data-slot-toggle.js' | asset_url | json }},"@data-slot/toggle-group":{{ 'data-slot-toggle-group.js' | asset_url | json }},"@data-slot/tooltip":{{ 'data-slot-tooltip.js' | asset_url | json }}}}
8
+ </script>
9
+ <script src='{{ 'ui-start.js' | asset_url }}' type='module'></script>
@@ -0,0 +1,68 @@
1
+ {% doc %}
2
+ All Fulldev UI styles. Render once in the head before theme styles.
3
+
4
+ @param {boolean} [runtime] - False when the theme owns its import map and initialization.
5
+ {% enddoc %}
6
+
7
+ {% render 'ui-init' %}
8
+ {% render 'ui-banner' %}
9
+ {% render 'ui-tabs' %}
10
+ {% render 'ui-form' %}
11
+ {% render 'ui-select' %}
12
+ {% render 'ui-field' %}
13
+ {% render 'ui-item' %}
14
+ {% render 'ui-spinner' %}
15
+ {% render 'ui-video' %}
16
+ {% render 'ui-button' %}
17
+ {% render 'ui-toggle' %}
18
+ {% render 'ui-logo' %}
19
+ {% render 'ui-kbd' %}
20
+ {% render 'ui-rating' %}
21
+ {% render 'ui-tooltip' %}
22
+ {% render 'ui-avatar' %}
23
+ {% render 'ui-empty' %}
24
+ {% render 'ui-alert-dialog' %}
25
+ {% render 'ui-navigation-menu' %}
26
+ {% render 'ui-typography' %}
27
+ {% render 'ui-toc' %}
28
+ {% render 'ui-icon' %}
29
+ {% render 'ui-combobox' %}
30
+ {% render 'ui-toast' %}
31
+ {% render 'ui-header' %}
32
+ {% render 'ui-command' %}
33
+ {% render 'ui-accordion' %}
34
+ {% render 'ui-slider' %}
35
+ {% render 'ui-input' %}
36
+ {% render 'ui-input-group' %}
37
+ {% render 'ui-triggers' %}
38
+ {% render 'ui-toggle-group' %}
39
+ {% render 'ui-dialog' %}
40
+ {% render 'ui-drawer' %}
41
+ {% render 'ui-badge' %}
42
+ {% render 'ui-alert' %}
43
+ {% render 'ui-table' %}
44
+ {% render 'ui-breadcrumb' %}
45
+ {% render 'ui-aspect-ratio' %}
46
+ {% render 'ui-price' %}
47
+ {% render 'ui-radio-group' %}
48
+ {% render 'ui-checkbox' %}
49
+ {% render 'ui-switch' %}
50
+ {% render 'ui-skeleton' %}
51
+ {% render 'ui-separator' %}
52
+ {% render 'ui-card' %}
53
+ {% render 'ui-pagination' %}
54
+ {% render 'ui-popup' %}
55
+ {% render 'ui-sheet' %}
56
+ {% render 'ui-carousel' %}
57
+ {% render 'ui-attachment' %}
58
+ {% render 'ui-marquee' %}
59
+ {% render 'ui-invalid-controls' %}
60
+ {% render 'ui-section' %}
61
+ {% render 'ui-button-group' %}
62
+ {% render 'ui-collapsible' %}
63
+ {% render 'ui-dropdown-menu' %}
64
+ {% render 'ui-popover' %}
65
+ {% render 'ui-hover-card' %}
66
+ {% if runtime != false %}
67
+ {% render 'ui-runtime' %}
68
+ {% endif %}
@@ -0,0 +1,66 @@
1
+ /* The data-slot accordion, and the same parts on native <details> and <summary>, which open
2
+ without JavaScript. */
3
+ [data-slot='accordion'] {
4
+ display: flex;
5
+ flex-direction: column;
6
+ width: 100%;
7
+ }
8
+ [data-slot='accordion-item']:not(:last-child) {
9
+ border-bottom: 1px solid var(--border);
10
+ }
11
+ .accordion__heading {
12
+ font: inherit;
13
+ letter-spacing: var(--tracking-normal);
14
+ }
15
+ [data-slot='accordion-trigger'] {
16
+ display: flex;
17
+ align-items: flex-start;
18
+ justify-content: space-between;
19
+ gap: calc(var(--spacing) * 4);
20
+ width: 100%;
21
+ padding-block: calc(var(--spacing) * 4);
22
+ border: 1px solid transparent;
23
+ border-radius: var(--radius-md);
24
+ font-size: 0.875rem;
25
+ font-weight: 500;
26
+ line-height: 1.43;
27
+ text-align: left;
28
+ list-style: none;
29
+ outline: none;
30
+ }
31
+ summary[data-slot='accordion-trigger']::-webkit-details-marker {
32
+ display: none;
33
+ }
34
+ [data-slot='accordion-trigger']:hover {
35
+ text-decoration: underline;
36
+ }
37
+ [data-slot='accordion-trigger']:focus-visible {
38
+ border-color: var(--ring);
39
+ box-shadow: var(--focus-ring);
40
+ }
41
+ [data-slot='accordion-trigger'] > .icon {
42
+ width: calc(var(--spacing) * 4);
43
+ height: calc(var(--spacing) * 4);
44
+ margin-left: auto;
45
+ color: var(--muted-foreground);
46
+ transition: rotate 200ms;
47
+ }
48
+ [data-slot='accordion-item'][data-state='open'] [data-slot='accordion-trigger'] > .icon,
49
+ details[open] > [data-slot='accordion-trigger'] > .icon {
50
+ rotate: 180deg;
51
+ }
52
+ [data-slot='accordion-content'] {
53
+ overflow: hidden;
54
+ font-size: 0.875rem;
55
+ }
56
+ [data-slot='accordion'] [data-slot='accordion-content'] {
57
+ height: var(--accordion-panel-height);
58
+ transition: height 200ms ease;
59
+ }
60
+ [data-slot='accordion-content'][data-starting-style],
61
+ [data-slot='accordion-content'][data-ending-style] {
62
+ height: 0;
63
+ }
64
+ [data-slot='accordion-content-inner'] {
65
+ padding-bottom: calc(var(--spacing) * 4);
66
+ }