huibo-ui 0.4.0 → 0.6.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-1ffddc59.js → date-helpers-c05ef385.js} +5 -16
- package/dist/cjs/date-helpers-c05ef385.js.map +1 -0
- 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-calendar.cjs.entry.js +2 -2
- package/dist/cjs/hb-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-cascader.cjs.entry.js +48 -12
- 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.cjs.entry.js +22 -19
- package/dist/cjs/hb-color-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-date-picker-pane.cjs.entry.js +1 -1
- package/dist/cjs/hb-date-picker.cjs.entry.js +13 -10
- package/dist/cjs/hb-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-date-range-picker.cjs.entry.js +1 -1
- package/dist/cjs/hb-date-time-picker.cjs.entry.js +1 -1
- 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-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 +27 -15
- 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-form-item.cjs.entry.js +67 -16
- package/dist/cjs/hb-form-item.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-form.cjs.entry.js +115 -7
- package/dist/cjs/hb-form.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-image-preview.cjs.entry.js +1 -1
- 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 +3 -2
- package/dist/cjs/hb-input.cjs.entry.js.map +1 -1
- 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-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 +2 -2
- 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-page-header.cjs.entry.js +1 -1
- package/dist/cjs/hb-pagination.cjs.entry.js +8 -5
- package/dist/cjs/hb-pagination.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-popconfirm.cjs.entry.js +27 -8
- package/dist/cjs/hb-popconfirm.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-popover.cjs.entry.js +26 -14
- 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 +3 -3
- package/dist/cjs/hb-rate.cjs.entry.js.map +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 +13 -2
- package/dist/cjs/hb-segmented.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-select.cjs.entry.js +100 -19
- package/dist/cjs/hb-select.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-slider.cjs.entry.js +6 -12
- 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 +3 -3
- 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 +3 -3
- 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 +218 -41
- 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-tooltip.cjs.entry.js +30 -10
- package/dist/cjs/hb-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/hb-tree-select.cjs.entry.js +125 -10
- 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-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/components/Alert/Alert.js +2 -1
- package/dist/collection/components/Alert/Alert.js.map +1 -1
- package/dist/collection/components/Calendar/Calendar.js +2 -2
- package/dist/collection/components/Calendar/Calendar.js.map +1 -1
- package/dist/collection/components/Cascader/Cascader.js +47 -11
- package/dist/collection/components/Cascader/Cascader.js.map +1 -1
- 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 +22 -19
- package/dist/collection/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/collection/components/ColorPicker/color-picker.css +8 -3
- package/dist/collection/components/DatePicker/DatePicker.js +12 -9
- package/dist/collection/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/collection/components/DatePicker/date-picker.css +3 -2
- package/dist/collection/components/Descriptions/descriptions.css +30 -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/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 +28 -13
- package/dist/collection/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/collection/components/Dropdown/dropdown.css +24 -2
- 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 +217 -9
- package/dist/collection/components/Form/Form.js.map +1 -1
- package/dist/collection/components/Form/FormItem.js +126 -18
- package/dist/collection/components/Form/FormItem.js.map +1 -1
- package/dist/collection/components/Form/form-item.css +8 -2
- 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 +1 -1
- package/dist/collection/components/ImagePreview/ImagePreview.js.map +1 -1
- package/dist/collection/components/Input/Input.js +3 -2
- package/dist/collection/components/Input/Input.js.map +1 -1
- package/dist/collection/components/Input/input.css +1 -2
- 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.map +1 -1
- package/dist/collection/components/Layout/Row.js +2 -2
- package/dist/collection/components/Layout/layout.css +1713 -576
- 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/Message/Message.js +13 -4
- package/dist/collection/components/Message/Message.js.map +1 -1
- package/dist/collection/components/PageHeader/PageHeader.js +1 -1
- package/dist/collection/components/Pagination/Pagination.js +8 -5
- package/dist/collection/components/Pagination/Pagination.js.map +1 -1
- package/dist/collection/components/Popconfirm/Popconfirm.js +28 -6
- 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 +27 -12
- 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 +3 -3
- package/dist/collection/components/Rate/Rate.js.map +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 +15 -1
- package/dist/collection/components/Segmented/Segmented.js.map +1 -1
- package/dist/collection/components/Select/Select.js +123 -19
- package/dist/collection/components/Select/Select.js.map +1 -1
- package/dist/collection/components/Select/select.css +0 -1
- package/dist/collection/components/Slider/Slider.js +6 -12
- package/dist/collection/components/Slider/Slider.js.map +1 -1
- package/dist/collection/components/Slider/slider.css +0 -1
- 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 +2 -2
- package/dist/collection/components/Steps/Steps.js.map +1 -1
- package/dist/collection/components/Switch/Switch.js +3 -3
- package/dist/collection/components/Switch/Switch.js.map +1 -1
- package/dist/collection/components/Switch/switch.css +3 -2
- package/dist/collection/components/Table/Table.js +296 -41
- package/dist/collection/components/Table/Table.js.map +1 -1
- package/dist/collection/components/Table/table.css +6 -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/Tooltip/Tooltip.js +31 -8
- package/dist/collection/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/collection/components/Tooltip/tooltip.css +24 -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 +130 -11
- package/dist/collection/components/TreeSelect/TreeSelect.js.map +1 -1
- 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 +4 -15
- 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/collection/utils/virtual-scroll.js +39 -0
- package/dist/collection/utils/virtual-scroll.js.map +1 -0
- package/dist/components/hb-alert.js +2 -1
- package/dist/components/hb-alert.js.map +1 -1
- package/dist/components/hb-calendar.js +2 -2
- package/dist/components/hb-calendar.js.map +1 -1
- package/dist/components/hb-cascader.js +48 -12
- 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.js +22 -19
- package/dist/components/hb-color-picker.js.map +1 -1
- package/dist/components/hb-date-picker-pane.js +1 -1
- package/dist/components/hb-date-picker.js +13 -10
- package/dist/components/hb-date-picker.js.map +1 -1
- package/dist/components/hb-date-range-picker.js +1 -1
- package/dist/components/hb-date-time-picker.js +1 -1
- 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-drawer.js +36 -5
- package/dist/components/hb-drawer.js.map +1 -1
- package/dist/components/hb-dropdown.js +28 -15
- 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-form-item.js +70 -16
- package/dist/components/hb-form-item.js.map +1 -1
- package/dist/components/hb-form.js +120 -7
- package/dist/components/hb-form.js.map +1 -1
- package/dist/components/hb-image-preview.js +1 -1
- 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 +3 -2
- package/dist/components/hb-input.js.map +1 -1
- 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-menu-item.js +15 -5
- package/dist/components/hb-menu-item.js.map +1 -1
- package/dist/components/hb-menu.js +2 -2
- package/dist/components/hb-message.js +13 -4
- package/dist/components/hb-message.js.map +1 -1
- package/dist/components/hb-page-header.js +1 -1
- package/dist/components/hb-pagination.js +8 -5
- package/dist/components/hb-pagination.js.map +1 -1
- package/dist/components/hb-popconfirm.js +28 -8
- package/dist/components/hb-popconfirm.js.map +1 -1
- package/dist/components/hb-popover.js +27 -14
- 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 +3 -3
- package/dist/components/hb-rate.js.map +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 +15 -2
- package/dist/components/hb-segmented.js.map +1 -1
- package/dist/components/hb-select.js +105 -20
- package/dist/components/hb-select.js.map +1 -1
- package/dist/components/hb-slider.js +6 -12
- 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 +3 -3
- package/dist/components/hb-steps.js.map +1 -1
- package/dist/components/hb-sub-menu.js +5 -5
- package/dist/components/hb-switch.js +3 -3
- package/dist/components/hb-switch.js.map +1 -1
- package/dist/components/hb-tab-pane.js +1 -1
- package/dist/components/hb-table.js +226 -43
- 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-tooltip.js +31 -10
- package/dist/components/hb-tooltip.js.map +1 -1
- package/dist/components/hb-tree-select.js +129 -11
- 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-watermark.js +19 -11
- package/dist/components/hb-watermark.js.map +1 -1
- package/dist/{esm/a11y-f9ab2964.js → components/p-00aa34c8.js} +17 -3
- package/dist/components/p-00aa34c8.js.map +1 -0
- package/dist/components/{p-08b4005c.js → p-e0876aca.js} +5 -16
- 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/{components/p-cc0aeb50.js → esm/a11y-e4cde5b0.js} +17 -3
- package/dist/esm/a11y-e4cde5b0.js.map +1 -0
- package/dist/esm/{date-helpers-44507189.js → date-helpers-259ed2f1.js} +5 -16
- package/dist/esm/date-helpers-259ed2f1.js.map +1 -0
- package/dist/esm/hb-alert.entry.js +2 -1
- package/dist/esm/hb-alert.entry.js.map +1 -1
- package/dist/esm/hb-calendar.entry.js +2 -2
- package/dist/esm/hb-calendar.entry.js.map +1 -1
- package/dist/esm/hb-cascader.entry.js +48 -12
- 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.entry.js +22 -19
- package/dist/esm/hb-color-picker.entry.js.map +1 -1
- package/dist/esm/hb-date-picker-pane.entry.js +1 -1
- package/dist/esm/hb-date-picker.entry.js +13 -10
- package/dist/esm/hb-date-picker.entry.js.map +1 -1
- package/dist/esm/hb-date-range-picker.entry.js +1 -1
- package/dist/esm/hb-date-time-picker.entry.js +1 -1
- 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-drawer.entry.js +34 -4
- package/dist/esm/hb-drawer.entry.js.map +1 -1
- package/dist/esm/hb-dropdown.entry.js +27 -15
- 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-form-item.entry.js +67 -16
- package/dist/esm/hb-form-item.entry.js.map +1 -1
- package/dist/esm/hb-form.entry.js +115 -7
- package/dist/esm/hb-form.entry.js.map +1 -1
- package/dist/esm/hb-image-preview.entry.js +1 -1
- 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 +3 -2
- package/dist/esm/hb-input.entry.js.map +1 -1
- 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-menu-item.entry.js +14 -5
- package/dist/esm/hb-menu-item.entry.js.map +1 -1
- package/dist/esm/hb-menu.entry.js +2 -2
- package/dist/esm/hb-message.entry.js +13 -4
- package/dist/esm/hb-message.entry.js.map +1 -1
- package/dist/esm/hb-page-header.entry.js +1 -1
- package/dist/esm/hb-pagination.entry.js +8 -5
- package/dist/esm/hb-pagination.entry.js.map +1 -1
- package/dist/esm/hb-popconfirm.entry.js +27 -8
- package/dist/esm/hb-popconfirm.entry.js.map +1 -1
- package/dist/esm/hb-popover.entry.js +26 -14
- 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 +3 -3
- package/dist/esm/hb-rate.entry.js.map +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 +13 -2
- package/dist/esm/hb-segmented.entry.js.map +1 -1
- package/dist/esm/hb-select.entry.js +100 -19
- package/dist/esm/hb-select.entry.js.map +1 -1
- package/dist/esm/hb-slider.entry.js +6 -12
- 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 +3 -3
- 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 +3 -3
- 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 +218 -41
- 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-tooltip.entry.js +30 -10
- package/dist/esm/hb-tooltip.entry.js.map +1 -1
- package/dist/esm/hb-tree-select.entry.js +125 -10
- 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-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.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-0cc1e3f3.entry.js +2 -0
- package/dist/huibo-ui/p-0cc1e3f3.entry.js.map +1 -0
- package/dist/huibo-ui/{p-678b4212.entry.js → p-0ddae4e9.entry.js} +2 -2
- package/dist/huibo-ui/p-10f6c184.entry.js.map +1 -1
- package/dist/huibo-ui/{p-f4336be9.entry.js → p-14c3b47b.entry.js} +2 -2
- package/dist/huibo-ui/{p-c50ad398.entry.js → p-193efdc0.entry.js} +2 -2
- package/dist/huibo-ui/{p-735bceef.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-0d4b2997.entry.js → p-2bcda1bb.entry.js} +2 -2
- package/dist/huibo-ui/{p-b8d87f7e.entry.js → p-2ca9796a.entry.js} +2 -2
- package/dist/huibo-ui/p-2ca9796a.entry.js.map +1 -0
- package/dist/huibo-ui/{p-c80f8ace.entry.js → p-2cf5bf20.entry.js} +2 -2
- package/dist/huibo-ui/p-2cf5bf20.entry.js.map +1 -0
- package/dist/huibo-ui/{p-7da14d7c.entry.js → p-3042f986.entry.js} +2 -2
- package/dist/huibo-ui/{p-e039155d.entry.js → p-3dacb26b.entry.js} +2 -2
- package/dist/huibo-ui/{p-a084b8e5.entry.js → p-412ff618.entry.js} +2 -2
- package/dist/huibo-ui/p-4148d875.entry.js +2 -0
- package/dist/huibo-ui/p-4148d875.entry.js.map +1 -0
- package/dist/huibo-ui/{p-6beb5b81.entry.js → p-415295f3.entry.js} +2 -2
- 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-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-ccd09d5a.entry.js → p-6518c435.entry.js} +2 -2
- package/dist/huibo-ui/{p-1f8db37a.entry.js → p-687d8dff.entry.js} +2 -2
- 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-2811e603.entry.js → p-6bfe1954.entry.js} +2 -2
- package/dist/huibo-ui/p-6bfe1954.entry.js.map +1 -0
- package/dist/huibo-ui/{p-e5cbfa9e.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.map +1 -1
- 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-7a38b3e2.entry.js +2 -0
- package/dist/huibo-ui/p-7a38b3e2.entry.js.map +1 -0
- package/dist/huibo-ui/{p-cad57c2d.entry.js → p-7a682c56.entry.js} +2 -2
- package/dist/huibo-ui/{p-a8996d22.entry.js → p-815fc943.entry.js} +2 -2
- package/dist/huibo-ui/{p-af74667d.entry.js → p-89be7973.entry.js} +2 -2
- package/dist/huibo-ui/p-8a202bc5.entry.js.map +1 -1
- package/dist/huibo-ui/{p-213b9de7.entry.js → p-8c4415ed.entry.js} +2 -2
- package/dist/huibo-ui/p-8c4415ed.entry.js.map +1 -0
- package/dist/huibo-ui/{p-8fdbd17c.entry.js → p-950e7465.entry.js} +2 -2
- package/dist/huibo-ui/{p-ab9cf0e4.entry.js → p-96cecd21.entry.js} +2 -2
- package/dist/huibo-ui/p-96cecd21.entry.js.map +1 -0
- package/dist/huibo-ui/{p-2b4556ff.entry.js → p-98b513cd.entry.js} +2 -2
- package/dist/huibo-ui/p-98b513cd.entry.js.map +1 -0
- package/dist/huibo-ui/{p-89ea1141.entry.js → p-ac45291c.entry.js} +2 -2
- package/dist/huibo-ui/{p-e10fcfbe.entry.js → p-b105cf76.entry.js} +2 -2
- package/dist/huibo-ui/p-b105cf76.entry.js.map +1 -0
- package/dist/huibo-ui/{p-9a5406f0.entry.js → p-b38802b0.entry.js} +2 -2
- package/dist/huibo-ui/{p-9a5406f0.entry.js.map → p-b38802b0.entry.js.map} +1 -1
- 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-41d9c846.entry.js → p-b6afe81e.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-33de6878.entry.js → p-c869842c.entry.js} +2 -2
- package/dist/huibo-ui/p-c869842c.entry.js.map +1 -0
- package/dist/huibo-ui/p-c8e917db.entry.js.map +1 -1
- 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-f5969181.entry.js → p-dd9c6459.entry.js} +2 -2
- package/dist/huibo-ui/{p-08b4005c.js → p-e0876aca.js} +1 -1
- package/dist/huibo-ui/p-e0876aca.js.map +1 -0
- package/dist/huibo-ui/{p-aa5e5e02.entry.js → p-e1773c93.entry.js} +2 -2
- package/dist/huibo-ui/p-e1773c93.entry.js.map +1 -0
- package/dist/huibo-ui/{p-626b48f1.entry.js → p-e73c357f.entry.js} +2 -2
- package/dist/huibo-ui/p-e73c357f.entry.js.map +1 -0
- package/dist/huibo-ui/{p-60532a1f.entry.js → p-e7c73624.entry.js} +2 -2
- package/dist/huibo-ui/p-e7c73624.entry.js.map +1 -0
- package/dist/huibo-ui/{p-86bdc48a.entry.js → p-e8824b2c.entry.js} +2 -2
- package/dist/huibo-ui/p-e8824b2c.entry.js.map +1 -0
- package/dist/huibo-ui/{p-13010da2.entry.js → p-e9e7abca.entry.js} +2 -2
- package/dist/huibo-ui/{p-f6889710.entry.js → p-ea0823f3.entry.js} +2 -2
- package/dist/huibo-ui/p-ea0823f3.entry.js.map +1 -0
- package/dist/huibo-ui/{p-b468858e.entry.js → p-f1f2483f.entry.js} +2 -2
- package/dist/huibo-ui/p-f69599fa.entry.js +2 -0
- package/dist/huibo-ui/p-f69599fa.entry.js.map +1 -0
- package/dist/huibo-ui/p-fad66d69.js +2 -0
- package/dist/huibo-ui/p-fad66d69.js.map +1 -0
- package/dist/huibo-ui/{p-fd8301c6.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/Cascader/Cascader.d.ts +12 -0
- 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/Dialog/Dialog.d.ts +13 -1
- package/dist/types/components/Drawer/Drawer.d.ts +4 -0
- package/dist/types/components/Dropdown/Dropdown.d.ts +6 -2
- package/dist/types/components/Form/Form.d.ts +59 -0
- package/dist/types/components/Form/FormItem.d.ts +23 -0
- package/dist/types/components/Image/Image.d.ts +6 -0
- package/dist/types/components/Menu/MenuItem.d.ts +8 -1
- package/dist/types/components/Message/Message.d.ts +3 -0
- package/dist/types/components/Popconfirm/Popconfirm.d.ts +6 -2
- package/dist/types/components/Popover/Popover.d.ts +6 -1
- package/dist/types/components/Radio/Radio.d.ts +5 -0
- package/dist/types/components/Segmented/Segmented.d.ts +6 -0
- package/dist/types/components/Select/Select.d.ts +24 -0
- package/dist/types/components/Table/Table.d.ts +110 -9
- package/dist/types/components/Tabs/Tabs.d.ts +6 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/types/components/Tree/Tree.d.ts +24 -0
- package/dist/types/components/TreeSelect/TreeSelect.d.ts +17 -0
- package/dist/types/components/Watermark/Watermark.d.ts +7 -1
- package/dist/types/components.d.ts +188 -6
- package/dist/types/utils/a11y.d.ts +9 -0
- package/dist/types/utils/transition.d.ts +27 -0
- package/dist/types/utils/virtual-scroll.d.ts +38 -0
- package/package.json +1 -1
- package/dist/cjs/a11y-802de67a.js.map +0 -1
- package/dist/cjs/date-helpers-1ffddc59.js.map +0 -1
- package/dist/components/p-08b4005c.js.map +0 -1
- package/dist/components/p-cc0aeb50.js.map +0 -1
- package/dist/esm/a11y-f9ab2964.js.map +0 -1
- package/dist/esm/date-helpers-44507189.js.map +0 -1
- package/dist/huibo-ui/p-08b4005c.js.map +0 -1
- package/dist/huibo-ui/p-1f8db37a.entry.js.map +0 -1
- package/dist/huibo-ui/p-213b9de7.entry.js.map +0 -1
- package/dist/huibo-ui/p-25fd7d5c.entry.js +0 -2
- package/dist/huibo-ui/p-25fd7d5c.entry.js.map +0 -1
- package/dist/huibo-ui/p-2811e603.entry.js.map +0 -1
- package/dist/huibo-ui/p-2943f5d0.entry.js +0 -2
- package/dist/huibo-ui/p-2943f5d0.entry.js.map +0 -1
- package/dist/huibo-ui/p-2b4556ff.entry.js.map +0 -1
- package/dist/huibo-ui/p-33de6878.entry.js.map +0 -1
- package/dist/huibo-ui/p-3807da71.entry.js +0 -2
- package/dist/huibo-ui/p-3807da71.entry.js.map +0 -1
- package/dist/huibo-ui/p-47ef7a86.entry.js +0 -2
- package/dist/huibo-ui/p-47ef7a86.entry.js.map +0 -1
- package/dist/huibo-ui/p-4d34e43e.entry.js +0 -2
- package/dist/huibo-ui/p-4d34e43e.entry.js.map +0 -1
- package/dist/huibo-ui/p-54aa2fd8.entry.js +0 -2
- package/dist/huibo-ui/p-54aa2fd8.entry.js.map +0 -1
- package/dist/huibo-ui/p-60532a1f.entry.js.map +0 -1
- package/dist/huibo-ui/p-626b48f1.entry.js.map +0 -1
- package/dist/huibo-ui/p-639f167d.entry.js +0 -2
- package/dist/huibo-ui/p-639f167d.entry.js.map +0 -1
- package/dist/huibo-ui/p-6beb5b81.entry.js.map +0 -1
- package/dist/huibo-ui/p-735bceef.entry.js.map +0 -1
- package/dist/huibo-ui/p-76519752.entry.js +0 -2
- package/dist/huibo-ui/p-76519752.entry.js.map +0 -1
- package/dist/huibo-ui/p-79af2efa.entry.js +0 -2
- package/dist/huibo-ui/p-79af2efa.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-86bdc48a.entry.js.map +0 -1
- package/dist/huibo-ui/p-8a8443b8.entry.js +0 -2
- package/dist/huibo-ui/p-8a8443b8.entry.js.map +0 -1
- package/dist/huibo-ui/p-8fd788c9.entry.js +0 -2
- package/dist/huibo-ui/p-8fd788c9.entry.js.map +0 -1
- package/dist/huibo-ui/p-92521c31.entry.js +0 -2
- package/dist/huibo-ui/p-92521c31.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-aa5e5e02.entry.js.map +0 -1
- package/dist/huibo-ui/p-ab9cf0e4.entry.js.map +0 -1
- package/dist/huibo-ui/p-b8d87f7e.entry.js.map +0 -1
- package/dist/huibo-ui/p-c6c91664.entry.js +0 -2
- package/dist/huibo-ui/p-c6c91664.entry.js.map +0 -1
- package/dist/huibo-ui/p-c80f8ace.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-d79a15b1.entry.js +0 -2
- package/dist/huibo-ui/p-d79a15b1.entry.js.map +0 -1
- package/dist/huibo-ui/p-e10fcfbe.entry.js.map +0 -1
- package/dist/huibo-ui/p-e5cbfa9e.entry.js.map +0 -1
- package/dist/huibo-ui/p-ea74fcae.entry.js.map +0 -1
- package/dist/huibo-ui/p-edbda423.entry.js +0 -2
- package/dist/huibo-ui/p-edbda423.entry.js.map +0 -1
- package/dist/huibo-ui/p-f6889710.entry.js.map +0 -1
- package/dist/huibo-ui/p-f9bb5217.entry.js +0 -2
- package/dist/huibo-ui/p-f9bb5217.entry.js.map +0 -1
- package/dist/huibo-ui/p-fea20295.entry.js +0 -2
- package/dist/huibo-ui/p-fea20295.entry.js.map +0 -1
- /package/dist/huibo-ui/{p-678b4212.entry.js.map → p-0ddae4e9.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-f4336be9.entry.js.map → p-14c3b47b.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-c50ad398.entry.js.map → p-193efdc0.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-0d4b2997.entry.js.map → p-2bcda1bb.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-7da14d7c.entry.js.map → p-3042f986.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-e039155d.entry.js.map → p-3dacb26b.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-a084b8e5.entry.js.map → p-412ff618.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-ccd09d5a.entry.js.map → p-6518c435.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-cad57c2d.entry.js.map → p-7a682c56.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-a8996d22.entry.js.map → p-815fc943.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-af74667d.entry.js.map → p-89be7973.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-8fdbd17c.entry.js.map → p-950e7465.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-89ea1141.entry.js.map → p-ac45291c.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-41d9c846.entry.js.map → p-b6afe81e.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-f5969181.entry.js.map → p-dd9c6459.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-13010da2.entry.js.map → p-e9e7abca.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-b468858e.entry.js.map → p-f1f2483f.entry.js.map} +0 -0
- /package/dist/huibo-ui/{p-fd8301c6.entry.js.map → p-fd6831f9.entry.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-form-item.js","mappings":";;AAAA,MAAM,WAAW,GAAG,yiOAAyiO,CAAC;AAC9jO,yBAAe,WAAW;;MCUb,QAAQ;;;;;;;;IAIX,IAAI,GAAW,EAAE,CAAC;;IAGlB,KAAK,GAAW,EAAE,CAAC;;IAGnB,UAAU,CAAU;;IAGpB,QAAQ,GAAY,KAAK,CAAC;;IAG1B,KAAK,GAAU,EAAE,CAAC;;IAGlB,IAAI,GAAkC,SAAS,CAAC;IAE/C,MAAM,GAAa,EAAE,CAAC;IACtB,YAAY,GAAY,KAAK,CAAC;;;;IAMv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AG,CAAC,KACrB,4DAAK,KAAK,EAAC,qBAAqB,EAAC,IAAI,EAAC,OAAO,IAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAO,CACrE,CACG,CACF,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"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 { opacity: 0; transform: translateY(-4px); }\n to { opacity: 1; transform: translateY(0); }\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(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 // 子控件值变化时清错(对齐 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 =\n value === undefined ||\n value === null ||\n value === '' ||\n (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'\n ? new RegExp(rule.pattern).test(String(value))\n : 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 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 '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\n class=\"hb-form-item__label\"\n style={this.labelWidth ? { width: this.labelWidth } : undefined}\n title={this.label}\n >\n {this.isRequired && (\n <span class=\"hb-form-item__required\" aria-hidden=\"true\">*</span>\n )}\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\" role=\"alert\">{this.errors[0]}</div>\n )}\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"hb-form-item.js","mappings":";;AAAA,MAAM,WAAW,GAAG,yiOAAyiO,CAAC;AAC9jO,yBAAe,WAAW;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AAS,CAAC;QAChB,QACE,4DACE,KAAK,EAAE;gBACL,cAAc,EAAE,IAAI;gBACpB,qBAAqB,EAAE,QAAQ;gBAC/B,0BAA0B,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,cAAc,KAAK,YAAY;gBACrF,wBAAwB,EAAE,IAAI,CAAC,UAAU;gBACzC,yBAAyB,EAAE,QAAQ;gBACnC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,KAAK,MAAM;aAClE,IAEA,IAAI,CAAC,KAAK,KACT,8DAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAC,qBAAqB,EAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IACjF,IAAI,CAAC,UAAU,KACd,6DAAM,KAAK,EAAC,wBAAwB,iBAAa,MAAM,QAEhD,CACR,EACA,IAAI,CAAC,KAAK,CACL,CACT,EACD,4DAAK,KAAK,EAAC,uBAAuB,EAAC,IAAI,EAAC,OAAO,qBAAkB,OAAO,mBAAiB,IAAI,CAAC,UAAU,GAAG,MAAM,GAAG,SAAS,kBAAgB,QAAQ,GAAG,MAAM,GAAG,SAAS,IACxK,8DAAQ,EACP,QAAQ,KACP,4DAAK,KAAK,EAAC,qBAAqB,EAAC,IAAI,EAAC,OAAO,IAC1C,IAAI,CAAC,YAAY,CACd,CACP,CACG,CACF,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"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 /**\n * F6:手动校验态('success' | 'warning' | 'error' | 'validating' | '')。\n * 设置后覆盖内部校验结果驱动的错误显示(对齐 antd validateStatus)。\n */\n @Prop() validateStatus?: '' | 'success' | 'warning' | 'error' | 'validating';\n\n /** F6:手动错误/帮助文案(配合 validateStatus='error' 显示自定义提示) */\n @Prop() help?: string;\n\n /**\n * F7:标签栅格占比(1-24)。未设置时用 labelWidth。\n * 对齐 antd labelCol(简化为纯数字栅格,labelCol.span)。\n */\n @Prop() labelCol?: number;\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 * F4:继承父 hb-form 的 validateMessages(校验提示模板)。\n * 支持占位符 {label}。仅对 rule 未显式指定 message 的规则生效。\n */\n private get resolvedValidateMessages(): Record<string, string> | undefined {\n const form = this.el.closest('hb-form') as any;\n return form && form.validateMessages;\n }\n\n /** 用模板生成错误文案({label} 替换为字段标签),优先级:rule.message > 模板 > 内置默认 */\n private msg(rule: any, key: string, fallback: string): string {\n if (rule.message) return rule.message;\n const tmpl = this.resolvedValidateMessages;\n const label = this.label || this.prop;\n if (tmpl && tmpl[key]) return tmpl[key].replace('{label}', label);\n return fallback.replace('{label}', label);\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(this.msg(rule, 'required', `${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(this.msg(rule, 'pattern', `${this.label || this.prop}格式不正确`));\n continue;\n }\n }\n if (rule.type === 'email') {\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(String(value))) {\n errors.push(this.msg(rule, 'email', `${this.label || this.prop}格式不正确`));\n continue;\n }\n }\n if (rule.min !== undefined && typeof value === 'string' && value.length < rule.min) {\n errors.push(this.msg(rule, 'min', `${this.label || this.prop}最少${rule.min}个字符`));\n continue;\n }\n if (rule.max !== undefined && typeof value === 'string' && value.length > rule.max) {\n errors.push(this.msg(rule, 'max', `${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 /** F6:实际显示的错误文案。手动 help 优先;否则取内部 errors[0] */\n private get displayError(): string {\n if (this.help !== undefined) return this.help;\n return this.errors[0] || '';\n }\n\n /** F6:实际是否显示错误(手动 validateStatus='error' 或内部有错) */\n private get showError(): boolean {\n if (this.validateStatus === 'error') return true;\n if (this.validateStatus === 'success' || this.validateStatus === 'validating') return false;\n return this.errors.length > 0;\n }\n\n render() {\n const labelTop = this.resolvedLabelPosition === 'top';\n const hasError = this.showError;\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 // F7:labelCol 栅格占比(1-24),未设置时回退 labelWidth\n const labelStyle = this.labelCol\n ? { width: `${(this.labelCol / 24) * 100}%` }\n : this.labelWidth\n ? { width: this.labelWidth }\n : 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 || this.validateStatus === 'validating',\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={labelStyle} 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.displayError}\n </div>\n )}\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -24,17 +24,104 @@ const Form = /*@__PURE__*/ proxyCustomElement(class Form extends H {
|
|
|
24
24
|
size = 'default';
|
|
25
25
|
/** 是否禁用 */
|
|
26
26
|
disabled = false;
|
|
27
|
+
/**
|
|
28
|
+
* F1:初始值(非受控)。挂载后把这些值写到对应字段的子控件 modelValue。
|
|
29
|
+
* key = FormItem 的 prop。
|
|
30
|
+
*/
|
|
31
|
+
initialValues;
|
|
32
|
+
/**
|
|
33
|
+
* F4:校验提示模板。覆盖默认的「{label}不能为空」「{label}格式不正确」等文案。
|
|
34
|
+
* 支持 {label} 占位符。仅对未在 rule.message 显式指定消息的规则生效。
|
|
35
|
+
*/
|
|
36
|
+
validateMessages;
|
|
37
|
+
/**
|
|
38
|
+
* F2:提交且校验通过后的回调。参数为各字段当前值组成的对象。
|
|
39
|
+
* 由表单 submit(form onSubmit)触发——表单内放 type="submit" 的按钮即可。
|
|
40
|
+
*/
|
|
41
|
+
onFinish;
|
|
42
|
+
/**
|
|
43
|
+
* F2:提交且校验失败后的回调。
|
|
44
|
+
*/
|
|
45
|
+
onFinishFailed;
|
|
46
|
+
/**
|
|
47
|
+
* F3:任意字段值变化时的回调。参数为 { prop, value, values }。
|
|
48
|
+
* 由子控件冒泡的 hbChange 触发。
|
|
49
|
+
*/
|
|
50
|
+
onValuesChange;
|
|
27
51
|
fields = [];
|
|
28
52
|
fieldRegistry = new Map();
|
|
29
53
|
// 用 componentWillLoad 而非 componentDidLoad 注册监听器:
|
|
30
54
|
// Stencil 生命周期里子组件(FormItem)的 componentDidLoad 先于父组件(Form)触发,
|
|
31
55
|
// 若在 componentDidLoad 才挂监听,会错过子项派发的 hbFormFieldRegister,
|
|
32
56
|
// 导致 fieldRegistry 为空、validate() 永远返回 true(真实浏览器里复现,mock-doc 被 waitForChanges 掩盖)。
|
|
57
|
+
// L1:抽命名 handler 以便 disconnectedCallback 正确 remove(修复前匿名箭头无法 remove)。
|
|
58
|
+
handleFieldRegister = ((e) => {
|
|
59
|
+
const { prop, validate, resetValue, getValue } = e.detail;
|
|
60
|
+
this.fieldRegistry.set(prop, { prop, validate, resetValue, getValue });
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* F3:监听子控件冒泡的 hbChange,识别来源 FormItem 并触发 onValuesChange。
|
|
64
|
+
* 注:hbChange 由 hb-input/hb-select 等控件发出(composed 冒泡穿过 shadow),
|
|
65
|
+
* 这里在 host 上捕获,通过 closest('hb-form-item') 定位字段 prop。
|
|
66
|
+
*/
|
|
67
|
+
handleFieldChange = ((e) => {
|
|
68
|
+
if (!this.onValuesChange)
|
|
69
|
+
return;
|
|
70
|
+
const target = e.target;
|
|
71
|
+
const item = target.closest?.('hb-form-item');
|
|
72
|
+
if (!item)
|
|
73
|
+
return;
|
|
74
|
+
const prop = item.prop;
|
|
75
|
+
if (!prop)
|
|
76
|
+
return;
|
|
77
|
+
// 取该字段最新值
|
|
78
|
+
const reg = this.fieldRegistry.get(prop);
|
|
79
|
+
const value = reg ? reg.getValue() : undefined;
|
|
80
|
+
this.onValuesChange({ prop, value, values: this.getFieldsValue() });
|
|
81
|
+
});
|
|
33
82
|
componentWillLoad() {
|
|
34
|
-
this.el.addEventListener('hbFormFieldRegister',
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
83
|
+
this.el.addEventListener('hbFormFieldRegister', this.handleFieldRegister);
|
|
84
|
+
// F3:捕获子控件值变化
|
|
85
|
+
this.el.addEventListener('hbChange', this.handleFieldChange);
|
|
86
|
+
}
|
|
87
|
+
componentDidLoad() {
|
|
88
|
+
// F1:把 initialValues 写到对应字段的子控件
|
|
89
|
+
if (this.initialValues) {
|
|
90
|
+
this.fieldRegistry.forEach((_reg, prop) => {
|
|
91
|
+
if (this.initialValues && prop in this.initialValues) {
|
|
92
|
+
this.setFieldValue(prop, this.initialValues[prop]);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
this.el.removeEventListener('hbFormFieldRegister', this.handleFieldRegister);
|
|
99
|
+
this.el.removeEventListener('hbChange', this.handleFieldChange);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 收集所有字段的当前值(getFieldsValue)。
|
|
103
|
+
*/
|
|
104
|
+
getFieldsValue() {
|
|
105
|
+
const values = {};
|
|
106
|
+
this.fieldRegistry.forEach((reg, prop) => {
|
|
107
|
+
values[prop] = reg.getValue();
|
|
108
|
+
});
|
|
109
|
+
return values;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 设置某字段子控件的值(setFieldValue)。
|
|
113
|
+
* 子控件统一用 modelValue 受控。
|
|
114
|
+
*/
|
|
115
|
+
setFieldValue(prop, value) {
|
|
116
|
+
const formItem = this.el.querySelector(`hb-form-item[prop="${prop}"]`);
|
|
117
|
+
if (!formItem)
|
|
118
|
+
return;
|
|
119
|
+
const control = formItem.querySelector('hb-input, hb-select, hb-cascader, hb-date-picker, hb-date-time-picker, hb-date-range-picker, ' +
|
|
120
|
+
'hb-input-number, hb-textarea, hb-checkbox, hb-checkbox-group, hb-radio-group, hb-switch, ' +
|
|
121
|
+
'hb-slider, hb-color-picker, hb-rate, hb-time-picker, hb-time-select');
|
|
122
|
+
if (control) {
|
|
123
|
+
control.modelValue = value;
|
|
124
|
+
}
|
|
38
125
|
}
|
|
39
126
|
/**
|
|
40
127
|
* 验证整个表单
|
|
@@ -47,18 +134,39 @@ const Form = /*@__PURE__*/ proxyCustomElement(class Form extends H {
|
|
|
47
134
|
}));
|
|
48
135
|
return results.every(Boolean);
|
|
49
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* F2:提交表单——校验全部字段,通过则 onFinish(values),失败则 onFinishFailed(errors)。
|
|
139
|
+
*/
|
|
140
|
+
handleSubmit = async (e) => {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
const errorList = [];
|
|
143
|
+
let allOk = true;
|
|
144
|
+
for (const field of this.fieldRegistry.values()) {
|
|
145
|
+
const errors = await field.validate();
|
|
146
|
+
if (errors.length > 0) {
|
|
147
|
+
allOk = false;
|
|
148
|
+
errorList.push({ prop: field.prop, errors });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (allOk) {
|
|
152
|
+
this.onFinish?.(this.getFieldsValue());
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.onFinishFailed?.(errorList);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
50
158
|
/**
|
|
51
159
|
* 重置表单
|
|
52
160
|
*/
|
|
53
161
|
resetFields = () => {
|
|
54
|
-
this.fieldRegistry.forEach(
|
|
162
|
+
this.fieldRegistry.forEach(field => field.resetValue());
|
|
55
163
|
};
|
|
56
164
|
render() {
|
|
57
|
-
return (h("form", { key: '
|
|
165
|
+
return (h("form", { key: '876ec07f044efed1a9aa92dbb76642b95013e9a5', class: {
|
|
58
166
|
'hb-form': true,
|
|
59
167
|
[`hb-form--label-${this.labelPosition}`]: true,
|
|
60
168
|
'hb-form--inline': this.inline,
|
|
61
|
-
}, onSubmit:
|
|
169
|
+
}, onSubmit: this.handleSubmit, novalidate: true }, h("slot", { key: '16efaff38a6f97ff1f339eef37f55b7e4aff0f4c' })));
|
|
62
170
|
}
|
|
63
171
|
static get style() { return HbFormStyle0; }
|
|
64
172
|
}, [1, "hb-form", {
|
|
@@ -69,6 +177,11 @@ const Form = /*@__PURE__*/ proxyCustomElement(class Form extends H {
|
|
|
69
177
|
"inline": [4],
|
|
70
178
|
"size": [1],
|
|
71
179
|
"disabled": [4],
|
|
180
|
+
"initialValues": [16],
|
|
181
|
+
"validateMessages": [16],
|
|
182
|
+
"onFinish": [16],
|
|
183
|
+
"onFinishFailed": [16],
|
|
184
|
+
"onValuesChange": [16],
|
|
72
185
|
"validate": [16],
|
|
73
186
|
"resetFields": [16],
|
|
74
187
|
"fields": [32]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-form.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;;;;;IAMjE,iBAAiB;QACf,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,qBAAqB,GAAG,CAAC,CAAc;YAC9D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;YAC1D,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;SACxE,EAAmB,CAAC;KACtB;;;;;IAMO,QAAQ,GAAG;QACjB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,KAAK;YACtD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;YACtC,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;SAC5B,CAAC,CACH,CAAC;QACF,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC/B,CAAC;;;;IAKM,WAAW,GAAG;QACpB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;KAC3D,CAAC;IAEF,MAAM;QACJ,QACE,6DACE,KAAK,EAAE;gBACL,SAAS,EAAE,IAAI;gBACf,CAAC,kBAAkB,IAAI,CAAC,aAAa,EAAE,GAAG,IAAI;gBAC9C,iBAAiB,EAAE,IAAI,CAAC,MAAM;aAC/B,EACD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,EACnC,UAAU,UAEV,8DAAQ,CACH,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/Form/form.css?tag=hb-form&encapsulation=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 componentWillLoad() {\n this.el.addEventListener('hbFormFieldRegister', ((e: CustomEvent) => {\n const { prop, validate, resetValue, getValue } = e.detail;\n this.fieldRegistry.set(prop, { prop, validate, resetValue, getValue });\n }) as EventListener);\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}
|
|
1
|
+
{"file":"hb-form.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;;;;;IAM1B,aAAa,CAAuB;;;;;IAMpC,gBAAgB,CAAuF;;;;;IAMvG,QAAQ,CAAyC;;;;IAKjD,cAAc,CAA0D;;;;;IAMxE,cAAc,CAA6E;IAE1F,MAAM,GAA4B,EAAE,CAAC;IAEtC,aAAa,GAAG,IAAI,GAAG,EAAiC,CAAC;;;;;;IAOzD,mBAAmB,IAAI,CAAC,CAAc;QAC5C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;QAC1D,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;KACxE,EAAmB;;;;;;IAOZ,iBAAiB,IAAI,CAAC,CAAQ;QACpC,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO;QACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAqB,CAAC;QACvC,MAAM,IAAI,GAAG,MA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rB,KAAK,GAAG,KAAK,CAAC;gBACd,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;aAC9C;SACF;QACD,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;SACxC;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;SAClC;KACF,CAAC;;;;IAKM,WAAW,GAAG;QACpB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;KACzD,CAAC;IAEF,MAAM;QACJ,QACE,6DACE,KAAK,EAAE;gBACL,SAAS,EAAE,IAAI;gBACf,CAAC,kBAAkB,IAAI,CAAC,aAAa,EAAE,GAAG,IAAI;gBAC9C,iBAAiB,EAAE,IAAI,CAAC,MAAM;aAC/B,EACD,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,UAAU,UAEV,8DAAQ,CACH,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/Form/form.css?tag=hb-form&encapsulation=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 /**\n * F1:初始值(非受控)。挂载后把这些值写到对应字段的子控件 modelValue。\n * key = FormItem 的 prop。\n */\n @Prop() initialValues?: Record<string, any>;\n\n /**\n * F4:校验提示模板。覆盖默认的「{label}不能为空」「{label}格式不正确」等文案。\n * 支持 {label} 占位符。仅对未在 rule.message 显式指定消息的规则生效。\n */\n @Prop() validateMessages?: { required?: string; pattern?: string; email?: string; min?: string; max?: string };\n\n /**\n * F2:提交且校验通过后的回调。参数为各字段当前值组成的对象。\n * 由表单 submit(form onSubmit)触发——表单内放 type=\"submit\" 的按钮即可。\n */\n @Prop() onFinish?: (values: Record<string, any>) => void;\n\n /**\n * F2:提交且校验失败后的回调。\n */\n @Prop() onFinishFailed?: (errors: { prop: string; errors: string[] }[]) => void;\n\n /**\n * F3:任意字段值变化时的回调。参数为 { prop, value, values }。\n * 由子控件冒泡的 hbChange 触发。\n */\n @Prop() onValuesChange?: (info: { prop: string; value: any; values: Record<string, any> }) => void;\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 /**\n * F3:监听子控件冒泡的 hbChange,识别来源 FormItem 并触发 onValuesChange。\n * 注:hbChange 由 hb-input/hb-select 等控件发出(composed 冒泡穿过 shadow),\n * 这里在 host 上捕获,通过 closest('hb-form-item') 定位字段 prop。\n */\n private handleFieldChange = ((e: Event) => {\n if (!this.onValuesChange) return;\n const target = e.target as HTMLElement;\n const item = target.closest?.('hb-form-item') as any;\n if (!item) return;\n const prop = item.prop;\n if (!prop) return;\n // 取该字段最新值\n const reg = this.fieldRegistry.get(prop);\n const value = reg ? reg.getValue() : undefined;\n this.onValuesChange({ prop, value, values: this.getFieldsValue() });\n }) as EventListener;\n\n componentWillLoad() {\n this.el.addEventListener('hbFormFieldRegister', this.handleFieldRegister);\n // F3:捕获子控件值变化\n this.el.addEventListener('hbChange', this.handleFieldChange);\n }\n\n componentDidLoad() {\n // F1:把 initialValues 写到对应字段的子控件\n if (this.initialValues) {\n this.fieldRegistry.forEach((_reg, prop) => {\n if (this.initialValues && prop in this.initialValues) {\n this.setFieldValue(prop, this.initialValues[prop]);\n }\n });\n }\n }\n\n disconnectedCallback() {\n this.el.removeEventListener('hbFormFieldRegister', this.handleFieldRegister);\n this.el.removeEventListener('hbChange', this.handleFieldChange);\n }\n\n /**\n * 收集所有字段的当前值(getFieldsValue)。\n */\n private getFieldsValue(): Record<string, any> {\n const values: Record<string, any> = {};\n this.fieldRegistry.forEach((reg, prop) => {\n values[prop] = reg.getValue();\n });\n return values;\n }\n\n /**\n * 设置某字段子控件的值(setFieldValue)。\n * 子控件统一用 modelValue 受控。\n */\n private setFieldValue(prop: string, value: any) {\n const formItem = this.el.querySelector(`hb-form-item[prop=\"${prop}\"]`) as HTMLElement | null;\n if (!formItem) return;\n const control = formItem.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 ) as any;\n if (control) {\n control.modelValue = value;\n }\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 * F2:提交表单——校验全部字段,通过则 onFinish(values),失败则 onFinishFailed(errors)。\n */\n private handleSubmit = async (e: Event) => {\n e.preventDefault();\n const errorList: { prop: string; errors: string[] }[] = [];\n let allOk = true;\n for (const field of this.fieldRegistry.values()) {\n const errors = await field.validate();\n if (errors.length > 0) {\n allOk = false;\n errorList.push({ prop: field.prop, errors });\n }\n }\n if (allOk) {\n this.onFinish?.(this.getFieldsValue());\n } else {\n this.onFinishFailed?.(errorList);\n }\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={this.handleSubmit}\n novalidate\n >\n <slot />\n </form>\n );\n }\n}\n"],"version":3}
|
|
@@ -167,7 +167,7 @@ const ImagePreview = /*@__PURE__*/ proxyCustomElement(class ImagePreview extends
|
|
|
167
167
|
const imgStyle = {
|
|
168
168
|
transform: `scale(${this.zoom}) rotate(${this.rotate}deg)`,
|
|
169
169
|
};
|
|
170
|
-
return (h("div", { class: "hb-image-preview", onClick: this.handleOverlayClick }, h("div", { class: "hb-image-preview__wrapper" }, h("img", { class: "hb-image-preview__img", src: this.currentSrc, alt: "", style: imgStyle, onWheel: this.handleWheel })), this.isMulti && (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 && (h("button", { type: "button", class: "hb-image-preview__btn hb-image-preview__btn--next", onClick: this.next, "aria-label": "\u4E0B\u4E00\u5F20" }, "\u203A")), h("div", { class: "hb-image-preview__toolbar", onClick:
|
|
170
|
+
return (h("div", { class: "hb-image-preview", onClick: this.handleOverlayClick }, h("div", { class: "hb-image-preview__wrapper" }, h("img", { class: "hb-image-preview__img", src: this.currentSrc, alt: "", style: imgStyle, onWheel: this.handleWheel })), this.isMulti && (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 && (h("button", { type: "button", class: "hb-image-preview__btn hb-image-preview__btn--next", onClick: this.next, "aria-label": "\u4E0B\u4E00\u5F20" }, "\u203A")), h("div", { class: "hb-image-preview__toolbar", onClick: e => e.stopPropagation() }, h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.zoomOut, "aria-label": "\u7F29\u5C0F" }, "\uFF0D"), h("span", { class: "hb-image-preview__tool-label" }, Math.round(this.zoom * 100), "%"), h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.zoomIn, "aria-label": "\u653E\u5927" }, "\uFF0B"), h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.handleRotateLeft, "aria-label": "\u5DE6\u65CB" }, "\u21BA"), h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.handleRotateRight, "aria-label": "\u53F3\u65CB" }, "\u21BB"), h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.handleReset, "aria-label": "\u91CD\u7F6E" }, "\u27F2"), h("button", { type: "button", class: "hb-image-preview__tool", onClick: this.stopAndClose, "aria-label": "\u5173\u95ED" }, "\u2715")), h("button", { type: "button", class: "hb-image-preview__close", onClick: this.stopAndClose, "aria-label": "\u5173\u95ED" }, "\u00D7")));
|
|
171
171
|
}
|
|
172
172
|
static get watchers() { return {
|
|
173
173
|
"modelValue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AC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,gBAAa,cAAI,aAE3F,EACT,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,gBAAa,cAAI,aAE5F,EACT,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,gBAAa,cAAI,aAEtF,EACT,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,gBAAa,cAAI,aAEvF,CACL,EAEN,cACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,yBAAyB,EAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,gBACf,cAAI,aAGR,CACL,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"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\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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C,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,gBAAa,cAAI,aAE3F,EACT,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,gBAAa,cAAI,aAE5F,EACT,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,gBAAa,cAAI,aAEtF,EACT,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,gBAAa,cAAI,aAEvF,CACL,EAEN,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,yBAAyB,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,gBAAa,cAAI,aAExF,CACL,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"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}
|
|
@@ -20,11 +20,29 @@ const Image = /*@__PURE__*/ proxyCustomElement(class Image extends H {
|
|
|
20
20
|
loaded = false;
|
|
21
21
|
error = false;
|
|
22
22
|
previewVisible = false;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* 换 src 时重置 loaded/error。
|
|
25
|
+
* 修复 B5——修复前换 src 不清状态:坏图换好图卡在错误占位(error 不清零),
|
|
26
|
+
* 好图换坏图 loaded 仍 true 造成短暂状态错乱。
|
|
27
|
+
*/
|
|
28
|
+
handleSrcChange() {
|
|
29
|
+
this.loaded = false;
|
|
30
|
+
this.error = false;
|
|
31
|
+
}
|
|
32
|
+
handleLoad = () => {
|
|
33
|
+
this.loaded = true;
|
|
34
|
+
};
|
|
35
|
+
handleError = () => {
|
|
36
|
+
this.error = true;
|
|
37
|
+
};
|
|
25
38
|
render() {
|
|
26
|
-
return (h("div", { key: '
|
|
39
|
+
return (h("div", { key: 'c9bbb745e78918ca3659138a91e7472911ac4c09', class: "hb-image", style: { width: this.width, height: this.height, borderRadius: this.radius } }, !this.error ? (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) })) : (h("div", { class: "hb-image__error" }, "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25")), this.previewVisible && (h("div", { key: '7d3b00d09c919169eab62ab6f525b2ef2f038a4c', class: "hb-image__preview", onClick: () => {
|
|
40
|
+
this.previewVisible = false;
|
|
41
|
+
} }, h("img", { key: '7c05ea33e51493d3a297f0e1c7d3511efae46a6c', src: this.src, alt: this.alt, class: "hb-image__preview-img" })))));
|
|
27
42
|
}
|
|
43
|
+
static get watchers() { return {
|
|
44
|
+
"src": ["handleSrcChange"]
|
|
45
|
+
}; }
|
|
28
46
|
static get style() { return HbImageStyle0; }
|
|
29
47
|
}, [1, "hb-image", {
|
|
30
48
|
"src": [1],
|
|
@@ -38,6 +56,8 @@ const Image = /*@__PURE__*/ proxyCustomElement(class Image extends H {
|
|
|
38
56
|
"loaded": [32],
|
|
39
57
|
"error": [32],
|
|
40
58
|
"previewVisible": [32]
|
|
59
|
+
}, undefined, {
|
|
60
|
+
"src": ["handleSrcChange"]
|
|
41
61
|
}]);
|
|
42
62
|
function defineCustomElement$1() {
|
|
43
63
|
if (typeof customElements === "undefined") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"hb-image.js","mappings":";;AAAA,MAAM,QAAQ,GAAG,usMAAusM,CAAC;AACztM,sBAAe,QAAQ;;MCEV,KAAK;;;;;;IACR,GAAG,GAAW,EAAE,CAAC;IACjB,GAAG,GAAW,EAAE,CAAC;IACjB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,GAAG,GAAyD,MAAM,CAAC;IACnE,IAAI,GAAY,KAAK,CAAC;IACtB,OAAO,GAAY,KAAK,CAAC;IACzB,MAAM,CAAU;IAEf,MAAM,GAAY,KAAK,CAAC;IACxB,KAAK,GAAY,KAAK,CAAC;IACvB,cAAc,GAAY,KAAK,CAAC;
|
|
1
|
+
{"file":"hb-image.js","mappings":";;AAAA,MAAM,QAAQ,GAAG,usMAAusM,CAAC;AACztM,sBAAe,QAAQ;;MCEV,KAAK;;;;;;IACR,GAAG,GAAW,EAAE,CAAC;IACjB,GAAG,GAAW,EAAE,CAAC;IACjB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,GAAG,GAAyD,MAAM,CAAC;IACnE,IAAI,GAAY,KAAK,CAAC;IACtB,OAAO,GAAY,KAAK,CAAC;IACzB,MAAM,CAAU;IAEf,MAAM,GAAY,KAAK,CAAC;IACxB,KAAK,GAAY,KAAK,CAAC;IACvB,cAAc,GAAY,KAAK,CAAC;;;;;;IAQzC,eAAe;QACb,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KACpB;IAEO,UAAU,GAAG;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;KACpB,CAAC;IACM,WAAW,GAAG;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB,CAAC;IAEF,MAAM;QACJ,QACE,4DAAK,KAAK,EAAC,UAAU,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,IAC/F,CAAC,IAAI,CAAC,KAAK,IACV,WACE,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,CAAC,MAAM,EAAE,EAC1E,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAC9B,OAAO,EAAE,IAAI,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,EACvC,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,MAAM,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAC3D,KAEF,WAAK,KAAK,EAAC,iBAAiB,2CAAa,CAC1C,EACA,IAAI,CAAC,cAAc,KAClB,4DACE,KAAK,EAAC,mBAAmB,EACzB,OAAO,EAAE;gBACP,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;aAC7B,IAED,4DAAK,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAC,uBAAuB,GAAG,CAC/D,CACP,CACG,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/Image/image.css?tag=hb-image&encapsulation=shadow","src/components/Image/Image.tsx"],"sourcesContent":[":host { display: inline-block; }\n.hb-image { position: relative; display: inline-flex; overflow: hidden; background: var(--hb-color-fill-quaternary); }\n.hb-image__inner { width: 100%; height: 100%; opacity: 0; transition: opacity 0.3s; }\n.hb-image__inner--loaded { opacity: 1; }\n.hb-image__error { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: var(--hb-font-size-sm); color: var(--hb-color-text-secondary); }\n.hb-image__preview { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 2000; cursor: zoom-out; }\n.hb-image__preview-img { max-width: 90%; max-height: 90%; object-fit: contain; }\n","import { Component, h, Prop, State, Watch } from '@stencil/core';\n\n@Component({ tag: 'hb-image', styleUrl: 'image.css', shadow: true })\nexport class Image {\n @Prop() src: string = '';\n @Prop() alt: string = '';\n @Prop() width?: string;\n @Prop() height?: string;\n @Prop() fit: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down' = 'fill';\n @Prop() lazy: boolean = false;\n @Prop() preview: boolean = false;\n @Prop() radius?: string;\n\n @State() loaded: boolean = false;\n @State() error: boolean = false;\n @State() previewVisible: boolean = false;\n\n /**\n * 换 src 时重置 loaded/error。\n * 修复 B5——修复前换 src 不清状态:坏图换好图卡在错误占位(error 不清零),\n * 好图换坏图 loaded 仍 true 造成短暂状态错乱。\n */\n @Watch('src')\n handleSrcChange() {\n this.loaded = false;\n this.error = false;\n }\n\n private handleLoad = () => {\n this.loaded = true;\n };\n private handleError = () => {\n this.error = true;\n };\n\n render() {\n return (\n <div class=\"hb-image\" style={{ width: this.width, height: this.height, borderRadius: this.radius }}>\n {!this.error ? (\n <img\n src={this.src}\n alt={this.alt}\n class={{ 'hb-image__inner': true, 'hb-image__inner--loaded': this.loaded }}\n style={{ objectFit: this.fit }}\n loading={this.lazy ? 'lazy' : undefined}\n onLoad={this.handleLoad}\n onError={this.handleError}\n onClick={() => this.preview && (this.previewVisible = true)}\n />\n ) : (\n <div class=\"hb-image__error\">图片加载失败</div>\n )}\n {this.previewVisible && (\n <div\n class=\"hb-image__preview\"\n onClick={() => {\n this.previewVisible = false;\n }}\n >\n <img src={this.src} alt={this.alt} class=\"hb-image__preview-img\" />\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h } from './p-1407a5e8.js';
|
|
2
2
|
|
|
3
|
-
const inputNumberCss = "/*! 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{.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{--hb-input-number-font-size:14px;--hb-input-number-height:32px;--hb-input-number-border-color:var(--hb-border-color,#dcdfe6);--hb-input-number-border-color-hover:var(--hb-color-primary);--hb-input-number-bg-color:var(--hb-color-white,#fff);display:inline-block;position:relative}.hb-input-number{display:inline-block;position:relative;width:180px}.hb-input-number,.hb-input-number__inner{line-height:var(--hb-input-number-height)}.hb-input-number__inner{-webkit-appearance:none;background-color:var(--hb-input-number-bg-color);border:1px solid var(--hb-input-number-border-color);border-radius:4px;box-sizing:border-box;color:var(--hb-color-text-regular,#606266);display:block;font-size:inherit;height:var(--hb-input-number-height);outline:none;padding:0 50px 0 15px;text-align:left;transition:border-color .2s cubic-bezier(.645,.045,.355,1);width:100%}.hb-input-number--without-controls .hb-input-number__inner{padding:0 15px}.hb-input-number--controls-right .hb-input-number__inner{padding:0 15px 0 50px}.hb-input-number__inner:focus,.hb-input-number__inner:hover:not(:disabled){border-color:var(--hb-input-number-border-color-hover)}.hb-input-number__inner:disabled{background-color:var(--hb-fill-color-light,#f5f7fa);border-color:var(--hb-input-number-border-color);color:var(--hb-color-text-disabled,#c0c4cc);cursor:not-allowed}.hb-input-number__decrease,.hb-input-number__increase{align-items:center;background:var(--hb-fill-color-light,#f5f7fa);color:var(--hb-color-text-regular,#606266);cursor:pointer;display:flex;font-size:13px;height:calc(100% - 2px);justify-content:center;position:absolute;text-align:center;top:1px;transition:all .2s;-webkit-user-select:none;user-select:none;width:35px;z-index:1}.hb-input-number__decrease:hover:not(.hb-input-number__decrease--disabled),.hb-input-number__increase:hover:not(.hb-input-number__increase--disabled){color:var(--hb-color-primary)}.hb-input-number__decrease--disabled,.hb-input-number__increase--disabled{color:var(--hb-color-text-disabled,#c0c4cc);cursor:not-allowed}.hb-input-number__increase{border-radius:0 4px 4px 0;right:1px}.hb-input-number__decrease,.hb-input-number__increase{border-left:1px solid var(--hb-input-number-border-color)}.hb-input-number__decrease{border-radius:0;right:36px}.hb-input-number--controls-right .hb-input-number__increase{border-radius:0 4px 4px 0;right:1px}.hb-input-number--controls-right .hb-input-number__decrease{border-radius:0;right:36px}.hb-input-number__controls{background:var(--hb-fill-color-light,#f5f7fa);border-left:1px solid var(--hb-input-number-border-color);border-radius:0 4px 4px 0;height:calc(100% - 2px);position:absolute;right:1px;top:1px;width:35px}.hb-input-number--controls-right .hb-input-number__controls{border-left:none;border-radius:4px 0 0 4px;border-right:1px solid var(--hb-input-number-border-color);left:1px;right:auto}.hb-input-number--controls-right .hb-input-number__controls .hb-input-number__increase{border:none;border-bottom:1px solid var(--hb-input-number-border-color);border-radius:0;position:static}.hb-input-number--controls-right .hb-input-number__controls .hb-input-number__decrease{border:none;border-radius:0 0 0 4px;position:static}.hb-input-number--small{width:150px}.hb-input-number--small .hb-input-number__inner{font-size:12px;height:24px;line-height:24px;padding:0 40px 0 12px}.hb-input-number--large{width:200px}.hb-input-number--large .hb-input-number__inner{font-size:16px;height:40px;line-height:40px;padding:0 55px 0 18px}.hb-input-number--disabled{cursor:not-allowed}@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}";
|
|
3
|
+
const inputNumberCss = "/*! 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{.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{--hb-input-number-font-size:14px;--hb-input-number-height:32px;--hb-input-number-border-color:var(--hb-border-color,#dcdfe6);--hb-input-number-border-color-hover:var(--hb-color-primary);--hb-input-number-bg-color:var(--hb-color-white,#fff);display:inline-block;position:relative}.hb-input-number{display:inline-block;position:relative;width:180px}.hb-input-number,.hb-input-number__inner{line-height:var(--hb-input-number-height)}.hb-input-number__inner{-webkit-appearance:none;background-color:var(--hb-input-number-bg-color);border:1px solid var(--hb-input-number-border-color);border-radius:4px;box-sizing:border-box;color:var(--hb-color-text-regular,#606266);display:block;font-size:inherit;height:var(--hb-input-number-height);outline:none;padding:0 50px 0 15px;text-align:left;transition:border-color .2s cubic-bezier(.645,.045,.355,1);width:100%}.hb-input-number--without-controls .hb-input-number__inner{padding:0 15px}.hb-input-number--controls-right .hb-input-number__inner{padding:0 15px 0 50px}.hb-input-number__inner:focus,.hb-input-number__inner:hover:not(:disabled){border-color:var(--hb-input-number-border-color-hover)}.hb-input-number__inner:disabled{background-color:var(--hb-fill-color-light,#f5f7fa);border-color:var(--hb-input-number-border-color);color:var(--hb-color-text-disabled,#c0c4cc);cursor:not-allowed}.hb-input-number__decrease,.hb-input-number__increase{align-items:center;background:var(--hb-fill-color-light,#f5f7fa);border:none;color:var(--hb-color-text-regular,#606266);cursor:pointer;display:flex;font-family:inherit;font-size:13px;height:calc(100% - 2px);justify-content:center;line-height:1;padding:0;position:absolute;text-align:center;top:1px;transition:all .2s;-webkit-user-select:none;user-select:none;width:35px;z-index:1}.hb-input-number__decrease:focus-visible,.hb-input-number__increase:focus-visible{outline:2px solid var(--hb-color-primary,#409eff);outline-offset:-2px}.hb-input-number__decrease:hover:not(.hb-input-number__decrease--disabled),.hb-input-number__increase:hover:not(.hb-input-number__increase--disabled){color:var(--hb-color-primary)}.hb-input-number__decrease--disabled,.hb-input-number__increase--disabled{color:var(--hb-color-text-disabled,#c0c4cc);cursor:not-allowed}.hb-input-number__increase{border-radius:0 4px 4px 0;right:1px}.hb-input-number__decrease,.hb-input-number__increase{border-left:1px solid var(--hb-input-number-border-color)}.hb-input-number__decrease{border-radius:0;right:36px}.hb-input-number--controls-right .hb-input-number__increase{border-radius:0 4px 4px 0;right:1px}.hb-input-number--controls-right .hb-input-number__decrease{border-radius:0;right:36px}.hb-input-number__controls{background:var(--hb-fill-color-light,#f5f7fa);border-left:1px solid var(--hb-input-number-border-color);border-radius:0 4px 4px 0;height:calc(100% - 2px);position:absolute;right:1px;top:1px;width:35px}.hb-input-number--controls-right .hb-input-number__controls{border-left:none;border-radius:4px 0 0 4px;border-right:1px solid var(--hb-input-number-border-color);left:1px;right:auto}.hb-input-number--controls-right .hb-input-number__controls .hb-input-number__increase{border:none;border-bottom:1px solid var(--hb-input-number-border-color);border-radius:0;position:static}.hb-input-number--controls-right .hb-input-number__controls .hb-input-number__decrease{border:none;border-radius:0 0 0 4px;position:static}.hb-input-number--small{width:150px}.hb-input-number--small .hb-input-number__inner{font-size:12px;height:24px;line-height:24px;padding:0 40px 0 12px}.hb-input-number--large{width:200px}.hb-input-number--large .hb-input-number__inner{font-size:16px;height:40px;line-height:40px;padding:0 55px 0 18px}.hb-input-number--disabled{cursor:not-allowed}@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}";
|
|
4
4
|
const HbInputNumberStyle0 = inputNumberCss;
|
|
5
5
|
|
|
6
6
|
const InputNumber = /*@__PURE__*/ proxyCustomElement(class InputNumber extends H {
|
|
@@ -136,25 +136,25 @@ const InputNumber = /*@__PURE__*/ proxyCustomElement(class InputNumber extends H
|
|
|
136
136
|
this.hbChange.emit(newValue);
|
|
137
137
|
};
|
|
138
138
|
render() {
|
|
139
|
-
return (h("div", { key: '
|
|
139
|
+
return (h("div", { key: 'cf809c8e0c9c722a4be473a3455626f58aab40d9', class: {
|
|
140
140
|
'hb-input-number': true,
|
|
141
141
|
[`hb-input-number--${this.size}`]: true,
|
|
142
142
|
'hb-input-number--disabled': this.disabled,
|
|
143
143
|
'hb-input-number--controls-right': this.controlsPosition === 'right',
|
|
144
144
|
'hb-input-number--without-controls': !this.controls,
|
|
145
|
-
} }, this.controls && this.controlsPosition !== 'right' && (h("
|
|
145
|
+
} }, this.controls && this.controlsPosition !== 'right' && (h("button", { key: 'b97e5a774d7747fa61ee59650517ab0f64167dda', type: "button", class: {
|
|
146
146
|
'hb-input-number__decrease': true,
|
|
147
147
|
'hb-input-number__decrease--disabled': this.currentValue <= this.min,
|
|
148
|
-
}, onClick: this.decrease }, "\u2212")), h("input", { key: '
|
|
148
|
+
}, "aria-label": "\u51CF\u5C11", "aria-disabled": this.currentValue <= this.min || this.disabled, disabled: this.currentValue <= this.min || this.disabled, onClick: this.decrease }, "\u2212")), h("input", { key: '3b5357639f8b3676bb4de27dd67297288020a97f', type: "number", id: this.inputId, name: this.name, class: "hb-input-number__inner", value: this.currentValue, disabled: this.disabled, readonly: this.readonly, placeholder: this.placeholder, min: this.min, max: this.max, step: this.step, onInput: this.handleInput, onChange: this.handleChange }), this.controls && this.controlsPosition === 'right' && (h("span", { key: '00f8a845f5226999d02914ba6e62a29d24f1a26f', class: "hb-input-number__controls" }, h("button", { key: '886db946083adb10bdf8312dc985194b872000c4', type: "button", class: {
|
|
149
149
|
'hb-input-number__increase': true,
|
|
150
150
|
'hb-input-number__increase--disabled': this.currentValue >= this.max,
|
|
151
|
-
}, onClick: this.increase }, "+"), h("
|
|
151
|
+
}, "aria-label": "\u589E\u52A0", "aria-disabled": this.currentValue >= this.max || this.disabled, disabled: this.currentValue >= this.max || this.disabled, onClick: this.increase }, "+"), h("button", { key: '9c9b8d9fa6871e354a38bd5691d0a01b0b87cf9a', type: "button", class: {
|
|
152
152
|
'hb-input-number__decrease': true,
|
|
153
153
|
'hb-input-number__decrease--disabled': this.currentValue <= this.min,
|
|
154
|
-
}, onClick: this.decrease }, "\u2212"))), this.controls && this.controlsPosition !== 'right' && (h("
|
|
154
|
+
}, "aria-label": "\u51CF\u5C11", "aria-disabled": this.currentValue <= this.min || this.disabled, disabled: this.currentValue <= this.min || this.disabled, onClick: this.decrease }, "\u2212"))), this.controls && this.controlsPosition !== 'right' && (h("button", { key: 'c32d05810f4c0d9cd660483f45aac0f0f7ac48a5', type: "button", class: {
|
|
155
155
|
'hb-input-number__increase': true,
|
|
156
156
|
'hb-input-number__increase--disabled': this.currentValue >= this.max,
|
|
157
|
-
}, onClick: this.increase }, "+"))));
|
|
157
|
+
}, "aria-label": "\u589E\u52A0", "aria-disabled": this.currentValue >= this.max || this.disabled, disabled: this.currentValue >= this.max || this.disabled, onClick: this.increase }, "+"))));
|
|
158
158
|
}
|
|
159
159
|
static get watchers() { return {
|
|
160
160
|
"modelValue": ["handleModelValueChange"]
|