krl-alfred 2.23.22 → 2.23.23

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.
@@ -56,6 +56,6 @@ var InfoBox = function (_a) {
56
56
  }
57
57
  });
58
58
  }, [description]);
59
- return ((0, jsx_runtime_1.jsxs)(InfoBox_styled_1.InfoBoxStyled, __assign({ onClick: onClick, "$radius": radius, "$variant": variant, "$hasLink": !!onClick, "$size": size }, { children: [hasIcon && ((0, jsx_runtime_1.jsx)(InfoBox_styled_1.IconWrapper, __assign({ "$variant": variant }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: variant === "danger" ? "Danger" : icon }) }))), (0, jsx_runtime_1.jsxs)(InfoBox_styled_1.TextWrapper, { children: [title && (0, jsx_runtime_1.jsx)(InfoBox_styled_1.Title, { dangerouslySetInnerHTML: { __html: title } }), description && (0, jsx_runtime_1.jsx)(InfoBox_styled_1.Description, __assign({ "$size": size, ref: descriptionRef }, { children: description })), (0, jsx_runtime_1.jsx)(InfoBox_styled_1.AlertStyled, __assign({ "$visible": alert, "$alertLeft": alertLeft, "$alertTop": alertTop }, { children: t('copied') })), (0, jsx_runtime_1.jsx)(InfoBox_styled_1.Input, { ref: inputRef, id: "infoBoxInput" })] }), !!onClick && ((0, jsx_runtime_1.jsx)(InfoBox_styled_1.LinkIconWrapper, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "ArrowRightBig" }) }))] })));
59
+ return ((0, jsx_runtime_1.jsxs)(InfoBox_styled_1.InfoBoxStyled, __assign({ onClick: onClick, "$radius": radius, "$variant": variant, "$hasLink": !!onClick, "$size": size }, { children: [hasIcon && ((0, jsx_runtime_1.jsx)(InfoBox_styled_1.IconWrapper, __assign({ "$variant": variant }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: variant === "danger" ? "Danger" : icon }) }))), (0, jsx_runtime_1.jsxs)(InfoBox_styled_1.TextWrapper, { children: [title && (0, jsx_runtime_1.jsx)(InfoBox_styled_1.Title, { children: title }), description && (0, jsx_runtime_1.jsx)(InfoBox_styled_1.Description, __assign({ "$size": size, ref: descriptionRef }, { children: description })), (0, jsx_runtime_1.jsx)(InfoBox_styled_1.AlertStyled, __assign({ "$visible": alert, "$alertLeft": alertLeft, "$alertTop": alertTop }, { children: t('copied') })), (0, jsx_runtime_1.jsx)(InfoBox_styled_1.Input, { ref: inputRef, id: "infoBoxInput" })] }), !!onClick && ((0, jsx_runtime_1.jsx)(InfoBox_styled_1.LinkIconWrapper, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "ArrowRightBig" }) }))] })));
60
60
  };
61
61
  exports.default = InfoBox;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,136 @@
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 InfoBox_1 = __importDefault(require("./InfoBox"));
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 renderInfoBox = function (props) {
64
+ if (props === void 0) { props = {}; }
65
+ return (0, react_1.render)((0, jsx_runtime_1.jsx)(InfoBox_1.default, __assign({}, props_1.InfoBoxDefault, { title: "Info text", description: "A\u00E7\u0131klama" }, props)));
66
+ };
67
+ describe('InfoBox', function () {
68
+ it('renders string title and description', function () {
69
+ renderInfoBox();
70
+ expect(react_1.screen.getByText('Info text')).toBeInTheDocument();
71
+ expect(react_1.screen.getByText('Açıklama')).toBeInTheDocument();
72
+ });
73
+ it('renders title and description as ReactNode', function () {
74
+ renderInfoBox({
75
+ title: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("b", { children: "\u00D6nemli" }), " ", (0, jsx_runtime_1.jsx)("span", { children: "ba\u015Fl\u0131k" })] })),
76
+ description: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { children: "Detay metni" }), (0, jsx_runtime_1.jsx)("img", { src: "/info.png", alt: "Bilgi" })] })),
77
+ });
78
+ expect(react_1.screen.getByText('Önemli')).toBeInTheDocument();
79
+ expect(react_1.screen.getByText('başlık')).toBeInTheDocument();
80
+ expect(react_1.screen.getByText('Detay metni')).toBeInTheDocument();
81
+ expect(react_1.screen.getByAltText('Bilgi')).toBeInTheDocument();
82
+ });
83
+ it('does not execute HTML strings passed as title or description', function () {
84
+ renderInfoBox({
85
+ title: '<script>window.__xssTitle = true</script>Başlık',
86
+ description: '<img src="x" onerror="window.__xssDesc = true" />Açıklama',
87
+ });
88
+ expect(react_1.screen.getByText(/Başlık/)).toBeInTheDocument();
89
+ expect(react_1.screen.getByText(/Açıklama/)).toBeInTheDocument();
90
+ expect(document.querySelector('script')).not.toBeInTheDocument();
91
+ expect(document.querySelector('img[onerror]')).not.toBeInTheDocument();
92
+ expect(window.__xssTitle).toBeUndefined();
93
+ expect(window.__xssDesc).toBeUndefined();
94
+ });
95
+ it('does not render title or description when they are null', function () {
96
+ renderInfoBox({ title: null, description: null });
97
+ expect(react_1.screen.queryByText('Info text')).not.toBeInTheDocument();
98
+ expect(react_1.screen.queryByText('Açıklama')).not.toBeInTheDocument();
99
+ });
100
+ it('calls onClick when the box is clicked', function () { return __awaiter(void 0, void 0, void 0, function () {
101
+ var onClick, container;
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0:
105
+ onClick = jest.fn();
106
+ container = renderInfoBox({ onClick: onClick }).container;
107
+ return [4 /*yield*/, user_event_1.default.click(container.firstChild)];
108
+ case 1:
109
+ _a.sent();
110
+ expect(onClick).toHaveBeenCalledTimes(1);
111
+ return [2 /*return*/];
112
+ }
113
+ });
114
+ }); });
115
+ it('copies digits from a description span click', function () { return __awaiter(void 0, void 0, void 0, function () {
116
+ var _a;
117
+ return __generator(this, function (_b) {
118
+ switch (_b.label) {
119
+ case 0:
120
+ document.execCommand = jest.fn();
121
+ renderInfoBox({
122
+ description: ((0, jsx_runtime_1.jsx)("div", __assign({ className: "bottom" }, { children: (0, jsx_runtime_1.jsxs)("p", { children: ["Kod: ", (0, jsx_runtime_1.jsx)("span", { children: "567890678" })] }) }))),
123
+ });
124
+ return [4 /*yield*/, user_event_1.default.click(react_1.screen.getByText('567890678'))];
125
+ case 1:
126
+ _b.sent();
127
+ expect(document.execCommand).toHaveBeenCalledWith('copy');
128
+ _a = expect;
129
+ return [4 /*yield*/, react_1.screen.findByText('copied')];
130
+ case 2:
131
+ _a.apply(void 0, [_b.sent()]).toBeInTheDocument();
132
+ return [2 /*return*/];
133
+ }
134
+ });
135
+ }); });
136
+ });
@@ -6,7 +6,7 @@ type SIZES = typeof sizes[number];
6
6
  type VARIANT = typeof variants[number];
7
7
  type ICON = typeof iconNames[any];
8
8
  export interface InfoBox {
9
- title?: string;
9
+ title?: React.ReactNode;
10
10
  description?: React.ReactNode;
11
11
  radius?: string;
12
12
  size?: SIZES;
@@ -153,6 +153,13 @@ export declare const SimpleDescription: {
153
153
  onClick: () => void;
154
154
  };
155
155
  };
156
+ export declare const ReactNodeTitle: {
157
+ args: {
158
+ title: React.JSX.Element;
159
+ description: string;
160
+ onClick: any;
161
+ };
162
+ };
156
163
  export declare const ReactNodeDescription: {
157
164
  args: {
158
165
  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.Empty = exports.Clickable = exports.CustomIcon = exports.WithCustomRadius = exports.ReactNodeDescription = exports.SimpleDescription = exports.Minimal = exports.WithoutDescription = exports.WithoutTitle = exports.WithoutOnClick = exports.AllSizes = exports.AllVariants = exports.Large = exports.Medium = exports.Small = exports.WithoutIcon = exports.Secondary = exports.Warning = exports.Danger = exports.Primary = exports.Default = void 0;
17
+ exports.Empty = exports.Clickable = exports.CustomIcon = exports.WithCustomRadius = exports.ReactNodeDescription = exports.ReactNodeTitle = exports.SimpleDescription = exports.Minimal = exports.WithoutDescription = exports.WithoutTitle = exports.WithoutOnClick = exports.AllSizes = exports.AllVariants = exports.Large = exports.Medium = exports.Small = exports.WithoutIcon = exports.Secondary = exports.Warning = exports.Danger = exports.Primary = exports.Default = void 0;
18
18
  var jsx_runtime_1 = require("react/jsx-runtime");
19
19
  var InfoBox_1 = __importDefault(require("../InfoBox"));
20
20
  var props_1 = require("../props");
@@ -93,6 +93,9 @@ exports.Minimal = {
93
93
  exports.SimpleDescription = {
94
94
  args: __assign(__assign({}, defaultArgs), { title: "Basit bilgi", description: "Bu sadece düz metin açıklamasıdır. HTML veya kopyalanabilir alan içermez." }),
95
95
  };
96
+ exports.ReactNodeTitle = {
97
+ args: __assign(__assign({}, defaultArgs), { title: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("b", { children: "\u00D6nemli" }), " ", (0, jsx_runtime_1.jsx)("span", { children: "bilgi" })] })), description: "Başlık React node olarak geçilebilir.", onClick: undefined }),
98
+ };
96
99
  exports.ReactNodeDescription = {
97
100
  args: __assign(__assign({}, defaultArgs), { title: "React node açıklama", description: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { children: "\u0130ade g\u00FCn\u00FCn kiralama biti\u015F g\u00FCn\u00FCnd\u00FCr." }), (0, jsx_runtime_1.jsxs)("p", { children: ["Detaylar i\u00E7in ", (0, jsx_runtime_1.jsx)("b", { children: "info@kiralarsin.com" }), " adresine yazabilirsin."] })] })), onClick: undefined }),
98
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "krl-alfred",
3
- "version": "2.23.22",
3
+ "version": "2.23.23",
4
4
  "files": [
5
5
  "dist"
6
6
  ],