@bifrostui/react 1.4.8-beta.0 → 1.5.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.
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { DatePickerProps } from './DatePicker.types';
3
- declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps<"div", Omit<import("../Picker").PickerProps<"div", import("..").DrawerProps>, "defaultValue" | "onChange" | "value" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
3
+ declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps<"div", Omit<import("../Picker").PickerProps<"div", import("..").DrawerProps>, "value" | "defaultValue" | "onChange" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
4
  export default DatePicker;
@@ -106,7 +106,8 @@ const DesktopPicker = /* @__PURE__ */ import_react.default.forwardRef(
106
106
  onMount,
107
107
  onUnmounted,
108
108
  containerWidth = "auto",
109
- BackdropProps
109
+ BackdropProps,
110
+ prefix = ""
110
111
  } = _a, others = __objRest(_a, [
111
112
  "className",
112
113
  "open",
@@ -120,12 +121,16 @@ const DesktopPicker = /* @__PURE__ */ import_react.default.forwardRef(
120
121
  "onMount",
121
122
  "onUnmounted",
122
123
  "containerWidth",
123
- "BackdropProps"
124
+ "BackdropProps",
125
+ "prefix"
124
126
  ]);
125
127
  const contentRef = (0, import_react.useRef)(null);
126
128
  const nodeRef = (0, import_react.useRef)(null);
127
129
  const renderChildren = import_react.default.cloneElement(children, {
128
- ref: nodeRef
130
+ ref: nodeRef,
131
+ style: {
132
+ flex: 1
133
+ }
129
134
  });
130
135
  const [contentPosition, setContentPosition] = (0, import_react.useState)(
131
136
  "bottom"
@@ -224,7 +229,7 @@ const DesktopPicker = /* @__PURE__ */ import_react.default.forwardRef(
224
229
  onMount == null ? void 0 : onMount();
225
230
  }
226
231
  }, [renderContainer]);
227
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(prefixCls, className) }, others), renderChildren), !import_utils.isMini && renderContainer && /* @__PURE__ */ import_react.default.createElement(import_Portal.default, null, renderContent()), import_utils.isMini && renderContainer && /* @__PURE__ */ import_react.default.createElement(import_Portal.default, null, renderContent(), !miniBackdropInvisible && /* @__PURE__ */ import_react.default.createElement(
232
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(prefixCls, className) }, others), prefix, renderChildren), !import_utils.isMini && renderContainer && /* @__PURE__ */ import_react.default.createElement(import_Portal.default, null, renderContent()), import_utils.isMini && renderContainer && /* @__PURE__ */ import_react.default.createElement(import_Portal.default, null, renderContent(), !miniBackdropInvisible && /* @__PURE__ */ import_react.default.createElement(
228
233
  import_Backdrop.default,
229
234
  __spreadProps(__spreadValues({}, BackdropProps), {
230
235
  invisible: true,
@@ -3,6 +3,10 @@ import { OverrideProps } from '@bifrostui/types';
3
3
  import { BackdropProps } from '../Backdrop/Backdrop.types';
4
4
  export type DesktopPickerProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
5
5
  props: P & {
6
+ /**
7
+ * 前缀
8
+ */
9
+ prefix?: React.ReactNode | string;
6
10
  /**
7
11
  * 是否继承宽度
8
12
  * @default true
@@ -6,6 +6,8 @@ xhs-page {
6
6
  --bui-desktop-picker-shadow: 0 0 0 2px var(--bui-color-bg-default);
7
7
  }
8
8
  .bui-desktop-picker {
9
+ display: flex;
10
+ align-items: center;
9
11
  position: relative;
10
12
  height: 100%;
11
13
  }
@@ -44,6 +44,11 @@ export interface DialogProps extends ModalProps {
44
44
  * theme 主题定制
45
45
  */
46
46
  theme?: ThemeProps;
47
+ /**
48
+ * 渲染Dialog的根容器
49
+ * @default document.body
50
+ */
51
+ container?: HTMLElement | (() => HTMLElement);
47
52
  /**
48
53
  * 确认回调
49
54
  */
@@ -91,10 +91,21 @@ const formatProps = (props) => {
91
91
  };
92
92
  const DialogGenerator = (options) => {
93
93
  const rootWrapper = document.createElement("div");
94
- const rootElement = (0, import_utils.getRootContainer)();
94
+ const rootElement = (0, import_utils.getRootContainer)(options == null ? void 0 : options.container);
95
95
  rootElement.appendChild(rootWrapper);
96
96
  const DialogComponent = () => {
97
- const _a = options, { onConfirm, onCancel, ref } = _a, others = __objRest(_a, ["onConfirm", "onCancel", "ref"]);
97
+ const _a = options, {
98
+ onConfirm,
99
+ onCancel,
100
+ ref,
101
+ container: container
102
+ } = _a, others = __objRest(_a, [
103
+ "onConfirm",
104
+ "onCancel",
105
+ "ref",
106
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
107
+ "container"
108
+ ]);
98
109
  const [visible, setVisible] = (0, import_react.useState)(false);
99
110
  const close = (0, import_react.useCallback)(() => {
100
111
  setVisible(false);
@@ -31,8 +31,6 @@
31
31
  .bui-input-input {
32
32
  flex: 1;
33
33
  min-width: 0;
34
- display: flex;
35
- align-items: center;
36
34
  padding: 0;
37
35
  height: 100%;
38
36
  color: var(--bui-color-fg-default);
@@ -100,10 +100,21 @@ const functionalToast = (props) => {
100
100
  rootWrapper.style[property] = styles[property];
101
101
  });
102
102
  }
103
- const rootElement = (0, import_utils.getRootContainer)();
103
+ const rootElement = (0, import_utils.getRootContainer)(options == null ? void 0 : options.container);
104
104
  rootElement.appendChild(rootWrapper);
105
105
  const ToastComponent = () => {
106
- const _a = options, { duration, allowMultiple, onClose } = _a, others = __objRest(_a, ["duration", "allowMultiple", "onClose"]);
106
+ const _a = options, {
107
+ duration,
108
+ allowMultiple,
109
+ onClose,
110
+ container: container
111
+ } = _a, others = __objRest(_a, [
112
+ "duration",
113
+ "allowMultiple",
114
+ "onClose",
115
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
116
+ "container"
117
+ ]);
107
118
  const [open, setOpen] = (0, import_react.useState)(false);
108
119
  let timer;
109
120
  const fadeTimeout = {
@@ -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
  */
@@ -86,7 +86,8 @@ const DesktopPicker = /* @__PURE__ */ React.forwardRef(
86
86
  onMount,
87
87
  onUnmounted,
88
88
  containerWidth = "auto",
89
- BackdropProps
89
+ BackdropProps,
90
+ prefix = ""
90
91
  } = _a, others = __objRest(_a, [
91
92
  "className",
92
93
  "open",
@@ -100,12 +101,16 @@ const DesktopPicker = /* @__PURE__ */ React.forwardRef(
100
101
  "onMount",
101
102
  "onUnmounted",
102
103
  "containerWidth",
103
- "BackdropProps"
104
+ "BackdropProps",
105
+ "prefix"
104
106
  ]);
105
107
  const contentRef = useRef(null);
106
108
  const nodeRef = useRef(null);
107
109
  const renderChildren = React.cloneElement(children, {
108
- ref: nodeRef
110
+ ref: nodeRef,
111
+ style: {
112
+ flex: 1
113
+ }
109
114
  });
110
115
  const [contentPosition, setContentPosition] = useState(
111
116
  "bottom"
@@ -204,7 +209,7 @@ const DesktopPicker = /* @__PURE__ */ React.forwardRef(
204
209
  onMount == null ? void 0 : onMount();
205
210
  }
206
211
  }, [renderContainer]);
207
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), renderChildren), !isMini && renderContainer && /* @__PURE__ */ React.createElement(Portal, null, renderContent()), isMini && renderContainer && /* @__PURE__ */ React.createElement(Portal, null, renderContent(), !miniBackdropInvisible && /* @__PURE__ */ React.createElement(
212
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), prefix, renderChildren), !isMini && renderContainer && /* @__PURE__ */ React.createElement(Portal, null, renderContent()), isMini && renderContainer && /* @__PURE__ */ React.createElement(Portal, null, renderContent(), !miniBackdropInvisible && /* @__PURE__ */ React.createElement(
208
213
  Backdrop,
209
214
  __spreadProps(__spreadValues({}, BackdropProps), {
210
215
  invisible: true,
@@ -3,6 +3,10 @@ import { OverrideProps } from '@bifrostui/types';
3
3
  import { BackdropProps } from '../Backdrop/Backdrop.types';
4
4
  export type DesktopPickerProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
5
5
  props: P & {
6
+ /**
7
+ * 前缀
8
+ */
9
+ prefix?: React.ReactNode | string;
6
10
  /**
7
11
  * 是否继承宽度
8
12
  * @default true
@@ -6,6 +6,8 @@ xhs-page {
6
6
  --bui-desktop-picker-shadow: 0 0 0 2px var(--bui-color-bg-default);
7
7
  }
8
8
  .bui-desktop-picker {
9
+ display: flex;
10
+ align-items: center;
9
11
  position: relative;
10
12
  height: 100%;
11
13
  }
@@ -44,6 +44,11 @@ export interface DialogProps extends ModalProps {
44
44
  * theme 主题定制
45
45
  */
46
46
  theme?: ThemeProps;
47
+ /**
48
+ * 渲染Dialog的根容器
49
+ * @default document.body
50
+ */
51
+ container?: HTMLElement | (() => HTMLElement);
47
52
  /**
48
53
  * 确认回调
49
54
  */
@@ -61,10 +61,21 @@ const formatProps = (props) => {
61
61
  };
62
62
  const DialogGenerator = (options) => {
63
63
  const rootWrapper = document.createElement("div");
64
- const rootElement = getRootContainer();
64
+ const rootElement = getRootContainer(options == null ? void 0 : options.container);
65
65
  rootElement.appendChild(rootWrapper);
66
66
  const DialogComponent = () => {
67
- const _a = options, { onConfirm, onCancel, ref } = _a, others = __objRest(_a, ["onConfirm", "onCancel", "ref"]);
67
+ const _a = options, {
68
+ onConfirm,
69
+ onCancel,
70
+ ref,
71
+ container: container
72
+ } = _a, others = __objRest(_a, [
73
+ "onConfirm",
74
+ "onCancel",
75
+ "ref",
76
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
77
+ "container"
78
+ ]);
68
79
  const [visible, setVisible] = useState(false);
69
80
  const close = useCallback(() => {
70
81
  setVisible(false);
@@ -31,8 +31,6 @@
31
31
  .bui-input-input {
32
32
  flex: 1;
33
33
  min-width: 0;
34
- display: flex;
35
- align-items: center;
36
34
  padding: 0;
37
35
  height: 100%;
38
36
  color: var(--bui-color-fg-default);
@@ -12,5 +12,5 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
12
12
  keepMounted?: boolean;
13
13
  } & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
14
14
  ref?: React.Ref<HTMLDivElement>;
15
- }, "open" | keyof import("@bifrostui/types").ICommonProps | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, "open" | "container" | "disablePortal" | keyof import("@bifrostui/types").ICommonProps | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Modal;
@@ -70,10 +70,21 @@ const functionalToast = (props) => {
70
70
  rootWrapper.style[property] = styles[property];
71
71
  });
72
72
  }
73
- const rootElement = getRootContainer();
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 = {
@@ -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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/react",
3
- "version": "1.4.8-beta.0",
3
+ "version": "1.5.0",
4
4
  "description": "React components for building mobile application",
5
5
  "homepage": "http://bui.taopiaopiao.com",
6
6
  "license": "MIT",
@@ -33,10 +33,10 @@
33
33
  "clsx": "^1.2.1",
34
34
  "dayjs": "^1.11.7",
35
35
  "swiper": "^8.1.5",
36
- "@bifrostui/icons": "1.4.8-beta.0",
37
- "@bifrostui/styles": "1.4.8-beta.0",
38
- "@bifrostui/types": "1.4.8-beta.0",
39
- "@bifrostui/utils": "1.4.8-beta.0"
36
+ "@bifrostui/icons": "1.5.0",
37
+ "@bifrostui/types": "1.5.0",
38
+ "@bifrostui/utils": "1.5.0",
39
+ "@bifrostui/styles": "1.5.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@tarojs/components": "^3.0.0",