@laser-ui/components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/accordion/Accordion.d.ts +3 -0
- package/accordion/Accordion.js +162 -0
- package/accordion/index.d.ts +2 -0
- package/accordion/index.js +1 -0
- package/accordion/types.d.ts +20 -0
- package/accordion/types.js +1 -0
- package/accordion/vars.d.ts +10 -0
- package/accordion/vars.js +10 -0
- package/affix/Affix.d.ts +3 -0
- package/affix/Affix.js +56 -0
- package/affix/index.d.ts +2 -0
- package/affix/index.js +1 -0
- package/affix/types.d.ts +14 -0
- package/affix/types.js +1 -0
- package/alert/Alert.d.ts +3 -0
- package/alert/Alert.js +53 -0
- package/alert/index.d.ts +2 -0
- package/alert/index.js +1 -0
- package/alert/types.d.ts +13 -0
- package/alert/types.js +1 -0
- package/alert/vars.d.ts +14 -0
- package/alert/vars.js +14 -0
- package/anchor/Anchor.d.ts +10 -0
- package/anchor/Anchor.js +112 -0
- package/anchor/index.d.ts +2 -0
- package/anchor/index.js +1 -0
- package/anchor/types.d.ts +23 -0
- package/anchor/types.js +1 -0
- package/anchor/vars.d.ts +11 -0
- package/anchor/vars.js +11 -0
- package/avatar/Avatar.d.ts +3 -0
- package/avatar/Avatar.js +43 -0
- package/avatar/index.d.ts +2 -0
- package/avatar/index.js +1 -0
- package/avatar/types.d.ts +11 -0
- package/avatar/types.js +1 -0
- package/avatar/vars.d.ts +9 -0
- package/avatar/vars.js +9 -0
- package/badge/Badge.d.ts +7 -0
- package/badge/Badge.js +61 -0
- package/badge/BadgeText.d.ts +2 -0
- package/badge/BadgeText.js +40 -0
- package/badge/index.d.ts +2 -0
- package/badge/index.js +1 -0
- package/badge/internal/BadgeNumber.d.ts +10 -0
- package/badge/internal/BadgeNumber.js +37 -0
- package/badge/types.d.ts +19 -0
- package/badge/types.js +1 -0
- package/badge/vars.d.ts +12 -0
- package/badge/vars.js +12 -0
- package/breadcrumb/Breadcrumb.d.ts +3 -0
- package/breadcrumb/Breadcrumb.js +22 -0
- package/breadcrumb/index.d.ts +2 -0
- package/breadcrumb/index.js +1 -0
- package/breadcrumb/types.d.ts +15 -0
- package/breadcrumb/types.js +1 -0
- package/breadcrumb/vars.d.ts +8 -0
- package/breadcrumb/vars.js +8 -0
- package/button/Button.d.ts +3 -0
- package/button/Button.js +50 -0
- package/button/index.d.ts +2 -0
- package/button/index.js +1 -0
- package/button/types.d.ts +14 -0
- package/button/types.js +1 -0
- package/button/vars.d.ts +23 -0
- package/button/vars.js +23 -0
- package/card/Card.d.ts +11 -0
- package/card/Card.js +30 -0
- package/card/CardAction.d.ts +3 -0
- package/card/CardAction.js +17 -0
- package/card/CardContent.d.ts +3 -0
- package/card/CardContent.js +13 -0
- package/card/CardHeader.d.ts +3 -0
- package/card/CardHeader.js +13 -0
- package/card/index.d.ts +2 -0
- package/card/index.js +1 -0
- package/card/types.d.ts +17 -0
- package/card/types.js +1 -0
- package/card/vars.d.ts +12 -0
- package/card/vars.js +12 -0
- package/cascader/Cascader.d.ts +5 -0
- package/cascader/Cascader.js +487 -0
- package/cascader/index.d.ts +2 -0
- package/cascader/index.js +1 -0
- package/cascader/internal/CascaderPanel.d.ts +23 -0
- package/cascader/internal/CascaderPanel.js +135 -0
- package/cascader/internal/CascaderSearchPanel.d.ts +22 -0
- package/cascader/internal/CascaderSearchPanel.js +73 -0
- package/cascader/internal/types.d.ts +8 -0
- package/cascader/internal/types.js +1 -0
- package/cascader/types.d.ts +49 -0
- package/cascader/types.js +1 -0
- package/cascader/vars.d.ts +32 -0
- package/cascader/vars.js +32 -0
- package/checkbox/Checkbox.d.ts +7 -0
- package/checkbox/Checkbox.js +25 -0
- package/checkbox/CheckboxGroup.d.ts +3 -0
- package/checkbox/CheckboxGroup.js +25 -0
- package/checkbox/index.d.ts +2 -0
- package/checkbox/index.js +1 -0
- package/checkbox/types.d.ts +29 -0
- package/checkbox/types.js +1 -0
- package/checkbox/vars.d.ts +11 -0
- package/checkbox/vars.js +11 -0
- package/compose/Compose.d.ts +7 -0
- package/compose/Compose.js +24 -0
- package/compose/ComposeItem.d.ts +3 -0
- package/compose/ComposeItem.js +18 -0
- package/compose/index.d.ts +2 -0
- package/compose/index.js +1 -0
- package/compose/types.d.ts +12 -0
- package/compose/types.js +1 -0
- package/compose/vars.d.ts +10 -0
- package/compose/vars.js +10 -0
- package/config-provider/ConfigProvider.d.ts +3 -0
- package/config-provider/ConfigProvider.js +14 -0
- package/config-provider/index.d.ts +2 -0
- package/config-provider/index.js +1 -0
- package/config-provider/types.d.ts +7 -0
- package/config-provider/types.js +1 -0
- package/context/index.d.ts +33 -0
- package/context/index.js +106 -0
- package/context/props.d.ts +134 -0
- package/context/props.js +1 -0
- package/date-picker/DatePicker.d.ts +3 -0
- package/date-picker/DatePicker.js +376 -0
- package/date-picker/index.d.ts +2 -0
- package/date-picker/index.js +1 -0
- package/date-picker/internal/DatePickerPanel.d.ts +15 -0
- package/date-picker/internal/DatePickerPanel.js +104 -0
- package/date-picker/types.d.ts +37 -0
- package/date-picker/types.js +1 -0
- package/date-picker/vars.d.ts +36 -0
- package/date-picker/vars.js +36 -0
- package/dayjs.d.ts +3 -0
- package/dayjs.js +11 -0
- package/drawer/Drawer.d.ts +9 -0
- package/drawer/Drawer.js +141 -0
- package/drawer/DrawerFooter.d.ts +3 -0
- package/drawer/DrawerFooter.js +51 -0
- package/drawer/DrawerHeader.d.ts +3 -0
- package/drawer/DrawerHeader.js +37 -0
- package/drawer/index.d.ts +2 -0
- package/drawer/index.js +1 -0
- package/drawer/types.d.ts +36 -0
- package/drawer/types.js +1 -0
- package/drawer/vars.d.ts +21 -0
- package/drawer/vars.js +18 -0
- package/dropdown/Dropdown.d.ts +5 -0
- package/dropdown/Dropdown.js +376 -0
- package/dropdown/index.d.ts +2 -0
- package/dropdown/index.js +1 -0
- package/dropdown/internal/DropdownGroup.d.ts +13 -0
- package/dropdown/internal/DropdownGroup.js +8 -0
- package/dropdown/internal/DropdownItem.d.ts +16 -0
- package/dropdown/internal/DropdownItem.js +9 -0
- package/dropdown/internal/DropdownSub.d.ts +22 -0
- package/dropdown/internal/DropdownSub.js +78 -0
- package/dropdown/types.d.ts +31 -0
- package/dropdown/types.js +1 -0
- package/dropdown/utils.d.ts +4 -0
- package/dropdown/utils.js +18 -0
- package/dropdown/vars.d.ts +23 -0
- package/dropdown/vars.js +23 -0
- package/empty/Empty.d.ts +7 -0
- package/empty/Empty.js +18 -0
- package/empty/index.d.ts +2 -0
- package/empty/index.js +1 -0
- package/empty/types.d.ts +8 -0
- package/empty/types.js +1 -0
- package/empty/vars.d.ts +7 -0
- package/empty/vars.js +7 -0
- package/fab/Fab.d.ts +9 -0
- package/fab/Fab.js +31 -0
- package/fab/FabBacktop.d.ts +3 -0
- package/fab/FabBacktop.js +58 -0
- package/fab/FabButton.d.ts +3 -0
- package/fab/FabButton.js +23 -0
- package/fab/index.d.ts +2 -0
- package/fab/index.js +1 -0
- package/fab/types.d.ts +26 -0
- package/fab/types.js +1 -0
- package/fab/vars.d.ts +28 -0
- package/fab/vars.js +28 -0
- package/form/Form.d.ts +7 -0
- package/form/Form.js +34 -0
- package/form/FormItem.d.ts +5 -0
- package/form/FormItem.js +201 -0
- package/form/hooks.d.ts +5 -0
- package/form/hooks.js +18 -0
- package/form/index.d.ts +8 -0
- package/form/index.js +7 -0
- package/form/internal/FormError.d.ts +12 -0
- package/form/internal/FormError.js +24 -0
- package/form/model/abstract-control.d.ts +67 -0
- package/form/model/abstract-control.js +335 -0
- package/form/model/form-control.d.ts +23 -0
- package/form/model/form-control.js +72 -0
- package/form/model/form-group.d.ts +62 -0
- package/form/model/form-group.js +165 -0
- package/form/model/types.d.ts +8 -0
- package/form/model/types.js +1 -0
- package/form/model/validators.d.ts +11 -0
- package/form/model/validators.js +83 -0
- package/form/model/vars.d.ts +1 -0
- package/form/model/vars.js +1 -0
- package/form/types.d.ts +63 -0
- package/form/types.js +1 -0
- package/form/vars.d.ts +27 -0
- package/form/vars.js +25 -0
- package/hooks/index.d.ts +14 -0
- package/hooks/index.js +14 -0
- package/hooks/useComponentProps.d.ts +2 -0
- package/hooks/useComponentProps.js +15 -0
- package/hooks/useControlled.d.ts +3 -0
- package/hooks/useControlled.js +26 -0
- package/hooks/useDesign.d.ts +12 -0
- package/hooks/useDesign.js +8 -0
- package/hooks/useFocusVisible.d.ts +2 -0
- package/hooks/useFocusVisible.js +38 -0
- package/hooks/useLayout.d.ts +5 -0
- package/hooks/useLayout.js +10 -0
- package/hooks/useListenGlobalScrolling.d.ts +1 -0
- package/hooks/useListenGlobalScrolling.js +9 -0
- package/hooks/useLockScroll.d.ts +1 -0
- package/hooks/useLockScroll.js +24 -0
- package/hooks/useMaxIndex.d.ts +1 -0
- package/hooks/useMaxIndex.js +32 -0
- package/hooks/useNamespace.d.ts +1 -0
- package/hooks/useNamespace.js +6 -0
- package/hooks/useNestedPopup.d.ts +13 -0
- package/hooks/useNestedPopup.js +37 -0
- package/hooks/useNextTick.d.ts +2 -0
- package/hooks/useNextTick.js +9 -0
- package/hooks/useScopedProps.d.ts +8 -0
- package/hooks/useScopedProps.js +7 -0
- package/hooks/useStyled.d.ts +20 -0
- package/hooks/useStyled.js +82 -0
- package/hooks/useTranslation.d.ts +4 -0
- package/hooks/useTranslation.js +17 -0
- package/icon/Icon.d.ts +3 -0
- package/icon/Icon.js +18 -0
- package/icon/index.d.ts +2 -0
- package/icon/index.js +1 -0
- package/icon/types.d.ts +12 -0
- package/icon/types.js +1 -0
- package/icon/vars.d.ts +7 -0
- package/icon/vars.js +7 -0
- package/image/Image.d.ts +9 -0
- package/image/Image.js +50 -0
- package/image/ImageAction.d.ts +3 -0
- package/image/ImageAction.js +15 -0
- package/image/ImagePreview.d.ts +3 -0
- package/image/ImagePreview.js +261 -0
- package/image/index.d.ts +2 -0
- package/image/index.js +1 -0
- package/image/types.d.ts +24 -0
- package/image/types.js +1 -0
- package/image/vars.d.ts +26 -0
- package/image/vars.js +26 -0
- package/index.d.ts +52 -0
- package/index.js +52 -0
- package/input/Input.d.ts +7 -0
- package/input/Input.js +56 -0
- package/input/InputNumber.d.ts +2 -0
- package/input/InputNumber.js +142 -0
- package/input/index.d.ts +2 -0
- package/input/index.js +1 -0
- package/input/types.d.ts +44 -0
- package/input/types.js +1 -0
- package/input/vars.d.ts +14 -0
- package/input/vars.js +14 -0
- package/internal/circular-progress/CircularProgress.d.ts +2 -0
- package/internal/circular-progress/CircularProgress.js +11 -0
- package/internal/circular-progress/index.d.ts +1 -0
- package/internal/circular-progress/index.js +1 -0
- package/internal/circular-progress/vars.d.ts +4 -0
- package/internal/circular-progress/vars.js +4 -0
- package/internal/mask/Mask.d.ts +3 -0
- package/internal/mask/Mask.js +36 -0
- package/internal/mask/index.d.ts +2 -0
- package/internal/mask/index.js +1 -0
- package/internal/mask/types.d.ts +7 -0
- package/internal/mask/types.js +1 -0
- package/internal/mask/vars.d.ts +3 -0
- package/internal/mask/vars.js +3 -0
- package/internal/popup/Popup.d.ts +3 -0
- package/internal/popup/Popup.js +132 -0
- package/internal/popup/index.d.ts +2 -0
- package/internal/popup/index.js +1 -0
- package/internal/popup/types.d.ts +21 -0
- package/internal/popup/types.js +1 -0
- package/internal/portal/Portal.d.ts +3 -0
- package/internal/portal/Portal.js +14 -0
- package/internal/portal/index.d.ts +2 -0
- package/internal/portal/index.js +1 -0
- package/internal/portal/types.d.ts +6 -0
- package/internal/portal/types.js +1 -0
- package/internal/transition/CollapseTransition.d.ts +3 -0
- package/internal/transition/CollapseTransition.js +101 -0
- package/internal/transition/Transition.d.ts +3 -0
- package/internal/transition/Transition.js +87 -0
- package/internal/transition/index.d.ts +3 -0
- package/internal/transition/index.js +2 -0
- package/internal/transition/types.d.ts +33 -0
- package/internal/transition/types.js +1 -0
- package/internal/wave/Wave.d.ts +3 -0
- package/internal/wave/Wave.js +25 -0
- package/internal/wave/index.d.ts +2 -0
- package/internal/wave/index.js +1 -0
- package/internal/wave/types.d.ts +6 -0
- package/internal/wave/types.js +1 -0
- package/internal/wave/vars.d.ts +3 -0
- package/internal/wave/vars.js +3 -0
- package/menu/Menu.d.ts +5 -0
- package/menu/Menu.js +386 -0
- package/menu/index.d.ts +2 -0
- package/menu/index.js +1 -0
- package/menu/internal/MenuGroup.d.ts +15 -0
- package/menu/internal/MenuGroup.js +8 -0
- package/menu/internal/MenuItem.d.ts +23 -0
- package/menu/internal/MenuItem.js +18 -0
- package/menu/internal/MenuSub.d.ts +31 -0
- package/menu/internal/MenuSub.js +129 -0
- package/menu/types.d.ts +30 -0
- package/menu/types.js +1 -0
- package/menu/utils.d.ts +4 -0
- package/menu/utils.js +18 -0
- package/menu/vars.d.ts +28 -0
- package/menu/vars.js +28 -0
- package/modal/Modal.d.ts +11 -0
- package/modal/Modal.js +127 -0
- package/modal/ModalAlert.d.ts +3 -0
- package/modal/ModalAlert.js +19 -0
- package/modal/ModalFooter.d.ts +3 -0
- package/modal/ModalFooter.js +51 -0
- package/modal/ModalHeader.d.ts +3 -0
- package/modal/ModalHeader.js +37 -0
- package/modal/index.d.ts +2 -0
- package/modal/index.js +1 -0
- package/modal/types.d.ts +39 -0
- package/modal/types.js +1 -0
- package/modal/vars.d.ts +23 -0
- package/modal/vars.js +23 -0
- package/notification/Notification.d.ts +3 -0
- package/notification/Notification.js +129 -0
- package/notification/index.d.ts +2 -0
- package/notification/index.js +1 -0
- package/notification/types.d.ts +18 -0
- package/notification/types.js +1 -0
- package/notification/vars.d.ts +17 -0
- package/notification/vars.js +14 -0
- package/package.json +47 -0
- package/pagination/Pagination.d.ts +3 -0
- package/pagination/Pagination.js +191 -0
- package/pagination/index.d.ts +2 -0
- package/pagination/index.js +1 -0
- package/pagination/types.d.ts +23 -0
- package/pagination/types.js +1 -0
- package/pagination/utils.d.ts +2 -0
- package/pagination/utils.js +14 -0
- package/pagination/vars.d.ts +14 -0
- package/pagination/vars.js +14 -0
- package/popover/Popover.d.ts +9 -0
- package/popover/Popover.js +173 -0
- package/popover/PopoverFooter.d.ts +3 -0
- package/popover/PopoverFooter.js +51 -0
- package/popover/PopoverHeader.d.ts +3 -0
- package/popover/PopoverHeader.js +37 -0
- package/popover/index.d.ts +2 -0
- package/popover/index.js +1 -0
- package/popover/types.d.ts +46 -0
- package/popover/types.js +1 -0
- package/popover/vars.d.ts +30 -0
- package/popover/vars.js +27 -0
- package/progress/Progress.d.ts +3 -0
- package/progress/Progress.js +45 -0
- package/progress/index.d.ts +2 -0
- package/progress/index.js +1 -0
- package/progress/types.d.ts +19 -0
- package/progress/types.js +1 -0
- package/progress/vars.d.ts +15 -0
- package/progress/vars.js +15 -0
- package/radio/Radio.d.ts +7 -0
- package/radio/Radio.js +38 -0
- package/radio/RadioGroup.d.ts +3 -0
- package/radio/RadioGroup.js +21 -0
- package/radio/index.d.ts +2 -0
- package/radio/index.js +1 -0
- package/radio/types.d.ts +31 -0
- package/radio/types.js +1 -0
- package/radio/vars.d.ts +14 -0
- package/radio/vars.js +14 -0
- package/rating/Rating.d.ts +3 -0
- package/rating/Rating.js +34 -0
- package/rating/index.d.ts +2 -0
- package/rating/index.js +1 -0
- package/rating/internal/RatingStar.d.ts +19 -0
- package/rating/internal/RatingStar.js +37 -0
- package/rating/types.d.ts +18 -0
- package/rating/types.js +1 -0
- package/rating/vars.d.ts +11 -0
- package/rating/vars.js +11 -0
- package/resources.json +128 -0
- package/root/Root.d.ts +3 -0
- package/root/Root.js +85 -0
- package/root/dialog-service.d.ts +12 -0
- package/root/dialog-service.js +62 -0
- package/root/index.d.ts +3 -0
- package/root/index.js +2 -0
- package/root/types.d.ts +16 -0
- package/root/types.js +1 -0
- package/root/vars.d.ts +25 -0
- package/root/vars.js +13 -0
- package/select/Select.d.ts +5 -0
- package/select/Select.js +528 -0
- package/select/index.d.ts +2 -0
- package/select/index.js +1 -0
- package/select/types.d.ts +50 -0
- package/select/types.js +1 -0
- package/select/vars.d.ts +31 -0
- package/select/vars.js +31 -0
- package/separator/Separator.d.ts +3 -0
- package/separator/Separator.js +19 -0
- package/separator/index.d.ts +2 -0
- package/separator/index.js +1 -0
- package/separator/types.d.ts +8 -0
- package/separator/types.js +1 -0
- package/separator/vars.d.ts +9 -0
- package/separator/vars.js +9 -0
- package/skeleton/Skeleton.d.ts +3 -0
- package/skeleton/Skeleton.js +13 -0
- package/skeleton/index.d.ts +2 -0
- package/skeleton/index.js +1 -0
- package/skeleton/types.d.ts +7 -0
- package/skeleton/types.js +1 -0
- package/skeleton/vars.d.ts +6 -0
- package/skeleton/vars.js +6 -0
- package/slider/Slider.d.ts +3 -0
- package/slider/Slider.js +324 -0
- package/slider/index.d.ts +2 -0
- package/slider/index.js +1 -0
- package/slider/types.d.ts +28 -0
- package/slider/types.js +1 -0
- package/slider/vars.d.ts +17 -0
- package/slider/vars.js +17 -0
- package/slides/Slides.d.ts +3 -0
- package/slides/Slides.js +277 -0
- package/slides/index.d.ts +2 -0
- package/slides/index.js +1 -0
- package/slides/types.d.ts +29 -0
- package/slides/types.js +1 -0
- package/slides/vars.d.ts +20 -0
- package/slides/vars.js +20 -0
- package/spinner/Spinner.d.ts +3 -0
- package/spinner/Spinner.js +66 -0
- package/spinner/index.d.ts +2 -0
- package/spinner/index.js +1 -0
- package/spinner/types.d.ts +12 -0
- package/spinner/types.js +1 -0
- package/spinner/vars.d.ts +7 -0
- package/spinner/vars.js +7 -0
- package/stepper/Stepper.d.ts +3 -0
- package/stepper/Stepper.js +87 -0
- package/stepper/index.d.ts +2 -0
- package/stepper/index.js +1 -0
- package/stepper/types.d.ts +22 -0
- package/stepper/types.js +1 -0
- package/stepper/vars.d.ts +19 -0
- package/stepper/vars.js +19 -0
- package/switch/Switch.d.ts +2 -0
- package/switch/Switch.js +48 -0
- package/switch/index.d.ts +2 -0
- package/switch/index.js +1 -0
- package/switch/types.d.ts +18 -0
- package/switch/types.js +1 -0
- package/switch/vars.d.ts +17 -0
- package/switch/vars.js +17 -0
- package/table/Table.d.ts +17 -0
- package/table/Table.js +72 -0
- package/table/TableEmpty.d.ts +3 -0
- package/table/TableEmpty.js +37 -0
- package/table/TableExpand.d.ts +3 -0
- package/table/TableExpand.js +20 -0
- package/table/TableFilter.d.ts +3 -0
- package/table/TableFilter.js +22 -0
- package/table/TableTd.d.ts +3 -0
- package/table/TableTd.js +11 -0
- package/table/TableTh.d.ts +3 -0
- package/table/TableTh.js +33 -0
- package/table/TableThAction.d.ts +3 -0
- package/table/TableThAction.js +18 -0
- package/table/index.d.ts +2 -0
- package/table/index.js +1 -0
- package/table/internal/TableCell.d.ts +19 -0
- package/table/internal/TableCell.js +61 -0
- package/table/types.d.ts +73 -0
- package/table/types.js +1 -0
- package/table/vars.d.ts +29 -0
- package/table/vars.js +28 -0
- package/tabs/Tabs.d.ts +5 -0
- package/tabs/Tabs.js +248 -0
- package/tabs/index.d.ts +2 -0
- package/tabs/index.js +1 -0
- package/tabs/types.d.ts +28 -0
- package/tabs/types.js +1 -0
- package/tabs/vars.d.ts +30 -0
- package/tabs/vars.js +30 -0
- package/tag/Tag.d.ts +3 -0
- package/tag/Tag.js +16 -0
- package/tag/index.d.ts +2 -0
- package/tag/index.js +1 -0
- package/tag/types.d.ts +9 -0
- package/tag/types.js +1 -0
- package/tag/vars.d.ts +13 -0
- package/tag/vars.js +13 -0
- package/textarea/Textarea.d.ts +3 -0
- package/textarea/Textarea.js +72 -0
- package/textarea/index.d.ts +2 -0
- package/textarea/index.js +1 -0
- package/textarea/types.d.ts +18 -0
- package/textarea/types.js +1 -0
- package/textarea/vars.d.ts +7 -0
- package/textarea/vars.js +7 -0
- package/time-picker/TimePicker.d.ts +3 -0
- package/time-picker/TimePicker.js +338 -0
- package/time-picker/index.d.ts +2 -0
- package/time-picker/index.js +1 -0
- package/time-picker/internal/TimePickerPanel.d.ts +16 -0
- package/time-picker/internal/TimePickerPanel.js +138 -0
- package/time-picker/types.d.ts +33 -0
- package/time-picker/types.js +1 -0
- package/time-picker/utils.d.ts +4 -0
- package/time-picker/utils.js +26 -0
- package/time-picker/vars.d.ts +20 -0
- package/time-picker/vars.js +20 -0
- package/timeline/Timeline.d.ts +3 -0
- package/timeline/Timeline.js +53 -0
- package/timeline/index.d.ts +2 -0
- package/timeline/index.js +1 -0
- package/timeline/types.d.ts +15 -0
- package/timeline/types.js +1 -0
- package/timeline/vars.d.ts +19 -0
- package/timeline/vars.js +19 -0
- package/toast/Toast.d.ts +3 -0
- package/toast/Toast.js +123 -0
- package/toast/index.d.ts +2 -0
- package/toast/index.js +1 -0
- package/toast/types.d.ts +17 -0
- package/toast/types.js +1 -0
- package/toast/vars.d.ts +14 -0
- package/toast/vars.js +11 -0
- package/tooltip/Tooltip.d.ts +3 -0
- package/tooltip/Tooltip.js +113 -0
- package/tooltip/index.d.ts +2 -0
- package/tooltip/index.js +1 -0
- package/tooltip/types.d.ts +29 -0
- package/tooltip/types.js +1 -0
- package/tooltip/vars.d.ts +20 -0
- package/tooltip/vars.js +17 -0
- package/transfer/Transfer.d.ts +3 -0
- package/transfer/Transfer.js +156 -0
- package/transfer/index.d.ts +2 -0
- package/transfer/index.js +1 -0
- package/transfer/internal/TransferPanel.d.ts +21 -0
- package/transfer/internal/TransferPanel.js +42 -0
- package/transfer/types.d.ts +34 -0
- package/transfer/types.js +1 -0
- package/transfer/vars.d.ts +17 -0
- package/transfer/vars.js +17 -0
- package/tree/Tree.d.ts +3 -0
- package/tree/Tree.js +165 -0
- package/tree/index.d.ts +2 -0
- package/tree/index.js +1 -0
- package/tree/internal/TreePanel.d.ts +32 -0
- package/tree/internal/TreePanel.js +167 -0
- package/tree/node/abstract-node.d.ts +25 -0
- package/tree/node/abstract-node.js +68 -0
- package/tree/node/multiple-node.d.ts +18 -0
- package/tree/node/multiple-node.js +109 -0
- package/tree/node/single-node.d.ts +16 -0
- package/tree/node/single-node.js +60 -0
- package/tree/node/types.d.ts +6 -0
- package/tree/node/types.js +1 -0
- package/tree/node/vars.d.ts +2 -0
- package/tree/node/vars.js +1 -0
- package/tree/types.d.ts +34 -0
- package/tree/types.js +1 -0
- package/tree/utils.d.ts +6 -0
- package/tree/utils.js +9 -0
- package/tree/vars.d.ts +20 -0
- package/tree/vars.js +20 -0
- package/tree-select/TreeSelect.d.ts +6 -0
- package/tree-select/TreeSelect.js +509 -0
- package/tree-select/index.d.ts +2 -0
- package/tree-select/index.js +1 -0
- package/tree-select/internal/TreeSelectSearchPanel.d.ts +22 -0
- package/tree-select/internal/TreeSelectSearchPanel.js +73 -0
- package/tree-select/internal/types.d.ts +8 -0
- package/tree-select/internal/types.js +1 -0
- package/tree-select/types.d.ts +48 -0
- package/tree-select/types.js +1 -0
- package/tree-select/vars.d.ts +37 -0
- package/tree-select/vars.js +37 -0
- package/types.d.ts +21 -0
- package/types.js +1 -0
- package/upload/Upload.d.ts +19 -0
- package/upload/Upload.js +203 -0
- package/upload/UploadAction.d.ts +3 -0
- package/upload/UploadAction.js +44 -0
- package/upload/UploadButton.d.ts +3 -0
- package/upload/UploadButton.js +31 -0
- package/upload/UploadList.d.ts +3 -0
- package/upload/UploadList.js +62 -0
- package/upload/UploadPicture.d.ts +3 -0
- package/upload/UploadPicture.js +72 -0
- package/upload/UploadPictureList.d.ts +3 -0
- package/upload/UploadPictureList.js +62 -0
- package/upload/UploadPreviewAction.d.ts +3 -0
- package/upload/UploadPreviewAction.js +32 -0
- package/upload/index.d.ts +2 -0
- package/upload/index.js +1 -0
- package/upload/types.d.ts +78 -0
- package/upload/types.js +1 -0
- package/upload/vars.d.ts +65 -0
- package/upload/vars.js +65 -0
- package/utils/handleModalKeyDown.d.ts +2 -0
- package/utils/handleModalKeyDown.js +17 -0
- package/utils/index.d.ts +6 -0
- package/utils/index.js +6 -0
- package/utils/isPrintableCharacter.d.ts +1 -0
- package/utils/isPrintableCharacter.js +3 -0
- package/utils/mergeCS.d.ts +11 -0
- package/utils/mergeCS.js +6 -0
- package/utils/position/getHorizontalSidePosition.d.ts +14 -0
- package/utils/position/getHorizontalSidePosition.js +22 -0
- package/utils/position/getPopupPosition.d.ts +18 -0
- package/utils/position/getPopupPosition.js +170 -0
- package/utils/position/getVerticalSidePosition.d.ts +17 -0
- package/utils/position/getVerticalSidePosition.js +43 -0
- package/vars.d.ts +5 -0
- package/vars.js +5 -0
- package/virtual-scroll/VirtualScroll.d.ts +5 -0
- package/virtual-scroll/VirtualScroll.js +430 -0
- package/virtual-scroll/index.d.ts +2 -0
- package/virtual-scroll/index.js +1 -0
- package/virtual-scroll/types.d.ts +34 -0
- package/virtual-scroll/types.js +1 -0
- package/virtual-scroll/vars.d.ts +1 -0
- package/virtual-scroll/vars.js +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DraftFunction } from '@laser-ui/hooks/useImmer';
|
|
3
|
+
interface PopupId<ID> {
|
|
4
|
+
id: ID;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function useNestedPopup<ID>(): {
|
|
8
|
+
popupIdsRef: import("react").MutableRefObject<PopupId<ID>[]>;
|
|
9
|
+
setPopupIds: (value: PopupId<ID>[] | DraftFunction<PopupId<ID>[]>) => void;
|
|
10
|
+
addPopupId: (id: ID) => void;
|
|
11
|
+
removePopupId: (id: ID) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useForceUpdate } from '@laser-ui/hooks';
|
|
2
|
+
import { freeze, produce } from 'immer';
|
|
3
|
+
import { isFunction } from 'lodash';
|
|
4
|
+
import { useRef } from 'react';
|
|
5
|
+
export function useNestedPopup() {
|
|
6
|
+
const forceUpdate = useForceUpdate();
|
|
7
|
+
const popupIdsRef = useRef([]);
|
|
8
|
+
const setPopupIds = (value) => {
|
|
9
|
+
popupIdsRef.current = isFunction(value) ? produce(popupIdsRef.current, value) : freeze(value);
|
|
10
|
+
forceUpdate();
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
popupIdsRef,
|
|
14
|
+
setPopupIds,
|
|
15
|
+
addPopupId: (id) => {
|
|
16
|
+
setPopupIds((draft) => {
|
|
17
|
+
if (draft.findIndex((v) => v.id === id) === -1) {
|
|
18
|
+
draft.push({ id, visible: true });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
removePopupId: (id) => {
|
|
23
|
+
setPopupIds((draft) => {
|
|
24
|
+
const index = draft.findIndex((v) => v.id === id);
|
|
25
|
+
if (index !== -1) {
|
|
26
|
+
draft[index].visible = false;
|
|
27
|
+
for (let index = draft.length - 1; index >= 0; index--) {
|
|
28
|
+
if (draft[index].visible) {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
draft.pop();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { LContext } from '../context';
|
|
3
|
+
export function useScopedProps(props) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const context = useContext(LContext);
|
|
6
|
+
return { size: (_b = (_a = props.size) !== null && _a !== void 0 ? _a : context.componentSize) !== null && _b !== void 0 ? _b : 'medium', disabled: props.disabled || context.componentDisabled };
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type Styled<C extends {
|
|
3
|
+
[index: string]: string;
|
|
4
|
+
}> = (...args: (keyof C | {
|
|
5
|
+
[K in keyof C]?: any;
|
|
6
|
+
})[]) => {
|
|
7
|
+
className: string;
|
|
8
|
+
style: React.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare function useStyled<C extends {
|
|
11
|
+
[index: string]: string;
|
|
12
|
+
}>(classes: C, styleProvider: {
|
|
13
|
+
[index: string]: string | undefined;
|
|
14
|
+
}, styleOverrides?: {
|
|
15
|
+
[K in keyof C]?: {
|
|
16
|
+
remove?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
}): Styled<C>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isString, isUndefined } from 'lodash';
|
|
2
|
+
import { useContext, useRef } from 'react';
|
|
3
|
+
import { LContext } from '../context';
|
|
4
|
+
export function useStyled(classes, styleProvider, styleOverrides) {
|
|
5
|
+
const context = useContext(LContext);
|
|
6
|
+
const classRoot = {};
|
|
7
|
+
Object.keys(styleProvider).forEach((key) => {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
|
+
classRoot[key] = isUndefined(styleProvider[key]) ? `${context.namespace}-${key}` : styleProvider[key];
|
|
10
|
+
});
|
|
11
|
+
const prevClassRoot = useRef(classRoot);
|
|
12
|
+
const cache = useRef({});
|
|
13
|
+
for (const key of Object.keys(classRoot)) {
|
|
14
|
+
if (prevClassRoot.current[key] !== classRoot[key]) {
|
|
15
|
+
prevClassRoot.current = classRoot;
|
|
16
|
+
cache.current = {};
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const replace = (className) => {
|
|
21
|
+
if (className in cache.current) {
|
|
22
|
+
return cache.current[className];
|
|
23
|
+
}
|
|
24
|
+
const res = (() => {
|
|
25
|
+
if (className.startsWith('^')) {
|
|
26
|
+
for (const key of Object.keys(classRoot)) {
|
|
27
|
+
const prefix = '^' + key;
|
|
28
|
+
if (className.startsWith(prefix)) {
|
|
29
|
+
if (className.length === prefix.length) {
|
|
30
|
+
return classRoot[key] + className.slice(prefix.length);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const joiner = className.slice(prefix.length, prefix.length + 2);
|
|
34
|
+
if (['--', '__'].includes(joiner)) {
|
|
35
|
+
return classRoot[key] + className.slice(prefix.length);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return className;
|
|
42
|
+
})();
|
|
43
|
+
cache.current[className] = res;
|
|
44
|
+
return res;
|
|
45
|
+
};
|
|
46
|
+
return (...args) => {
|
|
47
|
+
const className = [];
|
|
48
|
+
const style = {};
|
|
49
|
+
const handleKey = (classKey) => {
|
|
50
|
+
let remove = false;
|
|
51
|
+
if (styleOverrides && styleOverrides[classKey]) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
+
const styleOverride = styleOverrides[classKey];
|
|
54
|
+
if (styleOverride.remove) {
|
|
55
|
+
remove = true;
|
|
56
|
+
}
|
|
57
|
+
if (styleOverride.className) {
|
|
58
|
+
className.push(styleOverride.className);
|
|
59
|
+
}
|
|
60
|
+
if (styleOverride.style) {
|
|
61
|
+
Object.assign(style, styleOverride.style);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!remove) {
|
|
65
|
+
className.push(replace(classes[classKey]));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
args.forEach((classKey) => {
|
|
69
|
+
if (isString(classKey)) {
|
|
70
|
+
handleKey(classKey);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
Object.keys(classKey).forEach((key) => {
|
|
74
|
+
if (classKey[key]) {
|
|
75
|
+
handleKey(key);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return { className: className.join(' '), style };
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { get } from 'lodash';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { RootContext } from '../root/vars';
|
|
4
|
+
export function useTranslation() {
|
|
5
|
+
const context = useContext(RootContext);
|
|
6
|
+
const lang = context.i18nLang;
|
|
7
|
+
return {
|
|
8
|
+
t: (...path) => {
|
|
9
|
+
if (path.length === 1) {
|
|
10
|
+
path = ['Common', path[0]];
|
|
11
|
+
}
|
|
12
|
+
path.unshift(lang);
|
|
13
|
+
return get(context.i18nResources, path, path.join('.'));
|
|
14
|
+
},
|
|
15
|
+
lang,
|
|
16
|
+
};
|
|
17
|
+
}
|
package/icon/Icon.d.ts
ADDED
package/icon/Icon.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isArray, isNumber, isUndefined } from 'lodash';
|
|
4
|
+
import { cloneElement } from 'react';
|
|
5
|
+
import { CLASSES } from './vars';
|
|
6
|
+
import { useComponentProps, useNamespace, useStyled } from '../hooks';
|
|
7
|
+
import { mergeCS } from '../utils';
|
|
8
|
+
export function Icon(props) {
|
|
9
|
+
const _a = useComponentProps('Icon', props), { children, styleOverrides, styleProvider, size = '1em', theme, rotate, spin, spinSpeed = 1 } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "size", "theme", "rotate", "spin", "spinSpeed"]);
|
|
10
|
+
const namespace = useNamespace();
|
|
11
|
+
const styled = useStyled(CLASSES, { icon: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.icon }, styleOverrides);
|
|
12
|
+
const [width, height] = isArray(size) ? size : [size, size];
|
|
13
|
+
return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('icon', { [`icon.t-${theme}`]: theme }), {
|
|
14
|
+
className: restProps.className,
|
|
15
|
+
style: restProps.style,
|
|
16
|
+
}), { children: cloneElement(children, Object.assign(Object.assign({}, children.props), { style: Object.assign(Object.assign({}, children.props.style), { transform: isUndefined(rotate) ? undefined : `rotate(${rotate}deg)`, animation: spin ? `${namespace}-spin ${spinSpeed}${isNumber(spinSpeed) ? 's' : ''} linear infinite` : undefined }), fill: 'currentColor', width,
|
|
17
|
+
height })) })));
|
|
18
|
+
}
|
package/icon/index.d.ts
ADDED
package/icon/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Icon } from './Icon';
|
package/icon/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CLASSES } from './vars';
|
|
3
|
+
import type { BaseProps } from '../types';
|
|
4
|
+
export {};
|
|
5
|
+
export interface IconProps extends BaseProps<'icon', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
6
|
+
children: React.FunctionComponentElement<React.SVGProps<SVGSVGElement>>;
|
|
7
|
+
size?: number | string | [number | string, number | string];
|
|
8
|
+
theme?: 'primary' | 'success' | 'warning' | 'danger';
|
|
9
|
+
rotate?: number;
|
|
10
|
+
spin?: boolean;
|
|
11
|
+
spinSpeed?: number | string;
|
|
12
|
+
}
|
package/icon/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/icon/vars.d.ts
ADDED
package/icon/vars.js
ADDED
package/image/Image.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ImageProps } from './types';
|
|
3
|
+
import { ImageAction } from './ImageAction';
|
|
4
|
+
import { ImagePreview } from './ImagePreview';
|
|
5
|
+
export declare const Image: {
|
|
6
|
+
(props: ImageProps): JSX.Element | null;
|
|
7
|
+
Action: typeof ImageAction;
|
|
8
|
+
Preview: typeof ImagePreview;
|
|
9
|
+
};
|
package/image/Image.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useForceUpdate } from '@laser-ui/hooks';
|
|
4
|
+
import { checkNodeExist } from '@laser-ui/utils';
|
|
5
|
+
import { Children, useRef } from 'react';
|
|
6
|
+
import { ImageAction } from './ImageAction';
|
|
7
|
+
import { ImagePreview } from './ImagePreview';
|
|
8
|
+
import { CLASSES } from './vars';
|
|
9
|
+
import { useComponentProps, useStyled } from '../hooks';
|
|
10
|
+
import { mergeCS } from '../utils';
|
|
11
|
+
export const Image = (props) => {
|
|
12
|
+
const _a = useComponentProps('Image', props), { styleOverrides, styleProvider, src, loading, error, actions, imgProps } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "src", "loading", "error", "actions", "imgProps"]);
|
|
13
|
+
const styled = useStyled(CLASSES, { image: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.image }, styleOverrides);
|
|
14
|
+
const forceUpdate = useForceUpdate();
|
|
15
|
+
const dataRef = useRef({
|
|
16
|
+
isLoading: true,
|
|
17
|
+
isError: false,
|
|
18
|
+
});
|
|
19
|
+
if (src !== dataRef.current.prevSrc) {
|
|
20
|
+
dataRef.current.prevSrc = src;
|
|
21
|
+
dataRef.current.isLoading = true;
|
|
22
|
+
dataRef.current.isError = false;
|
|
23
|
+
}
|
|
24
|
+
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('image'), {
|
|
25
|
+
className: restProps.className,
|
|
26
|
+
style: restProps.style,
|
|
27
|
+
}), { children: [dataRef.current.isLoading && checkNodeExist(loading) && loading, dataRef.current.isError && checkNodeExist(error) && error, actions && _jsx("div", Object.assign({}, styled('image__actions'), { children: Children.map(actions, (action) => action) })), _jsx("img", Object.assign({}, imgProps, mergeCS(styled('image__img'), {
|
|
28
|
+
className: imgProps === null || imgProps === void 0 ? void 0 : imgProps.className,
|
|
29
|
+
style: Object.assign(Object.assign({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style), { display: (dataRef.current.isLoading && loading) || (dataRef.current.isError && error) ? 'none' : undefined }),
|
|
30
|
+
}), { src: src, onLoadStart: (e) => {
|
|
31
|
+
var _a;
|
|
32
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=458851
|
|
33
|
+
(_a = imgProps === null || imgProps === void 0 ? void 0 : imgProps.onLoadStart) === null || _a === void 0 ? void 0 : _a.call(imgProps, e);
|
|
34
|
+
dataRef.current.isLoading = true;
|
|
35
|
+
forceUpdate();
|
|
36
|
+
}, onLoad: (e) => {
|
|
37
|
+
var _a;
|
|
38
|
+
(_a = imgProps === null || imgProps === void 0 ? void 0 : imgProps.onLoad) === null || _a === void 0 ? void 0 : _a.call(imgProps, e);
|
|
39
|
+
dataRef.current.isLoading = false;
|
|
40
|
+
forceUpdate();
|
|
41
|
+
}, onError: (e) => {
|
|
42
|
+
var _a;
|
|
43
|
+
(_a = imgProps === null || imgProps === void 0 ? void 0 : imgProps.onError) === null || _a === void 0 ? void 0 : _a.call(imgProps, e);
|
|
44
|
+
dataRef.current.isLoading = false;
|
|
45
|
+
dataRef.current.isError = true;
|
|
46
|
+
forceUpdate();
|
|
47
|
+
} }))] })));
|
|
48
|
+
};
|
|
49
|
+
Image.Action = ImageAction;
|
|
50
|
+
Image.Preview = ImagePreview;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { CLASSES } from './vars';
|
|
5
|
+
import { useComponentProps, useStyled } from '../hooks';
|
|
6
|
+
import { mergeCS } from '../utils';
|
|
7
|
+
export const ImageAction = forwardRef((props, ref) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const _b = useComponentProps('ImageAction', props), { children, styleOverrides, styleProvider } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider"]);
|
|
10
|
+
const styled = useStyled(CLASSES, { image: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.image }, styleOverrides);
|
|
11
|
+
return (_jsx("button", Object.assign({}, restProps, mergeCS(styled('image__action'), {
|
|
12
|
+
className: restProps.className,
|
|
13
|
+
style: restProps.style,
|
|
14
|
+
}), { ref: ref, type: (_a = restProps['type']) !== null && _a !== void 0 ? _a : 'button', children: children })));
|
|
15
|
+
});
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useEvent, useImmer, useRefExtra } from '@laser-ui/hooks';
|
|
5
|
+
import { ReactComponent as CloseOutlined } from '@material-design-icons/svg/outlined/close.svg';
|
|
6
|
+
import { ReactComponent as KeyboardArrowLeftOutlined } from '@material-design-icons/svg/outlined/keyboard_arrow_left.svg';
|
|
7
|
+
import { ReactComponent as KeyboardArrowRightOutlined } from '@material-design-icons/svg/outlined/keyboard_arrow_right.svg';
|
|
8
|
+
import { ReactComponent as Rotate90DegreesCwOutlined } from '@material-design-icons/svg/outlined/rotate_90_degrees_cw.svg';
|
|
9
|
+
import { ReactComponent as ZoomInOutlined } from '@material-design-icons/svg/outlined/zoom_in.svg';
|
|
10
|
+
import { ReactComponent as ZoomOutOutlined } from '@material-design-icons/svg/outlined/zoom_out.svg';
|
|
11
|
+
import { isNull, isUndefined } from 'lodash';
|
|
12
|
+
import { useRef, useState } from 'react';
|
|
13
|
+
import { PREVIEW_CLASSES } from './vars';
|
|
14
|
+
import { Button } from '../button';
|
|
15
|
+
import { useComponentProps, useControlled, useLockScroll, useMaxIndex, useNamespace, useStyled } from '../hooks';
|
|
16
|
+
import { Icon } from '../icon';
|
|
17
|
+
import { Input } from '../input';
|
|
18
|
+
import { Mask } from '../internal/mask';
|
|
19
|
+
import { Portal } from '../internal/portal';
|
|
20
|
+
import { Transition } from '../internal/transition';
|
|
21
|
+
import { ROOT_DATA } from '../root/vars';
|
|
22
|
+
import { mergeCS } from '../utils';
|
|
23
|
+
import { TTANSITION_DURING_BASE } from '../vars';
|
|
24
|
+
export function ImagePreview(props) {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const _d = useComponentProps('ImagePreview', props), { styleOverrides, styleProvider, list, visible, active: activeProp, defaultActive, escClosable = true, zIndex: zIndexProp, onActiveChange, onClose, afterVisibleChange } = _d, restProps = __rest(_d, ["styleOverrides", "styleProvider", "list", "visible", "active", "defaultActive", "escClosable", "zIndex", "onActiveChange", "onClose", "afterVisibleChange"]);
|
|
27
|
+
const namespace = useNamespace();
|
|
28
|
+
const styled = useStyled(PREVIEW_CLASSES, { 'image-preview': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['image-preview'] }, styleOverrides);
|
|
29
|
+
const previewRef = useRef(null);
|
|
30
|
+
const windowRef = useRefExtra(() => window);
|
|
31
|
+
const dataRef = useRef({
|
|
32
|
+
prevActiveEl: null,
|
|
33
|
+
eventData: {},
|
|
34
|
+
});
|
|
35
|
+
const [active, changeActive] = useControlled(defaultActive !== null && defaultActive !== void 0 ? defaultActive : 0, activeProp, onActiveChange);
|
|
36
|
+
const activeSrc = list[active].src;
|
|
37
|
+
const [offset, setOffset] = useState(() => {
|
|
38
|
+
if (ROOT_DATA.windowSize.width) {
|
|
39
|
+
return ~~((ROOT_DATA.windowSize.width - 108) / 120);
|
|
40
|
+
}
|
|
41
|
+
return 3;
|
|
42
|
+
});
|
|
43
|
+
useEvent(windowRef, 'resize', () => {
|
|
44
|
+
setOffset(~~((ROOT_DATA.windowSize.width - 108) / 120));
|
|
45
|
+
}, {}, !visible);
|
|
46
|
+
let startIndex = Math.max(active - offset, 0);
|
|
47
|
+
const endIndex = Math.min(startIndex + offset * 2, list.length - 1);
|
|
48
|
+
startIndex = Math.max(endIndex - offset * 2, 0);
|
|
49
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
50
|
+
const listenDragEvent = visible && isDragging;
|
|
51
|
+
const [position, setPosition] = useImmer(new Map());
|
|
52
|
+
const activePosition = (_a = position.get(activeSrc)) !== null && _a !== void 0 ? _a : { top: 0, left: 0 };
|
|
53
|
+
const [rotate, setRotate] = useImmer(new Map());
|
|
54
|
+
const activeRotate = (_b = rotate.get(activeSrc)) !== null && _b !== void 0 ? _b : 0;
|
|
55
|
+
const [scale, setScale] = useImmer(new Map());
|
|
56
|
+
const activeScale = (_c = scale.get(activeSrc)) !== null && _c !== void 0 ? _c : 1;
|
|
57
|
+
const maxZIndex = useMaxIndex(visible);
|
|
58
|
+
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
59
|
+
useLockScroll(visible);
|
|
60
|
+
const handleMove = () => {
|
|
61
|
+
const { initMove, currentMove, initScale, currentScale } = dataRef.current.eventData;
|
|
62
|
+
if (initMove && currentMove) {
|
|
63
|
+
const movementX = currentMove.x - initMove.x;
|
|
64
|
+
const movementY = currentMove.y - initMove.y;
|
|
65
|
+
setPosition((draft) => {
|
|
66
|
+
var _a;
|
|
67
|
+
const oldPosition = (_a = draft.get(activeSrc)) !== null && _a !== void 0 ? _a : { top: 0, left: 0 };
|
|
68
|
+
draft.set(activeSrc, {
|
|
69
|
+
top: oldPosition.top + movementY,
|
|
70
|
+
left: oldPosition.left + movementX,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
dataRef.current.eventData.initMove = currentMove;
|
|
74
|
+
dataRef.current.eventData.currentMove = undefined;
|
|
75
|
+
}
|
|
76
|
+
if (initScale && currentScale) {
|
|
77
|
+
const initLength = Math.sqrt(Math.pow(initScale.x0 - initScale.x1, 2) + Math.pow(initScale.y0 - initScale.y1, 2));
|
|
78
|
+
const currentLength = Math.sqrt(Math.pow(currentScale.x0 - currentScale.x1, 2) + Math.pow(currentScale.y0 - currentScale.y1, 2));
|
|
79
|
+
setScale((draft) => {
|
|
80
|
+
var _a;
|
|
81
|
+
const oldScale = (_a = draft.get(activeSrc)) !== null && _a !== void 0 ? _a : 1;
|
|
82
|
+
draft.set(activeSrc, Math.max(oldScale + (currentLength - initLength) / 100, 1));
|
|
83
|
+
});
|
|
84
|
+
dataRef.current.eventData.initScale = currentScale;
|
|
85
|
+
dataRef.current.eventData.currentScale = undefined;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
useEvent(windowRef, 'touchmove', (e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (e.touches.length === 2) {
|
|
91
|
+
dataRef.current.eventData.initMove = dataRef.current.eventData.currentMove = undefined;
|
|
92
|
+
const newScale = {
|
|
93
|
+
x0: e.touches[0].clientX,
|
|
94
|
+
y0: e.touches[0].clientY,
|
|
95
|
+
x1: e.touches[1].clientX,
|
|
96
|
+
y1: e.touches[1].clientY,
|
|
97
|
+
};
|
|
98
|
+
if (isUndefined(dataRef.current.eventData.initScale)) {
|
|
99
|
+
dataRef.current.eventData.initScale = newScale;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
dataRef.current.eventData.currentScale = newScale;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
dataRef.current.eventData.initScale = dataRef.current.eventData.currentScale = undefined;
|
|
107
|
+
const newMove = {
|
|
108
|
+
x: e.touches[0].clientX,
|
|
109
|
+
y: e.touches[0].clientY,
|
|
110
|
+
};
|
|
111
|
+
if (isUndefined(dataRef.current.eventData.initMove)) {
|
|
112
|
+
dataRef.current.eventData.initMove = newMove;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
dataRef.current.eventData.currentMove = newMove;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
handleMove();
|
|
119
|
+
}, { passive: false }, !listenDragEvent);
|
|
120
|
+
useEvent(windowRef, 'mousemove', (e) => {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
const newMove = {
|
|
123
|
+
x: e.clientX,
|
|
124
|
+
y: e.clientY,
|
|
125
|
+
};
|
|
126
|
+
if (isUndefined(dataRef.current.eventData.initMove)) {
|
|
127
|
+
dataRef.current.eventData.initMove = newMove;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
dataRef.current.eventData.currentMove = newMove;
|
|
131
|
+
}
|
|
132
|
+
handleMove();
|
|
133
|
+
}, {}, !listenDragEvent);
|
|
134
|
+
useEvent(windowRef, 'mouseup', () => {
|
|
135
|
+
setIsDragging(false);
|
|
136
|
+
}, {}, !listenDragEvent);
|
|
137
|
+
return (_jsx(Portal, { selector: () => {
|
|
138
|
+
let el = document.getElementById(`${namespace}-image-preview-root`);
|
|
139
|
+
if (!el) {
|
|
140
|
+
el = document.createElement('div');
|
|
141
|
+
el.id = `${namespace}-image-preview-root`;
|
|
142
|
+
document.body.appendChild(el);
|
|
143
|
+
}
|
|
144
|
+
return el;
|
|
145
|
+
}, children: _jsx(Transition, { enter: visible, during: TTANSITION_DURING_BASE, destroyWhenLeaved: true, afterEnter: () => {
|
|
146
|
+
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
147
|
+
dataRef.current.prevActiveEl = document.activeElement;
|
|
148
|
+
if (previewRef.current) {
|
|
149
|
+
previewRef.current.focus({ preventScroll: true });
|
|
150
|
+
}
|
|
151
|
+
}, afterLeave: () => {
|
|
152
|
+
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
153
|
+
if (dataRef.current.prevActiveEl) {
|
|
154
|
+
dataRef.current.prevActiveEl.focus({ preventScroll: true });
|
|
155
|
+
}
|
|
156
|
+
}, children: (state) => {
|
|
157
|
+
let transitionStyle = {};
|
|
158
|
+
switch (state) {
|
|
159
|
+
case 'enter':
|
|
160
|
+
transitionStyle = { transform: 'scale(0.3)', opacity: 0 };
|
|
161
|
+
break;
|
|
162
|
+
case 'entering':
|
|
163
|
+
transitionStyle = {
|
|
164
|
+
transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-out`).join(', '),
|
|
165
|
+
};
|
|
166
|
+
break;
|
|
167
|
+
case 'leaving':
|
|
168
|
+
transitionStyle = {
|
|
169
|
+
transform: 'scale(0.3)',
|
|
170
|
+
opacity: 0,
|
|
171
|
+
transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-in`).join(', '),
|
|
172
|
+
};
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('image-preview'), {
|
|
178
|
+
className: restProps.className,
|
|
179
|
+
style: Object.assign(Object.assign(Object.assign({}, restProps.style), transitionStyle), { display: state === 'leaved' ? 'none' : undefined, zIndex }),
|
|
180
|
+
}), { ref: previewRef, tabIndex: -1, onKeyDown: (e) => {
|
|
181
|
+
var _a;
|
|
182
|
+
(_a = restProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
183
|
+
if (visible && escClosable && e.code === 'Escape') {
|
|
184
|
+
e.stopPropagation();
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
187
|
+
}
|
|
188
|
+
}, children: [_jsx("button", Object.assign({}, styled('image-preview__navigation-button', 'image-preview__navigation-button--prev'), { onClick: () => {
|
|
189
|
+
changeActive((prevActive) => {
|
|
190
|
+
return prevActive === 0 ? list.length - 1 : prevActive - 1;
|
|
191
|
+
});
|
|
192
|
+
}, children: _jsx(Icon, { children: _jsx(KeyboardArrowLeftOutlined, {}) }) })), _jsx("button", Object.assign({}, styled('image-preview__navigation-button', 'image-preview__navigation-button--next'), { onClick: () => {
|
|
193
|
+
changeActive((prevActive) => {
|
|
194
|
+
return prevActive === list.length - 1 ? 0 : prevActive + 1;
|
|
195
|
+
});
|
|
196
|
+
}, children: _jsx(Icon, { children: _jsx(KeyboardArrowRightOutlined, {}) }) })), _jsxs("ul", Object.assign({}, styled('image-preview__toolbar'), { children: [_jsxs("li", Object.assign({}, styled('image-preview__toolbar-page'), { children: [_jsx(Input.Number, Object.assign({}, styled('image-preview__toolbar-page-input'), { model: active + 1, min: 1, max: list.length, integer: true, onModelChange: (val) => {
|
|
197
|
+
if (!isNull(val)) {
|
|
198
|
+
changeActive(val - 1);
|
|
199
|
+
}
|
|
200
|
+
} })), _jsx("span", { children: "/" }), _jsx("span", { children: list.length })] })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-rotate'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(Rotate90DegreesCwOutlined, {}) }), onClick: () => {
|
|
201
|
+
setRotate((draft) => {
|
|
202
|
+
var _a;
|
|
203
|
+
const oldRotate = (_a = draft.get(activeSrc)) !== null && _a !== void 0 ? _a : 0;
|
|
204
|
+
draft.set(activeSrc, oldRotate + 90);
|
|
205
|
+
});
|
|
206
|
+
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-zoom-out'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(ZoomOutOutlined, {}) }), onClick: () => {
|
|
207
|
+
setScale((draft) => {
|
|
208
|
+
var _a;
|
|
209
|
+
const oldScale = (_a = draft.get(activeSrc)) !== null && _a !== void 0 ? _a : 1;
|
|
210
|
+
draft.set(activeSrc, Math.max(oldScale / 1.3, 1));
|
|
211
|
+
});
|
|
212
|
+
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-zoom'), { children: _jsx(Input.Number, Object.assign({}, styled('image-preview__toolbar-zoom-input'), { model: Math.round(activeScale * 100), min: 100, step: 10, integer: true, onModelChange: (val) => {
|
|
213
|
+
if (!isNull(val)) {
|
|
214
|
+
setScale((draft) => {
|
|
215
|
+
draft.set(activeSrc, val / 100);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
} })) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-zoom-in'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(ZoomInOutlined, {}) }), onClick: () => {
|
|
219
|
+
setScale((draft) => {
|
|
220
|
+
var _a;
|
|
221
|
+
const oldScale = (_a = draft.get(activeSrc)) !== null && _a !== void 0 ? _a : 1;
|
|
222
|
+
draft.set(activeSrc, oldScale * 1.3);
|
|
223
|
+
});
|
|
224
|
+
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-close'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }), onClick: () => {
|
|
225
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
226
|
+
} }) }))] })), _jsx("img", Object.assign({}, list[active], mergeCS(styled('image-preview__img'), {
|
|
227
|
+
style: {
|
|
228
|
+
transform: `translate(${activePosition.left}px, ${activePosition.top}px) rotate(${activeRotate}deg) scale(${activeScale})`,
|
|
229
|
+
},
|
|
230
|
+
}), { tabIndex: -1, onMouseDown: (e) => {
|
|
231
|
+
if (e.button === 0) {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
234
|
+
dataRef.current.eventData = {};
|
|
235
|
+
setIsDragging(true);
|
|
236
|
+
}
|
|
237
|
+
}, onMouseUp: (e) => {
|
|
238
|
+
if (e.button === 0) {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
}
|
|
241
|
+
}, onTouchStart: (e) => {
|
|
242
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
243
|
+
dataRef.current.eventData = {};
|
|
244
|
+
setIsDragging(true);
|
|
245
|
+
}, onTouchEnd: () => {
|
|
246
|
+
setIsDragging(false);
|
|
247
|
+
}, onWheel: (e) => {
|
|
248
|
+
setScale((draft) => {
|
|
249
|
+
var _a;
|
|
250
|
+
const oldScale = (_a = draft.get(activeSrc)) !== null && _a !== void 0 ? _a : 1;
|
|
251
|
+
draft.set(activeSrc, e.deltaY < 0 ? oldScale + 0.1 : Math.max(oldScale - 0.1, 1));
|
|
252
|
+
});
|
|
253
|
+
} })), _jsx("ul", Object.assign({}, styled('image-preview__thumbnail-list'), { children: list.map((imgProps, index) => index >= startIndex &&
|
|
254
|
+
index <= endIndex && (_createElement("li", Object.assign({}, styled('image-preview__thumbnail', {
|
|
255
|
+
'image-preview__thumbnail.is-active': active === index,
|
|
256
|
+
}), { key: index, onClick: () => {
|
|
257
|
+
changeActive(index);
|
|
258
|
+
} }),
|
|
259
|
+
_jsx("img", Object.assign({}, imgProps, styled('image-preview__thumbnail-img')))))) })), _jsx(Mask, { visible: true })] })));
|
|
260
|
+
} }) }));
|
|
261
|
+
}
|
package/image/index.d.ts
ADDED
package/image/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Image } from './Image';
|