@plasmicpkgs/react-aria 0.0.35 → 0.0.37

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 (108) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contexts.d.ts +2 -1
  3. package/dist/interaction-variant-utils.d.ts +4 -0
  4. package/dist/react-aria.esm.js +69 -49
  5. package/dist/react-aria.esm.js.map +1 -1
  6. package/dist/react-aria.js +67 -47
  7. package/dist/react-aria.js.map +1 -1
  8. package/dist/registerPopover.d.ts +6 -1
  9. package/dist/registerRadio.d.ts +2 -4
  10. package/dist/utils.d.ts +1 -0
  11. package/package.json +2 -2
  12. package/skinny/contexts-9475faad.esm.js.map +1 -1
  13. package/skinny/contexts-b21f6b12.cjs.js.map +1 -1
  14. package/skinny/contexts.d.ts +2 -1
  15. package/skinny/{interaction-variant-utils-c44a9d56.esm.js → interaction-variant-utils-0e04f834.esm.js} +5 -1
  16. package/skinny/interaction-variant-utils-0e04f834.esm.js.map +1 -0
  17. package/skinny/{interaction-variant-utils-244b74fb.cjs.js → interaction-variant-utils-d45aa2a2.cjs.js} +5 -1
  18. package/skinny/interaction-variant-utils-d45aa2a2.cjs.js.map +1 -0
  19. package/skinny/interaction-variant-utils.d.ts +4 -0
  20. package/skinny/registerButton.cjs.js +4 -3
  21. package/skinny/registerButton.cjs.js.map +1 -1
  22. package/skinny/registerButton.esm.js +4 -3
  23. package/skinny/registerButton.esm.js.map +1 -1
  24. package/skinny/registerCheckbox.cjs.js +2 -2
  25. package/skinny/registerCheckbox.esm.js +2 -2
  26. package/skinny/registerCheckboxGroup.cjs.js +2 -2
  27. package/skinny/registerCheckboxGroup.esm.js +2 -2
  28. package/skinny/registerComboBox.cjs.js +5 -3
  29. package/skinny/registerComboBox.cjs.js.map +1 -1
  30. package/skinny/registerComboBox.esm.js +5 -3
  31. package/skinny/registerComboBox.esm.js.map +1 -1
  32. package/skinny/registerDescription.cjs.js +1 -1
  33. package/skinny/registerDescription.esm.js +1 -1
  34. package/skinny/registerDialogTrigger.cjs.js +2 -2
  35. package/skinny/registerDialogTrigger.esm.js +2 -2
  36. package/skinny/registerFieldError.cjs.js +1 -1
  37. package/skinny/registerFieldError.esm.js +1 -1
  38. package/skinny/registerForm.cjs.js +1 -1
  39. package/skinny/registerForm.esm.js +1 -1
  40. package/skinny/registerHeader.cjs.js +1 -1
  41. package/skinny/registerHeader.esm.js +1 -1
  42. package/skinny/registerInput.cjs.js +2 -2
  43. package/skinny/registerInput.esm.js +2 -2
  44. package/skinny/registerLabel.cjs.js +1 -1
  45. package/skinny/registerLabel.esm.js +1 -1
  46. package/skinny/{registerListBox-1effa43d.esm.js → registerListBox-cbc7beea.esm.js} +2 -2
  47. package/skinny/{registerListBox-1effa43d.esm.js.map → registerListBox-cbc7beea.esm.js.map} +1 -1
  48. package/skinny/{registerListBox-837b90d8.cjs.js → registerListBox-e98e849f.cjs.js} +2 -2
  49. package/skinny/{registerListBox-837b90d8.cjs.js.map → registerListBox-e98e849f.cjs.js.map} +1 -1
  50. package/skinny/registerListBox.cjs.js +3 -2
  51. package/skinny/registerListBox.cjs.js.map +1 -1
  52. package/skinny/registerListBox.esm.js +3 -2
  53. package/skinny/registerListBox.esm.js.map +1 -1
  54. package/skinny/registerListBoxItem.cjs.js +4 -2
  55. package/skinny/registerListBoxItem.cjs.js.map +1 -1
  56. package/skinny/registerListBoxItem.esm.js +5 -3
  57. package/skinny/registerListBoxItem.esm.js.map +1 -1
  58. package/skinny/registerModal.cjs.js +1 -1
  59. package/skinny/registerModal.esm.js +1 -1
  60. package/skinny/registerPopover.cjs.js +30 -6
  61. package/skinny/registerPopover.cjs.js.map +1 -1
  62. package/skinny/registerPopover.d.ts +6 -1
  63. package/skinny/registerPopover.esm.js +31 -7
  64. package/skinny/registerPopover.esm.js.map +1 -1
  65. package/skinny/registerRadio.cjs.js +8 -24
  66. package/skinny/registerRadio.cjs.js.map +1 -1
  67. package/skinny/registerRadio.d.ts +2 -4
  68. package/skinny/registerRadio.esm.js +8 -24
  69. package/skinny/registerRadio.esm.js.map +1 -1
  70. package/skinny/registerRadioGroup.cjs.js +2 -2
  71. package/skinny/registerRadioGroup.esm.js +2 -2
  72. package/skinny/registerSection.cjs.js +1 -1
  73. package/skinny/registerSection.esm.js +1 -1
  74. package/skinny/registerSelect.cjs.js +6 -5
  75. package/skinny/registerSelect.cjs.js.map +1 -1
  76. package/skinny/registerSelect.esm.js +6 -5
  77. package/skinny/registerSelect.esm.js.map +1 -1
  78. package/skinny/{registerSlider-b37e26ac.esm.js → registerSlider-3d1d372e.esm.js} +3 -3
  79. package/skinny/{registerSlider-b37e26ac.esm.js.map → registerSlider-3d1d372e.esm.js.map} +1 -1
  80. package/skinny/{registerSlider-abe2fcd9.cjs.js → registerSlider-7d3a0b39.cjs.js} +3 -3
  81. package/skinny/{registerSlider-abe2fcd9.cjs.js.map → registerSlider-7d3a0b39.cjs.js.map} +1 -1
  82. package/skinny/registerSlider.cjs.js +3 -3
  83. package/skinny/registerSlider.esm.js +3 -3
  84. package/skinny/registerSliderOutput.cjs.js +1 -1
  85. package/skinny/registerSliderOutput.esm.js +1 -1
  86. package/skinny/registerSliderThumb.cjs.js +2 -2
  87. package/skinny/registerSliderThumb.esm.js +2 -2
  88. package/skinny/registerSliderTrack.cjs.js +3 -3
  89. package/skinny/registerSliderTrack.esm.js +3 -3
  90. package/skinny/registerSwitch.cjs.js +2 -2
  91. package/skinny/registerSwitch.esm.js +2 -2
  92. package/skinny/registerText.cjs.js +5 -2
  93. package/skinny/registerText.cjs.js.map +1 -1
  94. package/skinny/registerText.esm.js +5 -2
  95. package/skinny/registerText.esm.js.map +1 -1
  96. package/skinny/registerTextArea.cjs.js +2 -2
  97. package/skinny/registerTextArea.esm.js +2 -2
  98. package/skinny/registerTextField.cjs.js +2 -2
  99. package/skinny/registerTextField.esm.js +2 -2
  100. package/skinny/registerTooltip.cjs.js +1 -1
  101. package/skinny/registerTooltip.esm.js +1 -1
  102. package/skinny/{utils-5051df41.esm.js → utils-a1785802.esm.js} +5 -2
  103. package/skinny/{utils-5051df41.esm.js.map → utils-a1785802.esm.js.map} +1 -1
  104. package/skinny/{utils-745db876.cjs.js → utils-d3708034.cjs.js} +5 -1
  105. package/skinny/{utils-745db876.cjs.js.map → utils-d3708034.cjs.js.map} +1 -1
  106. package/skinny/utils.d.ts +1 -0
  107. package/skinny/interaction-variant-utils-244b74fb.cjs.js.map +0 -1
  108. package/skinny/interaction-variant-utils-c44a9d56.esm.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { StrictItemType } from "./option-utils";
2
3
  import type { BaseListBoxProps } from "./registerListBox";
3
4
  export declare const PlasmicCheckboxGroupContext: React.Context<import("react-aria-components").CheckboxGroupProps | undefined>;
4
5
  export declare const PlasmicRadioGroupContext: React.Context<(import("react-aria-components").RadioGroupProps & React.RefAttributes<HTMLDivElement>) | undefined>;
@@ -7,7 +8,7 @@ export declare const PlasmicSliderContext: React.Context<import("./registerSlide
7
8
  export declare const PlasmicLabelContext: React.Context<(import("react-aria-components").LabelProps & React.RefAttributes<HTMLLabelElement>) | undefined>;
8
9
  export declare const PlasmicListBoxContext: React.Context<BaseListBoxProps | undefined>;
9
10
  export declare const PlasmicPopoverContext: React.Context<import("./registerPopover").BasePopoverProps | undefined>;
10
- export declare const PlasmicItemContext: React.Context<(import("react-aria-components").ListBoxItemProps<object> & React.RefAttributes<HTMLDivElement>) | undefined>;
11
+ export declare const PlasmicItemContext: React.Context<StrictItemType | undefined>;
11
12
  export declare const PlasmicSectionContext: React.Context<import("./registerSection").BaseSectionProps | undefined>;
12
13
  export declare const PlasmicHeaderContext: React.Context<(React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>) | undefined>;
13
14
  export declare const PlasmicInputContext: React.Context<import("./registerInput").BaseInputProps | undefined>;
@@ -21,6 +21,10 @@ declare const ARIA_COMPONENTS_INTERACTION_VARIANTS: {
21
21
  cssSelector: string;
22
22
  displayName: string;
23
23
  };
24
+ selected: {
25
+ cssSelector: string;
26
+ displayName: string;
27
+ };
24
28
  };
25
29
  type AriaInteractionVariant = keyof typeof ARIA_COMPONENTS_INTERACTION_VARIANTS;
26
30
  type CodeComponentInteractionVariantsMeta = NonNullable<CodeComponentMeta<unknown>["interactionVariants"]>;
@@ -1,5 +1,5 @@
1
- import React, { forwardRef, useImperativeHandle, Component, useMemo, useRef, useEffect } from 'react';
2
- import { Button, Label, Checkbox, Text, FieldError, CheckboxGroup, Input, ListBoxItem, Header, Section, Collection, ListBox, PopoverContext, Popover, ComboBox, ComboBoxStateContext, Heading, ModalOverlay, Modal, Dialog, DialogTrigger, Form, Radio, RadioGroup, Select, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextArea, TextField } from 'react-aria-components';
1
+ import React, { Component, forwardRef, useImperativeHandle, useMemo, useRef, useEffect } from 'react';
2
+ import { Button, Label, Checkbox, Text, FieldError, CheckboxGroup, Input, ListBoxItem, ListBox, Header, Section, Collection, PopoverContext, SelectContext, Popover, ComboBox, ComboBoxStateContext, Heading, ModalOverlay, Modal, Dialog, DialogTrigger, Form, Radio, RadioGroup, Select, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextArea, TextField } from 'react-aria-components';
3
3
  import registerComponent from '@plasmicapp/host/registerComponent';
4
4
  import { useFilter } from '@react-aria/i18n';
5
5
  import { mergeProps } from '@react-aria/utils';
@@ -78,6 +78,10 @@ const ARIA_COMPONENTS_INTERACTION_VARIANTS = {
78
78
  dragging: {
79
79
  cssSelector: "[data-dragging]",
80
80
  displayName: "Dragging"
81
+ },
82
+ selected: {
83
+ cssSelector: "[data-selected]",
84
+ displayName: "Selected"
81
85
  }
82
86
  };
83
87
  function ChangesObserver({
@@ -169,6 +173,9 @@ function extractPlasmicDataProps(props) {
169
173
  function withoutNils(array) {
170
174
  return array.filter((x) => x != null);
171
175
  }
176
+ function isDefined(thing) {
177
+ return thing !== void 0 && thing !== null;
178
+ }
172
179
 
173
180
  var __defProp$p = Object.defineProperty;
174
181
  var __defProps$c = Object.defineProperties;
@@ -249,7 +256,8 @@ function registerButton(loader, overrides) {
249
256
  borderWidth: "1px",
250
257
  borderStyle: "solid",
251
258
  borderColor: "black",
252
- padding: "2px 10px"
259
+ padding: "2px 10px",
260
+ cursor: "pointer"
253
261
  },
254
262
  props: __spreadProps$c(__spreadValues$p({}, getCommonInputProps("button", [
255
263
  "isDisabled",
@@ -565,7 +573,10 @@ function registerText(loader, overrides) {
565
573
  }
566
574
  },
567
575
  slot: {
568
- type: "string"
576
+ type: "choice",
577
+ options: ["label", "description"],
578
+ defaultValueHint: "label",
579
+ defaultValue: "label"
569
580
  }
570
581
  },
571
582
  trapsFocus: true
@@ -1172,6 +1183,22 @@ function registerInput(loader, overrides) {
1172
1183
  );
1173
1184
  }
1174
1185
 
1186
+ class ErrorBoundary extends Component {
1187
+ constructor(props) {
1188
+ super(props);
1189
+ this.state = { hasError: false };
1190
+ }
1191
+ static getDerivedStateFromError(_) {
1192
+ return { hasError: true };
1193
+ }
1194
+ render() {
1195
+ if (this.state.hasError) {
1196
+ return this.props.fallback;
1197
+ }
1198
+ return this.props.children;
1199
+ }
1200
+ }
1201
+
1175
1202
  var __defProp$i = Object.defineProperty;
1176
1203
  var __defProps$8 = Object.defineProperties;
1177
1204
  var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
@@ -1194,7 +1221,8 @@ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
1194
1221
  function BaseListBoxItem(props) {
1195
1222
  const contextProps = React.useContext(PlasmicItemContext);
1196
1223
  const mergedProps = mergeProps(contextProps, props);
1197
- return /* @__PURE__ */ React.createElement(ListBoxItem, __spreadProps$8(__spreadValues$i({}, mergedProps), { textValue: contextProps.label }), mergedProps.children);
1224
+ const listboxItem = /* @__PURE__ */ React.createElement(ListBoxItem, __spreadProps$8(__spreadValues$i({}, mergedProps), { textValue: contextProps == null ? void 0 : contextProps.label }), mergedProps.children);
1225
+ return /* @__PURE__ */ React.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React.createElement(ListBox, null, listboxItem) }, listboxItem);
1198
1226
  }
1199
1227
  const makeDefaultListBoxItemChildren = (label, description) => ({
1200
1228
  type: "vbox",
@@ -1504,20 +1532,37 @@ var __objRest$b = (source, exclude) => {
1504
1532
  }
1505
1533
  return target;
1506
1534
  };
1535
+ const SHOULD_FLIP_INSIDE_SELECT = false;
1507
1536
  function BasePopover(props) {
1508
- const _a = props, { resetClassName } = _a, restProps = __objRest$b(_a, ["resetClassName"]);
1537
+ const _a = props, { resetClassName, setControlContextData } = _a, restProps = __objRest$b(_a, ["resetClassName", "setControlContextData"]);
1509
1538
  const isStandalone = !React.useContext(PopoverContext);
1510
1539
  const contextProps = React.useContext(PlasmicPopoverContext);
1511
- const mergedProps = mergeProps(contextProps, restProps, {
1512
- className: `${resetClassName}`
1513
- });
1540
+ const isInsideSelect = !!React.useContext(SelectContext);
1541
+ const mergedProps = mergeProps(
1542
+ contextProps,
1543
+ restProps,
1544
+ {
1545
+ className: `${resetClassName}`
1546
+ },
1547
+ isInsideSelect && !isDefined(restProps.shouldFlip) ? { shouldFlip: SHOULD_FLIP_INSIDE_SELECT } : void 0
1548
+ );
1549
+ const isEditMode = !!usePlasmicCanvasContext();
1514
1550
  const triggerRef = React.useRef(null);
1515
1551
  const standaloneProps = isStandalone ? {
1516
1552
  triggerRef,
1517
1553
  isNonModal: true,
1518
1554
  isOpen: true
1519
1555
  } : {};
1520
- return /* @__PURE__ */ React.createElement(React.Fragment, null, isStandalone && /* @__PURE__ */ React.createElement("div", { ref: triggerRef }), /* @__PURE__ */ React.createElement(Popover, __spreadValues$e(__spreadValues$e({}, mergedProps), standaloneProps)));
1556
+ setControlContextData == null ? void 0 : setControlContextData({
1557
+ isStandalone,
1558
+ isInsideSelect
1559
+ });
1560
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, isStandalone && /* @__PURE__ */ React.createElement("div", { ref: triggerRef }), /* @__PURE__ */ React.createElement(
1561
+ Popover,
1562
+ __spreadValues$e(__spreadValues$e({
1563
+ isNonModal: isEditMode ? true : void 0
1564
+ }, mergedProps), standaloneProps)
1565
+ ));
1521
1566
  }
1522
1567
  const POPOVER_COMPONENT_NAME = makeComponentName("popover");
1523
1568
  const POPOVER_ARROW_IMG = {
@@ -1588,9 +1633,15 @@ function registerPopover(loader, overrides) {
1588
1633
  description: "Additional offset applied vertically between the popover and its trigger",
1589
1634
  defaultValueHint: 0
1590
1635
  },
1636
+ shouldFlip: {
1637
+ type: "boolean",
1638
+ description: "Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.",
1639
+ defaultValueHint: (_ps, ctx) => (ctx == null ? void 0 : ctx.isInsideSelect) ? SHOULD_FLIP_INSIDE_SELECT : true
1640
+ },
1591
1641
  placement: {
1592
1642
  type: "choice",
1593
1643
  description: "Default placement of the popover relative to the trigger, if there is enough space",
1644
+ defaultValueHint: "bottom",
1594
1645
  options: [
1595
1646
  "bottom",
1596
1647
  "bottom left",
@@ -2338,22 +2389,6 @@ function registerForm(loader, overrides) {
2338
2389
  );
2339
2390
  }
2340
2391
 
2341
- class ErrorBoundary extends Component {
2342
- constructor(props) {
2343
- super(props);
2344
- this.state = { hasError: false };
2345
- }
2346
- static getDerivedStateFromError(_) {
2347
- return { hasError: true };
2348
- }
2349
- render() {
2350
- if (this.state.hasError) {
2351
- return this.props.fallback;
2352
- }
2353
- return this.props.children;
2354
- }
2355
- }
2356
-
2357
2392
  var __defProp$9 = Object.defineProperty;
2358
2393
  var __defProps$4 = Object.defineProperties;
2359
2394
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
@@ -2389,28 +2424,25 @@ const RADIO_INTERACTION_VARIANTS = [
2389
2424
  "hovered",
2390
2425
  "pressed",
2391
2426
  "focused",
2392
- "focusVisible"
2427
+ "focusVisible",
2428
+ "selected"
2393
2429
  ];
2394
2430
  const { interactionVariants: interactionVariants$4, withObservedValues: withObservedValues$3 } = pickAriaComponentVariants(
2395
2431
  RADIO_INTERACTION_VARIANTS
2396
2432
  );
2397
2433
  function BaseRadio(props) {
2398
- const _a = props, { children, updateInteractionVariant, setControlContextData } = _a, rest = __objRest$7(_a, ["children", "updateInteractionVariant", "setControlContextData"]);
2399
- const contextProps = React.useContext(PlasmicRadioGroupContext);
2400
- const radio = /* @__PURE__ */ React.createElement(Radio, __spreadValues$9({}, rest), ({ isHovered, isPressed, isFocused, isFocusVisible }) => withObservedValues$3(
2434
+ const _a = props, { children, updateInteractionVariant } = _a, rest = __objRest$7(_a, ["children", "updateInteractionVariant"]);
2435
+ const radio = /* @__PURE__ */ React.createElement(Radio, __spreadValues$9({}, rest), ({ isHovered, isPressed, isFocused, isFocusVisible, isSelected }) => withObservedValues$3(
2401
2436
  children,
2402
2437
  {
2403
2438
  hovered: isHovered,
2404
2439
  pressed: isPressed,
2405
2440
  focused: isFocused,
2406
- focusVisible: isFocusVisible
2441
+ focusVisible: isFocusVisible,
2442
+ selected: isSelected
2407
2443
  },
2408
2444
  updateInteractionVariant
2409
2445
  ));
2410
- const isStandalone = !contextProps;
2411
- setControlContextData == null ? void 0 : setControlContextData({
2412
- isStandalone
2413
- });
2414
2446
  return /* @__PURE__ */ React.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React.createElement(RadioGroup, null, radio) }, radio);
2415
2447
  }
2416
2448
  const makeDefaultRadioChildren = (label) => ({
@@ -2468,20 +2500,8 @@ function registerRadio(loader, overrides) {
2468
2500
  value: {
2469
2501
  type: "string",
2470
2502
  description: "The value of the input element, used when submitting an HTML form."
2471
- },
2472
- onSelectionChange: {
2473
- type: "eventHandler",
2474
- argTypes: [{ name: "isSelected", type: "boolean" }]
2475
2503
  }
2476
2504
  }),
2477
- states: {
2478
- isSelected: {
2479
- type: "readonly",
2480
- onChangeProp: "onSelectionChange",
2481
- variableType: "boolean",
2482
- hidden: (_ps, ctx) => !(ctx == null ? void 0 : ctx.isStandalone)
2483
- }
2484
- },
2485
2505
  trapsFocus: true
2486
2506
  },
2487
2507
  overrides
@@ -2668,7 +2688,7 @@ function BaseSelect(props) {
2668
2688
  "aria-label": ariaLabel
2669
2689
  } = props;
2670
2690
  const { options } = useStrictOptions(props);
2671
- const canvas = usePlasmicCanvasContext();
2691
+ const isEditMode = !!usePlasmicCanvasContext();
2672
2692
  const disabledKeys = flattenOptions(options).filter((op) => op.isDisabled).map((op) => op.id);
2673
2693
  return /* @__PURE__ */ React.createElement(
2674
2694
  Select,
@@ -2682,7 +2702,7 @@ function BaseSelect(props) {
2682
2702
  style,
2683
2703
  name,
2684
2704
  "aria-label": ariaLabel
2685
- }, previewOpen && canvas ? { isOpen: previewOpen } : void 0), extractPlasmicDataProps(props)),
2705
+ }, isEditMode ? { isOpen: previewOpen } : void 0), extractPlasmicDataProps(props)),
2686
2706
  /* @__PURE__ */ React.createElement(
2687
2707
  PlasmicListBoxContext.Provider,
2688
2708
  {