@bifrostui/react 2.0.0-beta.10 → 2.0.0-beta.11

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 (211) hide show
  1. package/dist/Calendar/Calendar.js +5 -1
  2. package/dist/Calendar/Calendar.types.d.ts +5 -0
  3. package/dist/Collapse/Collapse.css +0 -1
  4. package/dist/Collapse/Collapse.d.ts +1 -1
  5. package/dist/Collapse/Collapse.js +11 -8
  6. package/dist/Collapse/Collapse.miniapp.d.ts +5 -0
  7. package/dist/Collapse/Collapse.miniapp.js +177 -0
  8. package/dist/CollapsePanel/CollapsePanel.css +4 -2
  9. package/dist/DatePicker/DatePicker.d.ts +4 -0
  10. package/dist/DatePicker/DatePicker.js +335 -0
  11. package/dist/DatePicker/DatePicker.types.d.ts +36 -0
  12. package/dist/DatePicker/DatePicker.types.js +15 -0
  13. package/dist/DatePicker/constants.d.ts +9 -0
  14. package/dist/DatePicker/constants.js +37 -0
  15. package/dist/DatePicker/index.d.ts +3 -0
  16. package/dist/DatePicker/index.js +44 -0
  17. package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  18. package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
  19. package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  20. package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
  21. package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  22. package/dist/DesktopDatePicker/index.css +61 -0
  23. package/dist/DesktopDatePicker/index.d.ts +2 -0
  24. package/dist/DesktopDatePicker/index.js +41 -0
  25. package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  26. package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
  27. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  28. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
  29. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  30. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
  31. package/dist/DesktopDateTimePicker/index.css +66 -0
  32. package/dist/DesktopDateTimePicker/index.d.ts +2 -0
  33. package/dist/DesktopDateTimePicker/index.js +41 -0
  34. package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
  35. package/dist/DesktopPicker/DesktopPicker.js +243 -0
  36. package/dist/DesktopPicker/DesktopPicker.types.d.ts +61 -0
  37. package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
  38. package/dist/DesktopPicker/index.css +39 -0
  39. package/dist/DesktopPicker/index.d.ts +2 -0
  40. package/dist/DesktopPicker/index.js +41 -0
  41. package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  42. package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
  43. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  44. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
  45. package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  46. package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
  47. package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  48. package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
  49. package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  50. package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
  51. package/dist/DesktopTimePicker/index.css +170 -0
  52. package/dist/DesktopTimePicker/index.d.ts +2 -0
  53. package/dist/DesktopTimePicker/index.js +41 -0
  54. package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  55. package/dist/DesktopTimePicker/useGetTimePickerContent.js +249 -0
  56. package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  57. package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
  58. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  59. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
  60. package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
  61. package/dist/DesktopTimePicker/utils/utils.js +408 -0
  62. package/dist/Dialog/Dialog.types.d.ts +5 -0
  63. package/dist/Dialog/FunctionalDialog.js +13 -2
  64. package/dist/Input/Input.css +0 -2
  65. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  66. package/dist/Picker/Picker.css +5 -0
  67. package/dist/Picker/Picker.js +27 -5
  68. package/dist/Picker/Picker.types.d.ts +15 -2
  69. package/dist/Picker/PickerPanel.css +4 -0
  70. package/dist/Picker/PickerPanel.js +7 -6
  71. package/dist/Popover/Popover.js +70 -27
  72. package/dist/Portal/Portal.miniapp.js +7 -4
  73. package/dist/ScrollView/ScrollView.js +24 -11
  74. package/dist/ScrollView/ScrollView.types.d.ts +0 -1
  75. package/dist/Select/Select.css +1 -4
  76. package/dist/Select/Select.js +62 -37
  77. package/dist/Slider/Slider.js +13 -5
  78. package/dist/SwipeAction/SwipeAction.css +79 -0
  79. package/dist/SwipeAction/SwipeAction.d.ts +5 -0
  80. package/dist/SwipeAction/SwipeAction.js +349 -0
  81. package/dist/SwipeAction/SwipeAction.types.d.ts +75 -0
  82. package/dist/SwipeAction/SwipeAction.types.js +15 -0
  83. package/dist/SwipeAction/SwipeActionContext.d.ts +4 -0
  84. package/dist/SwipeAction/SwipeActionContext.js +30 -0
  85. package/dist/SwipeAction/SwipeActionItem.css +31 -0
  86. package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
  87. package/dist/SwipeAction/SwipeActionItem.js +105 -0
  88. package/dist/SwipeAction/constants.d.ts +9 -0
  89. package/dist/SwipeAction/constants.js +39 -0
  90. package/dist/SwipeAction/index.d.ts +5 -0
  91. package/dist/SwipeAction/index.js +50 -0
  92. package/dist/Tabs/Tabs.js +29 -14
  93. package/dist/Tabs/utils/scroll.d.ts +2 -0
  94. package/dist/Tabs/utils/scroll.js +55 -0
  95. package/dist/Toast/FunctionalToast.js +13 -2
  96. package/dist/Toast/Toast.css +0 -1
  97. package/dist/Toast/Toast.types.d.ts +5 -0
  98. package/dist/Tooltip/Tooltip.js +70 -27
  99. package/dist/index.d.ts +6 -0
  100. package/dist/index.js +13 -1
  101. package/dist/locales/base.d.ts +11 -0
  102. package/dist/locales/en-US.js +24 -0
  103. package/dist/locales/zh-CN.js +24 -0
  104. package/dist/locales/zh-TW.js +24 -0
  105. package/es/Calendar/Calendar.js +5 -1
  106. package/es/Calendar/Calendar.types.d.ts +5 -0
  107. package/es/Collapse/Collapse.css +0 -1
  108. package/es/Collapse/Collapse.d.ts +1 -1
  109. package/es/Collapse/Collapse.js +11 -8
  110. package/es/Collapse/Collapse.miniapp.d.ts +5 -0
  111. package/es/Collapse/Collapse.miniapp.js +157 -0
  112. package/es/CollapsePanel/CollapsePanel.css +4 -2
  113. package/es/DatePicker/DatePicker.d.ts +4 -0
  114. package/es/DatePicker/DatePicker.js +308 -0
  115. package/es/DatePicker/DatePicker.types.d.ts +36 -0
  116. package/es/DatePicker/DatePicker.types.js +1 -0
  117. package/es/DatePicker/constants.d.ts +9 -0
  118. package/es/DatePicker/constants.js +14 -0
  119. package/es/DatePicker/index.d.ts +3 -0
  120. package/es/DatePicker/index.js +8 -0
  121. package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  122. package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
  123. package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  124. package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
  125. package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  126. package/es/DesktopDatePicker/index.css +61 -0
  127. package/es/DesktopDatePicker/index.d.ts +2 -0
  128. package/es/DesktopDatePicker/index.js +6 -0
  129. package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  130. package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
  131. package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  132. package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
  133. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  134. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
  135. package/es/DesktopDateTimePicker/index.css +66 -0
  136. package/es/DesktopDateTimePicker/index.d.ts +2 -0
  137. package/es/DesktopDateTimePicker/index.js +9 -0
  138. package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
  139. package/es/DesktopPicker/DesktopPicker.js +226 -0
  140. package/es/DesktopPicker/DesktopPicker.types.d.ts +61 -0
  141. package/es/DesktopPicker/DesktopPicker.types.js +1 -0
  142. package/es/DesktopPicker/index.css +39 -0
  143. package/es/DesktopPicker/index.d.ts +2 -0
  144. package/es/DesktopPicker/index.js +6 -0
  145. package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  146. package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
  147. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  148. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
  149. package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  150. package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
  151. package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  152. package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
  153. package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  154. package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
  155. package/es/DesktopTimePicker/index.css +170 -0
  156. package/es/DesktopTimePicker/index.d.ts +2 -0
  157. package/es/DesktopTimePicker/index.js +6 -0
  158. package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  159. package/es/DesktopTimePicker/useGetTimePickerContent.js +226 -0
  160. package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  161. package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
  162. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  163. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
  164. package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
  165. package/es/DesktopTimePicker/utils/utils.js +365 -0
  166. package/es/Dialog/Dialog.types.d.ts +5 -0
  167. package/es/Dialog/FunctionalDialog.js +14 -3
  168. package/es/Input/Input.css +0 -2
  169. package/es/Picker/Picker.css +5 -0
  170. package/es/Picker/Picker.js +27 -5
  171. package/es/Picker/Picker.types.d.ts +15 -2
  172. package/es/Picker/PickerPanel.css +4 -0
  173. package/es/Picker/PickerPanel.js +7 -6
  174. package/es/Popover/Popover.js +73 -29
  175. package/es/Portal/Portal.miniapp.js +8 -5
  176. package/es/ScrollView/ScrollView.js +24 -11
  177. package/es/ScrollView/ScrollView.types.d.ts +0 -1
  178. package/es/Select/Select.css +1 -4
  179. package/es/Select/Select.js +62 -38
  180. package/es/Slider/Slider.js +16 -6
  181. package/es/SwipeAction/SwipeAction.css +79 -0
  182. package/es/SwipeAction/SwipeAction.d.ts +5 -0
  183. package/es/SwipeAction/SwipeAction.js +334 -0
  184. package/es/SwipeAction/SwipeAction.types.d.ts +75 -0
  185. package/es/SwipeAction/SwipeAction.types.js +1 -0
  186. package/es/SwipeAction/SwipeActionContext.d.ts +4 -0
  187. package/es/SwipeAction/SwipeActionContext.js +11 -0
  188. package/es/SwipeAction/SwipeActionItem.css +31 -0
  189. package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
  190. package/es/SwipeAction/SwipeActionItem.js +78 -0
  191. package/es/SwipeAction/constants.d.ts +9 -0
  192. package/es/SwipeAction/constants.js +15 -0
  193. package/es/SwipeAction/index.d.ts +5 -0
  194. package/es/SwipeAction/index.js +12 -0
  195. package/es/Tabs/Tabs.js +29 -14
  196. package/es/Tabs/utils/scroll.d.ts +2 -0
  197. package/es/Tabs/utils/scroll.js +36 -0
  198. package/es/Toast/FunctionalToast.js +14 -3
  199. package/es/Toast/Toast.css +0 -1
  200. package/es/Toast/Toast.types.d.ts +5 -0
  201. package/es/Tooltip/Tooltip.js +73 -29
  202. package/es/index.d.ts +6 -0
  203. package/es/index.js +6 -0
  204. package/es/locales/base.d.ts +11 -0
  205. package/es/locales/en-US.js +24 -0
  206. package/es/locales/zh-CN.js +24 -0
  207. package/es/locales/zh-TW.js +24 -0
  208. package/package.json +5 -5
  209. package/dist/Tabs/utils/bound.d.ts +0 -1
  210. package/es/Tabs/utils/bound.d.ts +0 -1
  211. package/es/Tabs/utils/bound.js +0 -13
@@ -0,0 +1,75 @@
1
+ import { OverrideProps, ThemeColor } from '@bifrostui/types';
2
+ import React from 'react';
3
+ import { SideTypeEnum } from './constants';
4
+ export type SwipeActionProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
5
+ props: P & {
6
+ /**
7
+ * 右侧的操作按钮列表区域
8
+ */
9
+ rightActions?: React.ReactNode;
10
+ /**
11
+ * 左侧的操作按钮列表区域
12
+ */
13
+ leftActions?: React.ReactNode;
14
+ /**
15
+ * 是否在点击按钮区自动归位
16
+ */
17
+ closeOnClickActionItem?: boolean;
18
+ /**
19
+ * 是否在点击其他区域时自动归位
20
+ */
21
+ closeOnClickContainer?: boolean;
22
+ /**
23
+ * 操作按钮展开时触发
24
+ */
25
+ onActionsReveal?: (params: RevealParams) => void;
26
+ /**
27
+ * 是否禁用拖动
28
+ */
29
+ disabled?: boolean;
30
+ };
31
+ defaultComponent: D;
32
+ }, D>;
33
+ interface RevealParams {
34
+ side: SideTypeEnum | '';
35
+ }
36
+ export type SwipeActionItemProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
37
+ props: P & {
38
+ /**
39
+ * 颜色风格
40
+ */
41
+ color?: ThemeColor | 'vip';
42
+ /**
43
+ * id
44
+ */
45
+ id?: string | number;
46
+ /**
47
+ * 点击事件
48
+ */
49
+ onClick?: (e: React.SyntheticEvent, item: {
50
+ id: string | number;
51
+ color: ThemeColor | 'vip';
52
+ text: React.ReactNode;
53
+ }) => void;
54
+ };
55
+ defaultComponent: D;
56
+ }, D>;
57
+ export interface BuiSwipeActionContextProps {
58
+ /**
59
+ * 是否在点击操作按钮时自动归位
60
+ */
61
+ closeOnClickActionItem?: boolean;
62
+ /**
63
+ * 关闭函数
64
+ */
65
+ close: () => void;
66
+ }
67
+ export type SwipeActionRef = {
68
+ close: () => void;
69
+ show: (params?: {
70
+ side: SideTypeEnum;
71
+ }) => void;
72
+ open: boolean;
73
+ ref?: HTMLDivElement;
74
+ };
75
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BuiSwipeActionContextProps } from './SwipeAction.types';
3
+ declare const BuiSwipeActionContext: import("react").Context<BuiSwipeActionContextProps>;
4
+ export default BuiSwipeActionContext;
@@ -0,0 +1,11 @@
1
+ import { createContext } from "react";
2
+ const BuiSwipeActionContext = createContext({
3
+ closeOnClickActionItem: true,
4
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
5
+ close: () => {
6
+ }
7
+ });
8
+ var SwipeActionContext_default = BuiSwipeActionContext;
9
+ export {
10
+ SwipeActionContext_default as default
11
+ };
@@ -0,0 +1,31 @@
1
+ .bui-swipe-action-item {
2
+ padding: 0 15px;
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ height: 100%;
7
+ width: 100%;
8
+ background: var(--background-button-color);
9
+ color: #fff;
10
+ box-sizing: content-box;
11
+ white-space: nowrap;
12
+ font-family: var(--bui-font-family);
13
+ }
14
+ .bui-swipe-action-item-primary {
15
+ background-color: var(--bui-color-primary);
16
+ }
17
+ .bui-swipe-action-item-vip {
18
+ background-color: var(--bui-color-vip);
19
+ }
20
+ .bui-swipe-action-item-success {
21
+ background-color: var(--bui-color-success);
22
+ }
23
+ .bui-swipe-action-item-info {
24
+ background-color: var(--bui-color-info);
25
+ }
26
+ .bui-swipe-action-item-warning {
27
+ background-color: var(--bui-color-warning);
28
+ }
29
+ .bui-swipe-action-item-danger {
30
+ background-color: var(--bui-color-danger);
31
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { SwipeActionItemProps } from './SwipeAction.types';
3
+ import './SwipeActionItem.less';
4
+ declare const SwipeActionItem: React.ForwardRefExoticComponent<Omit<SwipeActionItemProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export default SwipeActionItem;
@@ -0,0 +1,78 @@
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, { useContext } from "react";
30
+ import clsx from "clsx";
31
+ import BuiSwipeActionContext from "./SwipeActionContext";
32
+ import "./SwipeActionItem.css";
33
+ const prefixCls = "bui-swipe-action-item";
34
+ const SwipeActionItem = /* @__PURE__ */ React.forwardRef(
35
+ (props, ref) => {
36
+ const _a = props, {
37
+ className,
38
+ children,
39
+ onClick,
40
+ color = "primary",
41
+ id = ""
42
+ } = _a, others = __objRest(_a, [
43
+ "className",
44
+ "children",
45
+ "onClick",
46
+ "color",
47
+ "id"
48
+ ]);
49
+ const { closeOnClickActionItem, close } = useContext(BuiSwipeActionContext);
50
+ const onClickHandle = (e) => {
51
+ e.stopPropagation();
52
+ if (closeOnClickActionItem) {
53
+ close == null ? void 0 : close();
54
+ }
55
+ onClick == null ? void 0 : onClick(e, {
56
+ color,
57
+ id,
58
+ text: children
59
+ });
60
+ };
61
+ return /* @__PURE__ */ React.createElement(
62
+ "div",
63
+ __spreadValues({
64
+ className: clsx(prefixCls, className, {
65
+ [`${prefixCls}-${color}`]: color
66
+ }),
67
+ ref,
68
+ onClick: onClickHandle
69
+ }, others),
70
+ children
71
+ );
72
+ }
73
+ );
74
+ SwipeActionItem.displayName = "SwipeActionItem";
75
+ var SwipeActionItem_default = SwipeActionItem;
76
+ export {
77
+ SwipeActionItem_default as default
78
+ };
@@ -0,0 +1,9 @@
1
+ export declare enum SideTypeEnum {
2
+ LEFT = "left",
3
+ RIGHT = "right"
4
+ }
5
+ export declare enum DragPhaseEnum {
6
+ START = 1,
7
+ MOVE = 2,
8
+ END = 3
9
+ }
@@ -0,0 +1,15 @@
1
+ var SideTypeEnum = /* @__PURE__ */ ((SideTypeEnum2) => {
2
+ SideTypeEnum2["LEFT"] = "left";
3
+ SideTypeEnum2["RIGHT"] = "right";
4
+ return SideTypeEnum2;
5
+ })(SideTypeEnum || {});
6
+ var DragPhaseEnum = /* @__PURE__ */ ((DragPhaseEnum2) => {
7
+ DragPhaseEnum2[DragPhaseEnum2["START"] = 1] = "START";
8
+ DragPhaseEnum2[DragPhaseEnum2["MOVE"] = 2] = "MOVE";
9
+ DragPhaseEnum2[DragPhaseEnum2["END"] = 3] = "END";
10
+ return DragPhaseEnum2;
11
+ })(DragPhaseEnum || {});
12
+ export {
13
+ DragPhaseEnum,
14
+ SideTypeEnum
15
+ };
@@ -0,0 +1,5 @@
1
+ export * from './SwipeAction.types';
2
+ export { default } from './SwipeAction';
3
+ export { default as SwipeAction } from './SwipeAction';
4
+ export { default as SwipeActionItem } from './SwipeActionItem';
5
+ export { SideTypeEnum, DragPhaseEnum } from './constants';
@@ -0,0 +1,12 @@
1
+ export * from "./SwipeAction.types";
2
+ import { default as default2 } from "./SwipeAction";
3
+ import { default as default3 } from "./SwipeAction";
4
+ import { default as default4 } from "./SwipeActionItem";
5
+ import { SideTypeEnum, DragPhaseEnum } from "./constants";
6
+ export {
7
+ DragPhaseEnum,
8
+ SideTypeEnum,
9
+ default3 as SwipeAction,
10
+ default4 as SwipeActionItem,
11
+ default2 as default
12
+ };
package/es/Tabs/Tabs.js CHANGED
@@ -31,9 +31,10 @@ import clsx from "clsx";
31
31
  import React, { useEffect, useMemo, useRef, useState } from "react";
32
32
  import Tab from "./Tab";
33
33
  import { TabsContextProvider } from "./TabsContext";
34
- import bound from "./utils/bound";
34
+ import scrollLeftTo from "./utils/scroll";
35
35
  import "./Tabs.css";
36
36
  const prefixCls = "bui-tabs";
37
+ const duration = 300;
37
38
  const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
38
39
  const _a = props, { children, className, value, tabs = [], onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "onChange"]);
39
40
  const tabsRef = useRef(null);
@@ -46,14 +47,11 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
46
47
  leftMaskOpacity: 0,
47
48
  rightMaskOpacity: 0
48
49
  });
49
- const animate = useEventCallback(() => {
50
+ const getActiveTabElement = () => {
50
51
  const container = tabsRef.current;
51
52
  if (!container)
52
- return;
53
+ return void 0;
53
54
  const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === value);
54
- const activeLine = activeLineRef.current;
55
- if (!activeLine)
56
- return;
57
55
  let activeTab;
58
56
  if (tabs.length) {
59
57
  activeTab = activeIndex > -1 ? container.childNodes[activeIndex + 1] : void 0;
@@ -67,6 +65,25 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
67
65
  return [...child.classList].includes("bui-tab-active");
68
66
  });
69
67
  }
68
+ return activeTab;
69
+ };
70
+ const scrollIntoView = () => {
71
+ const tabsContainer = tabsRef.current;
72
+ const activeTab = getActiveTabElement();
73
+ if (!tabsContainer || !activeTab) {
74
+ return;
75
+ }
76
+ const to = activeTab.offsetLeft - (tabsContainer.offsetWidth - activeTab.offsetWidth) / 2;
77
+ scrollLeftTo(tabsContainer, to, duration);
78
+ };
79
+ const animate = useEventCallback(() => {
80
+ const container = tabsRef.current;
81
+ if (!container)
82
+ return;
83
+ const activeLine = activeLineRef.current;
84
+ if (!activeLine)
85
+ return;
86
+ const activeTab = getActiveTabElement();
70
87
  let activeTabLeft = 0;
71
88
  let activeTabWidth = 0;
72
89
  let containerWidth = 0;
@@ -88,13 +105,8 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
88
105
  const maxScrollDistance = containerScrollWidth - containerWidth;
89
106
  if (maxScrollDistance <= 0 || !activeTab)
90
107
  return;
91
- const nextScrollLeft = bound(
92
- activeTabLeft - (containerWidth - activeTabWidth) / 2,
93
- 0,
94
- containerScrollWidth - containerWidth
95
- );
96
- if (tabsRef.current) {
97
- tabsRef.current.scrollLeft = nextScrollLeft;
108
+ if (!isMini) {
109
+ scrollIntoView();
98
110
  }
99
111
  });
100
112
  const updateMask = useMemo(
@@ -105,7 +117,10 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
105
117
  return;
106
118
  const scrollLeft = container == null ? void 0 : container.scrollLeft;
107
119
  const showLeftMask = scrollLeft > 0;
108
- const showRightMask = scrollLeft + container.offsetWidth < container.scrollWidth;
120
+ const rightRange = Math.abs(
121
+ container.scrollWidth - (scrollLeft + container.offsetWidth)
122
+ );
123
+ const showRightMask = rightRange > 1;
109
124
  setMaskData({
110
125
  leftMaskOpacity: showLeftMask ? 1 : 0,
111
126
  rightMaskOpacity: showRightMask ? 1 : 0
@@ -0,0 +1,2 @@
1
+ declare const scrollLeftTo: (scroller: HTMLElement, to: number, duration: number) => void;
2
+ export default scrollLeftTo;
@@ -0,0 +1,36 @@
1
+ const root = window || global;
2
+ let rafId;
3
+ let prev = Date.now();
4
+ const rafPolyfill = (fn) => {
5
+ const curr = Date.now();
6
+ const ms = Math.max(0, 16 - (curr - prev));
7
+ const id = setTimeout(fn, ms);
8
+ prev = curr + ms;
9
+ return id;
10
+ };
11
+ const cancelRaf = (id) => {
12
+ const cancelAnimationFrame = (root == null ? void 0 : root.cancelAnimationFrame) || (root == null ? void 0 : root.clearTimeout) || clearTimeout;
13
+ cancelAnimationFrame.call(root, id);
14
+ };
15
+ const raf = (fn) => {
16
+ const requestAnimationFrame = (root == null ? void 0 : root.requestAnimationFrame) || rafPolyfill;
17
+ return requestAnimationFrame.call(root, fn);
18
+ };
19
+ const scrollLeftTo = (scroller, to, duration) => {
20
+ cancelRaf(rafId);
21
+ let count = 0;
22
+ const from = scroller.scrollLeft;
23
+ const frames = duration === 0 ? 1 : Math.round(duration / 16);
24
+ function animate() {
25
+ scroller.scrollLeft += (to - from) / frames;
26
+ count += 1;
27
+ if (count < frames) {
28
+ rafId = raf(animate);
29
+ }
30
+ }
31
+ animate();
32
+ };
33
+ var scroll_default = scrollLeftTo;
34
+ export {
35
+ scroll_default as default
36
+ };
@@ -29,7 +29,7 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { render, unmount, getRootElement } from "@bifrostui/utils";
32
+ import { render, unmount, getRootContainer } from "@bifrostui/utils";
33
33
  import React, { useCallback, useEffect, useState } from "react";
34
34
  import ToastView from "./Toast";
35
35
  let toastCloses = [];
@@ -70,10 +70,21 @@ const functionalToast = (props) => {
70
70
  rootWrapper.style[property] = styles[property];
71
71
  });
72
72
  }
73
- const rootElement = getRootElement();
73
+ const rootElement = getRootContainer(options == null ? void 0 : options.container);
74
74
  rootElement.appendChild(rootWrapper);
75
75
  const ToastComponent = () => {
76
- const _a = options, { duration, allowMultiple, onClose } = _a, others = __objRest(_a, ["duration", "allowMultiple", "onClose"]);
76
+ const _a = options, {
77
+ duration,
78
+ allowMultiple,
79
+ onClose,
80
+ container: container
81
+ } = _a, others = __objRest(_a, [
82
+ "duration",
83
+ "allowMultiple",
84
+ "onClose",
85
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
86
+ "container"
87
+ ]);
77
88
  const [open, setOpen] = useState(false);
78
89
  let timer;
79
90
  const fadeTimeout = {
@@ -13,7 +13,6 @@
13
13
  position: fixed;
14
14
  left: 50%;
15
15
  z-index: var(--bui-z-index-toast);
16
- width: fit-content;
17
16
  min-width: var(--min-width);
18
17
  max-width: var(--max-width);
19
18
  padding: var(--padding);
@@ -49,6 +49,11 @@ export interface ToastProps extends FadeProps {
49
49
  * @default false
50
50
  */
51
51
  disableClick?: boolean;
52
+ /**
53
+ * 渲染Toast的根容器
54
+ * @default document.body
55
+ */
56
+ container?: HTMLElement | (() => HTMLElement);
52
57
  /**
53
58
  * 关闭时的回调函数
54
59
  */
@@ -26,14 +26,35 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
29
49
  import clsx from "clsx";
30
50
  import React, { useState, useRef, useEffect } from "react";
31
51
  import {
32
52
  getStylesAndLocation,
33
53
  triggerEventTransform,
34
54
  parsePlacement,
35
- useUniqueId,
36
- throttle
55
+ throttle,
56
+ useForkRef,
57
+ isMini
37
58
  } from "@bifrostui/utils";
38
59
  import Portal from "../Portal";
39
60
  import "./Tooltip.css";
@@ -48,8 +69,8 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
48
69
  offsetSpacing = 0,
49
70
  placement = "top",
50
71
  trigger = "click",
51
- onOpenChange,
52
- open
72
+ open,
73
+ onOpenChange
53
74
  } = _a, others = __objRest(_a, [
54
75
  "className",
55
76
  "style",
@@ -59,8 +80,8 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
59
80
  "offsetSpacing",
60
81
  "placement",
61
82
  "trigger",
62
- "onOpenChange",
63
- "open"
83
+ "open",
84
+ "onOpenChange"
64
85
  ]);
65
86
  const controlByUser = typeof open !== "undefined";
66
87
  const { direction, location = "center" } = parsePlacement(placement);
@@ -68,11 +89,18 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
68
89
  const [openStatus, setOpenStatus] = useState(defaultOpen);
69
90
  const [arrowDirection, setArrowDirection] = useState(direction);
70
91
  const [arrowLocation, setArrowLocation] = useState(location);
71
- const [tooltyles, setTooltyles] = useState({});
72
- const ttId = useUniqueId();
92
+ const [toolStyles, setToolStyles] = useState({});
93
+ const tipRef = useRef(null);
94
+ const nodeRef = useForkRef(ref, tipRef);
95
+ const clearRef = (status) => {
96
+ if (status === false) {
97
+ tipRef.current = null;
98
+ }
99
+ };
73
100
  const changeOpenStatus = (event, status) => {
74
101
  if (controlByUser)
75
102
  return;
103
+ clearRef(status);
76
104
  setOpenStatus(status);
77
105
  onOpenChange == null ? void 0 : onOpenChange(event, { open: status });
78
106
  };
@@ -91,23 +119,33 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
91
119
  if (!controlByUser)
92
120
  return;
93
121
  setOpenStatus(open);
122
+ clearRef(open);
94
123
  }, [open]);
124
+ useEffect(() => {
125
+ if (!openStatus) {
126
+ setToolStyles({
127
+ visibility: "hidden"
128
+ });
129
+ }
130
+ }, [openStatus]);
95
131
  const clickEventHandler = (event) => {
96
132
  if (trigger === "hover" || (trigger == null ? void 0 : trigger.length) === 1 && (trigger == null ? void 0 : trigger[0]) === "hover")
97
133
  return;
98
134
  hideTooltip(event);
99
135
  };
100
- const onRootElementMouted = throttle(() => {
136
+ const onRootElementMouted = throttle(() => __async(void 0, null, function* () {
137
+ if (!tipRef.current)
138
+ return;
101
139
  const {
102
140
  direction: newParsedDirection,
103
141
  location: newParsedLocation = "center"
104
142
  } = parsePlacement(placement);
105
- const result = getStylesAndLocation({
143
+ const result = yield getStylesAndLocation({
106
144
  childrenRef,
107
145
  arrowDirection: newParsedDirection,
108
146
  arrowLocation: newParsedLocation,
109
147
  offsetSpacing,
110
- selector: `[data-id="tt_${ttId}"]`
148
+ tipRef
111
149
  });
112
150
  if (!result)
113
151
  return;
@@ -118,26 +156,32 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
118
156
  if (newArrowLocation !== arrowLocation) {
119
157
  setArrowLocation(newArrowLocation);
120
158
  }
121
- setTooltyles(styles);
122
- }, 100);
123
- const bindEvent = () => {
124
- if (!controlByUser) {
125
- document.addEventListener("click", clickEventHandler);
126
- }
127
- window.addEventListener("resize", onRootElementMouted);
128
- };
129
- const unbindEvent = () => {
130
- if (!controlByUser) {
131
- document.removeEventListener("click", clickEventHandler);
132
- }
133
- window.removeEventListener("resize", onRootElementMouted);
134
- };
159
+ setToolStyles(styles);
160
+ }), 100);
135
161
  useEffect(() => {
162
+ const bindEvent = () => {
163
+ if (!openStatus)
164
+ return;
165
+ if (!controlByUser) {
166
+ document.addEventListener("click", clickEventHandler);
167
+ }
168
+ if (!isMini) {
169
+ window.addEventListener("resize", onRootElementMouted);
170
+ }
171
+ };
172
+ const unbindEvent = () => {
173
+ if (!controlByUser) {
174
+ document.removeEventListener("click", clickEventHandler);
175
+ }
176
+ if (!isMini) {
177
+ window.removeEventListener("resize", onRootElementMouted);
178
+ }
179
+ };
136
180
  bindEvent();
137
181
  return () => {
138
182
  unbindEvent();
139
183
  };
140
- }, []);
184
+ }, [openStatus]);
141
185
  let triggerEventOption;
142
186
  if (!controlByUser) {
143
187
  triggerEventOption = triggerEventTransform({
@@ -150,12 +194,12 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
150
194
  const childrenOptions = __spreadValues({
151
195
  ref: childrenRef
152
196
  }, triggerEventOption);
153
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (open || openStatus) && title ? /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted, ref }, /* @__PURE__ */ React.createElement(
197
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, (open || openStatus) && title ? /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted }, /* @__PURE__ */ React.createElement(
154
198
  "div",
155
199
  __spreadValues({
156
200
  className: clsx(prefixCls, className, `tooltip-${arrowDirection}`),
157
- style: __spreadValues(__spreadValues({}, style), tooltyles),
158
- "data-id": `tt_${ttId}`
201
+ style: __spreadValues(__spreadValues({}, style), toolStyles),
202
+ ref: nodeRef
159
203
  }, others),
160
204
  /* @__PURE__ */ React.createElement(
161
205
  "div",
package/es/index.d.ts CHANGED
@@ -8,6 +8,11 @@ export * from './Calendar';
8
8
  export * from './Card';
9
9
  export * from './Checkbox';
10
10
  export * from './Collapse';
11
+ export * from './DatePicker';
12
+ export * from './DesktopDatePicker';
13
+ export * from './DesktopTimePicker';
14
+ export * from './DesktopDateTimePicker';
15
+ export * from './DesktopPicker';
11
16
  export * from './Divider';
12
17
  export * from './Drawer';
13
18
  export * from './Fade';
@@ -48,3 +53,4 @@ export * from './Toast';
48
53
  export * from './Dialog';
49
54
  export * from './ThemeProvider';
50
55
  export * from './locales';
56
+ export * from './SwipeAction';
package/es/index.js CHANGED
@@ -8,6 +8,11 @@ export * from "./Calendar";
8
8
  export * from "./Card";
9
9
  export * from "./Checkbox";
10
10
  export * from "./Collapse";
11
+ export * from "./DatePicker";
12
+ export * from "./DesktopDatePicker";
13
+ export * from "./DesktopTimePicker";
14
+ export * from "./DesktopDateTimePicker";
15
+ export * from "./DesktopPicker";
11
16
  export * from "./Divider";
12
17
  export * from "./Drawer";
13
18
  export * from "./Fade";
@@ -48,3 +53,4 @@ export * from "./Toast";
48
53
  export * from "./Dialog";
49
54
  export * from "./ThemeProvider";
50
55
  export * from "./locales";
56
+ export * from "./SwipeAction";
@@ -37,4 +37,15 @@ export interface BaseLang {
37
37
  currentType?: Record<string, string>;
38
38
  hotCityType?: Record<string, string>;
39
39
  };
40
+ desktopDatePicker?: {
41
+ month?: Record<number, string>;
42
+ };
43
+ datePicker?: {
44
+ year: string;
45
+ month: string;
46
+ day: string;
47
+ hour: string;
48
+ minute: string;
49
+ second: string;
50
+ };
40
51
  }