@smart-react-components/ui 2.0.0-alpha-65 → 2.0.0-alpha-66
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/Checkbox/index.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Position = void 0;
|
|
7
7
|
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
8
8
|
const intrinsic_styled_core_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-core-props"));
|
|
9
|
-
const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
|
|
10
9
|
const react_1 = __importDefault(require("react"));
|
|
11
10
|
const FormInlineLabel_1 = __importDefault(require("../components/Form/FormInlineLabel"));
|
|
12
11
|
const HiddenInput_1 = __importDefault(require("../components/Form/HiddenInput"));
|
|
@@ -15,7 +14,7 @@ const CheckboxElement_1 = __importDefault(require("../components/Checkbox/Checkb
|
|
|
15
14
|
var types_2 = require("../types");
|
|
16
15
|
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_2.OrderPosition; } });
|
|
17
16
|
const Checkbox = react_1.default.forwardRef((props, forwardRef) => {
|
|
18
|
-
const
|
|
17
|
+
const isChecked = react_1.default.useMemo(() => {
|
|
19
18
|
if (props.setChecked) {
|
|
20
19
|
return props.isChecked;
|
|
21
20
|
}
|
|
@@ -23,10 +22,6 @@ const Checkbox = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
23
22
|
return typeof props.active.find(v => v === props.value) !== 'undefined';
|
|
24
23
|
}
|
|
25
24
|
return false;
|
|
26
|
-
};
|
|
27
|
-
const [isChecked, setChecked] = react_1.default.useState(() => getChecked());
|
|
28
|
-
(0, useChangeEffect_1.default)(() => {
|
|
29
|
-
setChecked(getChecked());
|
|
30
25
|
}, [props.active, props.isChecked]);
|
|
31
26
|
const handleOnChange = () => {
|
|
32
27
|
if (!props.isDisabled) {
|
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const Container = styled_components_1.default.div(
|
|
9
|
+
const Container = styled_components_1.default.div.attrs({
|
|
10
|
+
className: 'src-checkbox-container',
|
|
11
|
+
})(({ theme }) => `
|
|
10
12
|
border: solid 2px ${theme.$.color.dynamic.accent};
|
|
11
13
|
box-sizing: border-box;
|
|
12
14
|
display: flex;
|
|
@@ -14,7 +16,9 @@ const Container = styled_components_1.default.div(({ theme }) => `
|
|
|
14
16
|
justify-content: center;
|
|
15
17
|
position: relative;
|
|
16
18
|
`);
|
|
17
|
-
const Rectangle = styled_components_1.default.div
|
|
19
|
+
const Rectangle = styled_components_1.default.div.attrs({
|
|
20
|
+
className: 'src-checkbox-rectangle',
|
|
21
|
+
}) `
|
|
18
22
|
position: absolute;
|
|
19
23
|
left: -2px;
|
|
20
24
|
height: calc(100% + 4px);
|
|
@@ -24,6 +28,7 @@ const Rectangle = styled_components_1.default.div `
|
|
|
24
28
|
`;
|
|
25
29
|
const Svg = styled_components_1.default.svg.attrs({
|
|
26
30
|
children: react_1.default.createElement("path", { d: "M3.5,17.2l7.6,7.6L28.5,7.3" }),
|
|
31
|
+
className: 'src-checkbox-svg',
|
|
27
32
|
viewBox: '0 0 32 32',
|
|
28
33
|
})(({ theme }) => `
|
|
29
34
|
flex: 0 0 auto;
|
|
@@ -51,7 +56,7 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ child
|
|
|
51
56
|
}))(({ theme, isChecked, isOutline, isSoft, palette, shape }) => `
|
|
52
57
|
position: relative;
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
.src-checkbox-container {
|
|
55
60
|
border-radius: ${theme.$.radius.checkbox[shape]};
|
|
56
61
|
|
|
57
62
|
${!isOutline
|
|
@@ -61,17 +66,17 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ child
|
|
|
61
66
|
: ''}
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
|
|
69
|
+
.src-checkbox-rectangle {
|
|
65
70
|
border-radius: ${theme.$.radius.checkbox[shape]};
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
${isChecked
|
|
69
74
|
? `
|
|
70
|
-
|
|
75
|
+
.src-checkbox-rectangle {
|
|
71
76
|
background: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
.src-checkbox-svg > path {
|
|
75
80
|
stroke-dashoffset: 0;
|
|
76
81
|
}
|
|
77
82
|
`
|