@bifrostui/react 1.2.9-beta.0 → 1.3.1-beta.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 (307) hide show
  1. package/dist/ActionSheet/ActionSheet.css +6 -3
  2. package/dist/ActionSheet/ActionSheetItem.css +10 -6
  3. package/dist/Alert/index.css +14 -8
  4. package/dist/Avatar/Avatar.css +13 -9
  5. package/dist/Avatar/AvatarGroup.css +15 -8
  6. package/dist/Backdrop/Backdrop.css +2 -1
  7. package/dist/Badge/Badge.css +27 -17
  8. package/dist/Breadcrumb/Breadcrumb.css +34 -0
  9. package/dist/Breadcrumb/Breadcrumb.d.ts +5 -0
  10. package/dist/Breadcrumb/Breadcrumb.js +128 -0
  11. package/dist/Breadcrumb/Breadcrumb.types.d.ts +49 -0
  12. package/dist/Breadcrumb/Breadcrumb.types.js +15 -0
  13. package/dist/Breadcrumb/BreadcrumbItem.d.ts +4 -0
  14. package/dist/Breadcrumb/BreadcrumbItem.js +78 -0
  15. package/dist/Breadcrumb/index.d.ts +4 -0
  16. package/dist/Breadcrumb/index.js +45 -0
  17. package/dist/Button/Button.css +26 -17
  18. package/dist/Calendar/Calendar.css +33 -18
  19. package/dist/Calendar/Calendar.d.ts +1 -1
  20. package/dist/Calendar/Calendar.js +85 -18
  21. package/dist/Calendar/Calendar.types.d.ts +33 -0
  22. package/dist/Card/CardFooter.css +2 -1
  23. package/dist/Card/CardHeader.css +3 -1
  24. package/dist/Checkbox/Checkbox.css +7 -5
  25. package/dist/CitySelector/CitySelector.css +29 -15
  26. package/dist/CitySelector/CitySelectorCore.js +25 -16
  27. package/dist/CitySelector/Selector/index.css +4 -4
  28. package/dist/Collapse/Collapse.css +6 -0
  29. package/dist/Collapse/Collapse.d.ts +5 -0
  30. package/dist/Collapse/Collapse.js +165 -0
  31. package/dist/Collapse/Collapse.types.d.ts +16 -0
  32. package/dist/Collapse/Collapse.types.js +15 -0
  33. package/dist/Collapse/index.d.ts +2 -0
  34. package/dist/Collapse/index.js +41 -0
  35. package/dist/CollapsePanel/CollapsePanel.css +32 -0
  36. package/dist/CollapsePanel/CollapsePanel.d.ts +5 -0
  37. package/dist/CollapsePanel/CollapsePanel.js +159 -0
  38. package/dist/CollapsePanel/CollapsePanel.types.d.ts +64 -0
  39. package/dist/CollapsePanel/CollapsePanel.types.js +15 -0
  40. package/dist/CollapsePanel/CollapsePanelItem.d.ts +4 -0
  41. package/dist/CollapsePanel/CollapsePanelItem.js +112 -0
  42. package/dist/CollapsePanel/index.d.ts +4 -0
  43. package/dist/CollapsePanel/index.js +45 -0
  44. package/dist/Countdown/Countdown.css +2 -1
  45. package/dist/Countdown/Countdown.js +3 -0
  46. package/dist/Dialog/Dialog.d.ts +5 -0
  47. package/dist/Dialog/Dialog.js +152 -0
  48. package/dist/Dialog/Dialog.types.d.ts +109 -0
  49. package/dist/Dialog/Dialog.types.js +15 -0
  50. package/dist/Dialog/FunctionalDialog.d.ts +3 -0
  51. package/dist/Dialog/FunctionalDialog.js +204 -0
  52. package/dist/Dialog/index.css +75 -0
  53. package/dist/Dialog/index.d.ts +2 -0
  54. package/dist/Dialog/index.js +41 -0
  55. package/dist/Divider/Divider.css +6 -4
  56. package/dist/IconButton/IconButton.css +9 -7
  57. package/dist/Image/index.css +2 -1
  58. package/dist/Input/Input.css +10 -5
  59. package/dist/List/List.css +3 -0
  60. package/dist/List/ListItem.css +3 -3
  61. package/dist/List/ListItemContent.css +1 -1
  62. package/dist/Loading/Loading.css +4 -2
  63. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  64. package/dist/NavBar/NavBar.css +9 -5
  65. package/dist/Picker/Picker.css +25 -29
  66. package/dist/Picker/Picker.js +31 -11
  67. package/dist/Picker/Picker.types.d.ts +4 -0
  68. package/dist/Picker/PickerPanel.css +8 -8
  69. package/dist/Picker/PickerPanel.js +14 -8
  70. package/dist/Picker/utils.d.ts +16 -0
  71. package/dist/Picker/utils.js +32 -2
  72. package/dist/Popover/Popover.css +97 -0
  73. package/dist/Popover/Popover.d.ts +5 -0
  74. package/dist/Popover/Popover.js +186 -0
  75. package/dist/Popover/Popover.types.d.ts +60 -0
  76. package/dist/Popover/Popover.types.js +15 -0
  77. package/dist/Popover/index.d.ts +2 -0
  78. package/dist/Popover/index.js +41 -0
  79. package/dist/Portal/Portal.types.d.ts +4 -0
  80. package/dist/Portal/PortalCore.js +8 -1
  81. package/dist/Progress/Progress.css +8 -6
  82. package/dist/Radio/Radio.css +2 -1
  83. package/dist/Radio/Radio.js +1 -1
  84. package/dist/Radio/RadioButtonIcon.d.ts +1 -6
  85. package/dist/Radio/RadioButtonIcon.js +0 -3
  86. package/dist/Rating/Rating.css +8 -4
  87. package/dist/Select/Select.css +21 -10
  88. package/dist/Select/Select.js +1 -1
  89. package/dist/Select/SelectOption.js +3 -0
  90. package/dist/Skeleton/Skeleton.css +3 -2
  91. package/dist/Slider/Slider.css +24 -13
  92. package/dist/Steps/Step.css +11 -11
  93. package/dist/Steps/Steps.css +14 -5
  94. package/dist/Swiper/Swiper.css +2 -1
  95. package/dist/Switch/Switch.css +31 -16
  96. package/dist/TabBar/TabBar.css +7 -3
  97. package/dist/TabBar/TabBarItem.css +0 -1
  98. package/dist/Tabs/Tab.css +2 -6
  99. package/dist/Tabs/Tabs.css +7 -4
  100. package/dist/Tag/Tag.css +7 -10
  101. package/dist/Tag/TagGroup.css +9 -1
  102. package/dist/TextArea/TextArea.css +14 -8
  103. package/dist/ThemeProvider/ThemeProvider.d.ts +4 -0
  104. package/dist/ThemeProvider/ThemeProvider.js +90 -0
  105. package/dist/ThemeProvider/ThemeProvider.types.d.ts +127 -0
  106. package/dist/ThemeProvider/ThemeProvider.types.js +27 -0
  107. package/dist/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
  108. package/dist/ThemeProvider/hooks/ThemeContext.js +35 -0
  109. package/dist/ThemeProvider/hooks/createTheme.d.ts +2 -0
  110. package/dist/ThemeProvider/hooks/createTheme.js +55 -0
  111. package/dist/ThemeProvider/hooks/index.d.ts +4 -0
  112. package/dist/ThemeProvider/hooks/index.js +43 -0
  113. package/dist/ThemeProvider/hooks/useTheme.d.ts +1 -0
  114. package/dist/ThemeProvider/hooks/useTheme.js +39 -0
  115. package/dist/ThemeProvider/index.d.ts +4 -0
  116. package/dist/ThemeProvider/index.js +45 -0
  117. package/dist/ThemeProvider/utils/constants.d.ts +38 -0
  118. package/dist/ThemeProvider/utils/constants.js +65 -0
  119. package/dist/ThemeProvider/utils/index.d.ts +2 -0
  120. package/dist/ThemeProvider/utils/index.js +23 -0
  121. package/dist/ThemeProvider/utils/mountTokens.d.ts +26 -0
  122. package/dist/ThemeProvider/utils/mountTokens.js +123 -0
  123. package/dist/Toast/FunctionalToast.d.ts +3 -0
  124. package/dist/Toast/FunctionalToast.js +177 -0
  125. package/dist/Toast/Toast.css +56 -0
  126. package/dist/Toast/Toast.d.ts +5 -0
  127. package/dist/Toast/Toast.js +121 -0
  128. package/dist/Toast/Toast.types.d.ts +101 -0
  129. package/dist/Toast/Toast.types.js +15 -0
  130. package/dist/Toast/index.d.ts +2 -0
  131. package/dist/Toast/index.js +41 -0
  132. package/dist/Tooltip/Tooltip.css +91 -0
  133. package/dist/Tooltip/Tooltip.d.ts +5 -0
  134. package/dist/Tooltip/Tooltip.js +177 -0
  135. package/dist/Tooltip/Tooltip.types.d.ts +51 -0
  136. package/dist/Tooltip/Tooltip.types.js +15 -0
  137. package/dist/Tooltip/index.d.ts +2 -0
  138. package/dist/Tooltip/index.js +41 -0
  139. package/dist/Transition/Transition.miniapp.js +7 -1
  140. package/dist/index.d.ts +9 -0
  141. package/dist/index.js +19 -1
  142. package/dist/locales/base.d.ts +40 -0
  143. package/dist/locales/base.js +15 -0
  144. package/dist/locales/en-US.d.ts +3 -0
  145. package/dist/locales/en-US.js +69 -0
  146. package/dist/locales/hooks/useLocaleText.d.ts +3 -0
  147. package/dist/locales/hooks/useLocaleText.js +43 -0
  148. package/dist/locales/index.d.ts +5 -0
  149. package/dist/locales/index.js +49 -0
  150. package/dist/locales/zh-CN.d.ts +3 -0
  151. package/dist/locales/zh-CN.js +51 -0
  152. package/dist/locales/zh-TW.d.ts +3 -0
  153. package/dist/locales/zh-TW.js +51 -0
  154. package/es/ActionSheet/ActionSheet.css +6 -3
  155. package/es/ActionSheet/ActionSheetItem.css +10 -6
  156. package/es/Alert/index.css +14 -8
  157. package/es/Avatar/Avatar.css +13 -9
  158. package/es/Avatar/AvatarGroup.css +15 -8
  159. package/es/Backdrop/Backdrop.css +2 -1
  160. package/es/Badge/Badge.css +27 -17
  161. package/es/Breadcrumb/Breadcrumb.css +34 -0
  162. package/es/Breadcrumb/Breadcrumb.d.ts +5 -0
  163. package/es/Breadcrumb/Breadcrumb.js +101 -0
  164. package/es/Breadcrumb/Breadcrumb.types.d.ts +49 -0
  165. package/es/Breadcrumb/Breadcrumb.types.js +1 -0
  166. package/es/Breadcrumb/BreadcrumbItem.d.ts +4 -0
  167. package/es/Breadcrumb/BreadcrumbItem.js +51 -0
  168. package/es/Breadcrumb/index.d.ts +4 -0
  169. package/es/Breadcrumb/index.js +9 -0
  170. package/es/Button/Button.css +26 -17
  171. package/es/Calendar/Calendar.css +33 -18
  172. package/es/Calendar/Calendar.d.ts +1 -1
  173. package/es/Calendar/Calendar.js +91 -19
  174. package/es/Calendar/Calendar.types.d.ts +33 -0
  175. package/es/Card/CardFooter.css +2 -1
  176. package/es/Card/CardHeader.css +3 -1
  177. package/es/Checkbox/Checkbox.css +7 -5
  178. package/es/CitySelector/CitySelector.css +29 -15
  179. package/es/CitySelector/CitySelectorCore.js +25 -16
  180. package/es/CitySelector/Selector/index.css +4 -4
  181. package/es/Collapse/Collapse.css +6 -0
  182. package/es/Collapse/Collapse.d.ts +5 -0
  183. package/es/Collapse/Collapse.js +144 -0
  184. package/es/Collapse/Collapse.types.d.ts +16 -0
  185. package/es/Collapse/Collapse.types.js +1 -0
  186. package/es/Collapse/index.d.ts +2 -0
  187. package/es/Collapse/index.js +6 -0
  188. package/es/CollapsePanel/CollapsePanel.css +32 -0
  189. package/es/CollapsePanel/CollapsePanel.d.ts +5 -0
  190. package/es/CollapsePanel/CollapsePanel.js +132 -0
  191. package/es/CollapsePanel/CollapsePanel.types.d.ts +64 -0
  192. package/es/CollapsePanel/CollapsePanel.types.js +1 -0
  193. package/es/CollapsePanel/CollapsePanelItem.d.ts +4 -0
  194. package/es/CollapsePanel/CollapsePanelItem.js +85 -0
  195. package/es/CollapsePanel/index.d.ts +4 -0
  196. package/es/CollapsePanel/index.js +9 -0
  197. package/es/Countdown/Countdown.css +2 -1
  198. package/es/Countdown/Countdown.js +3 -0
  199. package/es/Dialog/Dialog.d.ts +5 -0
  200. package/es/Dialog/Dialog.js +125 -0
  201. package/es/Dialog/Dialog.types.d.ts +109 -0
  202. package/es/Dialog/Dialog.types.js +1 -0
  203. package/es/Dialog/FunctionalDialog.d.ts +3 -0
  204. package/es/Dialog/FunctionalDialog.js +177 -0
  205. package/es/Dialog/index.css +75 -0
  206. package/es/Dialog/index.d.ts +2 -0
  207. package/es/Dialog/index.js +6 -0
  208. package/es/Divider/Divider.css +6 -4
  209. package/es/IconButton/IconButton.css +9 -7
  210. package/es/Image/index.css +2 -1
  211. package/es/Input/Input.css +10 -5
  212. package/es/List/List.css +3 -0
  213. package/es/List/ListItem.css +3 -3
  214. package/es/List/ListItemContent.css +1 -1
  215. package/es/Loading/Loading.css +4 -2
  216. package/es/Modal/Modal.miniapp.d.ts +1 -1
  217. package/es/NavBar/NavBar.css +9 -5
  218. package/es/Picker/Picker.css +25 -29
  219. package/es/Picker/Picker.js +32 -12
  220. package/es/Picker/Picker.types.d.ts +4 -0
  221. package/es/Picker/PickerPanel.css +8 -8
  222. package/es/Picker/PickerPanel.js +14 -8
  223. package/es/Picker/utils.d.ts +16 -0
  224. package/es/Picker/utils.js +29 -1
  225. package/es/Popover/Popover.css +97 -0
  226. package/es/Popover/Popover.d.ts +5 -0
  227. package/es/Popover/Popover.js +159 -0
  228. package/es/Popover/Popover.types.d.ts +60 -0
  229. package/es/Popover/Popover.types.js +1 -0
  230. package/es/Popover/index.d.ts +2 -0
  231. package/es/Popover/index.js +6 -0
  232. package/es/Portal/Portal.types.d.ts +4 -0
  233. package/es/Portal/PortalCore.js +8 -1
  234. package/es/Progress/Progress.css +8 -6
  235. package/es/Radio/Radio.css +2 -1
  236. package/es/Radio/Radio.js +1 -1
  237. package/es/Radio/RadioButtonIcon.d.ts +1 -6
  238. package/es/Radio/RadioButtonIcon.js +0 -3
  239. package/es/Rating/Rating.css +8 -4
  240. package/es/Select/Select.css +21 -10
  241. package/es/Select/Select.js +1 -1
  242. package/es/Select/SelectOption.js +3 -0
  243. package/es/Skeleton/Skeleton.css +3 -2
  244. package/es/Slider/Slider.css +24 -13
  245. package/es/Steps/Step.css +11 -11
  246. package/es/Steps/Steps.css +14 -5
  247. package/es/Swiper/Swiper.css +2 -1
  248. package/es/Switch/Switch.css +31 -16
  249. package/es/TabBar/TabBar.css +7 -3
  250. package/es/TabBar/TabBarItem.css +0 -1
  251. package/es/Tabs/Tab.css +2 -6
  252. package/es/Tabs/Tabs.css +7 -4
  253. package/es/Tag/Tag.css +7 -10
  254. package/es/Tag/TagGroup.css +9 -1
  255. package/es/TextArea/TextArea.css +14 -8
  256. package/es/ThemeProvider/ThemeProvider.d.ts +4 -0
  257. package/es/ThemeProvider/ThemeProvider.js +61 -0
  258. package/es/ThemeProvider/ThemeProvider.types.d.ts +127 -0
  259. package/es/ThemeProvider/ThemeProvider.types.js +1 -0
  260. package/es/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
  261. package/es/ThemeProvider/hooks/ThemeContext.js +6 -0
  262. package/es/ThemeProvider/hooks/createTheme.d.ts +2 -0
  263. package/es/ThemeProvider/hooks/createTheme.js +38 -0
  264. package/es/ThemeProvider/hooks/index.d.ts +4 -0
  265. package/es/ThemeProvider/hooks/index.js +8 -0
  266. package/es/ThemeProvider/hooks/useTheme.d.ts +1 -0
  267. package/es/ThemeProvider/hooks/useTheme.js +10 -0
  268. package/es/ThemeProvider/index.d.ts +4 -0
  269. package/es/ThemeProvider/index.js +8 -0
  270. package/es/ThemeProvider/utils/constants.d.ts +38 -0
  271. package/es/ThemeProvider/utils/constants.js +40 -0
  272. package/es/ThemeProvider/utils/index.d.ts +2 -0
  273. package/es/ThemeProvider/utils/index.js +2 -0
  274. package/es/ThemeProvider/utils/mountTokens.d.ts +26 -0
  275. package/es/ThemeProvider/utils/mountTokens.js +88 -0
  276. package/es/Toast/FunctionalToast.d.ts +3 -0
  277. package/es/Toast/FunctionalToast.js +150 -0
  278. package/es/Toast/Toast.css +56 -0
  279. package/es/Toast/Toast.d.ts +5 -0
  280. package/es/Toast/Toast.js +99 -0
  281. package/es/Toast/Toast.types.d.ts +101 -0
  282. package/es/Toast/Toast.types.js +1 -0
  283. package/es/Toast/index.d.ts +2 -0
  284. package/es/Toast/index.js +6 -0
  285. package/es/Tooltip/Tooltip.css +91 -0
  286. package/es/Tooltip/Tooltip.d.ts +5 -0
  287. package/es/Tooltip/Tooltip.js +150 -0
  288. package/es/Tooltip/Tooltip.types.d.ts +51 -0
  289. package/es/Tooltip/Tooltip.types.js +1 -0
  290. package/es/Tooltip/index.d.ts +2 -0
  291. package/es/Tooltip/index.js +6 -0
  292. package/es/Transition/Transition.miniapp.js +7 -1
  293. package/es/index.d.ts +9 -0
  294. package/es/index.js +9 -0
  295. package/es/locales/base.d.ts +40 -0
  296. package/es/locales/base.js +0 -0
  297. package/es/locales/en-US.d.ts +3 -0
  298. package/es/locales/en-US.js +50 -0
  299. package/es/locales/hooks/useLocaleText.d.ts +3 -0
  300. package/es/locales/hooks/useLocaleText.js +26 -0
  301. package/es/locales/index.d.ts +5 -0
  302. package/es/locales/index.js +11 -0
  303. package/es/locales/zh-CN.d.ts +3 -0
  304. package/es/locales/zh-CN.js +32 -0
  305. package/es/locales/zh-TW.d.ts +3 -0
  306. package/es/locales/zh-TW.js +32 -0
  307. package/package.json +5 -5
@@ -0,0 +1,26 @@
1
+ import { ThemeProps, MountResponsiveTokenOptions, BuiltInThemesTokenOptions } from '../ThemeProvider.types';
2
+ /**
3
+ * 挂载响应式自定义Tokens
4
+ * 响应式相关的Tokens挂载在全局根节点上,暗黑模式或大麦高亮主题下可自定义额外Toekns复写响应式Tokens
5
+ */
6
+ export declare const mountResponsiveTokens: (options: MountResponsiveTokenOptions) => void;
7
+ /**
8
+ * 复写内置主题Tokens,复写的自定义token应为对应主题css变量的子集
9
+ * BUI内置主题包括以下4种:
10
+ * 1. 默认高亮模式(defaultLightToken 复写 default-light.less)
11
+ * 2. 默认暗黑模式(defaultDarkToken 复写 default-dark.less)
12
+ * 3. 大麦高亮模式(dmLightToken 复写 dm-light.less)
13
+ * 4. 大麦暗黑模式(dmDarkToken 复写 dm-dark.less)
14
+ */
15
+ export declare const overrideBuiltInThemes: (tokenOptions: BuiltInThemesTokenOptions) => void;
16
+ /**
17
+ * 挂载Design Tokens
18
+ * Tokens的优先级:
19
+ * 1. 通常情况:组件的Tokens > 响应式Tokens > BUI内置Tokens(挂载顺序控制)
20
+ * 2. 暗黑模式:组件的Tokens > BUI内置的两种暗黑模式Tokens > 响应式Tokens (选择器权重控制)
21
+ *
22
+ * - 挂载顺序决定BUI内置Tokens(暗黑模式除外)和响应式Tokens的优先级
23
+ * - 选择器权重决定暗黑模式的Tokens和响应式Tokens的优先级
24
+ * - 命名规则决定组件的Tokens(如:--bui-button-xxx)
25
+ */
26
+ export declare const mountTokens: (tokenOptions?: ThemeProps) => void;
@@ -0,0 +1,88 @@
1
+ import React from "react";
2
+ import { isMini } from "@bifrostui/utils";
3
+ import { breakpoints as defaultBreakpoints, rootSelector } from "./constants";
4
+ const updateTokens = (options) => {
5
+ const { isRoot, rootString, container, containerId } = options || {};
6
+ if (isMini)
7
+ return;
8
+ const style = document.createElement("style");
9
+ style.type = "text/css";
10
+ style.appendChild(document.createTextNode(rootString));
11
+ let containerNode;
12
+ if (isRoot) {
13
+ containerNode = document.head;
14
+ } else if (containerId && container && React.isValidElement(container)) {
15
+ containerNode = document.querySelector(`.${containerId}`);
16
+ }
17
+ if (containerNode) {
18
+ containerNode.appendChild(style);
19
+ }
20
+ };
21
+ const mountResponsiveTokens = (options) => {
22
+ const { responsive, breakpoints = defaultBreakpoints } = options || {};
23
+ if (!responsive)
24
+ return;
25
+ const modeSelector = rootSelector.defaultLight;
26
+ let rootString = `${modeSelector.join(",")} { `;
27
+ Object.entries(responsive).forEach((config) => {
28
+ const [size, tokenConfig] = config || [];
29
+ if (!size || !tokenConfig)
30
+ return;
31
+ const cssVariablesString = Object.entries(tokenConfig || {}).reduce(
32
+ (acc, [key, value]) => {
33
+ return `${acc} ${key}: ${value};`;
34
+ },
35
+ ""
36
+ );
37
+ const mediaQuery = size === "xs" ? "max-width" : "min-width";
38
+ rootString += `@media (${mediaQuery}: ${breakpoints[size]}) { ${cssVariablesString} }`;
39
+ });
40
+ rootString = `${rootString} }`;
41
+ updateTokens({ isRoot: true, rootString });
42
+ };
43
+ const overrideBuiltInThemes = (tokenOptions) => {
44
+ if (!tokenOptions)
45
+ return;
46
+ Object.keys(rootSelector).forEach((selectorKey) => {
47
+ const modeSelector = rootSelector[selectorKey];
48
+ const token = tokenOptions[`${selectorKey}Token`];
49
+ if (token) {
50
+ let rootString = `${modeSelector.join(",")} { `;
51
+ const cssVariablesString = Object.entries(token).reduce(
52
+ (acc, [key, value]) => {
53
+ return `${acc} ${key}: ${value};`;
54
+ },
55
+ ""
56
+ );
57
+ rootString = `${rootString} ${cssVariablesString} }`;
58
+ updateTokens({ isRoot: true, rootString });
59
+ }
60
+ });
61
+ };
62
+ const mountComponentsTokens = (options) => {
63
+ const { isRoot = false, token, container, containerId } = options || {};
64
+ if (!token)
65
+ return;
66
+ const modeSelector = isRoot ? rootSelector.defaultLight : [`.${containerId}`];
67
+ let rootString = `${modeSelector.join(",")} { `;
68
+ const cssVariablesString = Object.entries(token).reduce(
69
+ (acc, [key, value]) => {
70
+ return `${acc} ${key}: ${value};`;
71
+ },
72
+ ""
73
+ );
74
+ rootString = `${rootString} ${cssVariablesString} }`;
75
+ updateTokens({ isRoot, rootString, container, containerId });
76
+ };
77
+ const mountTokens = (tokenOptions) => {
78
+ if (isMini)
79
+ return;
80
+ overrideBuiltInThemes(tokenOptions);
81
+ mountResponsiveTokens(tokenOptions);
82
+ mountComponentsTokens(tokenOptions);
83
+ };
84
+ export {
85
+ mountResponsiveTokens,
86
+ mountTokens,
87
+ overrideBuiltInThemes
88
+ };
@@ -0,0 +1,3 @@
1
+ import { ToastInstance } from './Toast.types';
2
+ declare const Toast: ToastInstance;
3
+ export default Toast;
@@ -0,0 +1,150 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { render, unmount, getRootElement } from "@bifrostui/utils";
33
+ import React, { useCallback, useEffect, useState } from "react";
34
+ import ToastView from "./Toast";
35
+ const toastCloses = [];
36
+ const formatProps = (props) => {
37
+ if (typeof props === "string") {
38
+ return { message: props };
39
+ }
40
+ return props;
41
+ };
42
+ const destroyAll = () => {
43
+ let closeToast = toastCloses.pop();
44
+ while (closeToast) {
45
+ closeToast();
46
+ closeToast = toastCloses.pop();
47
+ }
48
+ };
49
+ const functionalToast = (props) => {
50
+ const options = __spreadValues({
51
+ duration: 2e3,
52
+ position: "center",
53
+ allowMultiple: false,
54
+ disableClick: false
55
+ }, formatProps(props));
56
+ const instance = {
57
+ close: () => null
58
+ };
59
+ const rootWrapper = document.createElement("div");
60
+ if (options.disableClick) {
61
+ const styles = {
62
+ position: "fixed",
63
+ top: "0",
64
+ bottom: "0",
65
+ left: "0",
66
+ right: "0",
67
+ zIndex: "var(--bui-z-index-toast)"
68
+ };
69
+ Object.keys(styles).forEach((property) => {
70
+ rootWrapper.style[property] = styles[property];
71
+ });
72
+ }
73
+ const rootElement = getRootElement();
74
+ rootElement.appendChild(rootWrapper);
75
+ const ToastComponent = () => {
76
+ const _a = options, { duration, allowMultiple, onClose } = _a, others = __objRest(_a, ["duration", "allowMultiple", "onClose"]);
77
+ const [open, setOpen] = useState(false);
78
+ let timer;
79
+ const fadeTimeout = {
80
+ enter: 350,
81
+ exit: 150
82
+ };
83
+ const close = useCallback(() => {
84
+ setOpen(false);
85
+ setTimeout(() => {
86
+ const unmountRes = unmount(rootWrapper);
87
+ if (unmountRes && rootWrapper.parentNode) {
88
+ rootWrapper.parentNode.removeChild(rootWrapper);
89
+ }
90
+ }, fadeTimeout.exit);
91
+ onClose == null ? void 0 : onClose();
92
+ }, [rootWrapper]);
93
+ useEffect(() => {
94
+ setOpen(true);
95
+ if (!allowMultiple)
96
+ destroyAll();
97
+ toastCloses.push(close);
98
+ if (duration !== 0 && typeof duration === "number") {
99
+ timer = setTimeout(close, duration);
100
+ }
101
+ return () => {
102
+ clearTimeout(timer);
103
+ };
104
+ }, []);
105
+ instance.close = close;
106
+ return /* @__PURE__ */ React.createElement(
107
+ ToastView,
108
+ __spreadProps(__spreadValues({}, others), {
109
+ open,
110
+ timeout: fadeTimeout,
111
+ onClose: close
112
+ })
113
+ );
114
+ };
115
+ render(/* @__PURE__ */ React.createElement(ToastComponent, null), rootWrapper);
116
+ return instance;
117
+ };
118
+ ["warning", "loading", "success", "fail"].forEach((methodName) => {
119
+ functionalToast[methodName] = (options) => functionalToast(__spreadValues({
120
+ type: methodName
121
+ }, formatProps(options)));
122
+ });
123
+ functionalToast.clear = () => {
124
+ setTimeout(() => {
125
+ destroyAll();
126
+ });
127
+ };
128
+ const useToast = () => {
129
+ const holderRef = React.useRef(null);
130
+ ["warning", "loading", "success", "fail"].forEach((methodName) => {
131
+ functionalToast[methodName] = (options) => functionalToast(__spreadProps(__spreadValues({
132
+ type: methodName
133
+ }, formatProps(options)), {
134
+ theme: holderRef.current.theme
135
+ }));
136
+ });
137
+ functionalToast.clear = () => {
138
+ setTimeout(() => {
139
+ destroyAll();
140
+ });
141
+ };
142
+ const wrapAPI = functionalToast;
143
+ return [wrapAPI, /* @__PURE__ */ React.createElement(ToastView, { key: "toast-holder", ref: holderRef })];
144
+ };
145
+ functionalToast.useToast = useToast;
146
+ const Toast = functionalToast;
147
+ var FunctionalToast_default = Toast;
148
+ export {
149
+ FunctionalToast_default as default
150
+ };
@@ -0,0 +1,56 @@
1
+ .bui-toast {
2
+ --min-width: var(--bui-toast-min-width, 86px);
3
+ --max-width: var(--bui-toast-max-width, 80%);
4
+ --flex-direction: var(--bui-toast-flex-direction, column);
5
+ --padding: var(--bui-toast-padding, var(--bui-spacing-xl));
6
+ --word-break: break-all;
7
+ --z-index: var(--bui-z-index-toast);
8
+ --position-top: var(--bui-toast-position-top, 15%);
9
+ --position-bottom: var(--bui-toast-position-bottom, 85%);
10
+ --background-color: var(--bui-toast-bg-color, rgba(0, 0, 0, 0.8));
11
+ --border-radius: var(--bui-toast-border-radius, --bui-shape-radius-default);
12
+ --icon-margin: var(--bui-toast-icon-margin-bottom, 8px);
13
+ --icon-font-size: var(--bui-toast-icon-font-size, 30px);
14
+ --text-align: center;
15
+ position: fixed;
16
+ left: 50%;
17
+ z-index: var(--z-index);
18
+ width: fit-content;
19
+ min-width: var(--min-width);
20
+ max-width: var(--max-width);
21
+ padding: var(--padding);
22
+ font-size: var(--bui-text-size-1);
23
+ color: var(--bui-color-white);
24
+ border-radius: var(--border-radius);
25
+ word-break: var(--word-break);
26
+ white-space: pre-wrap;
27
+ background-color: var(--background-color);
28
+ text-align: var(--text-align);
29
+ font-family: var(--bui-font-family);
30
+ }
31
+ .bui-toast.bui-toast-allow-click {
32
+ position: fixed;
33
+ right: unset;
34
+ bottom: unset;
35
+ }
36
+ .bui-toast-center {
37
+ top: 50%;
38
+ transform: translate(-50%, -50%);
39
+ }
40
+ .bui-toast-top {
41
+ top: var(--position-top);
42
+ transform: translate(-50%, calc(-1 * var(--position-top)));
43
+ }
44
+ .bui-toast-bottom {
45
+ top: var(--position-bottom);
46
+ transform: translate(-50%, calc(-1 * var(--position-bottom)));
47
+ }
48
+ .bui-toast-icon {
49
+ display: flex;
50
+ flex-direction: var(--flex-direction);
51
+ align-items: center;
52
+ }
53
+ .bui-toast-icon .bui-svg-icon {
54
+ margin: 0 0 var(--icon-margin);
55
+ font-size: var(--icon-font-size);
56
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ToastProps, ToastRef } from './Toast.types';
3
+ import './Toast.less';
4
+ declare const ToastComponent: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<ToastRef>>;
5
+ export default ToastComponent;
@@ -0,0 +1,99 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import clsx from "clsx";
33
+ import React, { useImperativeHandle } from "react";
34
+ import {
35
+ ErrorCircleFilledBoldIcon,
36
+ AccessTimeCircleFilledBoldIcon,
37
+ AlertCircleFilledBoldIcon,
38
+ SuccessCircleFilledBoldIcon
39
+ } from "@bifrostui/icons";
40
+ import Fade from "../Fade";
41
+ import { useTheme } from "../ThemeProvider";
42
+ import "./Toast.css";
43
+ const prefixCls = "bui-toast";
44
+ const ToastComponent = /* @__PURE__ */ React.forwardRef((props, ref) => {
45
+ const _a = props, {
46
+ className,
47
+ style,
48
+ open,
49
+ type,
50
+ icon,
51
+ message,
52
+ position = "center",
53
+ disableClick = false,
54
+ theme
55
+ } = _a, others = __objRest(_a, [
56
+ "className",
57
+ "style",
58
+ "open",
59
+ "type",
60
+ "icon",
61
+ "message",
62
+ "position",
63
+ "disableClick",
64
+ "theme"
65
+ ]);
66
+ const themeConfig = useTheme(theme);
67
+ useImperativeHandle(ref, () => {
68
+ return { theme: themeConfig };
69
+ }, []);
70
+ const iconMap = {
71
+ fail: /* @__PURE__ */ React.createElement(ErrorCircleFilledBoldIcon, { htmlColor: "#ffffff" }),
72
+ loading: /* @__PURE__ */ React.createElement(AccessTimeCircleFilledBoldIcon, { htmlColor: "#ffffff" }),
73
+ warning: /* @__PURE__ */ React.createElement(AlertCircleFilledBoldIcon, { htmlColor: "#ffffff" }),
74
+ success: /* @__PURE__ */ React.createElement(SuccessCircleFilledBoldIcon, { htmlColor: "#ffffff" })
75
+ };
76
+ const iconDom = iconMap[type] || icon;
77
+ return /* @__PURE__ */ React.createElement(Fade, __spreadProps(__spreadValues({}, others), { in: open, appear: false, unmountOnExit: true }), /* @__PURE__ */ React.createElement(
78
+ "div",
79
+ {
80
+ className: clsx(
81
+ prefixCls,
82
+ `${prefixCls}-${position}`,
83
+ {
84
+ [`${prefixCls}-icon`]: !!iconDom,
85
+ [`${prefixCls}-allow-click`]: !disableClick
86
+ },
87
+ className
88
+ ),
89
+ style
90
+ },
91
+ iconDom,
92
+ message
93
+ ));
94
+ });
95
+ ToastComponent.displayName = "BuiToast";
96
+ var Toast_default = ToastComponent;
97
+ export {
98
+ Toast_default as default
99
+ };
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import { FadeProps } from '../Fade/Fade.types';
3
+ import { ThemeProps } from '../ThemeProvider/ThemeProvider.types';
4
+ export type ToastRef = {
5
+ theme?: ThemeProps;
6
+ };
7
+ /**
8
+ * 提示类型
9
+ */
10
+ export type ToastType = 'loading' | 'success' | 'fail' | 'warning';
11
+ export interface ToastProps extends FadeProps {
12
+ /**
13
+ * 是否展示
14
+ */
15
+ open?: boolean;
16
+ /**
17
+ * 提示类型
18
+ */
19
+ type?: ToastType;
20
+ /**
21
+ * toast内容,支持使用`\n`换行
22
+ */
23
+ message?: string;
24
+ /**
25
+ * 展示时长(ms),值为 0 时,toast 不会消失
26
+ * @default 2000
27
+ */
28
+ duration?: number;
29
+ /**
30
+ * 展示位置
31
+ * @default center
32
+ */
33
+ position?: 'top' | 'center' | 'bottom';
34
+ /**
35
+ * 是否允许同时存在多个Toast
36
+ * @default false
37
+ */
38
+ allowMultiple?: boolean;
39
+ /**
40
+ * 自定义图标
41
+ */
42
+ icon?: React.ReactNode;
43
+ /**
44
+ * theme 主题定制
45
+ */
46
+ theme?: ThemeProps;
47
+ /**
48
+ * 展示Toast时,页面内容是否可以点击
49
+ * @default false
50
+ */
51
+ disableClick?: boolean;
52
+ /**
53
+ * 关闭时的回调函数
54
+ */
55
+ onClose?: () => void;
56
+ }
57
+ /**
58
+ * 函数式调用配置参数
59
+ */
60
+ export type ToastOptions = Omit<ToastProps, 'type' | 'open'> | string;
61
+ /**
62
+ * 函数式调用返回值类型
63
+ */
64
+ export type ToastReturnType = {
65
+ /**
66
+ * 关闭当前提示
67
+ */
68
+ close: () => void;
69
+ };
70
+ /**
71
+ * Toast Instance
72
+ */
73
+ export interface ToastFunction {
74
+ (options: ToastOptions): ToastReturnType;
75
+ /**
76
+ * 警告提示
77
+ */
78
+ warning: (options: ToastOptions) => ToastReturnType;
79
+ /**
80
+ * 加载提示
81
+ */
82
+ loading: (options: ToastOptions) => ToastReturnType;
83
+ /**
84
+ * 成功提示
85
+ */
86
+ success: (options: ToastOptions) => ToastReturnType;
87
+ /**
88
+ * 失败提示
89
+ */
90
+ fail: (options: ToastOptions) => ToastReturnType;
91
+ /**
92
+ * 清空提示
93
+ */
94
+ clear: () => void;
95
+ }
96
+ export interface ToastInstance extends ToastFunction {
97
+ /**
98
+ * 获取toast静态方法 & contextHolder
99
+ */
100
+ useToast: () => [ToastFunction, React.JSX.Element];
101
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default, default as Toast } from './FunctionalToast';
2
+ export * from './Toast.types';
@@ -0,0 +1,6 @@
1
+ import { default as default2, default as default3 } from "./FunctionalToast";
2
+ export * from "./Toast.types";
3
+ export {
4
+ default3 as Toast,
5
+ default2 as default
6
+ };
@@ -0,0 +1,91 @@
1
+ .bui-tooltip {
2
+ --arrow-size: var(--bui-tooltip-arrow-size, 8px);
3
+ --localtion-position: var(--bui-tooltip-localtion-position, 8px);
4
+ --max-width: var(--bui-tooltip-max-width, 350px);
5
+ --content-min-width: var(--bui-tooltip-content-min-width, 30px);
6
+ --content-min-height: var(--bui-tooltip-content-min-height, 32px);
7
+ --content-padding: var(--bui-tooltip-content-padding, 6px 8px);
8
+ max-width: var(--max-width);
9
+ font-size: var(--bui-text-size-1);
10
+ position: absolute;
11
+ visibility: hidden;
12
+ z-index: var(--bui-z-index-tooltip);
13
+ }
14
+ .bui-tooltip .bui-tooltip-arrow {
15
+ width: 0;
16
+ height: 0;
17
+ position: absolute;
18
+ }
19
+ .bui-tooltip .bui-tooltip-arrow.location-left {
20
+ left: var(--localtion-position);
21
+ }
22
+ .bui-tooltip .bui-tooltip-arrow.location-right {
23
+ right: var(--localtion-position);
24
+ }
25
+ .bui-tooltip .bui-tooltip-arrow.location-top {
26
+ top: var(--localtion-position);
27
+ }
28
+ .bui-tooltip .bui-tooltip-arrow.location-bottom {
29
+ bottom: var(--localtion-position);
30
+ }
31
+ .bui-tooltip.tooltip-top .location-center,
32
+ .bui-tooltip.tooltip-bottom .location-center {
33
+ left: 50%;
34
+ transform: translateX(-50%);
35
+ }
36
+ .bui-tooltip.tooltip-left .location-center,
37
+ .bui-tooltip.tooltip-right .location-center {
38
+ top: 50%;
39
+ transform: translateY(-50%);
40
+ }
41
+ .bui-tooltip.tooltip-top {
42
+ padding-bottom: var(--arrow-size);
43
+ }
44
+ .bui-tooltip.tooltip-top .bui-tooltip-arrow {
45
+ border-left: var(--arrow-size) solid transparent;
46
+ border-right: var(--arrow-size) solid transparent;
47
+ border-top: var(--arrow-size) solid var(--bui-color-bg-alpha-dark-7);
48
+ bottom: 0;
49
+ }
50
+ .bui-tooltip.tooltip-bottom {
51
+ padding-top: var(--arrow-size);
52
+ }
53
+ .bui-tooltip.tooltip-bottom .bui-tooltip-arrow {
54
+ border-left: var(--arrow-size) solid transparent;
55
+ border-right: var(--arrow-size) solid transparent;
56
+ border-bottom: var(--arrow-size) solid var(--bui-color-bg-alpha-dark-7);
57
+ top: 0;
58
+ }
59
+ .bui-tooltip.tooltip-left {
60
+ padding-right: var(--arrow-size);
61
+ }
62
+ .bui-tooltip.tooltip-left .bui-tooltip-arrow {
63
+ border-top: var(--arrow-size) solid transparent;
64
+ border-bottom: var(--arrow-size) solid transparent;
65
+ border-left: var(--arrow-size) solid var(--bui-color-bg-alpha-dark-7);
66
+ right: 0;
67
+ }
68
+ .bui-tooltip.tooltip-right {
69
+ padding-left: var(--arrow-size);
70
+ }
71
+ .bui-tooltip.tooltip-right .bui-tooltip-arrow {
72
+ border-top: var(--arrow-size) solid transparent;
73
+ border-bottom: var(--arrow-size) solid transparent;
74
+ border-right: var(--arrow-size) solid var(--bui-color-bg-alpha-dark-7);
75
+ left: 0;
76
+ }
77
+ .bui-tooltip .bui-tooltip-content {
78
+ min-width: var(--content-min-width);
79
+ min-height: var(--content-min-height);
80
+ padding: var(--content-padding);
81
+ color: var(--bui-color-white);
82
+ text-align: left;
83
+ text-decoration: none;
84
+ word-wrap: break-word;
85
+ background-color: var(--bui-color-bg-alpha-dark-7);
86
+ border-radius: var(--bui-shape-radius-poster);
87
+ box-shadow:
88
+ 0 3px 6px -4px rgba(0, 0, 0, 0.12),
89
+ 0 6px 16px 0 rgba(0, 0, 0, 0.08),
90
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05);
91
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './Tooltip.less';
3
+ import { TooltipProps } from './Tooltip.types';
4
+ declare const Tooltip: React.ForwardRefExoticComponent<Omit<TooltipProps<"div", {}>, "ref"> & React.RefAttributes<HTMLElement>>;
5
+ export default Tooltip;