@arim-aisdc/public-components 2.0.3 → 2.0.4

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.
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
17
17
  value: any;
18
18
  field: string;
19
19
  label?: string;
20
- text: string | JSX.Element | Element;
20
+ text: string | Element | JSX.Element;
21
21
  units?: string;
22
22
  width?: string;
23
23
  labelWidth?: string;
@@ -1,3 +1,7 @@
1
- import ColorSelector from './ColorSelector';
2
- export type { ColorSelectorProps } from './ColorSelector';
1
+ import { ColorPickerProps } from 'antd';
2
+ import React from 'react';
3
+ interface ColorSelectorProps {
4
+ onChange?: (value: string) => void;
5
+ }
6
+ declare const ColorSelector: React.FC<ColorPickerProps & ColorSelectorProps>;
3
7
  export default ColorSelector;
@@ -1,2 +1,24 @@
1
- import ColorSelector from "./ColorSelector";
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
+ var _excluded = ["onChange"];
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 _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; }
9
+ 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; }
10
+ import { ColorPicker } from 'antd';
11
+ import { debounce } from 'lodash';
12
+ import React, { useCallback } from 'react';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ var ColorSelector = function ColorSelector(props) {
15
+ var onChange = props.onChange,
16
+ rest = _objectWithoutProperties(props, _excluded);
17
+ var debounceChange = useCallback(debounce(function (_, hex) {
18
+ onChange(hex);
19
+ }, 200), [onChange]);
20
+ return /*#__PURE__*/_jsx(ColorPicker, _objectSpread(_objectSpread({}, rest), {}, {
21
+ onChange: debounceChange
22
+ }));
23
+ };
2
24
  export default ColorSelector;
@@ -612,6 +612,9 @@ var CustomForm = function CustomForm(_ref) {
612
612
  labelAlign: labelAlign,
613
613
  autoComplete: "off",
614
614
  onFinish: onFinish,
615
+ onValuesChange: function onValuesChange(p) {
616
+ return console.log('p :>> ', p);
617
+ },
615
618
  children: /*#__PURE__*/_jsxs(Row, {
616
619
  gutter: {
617
620
  md: 8,
@@ -46,8 +46,9 @@ var QueryFilter = function QueryFilter(_ref) {
46
46
  _ref$submitLoading = _ref.submitLoading,
47
47
  submitLoading = _ref$submitLoading === void 0 ? false : _ref$submitLoading,
48
48
  _ref$renderButton = _ref.renderButton,
49
- renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton;
50
- var _Form$useForm = Form.useForm(),
49
+ renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton,
50
+ initForm = _ref.initForm;
51
+ var _Form$useForm = Form.useForm(initForm),
51
52
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
52
53
  form = _Form$useForm2[0];
53
54
  var Option = Select.Option;
@@ -59,10 +60,6 @@ var QueryFilter = function QueryFilter(_ref) {
59
60
  var displayRender = function displayRender(labels) {
60
61
  return labels[labels.length - 1];
61
62
  };
62
- var _useState3 = useState(false),
63
- _useState4 = _slicedToArray(_useState3, 2),
64
- isCancel = _useState4[0],
65
- setIsCancel = _useState4[1];
66
63
  // 处理初始值格式问题,主要是日期数据的格式,字符串处理为date格式
67
64
  var getHandledInitValues = function getHandledInitValues() {
68
65
  var newFormValues = {};
@@ -83,31 +80,29 @@ var QueryFilter = function QueryFilter(_ref) {
83
80
  return newValues;
84
81
  };
85
82
 
83
+ // const handledInitValues = getHandledInitValues()
84
+ var _useState3 = useState(getHandledInitValues()),
85
+ _useState4 = _slicedToArray(_useState3, 2),
86
+ formInitValue = _useState4[0],
87
+ setHandledInitValues = _useState4[1];
88
+ useEffect(function () {
89
+ setHandledInitValues(getHandledInitValues());
90
+ }, []);
91
+
86
92
  /**初始化表单 */
87
93
  var FormRef = useRef(null);
88
- useEffect(function () {
89
- // 修改 重置时set初始值
90
- if (isCancel) {
91
- var handledInitValues = getHandledInitValues();
92
- if (FormRef && FormRef.current) {
93
- FormRef.current.setFieldsValue(handledInitValues);
94
- }
95
- setFormValues(handledInitValues);
96
- setIsCancel(false);
97
- }
98
- }, [isCancel, initialValues]);
99
94
  useEffect(function () {
100
95
  /**回显异步初始值 */
101
96
  // FormRef && FormRef.current && FormRef.current.resetFields();
102
97
  var handledInitValues = getHandledInitValues();
103
- if (FormRef && FormRef.current) {
104
- FormRef.current.setFieldsValue(handledInitValues);
105
- }
98
+ // if (FormRef && FormRef.current) {
99
+ // FormRef.current.setFieldsValue(handledInitValues);
100
+ // }
106
101
  // console.log('handledInitValues :>> ', handledInitValues);
107
102
 
108
103
  // 更新表单数据
109
104
  setFormValues(handledInitValues);
110
- }, []);
105
+ }, [initialValues]);
111
106
 
112
107
  // 表单提交时保留数据
113
108
  var onFinish = function onFinish(values) {
@@ -154,7 +149,7 @@ var QueryFilter = function QueryFilter(_ref) {
154
149
  var _useDebounceFn = useDebounceFn(function (e, item, valueType) {
155
150
  commonChange(e, item, valueType);
156
151
  }, {
157
- wait: 500
152
+ wait: 200
158
153
  }),
159
154
  run = _useDebounceFn.run;
160
155
  var getElement = function getElement(item) {
@@ -219,7 +214,7 @@ var QueryFilter = function QueryFilter(_ref) {
219
214
  onSearch: item.showSearch ? debounce(function (value) {
220
215
  var _item$handleSearch;
221
216
  return (_item$handleSearch = item.handleSearch) === null || _item$handleSearch === void 0 ? void 0 : _item$handleSearch.call(item, value);
222
- }, 500) : undefined,
217
+ }, 200) : undefined,
223
218
  onChange: function onChange(e) {
224
219
  commonChange(e, item);
225
220
  },
@@ -234,7 +229,7 @@ var QueryFilter = function QueryFilter(_ref) {
234
229
  onSelect: item.showSelect ? debounce(function (value) {
235
230
  var _item$handleSelect;
236
231
  return (_item$handleSelect = item.handleSelect) === null || _item$handleSelect === void 0 ? void 0 : _item$handleSelect.call(item, value);
237
- }, 500) : undefined,
232
+ }, 200) : undefined,
238
233
  notFoundContent: ((_item$setting = item.setting) === null || _item$setting === void 0 ? void 0 : _item$setting.length) >= 0 ? null : /*#__PURE__*/_jsx(Spin, {
239
234
  size: "small"
240
235
  }),
@@ -280,7 +275,7 @@ var QueryFilter = function QueryFilter(_ref) {
280
275
  onSearch: debounce(function (value) {
281
276
  var _item$handleSearch3;
282
277
  return (_item$handleSearch3 = item.handleSearch) === null || _item$handleSearch3 === void 0 ? void 0 : _item$handleSearch3.call(item, value, item.isInitGetOptions);
283
- }, 500),
278
+ }, 200),
284
279
  onFocus: function onFocus() {
285
280
  var _item$handleSearch4;
286
281
  return (_item$handleSearch4 = item.handleSearch) === null || _item$handleSearch4 === void 0 ? void 0 : _item$handleSearch4.call(item, '', item.isInitGetOptions);
@@ -462,7 +457,7 @@ var QueryFilter = function QueryFilter(_ref) {
462
457
  onSearch: item.showSearch ? debounce(function (value) {
463
458
  var _item$handleSearch5;
464
459
  return (_item$handleSearch5 = item.handleSearch) === null || _item$handleSearch5 === void 0 ? void 0 : _item$handleSearch5.call(item, value);
465
- }, 500) : undefined,
460
+ }, 200) : undefined,
466
461
  onChange: function onChange(e) {
467
462
  run(e, item, typeList.start);
468
463
  },
@@ -473,7 +468,7 @@ var QueryFilter = function QueryFilter(_ref) {
473
468
  onSelect: item.showSelect ? debounce(function (value) {
474
469
  var _item$handleSelect2;
475
470
  return (_item$handleSelect2 = item.handleSelect) === null || _item$handleSelect2 === void 0 ? void 0 : _item$handleSelect2.call(item, value);
476
- }, 500) : undefined,
471
+ }, 200) : undefined,
477
472
  notFoundContent: ((_item$setting2 = item.setting) === null || _item$setting2 === void 0 ? void 0 : _item$setting2.length) >= 0 ? null : /*#__PURE__*/_jsx(Spin, {
478
473
  size: "small"
479
474
  }),
@@ -509,7 +504,7 @@ var QueryFilter = function QueryFilter(_ref) {
509
504
  onSearch: item.showSearch ? debounce(function (value) {
510
505
  var _item$handleSearch6;
511
506
  return (_item$handleSearch6 = item.handleSearch) === null || _item$handleSearch6 === void 0 ? void 0 : _item$handleSearch6.call(item, value);
512
- }, 500) : undefined,
507
+ }, 200) : undefined,
513
508
  onChange: function onChange(e) {
514
509
  run(e, item, typeList.end);
515
510
  },
@@ -520,7 +515,7 @@ var QueryFilter = function QueryFilter(_ref) {
520
515
  onSelect: item.showSelect ? debounce(function (value) {
521
516
  var _item$handleSelect3;
522
517
  return (_item$handleSelect3 = item.handleSelect) === null || _item$handleSelect3 === void 0 ? void 0 : _item$handleSelect3.call(item, value);
523
- }, 500) : undefined,
518
+ }, 200) : undefined,
524
519
  notFoundContent: ((_item$setting3 = item.setting) === null || _item$setting3 === void 0 ? void 0 : _item$setting3.length) >= 0 ? null : /*#__PURE__*/_jsx(Spin, {
525
520
  size: "small"
526
521
  }),
@@ -581,8 +576,8 @@ var QueryFilter = function QueryFilter(_ref) {
581
576
  ref: FormRef,
582
577
  form: form
583
578
  // name={styles.customForm}
584
- // initialValues={initialValues}
585
579
  ,
580
+ initialValues: formInitValue,
586
581
  labelAlign: "left",
587
582
  autoComplete: "off",
588
583
  onFinish: onFinish,
@@ -622,9 +617,8 @@ var QueryFilter = function QueryFilter(_ref) {
622
617
  children: [/*#__PURE__*/_jsx(Button, {
623
618
  className: "xmTtn xmTtnDefault",
624
619
  onClick: function onClick(e) {
625
- handleCancel(e);
626
620
  form.resetFields();
627
- setIsCancel(true);
621
+ handleCancel(e);
628
622
  // 重置后 再次筛选 会带有上一次的记录(修改)
629
623
  setFormValues({});
630
624
  },
@@ -1,4 +1,5 @@
1
1
  import { FormProps } from 'antd';
2
+ import { FormInstance } from 'antd/es/form';
2
3
  import { MouseEventHandler } from 'react';
3
4
  export declare enum FormItemType {
4
5
  Text = "text",
@@ -114,4 +115,5 @@ export interface QueryFilterProps {
114
115
  submitLoading?: boolean;
115
116
  buttonRender?: any;
116
117
  renderButton?: any;
118
+ initForm?: FormInstance;
117
119
  }
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
package/dist/index.d.ts CHANGED
@@ -27,8 +27,6 @@ export { default as TableMax } from './components/TableMax';
27
27
  export * from './components/ConfigProvider';
28
28
  export * from './components/Filter';
29
29
  export { default as SchemaForm } from './components/SchemaForm';
30
- export * from './components/ColorSelector';
31
- export { default as ColorSelector } from './components/ColorSelector';
32
30
  export * from './hooks/useEventBus';
33
31
  export { default as useEventBus } from './hooks/useEventBus';
34
32
  export { default as usePageCacheState } from './hooks/usePageCacheState';
package/dist/index.js CHANGED
@@ -28,8 +28,6 @@ export { default as TableMax } from "./components/TableMax";
28
28
  export * from "./components/ConfigProvider";
29
29
  export * from "./components/Filter";
30
30
  export { default as SchemaForm } from "./components/SchemaForm";
31
- export * from "./components/ColorSelector";
32
- export { default as ColorSelector } from "./components/ColorSelector";
33
31
 
34
32
  // hooks
35
33
  export * from "./hooks/useEventBus";
package/package.json CHANGED
@@ -1,104 +1,102 @@
1
- {
2
- "name": "@arim-aisdc/public-components",
3
- "version": "2.0.3",
4
- "description": "前端组件库",
5
- "license": "MIT",
6
- "main": "dist/index.js",
7
- "module": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "files": [
10
- "dist"
11
- ],
12
- "scripts": {
13
- "build": "father build",
14
- "build:watch": "father dev",
15
- "dev": "dumi dev",
16
- "docs:build": "dumi build",
17
- "doctor": "father doctor",
18
- "lint": "npm run lint:es && npm run lint:css",
19
- "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
20
- "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
21
- "local": "dumi dev",
22
- "prepare": "husky install && dumi setup",
23
- "prepublishOnly": "father doctor && npm run build",
24
- "start": "npm run dev"
25
- },
26
- "commitlint": {
27
- "extends": [
28
- "@commitlint/config-conventional"
29
- ]
30
- },
31
- "lint-staged": {
32
- "*.{md,json}": [
33
- "prettier --write --no-error-on-unmatched-pattern"
34
- ],
35
- "*.{css,less}": [
36
- "stylelint --fix",
37
- "prettier --write"
38
- ],
39
- "*.{js,jsx}": [
40
- "eslint --fix",
41
- "prettier --write"
42
- ],
43
- "*.{ts,tsx}": [
44
- "eslint --fix",
45
- "prettier --parser=typescript --write"
46
- ]
47
- },
48
- "dependencies": {
49
- "@ant-design/icons": "^5.3.7",
50
- "@ant-design/pro-components": "^2.7.10",
51
- "@tanstack/match-sorter-utils": "^8.8.4",
52
- "@tanstack/react-table": "^8.9.1",
53
- "ahooks": "^3.7.8",
54
- "antd": "^5.18.3",
55
- "classnames": "^2.5.1",
56
- "css-vars-ponyfill": "^2.4.8",
57
- "dayjs": "^1.11.11",
58
- "fs": "^0.0.1-security",
59
- "immer": "^10.0.3",
60
- "jsep": "^1.3.8",
61
- "lodash": "^4.17.21",
62
- "path": "^0.12.7",
63
- "react-color": "^2.19.3",
64
- "react-dnd": "^16.0.1",
65
- "react-dnd-html5-backend": "^16.0.1",
66
- "react-draggable": "^4.4.6",
67
- "react-router-dom": "^6.22.3",
68
- "react-split-pane": "^0.1.92",
69
- "umi-request": "^1.4.0"
70
- },
71
- "devDependencies": {
72
- "@commitlint/cli": "^17.1.2",
73
- "@commitlint/config-conventional": "^17.1.0",
74
- "@types/react": "^18.0.0",
75
- "@types/react-dom": "^18.0.0",
76
- "@umijs/lint": "^4.0.0",
77
- "babel-plugin-import": "^1.13.8",
78
- "dumi": "^2.2.13",
79
- "eslint": "^8.23.0",
80
- "father": "^4.1.0",
81
- "husky": "^8.0.1",
82
- "less": "^4.1.3",
83
- "less-loader": "^11.1.0",
84
- "less-vars-to-js": "^1.3.0",
85
- "lint-staged": "^13.0.3",
86
- "mockjs": "^1.1.0",
87
- "prettier": "^2.7.1",
88
- "prettier-plugin-organize-imports": "^3.0.0",
89
- "prettier-plugin-packagejson": "^2.2.18",
90
- "stylelint": "^14.9.1"
91
- },
92
- "peerDependencies": {
93
- "antd": "^5.18.3",
94
- "react": ">=17.0.1",
95
- "react-dom": ">=17.0.1",
96
- "umi-request": "^1.4.0"
97
- },
98
- "publishConfig": {
99
- "access": "public"
100
- },
101
- "authors": [
102
- "na.xu2278@foxmail.com"
103
- ]
104
- }
1
+ {
2
+ "name": "@arim-aisdc/public-components",
3
+ "version": "2.0.4",
4
+ "description": "前端组件库",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "father build",
14
+ "build:watch": "father dev",
15
+ "dev": "dumi dev",
16
+ "docs:build": "dumi build",
17
+ "doctor": "father doctor",
18
+ "lint": "npm run lint:es && npm run lint:css",
19
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
20
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
21
+ "local": "dumi dev",
22
+ "prepare": "husky install && dumi setup",
23
+ "prepublishOnly": "father doctor && npm run build",
24
+ "start": "npm run dev"
25
+ },
26
+ "commitlint": {
27
+ "extends": [
28
+ "@commitlint/config-conventional"
29
+ ]
30
+ },
31
+ "lint-staged": {
32
+ "*.{md,json}": [
33
+ "prettier --write --no-error-on-unmatched-pattern"
34
+ ],
35
+ "*.{css,less}": [
36
+ "stylelint --fix",
37
+ "prettier --write"
38
+ ],
39
+ "*.{js,jsx}": [
40
+ "eslint --fix",
41
+ "prettier --write"
42
+ ],
43
+ "*.{ts,tsx}": [
44
+ "eslint --fix",
45
+ "prettier --parser=typescript --write"
46
+ ]
47
+ },
48
+ "dependencies": {
49
+ "@ant-design/icons": "^5.3.7",
50
+ "@ant-design/pro-components": "^2.7.10",
51
+ "@tanstack/match-sorter-utils": "^8.8.4",
52
+ "@tanstack/react-table": "^8.9.1",
53
+ "ahooks": "^3.7.8",
54
+ "classnames": "^2.5.1",
55
+ "css-vars-ponyfill": "^2.4.8",
56
+ "dayjs": "^1.11.11",
57
+ "fs": "^0.0.1-security",
58
+ "immer": "^10.0.3",
59
+ "jsep": "^1.3.8",
60
+ "lodash": "^4.17.21",
61
+ "path": "^0.12.7",
62
+ "react-color": "^2.19.3",
63
+ "react-dnd": "^16.0.1",
64
+ "react-dnd-html5-backend": "^16.0.1",
65
+ "react-draggable": "^4.4.6",
66
+ "react-router-dom": "^6.22.3",
67
+ "react-split-pane": "^0.1.92"
68
+ },
69
+ "devDependencies": {
70
+ "@commitlint/cli": "^17.1.2",
71
+ "@commitlint/config-conventional": "^17.1.0",
72
+ "@types/react": "^18.0.0",
73
+ "@types/react-dom": "^18.0.0",
74
+ "@umijs/lint": "^4.0.0",
75
+ "babel-plugin-import": "^1.13.8",
76
+ "dumi": "^2.2.13",
77
+ "eslint": "^8.23.0",
78
+ "father": "^4.1.0",
79
+ "husky": "^8.0.1",
80
+ "less": "^4.1.3",
81
+ "less-loader": "^11.1.0",
82
+ "less-vars-to-js": "^1.3.0",
83
+ "lint-staged": "^13.0.3",
84
+ "mockjs": "^1.1.0",
85
+ "prettier": "^2.7.1",
86
+ "prettier-plugin-organize-imports": "^3.0.0",
87
+ "prettier-plugin-packagejson": "^2.2.18",
88
+ "stylelint": "^14.9.1"
89
+ },
90
+ "peerDependencies": {
91
+ "antd": "^5.18.3",
92
+ "react": ">=17.0.1",
93
+ "react-dom": ">=17.0.1",
94
+ "umi-request": "^1.4.0"
95
+ },
96
+ "publishConfig": {
97
+ "access": "public"
98
+ },
99
+ "authors": [
100
+ "na.xu2278@foxmail.com"
101
+ ]
102
+ }
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import './ColorSelector.less';
3
- export interface ColorSelectorProps {
4
- /**
5
- * 默认颜色值
6
- */
7
- defaultValue?: string;
8
- /**
9
- * 颜色值
10
- */
11
- value?: string;
12
- /**
13
- * 修改时的回调函数
14
- * @param color 修改后的颜色
15
- * @returns
16
- */
17
- onChange?: (color: string) => void;
18
- /**
19
- * onChange函数是否启用节流,默认启用
20
- * @default true
21
- */
22
- isDebounceChange?: boolean;
23
- /**
24
- * 快捷选择区颜色列表,空数组时不展示快捷选择区
25
- */
26
- presetColors?: string[];
27
- }
28
- declare const ColorSelector: React.FC<ColorSelectorProps>;
29
- export default ColorSelector;
@@ -1,66 +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
- import { Popover } from 'antd';
8
- import { debounce } from 'lodash';
9
- import React, { useCallback, useEffect, useState } from 'react';
10
- import { SketchPicker } from 'react-color';
11
- import "./ColorSelector.less";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- var defaultPresentColors = ['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF'];
14
- var ColorSelector = function ColorSelector(props) {
15
- var value = props.value,
16
- defaultValue = props.defaultValue,
17
- onChange = props.onChange,
18
- _props$isDebounceChan = props.isDebounceChange,
19
- isDebounceChange = _props$isDebounceChan === void 0 ? true : _props$isDebounceChan,
20
- _props$presetColors = props.presetColors,
21
- presetColors = _props$presetColors === void 0 ? defaultPresentColors : _props$presetColors;
22
- var _useState = useState(value || defaultValue || '#ffffff'),
23
- _useState2 = _slicedToArray(_useState, 2),
24
- color = _useState2[0],
25
- setColor = _useState2[1];
26
- useEffect(function () {
27
- if (value && color !== value) {
28
- setColor(value);
29
- }
30
- }, [value]);
31
- var debounceChange = useCallback(debounce(function (newValue) {
32
- onChange(newValue);
33
- }, 500), [onChange]);
34
- var handleChange = useCallback(function (color) {
35
- // console.log('color :>> ', color);
36
- var hex = color.hex || '';
37
- var hexUpperCase = hex.toLocaleUpperCase();
38
- setColor(hexUpperCase);
39
- if (isDebounceChange) {
40
- debounceChange(hexUpperCase);
41
- } else {
42
- onChange(hexUpperCase);
43
- }
44
- }, [debounceChange]);
45
- return /*#__PURE__*/_jsx(Popover, {
46
- content: /*#__PURE__*/_jsx(SketchPicker, {
47
- color: color,
48
- disableAlpha: true,
49
- onChange: handleChange,
50
- width: 220,
51
- presetColors: presetColors
52
- }),
53
- title: null,
54
- overlayClassName: "colorSelectorPopover",
55
- children: /*#__PURE__*/_jsx("div", {
56
- className: 'colorSelectorContent',
57
- children: /*#__PURE__*/_jsx("div", {
58
- className: 'colorBox',
59
- style: {
60
- backgroundColor: color
61
- }
62
- })
63
- })
64
- });
65
- };
66
- export default ColorSelector;
@@ -1,39 +0,0 @@
1
- .colorSelectorContent {
2
- width: 100%;
3
- height: 32px;
4
- padding: 4px;
5
- background: @global-curd-input-background-color;
6
- display: flex;
7
- justify-content: space-between;
8
- align-items: center;
9
- cursor: pointer;
10
-
11
- .colorBox {
12
- width: 100%;
13
- height: 100%;
14
- }
15
- }
16
-
17
- .colorSelectorPopover {
18
- .custom-light-popover-inner-content,
19
- .custom-dark-popover-inner-content,
20
- .ant-popover-inner-content {
21
- padding: 0;
22
- }
23
-
24
- .sketch-picker {
25
- background: transparent !important;
26
-
27
- input {
28
- background-color: @global-curd-input-background-color;
29
- border: 1px solid @tableColor2 !important;
30
- box-shadow: none;
31
- border-radius: 2px;
32
- color: @tableColor1 !important;
33
- }
34
-
35
- label {
36
- color: @tableColor1 !important;
37
- }
38
- }
39
- }