@bifrostui/react 1.3.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 (281) 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 +38 -17
  21. package/dist/Calendar/Calendar.types.d.ts +21 -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/Dialog/Dialog.d.ts +2 -2
  46. package/dist/Dialog/Dialog.js +20 -8
  47. package/dist/Dialog/Dialog.types.d.ts +12 -1
  48. package/dist/Dialog/FunctionalDialog.js +38 -2
  49. package/dist/Dialog/index.css +27 -18
  50. package/dist/Divider/Divider.css +6 -4
  51. package/dist/IconButton/IconButton.css +9 -7
  52. package/dist/Image/index.css +2 -1
  53. package/dist/Input/Input.css +10 -5
  54. package/dist/List/List.css +3 -0
  55. package/dist/List/ListItem.css +3 -3
  56. package/dist/List/ListItemContent.css +1 -1
  57. package/dist/Loading/Loading.css +4 -2
  58. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  59. package/dist/NavBar/NavBar.css +9 -5
  60. package/dist/Picker/Picker.css +25 -29
  61. package/dist/Picker/Picker.js +31 -11
  62. package/dist/Picker/Picker.types.d.ts +4 -0
  63. package/dist/Picker/PickerPanel.css +8 -8
  64. package/dist/Picker/PickerPanel.js +14 -8
  65. package/dist/Picker/utils.d.ts +16 -0
  66. package/dist/Picker/utils.js +32 -2
  67. package/dist/Popover/Popover.css +97 -0
  68. package/dist/Popover/Popover.d.ts +5 -0
  69. package/dist/Popover/Popover.js +186 -0
  70. package/dist/Popover/Popover.types.d.ts +60 -0
  71. package/dist/Popover/Popover.types.js +15 -0
  72. package/dist/Popover/index.d.ts +2 -0
  73. package/dist/Popover/index.js +41 -0
  74. package/dist/Portal/Portal.types.d.ts +4 -0
  75. package/dist/Portal/PortalCore.js +8 -1
  76. package/dist/Progress/Progress.css +8 -6
  77. package/dist/Radio/Radio.css +2 -1
  78. package/dist/Rating/Rating.css +8 -4
  79. package/dist/Select/Select.css +21 -10
  80. package/dist/Select/Select.js +1 -1
  81. package/dist/Select/SelectOption.js +3 -0
  82. package/dist/Skeleton/Skeleton.css +3 -2
  83. package/dist/Slider/Slider.css +24 -13
  84. package/dist/Steps/Step.css +11 -11
  85. package/dist/Steps/Steps.css +14 -5
  86. package/dist/Swiper/Swiper.css +2 -1
  87. package/dist/Switch/Switch.css +31 -16
  88. package/dist/TabBar/TabBar.css +7 -3
  89. package/dist/TabBar/TabBarItem.css +0 -1
  90. package/dist/Tabs/Tab.css +2 -6
  91. package/dist/Tabs/Tabs.css +7 -4
  92. package/dist/Tag/Tag.css +7 -10
  93. package/dist/Tag/TagGroup.css +9 -1
  94. package/dist/TextArea/TextArea.css +14 -8
  95. package/dist/ThemeProvider/ThemeProvider.d.ts +4 -0
  96. package/dist/ThemeProvider/ThemeProvider.js +90 -0
  97. package/dist/ThemeProvider/ThemeProvider.types.d.ts +127 -0
  98. package/dist/ThemeProvider/ThemeProvider.types.js +27 -0
  99. package/dist/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
  100. package/dist/ThemeProvider/hooks/ThemeContext.js +35 -0
  101. package/dist/ThemeProvider/hooks/createTheme.d.ts +2 -0
  102. package/dist/ThemeProvider/hooks/createTheme.js +55 -0
  103. package/dist/ThemeProvider/hooks/index.d.ts +4 -0
  104. package/dist/ThemeProvider/hooks/index.js +43 -0
  105. package/dist/ThemeProvider/hooks/useTheme.d.ts +1 -0
  106. package/dist/ThemeProvider/hooks/useTheme.js +39 -0
  107. package/dist/ThemeProvider/index.d.ts +4 -0
  108. package/dist/ThemeProvider/index.js +45 -0
  109. package/dist/ThemeProvider/utils/constants.d.ts +38 -0
  110. package/dist/ThemeProvider/utils/constants.js +65 -0
  111. package/dist/ThemeProvider/utils/index.d.ts +2 -0
  112. package/dist/ThemeProvider/utils/index.js +23 -0
  113. package/dist/ThemeProvider/utils/mountTokens.d.ts +26 -0
  114. package/dist/ThemeProvider/utils/mountTokens.js +123 -0
  115. package/dist/Toast/FunctionalToast.js +18 -0
  116. package/dist/Toast/Toast.css +15 -14
  117. package/dist/Toast/Toast.d.ts +2 -2
  118. package/dist/Toast/Toast.js +52 -48
  119. package/dist/Toast/Toast.types.d.ts +15 -1
  120. package/dist/Tooltip/Tooltip.css +91 -0
  121. package/dist/Tooltip/Tooltip.d.ts +5 -0
  122. package/dist/Tooltip/Tooltip.js +177 -0
  123. package/dist/Tooltip/Tooltip.types.d.ts +51 -0
  124. package/dist/Tooltip/Tooltip.types.js +15 -0
  125. package/dist/Tooltip/index.d.ts +2 -0
  126. package/dist/Tooltip/index.js +41 -0
  127. package/dist/index.d.ts +7 -0
  128. package/dist/index.js +15 -1
  129. package/dist/locales/base.d.ts +40 -0
  130. package/dist/locales/base.js +15 -0
  131. package/dist/locales/en-US.d.ts +3 -0
  132. package/dist/locales/en-US.js +69 -0
  133. package/dist/locales/hooks/useLocaleText.d.ts +3 -0
  134. package/dist/locales/hooks/useLocaleText.js +43 -0
  135. package/dist/locales/index.d.ts +5 -0
  136. package/dist/locales/index.js +49 -0
  137. package/dist/locales/zh-CN.d.ts +3 -0
  138. package/dist/locales/zh-CN.js +51 -0
  139. package/dist/locales/zh-TW.d.ts +3 -0
  140. package/dist/locales/zh-TW.js +51 -0
  141. package/es/ActionSheet/ActionSheet.css +6 -3
  142. package/es/ActionSheet/ActionSheetItem.css +10 -6
  143. package/es/Alert/index.css +14 -8
  144. package/es/Avatar/Avatar.css +13 -9
  145. package/es/Avatar/AvatarGroup.css +15 -8
  146. package/es/Backdrop/Backdrop.css +2 -1
  147. package/es/Badge/Badge.css +27 -17
  148. package/es/Breadcrumb/Breadcrumb.css +34 -0
  149. package/es/Breadcrumb/Breadcrumb.d.ts +5 -0
  150. package/es/Breadcrumb/Breadcrumb.js +101 -0
  151. package/es/Breadcrumb/Breadcrumb.types.d.ts +49 -0
  152. package/es/Breadcrumb/Breadcrumb.types.js +1 -0
  153. package/es/Breadcrumb/BreadcrumbItem.d.ts +4 -0
  154. package/es/Breadcrumb/BreadcrumbItem.js +51 -0
  155. package/es/Breadcrumb/index.d.ts +4 -0
  156. package/es/Breadcrumb/index.js +9 -0
  157. package/es/Button/Button.css +26 -17
  158. package/es/Calendar/Calendar.css +33 -18
  159. package/es/Calendar/Calendar.d.ts +1 -1
  160. package/es/Calendar/Calendar.js +38 -17
  161. package/es/Calendar/Calendar.types.d.ts +21 -0
  162. package/es/Card/CardFooter.css +2 -1
  163. package/es/Card/CardHeader.css +3 -1
  164. package/es/Checkbox/Checkbox.css +7 -5
  165. package/es/CitySelector/CitySelector.css +29 -15
  166. package/es/CitySelector/CitySelectorCore.js +25 -16
  167. package/es/CitySelector/Selector/index.css +4 -4
  168. package/es/Collapse/Collapse.css +6 -0
  169. package/es/Collapse/Collapse.d.ts +5 -0
  170. package/es/Collapse/Collapse.js +144 -0
  171. package/es/Collapse/Collapse.types.d.ts +16 -0
  172. package/es/Collapse/Collapse.types.js +1 -0
  173. package/es/Collapse/index.d.ts +2 -0
  174. package/es/Collapse/index.js +6 -0
  175. package/es/CollapsePanel/CollapsePanel.css +32 -0
  176. package/es/CollapsePanel/CollapsePanel.d.ts +5 -0
  177. package/es/CollapsePanel/CollapsePanel.js +132 -0
  178. package/es/CollapsePanel/CollapsePanel.types.d.ts +64 -0
  179. package/es/CollapsePanel/CollapsePanel.types.js +1 -0
  180. package/es/CollapsePanel/CollapsePanelItem.d.ts +4 -0
  181. package/es/CollapsePanel/CollapsePanelItem.js +85 -0
  182. package/es/CollapsePanel/index.d.ts +4 -0
  183. package/es/CollapsePanel/index.js +9 -0
  184. package/es/Countdown/Countdown.css +2 -1
  185. package/es/Dialog/Dialog.d.ts +2 -2
  186. package/es/Dialog/Dialog.js +20 -8
  187. package/es/Dialog/Dialog.types.d.ts +12 -1
  188. package/es/Dialog/FunctionalDialog.js +38 -2
  189. package/es/Dialog/index.css +27 -18
  190. package/es/Divider/Divider.css +6 -4
  191. package/es/IconButton/IconButton.css +9 -7
  192. package/es/Image/index.css +2 -1
  193. package/es/Input/Input.css +10 -5
  194. package/es/List/List.css +3 -0
  195. package/es/List/ListItem.css +3 -3
  196. package/es/List/ListItemContent.css +1 -1
  197. package/es/Loading/Loading.css +4 -2
  198. package/es/Modal/Modal.miniapp.d.ts +1 -1
  199. package/es/NavBar/NavBar.css +9 -5
  200. package/es/Picker/Picker.css +25 -29
  201. package/es/Picker/Picker.js +32 -12
  202. package/es/Picker/Picker.types.d.ts +4 -0
  203. package/es/Picker/PickerPanel.css +8 -8
  204. package/es/Picker/PickerPanel.js +14 -8
  205. package/es/Picker/utils.d.ts +16 -0
  206. package/es/Picker/utils.js +29 -1
  207. package/es/Popover/Popover.css +97 -0
  208. package/es/Popover/Popover.d.ts +5 -0
  209. package/es/Popover/Popover.js +159 -0
  210. package/es/Popover/Popover.types.d.ts +60 -0
  211. package/es/Popover/Popover.types.js +1 -0
  212. package/es/Popover/index.d.ts +2 -0
  213. package/es/Popover/index.js +6 -0
  214. package/es/Portal/Portal.types.d.ts +4 -0
  215. package/es/Portal/PortalCore.js +8 -1
  216. package/es/Progress/Progress.css +8 -6
  217. package/es/Radio/Radio.css +2 -1
  218. package/es/Rating/Rating.css +8 -4
  219. package/es/Select/Select.css +21 -10
  220. package/es/Select/Select.js +1 -1
  221. package/es/Select/SelectOption.js +3 -0
  222. package/es/Skeleton/Skeleton.css +3 -2
  223. package/es/Slider/Slider.css +24 -13
  224. package/es/Steps/Step.css +11 -11
  225. package/es/Steps/Steps.css +14 -5
  226. package/es/Swiper/Swiper.css +2 -1
  227. package/es/Switch/Switch.css +31 -16
  228. package/es/TabBar/TabBar.css +7 -3
  229. package/es/TabBar/TabBarItem.css +0 -1
  230. package/es/Tabs/Tab.css +2 -6
  231. package/es/Tabs/Tabs.css +7 -4
  232. package/es/Tag/Tag.css +7 -10
  233. package/es/Tag/TagGroup.css +9 -1
  234. package/es/TextArea/TextArea.css +14 -8
  235. package/es/ThemeProvider/ThemeProvider.d.ts +4 -0
  236. package/es/ThemeProvider/ThemeProvider.js +61 -0
  237. package/es/ThemeProvider/ThemeProvider.types.d.ts +127 -0
  238. package/es/ThemeProvider/ThemeProvider.types.js +1 -0
  239. package/es/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
  240. package/es/ThemeProvider/hooks/ThemeContext.js +6 -0
  241. package/es/ThemeProvider/hooks/createTheme.d.ts +2 -0
  242. package/es/ThemeProvider/hooks/createTheme.js +38 -0
  243. package/es/ThemeProvider/hooks/index.d.ts +4 -0
  244. package/es/ThemeProvider/hooks/index.js +8 -0
  245. package/es/ThemeProvider/hooks/useTheme.d.ts +1 -0
  246. package/es/ThemeProvider/hooks/useTheme.js +10 -0
  247. package/es/ThemeProvider/index.d.ts +4 -0
  248. package/es/ThemeProvider/index.js +8 -0
  249. package/es/ThemeProvider/utils/constants.d.ts +38 -0
  250. package/es/ThemeProvider/utils/constants.js +40 -0
  251. package/es/ThemeProvider/utils/index.d.ts +2 -0
  252. package/es/ThemeProvider/utils/index.js +2 -0
  253. package/es/ThemeProvider/utils/mountTokens.d.ts +26 -0
  254. package/es/ThemeProvider/utils/mountTokens.js +88 -0
  255. package/es/Toast/FunctionalToast.js +18 -0
  256. package/es/Toast/Toast.css +15 -14
  257. package/es/Toast/Toast.d.ts +2 -2
  258. package/es/Toast/Toast.js +53 -49
  259. package/es/Toast/Toast.types.d.ts +15 -1
  260. package/es/Tooltip/Tooltip.css +91 -0
  261. package/es/Tooltip/Tooltip.d.ts +5 -0
  262. package/es/Tooltip/Tooltip.js +150 -0
  263. package/es/Tooltip/Tooltip.types.d.ts +51 -0
  264. package/es/Tooltip/Tooltip.types.js +1 -0
  265. package/es/Tooltip/index.d.ts +2 -0
  266. package/es/Tooltip/index.js +6 -0
  267. package/es/index.d.ts +7 -0
  268. package/es/index.js +7 -0
  269. package/es/locales/base.d.ts +40 -0
  270. package/es/locales/base.js +0 -0
  271. package/es/locales/en-US.d.ts +3 -0
  272. package/es/locales/en-US.js +50 -0
  273. package/es/locales/hooks/useLocaleText.d.ts +3 -0
  274. package/es/locales/hooks/useLocaleText.js +26 -0
  275. package/es/locales/index.d.ts +5 -0
  276. package/es/locales/index.js +11 -0
  277. package/es/locales/zh-CN.d.ts +3 -0
  278. package/es/locales/zh-CN.js +32 -0
  279. package/es/locales/zh-TW.d.ts +3 -0
  280. package/es/locales/zh-TW.js +32 -0
  281. package/package.json +5 -5
@@ -0,0 +1,144 @@
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 React, { useEffect, useRef } from "react";
33
+ import {
34
+ useForkRef,
35
+ duration,
36
+ easing,
37
+ getTransitionProps,
38
+ createTransitions
39
+ } from "@bifrostui/utils";
40
+ import { Transition } from "../Transition";
41
+ import "./Collapse.css";
42
+ const defaultEasing = {
43
+ enter: easing.easeOut,
44
+ exit: easing.sharp
45
+ };
46
+ const defaultTimeout = {
47
+ enter: duration.enteringScreen,
48
+ exit: duration.leavingScreen
49
+ };
50
+ const Collapse = /* @__PURE__ */ React.forwardRef((props, ref) => {
51
+ const _a = props, {
52
+ appear = false,
53
+ in: inProp,
54
+ easing: easingProp = defaultEasing,
55
+ direction = "vertical",
56
+ timeout = defaultTimeout,
57
+ delay = 0,
58
+ collapsedSize: collapsedSizeProp = 0,
59
+ style,
60
+ className,
61
+ children
62
+ } = _a, other = __objRest(_a, [
63
+ "appear",
64
+ "in",
65
+ "easing",
66
+ "direction",
67
+ "timeout",
68
+ "delay",
69
+ "collapsedSize",
70
+ "style",
71
+ "className",
72
+ "children"
73
+ ]);
74
+ const nodeRef = useForkRef(ref);
75
+ const wrapperRef = useRef(null);
76
+ const collapseRef = useForkRef(wrapperRef, ref);
77
+ const transitions = createTransitions();
78
+ const isHorizontal = direction === "horizontal";
79
+ const collapsedSize = typeof collapsedSizeProp === "number" ? `${collapsedSizeProp}px` : collapsedSizeProp;
80
+ const size = isHorizontal ? "width" : "height";
81
+ const getCollapseWrapperSize = (reactNode) => {
82
+ return reactNode ? `${reactNode[isHorizontal ? "clientWidth" : "clientHeight"]}px` : "fit-content";
83
+ };
84
+ useEffect(() => {
85
+ var _a2, _b, _c, _d;
86
+ if (appear === false && inProp === true && ((_b = (_a2 = wrapperRef.current) == null ? void 0 : _a2.style) == null ? void 0 : _b[size]) === "fit-content") {
87
+ wrapperRef.current.style[size] = getCollapseWrapperSize(
88
+ (_d = (_c = wrapperRef.current) == null ? void 0 : _c.children) == null ? void 0 : _d[0]
89
+ );
90
+ }
91
+ }, [appear, inProp]);
92
+ if (!children)
93
+ return null;
94
+ return /* @__PURE__ */ React.createElement(
95
+ Transition,
96
+ __spreadProps(__spreadValues({}, other), {
97
+ ref: nodeRef,
98
+ in: inProp,
99
+ timeout,
100
+ delay,
101
+ appear
102
+ }),
103
+ (state, childProps) => {
104
+ var _a2;
105
+ const transition = transitions.create(
106
+ size,
107
+ getTransitionProps(
108
+ { timeout, style, easing: easingProp, delay },
109
+ { mode: state }
110
+ )
111
+ );
112
+ const wrapperSize = () => {
113
+ var _a3, _b;
114
+ const collapseWrapperSize = state === "entering" || state === "entered" ? getCollapseWrapperSize((_b = (_a3 = wrapperRef.current) == null ? void 0 : _a3.children) == null ? void 0 : _b[0]) : collapsedSize;
115
+ return isHorizontal ? {
116
+ width: collapseWrapperSize,
117
+ WebKitWidth: collapseWrapperSize
118
+ } : {
119
+ height: collapseWrapperSize,
120
+ WebKitHeight: collapseWrapperSize
121
+ };
122
+ };
123
+ return React.createElement(
124
+ "div",
125
+ {
126
+ className: `bui-collapse ${className}`,
127
+ style: __spreadValues(__spreadProps(__spreadValues({}, style), {
128
+ transition,
129
+ WebkitTransition: transition
130
+ }), wrapperSize()),
131
+ ref: collapseRef
132
+ },
133
+ React.cloneElement(children, __spreadValues({
134
+ style: __spreadValues({}, (_a2 = children.props) == null ? void 0 : _a2.style)
135
+ }, childProps))
136
+ );
137
+ }
138
+ );
139
+ });
140
+ Collapse.displayName = "BuiCollapse";
141
+ var Collapse_default = Collapse;
142
+ export {
143
+ Collapse_default as default
144
+ };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { TransitionProps } from '../Transition';
3
+ export interface CollapseProps extends Omit<TransitionProps, 'children'> {
4
+ easing?: string | {
5
+ enter?: string;
6
+ exit?: string;
7
+ };
8
+ children?: React.ReactElement;
9
+ /**
10
+ * 折叠的方向
11
+ * horizontal - 水平方向
12
+ * vertical - 垂直方向
13
+ */
14
+ direction?: 'horizontal' | 'vertical';
15
+ collapsedSize?: string | number;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default, default as Collapse } from './Collapse';
2
+ export * from './Collapse.types';
@@ -0,0 +1,6 @@
1
+ import { default as default2, default as default3 } from "./Collapse";
2
+ export * from "./Collapse.types";
3
+ export {
4
+ default3 as Collapse,
5
+ default2 as default
6
+ };
@@ -0,0 +1,32 @@
1
+ .bui-collapse-panel {
2
+ --width: var(--bui-collapse-panel-width, 100%);
3
+ --header-padding: var(--bui-collapse-panel-header-padding, var(--bui-spacing-lg) 0);
4
+ --content-padding: var(--bui-collapse-panel-content-padding, var(--bui-spacing-lg) 0);
5
+ width: var(--width);
6
+ background-color: var(--bui-color-bg-view);
7
+ color: var(--bui-color-fg-default);
8
+ }
9
+ .bui-collapse-panel-item-header {
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: space-between;
13
+ border-bottom: solid 1px #eee;
14
+ cursor: pointer;
15
+ }
16
+ .bui-collapse-panel-item-header-label {
17
+ padding: var(--header-padding);
18
+ font-size: var(--bui-title-size-2);
19
+ }
20
+ .bui-collapse-panel-item-header-icon-arrow {
21
+ transform: rotate(0deg);
22
+ transition: all 0.3s ease;
23
+ }
24
+ .bui-collapse-panel-item-header-icon-arrow-active {
25
+ transform: rotate(-180deg);
26
+ }
27
+ .bui-collapse-panel-item-content {
28
+ padding: var(--content-padding);
29
+ font-size: var(--bui-text-size-1);
30
+ transition: height 0.5s ease;
31
+ overflow: hidden;
32
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { CollapsePanelProps } from './CollapsePanel.types';
3
+ import './CollapsePanel.less';
4
+ declare const CollapsePanel: React.ForwardRefExoticComponent<Omit<CollapsePanelProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export default CollapsePanel;
@@ -0,0 +1,132 @@
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 React from "react";
33
+ import clsx from "clsx";
34
+ import { ArrowDownwardLargeIcon } from "@bifrostui/icons";
35
+ import { useValue } from "@bifrostui/utils";
36
+ import CollapseItem from "./CollapsePanelItem";
37
+ import "./CollapsePanel.css";
38
+ const prefixCls = "bui-collapse-panel";
39
+ const CollapsePanel = /* @__PURE__ */ React.forwardRef(
40
+ (props, ref) => {
41
+ const _a = props, {
42
+ className,
43
+ style,
44
+ accordion = false,
45
+ activeKeys,
46
+ defaultActiveKeys,
47
+ items,
48
+ children,
49
+ arrowIcon,
50
+ onChange
51
+ } = _a, others = __objRest(_a, [
52
+ "className",
53
+ "style",
54
+ "accordion",
55
+ "activeKeys",
56
+ "defaultActiveKeys",
57
+ "items",
58
+ "children",
59
+ "arrowIcon",
60
+ "onChange"
61
+ ]);
62
+ const [openKeys, setOpenKeys] = useValue({
63
+ defaultValue: defaultActiveKeys || [],
64
+ value: activeKeys
65
+ });
66
+ const handleClick = (event, target) => {
67
+ var _a2;
68
+ const targetKey = target == null ? void 0 : target.key;
69
+ let newOpenKeys = [];
70
+ if (accordion) {
71
+ newOpenKeys = openKeys.includes(targetKey) ? [] : [targetKey];
72
+ } else {
73
+ newOpenKeys = openKeys.includes(targetKey) ? openKeys.filter((k) => k !== targetKey) : [targetKey, ...openKeys];
74
+ }
75
+ setOpenKeys(event, newOpenKeys);
76
+ onChange == null ? void 0 : onChange(event, { activeKeys: newOpenKeys });
77
+ (_a2 = target == null ? void 0 : target.onClick) == null ? void 0 : _a2.call(target, event);
78
+ };
79
+ const getArrowIcon = () => {
80
+ if (arrowIcon) {
81
+ return arrowIcon;
82
+ }
83
+ return /* @__PURE__ */ React.createElement(ArrowDownwardLargeIcon, null);
84
+ };
85
+ const renderList = () => {
86
+ if (Array.isArray(items)) {
87
+ return items.map((item) => {
88
+ const _a2 = item, { key } = _a2, otherProps = __objRest(_a2, ["key"]);
89
+ return /* @__PURE__ */ React.createElement(
90
+ CollapseItem,
91
+ __spreadProps(__spreadValues({
92
+ key,
93
+ icon: getArrowIcon(),
94
+ active: openKeys.includes(item.key)
95
+ }, otherProps), {
96
+ onClick: (e) => handleClick(e, item)
97
+ })
98
+ );
99
+ });
100
+ }
101
+ const enhancedChildren = React.Children.map(children, (child) => {
102
+ if (React.isValidElement(child)) {
103
+ const newProps = {
104
+ icon: getArrowIcon(),
105
+ active: openKeys.includes(child.key),
106
+ onClick: (e) => handleClick(e, child)
107
+ };
108
+ return React.cloneElement(child, newProps);
109
+ }
110
+ return child;
111
+ });
112
+ return enhancedChildren;
113
+ };
114
+ if (items == null && children == null) {
115
+ return null;
116
+ }
117
+ return /* @__PURE__ */ React.createElement(
118
+ "div",
119
+ __spreadValues({
120
+ className: clsx(prefixCls, className),
121
+ style,
122
+ ref
123
+ }, others),
124
+ /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-list` }, renderList())
125
+ );
126
+ }
127
+ );
128
+ CollapsePanel.displayName = "BuiCollapsePanel";
129
+ var CollapsePanel_default = CollapsePanel;
130
+ export {
131
+ CollapsePanel_default as default
132
+ };
@@ -0,0 +1,64 @@
1
+ import { OverrideProps } from '@bifrostui/types';
2
+ import React from 'react';
3
+ export type CollapsePanelItemProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
4
+ props: P & {
5
+ /**
6
+ * 唯一标识,对应 activeKey
7
+ */
8
+ key?: string | number;
9
+ /**
10
+ * 面板标题
11
+ */
12
+ label?: React.ReactNode;
13
+ /**
14
+ * 自定义 icon
15
+ */
16
+ icon?: React.ReactNode | ((active: boolean) => React.ReactNode);
17
+ /**
18
+ * 是否展开
19
+ * @default false
20
+ */
21
+ active?: boolean;
22
+ /**
23
+ * body 区域内容
24
+ */
25
+ children?: React.ReactNode;
26
+ };
27
+ defaultComponent: D;
28
+ }, D>;
29
+ export type CollapsePanelProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
30
+ props: P & {
31
+ /**
32
+ * 是否开启手风琴模式
33
+ * @default false
34
+ */
35
+ accordion?: boolean;
36
+ /**
37
+ * 当前激活面板的 key
38
+ */
39
+ activeKeys?: (number | string)[];
40
+ /**
41
+ * 默认展开面板的 key
42
+ */
43
+ defaultActiveKeys?: (number | string)[];
44
+ /**
45
+ * 折叠项目内容
46
+ */
47
+ items?: Array<CollapsePanelItemProps>;
48
+ /**
49
+ * body 区域内容,使用 CollapseItem 进行渲染
50
+ */
51
+ children?: React.ReactNode;
52
+ /**
53
+ * 自定义箭头图标
54
+ */
55
+ arrowIcon?: React.ReactNode | ((active: boolean) => React.ReactNode);
56
+ /**
57
+ * 切换面板时触发
58
+ */
59
+ onChange?: (e: React.SyntheticEvent, params: {
60
+ activeKeys: (number | string)[];
61
+ }) => void;
62
+ };
63
+ defaultComponent: D;
64
+ }, D>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { CollapsePanelItemProps } from './CollapsePanel.types';
3
+ declare const CollapsePanelItem: React.ForwardRefExoticComponent<Omit<CollapsePanelItemProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ export default CollapsePanelItem;
@@ -0,0 +1,85 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import React from "react";
30
+ import clsx from "clsx";
31
+ import { Collapse } from "../Collapse";
32
+ const prefixCls = "bui-collapse-panel-item";
33
+ const CollapsePanelItem = /* @__PURE__ */ React.forwardRef((props, ref) => {
34
+ const _a = props, {
35
+ className,
36
+ style,
37
+ label,
38
+ children,
39
+ icon,
40
+ active,
41
+ onClick
42
+ } = _a, others = __objRest(_a, [
43
+ "className",
44
+ "style",
45
+ "label",
46
+ "children",
47
+ "icon",
48
+ "active",
49
+ "onClick"
50
+ ]);
51
+ const isControlledIcon = typeof icon === "function";
52
+ const getIcon = () => {
53
+ return typeof icon === "function" ? icon(active) : icon;
54
+ };
55
+ return /* @__PURE__ */ React.createElement(
56
+ "div",
57
+ __spreadValues({
58
+ className: clsx(prefixCls, active && `${prefixCls}-active`, className),
59
+ style,
60
+ ref
61
+ }, others),
62
+ /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header`, onClick }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header-label` }, label), /* @__PURE__ */ React.createElement(
63
+ "div",
64
+ {
65
+ className: clsx(
66
+ `${prefixCls}-header-icon`,
67
+ `${prefixCls}-header-icon-arrow`,
68
+ {
69
+ [`${prefixCls}-header-icon-arrow-active`]: !isControlledIcon && active
70
+ }
71
+ )
72
+ },
73
+ getIcon()
74
+ )),
75
+ /* @__PURE__ */ React.createElement(Collapse, { in: active, direction: "vertical", timeout: 300 }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-content` }, children))
76
+ );
77
+ });
78
+ CollapsePanelItem.displayName = "BuiCollapsePanelItem";
79
+ CollapsePanelItem.defaultProps = {
80
+ active: false
81
+ };
82
+ var CollapsePanelItem_default = CollapsePanelItem;
83
+ export {
84
+ CollapsePanelItem_default as default
85
+ };
@@ -0,0 +1,4 @@
1
+ export { default } from './CollapsePanel';
2
+ export { default as CollapsePanel } from './CollapsePanel';
3
+ export { default as CollapsePanelItem } from './CollapsePanelItem';
4
+ export * from './CollapsePanel.types';
@@ -0,0 +1,9 @@
1
+ import { default as default2 } from "./CollapsePanel";
2
+ import { default as default3 } from "./CollapsePanel";
3
+ import { default as default4 } from "./CollapsePanelItem";
4
+ export * from "./CollapsePanel.types";
5
+ export {
6
+ default3 as CollapsePanel,
7
+ default4 as CollapsePanelItem,
8
+ default2 as default
9
+ };
@@ -2,6 +2,7 @@
2
2
  --font-size: var(--bui-countdown-font-size, var(--bui-text-size-1));
3
3
  --color: var(--bui-countdown-color, var(--bui-color-fg-default));
4
4
  --font-weight: var(--bui-countdown-font-weight, var(--bui-font-weight-normal));
5
+ --slice-unit-margin: var(--bui-countdown-slice-unit-margin, 0 2px);
5
6
  display: flex;
6
7
  flex-direction: row;
7
8
  align-items: center;
@@ -34,5 +35,5 @@
34
35
  sans-serif;
35
36
  }
36
37
  .bui-countdown-slice-unit {
37
- margin: 0 2px;
38
+ margin: var(--slice-unit-margin);
38
39
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { DialogProps } from './Dialog.types';
2
+ import { DialogProps, DialogRef } from './Dialog.types';
3
3
  import './index.less';
4
- declare const Dialog: React.ForwardRefExoticComponent<Omit<DialogProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ declare const Dialog: React.ForwardRefExoticComponent<Omit<DialogProps, "ref"> & React.RefAttributes<DialogRef>>;
5
5
  export default Dialog;
@@ -29,11 +29,13 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import React, { useRef } from "react";
33
32
  import clsx from "clsx";
33
+ import React, { useImperativeHandle, useRef } from "react";
34
34
  import { Input } from "../Input";
35
35
  import { Button } from "../Button";
36
+ import { useLocaleText } from "../locales";
36
37
  import Modal from "../Modal";
38
+ import { useTheme } from "../ThemeProvider";
37
39
  import "./index.css";
38
40
  const prefixCls = "bui-dialog";
39
41
  const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
@@ -48,7 +50,8 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
48
50
  cancelText,
49
51
  placeholder,
50
52
  InputProps,
51
- className
53
+ className,
54
+ theme
52
55
  } = _a, others = __objRest(_a, [
53
56
  "open",
54
57
  "onOk",
@@ -60,9 +63,19 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
60
63
  "cancelText",
61
64
  "placeholder",
62
65
  "InputProps",
63
- "className"
66
+ "className",
67
+ "theme"
64
68
  ]);
65
69
  const InputRef = useRef(null);
70
+ const themeConfig = useTheme(theme);
71
+ const {
72
+ cancel,
73
+ confirm,
74
+ placeholder: placeholderLocaleName
75
+ } = useLocaleText("dialog", themeConfig);
76
+ useImperativeHandle(ref, () => {
77
+ return { theme: themeConfig };
78
+ });
66
79
  const footerNode = /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-body-footer` }, /* @__PURE__ */ React.createElement(
67
80
  Button,
68
81
  {
@@ -70,7 +83,7 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
70
83
  onClick: onClose,
71
84
  className: `${prefixCls}-body-button`
72
85
  },
73
- cancelText || "\u53D6\u6D88"
86
+ cancelText || cancel
74
87
  ), /* @__PURE__ */ React.createElement(
75
88
  Button,
76
89
  {
@@ -82,14 +95,14 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
82
95
  },
83
96
  className: `${prefixCls}-body-button`
84
97
  },
85
- confirmText || "\u786E\u5B9A"
98
+ confirmText || confirm
86
99
  ));
87
100
  const inputNode = type === "prompt" && /* @__PURE__ */ React.createElement(
88
101
  Input,
89
102
  __spreadProps(__spreadValues({}, InputProps), {
90
103
  inputRef: InputRef,
91
104
  className: `${prefixCls}-body-input`,
92
- placeholder: `${placeholder || "\u8BF7\u5728\u6B64\u5904\u8F93\u5165"}`
105
+ placeholder: `${placeholder || placeholderLocaleName}`
93
106
  })
94
107
  );
95
108
  if (!open)
@@ -100,8 +113,7 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
100
113
  open: true,
101
114
  className: clsx(prefixCls, className),
102
115
  disablePortal: true,
103
- onClose,
104
- ref
116
+ onClose
105
117
  }),
106
118
  /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-body` }, header && /* @__PURE__ */ React.createElement("h1", { className: `${prefixCls}-body-title` }, header), message && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-body-desc` }, message), inputNode, footerNode)
107
119
  );
@@ -1,11 +1,15 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { ModalProps } from '../Modal/Modal.types';
3
3
  import { InputProps } from '../Input/Input.types';
4
+ import { ThemeProps } from '../ThemeProvider/ThemeProvider.types';
4
5
  /**
5
6
  * 对话框类型
6
7
  */
7
8
  export type DialogType = 'confirm' | 'prompt';
8
9
  export type Dispatch = (action: boolean, val?: string) => void;
10
+ export type DialogRef = {
11
+ theme?: ThemeProps;
12
+ };
9
13
  export interface DialogProps extends ModalProps {
10
14
  /**
11
15
  * 对话框类型
@@ -36,6 +40,10 @@ export interface DialogProps extends ModalProps {
36
40
  * 取消文本内容
37
41
  */
38
42
  cancelText?: ReactNode;
43
+ /**
44
+ * theme 主题定制
45
+ */
46
+ theme?: ThemeProps;
39
47
  /**
40
48
  * 确认回调
41
49
  */
@@ -82,7 +90,7 @@ export type DialogPromise = Promise<boolean | string>;
82
90
  /**
83
91
  * Dialog Instance
84
92
  */
85
- export interface DialogInstance {
93
+ export interface DialogFunction {
86
94
  /**
87
95
  * 直接调用显示确认框 Dialog
88
96
  */
@@ -96,3 +104,6 @@ export interface DialogInstance {
96
104
  */
97
105
  prompt?: (options: PromptOptions, val?: string) => DialogPromise;
98
106
  }
107
+ export interface DialogInstance extends DialogFunction {
108
+ useDialog: () => [DialogFunction, React.JSX.Element];
109
+ }