@work-rjkashyap/unified-ui 0.3.3 → 0.3.5
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/CHANGELOG.md +105 -0
- package/LICENSE +21 -0
- package/dist/components/accordion.cjs +225 -0
- package/dist/components/accordion.d.cts +157 -0
- package/dist/components/accordion.d.ts +157 -0
- package/dist/components/accordion.mjs +199 -0
- package/dist/components/alert-dialog.cjs +246 -0
- package/dist/components/alert-dialog.d.cts +61 -0
- package/dist/components/alert-dialog.d.ts +61 -0
- package/dist/components/alert-dialog.mjs +218 -0
- package/dist/components/alert.cjs +401 -0
- package/dist/components/alert.d.cts +217 -0
- package/dist/components/alert.d.ts +217 -0
- package/dist/components/alert.mjs +374 -0
- package/dist/components/aspect-ratio.cjs +45 -0
- package/dist/components/aspect-ratio.d.cts +10 -0
- package/dist/components/aspect-ratio.d.ts +10 -0
- package/dist/components/aspect-ratio.mjs +23 -0
- package/dist/components/avatar.cjs +348 -0
- package/dist/components/avatar.d.cts +198 -0
- package/dist/components/avatar.d.ts +198 -0
- package/dist/components/avatar.mjs +329 -0
- package/dist/components/badge.cjs +325 -0
- package/dist/components/badge.d.cts +259 -0
- package/dist/components/badge.d.ts +259 -0
- package/dist/components/badge.mjs +298 -0
- package/dist/components/banner.cjs +147 -0
- package/dist/components/banner.d.cts +31 -0
- package/dist/components/banner.d.ts +31 -0
- package/dist/components/banner.mjs +122 -0
- package/dist/components/breadcrumb.cjs +266 -0
- package/dist/components/breadcrumb.d.cts +159 -0
- package/dist/components/breadcrumb.d.ts +159 -0
- package/dist/components/breadcrumb.mjs +235 -0
- package/dist/components/button.cjs +254 -0
- package/dist/components/button.d.cts +126 -0
- package/dist/components/button.d.ts +126 -0
- package/dist/components/button.mjs +229 -0
- package/dist/components/calendar.cjs +511 -0
- package/dist/components/calendar.d.cts +94 -0
- package/dist/components/calendar.d.ts +94 -0
- package/dist/components/calendar.mjs +492 -0
- package/dist/components/card.cjs +234 -0
- package/dist/components/card.d.cts +190 -0
- package/dist/components/card.d.ts +190 -0
- package/dist/components/card.mjs +210 -0
- package/dist/components/carousel.cjs +234 -0
- package/dist/components/carousel.d.cts +30 -0
- package/dist/components/carousel.d.ts +30 -0
- package/dist/components/carousel.mjs +217 -0
- package/dist/components/chart.cjs +122 -0
- package/dist/components/chart.d.cts +103 -0
- package/dist/components/chart.d.ts +103 -0
- package/dist/components/chart.mjs +96 -0
- package/dist/components/checkbox.cjs +318 -0
- package/dist/components/checkbox.d.cts +182 -0
- package/dist/components/checkbox.d.ts +182 -0
- package/dist/components/checkbox.mjs +296 -0
- package/dist/components/code-highlight.cjs +335 -0
- package/dist/components/code-highlight.d.cts +18 -0
- package/dist/components/code-highlight.d.ts +18 -0
- package/dist/components/code-highlight.mjs +308 -0
- package/dist/components/code.cjs +265 -0
- package/dist/components/code.d.cts +40 -0
- package/dist/components/code.d.ts +40 -0
- package/dist/components/code.mjs +243 -0
- package/dist/components/collapsible.cjs +143 -0
- package/dist/components/collapsible.d.cts +159 -0
- package/dist/components/collapsible.d.ts +159 -0
- package/dist/components/collapsible.mjs +123 -0
- package/dist/components/color-picker.cjs +348 -0
- package/dist/components/color-picker.d.cts +35 -0
- package/dist/components/color-picker.d.ts +35 -0
- package/dist/components/color-picker.mjs +331 -0
- package/dist/components/combobox.cjs +584 -0
- package/dist/components/combobox.d.cts +183 -0
- package/dist/components/combobox.d.ts +183 -0
- package/dist/components/combobox.mjs +571 -0
- package/dist/components/command.cjs +329 -0
- package/dist/components/command.d.cts +97 -0
- package/dist/components/command.d.ts +97 -0
- package/dist/components/command.mjs +311 -0
- package/dist/components/confirm-dialog.cjs +100 -0
- package/dist/components/confirm-dialog.d.cts +25 -0
- package/dist/components/confirm-dialog.d.ts +25 -0
- package/dist/components/confirm-dialog.mjs +86 -0
- package/dist/components/context-menu.cjs +325 -0
- package/dist/components/context-menu.d.cts +259 -0
- package/dist/components/context-menu.d.ts +259 -0
- package/dist/components/context-menu.mjs +290 -0
- package/dist/components/copy-button.cjs +203 -0
- package/dist/components/copy-button.d.cts +22 -0
- package/dist/components/copy-button.d.ts +22 -0
- package/dist/components/copy-button.mjs +178 -0
- package/dist/components/data-list.cjs +140 -0
- package/dist/components/data-list.d.cts +36 -0
- package/dist/components/data-list.d.ts +36 -0
- package/dist/components/data-list.mjs +113 -0
- package/dist/components/data-table-toolbar.cjs +338 -0
- package/dist/components/data-table-toolbar.d.cts +84 -0
- package/dist/components/data-table-toolbar.d.ts +84 -0
- package/dist/components/data-table-toolbar.mjs +320 -0
- package/dist/components/data-table.cjs +1324 -0
- package/dist/components/data-table.d.cts +349 -0
- package/dist/components/data-table.d.ts +349 -0
- package/dist/components/data-table.mjs +1323 -0
- package/dist/components/date-picker.cjs +282 -0
- package/dist/components/date-picker.d.cts +97 -0
- package/dist/components/date-picker.d.ts +97 -0
- package/dist/components/date-picker.mjs +258 -0
- package/dist/components/dialog.cjs +319 -0
- package/dist/components/dialog.d.cts +74 -0
- package/dist/components/dialog.d.ts +74 -0
- package/dist/components/dialog.mjs +292 -0
- package/dist/components/drawer.cjs +262 -0
- package/dist/components/drawer.d.cts +113 -0
- package/dist/components/drawer.d.ts +113 -0
- package/dist/components/drawer.mjs +230 -0
- package/dist/components/dropdown-menu.cjs +328 -0
- package/dist/components/dropdown-menu.d.cts +95 -0
- package/dist/components/dropdown-menu.d.ts +95 -0
- package/dist/components/dropdown-menu.mjs +293 -0
- package/dist/components/empty-state.cjs +123 -0
- package/dist/components/empty-state.d.cts +15 -0
- package/dist/components/empty-state.d.ts +15 -0
- package/dist/components/empty-state.mjs +99 -0
- package/dist/components/file-upload.cjs +442 -0
- package/dist/components/file-upload.d.cts +35 -0
- package/dist/components/file-upload.d.ts +35 -0
- package/dist/components/file-upload.mjs +423 -0
- package/dist/components/form-field.cjs +191 -0
- package/dist/components/form-field.d.cts +163 -0
- package/dist/components/form-field.d.ts +163 -0
- package/dist/components/form-field.mjs +167 -0
- package/dist/components/hover-card.cjs +99 -0
- package/dist/components/hover-card.d.cts +28 -0
- package/dist/components/hover-card.d.ts +28 -0
- package/dist/components/hover-card.mjs +75 -0
- package/dist/components/image-gallery.cjs +359 -0
- package/dist/components/image-gallery.d.cts +46 -0
- package/dist/components/image-gallery.d.ts +46 -0
- package/dist/components/image-gallery.mjs +340 -0
- package/dist/components/index.cjs +719 -0
- package/dist/components/index.d.cts +84 -0
- package/dist/components/index.d.ts +84 -0
- package/dist/components/index.mjs +771 -0
- package/dist/components/infinite-scroll.cjs +95 -0
- package/dist/components/infinite-scroll.d.cts +54 -0
- package/dist/components/infinite-scroll.d.ts +54 -0
- package/dist/components/infinite-scroll.mjs +71 -0
- package/dist/components/input-group.cjs +202 -0
- package/dist/components/input-group.d.cts +22 -0
- package/dist/components/input-group.d.ts +22 -0
- package/dist/components/input-group.mjs +178 -0
- package/dist/components/input.cjs +318 -0
- package/dist/components/input.d.cts +99 -0
- package/dist/components/input.d.ts +99 -0
- package/dist/components/input.mjs +296 -0
- package/dist/components/kbd.cjs +69 -0
- package/dist/components/kbd.d.cts +25 -0
- package/dist/components/kbd.d.ts +25 -0
- package/dist/components/kbd.mjs +44 -0
- package/dist/components/label.cjs +138 -0
- package/dist/components/label.d.cts +91 -0
- package/dist/components/label.d.ts +91 -0
- package/dist/components/label.mjs +113 -0
- package/dist/components/markdown.cjs +179 -0
- package/dist/components/markdown.d.cts +41 -0
- package/dist/components/markdown.d.ts +41 -0
- package/dist/components/markdown.mjs +155 -0
- package/dist/components/menubar.cjs +365 -0
- package/dist/components/menubar.d.cts +88 -0
- package/dist/components/menubar.d.ts +88 -0
- package/dist/components/menubar.mjs +329 -0
- package/dist/components/navigation-menu.cjs +280 -0
- package/dist/components/navigation-menu.d.cts +123 -0
- package/dist/components/navigation-menu.d.ts +123 -0
- package/dist/components/navigation-menu.mjs +250 -0
- package/dist/components/number-input.cjs +419 -0
- package/dist/components/number-input.d.cts +111 -0
- package/dist/components/number-input.d.ts +111 -0
- package/dist/components/number-input.mjs +400 -0
- package/dist/components/pagination.cjs +322 -0
- package/dist/components/pagination.d.cts +119 -0
- package/dist/components/pagination.d.ts +119 -0
- package/dist/components/pagination.mjs +297 -0
- package/dist/components/pin-input.cjs +321 -0
- package/dist/components/pin-input.d.cts +112 -0
- package/dist/components/pin-input.d.ts +112 -0
- package/dist/components/pin-input.mjs +303 -0
- package/dist/components/popover.cjs +194 -0
- package/dist/components/popover.d.cts +108 -0
- package/dist/components/popover.d.ts +108 -0
- package/dist/components/popover.mjs +168 -0
- package/dist/components/progress.cjs +237 -0
- package/dist/components/progress.d.cts +137 -0
- package/dist/components/progress.d.ts +137 -0
- package/dist/components/progress.mjs +211 -0
- package/dist/components/radio.cjs +344 -0
- package/dist/components/radio.d.cts +145 -0
- package/dist/components/radio.d.ts +145 -0
- package/dist/components/radio.mjs +320 -0
- package/dist/components/resizable.cjs +121 -0
- package/dist/components/resizable.d.cts +23 -0
- package/dist/components/resizable.d.ts +23 -0
- package/dist/components/resizable.mjs +99 -0
- package/dist/components/scroll-area.cjs +168 -0
- package/dist/components/scroll-area.d.cts +131 -0
- package/dist/components/scroll-area.d.ts +131 -0
- package/dist/components/scroll-area.mjs +143 -0
- package/dist/components/search-input.cjs +261 -0
- package/dist/components/search-input.d.cts +26 -0
- package/dist/components/search-input.d.ts +26 -0
- package/dist/components/search-input.mjs +243 -0
- package/dist/components/select.cjs +320 -0
- package/dist/components/select.d.cts +55 -0
- package/dist/components/select.d.ts +55 -0
- package/dist/components/select.mjs +288 -0
- package/dist/components/separator.cjs +193 -0
- package/dist/components/separator.d.cts +92 -0
- package/dist/components/separator.d.ts +92 -0
- package/dist/components/separator.mjs +170 -0
- package/dist/components/sheet.cjs +399 -0
- package/dist/components/sheet.d.cts +219 -0
- package/dist/components/sheet.d.ts +219 -0
- package/dist/components/sheet.mjs +379 -0
- package/dist/components/sidebar.cjs +1077 -0
- package/dist/components/sidebar.d.cts +733 -0
- package/dist/components/sidebar.d.ts +733 -0
- package/dist/components/sidebar.mjs +1033 -0
- package/dist/components/skeleton.cjs +210 -0
- package/dist/components/skeleton.d.cts +202 -0
- package/dist/components/skeleton.d.ts +202 -0
- package/dist/components/skeleton.mjs +182 -0
- package/dist/components/slider.cjs +319 -0
- package/dist/components/slider.d.cts +82 -0
- package/dist/components/slider.d.ts +82 -0
- package/dist/components/slider.mjs +296 -0
- package/dist/components/sonner.cjs +119 -0
- package/dist/components/sonner.d.cts +60 -0
- package/dist/components/sonner.d.ts +60 -0
- package/dist/components/sonner.mjs +94 -0
- package/dist/components/spinner.cjs +238 -0
- package/dist/components/spinner.d.cts +101 -0
- package/dist/components/spinner.d.ts +101 -0
- package/dist/components/spinner.mjs +213 -0
- package/dist/components/stat.cjs +180 -0
- package/dist/components/stat.d.cts +21 -0
- package/dist/components/stat.d.ts +21 -0
- package/dist/components/stat.mjs +161 -0
- package/dist/components/steps.cjs +228 -0
- package/dist/components/steps.d.cts +76 -0
- package/dist/components/steps.d.ts +76 -0
- package/dist/components/steps.mjs +207 -0
- package/dist/components/switch.cjs +243 -0
- package/dist/components/switch.d.cts +90 -0
- package/dist/components/switch.d.ts +90 -0
- package/dist/components/switch.mjs +228 -0
- package/dist/components/table.cjs +381 -0
- package/dist/components/table.d.cts +181 -0
- package/dist/components/table.d.ts +181 -0
- package/dist/components/table.mjs +349 -0
- package/dist/components/tabs.cjs +326 -0
- package/dist/components/tabs.d.cts +154 -0
- package/dist/components/tabs.d.ts +154 -0
- package/dist/components/tabs.mjs +304 -0
- package/dist/components/textarea.cjs +258 -0
- package/dist/components/textarea.d.cts +112 -0
- package/dist/components/textarea.d.ts +112 -0
- package/dist/components/textarea.mjs +233 -0
- package/dist/components/theme-toggle.cjs +282 -0
- package/dist/components/theme-toggle.d.cts +58 -0
- package/dist/components/theme-toggle.d.ts +58 -0
- package/dist/components/theme-toggle.mjs +258 -0
- package/dist/components/timeline.cjs +178 -0
- package/dist/components/timeline.d.cts +41 -0
- package/dist/components/timeline.d.ts +41 -0
- package/dist/components/timeline.mjs +157 -0
- package/dist/components/toast.cjs +546 -0
- package/dist/components/toast.d.cts +169 -0
- package/dist/components/toast.d.ts +169 -0
- package/dist/components/toast.mjs +528 -0
- package/dist/components/toggle-group.cjs +204 -0
- package/dist/components/toggle-group.d.cts +215 -0
- package/dist/components/toggle-group.d.ts +215 -0
- package/dist/components/toggle-group.mjs +180 -0
- package/dist/components/toggle.cjs +155 -0
- package/dist/components/toggle.d.cts +100 -0
- package/dist/components/toggle.d.ts +100 -0
- package/dist/components/toggle.mjs +130 -0
- package/dist/components/tooltip.cjs +155 -0
- package/dist/components/tooltip.d.cts +129 -0
- package/dist/components/tooltip.d.ts +129 -0
- package/dist/components/tooltip.mjs +132 -0
- package/dist/components/tree-view.cjs +450 -0
- package/dist/components/tree-view.d.cts +67 -0
- package/dist/components/tree-view.d.ts +67 -0
- package/dist/components/tree-view.mjs +433 -0
- package/dist/components/video-player.cjs +344 -0
- package/dist/components/video-player.d.cts +34 -0
- package/dist/components/video-player.d.ts +34 -0
- package/dist/components/video-player.mjs +320 -0
- package/dist/components/virtual-list.cjs +153 -0
- package/dist/components/virtual-list.d.cts +53 -0
- package/dist/components/virtual-list.d.ts +53 -0
- package/dist/components/virtual-list.mjs +136 -0
- package/dist/components/visually-hidden.cjs +43 -0
- package/dist/components/visually-hidden.d.cts +9 -0
- package/dist/components/visually-hidden.d.ts +9 -0
- package/dist/components/visually-hidden.mjs +21 -0
- package/dist/index.cjs +1081 -1933
- package/dist/index.d.cts +99 -11
- package/dist/index.d.ts +99 -11
- package/dist/index.mjs +1138 -16
- package/dist/motion/hooks.cjs +98 -0
- package/dist/motion/hooks.d.cts +32 -0
- package/dist/motion/hooks.d.ts +32 -0
- package/dist/motion/hooks.mjs +70 -0
- package/dist/motion/index.cjs +157 -0
- package/dist/motion/index.d.cts +5 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.mjs +137 -0
- package/dist/motion/presets.cjs +609 -0
- package/dist/{motion.d.ts → motion/presets.d.cts} +1 -30
- package/dist/{motion.d.cts → motion/presets.d.ts} +1 -30
- package/dist/{chunk-PLRSH37T.mjs → motion/presets.mjs} +119 -126
- package/dist/primitives/container.cjs +88 -0
- package/dist/primitives/container.d.cts +82 -0
- package/dist/primitives/container.d.ts +82 -0
- package/dist/primitives/container.mjs +64 -0
- package/dist/primitives/divider.cjs +74 -0
- package/dist/primitives/divider.d.cts +30 -0
- package/dist/primitives/divider.d.ts +30 -0
- package/dist/primitives/divider.mjs +50 -0
- package/dist/primitives/index.cjs +54 -0
- package/dist/primitives/index.d.cts +6 -0
- package/dist/primitives/index.d.ts +6 -0
- package/dist/primitives/index.mjs +33 -0
- package/dist/primitives/stack.cjs +167 -0
- package/dist/primitives/stack.d.cts +132 -0
- package/dist/primitives/stack.d.ts +132 -0
- package/dist/primitives/stack.mjs +142 -0
- package/dist/primitives/typography.cjs +260 -0
- package/dist/primitives/typography.d.cts +157 -0
- package/dist/primitives/typography.d.ts +157 -0
- package/dist/primitives/typography.mjs +229 -0
- package/dist/theme/contract.cjs +246 -0
- package/dist/theme/contract.d.cts +76 -0
- package/dist/theme/contract.d.ts +76 -0
- package/dist/theme/contract.mjs +221 -0
- package/dist/theme/customizer-store.cjs +266 -0
- package/dist/theme/customizer-store.d.cts +76 -0
- package/dist/theme/customizer-store.d.ts +76 -0
- package/dist/theme/customizer-store.mjs +261 -0
- package/dist/theme/customizer.cjs +812 -0
- package/dist/theme/customizer.d.cts +13 -0
- package/dist/theme/customizer.d.ts +13 -0
- package/dist/theme/customizer.mjs +803 -0
- package/dist/theme/index.cjs +105 -0
- package/dist/theme/index.d.cts +13 -0
- package/dist/theme/index.d.ts +13 -0
- package/dist/theme/index.mjs +87 -0
- package/dist/theme/presets.cjs +1205 -0
- package/dist/theme/presets.d.cts +232 -0
- package/dist/theme/presets.d.ts +232 -0
- package/dist/theme/presets.mjs +1175 -0
- package/dist/theme/provider.cjs +122 -0
- package/dist/theme/provider.d.cts +57 -0
- package/dist/theme/provider.d.ts +57 -0
- package/dist/theme/provider.mjs +104 -0
- package/dist/{chunk-IVZAB7BV.mjs → tokens/colors.cjs} +212 -86
- package/dist/{z-index-Dd8IllRx.d.cts → tokens/colors.d.cts} +235 -72
- package/dist/{z-index-Dd8IllRx.d.ts → tokens/colors.d.ts} +235 -72
- package/dist/{chunk-ZBGR7MUW.cjs → tokens/colors.mjs} +165 -104
- package/dist/tokens/index.cjs +96 -0
- package/dist/tokens/index.d.cts +7 -0
- package/dist/tokens/index.d.ts +7 -0
- package/dist/tokens/index.mjs +71 -0
- package/dist/{chunk-XCKK6P46.cjs → tokens/motion.cjs} +46 -18
- package/dist/{motion-D9wQbcKL.d.cts → tokens/motion.d.cts} +1 -1
- package/dist/{motion-D9wQbcKL.d.ts → tokens/motion.d.ts} +1 -1
- package/dist/{chunk-EZ2L3XPS.mjs → tokens/motion.mjs} +16 -10
- package/dist/tokens/radius.cjs +41 -0
- package/dist/tokens/radius.d.cts +18 -0
- package/dist/tokens/radius.d.ts +18 -0
- package/dist/tokens/radius.mjs +17 -0
- package/dist/tokens/shadows.cjs +57 -0
- package/dist/tokens/shadows.d.cts +32 -0
- package/dist/tokens/shadows.d.ts +32 -0
- package/dist/tokens/shadows.mjs +32 -0
- package/dist/tokens/spacing.cjs +51 -0
- package/dist/tokens/spacing.d.cts +26 -0
- package/dist/tokens/spacing.d.ts +26 -0
- package/dist/{chunk-NMPHV6ZD.mjs → tokens/spacing.mjs} +4 -4
- package/dist/{chunk-ECIGDEAH.cjs → tokens/typography.cjs} +43 -16
- package/dist/{typography-DlvVjEdE.d.ts → tokens/typography.d.cts} +1 -1
- package/dist/{typography-DlvVjEdE.d.cts → tokens/typography.d.ts} +1 -1
- package/dist/{chunk-ITBG42M5.mjs → tokens/typography.mjs} +14 -9
- package/dist/tokens/z-index.cjs +47 -0
- package/dist/tokens/z-index.d.cts +24 -0
- package/dist/tokens/z-index.d.ts +24 -0
- package/dist/tokens/z-index.mjs +23 -0
- package/dist/utils/cn.cjs +102 -0
- package/dist/utils/cn.d.cts +84 -0
- package/dist/utils/cn.d.ts +84 -0
- package/dist/{chunk-ZT3PCXDF.mjs → utils/cn.mjs} +14 -7
- package/dist/{chunk-33QEKXRQ.cjs → utils/contrast.cjs} +68 -38
- package/dist/utils/contrast.d.cts +209 -0
- package/dist/utils/contrast.d.ts +209 -0
- package/dist/{chunk-5NZDQWRV.mjs → utils/contrast.mjs} +27 -18
- package/dist/utils/focus-ring.cjs +81 -0
- package/dist/utils/focus-ring.d.cts +80 -0
- package/dist/utils/focus-ring.d.ts +80 -0
- package/dist/utils/focus-ring.mjs +47 -0
- package/dist/utils/index.cjs +107 -0
- package/dist/utils/index.d.cts +6 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.mjs +88 -0
- package/dist/utils/types.cjs +38 -0
- package/dist/utils/types.d.cts +187 -0
- package/dist/utils/types.d.ts +187 -0
- package/dist/utils/types.mjs +13 -0
- package/package.json +191 -191
- package/dist/chunk-2JFREULQ.cjs +0 -29
- package/dist/chunk-3EHT6IOA.cjs +0 -49
- package/dist/chunk-4ON3M3OM.cjs +0 -73
- package/dist/chunk-5TP7J7T4.cjs +0 -1766
- package/dist/chunk-A2DGHQL2.cjs +0 -21808
- package/dist/chunk-EQWESXRH.mjs +0 -1735
- package/dist/chunk-F4JJFWWU.cjs +0 -604
- package/dist/chunk-FUWXGHWQ.cjs +0 -468
- package/dist/chunk-MBYCK2JJ.mjs +0 -37
- package/dist/chunk-OHEH57BV.mjs +0 -455
- package/dist/chunk-XAIUX2YS.mjs +0 -21477
- package/dist/components.cjs +0 -1247
- package/dist/components.d.cts +0 -7881
- package/dist/components.d.ts +0 -7881
- package/dist/components.mjs +0 -6
- package/dist/motion.cjs +0 -264
- package/dist/motion.mjs +0 -3
- package/dist/primitives.cjs +0 -57
- package/dist/primitives.d.cts +0 -390
- package/dist/primitives.d.ts +0 -390
- package/dist/primitives.mjs +0 -4
- package/dist/theme.cjs +0 -131
- package/dist/theme.d.cts +0 -414
- package/dist/theme.d.ts +0 -414
- package/dist/theme.mjs +0 -6
- package/dist/tokens.cjs +0 -137
- package/dist/tokens.d.cts +0 -30
- package/dist/tokens.d.ts +0 -30
- package/dist/tokens.mjs +0 -4
- package/dist/utils.cjs +0 -164
- package/dist/utils.d.cts +0 -525
- package/dist/utils.d.ts +0 -525
- package/dist/utils.mjs +0 -3
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
|
+
import { VariantProps } from 'class-variance-authority';
|
|
5
|
+
import { Label as Label$1 } from 'radix-ui';
|
|
6
|
+
|
|
7
|
+
declare const labelVariants: (props?: ({
|
|
8
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
9
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
10
|
+
type LabelSize = "sm" | "md" | "lg";
|
|
11
|
+
interface LabelProps extends Omit<React.ComponentPropsWithoutRef<typeof Label$1.Root>, "asChild">, VariantProps<typeof labelVariants> {
|
|
12
|
+
/**
|
|
13
|
+
* Size of the label text.
|
|
14
|
+
* @default "md"
|
|
15
|
+
*/
|
|
16
|
+
size?: LabelSize;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the associated field is required.
|
|
19
|
+
* When true, a red asterisk (*) is displayed after the label text.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
required?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the associated field is disabled.
|
|
25
|
+
* Applies reduced opacity and not-allowed cursor.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optional description or helper text displayed below the label.
|
|
31
|
+
* Useful for providing additional context about the field.
|
|
32
|
+
*/
|
|
33
|
+
description?: ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Additional CSS classes for the description text.
|
|
36
|
+
*/
|
|
37
|
+
descriptionClassName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Additional CSS classes for the outer wrapper element.
|
|
40
|
+
* Only applied when `description` is provided (wrapper is needed
|
|
41
|
+
* to stack label + description).
|
|
42
|
+
*/
|
|
43
|
+
wrapperClassName?: string;
|
|
44
|
+
/** Content to render inside the label. */
|
|
45
|
+
children?: ReactNode;
|
|
46
|
+
/** Additional CSS classes to merge on the label element. */
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Label — an accessible label for form controls.
|
|
51
|
+
*
|
|
52
|
+
* Built on Radix UI's Label primitive for proper accessibility semantics
|
|
53
|
+
* and the design system's token layer for consistent styling. When used
|
|
54
|
+
* with Radix form controls, clicking the label will focus the associated
|
|
55
|
+
* input automatically.
|
|
56
|
+
*
|
|
57
|
+
* Accessibility:
|
|
58
|
+
* - Renders as a native `<label>` element for proper semantics
|
|
59
|
+
* - Use `htmlFor` to associate with the corresponding input's `id`
|
|
60
|
+
* - Required indicator is decorative (`aria-hidden`) — use `aria-required`
|
|
61
|
+
* on the input itself for screen reader support
|
|
62
|
+
* - Disabled state is visual only — disable the input for functional disabling
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* // Basic usage
|
|
67
|
+
* <Label htmlFor="email">Email address</Label>
|
|
68
|
+
* <Input id="email" type="email" />
|
|
69
|
+
*
|
|
70
|
+
* // Required field
|
|
71
|
+
* <Label htmlFor="name" required>Full name</Label>
|
|
72
|
+
* <Input id="name" aria-required="true" />
|
|
73
|
+
*
|
|
74
|
+
* // With description
|
|
75
|
+
* <Label htmlFor="bio" description="Keep it under 200 characters.">
|
|
76
|
+
* Bio
|
|
77
|
+
* </Label>
|
|
78
|
+
* <Textarea id="bio" />
|
|
79
|
+
*
|
|
80
|
+
* // Small size for dense UIs
|
|
81
|
+
* <Label htmlFor="code" size="sm">Verification code</Label>
|
|
82
|
+
* <Input id="code" size="sm" />
|
|
83
|
+
*
|
|
84
|
+
* // Disabled
|
|
85
|
+
* <Label htmlFor="locked" disabled>Locked field</Label>
|
|
86
|
+
* <Input id="locked" disabled />
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare const Label: react.ForwardRefExoticComponent<LabelProps & react.RefAttributes<HTMLLabelElement>>;
|
|
90
|
+
|
|
91
|
+
export { Label, type LabelProps, type LabelSize, labelVariants };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { Label as LabelPrimitive } from "radix-ui";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
// Base styles — shared across all sizes
|
|
9
|
+
[
|
|
10
|
+
// Typography
|
|
11
|
+
"font-medium leading-none text-foreground",
|
|
12
|
+
// Prevent text selection on double-click
|
|
13
|
+
"select-none",
|
|
14
|
+
// Peer-disabled styling (when used with peer inputs)
|
|
15
|
+
"peer-disabled:opacity-50 peer-disabled:cursor-not-allowed"
|
|
16
|
+
],
|
|
17
|
+
{
|
|
18
|
+
variants: {
|
|
19
|
+
// -----------------------------------------------------------------
|
|
20
|
+
// Size Variants
|
|
21
|
+
// -----------------------------------------------------------------
|
|
22
|
+
size: {
|
|
23
|
+
/**
|
|
24
|
+
* Small — for compact forms and dense UIs.
|
|
25
|
+
* Font: 12px
|
|
26
|
+
*/
|
|
27
|
+
sm: "text-xs leading-4",
|
|
28
|
+
/**
|
|
29
|
+
* Medium — default size for most labels.
|
|
30
|
+
* Font: 14px
|
|
31
|
+
*/
|
|
32
|
+
md: "text-sm leading-5",
|
|
33
|
+
/**
|
|
34
|
+
* Large — for prominent form fields.
|
|
35
|
+
* Font: 14px with slightly more weight
|
|
36
|
+
*/
|
|
37
|
+
lg: "text-sm leading-5 font-semibold"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
size: "md"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
function RequiredIndicator({ className }) {
|
|
46
|
+
return /* @__PURE__ */ jsx("span", { className: cn("text-danger ml-0.5", className), "aria-hidden": "true", children: "*" });
|
|
47
|
+
}
|
|
48
|
+
const Label = forwardRef(function Label2({
|
|
49
|
+
size = "md",
|
|
50
|
+
required = false,
|
|
51
|
+
disabled = false,
|
|
52
|
+
description,
|
|
53
|
+
descriptionClassName,
|
|
54
|
+
wrapperClassName,
|
|
55
|
+
className,
|
|
56
|
+
children,
|
|
57
|
+
...rest
|
|
58
|
+
}, ref) {
|
|
59
|
+
const descriptionSizeClass = size === "sm" ? "text-[11px] leading-4" : "text-xs leading-4";
|
|
60
|
+
const labelElement = /* @__PURE__ */ jsxs(
|
|
61
|
+
LabelPrimitive.Root,
|
|
62
|
+
{
|
|
63
|
+
ref,
|
|
64
|
+
className: cn(
|
|
65
|
+
labelVariants({ size }),
|
|
66
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
67
|
+
!disabled && "cursor-pointer",
|
|
68
|
+
className
|
|
69
|
+
),
|
|
70
|
+
"data-ds": "",
|
|
71
|
+
"data-ds-component": "label",
|
|
72
|
+
"data-ds-size": size,
|
|
73
|
+
...disabled ? { "data-ds-disabled": "" } : {},
|
|
74
|
+
...required ? { "data-ds-required": "" } : {},
|
|
75
|
+
...rest,
|
|
76
|
+
children: [
|
|
77
|
+
children,
|
|
78
|
+
required && /* @__PURE__ */ jsx(RequiredIndicator, {})
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
if (!description) {
|
|
83
|
+
return labelElement;
|
|
84
|
+
}
|
|
85
|
+
return /* @__PURE__ */ jsxs(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
className: cn("flex flex-col gap-1", wrapperClassName),
|
|
89
|
+
"data-ds": "",
|
|
90
|
+
"data-ds-component": "label-group",
|
|
91
|
+
children: [
|
|
92
|
+
labelElement,
|
|
93
|
+
/* @__PURE__ */ jsx(
|
|
94
|
+
"span",
|
|
95
|
+
{
|
|
96
|
+
className: cn(
|
|
97
|
+
descriptionSizeClass,
|
|
98
|
+
"text-muted-foreground",
|
|
99
|
+
disabled && "opacity-50",
|
|
100
|
+
descriptionClassName
|
|
101
|
+
),
|
|
102
|
+
children: description
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
Label.displayName = "Label";
|
|
110
|
+
export {
|
|
111
|
+
Label,
|
|
112
|
+
labelVariants
|
|
113
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var markdown_exports = {};
|
|
21
|
+
__export(markdown_exports, {
|
|
22
|
+
Markdown: () => Markdown
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(markdown_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_cn = require("../utils/cn");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
function escapeHtml(str) {
|
|
29
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
30
|
+
}
|
|
31
|
+
function parseInline(text) {
|
|
32
|
+
return text.replace(
|
|
33
|
+
/!\[([^\]]*)\]\(([^)]+)\)/g,
|
|
34
|
+
'<img src="$2" alt="$1" class="rounded-md max-w-full" loading="lazy" />'
|
|
35
|
+
).replace(
|
|
36
|
+
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
37
|
+
'<a href="$2" class="text-primary underline underline-offset-2 hover:text-primary-hover" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
38
|
+
).replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/__(.+?)__/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/_(.+?)_/g, "<em>$1</em>").replace(/~~(.+?)~~/g, "<del>$1</del>").replace(
|
|
39
|
+
/`([^`]+)`/g,
|
|
40
|
+
'<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-[0.875em]">$1</code>'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function parseMarkdown(input, allowHtml) {
|
|
44
|
+
const lines = input.split("\n");
|
|
45
|
+
const output = [];
|
|
46
|
+
let inCodeBlock = false;
|
|
47
|
+
let _codeBlockLang = "";
|
|
48
|
+
let codeBuffer = [];
|
|
49
|
+
let inList = false;
|
|
50
|
+
let listType = "ul";
|
|
51
|
+
function closeList() {
|
|
52
|
+
if (inList) {
|
|
53
|
+
output.push(`</${listType}>`);
|
|
54
|
+
inList = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < lines.length; i++) {
|
|
58
|
+
const line = lines[i];
|
|
59
|
+
if (line.startsWith("```")) {
|
|
60
|
+
if (inCodeBlock) {
|
|
61
|
+
output.push(
|
|
62
|
+
`<pre class="rounded-lg bg-muted p-4 overflow-x-auto text-sm font-mono"><code>${escapeHtml(codeBuffer.join("\n"))}</code></pre>`
|
|
63
|
+
);
|
|
64
|
+
codeBuffer = [];
|
|
65
|
+
inCodeBlock = false;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
closeList();
|
|
69
|
+
inCodeBlock = true;
|
|
70
|
+
_codeBlockLang = line.slice(3).trim();
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (inCodeBlock) {
|
|
74
|
+
codeBuffer.push(line);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const safeLine = allowHtml ? line : escapeHtml(line);
|
|
78
|
+
const trimmed = safeLine.trim();
|
|
79
|
+
if (trimmed === "") {
|
|
80
|
+
closeList();
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (/^(-{3,}|\*{3,}|_{3,})$/.test(trimmed)) {
|
|
84
|
+
closeList();
|
|
85
|
+
output.push('<hr class="border-border my-4" />');
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const headingMatch = trimmed.match(/^(#{1,6})\s+(.+)$/);
|
|
89
|
+
if (headingMatch) {
|
|
90
|
+
closeList();
|
|
91
|
+
const level = headingMatch[1].length;
|
|
92
|
+
const text = parseInline(headingMatch[2]);
|
|
93
|
+
const hClasses = {
|
|
94
|
+
1: "text-2xl font-bold mt-6 mb-3",
|
|
95
|
+
2: "text-xl font-semibold mt-5 mb-2",
|
|
96
|
+
3: "text-lg font-semibold mt-4 mb-2",
|
|
97
|
+
4: "text-base font-semibold mt-3 mb-1",
|
|
98
|
+
5: "text-sm font-semibold mt-3 mb-1",
|
|
99
|
+
6: "text-sm font-medium mt-3 mb-1 text-muted-foreground"
|
|
100
|
+
};
|
|
101
|
+
output.push(
|
|
102
|
+
`<h${level} class="${hClasses[level] || ""}">${text}</h${level}>`
|
|
103
|
+
);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (trimmed.startsWith("> ") || trimmed.startsWith("> ")) {
|
|
107
|
+
closeList();
|
|
108
|
+
const quoteText = trimmed.replace(/^(>\s?|>\s?)/, "");
|
|
109
|
+
output.push(
|
|
110
|
+
`<blockquote class="border-l-2 border-border pl-4 text-muted-foreground italic my-3">${parseInline(quoteText)}</blockquote>`
|
|
111
|
+
);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const ulMatch = trimmed.match(/^[-*+]\s+(.+)$/);
|
|
115
|
+
if (ulMatch) {
|
|
116
|
+
if (!inList || listType !== "ul") {
|
|
117
|
+
closeList();
|
|
118
|
+
output.push('<ul class="list-disc pl-6 my-2 space-y-1">');
|
|
119
|
+
inList = true;
|
|
120
|
+
listType = "ul";
|
|
121
|
+
}
|
|
122
|
+
output.push(`<li>${parseInline(ulMatch[1])}</li>`);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const olMatch = trimmed.match(/^\d+\.\s+(.+)$/);
|
|
126
|
+
if (olMatch) {
|
|
127
|
+
if (!inList || listType !== "ol") {
|
|
128
|
+
closeList();
|
|
129
|
+
output.push('<ol class="list-decimal pl-6 my-2 space-y-1">');
|
|
130
|
+
inList = true;
|
|
131
|
+
listType = "ol";
|
|
132
|
+
}
|
|
133
|
+
output.push(`<li>${parseInline(olMatch[1])}</li>`);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
closeList();
|
|
137
|
+
output.push(`<p class="my-2 leading-relaxed">${parseInline(trimmed)}</p>`);
|
|
138
|
+
}
|
|
139
|
+
closeList();
|
|
140
|
+
if (inCodeBlock) {
|
|
141
|
+
output.push(
|
|
142
|
+
`<pre class="rounded-lg bg-muted p-4 overflow-x-auto text-sm font-mono"><code>${escapeHtml(codeBuffer.join("\n"))}</code></pre>`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
return output.join("\n");
|
|
146
|
+
}
|
|
147
|
+
const sizeClasses = {
|
|
148
|
+
sm: "text-sm [&_h1]:text-xl [&_h2]:text-lg [&_h3]:text-base",
|
|
149
|
+
base: "text-base",
|
|
150
|
+
lg: "text-lg [&_h1]:text-3xl [&_h2]:text-2xl [&_h3]:text-xl"
|
|
151
|
+
};
|
|
152
|
+
const Markdown = (0, import_react.forwardRef)(
|
|
153
|
+
function Markdown2({ content, size = "base", fluid = false, className, allowHtml = false }, ref) {
|
|
154
|
+
const html = (0, import_react.useMemo)(
|
|
155
|
+
() => parseMarkdown(content, allowHtml),
|
|
156
|
+
[content, allowHtml]
|
|
157
|
+
);
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
ref,
|
|
162
|
+
className: (0, import_cn.cn)(
|
|
163
|
+
"text-foreground",
|
|
164
|
+
sizeClasses[size],
|
|
165
|
+
!fluid && "max-w-prose",
|
|
166
|
+
className
|
|
167
|
+
),
|
|
168
|
+
"data-ds": "",
|
|
169
|
+
"data-ds-component": "markdown",
|
|
170
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
Markdown.displayName = "Markdown";
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
Markdown
|
|
179
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface MarkdownProps {
|
|
4
|
+
/** Markdown string to render. */
|
|
5
|
+
content: string;
|
|
6
|
+
/** Text size variant. @default "base" */
|
|
7
|
+
size?: "sm" | "base" | "lg";
|
|
8
|
+
/** Whether to remove max-width constraint. @default false */
|
|
9
|
+
fluid?: boolean;
|
|
10
|
+
/** Additional CSS classes. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Whether to allow raw HTML in the markdown. @default false */
|
|
13
|
+
allowHtml?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `Markdown` — renders a markdown string with design system prose styles.
|
|
17
|
+
*
|
|
18
|
+
* For simple markdown display use cases. For full MDX support, use
|
|
19
|
+
* Fumadocs or a dedicated MDX processor.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Markdown content={`
|
|
24
|
+
* # Hello World
|
|
25
|
+
*
|
|
26
|
+
* Some **bold** and *italic* text with \`inline code\`.
|
|
27
|
+
*
|
|
28
|
+
* - Item one
|
|
29
|
+
* - Item two
|
|
30
|
+
*
|
|
31
|
+
* > A blockquote
|
|
32
|
+
*
|
|
33
|
+
* \`\`\`tsx
|
|
34
|
+
* const x = 42;
|
|
35
|
+
* \`\`\`
|
|
36
|
+
* `} />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare const Markdown: react.ForwardRefExoticComponent<MarkdownProps & react.RefAttributes<HTMLDivElement>>;
|
|
40
|
+
|
|
41
|
+
export { Markdown, type MarkdownProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface MarkdownProps {
|
|
4
|
+
/** Markdown string to render. */
|
|
5
|
+
content: string;
|
|
6
|
+
/** Text size variant. @default "base" */
|
|
7
|
+
size?: "sm" | "base" | "lg";
|
|
8
|
+
/** Whether to remove max-width constraint. @default false */
|
|
9
|
+
fluid?: boolean;
|
|
10
|
+
/** Additional CSS classes. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Whether to allow raw HTML in the markdown. @default false */
|
|
13
|
+
allowHtml?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `Markdown` — renders a markdown string with design system prose styles.
|
|
17
|
+
*
|
|
18
|
+
* For simple markdown display use cases. For full MDX support, use
|
|
19
|
+
* Fumadocs or a dedicated MDX processor.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Markdown content={`
|
|
24
|
+
* # Hello World
|
|
25
|
+
*
|
|
26
|
+
* Some **bold** and *italic* text with \`inline code\`.
|
|
27
|
+
*
|
|
28
|
+
* - Item one
|
|
29
|
+
* - Item two
|
|
30
|
+
*
|
|
31
|
+
* > A blockquote
|
|
32
|
+
*
|
|
33
|
+
* \`\`\`tsx
|
|
34
|
+
* const x = 42;
|
|
35
|
+
* \`\`\`
|
|
36
|
+
* `} />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare const Markdown: react.ForwardRefExoticComponent<MarkdownProps & react.RefAttributes<HTMLDivElement>>;
|
|
40
|
+
|
|
41
|
+
export { Markdown, type MarkdownProps };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
import { forwardRef, useMemo } from "react";
|
|
5
|
+
function escapeHtml(str) {
|
|
6
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7
|
+
}
|
|
8
|
+
function parseInline(text) {
|
|
9
|
+
return text.replace(
|
|
10
|
+
/!\[([^\]]*)\]\(([^)]+)\)/g,
|
|
11
|
+
'<img src="$2" alt="$1" class="rounded-md max-w-full" loading="lazy" />'
|
|
12
|
+
).replace(
|
|
13
|
+
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
14
|
+
'<a href="$2" class="text-primary underline underline-offset-2 hover:text-primary-hover" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
15
|
+
).replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/__(.+?)__/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/_(.+?)_/g, "<em>$1</em>").replace(/~~(.+?)~~/g, "<del>$1</del>").replace(
|
|
16
|
+
/`([^`]+)`/g,
|
|
17
|
+
'<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-[0.875em]">$1</code>'
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
function parseMarkdown(input, allowHtml) {
|
|
21
|
+
const lines = input.split("\n");
|
|
22
|
+
const output = [];
|
|
23
|
+
let inCodeBlock = false;
|
|
24
|
+
let _codeBlockLang = "";
|
|
25
|
+
let codeBuffer = [];
|
|
26
|
+
let inList = false;
|
|
27
|
+
let listType = "ul";
|
|
28
|
+
function closeList() {
|
|
29
|
+
if (inList) {
|
|
30
|
+
output.push(`</${listType}>`);
|
|
31
|
+
inList = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (let i = 0; i < lines.length; i++) {
|
|
35
|
+
const line = lines[i];
|
|
36
|
+
if (line.startsWith("```")) {
|
|
37
|
+
if (inCodeBlock) {
|
|
38
|
+
output.push(
|
|
39
|
+
`<pre class="rounded-lg bg-muted p-4 overflow-x-auto text-sm font-mono"><code>${escapeHtml(codeBuffer.join("\n"))}</code></pre>`
|
|
40
|
+
);
|
|
41
|
+
codeBuffer = [];
|
|
42
|
+
inCodeBlock = false;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
closeList();
|
|
46
|
+
inCodeBlock = true;
|
|
47
|
+
_codeBlockLang = line.slice(3).trim();
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (inCodeBlock) {
|
|
51
|
+
codeBuffer.push(line);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const safeLine = allowHtml ? line : escapeHtml(line);
|
|
55
|
+
const trimmed = safeLine.trim();
|
|
56
|
+
if (trimmed === "") {
|
|
57
|
+
closeList();
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (/^(-{3,}|\*{3,}|_{3,})$/.test(trimmed)) {
|
|
61
|
+
closeList();
|
|
62
|
+
output.push('<hr class="border-border my-4" />');
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const headingMatch = trimmed.match(/^(#{1,6})\s+(.+)$/);
|
|
66
|
+
if (headingMatch) {
|
|
67
|
+
closeList();
|
|
68
|
+
const level = headingMatch[1].length;
|
|
69
|
+
const text = parseInline(headingMatch[2]);
|
|
70
|
+
const hClasses = {
|
|
71
|
+
1: "text-2xl font-bold mt-6 mb-3",
|
|
72
|
+
2: "text-xl font-semibold mt-5 mb-2",
|
|
73
|
+
3: "text-lg font-semibold mt-4 mb-2",
|
|
74
|
+
4: "text-base font-semibold mt-3 mb-1",
|
|
75
|
+
5: "text-sm font-semibold mt-3 mb-1",
|
|
76
|
+
6: "text-sm font-medium mt-3 mb-1 text-muted-foreground"
|
|
77
|
+
};
|
|
78
|
+
output.push(
|
|
79
|
+
`<h${level} class="${hClasses[level] || ""}">${text}</h${level}>`
|
|
80
|
+
);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (trimmed.startsWith("> ") || trimmed.startsWith("> ")) {
|
|
84
|
+
closeList();
|
|
85
|
+
const quoteText = trimmed.replace(/^(>\s?|>\s?)/, "");
|
|
86
|
+
output.push(
|
|
87
|
+
`<blockquote class="border-l-2 border-border pl-4 text-muted-foreground italic my-3">${parseInline(quoteText)}</blockquote>`
|
|
88
|
+
);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const ulMatch = trimmed.match(/^[-*+]\s+(.+)$/);
|
|
92
|
+
if (ulMatch) {
|
|
93
|
+
if (!inList || listType !== "ul") {
|
|
94
|
+
closeList();
|
|
95
|
+
output.push('<ul class="list-disc pl-6 my-2 space-y-1">');
|
|
96
|
+
inList = true;
|
|
97
|
+
listType = "ul";
|
|
98
|
+
}
|
|
99
|
+
output.push(`<li>${parseInline(ulMatch[1])}</li>`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const olMatch = trimmed.match(/^\d+\.\s+(.+)$/);
|
|
103
|
+
if (olMatch) {
|
|
104
|
+
if (!inList || listType !== "ol") {
|
|
105
|
+
closeList();
|
|
106
|
+
output.push('<ol class="list-decimal pl-6 my-2 space-y-1">');
|
|
107
|
+
inList = true;
|
|
108
|
+
listType = "ol";
|
|
109
|
+
}
|
|
110
|
+
output.push(`<li>${parseInline(olMatch[1])}</li>`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
closeList();
|
|
114
|
+
output.push(`<p class="my-2 leading-relaxed">${parseInline(trimmed)}</p>`);
|
|
115
|
+
}
|
|
116
|
+
closeList();
|
|
117
|
+
if (inCodeBlock) {
|
|
118
|
+
output.push(
|
|
119
|
+
`<pre class="rounded-lg bg-muted p-4 overflow-x-auto text-sm font-mono"><code>${escapeHtml(codeBuffer.join("\n"))}</code></pre>`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return output.join("\n");
|
|
123
|
+
}
|
|
124
|
+
const sizeClasses = {
|
|
125
|
+
sm: "text-sm [&_h1]:text-xl [&_h2]:text-lg [&_h3]:text-base",
|
|
126
|
+
base: "text-base",
|
|
127
|
+
lg: "text-lg [&_h1]:text-3xl [&_h2]:text-2xl [&_h3]:text-xl"
|
|
128
|
+
};
|
|
129
|
+
const Markdown = forwardRef(
|
|
130
|
+
function Markdown2({ content, size = "base", fluid = false, className, allowHtml = false }, ref) {
|
|
131
|
+
const html = useMemo(
|
|
132
|
+
() => parseMarkdown(content, allowHtml),
|
|
133
|
+
[content, allowHtml]
|
|
134
|
+
);
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
136
|
+
"div",
|
|
137
|
+
{
|
|
138
|
+
ref,
|
|
139
|
+
className: cn(
|
|
140
|
+
"text-foreground",
|
|
141
|
+
sizeClasses[size],
|
|
142
|
+
!fluid && "max-w-prose",
|
|
143
|
+
className
|
|
144
|
+
),
|
|
145
|
+
"data-ds": "",
|
|
146
|
+
"data-ds-component": "markdown",
|
|
147
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
Markdown.displayName = "Markdown";
|
|
153
|
+
export {
|
|
154
|
+
Markdown
|
|
155
|
+
};
|