@lowdefy/blocks-color-selectors 4.0.0-alpha.6 → 4.0.0-alpha.9
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/README.md +1 -1
- package/dist/blocks/ColorSelector/ColorPicker.js +69 -0
- package/dist/blocks/ColorSelector/ColorSelector.js +19 -23
- package/dist/blocks/ColorSelector/schema.json +8 -33
- package/dist/blocks/ColorSelector/style.less +58 -2
- package/dist/blocks/ColorSelector/useClickOutside.js +46 -0
- package/dist/blocks.js +1 -8
- package/dist/types.js +1 -1
- package/package.json +16 -15
- package/dist/blocks/ChromeColorSelector/ChromeColorSelector.js +0 -75
- package/dist/blocks/ChromeColorSelector/schema.json +0 -99
- package/dist/blocks/ChromeColorSelector/style.less +0 -17
- package/dist/blocks/CircleColorSelector/CircleColorSelector.js +0 -93
- package/dist/blocks/CircleColorSelector/schema.json +0 -156
- package/dist/blocks/CircleColorSelector/style.less +0 -17
- package/dist/blocks/CompactColorSelector/CompactColorSelector.js +0 -71
- package/dist/blocks/CompactColorSelector/schema.json +0 -144
- package/dist/blocks/CompactColorSelector/style.less +0 -17
- package/dist/blocks/GithubColorSelector/GithubColorSelector.js +0 -73
- package/dist/blocks/GithubColorSelector/schema.json +0 -138
- package/dist/blocks/GithubColorSelector/style.less +0 -17
- package/dist/blocks/SliderColorSelector/SliderColorSelector.js +0 -69
- package/dist/blocks/SliderColorSelector/schema.json +0 -96
- package/dist/blocks/SliderColorSelector/style.less +0 -17
- package/dist/blocks/SwatchesColorSelector/SwatchesColorSelector.js +0 -72
- package/dist/blocks/SwatchesColorSelector/schema.json +0 -146
- package/dist/blocks/SwatchesColorSelector/style.less +0 -17
- package/dist/blocks/TwitterColorSelector/TwitterColorSelector.js +0 -66
- package/dist/blocks/TwitterColorSelector/schema.json +0 -125
- package/dist/blocks/TwitterColorSelector/style.less +0 -17
package/README.md
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useCallback, useRef, useState } from 'react';
|
|
16
|
+
import { HexColorPicker, HexColorInput } from 'react-colorful';
|
|
17
|
+
import classNames from 'classnames';
|
|
18
|
+
import useClickOutside from './useClickOutside.js';
|
|
19
|
+
const DEFAULT_COLOR = '#000000';
|
|
20
|
+
export const ColorPicker = ({ className , disabled , hideInput , onChange , size , undefinedColor , value , })=>{
|
|
21
|
+
const popover = useRef();
|
|
22
|
+
const [isOpen, toggle] = useState(false);
|
|
23
|
+
const [color, setColor] = useState(value || undefinedColor || DEFAULT_COLOR);
|
|
24
|
+
const close = useCallback((newColor)=>{
|
|
25
|
+
toggle(false);
|
|
26
|
+
onChange(newColor);
|
|
27
|
+
}, []);
|
|
28
|
+
useClickOutside(popover, close, color);
|
|
29
|
+
return(/*#__PURE__*/ React.createElement("div", {
|
|
30
|
+
className: classNames({
|
|
31
|
+
'color-picker': true,
|
|
32
|
+
[className]: true
|
|
33
|
+
})
|
|
34
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
35
|
+
className: classNames({
|
|
36
|
+
'color-picker-swatch': true,
|
|
37
|
+
'color-picker-swatch-sm': size === 'small',
|
|
38
|
+
'color-picker-swatch-lg': size === 'large',
|
|
39
|
+
'color-picker-swatch-disabled': disabled
|
|
40
|
+
}),
|
|
41
|
+
style: {
|
|
42
|
+
backgroundColor: color
|
|
43
|
+
},
|
|
44
|
+
onClick: ()=>!disabled && toggle(true)
|
|
45
|
+
}), !hideInput && /*#__PURE__*/ React.createElement(HexColorInput, {
|
|
46
|
+
className: classNames({
|
|
47
|
+
'color-picker-input': true,
|
|
48
|
+
'color-picker-input-sm ': size === 'small',
|
|
49
|
+
'color-picker-input-lg': size === 'large',
|
|
50
|
+
'ant-input': true,
|
|
51
|
+
'ant-input-sm': size === 'small',
|
|
52
|
+
'ant-input-lg': size === 'large'
|
|
53
|
+
}),
|
|
54
|
+
color: color,
|
|
55
|
+
onChange: (newColor)=>{
|
|
56
|
+
setColor(newColor);
|
|
57
|
+
onChange(newColor);
|
|
58
|
+
},
|
|
59
|
+
prefixed: true,
|
|
60
|
+
disabled: disabled
|
|
61
|
+
}), isOpen && /*#__PURE__*/ React.createElement("div", {
|
|
62
|
+
className: "color-picker-popover",
|
|
63
|
+
ref: popover
|
|
64
|
+
}, /*#__PURE__*/ React.createElement(HexColorPicker, {
|
|
65
|
+
color: color,
|
|
66
|
+
onChange: setColor
|
|
67
|
+
}))));
|
|
68
|
+
};
|
|
69
|
+
export default ColorPicker;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
3
|
|
|
5
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,13 +13,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
13
|
See the License for the specific language governing permissions and
|
|
15
14
|
limitations under the License.
|
|
16
15
|
*/ import React from 'react';
|
|
17
|
-
import { BlockPicker } from 'react-color';
|
|
18
16
|
import { blockDefaultProps } from '@lowdefy/block-utils';
|
|
19
17
|
import Label from '@lowdefy/blocks-antd/blocks/Label/Label.js';
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
import ColorPicker from './ColorPicker.js';
|
|
19
|
+
const ColorSelector = ({ blockId , components , events , loading , methods , properties , required , validation , value , })=>{
|
|
20
|
+
return(/*#__PURE__*/ React.createElement(Label, {
|
|
22
21
|
blockId: blockId,
|
|
23
|
-
|
|
22
|
+
components: components,
|
|
23
|
+
events: events,
|
|
24
24
|
methods: methods,
|
|
25
25
|
properties: {
|
|
26
26
|
title: properties.title,
|
|
@@ -30,7 +30,7 @@ const Selector = ({ blockId , loading , methods , properties , required , valida
|
|
|
30
30
|
required: required,
|
|
31
31
|
validation: validation,
|
|
32
32
|
content: {
|
|
33
|
-
content: ()=>/*#__PURE__*/
|
|
33
|
+
content: ()=>/*#__PURE__*/ React.createElement(ColorPicker, {
|
|
34
34
|
id: `${blockId}_input`,
|
|
35
35
|
className: methods.makeCssClass([
|
|
36
36
|
{
|
|
@@ -38,30 +38,26 @@ const Selector = ({ blockId , loading , methods , properties , required , valida
|
|
|
38
38
|
},
|
|
39
39
|
properties.inputStyle,
|
|
40
40
|
]),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
triangle: properties.triangle || 'hide',
|
|
44
|
-
width: properties.width || '100%',
|
|
45
|
-
onChangeComplete: (color)=>{
|
|
46
|
-
methods.setValue(color.hex ? color.hex : '#000000');
|
|
41
|
+
onChange: (newColor)=>{
|
|
42
|
+
methods.setValue(newColor);
|
|
47
43
|
methods.triggerEvent({
|
|
48
44
|
name: 'onChange'
|
|
49
45
|
});
|
|
50
|
-
}
|
|
46
|
+
},
|
|
47
|
+
size: properties.size,
|
|
48
|
+
undefinedColor: properties.undefinedColor,
|
|
49
|
+
value: value,
|
|
50
|
+
hideInput: properties.hideInput,
|
|
51
|
+
disabled: properties.disabled || loading,
|
|
52
|
+
methods: methods
|
|
51
53
|
})
|
|
52
54
|
}
|
|
53
55
|
}));
|
|
54
56
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
ColorSelector.defaultProps = blockDefaultProps;
|
|
58
|
+
ColorSelector.meta = {
|
|
57
59
|
valueType: 'string',
|
|
58
60
|
category: 'input',
|
|
59
|
-
loading: {
|
|
60
|
-
type: 'Skeleton',
|
|
61
|
-
properties: {
|
|
62
|
-
height: 216
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
61
|
icons: [
|
|
66
62
|
...Label.meta.icons
|
|
67
63
|
],
|
|
@@ -69,4 +65,4 @@ Selector.meta = {
|
|
|
69
65
|
'blocks/ColorSelector/style.less'
|
|
70
66
|
]
|
|
71
67
|
};
|
|
72
|
-
export default
|
|
68
|
+
export default ColorSelector;
|
|
@@ -7,28 +7,7 @@
|
|
|
7
7
|
"type": "string",
|
|
8
8
|
"description": "Title to describe the input component, if no title is specified the block id is displayed."
|
|
9
9
|
},
|
|
10
|
-
"
|
|
11
|
-
"type": "array",
|
|
12
|
-
"description": "Colors to display.",
|
|
13
|
-
"default": [
|
|
14
|
-
"#D9E3F0",
|
|
15
|
-
"#F47373",
|
|
16
|
-
"#697689",
|
|
17
|
-
"#37D67A",
|
|
18
|
-
"#2CCCE4",
|
|
19
|
-
"#555555",
|
|
20
|
-
"#dce775",
|
|
21
|
-
"#ff8a65",
|
|
22
|
-
"#ba68c8"
|
|
23
|
-
],
|
|
24
|
-
"items": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"docs": {
|
|
27
|
-
"displayType": "color"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"defaultColor": {
|
|
10
|
+
"undefinedColor": {
|
|
32
11
|
"type": "string",
|
|
33
12
|
"default": "#000000",
|
|
34
13
|
"description": "Default color to display if input value is null.",
|
|
@@ -43,19 +22,15 @@
|
|
|
43
22
|
"displayType": "yaml"
|
|
44
23
|
}
|
|
45
24
|
},
|
|
46
|
-
"
|
|
25
|
+
"disabled": {
|
|
47
26
|
"type": "boolean",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"description": "Show triangle on color selector border."
|
|
27
|
+
"default": false,
|
|
28
|
+
"description": "If true, the input is disabled."
|
|
51
29
|
},
|
|
52
|
-
"
|
|
53
|
-
"type":
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"docs": {
|
|
57
|
-
"displayType": "string"
|
|
58
|
-
}
|
|
30
|
+
"hideInput": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"default": false,
|
|
33
|
+
"description": "If true, the input is hidden."
|
|
59
34
|
},
|
|
60
35
|
"label": {
|
|
61
36
|
"type": "object",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,4 +14,60 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
@import '@lowdefy/blocks-antd/blocks/Label/style.less'
|
|
17
|
+
@import '@lowdefy/blocks-antd/blocks/Label/style.less';
|
|
18
|
+
@import '@lowdefy/blocks-antd/blocks/TextInput/style.less';
|
|
19
|
+
|
|
20
|
+
.color-picker {
|
|
21
|
+
position: relative;
|
|
22
|
+
display: flex;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.color-picker-swatch {
|
|
26
|
+
flex: 0 0 auto;
|
|
27
|
+
width: 34px;
|
|
28
|
+
height: 34px;
|
|
29
|
+
border-radius: 2px;
|
|
30
|
+
border: 3px solid #fff;
|
|
31
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.color-picker-swatch-disabled {
|
|
36
|
+
cursor: disabled;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.color-picker-swatch-sm {
|
|
40
|
+
width: 24px;
|
|
41
|
+
height: 24px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.color-picker-swatch-lg {
|
|
45
|
+
width: 40px;
|
|
46
|
+
height: 40px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.small .react-colorful {
|
|
50
|
+
width: 120px;
|
|
51
|
+
height: 120px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.color-picker-popover {
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: calc(100% + 2px);
|
|
57
|
+
left: 0;
|
|
58
|
+
border-radius: 3px;
|
|
59
|
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
|
|
60
|
+
z-index: 1000;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.color-picker-input {
|
|
64
|
+
margin-left: 8px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.color-picker-input-sm {
|
|
68
|
+
margin-left: 0px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.color-picker-input-lg {
|
|
72
|
+
margin-left: 12px;
|
|
73
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { useEffect } from 'react';
|
|
16
|
+
// Improved version of https://usehooks.com/useOnClickOutside/
|
|
17
|
+
const useClickOutside = (ref, handler, value)=>{
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
let startedInside = false;
|
|
20
|
+
let startedWhenMounted = false;
|
|
21
|
+
const listener = (event)=>{
|
|
22
|
+
// Do nothing if `mousedown` or `touchstart` started inside ref element
|
|
23
|
+
if (startedInside || !startedWhenMounted) return;
|
|
24
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
25
|
+
if (!ref.current || ref.current.contains(event.target)) return;
|
|
26
|
+
handler(value, event);
|
|
27
|
+
};
|
|
28
|
+
const validateEventStart = (event)=>{
|
|
29
|
+
startedWhenMounted = ref.current;
|
|
30
|
+
startedInside = ref.current && ref.current.contains(event.target);
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener('mousedown', validateEventStart);
|
|
33
|
+
document.addEventListener('touchstart', validateEventStart);
|
|
34
|
+
document.addEventListener('click', listener);
|
|
35
|
+
return ()=>{
|
|
36
|
+
document.removeEventListener('mousedown', validateEventStart);
|
|
37
|
+
document.removeEventListener('touchstart', validateEventStart);
|
|
38
|
+
document.removeEventListener('click', listener);
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
ref,
|
|
42
|
+
handler,
|
|
43
|
+
value
|
|
44
|
+
]);
|
|
45
|
+
};
|
|
46
|
+
export default useClickOutside;
|
package/dist/blocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,10 +13,3 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ export { default as ColorSelector } from './blocks/ColorSelector/ColorSelector.js';
|
|
16
|
-
export { default as ChromeColorSelector } from './blocks/ChromeColorSelector/ChromeColorSelector.js';
|
|
17
|
-
export { default as CircleColorSelector } from './blocks/CircleColorSelector/CircleColorSelector.js';
|
|
18
|
-
export { default as CompactColorSelector } from './blocks/CompactColorSelector/CompactColorSelector.js';
|
|
19
|
-
export { default as GithubColorSelector } from './blocks/GithubColorSelector/GithubColorSelector.js';
|
|
20
|
-
export { default as SliderColorSelector } from './blocks/SliderColorSelector/SliderColorSelector.js';
|
|
21
|
-
export { default as SwatchesColorSelector } from './blocks/SwatchesColorSelector/SwatchesColorSelector.js';
|
|
22
|
-
export { default as TwitterColorSelector } from './blocks/TwitterColorSelector/TwitterColorSelector.js';
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/blocks-color-selectors",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "A Lowdefy color selector blocks based on react-color.",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"lowdefy",
|
|
9
9
|
"lowdefy blocks",
|
|
10
10
|
"color picker",
|
|
11
|
-
"react-color"
|
|
11
|
+
"react-color",
|
|
12
|
+
"lowdefy plugin"
|
|
12
13
|
],
|
|
13
14
|
"bugs": {
|
|
14
15
|
"url": "https://github.com/lowdefy/lowdefy/issues"
|
|
@@ -50,30 +51,30 @@
|
|
|
50
51
|
"test": "jest --coverage"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
|
-
"@lowdefy/block-utils": "4.0.0-alpha.
|
|
54
|
-
"@lowdefy/blocks-antd": "4.0.0-alpha.
|
|
55
|
-
"
|
|
56
|
-
"react
|
|
57
|
-
"react-
|
|
54
|
+
"@lowdefy/block-utils": "4.0.0-alpha.9",
|
|
55
|
+
"@lowdefy/blocks-antd": "4.0.0-alpha.9",
|
|
56
|
+
"classnames": "2.3.1",
|
|
57
|
+
"react": "17.0.2",
|
|
58
|
+
"react-colorful": "5.5.1",
|
|
59
|
+
"react-dom": "17.0.2"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@lowdefy/block-dev": "4.0.0-alpha.6",
|
|
62
|
+
"@emotion/jest": "11.7.1",
|
|
63
|
+
"@lowdefy/block-dev": "4.0.0-alpha.9",
|
|
63
64
|
"@swc/cli": "0.1.55",
|
|
64
|
-
"@swc/core": "1.2.
|
|
65
|
+
"@swc/core": "1.2.135",
|
|
65
66
|
"@swc/jest": "0.2.17",
|
|
66
|
-
"@testing-library/dom": "8.
|
|
67
|
+
"@testing-library/dom": "8.11.3",
|
|
67
68
|
"@testing-library/react": "13.0.0-alpha.4",
|
|
68
69
|
"@testing-library/user-event": "14.0.0-alpha.14",
|
|
69
70
|
"copyfiles": "2.4.1",
|
|
70
|
-
"jest": "27.
|
|
71
|
+
"jest": "27.5.1",
|
|
71
72
|
"jest-canvas-mock": "2.3.1",
|
|
72
73
|
"jest-serializer-html": "7.1.0",
|
|
73
|
-
"jest-transform-yaml": "0.
|
|
74
|
+
"jest-transform-yaml": "1.0.0"
|
|
74
75
|
},
|
|
75
76
|
"publishConfig": {
|
|
76
77
|
"access": "public"
|
|
77
78
|
},
|
|
78
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
79
80
|
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
4
|
-
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/ import React, { useState } from 'react';
|
|
17
|
-
import { ChromePicker } from 'react-color';
|
|
18
|
-
import { blockDefaultProps } from '@lowdefy/block-utils';
|
|
19
|
-
import Label from '@lowdefy/blocks-antd/blocks/Label/Label.js';
|
|
20
|
-
const Selector = ({ blockId , loading , methods , properties , required , validation , value })=>{
|
|
21
|
-
const [color, setColor] = useState(value || properties.defaultColor || '#000000');
|
|
22
|
-
return(/*#__PURE__*/ _jsx(Label, {
|
|
23
|
-
blockId: blockId,
|
|
24
|
-
loading: loading,
|
|
25
|
-
methods: methods,
|
|
26
|
-
properties: {
|
|
27
|
-
title: properties.title,
|
|
28
|
-
size: properties.size,
|
|
29
|
-
...properties.label
|
|
30
|
-
},
|
|
31
|
-
required: required,
|
|
32
|
-
validation: validation,
|
|
33
|
-
content: {
|
|
34
|
-
content: ()=>/*#__PURE__*/ _jsx(ChromePicker, {
|
|
35
|
-
id: `${blockId}_input`,
|
|
36
|
-
className: methods.makeCssClass([
|
|
37
|
-
{
|
|
38
|
-
marginBottom: '0px !important'
|
|
39
|
-
},
|
|
40
|
-
properties.inputStyle,
|
|
41
|
-
]),
|
|
42
|
-
color: color && color[color.source] || color || '#000000',
|
|
43
|
-
disableAlpha: properties.disableAlpha,
|
|
44
|
-
onChange: (clr)=>setColor(clr)
|
|
45
|
-
,
|
|
46
|
-
onChangeComplete: (clr)=>{
|
|
47
|
-
setColor(clr);
|
|
48
|
-
methods.setValue(clr);
|
|
49
|
-
methods.triggerEvent({
|
|
50
|
-
name: 'onChange'
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
|
-
Selector.defaultProps = blockDefaultProps;
|
|
58
|
-
Selector.meta = {
|
|
59
|
-
valueType: 'object',
|
|
60
|
-
category: 'input',
|
|
61
|
-
loading: {
|
|
62
|
-
type: 'Skeleton',
|
|
63
|
-
properties: {
|
|
64
|
-
width: 225,
|
|
65
|
-
height: 240
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
icons: [
|
|
69
|
-
...Label.meta.icons
|
|
70
|
-
],
|
|
71
|
-
styles: [
|
|
72
|
-
'blocks/ChromeColorSelector/style.less'
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
|
-
export default Selector;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "object",
|
|
3
|
-
"properties": {
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"defaultColor": {
|
|
7
|
-
"type": "string",
|
|
8
|
-
"description": "Default color to display if input value is null.",
|
|
9
|
-
"docs": {
|
|
10
|
-
"displayType": "color"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"disableAlpha": {
|
|
14
|
-
"type": "boolean",
|
|
15
|
-
"description": "Remove alpha slider and options from picker."
|
|
16
|
-
},
|
|
17
|
-
"inputStyle": {
|
|
18
|
-
"type": "object",
|
|
19
|
-
"description": "Css style to applied to input.",
|
|
20
|
-
"docs": {
|
|
21
|
-
"displayType": "yaml"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"label": {
|
|
25
|
-
"type": "object",
|
|
26
|
-
"description": "Label properties.",
|
|
27
|
-
"additionalProperties": false,
|
|
28
|
-
"properties": {
|
|
29
|
-
"align": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"enum": ["left", "right"],
|
|
32
|
-
"default": "left",
|
|
33
|
-
"description": "Align label left or right when inline."
|
|
34
|
-
},
|
|
35
|
-
"colon": {
|
|
36
|
-
"type": "boolean",
|
|
37
|
-
"default": true,
|
|
38
|
-
"description": "Append label with colon."
|
|
39
|
-
},
|
|
40
|
-
"extra": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"description": "Extra text to display beneath the content."
|
|
43
|
-
},
|
|
44
|
-
"title": {
|
|
45
|
-
"type": "string",
|
|
46
|
-
"description": "Label title."
|
|
47
|
-
},
|
|
48
|
-
"span": {
|
|
49
|
-
"type": "number",
|
|
50
|
-
"description": "Label inline span."
|
|
51
|
-
},
|
|
52
|
-
"disabled": {
|
|
53
|
-
"type": "boolean",
|
|
54
|
-
"default": false,
|
|
55
|
-
"description": "Hide input label."
|
|
56
|
-
},
|
|
57
|
-
"hasFeedback": {
|
|
58
|
-
"type": "boolean",
|
|
59
|
-
"default": true,
|
|
60
|
-
"description": "Display feedback extra from validation, this does not disable validation."
|
|
61
|
-
},
|
|
62
|
-
"inline": {
|
|
63
|
-
"type": "boolean",
|
|
64
|
-
"default": false,
|
|
65
|
-
"description": "Render input and label inline."
|
|
66
|
-
},
|
|
67
|
-
"extraStyle": {
|
|
68
|
-
"type": "object",
|
|
69
|
-
"description": "Css style to applied to label extra.",
|
|
70
|
-
"docs": {
|
|
71
|
-
"displayType": "yaml"
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
"feedbackStyle": {
|
|
75
|
-
"type": "object",
|
|
76
|
-
"description": "Css style to applied to label feedback.",
|
|
77
|
-
"docs": {
|
|
78
|
-
"displayType": "yaml"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"title": {
|
|
84
|
-
"type": "string",
|
|
85
|
-
"description": "Title to describe the input component, if no title is specified the block id is displayed."
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
"events": {
|
|
90
|
-
"type": "object",
|
|
91
|
-
"additionalProperties": false,
|
|
92
|
-
"properties": {
|
|
93
|
-
"onChange": {
|
|
94
|
-
"type": "array",
|
|
95
|
-
"description": "Trigger actions when color is picked."
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
@import '@lowdefy/blocks-antd/blocks/Label/style.less'
|