@plasmicpkgs/react-aria 0.0.118 → 0.0.119

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 (92) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contexts.d.ts +2 -1
  3. package/dist/react-aria.esm.js +13 -4
  4. package/dist/react-aria.esm.js.map +1 -1
  5. package/dist/react-aria.js +13 -4
  6. package/dist/react-aria.js.map +1 -1
  7. package/dist/utils.d.ts +5 -4
  8. package/package.json +2 -2
  9. package/skinny/contexts-5cb81c2f.esm.js.map +1 -1
  10. package/skinny/contexts-6d0cb2b1.cjs.js.map +1 -1
  11. package/skinny/contexts.d.ts +2 -1
  12. package/skinny/registerComboBox.esm.js +1 -1
  13. package/skinny/registerInput.cjs.js +1 -1
  14. package/skinny/registerInput.cjs.js.map +1 -1
  15. package/skinny/registerInput.esm.js +2 -2
  16. package/skinny/registerInput.esm.js.map +1 -1
  17. package/skinny/{registerListBox-21dc99fa.esm.js → registerListBox-0f6ebcf0.esm.js} +2 -2
  18. package/skinny/{registerListBox-21dc99fa.esm.js.map → registerListBox-0f6ebcf0.esm.js.map} +1 -1
  19. package/skinny/registerListBox.esm.js +1 -1
  20. package/skinny/registerSection.esm.js +1 -1
  21. package/skinny/registerSelect.esm.js +1 -1
  22. package/skinny/registerTextArea.cjs.js +5 -2
  23. package/skinny/registerTextArea.cjs.js.map +1 -1
  24. package/skinny/registerTextArea.esm.js +6 -3
  25. package/skinny/registerTextArea.esm.js.map +1 -1
  26. package/skinny/registerTextField.cjs.js +8 -2
  27. package/skinny/registerTextField.cjs.js.map +1 -1
  28. package/skinny/registerTextField.esm.js +8 -2
  29. package/skinny/registerTextField.esm.js.map +1 -1
  30. package/skinny/utils-fc1ddd7c.cjs.js.map +1 -1
  31. package/skinny/utils-fd88ad47.esm.js.map +1 -1
  32. package/skinny/utils.d.ts +5 -4
  33. package/skinny/registerButton.stories.cjs.js +0 -163
  34. package/skinny/registerButton.stories.cjs.js.map +0 -1
  35. package/skinny/registerButton.stories.esm.js +0 -149
  36. package/skinny/registerButton.stories.esm.js.map +0 -1
  37. package/skinny/registerCheckboxGroup.stories.cjs.js +0 -121
  38. package/skinny/registerCheckboxGroup.stories.cjs.js.map +0 -1
  39. package/skinny/registerCheckboxGroup.stories.esm.js +0 -109
  40. package/skinny/registerCheckboxGroup.stories.esm.js.map +0 -1
  41. package/skinny/registerComboBox.stories.cjs.js +0 -244
  42. package/skinny/registerComboBox.stories.cjs.js.map +0 -1
  43. package/skinny/registerComboBox.stories.esm.js +0 -230
  44. package/skinny/registerComboBox.stories.esm.js.map +0 -1
  45. package/skinny/registerDialogTrigger.stories.cjs.js +0 -458
  46. package/skinny/registerDialogTrigger.stories.cjs.js.map +0 -1
  47. package/skinny/registerDialogTrigger.stories.esm.js +0 -441
  48. package/skinny/registerDialogTrigger.stories.esm.js.map +0 -1
  49. package/skinny/registerListbox.stories.cjs.js +0 -219
  50. package/skinny/registerListbox.stories.cjs.js.map +0 -1
  51. package/skinny/registerListbox.stories.esm.js +0 -206
  52. package/skinny/registerListbox.stories.esm.js.map +0 -1
  53. package/skinny/registerModal.stories.cjs.js +0 -194
  54. package/skinny/registerModal.stories.cjs.js.map +0 -1
  55. package/skinny/registerModal.stories.esm.js +0 -181
  56. package/skinny/registerModal.stories.esm.js.map +0 -1
  57. package/skinny/registerPopover.stories.cjs.js +0 -102
  58. package/skinny/registerPopover.stories.cjs.js.map +0 -1
  59. package/skinny/registerPopover.stories.esm.js +0 -92
  60. package/skinny/registerPopover.stories.esm.js.map +0 -1
  61. package/skinny/registerRadioGroup.stories.cjs.js +0 -120
  62. package/skinny/registerRadioGroup.stories.cjs.js.map +0 -1
  63. package/skinny/registerRadioGroup.stories.esm.js +0 -108
  64. package/skinny/registerRadioGroup.stories.esm.js.map +0 -1
  65. package/skinny/registerSelect.stories.cjs.js +0 -215
  66. package/skinny/registerSelect.stories.cjs.js.map +0 -1
  67. package/skinny/registerSelect.stories.esm.js +0 -202
  68. package/skinny/registerSelect.stories.esm.js.map +0 -1
  69. package/skinny/registerSlider.stories.cjs.js +0 -165
  70. package/skinny/registerSlider.stories.cjs.js.map +0 -1
  71. package/skinny/registerSlider.stories.esm.js +0 -151
  72. package/skinny/registerSlider.stories.esm.js.map +0 -1
  73. package/skinny/registerSwitch.stories.cjs.js +0 -162
  74. package/skinny/registerSwitch.stories.cjs.js.map +0 -1
  75. package/skinny/registerSwitch.stories.esm.js +0 -148
  76. package/skinny/registerSwitch.stories.esm.js.map +0 -1
  77. package/skinny/registerTextField-common-stories.cjs.js +0 -199
  78. package/skinny/registerTextField-common-stories.cjs.js.map +0 -1
  79. package/skinny/registerTextField-common-stories.esm.js +0 -185
  80. package/skinny/registerTextField-common-stories.esm.js.map +0 -1
  81. package/skinny/registerTextField-input.stories.cjs.js +0 -54
  82. package/skinny/registerTextField-input.stories.cjs.js.map +0 -1
  83. package/skinny/registerTextField-input.stories.esm.js +0 -37
  84. package/skinny/registerTextField-input.stories.esm.js.map +0 -1
  85. package/skinny/registerTextField-textarea.stories.cjs.js +0 -55
  86. package/skinny/registerTextField-textarea.stories.cjs.js.map +0 -1
  87. package/skinny/registerTextField-textarea.stories.esm.js +0 -39
  88. package/skinny/registerTextField-textarea.stories.esm.js.map +0 -1
  89. package/skinny/registerTooltip.stories.cjs.js +0 -616
  90. package/skinny/registerTooltip.stories.cjs.js.map +0 -1
  91. package/skinny/registerTooltip.stories.esm.js +0 -596
  92. package/skinny/registerTooltip.stories.esm.js.map +0 -1
@@ -1,596 +0,0 @@
1
- import { PlasmicCanvasContext } from '@plasmicapp/host';
2
- import { fn, within, expect, waitFor, userEvent } from '@storybook/test';
3
- import React, { useState } from 'react';
4
- import { BaseButton } from './registerButton.esm.js';
5
- import { BaseTooltip } from './registerTooltip.esm.js';
6
- import 'react-aria';
7
- import 'react-aria-components';
8
- import './common-616eb178.esm.js';
9
- import './utils-fd88ad47.esm.js';
10
- import '@plasmicapp/host/registerComponent';
11
- import './variant-utils-4405ebb0.esm.js';
12
- import 'react-stately';
13
-
14
- var __defProp = Object.defineProperty;
15
- var __defProps = Object.defineProperties;
16
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
17
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
18
- var __hasOwnProp = Object.prototype.hasOwnProperty;
19
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
20
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21
- var __spreadValues = (a, b) => {
22
- for (var prop in b || (b = {}))
23
- if (__hasOwnProp.call(b, prop))
24
- __defNormalProp(a, prop, b[prop]);
25
- if (__getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(b)) {
27
- if (__propIsEnum.call(b, prop))
28
- __defNormalProp(a, prop, b[prop]);
29
- }
30
- return a;
31
- };
32
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
33
- var __objRest = (source, exclude) => {
34
- var target = {};
35
- for (var prop in source)
36
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
37
- target[prop] = source[prop];
38
- if (source != null && __getOwnPropSymbols)
39
- for (var prop of __getOwnPropSymbols(source)) {
40
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
41
- target[prop] = source[prop];
42
- }
43
- return target;
44
- };
45
- const meta = {
46
- title: "Components/BaseTooltip",
47
- component: BaseTooltip,
48
- args: {
49
- onOpenChange: fn(),
50
- children: /* @__PURE__ */ React.createElement("span", null, "Show tooltip"),
51
- // anything can be used as a trigger
52
- tooltipContent: /* @__PURE__ */ React.createElement("div", { "data-testid": "tooltip-content" }, "This is a tooltip"),
53
- trigger: void 0,
54
- // means that it triggers on both focus and hover
55
- delay: 0,
56
- closeDelay: 0
57
- }
58
- };
59
- const Basic = {
60
- play: async ({ canvasElement, args }) => {
61
- const canvas = within(canvasElement);
62
- const trigger = canvas.getByText("Show tooltip");
63
- await waitFor(
64
- () => expect(
65
- within(document.body).queryByTestId("tooltip-content")
66
- ).not.toBeInTheDocument()
67
- );
68
- await userEvent.hover(trigger);
69
- await waitFor(() => {
70
- var _a, _b;
71
- const tooltip = within(document.body).getByTestId("tooltip-content");
72
- const tooltipId = (_a = tooltip.parentElement) == null ? void 0 : _a.getAttribute("id");
73
- expect(tooltipId).toBeDefined();
74
- expect((_b = trigger.parentElement) == null ? void 0 : _b.getAttribute("aria-describedby")).toEqual(
75
- tooltipId
76
- );
77
- });
78
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
79
- await userEvent.unhover(trigger);
80
- await waitFor(() => expect(args.onOpenChange).toHaveBeenCalledWith(false));
81
- expect(args.onOpenChange).toHaveBeenCalledTimes(2);
82
- await userEvent.tab();
83
- await expect(trigger).not.toHaveFocus();
84
- expect(args.onOpenChange).toHaveBeenCalledTimes(2);
85
- }
86
- };
87
- const AlwaysOpen = {
88
- args: {
89
- isOpen: true
90
- // Force tooltip to be open
91
- },
92
- play: async () => {
93
- await waitFor(
94
- () => expect(
95
- within(document.body).queryByTestId("tooltip-content")
96
- ).toBeInTheDocument()
97
- );
98
- }
99
- };
100
- const FocusTrigger = {
101
- args: {
102
- // TabIndex=0 makes it focusable
103
- children: /* @__PURE__ */ React.createElement("span", { tabIndex: 0 }, "Show tooltip")
104
- // anything can be used as a trigger
105
- },
106
- play: async ({ canvasElement, args }) => {
107
- const canvas = within(canvasElement);
108
- const trigger = canvas.getByText("Show tooltip");
109
- await waitFor(
110
- () => expect(
111
- within(document.body).queryByTestId("tooltip-content")
112
- ).not.toBeInTheDocument()
113
- );
114
- await userEvent.tab();
115
- await expect(trigger).toHaveFocus();
116
- await waitFor(
117
- () => expect(
118
- within(document.body).queryByTestId("tooltip-content")
119
- ).toBeInTheDocument()
120
- );
121
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
122
- await userEvent.tab();
123
- await expect(trigger).not.toHaveFocus();
124
- await waitFor(() => expect(args.onOpenChange).toHaveBeenCalledWith(false));
125
- }
126
- };
127
- const CustomButton = (_a) => {
128
- var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
129
- return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, props), { "data-testid": "trigger-wrapper" }), /* @__PURE__ */ React.createElement("span", { tabIndex: 0 }, children), /* @__PURE__ */ React.createElement("span", { tabIndex: 0 }, children));
130
- };
131
- const WithoutForwardRefTrigger = {
132
- args: {
133
- children: /* @__PURE__ */ React.createElement(CustomButton, null, "Show tooltip")
134
- },
135
- play: async ({ args, canvasElement }) => {
136
- const canvas = within(canvasElement);
137
- const triggerWrapper = canvas.getByTestId("trigger-wrapper");
138
- const innerFocusableButtons = canvas.getAllByText("Show tooltip");
139
- await waitFor(
140
- () => expect(
141
- within(document.body).queryByTestId("tooltip-content")
142
- ).not.toBeInTheDocument()
143
- );
144
- await expect(innerFocusableButtons[0]).not.toHaveFocus();
145
- await userEvent.tab();
146
- expect(innerFocusableButtons[0]).toHaveFocus();
147
- await waitFor(
148
- () => expect(
149
- within(document.body).queryByTestId("tooltip-content")
150
- ).toBeInTheDocument()
151
- );
152
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
153
- await userEvent.tab();
154
- expect(innerFocusableButtons[0]).not.toHaveFocus();
155
- expect(innerFocusableButtons[1]).toHaveFocus();
156
- await waitFor(
157
- () => expect(
158
- within(document.body).queryByTestId("tooltip-content")
159
- ).toBeInTheDocument()
160
- );
161
- await userEvent.tab();
162
- expect(innerFocusableButtons[1]).not.toHaveFocus();
163
- expect(args.onOpenChange).toHaveBeenCalledWith(false);
164
- await waitFor(
165
- () => expect(
166
- within(document.body).queryByTestId("tooltip-content")
167
- ).not.toBeInTheDocument()
168
- );
169
- await userEvent.hover(triggerWrapper);
170
- await waitFor(
171
- () => expect(
172
- within(document.body).queryByTestId("tooltip-content")
173
- ).toBeInTheDocument()
174
- );
175
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
176
- await userEvent.unhover(triggerWrapper);
177
- await waitFor(
178
- () => expect(
179
- within(document.body).queryByTestId("tooltip-content")
180
- ).not.toBeInTheDocument()
181
- );
182
- await waitFor(() => expect(args.onOpenChange).toHaveBeenCalledWith(false));
183
- }
184
- };
185
- const FocusTriggerOnly = {
186
- args: {
187
- trigger: "focus",
188
- children: /* @__PURE__ */ React.createElement("span", { tabIndex: 0 }, "Show tooltip")
189
- // anything can be used as a trigger
190
- },
191
- play: async ({ args, canvasElement }) => {
192
- const canvas = within(canvasElement);
193
- const trigger = canvas.getByText("Show tooltip");
194
- await waitFor(
195
- () => expect(
196
- within(document.body).queryByTestId("tooltip-content")
197
- ).not.toBeInTheDocument()
198
- );
199
- await userEvent.hover(trigger);
200
- await waitFor(
201
- () => expect(
202
- within(document.body).queryByTestId("tooltip-content")
203
- ).not.toBeInTheDocument()
204
- );
205
- expect(args.onOpenChange).not.toHaveBeenCalled();
206
- await userEvent.unhover(trigger);
207
- await userEvent.tab();
208
- await expect(trigger).toHaveFocus();
209
- await waitFor(
210
- () => expect(
211
- within(document.body).queryByTestId("tooltip-content")
212
- ).toBeInTheDocument()
213
- );
214
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
215
- await userEvent.tab();
216
- await waitFor(() => expect(args.onOpenChange).toHaveBeenCalledWith(false));
217
- }
218
- };
219
- const TriggerWithEventHandlers = {
220
- parameters: {
221
- customOnFocus: fn()
222
- },
223
- render: (args, { parameters }) => /* @__PURE__ */ React.createElement(BaseTooltip, __spreadValues({}, args), /* @__PURE__ */ React.createElement("button", { className: "custom-class", onFocus: parameters.customOnFocus }, "Show tooltip")),
224
- play: async ({ args, canvasElement, parameters }) => {
225
- const canvas = within(canvasElement);
226
- const trigger = canvas.getByText("Show tooltip");
227
- await expect(trigger).toHaveClass("custom-class");
228
- await waitFor(
229
- () => expect(
230
- within(document.body).queryByTestId("tooltip-content")
231
- ).not.toBeInTheDocument()
232
- );
233
- expect(parameters.customOnFocus).not.toHaveBeenCalled();
234
- await userEvent.tab();
235
- await expect(trigger).toHaveFocus();
236
- await waitFor(
237
- () => expect(
238
- within(document.body).queryByTestId("tooltip-content")
239
- ).toBeInTheDocument()
240
- );
241
- expect(parameters.customOnFocus).toHaveBeenCalled();
242
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
243
- await userEvent.tab();
244
- await waitFor(() => expect(args.onOpenChange).toHaveBeenCalledWith(false));
245
- }
246
- };
247
- const Disabled = {
248
- args: {
249
- isDisabled: true
250
- },
251
- play: async ({ args, canvasElement }) => {
252
- const canvas = within(canvasElement);
253
- const trigger = canvas.getByText("Show tooltip");
254
- await waitFor(
255
- () => expect(
256
- within(document.body).queryByTestId("tooltip-content")
257
- ).not.toBeInTheDocument()
258
- );
259
- await userEvent.tab();
260
- await waitFor(
261
- () => expect(
262
- within(document.body).queryByTestId("tooltip-content")
263
- ).not.toBeInTheDocument()
264
- );
265
- expect(args.onOpenChange).not.toHaveBeenCalled();
266
- await userEvent.hover(trigger);
267
- }
268
- };
269
- const Controlled = {
270
- render: (_c) => {
271
- var _d = _c, { isOpen: _isOpen, onOpenChange } = _d, args = __objRest(_d, ["isOpen", "onOpenChange"]);
272
- const [open, setOpen] = useState(false);
273
- return /* @__PURE__ */ React.createElement(
274
- BaseTooltip,
275
- __spreadProps(__spreadValues({}, args), {
276
- isOpen: open,
277
- onOpenChange: (newVal) => {
278
- setOpen(newVal);
279
- onOpenChange == null ? void 0 : onOpenChange(newVal);
280
- }
281
- })
282
- );
283
- },
284
- play: async ({ canvasElement }) => {
285
- const canvas = within(canvasElement);
286
- const trigger = canvas.getByText("Show tooltip");
287
- await waitFor(
288
- () => expect(
289
- within(document.body).queryByTestId("tooltip-content")
290
- ).not.toBeInTheDocument()
291
- );
292
- await userEvent.hover(trigger);
293
- await waitFor(
294
- () => expect(
295
- within(document.body).queryByTestId("tooltip-content")
296
- ).toBeInTheDocument()
297
- );
298
- await userEvent.unhover(trigger);
299
- await waitFor(
300
- () => expect(
301
- within(document.body).queryByTestId("tooltip-content")
302
- ).not.toBeInTheDocument()
303
- );
304
- }
305
- };
306
- const AriaButtonTrigger = {
307
- args: {
308
- children: /* @__PURE__ */ React.createElement(BaseButton, null, "Show tooltip")
309
- // anything can be used as a trigger
310
- },
311
- play: async ({ args, canvasElement }) => {
312
- const canvas = within(canvasElement);
313
- const trigger = canvas.getByText("Show tooltip");
314
- await waitFor(
315
- () => expect(
316
- within(document.body).queryByTestId("tooltip-content")
317
- ).not.toBeInTheDocument()
318
- );
319
- await userEvent.hover(trigger);
320
- await waitFor(
321
- () => expect(
322
- within(document.body).queryByTestId("tooltip-content")
323
- ).toBeInTheDocument()
324
- );
325
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
326
- expect(args.onOpenChange).toHaveBeenCalledTimes(1);
327
- await userEvent.unhover(trigger);
328
- await waitFor(
329
- () => expect(
330
- within(document.body).queryByTestId("tooltip-content")
331
- ).not.toBeInTheDocument()
332
- );
333
- expect(args.onOpenChange).toHaveBeenCalledWith(false);
334
- expect(args.onOpenChange).toHaveBeenCalledTimes(2);
335
- await expect(trigger).not.toHaveFocus();
336
- await userEvent.tab();
337
- expect(trigger).toHaveFocus();
338
- await waitFor(
339
- () => expect(
340
- within(document.body).queryByTestId("tooltip-content")
341
- ).toBeInTheDocument()
342
- );
343
- expect(args.onOpenChange).toHaveBeenCalledWith(true);
344
- expect(args.onOpenChange).toHaveBeenCalledTimes(3);
345
- await userEvent.tab();
346
- await expect(canvas.getByText("Show tooltip")).not.toHaveFocus();
347
- await waitFor(
348
- () => expect(
349
- within(document.body).queryByTestId("tooltip-content")
350
- ).not.toBeInTheDocument()
351
- );
352
- await waitFor(() => expect(args.onOpenChange).toHaveBeenCalledWith(false));
353
- expect(args.onOpenChange).toHaveBeenCalledTimes(4);
354
- }
355
- };
356
- const SelectedInCanvas = {
357
- render: (_e) => {
358
- var _f = _e, args = __objRest(_f, ["__plasmic_selection_prop__"]);
359
- const [selected, setSelected] = useState(false);
360
- const [selectedSlotName, setSelectedSlotName] = useState("");
361
- return (
362
- // Simulate Plasmic canvas envirnment
363
- /* @__PURE__ */ React.createElement(
364
- PlasmicCanvasContext.Provider,
365
- {
366
- value: {
367
- componentName: "test",
368
- globalVariants: {}
369
- }
370
- },
371
- /* @__PURE__ */ React.createElement(
372
- "style",
373
- {
374
- dangerouslySetInnerHTML: {
375
- __html: `
376
- .trigger {
377
- display: inline-block;
378
- }
379
- `
380
- }
381
- }
382
- ),
383
- /* @__PURE__ */ React.createElement(
384
- BaseTooltip,
385
- __spreadProps(__spreadValues({}, args), {
386
- __plasmic_selection_prop__: {
387
- isSelected: selected,
388
- selectedSlotName
389
- },
390
- className: "trigger"
391
- })
392
- ),
393
- /* @__PURE__ */ React.createElement("button", { onClick: () => setSelected((prev) => !prev) }, "Toggle selection"),
394
- /* @__PURE__ */ React.createElement("button", { onClick: () => setSelectedSlotName("children") }, "Select trigger"),
395
- /* @__PURE__ */ React.createElement("button", { onClick: () => setSelectedSlotName("some other slot") }, "Select other slot")
396
- )
397
- );
398
- },
399
- play: async ({ canvasElement }) => {
400
- const canvas = within(canvasElement);
401
- const toggleSelectionBtn = canvas.getByText("Toggle selection");
402
- const triggerSelectionBtn = canvas.getByText("Select trigger");
403
- const otherSlotSelectionBtn = canvas.getByText("Select other slot");
404
- await waitFor(
405
- () => expect(
406
- within(document.body).queryByTestId("tooltip-content")
407
- ).not.toBeInTheDocument()
408
- );
409
- await userEvent.click(toggleSelectionBtn);
410
- await waitFor(
411
- () => expect(
412
- within(document.body).queryByTestId("tooltip-content")
413
- ).toBeInTheDocument()
414
- );
415
- await userEvent.click(triggerSelectionBtn);
416
- await waitFor(
417
- () => expect(
418
- within(document.body).queryByTestId("tooltip-content")
419
- ).not.toBeInTheDocument()
420
- );
421
- await userEvent.click(otherSlotSelectionBtn);
422
- await waitFor(
423
- () => expect(
424
- within(document.body).queryByTestId("tooltip-content")
425
- ).toBeInTheDocument()
426
- );
427
- await userEvent.click(toggleSelectionBtn);
428
- await waitFor(
429
- () => expect(
430
- within(document.body).queryByTestId("tooltip-content")
431
- ).not.toBeInTheDocument(),
432
- { timeout: 1100 }
433
- );
434
- }
435
- };
436
- const TooltipPositionInCanvas = {
437
- render: (args) => {
438
- const [className, setClassName] = useState("trigger");
439
- const [selected, setSelected] = useState(false);
440
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
441
- "style",
442
- {
443
- dangerouslySetInnerHTML: {
444
- __html: `
445
- .trigger {
446
- display: inline-block;
447
- }
448
- .trigger-right {
449
- position: absolute;
450
- right: 0;
451
- }
452
- `
453
- }
454
- }
455
- ), /* @__PURE__ */ React.createElement(
456
- PlasmicCanvasContext.Provider,
457
- {
458
- value: {
459
- componentName: "test",
460
- globalVariants: {}
461
- }
462
- },
463
- /* @__PURE__ */ React.createElement("button", { onClick: () => setClassName("trigger trigger-right") }, "Move right"),
464
- /* @__PURE__ */ React.createElement("button", { onClick: () => setClassName("trigger") }, "Move back"),
465
- /* @__PURE__ */ React.createElement("button", { onClick: () => setSelected((prev) => !prev) }, "Toggle selection"),
466
- /* @__PURE__ */ React.createElement(
467
- BaseTooltip,
468
- __spreadProps(__spreadValues({}, args), {
469
- className,
470
- __plasmic_selection_prop__: {
471
- isSelected: selected
472
- }
473
- })
474
- )
475
- ));
476
- },
477
- play: async ({ canvasElement }) => {
478
- const canvas = within(canvasElement);
479
- const moveRightBtn = canvas.getByText("Move right");
480
- const moveBackBtn = canvas.getByText("Move back");
481
- const toggleSelectionBtn = canvas.getByText("Toggle selection");
482
- await waitFor(
483
- () => expect(
484
- within(document.body).queryByTestId("tooltip-content")
485
- ).not.toBeInTheDocument()
486
- );
487
- await userEvent.click(toggleSelectionBtn);
488
- const initialTooltipLeftPosition = await waitFor(() => {
489
- const tooltip = within(document.body).getByTestId("tooltip-content");
490
- return tooltip.getBoundingClientRect().left;
491
- });
492
- await userEvent.click(toggleSelectionBtn);
493
- await waitFor(
494
- () => expect(
495
- within(document.body).queryByTestId("tooltip-content")
496
- ).not.toBeInTheDocument()
497
- );
498
- await userEvent.click(moveRightBtn);
499
- await userEvent.click(toggleSelectionBtn);
500
- await waitFor(() => {
501
- const tooltip = within(document.body).getByTestId("tooltip-content");
502
- expect(initialTooltipLeftPosition).not.toEqual(
503
- tooltip.getBoundingClientRect().left
504
- );
505
- });
506
- await userEvent.click(toggleSelectionBtn);
507
- await waitFor(
508
- () => expect(
509
- within(document.body).queryByTestId("tooltip-content")
510
- ).not.toBeInTheDocument()
511
- );
512
- await userEvent.click(moveBackBtn);
513
- await userEvent.click(toggleSelectionBtn);
514
- await waitFor(() => {
515
- const tooltip = within(document.body).getByTestId("tooltip-content");
516
- expect(initialTooltipLeftPosition).toEqual(
517
- tooltip.getBoundingClientRect().left
518
- );
519
- });
520
- await userEvent.click(toggleSelectionBtn);
521
- await waitFor(
522
- () => expect(
523
- within(document.body).queryByTestId("tooltip-content")
524
- ).not.toBeInTheDocument()
525
- );
526
- }
527
- };
528
- const TooltipPositionInPreview = {
529
- render: (args) => {
530
- const [className, setClassName] = useState("trigger");
531
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
532
- "style",
533
- {
534
- dangerouslySetInnerHTML: {
535
- __html: `
536
- .trigger {
537
- display: inline-block;
538
- }
539
- .trigger-right {
540
- position: absolute;
541
- right: 0;
542
- }
543
- `
544
- }
545
- }
546
- ), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", { onClick: () => setClassName("trigger trigger-right") }, "Move right"), /* @__PURE__ */ React.createElement("button", { onClick: () => setClassName("trigger") }, "Move back"), /* @__PURE__ */ React.createElement(BaseTooltip, __spreadProps(__spreadValues({}, args), { className }))));
547
- },
548
- play: async ({ canvasElement }) => {
549
- const canvas = within(canvasElement);
550
- const trigger = canvas.getByText("Show tooltip");
551
- const moveRightBtn = canvas.getByText("Move right");
552
- const moveBackBtn = canvas.getByText("Move back");
553
- await userEvent.hover(trigger);
554
- const initialTooltipLeftPosition = await waitFor(() => {
555
- const tooltip = within(document.body).getByTestId("tooltip-content");
556
- return tooltip.getBoundingClientRect().left;
557
- });
558
- await userEvent.unhover(trigger);
559
- await waitFor(
560
- () => expect(
561
- within(document.body).queryByTestId("tooltip-content")
562
- ).not.toBeInTheDocument()
563
- );
564
- await userEvent.click(moveRightBtn);
565
- await userEvent.hover(trigger);
566
- await waitFor(() => {
567
- const tooltip = within(document.body).getByTestId("tooltip-content");
568
- expect(initialTooltipLeftPosition).not.toEqual(
569
- tooltip.getBoundingClientRect().left
570
- );
571
- });
572
- await userEvent.unhover(trigger);
573
- await waitFor(
574
- () => expect(
575
- within(document.body).queryByTestId("tooltip-content")
576
- ).not.toBeInTheDocument()
577
- );
578
- await userEvent.click(moveBackBtn);
579
- await userEvent.hover(trigger);
580
- await waitFor(() => {
581
- const tooltip = within(document.body).getByTestId("tooltip-content");
582
- expect(initialTooltipLeftPosition).toEqual(
583
- tooltip.getBoundingClientRect().left
584
- );
585
- });
586
- await userEvent.unhover(trigger);
587
- await waitFor(
588
- () => expect(
589
- within(document.body).queryByTestId("tooltip-content")
590
- ).not.toBeInTheDocument()
591
- );
592
- }
593
- };
594
-
595
- export { AlwaysOpen, AriaButtonTrigger, Basic, Controlled, Disabled, FocusTrigger, FocusTriggerOnly, SelectedInCanvas, TooltipPositionInCanvas, TooltipPositionInPreview, TriggerWithEventHandlers, WithoutForwardRefTrigger, meta as default };
596
- //# sourceMappingURL=registerTooltip.stories.esm.js.map