@rimelight/ui 0.0.33 → 0.0.34

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 (282) hide show
  1. package/README.md +157 -157
  2. package/package.json +105 -105
  3. package/src/components/astro/RLAAspectRatio.astro +2 -2
  4. package/src/components/astro/RLAButton.astro +141 -139
  5. package/src/components/astro/RLAChart.astro +19 -34
  6. package/src/components/astro/RLAHead.astro +427 -196
  7. package/src/components/astro/RLAHeader.astro +66 -59
  8. package/src/components/astro/RLAImage.astro +61 -19
  9. package/src/components/astro/RLALink.astro +22 -23
  10. package/src/components/astro/RLALinkGroup.astro +66 -4
  11. package/src/components/astro/RLALocaleSelector.astro +136 -113
  12. package/src/components/astro/RLAMain.astro +8 -3
  13. package/src/components/astro/RLAMarquee.astro +9 -2
  14. package/src/components/astro/RLANavigationMenu.astro +245 -56
  15. package/src/components/astro/RLAPagination.astro +2 -4
  16. package/src/components/astro/RLAProgress.astro +8 -2
  17. package/src/components/astro/RLASelect.astro +38 -24
  18. package/src/components/astro/RLASlideover.astro +66 -1
  19. package/src/components/astro/RLASlider.astro +14 -14
  20. package/src/components/astro/RLASplitter.astro +14 -2
  21. package/src/components/astro/RLAStickySurface.astro +9 -2
  22. package/src/components/vue/RLVCheckbox.vue +68 -68
  23. package/src/components/vue/RLVForm.vue +44 -44
  24. package/src/components/vue/RLVFormField.vue +58 -58
  25. package/src/components/vue/RLVInput.vue +93 -93
  26. package/src/components/vue/RLVPost.vue +63 -63
  27. package/src/components/vue/RLVPosts.vue +21 -21
  28. package/src/components/vue/RLVToast.vue +68 -68
  29. package/src/components/vue/RLVToaster.vue +29 -29
  30. package/src/composables/index.ts +3 -3
  31. package/src/composables/useHeaderStore.ts +13 -14
  32. package/src/composables/useScrollToTop.ts +62 -62
  33. package/src/composables/useToast.ts +43 -42
  34. package/src/config/index.ts +1 -0
  35. package/src/config/security.ts +220 -0
  36. package/src/integrations/ui.ts +199 -199
  37. package/src/middleware/security.ts +75 -15
  38. package/src/plugins/index.ts +2 -2
  39. package/src/plugins/starlightDocsApi/index.ts +272 -272
  40. package/src/presets/defaults.ts +297 -297
  41. package/src/presets/index.ts +683 -637
  42. package/src/styles/index.css +160 -160
  43. package/src/themes/3d-hover.theme.ts +13 -13
  44. package/src/themes/accordion.theme.ts +13 -13
  45. package/src/themes/alert.theme.ts +131 -125
  46. package/src/themes/app.theme.ts +13 -13
  47. package/src/themes/audio.theme.ts +13 -13
  48. package/src/themes/avatar.theme.ts +84 -84
  49. package/src/themes/badge.theme.ts +169 -163
  50. package/src/themes/banner.theme.ts +13 -13
  51. package/src/themes/browser-mockup.theme.ts +13 -13
  52. package/src/themes/button.theme.ts +224 -202
  53. package/src/themes/calendar.theme.ts +13 -13
  54. package/src/themes/card.theme.ts +42 -42
  55. package/src/themes/changelog.theme.ts +13 -13
  56. package/src/themes/chart.theme.ts +22 -22
  57. package/src/themes/chat-message.theme.ts +13 -13
  58. package/src/themes/chat-messages.theme.ts +13 -13
  59. package/src/themes/chat-palette.theme.ts +13 -13
  60. package/src/themes/chat-prompt-submit.theme.ts +13 -13
  61. package/src/themes/chat-prompt.theme.ts +13 -13
  62. package/src/themes/chat-reasoning.theme.ts +13 -13
  63. package/src/themes/chat-shimmer.theme.ts +13 -13
  64. package/src/themes/chat-tool.theme.ts +13 -13
  65. package/src/themes/chat.theme.ts +13 -13
  66. package/src/themes/checkbox.theme.ts +50 -50
  67. package/src/themes/chip.theme.ts +74 -74
  68. package/src/themes/color-picker.theme.ts +13 -13
  69. package/src/themes/command-palette.theme.ts +13 -13
  70. package/src/themes/compare.theme.ts +13 -13
  71. package/src/themes/confirm.theme.ts +48 -48
  72. package/src/themes/container.theme.ts +13 -13
  73. package/src/themes/context-menu.theme.ts +13 -13
  74. package/src/themes/dashboard-group.theme.ts +13 -13
  75. package/src/themes/dashboard-navbar.theme.ts +13 -13
  76. package/src/themes/dashboard-panel.theme.ts +13 -13
  77. package/src/themes/dashboard-resize-handle.theme.ts +13 -13
  78. package/src/themes/dashboard-search-button.theme.ts +13 -13
  79. package/src/themes/dashboard-search.theme.ts +13 -13
  80. package/src/themes/dashboard-sidebar-collapse.theme.ts +13 -13
  81. package/src/themes/dashboard-sidebar-toggle.theme.ts +13 -13
  82. package/src/themes/dashboard-sidebar.theme.ts +13 -13
  83. package/src/themes/dashboard-toolbar.theme.ts +13 -13
  84. package/src/themes/dock.theme.ts +13 -13
  85. package/src/themes/drawer.theme.ts +61 -61
  86. package/src/themes/dropdown-menu.theme.ts +29 -29
  87. package/src/themes/editor.theme.ts +13 -13
  88. package/src/themes/empty.theme.ts +13 -13
  89. package/src/themes/error.theme.ts +13 -13
  90. package/src/themes/field-group.theme.ts +24 -24
  91. package/src/themes/fieldset.theme.ts +13 -13
  92. package/src/themes/floating-action.theme.ts +13 -13
  93. package/src/themes/footer.theme.ts +30 -30
  94. package/src/themes/form.theme.ts +13 -13
  95. package/src/themes/gallery.theme.ts +13 -13
  96. package/src/themes/head.theme.ts +13 -13
  97. package/src/themes/header.theme.ts +45 -46
  98. package/src/themes/icon.theme.ts +23 -23
  99. package/src/themes/image.theme.ts +23 -19
  100. package/src/themes/input-date.theme.ts +13 -13
  101. package/src/themes/input-menu.theme.ts +35 -35
  102. package/src/themes/input-number.theme.ts +13 -13
  103. package/src/themes/input-tags.theme.ts +13 -13
  104. package/src/themes/input-time.theme.ts +13 -13
  105. package/src/themes/input.theme.ts +42 -42
  106. package/src/themes/kbd.theme.ts +95 -89
  107. package/src/themes/knob.theme.ts +13 -13
  108. package/src/themes/link-group.theme.ts +32 -32
  109. package/src/themes/link.theme.ts +13 -13
  110. package/src/themes/listbox.theme.ts +13 -13
  111. package/src/themes/locale-selector.theme.ts +49 -49
  112. package/src/themes/logo.theme.ts +13 -13
  113. package/src/themes/main.theme.ts +13 -13
  114. package/src/themes/megamenu.theme.ts +13 -13
  115. package/src/themes/meter.theme.ts +13 -13
  116. package/src/themes/navigation-menu.theme.ts +44 -27
  117. package/src/themes/page-aside.theme.ts +13 -13
  118. package/src/themes/page-body.theme.ts +13 -13
  119. package/src/themes/page-header.theme.ts +13 -13
  120. package/src/themes/page-section.theme.ts +187 -187
  121. package/src/themes/page.theme.ts +13 -13
  122. package/src/themes/password.theme.ts +13 -13
  123. package/src/themes/phone-mockup.theme.ts +13 -13
  124. package/src/themes/placeholder.theme.ts +15 -15
  125. package/src/themes/post.theme.ts +33 -33
  126. package/src/themes/pricing-plan.theme.ts +13 -13
  127. package/src/themes/pricing-table.theme.ts +13 -13
  128. package/src/themes/progress.theme.ts +38 -38
  129. package/src/themes/prose.theme.ts +13 -13
  130. package/src/themes/qr-code.theme.ts +13 -13
  131. package/src/themes/quote.theme.ts +13 -13
  132. package/src/themes/radio-group.theme.ts +13 -13
  133. package/src/themes/rating.theme.ts +13 -13
  134. package/src/themes/scroll-area.theme.ts +26 -26
  135. package/src/themes/scroll-to-top.theme.ts +52 -52
  136. package/src/themes/select.theme.ts +29 -29
  137. package/src/themes/separator.theme.ts +147 -147
  138. package/src/themes/sidebar.theme.ts +38 -38
  139. package/src/themes/skeleton.theme.ts +21 -21
  140. package/src/themes/slideover.theme.ts +4 -4
  141. package/src/themes/slider.theme.ts +36 -36
  142. package/src/themes/speed-dial.theme.ts +13 -13
  143. package/src/themes/spinner.theme.ts +34 -34
  144. package/src/themes/splitter.theme.ts +23 -23
  145. package/src/themes/spoiler.theme.ts +13 -13
  146. package/src/themes/stepper.theme.ts +13 -13
  147. package/src/themes/switch.theme.ts +67 -67
  148. package/src/themes/table-of-contents.theme.ts +48 -48
  149. package/src/themes/tabs.theme.ts +52 -52
  150. package/src/themes/textarea.theme.ts +27 -27
  151. package/src/themes/theme-selector.theme.ts +15 -15
  152. package/src/themes/timeline.theme.ts +13 -13
  153. package/src/themes/toast.theme.ts +31 -31
  154. package/src/themes/tooltip.theme.ts +28 -28
  155. package/src/themes/tour.theme.ts +13 -13
  156. package/src/themes/tree.theme.ts +13 -13
  157. package/src/themes/user.theme.ts +13 -13
  158. package/src/themes/video.theme.ts +17 -17
  159. package/src/themes/watermark.theme.ts +13 -13
  160. package/src/themes/window-mockup.theme.ts +13 -13
  161. package/src/types/components/3d-hover.ts +11 -11
  162. package/src/types/components/alert.ts +2 -2
  163. package/src/types/components/app.ts +11 -11
  164. package/src/types/components/audio.ts +11 -11
  165. package/src/types/components/avatar-group.ts +11 -11
  166. package/src/types/components/avatar.ts +60 -60
  167. package/src/types/components/badge.ts +2 -2
  168. package/src/types/components/banner.ts +11 -11
  169. package/src/types/components/browser-mockup.ts +11 -11
  170. package/src/types/components/button.ts +74 -81
  171. package/src/types/components/calendar.ts +11 -11
  172. package/src/types/components/changelog.ts +11 -11
  173. package/src/types/components/chart.ts +2 -1
  174. package/src/types/components/chat-message.ts +11 -11
  175. package/src/types/components/chat-messages.ts +11 -11
  176. package/src/types/components/chat-palette.ts +11 -11
  177. package/src/types/components/chat-prompt-submit.ts +11 -11
  178. package/src/types/components/chat-prompt.ts +11 -11
  179. package/src/types/components/chat-reasoning.ts +11 -11
  180. package/src/types/components/chat-shimmer.ts +11 -11
  181. package/src/types/components/chat-tool.ts +11 -11
  182. package/src/types/components/chat.ts +11 -11
  183. package/src/types/components/checkbox.ts +2 -2
  184. package/src/types/components/chip.ts +17 -17
  185. package/src/types/components/collapsible.ts +2 -1
  186. package/src/types/components/color-picker.ts +11 -11
  187. package/src/types/components/command-palette.ts +11 -11
  188. package/src/types/components/compare.ts +11 -11
  189. package/src/types/components/container.ts +17 -17
  190. package/src/types/components/context-menu.ts +11 -11
  191. package/src/types/components/dashboard-group.ts +11 -11
  192. package/src/types/components/dashboard-navbar.ts +11 -11
  193. package/src/types/components/dashboard-panel.ts +11 -11
  194. package/src/types/components/dashboard-resize-handle.ts +11 -11
  195. package/src/types/components/dashboard-search-button.ts +11 -11
  196. package/src/types/components/dashboard-search.ts +11 -11
  197. package/src/types/components/dashboard-sidebar-collapse.ts +11 -11
  198. package/src/types/components/dashboard-sidebar-toggle.ts +11 -11
  199. package/src/types/components/dashboard-sidebar.ts +11 -11
  200. package/src/types/components/dashboard-toolbar.ts +11 -11
  201. package/src/types/components/dock.ts +11 -11
  202. package/src/types/components/dropdown-menu.ts +2 -1
  203. package/src/types/components/editor.ts +11 -11
  204. package/src/types/components/empty.ts +11 -11
  205. package/src/types/components/error.ts +11 -11
  206. package/src/types/components/fieldset.ts +11 -11
  207. package/src/types/components/file-upload.ts +2 -1
  208. package/src/types/components/floating-action.ts +11 -11
  209. package/src/types/components/form.ts +19 -19
  210. package/src/types/components/gallery.ts +11 -11
  211. package/src/types/components/icon.ts +19 -19
  212. package/src/types/components/image.ts +32 -28
  213. package/src/types/components/index.ts +134 -135
  214. package/src/types/components/input-date.ts +11 -11
  215. package/src/types/components/input-menu.ts +44 -43
  216. package/src/types/components/input-number.ts +11 -11
  217. package/src/types/components/input-pin.ts +36 -35
  218. package/src/types/components/input-tags.ts +11 -11
  219. package/src/types/components/input-time.ts +11 -11
  220. package/src/types/components/input.ts +2 -2
  221. package/src/types/components/knob.ts +11 -11
  222. package/src/types/components/link-group.ts +45 -23
  223. package/src/types/components/link.ts +4 -0
  224. package/src/types/components/listbox.ts +11 -11
  225. package/src/types/components/locale-selector.ts +33 -33
  226. package/src/types/components/logo.ts +32 -31
  227. package/src/types/components/main.ts +17 -17
  228. package/src/types/components/megamenu.ts +11 -11
  229. package/src/types/components/meter.ts +11 -11
  230. package/src/types/components/modal.ts +39 -39
  231. package/src/types/components/navigation-menu.ts +59 -54
  232. package/src/types/components/page-aside.ts +11 -11
  233. package/src/types/components/page-body.ts +11 -11
  234. package/src/types/components/page-header.ts +11 -11
  235. package/src/types/components/page.ts +11 -11
  236. package/src/types/components/password.ts +11 -11
  237. package/src/types/components/phone-mockup.ts +5 -5
  238. package/src/types/components/pin-input.ts +11 -11
  239. package/src/types/components/popover.ts +23 -23
  240. package/src/types/components/post.ts +35 -35
  241. package/src/types/components/pricing-plan.ts +11 -11
  242. package/src/types/components/pricing-table.ts +11 -11
  243. package/src/types/components/progress.ts +33 -33
  244. package/src/types/components/prose.ts +11 -11
  245. package/src/types/components/qr-code.ts +11 -11
  246. package/src/types/components/radio-group.ts +11 -11
  247. package/src/types/components/rating.ts +11 -11
  248. package/src/types/components/scroll-area.ts +23 -23
  249. package/src/types/components/scroll-to-top.ts +2 -2
  250. package/src/types/components/select.ts +2 -1
  251. package/src/types/components/separator.ts +19 -19
  252. package/src/types/components/sidebar.ts +87 -72
  253. package/src/types/components/slideover.ts +31 -31
  254. package/src/types/components/slider.ts +2 -2
  255. package/src/types/components/speed-dial.ts +11 -11
  256. package/src/types/components/spinner.ts +25 -25
  257. package/src/types/components/splitter.ts +19 -19
  258. package/src/types/components/spoiler.ts +11 -11
  259. package/src/types/components/stepper.ts +11 -11
  260. package/src/types/components/sticky-surface.ts +19 -19
  261. package/src/types/components/switch.ts +41 -41
  262. package/src/types/components/table-of-contents.ts +17 -17
  263. package/src/types/components/tabs.ts +2 -1
  264. package/src/types/components/textarea.ts +2 -1
  265. package/src/types/components/theme-selector.ts +15 -15
  266. package/src/types/components/timeline.ts +11 -11
  267. package/src/types/components/toast.ts +2 -1
  268. package/src/types/components/tooltip.ts +23 -23
  269. package/src/types/components/tour.ts +11 -11
  270. package/src/types/components/tree.ts +11 -11
  271. package/src/types/components/user.ts +11 -11
  272. package/src/types/components/watermark.ts +11 -11
  273. package/src/types/components/window-mockup.ts +11 -11
  274. package/src/types/theme.ts +10 -0
  275. package/src/utils/docs.ts +215 -189
  276. package/src/utils/headerStack.ts +95 -95
  277. package/src/utils/index.ts +5 -5
  278. package/src/components/astro/RLABlogPost.astro +0 -7
  279. package/src/components/astro/RLABlogPosts.astro +0 -9
  280. package/src/components/astro/RLAPosts.astro +0 -23
  281. package/src/themes/posts.theme.ts +0 -13
  282. package/src/types/components/posts.ts +0 -11
@@ -1,139 +1,141 @@
1
- ---
2
- import { scv, cx } from "css-variants"
3
- import { useUi, resolveClasses } from "../../utils"
4
- import type { ButtonProps } from "../../types"
5
- import buttonThemeDefault, { createButtonTheme } from "../../themes/button.theme"
6
- import { getUIConfig } from "virtual:rimelight-ui"
7
- import RLAAvatar from "./RLAAvatar.astro"
8
-
9
- const uiConfig = getUIConfig()
10
- const buttonTheme = uiConfig.colors ? createButtonTheme(uiConfig.colors) : buttonThemeDefault
11
-
12
- const button = scv(buttonTheme)
13
-
14
- const {
15
- variant = "solid",
16
- color = "primary",
17
- size = "md",
18
- href,
19
- label,
20
- leadingIcon,
21
- trailingIcon,
22
- avatar,
23
- loading = false,
24
- loadingAuto = false,
25
- square = false,
26
- block = false,
27
- active = false,
28
- theme,
29
- activeColor,
30
- activeVariant,
31
- ui: uiProp,
32
- class: className,
33
- ...rest
34
- } = Astro.props as ButtonProps
35
-
36
- const isLeading = !!(leadingIcon || avatar || Astro.slots.has("leading")) || loading
37
- const isTrailing = !!(trailingIcon || Astro.slots.has("trailing")) || (loading && !isLeading)
38
-
39
- const showLeadingIcon = loading
40
- ? "i-lucide-loader-circle"
41
- : leadingIcon
42
-
43
- const showTrailingIcon = loading
44
- ? "i-lucide-loader-circle"
45
- : trailingIcon
46
-
47
- const leadingIconClass = loading ? "animate-spin" : ""
48
- const trailingIconClass = loading ? "animate-spin" : ""
49
-
50
- const classes = resolveClasses(button, {
51
- variant: active && activeVariant ? activeVariant : variant,
52
- color: active && activeColor ? activeColor : color,
53
- size,
54
- block,
55
- square: square || (!label && !Astro.slots.has("default")),
56
- leading: isLeading,
57
- trailing: isTrailing,
58
- loading,
59
- active,
60
- theme
61
- }, useUi("button", uiProp), className);
62
-
63
- const Tag = href ? "a" : "button";
64
-
65
- const loadingAutoProps = loadingAuto ? { 'data-loading-auto': '' } : {};
66
- ---
67
- <Tag
68
- class={classes.root}
69
- data-slot="root"
70
- {...(Tag === "a" ? { href } : {})}
71
- {...loadingAutoProps}
72
- {...rest}
73
- >
74
- <slot name="leading" {...{ ui: classes }}>
75
- {isLeading && (
76
- <span class={classes.leadingIcon} data-slot="leading-icon">
77
- {loading || leadingIcon ? (
78
- <span class={cx(showLeadingIcon, leadingIconClass)} aria-hidden="true" />
79
- ) : avatar ? (
80
- <RLAAvatar
81
- {...(typeof avatar === 'string' ? { src: avatar } : avatar)}
82
- size={classes.leadingAvatarSize as any}
83
- class={classes.leadingAvatar}
84
- data-slot="leading-avatar"
85
- />
86
- ) : null}
87
- </span>
88
- )}
89
- </slot>
90
-
91
- {label !== undefined && label !== null && (
92
- <span class={classes.label} data-slot="label">
93
- {label}
94
- </span>
95
- )}
96
- {!label && <slot />}
97
-
98
- <slot name="trailing" {...{ ui: classes }}>
99
- {isTrailing && (
100
- <span class={classes.trailingIcon} data-slot="trailing-icon">
101
- <span class={cx(showTrailingIcon, trailingIconClass)} aria-hidden="true" />
102
- </span>
103
- )}
104
- </slot>
105
- </Tag>
106
-
107
- {loadingAuto && (
108
- <script>
109
- document.querySelectorAll('button[data-loading-auto]').forEach((button) => {
110
- button.addEventListener('click', async (event) => {
111
- // Find if there are any other click listeners that return a promise
112
- // This is tricky in vanilla JS, but we can assume if it's data-loading-auto,
113
- // the user wants us to track the click.
114
- // If the button is already loading, don't do anything
115
- if (button.getAttribute('data-loading') === 'true') return;
116
-
117
- // We can't easily intercept other listeners, but if this is an Astro component,
118
- // the onClick might be passed via ...rest as a string or handled via a separate script.
119
-
120
- // A better way: if data-loading-auto is present, we wrap the click.
121
- // But we need to know what to wait for.
122
-
123
- // In Rimelight UI, we handle this via native DOM events.
124
- // In Astro, if the user adds an event listener in their own script, we don't know.
125
-
126
- // If they use standard onClick attribute:
127
- const onClick = button.getAttribute('onclick');
128
- if (onClick) {
129
- button.setAttribute('data-loading', 'true');
130
- button.classList.add('is-loading'); // We might need to ensure the CSS handles this
131
- // Actually, the styles are driven by the classes generated by scv.
132
- // Changing those classes dynamically is hard without knowing the full list.
133
-
134
- // However, if we just want PARITY in the API, we can at least provide the hook.
135
- }
136
- });
137
- });
138
- </script>
139
- )}
1
+ ---
2
+ import { scv, cx } from "css-variants"
3
+ import { useUi, resolveClasses } from "../../utils"
4
+ import type { ButtonProps } from "../../types"
5
+ import buttonThemeDefault, { createButtonTheme } from "../../themes/button.theme"
6
+ import { getUIConfig } from "virtual:rimelight-ui"
7
+ import RLAAvatar from "./RLAAvatar.astro"
8
+
9
+ const uiConfig = getUIConfig()
10
+ const buttonTheme = uiConfig.colors ? createButtonTheme(uiConfig.colors) : buttonThemeDefault
11
+
12
+ const button = scv(buttonTheme)
13
+
14
+ const {
15
+ variant = "solid",
16
+ color = "primary",
17
+ size = "md",
18
+ href,
19
+ label,
20
+ leadingIcon,
21
+ trailingIcon,
22
+ avatar,
23
+ loading = false,
24
+ loadingAuto = false,
25
+ square = false,
26
+ rounded = false,
27
+ block = false,
28
+ active = false,
29
+ theme,
30
+ activeColor,
31
+ activeVariant,
32
+ ui: uiProp,
33
+ class: className,
34
+ ...rest
35
+ } = Astro.props as ButtonProps
36
+
37
+ const isLeading = !!(leadingIcon || avatar || Astro.slots.has("leading")) || loading
38
+ const isTrailing = !!(trailingIcon || Astro.slots.has("trailing")) || (loading && !isLeading)
39
+
40
+ const showLeadingIcon = loading
41
+ ? "i-lucide-loader-circle"
42
+ : leadingIcon
43
+
44
+ const showTrailingIcon = loading
45
+ ? "i-lucide-loader-circle"
46
+ : trailingIcon
47
+
48
+ const leadingIconClass = loading ? "animate-spin" : ""
49
+ const trailingIconClass = loading ? "animate-spin" : ""
50
+
51
+ const classes = resolveClasses(button, {
52
+ variant: active && activeVariant ? activeVariant : variant,
53
+ color: active && activeColor ? activeColor : color,
54
+ size,
55
+ block,
56
+ square: square || (!label && !Astro.slots.has("default")),
57
+ rounded,
58
+ leading: isLeading,
59
+ trailing: isTrailing,
60
+ loading,
61
+ active,
62
+ theme
63
+ }, useUi("button", uiProp), className);
64
+
65
+ const Tag = href ? "a" : "button";
66
+
67
+ const loadingAutoProps = loadingAuto ? { 'data-loading-auto': '' } : {};
68
+ ---
69
+ <Tag
70
+ class={classes.root}
71
+ data-slot="root"
72
+ {...(Tag === "a" ? { href } : {})}
73
+ {...loadingAutoProps}
74
+ {...rest}
75
+ >
76
+ <slot name="leading" {...{ ui: classes }}>
77
+ {isLeading && (
78
+ <span class={classes.leadingIcon} data-slot="leading-icon">
79
+ {loading || leadingIcon ? (
80
+ <span class={cx(showLeadingIcon, leadingIconClass)} aria-hidden="true" />
81
+ ) : avatar ? (
82
+ <RLAAvatar
83
+ {...(typeof avatar === 'string' ? { src: avatar } : avatar)}
84
+ size={classes.leadingAvatarSize as any}
85
+ class={classes.leadingAvatar}
86
+ data-slot="leading-avatar"
87
+ />
88
+ ) : null}
89
+ </span>
90
+ )}
91
+ </slot>
92
+
93
+ {label !== undefined && label !== null && (
94
+ <span class={classes.label} data-slot="label">
95
+ {label}
96
+ </span>
97
+ )}
98
+ {!label && <slot />}
99
+
100
+ <slot name="trailing" {...{ ui: classes }}>
101
+ {isTrailing && (
102
+ <span class={classes.trailingIcon} data-slot="trailing-icon">
103
+ <span class={cx(showTrailingIcon, trailingIconClass)} aria-hidden="true" />
104
+ </span>
105
+ )}
106
+ </slot>
107
+ </Tag>
108
+
109
+ {loadingAuto && (
110
+ <script>
111
+ document.querySelectorAll('button[data-loading-auto]').forEach((button) => {
112
+ button.addEventListener('click', async (event) => {
113
+ // Find if there are any other click listeners that return a promise
114
+ // This is tricky in vanilla JS, but we can assume if it's data-loading-auto,
115
+ // the user wants us to track the click.
116
+ // If the button is already loading, don't do anything
117
+ if (button.getAttribute('data-loading') === 'true') return;
118
+
119
+ // We can't easily intercept other listeners, but if this is an Astro component,
120
+ // the onClick might be passed via ...rest as a string or handled via a separate script.
121
+
122
+ // A better way: if data-loading-auto is present, we wrap the click.
123
+ // But we need to know what to wait for.
124
+
125
+ // In Rimelight UI, we handle this via native DOM events.
126
+ // In Astro, if the user adds an event listener in their own script, we don't know.
127
+
128
+ // If they use standard onClick attribute:
129
+ const onClick = button.getAttribute('onclick');
130
+ if (onClick) {
131
+ button.setAttribute('data-loading', 'true');
132
+ button.classList.add('is-loading'); // We might need to ensure the CSS handles this
133
+ // Actually, the styles are driven by the classes generated by scv.
134
+ // Changing those classes dynamically is hard without knowing the full list.
135
+
136
+ // However, if we just want PARITY in the API, we can at least provide the hook.
137
+ }
138
+ });
139
+ });
140
+ </script>
141
+ )}
@@ -20,9 +20,6 @@ const {
20
20
 
21
21
  const classes = resolveClasses(chart, {}, useUi("chart", uiProp), className)
22
22
 
23
- // Unique instance ID to prevent CSS collisions between multiple charts
24
- const instanceId = Math.random().toString(36).substring(2, 8)
25
-
26
23
  // Compute derived values on the server so we don't do heavy JS on the client
27
24
  const max = data.length > 0 ? Math.max(...data.map(d => d.value)) : 1
28
25
  const total = data.reduce((sum, d) => sum + d.value, 0)
@@ -40,21 +37,6 @@ const palette = [
40
37
  const getColor = (item: ChartDataPoint, index: number) =>
41
38
  item.color ?? palette[index % palette.length]
42
39
 
43
- // Strip angle brackets from color values to prevent XSS via </style> breakout
44
- const cssColor = (item: ChartDataPoint, index: number) =>
45
- getColor(item, index).replace(/[<>]/g, "")
46
-
47
- // Build per-item CSS rules to avoid inline styles (CSP compliance)
48
- const itemCssRules: string[] = []
49
- data.forEach((item, i) => {
50
- if (type === "bar") {
51
- const pct = max > 0 ? (item.value / max) * 100 : 0
52
- itemCssRules.push(`.rlc-${instanceId}-b-${i}{height:${pct}%;background:${cssColor(item, i)};min-height:4px;width:100%}`)
53
- }
54
- itemCssRules.push(`.rlc-${instanceId}-s-${i}{background:${cssColor(item, i)}}`)
55
- })
56
- const chartItemStyles = itemCssRules.join("")
57
-
58
40
  // Build pie/donut SVG path segments
59
41
  const PIE_R = 80
60
42
  const PIE_CX = 100
@@ -99,17 +81,17 @@ const areaPath = linePoints.length > 0
99
81
  ` L ${linePoints[linePoints.length - 1]!.x} ${LINE_H - LINE_PAD}` +
100
82
  ` L ${linePoints[0]!.x} ${LINE_H - LINE_PAD} Z`
101
83
  : ""
84
+ const id = `chart-${Math.random().toString(36).substring(2, 9)}`
102
85
  ---
103
86
 
104
- <style define:vars={{ chartH: `${height}px`, chartInnerH: `${height - 60}px` }}>
105
- [data-slot="root"] { min-height: var(--chart-h); }
106
- [data-slot="container"] { height: var(--chart-inner-h); gap: 6px; align-items: flex-end; }
107
- .rla-chart-line-wrap { height: var(--chart-inner-h); }
108
- .rla-chart-pie-wrap { height: var(--chart-inner-h); }
109
- </style>
110
- <style set:html={chartItemStyles}></style>
87
+ <style is:inline set:html={`
88
+ .${id} { min-height: ${height}px; }
89
+ .${id} [data-slot="container"] { height: ${height - 60}px; gap: 6px; align-items: flex-end; }
90
+ .${id} .rla-chart-line-wrap { height: ${height - 60}px; }
91
+ .${id} .rla-chart-pie-wrap { height: ${height - 60}px; }
92
+ `} />
111
93
 
112
- <div class={classes.root} data-slot="root" {...rest}>
94
+ <div class:list={[classes.root, id]} data-slot="root" {...rest}>
113
95
  {title && <div class={classes.title} data-slot="title">{title}</div>}
114
96
 
115
97
  {/* Bar Chart */}
@@ -122,10 +104,11 @@ const areaPath = linePoints.length > 0
122
104
  <span class="text-[10px] text-muted-foreground font-mono opacity-0 group-hover:opacity-100 transition-opacity">
123
105
  {item.value}
124
106
  </span>
125
- <div
126
- class={`${classes.bar} rlc-${instanceId}-b-${i}`}
127
- title={`${item.label}: ${item.value}`}
128
- />
107
+ <div class:list={[classes.bar, "h-full w-full overflow-hidden !bg-transparent"]} title={`${item.label}: ${item.value}`}>
108
+ <svg class="h-full w-full overflow-visible" viewBox="0 0 20 100" preserveAspectRatio="none">
109
+ <rect x="0" y={100 - pct} width="20" height={pct} fill={getColor(item, i)} rx="2" />
110
+ </svg>
111
+ </div>
129
112
  <span class={classes.axis}>{item.label}</span>
130
113
  </div>
131
114
  )
@@ -211,9 +194,9 @@ const areaPath = linePoints.length > 0
211
194
  <div class="flex flex-col gap-1.5">
212
195
  {data.map((item, i) => (
213
196
  <div class="flex items-center gap-2 text-xs text-muted-foreground">
214
- <span
215
- class={`size-3 rounded-sm shrink-0 rlc-${instanceId}-s-${i}`}
216
- />
197
+ <svg class="size-3 shrink-0" viewBox="0 0 10 10">
198
+ <rect width="10" height="10" rx="2" fill={getColor(item, i)} />
199
+ </svg>
217
200
  <span>{item.label}</span>
218
201
  <span class="ml-1 font-mono text-foreground">{item.value}</span>
219
202
  </div>
@@ -230,7 +213,9 @@ const areaPath = linePoints.length > 0
230
213
  <div class={classes.legend} data-slot="legend">
231
214
  {data.map((item, i) => (
232
215
  <div class="flex items-center gap-1.5">
233
- <span class={`size-2.5 rounded-full shrink-0 rlc-${instanceId}-s-${i}`} />
216
+ <svg class="size-2.5 shrink-0" viewBox="0 0 10 10">
217
+ <circle cx="5" cy="5" r="5" fill={getColor(item, i)} />
218
+ </svg>
234
219
  <span>{item.label}</span>
235
220
  </div>
236
221
  ))}