@bifrostui/react 2.0.0-alpha.25 → 2.0.0-alpha.27

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>, "value" | "defaultValue" | "onChange" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
3
+ declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps<"div", Omit<import("../Picker").PickerProps<"div", import("..").DrawerProps>, "defaultValue" | "value" | "onChange" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
4
  export default DatePicker;
@@ -75,8 +75,6 @@ const Modal = /* @__PURE__ */ React.forwardRef((props, ref) => {
75
75
  container,
76
76
  disablePortal = false,
77
77
  disableScrollLock = false,
78
- disableAutoFocus = false,
79
- disableRestoreFocus = false,
80
78
  hideBackdrop = false,
81
79
  onClose,
82
80
  keepMounted = false
@@ -88,8 +86,6 @@ const Modal = /* @__PURE__ */ React.forwardRef((props, ref) => {
88
86
  "container",
89
87
  "disablePortal",
90
88
  "disableScrollLock",
91
- "disableAutoFocus",
92
- "disableRestoreFocus",
93
89
  "hideBackdrop",
94
90
  "onClose",
95
91
  "keepMounted"
@@ -104,9 +100,7 @@ const Modal = /* @__PURE__ */ React.forwardRef((props, ref) => {
104
100
  } = (0, import_useModal.useModal)(__spreadProps(__spreadValues({}, props), {
105
101
  container,
106
102
  disableScrollLock,
107
- disableAutoFocus,
108
- disableRestoreFocus,
109
- children,
103
+ children: React.isValidElement(children) ? children : void 0,
110
104
  open,
111
105
  onClose,
112
106
  rootRef: ref
@@ -10,9 +10,7 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
10
10
  disableScrollLock?: boolean;
11
11
  disablePortal?: boolean;
12
12
  keepMounted?: boolean;
13
- disableAutoFocus?: boolean;
14
- disableRestoreFocus?: boolean;
15
13
  } & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
16
14
  ref?: React.Ref<HTMLDivElement>;
17
- }, "open" | "container" | keyof import("@bifrostui/types").ICommonProps | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted" | "disableAutoFocus" | "disableRestoreFocus">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, keyof import("@bifrostui/types").ICommonProps | "open" | "container" | "BackdropProps" | "onClose" | "keepMounted" | "disablePortal" | "hideBackdrop" | "disableScrollLock">, "ref"> & React.RefAttributes<HTMLDivElement>>;
18
16
  export default Modal;
@@ -39,19 +39,6 @@ export type ModalProps<D extends React.ElementType = 'div', P = {}> = OverridePr
39
39
  * 是否保持挂载状态
40
40
  */
41
41
  keepMounted?: boolean;
42
- /**
43
- * 是否禁用自动焦点管理
44
- * 仅web端生效
45
- * @default false
46
- *
47
- */
48
- disableAutoFocus?: boolean;
49
- /**
50
- * 是否禁用在关闭时恢复焦点到触发元素
51
- * 仅web端生效
52
- * @default false
53
- */
54
- disableRestoreFocus?: boolean;
55
42
  };
56
43
  defaultComponent: D;
57
44
  }, D>;
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  export interface UseModalParameters {
3
3
  container?: Element | (() => Element | null) | null;
4
4
  disableScrollLock?: boolean;
5
- disableAutoFocus?: boolean;
6
- disableRestoreFocus?: boolean;
7
5
  onClose?: (event: React.SyntheticEvent<Element, Event>, detail?: {
8
6
  from: 'backdropClick' | 'escapeKeyDown';
9
7
  }) => void;
@@ -53,8 +53,6 @@ function useModal(parameters) {
53
53
  const {
54
54
  container,
55
55
  disableScrollLock = false,
56
- disableAutoFocus = false,
57
- disableRestoreFocus = false,
58
56
  onClose,
59
57
  open,
60
58
  rootRef,
@@ -69,7 +67,6 @@ function useModal(parameters) {
69
67
  const handleRef = (0, import_utils.useForkRef)(modalRef, rootRef);
70
68
  const [exited, setExited] = (0, import_react.useState)(!open);
71
69
  const hasTransition = getHasTransition(children);
72
- const lastFocusedElement = (0, import_react.useRef)(null);
73
70
  let ariaHiddenProp = true;
74
71
  if (parameters["aria-hidden"] === "false" || parameters["aria-hidden"] === false) {
75
72
  ariaHiddenProp = false;
@@ -123,38 +120,6 @@ function useModal(parameters) {
123
120
  handleClose();
124
121
  }
125
122
  }, [open, handleClose, hasTransition, handleOpen]);
126
- (0, import_react.useEffect)(() => {
127
- if (open && modalRef.current) {
128
- const doc = modalRef.current.ownerDocument || document;
129
- if (!lastFocusedElement.current) {
130
- lastFocusedElement.current = doc.activeElement;
131
- }
132
- if (!disableAutoFocus) {
133
- if (!modalRef.current.contains(doc.activeElement)) {
134
- if (!modalRef.current.hasAttribute("tabIndex")) {
135
- modalRef.current.setAttribute("tabIndex", "-1");
136
- }
137
- const autoFocusElement = modalRef.current.querySelector(
138
- '[autofocus], [tabindex="-1"]'
139
- );
140
- if (autoFocusElement) {
141
- autoFocusElement.focus();
142
- } else {
143
- modalRef.current.focus();
144
- }
145
- }
146
- }
147
- return () => {
148
- if (!disableRestoreFocus && lastFocusedElement.current) {
149
- if (lastFocusedElement.current && typeof lastFocusedElement.current.focus === "function") {
150
- lastFocusedElement.current.focus();
151
- }
152
- lastFocusedElement.current = null;
153
- }
154
- };
155
- }
156
- return void 0;
157
- }, [open, disableAutoFocus, disableRestoreFocus]);
158
123
  const createHandleBackdropClick = (backdropHandlers = {}) => (event) => {
159
124
  var _a;
160
125
  (_a = backdropHandlers.onClick) == null ? void 0 : _a.call(backdropHandlers, event);
@@ -39,6 +39,7 @@ xhs-page {
39
39
  .bui-tabs-scroll-wrapper {
40
40
  height: 100%;
41
41
  display: flex;
42
+ flex-direction: row;
42
43
  flex-wrap: nowrap;
43
44
  justify-content: flex-start;
44
45
  align-items: center;
@@ -39,6 +39,7 @@ xhs-page {
39
39
  .bui-tabs-scroll-wrapper {
40
40
  height: 100%;
41
41
  display: flex;
42
+ flex-direction: row;
42
43
  flex-wrap: nowrap;
43
44
  justify-content: flex-start;
44
45
  align-items: center;
@@ -232,8 +232,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
232
232
  onScroll: handleScroll,
233
233
  enhanced: true,
234
234
  showScrollbar: false,
235
- enablePassive: true,
236
- enableFlex: true
235
+ enablePassive: true
237
236
  },
238
237
  /* @__PURE__ */ import_react.default.createElement("div", { id: wrapperId, className: import_classes.tabsScrollWrapperClass }, /* @__PURE__ */ import_react.default.createElement(
239
238
  import_TabIndicator.default,
@@ -86,8 +86,7 @@ const Toast = (props) => {
86
86
  };
87
87
  const _a = options, { container } = _a, restOptions = __objRest(_a, ["container"]);
88
88
  const rootWrapper = document.createElement("div");
89
- const rootElement = (0, import_utils.getRootContainer)(container);
90
- rootElement == null ? void 0 : rootElement.appendChild(rootWrapper);
89
+ document.body.appendChild(rootWrapper);
91
90
  const ToastComponent = () => {
92
91
  const _a2 = restOptions, { duration, multiple, onClose, onExited } = _a2, others = __objRest(_a2, ["duration", "multiple", "onClose", "onExited"]);
93
92
  const [open, setOpen] = (0, import_react.useState)(true);
@@ -125,7 +124,7 @@ const Toast = (props) => {
125
124
  }
126
125
  };
127
126
  instance.close = close;
128
- return /* @__PURE__ */ import_react.default.createElement(import_Toast.default, __spreadProps(__spreadValues({}, others), { open, onExited: onProxyExited }));
127
+ return /* @__PURE__ */ import_react.default.createElement(import_Portal.default, { container }, /* @__PURE__ */ import_react.default.createElement(import_Toast.default, __spreadProps(__spreadValues({}, others), { open, onExited: onProxyExited })));
129
128
  };
130
129
  (0, import_utils.render)(/* @__PURE__ */ import_react.default.createElement(ToastComponent, null), rootWrapper);
131
130
  return instance;
package/es/Modal/Modal.js CHANGED
@@ -45,8 +45,6 @@ const Modal = /* @__PURE__ */ React.forwardRef((props, ref) => {
45
45
  container,
46
46
  disablePortal = false,
47
47
  disableScrollLock = false,
48
- disableAutoFocus = false,
49
- disableRestoreFocus = false,
50
48
  hideBackdrop = false,
51
49
  onClose,
52
50
  keepMounted = false
@@ -58,8 +56,6 @@ const Modal = /* @__PURE__ */ React.forwardRef((props, ref) => {
58
56
  "container",
59
57
  "disablePortal",
60
58
  "disableScrollLock",
61
- "disableAutoFocus",
62
- "disableRestoreFocus",
63
59
  "hideBackdrop",
64
60
  "onClose",
65
61
  "keepMounted"
@@ -74,9 +70,7 @@ const Modal = /* @__PURE__ */ React.forwardRef((props, ref) => {
74
70
  } = useModal(__spreadProps(__spreadValues({}, props), {
75
71
  container,
76
72
  disableScrollLock,
77
- disableAutoFocus,
78
- disableRestoreFocus,
79
- children,
73
+ children: React.isValidElement(children) ? children : void 0,
80
74
  open,
81
75
  onClose,
82
76
  rootRef: ref
@@ -10,9 +10,7 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
10
10
  disableScrollLock?: boolean;
11
11
  disablePortal?: boolean;
12
12
  keepMounted?: boolean;
13
- disableAutoFocus?: boolean;
14
- disableRestoreFocus?: boolean;
15
13
  } & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
16
14
  ref?: React.Ref<HTMLDivElement>;
17
- }, keyof import("@bifrostui/types").ICommonProps | "open" | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted" | "disableAutoFocus" | "disableRestoreFocus">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, "open" | "container" | "disableScrollLock" | "onClose" | keyof import("@bifrostui/types").ICommonProps | "BackdropProps" | "disablePortal" | "keepMounted" | "hideBackdrop">, "ref"> & React.RefAttributes<HTMLDivElement>>;
18
16
  export default Modal;
@@ -39,19 +39,6 @@ export type ModalProps<D extends React.ElementType = 'div', P = {}> = OverridePr
39
39
  * 是否保持挂载状态
40
40
  */
41
41
  keepMounted?: boolean;
42
- /**
43
- * 是否禁用自动焦点管理
44
- * 仅web端生效
45
- * @default false
46
- *
47
- */
48
- disableAutoFocus?: boolean;
49
- /**
50
- * 是否禁用在关闭时恢复焦点到触发元素
51
- * 仅web端生效
52
- * @default false
53
- */
54
- disableRestoreFocus?: boolean;
55
42
  };
56
43
  defaultComponent: D;
57
44
  }, D>;
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  export interface UseModalParameters {
3
3
  container?: Element | (() => Element | null) | null;
4
4
  disableScrollLock?: boolean;
5
- disableAutoFocus?: boolean;
6
- disableRestoreFocus?: boolean;
7
5
  onClose?: (event: React.SyntheticEvent<Element, Event>, detail?: {
8
6
  from: 'backdropClick' | 'escapeKeyDown';
9
7
  }) => void;
@@ -33,8 +33,6 @@ function useModal(parameters) {
33
33
  const {
34
34
  container,
35
35
  disableScrollLock = false,
36
- disableAutoFocus = false,
37
- disableRestoreFocus = false,
38
36
  onClose,
39
37
  open,
40
38
  rootRef,
@@ -49,7 +47,6 @@ function useModal(parameters) {
49
47
  const handleRef = useForkRef(modalRef, rootRef);
50
48
  const [exited, setExited] = useState(!open);
51
49
  const hasTransition = getHasTransition(children);
52
- const lastFocusedElement = useRef(null);
53
50
  let ariaHiddenProp = true;
54
51
  if (parameters["aria-hidden"] === "false" || parameters["aria-hidden"] === false) {
55
52
  ariaHiddenProp = false;
@@ -103,38 +100,6 @@ function useModal(parameters) {
103
100
  handleClose();
104
101
  }
105
102
  }, [open, handleClose, hasTransition, handleOpen]);
106
- useEffect(() => {
107
- if (open && modalRef.current) {
108
- const doc = modalRef.current.ownerDocument || document;
109
- if (!lastFocusedElement.current) {
110
- lastFocusedElement.current = doc.activeElement;
111
- }
112
- if (!disableAutoFocus) {
113
- if (!modalRef.current.contains(doc.activeElement)) {
114
- if (!modalRef.current.hasAttribute("tabIndex")) {
115
- modalRef.current.setAttribute("tabIndex", "-1");
116
- }
117
- const autoFocusElement = modalRef.current.querySelector(
118
- '[autofocus], [tabindex="-1"]'
119
- );
120
- if (autoFocusElement) {
121
- autoFocusElement.focus();
122
- } else {
123
- modalRef.current.focus();
124
- }
125
- }
126
- }
127
- return () => {
128
- if (!disableRestoreFocus && lastFocusedElement.current) {
129
- if (lastFocusedElement.current && typeof lastFocusedElement.current.focus === "function") {
130
- lastFocusedElement.current.focus();
131
- }
132
- lastFocusedElement.current = null;
133
- }
134
- };
135
- }
136
- return void 0;
137
- }, [open, disableAutoFocus, disableRestoreFocus]);
138
103
  const createHandleBackdropClick = (backdropHandlers = {}) => (event) => {
139
104
  var _a;
140
105
  (_a = backdropHandlers.onClick) == null ? void 0 : _a.call(backdropHandlers, event);
package/es/Tabs/Tabs.css CHANGED
@@ -39,6 +39,7 @@ xhs-page {
39
39
  .bui-tabs-scroll-wrapper {
40
40
  height: 100%;
41
41
  display: flex;
42
+ flex-direction: row;
42
43
  flex-wrap: nowrap;
43
44
  justify-content: flex-start;
44
45
  align-items: center;
package/es/Tabs/index.css CHANGED
@@ -39,6 +39,7 @@ xhs-page {
39
39
  .bui-tabs-scroll-wrapper {
40
40
  height: 100%;
41
41
  display: flex;
42
+ flex-direction: row;
42
43
  flex-wrap: nowrap;
43
44
  justify-content: flex-start;
44
45
  align-items: center;
@@ -207,8 +207,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
207
207
  onScroll: handleScroll,
208
208
  enhanced: true,
209
209
  showScrollbar: false,
210
- enablePassive: true,
211
- enableFlex: true
210
+ enablePassive: true
212
211
  },
213
212
  /* @__PURE__ */ React.createElement("div", { id: wrapperId, className: tabsScrollWrapperClass }, /* @__PURE__ */ React.createElement(
214
213
  TabIndicator,
@@ -35,7 +35,7 @@ import React, {
35
35
  useState,
36
36
  useRef
37
37
  } from "react";
38
- import { render, unmount, getRootContainer } from "@bifrostui/utils";
38
+ import { render, unmount } from "@bifrostui/utils";
39
39
  import Portal from "../Portal";
40
40
  import ToastView from "./Toast";
41
41
  const defaultProps = {
@@ -61,8 +61,7 @@ const Toast = (props) => {
61
61
  };
62
62
  const _a = options, { container } = _a, restOptions = __objRest(_a, ["container"]);
63
63
  const rootWrapper = document.createElement("div");
64
- const rootElement = getRootContainer(container);
65
- rootElement == null ? void 0 : rootElement.appendChild(rootWrapper);
64
+ document.body.appendChild(rootWrapper);
66
65
  const ToastComponent = () => {
67
66
  const _a2 = restOptions, { duration, multiple, onClose, onExited } = _a2, others = __objRest(_a2, ["duration", "multiple", "onClose", "onExited"]);
68
67
  const [open, setOpen] = useState(true);
@@ -100,7 +99,7 @@ const Toast = (props) => {
100
99
  }
101
100
  };
102
101
  instance.close = close;
103
- return /* @__PURE__ */ React.createElement(ToastView, __spreadProps(__spreadValues({}, others), { open, onExited: onProxyExited }));
102
+ return /* @__PURE__ */ React.createElement(Portal, { container }, /* @__PURE__ */ React.createElement(ToastView, __spreadProps(__spreadValues({}, others), { open, onExited: onProxyExited })));
104
103
  };
105
104
  render(/* @__PURE__ */ React.createElement(ToastComponent, null), rootWrapper);
106
105
  return instance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/react",
3
- "version": "2.0.0-alpha.25",
3
+ "version": "2.0.0-alpha.27",
4
4
  "description": "React components for building mobile application",
5
5
  "homepage": "http://bui.taopiaopiao.com",
6
6
  "license": "MIT",
@@ -43,10 +43,10 @@
43
43
  "clsx": "^2.1.1",
44
44
  "dayjs": "^1.11.7",
45
45
  "swiper": "^8.1.5",
46
- "@bifrostui/icons": "2.0.0-alpha.25",
47
- "@bifrostui/types": "2.0.0-alpha.25",
48
- "@bifrostui/styles": "2.0.0-alpha.25",
49
- "@bifrostui/utils": "2.0.0-alpha.25"
46
+ "@bifrostui/styles": "2.0.0-alpha.27",
47
+ "@bifrostui/icons": "2.0.0-alpha.27",
48
+ "@bifrostui/types": "2.0.0-alpha.27",
49
+ "@bifrostui/utils": "2.0.0-alpha.27"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@tarojs/components": "^3.0.0",