@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,39 @@
|
|
|
1
|
+
import { MessageScrollerButtonPropsT, MessageScrollerContentPropsT, MessageScrollerItemPropsT, MessageScrollerPropsT, MessageScrollerProviderPropsT, MessageScrollerViewportPropsT } from "./types.js";
|
|
2
|
+
import { useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility } from "./message-scroller-primitive.js";
|
|
3
|
+
/**
|
|
4
|
+
* Провайдер ленты сообщений: нужен, когда хуки прокрутки используются вне MessageScroller
|
|
5
|
+
* @param props - пропсы провайдера
|
|
6
|
+
* @returns контекст ленты
|
|
7
|
+
*/
|
|
8
|
+
export declare function MessageScrollerProvider(props: MessageScrollerProviderPropsT): import("react").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* Лента сообщений: корень с прокручиваемой областью и кнопками прокрутки
|
|
11
|
+
* @param props - пропсы корня
|
|
12
|
+
* @returns корень ленты
|
|
13
|
+
*/
|
|
14
|
+
export declare function MessageScroller({ className, ...props }: MessageScrollerPropsT): import("react").JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* Прокручиваемая область ленты: фокусируется и прокручивается с клавиатуры
|
|
17
|
+
* @param props - пропсы области
|
|
18
|
+
* @returns область прокрутки
|
|
19
|
+
*/
|
|
20
|
+
export declare function MessageScrollerViewport({ className, 'aria-label': ariaLabel, ...props }: MessageScrollerViewportPropsT): import("react").JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Содержимое ленты: колонка сообщений, объявляет новые сообщения скринридеру (role=log)
|
|
23
|
+
* @param props - пропсы содержимого
|
|
24
|
+
* @returns колонка сообщений
|
|
25
|
+
*/
|
|
26
|
+
export declare function MessageScrollerContent({ className, ...props }: MessageScrollerContentPropsT): import("react").JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* Элемент ленты: сообщение или группа сообщений
|
|
29
|
+
* @param props - пропсы элемента
|
|
30
|
+
* @returns элемент ленты
|
|
31
|
+
*/
|
|
32
|
+
export declare function MessageScrollerItem({ className, scrollAnchor, ...props }: MessageScrollerItemPropsT): import("react").JSX.Element;
|
|
33
|
+
/**
|
|
34
|
+
* Кнопка прокрутки: появляется, когда есть куда прокручивать
|
|
35
|
+
* @param props - пропсы кнопки
|
|
36
|
+
* @returns кнопка
|
|
37
|
+
*/
|
|
38
|
+
export declare function MessageScrollerButton({ direction, className, children, variant, size, label, ...props }: MessageScrollerButtonPropsT): import("react").JSX.Element;
|
|
39
|
+
export { useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { MessageScrollerPrimitive, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility } from "./message-scroller-primitive.js";
|
|
5
|
+
import { ArrowDownIcon } from "lucide-react";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/message-scroller/message-scroller.tsx
|
|
8
|
+
/** Подпись области сообщений для скринридера по умолчанию */
|
|
9
|
+
const VIEWPORT_LABEL = "Сообщения";
|
|
10
|
+
/** Подпись кнопки «в конец» по умолчанию */
|
|
11
|
+
const SCROLL_TO_END_LABEL = "Прокрутить в конец";
|
|
12
|
+
/** Подпись кнопки «в начало» по умолчанию */
|
|
13
|
+
const SCROLL_TO_START_LABEL = "Прокрутить в начало";
|
|
14
|
+
/**
|
|
15
|
+
* Провайдер ленты сообщений: нужен, когда хуки прокрутки используются вне MessageScroller
|
|
16
|
+
* @param props - пропсы провайдера
|
|
17
|
+
* @returns контекст ленты
|
|
18
|
+
*/
|
|
19
|
+
function MessageScrollerProvider(props) {
|
|
20
|
+
return /* @__PURE__ */ jsx(MessageScrollerPrimitive.Provider, { ...props });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Лента сообщений: корень с прокручиваемой областью и кнопками прокрутки
|
|
24
|
+
* @param props - пропсы корня
|
|
25
|
+
* @returns корень ленты
|
|
26
|
+
*/
|
|
27
|
+
function MessageScroller({ className, ...props }) {
|
|
28
|
+
const classes = cn("group/message-scroller", "relative", "flex", "size-full", "min-h-0", "flex-col", "overflow-hidden", className);
|
|
29
|
+
return /* @__PURE__ */ jsx(MessageScrollerPrimitive.Root, {
|
|
30
|
+
"data-slot": "message-scroller",
|
|
31
|
+
className: classes,
|
|
32
|
+
...props
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Прокручиваемая область ленты: фокусируется и прокручивается с клавиатуры
|
|
37
|
+
* @param props - пропсы области
|
|
38
|
+
* @returns область прокрутки
|
|
39
|
+
*/
|
|
40
|
+
function MessageScrollerViewport({ className, "aria-label": ariaLabel = VIEWPORT_LABEL, ...props }) {
|
|
41
|
+
const classes = cn("size-full", "min-h-0", "min-w-0", "scroll-fade-b", "overflow-y-auto", "overscroll-contain", "[contain:content]", "[scrollbar-gutter:stable]", "[scrollbar-width:thin]", "data-autoscrolling:[scrollbar-color:transparent_transparent]", "data-pending-scroll:invisible", className);
|
|
42
|
+
return /* @__PURE__ */ jsx(MessageScrollerPrimitive.Viewport, {
|
|
43
|
+
"data-slot": "message-scroller-viewport",
|
|
44
|
+
"aria-label": ariaLabel,
|
|
45
|
+
className: classes,
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Содержимое ленты: колонка сообщений, объявляет новые сообщения скринридеру (role=log)
|
|
51
|
+
* @param props - пропсы содержимого
|
|
52
|
+
* @returns колонка сообщений
|
|
53
|
+
*/
|
|
54
|
+
function MessageScrollerContent({ className, ...props }) {
|
|
55
|
+
const classes = cn("flex", "h-max", "min-h-full", "flex-col", "gap-8", className);
|
|
56
|
+
return /* @__PURE__ */ jsx(MessageScrollerPrimitive.Content, {
|
|
57
|
+
"data-slot": "message-scroller-content",
|
|
58
|
+
className: classes,
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Элемент ленты: сообщение или группа сообщений
|
|
64
|
+
* @param props - пропсы элемента
|
|
65
|
+
* @returns элемент ленты
|
|
66
|
+
*/
|
|
67
|
+
function MessageScrollerItem({ className, scrollAnchor = false, ...props }) {
|
|
68
|
+
const classes = cn("min-w-0", "shrink-0", "[contain-intrinsic-size:auto_10rem]", "[content-visibility:auto]", className);
|
|
69
|
+
return /* @__PURE__ */ jsx(MessageScrollerPrimitive.Item, {
|
|
70
|
+
"data-slot": "message-scroller-item",
|
|
71
|
+
scrollAnchor,
|
|
72
|
+
className: classes,
|
|
73
|
+
...props
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Кнопка прокрутки: появляется, когда есть куда прокручивать
|
|
78
|
+
* @param props - пропсы кнопки
|
|
79
|
+
* @returns кнопка
|
|
80
|
+
*/
|
|
81
|
+
function MessageScrollerButton({ direction = "end", className, children, variant = "secondary", size = "icon-sm", label, ...props }) {
|
|
82
|
+
const defaultLabel = direction === "end" ? SCROLL_TO_END_LABEL : SCROLL_TO_START_LABEL;
|
|
83
|
+
const classes = cn("absolute", "left-1/2", "-translate-x-1/2", "border-border", "bg-background", "text-foreground", "transition-[translate,scale,opacity]", "duration-200", "hover:bg-muted", "hover:text-foreground", "data-[active=false]:pointer-events-none", "data-[active=false]:scale-95", "data-[active=false]:opacity-0", "data-[active=false]:duration-400", "data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)]", "data-[active=true]:translate-y-0", "data-[active=true]:scale-100", "data-[active=true]:opacity-100", "data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)]", "data-[direction=end]:bottom-4", "data-[direction=end]:data-[active=false]:translate-y-full", "data-[direction=start]:top-4", "data-[direction=start]:data-[active=false]:-translate-y-full", "data-[direction=start]:[&_svg]:rotate-180", className);
|
|
84
|
+
const content = children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ArrowDownIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
85
|
+
className: "sr-only",
|
|
86
|
+
children: label ?? defaultLabel
|
|
87
|
+
})] });
|
|
88
|
+
return /* @__PURE__ */ jsx(MessageScrollerPrimitive.Button, {
|
|
89
|
+
"data-slot": "message-scroller-button",
|
|
90
|
+
"data-direction": direction,
|
|
91
|
+
"data-variant": variant,
|
|
92
|
+
"data-size": size,
|
|
93
|
+
direction,
|
|
94
|
+
className: classes,
|
|
95
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
96
|
+
variant,
|
|
97
|
+
size
|
|
98
|
+
}),
|
|
99
|
+
...props,
|
|
100
|
+
children: content
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export { MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ButtonPropsT } from "../button/types.js";
|
|
2
|
+
import "../button/index.js";
|
|
3
|
+
import { ComponentProps, ReactElement, ReactNode, RefObject } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Начальная позиция прокрутки: в начале, в конце или у последнего якоря
|
|
6
|
+
*/
|
|
7
|
+
export type MessageScrollerDefaultScrollPositionT = 'start' | 'end' | 'last-anchor';
|
|
8
|
+
/**
|
|
9
|
+
* Направление кнопки прокрутки
|
|
10
|
+
*/
|
|
11
|
+
export type MessageScrollerButtonDirectionT = 'start' | 'end';
|
|
12
|
+
/**
|
|
13
|
+
* Выравнивание сообщения при прокрутке к нему
|
|
14
|
+
*/
|
|
15
|
+
export type MessageScrollerScrollAlignT = 'start' | 'center' | 'end' | 'nearest';
|
|
16
|
+
/**
|
|
17
|
+
* Параметры прокрутки: выравнивание, поведение, отступ
|
|
18
|
+
* @property align - выравнивание сообщения
|
|
19
|
+
* @property behavior - плавная или мгновенная прокрутка
|
|
20
|
+
* @property scrollMargin - отступ от края в пикселях
|
|
21
|
+
*/
|
|
22
|
+
export type MessageScrollerScrollOptionsT = {
|
|
23
|
+
align?: MessageScrollerScrollAlignT;
|
|
24
|
+
behavior?: ScrollBehavior;
|
|
25
|
+
scrollMargin?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Есть ли куда прокручивать: к началу и к концу
|
|
29
|
+
* @property start - есть куда прокрутить к началу
|
|
30
|
+
* @property end - есть куда прокрутить к концу
|
|
31
|
+
*/
|
|
32
|
+
export type MessageScrollerScrollableT = {
|
|
33
|
+
start: boolean;
|
|
34
|
+
end: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Видимые сообщения и текущий якорь
|
|
38
|
+
* @property currentAnchorId - якорь, который сейчас у верхнего края
|
|
39
|
+
* @property visibleMessageIds - видимые сообщения по порядку
|
|
40
|
+
*/
|
|
41
|
+
export type MessageScrollerVisibilityStateT = {
|
|
42
|
+
currentAnchorId: string | null;
|
|
43
|
+
visibleMessageIds: string[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Пропсы провайдера ленты сообщений
|
|
47
|
+
*/
|
|
48
|
+
export type MessageScrollerProviderPropsT = {
|
|
49
|
+
/** Содержимое: лента и элементы, которые управляют прокруткой через хуки */
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/** Следовать за новыми сообщениями, пока пользователь у нижнего края */
|
|
52
|
+
autoScroll?: boolean;
|
|
53
|
+
/** Начальная позиция: start, end или last-anchor (начало последнего якоря), по умолчанию end */
|
|
54
|
+
defaultScrollPosition?: MessageScrollerDefaultScrollPositionT;
|
|
55
|
+
/** Расстояние до края в пикселях, при котором лента считается прокрученной до конца, по умолчанию 8 */
|
|
56
|
+
scrollEdgeThreshold?: number;
|
|
57
|
+
/** Сколько пикселей предыдущего сообщения видно над якорем, по умолчанию 64 */
|
|
58
|
+
scrollPreviousItemPeek?: number;
|
|
59
|
+
/** Отступ сверху при прокрутке к сообщению в пикселях, по умолчанию 0 */
|
|
60
|
+
scrollMargin?: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Пропсы корня ленты сообщений
|
|
64
|
+
*/
|
|
65
|
+
export type MessageScrollerPropsT = ComponentProps<'div'>;
|
|
66
|
+
/**
|
|
67
|
+
* Пропсы прокручиваемой области
|
|
68
|
+
*/
|
|
69
|
+
export type MessageScrollerViewportPropsT = Omit<ComponentProps<'div'>, 'aria-label'> & {
|
|
70
|
+
/** Подпись области для скринридера, по умолчанию «Сообщения» */
|
|
71
|
+
'aria-label'?: string;
|
|
72
|
+
/** Сохранять видимое сообщение на месте, когда сверху подгружается история, по умолчанию true */
|
|
73
|
+
preserveScrollOnPrepend?: boolean;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Пропсы содержимого ленты
|
|
77
|
+
*/
|
|
78
|
+
export type MessageScrollerContentPropsT = ComponentProps<'div'> & {
|
|
79
|
+
/** Классы служебного отступа в конце ленты, который позволяет прокрутить якорь к верху */
|
|
80
|
+
spacerClassName?: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Пропсы элемента ленты
|
|
84
|
+
*/
|
|
85
|
+
export type MessageScrollerItemPropsT = ComponentProps<'div'> & {
|
|
86
|
+
/** Идентификатор сообщения: для scrollToMessage и отслеживания видимости */
|
|
87
|
+
messageId?: string;
|
|
88
|
+
/** Якорь: при появлении лента прокручивается так, чтобы элемент оказался сверху */
|
|
89
|
+
scrollAnchor?: boolean;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Пропсы кнопки прокрутки
|
|
93
|
+
*/
|
|
94
|
+
export type MessageScrollerButtonPropsT = Omit<ComponentProps<'button'>, 'children'> & {
|
|
95
|
+
/** Куда прокручивает: end — в конец (внизу ленты), start — в начало (вверху) */
|
|
96
|
+
direction?: MessageScrollerButtonDirectionT;
|
|
97
|
+
/** Плавная или мгновенная прокрутка, по умолчанию smooth */
|
|
98
|
+
behavior?: ScrollBehavior;
|
|
99
|
+
/** Оформление кнопки, по умолчанию secondary */
|
|
100
|
+
variant?: ButtonPropsT['variant'];
|
|
101
|
+
/** Размер кнопки, по умолчанию icon-sm */
|
|
102
|
+
size?: ButtonPropsT['size'];
|
|
103
|
+
/** Подпись для скринридера, по умолчанию «Прокрутить в конец» или «Прокрутить в начало» */
|
|
104
|
+
label?: string;
|
|
105
|
+
/** Своё содержимое вместо стрелки и подписи */
|
|
106
|
+
children?: ReactNode;
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MoneyInput } from "./money-input.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MoneyInputPropsT } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Поле суммы: разряды через пробел, запятая в дробной части, ₽ справа
|
|
4
|
+
* @param props - пропсы поля; value — число, onValueChange — число или null
|
|
5
|
+
* @returns группа поля
|
|
6
|
+
*/
|
|
7
|
+
export declare function MoneyInput({ value, defaultValue, onValueChange, fractionDigits, allowNegative, currencySymbol, groupClassName, onChange, placeholder, disabled, ...props }: MoneyInputPropsT): import("react").JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { NUMBER_LOCALE } from "../../lib/locale.js";
|
|
4
|
+
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from "../input-group/input-group.js";
|
|
5
|
+
import { useControllableState } from "../../lib/use-controllable-state.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
8
|
+
// src/components/money-input/money-input.tsx
|
|
9
|
+
/** Разделитель тысяч в ru-RU: неразрывный пробел */
|
|
10
|
+
const GROUP_SEPARATOR = "\xA0";
|
|
11
|
+
/**
|
|
12
|
+
* Разбить целую часть на разряды: 1234567 → 1 234 567
|
|
13
|
+
* @param integer - цифры целой части
|
|
14
|
+
* @returns цифры с разделителями
|
|
15
|
+
*/
|
|
16
|
+
function groupDigits(integer) {
|
|
17
|
+
return integer.replace(/\B(?=(\d{3})+(?!\d))/g, GROUP_SEPARATOR);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Очистить ввод: цифры, одна запятая, минус в начале; разряды через пробел
|
|
21
|
+
* @param raw - текст из поля
|
|
22
|
+
* @param fractionDigits - знаков после запятой
|
|
23
|
+
* @param allowNegative - можно ли минус
|
|
24
|
+
* @returns текст для показа
|
|
25
|
+
*/
|
|
26
|
+
function cleanText(raw, fractionDigits, allowNegative) {
|
|
27
|
+
const isNegative = allowNegative && raw.trim().startsWith("-");
|
|
28
|
+
const normalized = raw.replace(/\./g, ",").replace(/[^\d,]/g, "");
|
|
29
|
+
const commaIndex = fractionDigits > 0 ? normalized.indexOf(",") : -1;
|
|
30
|
+
let integer;
|
|
31
|
+
let fraction = "";
|
|
32
|
+
if (commaIndex >= 0) {
|
|
33
|
+
integer = normalized.slice(0, commaIndex);
|
|
34
|
+
fraction = normalized.slice(commaIndex + 1).replace(/,/g, "").slice(0, fractionDigits);
|
|
35
|
+
} else integer = normalized.replace(/,/g, "");
|
|
36
|
+
integer = integer.replace(/^0+(?=\d)/, "");
|
|
37
|
+
if (commaIndex >= 0 && integer === "") integer = "0";
|
|
38
|
+
const sign = isNegative ? "-" : "";
|
|
39
|
+
const comma = commaIndex >= 0 ? "," : "";
|
|
40
|
+
return `${sign}${groupDigits(integer)}${comma}${fraction}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Число из текста поля
|
|
44
|
+
* @param text - текст с разрядами и запятой
|
|
45
|
+
* @returns число или null, если цифр нет
|
|
46
|
+
*/
|
|
47
|
+
function parseText(text) {
|
|
48
|
+
const plain = text.replace(new RegExp(GROUP_SEPARATOR, "g"), "").replace(",", ".");
|
|
49
|
+
if (!/\d/.test(plain)) return null;
|
|
50
|
+
return Number(plain);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Текст поля для числа: разряды и запятая, без лишних нулей
|
|
54
|
+
* @param value - сумма
|
|
55
|
+
* @param fractionDigits - знаков после запятой
|
|
56
|
+
* @returns текст
|
|
57
|
+
*/
|
|
58
|
+
function formatValue(value, fractionDigits) {
|
|
59
|
+
if (value === null || Number.isNaN(value)) return "";
|
|
60
|
+
return new Intl.NumberFormat(NUMBER_LOCALE, {
|
|
61
|
+
maximumFractionDigits: fractionDigits,
|
|
62
|
+
useGrouping: true
|
|
63
|
+
}).format(value).replace(/\s/g, GROUP_SEPARATOR);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Сколько значимых символов (цифр, запятых и точек, минуса) стоит до позиции
|
|
67
|
+
* @param text - текст
|
|
68
|
+
* @param position - позиция курсора
|
|
69
|
+
* @returns число символов
|
|
70
|
+
*/
|
|
71
|
+
function countSignificant(text, position) {
|
|
72
|
+
return text.slice(0, position).replace(/[^\d,.-]/g, "").length;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Позиция после заданного числа значимых символов
|
|
76
|
+
* @param text - текст
|
|
77
|
+
* @param count - число значимых символов
|
|
78
|
+
* @returns позиция курсора
|
|
79
|
+
*/
|
|
80
|
+
function findPosition(text, count) {
|
|
81
|
+
let seen = 0;
|
|
82
|
+
for (let index = 0; index < text.length; index++) {
|
|
83
|
+
if (seen === count) return index;
|
|
84
|
+
if (/[\d,-]/.test(text.charAt(index))) seen++;
|
|
85
|
+
}
|
|
86
|
+
return text.length;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Поле суммы: разряды через пробел, запятая в дробной части, ₽ справа
|
|
90
|
+
* @param props - пропсы поля; value — число, onValueChange — число или null
|
|
91
|
+
* @returns группа поля
|
|
92
|
+
*/
|
|
93
|
+
function MoneyInput({ value, defaultValue = null, onValueChange, fractionDigits = 2, allowNegative = false, currencySymbol = "₽", groupClassName, onChange, placeholder = "0", disabled, ...props }) {
|
|
94
|
+
const [amount, setAmount] = useControllableState({
|
|
95
|
+
prop: value,
|
|
96
|
+
defaultProp: defaultValue,
|
|
97
|
+
onChange: onValueChange,
|
|
98
|
+
caller: "MoneyInput"
|
|
99
|
+
});
|
|
100
|
+
const [text, setText] = useState(() => formatValue(amount, fractionDigits));
|
|
101
|
+
const inputRef = useRef(null);
|
|
102
|
+
const caretRef = useRef(null);
|
|
103
|
+
const shownText = parseText(text) === amount ? text : formatValue(amount, fractionDigits);
|
|
104
|
+
const classes = cn(groupClassName);
|
|
105
|
+
useLayoutEffect(() => {
|
|
106
|
+
const input = inputRef.current;
|
|
107
|
+
if (input && caretRef.current !== null && document.activeElement === input) input.setSelectionRange(caretRef.current, caretRef.current);
|
|
108
|
+
caretRef.current = null;
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Новый текст поля: очистить, разбить на разряды и сохранить место курсора
|
|
112
|
+
* @param event - событие изменения
|
|
113
|
+
*/
|
|
114
|
+
const handleChange = (event) => {
|
|
115
|
+
onChange?.(event);
|
|
116
|
+
const raw = event.target.value;
|
|
117
|
+
const significantBefore = countSignificant(raw, event.target.selectionStart ?? raw.length);
|
|
118
|
+
const nextText = cleanText(raw, fractionDigits, allowNegative);
|
|
119
|
+
caretRef.current = findPosition(nextText, significantBefore);
|
|
120
|
+
setText(nextText);
|
|
121
|
+
setAmount(parseText(nextText));
|
|
122
|
+
};
|
|
123
|
+
return /* @__PURE__ */ jsxs(InputGroup, {
|
|
124
|
+
"data-slot": "money-input",
|
|
125
|
+
"data-disabled": disabled,
|
|
126
|
+
className: classes,
|
|
127
|
+
children: [/* @__PURE__ */ jsx(InputGroupInput, {
|
|
128
|
+
ref: inputRef,
|
|
129
|
+
type: "text",
|
|
130
|
+
inputMode: "decimal",
|
|
131
|
+
autoComplete: "off",
|
|
132
|
+
placeholder,
|
|
133
|
+
value: shownText,
|
|
134
|
+
onChange: handleChange,
|
|
135
|
+
disabled,
|
|
136
|
+
...props
|
|
137
|
+
}), currencySymbol && /* @__PURE__ */ jsx(InputGroupAddon, {
|
|
138
|
+
align: "inline-end",
|
|
139
|
+
children: /* @__PURE__ */ jsx(InputGroupText, { children: currencySymbol })
|
|
140
|
+
})]
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
export { MoneyInput };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InputPropsT } from "../input/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Пропсы поля суммы
|
|
4
|
+
*/
|
|
5
|
+
export type MoneyInputPropsT = Omit<InputPropsT, 'type' | 'value' | 'defaultValue' | 'inputMode'> & {
|
|
6
|
+
/** Сумма — контролируемый режим, вместе с onValueChange. null — поле пустое */
|
|
7
|
+
value?: number | null;
|
|
8
|
+
/** Сумма при первом рендере — неконтролируемый режим */
|
|
9
|
+
defaultValue?: number | null;
|
|
10
|
+
/** Сумма изменилась: число или null, если поле пустое */
|
|
11
|
+
onValueChange?: (value: number | null) => void;
|
|
12
|
+
/** Сколько знаков после запятой можно ввести. По умолчанию 2, 0 — только целые */
|
|
13
|
+
fractionDigits?: number;
|
|
14
|
+
/** Разрешить отрицательные суммы */
|
|
15
|
+
allowNegative?: boolean;
|
|
16
|
+
/** Символ валюты справа. По умолчанию ₽; пустая строка — без символа */
|
|
17
|
+
currencySymbol?: string;
|
|
18
|
+
/** Классы рамки поля */
|
|
19
|
+
groupClassName?: string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MorphImagePropsT } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Изображение с плавным раскрытием на весь экран: клик по миниатюре увеличивает её поверх страницы,
|
|
4
|
+
* клик по затемнению или Escape возвращает на место
|
|
5
|
+
* @param props - пропсы изображения
|
|
6
|
+
* @returns миниатюра и слой с раскрытым изображением
|
|
7
|
+
*/
|
|
8
|
+
export declare function MorphImage({ className, expandedClassName, src, alt, open, defaultOpen, onOpenChange, closeOnScroll, transition, openLabel, closeLabel, ref, ...props }: MorphImagePropsT): import("react").JSX.Element;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { texts } from "../../lib/locale.js";
|
|
4
|
+
import { morphImageVariants } from "./types.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
// src/components/morph-image/morph-image.tsx
|
|
10
|
+
/** Пружина по умолчанию: раскрытие и возврат изображения */
|
|
11
|
+
const defaultTransition = {
|
|
12
|
+
type: "spring",
|
|
13
|
+
stiffness: 120,
|
|
14
|
+
damping: 15
|
|
15
|
+
};
|
|
16
|
+
/** Без анимации: для пользователей с prefers-reduced-motion */
|
|
17
|
+
const instantTransition = { duration: 0 };
|
|
18
|
+
/**
|
|
19
|
+
* Скругление элемента в px из его классов. motion сохраняет скругление при анимации
|
|
20
|
+
* размера, только если оно задано числом в style, иначе углы сжимаются вместе с картинкой
|
|
21
|
+
* @param ref - элемент, у которого берётся скругление
|
|
22
|
+
* @param isShown - элемент показан: при появлении скругление измеряется заново
|
|
23
|
+
* @returns скругление в px или undefined до измерения
|
|
24
|
+
*/
|
|
25
|
+
function useBorderRadius(ref, isShown = true) {
|
|
26
|
+
const [radius, setRadius] = useState();
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (isShown && ref.current) setRadius(parseFloat(getComputedStyle(ref.current).borderTopLeftRadius));
|
|
29
|
+
}, [ref, isShown]);
|
|
30
|
+
return radius;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Изображение с плавным раскрытием на весь экран: клик по миниатюре увеличивает её поверх страницы,
|
|
34
|
+
* клик по затемнению или Escape возвращает на место
|
|
35
|
+
* @param props - пропсы изображения
|
|
36
|
+
* @returns миниатюра и слой с раскрытым изображением
|
|
37
|
+
*/
|
|
38
|
+
function MorphImage({ className, expandedClassName, src, alt, open, defaultOpen = false, onOpenChange, closeOnScroll = true, transition = defaultTransition, openLabel = "Увеличить изображение", closeLabel = texts.close, ref, ...props }) {
|
|
39
|
+
const layoutId = useId();
|
|
40
|
+
const isReduced = useReducedMotion();
|
|
41
|
+
const [innerOpen, setInnerOpen] = useState(defaultOpen);
|
|
42
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
43
|
+
const isOpen = open ?? innerOpen;
|
|
44
|
+
const triggerRef = useRef(null);
|
|
45
|
+
const expandedRef = useRef(null);
|
|
46
|
+
const triggerRadius = useBorderRadius(triggerRef);
|
|
47
|
+
const expandedRadius = useBorderRadius(expandedRef, isOpen);
|
|
48
|
+
const triggerLabel = alt ? `${openLabel}: ${alt}` : openLabel;
|
|
49
|
+
const motionTransition = isReduced ? instantTransition : transition;
|
|
50
|
+
const triggerClasses = cn(morphImageVariants({ part: "trigger" }), className);
|
|
51
|
+
const imageClasses = morphImageVariants({ part: "image" });
|
|
52
|
+
const expandedClasses = cn(morphImageVariants({ part: "expanded" }), expandedClassName);
|
|
53
|
+
const expandedImageClasses = morphImageVariants({ part: "expandedImage" });
|
|
54
|
+
/**
|
|
55
|
+
* Раскрыть или свернуть изображение
|
|
56
|
+
* @param nextOpen - новое состояние
|
|
57
|
+
*/
|
|
58
|
+
const changeOpen = (nextOpen) => {
|
|
59
|
+
setInnerOpen(nextOpen);
|
|
60
|
+
onOpenChange?.(nextOpen);
|
|
61
|
+
};
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setIsMounted(true);
|
|
64
|
+
}, []);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!isOpen) return;
|
|
67
|
+
const handleKeyDown = (event) => {
|
|
68
|
+
if (event.key === "Escape") {
|
|
69
|
+
setInnerOpen(false);
|
|
70
|
+
onOpenChange?.(false);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const handleScroll = () => {
|
|
74
|
+
if (closeOnScroll) {
|
|
75
|
+
setInnerOpen(false);
|
|
76
|
+
onOpenChange?.(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
80
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
81
|
+
return () => {
|
|
82
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
83
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
84
|
+
};
|
|
85
|
+
}, [
|
|
86
|
+
isOpen,
|
|
87
|
+
closeOnScroll,
|
|
88
|
+
onOpenChange
|
|
89
|
+
]);
|
|
90
|
+
const overlay = /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(motion.div, {
|
|
91
|
+
"data-slot": "morph-image-backdrop",
|
|
92
|
+
"aria-hidden": true,
|
|
93
|
+
className: morphImageVariants({ part: "backdrop" }),
|
|
94
|
+
initial: { opacity: 0 },
|
|
95
|
+
animate: {
|
|
96
|
+
opacity: 1,
|
|
97
|
+
pointerEvents: "auto"
|
|
98
|
+
},
|
|
99
|
+
exit: {
|
|
100
|
+
opacity: 0,
|
|
101
|
+
pointerEvents: "none"
|
|
102
|
+
},
|
|
103
|
+
transition: motionTransition,
|
|
104
|
+
onClick: () => changeOpen(false)
|
|
105
|
+
}, "backdrop"), /* @__PURE__ */ jsx("div", {
|
|
106
|
+
"data-slot": "morph-image-layer",
|
|
107
|
+
role: "dialog",
|
|
108
|
+
"aria-modal": true,
|
|
109
|
+
"aria-label": alt || closeLabel,
|
|
110
|
+
className: morphImageVariants({ part: "layer" }),
|
|
111
|
+
children: /* @__PURE__ */ jsx(motion.button, {
|
|
112
|
+
type: "button",
|
|
113
|
+
"data-slot": "morph-image-expanded",
|
|
114
|
+
ref: expandedRef,
|
|
115
|
+
animate: { pointerEvents: "auto" },
|
|
116
|
+
exit: { pointerEvents: "none" },
|
|
117
|
+
"aria-label": closeLabel,
|
|
118
|
+
autoFocus: true,
|
|
119
|
+
className: expandedClasses,
|
|
120
|
+
onClick: () => changeOpen(false),
|
|
121
|
+
children: /* @__PURE__ */ jsx(motion.img, {
|
|
122
|
+
"data-slot": "morph-image-expanded-image",
|
|
123
|
+
layoutId,
|
|
124
|
+
src,
|
|
125
|
+
alt,
|
|
126
|
+
className: expandedImageClasses,
|
|
127
|
+
style: { borderRadius: expandedRadius },
|
|
128
|
+
transition: motionTransition
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
}, "layer")] }) });
|
|
132
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
133
|
+
type: "button",
|
|
134
|
+
"data-slot": "morph-image",
|
|
135
|
+
"data-state": isOpen ? "open" : "closed",
|
|
136
|
+
"aria-label": triggerLabel,
|
|
137
|
+
"aria-haspopup": "dialog",
|
|
138
|
+
"aria-expanded": isOpen,
|
|
139
|
+
ref: triggerRef,
|
|
140
|
+
className: triggerClasses,
|
|
141
|
+
onClick: () => changeOpen(true),
|
|
142
|
+
children: /* @__PURE__ */ jsx(motion.img, {
|
|
143
|
+
"data-slot": "morph-image-image",
|
|
144
|
+
layoutId,
|
|
145
|
+
ref,
|
|
146
|
+
src,
|
|
147
|
+
alt,
|
|
148
|
+
className: imageClasses,
|
|
149
|
+
style: { borderRadius: triggerRadius },
|
|
150
|
+
transition: motionTransition,
|
|
151
|
+
...props
|
|
152
|
+
})
|
|
153
|
+
}), isMounted && createPortal(overlay, document.body)] });
|
|
154
|
+
}
|
|
155
|
+
export { MorphImage };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentProps, Ref } from "react";
|
|
2
|
+
import { Transition } from "motion/react";
|
|
3
|
+
/**
|
|
4
|
+
* Стили частей: кнопка-миниатюра, затемнение, слой и раскрытое изображение.
|
|
5
|
+
* Экспортируются, чтобы оформить свой элемент так же: morphImageVariants({ part: 'backdrop' }).
|
|
6
|
+
*/
|
|
7
|
+
export declare const morphImageVariants: (props?: ({
|
|
8
|
+
part?: "image" | "trigger" | "backdrop" | "layer" | "expanded" | "expandedImage" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Пропсы изображения с раскрытием
|
|
12
|
+
*/
|
|
13
|
+
export type MorphImagePropsT = Omit<ComponentProps<'img'>, 'className' | 'ref' | 'src' | 'alt' | 'onClick' | 'onAnimationStart' | 'onDrag' | 'onDragStart' | 'onDragEnd'> & {
|
|
14
|
+
/** Адрес изображения */
|
|
15
|
+
src: string;
|
|
16
|
+
/** Описание изображения для скринридера. Для декоративной картинки — пустая строка */
|
|
17
|
+
alt: string;
|
|
18
|
+
/** Классы миниатюры (самого изображения): размеры и скругление задаются здесь */
|
|
19
|
+
className?: string;
|
|
20
|
+
/** Классы раскрытого изображения: например, свой максимальный размер */
|
|
21
|
+
expandedClassName?: string;
|
|
22
|
+
/** Раскрыто ли изображение (контролируемый режим) */
|
|
23
|
+
open?: boolean;
|
|
24
|
+
/** Раскрыто ли изображение при первом показе (неконтролируемый режим). По умолчанию false */
|
|
25
|
+
defaultOpen?: boolean;
|
|
26
|
+
/** Изображение раскрыли или свернули */
|
|
27
|
+
onOpenChange?: (open: boolean) => void;
|
|
28
|
+
/** Сворачивать изображение при прокрутке страницы. По умолчанию true */
|
|
29
|
+
closeOnScroll?: boolean;
|
|
30
|
+
/** Параметры анимации раскрытия motion, по умолчанию пружина */
|
|
31
|
+
transition?: Transition;
|
|
32
|
+
/** Подпись кнопки миниатюры для скринридера, по умолчанию «Увеличить изображение» */
|
|
33
|
+
openLabel?: string;
|
|
34
|
+
/** Подпись раскрытого изображения для скринридера, по умолчанию «Закрыть» */
|
|
35
|
+
closeLabel?: string;
|
|
36
|
+
/** Ссылка на элемент миниатюры */
|
|
37
|
+
ref?: Ref<HTMLImageElement>;
|
|
38
|
+
};
|