huibo-ui 0.3.0 → 0.5.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/dist/cjs/{a11y-802de67a.js → a11y-4385c871.js} +17 -2
- package/dist/cjs/a11y-4385c871.js.map +1 -0
- package/dist/cjs/{date-helpers-904747ff.js → date-helpers-c05ef385.js} +10 -17
- package/dist/cjs/date-helpers-c05ef385.js.map +1 -0
- package/dist/cjs/hb-affix.cjs.entry.js +1 -1
- package/dist/cjs/hb-alert.cjs.entry.js +2 -1
- package/dist/cjs/hb-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-aside.cjs.entry.js +1 -1
- package/dist/cjs/hb-avatar.cjs.entry.js +1 -1
- package/dist/cjs/hb-backtop.cjs.entry.js +2 -2
- package/dist/cjs/hb-badge.cjs.entry.js +1 -1
- package/dist/cjs/hb-breadcrumb-item.cjs.entry.js +1 -1
- package/dist/cjs/hb-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/hb-button.cjs.entry.js +2 -2
- package/dist/cjs/hb-calendar.cjs.entry.js +78 -10
- package/dist/cjs/hb-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-card.cjs.entry.js +1 -1
- package/dist/cjs/hb-cascader.cjs.entry.js +306 -146
- package/dist/cjs/hb-cascader.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-checkbox-group.cjs.entry.js +12 -8
- package/dist/cjs/hb-checkbox-group.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-checkbox.cjs.entry.js +9 -4
- package/dist/cjs/hb-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-collapse-item.cjs.entry.js +13 -4
- package/dist/cjs/hb-collapse-item.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-collapse.cjs.entry.js +20 -15
- package/dist/cjs/hb-collapse.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-color-picker-panel.cjs.entry.js +2 -2
- package/dist/cjs/hb-color-picker.cjs.entry.js +108 -28
- package/dist/cjs/hb-color-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-config-provider.cjs.entry.js +1 -1
- package/dist/cjs/hb-container.cjs.entry.js +2 -2
- package/dist/cjs/hb-date-picker-pane.cjs.entry.js +2 -2
- package/dist/cjs/hb-date-picker.cjs.entry.js +90 -9
- package/dist/cjs/hb-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-date-range-picker.cjs.entry.js +3 -3
- package/dist/cjs/hb-date-time-picker.cjs.entry.js +3 -3
- package/dist/cjs/hb-descriptions.cjs.entry.js +2 -2
- package/dist/cjs/hb-descriptions.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-dialog.cjs.entry.js +51 -12
- package/dist/cjs/hb-dialog.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-divider.cjs.entry.js +2 -2
- package/dist/cjs/hb-drawer.cjs.entry.js +34 -4
- package/dist/cjs/hb-drawer.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-dropdown.cjs.entry.js +91 -11
- package/dist/cjs/hb-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-empty.cjs.entry.js +1 -1
- package/dist/cjs/hb-float-button.cjs.entry.js +2 -2
- package/dist/cjs/hb-footer.cjs.entry.js +1 -1
- package/dist/cjs/hb-form-item.cjs.entry.js +61 -9
- package/dist/cjs/hb-form-item.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-form.cjs.entry.js +13 -8
- package/dist/cjs/hb-form.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-header.cjs.entry.js +1 -1
- package/dist/cjs/hb-image-preview.cjs.entry.js +13 -9
- package/dist/cjs/hb-image-preview.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-image.cjs.entry.js +21 -3
- package/dist/cjs/hb-image.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-input-number.cjs.entry.js +7 -7
- package/dist/cjs/hb-input-number.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-input-tag.cjs.entry.js +2 -2
- package/dist/cjs/hb-input.cjs.entry.js +40 -3
- package/dist/cjs/hb-input.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-layout.cjs.entry.js +36 -14
- package/dist/cjs/hb-layout.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-link.cjs.entry.js +2 -2
- package/dist/cjs/hb-loading.cjs.entry.js +2 -2
- package/dist/cjs/hb-main.cjs.entry.js +1 -1
- package/dist/cjs/hb-menu-item.cjs.entry.js +14 -5
- package/dist/cjs/hb-menu-item.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-menu.cjs.entry.js +3 -3
- package/dist/cjs/hb-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-message.cjs.entry.js +13 -4
- package/dist/cjs/hb-message.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-notification.cjs.entry.js +2 -2
- package/dist/cjs/hb-page-header.cjs.entry.js +1 -1
- package/dist/cjs/hb-pagination.cjs.entry.js +24 -8
- package/dist/cjs/hb-pagination.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-popconfirm.cjs.entry.js +57 -8
- package/dist/cjs/hb-popconfirm.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-popover.cjs.entry.js +37 -5
- package/dist/cjs/hb-popover.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-progress.cjs.entry.js +1 -1
- package/dist/cjs/hb-radio.cjs.entry.js +8 -3
- package/dist/cjs/hb-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-rate.cjs.entry.js +46 -4
- package/dist/cjs/hb-rate.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-result.cjs.entry.js +1 -1
- package/dist/cjs/hb-row.cjs.entry.js +2 -2
- package/dist/cjs/hb-scrollbar.cjs.entry.js +5 -5
- package/dist/cjs/hb-scrollbar.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-segmented.cjs.entry.js +50 -5
- package/dist/cjs/hb-segmented.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-select.cjs.entry.js +64 -16
- package/dist/cjs/hb-select.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-slider.cjs.entry.js +186 -23
- package/dist/cjs/hb-slider.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-space.cjs.entry.js +2 -2
- package/dist/cjs/hb-statistic.cjs.entry.js +1 -1
- package/dist/cjs/hb-step.cjs.entry.js +1 -1
- package/dist/cjs/hb-steps.cjs.entry.js +30 -9
- package/dist/cjs/hb-steps.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-sub-menu.cjs.entry.js +5 -5
- package/dist/cjs/hb-switch.cjs.entry.js +9 -4
- package/dist/cjs/hb-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-tab-pane.cjs.entry.js +1 -1
- package/dist/cjs/hb-table.cjs.entry.js +26 -17
- package/dist/cjs/hb-table.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-tabs.cjs.entry.js +31 -10
- package/dist/cjs/hb-tabs.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-tag.cjs.entry.js +3 -2
- package/dist/cjs/hb-tag.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-text.cjs.entry.js +2 -2
- package/dist/cjs/hb-time-picker.cjs.entry.js +14 -9
- package/dist/cjs/hb-time-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-time-select.cjs.entry.js +13 -4
- package/dist/cjs/hb-time-select.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-timeline.cjs.entry.js +1 -1
- package/dist/cjs/hb-tooltip.cjs.entry.js +43 -6
- package/dist/cjs/hb-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-transfer.cjs.entry.js +2 -2
- package/dist/cjs/hb-tree-select.cjs.entry.js +215 -23
- package/dist/cjs/hb-tree-select.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-tree.cjs.entry.js +145 -12
- package/dist/cjs/hb-tree.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-upload.cjs.entry.js +3 -3
- package/dist/cjs/hb-watermark.cjs.entry.js +19 -11
- package/dist/cjs/hb-watermark.cjs.entry.js.map +1 -1
- package/dist/cjs/huibo-ui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/transition-59f1da0f.js +34 -0
- package/dist/cjs/transition-59f1da0f.js.map +1 -0
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/Affix/Affix.js +1 -1
- package/dist/collection/components/Alert/Alert.js +2 -1
- package/dist/collection/components/Alert/Alert.js.map +1 -1
- package/dist/collection/components/Avatar/Avatar.js +1 -1
- package/dist/collection/components/Backtop/Backtop.js +2 -2
- package/dist/collection/components/Badge/Badge.js +1 -1
- package/dist/collection/components/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/collection/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/dist/collection/components/Button/Button.js +2 -2
- package/dist/collection/components/Calendar/Calendar.js +84 -10
- package/dist/collection/components/Calendar/Calendar.js.map +1 -1
- package/dist/collection/components/Calendar/calendar.css +16 -0
- package/dist/collection/components/Card/Card.js +1 -1
- package/dist/collection/components/Cascader/Cascader.js +410 -194
- package/dist/collection/components/Cascader/Cascader.js.map +1 -1
- package/dist/collection/components/Cascader/cascader.css +170 -16
- package/dist/collection/components/Checkbox/Checkbox.js +9 -4
- package/dist/collection/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/collection/components/Checkbox/CheckboxGroup.js +12 -8
- package/dist/collection/components/Checkbox/CheckboxGroup.js.map +1 -1
- package/dist/collection/components/Collapse/Collapse.js +20 -15
- package/dist/collection/components/Collapse/Collapse.js.map +1 -1
- package/dist/collection/components/Collapse/CollapseItem.js +33 -4
- package/dist/collection/components/Collapse/CollapseItem.js.map +1 -1
- package/dist/collection/components/ColorPicker/ColorPicker.js +109 -28
- package/dist/collection/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/collection/components/ColorPicker/color-picker.css +21 -3
- package/dist/collection/components/ColorPickerPanel/ColorPickerPanel.js +2 -2
- package/dist/collection/components/ConfigProvider/ConfigProvider.js +1 -1
- package/dist/collection/components/Container/Aside.js +1 -1
- package/dist/collection/components/Container/Container.js +2 -2
- package/dist/collection/components/Container/Footer.js +1 -1
- package/dist/collection/components/Container/Header.js +1 -1
- package/dist/collection/components/Container/Main.js +1 -1
- package/dist/collection/components/DatePicker/DatePicker.js +94 -12
- package/dist/collection/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/collection/components/DatePicker/date-picker.css +63 -2
- package/dist/collection/components/DatePickerPane/DatePickerPane.js +1 -1
- package/dist/collection/components/DateRangePicker/DateRangePicker.js +2 -2
- package/dist/collection/components/DateTimePicker/DateTimePicker.js +2 -2
- package/dist/collection/components/Descriptions/Descriptions.js +1 -1
- package/dist/collection/components/Descriptions/descriptions.css +52 -10
- package/dist/collection/components/Dialog/Dialog.js +54 -10
- package/dist/collection/components/Dialog/Dialog.js.map +1 -1
- package/dist/collection/components/Dialog/dialog.css +57 -11
- package/dist/collection/components/Divider/Divider.js +2 -2
- package/dist/collection/components/Drawer/Drawer.js +34 -3
- package/dist/collection/components/Drawer/Drawer.js.map +1 -1
- package/dist/collection/components/Drawer/drawer.css +207 -17
- package/dist/collection/components/Dropdown/Dropdown.js +103 -12
- package/dist/collection/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/collection/components/Dropdown/dropdown.css +26 -3
- package/dist/collection/components/Empty/Empty.js +1 -1
- package/dist/collection/components/FloatButton/FloatButton.js +2 -2
- package/dist/collection/components/Form/Form.js +14 -9
- package/dist/collection/components/Form/Form.js.map +1 -1
- package/dist/collection/components/Form/FormItem.js +62 -10
- package/dist/collection/components/Form/FormItem.js.map +1 -1
- package/dist/collection/components/Form/form-item.css +57 -6
- package/dist/collection/components/Form/form.css +1 -0
- package/dist/collection/components/Image/Image.js +24 -3
- package/dist/collection/components/Image/Image.js.map +1 -1
- package/dist/collection/components/ImagePreview/ImagePreview.js +13 -9
- package/dist/collection/components/ImagePreview/ImagePreview.js.map +1 -1
- package/dist/collection/components/Input/Input.js +39 -2
- package/dist/collection/components/Input/Input.js.map +1 -1
- package/dist/collection/components/Input/input.css +22 -4
- package/dist/collection/components/InputNumber/InputNumber.js +6 -6
- package/dist/collection/components/InputNumber/InputNumber.js.map +1 -1
- package/dist/collection/components/InputNumber/input-number.css +11 -1
- package/dist/collection/components/InputTag/InputTag.js +2 -2
- package/dist/collection/components/Layout/Layout.js +87 -34
- package/dist/collection/components/Layout/Layout.js.map +1 -1
- package/dist/collection/components/Layout/Row.js +2 -2
- package/dist/collection/components/Layout/layout.css +1732 -71
- package/dist/collection/components/Link/Link.js +2 -2
- package/dist/collection/components/Loading/Loading.js +2 -2
- package/dist/collection/components/Menu/Menu.js +2 -2
- package/dist/collection/components/Menu/MenuItem.js +34 -5
- package/dist/collection/components/Menu/MenuItem.js.map +1 -1
- package/dist/collection/components/Menu/SubMenu.js +4 -4
- package/dist/collection/components/Menu/menu.css +25 -0
- package/dist/collection/components/Message/Message.js +13 -4
- package/dist/collection/components/Message/Message.js.map +1 -1
- package/dist/collection/components/Notification/Notification.js +2 -2
- package/dist/collection/components/PageHeader/PageHeader.js +1 -1
- package/dist/collection/components/Pagination/Pagination.js +26 -7
- package/dist/collection/components/Pagination/Pagination.js.map +1 -1
- package/dist/collection/components/Pagination/pagination.css +23 -0
- package/dist/collection/components/Popconfirm/Popconfirm.js +66 -7
- package/dist/collection/components/Popconfirm/Popconfirm.js.map +1 -1
- package/dist/collection/components/Popconfirm/popconfirm.css +80 -16
- package/dist/collection/components/Popover/Popover.js +46 -4
- package/dist/collection/components/Popover/Popover.js.map +1 -1
- package/dist/collection/components/Popover/popover.css +49 -8
- package/dist/collection/components/Progress/Progress.js +1 -1
- package/dist/collection/components/Radio/Radio.js +8 -3
- package/dist/collection/components/Radio/Radio.js.map +1 -1
- package/dist/collection/components/Rate/Rate.js +46 -4
- package/dist/collection/components/Rate/Rate.js.map +1 -1
- package/dist/collection/components/Result/Result.js +1 -1
- package/dist/collection/components/Scrollbar/Scrollbar.js +5 -5
- package/dist/collection/components/Scrollbar/Scrollbar.js.map +1 -1
- package/dist/collection/components/Segmented/Segmented.js +65 -6
- package/dist/collection/components/Segmented/Segmented.js.map +1 -1
- package/dist/collection/components/Select/Select.js +63 -15
- package/dist/collection/components/Select/Select.js.map +1 -1
- package/dist/collection/components/Select/select.css +50 -5
- package/dist/collection/components/Slider/Slider.js +218 -24
- package/dist/collection/components/Slider/Slider.js.map +1 -1
- package/dist/collection/components/Slider/slider.css +57 -7
- package/dist/collection/components/Space/Space.js +2 -2
- package/dist/collection/components/Statistic/Statistic.js +1 -1
- package/dist/collection/components/Steps/Step.js +1 -1
- package/dist/collection/components/Steps/Steps.js +35 -8
- package/dist/collection/components/Steps/Steps.js.map +1 -1
- package/dist/collection/components/Switch/Switch.js +8 -3
- package/dist/collection/components/Switch/Switch.js.map +1 -1
- package/dist/collection/components/Switch/switch.css +47 -1
- package/dist/collection/components/Table/Table.js +25 -16
- package/dist/collection/components/Table/Table.js.map +1 -1
- package/dist/collection/components/Table/table.css +26 -2
- package/dist/collection/components/Tabs/TabPane.js +1 -1
- package/dist/collection/components/Tabs/Tabs.js +31 -10
- package/dist/collection/components/Tabs/Tabs.js.map +1 -1
- package/dist/collection/components/Tag/Tag.js +3 -2
- package/dist/collection/components/Tag/Tag.js.map +1 -1
- package/dist/collection/components/Text/Text.js +2 -2
- package/dist/collection/components/TimePicker/TimePicker.js +14 -9
- package/dist/collection/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/collection/components/TimeSelect/TimeSelect.js +13 -4
- package/dist/collection/components/TimeSelect/TimeSelect.js.map +1 -1
- package/dist/collection/components/Timeline/Timeline.js +1 -1
- package/dist/collection/components/Tooltip/Tooltip.js +52 -6
- package/dist/collection/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/collection/components/Tooltip/tooltip.css +24 -2
- package/dist/collection/components/Transfer/Transfer.js +2 -2
- package/dist/collection/components/Tree/Tree.js +147 -13
- package/dist/collection/components/Tree/Tree.js.map +1 -1
- package/dist/collection/components/TreeSelect/TreeSelect.js +219 -23
- package/dist/collection/components/TreeSelect/TreeSelect.js.map +1 -1
- package/dist/collection/components/TreeSelect/tree-select.css +41 -7
- package/dist/collection/components/Upload/Upload.js +3 -3
- package/dist/collection/components/Watermark/Watermark.js +19 -11
- package/dist/collection/components/Watermark/Watermark.js.map +1 -1
- package/dist/collection/utils/a11y.js +15 -1
- package/dist/collection/utils/a11y.js.map +1 -1
- package/dist/collection/utils/date-helpers.js +9 -16
- package/dist/collection/utils/date-helpers.js.map +1 -1
- package/dist/collection/utils/transition.js +29 -0
- package/dist/collection/utils/transition.js.map +1 -0
- package/dist/components/hb-affix.js +1 -1
- package/dist/components/hb-alert.js +2 -1
- package/dist/components/hb-alert.js.map +1 -1
- package/dist/components/hb-aside.js +1 -1
- package/dist/components/hb-avatar.js +1 -1
- package/dist/components/hb-backtop.js +2 -2
- package/dist/components/hb-badge.js +1 -1
- package/dist/components/hb-breadcrumb-item.js +1 -1
- package/dist/components/hb-breadcrumb.js +1 -1
- package/dist/components/hb-button.js +2 -2
- package/dist/components/hb-calendar.js +80 -11
- package/dist/components/hb-calendar.js.map +1 -1
- package/dist/components/hb-card.js +1 -1
- package/dist/components/hb-cascader.js +309 -146
- package/dist/components/hb-cascader.js.map +1 -1
- package/dist/components/hb-checkbox-group.js +12 -8
- package/dist/components/hb-checkbox-group.js.map +1 -1
- package/dist/components/hb-checkbox.js +9 -4
- package/dist/components/hb-checkbox.js.map +1 -1
- package/dist/components/hb-collapse-item.js +14 -4
- package/dist/components/hb-collapse-item.js.map +1 -1
- package/dist/components/hb-collapse.js +20 -15
- package/dist/components/hb-collapse.js.map +1 -1
- package/dist/components/hb-color-picker-panel.js +2 -2
- package/dist/components/hb-color-picker.js +110 -29
- package/dist/components/hb-color-picker.js.map +1 -1
- package/dist/components/hb-config-provider.js +1 -1
- package/dist/components/hb-container.js +2 -2
- package/dist/components/hb-date-picker-pane.js +2 -2
- package/dist/components/hb-date-picker.js +92 -10
- package/dist/components/hb-date-picker.js.map +1 -1
- package/dist/components/hb-date-range-picker.js +3 -3
- package/dist/components/hb-date-time-picker.js +3 -3
- package/dist/components/hb-descriptions.js +2 -2
- package/dist/components/hb-descriptions.js.map +1 -1
- package/dist/components/hb-dialog.js +53 -13
- package/dist/components/hb-dialog.js.map +1 -1
- package/dist/components/hb-divider.js +2 -2
- package/dist/components/hb-drawer.js +36 -5
- package/dist/components/hb-drawer.js.map +1 -1
- package/dist/components/hb-dropdown.js +94 -12
- package/dist/components/hb-dropdown.js.map +1 -1
- package/dist/components/hb-empty.js +1 -1
- package/dist/components/hb-float-button.js +2 -2
- package/dist/components/hb-footer.js +1 -1
- package/dist/components/hb-form-item.js +61 -9
- package/dist/components/hb-form-item.js.map +1 -1
- package/dist/components/hb-form.js +13 -8
- package/dist/components/hb-form.js.map +1 -1
- package/dist/components/hb-header.js +1 -1
- package/dist/components/hb-icon.js +1 -89
- package/dist/components/hb-icon.js.map +1 -1
- package/dist/components/hb-image-preview.js +13 -9
- package/dist/components/hb-image-preview.js.map +1 -1
- package/dist/components/hb-image.js +23 -3
- package/dist/components/hb-image.js.map +1 -1
- package/dist/components/hb-input-number.js +7 -7
- package/dist/components/hb-input-number.js.map +1 -1
- package/dist/components/hb-input-tag.js +2 -2
- package/dist/components/hb-input.js +40 -3
- package/dist/components/hb-input.js.map +1 -1
- package/dist/components/hb-layout.js +36 -14
- package/dist/components/hb-layout.js.map +1 -1
- package/dist/components/hb-link.js +2 -2
- package/dist/components/hb-loading.js +2 -2
- package/dist/components/hb-main.js +1 -1
- package/dist/components/hb-menu-item.js +15 -5
- package/dist/components/hb-menu-item.js.map +1 -1
- package/dist/components/hb-menu.js +3 -3
- package/dist/components/hb-menu.js.map +1 -1
- package/dist/components/hb-message.js +13 -4
- package/dist/components/hb-message.js.map +1 -1
- package/dist/components/hb-notification.js +2 -2
- package/dist/components/hb-page-header.js +1 -1
- package/dist/components/hb-pagination.js +28 -10
- package/dist/components/hb-pagination.js.map +1 -1
- package/dist/components/hb-popconfirm.js +58 -8
- package/dist/components/hb-popconfirm.js.map +1 -1
- package/dist/components/hb-popover.js +38 -5
- package/dist/components/hb-popover.js.map +1 -1
- package/dist/components/hb-progress.js +1 -1
- package/dist/components/hb-radio.js +8 -3
- package/dist/components/hb-radio.js.map +1 -1
- package/dist/components/hb-rate.js +46 -4
- package/dist/components/hb-rate.js.map +1 -1
- package/dist/components/hb-result.js +1 -1
- package/dist/components/hb-row.js +2 -2
- package/dist/components/hb-scrollbar.js +5 -5
- package/dist/components/hb-scrollbar.js.map +1 -1
- package/dist/components/hb-segmented.js +54 -6
- package/dist/components/hb-segmented.js.map +1 -1
- package/dist/components/hb-select.js +64 -16
- package/dist/components/hb-select.js.map +1 -1
- package/dist/components/hb-slider.js +191 -24
- package/dist/components/hb-slider.js.map +1 -1
- package/dist/components/hb-space.js +2 -2
- package/dist/components/hb-statistic.js +1 -1
- package/dist/components/hb-step.js +1 -1
- package/dist/components/hb-steps.js +35 -8
- package/dist/components/hb-steps.js.map +1 -1
- package/dist/components/hb-sub-menu.js +5 -5
- package/dist/components/hb-switch.js +9 -4
- package/dist/components/hb-switch.js.map +1 -1
- package/dist/components/hb-tab-pane.js +1 -1
- package/dist/components/hb-table.js +26 -17
- package/dist/components/hb-table.js.map +1 -1
- package/dist/components/hb-tabs.js +31 -10
- package/dist/components/hb-tabs.js.map +1 -1
- package/dist/components/hb-tag.js +3 -2
- package/dist/components/hb-tag.js.map +1 -1
- package/dist/components/hb-text.js +2 -2
- package/dist/components/hb-time-picker.js +14 -9
- package/dist/components/hb-time-picker.js.map +1 -1
- package/dist/components/hb-time-select.js +13 -4
- package/dist/components/hb-time-select.js.map +1 -1
- package/dist/components/hb-timeline.js +1 -1
- package/dist/components/hb-tooltip.js +44 -6
- package/dist/components/hb-tooltip.js.map +1 -1
- package/dist/components/hb-transfer.js +2 -2
- package/dist/components/hb-tree-select.js +219 -24
- package/dist/components/hb-tree-select.js.map +1 -1
- package/dist/components/hb-tree.js +147 -13
- package/dist/components/hb-tree.js.map +1 -1
- package/dist/components/hb-upload.js +3 -3
- package/dist/components/hb-watermark.js +19 -11
- package/dist/components/hb-watermark.js.map +1 -1
- package/dist/components/{p-cc0aeb50.js → p-00aa34c8.js} +17 -3
- package/dist/components/p-00aa34c8.js.map +1 -0
- package/dist/components/p-86d92faf.js +93 -0
- package/dist/components/p-86d92faf.js.map +1 -0
- package/dist/{esm/date-helpers-e4d85a67.js → components/p-e0876aca.js} +10 -17
- package/dist/components/p-e0876aca.js.map +1 -0
- package/dist/components/p-fad66d69.js +32 -0
- package/dist/components/p-fad66d69.js.map +1 -0
- package/dist/esm/{a11y-f9ab2964.js → a11y-e4cde5b0.js} +17 -3
- package/dist/esm/a11y-e4cde5b0.js.map +1 -0
- package/dist/{components/p-cf94cbf6.js → esm/date-helpers-259ed2f1.js} +10 -17
- package/dist/esm/date-helpers-259ed2f1.js.map +1 -0
- package/dist/esm/hb-affix.entry.js +1 -1
- package/dist/esm/hb-alert.entry.js +2 -1
- package/dist/esm/hb-alert.entry.js.map +1 -1
- package/dist/esm/hb-aside.entry.js +1 -1
- package/dist/esm/hb-avatar.entry.js +1 -1
- package/dist/esm/hb-backtop.entry.js +2 -2
- package/dist/esm/hb-badge.entry.js +1 -1
- package/dist/esm/hb-breadcrumb-item.entry.js +1 -1
- package/dist/esm/hb-breadcrumb.entry.js +1 -1
- package/dist/esm/hb-button.entry.js +2 -2
- package/dist/esm/hb-calendar.entry.js +78 -10
- package/dist/esm/hb-calendar.entry.js.map +1 -1
- package/dist/esm/hb-card.entry.js +1 -1
- package/dist/esm/hb-cascader.entry.js +306 -146
- package/dist/esm/hb-cascader.entry.js.map +1 -1
- package/dist/esm/hb-checkbox-group.entry.js +12 -8
- package/dist/esm/hb-checkbox-group.entry.js.map +1 -1
- package/dist/esm/hb-checkbox.entry.js +9 -4
- package/dist/esm/hb-checkbox.entry.js.map +1 -1
- package/dist/esm/hb-collapse-item.entry.js +13 -4
- package/dist/esm/hb-collapse-item.entry.js.map +1 -1
- package/dist/esm/hb-collapse.entry.js +20 -15
- package/dist/esm/hb-collapse.entry.js.map +1 -1
- package/dist/esm/hb-color-picker-panel.entry.js +2 -2
- package/dist/esm/hb-color-picker.entry.js +108 -28
- package/dist/esm/hb-color-picker.entry.js.map +1 -1
- package/dist/esm/hb-config-provider.entry.js +1 -1
- package/dist/esm/hb-container.entry.js +2 -2
- package/dist/esm/hb-date-picker-pane.entry.js +2 -2
- package/dist/esm/hb-date-picker.entry.js +90 -9
- package/dist/esm/hb-date-picker.entry.js.map +1 -1
- package/dist/esm/hb-date-range-picker.entry.js +3 -3
- package/dist/esm/hb-date-time-picker.entry.js +3 -3
- package/dist/esm/hb-descriptions.entry.js +2 -2
- package/dist/esm/hb-descriptions.entry.js.map +1 -1
- package/dist/esm/hb-dialog.entry.js +51 -12
- package/dist/esm/hb-dialog.entry.js.map +1 -1
- package/dist/esm/hb-divider.entry.js +2 -2
- package/dist/esm/hb-drawer.entry.js +34 -4
- package/dist/esm/hb-drawer.entry.js.map +1 -1
- package/dist/esm/hb-dropdown.entry.js +91 -11
- package/dist/esm/hb-dropdown.entry.js.map +1 -1
- package/dist/esm/hb-empty.entry.js +1 -1
- package/dist/esm/hb-float-button.entry.js +2 -2
- package/dist/esm/hb-footer.entry.js +1 -1
- package/dist/esm/hb-form-item.entry.js +61 -9
- package/dist/esm/hb-form-item.entry.js.map +1 -1
- package/dist/esm/hb-form.entry.js +13 -8
- package/dist/esm/hb-form.entry.js.map +1 -1
- package/dist/esm/hb-header.entry.js +1 -1
- package/dist/esm/hb-image-preview.entry.js +13 -9
- package/dist/esm/hb-image-preview.entry.js.map +1 -1
- package/dist/esm/hb-image.entry.js +21 -3
- package/dist/esm/hb-image.entry.js.map +1 -1
- package/dist/esm/hb-input-number.entry.js +7 -7
- package/dist/esm/hb-input-number.entry.js.map +1 -1
- package/dist/esm/hb-input-tag.entry.js +2 -2
- package/dist/esm/hb-input.entry.js +40 -3
- package/dist/esm/hb-input.entry.js.map +1 -1
- package/dist/esm/hb-layout.entry.js +36 -14
- package/dist/esm/hb-layout.entry.js.map +1 -1
- package/dist/esm/hb-link.entry.js +2 -2
- package/dist/esm/hb-loading.entry.js +2 -2
- package/dist/esm/hb-main.entry.js +1 -1
- package/dist/esm/hb-menu-item.entry.js +14 -5
- package/dist/esm/hb-menu-item.entry.js.map +1 -1
- package/dist/esm/hb-menu.entry.js +3 -3
- package/dist/esm/hb-menu.entry.js.map +1 -1
- package/dist/esm/hb-message.entry.js +13 -4
- package/dist/esm/hb-message.entry.js.map +1 -1
- package/dist/esm/hb-notification.entry.js +2 -2
- package/dist/esm/hb-page-header.entry.js +1 -1
- package/dist/esm/hb-pagination.entry.js +24 -8
- package/dist/esm/hb-pagination.entry.js.map +1 -1
- package/dist/esm/hb-popconfirm.entry.js +57 -8
- package/dist/esm/hb-popconfirm.entry.js.map +1 -1
- package/dist/esm/hb-popover.entry.js +37 -5
- package/dist/esm/hb-popover.entry.js.map +1 -1
- package/dist/esm/hb-progress.entry.js +1 -1
- package/dist/esm/hb-radio.entry.js +8 -3
- package/dist/esm/hb-radio.entry.js.map +1 -1
- package/dist/esm/hb-rate.entry.js +46 -4
- package/dist/esm/hb-rate.entry.js.map +1 -1
- package/dist/esm/hb-result.entry.js +1 -1
- package/dist/esm/hb-row.entry.js +2 -2
- package/dist/esm/hb-scrollbar.entry.js +5 -5
- package/dist/esm/hb-scrollbar.entry.js.map +1 -1
- package/dist/esm/hb-segmented.entry.js +51 -6
- package/dist/esm/hb-segmented.entry.js.map +1 -1
- package/dist/esm/hb-select.entry.js +64 -16
- package/dist/esm/hb-select.entry.js.map +1 -1
- package/dist/esm/hb-slider.entry.js +186 -23
- package/dist/esm/hb-slider.entry.js.map +1 -1
- package/dist/esm/hb-space.entry.js +2 -2
- package/dist/esm/hb-statistic.entry.js +1 -1
- package/dist/esm/hb-step.entry.js +1 -1
- package/dist/esm/hb-steps.entry.js +28 -7
- package/dist/esm/hb-steps.entry.js.map +1 -1
- package/dist/esm/hb-sub-menu.entry.js +5 -5
- package/dist/esm/hb-switch.entry.js +9 -4
- package/dist/esm/hb-switch.entry.js.map +1 -1
- package/dist/esm/hb-tab-pane.entry.js +1 -1
- package/dist/esm/hb-table.entry.js +26 -17
- package/dist/esm/hb-table.entry.js.map +1 -1
- package/dist/esm/hb-tabs.entry.js +31 -10
- package/dist/esm/hb-tabs.entry.js.map +1 -1
- package/dist/esm/hb-tag.entry.js +3 -2
- package/dist/esm/hb-tag.entry.js.map +1 -1
- package/dist/esm/hb-text.entry.js +2 -2
- package/dist/esm/hb-time-picker.entry.js +14 -9
- package/dist/esm/hb-time-picker.entry.js.map +1 -1
- package/dist/esm/hb-time-select.entry.js +13 -4
- package/dist/esm/hb-time-select.entry.js.map +1 -1
- package/dist/esm/hb-timeline.entry.js +1 -1
- package/dist/esm/hb-tooltip.entry.js +43 -6
- package/dist/esm/hb-tooltip.entry.js.map +1 -1
- package/dist/esm/hb-transfer.entry.js +2 -2
- package/dist/esm/hb-tree-select.entry.js +215 -23
- package/dist/esm/hb-tree-select.entry.js.map +1 -1
- package/dist/esm/hb-tree.entry.js +145 -12
- package/dist/esm/hb-tree.entry.js.map +1 -1
- package/dist/esm/hb-upload.entry.js +3 -3
- package/dist/esm/hb-watermark.entry.js +19 -11
- package/dist/esm/hb-watermark.entry.js.map +1 -1
- package/dist/esm/huibo-ui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/transition-4295d789.js +32 -0
- package/dist/esm/transition-4295d789.js.map +1 -0
- package/dist/huibo-ui/huibo-ui.css +1 -1
- package/dist/huibo-ui/huibo-ui.esm.js +1 -1
- package/dist/huibo-ui/huibo-ui.esm.js.map +1 -1
- package/dist/huibo-ui/p-00aa34c8.js +2 -0
- package/dist/huibo-ui/p-00aa34c8.js.map +1 -0
- package/dist/huibo-ui/p-02f15843.entry.js +2 -0
- package/dist/huibo-ui/p-0cc1e3f3.entry.js +2 -0
- package/dist/huibo-ui/p-0cc1e3f3.entry.js.map +1 -0
- package/dist/huibo-ui/{p-f1c084c5.entry.js → p-0ddae4e9.entry.js} +2 -2
- package/dist/huibo-ui/{p-672076c3.entry.js → p-10f6c184.entry.js} +2 -2
- package/dist/huibo-ui/p-10f6c184.entry.js.map +1 -0
- package/dist/huibo-ui/{p-6ac242fe.entry.js → p-14c3b47b.entry.js} +2 -2
- package/dist/huibo-ui/{p-8c80a765.entry.js → p-15db24e9.entry.js} +2 -2
- package/dist/huibo-ui/{p-8b027491.entry.js → p-193efdc0.entry.js} +2 -2
- package/dist/huibo-ui/{p-8d925e3d.entry.js → p-1b0fbe69.entry.js} +2 -2
- package/dist/huibo-ui/{p-85f68526.entry.js → p-1b98152b.entry.js} +2 -2
- package/dist/huibo-ui/p-1b98152b.entry.js.map +1 -0
- package/dist/huibo-ui/p-1f6d0adb.entry.js +2 -0
- package/dist/huibo-ui/p-1f6d0adb.entry.js.map +1 -0
- package/dist/huibo-ui/{p-f374d5a3.entry.js → p-20632186.entry.js} +2 -2
- package/dist/huibo-ui/{p-e6f2d71d.entry.js → p-20fc554b.entry.js} +2 -2
- package/dist/huibo-ui/{p-64ca0980.entry.js → p-29092b85.entry.js} +2 -2
- package/dist/huibo-ui/p-29092b85.entry.js.map +1 -0
- package/dist/huibo-ui/p-2bc30b1b.entry.js +2 -0
- package/dist/huibo-ui/p-2bc30b1b.entry.js.map +1 -0
- package/dist/huibo-ui/{p-fd19813c.entry.js → p-2bcda1bb.entry.js} +2 -2
- package/dist/huibo-ui/{p-231a7335.entry.js → p-2ca9796a.entry.js} +2 -2
- package/dist/huibo-ui/p-2ca9796a.entry.js.map +1 -0
- package/dist/huibo-ui/{p-e0768565.entry.js → p-3042f986.entry.js} +2 -2
- package/dist/huibo-ui/{p-be48d2aa.entry.js → p-3dacb26b.entry.js} +2 -2
- package/dist/huibo-ui/{p-6a1ec3ff.entry.js → p-3deff48c.entry.js} +2 -2
- package/dist/huibo-ui/{p-c321c4aa.entry.js → p-412ff618.entry.js} +2 -2
- package/dist/huibo-ui/p-415295f3.entry.js +2 -0
- package/dist/huibo-ui/p-415295f3.entry.js.map +1 -0
- package/dist/huibo-ui/p-494e6c25.entry.js +2 -0
- package/dist/huibo-ui/p-494e6c25.entry.js.map +1 -0
- package/dist/huibo-ui/p-4d87d7f4.entry.js +2 -0
- package/dist/huibo-ui/p-4d87d7f4.entry.js.map +1 -0
- package/dist/huibo-ui/p-54a28052.entry.js +2 -0
- package/dist/huibo-ui/p-54a28052.entry.js.map +1 -0
- package/dist/huibo-ui/{p-88127de1.entry.js → p-55cd13eb.entry.js} +2 -2
- package/dist/huibo-ui/{p-58ebb9b3.entry.js → p-5c839288.entry.js} +2 -2
- package/dist/huibo-ui/p-5e253c15.entry.js +2 -0
- package/dist/huibo-ui/p-5e253c15.entry.js.map +1 -0
- package/dist/huibo-ui/p-63d68c61.entry.js +2 -0
- package/dist/huibo-ui/p-63d68c61.entry.js.map +1 -0
- package/dist/huibo-ui/{p-a042e3d0.entry.js → p-6518c435.entry.js} +2 -2
- package/dist/huibo-ui/p-687d8dff.entry.js +2 -0
- package/dist/huibo-ui/p-687d8dff.entry.js.map +1 -0
- package/dist/huibo-ui/p-688460ce.entry.js +2 -0
- package/dist/huibo-ui/p-688460ce.entry.js.map +1 -0
- package/dist/huibo-ui/p-69bb1dd9.entry.js +2 -0
- package/dist/huibo-ui/p-69bb1dd9.entry.js.map +1 -0
- package/dist/huibo-ui/{p-a0015341.entry.js → p-6bfeab80.entry.js} +2 -2
- package/dist/huibo-ui/{p-4001c08d.entry.js → p-6c23fbd1.entry.js} +2 -2
- package/dist/huibo-ui/p-6c23fbd1.entry.js.map +1 -0
- package/dist/huibo-ui/p-6c8cf248.entry.js +2 -0
- package/dist/huibo-ui/p-6c8cf248.entry.js.map +1 -0
- package/dist/huibo-ui/p-6efed295.entry.js +2 -0
- package/dist/huibo-ui/p-6efed295.entry.js.map +1 -0
- package/dist/huibo-ui/{p-8b1ae77e.entry.js → p-746a11a3.entry.js} +2 -2
- package/dist/huibo-ui/{p-c3e8893d.entry.js → p-79b24b83.entry.js} +2 -2
- package/dist/huibo-ui/p-79b24b83.entry.js.map +1 -0
- package/dist/huibo-ui/p-7a38b3e2.entry.js +2 -0
- package/dist/huibo-ui/p-7a38b3e2.entry.js.map +1 -0
- package/dist/huibo-ui/{p-c922d672.entry.js → p-7a682c56.entry.js} +2 -2
- package/dist/huibo-ui/{p-8c987d57.entry.js → p-7f65dc36.entry.js} +2 -2
- package/dist/huibo-ui/{p-463de26d.entry.js → p-815fc943.entry.js} +2 -2
- package/dist/huibo-ui/{p-d87fc21a.entry.js → p-88a6c905.entry.js} +2 -2
- package/dist/huibo-ui/{p-77017274.entry.js → p-89be7973.entry.js} +2 -2
- package/dist/huibo-ui/p-8a202bc5.entry.js +2 -0
- package/dist/huibo-ui/p-8a202bc5.entry.js.map +1 -0
- package/dist/huibo-ui/{p-315feadf.entry.js → p-8c4415ed.entry.js} +2 -2
- package/dist/huibo-ui/p-8c4415ed.entry.js.map +1 -0
- package/dist/huibo-ui/{p-9319c650.entry.js → p-950e7465.entry.js} +2 -2
- package/dist/huibo-ui/{p-6b381d0e.entry.js → p-96cecd21.entry.js} +2 -2
- package/dist/huibo-ui/p-96cecd21.entry.js.map +1 -0
- package/dist/huibo-ui/{p-710f38de.entry.js → p-98b513cd.entry.js} +2 -2
- package/dist/huibo-ui/p-98b513cd.entry.js.map +1 -0
- package/dist/huibo-ui/{p-5df47135.entry.js → p-a190ca89.entry.js} +2 -2
- package/dist/huibo-ui/{p-0e65e1bd.entry.js → p-ac18c68b.entry.js} +2 -2
- package/dist/huibo-ui/p-ac18c68b.entry.js.map +1 -0
- package/dist/huibo-ui/{p-d64b91ef.entry.js → p-ac45291c.entry.js} +2 -2
- package/dist/huibo-ui/p-ac45291c.entry.js.map +1 -0
- package/dist/huibo-ui/{p-477d8568.entry.js → p-aeae83af.entry.js} +2 -2
- package/dist/huibo-ui/{p-b489a526.entry.js → p-b06c8020.entry.js} +2 -2
- package/dist/huibo-ui/{p-dfaf7e37.entry.js → p-b105cf76.entry.js} +2 -2
- package/dist/huibo-ui/p-b105cf76.entry.js.map +1 -0
- package/dist/huibo-ui/{p-c3e665f6.entry.js → p-b38802b0.entry.js} +2 -2
- package/dist/huibo-ui/p-b38802b0.entry.js.map +1 -0
- package/dist/huibo-ui/{p-ea74fcae.entry.js → p-b3fd12c7.entry.js} +2 -2
- package/dist/huibo-ui/p-b3fd12c7.entry.js.map +1 -0
- package/dist/huibo-ui/p-b5ea18ba.entry.js +2 -0
- package/dist/huibo-ui/p-b5ea18ba.entry.js.map +1 -0
- package/dist/huibo-ui/{p-e2a8a396.entry.js → p-b6afe81e.entry.js} +2 -2
- package/dist/huibo-ui/{p-2b286698.entry.js → p-b7885d4a.entry.js} +2 -2
- package/dist/huibo-ui/p-b7900dee.entry.js +2 -0
- package/dist/huibo-ui/p-b7900dee.entry.js.map +1 -0
- package/dist/huibo-ui/p-b8c83751.entry.js +2 -0
- package/dist/huibo-ui/p-b8c83751.entry.js.map +1 -0
- package/dist/huibo-ui/p-c7713947.entry.js +2 -0
- package/dist/huibo-ui/p-c7713947.entry.js.map +1 -0
- package/dist/huibo-ui/{p-e0ab9010.entry.js → p-c869842c.entry.js} +2 -2
- package/dist/huibo-ui/p-c869842c.entry.js.map +1 -0
- package/dist/huibo-ui/{p-476527c1.entry.js → p-c8e917db.entry.js} +2 -2
- package/dist/huibo-ui/p-c8e917db.entry.js.map +1 -0
- package/dist/huibo-ui/p-cb66dbef.entry.js +2 -0
- package/dist/huibo-ui/p-cb66dbef.entry.js.map +1 -0
- package/dist/huibo-ui/p-cde83f76.entry.js +2 -0
- package/dist/huibo-ui/p-cde83f76.entry.js.map +1 -0
- package/dist/huibo-ui/{p-10c088f3.entry.js → p-d9c7c378.entry.js} +2 -2
- package/dist/huibo-ui/{p-332c8877.entry.js → p-dd9c6459.entry.js} +2 -2
- package/dist/huibo-ui/{p-80aca641.entry.js → p-dfccc7aa.entry.js} +2 -2
- package/dist/huibo-ui/{p-21682e92.entry.js → p-dfd144d8.entry.js} +2 -2
- package/dist/huibo-ui/p-e0876aca.js +2 -0
- package/dist/huibo-ui/p-e0876aca.js.map +1 -0
- package/dist/huibo-ui/p-e1773c93.entry.js +2 -0
- package/dist/huibo-ui/p-e1773c93.entry.js.map +1 -0
- package/dist/huibo-ui/{p-079a4130.entry.js → p-e3155cd7.entry.js} +2 -2
- package/dist/huibo-ui/{p-59b2e61c.entry.js → p-e73c357f.entry.js} +2 -2
- package/dist/huibo-ui/p-e73c357f.entry.js.map +1 -0
- package/dist/huibo-ui/{p-c1b4eacb.entry.js → p-e7c73624.entry.js} +2 -2
- package/dist/huibo-ui/p-e7c73624.entry.js.map +1 -0
- package/dist/huibo-ui/{p-d7815b4f.entry.js → p-e9e7abca.entry.js} +2 -2
- package/dist/huibo-ui/{p-f81ec512.entry.js → p-ea0823f3.entry.js} +2 -2
- package/dist/huibo-ui/p-ea0823f3.entry.js.map +1 -0
- package/dist/huibo-ui/{p-2e6584ea.entry.js → p-f1f2483f.entry.js} +2 -2
- package/dist/huibo-ui/{p-465dcb4c.entry.js → p-f2c78699.entry.js} +2 -2
- package/dist/huibo-ui/p-fad66d69.js +2 -0
- package/dist/huibo-ui/p-fad66d69.js.map +1 -0
- package/dist/huibo-ui/{p-4d8b1404.entry.js → p-fd6831f9.entry.js} +2 -2
- package/dist/huibo-ui/p-ff6bc5cc.entry.js +2 -0
- package/dist/huibo-ui/p-ff6bc5cc.entry.js.map +1 -0
- package/dist/types/components/Calendar/Calendar.d.ts +13 -1
- package/dist/types/components/Cascader/Cascader.d.ts +80 -90
- package/dist/types/components/Checkbox/Checkbox.d.ts +5 -0
- package/dist/types/components/Checkbox/CheckboxGroup.d.ts +1 -0
- package/dist/types/components/Collapse/Collapse.d.ts +2 -0
- package/dist/types/components/Collapse/CollapseItem.d.ts +8 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +11 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +14 -3
- package/dist/types/components/Dialog/Dialog.d.ts +13 -1
- package/dist/types/components/Drawer/Drawer.d.ts +4 -0
- package/dist/types/components/Dropdown/Dropdown.d.ts +18 -1
- package/dist/types/components/Form/Form.d.ts +2 -0
- package/dist/types/components/Form/FormItem.d.ts +10 -0
- package/dist/types/components/Image/Image.d.ts +6 -0
- package/dist/types/components/ImagePreview/ImagePreview.d.ts +5 -1
- package/dist/types/components/Input/Input.d.ts +9 -0
- package/dist/types/components/Layout/Layout.d.ts +20 -10
- package/dist/types/components/Menu/MenuItem.d.ts +8 -1
- package/dist/types/components/Message/Message.d.ts +3 -0
- package/dist/types/components/Pagination/Pagination.d.ts +3 -0
- package/dist/types/components/Popconfirm/Popconfirm.d.ts +16 -0
- package/dist/types/components/Popover/Popover.d.ts +14 -0
- package/dist/types/components/Radio/Radio.d.ts +5 -0
- package/dist/types/components/Rate/Rate.d.ts +7 -0
- package/dist/types/components/Segmented/Segmented.d.ts +18 -1
- package/dist/types/components/Select/Select.d.ts +11 -0
- package/dist/types/components/Slider/Slider.d.ts +27 -1
- package/dist/types/components/Steps/Steps.d.ts +14 -6
- package/dist/types/components/Table/Table.d.ts +8 -2
- package/dist/types/components/Tabs/Tabs.d.ts +6 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +15 -1
- package/dist/types/components/Tree/Tree.d.ts +24 -0
- package/dist/types/components/TreeSelect/TreeSelect.d.ts +26 -0
- package/dist/types/components/Watermark/Watermark.d.ts +7 -1
- package/dist/types/components.d.ts +290 -98
- package/dist/types/utils/a11y.d.ts +9 -0
- package/dist/types/utils/date-helpers.d.ts +1 -1
- package/dist/types/utils/transition.d.ts +27 -0
- package/package.json +8 -2
- package/readme.md +88 -73
- package/dist/cjs/a11y-802de67a.js.map +0 -1
- package/dist/cjs/date-helpers-904747ff.js.map +0 -1
- package/dist/components/p-cc0aeb50.js.map +0 -1
- package/dist/components/p-cf94cbf6.js.map +0 -1
- package/dist/esm/a11y-f9ab2964.js.map +0 -1
- package/dist/esm/date-helpers-e4d85a67.js.map +0 -1
- package/dist/huibo-ui/p-003cee87.entry.js +0 -2
- package/dist/huibo-ui/p-003cee87.entry.js.map +0 -1
- package/dist/huibo-ui/p-0a033738.entry.js +0 -2
- package/dist/huibo-ui/p-0a033738.entry.js.map +0 -1
- package/dist/huibo-ui/p-0bef78ac.entry.js +0 -2
- package/dist/huibo-ui/p-0bef78ac.entry.js.map +0 -1
- package/dist/huibo-ui/p-0e65e1bd.entry.js.map +0 -1
- package/dist/huibo-ui/p-0f189251.entry.js +0 -2
- package/dist/huibo-ui/p-0f189251.entry.js.map +0 -1
- package/dist/huibo-ui/p-1b5acd6d.entry.js +0 -2
- package/dist/huibo-ui/p-1b5acd6d.entry.js.map +0 -1
- package/dist/huibo-ui/p-231a7335.entry.js.map +0 -1
- package/dist/huibo-ui/p-24ad7eec.entry.js +0 -2
- package/dist/huibo-ui/p-24ad7eec.entry.js.map +0 -1
- package/dist/huibo-ui/p-315feadf.entry.js.map +0 -1
- package/dist/huibo-ui/p-3c7f73c8.entry.js +0 -2
- package/dist/huibo-ui/p-3c7f73c8.entry.js.map +0 -1
- package/dist/huibo-ui/p-4001c08d.entry.js.map +0 -1
- package/dist/huibo-ui/p-44c48246.entry.js +0 -2
- package/dist/huibo-ui/p-44c48246.entry.js.map +0 -1
- package/dist/huibo-ui/p-476527c1.entry.js.map +0 -1
- package/dist/huibo-ui/p-4d0dff15.entry.js +0 -2
- package/dist/huibo-ui/p-58d20809.entry.js +0 -2
- package/dist/huibo-ui/p-58d20809.entry.js.map +0 -1
- package/dist/huibo-ui/p-59b2e61c.entry.js.map +0 -1
- package/dist/huibo-ui/p-64ca0980.entry.js.map +0 -1
- package/dist/huibo-ui/p-672076c3.entry.js.map +0 -1
- package/dist/huibo-ui/p-6b381d0e.entry.js.map +0 -1
- package/dist/huibo-ui/p-710f38de.entry.js.map +0 -1
- package/dist/huibo-ui/p-756acbdb.entry.js +0 -2
- package/dist/huibo-ui/p-756acbdb.entry.js.map +0 -1
- package/dist/huibo-ui/p-75a93de3.entry.js +0 -2
- package/dist/huibo-ui/p-75a93de3.entry.js.map +0 -1
- package/dist/huibo-ui/p-769960f4.entry.js +0 -2
- package/dist/huibo-ui/p-769960f4.entry.js.map +0 -1
- package/dist/huibo-ui/p-7f6975ad.entry.js +0 -2
- package/dist/huibo-ui/p-7f6975ad.entry.js.map +0 -1
- package/dist/huibo-ui/p-85f68526.entry.js.map +0 -1
- package/dist/huibo-ui/p-8d615521.entry.js +0 -2
- package/dist/huibo-ui/p-8d615521.entry.js.map +0 -1
- package/dist/huibo-ui/p-953b9514.entry.js +0 -2
- package/dist/huibo-ui/p-953b9514.entry.js.map +0 -1
- package/dist/huibo-ui/p-965d4d02.entry.js +0 -2
- package/dist/huibo-ui/p-965d4d02.entry.js.map +0 -1
- package/dist/huibo-ui/p-ad6b0c6e.entry.js +0 -2
- package/dist/huibo-ui/p-ad6b0c6e.entry.js.map +0 -1
- package/dist/huibo-ui/p-c1a059d9.entry.js +0 -2
- package/dist/huibo-ui/p-c1a059d9.entry.js.map +0 -1
- package/dist/huibo-ui/p-c1b4eacb.entry.js.map +0 -1
- package/dist/huibo-ui/p-c3e665f6.entry.js.map +0 -1
- package/dist/huibo-ui/p-c3e8893d.entry.js.map +0 -1
- package/dist/huibo-ui/p-cc0aeb50.js +0 -2
- package/dist/huibo-ui/p-cc0aeb50.js.map +0 -1
- package/dist/huibo-ui/p-cf94cbf6.js +0 -2
- package/dist/huibo-ui/p-cf94cbf6.js.map +0 -1
- package/dist/huibo-ui/p-d3939d44.entry.js +0 -2
- package/dist/huibo-ui/p-d3939d44.entry.js.map +0 -1
- package/dist/huibo-ui/p-d64b91ef.entry.js.map +0 -1
- package/dist/huibo-ui/p-dd05cb2c.entry.js +0 -2
- package/dist/huibo-ui/p-dd05cb2c.entry.js.map +0 -1
- package/dist/huibo-ui/p-dfaf7e37.entry.js.map +0 -1
- package/dist/huibo-ui/p-e0ab9010.entry.js.map +0 -1
- package/dist/huibo-ui/p-e9490259.entry.js +0 -2
- package/dist/huibo-ui/p-e9490259.entry.js.map +0 -1
- package/dist/huibo-ui/p-ea74fcae.entry.js.map +0 -1
- package/dist/huibo-ui/p-ebd04656.entry.js +0 -2
- package/dist/huibo-ui/p-ebd04656.entry.js.map +0 -1
- package/dist/huibo-ui/p-ed0ff857.entry.js +0 -2
- package/dist/huibo-ui/p-ed0ff857.entry.js.map +0 -1
- package/dist/huibo-ui/p-f0ac7db5.entry.js +0 -2
- package/dist/huibo-ui/p-f0ac7db5.entry.js.map +0 -1
- package/dist/huibo-ui/p-f81ec512.entry.js.map +0 -1
- /package/dist/huibo-ui/{p-4d0dff15.entry.js.map → p-02f15843.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-f1c084c5.entry.js.map → p-0ddae4e9.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-6ac242fe.entry.js.map → p-14c3b47b.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-8c80a765.entry.js.map → p-15db24e9.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-8b027491.entry.js.map → p-193efdc0.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-8d925e3d.entry.js.map → p-1b0fbe69.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-f374d5a3.entry.js.map → p-20632186.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-e6f2d71d.entry.js.map → p-20fc554b.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-fd19813c.entry.js.map → p-2bcda1bb.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-e0768565.entry.js.map → p-3042f986.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-be48d2aa.entry.js.map → p-3dacb26b.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-6a1ec3ff.entry.js.map → p-3deff48c.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-c321c4aa.entry.js.map → p-412ff618.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-88127de1.entry.js.map → p-55cd13eb.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-58ebb9b3.entry.js.map → p-5c839288.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-a042e3d0.entry.js.map → p-6518c435.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-a0015341.entry.js.map → p-6bfeab80.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-8b1ae77e.entry.js.map → p-746a11a3.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-c922d672.entry.js.map → p-7a682c56.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-8c987d57.entry.js.map → p-7f65dc36.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-463de26d.entry.js.map → p-815fc943.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-d87fc21a.entry.js.map → p-88a6c905.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-77017274.entry.js.map → p-89be7973.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-9319c650.entry.js.map → p-950e7465.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-5df47135.entry.js.map → p-a190ca89.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-477d8568.entry.js.map → p-aeae83af.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-b489a526.entry.js.map → p-b06c8020.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-e2a8a396.entry.js.map → p-b6afe81e.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-2b286698.entry.js.map → p-b7885d4a.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-10c088f3.entry.js.map → p-d9c7c378.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-332c8877.entry.js.map → p-dd9c6459.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-80aca641.entry.js.map → p-dfccc7aa.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-21682e92.entry.js.map → p-dfd144d8.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-079a4130.entry.js.map → p-e3155cd7.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-d7815b4f.entry.js.map → p-e9e7abca.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-2e6584ea.entry.js.map → p-f1f2483f.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-465dcb4c.entry.js.map → p-f2c78699.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-4d8b1404.entry.js.map → p-fd6831f9.entry.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-dropdown.entry.cjs.js","mappings":";;;;;;;;AAAA,MAAM,WAAW,GAAG,mzNAAmzN,CAAC;AACx0N,yBAAe,WAAW;;MCoBb,QAAQ;;;;;;;IAIX,KAAK,GAAmB,EAAE,CAAC;;IAG3B,OAAO,GAAsB,OAAO,CAAC;;IAGrC,QAAQ,GAAY,KAAK,CAAC;IAEzB,MAAM,GAAY,KAAK,CAAC;;IAGxB,SAAS,CAAuB;IAEjC,YAAY,GAAGA,sCAAyB,CAAC;QAC/C,IAAI,EAAE,IAAW;QACjB,MAAM,EAAE,MAAM,IAAI,CAAC,MAAM;QACzB,OAAO,EAAE,QAAQ,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE;KACxC,CAAC,CAAC;IAEH,gBAAgB;QACd,IAAI,CAAC,YAAY,GAAGA,sCAAyB,CAAC;YAC5C,IAAI,EAAE,IAAI,CAAC,EAAE;YACb,MAAM,EAAE,MAAM,IAAI,CAAC,MAAM;YACzB,OAAO,EAAE,QAAQ,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE;SACxC,CAAC,CAAC;QACH,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,EAAE;YAC5B,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;SAC7B;KACF;IAED,oBAAoB;QAClB,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;KAChC;IAEO,IAAI,GAAG;QACb,IAAI,IAAI,CAAC,QAAQ;YAAE,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ACP,CAAC,CACE,CACP,CACG,EACN;KACH;;;;;;","names":["createClickOutsideHandler","h","getNextZIndex"],"sources":["src/components/Dropdown/dropdown.css?tag=hb-dropdown&encapsulation=shadow","src/components/Dropdown/Dropdown.tsx"],"sourcesContent":[":host {\n display: inline-block;\n position: relative;\n}\n\n.hb-dropdown__trigger {\n display: inline-block;\n cursor: pointer;\n}\n\n.hb-dropdown__menu {\n position: absolute;\n top: 100%;\n left: 0;\n min-width: 120px;\n margin-top: 4px;\n padding: 4px 0;\n background-color: var(--hb-color-bg-elevated);\n border-radius: var(--hb-border-radius-base);\n box-shadow: var(--hb-box-shadow);\n animation: hb-dropdown-fade-in 0.15s ease-out;\n}\n\n.hb-dropdown__item {\n display: flex;\n align-items: center;\n padding: 6px 16px;\n font-size: var(--hb-font-size-sm);\n color: var(--hb-color-text);\n cursor: pointer;\n white-space: nowrap;\n transition: background-color var(--hb-transition-duration);\n}\n\n.hb-dropdown__item:hover:not(.hb-dropdown__item--disabled) {\n background-color: var(--hb-color-fill-tertiary);\n color: var(--hb-color-primary);\n}\n\n.hb-dropdown__item--disabled {\n color: var(--hb-color-text-disabled);\n cursor: not-allowed;\n}\n\n.hb-dropdown__item--divided {\n margin-top: 4px;\n padding-top: 8px;\n border-top: 1px solid var(--hb-color-border-secondary);\n}\n\n.hb-dropdown__item--danger {\n color: var(--hb-color-danger);\n}\n.hb-dropdown__item--danger:hover:not(.hb-dropdown__item--disabled) {\n background-color: var(--hb-color-danger-bg);\n color: var(--hb-color-danger);\n}\n\n@keyframes hb-dropdown-fade-in {\n from { opacity: 0; transform: translateY(-4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n","import { Component, h, Prop, State, Element, Event, EventEmitter } from '@stencil/core';\nimport { createClickOutsideHandler } from '../../utils/click-outside';\nimport { getNextZIndex } from '../../utils/popup-manager';\n\nexport interface DropdownItem {\n key: string;\n label: string;\n disabled?: boolean;\n divided?: boolean;\n danger?: boolean;\n}\n\n/**\n * Dropdown 下拉菜单组件\n * 将动作或菜单折叠到下拉菜单中\n */\n@Component({\n tag: 'hb-dropdown',\n styleUrl: 'dropdown.css',\n shadow: true,\n})\nexport class Dropdown {\n @Element() el: HTMLElement;\n\n /** 菜单项 */\n @Prop() items: DropdownItem[] = [];\n\n /** 触发方式 */\n @Prop() trigger: 'hover' | 'click' = 'hover';\n\n /** 是否禁用 */\n @Prop() disabled: boolean = false;\n\n @State() isOpen: boolean = false;\n\n /** 命令事件 */\n @Event() hbCommand: EventEmitter<string>;\n\n private clickOutside = createClickOutsideHandler({\n host: null as any,\n isOpen: () => this.isOpen,\n onClose: () => { this.isOpen = false; },\n });\n\n componentDidLoad() {\n this.clickOutside = createClickOutsideHandler({\n host: this.el,\n isOpen: () => this.isOpen,\n onClose: () => { this.isOpen = false; },\n });\n if (this.trigger === 'click') {\n this.clickOutside.connect();\n }\n }\n\n disconnectedCallback() {\n this.clickOutside.disconnect();\n }\n\n private show = () => {\n if (this.disabled) return;\n this.isOpen = true;\n };\n\n private hide = () => {\n this.isOpen = false;\n };\n\n private toggle = () => {\n if (this.disabled) return;\n this.isOpen = !this.isOpen;\n };\n\n private handleSelect = (item: DropdownItem) => {\n if (item.disabled) return;\n this.isOpen = false;\n this.hbCommand.emit(item.key);\n };\n\n render() {\n const triggerEvents = this.trigger === 'hover'\n ? { onMouseEnter: this.show, onMouseLeave: this.hide }\n : { onClick: this.toggle };\n\n return (\n <div class=\"hb-dropdown\" {...triggerEvents}>\n <div class=\"hb-dropdown__trigger\">\n <slot />\n </div>\n {this.isOpen && (\n <div class=\"hb-dropdown__menu\" style={{ zIndex: String(getNextZIndex()) }}>\n {this.items.map(item => (\n <div\n class={{\n 'hb-dropdown__item': true,\n 'hb-dropdown__item--disabled': item.disabled,\n 'hb-dropdown__item--divided': item.divided,\n 'hb-dropdown__item--danger': item.danger,\n }}\n onClick={() => this.handleSelect(item)}\n >\n {item.label}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
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C,WAAW,GAAGA,OAAK,CAAC;aAC9C,EACD,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAErC,IAAI,CAAC,KAAK,CACP,CACP,CAAC,CACE,CACP,CACG,EACN;KACH;;;;;;","names":["createLeaveScheduler","createClickOutsideHandler","isActivationKey","handleListKeyboard","h","getNextZIndex","index"],"sources":["src/components/Dropdown/dropdown.css?tag=hb-dropdown&encapsulation=shadow","src/components/Dropdown/Dropdown.tsx"],"sourcesContent":[":host {\n display: inline-block;\n position: relative;\n}\n\n.hb-dropdown__trigger {\n display: inline-block;\n cursor: pointer;\n}\n\n.hb-dropdown__menu {\n position: absolute;\n top: 100%;\n left: 0;\n min-width: 120px;\n margin-top: 4px;\n padding: 4px 0;\n background-color: var(--hb-color-bg-elevated);\n border-radius: var(--hb-border-radius-base);\n box-shadow: var(--hb-box-shadow);\n animation: hb-dropdown-fade-in 0.15s ease-out;\n}\n\n.hb-dropdown__item {\n display: flex;\n align-items: center;\n padding: 6px 16px;\n font-size: var(--hb-font-size-sm);\n color: var(--hb-color-text);\n cursor: pointer;\n white-space: nowrap;\n transition: background-color var(--hb-transition-duration);\n}\n\n.hb-dropdown__item:hover:not(.hb-dropdown__item--disabled),\n.hb-dropdown__item--active:not(.hb-dropdown__item--disabled) {\n background-color: var(--hb-color-fill-tertiary);\n color: var(--hb-color-primary);\n}\n\n.hb-dropdown__item--disabled {\n color: var(--hb-color-text-disabled);\n cursor: not-allowed;\n}\n\n.hb-dropdown__item--divided {\n margin-top: 4px;\n padding-top: 8px;\n border-top: 1px solid var(--hb-color-border-secondary);\n}\n\n.hb-dropdown__item--danger {\n color: var(--hb-color-danger);\n}\n.hb-dropdown__item--danger:hover:not(.hb-dropdown__item--disabled) {\n background-color: var(--hb-color-danger-bg);\n color: var(--hb-color-danger);\n}\n\n@keyframes hb-dropdown-fade-in {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n/* 离场动画 */\n.hb-dropdown__menu--leaving {\n animation: hb-dropdown-fade-out 0.15s ease-in forwards;\n}\n\n@keyframes hb-dropdown-fade-out {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-4px);\n }\n}\n","import { Component, h, Prop, State, Element, Event, EventEmitter } from '@stencil/core';\nimport { createClickOutsideHandler } from '../../utils/click-outside';\nimport { getNextZIndex } from '../../utils/popup-manager';\nimport { handleListKeyboard, isActivationKey } from '../../utils/a11y';\nimport { createLeaveScheduler } from '../../utils/transition';\n\nexport interface DropdownItem {\n key: string;\n label: string;\n disabled?: boolean;\n divided?: boolean;\n danger?: boolean;\n}\n\n/**\n * Dropdown 下拉菜单组件\n * 将动作或菜单折叠到下拉菜单中。\n *\n * 无障碍(对齐 WAI-ARIA menu / antd):\n * - 触发器 role=button + aria-haspopup=menu + aria-expanded\n * - 菜单 role=menu,菜单项 role=menuitem + aria-disabled\n * - 键盘:trigger 上 Enter/Space/↓ 打开;菜单内 ↑↓ 导航、Enter/Space 选中、Esc 关闭\n *\n * 进出场动画:用 leaving state 延迟卸载,让 fade-out 有机会播放。\n */\n@Component({\n tag: 'hb-dropdown',\n styleUrl: 'dropdown.css',\n shadow: true,\n})\nexport class Dropdown {\n @Element() el: HTMLElement;\n\n /** 菜单项 */\n @Prop() items: DropdownItem[] = [];\n\n /** 触发方式 */\n @Prop() trigger: 'hover' | 'click' = 'hover';\n\n /** 是否禁用 */\n @Prop() disabled: boolean = false;\n\n @State() isOpen: boolean = false;\n /** 离场动画期(保留 DOM 让 fade-out 播完) */\n @State() leaving: boolean = false;\n /** 键盘高亮项索引(-1 表示无) */\n @State() activeIndex: number = -1;\n\n /** 命令事件 */\n @Event() hbCommand: EventEmitter<string>;\n\n private leave = createLeaveScheduler(\n () => this.leaving,\n v => (this.leaving = v),\n 150,\n );\n\n private clickOutside = createClickOutsideHandler({\n host: null as any,\n isOpen: () => this.isOpen,\n onClose: () => {\n this.close();\n },\n });\n\n componentDidLoad() {\n this.clickOutside = createClickOutsideHandler({\n host: this.el,\n isOpen: () => this.isOpen,\n onClose: () => {\n this.close();\n },\n });\n if (this.trigger === 'click') {\n this.clickOutside.connect();\n }\n }\n\n disconnectedCallback() {\n this.clickOutside.disconnect();\n this.leave.dispose();\n }\n\n private open = () => {\n if (this.disabled) return;\n this.leave.cancel(); // 中途又打开:取消挂起的离场\n this.isOpen = true;\n this.activeIndex = this.items.findIndex(i => !i.disabled);\n };\n\n private close = () => {\n if (!this.isOpen && !this.leaving) return;\n this.isOpen = false;\n this.activeIndex = -1;\n this.leave.start();\n };\n\n private show = () => {\n if (this.disabled) return;\n this.open();\n };\n\n private hide = () => {\n this.close();\n };\n\n private toggle = () => {\n if (this.disabled) return;\n if (this.isOpen) this.close();\n else this.open();\n };\n\n private handleSelect = (item: DropdownItem) => {\n if (item.disabled) return;\n this.close();\n this.hbCommand.emit(item.key);\n };\n\n private handleTriggerKeydown = (e: KeyboardEvent) => {\n if (this.disabled) return;\n if (this.trigger === 'hover') return;\n if (isActivationKey(e.key) || e.key === 'ArrowDown') {\n e.preventDefault();\n this.open();\n }\n };\n\n private handleMenuKeydown = (e: KeyboardEvent) => {\n const enabledCount = this.items.length;\n const action = handleListKeyboard(e, {\n activeIndex: this.activeIndex,\n itemCount: enabledCount,\n loop: true,\n });\n switch (action.type) {\n case 'navigate':\n e.preventDefault();\n {\n let idx = action.index;\n for (let i = 0; i < enabledCount; i++) {\n if (!this.items[idx]?.disabled) break;\n idx = (idx + 1) % enabledCount;\n }\n this.activeIndex = idx;\n }\n break;\n case 'select': {\n e.preventDefault();\n const item = this.items[action.index];\n if (item && !item.disabled) this.handleSelect(item);\n break;\n }\n case 'close':\n e.preventDefault();\n this.close();\n break;\n default:\n break;\n }\n };\n\n private get shouldRender(): boolean {\n return this.isOpen || this.leaving;\n }\n\n render() {\n const triggerEvents = this.trigger === 'hover' ? { onMouseEnter: this.show, onMouseLeave: this.hide } : { onClick: this.toggle };\n\n return (\n <div class=\"hb-dropdown\" {...triggerEvents} onKeyDown={this.handleTriggerKeydown}>\n <div\n class=\"hb-dropdown__trigger\"\n role=\"button\"\n tabindex={this.disabled ? -1 : 0}\n aria-haspopup=\"menu\"\n aria-expanded={this.isOpen ? 'true' : 'false'}\n aria-disabled={this.disabled ? 'true' : 'false'}\n >\n <slot />\n </div>\n {this.shouldRender && (\n <div\n class={{\n 'hb-dropdown__menu': true,\n 'hb-dropdown__menu--leaving': this.leaving,\n }}\n style={{ zIndex: String(getNextZIndex()) }}\n role=\"menu\"\n onKeyDown={this.handleMenuKeydown}\n >\n {this.items.map((item, index) => (\n <div\n class={{\n 'hb-dropdown__item': true,\n 'hb-dropdown__item--disabled': item.disabled,\n 'hb-dropdown__item--divided': item.divided,\n 'hb-dropdown__item--danger': item.danger,\n 'hb-dropdown__item--active': index === this.activeIndex,\n }}\n role=\"menuitem\"\n tabindex={-1}\n aria-disabled={item.disabled ? 'true' : undefined}\n onMouseEnter={() => {\n if (!item.disabled) this.activeIndex = index;\n }}\n onClick={() => this.handleSelect(item)}\n >\n {item.label}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -14,7 +14,7 @@ const Empty = class {
|
|
|
14
14
|
description = '暂无数据';
|
|
15
15
|
image;
|
|
16
16
|
render() {
|
|
17
|
-
return (index.h("div", { key: '
|
|
17
|
+
return (index.h("div", { key: '716385f61e4692d30d9ef0dab2671b4ee4a8381a', class: "hb-empty" }, index.h("div", { key: '39162ccfefa991ae63a59f585e7a91179b64523a', class: "hb-empty__image" }, this.image ? index.h("img", { src: this.image, alt: this.description }) : index.h("span", { class: "hb-empty__icon" }, "\uD83D\uDCED")), index.h("div", { key: '2ada1cc904ba094aaaf863d82ead88b81576590e', class: "hb-empty__description" }, this.description), index.h("div", { key: 'cb573d62ea4d81a66815a27be96617e0a3c3e470', class: "hb-empty__footer" }, index.h("slot", { key: '424ec328528ea66240ae4216e178bfc7f5ba2acd' }))));
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
Empty.style = HbEmptyStyle0;
|
|
@@ -43,11 +43,11 @@ const FloatButton = class {
|
|
|
43
43
|
right: `${this.right}px`,
|
|
44
44
|
bottom: `${this.bottom}px`,
|
|
45
45
|
};
|
|
46
|
-
return (index.h("button", { key: '
|
|
46
|
+
return (index.h("button", { key: '1c3836a10620e871fd54fdcacab8ed447329203f', type: "button", class: {
|
|
47
47
|
'hb-float-button': true,
|
|
48
48
|
[`hb-float-button--${this.type}`]: true,
|
|
49
49
|
[`hb-float-button--${this.shape}`]: true,
|
|
50
|
-
}, style: style, onClick: this.handleClick }, this.icon && index.h("span", { key: '
|
|
50
|
+
}, style: style, onClick: this.handleClick }, this.icon && index.h("span", { key: 'f0eaa8a4e40805f1442a55ec6830e2ed7aa54299', class: "hb-float-button__icon" }, this.icon), this.description && index.h("span", { key: '8f276ce89d0ace7f26ad65bb0d41dc0a4e262a45', class: "hb-float-button__description" }, this.description), this.renderBadge()));
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
FloatButton.style = HbFloatButtonStyle0;
|
|
@@ -20,7 +20,7 @@ const Footer = class {
|
|
|
20
20
|
if (this.height) {
|
|
21
21
|
style.height = this.height;
|
|
22
22
|
}
|
|
23
|
-
return (index.h("footer", { key: '
|
|
23
|
+
return (index.h("footer", { key: '65847074853df09c57dd2bcead1470dac15f5951', class: "hb-footer", style: style }, index.h("slot", { key: 'e0f976bf1b3cd1f3a7ae2609bdf9b621070dac10' })));
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
Footer.style = HbFooterStyle0;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-5aa5c817.js');
|
|
6
6
|
|
|
7
|
-
const formItemCss = "/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);line-height:1.5;tab-size:4;-webkit-tap-highlight-color:transparent}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.inline{display:inline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}} /*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;:host{display:block}.hb-form-item{align-items:flex-start;display:flex;gap:var(--hb-spacing-sm)}.hb-form-item__label{align-items:center;color:var(--hb-color-text);display:inline-flex;flex-shrink:0;font-size:var(--hb-font-size-sm);height:var(--hb-size-default);justify-content:flex-end;white-space:nowrap}.hb-form-item__required{color:var(--hb-color-danger);margin-right:4px}.hb-form-item__content{flex:1;position:relative}.hb-form-item__error{animation:hb-form-error-fade-in .2s ease-out;color:var(--hb-color-danger);font-size:var(--hb-font-size-xs);line-height:1;margin-top:4px}@keyframes hb-form-error-fade-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}";
|
|
7
|
+
const formItemCss = "/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);line-height:1.5;tab-size:4;-webkit-tap-highlight-color:transparent}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.inline{display:inline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}} /*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;:host{display:block}.hb-form-item{align-items:flex-start;display:flex;gap:var(--hb-spacing-sm)}.hb-form-item--label-top,:host([data-label-top]) .hb-form-item{align-items:stretch;flex-direction:column;gap:var(--hb-spacing-xs)}.hb-form-item__label{align-items:center;color:var(--hb-color-text);display:inline-flex;flex-shrink:0;font-size:var(--hb-font-size-sm,14px);height:var(--hb-size-default,32px);justify-content:flex-end;white-space:nowrap}.hb-form-item--label-top .hb-form-item__label,:host([data-label-top]) .hb-form-item__label{height:auto;justify-content:flex-start;padding-bottom:var(--hb-spacing-xxs,2px)}.hb-form-item--label-left .hb-form-item__label{justify-content:flex-start}.hb-form-item__required{color:var(--hb-color-danger);font-family:SimSun,sans-serif;font-size:var(--hb-font-size-sm,14px);margin-right:4px}.hb-form-item__content{flex:1;min-width:0;position:relative}.hb-form-item__error{animation:hb-form-error-fade-in .2s ease-out;color:var(--hb-color-danger);font-size:var(--hb-font-size-xs,12px);line-height:1.5;margin-top:4px;min-height:0}@keyframes hb-form-error-fade-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@media (max-width:575.98px){.hb-form-item{align-items:stretch!important;flex-direction:column!important;gap:var(--hb-spacing-xs)!important}.hb-form-item__label{height:auto!important;justify-content:flex-start!important;padding-bottom:var(--hb-spacing-xxs,2px)!important}}";
|
|
8
8
|
const HbFormItemStyle0 = formItemCss;
|
|
9
9
|
|
|
10
10
|
const FormItem = class {
|
|
@@ -26,6 +26,9 @@ const FormItem = class {
|
|
|
26
26
|
size = 'default';
|
|
27
27
|
errors = [];
|
|
28
28
|
isvalidating = false;
|
|
29
|
+
/** hb-form 在 componentWillLoad 注册的事件监听;FormItem 在 componentDidLoad 派发,
|
|
30
|
+
* 但 componentWillLoad 早于子组件的 componentDidLoad,因此注册一定先到。
|
|
31
|
+
* 这里还监听 hbFieldReset,便于 Form.resetFields 主动广播。 */
|
|
29
32
|
componentDidLoad() {
|
|
30
33
|
// 向父级 hb-form 注册
|
|
31
34
|
this.el.dispatchEvent(new CustomEvent('hbFormFieldRegister', {
|
|
@@ -36,14 +39,37 @@ const FormItem = class {
|
|
|
36
39
|
getValue: this.getValue,
|
|
37
40
|
},
|
|
38
41
|
bubbles: true,
|
|
42
|
+
composed: true, // 穿越 Shadow DOM 边界(FormItem 自身 shadow -> Form host)
|
|
39
43
|
}));
|
|
44
|
+
// 子控件值变化时清错(对齐 antd:合法输入即移除错误提示)
|
|
45
|
+
this.el.addEventListener('hbChange', this.handleChildChange);
|
|
40
46
|
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
this.el.removeEventListener('hbChange', this.handleChildChange);
|
|
49
|
+
}
|
|
50
|
+
/** 子控件 hbChange 时,若当前有错误则重新校验以尽早清除错误提示 */
|
|
51
|
+
handleChildChange = () => {
|
|
52
|
+
if (this.errors.length > 0) {
|
|
53
|
+
void this.validate();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
41
56
|
get formRules() {
|
|
42
57
|
// 合并 prop 对应的 form rules 和自身 rules
|
|
43
58
|
const form = this.el.closest('hb-form');
|
|
44
59
|
const formLevelRules = form ? form.rules?.[this.prop] || [] : [];
|
|
45
60
|
return [...formLevelRules, ...this.rules];
|
|
46
61
|
}
|
|
62
|
+
/** 是否渲染必填星号:显式 required 或任一规则带 required(对齐 antd 自动推断) */
|
|
63
|
+
get isRequired() {
|
|
64
|
+
if (this.required)
|
|
65
|
+
return true;
|
|
66
|
+
return this.formRules.some(r => r && r.required);
|
|
67
|
+
}
|
|
68
|
+
/** 继承父 hb-form 的 labelPosition(FormItem 自身无此 prop,避免与 Form 冲突时以 Form 为准) */
|
|
69
|
+
get resolvedLabelPosition() {
|
|
70
|
+
const form = this.el.closest('hb-form');
|
|
71
|
+
return (form && form.labelPosition) || 'right';
|
|
72
|
+
}
|
|
47
73
|
/**
|
|
48
74
|
* 验证此字段
|
|
49
75
|
*/
|
|
@@ -57,13 +83,27 @@ const FormItem = class {
|
|
|
57
83
|
this.isvalidating = true;
|
|
58
84
|
const errors = [];
|
|
59
85
|
for (const rule of rules) {
|
|
60
|
-
|
|
86
|
+
// 必填校验:空字符串 / null / undefined / 空数组均视为"未填"
|
|
87
|
+
const isEmpty = value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);
|
|
88
|
+
if (rule.required && isEmpty) {
|
|
61
89
|
errors.push(rule.message || `${this.label || this.prop}不能为空`);
|
|
62
90
|
continue;
|
|
63
91
|
}
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
// 非必填且为空时,跳过后续格式校验(与 antd 行为一致)
|
|
93
|
+
if (isEmpty)
|
|
66
94
|
continue;
|
|
95
|
+
if (rule.pattern) {
|
|
96
|
+
const ok = typeof rule.pattern === 'string' ? new RegExp(rule.pattern).test(String(value)) : rule.pattern.test(String(value));
|
|
97
|
+
if (!ok) {
|
|
98
|
+
errors.push(rule.message || `${this.label || this.prop}格式不正确`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (rule.type === 'email') {
|
|
103
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(value))) {
|
|
104
|
+
errors.push(rule.message || `${this.label || this.prop}格式不正确`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
67
107
|
}
|
|
68
108
|
if (rule.min !== undefined && typeof value === 'string' && value.length < rule.min) {
|
|
69
109
|
errors.push(rule.message || `${this.label || this.prop}最少${rule.min}个字符`);
|
|
@@ -90,19 +130,31 @@ const FormItem = class {
|
|
|
90
130
|
this.errors = [];
|
|
91
131
|
};
|
|
92
132
|
getValue = () => {
|
|
93
|
-
//
|
|
94
|
-
const input = this.el.querySelector('hb-input, hb-select, hb-cascader, hb-date-picker, hb-
|
|
133
|
+
// 覆盖所有表单控件:input/select/cascader/date 系列/数字/checkbox/radio/switch/slider/color-picker/rate/upload
|
|
134
|
+
const input = this.el.querySelector('hb-input, hb-select, hb-cascader, hb-date-picker, hb-date-time-picker, hb-date-range-picker, ' +
|
|
135
|
+
'hb-input-number, hb-textarea, hb-checkbox, hb-checkbox-group, hb-radio-group, hb-switch, ' +
|
|
136
|
+
'hb-slider, hb-color-picker, hb-rate, hb-time-picker, hb-time-select');
|
|
95
137
|
if (input) {
|
|
96
138
|
return input.modelValue;
|
|
97
139
|
}
|
|
98
140
|
return undefined;
|
|
99
141
|
};
|
|
100
142
|
render() {
|
|
101
|
-
|
|
143
|
+
const labelTop = this.resolvedLabelPosition === 'top';
|
|
144
|
+
const hasError = this.errors.length > 0;
|
|
145
|
+
// A4:label 与内容关联。子控件是 slot(id 未知),无法用 label.for;
|
|
146
|
+
// 改用 content 容器 role=group + aria-labelledby 指向 label id,
|
|
147
|
+
// 把 label 语义绑到整组;并用 aria-required / aria-invalid 暴露必填与校验态(读屏可感知,
|
|
148
|
+
// 不再仅靠红色 + 隐藏星号)。
|
|
149
|
+
const labelId = this.label ? `hb-form-item__label-${this.prop || 'x'}` : undefined;
|
|
150
|
+
return (index.h("div", { key: 'ad51782227c637557a1cc0a4be2397b20f63b2e2', class: {
|
|
102
151
|
'hb-form-item': true,
|
|
103
|
-
'hb-form-item--error':
|
|
152
|
+
'hb-form-item--error': hasError,
|
|
104
153
|
'hb-form-item--validating': this.isvalidating,
|
|
105
|
-
|
|
154
|
+
'hb-form-item--required': this.isRequired,
|
|
155
|
+
'hb-form-item--label-top': labelTop,
|
|
156
|
+
'hb-form-item--label-left': this.resolvedLabelPosition === 'left',
|
|
157
|
+
} }, this.label && (index.h("label", { key: '22b4830775644a315a797c91ca77045015632cf5', id: labelId, class: "hb-form-item__label", style: this.labelWidth ? { width: this.labelWidth } : undefined, title: this.label }, this.isRequired && (index.h("span", { key: '43c4db5f65f68f8a9db2362c8cdf724069895238', class: "hb-form-item__required", "aria-hidden": "true" }, "*")), this.label)), index.h("div", { key: '0fe8dda2a5b0363c55ca6e19d1c2b0e3a44e503f', class: "hb-form-item__content", role: "group", "aria-labelledby": labelId, "aria-required": this.isRequired ? 'true' : undefined, "aria-invalid": hasError ? 'true' : undefined }, index.h("slot", { key: '6b714ffde9c6a0f9112aef9a28519ba42df0fa96' }), hasError && (index.h("div", { key: '41a97ac3f7f0dccd9938d9dbf844852c085d0b72', class: "hb-form-item__error", role: "alert" }, this.errors[0])))));
|
|
106
158
|
}
|
|
107
159
|
};
|
|
108
160
|
FormItem.style = HbFormItemStyle0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-form-item.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,WAAW,GAAG,qzMAAqzM,CAAC;AAC10M,yBAAe,WAAW;;MCUb,QAAQ;;;;;;IAIX,IAAI,GAAW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sourcesContent":[":host {\n display: block;\n}\n\n.hb-form-item {\n display: flex;\n align-items: flex-start;\n gap: var(--hb-spacing-sm);\n}\n\n.hb-form-item__label {\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n height: var(--hb-size-default);\n font-size: var(--hb-font-size-sm);\n color: var(--hb-color-text);\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.hb-form-item__required {\n color: var(--hb-color-danger);\n margin-right: 4px;\n}\n\n.hb-form-item__content {\n flex: 1;\n position: relative;\n}\n\n.hb-form-item__error {\n font-size: var(--hb-font-size-xs);\n color: var(--hb-color-danger);\n margin-top: 4px;\n line-height: 1;\n animation: hb-form-error-fade-in 0.2s ease-out;\n}\n\n@keyframes hb-form-error-fade-in {\n from { opacity: 0; transform: translateY(-4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n","import { Component, h, Prop, State, Element } from '@stencil/core';\n\n/**\n * FormItem 表单项组件\n * 表单中的每一项\n */\n@Component({\n tag: 'hb-form-item',\n styleUrl: 'form-item.css',\n shadow: true,\n})\nexport class FormItem {\n @Element() el: HTMLElement;\n\n /** 字段名 */\n @Prop() prop: string = '';\n\n /** 标签文本 */\n @Prop() label: string = '';\n\n /** 标签宽度 */\n @Prop() labelWidth?: string;\n\n /** 是否必填 */\n @Prop() required: boolean = false;\n\n /** 该表单项的验证规则 */\n @Prop() rules: any[] = [];\n\n /** 表单尺寸 */\n @Prop() size: 'large' | 'default' | 'small' = 'default';\n\n @State() errors: string[] = [];\n @State() isvalidating: boolean = false;\n\n componentDidLoad() {\n // 向父级 hb-form 注册\n this.el.dispatchEvent(new CustomEvent('hbFormFieldRegister', {\n detail: {\n prop: this.prop,\n validate: this.validate,\n resetValue: this.resetValue,\n getValue: this.getValue,\n },\n bubbles: true,\n }));\n }\n\n private get formRules(): any[] {\n // 合并 prop 对应的 form rules 和自身 rules\n const form = this.el.closest('hb-form');\n const formLevelRules = form ? (form as any).rules?.[this.prop] || [] : [];\n return [...formLevelRules, ...this.rules];\n }\n\n /**\n * 验证此字段\n */\n @Prop() validate = async (): Promise<string[]> => {\n const value = this.getValue();\n const rules = this.formRules;\n\n if (rules.length === 0) {\n this.errors = [];\n return [];\n }\n\n this.isvalidating = true;\n const errors: string[] = [];\n\n for (const rule of rules) {\n if (rule.required && (!value && value !== 0)) {\n errors.push(rule.message || `${this.label || this.prop}不能为空`);\n continue;\n }\n if (rule.pattern && !rule.pattern.test(value)) {\n errors.push(rule.message || `${this.label || this.prop}格式不正确`);\n continue;\n }\n if (rule.min !== undefined && typeof value === 'string' && value.length < rule.min) {\n errors.push(rule.message || `${this.label || this.prop}最少${rule.min}个字符`);\n continue;\n }\n if (rule.max !== undefined && typeof value === 'string' && value.length > rule.max) {\n errors.push(rule.message || `${this.label || this.prop}最多${rule.max}个字符`);\n continue;\n }\n if (rule.validator) {\n try {\n await rule.validator(value, this.formRules);\n } catch (err: any) {\n errors.push(err.message || rule.message || `${this.label || this.prop}验证失败`);\n }\n }\n }\n\n this.errors = errors;\n this.isvalidating = false;\n return errors;\n };\n\n @Prop() resetValue = () => {\n this.errors = [];\n };\n\n @Prop() getValue = (): any => {\n // 尝试从子元素中获取值\n const input = this.el.querySelector('hb-input, hb-select, hb-cascader, hb-date-picker, hb-input-number, hb-textarea, hb-checkbox, hb-radio, hb-switch');\n if (input) {\n return (input as any).modelValue;\n }\n return undefined;\n };\n\n render() {\n return (\n <div\n class={{\n 'hb-form-item': true,\n 'hb-form-item--error': this.errors.length > 0,\n 'hb-form-item--validating': this.isvalidating,\n }}\n >\n {this.label && (\n <label\n class=\"hb-form-item__label\"\n style={this.labelWidth ? { width: this.labelWidth } : undefined}\n >\n {this.required && <span class=\"hb-form-item__required\">*</span>}\n {this.label}\n </label>\n )}\n <div class=\"hb-form-item__content\">\n <slot />\n {this.errors.length > 0 && (\n <div class=\"hb-form-item__error\">{this.errors[0]}</div>\n )}\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"hb-form-item.entry.cjs.js","m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AAI,CAAC,UAAU;gBACzC,yBAAyB,EAAE,QAAQ;gBACnC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,KAAK,MAAM;aAClE,IAEA,IAAI,CAAC,KAAK,KACTA,oEAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAC,qBAAqB,EAAC,KAAK,EAAE,IAAI,CAAC,UAAU,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAC/H,IAAI,CAAC,UAAU,KACdA,mEAAM,KAAK,EAAC,wBAAwB,iBAAa,MAAM,QAEhD,CACR,EACA,IAAI,CAAC,KAAK,CACL,CACT,EACDA,kEAAK,KAAK,EAAC,uBAAuB,EAAC,IAAI,EAAC,OAAO,qBAAkB,OAAO,mBAAiB,IAAI,CAAC,UAAU,GAAG,MAAM,GAAG,SAAS,kBAAgB,QAAQ,GAAG,MAAM,GAAG,SAAS,IACxKA,oEAAQ,EACP,QAAQ,KACPA,kEAAK,KAAK,EAAC,qBAAqB,EAAC,IAAI,EAAC,OAAO,IAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CACX,CACP,CACG,CACF,EACN;KACH;;;;;;","names":["h"],"sources":["src/components/Form/form-item.css?tag=hb-form-item&encapsulation=shadow","src/components/Form/FormItem.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n.hb-form-item {\n display: flex;\n align-items: flex-start;\n gap: var(--hb-spacing-sm);\n}\n\n/* label 位置:顶部(对齐 antd label-position=\"top\")——\n 需要 Form 通过 class 下发,但 FormItem 在独立使用时也支持自身包装。\n 这里用 :host([data-label-position=\"top\"]) 兜底,Form 可通过 setting attribute 生效。 */\n:host([data-label-top]) .hb-form-item,\n.hb-form-item--label-top {\n flex-direction: column;\n align-items: stretch;\n gap: var(--hb-spacing-xs);\n}\n\n.hb-form-item__label {\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n height: var(--hb-size-default, 32px);\n font-size: var(--hb-font-size-sm, 14px);\n color: var(--hb-color-text);\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n/* label-position=top 时标签左对齐 */\n:host([data-label-top]) .hb-form-item__label,\n.hb-form-item--label-top .hb-form-item__label {\n justify-content: flex-start;\n height: auto;\n padding-bottom: var(--hb-spacing-xxs, 2px);\n}\n\n/* label-position=left 时标签左对齐 */\n.hb-form-item--label-left .hb-form-item__label {\n justify-content: flex-start;\n}\n\n.hb-form-item__required {\n color: var(--hb-color-danger);\n margin-right: 4px;\n font-size: var(--hb-font-size-sm, 14px);\n font-family: SimSun, sans-serif;\n}\n\n.hb-form-item__content {\n flex: 1;\n position: relative;\n min-width: 0;\n}\n\n.hb-form-item__error {\n font-size: var(--hb-font-size-xs, 12px);\n color: var(--hb-color-danger);\n margin-top: 4px;\n line-height: 1.5;\n min-height: 0;\n animation: hb-form-error-fade-in 0.2s ease-out;\n}\n\n@keyframes hb-form-error-fade-in {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n/* ============================================================\n * 响应式(移动端):小屏强制 label 顶部布局,\n * 避免标签列在窄屏被挤压。覆盖 hb-form-item--label-left/right。\n * ============================================================ */\n@media (max-width: 575.98px) {\n .hb-form-item {\n flex-direction: column !important;\n align-items: stretch !important;\n gap: var(--hb-spacing-xs) !important;\n }\n\n .hb-form-item__label {\n justify-content: flex-start !important;\n height: auto !important;\n padding-bottom: var(--hb-spacing-xxs, 2px) !important;\n }\n}\n","import { Component, h, Prop, State, Element } from '@stencil/core';\n\n/**\n * FormItem 表单项组件\n * 表单中的每一项\n */\n@Component({\n tag: 'hb-form-item',\n styleUrl: 'form-item.css',\n shadow: true,\n})\nexport class FormItem {\n @Element() el: HTMLElement;\n\n /** 字段名 */\n @Prop() prop: string = '';\n\n /** 标签文本 */\n @Prop() label: string = '';\n\n /** 标签宽度 */\n @Prop() labelWidth?: string;\n\n /** 是否必填 */\n @Prop() required: boolean = false;\n\n /** 该表单项的验证规则 */\n @Prop() rules: any[] = [];\n\n /** 表单尺寸 */\n @Prop() size: 'large' | 'default' | 'small' = 'default';\n\n @State() errors: string[] = [];\n @State() isvalidating: boolean = false;\n\n /** hb-form 在 componentWillLoad 注册的事件监听;FormItem 在 componentDidLoad 派发,\n * 但 componentWillLoad 早于子组件的 componentDidLoad,因此注册一定先到。\n * 这里还监听 hbFieldReset,便于 Form.resetFields 主动广播。 */\n\n componentDidLoad() {\n // 向父级 hb-form 注册\n this.el.dispatchEvent(\n new CustomEvent('hbFormFieldRegister', {\n detail: {\n prop: this.prop,\n validate: this.validate,\n resetValue: this.resetValue,\n getValue: this.getValue,\n },\n bubbles: true,\n composed: true, // 穿越 Shadow DOM 边界(FormItem 自身 shadow -> Form host)\n }),\n );\n\n // 子控件值变化时清错(对齐 antd:合法输入即移除错误提示)\n this.el.addEventListener('hbChange', this.handleChildChange);\n }\n\n disconnectedCallback() {\n this.el.removeEventListener('hbChange', this.handleChildChange);\n }\n\n /** 子控件 hbChange 时,若当前有错误则重新校验以尽早清除错误提示 */\n private handleChildChange = () => {\n if (this.errors.length > 0) {\n void this.validate();\n }\n };\n\n private get formRules(): any[] {\n // 合并 prop 对应的 form rules 和自身 rules\n const form = this.el.closest('hb-form');\n const formLevelRules = form ? (form as any).rules?.[this.prop] || [] : [];\n return [...formLevelRules, ...this.rules];\n }\n\n /** 是否渲染必填星号:显式 required 或任一规则带 required(对齐 antd 自动推断) */\n private get isRequired(): boolean {\n if (this.required) return true;\n return this.formRules.some(r => r && r.required);\n }\n\n /** 继承父 hb-form 的 labelPosition(FormItem 自身无此 prop,避免与 Form 冲突时以 Form 为准) */\n private get resolvedLabelPosition(): 'left' | 'right' | 'top' {\n const form = this.el.closest('hb-form') as any;\n return (form && form.labelPosition) || 'right';\n }\n\n /**\n * 验证此字段\n */\n @Prop() validate = async (): Promise<string[]> => {\n const value = this.getValue();\n const rules = this.formRules;\n\n if (rules.length === 0) {\n this.errors = [];\n return [];\n }\n\n this.isvalidating = true;\n const errors: string[] = [];\n\n for (const rule of rules) {\n // 必填校验:空字符串 / null / undefined / 空数组均视为\"未填\"\n const isEmpty = value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);\n if (rule.required && isEmpty) {\n errors.push(rule.message || `${this.label || this.prop}不能为空`);\n continue;\n }\n // 非必填且为空时,跳过后续格式校验(与 antd 行为一致)\n if (isEmpty) continue;\n if (rule.pattern) {\n const ok = typeof rule.pattern === 'string' ? new RegExp(rule.pattern).test(String(value)) : rule.pattern.test(String(value));\n if (!ok) {\n errors.push(rule.message || `${this.label || this.prop}格式不正确`);\n continue;\n }\n }\n if (rule.type === 'email') {\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(String(value))) {\n errors.push(rule.message || `${this.label || this.prop}格式不正确`);\n continue;\n }\n }\n if (rule.min !== undefined && typeof value === 'string' && value.length < rule.min) {\n errors.push(rule.message || `${this.label || this.prop}最少${rule.min}个字符`);\n continue;\n }\n if (rule.max !== undefined && typeof value === 'string' && value.length > rule.max) {\n errors.push(rule.message || `${this.label || this.prop}最多${rule.max}个字符`);\n continue;\n }\n if (rule.validator) {\n try {\n await rule.validator(value, this.formRules);\n } catch (err: any) {\n errors.push(err.message || rule.message || `${this.label || this.prop}验证失败`);\n }\n }\n }\n\n this.errors = errors;\n this.isvalidating = false;\n return errors;\n };\n\n @Prop() resetValue = () => {\n this.errors = [];\n };\n\n @Prop() getValue = (): any => {\n // 覆盖所有表单控件:input/select/cascader/date 系列/数字/checkbox/radio/switch/slider/color-picker/rate/upload\n const input = this.el.querySelector(\n 'hb-input, hb-select, hb-cascader, hb-date-picker, hb-date-time-picker, hb-date-range-picker, ' +\n 'hb-input-number, hb-textarea, hb-checkbox, hb-checkbox-group, hb-radio-group, hb-switch, ' +\n 'hb-slider, hb-color-picker, hb-rate, hb-time-picker, hb-time-select',\n );\n if (input) {\n return (input as any).modelValue;\n }\n return undefined;\n };\n\n render() {\n const labelTop = this.resolvedLabelPosition === 'top';\n const hasError = this.errors.length > 0;\n // A4:label 与内容关联。子控件是 slot(id 未知),无法用 label.for;\n // 改用 content 容器 role=group + aria-labelledby 指向 label id,\n // 把 label 语义绑到整组;并用 aria-required / aria-invalid 暴露必填与校验态(读屏可感知,\n // 不再仅靠红色 + 隐藏星号)。\n const labelId = this.label ? `hb-form-item__label-${this.prop || 'x'}` : undefined;\n return (\n <div\n class={{\n 'hb-form-item': true,\n 'hb-form-item--error': hasError,\n 'hb-form-item--validating': this.isvalidating,\n 'hb-form-item--required': this.isRequired,\n 'hb-form-item--label-top': labelTop,\n 'hb-form-item--label-left': this.resolvedLabelPosition === 'left',\n }}\n >\n {this.label && (\n <label id={labelId} class=\"hb-form-item__label\" style={this.labelWidth ? { width: this.labelWidth } : undefined} title={this.label}>\n {this.isRequired && (\n <span class=\"hb-form-item__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n {this.label}\n </label>\n )}\n <div class=\"hb-form-item__content\" role=\"group\" aria-labelledby={labelId} aria-required={this.isRequired ? 'true' : undefined} aria-invalid={hasError ? 'true' : undefined}>\n <slot />\n {hasError && (\n <div class=\"hb-form-item__error\" role=\"alert\">\n {this.errors[0]}\n </div>\n )}\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-5aa5c817.js');
|
|
6
6
|
|
|
7
|
-
const formCss = "/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);line-height:1.5;tab-size:4;-webkit-tap-highlight-color:transparent}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.inline{display:inline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}} /*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;:host{display:block}.hb-form{display:flex;flex-direction:column;gap:var(--hb-spacing-md)}.hb-form--inline{flex-flow:wrap;gap:var(--hb-spacing-sm)var(--hb-spacing-lg)}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}";
|
|
7
|
+
const formCss = "/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);line-height:1.5;tab-size:4;-webkit-tap-highlight-color:transparent}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.inline{display:inline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}} /*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;:host{display:block}.hb-form{display:flex;flex-direction:column;gap:var(--hb-spacing-md)}.hb-form--inline{align-items:flex-start;flex-flow:wrap;gap:var(--hb-spacing-sm)var(--hb-spacing-lg)}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}";
|
|
8
8
|
const HbFormStyle0 = formCss;
|
|
9
9
|
|
|
10
10
|
const Form = class {
|
|
@@ -32,11 +32,16 @@ const Form = class {
|
|
|
32
32
|
// Stencil 生命周期里子组件(FormItem)的 componentDidLoad 先于父组件(Form)触发,
|
|
33
33
|
// 若在 componentDidLoad 才挂监听,会错过子项派发的 hbFormFieldRegister,
|
|
34
34
|
// 导致 fieldRegistry 为空、validate() 永远返回 true(真实浏览器里复现,mock-doc 被 waitForChanges 掩盖)。
|
|
35
|
+
// L1:抽命名 handler 以便 disconnectedCallback 正确 remove(修复前匿名箭头无法 remove)。
|
|
36
|
+
handleFieldRegister = ((e) => {
|
|
37
|
+
const { prop, validate, resetValue, getValue } = e.detail;
|
|
38
|
+
this.fieldRegistry.set(prop, { prop, validate, resetValue, getValue });
|
|
39
|
+
});
|
|
35
40
|
componentWillLoad() {
|
|
36
|
-
this.el.addEventListener('hbFormFieldRegister',
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
this.el.addEventListener('hbFormFieldRegister', this.handleFieldRegister);
|
|
42
|
+
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
this.el.removeEventListener('hbFormFieldRegister', this.handleFieldRegister);
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* 验证整个表单
|
|
@@ -53,14 +58,14 @@ const Form = class {
|
|
|
53
58
|
* 重置表单
|
|
54
59
|
*/
|
|
55
60
|
resetFields = () => {
|
|
56
|
-
this.fieldRegistry.forEach(
|
|
61
|
+
this.fieldRegistry.forEach(field => field.resetValue());
|
|
57
62
|
};
|
|
58
63
|
render() {
|
|
59
|
-
return (index.h("form", { key: '
|
|
64
|
+
return (index.h("form", { key: '4e5a8f5d54c6760936fa8735e9a41d7956d631b1', class: {
|
|
60
65
|
'hb-form': true,
|
|
61
66
|
[`hb-form--label-${this.labelPosition}`]: true,
|
|
62
67
|
'hb-form--inline': this.inline,
|
|
63
|
-
}, onSubmit:
|
|
68
|
+
}, onSubmit: e => e.preventDefault(), novalidate: true }, index.h("slot", { key: 'd2e9a364e36387770dc8deb4c42c0e66542cd6a0' })));
|
|
64
69
|
}
|
|
65
70
|
};
|
|
66
71
|
Form.style = HbFormStyle0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-form.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,OAAO,GAAG,
|
|
1
|
+
{"file":"hb-form.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,OAAO,GAAG,i0LAAi0L,CAAC;AACl1L,qBAAe,OAAO;;MCiBT,IAAI;;;;;;IAIP,KAAK,GAAwB,EAAE,CAAC;;IAGhC,KAAK,GAA0B,EAAE,CAAC;;IAGlC,aAAa,GAA6B,OAAO,CAAC;;IAGlD,UAAU,GAAW,MAAM,CAAC;;IAG5B,MAAM,GAAY,KAAK,CAAC;;IAGxB,IAAI,GAAkC,SAAS,CAAC;;IAGhD,QAAQ,GAAY,KAAK,CAAC;IAEzB,MAAM,GAA4B,EAAE,CAAC;IAEtC,aAAa,GAAG,IAAI,GAAG,EAAiC,CAAC;;;;;;IAOzD,mBAAmB,IAAI,CAAC,CAAc;QAC5C,MAAM,EAAE,IAAI,EAAE,QAAQ,EA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apsulation=shadow","src/components/Form/Form.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n.hb-form {\n display: flex;\n flex-direction: column;\n gap: var(--hb-spacing-md);\n}\n\n.hb-form--inline {\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--hb-spacing-sm) var(--hb-spacing-lg);\n align-items: flex-start;\n}\n","import { Component, h, Prop, State, Element } from '@stencil/core';\n\ninterface FormFieldRegistration {\n prop: string;\n validate: () => Promise<string[]>;\n resetValue: () => void;\n getValue: () => any;\n}\n\n/**\n * Form 表单组件\n * 由输入框、选择器、单选框、多选框等控件组成,配合表单校验\n */\n@Component({\n tag: 'hb-form',\n styleUrl: 'form.css',\n shadow: true,\n})\nexport class Form {\n @Element() el: HTMLElement;\n\n /** 表单数据对象 */\n @Prop() model: Record<string, any> = {};\n\n /** 表单验证规则 */\n @Prop() rules: Record<string, any[]> = {};\n\n /** 标签位置 */\n @Prop() labelPosition: 'left' | 'right' | 'top' = 'right';\n\n /** 标签宽度 */\n @Prop() labelWidth: string = '80px';\n\n /** 是否行内表单 */\n @Prop() inline: boolean = false;\n\n /** 表单尺寸 */\n @Prop() size: 'large' | 'default' | 'small' = 'default';\n\n /** 是否禁用 */\n @Prop() disabled: boolean = false;\n\n @State() fields: FormFieldRegistration[] = [];\n\n private fieldRegistry = new Map<string, FormFieldRegistration>();\n\n // 用 componentWillLoad 而非 componentDidLoad 注册监听器:\n // Stencil 生命周期里子组件(FormItem)的 componentDidLoad 先于父组件(Form)触发,\n // 若在 componentDidLoad 才挂监听,会错过子项派发的 hbFormFieldRegister,\n // 导致 fieldRegistry 为空、validate() 永远返回 true(真实浏览器里复现,mock-doc 被 waitForChanges 掩盖)。\n // L1:抽命名 handler 以便 disconnectedCallback 正确 remove(修复前匿名箭头无法 remove)。\n private handleFieldRegister = ((e: CustomEvent) => {\n const { prop, validate, resetValue, getValue } = e.detail;\n this.fieldRegistry.set(prop, { prop, validate, resetValue, getValue });\n }) as EventListener;\n\n componentWillLoad() {\n this.el.addEventListener('hbFormFieldRegister', this.handleFieldRegister);\n }\n\n disconnectedCallback() {\n this.el.removeEventListener('hbFormFieldRegister', this.handleFieldRegister);\n }\n\n /**\n * 验证整个表单\n * @returns 是否验证通过\n */\n @Prop() validate = async (): Promise<boolean> => {\n const results = await Promise.all(\n Array.from(this.fieldRegistry.values()).map(async field => {\n const errors = await field.validate();\n return errors.length === 0;\n }),\n );\n return results.every(Boolean);\n };\n\n /**\n * 重置表单\n */\n @Prop() resetFields = (): void => {\n this.fieldRegistry.forEach(field => field.resetValue());\n };\n\n render() {\n return (\n <form\n class={{\n 'hb-form': true,\n [`hb-form--label-${this.labelPosition}`]: true,\n 'hb-form--inline': this.inline,\n }}\n onSubmit={e => e.preventDefault()}\n novalidate\n >\n <slot />\n </form>\n );\n }\n}\n"],"version":3}
|
|
@@ -20,7 +20,7 @@ const Header = class {
|
|
|
20
20
|
if (this.height) {
|
|
21
21
|
style.height = this.height;
|
|
22
22
|
}
|
|
23
|
-
return (index.h("header", { key: '
|
|
23
|
+
return (index.h("header", { key: 'b0f4403c73f20d13b4513dd21266e5fea1004f7b', class: "hb-header", style: style }, index.h("slot", { key: '15f9743951c0183e7ee10124c0e3d2e8d071bee0' })));
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
Header.style = HbHeaderStyle0;
|
|
@@ -138,16 +138,20 @@ const ImagePreview = class {
|
|
|
138
138
|
handleRotateRight = () => {
|
|
139
139
|
this.rotate = this.rotate + 90;
|
|
140
140
|
};
|
|
141
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* 滚轮缩放(平滑 + 像素级响应):
|
|
143
|
+
* 按 deltaY 的绝对值映射缩放因子(小滚幅小步、大滚幅大步),
|
|
144
|
+
* 并夹取到 [minZoom, maxZoom],避免抖动与越界。
|
|
145
|
+
*/
|
|
142
146
|
handleWheel = (e) => {
|
|
143
|
-
// TODO: 平滑缩放 + 图片中心锚点;当前实现为基础步长缩放
|
|
144
147
|
e.preventDefault();
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
// 把 deltaY 映射成指数缩放系数:wheel 越快缩放越激进,但单次不超 zoomStep*2
|
|
149
|
+
const dir = e.deltaY < 0 ? 1 : -1;
|
|
150
|
+
const intensity = Math.min(Math.abs(e.deltaY) / 100, 2); // 0~2
|
|
151
|
+
const factor = 1 + dir * this.zoomStep * Math.max(1, intensity);
|
|
152
|
+
const next = Math.max(this.minZoom, Math.min(this.zoom * factor, this.maxZoom));
|
|
153
|
+
// 平滑:小数位保留两位,避免浮点累积误差
|
|
154
|
+
this.zoom = Math.round(next * 100) / 100;
|
|
151
155
|
};
|
|
152
156
|
/** 点击遮罩空白处关闭 */
|
|
153
157
|
handleOverlayClick = (e) => {
|
|
@@ -165,7 +169,7 @@ const ImagePreview = class {
|
|
|
165
169
|
const imgStyle = {
|
|
166
170
|
transform: `scale(${this.zoom}) rotate(${this.rotate}deg)`,
|
|
167
171
|
};
|
|
168
|
-
return (index.h("div", { class: "hb-image-preview", onClick: this.handleOverlayClick }, index.h("div", { class: "hb-image-preview__wrapper" }, index.h("img", { class: "hb-image-preview__img", src: this.currentSrc, alt: "", style: imgStyle, onWheel: this.handleWheel })), this.isMulti && (index.h("button", { type: "button", class: "hb-image-preview__btn hb-image-preview__btn--prev", onClick: this.prev, "aria-label": "\u4E0A\u4E00\u5F20" }, "\u2039")), this.isMulti && (index.h("button", { type: "button", class: "hb-image-preview__btn hb-image-preview__btn--next", onClick: this.next, "aria-label": "\u4E0B\u4E00\u5F20" }, "\u203A")), index.h("div", { class: "hb-image-preview__toolbar", onClick:
|
|
172
|
+
return (index.h("div", { class: "hb-image-preview", onClick: this.handleOverlayClick }, index.h("div", { class: "hb-image-preview__wrapper" }, index.h("img", { class: "hb-image-preview__img", src: this.currentSrc, alt: "", style: imgStyle, onWheel: this.handleWheel })), this.isMulti && (index.h("button", { type: "button", class: "hb-image-preview__btn hb-image-preview__btn--prev", onClick: this.prev, "aria-label": "\u4E0A\u4E00\u5F20" }, "\u2039")), this.isMulti && (index.h("button", { type: "button", class: "hb-image-preview__btn hb-image-preview__btn--next", onClick: this.next, "aria-label": "\u4E0B\u4E00\u5F20" }, "\u203A")), index.h("div", { class: "hb-image-preview__toolbar", onClick: e => e.stopPropagation() }, index.h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.zoomOut, "aria-label": "\u7F29\u5C0F" }, "\uFF0D"), index.h("span", { class: "hb-image-preview__tool-label" }, Math.round(this.zoom * 100), "%"), index.h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.zoomIn, "aria-label": "\u653E\u5927" }, "\uFF0B"), index.h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.handleRotateLeft, "aria-label": "\u5DE6\u65CB" }, "\u21BA"), index.h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.handleRotateRight, "aria-label": "\u53F3\u65CB" }, "\u21BB"), index.h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.handleReset, "aria-label": "\u91CD\u7F6E" }, "\u27F2"), index.h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.stopAndClose, "aria-label": "\u5173\u95ED" }, "\u2715")), index.h("button", { type: "button", class: "hb-image-preview__close", onClick: this.stopAndClose, "aria-label": "\u5173\u95ED" }, "\u00D7")));
|
|
169
173
|
}
|
|
170
174
|
static get watchers() { return {
|
|
171
175
|
"modelValue": ["handleVisibleChange"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-image-preview.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,eAAe,GAAG,unQAAunQ,CAAC;AAChpQ,6BAAe,eAAe;;MCejB,YAAY;;;;;;;;IAIE,UAAU,GAAY,KAAK,CAAC;;IAG7C,GAAG,GAAW,EAAE,CAAC;;IAGjB,OAAO,GAAa,EAAE,CAAC;;IAGN,OAAO,GAAW,CAAC,CAAC;;IAGrC,QAAQ,GAAW,GAAG,CAAC;;IAGvB,OAAO,GAAW,GA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EAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,IACxEA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,OAAO,gBAAa,cAAI,aAElF,EACTA,kBAAM,KAAK,EAAC,8BAA8B,IAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAS,EAChFA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,MAAM,gBAAa,cAAI,aAEjF,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,gBAAa,cAAI,aAE3F,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,gBAAa,cAAI,aAE5F,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,gBAAa,cAAI,aAEtF,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,gBAAa,cAAI,aAEvF,CACL,EAENA,oBACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,yBAAyB,EAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,gBACf,cAAI,aAGR,CACL,EACN;KACH;;;;;;;;;;","names":["h"],"sources":["src/components/ImagePreview/image-preview.css?tag=hb-image-preview&encapsulation=shadow","src/components/ImagePreview/ImagePreview.tsx"],"sourcesContent":[":host {\n display: contents;\n}\n\n.hb-image-preview {\n position: fixed;\n inset: 0;\n z-index: var(--hb-z-index-modal-mask, 2000);\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: var(--hb-color-bg-mask, rgba(0, 0, 0, 0.5));\n}\n\n.hb-image-preview__wrapper {\n max-width: 90vw;\n max-height: 90vh;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.hb-image-preview__img {\n max-width: 90vw;\n max-height: 90vh;\n object-fit: contain;\n user-select: none;\n transition: transform 0.2s ease;\n pointer-events: none;\n}\n\n.hb-image-preview__btn {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n width: 44px;\n height: 44px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n background-color: rgba(0, 0, 0, 0.4);\n color: var(--hb-color-text-inverse, #ffffff);\n font-size: 28px;\n line-height: 1;\n cursor: pointer;\n transition: background-color var(--hb-transition-duration, 0.2s) ease;\n}\n\n.hb-image-preview__btn:hover {\n background-color: rgba(0, 0, 0, 0.6);\n}\n\n.hb-image-preview__btn--prev {\n left: 24px;\n}\n\n.hb-image-preview__btn--next {\n right: 24px;\n}\n\n.hb-image-preview__toolbar {\n position: absolute;\n bottom: 32px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 8px 12px;\n border-radius: var(--hb-border-radius-base, 4px);\n background-color: rgba(0, 0, 0, 0.5);\n color: var(--hb-color-text-inverse, #ffffff);\n}\n\n.hb-image-preview__tool {\n min-width: 32px;\n height: 32px;\n padding: 0 8px;\n border: none;\n border-radius: var(--hb-border-radius-sm, 2px);\n background: transparent;\n color: var(--hb-color-text-inverse, #ffffff);\n font-size: 16px;\n cursor: pointer;\n transition: background-color var(--hb-transition-duration, 0.2s) ease;\n}\n\n.hb-image-preview__tool:hover {\n background-color: rgba(255, 255, 255, 0.15);\n}\n\n.hb-image-preview__tool-label {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 48px;\n padding: 0 4px;\n font-size: 13px;\n color: var(--hb-color-text-inverse, #ffffff);\n}\n\n.hb-image-preview__close {\n position: absolute;\n top: 24px;\n right: 24px;\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n background-color: rgba(0, 0, 0, 0.4);\n color: var(--hb-color-text-inverse, #ffffff);\n font-size: 28px;\n line-height: 1;\n cursor: pointer;\n transition: background-color var(--hb-transition-duration, 0.2s) ease;\n}\n\n.hb-image-preview__close:hover {\n background-color: rgba(0, 0, 0, 0.6);\n}\n","import { Component, h, Prop, Event, EventEmitter, State, Watch, Element } from '@stencil/core';\n\nexport interface ImagePreviewChangeDetail {\n src: string;\n index: number;\n}\n\n/**\n * ImagePreview 图片预览组件\n * 点击图片后展示大图,支持缩放、旋转、多图切换\n */\n@Component({\n tag: 'hb-image-preview',\n styleUrl: 'image-preview.css',\n shadow: true,\n})\nexport class ImagePreview {\n @Element() el: HTMLElement;\n\n /** 是否显示预览(受控,可双向) */\n @Prop({ mutable: true }) modelValue: boolean = false;\n\n /** 单图源(srcList 为空时使用) */\n @Prop() src: string = '';\n\n /** 多图源列表 */\n @Prop() srcList: string[] = [];\n\n /** 多图当前索引 */\n @Prop({ mutable: true }) current: number = 0;\n\n /** 单次缩放步长 */\n @Prop() zoomStep: number = 0.2;\n\n /** 最小缩放比例 */\n @Prop() minZoom: number = 0.5;\n\n /** 最大缩放比例 */\n @Prop() maxZoom: number = 3;\n\n /** 关闭事件 */\n @Event() hbClose: EventEmitter<void>;\n\n /** 切换事件,detail 为 { src, index } */\n @Event() hbChange: EventEmitter<ImagePreviewChangeDetail>;\n\n /** 当前缩放比例 */\n @State() zoom: number = 1;\n\n /** 当前旋转角度 */\n @State() rotate: number = 0;\n\n private keyDownHandler = (e: KeyboardEvent) => {\n if (!this.modelValue) return;\n if (e.key === 'Escape') {\n this.close();\n } else if (e.key === 'ArrowLeft') {\n this.prev();\n } else if (e.key === 'ArrowRight') {\n this.next();\n }\n };\n\n @Watch('modelValue')\n handleVisibleChange(newVal: boolean) {\n if (newVal) {\n // 打开时重置缩放与旋转\n this.zoom = 1;\n this.rotate = 0;\n document.addEventListener('keydown', this.keyDownHandler);\n } else {\n document.removeEventListener('keydown', this.keyDownHandler);\n }\n }\n\n @Watch('current')\n handleCurrentChange() {\n // 切换图片时重置变换\n this.zoom = 1;\n this.rotate = 0;\n }\n\n componentDidLoad() {\n if (this.modelValue) {\n document.addEventListener('keydown', this.keyDownHandler);\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('keydown', this.keyDownHandler);\n }\n\n /** 实际可切换的图片列表 */\n private get imageList(): string[] {\n if (this.srcList && this.srcList.length > 0) {\n return this.srcList;\n }\n return this.src ? [this.src] : [];\n }\n\n private get currentIndex(): number {\n const list = this.imageList;\n if (list.length === 0) return 0;\n if (this.current < 0) return 0;\n if (this.current >= list.length) return list.length - 1;\n return this.current;\n }\n\n private get currentSrc(): string {\n const list = this.imageList;\n if (list.length === 0) return '';\n return list[this.currentIndex] || '';\n }\n\n private get isMulti(): boolean {\n return this.imageList.length > 1;\n }\n\n private close = () => {\n this.modelValue = false;\n this.hbClose.emit();\n };\n\n private emitChange() {\n this.hbChange.emit({ src: this.currentSrc, index: this.currentIndex });\n }\n\n private next = () => {\n const list = this.imageList;\n if (list.length <= 1) return;\n this.current = (this.currentIndex + 1) % list.length;\n this.emitChange();\n };\n\n private prev = () => {\n const list = this.imageList;\n if (list.length <= 1) return;\n this.current = (this.currentIndex - 1 + list.length) % list.length;\n this.emitChange();\n };\n\n private zoomIn = () => {\n const next = Math.min(this.zoom + this.zoomStep, this.maxZoom);\n this.zoom = Math.round(next * 100) / 100;\n };\n\n private zoomOut = () => {\n const next = Math.max(this.zoom - this.zoomStep, this.minZoom);\n this.zoom = Math.round(next * 100) / 100;\n };\n\n private handleReset = () => {\n this.zoom = 1;\n this.rotate = 0;\n };\n\n private handleRotateLeft = () => {\n this.rotate = this.rotate - 90;\n };\n\n private handleRotateRight = () => {\n this.rotate = this.rotate + 90;\n };\n\n /** 滚轮缩放 */\n private handleWheel = (e: WheelEvent) => {\n // TODO: 平滑缩放 + 图片中心锚点;当前实现为基础步长缩放\n e.preventDefault();\n if (e.deltaY < 0) {\n this.zoomIn();\n } else {\n this.zoomOut();\n }\n };\n\n /** 点击遮罩空白处关闭 */\n private handleOverlayClick = (e: MouseEvent) => {\n if (e.target === e.currentTarget) {\n this.close();\n }\n };\n\n private stopAndClose = (e: MouseEvent) => {\n e.stopPropagation();\n this.close();\n };\n\n render() {\n if (!this.modelValue) return null;\n\n const imgStyle = {\n transform: `scale(${this.zoom}) rotate(${this.rotate}deg)`,\n };\n\n return (\n <div class=\"hb-image-preview\" onClick={this.handleOverlayClick}>\n <div class=\"hb-image-preview__wrapper\">\n <img\n class=\"hb-image-preview__img\"\n src={this.currentSrc}\n alt=\"\"\n style={imgStyle}\n onWheel={this.handleWheel}\n />\n </div>\n\n {this.isMulti && (\n <button\n type=\"button\"\n class=\"hb-image-preview__btn hb-image-preview__btn--prev\"\n onClick={this.prev}\n aria-label=\"上一张\"\n >\n ‹\n </button>\n )}\n {this.isMulti && (\n <button\n type=\"button\"\n class=\"hb-image-preview__btn hb-image-preview__btn--next\"\n onClick={this.next}\n aria-label=\"下一张\"\n >\n ›\n </button>\n )}\n\n <div class=\"hb-image-preview__toolbar\" onClick={(e) => e.stopPropagation()}>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.zoomOut} aria-label=\"缩小\">\n -\n </button>\n <span class=\"hb-image-preview__tool-label\">{Math.round(this.zoom * 100)}%</span>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.zoomIn} aria-label=\"放大\">\n +\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.handleRotateLeft} aria-label=\"左旋\">\n ↺\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.handleRotateRight} aria-label=\"右旋\">\n ↻\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.handleReset} aria-label=\"重置\">\n ⟲\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.stopAndClose} aria-label=\"关闭\">\n ✕\n </button>\n </div>\n\n <button\n type=\"button\"\n class=\"hb-image-preview__close\"\n onClick={this.stopAndClose}\n aria-label=\"关闭\"\n >\n ×\n </button>\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"hb-image-preview.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,eAAe,GAAG,unQAAunQ,CAAC;AAChpQ,6BAAe,eAAe;;MCejB,YAAY;;;;;;;;IAIE,UAAU,GAAY,KAAK,CAAC;;IAG7C,GAAG,GAAW,EAAE,CAAC;;IAGjB,OAAO,GAAa,EAAE,CAAC;;IAGN,OAAO,GAAW,CAAC,CAAC;;IAGrC,QAAQ,GAAW,GAAG,CAAC;;IAGvB,OAAO,GAAW,GAAG,CAAC;;IAGtB,OAAO,GAAW,CAAC,CAAC;;IAGnB,OAAO,CAAqB;;IAG5B,QAAQ,CAAyC;;IAGjD,IAAI,GAAW,CAAC,CAAC;;IAGjB,MAAM,GAAW,CAAC,CAAC;IAEpB,cAAc,GAAG,CAAC,CAAgB;QACxC,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7B,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE;YACtB,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;aAAM,IAAI,CAAC,CAAC,GAAG,KAAK,WAAW,EAAE;YAChC,IAAI,CAAC,IAAI,EAAE,CAAC;SACb;aAAM,IAAI,CAAC,CAAC,GAAG,KAAK,YAAY,EAAE;YACjC,IAAI,CAAC,IAAI,EAAE,CAAC;SACb;KACF,CAAC;IAGF,mBAAmB,CAAC,MAAe;QACjC,IAAI,MAAM,EAAE;;YAEV,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAChB,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;SAC3D;aAAM;YACL,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,C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A,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,MAAM,gBAAa,cAAI,aAEjF,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,gBAAa,cAAI,aAE3F,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,gBAAa,cAAI,aAE5F,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,gBAAa,cAAI,aAEtF,EACTA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,gBAAa,cAAI,aAEvF,CACL,EAENA,oBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,yBAAyB,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,gBAAa,cAAI,aAExF,CACL,EACN;KACH;;;;;;;;;;","names":["h"],"sources":["src/components/ImagePreview/image-preview.css?tag=hb-image-preview&encapsulation=shadow","src/components/ImagePreview/ImagePreview.tsx"],"sourcesContent":[":host {\n display: contents;\n}\n\n.hb-image-preview {\n position: fixed;\n inset: 0;\n z-index: var(--hb-z-index-modal-mask, 2000);\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: var(--hb-color-bg-mask, rgba(0, 0, 0, 0.5));\n}\n\n.hb-image-preview__wrapper {\n max-width: 90vw;\n max-height: 90vh;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.hb-image-preview__img {\n max-width: 90vw;\n max-height: 90vh;\n object-fit: contain;\n user-select: none;\n transition: transform 0.2s ease;\n pointer-events: none;\n}\n\n.hb-image-preview__btn {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n width: 44px;\n height: 44px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n background-color: rgba(0, 0, 0, 0.4);\n color: var(--hb-color-text-inverse, #ffffff);\n font-size: 28px;\n line-height: 1;\n cursor: pointer;\n transition: background-color var(--hb-transition-duration, 0.2s) ease;\n}\n\n.hb-image-preview__btn:hover {\n background-color: rgba(0, 0, 0, 0.6);\n}\n\n.hb-image-preview__btn--prev {\n left: 24px;\n}\n\n.hb-image-preview__btn--next {\n right: 24px;\n}\n\n.hb-image-preview__toolbar {\n position: absolute;\n bottom: 32px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 8px 12px;\n border-radius: var(--hb-border-radius-base, 4px);\n background-color: rgba(0, 0, 0, 0.5);\n color: var(--hb-color-text-inverse, #ffffff);\n}\n\n.hb-image-preview__tool {\n min-width: 32px;\n height: 32px;\n padding: 0 8px;\n border: none;\n border-radius: var(--hb-border-radius-sm, 2px);\n background: transparent;\n color: var(--hb-color-text-inverse, #ffffff);\n font-size: 16px;\n cursor: pointer;\n transition: background-color var(--hb-transition-duration, 0.2s) ease;\n}\n\n.hb-image-preview__tool:hover {\n background-color: rgba(255, 255, 255, 0.15);\n}\n\n.hb-image-preview__tool-label {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 48px;\n padding: 0 4px;\n font-size: 13px;\n color: var(--hb-color-text-inverse, #ffffff);\n}\n\n.hb-image-preview__close {\n position: absolute;\n top: 24px;\n right: 24px;\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n background-color: rgba(0, 0, 0, 0.4);\n color: var(--hb-color-text-inverse, #ffffff);\n font-size: 28px;\n line-height: 1;\n cursor: pointer;\n transition: background-color var(--hb-transition-duration, 0.2s) ease;\n}\n\n.hb-image-preview__close:hover {\n background-color: rgba(0, 0, 0, 0.6);\n}\n","import { Component, h, Prop, Event, EventEmitter, State, Watch, Element } from '@stencil/core';\n\nexport interface ImagePreviewChangeDetail {\n src: string;\n index: number;\n}\n\n/**\n * ImagePreview 图片预览组件\n * 点击图片后展示大图,支持缩放、旋转、多图切换\n */\n@Component({\n tag: 'hb-image-preview',\n styleUrl: 'image-preview.css',\n shadow: true,\n})\nexport class ImagePreview {\n @Element() el: HTMLElement;\n\n /** 是否显示预览(受控,可双向) */\n @Prop({ mutable: true }) modelValue: boolean = false;\n\n /** 单图源(srcList 为空时使用) */\n @Prop() src: string = '';\n\n /** 多图源列表 */\n @Prop() srcList: string[] = [];\n\n /** 多图当前索引 */\n @Prop({ mutable: true }) current: number = 0;\n\n /** 单次缩放步长 */\n @Prop() zoomStep: number = 0.2;\n\n /** 最小缩放比例 */\n @Prop() minZoom: number = 0.5;\n\n /** 最大缩放比例 */\n @Prop() maxZoom: number = 3;\n\n /** 关闭事件 */\n @Event() hbClose: EventEmitter<void>;\n\n /** 切换事件,detail 为 { src, index } */\n @Event() hbChange: EventEmitter<ImagePreviewChangeDetail>;\n\n /** 当前缩放比例 */\n @State() zoom: number = 1;\n\n /** 当前旋转角度 */\n @State() rotate: number = 0;\n\n private keyDownHandler = (e: KeyboardEvent) => {\n if (!this.modelValue) return;\n if (e.key === 'Escape') {\n this.close();\n } else if (e.key === 'ArrowLeft') {\n this.prev();\n } else if (e.key === 'ArrowRight') {\n this.next();\n }\n };\n\n @Watch('modelValue')\n handleVisibleChange(newVal: boolean) {\n if (newVal) {\n // 打开时重置缩放与旋转\n this.zoom = 1;\n this.rotate = 0;\n document.addEventListener('keydown', this.keyDownHandler);\n } else {\n document.removeEventListener('keydown', this.keyDownHandler);\n }\n }\n\n @Watch('current')\n handleCurrentChange() {\n // 切换图片时重置变换\n this.zoom = 1;\n this.rotate = 0;\n }\n\n componentDidLoad() {\n if (this.modelValue) {\n document.addEventListener('keydown', this.keyDownHandler);\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('keydown', this.keyDownHandler);\n }\n\n /** 实际可切换的图片列表 */\n private get imageList(): string[] {\n if (this.srcList && this.srcList.length > 0) {\n return this.srcList;\n }\n return this.src ? [this.src] : [];\n }\n\n private get currentIndex(): number {\n const list = this.imageList;\n if (list.length === 0) return 0;\n if (this.current < 0) return 0;\n if (this.current >= list.length) return list.length - 1;\n return this.current;\n }\n\n private get currentSrc(): string {\n const list = this.imageList;\n if (list.length === 0) return '';\n return list[this.currentIndex] || '';\n }\n\n private get isMulti(): boolean {\n return this.imageList.length > 1;\n }\n\n private close = () => {\n this.modelValue = false;\n this.hbClose.emit();\n };\n\n private emitChange() {\n this.hbChange.emit({ src: this.currentSrc, index: this.currentIndex });\n }\n\n private next = () => {\n const list = this.imageList;\n if (list.length <= 1) return;\n this.current = (this.currentIndex + 1) % list.length;\n this.emitChange();\n };\n\n private prev = () => {\n const list = this.imageList;\n if (list.length <= 1) return;\n this.current = (this.currentIndex - 1 + list.length) % list.length;\n this.emitChange();\n };\n\n private zoomIn = () => {\n const next = Math.min(this.zoom + this.zoomStep, this.maxZoom);\n this.zoom = Math.round(next * 100) / 100;\n };\n\n private zoomOut = () => {\n const next = Math.max(this.zoom - this.zoomStep, this.minZoom);\n this.zoom = Math.round(next * 100) / 100;\n };\n\n private handleReset = () => {\n this.zoom = 1;\n this.rotate = 0;\n };\n\n private handleRotateLeft = () => {\n this.rotate = this.rotate - 90;\n };\n\n private handleRotateRight = () => {\n this.rotate = this.rotate + 90;\n };\n\n /**\n * 滚轮缩放(平滑 + 像素级响应):\n * 按 deltaY 的绝对值映射缩放因子(小滚幅小步、大滚幅大步),\n * 并夹取到 [minZoom, maxZoom],避免抖动与越界。\n */\n private handleWheel = (e: WheelEvent) => {\n e.preventDefault();\n // 把 deltaY 映射成指数缩放系数:wheel 越快缩放越激进,但单次不超 zoomStep*2\n const dir = e.deltaY < 0 ? 1 : -1;\n const intensity = Math.min(Math.abs(e.deltaY) / 100, 2); // 0~2\n const factor = 1 + dir * this.zoomStep * Math.max(1, intensity);\n const next = Math.max(this.minZoom, Math.min(this.zoom * factor, this.maxZoom));\n // 平滑:小数位保留两位,避免浮点累积误差\n this.zoom = Math.round(next * 100) / 100;\n };\n\n /** 点击遮罩空白处关闭 */\n private handleOverlayClick = (e: MouseEvent) => {\n if (e.target === e.currentTarget) {\n this.close();\n }\n };\n\n private stopAndClose = (e: MouseEvent) => {\n e.stopPropagation();\n this.close();\n };\n\n render() {\n if (!this.modelValue) return null;\n\n const imgStyle = {\n transform: `scale(${this.zoom}) rotate(${this.rotate}deg)`,\n };\n\n return (\n <div class=\"hb-image-preview\" onClick={this.handleOverlayClick}>\n <div class=\"hb-image-preview__wrapper\">\n <img class=\"hb-image-preview__img\" src={this.currentSrc} alt=\"\" style={imgStyle} onWheel={this.handleWheel} />\n </div>\n\n {this.isMulti && (\n <button type=\"button\" class=\"hb-image-preview__btn hb-image-preview__btn--prev\" onClick={this.prev} aria-label=\"上一张\">\n ‹\n </button>\n )}\n {this.isMulti && (\n <button type=\"button\" class=\"hb-image-preview__btn hb-image-preview__btn--next\" onClick={this.next} aria-label=\"下一张\">\n ›\n </button>\n )}\n\n <div class=\"hb-image-preview__toolbar\" onClick={e => e.stopPropagation()}>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.zoomOut} aria-label=\"缩小\">\n -\n </button>\n <span class=\"hb-image-preview__tool-label\">{Math.round(this.zoom * 100)}%</span>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.zoomIn} aria-label=\"放大\">\n +\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.handleRotateLeft} aria-label=\"左旋\">\n ↺\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.handleRotateRight} aria-label=\"右旋\">\n ↻\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.handleReset} aria-label=\"重置\">\n ⟲\n </button>\n <button type=\"button\" class=\"hb-image-preview__tool\" onClick={this.stopAndClose} aria-label=\"关闭\">\n ✕\n </button>\n </div>\n\n <button type=\"button\" class=\"hb-image-preview__close\" onClick={this.stopAndClose} aria-label=\"关闭\">\n ×\n </button>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -22,11 +22,29 @@ const Image = class {
|
|
|
22
22
|
loaded = false;
|
|
23
23
|
error = false;
|
|
24
24
|
previewVisible = false;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* 换 src 时重置 loaded/error。
|
|
27
|
+
* 修复 B5——修复前换 src 不清状态:坏图换好图卡在错误占位(error 不清零),
|
|
28
|
+
* 好图换坏图 loaded 仍 true 造成短暂状态错乱。
|
|
29
|
+
*/
|
|
30
|
+
handleSrcChange() {
|
|
31
|
+
this.loaded = false;
|
|
32
|
+
this.error = false;
|
|
33
|
+
}
|
|
34
|
+
handleLoad = () => {
|
|
35
|
+
this.loaded = true;
|
|
36
|
+
};
|
|
37
|
+
handleError = () => {
|
|
38
|
+
this.error = true;
|
|
39
|
+
};
|
|
27
40
|
render() {
|
|
28
|
-
return (index.h("div", { key: '
|
|
41
|
+
return (index.h("div", { key: 'c9bbb745e78918ca3659138a91e7472911ac4c09', class: "hb-image", style: { width: this.width, height: this.height, borderRadius: this.radius } }, !this.error ? (index.h("img", { src: this.src, alt: this.alt, class: { 'hb-image__inner': true, 'hb-image__inner--loaded': this.loaded }, style: { objectFit: this.fit }, loading: this.lazy ? 'lazy' : undefined, onLoad: this.handleLoad, onError: this.handleError, onClick: () => this.preview && (this.previewVisible = true) })) : (index.h("div", { class: "hb-image__error" }, "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25")), this.previewVisible && (index.h("div", { key: '7d3b00d09c919169eab62ab6f525b2ef2f038a4c', class: "hb-image__preview", onClick: () => {
|
|
42
|
+
this.previewVisible = false;
|
|
43
|
+
} }, index.h("img", { key: '7c05ea33e51493d3a297f0e1c7d3511efae46a6c', src: this.src, alt: this.alt, class: "hb-image__preview-img" })))));
|
|
29
44
|
}
|
|
45
|
+
static get watchers() { return {
|
|
46
|
+
"src": ["handleSrcChange"]
|
|
47
|
+
}; }
|
|
30
48
|
};
|
|
31
49
|
Image.style = HbImageStyle0;
|
|
32
50
|
|