@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.
Files changed (476) hide show
  1. package/dist/components.json +1 -1
  2. package/package.json +7 -8
  3. package/src/_floating/use-floating.ts +0 -208
  4. package/src/anchor/Anchor.a11y.test.ts +0 -49
  5. package/src/anchor/Anchor.kbd.test.ts +0 -70
  6. package/src/anchor/Anchor.svelte +0 -359
  7. package/src/anchor/AnchorKbdFixture.svelte +0 -24
  8. package/src/anchor/index.ts +0 -3
  9. package/src/anchor/meta.ts +0 -70
  10. package/src/anchor/types.ts +0 -8
  11. package/src/autocomplete/AutoComplete.a11y.test.ts +0 -49
  12. package/src/autocomplete/AutoComplete.kbd.test.ts +0 -69
  13. package/src/autocomplete/AutoComplete.svelte +0 -706
  14. package/src/autocomplete/AutoCompleteKbdFixture.svelte +0 -24
  15. package/src/autocomplete/index.ts +0 -2
  16. package/src/autocomplete/meta.ts +0 -41
  17. package/src/avatar/Avatar.a11y.test.ts +0 -37
  18. package/src/avatar/Avatar.svelte +0 -315
  19. package/src/avatar/AvatarGroup.svelte +0 -142
  20. package/src/avatar/context.ts +0 -21
  21. package/src/avatar/index.ts +0 -10
  22. package/src/avatar/meta.ts +0 -73
  23. package/src/back-top/BackTop.a11y.test.ts +0 -40
  24. package/src/back-top/BackTop.svelte +0 -314
  25. package/src/back-top/index.ts +0 -2
  26. package/src/back-top/meta.ts +0 -108
  27. package/src/badge/Badge.a11y.test.ts +0 -35
  28. package/src/badge/Badge.svelte +0 -328
  29. package/src/badge/BadgeA11yFixture.svelte +0 -18
  30. package/src/badge/index.ts +0 -2
  31. package/src/badge/meta.ts +0 -62
  32. package/src/banner/Banner.a11y.test.ts +0 -48
  33. package/src/banner/Banner.svelte +0 -368
  34. package/src/banner/index.ts +0 -3
  35. package/src/banner/meta.ts +0 -121
  36. package/src/breadcrumb/Breadcrumb.a11y.test.ts +0 -35
  37. package/src/breadcrumb/Breadcrumb.kbd.test.ts +0 -45
  38. package/src/breadcrumb/Breadcrumb.svelte +0 -414
  39. package/src/breadcrumb/BreadcrumbKbdFixture.svelte +0 -23
  40. package/src/breadcrumb/Item.svelte +0 -77
  41. package/src/breadcrumb/context.ts +0 -27
  42. package/src/breadcrumb/index.ts +0 -21
  43. package/src/breadcrumb/meta.ts +0 -128
  44. package/src/breadcrumb/types.ts +0 -4
  45. package/src/button/Button.a11y.test.ts +0 -54
  46. package/src/button/Button.svelte +0 -176
  47. package/src/button/index.ts +0 -2
  48. package/src/button/meta.ts +0 -28
  49. package/src/calendar/Calendar.a11y.test.ts +0 -51
  50. package/src/calendar/Calendar.kbd.test.ts +0 -59
  51. package/src/calendar/Calendar.svelte +0 -1344
  52. package/src/calendar/CalendarKbdFixture.svelte +0 -23
  53. package/src/calendar/index.ts +0 -3
  54. package/src/calendar/meta.ts +0 -117
  55. package/src/card/Card.a11y.test.ts +0 -38
  56. package/src/card/Card.svelte +0 -341
  57. package/src/card/CardMeta.svelte +0 -60
  58. package/src/card/index.ts +0 -8
  59. package/src/card/meta.ts +0 -83
  60. package/src/carousel/Carousel.a11y.test.ts +0 -53
  61. package/src/carousel/Carousel.kbd.test.ts +0 -67
  62. package/src/carousel/Carousel.svelte +0 -806
  63. package/src/carousel/CarouselA11yFixture.svelte +0 -25
  64. package/src/carousel/CarouselKbdFixture.svelte +0 -24
  65. package/src/carousel/index.ts +0 -2
  66. package/src/carousel/meta.ts +0 -74
  67. package/src/cascader/Cascader.a11y.test.ts +0 -59
  68. package/src/cascader/Cascader.kbd.test.ts +0 -56
  69. package/src/cascader/Cascader.svelte +0 -1570
  70. package/src/cascader/CascaderKbdFixture.svelte +0 -31
  71. package/src/cascader/index.ts +0 -3
  72. package/src/cascader/meta.ts +0 -57
  73. package/src/cascader/types.ts +0 -9
  74. package/src/checkbox/Checkbox.svelte +0 -281
  75. package/src/checkbox/CheckboxGroup.a11y.test.ts +0 -43
  76. package/src/checkbox/CheckboxGroup.kbd.test.ts +0 -40
  77. package/src/checkbox/CheckboxGroup.svelte +0 -122
  78. package/src/checkbox/CheckboxGroupKbdFixture.svelte +0 -20
  79. package/src/checkbox/context.ts +0 -31
  80. package/src/checkbox/index.ts +0 -4
  81. package/src/checkbox/meta.ts +0 -67
  82. package/src/collapse/Collapse.a11y.test.ts +0 -53
  83. package/src/collapse/Collapse.kbd.test.ts +0 -89
  84. package/src/collapse/Collapse.svelte +0 -406
  85. package/src/collapse/CollapseA11yFixture.svelte +0 -27
  86. package/src/collapse/CollapseKbdFixture.svelte +0 -25
  87. package/src/collapse/CollapsePanel.svelte +0 -102
  88. package/src/collapse/context.ts +0 -54
  89. package/src/collapse/index.ts +0 -17
  90. package/src/collapse/meta.ts +0 -79
  91. package/src/collapse/types.ts +0 -5
  92. package/src/color-picker/ColorPicker.a11y.test.ts +0 -60
  93. package/src/color-picker/ColorPicker.kbd.test.ts +0 -73
  94. package/src/color-picker/ColorPicker.svelte +0 -985
  95. package/src/color-picker/ColorPickerKbdFixture.svelte +0 -25
  96. package/src/color-picker/index.ts +0 -2
  97. package/src/color-picker/meta.ts +0 -47
  98. package/src/config-provider/ConfigProvider.svelte +0 -227
  99. package/src/config-provider/context.ts +0 -29
  100. package/src/config-provider/index.ts +0 -48
  101. package/src/config-provider/meta.ts +0 -128
  102. package/src/date-picker/DatePicker.a11y.test.ts +0 -45
  103. package/src/date-picker/DatePicker.kbd.test.ts +0 -71
  104. package/src/date-picker/DatePicker.svelte +0 -1798
  105. package/src/date-picker/DatePickerKbdFixture.svelte +0 -26
  106. package/src/date-picker/RangePicker.kbd.test.ts +0 -69
  107. package/src/date-picker/RangePicker.svelte +0 -775
  108. package/src/date-picker/RangePickerKbdFixture.svelte +0 -30
  109. package/src/date-picker/index.ts +0 -4
  110. package/src/date-picker/meta.ts +0 -67
  111. package/src/date-picker/range-meta.ts +0 -44
  112. package/src/descriptions/Descriptions.a11y.test.ts +0 -33
  113. package/src/descriptions/Descriptions.svelte +0 -287
  114. package/src/descriptions/DescriptionsItem.svelte +0 -43
  115. package/src/descriptions/context.ts +0 -21
  116. package/src/descriptions/index.ts +0 -16
  117. package/src/descriptions/meta.ts +0 -45
  118. package/src/descriptions/types.ts +0 -6
  119. package/src/divider/Divider.a11y.test.ts +0 -23
  120. package/src/divider/Divider.svelte +0 -154
  121. package/src/divider/index.ts +0 -2
  122. package/src/divider/meta.ts +0 -23
  123. package/src/drawer/Drawer.a11y.test.ts +0 -41
  124. package/src/drawer/Drawer.kbd.test.ts +0 -67
  125. package/src/drawer/Drawer.svelte +0 -554
  126. package/src/drawer/DrawerKbdFixture.svelte +0 -28
  127. package/src/drawer/index.ts +0 -2
  128. package/src/drawer/meta.ts +0 -127
  129. package/src/dropdown/Dropdown.a11y.test.ts +0 -46
  130. package/src/dropdown/Dropdown.kbd.test.ts +0 -56
  131. package/src/dropdown/Dropdown.svelte +0 -573
  132. package/src/dropdown/DropdownA11yFixture.svelte +0 -24
  133. package/src/dropdown/DropdownDivider.svelte +0 -17
  134. package/src/dropdown/DropdownItem.svelte +0 -127
  135. package/src/dropdown/DropdownItemNode.svelte +0 -355
  136. package/src/dropdown/DropdownKbdFixture.svelte +0 -26
  137. package/src/dropdown/DropdownMenu.svelte +0 -24
  138. package/src/dropdown/DropdownSubMenu.svelte +0 -212
  139. package/src/dropdown/DropdownTitle.svelte +0 -34
  140. package/src/dropdown/context.ts +0 -13
  141. package/src/dropdown/index.ts +0 -36
  142. package/src/dropdown/meta.ts +0 -97
  143. package/src/dropdown/types.test.ts +0 -50
  144. package/src/dropdown/types.ts +0 -67
  145. package/src/empty/Empty.a11y.test.ts +0 -24
  146. package/src/empty/Empty.svelte +0 -304
  147. package/src/empty/index.ts +0 -2
  148. package/src/empty/meta.ts +0 -41
  149. package/src/form/Field.svelte +0 -492
  150. package/src/form/FieldArray.svelte +0 -75
  151. package/src/form/Form.a11y.test.ts +0 -39
  152. package/src/form/Form.svelte +0 -243
  153. package/src/form/FormA11yFixture.svelte +0 -31
  154. package/src/form/FormCascader.svelte +0 -82
  155. package/src/form/FormCheckbox.svelte +0 -83
  156. package/src/form/FormDatePicker.svelte +0 -80
  157. package/src/form/FormErrorMessage.svelte +0 -44
  158. package/src/form/FormInput.svelte +0 -95
  159. package/src/form/FormLabel.svelte +0 -46
  160. package/src/form/FormRadio.svelte +0 -83
  161. package/src/form/FormRating.svelte +0 -85
  162. package/src/form/FormSection.svelte +0 -45
  163. package/src/form/FormSelect.svelte +0 -96
  164. package/src/form/FormSlider.svelte +0 -95
  165. package/src/form/FormSlot.svelte +0 -51
  166. package/src/form/FormSwitch.svelte +0 -82
  167. package/src/form/FormTagInput.svelte +0 -79
  168. package/src/form/FormTreeSelect.svelte +0 -85
  169. package/src/form/FormUpload.svelte +0 -92
  170. package/src/form/context.ts +0 -47
  171. package/src/form/index.ts +0 -22
  172. package/src/form/meta.ts +0 -85
  173. package/src/grid/Col.svelte +0 -142
  174. package/src/grid/Grid.a11y.test.ts +0 -14
  175. package/src/grid/GridA11yFixture.svelte +0 -12
  176. package/src/grid/Row.svelte +0 -116
  177. package/src/grid/index.ts +0 -3
  178. package/src/grid/meta.ts +0 -72
  179. package/src/grid/use-breakpoint.svelte.ts +0 -48
  180. package/src/highlight/Highlight.a11y.test.ts +0 -25
  181. package/src/highlight/Highlight.svelte +0 -99
  182. package/src/highlight/index.ts +0 -2
  183. package/src/highlight/meta.ts +0 -80
  184. package/src/icon/Icon.svelte +0 -156
  185. package/src/icon/index.ts +0 -2
  186. package/src/icon/meta.ts +0 -41
  187. package/src/image/Image.a11y.test.ts +0 -30
  188. package/src/image/Image.svelte +0 -387
  189. package/src/image/ImagePreview.kbd.test.ts +0 -52
  190. package/src/image/ImagePreview.svelte +0 -309
  191. package/src/image/ImagePreviewGroup.svelte +0 -93
  192. package/src/image/ImagePreviewKbdFixture.svelte +0 -32
  193. package/src/image/context.ts +0 -26
  194. package/src/image/index.ts +0 -15
  195. package/src/image/meta.ts +0 -131
  196. package/src/index.ts +0 -208
  197. package/src/input/Input.a11y.test.ts +0 -58
  198. package/src/input/Input.svelte +0 -505
  199. package/src/input/index.ts +0 -2
  200. package/src/input/meta.ts +0 -40
  201. package/src/input-number/InputNumber.a11y.test.ts +0 -43
  202. package/src/input-number/InputNumber.kbd.test.ts +0 -41
  203. package/src/input-number/InputNumber.svelte +0 -674
  204. package/src/input-number/InputNumberKbdFixture.svelte +0 -15
  205. package/src/input-number/index.ts +0 -2
  206. package/src/input-number/meta.ts +0 -65
  207. package/src/layout/Content.svelte +0 -37
  208. package/src/layout/Footer.svelte +0 -49
  209. package/src/layout/Header.svelte +0 -46
  210. package/src/layout/Layout.a11y.test.ts +0 -34
  211. package/src/layout/Layout.svelte +0 -60
  212. package/src/layout/LayoutA11yFixture.svelte +0 -21
  213. package/src/layout/Sider.svelte +0 -207
  214. package/src/layout/index.ts +0 -26
  215. package/src/layout/meta.ts +0 -116
  216. package/src/list/List.a11y.test.ts +0 -69
  217. package/src/list/List.bench.ts +0 -26
  218. package/src/list/List.kbd.test.ts +0 -71
  219. package/src/list/List.svelte +0 -920
  220. package/src/list/ListA11yFixture.svelte +0 -38
  221. package/src/list/ListBenchFixture.svelte +0 -22
  222. package/src/list/ListItem.svelte +0 -175
  223. package/src/list/ListKbdFixture.svelte +0 -31
  224. package/src/list/ListMeta.svelte +0 -73
  225. package/src/list/context.ts +0 -39
  226. package/src/list/index.ts +0 -21
  227. package/src/list/meta.ts +0 -99
  228. package/src/locale-provider/LocaleProvider.svelte +0 -110
  229. package/src/locale-provider/context.ts +0 -22
  230. package/src/locale-provider/index.ts +0 -21
  231. package/src/locale-provider/meta.ts +0 -93
  232. package/src/locale-provider/use-locale.ts +0 -25
  233. package/src/lottie-icon/LottieIcon.svelte +0 -330
  234. package/src/lottie-icon/index.ts +0 -9
  235. package/src/lottie-icon/meta.ts +0 -162
  236. package/src/menu/Menu.a11y.test.ts +0 -54
  237. package/src/menu/Menu.kbd.test.ts +0 -69
  238. package/src/menu/Menu.svelte +0 -762
  239. package/src/menu/MenuKbdFixture.svelte +0 -22
  240. package/src/menu/MenuPopupNode.svelte +0 -525
  241. package/src/menu/index.ts +0 -4
  242. package/src/menu/meta.ts +0 -137
  243. package/src/menu/types.ts +0 -120
  244. package/src/meta.test.ts +0 -173
  245. package/src/modal/ConfirmModal.svelte +0 -173
  246. package/src/modal/Modal.a11y.test.ts +0 -46
  247. package/src/modal/Modal.kbd.test.ts +0 -65
  248. package/src/modal/Modal.svelte +0 -511
  249. package/src/modal/ModalKbdFixture.svelte +0 -24
  250. package/src/modal/command.svelte.ts +0 -103
  251. package/src/modal/index.ts +0 -30
  252. package/src/modal/meta.ts +0 -165
  253. package/src/modal/z-stack.ts +0 -26
  254. package/src/notification/NotificationContainer.svelte +0 -192
  255. package/src/notification/NotificationItem.a11y.test.ts +0 -73
  256. package/src/notification/NotificationItem.svelte +0 -368
  257. package/src/notification/index.ts +0 -9
  258. package/src/notification/meta.ts +0 -120
  259. package/src/notification/store.ts +0 -191
  260. package/src/overflow-list/OverflowList.a11y.test.ts +0 -46
  261. package/src/overflow-list/OverflowList.kbd.test.ts +0 -34
  262. package/src/overflow-list/OverflowList.svelte +0 -539
  263. package/src/overflow-list/OverflowListA11yFixture.svelte +0 -22
  264. package/src/overflow-list/OverflowListKbdFixture.svelte +0 -21
  265. package/src/overflow-list/index.ts +0 -2
  266. package/src/overflow-list/meta.ts +0 -138
  267. package/src/pagination/Pagination.a11y.test.ts +0 -62
  268. package/src/pagination/Pagination.kbd.test.ts +0 -66
  269. package/src/pagination/Pagination.svelte +0 -428
  270. package/src/pagination/PaginationKbdFixture.svelte +0 -15
  271. package/src/pagination/index.ts +0 -2
  272. package/src/pagination/meta.ts +0 -73
  273. package/src/popconfirm/Popconfirm.a11y.test.ts +0 -46
  274. package/src/popconfirm/Popconfirm.kbd.test.ts +0 -42
  275. package/src/popconfirm/Popconfirm.svelte +0 -724
  276. package/src/popconfirm/PopconfirmA11yFixture.svelte +0 -34
  277. package/src/popconfirm/PopconfirmKbdFixture.svelte +0 -17
  278. package/src/popconfirm/index.ts +0 -2
  279. package/src/popconfirm/meta.ts +0 -200
  280. package/src/popover/Popover.a11y.test.ts +0 -58
  281. package/src/popover/Popover.kbd.test.ts +0 -42
  282. package/src/popover/Popover.svelte +0 -643
  283. package/src/popover/PopoverA11yFixture.svelte +0 -35
  284. package/src/popover/PopoverKbdFixture.svelte +0 -18
  285. package/src/popover/index.ts +0 -2
  286. package/src/popover/meta.ts +0 -103
  287. package/src/progress/Progress.a11y.test.ts +0 -37
  288. package/src/progress/Progress.svelte +0 -423
  289. package/src/progress/index.ts +0 -3
  290. package/src/progress/meta.ts +0 -132
  291. package/src/radio/Radio.svelte +0 -330
  292. package/src/radio/RadioGroup.a11y.test.ts +0 -43
  293. package/src/radio/RadioGroup.kbd.test.ts +0 -75
  294. package/src/radio/RadioGroup.svelte +0 -199
  295. package/src/radio/RadioGroupKbdFixture.svelte +0 -21
  296. package/src/radio/context.ts +0 -42
  297. package/src/radio/index.ts +0 -4
  298. package/src/radio/meta.ts +0 -68
  299. package/src/rating/Rating.a11y.test.ts +0 -41
  300. package/src/rating/Rating.kbd.test.ts +0 -48
  301. package/src/rating/Rating.svelte +0 -407
  302. package/src/rating/RatingKbdFixture.svelte +0 -15
  303. package/src/rating/index.ts +0 -2
  304. package/src/rating/meta.ts +0 -40
  305. package/src/resize-observer/ResizeObserver.svelte +0 -169
  306. package/src/resize-observer/action.ts +0 -80
  307. package/src/resize-observer/index.ts +0 -9
  308. package/src/resize-observer/meta.ts +0 -102
  309. package/src/scroll-list/ScrollColumn.svelte +0 -592
  310. package/src/scroll-list/ScrollList.svelte +0 -257
  311. package/src/scroll-list/index.ts +0 -4
  312. package/src/scroll-list/meta.ts +0 -93
  313. package/src/scroll-list/types.ts +0 -18
  314. package/src/select/Select.a11y.test.ts +0 -59
  315. package/src/select/Select.kbd.test.ts +0 -59
  316. package/src/select/Select.svelte +0 -1155
  317. package/src/select/SelectKbdFixture.svelte +0 -29
  318. package/src/select/index.ts +0 -3
  319. package/src/select/meta.ts +0 -78
  320. package/src/select/types.ts +0 -2
  321. package/src/side-sheet/SideSheet.a11y.test.ts +0 -53
  322. package/src/side-sheet/SideSheet.kbd.test.ts +0 -63
  323. package/src/side-sheet/SideSheet.svelte +0 -659
  324. package/src/side-sheet/SideSheetKbdFixture.svelte +0 -30
  325. package/src/side-sheet/index.ts +0 -2
  326. package/src/side-sheet/meta.ts +0 -116
  327. package/src/skeleton/Skeleton.a11y.test.ts +0 -35
  328. package/src/skeleton/Skeleton.svelte +0 -131
  329. package/src/skeleton/SkeletonAvatar.svelte +0 -82
  330. package/src/skeleton/SkeletonButton.svelte +0 -90
  331. package/src/skeleton/SkeletonImage.svelte +0 -100
  332. package/src/skeleton/SkeletonParagraph.svelte +0 -103
  333. package/src/skeleton/SkeletonTitle.svelte +0 -74
  334. package/src/skeleton/context.ts +0 -11
  335. package/src/skeleton/index.ts +0 -8
  336. package/src/skeleton/meta.ts +0 -65
  337. package/src/slider/Slider.a11y.test.ts +0 -44
  338. package/src/slider/Slider.kbd.test.ts +0 -74
  339. package/src/slider/Slider.svelte +0 -716
  340. package/src/slider/SliderKbdFixture.svelte +0 -21
  341. package/src/slider/index.ts +0 -2
  342. package/src/slider/meta.ts +0 -55
  343. package/src/space/Space.a11y.test.ts +0 -22
  344. package/src/space/Space.svelte +0 -109
  345. package/src/space/SpaceA11yFixture.svelte +0 -17
  346. package/src/space/index.ts +0 -2
  347. package/src/space/meta.ts +0 -27
  348. package/src/spin/Spin.a11y.test.ts +0 -29
  349. package/src/spin/Spin.svelte +0 -293
  350. package/src/spin/SpinA11yFixture.svelte +0 -18
  351. package/src/spin/index.ts +0 -2
  352. package/src/spin/meta.ts +0 -72
  353. package/src/steps/Steps.a11y.test.ts +0 -39
  354. package/src/steps/Steps.kbd.test.ts +0 -73
  355. package/src/steps/Steps.svelte +0 -392
  356. package/src/steps/StepsKbdFixture.svelte +0 -21
  357. package/src/steps/index.ts +0 -3
  358. package/src/steps/meta.ts +0 -59
  359. package/src/steps/types.ts +0 -8
  360. package/src/switch/Switch.a11y.test.ts +0 -46
  361. package/src/switch/Switch.kbd.test.ts +0 -40
  362. package/src/switch/Switch.svelte +0 -310
  363. package/src/switch/SwitchKbdFixture.svelte +0 -22
  364. package/src/switch/index.ts +0 -2
  365. package/src/switch/meta.ts +0 -44
  366. package/src/table/Table.a11y.test.ts +0 -70
  367. package/src/table/Table.bench.ts +0 -51
  368. package/src/table/Table.kbd.test.ts +0 -94
  369. package/src/table/Table.svelte +0 -2327
  370. package/src/table/TableKbdFixture.svelte +0 -35
  371. package/src/table/grid-nav.test.ts +0 -173
  372. package/src/table/grid-nav.ts +0 -146
  373. package/src/table/index.ts +0 -13
  374. package/src/table/meta.ts +0 -121
  375. package/src/table/types.ts +0 -133
  376. package/src/tabs/TabPane.svelte +0 -92
  377. package/src/tabs/Tabs.a11y.test.ts +0 -47
  378. package/src/tabs/Tabs.kbd.test.ts +0 -74
  379. package/src/tabs/Tabs.svelte +0 -1128
  380. package/src/tabs/TabsA11yFixture.svelte +0 -20
  381. package/src/tabs/TabsKbdFixture.svelte +0 -25
  382. package/src/tabs/context.ts +0 -43
  383. package/src/tabs/index.ts +0 -14
  384. package/src/tabs/meta.ts +0 -152
  385. package/src/tabs/types.ts +0 -6
  386. package/src/tag/Tag.a11y.test.ts +0 -33
  387. package/src/tag/Tag.svelte +0 -366
  388. package/src/tag/TagA11yFixture.svelte +0 -18
  389. package/src/tag/index.ts +0 -2
  390. package/src/tag/meta.ts +0 -92
  391. package/src/tag-input/TagInput.a11y.test.ts +0 -41
  392. package/src/tag-input/TagInput.svelte +0 -544
  393. package/src/tag-input/index.ts +0 -2
  394. package/src/tag-input/meta.ts +0 -43
  395. package/src/tag-input/reorder.test.ts +0 -59
  396. package/src/tag-input/reorder.ts +0 -41
  397. package/src/test-utils/LocaleHarness.svelte +0 -29
  398. package/src/test-utils/a11y.ts +0 -108
  399. package/src/test-utils/kbd.ts +0 -52
  400. package/src/textarea/TextArea.a11y.test.ts +0 -44
  401. package/src/textarea/TextArea.svelte +0 -420
  402. package/src/textarea/index.ts +0 -2
  403. package/src/textarea/meta.ts +0 -104
  404. package/src/time-picker/TimePicker.a11y.test.ts +0 -45
  405. package/src/time-picker/TimePicker.kbd.test.ts +0 -70
  406. package/src/time-picker/TimePicker.svelte +0 -1023
  407. package/src/time-picker/TimePickerKbdFixture.svelte +0 -23
  408. package/src/time-picker/index.ts +0 -2
  409. package/src/time-picker/meta.ts +0 -64
  410. package/src/timeline/Timeline.a11y.test.ts +0 -54
  411. package/src/timeline/Timeline.svelte +0 -599
  412. package/src/timeline/TimelineItem.svelte +0 -164
  413. package/src/timeline/context.ts +0 -28
  414. package/src/timeline/index.ts +0 -16
  415. package/src/timeline/meta.ts +0 -129
  416. package/src/timeline/types.ts +0 -9
  417. package/src/toast/Toast.a11y.test.ts +0 -67
  418. package/src/toast/ToastContainer.svelte +0 -184
  419. package/src/toast/ToastItem.svelte +0 -247
  420. package/src/toast/index.ts +0 -9
  421. package/src/toast/live-region.ts +0 -78
  422. package/src/toast/meta.ts +0 -95
  423. package/src/toast/store.ts +0 -187
  424. package/src/tooltip/Tooltip.a11y.test.ts +0 -41
  425. package/src/tooltip/Tooltip.kbd.test.ts +0 -37
  426. package/src/tooltip/Tooltip.svelte +0 -416
  427. package/src/tooltip/TooltipA11yFixture.svelte +0 -31
  428. package/src/tooltip/TooltipKbdFixture.svelte +0 -16
  429. package/src/tooltip/index.ts +0 -2
  430. package/src/tooltip/meta.ts +0 -59
  431. package/src/tooltip/placement.ts +0 -6
  432. package/src/transfer/Transfer.a11y.test.ts +0 -63
  433. package/src/transfer/Transfer.kbd.test.ts +0 -75
  434. package/src/transfer/Transfer.svelte +0 -1451
  435. package/src/transfer/TransferKbdFixture.svelte +0 -23
  436. package/src/transfer/group.test.ts +0 -55
  437. package/src/transfer/group.ts +0 -61
  438. package/src/transfer/index.ts +0 -3
  439. package/src/transfer/meta.ts +0 -55
  440. package/src/transfer/reorder.test.ts +0 -52
  441. package/src/transfer/reorder.ts +0 -42
  442. package/src/transfer/tree.test.ts +0 -44
  443. package/src/transfer/tree.ts +0 -52
  444. package/src/transfer/types.ts +0 -32
  445. package/src/tree/Tree.a11y.test.ts +0 -63
  446. package/src/tree/Tree.kbd.test.ts +0 -91
  447. package/src/tree/Tree.svelte +0 -1500
  448. package/src/tree/TreeKbdFixture.svelte +0 -30
  449. package/src/tree/index.ts +0 -3
  450. package/src/tree/meta.ts +0 -152
  451. package/src/tree-select/TreeSelect.a11y.test.ts +0 -52
  452. package/src/tree-select/TreeSelect.kbd.test.ts +0 -53
  453. package/src/tree-select/TreeSelect.svelte +0 -1611
  454. package/src/tree-select/TreeSelectKbdFixture.svelte +0 -20
  455. package/src/tree-select/index.ts +0 -3
  456. package/src/tree-select/meta.ts +0 -73
  457. package/src/tree-select/types.ts +0 -11
  458. package/src/tree-select/virtual.test.ts +0 -104
  459. package/src/typography/Link.svelte +0 -120
  460. package/src/typography/Paragraph.svelte +0 -92
  461. package/src/typography/Text.svelte +0 -93
  462. package/src/typography/Title.svelte +0 -91
  463. package/src/typography/Typography.a11y.test.ts +0 -34
  464. package/src/typography/TypographyA11yFixture.svelte +0 -27
  465. package/src/typography/TypographyBase.svelte +0 -807
  466. package/src/typography/index.ts +0 -16
  467. package/src/typography/meta.ts +0 -158
  468. package/src/upload/Upload.a11y.test.ts +0 -58
  469. package/src/upload/Upload.svelte +0 -1094
  470. package/src/upload/UploadA11yFixture.svelte +0 -23
  471. package/src/upload/index.ts +0 -3
  472. package/src/upload/meta.ts +0 -64
  473. package/src/upload/types.ts +0 -16
  474. package/src/virtual-list/VirtualList.svelte +0 -401
  475. package/src/virtual-list/index.ts +0 -2
  476. package/src/virtual-list/meta.ts +0 -106
@@ -1,368 +0,0 @@
1
- <!--
2
- NotificationItem — 单条通知卡片。
3
- 类型图标(可选)+ 主体(title + content)+ 可选关闭按钮(右上角绝对定位)+ 可选 footer 操作区。
4
- pauseOnHover 经 mouseenter/leave + focusin/out 暂停/恢复定时器。
5
- showProgress:底部倒计时进度条,随 duration 递减;hover/聚焦时暂停(与定时器同步)。
6
- 命令式 rAF 驱动(红线 #3)——effect 启动循环、cleanup 取消帧并清空 ref;duration<=0 时不渲染。
7
- theme:light(默认,与卡片背景一致)/ dark(深色卡片)。
8
- a11y:error/warning -> role=alert + aria-live=assertive;其余 -> role=status + aria-live=polite。
9
- title/content 经 useId 关联 aria-labelledby / aria-describedby;关闭按钮 aria-label「关闭」,不抢焦点。
10
- 类型前缀(如「错误:」)以视觉隐藏文本注入卡片首部(spec §6),令屏幕阅读器先播报极性语义。
11
- -->
12
- <script lang="ts">
13
- import type { Snippet } from 'svelte';
14
- import { useId } from '@chenzy-design/core';
15
- import type { NotificationItem, NotificationType } from '@chenzy-design/core';
16
- import { useLocale } from '../locale-provider/index.js';
17
-
18
- interface Props {
19
- item: NotificationItem;
20
- onClose: (id: string) => void;
21
- /**
22
- * 仅在用户点击关闭按钮时触发(与 onClose 区分:onClose 在任何关闭方式时触发)。
23
- * 由 NotificationContainer 传入,从 onCloseClickMap 中查找并调用对应回调。
24
- */
25
- onCloseClick?: (id: string) => void;
26
- onPause: (id: string) => void;
27
- onResume: (id: string) => void;
28
- }
29
-
30
- let { item, onClose, onCloseClick, onPause, onResume }: Props = $props();
31
- const loc = useLocale();
32
-
33
- const titleId = useId('cd-notification-title');
34
- const contentId = useId('cd-notification-content');
35
-
36
- const isAlert = $derived(item.type === 'error' || item.type === 'warning');
37
- const role = $derived(isAlert ? 'alert' : 'status');
38
- const ariaLive = $derived(isAlert ? 'assertive' : 'polite');
39
- const hasIcon = $derived(item.type !== 'default');
40
-
41
- // 视觉隐藏类型前缀(如「错误:」):default 无前缀;其余走 i18n(colon 跟随 locale)。
42
- // 注入卡片首部,令屏幕阅读器先读极性语义再读 title/content。
43
- const typePrefix = $derived(
44
- item.type === 'default'
45
- ? ''
46
- : `${loc().t(`Notification.${item.type}`)}${loc().t('Form.colon')}`,
47
- );
48
-
49
- // footer 是渲染层 Snippet(core 用 unknown 透传,无框架依赖)。
50
- const footer = $derived(item.footer as Snippet | undefined);
51
-
52
- // showProgress 仅在有限 duration 下有意义;duration<=0(常驻)无倒计时可显示。
53
- const hasProgress = $derived(item.showProgress && item.duration > 0);
54
-
55
- // 本地暂停态:与 store 定时器的暂停/恢复严格同源(同一组 hover/focus 处理器)。
56
- // 用普通变量(非 $state)让 rAF 循环直接读取,避免 effect 重订阅/重启而丢失进度。
57
- let paused = false;
58
- // 进度条 DOM 引用;命令式驱动 scaleX,避免每帧触发 Svelte 响应式。
59
- let progressEl = $state<HTMLDivElement | null>(null);
60
-
61
- function handlePause() {
62
- if (item.pauseOnHover) {
63
- paused = true;
64
- onPause(item.id);
65
- }
66
- }
67
- function handleResume() {
68
- if (item.pauseOnHover) {
69
- paused = false;
70
- onResume(item.id);
71
- }
72
- }
73
-
74
- // 命令式 rAF 倒计时进度(红线 #3):effect 仅依赖 duration/progressEl 启动单条循环,
75
- // 循环内直接读 paused(普通变量)冻结/推进剩余时间,直接写 DOM scaleX;cleanup 取消帧。
76
- $effect(() => {
77
- if (!hasProgress || !progressEl) return;
78
- const totalMs = item.duration * 1000;
79
- const el = progressEl;
80
- let raf = 0;
81
- let remaining = totalMs;
82
- let last = performance.now();
83
-
84
- function tick(t: number): void {
85
- if (!paused) remaining = Math.max(0, remaining - (t - last));
86
- last = t;
87
- el.style.transform = `scaleX(${remaining / totalMs})`;
88
- if (remaining > 0) raf = requestAnimationFrame(tick);
89
- }
90
- raf = requestAnimationFrame(tick);
91
- return () => cancelAnimationFrame(raf);
92
- });
93
- </script>
94
-
95
- {#snippet typeIcon(type: NotificationType)}
96
- {#if type === 'success'}
97
- <svg class="cd-notification-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
98
- <circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.4" />
99
- <path
100
- fill="none"
101
- stroke="currentColor"
102
- stroke-width="1.6"
103
- stroke-linecap="round"
104
- stroke-linejoin="round"
105
- d="M5 8.2l2 2 4-4.4"
106
- />
107
- </svg>
108
- {:else if type === 'info'}
109
- <svg class="cd-notification-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
110
- <circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.4" />
111
- <path stroke="currentColor" stroke-width="1.4" stroke-linecap="round" d="M8 7.2v4" />
112
- <circle cx="8" cy="4.7" r="0.85" fill="currentColor" />
113
- </svg>
114
- {:else if type === 'warning'}
115
- <svg class="cd-notification-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
116
- <path
117
- fill="none"
118
- stroke="currentColor"
119
- stroke-width="1.4"
120
- stroke-linejoin="round"
121
- d="M8 1.5l6.5 12h-13z"
122
- />
123
- <path stroke="currentColor" stroke-width="1.4" stroke-linecap="round" d="M8 6.5v3.2" />
124
- <circle cx="8" cy="11.6" r="0.85" fill="currentColor" />
125
- </svg>
126
- {:else if type === 'error'}
127
- <svg class="cd-notification-item__icon-svg" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
128
- <circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.4" />
129
- <path
130
- stroke="currentColor"
131
- stroke-width="1.6"
132
- stroke-linecap="round"
133
- d="M5.5 5.5l5 5M10.5 5.5l-5 5"
134
- />
135
- </svg>
136
- {/if}
137
- {/snippet}
138
-
139
- <div
140
- class="cd-notification-item cd-notification-item--{item.type} cd-notification-item--{item.theme}"
141
- {role}
142
- aria-live={ariaLive}
143
- aria-labelledby={item.title ? titleId : undefined}
144
- aria-describedby={item.content ? contentId : undefined}
145
- onmouseenter={handlePause}
146
- onmouseleave={handleResume}
147
- onfocusin={handlePause}
148
- onfocusout={handleResume}
149
- >
150
- {#if typePrefix}
151
- <span class="cd-sr-only">{typePrefix}</span>
152
- {/if}
153
- {#if hasIcon}
154
- <span class="cd-notification-item__icon">
155
- {@render typeIcon(item.type)}
156
- </span>
157
- {/if}
158
- <div class="cd-notification-item__body">
159
- {#if item.title}
160
- <div class="cd-notification-item__title" id={titleId}>{item.title}</div>
161
- {/if}
162
- {#if item.content}
163
- <div class="cd-notification-item__content" id={contentId}>{item.content}</div>
164
- {/if}
165
- {#if footer}
166
- <div class="cd-notification-item__footer">
167
- {@render footer()}
168
- </div>
169
- {/if}
170
- </div>
171
- {#if item.closable}
172
- <button
173
- type="button"
174
- class="cd-notification-item__close"
175
- aria-label={loc().t('Notification.closeText')}
176
- onclick={() => { onCloseClick?.(item.id); onClose(item.id); }}
177
- >
178
- <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
179
- <path
180
- stroke="currentColor"
181
- stroke-width="1.4"
182
- stroke-linecap="round"
183
- d="M4 4l8 8M12 4l-8 8"
184
- />
185
- </svg>
186
- </button>
187
- {/if}
188
- {#if hasProgress}
189
- <div class="cd-notification-item__progress" aria-hidden="true">
190
- <div class="cd-notification-item__progress-bar" bind:this={progressEl}></div>
191
- </div>
192
- {/if}
193
- </div>
194
-
195
- <style>
196
- .cd-notification-item {
197
- position: relative;
198
- display: flex;
199
- gap: var(--cd-notification-gap);
200
- align-items: flex-start;
201
- box-sizing: border-box;
202
- inline-size: var(--cd-notification-width);
203
- max-inline-size: 100%;
204
- padding: var(--cd-notification-padding);
205
- background: var(--cd-notification-bg);
206
- border: 1px solid var(--cd-notification-border);
207
- border-radius: var(--cd-notification-radius);
208
- box-shadow: var(--cd-notification-shadow);
209
- pointer-events: auto;
210
- }
211
-
212
- /* 视觉隐藏类型前缀复用 tokens.css 全局 .cd-sr-only:仅供屏幕阅读器读取极性语义。 */
213
-
214
- .cd-notification-item__icon {
215
- display: inline-flex;
216
- flex: none;
217
- align-items: center;
218
- justify-content: center;
219
- inline-size: 1.25em;
220
- block-size: 1.25em;
221
- margin-block-start: 0.0625em;
222
- }
223
-
224
- .cd-notification-item__icon-svg {
225
- inline-size: 100%;
226
- block-size: 100%;
227
- }
228
-
229
- .cd-notification-item--success .cd-notification-item__icon {
230
- color: var(--cd-notification-icon-success);
231
- }
232
- .cd-notification-item--info .cd-notification-item__icon {
233
- color: var(--cd-notification-icon-info);
234
- }
235
- .cd-notification-item--warning .cd-notification-item__icon {
236
- color: var(--cd-notification-icon-warning);
237
- }
238
- .cd-notification-item--error .cd-notification-item__icon {
239
- color: var(--cd-notification-icon-error);
240
- }
241
-
242
- .cd-notification-item__body {
243
- flex: 1 1 auto;
244
- min-inline-size: 0;
245
- /* 为右上角关闭按钮预留空间 */
246
- padding-inline-end: 1.5em;
247
- }
248
-
249
- .cd-notification-item__title {
250
- font-size: var(--cd-notification-title-size);
251
- font-weight: 600;
252
- line-height: 1.4;
253
- color: var(--cd-notification-color-title);
254
- overflow-wrap: anywhere;
255
- }
256
-
257
- .cd-notification-item__content {
258
- margin-block-start: var(--cd-spacing-1);
259
- font-size: var(--cd-notification-content-size);
260
- line-height: 1.5;
261
- color: var(--cd-notification-color-content);
262
- overflow-wrap: anywhere;
263
- }
264
-
265
- .cd-notification-item__footer {
266
- display: flex;
267
- flex-wrap: wrap;
268
- gap: var(--cd-spacing-2);
269
- align-items: center;
270
- margin-block-start: var(--cd-spacing-3);
271
- }
272
-
273
- .cd-notification-item__progress {
274
- position: absolute;
275
- inset-inline: 0;
276
- inset-block-end: 0;
277
- block-size: var(--cd-notification-progress-height);
278
- overflow: hidden;
279
- border-end-start-radius: var(--cd-notification-radius);
280
- border-end-end-radius: var(--cd-notification-radius);
281
- pointer-events: none;
282
- }
283
-
284
- .cd-notification-item__progress-bar {
285
- block-size: 100%;
286
- inline-size: 100%;
287
- background: var(--cd-notification-progress-color);
288
- /* 倒计时从起始边收缩:LTR 自左、RTL 自右(随 dir 翻转 transform-origin)。 */
289
- transform-origin: left center;
290
- /* 初始满格;命令式 rAF 写 scaleX 递减 */
291
- transform: scaleX(1);
292
- }
293
-
294
- :global([dir='rtl']) .cd-notification-item__progress-bar {
295
- transform-origin: right center;
296
- }
297
-
298
- .cd-notification-item--success .cd-notification-item__progress-bar {
299
- background: var(--cd-notification-icon-success);
300
- }
301
- .cd-notification-item--info .cd-notification-item__progress-bar {
302
- background: var(--cd-notification-icon-info);
303
- }
304
- .cd-notification-item--warning .cd-notification-item__progress-bar {
305
- background: var(--cd-notification-icon-warning);
306
- }
307
- .cd-notification-item--error .cd-notification-item__progress-bar {
308
- background: var(--cd-notification-icon-error);
309
- }
310
-
311
- /* dark 主题:深色卡片,文案/边框/关闭色覆盖为 token */
312
- .cd-notification-item--dark {
313
- background: var(--cd-notification-bg-dark);
314
- border-color: var(--cd-notification-border-dark);
315
- }
316
- .cd-notification-item--dark .cd-notification-item__title {
317
- color: var(--cd-notification-color-title-dark);
318
- }
319
- .cd-notification-item--dark .cd-notification-item__content {
320
- color: var(--cd-notification-color-content-dark);
321
- }
322
- .cd-notification-item--dark .cd-notification-item__close {
323
- color: var(--cd-notification-close-color-dark);
324
- }
325
- .cd-notification-item--dark .cd-notification-item__close:hover {
326
- color: var(--cd-notification-close-color-hover-dark);
327
- }
328
-
329
- .cd-notification-item__close {
330
- position: absolute;
331
- inset-block-start: var(--cd-notification-padding);
332
- inset-inline-end: var(--cd-notification-padding);
333
- display: inline-flex;
334
- flex: none;
335
- align-items: center;
336
- justify-content: center;
337
- inline-size: 1.25em;
338
- block-size: 1.25em;
339
- padding: 0;
340
- margin: 0;
341
- border: none;
342
- background: transparent;
343
- color: var(--cd-notification-close-color);
344
- cursor: pointer;
345
- border-radius: var(--cd-radius-1);
346
- transition: color var(--cd-notification-motion-duration) ease;
347
- }
348
-
349
- .cd-notification-item__close:hover {
350
- color: var(--cd-notification-close-color-hover);
351
- }
352
-
353
- .cd-notification-item__close:focus-visible {
354
- outline: 2px solid var(--cd-color-primary);
355
- outline-offset: 1px;
356
- }
357
-
358
- .cd-notification-item__close svg {
359
- inline-size: 100%;
360
- block-size: 100%;
361
- }
362
-
363
- @media (prefers-reduced-motion: reduce) {
364
- .cd-notification-item__close {
365
- transition: none;
366
- }
367
- }
368
- </style>
@@ -1,9 +0,0 @@
1
- export { notification, type NotificationConfig, type SvelteNotificationOptions } from './store.js';
2
- export { meta as notificationMeta } from './meta.js';
3
- export type {
4
- NotificationType,
5
- NotificationOptions,
6
- NotificationItem,
7
- NotificationPlacement,
8
- NotificationDirection,
9
- } from '@chenzy-design/core';
@@ -1,120 +0,0 @@
1
- /**
2
- * Machine-readable component metadata for AI/docs consumption.
3
- * Notification — see specs/components/feedback/Notification.spec.md
4
- */
5
- export const meta = {
6
- name: 'Notification',
7
- category: 'feedback',
8
- description:
9
- '通知提醒框:命令式全局反馈 API(notification.open/success/info/warning/error/close/update/destroyAll)。比 Toast 更丰富——标题 + 内容 + 图标;6 方位独立堆叠;单例容器惰性挂载到 body;自动关闭 + 悬停暂停 + maxCount 按方位 FIFO 淘汰 + 同 id 去重更新;error/warning role=alert(assertive)、其余 role=status(polite);可选 showProgress 倒计时进度条(命令式 rAF + 悬停同步暂停)、footer 操作区 Snippet、theme(light/dark);RTL(direction=rtl 镜像卡片布局并左右互换方位)、Esc 关闭最近一条(window keydown + cleanup)、notification.config({ direction, getPopupContainer }) 配置全局方向与容器挂载点(默认 ltr + body,对齐 Modal/Dropdown getContainer)。',
10
- exports: ['notification'],
11
- imperative: true,
12
- config: {
13
- direction: "全局默认书写方向 'ltr'|'rtl'(per-item direction 优先)",
14
- getPopupContainer:
15
- '() => HTMLElement,容器宿主挂载目标(默认 body);须在首条通知前调用方生效',
16
- },
17
- props: [
18
- { name: 'id', type: 'string', default: 'undefined', desc: '指定 id;已存在则原地更新' },
19
- { name: 'title', type: 'string', default: '—', desc: '通知标题' },
20
- { name: 'content', type: 'string', default: '—', desc: '通知正文' },
21
- {
22
- name: 'type',
23
- type: "'default'|'success'|'info'|'warning'|'error'",
24
- default: "'default'",
25
- desc: '语义类型,决定图标与强调色',
26
- },
27
- {
28
- name: 'duration',
29
- type: 'number',
30
- default: '4.5',
31
- desc: '自动关闭秒数;0 持久',
32
- },
33
- {
34
- name: 'placement',
35
- type: "'topLeft'|'top'|'topRight'|'bottomLeft'|'bottom'|'bottomRight'",
36
- default: "'topRight'",
37
- desc: '弹出位置,每方位独立堆叠',
38
- },
39
- { name: 'closable', type: 'boolean', default: 'true', desc: '是否显示关闭按钮' },
40
- { name: 'pauseOnHover', type: 'boolean', default: 'true', desc: '悬停/聚焦时暂停定时器' },
41
- {
42
- name: 'showProgress',
43
- type: 'boolean',
44
- default: 'false',
45
- desc: '底部倒计时进度条,随 duration 递减;悬停/聚焦时与定时器同步暂停(duration=0 时不显示)',
46
- },
47
- {
48
- name: 'theme',
49
- type: "'light'|'dark'",
50
- default: "'light'",
51
- desc: '卡片主题;dark 为深色卡片',
52
- },
53
- {
54
- name: 'direction',
55
- type: "'ltr'|'rtl'",
56
- default: "'ltr'(可经 notification.config 改默认)",
57
- desc: 'RTL 时镜像卡片布局(关闭按钮/图标/文案/进度方向翻转)并左右互换方位',
58
- },
59
- {
60
- name: 'footer',
61
- type: 'Snippet',
62
- default: 'undefined',
63
- desc: '底部操作区插槽(按钮等),渲染在内容下方',
64
- },
65
- {
66
- name: 'onClose',
67
- type: "(id: string, reason: 'timeout'|'manual'|'replace'|'destroyAll') => void",
68
- default: 'undefined',
69
- desc: '关闭回调,附关闭原因',
70
- },
71
- ],
72
- events: [{ name: 'onClose', desc: '单条关闭(超时/手动/被替换/清空)时触发,带 id 与 reason' }],
73
- slots: [],
74
- a11y: {
75
- hasRole: true,
76
- focusable: false,
77
- note: 'error/warning 用 role=alert + aria-live=assertive,其余 role=status + aria-live=polite;标题 aria-labelledby、内容 aria-describedby;关闭按钮 button + aria-label「关闭」。不抢焦点、不锁滚动。',
78
- },
79
- tokens: [
80
- '--cd-notification-width',
81
- '--cd-notification-bg',
82
- '--cd-notification-color-title',
83
- '--cd-notification-color-content',
84
- '--cd-notification-border',
85
- '--cd-notification-radius',
86
- '--cd-notification-shadow',
87
- '--cd-notification-padding',
88
- '--cd-notification-gap',
89
- '--cd-notification-icon-success',
90
- '--cd-notification-icon-info',
91
- '--cd-notification-icon-warning',
92
- '--cd-notification-icon-error',
93
- '--cd-notification-close-color',
94
- '--cd-notification-close-color-hover',
95
- '--cd-notification-title-size',
96
- '--cd-notification-content-size',
97
- '--cd-notification-z',
98
- '--cd-notification-offset',
99
- '--cd-notification-motion-duration',
100
- '--cd-notification-progress-height',
101
- '--cd-notification-progress-color',
102
- '--cd-notification-bg-dark',
103
- '--cd-notification-border-dark',
104
- '--cd-notification-color-title-dark',
105
- '--cd-notification-color-content-dark',
106
- '--cd-notification-close-color-dark',
107
- '--cd-notification-close-color-hover-dark',
108
- ],
109
- responsive: false,
110
- examples: [
111
- { title: '成功', code: "notification.success({ title: '已上传', content: '文件保存成功' })" },
112
- { title: '错误', code: "notification.error({ title: '保存失败', content: '网络中断' })" },
113
- { title: '常驻', code: "notification.open({ title: '提醒', duration: 0 })" },
114
- { title: 'RTL', code: "notification.info({ title: 'مرحبا', content: 'نص', direction: 'rtl' })" },
115
- {
116
- title: '全局配置',
117
- code: "notification.config({ direction: 'rtl', getPopupContainer: () => document.getElementById('app')! })",
118
- },
119
- ],
120
- } as const;
@@ -1,191 +0,0 @@
1
- /**
2
- * Notification — 命令式全局通知提醒框入口。
3
- * 模块级单例 store + 惰性挂载的单例 NotificationContainer(首次调用时 mount 到 body)。
4
- * 复用 @chenzy-design/core 的 createNotificationStore(无框架依赖的队列 + 定时器)。
5
- * 与 Toast 同构,差异:数据含 title + content、6 方位独立堆叠、无 loading 类型;
6
- * 命令式入参是 NotificationOptions 配置对象(不像 Toast 首参是 string)。
7
- * See specs/components/feedback/Notification.spec.md
8
- */
9
- import {
10
- createNotificationStore,
11
- type NotificationStore,
12
- type NotificationOptions,
13
- type NotificationType,
14
- type NotificationPlacement,
15
- type NotificationDirection,
16
- } from '@chenzy-design/core';
17
-
18
- /**
19
- * 全局通知配置(命令式单例特有)。容器经 mount() 挂在 Svelte 组件树之外,
20
- * 拿不到 ConfigProvider context,故 RTL / 挂载容器只能经此命令式入口配置:
21
- * - direction:未显式指定 direction 的通知的默认书写方向(rtl 镜像布局并左右互换方位)。
22
- * - getPopupContainer:容器宿主挂载目标(默认 body),对齐 Modal/Dropdown getContainer。
23
- * - top/bottom/left/right:六方位容器与视口边缘的偏移(CSS 像素字符串或数字)。
24
- * - zIndex:通知容器层叠优先级。
25
- * - duration:全局默认自动关闭秒数(0 = 常驻),可被单条 options.duration 覆盖。
26
- * 须在首条通知前调用方对挂载点生效(容器惰性挂载且单例,仅挂一次)。
27
- */
28
- export interface NotificationConfig {
29
- direction?: NotificationDirection;
30
- getPopupContainer?: () => HTMLElement | null | undefined;
31
- /** 通知容器距视口顶部偏移(CSS 值,如 '24px' 或数字像素),适用于 topLeft/top/topRight 方位 */
32
- top?: number | string;
33
- /** 通知容器距视口底部偏移 */
34
- bottom?: number | string;
35
- /** 通知容器距视口左侧偏移 */
36
- left?: number | string;
37
- /** 通知容器距视口右侧偏移 */
38
- right?: number | string;
39
- /** 通知容器 z-index */
40
- zIndex?: number;
41
- /** 全局默认自动关闭秒数(0 = 常驻);可被单条 notification.xxx({ duration }) 覆盖 */
42
- duration?: number;
43
- }
44
-
45
- let store: NotificationStore | null = null;
46
- let containerMounted = false;
47
- let globalDirection: NotificationDirection = 'ltr';
48
- let getPopupContainer: (() => HTMLElement | null | undefined) | undefined;
49
- let globalDuration: number | undefined;
50
- // 位置偏移:由 NotificationContainer 读取并注入 CSS custom property。
51
- type PositionOffsets = Pick<NotificationConfig, 'top' | 'bottom' | 'left' | 'right' | 'zIndex'>;
52
- let positionOffsets: PositionOffsets = {};
53
-
54
- /**
55
- * Svelte 层扩展选项(core NotificationOptions 的超集):
56
- * - showClose: closable 的别名(Semi 文档用 showClose),两者等价,showClose 优先。
57
- * - onCloseClick: 仅在用户点击关闭按钮时触发(与 onClose 区分:onClose 在任何关闭方式时触发)。
58
- */
59
- export interface SvelteNotificationOptions extends NotificationOptions {
60
- /** closable 的别名(Semi 文档用 showClose);showClose 优先于 closable */
61
- showClose?: boolean;
62
- /** 仅在用户点击关闭按钮时触发;onClose 在所有关闭方式(timeout/manual/replace/destroyAll)时触发 */
63
- onCloseClick?: (id: string) => void;
64
- }
65
-
66
- // onCloseClick 回调按 id 存储在模块级 Map,NotificationContainer 关闭按钮点击时查找并调用。
67
- export const onCloseClickMap = new Map<string, (id: string) => void>();
68
-
69
- /** 位置偏移 getter:供 NotificationContainer 读取并注入 inline style(config() 后生效)。 */
70
- export function getPositionOffsets(): Pick<NotificationConfig, 'top' | 'bottom' | 'left' | 'right' | 'zIndex'> {
71
- return positionOffsets;
72
- }
73
-
74
- function ensureStore(): NotificationStore {
75
- if (!store) {
76
- store = createNotificationStore({
77
- maxCount: 5,
78
- defaultDuration: globalDuration ?? 4.5,
79
- });
80
- }
81
- return store;
82
- }
83
-
84
- /**
85
- * 把全局 direction 作为默认注入未显式指定方向的选项(per-item direction 仍优先)。
86
- * 同时解析 showClose 别名(→ closable);onCloseClick 单独处理。
87
- */
88
- interface ResolvedOpts {
89
- coreOpts: NotificationOptions;
90
- onCloseClick: ((id: string) => void) | undefined;
91
- }
92
-
93
- function resolveOpts(opts: SvelteNotificationOptions): ResolvedOpts {
94
- // Cast via unknown to tolerate svelte-check false positives when @chenzy-design/core is not built.
95
- type CoreOpts = NotificationOptions & Record<string, unknown>;
96
- const { showClose, onCloseClick, ...rest } = opts as SvelteNotificationOptions & Record<string, unknown>;
97
- // showClose 优先于 closable;都未传则 core 默认 true。
98
- const closable = showClose !== undefined ? showClose : (rest as CoreOpts).closable;
99
- const coreOpts: NotificationOptions = {
100
- ...(rest as NotificationOptions),
101
- ...(closable !== undefined ? { closable } : {}),
102
- direction: (opts as CoreOpts).direction !== undefined
103
- ? (opts as CoreOpts).direction as string
104
- : globalDirection,
105
- } as NotificationOptions;
106
- // 若有 onCloseClick,在 onClose 钩子中清理 map(防内存泄漏)。
107
- if (onCloseClick) {
108
- const origOnClose = (coreOpts as CoreOpts).onClose as ((id: string, r: unknown) => void) | undefined;
109
- (coreOpts as CoreOpts).onClose = (closedId: string, reason: unknown) => {
110
- onCloseClickMap.delete(closedId);
111
- origOnClose?.(closedId, reason);
112
- };
113
- }
114
- return { coreOpts, onCloseClick };
115
- }
116
-
117
- /**
118
- * 惰性挂载容器:首次调用时动态 import + mount NotificationContainer 到 body。
119
- * mount 是 async(动态 import),但调用方的 s.open 已同步把数据写进 store;
120
- * 容器在 mount 时立即同步读一次 store.getItems(),不会丢首条通知。
121
- */
122
- async function ensureContainer(): Promise<void> {
123
- if (containerMounted || typeof document === 'undefined') return;
124
- containerMounted = true;
125
- const { mount } = await import('svelte');
126
- const { default: NotificationContainer } = await import('./NotificationContainer.svelte');
127
- const host = document.createElement('div');
128
- host.className = 'cd-notification-host';
129
- // 挂载到 getPopupContainer() 指定容器(默认 body),对齐 Modal/Dropdown getContainer。
130
- const target = getPopupContainer?.() ?? document.body;
131
- target.appendChild(host);
132
- mount(NotificationContainer, { target: host, props: { store: ensureStore() } });
133
- }
134
-
135
- function show(type: NotificationType, opts: SvelteNotificationOptions): string {
136
- const s = ensureStore();
137
- void ensureContainer();
138
- const merged: SvelteNotificationOptions = { ...opts };
139
- (merged as NotificationOptions).type = type;
140
- const { coreOpts, onCloseClick } = resolveOpts(merged);
141
- const id = s.open(coreOpts);
142
- if (onCloseClick) onCloseClickMap.set(id, onCloseClick);
143
- return id;
144
- }
145
-
146
- export const notification = {
147
- /**
148
- * 配置全局通知行为:direction(默认书写方向)、getPopupContainer(容器挂载目标)、
149
- * top/bottom/left/right/zIndex(容器位置偏移)、duration(全局默认自动关闭秒数)。
150
- * 命令式单例特性——须在首条通知前调用方对挂载点生效。向后兼容:不调用即 ltr + body。
151
- */
152
- config: (cfg: NotificationConfig): void => {
153
- if (cfg.direction !== undefined) globalDirection = cfg.direction;
154
- if ('getPopupContainer' in cfg) getPopupContainer = cfg.getPopupContainer;
155
- if (cfg.duration !== undefined) globalDuration = cfg.duration;
156
- const next: PositionOffsets = {};
157
- if (cfg.top !== undefined) next.top = cfg.top;
158
- if (cfg.bottom !== undefined) next.bottom = cfg.bottom;
159
- if (cfg.left !== undefined) next.left = cfg.left;
160
- if (cfg.right !== undefined) next.right = cfg.right;
161
- if (cfg.zIndex !== undefined) next.zIndex = cfg.zIndex;
162
- positionOffsets = next;
163
- },
164
- /** 完整选项打开一条通知,返回其 id。 */
165
- open: (opts: SvelteNotificationOptions): string => {
166
- void ensureContainer();
167
- const { coreOpts, onCloseClick } = resolveOpts(opts);
168
- const id = ensureStore().open(coreOpts);
169
- if (onCloseClick) onCloseClickMap.set(id, onCloseClick);
170
- return id;
171
- },
172
- success: (opts: SvelteNotificationOptions): string => show('success', opts),
173
- info: (opts: SvelteNotificationOptions): string => show('info', opts),
174
- warning: (opts: SvelteNotificationOptions): string => show('warning', opts),
175
- error: (opts: SvelteNotificationOptions): string => show('error', opts),
176
- /** 手动关闭指定通知。 */
177
- close: (id: string): void => ensureStore().close(id, 'manual'),
178
- /** 按同 id 更新一条通知(store.open 对已存在 id 走原地更新 + 重启定时器)。 */
179
- update: (id: string, opts: SvelteNotificationOptions): string => {
180
- void ensureContainer();
181
- const merged: SvelteNotificationOptions = { ...opts };
182
- (merged as NotificationOptions).id = id;
183
- const { coreOpts, onCloseClick } = resolveOpts(merged);
184
- const newId = ensureStore().open(coreOpts);
185
- if (onCloseClick) onCloseClickMap.set(newId, onCloseClick);
186
- return newId;
187
- },
188
- /** 清空全部通知,或仅清空指定方位。 */
189
- destroyAll: (placement?: NotificationPlacement): void =>
190
- ensureStore().destroyAll(placement),
191
- };