krl-alfred 2.25.1 → 2.25.2

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.
@@ -19,6 +19,7 @@ var react_1 = require("react");
19
19
  var props_1 = require("./props");
20
20
  var DropdownButton_styled_1 = require("./DropdownButton.styled");
21
21
  var Icon_1 = __importDefault(require("../Icon/Icon"));
22
+ var Badges_1 = __importDefault(require("../Badges"));
22
23
  var DropdownButton = function (_a) {
23
24
  var _b = _a.icon, icon = _b === void 0 ? props_1.DropdownButtonDefault.icon : _b, _c = _a.title, title = _c === void 0 ? props_1.DropdownButtonDefault.title : _c, _d = _a.hasDropdown, hasDropdown = _d === void 0 ? props_1.DropdownButtonDefault.hasDropdown : _d, _e = _a.isShow, isShow = _e === void 0 ? props_1.DropdownButtonDefault.isShow : _e, _f = _a.isActive, isActive = _f === void 0 ? props_1.DropdownButtonDefault.isActive : _f, _g = _a.list, list = _g === void 0 ? props_1.DropdownButtonDefault.list : _g, component = _a.component;
24
25
  var _h = (0, react_1.useState)(isActive || isShow), showDropdown = _h[0], setShowDropdown = _h[1];
@@ -36,6 +37,6 @@ var DropdownButton = function (_a) {
36
37
  return (item === null || item === void 0 ? void 0 : item.component) ? (0, jsx_runtime_1.jsxs)(item.component, { children: [(item === null || item === void 0 ? void 0 : item.icon) && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "iconWrapper" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: item === null || item === void 0 ? void 0 : item.icon }) }))), children] }) : (0, jsx_runtime_1.jsx)("div", { children: children });
37
38
  };
38
39
  return ((0, jsx_runtime_1.jsxs)(DropdownButton_styled_1.DropdownButtonStyled, __assign({ ref: dropdownRef, "$isShow": showDropdown, "$isActive": isActive }, { children: [(0, jsx_runtime_1.jsx)(ButtonLinkComponent, __assign({ item: { component: component } }, { children: (0, jsx_runtime_1.jsxs)("span", __assign({ className: "buttonInner", onClick: function () { return hasDropdown && setShowDropdown(!showDropdown); } }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ className: "icon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: icon }) })), (0, jsx_runtime_1.jsx)("div", __assign({ className: "title" }, { children: title })), hasDropdown && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "dropdownIcon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "ArrowDownBig" }) })))] })) })), hasDropdown && (list === null || list === void 0 ? void 0 : list.length) > 0 &&
39
- (0, jsx_runtime_1.jsx)(DropdownButton_styled_1.DropdownListStyled, __assign({ "$isShow": showDropdown }, { children: list.map(function (item, key) { return ((0, jsx_runtime_1.jsx)(DropdownButton_styled_1.DropdownListItemStyled, __assign({ "$isActive": item.isActive, "$hasIcon": !!(item === null || item === void 0 ? void 0 : item.icon) }, { children: (0, jsx_runtime_1.jsx)(ButtonLinkComponent, __assign({ item: item }, { children: item.title })) }), key)); }) }))] })));
40
+ (0, jsx_runtime_1.jsx)(DropdownButton_styled_1.DropdownListStyled, __assign({ "$isShow": showDropdown }, { children: list.map(function (item, key) { return ((0, jsx_runtime_1.jsx)(DropdownButton_styled_1.DropdownListItemStyled, __assign({ "$isActive": item.isActive, "$hasIcon": !!(item === null || item === void 0 ? void 0 : item.icon) }, { children: (0, jsx_runtime_1.jsxs)(ButtonLinkComponent, __assign({ item: item }, { children: [item.title, item.hasBadge && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "badgesWrapper" }, { children: (0, jsx_runtime_1.jsx)(Badges_1.default, { layout: "text", variant: "primary", title: item.badgeText }) })))] })) }), key)); }) }))] })));
40
41
  };
41
42
  exports.default = DropdownButton;
@@ -11,5 +11,5 @@ exports.DropdownListItemStyled = exports.DropdownListStyled = exports.DropdownBu
11
11
  var styled_components_1 = __importDefault(require("styled-components"));
12
12
  exports.DropdownButtonStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n\n ", "\n .buttonInner {\n padding: 1.5rem 1.5rem;\n border-radius: 0.5rem;\n color: var(--text);\n display: grid;\n align-items: center;\n grid-template-columns: auto 1fr auto;\n transition: all .2s ease;\n cursor: pointer;\n &:hover{\n background-color: var(--primary-opacity-5) !important;\n color: var(--primary) !important;\n }\n .icon{\n *{\n stop-color:currentColor;\n }\n }\n .title {\n font: var(--title-bold-16-19);\n display: block;\n margin-left: 1rem;\n }\n\n .dropdownIcon {\n transition: all .2s ease;\n ", "\n }\n }\n\n + div {\n margin-top: 0.25rem;\n }\n"], ["\n box-sizing: border-box;\n\n ", "\n .buttonInner {\n padding: 1.5rem 1.5rem;\n border-radius: 0.5rem;\n color: var(--text);\n display: grid;\n align-items: center;\n grid-template-columns: auto 1fr auto;\n transition: all .2s ease;\n cursor: pointer;\n &:hover{\n background-color: var(--primary-opacity-5) !important;\n color: var(--primary) !important;\n }\n .icon{\n *{\n stop-color:currentColor;\n }\n }\n .title {\n font: var(--title-bold-16-19);\n display: block;\n margin-left: 1rem;\n }\n\n .dropdownIcon {\n transition: all .2s ease;\n ", "\n }\n }\n\n + div {\n margin-top: 0.25rem;\n }\n"])), function (props) { return (props.$isActive) && "\n .buttonInner {\n background-color: var(--primary-opacity-5) !important;\n color: var(--primary) !important;\n }\n "; }, function (props) { return props.$isShow && "\n transform: rotate(180deg)\n "; });
13
13
  exports.DropdownListStyled = styled_components_1.default.ul(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0;\n margin: 0.25rem 0 0 0;\n display: ", ";\n\n > li {\n + li {\n margin-top: 0.25rem;\n }\n }\n"], ["\n padding: 0;\n margin: 0.25rem 0 0 0;\n display: ", ";\n\n > li {\n + li {\n margin-top: 0.25rem;\n }\n }\n"])), function (props) { return props.$isShow ? "block" : "none"; });
14
- exports.DropdownListItemStyled = styled_components_1.default.li(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: block;\n\n a {\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n font: ", ";\n padding: 1rem 1rem 1rem 4rem;\n border-radius: 0.5rem;\n color: ", ";\n .iconWrapper{\n margin-right: 1rem;\n }\n }\n\n ", ";\n"], ["\n display: block;\n\n a {\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n font: ", ";\n padding: 1rem 1rem 1rem 4rem;\n border-radius: 0.5rem;\n color: ", ";\n .iconWrapper{\n margin-right: 1rem;\n }\n }\n\n ", ";\n"])), function (props) { return props.$hasIcon ? "var(--body-bold-14-17)" : "var(--body-medium-14-17)"; }, function (props) { return props.$hasIcon ? "var(--primary)" : "var(--text)"; }, function (props) { return props.$hasIcon && !props.$isActive ? "\n &:hover{\n a{\n color: var(--primary-hover) !important;\n }\n }\n " : "\n ".concat(props.$isActive ? "" : "&:hover{", "\n a {\n background-color: var(--primary-opacity-5) !important;\n color: var(--primary) !important;\n font: var(--body-bold-14-17) !important;\n }\n\n ").concat(!props.$isActive ? "" : "}", "\n "); });
14
+ exports.DropdownListItemStyled = styled_components_1.default.li(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: block;\n\n a {\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n text-decoration: none;\n font: ", ";\n padding: 1rem 1rem 1rem 4rem;\n border-radius: 0.5rem;\n color: ", ";\n .iconWrapper{\n margin-right: 1rem;\n }\n .badgesWrapper {\n margin-left: auto;\n pointer-events: none;\n user-select: none;\n }\n }\n\n ", ";\n"], ["\n display: block;\n\n a {\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n text-decoration: none;\n font: ", ";\n padding: 1rem 1rem 1rem 4rem;\n border-radius: 0.5rem;\n color: ", ";\n .iconWrapper{\n margin-right: 1rem;\n }\n .badgesWrapper {\n margin-left: auto;\n pointer-events: none;\n user-select: none;\n }\n }\n\n ", ";\n"])), function (props) { return props.$hasIcon ? "var(--body-bold-14-17)" : "var(--body-medium-14-17)"; }, function (props) { return props.$hasIcon ? "var(--primary)" : "var(--text)"; }, function (props) { return props.$hasIcon && !props.$isActive ? "\n &:hover{\n a{\n color: var(--primary-hover) !important;\n }\n }\n " : props.$isActive ? "\n a {\n background-color: var(--primary-opacity-5) !important;\n color: var(--primary) !important;\n font: var(--body-bold-14-17) !important;\n }\n " : "\n &:hover {\n a {\n background-color: var(--primary-opacity-5) !important;\n color: var(--primary) !important;\n font: var(--body-bold-14-17) !important;\n }\n }\n "; });
15
15
  var templateObject_1, templateObject_2, templateObject_3;
@@ -0,0 +1,44 @@
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 DropdownButton_1 = __importDefault(require("./DropdownButton"));
20
+ var Link = function (_a) {
21
+ var children = _a.children;
22
+ return (0, jsx_runtime_1.jsx)("a", __assign({ href: "#" }, { children: children }));
23
+ };
24
+ var renderDropdownButton = function (list) { return (0, react_1.render)((0, jsx_runtime_1.jsx)(DropdownButton_1.default, { title: "Hesab\u0131m", hasDropdown: true, isShow: true, list: list })); };
25
+ describe("DropdownButton", function () {
26
+ it("renders the custom badge text for a badged submenu item", function () {
27
+ renderDropdownButton([
28
+ { title: "Siparişlerim", hasBadge: true, badgeText: "Yeni", component: Link },
29
+ ]);
30
+ expect(react_1.screen.getByText("Yeni")).toBeInTheDocument();
31
+ });
32
+ it("does not render badge text when hasBadge is false", function () {
33
+ renderDropdownButton([
34
+ { title: "Siparişlerim", hasBadge: false, badgeText: "Yeni", component: Link },
35
+ ]);
36
+ expect(react_1.screen.queryByText("Yeni")).not.toBeInTheDocument();
37
+ });
38
+ it("removes text decoration from submenu links", function () {
39
+ renderDropdownButton([
40
+ { title: "Siparişlerim", component: Link },
41
+ ]);
42
+ expect(react_1.screen.getByRole("link", { name: "Siparişlerim" })).toHaveStyle("text-decoration: none");
43
+ });
44
+ });
@@ -16,6 +16,8 @@ export interface List {
16
16
  slug?: string;
17
17
  isActive?: boolean;
18
18
  icon?: ICON;
19
+ hasBadge?: boolean;
20
+ badgeText?: string;
19
21
  }
20
22
  export declare const DropdownButtonDefault: DropdownButton;
21
23
  export interface DropdownButtonStyledProps {
@@ -154,6 +154,30 @@ export declare const WithoutItemIcons: {
154
154
  isActive: boolean;
155
155
  };
156
156
  };
157
+ export declare const WithNewBadge: {
158
+ args: {
159
+ isShow: boolean;
160
+ list: ({
161
+ title: string;
162
+ hasBadge: boolean;
163
+ badgeText: string;
164
+ component: ({ children }: {
165
+ children: any;
166
+ }) => React.JSX.Element;
167
+ } | {
168
+ title: string;
169
+ component: ({ children }: {
170
+ children: any;
171
+ }) => React.JSX.Element;
172
+ hasBadge?: undefined;
173
+ badgeText?: undefined;
174
+ })[];
175
+ title: string;
176
+ icon: string;
177
+ hasDropdown: boolean;
178
+ isActive: boolean;
179
+ };
180
+ };
157
181
  export declare const CustomIcon: {
158
182
  args: {
159
183
  icon: 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.CustomIcon = exports.WithoutItemIcons = exports.EmptyList = exports.WithoutDropdown = exports.Active = exports.Open = exports.Default = void 0;
17
+ exports.Interactive = exports.CustomIcon = exports.WithNewBadge = exports.WithoutItemIcons = exports.EmptyList = exports.WithoutDropdown = exports.Active = exports.Open = 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 DropdownButton_1 = __importDefault(require("../DropdownButton"));
@@ -96,6 +96,26 @@ exports.WithoutItemIcons = {
96
96
  } },
97
97
  ] }),
98
98
  };
99
+ exports.WithNewBadge = {
100
+ args: __assign(__assign({}, baseArgs), { isShow: true, list: [
101
+ {
102
+ title: "Siparişlerim",
103
+ hasBadge: true,
104
+ badgeText: "Yeni",
105
+ component: function (_a) {
106
+ var children = _a.children;
107
+ return (0, jsx_runtime_1.jsx)("a", __assign({ href: "#" }, { children: children }));
108
+ },
109
+ },
110
+ {
111
+ title: "Hesabım",
112
+ component: function (_a) {
113
+ var children = _a.children;
114
+ return (0, jsx_runtime_1.jsx)("a", __assign({ href: "#" }, { children: children }));
115
+ },
116
+ },
117
+ ] }),
118
+ };
99
119
  exports.CustomIcon = {
100
120
  args: __assign(__assign({}, baseArgs), { icon: "Setting", title: "Ayarlar", isShow: true }),
101
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "krl-alfred",
3
- "version": "2.25.1",
3
+ "version": "2.25.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],