decantr 0.9.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 (382) hide show
  1. package/AGENTS.md +868 -0
  2. package/CHANGELOG.md +255 -0
  3. package/CLAUDE.md +178 -0
  4. package/LICENSE +21 -0
  5. package/README.md +229 -0
  6. package/cli/art.js +127 -0
  7. package/cli/commands/a11y.js +61 -0
  8. package/cli/commands/audit.js +225 -0
  9. package/cli/commands/build.js +38 -0
  10. package/cli/commands/dev.js +18 -0
  11. package/cli/commands/doctor.js +197 -0
  12. package/cli/commands/figma-sync.js +48 -0
  13. package/cli/commands/figma-tokens.js +55 -0
  14. package/cli/commands/generate.js +26 -0
  15. package/cli/commands/init.js +116 -0
  16. package/cli/commands/lint.js +209 -0
  17. package/cli/commands/mcp.js +530 -0
  18. package/cli/commands/migrate.js +175 -0
  19. package/cli/commands/test.js +38 -0
  20. package/cli/commands/validate.js +354 -0
  21. package/cli/index.js +113 -0
  22. package/package.json +95 -0
  23. package/reference/atoms.md +517 -0
  24. package/reference/behaviors.md +384 -0
  25. package/reference/build-tooling.md +275 -0
  26. package/reference/color-guidelines.md +965 -0
  27. package/reference/component-lifecycle.md +137 -0
  28. package/reference/compound-spacing.md +95 -0
  29. package/reference/decantation-process.md +499 -0
  30. package/reference/dev-server-routes.md +93 -0
  31. package/reference/form-system.md +253 -0
  32. package/reference/i18n.md +336 -0
  33. package/reference/icons.md +576 -0
  34. package/reference/llm-primer.md +953 -0
  35. package/reference/plugins.md +252 -0
  36. package/reference/registry-consumption.md +76 -0
  37. package/reference/router.md +217 -0
  38. package/reference/shells.md +116 -0
  39. package/reference/spatial-guidelines.md +541 -0
  40. package/reference/ssr.md +234 -0
  41. package/reference/state-data.md +215 -0
  42. package/reference/state-patterns.md +166 -0
  43. package/reference/state.md +194 -0
  44. package/reference/style-system.md +110 -0
  45. package/reference/tokens.md +460 -0
  46. package/src/app.js +19 -0
  47. package/src/chart/_animate.js +266 -0
  48. package/src/chart/_base.js +109 -0
  49. package/src/chart/_data.js +209 -0
  50. package/src/chart/_format.js +106 -0
  51. package/src/chart/_interact.js +364 -0
  52. package/src/chart/_palette.js +105 -0
  53. package/src/chart/_renderer.js +52 -0
  54. package/src/chart/_scene.js +262 -0
  55. package/src/chart/_shared.js +371 -0
  56. package/src/chart/index.js +637 -0
  57. package/src/chart/layouts/_layout-base.js +328 -0
  58. package/src/chart/layouts/cartesian.js +148 -0
  59. package/src/chart/layouts/hierarchy.js +562 -0
  60. package/src/chart/layouts/polar.js +101 -0
  61. package/src/chart/renderers/canvas.js +179 -0
  62. package/src/chart/renderers/svg.js +256 -0
  63. package/src/chart/renderers/webgpu.js +715 -0
  64. package/src/chart/types/_type-base.js +26 -0
  65. package/src/chart/types/area.js +134 -0
  66. package/src/chart/types/bar.js +173 -0
  67. package/src/chart/types/box-plot.js +125 -0
  68. package/src/chart/types/bubble.js +63 -0
  69. package/src/chart/types/candlestick.js +115 -0
  70. package/src/chart/types/chord.js +85 -0
  71. package/src/chart/types/combination.js +108 -0
  72. package/src/chart/types/funnel.js +68 -0
  73. package/src/chart/types/gauge.js +163 -0
  74. package/src/chart/types/heatmap.js +98 -0
  75. package/src/chart/types/histogram.js +71 -0
  76. package/src/chart/types/line.js +111 -0
  77. package/src/chart/types/org-chart.js +93 -0
  78. package/src/chart/types/pie.js +81 -0
  79. package/src/chart/types/radar.js +96 -0
  80. package/src/chart/types/radial.js +68 -0
  81. package/src/chart/types/range-area.js +55 -0
  82. package/src/chart/types/range-bar.js +61 -0
  83. package/src/chart/types/sankey.js +73 -0
  84. package/src/chart/types/scatter.js +66 -0
  85. package/src/chart/types/sparkline.js +81 -0
  86. package/src/chart/types/sunburst.js +69 -0
  87. package/src/chart/types/swimlane.js +88 -0
  88. package/src/chart/types/treemap.js +62 -0
  89. package/src/chart/types/waterfall.js +100 -0
  90. package/src/components/_base.js +1658 -0
  91. package/src/components/_behaviors.js +1140 -0
  92. package/src/components/_primitives.js +534 -0
  93. package/src/components/_qr-encoder.js +539 -0
  94. package/src/components/accordion.js +207 -0
  95. package/src/components/affix.js +62 -0
  96. package/src/components/alert-dialog.js +75 -0
  97. package/src/components/alert.js +47 -0
  98. package/src/components/aspect-ratio.js +24 -0
  99. package/src/components/avatar-group.js +55 -0
  100. package/src/components/avatar.js +38 -0
  101. package/src/components/back-top.js +75 -0
  102. package/src/components/badge.js +74 -0
  103. package/src/components/banner.js +68 -0
  104. package/src/components/breadcrumb.js +162 -0
  105. package/src/components/button.js +115 -0
  106. package/src/components/calendar.js +131 -0
  107. package/src/components/card.js +192 -0
  108. package/src/components/carousel.js +98 -0
  109. package/src/components/cascader.js +261 -0
  110. package/src/components/checkbox.js +80 -0
  111. package/src/components/chip.js +81 -0
  112. package/src/components/code-block.js +82 -0
  113. package/src/components/collapsible.js +50 -0
  114. package/src/components/color-palette.js +438 -0
  115. package/src/components/color-picker.js +314 -0
  116. package/src/components/combobox.js +181 -0
  117. package/src/components/command.js +174 -0
  118. package/src/components/comment.js +206 -0
  119. package/src/components/context-menu.js +76 -0
  120. package/src/components/data-table.js +724 -0
  121. package/src/components/date-picker.js +217 -0
  122. package/src/components/date-range-picker.js +244 -0
  123. package/src/components/datetime-picker.js +271 -0
  124. package/src/components/descriptions.js +68 -0
  125. package/src/components/drawer.js +179 -0
  126. package/src/components/dropdown.js +88 -0
  127. package/src/components/empty.js +41 -0
  128. package/src/components/float-button.js +90 -0
  129. package/src/components/form.js +106 -0
  130. package/src/components/hover-card.js +49 -0
  131. package/src/components/icon.js +87 -0
  132. package/src/components/image.js +97 -0
  133. package/src/components/index.js +117 -0
  134. package/src/components/input-group.js +75 -0
  135. package/src/components/input-number.js +155 -0
  136. package/src/components/input-otp.js +178 -0
  137. package/src/components/input.js +91 -0
  138. package/src/components/kbd.js +36 -0
  139. package/src/components/label.js +25 -0
  140. package/src/components/list.js +118 -0
  141. package/src/components/masked-input.js +236 -0
  142. package/src/components/mentions.js +165 -0
  143. package/src/components/menu.js +259 -0
  144. package/src/components/message.js +80 -0
  145. package/src/components/modal.js +147 -0
  146. package/src/components/navigation-menu.js +166 -0
  147. package/src/components/notification.js +84 -0
  148. package/src/components/pagination.js +104 -0
  149. package/src/components/placeholder.js +132 -0
  150. package/src/components/popconfirm.js +70 -0
  151. package/src/components/popover.js +58 -0
  152. package/src/components/progress.js +61 -0
  153. package/src/components/qrcode.js +251 -0
  154. package/src/components/radiogroup.js +120 -0
  155. package/src/components/range-slider.js +176 -0
  156. package/src/components/rate.js +186 -0
  157. package/src/components/resizable.js +83 -0
  158. package/src/components/result.js +57 -0
  159. package/src/components/scroll-area.js +43 -0
  160. package/src/components/segmented.js +97 -0
  161. package/src/components/select.js +165 -0
  162. package/src/components/separator.js +31 -0
  163. package/src/components/shell.js +407 -0
  164. package/src/components/skeleton.js +39 -0
  165. package/src/components/slider.js +141 -0
  166. package/src/components/sortable-list.js +176 -0
  167. package/src/components/space.js +42 -0
  168. package/src/components/spinner.js +112 -0
  169. package/src/components/splitter.js +147 -0
  170. package/src/components/statistic.js +136 -0
  171. package/src/components/steps.js +99 -0
  172. package/src/components/switch.js +95 -0
  173. package/src/components/table.js +44 -0
  174. package/src/components/tabs.js +216 -0
  175. package/src/components/tag.js +115 -0
  176. package/src/components/textarea.js +82 -0
  177. package/src/components/time-picker.js +153 -0
  178. package/src/components/time-range-picker.js +170 -0
  179. package/src/components/timeline.js +226 -0
  180. package/src/components/toast.js +71 -0
  181. package/src/components/toggle.js +213 -0
  182. package/src/components/tooltip.js +57 -0
  183. package/src/components/tour.js +159 -0
  184. package/src/components/transfer.js +163 -0
  185. package/src/components/tree-select.js +274 -0
  186. package/src/components/tree.js +141 -0
  187. package/src/components/typography.js +136 -0
  188. package/src/components/upload.js +118 -0
  189. package/src/components/visually-hidden.js +20 -0
  190. package/src/components/watermark.js +124 -0
  191. package/src/core/index.js +539 -0
  192. package/src/core/lifecycle.js +69 -0
  193. package/src/css/atoms.js +651 -0
  194. package/src/css/components.js +940 -0
  195. package/src/css/derive.js +1296 -0
  196. package/src/css/index.js +265 -0
  197. package/src/css/runtime.js +268 -0
  198. package/src/css/styles/addons/bioluminescent.js +93 -0
  199. package/src/css/styles/addons/clay.js +70 -0
  200. package/src/css/styles/addons/clean.js +57 -0
  201. package/src/css/styles/addons/command-center.js +143 -0
  202. package/src/css/styles/addons/dopamine.js +83 -0
  203. package/src/css/styles/addons/editorial.js +80 -0
  204. package/src/css/styles/addons/glassmorphism.js +99 -0
  205. package/src/css/styles/addons/liquid-glass.js +105 -0
  206. package/src/css/styles/addons/prismatic.js +100 -0
  207. package/src/css/styles/addons/retro.js +63 -0
  208. package/src/css/styles/auradecantism.js +96 -0
  209. package/src/css/theme-registry.js +444 -0
  210. package/src/data/entity.js +281 -0
  211. package/src/data/index.js +13 -0
  212. package/src/data/persist.js +225 -0
  213. package/src/data/query.js +839 -0
  214. package/src/data/realtime.js +299 -0
  215. package/src/data/url.js +177 -0
  216. package/src/data/worker.js +134 -0
  217. package/src/explorer/archetypes.js +243 -0
  218. package/src/explorer/atoms.js +228 -0
  219. package/src/explorer/charts.js +497 -0
  220. package/src/explorer/components.js +129 -0
  221. package/src/explorer/foundations.js +949 -0
  222. package/src/explorer/icons.js +178 -0
  223. package/src/explorer/patterns.js +247 -0
  224. package/src/explorer/recipes.js +194 -0
  225. package/src/explorer/shared/pattern-examples.js +1337 -0
  226. package/src/explorer/shared/showcase-renderer.js +958 -0
  227. package/src/explorer/shared/spec-table.js +41 -0
  228. package/src/explorer/shared/usage-links.js +87 -0
  229. package/src/explorer/shell-config.js +10 -0
  230. package/src/explorer/shells.js +551 -0
  231. package/src/explorer/styles.js +161 -0
  232. package/src/explorer/tokens.js +262 -0
  233. package/src/explorer/tools.js +525 -0
  234. package/src/form/index.js +804 -0
  235. package/src/i18n/index.js +251 -0
  236. package/src/icons/essential.js +479 -0
  237. package/src/icons/index.js +53 -0
  238. package/src/plugins/index.js +282 -0
  239. package/src/registry/archetypes/content-site.json +71 -0
  240. package/src/registry/archetypes/docs-explorer.json +23 -0
  241. package/src/registry/archetypes/ecommerce.json +104 -0
  242. package/src/registry/archetypes/financial-dashboard.json +77 -0
  243. package/src/registry/archetypes/index.json +41 -0
  244. package/src/registry/archetypes/portfolio.json +82 -0
  245. package/src/registry/archetypes/recipe-community.json +159 -0
  246. package/src/registry/archetypes/saas-dashboard.json +86 -0
  247. package/src/registry/architect/cross-cutting.json +45 -0
  248. package/src/registry/architect/domains/ecommerce.json +294 -0
  249. package/src/registry/architect/domains/financial-services.json +302 -0
  250. package/src/registry/architect/index.json +26 -0
  251. package/src/registry/architect/traits.json +379 -0
  252. package/src/registry/atoms.json +16 -0
  253. package/src/registry/chart-showcase.json +160 -0
  254. package/src/registry/chart.json +136 -0
  255. package/src/registry/components.json +8616 -0
  256. package/src/registry/core.json +216 -0
  257. package/src/registry/css.json +319 -0
  258. package/src/registry/data.json +135 -0
  259. package/src/registry/foundations.json +11 -0
  260. package/src/registry/icons.json +463 -0
  261. package/src/registry/index.json +101 -0
  262. package/src/registry/patterns/activity-feed.json +37 -0
  263. package/src/registry/patterns/article-content.json +27 -0
  264. package/src/registry/patterns/auth-form.json +37 -0
  265. package/src/registry/patterns/author-card.json +20 -0
  266. package/src/registry/patterns/card-grid.json +127 -0
  267. package/src/registry/patterns/category-nav.json +26 -0
  268. package/src/registry/patterns/chart-grid.json +36 -0
  269. package/src/registry/patterns/chat-interface.json +37 -0
  270. package/src/registry/patterns/checklist-card.json +55 -0
  271. package/src/registry/patterns/comparison-panel.json +27 -0
  272. package/src/registry/patterns/component-showcase.json +24 -0
  273. package/src/registry/patterns/contact-form.json +31 -0
  274. package/src/registry/patterns/cta-section.json +20 -0
  275. package/src/registry/patterns/data-table.json +37 -0
  276. package/src/registry/patterns/detail-header.json +83 -0
  277. package/src/registry/patterns/detail-panel.json +27 -0
  278. package/src/registry/patterns/explorer-shell.json +22 -0
  279. package/src/registry/patterns/filter-bar.json +33 -0
  280. package/src/registry/patterns/filter-sidebar.json +27 -0
  281. package/src/registry/patterns/form-sections.json +110 -0
  282. package/src/registry/patterns/goal-tracker.json +27 -0
  283. package/src/registry/patterns/hero.json +107 -0
  284. package/src/registry/patterns/index.json +47 -0
  285. package/src/registry/patterns/kpi-grid.json +36 -0
  286. package/src/registry/patterns/media-gallery.json +20 -0
  287. package/src/registry/patterns/order-history.json +20 -0
  288. package/src/registry/patterns/pagination.json +19 -0
  289. package/src/registry/patterns/photo-to-recipe.json +36 -0
  290. package/src/registry/patterns/pipeline-tracker.json +28 -0
  291. package/src/registry/patterns/post-list.json +27 -0
  292. package/src/registry/patterns/pricing-table.json +32 -0
  293. package/src/registry/patterns/scorecard.json +28 -0
  294. package/src/registry/patterns/search-bar.json +20 -0
  295. package/src/registry/patterns/specimen-grid.json +19 -0
  296. package/src/registry/patterns/stat-card.json +55 -0
  297. package/src/registry/patterns/stats-bar.json +55 -0
  298. package/src/registry/patterns/steps-card.json +55 -0
  299. package/src/registry/patterns/table-of-contents.json +19 -0
  300. package/src/registry/patterns/testimonials.json +21 -0
  301. package/src/registry/patterns/timeline.json +27 -0
  302. package/src/registry/patterns/token-inspector.json +21 -0
  303. package/src/registry/patterns/wizard.json +27 -0
  304. package/src/registry/recipe-auradecantism.json +69 -0
  305. package/src/registry/recipe-clean.json +65 -0
  306. package/src/registry/recipe-command-center.json +78 -0
  307. package/src/registry/router.json +73 -0
  308. package/src/registry/schema/README.md +197 -0
  309. package/src/registry/skeletons.json +259 -0
  310. package/src/registry/state.json +137 -0
  311. package/src/registry/tokens.json +40 -0
  312. package/src/router/hash.js +17 -0
  313. package/src/router/history.js +18 -0
  314. package/src/router/index.js +598 -0
  315. package/src/ssr/index.js +922 -0
  316. package/src/state/arrays.js +181 -0
  317. package/src/state/devtools.js +647 -0
  318. package/src/state/index.js +498 -0
  319. package/src/state/middleware.js +288 -0
  320. package/src/state/scheduler.js +206 -0
  321. package/src/state/store.js +300 -0
  322. package/src/tags/index.js +19 -0
  323. package/src/tannins/auth.js +396 -0
  324. package/src/test/dom.js +352 -0
  325. package/src/test/index.js +62 -0
  326. package/src/test/state.js +306 -0
  327. package/tools/a11y-audit.js +487 -0
  328. package/tools/analyzer.js +315 -0
  329. package/tools/audit.js +706 -0
  330. package/tools/builder.js +1422 -0
  331. package/tools/css-extract.js +188 -0
  332. package/tools/dev-server.js +316 -0
  333. package/tools/dts-gen.js +1260 -0
  334. package/tools/figma-components.js +329 -0
  335. package/tools/figma-patterns.js +516 -0
  336. package/tools/figma-plugin/code.js +453 -0
  337. package/tools/figma-plugin/manifest.json +14 -0
  338. package/tools/figma-plugin/ui.html +268 -0
  339. package/tools/figma-render.js +293 -0
  340. package/tools/figma-tokens.js +712 -0
  341. package/tools/figma-upload.js +318 -0
  342. package/tools/generate.js +738 -0
  343. package/tools/icons.js +133 -0
  344. package/tools/init-templates.js +265 -0
  345. package/tools/install-hooks.sh +5 -0
  346. package/tools/migrations/0.5.0.js +53 -0
  347. package/tools/migrations/0.6.0.js +95 -0
  348. package/tools/minify.js +170 -0
  349. package/tools/pre-commit +4 -0
  350. package/tools/registry.js +662 -0
  351. package/tools/reset-playground.js +61 -0
  352. package/tools/starter-templates/content-site/app.js +49 -0
  353. package/tools/starter-templates/content-site/essence.js +19 -0
  354. package/tools/starter-templates/content-site/pages.js +31 -0
  355. package/tools/starter-templates/ecommerce/app.js +50 -0
  356. package/tools/starter-templates/ecommerce/essence.js +19 -0
  357. package/tools/starter-templates/ecommerce/pages.js +31 -0
  358. package/tools/starter-templates/landing-page/app.js +38 -0
  359. package/tools/starter-templates/landing-page/essence.js +18 -0
  360. package/tools/starter-templates/landing-page/pages.js +21 -0
  361. package/tools/starter-templates/portfolio/app.js +45 -0
  362. package/tools/starter-templates/portfolio/essence.js +19 -0
  363. package/tools/starter-templates/portfolio/pages.js +33 -0
  364. package/tools/starter-templates/saas-dashboard/app.js +70 -0
  365. package/tools/starter-templates/saas-dashboard/essence.js +19 -0
  366. package/tools/starter-templates/saas-dashboard/pages.js +31 -0
  367. package/tools/verify-pack.js +203 -0
  368. package/types/chart.d.ts +77 -0
  369. package/types/components.d.ts +587 -0
  370. package/types/core.d.ts +89 -0
  371. package/types/css.d.ts +149 -0
  372. package/types/data.d.ts +238 -0
  373. package/types/form.d.ts +164 -0
  374. package/types/i18n.d.ts +51 -0
  375. package/types/icons.d.ts +27 -0
  376. package/types/index.d.ts +13 -0
  377. package/types/router.d.ts +116 -0
  378. package/types/ssr.d.ts +102 -0
  379. package/types/state.d.ts +83 -0
  380. package/types/tags.d.ts +62 -0
  381. package/types/tannins.d.ts +63 -0
  382. package/types/test.d.ts +48 -0
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Toggle — A pressable button with on/off state.
3
+ * Uses aria-pressed for accessibility. Supports reactive pressed state.
4
+ *
5
+ * @module decantr/components/toggle
6
+ */
7
+ import { onDestroy } from '../core/index.js';
8
+ import { createEffect } from '../state/index.js';
9
+ import { tags } from '../tags/index.js';
10
+ import { injectBase, cx, reactiveAttr } from './_base.js';
11
+ import { createRovingTabindex } from './_behaviors.js';
12
+
13
+ const { div, button: buttonTag } = tags;
14
+
15
+ /**
16
+ * @param {Object} [props]
17
+ * @param {boolean|Function} [props.pressed=false] - Pressed state (static or signal getter)
18
+ * @param {string} [props.variant] - default|outline
19
+ * @param {string} [props.size] - xs|sm|lg
20
+ * @param {boolean|Function} [props.disabled]
21
+ * @param {Function} [props.onchange] - Called with new pressed state
22
+ * @param {string} [props.class]
23
+ * @param {...(string|Node)} children
24
+ * @returns {HTMLElement}
25
+ */
26
+ export function Toggle(props = {}, ...children) {
27
+ injectBase();
28
+
29
+ const { pressed = false, variant, size, disabled, onchange, class: cls, ...rest } = props;
30
+
31
+ const className = cx(
32
+ 'd-toggle',
33
+ variant && `d-toggle-${variant}`,
34
+ size && `d-toggle-${size}`,
35
+ cls
36
+ );
37
+
38
+ let _pressed = typeof pressed === 'function' ? pressed() : pressed;
39
+
40
+ const el = buttonTag({
41
+ type: 'button',
42
+ class: className,
43
+ role: 'button',
44
+ 'aria-pressed': String(_pressed),
45
+ ...rest
46
+ }, ...children);
47
+
48
+ el.addEventListener('click', () => {
49
+ _pressed = !_pressed;
50
+ el.setAttribute('aria-pressed', String(_pressed));
51
+ if (onchange) onchange(_pressed);
52
+ });
53
+
54
+ reactiveAttr(el, disabled, 'disabled');
55
+
56
+ if (typeof pressed === 'function') {
57
+ createEffect(() => {
58
+ _pressed = pressed();
59
+ el.setAttribute('aria-pressed', String(_pressed));
60
+ });
61
+ }
62
+
63
+ return el;
64
+ }
65
+
66
+ /**
67
+ * ToggleGroup — A group of toggles, single or multi-select.
68
+ * Features a sliding indicator for single-select mode.
69
+ * Uses createRovingTabindex for keyboard navigation.
70
+ *
71
+ * @param {Object} [props]
72
+ * @param {{ value: string, label?: string, icon?: string|Node, disabled?: boolean }[]} [props.items]
73
+ * @param {string|string[]|Function} [props.value] - Selected value(s)
74
+ * @param {'single'|'multiple'} [props.type='single']
75
+ * @param {boolean} [props.multiple] - Alias for type='multiple'
76
+ * @param {string} [props.variant]
77
+ * @param {string} [props.size] - sm|lg
78
+ * @param {boolean} [props.block=false] - Full-width layout
79
+ * @param {boolean|Function} [props.disabled] - Group-level disabled
80
+ * @param {Function} [props.onchange] - Called with new value(s)
81
+ * @param {string} [props.class]
82
+ * @returns {HTMLElement}
83
+ */
84
+ export function ToggleGroup(props = {}) {
85
+ injectBase();
86
+
87
+ const { items = [], value, type, multiple, variant, size, block, disabled, onchange, class: cls } = props;
88
+
89
+ const isMulti = multiple || type === 'multiple';
90
+ const isSingle = !isMulti;
91
+
92
+ let current = typeof value === 'function' ? value() : (value || (isMulti ? [] : ''));
93
+
94
+ // Single-select uses radiogroup/radio; multi-select uses group/button+aria-pressed
95
+ const group = div({
96
+ class: cx('d-toggle-group', size && `d-toggle-group-${size}`, block && 'd-toggle-group-block', cls),
97
+ role: isSingle ? 'radiogroup' : 'group'
98
+ });
99
+
100
+ // Sliding indicator for single-select
101
+ let indicator = null;
102
+ if (isSingle) {
103
+ indicator = div({ class: 'd-toggle-indicator' });
104
+ indicator.style.opacity = '0';
105
+ group.appendChild(indicator);
106
+ }
107
+
108
+ let _rafId = null;
109
+ const rAF = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : (fn) => { fn(); return 0; };
110
+ const cAF = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : () => {};
111
+
112
+ function isSelected(val) {
113
+ return isMulti ? current.includes(val) : current === val;
114
+ }
115
+
116
+ function select(val) {
117
+ if (isMulti) {
118
+ current = current.includes(val) ? current.filter(v => v !== val) : [...current, val];
119
+ } else {
120
+ current = current === val ? '' : val;
121
+ }
122
+ updateAll();
123
+ if (onchange) onchange(current);
124
+ }
125
+
126
+ const buttons = items.map(item => {
127
+ const content = item.icon
128
+ ? (typeof item.icon === 'string' ? item.icon : item.icon)
129
+ : (item.label || item.value);
130
+
131
+ const ariaAttrs = isSingle
132
+ ? { role: 'radio', 'aria-checked': String(isSelected(item.value)) }
133
+ : { role: 'button', 'aria-pressed': String(isSelected(item.value)) };
134
+
135
+ const btn = buttonTag({
136
+ type: 'button',
137
+ class: cx('d-toggle', variant && `d-toggle-${variant}`),
138
+ 'aria-label': item.label || item.value,
139
+ disabled: item.disabled ? '' : undefined,
140
+ ...ariaAttrs
141
+ }, content);
142
+
143
+ btn.addEventListener('click', () => {
144
+ if (!item.disabled) select(item.value);
145
+ });
146
+
147
+ group.appendChild(btn);
148
+ return { btn, value: item.value };
149
+ });
150
+
151
+ function positionIndicator() {
152
+ if (!indicator) return;
153
+ const selected = buttons.find(b => isSelected(b.value));
154
+ if (selected) {
155
+ const btn = selected.btn;
156
+ const pad = typeof getComputedStyle === 'function'
157
+ ? (parseFloat(getComputedStyle(group).paddingLeft) || 0)
158
+ : 0;
159
+ indicator.style.transform = `translateX(${btn.offsetLeft - pad}px)`;
160
+ indicator.style.width = `${btn.offsetWidth}px`;
161
+ indicator.style.opacity = '1';
162
+ } else {
163
+ indicator.style.opacity = '0';
164
+ }
165
+ }
166
+
167
+ function updateAll() {
168
+ const attr = isSingle ? 'aria-checked' : 'aria-pressed';
169
+ buttons.forEach(({ btn, value: v }) => {
170
+ btn.setAttribute(attr, String(isSelected(v)));
171
+ });
172
+ if (_rafId) cAF(_rafId);
173
+ _rafId = rAF(positionIndicator);
174
+ }
175
+
176
+ // Roving tabindex — single mode auto-selects on focus; multi mode focus-only
177
+ const roving = createRovingTabindex(group, {
178
+ itemSelector: '.d-toggle:not([disabled])',
179
+ orientation: 'horizontal',
180
+ onFocus: isSingle ? (el) => el.click() : undefined
181
+ });
182
+
183
+ // Reactive value
184
+ if (typeof value === 'function') {
185
+ createEffect(() => {
186
+ current = value();
187
+ updateAll();
188
+ });
189
+ }
190
+
191
+ // Reactive group-level disabled
192
+ if (typeof disabled === 'function') {
193
+ createEffect(() => {
194
+ const v = disabled();
195
+ group.toggleAttribute('data-disabled', v);
196
+ buttons.forEach(({ btn }) => { btn.disabled = v; });
197
+ });
198
+ } else if (disabled) {
199
+ group.setAttribute('data-disabled', '');
200
+ buttons.forEach(({ btn }) => { btn.disabled = true; });
201
+ }
202
+
203
+ // Initial indicator position after mount
204
+ _rafId = rAF(positionIndicator);
205
+
206
+ // Cleanup
207
+ onDestroy(() => {
208
+ roving.destroy();
209
+ if (_rafId) cAF(_rafId);
210
+ });
211
+
212
+ return group;
213
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Tooltip — Informational popup that appears on hover or focus.
3
+ * Uses createOverlay behavior with hover trigger.
4
+ *
5
+ * @module decantr/components/tooltip
6
+ */
7
+ import { onDestroy } from '../core/index.js';
8
+ import { tags } from '../tags/index.js';
9
+ import { injectBase, cx } from './_base.js';
10
+ import { createOverlay } from './_behaviors.js';
11
+
12
+ const { div } = tags;
13
+
14
+ /**
15
+ * @param {Object} [props]
16
+ * @param {string} props.content - Tooltip text
17
+ * @param {string} [props.position] - top|bottom|left|right (default: top)
18
+ * @param {number} [props.delay] - Show delay in ms (default: 200)
19
+ * @param {string} [props.class]
20
+ * @param {...Node} children
21
+ * @returns {HTMLElement}
22
+ */
23
+ export function Tooltip(props = {}, ...children) {
24
+ injectBase();
25
+
26
+ const { content, position = 'top', delay = 200, class: cls } = props;
27
+
28
+ const tooltipId = `d-tooltip-${_tooltipId++}`;
29
+
30
+ const tooltipEl = div({
31
+ class: cx('d-tooltip', `d-tooltip-${position}`, cls),
32
+ role: 'tooltip',
33
+ id: tooltipId
34
+ }, content);
35
+
36
+ const wrapper = div({ class: 'd-tooltip-wrap', 'aria-describedby': tooltipId }, ...children, tooltipEl);
37
+
38
+ const overlay = createOverlay(wrapper, tooltipEl, {
39
+ trigger: 'hover',
40
+ hoverDelay: delay,
41
+ hoverCloseDelay: 0,
42
+ closeOnEscape: true,
43
+ closeOnOutside: false
44
+ });
45
+
46
+ // Keyboard a11y: show on focusin, hide on focusout
47
+ wrapper.addEventListener('focusin', () => overlay.open());
48
+ wrapper.addEventListener('focusout', () => overlay.close());
49
+
50
+ onDestroy(() => {
51
+ overlay.destroy();
52
+ });
53
+
54
+ return wrapper;
55
+ }
56
+
57
+ let _tooltipId = 0;
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Tour — Step-by-step onboarding guide that highlights elements on the page.
3
+ * Draws a spotlight overlay + popover with step content.
4
+ *
5
+ * @module decantr/components/tour
6
+ */
7
+ import { onDestroy } from '../core/index.js';
8
+ import { tags } from '../tags/index.js';
9
+ import { injectBase, cx } from './_base.js';
10
+
11
+ const { div, span, button: buttonTag } = tags;
12
+
13
+ /**
14
+ * @param {Object} [props]
15
+ * @param {{ target: HTMLElement|string, title?: string, description?: string, placement?: 'top'|'bottom'|'left'|'right' }[]} props.steps
16
+ * @param {Function} [props.onFinish]
17
+ * @param {Function} [props.onChange] - Called with (currentStep, direction)
18
+ * @param {Function} [props.onClose]
19
+ * @param {string} [props.class]
20
+ * @returns {{ start: Function, next: Function, prev: Function, close: Function, goTo: Function }}
21
+ */
22
+ export function Tour(props = {}) {
23
+ injectBase();
24
+ const { steps = [], onFinish, onChange, onClose, class: cls } = props;
25
+
26
+ let current = 0;
27
+ let overlayEl = null;
28
+ let popoverEl = null;
29
+
30
+ function resolveTarget(target) {
31
+ if (typeof target === 'string') return document.querySelector(target);
32
+ return target;
33
+ }
34
+
35
+ function createOverlayEl() {
36
+ return div({ class: cx('d-tour-overlay', cls) });
37
+ }
38
+
39
+ // Read the offset token at runtime
40
+ function getOffset() {
41
+ if (typeof document === 'undefined') return 12;
42
+ const val = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--d-offset-tour'), 10);
43
+ return isNaN(val) ? 12 : val;
44
+ }
45
+
46
+ function positionPopover(targetEl, placement = 'bottom') {
47
+ if (!targetEl || !popoverEl) return;
48
+ const rect = targetEl.getBoundingClientRect();
49
+ const scrollX = window.scrollX;
50
+ const scrollY = window.scrollY;
51
+ const offset = getOffset();
52
+
53
+ // Spotlight cutout
54
+ overlayEl.style.setProperty('--tour-x', `${rect.left + scrollX}px`);
55
+ overlayEl.style.setProperty('--tour-y', `${rect.top + scrollY}px`);
56
+ overlayEl.style.setProperty('--tour-w', `${rect.width}px`);
57
+ overlayEl.style.setProperty('--tour-h', `${rect.height}px`);
58
+
59
+ // Position popover — all runtime values from DOM measurement
60
+ let top, left;
61
+ if (placement === 'bottom') { top = rect.bottom + scrollY + offset; left = rect.left + scrollX; }
62
+ else if (placement === 'top') { top = rect.top + scrollY - offset; left = rect.left + scrollX; popoverEl.style.transform = 'translateY(-100%)'; }
63
+ else if (placement === 'left') { top = rect.top + scrollY; left = rect.left + scrollX - offset; popoverEl.style.transform = 'translateX(-100%)'; }
64
+ else { top = rect.top + scrollY; left = rect.right + scrollX + offset; }
65
+
66
+ popoverEl.style.position = 'absolute';
67
+ popoverEl.style.top = `${top}px`;
68
+ popoverEl.style.left = `${left}px`;
69
+ }
70
+
71
+ function renderStep() {
72
+ const step = steps[current];
73
+ if (!step) return;
74
+ const targetEl = resolveTarget(step.target);
75
+
76
+ if (popoverEl) popoverEl.remove();
77
+
78
+ const prevBtn = buttonTag({ type: 'button', class: 'd-btn d-btn-sm d-btn-outline', disabled: current === 0 }, 'Prev');
79
+ const nextBtn = buttonTag({ type: 'button', class: 'd-btn d-btn-sm d-btn-primary' },
80
+ current === steps.length - 1 ? 'Finish' : 'Next');
81
+ const closeBtn = buttonTag({ type: 'button', class: 'd-tour-close', 'aria-label': 'Close tour' }, '\u00d7');
82
+
83
+ const body = div({ class: 'd-tour-body' });
84
+ if (step.title) body.appendChild(div({ class: 'd-tour-title' }, step.title));
85
+ if (step.description) body.appendChild(div({ class: 'd-tour-desc' }, step.description));
86
+
87
+ const footer = div({ class: 'd-tour-footer' },
88
+ span({ class: 'd-tour-steps' }, `${current + 1} / ${steps.length}`),
89
+ div({ class: 'd-tour-actions' }, prevBtn, nextBtn)
90
+ );
91
+
92
+ popoverEl = div({ class: cx('d-tour-popover', cls) }, closeBtn, body, footer);
93
+ document.body.appendChild(popoverEl);
94
+
95
+ prevBtn.addEventListener('click', prev);
96
+ nextBtn.addEventListener('click', () => {
97
+ if (current === steps.length - 1) { close(); if (onFinish) onFinish(); }
98
+ else next();
99
+ });
100
+ closeBtn.addEventListener('click', close);
101
+
102
+ if (targetEl) {
103
+ targetEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
104
+ requestAnimationFrame(() => positionPopover(targetEl, step.placement));
105
+ }
106
+ }
107
+
108
+ function start(stepIndex = 0) {
109
+ if (typeof document === 'undefined') return;
110
+ current = stepIndex;
111
+ overlayEl = createOverlayEl();
112
+ document.body.appendChild(overlayEl);
113
+ renderStep();
114
+
115
+ // Close on Escape
116
+ document.addEventListener('keydown', _onKey);
117
+ }
118
+
119
+ function _onKey(e) {
120
+ if (e.key === 'Escape') close();
121
+ }
122
+
123
+ function next() {
124
+ if (current < steps.length - 1) {
125
+ current++;
126
+ if (onChange) onChange(current, 'next');
127
+ renderStep();
128
+ }
129
+ }
130
+
131
+ function prev() {
132
+ if (current > 0) {
133
+ current--;
134
+ if (onChange) onChange(current, 'prev');
135
+ renderStep();
136
+ }
137
+ }
138
+
139
+ function goTo(index) {
140
+ if (index >= 0 && index < steps.length) {
141
+ current = index;
142
+ if (onChange) onChange(current, 'goto');
143
+ renderStep();
144
+ }
145
+ }
146
+
147
+ function close() {
148
+ if (overlayEl) { overlayEl.remove(); overlayEl = null; }
149
+ if (popoverEl) { popoverEl.remove(); popoverEl = null; }
150
+ document.removeEventListener('keydown', _onKey);
151
+ if (onClose) onClose();
152
+ }
153
+
154
+ onDestroy(() => {
155
+ close();
156
+ });
157
+
158
+ return { start, next, prev, close, goTo };
159
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Transfer — Dual-list transfer component with search and selection.
3
+ *
4
+ * @module decantr/components/transfer
5
+ */
6
+ import { h } from '../core/index.js';
7
+ import { createEffect, createSignal } from '../state/index.js';
8
+ import { injectBase, cx } from './_base.js';
9
+ import { caret, createCheckControl } from './_behaviors.js';
10
+
11
+ /**
12
+ * @param {Object} [props]
13
+ * @param {{ key: string, label: string, disabled?: boolean }[]} [props.dataSource=[]]
14
+ * @param {string[]} [props.targetKeys=[]] - Keys in right panel
15
+ * @param {boolean} [props.searchable=false]
16
+ * @param {string[]} [props.titles=['Source', 'Target']]
17
+ * @param {Function} [props.onchange] - Called with (targetKeys, direction, movedKeys)
18
+ * @param {string} [props.class]
19
+ * @returns {HTMLElement}
20
+ */
21
+ export function Transfer(props = {}) {
22
+ injectBase();
23
+ const { dataSource = [], targetKeys: initTarget = [], searchable = false, titles = ['Source', 'Target'], onchange, class: cls } = props;
24
+
25
+ let targetKeys = [...initTarget];
26
+ let leftChecked = new Set();
27
+ let rightChecked = new Set();
28
+
29
+ const container = h('div', { class: cx('d-transfer', cls) });
30
+
31
+ function getLeftItems() {
32
+ return dataSource.filter(d => !targetKeys.includes(d.key));
33
+ }
34
+
35
+ function getRightItems() {
36
+ return dataSource.filter(d => targetKeys.includes(d.key));
37
+ }
38
+
39
+ function renderPanel(items, checked, searchFilter, title) {
40
+ const panel = h('div', { class: 'd-transfer-panel' });
41
+
42
+ // Header
43
+ const allChecked = items.length > 0 && items.filter(i => !i.disabled).every(i => checked.has(i.key));
44
+ const { wrap: selectAllWrap, input: selectAll } = createCheckControl();
45
+ selectAll.checked = allChecked;
46
+ selectAll.indeterminate = checked.size > 0 && !allChecked;
47
+ selectAll.addEventListener('change', () => {
48
+ if (selectAll.checked) items.filter(i => !i.disabled).forEach(i => checked.add(i.key));
49
+ else checked.clear();
50
+ render();
51
+ });
52
+
53
+ const header = h('div', { class: 'd-transfer-header' },
54
+ h('label', null,
55
+ selectAllWrap,
56
+ h('span', null, `${checked.size}/${items.length}`)
57
+ ),
58
+ h('span', null, title)
59
+ );
60
+ panel.appendChild(header);
61
+
62
+ // Search
63
+ let filteredItems = items;
64
+ if (searchable) {
65
+ const search = h('input', {
66
+ type: 'text',
67
+ class: 'd-input',
68
+ placeholder: 'Search...',
69
+ });
70
+ search.addEventListener('input', () => {
71
+ searchFilter.value = search.value.toLowerCase();
72
+ render();
73
+ });
74
+ panel.appendChild(h('div', { class: 'd-transfer-search' }, search));
75
+ if (searchFilter.value) {
76
+ filteredItems = items.filter(i => i.label.toLowerCase().includes(searchFilter.value));
77
+ }
78
+ }
79
+
80
+ // Body
81
+ const body = h('div', { class: 'd-transfer-body' });
82
+ filteredItems.forEach(item => {
83
+ const { wrap: cbWrap, input: cb } = createCheckControl({ disabled: item.disabled ? '' : undefined });
84
+ cb.checked = checked.has(item.key);
85
+ cb.addEventListener('change', () => {
86
+ if (cb.checked) checked.add(item.key);
87
+ else checked.delete(item.key);
88
+ render();
89
+ });
90
+
91
+ const row = h('div', {
92
+ class: cx('d-transfer-item', item.disabled && 'd-transfer-item-disabled')
93
+ }, cbWrap, h('span', null, item.label));
94
+
95
+ if (!item.disabled) {
96
+ row.addEventListener('click', (e) => {
97
+ if (e.target === cb) return;
98
+ cb.checked = !cb.checked;
99
+ if (cb.checked) checked.add(item.key);
100
+ else checked.delete(item.key);
101
+ render();
102
+ });
103
+ }
104
+
105
+ body.appendChild(row);
106
+ });
107
+ panel.appendChild(body);
108
+
109
+ return panel;
110
+ }
111
+
112
+ const leftSearch = { value: '' };
113
+ const rightSearch = { value: '' };
114
+
115
+ function render() {
116
+ container.replaceChildren();
117
+
118
+ const leftItems = getLeftItems();
119
+ const rightItems = getRightItems();
120
+
121
+ const leftPanel = renderPanel(leftItems, leftChecked, leftSearch, titles[0]);
122
+ const rightPanel = renderPanel(rightItems, rightChecked, rightSearch, titles[1]);
123
+
124
+ // Action buttons
125
+ const moveRight = h('button', {
126
+ type: 'button',
127
+ class: 'd-btn d-btn-sm',
128
+ disabled: leftChecked.size === 0 ? '' : undefined,
129
+ 'aria-label': 'Move to target'
130
+ }, caret('right'));
131
+ const moveLeft = h('button', {
132
+ type: 'button',
133
+ class: 'd-btn d-btn-sm',
134
+ disabled: rightChecked.size === 0 ? '' : undefined,
135
+ 'aria-label': 'Move to source'
136
+ }, caret('left'));
137
+
138
+ moveRight.addEventListener('click', () => {
139
+ const moved = [...leftChecked];
140
+ targetKeys = [...targetKeys, ...moved];
141
+ leftChecked.clear();
142
+ render();
143
+ if (onchange) onchange(targetKeys, 'right', moved);
144
+ });
145
+
146
+ moveLeft.addEventListener('click', () => {
147
+ const moved = [...rightChecked];
148
+ targetKeys = targetKeys.filter(k => !rightChecked.has(k));
149
+ rightChecked.clear();
150
+ render();
151
+ if (onchange) onchange(targetKeys, 'left', moved);
152
+ });
153
+
154
+ const actions = h('div', { class: 'd-transfer-actions' }, moveRight, moveLeft);
155
+
156
+ container.appendChild(leftPanel);
157
+ container.appendChild(actions);
158
+ container.appendChild(rightPanel);
159
+ }
160
+
161
+ render();
162
+ return container;
163
+ }