@mi-avalon/libs 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IMFormCascaderItem, IMFormChkBoxGroupItem, IMFormDatePickerItem, IMFormInputItem, IMFormInputNumItem, IMFormItem, IMFormMentionsItem, IMFormRadioGroupItem, IMFormRangePickerItem, IMFormSelectItem, IMFormSliderItem, IMFormTextItem, IMFormTreeSelectItem, IMFormUploadItem } from './type';
2
+ import { IMFormCascaderItem, IMFormCheckBoxGroupItem, IMFormDatePickerItem, IMFormInputItem, IMFormInputNumItem, IMFormItem, IMFormMentionsItem, IMFormRadioGroupItem, IMFormRangePickerItem, IMFormSelectItem, IMFormTextItem, IMFormTreeSelectItem, IMFormUploadItem } from './type';
3
3
  export declare class MFormItemConst {
4
4
  static readonly labelCol: {
5
5
  span: number;
@@ -9,7 +9,7 @@ export declare class MFormItemConst {
9
9
  };
10
10
  static readonly defaultRowGutter = 24;
11
11
  static getDefaultArrayPlaceholder(item: IMFormItem): [string, string];
12
- static getDefaultPlaceholder(item: IMFormItem): string | undefined;
12
+ static getDefaultPlaceholder(item: IMFormItem): string;
13
13
  static input: (item: IMFormInputItem) => React.JSX.Element;
14
14
  static password: (item: IMFormInputItem) => React.JSX.Element;
15
15
  static text: (item: IMFormTextItem) => React.JSX.Element;
@@ -18,10 +18,9 @@ export declare class MFormItemConst {
18
18
  static rangePicker: (item: IMFormRangePickerItem) => React.JSX.Element;
19
19
  static select: (item: IMFormSelectItem) => React.JSX.Element;
20
20
  static radio: (item: IMFormRadioGroupItem) => React.JSX.Element;
21
- static checkbox: (item: IMFormChkBoxGroupItem) => React.JSX.Element;
21
+ static checkbox: (item: IMFormCheckBoxGroupItem) => React.JSX.Element;
22
22
  static upload: (item: IMFormUploadItem) => React.JSX.Element;
23
23
  static mentions: (item: IMFormMentionsItem) => React.JSX.Element;
24
24
  static cascader: (item: IMFormCascaderItem) => React.JSX.Element;
25
25
  static treeSelect: (item: IMFormTreeSelectItem) => React.JSX.Element;
26
- static slider: (item: IMFormSliderItem) => React.JSX.Element;
27
26
  }
@@ -1,11 +1,9 @@
1
- import { CascaderAutoProps, FormInstance, FormItemProps, FormProps, InputNumberProps, InputProps, MentionsProps, RadioGroupProps, RowProps, SelectProps, SliderSingleProps, TreeSelectProps, UploadProps } from 'antd';
2
- import { CheckboxGroupProps } from 'antd/es/checkbox';
3
- import { RangePickerProps } from 'antd/es/date-picker';
4
- import { Rule } from 'antd/es/form';
5
- import { TextAreaProps } from 'antd/es/input';
6
- import { SliderRangeProps } from 'antd/es/slider';
7
- import { DatePickerProps } from 'antd/lib';
1
+ import { CascaderAutoProps, Checkbox, DatePicker, FormInstance, FormItemProps, FormProps, FormRule, Input, InputNumberProps, InputProps, MentionsProps, RadioGroupProps, RowProps, SelectProps, TreeSelectProps, UploadProps } from 'antd';
8
2
  import { ReactElement } from 'react';
3
+ declare type CheckboxGroupProps = React.ComponentProps<typeof Checkbox.Group>;
4
+ declare type RangePickerProps = React.ComponentProps<typeof DatePicker.RangePicker>;
5
+ declare type DatePickerProps = React.ComponentProps<typeof DatePicker>;
6
+ declare type TextAreaProps = React.ComponentProps<typeof Input.TextArea>;
9
7
  export declare enum MFormItemTypeEnum {
10
8
  Input = "input",
11
9
  InputNumber = "inputNumber",
@@ -19,8 +17,7 @@ export declare enum MFormItemTypeEnum {
19
17
  Upload = "upload",
20
18
  Mentions = "mentions",
21
19
  Cascader = "cascader",
22
- TreeSelect = "treeSelect",
23
- Slider = "slider"
20
+ TreeSelect = "treeSelect"
24
21
  }
25
22
  export declare type MFormItemLayout = {
26
23
  span?: number;
@@ -85,7 +82,7 @@ export interface IMFormBaseItem {
85
82
  /**
86
83
  * rule-max, 正则,验证消息
87
84
  */
88
- rules?: Rule[];
85
+ rules?: FormRule[];
89
86
  /**
90
87
  * 自定义form
91
88
  */
@@ -138,7 +135,7 @@ export interface IMFormRadioGroupItem extends IMFormBaseItem {
138
135
  type: MFormItemTypeEnum.Radio;
139
136
  props?: RadioGroupProps;
140
137
  }
141
- export interface IMFormChkBoxGroupItem extends IMFormBaseItem {
138
+ export interface IMFormCheckBoxGroupItem extends IMFormBaseItem {
142
139
  type: MFormItemTypeEnum.Checkbox;
143
140
  props?: CheckboxGroupProps;
144
141
  }
@@ -177,8 +174,5 @@ export interface IMFormTreeSelectItem extends IMFormBaseItem {
177
174
  placeholder?: string;
178
175
  props?: TreeSelectProps;
179
176
  }
180
- export interface IMFormSliderItem extends IMFormBaseItem {
181
- type: MFormItemTypeEnum.Slider;
182
- props?: SliderSingleProps | SliderRangeProps;
183
- }
184
- export declare type IMFormItem = IMFormInputItem | IMFormInputNumItem | IMFormSelectItem | IMFormChkBoxGroupItem | IMFormRadioGroupItem | IMFormTextItem | IMFormDatePickerItem | IMFormRangePickerItem | IMFormUploadItem | IMFormMentionsItem | IMFormCascaderItem | IMFormTreeSelectItem | IMFormSliderItem;
177
+ export declare type IMFormItem = IMFormInputItem | IMFormInputNumItem | IMFormSelectItem | IMFormCheckBoxGroupItem | IMFormRadioGroupItem | IMFormTextItem | IMFormDatePickerItem | IMFormRangePickerItem | IMFormUploadItem | IMFormMentionsItem | IMFormCascaderItem | IMFormTreeSelectItem;
178
+ export {};
@@ -9,7 +9,6 @@ var React = require('react');
9
9
  var React__default = _interopDefault(React);
10
10
  var ReactDOMClient = require('react-dom/client');
11
11
  var icons = require('@ant-design/icons');
12
- var lodash = require('lodash');
13
12
 
14
13
  var CMX = function CMX() {
15
14
  /**
@@ -506,6 +505,42 @@ var removeNull = function removeNull(obj) {
506
505
  }
507
506
  return obj;
508
507
  };
508
+ // 防抖函数
509
+ var debounce = function debounce(func, wait) {
510
+ var timeout = null;
511
+ return function () {
512
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
513
+ args[_key] = arguments[_key];
514
+ }
515
+ if (timeout) {
516
+ clearTimeout(timeout);
517
+ }
518
+ timeout = setTimeout(function () {
519
+ func.apply(void 0, args);
520
+ }, wait);
521
+ };
522
+ };
523
+ // 节流函数
524
+ var throttle = function throttle(func, wait) {
525
+ var timeout = null;
526
+ var lastTime = 0;
527
+ return function () {
528
+ var nowTime = Date.now();
529
+ if (!timeout) {
530
+ func.apply(void 0, arguments);
531
+ lastTime = nowTime;
532
+ timeout = setTimeout(function () {
533
+ timeout = null;
534
+ }, wait);
535
+ } else {
536
+ var diffTime = nowTime - lastTime;
537
+ if (diffTime >= wait) {
538
+ func.apply(void 0, arguments);
539
+ lastTime = nowTime;
540
+ }
541
+ }
542
+ };
543
+ };
509
544
 
510
545
  /**
511
546
  * 版本号工具类
@@ -907,8 +942,9 @@ styleInject(css_248z$1);
907
942
  MFormItemTypeEnum["Mentions"] = "mentions";
908
943
  MFormItemTypeEnum["Cascader"] = "cascader";
909
944
  MFormItemTypeEnum["TreeSelect"] = "treeSelect";
910
- MFormItemTypeEnum["Slider"] = "slider";
945
+ // Slider = 'slider',
911
946
  })(exports.MFormItemTypeEnum || (exports.MFormItemTypeEnum = {}));
947
+ // | IMFormSliderItem;
912
948
 
913
949
  var RangePicker = antd.DatePicker.RangePicker;
914
950
  var MFormItemConst = /*#__PURE__*/function () {
@@ -1035,9 +1071,6 @@ MFormItemConst.treeSelect = function (item) {
1035
1071
  placeholder: item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
1036
1072
  }));
1037
1073
  };
1038
- MFormItemConst.slider = function (item) {
1039
- return React__default.createElement(antd.Slider, Object.assign({}, item.props));
1040
- };
1041
1074
 
1042
1075
  var classname$2 = function classname(n) {
1043
1076
  if (n === void 0) {
@@ -1712,7 +1745,7 @@ option) {
1712
1745
  return _ref3.apply(this, arguments);
1713
1746
  };
1714
1747
  }();
1715
- var debounceRefresh = React.useCallback(lodash.debounce(refresh, 500), [refresh]);
1748
+ var debounceRefresh = React.useCallback(debounce(refresh, 500), [refresh]);
1716
1749
  /* 重置逻辑 */
1717
1750
  var _deps = [].concat(deps || [], [isReady]);
1718
1751
  React.useEffect(function () {
@@ -2023,7 +2056,7 @@ option) {
2023
2056
  };
2024
2057
  }();
2025
2058
  // 防抖 加载下一页数据
2026
- var debounceRefresh = React.useCallback(lodash.debounce(_refresh, 500), [_refresh]);
2059
+ var debounceRefresh = React.useCallback(debounce(_refresh, 500), [_refresh]);
2027
2060
  /* 重置逻辑 */
2028
2061
  var _deps = [].concat(deps || [], [isReady]);
2029
2062
  React.useEffect(function () {
@@ -2077,12 +2110,14 @@ exports.PAGE_SIZE = PAGE_SIZE;
2077
2110
  exports.PatternType = PatternType;
2078
2111
  exports.VersionUtil = VersionUtil;
2079
2112
  exports.cmx = cmx;
2113
+ exports.debounce = debounce;
2080
2114
  exports.getClassName = getClassName;
2081
2115
  exports.getFieldsByPath = getFieldsByPath;
2082
2116
  exports.nextTick = nextTick;
2083
2117
  exports.noop = noop;
2084
2118
  exports.openModal = openModal;
2085
2119
  exports.removeNull = removeNull;
2120
+ exports.throttle = throttle;
2086
2121
  exports.useFuncRequest = useFuncRequest;
2087
2122
  exports.useInterval = useInterval;
2088
2123
  exports.useMiThemeConfig = useMiThemeConfig;