@chenzy-design/svelte 0.1.0 → 0.2.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/components.json +1 -1
- package/package.json +7 -8
- package/src/_floating/use-floating.ts +0 -208
- package/src/anchor/Anchor.a11y.test.ts +0 -49
- package/src/anchor/Anchor.kbd.test.ts +0 -70
- package/src/anchor/Anchor.svelte +0 -359
- package/src/anchor/AnchorKbdFixture.svelte +0 -24
- package/src/anchor/index.ts +0 -3
- package/src/anchor/meta.ts +0 -70
- package/src/anchor/types.ts +0 -8
- package/src/autocomplete/AutoComplete.a11y.test.ts +0 -49
- package/src/autocomplete/AutoComplete.kbd.test.ts +0 -69
- package/src/autocomplete/AutoComplete.svelte +0 -706
- package/src/autocomplete/AutoCompleteKbdFixture.svelte +0 -24
- package/src/autocomplete/index.ts +0 -2
- package/src/autocomplete/meta.ts +0 -41
- package/src/avatar/Avatar.a11y.test.ts +0 -37
- package/src/avatar/Avatar.svelte +0 -315
- package/src/avatar/AvatarGroup.svelte +0 -142
- package/src/avatar/context.ts +0 -21
- package/src/avatar/index.ts +0 -10
- package/src/avatar/meta.ts +0 -73
- package/src/back-top/BackTop.a11y.test.ts +0 -40
- package/src/back-top/BackTop.svelte +0 -314
- package/src/back-top/index.ts +0 -2
- package/src/back-top/meta.ts +0 -108
- package/src/badge/Badge.a11y.test.ts +0 -35
- package/src/badge/Badge.svelte +0 -328
- package/src/badge/BadgeA11yFixture.svelte +0 -18
- package/src/badge/index.ts +0 -2
- package/src/badge/meta.ts +0 -62
- package/src/banner/Banner.a11y.test.ts +0 -48
- package/src/banner/Banner.svelte +0 -368
- package/src/banner/index.ts +0 -3
- package/src/banner/meta.ts +0 -121
- package/src/breadcrumb/Breadcrumb.a11y.test.ts +0 -35
- package/src/breadcrumb/Breadcrumb.kbd.test.ts +0 -45
- package/src/breadcrumb/Breadcrumb.svelte +0 -414
- package/src/breadcrumb/BreadcrumbKbdFixture.svelte +0 -23
- package/src/breadcrumb/Item.svelte +0 -77
- package/src/breadcrumb/context.ts +0 -27
- package/src/breadcrumb/index.ts +0 -21
- package/src/breadcrumb/meta.ts +0 -128
- package/src/breadcrumb/types.ts +0 -4
- package/src/button/Button.a11y.test.ts +0 -54
- package/src/button/Button.svelte +0 -176
- package/src/button/index.ts +0 -2
- package/src/button/meta.ts +0 -28
- package/src/calendar/Calendar.a11y.test.ts +0 -51
- package/src/calendar/Calendar.kbd.test.ts +0 -59
- package/src/calendar/Calendar.svelte +0 -1344
- package/src/calendar/CalendarKbdFixture.svelte +0 -23
- package/src/calendar/index.ts +0 -3
- package/src/calendar/meta.ts +0 -117
- package/src/card/Card.a11y.test.ts +0 -38
- package/src/card/Card.svelte +0 -341
- package/src/card/CardMeta.svelte +0 -60
- package/src/card/index.ts +0 -8
- package/src/card/meta.ts +0 -83
- package/src/carousel/Carousel.a11y.test.ts +0 -53
- package/src/carousel/Carousel.kbd.test.ts +0 -67
- package/src/carousel/Carousel.svelte +0 -806
- package/src/carousel/CarouselA11yFixture.svelte +0 -25
- package/src/carousel/CarouselKbdFixture.svelte +0 -24
- package/src/carousel/index.ts +0 -2
- package/src/carousel/meta.ts +0 -74
- package/src/cascader/Cascader.a11y.test.ts +0 -59
- package/src/cascader/Cascader.kbd.test.ts +0 -56
- package/src/cascader/Cascader.svelte +0 -1570
- package/src/cascader/CascaderKbdFixture.svelte +0 -31
- package/src/cascader/index.ts +0 -3
- package/src/cascader/meta.ts +0 -57
- package/src/cascader/types.ts +0 -9
- package/src/checkbox/Checkbox.svelte +0 -281
- package/src/checkbox/CheckboxGroup.a11y.test.ts +0 -43
- package/src/checkbox/CheckboxGroup.kbd.test.ts +0 -40
- package/src/checkbox/CheckboxGroup.svelte +0 -122
- package/src/checkbox/CheckboxGroupKbdFixture.svelte +0 -20
- package/src/checkbox/context.ts +0 -31
- package/src/checkbox/index.ts +0 -4
- package/src/checkbox/meta.ts +0 -67
- package/src/collapse/Collapse.a11y.test.ts +0 -53
- package/src/collapse/Collapse.kbd.test.ts +0 -89
- package/src/collapse/Collapse.svelte +0 -406
- package/src/collapse/CollapseA11yFixture.svelte +0 -27
- package/src/collapse/CollapseKbdFixture.svelte +0 -25
- package/src/collapse/CollapsePanel.svelte +0 -102
- package/src/collapse/context.ts +0 -54
- package/src/collapse/index.ts +0 -17
- package/src/collapse/meta.ts +0 -79
- package/src/collapse/types.ts +0 -5
- package/src/color-picker/ColorPicker.a11y.test.ts +0 -60
- package/src/color-picker/ColorPicker.kbd.test.ts +0 -73
- package/src/color-picker/ColorPicker.svelte +0 -985
- package/src/color-picker/ColorPickerKbdFixture.svelte +0 -25
- package/src/color-picker/index.ts +0 -2
- package/src/color-picker/meta.ts +0 -47
- package/src/config-provider/ConfigProvider.svelte +0 -227
- package/src/config-provider/context.ts +0 -29
- package/src/config-provider/index.ts +0 -48
- package/src/config-provider/meta.ts +0 -128
- package/src/date-picker/DatePicker.a11y.test.ts +0 -45
- package/src/date-picker/DatePicker.kbd.test.ts +0 -71
- package/src/date-picker/DatePicker.svelte +0 -1798
- package/src/date-picker/DatePickerKbdFixture.svelte +0 -26
- package/src/date-picker/RangePicker.kbd.test.ts +0 -69
- package/src/date-picker/RangePicker.svelte +0 -775
- package/src/date-picker/RangePickerKbdFixture.svelte +0 -30
- package/src/date-picker/index.ts +0 -4
- package/src/date-picker/meta.ts +0 -67
- package/src/date-picker/range-meta.ts +0 -44
- package/src/descriptions/Descriptions.a11y.test.ts +0 -33
- package/src/descriptions/Descriptions.svelte +0 -287
- package/src/descriptions/DescriptionsItem.svelte +0 -43
- package/src/descriptions/context.ts +0 -21
- package/src/descriptions/index.ts +0 -16
- package/src/descriptions/meta.ts +0 -45
- package/src/descriptions/types.ts +0 -6
- package/src/divider/Divider.a11y.test.ts +0 -23
- package/src/divider/Divider.svelte +0 -154
- package/src/divider/index.ts +0 -2
- package/src/divider/meta.ts +0 -23
- package/src/drawer/Drawer.a11y.test.ts +0 -41
- package/src/drawer/Drawer.kbd.test.ts +0 -67
- package/src/drawer/Drawer.svelte +0 -554
- package/src/drawer/DrawerKbdFixture.svelte +0 -28
- package/src/drawer/index.ts +0 -2
- package/src/drawer/meta.ts +0 -127
- package/src/dropdown/Dropdown.a11y.test.ts +0 -46
- package/src/dropdown/Dropdown.kbd.test.ts +0 -56
- package/src/dropdown/Dropdown.svelte +0 -573
- package/src/dropdown/DropdownA11yFixture.svelte +0 -24
- package/src/dropdown/DropdownDivider.svelte +0 -17
- package/src/dropdown/DropdownItem.svelte +0 -127
- package/src/dropdown/DropdownItemNode.svelte +0 -355
- package/src/dropdown/DropdownKbdFixture.svelte +0 -26
- package/src/dropdown/DropdownMenu.svelte +0 -24
- package/src/dropdown/DropdownSubMenu.svelte +0 -212
- package/src/dropdown/DropdownTitle.svelte +0 -34
- package/src/dropdown/context.ts +0 -13
- package/src/dropdown/index.ts +0 -36
- package/src/dropdown/meta.ts +0 -97
- package/src/dropdown/types.test.ts +0 -50
- package/src/dropdown/types.ts +0 -67
- package/src/empty/Empty.a11y.test.ts +0 -24
- package/src/empty/Empty.svelte +0 -304
- package/src/empty/index.ts +0 -2
- package/src/empty/meta.ts +0 -41
- package/src/form/Field.svelte +0 -492
- package/src/form/FieldArray.svelte +0 -75
- package/src/form/Form.a11y.test.ts +0 -39
- package/src/form/Form.svelte +0 -243
- package/src/form/FormA11yFixture.svelte +0 -31
- package/src/form/FormCascader.svelte +0 -82
- package/src/form/FormCheckbox.svelte +0 -83
- package/src/form/FormDatePicker.svelte +0 -80
- package/src/form/FormErrorMessage.svelte +0 -44
- package/src/form/FormInput.svelte +0 -95
- package/src/form/FormLabel.svelte +0 -46
- package/src/form/FormRadio.svelte +0 -83
- package/src/form/FormRating.svelte +0 -85
- package/src/form/FormSection.svelte +0 -45
- package/src/form/FormSelect.svelte +0 -96
- package/src/form/FormSlider.svelte +0 -95
- package/src/form/FormSlot.svelte +0 -51
- package/src/form/FormSwitch.svelte +0 -82
- package/src/form/FormTagInput.svelte +0 -79
- package/src/form/FormTreeSelect.svelte +0 -85
- package/src/form/FormUpload.svelte +0 -92
- package/src/form/context.ts +0 -47
- package/src/form/index.ts +0 -22
- package/src/form/meta.ts +0 -85
- package/src/grid/Col.svelte +0 -142
- package/src/grid/Grid.a11y.test.ts +0 -14
- package/src/grid/GridA11yFixture.svelte +0 -12
- package/src/grid/Row.svelte +0 -116
- package/src/grid/index.ts +0 -3
- package/src/grid/meta.ts +0 -72
- package/src/grid/use-breakpoint.svelte.ts +0 -48
- package/src/highlight/Highlight.a11y.test.ts +0 -25
- package/src/highlight/Highlight.svelte +0 -99
- package/src/highlight/index.ts +0 -2
- package/src/highlight/meta.ts +0 -80
- package/src/icon/Icon.svelte +0 -156
- package/src/icon/index.ts +0 -2
- package/src/icon/meta.ts +0 -41
- package/src/image/Image.a11y.test.ts +0 -30
- package/src/image/Image.svelte +0 -387
- package/src/image/ImagePreview.kbd.test.ts +0 -52
- package/src/image/ImagePreview.svelte +0 -309
- package/src/image/ImagePreviewGroup.svelte +0 -93
- package/src/image/ImagePreviewKbdFixture.svelte +0 -32
- package/src/image/context.ts +0 -26
- package/src/image/index.ts +0 -15
- package/src/image/meta.ts +0 -131
- package/src/index.ts +0 -208
- package/src/input/Input.a11y.test.ts +0 -58
- package/src/input/Input.svelte +0 -505
- package/src/input/index.ts +0 -2
- package/src/input/meta.ts +0 -40
- package/src/input-number/InputNumber.a11y.test.ts +0 -43
- package/src/input-number/InputNumber.kbd.test.ts +0 -41
- package/src/input-number/InputNumber.svelte +0 -674
- package/src/input-number/InputNumberKbdFixture.svelte +0 -15
- package/src/input-number/index.ts +0 -2
- package/src/input-number/meta.ts +0 -65
- package/src/layout/Content.svelte +0 -37
- package/src/layout/Footer.svelte +0 -49
- package/src/layout/Header.svelte +0 -46
- package/src/layout/Layout.a11y.test.ts +0 -34
- package/src/layout/Layout.svelte +0 -60
- package/src/layout/LayoutA11yFixture.svelte +0 -21
- package/src/layout/Sider.svelte +0 -207
- package/src/layout/index.ts +0 -26
- package/src/layout/meta.ts +0 -116
- package/src/list/List.a11y.test.ts +0 -69
- package/src/list/List.bench.ts +0 -26
- package/src/list/List.kbd.test.ts +0 -71
- package/src/list/List.svelte +0 -920
- package/src/list/ListA11yFixture.svelte +0 -38
- package/src/list/ListBenchFixture.svelte +0 -22
- package/src/list/ListItem.svelte +0 -175
- package/src/list/ListKbdFixture.svelte +0 -31
- package/src/list/ListMeta.svelte +0 -73
- package/src/list/context.ts +0 -39
- package/src/list/index.ts +0 -21
- package/src/list/meta.ts +0 -99
- package/src/locale-provider/LocaleProvider.svelte +0 -110
- package/src/locale-provider/context.ts +0 -22
- package/src/locale-provider/index.ts +0 -21
- package/src/locale-provider/meta.ts +0 -93
- package/src/locale-provider/use-locale.ts +0 -25
- package/src/lottie-icon/LottieIcon.svelte +0 -330
- package/src/lottie-icon/index.ts +0 -9
- package/src/lottie-icon/meta.ts +0 -162
- package/src/menu/Menu.a11y.test.ts +0 -54
- package/src/menu/Menu.kbd.test.ts +0 -69
- package/src/menu/Menu.svelte +0 -762
- package/src/menu/MenuKbdFixture.svelte +0 -22
- package/src/menu/MenuPopupNode.svelte +0 -525
- package/src/menu/index.ts +0 -4
- package/src/menu/meta.ts +0 -137
- package/src/menu/types.ts +0 -120
- package/src/meta.test.ts +0 -173
- package/src/modal/ConfirmModal.svelte +0 -173
- package/src/modal/Modal.a11y.test.ts +0 -46
- package/src/modal/Modal.kbd.test.ts +0 -65
- package/src/modal/Modal.svelte +0 -511
- package/src/modal/ModalKbdFixture.svelte +0 -24
- package/src/modal/command.svelte.ts +0 -103
- package/src/modal/index.ts +0 -30
- package/src/modal/meta.ts +0 -165
- package/src/modal/z-stack.ts +0 -26
- package/src/notification/NotificationContainer.svelte +0 -192
- package/src/notification/NotificationItem.a11y.test.ts +0 -73
- package/src/notification/NotificationItem.svelte +0 -368
- package/src/notification/index.ts +0 -9
- package/src/notification/meta.ts +0 -120
- package/src/notification/store.ts +0 -191
- package/src/overflow-list/OverflowList.a11y.test.ts +0 -46
- package/src/overflow-list/OverflowList.kbd.test.ts +0 -34
- package/src/overflow-list/OverflowList.svelte +0 -539
- package/src/overflow-list/OverflowListA11yFixture.svelte +0 -22
- package/src/overflow-list/OverflowListKbdFixture.svelte +0 -21
- package/src/overflow-list/index.ts +0 -2
- package/src/overflow-list/meta.ts +0 -138
- package/src/pagination/Pagination.a11y.test.ts +0 -62
- package/src/pagination/Pagination.kbd.test.ts +0 -66
- package/src/pagination/Pagination.svelte +0 -428
- package/src/pagination/PaginationKbdFixture.svelte +0 -15
- package/src/pagination/index.ts +0 -2
- package/src/pagination/meta.ts +0 -73
- package/src/popconfirm/Popconfirm.a11y.test.ts +0 -46
- package/src/popconfirm/Popconfirm.kbd.test.ts +0 -42
- package/src/popconfirm/Popconfirm.svelte +0 -724
- package/src/popconfirm/PopconfirmA11yFixture.svelte +0 -34
- package/src/popconfirm/PopconfirmKbdFixture.svelte +0 -17
- package/src/popconfirm/index.ts +0 -2
- package/src/popconfirm/meta.ts +0 -200
- package/src/popover/Popover.a11y.test.ts +0 -58
- package/src/popover/Popover.kbd.test.ts +0 -42
- package/src/popover/Popover.svelte +0 -643
- package/src/popover/PopoverA11yFixture.svelte +0 -35
- package/src/popover/PopoverKbdFixture.svelte +0 -18
- package/src/popover/index.ts +0 -2
- package/src/popover/meta.ts +0 -103
- package/src/progress/Progress.a11y.test.ts +0 -37
- package/src/progress/Progress.svelte +0 -423
- package/src/progress/index.ts +0 -3
- package/src/progress/meta.ts +0 -132
- package/src/radio/Radio.svelte +0 -330
- package/src/radio/RadioGroup.a11y.test.ts +0 -43
- package/src/radio/RadioGroup.kbd.test.ts +0 -75
- package/src/radio/RadioGroup.svelte +0 -199
- package/src/radio/RadioGroupKbdFixture.svelte +0 -21
- package/src/radio/context.ts +0 -42
- package/src/radio/index.ts +0 -4
- package/src/radio/meta.ts +0 -68
- package/src/rating/Rating.a11y.test.ts +0 -41
- package/src/rating/Rating.kbd.test.ts +0 -48
- package/src/rating/Rating.svelte +0 -407
- package/src/rating/RatingKbdFixture.svelte +0 -15
- package/src/rating/index.ts +0 -2
- package/src/rating/meta.ts +0 -40
- package/src/resize-observer/ResizeObserver.svelte +0 -169
- package/src/resize-observer/action.ts +0 -80
- package/src/resize-observer/index.ts +0 -9
- package/src/resize-observer/meta.ts +0 -102
- package/src/scroll-list/ScrollColumn.svelte +0 -592
- package/src/scroll-list/ScrollList.svelte +0 -257
- package/src/scroll-list/index.ts +0 -4
- package/src/scroll-list/meta.ts +0 -93
- package/src/scroll-list/types.ts +0 -18
- package/src/select/Select.a11y.test.ts +0 -59
- package/src/select/Select.kbd.test.ts +0 -59
- package/src/select/Select.svelte +0 -1155
- package/src/select/SelectKbdFixture.svelte +0 -29
- package/src/select/index.ts +0 -3
- package/src/select/meta.ts +0 -78
- package/src/select/types.ts +0 -2
- package/src/side-sheet/SideSheet.a11y.test.ts +0 -53
- package/src/side-sheet/SideSheet.kbd.test.ts +0 -63
- package/src/side-sheet/SideSheet.svelte +0 -659
- package/src/side-sheet/SideSheetKbdFixture.svelte +0 -30
- package/src/side-sheet/index.ts +0 -2
- package/src/side-sheet/meta.ts +0 -116
- package/src/skeleton/Skeleton.a11y.test.ts +0 -35
- package/src/skeleton/Skeleton.svelte +0 -131
- package/src/skeleton/SkeletonAvatar.svelte +0 -82
- package/src/skeleton/SkeletonButton.svelte +0 -90
- package/src/skeleton/SkeletonImage.svelte +0 -100
- package/src/skeleton/SkeletonParagraph.svelte +0 -103
- package/src/skeleton/SkeletonTitle.svelte +0 -74
- package/src/skeleton/context.ts +0 -11
- package/src/skeleton/index.ts +0 -8
- package/src/skeleton/meta.ts +0 -65
- package/src/slider/Slider.a11y.test.ts +0 -44
- package/src/slider/Slider.kbd.test.ts +0 -74
- package/src/slider/Slider.svelte +0 -716
- package/src/slider/SliderKbdFixture.svelte +0 -21
- package/src/slider/index.ts +0 -2
- package/src/slider/meta.ts +0 -55
- package/src/space/Space.a11y.test.ts +0 -22
- package/src/space/Space.svelte +0 -109
- package/src/space/SpaceA11yFixture.svelte +0 -17
- package/src/space/index.ts +0 -2
- package/src/space/meta.ts +0 -27
- package/src/spin/Spin.a11y.test.ts +0 -29
- package/src/spin/Spin.svelte +0 -293
- package/src/spin/SpinA11yFixture.svelte +0 -18
- package/src/spin/index.ts +0 -2
- package/src/spin/meta.ts +0 -72
- package/src/steps/Steps.a11y.test.ts +0 -39
- package/src/steps/Steps.kbd.test.ts +0 -73
- package/src/steps/Steps.svelte +0 -392
- package/src/steps/StepsKbdFixture.svelte +0 -21
- package/src/steps/index.ts +0 -3
- package/src/steps/meta.ts +0 -59
- package/src/steps/types.ts +0 -8
- package/src/switch/Switch.a11y.test.ts +0 -46
- package/src/switch/Switch.kbd.test.ts +0 -40
- package/src/switch/Switch.svelte +0 -310
- package/src/switch/SwitchKbdFixture.svelte +0 -22
- package/src/switch/index.ts +0 -2
- package/src/switch/meta.ts +0 -44
- package/src/table/Table.a11y.test.ts +0 -70
- package/src/table/Table.bench.ts +0 -51
- package/src/table/Table.kbd.test.ts +0 -94
- package/src/table/Table.svelte +0 -2327
- package/src/table/TableKbdFixture.svelte +0 -35
- package/src/table/grid-nav.test.ts +0 -173
- package/src/table/grid-nav.ts +0 -146
- package/src/table/index.ts +0 -13
- package/src/table/meta.ts +0 -121
- package/src/table/types.ts +0 -133
- package/src/tabs/TabPane.svelte +0 -92
- package/src/tabs/Tabs.a11y.test.ts +0 -47
- package/src/tabs/Tabs.kbd.test.ts +0 -74
- package/src/tabs/Tabs.svelte +0 -1128
- package/src/tabs/TabsA11yFixture.svelte +0 -20
- package/src/tabs/TabsKbdFixture.svelte +0 -25
- package/src/tabs/context.ts +0 -43
- package/src/tabs/index.ts +0 -14
- package/src/tabs/meta.ts +0 -152
- package/src/tabs/types.ts +0 -6
- package/src/tag/Tag.a11y.test.ts +0 -33
- package/src/tag/Tag.svelte +0 -366
- package/src/tag/TagA11yFixture.svelte +0 -18
- package/src/tag/index.ts +0 -2
- package/src/tag/meta.ts +0 -92
- package/src/tag-input/TagInput.a11y.test.ts +0 -41
- package/src/tag-input/TagInput.svelte +0 -544
- package/src/tag-input/index.ts +0 -2
- package/src/tag-input/meta.ts +0 -43
- package/src/tag-input/reorder.test.ts +0 -59
- package/src/tag-input/reorder.ts +0 -41
- package/src/test-utils/LocaleHarness.svelte +0 -29
- package/src/test-utils/a11y.ts +0 -108
- package/src/test-utils/kbd.ts +0 -52
- package/src/textarea/TextArea.a11y.test.ts +0 -44
- package/src/textarea/TextArea.svelte +0 -420
- package/src/textarea/index.ts +0 -2
- package/src/textarea/meta.ts +0 -104
- package/src/time-picker/TimePicker.a11y.test.ts +0 -45
- package/src/time-picker/TimePicker.kbd.test.ts +0 -70
- package/src/time-picker/TimePicker.svelte +0 -1023
- package/src/time-picker/TimePickerKbdFixture.svelte +0 -23
- package/src/time-picker/index.ts +0 -2
- package/src/time-picker/meta.ts +0 -64
- package/src/timeline/Timeline.a11y.test.ts +0 -54
- package/src/timeline/Timeline.svelte +0 -599
- package/src/timeline/TimelineItem.svelte +0 -164
- package/src/timeline/context.ts +0 -28
- package/src/timeline/index.ts +0 -16
- package/src/timeline/meta.ts +0 -129
- package/src/timeline/types.ts +0 -9
- package/src/toast/Toast.a11y.test.ts +0 -67
- package/src/toast/ToastContainer.svelte +0 -184
- package/src/toast/ToastItem.svelte +0 -247
- package/src/toast/index.ts +0 -9
- package/src/toast/live-region.ts +0 -78
- package/src/toast/meta.ts +0 -95
- package/src/toast/store.ts +0 -187
- package/src/tooltip/Tooltip.a11y.test.ts +0 -41
- package/src/tooltip/Tooltip.kbd.test.ts +0 -37
- package/src/tooltip/Tooltip.svelte +0 -416
- package/src/tooltip/TooltipA11yFixture.svelte +0 -31
- package/src/tooltip/TooltipKbdFixture.svelte +0 -16
- package/src/tooltip/index.ts +0 -2
- package/src/tooltip/meta.ts +0 -59
- package/src/tooltip/placement.ts +0 -6
- package/src/transfer/Transfer.a11y.test.ts +0 -63
- package/src/transfer/Transfer.kbd.test.ts +0 -75
- package/src/transfer/Transfer.svelte +0 -1451
- package/src/transfer/TransferKbdFixture.svelte +0 -23
- package/src/transfer/group.test.ts +0 -55
- package/src/transfer/group.ts +0 -61
- package/src/transfer/index.ts +0 -3
- package/src/transfer/meta.ts +0 -55
- package/src/transfer/reorder.test.ts +0 -52
- package/src/transfer/reorder.ts +0 -42
- package/src/transfer/tree.test.ts +0 -44
- package/src/transfer/tree.ts +0 -52
- package/src/transfer/types.ts +0 -32
- package/src/tree/Tree.a11y.test.ts +0 -63
- package/src/tree/Tree.kbd.test.ts +0 -91
- package/src/tree/Tree.svelte +0 -1500
- package/src/tree/TreeKbdFixture.svelte +0 -30
- package/src/tree/index.ts +0 -3
- package/src/tree/meta.ts +0 -152
- package/src/tree-select/TreeSelect.a11y.test.ts +0 -52
- package/src/tree-select/TreeSelect.kbd.test.ts +0 -53
- package/src/tree-select/TreeSelect.svelte +0 -1611
- package/src/tree-select/TreeSelectKbdFixture.svelte +0 -20
- package/src/tree-select/index.ts +0 -3
- package/src/tree-select/meta.ts +0 -73
- package/src/tree-select/types.ts +0 -11
- package/src/tree-select/virtual.test.ts +0 -104
- package/src/typography/Link.svelte +0 -120
- package/src/typography/Paragraph.svelte +0 -92
- package/src/typography/Text.svelte +0 -93
- package/src/typography/Title.svelte +0 -91
- package/src/typography/Typography.a11y.test.ts +0 -34
- package/src/typography/TypographyA11yFixture.svelte +0 -27
- package/src/typography/TypographyBase.svelte +0 -807
- package/src/typography/index.ts +0 -16
- package/src/typography/meta.ts +0 -158
- package/src/upload/Upload.a11y.test.ts +0 -58
- package/src/upload/Upload.svelte +0 -1094
- package/src/upload/UploadA11yFixture.svelte +0 -23
- package/src/upload/index.ts +0 -3
- package/src/upload/meta.ts +0 -64
- package/src/upload/types.ts +0 -16
- package/src/virtual-list/VirtualList.svelte +0 -401
- package/src/virtual-list/index.ts +0 -2
- package/src/virtual-list/meta.ts +0 -106
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
ToastItem — 单条轻提示卡片(纯视觉)。
|
|
3
|
-
类型图标 + 内容 + 可选关闭按钮;pauseOnHover 经 mouseenter/leave + focusin/out 暂停/恢复定时器。
|
|
4
|
-
a11y:卡片 role=presentation + aria-live=off(不充当 live region);所有文案播报统一走单例
|
|
5
|
-
live region(见 live-region.ts),由 store.ts 在新增/更新 toast 时命令式写入,避免每条卡片
|
|
6
|
-
各自 region 造成的重复/竞争播报。error -> assertive,其余 -> polite。
|
|
7
|
-
关闭按钮 button + aria-label「关闭」,不抢焦点、不锁滚动。
|
|
8
|
-
loading 用 CSS infinite rotate spinner(旋转 animation 非显隐 from 帧问题,安全)。
|
|
9
|
-
-->
|
|
10
|
-
<script lang="ts">
|
|
11
|
-
import type { ToastItem, ToastType } from '@chenzy-design/core';
|
|
12
|
-
import { useLocale } from '../locale-provider/index.js';
|
|
13
|
-
|
|
14
|
-
interface Props {
|
|
15
|
-
toast: ToastItem;
|
|
16
|
-
onClose: (id: string) => void;
|
|
17
|
-
onPause: (id: string) => void;
|
|
18
|
-
onResume: (id: string) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let { toast, onClose, onPause, onResume }: Props = $props();
|
|
22
|
-
const loc = useLocale();
|
|
23
|
-
|
|
24
|
-
function handlePause() {
|
|
25
|
-
if (toast.pauseOnHover) onPause(toast.id);
|
|
26
|
-
}
|
|
27
|
-
function handleResume() {
|
|
28
|
-
if (toast.pauseOnHover) onResume(toast.id);
|
|
29
|
-
}
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
{#snippet typeIcon(type: ToastType)}
|
|
33
|
-
{#if type === 'success'}
|
|
34
|
-
<svg class="cd-toast-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
35
|
-
<circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.4" />
|
|
36
|
-
<path
|
|
37
|
-
fill="none"
|
|
38
|
-
stroke="currentColor"
|
|
39
|
-
stroke-width="1.6"
|
|
40
|
-
stroke-linecap="round"
|
|
41
|
-
stroke-linejoin="round"
|
|
42
|
-
d="M5 8.2l2 2 4-4.4"
|
|
43
|
-
/>
|
|
44
|
-
</svg>
|
|
45
|
-
{:else if type === 'warning'}
|
|
46
|
-
<svg class="cd-toast-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
47
|
-
<path
|
|
48
|
-
fill="none"
|
|
49
|
-
stroke="currentColor"
|
|
50
|
-
stroke-width="1.4"
|
|
51
|
-
stroke-linejoin="round"
|
|
52
|
-
d="M8 1.5l6.5 12h-13z"
|
|
53
|
-
/>
|
|
54
|
-
<path stroke="currentColor" stroke-width="1.4" stroke-linecap="round" d="M8 6.5v3.2" />
|
|
55
|
-
<circle cx="8" cy="11.6" r="0.85" fill="currentColor" />
|
|
56
|
-
</svg>
|
|
57
|
-
{:else if type === 'error'}
|
|
58
|
-
<svg class="cd-toast-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
59
|
-
<circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.4" />
|
|
60
|
-
<path
|
|
61
|
-
stroke="currentColor"
|
|
62
|
-
stroke-width="1.6"
|
|
63
|
-
stroke-linecap="round"
|
|
64
|
-
d="M5.5 5.5l5 5M10.5 5.5l-5 5"
|
|
65
|
-
/>
|
|
66
|
-
</svg>
|
|
67
|
-
{:else if type === 'loading'}
|
|
68
|
-
<svg
|
|
69
|
-
class="cd-toast-item__icon-svg cd-toast-item__spinner"
|
|
70
|
-
viewBox="0 0 16 16"
|
|
71
|
-
aria-hidden="true"
|
|
72
|
-
focusable="false"
|
|
73
|
-
>
|
|
74
|
-
<circle cx="8" cy="8" r="6.4" fill="none" stroke="currentColor" stroke-width="1.6" opacity="0.25" />
|
|
75
|
-
<path
|
|
76
|
-
fill="none"
|
|
77
|
-
stroke="currentColor"
|
|
78
|
-
stroke-width="1.6"
|
|
79
|
-
stroke-linecap="round"
|
|
80
|
-
d="M8 1.6a6.4 6.4 0 0 1 6.4 6.4"
|
|
81
|
-
/>
|
|
82
|
-
</svg>
|
|
83
|
-
{:else}
|
|
84
|
-
<svg class="cd-toast-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
85
|
-
<circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.4" />
|
|
86
|
-
<path stroke="currentColor" stroke-width="1.4" stroke-linecap="round" d="M8 7.2v4" />
|
|
87
|
-
<circle cx="8" cy="4.7" r="0.85" fill="currentColor" />
|
|
88
|
-
</svg>
|
|
89
|
-
{/if}
|
|
90
|
-
{/snippet}
|
|
91
|
-
|
|
92
|
-
<div
|
|
93
|
-
class={['cd-toast-item', `cd-toast-item--${toast.type}`, `cd-toast-item--${toast.theme}`, toast.theme === 'light' && 'cd-toast-item--light']}
|
|
94
|
-
style={toast.textMaxWidth !== 450 ? `max-inline-size: ${typeof toast.textMaxWidth === 'number' ? `${toast.textMaxWidth}px` : toast.textMaxWidth}` : undefined}
|
|
95
|
-
role="presentation"
|
|
96
|
-
aria-live="off"
|
|
97
|
-
onmouseenter={handlePause}
|
|
98
|
-
onmouseleave={handleResume}
|
|
99
|
-
onfocusin={handlePause}
|
|
100
|
-
onfocusout={handleResume}
|
|
101
|
-
>
|
|
102
|
-
{#if toast.icon !== false}
|
|
103
|
-
<span class="cd-toast-item__icon">
|
|
104
|
-
{#if toast.icon && toast.icon !== true}
|
|
105
|
-
{@render toast.icon()}
|
|
106
|
-
{:else}
|
|
107
|
-
{@render typeIcon(toast.type)}
|
|
108
|
-
{/if}
|
|
109
|
-
</span>
|
|
110
|
-
{/if}
|
|
111
|
-
<span class="cd-toast-item__content">{toast.content}</span>
|
|
112
|
-
{#if toast.showClose}
|
|
113
|
-
<button
|
|
114
|
-
type="button"
|
|
115
|
-
class="cd-toast-item__close"
|
|
116
|
-
aria-label={loc().t('Toast.close')}
|
|
117
|
-
onclick={() => onClose(toast.id)}
|
|
118
|
-
>
|
|
119
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
120
|
-
<path
|
|
121
|
-
stroke="currentColor"
|
|
122
|
-
stroke-width="1.4"
|
|
123
|
-
stroke-linecap="round"
|
|
124
|
-
d="M4 4l8 8M12 4l-8 8"
|
|
125
|
-
/>
|
|
126
|
-
</svg>
|
|
127
|
-
</button>
|
|
128
|
-
{/if}
|
|
129
|
-
</div>
|
|
130
|
-
|
|
131
|
-
<style>
|
|
132
|
-
.cd-toast-item {
|
|
133
|
-
display: flex;
|
|
134
|
-
gap: var(--cd-toast-gap);
|
|
135
|
-
align-items: center;
|
|
136
|
-
box-sizing: border-box;
|
|
137
|
-
padding: var(--cd-toast-padding);
|
|
138
|
-
max-inline-size: var(--cd-toast-max-width);
|
|
139
|
-
min-inline-size: var(--cd-toast-min-width);
|
|
140
|
-
background: var(--cd-toast-bg);
|
|
141
|
-
color: var(--cd-toast-color-text);
|
|
142
|
-
font-size: var(--cd-toast-font-size);
|
|
143
|
-
line-height: 1.5;
|
|
144
|
-
border-radius: var(--cd-toast-radius);
|
|
145
|
-
box-shadow: var(--cd-toast-shadow);
|
|
146
|
-
pointer-events: auto;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.cd-toast-item__icon {
|
|
150
|
-
display: inline-flex;
|
|
151
|
-
flex: none;
|
|
152
|
-
align-items: center;
|
|
153
|
-
justify-content: center;
|
|
154
|
-
inline-size: 1.125em;
|
|
155
|
-
block-size: 1.125em;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.cd-toast-item__icon-svg {
|
|
159
|
-
inline-size: 100%;
|
|
160
|
-
block-size: 100%;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.cd-toast-item--info .cd-toast-item__icon {
|
|
164
|
-
color: var(--cd-toast-color-icon-info);
|
|
165
|
-
}
|
|
166
|
-
.cd-toast-item--success .cd-toast-item__icon {
|
|
167
|
-
color: var(--cd-toast-color-icon-success);
|
|
168
|
-
}
|
|
169
|
-
.cd-toast-item--warning .cd-toast-item__icon {
|
|
170
|
-
color: var(--cd-toast-color-icon-warning);
|
|
171
|
-
}
|
|
172
|
-
.cd-toast-item--error .cd-toast-item__icon {
|
|
173
|
-
color: var(--cd-toast-color-icon-error);
|
|
174
|
-
}
|
|
175
|
-
.cd-toast-item--loading .cd-toast-item__icon {
|
|
176
|
-
color: var(--cd-toast-color-icon-info);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* dark 主题:深色卡片,文案/关闭色覆盖为 token(对齐 Notification dark theme) */
|
|
180
|
-
.cd-toast-item--dark {
|
|
181
|
-
background: var(--cd-toast-bg-dark);
|
|
182
|
-
color: var(--cd-toast-color-text-dark);
|
|
183
|
-
}
|
|
184
|
-
.cd-toast-item--dark .cd-toast-item__close {
|
|
185
|
-
color: var(--cd-toast-color-close-dark);
|
|
186
|
-
}
|
|
187
|
-
.cd-toast-item--dark .cd-toast-item__close:hover {
|
|
188
|
-
color: var(--cd-toast-color-close-hover-dark);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.cd-toast-item__content {
|
|
192
|
-
flex: 1 1 auto;
|
|
193
|
-
min-inline-size: 0;
|
|
194
|
-
overflow-wrap: anywhere;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.cd-toast-item__close {
|
|
198
|
-
display: inline-flex;
|
|
199
|
-
flex: none;
|
|
200
|
-
align-items: center;
|
|
201
|
-
justify-content: center;
|
|
202
|
-
inline-size: 1.25em;
|
|
203
|
-
block-size: 1.25em;
|
|
204
|
-
padding: 0;
|
|
205
|
-
margin: 0;
|
|
206
|
-
border: none;
|
|
207
|
-
background: transparent;
|
|
208
|
-
color: var(--cd-toast-color-close);
|
|
209
|
-
cursor: pointer;
|
|
210
|
-
border-radius: var(--cd-radius-1);
|
|
211
|
-
transition: color var(--cd-toast-motion-duration) ease;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.cd-toast-item__close:hover {
|
|
215
|
-
color: var(--cd-toast-color-close-hover);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.cd-toast-item__close:focus-visible {
|
|
219
|
-
outline: 2px solid var(--cd-color-primary);
|
|
220
|
-
outline-offset: 1px;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.cd-toast-item__close svg {
|
|
224
|
-
inline-size: 100%;
|
|
225
|
-
block-size: 100%;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.cd-toast-item__spinner {
|
|
229
|
-
transform-origin: center;
|
|
230
|
-
animation: cd-toast-spin 0.8s linear infinite;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
@keyframes cd-toast-spin {
|
|
234
|
-
to {
|
|
235
|
-
transform: rotate(360deg);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
@media (prefers-reduced-motion: reduce) {
|
|
240
|
-
.cd-toast-item__spinner {
|
|
241
|
-
animation-duration: 1.6s;
|
|
242
|
-
}
|
|
243
|
-
.cd-toast-item__close {
|
|
244
|
-
transition: none;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
</style>
|
package/src/toast/index.ts
DELETED
package/src/toast/live-region.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 单例 ARIA live region — 承载所有 toast 文案的屏幕阅读器播报。
|
|
3
|
-
*
|
|
4
|
-
* 视觉上的多个 toast 卡片各自独立,但 a11y 播报统一走这里的两个全局唯一
|
|
5
|
-
* region(polite + assertive),避免每条卡片各自 role/aria-live 导致的重复/竞争。
|
|
6
|
-
*
|
|
7
|
-
* 红线 #3:region DOM 命令式创建/挂载到 body + 写入 + cleanup。模块级单例,
|
|
8
|
-
* 多次 toast 复用同一对节点;__resetLiveRegion 供测试清理。客户端 only(守 document)。
|
|
9
|
-
*
|
|
10
|
-
* 级别策略(参考 WAI-ARIA APG / Semi,对齐 spec §6):error / warning -> assertive
|
|
11
|
-
* (立即打断),info / success / loading -> polite。region 视觉隐藏(sr-only),仅供辅助技术读取。
|
|
12
|
-
*/
|
|
13
|
-
import type { ToastType } from '@chenzy-design/core';
|
|
14
|
-
|
|
15
|
-
interface LiveRegions {
|
|
16
|
-
polite: HTMLElement;
|
|
17
|
-
assertive: HTMLElement;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let regions: LiveRegions | null = null;
|
|
21
|
-
|
|
22
|
-
function makeRegion(politeness: 'polite' | 'assertive'): HTMLElement {
|
|
23
|
-
const el = document.createElement('div');
|
|
24
|
-
// role=status 隐含 polite;role=alert 隐含 assertive。同时显式标注更稳。
|
|
25
|
-
el.setAttribute('role', politeness === 'assertive' ? 'alert' : 'status');
|
|
26
|
-
el.setAttribute('aria-live', politeness);
|
|
27
|
-
el.setAttribute('aria-atomic', 'true');
|
|
28
|
-
el.className = 'cd-toast-live-region';
|
|
29
|
-
// 视觉隐藏但对辅助技术可见(不可用 display:none / visibility:hidden,会被 AT 忽略)。
|
|
30
|
-
const s = el.style;
|
|
31
|
-
s.position = 'absolute';
|
|
32
|
-
s.width = '1px';
|
|
33
|
-
s.height = '1px';
|
|
34
|
-
s.margin = '-1px';
|
|
35
|
-
s.padding = '0';
|
|
36
|
-
s.overflow = 'hidden';
|
|
37
|
-
s.clip = 'rect(0 0 0 0)';
|
|
38
|
-
s.clipPath = 'inset(50%)';
|
|
39
|
-
s.whiteSpace = 'nowrap';
|
|
40
|
-
s.border = '0';
|
|
41
|
-
return el;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function ensureRegions(): LiveRegions | null {
|
|
45
|
-
if (typeof document === 'undefined') return null;
|
|
46
|
-
if (!regions) {
|
|
47
|
-
const polite = makeRegion('polite');
|
|
48
|
-
const assertive = makeRegion('assertive');
|
|
49
|
-
document.body.appendChild(polite);
|
|
50
|
-
document.body.appendChild(assertive);
|
|
51
|
-
regions = { polite, assertive };
|
|
52
|
-
}
|
|
53
|
-
return regions;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 把一条 toast 文案写入对应级别的单例 region 供屏幕阅读器播报。
|
|
58
|
-
* 同文案连续两次也能被重播:先清空再写入(textContent 重新赋值触发 AT 播报)。
|
|
59
|
-
*/
|
|
60
|
-
export function announce(message: string, type: ToastType): void {
|
|
61
|
-
const r = ensureRegions();
|
|
62
|
-
if (!r || !message) return;
|
|
63
|
-
// spec §6:error / warning 立即打断(assertive),其余排队播报(polite)。
|
|
64
|
-
const target = type === 'error' || type === 'warning' ? r.assertive : r.polite;
|
|
65
|
-
// 先清空,确保重复文案也会触发新一次播报。
|
|
66
|
-
target.textContent = '';
|
|
67
|
-
// 同步直接写入即可被 AT 捕获;保持纯命令式、无 effect。
|
|
68
|
-
target.textContent = message;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** 测试 only:移除单例 region 并复位模块状态。 */
|
|
72
|
-
export function __resetLiveRegion(): void {
|
|
73
|
-
if (regions) {
|
|
74
|
-
regions.polite.remove();
|
|
75
|
-
regions.assertive.remove();
|
|
76
|
-
regions = null;
|
|
77
|
-
}
|
|
78
|
-
}
|
package/src/toast/meta.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Machine-readable component metadata for AI/docs consumption.
|
|
3
|
-
* Toast — see specs/components/feedback/Toast.spec.md
|
|
4
|
-
*/
|
|
5
|
-
export const meta = {
|
|
6
|
-
name: 'Toast',
|
|
7
|
-
category: 'feedback',
|
|
8
|
-
description:
|
|
9
|
-
'轻提示:命令式全局反馈 API(Toast.info/success/warning/error/loading/open/promise/close/update/destroyAll)。单例容器惰性挂载到 body;类型预设图标 + 自动消失 + 悬停暂停 + 按方位 maxCount FIFO 淘汰 + 同 id 去重更新;6 方位独立堆叠(topLeft/top/topRight/bottomLeft/bottom/bottomRight,对齐 Notification)多条同方位纵向堆叠不重叠;theme(light/dark) 卡片主题;Toast.promise(promise, { loading, success, error }) 传入 Promise 自动 pending→resolve/reject 切文案(success/error 可为函数接收值,默认文案经 @chenzy-design/locale);a11y 播报走单例 ARIA live region(error->assertive、其余->polite),卡片本身纯视觉无 role/aria-live。',
|
|
10
|
-
exports: ['Toast', 'ToastPromiseMessages'],
|
|
11
|
-
imperative: true,
|
|
12
|
-
props: [
|
|
13
|
-
{ name: 'content', type: 'string', default: '—', desc: '提示文本(必填)' },
|
|
14
|
-
{ name: 'id', type: 'string', default: 'undefined', desc: '指定 id;已存在则原地更新并重启定时器' },
|
|
15
|
-
{
|
|
16
|
-
name: 'type',
|
|
17
|
-
type: "'info'|'success'|'warning'|'error'|'loading'",
|
|
18
|
-
default: "'info'",
|
|
19
|
-
desc: '语义类型,决定图标与色',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'duration',
|
|
23
|
-
type: 'number',
|
|
24
|
-
default: '3',
|
|
25
|
-
desc: '自动消失秒数;0 持久。loading 默认 0',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'position',
|
|
29
|
-
type: "'topLeft'|'top'|'topRight'|'bottomLeft'|'bottom'|'bottomRight'",
|
|
30
|
-
default: "'top'",
|
|
31
|
-
desc: '出现方位,每方位独立纵向堆叠',
|
|
32
|
-
},
|
|
33
|
-
{ name: 'closable', type: 'boolean', default: 'true', desc: '是否显示关闭按钮' },
|
|
34
|
-
{ name: 'pauseOnHover', type: 'boolean', default: 'true', desc: '悬停/聚焦时暂停定时器' },
|
|
35
|
-
{
|
|
36
|
-
name: 'theme',
|
|
37
|
-
type: "'light'|'dark'",
|
|
38
|
-
default: "'light'",
|
|
39
|
-
desc: '卡片主题;dark 为深色卡片',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'onClose',
|
|
43
|
-
type: "(id: string, reason: 'timeout'|'manual'|'replace'|'destroyAll') => void",
|
|
44
|
-
default: 'undefined',
|
|
45
|
-
desc: '关闭回调,附关闭原因',
|
|
46
|
-
},
|
|
47
|
-
{ name: 'icon', type: 'Snippet | false', default: 'undefined', desc: '自定义图标 snippet;false 隐藏图标' },
|
|
48
|
-
{ name: 'showClose', type: 'boolean', default: 'true', desc: '是否显示关闭按钮(closable 别名)' },
|
|
49
|
-
{ name: 'textMaxWidth', type: 'number | string', default: '450', desc: '内容区最大宽度(px 数字或 CSS 字符串)' },
|
|
50
|
-
{ name: 'stack', type: 'boolean', default: 'false', desc: '堆叠显示:容器附加 cd-toast-wrapper--stacked class' },
|
|
51
|
-
],
|
|
52
|
-
events: [{ name: 'onClose', desc: '单条关闭(超时/手动/被替换/清空)时触发,带 id 与 reason' }],
|
|
53
|
-
slots: [],
|
|
54
|
-
a11y: {
|
|
55
|
-
hasRole: true,
|
|
56
|
-
focusable: false,
|
|
57
|
-
note: '所有文案播报走 body 上单例 ARIA live region(全局唯一一对:role=status/aria-live=polite + role=alert/aria-live=assertive);error 走 assertive 立即打断,其余走 polite。store 在新增/更新 toast 时命令式写入 region 文案,卡片本身纯视觉、不带 role/aria-live,避免多 region 重复/竞争播报。关闭按钮 button + aria-label「关闭」。不抢焦点、不锁滚动。',
|
|
58
|
-
},
|
|
59
|
-
tokens: [
|
|
60
|
-
'--cd-toast-bg',
|
|
61
|
-
'--cd-toast-color-text',
|
|
62
|
-
'--cd-toast-color-icon-info',
|
|
63
|
-
'--cd-toast-color-icon-success',
|
|
64
|
-
'--cd-toast-color-icon-warning',
|
|
65
|
-
'--cd-toast-color-icon-error',
|
|
66
|
-
'--cd-toast-color-close',
|
|
67
|
-
'--cd-toast-color-close-hover',
|
|
68
|
-
'--cd-toast-radius',
|
|
69
|
-
'--cd-toast-shadow',
|
|
70
|
-
'--cd-toast-padding',
|
|
71
|
-
'--cd-toast-gap',
|
|
72
|
-
'--cd-toast-font-size',
|
|
73
|
-
'--cd-toast-max-width',
|
|
74
|
-
'--cd-toast-min-width',
|
|
75
|
-
'--cd-toast-stack-gap',
|
|
76
|
-
'--cd-toast-z',
|
|
77
|
-
'--cd-toast-motion-duration',
|
|
78
|
-
'--cd-toast-bg-dark',
|
|
79
|
-
'--cd-toast-color-text-dark',
|
|
80
|
-
'--cd-toast-color-close-dark',
|
|
81
|
-
'--cd-toast-color-close-hover-dark',
|
|
82
|
-
],
|
|
83
|
-
responsive: false,
|
|
84
|
-
examples: [
|
|
85
|
-
{ title: '成功', code: "Toast.success('已保存')" },
|
|
86
|
-
{ title: '错误', code: "Toast.error('保存失败')" },
|
|
87
|
-
{ title: '加载(持久)', code: "Toast.loading('上传中', { duration: 0 })" },
|
|
88
|
-
{ title: '右下角', code: "Toast.info('已同步', { position: 'bottomRight' })" },
|
|
89
|
-
{ title: '深色主题', code: "Toast.success('已保存', { theme: 'dark' })" },
|
|
90
|
-
{
|
|
91
|
-
title: 'promise',
|
|
92
|
-
code: "Toast.promise(save(), { loading: '保存中…', success: '已保存', error: (e) => `失败:${e.message}` })",
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
} as const;
|
package/src/toast/store.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Toast — 命令式全局轻提示入口。
|
|
3
|
-
* 模块级单例 store + 惰性挂载的单例 ToastContainer(首次调用时 mount 到 body)。
|
|
4
|
-
* 复用 @chenzy-design/core 的 createToastStore(无框架依赖的队列 + 定时器)。
|
|
5
|
-
* See specs/components/feedback/Toast.spec.md
|
|
6
|
-
*/
|
|
7
|
-
import {
|
|
8
|
-
createToastStore,
|
|
9
|
-
type ToastStore,
|
|
10
|
-
type ToastOptions,
|
|
11
|
-
type ToastType,
|
|
12
|
-
} from '@chenzy-design/core';
|
|
13
|
-
import { createLocale, en_US, type LocaleApi } from '@chenzy-design/locale';
|
|
14
|
-
import { announce } from './live-region.js';
|
|
15
|
-
|
|
16
|
-
let store: ToastStore | null = null;
|
|
17
|
-
let containerMounted = false;
|
|
18
|
-
|
|
19
|
-
/** Toast.config() 全局配置。 */
|
|
20
|
-
export interface ToastConfig {
|
|
21
|
-
/** 卡片主题(全局默认值)。 */
|
|
22
|
-
theme?: 'light' | 'dark';
|
|
23
|
-
/** 容器层级。 */
|
|
24
|
-
zIndex?: number;
|
|
25
|
-
/** 容器距顶部偏移(px 数字或 CSS 字符串)。 */
|
|
26
|
-
top?: number | string;
|
|
27
|
-
/** 容器距底部偏移(px 数字或 CSS 字符串)。 */
|
|
28
|
-
bottom?: number | string;
|
|
29
|
-
/** 容器距左侧偏移(px 数字或 CSS 字符串)。 */
|
|
30
|
-
left?: number | string;
|
|
31
|
-
/** 容器距右侧偏移(px 数字或 CSS 字符串)。 */
|
|
32
|
-
right?: number | string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let globalConfig: ToastConfig = {};
|
|
36
|
-
|
|
37
|
-
/** 读取当前全局配置(供 ToastContainer 消费)。 */
|
|
38
|
-
export function getToastConfig(): ToastConfig {
|
|
39
|
-
return globalConfig;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// promise 默认文案的回退 locale(与 useLocale 一致用 en_US 构造,模块级单例)。
|
|
43
|
-
// 命令式入口在组件树之外,拿不到 LocaleProvider context,故默认文案走此回退实例;
|
|
44
|
-
// 调用方可经 messages 显式覆盖任一文案。
|
|
45
|
-
let fallbackLocale: LocaleApi | undefined;
|
|
46
|
-
function getFallbackLocale(): LocaleApi {
|
|
47
|
-
if (!fallbackLocale) fallbackLocale = createLocale({ locale: en_US });
|
|
48
|
-
return fallbackLocale;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function ensureStore(): ToastStore {
|
|
52
|
-
if (!store) store = createToastStore({ maxCount: 5, defaultDuration: 3 });
|
|
53
|
-
return store;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 惰性挂载容器:首次调用时动态 import + mount ToastContainer 到 body。
|
|
58
|
-
* mount 是 async(动态 import),但调用方的 s.add 已同步把数据写进 store;
|
|
59
|
-
* 容器在 mount 时立即同步读一次 store.getToasts(),不会丢首条 toast。
|
|
60
|
-
*/
|
|
61
|
-
async function ensureContainer(): Promise<void> {
|
|
62
|
-
if (containerMounted || typeof document === 'undefined') return;
|
|
63
|
-
containerMounted = true;
|
|
64
|
-
const { mount } = await import('svelte');
|
|
65
|
-
const { default: ToastContainer } = await import('./ToastContainer.svelte');
|
|
66
|
-
const host = document.createElement('div');
|
|
67
|
-
host.className = 'cd-toast-host';
|
|
68
|
-
document.body.appendChild(host);
|
|
69
|
-
mount(ToastContainer, { target: host, props: { store: ensureStore() } });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function show(
|
|
73
|
-
type: ToastType,
|
|
74
|
-
content: string,
|
|
75
|
-
opts: Partial<Omit<ToastOptions, 'content'>> = {},
|
|
76
|
-
): string {
|
|
77
|
-
const s = ensureStore();
|
|
78
|
-
void ensureContainer();
|
|
79
|
-
const id = s.add({ content, type, ...opts });
|
|
80
|
-
// a11y:把文案写入单例 live region 供屏幕阅读器播报(卡片本身不再带 role/aria-live)。
|
|
81
|
-
announce(content, type);
|
|
82
|
-
return id;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Toast.promise 文案:可为静态字符串,或接收 resolve 值 / reject 原因的函数(对齐 sonner / AntD)。
|
|
87
|
-
*/
|
|
88
|
-
type PromiseMessage<T> = string | ((value: T) => string);
|
|
89
|
-
|
|
90
|
-
export interface ToastPromiseMessages<T> {
|
|
91
|
-
/** pending 阶段文案;省略走 locale 默认 promiseLoading */
|
|
92
|
-
loading?: string;
|
|
93
|
-
/** resolve 文案;省略走 locale 默认 promiseSuccess */
|
|
94
|
-
success?: PromiseMessage<T>;
|
|
95
|
-
/** reject 文案;省略走 locale 默认 promiseError */
|
|
96
|
-
error?: PromiseMessage<unknown>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** 透传给底层 toast 的额外选项(position/theme/duration 等),content/type 由 promise 阶段接管。 */
|
|
100
|
-
type PromiseToastOptions = Partial<Omit<ToastOptions, 'content' | 'type' | 'id'>>;
|
|
101
|
-
|
|
102
|
-
function resolveMessage<T>(msg: PromiseMessage<T> | undefined, value: T, fallback: string): string {
|
|
103
|
-
if (msg === undefined) return fallback;
|
|
104
|
-
return typeof msg === 'function' ? msg(value) : msg;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export const Toast = {
|
|
108
|
-
info: (content: string, opts?: Partial<Omit<ToastOptions, 'content'>>) =>
|
|
109
|
-
show('info', content, opts),
|
|
110
|
-
success: (content: string, opts?: Partial<Omit<ToastOptions, 'content'>>) =>
|
|
111
|
-
show('success', content, opts),
|
|
112
|
-
warning: (content: string, opts?: Partial<Omit<ToastOptions, 'content'>>) =>
|
|
113
|
-
show('warning', content, opts),
|
|
114
|
-
error: (content: string, opts?: Partial<Omit<ToastOptions, 'content'>>) =>
|
|
115
|
-
show('error', content, opts),
|
|
116
|
-
loading: (content: string, opts?: Partial<Omit<ToastOptions, 'content'>>) =>
|
|
117
|
-
show('loading', content, opts),
|
|
118
|
-
/** 完整选项打开一条 toast,返回其 id。 */
|
|
119
|
-
open: (opts: ToastOptions): string => {
|
|
120
|
-
void ensureContainer();
|
|
121
|
-
const id = ensureStore().add(opts);
|
|
122
|
-
announce(opts.content, opts.type ?? 'info');
|
|
123
|
-
return id;
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* promise API:传入 Promise,pending 显示 loading toast,resolve→success、reject→error 切文案。
|
|
127
|
-
* 返回原 Promise 以便继续链式/await(对齐 sonner / AntD message.promise)。
|
|
128
|
-
*
|
|
129
|
-
* 红线 #3:单条 toast 经同 id update 命令式切换状态(loading→success/error),
|
|
130
|
-
* 计时由底层 store 接管(loading 持久 duration:0,success/error 用默认 3s 自动关闭);
|
|
131
|
-
* .then/.catch 是 Promise 自身的生命周期回调,无需额外手动 cleanup(toast 自身定时器在 store 内 cleanup)。
|
|
132
|
-
* 默认文案经 @chenzy-design/locale(回退 en_US,无 Provider context);调用方可经 messages 覆盖。
|
|
133
|
-
*/
|
|
134
|
-
promise: <T>(
|
|
135
|
-
promise: Promise<T>,
|
|
136
|
-
messages: ToastPromiseMessages<T> = {},
|
|
137
|
-
opts: PromiseToastOptions = {},
|
|
138
|
-
): Promise<T> => {
|
|
139
|
-
const s = ensureStore();
|
|
140
|
-
void ensureContainer();
|
|
141
|
-
const t = getFallbackLocale().t;
|
|
142
|
-
const loadingText = messages.loading ?? t('Toast.promiseLoading');
|
|
143
|
-
// loading 阶段:持久(duration 0),不可关闭,交给 resolve/reject 接管。
|
|
144
|
-
const id = s.add({
|
|
145
|
-
...opts,
|
|
146
|
-
content: loadingText,
|
|
147
|
-
type: 'loading',
|
|
148
|
-
duration: 0,
|
|
149
|
-
closable: opts.closable ?? false,
|
|
150
|
-
});
|
|
151
|
-
announce(loadingText, 'loading');
|
|
152
|
-
|
|
153
|
-
const settle = (type: ToastType, content: string): void => {
|
|
154
|
-
// 同 id update:原地把 loading 切为 success/error 并重启定时器(默认 3s 自动关闭)。
|
|
155
|
-
s.add({ ...opts, id, content, type });
|
|
156
|
-
announce(content, type);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
return promise.then(
|
|
160
|
-
(value) => {
|
|
161
|
-
settle('success', resolveMessage(messages.success, value, t('Toast.promiseSuccess')));
|
|
162
|
-
return value;
|
|
163
|
-
},
|
|
164
|
-
(reason: unknown) => {
|
|
165
|
-
settle('error', resolveMessage(messages.error, reason, t('Toast.promiseError')));
|
|
166
|
-
throw reason;
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
},
|
|
170
|
-
/** 手动关闭指定 toast。 */
|
|
171
|
-
close: (id: string): void => ensureStore().remove(id, 'manual'),
|
|
172
|
-
/** 按同 id 更新一条 toast(store.add 对已存在 id 走原地更新 + 重启定时器)。 */
|
|
173
|
-
update: (id: string, opts: Partial<ToastOptions>): string => {
|
|
174
|
-
void ensureContainer();
|
|
175
|
-
const content = opts.content ?? '';
|
|
176
|
-
const result = ensureStore().add({ ...opts, id, content });
|
|
177
|
-
// 仅在有新文案时播报,避免空字符串无意义地刷新 region。
|
|
178
|
-
if (content) announce(content, opts.type ?? 'info');
|
|
179
|
-
return result;
|
|
180
|
-
},
|
|
181
|
-
/** 清空全部 toast。 */
|
|
182
|
-
destroyAll: (): void => ensureStore().removeAll(),
|
|
183
|
-
/** 设置全局配置(theme/zIndex/top/bottom/left/right 位置偏移)。 */
|
|
184
|
-
config: (cfg: ToastConfig): void => {
|
|
185
|
-
globalConfig = { ...globalConfig, ...cfg };
|
|
186
|
-
},
|
|
187
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Tooltip a11y:浮层 role=tooltip,触发器 aria-describedby 关联浮层(打开时)。
|
|
2
|
-
// 浮层经 use:floating portal 到 document.body —— 参照 Modal.a11y.test.ts 全局查询。
|
|
3
|
-
// jsdom 触发不了真实 hover/focus,故用受控 open + trigger='custom' 强制打开再断言静态 ARIA。
|
|
4
|
-
// 经 TooltipA11yFixture 提供真实触发按钮 children(自带 LocaleProvider,故直接 render)。
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { render } from '@testing-library/svelte';
|
|
7
|
-
import { expectNoAxeViolations } from '../test-utils/a11y.js';
|
|
8
|
-
import Fixture from './TooltipA11yFixture.svelte';
|
|
9
|
-
|
|
10
|
-
describe('Tooltip a11y', () => {
|
|
11
|
-
it('收起:仅触发器可见,无浮层,无 axe violations', async () => {
|
|
12
|
-
const { container } = render(Fixture, { props: { open: false } });
|
|
13
|
-
expect(document.querySelector('[role="tooltip"]')).toBeNull();
|
|
14
|
-
await expectNoAxeViolations(container);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('open=true:浮层 role=tooltip + 触发器 aria-describedby 指向浮层,无 axe violations', async () => {
|
|
18
|
-
render(Fixture, { props: { open: true, content: 'Helpful hint' } });
|
|
19
|
-
|
|
20
|
-
const tip = document.querySelector('[role="tooltip"]') as HTMLElement | null;
|
|
21
|
-
expect(tip).not.toBeNull();
|
|
22
|
-
expect(tip?.textContent).toContain('Helpful hint');
|
|
23
|
-
|
|
24
|
-
const trigger = document.querySelector('.cd-tooltip__trigger') as HTMLElement | null;
|
|
25
|
-
const describedby = trigger?.getAttribute('aria-describedby');
|
|
26
|
-
expect(describedby).toBeTruthy();
|
|
27
|
-
expect(describedby).toBe(tip?.id);
|
|
28
|
-
|
|
29
|
-
await expectNoAxeViolations(document.body);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('status=error:语义图标有 role=img + 可访问名(locale),无 axe violations', async () => {
|
|
33
|
-
render(Fixture, { props: { open: true, content: 'Invalid', status: 'error' } });
|
|
34
|
-
|
|
35
|
-
const statusIcon = document.querySelector('.cd-tooltip__status') as HTMLElement | null;
|
|
36
|
-
expect(statusIcon?.getAttribute('role')).toBe('img');
|
|
37
|
-
expect(statusIcon?.getAttribute('aria-label')).toBeTruthy();
|
|
38
|
-
|
|
39
|
-
await expectNoAxeViolations(document.body);
|
|
40
|
-
});
|
|
41
|
-
});
|