dtable-ui-component 5.0.21 → 5.1.0

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.
@@ -0,0 +1,149 @@
1
+ .dtable-color-picker {
2
+ width: 240px;
3
+ height: 370px;
4
+ background-color: #fff;
5
+ border-radius: 2px;
6
+ z-index: 100;
7
+ padding: 0.75rem;
8
+ line-height: normal;
9
+ position: absolute;
10
+ box-shadow: rgba(0, 0, 0, 0.3) 0px 0px 2px, rgba(0, 0, 0, 0.3) 0px 4px 8px;
11
+ }
12
+
13
+ .dtable-color-picker .chrome-picker {
14
+ width: 100% !important;
15
+ box-shadow: unset !important;
16
+ }
17
+
18
+ .dtable-color-picker .colorinput-color {
19
+ width: 20px;
20
+ height: 20px;
21
+ cursor: pointer;
22
+ }
23
+
24
+ .dtable-color-picker .colorinput-color .dtable-icon-color-check {
25
+ color: #666;
26
+ font-size: 12px;
27
+ }
28
+
29
+ .dtable-color-picker .dark .colorinput-color .dtable-icon-color-check {
30
+ color: #fff;
31
+ }
32
+
33
+ .dtable-color-picker .blank-placeholder {
34
+ width: 20px;
35
+ height: 20px;
36
+ border: 2px #eee solid;
37
+ border-radius: 4px;
38
+ }
39
+
40
+ .dtable-color-picker .blank-placeholder span {
41
+ color: red;
42
+ transform: rotate(120deg) translate(0px, -2px);
43
+ font-size: 16px;
44
+ }
45
+
46
+ .dtable-color-picker .chrome-picker > div:first-of-type {
47
+ height: 140px;
48
+ border-radius: 2px !important;
49
+ }
50
+
51
+ .dtable-color-picker .chrome-picker > div:nth-child(2) {
52
+ padding: 0.75rem 0 !important;
53
+ }
54
+
55
+ .dtable-color-picker .color-setting {
56
+ font-size: 13px;
57
+ }
58
+
59
+ .dtable-color-picker .color-setting .mode-btn {
60
+ cursor: pointer;
61
+ }
62
+
63
+ .dtable-color-picker .color-setting .mode-btn:hover,
64
+ .dtable-color-picker .color-setting .mode-btn:hover .dtable-font {
65
+ color: #555;
66
+ }
67
+
68
+ .dtable-color-picker .color-setting input {
69
+ height: 24px;
70
+ font-family: inherit;
71
+ font-size: 13px;
72
+ }
73
+
74
+ .dtable-color-picker .color-setting .hex-container {
75
+ position: relative;
76
+ }
77
+
78
+ .dtable-color-picker .color-setting .hex-container span {
79
+ position: absolute;
80
+ top: 4.8px;
81
+ left: 10px;
82
+ color: #999;
83
+ }
84
+
85
+ .dtable-color-picker .color-setting .hex-input {
86
+ padding-left: 20px;
87
+ width: 100px;
88
+ }
89
+
90
+ .dtable-color-picker .color-setting .rgb-container span {
91
+ margin: 0 2px 0 4px;
92
+ color: #999;
93
+ }
94
+
95
+ .dtable-color-picker .color-setting .rgb-input {
96
+ width: 28px;
97
+ display: inline-block;
98
+ padding: 0 0 0 2px;
99
+ }
100
+
101
+ .dtable-color-picker .color-setting .alpha-input {
102
+ width: 60px;
103
+ margin-left: 0.5rem;
104
+ }
105
+
106
+ .dtable-color-picker .color-setting.rgba .alpha-input {
107
+ width: 40px;
108
+ padding: 0 0 0 2px;
109
+ margin-left: 4px;
110
+ }
111
+
112
+ .dtable-color-picker .color-setting .dtable-font {
113
+ font-size: 12px;
114
+ margin-left: 2px;
115
+ color: #ccc;
116
+ display: inline-block;
117
+ transform: rotate(90deg);
118
+ cursor: pointer;
119
+ }
120
+
121
+ .dtable-color-picker .saturation-black {
122
+ cursor: pointer;
123
+ }
124
+
125
+ .dtable-color-picker .chrome-picker .color-bar .hue-horizontal,
126
+ .dtable-color-picker .chrome-picker .color-bar > div:last-of-type > div:last-of-type > div > div:first-of-type,
127
+ .dtable-color-picker .chrome-picker .color-bar > div:last-of-type > div:last-of-type > div > div:nth-child(2) {
128
+ border-radius: 10px;
129
+ }
130
+
131
+ .dtable-color-picker .chrome-picker .color-bar .hue-horizontal,
132
+ .dtable-color-picker .chrome-picker > div:nth-child(2) > div > div > div:nth-child(2) {
133
+ cursor: pointer;
134
+ }
135
+
136
+ .dtable-color-picker .chrome-picker .color-bar > div:first-of-type > div {
137
+ margin-top: 4px !important;
138
+ width: 20px !important;
139
+ height: 20px !important;
140
+ border-radius: 2px !important;
141
+ }
142
+
143
+ .dtable-color-picker .chrome-picker .color-bar > div:first-of-type > div > div:first-of-type {
144
+ border-radius: 2px !important;
145
+ }
146
+
147
+ .dtable-color-picker .chrome-picker > div:nth-child(2) > div:nth-child(2) {
148
+ display: none !important;
149
+ }
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _reactstrap = require("reactstrap");
11
+ var _reactColor = require("react-color");
12
+ var _dtableUtils = require("dtable-utils");
13
+ var _lang = require("../lang");
14
+ var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
15
+ var _utils = require("./utils");
16
+ require("./index.css");
17
+ const DEFAULT_COLORS = ['#ffffff', '#f5f5f5', '#eef6f9', '#deffe6', '#def7c4', '#fefdb5', '#feebb6', '#ffdde5'];
18
+ const COLOR_PICKER_MODE = {
19
+ HEX: 'hex',
20
+ RGBA: 'rgba'
21
+ };
22
+ const RGB_COLORS_MAP = {
23
+ RED: 'r',
24
+ GREEN: 'g',
25
+ BLUE: 'b'
26
+ };
27
+ const LOCAL_STORAGE_KEY = 'dtable-color-picker';
28
+ const DTableColorPicker = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
29
+ const {
30
+ onToggle,
31
+ popoverStyle,
32
+ color,
33
+ defaultColors
34
+ } = props;
35
+ const initialRgbaColor = (0, _utils.hexToRgba)(color);
36
+ const [value, setValue] = (0, _react.useState)(initialRgbaColor);
37
+ const [hexVal, setHexVal] = (0, _react.useState)((0, _utils.getInitialHexVal)(color));
38
+ const [alphaVal, setAlphaVal] = (0, _react.useState)((0, _utils.toPercentage)(initialRgbaColor.a));
39
+ const [redVal, setRedVal] = (0, _react.useState)(initialRgbaColor.r);
40
+ const [greenVal, setGreenVal] = (0, _react.useState)(initialRgbaColor.g);
41
+ const [blueVal, setBlueVal] = (0, _react.useState)(initialRgbaColor.b);
42
+ const [colorMode, setColorMode] = (0, _react.useState)(COLOR_PICKER_MODE.HEX); // hex or rgb
43
+ const colorPickerRef = (0, _react.useRef)(null);
44
+ let currentUsedColors = [];
45
+ const currentUsedColorsStr = window.localStorage.getItem(LOCAL_STORAGE_KEY);
46
+ try {
47
+ currentUsedColors = currentUsedColorsStr ? JSON.parse(currentUsedColorsStr) : [];
48
+ } catch (error) {
49
+ console.error('Error parsing current used colors from localStorage:', error);
50
+ }
51
+ (0, _react.useEffect)(() => {
52
+ const colorBarElement = document.querySelector('.chrome-picker > div:last-of-type > .flexbox-fix:first-of-type');
53
+ if (colorBarElement) {
54
+ colorBarElement.classList.add('color-bar');
55
+ }
56
+ }, []);
57
+ (0, _react.useImperativeHandle)(ref, () => ({
58
+ getHeight: () => colorPickerRef.current ? colorPickerRef.current.offsetHeight : 0
59
+ }));
60
+ const onChangeChromePicker = newColor => {
61
+ const rgba = newColor.rgb;
62
+ rgba.a = Math.round(rgba.a * 100) / 100;
63
+ const transferedHex = (0, _utils.rgbaToHex)(rgba);
64
+ const hexVal = transferedHex.substring(1, 7);
65
+ const {
66
+ r,
67
+ g,
68
+ b,
69
+ a
70
+ } = rgba;
71
+ setAlphaVal((0, _utils.toPercentage)(a));
72
+ updateValue(rgba);
73
+ if (colorMode === COLOR_PICKER_MODE.HEX) {
74
+ setHexVal(hexVal);
75
+ } else {
76
+ setRedVal(r);
77
+ setGreenVal(g);
78
+ setBlueVal(b);
79
+ }
80
+ };
81
+ const onChangeMode = () => {
82
+ let newMode;
83
+ if (colorMode === COLOR_PICKER_MODE.HEX) {
84
+ newMode = COLOR_PICKER_MODE.RGBA;
85
+ const rgba = (0, _utils.hexToRgba)(color);
86
+ const {
87
+ r,
88
+ g,
89
+ b
90
+ } = rgba;
91
+ setRedVal(r);
92
+ setGreenVal(g);
93
+ setBlueVal(b);
94
+ } else {
95
+ newMode = COLOR_PICKER_MODE.HEX;
96
+ const hexVal = (0, _utils.rgbaToHex)(value, false, false);
97
+ setHexVal(hexVal);
98
+ }
99
+ setColorMode(newMode);
100
+ };
101
+ const onChangeHex = e => {
102
+ const hex = e.target.value;
103
+ setHexVal(hex);
104
+ };
105
+ const onHexInputBlur = () => {
106
+ const hexRegex = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/i;
107
+ if (!hexRegex.test(hexVal)) {
108
+ const validHex = (0, _utils.rgbaToHex)(value, false);
109
+ setHexVal(validHex);
110
+ return;
111
+ }
112
+ let newHexVal = hexVal;
113
+ if (newHexVal.length === 3) {
114
+ newHexVal = newHexVal.split('').map(char => char + char).join('');
115
+ }
116
+ setHexVal(newHexVal);
117
+ const {
118
+ r,
119
+ g,
120
+ b
121
+ } = (0, _utils.hexToRgba)(newHexVal);
122
+ const newValue = {
123
+ r,
124
+ g,
125
+ b,
126
+ a: value.a
127
+ };
128
+ updateValue(newValue);
129
+ };
130
+ const onChangeAlpha = e => {
131
+ const regex = /^(\d+|\d+%)?$/;
132
+ const alphaVal = e.target.value.trim().replace('%', '');
133
+ if (!regex.test(alphaVal)) return;
134
+ setAlphaVal(alphaVal);
135
+ };
136
+ const onChangeRgb = (e, specColor) => {
137
+ let newVal = e.target.value;
138
+ const regex = /^[0-9]*$/;
139
+ if (!regex.test(newVal)) return;
140
+ if (newVal) newVal = parseInt(newVal);
141
+ switch (specColor) {
142
+ case RGB_COLORS_MAP.RED:
143
+ {
144
+ setRedVal(newVal);
145
+ break;
146
+ }
147
+ case RGB_COLORS_MAP.GREEN:
148
+ {
149
+ setGreenVal(newVal);
150
+ break;
151
+ }
152
+ case RGB_COLORS_MAP.BLUE:
153
+ {
154
+ setBlueVal(newVal);
155
+ break;
156
+ }
157
+ default:
158
+ break;
159
+ }
160
+ };
161
+ const onRgbInputBlur = specColor => {
162
+ let val = redVal;
163
+ let setSpecColor = setRedVal;
164
+ if (specColor === RGB_COLORS_MAP.GREEN) {
165
+ val = greenVal;
166
+ setSpecColor = setGreenVal;
167
+ } else if (specColor === RGB_COLORS_MAP.BLUE) {
168
+ val = blueVal;
169
+ setSpecColor = setBlueVal;
170
+ }
171
+ if ((0, _dtableUtils.isEmpty)(val) || val < 0 || val > 255) {
172
+ setSpecColor(value[specColor]);
173
+ return;
174
+ }
175
+ const newValue = {
176
+ ...value,
177
+ [specColor]: val
178
+ };
179
+ updateValue(newValue);
180
+ };
181
+ const updateValue = newValue => {
182
+ setValue(newValue);
183
+ const submitHex = (0, _utils.rgbaToHex)(newValue);
184
+ props.onSubmit(submitHex);
185
+ };
186
+ const onAlphaInputBlur = () => {
187
+ if ((0, _dtableUtils.isEmpty)(alphaVal) || alphaVal < 0 || alphaVal > 100) {
188
+ setAlphaVal((0, _utils.toPercentage)(value.a));
189
+ return;
190
+ }
191
+ const newValue = {
192
+ ...value,
193
+ a: parseFloat(alphaVal) / 100
194
+ };
195
+ updateValue(newValue);
196
+ };
197
+ const onKeyDown = (event, callBack) => {
198
+ if (event.key === 'Enter') {
199
+ event.preventDefault();
200
+ event.target.blur();
201
+ callBack && callBack();
202
+ }
203
+ };
204
+ const onSelectDefaultColor = color => {
205
+ const rgba = (0, _utils.hexToRgba)(color);
206
+ const {
207
+ r,
208
+ g,
209
+ b,
210
+ a
211
+ } = rgba;
212
+ const alphaVal = (0, _utils.toPercentage)(a);
213
+ if (colorMode === COLOR_PICKER_MODE.RGBA) {
214
+ setRedVal(r);
215
+ setGreenVal(g);
216
+ setBlueVal(b);
217
+ }
218
+ setHexVal(color.slice(1, 7));
219
+ setAlphaVal(alphaVal);
220
+ updateValue(rgba);
221
+ };
222
+ const onClosePopover = () => {
223
+ if (currentUsedColors.length >= 8) currentUsedColors.pop();
224
+ const hex = (0, _utils.rgbaToHex)(value);
225
+ if (!currentUsedColors.includes(hex)) {
226
+ currentUsedColors.unshift(hex);
227
+ window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(currentUsedColors));
228
+ }
229
+ onToggle();
230
+ };
231
+ const renderDefaultContainer = () => {
232
+ const colors = defaultColors ? defaultColors.slice(0, 8) : DEFAULT_COLORS;
233
+ return /*#__PURE__*/_react.default.createElement("div", {
234
+ className: "default-color-setting"
235
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Default')), /*#__PURE__*/_react.default.createElement("div", {
236
+ className: "default-colors-container d-flex mt-2 mb-2"
237
+ }, colors.map((color, index) => {
238
+ const isLight = (0, _utils.isLightColor)(color);
239
+ return /*#__PURE__*/_react.default.createElement("div", {
240
+ className: "color-item mr-2 ".concat(isLight ? '' : 'dark'),
241
+ onClick: () => onSelectDefaultColor(color),
242
+ key: "default-color-".concat(index)
243
+ }, /*#__PURE__*/_react.default.createElement("span", {
244
+ className: "colorinput-color d-flex align-items-center justify-content-center",
245
+ style: {
246
+ backgroundColor: color
247
+ }
248
+ }, color === "".concat((0, _utils.rgbaToHex)(value)) && alphaVal === 100 && /*#__PURE__*/_react.default.createElement("i", {
249
+ className: "dtable-icon-color-check dtable-font dtable-icon-check-mark"
250
+ })));
251
+ })));
252
+ };
253
+ const renderCustomContainer = () => {
254
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Custom')), /*#__PURE__*/_react.default.createElement(_reactColor.ChromePicker, {
255
+ className: "mt-2",
256
+ color: value,
257
+ onChange: onChangeChromePicker
258
+ }), /*#__PURE__*/_react.default.createElement("div", {
259
+ className: "color-setting d-flex align-items-center ".concat(colorMode)
260
+ }, /*#__PURE__*/_react.default.createElement("span", {
261
+ className: "mode-btn d-flex",
262
+ onClick: onChangeMode
263
+ }, colorMode === COLOR_PICKER_MODE.HEX ? 'HEX' : 'RGB', /*#__PURE__*/_react.default.createElement("i", {
264
+ className: "dtable-font dtable-icon-right"
265
+ })), colorMode === COLOR_PICKER_MODE.HEX ? renderHexContainer() : renderRgbContainer(), /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
266
+ className: "alpha-input",
267
+ type: "text",
268
+ value: alphaVal + '%',
269
+ onBlur: onAlphaInputBlur,
270
+ onKeyDown: e => onKeyDown(e, onAlphaInputBlur),
271
+ onChange: onChangeAlpha
272
+ })));
273
+ };
274
+ const renderHexContainer = () => {
275
+ return /*#__PURE__*/_react.default.createElement("div", {
276
+ className: "hex-container ml-2"
277
+ }, /*#__PURE__*/_react.default.createElement("span", null, "#"), /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
278
+ className: "hex-input",
279
+ type: "text",
280
+ value: hexVal,
281
+ onBlur: onHexInputBlur,
282
+ onKeyDown: e => onKeyDown(e, onHexInputBlur),
283
+ onChange: onChangeHex
284
+ }));
285
+ };
286
+ const renderRgbContainer = () => {
287
+ return /*#__PURE__*/_react.default.createElement("div", {
288
+ className: "rgb-container"
289
+ }, /*#__PURE__*/_react.default.createElement("span", null, "R"), /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
290
+ className: "rgb-input",
291
+ type: "text",
292
+ value: redVal,
293
+ onBlur: () => onRgbInputBlur(RGB_COLORS_MAP.RED),
294
+ onChange: e => onChangeRgb(e, RGB_COLORS_MAP.RED)
295
+ }), /*#__PURE__*/_react.default.createElement("span", null, "G"), /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
296
+ className: "rgb-input",
297
+ type: "text",
298
+ value: greenVal,
299
+ onBlur: () => onRgbInputBlur(RGB_COLORS_MAP.GREEN),
300
+ onChange: e => onChangeRgb(e, RGB_COLORS_MAP.GREEN)
301
+ }), /*#__PURE__*/_react.default.createElement("span", null, "B"), /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
302
+ className: "rgb-input",
303
+ type: "text",
304
+ value: blueVal,
305
+ onBlur: () => onRgbInputBlur(RGB_COLORS_MAP.BLUE),
306
+ onChange: e => onChangeRgb(e, RGB_COLORS_MAP.BLUE)
307
+ }));
308
+ };
309
+ const renderUsedContainer = () => {
310
+ return /*#__PURE__*/_react.default.createElement("div", {
311
+ className: "current-used-container mt-2"
312
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Recently_used')), /*#__PURE__*/_react.default.createElement("div", {
313
+ className: "current-used-colors d-flex mt-2"
314
+ }, currentUsedColors.length > 0 ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentUsedColors.map((color, index) => {
315
+ const isLight = (0, _utils.isLightColor)(color);
316
+ return /*#__PURE__*/_react.default.createElement("div", {
317
+ className: "color-item mr-2 ".concat(isLight ? '' : 'dark'),
318
+ onClick: () => onSelectDefaultColor(color),
319
+ key: "default-color-".concat(index)
320
+ }, /*#__PURE__*/_react.default.createElement("span", {
321
+ className: "colorinput-color d-flex align-items-center justify-content-center",
322
+ style: {
323
+ backgroundColor: color
324
+ }
325
+ }, color === "".concat((0, _utils.rgbaToHex)(value)) && /*#__PURE__*/_react.default.createElement("i", {
326
+ className: "dtable-icon-color-check dtable-font dtable-icon-check-mark"
327
+ })));
328
+ })) : /*#__PURE__*/_react.default.createElement("div", {
329
+ className: "blank-placeholder d-flex align-items-center justify-content-center"
330
+ }, /*#__PURE__*/_react.default.createElement("span", null, "/"))));
331
+ };
332
+ return /*#__PURE__*/_react.default.createElement(_ClickOutside.default, {
333
+ onClickOutside: onClosePopover
334
+ }, /*#__PURE__*/_react.default.createElement("div", {
335
+ style: popoverStyle,
336
+ ref: colorPickerRef,
337
+ className: "dtable-color-picker"
338
+ }, renderDefaultContainer(), renderCustomContainer(), renderUsedContainer()));
339
+ });
340
+ DTableColorPicker.defaultProps = {
341
+ color: '#ffffff'
342
+ };
343
+ var _default = exports.default = DTableColorPicker;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toPercentage = exports.rgbaToHex = exports.isLightColor = exports.hexToRgba = exports.getInitialHexVal = void 0;
7
+ const hexRegex = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/i;
8
+ const rgbaRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/i;
9
+ const hexToRgba = color => {
10
+ if (rgbaRegex.test(color)) return color;
11
+ let r;
12
+ let g;
13
+ let b;
14
+ let a = 1;
15
+ const hex = color.replace(/^#/, '');
16
+ if (hex.length === 6 || hex.length === 8) {
17
+ r = parseInt(hex.slice(0, 2), 16);
18
+ g = parseInt(hex.slice(2, 4), 16);
19
+ b = parseInt(hex.slice(4, 6), 16);
20
+ a = hex.length === 8 ? Math.round(parseInt(hex.slice(6, 8), 16) / 255 * 100) / 100 : 1;
21
+ } else if (hex.length === 3) {
22
+ r = parseInt(hex[0] + hex[0], 16);
23
+ g = parseInt(hex[1] + hex[1], 16);
24
+ b = parseInt(hex[2] + hex[2], 16);
25
+ } else {
26
+ throw new Error('Invalid HEX color.');
27
+ }
28
+ return {
29
+ r,
30
+ g,
31
+ b,
32
+ a
33
+ };
34
+ };
35
+ exports.hexToRgba = hexToRgba;
36
+ const rgbaToHex = function (color) {
37
+ let isNeedPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
38
+ let isNeedAlpha = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
39
+ if (hexRegex.test(color)) return color;
40
+ const {
41
+ r,
42
+ g,
43
+ b,
44
+ a
45
+ } = color;
46
+ const toHex = value => {
47
+ const hex = value.toString(16);
48
+ return hex.length === 1 ? '0' + hex : hex;
49
+ };
50
+ const alpha = a !== undefined && a !== 1 ? toHex(Math.round(a * 255)) : '';
51
+ return "".concat(isNeedPrefix ? '#' : '').concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).concat(isNeedAlpha ? alpha : '');
52
+ };
53
+ exports.rgbaToHex = rgbaToHex;
54
+ const isLightColor = color => {
55
+ if (color.startsWith('#')) color = color.slice(1);
56
+ const r = parseInt(color.substring(0, 2), 16);
57
+ const g = parseInt(color.substring(2, 4), 16);
58
+ const b = parseInt(color.substring(4, 6), 16);
59
+ const a = color.length === 8 ? parseInt(color.substring(6, 8), 16) / 255 : 1;
60
+ const bgColor = {
61
+ r: 255,
62
+ g: 255,
63
+ b: 255
64
+ };
65
+ const mixedR = Math.round((1 - a) * bgColor.r + a * r);
66
+ const mixedG = Math.round((1 - a) * bgColor.g + a * g);
67
+ const mixedB = Math.round((1 - a) * bgColor.b + a * b);
68
+ const luminance = 0.2126 * mixedR + 0.7152 * mixedG + 0.0722 * mixedB;
69
+ return luminance > 128;
70
+ };
71
+ exports.isLightColor = isLightColor;
72
+ const getInitialHexVal = hex => {
73
+ let hexVal = hex.slice(1); // Remove #
74
+ if (hexVal.length > 6) {
75
+ hexVal = hexVal.slice(0, 6);
76
+ }
77
+ return hexVal;
78
+ };
79
+ exports.getInitialHexVal = getInitialHexVal;
80
+ const toPercentage = number => {
81
+ if (number < 0 || number > 1) {
82
+ return null;
83
+ }
84
+ return Math.round(number * 100);
85
+ };
86
+ exports.toPercentage = toPercentage;
@@ -206,7 +206,7 @@
206
206
  .filters-list .delete-filter .dtable-icon-fork-number {
207
207
  display: inline-block;
208
208
  font-size: 12px;
209
- color: #666;
209
+ color: #999;
210
210
  }
211
211
 
212
212
  .filters-list .multiple-option-name {
@@ -289,7 +289,7 @@
289
289
  }
290
290
 
291
291
  .filters-list .filter-item .dtable-icon-fork-number:hover {
292
- color: #5a5a5a;
292
+ color: #555;
293
293
  }
294
294
 
295
295
  .filters-list .filter-container-readonly .dtable-select .selected-option-show,
@@ -28,7 +28,7 @@
28
28
  text-overflow: ellipsis;
29
29
  white-space: nowrap;
30
30
  border-radius: 3px;
31
- z-index: 2;
31
+ z-index: 1;
32
32
  }
33
33
 
34
34
  .radio-group-options .radio-group-button:hover {
@@ -48,7 +48,7 @@
48
48
  position: absolute;
49
49
  height: 100%;
50
50
  border-radius: 3px;
51
- z-index: 1;
51
+ z-index: 0;
52
52
  }
53
53
 
54
54
  .radio-group-options .radio-group-button:nth-of-type(1).active ~ .radio-group-slider {
package/lib/index.js CHANGED
@@ -70,6 +70,12 @@ Object.defineProperty(exports, "CreatorFormatter", {
70
70
  return _CreatorFormatter.default;
71
71
  }
72
72
  });
73
+ Object.defineProperty(exports, "DTableColorPicker", {
74
+ enumerable: true,
75
+ get: function () {
76
+ return _DTableColorPicker.default;
77
+ }
78
+ });
73
79
  Object.defineProperty(exports, "DTableCommonAddTool", {
74
80
  enumerable: true,
75
81
  get: function () {
@@ -465,6 +471,7 @@ var _DTableSwitch = _interopRequireDefault(require("./DTableSwitch"));
465
471
  var _DTableCustomizeSelect = _interopRequireDefault(require("./DTableCustomizeSelect"));
466
472
  var _DTableCustomizeCollaboratorSelect = _interopRequireDefault(require("./DTableCustomizeCollaboratorSelect"));
467
473
  var _DTableSearchInput = _interopRequireDefault(require("./DTableSearchInput"));
474
+ var _DTableColorPicker = _interopRequireDefault(require("./DTableColorPicker"));
468
475
  var _ModalPortal = _interopRequireDefault(require("./ModalPortal"));
469
476
  var _RoleStatusEditor = _interopRequireDefault(require("./RoleStatusEditor"));
470
477
  var _DepartmentSelectFilter = _interopRequireDefault(require("./DepartmentSelectFilter"));
package/lib/locals/de.js CHANGED
@@ -95,6 +95,9 @@ const de = {
95
95
  "last_month": "letzten Monat",
96
96
  "last_year": "letztes Jahr",
97
97
  "URL_is_invalid": "Die URL ist ungültig.",
98
- "Select_department": "Bereich auswählen"
98
+ "Select_department": "Bereich auswählen",
99
+ "Default": "Standard",
100
+ "Custom": "Benutzerdefiniert",
101
+ "Recently_used": "Kürzlich benutzt"
99
102
  };
100
103
  var _default = exports.default = de;
package/lib/locals/en.js CHANGED
@@ -95,6 +95,9 @@ const en = {
95
95
  "last_month": "last month",
96
96
  "last_year": "last year",
97
97
  "URL_is_invalid": "URL is invalid",
98
- "Select_department": "Select department"
98
+ "Select_department": "Select department",
99
+ "Default": "Default",
100
+ "Custom": "Custom",
101
+ "Recently_used": "Recently used"
99
102
  };
100
103
  var _default = exports.default = en;
package/lib/locals/es.js CHANGED
@@ -95,6 +95,9 @@ const es = {
95
95
  "last_month": "el mes pasado",
96
96
  "last_year": "el año pasado",
97
97
  "URL_is_invalid": "URL no válida",
98
- "Select_department": "Select department"
98
+ "Select_department": "Select department",
99
+ "Default": "Incumplimiento de contrato",
100
+ "Custom": "Costumbres",
101
+ "Recently_used": "Recientemente usado"
99
102
  };
100
103
  var _default = exports.default = es;
package/lib/locals/fr.js CHANGED
@@ -95,6 +95,9 @@ const fr = {
95
95
  "last_month": "le mois dernier",
96
96
  "last_year": "l'année dernière",
97
97
  "URL_is_invalid": "L'URL est invalide.",
98
- "Select_department": "Sélectionner un département"
98
+ "Select_department": "Sélectionner un département",
99
+ "Default": "Violation",
100
+ "Custom": "Les coutumes",
101
+ "Recently_used": "Utilisé récemment"
99
102
  };
100
103
  var _default = exports.default = fr;
package/lib/locals/pt.js CHANGED
@@ -95,6 +95,9 @@ const pt = {
95
95
  "last_month": "mês passado",
96
96
  "last_year": "ano passado",
97
97
  "URL_is_invalid": "URL é inválido",
98
- "Select_department": "Select department"
98
+ "Select_department": "Select department",
99
+ "Default": "por omissão",
100
+ "Custom": "personalizado",
101
+ "Recently_used": "usado recentemente"
99
102
  };
100
103
  var _default = exports.default = pt;
package/lib/locals/ru.js CHANGED
@@ -95,6 +95,9 @@ const ru = {
95
95
  "last_month": "last month",
96
96
  "last_year": "last year",
97
97
  "URL_is_invalid": "URL-адрес недействителен",
98
- "Select_department": "Select department"
98
+ "Select_department": "Select department",
99
+ "Default": "Нарушение обязательств",
100
+ "Custom": "Обычаи",
101
+ "Recently_used": "Недавно использованный"
99
102
  };
100
103
  var _default = exports.default = ru;
@@ -95,6 +95,9 @@ const zh_CN = {
95
95
  "last_month": "上个月",
96
96
  "last_year": "去年",
97
97
  "URL_is_invalid": "URL 无效",
98
- "Select_department": "选择部门"
98
+ "Select_department": "选择部门",
99
+ "Default": "默认",
100
+ "Custom": "自定义",
101
+ "Recently_used": "最近使用"
99
102
  };
100
103
  var _default = exports.default = zh_CN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "5.0.21",
3
+ "version": "5.1.0",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "2.0.5",
@@ -16,6 +16,7 @@
16
16
  "react-app-polyfill": "^3.0.0",
17
17
  "react-dom": "17.0.2",
18
18
  "react-responsive": "9.0.2",
19
+ "react-color": "2.19.3",
19
20
  "react-select": "5.7.0",
20
21
  "react-transition-group": "^4.4.1",
21
22
  "reactstrap": "8.9.0"