@archytechtor/ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +105 -2
- package/dist/components/accordion/accordion.d.ts +25 -0
- package/dist/components/accordion/accordion.js +88 -0
- package/dist/components/accordion/index.d.ts +3 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/accordion/types.d.ts +39 -0
- package/dist/components/alert/alert.d.ts +25 -0
- package/dist/components/alert/alert.js +59 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/alert/index.js +3 -0
- package/dist/components/alert/types.d.ts +32 -0
- package/dist/components/alert/types.js +19 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +73 -0
- package/dist/components/alert-dialog/alert-dialog.js +170 -0
- package/dist/components/alert-dialog/index.d.ts +3 -0
- package/dist/components/alert-dialog/index.js +1 -0
- package/dist/components/alert-dialog/types.d.ts +80 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +8 -0
- package/dist/components/aspect-ratio/aspect-ratio.js +20 -0
- package/dist/components/aspect-ratio/index.d.ts +3 -0
- package/dist/components/aspect-ratio/index.js +1 -0
- package/dist/components/aspect-ratio/types.d.ts +8 -0
- package/dist/components/attachment/attachment.d.ts +57 -0
- package/dist/components/attachment/attachment.js +139 -0
- package/dist/components/attachment/index.d.ts +3 -0
- package/dist/components/attachment/index.js +3 -0
- package/dist/components/attachment/types.d.ts +79 -0
- package/dist/components/attachment/types.js +43 -0
- package/dist/components/avatar/avatar.d.ts +39 -0
- package/dist/components/avatar/avatar.js +88 -0
- package/dist/components/avatar/index.d.ts +3 -0
- package/dist/components/avatar/index.js +3 -0
- package/dist/components/avatar/types.d.ts +54 -0
- package/dist/components/avatar/types.js +21 -0
- package/dist/components/badge/badge.d.ts +7 -0
- package/dist/components/badge/badge.js +23 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/badge/index.js +3 -0
- package/dist/components/badge/types.d.ts +21 -0
- package/dist/components/badge/types.js +26 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +43 -0
- package/dist/components/breadcrumb/breadcrumb.js +115 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/breadcrumb/types.d.ts +36 -0
- package/dist/components/bubble/bubble.d.ts +25 -0
- package/dist/components/bubble/bubble.js +69 -0
- package/dist/components/bubble/index.d.ts +3 -0
- package/dist/components/bubble/index.js +3 -0
- package/dist/components/bubble/types.d.ts +51 -0
- package/dist/components/bubble/types.js +60 -0
- package/dist/components/button/button.d.ts +7 -0
- package/dist/components/button/button.js +155 -0
- package/dist/components/button/index.d.ts +4 -0
- package/dist/components/button/index.js +4 -0
- package/dist/components/button/types.d.ts +80 -0
- package/dist/components/button/types.js +99 -0
- package/dist/components/button/use-hold-to-confirm.d.ts +25 -0
- package/dist/components/button/use-hold-to-confirm.js +161 -0
- package/dist/components/button-group/button-group.d.ts +20 -0
- package/dist/components/button-group/button-group.js +62 -0
- package/dist/components/button-group/index.d.ts +3 -0
- package/dist/components/button-group/index.js +3 -0
- package/dist/components/button-group/types.d.ts +30 -0
- package/dist/components/button-group/types.js +19 -0
- package/dist/components/calendar/calendar.d.ts +15 -0
- package/dist/components/calendar/calendar.js +157 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/calendar/types.d.ts +21 -0
- package/dist/components/card/card.d.ts +43 -0
- package/dist/components/card/card.js +97 -0
- package/dist/components/card/index.d.ts +3 -0
- package/dist/components/card/index.js +3 -0
- package/dist/components/card/types.d.ts +44 -0
- package/dist/components/card/types.js +19 -0
- package/dist/components/carousel/carousel.d.ts +36 -0
- package/dist/components/carousel/carousel.js +190 -0
- package/dist/components/carousel/index.d.ts +3 -0
- package/dist/components/carousel/index.js +1 -0
- package/dist/components/carousel/types.d.ts +79 -0
- package/dist/components/chart/chart.d.ts +35 -0
- package/dist/components/chart/chart.js +212 -0
- package/dist/components/chart/index.d.ts +3 -0
- package/dist/components/chart/index.js +1 -0
- package/dist/components/chart/types.d.ts +89 -0
- package/dist/components/chart/types.js +7 -0
- package/dist/components/checkbox/checkbox.d.ts +7 -0
- package/dist/components/checkbox/checkbox.js +31 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/checkbox/types.d.ts +25 -0
- package/dist/components/code-block/code-block.d.ts +49 -0
- package/dist/components/code-block/code-block.js +188 -0
- package/dist/components/code-block/highlighter.d.ts +15 -0
- package/dist/components/code-block/highlighter.js +123 -0
- package/dist/components/code-block/index.d.ts +5 -0
- package/dist/components/code-block/index.js +5 -0
- package/dist/components/code-block/types.d.ts +94 -0
- package/dist/components/code-block/types.js +38 -0
- package/dist/components/code-block/use-highlighted-code.d.ts +9 -0
- package/dist/components/code-block/use-highlighted-code.js +67 -0
- package/dist/components/collapsible/collapsible.d.ts +19 -0
- package/dist/components/collapsible/collapsible.js +44 -0
- package/dist/components/collapsible/index.d.ts +3 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/collapsible/types.d.ts +26 -0
- package/dist/components/combobox/combobox.d.ts +104 -0
- package/dist/components/combobox/combobox.js +365 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/combobox/types.d.ts +229 -0
- package/dist/components/command/command.d.ts +55 -0
- package/dist/components/command/command.js +179 -0
- package/dist/components/command/index.d.ts +3 -0
- package/dist/components/command/index.js +1 -0
- package/dist/components/command/types.d.ts +69 -0
- package/dist/components/context-menu/context-menu.d.ts +92 -0
- package/dist/components/context-menu/context-menu.js +270 -0
- package/dist/components/context-menu/index.d.ts +3 -0
- package/dist/components/context-menu/index.js +1 -0
- package/dist/components/context-menu/types.d.ts +138 -0
- package/dist/components/data-table/data-table-features.d.ts +21 -0
- package/dist/components/data-table/data-table-features.js +22 -0
- package/dist/components/data-table/data-table.d.ts +69 -0
- package/dist/components/data-table/data-table.js +283 -0
- package/dist/components/data-table/index.d.ts +4 -0
- package/dist/components/data-table/index.js +3 -0
- package/dist/components/data-table/types.d.ts +63 -0
- package/dist/components/date-input/date-input.d.ts +7 -0
- package/dist/components/date-input/date-input.js +147 -0
- package/dist/components/date-input/index.d.ts +3 -0
- package/dist/components/date-input/index.js +1 -0
- package/dist/components/date-input/types.d.ts +27 -0
- package/dist/components/date-picker/date-picker.d.ts +7 -0
- package/dist/components/date-picker/date-picker.js +74 -0
- package/dist/components/date-picker/index.d.ts +3 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-picker/types.d.ts +38 -0
- package/dist/components/date-range-picker/date-range-picker.d.ts +7 -0
- package/dist/components/date-range-picker/date-range-picker.js +89 -0
- package/dist/components/date-range-picker/index.d.ts +3 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/date-range-picker/types.d.ts +43 -0
- package/dist/components/dialog/dialog.d.ts +61 -0
- package/dist/components/dialog/dialog.js +160 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/dialog/types.d.ts +68 -0
- package/dist/components/drawer/drawer.d.ts +69 -0
- package/dist/components/drawer/drawer.js +245 -0
- package/dist/components/drawer/index.d.ts +3 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/drawer/types.d.ts +93 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +92 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +268 -0
- package/dist/components/dropdown-menu/index.d.ts +3 -0
- package/dist/components/dropdown-menu/index.js +1 -0
- package/dist/components/dropdown-menu/types.d.ts +143 -0
- package/dist/components/empty/empty.d.ts +37 -0
- package/dist/components/empty/empty.js +84 -0
- package/dist/components/empty/index.d.ts +3 -0
- package/dist/components/empty/index.js +3 -0
- package/dist/components/empty/types.d.ts +39 -0
- package/dist/components/empty/types.js +13 -0
- package/dist/components/expanded-card/expanded-card.d.ts +43 -0
- package/dist/components/expanded-card/expanded-card.js +352 -0
- package/dist/components/expanded-card/index.d.ts +3 -0
- package/dist/components/expanded-card/index.js +1 -0
- package/dist/components/expanded-card/types.d.ts +52 -0
- package/dist/components/field/field.d.ts +62 -0
- package/dist/components/field/field.js +173 -0
- package/dist/components/field/index.d.ts +3 -0
- package/dist/components/field/index.js +3 -0
- package/dist/components/field/types.d.ts +81 -0
- package/dist/components/field/types.js +21 -0
- package/dist/components/form/form.d.ts +49 -0
- package/dist/components/form/form.js +136 -0
- package/dist/components/form/index.d.ts +3 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/form/types.d.ts +59 -0
- package/dist/components/hover-card/hover-card.d.ts +19 -0
- package/dist/components/hover-card/hover-card.js +63 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/hover-card/index.js +1 -0
- package/dist/components/hover-card/types.d.ts +27 -0
- package/dist/components/image-gallery/image-gallery.d.ts +8 -0
- package/dist/components/image-gallery/image-gallery.js +294 -0
- package/dist/components/image-gallery/index.d.ts +4 -0
- package/dist/components/image-gallery/index.js +3 -0
- package/dist/components/image-gallery/masonry.d.ts +11 -0
- package/dist/components/image-gallery/masonry.js +62 -0
- package/dist/components/image-gallery/types.d.ts +80 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/input.d.ts +7 -0
- package/dist/components/input/input.js +18 -0
- package/dist/components/input/types.d.ts +28 -0
- package/dist/components/input-group/index.d.ts +3 -0
- package/dist/components/input-group/index.js +3 -0
- package/dist/components/input-group/input-group.d.ts +37 -0
- package/dist/components/input-group/input-group.js +103 -0
- package/dist/components/input-group/types.d.ts +64 -0
- package/dist/components/input-group/types.js +31 -0
- package/dist/components/input-otp/index.d.ts +3 -0
- package/dist/components/input-otp/index.js +1 -0
- package/dist/components/input-otp/input-otp.d.ts +25 -0
- package/dist/components/input-otp/input-otp.js +76 -0
- package/dist/components/input-otp/types.d.ts +43 -0
- package/dist/components/item/index.d.ts +3 -0
- package/dist/components/item/index.js +3 -0
- package/dist/components/item/item.d.ts +61 -0
- package/dist/components/item/item.js +149 -0
- package/dist/components/item/types.d.ts +75 -0
- package/dist/components/item/types.js +48 -0
- package/dist/components/kbd/index.d.ts +3 -0
- package/dist/components/kbd/index.js +1 -0
- package/dist/components/kbd/kbd.d.ts +13 -0
- package/dist/components/kbd/kbd.js +30 -0
- package/dist/components/kbd/types.d.ts +9 -0
- package/dist/components/label/index.d.ts +3 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/label/label.d.ts +7 -0
- package/dist/components/label/label.js +17 -0
- package/dist/components/label/types.d.ts +8 -0
- package/dist/components/loader/index.d.ts +3 -0
- package/dist/components/loader/index.js +3 -0
- package/dist/components/loader/loader.d.ts +8 -0
- package/dist/components/loader/loader.js +386 -0
- package/dist/components/loader/types.d.ts +27 -0
- package/dist/components/loader/types.js +58 -0
- package/dist/components/marker/index.d.ts +3 -0
- package/dist/components/marker/index.js +3 -0
- package/dist/components/marker/marker.d.ts +19 -0
- package/dist/components/marker/marker.js +51 -0
- package/dist/components/marker/types.d.ts +30 -0
- package/dist/components/marker/types.js +16 -0
- package/dist/components/menubar/index.d.ts +3 -0
- package/dist/components/menubar/index.js +1 -0
- package/dist/components/menubar/menubar.d.ts +98 -0
- package/dist/components/menubar/menubar.js +284 -0
- package/dist/components/menubar/types.d.ts +146 -0
- package/dist/components/message/index.d.ts +3 -0
- package/dist/components/message/index.js +1 -0
- package/dist/components/message/message.d.ts +37 -0
- package/dist/components/message/message.js +83 -0
- package/dist/components/message/types.d.ts +32 -0
- package/dist/components/message-scroller/index.d.ts +4 -0
- package/dist/components/message-scroller/index.js +3 -0
- package/dist/components/message-scroller/message-scroller-primitive.d.ts +21 -0
- package/dist/components/message-scroller/message-scroller-primitive.js +1349 -0
- package/dist/components/message-scroller/message-scroller.d.ts +39 -0
- package/dist/components/message-scroller/message-scroller.js +103 -0
- package/dist/components/message-scroller/types.d.ts +107 -0
- package/dist/components/money-input/index.d.ts +3 -0
- package/dist/components/money-input/index.js +1 -0
- package/dist/components/money-input/money-input.d.ts +7 -0
- package/dist/components/money-input/money-input.js +143 -0
- package/dist/components/money-input/types.d.ts +20 -0
- package/dist/components/morph-image/index.d.ts +3 -0
- package/dist/components/morph-image/index.js +3 -0
- package/dist/components/morph-image/morph-image.d.ts +8 -0
- package/dist/components/morph-image/morph-image.js +155 -0
- package/dist/components/morph-image/types.d.ts +38 -0
- package/dist/components/morph-image/types.js +18 -0
- package/dist/components/native-select/index.d.ts +3 -0
- package/dist/components/native-select/index.js +3 -0
- package/dist/components/native-select/native-select.d.ts +20 -0
- package/dist/components/native-select/native-select.js +57 -0
- package/dist/components/native-select/types.d.ts +52 -0
- package/dist/components/native-select/types.js +23 -0
- package/dist/components/navigation-menu/index.d.ts +3 -0
- package/dist/components/navigation-menu/index.js +3 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +50 -0
- package/dist/components/navigation-menu/navigation-menu.js +145 -0
- package/dist/components/navigation-menu/types.d.ts +79 -0
- package/dist/components/navigation-menu/types.js +15 -0
- package/dist/components/number-stepper/index.d.ts +3 -0
- package/dist/components/number-stepper/index.js +3 -0
- package/dist/components/number-stepper/number-stepper.d.ts +9 -0
- package/dist/components/number-stepper/number-stepper.js +223 -0
- package/dist/components/number-stepper/types.d.ts +47 -0
- package/dist/components/number-stepper/types.js +174 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/pagination/pagination.d.ts +43 -0
- package/dist/components/pagination/pagination.js +121 -0
- package/dist/components/pagination/types.d.ts +37 -0
- package/dist/components/phone-input/index.d.ts +3 -0
- package/dist/components/phone-input/index.js +1 -0
- package/dist/components/phone-input/phone-input.d.ts +7 -0
- package/dist/components/phone-input/phone-input.js +54 -0
- package/dist/components/phone-input/types.d.ts +12 -0
- package/dist/components/popover/index.d.ts +3 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/popover/popover.d.ts +37 -0
- package/dist/components/popover/popover.js +100 -0
- package/dist/components/popover/types.d.ts +51 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/progress.d.ts +32 -0
- package/dist/components/progress/progress.js +100 -0
- package/dist/components/progress/types.d.ts +31 -0
- package/dist/components/questionnaire/index.d.ts +3 -0
- package/dist/components/questionnaire/index.js +1 -0
- package/dist/components/questionnaire/questionnaire-primitive.js +1563 -0
- package/dist/components/questionnaire/questionnaire.d.ts +91 -0
- package/dist/components/questionnaire/questionnaire.js +315 -0
- package/dist/components/questionnaire/types.d.ts +203 -0
- package/dist/components/radio-group/index.d.ts +3 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/radio-group/radio-group.d.ts +13 -0
- package/dist/components/radio-group/radio-group.js +44 -0
- package/dist/components/radio-group/types.d.ts +33 -0
- package/dist/components/reorder-list/index.d.ts +3 -0
- package/dist/components/reorder-list/index.js +1 -0
- package/dist/components/reorder-list/reorder-list.d.ts +19 -0
- package/dist/components/reorder-list/reorder-list.js +279 -0
- package/dist/components/reorder-list/types.d.ts +65 -0
- package/dist/components/resizable/index.d.ts +3 -0
- package/dist/components/resizable/index.js +1 -0
- package/dist/components/resizable/resizable.d.ts +19 -0
- package/dist/components/resizable/resizable.js +44 -0
- package/dist/components/resizable/types.d.ts +89 -0
- package/dist/components/scroll-area/index.d.ts +3 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +13 -0
- package/dist/components/scroll-area/scroll-area.js +47 -0
- package/dist/components/scroll-area/types.d.ts +19 -0
- package/dist/components/select/index.d.ts +3 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/select/select.d.ts +61 -0
- package/dist/components/select/select.js +183 -0
- package/dist/components/select/types.d.ts +100 -0
- package/dist/components/separator/index.d.ts +3 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/separator/separator.d.ts +7 -0
- package/dist/components/separator/separator.js +20 -0
- package/dist/components/separator/types.d.ts +9 -0
- package/dist/components/sheet/index.d.ts +3 -0
- package/dist/components/sheet/index.js +1 -0
- package/dist/components/sheet/sheet.d.ts +61 -0
- package/dist/components/sheet/sheet.js +155 -0
- package/dist/components/sheet/types.d.ts +69 -0
- package/dist/components/sidebar/index.d.ts +3 -0
- package/dist/components/sidebar/index.js +3 -0
- package/dist/components/sidebar/sidebar.d.ts +145 -0
- package/dist/components/sidebar/sidebar.js +550 -0
- package/dist/components/sidebar/types.d.ts +186 -0
- package/dist/components/sidebar/types.js +42 -0
- package/dist/components/sidebar/use-mobile.js +21 -0
- package/dist/components/skeleton/index.d.ts +3 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/skeleton.d.ts +8 -0
- package/dist/components/skeleton/skeleton.js +18 -0
- package/dist/components/skeleton/types.d.ts +5 -0
- package/dist/components/slider/index.d.ts +3 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/slider.d.ts +7 -0
- package/dist/components/slider/slider.js +106 -0
- package/dist/components/slider/types.d.ts +39 -0
- package/dist/components/spinner/index.d.ts +3 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.d.ts +7 -0
- package/dist/components/spinner/spinner.js +21 -0
- package/dist/components/spinner/types.d.ts +8 -0
- package/dist/components/switch/index.d.ts +3 -0
- package/dist/components/switch/index.js +3 -0
- package/dist/components/switch/switch.d.ts +7 -0
- package/dist/components/switch/switch.js +32 -0
- package/dist/components/switch/types.d.ts +37 -0
- package/dist/components/switch/types.js +23 -0
- package/dist/components/table/index.d.ts +3 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/table.d.ts +49 -0
- package/dist/components/table/table.js +112 -0
- package/dist/components/table/types.d.ts +33 -0
- package/dist/components/tabs/index.d.ts +3 -0
- package/dist/components/tabs/index.js +3 -0
- package/dist/components/tabs/tabs.d.ts +25 -0
- package/dist/components/tabs/tabs.js +81 -0
- package/dist/components/tabs/types.d.ts +61 -0
- package/dist/components/tabs/types.js +18 -0
- package/dist/components/textarea/index.d.ts +3 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/textarea.d.ts +7 -0
- package/dist/components/textarea/textarea.js +17 -0
- package/dist/components/textarea/types.d.ts +26 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/toast/toast.d.ts +63 -0
- package/dist/components/toast/toast.js +321 -0
- package/dist/components/toast/types.d.ts +120 -0
- package/dist/components/toggle/index.d.ts +3 -0
- package/dist/components/toggle/index.js +3 -0
- package/dist/components/toggle/toggle.d.ts +7 -0
- package/dist/components/toggle/toggle.js +32 -0
- package/dist/components/toggle/types.d.ts +35 -0
- package/dist/components/toggle/types.js +37 -0
- package/dist/components/toggle-group/index.d.ts +3 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/toggle-group/toggle-group.d.ts +13 -0
- package/dist/components/toggle-group/toggle-group.js +88 -0
- package/dist/components/toggle-group/types.d.ts +52 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/tooltip.d.ts +25 -0
- package/dist/components/tooltip/tooltip.js +79 -0
- package/dist/components/tooltip/types.d.ts +48 -0
- package/dist/components/trace/index.d.ts +3 -0
- package/dist/components/trace/index.js +1 -0
- package/dist/components/trace/trace.d.ts +52 -0
- package/dist/components/trace/trace.js +132 -0
- package/dist/components/trace/types.d.ts +54 -0
- package/dist/components/typography/index.d.ts +3 -0
- package/dist/components/typography/index.js +3 -0
- package/dist/components/typography/types.d.ts +29 -0
- package/dist/components/typography/types.js +25 -0
- package/dist/components/typography/typography.d.ts +7 -0
- package/dist/components/typography/typography.js +40 -0
- package/dist/components/video-player/index.d.ts +6 -0
- package/dist/components/video-player/index.js +5 -0
- package/dist/components/video-player/types.d.ts +143 -0
- package/dist/components/video-player/use-video-player.js +319 -0
- package/dist/components/video-player/video-player-context.d.ts +45 -0
- package/dist/components/video-player/video-player-context.js +15 -0
- package/dist/components/video-player/video-player-controls.d.ts +38 -0
- package/dist/components/video-player/video-player-controls.js +226 -0
- package/dist/components/video-player/video-player-overlay.d.ts +13 -0
- package/dist/components/video-player/video-player-overlay.js +113 -0
- package/dist/components/video-player/video-player.d.ts +8 -0
- package/dist/components/video-player/video-player.js +139 -0
- package/dist/index.d.ts +244 -0
- package/dist/index.js +114 -0
- package/dist/lib/floating.d.ts +44 -0
- package/dist/lib/focus-source.js +51 -0
- package/dist/lib/format.d.ts +67 -0
- package/dist/lib/format.js +130 -0
- package/dist/lib/locale.d.ts +104 -0
- package/dist/lib/locale.js +103 -0
- package/dist/lib/part-props.d.ts +15 -0
- package/dist/lib/use-controllable-state.js +22 -0
- package/dist/lib/utils.d.ts +9 -0
- package/dist/lib/utils.js +16 -0
- package/dist/styles/index.css +126 -0
- package/dist/styles/theme.css +80 -0
- package/dist/styles/utilities.css +553 -0
- package/package.json +89 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { CheckIcon, MinusIcon } from "lucide-react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
6
|
+
// src/components/checkbox/checkbox.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Флажок: отметить или снять отметку
|
|
9
|
+
* @param props - пропсы флажка
|
|
10
|
+
* @returns элемент с role=checkbox
|
|
11
|
+
*/
|
|
12
|
+
function Checkbox$1({ className, onCheckedChange, ...props }) {
|
|
13
|
+
const classes = cn("peer", "relative", "flex", "size-4", "shrink-0", "items-center", "justify-center", "rounded-[4px]", "border", "border-input", "transition-colors", "outline-none", "group-has-disabled/field:opacity-50", "keyboard:group-has-[:focus-visible]/field-label:ring-0", "keyboard:group-has-[:focus-visible]/field-label:not-data-checked:border-input", "after:absolute", "after:-inset-x-3", "after:-inset-y-2", "focus-visible:border-ring", "focus-visible:ring-3", "focus-visible:ring-ring/50", "data-disabled:cursor-not-allowed", "data-disabled:opacity-50", "aria-invalid:border-destructive", "aria-invalid:ring-3", "aria-invalid:ring-destructive/20", "aria-invalid:aria-checked:border-primary", "aria-invalid:aria-[checked=mixed]:border-primary", "dark:bg-input/30", "dark:aria-invalid:border-destructive/50", "dark:aria-invalid:ring-destructive/40", "data-checked:border-primary", "data-checked:bg-primary", "data-checked:text-primary-foreground", "dark:data-checked:bg-primary", "keyboard:group-has-[:focus-visible]/field-label:data-checked:border-primary", "data-indeterminate:border-primary", "data-indeterminate:bg-primary", "data-indeterminate:text-primary-foreground", "dark:data-indeterminate:bg-primary", "keyboard:group-has-[:focus-visible]/field-label:data-indeterminate:border-primary", className);
|
|
14
|
+
/**
|
|
15
|
+
* Флажок переключили: наружу только состояние
|
|
16
|
+
* @param checked - отмечен ли
|
|
17
|
+
*/
|
|
18
|
+
const handleCheckedChange = (checked) => onCheckedChange?.(checked);
|
|
19
|
+
return /* @__PURE__ */ jsx(Checkbox.Root, {
|
|
20
|
+
"data-slot": "checkbox",
|
|
21
|
+
className: classes,
|
|
22
|
+
onCheckedChange: handleCheckedChange,
|
|
23
|
+
...props,
|
|
24
|
+
children: /* @__PURE__ */ jsxs(Checkbox.Indicator, {
|
|
25
|
+
"data-slot": "checkbox-indicator",
|
|
26
|
+
className: "group/checkbox-indicator grid place-content-center text-current transition-none [&>svg]:size-3.5",
|
|
27
|
+
children: [/* @__PURE__ */ jsx(CheckIcon, { className: "group-data-indeterminate/checkbox-indicator:hidden" }), /* @__PURE__ */ jsx(MinusIcon, { className: "hidden group-data-indeterminate/checkbox-indicator:block" })]
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { Checkbox$1 as Checkbox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from "./checkbox.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PartPropsT } from "../../lib/part-props.js";
|
|
2
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
3
|
+
/**
|
|
4
|
+
* Пропсы флажка
|
|
5
|
+
*/
|
|
6
|
+
export type CheckboxPropsT = PartPropsT<Omit<Checkbox.Root.Props, 'onCheckedChange' | 'children'>> & {
|
|
7
|
+
/** Отмечен ли флажок — контролируемый режим, вместе с onCheckedChange */
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
/** Отмечен ли флажок при первом рендере — неконтролируемый режим */
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
/** Частично отмечен: черта вместо галочки, например у «выбрать все», когда выбрана часть */
|
|
12
|
+
indeterminate?: boolean;
|
|
13
|
+
/** Флажок отметили или сняли: новое состояние */
|
|
14
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
15
|
+
/** Отключённое состояние: флажок не переключается */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Обязательное поле: форма не отправится, пока флажок не отмечен */
|
|
18
|
+
required?: boolean;
|
|
19
|
+
/** Имя поля при отправке формы */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Значение при отправке формы, по умолчанию on */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** Ошибка: красная рамка и объявление скринридеру, что значение неверное */
|
|
24
|
+
'aria-invalid'?: boolean;
|
|
25
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CodeBlockActionsPropsT, CodeBlockContentPropsT, CodeBlockCopyButtonPropsT, CodeBlockFooterPropsT, CodeBlockHeaderPropsT, CodeBlockLinePropsT, CodeBlockPropsT, CodeBlockTitlePropsT } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Блок кода: код или вывод терминала с шапкой и действиями
|
|
4
|
+
* @param props - пропсы блока
|
|
5
|
+
* @returns блок кода
|
|
6
|
+
*/
|
|
7
|
+
export declare function CodeBlock({ className, variant, size, ...props }: CodeBlockPropsT): import("react").JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Шапка блока кода: заголовок и действия
|
|
10
|
+
* @param props - пропсы шапки
|
|
11
|
+
* @returns шапка
|
|
12
|
+
*/
|
|
13
|
+
export declare function CodeBlockHeader({ className, ...props }: CodeBlockHeaderPropsT): import("react").JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Заголовок блока кода: имя файла, иконка
|
|
16
|
+
* @param props - пропсы заголовка
|
|
17
|
+
* @returns заголовок в одну строку
|
|
18
|
+
*/
|
|
19
|
+
export declare function CodeBlockTitle({ className, ...props }: CodeBlockTitlePropsT): import("react").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* Действия блока кода: в шапке — справа, прямо в блоке — плавают в углу и появляются при наведении
|
|
22
|
+
* @param props - пропсы действий
|
|
23
|
+
* @returns блок действий
|
|
24
|
+
*/
|
|
25
|
+
export declare function CodeBlockActions({ className, ...props }: CodeBlockActionsPropsT): import("react").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Кнопка копирования: копирует value и на 2 секунды показывает галочку
|
|
28
|
+
* @param props - пропсы кнопки
|
|
29
|
+
* @returns кнопка и объявление для скринридера
|
|
30
|
+
*/
|
|
31
|
+
export declare function CodeBlockCopyButton({ value, variant, size, copyLabel, copiedLabel, className, onClick, ...props }: CodeBlockCopyButtonPropsT): import("react").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Содержимое блока кода: <pre> с прокруткой, фокусируется с клавиатуры для прокрутки стрелками
|
|
34
|
+
* @param props - пропсы содержимого
|
|
35
|
+
* @returns код
|
|
36
|
+
*/
|
|
37
|
+
export declare function CodeBlockContent({ className, children, style, wrap, lineNumbers, startLine, ...props }: CodeBlockContentPropsT): import("react").JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* Строка кода: номер строки и отметка изменения рисуются псевдоэлементами
|
|
40
|
+
* @param props - пропсы строки
|
|
41
|
+
* @returns строка
|
|
42
|
+
*/
|
|
43
|
+
export declare function CodeBlockLine({ className, variant, children, ...props }: CodeBlockLinePropsT): import("react").JSX.Element;
|
|
44
|
+
/**
|
|
45
|
+
* Подвал блока кода: кнопка «Показать полностью», подпись
|
|
46
|
+
* @param props - пропсы подвала
|
|
47
|
+
* @returns подвал
|
|
48
|
+
*/
|
|
49
|
+
export declare function CodeBlockFooter({ className, ...props }: CodeBlockFooterPropsT): import("react").JSX.Element;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { texts } from "../../lib/locale.js";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { codeBlockLineVariants, codeBlockVariants } from "./types.js";
|
|
6
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
// src/components/code-block/code-block.tsx
|
|
10
|
+
/** Сколько миллисекунд показывать отметку «Скопировано» */
|
|
11
|
+
const COPIED_TIMEOUT = 2e3;
|
|
12
|
+
/**
|
|
13
|
+
* Блок кода: код или вывод терминала с шапкой и действиями
|
|
14
|
+
* @param props - пропсы блока
|
|
15
|
+
* @returns блок кода
|
|
16
|
+
*/
|
|
17
|
+
function CodeBlock({ className, variant = "default", size = "default", ...props }) {
|
|
18
|
+
const classes = cn(codeBlockVariants({ variant }), className);
|
|
19
|
+
return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
"data-slot": "code-block",
|
|
21
|
+
"data-variant": variant,
|
|
22
|
+
"data-size": size,
|
|
23
|
+
className: classes,
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Шапка блока кода: заголовок и действия
|
|
29
|
+
* @param props - пропсы шапки
|
|
30
|
+
* @returns шапка
|
|
31
|
+
*/
|
|
32
|
+
function CodeBlockHeader({ className, ...props }) {
|
|
33
|
+
const classes = cn("flex", "min-w-0", "shrink-0", "items-center", "gap-2", "px-3", "pt-3", "text-muted-foreground", "*:has-[>[data-slot=code-block-title]]:min-w-0", "group-data-[variant=destructive]/code-block:text-destructive", "group-data-[size=sm]/code-block:px-2.5", "group-data-[size=sm]/code-block:pt-2.5", className);
|
|
34
|
+
return /* @__PURE__ */ jsx("div", {
|
|
35
|
+
"data-slot": "code-block-header",
|
|
36
|
+
className: classes,
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Заголовок блока кода: имя файла, иконка
|
|
42
|
+
* @param props - пропсы заголовка
|
|
43
|
+
* @returns заголовок в одну строку
|
|
44
|
+
*/
|
|
45
|
+
function CodeBlockTitle({ className, ...props }) {
|
|
46
|
+
const classes = cn("min-w-0", "truncate", "font-sans", "text-sm", "font-medium", "text-foreground", "group-data-[variant=destructive]/code-block:text-destructive", "group-data-[size=sm]/code-block:text-xs", "[&_svg]:pointer-events-none", "[&_svg]:inline-block", "[&_svg]:align-middle", "*:[svg]:me-1.5", "[&_svg:not([class*=size-])]:size-3.5", className);
|
|
47
|
+
return /* @__PURE__ */ jsx("div", {
|
|
48
|
+
"data-slot": "code-block-title",
|
|
49
|
+
className: classes,
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Действия блока кода: в шапке — справа, прямо в блоке — плавают в углу и появляются при наведении
|
|
55
|
+
* @param props - пропсы действий
|
|
56
|
+
* @returns блок действий
|
|
57
|
+
*/
|
|
58
|
+
function CodeBlockActions({ className, ...props }) {
|
|
59
|
+
const classes = cn("ms-auto", "-my-1", "-me-1.5", "flex", "shrink-0", "items-center", "gap-1", "[[data-slot=code-block]>&]:absolute", "[[data-slot=code-block]>&]:end-2", "[[data-slot=code-block]>&]:top-2", "[[data-slot=code-block]>&]:z-10", "[[data-slot=code-block]>&]:m-0", "[[data-slot=code-block]>&]:opacity-0", "[[data-slot=code-block]>&]:transition-opacity", "[[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100", "[[data-slot=code-block]>&]:group-hover/code-block:opacity-100", "[[data-slot=code-block]>&]:pointer-coarse:opacity-100", "group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5", "group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5", "[[data-slot=code-block]>&]:*:[button]:bg-background", "[[data-slot=code-block]>&]:*:[button]:ring-1", "[[data-slot=code-block]>&]:*:[button]:ring-foreground/10", className);
|
|
60
|
+
return /* @__PURE__ */ jsx("div", {
|
|
61
|
+
"data-slot": "code-block-actions",
|
|
62
|
+
className: classes,
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Кнопка копирования: копирует value и на 2 секунды показывает галочку
|
|
68
|
+
* @param props - пропсы кнопки
|
|
69
|
+
* @returns кнопка и объявление для скринридера
|
|
70
|
+
*/
|
|
71
|
+
function CodeBlockCopyButton({ value, variant = "ghost", size = "icon-xs", copyLabel = texts.copy, copiedLabel = texts.copied, className, onClick, ...props }) {
|
|
72
|
+
const [isCopied, setCopied] = useState(false);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!isCopied) return;
|
|
75
|
+
const timeout = setTimeout(() => setCopied(false), COPIED_TIMEOUT);
|
|
76
|
+
return () => clearTimeout(timeout);
|
|
77
|
+
}, [isCopied]);
|
|
78
|
+
/**
|
|
79
|
+
* Нажатие: вызвать onClick и скопировать значение
|
|
80
|
+
* @param event - событие нажатия
|
|
81
|
+
*/
|
|
82
|
+
const copyValue = (event) => {
|
|
83
|
+
onClick?.(event);
|
|
84
|
+
navigator.clipboard.writeText(value).then(() => setCopied(true)).catch(() => void 0);
|
|
85
|
+
};
|
|
86
|
+
const label = isCopied ? copiedLabel : copyLabel;
|
|
87
|
+
const announcement = isCopied ? copiedLabel : "";
|
|
88
|
+
const icon = isCopied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {});
|
|
89
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
90
|
+
"data-slot": "code-block-copy-button",
|
|
91
|
+
"data-copied": isCopied || void 0,
|
|
92
|
+
variant,
|
|
93
|
+
size,
|
|
94
|
+
"aria-label": label,
|
|
95
|
+
className,
|
|
96
|
+
onClick: copyValue,
|
|
97
|
+
...props,
|
|
98
|
+
children: icon
|
|
99
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
100
|
+
"aria-live": "polite",
|
|
101
|
+
className: "sr-only",
|
|
102
|
+
children: announcement
|
|
103
|
+
})] });
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Пустая ли строка: пустая строка хранит перевод строки, чтобы при копировании выделения
|
|
107
|
+
* пустые строки не терялись
|
|
108
|
+
* @param children - содержимое строки
|
|
109
|
+
* @returns true, если содержимого нет
|
|
110
|
+
*/
|
|
111
|
+
function isEmptyLine(children) {
|
|
112
|
+
if (children === void 0 || children === null || children === "") return true;
|
|
113
|
+
return Array.isArray(children) && children.length === 0;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Разбить текст на строки кода, чтобы показать номера строк
|
|
117
|
+
* @param text - код
|
|
118
|
+
* @returns строки
|
|
119
|
+
*/
|
|
120
|
+
function splitLines(text) {
|
|
121
|
+
const lines = [];
|
|
122
|
+
text.replace(/\n$/, "").split("\n").forEach((row, index) => {
|
|
123
|
+
lines.push(/* @__PURE__ */ jsx(CodeBlockLine, { children: row }, index));
|
|
124
|
+
});
|
|
125
|
+
return lines;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Содержимое блока кода: <pre> с прокруткой, фокусируется с клавиатуры для прокрутки стрелками
|
|
129
|
+
* @param props - пропсы содержимого
|
|
130
|
+
* @returns код
|
|
131
|
+
*/
|
|
132
|
+
function CodeBlockContent({ className, children, style, wrap = false, lineNumbers = false, startLine = 1, ...props }) {
|
|
133
|
+
const classes = cn("min-h-0", "min-w-0", "overflow-auto", "px-3", "py-3", "text-start", "font-mono", "leading-relaxed", "outline-none", "scroll-fade-x", "[scrollbar-width:thin]", "data-wrap:scroll-fade-y", "data-wrap:wrap-break-word", "data-wrap:whitespace-pre-wrap", "group-has-data-[slot=code-block-header]/code-block:pt-2", "group-has-data-[slot=code-block-footer]/code-block:pb-2", "group-data-[size=sm]/code-block:px-2.5", "group-data-[size=sm]/code-block:py-2.5", "group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5", className);
|
|
134
|
+
const codeClasses = cn("grid", "min-h-lh", "min-w-max", "content-start", "in-data-numbered:grid-cols-[auto_1fr]", "in-data-wrap:min-w-0");
|
|
135
|
+
const counterReset = `line ${startLine - 1}`;
|
|
136
|
+
const content = lineNumbers && typeof children === "string" ? splitLines(children) : children;
|
|
137
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
138
|
+
"data-slot": "code-block-content",
|
|
139
|
+
"data-wrap": wrap || void 0,
|
|
140
|
+
"data-numbered": lineNumbers || void 0,
|
|
141
|
+
tabIndex: 0,
|
|
142
|
+
style: {
|
|
143
|
+
counterReset,
|
|
144
|
+
...style
|
|
145
|
+
},
|
|
146
|
+
className: classes,
|
|
147
|
+
...props,
|
|
148
|
+
children: /* @__PURE__ */ jsx("code", {
|
|
149
|
+
"data-slot": "code-block-code",
|
|
150
|
+
className: codeClasses,
|
|
151
|
+
children: content
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Строка кода: номер строки и отметка изменения рисуются псевдоэлементами
|
|
157
|
+
* @param props - пропсы строки
|
|
158
|
+
* @returns строка
|
|
159
|
+
*/
|
|
160
|
+
function CodeBlockLine({ className, variant = "default", children, ...props }) {
|
|
161
|
+
const classes = cn(codeBlockLineVariants({ variant }), className);
|
|
162
|
+
const content = isEmptyLine(children) ? "\n" : children;
|
|
163
|
+
return /* @__PURE__ */ jsx("span", {
|
|
164
|
+
"data-slot": "code-block-line",
|
|
165
|
+
"data-variant": variant,
|
|
166
|
+
className: classes,
|
|
167
|
+
...props,
|
|
168
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
169
|
+
"data-slot": "code-block-line-content",
|
|
170
|
+
className: "min-w-0",
|
|
171
|
+
children: content
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Подвал блока кода: кнопка «Показать полностью», подпись
|
|
177
|
+
* @param props - пропсы подвала
|
|
178
|
+
* @returns подвал
|
|
179
|
+
*/
|
|
180
|
+
function CodeBlockFooter({ className, ...props }) {
|
|
181
|
+
const classes = cn("flex", "min-w-0", "shrink-0", "items-center", "gap-2", "px-3", "pb-3", "text-muted-foreground", "group-data-[size=sm]/code-block:px-2.5", "group-data-[size=sm]/code-block:pb-2.5", className);
|
|
182
|
+
return /* @__PURE__ */ jsx("div", {
|
|
183
|
+
"data-slot": "code-block-footer",
|
|
184
|
+
className: classes,
|
|
185
|
+
...props
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CodeHighlighterI } from "./types.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Загрузить язык и вернуть подсветку для него
|
|
5
|
+
* @param language - имя языка: ts, tsx, json, bash, ansi…
|
|
6
|
+
* @returns подсветка или null для языка не из списка
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadHighlighter(language: string): Promise<CodeHighlighterI | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Подсветить код целиком
|
|
11
|
+
* @param code - код
|
|
12
|
+
* @param language - имя языка
|
|
13
|
+
* @returns по узлу React на строку или null для языка не из списка
|
|
14
|
+
*/
|
|
15
|
+
export declare function highlightCode(code: string, language: string): Promise<ReactNode[] | null>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createHighlighterCore } from "shiki/core";
|
|
3
|
+
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
4
|
+
// src/components/code-block/highlighter.tsx
|
|
5
|
+
/** Поддерживаемые языки: каждый загружается при первом использовании */
|
|
6
|
+
const languages = {
|
|
7
|
+
bash: () => import("shiki/langs/shellscript.mjs"),
|
|
8
|
+
css: () => import("shiki/langs/css.mjs"),
|
|
9
|
+
diff: () => import("shiki/langs/diff.mjs"),
|
|
10
|
+
html: () => import("shiki/langs/html.mjs"),
|
|
11
|
+
javascript: () => import("shiki/langs/javascript.mjs"),
|
|
12
|
+
json: () => import("shiki/langs/json.mjs"),
|
|
13
|
+
jsx: () => import("shiki/langs/jsx.mjs"),
|
|
14
|
+
markdown: () => import("shiki/langs/markdown.mjs"),
|
|
15
|
+
python: () => import("shiki/langs/python.mjs"),
|
|
16
|
+
sql: () => import("shiki/langs/sql.mjs"),
|
|
17
|
+
tsx: () => import("shiki/langs/tsx.mjs"),
|
|
18
|
+
typescript: () => import("shiki/langs/typescript.mjs"),
|
|
19
|
+
yaml: () => import("shiki/langs/yaml.mjs")
|
|
20
|
+
};
|
|
21
|
+
/** Другие имена языков */
|
|
22
|
+
const aliases = {
|
|
23
|
+
js: "javascript",
|
|
24
|
+
md: "markdown",
|
|
25
|
+
py: "python",
|
|
26
|
+
sh: "bash",
|
|
27
|
+
shell: "bash",
|
|
28
|
+
shellscript: "bash",
|
|
29
|
+
ts: "typescript",
|
|
30
|
+
yml: "yaml",
|
|
31
|
+
zsh: "bash"
|
|
32
|
+
};
|
|
33
|
+
let highlighterPromise;
|
|
34
|
+
/**
|
|
35
|
+
* Получить общий экземпляр shiki со светлой и тёмной темой
|
|
36
|
+
* @returns экземпляр shiki
|
|
37
|
+
*/
|
|
38
|
+
function getHighlighter() {
|
|
39
|
+
highlighterPromise ??= createHighlighterCore({
|
|
40
|
+
themes: [import("shiki/themes/one-light.mjs"), import("shiki/themes/one-dark-pro.mjs")],
|
|
41
|
+
langs: [],
|
|
42
|
+
engine: createJavaScriptRegexEngine({ forgiving: true })
|
|
43
|
+
});
|
|
44
|
+
return highlighterPromise;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Найти язык по имени или псевдониму
|
|
48
|
+
* @param language - имя языка
|
|
49
|
+
* @returns язык, ansi или null, если язык не поддерживается
|
|
50
|
+
*/
|
|
51
|
+
function getLanguage(language) {
|
|
52
|
+
const name = language.toLowerCase();
|
|
53
|
+
if (name === "ansi") return name;
|
|
54
|
+
if (name in languages) return name;
|
|
55
|
+
return aliases[name] ?? null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Отрисовать строку токенов: цвет светлой и тёмной темы в CSS-переменных
|
|
59
|
+
* @param line - токены строки
|
|
60
|
+
* @returns узлы строки
|
|
61
|
+
*/
|
|
62
|
+
function renderLine(line) {
|
|
63
|
+
const nodes = [];
|
|
64
|
+
line.forEach((token, index) => {
|
|
65
|
+
nodes.push(/* @__PURE__ */ jsx("span", {
|
|
66
|
+
style: token.htmlStyle,
|
|
67
|
+
className: "text-(--shiki-light) dark:text-(--shiki-dark)",
|
|
68
|
+
children: token.content
|
|
69
|
+
}, index));
|
|
70
|
+
});
|
|
71
|
+
return nodes;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Загрузить язык и вернуть подсветку для него
|
|
75
|
+
* @param language - имя языка: ts, tsx, json, bash, ansi…
|
|
76
|
+
* @returns подсветка или null для языка не из списка
|
|
77
|
+
*/
|
|
78
|
+
async function loadHighlighter(language) {
|
|
79
|
+
const lang = getLanguage(language);
|
|
80
|
+
if (lang === null) return null;
|
|
81
|
+
const shiki = await getHighlighter();
|
|
82
|
+
if (lang !== "ansi" && !shiki.getLoadedLanguages().includes(lang)) await shiki.loadLanguage(languages[lang]);
|
|
83
|
+
/**
|
|
84
|
+
* Подсветить код
|
|
85
|
+
* @param code - код
|
|
86
|
+
* @param state - состояние грамматики, с которого продолжить
|
|
87
|
+
* @returns строки и состояние грамматики после последней
|
|
88
|
+
*/
|
|
89
|
+
const highlight = (code, state) => {
|
|
90
|
+
/**
|
|
91
|
+
* Разбить текст на токены
|
|
92
|
+
* @param text - текст
|
|
93
|
+
* @returns строки токенов
|
|
94
|
+
*/
|
|
95
|
+
const tokenize = (text) => shiki.codeToTokens(text, {
|
|
96
|
+
lang,
|
|
97
|
+
themes: {
|
|
98
|
+
light: "one-light",
|
|
99
|
+
dark: "one-dark-pro"
|
|
100
|
+
},
|
|
101
|
+
defaultColor: false,
|
|
102
|
+
grammarState: state
|
|
103
|
+
}).tokens;
|
|
104
|
+
const tokens = lang === "ansi" ? code.split("\n").flatMap((line) => tokenize(line)) : tokenize(code);
|
|
105
|
+
return {
|
|
106
|
+
lines: tokens.map(renderLine),
|
|
107
|
+
state: shiki.getLastGrammarState(tokens)
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
return { highlight };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Подсветить код целиком
|
|
114
|
+
* @param code - код
|
|
115
|
+
* @param language - имя языка
|
|
116
|
+
* @returns по узлу React на строку или null для языка не из списка
|
|
117
|
+
*/
|
|
118
|
+
async function highlightCode(code, language) {
|
|
119
|
+
const highlighter = await loadHighlighter(language);
|
|
120
|
+
if (highlighter === null) return null;
|
|
121
|
+
return highlighter.highlight(code).lines;
|
|
122
|
+
}
|
|
123
|
+
export { highlightCode, loadHighlighter };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CodeBlockActionsPropsT, CodeBlockContentPropsT, CodeBlockCopyButtonPropsT, CodeBlockFooterPropsT, CodeBlockHeaderPropsT, CodeBlockLinePropsT, CodeBlockPropsT, CodeBlockTitlePropsT, CodeHighlighterI, HighlightResultI, codeBlockLineVariants, codeBlockVariants } from "./types.js";
|
|
2
|
+
import { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle } from "./code-block.js";
|
|
3
|
+
import { highlightCode, loadHighlighter } from "./highlighter.js";
|
|
4
|
+
import { useHighlightedCode } from "./use-highlighted-code.js";
|
|
5
|
+
export { CodeBlock, CodeBlockActions, type CodeBlockActionsPropsT, CodeBlockContent, type CodeBlockContentPropsT, CodeBlockCopyButton, type CodeBlockCopyButtonPropsT, CodeBlockFooter, type CodeBlockFooterPropsT, CodeBlockHeader, type CodeBlockHeaderPropsT, CodeBlockLine, type CodeBlockLinePropsT, type CodeBlockPropsT, CodeBlockTitle, type CodeBlockTitlePropsT, type CodeHighlighterI, type HighlightResultI, codeBlockLineVariants, codeBlockVariants, highlightCode, loadHighlighter, useHighlightedCode };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { codeBlockLineVariants, codeBlockVariants } from "./types.js";
|
|
2
|
+
import { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle } from "./code-block.js";
|
|
3
|
+
import { highlightCode, loadHighlighter } from "./highlighter.js";
|
|
4
|
+
import { useHighlightedCode } from "./use-highlighted-code.js";
|
|
5
|
+
export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle, codeBlockLineVariants, codeBlockVariants, highlightCode, loadHighlighter, useHighlightedCode };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ButtonPropsT } from "../button/types.js";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
import { GrammarState } from "shiki/core";
|
|
5
|
+
/**
|
|
6
|
+
* Стили блока кода: обычный или блок ошибки
|
|
7
|
+
*/
|
|
8
|
+
export declare const codeBlockVariants: (props?: ({
|
|
9
|
+
variant?: "default" | "destructive" | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Стили строки кода: обычная, подсвеченная, добавленная или удалённая
|
|
13
|
+
*/
|
|
14
|
+
export declare const codeBlockLineVariants: (props?: ({
|
|
15
|
+
variant?: "default" | "added" | "removed" | "highlighted" | null | undefined;
|
|
16
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Вариант оформления блока кода
|
|
19
|
+
*/
|
|
20
|
+
export type CodeBlockVariantsT = VariantProps<typeof codeBlockVariants>;
|
|
21
|
+
/**
|
|
22
|
+
* Вариант строки кода
|
|
23
|
+
*/
|
|
24
|
+
export type CodeBlockLineVariantsT = VariantProps<typeof codeBlockLineVariants>;
|
|
25
|
+
/**
|
|
26
|
+
* Пропсы блока кода
|
|
27
|
+
*/
|
|
28
|
+
export type CodeBlockPropsT = ComponentProps<'div'> & {
|
|
29
|
+
/** Оформление: default — обычный код, destructive — вывод ошибки */
|
|
30
|
+
variant?: CodeBlockVariantsT['variant'];
|
|
31
|
+
/** Размер: default или sm — мельче шрифт и отступы */
|
|
32
|
+
size?: 'default' | 'sm';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Пропсы шапки блока кода
|
|
36
|
+
*/
|
|
37
|
+
export type CodeBlockHeaderPropsT = ComponentProps<'div'>;
|
|
38
|
+
/**
|
|
39
|
+
* Пропсы заголовка блока кода
|
|
40
|
+
*/
|
|
41
|
+
export type CodeBlockTitlePropsT = ComponentProps<'div'>;
|
|
42
|
+
/**
|
|
43
|
+
* Пропсы действий блока кода
|
|
44
|
+
*/
|
|
45
|
+
export type CodeBlockActionsPropsT = ComponentProps<'div'>;
|
|
46
|
+
/**
|
|
47
|
+
* Пропсы кнопки копирования
|
|
48
|
+
*/
|
|
49
|
+
export type CodeBlockCopyButtonPropsT = ButtonPropsT & {
|
|
50
|
+
/** Текст, который копируется в буфер обмена */
|
|
51
|
+
value: string;
|
|
52
|
+
/** Подпись кнопки для скринридера, по умолчанию «Копировать» */
|
|
53
|
+
copyLabel?: string;
|
|
54
|
+
/** Подпись после копирования и объявление для скринридера, по умолчанию «Скопировано» */
|
|
55
|
+
copiedLabel?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Пропсы содержимого блока кода
|
|
59
|
+
*/
|
|
60
|
+
export type CodeBlockContentPropsT = ComponentProps<'pre'> & {
|
|
61
|
+
/** Переносить длинные строки вместо горизонтальной прокрутки */
|
|
62
|
+
wrap?: boolean;
|
|
63
|
+
/** Показывать номера строк */
|
|
64
|
+
lineNumbers?: boolean;
|
|
65
|
+
/** Номер первой строки, по умолчанию 1 */
|
|
66
|
+
startLine?: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Пропсы строки кода
|
|
70
|
+
*/
|
|
71
|
+
export type CodeBlockLinePropsT = ComponentProps<'span'> & {
|
|
72
|
+
/** Оформление: default, highlighted — подсвечена, added — добавлена (+), removed — удалена (−) */
|
|
73
|
+
variant?: CodeBlockLineVariantsT['variant'];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Пропсы подвала блока кода
|
|
77
|
+
*/
|
|
78
|
+
export type CodeBlockFooterPropsT = ComponentProps<'div'>;
|
|
79
|
+
/**
|
|
80
|
+
* Результат подсветки
|
|
81
|
+
* @property lines - по узлу React на строку
|
|
82
|
+
* @property state - состояние грамматики после последней строки: продолжить подсветку с того же места
|
|
83
|
+
*/
|
|
84
|
+
export interface HighlightResultI {
|
|
85
|
+
lines: ReactNode[];
|
|
86
|
+
state?: GrammarState;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Подсветка для одного языка
|
|
90
|
+
* @property highlight - подсветить код, продолжая с состояния грамматики
|
|
91
|
+
*/
|
|
92
|
+
export interface CodeHighlighterI {
|
|
93
|
+
highlight: (code: string, state?: GrammarState) => HighlightResultI;
|
|
94
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
// src/components/code-block/types.ts
|
|
3
|
+
/**
|
|
4
|
+
* Стили блока кода: обычный или блок ошибки
|
|
5
|
+
*/
|
|
6
|
+
const codeBlockVariants = cva([
|
|
7
|
+
"group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm",
|
|
8
|
+
"data-[size=sm]:text-xs",
|
|
9
|
+
"keyboard:has-[>[data-slot=code-block-content]:focus-visible]:ring-3",
|
|
10
|
+
"keyboard:has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50"
|
|
11
|
+
], {
|
|
12
|
+
variants: { variant: {
|
|
13
|
+
default: "bg-muted text-foreground ring-1 ring-foreground/5 dark:ring-foreground/10",
|
|
14
|
+
destructive: ["bg-destructive/5 text-destructive ring-1 ring-destructive/15", "dark:bg-destructive/10 dark:ring-destructive/20"]
|
|
15
|
+
} },
|
|
16
|
+
defaultVariants: { variant: "default" }
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Стили строки кода: обычная, подсвеченная, добавленная или удалённая
|
|
20
|
+
*/
|
|
21
|
+
const codeBlockLineVariants = cva([
|
|
22
|
+
"relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5",
|
|
23
|
+
"after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none",
|
|
24
|
+
"in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3",
|
|
25
|
+
"in-data-numbered:[counter-increment:line]",
|
|
26
|
+
"in-data-numbered:before:min-w-6 in-data-numbered:before:text-end in-data-numbered:before:text-muted-foreground",
|
|
27
|
+
"in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none",
|
|
28
|
+
"in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']"
|
|
29
|
+
], {
|
|
30
|
+
variants: { variant: {
|
|
31
|
+
default: "",
|
|
32
|
+
added: "bg-foreground/5 after:content-['+']",
|
|
33
|
+
removed: "bg-destructive/10 after:text-destructive after:content-['−']",
|
|
34
|
+
highlighted: "bg-foreground/5"
|
|
35
|
+
} },
|
|
36
|
+
defaultVariants: { variant: "default" }
|
|
37
|
+
});
|
|
38
|
+
export { codeBlockLineVariants, codeBlockVariants };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Подсветить код по строкам. Пока язык загружается — строки без подсветки.
|
|
4
|
+
* При потоковом коде подсвечиваются только новые строки, начиная с состояния последней
|
|
5
|
+
* @param value - код
|
|
6
|
+
* @param language - имя языка: ts, tsx, json, bash, ansi…
|
|
7
|
+
* @returns по узлу React на строку — для CodeBlockLine
|
|
8
|
+
*/
|
|
9
|
+
export declare function useHighlightedCode(value: string, language: string): ReactNode[];
|