@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.
- package/README.md +157 -157
- package/package.json +105 -105
- package/src/components/astro/RLAAspectRatio.astro +2 -2
- package/src/components/astro/RLAButton.astro +141 -139
- package/src/components/astro/RLAChart.astro +19 -34
- package/src/components/astro/RLAHead.astro +427 -196
- package/src/components/astro/RLAHeader.astro +66 -59
- package/src/components/astro/RLAImage.astro +61 -19
- package/src/components/astro/RLALink.astro +22 -23
- package/src/components/astro/RLALinkGroup.astro +66 -4
- package/src/components/astro/RLALocaleSelector.astro +136 -113
- package/src/components/astro/RLAMain.astro +8 -3
- package/src/components/astro/RLAMarquee.astro +9 -2
- package/src/components/astro/RLANavigationMenu.astro +245 -56
- package/src/components/astro/RLAPagination.astro +2 -4
- package/src/components/astro/RLAProgress.astro +8 -2
- package/src/components/astro/RLASelect.astro +38 -24
- package/src/components/astro/RLASlideover.astro +66 -1
- package/src/components/astro/RLASlider.astro +14 -14
- package/src/components/astro/RLASplitter.astro +14 -2
- package/src/components/astro/RLAStickySurface.astro +9 -2
- package/src/components/vue/RLVCheckbox.vue +68 -68
- package/src/components/vue/RLVForm.vue +44 -44
- package/src/components/vue/RLVFormField.vue +58 -58
- package/src/components/vue/RLVInput.vue +93 -93
- package/src/components/vue/RLVPost.vue +63 -63
- package/src/components/vue/RLVPosts.vue +21 -21
- package/src/components/vue/RLVToast.vue +68 -68
- package/src/components/vue/RLVToaster.vue +29 -29
- package/src/composables/index.ts +3 -3
- package/src/composables/useHeaderStore.ts +13 -14
- package/src/composables/useScrollToTop.ts +62 -62
- package/src/composables/useToast.ts +43 -42
- package/src/config/index.ts +1 -0
- package/src/config/security.ts +220 -0
- package/src/integrations/ui.ts +199 -199
- package/src/middleware/security.ts +75 -15
- package/src/plugins/index.ts +2 -2
- package/src/plugins/starlightDocsApi/index.ts +272 -272
- package/src/presets/defaults.ts +297 -297
- package/src/presets/index.ts +683 -637
- package/src/styles/index.css +160 -160
- package/src/themes/3d-hover.theme.ts +13 -13
- package/src/themes/accordion.theme.ts +13 -13
- package/src/themes/alert.theme.ts +131 -125
- package/src/themes/app.theme.ts +13 -13
- package/src/themes/audio.theme.ts +13 -13
- package/src/themes/avatar.theme.ts +84 -84
- package/src/themes/badge.theme.ts +169 -163
- package/src/themes/banner.theme.ts +13 -13
- package/src/themes/browser-mockup.theme.ts +13 -13
- package/src/themes/button.theme.ts +224 -202
- package/src/themes/calendar.theme.ts +13 -13
- package/src/themes/card.theme.ts +42 -42
- package/src/themes/changelog.theme.ts +13 -13
- package/src/themes/chart.theme.ts +22 -22
- package/src/themes/chat-message.theme.ts +13 -13
- package/src/themes/chat-messages.theme.ts +13 -13
- package/src/themes/chat-palette.theme.ts +13 -13
- package/src/themes/chat-prompt-submit.theme.ts +13 -13
- package/src/themes/chat-prompt.theme.ts +13 -13
- package/src/themes/chat-reasoning.theme.ts +13 -13
- package/src/themes/chat-shimmer.theme.ts +13 -13
- package/src/themes/chat-tool.theme.ts +13 -13
- package/src/themes/chat.theme.ts +13 -13
- package/src/themes/checkbox.theme.ts +50 -50
- package/src/themes/chip.theme.ts +74 -74
- package/src/themes/color-picker.theme.ts +13 -13
- package/src/themes/command-palette.theme.ts +13 -13
- package/src/themes/compare.theme.ts +13 -13
- package/src/themes/confirm.theme.ts +48 -48
- package/src/themes/container.theme.ts +13 -13
- package/src/themes/context-menu.theme.ts +13 -13
- package/src/themes/dashboard-group.theme.ts +13 -13
- package/src/themes/dashboard-navbar.theme.ts +13 -13
- package/src/themes/dashboard-panel.theme.ts +13 -13
- package/src/themes/dashboard-resize-handle.theme.ts +13 -13
- package/src/themes/dashboard-search-button.theme.ts +13 -13
- package/src/themes/dashboard-search.theme.ts +13 -13
- package/src/themes/dashboard-sidebar-collapse.theme.ts +13 -13
- package/src/themes/dashboard-sidebar-toggle.theme.ts +13 -13
- package/src/themes/dashboard-sidebar.theme.ts +13 -13
- package/src/themes/dashboard-toolbar.theme.ts +13 -13
- package/src/themes/dock.theme.ts +13 -13
- package/src/themes/drawer.theme.ts +61 -61
- package/src/themes/dropdown-menu.theme.ts +29 -29
- package/src/themes/editor.theme.ts +13 -13
- package/src/themes/empty.theme.ts +13 -13
- package/src/themes/error.theme.ts +13 -13
- package/src/themes/field-group.theme.ts +24 -24
- package/src/themes/fieldset.theme.ts +13 -13
- package/src/themes/floating-action.theme.ts +13 -13
- package/src/themes/footer.theme.ts +30 -30
- package/src/themes/form.theme.ts +13 -13
- package/src/themes/gallery.theme.ts +13 -13
- package/src/themes/head.theme.ts +13 -13
- package/src/themes/header.theme.ts +45 -46
- package/src/themes/icon.theme.ts +23 -23
- package/src/themes/image.theme.ts +23 -19
- package/src/themes/input-date.theme.ts +13 -13
- package/src/themes/input-menu.theme.ts +35 -35
- package/src/themes/input-number.theme.ts +13 -13
- package/src/themes/input-tags.theme.ts +13 -13
- package/src/themes/input-time.theme.ts +13 -13
- package/src/themes/input.theme.ts +42 -42
- package/src/themes/kbd.theme.ts +95 -89
- package/src/themes/knob.theme.ts +13 -13
- package/src/themes/link-group.theme.ts +32 -32
- package/src/themes/link.theme.ts +13 -13
- package/src/themes/listbox.theme.ts +13 -13
- package/src/themes/locale-selector.theme.ts +49 -49
- package/src/themes/logo.theme.ts +13 -13
- package/src/themes/main.theme.ts +13 -13
- package/src/themes/megamenu.theme.ts +13 -13
- package/src/themes/meter.theme.ts +13 -13
- package/src/themes/navigation-menu.theme.ts +44 -27
- package/src/themes/page-aside.theme.ts +13 -13
- package/src/themes/page-body.theme.ts +13 -13
- package/src/themes/page-header.theme.ts +13 -13
- package/src/themes/page-section.theme.ts +187 -187
- package/src/themes/page.theme.ts +13 -13
- package/src/themes/password.theme.ts +13 -13
- package/src/themes/phone-mockup.theme.ts +13 -13
- package/src/themes/placeholder.theme.ts +15 -15
- package/src/themes/post.theme.ts +33 -33
- package/src/themes/pricing-plan.theme.ts +13 -13
- package/src/themes/pricing-table.theme.ts +13 -13
- package/src/themes/progress.theme.ts +38 -38
- package/src/themes/prose.theme.ts +13 -13
- package/src/themes/qr-code.theme.ts +13 -13
- package/src/themes/quote.theme.ts +13 -13
- package/src/themes/radio-group.theme.ts +13 -13
- package/src/themes/rating.theme.ts +13 -13
- package/src/themes/scroll-area.theme.ts +26 -26
- package/src/themes/scroll-to-top.theme.ts +52 -52
- package/src/themes/select.theme.ts +29 -29
- package/src/themes/separator.theme.ts +147 -147
- package/src/themes/sidebar.theme.ts +38 -38
- package/src/themes/skeleton.theme.ts +21 -21
- package/src/themes/slideover.theme.ts +4 -4
- package/src/themes/slider.theme.ts +36 -36
- package/src/themes/speed-dial.theme.ts +13 -13
- package/src/themes/spinner.theme.ts +34 -34
- package/src/themes/splitter.theme.ts +23 -23
- package/src/themes/spoiler.theme.ts +13 -13
- package/src/themes/stepper.theme.ts +13 -13
- package/src/themes/switch.theme.ts +67 -67
- package/src/themes/table-of-contents.theme.ts +48 -48
- package/src/themes/tabs.theme.ts +52 -52
- package/src/themes/textarea.theme.ts +27 -27
- package/src/themes/theme-selector.theme.ts +15 -15
- package/src/themes/timeline.theme.ts +13 -13
- package/src/themes/toast.theme.ts +31 -31
- package/src/themes/tooltip.theme.ts +28 -28
- package/src/themes/tour.theme.ts +13 -13
- package/src/themes/tree.theme.ts +13 -13
- package/src/themes/user.theme.ts +13 -13
- package/src/themes/video.theme.ts +17 -17
- package/src/themes/watermark.theme.ts +13 -13
- package/src/themes/window-mockup.theme.ts +13 -13
- package/src/types/components/3d-hover.ts +11 -11
- package/src/types/components/alert.ts +2 -2
- package/src/types/components/app.ts +11 -11
- package/src/types/components/audio.ts +11 -11
- package/src/types/components/avatar-group.ts +11 -11
- package/src/types/components/avatar.ts +60 -60
- package/src/types/components/badge.ts +2 -2
- package/src/types/components/banner.ts +11 -11
- package/src/types/components/browser-mockup.ts +11 -11
- package/src/types/components/button.ts +74 -81
- package/src/types/components/calendar.ts +11 -11
- package/src/types/components/changelog.ts +11 -11
- package/src/types/components/chart.ts +2 -1
- package/src/types/components/chat-message.ts +11 -11
- package/src/types/components/chat-messages.ts +11 -11
- package/src/types/components/chat-palette.ts +11 -11
- package/src/types/components/chat-prompt-submit.ts +11 -11
- package/src/types/components/chat-prompt.ts +11 -11
- package/src/types/components/chat-reasoning.ts +11 -11
- package/src/types/components/chat-shimmer.ts +11 -11
- package/src/types/components/chat-tool.ts +11 -11
- package/src/types/components/chat.ts +11 -11
- package/src/types/components/checkbox.ts +2 -2
- package/src/types/components/chip.ts +17 -17
- package/src/types/components/collapsible.ts +2 -1
- package/src/types/components/color-picker.ts +11 -11
- package/src/types/components/command-palette.ts +11 -11
- package/src/types/components/compare.ts +11 -11
- package/src/types/components/container.ts +17 -17
- package/src/types/components/context-menu.ts +11 -11
- package/src/types/components/dashboard-group.ts +11 -11
- package/src/types/components/dashboard-navbar.ts +11 -11
- package/src/types/components/dashboard-panel.ts +11 -11
- package/src/types/components/dashboard-resize-handle.ts +11 -11
- package/src/types/components/dashboard-search-button.ts +11 -11
- package/src/types/components/dashboard-search.ts +11 -11
- package/src/types/components/dashboard-sidebar-collapse.ts +11 -11
- package/src/types/components/dashboard-sidebar-toggle.ts +11 -11
- package/src/types/components/dashboard-sidebar.ts +11 -11
- package/src/types/components/dashboard-toolbar.ts +11 -11
- package/src/types/components/dock.ts +11 -11
- package/src/types/components/dropdown-menu.ts +2 -1
- package/src/types/components/editor.ts +11 -11
- package/src/types/components/empty.ts +11 -11
- package/src/types/components/error.ts +11 -11
- package/src/types/components/fieldset.ts +11 -11
- package/src/types/components/file-upload.ts +2 -1
- package/src/types/components/floating-action.ts +11 -11
- package/src/types/components/form.ts +19 -19
- package/src/types/components/gallery.ts +11 -11
- package/src/types/components/icon.ts +19 -19
- package/src/types/components/image.ts +32 -28
- package/src/types/components/index.ts +134 -135
- package/src/types/components/input-date.ts +11 -11
- package/src/types/components/input-menu.ts +44 -43
- package/src/types/components/input-number.ts +11 -11
- package/src/types/components/input-pin.ts +36 -35
- package/src/types/components/input-tags.ts +11 -11
- package/src/types/components/input-time.ts +11 -11
- package/src/types/components/input.ts +2 -2
- package/src/types/components/knob.ts +11 -11
- package/src/types/components/link-group.ts +45 -23
- package/src/types/components/link.ts +4 -0
- package/src/types/components/listbox.ts +11 -11
- package/src/types/components/locale-selector.ts +33 -33
- package/src/types/components/logo.ts +32 -31
- package/src/types/components/main.ts +17 -17
- package/src/types/components/megamenu.ts +11 -11
- package/src/types/components/meter.ts +11 -11
- package/src/types/components/modal.ts +39 -39
- package/src/types/components/navigation-menu.ts +59 -54
- package/src/types/components/page-aside.ts +11 -11
- package/src/types/components/page-body.ts +11 -11
- package/src/types/components/page-header.ts +11 -11
- package/src/types/components/page.ts +11 -11
- package/src/types/components/password.ts +11 -11
- package/src/types/components/phone-mockup.ts +5 -5
- package/src/types/components/pin-input.ts +11 -11
- package/src/types/components/popover.ts +23 -23
- package/src/types/components/post.ts +35 -35
- package/src/types/components/pricing-plan.ts +11 -11
- package/src/types/components/pricing-table.ts +11 -11
- package/src/types/components/progress.ts +33 -33
- package/src/types/components/prose.ts +11 -11
- package/src/types/components/qr-code.ts +11 -11
- package/src/types/components/radio-group.ts +11 -11
- package/src/types/components/rating.ts +11 -11
- package/src/types/components/scroll-area.ts +23 -23
- package/src/types/components/scroll-to-top.ts +2 -2
- package/src/types/components/select.ts +2 -1
- package/src/types/components/separator.ts +19 -19
- package/src/types/components/sidebar.ts +87 -72
- package/src/types/components/slideover.ts +31 -31
- package/src/types/components/slider.ts +2 -2
- package/src/types/components/speed-dial.ts +11 -11
- package/src/types/components/spinner.ts +25 -25
- package/src/types/components/splitter.ts +19 -19
- package/src/types/components/spoiler.ts +11 -11
- package/src/types/components/stepper.ts +11 -11
- package/src/types/components/sticky-surface.ts +19 -19
- package/src/types/components/switch.ts +41 -41
- package/src/types/components/table-of-contents.ts +17 -17
- package/src/types/components/tabs.ts +2 -1
- package/src/types/components/textarea.ts +2 -1
- package/src/types/components/theme-selector.ts +15 -15
- package/src/types/components/timeline.ts +11 -11
- package/src/types/components/toast.ts +2 -1
- package/src/types/components/tooltip.ts +23 -23
- package/src/types/components/tour.ts +11 -11
- package/src/types/components/tree.ts +11 -11
- package/src/types/components/user.ts +11 -11
- package/src/types/components/watermark.ts +11 -11
- package/src/types/components/window-mockup.ts +11 -11
- package/src/types/theme.ts +10 -0
- package/src/utils/docs.ts +215 -189
- package/src/utils/headerStack.ts +95 -95
- package/src/utils/index.ts +5 -5
- package/src/components/astro/RLABlogPost.astro +0 -7
- package/src/components/astro/RLABlogPosts.astro +0 -9
- package/src/components/astro/RLAPosts.astro +0 -23
- package/src/themes/posts.theme.ts +0 -13
- 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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
{...
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
|
105
|
-
|
|
106
|
-
[data-slot="container"] { height:
|
|
107
|
-
.rla-chart-line-wrap { height:
|
|
108
|
-
.rla-chart-pie-wrap { height:
|
|
109
|
-
|
|
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=
|
|
127
|
-
|
|
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
|
-
<
|
|
215
|
-
|
|
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
|
-
<
|
|
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
|
))}
|