@plasmicpkgs/react-aria 0.0.98 → 0.0.100

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,7 +1,7 @@
1
+ import { usePlasmicCanvasContext, usePlasmicCanvasComponentInfo, usePlasmicLink } from '@plasmicapp/host';
1
2
  import React, { useEffect, useState, useMemo, useCallback, forwardRef, useImperativeHandle, Component } from 'react';
2
- import { mergeProps, useFocusable } from 'react-aria';
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
- import { usePlasmicCanvasContext, usePlasmicCanvasComponentInfo } from '@plasmicapp/host';
3
+ import { mergeProps, useLink, useHover, useFocusRing, useFocusable } from 'react-aria';
4
+ import { Button, Checkbox, Text, Label, CheckboxGroup, Input, ListBoxItem, ListBox, Section, Header, PopoverContext, Popover, ComboBox, ComboBoxStateContext, Dialog, ModalOverlay, Modal, DialogTrigger, Heading, TooltipContext, OverlayArrow, Radio, RadioGroup, Select, SelectStateContext, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextArea, TextField, TooltipTrigger, Tooltip } from 'react-aria-components';
5
5
  import registerComponent from '@plasmicapp/host/registerComponent';
6
6
  import { mergeProps as mergeProps$1 } from '@react-aria/utils';
7
7
  import flattenChildren from 'react-keyed-flatten-children';
@@ -652,24 +652,73 @@ const BUTTON_VARIANTS = [
652
652
  ];
653
653
  const { variants: variants$h, withObservedValues: withObservedValues$e } = pickAriaComponentVariants(BUTTON_VARIANTS);
654
654
  const BaseButton = React.forwardRef(function BaseButtonInner(props, ref) {
655
- const _a = props, { submitsForm, resetsForm, children, plasmicUpdateVariant } = _a, rest = __objRest$m(_a, ["submitsForm", "resetsForm", "children", "plasmicUpdateVariant"]);
656
- const type = submitsForm ? "submit" : resetsForm ? "reset" : "button";
657
- const mergedProps = mergeProps(rest, {
658
- type,
655
+ const { href } = props;
656
+ if (href) {
657
+ return /* @__PURE__ */ React.createElement(
658
+ LinkButton,
659
+ {
660
+ props,
661
+ ref
662
+ }
663
+ );
664
+ } else {
665
+ const _a = props, { submitsForm, resetsForm, children, plasmicUpdateVariant } = _a, rest = __objRest$m(_a, ["submitsForm", "resetsForm", "children", "plasmicUpdateVariant"]);
666
+ const type = submitsForm ? "submit" : resetsForm ? "reset" : "button";
667
+ const buttonProps = mergeProps(rest, {
668
+ type,
669
+ style: COMMON_STYLES,
670
+ ref
671
+ });
672
+ return /* @__PURE__ */ React.createElement(Button, __spreadValues$q({}, buttonProps), ({ isHovered, isPressed, isFocused, isFocusVisible, isDisabled }) => withObservedValues$e(
673
+ children,
674
+ {
675
+ hovered: isHovered,
676
+ pressed: isPressed,
677
+ focused: isFocused,
678
+ focusVisible: isFocusVisible,
679
+ disabled: isDisabled
680
+ },
681
+ plasmicUpdateVariant
682
+ ));
683
+ }
684
+ });
685
+ function LinkButton({
686
+ props,
687
+ ref
688
+ }) {
689
+ const _a = props, { href, children, plasmicUpdateVariant } = _a, rest = __objRest$m(_a, ["href", "children", "plasmicUpdateVariant"]);
690
+ const PlasmicLink = usePlasmicLink();
691
+ const { linkProps, isPressed } = useLink(props, ref);
692
+ const { hoverProps, isHovered } = useHover(props);
693
+ const { focusProps, isFocused, isFocusVisible } = useFocusRing();
694
+ const combinedLinkProps = mergeProps(linkProps, hoverProps, focusProps, {
695
+ href,
696
+ className: props.className,
697
+ style: COMMON_STYLES,
659
698
  ref
660
699
  });
661
- return /* @__PURE__ */ React.createElement(Button, __spreadProps$m(__spreadValues$q({}, mergedProps), { style: COMMON_STYLES }), ({ isHovered, isPressed, isFocused, isFocusVisible, isDisabled }) => withObservedValues$e(
662
- children,
663
- {
664
- hovered: isHovered,
665
- pressed: isPressed,
666
- focused: isFocused,
667
- focusVisible: isFocusVisible,
668
- disabled: isDisabled
669
- },
670
- plasmicUpdateVariant
671
- ));
672
- });
700
+ return /* @__PURE__ */ React.createElement(
701
+ PlasmicLink,
702
+ __spreadProps$m(__spreadValues$q({}, combinedLinkProps), {
703
+ "data-focused": isFocused || void 0,
704
+ "data-hovered": isHovered || void 0,
705
+ "data-pressed": isPressed || void 0,
706
+ "data-focus-visible": isFocusVisible || void 0,
707
+ "data-disabled": props.isDisabled || void 0
708
+ }),
709
+ withObservedValues$e(
710
+ children,
711
+ {
712
+ hovered: isHovered,
713
+ pressed: isPressed,
714
+ focused: isFocused,
715
+ focusVisible: isFocusVisible,
716
+ disabled: !!rest.isDisabled
717
+ },
718
+ plasmicUpdateVariant
719
+ )
720
+ );
721
+ }
673
722
  const BUTTON_COMPONENT_NAME = makeComponentName("button");
674
723
  function registerButton(loader, overrides) {
675
724
  registerComponentHelper(
@@ -682,11 +731,18 @@ function registerButton(loader, overrides) {
682
731
  importName: "BaseButton",
683
732
  variants: variants$h,
684
733
  defaultStyles: {
685
- borderWidth: "1px",
686
- borderStyle: "solid",
734
+ // Ensure consistent design across rendered elements (button, anchor tag).
735
+ backgroundColor: "#EFEFEF",
687
736
  borderColor: "black",
737
+ borderStyle: "solid",
738
+ borderWidth: "1px",
739
+ color: "#000000",
740
+ cursor: "pointer",
741
+ fontFamily: "Arial",
742
+ fontSize: "1rem",
743
+ lineHeight: "1.2",
688
744
  padding: "2px 10px",
689
- cursor: "pointer"
745
+ textDecorationLine: "none"
690
746
  },
691
747
  props: __spreadProps$m(__spreadValues$q({}, getCommonProps("button", [
692
748
  "autoFocus",
@@ -701,11 +757,22 @@ function registerButton(loader, overrides) {
701
757
  value: "Button"
702
758
  }
703
759
  },
760
+ href: {
761
+ type: "href",
762
+ description: "The URL this button navigates to. If present, this button is an <a> element."
763
+ },
764
+ target: {
765
+ type: "choice",
766
+ options: ["_blank", "_self", "_parent", "_top"],
767
+ description: "Same as target attribute of <a> element. Only applies when the href prop is present.",
768
+ hidden: (props) => !props.href,
769
+ defaultValueHint: "_self"
770
+ },
704
771
  submitsForm: {
705
772
  type: "boolean",
706
773
  displayName: "Submits form?",
707
774
  defaultValueHint: false,
708
- hidden: (props) => Boolean(props.resetsForm),
775
+ hidden: (props) => Boolean(props.resetsForm) || Boolean(props.href),
709
776
  description: "Whether clicking this button should submit the enclosing form.",
710
777
  advanced: true
711
778
  },
@@ -713,7 +780,7 @@ function registerButton(loader, overrides) {
713
780
  type: "boolean",
714
781
  displayName: "Resets form?",
715
782
  defaultValueHint: false,
716
- hidden: (props) => Boolean(props.submitsForm),
783
+ hidden: (props) => Boolean(props.submitsForm) || Boolean(props.href),
717
784
  description: "Whether clicking this button should reset the enclosing form.",
718
785
  advanced: true
719
786
  },
@@ -2560,77 +2627,6 @@ var __objRest$b = (source, exclude) => {
2560
2627
  }
2561
2628
  return target;
2562
2629
  };
2563
- function BaseHeading(_a) {
2564
- var _b = _a, { children } = _b, rest = __objRest$b(_b, ["children"]);
2565
- return /* @__PURE__ */ React.createElement(Heading, __spreadProps$c(__spreadValues$e({}, rest), { style: COMMON_STYLES }), children);
2566
- }
2567
- const HEADING_COMPONENT_NAME = makeComponentName("heading");
2568
- function registerHeading(loader, overrides) {
2569
- return registerComponentHelper(
2570
- loader,
2571
- BaseHeading,
2572
- {
2573
- name: HEADING_COMPONENT_NAME,
2574
- displayName: "Aria Heading",
2575
- importPath: "@plasmicpkgs/react-aria/skinny/registerHeading",
2576
- importName: "BaseHeading",
2577
- defaultStyles: {
2578
- fontSize: "20px",
2579
- fontWeight: "bold",
2580
- marginBottom: "10px"
2581
- },
2582
- props: {
2583
- children: {
2584
- type: "slot",
2585
- mergeWithParent: true,
2586
- defaultValue: {
2587
- type: "text",
2588
- value: "Heading"
2589
- }
2590
- },
2591
- slot: {
2592
- type: "string",
2593
- defaultValue: "title",
2594
- hidden: () => true
2595
- }
2596
- },
2597
- trapsFocus: true
2598
- },
2599
- overrides
2600
- );
2601
- }
2602
-
2603
- var __defProp$d = Object.defineProperty;
2604
- var __defProps$b = Object.defineProperties;
2605
- var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2606
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
2607
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
2608
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
2609
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2610
- var __spreadValues$d = (a, b) => {
2611
- for (var prop in b || (b = {}))
2612
- if (__hasOwnProp$d.call(b, prop))
2613
- __defNormalProp$d(a, prop, b[prop]);
2614
- if (__getOwnPropSymbols$d)
2615
- for (var prop of __getOwnPropSymbols$d(b)) {
2616
- if (__propIsEnum$d.call(b, prop))
2617
- __defNormalProp$d(a, prop, b[prop]);
2618
- }
2619
- return a;
2620
- };
2621
- var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
2622
- var __objRest$a = (source, exclude) => {
2623
- var target = {};
2624
- for (var prop in source)
2625
- if (__hasOwnProp$d.call(source, prop) && exclude.indexOf(prop) < 0)
2626
- target[prop] = source[prop];
2627
- if (source != null && __getOwnPropSymbols$d)
2628
- for (var prop of __getOwnPropSymbols$d(source)) {
2629
- if (exclude.indexOf(prop) < 0 && __propIsEnum$d.call(source, prop))
2630
- target[prop] = source[prop];
2631
- }
2632
- return target;
2633
- };
2634
2630
  const BaseModal = forwardRef(
2635
2631
  function BaseModalInner(props, ref) {
2636
2632
  var _b, _c, _d;
@@ -2642,7 +2638,7 @@ const BaseModal = forwardRef(
2642
2638
  resetClassName,
2643
2639
  setControlContextData,
2644
2640
  isDismissable
2645
- } = _a, rest = __objRest$a(_a, [
2641
+ } = _a, rest = __objRest$b(_a, [
2646
2642
  "children",
2647
2643
  "modalOverlayClass",
2648
2644
  "className",
@@ -2682,7 +2678,7 @@ const BaseModal = forwardRef(
2682
2678
  }));
2683
2679
  return /* @__PURE__ */ React.createElement(
2684
2680
  ModalOverlay,
2685
- __spreadProps$b(__spreadValues$d({}, mergedProps), {
2681
+ __spreadProps$c(__spreadValues$e({}, mergedProps), {
2686
2682
  className: `${resetClassName} ${modalOverlayClass}`
2687
2683
  }),
2688
2684
  /* @__PURE__ */ React.createElement(Modal, { className }, children)
@@ -2701,8 +2697,9 @@ const MODAL_DEFAULT_SLOT_CONTENT = {
2701
2697
  },
2702
2698
  children: [
2703
2699
  {
2704
- type: "component",
2705
- name: HEADING_COMPONENT_NAME
2700
+ type: "text",
2701
+ value: "Heading",
2702
+ tag: "h2"
2706
2703
  },
2707
2704
  {
2708
2705
  type: "text",
@@ -2804,46 +2801,46 @@ function registerModal(loader, overrides) {
2804
2801
  );
2805
2802
  }
2806
2803
 
2807
- var __defProp$c = Object.defineProperty;
2808
- var __defProps$a = Object.defineProperties;
2809
- var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
2810
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
2811
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
2812
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
2813
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2814
- var __spreadValues$c = (a, b) => {
2804
+ var __defProp$d = Object.defineProperty;
2805
+ var __defProps$b = Object.defineProperties;
2806
+ var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2807
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
2808
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
2809
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
2810
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2811
+ var __spreadValues$d = (a, b) => {
2815
2812
  for (var prop in b || (b = {}))
2816
- if (__hasOwnProp$c.call(b, prop))
2817
- __defNormalProp$c(a, prop, b[prop]);
2818
- if (__getOwnPropSymbols$c)
2819
- for (var prop of __getOwnPropSymbols$c(b)) {
2820
- if (__propIsEnum$c.call(b, prop))
2821
- __defNormalProp$c(a, prop, b[prop]);
2813
+ if (__hasOwnProp$d.call(b, prop))
2814
+ __defNormalProp$d(a, prop, b[prop]);
2815
+ if (__getOwnPropSymbols$d)
2816
+ for (var prop of __getOwnPropSymbols$d(b)) {
2817
+ if (__propIsEnum$d.call(b, prop))
2818
+ __defNormalProp$d(a, prop, b[prop]);
2822
2819
  }
2823
2820
  return a;
2824
2821
  };
2825
- var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
2826
- var __objRest$9 = (source, exclude) => {
2822
+ var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
2823
+ var __objRest$a = (source, exclude) => {
2827
2824
  var target = {};
2828
2825
  for (var prop in source)
2829
- if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
2826
+ if (__hasOwnProp$d.call(source, prop) && exclude.indexOf(prop) < 0)
2830
2827
  target[prop] = source[prop];
2831
- if (source != null && __getOwnPropSymbols$c)
2832
- for (var prop of __getOwnPropSymbols$c(source)) {
2833
- if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
2828
+ if (source != null && __getOwnPropSymbols$d)
2829
+ for (var prop of __getOwnPropSymbols$d(source)) {
2830
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$d.call(source, prop))
2834
2831
  target[prop] = source[prop];
2835
2832
  }
2836
2833
  return target;
2837
2834
  };
2838
2835
  function BaseDialogTrigger(props) {
2839
2836
  var _b, _c, _d;
2840
- const _a = props, { trigger, dialog, isOpen } = _a, rest = __objRest$9(_a, ["trigger", "dialog", "isOpen"]);
2837
+ const _a = props, { trigger, dialog, isOpen } = _a, rest = __objRest$a(_a, ["trigger", "dialog", "isOpen"]);
2841
2838
  const { isSelected, selectedSlotName } = (_c = (_b = usePlasmicCanvasComponentInfo) == null ? void 0 : _b(props)) != null ? _c : {};
2842
2839
  const isAutoOpen = selectedSlotName !== "trigger" && isSelected;
2843
- const mergedProps = __spreadProps$a(__spreadValues$c({}, rest), {
2840
+ const mergedProps = __spreadProps$b(__spreadValues$d({}, rest), {
2844
2841
  isOpen: (_d = isAutoOpen || isOpen) != null ? _d : false
2845
2842
  });
2846
- return /* @__PURE__ */ React.createElement(PlasmicDialogTriggerContext.Provider, { value: mergedProps }, /* @__PURE__ */ React.createElement(DialogTrigger, __spreadValues$c({}, mergedProps), trigger, dialog));
2843
+ return /* @__PURE__ */ React.createElement(PlasmicDialogTriggerContext.Provider, { value: mergedProps }, /* @__PURE__ */ React.createElement(DialogTrigger, __spreadValues$d({}, mergedProps), trigger, dialog));
2847
2844
  }
2848
2845
  function registerDialogTrigger(loader, overrides) {
2849
2846
  registerComponentHelper(
@@ -2914,6 +2911,77 @@ function registerDialogTrigger(loader, overrides) {
2914
2911
  );
2915
2912
  }
2916
2913
 
2914
+ var __defProp$c = Object.defineProperty;
2915
+ var __defProps$a = Object.defineProperties;
2916
+ var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
2917
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
2918
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
2919
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
2920
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2921
+ var __spreadValues$c = (a, b) => {
2922
+ for (var prop in b || (b = {}))
2923
+ if (__hasOwnProp$c.call(b, prop))
2924
+ __defNormalProp$c(a, prop, b[prop]);
2925
+ if (__getOwnPropSymbols$c)
2926
+ for (var prop of __getOwnPropSymbols$c(b)) {
2927
+ if (__propIsEnum$c.call(b, prop))
2928
+ __defNormalProp$c(a, prop, b[prop]);
2929
+ }
2930
+ return a;
2931
+ };
2932
+ var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
2933
+ var __objRest$9 = (source, exclude) => {
2934
+ var target = {};
2935
+ for (var prop in source)
2936
+ if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
2937
+ target[prop] = source[prop];
2938
+ if (source != null && __getOwnPropSymbols$c)
2939
+ for (var prop of __getOwnPropSymbols$c(source)) {
2940
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
2941
+ target[prop] = source[prop];
2942
+ }
2943
+ return target;
2944
+ };
2945
+ function BaseHeading(_a) {
2946
+ var _b = _a, { children } = _b, rest = __objRest$9(_b, ["children"]);
2947
+ return /* @__PURE__ */ React.createElement(Heading, __spreadProps$a(__spreadValues$c({}, rest), { style: COMMON_STYLES }), children);
2948
+ }
2949
+ const HEADING_COMPONENT_NAME = makeComponentName("heading");
2950
+ function registerHeading(loader, overrides) {
2951
+ return registerComponentHelper(
2952
+ loader,
2953
+ BaseHeading,
2954
+ {
2955
+ name: HEADING_COMPONENT_NAME,
2956
+ displayName: "Aria Heading (deprecated)",
2957
+ importPath: "@plasmicpkgs/react-aria/skinny/registerHeading",
2958
+ importName: "BaseHeading",
2959
+ defaultStyles: {
2960
+ fontSize: "20px",
2961
+ fontWeight: "bold",
2962
+ marginBottom: "10px"
2963
+ },
2964
+ props: {
2965
+ children: {
2966
+ type: "slot",
2967
+ mergeWithParent: true,
2968
+ defaultValue: {
2969
+ type: "text",
2970
+ value: "Heading"
2971
+ }
2972
+ },
2973
+ slot: {
2974
+ type: "string",
2975
+ defaultValue: "title",
2976
+ hidden: () => true
2977
+ }
2978
+ },
2979
+ trapsFocus: true
2980
+ },
2981
+ overrides
2982
+ );
2983
+ }
2984
+
2917
2985
  var __defProp$b = Object.defineProperty;
2918
2986
  var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
2919
2987
  var __hasOwnProp$b = Object.prototype.hasOwnProperty;