@rimelight/ui 0.0.46 → 0.0.48
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/dist/icons-DPnFQCts.d.mts +72 -0
- package/dist/icons.d.mts +1 -1
- package/dist/index.d.mts +5 -6
- package/dist/preset.d.mts +1 -1
- package/dist/preset.mjs +73 -1
- package/dist/resolver.d.mts +4 -5
- package/dist/resolver.mjs +2 -4
- package/dist/shortcuts.d.mts +10 -11
- package/dist/stores.d.mts +3 -4
- package/dist/{types-DqAgCNcm.d.mts → types-DWmKMcYC.d.mts} +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +8 -6
- package/src/components/3d-hover/RLS3dHover.tsx +21 -0
- package/src/components/accordion/RLSAccordion.tsx +112 -0
- package/src/components/app/RLSApp.tsx +21 -0
- package/src/components/aspect-ratio/RLSAspectRatio.tsx +30 -0
- package/src/components/audio/RLSAudio.tsx +27 -0
- package/src/components/avatar/RLSAvatar.tsx +142 -0
- package/src/components/avatar/avatar.ts +22 -21
- package/src/components/avatar-group/RLSAvatarGroup.tsx +163 -0
- package/src/components/badge/RLSBadge.tsx +1 -1
- package/src/components/badge/RLVBadge.vue +5 -3
- package/src/components/banner/RLABanner.astro +1 -1
- package/src/components/banner/RLSBanner.tsx +151 -0
- package/src/components/breadcrumb/RLSBreadcrumb.tsx +194 -0
- package/src/components/browser-mockup/RLSBrowserMockup.tsx +21 -0
- package/src/components/button/RLSButton.tsx +53 -38
- package/src/components/button/RLVButton.vue +44 -32
- package/src/components/calendar/RLSCalendar.tsx +26 -0
- package/src/components/callout/RLSCallout.tsx +151 -0
- package/src/components/card/RLSCard.tsx +4 -0
- package/src/components/card/RLVCard.vue +4 -0
- package/src/components/card/card.ts +10 -0
- package/src/components/carousel/RLACarousel.astro +14 -1
- package/src/components/carousel/RLSCarousel.tsx +260 -0
- package/src/components/chart/RLSChart.tsx +299 -0
- package/src/components/chat/RLSChat.tsx +27 -0
- package/src/components/chat-message/RLSChatMessage.tsx +27 -0
- package/src/components/chat-messages/RLSChatMessages.tsx +27 -0
- package/src/components/chat-palette/RLSChatPalette.tsx +27 -0
- package/src/components/chat-prompt/RLSChatPrompt.tsx +27 -0
- package/src/components/chat-prompt-submit/RLSChatPromptSubmit.tsx +27 -0
- package/src/components/chat-reasoning/RLSChatReasoning.tsx +27 -0
- package/src/components/chat-shimmer/RLSChatShimmer.tsx +27 -0
- package/src/components/chat-tool/RLSChatTool.tsx +27 -0
- package/src/components/checkbox/RLACheckbox.astro +1 -0
- package/src/components/checkbox/RLSCheckbox.tsx +1 -1
- package/src/components/checkbox/checkbox.theme.ts +2 -2
- package/src/components/chip/RLSChip.tsx +65 -0
- package/src/components/collapsible/RLSCollapsible.tsx +89 -0
- package/src/components/color-area/RLSColorArea.tsx +554 -0
- package/src/components/color-field/RLSColorField.tsx +236 -0
- package/src/components/color-picker/RLSColorPicker.tsx +26 -0
- package/src/components/color-slider/RLSColorSlider.tsx +373 -0
- package/src/components/command-palette/RLSCommandPalette.tsx +26 -0
- package/src/components/compare/RLSCompare.tsx +26 -0
- package/src/components/confirm/RLSConfirm.tsx +173 -0
- package/src/components/container/RLSContainer.tsx +24 -0
- package/src/components/context-menu/RLSContextMenu.tsx +26 -0
- package/src/components/copy-markdown/RLSCopyMarkdown.tsx +57 -0
- package/src/components/dashboard-group/RLSDashboardGroup.tsx +29 -0
- package/src/components/dashboard-navbar/RLSDashboardNavbar.tsx +116 -0
- package/src/components/dashboard-panel/RLSDashboardPanel.tsx +84 -0
- package/src/components/dashboard-resize-handle/RLSDashboardResizeHandle.tsx +35 -0
- package/src/components/dashboard-search/RLADashboardSearch.astro +1 -1
- package/src/components/dashboard-search/RLSDashboardSearch.tsx +125 -0
- package/src/components/dashboard-search-button/RLSDashboardSearchButton.tsx +82 -0
- package/src/components/dashboard-sidebar/RLADashboardSidebar.astro +4 -4
- package/src/components/dashboard-sidebar/RLSDashboardSidebar.tsx +184 -0
- package/src/components/dashboard-sidebar-collapse/RLSDashboardSidebarCollapse.tsx +46 -0
- package/src/components/dashboard-sidebar-toggle/RLSDashboardSidebarToggle.tsx +35 -0
- package/src/components/dashboard-toolbar/RLSDashboardToolbar.tsx +49 -0
- package/src/components/date/RLSDate.tsx +34 -0
- package/src/components/dock/RLSDock.tsx +26 -0
- package/src/components/drawer/RLSDrawer.tsx +177 -0
- package/src/components/dropdown-menu/RLADropdownMenu.astro +250 -241
- package/src/components/dropdown-menu/RLSDropdownMenu.tsx +183 -86
- package/src/components/editor/RLSEditor.tsx +26 -0
- package/src/components/empty/RLSEmpty.tsx +132 -0
- package/src/components/error/RLSError.tsx +26 -0
- package/src/components/field-group/RLSFieldGroup.tsx +46 -0
- package/src/components/fieldset/RLSFieldset.tsx +26 -0
- package/src/components/file-upload/RLAFileUpload.astro +1 -1
- package/src/components/file-upload/RLSFileUpload.tsx +163 -0
- package/src/components/floating-action/RLSFloatingAction.tsx +26 -0
- package/src/components/footer/RLSFooter.tsx +56 -0
- package/src/components/form/RLSForm.tsx +34 -0
- package/src/components/gallery/RLSGallery.tsx +21 -0
- package/src/components/gamepad/RLSGamepad.tsx +269 -0
- package/src/components/grid/RLSGrid.tsx +29 -0
- package/src/components/head/RLAHead.astro +9 -0
- package/src/components/head/RLSHead.tsx +42 -0
- package/src/components/head/UIHead.astro +3 -0
- package/src/components/header/HeaderLayer.astro +1 -1
- package/src/components/header/RLSHeader.tsx +87 -0
- package/src/components/hover-card/RLSHoverCard.tsx +72 -0
- package/src/components/icon/RLSIcon.tsx +3 -1
- package/src/components/image/RLAImage.astro +447 -138
- package/src/components/image/RLSImage.tsx +545 -0
- package/src/components/image/image.theme.ts +19 -3
- package/src/components/image/image.ts +31 -1
- package/src/components/input/RLAInput.astro +62 -51
- package/src/components/input/RLSInput.tsx +1 -1
- package/src/components/input-date/RLSInputDate.tsx +92 -0
- package/src/components/input-menu/RLAInputMenu.astro +3 -3
- package/src/components/input-menu/RLSInputMenu.tsx +199 -0
- package/src/components/input-number/RLSInputNumber.tsx +184 -0
- package/src/components/input-pin/RLSInputPin.tsx +185 -0
- package/src/components/input-rating/RLAInputRating.astro +8 -8
- package/src/components/input-rating/RLSInputRating.tsx +198 -0
- package/src/components/input-rating/input-rating.ts +4 -0
- package/src/components/input-tags/RLSInputTags.tsx +94 -0
- package/src/components/input-time/RLSInputTime.tsx +92 -0
- package/src/components/kbd/RLSKbd.tsx +37 -0
- package/src/components/keyboard/RLSKeyboard.tsx +476 -0
- package/src/components/knob/RLSKnob.tsx +27 -0
- package/src/components/label/RLSLabel.tsx +27 -0
- package/src/components/layout-grid/RLALayoutGrid.astro +29 -29
- package/src/components/layout-grid/RLSLayoutGrid.tsx +402 -0
- package/src/components/layout-grid/layout-grid.ts +25 -1
- package/src/components/link/RLALink.astro +5 -5
- package/src/components/link/RLSLink.tsx +6 -5
- package/src/components/link/link.ts +21 -12
- package/src/components/link-group/RLSLinkGroup.tsx +76 -0
- package/src/components/listbox/RLSListbox.tsx +27 -0
- package/src/components/locale-selector/RLALocaleSelector.astro +110 -102
- package/src/components/locale-selector/RLSLocaleSelector.tsx +178 -0
- package/src/components/locale-selector/locale-selector.ts +2 -7
- package/src/components/logo/RLALogo.astro +153 -102
- package/src/components/logo/RLSLogo.tsx +129 -0
- package/src/components/main/RLSMain.tsx +40 -0
- package/src/components/marquee/RLSMarquee.tsx +80 -0
- package/src/components/meter/RLSMeter.tsx +27 -0
- package/src/components/modal/RLAModal.astro +1 -1
- package/src/components/modal/RLSModal.tsx +109 -72
- package/src/components/navigation-menu/RLANavigationMenu.astro +6 -6
- package/src/components/navigation-menu/RLSNavigationMenu.tsx +228 -0
- package/src/components/navigation-menu/navigation-menu.ts +2 -2
- package/src/components/package-managers/RLSPackageManagers.tsx +204 -0
- package/src/components/page/RLSPage.tsx +21 -0
- package/src/components/page-aside/RLSPageAside.tsx +21 -0
- package/src/components/page-body/RLSPageBody.tsx +21 -0
- package/src/components/page-header/RLSPageHeader.tsx +21 -0
- package/src/components/page-section/RLSPageSection.tsx +201 -0
- package/src/components/pagination/RLSPagination.tsx +114 -0
- package/src/components/password/RLSPassword.tsx +27 -0
- package/src/components/phone-mockup/RLSPhoneMockup.tsx +27 -0
- package/src/components/placeholder/RLSPlaceholder.tsx +47 -0
- package/src/components/popover/RLAPopover.astro +2 -2
- package/src/components/popover/RLSPopover.tsx +124 -0
- package/src/components/post/RLSPost.tsx +134 -0
- package/src/components/pricing-plan/RLSPricingPlan.tsx +26 -0
- package/src/components/pricing-table/RLSPricingTable.tsx +26 -0
- package/src/components/progress/RLSProgress.tsx +53 -0
- package/src/components/prose/RLSProse.tsx +26 -0
- package/src/components/qr-code/RLSQrCode.tsx +26 -0
- package/src/components/quote/RLAQuote.astro +10 -6
- package/src/components/quote/RLSQuote.tsx +37 -0
- package/src/components/quote/quote.theme.ts +5 -2
- package/src/components/radio-group/RLSRadioGroup.tsx +37 -0
- package/src/components/rating/RLSRating.tsx +27 -0
- package/src/components/scroll-area/RLAScrollArea.astro +1 -1
- package/src/components/scroll-area/RLSScrollArea.tsx +210 -0
- package/src/components/scroll-to-top/RLAScrollToTop.astro +5 -4
- package/src/components/scroll-to-top/RLSScrollToTop.tsx +145 -0
- package/src/components/search/RLASearch.astro +6 -6
- package/src/components/search/RLSSearch.tsx +237 -0
- package/src/components/select/RLASelect.astro +67 -4
- package/src/components/select/RLSSelect.tsx +107 -39
- package/src/components/select/RLVSelect.vue +50 -1
- package/src/components/select/select.theme.ts +30 -10
- package/src/components/select/select.ts +20 -1
- package/src/components/separator/RLSSeparator.tsx +92 -0
- package/src/components/share/RLSShare.tsx +66 -0
- package/src/components/shortcuts/RLAShortcuts.astro +2 -2
- package/src/components/shortcuts/RLSShortcuts.tsx +393 -0
- package/src/components/sidebar/RLASidebar.astro +1 -1
- package/src/components/sidebar/RLSSidebar.tsx +271 -0
- package/src/components/skeleton/RLSSkeleton.tsx +21 -0
- package/src/components/slideover/RLASlideover.astro +1 -1
- package/src/components/slideover/RLSSlideover.tsx +159 -0
- package/src/components/slider/RLSSlider.tsx +112 -0
- package/src/components/speed-dial/RLSSpeedDial.tsx +27 -0
- package/src/components/spinner/RLSSpinner.tsx +22 -0
- package/src/components/splitter/RLASplitter.astro +1 -1
- package/src/components/splitter/RLSSplitter.tsx +178 -0
- package/src/components/spoiler/RLSSpoiler.tsx +26 -0
- package/src/components/stepper/RLAStepper.astro +9 -9
- package/src/components/stepper/RLSStepper.tsx +205 -0
- package/src/components/steps/RLSSteps.tsx +108 -0
- package/src/components/sticky-surface/RLSStickySurface.tsx +63 -0
- package/src/components/surround/RLSSurround.tsx +57 -0
- package/src/components/switch/RLSSwitch.tsx +56 -0
- package/src/components/table/RLATable.astro +1044 -579
- package/src/components/table/RLSTable.tsx +893 -0
- package/src/components/table/table.theme.ts +47 -16
- package/src/components/table/table.ts +104 -66
- package/src/components/table-of-contents/RLSTableOfContents.tsx +196 -0
- package/src/components/tabs/RLATabs.astro +8 -8
- package/src/components/tabs/RLSTabs.tsx +298 -0
- package/src/components/textarea/RLATextarea.astro +1 -0
- package/src/components/textarea/RLSTextarea.tsx +3 -1
- package/src/components/theme-selector/RLAThemeSelector.astro +85 -56
- package/src/components/theme-selector/RLSThemeSelector.tsx +131 -0
- package/src/components/theme-selector/theme-selector.theme.ts +5 -7
- package/src/components/theme-selector/theme-selector.ts +11 -1
- package/src/components/timeline/RLSTimeline.tsx +171 -0
- package/src/components/toast/RLAToast.astro +2 -2
- package/src/components/toast/RLSToast.tsx +179 -0
- package/src/components/toaster/RLSToaster.tsx +82 -0
- package/src/components/tooltip/RLSTooltip.tsx +48 -0
- package/src/components/tour/RLSTour.tsx +26 -0
- package/src/components/tree/RLSTree.tsx +26 -0
- package/src/components/user/RLSUser.tsx +26 -0
- package/src/components/video/RLAVideo.astro +4 -1
- package/src/components/video/RLSVideo.tsx +158 -0
- package/src/components/watermark/RLSWatermark.tsx +27 -0
- package/src/components/window-mockup/RLSWindowMockup.tsx +27 -0
- package/src/preset.ts +73 -1
- package/src/resolver.ts +6 -1
- package/src/virtual.d.ts +6 -0
- package/dist/icons--RzV1RTU.d.mts +0 -72
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMemo,
|
|
3
|
+
createSignal,
|
|
4
|
+
createEffect,
|
|
3
5
|
splitProps,
|
|
4
6
|
Show,
|
|
5
7
|
onMount,
|
|
6
8
|
onCleanup,
|
|
7
|
-
createEffect,
|
|
8
9
|
type Component,
|
|
9
10
|
type JSX
|
|
10
11
|
} from "solid-js"
|
|
@@ -15,8 +16,11 @@ import RLSButton from "../button/RLSButton"
|
|
|
15
16
|
export interface RLSModalProps extends ModalProps {
|
|
16
17
|
onClose?: () => void
|
|
17
18
|
children?: JSX.Element
|
|
19
|
+
trigger?: JSX.Element
|
|
20
|
+
triggerSlot?: JSX.Element
|
|
18
21
|
titleSlot?: JSX.Element
|
|
19
22
|
descriptionSlot?: JSX.Element
|
|
23
|
+
footer?: JSX.Element
|
|
20
24
|
footerSlot?: JSX.Element
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -26,6 +30,7 @@ const RLSModal: Component<RLSModalProps> = (allProps) => {
|
|
|
26
30
|
"onClose",
|
|
27
31
|
"title",
|
|
28
32
|
"description",
|
|
33
|
+
"triggerLabel",
|
|
29
34
|
"size",
|
|
30
35
|
"closeOnClickOutside",
|
|
31
36
|
"closeOnEscape",
|
|
@@ -34,32 +39,50 @@ const RLSModal: Component<RLSModalProps> = (allProps) => {
|
|
|
34
39
|
"ui",
|
|
35
40
|
"class",
|
|
36
41
|
"children",
|
|
42
|
+
"trigger",
|
|
43
|
+
"triggerSlot",
|
|
37
44
|
"titleSlot",
|
|
38
45
|
"descriptionSlot",
|
|
46
|
+
"footer",
|
|
39
47
|
"footerSlot"
|
|
40
48
|
])
|
|
41
49
|
|
|
50
|
+
const [internalOpen, setInternalOpen] = createSignal(props.open ?? false)
|
|
51
|
+
const isControlled = () => props.open !== undefined
|
|
52
|
+
const isOpen = () => (isControlled() ? !!props.open : internalOpen())
|
|
53
|
+
|
|
54
|
+
createEffect(() => {
|
|
55
|
+
if (props.open !== undefined) {
|
|
56
|
+
setInternalOpen(props.open)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
42
60
|
const closeOnClickOutside = () => props.closeOnClickOutside !== false
|
|
43
61
|
const closeOnEscape = () => props.closeOnEscape !== false
|
|
44
62
|
const unmountOnHide = () => props.unmountOnHide !== false
|
|
45
63
|
|
|
46
64
|
const handleClose = () => {
|
|
65
|
+
if (!isControlled()) setInternalOpen(false)
|
|
47
66
|
props.onClose?.()
|
|
48
67
|
}
|
|
49
68
|
|
|
69
|
+
const handleOpen = () => {
|
|
70
|
+
if (!isControlled()) setInternalOpen(true)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let dialogRef: HTMLDialogElement | undefined
|
|
74
|
+
|
|
50
75
|
onMount(() => {
|
|
51
76
|
const handleCancel = (e: Event) => {
|
|
52
|
-
// Native Escape fires 'cancel' on the dialog element
|
|
53
77
|
if (e.target !== dialogRef) return
|
|
54
78
|
if (!closeOnEscape()) {
|
|
55
79
|
e.preventDefault()
|
|
56
|
-
|
|
57
|
-
e.preventDefault()
|
|
80
|
+
return
|
|
58
81
|
}
|
|
82
|
+
e.preventDefault()
|
|
59
83
|
handleClose()
|
|
60
84
|
}
|
|
61
85
|
const handleClick = (e: MouseEvent) => {
|
|
62
|
-
// Clicking the ::backdrop means e.target IS the dialog element
|
|
63
86
|
if (closeOnClickOutside() && e.target === dialogRef) {
|
|
64
87
|
handleClose()
|
|
65
88
|
}
|
|
@@ -80,81 +103,95 @@ const RLSModal: Component<RLSModalProps> = (allProps) => {
|
|
|
80
103
|
})
|
|
81
104
|
)
|
|
82
105
|
|
|
83
|
-
let dialogRef: HTMLDialogElement | undefined
|
|
84
|
-
|
|
85
106
|
createEffect(() => {
|
|
86
107
|
if (!dialogRef) return
|
|
87
|
-
if (
|
|
88
|
-
if (!dialogRef.open
|
|
108
|
+
if (isOpen()) {
|
|
109
|
+
if (!dialogRef.open && typeof dialogRef.showModal === "function") {
|
|
110
|
+
dialogRef.showModal()
|
|
111
|
+
if (props.lockScroll !== false) {
|
|
112
|
+
document.body.style.overflow = "hidden"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
89
115
|
} else {
|
|
90
|
-
if (dialogRef.open
|
|
116
|
+
if (dialogRef.open && typeof dialogRef.close === "function") {
|
|
117
|
+
dialogRef.close()
|
|
118
|
+
if (props.lockScroll !== false) {
|
|
119
|
+
document.body.style.overflow = ""
|
|
120
|
+
}
|
|
121
|
+
}
|
|
91
122
|
}
|
|
92
123
|
})
|
|
93
124
|
|
|
125
|
+
const triggerContent = () => props.trigger ?? props.triggerSlot
|
|
126
|
+
const footerContent = () => props.footer ?? props.footerSlot
|
|
127
|
+
|
|
94
128
|
return (
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} ${resolvedClasses().content || ""} ${props.class || ""}`}
|
|
101
|
-
data-state={props.open ? "open" : "closed"}
|
|
102
|
-
data-slot="content"
|
|
103
|
-
{...rest}
|
|
104
|
-
>
|
|
105
|
-
<RLSButton
|
|
129
|
+
<div class={resolvedClasses().root} data-slot="root">
|
|
130
|
+
{triggerContent() ? (
|
|
131
|
+
<span onClick={handleOpen}>{triggerContent()}</span>
|
|
132
|
+
) : props.triggerLabel ? (
|
|
133
|
+
<button
|
|
106
134
|
type="button"
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
class={resolvedClasses().trigger}
|
|
136
|
+
data-slot="trigger"
|
|
137
|
+
onClick={handleOpen}
|
|
138
|
+
>
|
|
139
|
+
{props.triggerLabel}
|
|
140
|
+
</button>
|
|
141
|
+
) : null}
|
|
142
|
+
|
|
143
|
+
<Show when={isOpen() || !unmountOnHide()}>
|
|
144
|
+
<dialog
|
|
145
|
+
ref={(el) => (dialogRef = el)}
|
|
146
|
+
class={resolvedClasses().content}
|
|
147
|
+
aria-modal="true"
|
|
148
|
+
data-state={isOpen() ? "open" : "closed"}
|
|
149
|
+
data-slot="content"
|
|
150
|
+
{...rest}
|
|
151
|
+
>
|
|
152
|
+
<RLSButton
|
|
153
|
+
type="button"
|
|
154
|
+
variant="ghost"
|
|
155
|
+
color="neutral"
|
|
156
|
+
size="sm"
|
|
157
|
+
square
|
|
158
|
+
leadingIcon="close"
|
|
159
|
+
aria-label="Close modal"
|
|
160
|
+
data-slot="close-button"
|
|
161
|
+
class={resolvedClasses().closeButton}
|
|
162
|
+
onClick={handleClose}
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
{props.title || props.description || props.titleSlot || props.descriptionSlot ? (
|
|
166
|
+
<div class={resolvedClasses().header} data-slot="header">
|
|
167
|
+
{props.titleSlot ? (
|
|
168
|
+
props.titleSlot
|
|
169
|
+
) : props.title ? (
|
|
170
|
+
<h3 class={resolvedClasses().title} data-slot="title">
|
|
171
|
+
{props.title}
|
|
172
|
+
</h3>
|
|
173
|
+
) : null}
|
|
174
|
+
|
|
175
|
+
{props.descriptionSlot ? (
|
|
176
|
+
props.descriptionSlot
|
|
177
|
+
) : props.description ? (
|
|
178
|
+
<p class={resolvedClasses().description} data-slot="description">
|
|
179
|
+
{props.description}
|
|
180
|
+
</p>
|
|
181
|
+
) : null}
|
|
182
|
+
</div>
|
|
183
|
+
) : null}
|
|
184
|
+
|
|
185
|
+
{props.children}
|
|
186
|
+
|
|
187
|
+
{footerContent() ? (
|
|
188
|
+
<div class={resolvedClasses().footer} data-slot="footer">
|
|
189
|
+
{footerContent()}
|
|
190
|
+
</div>
|
|
191
|
+
) : null}
|
|
192
|
+
</dialog>
|
|
193
|
+
</Show>
|
|
194
|
+
</div>
|
|
158
195
|
)
|
|
159
196
|
}
|
|
160
197
|
|
|
@@ -29,11 +29,11 @@ await Promise.all(
|
|
|
29
29
|
{items.map((item, i) => {
|
|
30
30
|
const hasChildren = item.children && item.children.length > 0
|
|
31
31
|
|
|
32
|
-
const itemPath = (item
|
|
32
|
+
const itemPath = (item["href"] ?? item["to"] ?? "#") as string
|
|
33
33
|
const normalizedPath = itemPath.replace(/^\/[a-z]{2}(?:-[a-zA-Z]{2})?(?=\/|$)/, '').replace(/\/+$/, '') || '/'
|
|
34
34
|
const currentPath = Astro.url.pathname.replace(/^\/[a-z]{2}(?:-[a-zA-Z]{2})?(?=\/|$)/, '').replace(/\/+$/, '') || '/'
|
|
35
35
|
|
|
36
|
-
const isActive = item
|
|
36
|
+
const isActive = item["active"] ?? (
|
|
37
37
|
normalizedPath !== '' && normalizedPath !== '/'
|
|
38
38
|
? currentPath.startsWith(normalizedPath)
|
|
39
39
|
: currentPath === '/'
|
|
@@ -56,7 +56,7 @@ await Promise.all(
|
|
|
56
56
|
</button>
|
|
57
57
|
) : (
|
|
58
58
|
<a
|
|
59
|
-
href={typeof item
|
|
59
|
+
href={typeof item["href"] === "string" ? item["href"] : (typeof item["to"] === "string" ? item["to"] : "#")}
|
|
60
60
|
class={classes.link}
|
|
61
61
|
data-slot="link"
|
|
62
62
|
aria-current={isActive ? "page" : undefined}
|
|
@@ -81,12 +81,12 @@ await Promise.all(
|
|
|
81
81
|
{item.children!.map(child => (
|
|
82
82
|
<li>
|
|
83
83
|
<a
|
|
84
|
-
href={typeof child
|
|
84
|
+
href={typeof child["href"] === "string" ? child["href"] : (typeof child["to"] === "string" ? child["to"] : "#")}
|
|
85
85
|
class="flex items-start gap-3 rounded-sm px-3 py-2 text-sm hover:bg-accented hover:text-highlighted transition-colors"
|
|
86
86
|
>
|
|
87
|
-
{child
|
|
87
|
+
{child["icon"] && <span class={child["icon"] + " mt-0.5 size-4 shrink-0 text-muted"} />}
|
|
88
88
|
<div>
|
|
89
|
-
<div class="font-medium leading-none">{child
|
|
89
|
+
<div class="font-medium leading-none">{child["label"]}</div>
|
|
90
90
|
{child.description && (
|
|
91
91
|
<p class="mt-1 text-xs text-muted line-clamp-2">{child.description}</p>
|
|
92
92
|
)}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMemo,
|
|
3
|
+
createSignal,
|
|
4
|
+
splitProps,
|
|
5
|
+
For,
|
|
6
|
+
onCleanup,
|
|
7
|
+
type Component,
|
|
8
|
+
type JSX
|
|
9
|
+
} from "solid-js"
|
|
10
|
+
import type {
|
|
11
|
+
NavigationMenuItem,
|
|
12
|
+
NavigationMenuChildItem,
|
|
13
|
+
NavigationMenuProps
|
|
14
|
+
} from "./navigation-menu"
|
|
15
|
+
import { navigationMenuTheme } from "./navigation-menu.theme"
|
|
16
|
+
import RLSIcon from "../icon/RLSIcon"
|
|
17
|
+
|
|
18
|
+
export interface RLSNavigationMenuProps extends NavigationMenuProps {
|
|
19
|
+
children?: JSX.Element
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const RLSNavigationMenu: Component<RLSNavigationMenuProps> = (allProps) => {
|
|
23
|
+
const [props, rest] = splitProps(allProps, [
|
|
24
|
+
"items",
|
|
25
|
+
"color",
|
|
26
|
+
"orientation",
|
|
27
|
+
"theme",
|
|
28
|
+
"ui",
|
|
29
|
+
"class",
|
|
30
|
+
"children"
|
|
31
|
+
])
|
|
32
|
+
|
|
33
|
+
const [openIndex, setOpenIndex] = createSignal<number | null>(null)
|
|
34
|
+
|
|
35
|
+
const items = createMemo(() => props.items ?? [])
|
|
36
|
+
|
|
37
|
+
const orientation = () => props.orientation ?? "horizontal"
|
|
38
|
+
|
|
39
|
+
const resolvedClasses = createMemo(() =>
|
|
40
|
+
navigationMenuTheme({
|
|
41
|
+
color: props.color ?? "primary",
|
|
42
|
+
orientation: orientation(),
|
|
43
|
+
ui: props.ui,
|
|
44
|
+
class: props.class
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const currentPath = () => {
|
|
49
|
+
if (typeof window === "undefined") return ""
|
|
50
|
+
return (
|
|
51
|
+
window.location.pathname
|
|
52
|
+
.replace(/^\/[a-z]{2}(?:-[a-zA-Z]{2})?(?=\/|$)/, "")
|
|
53
|
+
.replace(/\/+$/, "") || "/"
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isItemActive = (item: NavigationMenuItem) => {
|
|
58
|
+
if (item["active"] !== undefined) return !!item["active"]
|
|
59
|
+
const rawPath = (item["href"] ?? (item["to"] as string | undefined) ?? "#") as string
|
|
60
|
+
const normalizedPath =
|
|
61
|
+
rawPath.replace(/^\/[a-z]{2}(?:-[a-zA-Z]{2})?(?=\/|$)/, "").replace(/\/+$/, "") || "/"
|
|
62
|
+
const path = currentPath()
|
|
63
|
+
if (normalizedPath !== "" && normalizedPath !== "/") return path.startsWith(normalizedPath)
|
|
64
|
+
return path === "/"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let closeTimer: ReturnType<typeof setTimeout> | undefined
|
|
68
|
+
|
|
69
|
+
const openItem = (index: number) => {
|
|
70
|
+
if (closeTimer) clearTimeout(closeTimer)
|
|
71
|
+
setOpenIndex(index)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const closeAll = () => {
|
|
75
|
+
if (closeTimer) clearTimeout(closeTimer)
|
|
76
|
+
setOpenIndex(null)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const scheduleClose = () => {
|
|
80
|
+
if (closeTimer) clearTimeout(closeTimer)
|
|
81
|
+
closeTimer = setTimeout(() => {
|
|
82
|
+
setOpenIndex(null)
|
|
83
|
+
}, 150)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
onCleanup(() => {
|
|
87
|
+
if (closeTimer) clearTimeout(closeTimer)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const itemHref = (item: NavigationMenuItem) =>
|
|
91
|
+
typeof item["href"] === "string"
|
|
92
|
+
? item["href"]
|
|
93
|
+
: typeof item["to"] === "string"
|
|
94
|
+
? item["to"]
|
|
95
|
+
: "#"
|
|
96
|
+
|
|
97
|
+
const childHref = (child: NavigationMenuChildItem) =>
|
|
98
|
+
typeof child["href"] === "string"
|
|
99
|
+
? child["href"]
|
|
100
|
+
: typeof child["to"] === "string"
|
|
101
|
+
? child["to"]
|
|
102
|
+
: "#"
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<nav
|
|
106
|
+
class={resolvedClasses().root}
|
|
107
|
+
data-slot="root"
|
|
108
|
+
data-theme={props.theme}
|
|
109
|
+
data-nav-menu
|
|
110
|
+
data-orientation={orientation()}
|
|
111
|
+
{...rest}
|
|
112
|
+
>
|
|
113
|
+
<ul class={resolvedClasses().list} data-slot="list" role="list">
|
|
114
|
+
<For each={items()}>
|
|
115
|
+
{(item, i) => {
|
|
116
|
+
const hasChildren = () => !!(item.children && item.children.length > 0)
|
|
117
|
+
const isActive = () => isItemActive(item)
|
|
118
|
+
const isOpen = () => openIndex() === i()
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<li
|
|
122
|
+
class={resolvedClasses().item}
|
|
123
|
+
data-slot="item"
|
|
124
|
+
data-nav-item
|
|
125
|
+
data-index={i()}
|
|
126
|
+
onMouseEnter={() => {
|
|
127
|
+
if (orientation() === "horizontal" && hasChildren()) openItem(i())
|
|
128
|
+
}}
|
|
129
|
+
onMouseLeave={() => {
|
|
130
|
+
if (orientation() === "horizontal" && hasChildren()) scheduleClose()
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{hasChildren() ? (
|
|
134
|
+
<button
|
|
135
|
+
type="button"
|
|
136
|
+
class={resolvedClasses().trigger}
|
|
137
|
+
data-slot="trigger"
|
|
138
|
+
data-nav-trigger
|
|
139
|
+
aria-expanded={isOpen() ? "true" : "false"}
|
|
140
|
+
aria-haspopup="true"
|
|
141
|
+
data-state={isOpen() ? "open" : "closed"}
|
|
142
|
+
onClick={(e) => {
|
|
143
|
+
e.stopPropagation()
|
|
144
|
+
if (isOpen()) {
|
|
145
|
+
closeAll()
|
|
146
|
+
} else {
|
|
147
|
+
openItem(i())
|
|
148
|
+
}
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{item.icon && <span class={`${item.icon} mr-1.5 size-4`} aria-hidden="true" />}
|
|
152
|
+
{item.label}
|
|
153
|
+
<RLSIcon
|
|
154
|
+
name="chevronDown"
|
|
155
|
+
class={`ml-1 size-3.5 transition-transform duration-200 ${isOpen() ? "rotate-180" : ""}`}
|
|
156
|
+
aria-hidden="true"
|
|
157
|
+
data-chevron
|
|
158
|
+
/>
|
|
159
|
+
</button>
|
|
160
|
+
) : (
|
|
161
|
+
<a
|
|
162
|
+
href={itemHref(item)}
|
|
163
|
+
class={resolvedClasses().link}
|
|
164
|
+
data-slot="link"
|
|
165
|
+
aria-current={isActive() ? "page" : undefined}
|
|
166
|
+
>
|
|
167
|
+
{item.icon && <span class={`${item.icon} mr-1.5 size-4`} aria-hidden="true" />}
|
|
168
|
+
{item.label}
|
|
169
|
+
</a>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
{hasChildren() ? (
|
|
173
|
+
<div
|
|
174
|
+
class={`${resolvedClasses().content} ${isOpen() ? "" : "hidden"}`}
|
|
175
|
+
data-slot="content"
|
|
176
|
+
data-nav-content
|
|
177
|
+
data-item-index={i()}
|
|
178
|
+
role="region"
|
|
179
|
+
>
|
|
180
|
+
<ul role="list" class="py-1">
|
|
181
|
+
<For each={item.children}>
|
|
182
|
+
{(child) => (
|
|
183
|
+
<li>
|
|
184
|
+
<a
|
|
185
|
+
href={childHref(child)}
|
|
186
|
+
class="flex items-start gap-3 rounded-sm px-3 py-2 text-sm hover:bg-accented hover:text-highlighted transition-colors"
|
|
187
|
+
>
|
|
188
|
+
{child["icon"] && (
|
|
189
|
+
<span
|
|
190
|
+
class={`${child["icon"]} mt-0.5 size-4 shrink-0 text-muted`}
|
|
191
|
+
aria-hidden="true"
|
|
192
|
+
/>
|
|
193
|
+
)}
|
|
194
|
+
<div>
|
|
195
|
+
<div class="font-medium leading-none">{child["label"]}</div>
|
|
196
|
+
{child["description"] && (
|
|
197
|
+
<p class="mt-1 text-xs text-muted line-clamp-2">
|
|
198
|
+
{child["description"]}
|
|
199
|
+
</p>
|
|
200
|
+
)}
|
|
201
|
+
</div>
|
|
202
|
+
</a>
|
|
203
|
+
</li>
|
|
204
|
+
)}
|
|
205
|
+
</For>
|
|
206
|
+
</ul>
|
|
207
|
+
</div>
|
|
208
|
+
) : null}
|
|
209
|
+
</li>
|
|
210
|
+
)
|
|
211
|
+
}}
|
|
212
|
+
</For>
|
|
213
|
+
</ul>
|
|
214
|
+
|
|
215
|
+
{props.children}
|
|
216
|
+
|
|
217
|
+
<div
|
|
218
|
+
class={`${resolvedClasses().viewportWrapper} hidden`}
|
|
219
|
+
data-slot="viewport-wrapper"
|
|
220
|
+
data-nav-viewport-wrapper
|
|
221
|
+
>
|
|
222
|
+
<div class={resolvedClasses().viewport} data-slot="viewport" data-nav-viewport />
|
|
223
|
+
</div>
|
|
224
|
+
</nav>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export default RLSNavigationMenu
|
|
@@ -26,7 +26,7 @@ export interface NavigationMenuItem extends Omit<LinkProps, "type" | "raw" | "cu
|
|
|
26
26
|
* Additional CSS classes to apply to the root element.
|
|
27
27
|
*/
|
|
28
28
|
class?: any
|
|
29
|
-
[key: string]:
|
|
29
|
+
[key: string]: any
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface NavigationMenuChildItem extends Omit<NavigationMenuItem, "type" | "ui"> {
|
|
@@ -56,5 +56,5 @@ export interface NavigationMenuProps {
|
|
|
56
56
|
* Additional CSS classes to apply to the root element.
|
|
57
57
|
*/
|
|
58
58
|
class?: any
|
|
59
|
-
[key: string]:
|
|
59
|
+
[key: string]: any
|
|
60
60
|
}
|