@webstudio-is/sdk-components-react-radix 0.167.0 → 0.173.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/components.js CHANGED
@@ -4,7 +4,10 @@ import {
4
4
  Children
5
5
  } from "react";
6
6
  import { Root, Trigger, Content } from "@radix-ui/react-collapsible";
7
- import { getClosestInstance } from "@webstudio-is/react-sdk";
7
+ import {
8
+ getClosestInstance,
9
+ getInstanceSelectorById
10
+ } from "@webstudio-is/react-sdk";
8
11
  import { jsx } from "react/jsx-runtime";
9
12
  var Collapsible = Root;
10
13
  var CollapsibleTrigger = forwardRef(({ children, ...props }, ref) => {
@@ -24,7 +27,8 @@ import {
24
27
  import * as DialogPrimitive from "@radix-ui/react-dialog";
25
28
  import {
26
29
  ReactSdkContext,
27
- getClosestInstance as getClosestInstance2
30
+ getClosestInstance as getClosestInstance2,
31
+ getInstanceSelectorById as getInstanceSelectorById2
28
32
  } from "@webstudio-is/react-sdk";
29
33
  import { jsx as jsx2 } from "react/jsx-runtime";
30
34
  var willNavigate = (event) => {
@@ -127,7 +131,10 @@ import {
127
131
  Children as Children3
128
132
  } from "react";
129
133
  import * as PopoverPrimitive from "@radix-ui/react-popover";
130
- import { getClosestInstance as getClosestInstance3 } from "@webstudio-is/react-sdk";
134
+ import {
135
+ getClosestInstance as getClosestInstance3,
136
+ getInstanceSelectorById as getInstanceSelectorById3
137
+ } from "@webstudio-is/react-sdk";
131
138
  import { jsx as jsx3 } from "react/jsx-runtime";
132
139
  var Popover = forwardRef3((props, _ref) => {
133
140
  return /* @__PURE__ */ jsx3(PopoverPrimitive.Root, { ...props });
@@ -151,7 +158,10 @@ var PopoverContent = forwardRef3(
151
158
 
152
159
  // src/tooltip.tsx
153
160
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
154
- import { getClosestInstance as getClosestInstance4 } from "@webstudio-is/react-sdk";
161
+ import {
162
+ getClosestInstance as getClosestInstance4,
163
+ getInstanceSelectorById as getInstanceSelectorById4
164
+ } from "@webstudio-is/react-sdk";
155
165
  import {
156
166
  forwardRef as forwardRef4,
157
167
  Children as Children4
@@ -181,7 +191,8 @@ import {
181
191
  import { Root as Root5, List, Trigger as Trigger5, Content as Content5 } from "@radix-ui/react-tabs";
182
192
  import {
183
193
  getClosestInstance as getClosestInstance5,
184
- getIndexWithinAncestorFromComponentProps
194
+ getIndexWithinAncestorFromComponentProps,
195
+ getInstanceSelectorById as getInstanceSelectorById5
185
196
  } from "@webstudio-is/react-sdk";
186
197
  import { jsx as jsx5 } from "react/jsx-runtime";
187
198
  var Tabs = Root5;
@@ -216,7 +227,8 @@ import {
216
227
  } from "@radix-ui/react-accordion";
217
228
  import {
218
229
  getClosestInstance as getClosestInstance6,
219
- getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps2
230
+ getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps2,
231
+ getInstanceSelectorById as getInstanceSelectorById6
220
232
  } from "@webstudio-is/react-sdk";
221
233
  import { jsx as jsx7 } from "react/jsx-runtime";
222
234
  var Accordion = forwardRef7((props, ref) => {
@@ -235,6 +247,7 @@ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
235
247
  import {
236
248
  getClosestInstance as getClosestInstance7,
237
249
  getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps3,
250
+ getInstanceSelectorById as getInstanceSelectorById7,
238
251
  ReactSdkContext as ReactSdkContext2
239
252
  } from "@webstudio-is/react-sdk";
240
253
  import {
@@ -269,7 +282,8 @@ var NavigationMenuTrigger = forwardRef8(({ children, ...props }, ref) => {
269
282
 
270
283
  // src/select.tsx
271
284
  import {
272
- forwardRef as forwardRef9
285
+ forwardRef as forwardRef9,
286
+ useContext as useContext3
273
287
  } from "react";
274
288
  import {
275
289
  Root as Root9,
@@ -282,12 +296,22 @@ import {
282
296
  Portal as Portal3,
283
297
  Viewport as Viewport2
284
298
  } from "@radix-ui/react-select";
285
- import { getClosestInstance as getClosestInstance8 } from "@webstudio-is/react-sdk";
299
+ import {
300
+ getClosestInstance as getClosestInstance8,
301
+ getInstanceSelectorById as getInstanceSelectorById8,
302
+ ReactSdkContext as ReactSdkContext3
303
+ } from "@webstudio-is/react-sdk";
286
304
  import { jsx as jsx9 } from "react/jsx-runtime";
287
305
  var Select = forwardRef9((props, _ref) => {
288
306
  return /* @__PURE__ */ jsx9(Root9, { ...props });
289
307
  });
290
- var SelectTrigger = Trigger8;
308
+ var SelectTrigger = forwardRef9((props, ref) => {
309
+ const { renderer } = useContext3(ReactSdkContext3);
310
+ const onPointerDown = renderer === "canvas" ? (event) => {
311
+ event.preventDefault();
312
+ } : void 0;
313
+ return /* @__PURE__ */ jsx9(Trigger8, { onPointerDown, ref, ...props });
314
+ });
291
315
  var SelectValue = forwardRef9((props, ref) => {
292
316
  return /* @__PURE__ */ jsx9(Value, { ref, ...props });
293
317
  });
package/lib/hooks.js CHANGED
@@ -4,7 +4,10 @@ import {
4
4
  Children
5
5
  } from "react";
6
6
  import { Root, Trigger, Content } from "@radix-ui/react-collapsible";
7
- import { getClosestInstance } from "@webstudio-is/react-sdk";
7
+ import {
8
+ getClosestInstance,
9
+ getInstanceSelectorById
10
+ } from "@webstudio-is/react-sdk";
8
11
  import { jsx } from "react/jsx-runtime";
9
12
  var CollapsibleTrigger = forwardRef(({ children, ...props }, ref) => {
10
13
  const firstChild = Children.toArray(children)[0];
@@ -21,7 +24,11 @@ var hooksCollapsible = {
21
24
  `${namespace}:Collapsible`
22
25
  );
23
26
  if (collapsible) {
24
- context.setPropVariable(collapsible.id, "open", true);
27
+ const instanceSelector = getInstanceSelectorById(
28
+ event.instanceSelector,
29
+ collapsible.id
30
+ );
31
+ context.setMemoryProp(instanceSelector, "open", true);
25
32
  }
26
33
  }
27
34
  }
@@ -35,7 +42,8 @@ import {
35
42
  import { Root as Root2, List, Trigger as Trigger2, Content as Content2 } from "@radix-ui/react-tabs";
36
43
  import {
37
44
  getClosestInstance as getClosestInstance2,
38
- getIndexWithinAncestorFromComponentProps
45
+ getIndexWithinAncestorFromComponentProps,
46
+ getInstanceSelectorById as getInstanceSelectorById2
39
47
  } from "@webstudio-is/react-sdk";
40
48
  import { jsx as jsx2 } from "react/jsx-runtime";
41
49
  var TabsTrigger = forwardRef2(({ value, ...props }, ref) => {
@@ -58,7 +66,11 @@ var hooksTabs = {
58
66
  );
59
67
  const contentValue = context.getPropValue(instance.id, "value") ?? context.indexesWithinAncestors.get(instance.id)?.toString();
60
68
  if (tabs && contentValue) {
61
- context.setPropVariable(tabs.id, "value", contentValue);
69
+ const instanceSelector = getInstanceSelectorById2(
70
+ event.instanceSelector,
71
+ tabs.id
72
+ );
73
+ context.setMemoryProp(instanceSelector, "value", contentValue);
62
74
  }
63
75
  }
64
76
  }
@@ -76,7 +88,8 @@ import {
76
88
  import * as DialogPrimitive from "@radix-ui/react-dialog";
77
89
  import {
78
90
  ReactSdkContext,
79
- getClosestInstance as getClosestInstance3
91
+ getClosestInstance as getClosestInstance3,
92
+ getInstanceSelectorById as getInstanceSelectorById3
80
93
  } from "@webstudio-is/react-sdk";
81
94
  import { jsx as jsx3 } from "react/jsx-runtime";
82
95
  var willNavigate = (event) => {
@@ -181,7 +194,11 @@ var hooksDialog = {
181
194
  `${namespace3}:Dialog`
182
195
  );
183
196
  if (dialog) {
184
- context.setPropVariable(dialog.id, "open", false);
197
+ const instanceSelector = getInstanceSelectorById3(
198
+ event.instanceSelector,
199
+ dialog.id
200
+ );
201
+ context.setMemoryProp(instanceSelector, "open", void 0);
185
202
  }
186
203
  }
187
204
  }
@@ -195,7 +212,11 @@ var hooksDialog = {
195
212
  `${namespace3}:Dialog`
196
213
  );
197
214
  if (dialog) {
198
- context.setPropVariable(dialog.id, "open", true);
215
+ const instanceSelector = getInstanceSelectorById3(
216
+ event.instanceSelector,
217
+ dialog.id
218
+ );
219
+ context.setMemoryProp(instanceSelector, "open", true);
199
220
  }
200
221
  }
201
222
  }
@@ -208,7 +229,10 @@ import {
208
229
  Children as Children3
209
230
  } from "react";
210
231
  import * as PopoverPrimitive from "@radix-ui/react-popover";
211
- import { getClosestInstance as getClosestInstance4 } from "@webstudio-is/react-sdk";
232
+ import {
233
+ getClosestInstance as getClosestInstance4,
234
+ getInstanceSelectorById as getInstanceSelectorById4
235
+ } from "@webstudio-is/react-sdk";
212
236
  import { jsx as jsx4 } from "react/jsx-runtime";
213
237
  var Popover = forwardRef4((props, _ref) => {
214
238
  return /* @__PURE__ */ jsx4(PopoverPrimitive.Root, { ...props });
@@ -240,7 +264,11 @@ var hooksPopover = {
240
264
  `${namespace4}:Popover`
241
265
  );
242
266
  if (popover) {
243
- context.setPropVariable(popover.id, "open", false);
267
+ const instanceSelector = getInstanceSelectorById4(
268
+ event.instanceSelector,
269
+ popover.id
270
+ );
271
+ context.setMemoryProp(instanceSelector, "open", void 0);
244
272
  }
245
273
  }
246
274
  }
@@ -254,7 +282,11 @@ var hooksPopover = {
254
282
  `${namespace4}:Popover`
255
283
  );
256
284
  if (popover) {
257
- context.setPropVariable(popover.id, "open", true);
285
+ const instanceSelector = getInstanceSelectorById4(
286
+ event.instanceSelector,
287
+ popover.id
288
+ );
289
+ context.setMemoryProp(instanceSelector, "open", true);
258
290
  }
259
291
  }
260
292
  }
@@ -265,7 +297,10 @@ var hooksPopover = {
265
297
  import {
266
298
  forwardRef as forwardRef5
267
299
  } from "react";
268
- import { getClosestInstance as getClosestInstance5 } from "@webstudio-is/react-sdk";
300
+ import {
301
+ getClosestInstance as getClosestInstance5,
302
+ getInstanceSelectorById as getInstanceSelectorById5
303
+ } from "@webstudio-is/react-sdk";
269
304
  import { jsx as jsx5 } from "react/jsx-runtime";
270
305
  var SheetContent = forwardRef5(
271
306
  ({ tag = "nav", side = "left", role = "navigation", children, ...props }, ref) => {
@@ -293,7 +328,11 @@ var hooksSheet = {
293
328
  `${namespace5}:Sheet`
294
329
  );
295
330
  if (sheet) {
296
- context.setPropVariable(sheet.id, "open", false);
331
+ const instanceSelector = getInstanceSelectorById5(
332
+ event.instanceSelector,
333
+ sheet.id
334
+ );
335
+ context.setMemoryProp(instanceSelector, "open", void 0);
297
336
  }
298
337
  }
299
338
  }
@@ -307,7 +346,11 @@ var hooksSheet = {
307
346
  `${namespace5}:Sheet`
308
347
  );
309
348
  if (sheet) {
310
- context.setPropVariable(sheet.id, "open", true);
349
+ const instanceSelector = getInstanceSelectorById5(
350
+ event.instanceSelector,
351
+ sheet.id
352
+ );
353
+ context.setMemoryProp(instanceSelector, "open", true);
311
354
  }
312
355
  }
313
356
  }
@@ -316,7 +359,10 @@ var hooksSheet = {
316
359
 
317
360
  // src/tooltip.tsx
318
361
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
319
- import { getClosestInstance as getClosestInstance6 } from "@webstudio-is/react-sdk";
362
+ import {
363
+ getClosestInstance as getClosestInstance6,
364
+ getInstanceSelectorById as getInstanceSelectorById6
365
+ } from "@webstudio-is/react-sdk";
320
366
  import {
321
367
  forwardRef as forwardRef6,
322
368
  Children as Children4
@@ -349,7 +395,11 @@ var hooksTooltip = {
349
395
  `${namespace6}:Tooltip`
350
396
  );
351
397
  if (tooltip) {
352
- context.setPropVariable(tooltip.id, "open", false);
398
+ const instanceSelector = getInstanceSelectorById6(
399
+ event.instanceSelector,
400
+ tooltip.id
401
+ );
402
+ context.setMemoryProp(instanceSelector, "open", void 0);
353
403
  }
354
404
  }
355
405
  }
@@ -363,7 +413,11 @@ var hooksTooltip = {
363
413
  `${namespace6}:Tooltip`
364
414
  );
365
415
  if (tooltip) {
366
- context.setPropVariable(tooltip.id, "open", true);
416
+ const instanceSelector = getInstanceSelectorById6(
417
+ event.instanceSelector,
418
+ tooltip.id
419
+ );
420
+ context.setMemoryProp(instanceSelector, "open", true);
367
421
  }
368
422
  }
369
423
  }
@@ -383,7 +437,8 @@ import {
383
437
  } from "@radix-ui/react-accordion";
384
438
  import {
385
439
  getClosestInstance as getClosestInstance7,
386
- getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps2
440
+ getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps2,
441
+ getInstanceSelectorById as getInstanceSelectorById7
387
442
  } from "@webstudio-is/react-sdk";
388
443
  import { jsx as jsx7 } from "react/jsx-runtime";
389
444
  var Accordion = forwardRef7((props, ref) => {
@@ -411,7 +466,11 @@ var hooksAccordion = {
411
466
  if (accordion && item) {
412
467
  const itemValue = context.getPropValue(item.id, "value") ?? context.indexesWithinAncestors.get(item.id)?.toString();
413
468
  if (itemValue) {
414
- context.setPropVariable(accordion.id, "value", itemValue);
469
+ const instanceSelector = getInstanceSelectorById7(
470
+ event.instanceSelector,
471
+ accordion.id
472
+ );
473
+ context.setMemoryProp(instanceSelector, "value", itemValue);
415
474
  }
416
475
  }
417
476
  }
@@ -424,6 +483,7 @@ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
424
483
  import {
425
484
  getClosestInstance as getClosestInstance8,
426
485
  getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps3,
486
+ getInstanceSelectorById as getInstanceSelectorById8,
427
487
  ReactSdkContext as ReactSdkContext2
428
488
  } from "@webstudio-is/react-sdk";
429
489
  import {
@@ -463,7 +523,11 @@ var hooksNavigationMenu = {
463
523
  `${namespace8}:NavigationMenu`
464
524
  );
465
525
  if (menu) {
466
- context.setPropVariable(menu.id, "value", "");
526
+ const menuSelector = getInstanceSelectorById8(
527
+ event.instanceSelector,
528
+ menu.id
529
+ );
530
+ context.setMemoryProp(menuSelector, "value", void 0);
467
531
  }
468
532
  }
469
533
  }
@@ -486,7 +550,11 @@ var hooksNavigationMenu = {
486
550
  }
487
551
  const contentValue = context.getPropValue(menuItem.id, "value") ?? context.indexesWithinAncestors.get(menuItem.id)?.toString();
488
552
  if (contentValue) {
489
- context.setPropVariable(menu.id, "value", contentValue);
553
+ const menuSelector = getInstanceSelectorById8(
554
+ event.instanceSelector,
555
+ menu.id
556
+ );
557
+ context.setMemoryProp(menuSelector, "value", contentValue);
490
558
  }
491
559
  }
492
560
  }
@@ -495,7 +563,8 @@ var hooksNavigationMenu = {
495
563
 
496
564
  // src/select.tsx
497
565
  import {
498
- forwardRef as forwardRef9
566
+ forwardRef as forwardRef9,
567
+ useContext as useContext3
499
568
  } from "react";
500
569
  import {
501
570
  Root as Root8,
@@ -508,11 +577,22 @@ import {
508
577
  Portal as Portal3,
509
578
  Viewport as Viewport2
510
579
  } from "@radix-ui/react-select";
511
- import { getClosestInstance as getClosestInstance9 } from "@webstudio-is/react-sdk";
580
+ import {
581
+ getClosestInstance as getClosestInstance9,
582
+ getInstanceSelectorById as getInstanceSelectorById9,
583
+ ReactSdkContext as ReactSdkContext3
584
+ } from "@webstudio-is/react-sdk";
512
585
  import { jsx as jsx9 } from "react/jsx-runtime";
513
586
  var Select = forwardRef9((props, _ref) => {
514
587
  return /* @__PURE__ */ jsx9(Root8, { ...props });
515
588
  });
589
+ var SelectTrigger = forwardRef9((props, ref) => {
590
+ const { renderer } = useContext3(ReactSdkContext3);
591
+ const onPointerDown = renderer === "canvas" ? (event) => {
592
+ event.preventDefault();
593
+ } : void 0;
594
+ return /* @__PURE__ */ jsx9(Trigger8, { onPointerDown, ref, ...props });
595
+ });
516
596
  var SelectValue = forwardRef9((props, ref) => {
517
597
  return /* @__PURE__ */ jsx9(Value, { ref, ...props });
518
598
  });
@@ -530,7 +610,11 @@ var hooksSelect = {
530
610
  `${namespace9}:Select`
531
611
  );
532
612
  if (select) {
533
- context.setPropVariable(select.id, "open", false);
613
+ const instanceSelector = getInstanceSelectorById9(
614
+ event.instanceSelector,
615
+ select.id
616
+ );
617
+ context.setMemoryProp(instanceSelector, "open", void 0);
534
618
  }
535
619
  }
536
620
  }
@@ -544,7 +628,11 @@ var hooksSelect = {
544
628
  `${namespace9}:Select`
545
629
  );
546
630
  if (select) {
547
- context.setPropVariable(select.id, "open", true);
631
+ const instanceSelector = getInstanceSelectorById9(
632
+ event.instanceSelector,
633
+ select.id
634
+ );
635
+ context.setMemoryProp(instanceSelector, "open", true);
548
636
  }
549
637
  }
550
638
  }