@pisell/materials 1.0.924 → 1.0.925

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 (77) 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 +148 -164
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +17 -31
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +28 -42
  11. package/es/components/batch-editor/index.d.ts +1 -0
  12. package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -1
  13. package/es/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +1 -0
  14. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  15. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  16. package/es/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
  17. package/es/components/dataSourceComponents/fields/Upload/CameraPopover.d.ts +1 -0
  18. package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
  19. package/es/components/dataSourceComponents/fields/index.d.ts +9 -9
  20. package/es/components/filter/index.d.ts +1 -0
  21. package/es/components/list/index.d.ts +1 -0
  22. package/es/components/pisellToast/index.d.ts +1 -1
  23. package/es/components/pisellToast/index.js +1 -1
  24. package/es/components/pisellToast/squareToast/index.d.ts +12 -22
  25. package/es/components/pisellToast/squareToast/index.js +24 -106
  26. package/es/components/pisellToast/squareToast/index.less +7 -18
  27. package/es/components/pisellToast/squareToast/methods.d.ts +13 -0
  28. package/es/components/pisellToast/squareToast/methods.js +138 -0
  29. package/es/components/pisellToast/squareToast/renderImperatively.d.ts +31 -0
  30. package/es/components/pisellToast/squareToast/renderImperatively.js +167 -0
  31. package/es/components/pisellToast/squareToast/toast.d.ts +23 -0
  32. package/es/components/pisellToast/squareToast/toast.js +71 -0
  33. package/es/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  34. package/es/components/table/Table/SelectField/index.d.ts +1 -0
  35. package/es/components/table/Table/fields/index.d.ts +1 -0
  36. package/es/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  37. package/es/components/table/Table/fields/text/Show/index.d.ts +1 -0
  38. package/es/components/table/Table/fields/text/index.d.ts +1 -0
  39. package/es/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  40. package/es/components/table/Table/utils.d.ts +1 -1
  41. package/es/utils/index.d.ts +1 -1
  42. package/lib/components/batch-editor/index.d.ts +1 -0
  43. package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -1
  44. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +1 -0
  45. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  46. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  47. package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
  48. package/lib/components/dataSourceComponents/fields/Upload/CameraPopover.d.ts +1 -0
  49. package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
  50. package/lib/components/dataSourceComponents/fields/index.d.ts +9 -9
  51. package/lib/components/filter/index.d.ts +1 -0
  52. package/lib/components/list/index.d.ts +1 -0
  53. package/lib/components/pisellToast/index.d.ts +1 -1
  54. package/lib/components/pisellToast/index.js +2 -2
  55. package/lib/components/pisellToast/squareToast/index.d.ts +12 -22
  56. package/lib/components/pisellToast/squareToast/index.js +30 -93
  57. package/lib/components/pisellToast/squareToast/index.less +7 -18
  58. package/lib/components/pisellToast/squareToast/methods.d.ts +13 -0
  59. package/lib/components/pisellToast/squareToast/methods.js +152 -0
  60. package/lib/components/pisellToast/squareToast/renderImperatively.d.ts +31 -0
  61. package/lib/components/pisellToast/squareToast/renderImperatively.js +148 -0
  62. package/lib/components/pisellToast/squareToast/toast.d.ts +23 -0
  63. package/lib/components/pisellToast/squareToast/toast.js +91 -0
  64. package/lib/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  65. package/lib/components/table/Table/SelectField/index.d.ts +1 -0
  66. package/lib/components/table/Table/fields/index.d.ts +1 -0
  67. package/lib/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  68. package/lib/components/table/Table/fields/text/Show/index.d.ts +1 -0
  69. package/lib/components/table/Table/fields/text/index.d.ts +1 -0
  70. package/lib/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  71. package/lib/components/table/Table/utils.d.ts +1 -1
  72. package/lib/utils/index.d.ts +1 -1
  73. package/package.json +2 -2
  74. package/es/components/pisellToast/squareToast/useToast.d.ts +0 -39
  75. package/es/components/pisellToast/squareToast/useToast.js +0 -145
  76. package/lib/components/pisellToast/squareToast/useToast.d.ts +0 -39
  77. package/lib/components/pisellToast/squareToast/useToast.js +0 -148
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import "./index.less";
2
3
  interface BatchEditorProps {
3
4
  columns: any[];
@@ -43,7 +43,7 @@ export declare const withDataSource: <P extends unknown>(WrappedComponent: React
43
43
  }) => JSX.Element;
44
44
  export declare const withOptions: <P extends unknown>(WrappedComponent: React.ComponentType<P>) => (props: P & {
45
45
  options?: any;
46
- optionSourceType?: "default" | "custom" | "api" | undefined;
46
+ optionSourceType?: "custom" | "default" | "api" | undefined;
47
47
  labelField: string;
48
48
  valueField: string;
49
49
  extraParams?: Record<string, any> | undefined;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import './index.less';
2
3
  interface BaseFilterItem {
3
4
  name?: string;
@@ -1,5 +1,5 @@
1
1
  declare const useDataSourceKey: () => {
2
- dataSourceKey: string | import("../../provider/dataSource/DataSourceContext").DataSourceType | undefined;
3
- dataSourceKeyRef: import("react").MutableRefObject<string | import("../../provider/dataSource/DataSourceContext").DataSourceType | undefined>;
2
+ dataSourceKey: string | undefined;
3
+ dataSourceKeyRef: import("react").MutableRefObject<string | undefined>;
4
4
  };
5
5
  export default useDataSourceKey;
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
17
17
  * @returns
18
18
  */
19
19
  declare const useTableProps: (props: UseTablePropsProps) => {
20
- title: string | number | boolean | JSX.Element | React.ReactFragment | (() => React.ReactNode) | null | undefined;
20
+ title: number | boolean | JSX.Element | React.ReactFragment | (() => React.ReactNode) | null | undefined;
21
21
  pagination: {
22
22
  total: number;
23
23
  current: number;
@@ -26,7 +26,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
26
26
  showSizeChanger: boolean;
27
27
  };
28
28
  columns: import("./useColumns").Column[];
29
- subTitle: string | number | boolean | JSX.Element | React.ReactFragment | (() => React.ReactNode) | null | undefined;
29
+ subTitle: number | boolean | JSX.Element | React.ReactFragment | (() => React.ReactNode) | null | undefined;
30
30
  buttons: any[] | null;
31
31
  filter: JSX.Element | null;
32
32
  onRow: (record: any) => any;
@@ -53,7 +53,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
53
53
  width: number;
54
54
  align: "center" | "left" | "right";
55
55
  fixed: false | "left" | "right";
56
- type: "link" | "button";
56
+ type: "button" | "link";
57
57
  items: OperationItem[];
58
58
  } | undefined;
59
59
  operationContent?: {
@@ -1,6 +1,6 @@
1
1
  declare const SelectWithDataSource: (props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps & {
2
2
  options?: any;
3
- optionSourceType?: "default" | "custom" | "api" | undefined;
3
+ optionSourceType?: "custom" | "default" | "api" | undefined;
4
4
  labelField: string;
5
5
  valueField: string;
6
6
  extraParams?: Record<string, any> | undefined;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  declare const CameraPopover: (props: {
2
3
  onLocalFileClick: () => void;
3
4
  onCameraChange: (file: any) => void;
@@ -15,4 +15,4 @@ export declare const getFileMetadataParams: (file: RcFile & {
15
15
  metadata?: MediaMetadata;
16
16
  }) => Record<string, any>;
17
17
  export declare const isValueEqual: (value: any, fileListValue: any) => boolean;
18
- export declare const getBaseTime: (size: number) => 1000 | 2000 | 4000 | 8000;
18
+ export declare const getBaseTime: (size: number) => 2000 | 1000 | 4000 | 8000;
@@ -34,7 +34,7 @@ declare const formFieldMap: {
34
34
  };
35
35
  FormItemSelect: (props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps & {
36
36
  options?: any;
37
- optionSourceType?: "default" | "custom" | "api" | undefined;
37
+ optionSourceType?: "custom" | "default" | "api" | undefined;
38
38
  labelField: string;
39
39
  valueField: string;
40
40
  extraParams?: Record<string, any> | undefined;
@@ -59,7 +59,11 @@ declare const formFieldMap: {
59
59
  FormItemTranslation: import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
60
60
  FormItemIconSelect: import("react").FC<import("./IconSelect/type").IconSelectProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
61
61
  };
62
- declare const getFieldComponent: (fieldComponent: string) => (import("react").FC<import("./Input/type").InputProps> & {
62
+ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<import("./IconSelect/type").IconSelectProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | (import("react").FC<{}> & {
63
+ Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
64
+ } & {
65
+ Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
66
+ }) | import("react").FC<import("./ColorPicker/type").ColorPickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<(import("antd").DatePickerProps & import("../dataSourceForm/utils").WithModeProps) & import("../dataSourceForm/utils").WithFormItemProps> | (import("react").FC<import("./Input/type").InputProps> & {
63
67
  JSON: import("react").FC<any>;
64
68
  Password: import("react").FC<import("antd/es/input").PasswordProps & import("react").RefAttributes<import("antd").InputRef> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
65
69
  TextArea: import("react").FC<import("antd/es/input").TextAreaProps & import("react").RefAttributes<import("antd/es/input/TextArea").TextAreaRef> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
@@ -79,17 +83,13 @@ declare const getFieldComponent: (fieldComponent: string) => (import("react").FC
79
83
  name?: string | undefined;
80
84
  fieldKey?: string | undefined;
81
85
  } & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
82
- }) | import("react").FC<import("./IconSelect/type").IconSelectProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | (import("react").FC<{}> & {
83
- Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
84
- } & {
85
- Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
86
- }) | import("react").FC<import("./ColorPicker/type").ColorPickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<(import("antd").DatePickerProps & import("../dataSourceForm/utils").WithModeProps) & import("../dataSourceForm/utils").WithFormItemProps> | (import("react").FC<{}> & {
86
+ }) | (import("react").FC<{}> & {
87
87
  Group: import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps>;
88
88
  } & {
89
89
  Group: import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps>;
90
90
  }) | ((props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps & {
91
91
  options?: any;
92
- optionSourceType?: "default" | "custom" | "api" | undefined;
92
+ optionSourceType?: "custom" | "default" | "api" | undefined;
93
93
  labelField: string;
94
94
  valueField: string;
95
95
  extraParams?: Record<string, any> | undefined;
@@ -97,5 +97,5 @@ declare const getFieldComponent: (fieldComponent: string) => (import("react").FC
97
97
  dataSource?: any;
98
98
  }) => JSX.Element) | import("react").FC<any> | import("react").FC<import("./TimePicker/type").TimePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Input.Phone/WithMode").PhoneInputProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Input.Mobile/WithMode").PhoneInputProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("antd").InputProps & {
99
99
  onChange: (value: string) => void;
100
- } & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("antd").InputProps & import("react").RefAttributes<import("antd").InputRef> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("antd/es/input").PasswordProps & import("react").RefAttributes<import("antd").InputRef> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps> | import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps> | import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
100
+ } & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("antd").InputProps & import("react").RefAttributes<import("antd").InputRef> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("antd/es/input").PasswordProps & import("react").RefAttributes<import("antd").InputRef> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps> | import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps> | import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
101
101
  export { getFieldComponent, formFieldMap };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { FilterProps } from "./types";
2
3
  declare const Filter: (props: FilterProps) => JSX.Element | null;
3
4
  export default Filter;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import "./index.less";
2
3
  declare const List: {
3
4
  (props: any): JSX.Element;
@@ -13,5 +13,5 @@ export interface PisellToastProps {
13
13
  onClose?: () => void;
14
14
  }
15
15
  declare const PisellToast: (props: PisellToastProps) => void;
16
- export { default as useToast } from './squareToast/useToast';
16
+ export { useToast } from './squareToast';
17
17
  export default PisellToast;
@@ -32,5 +32,5 @@ var PisellToast = function PisellToast(props) {
32
32
  onClose: onClose
33
33
  });
34
34
  };
35
- export { default as useToast } from "./squareToast/useToast";
35
+ export { useToast } from "./squareToast";
36
36
  export default PisellToast;
@@ -1,25 +1,15 @@
1
- import React from 'react';
1
+ import { clear, show, success, info, loading, fail, hide } from './methods';
2
2
  import './index.less';
3
- export declare type ToastType = 'success' | 'error' | 'warning' | 'info' | 'loading';
4
- export interface ToastProps {
5
- /** Toast 类型 */
6
- type?: ToastType;
7
- /** 显示的内容,支持文本或 React 节点 */
8
- message: React.ReactNode;
9
- /** 是否显示 */
10
- visible?: boolean;
11
- /** 自动关闭时间,单位毫秒,0 表示不自动关闭 */
12
- duration?: number;
13
- /** 关闭回调 */
14
- onClose?: () => void;
15
- /** 自定义图标 */
16
- icon?: React.ReactNode;
17
- /** 自定义样式类名 */
18
- className?: string;
19
- /** 自定义样式 */
20
- style?: React.CSSProperties;
21
- /** 是否显示遮罩 */
22
- mask?: boolean;
3
+ interface ToastInstance {
4
+ show: typeof show;
5
+ clear: typeof clear;
6
+ success: typeof success;
7
+ info: typeof info;
8
+ loading: typeof loading;
9
+ fail: typeof fail;
10
+ error: typeof fail;
11
+ hide: typeof hide;
23
12
  }
24
- declare const Toast: React.FC<ToastProps>;
13
+ declare const Toast: ToastInstance;
14
+ export declare const useToast: () => ToastInstance;
25
15
  export default Toast;
@@ -1,110 +1,28 @@
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 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; }
3
- 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; }
4
- 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; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- 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); }
7
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
- 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."); }
9
- 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); }
10
- 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; }
11
- 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; } }
12
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React, { useEffect, useMemo, useState } from 'react';
14
- import Modal from "../../modal";
15
- import Icon from "../../icon";
16
- import classNames from 'classnames';
1
+ import { useMemo } from 'react';
2
+ import { clear, show, success, info, loading, fail, hide } from "./methods";
17
3
  import "./index.less";
18
- var icons = {
19
- info: '',
20
- success: 'iconchenggong-1-01',
21
- error: 'icon-warning',
22
- warning: 'icon-warning',
23
- loading: 'icon-loading',
24
- fail: 'icon-warning'
4
+ var Toast = {
5
+ show: show,
6
+ clear: clear,
7
+ success: success,
8
+ info: info,
9
+ loading: loading,
10
+ fail: fail,
11
+ error: fail,
12
+ hide: hide
25
13
  };
26
- var Toast = function Toast(_ref) {
27
- var _ref$type = _ref.type,
28
- type = _ref$type === void 0 ? 'info' : _ref$type,
29
- message = _ref.message,
30
- _ref$visible = _ref.visible,
31
- visible = _ref$visible === void 0 ? false : _ref$visible,
32
- _ref$duration = _ref.duration,
33
- duration = _ref$duration === void 0 ? 2000 : _ref$duration,
34
- onClose = _ref.onClose,
35
- icon = _ref.icon,
36
- className = _ref.className,
37
- _ref$mask = _ref.mask,
38
- mask = _ref$mask === void 0 ? false : _ref$mask,
39
- style = _ref.style;
40
- var _useState = useState(visible),
41
- _useState2 = _slicedToArray(_useState, 2),
42
- internalVisible = _useState2[0],
43
- setInternalVisible = _useState2[1];
44
- useEffect(function () {
45
- setInternalVisible(visible);
46
- }, [visible]);
47
- useEffect(function () {
48
- if (internalVisible && duration > 0) {
49
- var timer = setTimeout(function () {
50
- handleClose();
51
- }, duration);
52
- return function () {
53
- return clearTimeout(timer);
54
- };
55
- }
56
- }, [internalVisible, duration]);
57
- var handleClose = function handleClose() {
58
- setInternalVisible(false);
59
- onClose === null || onClose === void 0 || onClose();
60
- };
61
- var showIcon = useMemo(function () {
62
- return icon !== undefined || icons[type];
63
- }, [type, icon]);
64
- var renderIcon = function renderIcon() {
65
- if (icon !== undefined) {
66
- return icon;
67
- }
68
- var iconType = icons[type];
69
- if (iconType) {
70
- return /*#__PURE__*/React.createElement(Icon, {
71
- type: iconType,
72
- className: "pisell-square-toast-icon pisell-square-toast-icon-".concat(type)
73
- });
74
- }
75
- return null;
76
- };
77
- return /*#__PURE__*/React.createElement(Modal, {
78
- open: visible,
79
- footer: null,
80
- closable: false,
81
- centered: true,
82
- maskTransitionName: "",
83
- transitionName: "",
84
- getContainer: function getContainer() {
85
- return document.body;
86
- },
87
- wrapClassName: "pisell-square-toast-wrap",
88
- className: classNames('pisell-square-toast-modal', className),
89
- width: "auto",
90
- style: _objectSpread({
91
- textAlign: 'center'
92
- }, style),
93
- bodyStyle: {
94
- padding: 0
95
- },
96
- mask: mask,
97
- modalRender: function modalRender() {
98
- return /*#__PURE__*/React.createElement("div", {
99
- className: "pisell-square-toast ".concat(type ? "pisell-square-toast-".concat(type) : '')
100
- }, showIcon && /*#__PURE__*/React.createElement("div", {
101
- className: "pisell-square-toast-icon-wrapper"
102
- }, renderIcon()), /*#__PURE__*/React.createElement("div", {
103
- className: "pisell-square-toast-content"
104
- }, /*#__PURE__*/React.createElement("div", {
105
- className: "pisell-square-toast-message"
106
- }, message)));
107
- }
108
- });
14
+ export var useToast = function useToast() {
15
+ return useMemo(function () {
16
+ return {
17
+ show: show,
18
+ clear: clear,
19
+ success: success,
20
+ info: info,
21
+ loading: loading,
22
+ fail: fail,
23
+ error: fail,
24
+ hide: hide
25
+ };
26
+ }, []);
109
27
  };
110
28
  export default Toast;
@@ -5,6 +5,8 @@
5
5
  .pisell-square-toast-modal {
6
6
  pointer-events: none;
7
7
  user-select: none;
8
+ min-width: 190px;
9
+ min-height: 74px;
8
10
 
9
11
  // Toast 容器
10
12
  .pisell-square-toast {
@@ -19,7 +21,6 @@
19
21
  overflow: hidden;
20
22
  background: rgba(0, 0, 0, 0.8);
21
23
 
22
- // 图标包装器
23
24
  .pisell-square-toast-icon-wrapper {
24
25
  display: flex;
25
26
  align-items: center;
@@ -43,27 +44,15 @@
43
44
 
44
45
  // 内容区域
45
46
  .pisell-square-toast-content {
46
- .pisell-square-toast-message {
47
- font-size: 20px;
48
- line-height: 1.5;
49
- color: #ffffff;
50
- text-align: center;
51
- }
52
- }
53
-
54
- // 带图标的样式调整
55
- &.pisell-square-toast-success,
56
- &.pisell-square-toast-error,
57
- &.pisell-square-toast-warning,
58
- &.pisell-square-toast-fail,
59
- &.pisell-square-toast-loading {
60
- min-width: 190px;
61
- min-height: 74px;
47
+ font-size: 20px;
48
+ line-height: 1.5;
49
+ color: #ffffff;
50
+ text-align: center;
62
51
  }
63
52
  }
64
53
  }
65
54
 
66
- // 旋转动画
55
+ // loading 旋转动画
67
56
  @keyframes fadenum {
68
57
  to {
69
58
  transform: rotate(360deg);
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ToastProps } from './toast';
3
+ interface ToastInstance {
4
+ close: () => void;
5
+ }
6
+ declare const show: (configOrContent: Partial<ToastProps> | React.ReactNode, duration?: number, onClose?: () => void) => ToastInstance;
7
+ declare const clear: () => void;
8
+ declare const success: (content: React.ReactNode, duration?: number, onClose?: () => void) => ToastInstance;
9
+ declare const info: (content: React.ReactNode, duration?: number, onClose?: () => void) => ToastInstance;
10
+ declare const loading: (content: React.ReactNode, duration?: number, onClose?: () => void) => ToastInstance;
11
+ declare const fail: (content: React.ReactNode, duration?: number, onClose?: () => void) => ToastInstance;
12
+ declare const hide: () => void;
13
+ export { show, clear, success, info, loading, fail, hide };
@@ -0,0 +1,138 @@
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, onClose) {
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
+ }), onClose !== undefined && {
43
+ onClose: onClose
44
+ }));
45
+ } else {
46
+ // 如果不是 string 或 ReactNode,则认为是 config 对象
47
+ props = mergeProps(defaultProps, configOrContent || {});
48
+ }
49
+ var element = /*#__PURE__*/React.createElement(Toast, _extends({}, props, {
50
+ onClose: function onClose() {
51
+ var _props$onClose, _props;
52
+ currentHandler = null;
53
+ (_props$onClose = (_props = props).onClose) === null || _props$onClose === void 0 || _props$onClose.call(_props);
54
+ }
55
+ }));
56
+ if (currentHandler) {
57
+ var _currentHandler$isRen, _currentHandler;
58
+ if ((_currentHandler$isRen = (_currentHandler = currentHandler).isRendered) !== null && _currentHandler$isRen !== void 0 && _currentHandler$isRen.call(_currentHandler)) {
59
+ currentHandler.replace(element);
60
+ } else {
61
+ currentHandler.close();
62
+ currentHandler = renderImperatively(element);
63
+ }
64
+ } else {
65
+ currentHandler = renderImperatively(element);
66
+ }
67
+ if (currentTimeout) {
68
+ window.clearTimeout(currentTimeout);
69
+ }
70
+ if (props.duration !== 0) {
71
+ currentTimeout = window.setTimeout(function () {
72
+ clear();
73
+ }, props.duration);
74
+ }
75
+ var instance = {
76
+ close: function close() {
77
+ if (currentHandler) {
78
+ currentHandler.close();
79
+ currentHandler = null;
80
+ }
81
+ if (currentTimeout) {
82
+ window.clearTimeout(currentTimeout);
83
+ currentTimeout = null;
84
+ }
85
+ }
86
+ };
87
+ return instance;
88
+ };
89
+
90
+ // 清理函数
91
+ var clear = function clear() {
92
+ if (currentHandler) {
93
+ currentHandler.close();
94
+ currentHandler = null;
95
+ }
96
+ if (currentTimeout) {
97
+ window.clearTimeout(currentTimeout);
98
+ currentTimeout = null;
99
+ }
100
+ };
101
+
102
+ // 便捷方法
103
+ var success = function success(content, duration, onClose) {
104
+ return show({
105
+ content: content,
106
+ icon: 'success',
107
+ duration: duration,
108
+ onClose: onClose
109
+ });
110
+ };
111
+ var info = function info(content, duration, onClose) {
112
+ return show({
113
+ content: content,
114
+ icon: 'info',
115
+ duration: duration,
116
+ onClose: onClose
117
+ });
118
+ };
119
+ var loading = function loading(content, duration, onClose) {
120
+ return show({
121
+ content: content,
122
+ icon: 'loading',
123
+ duration: duration,
124
+ onClose: onClose
125
+ });
126
+ };
127
+ var fail = function fail(content, duration, onClose) {
128
+ return show({
129
+ content: content,
130
+ icon: 'error',
131
+ duration: duration,
132
+ onClose: onClose
133
+ });
134
+ };
135
+ var hide = function hide() {
136
+ clear();
137
+ };
138
+ export { show, clear, success, info, loading, fail, hide };
@@ -0,0 +1,31 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { Root } from 'react-dom/client';
3
+ import React from 'react';
4
+ declare type ImperativeProps = {
5
+ visible?: boolean;
6
+ onClose?: () => 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 = "__rc_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 Set React render function for compatible usage.
25
+ * This is internal usage only compatible with React 19.
26
+ * And will be removed in next major version.
27
+ */
28
+ export declare function unstableSetRender(render?: RenderType): RenderType;
29
+ export declare function renderToBody(element: ReactElement): UnmountType;
30
+ export declare function renderImperatively(element: TargetElement): ImperativeHandler;
31
+ export {};