krl-alfred 2.23.17 → 2.23.18
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/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +11 -1
- package/dist/components/Checkbox/Checkbox.styled.js +10 -4
- package/dist/components/Checkbox/Checkbox.test.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.test.js +38 -0
- package/dist/components/Checkbox/props.d.ts +8 -0
- package/dist/components/Checkbox/props.js +5 -2
- package/dist/components/Checkbox/stories/Checkbox.stories.d.ts +66 -0
- package/dist/components/Checkbox/stories/Checkbox.stories.js +14 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckboxProps } from "./props";
|
|
3
|
-
declare const Checkbox: ({ value, checked, onChange, name, id, label, disabled, size, valid, labelOffset, textSize, verticalAlign, required, readOnly, }: CheckboxProps) => import("react").JSX.Element;
|
|
3
|
+
declare const Checkbox: ({ value, checked, onChange, name, id, label, disabled, size, valid, labelOffset, textSize, verticalAlign, required, readOnly, isCheckable, variant, }: CheckboxProps) => import("react").JSX.Element;
|
|
4
4
|
export default Checkbox;
|
|
@@ -16,9 +16,16 @@ var props_1 = require("./props");
|
|
|
16
16
|
var Checkbox_styled_1 = require("./Checkbox.styled");
|
|
17
17
|
var react_i18next_1 = require("react-i18next");
|
|
18
18
|
var getRootCssVariable_1 = require("../../utils/getRootCssVariable");
|
|
19
|
+
var getCheckedColor = function (variant) {
|
|
20
|
+
if (variant === "success") {
|
|
21
|
+
return (0, getRootCssVariable_1.getRootCssVariable)("--green", "#0FDF7B");
|
|
22
|
+
}
|
|
23
|
+
return (0, getRootCssVariable_1.getPrimaryColor)();
|
|
24
|
+
};
|
|
19
25
|
var Checkbox = function (_a) {
|
|
20
|
-
var _b = _a.value, value = _b === void 0 ? props_1.CheckboxDefault.value : _b, _c = _a.checked, checked = _c === void 0 ? props_1.CheckboxDefault.checked : _c, _d = _a.onChange, onChange = _d === void 0 ? props_1.CheckboxDefault.onChange : _d, _e = _a.name, name = _e === void 0 ? props_1.CheckboxDefault.name : _e, _f = _a.id, id = _f === void 0 ? props_1.CheckboxDefault.id : _f, _g = _a.label, label = _g === void 0 ? props_1.CheckboxDefault.label : _g, _h = _a.disabled, disabled = _h === void 0 ? props_1.CheckboxDefault.disabled : _h, _j = _a.size, size = _j === void 0 ? props_1.CheckboxDefault.size : _j, _k = _a.valid, valid = _k === void 0 ? props_1.CheckboxDefault.valid : _k, _l = _a.labelOffset, labelOffset = _l === void 0 ? props_1.CheckboxDefault.labelOffset : _l, _m = _a.textSize, textSize = _m === void 0 ? props_1.CheckboxDefault.textSize : _m, _o = _a.verticalAlign, verticalAlign = _o === void 0 ? props_1.CheckboxDefault.verticalAlign : _o, _p = _a.required, required = _p === void 0 ? props_1.CheckboxDefault.required : _p, _q = _a.readOnly, readOnly = _q === void 0 ? props_1.CheckboxDefault.readOnly : _q;
|
|
26
|
+
var _b = _a.value, value = _b === void 0 ? props_1.CheckboxDefault.value : _b, _c = _a.checked, checked = _c === void 0 ? props_1.CheckboxDefault.checked : _c, _d = _a.onChange, onChange = _d === void 0 ? props_1.CheckboxDefault.onChange : _d, _e = _a.name, name = _e === void 0 ? props_1.CheckboxDefault.name : _e, _f = _a.id, id = _f === void 0 ? props_1.CheckboxDefault.id : _f, _g = _a.label, label = _g === void 0 ? props_1.CheckboxDefault.label : _g, _h = _a.disabled, disabled = _h === void 0 ? props_1.CheckboxDefault.disabled : _h, _j = _a.size, size = _j === void 0 ? props_1.CheckboxDefault.size : _j, _k = _a.valid, valid = _k === void 0 ? props_1.CheckboxDefault.valid : _k, _l = _a.labelOffset, labelOffset = _l === void 0 ? props_1.CheckboxDefault.labelOffset : _l, _m = _a.textSize, textSize = _m === void 0 ? props_1.CheckboxDefault.textSize : _m, _o = _a.verticalAlign, verticalAlign = _o === void 0 ? props_1.CheckboxDefault.verticalAlign : _o, _p = _a.required, required = _p === void 0 ? props_1.CheckboxDefault.required : _p, _q = _a.readOnly, readOnly = _q === void 0 ? props_1.CheckboxDefault.readOnly : _q, _r = _a.isCheckable, isCheckable = _r === void 0 ? props_1.CheckboxDefault.isCheckable : _r, _s = _a.variant, variant = _s === void 0 ? props_1.CheckboxDefault.variant : _s;
|
|
21
27
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
28
|
+
var checkedColor = getCheckedColor(variant);
|
|
22
29
|
var styledProps = {
|
|
23
30
|
disabled: disabled,
|
|
24
31
|
checked: checked,
|
|
@@ -26,9 +33,12 @@ var Checkbox = function (_a) {
|
|
|
26
33
|
$valid: valid,
|
|
27
34
|
$labelOffset: labelOffset,
|
|
28
35
|
$color: (0, getRootCssVariable_1.getPrimaryColor)(),
|
|
36
|
+
$checkedColor: checkedColor,
|
|
37
|
+
$variant: variant,
|
|
29
38
|
$textSize: textSize,
|
|
30
39
|
$verticalAlign: verticalAlign,
|
|
31
40
|
$required: required,
|
|
41
|
+
$isCheckable: isCheckable,
|
|
32
42
|
};
|
|
33
43
|
return ((0, jsx_runtime_1.jsxs)(Checkbox_styled_1.CheckboxWrapper, __assign({ htmlFor: id }, styledProps, { children: [(0, jsx_runtime_1.jsx)(Checkbox_styled_1.CheckboxInput, __assign({}, styledProps, { id: id, type: "checkbox", name: name, value: value, disabled: disabled, checked: checked, onChange: onChange, readOnly: readOnly })), (0, jsx_runtime_1.jsx)(Checkbox_styled_1.CheckboxIndicator, __assign({}, styledProps)), label && ((0, jsx_runtime_1.jsx)(Checkbox_styled_1.LabelsWrapper, __assign({}, styledProps, { children: (0, jsx_runtime_1.jsxs)(Checkbox_styled_1.CheckboxLabel, __assign({}, styledProps, { htmlFor: id }, { children: [label, " ", !required && (0, jsx_runtime_1.jsxs)("b", { children: ["(", t("OPTIONAL"), ")"] })] })) })))] })));
|
|
34
44
|
};
|
|
@@ -45,12 +45,18 @@ var getUncheckedBackground = function (props) {
|
|
|
45
45
|
return (0, svgToBase64_1.default)((0, jsx_runtime_1.jsx)(Icon_1.default, { hasWrapper: false, color: "#FF1F1F", name: "CheckboxElementInvalid" }));
|
|
46
46
|
};
|
|
47
47
|
var getCheckedBackground = function (props) {
|
|
48
|
-
return (0, svgToBase64_1.default)((0, jsx_runtime_1.jsx)(Icon_1.default, { hasWrapper: false, color: props.$color, name: "CheckboxElementChecked" }));
|
|
48
|
+
return (0, svgToBase64_1.default)((0, jsx_runtime_1.jsx)(Icon_1.default, { hasWrapper: false, color: props.$checkedColor || props.$color, name: "CheckboxElementChecked" }));
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
var getCheckboxCursor = function (props) {
|
|
51
|
+
if (props.disabled || props.$isCheckable === false) {
|
|
52
|
+
return 'default';
|
|
53
|
+
}
|
|
54
|
+
return 'pointer';
|
|
55
|
+
};
|
|
56
|
+
exports.CheckboxWrapper = styled_components_1.default.label(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex: 1;\n position: relative;\n align-items: ", ";\n justify-content: flex-start;\n display: grid;\n grid-template-columns: auto 1fr;\n cursor: ", ";\n"], ["\n flex: 1;\n position: relative;\n align-items: ", ";\n justify-content: flex-start;\n display: grid;\n grid-template-columns: auto 1fr;\n cursor: ", ";\n"])), function (props) { return props.$verticalAlign; }, function (props) { return getCheckboxCursor(props); });
|
|
57
|
+
exports.CheckboxIndicator = styled_components_1.default.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-image: url('", "');\n background-size: 100% 100%;\n display: block;\n position: relative;\n flex-shrink: 0;\n margin: ", " ", " 0 0;\n width: ", ";\n height: ", ";\n cursor: ", ";\n"], ["\n background-image: url('", "');\n background-size: 100% 100%;\n display: block;\n position: relative;\n flex-shrink: 0;\n margin: ", " ", " 0 0;\n width: ", ";\n height: ", ";\n cursor: ", ";\n"])), function (props) { return getUncheckedBackground(props); }, function (props) { return props.$verticalAlign === "flex-start" ? "1px" : 0; }, function (props) { return props.$labelOffset; }, function (props) { return getIndicatorSize(props.$size); }, function (props) { return getIndicatorSize(props.$size); }, function (props) { return getCheckboxCursor(props); });
|
|
52
58
|
exports.CheckboxInput = styled_components_1.default.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 0;\n width: 0;\n opacity: 0;\n z-index: -1;\n position: absolute;\n\n &:checked:not(:disabled) + ", " {\n background-image: url('", "');\n }\n"], ["\n height: 0;\n width: 0;\n opacity: 0;\n z-index: -1;\n position: absolute;\n\n &:checked:not(:disabled) + ", " {\n background-image: url('", "');\n }\n"])), exports.CheckboxIndicator, function (props) { return getCheckedBackground(props); });
|
|
53
|
-
exports.LabelsWrapper = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: grid;\n row-gap: 8px;\n cursor: ", ";\n margin: 0;\n color: ", ";\n\n * {\n ", ";\n }\n"], ["\n position: relative;\n display: grid;\n row-gap: 8px;\n cursor: ", ";\n margin: 0;\n color: ", ";\n\n * {\n ", ";\n }\n"])), function (props) { return props
|
|
59
|
+
exports.LabelsWrapper = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: grid;\n row-gap: 8px;\n cursor: ", ";\n margin: 0;\n color: ", ";\n\n * {\n ", ";\n }\n"], ["\n position: relative;\n display: grid;\n row-gap: 8px;\n cursor: ", ";\n margin: 0;\n color: ", ";\n\n * {\n ", ";\n }\n"])), function (props) { return getCheckboxCursor(props); }, function (props) {
|
|
54
60
|
if (props.disabled)
|
|
55
61
|
return 'var(--dark-opacity-25)';
|
|
56
62
|
return props.$valid ? 'var(--dark)' : 'var(--red)';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
var react_1 = require("@testing-library/react");
|
|
19
|
+
var Checkbox_1 = __importDefault(require("./Checkbox"));
|
|
20
|
+
var props_1 = require("./props");
|
|
21
|
+
var renderCheckbox = function (props) {
|
|
22
|
+
if (props === void 0) { props = {}; }
|
|
23
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.default, __assign({}, props_1.CheckboxDefault, { id: "checkbox-test", label: "Se\u00E7enek" }, props)));
|
|
24
|
+
};
|
|
25
|
+
describe('Checkbox', function () {
|
|
26
|
+
it('uses pointer cursor by default', function () {
|
|
27
|
+
var container = renderCheckbox().container;
|
|
28
|
+
expect(container.querySelector('label')).toHaveStyle({ cursor: 'pointer' });
|
|
29
|
+
});
|
|
30
|
+
it('uses default cursor when isCheckable is false', function () {
|
|
31
|
+
var container = renderCheckbox({ isCheckable: false }).container;
|
|
32
|
+
expect(container.querySelector('label')).toHaveStyle({ cursor: 'default' });
|
|
33
|
+
});
|
|
34
|
+
it('renders success variant when checked', function () {
|
|
35
|
+
renderCheckbox({ variant: 'success', checked: true });
|
|
36
|
+
expect(react_1.screen.getByText('Seçenek')).toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export declare const sizes: string[];
|
|
3
3
|
export declare const textSizes: string[];
|
|
4
|
+
export declare const variants: readonly ["default", "success"];
|
|
4
5
|
type SIZES = (typeof sizes)[number];
|
|
5
6
|
type TEXTSIZES = (typeof textSizes)[number];
|
|
7
|
+
type VARIANT = (typeof variants)[number];
|
|
6
8
|
export interface Checkbox {
|
|
7
9
|
disabled?: boolean;
|
|
8
10
|
value?: any;
|
|
@@ -19,6 +21,9 @@ export interface Checkbox {
|
|
|
19
21
|
verticalAlign?: string;
|
|
20
22
|
required?: boolean;
|
|
21
23
|
readOnly?: boolean;
|
|
24
|
+
/** false ise tıklanabilir görünüm (pointer cursor) kapalı kalır */
|
|
25
|
+
isCheckable?: boolean;
|
|
26
|
+
variant?: VARIANT;
|
|
22
27
|
}
|
|
23
28
|
export interface CheckboxStyledProps {
|
|
24
29
|
$labelOffset?: string;
|
|
@@ -35,6 +40,9 @@ export interface CheckboxStyledProps {
|
|
|
35
40
|
$color?: string;
|
|
36
41
|
$verticalAlign?: string;
|
|
37
42
|
$required?: boolean;
|
|
43
|
+
$isCheckable?: boolean;
|
|
44
|
+
$variant?: VARIANT;
|
|
45
|
+
$checkedColor?: string;
|
|
38
46
|
}
|
|
39
47
|
export declare const CheckboxDefault: Checkbox;
|
|
40
48
|
export type CheckboxProps = typeof CheckboxDefault;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CheckboxDefault = exports.textSizes = exports.sizes = void 0;
|
|
3
|
+
exports.CheckboxDefault = exports.variants = exports.textSizes = exports.sizes = void 0;
|
|
4
4
|
exports.sizes = ["small", "medium", "large"];
|
|
5
5
|
exports.textSizes = ["small", "medium", "large", "xlarge"];
|
|
6
|
+
exports.variants = ["default", "success"];
|
|
6
7
|
exports.CheckboxDefault = {
|
|
7
8
|
disabled: false,
|
|
8
9
|
value: undefined,
|
|
@@ -18,5 +19,7 @@ exports.CheckboxDefault = {
|
|
|
18
19
|
labelOffset: "0.5rem",
|
|
19
20
|
color: null,
|
|
20
21
|
verticalAlign: "center",
|
|
21
|
-
required: true
|
|
22
|
+
required: true,
|
|
23
|
+
isCheckable: true,
|
|
24
|
+
variant: "default",
|
|
22
25
|
};
|
|
@@ -30,6 +30,13 @@ declare const _default: {
|
|
|
30
30
|
readOnly: {
|
|
31
31
|
control: string;
|
|
32
32
|
};
|
|
33
|
+
isCheckable: {
|
|
34
|
+
control: string;
|
|
35
|
+
};
|
|
36
|
+
variant: {
|
|
37
|
+
control: string;
|
|
38
|
+
options: readonly ["default", "success"];
|
|
39
|
+
};
|
|
33
40
|
labelOffset: {
|
|
34
41
|
control: string;
|
|
35
42
|
};
|
|
@@ -133,6 +140,65 @@ export declare const DisabledChecked: {
|
|
|
133
140
|
onChange: (e: any) => void;
|
|
134
141
|
};
|
|
135
142
|
};
|
|
143
|
+
export declare const NotCheckable: {
|
|
144
|
+
name: string;
|
|
145
|
+
args: {
|
|
146
|
+
isCheckable: boolean;
|
|
147
|
+
checked: boolean;
|
|
148
|
+
id: string;
|
|
149
|
+
label: string;
|
|
150
|
+
valid: boolean;
|
|
151
|
+
disabled: boolean;
|
|
152
|
+
required: boolean;
|
|
153
|
+
readOnly: boolean;
|
|
154
|
+
size: string;
|
|
155
|
+
textSize: string;
|
|
156
|
+
labelOffset: string;
|
|
157
|
+
verticalAlign: string;
|
|
158
|
+
name: string;
|
|
159
|
+
value: string;
|
|
160
|
+
onChange: (e: any) => void;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export declare const Success: {
|
|
164
|
+
args: {
|
|
165
|
+
variant: string;
|
|
166
|
+
checked: boolean;
|
|
167
|
+
label: string;
|
|
168
|
+
id: string;
|
|
169
|
+
valid: boolean;
|
|
170
|
+
disabled: boolean;
|
|
171
|
+
required: boolean;
|
|
172
|
+
readOnly: boolean;
|
|
173
|
+
size: string;
|
|
174
|
+
textSize: string;
|
|
175
|
+
labelOffset: string;
|
|
176
|
+
verticalAlign: string;
|
|
177
|
+
name: string;
|
|
178
|
+
value: string;
|
|
179
|
+
onChange: (e: any) => void;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export declare const SuccessUnchecked: {
|
|
183
|
+
name: string;
|
|
184
|
+
args: {
|
|
185
|
+
variant: string;
|
|
186
|
+
checked: boolean;
|
|
187
|
+
label: string;
|
|
188
|
+
id: string;
|
|
189
|
+
valid: boolean;
|
|
190
|
+
disabled: boolean;
|
|
191
|
+
required: boolean;
|
|
192
|
+
readOnly: boolean;
|
|
193
|
+
size: string;
|
|
194
|
+
textSize: string;
|
|
195
|
+
labelOffset: string;
|
|
196
|
+
verticalAlign: string;
|
|
197
|
+
name: string;
|
|
198
|
+
value: string;
|
|
199
|
+
onChange: (e: any) => void;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
136
202
|
export declare const Invalid: {
|
|
137
203
|
args: {
|
|
138
204
|
valid: boolean;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Complete = exports.Interactive = exports.AllTextSizes = exports.AllSizes = exports.LongLabel = exports.WithHtmlLabel = exports.WithoutLabel = exports.VerticalAlignStart = exports.CustomLabelOffset = exports.TextSizeXlarge = exports.TextSizeLarge = exports.Large = exports.Medium = exports.Small = exports.ReadOnly = exports.OptionalChecked = exports.Optional = exports.InvalidChecked = exports.Invalid = exports.DisabledChecked = exports.Disabled = exports.Unchecked = exports.Checked = exports.Default = void 0;
|
|
17
|
+
exports.Complete = exports.Interactive = exports.AllTextSizes = exports.AllSizes = exports.LongLabel = exports.WithHtmlLabel = exports.WithoutLabel = exports.VerticalAlignStart = exports.CustomLabelOffset = exports.TextSizeXlarge = exports.TextSizeLarge = exports.Large = exports.Medium = exports.Small = exports.ReadOnly = exports.OptionalChecked = exports.Optional = exports.InvalidChecked = exports.Invalid = exports.SuccessUnchecked = exports.Success = exports.NotCheckable = exports.DisabledChecked = exports.Disabled = exports.Unchecked = exports.Checked = exports.Default = void 0;
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
var react_1 = __importDefault(require("react"));
|
|
20
20
|
var Checkbox_1 = __importDefault(require("../Checkbox"));
|
|
@@ -48,6 +48,8 @@ exports.default = {
|
|
|
48
48
|
valid: { control: "boolean" },
|
|
49
49
|
required: { control: "boolean" },
|
|
50
50
|
readOnly: { control: "boolean" },
|
|
51
|
+
isCheckable: { control: "boolean" },
|
|
52
|
+
variant: { control: "select", options: props_1.variants },
|
|
51
53
|
labelOffset: { control: "text" },
|
|
52
54
|
verticalAlign: {
|
|
53
55
|
control: "select",
|
|
@@ -71,6 +73,17 @@ exports.Disabled = {
|
|
|
71
73
|
exports.DisabledChecked = {
|
|
72
74
|
args: __assign(__assign({}, baseArgs), { disabled: true, checked: true, id: "check_disabled_checked" }),
|
|
73
75
|
};
|
|
76
|
+
exports.NotCheckable = {
|
|
77
|
+
name: "Not checkable (isCheckable: false)",
|
|
78
|
+
args: __assign(__assign({}, baseArgs), { isCheckable: false, checked: true, id: "check_not_checkable" }),
|
|
79
|
+
};
|
|
80
|
+
exports.Success = {
|
|
81
|
+
args: __assign(__assign({}, baseArgs), { variant: "success", checked: true, label: "Onaylandı", id: "check_success" }),
|
|
82
|
+
};
|
|
83
|
+
exports.SuccessUnchecked = {
|
|
84
|
+
name: "Success — unchecked",
|
|
85
|
+
args: __assign(__assign({}, baseArgs), { variant: "success", checked: false, label: "Onay bekliyor", id: "check_success_unchecked" }),
|
|
86
|
+
};
|
|
74
87
|
exports.Invalid = {
|
|
75
88
|
args: __assign(__assign({}, baseArgs), { valid: false, id: "check_invalid" }),
|
|
76
89
|
};
|