@pisell/materials 1.0.924 → 1.0.926

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +146 -146
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +18 -18
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +23 -23
  11. package/dist/umd/materials.min.css +1 -0
  12. package/dist/umd/materials.min.js +1 -0
  13. package/dist/umd/static/DotsSix.57d66266.svg +1 -0
  14. package/dist/umd/static/arrow-left.e542294f.svg +1 -0
  15. package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
  16. package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
  17. package/dist/umd/static/help-circle.31c9be40.svg +1 -0
  18. package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
  19. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  20. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  21. package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
  22. package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
  23. package/es/components/dataSourceComponents/fields/index.d.ts +11 -11
  24. package/es/components/pisellCamera/index.js +11 -2
  25. package/es/components/pisellCamera/index.less +17 -6
  26. package/es/components/pisellToast/index.d.ts +1 -1
  27. package/es/components/pisellToast/index.js +1 -1
  28. package/es/components/pisellToast/squareToast/index.d.ts +12 -22
  29. package/es/components/pisellToast/squareToast/index.js +24 -106
  30. package/es/components/pisellToast/squareToast/index.less +7 -18
  31. package/es/components/pisellToast/squareToast/methods.d.ts +13 -0
  32. package/es/components/pisellToast/squareToast/methods.js +136 -0
  33. package/es/components/pisellToast/squareToast/renderImperatively.d.ts +29 -0
  34. package/es/components/pisellToast/squareToast/renderImperatively.js +165 -0
  35. package/es/components/pisellToast/squareToast/toast.d.ts +25 -0
  36. package/es/components/pisellToast/squareToast/toast.js +60 -0
  37. package/es/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  38. package/es/components/table/Table/fields/index.d.ts +2 -2
  39. package/es/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  40. package/es/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  41. package/es/components/table/Table/utils.d.ts +1 -1
  42. package/es/locales/zh-TW.js +8 -15
  43. package/es/utils/index.d.ts +1 -1
  44. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  45. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  46. package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
  47. package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
  48. package/lib/components/dataSourceComponents/fields/index.d.ts +11 -11
  49. package/lib/components/pisellCamera/index.js +5 -2
  50. package/lib/components/pisellCamera/index.less +17 -6
  51. package/lib/components/pisellToast/index.d.ts +1 -1
  52. package/lib/components/pisellToast/index.js +2 -2
  53. package/lib/components/pisellToast/squareToast/index.d.ts +12 -22
  54. package/lib/components/pisellToast/squareToast/index.js +30 -93
  55. package/lib/components/pisellToast/squareToast/index.less +7 -18
  56. package/lib/components/pisellToast/squareToast/methods.d.ts +13 -0
  57. package/lib/components/pisellToast/squareToast/methods.js +150 -0
  58. package/lib/components/pisellToast/squareToast/renderImperatively.d.ts +29 -0
  59. package/lib/components/pisellToast/squareToast/renderImperatively.js +148 -0
  60. package/lib/components/pisellToast/squareToast/toast.d.ts +25 -0
  61. package/lib/components/pisellToast/squareToast/toast.js +88 -0
  62. package/lib/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  63. package/lib/components/table/Table/fields/index.d.ts +2 -2
  64. package/lib/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  65. package/lib/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  66. package/lib/components/table/Table/utils.d.ts +1 -1
  67. package/lib/locales/zh-TW.js +4 -0
  68. package/lib/utils/index.d.ts +1 -1
  69. package/package.json +2 -2
  70. package/es/components/pisellToast/squareToast/useToast.d.ts +0 -39
  71. package/es/components/pisellToast/squareToast/useToast.js +0 -145
  72. package/lib/components/pisellToast/squareToast/useToast.d.ts +0 -39
  73. package/lib/components/pisellToast/squareToast/useToast.js +0 -148
@@ -0,0 +1,88 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/pisellToast/squareToast/toast.tsx
30
+ var toast_exports = {};
31
+ __export(toast_exports, {
32
+ default: () => toast_default
33
+ });
34
+ module.exports = __toCommonJS(toast_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_modal = __toESM(require("../../modal"));
37
+ var import_icon = __toESM(require("../../icon"));
38
+ var import_classnames = __toESM(require("classnames"));
39
+ var import_index = require("./index.less");
40
+ var icons = {
41
+ info: "",
42
+ success: "iconchenggong-1-01",
43
+ error: "icon-warning",
44
+ warning: "icon-warning",
45
+ loading: "icon-loading",
46
+ fail: "icon-warning"
47
+ };
48
+ var Toast = ({
49
+ content,
50
+ open,
51
+ icon,
52
+ className,
53
+ ...rest
54
+ }) => {
55
+ const iconElement = (0, import_react.useMemo)(() => {
56
+ if (icon === null || icon === void 0) return null;
57
+ if (typeof icon === "string" && icon in icons) {
58
+ if (!icons[icon]) return null;
59
+ return /* @__PURE__ */ import_react.default.createElement(
60
+ import_icon.default,
61
+ {
62
+ type: icons[icon],
63
+ className: `pisell-square-toast-icon pisell-square-toast-icon-${icon}`
64
+ }
65
+ );
66
+ }
67
+ return icon;
68
+ }, [icon]);
69
+ return /* @__PURE__ */ import_react.default.createElement(
70
+ import_modal.default,
71
+ {
72
+ open,
73
+ footer: null,
74
+ closable: false,
75
+ centered: true,
76
+ maskTransitionName: "",
77
+ transitionName: "",
78
+ width: "unset",
79
+ wrapClassName: "pisell-square-toast-wrap",
80
+ className: (0, import_classnames.default)("pisell-square-toast-modal", className),
81
+ bodyStyle: { padding: 0 },
82
+ destroyOnClose: true,
83
+ modalRender: () => /* @__PURE__ */ import_react.default.createElement("div", { className: `pisell-square-toast` }, iconElement && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-square-toast-icon-wrapper" }, iconElement), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-square-toast-content" }, content)),
84
+ ...rest
85
+ }
86
+ );
87
+ };
88
+ var toast_default = Toast;
@@ -1,5 +1,5 @@
1
1
  declare const useGapSize: (gap: number | number[]) => {
2
- horizontal: any;
3
- vertical: any;
2
+ horizontal: number;
3
+ vertical: number;
4
4
  };
5
5
  export default useGapSize;
@@ -197,12 +197,12 @@ export declare const fieldList: ({
197
197
  field_icon: string;
198
198
  field_name: string;
199
199
  field_type: string;
200
- default_value: boolean;
200
+ default_value: string;
201
201
  } | {
202
202
  field_icon: string;
203
203
  field_name: string;
204
204
  field_type: string;
205
- default_value: string;
205
+ default_value: boolean;
206
206
  } | {
207
207
  field_icon: string;
208
208
  field_name: string;
@@ -2,4 +2,4 @@ export default function ({ value, key, item, }: {
2
2
  value: string | string[];
3
3
  key: string | string[];
4
4
  item: Record<string, any>;
5
- }): any;
5
+ }): boolean;
@@ -2,4 +2,4 @@ export default function ({ value, key, item, }: {
2
2
  value: string | string[] | Record<string, any>[];
3
3
  key: string | string[];
4
4
  item: Record<string, any>;
5
- }): any;
5
+ }): boolean;
@@ -167,7 +167,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
167
167
  sort?: SortType | undefined;
168
168
  mode: "" | "localStorage" | "remote";
169
169
  currentViewMode: ModeType;
170
- }) => ("view_mode" | "filter_setting" | "group_by" | "order_by" | "column_setting" | "gallery_setting")[];
170
+ }) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
171
171
  export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
172
172
  export declare const stringify: (obj: Record<string, any>) => string;
173
173
  export {};
@@ -377,6 +377,10 @@ var zh_TW_default = {
377
377
  "pisell-list-pagination-page-of": (current, total) => `第 ${current} 頁 共 ${total} 頁`,
378
378
  "pisell-list-pagination-previous": "上一頁",
379
379
  "pisell-list-pagination-next": "下一頁",
380
+ "pisell2.text.goodpass.product-vouchers": "優惠促銷",
381
+ "pisell2.text.goodpass.last-settlement": "(上次結算)",
382
+ "pisell2.text.goodpass.view-more": "查看更多",
383
+ "pisell2.text.goodpass.save": "節省",
380
384
  // 相机组件
381
385
  "pisell-camera-no-camera-accessible": "沒有找到攝像頭",
382
386
  "pisell-camera-permission-denied": "沒有權限使用攝像頭",
@@ -1,4 +1,4 @@
1
1
  export declare const isBrowser: boolean;
2
- export declare const getCssNumber: (val: string | number) => string | number;
2
+ export declare const getCssNumber: (val: string | number) => string;
3
3
  export declare function uuid(): string;
4
4
  export * from './mergeWith';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.924",
3
+ "version": "1.0.926",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -72,8 +72,8 @@
72
72
  "react-window": "^1.8.10",
73
73
  "styled-components": "^6.0.0-rc.3",
74
74
  "swiper": "^8.4.7",
75
- "vod-js-sdk-v6": "^1.4.11",
76
75
  "antd-mobile": "^5.38.1",
76
+ "vod-js-sdk-v6": "^1.4.11",
77
77
  "react-camera-pro": "1.4.0",
78
78
  "@pisell/date-picker": "1.0.126",
79
79
  "@pisell/icon": "0.0.10",
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import { ToastProps } from './index';
3
- interface ToastInstance {
4
- destroy: () => void;
5
- }
6
- interface ToastConfig extends ToastProps {
7
- /** 容器节点,默认为 document.body */
8
- getContainer?: () => HTMLElement;
9
- }
10
- interface UseToastConfig {
11
- /** 默认自动关闭时间,单位毫秒 */
12
- duration?: number;
13
- /** 默认关闭回调 */
14
- onClose?: () => void;
15
- /** 默认容器节点 */
16
- getContainer?: () => HTMLElement;
17
- /** 默认是否显示遮罩 */
18
- mask?: boolean;
19
- /** 默认点击遮罩是否关闭 */
20
- maskClosable?: boolean;
21
- }
22
- interface ToastMethod {
23
- (config: ToastConfig): ToastInstance;
24
- (message: React.ReactNode, config?: Omit<ToastConfig, 'type' | 'message'>): ToastInstance;
25
- (message: React.ReactNode, duration?: number, onClose?: () => void): ToastInstance;
26
- }
27
- interface ToastApi {
28
- success: ToastMethod;
29
- error: ToastMethod;
30
- warning: ToastMethod;
31
- info: ToastMethod;
32
- fail: ToastMethod;
33
- loading: ToastMethod;
34
- show: (config: ToastConfig) => ToastInstance;
35
- destroy: (instance?: ToastInstance) => void;
36
- destroyAll: () => void;
37
- }
38
- export declare const useToast: (defaultConfig?: UseToastConfig) => ToastApi;
39
- export default useToast;
@@ -1,145 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- 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."); }
3
- 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); }
4
- 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; }
5
- 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; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- 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; }
8
- 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; }
9
- 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; }
10
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
11
- 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); }
12
- 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); }
13
- 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); }
14
- import React, { useCallback, useRef } from 'react';
15
- import { createRoot } from 'react-dom/client';
16
- import Toast from "./index";
17
- // 全局实例管理
18
- var instances = new Set();
19
- var createToastInstance = function createToastInstance(config) {
20
- var container = document.createElement('div');
21
- var getContainer = config.getContainer || function () {
22
- return document.body;
23
- };
24
- var parentNode = getContainer();
25
- parentNode.appendChild(container);
26
- var root = createRoot(container);
27
- var instance = {
28
- destroy: function destroy() {
29
- instances.delete(instance);
30
- root.unmount();
31
- if (container.parentNode) {
32
- container.parentNode.removeChild(container);
33
- }
34
- }
35
- };
36
- instances.add(instance);
37
- var handleClose = function handleClose() {
38
- instance.destroy();
39
- };
40
- root.render( /*#__PURE__*/React.createElement(Toast, _extends({}, config, {
41
- visible: true,
42
- onClose: handleClose
43
- })));
44
- return instance;
45
- };
46
-
47
- // 参数解析辅助函数
48
- var parseToastArgs = function parseToastArgs(args, type) {
49
- var defaultConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
50
- // 支持 (config) 形式
51
- if (args.length === 1 && _typeof(args[0]) === 'object' && args[0].message) {
52
- return _objectSpread(_objectSpread(_objectSpread({}, defaultConfig), args[0]), {}, {
53
- type: type
54
- });
55
- }
56
-
57
- // 支持 (message, config) 形式
58
- if (args.length <= 2 && args.length >= 1 && (args.length === 1 || _typeof(args[1]) === 'object')) {
59
- var _args = _slicedToArray(args, 2),
60
- _message = _args[0],
61
- _args$ = _args[1],
62
- _config = _args$ === void 0 ? {} : _args$;
63
- return _objectSpread(_objectSpread(_objectSpread({}, defaultConfig), _config), {}, {
64
- type: type,
65
- message: _message
66
- });
67
- }
68
-
69
- // 支持 (message, duration, onClose) 形式
70
- var _args2 = _slicedToArray(args, 3),
71
- message = _args2[0],
72
- duration = _args2[1],
73
- onClose = _args2[2];
74
- return _objectSpread(_objectSpread({}, defaultConfig), {}, {
75
- type: type,
76
- message: message,
77
- duration: duration !== undefined ? duration : defaultConfig.duration,
78
- onClose: onClose || defaultConfig.onClose
79
- });
80
- };
81
-
82
- // React Hook
83
- export var useToast = function useToast() {
84
- var defaultConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
85
- var instancesRef = useRef(new Set());
86
- var createInstance = useCallback(function (config) {
87
- var instance = createToastInstance(config);
88
- instancesRef.current.add(instance);
89
- var originalDestroy = instance.destroy;
90
- instance.destroy = function () {
91
- instancesRef.current.delete(instance);
92
- originalDestroy();
93
- };
94
- return instance;
95
- }, []);
96
- var createToastMethod = useCallback(function (type) {
97
- return useCallback(function () {
98
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
99
- args[_key] = arguments[_key];
100
- }
101
- var config = parseToastArgs(args, type, defaultConfig);
102
- return createInstance(config);
103
- }, [createInstance, defaultConfig]);
104
- }, [createInstance, defaultConfig]);
105
- var success = createToastMethod('success');
106
- var error = createToastMethod('error');
107
- var warning = createToastMethod('warning');
108
- var info = createToastMethod('info');
109
- var fail = createToastMethod('warning'); // fail 使用 warning 类型
110
- var loading = createToastMethod('loading');
111
- var show = useCallback(function (config) {
112
- var mergedConfig = _objectSpread(_objectSpread({}, defaultConfig), config);
113
- return createInstance(mergedConfig);
114
- }, [createInstance, defaultConfig]);
115
- var destroy = useCallback(function (instance) {
116
- if (instance) {
117
- instance.destroy();
118
- }
119
- }, []);
120
- var destroyAll = useCallback(function () {
121
- instancesRef.current.forEach(function (instance) {
122
- instance.destroy();
123
- });
124
- instancesRef.current.clear();
125
- }, []);
126
-
127
- // 组件卸载时清理所有实例
128
- React.useEffect(function () {
129
- return function () {
130
- destroyAll();
131
- };
132
- }, [destroyAll]);
133
- return {
134
- success: success,
135
- error: error,
136
- warning: warning,
137
- info: info,
138
- fail: fail,
139
- loading: loading,
140
- show: show,
141
- destroy: destroy,
142
- destroyAll: destroyAll
143
- };
144
- };
145
- export default useToast;
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import { ToastProps } from './index';
3
- interface ToastInstance {
4
- destroy: () => void;
5
- }
6
- interface ToastConfig extends ToastProps {
7
- /** 容器节点,默认为 document.body */
8
- getContainer?: () => HTMLElement;
9
- }
10
- interface UseToastConfig {
11
- /** 默认自动关闭时间,单位毫秒 */
12
- duration?: number;
13
- /** 默认关闭回调 */
14
- onClose?: () => void;
15
- /** 默认容器节点 */
16
- getContainer?: () => HTMLElement;
17
- /** 默认是否显示遮罩 */
18
- mask?: boolean;
19
- /** 默认点击遮罩是否关闭 */
20
- maskClosable?: boolean;
21
- }
22
- interface ToastMethod {
23
- (config: ToastConfig): ToastInstance;
24
- (message: React.ReactNode, config?: Omit<ToastConfig, 'type' | 'message'>): ToastInstance;
25
- (message: React.ReactNode, duration?: number, onClose?: () => void): ToastInstance;
26
- }
27
- interface ToastApi {
28
- success: ToastMethod;
29
- error: ToastMethod;
30
- warning: ToastMethod;
31
- info: ToastMethod;
32
- fail: ToastMethod;
33
- loading: ToastMethod;
34
- show: (config: ToastConfig) => ToastInstance;
35
- destroy: (instance?: ToastInstance) => void;
36
- destroyAll: () => void;
37
- }
38
- export declare const useToast: (defaultConfig?: UseToastConfig) => ToastApi;
39
- export default useToast;
@@ -1,148 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/components/pisellToast/squareToast/useToast.tsx
30
- var useToast_exports = {};
31
- __export(useToast_exports, {
32
- default: () => useToast_default,
33
- useToast: () => useToast
34
- });
35
- module.exports = __toCommonJS(useToast_exports);
36
- var import_react = __toESM(require("react"));
37
- var import_client = require("react-dom/client");
38
- var import_index = __toESM(require("./index"));
39
- var instances = /* @__PURE__ */ new Set();
40
- var createToastInstance = (config) => {
41
- const container = document.createElement("div");
42
- const getContainer = config.getContainer || (() => document.body);
43
- const parentNode = getContainer();
44
- parentNode.appendChild(container);
45
- const root = (0, import_client.createRoot)(container);
46
- const instance = {
47
- destroy: () => {
48
- instances.delete(instance);
49
- root.unmount();
50
- if (container.parentNode) {
51
- container.parentNode.removeChild(container);
52
- }
53
- }
54
- };
55
- instances.add(instance);
56
- const handleClose = () => {
57
- instance.destroy();
58
- };
59
- root.render(/* @__PURE__ */ import_react.default.createElement(import_index.default, { ...config, visible: true, onClose: handleClose }));
60
- return instance;
61
- };
62
- var parseToastArgs = (args, type, defaultConfig = {}) => {
63
- if (args.length === 1 && typeof args[0] === "object" && args[0].message) {
64
- return { ...defaultConfig, ...args[0], type };
65
- }
66
- if (args.length <= 2 && args.length >= 1 && (args.length === 1 || typeof args[1] === "object")) {
67
- const [message2, config = {}] = args;
68
- return { ...defaultConfig, ...config, type, message: message2 };
69
- }
70
- const [message, duration, onClose] = args;
71
- return {
72
- ...defaultConfig,
73
- type,
74
- message,
75
- duration: duration !== void 0 ? duration : defaultConfig.duration,
76
- onClose: onClose || defaultConfig.onClose
77
- };
78
- };
79
- var useToast = (defaultConfig = {}) => {
80
- const instancesRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
81
- const createInstance = (0, import_react.useCallback)((config) => {
82
- const instance = createToastInstance(config);
83
- instancesRef.current.add(instance);
84
- const originalDestroy = instance.destroy;
85
- instance.destroy = () => {
86
- instancesRef.current.delete(instance);
87
- originalDestroy();
88
- };
89
- return instance;
90
- }, []);
91
- const createToastMethod = (0, import_react.useCallback)(
92
- (type) => {
93
- return (0, import_react.useCallback)(
94
- (...args) => {
95
- const config = parseToastArgs(args, type, defaultConfig);
96
- return createInstance(config);
97
- },
98
- [createInstance, defaultConfig]
99
- );
100
- },
101
- [createInstance, defaultConfig]
102
- );
103
- const success = createToastMethod("success");
104
- const error = createToastMethod("error");
105
- const warning = createToastMethod("warning");
106
- const info = createToastMethod("info");
107
- const fail = createToastMethod("warning");
108
- const loading = createToastMethod("loading");
109
- const show = (0, import_react.useCallback)(
110
- (config) => {
111
- const mergedConfig = { ...defaultConfig, ...config };
112
- return createInstance(mergedConfig);
113
- },
114
- [createInstance, defaultConfig]
115
- );
116
- const destroy = (0, import_react.useCallback)((instance) => {
117
- if (instance) {
118
- instance.destroy();
119
- }
120
- }, []);
121
- const destroyAll = (0, import_react.useCallback)(() => {
122
- instancesRef.current.forEach((instance) => {
123
- instance.destroy();
124
- });
125
- instancesRef.current.clear();
126
- }, []);
127
- import_react.default.useEffect(() => {
128
- return () => {
129
- destroyAll();
130
- };
131
- }, [destroyAll]);
132
- return {
133
- success,
134
- error,
135
- warning,
136
- info,
137
- fail,
138
- loading,
139
- show,
140
- destroy,
141
- destroyAll
142
- };
143
- };
144
- var useToast_default = useToast;
145
- // Annotate the CommonJS export names for ESM import in node:
146
- 0 && (module.exports = {
147
- useToast
148
- });