@pisell/materials 6.3.17 → 6.3.18
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +5 -5
- package/build/lowcode/preview.js +144 -144
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +23 -23
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +23 -23
- package/es/components/TimeResourceSelector/index.d.ts +21 -0
- package/es/components/auto-resize-text/auto-text-size-standalone.d.ts +20 -0
- package/es/components/auto-resize-text/auto-text-size-standalone.js +258 -0
- package/es/components/auto-resize-text/index.d.ts +6 -0
- package/es/components/auto-resize-text/index.js +40 -0
- package/es/components/cardPro/index.js +10 -3
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/index.d.ts +16 -16
- package/es/components/iconfont/index.js +1 -1
- package/es/components/keyboard/index.d.ts +22 -0
- package/es/components/keyboard/index.js +159 -0
- package/es/components/keyboard/index.less +44 -0
- package/es/components/page/index.js +5 -2
- package/es/components/pisell-config-provider/context.d.ts +2 -0
- package/es/components/pisell-config-provider/index.d.ts +1 -0
- package/es/components/pisellAdjustPrice/index.js +5 -1
- package/es/components/pisellAdjustPrice/type.d.ts +2 -0
- package/es/components/pisellCardList/index.d.ts +32 -2
- package/es/components/pisellCardList/index.js +39 -2
- package/es/components/pisellCardList/index.less +9 -1
- package/es/components/pisellCheckboxGroup/index.d.ts +3 -0
- package/es/components/pisellCheckboxGroup/index.js +9 -4
- package/es/components/pisellCheckboxGroup/index.less +28 -1
- package/es/components/pisellCustomCheckboxGroup/index.d.ts +16 -0
- package/es/components/pisellGoodPassCard/index.d.ts +1 -0
- package/es/components/pisellGoodPassCard/index.js +17 -5
- package/es/components/pisellText/components/Amount/index.js +2 -1
- package/es/components/pisellToast/index.d.ts +1 -0
- package/es/components/pisellToast/index.js +4 -0
- package/es/components/pisellToast/squareToast/index.d.ts +15 -0
- package/es/components/pisellToast/squareToast/index.js +28 -0
- package/es/components/pisellToast/squareToast/index.less +60 -0
- package/es/components/pisellToast/squareToast/methods.d.ts +13 -0
- package/es/components/pisellToast/squareToast/methods.js +136 -0
- package/es/components/pisellToast/squareToast/renderImperatively.d.ts +28 -0
- package/es/components/pisellToast/squareToast/renderImperatively.js +190 -0
- package/es/components/pisellToast/squareToast/toast.d.ts +25 -0
- package/es/components/pisellToast/squareToast/toast.js +60 -0
- package/es/components/pisellWalletPassCard/index.d.ts +53 -1
- package/es/components/pisellWalletPassCard/index.js +333 -73
- package/es/components/pisellWalletPassCard/index.less +47 -9
- package/es/components/productCard/cartSkuCard/components/AmountFooter/index.d.ts +3 -0
- package/es/components/productCard/cartSkuCard/components/AmountFooter/index.js +80 -0
- package/es/components/productCard/cartSkuCard/components/AmountFooter/index.less +75 -0
- package/es/components/productCard/cartSkuCard/components/MultiDay/index.d.ts +3 -0
- package/es/components/productCard/cartSkuCard/components/MultiDay/index.js +82 -0
- package/es/components/productCard/cartSkuCard/components/MultiDay/index.less +31 -0
- package/es/components/productCard/cartSkuCard/components/MultiDay/utils.d.ts +14 -0
- package/es/components/productCard/cartSkuCard/components/MultiDay/utils.js +56 -0
- package/es/components/productCard/cartSkuCard/components/Note/index.d.ts +3 -0
- package/es/components/productCard/cartSkuCard/components/Note/index.js +29 -0
- package/es/components/productCard/cartSkuCard/components/Note/index.less +27 -0
- package/es/components/productCard/cartSkuCard/components/basicInfo/index.d.ts +28 -0
- package/es/components/productCard/cartSkuCard/components/basicInfo/index.js +94 -0
- package/es/components/productCard/cartSkuCard/components/basicInfo/index.less +117 -0
- package/es/components/productCard/cartSkuCard/components/discountReason/index.d.ts +2 -0
- package/es/components/productCard/cartSkuCard/components/discountReason/index.js +51 -0
- package/es/components/productCard/cartSkuCard/components/holders/index.d.ts +3 -0
- package/es/components/productCard/cartSkuCard/components/holders/index.js +49 -0
- package/es/components/productCard/cartSkuCard/components/holders/index.less +47 -0
- package/es/components/productCard/cartSkuCard/components/packages/index.d.ts +10 -0
- package/es/components/productCard/cartSkuCard/components/packages/index.js +52 -0
- package/es/components/productCard/cartSkuCard/components/packages/index.less +22 -0
- package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +20 -0
- package/es/components/productCard/cartSkuCard/components/packages/utils.js +40 -0
- package/es/components/productCard/cartSkuCard/components/resources/index.d.ts +3 -0
- package/es/components/productCard/cartSkuCard/components/resources/index.js +39 -0
- package/es/components/productCard/cartSkuCard/components/resources/index.less +19 -0
- package/es/components/productCard/cartSkuCard/components/sales/index.d.ts +12 -0
- package/es/components/productCard/cartSkuCard/components/sales/index.js +57 -0
- package/es/components/productCard/cartSkuCard/components/sales/index.less +22 -0
- package/es/components/productCard/cartSkuCard/components/specs/index.d.ts +3 -0
- package/es/components/productCard/cartSkuCard/components/specs/index.js +44 -0
- package/es/components/productCard/cartSkuCard/components/specs/index.less +34 -0
- package/es/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +46 -0
- package/es/components/productCard/cartSkuCard/components/swipeAction/index.js +360 -0
- package/es/components/productCard/cartSkuCard/components/swipeAction/index.less +74 -0
- package/es/components/productCard/cartSkuCard/components/timeRange/index.d.ts +6 -0
- package/es/components/productCard/cartSkuCard/components/timeRange/index.js +54 -0
- package/es/components/productCard/cartSkuCard/components/timeRange/index.less +38 -0
- package/es/components/productCard/cartSkuCard/index.d.ts +10 -0
- package/es/components/productCard/cartSkuCard/index.js +194 -0
- package/es/components/productCard/cartSkuCard/index.less +33 -0
- package/es/components/productCard/cartSkuCard/locales.d.ts +99 -0
- package/es/components/productCard/cartSkuCard/locales.js +33 -0
- package/es/components/productCard/components/Action/index.js +14 -1
- package/es/components/productCard/components/Action/index.less +3 -0
- package/es/components/productCard/components/Header/index.js +23 -8
- package/es/components/productCard/components/Header/index.less +16 -1
- package/es/components/productCard/components/Sales/index.js +2 -2
- package/es/components/productCard/components/Time/components/SelectHolderModal/index.js +3 -1
- package/es/components/productCard/components/Time/components/SelectHolderModal/index.less +3 -0
- package/es/components/productCard/index.d.ts +3 -1
- package/es/components/productCard/index.js +7 -2
- package/es/components/productCard/index.less +6 -0
- package/es/components/productCard/locales.js +3 -0
- package/es/components/productCard/status.js +1 -0
- package/es/components/productCard/types.d.ts +1 -0
- package/es/components/productCard/utils.js +8 -1
- package/es/components/select-time/index.d.ts +14 -0
- package/es/components/table/Table/AddFieldModal/index.d.ts +1 -0
- package/es/components/table/Table/AddFieldModal/index.js +13 -13
- package/es/components/table/Table/AddFieldModal/index.less +11 -11
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +5 -1
- package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +21 -7
- package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +9 -5
- package/es/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +4 -0
- package/es/components/virtual-keyboard/BaseNumberKeyboard/index.js +44 -25
- package/es/components/virtual-keyboard/Number/index.js +4 -1
- package/es/components/virtual-keyboard/Number/types.d.ts +1 -0
- package/es/components/virtual-keyboard/index.d.ts +11 -0
- package/es/components/virtual-keyboard/index.js +88 -3
- package/es/components/virtual-keyboard/index.less +33 -1
- package/es/components/virtualInput/BaseVirtualInput/index.d.ts +40 -0
- package/es/components/virtualInput/BaseVirtualInput/index.js +163 -0
- package/es/components/virtualInput/BaseVirtualInput/index.less +77 -0
- package/es/components/virtualInput/index.d.ts +24 -0
- package/es/components/virtualInput/index.js +60 -0
- package/es/components/virtualInput/index.less +42 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +5 -2
- package/es/locales/en-US.d.ts +19 -2
- package/es/locales/en-US.js +29 -6
- package/es/locales/zh-CN.d.ts +19 -2
- package/es/locales/zh-CN.js +29 -6
- package/es/locales/zh-TW.d.ts +19 -2
- package/es/locales/zh-TW.js +28 -6
- package/lib/components/TimeResourceSelector/index.d.ts +21 -0
- package/lib/components/auto-resize-text/auto-text-size-standalone.d.ts +20 -0
- package/lib/components/auto-resize-text/auto-text-size-standalone.js +273 -0
- package/lib/components/auto-resize-text/index.d.ts +6 -0
- package/lib/components/auto-resize-text/index.js +71 -0
- package/lib/components/cardPro/index.js +3 -2
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/index.d.ts +16 -16
- package/lib/components/iconfont/index.js +1 -1
- package/lib/components/keyboard/index.d.ts +22 -0
- package/lib/components/keyboard/index.js +223 -0
- package/lib/components/keyboard/index.less +44 -0
- package/lib/components/page/index.js +3 -2
- package/lib/components/pisell-config-provider/context.d.ts +2 -0
- package/lib/components/pisell-config-provider/index.d.ts +1 -0
- package/lib/components/pisellAdjustPrice/index.js +4 -0
- package/lib/components/pisellAdjustPrice/type.d.ts +2 -0
- package/lib/components/pisellCardList/index.d.ts +32 -2
- package/lib/components/pisellCardList/index.js +39 -2
- package/lib/components/pisellCardList/index.less +9 -1
- package/lib/components/pisellCheckboxGroup/index.d.ts +3 -0
- package/lib/components/pisellCheckboxGroup/index.js +6 -1
- package/lib/components/pisellCheckboxGroup/index.less +28 -1
- package/lib/components/pisellCustomCheckboxGroup/index.d.ts +16 -0
- package/lib/components/pisellGoodPassCard/index.d.ts +1 -0
- package/lib/components/pisellGoodPassCard/index.js +31 -4
- package/lib/components/pisellText/components/Amount/index.js +2 -1
- package/lib/components/pisellToast/index.d.ts +1 -0
- package/lib/components/pisellToast/index.js +10 -1
- package/lib/components/pisellToast/squareToast/index.d.ts +15 -0
- package/lib/components/pisellToast/squareToast/index.js +58 -0
- package/lib/components/pisellToast/squareToast/index.less +60 -0
- package/lib/components/pisellToast/squareToast/methods.d.ts +13 -0
- package/lib/components/pisellToast/squareToast/methods.js +150 -0
- package/lib/components/pisellToast/squareToast/renderImperatively.d.ts +28 -0
- package/lib/components/pisellToast/squareToast/renderImperatively.js +162 -0
- package/lib/components/pisellToast/squareToast/toast.d.ts +25 -0
- package/lib/components/pisellToast/squareToast/toast.js +88 -0
- package/lib/components/pisellWalletPassCard/index.d.ts +53 -1
- package/lib/components/pisellWalletPassCard/index.js +257 -59
- package/lib/components/pisellWalletPassCard/index.less +47 -9
- package/lib/components/productCard/cartSkuCard/components/AmountFooter/index.d.ts +3 -0
- package/lib/components/productCard/cartSkuCard/components/AmountFooter/index.js +80 -0
- package/lib/components/productCard/cartSkuCard/components/AmountFooter/index.less +75 -0
- package/lib/components/productCard/cartSkuCard/components/MultiDay/index.d.ts +3 -0
- package/lib/components/productCard/cartSkuCard/components/MultiDay/index.js +71 -0
- package/lib/components/productCard/cartSkuCard/components/MultiDay/index.less +31 -0
- package/lib/components/productCard/cartSkuCard/components/MultiDay/utils.d.ts +14 -0
- package/lib/components/productCard/cartSkuCard/components/MultiDay/utils.js +77 -0
- package/lib/components/productCard/cartSkuCard/components/Note/index.d.ts +3 -0
- package/lib/components/productCard/cartSkuCard/components/Note/index.js +56 -0
- package/lib/components/productCard/cartSkuCard/components/Note/index.less +27 -0
- package/lib/components/productCard/cartSkuCard/components/basicInfo/index.d.ts +28 -0
- package/lib/components/productCard/cartSkuCard/components/basicInfo/index.js +83 -0
- package/lib/components/productCard/cartSkuCard/components/basicInfo/index.less +117 -0
- package/lib/components/productCard/cartSkuCard/components/discountReason/index.d.ts +2 -0
- package/lib/components/productCard/cartSkuCard/components/discountReason/index.js +70 -0
- package/lib/components/productCard/cartSkuCard/components/holders/index.d.ts +3 -0
- package/lib/components/productCard/cartSkuCard/components/holders/index.js +64 -0
- package/lib/components/productCard/cartSkuCard/components/holders/index.less +47 -0
- package/lib/components/productCard/cartSkuCard/components/packages/index.d.ts +10 -0
- package/lib/components/productCard/cartSkuCard/components/packages/index.js +73 -0
- package/lib/components/productCard/cartSkuCard/components/packages/index.less +22 -0
- package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +20 -0
- package/lib/components/productCard/cartSkuCard/components/packages/utils.js +44 -0
- package/lib/components/productCard/cartSkuCard/components/resources/index.d.ts +3 -0
- package/lib/components/productCard/cartSkuCard/components/resources/index.js +71 -0
- package/lib/components/productCard/cartSkuCard/components/resources/index.less +19 -0
- package/lib/components/productCard/cartSkuCard/components/sales/index.d.ts +12 -0
- package/lib/components/productCard/cartSkuCard/components/sales/index.js +77 -0
- package/lib/components/productCard/cartSkuCard/components/sales/index.less +22 -0
- package/lib/components/productCard/cartSkuCard/components/specs/index.d.ts +3 -0
- package/lib/components/productCard/cartSkuCard/components/specs/index.js +66 -0
- package/lib/components/productCard/cartSkuCard/components/specs/index.less +34 -0
- package/lib/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +46 -0
- package/lib/components/productCard/cartSkuCard/components/swipeAction/index.js +373 -0
- package/lib/components/productCard/cartSkuCard/components/swipeAction/index.less +74 -0
- package/lib/components/productCard/cartSkuCard/components/timeRange/index.d.ts +6 -0
- package/lib/components/productCard/cartSkuCard/components/timeRange/index.js +68 -0
- package/lib/components/productCard/cartSkuCard/components/timeRange/index.less +38 -0
- package/lib/components/productCard/cartSkuCard/index.d.ts +10 -0
- package/lib/components/productCard/cartSkuCard/index.js +229 -0
- package/lib/components/productCard/cartSkuCard/index.less +33 -0
- package/lib/components/productCard/cartSkuCard/locales.d.ts +99 -0
- package/lib/components/productCard/cartSkuCard/locales.js +64 -0
- package/lib/components/productCard/components/Action/index.js +9 -0
- package/lib/components/productCard/components/Action/index.less +3 -0
- package/lib/components/productCard/components/Header/index.js +21 -11
- package/lib/components/productCard/components/Header/index.less +16 -1
- package/lib/components/productCard/components/Sales/index.js +2 -2
- package/lib/components/productCard/components/Time/components/SelectHolderModal/index.js +1 -1
- package/lib/components/productCard/components/Time/components/SelectHolderModal/index.less +3 -0
- package/lib/components/productCard/index.d.ts +3 -1
- package/lib/components/productCard/index.js +7 -2
- package/lib/components/productCard/index.less +6 -0
- package/lib/components/productCard/locales.js +12 -3
- package/lib/components/productCard/status.js +1 -0
- package/lib/components/productCard/types.d.ts +1 -0
- package/lib/components/productCard/utils.js +8 -1
- package/lib/components/select-time/index.d.ts +14 -0
- package/lib/components/table/Table/AddFieldModal/index.d.ts +1 -0
- package/lib/components/table/Table/AddFieldModal/index.js +9 -9
- package/lib/components/table/Table/AddFieldModal/index.less +11 -11
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +5 -1
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +19 -2
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +9 -5
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +4 -0
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.js +45 -27
- package/lib/components/virtual-keyboard/Number/index.js +3 -0
- package/lib/components/virtual-keyboard/Number/types.d.ts +1 -0
- package/lib/components/virtual-keyboard/index.d.ts +11 -0
- package/lib/components/virtual-keyboard/index.js +60 -2
- package/lib/components/virtual-keyboard/index.less +33 -1
- package/lib/components/virtualInput/BaseVirtualInput/index.d.ts +40 -0
- package/lib/components/virtualInput/BaseVirtualInput/index.js +179 -0
- package/lib/components/virtualInput/BaseVirtualInput/index.less +77 -0
- package/lib/components/virtualInput/index.d.ts +24 -0
- package/lib/components/virtualInput/index.js +102 -0
- package/lib/components/virtualInput/index.less +42 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +11 -0
- package/lib/locales/en-US.d.ts +19 -2
- package/lib/locales/en-US.js +24 -5
- package/lib/locales/zh-CN.d.ts +19 -2
- package/lib/locales/zh-CN.js +24 -5
- package/lib/locales/zh-TW.d.ts +19 -2
- package/lib/locales/zh-TW.js +23 -5
- package/package.json +4 -4
- package/es/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +0 -12
- package/lib/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +0 -12
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import Toast from "./toast";
|
|
10
|
+
import { renderImperatively } from "./renderImperatively";
|
|
11
|
+
var currentHandler = null;
|
|
12
|
+
var currentTimeout = null;
|
|
13
|
+
var defaultProps = {
|
|
14
|
+
duration: 2000,
|
|
15
|
+
mask: false,
|
|
16
|
+
icon: 'info'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// mergeProps 工具函数
|
|
20
|
+
function mergeProps(a, b) {
|
|
21
|
+
// 过滤掉 b 中值为 undefined 的字段
|
|
22
|
+
var filteredB = Object.keys(b).reduce(function (acc, key) {
|
|
23
|
+
if (b[key] !== undefined) {
|
|
24
|
+
acc[key] = b[key];
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
return _objectSpread(_objectSpread({}, a), filteredB);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 基于 renderImperatively 的新 show 实现
|
|
32
|
+
var show = function show(configOrContent, duration, afterClose) {
|
|
33
|
+
var props;
|
|
34
|
+
|
|
35
|
+
// 判断是否为 string 或 ReactNode,如果不是则认为是 config 对象
|
|
36
|
+
if (typeof configOrContent === 'string' || /*#__PURE__*/React.isValidElement(configOrContent)) {
|
|
37
|
+
// 如果是 string 或 ReactNode,视为 content
|
|
38
|
+
props = mergeProps(defaultProps, _objectSpread(_objectSpread({
|
|
39
|
+
content: configOrContent
|
|
40
|
+
}, duration !== undefined && {
|
|
41
|
+
duration: duration
|
|
42
|
+
}), afterClose !== undefined && {
|
|
43
|
+
afterClose: afterClose
|
|
44
|
+
}));
|
|
45
|
+
} else {
|
|
46
|
+
// 如果不是 string 或 ReactNode,则认为是 config 对象
|
|
47
|
+
props = mergeProps(defaultProps, configOrContent || {});
|
|
48
|
+
}
|
|
49
|
+
var element = /*#__PURE__*/React.createElement(Toast, _extends({}, props, {
|
|
50
|
+
onCancel: function onCancel() {
|
|
51
|
+
currentHandler = null;
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
if (currentHandler) {
|
|
55
|
+
var _currentHandler$isRen, _currentHandler;
|
|
56
|
+
if ((_currentHandler$isRen = (_currentHandler = currentHandler).isRendered) !== null && _currentHandler$isRen !== void 0 && _currentHandler$isRen.call(_currentHandler)) {
|
|
57
|
+
currentHandler.replace(element);
|
|
58
|
+
} else {
|
|
59
|
+
currentHandler.close();
|
|
60
|
+
currentHandler = renderImperatively(element);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
currentHandler = renderImperatively(element);
|
|
64
|
+
}
|
|
65
|
+
if (currentTimeout) {
|
|
66
|
+
window.clearTimeout(currentTimeout);
|
|
67
|
+
}
|
|
68
|
+
if (props.duration !== 0) {
|
|
69
|
+
currentTimeout = window.setTimeout(function () {
|
|
70
|
+
clear();
|
|
71
|
+
}, props.duration);
|
|
72
|
+
}
|
|
73
|
+
var instance = {
|
|
74
|
+
close: function close() {
|
|
75
|
+
if (currentHandler) {
|
|
76
|
+
currentHandler.close();
|
|
77
|
+
currentHandler = null;
|
|
78
|
+
}
|
|
79
|
+
if (currentTimeout) {
|
|
80
|
+
window.clearTimeout(currentTimeout);
|
|
81
|
+
currentTimeout = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return instance;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// 清理函数
|
|
89
|
+
var clear = function clear() {
|
|
90
|
+
if (currentHandler) {
|
|
91
|
+
currentHandler.close();
|
|
92
|
+
currentHandler = null;
|
|
93
|
+
}
|
|
94
|
+
if (currentTimeout) {
|
|
95
|
+
window.clearTimeout(currentTimeout);
|
|
96
|
+
currentTimeout = null;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 便捷方法
|
|
101
|
+
var success = function success(content, duration, afterClose) {
|
|
102
|
+
return show({
|
|
103
|
+
content: content,
|
|
104
|
+
icon: 'success',
|
|
105
|
+
duration: duration,
|
|
106
|
+
afterClose: afterClose
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
var info = function info(content, duration, afterClose) {
|
|
110
|
+
return show({
|
|
111
|
+
content: content,
|
|
112
|
+
icon: 'info',
|
|
113
|
+
duration: duration,
|
|
114
|
+
afterClose: afterClose
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
var loading = function loading(content, duration, afterClose) {
|
|
118
|
+
return show({
|
|
119
|
+
content: content,
|
|
120
|
+
icon: 'loading',
|
|
121
|
+
duration: duration,
|
|
122
|
+
afterClose: afterClose
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
var fail = function fail(content, duration, afterClose) {
|
|
126
|
+
return show({
|
|
127
|
+
content: content,
|
|
128
|
+
icon: 'error',
|
|
129
|
+
duration: duration,
|
|
130
|
+
afterClose: afterClose
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
var hide = function hide() {
|
|
134
|
+
clear();
|
|
135
|
+
};
|
|
136
|
+
export { show, clear, success, info, loading, fail, hide };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Root } from 'react-dom/client';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
declare type ImperativeProps = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
afterClose?: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare type TargetElement = ReactElement<ImperativeProps>;
|
|
10
|
+
export declare type ImperativeHandler = {
|
|
11
|
+
close: () => void;
|
|
12
|
+
replace: (element: TargetElement) => void;
|
|
13
|
+
isRendered?: () => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare type UnmountType = () => Promise<void>;
|
|
16
|
+
export declare type RenderType = (node: React.ReactElement, container: Element | DocumentFragment) => UnmountType;
|
|
17
|
+
declare const MARK = "__pisell_react_root__";
|
|
18
|
+
declare type ContainerType = (Element | DocumentFragment) & {
|
|
19
|
+
[MARK]?: Root;
|
|
20
|
+
};
|
|
21
|
+
export declare function render(node: React.ReactElement, container: ContainerType): void;
|
|
22
|
+
export declare function unmount(container: ContainerType): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated 设置 React 渲染函数以兼容使用。
|
|
25
|
+
*/
|
|
26
|
+
export declare function unstableSetRender(render?: RenderType): RenderType;
|
|
27
|
+
export declare function renderImperatively(element: TargetElement): ImperativeHandler;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
16
|
+
import * as ReactDOM from 'react-dom';
|
|
17
|
+
import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
18
|
+
var MARK = '__pisell_react_root__';
|
|
19
|
+
|
|
20
|
+
// ========================== Render ==========================
|
|
21
|
+
|
|
22
|
+
export function render(node, container) {
|
|
23
|
+
var root = container[MARK];
|
|
24
|
+
if (root) {
|
|
25
|
+
root.render(node);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
var ReactMajorVersion = parseInt(React.version.split('.')[0], 10);
|
|
29
|
+
var isReact18OrNewer = ReactMajorVersion >= 18;
|
|
30
|
+
|
|
31
|
+
// 尝试探测 ReactDOM.createRoot (某些环境或 Polyfill)
|
|
32
|
+
var fallbackCreateRoot = ReactDOM.createRoot;
|
|
33
|
+
if (isReact18OrNewer && fallbackCreateRoot) {
|
|
34
|
+
var _root = fallbackCreateRoot(container);
|
|
35
|
+
_root.render(node);
|
|
36
|
+
container[MARK] = _root;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// React 19 强制检查:如果此时还没找到 createRoot,必须报错
|
|
41
|
+
// 因为 React 19 已移除 ReactDOM.render
|
|
42
|
+
if (ReactMajorVersion >= 19) {
|
|
43
|
+
console.error('[pisellToast] React 19+ requires `createRoot`. Please call `setCreateRoot(createRoot)` at your app entry.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 降级到 Legacy Render (React 16/17 或 React 18 Legacy Mode)
|
|
47
|
+
ReactDOM.render(node, container);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ========================= Unmount ==========================
|
|
51
|
+
export function unmount(_x) {
|
|
52
|
+
return _unmount.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
function _unmount() {
|
|
55
|
+
_unmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(container) {
|
|
56
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
57
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
return _context2.abrupt("return", Promise.resolve().then(function () {
|
|
60
|
+
if (container[MARK]) {
|
|
61
|
+
var _container$MARK;
|
|
62
|
+
// React 18+ with createRoot
|
|
63
|
+
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 || _container$MARK.unmount();
|
|
64
|
+
delete container[MARK];
|
|
65
|
+
} else {
|
|
66
|
+
// Legacy React 16/17
|
|
67
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
case 1:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context2.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee2);
|
|
75
|
+
}));
|
|
76
|
+
return _unmount.apply(this, arguments);
|
|
77
|
+
}
|
|
78
|
+
var defaultReactRender = function defaultReactRender(node, container) {
|
|
79
|
+
render(node, container);
|
|
80
|
+
return function () {
|
|
81
|
+
return unmount(container);
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var unstableRender = defaultReactRender;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated 设置 React 渲染函数以兼容使用。
|
|
88
|
+
*/
|
|
89
|
+
export function unstableSetRender(render) {
|
|
90
|
+
if (render) {
|
|
91
|
+
unstableRender = render;
|
|
92
|
+
}
|
|
93
|
+
return unstableRender;
|
|
94
|
+
}
|
|
95
|
+
var sharedContainer = null;
|
|
96
|
+
function renderToBody(element) {
|
|
97
|
+
if (!sharedContainer) {
|
|
98
|
+
sharedContainer = document.createElement('div');
|
|
99
|
+
document.body.appendChild(sharedContainer);
|
|
100
|
+
}
|
|
101
|
+
var container = sharedContainer;
|
|
102
|
+
return unstableSetRender()(element, container);
|
|
103
|
+
}
|
|
104
|
+
export function renderImperatively(element) {
|
|
105
|
+
var Wrapper = /*#__PURE__*/React.forwardRef(function (_, ref) {
|
|
106
|
+
var _useState = useState(false),
|
|
107
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
108
|
+
open = _useState2[0],
|
|
109
|
+
setOpen = _useState2[1];
|
|
110
|
+
var closedRef = useRef(false);
|
|
111
|
+
var _useState3 = useState(element),
|
|
112
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
113
|
+
elementToRender = _useState4[0],
|
|
114
|
+
setElementToRender = _useState4[1];
|
|
115
|
+
var keyRef = useRef(0);
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
if (!closedRef.current) {
|
|
118
|
+
setOpen(true);
|
|
119
|
+
} else {
|
|
120
|
+
afterClose();
|
|
121
|
+
}
|
|
122
|
+
}, []);
|
|
123
|
+
function onCancel() {
|
|
124
|
+
var _elementToRender$prop, _elementToRender$prop2;
|
|
125
|
+
closedRef.current = true;
|
|
126
|
+
setOpen(false);
|
|
127
|
+
(_elementToRender$prop = (_elementToRender$prop2 = elementToRender.props).onCancel) === null || _elementToRender$prop === void 0 || _elementToRender$prop.call(_elementToRender$prop2);
|
|
128
|
+
}
|
|
129
|
+
function afterClose() {
|
|
130
|
+
var _elementToRender$prop3, _elementToRender$prop4;
|
|
131
|
+
unmount();
|
|
132
|
+
(_elementToRender$prop3 = (_elementToRender$prop4 = elementToRender.props).afterClose) === null || _elementToRender$prop3 === void 0 || _elementToRender$prop3.call(_elementToRender$prop4);
|
|
133
|
+
}
|
|
134
|
+
useImperativeHandle(ref, function () {
|
|
135
|
+
return {
|
|
136
|
+
close: onCancel,
|
|
137
|
+
replace: function replace(element) {
|
|
138
|
+
var _elementToRender$prop5, _elementToRender$prop6;
|
|
139
|
+
keyRef.current++;
|
|
140
|
+
(_elementToRender$prop5 = (_elementToRender$prop6 = elementToRender.props).afterClose) === null || _elementToRender$prop5 === void 0 || _elementToRender$prop5.call(_elementToRender$prop6);
|
|
141
|
+
setElementToRender(element);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
return /*#__PURE__*/React.cloneElement(elementToRender, _objectSpread(_objectSpread({}, elementToRender.props), {}, {
|
|
146
|
+
key: keyRef.current,
|
|
147
|
+
open: open,
|
|
148
|
+
onCancel: onCancel,
|
|
149
|
+
afterClose: afterClose
|
|
150
|
+
}));
|
|
151
|
+
});
|
|
152
|
+
var wrapperRef = /*#__PURE__*/React.createRef();
|
|
153
|
+
var unmount = renderToBody( /*#__PURE__*/React.createElement(Wrapper, {
|
|
154
|
+
ref: wrapperRef
|
|
155
|
+
}));
|
|
156
|
+
return {
|
|
157
|
+
close: function () {
|
|
158
|
+
var _close = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
159
|
+
var _element$props$afterC, _element$props, _wrapperRef$current;
|
|
160
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
161
|
+
while (1) switch (_context.prev = _context.next) {
|
|
162
|
+
case 0:
|
|
163
|
+
if (!wrapperRef.current) {
|
|
164
|
+
// wrapper引用还没被赋值,说明组件还没被挂载 ,直接调用unmount
|
|
165
|
+
unmount();
|
|
166
|
+
// 手动调用,确保afterClose被调用
|
|
167
|
+
(_element$props$afterC = (_element$props = element.props).afterClose) === null || _element$props$afterC === void 0 || _element$props$afterC.call(_element$props);
|
|
168
|
+
} else {
|
|
169
|
+
(_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 || _wrapperRef$current.close();
|
|
170
|
+
}
|
|
171
|
+
case 1:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}, _callee);
|
|
176
|
+
}));
|
|
177
|
+
function close() {
|
|
178
|
+
return _close.apply(this, arguments);
|
|
179
|
+
}
|
|
180
|
+
return close;
|
|
181
|
+
}(),
|
|
182
|
+
replace: function replace(element) {
|
|
183
|
+
var _wrapperRef$current2;
|
|
184
|
+
(_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 || _wrapperRef$current2.replace(element);
|
|
185
|
+
},
|
|
186
|
+
isRendered: function isRendered() {
|
|
187
|
+
return !!wrapperRef.current;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
export declare type ToastType = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
4
|
+
export interface ToastProps {
|
|
5
|
+
/** Toast 类型 */
|
|
6
|
+
icon?: ToastType | React.ReactNode;
|
|
7
|
+
/** 显示的内容,支持文本或 React 节点 */
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
/** 是否显示 */
|
|
10
|
+
open?: boolean;
|
|
11
|
+
/** 自动关闭时间,单位毫秒,0 表示不自动关闭 */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** 关闭 */
|
|
14
|
+
onCancel?: () => void;
|
|
15
|
+
/** 关闭后回调 */
|
|
16
|
+
afterClose?: () => void;
|
|
17
|
+
/** 自定义样式类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 自定义样式 */
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
/** 是否显示遮罩 */
|
|
22
|
+
mask?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const Toast: React.FC<ToastProps>;
|
|
25
|
+
export default Toast;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var _excluded = ["content", "open", "icon", "className"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
import Modal from "../../modal";
|
|
7
|
+
import Icon from "../../icon";
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import "./index.less";
|
|
10
|
+
var icons = {
|
|
11
|
+
info: '',
|
|
12
|
+
success: 'iconchenggong-1-01',
|
|
13
|
+
error: 'icon-warning',
|
|
14
|
+
warning: 'icon-warning',
|
|
15
|
+
loading: 'icon-loading',
|
|
16
|
+
fail: 'icon-warning'
|
|
17
|
+
};
|
|
18
|
+
var Toast = function Toast(_ref) {
|
|
19
|
+
var content = _ref.content,
|
|
20
|
+
open = _ref.open,
|
|
21
|
+
icon = _ref.icon,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
var iconElement = useMemo(function () {
|
|
25
|
+
if (icon === null || icon === undefined) return null;
|
|
26
|
+
if (typeof icon === 'string' && icon in icons) {
|
|
27
|
+
if (!icons[icon]) return null;
|
|
28
|
+
return /*#__PURE__*/React.createElement(Icon, {
|
|
29
|
+
type: icons[icon],
|
|
30
|
+
className: "pisell-square-toast-icon pisell-square-toast-icon-".concat(icon)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return icon;
|
|
34
|
+
}, [icon]);
|
|
35
|
+
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
36
|
+
open: open,
|
|
37
|
+
footer: null,
|
|
38
|
+
closable: false,
|
|
39
|
+
centered: true,
|
|
40
|
+
maskTransitionName: "",
|
|
41
|
+
transitionName: "",
|
|
42
|
+
width: "unset",
|
|
43
|
+
wrapClassName: "pisell-square-toast-wrap",
|
|
44
|
+
className: classNames('pisell-square-toast-modal', className),
|
|
45
|
+
bodyStyle: {
|
|
46
|
+
padding: 0
|
|
47
|
+
},
|
|
48
|
+
destroyOnClose: true,
|
|
49
|
+
modalRender: function modalRender() {
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "pisell-square-toast"
|
|
52
|
+
}, iconElement && /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "pisell-square-toast-icon-wrapper"
|
|
54
|
+
}, iconElement), /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "pisell-square-toast-content"
|
|
56
|
+
}, content));
|
|
57
|
+
}
|
|
58
|
+
}, rest));
|
|
59
|
+
};
|
|
60
|
+
export default Toast;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import './index.less';
|
|
3
|
+
export interface FormatOption {
|
|
4
|
+
/** 原始 DOM 元素 */
|
|
5
|
+
originDom: React.ReactNode;
|
|
6
|
+
/** 是否选中状态 */
|
|
7
|
+
active: boolean;
|
|
8
|
+
/** 完整的组件数据 */
|
|
9
|
+
data: PisellWalletPassCardProps;
|
|
10
|
+
}
|
|
2
11
|
export interface PisellWalletPassCardProps {
|
|
3
12
|
id: number;
|
|
4
13
|
/** 卡片样式 */
|
|
@@ -34,7 +43,7 @@ export interface PisellWalletPassCardProps {
|
|
|
34
43
|
/** 是否展示商品名称 */
|
|
35
44
|
showName?: boolean;
|
|
36
45
|
/** 是否展示共享店铺名称 */
|
|
37
|
-
showStoreName?: boolean;
|
|
46
|
+
showStoreName?: boolean | ((data: any) => boolean);
|
|
38
47
|
/** 是否展示使用金额 */
|
|
39
48
|
showRedeem?: boolean;
|
|
40
49
|
/** 是否展示余额 */
|
|
@@ -82,6 +91,49 @@ export interface PisellWalletPassCardProps {
|
|
|
82
91
|
beforeEdit?: (value: any) => Promise<any> | boolean | void;
|
|
83
92
|
/** 编辑弹窗点击提交 */
|
|
84
93
|
onConfirmEdit?: (value: any) => void;
|
|
94
|
+
/** 编辑金额事件 */
|
|
95
|
+
onConfirmEditAmount?: (value: number) => void;
|
|
96
|
+
/** 详情按钮点击事件 */
|
|
97
|
+
onDetail?: (data: {
|
|
98
|
+
id: number;
|
|
99
|
+
name: string;
|
|
100
|
+
storeName: string;
|
|
101
|
+
balance?: number;
|
|
102
|
+
redeem?: number;
|
|
103
|
+
code: string;
|
|
104
|
+
validDate: string;
|
|
105
|
+
originData?: any;
|
|
106
|
+
}) => void;
|
|
107
|
+
/** 是否使用外部详情处理(当为 true 且提供了 onDetail 时,不显示内部模态框) */
|
|
108
|
+
useExternalDetail?: boolean;
|
|
109
|
+
/** 单选或者多选 */
|
|
110
|
+
mode?: 'multiple' | 'single';
|
|
111
|
+
/** 是否展示选中图标 */
|
|
112
|
+
showActiveIcon?: boolean;
|
|
113
|
+
/** 开启编辑金额 */
|
|
114
|
+
enableEditAmount?: boolean;
|
|
115
|
+
/** 显示状态标识 */
|
|
116
|
+
showStatus?: boolean;
|
|
117
|
+
/** 名称标题字号字重颜色配置 */
|
|
118
|
+
nameTitleStyle?: {
|
|
119
|
+
fontSize: number;
|
|
120
|
+
fontWeight: number;
|
|
121
|
+
color: string;
|
|
122
|
+
};
|
|
123
|
+
/** 卡片状态 */
|
|
124
|
+
cardStatus?: 'used' | 'expired' | 'disabled' | 'conflict' | 'lastPayment';
|
|
125
|
+
/** 自定义余额格式化函数,如果提供则优先使用 */
|
|
126
|
+
formatBalance?: (balance?: number, option?: FormatOption) => React.ReactNode;
|
|
127
|
+
/** 自定义余额标题格式化函数,如果提供则优先使用 */
|
|
128
|
+
formatBalanceTitle?: (balanceTitle?: string, option?: FormatOption) => React.ReactNode;
|
|
129
|
+
/** 自定义使用金额格式化函数,如果提供则优先使用 */
|
|
130
|
+
formatRedeem?: (redeem?: number, option?: FormatOption) => React.ReactNode;
|
|
131
|
+
/** 自定义使用金额标题格式化函数,如果提供则优先使用 */
|
|
132
|
+
formatRedeemTitle?: (redeemTitle?: string, option?: FormatOption) => React.ReactNode;
|
|
133
|
+
/** 最大使用金额 */
|
|
134
|
+
maxRedeem?: number;
|
|
135
|
+
/** 编辑金额前事件 */
|
|
136
|
+
onBeforeEditAmount?: (value: any) => Promise<any> | boolean | void;
|
|
85
137
|
/** 是否显示持有人 */
|
|
86
138
|
showHolderName?: boolean;
|
|
87
139
|
/** 持有人, 表单记录,展示时一般取main_field */
|