@nutui/nutui-react 2.0.0-alpha.2 → 2.0.0-alpha.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v2.0.0-alpha.3
2
+ `2023-04-28`
3
+
4
+ * :bug: fix: overlay 属性 onClick 暴露、lockscroll 相关demo 修订 (#959) @xiaoyatong
5
+ * :bug: fix: 修改taro增加主题编译 (#950) @junjun666
6
+ * 🛠 refactor: dialog (#945) @xiaoyatong
7
+ * 🛠 refactor: switch (#941) @拧巴的猫
8
+ * 🛠 refactor: tabs (#939) @oasis-cloud
9
+ * 🔨 chore: website 2.0 (#955) @oasis-cloud
10
+ * 📖 docs: button 文档表格优化 (#956) @oasis-cloud
11
+
12
+
1
13
  # v2.0.0-alpha.2
2
14
  `2023-04-26`
3
15
 
@@ -26,19 +26,9 @@ import React__default, { useState, useRef, useEffect } from "react";
26
26
  import classNames from "classnames";
27
27
  import { c as cn } from "./bem.js";
28
28
  import { U as Utils } from "./date.js";
29
+ import { r as requestAniFrame } from "./raf.js";
29
30
  import { useConfig } from "./ConfigProvider.js";
30
31
  import "@bem-react/classname";
31
- function requestAniFrame() {
32
- if (typeof window !== "undefined") {
33
- return window.requestAnimationFrame || function(callback) {
34
- window.setTimeout(callback, 1e3 / 60);
35
- };
36
- }
37
- return function(callback) {
38
- setTimeout(callback, 1e3 / 60);
39
- };
40
- }
41
- var requestAniFrame$1 = requestAniFrame();
42
32
  var defaultProps = {
43
33
  type: "one",
44
34
  isAutoBackFill: false,
@@ -510,7 +500,7 @@ var CalendarItem = React__default.forwardRef(function(props, ref) {
510
500
  }
511
501
  var lastItem = state.monthsData[state.monthsData.length - 1];
512
502
  var containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
513
- requestAniFrame$1(function() {
503
+ requestAniFrame(function() {
514
504
  if (months && monthsPanel && viewArea) {
515
505
  viewHeight = months.current.clientHeight;
516
506
  monthsPanel.current.style.height = "".concat(containerHeight, "px");
@@ -52,6 +52,8 @@ import { Loading, Checklist } from "@nutui/icons-react";
52
52
  import { c as cn } from "./bem.js";
53
53
  import "./typings.js";
54
54
  import "./TabPane.js";
55
+ import "./raf.js";
56
+ import "./use-props-value.js";
55
57
  import "@bem-react/classname";
56
58
  var defaultProps$1 = {
57
59
  data: {
@@ -608,7 +610,7 @@ var InternalCascader = function InternalCascader2(props, ref) {
608
610
  className: b("title")
609
611
  }, title), React__default.createElement(Tabs, {
610
612
  value: tabvalue,
611
- titleNode: function titleNode() {
613
+ title: function title2() {
612
614
  return optionsData.map(function(pane, index) {
613
615
  var _pane$selectedNode, _pane$selectedNode2;
614
616
  return React__default.createElement("div", {
@@ -631,7 +633,7 @@ var InternalCascader = function InternalCascader2(props, ref) {
631
633
  }, !state.initLoading && state.panes.length ? optionsData.map(function(pane) {
632
634
  return React__default.createElement(TabPane, {
633
635
  key: pane.paneKey,
634
- paneKey: pane.paneKey
636
+ value: pane.paneKey
635
637
  }, React__default.createElement("div", {
636
638
  className: classesPane
637
639
  }, pane.nodes && pane.nodes.map(function(node, index) {
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- var _excluded = ["visible", "footer", "noFooter", "noOkBtn", "noCancelBtn", "lockScroll", "okBtnDisabled", "cancelAutoClose", "confirmText", "cancelText", "onClosed", "onCancel", "onOk"];
3
+ var _excluded = ["visible", "footer", "hideConfirmButton", "hideCancelButton", "lockScroll", "disableConfirmButton", "closeOnOverlayClick", "confirmText", "cancelText", "onClose", "onCancel", "onConfirm", "beforeCancel", "beforeClose"];
4
4
  function ownKeys(object, enumerableOnly) {
5
5
  var keys = Object.keys(object);
6
6
  if (Object.getOwnPropertySymbols) {
@@ -22,262 +22,253 @@ function _objectSpread(target) {
22
22
  }
23
23
  return target;
24
24
  }
25
- import * as React from "react";
26
- import React__default, { useEffect, forwardRef } from "react";
25
+ import React__default, { forwardRef } from "react";
27
26
  import classNames from "classnames";
28
27
  import Button from "./Button.js";
29
- import { CSSTransition } from "react-transition-group";
30
28
  import { r as render, u as unmount } from "./render.js";
29
+ import { CSSTransition } from "react-transition-group";
30
+ import { d as defaultOverlayProps } from "./overlay2.js";
31
+ import { C as ComponentDefaults } from "./typings.js";
32
+ import Overlay from "./Overlay.js";
33
+ import { useConfig } from "./ConfigProvider.js";
31
34
  import "react-dom";
32
- var Content = function Content2(props) {
33
- var visible = props.visible, title = props.title, footer = props.footer, textAlign = props.textAlign, footerDirection = props.footerDirection, onClickSelf = props.onClickSelf, children = props.children;
34
- var headerNode;
35
- if (title) {
36
- headerNode = React__default.createElement("div", {
37
- className: "nut-dialog__header"
38
- }, title);
39
- }
40
- var footerNode;
41
- if (footer) {
42
- footerNode = React__default.createElement("div", {
43
- className: classNames("nut-dialog__footer", _defineProperty({}, footerDirection, footerDirection))
44
- }, footer);
45
- }
46
- var handleClick = function handleClick2() {
47
- onClickSelf && onClickSelf();
48
- };
49
- return React__default.createElement("div", {
50
- className: "nut-dialog__outer",
51
- onClick: handleClick
52
- }, React__default.createElement("div", {
53
- className: "nut-dialog",
54
- style: {
55
- display: visible ? "flex" : "none"
56
- }
57
- }, headerNode, React__default.createElement("div", {
58
- className: "nut-dialog__content",
59
- style: {
60
- textAlign
61
- }
62
- }, React__default.createElement("div", null, children)), footerNode));
63
- };
64
- Content.displayName = "NutContent";
65
- function Mask(props) {
66
- return React.createElement("div", {
67
- className: "nut-dialog__mask"
68
- });
69
- }
70
- var DialogWrap = function DialogWrap2(props) {
71
- var className = props.className, style = props.style, visible = props.visible, mask = props.mask, closeOnClickOverlay = props.closeOnClickOverlay, lockScroll = props.lockScroll, onClosed = props.onClosed, onCancel = props.onCancel;
72
- var handleClick = function handleClick2(e) {
73
- if (closeOnClickOverlay && visible && e.target === e.currentTarget) {
74
- onClosed === null || onClosed === void 0 ? void 0 : onClosed();
75
- onCancel === null || onCancel === void 0 ? void 0 : onCancel();
76
- lockScroll && document.body.classList.remove("nut-overflow-hidden");
77
- }
78
- };
79
- var wrapStyle = _objectSpread(_objectSpread({}, style), {}, {
80
- display: visible ? "block" : "none"
81
- });
82
- if (lockScroll && visible) {
83
- document.body.classList.add("nut-overflow-hidden");
84
- }
85
- return React__default.createElement(React__default.Fragment, null, mask ? React__default.createElement(CSSTransition, {
86
- "in": visible,
87
- timeout: 300,
88
- classNames: "fadeDialog",
89
- unmountOnExit: true,
90
- appear: true
91
- }, React__default.createElement(Mask, null)) : null, React__default.createElement("div", {
92
- className: classNames("nut-dialog__wrap", className),
93
- onClick: handleClick,
94
- style: wrapStyle
95
- }, React__default.createElement(Content, _objectSpread(_objectSpread({}, props), {}, {
96
- visible
97
- }))));
98
- };
99
- DialogWrap.displayName = "NutDialogWrap";
100
- var DialogWrapper = function DialogWrapper2(props) {
101
- var visible = props.visible, lockScroll = props.lockScroll;
102
- useEffect(function() {
103
- if (lockScroll && visible) {
104
- document.body.classList.add("nut-overflow-hidden");
105
- } else {
106
- document.body.classList.remove("nut-overflow-hidden");
107
- }
108
- }, [visible]);
109
- useEffect(function() {
110
- return function() {
111
- if (document.body.classList.value.includes("nut-overflow-hidden")) {
112
- document.body.classList.remove("nut-overflow-hidden");
113
- }
114
- };
115
- }, []);
116
- return React__default.createElement("div", {
117
- style: {
118
- display: visible ? "block" : "none"
119
- }
120
- }, React__default.createElement(DialogWrap, _objectSpread({}, props)));
121
- };
122
- DialogWrapper.displayName = "NutDialogWrapper";
123
35
  function ConfirmDialog(props) {
124
36
  return React__default.createElement(Dialog, _objectSpread({}, props), props.content);
125
37
  }
126
- var normalizeConfig = function normalizeConfig2(_config) {
127
- if (_config.isNotice) {
128
- var icon = _config.icon;
38
+ var normalizeConfig = function normalizeConfig2(config) {
39
+ if (config.isNotice) {
40
+ var icon = config.icon;
129
41
  if (!icon && icon !== null) {
130
- switch (_config.noticeType) {
42
+ switch (config.noticeType) {
131
43
  case "alert":
132
44
  icon = "";
133
45
  break;
134
46
  }
135
47
  }
136
- _config.noCancelBtn = true;
48
+ config.hideCancelButton = true;
137
49
  }
138
- return _config;
50
+ return config;
139
51
  };
140
- function confirm(config, renderFunc) {
52
+ var confirm = function confirm2(config, renderFunc) {
141
53
  var div = document.createElement("div");
142
54
  document.body.appendChild(div);
143
- function render$1(props, callback) {
55
+ var dialogConfig = _objectSpread(_objectSpread({}, config), {}, {
56
+ visible: false
57
+ });
58
+ var render$1 = function render$12(props, callback) {
144
59
  render(React__default.createElement(ConfirmDialog, _objectSpread(_objectSpread({}, props), {}, {
145
- onCancel
60
+ onCancel: function onCancel2() {
61
+ return _onCancel();
62
+ }
146
63
  })), div);
147
64
  callback && callback();
148
- }
65
+ };
149
66
  var renderFunction = renderFunc || render$1;
150
- var dialogConfig = _objectSpread(_objectSpread({}, config), {}, {
151
- visible: false
152
- });
153
- var onOk = function onOk2() {
154
- var ret;
155
- var _onOk = config.onOk || config.onConfirm;
156
- if (_onOk) {
157
- ret = _onOk();
158
- }
67
+ var onConfirm = function onConfirm2() {
68
+ var _onConfirm = config.onConfirm || config.onConfirm;
69
+ var ret = _onConfirm === null || _onConfirm === void 0 ? void 0 : _onConfirm();
159
70
  if (ret && ret.then) {
160
71
  renderFunction(dialogConfig);
161
72
  ret.then(function() {
162
- onCancel(true);
73
+ _onCancel(true);
163
74
  }, function(e) {
164
75
  console.error(e);
165
76
  renderFunction(dialogConfig);
166
77
  });
167
78
  }
168
79
  if (!ret) {
169
- onCancel(true);
80
+ _onCancel(true);
170
81
  }
171
82
  };
172
- dialogConfig.onOk = onOk;
83
+ dialogConfig.onConfirm = onConfirm;
173
84
  dialogConfig = normalizeConfig(dialogConfig);
174
85
  dialogConfig.visible = true;
175
86
  renderFunction(dialogConfig);
176
- function destroy() {
87
+ var destroy = function destroy2() {
177
88
  unmount(div);
178
89
  if (div !== null && div !== void 0 && div.parentNode) {
179
90
  div.parentNode.removeChild(div);
180
91
  }
181
- }
182
- function onCancel(isOnOk) {
183
- !isOnOk && config.onCancel && config.onCancel();
92
+ };
93
+ var _onCancel = function _onCancel2(confirm22) {
94
+ !confirm22 && config.onCancel && config.onCancel();
184
95
  dialogConfig.visible = false;
185
- dialogConfig.onClosed = function() {
186
- config.onClosed && config.onClosed();
96
+ dialogConfig.onClose = function() {
97
+ config.onClose && config.onClose();
187
98
  };
188
99
  renderFunction(dialogConfig, function() {
189
100
  destroy();
190
101
  });
191
- }
192
- function update(newConfig) {
102
+ };
103
+ var update = function update2(newConfig) {
193
104
  dialogConfig = _objectSpread(_objectSpread({}, dialogConfig), {}, {
194
105
  title: config.title
195
106
  }, newConfig);
196
107
  dialogConfig = normalizeConfig(dialogConfig);
197
108
  renderFunction(dialogConfig);
198
- }
199
- function close() {
109
+ };
110
+ var close = function close2() {
200
111
  dialogConfig.visible = false;
201
- dialogConfig.onClosed = function() {
202
- config.onClosed && config.onClosed();
112
+ dialogConfig.onClose = function() {
113
+ config.onClose && config.onClose();
203
114
  destroy();
204
115
  };
205
116
  renderFunction(dialogConfig);
206
- }
117
+ };
207
118
  return {
208
119
  close,
209
120
  update
210
121
  };
211
- }
122
+ };
123
+ var confirm$1 = confirm;
124
+ var Content = function Content2(props) {
125
+ var visible = props.visible, title = props.title, footer = props.footer, footerDirection = props.footerDirection, onClick = props.onClick, children = props.children;
126
+ var classPrefix = "nut-dialog";
127
+ var renderHeader = function renderHeader2() {
128
+ return title ? React__default.createElement("div", {
129
+ className: "".concat(classPrefix, "__header")
130
+ }, title) : null;
131
+ };
132
+ var renderFooter = function renderFooter2() {
133
+ return footer ? React__default.createElement("div", {
134
+ className: classNames("".concat(classPrefix, "__footer"), _defineProperty({}, footerDirection, footerDirection))
135
+ }, footer) : null;
136
+ };
137
+ var handleClick = function handleClick2(e) {
138
+ onClick && onClick(e);
139
+ };
140
+ return React__default.createElement("div", {
141
+ className: "".concat(classPrefix, "__outer"),
142
+ onClick: function onClick2(e) {
143
+ return handleClick(e);
144
+ }
145
+ }, React__default.createElement("div", {
146
+ className: classPrefix,
147
+ style: {
148
+ display: visible ? "flex" : "none"
149
+ }
150
+ }, renderHeader(), React__default.createElement("div", {
151
+ className: "".concat(classPrefix, "__content")
152
+ }, React__default.createElement(React__default.Fragment, null, children)), renderFooter()));
153
+ };
154
+ Content.displayName = "NutContent";
155
+ var defaultDialogProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
156
+ overlay: true,
157
+ overlayStyle: {},
158
+ overlayClassName: "",
159
+ onCancel: function onCancel() {
160
+ },
161
+ onClose: function onClose() {
162
+ },
163
+ onOverlayClick: function onOverlayClick(e) {
164
+ return true;
165
+ }
166
+ }, defaultOverlayProps);
167
+ var DialogWrap = function DialogWrap2(props) {
168
+ var visible = props.visible, overlay = props.overlay, overlayStyle = props.overlayStyle, overlayClassName = props.overlayClassName, closeOnOverlayClick = props.closeOnOverlayClick, lockScroll = props.lockScroll, onClose2 = props.onClose, onCancel2 = props.onCancel, onOverlayClick2 = props.onOverlayClick;
169
+ var onHandleClickOverlay = function onHandleClickOverlay2(e) {
170
+ if (closeOnOverlayClick && visible && e.target === e.currentTarget) {
171
+ var closed = onOverlayClick2 && onOverlayClick2(e);
172
+ closed && (onClose2 === null || onClose2 === void 0 ? void 0 : onClose2());
173
+ closed && (onCancel2 === null || onCancel2 === void 0 ? void 0 : onCancel2());
174
+ }
175
+ };
176
+ return React__default.createElement(React__default.Fragment, null, overlay ? React__default.createElement(Overlay, {
177
+ style: overlayStyle,
178
+ className: overlayClassName,
179
+ visible,
180
+ closeOnOverlayClick,
181
+ lockScroll,
182
+ onClick: onHandleClickOverlay
183
+ }) : null, React__default.createElement(CSSTransition, {
184
+ "in": visible,
185
+ timeout: 300,
186
+ classNames: "fadeDialog",
187
+ unmountOnExit: true,
188
+ appear: true
189
+ }, React__default.createElement(Content, _objectSpread(_objectSpread({}, props), {}, {
190
+ visible
191
+ }))));
192
+ };
193
+ DialogWrap.defaultProps = defaultDialogProps;
194
+ DialogWrap.displayName = "NutDialogWrap";
212
195
  var defaultProps = {
213
- confirmText: "确认",
214
- cancelText: "取消",
215
- mask: true,
216
- closeOnClickOverlay: true,
217
- noFooter: false,
218
- noOkBtn: false,
219
- noCancelBtn: false,
220
- okBtnDisabled: false,
221
- cancelAutoClose: true,
222
- textAlign: "center",
196
+ confirmText: "",
197
+ cancelText: "",
198
+ overlay: true,
199
+ closeOnOverlayClick: true,
200
+ hideConfirmButton: false,
201
+ hideCancelButton: false,
202
+ disableConfirmButton: false,
223
203
  footerDirection: "horizontal",
224
- lockScroll: false
204
+ lockScroll: true,
205
+ beforeCancel: function beforeCancel() {
206
+ return true;
207
+ },
208
+ beforeClose: function beforeClose() {
209
+ return true;
210
+ }
225
211
  };
226
212
  var BaseDialog = function BaseDialog2(props, ref) {
227
- var visible = props.visible, footer = props.footer, noFooter = props.noFooter, noOkBtn = props.noOkBtn, noCancelBtn = props.noCancelBtn, lockScroll = props.lockScroll, okBtnDisabled = props.okBtnDisabled, cancelAutoClose = props.cancelAutoClose, confirmText = props.confirmText, cancelText = props.cancelText, onClosed = props.onClosed, onCancel = props.onCancel, onOk = props.onOk, restProps = _objectWithoutProperties(props, _excluded);
213
+ var _useConfig = useConfig(), locale = _useConfig.locale;
214
+ var visible = props.visible, footer = props.footer, hideConfirmButton = props.hideConfirmButton, hideCancelButton = props.hideCancelButton, lockScroll = props.lockScroll, disableConfirmButton = props.disableConfirmButton, closeOnOverlayClick = props.closeOnOverlayClick, confirmText = props.confirmText, cancelText = props.cancelText, onClose2 = props.onClose, onCancel2 = props.onCancel, onConfirm = props.onConfirm, beforeCancel2 = props.beforeCancel, beforeClose2 = props.beforeClose, restProps = _objectWithoutProperties(props, _excluded);
215
+ var classPrefix = "nut-dialog";
228
216
  var renderFooter = function renderFooter2() {
229
- if (footer === null || noFooter)
217
+ if (footer === null)
230
218
  return "";
231
219
  var handleCancel = function handleCancel2(e) {
232
220
  e.stopPropagation();
233
- if (!cancelAutoClose)
221
+ if (!(beforeCancel2 !== null && beforeCancel2 !== void 0 && beforeCancel2()))
234
222
  return;
235
- onClosed === null || onClosed === void 0 ? void 0 : onClosed();
236
- onCancel === null || onCancel === void 0 ? void 0 : onCancel();
237
- if (lockScroll && visible) {
238
- document.body.classList.remove("nut-overflow-hidden");
239
- }
223
+ if (!(beforeClose2 !== null && beforeClose2 !== void 0 && beforeClose2()))
224
+ return;
225
+ onClose2 === null || onClose2 === void 0 ? void 0 : onClose2();
226
+ onCancel2 === null || onCancel2 === void 0 ? void 0 : onCancel2();
240
227
  };
241
228
  var handleOk = function handleOk2(e) {
242
229
  e.stopPropagation();
243
- onClosed === null || onClosed === void 0 ? void 0 : onClosed();
244
- onOk === null || onOk === void 0 ? void 0 : onOk(e);
245
- if (lockScroll && visible) {
246
- document.body.classList.remove("nut-overflow-hidden");
247
- }
230
+ onClose2 === null || onClose2 === void 0 ? void 0 : onClose2();
231
+ onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(e);
248
232
  };
249
- var footerContent = footer || React__default.createElement(React__default.Fragment, null, !noCancelBtn && React__default.createElement(Button, {
233
+ return footer || React__default.createElement(React__default.Fragment, null, !hideCancelButton && React__default.createElement(Button, {
250
234
  size: "small",
251
235
  fill: "outline",
252
236
  type: "primary",
253
- className: "nut-dialog__footer-cancel",
254
- onClick: handleCancel
255
- }, cancelText), !noOkBtn && React__default.createElement(Button, {
237
+ className: "".concat(classPrefix, "__footer-cancel"),
238
+ onClick: function onClick(e) {
239
+ return handleCancel(e);
240
+ }
241
+ }, cancelText || locale.cancel), !hideConfirmButton && React__default.createElement(Button, {
256
242
  size: "small",
257
243
  type: "primary",
258
- className: classNames("nut-dialog__footer-ok", {
259
- disabled: okBtnDisabled
244
+ className: classNames("".concat(classPrefix, "__footer-ok"), {
245
+ disabled: disableConfirmButton
260
246
  }),
261
- disabled: okBtnDisabled,
262
- onClick: handleOk
263
- }, confirmText));
264
- return footerContent;
247
+ disabled: disableConfirmButton,
248
+ onClick: function onClick(e) {
249
+ return handleOk(e);
250
+ }
251
+ }, confirmText || locale.confirm));
265
252
  };
266
- return React__default.createElement(DialogWrapper, _objectSpread(_objectSpread({}, restProps), {}, {
253
+ return React__default.createElement("div", {
254
+ style: {
255
+ display: visible ? "block" : "none"
256
+ }
257
+ }, React__default.createElement(DialogWrap, _objectSpread(_objectSpread({}, props), {}, {
267
258
  visible,
268
259
  lockScroll,
269
260
  footer: renderFooter(),
270
- onClosed,
271
- onCancel
272
- }));
261
+ onClose: onClose2,
262
+ onCancel: onCancel2
263
+ })));
273
264
  };
274
265
  var Dialog = forwardRef(BaseDialog);
275
266
  Dialog.confirm = function(props) {
276
- return confirm(props);
267
+ return confirm$1(props);
277
268
  };
278
269
  ["alert"].forEach(function(type) {
279
270
  Dialog[type] = function(props) {
280
- return confirm(_objectSpread(_objectSpread({}, props), {}, {
271
+ return confirm$1(_objectSpread(_objectSpread({}, props), {}, {
281
272
  isNotice: false,
282
273
  noticeType: type
283
274
  }));
package/dist/esm/Popup.js CHANGED
@@ -45,8 +45,6 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
45
45
  },
46
46
  onClose: function onClose() {
47
47
  },
48
- onClick: function onClick(e) {
49
- },
50
48
  onClickOverlay: function onClickOverlay(e) {
51
49
  return true;
52
50
  },
@@ -57,7 +55,7 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
57
55
  var _zIndex = 1e3;
58
56
  var Popup = function Popup2(props) {
59
57
  var _classNames, _classNames2;
60
- var children = props.children, visible = props.visible, overlay = props.overlay, closeOnOverlayClick = props.closeOnOverlayClick, overlayStyle = props.overlayStyle, overlayClassName = props.overlayClassName, zIndex = props.zIndex, lockScroll = props.lockScroll, duration = props.duration, closeable = props.closeable, closeIconPosition = props.closeIconPosition, closeIcon = props.closeIcon, style = props.style, transition = props.transition, round = props.round, position = props.position, className = props.className, destroyOnClose = props.destroyOnClose, portal = props.portal, onOpen2 = props.onOpen, onClose2 = props.onClose, onClickOverlay2 = props.onClickOverlay, onClickCloseIcon2 = props.onClickCloseIcon, afterShow = props.afterShow, afterClose = props.afterClose, onClick2 = props.onClick;
58
+ var children = props.children, visible = props.visible, overlay = props.overlay, closeOnOverlayClick = props.closeOnOverlayClick, overlayStyle = props.overlayStyle, overlayClassName = props.overlayClassName, zIndex = props.zIndex, lockScroll = props.lockScroll, duration = props.duration, closeable = props.closeable, closeIconPosition = props.closeIconPosition, closeIcon = props.closeIcon, style = props.style, transition = props.transition, round = props.round, position = props.position, className = props.className, destroyOnClose = props.destroyOnClose, portal = props.portal, onOpen2 = props.onOpen, onClose2 = props.onClose, onClickOverlay2 = props.onClickOverlay, onClickCloseIcon2 = props.onClickCloseIcon, afterShow = props.afterShow, afterClose = props.afterClose, onClick = props.onClick;
61
59
  var _useState = useState(zIndex || _zIndex), _useState2 = _slicedToArray(_useState, 2), index = _useState2[0], setIndex = _useState2[1];
62
60
  var _useState3 = useState(visible), _useState4 = _slicedToArray(_useState3, 2), innerVisible = _useState4[0], setInnerVisible = _useState4[1];
63
61
  var _useState5 = useState(true), _useState6 = _slicedToArray(_useState5, 2), showChildren = _useState6[0], setShowChildren = _useState6[1];
@@ -101,7 +99,7 @@ var Popup = function Popup2(props) {
101
99
  }
102
100
  };
103
101
  var onHandleClick = function onHandleClick2(e) {
104
- onClick2 && onClick2(e);
102
+ onClick && onClick(e);
105
103
  };
106
104
  var onHandleClickCloseIcon = function onHandleClickCloseIcon2(e) {
107
105
  var closed = onClickCloseIcon2 && onClickCloseIcon2(e);
@@ -21,58 +21,44 @@ function _objectSpread(target) {
21
21
  }
22
22
  return target;
23
23
  }
24
- import React__default, { useState, useEffect } from "react";
25
- import { c as cn } from "./bem.js";
24
+ import React__default from "react";
26
25
  import { C as ComponentDefaults } from "./typings.js";
27
- import "@bem-react/classname";
26
+ import { u as usePropsValue } from "./use-props-value.js";
28
27
  var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
29
- isAsync: false,
30
- checked: false,
31
- disable: false,
32
- activeColor: "",
33
- inactiveColor: "",
28
+ disabled: false,
34
29
  activeText: "",
35
- inactiveText: "",
36
- className: ""
30
+ inactiveText: ""
37
31
  });
38
32
  var Switch = function Switch2(props) {
39
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), isAsync = _defaultProps$props.isAsync, checked = _defaultProps$props.checked, disable = _defaultProps$props.disable, activeColor = _defaultProps$props.activeColor, inactiveColor = _defaultProps$props.inactiveColor, activeText = _defaultProps$props.activeText, inactiveText = _defaultProps$props.inactiveText, onChange = _defaultProps$props.onChange, className = _defaultProps$props.className, style = _defaultProps$props.style;
40
- var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue = _useState2[1];
41
- var b = cn("switch");
42
- useEffect(function() {
43
- setValue(checked);
44
- }, [checked]);
33
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), checked = _defaultProps$props.checked, defaultChecked = _defaultProps$props.defaultChecked, disabled = _defaultProps$props.disabled, activeText = _defaultProps$props.activeText, inactiveText = _defaultProps$props.inactiveText, className = _defaultProps$props.className, style = _defaultProps$props.style, onChange = _defaultProps$props.onChange;
34
+ var classPrefix = "nut-switch";
35
+ var _usePropsValue = usePropsValue({
36
+ value: checked,
37
+ defaultValue: defaultChecked
38
+ }), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), value = _usePropsValue2[0], setValue = _usePropsValue2[1];
45
39
  var classes = function classes2() {
46
- return "".concat(b(), " ").concat(value ? "switch-open" : "switch-close", " ").concat(disable ? "".concat(b(), "-disable") : "", " ", "".concat(b(), "-base"), " ").concat(className);
47
- };
48
- var styles = function styles2() {
49
- var myStyle = _objectSpread({
50
- backgroundColor: value ? activeColor : inactiveColor
51
- }, style || {});
52
- return myStyle;
40
+ return "".concat(classPrefix, " ").concat(value ? "switch-open" : "switch-close", " ").concat(disabled ? "".concat(classPrefix, "-disabled") : "", " ", "".concat(classPrefix, "-base"), " ").concat(className);
53
41
  };
54
42
  var _onClick = function onClick(event) {
55
- if (disable)
43
+ if (disabled)
56
44
  return;
57
- if (!isAsync) {
58
- setValue(!value);
59
- }
60
45
  onChange && onChange(!value, event);
46
+ setValue(!value);
61
47
  };
62
48
  return React__default.createElement("div", {
63
49
  className: classes(),
64
50
  onClick: function onClick(e) {
65
51
  return _onClick(e);
66
52
  },
67
- style: styles()
53
+ style
68
54
  }, React__default.createElement("div", {
69
55
  className: "switch-button"
70
56
  }, !value && React__default.createElement("div", {
71
57
  className: "close-line"
72
58
  }), activeText && React__default.createElement(React__default.Fragment, null, value ? React__default.createElement("div", {
73
- className: "".concat(b("label"), " open")
59
+ className: "".concat(classPrefix, "__label open")
74
60
  }, activeText) : React__default.createElement("div", {
75
- className: "".concat(b("label"), " close")
61
+ className: "".concat(classPrefix, "__label close")
76
62
  }, inactiveText))));
77
63
  };
78
64
  Switch.defaultProps = defaultProps;
@@ -1,8 +1,6 @@
1
1
  import { T as TabPane } from "./tabpane2.js";
2
2
  import "react";
3
3
  import "classnames";
4
- import "./bem.js";
5
- import "@bem-react/classname";
6
4
  export {
7
5
  TabPane as default
8
6
  };
package/dist/esm/Tabs.js CHANGED
@@ -2,10 +2,10 @@ import { T as Tabs } from "./tabs2.js";
2
2
  import "react";
3
3
  import "classnames";
4
4
  import "@nutui/icons-react";
5
- import "./bem.js";
6
- import "@bem-react/classname";
7
5
  import "./typings.js";
8
6
  import "./TabPane.js";
7
+ import "./raf.js";
8
+ import "./use-props-value.js";
9
9
  export {
10
10
  Tabs as default
11
11
  };