@aloudata/aloudata-design 0.3.2 → 0.3.3

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 (89) hide show
  1. package/es/Button/index.js +3 -2
  2. package/es/Button/style/index.less +135 -126
  3. package/es/Button/style/variables.less +53 -53
  4. package/es/Dropdown/Button.js +3 -2
  5. package/es/Icon/icons.json +410 -0
  6. package/es/Input/components/Group/index.d.ts +2 -1
  7. package/es/Input/components/Group/index.js +6 -12
  8. package/es/Input/components/Input/index.d.ts +3 -2
  9. package/es/Input/components/Input/index.js +11 -22
  10. package/es/Input/components/Password/index.js +11 -16
  11. package/es/Input/style/index.less +102 -102
  12. package/es/InputNumber/style/index.less +69 -69
  13. package/es/Modal/index.js +4 -7
  14. package/es/Modal/style/index.less +45 -45
  15. package/es/PageHeader/index.d.ts +3 -0
  16. package/es/PageHeader/index.js +3 -0
  17. package/es/PageHeader/style/index.d.ts +2 -0
  18. package/es/PageHeader/style/index.js +2 -0
  19. package/es/PageHeader/style/index.less +1 -0
  20. package/es/Select/rc-select/OptionList.js +3 -2
  21. package/es/Select/rc-select/hooks/useOptions.d.ts +1 -1
  22. package/es/Select/style/index.less +49 -49
  23. package/es/Select/style/variables.less +45 -45
  24. package/es/Select/utils/iconUtil.d.ts +2 -2
  25. package/es/Select/utils/iconUtil.js +6 -4
  26. package/es/Steps/components/ProcessIcon/index.d.ts +5 -0
  27. package/es/Steps/components/ProcessIcon/index.js +8 -0
  28. package/es/Steps/components/Step/index.d.ts +20 -0
  29. package/es/Steps/components/Step/index.js +45 -0
  30. package/es/Steps/index.d.ts +36 -2
  31. package/es/Steps/index.js +30 -1
  32. package/es/Steps/matchMedia.mock.d.ts +1 -0
  33. package/es/Steps/matchMedia.mock.js +17 -0
  34. package/es/Steps/style/index.less +251 -0
  35. package/es/Switch/index.d.ts +46 -2
  36. package/es/Switch/index.js +71 -1
  37. package/es/Switch/style/index.less +129 -0
  38. package/es/Table/style/index.less +1 -1
  39. package/es/Tabs/index.js +3 -2
  40. package/es/Tabs/style/index.less +25 -25
  41. package/es/index.d.ts +6 -4
  42. package/es/index.js +2 -1
  43. package/es/style/index.less +1 -1
  44. package/es/style/themes/default/index.less +30 -30
  45. package/lib/Button/index.js +5 -3
  46. package/lib/Button/style/index.less +135 -126
  47. package/lib/Button/style/variables.less +53 -53
  48. package/lib/Dropdown/Button.js +7 -5
  49. package/lib/Icon/icons.json +410 -0
  50. package/lib/Input/components/Group/index.d.ts +2 -1
  51. package/lib/Input/components/Group/index.js +7 -12
  52. package/lib/Input/components/Input/index.d.ts +3 -2
  53. package/lib/Input/components/Input/index.js +13 -22
  54. package/lib/Input/components/Password/index.js +13 -17
  55. package/lib/Input/style/index.less +102 -102
  56. package/lib/InputNumber/style/index.less +69 -69
  57. package/lib/Modal/index.js +8 -10
  58. package/lib/Modal/style/index.less +45 -45
  59. package/lib/PageHeader/index.d.ts +3 -0
  60. package/lib/PageHeader/index.js +15 -0
  61. package/lib/PageHeader/style/index.d.ts +2 -0
  62. package/lib/PageHeader/style/index.js +5 -0
  63. package/lib/PageHeader/style/index.less +1 -0
  64. package/lib/Select/rc-select/OptionList.js +7 -5
  65. package/lib/Select/rc-select/hooks/useOptions.d.ts +1 -1
  66. package/lib/Select/style/index.less +49 -49
  67. package/lib/Select/style/variables.less +45 -45
  68. package/lib/Select/utils/iconUtil.d.ts +2 -2
  69. package/lib/Select/utils/iconUtil.js +10 -8
  70. package/lib/Steps/components/ProcessIcon/index.d.ts +5 -0
  71. package/lib/Steps/components/ProcessIcon/index.js +19 -0
  72. package/lib/Steps/components/Step/index.d.ts +20 -0
  73. package/lib/Steps/components/Step/index.js +61 -0
  74. package/lib/Steps/index.d.ts +36 -2
  75. package/lib/Steps/index.js +34 -1
  76. package/lib/Steps/matchMedia.mock.d.ts +1 -0
  77. package/lib/Steps/matchMedia.mock.js +17 -0
  78. package/lib/Steps/style/index.less +251 -0
  79. package/lib/Switch/index.d.ts +46 -2
  80. package/lib/Switch/index.js +78 -1
  81. package/lib/Switch/style/index.less +129 -0
  82. package/lib/Table/style/index.less +1 -1
  83. package/lib/Tabs/index.js +5 -3
  84. package/lib/Tabs/style/index.less +25 -25
  85. package/lib/index.d.ts +6 -4
  86. package/lib/index.js +8 -0
  87. package/lib/style/index.less +1 -1
  88. package/lib/style/themes/default/index.less +30 -30
  89. package/package.json +2 -1
@@ -7,6 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = getIcons;
9
9
 
10
+ require("@aloudata/icons-react/styles/index.less");
11
+
12
+ var _CancelFill2 = _interopRequireDefault(require("@aloudata/icons-react/es/icons/CancelFill"));
13
+
14
+ var _ArrowsDownLine2 = _interopRequireDefault(require("@aloudata/icons-react/es/icons/ArrowsDownLine"));
15
+
10
16
  var React = _interopRequireWildcard(require("react"));
11
17
 
12
18
  var _LoadingOutlined = _interopRequireDefault(require("@ant-design/icons/LoadingOutlined"));
@@ -15,18 +21,14 @@ var _CheckOutlined = _interopRequireDefault(require("@ant-design/icons/CheckOutl
15
21
 
16
22
  var _CloseCircleFilled = _interopRequireDefault(require("@ant-design/icons/CloseCircleFilled"));
17
23
 
18
- var _CancelFill = _interopRequireDefault(require("../../Icon/icons/CancelFill"));
19
-
20
24
  var _themeColorModule = _interopRequireDefault(require("../../style/themes/default/themeColor.module.less"));
21
25
 
22
- var _ArrowsDownLine = _interopRequireDefault(require("../../Icon/icons/ArrowsDownLine"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
27
 
28
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
29
 
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
30
32
  function getIcons(_ref) {
31
33
  var suffixIcon = _ref.suffixIcon,
32
34
  clearIcon = _ref.clearIcon,
@@ -68,7 +70,7 @@ function getIcons(_ref) {
68
70
  // if (open && showSearch) {
69
71
  // return getSuffixIconNode(<SearchOutlined className={iconCls} />);
70
72
  // }
71
- return getSuffixIconNode( /*#__PURE__*/React.createElement(_ArrowsDownLine.default, {
73
+ return getSuffixIconNode( /*#__PURE__*/React.createElement(_ArrowsDownLine2.default, {
72
74
  color: _themeColorModule.default.NL50,
73
75
  className: iconCls
74
76
  }));
@@ -91,7 +93,7 @@ function getIcons(_ref) {
91
93
  if (removeIcon !== undefined) {
92
94
  mergedRemoveIcon = removeIcon;
93
95
  } else {
94
- mergedRemoveIcon = /*#__PURE__*/React.createElement(_CancelFill.default, {
96
+ mergedRemoveIcon = /*#__PURE__*/React.createElement(_CancelFill2.default, {
95
97
  color: _themeColorModule.default.NL50,
96
98
  size: '1em'
97
99
  });
@@ -0,0 +1,5 @@
1
+ interface IProcessIconProps {
2
+ type: 'process' | 'wait';
3
+ }
4
+ export declare function ProcessIcon({ type }: IProcessIconProps): JSX.Element;
5
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProcessIcon = ProcessIcon;
7
+
8
+ var _classnames = _interopRequireDefault(require("classnames"));
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function ProcessIcon(_ref) {
15
+ var type = _ref.type;
16
+ return /*#__PURE__*/_react.default.createElement("span", {
17
+ className: (0, _classnames.default)("".concat(type, "-icon-box"), 'icon-box')
18
+ });
19
+ }
@@ -0,0 +1,20 @@
1
+ import { ReactNode } from 'react';
2
+ export declare type TStatus = 'wait' | 'process' | 'finish' | 'error';
3
+ export interface IStepProps {
4
+ /**
5
+ * @description 当前步骤的描述信息
6
+ * @default -
7
+ */
8
+ description?: ReactNode;
9
+ /**
10
+ * @description 当前步骤的状态,可选`wait`、`process`、`finish`、`error`
11
+ * @default wait
12
+ */
13
+ status?: TStatus;
14
+ /**
15
+ * @description 标题
16
+ * @default -
17
+ */
18
+ title?: ReactNode;
19
+ }
20
+ export declare function Step(props: IStepProps): JSX.Element;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Step = Step;
7
+
8
+ require("@aloudata/icons-react/styles/index.less");
9
+
10
+ var _CheckFill2 = _interopRequireDefault(require("@aloudata/icons-react/es/icons/CheckFill"));
11
+
12
+ var _ErrorFill2 = _interopRequireDefault(require("@aloudata/icons-react/es/icons/ErrorFill"));
13
+
14
+ require("antd/es/steps/style");
15
+
16
+ var _steps = _interopRequireDefault(require("antd/es/steps"));
17
+
18
+ var _react = _interopRequireDefault(require("react"));
19
+
20
+ var _ProcessIcon = require("../ProcessIcon");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ var AntdStep = _steps.default.Step;
25
+
26
+ function Step(props) {
27
+ var status = props.status;
28
+
29
+ var getIcon = function getIcon(stepStatus) {
30
+ if (stepStatus === 'error') {
31
+ return /*#__PURE__*/_react.default.createElement("span", {
32
+ className: "error-icon-box icon-box"
33
+ }, /*#__PURE__*/_react.default.createElement(_ErrorFill2.default, {
34
+ size: 16
35
+ }));
36
+ }
37
+
38
+ if (stepStatus === 'finish') {
39
+ return /*#__PURE__*/_react.default.createElement("span", {
40
+ className: "check-icon-box icon-box"
41
+ }, /*#__PURE__*/_react.default.createElement(_CheckFill2.default, {
42
+ size: 16
43
+ }));
44
+ }
45
+
46
+ if (stepStatus === 'process') {
47
+ return /*#__PURE__*/_react.default.createElement(_ProcessIcon.ProcessIcon, {
48
+ type: "process"
49
+ });
50
+ } // wait
51
+
52
+
53
+ return /*#__PURE__*/_react.default.createElement(_ProcessIcon.ProcessIcon, {
54
+ type: "wait"
55
+ });
56
+ };
57
+
58
+ return /*#__PURE__*/_react.default.createElement(AntdStep, Object.assign({}, props, {
59
+ icon: getIcon(status)
60
+ }));
61
+ }
@@ -1,3 +1,37 @@
1
- import Steps, { StepsProps, StepProps } from 'antd/es/steps';
2
- export { StepsProps, StepProps };
1
+ import { ReactElement } from 'react';
2
+ import { IStepProps } from './components/Step';
3
+ export type { IStepProps };
4
+ export declare type TStatus = 'wait' | 'process' | 'finish' | 'error';
5
+ export interface IStepsProps {
6
+ /**
7
+ * @description Steps最外层类名
8
+ * @default -
9
+ */
10
+ className?: string;
11
+ /**
12
+ * @description 当前步骤,从0开始计数,可以通过在子Step中的设置status字段覆盖状态
13
+ * @default 0
14
+ */
15
+ current?: number;
16
+ /**
17
+ * @description 指定步骤条方向,水平:`horizontal`和竖直:`vertical`
18
+ * @default horizontal
19
+ */
20
+ direction?: 'horizontal' | 'vertical';
21
+ /**
22
+ * @description 默认开始步骤,从0开始计数
23
+ * @default 0
24
+ */
25
+ defaultCurrent?: number;
26
+ /**
27
+ * @description current属性指向步骤的状态,可选`wait`、`process`、`finish`、‘error
28
+ * @default process
29
+ */
30
+ status?: TStatus;
31
+ children?: ReactElement<IStepProps>[];
32
+ }
33
+ declare function Steps({ className, current, direction, defaultCurrent, status, children, }: IStepsProps): JSX.Element;
34
+ declare namespace Steps {
35
+ var Step: typeof import("./components/Step").Step;
36
+ }
3
37
  export default Steps;
@@ -5,9 +5,42 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ require("antd/es/steps/style");
9
+
8
10
  var _steps = _interopRequireDefault(require("antd/es/steps"));
9
11
 
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ var _Step = require("./components/Step");
17
+
10
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
19
 
12
- var _default = _steps.default;
20
+ var INITIAL = 0;
21
+
22
+ function Steps(_ref) {
23
+ var className = _ref.className,
24
+ current = _ref.current,
25
+ _ref$direction = _ref.direction,
26
+ direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
27
+ _ref$defaultCurrent = _ref.defaultCurrent,
28
+ defaultCurrent = _ref$defaultCurrent === void 0 ? INITIAL : _ref$defaultCurrent,
29
+ status = _ref.status,
30
+ children = _ref.children;
31
+ return /*#__PURE__*/_react.default.createElement(_steps.default, {
32
+ className: (0, _classnames.default)('ald-steps', className),
33
+ current: current,
34
+ direction: direction,
35
+ initial: defaultCurrent,
36
+ status: status,
37
+ labelPlacement: "vertical",
38
+ responsive: false,
39
+ size: "default",
40
+ type: "default"
41
+ }, children);
42
+ }
43
+
44
+ Steps.Step = _Step.Step;
45
+ var _default = Steps;
13
46
  exports.default = _default;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(window, 'matchMedia', {
4
+ writable: true,
5
+ value: jest.fn().mockImplementation(function (query) {
6
+ return {
7
+ matches: false,
8
+ media: query,
9
+ onchange: null,
10
+ addListener: jest.fn(),
11
+ removeListener: jest.fn(),
12
+ addEventListener: jest.fn(),
13
+ removeEventListener: jest.fn(),
14
+ dispatchEvent: jest.fn()
15
+ };
16
+ })
17
+ });
@@ -1 +1,252 @@
1
1
  @import '../../style/index.less';
2
+
3
+ .ant-steps-item-icon {
4
+ width: 24px;
5
+ height: 24px;
6
+ margin: 6px 8px -2px 0;
7
+ font-size: 12px;
8
+ line-height: 24px;
9
+ text-align: center;
10
+ border-radius: 24px;
11
+ transition: background-color 0.3s, border-color 0.3s;
12
+ }
13
+
14
+ // 水平状态下
15
+ .ant-steps.ald-steps {
16
+ padding: 24px;
17
+
18
+ .ant-steps-item-content {
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ margin: 0 -4px;
23
+ }
24
+
25
+ .ant-steps-item-custom > .ant-steps-item-container > .ant-steps-item-icon > .ant-steps-icon {
26
+ top: 2px;
27
+ left: 0.5px;
28
+ width: 16px;
29
+ height: 16px;
30
+ font-size: 16px;
31
+ line-height: 16px;
32
+ }
33
+
34
+ // 常规step
35
+ .ant-steps-item {
36
+ .ant-steps-item-tail {
37
+ margin-left: 50px;
38
+ padding: 3.5px 7px;
39
+
40
+ &::after {
41
+ height: 2px;
42
+ background-color: @NL90;
43
+ }
44
+ }
45
+
46
+ .ant-steps-item-title {
47
+ height: 20px;
48
+ font-weight: 400;
49
+ font-size: 14px;
50
+ font-style: normal;
51
+ line-height: 20px;
52
+ }
53
+
54
+ .ant-steps-item-description {
55
+ max-width: 264px;
56
+ max-height: 32px;
57
+ margin-top: 3px;
58
+ overflow: hidden;
59
+ color: @NL50;
60
+ font-weight: 400;
61
+ font-size: 12px;
62
+ font-style: normal;
63
+ line-height: 16px;
64
+ word-break: break-all;
65
+ }
66
+ }
67
+ // 已完成的step
68
+ .ant-steps-item-finish {
69
+ .ant-steps-item-tail::after {
70
+ height: 2px;
71
+ background-color: @B60;
72
+ }
73
+
74
+ .ant-steps-item-title {
75
+ color: @NL50;
76
+ }
77
+ }
78
+ // 正在进行中的step
79
+ .ant-steps-item-active {
80
+ .ant-steps-item-title {
81
+ color: @B60;
82
+ font-weight: 500;
83
+ }
84
+ }
85
+ // 等待中step
86
+ .ant-steps-item-wait {
87
+ .ant-steps-item-title {
88
+ color: @NL0;
89
+ }
90
+ }
91
+ // 错误状态下的step
92
+ .ant-steps-item-error {
93
+ .ant-steps-item-title {
94
+ color: @SC60;
95
+ }
96
+ }
97
+ }
98
+ // 竖直状态下
99
+ .ant-steps.ald-steps.ant-steps-vertical {
100
+ height: 100%;
101
+
102
+ .ant-steps-item-container {
103
+ display: flex;
104
+ align-items: center;
105
+
106
+ .ant-steps-item-content {
107
+ display: flex;
108
+ flex-direction: column;
109
+ align-items: flex-start;
110
+ justify-content: center;
111
+ margin-left: 5px;
112
+
113
+ .ant-steps-item-title {
114
+ height: 20px;
115
+ margin-top: 1px;
116
+ font-size: 14px;
117
+ line-height: 20px;
118
+ }
119
+
120
+ .ant-steps-item-description {
121
+ max-width: 264px;
122
+ // height: 16px;
123
+ max-height: 32px;
124
+ margin-top: 4px;
125
+ padding: 0;
126
+ overflow: hidden;
127
+ font-size: 12px;
128
+ line-height: 16px;
129
+ text-overflow: ellipsis;
130
+ word-wrap: break-word;
131
+ -webkit-line-clamp: 2;
132
+ }
133
+ }
134
+
135
+ .ant-steps-item-icon {
136
+ width: 16px;
137
+ height: 16px;
138
+ margin-top: 0;
139
+ margin-right: 0;
140
+
141
+ & .ant-steps-icon {
142
+ top: 0;
143
+ left: 0.5px;
144
+ width: 16px;
145
+ height: 16px;
146
+ font-size: 16px;
147
+ line-height: 16px;
148
+ }
149
+ }
150
+ }
151
+
152
+ // 常规step
153
+ .ant-steps-item {
154
+ &:last-child {
155
+ flex: 0 0 auto;
156
+ }
157
+
158
+ .ant-steps-item-tail {
159
+ position: absolute;
160
+ top: 18px;
161
+ left: 8px;
162
+ width: 2px;
163
+ height: 100%;
164
+ margin: 0;
165
+ padding: 14px 0 0;
166
+
167
+ &::after {
168
+ width: 2px;
169
+ height: 100%;
170
+ background-color: @NL90;
171
+ }
172
+ }
173
+ }
174
+ // 已完成的step
175
+ .ant-steps-item-finish {
176
+ .ant-steps-item-tail::after {
177
+ width: 2px;
178
+ height: 100%;
179
+ background-color: @B60;
180
+ }
181
+
182
+ &.ant-steps-item-title {
183
+ color: @NL50;
184
+ }
185
+ }
186
+ }
187
+
188
+ .ant-steps.ald-steps
189
+ .ant-steps-item:not(.ant-steps-item-active)
190
+ > .ant-steps-item-container[role='button'] {
191
+ cursor: pointer;
192
+
193
+ &:hover {
194
+ .ant-steps-item-title,
195
+ .ant-steps-item-description {
196
+ color: #0f62fe;
197
+ }
198
+ }
199
+ }
200
+ // 自定义Icon的样式
201
+ .icon-box {
202
+ display: flex;
203
+ align-items: center;
204
+ justify-content: center;
205
+ width: 16px;
206
+ height: 16px;
207
+ margin-bottom: 9px;
208
+ background-color: #fff;
209
+ border-radius: 50%;
210
+ }
211
+
212
+ .error-icon-box {
213
+ color: @SC60;
214
+ }
215
+
216
+ .check-icon-box {
217
+ color: @B60;
218
+ }
219
+ // 提升该类名的优先级,不然会被.iconBox覆盖掉
220
+ .ald-steps .process-icon-box {
221
+ position: relative;
222
+ background-color: @B60;
223
+
224
+ &::after {
225
+ position: absolute;
226
+ top: 50%;
227
+ left: 50%;
228
+ width: 6px;
229
+ height: 6px;
230
+ background-color: @ND0;
231
+ border-radius: 50%;
232
+ transform: translate(-50%, -50%);
233
+ content: '';
234
+ }
235
+ }
236
+
237
+ .ald-steps .wait-icon-box {
238
+ position: relative;
239
+ background-color: @BG90;
240
+
241
+ &::after {
242
+ position: absolute;
243
+ top: 50%;
244
+ left: 50%;
245
+ width: 6px;
246
+ height: 6px;
247
+ background-color: @BG80;
248
+ border-radius: 50%;
249
+ transform: translate(-50%, -50%);
250
+ content: '';
251
+ }
252
+ }
@@ -1,4 +1,48 @@
1
- import Switch, { SwitchProps } from 'antd/es/switch';
1
+ import { SwitchChangeEventHandler } from 'antd/es/switch';
2
+ import React from 'react';
2
3
  export type { SwitchSize, SwitchChangeEventHandler, SwitchClickEventHandler } from 'antd/es/switch';
3
- export { SwitchProps };
4
+ export interface ISwitchProps {
5
+ /**
6
+ * @description class类名
7
+ * @default -
8
+ */
9
+ className?: string;
10
+ /**
11
+ * @description 指定当前是否选中
12
+ * @default false
13
+ */
14
+ checked?: boolean;
15
+ /**
16
+ * @description 初始是否选中
17
+ * @default false
18
+ */
19
+ defaultChecked?: boolean;
20
+ /**
21
+ * @description 是否禁用
22
+ * @default false
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * @description 加载中的开关
27
+ * @default false
28
+ */
29
+ loading?: boolean;
30
+ /**
31
+ * @description 尺寸大小
32
+ * @default middle
33
+ */
34
+ size?: 'middle' | 'small';
35
+ /**
36
+ * @description 点击时的回调
37
+ * @type (checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;
38
+ */
39
+ onClick?: SwitchChangeEventHandler;
40
+ /**
41
+ * @description 变时的回调
42
+ * @type (checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;
43
+ */
44
+ onChange?: SwitchChangeEventHandler;
45
+ children?: React.ReactNode;
46
+ }
47
+ declare const Switch: React.FC<ISwitchProps>;
4
48
  export default Switch;
@@ -1,13 +1,90 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
10
+ require("antd/es/switch/style");
11
+
8
12
  var _switch = _interopRequireDefault(require("antd/es/switch"));
9
13
 
14
+ var _react = _interopRequireWildcard(require("react"));
15
+
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
10
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
23
 
12
- var _default = _switch.default;
24
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
25
+
26
+ 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."); }
27
+
28
+ 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); }
29
+
30
+ 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; }
31
+
32
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
33
+
34
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
+
36
+ var Switch = function Switch(_ref) {
37
+ var _ref$className = _ref.className,
38
+ className = _ref$className === void 0 ? '' : _ref$className,
39
+ _ref$disabled = _ref.disabled,
40
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
41
+ _ref$loading = _ref.loading,
42
+ loading = _ref$loading === void 0 ? false : _ref$loading,
43
+ _ref$size = _ref.size,
44
+ size = _ref$size === void 0 ? 'middle' : _ref$size,
45
+ checked = _ref.checked,
46
+ _ref$defaultChecked = _ref.defaultChecked,
47
+ defaultChecked = _ref$defaultChecked === void 0 ? false : _ref$defaultChecked,
48
+ onChange = _ref.onChange,
49
+ onClick = _ref.onClick,
50
+ children = _ref.children;
51
+
52
+ var _useState = (0, _react.useState)(typeof checked === 'undefined' ? defaultChecked : checked),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ userChecked = _useState2[0],
55
+ setUserChecked = _useState2[1];
56
+
57
+ var onChangeCB = function onChangeCB(isChecked, event) {
58
+ setUserChecked(isChecked);
59
+
60
+ if (typeof onChange === 'function') {
61
+ onChange(isChecked, event);
62
+ }
63
+ };
64
+
65
+ var currentDisabled = loading ? true : disabled;
66
+ (0, _react.useEffect)(function () {
67
+ if (typeof checked === 'boolean') {
68
+ setUserChecked(checked);
69
+ }
70
+ }, [checked]);
71
+ return /*#__PURE__*/_react.default.createElement("span", {
72
+ className: (0, _classnames.default)(className, 'ald-switch', "ald-switch-".concat(size), {
73
+ 'ald-switch-disabled': currentDisabled,
74
+ 'ald-switch-checked': userChecked
75
+ })
76
+ }, /*#__PURE__*/_react.default.createElement(_switch.default, {
77
+ disabled: currentDisabled,
78
+ loading: loading,
79
+ onChange: onChangeCB,
80
+ onClick: onClick,
81
+ checked: userChecked,
82
+ className: "ald-switch-btn",
83
+ defaultChecked: defaultChecked
84
+ }), children && /*#__PURE__*/_react.default.createElement("span", {
85
+ className: "ald-switch-text"
86
+ }, children));
87
+ };
88
+
89
+ var _default = Switch;
13
90
  exports.default = _default;