krl-alfred 2.25.2 → 2.25.3

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.
Files changed (65) hide show
  1. package/dist/components/Dropdown/Dropdown.d.ts +2 -2
  2. package/dist/components/Dropdown/Dropdown.js +89 -19
  3. package/dist/components/Dropdown/Dropdown.styled.d.ts +2 -1
  4. package/dist/components/Dropdown/Dropdown.styled.js +4 -39
  5. package/dist/components/Dropdown/Dropdown.test.d.ts +1 -0
  6. package/dist/components/Dropdown/Dropdown.test.js +254 -0
  7. package/dist/components/Dropdown/props.d.ts +17 -9
  8. package/dist/components/Dropdown/props.js +3 -0
  9. package/dist/components/Dropdown/stories/Dropdown.stories.d.ts +44 -2
  10. package/dist/components/Dropdown/stories/Dropdown.stories.js +6 -3
  11. package/dist/components/Input/Input.d.ts +1 -1
  12. package/dist/components/Input/Input.js +45 -17
  13. package/dist/components/Input/Input.styled.js +1 -1
  14. package/dist/components/Input/Input.test.js +290 -7
  15. package/dist/components/Input/props.d.ts +5 -0
  16. package/dist/components/Input/props.js +5 -0
  17. package/dist/components/Input/stories/Input.stories.d.ts +74 -0
  18. package/dist/components/Input/stories/Input.stories.js +69 -1
  19. package/dist/components/PaymentCart/PaymentCart.d.ts +1 -1
  20. package/dist/components/PaymentCart/PaymentCart.js +4 -4
  21. package/dist/components/PaymentCart/PaymentCart.styled.js +1 -1
  22. package/dist/components/PaymentCart/PaymentCart.test.d.ts +1 -0
  23. package/dist/components/PaymentCart/PaymentCart.test.js +137 -0
  24. package/dist/components/PaymentCart/props.d.ts +3 -1
  25. package/dist/components/PaymentCart/props.js +2 -0
  26. package/dist/components/PaymentCart/stories/PaymentCart.stories.d.ts +63 -0
  27. package/dist/components/PaymentCart/stories/PaymentCart.stories.js +10 -2
  28. package/dist/components/ProductCardHorizontal/ProductCardHorizontal.js +1 -1
  29. package/dist/components/ProductCardHorizontal/ProductCardHorizontal.test.d.ts +1 -0
  30. package/dist/components/ProductCardHorizontal/ProductCardHorizontal.test.js +32 -0
  31. package/dist/components/QuantitySelector/QuantitySelector.d.ts +1 -1
  32. package/dist/components/QuantitySelector/QuantitySelector.js +5 -3
  33. package/dist/components/QuantitySelector/QuantitySelector.test.js +141 -35
  34. package/dist/components/QuantitySelector/props.d.ts +6 -0
  35. package/dist/components/QuantitySelector/props.js +3 -0
  36. package/dist/components/QuantitySelector/stories/QuantitySelector.stories.d.ts +43 -1
  37. package/dist/components/QuantitySelector/stories/QuantitySelector.stories.js +6 -0
  38. package/dist/components/SearchBox/SearchBox.js +76 -52
  39. package/dist/components/SearchBox/SearchBox.styled.js +1 -1
  40. package/dist/components/SearchBox/SearchBox.test.d.ts +1 -0
  41. package/dist/components/SearchBox/SearchBox.test.js +371 -0
  42. package/dist/components/SearchBox/props.d.ts +6 -0
  43. package/dist/components/SearchBox/props.js +3 -0
  44. package/dist/components/SearchBox/stories/SearchBox.stories.d.ts +23 -0
  45. package/dist/components/SearchBox/stories/SearchBox.stories.js +4 -0
  46. package/dist/components/ShoppingCartProduct/ShoppingCartProduct.d.ts +1 -1
  47. package/dist/components/ShoppingCartProduct/ShoppingCartProduct.js +2 -2
  48. package/dist/components/ShoppingCartProduct/ShoppingCartProduct.test.js +67 -0
  49. package/dist/components/ShoppingCartProduct/props.d.ts +6 -0
  50. package/dist/components/ShoppingCartProduct/props.js +3 -0
  51. package/dist/components/ShoppingCartProduct/stories/ShoppingCartProduct.stories.d.ts +78 -0
  52. package/dist/components/ShoppingCartProduct/stories/ShoppingCartProduct.stories.js +6 -0
  53. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  54. package/dist/components/Tooltip/Tooltip.js +34 -3
  55. package/dist/components/Tooltip/Tooltip.styled.d.ts +1 -1
  56. package/dist/components/Tooltip/Tooltip.styled.js +3 -3
  57. package/dist/components/Tooltip/Tooltip.test.d.ts +1 -0
  58. package/dist/components/Tooltip/Tooltip.test.js +152 -0
  59. package/dist/components/Tooltip/props.d.ts +1 -0
  60. package/dist/components/Tooltip/props.js +1 -0
  61. package/dist/components/Tooltip/stories/Tooltip.stories.d.ts +22 -0
  62. package/dist/components/Tooltip/stories/Tooltip.stories.js +2 -0
  63. package/dist/i18n/locales/english.json +12 -0
  64. package/dist/i18n/locales/turkish.json +12 -0
  65. package/package.json +1 -1
@@ -118,6 +118,73 @@ var renderProduct = function (props) {
118
118
  if (props === void 0) { props = {}; }
119
119
  return (0, react_1.render)((0, jsx_runtime_1.jsx)(ShoppingCartProduct_1.default, __assign({}, campaignProps, props)));
120
120
  };
121
+ var quantityLabels = {
122
+ incrementAriaLabel: 'Kenya AA adedini artır',
123
+ decrementAriaLabel: 'Kenya AA adedini azalt',
124
+ removeAriaLabel: 'Kenya AA ürününü sepetten kaldır',
125
+ };
126
+ describe('ShoppingCartProduct quantity controls', function () {
127
+ it('forwards product-specific increment and decrement names unchanged', function () {
128
+ renderProduct(__assign(__assign({}, quantityLabels), { hasRemove: false }));
129
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.incrementAriaLabel })).toBeInTheDocument();
130
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.decrementAriaLabel })).toBeInTheDocument();
131
+ expect(react_1.screen.queryByRole('button', { name: quantityLabels.removeAriaLabel })).not.toBeInTheDocument();
132
+ });
133
+ it('forwards the remove name when the product is removable', function () {
134
+ renderProduct(__assign(__assign({}, quantityLabels), { hasRemove: true }));
135
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.incrementAriaLabel })).toBeInTheDocument();
136
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.removeAriaLabel })).toBeInTheDocument();
137
+ expect(react_1.screen.queryByRole('button', { name: quantityLabels.decrementAriaLabel })).not.toBeInTheDocument();
138
+ });
139
+ it('keeps named callbacks connected to their actions', function () { return __awaiter(void 0, void 0, void 0, function () {
140
+ var user, onIncrement, onDecrement;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0:
144
+ user = user_event_1.default.setup();
145
+ onIncrement = jest.fn();
146
+ onDecrement = jest.fn();
147
+ renderProduct(__assign(__assign({}, quantityLabels), { onIncrement: onIncrement, onDecrement: onDecrement }));
148
+ return [4 /*yield*/, user.click(react_1.screen.getByRole('button', { name: quantityLabels.incrementAriaLabel }))];
149
+ case 1:
150
+ _a.sent();
151
+ return [4 /*yield*/, user.click(react_1.screen.getByRole('button', { name: quantityLabels.decrementAriaLabel }))];
152
+ case 2:
153
+ _a.sent();
154
+ expect(onIncrement).toHaveBeenCalledTimes(1);
155
+ expect(onDecrement).toHaveBeenCalledTimes(1);
156
+ return [2 /*return*/];
157
+ }
158
+ });
159
+ }); });
160
+ it('keeps the named remove callback connected to the remove action', function () { return __awaiter(void 0, void 0, void 0, function () {
161
+ var user, onRemove;
162
+ return __generator(this, function (_a) {
163
+ switch (_a.label) {
164
+ case 0:
165
+ user = user_event_1.default.setup();
166
+ onRemove = jest.fn();
167
+ renderProduct(__assign(__assign({}, quantityLabels), { hasRemove: true, onRemove: onRemove }));
168
+ return [4 /*yield*/, user.click(react_1.screen.getByRole('button', { name: quantityLabels.removeAriaLabel }))];
169
+ case 1:
170
+ _a.sent();
171
+ expect(onRemove).toHaveBeenCalledTimes(1);
172
+ return [2 /*return*/];
173
+ }
174
+ });
175
+ }); });
176
+ it('preserves names while loading and hides controls when actions are disabled', function () {
177
+ var rerender = renderProduct(__assign(__assign({}, quantityLabels), { hasLoading: true })).rerender;
178
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.incrementAriaLabel })).toBeDisabled();
179
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.decrementAriaLabel })).toBeDisabled();
180
+ rerender((0, jsx_runtime_1.jsx)(ShoppingCartProduct_1.default, __assign({}, campaignProps, quantityLabels, { hasDisableIncrement: true })));
181
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.incrementAriaLabel })).toBeDisabled();
182
+ expect(react_1.screen.getByRole('button', { name: quantityLabels.decrementAriaLabel })).toBeEnabled();
183
+ rerender((0, jsx_runtime_1.jsx)(ShoppingCartProduct_1.default, __assign({}, campaignProps, quantityLabels, { hasDisableActions: true })));
184
+ expect(react_1.screen.queryByRole('button', { name: quantityLabels.incrementAriaLabel })).not.toBeInTheDocument();
185
+ expect(react_1.screen.queryByRole('button', { name: quantityLabels.decrementAriaLabel })).not.toBeInTheDocument();
186
+ });
187
+ });
121
188
  describe('ShoppingCartProduct campaigns', function () {
122
189
  it('does not render a campaign row when campaigns is empty', function () {
123
190
  renderProduct({ campaigns: [] });
@@ -58,6 +58,12 @@ export interface ShoppingCartProduct {
58
58
  onRemove?(): void;
59
59
  onIncrement?(): void;
60
60
  onDecrement?(): void;
61
+ /** Accessible name forwarded to the quantity increment button */
62
+ incrementAriaLabel?: string;
63
+ /** Accessible name forwarded to the quantity decrement button */
64
+ decrementAriaLabel?: string;
65
+ /** Accessible name forwarded to the remove button */
66
+ removeAriaLabel?: string;
61
67
  toggleInsurance?(): void;
62
68
  toggleInsuranceLogo?(): void;
63
69
  insuranceOption1TooltipTitle?: string;
@@ -52,6 +52,9 @@ exports.ShoppingCartProductDefault = {
52
52
  onRemove: null,
53
53
  onIncrement: null,
54
54
  onDecrement: null,
55
+ incrementAriaLabel: null,
56
+ decrementAriaLabel: null,
57
+ removeAriaLabel: null,
55
58
  toggleInsurance: null,
56
59
  toggleInsuranceLogo: null,
57
60
  hasInsurancePriceAdded: false,
@@ -44,6 +44,15 @@ declare const _default: {
44
44
  campaigns: {
45
45
  control: string;
46
46
  };
47
+ incrementAriaLabel: {
48
+ control: string;
49
+ };
50
+ decrementAriaLabel: {
51
+ control: string;
52
+ };
53
+ removeAriaLabel: {
54
+ control: string;
55
+ };
47
56
  };
48
57
  };
49
58
  export default _default;
@@ -66,6 +75,9 @@ export declare const Default: {
66
75
  onRemove: () => void;
67
76
  onIncrement: () => void;
68
77
  onDecrement: () => void;
78
+ incrementAriaLabel: string;
79
+ decrementAriaLabel: string;
80
+ removeAriaLabel: string;
69
81
  toggleInsurance: () => void;
70
82
  image: React.JSX.Element;
71
83
  hasError: boolean;
@@ -100,6 +112,9 @@ export declare const WithRemove: {
100
112
  onRemove: () => void;
101
113
  onIncrement: () => void;
102
114
  onDecrement: () => void;
115
+ incrementAriaLabel: string;
116
+ decrementAriaLabel: string;
117
+ removeAriaLabel: string;
103
118
  toggleInsurance: () => void;
104
119
  image: React.JSX.Element;
105
120
  hasError: boolean;
@@ -135,6 +150,9 @@ export declare const WithoutInsurance: {
135
150
  onRemove: () => void;
136
151
  onIncrement: () => void;
137
152
  onDecrement: () => void;
153
+ incrementAriaLabel: string;
154
+ decrementAriaLabel: string;
155
+ removeAriaLabel: string;
138
156
  toggleInsurance: () => void;
139
157
  image: React.JSX.Element;
140
158
  hasError: boolean;
@@ -169,6 +187,9 @@ export declare const Loading: {
169
187
  onRemove: () => void;
170
188
  onIncrement: () => void;
171
189
  onDecrement: () => void;
190
+ incrementAriaLabel: string;
191
+ decrementAriaLabel: string;
192
+ removeAriaLabel: string;
172
193
  toggleInsurance: () => void;
173
194
  image: React.JSX.Element;
174
195
  hasError: boolean;
@@ -203,6 +224,9 @@ export declare const WithError: {
203
224
  onRemove: () => void;
204
225
  onIncrement: () => void;
205
226
  onDecrement: () => void;
227
+ incrementAriaLabel: string;
228
+ decrementAriaLabel: string;
229
+ removeAriaLabel: string;
206
230
  toggleInsurance: () => void;
207
231
  image: React.JSX.Element;
208
232
  hasLoading: boolean;
@@ -236,6 +260,9 @@ export declare const WithoutDiscount: {
236
260
  onRemove: () => void;
237
261
  onIncrement: () => void;
238
262
  onDecrement: () => void;
263
+ incrementAriaLabel: string;
264
+ decrementAriaLabel: string;
265
+ removeAriaLabel: string;
239
266
  toggleInsurance: () => void;
240
267
  image: React.JSX.Element;
241
268
  hasError: boolean;
@@ -271,6 +298,9 @@ export declare const DisabledActions: {
271
298
  onRemove: () => void;
272
299
  onIncrement: () => void;
273
300
  onDecrement: () => void;
301
+ incrementAriaLabel: string;
302
+ decrementAriaLabel: string;
303
+ removeAriaLabel: string;
274
304
  toggleInsurance: () => void;
275
305
  image: React.JSX.Element;
276
306
  hasError: boolean;
@@ -306,6 +336,9 @@ export declare const WithInsurancePrice: {
306
336
  onRemove: () => void;
307
337
  onIncrement: () => void;
308
338
  onDecrement: () => void;
339
+ incrementAriaLabel: string;
340
+ decrementAriaLabel: string;
341
+ removeAriaLabel: string;
309
342
  toggleInsurance: () => void;
310
343
  image: React.JSX.Element;
311
344
  hasError: boolean;
@@ -339,6 +372,9 @@ export declare const Minimal: {
339
372
  onRemove: () => void;
340
373
  onIncrement: () => void;
341
374
  onDecrement: () => void;
375
+ incrementAriaLabel: string;
376
+ decrementAriaLabel: string;
377
+ removeAriaLabel: string;
342
378
  toggleInsurance: () => void;
343
379
  image: React.JSX.Element;
344
380
  hasError: boolean;
@@ -374,6 +410,9 @@ export declare const WithCampaign: {
374
410
  onRemove: () => void;
375
411
  onIncrement: () => void;
376
412
  onDecrement: () => void;
413
+ incrementAriaLabel: string;
414
+ decrementAriaLabel: string;
415
+ removeAriaLabel: string;
377
416
  toggleInsurance: () => void;
378
417
  image: React.JSX.Element;
379
418
  hasError: boolean;
@@ -410,6 +449,9 @@ export declare const WithMultipleCampaigns: {
410
449
  onRemove: () => void;
411
450
  onIncrement: () => void;
412
451
  onDecrement: () => void;
452
+ incrementAriaLabel: string;
453
+ decrementAriaLabel: string;
454
+ removeAriaLabel: string;
413
455
  toggleInsurance: () => void;
414
456
  image: React.JSX.Element;
415
457
  hasError: boolean;
@@ -453,6 +495,9 @@ export declare const InsuranceType2: {
453
495
  onRemove: () => void;
454
496
  onIncrement: () => void;
455
497
  onDecrement: () => void;
498
+ incrementAriaLabel: string;
499
+ decrementAriaLabel: string;
500
+ removeAriaLabel: string;
456
501
  toggleInsurance: () => void;
457
502
  image: React.JSX.Element;
458
503
  hasError: boolean;
@@ -494,6 +539,9 @@ export declare const InsuranceType2PriceLoading: {
494
539
  onRemove: () => void;
495
540
  onIncrement: () => void;
496
541
  onDecrement: () => void;
542
+ incrementAriaLabel: string;
543
+ decrementAriaLabel: string;
544
+ removeAriaLabel: string;
497
545
  toggleInsurance: () => void;
498
546
  image: React.JSX.Element;
499
547
  hasError: boolean;
@@ -536,6 +584,9 @@ export declare const UpfrontAddonWithDiscount: {
536
584
  onRemove: () => void;
537
585
  onIncrement: () => void;
538
586
  onDecrement: () => void;
587
+ incrementAriaLabel: string;
588
+ decrementAriaLabel: string;
589
+ removeAriaLabel: string;
539
590
  toggleInsurance: () => void;
540
591
  hasError: boolean;
541
592
  hasLoading: boolean;
@@ -575,6 +626,9 @@ export declare const UpfrontAddonSimple: {
575
626
  onRemove: () => void;
576
627
  onIncrement: () => void;
577
628
  onDecrement: () => void;
629
+ incrementAriaLabel: string;
630
+ decrementAriaLabel: string;
631
+ removeAriaLabel: string;
578
632
  toggleInsurance: () => void;
579
633
  hasError: boolean;
580
634
  hasLoading: boolean;
@@ -617,6 +671,9 @@ export declare const UpfrontAddonChecked: {
617
671
  onRemove: () => void;
618
672
  onIncrement: () => void;
619
673
  onDecrement: () => void;
674
+ incrementAriaLabel: string;
675
+ decrementAriaLabel: string;
676
+ removeAriaLabel: string;
620
677
  toggleInsurance: () => void;
621
678
  hasError: boolean;
622
679
  hasLoading: boolean;
@@ -660,6 +717,9 @@ export declare const UpfrontAddonCheckedLoading: {
660
717
  onRemove: () => void;
661
718
  onIncrement: () => void;
662
719
  onDecrement: () => void;
720
+ incrementAriaLabel: string;
721
+ decrementAriaLabel: string;
722
+ removeAriaLabel: string;
663
723
  toggleInsurance: () => void;
664
724
  hasError: boolean;
665
725
  hasLoading: boolean;
@@ -694,6 +754,9 @@ export declare const WithInsuranceTooltip: {
694
754
  onRemove: () => void;
695
755
  onIncrement: () => void;
696
756
  onDecrement: () => void;
757
+ incrementAriaLabel: string;
758
+ decrementAriaLabel: string;
759
+ removeAriaLabel: string;
697
760
  toggleInsurance: () => void;
698
761
  image: React.JSX.Element;
699
762
  hasError: boolean;
@@ -727,6 +790,9 @@ export declare const InsuranceLoading: {
727
790
  onRemove: () => void;
728
791
  onIncrement: () => void;
729
792
  onDecrement: () => void;
793
+ incrementAriaLabel: string;
794
+ decrementAriaLabel: string;
795
+ removeAriaLabel: string;
730
796
  toggleInsurance: () => void;
731
797
  image: React.JSX.Element;
732
798
  hasError: boolean;
@@ -764,6 +830,9 @@ export declare const InsurancePriceAdded: {
764
830
  onRemove: () => void;
765
831
  onIncrement: () => void;
766
832
  onDecrement: () => void;
833
+ incrementAriaLabel: string;
834
+ decrementAriaLabel: string;
835
+ removeAriaLabel: string;
767
836
  toggleInsurance: () => void;
768
837
  image: React.JSX.Element;
769
838
  hasError: boolean;
@@ -797,6 +866,9 @@ export declare const DisableIncrement: {
797
866
  onRemove: () => void;
798
867
  onIncrement: () => void;
799
868
  onDecrement: () => void;
869
+ incrementAriaLabel: string;
870
+ decrementAriaLabel: string;
871
+ removeAriaLabel: string;
800
872
  toggleInsurance: () => void;
801
873
  image: React.JSX.Element;
802
874
  hasError: boolean;
@@ -838,6 +910,9 @@ export declare const Complete: {
838
910
  onRemove: () => void;
839
911
  onIncrement: () => void;
840
912
  onDecrement: () => void;
913
+ incrementAriaLabel: string;
914
+ decrementAriaLabel: string;
915
+ removeAriaLabel: string;
841
916
  toggleInsurance: () => void;
842
917
  image: React.JSX.Element;
843
918
  hasLoading: boolean;
@@ -867,6 +942,9 @@ export declare const Interactive: {
867
942
  onRemove: () => void;
868
943
  onIncrement: () => void;
869
944
  onDecrement: () => void;
945
+ incrementAriaLabel: string;
946
+ decrementAriaLabel: string;
947
+ removeAriaLabel: string;
870
948
  toggleInsurance: () => void;
871
949
  image: React.JSX.Element;
872
950
  hasError: boolean;
@@ -40,6 +40,9 @@ var defaultArgs = {
40
40
  onRemove: function () { return console.log("onRemove event"); },
41
41
  onIncrement: function () { return console.log("onIncrement event"); },
42
42
  onDecrement: function () { return console.log("onDecrement event"); },
43
+ incrementAriaLabel: "Apple iPad Air adedini artır",
44
+ decrementAriaLabel: "Apple iPad Air adedini azalt",
45
+ removeAriaLabel: "Apple iPad Air ürününü sepetten kaldır",
43
46
  toggleInsurance: function () { return console.log("toggleInsurance event"); },
44
47
  image: defaultImage,
45
48
  hasError: false,
@@ -72,6 +75,9 @@ exports.default = {
72
75
  discountRate: { control: 'number' },
73
76
  quantity: { control: 'text' },
74
77
  campaigns: { control: 'object' },
78
+ incrementAriaLabel: { control: 'text' },
79
+ decrementAriaLabel: { control: 'text' },
80
+ removeAriaLabel: { control: 'text' },
75
81
  }
76
82
  };
77
83
  exports.Default = {
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { TooltipProps } from "./props";
3
- declare const Tooltip: ({ iconWidth, iconHeight, children, title, popupWidth, hasClickAction, hasCloseOnOutsideClick, isOpen, position, popupSize, popupLeft, popupRight, id, selectorTitle, popupRightSm, }: TooltipProps) => React.JSX.Element;
3
+ declare const Tooltip: ({ iconWidth, iconHeight, children, title, popupWidth, hasClickAction, hasCloseOnOutsideClick, isOpen, position, popupSize, popupLeft, popupRight, id, selectorTitle, selectorAriaLabel, popupRightSm, }: TooltipProps) => React.JSX.Element;
4
4
  export default Tooltip;
@@ -21,13 +21,44 @@ var Tooltip_styled_1 = require("./Tooltip.styled");
21
21
  var Icon_1 = __importDefault(require("../Icon/Icon"));
22
22
  var useOnClickOutside_1 = __importDefault(require("../../hooks/useOnClickOutside"));
23
23
  var Tooltip = function (_a) {
24
- var _b = _a.iconWidth, iconWidth = _b === void 0 ? props_1.TooltipDefault.iconWidth : _b, _c = _a.iconHeight, iconHeight = _c === void 0 ? props_1.TooltipDefault.iconHeight : _c, _d = _a.children, children = _d === void 0 ? props_1.TooltipDefault.children : _d, _e = _a.title, title = _e === void 0 ? props_1.TooltipDefault.title : _e, _f = _a.popupWidth, popupWidth = _f === void 0 ? props_1.TooltipDefault.popupWidth : _f, _g = _a.hasClickAction, hasClickAction = _g === void 0 ? props_1.TooltipDefault.hasClickAction : _g, _h = _a.hasCloseOnOutsideClick, hasCloseOnOutsideClick = _h === void 0 ? props_1.TooltipDefault.hasCloseOnOutsideClick : _h, _j = _a.isOpen, isOpen = _j === void 0 ? props_1.TooltipDefault.isOpen : _j, _k = _a.position, position = _k === void 0 ? props_1.TooltipDefault.position : _k, _l = _a.popupSize, popupSize = _l === void 0 ? props_1.TooltipDefault.popupSize : _l, _m = _a.popupLeft, popupLeft = _m === void 0 ? props_1.TooltipDefault.popupLeft : _m, _o = _a.popupRight, popupRight = _o === void 0 ? props_1.TooltipDefault.popupRight : _o, _p = _a.id, id = _p === void 0 ? props_1.TooltipDefault.id : _p, _q = _a.selectorTitle, selectorTitle = _q === void 0 ? props_1.TooltipDefault.selectorTitle : _q, _r = _a.popupRightSm, popupRightSm = _r === void 0 ? props_1.TooltipDefault.popupRightSm : _r;
25
- var _s = (0, react_1.useState)(isOpen), isOpenTooltip = _s[0], setIsOpenTooltip = _s[1];
24
+ var _b = _a.iconWidth, iconWidth = _b === void 0 ? props_1.TooltipDefault.iconWidth : _b, _c = _a.iconHeight, iconHeight = _c === void 0 ? props_1.TooltipDefault.iconHeight : _c, _d = _a.children, children = _d === void 0 ? props_1.TooltipDefault.children : _d, _e = _a.title, title = _e === void 0 ? props_1.TooltipDefault.title : _e, _f = _a.popupWidth, popupWidth = _f === void 0 ? props_1.TooltipDefault.popupWidth : _f, _g = _a.hasClickAction, hasClickAction = _g === void 0 ? props_1.TooltipDefault.hasClickAction : _g, _h = _a.hasCloseOnOutsideClick, hasCloseOnOutsideClick = _h === void 0 ? props_1.TooltipDefault.hasCloseOnOutsideClick : _h, _j = _a.isOpen, isOpen = _j === void 0 ? props_1.TooltipDefault.isOpen : _j, _k = _a.position, position = _k === void 0 ? props_1.TooltipDefault.position : _k, _l = _a.popupSize, popupSize = _l === void 0 ? props_1.TooltipDefault.popupSize : _l, _m = _a.popupLeft, popupLeft = _m === void 0 ? props_1.TooltipDefault.popupLeft : _m, _o = _a.popupRight, popupRight = _o === void 0 ? props_1.TooltipDefault.popupRight : _o, _p = _a.id, id = _p === void 0 ? props_1.TooltipDefault.id : _p, _q = _a.selectorTitle, selectorTitle = _q === void 0 ? props_1.TooltipDefault.selectorTitle : _q, _r = _a.selectorAriaLabel, selectorAriaLabel = _r === void 0 ? props_1.TooltipDefault.selectorAriaLabel : _r, _s = _a.popupRightSm, popupRightSm = _s === void 0 ? props_1.TooltipDefault.popupRightSm : _s;
25
+ var _t = (0, react_1.useState)(isOpen), isOpenTooltip = _t[0], setIsOpenTooltip = _t[1];
26
+ var generatedId = (0, react_1.useId)();
27
+ var popupId = "".concat(id || "alfred-tooltip-".concat(generatedId), "-content");
28
+ var selectorRef = (0, react_1.useRef)();
26
29
  (0, react_1.useEffect)(function () {
27
30
  setIsOpenTooltip(isOpen);
28
31
  }, [isOpen]);
29
32
  var tooltipRef = (0, react_1.useRef)();
30
33
  (0, useOnClickOutside_1.default)(tooltipRef, function () { return setIsOpenTooltip(false); }, hasCloseOnOutsideClick);
31
- return ((0, jsx_runtime_1.jsxs)(Tooltip_styled_1.TooltipStyled, __assign({ id: id, ref: tooltipRef, "$hasClickAction": hasClickAction }, { children: [(0, jsx_runtime_1.jsxs)(Tooltip_styled_1.Selector, __assign({ "$isOpen": isOpenTooltip, "$position": position, "$hasClickAction": hasClickAction, onClick: function () { return setIsOpenTooltip(!isOpenTooltip); } }, { children: [(0, jsx_runtime_1.jsx)(Tooltip_styled_1.SelectorIconWrapper, __assign({ "$isOpen": isOpenTooltip, "$position": position, "$hasClickAction": hasClickAction }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: iconWidth === "16px" ? "InfoSquareSmall" : "InfoSquare", width: iconWidth, height: iconHeight }) })), selectorTitle && (0, jsx_runtime_1.jsx)(Tooltip_styled_1.SelectorTitle, { children: selectorTitle })] })), (0, jsx_runtime_1.jsx)(Tooltip_styled_1.PopupWrapper, __assign({ "$iconWidth": iconWidth }, { children: (0, jsx_runtime_1.jsxs)(Tooltip_styled_1.Popup, __assign({ "$popupSize": popupSize, "$position": position, "$popupWidth": popupWidth, "$isOpen": isOpenTooltip, "$hasClickAction": hasClickAction, "$popupLeft": popupLeft, "$popupRight": popupRight, "$popupRightSm": popupRightSm, className: "customPopup" }, { children: [title && (0, jsx_runtime_1.jsx)(Tooltip_styled_1.Title, { children: title }), children] })) }))] })));
34
+ var handleClick = function () {
35
+ if (hasClickAction)
36
+ setIsOpenTooltip(function (current) { return !current; });
37
+ };
38
+ var handleKeyDown = function (event) {
39
+ var _a;
40
+ if (event.key === 'Escape') {
41
+ event.preventDefault();
42
+ setIsOpenTooltip(false);
43
+ (_a = selectorRef.current) === null || _a === void 0 ? void 0 : _a.focus();
44
+ }
45
+ };
46
+ var handleFocus = function () {
47
+ if (!hasClickAction)
48
+ setIsOpenTooltip(true);
49
+ };
50
+ var handleBlur = function () {
51
+ if (!hasClickAction)
52
+ setIsOpenTooltip(false);
53
+ };
54
+ var handleMouseEnter = function () {
55
+ if (!hasClickAction)
56
+ setIsOpenTooltip(true);
57
+ };
58
+ var handleMouseLeave = function () {
59
+ if (!hasClickAction)
60
+ setIsOpenTooltip(false);
61
+ };
62
+ return ((0, jsx_runtime_1.jsxs)(Tooltip_styled_1.TooltipStyled, __assign({ id: id, ref: tooltipRef, "$hasClickAction": hasClickAction, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, { children: [(0, jsx_runtime_1.jsxs)(Tooltip_styled_1.Selector, __assign({ ref: selectorRef, type: "button", "aria-label": selectorAriaLabel || undefined, "aria-describedby": popupId, "aria-expanded": isOpenTooltip, "$isOpen": isOpenTooltip, "$position": position, "$hasClickAction": hasClickAction, onClick: handleClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur }, { children: [(0, jsx_runtime_1.jsx)(Tooltip_styled_1.SelectorIconWrapper, __assign({ "aria-hidden": "true", "$isOpen": isOpenTooltip, "$position": position, "$hasClickAction": hasClickAction }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: iconWidth === "16px" ? "InfoSquareSmall" : "InfoSquare", width: iconWidth, height: iconHeight }) })), selectorTitle && (0, jsx_runtime_1.jsx)(Tooltip_styled_1.SelectorTitle, { children: selectorTitle })] })), (0, jsx_runtime_1.jsx)(Tooltip_styled_1.PopupWrapper, __assign({ "$iconWidth": iconWidth }, { children: (0, jsx_runtime_1.jsxs)(Tooltip_styled_1.Popup, __assign({ id: popupId, role: "tooltip", hidden: !isOpenTooltip, "$popupSize": popupSize, "$position": position, "$popupWidth": popupWidth, "$isOpen": isOpenTooltip, "$hasClickAction": hasClickAction, "$popupLeft": popupLeft, "$popupRight": popupRight, "$popupRightSm": popupRightSm, className: "customPopup" }, { children: [title && (0, jsx_runtime_1.jsx)(Tooltip_styled_1.Title, { children: title }), children] })) }))] })));
32
63
  };
33
64
  exports.default = Tooltip;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { TooltipStyledProps } from "./props";
3
3
  export declare const TooltipStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TooltipStyledProps> & TooltipStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TooltipStyledProps> & TooltipStyledProps, never>>> & string;
4
- export declare const Selector: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TooltipStyledProps> & TooltipStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TooltipStyledProps> & TooltipStyledProps, never>>> & string;
4
+ export declare const Selector: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, keyof TooltipStyledProps> & TooltipStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, keyof TooltipStyledProps> & TooltipStyledProps, never>>> & string;
5
5
  export declare const SelectorIconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TooltipStyledProps> & TooltipStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TooltipStyledProps> & TooltipStyledProps, never>>> & string;
6
6
  export declare const SelectorTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, keyof TooltipStyledProps> & TooltipStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, keyof TooltipStyledProps> & TooltipStyledProps, never>>> & string;
7
7
  export declare const Title: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, keyof TooltipStyledProps> & TooltipStyledProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, keyof TooltipStyledProps> & TooltipStyledProps, never>>> & string;
@@ -11,7 +11,7 @@ exports.PopupWrapper = exports.Popup = exports.Title = exports.SelectorTitle = e
11
11
  var styled_components_1 = __importDefault(require("styled-components"));
12
12
  var devices_1 = require("../../constants/devices");
13
13
  exports.TooltipStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: block;\n position: relative;\n vertical-align: middle;\n color: var(--text);\n ", "\n"], ["\n display: block;\n position: relative;\n vertical-align: middle;\n color: var(--text);\n ", "\n"])), function (props) { return !props.$hasClickAction && "\n &:hover {\n ".concat(exports.Popup, " {\n opacity: 1;\n }\n :before{\n opacity:1;\n }\n }\n "); });
14
- exports.Selector = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n cursor: ", ";\n position: relative;\n color: var(--primary);\n ", "\n"], ["\n display: flex;\n align-items: center;\n cursor: ", ";\n position: relative;\n color: var(--primary);\n ", "\n"])), function (props) { return props.$hasClickAction ? 'pointer' : 'initial'; }, function (props) { return (!props.$hasClickAction) ? "\n &:hover{\n ".concat(exports.SelectorIconWrapper, "{\n &:before{\n opacity: 1;\n }\n }\n }\n ") : null; });
14
+ exports.Selector = styled_components_1.default.button(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n appearance: none;\n border: 0;\n padding: 0;\n background: transparent;\n font: inherit;\n display: flex;\n align-items: center;\n cursor: ", ";\n position: relative;\n color: var(--primary);\n &:focus-visible {\n outline: 2px solid var(--primary);\n outline-offset: 2px;\n border-radius: 0.25rem;\n }\n ", "\n"], ["\n appearance: none;\n border: 0;\n padding: 0;\n background: transparent;\n font: inherit;\n display: flex;\n align-items: center;\n cursor: ", ";\n position: relative;\n color: var(--primary);\n &:focus-visible {\n outline: 2px solid var(--primary);\n outline-offset: 2px;\n border-radius: 0.25rem;\n }\n ", "\n"])), function (props) { return props.$hasClickAction ? 'pointer' : 'initial'; }, function (props) { return (!props.$hasClickAction) ? "\n &:hover{\n ".concat(exports.SelectorIconWrapper, "{\n &:before{\n opacity: 1;\n }\n }\n }\n ") : null; });
15
15
  exports.SelectorIconWrapper = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n &:before {\n content: '';\n position: absolute;\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n right: auto;\n transition: all 0.15s ease;\n background-color: var(--primary-opacity-10);\n width: 12px;\n height: 12px;\n border-radius: 3px;\n opacity: ", ";\n ", ";\n }\n"], ["\n position: relative;\n &:before {\n content: '';\n position: absolute;\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n right: auto;\n transition: all 0.15s ease;\n background-color: var(--primary-opacity-10);\n width: 12px;\n height: 12px;\n border-radius: 3px;\n opacity: ", ";\n ", ";\n }\n"])), function (props) { return (props.$hasClickAction && props.$isOpen) ? '1' : "0"; }, function (props) {
16
16
  switch (props.$position) {
17
17
  case 'bottomRight':
@@ -32,7 +32,7 @@ exports.SelectorIconWrapper = styled_components_1.default.div(templateObject_3 |
32
32
  });
33
33
  exports.SelectorTitle = styled_components_1.default.strong(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-left: 0.5rem;\n font: var(--body-bold-14-17);\n color: var(--primary);\n"], ["\n margin-left: 0.5rem;\n font: var(--body-bold-14-17);\n color: var(--primary);\n"])));
34
34
  exports.Title = styled_components_1.default.strong(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: block;\n margin-bottom: 0.5rem;\n font:var(--body-extra-bold-13-16);\n"], ["\n display: block;\n margin-bottom: 0.5rem;\n font:var(--body-extra-bold-13-16);\n"])));
35
- exports.Popup = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n max-width: ", ";\n width: calc(100vw - 4.5rem);\n padding: ", ";\n border-radius: 0.5rem;\n background-color: var(--primary-opacity-10);\n z-index: 99999;\n box-sizing: border-box;\n user-select: none;\n pointer-events: none;\n transition: all 0.15s ease;\n opacity: ", ";\n font:var(--caption-medium-11-13);\n ", ";\n\n @media only screen and ", " {\n left: auto;\n transform: none;\n right: ", " !important;\n }\n"], ["\n position: absolute;\n max-width: ", ";\n width: calc(100vw - 4.5rem);\n padding: ", ";\n border-radius: 0.5rem;\n background-color: var(--primary-opacity-10);\n z-index: 99999;\n box-sizing: border-box;\n user-select: none;\n pointer-events: none;\n transition: all 0.15s ease;\n opacity: ", ";\n font:var(--caption-medium-11-13);\n ", ";\n\n @media only screen and ", " {\n left: auto;\n transform: none;\n right: ", " !important;\n }\n"])), function (props) { return props.$popupWidth ? props.$popupWidth : "151px"; }, function (props) {
35
+ exports.Popup = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n max-width: ", ";\n width: calc(100vw - 4.5rem);\n padding: ", ";\n border-radius: 0.5rem;\n background-color: var(--primary-opacity-10);\n z-index: 99999;\n box-sizing: border-box;\n user-select: none;\n pointer-events: none;\n transition: all 0.15s ease;\n opacity: ", ";\n ", "\n font:var(--caption-medium-11-13);\n ", ";\n\n @media only screen and ", " {\n left: auto;\n transform: none;\n right: ", " !important;\n }\n"], ["\n position: absolute;\n max-width: ", ";\n width: calc(100vw - 4.5rem);\n padding: ", ";\n border-radius: 0.5rem;\n background-color: var(--primary-opacity-10);\n z-index: 99999;\n box-sizing: border-box;\n user-select: none;\n pointer-events: none;\n transition: all 0.15s ease;\n opacity: ", ";\n ", "\n font:var(--caption-medium-11-13);\n ", ";\n\n @media only screen and ", " {\n left: auto;\n transform: none;\n right: ", " !important;\n }\n"])), function (props) { return props.$popupWidth ? props.$popupWidth : "151px"; }, function (props) {
36
36
  switch (props.$popupSize) {
37
37
  case 'small':
38
38
  return "10px";
@@ -41,7 +41,7 @@ exports.Popup = styled_components_1.default.div(templateObject_6 || (templateObj
41
41
  default:
42
42
  return "10px";
43
43
  }
44
- }, function (props) { return (props.$hasClickAction && props.$isOpen) ? '1' : "0"; }, function (props) {
44
+ }, function (props) { return (props.$hasClickAction && props.$isOpen) ? '1' : "0"; }, function (props) { return (!props.$hasClickAction && props.$isOpen) ? 'opacity: 1;' : ''; }, function (props) {
45
45
  switch (props.$position) {
46
46
  case 'bottomRight':
47
47
  return "\n right: ".concat(props.$popupRight || '-22px', ";\n top: calc(100% + 10px);\n ");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,152 @@
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 Tooltip_1 = __importDefault(require("./Tooltip"));
57
+ var label = '1234 ile biten kart hakkında bilgi';
58
+ var renderTooltip = function (props) {
59
+ if (props === void 0) { props = {}; }
60
+ return (0, react_1.render)((0, jsx_runtime_1.jsx)(Tooltip_1.default, __assign({ hasClickAction: true, selectorAriaLabel: label }, props, { children: "Kart bilgisi" })));
61
+ };
62
+ describe('Tooltip accessibility', function () {
63
+ it('renders a named focusable button connected to the tooltip', function () { return __awaiter(void 0, void 0, void 0, function () {
64
+ var user, trigger;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ user = user_event_1.default.setup();
69
+ renderTooltip();
70
+ return [4 /*yield*/, user.tab()];
71
+ case 1:
72
+ _a.sent();
73
+ trigger = react_1.screen.getByRole('button', { name: label });
74
+ expect(trigger).toHaveFocus();
75
+ expect(trigger).toHaveAttribute('type', 'button');
76
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
77
+ expect(react_1.screen.getByRole('tooltip', { hidden: true })).toHaveAttribute('id', trigger.getAttribute('aria-describedby'));
78
+ return [2 /*return*/];
79
+ }
80
+ });
81
+ }); });
82
+ it.each(['Enter', ' '])('toggles with %s', function (key) { return __awaiter(void 0, void 0, void 0, function () {
83
+ var user, trigger;
84
+ return __generator(this, function (_a) {
85
+ switch (_a.label) {
86
+ case 0:
87
+ user = user_event_1.default.setup();
88
+ renderTooltip();
89
+ trigger = react_1.screen.getByRole('button', { name: label });
90
+ trigger.focus();
91
+ return [4 /*yield*/, user.keyboard(key === ' ' ? '[Space]' : "[".concat(key, "]"))];
92
+ case 1:
93
+ _a.sent();
94
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
95
+ expect(react_1.screen.getByRole('tooltip')).toBeVisible();
96
+ return [2 /*return*/];
97
+ }
98
+ });
99
+ }); });
100
+ it('closes with Escape and keeps focus on the trigger', function () { return __awaiter(void 0, void 0, void 0, function () {
101
+ var user, trigger;
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0:
105
+ user = user_event_1.default.setup();
106
+ renderTooltip({ isOpen: true });
107
+ trigger = react_1.screen.getByRole('button', { name: label });
108
+ trigger.focus();
109
+ return [4 /*yield*/, user.keyboard('[Escape]')];
110
+ case 1:
111
+ _a.sent();
112
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
113
+ expect(trigger).toHaveFocus();
114
+ expect(react_1.screen.getByRole('tooltip', { hidden: true })).not.toBeVisible();
115
+ return [2 /*return*/];
116
+ }
117
+ });
118
+ }); });
119
+ it('opens on focus and closes on blur in hover mode', function () { return __awaiter(void 0, void 0, void 0, function () {
120
+ var user;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0:
124
+ user = user_event_1.default.setup();
125
+ (0, react_1.render)((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Tooltip_1.default, __assign({ selectorAriaLabel: label }, { children: "Kart bilgisi" })), (0, jsx_runtime_1.jsx)("button", { children: "Next" })] }));
126
+ return [4 /*yield*/, user.tab()];
127
+ case 1:
128
+ _a.sent();
129
+ expect(react_1.screen.getByRole('tooltip')).toBeVisible();
130
+ return [4 /*yield*/, user.tab()];
131
+ case 2:
132
+ _a.sent();
133
+ expect(react_1.screen.getByRole('tooltip', { hidden: true })).not.toBeVisible();
134
+ return [2 /*return*/];
135
+ }
136
+ });
137
+ }); });
138
+ it('keeps its icon decorative', function () {
139
+ var _a;
140
+ renderTooltip();
141
+ var trigger = react_1.screen.getByRole('button', { name: label });
142
+ expect((_a = trigger.querySelector('svg')) === null || _a === void 0 ? void 0 : _a.closest('[aria-hidden="true"]')).toBeInTheDocument();
143
+ });
144
+ it('uses unique stable popup IDs', function () {
145
+ var rerender = (0, react_1.render)((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Tooltip_1.default, __assign({ selectorAriaLabel: "First" }, { children: "First info" })), (0, jsx_runtime_1.jsx)(Tooltip_1.default, __assign({ selectorAriaLabel: "Second" }, { children: "Second info" }))] })).rerender;
146
+ var firstId = react_1.screen.getByRole('button', { name: 'First' }).getAttribute('aria-describedby');
147
+ var secondId = react_1.screen.getByRole('button', { name: 'Second' }).getAttribute('aria-describedby');
148
+ expect(firstId).not.toBe(secondId);
149
+ rerender((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Tooltip_1.default, __assign({ selectorAriaLabel: "First" }, { children: "First info" })), (0, jsx_runtime_1.jsx)(Tooltip_1.default, __assign({ selectorAriaLabel: "Second" }, { children: "Second info" }))] }));
150
+ expect(react_1.screen.getByRole('button', { name: 'First' })).toHaveAttribute('aria-describedby', firstId);
151
+ });
152
+ });
@@ -19,6 +19,7 @@ export interface Tooltip {
19
19
  popupRightSm?: string;
20
20
  id?: string;
21
21
  selectorTitle?: React.ReactNode;
22
+ selectorAriaLabel?: string;
22
23
  }
23
24
  export interface TooltipStyledProps {
24
25
  $iconWidth?: string;
@@ -19,4 +19,5 @@ exports.TooltipDefault = {
19
19
  popupRightSm: "",
20
20
  id: "",
21
21
  selectorTitle: "",
22
+ selectorAriaLabel: "More information",
22
23
  };