@kdcloudjs/kdesign 1.6.40 → 1.7.1
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.
- package/CHANGELOG.md +32 -0
- package/dist/default-theme.js +4 -5
- package/dist/kdesign-complete.less +806 -35
- package/dist/kdesign.css +1051 -35
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +59352 -40542
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +9 -9
- package/dist/kdesign.min.js.map +1 -1
- package/es/alert/style/index.css +2 -0
- package/es/anchor/style/index.css +2 -0
- package/es/avatar/style/index.css +2 -0
- package/es/badge/style/index.css +2 -0
- package/es/base-data/style/index.css +2 -0
- package/es/button/style/index.css +2 -0
- package/es/card/style/index.css +2 -0
- package/es/carousel/style/index.css +2 -0
- package/es/cascader/cascader.js +14 -3
- package/es/cascader/style/index.css +2 -0
- package/es/cascader/util.js +13 -4
- package/es/checkbox/style/index.css +2 -0
- package/es/city-picker/style/index.css +2 -0
- package/es/collapse/style/index.css +2 -0
- package/es/color-picker/color-picker-panel.d.ts +4 -0
- package/es/color-picker/color-picker-panel.js +239 -0
- package/es/color-picker/color-picker.d.ts +4 -0
- package/es/color-picker/color-picker.js +201 -0
- package/es/color-picker/constant/colorTypes.d.ts +4 -0
- package/es/color-picker/constant/colorTypes.js +13 -0
- package/es/color-picker/constant/defaultColor.d.ts +1 -0
- package/es/color-picker/constant/defaultColor.js +1 -0
- package/es/color-picker/constant/systemPresetColor.d.ts +1 -0
- package/es/color-picker/constant/systemPresetColor.js +1 -0
- package/es/color-picker/index.d.ts +3 -0
- package/es/color-picker/index.js +3 -0
- package/es/color-picker/interface.d.ts +64 -0
- package/es/color-picker/interface.js +3 -0
- package/es/color-picker/style/css.js +2 -0
- package/es/color-picker/style/index.css +317 -0
- package/es/color-picker/style/index.d.ts +2 -0
- package/es/color-picker/style/index.js +2 -0
- package/es/color-picker/style/index.less +253 -0
- package/es/color-picker/style/mixin.less +5 -0
- package/es/color-picker/style/token.less +22 -0
- package/es/color-picker/utils/colorFormat.d.ts +18 -0
- package/es/color-picker/utils/colorFormat.js +153 -0
- package/es/color-picker/utils/convertLetters.d.ts +1 -0
- package/es/color-picker/utils/convertLetters.js +12 -0
- package/es/color-picker/utils/hooks/useOnClickOutside.d.ts +2 -0
- package/es/color-picker/utils/hooks/useOnClickOutside.js +16 -0
- package/es/color-picker/utils/validateColor.d.ts +1 -0
- package/es/color-picker/utils/validateColor.js +24 -0
- package/es/config-provider/compDefaultProps.d.ts +25 -0
- package/es/config-provider/compDefaultProps.js +29 -0
- package/es/date-picker/style/index.css +2 -0
- package/es/drawer/style/index.css +2 -0
- package/es/dropdown/style/index.css +2 -0
- package/es/empty/style/index.css +2 -0
- package/es/filter/style/index.css +2 -0
- package/es/form/style/index.css +2 -0
- package/es/grid/style/index.css +2 -0
- package/es/icon/style/index.css +2 -0
- package/es/image/style/index.css +2 -0
- package/es/image-cropper/style/index.css +2 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/es/input/ClearableLabeledInput.js +8 -2
- package/es/input/input.js +1 -5
- package/es/input/style/index.css +2 -0
- package/es/input-number/style/index.css +2 -0
- package/es/layout/style/index.css +2 -0
- package/es/link/style/index.css +2 -0
- package/es/locale/locale.d.ts +4 -0
- package/es/locale/locale.js +6 -4
- package/es/locale/zh-CN.d.ts +1 -0
- package/es/locale/zh-CN.js +1 -0
- package/es/menu/style/index.css +2 -0
- package/es/message/style/index.css +2 -0
- package/es/modal/style/index.css +2 -0
- package/es/notification/style/index.css +2 -0
- package/es/pagination/style/index.css +116 -29
- package/es/pagination/style/index.less +38 -29
- package/es/popconfirm/style/index.css +2 -0
- package/es/progress/style/index.css +2 -0
- package/es/radio/style/index.css +2 -0
- package/es/rate/style/index.css +2 -0
- package/es/search/style/index.css +2 -0
- package/es/select/style/index.css +2 -0
- package/es/slider/style/index.css +2 -0
- package/es/space/style/index.css +2 -0
- package/es/spin/style/index.css +2 -0
- package/es/split-panel/style/index.css +2 -0
- package/es/stepper/style/index.css +2 -0
- package/es/steps/style/index.css +2 -0
- package/es/style/index.css +2 -0
- package/es/style/themes/default.less +10 -6
- package/es/switch/style/index.css +2 -0
- package/es/table/style/index.css +2 -0
- package/es/tabs/style/index.css +2 -0
- package/es/tag/style/index.css +2 -0
- package/es/timeline/style/index.css +2 -0
- package/es/tooltip/style/index.css +2 -0
- package/es/transfer/style/index.css +2 -0
- package/es/tree/style/index.css +2 -0
- package/es/tree/tree.d.ts +2 -1
- package/es/tree/tree.js +4 -3
- package/es/tree-select/index.d.ts +3 -0
- package/es/tree-select/index.js +3 -0
- package/es/tree-select/interface.d.ts +68 -0
- package/es/tree-select/interface.js +4 -0
- package/es/tree-select/style/css.js +2 -0
- package/es/tree-select/style/index.css +504 -0
- package/es/tree-select/style/index.d.ts +2 -0
- package/es/tree-select/style/index.js +2 -0
- package/es/tree-select/style/index.less +392 -0
- package/es/tree-select/style/mixin.less +29 -0
- package/es/tree-select/style/token.less +54 -0
- package/es/tree-select/tree-select.d.ts +4 -0
- package/es/tree-select/tree-select.js +506 -0
- package/es/typography/style/index.css +2 -0
- package/es/upload/style/index.css +2 -0
- package/lib/alert/style/index.css +2 -0
- package/lib/anchor/style/index.css +2 -0
- package/lib/avatar/style/index.css +2 -0
- package/lib/badge/style/index.css +2 -0
- package/lib/base-data/style/index.css +2 -0
- package/lib/button/style/index.css +2 -0
- package/lib/card/style/index.css +2 -0
- package/lib/carousel/style/index.css +2 -0
- package/lib/cascader/cascader.js +14 -3
- package/lib/cascader/style/index.css +2 -0
- package/lib/cascader/util.js +13 -4
- package/lib/checkbox/style/index.css +2 -0
- package/lib/city-picker/style/index.css +2 -0
- package/lib/collapse/style/index.css +2 -0
- package/lib/color-picker/color-picker-panel.d.ts +4 -0
- package/lib/color-picker/color-picker-panel.js +253 -0
- package/lib/color-picker/color-picker.d.ts +4 -0
- package/lib/color-picker/color-picker.js +214 -0
- package/lib/color-picker/constant/colorTypes.d.ts +4 -0
- package/lib/color-picker/constant/colorTypes.js +20 -0
- package/lib/color-picker/constant/defaultColor.d.ts +1 -0
- package/lib/color-picker/constant/defaultColor.js +8 -0
- package/lib/color-picker/constant/systemPresetColor.d.ts +1 -0
- package/lib/color-picker/constant/systemPresetColor.js +8 -0
- package/lib/color-picker/index.d.ts +3 -0
- package/lib/color-picker/index.js +27 -0
- package/lib/color-picker/interface.d.ts +64 -0
- package/lib/color-picker/interface.js +11 -0
- package/lib/color-picker/style/css.js +4 -0
- package/lib/color-picker/style/index.css +317 -0
- package/lib/color-picker/style/index.d.ts +2 -0
- package/lib/color-picker/style/index.js +4 -0
- package/lib/color-picker/style/index.less +253 -0
- package/lib/color-picker/style/mixin.less +5 -0
- package/lib/color-picker/style/token.less +22 -0
- package/lib/color-picker/utils/colorFormat.d.ts +18 -0
- package/lib/color-picker/utils/colorFormat.js +166 -0
- package/lib/color-picker/utils/convertLetters.d.ts +1 -0
- package/lib/color-picker/utils/convertLetters.js +18 -0
- package/lib/color-picker/utils/hooks/useOnClickOutside.d.ts +2 -0
- package/lib/color-picker/utils/hooks/useOnClickOutside.js +23 -0
- package/lib/color-picker/utils/validateColor.d.ts +1 -0
- package/lib/color-picker/utils/validateColor.js +30 -0
- package/lib/config-provider/compDefaultProps.d.ts +25 -0
- package/lib/config-provider/compDefaultProps.js +29 -0
- package/lib/date-picker/style/index.css +2 -0
- package/lib/drawer/style/index.css +2 -0
- package/lib/dropdown/style/index.css +2 -0
- package/lib/empty/style/index.css +2 -0
- package/lib/filter/style/index.css +2 -0
- package/lib/form/style/index.css +2 -0
- package/lib/grid/style/index.css +2 -0
- package/lib/icon/style/index.css +2 -0
- package/lib/image/style/index.css +2 -0
- package/lib/image-cropper/style/index.css +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +14 -0
- package/lib/input/ClearableLabeledInput.js +8 -2
- package/lib/input/input.js +1 -5
- package/lib/input/style/index.css +2 -0
- package/lib/input-number/style/index.css +2 -0
- package/lib/layout/style/index.css +2 -0
- package/lib/link/style/index.css +2 -0
- package/lib/locale/locale.d.ts +4 -0
- package/lib/locale/locale.js +6 -4
- package/lib/locale/zh-CN.d.ts +1 -0
- package/lib/locale/zh-CN.js +1 -0
- package/lib/menu/style/index.css +2 -0
- package/lib/message/style/index.css +2 -0
- package/lib/modal/style/index.css +2 -0
- package/lib/notification/style/index.css +2 -0
- package/lib/pagination/style/index.css +116 -29
- package/lib/pagination/style/index.less +38 -29
- package/lib/popconfirm/style/index.css +2 -0
- package/lib/progress/style/index.css +2 -0
- package/lib/radio/style/index.css +2 -0
- package/lib/rate/style/index.css +2 -0
- package/lib/search/style/index.css +2 -0
- package/lib/select/style/index.css +2 -0
- package/lib/slider/style/index.css +2 -0
- package/lib/space/style/index.css +2 -0
- package/lib/spin/style/index.css +2 -0
- package/lib/split-panel/style/index.css +2 -0
- package/lib/stepper/style/index.css +2 -0
- package/lib/steps/style/index.css +2 -0
- package/lib/style/components.less +2 -0
- package/lib/style/index.css +2 -0
- package/lib/style/themes/default.less +10 -6
- package/lib/switch/style/index.css +2 -0
- package/lib/table/style/index.css +2 -0
- package/lib/tabs/style/index.css +2 -0
- package/lib/tag/style/index.css +2 -0
- package/lib/timeline/style/index.css +2 -0
- package/lib/tooltip/style/index.css +2 -0
- package/lib/transfer/style/index.css +2 -0
- package/lib/tree/style/index.css +2 -0
- package/lib/tree/tree.d.ts +2 -1
- package/lib/tree/tree.js +4 -3
- package/lib/tree-select/index.d.ts +3 -0
- package/lib/tree-select/index.js +27 -0
- package/lib/tree-select/interface.d.ts +68 -0
- package/lib/tree-select/interface.js +13 -0
- package/lib/tree-select/style/css.js +4 -0
- package/lib/tree-select/style/index.css +504 -0
- package/lib/tree-select/style/index.d.ts +2 -0
- package/lib/tree-select/style/index.js +4 -0
- package/lib/tree-select/style/index.less +392 -0
- package/lib/tree-select/style/mixin.less +29 -0
- package/lib/tree-select/style/token.less +54 -0
- package/lib/tree-select/tree-select.d.ts +4 -0
- package/lib/tree-select/tree-select.js +519 -0
- package/lib/typography/style/index.css +2 -0
- package/lib/upload/style/index.css +2 -0
- package/package.json +5 -1
package/es/alert/style/index.css
CHANGED
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
package/es/badge/style/index.css
CHANGED
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
package/es/card/style/index.css
CHANGED
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
package/es/cascader/cascader.js
CHANGED
|
@@ -169,6 +169,17 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
171
|
}, [currentOptions, fieldNames.label, isMultiple]);
|
|
172
|
+
var values = useMemo(function () {
|
|
173
|
+
return !isMultiple ? _mapInstanceProperty(currentOptions).call(currentOptions, function (_ref3) {
|
|
174
|
+
var value = _ref3.value;
|
|
175
|
+
return value;
|
|
176
|
+
}) : _mapInstanceProperty(currentOptions).call(currentOptions, function (option) {
|
|
177
|
+
return _mapInstanceProperty(option).call(option, function (_ref4) {
|
|
178
|
+
var value = _ref4.value;
|
|
179
|
+
return value;
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}, [currentOptions, isMultiple]);
|
|
172
183
|
var allowClear = allProps.allowClear && value.length > 0;
|
|
173
184
|
var locatorProps = {
|
|
174
185
|
style: style,
|
|
@@ -256,7 +267,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
256
267
|
ref: wrapperRef
|
|
257
268
|
}, Array.isArray(currentOptions) && /*#__PURE__*/React.createElement(React.Fragment, null, _mapInstanceProperty(currentOptions).call(currentOptions, function (option, index) {
|
|
258
269
|
return /*#__PURE__*/React.createElement("span", {
|
|
259
|
-
key: _JSON$stringify(
|
|
270
|
+
key: _JSON$stringify(values[index]),
|
|
260
271
|
className: classNames("".concat(prefixCls, "-selection-tag"))
|
|
261
272
|
}, (!maxTagCount || index <= maxTagCount - 1) && /*#__PURE__*/React.createElement(Tag, {
|
|
262
273
|
type: "edit",
|
|
@@ -331,8 +342,8 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
331
342
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, newValue, newMultipleOptions);
|
|
332
343
|
};
|
|
333
344
|
var onChange = function onChange(selectedOptions) {
|
|
334
|
-
var selectedValue = _mapInstanceProperty(selectedOptions).call(selectedOptions, function (
|
|
335
|
-
var value =
|
|
345
|
+
var selectedValue = _mapInstanceProperty(selectedOptions).call(selectedOptions, function (_ref5) {
|
|
346
|
+
var value = _ref5[fieldNames.value];
|
|
336
347
|
return value;
|
|
337
348
|
});
|
|
338
349
|
setCurrentOptions(selectedOptions);
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
package/es/cascader/util.js
CHANGED
|
@@ -7,9 +7,9 @@ import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
|
7
7
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
8
8
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
9
9
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
10
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
11
10
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
12
11
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
|
12
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
13
13
|
var __rest = this && this.__rest || function (s, e) {
|
|
14
14
|
var t = {};
|
|
15
15
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -193,9 +193,18 @@ export var getChecked = function getChecked(checkedKeys, key) {
|
|
|
193
193
|
return checkedKeys === null || checkedKeys === void 0 ? void 0 : _includesInstanceProperty(checkedKeys).call(checkedKeys, key);
|
|
194
194
|
};
|
|
195
195
|
var getCheckedNodes = function getCheckedNodes(flatNodes, checkedKeys) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
var result = [];
|
|
197
|
+
for (var i = 0; i < checkedKeys.length; i++) {
|
|
198
|
+
var key = checkedKeys[i];
|
|
199
|
+
for (var j = 0; j < flatNodes.length; j++) {
|
|
200
|
+
var obj = flatNodes[j];
|
|
201
|
+
if (obj.value === key) {
|
|
202
|
+
result.push(obj);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
199
208
|
};
|
|
200
209
|
export var addKeys = function addKeys() {
|
|
201
210
|
var _context6;
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
/* ----------- Transfer ——————---- end */
|
|
57
57
|
/* ----------- DatePicker ——————---- start */
|
|
58
58
|
/* ----------- DatePicker ——————---- end */
|
|
59
|
+
/* ----------- ColorPicker ——————---- start */
|
|
60
|
+
/* ----------- ColorPicker ——————---- end */
|
|
59
61
|
/* ----------- Tree ——————---- start */
|
|
60
62
|
/* ----------- Tree ——————---- end */
|
|
61
63
|
/* ----------- Alert ——————---- start */
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
import React, { useContext, useRef } from 'react';
|
|
5
|
+
import { Input, Select, Switch } from '../index';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import { ConfigContext } from '../config-provider';
|
|
8
|
+
import { systemPresetColor } from './constant/systemPresetColor';
|
|
9
|
+
import { colorFormat, valOfCorrespondingType, strFixed, getColorObj, highlightPresetColorIndex, presetColorToHEX } from './utils/colorFormat';
|
|
10
|
+
import { defaultSystemColor } from './constant/defaultColor';
|
|
11
|
+
import { validateColor } from './utils/validateColor';
|
|
12
|
+
import { toLowerCase } from './utils/convertLetters';
|
|
13
|
+
import Color from 'color';
|
|
14
|
+
import { ChromePicker } from 'react-color';
|
|
15
|
+
import devWarning from '../_utils/devwarning';
|
|
16
|
+
import useOnClickOutside from './utils/hooks/useOnClickOutside';
|
|
17
|
+
var ColorPickerPanel = function ColorPickerPanel(props) {
|
|
18
|
+
var _context;
|
|
19
|
+
var setCorrectColorValue = props.setCorrectColorValue,
|
|
20
|
+
setInputColorValue = props.setInputColorValue,
|
|
21
|
+
setAlpha = props.setAlpha,
|
|
22
|
+
setAlphaNoVerifyVal = props.setAlphaNoVerifyVal,
|
|
23
|
+
setIsFollow = props.setIsFollow,
|
|
24
|
+
setClickedColorIndex = props.setClickedColorIndex,
|
|
25
|
+
setShowPanel = props.setShowPanel,
|
|
26
|
+
setColTypeArr = props.setColTypeArr,
|
|
27
|
+
setCurrentColorType = props.setCurrentColorType,
|
|
28
|
+
onChange = props.onChange,
|
|
29
|
+
alpha = props.alpha,
|
|
30
|
+
alphaNoVerifyVal = props.alphaNoVerifyVal,
|
|
31
|
+
clickedColorIndex = props.clickedColorIndex,
|
|
32
|
+
colTypeArr = props.colTypeArr,
|
|
33
|
+
correctColorValue = props.correctColorValue,
|
|
34
|
+
currentColorType = props.currentColorType,
|
|
35
|
+
functionalColor = props.functionalColor,
|
|
36
|
+
functionalColorName = props.functionalColorName,
|
|
37
|
+
switchName = props.switchName,
|
|
38
|
+
inputRef = props.inputRef,
|
|
39
|
+
isFollow = props.isFollow,
|
|
40
|
+
presetColor = props.presetColor,
|
|
41
|
+
showSwitch = props.showSwitch,
|
|
42
|
+
showColorTransfer = props.showColorTransfer,
|
|
43
|
+
showPresetColor = props.showPresetColor,
|
|
44
|
+
showColorPickerBox = props.showColorPickerBox,
|
|
45
|
+
value = props.value;
|
|
46
|
+
var panelInputRef = useRef(null);
|
|
47
|
+
var panelClsRef = useRef(null);
|
|
48
|
+
var Option = Select.Option;
|
|
49
|
+
var _useContext = useContext(ConfigContext),
|
|
50
|
+
getPrefixCls = _useContext.getPrefixCls,
|
|
51
|
+
prefixCls = _useContext.prefixCls,
|
|
52
|
+
locale = _useContext.locale;
|
|
53
|
+
var colorPickerPrefixCls = getPrefixCls(prefixCls, 'color-picker');
|
|
54
|
+
var panelCls = classNames("".concat(colorPickerPrefixCls, "-panel"));
|
|
55
|
+
var panelChromePickerCls = classNames("".concat(colorPickerPrefixCls, "-panel-chrome"));
|
|
56
|
+
var panelFollowThemeCls = classNames("".concat(colorPickerPrefixCls, "-panel-switch"));
|
|
57
|
+
var panelInputCls = classNames("".concat(colorPickerPrefixCls, "-panel-input"), _defineProperty({}, "".concat(colorPickerPrefixCls, "-panel-input-no-recommend"), !showPresetColor));
|
|
58
|
+
var transparentCls = classNames("".concat(colorPickerPrefixCls, "-panel-transparent"));
|
|
59
|
+
var colorDivContainerCls = classNames("".concat(colorPickerPrefixCls, "-panel-colorDivContainer"));
|
|
60
|
+
var colorLiClick = function colorLiClick(index, colorValue) {
|
|
61
|
+
var formatArr = colorFormat(colorValue, alpha);
|
|
62
|
+
var formatValue = toLowerCase(formatArr[valOfCorrespondingType(currentColorType)].value);
|
|
63
|
+
setIsFollow(false);
|
|
64
|
+
if (isFollow) {
|
|
65
|
+
setAlpha(1);
|
|
66
|
+
setAlphaNoVerifyVal(100 + '%');
|
|
67
|
+
}
|
|
68
|
+
if (value === undefined) {
|
|
69
|
+
setInputColorValue(formatValue);
|
|
70
|
+
setCorrectColorValue(formatValue);
|
|
71
|
+
setColTypeArr(formatArr);
|
|
72
|
+
}
|
|
73
|
+
setClickedColorIndex(index);
|
|
74
|
+
onChange && onChange(formatValue, colTypeArr);
|
|
75
|
+
};
|
|
76
|
+
var handleTypeChange = function handleTypeChange(selectValue, option) {
|
|
77
|
+
setCurrentColorType(option.label);
|
|
78
|
+
if (value === undefined) {
|
|
79
|
+
setCorrectColorValue(selectValue);
|
|
80
|
+
setInputColorValue(selectValue);
|
|
81
|
+
}
|
|
82
|
+
onChange && onChange(selectValue, colTypeArr);
|
|
83
|
+
};
|
|
84
|
+
var setPanelState = function setPanelState(formatArr, correctColorValue, inputColorValue, alpha, alphaStr) {
|
|
85
|
+
setColTypeArr(formatArr);
|
|
86
|
+
setCorrectColorValue(correctColorValue);
|
|
87
|
+
setInputColorValue(inputColorValue);
|
|
88
|
+
alpha && setAlpha(alpha);
|
|
89
|
+
alphaStr && setAlphaNoVerifyVal(alphaStr);
|
|
90
|
+
};
|
|
91
|
+
var handleAlphaChange = function handleAlphaChange(e) {
|
|
92
|
+
var regPercentage = /^(0|[1-9][0-9]?|100)%$/;
|
|
93
|
+
var regDot = /^(0(\.\d+)?|1(\.0+)?)$/;
|
|
94
|
+
var val = e.target.value;
|
|
95
|
+
var formatArr, outValue;
|
|
96
|
+
if (value === undefined) {
|
|
97
|
+
setAlphaNoVerifyVal(e.target.value);
|
|
98
|
+
if (regPercentage.test(val)) {
|
|
99
|
+
console.log(1);
|
|
100
|
+
formatArr = colorFormat(correctColorValue, +val.replace('%', '') / 100, 'all', true);
|
|
101
|
+
outValue = formatArr[valOfCorrespondingType(currentColorType)].value;
|
|
102
|
+
setPanelState(formatArr, outValue, outValue, +val.replace('%', '') / 100);
|
|
103
|
+
setClickedColorIndex(highlightPresetColorIndex(formatArr[0].value, presetColorToHEX(presetColor || systemPresetColor)));
|
|
104
|
+
} else if (regDot.test(val)) {
|
|
105
|
+
console.log(2);
|
|
106
|
+
formatArr = colorFormat(correctColorValue, +val, 'all', true);
|
|
107
|
+
outValue = formatArr[valOfCorrespondingType(currentColorType)].value;
|
|
108
|
+
setPanelState(formatArr, outValue, outValue, strFixed(val, 2));
|
|
109
|
+
setClickedColorIndex(highlightPresetColorIndex(formatArr[0].value, presetColorToHEX(presetColor || systemPresetColor)));
|
|
110
|
+
} else {
|
|
111
|
+
console.log(3);
|
|
112
|
+
formatArr = colorFormat(correctColorValue, 1, 'all', true);
|
|
113
|
+
outValue = formatArr[valOfCorrespondingType(currentColorType)].value;
|
|
114
|
+
setPanelState(formatArr, outValue, outValue, 1);
|
|
115
|
+
}
|
|
116
|
+
onChange && onChange(outValue, formatArr);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var handleAlphaBlur = function handleAlphaBlur(e) {
|
|
120
|
+
var regPercentage = /^(0|[1-9][0-9]?|100)%$/;
|
|
121
|
+
var regDot = /^(0(\.\d+)?|1(\.0+)?)$/;
|
|
122
|
+
var val = e.target.value;
|
|
123
|
+
if (regPercentage.test(val)) {
|
|
124
|
+
setAlphaNoVerifyVal(val);
|
|
125
|
+
} else if (regDot.test(val)) {
|
|
126
|
+
setAlphaNoVerifyVal(strFixed(+val * 100) + '%');
|
|
127
|
+
} else {
|
|
128
|
+
setAlphaNoVerifyVal('100%');
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var handleSwitchChange = function handleSwitchChange(switchValue) {
|
|
132
|
+
var formatArr;
|
|
133
|
+
if (functionalColor) {
|
|
134
|
+
var inputValType = validateColor(functionalColor);
|
|
135
|
+
if (inputValType) {
|
|
136
|
+
if (value === undefined) {
|
|
137
|
+
setIsFollow(switchValue);
|
|
138
|
+
if (switchValue) {
|
|
139
|
+
formatArr = colorFormat(functionalColor, alpha);
|
|
140
|
+
setPanelState(formatArr, formatArr[valOfCorrespondingType(currentColorType)].value, functionalColorName, strFixed(Color(getColorObj(functionalColor)).alpha(), 2), strFixed(Color(getColorObj(functionalColor)).alpha(), 2) * 100 + '%');
|
|
141
|
+
setClickedColorIndex(highlightPresetColorIndex(formatArr[0].value, presetColorToHEX(presetColor || systemPresetColor)));
|
|
142
|
+
} else {
|
|
143
|
+
formatArr = colorFormat(defaultSystemColor, 1, 'all', true);
|
|
144
|
+
setPanelState(formatArr, defaultSystemColor, '', 1, 100 + '%');
|
|
145
|
+
setClickedColorIndex(-1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
devWarning(!inputValType, 'color-picker', "'themeColor' must be hexadecimal, RGB, HSB, HSL or color English name");
|
|
150
|
+
}
|
|
151
|
+
if (switchValue) {
|
|
152
|
+
onChange && onChange(functionalColorName, formatArr);
|
|
153
|
+
} else {
|
|
154
|
+
onChange && onChange(defaultSystemColor, formatArr);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var handleChromeChange = function handleChromeChange(color) {
|
|
158
|
+
var formatArr = colorFormat(color.hex, color.rgb.a);
|
|
159
|
+
var colorObj = formatArr[valOfCorrespondingType(currentColorType)];
|
|
160
|
+
if (value === undefined) {
|
|
161
|
+
setIsFollow(false);
|
|
162
|
+
setPanelState(formatArr, colorObj.value, colorObj.value, color.rgb.a, (color.rgb.a * 100).toFixed() + '%');
|
|
163
|
+
setClickedColorIndex(highlightPresetColorIndex(formatArr[0].value, presetColorToHEX(presetColor || systemPresetColor)));
|
|
164
|
+
}
|
|
165
|
+
onChange && onChange(colorObj.value, formatArr);
|
|
166
|
+
};
|
|
167
|
+
var checkUserPresetColor = function checkUserPresetColor(colorArr) {
|
|
168
|
+
if (!colorArr) return false;
|
|
169
|
+
var isTrueFormat = colorArr.every(function (hexColor) {
|
|
170
|
+
return ['HEX', 'HSB', 'RGB', 'HSL', 'colorName'].indexOf(validateColor(hexColor)) !== -1;
|
|
171
|
+
});
|
|
172
|
+
devWarning(!isTrueFormat, 'color-picker', "'presetColor' must be Array of the HEX string type");
|
|
173
|
+
return isTrueFormat;
|
|
174
|
+
};
|
|
175
|
+
useOnClickOutside([panelClsRef, inputRef], function () {
|
|
176
|
+
setShowPanel(false);
|
|
177
|
+
});
|
|
178
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
179
|
+
className: panelCls,
|
|
180
|
+
ref: panelClsRef
|
|
181
|
+
}, showColorPickerBox && /*#__PURE__*/React.createElement(ChromePicker, {
|
|
182
|
+
className: panelChromePickerCls,
|
|
183
|
+
color: colTypeArr[2].value,
|
|
184
|
+
onChange: handleChromeChange
|
|
185
|
+
}), functionalColor && showSwitch && /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: panelFollowThemeCls
|
|
187
|
+
}, /*#__PURE__*/React.createElement("span", null, (switchName === null || switchName === void 0 ? void 0 : switchName.internationalName) && locale.getLangMsg('ColorPicker', switchName.internationalName) || switchName.name), /*#__PURE__*/React.createElement(Switch, {
|
|
188
|
+
checked: isFollow,
|
|
189
|
+
onChange: handleSwitchChange
|
|
190
|
+
})), showColorTransfer && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
className: panelInputCls,
|
|
192
|
+
ref: panelInputRef
|
|
193
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
194
|
+
disabled: isFollow,
|
|
195
|
+
borderType: "bordered",
|
|
196
|
+
value: correctColorValue,
|
|
197
|
+
placeholder: "#",
|
|
198
|
+
onChange: handleTypeChange,
|
|
199
|
+
showSearch: true,
|
|
200
|
+
optionLabelProp: "value",
|
|
201
|
+
getPopupContainer: function getPopupContainer() {
|
|
202
|
+
return panelInputRef.current;
|
|
203
|
+
}
|
|
204
|
+
}, _mapInstanceProperty(colTypeArr).call(colTypeArr, function (obj, i) {
|
|
205
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
206
|
+
title: obj.value,
|
|
207
|
+
value: obj.value,
|
|
208
|
+
className: classNames({
|
|
209
|
+
'active-option': obj.type === currentColorType && obj.value === correctColorValue
|
|
210
|
+
}),
|
|
211
|
+
key: i
|
|
212
|
+
}, obj.type);
|
|
213
|
+
}))), /*#__PURE__*/React.createElement(Input, {
|
|
214
|
+
className: transparentCls,
|
|
215
|
+
onChange: handleAlphaChange,
|
|
216
|
+
onBlur: handleAlphaBlur,
|
|
217
|
+
borderType: "bordered",
|
|
218
|
+
value: alphaNoVerifyVal,
|
|
219
|
+
disabled: isFollow
|
|
220
|
+
})), showPresetColor && /*#__PURE__*/React.createElement("div", {
|
|
221
|
+
className: colorDivContainerCls
|
|
222
|
+
}, _mapInstanceProperty(_context = checkUserPresetColor(presetColor) && presetColorToHEX(presetColor) || systemPresetColor).call(_context, function (colorValue, i) {
|
|
223
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
224
|
+
key: i,
|
|
225
|
+
style: {
|
|
226
|
+
backgroundColor: "".concat(colorValue)
|
|
227
|
+
},
|
|
228
|
+
onClick: function onClick() {
|
|
229
|
+
colorLiClick(i, colorValue);
|
|
230
|
+
}
|
|
231
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
className: classNames('square', {
|
|
233
|
+
'square-click': clickedColorIndex === i
|
|
234
|
+
})
|
|
235
|
+
}));
|
|
236
|
+
})));
|
|
237
|
+
};
|
|
238
|
+
ColorPickerPanel.displayName = 'ColorPickerPanel';
|
|
239
|
+
export default ColorPickerPanel;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
4
|
+
import React, { useContext, useState, useRef, useEffect } from 'react';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { ConfigContext } from '../config-provider';
|
|
7
|
+
import { Input, Icon } from '../index';
|
|
8
|
+
import { validateColor } from './utils/validateColor';
|
|
9
|
+
import { colorTypes } from './constant/colorTypes';
|
|
10
|
+
import ColorPickerPanel from './color-picker-panel';
|
|
11
|
+
import { colorFormat, strFixed, getColorObj, valOfCorrespondingType, highlightPresetColorIndex, presetColorToHEX } from './utils/colorFormat';
|
|
12
|
+
import { toLowerCase } from './utils/convertLetters';
|
|
13
|
+
import { defaultSystemColor } from './constant/defaultColor';
|
|
14
|
+
import Color from 'color';
|
|
15
|
+
import { getCompProps } from '../_utils';
|
|
16
|
+
import usePopper from '../_utils/usePopper';
|
|
17
|
+
import { systemPresetColor } from './constant/systemPresetColor';
|
|
18
|
+
var ColorPicker = function ColorPicker(props) {
|
|
19
|
+
var _useContext = useContext(ConfigContext),
|
|
20
|
+
getPrefixCls = _useContext.getPrefixCls,
|
|
21
|
+
prefixCls = _useContext.prefixCls,
|
|
22
|
+
userDefaultProps = _useContext.compDefaultProps;
|
|
23
|
+
var colorPickerProps = getCompProps('ColorPicker', userDefaultProps, props);
|
|
24
|
+
var value = colorPickerProps.value,
|
|
25
|
+
className = colorPickerProps.className,
|
|
26
|
+
style = colorPickerProps.style,
|
|
27
|
+
functionalColor = colorPickerProps.functionalColor,
|
|
28
|
+
functionalColorName = colorPickerProps.functionalColorName,
|
|
29
|
+
switchName = colorPickerProps.switchName,
|
|
30
|
+
showSwitch = colorPickerProps.showSwitch,
|
|
31
|
+
showColorTransfer = colorPickerProps.showColorTransfer,
|
|
32
|
+
showPresetColor = colorPickerProps.showPresetColor,
|
|
33
|
+
showColorPickerBox = colorPickerProps.showColorPickerBox,
|
|
34
|
+
borderType = colorPickerProps.borderType,
|
|
35
|
+
presetColor = colorPickerProps.presetColor,
|
|
36
|
+
placeholder = colorPickerProps.placeholder,
|
|
37
|
+
defaultValue = colorPickerProps.defaultValue,
|
|
38
|
+
defaultOpen = colorPickerProps.defaultOpen,
|
|
39
|
+
suffixIcon = colorPickerProps.suffixIcon,
|
|
40
|
+
onChange = colorPickerProps.onChange;
|
|
41
|
+
var _useState = useState(defaultValue || ''),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
inputColorValue = _useState2[0],
|
|
44
|
+
setInputColorValue = _useState2[1];
|
|
45
|
+
var _useState3 = useState(defaultValue || defaultSystemColor),
|
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
+
correctColorValue = _useState4[0],
|
|
48
|
+
setCorrectColorValue = _useState4[1];
|
|
49
|
+
var _useState5 = useState('HEX'),
|
|
50
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
51
|
+
currentColorType = _useState6[0],
|
|
52
|
+
setCurrentColorType = _useState6[1];
|
|
53
|
+
var _useState7 = useState(colorTypes),
|
|
54
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
55
|
+
colTypeArr = _useState8[0],
|
|
56
|
+
setColTypeArr = _useState8[1];
|
|
57
|
+
var _useState9 = useState(defaultOpen),
|
|
58
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
59
|
+
showPanel = _useState10[0],
|
|
60
|
+
setShowPanel = _useState10[1];
|
|
61
|
+
var _useState11 = useState(1),
|
|
62
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
63
|
+
alpha = _useState12[0],
|
|
64
|
+
setAlpha = _useState12[1];
|
|
65
|
+
var _useState13 = useState(alpha * 100 + '%'),
|
|
66
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
67
|
+
alphaNoVerifyVal = _useState14[0],
|
|
68
|
+
setAlphaNoVerifyVal = _useState14[1];
|
|
69
|
+
var _useState15 = useState(false),
|
|
70
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
71
|
+
isFollow = _useState16[0],
|
|
72
|
+
setIsFollow = _useState16[1];
|
|
73
|
+
var _useState17 = useState(),
|
|
74
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
75
|
+
clickedColorIndex = _useState18[0],
|
|
76
|
+
setClickedColorIndex = _useState18[1];
|
|
77
|
+
var colorPickerPrefixCls = getPrefixCls(prefixCls, 'color-picker');
|
|
78
|
+
var popUpLayer = getPrefixCls(prefixCls, 'color-picker-pop');
|
|
79
|
+
var containerCls = classNames("".concat(colorPickerPrefixCls, "-container"));
|
|
80
|
+
var inputCls = classNames("".concat(colorPickerPrefixCls, "-input"), className);
|
|
81
|
+
var inputRef = useRef(null);
|
|
82
|
+
var setIconColor = function setIconColor(value) {
|
|
83
|
+
value === functionalColorName ? setIsFollow(true) : setIsFollow(false);
|
|
84
|
+
var inpValue = value === functionalColorName ? functionalColor : value;
|
|
85
|
+
var inputValType = validateColor(inpValue);
|
|
86
|
+
var setState = function setState(formatArr, correctColorValue, alpha, alphaStr) {
|
|
87
|
+
setColTypeArr(formatArr);
|
|
88
|
+
setCorrectColorValue(correctColorValue);
|
|
89
|
+
setAlpha(alpha);
|
|
90
|
+
setAlphaNoVerifyVal(alphaStr);
|
|
91
|
+
};
|
|
92
|
+
if (inputValType) {
|
|
93
|
+
var formatArr = colorFormat(inpValue, strFixed(Color(getColorObj(inpValue)).alpha(), 2));
|
|
94
|
+
setState(formatArr, formatArr[valOfCorrespondingType(currentColorType)].value, Color(getColorObj(inpValue)).alpha(), (strFixed(Color(getColorObj(inpValue)).alpha(), 2) * 100).toFixed() + '%');
|
|
95
|
+
setClickedColorIndex(highlightPresetColorIndex(formatArr[0].value, presetColorToHEX(presetColor || systemPresetColor)));
|
|
96
|
+
} else {
|
|
97
|
+
var _formatArr = colorFormat(defaultSystemColor);
|
|
98
|
+
setState(_formatArr, defaultSystemColor, 1, '100%');
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var handleChange = function handleChange(e) {
|
|
102
|
+
setClickedColorIndex(-1);
|
|
103
|
+
var inpValue = toLowerCase(e.target.value);
|
|
104
|
+
if (value === undefined) {
|
|
105
|
+
setIconColor(inpValue);
|
|
106
|
+
setInputColorValue(inpValue);
|
|
107
|
+
}
|
|
108
|
+
var callback = function callback(val, alpha) {
|
|
109
|
+
var formatArr = colorFormat(val, alpha);
|
|
110
|
+
onChange && onChange(inpValue, formatArr);
|
|
111
|
+
};
|
|
112
|
+
if (validateColor(inpValue)) {
|
|
113
|
+
callback(inpValue, alpha);
|
|
114
|
+
} else {
|
|
115
|
+
callback(defaultSystemColor, alpha);
|
|
116
|
+
}
|
|
117
|
+
functionalColor && showSwitch && setIsFollow(false);
|
|
118
|
+
};
|
|
119
|
+
var handleClick = function handleClick() {
|
|
120
|
+
setShowPanel(!showPanel);
|
|
121
|
+
};
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
if (value) {
|
|
124
|
+
setIconColor(value);
|
|
125
|
+
} else {
|
|
126
|
+
if (defaultValue) {
|
|
127
|
+
setIconColor(defaultValue);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, [value, defaultValue]);
|
|
131
|
+
var afterIcon = function afterIcon() {
|
|
132
|
+
var _classNames;
|
|
133
|
+
var afterIconContainerCls = classNames("".concat(colorPickerPrefixCls, "-icon"), (_classNames = {}, _defineProperty(_classNames, "".concat(colorPickerPrefixCls, "-icon-underline"), borderType === 'underline'), _defineProperty(_classNames, "".concat(colorPickerPrefixCls, "-icon-bordered"), borderType === 'bordered'), _defineProperty(_classNames, "".concat(colorPickerPrefixCls, "-icon-up"), showPanel), _defineProperty(_classNames, "".concat(colorPickerPrefixCls, "-icon-down"), !showPanel), _classNames));
|
|
134
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
className: afterIconContainerCls,
|
|
136
|
+
style: {
|
|
137
|
+
backgroundColor: "".concat(colTypeArr[2].value || defaultSystemColor)
|
|
138
|
+
}
|
|
139
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
140
|
+
type: "arrow-down"
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
var colorInputEle = /*#__PURE__*/React.createElement("div", {
|
|
144
|
+
className: containerCls,
|
|
145
|
+
ref: inputRef
|
|
146
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
147
|
+
borderType: borderType,
|
|
148
|
+
placeholder: placeholder,
|
|
149
|
+
value: value !== null && value !== void 0 ? value : inputColorValue,
|
|
150
|
+
className: inputCls,
|
|
151
|
+
onChange: handleChange,
|
|
152
|
+
style: style,
|
|
153
|
+
onClick: handleClick
|
|
154
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
155
|
+
onClick: handleClick,
|
|
156
|
+
className: "".concat(colorPickerPrefixCls, "-icon-container")
|
|
157
|
+
}, suffixIcon && suffixIcon(colTypeArr[2].value) || afterIcon()));
|
|
158
|
+
var panel = /*#__PURE__*/React.createElement(ColorPickerPanel
|
|
159
|
+
// API
|
|
160
|
+
, {
|
|
161
|
+
// API
|
|
162
|
+
showSwitch: showSwitch,
|
|
163
|
+
showColorTransfer: showColorTransfer,
|
|
164
|
+
showPresetColor: showPresetColor,
|
|
165
|
+
showColorPickerBox: showColorPickerBox,
|
|
166
|
+
functionalColor: functionalColor,
|
|
167
|
+
functionalColorName: functionalColorName,
|
|
168
|
+
switchName: switchName,
|
|
169
|
+
presetColor: presetColor,
|
|
170
|
+
value: value,
|
|
171
|
+
// private
|
|
172
|
+
setInputColorValue: setInputColorValue,
|
|
173
|
+
setCorrectColorValue: setCorrectColorValue,
|
|
174
|
+
correctColorValue: correctColorValue,
|
|
175
|
+
clickedColorIndex: clickedColorIndex,
|
|
176
|
+
setClickedColorIndex: setClickedColorIndex,
|
|
177
|
+
onChange: onChange,
|
|
178
|
+
alpha: alpha,
|
|
179
|
+
setAlpha: setAlpha,
|
|
180
|
+
alphaNoVerifyVal: alphaNoVerifyVal,
|
|
181
|
+
setAlphaNoVerifyVal: setAlphaNoVerifyVal,
|
|
182
|
+
isFollow: isFollow,
|
|
183
|
+
setIsFollow: setIsFollow,
|
|
184
|
+
setShowPanel: setShowPanel,
|
|
185
|
+
inputRef: inputRef,
|
|
186
|
+
colTypeArr: colTypeArr,
|
|
187
|
+
setColTypeArr: setColTypeArr,
|
|
188
|
+
currentColorType: currentColorType,
|
|
189
|
+
setCurrentColorType: setCurrentColorType
|
|
190
|
+
});
|
|
191
|
+
var popperProps = _extends(_extends({}, colorPickerProps), {
|
|
192
|
+
popperClassName: popUpLayer,
|
|
193
|
+
placement: 'bottomLeft',
|
|
194
|
+
defaultVisible: showPanel,
|
|
195
|
+
visible: showPanel,
|
|
196
|
+
clickToClose: false
|
|
197
|
+
});
|
|
198
|
+
return usePopper(colorInputEle, panel, popperProps);
|
|
199
|
+
};
|
|
200
|
+
ColorPicker.displayName = 'ColorPicker';
|
|
201
|
+
export default ColorPicker;
|