assui 2.1.55 → 2.2.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/es/color-select/index.d.ts +23 -0
- package/es/color-select/index.js +106 -0
- package/es/color-select/style/index.css +1821 -0
- package/es/color-select/style/index.d.ts +2 -0
- package/es/color-select/style/index.js +2 -0
- package/es/color-select/style/index.less +46 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +2 -0
- package/es/messages/en_US.d.ts +3 -0
- package/es/messages/en_US.js +3 -0
- package/es/messages/index.d.ts +7 -2
- package/es/messages/zh_CN.d.ts +3 -0
- package/es/messages/zh_CN.js +3 -0
- package/es/picker-with-type/index.d.ts +2 -0
- package/es/picker-with-type/index.js +63 -0
- package/es/picker-with-type/style/index.d.ts +3 -0
- package/es/picker-with-type/style/index.js +3 -0
- package/lib/color-select/index.d.ts +23 -0
- package/lib/color-select/index.js +165 -0
- package/lib/color-select/style/index.css +1821 -0
- package/lib/color-select/style/index.d.ts +2 -0
- package/lib/color-select/style/index.js +9 -0
- package/lib/color-select/style/index.less +46 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +19 -1
- package/lib/messages/en_US.d.ts +3 -0
- package/lib/messages/en_US.js +3 -0
- package/lib/messages/index.d.ts +7 -2
- package/lib/messages/zh_CN.d.ts +3 -0
- package/lib/messages/zh_CN.js +3 -0
- package/lib/picker-with-type/index.d.ts +2 -0
- package/lib/picker-with-type/index.js +118 -0
- package/lib/picker-with-type/style/index.d.ts +3 -0
- package/lib/picker-with-type/style/index.js +11 -0
- package/package.json +6 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SketchPickerProps } from 'react-color';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { TriggerProps } from 'rc-trigger';
|
|
4
|
+
export declare type ColorSelectProps = {
|
|
5
|
+
value?: {
|
|
6
|
+
hex?: string;
|
|
7
|
+
rgb?: string;
|
|
8
|
+
};
|
|
9
|
+
/** 自定义总容器 class */
|
|
10
|
+
classNameWrap?: string;
|
|
11
|
+
/** 自定义其余描述展示 */
|
|
12
|
+
renderExtra?: (value: ColorSelectProps['value']) => React.ReactElement;
|
|
13
|
+
/** 自定义value class */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** 组件react-color的props */
|
|
16
|
+
reactColorProps?: Omit<SketchPickerProps, 'onChange'>;
|
|
17
|
+
/** 组件rc-trigger */
|
|
18
|
+
RcTriggerProps?: Omit<TriggerProps, 'popup'>;
|
|
19
|
+
/** 自定义value的展示 */
|
|
20
|
+
renderValueNode?: (value: ColorSelectProps['value']) => React.ReactElement;
|
|
21
|
+
};
|
|
22
|
+
declare const ColorSelect: React.FC<ColorSelectProps>;
|
|
23
|
+
export default ColorSelect;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
|
|
6
|
+
for (var p in s) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var __read = this && this.__read || function (o, n) {
|
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
+
if (!m) return o;
|
|
20
|
+
var i = m.call(o),
|
|
21
|
+
r,
|
|
22
|
+
ar = [],
|
|
23
|
+
e;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
27
|
+
ar.push(r.value);
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
e = {
|
|
31
|
+
error: error
|
|
32
|
+
};
|
|
33
|
+
} finally {
|
|
34
|
+
try {
|
|
35
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
+
} finally {
|
|
37
|
+
if (e) throw e.error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return ar;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
import { SketchPicker } from 'react-color';
|
|
45
|
+
import React, { useContext } from 'react';
|
|
46
|
+
import RcTrigger from 'rc-trigger';
|
|
47
|
+
import classNames from 'classnames';
|
|
48
|
+
import useControllableValue from "ahooks/es/useControllableValue";
|
|
49
|
+
import ChevronRightOutlined from "a-icons/es/ChevronRightOutlined";
|
|
50
|
+
import LocaleContext from '../config-provider/context';
|
|
51
|
+
import formatMessage from '../messages';
|
|
52
|
+
|
|
53
|
+
var ColorSelect = function ColorSelect(props) {
|
|
54
|
+
var className = props.className,
|
|
55
|
+
classNameWrap = props.classNameWrap,
|
|
56
|
+
reactColorProps = props.reactColorProps,
|
|
57
|
+
RcTriggerProps = props.RcTriggerProps,
|
|
58
|
+
renderValueNode = props.renderValueNode,
|
|
59
|
+
renderExtra = props.renderExtra;
|
|
60
|
+
|
|
61
|
+
var _a = __read(useControllableValue(props), 2),
|
|
62
|
+
value = _a[0],
|
|
63
|
+
onChangeValue = _a[1];
|
|
64
|
+
|
|
65
|
+
var messages = useContext(LocaleContext);
|
|
66
|
+
|
|
67
|
+
var onChange = function onChange(nextValue) {
|
|
68
|
+
onChangeValue({
|
|
69
|
+
hex: nextValue.hex,
|
|
70
|
+
rgb: "".concat(nextValue.rgb.r, ",").concat(nextValue.rgb.g, ",").concat(nextValue.rgb.b)
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var defaultValueNode = /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: classNames('color-select', className),
|
|
76
|
+
tabIndex: 0
|
|
77
|
+
}, value ? /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "color-select-value",
|
|
79
|
+
style: value ? {
|
|
80
|
+
backgroundColor: value.hex
|
|
81
|
+
} : undefined
|
|
82
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
className: "color-select-placeholder"
|
|
84
|
+
}, formatMessage(messages, 'global', 'placeholder')), /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: "color-select-arrow"
|
|
86
|
+
}, /*#__PURE__*/React.createElement(ChevronRightOutlined, {
|
|
87
|
+
rotate: 90
|
|
88
|
+
})));
|
|
89
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: classNames('color-select-wrap', classNameWrap)
|
|
91
|
+
}, /*#__PURE__*/React.createElement(RcTrigger, __assign({
|
|
92
|
+
popupAlign: {
|
|
93
|
+
points: ['tl', 'bl'],
|
|
94
|
+
offset: [0, 3]
|
|
95
|
+
},
|
|
96
|
+
action: ['click']
|
|
97
|
+
}, RcTriggerProps, {
|
|
98
|
+
popup: /*#__PURE__*/React.createElement(SketchPicker, __assign({
|
|
99
|
+
width: "320px",
|
|
100
|
+
color: value ? value.hex : undefined,
|
|
101
|
+
onChange: onChange
|
|
102
|
+
}, reactColorProps))
|
|
103
|
+
}), renderValueNode ? renderValueNode(value) : defaultValueNode), renderExtra && renderExtra(value));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default ColorSelect;
|