assui 3.2.41 → 3.2.43

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.
@@ -0,0 +1,9 @@
1
+ import type { ConditionSelectProps } from './types';
2
+ declare const ConditionSelect: ({
3
+ option,
4
+ value,
5
+ onChange,
6
+ selectProps,
7
+ selectName,
8
+ }: ConditionSelectProps) => JSX.Element;
9
+ export default ConditionSelect;
@@ -0,0 +1,163 @@
1
+ var __assign =
2
+ (this && this.__assign) ||
3
+ function () {
4
+ __assign =
5
+ Object.assign ||
6
+ function (t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) {
10
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
11
+ }
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __read =
18
+ (this && this.__read) ||
19
+ function (o, n) {
20
+ var m = typeof Symbol === 'function' && o[Symbol.iterator];
21
+ if (!m) return o;
22
+ var i = m.call(o),
23
+ r,
24
+ ar = [],
25
+ e;
26
+ try {
27
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
28
+ ar.push(r.value);
29
+ }
30
+ } catch (error) {
31
+ e = {
32
+ error: error,
33
+ };
34
+ } finally {
35
+ try {
36
+ if (r && !r.done && (m = i['return'])) m.call(i);
37
+ } finally {
38
+ if (e) throw e.error;
39
+ }
40
+ }
41
+ return ar;
42
+ };
43
+ import useControllableValue from 'ahooks/es/useControllableValue';
44
+ import Col from 'antd/es/grid/col';
45
+ import Row from 'antd/es/grid/row';
46
+ import Select from 'antd/es/select';
47
+ import omit from 'lodash/omit';
48
+ import React from 'react';
49
+ var ConditionSelect = function ConditionSelect(_a) {
50
+ var option = _a.option,
51
+ value = _a.value,
52
+ onChange = _a.onChange,
53
+ selectProps = _a.selectProps,
54
+ selectName = _a.selectName;
55
+ var _b = __read(
56
+ useControllableValue({
57
+ value: value,
58
+ onChange: onChange,
59
+ }),
60
+ 2,
61
+ ),
62
+ componentValue = _b[0],
63
+ setComponentValue = _b[1];
64
+ var current = React.useMemo(
65
+ function () {
66
+ if (!componentValue || !componentValue[selectName]) {
67
+ return null;
68
+ }
69
+ var result = option.find(function (item) {
70
+ return item.value === componentValue[selectName];
71
+ });
72
+ if (result) {
73
+ return result;
74
+ }
75
+ throw new Error('can not find this option');
76
+ },
77
+ [componentValue],
78
+ );
79
+ var DynamicComponent =
80
+ current === null || current === void 0 ? void 0 : current.component;
81
+ var componentProps = omit(
82
+ current === null || current === void 0 ? void 0 : current.componentProps,
83
+ 'parseValue',
84
+ );
85
+ var fieldProps =
86
+ current === null || current === void 0 ? void 0 : current.componentProps;
87
+ var handleTypeChange = function handleTypeChange(val) {
88
+ var _a;
89
+ setComponentValue(((_a = {}), (_a[selectName] = val), _a));
90
+ };
91
+ var handleInputChange = function handleInputChange(v) {
92
+ var _a;
93
+ setComponentValue(
94
+ __assign(
95
+ __assign({}, componentValue),
96
+ ((_a = {}), (_a[componentProps.name] = v), _a),
97
+ ),
98
+ );
99
+ };
100
+ var firstSpan = DynamicComponent ? 10 : 24;
101
+ return /*#__PURE__*/ React.createElement(
102
+ Row,
103
+ {
104
+ gutter: 10,
105
+ },
106
+ /*#__PURE__*/ React.createElement(
107
+ Col,
108
+ {
109
+ span: firstSpan,
110
+ },
111
+ /*#__PURE__*/ React.createElement(
112
+ Select,
113
+ __assign(
114
+ {
115
+ onChange: handleTypeChange,
116
+ value:
117
+ componentValue === null || componentValue === void 0
118
+ ? void 0
119
+ : componentValue[selectName],
120
+ allowClear: true,
121
+ },
122
+ selectProps,
123
+ ),
124
+ option.map(function (item) {
125
+ return /*#__PURE__*/ React.createElement(
126
+ Select.Option,
127
+ {
128
+ key: item.value,
129
+ value: item.value,
130
+ },
131
+ item.label,
132
+ );
133
+ }),
134
+ ),
135
+ ),
136
+ DynamicComponent &&
137
+ /*#__PURE__*/ React.createElement(
138
+ Col,
139
+ {
140
+ span: 14,
141
+ },
142
+ /*#__PURE__*/ React.createElement(
143
+ DynamicComponent,
144
+ __assign(__assign({}, componentProps), {
145
+ value: componentValue[componentProps.name],
146
+ onChange: function onChange(v) {
147
+ var parseValue =
148
+ fieldProps === null || fieldProps === void 0
149
+ ? void 0
150
+ : fieldProps.parseValue;
151
+ if (parseValue) {
152
+ var parseValueResult = parseValue(v);
153
+ handleInputChange(parseValueResult);
154
+ return;
155
+ }
156
+ handleInputChange(v);
157
+ },
158
+ }),
159
+ ),
160
+ ),
161
+ );
162
+ };
163
+ export default ConditionSelect;
@@ -0,0 +1,3 @@
1
+ import 'antd/lib/col/style';
2
+ import 'antd/lib/row/style';
3
+ import 'antd/lib/select/style';
@@ -0,0 +1,3 @@
1
+ import 'antd/es/col/style';
2
+ import 'antd/es/row/style';
3
+ import 'antd/es/select/style';
@@ -0,0 +1,23 @@
1
+ import type { SelectProps } from 'antd';
2
+ export type ValueType = Record<string, any>;
3
+ export type ComponentConfig<
4
+ C extends React.ComponentType<any> = React.ComponentType<any>,
5
+ > = {
6
+ component?: C;
7
+ componentProps?: React.ComponentProps<C> & {
8
+ parseValue?: (value: any) => any;
9
+ onChange: (value: any) => any;
10
+ };
11
+ };
12
+ export type DynamicComponentType = {
13
+ label: string | React.ReactNode;
14
+ value: any;
15
+ name: string;
16
+ } & ComponentConfig;
17
+ export type ConditionSelectProps = {
18
+ value?: ValueType;
19
+ onChange?: (value: ValueType) => void;
20
+ option: DynamicComponentType[];
21
+ selectName: string;
22
+ selectProps: SelectProps;
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ComponentConfig } from '../types';
2
+ export declare function getComponentConfig<C extends React.ComponentType<any>>(
3
+ component: C,
4
+ props: React.ComponentProps<C> & {
5
+ name?: string;
6
+ parseValue?: (v: any) => any;
7
+ },
8
+ ): ComponentConfig;
@@ -0,0 +1,6 @@
1
+ export function getComponentConfig(component, props) {
2
+ return {
3
+ component: component,
4
+ componentProps: props,
5
+ };
6
+ }
package/es/index.d.ts CHANGED
@@ -13,8 +13,10 @@ export { default as ComplexValSelect } from './complex-val-select';
13
13
  export type { ComplexValSelectProps } from './complex-val-select';
14
14
  export { default as ConditionInput } from './condition-input';
15
15
  export type { ConditionInputProps } from './condition-input';
16
+ export { default as ConditionSelect } from './condition-select';
16
17
  export { default as ConditionSelectInput } from './condition-select-input';
17
18
  export type { ConditionSelectInputProps } from './condition-select-input';
19
+ export type { ConditionSelectProps } from './condition-select/types';
18
20
  export { default as ConfigProvider } from './config-provider';
19
21
  export type { ConfigProviderProps } from './config-provider';
20
22
  export { default as CopyToClipboard } from './copy-to-clipboard';
package/es/index.js CHANGED
@@ -6,6 +6,7 @@ export { default as ButtonModal } from './button-modal';
6
6
  export { default as ColorSelect } from './color-select';
7
7
  export { default as ComplexValSelect } from './complex-val-select';
8
8
  export { default as ConditionInput } from './condition-input';
9
+ export { default as ConditionSelect } from './condition-select';
9
10
  export { default as ConditionSelectInput } from './condition-select-input';
10
11
  export { default as ConfigProvider } from './config-provider';
11
12
  export { default as CopyToClipboard } from './copy-to-clipboard';
@@ -0,0 +1,9 @@
1
+ import type { ConditionSelectProps } from './types';
2
+ declare const ConditionSelect: ({
3
+ option,
4
+ value,
5
+ onChange,
6
+ selectProps,
7
+ selectName,
8
+ }: ConditionSelectProps) => JSX.Element;
9
+ export default ConditionSelect;
@@ -0,0 +1,177 @@
1
+ 'use strict';
2
+
3
+ var __assign =
4
+ (this && this.__assign) ||
5
+ function () {
6
+ __assign =
7
+ Object.assign ||
8
+ function (t) {
9
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
10
+ s = arguments[i];
11
+ for (var p in s) {
12
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
13
+ }
14
+ }
15
+ return t;
16
+ };
17
+ return __assign.apply(this, arguments);
18
+ };
19
+ var __read =
20
+ (this && this.__read) ||
21
+ function (o, n) {
22
+ var m = typeof Symbol === 'function' && o[Symbol.iterator];
23
+ if (!m) return o;
24
+ var i = m.call(o),
25
+ r,
26
+ ar = [],
27
+ e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
30
+ ar.push(r.value);
31
+ }
32
+ } catch (error) {
33
+ e = {
34
+ error: error,
35
+ };
36
+ } finally {
37
+ try {
38
+ if (r && !r.done && (m = i['return'])) m.call(i);
39
+ } finally {
40
+ if (e) throw e.error;
41
+ }
42
+ }
43
+ return ar;
44
+ };
45
+ var __importDefault =
46
+ (this && this.__importDefault) ||
47
+ function (mod) {
48
+ return mod && mod.__esModule
49
+ ? mod
50
+ : {
51
+ default: mod,
52
+ };
53
+ };
54
+ Object.defineProperty(exports, '__esModule', {
55
+ value: true,
56
+ });
57
+ var useControllableValue_1 = __importDefault(require('ahooks/lib/useControllableValue'));
58
+ var col_1 = __importDefault(require('antd/lib/grid/col'));
59
+ var row_1 = __importDefault(require('antd/lib/grid/row'));
60
+ var select_1 = __importDefault(require('antd/lib/select'));
61
+ var omit_1 = __importDefault(require('lodash/omit'));
62
+ var react_1 = __importDefault(require('react'));
63
+ var ConditionSelect = function ConditionSelect(_a) {
64
+ var option = _a.option,
65
+ value = _a.value,
66
+ onChange = _a.onChange,
67
+ selectProps = _a.selectProps,
68
+ selectName = _a.selectName;
69
+ var _b = __read(
70
+ (0, useControllableValue_1['default'])({
71
+ value: value,
72
+ onChange: onChange,
73
+ }),
74
+ 2,
75
+ ),
76
+ componentValue = _b[0],
77
+ setComponentValue = _b[1];
78
+ var current = react_1['default'].useMemo(
79
+ function () {
80
+ if (!componentValue || !componentValue[selectName]) {
81
+ return null;
82
+ }
83
+ var result = option.find(function (item) {
84
+ return item.value === componentValue[selectName];
85
+ });
86
+ if (result) {
87
+ return result;
88
+ }
89
+ throw new Error('can not find this option');
90
+ },
91
+ [componentValue],
92
+ );
93
+ var DynamicComponent =
94
+ current === null || current === void 0 ? void 0 : current.component;
95
+ var componentProps = (0, omit_1['default'])(
96
+ current === null || current === void 0 ? void 0 : current.componentProps,
97
+ 'parseValue',
98
+ );
99
+ var fieldProps =
100
+ current === null || current === void 0 ? void 0 : current.componentProps;
101
+ var handleTypeChange = function handleTypeChange(val) {
102
+ var _a;
103
+ setComponentValue(((_a = {}), (_a[selectName] = val), _a));
104
+ };
105
+ var handleInputChange = function handleInputChange(v) {
106
+ var _a;
107
+ setComponentValue(
108
+ __assign(
109
+ __assign({}, componentValue),
110
+ ((_a = {}), (_a[componentProps.name] = v), _a),
111
+ ),
112
+ );
113
+ };
114
+ var firstSpan = DynamicComponent ? 10 : 24;
115
+ return react_1['default'].createElement(
116
+ row_1['default'],
117
+ {
118
+ gutter: 10,
119
+ },
120
+ react_1['default'].createElement(
121
+ col_1['default'],
122
+ {
123
+ span: firstSpan,
124
+ },
125
+ react_1['default'].createElement(
126
+ select_1['default'],
127
+ __assign(
128
+ {
129
+ onChange: handleTypeChange,
130
+ value:
131
+ componentValue === null || componentValue === void 0
132
+ ? void 0
133
+ : componentValue[selectName],
134
+ allowClear: true,
135
+ },
136
+ selectProps,
137
+ ),
138
+ option.map(function (item) {
139
+ return react_1['default'].createElement(
140
+ select_1['default'].Option,
141
+ {
142
+ key: item.value,
143
+ value: item.value,
144
+ },
145
+ item.label,
146
+ );
147
+ }),
148
+ ),
149
+ ),
150
+ DynamicComponent &&
151
+ react_1['default'].createElement(
152
+ col_1['default'],
153
+ {
154
+ span: 14,
155
+ },
156
+ react_1['default'].createElement(
157
+ DynamicComponent,
158
+ __assign(__assign({}, componentProps), {
159
+ value: componentValue[componentProps.name],
160
+ onChange: function onChange(v) {
161
+ var parseValue =
162
+ fieldProps === null || fieldProps === void 0
163
+ ? void 0
164
+ : fieldProps.parseValue;
165
+ if (parseValue) {
166
+ var parseValueResult = parseValue(v);
167
+ handleInputChange(parseValueResult);
168
+ return;
169
+ }
170
+ handleInputChange(v);
171
+ },
172
+ }),
173
+ ),
174
+ ),
175
+ );
176
+ };
177
+ exports['default'] = ConditionSelect;
@@ -0,0 +1,3 @@
1
+ import 'antd/lib/col/style';
2
+ import 'antd/lib/row/style';
3
+ import 'antd/lib/select/style';
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true,
5
+ });
6
+ require('antd/lib/col/style');
7
+ require('antd/lib/row/style');
8
+ require('antd/lib/select/style');
@@ -0,0 +1,23 @@
1
+ import type { SelectProps } from 'antd';
2
+ export type ValueType = Record<string, any>;
3
+ export type ComponentConfig<
4
+ C extends React.ComponentType<any> = React.ComponentType<any>,
5
+ > = {
6
+ component?: C;
7
+ componentProps?: React.ComponentProps<C> & {
8
+ parseValue?: (value: any) => any;
9
+ onChange: (value: any) => any;
10
+ };
11
+ };
12
+ export type DynamicComponentType = {
13
+ label: string | React.ReactNode;
14
+ value: any;
15
+ name: string;
16
+ } & ComponentConfig;
17
+ export type ConditionSelectProps = {
18
+ value?: ValueType;
19
+ onChange?: (value: ValueType) => void;
20
+ option: DynamicComponentType[];
21
+ selectName: string;
22
+ selectProps: SelectProps;
23
+ };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true,
5
+ });
@@ -0,0 +1,8 @@
1
+ import type { ComponentConfig } from '../types';
2
+ export declare function getComponentConfig<C extends React.ComponentType<any>>(
3
+ component: C,
4
+ props: React.ComponentProps<C> & {
5
+ name?: string;
6
+ parseValue?: (v: any) => any;
7
+ },
8
+ ): ComponentConfig;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true,
5
+ });
6
+ exports.getComponentConfig = getComponentConfig;
7
+ function getComponentConfig(component, props) {
8
+ return {
9
+ component: component,
10
+ componentProps: props,
11
+ };
12
+ }
package/lib/index.d.ts CHANGED
@@ -13,8 +13,10 @@ export { default as ComplexValSelect } from './complex-val-select';
13
13
  export type { ComplexValSelectProps } from './complex-val-select';
14
14
  export { default as ConditionInput } from './condition-input';
15
15
  export type { ConditionInputProps } from './condition-input';
16
+ export { default as ConditionSelect } from './condition-select';
16
17
  export { default as ConditionSelectInput } from './condition-select-input';
17
18
  export type { ConditionSelectInputProps } from './condition-select-input';
19
+ export type { ConditionSelectProps } from './condition-select/types';
18
20
  export { default as ConfigProvider } from './config-provider';
19
21
  export type { ConfigProviderProps } from './config-provider';
20
22
  export { default as CopyToClipboard } from './copy-to-clipboard';
package/lib/index.js CHANGED
@@ -12,15 +12,16 @@ var __importDefault =
12
12
  Object.defineProperty(exports, '__esModule', {
13
13
  value: true,
14
14
  });
15
- exports.CountDown =
15
+ exports.ConditionSelect =
16
16
  exports.CountUp =
17
+ exports.CountDown =
17
18
  exports.ComplexValSelect =
18
19
  exports.MultipartUpload =
19
20
  exports.LabelConditionSelectInput =
20
21
  exports.Flex =
21
22
  exports.Resizable =
22
- exports.BeautifulDnd =
23
23
  exports.RichTextEditor =
24
+ exports.BeautifulDnd =
24
25
  exports.LabelCustomizeRangePicker =
25
26
  exports.TableCol =
26
27
  exports.LabelTreeSelect =
@@ -326,18 +327,18 @@ Object.defineProperty(exports, 'LabelCustomizeRangePicker', {
326
327
  return __importDefault(label_customize_range_picker_1)['default'];
327
328
  },
328
329
  });
329
- var rich_text_editor_1 = require('./rich-text-editor');
330
- Object.defineProperty(exports, 'RichTextEditor', {
330
+ var beautiful_dnd_1 = require('./beautiful-dnd');
331
+ Object.defineProperty(exports, 'BeautifulDnd', {
331
332
  enumerable: true,
332
333
  get: function get() {
333
- return __importDefault(rich_text_editor_1)['default'];
334
+ return __importDefault(beautiful_dnd_1)['default'];
334
335
  },
335
336
  });
336
- var beautiful_dnd_1 = require('./beautiful-dnd');
337
- Object.defineProperty(exports, 'BeautifulDnd', {
337
+ var rich_text_editor_1 = require('./rich-text-editor');
338
+ Object.defineProperty(exports, 'RichTextEditor', {
338
339
  enumerable: true,
339
340
  get: function get() {
340
- return __importDefault(beautiful_dnd_1)['default'];
341
+ return __importDefault(rich_text_editor_1)['default'];
341
342
  },
342
343
  });
343
344
  var resizable_1 = require('./resizable');
@@ -375,6 +376,13 @@ Object.defineProperty(exports, 'ComplexValSelect', {
375
376
  return __importDefault(complex_val_select_1)['default'];
376
377
  },
377
378
  });
379
+ var count_down_1 = require('./count-down');
380
+ Object.defineProperty(exports, 'CountDown', {
381
+ enumerable: true,
382
+ get: function get() {
383
+ return __importDefault(count_down_1)['default'];
384
+ },
385
+ });
378
386
  var count_up_1 = require('./count-up');
379
387
  Object.defineProperty(exports, 'CountUp', {
380
388
  enumerable: true,
@@ -382,10 +390,10 @@ Object.defineProperty(exports, 'CountUp', {
382
390
  return __importDefault(count_up_1)['default'];
383
391
  },
384
392
  });
385
- var count_down_1 = require('./count-down');
386
- Object.defineProperty(exports, 'CountDown', {
393
+ var condition_select_1 = require('./condition-select');
394
+ Object.defineProperty(exports, 'ConditionSelect', {
387
395
  enumerable: true,
388
396
  get: function get() {
389
- return __importDefault(count_down_1)['default'];
397
+ return __importDefault(condition_select_1)['default'];
390
398
  },
391
399
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "3.2.41",
3
+ "version": "3.2.43",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "@types/react-beautiful-dnd": "^13.1.2",
36
36
  "@types/react-color": "^3.0.6",
37
37
  "@types/react-resizable": "^3.0.0",
38
- "a-icons": "^1.2.34",
38
+ "a-icons": "^1.2.35",
39
39
  "aa-utils": "^2.1.30",
40
40
  "ahooks": "^3.0.8",
41
41
  "bignumber.js": "^9.0.1",
@@ -82,5 +82,5 @@
82
82
  "node": ">=10.0.0"
83
83
  },
84
84
  "license": "MIT",
85
- "gitHead": "02eb2b0598ff197ce64db430ef7d7ffce601f366"
85
+ "gitHead": "2f50b0af7f3269388a574ad8f7924da3a3b892db"
86
86
  }