@dktunited-techoff/techoff-suite-ui 0.8.11 → 0.8.13
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/esm/assets/fonts/Roboto-Light.ttf +0 -0
- package/esm/components/Checkbox/Checkbox.css +11 -0
- package/esm/components/Checkbox/Checkbox.d.ts +1 -4
- package/esm/components/Checkbox/Checkbox.js +9 -12
- package/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/esm/components/Checkbox/Checkbox.types.d.ts +3 -0
- package/esm/components/Checkbox/__stories__/Checkbox.stories.mdx +18 -8
- package/esm/index.d.ts +4 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -1
- package/lib/assets/fonts/Roboto-Light.ttf +0 -0
- package/lib/components/Checkbox/Checkbox.css +11 -0
- package/lib/components/Checkbox/Checkbox.d.ts +1 -4
- package/lib/components/Checkbox/Checkbox.js +10 -15
- package/lib/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/components/Checkbox/Checkbox.types.d.ts +3 -0
- package/lib/components/Checkbox/__stories__/Checkbox.stories.mdx +18 -8
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Checkbox/Checkbox.css +11 -0
- package/src/components/Checkbox/Checkbox.tsx +9 -13
- package/src/components/Checkbox/Checkbox.types.ts +7 -1
- package/src/components/Checkbox/__stories__/Checkbox.stories.mdx +18 -8
- package/src/index.ts +4 -0
|
Binary file
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
}
|
|
6
|
+
/* ########## */
|
|
7
|
+
/* DISABLED */
|
|
8
|
+
.checkbox--disabled {
|
|
9
|
+
cursor: not-allowed;
|
|
10
|
+
}
|
|
11
|
+
.checkbox--disabled .checkbox-box {
|
|
12
|
+
color: #999999;
|
|
13
|
+
}
|
|
14
|
+
.checkbox--disabled:hover .checkbox-box {
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
6
17
|
/* ##### */
|
|
7
18
|
/* BOX */
|
|
8
19
|
.checkbox:hover .checkbox-box {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
2
|
import { CheckboxProps } from './Checkbox.types';
|
|
4
3
|
import './Checkbox.css';
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const CheckboxCaption: ({ children }: PropsWithChildren) => React.JSX.Element;
|
|
7
|
-
export declare const Checkbox: ({ children, checked, onChange }: PropsWithChildren<CheckboxProps>) => React.JSX.Element;
|
|
4
|
+
export declare const Checkbox: ({ caption, label, checked, disabled, onChange }: CheckboxProps) => React.JSX.Element;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Children } from 'react';
|
|
3
|
-
import { isSuiteElement } from '../../utils/validator.utils';
|
|
4
2
|
import { Icon } from '../Icon/Icon';
|
|
5
3
|
import './Checkbox.css';
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const captionElement = Children.toArray(children).find(c => isSuiteElement(c, 'CheckboxCaption'));
|
|
4
|
+
export const Checkbox = ({ caption, label, checked, disabled, onChange }) => {
|
|
5
|
+
// ########
|
|
6
|
+
// Handlers
|
|
7
|
+
const handleChange = () => !disabled && onChange(!checked);
|
|
11
8
|
// #########
|
|
12
9
|
// Rendering
|
|
13
|
-
return (React.createElement("div", { className:
|
|
10
|
+
return (React.createElement("div", { className: `checkbox ${disabled ? 'checkbox--disabled' : ''}`, onClick: handleChange },
|
|
14
11
|
React.createElement("div", { className: "checkbox-box" },
|
|
15
|
-
checked && React.createElement(Icon, { name: "square-
|
|
12
|
+
checked && React.createElement(Icon, { name: "check-square-filled" }),
|
|
16
13
|
!checked && React.createElement(Icon, { name: "square" })),
|
|
17
|
-
React.createElement("div", { className: `checkbox-container ${
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
React.createElement("div", { className: `checkbox-container ${caption ? 'checkbox-container--with-caption' : ''}` },
|
|
15
|
+
React.createElement("div", { className: "checkbox-label" }, label),
|
|
16
|
+
caption && React.createElement("div", { className: "checkbox-caption" }, caption))));
|
|
20
17
|
};
|
|
21
18
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAiB,EAAE,EAAE;IACzF,WAAW;IACX,WAAW;IACX,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;IAE3D,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,YAAY,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY;QACvF,6BAAK,SAAS,EAAC,cAAc;YAC1B,OAAO,IAAI,oBAAC,IAAI,IAAC,IAAI,EAAC,qBAAqB,GAAG;YAC9C,CAAC,OAAO,IAAI,oBAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,CAC/B;QAEN,6BAAK,SAAS,EAAE,sBAAsB,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,EAAE,EAAE;YACvF,6BAAK,SAAS,EAAC,gBAAgB,IAAE,KAAK,CAAO;YAC5C,OAAO,IAAI,6BAAK,SAAS,EAAC,kBAAkB,IAAE,OAAO,CAAO,CACzD,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
|
|
3
|
-
import { Checkbox
|
|
3
|
+
import { Checkbox } from '../Checkbox';
|
|
4
4
|
|
|
5
5
|
<Meta title="Components/Checkbox" />
|
|
6
6
|
|
|
7
7
|
export const checkboxArgTypes = {
|
|
8
|
+
caption: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Caption of the checkbox.',
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Label of the checkbox.',
|
|
15
|
+
},
|
|
8
16
|
checked: {
|
|
9
17
|
control: 'boolean',
|
|
10
18
|
description: 'State of the checkbox.',
|
|
11
19
|
table: { defaultValue: { summary: 'false' } },
|
|
12
20
|
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description: 'Enable state of the checkbox.',
|
|
24
|
+
table: { defaultValue: { summary: 'false' } },
|
|
25
|
+
},
|
|
13
26
|
};
|
|
14
27
|
|
|
15
28
|
# Checkbox
|
|
@@ -22,14 +35,11 @@ Checkboxes are applied when users can select all, several, or none of the option
|
|
|
22
35
|
<Story
|
|
23
36
|
name="Overview"
|
|
24
37
|
args={{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo
|
|
29
|
-
viverra nisl, in posuere dui urna eget quam.
|
|
30
|
-
</CheckboxCaption>,
|
|
31
|
-
],
|
|
38
|
+
label: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
39
|
+
caption:
|
|
40
|
+
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
32
41
|
checked: false,
|
|
42
|
+
disabled: false,
|
|
33
43
|
onChange: () => {},
|
|
34
44
|
}}
|
|
35
45
|
argTypes={checkboxArgTypes}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './components/Button/Button';
|
|
2
|
+
export * from './components/Checkbox/Checkbox';
|
|
2
3
|
export * from './components/Icon/Icon';
|
|
4
|
+
export * from './components/Inputs/BooleanInput/BooleanInput';
|
|
5
|
+
export * from './components/Inputs/TextInput/TextInput';
|
|
6
|
+
export * from './components/Loader/Loader';
|
|
3
7
|
export * from './layouts/Header/Header';
|
|
4
8
|
export * from './layouts/Header/HeaderProfile';
|
|
5
9
|
export * from './layouts/Navigation/Navigation';
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './components/Button/Button';
|
|
2
|
+
export * from './components/Checkbox/Checkbox';
|
|
2
3
|
export * from './components/Icon/Icon';
|
|
4
|
+
export * from './components/Inputs/BooleanInput/BooleanInput';
|
|
5
|
+
export * from './components/Inputs/TextInput/TextInput';
|
|
6
|
+
export * from './components/Loader/Loader';
|
|
3
7
|
export * from './layouts/Header/Header';
|
|
4
8
|
export * from './layouts/Header/HeaderProfile';
|
|
5
9
|
export * from './layouts/Navigation/Navigation';
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,yCAAyC,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC"}
|
|
Binary file
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
}
|
|
6
|
+
/* ########## */
|
|
7
|
+
/* DISABLED */
|
|
8
|
+
.checkbox--disabled {
|
|
9
|
+
cursor: not-allowed;
|
|
10
|
+
}
|
|
11
|
+
.checkbox--disabled .checkbox-box {
|
|
12
|
+
color: #999999;
|
|
13
|
+
}
|
|
14
|
+
.checkbox--disabled:hover .checkbox-box {
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
6
17
|
/* ##### */
|
|
7
18
|
/* BOX */
|
|
8
19
|
.checkbox:hover .checkbox-box {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
2
|
import { CheckboxProps } from './Checkbox.types';
|
|
4
3
|
import './Checkbox.css';
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const CheckboxCaption: ({ children }: PropsWithChildren) => React.JSX.Element;
|
|
7
|
-
export declare const Checkbox: ({ children, checked, onChange }: PropsWithChildren<CheckboxProps>) => React.JSX.Element;
|
|
4
|
+
export declare const Checkbox: ({ caption, label, checked, disabled, onChange }: CheckboxProps) => React.JSX.Element;
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Checkbox =
|
|
3
|
+
exports.Checkbox = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const validator_utils_1 = require("../../utils/validator.utils");
|
|
7
5
|
const Icon_1 = require("../Icon/Icon");
|
|
8
6
|
require("./Checkbox.css");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const Checkbox = ({ children, checked, onChange }) => {
|
|
14
|
-
const labelElement = react_1.Children.toArray(children).find(c => (0, validator_utils_1.isSuiteElement)(c, 'CheckboxLabel'));
|
|
15
|
-
const captionElement = react_1.Children.toArray(children).find(c => (0, validator_utils_1.isSuiteElement)(c, 'CheckboxCaption'));
|
|
7
|
+
const Checkbox = ({ caption, label, checked, disabled, onChange }) => {
|
|
8
|
+
// ########
|
|
9
|
+
// Handlers
|
|
10
|
+
const handleChange = () => !disabled && onChange(!checked);
|
|
16
11
|
// #########
|
|
17
12
|
// Rendering
|
|
18
|
-
return (React.createElement("div", { className:
|
|
13
|
+
return (React.createElement("div", { className: `checkbox ${disabled ? 'checkbox--disabled' : ''}`, onClick: handleChange },
|
|
19
14
|
React.createElement("div", { className: "checkbox-box" },
|
|
20
|
-
checked && React.createElement(Icon_1.Icon, { name: "square-
|
|
15
|
+
checked && React.createElement(Icon_1.Icon, { name: "check-square-filled" }),
|
|
21
16
|
!checked && React.createElement(Icon_1.Icon, { name: "square" })),
|
|
22
|
-
React.createElement("div", { className: `checkbox-container ${
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
React.createElement("div", { className: `checkbox-container ${caption ? 'checkbox-container--with-caption' : ''}` },
|
|
18
|
+
React.createElement("div", { className: "checkbox-label" }, label),
|
|
19
|
+
caption && React.createElement("div", { className: "checkbox-caption" }, caption))));
|
|
25
20
|
};
|
|
26
21
|
exports.Checkbox = Checkbox;
|
|
27
22
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,uCAAoC;AAEpC,0BAAwB;AAEjB,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAiB,EAAE,EAAE;IACzF,WAAW;IACX,WAAW;IACX,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;IAE3D,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,YAAY,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY;QACvF,6BAAK,SAAS,EAAC,cAAc;YAC1B,OAAO,IAAI,oBAAC,WAAI,IAAC,IAAI,EAAC,qBAAqB,GAAG;YAC9C,CAAC,OAAO,IAAI,oBAAC,WAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,CAC/B;QAEN,6BAAK,SAAS,EAAE,sBAAsB,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,EAAE,EAAE;YACvF,6BAAK,SAAS,EAAC,gBAAgB,IAAE,KAAK,CAAO;YAC5C,OAAO,IAAI,6BAAK,SAAS,EAAC,kBAAkB,IAAE,OAAO,CAAO,CACzD,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,QAAQ,YAoBnB"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
|
|
3
|
-
import { Checkbox
|
|
3
|
+
import { Checkbox } from '../Checkbox';
|
|
4
4
|
|
|
5
5
|
<Meta title="Components/Checkbox" />
|
|
6
6
|
|
|
7
7
|
export const checkboxArgTypes = {
|
|
8
|
+
caption: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Caption of the checkbox.',
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Label of the checkbox.',
|
|
15
|
+
},
|
|
8
16
|
checked: {
|
|
9
17
|
control: 'boolean',
|
|
10
18
|
description: 'State of the checkbox.',
|
|
11
19
|
table: { defaultValue: { summary: 'false' } },
|
|
12
20
|
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description: 'Enable state of the checkbox.',
|
|
24
|
+
table: { defaultValue: { summary: 'false' } },
|
|
25
|
+
},
|
|
13
26
|
};
|
|
14
27
|
|
|
15
28
|
# Checkbox
|
|
@@ -22,14 +35,11 @@ Checkboxes are applied when users can select all, several, or none of the option
|
|
|
22
35
|
<Story
|
|
23
36
|
name="Overview"
|
|
24
37
|
args={{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo
|
|
29
|
-
viverra nisl, in posuere dui urna eget quam.
|
|
30
|
-
</CheckboxCaption>,
|
|
31
|
-
],
|
|
38
|
+
label: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
39
|
+
caption:
|
|
40
|
+
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
32
41
|
checked: false,
|
|
42
|
+
disabled: false,
|
|
33
43
|
onChange: () => {},
|
|
34
44
|
}}
|
|
35
45
|
argTypes={checkboxArgTypes}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './components/Button/Button';
|
|
2
|
+
export * from './components/Checkbox/Checkbox';
|
|
2
3
|
export * from './components/Icon/Icon';
|
|
4
|
+
export * from './components/Inputs/BooleanInput/BooleanInput';
|
|
5
|
+
export * from './components/Inputs/TextInput/TextInput';
|
|
6
|
+
export * from './components/Loader/Loader';
|
|
3
7
|
export * from './layouts/Header/Header';
|
|
4
8
|
export * from './layouts/Header/HeaderProfile';
|
|
5
9
|
export * from './layouts/Navigation/Navigation';
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./components/Button/Button"), exports);
|
|
18
|
+
__exportStar(require("./components/Checkbox/Checkbox"), exports);
|
|
18
19
|
__exportStar(require("./components/Icon/Icon"), exports);
|
|
20
|
+
__exportStar(require("./components/Inputs/BooleanInput/BooleanInput"), exports);
|
|
21
|
+
__exportStar(require("./components/Inputs/TextInput/TextInput"), exports);
|
|
22
|
+
__exportStar(require("./components/Loader/Loader"), exports);
|
|
19
23
|
__exportStar(require("./layouts/Header/Header"), exports);
|
|
20
24
|
__exportStar(require("./layouts/Header/HeaderProfile"), exports);
|
|
21
25
|
__exportStar(require("./layouts/Navigation/Navigation"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,yDAAuC;AACvC,0DAAwC;AACxC,iEAA+C;AAC/C,kEAAgD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,iEAA+C;AAC/C,yDAAuC;AACvC,gFAA8D;AAC9D,0EAAwD;AACxD,6DAA2C;AAC3C,0DAAwC;AACxC,iEAA+C;AAC/C,kEAAgD"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
}
|
|
6
|
+
/* ########## */
|
|
7
|
+
/* DISABLED */
|
|
8
|
+
.checkbox--disabled {
|
|
9
|
+
cursor: not-allowed;
|
|
10
|
+
}
|
|
11
|
+
.checkbox--disabled .checkbox-box {
|
|
12
|
+
color: #999999;
|
|
13
|
+
}
|
|
14
|
+
.checkbox--disabled:hover .checkbox-box {
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
6
17
|
/* ##### */
|
|
7
18
|
/* BOX */
|
|
8
19
|
.checkbox:hover .checkbox-box {
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Children, PropsWithChildren } from 'react';
|
|
3
|
-
import { isSuiteElement } from '../../utils/validator.utils';
|
|
4
2
|
import { Icon } from '../Icon/Icon';
|
|
5
3
|
import { CheckboxProps } from './Checkbox.types';
|
|
6
4
|
import './Checkbox.css';
|
|
7
5
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const labelElement = Children.toArray(children).find(c => isSuiteElement(c, 'CheckboxLabel'));
|
|
13
|
-
const captionElement = Children.toArray(children).find(c => isSuiteElement(c, 'CheckboxCaption'));
|
|
6
|
+
export const Checkbox = ({ caption, label, checked, disabled, onChange }: CheckboxProps) => {
|
|
7
|
+
// ########
|
|
8
|
+
// Handlers
|
|
9
|
+
const handleChange = () => !disabled && onChange(!checked);
|
|
14
10
|
|
|
15
11
|
// #########
|
|
16
12
|
// Rendering
|
|
17
13
|
return (
|
|
18
|
-
<div className=
|
|
14
|
+
<div className={`checkbox ${disabled ? 'checkbox--disabled' : ''}`} onClick={handleChange}>
|
|
19
15
|
<div className="checkbox-box">
|
|
20
|
-
{checked && <Icon name="square-
|
|
16
|
+
{checked && <Icon name="check-square-filled" />}
|
|
21
17
|
{!checked && <Icon name="square" />}
|
|
22
18
|
</div>
|
|
23
19
|
|
|
24
|
-
<div className={`checkbox-container ${
|
|
25
|
-
{
|
|
26
|
-
{
|
|
20
|
+
<div className={`checkbox-container ${caption ? 'checkbox-container--with-caption' : ''}`}>
|
|
21
|
+
<div className="checkbox-label">{label}</div>
|
|
22
|
+
{caption && <div className="checkbox-caption">{caption}</div>}
|
|
27
23
|
</div>
|
|
28
24
|
</div>
|
|
29
25
|
);
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
|
|
3
|
-
import { Checkbox
|
|
3
|
+
import { Checkbox } from '../Checkbox';
|
|
4
4
|
|
|
5
5
|
<Meta title="Components/Checkbox" />
|
|
6
6
|
|
|
7
7
|
export const checkboxArgTypes = {
|
|
8
|
+
caption: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Caption of the checkbox.',
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Label of the checkbox.',
|
|
15
|
+
},
|
|
8
16
|
checked: {
|
|
9
17
|
control: 'boolean',
|
|
10
18
|
description: 'State of the checkbox.',
|
|
11
19
|
table: { defaultValue: { summary: 'false' } },
|
|
12
20
|
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description: 'Enable state of the checkbox.',
|
|
24
|
+
table: { defaultValue: { summary: 'false' } },
|
|
25
|
+
},
|
|
13
26
|
};
|
|
14
27
|
|
|
15
28
|
# Checkbox
|
|
@@ -22,14 +35,11 @@ Checkboxes are applied when users can select all, several, or none of the option
|
|
|
22
35
|
<Story
|
|
23
36
|
name="Overview"
|
|
24
37
|
args={{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo
|
|
29
|
-
viverra nisl, in posuere dui urna eget quam.
|
|
30
|
-
</CheckboxCaption>,
|
|
31
|
-
],
|
|
38
|
+
label: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
39
|
+
caption:
|
|
40
|
+
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
32
41
|
checked: false,
|
|
42
|
+
disabled: false,
|
|
33
43
|
onChange: () => {},
|
|
34
44
|
}}
|
|
35
45
|
argTypes={checkboxArgTypes}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './components/Button/Button';
|
|
2
|
+
export * from './components/Checkbox/Checkbox';
|
|
2
3
|
export * from './components/Icon/Icon';
|
|
4
|
+
export * from './components/Inputs/BooleanInput/BooleanInput';
|
|
5
|
+
export * from './components/Inputs/TextInput/TextInput';
|
|
6
|
+
export * from './components/Loader/Loader';
|
|
3
7
|
export * from './layouts/Header/Header';
|
|
4
8
|
export * from './layouts/Header/HeaderProfile';
|
|
5
9
|
export * from './layouts/Navigation/Navigation';
|