@kdcloudjs/kdesign 1.7.0 → 1.7.2

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 (208) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/default-theme.js +4 -5
  3. package/dist/kdesign-complete.less +332 -35
  4. package/dist/kdesign.css +549 -30
  5. package/dist/kdesign.css.map +1 -1
  6. package/dist/kdesign.js +21841 -3922
  7. package/dist/kdesign.js.map +1 -1
  8. package/dist/kdesign.min.css +3 -3
  9. package/dist/kdesign.min.js +9 -9
  10. package/dist/kdesign.min.js.map +1 -1
  11. package/es/alert/style/index.css +2 -0
  12. package/es/anchor/style/index.css +2 -0
  13. package/es/avatar/style/index.css +2 -0
  14. package/es/badge/style/index.css +2 -0
  15. package/es/base-data/style/index.css +2 -0
  16. package/es/button/style/index.css +2 -0
  17. package/es/card/style/index.css +2 -0
  18. package/es/carousel/style/index.css +2 -0
  19. package/es/cascader/style/index.css +2 -0
  20. package/es/checkbox/style/index.css +2 -0
  21. package/es/city-picker/style/index.css +2 -0
  22. package/es/collapse/style/index.css +2 -0
  23. package/es/color-picker/color-picker-panel.d.ts +4 -0
  24. package/es/color-picker/color-picker-panel.js +239 -0
  25. package/es/color-picker/color-picker.d.ts +4 -0
  26. package/es/color-picker/color-picker.js +201 -0
  27. package/es/color-picker/constant/colorTypes.d.ts +4 -0
  28. package/es/color-picker/constant/colorTypes.js +13 -0
  29. package/es/color-picker/constant/defaultColor.d.ts +1 -0
  30. package/es/color-picker/constant/defaultColor.js +1 -0
  31. package/es/color-picker/constant/systemPresetColor.d.ts +1 -0
  32. package/es/color-picker/constant/systemPresetColor.js +1 -0
  33. package/es/color-picker/index.d.ts +3 -0
  34. package/es/color-picker/index.js +3 -0
  35. package/es/color-picker/interface.d.ts +64 -0
  36. package/es/color-picker/interface.js +3 -0
  37. package/es/color-picker/style/css.js +2 -0
  38. package/es/color-picker/style/index.css +323 -0
  39. package/es/color-picker/style/index.d.ts +2 -0
  40. package/es/color-picker/style/index.js +2 -0
  41. package/es/color-picker/style/index.less +257 -0
  42. package/es/color-picker/style/mixin.less +5 -0
  43. package/es/color-picker/style/token.less +22 -0
  44. package/es/color-picker/utils/colorFormat.d.ts +18 -0
  45. package/es/color-picker/utils/colorFormat.js +153 -0
  46. package/es/color-picker/utils/convertLetters.d.ts +1 -0
  47. package/es/color-picker/utils/convertLetters.js +12 -0
  48. package/es/color-picker/utils/hooks/useOnClickOutside.d.ts +2 -0
  49. package/es/color-picker/utils/hooks/useOnClickOutside.js +16 -0
  50. package/es/color-picker/utils/validateColor.d.ts +1 -0
  51. package/es/color-picker/utils/validateColor.js +24 -0
  52. package/es/config-provider/compDefaultProps.d.ts +12 -0
  53. package/es/config-provider/compDefaultProps.js +12 -0
  54. package/es/date-picker/style/index.css +2 -0
  55. package/es/drawer/style/index.css +2 -0
  56. package/es/dropdown/dropdown.js +2 -7
  57. package/es/dropdown/menu.js +3 -0
  58. package/es/dropdown/style/index.css +2 -0
  59. package/es/empty/style/index.css +2 -0
  60. package/es/filter/style/index.css +2 -0
  61. package/es/form/style/index.css +2 -0
  62. package/es/grid/style/index.css +2 -0
  63. package/es/icon/style/index.css +2 -0
  64. package/es/image/style/index.css +2 -0
  65. package/es/image-cropper/style/index.css +2 -0
  66. package/es/index.d.ts +1 -0
  67. package/es/index.js +2 -1
  68. package/es/input/style/index.css +2 -0
  69. package/es/input-number/style/index.css +2 -0
  70. package/es/layout/style/index.css +2 -0
  71. package/es/link/style/index.css +2 -0
  72. package/es/locale/locale.d.ts +4 -0
  73. package/es/locale/locale.js +6 -4
  74. package/es/locale/zh-CN.d.ts +1 -0
  75. package/es/locale/zh-CN.js +1 -0
  76. package/es/menu/style/index.css +2 -0
  77. package/es/message/style/index.css +2 -0
  78. package/es/modal/modal.d.ts +7 -1
  79. package/es/modal/modal.js +29 -5
  80. package/es/modal/style/index.css +2 -0
  81. package/es/notification/style/index.css +2 -0
  82. package/es/pagination/style/index.css +116 -29
  83. package/es/pagination/style/index.less +38 -29
  84. package/es/popconfirm/style/index.css +2 -0
  85. package/es/progress/style/index.css +2 -0
  86. package/es/radio/style/index.css +2 -0
  87. package/es/rate/style/index.css +2 -0
  88. package/es/search/style/index.css +2 -0
  89. package/es/select/style/index.css +2 -0
  90. package/es/slider/style/index.css +2 -0
  91. package/es/space/style/index.css +2 -0
  92. package/es/spin/style/index.css +2 -0
  93. package/es/split-panel/style/index.css +2 -0
  94. package/es/stepper/style/index.css +2 -0
  95. package/es/steps/style/index.css +2 -0
  96. package/es/style/index.css +2 -0
  97. package/es/style/themes/default.less +10 -6
  98. package/es/switch/style/index.css +2 -0
  99. package/es/table/style/index.css +2 -0
  100. package/es/tabs/style/index.css +2 -0
  101. package/es/tag/style/index.css +2 -0
  102. package/es/timeline/style/index.css +2 -0
  103. package/es/tooltip/style/index.css +2 -0
  104. package/es/transfer/style/index.css +2 -0
  105. package/es/tree/style/index.css +2 -0
  106. package/es/tree-select/style/index.css +2 -0
  107. package/es/typography/style/index.css +2 -0
  108. package/es/upload/style/index.css +2 -0
  109. package/lib/alert/style/index.css +2 -0
  110. package/lib/anchor/style/index.css +2 -0
  111. package/lib/avatar/style/index.css +2 -0
  112. package/lib/badge/style/index.css +2 -0
  113. package/lib/base-data/style/index.css +2 -0
  114. package/lib/button/style/index.css +2 -0
  115. package/lib/card/style/index.css +2 -0
  116. package/lib/carousel/style/index.css +2 -0
  117. package/lib/cascader/style/index.css +2 -0
  118. package/lib/checkbox/style/index.css +2 -0
  119. package/lib/city-picker/style/index.css +2 -0
  120. package/lib/collapse/style/index.css +2 -0
  121. package/lib/color-picker/color-picker-panel.d.ts +4 -0
  122. package/lib/color-picker/color-picker-panel.js +253 -0
  123. package/lib/color-picker/color-picker.d.ts +4 -0
  124. package/lib/color-picker/color-picker.js +214 -0
  125. package/lib/color-picker/constant/colorTypes.d.ts +4 -0
  126. package/lib/color-picker/constant/colorTypes.js +20 -0
  127. package/lib/color-picker/constant/defaultColor.d.ts +1 -0
  128. package/lib/color-picker/constant/defaultColor.js +8 -0
  129. package/lib/color-picker/constant/systemPresetColor.d.ts +1 -0
  130. package/lib/color-picker/constant/systemPresetColor.js +8 -0
  131. package/lib/color-picker/index.d.ts +3 -0
  132. package/lib/color-picker/index.js +27 -0
  133. package/lib/color-picker/interface.d.ts +64 -0
  134. package/lib/color-picker/interface.js +11 -0
  135. package/lib/color-picker/style/css.js +4 -0
  136. package/lib/color-picker/style/index.css +323 -0
  137. package/lib/color-picker/style/index.d.ts +2 -0
  138. package/lib/color-picker/style/index.js +4 -0
  139. package/lib/color-picker/style/index.less +257 -0
  140. package/lib/color-picker/style/mixin.less +5 -0
  141. package/lib/color-picker/style/token.less +22 -0
  142. package/lib/color-picker/utils/colorFormat.d.ts +18 -0
  143. package/lib/color-picker/utils/colorFormat.js +166 -0
  144. package/lib/color-picker/utils/convertLetters.d.ts +1 -0
  145. package/lib/color-picker/utils/convertLetters.js +18 -0
  146. package/lib/color-picker/utils/hooks/useOnClickOutside.d.ts +2 -0
  147. package/lib/color-picker/utils/hooks/useOnClickOutside.js +23 -0
  148. package/lib/color-picker/utils/validateColor.d.ts +1 -0
  149. package/lib/color-picker/utils/validateColor.js +30 -0
  150. package/lib/config-provider/compDefaultProps.d.ts +12 -0
  151. package/lib/config-provider/compDefaultProps.js +12 -0
  152. package/lib/date-picker/style/index.css +2 -0
  153. package/lib/drawer/style/index.css +2 -0
  154. package/lib/dropdown/dropdown.js +2 -7
  155. package/lib/dropdown/menu.js +3 -0
  156. package/lib/dropdown/style/index.css +2 -0
  157. package/lib/empty/style/index.css +2 -0
  158. package/lib/filter/style/index.css +2 -0
  159. package/lib/form/style/index.css +2 -0
  160. package/lib/grid/style/index.css +2 -0
  161. package/lib/icon/style/index.css +2 -0
  162. package/lib/image/style/index.css +2 -0
  163. package/lib/image-cropper/style/index.css +2 -0
  164. package/lib/index.d.ts +1 -0
  165. package/lib/index.js +7 -0
  166. package/lib/input/style/index.css +2 -0
  167. package/lib/input-number/style/index.css +2 -0
  168. package/lib/layout/style/index.css +2 -0
  169. package/lib/link/style/index.css +2 -0
  170. package/lib/locale/locale.d.ts +4 -0
  171. package/lib/locale/locale.js +6 -4
  172. package/lib/locale/zh-CN.d.ts +1 -0
  173. package/lib/locale/zh-CN.js +1 -0
  174. package/lib/menu/style/index.css +2 -0
  175. package/lib/message/style/index.css +2 -0
  176. package/lib/modal/modal.d.ts +7 -1
  177. package/lib/modal/modal.js +31 -7
  178. package/lib/modal/style/index.css +2 -0
  179. package/lib/notification/style/index.css +2 -0
  180. package/lib/pagination/style/index.css +116 -29
  181. package/lib/pagination/style/index.less +38 -29
  182. package/lib/popconfirm/style/index.css +2 -0
  183. package/lib/progress/style/index.css +2 -0
  184. package/lib/radio/style/index.css +2 -0
  185. package/lib/rate/style/index.css +2 -0
  186. package/lib/search/style/index.css +2 -0
  187. package/lib/select/style/index.css +2 -0
  188. package/lib/slider/style/index.css +2 -0
  189. package/lib/space/style/index.css +2 -0
  190. package/lib/spin/style/index.css +2 -0
  191. package/lib/split-panel/style/index.css +2 -0
  192. package/lib/stepper/style/index.css +2 -0
  193. package/lib/steps/style/index.css +2 -0
  194. package/lib/style/components.less +1 -0
  195. package/lib/style/index.css +2 -0
  196. package/lib/style/themes/default.less +10 -6
  197. package/lib/switch/style/index.css +2 -0
  198. package/lib/table/style/index.css +2 -0
  199. package/lib/tabs/style/index.css +2 -0
  200. package/lib/tag/style/index.css +2 -0
  201. package/lib/timeline/style/index.css +2 -0
  202. package/lib/tooltip/style/index.css +2 -0
  203. package/lib/transfer/style/index.css +2 -0
  204. package/lib/tree/style/index.css +2 -0
  205. package/lib/tree-select/style/index.css +2 -0
  206. package/lib/typography/style/index.css +2 -0
  207. package/lib/upload/style/index.css +2 -0
  208. package/package.json +5 -1
@@ -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 */
@@ -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 */
@@ -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 */
@@ -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,4 @@
1
+ import { FC } from 'react';
2
+ import { IColorPickerPanelProps } from './interface';
3
+ declare const ColorPickerPanel: FC<IColorPickerPanelProps>;
4
+ export default ColorPickerPanel;
@@ -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,4 @@
1
+ import { FC } from 'react';
2
+ import { IColorPickerProps } from './interface';
3
+ declare const ColorPicker: FC<Partial<IColorPickerProps>>;
4
+ export default ColorPicker;
@@ -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;
@@ -0,0 +1,4 @@
1
+ export declare const colorTypes: {
2
+ type: string;
3
+ value: string;
4
+ }[];
@@ -0,0 +1,13 @@
1
+ export var colorTypes = [{
2
+ type: 'HEX',
3
+ value: '#b2b2b2'
4
+ }, {
5
+ type: 'HSB',
6
+ value: 'hsb(0, 0%, 70%)'
7
+ }, {
8
+ type: 'RGB',
9
+ value: 'rgb(178, 178, 178)'
10
+ }, {
11
+ type: 'HSL',
12
+ value: 'hsl(0, 0%, 70%)'
13
+ }];
@@ -0,0 +1 @@
1
+ export declare const defaultSystemColor = "#b2b2b2";
@@ -0,0 +1 @@
1
+ export var defaultSystemColor = '#b2b2b2';
@@ -0,0 +1 @@
1
+ export declare const systemPresetColor: string[];
@@ -0,0 +1 @@
1
+ export var systemPresetColor = ['#A1ECFF', '#A1F5E8', '#A1E6B5', '#DDFF8F', '#FFEF8A', '#FFE0A6', '#FFCAA8', '#FFADB6', '#FF96AD', '#D4A8FF', '#99CCFF', '#B3D5FF', '#16B0F1', '#16B8B1', '#1BA854', '#77C404', '#FDC200', '#FF991C', '#FF5F1F', '#FB2323', '#F90D58', '#701DF0', '#0E5FD8', '#276FF5', '#FFFFFF', '#FAFAFA', '#F5F5F5', '#F2F2F2', '#E5E5E5', '#D9D9D9', '#CCCCCC', '#999999', '#666666', '#404040', '#212121', '#000000'];
@@ -0,0 +1,3 @@
1
+ import ColorPicker from './color-picker';
2
+ export * from './color-picker';
3
+ export default ColorPicker;
@@ -0,0 +1,3 @@
1
+ import ColorPicker from './color-picker';
2
+ export * from './color-picker';
3
+ export default ColorPicker;