@lushly-dev/violet-elements 0.0.0-stage → 0.2.0-preview.1

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 (426) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +262 -2
  3. package/custom-elements.json +42309 -0
  4. package/dist/accordion/violet-accordion.d.ts +24 -0
  5. package/dist/accordion/violet-accordion.js +133 -0
  6. package/dist/accordion/violet-accordion.js.map +1 -0
  7. package/dist/accordion-item/violet-accordion-item.d.ts +27 -0
  8. package/dist/accordion-item/violet-accordion-item.js +228 -0
  9. package/dist/accordion-item/violet-accordion-item.js.map +1 -0
  10. package/dist/alert/violet-alert.d.ts +44 -0
  11. package/dist/alert/violet-alert.js +346 -0
  12. package/dist/alert/violet-alert.js.map +1 -0
  13. package/dist/badge/violet-badge.d.ts +27 -0
  14. package/dist/badge/violet-badge.js +179 -0
  15. package/dist/badge/violet-badge.js.map +1 -0
  16. package/dist/breadcrumb/violet-breadcrumb.d.ts +20 -0
  17. package/dist/breadcrumb/violet-breadcrumb.js +88 -0
  18. package/dist/breadcrumb/violet-breadcrumb.js.map +1 -0
  19. package/dist/breadcrumb-item/violet-breadcrumb-item.d.ts +20 -0
  20. package/dist/breadcrumb-item/violet-breadcrumb-item.js +130 -0
  21. package/dist/breadcrumb-item/violet-breadcrumb-item.js.map +1 -0
  22. package/dist/button/violet-button.d.ts +76 -0
  23. package/dist/button/violet-button.js +281 -0
  24. package/dist/button/violet-button.js.map +1 -0
  25. package/dist/calendar/violet-calendar.d.ts +59 -0
  26. package/dist/calendar/violet-calendar.js +485 -0
  27. package/dist/calendar/violet-calendar.js.map +1 -0
  28. package/dist/card/violet-card.d.ts +30 -0
  29. package/dist/card/violet-card.js +249 -0
  30. package/dist/card/violet-card.js.map +1 -0
  31. package/dist/carousel/violet-carousel.d.ts +56 -0
  32. package/dist/carousel/violet-carousel.js +600 -0
  33. package/dist/carousel/violet-carousel.js.map +1 -0
  34. package/dist/checkbox/violet-checkbox.d.ts +82 -0
  35. package/dist/checkbox/violet-checkbox.js +465 -0
  36. package/dist/checkbox/violet-checkbox.js.map +1 -0
  37. package/dist/color-picker/violet-color-picker.d.ts +111 -0
  38. package/dist/color-picker/violet-color-picker.js +997 -0
  39. package/dist/color-picker/violet-color-picker.js.map +1 -0
  40. package/dist/color-picker/violet-color-utils.d.ts +21 -0
  41. package/dist/color-picker/violet-color-utils.js +126 -0
  42. package/dist/color-picker/violet-color-utils.js.map +1 -0
  43. package/dist/color-swatch/violet-color-swatch.d.ts +19 -0
  44. package/dist/color-swatch/violet-color-swatch.js +93 -0
  45. package/dist/color-swatch/violet-color-swatch.js.map +1 -0
  46. package/dist/combobox/violet-combobox.d.ts +86 -0
  47. package/dist/combobox/violet-combobox.js +669 -0
  48. package/dist/combobox/violet-combobox.js.map +1 -0
  49. package/dist/conversation/violet-approval-card.d.ts +34 -0
  50. package/dist/conversation/violet-approval-card.js +289 -0
  51. package/dist/conversation/violet-approval-card.js.map +1 -0
  52. package/dist/conversation/violet-chat-composer.d.ts +47 -0
  53. package/dist/conversation/violet-chat-composer.js +308 -0
  54. package/dist/conversation/violet-chat-composer.js.map +1 -0
  55. package/dist/conversation/violet-chat-suggestions.d.ts +21 -0
  56. package/dist/conversation/violet-chat-suggestions.js +159 -0
  57. package/dist/conversation/violet-chat-suggestions.js.map +1 -0
  58. package/dist/conversation/violet-conversation-thread.d.ts +26 -0
  59. package/dist/conversation/violet-conversation-thread.js +207 -0
  60. package/dist/conversation/violet-conversation-thread.js.map +1 -0
  61. package/dist/conversation/violet-message-media.d.ts +38 -0
  62. package/dist/conversation/violet-message-media.js +230 -0
  63. package/dist/conversation/violet-message-media.js.map +1 -0
  64. package/dist/conversation/violet-message-status.d.ts +17 -0
  65. package/dist/conversation/violet-message-status.js +168 -0
  66. package/dist/conversation/violet-message-status.js.map +1 -0
  67. package/dist/conversation/violet-message-text.d.ts +15 -0
  68. package/dist/conversation/violet-message-text.js +83 -0
  69. package/dist/conversation/violet-message-text.js.map +1 -0
  70. package/dist/conversation/violet-message.d.ts +28 -0
  71. package/dist/conversation/violet-message.js +189 -0
  72. package/dist/conversation/violet-message.js.map +1 -0
  73. package/dist/conversation/violet-reasoning-block.d.ts +22 -0
  74. package/dist/conversation/violet-reasoning-block.js +171 -0
  75. package/dist/conversation/violet-reasoning-block.js.map +1 -0
  76. package/dist/conversation/violet-source-citation.d.ts +25 -0
  77. package/dist/conversation/violet-source-citation.js +155 -0
  78. package/dist/conversation/violet-source-citation.js.map +1 -0
  79. package/dist/conversation/violet-tool-call-card.d.ts +37 -0
  80. package/dist/conversation/violet-tool-call-card.js +370 -0
  81. package/dist/conversation/violet-tool-call-card.js.map +1 -0
  82. package/dist/conversation/violet-tool-result-card.d.ts +27 -0
  83. package/dist/conversation/violet-tool-result-card.js +264 -0
  84. package/dist/conversation/violet-tool-result-card.js.map +1 -0
  85. package/dist/data-grid/violet-data-grid-attachment-cell-values.d.ts +15 -0
  86. package/dist/data-grid/violet-data-grid-attachment-cell-values.js +122 -0
  87. package/dist/data-grid/violet-data-grid-attachment-cell-values.js.map +1 -0
  88. package/dist/data-grid/violet-data-grid-attachment-cell.d.ts +79 -0
  89. package/dist/data-grid/violet-data-grid-attachment-cell.js +812 -0
  90. package/dist/data-grid/violet-data-grid-attachment-cell.js.map +1 -0
  91. package/dist/data-grid/violet-data-grid-cell-state.d.ts +20 -0
  92. package/dist/data-grid/violet-data-grid-cell-state.js +68 -0
  93. package/dist/data-grid/violet-data-grid-cell-state.js.map +1 -0
  94. package/dist/data-grid/violet-data-grid-cell-templates.d.ts +28 -0
  95. package/dist/data-grid/violet-data-grid-cell-templates.js +36 -0
  96. package/dist/data-grid/violet-data-grid-cell-templates.js.map +1 -0
  97. package/dist/data-grid/violet-data-grid-clipboard.d.ts +44 -0
  98. package/dist/data-grid/violet-data-grid-clipboard.js +127 -0
  99. package/dist/data-grid/violet-data-grid-clipboard.js.map +1 -0
  100. package/dist/data-grid/violet-data-grid-css.d.ts +7 -0
  101. package/dist/data-grid/violet-data-grid-css.js +20 -0
  102. package/dist/data-grid/violet-data-grid-css.js.map +1 -0
  103. package/dist/data-grid/violet-data-grid-data.d.ts +34 -0
  104. package/dist/data-grid/violet-data-grid-data.js +93 -0
  105. package/dist/data-grid/violet-data-grid-data.js.map +1 -0
  106. package/dist/data-grid/violet-data-grid-editing.d.ts +46 -0
  107. package/dist/data-grid/violet-data-grid-editing.js +75 -0
  108. package/dist/data-grid/violet-data-grid-editing.js.map +1 -0
  109. package/dist/data-grid/violet-data-grid-editor-option-helpers.d.ts +10 -0
  110. package/dist/data-grid/violet-data-grid-editor-option-helpers.js +84 -0
  111. package/dist/data-grid/violet-data-grid-editor-option-helpers.js.map +1 -0
  112. package/dist/data-grid/violet-data-grid-events.d.ts +4 -0
  113. package/dist/data-grid/violet-data-grid-events.js +46 -0
  114. package/dist/data-grid/violet-data-grid-events.js.map +1 -0
  115. package/dist/data-grid/violet-data-grid-fill.d.ts +37 -0
  116. package/dist/data-grid/violet-data-grid-fill.js +155 -0
  117. package/dist/data-grid/violet-data-grid-fill.js.map +1 -0
  118. package/dist/data-grid/violet-data-grid-geometry.d.ts +13 -0
  119. package/dist/data-grid/violet-data-grid-geometry.js +59 -0
  120. package/dist/data-grid/violet-data-grid-geometry.js.map +1 -0
  121. package/dist/data-grid/violet-data-grid-multi-picker-values.d.ts +3 -0
  122. package/dist/data-grid/violet-data-grid-multi-picker-values.js +40 -0
  123. package/dist/data-grid/violet-data-grid-multi-picker-values.js.map +1 -0
  124. package/dist/data-grid/violet-data-grid-multi-picker.d.ts +87 -0
  125. package/dist/data-grid/violet-data-grid-multi-picker.js +789 -0
  126. package/dist/data-grid/violet-data-grid-multi-picker.js.map +1 -0
  127. package/dist/data-grid/violet-data-grid-navigation.d.ts +29 -0
  128. package/dist/data-grid/violet-data-grid-navigation.js +63 -0
  129. package/dist/data-grid/violet-data-grid-navigation.js.map +1 -0
  130. package/dist/data-grid/violet-data-grid-persona-picker-values.d.ts +3 -0
  131. package/dist/data-grid/violet-data-grid-persona-picker-values.js +40 -0
  132. package/dist/data-grid/violet-data-grid-persona-picker-values.js.map +1 -0
  133. package/dist/data-grid/violet-data-grid-persona-picker.d.ts +86 -0
  134. package/dist/data-grid/violet-data-grid-persona-picker.js +840 -0
  135. package/dist/data-grid/violet-data-grid-persona-picker.js.map +1 -0
  136. package/dist/data-grid/violet-data-grid-pill-select.d.ts +65 -0
  137. package/dist/data-grid/violet-data-grid-pill-select.js +635 -0
  138. package/dist/data-grid/violet-data-grid-pill-select.js.map +1 -0
  139. package/dist/data-grid/violet-data-grid-pointer.d.ts +17 -0
  140. package/dist/data-grid/violet-data-grid-pointer.js +45 -0
  141. package/dist/data-grid/violet-data-grid-pointer.js.map +1 -0
  142. package/dist/data-grid/violet-data-grid-presentation.d.ts +142 -0
  143. package/dist/data-grid/violet-data-grid-presentation.js +152 -0
  144. package/dist/data-grid/violet-data-grid-presentation.js.map +1 -0
  145. package/dist/data-grid/violet-data-grid-rating-values.d.ts +3 -0
  146. package/dist/data-grid/violet-data-grid-rating-values.js +30 -0
  147. package/dist/data-grid/violet-data-grid-rating-values.js.map +1 -0
  148. package/dist/data-grid/violet-data-grid-rating.d.ts +39 -0
  149. package/dist/data-grid/violet-data-grid-rating.js +346 -0
  150. package/dist/data-grid/violet-data-grid-rating.js.map +1 -0
  151. package/dist/data-grid/violet-data-grid-reference-picker-values.d.ts +3 -0
  152. package/dist/data-grid/violet-data-grid-reference-picker-values.js +40 -0
  153. package/dist/data-grid/violet-data-grid-reference-picker-values.js.map +1 -0
  154. package/dist/data-grid/violet-data-grid-reference-picker.d.ts +98 -0
  155. package/dist/data-grid/violet-data-grid-reference-picker.js +933 -0
  156. package/dist/data-grid/violet-data-grid-reference-picker.js.map +1 -0
  157. package/dist/data-grid/violet-data-grid-resize.d.ts +36 -0
  158. package/dist/data-grid/violet-data-grid-resize.js +47 -0
  159. package/dist/data-grid/violet-data-grid-resize.js.map +1 -0
  160. package/dist/data-grid/violet-data-grid-selection.d.ts +27 -0
  161. package/dist/data-grid/violet-data-grid-selection.js +88 -0
  162. package/dist/data-grid/violet-data-grid-selection.js.map +1 -0
  163. package/dist/data-grid/violet-data-grid-sizing.d.ts +38 -0
  164. package/dist/data-grid/violet-data-grid-sizing.js +82 -0
  165. package/dist/data-grid/violet-data-grid-sizing.js.map +1 -0
  166. package/dist/data-grid/violet-data-grid-targets.d.ts +5 -0
  167. package/dist/data-grid/violet-data-grid-targets.js +41 -0
  168. package/dist/data-grid/violet-data-grid-targets.js.map +1 -0
  169. package/dist/data-grid/violet-data-grid-values.d.ts +19 -0
  170. package/dist/data-grid/violet-data-grid-values.js +60 -0
  171. package/dist/data-grid/violet-data-grid-values.js.map +1 -0
  172. package/dist/data-grid/violet-data-grid-virtualization.d.ts +31 -0
  173. package/dist/data-grid/violet-data-grid-virtualization.js +41 -0
  174. package/dist/data-grid/violet-data-grid-virtualization.js.map +1 -0
  175. package/dist/data-grid/violet-data-grid.d.ts +590 -0
  176. package/dist/data-grid/violet-data-grid.js +2998 -0
  177. package/dist/data-grid/violet-data-grid.js.map +1 -0
  178. package/dist/data-grid/violet-data-grid.styles.d.ts +1 -0
  179. package/dist/data-grid/violet-data-grid.styles.js +638 -0
  180. package/dist/data-grid/violet-data-grid.styles.js.map +1 -0
  181. package/dist/date-picker/violet-date-picker.d.ts +90 -0
  182. package/dist/date-picker/violet-date-picker.js +624 -0
  183. package/dist/date-picker/violet-date-picker.js.map +1 -0
  184. package/dist/date-range-picker/violet-date-range-picker.d.ts +64 -0
  185. package/dist/date-range-picker/violet-date-range-picker.js +470 -0
  186. package/dist/date-range-picker/violet-date-range-picker.js.map +1 -0
  187. package/dist/date-time/violet-date-utils.d.ts +50 -0
  188. package/dist/date-time/violet-date-utils.js +176 -0
  189. package/dist/date-time/violet-date-utils.js.map +1 -0
  190. package/dist/dialog/violet-dialog.d.ts +53 -0
  191. package/dist/dialog/violet-dialog.js +439 -0
  192. package/dist/dialog/violet-dialog.js.map +1 -0
  193. package/dist/divider/violet-divider.d.ts +15 -0
  194. package/dist/divider/violet-divider.js +88 -0
  195. package/dist/divider/violet-divider.js.map +1 -0
  196. package/dist/empty-state/violet-empty-state.d.ts +31 -0
  197. package/dist/empty-state/violet-empty-state.js +182 -0
  198. package/dist/empty-state/violet-empty-state.js.map +1 -0
  199. package/dist/file-explorer/violet-file-explorer.d.ts +164 -0
  200. package/dist/file-explorer/violet-file-explorer.js +1094 -0
  201. package/dist/file-explorer/violet-file-explorer.js.map +1 -0
  202. package/dist/file-upload/violet-file-upload.d.ts +109 -0
  203. package/dist/file-upload/violet-file-upload.js +950 -0
  204. package/dist/file-upload/violet-file-upload.js.map +1 -0
  205. package/dist/foundations/reference-component-set.d.ts +9 -0
  206. package/dist/foundations/reference-component-set.js +107 -0
  207. package/dist/foundations/reference-component-set.js.map +1 -0
  208. package/dist/foundations/token-registry.d.ts +38 -0
  209. package/dist/foundations/token-registry.js +203 -0
  210. package/dist/foundations/token-registry.js.map +1 -0
  211. package/dist/foundations/violet-direction.d.ts +11 -0
  212. package/dist/foundations/violet-direction.js +22 -0
  213. package/dist/foundations/violet-direction.js.map +1 -0
  214. package/dist/foundations/violet-form-disabled.d.ts +25 -0
  215. package/dist/foundations/violet-form-disabled.js +79 -0
  216. package/dist/foundations/violet-form-disabled.js.map +1 -0
  217. package/dist/foundations/violet-safe-url.d.ts +8 -0
  218. package/dist/foundations/violet-safe-url.js +21 -0
  219. package/dist/foundations/violet-safe-url.js.map +1 -0
  220. package/dist/gantt/violet-gantt-geometry.d.ts +18 -0
  221. package/dist/gantt/violet-gantt-geometry.js +78 -0
  222. package/dist/gantt/violet-gantt-geometry.js.map +1 -0
  223. package/dist/gantt/violet-gantt.d.ts +239 -0
  224. package/dist/gantt/violet-gantt.js +1627 -0
  225. package/dist/gantt/violet-gantt.js.map +1 -0
  226. package/dist/gantt/violet-gantt.styles.d.ts +1 -0
  227. package/dist/gantt/violet-gantt.styles.js +580 -0
  228. package/dist/gantt/violet-gantt.styles.js.map +1 -0
  229. package/dist/icon/generated/icon-sources.d.ts +9 -0
  230. package/dist/icon/generated/icon-sources.js +15 -0
  231. package/dist/icon/generated/icon-sources.js.map +1 -0
  232. package/dist/icon/generated/icons/system-arrow-up.d.ts +8 -0
  233. package/dist/icon/generated/icons/system-arrow-up.js +15 -0
  234. package/dist/icon/generated/icons/system-arrow-up.js.map +1 -0
  235. package/dist/icon/generated/icons/system-attach.d.ts +8 -0
  236. package/dist/icon/generated/icons/system-attach.js +15 -0
  237. package/dist/icon/generated/icons/system-attach.js.map +1 -0
  238. package/dist/icon/generated/icons/system-calendar.d.ts +8 -0
  239. package/dist/icon/generated/icons/system-calendar.js +15 -0
  240. package/dist/icon/generated/icons/system-calendar.js.map +1 -0
  241. package/dist/icon/generated/icons/system-checkmark.d.ts +8 -0
  242. package/dist/icon/generated/icons/system-checkmark.js +15 -0
  243. package/dist/icon/generated/icons/system-checkmark.js.map +1 -0
  244. package/dist/icon/generated/icons/system-chevron-right.d.ts +8 -0
  245. package/dist/icon/generated/icons/system-chevron-right.js +15 -0
  246. package/dist/icon/generated/icons/system-chevron-right.js.map +1 -0
  247. package/dist/icon/generated/icons/system-clock.d.ts +8 -0
  248. package/dist/icon/generated/icons/system-clock.js +15 -0
  249. package/dist/icon/generated/icons/system-clock.js.map +1 -0
  250. package/dist/icon/generated/icons/system-close.d.ts +8 -0
  251. package/dist/icon/generated/icons/system-close.js +15 -0
  252. package/dist/icon/generated/icons/system-close.js.map +1 -0
  253. package/dist/icon/generated/icons/system-dismiss.d.ts +8 -0
  254. package/dist/icon/generated/icons/system-dismiss.js +15 -0
  255. package/dist/icon/generated/icons/system-dismiss.js.map +1 -0
  256. package/dist/icon/generated/icons/system-document.d.ts +8 -0
  257. package/dist/icon/generated/icons/system-document.js +15 -0
  258. package/dist/icon/generated/icons/system-document.js.map +1 -0
  259. package/dist/icon/generated/icons/system-folder.d.ts +8 -0
  260. package/dist/icon/generated/icons/system-folder.js +15 -0
  261. package/dist/icon/generated/icons/system-folder.js.map +1 -0
  262. package/dist/icon/generated/icons/system-search.d.ts +8 -0
  263. package/dist/icon/generated/icons/system-search.js +15 -0
  264. package/dist/icon/generated/icons/system-search.js.map +1 -0
  265. package/dist/icon/generated/icons/system-settings.d.ts +8 -0
  266. package/dist/icon/generated/icons/system-settings.js +15 -0
  267. package/dist/icon/generated/icons/system-settings.js.map +1 -0
  268. package/dist/icon/generated/icons/system-sort-ascending.d.ts +8 -0
  269. package/dist/icon/generated/icons/system-sort-ascending.js +15 -0
  270. package/dist/icon/generated/icons/system-sort-ascending.js.map +1 -0
  271. package/dist/icon/generated/icons/system-sort-descending.d.ts +8 -0
  272. package/dist/icon/generated/icons/system-sort-descending.js +15 -0
  273. package/dist/icon/generated/icons/system-sort-descending.js.map +1 -0
  274. package/dist/icon/generated/icons/system-stop.d.ts +8 -0
  275. package/dist/icon/generated/icons/system-stop.js +15 -0
  276. package/dist/icon/generated/icons/system-stop.js.map +1 -0
  277. package/dist/icon/generated/icons/system-warning.d.ts +8 -0
  278. package/dist/icon/generated/icons/system-warning.js +15 -0
  279. package/dist/icon/generated/icons/system-warning.js.map +1 -0
  280. package/dist/icon/generated/index.d.ts +17 -0
  281. package/dist/icon/generated/index.js +22 -0
  282. package/dist/icon/generated/index.js.map +1 -0
  283. package/dist/icon/icon-registry.d.ts +20 -0
  284. package/dist/icon/icon-registry.js +22 -0
  285. package/dist/icon/icon-registry.js.map +1 -0
  286. package/dist/icon/violet-icon.d.ts +22 -0
  287. package/dist/icon/violet-icon.js +75 -0
  288. package/dist/icon/violet-icon.js.map +1 -0
  289. package/dist/icon-button/violet-icon-button.d.ts +29 -0
  290. package/dist/icon-button/violet-icon-button.js +193 -0
  291. package/dist/icon-button/violet-icon-button.js.map +1 -0
  292. package/dist/image/violet-image.d.ts +33 -0
  293. package/dist/image/violet-image.js +215 -0
  294. package/dist/image/violet-image.js.map +1 -0
  295. package/dist/index.d.ts +86 -0
  296. package/dist/index.js +87 -0
  297. package/dist/index.js.map +1 -0
  298. package/dist/listbox/violet-listbox.d.ts +41 -0
  299. package/dist/listbox/violet-listbox.js +323 -0
  300. package/dist/listbox/violet-listbox.js.map +1 -0
  301. package/dist/listbox/violet-selection-helpers.d.ts +9 -0
  302. package/dist/listbox/violet-selection-helpers.js +52 -0
  303. package/dist/listbox/violet-selection-helpers.js.map +1 -0
  304. package/dist/menu/violet-menu-item.d.ts +30 -0
  305. package/dist/menu/violet-menu-item.js +148 -0
  306. package/dist/menu/violet-menu-item.js.map +1 -0
  307. package/dist/menu/violet-menu.d.ts +70 -0
  308. package/dist/menu/violet-menu.js +480 -0
  309. package/dist/menu/violet-menu.js.map +1 -0
  310. package/dist/option/violet-option.d.ts +38 -0
  311. package/dist/option/violet-option.js +258 -0
  312. package/dist/option/violet-option.js.map +1 -0
  313. package/dist/option-group/violet-option-group.d.ts +20 -0
  314. package/dist/option-group/violet-option-group.js +100 -0
  315. package/dist/option-group/violet-option-group.js.map +1 -0
  316. package/dist/pagination/violet-pagination.d.ts +36 -0
  317. package/dist/pagination/violet-pagination.js +356 -0
  318. package/dist/pagination/violet-pagination.js.map +1 -0
  319. package/dist/persona/violet-persona.d.ts +28 -0
  320. package/dist/persona/violet-persona.js +250 -0
  321. package/dist/persona/violet-persona.js.map +1 -0
  322. package/dist/popover/violet-popover.d.ts +32 -0
  323. package/dist/popover/violet-popover.js +225 -0
  324. package/dist/popover/violet-popover.js.map +1 -0
  325. package/dist/progress/violet-progress.d.ts +22 -0
  326. package/dist/progress/violet-progress.js +197 -0
  327. package/dist/progress/violet-progress.js.map +1 -0
  328. package/dist/radio/violet-radio.d.ts +59 -0
  329. package/dist/radio/violet-radio.js +402 -0
  330. package/dist/radio/violet-radio.js.map +1 -0
  331. package/dist/radio-group/violet-radio-group.d.ts +89 -0
  332. package/dist/radio-group/violet-radio-group.js +388 -0
  333. package/dist/radio-group/violet-radio-group.js.map +1 -0
  334. package/dist/segment/violet-segment.d.ts +29 -0
  335. package/dist/segment/violet-segment.js +166 -0
  336. package/dist/segment/violet-segment.js.map +1 -0
  337. package/dist/segmented-control/violet-segmented-control.d.ts +64 -0
  338. package/dist/segmented-control/violet-segmented-control.js +349 -0
  339. package/dist/segmented-control/violet-segmented-control.js.map +1 -0
  340. package/dist/select/violet-select.d.ts +84 -0
  341. package/dist/select/violet-select.js +690 -0
  342. package/dist/select/violet-select.js.map +1 -0
  343. package/dist/skeleton/violet-skeleton.d.ts +18 -0
  344. package/dist/skeleton/violet-skeleton.js +150 -0
  345. package/dist/skeleton/violet-skeleton.js.map +1 -0
  346. package/dist/slider/violet-range-slider.d.ts +96 -0
  347. package/dist/slider/violet-range-slider.js +833 -0
  348. package/dist/slider/violet-range-slider.js.map +1 -0
  349. package/dist/slider/violet-slider.d.ts +80 -0
  350. package/dist/slider/violet-slider.js +666 -0
  351. package/dist/slider/violet-slider.js.map +1 -0
  352. package/dist/snackbar/violet-snackbar.d.ts +39 -0
  353. package/dist/snackbar/violet-snackbar.js +310 -0
  354. package/dist/snackbar/violet-snackbar.js.map +1 -0
  355. package/dist/spinner/violet-spinner.d.ts +15 -0
  356. package/dist/spinner/violet-spinner.js +99 -0
  357. package/dist/spinner/violet-spinner.js.map +1 -0
  358. package/dist/switch/violet-switch.d.ts +59 -0
  359. package/dist/switch/violet-switch.js +459 -0
  360. package/dist/switch/violet-switch.js.map +1 -0
  361. package/dist/tab/violet-tab.d.ts +23 -0
  362. package/dist/tab/violet-tab.js +245 -0
  363. package/dist/tab/violet-tab.js.map +1 -0
  364. package/dist/tab-panel/violet-tab-panel.d.ts +10 -0
  365. package/dist/tab-panel/violet-tab-panel.js +46 -0
  366. package/dist/tab-panel/violet-tab-panel.js.map +1 -0
  367. package/dist/tabs/violet-tabs.d.ts +48 -0
  368. package/dist/tabs/violet-tabs.js +398 -0
  369. package/dist/tabs/violet-tabs.js.map +1 -0
  370. package/dist/teaching-tip/violet-teaching-tip.d.ts +48 -0
  371. package/dist/teaching-tip/violet-teaching-tip.js +418 -0
  372. package/dist/teaching-tip/violet-teaching-tip.js.map +1 -0
  373. package/dist/text/violet-text.d.ts +18 -0
  374. package/dist/text/violet-text.js +128 -0
  375. package/dist/text/violet-text.js.map +1 -0
  376. package/dist/text-area/violet-text-area.d.ts +93 -0
  377. package/dist/text-area/violet-text-area.js +323 -0
  378. package/dist/text-area/violet-text-area.js.map +1 -0
  379. package/dist/text-field/violet-text-field.d.ts +132 -0
  380. package/dist/text-field/violet-text-field.js +445 -0
  381. package/dist/text-field/violet-text-field.js.map +1 -0
  382. package/dist/theme/generated/violet-theme-presets.generated.d.ts +9 -0
  383. package/dist/theme/generated/violet-theme-presets.generated.js +9 -0
  384. package/dist/theme/generated/violet-theme-presets.generated.js.map +1 -0
  385. package/dist/theme/generated/violet-theme.generated.d.ts +1048 -0
  386. package/dist/theme/generated/violet-theme.generated.js +362 -0
  387. package/dist/theme/generated/violet-theme.generated.js.map +1 -0
  388. package/dist/theme/index.d.ts +4 -0
  389. package/dist/theme/index.js +7 -0
  390. package/dist/theme/index.js.map +1 -0
  391. package/dist/theme/violet-theme-builtin.d.ts +14 -0
  392. package/dist/theme/violet-theme-builtin.js +19 -0
  393. package/dist/theme/violet-theme-builtin.js.map +1 -0
  394. package/dist/theme/violet-theme-css.d.ts +77 -0
  395. package/dist/theme/violet-theme-css.js +154 -0
  396. package/dist/theme/violet-theme-css.js.map +1 -0
  397. package/dist/theme/violet-theme-runtime.d.ts +72 -0
  398. package/dist/theme/violet-theme-runtime.js +221 -0
  399. package/dist/theme/violet-theme-runtime.js.map +1 -0
  400. package/dist/theme/violet-theme.d.ts +22 -0
  401. package/dist/theme/violet-theme.js +60 -0
  402. package/dist/theme/violet-theme.js.map +1 -0
  403. package/dist/theme/violet-token-defaults.d.ts +4 -0
  404. package/dist/theme/violet-token-defaults.js +198 -0
  405. package/dist/theme/violet-token-defaults.js.map +1 -0
  406. package/dist/time-picker/violet-time-picker.d.ts +59 -0
  407. package/dist/time-picker/violet-time-picker.js +369 -0
  408. package/dist/time-picker/violet-time-picker.js.map +1 -0
  409. package/dist/toast/violet-toast.d.ts +50 -0
  410. package/dist/toast/violet-toast.js +395 -0
  411. package/dist/toast/violet-toast.js.map +1 -0
  412. package/dist/tooltip/violet-tooltip.d.ts +34 -0
  413. package/dist/tooltip/violet-tooltip.js +387 -0
  414. package/dist/tooltip/violet-tooltip.js.map +1 -0
  415. package/dist/tree/violet-tree.d.ts +44 -0
  416. package/dist/tree/violet-tree.js +451 -0
  417. package/dist/tree/violet-tree.js.map +1 -0
  418. package/dist/tree-item/violet-tree-item.d.ts +49 -0
  419. package/dist/tree-item/violet-tree-item.js +359 -0
  420. package/dist/tree-item/violet-tree-item.js.map +1 -0
  421. package/package.json +78 -3
  422. package/tokens/interface.json +364 -0
  423. package/tokens/master-semantic.tokens.jsonc +7 -0
  424. package/tokens/raw-palette.proposal.jsonc +159 -0
  425. package/tokens/theme-presets.jsonc +7 -0
  426. package/tokens/violet-theme.export.json +1392 -0
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Violet theme sets as data, and the stylesheet that applies one. No DOM access: this module is
3
+ * shared by the runtime installer and the build-time checks a product runs against
4
+ * `tokens/interface.json`.
5
+ */
6
+ export const VIOLET_THEME_ROOT_ATTRIBUTE = "data-violet-theme-root";
7
+ export const VIOLET_THEME_PRESET_ATTRIBUTE = "data-violet-theme";
8
+ /** The token types `tokens/interface.json` uses. */
9
+ export const VIOLET_TOKEN_TYPES = [
10
+ "color",
11
+ "dimension",
12
+ "duration",
13
+ "cubicBezier",
14
+ "fontWeight",
15
+ "fontFamily",
16
+ "number",
17
+ "shadow",
18
+ ];
19
+ const PRESET_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
20
+ const TOKEN_ID = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/;
21
+ // A value is one declaration's value: nothing that could end the declaration, the rule or the
22
+ // style element it is written into.
23
+ const UNSAFE_VALUE = /[;{}<>]|\/\*|\\|[\r\n]/;
24
+ const CLOSERS = { ")": "(", "]": "[" };
25
+ /**
26
+ * Whether every quote in `value` closes and every `(` and `[` outside quotes closes in order. An
27
+ * open one would swallow the rest of the stylesheet (CSS Syntax consumes to its match), so
28
+ * `rgb(0 0 0` is refused. Backslashes are refused already, so no quote is escaped.
29
+ */
30
+ function isBalanced(value) {
31
+ const open = [];
32
+ let quote = null;
33
+ for (const char of value) {
34
+ if (quote !== null) {
35
+ if (char === quote) {
36
+ quote = null;
37
+ }
38
+ }
39
+ else if (char === '"' || char === "'") {
40
+ quote = char;
41
+ }
42
+ else if (char === "(" || char === "[") {
43
+ open.push(char);
44
+ }
45
+ else if (char in CLOSERS && open.pop() !== CLOSERS[char]) {
46
+ return false;
47
+ }
48
+ }
49
+ return quote === null && open.length === 0;
50
+ }
51
+ /** `--` and the id with `.` replaced by `-`: `color.surface.page` gives `--color-surface-page`. */
52
+ export function violetTokenProperty(id) {
53
+ return `--${id.replace(/\./g, "-")}`;
54
+ }
55
+ /** Every problem with a theme set's shape, preset names, ids and values; empty when it is sound. */
56
+ export function validateVioletThemeSet(themeSet) {
57
+ const problems = [];
58
+ const presets = themeSet?.presets;
59
+ if (typeof presets !== "object" || presets === null || Array.isArray(presets)) {
60
+ return ["the theme set has no presets object"];
61
+ }
62
+ const names = Object.keys(presets);
63
+ if (names.length === 0) {
64
+ problems.push("the theme set has no presets");
65
+ }
66
+ if (typeof themeSet.defaultPreset !== "string" || !names.includes(themeSet.defaultPreset)) {
67
+ problems.push(`the default preset '${String(themeSet.defaultPreset)}' is not one of the presets (${names.join(", ")})`);
68
+ }
69
+ for (const name of names) {
70
+ if (!PRESET_NAME.test(name)) {
71
+ problems.push(`the preset name '${name}' must be letters, digits, '-' and '_', starting with a letter or digit`);
72
+ }
73
+ const tokens = presets[name];
74
+ if (!Array.isArray(tokens)) {
75
+ problems.push(`the preset '${name}' is not a list of { id, value } tokens`);
76
+ continue;
77
+ }
78
+ const seen = new Set();
79
+ for (const token of tokens) {
80
+ const id = token?.id;
81
+ if (typeof id !== "string" || !TOKEN_ID.test(id)) {
82
+ problems.push(`the preset '${name}' has a token with an invalid id ${JSON.stringify(id)}`);
83
+ continue;
84
+ }
85
+ if (seen.has(id)) {
86
+ problems.push(`the preset '${name}' lists '${id}' more than once`);
87
+ }
88
+ seen.add(id);
89
+ const value = token.value;
90
+ if (typeof value !== "string" || value.trim() === "" || UNSAFE_VALUE.test(value) || !isBalanced(value)) {
91
+ problems.push(`the preset '${name}' has an empty or unsafe value for '${id}': ${JSON.stringify(value)}`);
92
+ }
93
+ }
94
+ }
95
+ return problems;
96
+ }
97
+ function declarations(tokens) {
98
+ return tokens.map(token => ` ${violetTokenProperty(token.id)}: ${token.value};`).join("\n");
99
+ }
100
+ /**
101
+ * The stylesheet for a theme set: the default preset on `:root` and on every
102
+ * `[data-violet-theme-root]`, then each other preset on the same selectors with
103
+ * `[data-violet-theme="<preset>"]`. Throws a `TypeError` listing every problem when the set is not
104
+ * sound.
105
+ */
106
+ export function createVioletThemeCss(themeSet) {
107
+ const problems = validateVioletThemeSet(themeSet);
108
+ if (problems.length > 0) {
109
+ throw new TypeError(`Invalid Violet theme set: ${problems.join("; ")}`);
110
+ }
111
+ const blocks = [
112
+ ":root,",
113
+ `[${VIOLET_THEME_ROOT_ATTRIBUTE}]`,
114
+ "{",
115
+ declarations(themeSet.presets[themeSet.defaultPreset]),
116
+ "}",
117
+ ];
118
+ for (const [name, tokens] of Object.entries(themeSet.presets)) {
119
+ if (name === themeSet.defaultPreset) {
120
+ continue;
121
+ }
122
+ blocks.push(`:root[${VIOLET_THEME_PRESET_ATTRIBUTE}="${name}"],`, `[${VIOLET_THEME_ROOT_ATTRIBUTE}][${VIOLET_THEME_PRESET_ATTRIBUTE}="${name}"]`, "{", declarations(tokens), "}");
123
+ }
124
+ return blocks.join("\n");
125
+ }
126
+ /**
127
+ * What a theme set lacks against the components' token interface. `problems` holds
128
+ * `validateVioletThemeSet`'s findings; for a sound set, `missing` holds, per preset, every interface
129
+ * id it does not supply, counting what a non-default preset inherits from the default.
130
+ *
131
+ * Completeness is not enforced at runtime: an id a set omits silently falls back to the
132
+ * component's literal `var()` fallback (the built-in light value). A product runs this in its
133
+ * build with the `tokens/interface.json` of the installed version, from the Node-safe
134
+ * `@lushly-dev/violet-elements/theme-css` entry. Ids the interface does not list are allowed: a
135
+ * product's tree may hold more than the components read.
136
+ */
137
+ export function findVioletThemeSetGaps(themeSet, tokenInterface) {
138
+ const problems = validateVioletThemeSet(themeSet);
139
+ if (problems.length > 0) {
140
+ return { problems, missing: [], complete: false };
141
+ }
142
+ const missing = [];
143
+ const defaults = new Set(themeSet.presets[themeSet.defaultPreset].map(token => token.id));
144
+ for (const [preset, tokens] of Object.entries(themeSet.presets)) {
145
+ const supplied = new Set([...defaults, ...tokens.map(token => token.id)]);
146
+ for (const [id, entry] of Object.entries(tokenInterface.tokens)) {
147
+ if (!supplied.has(id)) {
148
+ missing.push({ preset, id, property: entry.property });
149
+ }
150
+ }
151
+ }
152
+ return { problems: [], missing, complete: missing.length === 0 };
153
+ }
154
+ //# sourceMappingURL=violet-theme-css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"violet-theme-css.js","sourceRoot":"","sources":["../../src/theme/violet-theme-css.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAwB,CAAC;AACpE,MAAM,CAAC,MAAM,6BAA6B,GAAG,mBAAmB,CAAC;AAsBjE,oDAAoD;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,OAAO;IACP,WAAW;IACX,UAAU;IACV,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,QAAQ;CACF,CAAC;AAmCX,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAClD,MAAM,QAAQ,GAAG,uCAAuC,CAAC;AACzD,8FAA8F;AAC9F,oCAAoC;AACpC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAC9C,MA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,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1E,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3D,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;AACrE,CAAC","sourcesContent":["/**\n * Violet theme sets as data, and the stylesheet that applies one. No DOM access: this module is\n * shared by the runtime installer and the build-time checks a product runs against\n * `tokens/interface.json`.\n */\n\nexport const VIOLET_THEME_ROOT_ATTRIBUTE = \"data-violet-theme-root\";\nexport const VIOLET_THEME_PRESET_ATTRIBUTE = \"data-violet-theme\";\n\n/** A preset name: open, so a product may name its presets as it likes (`sepia`, `brand-dark`). */\nexport type VioletThemePreset = string;\n\n/** One resolved token: a Violet token id (`color.surface.page`) and its CSS value. */\nexport interface VioletThemeToken {\n readonly id: string;\n readonly value: string;\n}\n\n/**\n * A complete theme set: every preset a page can select, as resolved tokens, and the preset that\n * applies when none is selected. The default preset must supply every id of\n * `tokens/interface.json`; another preset lists what it sets and inherits the rest from the\n * default. This is the shape `@lushly-dev/violet-core`'s resolved tokens map to.\n */\nexport interface VioletThemeSet {\n readonly defaultPreset: VioletThemePreset;\n readonly presets: Readonly<Record<VioletThemePreset, readonly VioletThemeToken[]>>;\n}\n\n/** The token types `tokens/interface.json` uses. */\nexport const VIOLET_TOKEN_TYPES = [\n \"color\",\n \"dimension\",\n \"duration\",\n \"cubicBezier\",\n \"fontWeight\",\n \"fontFamily\",\n \"number\",\n \"shadow\",\n] as const;\n\n/** One of `VIOLET_TOKEN_TYPES`. */\nexport type VioletTokenType = (typeof VIOLET_TOKEN_TYPES)[number];\n\n/** One entry of `tokens/interface.json`. */\nexport interface VioletTokenInterfaceEntry {\n readonly property: string;\n readonly type: VioletTokenType;\n /** In the interface, but no component reads it yet. A theme set supplies it anyway. */\n readonly reserved?: boolean;\n}\n\n/** `tokens/interface.json`: the custom properties the components read, per token id. */\nexport interface VioletTokenInterface {\n readonly contractVersion: number;\n readonly tokens: Readonly<Record<string, VioletTokenInterfaceEntry>>;\n}\n\n/** An interface id a preset does not supply, counting what it inherits from the default. */\nexport interface VioletThemeSetGap {\n readonly preset: VioletThemePreset;\n readonly id: string;\n readonly property: string;\n}\n\n/** What `findVioletThemeSetGaps` found: an unsound set's problems, or the ids it lacks. */\nexport interface VioletThemeSetGaps {\n /** `validateVioletThemeSet`'s problems; when any, `missing` is not computed and is empty. */\n readonly problems: readonly string[];\n readonly missing: readonly VioletThemeSetGap[];\n /** No problems and nothing missing. */\n readonly complete: boolean;\n}\n\nconst PRESET_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;\nconst TOKEN_ID = /^[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*$/;\n// A value is one declaration's value: nothing that could end the declaration, the rule or the\n// style element it is written into.\nconst UNSAFE_VALUE = /[;{}<>]|\\/\\*|\\\\|[\\r\\n]/;\nconst CLOSERS: Readonly<Record<string, string>> = { \")\": \"(\", \"]\": \"[\" };\n\n/**\n * Whether every quote in `value` closes and every `(` and `[` outside quotes closes in order. An\n * open one would swallow the rest of the stylesheet (CSS Syntax consumes to its match), so\n * `rgb(0 0 0` is refused. Backslashes are refused already, so no quote is escaped.\n */\nfunction isBalanced(value: string): boolean {\n const open: string[] = [];\n let quote: string | null = null;\n for (const char of value) {\n if (quote !== null) {\n if (char === quote) {\n quote = null;\n }\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \"(\" || char === \"[\") {\n open.push(char);\n } else if (char in CLOSERS && open.pop() !== CLOSERS[char]) {\n return false;\n }\n }\n return quote === null && open.length === 0;\n}\n\n/** `--` and the id with `.` replaced by `-`: `color.surface.page` gives `--color-surface-page`. */\nexport function violetTokenProperty(id: string): string {\n return `--${id.replace(/\\./g, \"-\")}`;\n}\n\n/** Every problem with a theme set's shape, preset names, ids and values; empty when it is sound. */\nexport function validateVioletThemeSet(themeSet: VioletThemeSet): string[] {\n const problems: string[] = [];\n const presets = themeSet?.presets;\n if (typeof presets !== \"object\" || presets === null || Array.isArray(presets)) {\n return [\"the theme set has no presets object\"];\n }\n const names = Object.keys(presets);\n if (names.length === 0) {\n problems.push(\"the theme set has no presets\");\n }\n if (typeof themeSet.defaultPreset !== \"string\" || !names.includes(themeSet.defaultPreset)) {\n problems.push(`the default preset '${String(themeSet.defaultPreset)}' is not one of the presets (${names.join(\", \")})`);\n }\n for (const name of names) {\n if (!PRESET_NAME.test(name)) {\n problems.push(`the preset name '${name}' must be letters, digits, '-' and '_', starting with a letter or digit`);\n }\n const tokens = presets[name];\n if (!Array.isArray(tokens)) {\n problems.push(`the preset '${name}' is not a list of { id, value } tokens`);\n continue;\n }\n const seen = new Set<string>();\n for (const token of tokens) {\n const id = token?.id;\n if (typeof id !== \"string\" || !TOKEN_ID.test(id)) {\n problems.push(`the preset '${name}' has a token with an invalid id ${JSON.stringify(id)}`);\n continue;\n }\n if (seen.has(id)) {\n problems.push(`the preset '${name}' lists '${id}' more than once`);\n }\n seen.add(id);\n const value = token.value;\n if (typeof value !== \"string\" || value.trim() === \"\" || UNSAFE_VALUE.test(value) || !isBalanced(value)) {\n problems.push(`the preset '${name}' has an empty or unsafe value for '${id}': ${JSON.stringify(value)}`);\n }\n }\n }\n return problems;\n}\n\nfunction declarations(tokens: readonly VioletThemeToken[]): string {\n return tokens.map(token => ` ${violetTokenProperty(token.id)}: ${token.value};`).join(\"\\n\");\n}\n\n/**\n * The stylesheet for a theme set: the default preset on `:root` and on every\n * `[data-violet-theme-root]`, then each other preset on the same selectors with\n * `[data-violet-theme=\"<preset>\"]`. Throws a `TypeError` listing every problem when the set is not\n * sound.\n */\nexport function createVioletThemeCss(themeSet: VioletThemeSet): string {\n const problems = validateVioletThemeSet(themeSet);\n if (problems.length > 0) {\n throw new TypeError(`Invalid Violet theme set: ${problems.join(\"; \")}`);\n }\n const blocks = [\n \":root,\",\n `[${VIOLET_THEME_ROOT_ATTRIBUTE}]`,\n \"{\",\n declarations(themeSet.presets[themeSet.defaultPreset]),\n \"}\",\n ];\n for (const [name, tokens] of Object.entries(themeSet.presets)) {\n if (name === themeSet.defaultPreset) {\n continue;\n }\n blocks.push(\n `:root[${VIOLET_THEME_PRESET_ATTRIBUTE}=\"${name}\"],`,\n `[${VIOLET_THEME_ROOT_ATTRIBUTE}][${VIOLET_THEME_PRESET_ATTRIBUTE}=\"${name}\"]`,\n \"{\",\n declarations(tokens),\n \"}\",\n );\n }\n return blocks.join(\"\\n\");\n}\n\n/**\n * What a theme set lacks against the components' token interface. `problems` holds\n * `validateVioletThemeSet`'s findings; for a sound set, `missing` holds, per preset, every interface\n * id it does not supply, counting what a non-default preset inherits from the default.\n *\n * Completeness is not enforced at runtime: an id a set omits silently falls back to the\n * component's literal `var()` fallback (the built-in light value). A product runs this in its\n * build with the `tokens/interface.json` of the installed version, from the Node-safe\n * `@lushly-dev/violet-elements/theme-css` entry. Ids the interface does not list are allowed: a\n * product's tree may hold more than the components read.\n */\nexport function findVioletThemeSetGaps(themeSet: VioletThemeSet, tokenInterface: VioletTokenInterface): VioletThemeSetGaps {\n const problems = validateVioletThemeSet(themeSet);\n if (problems.length > 0) {\n return { problems, missing: [], complete: false };\n }\n const missing: VioletThemeSetGap[] = [];\n const defaults = new Set(themeSet.presets[themeSet.defaultPreset].map(token => token.id));\n for (const [preset, tokens] of Object.entries(themeSet.presets)) {\n const supplied = new Set([...defaults, ...tokens.map(token => token.id)]);\n for (const [id, entry] of Object.entries(tokenInterface.tokens)) {\n if (!supplied.has(id)) {\n missing.push({ preset, id, property: entry.property });\n }\n }\n }\n return { problems: [], missing, complete: missing.length === 0 };\n}\n"]}
@@ -0,0 +1,72 @@
1
+ import { type VioletThemePreset, type VioletThemeSet } from "./violet-theme-css";
2
+ export { VIOLET_THEME_DEFAULT_PRESET, type VioletBuiltInThemePreset, violetThemePresets, } from "./generated/violet-theme-presets.generated";
3
+ /**
4
+ * Loads the built-in default set's stylesheet, writing it into every installed runtime style if no
5
+ * product set is active by then. `installVioletTheme()` calls it; await it to know the built-in
6
+ * theme is applied. A failed load (a chunk that did not arrive) rejects and is not cached, so the
7
+ * next call, or the next install, tries again.
8
+ */
9
+ export declare function loadVioletBuiltInTheme(): Promise<string>;
10
+ type BuiltInImporter = () => Promise<{
11
+ violetThemeCssText: string;
12
+ }>;
13
+ /**
14
+ * Replaces how the built-in set's module is imported, for this package's specs: a browser caches a
15
+ * module that failed, so a spec cannot make the real chunk fail once and then load. Not exported
16
+ * from the package root.
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function setVioletBuiltInThemeImporterForTesting(importer: BuiltInImporter): void;
21
+ /**
22
+ * Writes the active theme set's stylesheet into `target` (the document's head by default, or a
23
+ * shadow root), reusing the runtime style element already there. The active set is the built-in
24
+ * default unless `installVioletThemeSet()` installed another; the built-in stylesheet is written
25
+ * when its module has loaded (`loadVioletBuiltInTheme()`).
26
+ */
27
+ export declare function installVioletTheme(target?: Document | ShadowRoot): HTMLStyleElement;
28
+ /**
29
+ * Makes `themeSet` the active theme set, replacing the built-in default, and writes it into
30
+ * `target` and every runtime style element installed before, so scoped `violet-theme` hosts in
31
+ * shadow roots switch too. Preset names are the set's own. Throws a `TypeError` when the set is not
32
+ * sound (see `validateVioletThemeSet`); completeness against `tokens/interface.json` is a build-time
33
+ * check (`findVioletThemeSetGaps`).
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { applyVioletThemePreset, installVioletThemeSet } from "@lushly-dev/violet-elements";
38
+ *
39
+ * installVioletThemeSet({
40
+ * defaultPreset: "light",
41
+ * presets: { light: lightTokens, dark: darkTokens, sepia: sepiaTokens },
42
+ * });
43
+ * applyVioletThemePreset(document, "sepia");
44
+ * ```
45
+ */
46
+ export declare function installVioletThemeSet(themeSet: VioletThemeSet, target?: Document | ShadowRoot): HTMLStyleElement;
47
+ /** Makes the built-in default the active set again and rewrites every installed runtime style. */
48
+ export declare function resetVioletThemeSet(): void;
49
+ /** The active set's preset names. */
50
+ export declare function getVioletThemePresets(): readonly VioletThemePreset[];
51
+ /** The active set's default preset. */
52
+ export declare function getVioletThemeDefaultPreset(): VioletThemePreset;
53
+ /** Whether `value` names a preset of the active set. */
54
+ export declare function isVioletThemePreset(value: string | null | undefined): value is VioletThemePreset;
55
+ /**
56
+ * The active set's preset `value` names: the default preset for `null`, `undefined` or an empty
57
+ * string, `value` itself when the active set has it. Throws a `RangeError` for any other name; it
58
+ * is never mapped to the default.
59
+ */
60
+ export declare function normalizeVioletThemePreset(value: string | null | undefined): VioletThemePreset;
61
+ /**
62
+ * Selects a preset of the active set on the document root or an element. Throws a `RangeError` for
63
+ * a name the active set does not have, so install a product's set before selecting its presets.
64
+ */
65
+ export declare function applyVioletThemePreset<T extends Document | HTMLElement>(target: T, preset?: VioletThemePreset): T;
66
+ /**
67
+ * The preset selected on the document root or an element: its `data-violet-theme` attribute as
68
+ * written, or the active set's default when it has none.
69
+ */
70
+ export declare function getVioletThemePreset(target?: Document | HTMLElement): VioletThemePreset;
71
+ /** Marks an element as a scoped theme root and selects a preset of the active set on it. */
72
+ export declare function applyVioletThemeRoot<T extends HTMLElement>(element: T, preset?: VioletThemePreset): T;
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Installs a Violet theme set and selects its presets on the document or a scoped
3
+ * `[data-violet-theme-root]`.
4
+ *
5
+ * With nothing installed, the active set is the built-in default, so `installVioletTheme()` stays
6
+ * the zero-config route. A product that brings its own tree calls `installVioletThemeSet()`
7
+ * instead: its set replaces the built-in one wherever this module has installed a theme.
8
+ *
9
+ * The built-in set's values live in `violet-theme-builtin`, which this module never imports
10
+ * statically: `installVioletTheme()` loads it on first use, with a dynamic import, and writes its
11
+ * stylesheet once it arrives (the components' literal fallbacks are its light values meanwhile). A
12
+ * product that installs its own set first never loads it, and a bundler keeps it in a chunk of its
13
+ * own.
14
+ */
15
+ import { VIOLET_THEME_DEFAULT_PRESET, violetThemePresets } from "./generated/violet-theme-presets.generated";
16
+ import { createVioletThemeCss, VIOLET_THEME_PRESET_ATTRIBUTE, VIOLET_THEME_ROOT_ATTRIBUTE, } from "./violet-theme-css";
17
+ export { VIOLET_THEME_DEFAULT_PRESET, violetThemePresets, } from "./generated/violet-theme-presets.generated";
18
+ /** The product's set; `null` while the built-in default is active. */
19
+ let product = null;
20
+ /** The built-in stylesheet, once its module has loaded. */
21
+ let builtInCssText;
22
+ let builtInLoad;
23
+ /**
24
+ * Every runtime style element this module wrote, held weakly so a removed shadow root's style can
25
+ * be collected, and written on every change, connected or not, so one reattached later is current.
26
+ */
27
+ const installedStyles = new Set();
28
+ const trackedStyles = new WeakSet();
29
+ function activePresets() {
30
+ return product?.presets ?? violetThemePresets;
31
+ }
32
+ function activeDefaultPreset() {
33
+ return product?.defaultPreset ?? VIOLET_THEME_DEFAULT_PRESET;
34
+ }
35
+ /** The active stylesheet; empty while the built-in one is still loading. */
36
+ function activeCssText() {
37
+ if (product !== null) {
38
+ return product.cssText;
39
+ }
40
+ if (builtInCssText === undefined) {
41
+ loadVioletBuiltInTheme().catch((error) => {
42
+ console.error("violet-theme: the built-in theme failed to load; the next install retries", error);
43
+ });
44
+ return "";
45
+ }
46
+ return builtInCssText;
47
+ }
48
+ /**
49
+ * Loads the built-in default set's stylesheet, writing it into every installed runtime style if no
50
+ * product set is active by then. `installVioletTheme()` calls it; await it to know the built-in
51
+ * theme is applied. A failed load (a chunk that did not arrive) rejects and is not cached, so the
52
+ * next call, or the next install, tries again.
53
+ */
54
+ export function loadVioletBuiltInTheme() {
55
+ builtInLoad ??= importBuiltIn()
56
+ .then(module => {
57
+ const cssText = module.violetThemeCssText;
58
+ builtInCssText = cssText;
59
+ if (product === null) {
60
+ refreshInstalledStyles();
61
+ }
62
+ return cssText;
63
+ })
64
+ .catch((error) => {
65
+ builtInLoad = undefined;
66
+ throw error;
67
+ });
68
+ return builtInLoad;
69
+ }
70
+ let importBuiltIn = () => import("./violet-theme-builtin");
71
+ /**
72
+ * Replaces how the built-in set's module is imported, for this package's specs: a browser caches a
73
+ * module that failed, so a spec cannot make the real chunk fail once and then load. Not exported
74
+ * from the package root.
75
+ *
76
+ * @internal
77
+ */
78
+ export function setVioletBuiltInThemeImporterForTesting(importer) {
79
+ importBuiltIn = importer;
80
+ builtInLoad = undefined;
81
+ builtInCssText = undefined;
82
+ }
83
+ function isShadowRoot(target) {
84
+ return typeof ShadowRoot !== "undefined" && target instanceof ShadowRoot;
85
+ }
86
+ function isDocument(target) {
87
+ return typeof Document !== "undefined" && target instanceof Document;
88
+ }
89
+ function resolveStyleContainer(target = document) {
90
+ if (isShadowRoot(target)) {
91
+ return target;
92
+ }
93
+ if (isDocument(target)) {
94
+ return target.head ?? target.documentElement;
95
+ }
96
+ return document.head ?? document.documentElement;
97
+ }
98
+ function resolvePresetTarget(target = document) {
99
+ if (isDocument(target)) {
100
+ return target.documentElement;
101
+ }
102
+ return target;
103
+ }
104
+ function writeStyle(target) {
105
+ const styleContainer = resolveStyleContainer(target);
106
+ const existing = styleContainer.querySelector('style[data-violet-theme="runtime"]');
107
+ const ownerDocument = isShadowRoot(target) ? target.ownerDocument : isDocument(target) ? target : document;
108
+ const style = existing instanceof HTMLStyleElement ? existing : ownerDocument.createElement("style");
109
+ style.dataset.violetTheme = "runtime";
110
+ style.textContent = activeCssText();
111
+ if (!style.isConnected) {
112
+ styleContainer.append(style);
113
+ }
114
+ if (!trackedStyles.has(style)) {
115
+ trackedStyles.add(style);
116
+ installedStyles.add(new WeakRef(style));
117
+ }
118
+ return style;
119
+ }
120
+ function refreshInstalledStyles() {
121
+ const cssText = activeCssText();
122
+ for (const ref of installedStyles) {
123
+ const style = ref.deref();
124
+ if (style === undefined) {
125
+ installedStyles.delete(ref);
126
+ }
127
+ else {
128
+ style.textContent = cssText;
129
+ }
130
+ }
131
+ }
132
+ /**
133
+ * Writes the active theme set's stylesheet into `target` (the document's head by default, or a
134
+ * shadow root), reusing the runtime style element already there. The active set is the built-in
135
+ * default unless `installVioletThemeSet()` installed another; the built-in stylesheet is written
136
+ * when its module has loaded (`loadVioletBuiltInTheme()`).
137
+ */
138
+ export function installVioletTheme(target = document) {
139
+ return writeStyle(target);
140
+ }
141
+ /**
142
+ * Makes `themeSet` the active theme set, replacing the built-in default, and writes it into
143
+ * `target` and every runtime style element installed before, so scoped `violet-theme` hosts in
144
+ * shadow roots switch too. Preset names are the set's own. Throws a `TypeError` when the set is not
145
+ * sound (see `validateVioletThemeSet`); completeness against `tokens/interface.json` is a build-time
146
+ * check (`findVioletThemeSetGaps`).
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * import { applyVioletThemePreset, installVioletThemeSet } from "@lushly-dev/violet-elements";
151
+ *
152
+ * installVioletThemeSet({
153
+ * defaultPreset: "light",
154
+ * presets: { light: lightTokens, dark: darkTokens, sepia: sepiaTokens },
155
+ * });
156
+ * applyVioletThemePreset(document, "sepia");
157
+ * ```
158
+ */
159
+ export function installVioletThemeSet(themeSet, target = document) {
160
+ product = {
161
+ cssText: createVioletThemeCss(themeSet),
162
+ presets: Object.keys(themeSet.presets),
163
+ defaultPreset: themeSet.defaultPreset,
164
+ };
165
+ refreshInstalledStyles();
166
+ return writeStyle(target);
167
+ }
168
+ /** Makes the built-in default the active set again and rewrites every installed runtime style. */
169
+ export function resetVioletThemeSet() {
170
+ product = null;
171
+ refreshInstalledStyles();
172
+ }
173
+ /** The active set's preset names. */
174
+ export function getVioletThemePresets() {
175
+ return activePresets();
176
+ }
177
+ /** The active set's default preset. */
178
+ export function getVioletThemeDefaultPreset() {
179
+ return activeDefaultPreset();
180
+ }
181
+ /** Whether `value` names a preset of the active set. */
182
+ export function isVioletThemePreset(value) {
183
+ return typeof value === "string" && activePresets().includes(value);
184
+ }
185
+ /**
186
+ * The active set's preset `value` names: the default preset for `null`, `undefined` or an empty
187
+ * string, `value` itself when the active set has it. Throws a `RangeError` for any other name; it
188
+ * is never mapped to the default.
189
+ */
190
+ export function normalizeVioletThemePreset(value) {
191
+ if (value === null || value === undefined || value === "") {
192
+ return activeDefaultPreset();
193
+ }
194
+ if (isVioletThemePreset(value)) {
195
+ return value;
196
+ }
197
+ throw new RangeError(`Unknown Violet theme preset '${value}'; the installed presets are ${activePresets().join(", ")}`);
198
+ }
199
+ /**
200
+ * Selects a preset of the active set on the document root or an element. Throws a `RangeError` for
201
+ * a name the active set does not have, so install a product's set before selecting its presets.
202
+ */
203
+ export function applyVioletThemePreset(target, preset) {
204
+ resolvePresetTarget(target).setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, normalizeVioletThemePreset(preset));
205
+ return target;
206
+ }
207
+ /**
208
+ * The preset selected on the document root or an element: its `data-violet-theme` attribute as
209
+ * written, or the active set's default when it has none.
210
+ */
211
+ export function getVioletThemePreset(target = document) {
212
+ return resolvePresetTarget(target).getAttribute(VIOLET_THEME_PRESET_ATTRIBUTE) || activeDefaultPreset();
213
+ }
214
+ /** Marks an element as a scoped theme root and selects a preset of the active set on it. */
215
+ export function applyVioletThemeRoot(element, preset) {
216
+ const resolved = normalizeVioletThemePreset(preset);
217
+ element.setAttribute(VIOLET_THEME_ROOT_ATTRIBUTE, "");
218
+ element.setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, resolved);
219
+ return element;
220
+ }
221
+ //# sourceMappingURL=violet-theme-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"violet-theme-runtime.js","sourceRoot":"","sources":["../../src/theme/violet-theme-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;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gCAAgC,KAAK,gCAAgC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5H,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAmC,MAAS,EAAE,MAA0B;IAC1G,mBAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,6BAA6B,EAAE,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5G,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAM,GAA2B,QAAQ;IAC1E,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,6BAA6B,CAAC,IAAI,mBAAmB,EAAE,CAAC;AAC5G,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAwB,OAAU,EAAE,MAA0B;IAC9F,MAAM,QAAQ,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACpD,OAAO,CAAC,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,YAAY,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Installs a Violet theme set and selects its presets on the document or a scoped\n * `[data-violet-theme-root]`.\n *\n * With nothing installed, the active set is the built-in default, so `installVioletTheme()` stays\n * the zero-config route. A product that brings its own tree calls `installVioletThemeSet()`\n * instead: its set replaces the built-in one wherever this module has installed a theme.\n *\n * The built-in set's values live in `violet-theme-builtin`, which this module never imports\n * statically: `installVioletTheme()` loads it on first use, with a dynamic import, and writes its\n * stylesheet once it arrives (the components' literal fallbacks are its light values meanwhile). A\n * product that installs its own set first never loads it, and a bundler keeps it in a chunk of its\n * own.\n */\nimport { VIOLET_THEME_DEFAULT_PRESET, violetThemePresets } from \"./generated/violet-theme-presets.generated\";\nimport {\n createVioletThemeCss,\n VIOLET_THEME_PRESET_ATTRIBUTE,\n VIOLET_THEME_ROOT_ATTRIBUTE,\n type VioletThemePreset,\n type VioletThemeSet,\n} from \"./violet-theme-css\";\n\nexport {\n VIOLET_THEME_DEFAULT_PRESET,\n type VioletBuiltInThemePreset,\n violetThemePresets,\n} from \"./generated/violet-theme-presets.generated\";\n\ninterface ProductThemeSet {\n readonly cssText: string;\n readonly presets: readonly VioletThemePreset[];\n readonly defaultPreset: VioletThemePreset;\n}\n\n/** The product's set; `null` while the built-in default is active. */\nlet product: ProductThemeSet | null = null;\n/** The built-in stylesheet, once its module has loaded. */\nlet builtInCssText: string | undefined;\nlet builtInLoad: Promise<string> | undefined;\n\n/**\n * Every runtime style element this module wrote, held weakly so a removed shadow root's style can\n * be collected, and written on every change, connected or not, so one reattached later is current.\n */\nconst installedStyles = new Set<WeakRef<HTMLStyleElement>>();\nconst trackedStyles = new WeakSet<HTMLStyleElement>();\n\nfunction activePresets(): readonly VioletThemePreset[] {\n return product?.presets ?? violetThemePresets;\n}\n\nfunction activeDefaultPreset(): VioletThemePreset {\n return product?.defaultPreset ?? VIOLET_THEME_DEFAULT_PRESET;\n}\n\n/** The active stylesheet; empty while the built-in one is still loading. */\nfunction activeCssText(): string {\n if (product !== null) {\n return product.cssText;\n }\n if (builtInCssText === undefined) {\n loadVioletBuiltInTheme().catch((error: unknown) => {\n console.error(\"violet-theme: the built-in theme failed to load; the next install retries\", error);\n });\n return \"\";\n }\n return builtInCssText;\n}\n\n/**\n * Loads the built-in default set's stylesheet, writing it into every installed runtime style if no\n * product set is active by then. `installVioletTheme()` calls it; await it to know the built-in\n * theme is applied. A failed load (a chunk that did not arrive) rejects and is not cached, so the\n * next call, or the next install, tries again.\n */\nexport function loadVioletBuiltInTheme(): Promise<string> {\n builtInLoad ??= importBuiltIn()\n .then(module => {\n const cssText = module.violetThemeCssText;\n builtInCssText = cssText;\n if (product === null) {\n refreshInstalledStyles();\n }\n return cssText;\n })\n .catch((error: unknown) => {\n builtInLoad = undefined;\n throw error;\n });\n return builtInLoad;\n}\n\ntype BuiltInImporter = () => Promise<{ violetThemeCssText: string }>;\n\nlet importBuiltIn: BuiltInImporter = () => import(\"./violet-theme-builtin\");\n\n/**\n * Replaces how the built-in set's module is imported, for this package's specs: a browser caches a\n * module that failed, so a spec cannot make the real chunk fail once and then load. Not exported\n * from the package root.\n *\n * @internal\n */\nexport function setVioletBuiltInThemeImporterForTesting(importer: BuiltInImporter): void {\n importBuiltIn = importer;\n builtInLoad = undefined;\n builtInCssText = undefined;\n}\n\nfunction isShadowRoot(target: unknown): target is ShadowRoot {\n return typeof ShadowRoot !== \"undefined\" && target instanceof ShadowRoot;\n}\n\nfunction isDocument(target: unknown): target is Document {\n return typeof Document !== \"undefined\" && target instanceof Document;\n}\n\nfunction resolveStyleContainer(target: Document | ShadowRoot = document): ShadowRoot | HTMLElement {\n if (isShadowRoot(target)) {\n return target;\n }\n\n if (isDocument(target)) {\n return target.head ?? target.documentElement;\n }\n\n return document.head ?? document.documentElement;\n}\n\nfunction resolvePresetTarget(target: Document | HTMLElement = document): HTMLElement {\n if (isDocument(target)) {\n return target.documentElement;\n }\n\n return target;\n}\n\nfunction writeStyle(target: Document | ShadowRoot): HTMLStyleElement {\n const styleContainer = resolveStyleContainer(target);\n const existing = styleContainer.querySelector('style[data-violet-theme=\"runtime\"]');\n const ownerDocument = isShadowRoot(target) ? target.ownerDocument : isDocument(target) ? target : document;\n const style = existing instanceof HTMLStyleElement ? existing : ownerDocument.createElement(\"style\");\n\n style.dataset.violetTheme = \"runtime\";\n style.textContent = activeCssText();\n if (!style.isConnected) {\n styleContainer.append(style);\n }\n if (!trackedStyles.has(style)) {\n trackedStyles.add(style);\n installedStyles.add(new WeakRef(style));\n }\n return style;\n}\n\nfunction refreshInstalledStyles(): void {\n const cssText = activeCssText();\n for (const ref of installedStyles) {\n const style = ref.deref();\n if (style === undefined) {\n installedStyles.delete(ref);\n } else {\n style.textContent = cssText;\n }\n }\n}\n\n/**\n * Writes the active theme set's stylesheet into `target` (the document's head by default, or a\n * shadow root), reusing the runtime style element already there. The active set is the built-in\n * default unless `installVioletThemeSet()` installed another; the built-in stylesheet is written\n * when its module has loaded (`loadVioletBuiltInTheme()`).\n */\nexport function installVioletTheme(target: Document | ShadowRoot = document): HTMLStyleElement {\n return writeStyle(target);\n}\n\n/**\n * Makes `themeSet` the active theme set, replacing the built-in default, and writes it into\n * `target` and every runtime style element installed before, so scoped `violet-theme` hosts in\n * shadow roots switch too. Preset names are the set's own. Throws a `TypeError` when the set is not\n * sound (see `validateVioletThemeSet`); completeness against `tokens/interface.json` is a build-time\n * check (`findVioletThemeSetGaps`).\n *\n * @example\n * ```ts\n * import { applyVioletThemePreset, installVioletThemeSet } from \"@lushly-dev/violet-elements\";\n *\n * installVioletThemeSet({\n * defaultPreset: \"light\",\n * presets: { light: lightTokens, dark: darkTokens, sepia: sepiaTokens },\n * });\n * applyVioletThemePreset(document, \"sepia\");\n * ```\n */\nexport function installVioletThemeSet(\n themeSet: VioletThemeSet,\n target: Document | ShadowRoot = document,\n): HTMLStyleElement {\n product = {\n cssText: createVioletThemeCss(themeSet),\n presets: Object.keys(themeSet.presets),\n defaultPreset: themeSet.defaultPreset,\n };\n refreshInstalledStyles();\n return writeStyle(target);\n}\n\n/** Makes the built-in default the active set again and rewrites every installed runtime style. */\nexport function resetVioletThemeSet(): void {\n product = null;\n refreshInstalledStyles();\n}\n\n/** The active set's preset names. */\nexport function getVioletThemePresets(): readonly VioletThemePreset[] {\n return activePresets();\n}\n\n/** The active set's default preset. */\nexport function getVioletThemeDefaultPreset(): VioletThemePreset {\n return activeDefaultPreset();\n}\n\n/** Whether `value` names a preset of the active set. */\nexport function isVioletThemePreset(value: string | null | undefined): value is VioletThemePreset {\n return typeof value === \"string\" && activePresets().includes(value);\n}\n\n/**\n * The active set's preset `value` names: the default preset for `null`, `undefined` or an empty\n * string, `value` itself when the active set has it. Throws a `RangeError` for any other name; it\n * is never mapped to the default.\n */\nexport function normalizeVioletThemePreset(value: string | null | undefined): VioletThemePreset {\n if (value === null || value === undefined || value === \"\") {\n return activeDefaultPreset();\n }\n if (isVioletThemePreset(value)) {\n return value;\n }\n throw new RangeError(`Unknown Violet theme preset '${value}'; the installed presets are ${activePresets().join(\", \")}`);\n}\n\n/**\n * Selects a preset of the active set on the document root or an element. Throws a `RangeError` for\n * a name the active set does not have, so install a product's set before selecting its presets.\n */\nexport function applyVioletThemePreset<T extends Document | HTMLElement>(target: T, preset?: VioletThemePreset): T {\n resolvePresetTarget(target).setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, normalizeVioletThemePreset(preset));\n return target;\n}\n\n/**\n * The preset selected on the document root or an element: its `data-violet-theme` attribute as\n * written, or the active set's default when it has none.\n */\nexport function getVioletThemePreset(target: Document | HTMLElement = document): VioletThemePreset {\n return resolvePresetTarget(target).getAttribute(VIOLET_THEME_PRESET_ATTRIBUTE) || activeDefaultPreset();\n}\n\n/** Marks an element as a scoped theme root and selects a preset of the active set on it. */\nexport function applyVioletThemeRoot<T extends HTMLElement>(element: T, preset?: VioletThemePreset): T {\n const resolved = normalizeVioletThemePreset(preset);\n element.setAttribute(VIOLET_THEME_ROOT_ATTRIBUTE, \"\");\n element.setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, resolved);\n return element;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { FASTElement } from "@lushly-dev/fast-element";
2
+ import { type VioletThemePreset } from "./violet-theme-css";
3
+ /**
4
+ * Violet optional scoped theme host.
5
+ *
6
+ * @summary Applies the shared Violet runtime token layer to a subtree without requiring a global provider wrapper.
7
+ * @slot - Descendant content that should inherit Violet token values from this scope.
8
+ */
9
+ export declare class VioletTheme extends FASTElement {
10
+ /**
11
+ * Selects which preset of the installed Violet theme set this scoped host exposes. Any name the
12
+ * set has works; the built-in set has light, dark and high-contrast.
13
+ */
14
+ preset: VioletThemePreset;
15
+ connectedCallback(): void;
16
+ presetChanged(): void;
17
+ /**
18
+ * Writes the preset as given: a name the installed set lacks is kept, not mapped to the default,
19
+ * so it applies as soon as a set that has it is installed, and a warning names the known ones.
20
+ */
21
+ private applyPreset;
22
+ }
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { FASTElement, attr, css, html } from "@lushly-dev/fast-element";
8
+ import { VIOLET_THEME_PRESET_ATTRIBUTE, VIOLET_THEME_ROOT_ATTRIBUTE } from "./violet-theme-css";
9
+ import { getVioletThemeDefaultPreset, getVioletThemePresets, installVioletTheme, isVioletThemePreset } from "./violet-theme-runtime";
10
+ const styles = css `
11
+ :host {
12
+ display: contents;
13
+ }
14
+ `;
15
+ const template = html `
16
+ <slot></slot>
17
+ `;
18
+ /**
19
+ * Violet optional scoped theme host.
20
+ *
21
+ * @summary Applies the shared Violet runtime token layer to a subtree without requiring a global provider wrapper.
22
+ * @slot - Descendant content that should inherit Violet token values from this scope.
23
+ */
24
+ export class VioletTheme extends FASTElement {
25
+ connectedCallback() {
26
+ super.connectedCallback();
27
+ const rootNode = this.getRootNode();
28
+ installVioletTheme(rootNode instanceof ShadowRoot ? rootNode : this.ownerDocument);
29
+ this.setAttribute(VIOLET_THEME_ROOT_ATTRIBUTE, "");
30
+ this.applyPreset();
31
+ }
32
+ presetChanged() {
33
+ if (!this.$fastController.isConnected) {
34
+ return;
35
+ }
36
+ this.applyPreset();
37
+ }
38
+ /**
39
+ * Writes the preset as given: a name the installed set lacks is kept, not mapped to the default,
40
+ * so it applies as soon as a set that has it is installed, and a warning names the known ones.
41
+ */
42
+ applyPreset() {
43
+ const preset = this.getAttribute("preset") || this.preset || getVioletThemeDefaultPreset();
44
+ if (!isVioletThemePreset(preset)) {
45
+ console.warn(`violet-theme: the preset '${preset}' is not in the installed theme set (${getVioletThemePresets().join(", ")})`);
46
+ }
47
+ this.setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, preset);
48
+ }
49
+ }
50
+ __decorate([
51
+ attr
52
+ ], VioletTheme.prototype, "preset", void 0);
53
+ if (!customElements.get("violet-theme")) {
54
+ await FASTElement.define(VioletTheme, {
55
+ name: "violet-theme",
56
+ template,
57
+ styles,
58
+ });
59
+ }
60
+ //# sourceMappingURL=violet-theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"violet-theme.js","sourceRoot":"","sources":["../../src/theme/violet-theme.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAA0B,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAErI,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIjB,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,CAAa;;CAEjC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAQjC,iBAAiB;QACpB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,kBAAkB,CAAC,QAAQ,YAAY,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnF,IAAI,CAAC,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAEM,aAAa;QAChB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;YACpC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACK,WAAW;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,2BAA2B,EAAE,CAAC;QAC3F,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,CACR,6BAA6B,MAAM,wCAAwC,qBAAqB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnH,CAAC;QACN,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;CACJ;AA/BkB;IADd,IAAI;2CACoC;AAiC7C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;IACtC,MAAM,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE;QAClC,IAAI,EAAE,cAAc;QACpB,QAAQ;QACR,MAAM;KACT,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, attr, css, html } from \"@lushly-dev/fast-element\";\n\nimport { VIOLET_THEME_PRESET_ATTRIBUTE, VIOLET_THEME_ROOT_ATTRIBUTE, type VioletThemePreset } from \"./violet-theme-css\";\nimport { getVioletThemeDefaultPreset, getVioletThemePresets, installVioletTheme, isVioletThemePreset } from \"./violet-theme-runtime\";\n\nconst styles = css`\n :host {\n display: contents;\n }\n`;\n\nconst template = html<VioletTheme>`\n <slot></slot>\n`;\n\n/**\n * Violet optional scoped theme host.\n *\n * @summary Applies the shared Violet runtime token layer to a subtree without requiring a global provider wrapper.\n * @slot - Descendant content that should inherit Violet token values from this scope.\n */\nexport class VioletTheme extends FASTElement {\n /**\n * Selects which preset of the installed Violet theme set this scoped host exposes. Any name the\n * set has works; the built-in set has light, dark and high-contrast.\n */\n @attr\n declare public preset: VioletThemePreset;\n\n public connectedCallback(): void {\n super.connectedCallback();\n const rootNode = this.getRootNode();\n installVioletTheme(rootNode instanceof ShadowRoot ? rootNode : this.ownerDocument);\n this.setAttribute(VIOLET_THEME_ROOT_ATTRIBUTE, \"\");\n this.applyPreset();\n }\n\n public presetChanged(): void {\n if (!this.$fastController.isConnected) {\n return;\n }\n\n this.applyPreset();\n }\n\n /**\n * Writes the preset as given: a name the installed set lacks is kept, not mapped to the default,\n * so it applies as soon as a set that has it is installed, and a warning names the known ones.\n */\n private applyPreset(): void {\n const preset = this.getAttribute(\"preset\") || this.preset || getVioletThemeDefaultPreset();\n if (!isVioletThemePreset(preset)) {\n console.warn(\n `violet-theme: the preset '${preset}' is not in the installed theme set (${getVioletThemePresets().join(\", \")})`,\n );\n }\n this.setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, preset);\n }\n}\n\nif (!customElements.get(\"violet-theme\")) {\n await FASTElement.define(VioletTheme, {\n name: \"violet-theme\",\n template,\n styles,\n });\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { type ElementStyles } from "@lushly-dev/fast-element";
2
+ export declare const violetActionTokenDefaults: ElementStyles;
3
+ export declare const violetFieldTokenDefaults: ElementStyles;
4
+ export declare const violetSurfaceTokenDefaults: ElementStyles;