krl-alfred 2.24.11 → 2.25.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.
- package/dist/components/AddressCard/AddressCard.d.ts +1 -1
- package/dist/components/AddressCard/AddressCard.js +2 -2
- package/dist/components/AddressCard/AddressCard.styled.d.ts +1 -0
- package/dist/components/AddressCard/AddressCard.styled.js +5 -4
- package/dist/components/AddressCard/AddressCard.test.d.ts +1 -0
- package/dist/components/AddressCard/AddressCard.test.js +148 -0
- package/dist/components/AddressCard/props.d.ts +4 -0
- package/dist/components/AddressCard/props.js +1 -0
- package/dist/components/AddressCard/stories/AddressCard.stories.d.ts +21 -0
- package/dist/components/AddressCard/stories/AddressCard.stories.js +5 -1
- package/dist/components/Input/stories/Input.stories.d.ts +37 -0
- package/dist/components/Input/stories/Input.stories.js +7 -1
- package/dist/components/LoadingBar/LoadingBar.d.ts +4 -0
- package/dist/components/LoadingBar/LoadingBar.js +28 -0
- package/dist/components/LoadingBar/LoadingBar.styled.d.ts +2 -0
- package/dist/components/LoadingBar/LoadingBar.styled.js +13 -0
- package/dist/components/LoadingBar/LoadingBar.test.d.ts +1 -0
- package/dist/components/LoadingBar/LoadingBar.test.js +97 -0
- package/dist/components/LoadingBar/index.d.ts +1 -0
- package/dist/components/LoadingBar/index.js +8 -0
- package/dist/components/LoadingBar/props.d.ts +12 -0
- package/dist/components/LoadingBar/props.js +12 -0
- package/dist/components/LoadingBar/stories/LoadingBar.stories.d.ts +78 -0
- package/dist/components/LoadingBar/stories/LoadingBar.stories.js +56 -0
- package/dist/components/LoadingBar/utils/progress.d.ts +5 -0
- package/dist/components/LoadingBar/utils/progress.js +35 -0
- package/dist/components/QuantitySelector/QuantitySelector.js +3 -1
- package/dist/components/QuantitySelector/QuantitySelector.test.js +21 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AddressCardProps } from "./props";
|
|
3
|
-
declare const AddressCard: ({ title, description, content, handleUpdate, onChange, checked, isShowEditBtn, id, minHeight, name, value, disabled, hasBlockDescription }: AddressCardProps) => React.JSX.Element;
|
|
3
|
+
declare const AddressCard: ({ title, description, content, handleUpdate, onChange, checked, isShowEditBtn, id, minHeight, name, value, disabled, hasBlockDescription, notice }: AddressCardProps) => React.JSX.Element;
|
|
4
4
|
export default AddressCard;
|
|
@@ -21,8 +21,8 @@ var RadioButton_1 = __importDefault(require("../RadioButton"));
|
|
|
21
21
|
var TextLink_1 = __importDefault(require("../TextLink"));
|
|
22
22
|
var react_i18next_1 = require("react-i18next");
|
|
23
23
|
var AddressCard = function (_a) {
|
|
24
|
-
var _b = _a.title, title = _b === void 0 ? props_1.AddressCardDefault.title : _b, _c = _a.description, description = _c === void 0 ? props_1.AddressCardDefault.description : _c, _d = _a.content, content = _d === void 0 ? props_1.AddressCardDefault.content : _d, _e = _a.handleUpdate, handleUpdate = _e === void 0 ? props_1.AddressCardDefault.handleUpdate : _e, _f = _a.onChange, onChange = _f === void 0 ? props_1.AddressCardDefault.onChange : _f, _g = _a.checked, checked = _g === void 0 ? props_1.AddressCardDefault.checked : _g, _h = _a.isShowEditBtn, isShowEditBtn = _h === void 0 ? props_1.AddressCardDefault.isShowEditBtn : _h, _j = _a.id, id = _j === void 0 ? props_1.AddressCardDefault.id : _j, _k = _a.minHeight, minHeight = _k === void 0 ? props_1.AddressCardDefault.minHeight : _k, _l = _a.name, name = _l === void 0 ? props_1.AddressCardDefault.name : _l, _m = _a.value, value = _m === void 0 ? props_1.AddressCardDefault.value : _m, _o = _a.disabled, disabled = _o === void 0 ? props_1.AddressCardDefault.disabled : _o, _p = _a.hasBlockDescription, hasBlockDescription = _p === void 0 ? props_1.AddressCardDefault.hasBlockDescription : _p;
|
|
24
|
+
var _b = _a.title, title = _b === void 0 ? props_1.AddressCardDefault.title : _b, _c = _a.description, description = _c === void 0 ? props_1.AddressCardDefault.description : _c, _d = _a.content, content = _d === void 0 ? props_1.AddressCardDefault.content : _d, _e = _a.handleUpdate, handleUpdate = _e === void 0 ? props_1.AddressCardDefault.handleUpdate : _e, _f = _a.onChange, onChange = _f === void 0 ? props_1.AddressCardDefault.onChange : _f, _g = _a.checked, checked = _g === void 0 ? props_1.AddressCardDefault.checked : _g, _h = _a.isShowEditBtn, isShowEditBtn = _h === void 0 ? props_1.AddressCardDefault.isShowEditBtn : _h, _j = _a.id, id = _j === void 0 ? props_1.AddressCardDefault.id : _j, _k = _a.minHeight, minHeight = _k === void 0 ? props_1.AddressCardDefault.minHeight : _k, _l = _a.name, name = _l === void 0 ? props_1.AddressCardDefault.name : _l, _m = _a.value, value = _m === void 0 ? props_1.AddressCardDefault.value : _m, _o = _a.disabled, disabled = _o === void 0 ? props_1.AddressCardDefault.disabled : _o, _p = _a.hasBlockDescription, hasBlockDescription = _p === void 0 ? props_1.AddressCardDefault.hasBlockDescription : _p, _q = _a.notice, notice = _q === void 0 ? props_1.AddressCardDefault.notice : _q;
|
|
25
25
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
26
|
-
return ((0, jsx_runtime_1.jsxs)(AddressCard_styled_1.AddressCardStyled, __assign({ htmlFor: id, checked: checked, "$minHeight": minHeight, "$hasBlockDescription": hasBlockDescription }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ className: "head" }, { children: [(0, jsx_runtime_1.jsx)(RadioButton_1.default, { id: id, onChange: onChange, checked: checked, isWrapText: false, layout: "basic", size: "small", label: title, name: name, value: value, disabled: disabled, textSize: "large" }), isShowEditBtn && ((0, jsx_runtime_1.jsx)("label", __assign({ htmlFor: "xxxxx", className: "editBtn" }, { children: (0, jsx_runtime_1.jsx)(TextLink_1.default, __assign({ onClick: handleUpdate }, { children: t("edit") })) })))] })), description && (0, jsx_runtime_1.
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(AddressCard_styled_1.AddressCardStyled, __assign({ htmlFor: id, checked: checked, "$minHeight": minHeight, "$hasBlockDescription": hasBlockDescription, "$disabled": disabled, "$hasNotice": Boolean(notice) }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ className: "head" }, { children: [(0, jsx_runtime_1.jsx)(RadioButton_1.default, { id: id, onChange: onChange, checked: checked, isWrapText: false, layout: "basic", size: "small", label: title, name: name, value: value, disabled: disabled, textSize: "large" }), isShowEditBtn && ((0, jsx_runtime_1.jsx)("label", __assign({ htmlFor: "xxxxx", className: "editBtn" }, { children: (0, jsx_runtime_1.jsx)(TextLink_1.default, __assign({ onClick: handleUpdate }, { children: t("edit") })) })))] })), (description || notice) && ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "description" }, { children: [description, notice ? (0, jsx_runtime_1.jsx)(AddressCard_styled_1.Notice, { children: notice }) : null] }))), checked && content != null && ((0, jsx_runtime_1.jsx)(AddressCard_styled_1.Content, { children: content }))] })));
|
|
27
27
|
};
|
|
28
28
|
exports.default = AddressCard;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { AddressCardStyledProps } from "./props";
|
|
3
3
|
export declare const AddressCardStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, keyof AddressCardStyledProps> & AddressCardStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, keyof AddressCardStyledProps> & AddressCardStyledProps, never>>> & string;
|
|
4
|
+
export declare const Notice: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
|
|
4
5
|
export declare const Content: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
@@ -7,9 +7,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.Content = exports.AddressCardStyled = void 0;
|
|
10
|
+
exports.Content = exports.Notice = exports.AddressCardStyled = void 0;
|
|
11
11
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
12
|
var devices_1 = require("../../constants/devices");
|
|
13
|
-
exports.AddressCardStyled = styled_components_1.default.label(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 0.5rem;\n border: 1px solid var(--border);\n background: var(--bg);\n padding: 1rem;\n cursor:
|
|
14
|
-
exports.
|
|
15
|
-
|
|
13
|
+
exports.AddressCardStyled = styled_components_1.default.label(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 0.5rem;\n border: 1px solid var(--border);\n background: var(--bg);\n padding: 1rem;\n cursor: ", ";\n display: block;\n position: relative;\n box-sizing: border-box;\n\n &:before {\n content: \"\";\n position: absolute;\n inset: -1px;\n border: 2px solid var(--primary);\n opacity: ", ";\n user-select: none;\n pointer-events: none;\n border-radius: inherit;\n }\n\n ", "\n\n ", "\n .head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: inherit;\n\n .editBtn {\n font: var(--body-bold-14-17);\n margin-left: 1rem;\n display: block;\n\n * {\n display: block;\n }\n }\n }\n\n .description {\n margin-top: 1.5rem;\n -webkit-line-clamp: 4;\n -webkit-box-orient: vertical;\n overflow: hidden;\n word-break: break-word;\n font: var(--body-regular-14-17);\n color: ", ";\n height: ", ";\n cursor: inherit;\n display: ", ";\n -webkit-line-clamp: ", ";\n -webkit-box-orient: ", ";\n vertical-align: ", ";\n ", "\n }\n"], ["\n border-radius: 0.5rem;\n border: 1px solid var(--border);\n background: var(--bg);\n padding: 1rem;\n cursor: ", ";\n display: block;\n position: relative;\n box-sizing: border-box;\n\n &:before {\n content: \"\";\n position: absolute;\n inset: -1px;\n border: 2px solid var(--primary);\n opacity: ", ";\n user-select: none;\n pointer-events: none;\n border-radius: inherit;\n }\n\n ", "\n\n ", "\n .head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: inherit;\n\n .editBtn {\n font: var(--body-bold-14-17);\n margin-left: 1rem;\n display: block;\n\n * {\n display: block;\n }\n }\n }\n\n .description {\n margin-top: 1.5rem;\n -webkit-line-clamp: 4;\n -webkit-box-orient: vertical;\n overflow: hidden;\n word-break: break-word;\n font: var(--body-regular-14-17);\n color: ", ";\n height: ", ";\n cursor: inherit;\n display: ", ";\n -webkit-line-clamp: ", ";\n -webkit-box-orient: ", ";\n vertical-align: ", ";\n ", "\n }\n"])), function (props) { return props.$disabled ? 'not-allowed' : 'pointer'; }, function (props) { return props.checked ? '1' : '0'; }, function (props) { return props.$disabled && "\n .head > label:first-child,\n .head > label:first-child * {\n color: var(--text-disabled);\n }\n "; }, function (props) { return !props.checked && !props.$disabled && "\n @media only screen and ".concat(devices_1.devices.mdUp, " {\n &:hover {\n &:before{\n border: 1px solid var(--primary);\n opacity: 1;\n } \n }\n }\n &:active {\n &:before{\n border: 1px solid var(--primary);\n opacity: 1;\n } \n }\n "); }, function (props) { return props.$disabled ? 'var(--text-disabled)' : 'var(--text)'; }, function (props) { return props.$minHeight ? props.$minHeight : '68px'; }, function (props) { return props.$hasBlockDescription || props.$hasNotice ? 'block' : '-webkit-inline-box'; }, function (props) { return props.$hasBlockDescription || props.$hasNotice ? 'unset' : '4'; }, function (props) { return props.$hasBlockDescription || props.$hasNotice ? 'unset' : 'vertical'; }, function (props) { return props.$hasBlockDescription || props.$hasNotice ? 'unset' : 'middle'; }, function (props) { return props.$hasNotice && "\n height: auto;\n overflow: visible;\n "; });
|
|
14
|
+
exports.Notice = styled_components_1.default.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: block;\n margin-top: 0.25rem;\n font: var(--body-medium-13-16);\n color: var(--text-soft);\n"], ["\n display: block;\n margin-top: 0.25rem;\n font: var(--body-medium-13-16);\n color: var(--text-soft);\n"])));
|
|
15
|
+
exports.Content = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin-top: 1rem;\n cursor: default;\n"], ["\n margin-top: 1rem;\n cursor: default;\n"])));
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
56
|
+
var AddressCard_1 = __importDefault(require("./AddressCard"));
|
|
57
|
+
var props_1 = require("./props");
|
|
58
|
+
jest.mock('react-i18next', function () { return ({
|
|
59
|
+
useTranslation: function () { return ({
|
|
60
|
+
t: function (key) { return key; },
|
|
61
|
+
}); },
|
|
62
|
+
}); });
|
|
63
|
+
var renderCard = function (props) {
|
|
64
|
+
if (props === void 0) { props = {}; }
|
|
65
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(AddressCard_1.default, __assign({}, props_1.AddressCardDefault, { id: "address-1", name: "address", value: "home", title: "Ev", description: "Ba\u011Fdat Cad. No:12", onChange: jest.fn(), handleUpdate: jest.fn() }, props)));
|
|
66
|
+
};
|
|
67
|
+
describe('AddressCard', function () {
|
|
68
|
+
it('renders title and description', function () {
|
|
69
|
+
renderCard();
|
|
70
|
+
expect(react_1.screen.getByText('Ev')).toBeInTheDocument();
|
|
71
|
+
expect(react_1.screen.getByText('Bağdat Cad. No:12')).toBeInTheDocument();
|
|
72
|
+
});
|
|
73
|
+
it('calls onChange when the radio is selected', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
var onChange;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
onChange = jest.fn();
|
|
79
|
+
renderCard({ onChange: onChange });
|
|
80
|
+
return [4 /*yield*/, user_event_1.default.click(react_1.screen.getByRole('radio'))];
|
|
81
|
+
case 1:
|
|
82
|
+
_a.sent();
|
|
83
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}); });
|
|
88
|
+
it('calls handleUpdate when edit is clicked', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
+
var handleUpdate;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0:
|
|
93
|
+
handleUpdate = jest.fn();
|
|
94
|
+
renderCard({ handleUpdate: handleUpdate });
|
|
95
|
+
return [4 /*yield*/, user_event_1.default.click(react_1.screen.getByText('edit'))];
|
|
96
|
+
case 1:
|
|
97
|
+
_a.sent();
|
|
98
|
+
expect(handleUpdate).toHaveBeenCalledTimes(1);
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}); });
|
|
103
|
+
it('shows extra content only when checked', function () {
|
|
104
|
+
var rerender = renderCard({ checked: false, content: (0, jsx_runtime_1.jsx)("span", { children: "Ek i\u00E7erik" }) }).rerender;
|
|
105
|
+
expect(react_1.screen.queryByText('Ek içerik')).not.toBeInTheDocument();
|
|
106
|
+
rerender((0, jsx_runtime_1.jsx)(AddressCard_1.default, __assign({}, props_1.AddressCardDefault, { id: "address-1", title: "Ev", checked: true, content: (0, jsx_runtime_1.jsx)("span", { children: "Ek i\u00E7erik" }) })));
|
|
107
|
+
expect(react_1.screen.getByText('Ek içerik')).toBeInTheDocument();
|
|
108
|
+
});
|
|
109
|
+
it('does not call onChange when disabled', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
|
+
var onChange;
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
onChange = jest.fn();
|
|
115
|
+
renderCard({ disabled: true, onChange: onChange });
|
|
116
|
+
return [4 /*yield*/, user_event_1.default.click(react_1.screen.getByRole('radio'))];
|
|
117
|
+
case 1:
|
|
118
|
+
_a.sent();
|
|
119
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
120
|
+
return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}); });
|
|
124
|
+
it('dims the title and address when disabled', function () {
|
|
125
|
+
renderCard({ disabled: true });
|
|
126
|
+
expect(react_1.screen.getByText('Ev')).toHaveStyle({ color: 'var(--text-disabled)' });
|
|
127
|
+
expect(react_1.screen.getByText('Bağdat Cad. No:12')).toHaveStyle({ color: 'var(--text-disabled)' });
|
|
128
|
+
});
|
|
129
|
+
it('renders the unavailable notice under the address', function () {
|
|
130
|
+
var container = renderCard({
|
|
131
|
+
disabled: true,
|
|
132
|
+
notice: 'Bu bölgeye teslimat yapılmıyor',
|
|
133
|
+
}).container;
|
|
134
|
+
var notice = react_1.screen.getByText('Bu bölgeye teslimat yapılmıyor');
|
|
135
|
+
expect(notice).toHaveStyle({ color: 'var(--text-soft)' });
|
|
136
|
+
expect(container.firstChild).toHaveStyle({ cursor: 'not-allowed' });
|
|
137
|
+
});
|
|
138
|
+
it('renders unsafe title, description and notice as text', function () {
|
|
139
|
+
var payload = '<script>alert(1)</script>';
|
|
140
|
+
var container = renderCard({
|
|
141
|
+
title: payload,
|
|
142
|
+
description: payload,
|
|
143
|
+
notice: payload,
|
|
144
|
+
}).container;
|
|
145
|
+
expect(container.querySelector('script')).not.toBeInTheDocument();
|
|
146
|
+
expect(container.textContent).toContain(payload);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -13,11 +13,15 @@ export interface AddressCard {
|
|
|
13
13
|
value?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
hasBlockDescription?: boolean;
|
|
16
|
+
/** Adres satırının altında, örn. teslimat yapılamayan bölge notu. */
|
|
17
|
+
notice?: string;
|
|
16
18
|
}
|
|
17
19
|
export interface AddressCardStyledProps {
|
|
18
20
|
checked?: boolean;
|
|
19
21
|
$minHeight?: string;
|
|
20
22
|
$hasBlockDescription?: boolean;
|
|
23
|
+
$disabled?: boolean;
|
|
24
|
+
$hasNotice?: boolean;
|
|
21
25
|
}
|
|
22
26
|
export declare const AddressCardDefault: AddressCard;
|
|
23
27
|
export type AddressCardProps = typeof AddressCardDefault;
|
|
@@ -23,6 +23,9 @@ declare const _default: {
|
|
|
23
23
|
hasBlockDescription: {
|
|
24
24
|
control: string;
|
|
25
25
|
};
|
|
26
|
+
notice: {
|
|
27
|
+
control: string;
|
|
28
|
+
};
|
|
26
29
|
minHeight: {
|
|
27
30
|
control: string;
|
|
28
31
|
};
|
|
@@ -134,6 +137,24 @@ export declare const Disabled: {
|
|
|
134
137
|
content: any;
|
|
135
138
|
};
|
|
136
139
|
};
|
|
140
|
+
export declare const Unavailable: {
|
|
141
|
+
args: {
|
|
142
|
+
title: string;
|
|
143
|
+
description: string;
|
|
144
|
+
id: string;
|
|
145
|
+
value: string;
|
|
146
|
+
disabled: boolean;
|
|
147
|
+
isShowEditBtn: boolean;
|
|
148
|
+
minHeight: string;
|
|
149
|
+
notice: string;
|
|
150
|
+
handleUpdate: () => void;
|
|
151
|
+
onChange: () => void;
|
|
152
|
+
name: string;
|
|
153
|
+
checked: boolean;
|
|
154
|
+
hasBlockDescription: boolean;
|
|
155
|
+
content: any;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
137
158
|
export declare const DisabledChecked: {
|
|
138
159
|
args: {
|
|
139
160
|
title: string;
|
|
@@ -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.AddressList = exports.BlockDescriptionChecked = exports.BlockDescription = exports.WithContentAndEdit = exports.WithContentOpen = exports.WithContent = exports.CustomMinHeight = exports.LongDescription = exports.ShortDescription = exports.DisabledWithoutEditButton = exports.DisabledChecked = exports.Disabled = exports.WithoutDescription = exports.WithoutEditButtonChecked = exports.WithoutEditButton = exports.Checked = exports.Default = void 0;
|
|
17
|
+
exports.Complete = exports.AddressList = exports.BlockDescriptionChecked = exports.BlockDescription = exports.WithContentAndEdit = exports.WithContentOpen = exports.WithContent = exports.CustomMinHeight = exports.LongDescription = exports.ShortDescription = exports.DisabledWithoutEditButton = exports.DisabledChecked = exports.Unavailable = exports.Disabled = exports.WithoutDescription = exports.WithoutEditButtonChecked = exports.WithoutEditButton = 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 AddressCard_1 = __importDefault(require("../AddressCard"));
|
|
@@ -86,6 +86,7 @@ exports.default = {
|
|
|
86
86
|
disabled: { control: "boolean" },
|
|
87
87
|
isShowEditBtn: { control: "boolean" },
|
|
88
88
|
hasBlockDescription: { control: "boolean" },
|
|
89
|
+
notice: { control: "text" },
|
|
89
90
|
minHeight: { control: "text" },
|
|
90
91
|
content: { control: false },
|
|
91
92
|
},
|
|
@@ -108,6 +109,9 @@ exports.WithoutDescription = {
|
|
|
108
109
|
exports.Disabled = {
|
|
109
110
|
args: __assign(__assign({}, baseArgs), { title: "Disabled Address", id: "addressCard_5", value: "address_5", disabled: true }),
|
|
110
111
|
};
|
|
112
|
+
exports.Unavailable = {
|
|
113
|
+
args: __assign(__assign({}, baseArgs), { title: "Ev", description: "Bağdat Cad. No:12, Kadıköy / İstanbul", id: "addressCard_unavailable", value: "address_unavailable", disabled: true, isShowEditBtn: false, minHeight: "auto", notice: "Bu bölgeye teslimat yapılmıyor" }),
|
|
114
|
+
};
|
|
111
115
|
exports.DisabledChecked = {
|
|
112
116
|
args: __assign(__assign({}, baseArgs), { title: "Disabled Selected Address", id: "addressCard_6", value: "address_6", checked: true, disabled: true }),
|
|
113
117
|
};
|
|
@@ -268,6 +268,43 @@ export declare const DateWithMinMax: {
|
|
|
268
268
|
onChange: (e: any) => void;
|
|
269
269
|
};
|
|
270
270
|
};
|
|
271
|
+
export declare const Time: {
|
|
272
|
+
args: {
|
|
273
|
+
label: string;
|
|
274
|
+
placeholder: string;
|
|
275
|
+
format: string;
|
|
276
|
+
mask: string;
|
|
277
|
+
allowEmptyFormatting: boolean;
|
|
278
|
+
id: string;
|
|
279
|
+
hasError: boolean;
|
|
280
|
+
disabled: boolean;
|
|
281
|
+
readOnly: boolean;
|
|
282
|
+
isClearable: boolean;
|
|
283
|
+
type: string;
|
|
284
|
+
infoText: any;
|
|
285
|
+
tooltipText: any;
|
|
286
|
+
onChange: (e: any) => void;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
export declare const TimeWithValue: {
|
|
290
|
+
args: {
|
|
291
|
+
label: string;
|
|
292
|
+
placeholder: string;
|
|
293
|
+
format: string;
|
|
294
|
+
mask: string;
|
|
295
|
+
allowEmptyFormatting: boolean;
|
|
296
|
+
value: string;
|
|
297
|
+
id: string;
|
|
298
|
+
hasError: boolean;
|
|
299
|
+
disabled: boolean;
|
|
300
|
+
readOnly: boolean;
|
|
301
|
+
isClearable: boolean;
|
|
302
|
+
type: string;
|
|
303
|
+
infoText: any;
|
|
304
|
+
tooltipText: any;
|
|
305
|
+
onChange: (e: any) => void;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
271
308
|
export declare const WithCopyButton: {
|
|
272
309
|
args: {
|
|
273
310
|
placeholder: string;
|
|
@@ -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.Interactive = exports.PercentageMaskWithValue = exports.PercentageMask = exports.WithMaxLengthAndDescription = exports.ErrorWithCustomLink = exports.Complete = exports.CustomWidth = exports.Number = exports.Tel = exports.Email = exports.PatternFormatWithValue = exports.PatternFormat = exports.PriceFormat = exports.NumericFormat = exports.WithTooltip = exports.WithInfoText = exports.Clearable = exports.WithCopyButton = exports.DateWithMinMax = exports.DateInline = exports.DateInput = exports.PasswordWithValue = exports.Password = exports.WithCustomLink = exports.ReadOnly = exports.Disabled = exports.WithError = exports.WithLabel = exports.WithValue = exports.Empty = exports.Default = void 0;
|
|
17
|
+
exports.Interactive = exports.PercentageMaskWithValue = exports.PercentageMask = exports.WithMaxLengthAndDescription = exports.ErrorWithCustomLink = exports.Complete = exports.CustomWidth = exports.Number = exports.Tel = exports.Email = exports.PatternFormatWithValue = exports.PatternFormat = exports.PriceFormat = exports.NumericFormat = exports.WithTooltip = exports.WithInfoText = exports.Clearable = exports.WithCopyButton = exports.TimeWithValue = exports.Time = exports.DateWithMinMax = exports.DateInline = exports.DateInput = exports.PasswordWithValue = exports.Password = exports.WithCustomLink = exports.ReadOnly = exports.Disabled = exports.WithError = exports.WithLabel = exports.WithValue = exports.Empty = 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 Input_1 = __importDefault(require("../Input"));
|
|
@@ -244,6 +244,12 @@ exports.DateWithMinMax = {
|
|
|
244
244
|
}
|
|
245
245
|
},
|
|
246
246
|
};
|
|
247
|
+
exports.Time = {
|
|
248
|
+
args: __assign(__assign({}, baseArgs), { label: "Saat", placeholder: "Örn: 07:00", format: "##:##", mask: "_", allowEmptyFormatting: false, id: "input_time" }),
|
|
249
|
+
};
|
|
250
|
+
exports.TimeWithValue = {
|
|
251
|
+
args: __assign(__assign({}, baseArgs), { label: "Saat", placeholder: "Örn: 10:30", format: "##:##", mask: "_", allowEmptyFormatting: false, value: "14:30", id: "input_time_value" }),
|
|
252
|
+
};
|
|
247
253
|
exports.WithCopyButton = {
|
|
248
254
|
args: {
|
|
249
255
|
placeholder: "Copy this text",
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
var react_1 = require("react");
|
|
16
|
+
var props_1 = require("./props");
|
|
17
|
+
var LoadingBar_styled_1 = require("./LoadingBar.styled");
|
|
18
|
+
var progress_1 = require("./utils/progress");
|
|
19
|
+
var LoadingBar = function (_a) {
|
|
20
|
+
var _b = _a.title, title = _b === void 0 ? props_1.LoadingBarDefault.title : _b, _c = _a.description, description = _c === void 0 ? props_1.LoadingBarDefault.description : _c, _d = _a.value, value = _d === void 0 ? props_1.LoadingBarDefault.value : _d, _e = _a.total, total = _e === void 0 ? props_1.LoadingBarDefault.total : _e, _f = _a.format, format = _f === void 0 ? props_1.LoadingBarDefault.format : _f, _g = _a.progressText, progressText = _g === void 0 ? props_1.LoadingBarDefault.progressText : _g;
|
|
21
|
+
var titleId = (0, react_1.useId)();
|
|
22
|
+
var descriptionId = (0, react_1.useId)();
|
|
23
|
+
var progress = (0, progress_1.getLoadingProgress)(value, total);
|
|
24
|
+
var current = (0, progress_1.getLoadingCurrent)(value, total);
|
|
25
|
+
var max = (0, progress_1.getLoadingTotal)(total);
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(LoadingBar_styled_1.LoadingBarStyled, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ className: "header" }, { children: [title ? ((0, jsx_runtime_1.jsx)("p", __assign({ className: "title", id: titleId }, { children: title }))) : null, (0, jsx_runtime_1.jsx)("p", __assign({ className: "value" }, { children: progressText || (0, progress_1.formatLoadingValue)(value, total, format) }))] })), (0, jsx_runtime_1.jsxs)("div", __assign({ className: "body" }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ className: "track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": max, "aria-valuenow": current, "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined }, { children: (0, jsx_runtime_1.jsx)("div", { className: "fill", style: { width: "".concat(progress, "%") } }) })), description ? ((0, jsx_runtime_1.jsx)("p", __assign({ className: "description", id: descriptionId }, { children: description }))) : null] }))] }));
|
|
27
|
+
};
|
|
28
|
+
exports.default = LoadingBar;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const LoadingBarStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LoadingBarStyled = void 0;
|
|
11
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
exports.LoadingBarStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 16px;\n width: 100%;\n\n .header {\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n gap: 16px;\n width: 100%;\n }\n\n .title {\n margin: 0;\n color: var(--dark);\n font: var(--caption-semi-bold-12-15);\n }\n\n .value {\n margin: 0 0 0 auto;\n flex-shrink: 0;\n color: var(--grey-50);\n font: var(--caption-semi-bold-11-13);\n white-space: nowrap;\n }\n\n .body {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n width: 100%;\n }\n\n .track {\n width: 100%;\n height: 4px;\n border-radius: 16px;\n background-color: var(--dark-opacity-5);\n overflow: hidden;\n }\n\n .fill {\n height: 4px;\n border-radius: 16px;\n background-color: var(--primary);\n transition: width 0.2s ease;\n }\n\n .description {\n margin: 0;\n width: 100%;\n color: var(--dark-opacity-50);\n font: var(--caption-medium-12-15);\n }\n"], ["\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 16px;\n width: 100%;\n\n .header {\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n gap: 16px;\n width: 100%;\n }\n\n .title {\n margin: 0;\n color: var(--dark);\n font: var(--caption-semi-bold-12-15);\n }\n\n .value {\n margin: 0 0 0 auto;\n flex-shrink: 0;\n color: var(--grey-50);\n font: var(--caption-semi-bold-11-13);\n white-space: nowrap;\n }\n\n .body {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n width: 100%;\n }\n\n .track {\n width: 100%;\n height: 4px;\n border-radius: 16px;\n background-color: var(--dark-opacity-5);\n overflow: hidden;\n }\n\n .fill {\n height: 4px;\n border-radius: 16px;\n background-color: var(--primary);\n transition: width 0.2s ease;\n }\n\n .description {\n margin: 0;\n width: 100%;\n color: var(--dark-opacity-50);\n font: var(--caption-medium-12-15);\n }\n"])));
|
|
13
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
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 LoadingBar_1 = __importDefault(require("./LoadingBar"));
|
|
20
|
+
var props_1 = require("./props");
|
|
21
|
+
var renderLoadingBar = function (props) {
|
|
22
|
+
if (props === void 0) { props = {}; }
|
|
23
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(LoadingBar_1.default, __assign({}, props_1.LoadingBarDefault, props)));
|
|
24
|
+
};
|
|
25
|
+
describe("LoadingBar", function () {
|
|
26
|
+
it("renders the title, description and fraction label", function () {
|
|
27
|
+
renderLoadingBar({
|
|
28
|
+
title: "Ürünler getiriliyor...",
|
|
29
|
+
description: "Aktarım devam eder.",
|
|
30
|
+
value: 268,
|
|
31
|
+
total: 510,
|
|
32
|
+
format: "fraction",
|
|
33
|
+
});
|
|
34
|
+
expect(react_1.screen.getByText("Ürünler getiriliyor...")).toBeInTheDocument();
|
|
35
|
+
expect(react_1.screen.getByText("Aktarım devam eder.")).toBeInTheDocument();
|
|
36
|
+
expect(react_1.screen.getByText("268 / 510")).toBeInTheDocument();
|
|
37
|
+
expect(react_1.screen.getByRole("progressbar")).toHaveAttribute("aria-valuenow", "268");
|
|
38
|
+
expect(react_1.screen.getByRole("progressbar")).toHaveAttribute("aria-valuemax", "510");
|
|
39
|
+
});
|
|
40
|
+
it("renders a percent label", function () {
|
|
41
|
+
renderLoadingBar({ value: 20, total: 100, format: "percent" });
|
|
42
|
+
expect(react_1.screen.getByText("%20 / %100")).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
it("clamps the bar when value is outside the total", function () {
|
|
45
|
+
var container = renderLoadingBar({ value: 800, total: 510, format: "percent" }).container;
|
|
46
|
+
expect(react_1.screen.getByText("%100 / %100")).toBeInTheDocument();
|
|
47
|
+
expect(react_1.screen.getByRole("progressbar")).toHaveAttribute("aria-valuenow", "510");
|
|
48
|
+
expect(container.querySelector(".fill")).toHaveStyle({ width: "100%" });
|
|
49
|
+
});
|
|
50
|
+
it("stays at zero when total is not positive", function () {
|
|
51
|
+
var container = renderLoadingBar({ value: 10, total: 0, format: "fraction" }).container;
|
|
52
|
+
expect(react_1.screen.getByText("10 / 0")).toBeInTheDocument();
|
|
53
|
+
expect(react_1.screen.getByRole("progressbar")).toHaveAttribute("aria-valuenow", "0");
|
|
54
|
+
expect(react_1.screen.getByRole("progressbar")).toHaveAttribute("aria-valuemax", "0");
|
|
55
|
+
expect(container.querySelector(".fill")).toHaveStyle({ width: "0%" });
|
|
56
|
+
});
|
|
57
|
+
it("renders progressText instead of the generated label", function () {
|
|
58
|
+
renderLoadingBar({
|
|
59
|
+
value: 268,
|
|
60
|
+
total: 510,
|
|
61
|
+
format: "fraction",
|
|
62
|
+
progressText: "268 ürün",
|
|
63
|
+
});
|
|
64
|
+
expect(react_1.screen.getByText("268 ürün")).toBeInTheDocument();
|
|
65
|
+
expect(react_1.screen.queryByText("268 / 510")).not.toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
it("does not execute HTML passed as progressText", function () {
|
|
68
|
+
renderLoadingBar({
|
|
69
|
+
progressText: '<script>window.__xssProgress = true</script>%20',
|
|
70
|
+
value: 20,
|
|
71
|
+
total: 100,
|
|
72
|
+
});
|
|
73
|
+
expect(react_1.screen.getByText(/%20/)).toBeInTheDocument();
|
|
74
|
+
expect(document.querySelector("script")).not.toBeInTheDocument();
|
|
75
|
+
expect(window.__xssProgress).toBeUndefined();
|
|
76
|
+
});
|
|
77
|
+
it("omits empty title and description", function () {
|
|
78
|
+
renderLoadingBar({ title: "", description: "", value: 1, total: 4 });
|
|
79
|
+
expect(react_1.screen.getByText("1 / 4")).toBeInTheDocument();
|
|
80
|
+
expect(document.querySelector(".title")).not.toBeInTheDocument();
|
|
81
|
+
expect(document.querySelector(".description")).not.toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
it("does not execute HTML passed as title or description", function () {
|
|
84
|
+
renderLoadingBar({
|
|
85
|
+
title: '<script>window.__xssTitle = true</script>Başlık',
|
|
86
|
+
description: '<img src="x" onerror="window.__xssDesc = true" />Açıklama',
|
|
87
|
+
value: 1,
|
|
88
|
+
total: 2,
|
|
89
|
+
});
|
|
90
|
+
expect(react_1.screen.getByText(/Başlık/)).toBeInTheDocument();
|
|
91
|
+
expect(react_1.screen.getByText(/Açıklama/)).toBeInTheDocument();
|
|
92
|
+
expect(document.querySelector("script")).not.toBeInTheDocument();
|
|
93
|
+
expect(document.querySelector("img")).not.toBeInTheDocument();
|
|
94
|
+
expect(window.__xssTitle).toBeUndefined();
|
|
95
|
+
expect(window.__xssDesc).toBeUndefined();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./LoadingBar";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var LoadingBar_1 = require("./LoadingBar");
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(LoadingBar_1).default; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LoadingBarFormat } from "./utils/progress";
|
|
2
|
+
export declare const formats: readonly ["fraction", "percent"];
|
|
3
|
+
export interface LoadingBar {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
value?: number;
|
|
7
|
+
total?: number;
|
|
8
|
+
format?: LoadingBarFormat;
|
|
9
|
+
progressText?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const LoadingBarDefault: LoadingBar;
|
|
12
|
+
export type LoadingBarProps = typeof LoadingBarDefault;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoadingBarDefault = exports.formats = void 0;
|
|
4
|
+
exports.formats = ["fraction", "percent"];
|
|
5
|
+
exports.LoadingBarDefault = {
|
|
6
|
+
title: "",
|
|
7
|
+
description: "",
|
|
8
|
+
value: 0,
|
|
9
|
+
total: 100,
|
|
10
|
+
format: "fraction",
|
|
11
|
+
progressText: "",
|
|
12
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: (props: any) => React.JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
title: {
|
|
8
|
+
control: string;
|
|
9
|
+
};
|
|
10
|
+
description: {
|
|
11
|
+
control: string;
|
|
12
|
+
};
|
|
13
|
+
value: {
|
|
14
|
+
control: string;
|
|
15
|
+
};
|
|
16
|
+
total: {
|
|
17
|
+
control: string;
|
|
18
|
+
};
|
|
19
|
+
format: {
|
|
20
|
+
control: string;
|
|
21
|
+
options: readonly ["fraction", "percent"];
|
|
22
|
+
};
|
|
23
|
+
progressText: {
|
|
24
|
+
control: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default _default;
|
|
29
|
+
export declare const Default: {
|
|
30
|
+
args: {
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
value: number;
|
|
34
|
+
total: number;
|
|
35
|
+
format: "fraction";
|
|
36
|
+
progressText: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare const Percent: {
|
|
40
|
+
args: {
|
|
41
|
+
value: number;
|
|
42
|
+
total: number;
|
|
43
|
+
format: string;
|
|
44
|
+
title: string;
|
|
45
|
+
description: string;
|
|
46
|
+
progressText: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare const WithoutDescription: {
|
|
50
|
+
args: {
|
|
51
|
+
description: string;
|
|
52
|
+
title: string;
|
|
53
|
+
value: number;
|
|
54
|
+
total: number;
|
|
55
|
+
format: "fraction";
|
|
56
|
+
progressText: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare const CustomProgressText: {
|
|
60
|
+
args: {
|
|
61
|
+
progressText: string;
|
|
62
|
+
title: string;
|
|
63
|
+
description: string;
|
|
64
|
+
value: number;
|
|
65
|
+
total: number;
|
|
66
|
+
format: "fraction";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export declare const TitleOnly: {
|
|
70
|
+
args: {
|
|
71
|
+
description: string;
|
|
72
|
+
value: number;
|
|
73
|
+
total: number;
|
|
74
|
+
title: string;
|
|
75
|
+
format: "fraction";
|
|
76
|
+
progressText: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
exports.TitleOnly = exports.CustomProgressText = exports.WithoutDescription = exports.Percent = exports.Default = void 0;
|
|
18
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
var LoadingBar_1 = __importDefault(require("../LoadingBar"));
|
|
20
|
+
var props_1 = require("../props");
|
|
21
|
+
var baseArgs = {
|
|
22
|
+
title: "Ürünler getiriliyor...",
|
|
23
|
+
description: "Bu işlem arka planda çalışıyor. Sayfadan ayrılabilirsin, aktarım devam eder.",
|
|
24
|
+
value: 268,
|
|
25
|
+
total: 510,
|
|
26
|
+
format: "fraction",
|
|
27
|
+
progressText: "",
|
|
28
|
+
};
|
|
29
|
+
exports.default = {
|
|
30
|
+
title: "Components/LoadingBar",
|
|
31
|
+
component: function (props) { return ((0, jsx_runtime_1.jsx)("div", __assign({ style: { width: 920 } }, { children: (0, jsx_runtime_1.jsx)(LoadingBar_1.default, __assign({}, props)) }))); },
|
|
32
|
+
tags: ["autodocs"],
|
|
33
|
+
argTypes: {
|
|
34
|
+
title: { control: "text" },
|
|
35
|
+
description: { control: "text" },
|
|
36
|
+
value: { control: "number" },
|
|
37
|
+
total: { control: "number" },
|
|
38
|
+
format: { control: "select", options: props_1.formats },
|
|
39
|
+
progressText: { control: "text" },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
exports.Default = {
|
|
43
|
+
args: __assign({}, baseArgs),
|
|
44
|
+
};
|
|
45
|
+
exports.Percent = {
|
|
46
|
+
args: __assign(__assign({}, baseArgs), { value: 20, total: 100, format: "percent" }),
|
|
47
|
+
};
|
|
48
|
+
exports.WithoutDescription = {
|
|
49
|
+
args: __assign(__assign({}, baseArgs), { description: "" }),
|
|
50
|
+
};
|
|
51
|
+
exports.CustomProgressText = {
|
|
52
|
+
args: __assign(__assign({}, baseArgs), { progressText: "268 ürün" }),
|
|
53
|
+
};
|
|
54
|
+
exports.TitleOnly = {
|
|
55
|
+
args: __assign(__assign({}, baseArgs), { description: "", value: 0, total: 100 }),
|
|
56
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type LoadingBarFormat = "fraction" | "percent";
|
|
2
|
+
export declare const getLoadingTotal: (total: number) => number;
|
|
3
|
+
export declare const getLoadingProgress: (value: number, total: number) => number;
|
|
4
|
+
export declare const getLoadingCurrent: (value: number, total: number) => number;
|
|
5
|
+
export declare const formatLoadingValue: (value: number, total: number, format: LoadingBarFormat) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatLoadingValue = exports.getLoadingCurrent = exports.getLoadingProgress = exports.getLoadingTotal = void 0;
|
|
4
|
+
var toFiniteNumber = function (value) { return (Number.isFinite(value) ? value : 0); };
|
|
5
|
+
var getLoadingTotal = function (total) {
|
|
6
|
+
var safeTotal = toFiniteNumber(total);
|
|
7
|
+
return safeTotal > 0 ? safeTotal : 0;
|
|
8
|
+
};
|
|
9
|
+
exports.getLoadingTotal = getLoadingTotal;
|
|
10
|
+
var getLoadingProgress = function (value, total) {
|
|
11
|
+
var safeTotal = (0, exports.getLoadingTotal)(total);
|
|
12
|
+
if (safeTotal === 0) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
var ratio = (toFiniteNumber(value) / safeTotal) * 100;
|
|
16
|
+
return Math.min(100, Math.max(0, ratio));
|
|
17
|
+
};
|
|
18
|
+
exports.getLoadingProgress = getLoadingProgress;
|
|
19
|
+
var getLoadingCurrent = function (value, total) {
|
|
20
|
+
var safeTotal = (0, exports.getLoadingTotal)(total);
|
|
21
|
+
if (safeTotal === 0) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
return Math.min(safeTotal, Math.max(0, toFiniteNumber(value)));
|
|
25
|
+
};
|
|
26
|
+
exports.getLoadingCurrent = getLoadingCurrent;
|
|
27
|
+
var formatLoadingValue = function (value, total, format) {
|
|
28
|
+
var safeTotal = (0, exports.getLoadingTotal)(total);
|
|
29
|
+
var safeValue = Math.max(0, toFiniteNumber(value));
|
|
30
|
+
if (format === "percent") {
|
|
31
|
+
return "%".concat(Math.round((0, exports.getLoadingProgress)(value, total)), " / %100");
|
|
32
|
+
}
|
|
33
|
+
return "".concat(safeValue, " / ").concat(safeTotal);
|
|
34
|
+
};
|
|
35
|
+
exports.formatLoadingValue = formatLoadingValue;
|
|
@@ -26,6 +26,8 @@ var QuantitySelector = function (_a) {
|
|
|
26
26
|
$hasDisableActions: hasDisableActions,
|
|
27
27
|
};
|
|
28
28
|
var decrementButton = hasRemove ? ((0, jsx_runtime_1.jsx)(QuantitySelector_styled_1.SelectorButton, __assign({ type: "button", disabled: hasLoading, onClick: onRemove }, styledProps, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "DeleteSmall" }) }))) : ((0, jsx_runtime_1.jsx)(QuantitySelector_styled_1.SelectorButton, __assign({ type: "button", disabled: hasLoading, onClick: onDecrement }, styledProps, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "NegativeSmall" }) })));
|
|
29
|
-
|
|
29
|
+
var incrementButton = ((0, jsx_runtime_1.jsxs)(QuantitySelector_styled_1.SelectorButton, __assign({ type: "button", disabled: hasLoading || hasError || hasDisableIncrement, onClick: onIncrement }, styledProps, { children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { name: "PlusSmall" }), hasError && ((0, jsx_runtime_1.jsx)("div", { className: "popup", dangerouslySetInnerHTML: { __html: errorText } }))] })));
|
|
30
|
+
var isHorizontal = orientation === 'horizontal';
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(QuantitySelector_styled_1.Container, { children: [label && (0, jsx_runtime_1.jsx)(QuantitySelector_styled_1.Label, __assign({ htmlFor: id }, { children: label })), (0, jsx_runtime_1.jsxs)(QuantitySelector_styled_1.Controls, __assign({}, styledProps, { children: [!hasDisableActions && (isHorizontal ? decrementButton : incrementButton), (0, jsx_runtime_1.jsx)(QuantitySelector_styled_1.QuantityValue, __assign({}, styledProps, { children: hasLoading ? (0, jsx_runtime_1.jsx)(Loader_1.default, { variant: "primary", width: "16px", height: "16px" }) : quantity })), !hasDisableActions && (isHorizontal ? incrementButton : decrementButton)] }))] }));
|
|
30
32
|
};
|
|
31
33
|
exports.default = QuantitySelector;
|
|
@@ -84,6 +84,27 @@ describe('QuantitySelector', function () {
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
}); });
|
|
87
|
+
it('places decrement before increment when horizontal', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
var onIncrement, onDecrement, _a, first, second;
|
|
89
|
+
return __generator(this, function (_b) {
|
|
90
|
+
switch (_b.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
onIncrement = jest.fn();
|
|
93
|
+
onDecrement = jest.fn();
|
|
94
|
+
renderSelector({ orientation: 'horizontal', onIncrement: onIncrement, onDecrement: onDecrement });
|
|
95
|
+
_a = react_1.screen.getAllByRole('button'), first = _a[0], second = _a[1];
|
|
96
|
+
return [4 /*yield*/, user_event_1.default.click(first)];
|
|
97
|
+
case 1:
|
|
98
|
+
_b.sent();
|
|
99
|
+
return [4 /*yield*/, user_event_1.default.click(second)];
|
|
100
|
+
case 2:
|
|
101
|
+
_b.sent();
|
|
102
|
+
expect(onDecrement).toHaveBeenCalledTimes(1);
|
|
103
|
+
expect(onIncrement).toHaveBeenCalledTimes(1);
|
|
104
|
+
return [2 /*return*/];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}); });
|
|
87
108
|
it('does not call onIncrement when increment is disabled', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
109
|
var onIncrement;
|
|
89
110
|
return __generator(this, function (_a) {
|
package/dist/index.d.ts
CHANGED
|
@@ -66,4 +66,5 @@ import Tag from "./components/Tag";
|
|
|
66
66
|
import TagInput from "./components/TagInput";
|
|
67
67
|
import RichTextEditor from "./components/RichTextEditor";
|
|
68
68
|
import ColorCard from "./components/ColorCard";
|
|
69
|
-
|
|
69
|
+
import LoadingBar from "./components/LoadingBar";
|
|
70
|
+
export { Button, Breadcrumbs, CategoryMenu, Checkbox, CircleProgress, Input, Modal, OtpInput, Stepper, Alert, Agreement, Icon, RadioButton, ActionButton, Textarea, SearchBox, Divider, Accordion, toast, Toaster, SuggestBox, Badges, SelectBox, TextLink, Tooltip, InsuranceBox, ListGroup, InfoBox, CouponCode, ShoppingCartProduct, Loader, InlineProgress, Dropdown, CampaignCard, initReactI18next, initi18n, enLocale, trLocale, useTranslation, ReviewCard, AddressCard, InstallmentBox, AutocompleteInput, BannerCard, ProductCardVertical, ProductCardHorizontal, ProductCardHorizontalSm, ProductCardHorizontalMd, ProductCardCheckbox, ProductCardRadio, Tabs, PaymentCart, OptionMenu, DropdownButton, Table, DescriptionCard, Pagination, SkeletonLoader, RadioScale, BlogCard, ReviewBlock, VideoCard, StepSlider, RadioGroup, CheckboxGroup, QuantitySelector, Tag, TagInput, RichTextEditor, ColorCard, LoadingBar };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ProductCardRadio = exports.ProductCardCheckbox = exports.ProductCardHorizontalMd = exports.ProductCardHorizontalSm = exports.ProductCardHorizontal = exports.ProductCardVertical = exports.BannerCard = exports.AutocompleteInput = exports.InstallmentBox = exports.AddressCard = exports.ReviewCard = exports.useTranslation = exports.trLocale = exports.enLocale = exports.initi18n = exports.initReactI18next = exports.CampaignCard = exports.Dropdown = exports.InlineProgress = exports.Loader = exports.ShoppingCartProduct = exports.CouponCode = exports.InfoBox = exports.ListGroup = exports.InsuranceBox = exports.Tooltip = exports.TextLink = exports.SelectBox = exports.Badges = exports.SuggestBox = exports.Toaster = exports.toast = exports.Accordion = exports.Divider = exports.SearchBox = exports.Textarea = exports.ActionButton = exports.RadioButton = exports.Icon = exports.Agreement = exports.Alert = exports.Stepper = exports.OtpInput = exports.Modal = exports.Input = exports.CircleProgress = exports.Checkbox = exports.CategoryMenu = exports.Breadcrumbs = exports.Button = void 0;
|
|
7
|
-
exports.ColorCard = exports.RichTextEditor = exports.TagInput = exports.Tag = exports.QuantitySelector = exports.CheckboxGroup = exports.RadioGroup = exports.StepSlider = exports.VideoCard = exports.ReviewBlock = exports.BlogCard = exports.RadioScale = exports.SkeletonLoader = exports.Pagination = exports.DescriptionCard = exports.Table = exports.DropdownButton = exports.OptionMenu = exports.PaymentCart = exports.Tabs = void 0;
|
|
7
|
+
exports.LoadingBar = exports.ColorCard = exports.RichTextEditor = exports.TagInput = exports.Tag = exports.QuantitySelector = exports.CheckboxGroup = exports.RadioGroup = exports.StepSlider = exports.VideoCard = exports.ReviewBlock = exports.BlogCard = exports.RadioScale = exports.SkeletonLoader = exports.Pagination = exports.DescriptionCard = exports.Table = exports.DropdownButton = exports.OptionMenu = exports.PaymentCart = exports.Tabs = void 0;
|
|
8
8
|
var react_i18next_1 = require("react-i18next");
|
|
9
9
|
Object.defineProperty(exports, "initReactI18next", { enumerable: true, get: function () { return react_i18next_1.initReactI18next; } });
|
|
10
10
|
Object.defineProperty(exports, "useTranslation", { enumerable: true, get: function () { return react_i18next_1.useTranslation; } });
|
|
@@ -143,3 +143,5 @@ var RichTextEditor_1 = __importDefault(require("./components/RichTextEditor"));
|
|
|
143
143
|
exports.RichTextEditor = RichTextEditor_1.default;
|
|
144
144
|
var ColorCard_1 = __importDefault(require("./components/ColorCard"));
|
|
145
145
|
exports.ColorCard = ColorCard_1.default;
|
|
146
|
+
var LoadingBar_1 = __importDefault(require("./components/LoadingBar"));
|
|
147
|
+
exports.LoadingBar = LoadingBar_1.default;
|