@plasmicpkgs/react-aria 0.0.95 → 0.0.96

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.
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState, useMemo, useCallback, forwardRef, useImperativeHandle, Component } from 'react';
2
2
  import { mergeProps, useFocusable } from 'react-aria';
3
- import { Button, Checkbox, Text, Label, CheckboxGroup, Input, ListBoxItem, ListBox, Section, Header, PopoverContext, Popover, Dialog, ComboBox, ComboBoxStateContext, Heading, ModalOverlay, Modal, DialogTrigger, TooltipContext, OverlayArrow, Radio, RadioGroup, Select, SelectStateContext, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextArea, TextField, TooltipTrigger, Tooltip } from 'react-aria-components';
3
+ import { Button, Checkbox, Text, Label, CheckboxGroup, Input, ListBoxItem, ListBox, Section, Header, PopoverContext, Popover, ComboBox, ComboBoxStateContext, Dialog, Heading, ModalOverlay, Modal, DialogTrigger, TooltipContext, OverlayArrow, Radio, RadioGroup, Select, SelectStateContext, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextArea, TextField, TooltipTrigger, Tooltip } from 'react-aria-components';
4
4
  import { usePlasmicCanvasContext, usePlasmicCanvasComponentInfo } from '@plasmicapp/host';
5
5
  import registerComponent from '@plasmicapp/host/registerComponent';
6
6
  import { mergeProps as mergeProps$1 } from '@react-aria/utils';
@@ -2150,8 +2150,6 @@ function BasePopover(props) {
2150
2150
  const triggerRef = React.useRef(null);
2151
2151
  const canvasContext = usePlasmicCanvasContext();
2152
2152
  const matchTriggerWidthProp = hasTrigger && matchTriggerWidth;
2153
- const dialogTriggerContext = React.useContext(PlasmicDialogTriggerContext);
2154
- const shouldTrapFocus = !canvasContext && !!dialogTriggerContext;
2155
2153
  const _b = mergeProps$1(
2156
2154
  {
2157
2155
  // isNonModal: Whether the popover is non-modal, i.e. elements outside the popover may be interacted with by assistive technologies.
@@ -2174,15 +2172,13 @@ function BasePopover(props) {
2174
2172
  canMatchTriggerWidth: hasTrigger
2175
2173
  });
2176
2174
  }, [hasTrigger, setControlContextData]);
2177
- const withoutDialog = /* @__PURE__ */ React.createElement("div", null, children);
2178
- const dialog = /* @__PURE__ */ React.createElement(Dialog, null, children);
2179
2175
  return /* @__PURE__ */ React.createElement(React.Fragment, null, isStandalone && /* @__PURE__ */ React.createElement("div", { ref: triggerRef }), /* @__PURE__ */ React.createElement(
2180
2176
  Popover,
2181
2177
  __spreadValues$g({
2182
2178
  style: __spreadValues$g(__spreadValues$g({}, matchTriggerWidthProp ? { width: `var(--trigger-width)` } : {}), COMMON_STYLES)
2183
2179
  }, mergedProps),
2184
2180
  ({ placement }) => withObservedValues$a(
2185
- shouldTrapFocus ? dialog : withoutDialog,
2181
+ children,
2186
2182
  {
2187
2183
  placementTop: placement === "top",
2188
2184
  placementBottom: placement === "bottom",
@@ -2488,6 +2484,36 @@ function registerComboBox(loader) {
2488
2484
  });
2489
2485
  }
2490
2486
 
2487
+ function BaseDialog({ children, className }) {
2488
+ const canvasContext = usePlasmicCanvasContext();
2489
+ if (canvasContext) {
2490
+ return /* @__PURE__ */ React.createElement("div", { className, style: COMMON_STYLES }, children);
2491
+ } else {
2492
+ return /* @__PURE__ */ React.createElement(Dialog, { className, style: COMMON_STYLES }, children);
2493
+ }
2494
+ }
2495
+ const DIALOG_COMPONENT_NAME = makeComponentName("dialog");
2496
+ function registerDialog(loader, overrides) {
2497
+ registerComponentHelper(
2498
+ loader,
2499
+ BaseDialog,
2500
+ {
2501
+ name: DIALOG_COMPONENT_NAME,
2502
+ displayName: "Aria Dialog",
2503
+ importPath: "@plasmicpkgs/react-aria/skinny/registerDialog",
2504
+ importName: "BaseDialog",
2505
+ props: {
2506
+ children: {
2507
+ type: "slot",
2508
+ mergeWithParent: true
2509
+ }
2510
+ },
2511
+ trapsFocus: true
2512
+ },
2513
+ overrides
2514
+ );
2515
+ }
2516
+
2491
2517
  var __defProp$e = Object.defineProperty;
2492
2518
  var __defProps$c = Object.defineProperties;
2493
2519
  var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
@@ -2639,18 +2665,47 @@ const BaseModal = forwardRef(
2639
2665
  (_a2 = mergedProps.onOpenChange) == null ? void 0 : _a2.call(mergedProps, true);
2640
2666
  }
2641
2667
  }));
2642
- const dialogInCanvas = /* @__PURE__ */ React.createElement("div", { style: COMMON_STYLES, className }, children);
2643
- const dialog = /* @__PURE__ */ React.createElement(Dialog, { style: COMMON_STYLES, className }, children);
2644
2668
  return /* @__PURE__ */ React.createElement(
2645
2669
  ModalOverlay,
2646
2670
  __spreadProps$b(__spreadValues$d({}, mergedProps), {
2647
2671
  className: `${resetClassName} ${modalOverlayClass}`
2648
2672
  }),
2649
- /* @__PURE__ */ React.createElement(Modal, null, canvasCtx ? dialogInCanvas : dialog)
2673
+ /* @__PURE__ */ React.createElement(Modal, { className }, children)
2650
2674
  );
2651
2675
  }
2652
2676
  );
2653
2677
  const MODAL_COMPONENT_NAME = makeComponentName("modal");
2678
+ const MODAL_DEFAULT_SLOT_CONTENT = {
2679
+ type: "vbox",
2680
+ styles: {
2681
+ width: "stretch",
2682
+ padding: 0,
2683
+ gap: "10px",
2684
+ justifyContent: "flex-start",
2685
+ alignItems: "flex-start"
2686
+ },
2687
+ children: [
2688
+ {
2689
+ type: "component",
2690
+ name: HEADING_COMPONENT_NAME
2691
+ },
2692
+ {
2693
+ type: "text",
2694
+ value: "This is a Modal!"
2695
+ },
2696
+ {
2697
+ type: "text",
2698
+ value: "You can put anything you can imagine here!",
2699
+ styles: {
2700
+ fontWeight: 500
2701
+ }
2702
+ },
2703
+ {
2704
+ type: "text",
2705
+ value: "Use it in a `Aria Dialog Trigger` component to trigger it on a button click!"
2706
+ }
2707
+ ]
2708
+ };
2654
2709
  function registerModal(loader, overrides) {
2655
2710
  registerComponentHelper(
2656
2711
  loader,
@@ -2689,37 +2744,7 @@ function registerModal(loader, overrides) {
2689
2744
  children: {
2690
2745
  type: "slot",
2691
2746
  mergeWithParent: true,
2692
- defaultValue: {
2693
- type: "vbox",
2694
- styles: {
2695
- width: "stretch",
2696
- padding: 0,
2697
- gap: "10px",
2698
- justifyContent: "flex-start",
2699
- alignItems: "flex-start"
2700
- },
2701
- children: [
2702
- {
2703
- type: "component",
2704
- name: HEADING_COMPONENT_NAME
2705
- },
2706
- {
2707
- type: "text",
2708
- value: "This is a Modal!"
2709
- },
2710
- {
2711
- type: "text",
2712
- value: "You can put anything you can imagine here!",
2713
- styles: {
2714
- fontWeight: 500
2715
- }
2716
- },
2717
- {
2718
- type: "text",
2719
- value: "Use it in a `Aria Dialog Trigger` component to trigger it on a button click!"
2720
- }
2721
- ]
2722
- }
2747
+ defaultValue: MODAL_DEFAULT_SLOT_CONTENT
2723
2748
  },
2724
2749
  modalOverlayClass: {
2725
2750
  type: "class",
@@ -2815,7 +2840,6 @@ function registerDialogTrigger(loader, overrides) {
2815
2840
  importPath: "@plasmicpkgs/react-aria/skinny/registerDialogTrigger",
2816
2841
  importName: "BaseDialogTrigger",
2817
2842
  styleSections: false,
2818
- isAttachment: true,
2819
2843
  props: {
2820
2844
  trigger: {
2821
2845
  type: "slot",
@@ -2834,10 +2858,21 @@ function registerDialogTrigger(loader, overrides) {
2834
2858
  dialog: {
2835
2859
  type: "slot",
2836
2860
  mergeWithParent: true,
2837
- defaultValue: {
2838
- type: "component",
2839
- name: MODAL_COMPONENT_NAME
2840
- }
2861
+ defaultValue: [
2862
+ {
2863
+ type: "component",
2864
+ name: MODAL_COMPONENT_NAME,
2865
+ props: {
2866
+ children: {
2867
+ type: "component",
2868
+ name: DIALOG_COMPONENT_NAME,
2869
+ props: {
2870
+ children: MODAL_DEFAULT_SLOT_CONTENT
2871
+ }
2872
+ }
2873
+ }
2874
+ }
2875
+ ]
2841
2876
  },
2842
2877
  isOpen: {
2843
2878
  type: "boolean",
@@ -4927,6 +4962,7 @@ function registerAll(loader) {
4927
4962
  registerText(loader);
4928
4963
  registerHeading(loader);
4929
4964
  registerDescription(loader);
4965
+ registerDialog(loader);
4930
4966
  registerOverlayArrow(loader);
4931
4967
  registerSelect(loader);
4932
4968
  registerComboBox(loader);