tdesign-react 0.31.2-alpha.1 → 0.31.2-alpha.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.
- package/CHANGELOG.md +1 -1
- package/dist/tdesign.css +498 -0
- package/dist/tdesign.css.map +1 -1
- package/dist/tdesign.js +26543 -20076
- package/dist/tdesign.js.map +1 -1
- package/dist/tdesign.min.css +1 -1
- package/dist/tdesign.min.css.map +1 -1
- package/dist/tdesign.min.js +9 -3
- package/dist/tdesign.min.js.map +1 -1
- package/es/_chunks/{dep-5d29cc59.js → dep-7e7b26b4.js} +1 -1
- package/es/_chunks/{dep-5d29cc59.js.map → dep-7e7b26b4.js.map} +1 -1
- package/es/_common/js/color-picker/cmyk.d.ts +27 -0
- package/es/_common/js/color-picker/color.d.ts +154 -0
- package/es/_common/js/color-picker/gradient.d.ts +22 -0
- package/es/_util/useClickOutside.d.ts +1 -1
- package/es/_util/useClickOutside.js +51 -3
- package/es/_util/useClickOutside.js.map +1 -1
- package/es/_util/useDrag.d.ts +16 -0
- package/es/_util/useDrag.js +74 -0
- package/es/_util/useDrag.js.map +1 -0
- package/es/avatar/AvararGroup.js +1 -1
- package/es/avatar/Avatar.js +1 -1
- package/es/avatar/index.js +1 -1
- package/es/color-picker/ColorPicker.d.ts +4 -0
- package/es/color-picker/ColorPicker.js +241 -0
- package/es/color-picker/ColorPicker.js.map +1 -0
- package/es/color-picker/ColorPickerPanel.d.ts +7 -0
- package/es/color-picker/ColorPickerPanel.js +179 -0
- package/es/color-picker/ColorPickerPanel.js.map +1 -0
- package/es/color-picker/components/panel/alpha.d.ts +4 -0
- package/es/color-picker/components/panel/alpha.js +48 -0
- package/es/color-picker/components/panel/alpha.js.map +1 -0
- package/es/color-picker/components/panel/format/config.d.ts +19 -0
- package/es/color-picker/components/panel/format/config.js +90 -0
- package/es/color-picker/components/panel/format/config.js.map +1 -0
- package/es/color-picker/components/panel/format/index.d.ts +11 -0
- package/es/color-picker/components/panel/format/index.js +197 -0
- package/es/color-picker/components/panel/format/index.js.map +1 -0
- package/es/color-picker/components/panel/format/inputs.d.ts +3 -0
- package/es/color-picker/components/panel/format/inputs.js +223 -0
- package/es/color-picker/components/panel/format/inputs.js.map +1 -0
- package/es/color-picker/components/panel/header.d.ts +14 -0
- package/es/color-picker/components/panel/header.js +100 -0
- package/es/color-picker/components/panel/header.js.map +1 -0
- package/es/color-picker/components/panel/hue.d.ts +4 -0
- package/es/color-picker/components/panel/hue.js +32 -0
- package/es/color-picker/components/panel/hue.js.map +1 -0
- package/es/color-picker/components/panel/index.d.ts +4 -0
- package/es/color-picker/components/panel/index.js +456 -0
- package/es/color-picker/components/panel/index.js.map +1 -0
- package/es/color-picker/components/panel/linear-gradient.d.ts +3 -0
- package/es/color-picker/components/panel/linear-gradient.js +360 -0
- package/es/color-picker/components/panel/linear-gradient.js.map +1 -0
- package/es/color-picker/components/panel/saturation.d.ts +4 -0
- package/es/color-picker/components/panel/saturation.js +124 -0
- package/es/color-picker/components/panel/saturation.js.map +1 -0
- package/es/color-picker/components/panel/slider.d.ts +10 -0
- package/es/color-picker/components/panel/slider.js +106 -0
- package/es/color-picker/components/panel/slider.js.map +1 -0
- package/es/color-picker/components/panel/style/css.d.ts +1 -0
- package/es/color-picker/components/panel/style/css.js +1 -0
- package/es/color-picker/components/panel/style/index.d.ts +1 -0
- package/es/color-picker/components/panel/style/index.js +7 -0
- package/es/color-picker/components/panel/style/index.js.map +1 -0
- package/es/color-picker/components/panel/swatches.d.ts +11 -0
- package/es/color-picker/components/panel/swatches.js +134 -0
- package/es/color-picker/components/panel/swatches.js.map +1 -0
- package/es/color-picker/components/style/css.d.ts +1 -0
- package/es/color-picker/components/style/css.js +1 -0
- package/es/color-picker/components/style/index.d.ts +1 -0
- package/es/color-picker/components/style/index.js +7 -0
- package/es/color-picker/components/style/index.js.map +1 -0
- package/es/color-picker/components/trigger.d.ts +9 -0
- package/es/color-picker/components/trigger.js +125 -0
- package/es/color-picker/components/trigger.js.map +1 -0
- package/es/color-picker/const.d.ts +15 -0
- package/es/color-picker/const.js +22 -0
- package/es/color-picker/const.js.map +1 -0
- package/es/color-picker/hooks/useClassname.d.ts +2 -0
- package/es/color-picker/hooks/useClassname.js +46 -0
- package/es/color-picker/hooks/useClassname.js.map +1 -0
- package/es/color-picker/index.d.ts +10 -0
- package/es/color-picker/index.js +172 -0
- package/es/color-picker/index.js.map +1 -0
- package/es/color-picker/interface.d.ts +23 -0
- package/es/color-picker/interface.js +7 -0
- package/es/color-picker/interface.js.map +1 -0
- package/es/color-picker/style/css.d.ts +1 -0
- package/es/color-picker/style/css.js +1 -0
- package/es/color-picker/style/index.css +497 -0
- package/es/color-picker/style/index.d.ts +1 -0
- package/es/color-picker/style/index.js +7 -0
- package/es/color-picker/style/index.js.map +1 -0
- package/es/color-picker/type.d.ts +109 -0
- package/es/color-picker/type.js +7 -0
- package/es/color-picker/type.js.map +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +24 -1
- package/es/index.js.map +1 -1
- package/es/input/Input.js +1 -1
- package/es/input/Input.js.map +1 -1
- package/es/popup/hooks/useTriggerProps.js +28 -0
- package/es/popup/hooks/useTriggerProps.js.map +1 -1
- package/esm/_chunks/{dep-5d29cc59.js → dep-7e7b26b4.js} +1 -1
- package/esm/_chunks/{dep-5d29cc59.js.map → dep-7e7b26b4.js.map} +1 -1
- package/esm/_common/js/color-picker/cmyk.d.ts +27 -0
- package/esm/_common/js/color-picker/color.d.ts +154 -0
- package/esm/_common/js/color-picker/gradient.d.ts +22 -0
- package/esm/_util/useClickOutside.d.ts +1 -1
- package/esm/_util/useClickOutside.js +51 -3
- package/esm/_util/useClickOutside.js.map +1 -1
- package/esm/_util/useDrag.d.ts +16 -0
- package/esm/_util/useDrag.js +74 -0
- package/esm/_util/useDrag.js.map +1 -0
- package/esm/avatar/AvararGroup.js +1 -1
- package/esm/avatar/Avatar.js +1 -1
- package/esm/avatar/index.js +1 -1
- package/esm/color-picker/ColorPicker.d.ts +4 -0
- package/esm/color-picker/ColorPicker.js +250 -0
- package/esm/color-picker/ColorPicker.js.map +1 -0
- package/esm/color-picker/ColorPickerPanel.d.ts +7 -0
- package/esm/color-picker/ColorPickerPanel.js +188 -0
- package/esm/color-picker/ColorPickerPanel.js.map +1 -0
- package/esm/color-picker/components/panel/alpha.d.ts +4 -0
- package/esm/color-picker/components/panel/alpha.js +48 -0
- package/esm/color-picker/components/panel/alpha.js.map +1 -0
- package/esm/color-picker/components/panel/format/config.d.ts +19 -0
- package/esm/color-picker/components/panel/format/config.js +90 -0
- package/esm/color-picker/components/panel/format/config.js.map +1 -0
- package/esm/color-picker/components/panel/format/index.d.ts +11 -0
- package/esm/color-picker/components/panel/format/index.js +205 -0
- package/esm/color-picker/components/panel/format/index.js.map +1 -0
- package/esm/color-picker/components/panel/format/inputs.d.ts +3 -0
- package/esm/color-picker/components/panel/format/inputs.js +226 -0
- package/esm/color-picker/components/panel/format/inputs.js.map +1 -0
- package/esm/color-picker/components/panel/header.d.ts +14 -0
- package/esm/color-picker/components/panel/header.js +100 -0
- package/esm/color-picker/components/panel/header.js.map +1 -0
- package/esm/color-picker/components/panel/hue.d.ts +4 -0
- package/esm/color-picker/components/panel/hue.js +32 -0
- package/esm/color-picker/components/panel/hue.js.map +1 -0
- package/esm/color-picker/components/panel/index.d.ts +4 -0
- package/esm/color-picker/components/panel/index.js +465 -0
- package/esm/color-picker/components/panel/index.js.map +1 -0
- package/esm/color-picker/components/panel/linear-gradient.d.ts +3 -0
- package/esm/color-picker/components/panel/linear-gradient.js +363 -0
- package/esm/color-picker/components/panel/linear-gradient.js.map +1 -0
- package/esm/color-picker/components/panel/saturation.d.ts +4 -0
- package/esm/color-picker/components/panel/saturation.js +124 -0
- package/esm/color-picker/components/panel/saturation.js.map +1 -0
- package/esm/color-picker/components/panel/slider.d.ts +10 -0
- package/esm/color-picker/components/panel/slider.js +106 -0
- package/esm/color-picker/components/panel/slider.js.map +1 -0
- package/esm/color-picker/components/panel/style/css.d.ts +1 -0
- package/esm/color-picker/components/panel/style/index.d.ts +1 -0
- package/esm/color-picker/components/panel/style/index.js +1 -0
- package/esm/color-picker/components/panel/swatches.d.ts +11 -0
- package/esm/color-picker/components/panel/swatches.js +134 -0
- package/esm/color-picker/components/panel/swatches.js.map +1 -0
- package/esm/color-picker/components/style/css.d.ts +1 -0
- package/esm/color-picker/components/style/index.d.ts +1 -0
- package/esm/color-picker/components/style/index.js +1 -0
- package/esm/color-picker/components/trigger.d.ts +9 -0
- package/esm/color-picker/components/trigger.js +125 -0
- package/esm/color-picker/components/trigger.js.map +1 -0
- package/esm/color-picker/const.d.ts +15 -0
- package/esm/color-picker/const.js +22 -0
- package/esm/color-picker/const.js.map +1 -0
- package/esm/color-picker/hooks/useClassname.d.ts +2 -0
- package/esm/color-picker/hooks/useClassname.js +46 -0
- package/esm/color-picker/hooks/useClassname.js.map +1 -0
- package/esm/color-picker/index.d.ts +10 -0
- package/esm/color-picker/index.js +182 -0
- package/esm/color-picker/index.js.map +1 -0
- package/esm/color-picker/interface.d.ts +23 -0
- package/esm/color-picker/interface.js +7 -0
- package/esm/color-picker/interface.js.map +1 -0
- package/esm/color-picker/style/css.d.ts +1 -0
- package/esm/color-picker/style/index.d.ts +1 -0
- package/esm/color-picker/style/index.js +1 -0
- package/esm/color-picker/type.d.ts +109 -0
- package/esm/color-picker/type.js +7 -0
- package/esm/color-picker/type.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +25 -1
- package/esm/index.js.map +1 -1
- package/esm/input/Input.js +1 -1
- package/esm/input/Input.js.map +1 -1
- package/esm/popup/hooks/useTriggerProps.js +28 -0
- package/esm/popup/hooks/useTriggerProps.js.map +1 -1
- package/lib/_chunks/{dep-1c7ceac8.js → dep-9d6a55ed.js} +1 -1
- package/lib/_chunks/{dep-1c7ceac8.js.map → dep-9d6a55ed.js.map} +1 -1
- package/lib/_common/js/color-picker/cmyk.d.ts +27 -0
- package/lib/_common/js/color-picker/color.d.ts +154 -0
- package/lib/_common/js/color-picker/gradient.d.ts +22 -0
- package/lib/_util/useClickOutside.d.ts +1 -1
- package/lib/_util/useClickOutside.js +47 -3
- package/lib/_util/useClickOutside.js.map +1 -1
- package/lib/_util/useDrag.d.ts +16 -0
- package/lib/_util/useDrag.js +78 -0
- package/lib/_util/useDrag.js.map +1 -0
- package/lib/avatar/AvararGroup.js +1 -1
- package/lib/avatar/Avatar.js +1 -1
- package/lib/avatar/index.js +1 -1
- package/lib/color-picker/ColorPicker.d.ts +4 -0
- package/lib/color-picker/ColorPicker.js +232 -0
- package/lib/color-picker/ColorPicker.js.map +1 -0
- package/lib/color-picker/ColorPickerPanel.d.ts +7 -0
- package/lib/color-picker/ColorPickerPanel.js +170 -0
- package/lib/color-picker/ColorPickerPanel.js.map +1 -0
- package/lib/color-picker/components/panel/alpha.d.ts +4 -0
- package/lib/color-picker/components/panel/alpha.js +57 -0
- package/lib/color-picker/components/panel/alpha.js.map +1 -0
- package/lib/color-picker/components/panel/format/config.d.ts +19 -0
- package/lib/color-picker/components/panel/format/config.js +95 -0
- package/lib/color-picker/components/panel/format/config.js.map +1 -0
- package/lib/color-picker/components/panel/format/index.d.ts +11 -0
- package/lib/color-picker/components/panel/format/index.js +189 -0
- package/lib/color-picker/components/panel/format/index.js.map +1 -0
- package/lib/color-picker/components/panel/format/inputs.d.ts +3 -0
- package/lib/color-picker/components/panel/format/inputs.js +220 -0
- package/lib/color-picker/components/panel/format/inputs.js.map +1 -0
- package/lib/color-picker/components/panel/header.d.ts +14 -0
- package/lib/color-picker/components/panel/header.js +103 -0
- package/lib/color-picker/components/panel/header.js.map +1 -0
- package/lib/color-picker/components/panel/hue.d.ts +4 -0
- package/lib/color-picker/components/panel/hue.js +40 -0
- package/lib/color-picker/components/panel/hue.js.map +1 -0
- package/lib/color-picker/components/panel/index.d.ts +4 -0
- package/lib/color-picker/components/panel/index.js +448 -0
- package/lib/color-picker/components/panel/index.js.map +1 -0
- package/lib/color-picker/components/panel/linear-gradient.d.ts +3 -0
- package/lib/color-picker/components/panel/linear-gradient.js +358 -0
- package/lib/color-picker/components/panel/linear-gradient.js.map +1 -0
- package/lib/color-picker/components/panel/saturation.d.ts +4 -0
- package/lib/color-picker/components/panel/saturation.js +132 -0
- package/lib/color-picker/components/panel/saturation.js.map +1 -0
- package/lib/color-picker/components/panel/slider.d.ts +10 -0
- package/lib/color-picker/components/panel/slider.js +115 -0
- package/lib/color-picker/components/panel/slider.js.map +1 -0
- package/lib/color-picker/components/panel/style/css.d.ts +1 -0
- package/lib/color-picker/components/panel/style/index.d.ts +1 -0
- package/lib/color-picker/components/panel/swatches.d.ts +11 -0
- package/lib/color-picker/components/panel/swatches.js +139 -0
- package/lib/color-picker/components/panel/swatches.js.map +1 -0
- package/lib/color-picker/components/style/css.d.ts +1 -0
- package/lib/color-picker/components/style/index.d.ts +1 -0
- package/lib/color-picker/components/trigger.d.ts +9 -0
- package/lib/color-picker/components/trigger.js +126 -0
- package/lib/color-picker/components/trigger.js.map +1 -0
- package/lib/color-picker/const.d.ts +15 -0
- package/lib/color-picker/const.js +35 -0
- package/lib/color-picker/const.js.map +1 -0
- package/lib/color-picker/hooks/useClassname.d.ts +2 -0
- package/lib/color-picker/hooks/useClassname.js +46 -0
- package/lib/color-picker/hooks/useClassname.js.map +1 -0
- package/lib/color-picker/index.d.ts +10 -0
- package/lib/color-picker/index.js +160 -0
- package/lib/color-picker/index.js.map +1 -0
- package/lib/color-picker/interface.d.ts +23 -0
- package/lib/color-picker/interface.js +9 -0
- package/lib/color-picker/interface.js.map +1 -0
- package/lib/color-picker/style/css.d.ts +1 -0
- package/lib/color-picker/style/index.d.ts +1 -0
- package/lib/color-picker/type.d.ts +109 -0
- package/lib/color-picker/type.js +9 -0
- package/lib/color-picker/type.js.map +1 -0
- package/lib/index-lib.js +25 -1
- package/lib/index-lib.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +25 -1
- package/lib/index.js.map +1 -1
- package/lib/input/Input.js +1 -1
- package/lib/input/Input.js.map +1 -1
- package/lib/popup/hooks/useTriggerProps.js +24 -0
- package/lib/popup/hooks/useTriggerProps.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdesign v0.31.1
|
|
3
|
+
* (c) 2022 tdesign
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { CloseIcon } from 'tdesign-icons-react';
|
|
10
|
+
import { COLOR_MODES } from '../../const.js';
|
|
11
|
+
import { Radio } from '../../../radio/index.js';
|
|
12
|
+
import '../../../_chunks/dep-07385e51.js';
|
|
13
|
+
import '../../../_chunks/dep-1628aaec.js';
|
|
14
|
+
import '../../../_util/forwardRefWithStatics.js';
|
|
15
|
+
import 'hoist-non-react-statics';
|
|
16
|
+
import '../../../common/Check.js';
|
|
17
|
+
import '../../../_chunks/dep-aca05d9d.js';
|
|
18
|
+
import '../../../_chunks/dep-85a9595a.js';
|
|
19
|
+
import '../../../_chunks/dep-ea842483.js';
|
|
20
|
+
import '../../../_util/helper.js';
|
|
21
|
+
import '../../../_chunks/dep-e0790d2e.js';
|
|
22
|
+
import '../../../_chunks/dep-8702aba9.js';
|
|
23
|
+
import '../../../_chunks/dep-020d9062.js';
|
|
24
|
+
import '../../../_chunks/dep-db8880c0.js';
|
|
25
|
+
import '../../../_chunks/dep-8efaaac0.js';
|
|
26
|
+
import '../../../_chunks/dep-ae52f85e.js';
|
|
27
|
+
import '../../../_chunks/dep-63ed508e.js';
|
|
28
|
+
import '../../../_chunks/dep-fd1b4e24.js';
|
|
29
|
+
import '../../../_chunks/dep-9b67144e.js';
|
|
30
|
+
import '../../../_chunks/dep-0d23bb2c.js';
|
|
31
|
+
import '../../../_chunks/dep-db65b23a.js';
|
|
32
|
+
import '../../../_util/useConfig.js';
|
|
33
|
+
import '../../../_chunks/dep-bbad8591.js';
|
|
34
|
+
import '../../../_chunks/dep-e9e7c24f.js';
|
|
35
|
+
import '../../../_chunks/dep-c47502ef.js';
|
|
36
|
+
import '../../../_chunks/dep-3a2f4bdf.js';
|
|
37
|
+
import '../../../_chunks/dep-d51fd958.js';
|
|
38
|
+
import '../../../_chunks/dep-d539b435.js';
|
|
39
|
+
import '../../../_chunks/dep-2b0021c1.js';
|
|
40
|
+
import '../../../_chunks/dep-09299e3f.js';
|
|
41
|
+
import '../../../_chunks/dep-23b2574f.js';
|
|
42
|
+
import '../../../_chunks/dep-a1403158.js';
|
|
43
|
+
import '../../../_chunks/dep-c03c5f48.js';
|
|
44
|
+
import '../../../_chunks/dep-d038aaf3.js';
|
|
45
|
+
import '../../../_chunks/dep-00728537.js';
|
|
46
|
+
import '../../../_chunks/dep-32abd81f.js';
|
|
47
|
+
import '../../../_chunks/dep-f3e5eb4b.js';
|
|
48
|
+
import '../../../_chunks/dep-155571ca.js';
|
|
49
|
+
import '../../../_chunks/dep-81670ae9.js';
|
|
50
|
+
import '../../../locale/zh_CN.js';
|
|
51
|
+
import '../../../_common/js/global-config/locale/zh_CN.js';
|
|
52
|
+
import '../../../config-provider/zh_CN_config.js';
|
|
53
|
+
import '../../../_util/useDefault.js';
|
|
54
|
+
import '../../../_util/noop.js';
|
|
55
|
+
import '../../../_util/useCommonClassName.js';
|
|
56
|
+
import '../../../_util/useMutationObserver.js';
|
|
57
|
+
import '../../../_chunks/dep-be94af1f.js';
|
|
58
|
+
import '../../../_chunks/dep-5e457cfd.js';
|
|
59
|
+
import '../../../radio/style/index.js';
|
|
60
|
+
import '../../../radio/type.js';
|
|
61
|
+
|
|
62
|
+
var Header = function Header(props) {
|
|
63
|
+
var baseClassName = props.baseClassName,
|
|
64
|
+
_props$mode = props.mode,
|
|
65
|
+
mode = _props$mode === void 0 ? "monochrome" : _props$mode,
|
|
66
|
+
colorModes = props.colorModes,
|
|
67
|
+
togglePopup = props.togglePopup,
|
|
68
|
+
_props$closeBtn = props.closeBtn,
|
|
69
|
+
closeBtn = _props$closeBtn === void 0 ? true : _props$closeBtn,
|
|
70
|
+
onModeChange = props.onModeChange;
|
|
71
|
+
|
|
72
|
+
var handleClosePopup = function handleClosePopup() {
|
|
73
|
+
togglePopup === null || togglePopup === void 0 ? void 0 : togglePopup(false);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
77
|
+
className: "".concat(baseClassName, "__head")
|
|
78
|
+
}, /* @__PURE__ */React.createElement("div", {
|
|
79
|
+
className: "".concat(baseClassName, "__mode")
|
|
80
|
+
}, (colorModes === null || colorModes === void 0 ? void 0 : colorModes.length) === 1 ? COLOR_MODES[colorModes[0]] : /* @__PURE__ */React.createElement(Radio.Group, {
|
|
81
|
+
variant: "default-filled",
|
|
82
|
+
size: "small",
|
|
83
|
+
value: mode,
|
|
84
|
+
onChange: onModeChange
|
|
85
|
+
}, Object.keys(COLOR_MODES).map(function (key) {
|
|
86
|
+
return /* @__PURE__ */React.createElement(Radio.Button, {
|
|
87
|
+
key: key,
|
|
88
|
+
value: key
|
|
89
|
+
}, COLOR_MODES[key]);
|
|
90
|
+
}))), closeBtn ? /* @__PURE__ */React.createElement("span", {
|
|
91
|
+
role: "button",
|
|
92
|
+
className: classNames("".concat(baseClassName, "__icon"), "".concat(baseClassName, "__close")),
|
|
93
|
+
onClick: handleClosePopup
|
|
94
|
+
}, /* @__PURE__ */React.createElement(CloseIcon, null)) : null);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var PanelHeader = /*#__PURE__*/React.memo(Header);
|
|
98
|
+
|
|
99
|
+
export { PanelHeader as default };
|
|
100
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","sources":["../../../../src/color-picker/components/panel/header.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { CloseIcon } from 'tdesign-icons-react';\nimport { COLOR_MODES } from '../../const';\nimport Radio, { RadioValue } from '../../../radio';\nimport { TdColorModes } from '../../interface';\nimport { TdColorPickerProps } from '../../type';\n\nexport interface ColorPanelHeaderProps extends TdColorPickerProps {\n mode?: TdColorModes;\n togglePopup?: Function;\n onModeChange?: (value: RadioValue, context: { e: React.ChangeEvent<HTMLInputElement> }) => void;\n baseClassName?: string;\n}\n\nconst Header = (props: ColorPanelHeaderProps) => {\n const { baseClassName, mode = 'monochrome', colorModes, togglePopup, closeBtn = true, onModeChange } = props;\n\n const handleClosePopup = () => {\n togglePopup?.(false);\n };\n\n return (\n <div className={`${baseClassName}__head`}>\n <div className={`${baseClassName}__mode`}>\n {colorModes?.length === 1 ? (\n COLOR_MODES[colorModes[0]]\n ) : (\n <Radio.Group variant=\"default-filled\" size=\"small\" value={mode} onChange={onModeChange}>\n {Object.keys(COLOR_MODES).map((key) => (\n <Radio.Button key={key} value={key}>\n {COLOR_MODES[key]}\n </Radio.Button>\n ))}\n </Radio.Group>\n )}\n </div>\n {closeBtn ? (\n <span\n role=\"button\"\n className={classNames(`${baseClassName}__icon`, `${baseClassName}__close`)}\n onClick={handleClosePopup}\n >\n <CloseIcon />\n </span>\n ) : null}\n </div>\n );\n};\n\nexport default React.memo(Header);\n"],"names":["Header","props","baseClassName","mode","colorModes","togglePopup","closeBtn","onModeChange","handleClosePopup","React","createElement","className","length","COLOR_MODES","Radio","Group","variant","size","value","onChange","Object","keys","map","key","Button","role","classNames","onClick","CloseIcon","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD,EAAW;AACxB,EAAA,IAAQC,aAAR,GAAuGD,KAAvG,CAAQC,aAAR;AAAA,MAAuGD,WAAAA,GAAAA,KAAvG,CAAuBE,IAAvB;AAAA,MAAuBA,IAAvB,4BAA8B,YAA9B,GAAA,WAAA;AAAA,MAA4CC,UAA5C,GAAuGH,KAAvG,CAA4CG,UAA5C;AAAA,MAAwDC,WAAxD,GAAuGJ,KAAvG,CAAwDI,WAAxD;AAAA,MAAuGJ,eAAAA,GAAAA,KAAvG,CAAqEK,QAArE;AAAA,MAAqEA,QAArE,gCAAgF,IAAhF,GAAA,eAAA;AAAA,MAAsFC,YAAtF,GAAuGN,KAAvG,CAAsFM,YAAtF,CAAA;;AACA,EAAA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,GAAM;AAC7BH,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,GAAAA,KAAAA,CAAAA,GAAAA,WAAW,CAAG,KAAH,CAAX,CAAA;AACD,GAFD,CAAA;;AAGA,EAAA,sBAAuBI,KAAK,CAACC,aAAN,CAAoB,KAApB,EAA2B;AAChDC,IAAAA,SAAS,YAAKT,aAAL,EAAA,QAAA,CAAA;AADuC,GAA3B,iBAEJO,KAAK,CAACC,aAAN,CAAoB,KAApB,EAA2B;AAC5CC,IAAAA,SAAS,YAAKT,aAAL,EAAA,QAAA,CAAA;AADmC,GAA3B,EAEhB,CAAAE,UAAU,KAAA,IAAV,IAAAA,UAAU,KAAV,KAAA,CAAA,GAAA,KAAA,CAAA,GAAAA,UAAU,CAAEQ,MAAZ,MAAuB,CAAvB,GAA2BC,WAAW,CAACT,UAAU,CAAC,CAAD,CAAX,CAAtC,kBAAwEK,KAAK,CAACC,aAAN,CAAoBI,KAAK,CAACC,KAA1B,EAAiC;AAC1GC,IAAAA,OAAO,EAAE,gBADiG;AAE1GC,IAAAA,IAAI,EAAE,OAFoG;AAG1GC,IAAAA,KAAK,EAAEf,IAHmG;AAI1GgB,IAAAA,QAAQ,EAAEZ,YAAAA;AAJgG,GAAjC,EAKxEa,MAAM,CAACC,IAAP,CAAYR,WAAZ,CAAyBS,CAAAA,GAAzB,CAA6B,UAACC,GAAD,EAAA;AAAA,IAAS,sBAAgBd,KAAK,CAACC,aAAN,CAAoBI,KAAK,CAACU,MAA1B,EAAkC;AACzFD,MAAAA,GAAG,EAAHA,GADyF;AAEzFL,MAAAA,KAAK,EAAEK,GAAAA;AAFkF,KAAlC,EAGtDV,WAAW,CAACU,GAAD,CAH2C,CAAzB,CAAA;AAAA,GAA7B,CALwE,CAFxD,CAFI,EAYEjB,QAAQ,kBAAmBG,KAAK,CAACC,aAAN,CAAoB,MAApB,EAA4B;AAC9Ee,IAAAA,IAAI,EAAE,QADwE;AAE9Ed,IAAAA,SAAS,EAAEe,UAAU,WAAIxB,aAAJ,EAAA,QAAA,CAAA,EAAA,EAAA,CAAA,MAAA,CAA8BA,aAA9B,EAFyD,SAAA,CAAA,CAAA;AAG9EyB,IAAAA,OAAO,EAAEnB,gBAAAA;AAHqE,GAA5B,iBAIjCC,KAAK,CAACC,aAAN,CAAoBkB,SAApB,EAA+B,IAA/B,CAJiC,CAAnB,GAI0B,IAhBpC,CAAvB,CAAA;AAiBD,CAtBD,CAAA;;AAuBA,kBAAA,aAAenB,KAAK,CAACoB,IAAN,CAAW7B,MAAX,CAAf;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdesign v0.31.1
|
|
3
|
+
* (c) 2022 tdesign
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import ColorSlider from './slider.js';
|
|
9
|
+
import '../../../_chunks/dep-1628aaec.js';
|
|
10
|
+
import 'classnames';
|
|
11
|
+
import '../../const.js';
|
|
12
|
+
import '../../../_util/useDrag.js';
|
|
13
|
+
|
|
14
|
+
var HUESlider = function HUESlider(props) {
|
|
15
|
+
var color = props.color,
|
|
16
|
+
baseClassName = props.baseClassName,
|
|
17
|
+
disabled = props.disabled,
|
|
18
|
+
onChange = props.onChange;
|
|
19
|
+
return /* @__PURE__ */React.createElement(ColorSlider, {
|
|
20
|
+
disabled: disabled,
|
|
21
|
+
baseClassName: baseClassName,
|
|
22
|
+
className: "".concat(baseClassName, "__hue"),
|
|
23
|
+
color: color,
|
|
24
|
+
value: color.hue,
|
|
25
|
+
onChange: onChange
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var HUESlider$1 = /*#__PURE__*/React.memo(HUESlider);
|
|
30
|
+
|
|
31
|
+
export { HUESlider$1 as default };
|
|
32
|
+
//# sourceMappingURL=hue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hue.js","sources":["../../../../src/color-picker/components/panel/hue.tsx"],"sourcesContent":["import React from 'react';\nimport ColorSlider from './slider';\nimport { TdColorBaseProps } from '../../interface';\n\nconst HUESlider = (props: TdColorBaseProps) => {\n const { color, baseClassName, disabled, onChange } = props;\n return (\n <ColorSlider\n disabled={disabled}\n baseClassName={baseClassName}\n className={`${baseClassName}__hue`}\n color={color}\n value={color.hue}\n onChange={onChange}\n />\n );\n};\n\nexport default React.memo(HUESlider);\n"],"names":["HUESlider","props","color","baseClassName","disabled","onChange","React","createElement","ColorSlider","className","value","hue","memo"],"mappings":";;;;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD,EAAW;AAC3B,EAAA,IAAQC,KAAR,GAAqDD,KAArD,CAAQC,KAAR;AAAA,MAAeC,aAAf,GAAqDF,KAArD,CAAeE,aAAf;AAAA,MAA8BC,QAA9B,GAAqDH,KAArD,CAA8BG,QAA9B;AAAA,MAAwCC,QAAxC,GAAqDJ,KAArD,CAAwCI,QAAxC,CAAA;AACA,EAAA,sBAAuBC,KAAK,CAACC,aAAN,CAAoBC,WAApB,EAAiC;AACtDJ,IAAAA,QAAQ,EAARA,QADsD;AAEtDD,IAAAA,aAAa,EAAbA,aAFsD;AAGtDM,IAAAA,SAAS,EAAKN,EAAAA,CAAAA,MAAAA,CAAAA,aAAL,EAH6C,OAAA,CAAA;AAItDD,IAAAA,KAAK,EAALA,KAJsD;AAKtDQ,IAAAA,KAAK,EAAER,KAAK,CAACS,GALyC;AAMtDN,IAAAA,QAAQ,EAARA,QAAAA;AANsD,GAAjC,CAAvB,CAAA;AAQD,CAVD,CAAA;;AAWA,kBAAA,aAAeC,KAAK,CAACM,IAAN,CAAWZ,SAAX,CAAf;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ColorPickerProps } from '../../interface';
|
|
3
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<ColorPickerProps, "value" | "style" | "className" | "disabled" | "multiple" | "defaultValue" | "format" | "onChange" | "popupProps" | "inputProps" | "selectInputProps" | "closeBtn" | "togglePopup" | "colorModes" | "enableAlpha" | "recentColors" | "defaultRecentColors" | "swatchColors" | "onPaletteBarChange" | "onRecentColorsChange"> & React.RefAttributes<HTMLDivElement>>>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdesign v0.31.1
|
|
3
|
+
* (c) 2022 tdesign
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { _ as _defineProperty } from '../../../_chunks/dep-1628aaec.js';
|
|
8
|
+
import { _ as _toConsumableArray } from '../../../_chunks/dep-3cf23cb4.js';
|
|
9
|
+
import { _ as _slicedToArray } from '../../../_chunks/dep-aca05d9d.js';
|
|
10
|
+
import React, { forwardRef, useRef, useEffect, useState } from 'react';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import useCommonClassName from '../../../_util/useCommonClassName.js';
|
|
13
|
+
import useDefault from '../../../_util/useDefault.js';
|
|
14
|
+
import { useLocaleReceiver } from '../../../locale/LocalReceiver.js';
|
|
15
|
+
import useClassname from '../../hooks/useClassname.js';
|
|
16
|
+
import PanelHeader from './header.js';
|
|
17
|
+
import { Color, getColorObject } from '../../../_common/js/color-picker/color.js';
|
|
18
|
+
import { DEFAULT_COLOR, DEFAULT_LINEAR_GRADIENT, TD_COLOR_USED_COLORS_MAX_SIZE, DEFAULT_SYSTEM_SWATCH_COLORS } from '../../const.js';
|
|
19
|
+
import LinearGradient from './linear-gradient.js';
|
|
20
|
+
import SaturationPanel from './saturation.js';
|
|
21
|
+
import HUESlider from './hue.js';
|
|
22
|
+
import AlphaSlider from './alpha.js';
|
|
23
|
+
import FormatPanel from './format/index.js';
|
|
24
|
+
import SwatchesPanel from './swatches.js';
|
|
25
|
+
import '../../../_chunks/dep-85a9595a.js';
|
|
26
|
+
import '../../../_util/useConfig.js';
|
|
27
|
+
import '../../../_chunks/dep-bbad8591.js';
|
|
28
|
+
import '../../../_chunks/dep-8702aba9.js';
|
|
29
|
+
import '../../../_chunks/dep-e9e7c24f.js';
|
|
30
|
+
import '../../../_chunks/dep-c47502ef.js';
|
|
31
|
+
import '../../../_chunks/dep-3a2f4bdf.js';
|
|
32
|
+
import '../../../_chunks/dep-d51fd958.js';
|
|
33
|
+
import '../../../_chunks/dep-db8880c0.js';
|
|
34
|
+
import '../../../_chunks/dep-8efaaac0.js';
|
|
35
|
+
import '../../../_chunks/dep-d539b435.js';
|
|
36
|
+
import '../../../_chunks/dep-2b0021c1.js';
|
|
37
|
+
import '../../../_chunks/dep-09299e3f.js';
|
|
38
|
+
import '../../../_chunks/dep-23b2574f.js';
|
|
39
|
+
import '../../../_chunks/dep-a1403158.js';
|
|
40
|
+
import '../../../_chunks/dep-c03c5f48.js';
|
|
41
|
+
import '../../../_chunks/dep-9b67144e.js';
|
|
42
|
+
import '../../../_chunks/dep-d038aaf3.js';
|
|
43
|
+
import '../../../_chunks/dep-00728537.js';
|
|
44
|
+
import '../../../_chunks/dep-32abd81f.js';
|
|
45
|
+
import '../../../_chunks/dep-f3e5eb4b.js';
|
|
46
|
+
import '../../../_chunks/dep-ae52f85e.js';
|
|
47
|
+
import '../../../_chunks/dep-63ed508e.js';
|
|
48
|
+
import '../../../_chunks/dep-155571ca.js';
|
|
49
|
+
import '../../../_chunks/dep-81670ae9.js';
|
|
50
|
+
import '../../../locale/zh_CN.js';
|
|
51
|
+
import '../../../_common/js/global-config/locale/zh_CN.js';
|
|
52
|
+
import '../../../config-provider/zh_CN_config.js';
|
|
53
|
+
import '../../../_util/noop.js';
|
|
54
|
+
import '../../../config-provider/index.js';
|
|
55
|
+
import '../../../config-provider/ConfigProvider.js';
|
|
56
|
+
import 'tdesign-icons-react';
|
|
57
|
+
import '../../../radio/index.js';
|
|
58
|
+
import '../../../_chunks/dep-07385e51.js';
|
|
59
|
+
import '../../../_util/forwardRefWithStatics.js';
|
|
60
|
+
import 'hoist-non-react-statics';
|
|
61
|
+
import '../../../common/Check.js';
|
|
62
|
+
import '../../../_chunks/dep-ea842483.js';
|
|
63
|
+
import '../../../_util/helper.js';
|
|
64
|
+
import '../../../_chunks/dep-e0790d2e.js';
|
|
65
|
+
import '../../../_chunks/dep-020d9062.js';
|
|
66
|
+
import '../../../_chunks/dep-fd1b4e24.js';
|
|
67
|
+
import '../../../_chunks/dep-0d23bb2c.js';
|
|
68
|
+
import '../../../_chunks/dep-db65b23a.js';
|
|
69
|
+
import '../../../_util/useMutationObserver.js';
|
|
70
|
+
import '../../../_chunks/dep-be94af1f.js';
|
|
71
|
+
import '../../../_chunks/dep-5e457cfd.js';
|
|
72
|
+
import '../../../radio/style/index.js';
|
|
73
|
+
import '../../../radio/type.js';
|
|
74
|
+
import '../../../_chunks/dep-926c2765.js';
|
|
75
|
+
import 'tinycolor2';
|
|
76
|
+
import '../../../_common/js/color-picker/cmyk.js';
|
|
77
|
+
import '../../../_common/js/color-picker/gradient.js';
|
|
78
|
+
import '../../../_chunks/dep-9926d76f.js';
|
|
79
|
+
import '../../../_chunks/dep-cdbc448f.js';
|
|
80
|
+
import '../../../_chunks/dep-d17dffc0.js';
|
|
81
|
+
import '../../../_chunks/dep-6bf856c2.js';
|
|
82
|
+
import '../../../_chunks/dep-d820193b.js';
|
|
83
|
+
import '../../../input-number/index.js';
|
|
84
|
+
import '../../../input-number/InputNumber.js';
|
|
85
|
+
import '../../../_util/useUpdateEffect.js';
|
|
86
|
+
import '../../../_util/useLayoutEffect.js';
|
|
87
|
+
import '../../../_util/dom.js';
|
|
88
|
+
import 'raf';
|
|
89
|
+
import '../../../_chunks/dep-c9e242b1.js';
|
|
90
|
+
import '../../../_util/easing.js';
|
|
91
|
+
import '../../../input-number/StepHandler.js';
|
|
92
|
+
import '../../../button/index.js';
|
|
93
|
+
import '../../../button/Button.js';
|
|
94
|
+
import '../../../_util/useRipple.js';
|
|
95
|
+
import '../../../_util/useAnimation.js';
|
|
96
|
+
import '../../../_util/setStyle.js';
|
|
97
|
+
import '../../../loading/index.js';
|
|
98
|
+
import '../../../loading/Loading.js';
|
|
99
|
+
import '../../../common/Portal.js';
|
|
100
|
+
import 'react-dom';
|
|
101
|
+
import '../../../loading/gradient.js';
|
|
102
|
+
import '../../../_common/js/loading/circle-adapter.js';
|
|
103
|
+
import '../../../_common/js/utils/set-style.js';
|
|
104
|
+
import '../../../_common/js/utils/helper.js';
|
|
105
|
+
import '../../../loading/plugin.js';
|
|
106
|
+
import '../../../loading/style/index.js';
|
|
107
|
+
import '../../../loading/type.js';
|
|
108
|
+
import '../../../button/style/index.js';
|
|
109
|
+
import '../../../button/type.js';
|
|
110
|
+
import '../../../input-number/utils/numberUtils.js';
|
|
111
|
+
import '../../../input/index.js';
|
|
112
|
+
import '../../../input/Input.js';
|
|
113
|
+
import '../../../input/InputGroup.js';
|
|
114
|
+
import '../../../_util/useDefaultValue.js';
|
|
115
|
+
import '../../../input/style/index.js';
|
|
116
|
+
import '../../../input/type.js';
|
|
117
|
+
import '../../../input-number/style/index.js';
|
|
118
|
+
import '../../../input-number/type.js';
|
|
119
|
+
import '../../../_util/useDrag.js';
|
|
120
|
+
import './slider.js';
|
|
121
|
+
import 'lodash';
|
|
122
|
+
import '../../../select/index.js';
|
|
123
|
+
import '../../../select/base/Select.js';
|
|
124
|
+
import '../../../_chunks/dep-83cb7911.js';
|
|
125
|
+
import '../../../_chunks/dep-83177e8d.js';
|
|
126
|
+
import '../../../select/util/helper.js';
|
|
127
|
+
import '../../../select/base/OptionGroup.js';
|
|
128
|
+
import '../../../select/base/Option.js';
|
|
129
|
+
import '../../../_chunks/dep-cf0a5e4d.js';
|
|
130
|
+
import '../../../common/FakeArrow.js';
|
|
131
|
+
import '../../../select-input/index.js';
|
|
132
|
+
import '../../../select-input/SelectInput.js';
|
|
133
|
+
import '../../../popup/index.js';
|
|
134
|
+
import '../../../popup/Popup.js';
|
|
135
|
+
import 'react-transition-group';
|
|
136
|
+
import 'react-popper';
|
|
137
|
+
import '../../../_util/composeRefs.js';
|
|
138
|
+
import '../../../popup/hooks/useTriggerProps.js';
|
|
139
|
+
import '../../../_util/useClickOutside.js';
|
|
140
|
+
import '../../../popup/utils/getTransitionParams.js';
|
|
141
|
+
import '../../../_util/useWindowSize.js';
|
|
142
|
+
import '../../../popup/style/index.js';
|
|
143
|
+
import '../../../popup/type.js';
|
|
144
|
+
import '../../../select-input/useSingle.js';
|
|
145
|
+
import '../../../_chunks/dep-41ddaf4d.js';
|
|
146
|
+
import '../../../_chunks/dep-3ce0d185.js';
|
|
147
|
+
import '../../../_chunks/dep-b1d1fc8a.js';
|
|
148
|
+
import '../../../_chunks/dep-65dde75f.js';
|
|
149
|
+
import '../../../select-input/useMultiple.js';
|
|
150
|
+
import '../../../tag-input/index.js';
|
|
151
|
+
import '../../../tag-input/TagInput.js';
|
|
152
|
+
import '../../../_util/useDragSorter.js';
|
|
153
|
+
import '../../../tag-input/useTagScroll.js';
|
|
154
|
+
import '../../../tag-input/useTagList.js';
|
|
155
|
+
import '../../../tag/index.js';
|
|
156
|
+
import '../../../tag/Tag.js';
|
|
157
|
+
import '../../../tag/CheckTag.js';
|
|
158
|
+
import '../../../tag/style/index.js';
|
|
159
|
+
import '../../../tag/type.js';
|
|
160
|
+
import '../../../tag-input/useHover.js';
|
|
161
|
+
import '../../../tag-input/style/index.js';
|
|
162
|
+
import '../../../tag-input/type.js';
|
|
163
|
+
import '../../../select-input/useOverlayStyle.js';
|
|
164
|
+
import '../../../select-input/style/index.js';
|
|
165
|
+
import '../../../select-input/type.js';
|
|
166
|
+
import '../../../select/base/PopupContent.js';
|
|
167
|
+
import '../../../select/style/index.js';
|
|
168
|
+
import '../../../select/type.js';
|
|
169
|
+
import './format/inputs.js';
|
|
170
|
+
import './format/config.js';
|
|
171
|
+
|
|
172
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
173
|
+
|
|
174
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
175
|
+
var Panel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
176
|
+
var baseClassName = useClassname();
|
|
177
|
+
|
|
178
|
+
var _useCommonClassName = useCommonClassName(),
|
|
179
|
+
STATUS = _useCommonClassName.STATUS;
|
|
180
|
+
|
|
181
|
+
var _useLocaleReceiver = useLocaleReceiver("colorPicker"),
|
|
182
|
+
_useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 2),
|
|
183
|
+
local = _useLocaleReceiver2[0],
|
|
184
|
+
t = _useLocaleReceiver2[1];
|
|
185
|
+
|
|
186
|
+
var disabled = props.disabled,
|
|
187
|
+
value = props.value,
|
|
188
|
+
defaultValue = props.defaultValue,
|
|
189
|
+
onChange = props.onChange,
|
|
190
|
+
_props$enableAlpha = props.enableAlpha,
|
|
191
|
+
enableAlpha = _props$enableAlpha === void 0 ? false : _props$enableAlpha,
|
|
192
|
+
format = props.format,
|
|
193
|
+
onPaletteBarChange = props.onPaletteBarChange,
|
|
194
|
+
swatchColors = props.swatchColors,
|
|
195
|
+
className = props.className,
|
|
196
|
+
_props$style = props.style,
|
|
197
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
198
|
+
togglePopup = props.togglePopup,
|
|
199
|
+
closeBtn = props.closeBtn,
|
|
200
|
+
_props$colorModes = props.colorModes,
|
|
201
|
+
colorModes = _props$colorModes === void 0 ? ["linear-gradient", "monochrome"] : _props$colorModes;
|
|
202
|
+
|
|
203
|
+
var _useDefault = useDefault(value, defaultValue, onChange),
|
|
204
|
+
_useDefault2 = _slicedToArray(_useDefault, 2),
|
|
205
|
+
innerValue = _useDefault2[0],
|
|
206
|
+
setInnerValue = _useDefault2[1];
|
|
207
|
+
|
|
208
|
+
var colorInstanceRef = useRef(new Color(innerValue || DEFAULT_COLOR));
|
|
209
|
+
useEffect(function () {
|
|
210
|
+
colorInstanceRef.current.update(defaultValue || DEFAULT_COLOR);
|
|
211
|
+
}, [defaultValue]);
|
|
212
|
+
var getmodeByColor = colorInstanceRef.current.isGradient ? "linear-gradient" : "monochrome";
|
|
213
|
+
|
|
214
|
+
var _useState = useState("monochrome"),
|
|
215
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
216
|
+
mode = _useState2[0],
|
|
217
|
+
setMode = _useState2[1];
|
|
218
|
+
|
|
219
|
+
useEffect(function () {
|
|
220
|
+
if (colorModes.length === 1) {
|
|
221
|
+
setMode(colorModes[0]);
|
|
222
|
+
} else {
|
|
223
|
+
setMode(getmodeByColor);
|
|
224
|
+
}
|
|
225
|
+
}, [colorModes, getmodeByColor]);
|
|
226
|
+
var formatRef = useRef(colorInstanceRef.current.isGradient ? "CSS" : "RGB");
|
|
227
|
+
var recentColors = props.recentColors,
|
|
228
|
+
defaultRecentColors = props.defaultRecentColors,
|
|
229
|
+
onRecentColorsChange = props.onRecentColorsChange;
|
|
230
|
+
|
|
231
|
+
var _useDefault3 = useDefault(recentColors, defaultRecentColors, onRecentColorsChange),
|
|
232
|
+
_useDefault4 = _slicedToArray(_useDefault3, 2),
|
|
233
|
+
recentlyUsedColors = _useDefault4[0],
|
|
234
|
+
setRecentlyUsedColors = _useDefault4[1];
|
|
235
|
+
|
|
236
|
+
var baseProps = {
|
|
237
|
+
color: colorInstanceRef.current,
|
|
238
|
+
disabled: disabled,
|
|
239
|
+
baseClassName: baseClassName
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
var handleModeChange = function handleModeChange(value2) {
|
|
243
|
+
setMode(value2);
|
|
244
|
+
var _colorInstanceRef$cur = colorInstanceRef.current,
|
|
245
|
+
rgba = _colorInstanceRef$cur.rgba,
|
|
246
|
+
gradientColors = _colorInstanceRef$cur.gradientColors,
|
|
247
|
+
linearGradient = _colorInstanceRef$cur.linearGradient;
|
|
248
|
+
|
|
249
|
+
if (value2 === "linear-gradient") {
|
|
250
|
+
colorInstanceRef.current = new Color(gradientColors.length > 0 ? linearGradient : DEFAULT_LINEAR_GRADIENT);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
colorInstanceRef.current = new Color(rgba);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
var formatValue = function formatValue() {
|
|
258
|
+
if (mode === "linear-gradient") {
|
|
259
|
+
return colorInstanceRef.current.linearGradient;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return colorInstanceRef.current.getFormatsColorMap()[format] || colorInstanceRef.current.css;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
var handleRecentlyUsedColorsChange = function handleRecentlyUsedColorsChange(colors) {
|
|
266
|
+
setRecentlyUsedColors(colors);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
var addRecentlyUsedColor = function addRecentlyUsedColor() {
|
|
270
|
+
if (recentlyUsedColors === null || recentlyUsedColors === false) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var colors = _toConsumableArray(recentlyUsedColors || []);
|
|
275
|
+
|
|
276
|
+
var _colorInstanceRef$cur2 = colorInstanceRef.current,
|
|
277
|
+
isGradient = _colorInstanceRef$cur2.isGradient,
|
|
278
|
+
linearGradient = _colorInstanceRef$cur2.linearGradient,
|
|
279
|
+
rgba = _colorInstanceRef$cur2.rgba;
|
|
280
|
+
var currentColor = isGradient ? linearGradient : rgba;
|
|
281
|
+
var index = colors.indexOf(currentColor);
|
|
282
|
+
|
|
283
|
+
if (index > -1) {
|
|
284
|
+
colors.splice(index, 1);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
colors.unshift(currentColor);
|
|
288
|
+
|
|
289
|
+
if (colors.length > TD_COLOR_USED_COLORS_MAX_SIZE) {
|
|
290
|
+
colors.length = TD_COLOR_USED_COLORS_MAX_SIZE;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
handleRecentlyUsedColorsChange(colors);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
var emitColorChange = function emitColorChange(trigger) {
|
|
297
|
+
setInnerValue(formatValue(), {
|
|
298
|
+
color: getColorObject(colorInstanceRef.current),
|
|
299
|
+
trigger: trigger || "palette-saturation-brightness"
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
var handleSaturationChange = function handleSaturationChange(_ref) {
|
|
304
|
+
var saturation = _ref.saturation,
|
|
305
|
+
value2 = _ref.value;
|
|
306
|
+
var _colorInstanceRef$cur3 = colorInstanceRef.current,
|
|
307
|
+
sat = _colorInstanceRef$cur3.saturation,
|
|
308
|
+
val = _colorInstanceRef$cur3.value;
|
|
309
|
+
var changeTrigger = "palette-saturation-brightness";
|
|
310
|
+
colorInstanceRef.current.saturation = saturation;
|
|
311
|
+
colorInstanceRef.current.value = value2;
|
|
312
|
+
|
|
313
|
+
if (value2 !== val && saturation !== sat) {
|
|
314
|
+
changeTrigger = "palette-saturation-brightness";
|
|
315
|
+
} else if (saturation !== sat) {
|
|
316
|
+
changeTrigger = "palette-saturation";
|
|
317
|
+
} else if (value2 !== val) {
|
|
318
|
+
changeTrigger = "palette-brightness";
|
|
319
|
+
} else {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
emitColorChange(changeTrigger);
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
var handleHUEChange = function handleHUEChange(hue) {
|
|
327
|
+
colorInstanceRef.current.hue = hue;
|
|
328
|
+
emitColorChange("palette-hue-bar");
|
|
329
|
+
onPaletteBarChange === null || onPaletteBarChange === void 0 ? void 0 : onPaletteBarChange({
|
|
330
|
+
color: getColorObject(colorInstanceRef.current)
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
var handleAlphaChange = function handleAlphaChange(alpha) {
|
|
335
|
+
colorInstanceRef.current.alpha = alpha;
|
|
336
|
+
emitColorChange("palette-alpha-bar");
|
|
337
|
+
onPaletteBarChange === null || onPaletteBarChange === void 0 ? void 0 : onPaletteBarChange({
|
|
338
|
+
color: getColorObject(colorInstanceRef.current)
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
var handleGradientChange = function handleGradientChange(_ref2) {
|
|
343
|
+
var key = _ref2.key,
|
|
344
|
+
payload = _ref2.payload;
|
|
345
|
+
var trigger = "palette-saturation-brightness";
|
|
346
|
+
|
|
347
|
+
switch (key) {
|
|
348
|
+
case "degree":
|
|
349
|
+
colorInstanceRef.current.gradientDegree = payload;
|
|
350
|
+
trigger = "input";
|
|
351
|
+
break;
|
|
352
|
+
|
|
353
|
+
case "selectedId":
|
|
354
|
+
colorInstanceRef.current.gradientSelectedId = payload;
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
case "colors":
|
|
358
|
+
colorInstanceRef.current.gradientColors = payload;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
emitColorChange(trigger);
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
var handleFormatModeChange = function handleFormatModeChange(format2) {
|
|
366
|
+
return formatRef.current = format2;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
var handleInputChange = function handleInputChange(input, alpha) {
|
|
370
|
+
colorInstanceRef.current.update(input);
|
|
371
|
+
colorInstanceRef.current.alpha = alpha;
|
|
372
|
+
emitColorChange("input");
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
var SwatchesArea = /*#__PURE__*/React.memo(function () {
|
|
376
|
+
var _systemColors;
|
|
377
|
+
|
|
378
|
+
var showUsedColors = recentColors !== null && recentColors !== false;
|
|
379
|
+
var systemColors = swatchColors;
|
|
380
|
+
|
|
381
|
+
if (systemColors === void 0) {
|
|
382
|
+
systemColors = _toConsumableArray(DEFAULT_SYSTEM_SWATCH_COLORS);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
var showSystemColors = ((_systemColors = systemColors) === null || _systemColors === void 0 ? void 0 : _systemColors.length) > 0;
|
|
386
|
+
|
|
387
|
+
if (!showSystemColors && !showUsedColors) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
var handleSetColor = function handleSetColor(value2) {
|
|
392
|
+
var isGradientValue = Color.isGradientColor(value2);
|
|
393
|
+
var color = colorInstanceRef.current;
|
|
394
|
+
|
|
395
|
+
if (isGradientValue) {
|
|
396
|
+
if (colorModes.includes("linear-gradient")) {
|
|
397
|
+
setMode("linear-gradient");
|
|
398
|
+
color.update(value2);
|
|
399
|
+
color.updateCurrentGradientColor();
|
|
400
|
+
} else {
|
|
401
|
+
console.warn("\u8BE5\u6A21\u5F0F\u4E0D\u652F\u6301\u6E10\u53D8\u8272");
|
|
402
|
+
}
|
|
403
|
+
} else if (mode === "linear-gradient") {
|
|
404
|
+
color.updateStates(value2);
|
|
405
|
+
color.updateCurrentGradientColor();
|
|
406
|
+
} else {
|
|
407
|
+
color.update(value2);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
emitColorChange();
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement("div", {
|
|
414
|
+
className: "".concat(baseClassName, "__swatches-wrap")
|
|
415
|
+
}, showUsedColors && /* @__PURE__ */React.createElement(SwatchesPanel, _objectSpread(_objectSpread({}, baseProps), {}, {
|
|
416
|
+
title: t(local.recentColorTitle),
|
|
417
|
+
editable: true,
|
|
418
|
+
handleAddColor: addRecentlyUsedColor,
|
|
419
|
+
colors: recentlyUsedColors,
|
|
420
|
+
onSetColor: function onSetColor(color) {
|
|
421
|
+
return handleSetColor(color);
|
|
422
|
+
},
|
|
423
|
+
onChange: handleRecentlyUsedColorsChange
|
|
424
|
+
})), showSystemColors && /* @__PURE__ */React.createElement(SwatchesPanel, _objectSpread(_objectSpread({}, baseProps), {}, {
|
|
425
|
+
title: t(local.swatchColorTitle),
|
|
426
|
+
colors: systemColors,
|
|
427
|
+
onSetColor: function onSetColor(color) {
|
|
428
|
+
return handleSetColor(color);
|
|
429
|
+
}
|
|
430
|
+
}))));
|
|
431
|
+
});
|
|
432
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
433
|
+
className: classNames("".concat(baseClassName, "__panel"), disabled ? STATUS.disabled : false, className),
|
|
434
|
+
onClick: function onClick(e) {
|
|
435
|
+
return e.stopPropagation();
|
|
436
|
+
},
|
|
437
|
+
style: _objectSpread({}, style),
|
|
438
|
+
ref: ref
|
|
439
|
+
}, /* @__PURE__ */React.createElement(PanelHeader, {
|
|
440
|
+
baseClassName: baseClassName,
|
|
441
|
+
mode: mode,
|
|
442
|
+
colorModes: colorModes,
|
|
443
|
+
closeBtn: closeBtn,
|
|
444
|
+
togglePopup: togglePopup,
|
|
445
|
+
onModeChange: handleModeChange
|
|
446
|
+
}), /* @__PURE__ */React.createElement("div", {
|
|
447
|
+
className: "".concat(baseClassName, "__body")
|
|
448
|
+
}, mode === "linear-gradient" && /* @__PURE__ */React.createElement(LinearGradient, _objectSpread(_objectSpread({}, baseProps), {}, {
|
|
449
|
+
onChange: handleGradientChange
|
|
450
|
+
})), /* @__PURE__ */React.createElement(SaturationPanel, _objectSpread(_objectSpread({}, baseProps), {}, {
|
|
451
|
+
onChange: handleSaturationChange
|
|
452
|
+
})), /* @__PURE__ */React.createElement(HUESlider, _objectSpread(_objectSpread({}, baseProps), {}, {
|
|
453
|
+
onChange: handleHUEChange
|
|
454
|
+
})), enableAlpha && /* @__PURE__ */React.createElement(AlphaSlider, _objectSpread(_objectSpread({}, baseProps), {}, {
|
|
455
|
+
onChange: handleAlphaChange
|
|
456
|
+
})), /* @__PURE__ */React.createElement(FormatPanel, _objectSpread(_objectSpread(_objectSpread({}, props), baseProps), {}, {
|
|
457
|
+
format: formatRef.current,
|
|
458
|
+
onModeChange: handleFormatModeChange,
|
|
459
|
+
onInputChange: handleInputChange
|
|
460
|
+
})), /* @__PURE__ */React.createElement(SwatchesArea, null)));
|
|
461
|
+
});
|
|
462
|
+
var ColorPanel = /*#__PURE__*/React.memo(Panel);
|
|
463
|
+
|
|
464
|
+
export { ColorPanel as default };
|
|
465
|
+
//# sourceMappingURL=index.js.map
|