@stridge/noctis 1.0.0-beta.0
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 +60 -0
- package/dist/_virtual/_rolldown/runtime.js +27 -0
- package/dist/components/accordion/accordion.context.js +15 -0
- package/dist/components/accordion/accordion.d.ts +136 -0
- package/dist/components/accordion/accordion.js +132 -0
- package/dist/components/accordion/accordion.props.d.ts +45 -0
- package/dist/components/accordion/accordion.props.js +53 -0
- package/dist/components/accordion/accordion.slots.d.ts +24 -0
- package/dist/components/accordion/accordion.slots.js +39 -0
- package/dist/components/accordion/accordion.types.d.ts +11 -0
- package/dist/components/accordion/index.d.ts +3 -0
- package/dist/components/alert-dialog/alert-dialog.context.js +16 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +324 -0
- package/dist/components/alert-dialog/alert-dialog.js +279 -0
- package/dist/components/alert-dialog/alert-dialog.props.d.ts +85 -0
- package/dist/components/alert-dialog/alert-dialog.props.js +84 -0
- package/dist/components/alert-dialog/alert-dialog.slots.d.ts +29 -0
- package/dist/components/alert-dialog/alert-dialog.slots.js +52 -0
- package/dist/components/alert-dialog/alert-dialog.types.d.ts +22 -0
- package/dist/components/alert-dialog/index.d.ts +3 -0
- package/dist/components/autocomplete/autocomplete.context.d.ts +5 -0
- package/dist/components/autocomplete/autocomplete.context.js +13 -0
- package/dist/components/autocomplete/autocomplete.d.ts +364 -0
- package/dist/components/autocomplete/autocomplete.js +373 -0
- package/dist/components/autocomplete/autocomplete.props.d.ts +83 -0
- package/dist/components/autocomplete/autocomplete.props.js +63 -0
- package/dist/components/autocomplete/autocomplete.slots.d.ts +32 -0
- package/dist/components/autocomplete/autocomplete.slots.js +61 -0
- package/dist/components/autocomplete/index.d.ts +3 -0
- package/dist/components/avatar/avatar.context.js +21 -0
- package/dist/components/avatar/avatar.d.ts +235 -0
- package/dist/components/avatar/avatar.js +208 -0
- package/dist/components/avatar/avatar.props.d.ts +86 -0
- package/dist/components/avatar/avatar.props.js +78 -0
- package/dist/components/avatar/avatar.slots.d.ts +35 -0
- package/dist/components/avatar/avatar.slots.js +49 -0
- package/dist/components/avatar/avatar.types.d.ts +28 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/button/button.d.ts +91 -0
- package/dist/components/button/button.js +82 -0
- package/dist/components/button/button.props.d.ts +48 -0
- package/dist/components/button/button.props.js +25 -0
- package/dist/components/button/button.slots.d.ts +30 -0
- package/dist/components/button/button.slots.js +40 -0
- package/dist/components/button/button.types.d.ts +12 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button-group/button-group.context.js +15 -0
- package/dist/components/button-group/button-group.d.ts +60 -0
- package/dist/components/button-group/button-group.js +50 -0
- package/dist/components/button-group/button-group.props.d.ts +22 -0
- package/dist/components/button-group/button-group.props.js +33 -0
- package/dist/components/button-group/button-group.slots.d.ts +12 -0
- package/dist/components/button-group/button-group.slots.js +18 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/checkbox/checkbox-group.d.ts +46 -0
- package/dist/components/checkbox/checkbox-group.js +31 -0
- package/dist/components/checkbox/checkbox.context.js +15 -0
- package/dist/components/checkbox/checkbox.d.ts +130 -0
- package/dist/components/checkbox/checkbox.js +117 -0
- package/dist/components/checkbox/checkbox.props.d.ts +84 -0
- package/dist/components/checkbox/checkbox.props.js +49 -0
- package/dist/components/checkbox/checkbox.slots.d.ts +27 -0
- package/dist/components/checkbox/checkbox.slots.js +40 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/code-block/brand-logo.d.ts +37 -0
- package/dist/components/code-block/brand-logo.js +212 -0
- package/dist/components/code-block/code-block.context.js +13 -0
- package/dist/components/code-block/code-block.d.ts +190 -0
- package/dist/components/code-block/code-block.js +267 -0
- package/dist/components/code-block/code-block.props.d.ts +42 -0
- package/dist/components/code-block/code-block.props.js +51 -0
- package/dist/components/code-block/code-block.slots.d.ts +16 -0
- package/dist/components/code-block/code-block.slots.js +31 -0
- package/dist/components/code-block/index.d.ts +3 -0
- package/dist/components/code-block/language-label.js +43 -0
- package/dist/components/collapsible/collapsible.context.js +18 -0
- package/dist/components/collapsible/collapsible.d.ts +167 -0
- package/dist/components/collapsible/collapsible.js +182 -0
- package/dist/components/collapsible/collapsible.props.d.ts +33 -0
- package/dist/components/collapsible/collapsible.props.js +44 -0
- package/dist/components/collapsible/collapsible.slots.d.ts +25 -0
- package/dist/components/collapsible/collapsible.slots.js +40 -0
- package/dist/components/collapsible/collapsible.types.d.ts +23 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/color-picker/area.d.ts +11 -0
- package/dist/components/color-picker/area.js +148 -0
- package/dist/components/color-picker/color-picker.d.ts +110 -0
- package/dist/components/color-picker/color-picker.js +149 -0
- package/dist/components/color-picker/color-picker.props.d.ts +69 -0
- package/dist/components/color-picker/color-picker.props.js +74 -0
- package/dist/components/color-picker/color-picker.slots.js +21 -0
- package/dist/components/color-picker/color.d.ts +18 -0
- package/dist/components/color-picker/color.js +224 -0
- package/dist/components/color-picker/context.d.ts +25 -0
- package/dist/components/color-picker/context.js +23 -0
- package/dist/components/color-picker/eyedropper.d.ts +14 -0
- package/dist/components/color-picker/eyedropper.js +50 -0
- package/dist/components/color-picker/format-tabs.d.ts +11 -0
- package/dist/components/color-picker/format-tabs.js +35 -0
- package/dist/components/color-picker/index.d.ts +3 -0
- package/dist/components/color-picker/inputs.d.ts +16 -0
- package/dist/components/color-picker/inputs.js +61 -0
- package/dist/components/color-picker/sliders.d.ts +17 -0
- package/dist/components/color-picker/sliders.js +94 -0
- package/dist/components/color-picker/store.js +48 -0
- package/dist/components/color-picker/swatch.d.ts +15 -0
- package/dist/components/color-picker/swatch.js +25 -0
- package/dist/components/color-swatch/color-swatch-picker.d.ts +87 -0
- package/dist/components/color-swatch/color-swatch-picker.js +73 -0
- package/dist/components/color-swatch/color-swatch.context.js +8 -0
- package/dist/components/color-swatch/color-swatch.d.ts +55 -0
- package/dist/components/color-swatch/color-swatch.js +48 -0
- package/dist/components/color-swatch/color-swatch.props.d.ts +54 -0
- package/dist/components/color-swatch/color-swatch.props.js +32 -0
- package/dist/components/color-swatch/color-swatch.slots.js +13 -0
- package/dist/components/color-swatch/index.d.ts +2 -0
- package/dist/components/combobox/combobox.context.js +13 -0
- package/dist/components/combobox/combobox.d.ts +328 -0
- package/dist/components/combobox/combobox.js +315 -0
- package/dist/components/combobox/combobox.props.d.ts +85 -0
- package/dist/components/combobox/combobox.props.js +79 -0
- package/dist/components/combobox/combobox.slots.d.ts +28 -0
- package/dist/components/combobox/combobox.slots.js +63 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/context-menu/context-menu.d.ts +254 -0
- package/dist/components/context-menu/context-menu.js +150 -0
- package/dist/components/context-menu/context-menu.props.d.ts +22 -0
- package/dist/components/context-menu/context-menu.props.js +32 -0
- package/dist/components/context-menu/context-menu.slots.d.ts +24 -0
- package/dist/components/context-menu/context-menu.slots.js +42 -0
- package/dist/components/context-menu/index.d.ts +2 -0
- package/dist/components/copy-button/copy-button.d.ts +56 -0
- package/dist/components/copy-button/copy-button.js +88 -0
- package/dist/components/copy-button/copy-button.props.d.ts +27 -0
- package/dist/components/copy-button/copy-button.props.js +51 -0
- package/dist/components/copy-button/copy-button.slots.d.ts +20 -0
- package/dist/components/copy-button/copy-button.slots.js +36 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/dialog/dialog.context.js +15 -0
- package/dist/components/dialog/dialog.d.ts +299 -0
- package/dist/components/dialog/dialog.js +263 -0
- package/dist/components/dialog/dialog.props.d.ts +71 -0
- package/dist/components/dialog/dialog.props.js +75 -0
- package/dist/components/dialog/dialog.slots.d.ts +26 -0
- package/dist/components/dialog/dialog.slots.js +46 -0
- package/dist/components/dialog/dialog.types.d.ts +16 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/field/field.d.ts +221 -0
- package/dist/components/field/field.js +192 -0
- package/dist/components/field/field.props.d.ts +66 -0
- package/dist/components/field/field.props.js +65 -0
- package/dist/components/field/field.slots.d.ts +35 -0
- package/dist/components/field/field.slots.js +54 -0
- package/dist/components/field/field.types.d.ts +5 -0
- package/dist/components/field/index.d.ts +4 -0
- package/dist/components/inline-code/index.d.ts +1 -0
- package/dist/components/inline-code/inline-code.d.ts +46 -0
- package/dist/components/inline-code/inline-code.js +36 -0
- package/dist/components/inline-code/inline-code.props.d.ts +17 -0
- package/dist/components/inline-code/inline-code.props.js +27 -0
- package/dist/components/inline-code/inline-code.slots.js +8 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/input.context.js +13 -0
- package/dist/components/input/input.d.ts +161 -0
- package/dist/components/input/input.js +117 -0
- package/dist/components/input/input.props.d.ts +51 -0
- package/dist/components/input/input.props.js +50 -0
- package/dist/components/input/input.slots.d.ts +35 -0
- package/dist/components/input/input.slots.js +46 -0
- package/dist/components/input/input.types.d.ts +12 -0
- package/dist/components/kbd/glyphs.js +45 -0
- package/dist/components/kbd/index.d.ts +1 -0
- package/dist/components/kbd/kbd.d.ts +61 -0
- package/dist/components/kbd/kbd.js +233 -0
- package/dist/components/kbd/kbd.props.d.ts +30 -0
- package/dist/components/kbd/kbd.props.js +39 -0
- package/dist/components/kbd/kbd.slots.js +14 -0
- package/dist/components/kbd/use-apple-platform.js +25 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/menu.d.ts +355 -0
- package/dist/components/menu/menu.js +263 -0
- package/dist/components/menu/menu.props.d.ts +92 -0
- package/dist/components/menu/menu.props.js +97 -0
- package/dist/components/menu/menu.slots.d.ts +32 -0
- package/dist/components/menu/menu.slots.js +60 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/menubar.context.js +13 -0
- package/dist/components/menubar/menubar.d.ts +162 -0
- package/dist/components/menubar/menubar.js +122 -0
- package/dist/components/menubar/menubar.props.d.ts +41 -0
- package/dist/components/menubar/menubar.props.js +45 -0
- package/dist/components/menubar/menubar.slots.d.ts +26 -0
- package/dist/components/menubar/menubar.slots.js +40 -0
- package/dist/components/meter/index.d.ts +2 -0
- package/dist/components/meter/meter.context.d.ts +9 -0
- package/dist/components/meter/meter.context.js +13 -0
- package/dist/components/meter/meter.d.ts +163 -0
- package/dist/components/meter/meter.js +121 -0
- package/dist/components/meter/meter.props.d.ts +50 -0
- package/dist/components/meter/meter.props.js +33 -0
- package/dist/components/meter/meter.slots.d.ts +18 -0
- package/dist/components/meter/meter.slots.js +31 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +328 -0
- package/dist/components/navigation-menu/navigation-menu.js +274 -0
- package/dist/components/navigation-menu/navigation-menu.props.d.ts +98 -0
- package/dist/components/navigation-menu/navigation-menu.props.js +90 -0
- package/dist/components/navigation-menu/navigation-menu.slots.d.ts +34 -0
- package/dist/components/navigation-menu/navigation-menu.slots.js +60 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/number-field.context.d.ts +13 -0
- package/dist/components/number-field/number-field.context.js +13 -0
- package/dist/components/number-field/number-field.d.ts +197 -0
- package/dist/components/number-field/number-field.js +187 -0
- package/dist/components/number-field/number-field.props.d.ts +66 -0
- package/dist/components/number-field/number-field.props.js +50 -0
- package/dist/components/number-field/number-field.slots.d.ts +31 -0
- package/dist/components/number-field/number-field.slots.js +48 -0
- package/dist/components/otp-field/index.d.ts +3 -0
- package/dist/components/otp-field/otp-field.context.js +13 -0
- package/dist/components/otp-field/otp-field.d.ts +99 -0
- package/dist/components/otp-field/otp-field.js +76 -0
- package/dist/components/otp-field/otp-field.props.d.ts +48 -0
- package/dist/components/otp-field/otp-field.props.js +43 -0
- package/dist/components/otp-field/otp-field.slots.d.ts +28 -0
- package/dist/components/otp-field/otp-field.slots.js +39 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/popover.d.ts +192 -0
- package/dist/components/popover/popover.js +152 -0
- package/dist/components/popover/popover.props.d.ts +34 -0
- package/dist/components/popover/popover.props.js +44 -0
- package/dist/components/popover/popover.slots.d.ts +22 -0
- package/dist/components/popover/popover.slots.js +42 -0
- package/dist/components/preview-card/index.d.ts +2 -0
- package/dist/components/preview-card/preview-card.d.ts +182 -0
- package/dist/components/preview-card/preview-card.js +146 -0
- package/dist/components/preview-card/preview-card.props.d.ts +37 -0
- package/dist/components/preview-card/preview-card.props.js +48 -0
- package/dist/components/preview-card/preview-card.slots.d.ts +22 -0
- package/dist/components/preview-card/preview-card.slots.js +39 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/progress/progress.context.d.ts +9 -0
- package/dist/components/progress/progress.context.js +13 -0
- package/dist/components/progress/progress.d.ts +139 -0
- package/dist/components/progress/progress.js +92 -0
- package/dist/components/progress/progress.props.d.ts +56 -0
- package/dist/components/progress/progress.props.js +38 -0
- package/dist/components/progress/progress.slots.d.ts +24 -0
- package/dist/components/progress/progress.slots.js +37 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio.context.js +5 -0
- package/dist/components/radio/radio.d.ts +205 -0
- package/dist/components/radio/radio.js +168 -0
- package/dist/components/radio/radio.props.d.ts +106 -0
- package/dist/components/radio/radio.props.js +65 -0
- package/dist/components/radio/radio.slots.d.ts +29 -0
- package/dist/components/radio/radio.slots.js +44 -0
- package/dist/components/rail/index.d.ts +3 -0
- package/dist/components/rail/rail.context.d.ts +17 -0
- package/dist/components/rail/rail.context.js +23 -0
- package/dist/components/rail/rail.d.ts +232 -0
- package/dist/components/rail/rail.js +254 -0
- package/dist/components/rail/rail.props.d.ts +98 -0
- package/dist/components/rail/rail.props.js +64 -0
- package/dist/components/rail/rail.slots.d.ts +20 -0
- package/dist/components/rail/rail.slots.js +40 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/scroll-area.context.js +15 -0
- package/dist/components/scroll-area/scroll-area.d.ts +217 -0
- package/dist/components/scroll-area/scroll-area.js +153 -0
- package/dist/components/scroll-area/scroll-area.props.d.ts +73 -0
- package/dist/components/scroll-area/scroll-area.props.js +64 -0
- package/dist/components/scroll-area/scroll-area.slots.d.ts +40 -0
- package/dist/components/scroll-area/scroll-area.slots.js +54 -0
- package/dist/components/scroll-area/scroll-area.types.d.ts +24 -0
- package/dist/components/search-dialog/index.d.ts +3 -0
- package/dist/components/search-dialog/parts/input.d.ts +24 -0
- package/dist/components/search-dialog/parts/input.js +53 -0
- package/dist/components/search-dialog/parts/messages.d.ts +80 -0
- package/dist/components/search-dialog/parts/messages.js +75 -0
- package/dist/components/search-dialog/parts/results.d.ts +43 -0
- package/dist/components/search-dialog/parts/results.js +63 -0
- package/dist/components/search-dialog/parts/root.d.ts +54 -0
- package/dist/components/search-dialog/parts/root.js +99 -0
- package/dist/components/search-dialog/search-dialog.context.d.ts +15 -0
- package/dist/components/search-dialog/search-dialog.context.js +20 -0
- package/dist/components/search-dialog/search-dialog.d.ts +84 -0
- package/dist/components/search-dialog/search-dialog.js +43 -0
- package/dist/components/search-dialog/search-dialog.props.d.ts +45 -0
- package/dist/components/search-dialog/search-dialog.props.js +49 -0
- package/dist/components/search-dialog/search-dialog.slots.d.ts +16 -0
- package/dist/components/search-dialog/search-dialog.slots.js +32 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/select.context.js +17 -0
- package/dist/components/select/select.d.ts +356 -0
- package/dist/components/select/select.js +314 -0
- package/dist/components/select/select.props.d.ts +110 -0
- package/dist/components/select/select.props.js +103 -0
- package/dist/components/select/select.slots.d.ts +38 -0
- package/dist/components/select/select.slots.js +67 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/separator.d.ts +69 -0
- package/dist/components/separator/separator.js +44 -0
- package/dist/components/separator/separator.props.d.ts +30 -0
- package/dist/components/separator/separator.props.js +30 -0
- package/dist/components/separator/separator.slots.d.ts +22 -0
- package/dist/components/separator/separator.slots.js +21 -0
- package/dist/components/separator/separator.types.d.ts +5 -0
- package/dist/components/sheet/index.d.ts +3 -0
- package/dist/components/sheet/sheet-stack.d.ts +106 -0
- package/dist/components/sheet/sheet-stack.js +146 -0
- package/dist/components/sheet/sheet.d.ts +279 -0
- package/dist/components/sheet/sheet.js +264 -0
- package/dist/components/sheet/sheet.props.d.ts +74 -0
- package/dist/components/sheet/sheet.props.js +77 -0
- package/dist/components/sheet/sheet.slots.js +22 -0
- package/dist/components/sheet/sheet.types.d.ts +12 -0
- package/dist/components/slider/index.d.ts +3 -0
- package/dist/components/slider/slider.context.d.ts +5 -0
- package/dist/components/slider/slider.context.js +29 -0
- package/dist/components/slider/slider.d.ts +230 -0
- package/dist/components/slider/slider.js +274 -0
- package/dist/components/slider/slider.props.d.ts +72 -0
- package/dist/components/slider/slider.props.js +59 -0
- package/dist/components/slider/slider.slots.d.ts +30 -0
- package/dist/components/slider/slider.slots.js +50 -0
- package/dist/components/surface/index.d.ts +1 -0
- package/dist/components/surface/surface.d.ts +84 -0
- package/dist/components/surface/surface.js +48 -0
- package/dist/components/surface/surface.props.d.ts +35 -0
- package/dist/components/surface/surface.props.js +26 -0
- package/dist/components/surface/surface.slots.js +9 -0
- package/dist/components/surface/surface.types.d.ts +14 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/switch.context.js +14 -0
- package/dist/components/switch/switch.d.ts +110 -0
- package/dist/components/switch/switch.js +92 -0
- package/dist/components/switch/switch.props.d.ts +68 -0
- package/dist/components/switch/switch.props.js +41 -0
- package/dist/components/switch/switch.slots.d.ts +23 -0
- package/dist/components/switch/switch.slots.js +35 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/table.d.ts +104 -0
- package/dist/components/table/table.js +92 -0
- package/dist/components/table/table.props.d.ts +38 -0
- package/dist/components/table/table.props.js +49 -0
- package/dist/components/table/table.slots.js +17 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.context.d.ts +9 -0
- package/dist/components/tabs/tabs.context.js +13 -0
- package/dist/components/tabs/tabs.d.ts +139 -0
- package/dist/components/tabs/tabs.js +118 -0
- package/dist/components/tabs/tabs.props.d.ts +59 -0
- package/dist/components/tabs/tabs.props.js +39 -0
- package/dist/components/tabs/tabs.slots.d.ts +20 -0
- package/dist/components/tabs/tabs.slots.js +33 -0
- package/dist/components/textarea/index.d.ts +3 -0
- package/dist/components/textarea/textarea.context.js +13 -0
- package/dist/components/textarea/textarea.d.ts +142 -0
- package/dist/components/textarea/textarea.js +129 -0
- package/dist/components/textarea/textarea.props.d.ts +44 -0
- package/dist/components/textarea/textarea.props.js +32 -0
- package/dist/components/textarea/textarea.slots.d.ts +23 -0
- package/dist/components/textarea/textarea.slots.js +33 -0
- package/dist/components/textarea/textarea.types.d.ts +5 -0
- package/dist/components/toast/index.d.ts +4 -0
- package/dist/components/toast/toast.d.ts +241 -0
- package/dist/components/toast/toast.js +193 -0
- package/dist/components/toast/toast.manager.d.ts +76 -0
- package/dist/components/toast/toast.manager.js +71 -0
- package/dist/components/toast/toast.props.d.ts +66 -0
- package/dist/components/toast/toast.props.js +74 -0
- package/dist/components/toast/toast.slots.d.ts +30 -0
- package/dist/components/toast/toast.slots.js +49 -0
- package/dist/components/toast/toast.types.d.ts +19 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/toggle.context.d.ts +11 -0
- package/dist/components/toggle/toggle.context.js +14 -0
- package/dist/components/toggle/toggle.d.ts +136 -0
- package/dist/components/toggle/toggle.js +101 -0
- package/dist/components/toggle/toggle.props.d.ts +51 -0
- package/dist/components/toggle/toggle.props.js +29 -0
- package/dist/components/toggle/toggle.slots.d.ts +26 -0
- package/dist/components/toggle/toggle.slots.js +36 -0
- package/dist/components/toolbar/index.d.ts +3 -0
- package/dist/components/toolbar/toolbar.context.js +23 -0
- package/dist/components/toolbar/toolbar.d.ts +218 -0
- package/dist/components/toolbar/toolbar.js +197 -0
- package/dist/components/toolbar/toolbar.props.d.ts +54 -0
- package/dist/components/toolbar/toolbar.props.js +55 -0
- package/dist/components/toolbar/toolbar.slots.d.ts +24 -0
- package/dist/components/toolbar/toolbar.slots.js +37 -0
- package/dist/components/toolbar/toolbar.types.d.ts +15 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/tooltip.d.ts +170 -0
- package/dist/components/tooltip/tooltip.js +143 -0
- package/dist/components/tooltip/tooltip.props.d.ts +36 -0
- package/dist/components/tooltip/tooltip.props.js +42 -0
- package/dist/components/tooltip/tooltip.slots.d.ts +26 -0
- package/dist/components/tooltip/tooltip.slots.js +42 -0
- package/dist/core/derive-threshold-tone.js +35 -0
- package/dist/core/merge-class-name.d.ts +17 -0
- package/dist/core/merge-class-name.js +16 -0
- package/dist/core/noctis-provider.d.ts +38 -0
- package/dist/core/noctis-provider.js +44 -0
- package/dist/core/primitive/index.d.ts +1 -0
- package/dist/core/primitive/primitive.d.ts +44 -0
- package/dist/core/primitive/primitive.js +27 -0
- package/dist/core/radius-scope/index.d.ts +2 -0
- package/dist/core/radius-scope/radius-scope.d.ts +43 -0
- package/dist/core/radius-scope/radius-scope.js +36 -0
- package/dist/core/radius-scope/radius-scope.styles.d.ts +13 -0
- package/dist/core/radius-scope/radius-scope.styles.js +11 -0
- package/dist/core/render.d.ts +24 -0
- package/dist/core/render.js +12 -0
- package/dist/core/use-copy.d.ts +13 -0
- package/dist/core/use-copy.js +30 -0
- package/dist/core/use-injected-labels.js +55 -0
- package/dist/core/use-reduced-motion.d.ts +9 -0
- package/dist/core/use-reduced-motion.js +26 -0
- package/dist/core/visually-hidden/index.d.ts +1 -0
- package/dist/core/visually-hidden/visually-hidden.d.ts +24 -0
- package/dist/core/visually-hidden/visually-hidden.js +19 -0
- package/dist/i18n/default-messages.d.ts +12 -0
- package/dist/i18n/default-messages.js +10 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/messages/index.d.ts +2 -0
- package/dist/i18n/messages/index.js +2 -0
- package/dist/icons/glyphs.d.ts +2 -0
- package/dist/icons/glyphs.js +2 -0
- package/dist/icons/icon.d.ts +40 -0
- package/dist/icons/icon.js +26 -0
- package/dist/icons/icon.styles.d.ts +9 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.js +112 -0
- package/dist/primitives/accordion.d.ts +7 -0
- package/dist/primitives/accordion.js +8 -0
- package/dist/primitives/alert-dialog.d.ts +7 -0
- package/dist/primitives/alert-dialog.js +8 -0
- package/dist/primitives/autocomplete/autocomplete.d.ts +58 -0
- package/dist/primitives/autocomplete/autocomplete.js +58 -0
- package/dist/primitives/autocomplete/index.d.ts +1 -0
- package/dist/primitives/autocomplete.d.ts +2 -0
- package/dist/primitives/autocomplete.js +2 -0
- package/dist/primitives/avatar.d.ts +7 -0
- package/dist/primitives/avatar.js +8 -0
- package/dist/primitives/button.d.ts +7 -0
- package/dist/primitives/button.js +8 -0
- package/dist/primitives/checkbox-group.d.ts +7 -0
- package/dist/primitives/checkbox-group.js +8 -0
- package/dist/primitives/checkbox.d.ts +7 -0
- package/dist/primitives/checkbox.js +8 -0
- package/dist/primitives/collapsible.d.ts +7 -0
- package/dist/primitives/collapsible.js +8 -0
- package/dist/primitives/combobox/combobox.d.ts +71 -0
- package/dist/primitives/combobox/combobox.js +66 -0
- package/dist/primitives/combobox/index.d.ts +1 -0
- package/dist/primitives/combobox.d.ts +2 -0
- package/dist/primitives/combobox.js +2 -0
- package/dist/primitives/context-menu.d.ts +7 -0
- package/dist/primitives/context-menu.js +8 -0
- package/dist/primitives/csp-provider.d.ts +1 -0
- package/dist/primitives/csp-provider.js +2 -0
- package/dist/primitives/dialog.d.ts +7 -0
- package/dist/primitives/dialog.js +8 -0
- package/dist/primitives/direction-provider.d.ts +1 -0
- package/dist/primitives/direction-provider.js +8 -0
- package/dist/primitives/drawer.d.ts +1 -0
- package/dist/primitives/drawer.js +2 -0
- package/dist/primitives/field.d.ts +7 -0
- package/dist/primitives/field.js +8 -0
- package/dist/primitives/fieldset.d.ts +7 -0
- package/dist/primitives/fieldset.js +8 -0
- package/dist/primitives/form.d.ts +7 -0
- package/dist/primitives/form.js +8 -0
- package/dist/primitives/index.d.ts +79 -0
- package/dist/primitives/index.js +113 -0
- package/dist/primitives/input.d.ts +7 -0
- package/dist/primitives/input.js +8 -0
- package/dist/primitives/menu.d.ts +7 -0
- package/dist/primitives/menu.js +8 -0
- package/dist/primitives/menubar.d.ts +7 -0
- package/dist/primitives/menubar.js +8 -0
- package/dist/primitives/meter/index.d.ts +1 -0
- package/dist/primitives/meter/meter.d.ts +56 -0
- package/dist/primitives/meter/meter.js +59 -0
- package/dist/primitives/meter.d.ts +2 -0
- package/dist/primitives/meter.js +2 -0
- package/dist/primitives/navigation-menu.d.ts +7 -0
- package/dist/primitives/navigation-menu.js +8 -0
- package/dist/primitives/number-field/context.d.ts +13 -0
- package/dist/primitives/number-field/context.js +36 -0
- package/dist/primitives/number-field/index.d.ts +2 -0
- package/dist/primitives/number-field/number-field.d.ts +90 -0
- package/dist/primitives/number-field/number-field.js +107 -0
- package/dist/primitives/number-field.d.ts +3 -0
- package/dist/primitives/number-field.js +2 -0
- package/dist/primitives/otp-field.d.ts +7 -0
- package/dist/primitives/otp-field.js +8 -0
- package/dist/primitives/popover.d.ts +7 -0
- package/dist/primitives/popover.js +8 -0
- package/dist/primitives/preview-card.d.ts +7 -0
- package/dist/primitives/preview-card.js +8 -0
- package/dist/primitives/progress/index.d.ts +1 -0
- package/dist/primitives/progress/progress.d.ts +56 -0
- package/dist/primitives/progress/progress.js +59 -0
- package/dist/primitives/progress.d.ts +2 -0
- package/dist/primitives/progress.js +2 -0
- package/dist/primitives/radio-group.d.ts +7 -0
- package/dist/primitives/radio-group.js +8 -0
- package/dist/primitives/radio.d.ts +7 -0
- package/dist/primitives/radio.js +8 -0
- package/dist/primitives/scroll-area.d.ts +7 -0
- package/dist/primitives/scroll-area.js +8 -0
- package/dist/primitives/select.d.ts +7 -0
- package/dist/primitives/select.js +8 -0
- package/dist/primitives/separator.d.ts +7 -0
- package/dist/primitives/separator.js +8 -0
- package/dist/primitives/slider/context.d.ts +12 -0
- package/dist/primitives/slider/context.js +18 -0
- package/dist/primitives/slider/index.d.ts +2 -0
- package/dist/primitives/slider/slider.d.ts +83 -0
- package/dist/primitives/slider/slider.js +99 -0
- package/dist/primitives/slider.d.ts +3 -0
- package/dist/primitives/slider.js +2 -0
- package/dist/primitives/switch.d.ts +1 -0
- package/dist/primitives/switch.js +2 -0
- package/dist/primitives/tabs.d.ts +7 -0
- package/dist/primitives/tabs.js +8 -0
- package/dist/primitives/toast/context.d.ts +11 -0
- package/dist/primitives/toast/context.js +18 -0
- package/dist/primitives/toast/index.d.ts +2 -0
- package/dist/primitives/toast/toast.d.ts +122 -0
- package/dist/primitives/toast/toast.js +133 -0
- package/dist/primitives/toast.d.ts +3 -0
- package/dist/primitives/toast.js +2 -0
- package/dist/primitives/toggle-group.d.ts +7 -0
- package/dist/primitives/toggle-group.js +8 -0
- package/dist/primitives/toggle.d.ts +7 -0
- package/dist/primitives/toggle.js +8 -0
- package/dist/primitives/toolbar.d.ts +7 -0
- package/dist/primitives/toolbar.js +8 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +8 -0
- package/dist/props.d.ts +46 -0
- package/dist/props.js +46 -0
- package/dist/styles.css +11513 -0
- package/dist/tailwind/cn.d.ts +33 -0
- package/dist/tailwind/cn.js +42 -0
- package/dist/tailwind/index.d.ts +3 -0
- package/dist/tailwind/index.js +3 -0
- package/dist/tailwind/tv.d.ts +20 -0
- package/dist/tailwind/tv.js +11 -0
- package/dist/tailwind.css +485 -0
- package/dist/theme/react.d.ts +1 -0
- package/dist/theme/react.js +1 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +1 -0
- package/dist/tokens/react.d.ts +1 -0
- package/dist/tokens/react.js +1 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Icon } from "../../icons/icon.js";
|
|
2
|
+
import { TerminalIcon } from "../../icons/glyphs.js";
|
|
3
|
+
import { managerGlyphProps } from "./code-block.props.js";
|
|
4
|
+
import clsx$1 from "clsx";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { siApachegroovy, siAstro, siC, siClojure, siCplusplus, siCrystal, siCss, siCurl, siDart, siDocker, siDotnet, siElixir, siErlang, siFishshell, siGnubash, siGo, siGradle, siGraphql, siHaskell, siHelm, siHtml5, siJavascript, siJson, siJulia, siKotlin, siKubernetes, siLua, siMarkdown, siMdx, siMysql, siNextdotjs, siNginx, siNim, siNodedotjs, siOcaml, siOpenjdk, siPerl, siPhp, siPostgresql, siPython, siR, siReact, siRuby, siRust, siSass, siScala, siShell, siSolidity, siSqlite, siSvelte, siSwift, siTailwindcss, siTerraform, siToml, siTypescript, siVuedotjs, siWebassembly, siXml, siYaml, siZig } from "simple-icons";
|
|
7
|
+
//#region src/components/code-block/brand-logo.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Inline data-URI brand glyphs for each package manager — static 1em SVGs, so no asset coupling and no
|
|
10
|
+
* `next/image` round-trip. Kept as data URIs (rather than Simple Icons) because these are the official
|
|
11
|
+
* multi-colour marks, which the monochrome Simple Icons set doesn't carry; they take precedence over the
|
|
12
|
+
* recoloured language marks when a name matches a manager.
|
|
13
|
+
*/
|
|
14
|
+
const MANAGER_ICON = {
|
|
15
|
+
pnpm: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 32 32'%3E%3Cpath fill='%23f9ad00' d='M30 10.75h-8.749V2H30Zm-9.626 0h-8.75V2h8.75Zm-9.625 0H2V2h8.749ZM30 20.375h-8.749v-8.75H30Z'/%3E%3Cpath fill='%234e4e4e' d='M20.374 20.375h-8.75v-8.75h8.75Zm0 9.625h-8.75v-8.75h8.75ZM30 30h-8.749v-8.75H30Zm-19.251 0H2v-8.75h8.749Z'/%3E%3C/svg%3E",
|
|
16
|
+
npm: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 32 32'%3E%3Cpath fill='%23c12127' d='M2 2h28v28H2'/%3E%3Cpath fill='%23fff' d='M7.25 7.25h17.5v17.5h-3.5v-14H16v14H7.25'/%3E%3C/svg%3E",
|
|
17
|
+
yarn: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 32 32'%3E%3Cpath fill='%232188b6' d='M28.208 24.409a10.5 10.5 0 0 0-3.959 1.822a23.7 23.7 0 0 1-5.835 2.642a1.63 1.63 0 0 1-.983.55a62 62 0 0 1-6.447.577c-1.163.009-1.876-.3-2.074-.776a1.573 1.573 0 0 1 .866-2.074a4 4 0 0 1-.514-.379c-.171-.171-.352-.514-.406-.388c-.225.55-.343 1.894-.947 2.5c-.83.839-2.4.559-3.328.072c-1.019-.541.072-1.813.072-1.813a.73.73 0 0 1-.992-.343a4.85 4.85 0 0 1-.667-2.949a5.37 5.37 0 0 1 1.749-2.895a9.3 9.3 0 0 1 .658-4.4a10.45 10.45 0 0 1 3.165-3.661S6.628 10.747 7.35 8.817c.469-1.262.658-1.253.812-1.308a3.6 3.6 0 0 0 1.452-.857a5.27 5.27 0 0 1 4.41-1.7S15.2 1.4 16.277 2.09a18.4 18.4 0 0 1 1.533 2.886s1.281-.748 1.425-.469a11.33 11.33 0 0 1 .523 6.132a14 14 0 0 1-2.6 5.411c-.135.225 1.551.938 2.615 3.887c.983 2.7.108 4.96.262 5.212c.027.045.036.063.036.063s1.127.09 3.391-1.308a8.5 8.5 0 0 1 4.277-1.604a1.081 1.081 0 0 1 .469 2.11Z'/%3E%3C/svg%3E",
|
|
18
|
+
bun: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 32 32'%3E%3Cpath fill='%23fbf0df' d='M29 17c0 5.65-5.82 10.23-13 10.23S3 22.61 3 17c0-3.5 2.24-6.6 5.66-8.44S14.21 4.81 16 4.81s3.32 1.54 7.34 3.71C26.76 10.36 29 13.46 29 17'/%3E%3Cpath fill='none' stroke='%23000' d='M16 27.65c7.32 0 13.46-4.65 13.46-10.65c0-3.72-2.37-7-5.89-8.85c-1.39-.75-2.46-1.41-3.37-2l-1.13-.69A6.14 6.14 0 0 0 16 4.35a6.9 6.9 0 0 0-3.3 1.23c-.42.24-.86.51-1.32.8c-.87.54-1.83 1.13-3 1.73C4.91 10 2.54 13.24 2.54 17c0 6 6.14 10.65 13.46 10.65Z'/%3E%3Cellipse cx='21.65' cy='18.62' fill='%23febbd0' rx='2.17' ry='1.28'/%3E%3Cellipse cx='10.41' cy='18.62' fill='%23febbd0' rx='2.17' ry='1.28'/%3E%3Cpath fill-rule='evenodd' d='M11.43 18.11a2 2 0 1 0-2-2.05a2.05 2.05 0 0 0 2 2.05m9.2 0a2 2 0 1 0-2-2.05a2 2 0 0 0 2 2.05'/%3E%3Cpath fill='%23fff' fill-rule='evenodd' d='M10.79 16.19a.77.77 0 1 0-.76-.77a.76.76 0 0 0 .76.77m9.2 0a.77.77 0 1 0 0-1.53a.77.77 0 0 0 0 1.53'/%3E%3Cpath fill='%23b71422' stroke='%23000' stroke-width='.75' d='M18.62 19.67a3.3 3.3 0 0 1-1.09 1.75a2.48 2.48 0 0 1-1.5.69a2.53 2.53 0 0 1-1.5-.69a3.28 3.28 0 0 1-1.08-1.75a.26.26 0 0 1 .29-.3h4.58a.27.27 0 0 1 .3.3Z'/%3E%3Cpath fill='%23ccbea7' fill-rule='evenodd' d='M14.93 5.75a6.1 6.1 0 0 1-2.09 4.62c-.1.09 0 .27.11.22c1.25-.49 2.94-1.94 2.23-4.88c-.03-.15-.25-.11-.25.04m.85 0a6 6 0 0 1 .57 5c0 .13.12.24.21.13c.83-1 1.54-3.11-.59-5.31c-.1-.11-.27.04-.19.17Zm1-.06a6.1 6.1 0 0 1 2.53 4.38c0 .14.21.17.24 0c.34-1.3.15-3.51-2.66-4.66c-.12-.02-.21.18-.09.27ZM9.94 9.55a6.27 6.27 0 0 0 3.89-3.33c.07-.13.28-.08.25.07c-.64 3-2.79 3.59-4.13 3.51c-.14-.01-.14-.21-.01-.25'/%3E%3C/svg%3E",
|
|
19
|
+
deno: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 32 32'%3E%3Cpath fill-rule='evenodd' d='M4.45 21.34A12.5 12.5 0 0 1 3.27 16a12 12 0 0 1 .09-1.46a11 11 0 0 1 .24-1.42a12.75 12.75 0 0 1 9.73-9.57A13 13 0 0 1 16 3.27h1a12.73 12.73 0 0 1 11.57 10.5a13 13 0 0 1 .16 2.23v1a12.6 12.6 0 0 1-3.3 7.61a6.62 6.62 0 0 1-4.7 2.06a4.68 4.68 0 0 1-2.88-1.09a4.58 4.58 0 0 1-1.63-3.09a5.5 5.5 0 0 1 .14-1.61a3.4 3.4 0 0 1 .8-1.53a5 5 0 0 1-1.3-.88a.15.15 0 0 1 0-.19a.16.16 0 0 1 .18-.06a10 10 0 0 0 1.46.37a20 20 0 0 0 2.45.31c2.13.1 4.38-.9 5.05-2.81s.43-3.83-2.08-5s-3.66-2.5-5.69-3.32a5 5 0 0 0-4.3.62c-4.08 2.25-7.72 9.35-6 15.94a.21.21 0 0 1-.1.23a.2.2 0 0 1-.23 0a13 13 0 0 1-1.33-1.73a13 13 0 0 1-.82-1.49'/%3E%3Cpath fill='%23f5f5f5' fill-rule='evenodd' d='M16.65 2A14 14 0 1 1 2 15.35A14 14 0 0 1 16.65 2m3.27 16.85a20 20 0 0 1-2.45-.31a8.6 8.6 0 0 1-1.47-.35a.16.16 0 0 0-.18.06a.15.15 0 0 0 0 .19a5 5 0 0 0 1.3.88a3.4 3.4 0 0 0-.8 1.53a5.5 5.5 0 0 0-.14 1.61a4.58 4.58 0 0 0 1.63 3.09a4.68 4.68 0 0 0 2.88 1.09a6.62 6.62 0 0 0 4.72-2.07a12.73 12.73 0 1 0-18.84 0a.21.21 0 0 0 .35-.19c-1.68-6.59 2-13.69 6-15.94a5 5 0 0 1 4.3-.62c2 .82 3.18 2.18 5.69 3.32s2.78 3 2.08 5s-2.91 2.86-5.07 2.73ZM15.54 8.69c-.82.06-1.36 1.08-1.43 1.73s.25 1.73 1.32 1.71c1.25 0 1.64-1.09 1.5-2.13a1.39 1.39 0 0 0-1.39-1.31'/%3E%3Cpath fill-rule='evenodd' d='M15.54 8.68A1.4 1.4 0 0 1 16.93 10c.14 1-.24 2.12-1.49 2.14c-1.07 0-1.4-1.06-1.33-1.71s.61-1.68 1.43-1.75'/%3E%3C/svg%3E"
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Brand logo for a fenced-code language, addressed by its Shiki language id (`bash`, `ts`, `go`) or a
|
|
23
|
+
* human label (`Node.js`, `cURL`). Backed by Simple Icons — the canonical CC0 brand-mark set. Drives
|
|
24
|
+
* the `CodeBlock` header and the `CodeBlock.Tabs` tab strip so a tab reads as the language with its
|
|
25
|
+
* real logo. Keys match case-insensitively against the raw token, then a punctuation-stripped form
|
|
26
|
+
* (`node.js` → `nodejs`, `c++` → `cpp`); unknown languages fall back to a neutral terminal glyph.
|
|
27
|
+
*/
|
|
28
|
+
const ICON_BY_KEY = {
|
|
29
|
+
javascript: siJavascript,
|
|
30
|
+
js: siJavascript,
|
|
31
|
+
mjs: siJavascript,
|
|
32
|
+
cjs: siJavascript,
|
|
33
|
+
typescript: siTypescript,
|
|
34
|
+
ts: siTypescript,
|
|
35
|
+
react: siReact,
|
|
36
|
+
jsx: siReact,
|
|
37
|
+
tsx: siReact,
|
|
38
|
+
node: siNodedotjs,
|
|
39
|
+
nodejs: siNodedotjs,
|
|
40
|
+
"node.js": siNodedotjs,
|
|
41
|
+
nextjs: siNextdotjs,
|
|
42
|
+
"next.js": siNextdotjs,
|
|
43
|
+
vue: siVuedotjs,
|
|
44
|
+
svelte: siSvelte,
|
|
45
|
+
astro: siAstro,
|
|
46
|
+
go: siGo,
|
|
47
|
+
golang: siGo,
|
|
48
|
+
rust: siRust,
|
|
49
|
+
rs: siRust,
|
|
50
|
+
c: siC,
|
|
51
|
+
cpp: siCplusplus,
|
|
52
|
+
"c++": siCplusplus,
|
|
53
|
+
cc: siCplusplus,
|
|
54
|
+
cxx: siCplusplus,
|
|
55
|
+
csharp: siDotnet,
|
|
56
|
+
"c#": siDotnet,
|
|
57
|
+
cs: siDotnet,
|
|
58
|
+
fsharp: siDotnet,
|
|
59
|
+
"f#": siDotnet,
|
|
60
|
+
dotnet: siDotnet,
|
|
61
|
+
".net": siDotnet,
|
|
62
|
+
java: siOpenjdk,
|
|
63
|
+
kotlin: siKotlin,
|
|
64
|
+
kt: siKotlin,
|
|
65
|
+
kts: siKotlin,
|
|
66
|
+
swift: siSwift,
|
|
67
|
+
zig: siZig,
|
|
68
|
+
nim: siNim,
|
|
69
|
+
crystal: siCrystal,
|
|
70
|
+
python: siPython,
|
|
71
|
+
py: siPython,
|
|
72
|
+
ruby: siRuby,
|
|
73
|
+
rb: siRuby,
|
|
74
|
+
php: siPhp,
|
|
75
|
+
perl: siPerl,
|
|
76
|
+
pl: siPerl,
|
|
77
|
+
lua: siLua,
|
|
78
|
+
r: siR,
|
|
79
|
+
dart: siDart,
|
|
80
|
+
elixir: siElixir,
|
|
81
|
+
ex: siElixir,
|
|
82
|
+
exs: siElixir,
|
|
83
|
+
erlang: siErlang,
|
|
84
|
+
erl: siErlang,
|
|
85
|
+
scala: siScala,
|
|
86
|
+
groovy: siApachegroovy,
|
|
87
|
+
clojure: siClojure,
|
|
88
|
+
clj: siClojure,
|
|
89
|
+
haskell: siHaskell,
|
|
90
|
+
hs: siHaskell,
|
|
91
|
+
ocaml: siOcaml,
|
|
92
|
+
ml: siOcaml,
|
|
93
|
+
julia: siJulia,
|
|
94
|
+
jl: siJulia,
|
|
95
|
+
solidity: siSolidity,
|
|
96
|
+
sol: siSolidity,
|
|
97
|
+
bash: siGnubash,
|
|
98
|
+
sh: siShell,
|
|
99
|
+
shell: siShell,
|
|
100
|
+
shellsession: siShell,
|
|
101
|
+
console: siShell,
|
|
102
|
+
zsh: siShell,
|
|
103
|
+
ksh: siShell,
|
|
104
|
+
fish: siFishshell,
|
|
105
|
+
curl: siCurl,
|
|
106
|
+
json: siJson,
|
|
107
|
+
jsonc: siJson,
|
|
108
|
+
json5: siJson,
|
|
109
|
+
yaml: siYaml,
|
|
110
|
+
yml: siYaml,
|
|
111
|
+
toml: siToml,
|
|
112
|
+
xml: siXml,
|
|
113
|
+
html: siHtml5,
|
|
114
|
+
htm: siHtml5,
|
|
115
|
+
css: siCss,
|
|
116
|
+
scss: siSass,
|
|
117
|
+
sass: siSass,
|
|
118
|
+
markdown: siMarkdown,
|
|
119
|
+
md: siMarkdown,
|
|
120
|
+
mdx: siMdx,
|
|
121
|
+
graphql: siGraphql,
|
|
122
|
+
gql: siGraphql,
|
|
123
|
+
wasm: siWebassembly,
|
|
124
|
+
wat: siWebassembly,
|
|
125
|
+
sql: siPostgresql,
|
|
126
|
+
postgres: siPostgresql,
|
|
127
|
+
postgresql: siPostgresql,
|
|
128
|
+
psql: siPostgresql,
|
|
129
|
+
mysql: siMysql,
|
|
130
|
+
sqlite: siSqlite,
|
|
131
|
+
docker: siDocker,
|
|
132
|
+
dockerfile: siDocker,
|
|
133
|
+
nginx: siNginx,
|
|
134
|
+
terraform: siTerraform,
|
|
135
|
+
tf: siTerraform,
|
|
136
|
+
hcl: siTerraform,
|
|
137
|
+
kubernetes: siKubernetes,
|
|
138
|
+
k8s: siKubernetes,
|
|
139
|
+
helm: siHelm,
|
|
140
|
+
gradle: siGradle,
|
|
141
|
+
tailwind: siTailwindcss,
|
|
142
|
+
tailwindcss: siTailwindcss
|
|
143
|
+
};
|
|
144
|
+
function parseHex(hex) {
|
|
145
|
+
const value = hex.replace("#", "");
|
|
146
|
+
return [
|
|
147
|
+
Number.parseInt(value.slice(0, 2), 16),
|
|
148
|
+
Number.parseInt(value.slice(2, 4), 16),
|
|
149
|
+
Number.parseInt(value.slice(4, 6), 16)
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
const toByte = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
|
|
153
|
+
/** Minimum perceived luminance (0–255) a logo fill must clear to stay legible on the dark code well. */
|
|
154
|
+
const LUMINANCE_FLOOR = 96;
|
|
155
|
+
/**
|
|
156
|
+
* Brand hex nudged so a near-black mark (Rust, JSON, Markdown) reads on the dark code surface: mixed
|
|
157
|
+
* toward white by the smallest amount that lifts its luminance to {@link LUMINANCE_FLOOR}, keeping the
|
|
158
|
+
* hue. Most logos pass through untouched.
|
|
159
|
+
*/
|
|
160
|
+
function readableHex(hex) {
|
|
161
|
+
const [r, g, b] = parseHex(hex);
|
|
162
|
+
const luminance = .2126 * r + .7152 * g + .0722 * b;
|
|
163
|
+
if (luminance >= LUMINANCE_FLOOR) return `#${hex.replace("#", "")}`;
|
|
164
|
+
const t = (LUMINANCE_FLOOR - luminance) / (255 - luminance);
|
|
165
|
+
const lift = (c) => c + (255 - c) * t;
|
|
166
|
+
return `#${toByte(lift(r))}${toByte(lift(g))}${toByte(lift(b))}`;
|
|
167
|
+
}
|
|
168
|
+
function lookup(token) {
|
|
169
|
+
if (!token) return void 0;
|
|
170
|
+
const key = token.trim().toLowerCase();
|
|
171
|
+
if (key in ICON_BY_KEY) return ICON_BY_KEY[key];
|
|
172
|
+
return ICON_BY_KEY[key.replace(/[\s._-]/g, "")];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The brand glyph for a fenced-code language or a package manager — one component for both, so a
|
|
176
|
+
* `CodeBlock.Tab`'s leading mark reads consistently whether the strip is languages or managers.
|
|
177
|
+
* Resolves in order: an official multi-colour package-manager mark (pnpm, npm, yarn, bun, deno), then a
|
|
178
|
+
* Simple Icons language mark (recoloured to stay legible on the dark well), then a muted terminal glyph
|
|
179
|
+
* so every tab keeps a leading icon. Reads `label` first (an explicit `Node.js` beats the raw `ts`
|
|
180
|
+
* fence id), then `name`.
|
|
181
|
+
*
|
|
182
|
+
* @see {@link BrandLogo.Props}
|
|
183
|
+
*/
|
|
184
|
+
function BrandLogo({ name, label, size = 14, className, ...rest }) {
|
|
185
|
+
const manager = (label ?? name)?.trim().toLowerCase();
|
|
186
|
+
if (manager && Object.hasOwn(MANAGER_ICON, manager)) return /* @__PURE__ */ jsx("span", {
|
|
187
|
+
"aria-hidden": true,
|
|
188
|
+
style: { backgroundImage: `url("${MANAGER_ICON[manager]}")` },
|
|
189
|
+
...managerGlyphProps({ className }),
|
|
190
|
+
...rest
|
|
191
|
+
});
|
|
192
|
+
const icon = lookup(label) ?? lookup(name);
|
|
193
|
+
if (!icon) return /* @__PURE__ */ jsx(Icon, {
|
|
194
|
+
icon: TerminalIcon,
|
|
195
|
+
size: "sm",
|
|
196
|
+
className,
|
|
197
|
+
"aria-hidden": true,
|
|
198
|
+
...rest
|
|
199
|
+
});
|
|
200
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
201
|
+
viewBox: "0 0 24 24",
|
|
202
|
+
width: size,
|
|
203
|
+
height: size,
|
|
204
|
+
fill: readableHex(icon.hex),
|
|
205
|
+
className: clsx$1(className),
|
|
206
|
+
"aria-hidden": true,
|
|
207
|
+
...rest,
|
|
208
|
+
children: [/* @__PURE__ */ jsx("title", { children: icon.title }), /* @__PURE__ */ jsx("path", { d: icon.path })]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { BrandLogo };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use } from "react";
|
|
3
|
+
//#region src/components/code-block/code-block.context.ts
|
|
4
|
+
const CodeBlockContext = createContext(null);
|
|
5
|
+
const CodeBlockProvider = CodeBlockContext.Provider;
|
|
6
|
+
/** Read the code-block context, throwing a named error when a part renders outside `<CodeBlock>`. */
|
|
7
|
+
function useCodeBlockContext(part) {
|
|
8
|
+
const context = use(CodeBlockContext);
|
|
9
|
+
if (context === null) throw new Error(`CodeBlock.${part} must be rendered inside <CodeBlock>.`);
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CodeBlockProvider, useCodeBlockContext };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { tabs_d_exports } from "../../primitives/tabs.js";
|
|
2
|
+
import { bodyProps, frameProps, headerProps, titleProps } from "./code-block.props.js";
|
|
3
|
+
import { JSX, ReactElement, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/code-block/code-block.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Owns the copy-target resolution and the chrome labels, and renders the default composition when
|
|
8
|
+
* called with children only: a header band (the language logo plus a filename `label` or the language
|
|
9
|
+
* name, with a copy button) over the code in a horizontally scrollable body — or a floating copy
|
|
10
|
+
* button when there is no header. The Noctis well surface (`Surface` at the `sunken` shade) is the
|
|
11
|
+
* chassis; the `data-codeblock` hook lets the app stylesheet attach the line-number gutter.
|
|
12
|
+
*
|
|
13
|
+
* Compose explicitly for full control: {@link CodeBlock.Header} (holding {@link CodeBlock.Title} and
|
|
14
|
+
* {@link CodeBlock.CopyButton}), {@link CodeBlock.Body}, and — for a tabbed group of samples —
|
|
15
|
+
* {@link CodeBlock.Tabs} with {@link CodeBlock.Tab}s and {@link CodeBlock.Panel}s.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link CodeBlock.Root.Props}
|
|
18
|
+
*/
|
|
19
|
+
declare function CodeBlockRoot({
|
|
20
|
+
label,
|
|
21
|
+
language,
|
|
22
|
+
icon,
|
|
23
|
+
copyText,
|
|
24
|
+
copyLabel,
|
|
25
|
+
copiedLabel,
|
|
26
|
+
className,
|
|
27
|
+
children
|
|
28
|
+
}: CodeBlock.Root.Props): ReactElement;
|
|
29
|
+
/** The header band. Renders the `code-block-header` slot; holds the title, logo, and copy button. */
|
|
30
|
+
declare function CodeBlockHeader({
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}: CodeBlock.Header.Props): ReactElement;
|
|
34
|
+
/** The filename / language caption in the header. Treated as code, not prose. Renders no slot. */
|
|
35
|
+
declare function CodeBlockTitle({
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: CodeBlock.Title.Props): ReactElement;
|
|
39
|
+
/**
|
|
40
|
+
* The copy affordance, reading the copy target and chrome labels from context so it works in the header
|
|
41
|
+
* or floating. Renders the `code-copy` slot.
|
|
42
|
+
*/
|
|
43
|
+
declare function CodeBlockCopyButton({
|
|
44
|
+
className
|
|
45
|
+
}: CodeBlock.CopyButton.Props): ReactElement;
|
|
46
|
+
/**
|
|
47
|
+
* The horizontally scrollable code body. Pinned `dir=ltr` so tokens never reorder on an RTL page, and
|
|
48
|
+
* registers its ref as the copy target. Renders no slot — the frame above carries `code-block`.
|
|
49
|
+
*/
|
|
50
|
+
declare function CodeBlockBody({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
...props
|
|
54
|
+
}: CodeBlock.Body.Props): ReactElement;
|
|
55
|
+
/**
|
|
56
|
+
* A tabbed group of code samples — one tab per language or filename, each with its brand logo — on the
|
|
57
|
+
* well surface. Each child is a `<CodeBlock>` (or a raw `<pre>` with `label` / `language`); the strip
|
|
58
|
+
* reads each child's label, the active panel renders that child flush, and one copy button copies
|
|
59
|
+
* whichever sample is showing. Owns its own copy-target/active context. Renders the `code-tabs` slot.
|
|
60
|
+
*
|
|
61
|
+
* Styling lives in the sibling `code-tabs.css` (the tab strip is the `code-tabs` component in the token
|
|
62
|
+
* graph). It keys the frame radius off the `code-tabs` slot, and the strip/list/tab/logo metrics off the
|
|
63
|
+
* stable descendant hooks this markup stamps — `data-code-tabs-strip` on the bar, Base UI's
|
|
64
|
+
* `[role="tablist"]`/`[role="tab"]` on the list and tabs, and `data-code-tabs-logo` on each tab's logo.
|
|
65
|
+
*/
|
|
66
|
+
declare function CodeBlockTabs({
|
|
67
|
+
children,
|
|
68
|
+
"aria-label": ariaLabel,
|
|
69
|
+
copyLabel,
|
|
70
|
+
copiedLabel,
|
|
71
|
+
className
|
|
72
|
+
}: CodeBlock.Tabs.Props): ReactElement | null;
|
|
73
|
+
/**
|
|
74
|
+
* One language tab — a brand logo plus its label, addressed by `value`. The logo de-dims when the tab
|
|
75
|
+
* is active or hovered (handled by `code-tabs.css` off Base UI's `[data-active]`). Renders no slot (a
|
|
76
|
+
* Base UI tab inside the strip); stamps `data-code-tabs-logo` on the logo wrapper for the CSS to key on.
|
|
77
|
+
*/
|
|
78
|
+
declare function CodeBlockTab({
|
|
79
|
+
value,
|
|
80
|
+
language,
|
|
81
|
+
label,
|
|
82
|
+
icon,
|
|
83
|
+
className,
|
|
84
|
+
children,
|
|
85
|
+
...props
|
|
86
|
+
}: CodeBlock.Tab.Props): ReactElement;
|
|
87
|
+
/**
|
|
88
|
+
* The active sample's panel. Matches its `value` to the showing tab; flattens a nested `CodeBlock`'s
|
|
89
|
+
* frame so the sample sits flush (handled by `code-tabs.css`). Renders the `code-tabs-panel` slot.
|
|
90
|
+
*/
|
|
91
|
+
declare function CodeBlockPanel({
|
|
92
|
+
className,
|
|
93
|
+
...props
|
|
94
|
+
}: CodeBlock.Panel.Props): ReactElement;
|
|
95
|
+
/**
|
|
96
|
+
* The code-block family — one composable component. Bare `<CodeBlock>` renders the default composition
|
|
97
|
+
* (a header from the `label`/`language` plus a copy button over the scrollable body); compose the parts
|
|
98
|
+
* for full control: `CodeBlock.Header` (with `CodeBlock.Title` + `CodeBlock.CopyButton`),
|
|
99
|
+
* `CodeBlock.Body`, and `CodeBlock.Tabs` (with `CodeBlock.Tab`s and `CodeBlock.Panel`s) for a tabbed
|
|
100
|
+
* group of samples. Presentation only — syntax highlighting is the caller's concern (Shiki at build
|
|
101
|
+
* time in the docs), so any pre-tokenised `<pre>` drops straight in.
|
|
102
|
+
*
|
|
103
|
+
* The runtime compound is a plain object (kept tree-shakeable); per-part prop types are exposed through
|
|
104
|
+
* the matching `CodeBlock` namespace — e.g. `CodeBlock.Tab.Props`. Each part carries its D12 `props()`
|
|
105
|
+
* escape hatch via `Object.assign`: spread `CodeBlock.Header.props()` onto a foreign element to style
|
|
106
|
+
* it as that part (styling is attribute-driven — `code-block.css` keys off the stamped `data-slot`).
|
|
107
|
+
*/
|
|
108
|
+
declare const CodeBlock: typeof CodeBlockRoot & {
|
|
109
|
+
Header: typeof CodeBlockHeader & {
|
|
110
|
+
props: typeof headerProps;
|
|
111
|
+
};
|
|
112
|
+
Title: typeof CodeBlockTitle & {
|
|
113
|
+
props: typeof titleProps;
|
|
114
|
+
};
|
|
115
|
+
CopyButton: typeof CodeBlockCopyButton;
|
|
116
|
+
Body: typeof CodeBlockBody & {
|
|
117
|
+
props: typeof bodyProps;
|
|
118
|
+
};
|
|
119
|
+
Tabs: typeof CodeBlockTabs;
|
|
120
|
+
Tab: typeof CodeBlockTab;
|
|
121
|
+
Panel: typeof CodeBlockPanel; /** Escape-hatch helper for the frame slot — spread onto an element a `<Surface>` can't wrap. */
|
|
122
|
+
props: typeof frameProps;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Per-part prop types, mirroring Base UI's `Component.Part.Props` convention. Types-only — it emits no
|
|
126
|
+
* runtime code and merges with the `CodeBlock` object above, so `CodeBlock.Tab` is the component value
|
|
127
|
+
* while `CodeBlock.Tab.Props` is its prop type.
|
|
128
|
+
*/
|
|
129
|
+
declare namespace CodeBlock {
|
|
130
|
+
namespace Root {
|
|
131
|
+
type Props = {
|
|
132
|
+
/** A filename / caption shown in the header band (e.g. `App.tsx`). Treated as code, not prose. */label?: string; /** The language id, used for the brand logo and (absent a `label`) the header text. */
|
|
133
|
+
language?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Override the brand logo shown in the header — e.g. a package-manager glyph
|
|
136
|
+
* (`<BrandLogo name="pnpm" />`). Inside `CodeBlock.Tabs`, this is the tab's logo.
|
|
137
|
+
* Defaults to the language logo.
|
|
138
|
+
*/
|
|
139
|
+
icon?: ReactNode;
|
|
140
|
+
/**
|
|
141
|
+
* The exact text the copy button writes to the clipboard. Omit to copy the rendered code's
|
|
142
|
+
* `textContent` — the right default when `children` is a syntax-highlighted `<pre>`.
|
|
143
|
+
*/
|
|
144
|
+
copyText?: string; /** Copy button label at rest. Defaults to `Copy`. */
|
|
145
|
+
copyLabel?: string; /** Copy button label just after copying. Defaults to `Copied`. */
|
|
146
|
+
copiedLabel?: string; /** Classes merged onto the well surface. */
|
|
147
|
+
className?: string; /** The code itself — typically a build-time syntax-highlighted `<pre>`. */
|
|
148
|
+
children?: ReactNode;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
namespace Header {
|
|
152
|
+
type Props = JSX.IntrinsicElements["div"];
|
|
153
|
+
}
|
|
154
|
+
namespace Title {
|
|
155
|
+
type Props = JSX.IntrinsicElements["span"];
|
|
156
|
+
}
|
|
157
|
+
namespace CopyButton {
|
|
158
|
+
type Props = {
|
|
159
|
+
/** Classes merged onto the copy button. */className?: string;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
namespace Body {
|
|
163
|
+
type Props = JSX.IntrinsicElements["div"];
|
|
164
|
+
}
|
|
165
|
+
namespace Tabs {
|
|
166
|
+
type Props = {
|
|
167
|
+
/** One child per language — a `<CodeBlock>` or a raw `<pre>` carrying `label` / `language`. */children?: ReactNode; /** Accessible name for the tab strip (e.g. "Code language"). */
|
|
168
|
+
"aria-label"?: string; /** Copy button label at rest. Defaults to `Copy`. */
|
|
169
|
+
copyLabel?: string; /** Copy button label just after copying. Defaults to `Copied`. */
|
|
170
|
+
copiedLabel?: string; /** Classes merged onto the tab-group frame. */
|
|
171
|
+
className?: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
namespace Tab {
|
|
175
|
+
type Props = tabs_d_exports.Tabs.Tab.Props & {
|
|
176
|
+
/** Shiki language id for the tab's brand logo. */language?: string; /** Author-facing label for the tab's brand logo; preferred over `language`. */
|
|
177
|
+
label?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Override the tab's brand logo — e.g. a package-manager glyph
|
|
180
|
+
* (`<BrandLogo name="pnpm" />`). Defaults to the language logo from `language`/`label`.
|
|
181
|
+
*/
|
|
182
|
+
icon?: ReactNode;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
namespace Panel {
|
|
186
|
+
type Props = tabs_d_exports.Tabs.Panel.Props;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { CodeBlock };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Surface } from "../surface/surface.js";
|
|
3
|
+
import { tabs_exports } from "../../primitives/tabs.js";
|
|
4
|
+
import { CopyButton } from "../copy-button/copy-button.js";
|
|
5
|
+
import { CODE_BLOCK_SLOTS } from "./code-block.slots.js";
|
|
6
|
+
import { bodyProps, floatingCopyProps, frameProps, headerProps, logoProps, titleProps } from "./code-block.props.js";
|
|
7
|
+
import { BrandLogo } from "./brand-logo.js";
|
|
8
|
+
import { CodeBlockProvider, useCodeBlockContext } from "./code-block.context.js";
|
|
9
|
+
import { prettyLanguage } from "./language-label.js";
|
|
10
|
+
import { Children, isValidElement, useCallback, useMemo, useRef, useState } from "react";
|
|
11
|
+
import clsx$1 from "clsx";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
//#region src/components/code-block/code-block.tsx
|
|
14
|
+
const childLabel = (props) => props.label ?? props["data-label"];
|
|
15
|
+
const childLanguage = (props) => props.language ?? props["data-language"];
|
|
16
|
+
const childIcon = (props) => props.icon;
|
|
17
|
+
function resolveTabLabel(label, language, index) {
|
|
18
|
+
if (label) return label;
|
|
19
|
+
if (language) return prettyLanguage(language, language);
|
|
20
|
+
return `${index + 1}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Owns the copy-target resolution and the chrome labels, and renders the default composition when
|
|
24
|
+
* called with children only: a header band (the language logo plus a filename `label` or the language
|
|
25
|
+
* name, with a copy button) over the code in a horizontally scrollable body — or a floating copy
|
|
26
|
+
* button when there is no header. The Noctis well surface (`Surface` at the `sunken` shade) is the
|
|
27
|
+
* chassis; the `data-codeblock` hook lets the app stylesheet attach the line-number gutter.
|
|
28
|
+
*
|
|
29
|
+
* Compose explicitly for full control: {@link CodeBlock.Header} (holding {@link CodeBlock.Title} and
|
|
30
|
+
* {@link CodeBlock.CopyButton}), {@link CodeBlock.Body}, and — for a tabbed group of samples —
|
|
31
|
+
* {@link CodeBlock.Tabs} with {@link CodeBlock.Tab}s and {@link CodeBlock.Panel}s.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link CodeBlock.Root.Props}
|
|
34
|
+
*/
|
|
35
|
+
function CodeBlockRoot({ label, language, icon, copyText, copyLabel, copiedLabel, className, children }) {
|
|
36
|
+
const targetRef = useRef(null);
|
|
37
|
+
const registerTarget = useCallback((ref) => {
|
|
38
|
+
targetRef.current = ref;
|
|
39
|
+
}, []);
|
|
40
|
+
const getText = useCallback(() => copyText ?? targetRef.current?.current?.querySelector("code, pre")?.textContent ?? "", [copyText]);
|
|
41
|
+
const context = useMemo(() => ({
|
|
42
|
+
state: { activeValue: void 0 },
|
|
43
|
+
actions: {
|
|
44
|
+
setActiveValue: () => {},
|
|
45
|
+
registerTarget,
|
|
46
|
+
getText
|
|
47
|
+
},
|
|
48
|
+
meta: {
|
|
49
|
+
copyLabel,
|
|
50
|
+
copiedLabel
|
|
51
|
+
}
|
|
52
|
+
}), [
|
|
53
|
+
registerTarget,
|
|
54
|
+
getText,
|
|
55
|
+
copyLabel,
|
|
56
|
+
copiedLabel
|
|
57
|
+
]);
|
|
58
|
+
const headerText = label ?? prettyLanguage(language);
|
|
59
|
+
const showHeader = Boolean(headerText);
|
|
60
|
+
return /* @__PURE__ */ jsx(CodeBlockProvider, {
|
|
61
|
+
value: context,
|
|
62
|
+
children: /* @__PURE__ */ jsxs(Surface, {
|
|
63
|
+
"data-codeblock": "",
|
|
64
|
+
shade: "sunken",
|
|
65
|
+
bordered: true,
|
|
66
|
+
...frameProps({ className }),
|
|
67
|
+
children: [showHeader ? /* @__PURE__ */ jsxs(CodeBlockHeader, { children: [
|
|
68
|
+
icon ?? /* @__PURE__ */ jsx(BrandLogo, {
|
|
69
|
+
name: language,
|
|
70
|
+
label,
|
|
71
|
+
...logoProps()
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx(CodeBlockTitle, { children: headerText }),
|
|
74
|
+
/* @__PURE__ */ jsx(CodeBlockCopyButton, {})
|
|
75
|
+
] }) : /* @__PURE__ */ jsx("div", {
|
|
76
|
+
...floatingCopyProps(),
|
|
77
|
+
children: /* @__PURE__ */ jsx(CodeBlockCopyButton, {})
|
|
78
|
+
}), /* @__PURE__ */ jsx(CodeBlockBody, { children })]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** The header band. Renders the `code-block-header` slot; holds the title, logo, and copy button. */
|
|
83
|
+
function CodeBlockHeader({ className, ...props }) {
|
|
84
|
+
return /* @__PURE__ */ jsx("div", {
|
|
85
|
+
...headerProps({ className }),
|
|
86
|
+
...props
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** The filename / language caption in the header. Treated as code, not prose. Renders no slot. */
|
|
90
|
+
function CodeBlockTitle({ className, ...props }) {
|
|
91
|
+
return /* @__PURE__ */ jsx("span", {
|
|
92
|
+
"data-allow-literal": true,
|
|
93
|
+
...titleProps({ className }),
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The copy affordance, reading the copy target and chrome labels from context so it works in the header
|
|
99
|
+
* or floating. Renders the `code-copy` slot.
|
|
100
|
+
*/
|
|
101
|
+
function CodeBlockCopyButton({ className }) {
|
|
102
|
+
const { actions, meta } = useCodeBlockContext("CopyButton");
|
|
103
|
+
return /* @__PURE__ */ jsx(CopyButton, {
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
size: "xs",
|
|
106
|
+
iconOnly: true,
|
|
107
|
+
getText: actions.getText,
|
|
108
|
+
copyLabel: meta.copyLabel,
|
|
109
|
+
copiedLabel: meta.copiedLabel,
|
|
110
|
+
className: clsx$1(className)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The horizontally scrollable code body. Pinned `dir=ltr` so tokens never reorder on an RTL page, and
|
|
115
|
+
* registers its ref as the copy target. Renders no slot — the frame above carries `code-block`.
|
|
116
|
+
*/
|
|
117
|
+
function CodeBlockBody({ className, children, ...props }) {
|
|
118
|
+
const { actions } = useCodeBlockContext("Body");
|
|
119
|
+
const ref = useRef(null);
|
|
120
|
+
return /* @__PURE__ */ jsx("div", {
|
|
121
|
+
ref: useCallback((node) => {
|
|
122
|
+
ref.current = node;
|
|
123
|
+
actions.registerTarget(ref);
|
|
124
|
+
}, [actions]),
|
|
125
|
+
dir: "ltr",
|
|
126
|
+
"data-custom-scrollbar": true,
|
|
127
|
+
...bodyProps({ className }),
|
|
128
|
+
...props,
|
|
129
|
+
children
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A tabbed group of code samples — one tab per language or filename, each with its brand logo — on the
|
|
134
|
+
* well surface. Each child is a `<CodeBlock>` (or a raw `<pre>` with `label` / `language`); the strip
|
|
135
|
+
* reads each child's label, the active panel renders that child flush, and one copy button copies
|
|
136
|
+
* whichever sample is showing. Owns its own copy-target/active context. Renders the `code-tabs` slot.
|
|
137
|
+
*
|
|
138
|
+
* Styling lives in the sibling `code-tabs.css` (the tab strip is the `code-tabs` component in the token
|
|
139
|
+
* graph). It keys the frame radius off the `code-tabs` slot, and the strip/list/tab/logo metrics off the
|
|
140
|
+
* stable descendant hooks this markup stamps — `data-code-tabs-strip` on the bar, Base UI's
|
|
141
|
+
* `[role="tablist"]`/`[role="tab"]` on the list and tabs, and `data-code-tabs-logo` on each tab's logo.
|
|
142
|
+
*/
|
|
143
|
+
function CodeBlockTabs({ children, "aria-label": ariaLabel, copyLabel, copiedLabel, className }) {
|
|
144
|
+
const items = Children.toArray(children).filter((child) => isValidElement(child));
|
|
145
|
+
const [value, setValue] = useState("0");
|
|
146
|
+
const panelRef = useRef(null);
|
|
147
|
+
const registerTarget = useCallback((_ref) => {}, []);
|
|
148
|
+
const getText = useCallback(() => panelRef.current?.querySelector("code, pre")?.textContent ?? "", []);
|
|
149
|
+
const setActiveValue = useCallback((next) => setValue(next), []);
|
|
150
|
+
const context = useMemo(() => ({
|
|
151
|
+
state: { activeValue: value },
|
|
152
|
+
actions: {
|
|
153
|
+
setActiveValue,
|
|
154
|
+
registerTarget,
|
|
155
|
+
getText
|
|
156
|
+
},
|
|
157
|
+
meta: {
|
|
158
|
+
copyLabel,
|
|
159
|
+
copiedLabel
|
|
160
|
+
}
|
|
161
|
+
}), [
|
|
162
|
+
value,
|
|
163
|
+
setActiveValue,
|
|
164
|
+
registerTarget,
|
|
165
|
+
getText,
|
|
166
|
+
copyLabel,
|
|
167
|
+
copiedLabel
|
|
168
|
+
]);
|
|
169
|
+
if (items.length === 0) return null;
|
|
170
|
+
const activeChild = items[Number(value)] ?? items[0];
|
|
171
|
+
return /* @__PURE__ */ jsx(CodeBlockProvider, {
|
|
172
|
+
value: context,
|
|
173
|
+
children: /* @__PURE__ */ jsx(Surface, {
|
|
174
|
+
"data-slot": CODE_BLOCK_SLOTS.tabs,
|
|
175
|
+
"data-codeblock": "",
|
|
176
|
+
shade: "sunken",
|
|
177
|
+
bordered: true,
|
|
178
|
+
className: clsx$1(className),
|
|
179
|
+
children: /* @__PURE__ */ jsxs(tabs_exports.Tabs.Root, {
|
|
180
|
+
value,
|
|
181
|
+
onValueChange: (next) => setActiveValue(String(next)),
|
|
182
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
183
|
+
"data-code-tabs-strip": "",
|
|
184
|
+
children: [/* @__PURE__ */ jsx(tabs_exports.Tabs.List, {
|
|
185
|
+
"aria-label": ariaLabel,
|
|
186
|
+
children: items.map((child, index) => {
|
|
187
|
+
const language = childLanguage(child.props);
|
|
188
|
+
const label = childLabel(child.props);
|
|
189
|
+
return /* @__PURE__ */ jsx(CodeBlockTab, {
|
|
190
|
+
value: String(index),
|
|
191
|
+
language,
|
|
192
|
+
label,
|
|
193
|
+
icon: childIcon(child.props),
|
|
194
|
+
children: resolveTabLabel(label, language, index)
|
|
195
|
+
}, child.key ?? index);
|
|
196
|
+
})
|
|
197
|
+
}), /* @__PURE__ */ jsx(CodeBlockCopyButton, {})]
|
|
198
|
+
}), /* @__PURE__ */ jsx(CodeBlockPanel, {
|
|
199
|
+
ref: panelRef,
|
|
200
|
+
value,
|
|
201
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
202
|
+
dir: "ltr",
|
|
203
|
+
"data-code-block-body": "",
|
|
204
|
+
children: activeChild.props.children
|
|
205
|
+
})
|
|
206
|
+
})]
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* One language tab — a brand logo plus its label, addressed by `value`. The logo de-dims when the tab
|
|
213
|
+
* is active or hovered (handled by `code-tabs.css` off Base UI's `[data-active]`). Renders no slot (a
|
|
214
|
+
* Base UI tab inside the strip); stamps `data-code-tabs-logo` on the logo wrapper for the CSS to key on.
|
|
215
|
+
*/
|
|
216
|
+
function CodeBlockTab({ value, language, label, icon, className, children, ...props }) {
|
|
217
|
+
return /* @__PURE__ */ jsxs(tabs_exports.Tabs.Tab, {
|
|
218
|
+
value,
|
|
219
|
+
"data-allow-literal": true,
|
|
220
|
+
className: clsx$1(className),
|
|
221
|
+
...props,
|
|
222
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
223
|
+
"data-code-tabs-logo": "",
|
|
224
|
+
children: icon ?? /* @__PURE__ */ jsx(BrandLogo, {
|
|
225
|
+
name: language,
|
|
226
|
+
label
|
|
227
|
+
})
|
|
228
|
+
}), children]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The active sample's panel. Matches its `value` to the showing tab; flattens a nested `CodeBlock`'s
|
|
233
|
+
* frame so the sample sits flush (handled by `code-tabs.css`). Renders the `code-tabs-panel` slot.
|
|
234
|
+
*/
|
|
235
|
+
function CodeBlockPanel({ className, ...props }) {
|
|
236
|
+
return /* @__PURE__ */ jsx(tabs_exports.Tabs.Panel, {
|
|
237
|
+
"data-slot": CODE_BLOCK_SLOTS.panel,
|
|
238
|
+
className: clsx$1(className),
|
|
239
|
+
...props
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The code-block family — one composable component. Bare `<CodeBlock>` renders the default composition
|
|
244
|
+
* (a header from the `label`/`language` plus a copy button over the scrollable body); compose the parts
|
|
245
|
+
* for full control: `CodeBlock.Header` (with `CodeBlock.Title` + `CodeBlock.CopyButton`),
|
|
246
|
+
* `CodeBlock.Body`, and `CodeBlock.Tabs` (with `CodeBlock.Tab`s and `CodeBlock.Panel`s) for a tabbed
|
|
247
|
+
* group of samples. Presentation only — syntax highlighting is the caller's concern (Shiki at build
|
|
248
|
+
* time in the docs), so any pre-tokenised `<pre>` drops straight in.
|
|
249
|
+
*
|
|
250
|
+
* The runtime compound is a plain object (kept tree-shakeable); per-part prop types are exposed through
|
|
251
|
+
* the matching `CodeBlock` namespace — e.g. `CodeBlock.Tab.Props`. Each part carries its D12 `props()`
|
|
252
|
+
* escape hatch via `Object.assign`: spread `CodeBlock.Header.props()` onto a foreign element to style
|
|
253
|
+
* it as that part (styling is attribute-driven — `code-block.css` keys off the stamped `data-slot`).
|
|
254
|
+
*/
|
|
255
|
+
const CodeBlock = Object.assign(CodeBlockRoot, {
|
|
256
|
+
Header: Object.assign(CodeBlockHeader, { props: headerProps }),
|
|
257
|
+
Title: Object.assign(CodeBlockTitle, { props: titleProps }),
|
|
258
|
+
CopyButton: CodeBlockCopyButton,
|
|
259
|
+
Body: Object.assign(CodeBlockBody, { props: bodyProps }),
|
|
260
|
+
Tabs: CodeBlockTabs,
|
|
261
|
+
Tab: CodeBlockTab,
|
|
262
|
+
Panel: CodeBlockPanel,
|
|
263
|
+
/** Escape-hatch helper for the frame slot — spread onto an element a `<Surface>` can't wrap. */
|
|
264
|
+
props: frameProps
|
|
265
|
+
});
|
|
266
|
+
//#endregion
|
|
267
|
+
export { CodeBlock };
|