@plasmicpkgs/react-aria 0.0.27 → 0.0.28

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 (86) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contexts.d.ts +2 -7
  3. package/dist/option-utils.d.ts +4 -13
  4. package/dist/react-aria.esm.js +346 -379
  5. package/dist/react-aria.esm.js.map +1 -1
  6. package/dist/react-aria.js +345 -378
  7. package/dist/react-aria.js.map +1 -1
  8. package/dist/registerDialogTrigger.d.ts +10 -0
  9. package/dist/registerListBox.d.ts +7 -5
  10. package/dist/registerListBoxItem.d.ts +2 -4
  11. package/dist/registerPopover.d.ts +4 -2
  12. package/dist/registerSection.d.ts +1 -3
  13. package/dist/registerSelect.d.ts +1 -1
  14. package/package.json +3 -3
  15. package/skinny/contexts.d.ts +2 -7
  16. package/skinny/{interaction-variant-utils-80bf1cfd.cjs.js → interaction-variant-utils-0f05190f.cjs.js} +16 -2
  17. package/skinny/interaction-variant-utils-0f05190f.cjs.js.map +1 -0
  18. package/skinny/{interaction-variant-utils-608d984b.esm.js → interaction-variant-utils-909267e5.esm.js} +16 -2
  19. package/skinny/interaction-variant-utils-909267e5.esm.js.map +1 -0
  20. package/skinny/{option-utils-765a1782.esm.js → option-utils-4f037568.esm.js} +22 -22
  21. package/skinny/option-utils-4f037568.esm.js.map +1 -0
  22. package/skinny/{option-utils-0db61f6d.cjs.js → option-utils-5e4e85bd.cjs.js} +22 -22
  23. package/skinny/option-utils-5e4e85bd.cjs.js.map +1 -0
  24. package/skinny/option-utils.d.ts +4 -13
  25. package/skinny/registerButton.cjs.js +5 -1
  26. package/skinny/registerButton.cjs.js.map +1 -1
  27. package/skinny/registerButton.esm.js +5 -1
  28. package/skinny/registerButton.esm.js.map +1 -1
  29. package/skinny/registerCheckbox.cjs.js +1 -1
  30. package/skinny/registerCheckbox.esm.js +1 -1
  31. package/skinny/registerCheckboxGroup.cjs.js +1 -1
  32. package/skinny/registerCheckboxGroup.esm.js +1 -1
  33. package/skinny/registerComboBox.cjs.js +10 -18
  34. package/skinny/registerComboBox.cjs.js.map +1 -1
  35. package/skinny/registerComboBox.esm.js +10 -18
  36. package/skinny/registerComboBox.esm.js.map +1 -1
  37. package/skinny/registerDialogTrigger.cjs.js +88 -0
  38. package/skinny/registerDialogTrigger.cjs.js.map +1 -0
  39. package/skinny/registerDialogTrigger.d.ts +10 -0
  40. package/skinny/registerDialogTrigger.esm.js +81 -0
  41. package/skinny/registerDialogTrigger.esm.js.map +1 -0
  42. package/skinny/registerInput.cjs.js +1 -1
  43. package/skinny/registerInput.esm.js +1 -1
  44. package/skinny/registerListBox.cjs.js +29 -73
  45. package/skinny/registerListBox.cjs.js.map +1 -1
  46. package/skinny/registerListBox.d.ts +7 -5
  47. package/skinny/registerListBox.esm.js +29 -73
  48. package/skinny/registerListBox.esm.js.map +1 -1
  49. package/skinny/registerListBoxItem.cjs.js +3 -19
  50. package/skinny/registerListBoxItem.cjs.js.map +1 -1
  51. package/skinny/registerListBoxItem.d.ts +2 -4
  52. package/skinny/registerListBoxItem.esm.js +3 -19
  53. package/skinny/registerListBoxItem.esm.js.map +1 -1
  54. package/skinny/registerPopover.cjs.js +7 -32
  55. package/skinny/registerPopover.cjs.js.map +1 -1
  56. package/skinny/registerPopover.d.ts +4 -2
  57. package/skinny/registerPopover.esm.js +7 -32
  58. package/skinny/registerPopover.esm.js.map +1 -1
  59. package/skinny/registerRadio.cjs.js +1 -1
  60. package/skinny/registerRadio.esm.js +1 -1
  61. package/skinny/registerRadioGroup.cjs.js +1 -1
  62. package/skinny/registerRadioGroup.esm.js +1 -1
  63. package/skinny/registerSection.cjs.js +4 -33
  64. package/skinny/registerSection.cjs.js.map +1 -1
  65. package/skinny/registerSection.d.ts +1 -3
  66. package/skinny/registerSection.esm.js +4 -33
  67. package/skinny/registerSection.esm.js.map +1 -1
  68. package/skinny/registerSelect.cjs.js +4 -15
  69. package/skinny/registerSelect.cjs.js.map +1 -1
  70. package/skinny/registerSelect.d.ts +1 -1
  71. package/skinny/registerSelect.esm.js +4 -15
  72. package/skinny/registerSelect.esm.js.map +1 -1
  73. package/skinny/registerSwitch.cjs.js +1 -1
  74. package/skinny/registerSwitch.esm.js +1 -1
  75. package/skinny/registerTextArea.cjs.js +1 -1
  76. package/skinny/registerTextArea.esm.js +1 -1
  77. package/skinny/registerTextField.cjs.js +1 -1
  78. package/skinny/registerTextField.esm.js +1 -1
  79. package/skinny/registerTooltip.cjs.js +13 -6
  80. package/skinny/registerTooltip.cjs.js.map +1 -1
  81. package/skinny/registerTooltip.esm.js +13 -6
  82. package/skinny/registerTooltip.esm.js.map +1 -1
  83. package/skinny/interaction-variant-utils-608d984b.esm.js.map +0 -1
  84. package/skinny/interaction-variant-utils-80bf1cfd.cjs.js.map +0 -1
  85. package/skinny/option-utils-0db61f6d.cjs.js.map +0 -1
  86. package/skinny/option-utils-765a1782.esm.js.map +0 -1
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { DialogTrigger } from "react-aria-components";
3
+ import { CodeComponentMetaOverrides, Registerable } from "./utils";
4
+ interface BaseDialogTriggerProps extends React.ComponentProps<typeof DialogTrigger> {
5
+ trigger: React.ReactNode;
6
+ dialog: React.ReactNode;
7
+ }
8
+ export declare function BaseDialogTrigger(props: BaseDialogTriggerProps): React.JSX.Element;
9
+ export declare function registerDialogTrigger(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseDialogTrigger>): void;
10
+ export {};
@@ -1,14 +1,16 @@
1
1
  import React from "react";
2
2
  import { ListBox } from "react-aria-components";
3
- import { type BaseListBoxItem } from "./registerListBoxItem";
4
- import type { BaseSection } from "./registerSection";
3
+ import { HasOptions } from "./option-utils";
5
4
  import { CodeComponentMetaOverrides, Registerable } from "./utils";
6
- export interface BaseListBoxProps extends React.ComponentProps<typeof ListBox> {
7
- makeItemProps?: (item: any) => Partial<React.ComponentProps<typeof BaseListBoxItem>>;
8
- makeSectionProps?: (section: any) => Partial<React.ComponentProps<typeof BaseSection>>;
5
+ interface BaseListBoxControlContextData {
6
+ isStandalone: boolean;
7
+ }
8
+ export interface BaseListBoxProps extends React.ComponentProps<typeof ListBox>, HasOptions<any> {
9
9
  renderItem?: (item: any) => React.ReactNode;
10
10
  renderSection?: (section: any) => React.ReactNode;
11
11
  getItemType?: (thing: any) => "item" | "section";
12
+ setControlContextData?: (ctxData: BaseListBoxControlContextData) => void;
12
13
  }
13
14
  export declare function BaseListBox(props: BaseListBoxProps): React.JSX.Element;
14
15
  export declare function registerListBox(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseListBox>): void;
16
+ export {};
@@ -1,7 +1,5 @@
1
1
  import React from "react";
2
- import { Key, ListBoxItem } from "react-aria-components";
2
+ import { ListBoxItem } from "react-aria-components";
3
3
  import { CodeComponentMetaOverrides, Registerable } from "./utils";
4
- export declare function BaseListBoxItem(props: React.ComponentProps<typeof ListBoxItem> & {
5
- key?: Key;
6
- }): React.JSX.Element;
4
+ export declare function BaseListBoxItem(props: React.ComponentProps<typeof ListBoxItem>): React.JSX.Element;
7
5
  export declare function registerListBoxItem(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseListBoxItem>): void;
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
+ import { Popover } from "react-aria-components";
2
3
  import { CodeComponentMetaOverrides, Registerable } from "./utils";
3
- export declare function BasePopover(props: {
4
+ export interface BasePopoverProps extends React.ComponentProps<typeof Popover> {
4
5
  className?: string;
5
6
  resetClassName?: string;
6
- }): React.JSX.Element;
7
+ }
8
+ export declare function BasePopover(props: BasePopoverProps): React.JSX.Element;
7
9
  export declare function registerPopover(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BasePopover>): void;
@@ -1,14 +1,12 @@
1
1
  import React from "react";
2
2
  import { Key } from "react-aria-components";
3
3
  import type { StrictSectionType } from "./option-utils";
4
- import { BaseListBoxItem } from "./registerListBoxItem";
5
4
  import { CodeComponentMetaOverrides, Registerable, Styleable } from "./utils";
6
5
  export interface BaseSectionProps extends Styleable {
7
6
  renderHeader?: (section: any) => React.ReactNode;
7
+ renderItem?: (item?: any) => React.ReactNode;
8
8
  key?: Key;
9
9
  section?: StrictSectionType;
10
- makeItemProps?: (item: any) => Partial<React.ComponentProps<typeof BaseListBoxItem>>;
11
- renderItem?: (item?: any) => React.ReactNode;
12
10
  }
13
11
  export declare function BaseSection(props: BaseSectionProps): React.JSX.Element;
14
12
  export declare function registerSection(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseSection>): void;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Key, SelectValue as BaseSelectValue } from "react-aria-components";
2
+ import { SelectValue as BaseSelectValue, Key } from "react-aria-components";
3
3
  import { HasOptions } from "./option-utils";
4
4
  import { Registerable, Styleable } from "./utils";
5
5
  export { BaseSelectValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicpkgs/react-aria",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Plasmic registration calls for react-aria based components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "react-stately": "^3.31.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@plasmicapp/host": "1.0.199",
57
+ "@plasmicapp/host": "1.0.200",
58
58
  "@rollup/plugin-commonjs": "^11.0.0",
59
59
  "@rollup/plugin-json": "^4.0.0",
60
60
  "@rollup/plugin-node-resolve": "^9.0.0",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "7fdda11c2d8a17f38f4af56153ff6fbaf09d4b07"
77
+ "gitHead": "fe773e8b44561aecdfe29d6c48155d2123892ce7"
78
78
  }
@@ -2,13 +2,8 @@ import React from "react";
2
2
  import type { BaseListBoxProps } from "./registerListBox";
3
3
  export declare const PlasmicLabelContext: React.Context<(import("react-aria-components").LabelProps & React.RefAttributes<HTMLLabelElement>) | undefined>;
4
4
  export declare const PlasmicListBoxContext: React.Context<BaseListBoxProps | undefined>;
5
- export declare const PlasmicPopoverContext: React.Context<{
6
- className?: string | undefined;
7
- resetClassName?: string | undefined;
8
- } | undefined>;
9
- export declare const PlasmicItemContext: React.Context<(import("react-aria-components").ListBoxItemProps<object> & React.RefAttributes<HTMLDivElement> & {
10
- key?: import("react-aria").Key | undefined;
11
- }) | undefined>;
5
+ export declare const PlasmicPopoverContext: React.Context<import("./registerPopover").BasePopoverProps | undefined>;
6
+ export declare const PlasmicItemContext: React.Context<(import("react-aria-components").ListBoxItemProps<object> & React.RefAttributes<HTMLDivElement>) | undefined>;
12
7
  export declare const PlasmicSectionContext: React.Context<import("./registerSection").BaseSectionProps | undefined>;
13
8
  export declare const PlasmicHeaderContext: React.Context<(React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>) | undefined>;
14
9
  export declare const PlasmicInputContext: React.Context<import("./registerInput").BaseInputProps | undefined>;
@@ -24,7 +24,11 @@ const ARIA_COMPONENTS_INTERACTION_VARIANTS = {
24
24
  displayName: "Focus Visible"
25
25
  }
26
26
  };
27
- function realWithObservedValues(children, changes, updateInteractionVariant) {
27
+ function ChangesObserver({
28
+ children,
29
+ changes,
30
+ updateInteractionVariant
31
+ }) {
28
32
  React__default.default.useEffect(() => {
29
33
  if (updateInteractionVariant) {
30
34
  updateInteractionVariant(changes);
@@ -32,6 +36,16 @@ function realWithObservedValues(children, changes, updateInteractionVariant) {
32
36
  }, [changes, updateInteractionVariant]);
33
37
  return children;
34
38
  }
39
+ function realWithObservedValues(children, changes, updateInteractionVariant) {
40
+ return /* @__PURE__ */ React__default.default.createElement(
41
+ ChangesObserver,
42
+ {
43
+ changes,
44
+ updateInteractionVariant
45
+ },
46
+ children
47
+ );
48
+ }
35
49
  function pickAriaComponentVariants(keys) {
36
50
  return {
37
51
  interactionVariants: Object.fromEntries(
@@ -42,4 +56,4 @@ function pickAriaComponentVariants(keys) {
42
56
  }
43
57
 
44
58
  exports.pickAriaComponentVariants = pickAriaComponentVariants;
45
- //# sourceMappingURL=interaction-variant-utils-80bf1cfd.cjs.js.map
59
+ //# sourceMappingURL=interaction-variant-utils-0f05190f.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-variant-utils-0f05190f.cjs.js","sources":["../src/interaction-variant-utils.tsx"],"sourcesContent":["import { CodeComponentMeta } from \"@plasmicapp/host\";\nimport React from \"react\";\n\nconst ARIA_COMPONENTS_INTERACTION_VARIANTS = {\n hovered: {\n cssSelector: \"[data-hovered]\",\n displayName: \"Hovered\",\n },\n pressed: {\n cssSelector: \"[data-pressed]\",\n displayName: \"Pressed\",\n },\n focused: {\n cssSelector: \"[data-focused]\",\n displayName: \"Focused\",\n },\n focusVisible: {\n cssSelector: \"[data-focus-visible]\",\n displayName: \"Focus Visible\",\n },\n};\n\ntype AriaInteractionVariant = keyof typeof ARIA_COMPONENTS_INTERACTION_VARIANTS;\n\ntype CodeComponentInteractionVariantsMeta = NonNullable<\n CodeComponentMeta<unknown>[\"interactionVariants\"]\n>;\n\ntype InteractionVariantMeta = CodeComponentInteractionVariantsMeta[string];\n\ntype ArrayElement<T> = T extends (infer U)[] ? U : never;\n\nexport type UpdateInteractionVariant<T extends AriaInteractionVariant[]> =\n | ((changes: Partial<Record<ArrayElement<T>, boolean>>) => void)\n | undefined;\n\ntype WithObservedValues<T extends AriaInteractionVariant[]> = (\n children: React.ReactNode,\n state: Record<ArrayElement<T>, boolean>,\n updateInteractionVariant: UpdateInteractionVariant<T>\n) => React.ReactNode;\n\nfunction ChangesObserver<T extends AriaInteractionVariant[]>({\n children,\n changes,\n updateInteractionVariant,\n}: {\n children: React.ReactNode;\n changes: Partial<Record<ArrayElement<T>, boolean>>;\n updateInteractionVariant?: UpdateInteractionVariant<T>;\n}) {\n React.useEffect(() => {\n if (updateInteractionVariant) {\n updateInteractionVariant(changes);\n }\n }, [changes, updateInteractionVariant]);\n return children;\n}\n\nfunction realWithObservedValues<T extends AriaInteractionVariant[]>(\n children: React.ReactNode,\n changes: Partial<Record<ArrayElement<T>, boolean>>,\n updateInteractionVariant?: UpdateInteractionVariant<T>\n) {\n return (\n <ChangesObserver\n changes={changes}\n updateInteractionVariant={updateInteractionVariant}\n >\n {children}\n </ChangesObserver>\n );\n}\n\nexport function pickAriaComponentVariants<T extends AriaInteractionVariant[]>(\n keys: T\n): {\n interactionVariants: Record<ArrayElement<T>, InteractionVariantMeta>;\n withObservedValues: WithObservedValues<T>;\n} {\n return {\n interactionVariants: Object.fromEntries(\n keys.map((key) => [key, ARIA_COMPONENTS_INTERACTION_VARIANTS[key]])\n ) as Record<ArrayElement<T>, InteractionVariantMeta>,\n withObservedValues: realWithObservedValues<T>,\n };\n}\n"],"names":["React"],"mappings":";;;;;;;;AAGA,MAAM,oCAAuC,GAAA;AAAA,EAC3C,OAAS,EAAA;AAAA,IACP,WAAa,EAAA,gBAAA;AAAA,IACb,WAAa,EAAA,SAAA;AAAA,GACf;AAAA,EACA,OAAS,EAAA;AAAA,IACP,WAAa,EAAA,gBAAA;AAAA,IACb,WAAa,EAAA,SAAA;AAAA,GACf;AAAA,EACA,OAAS,EAAA;AAAA,IACP,WAAa,EAAA,gBAAA;AAAA,IACb,WAAa,EAAA,SAAA;AAAA,GACf;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,WAAa,EAAA,sBAAA;AAAA,IACb,WAAa,EAAA,eAAA;AAAA,GACf;AACF,CAAA,CAAA;AAsBA,SAAS,eAAoD,CAAA;AAAA,EAC3D,QAAA;AAAA,EACA,OAAA;AAAA,EACA,wBAAA;AACF,CAIG,EAAA;AACD,EAAAA,sBAAA,CAAM,UAAU,MAAM;AACpB,IAAA,IAAI,wBAA0B,EAAA;AAC5B,MAAA,wBAAA,CAAyB,OAAO,CAAA,CAAA;AAAA,KAClC;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,wBAAwB,CAAC,CAAA,CAAA;AACtC,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAEA,SAAS,sBAAA,CACP,QACA,EAAA,OAAA,EACA,wBACA,EAAA;AACA,EACE,uBAAAA,sBAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,wBAAA;AAAA,KAAA;AAAA,IAEC,QAAA;AAAA,GACH,CAAA;AAEJ,CAAA;AAEO,SAAS,0BACd,IAIA,EAAA;AACA,EAAO,OAAA;AAAA,IACL,qBAAqB,MAAO,CAAA,WAAA;AAAA,MAC1B,IAAA,CAAK,IAAI,CAAC,GAAA,KAAQ,CAAC,GAAK,EAAA,oCAAA,CAAqC,GAAG,CAAC,CAAC,CAAA;AAAA,KACpE;AAAA,IACA,kBAAoB,EAAA,sBAAA;AAAA,GACtB,CAAA;AACF;;;;"}
@@ -18,7 +18,11 @@ const ARIA_COMPONENTS_INTERACTION_VARIANTS = {
18
18
  displayName: "Focus Visible"
19
19
  }
20
20
  };
21
- function realWithObservedValues(children, changes, updateInteractionVariant) {
21
+ function ChangesObserver({
22
+ children,
23
+ changes,
24
+ updateInteractionVariant
25
+ }) {
22
26
  React.useEffect(() => {
23
27
  if (updateInteractionVariant) {
24
28
  updateInteractionVariant(changes);
@@ -26,6 +30,16 @@ function realWithObservedValues(children, changes, updateInteractionVariant) {
26
30
  }, [changes, updateInteractionVariant]);
27
31
  return children;
28
32
  }
33
+ function realWithObservedValues(children, changes, updateInteractionVariant) {
34
+ return /* @__PURE__ */ React.createElement(
35
+ ChangesObserver,
36
+ {
37
+ changes,
38
+ updateInteractionVariant
39
+ },
40
+ children
41
+ );
42
+ }
29
43
  function pickAriaComponentVariants(keys) {
30
44
  return {
31
45
  interactionVariants: Object.fromEntries(
@@ -36,4 +50,4 @@ function pickAriaComponentVariants(keys) {
36
50
  }
37
51
 
38
52
  export { pickAriaComponentVariants as p };
39
- //# sourceMappingURL=interaction-variant-utils-608d984b.esm.js.map
53
+ //# sourceMappingURL=interaction-variant-utils-909267e5.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-variant-utils-909267e5.esm.js","sources":["../src/interaction-variant-utils.tsx"],"sourcesContent":["import { CodeComponentMeta } from \"@plasmicapp/host\";\nimport React from \"react\";\n\nconst ARIA_COMPONENTS_INTERACTION_VARIANTS = {\n hovered: {\n cssSelector: \"[data-hovered]\",\n displayName: \"Hovered\",\n },\n pressed: {\n cssSelector: \"[data-pressed]\",\n displayName: \"Pressed\",\n },\n focused: {\n cssSelector: \"[data-focused]\",\n displayName: \"Focused\",\n },\n focusVisible: {\n cssSelector: \"[data-focus-visible]\",\n displayName: \"Focus Visible\",\n },\n};\n\ntype AriaInteractionVariant = keyof typeof ARIA_COMPONENTS_INTERACTION_VARIANTS;\n\ntype CodeComponentInteractionVariantsMeta = NonNullable<\n CodeComponentMeta<unknown>[\"interactionVariants\"]\n>;\n\ntype InteractionVariantMeta = CodeComponentInteractionVariantsMeta[string];\n\ntype ArrayElement<T> = T extends (infer U)[] ? U : never;\n\nexport type UpdateInteractionVariant<T extends AriaInteractionVariant[]> =\n | ((changes: Partial<Record<ArrayElement<T>, boolean>>) => void)\n | undefined;\n\ntype WithObservedValues<T extends AriaInteractionVariant[]> = (\n children: React.ReactNode,\n state: Record<ArrayElement<T>, boolean>,\n updateInteractionVariant: UpdateInteractionVariant<T>\n) => React.ReactNode;\n\nfunction ChangesObserver<T extends AriaInteractionVariant[]>({\n children,\n changes,\n updateInteractionVariant,\n}: {\n children: React.ReactNode;\n changes: Partial<Record<ArrayElement<T>, boolean>>;\n updateInteractionVariant?: UpdateInteractionVariant<T>;\n}) {\n React.useEffect(() => {\n if (updateInteractionVariant) {\n updateInteractionVariant(changes);\n }\n }, [changes, updateInteractionVariant]);\n return children;\n}\n\nfunction realWithObservedValues<T extends AriaInteractionVariant[]>(\n children: React.ReactNode,\n changes: Partial<Record<ArrayElement<T>, boolean>>,\n updateInteractionVariant?: UpdateInteractionVariant<T>\n) {\n return (\n <ChangesObserver\n changes={changes}\n updateInteractionVariant={updateInteractionVariant}\n >\n {children}\n </ChangesObserver>\n );\n}\n\nexport function pickAriaComponentVariants<T extends AriaInteractionVariant[]>(\n keys: T\n): {\n interactionVariants: Record<ArrayElement<T>, InteractionVariantMeta>;\n withObservedValues: WithObservedValues<T>;\n} {\n return {\n interactionVariants: Object.fromEntries(\n keys.map((key) => [key, ARIA_COMPONENTS_INTERACTION_VARIANTS[key]])\n ) as Record<ArrayElement<T>, InteractionVariantMeta>,\n withObservedValues: realWithObservedValues<T>,\n };\n}\n"],"names":[],"mappings":";;AAGA,MAAM,oCAAuC,GAAA;AAAA,EAC3C,OAAS,EAAA;AAAA,IACP,WAAa,EAAA,gBAAA;AAAA,IACb,WAAa,EAAA,SAAA;AAAA,GACf;AAAA,EACA,OAAS,EAAA;AAAA,IACP,WAAa,EAAA,gBAAA;AAAA,IACb,WAAa,EAAA,SAAA;AAAA,GACf;AAAA,EACA,OAAS,EAAA;AAAA,IACP,WAAa,EAAA,gBAAA;AAAA,IACb,WAAa,EAAA,SAAA;AAAA,GACf;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,WAAa,EAAA,sBAAA;AAAA,IACb,WAAa,EAAA,eAAA;AAAA,GACf;AACF,CAAA,CAAA;AAsBA,SAAS,eAAoD,CAAA;AAAA,EAC3D,QAAA;AAAA,EACA,OAAA;AAAA,EACA,wBAAA;AACF,CAIG,EAAA;AACD,EAAA,KAAA,CAAM,UAAU,MAAM;AACpB,IAAA,IAAI,wBAA0B,EAAA;AAC5B,MAAA,wBAAA,CAAyB,OAAO,CAAA,CAAA;AAAA,KAClC;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,wBAAwB,CAAC,CAAA,CAAA;AACtC,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAEA,SAAS,sBAAA,CACP,QACA,EAAA,OAAA,EACA,wBACA,EAAA;AACA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,wBAAA;AAAA,KAAA;AAAA,IAEC,QAAA;AAAA,GACH,CAAA;AAEJ,CAAA;AAEO,SAAS,0BACd,IAIA,EAAA;AACA,EAAO,OAAA;AAAA,IACL,qBAAqB,MAAO,CAAA,WAAA;AAAA,MAC1B,IAAA,CAAK,IAAI,CAAC,GAAA,KAAQ,CAAC,GAAK,EAAA,oCAAA,CAAqC,GAAG,CAAC,CAAC,CAAA;AAAA,KACpE;AAAA,IACA,kBAAoB,EAAA,sBAAA;AAAA,GACtB,CAAA;AACF;;;;"}
@@ -16,26 +16,26 @@ function deriveStrictOptions(props) {
16
16
  return void 0;
17
17
  } else if (typeof op === "string" || typeof op === "number") {
18
18
  const item = {
19
- value: op
19
+ id: op
20
20
  };
21
21
  return item;
22
22
  } else if (optionInfo) {
23
23
  const info = optionInfo(op);
24
- if (info.type === "section") {
24
+ if (info.type === "option-group") {
25
25
  const section = {
26
- type: "section",
26
+ type: "option-group",
27
27
  items: (_c = (_b = (_a2 = info.items) == null ? void 0 : _a2.map) == null ? void 0 : _b.call(_a2, (item) => makeStrict(item))) == null ? void 0 : _c.filter((x) => !!x),
28
28
  label: info.label,
29
- key: `section-${sectionCount}`
29
+ key: `option-group-${sectionCount}`
30
30
  };
31
31
  sectionCount += 1;
32
32
  return section;
33
33
  } else {
34
34
  let item = info;
35
- if (!("value" in item)) {
35
+ if (!("id" in item)) {
36
36
  item = {
37
- type: "item",
38
- value: JSON.stringify(item)
37
+ type: "option",
38
+ id: JSON.stringify(item)
39
39
  };
40
40
  }
41
41
  return item;
@@ -43,19 +43,19 @@ function deriveStrictOptions(props) {
43
43
  } else if (typeof op === "object") {
44
44
  if ("items" in op) {
45
45
  const section = {
46
- type: "section",
46
+ type: "option-group",
47
47
  items: (_f = (_e = (_d = op.items) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (item) => makeStrict(item))) == null ? void 0 : _f.filter((x) => !!x),
48
48
  label: op.label,
49
- key: `section-${sectionCount}`
49
+ key: `option-group-${sectionCount}`
50
50
  };
51
51
  sectionCount += 1;
52
52
  return section;
53
53
  } else {
54
54
  let item = op;
55
- if (!("value" in item)) {
55
+ if (!("id" in item)) {
56
56
  item = {
57
- type: "item",
58
- value: JSON.stringify(item)
57
+ type: "option",
58
+ id: JSON.stringify(item)
59
59
  };
60
60
  }
61
61
  return item;
@@ -67,7 +67,7 @@ function deriveStrictOptions(props) {
67
67
  const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
68
68
  const optionText = (op) => {
69
69
  var _a2;
70
- return (_a2 = op.label) != null ? _a2 : op.value;
70
+ return (_a2 = op.label) != null ? _a2 : op.id;
71
71
  };
72
72
  return { options: strictOptions, optionText };
73
73
  }
@@ -78,7 +78,7 @@ function flattenOptions(options) {
78
78
  return options.flatMap(
79
79
  (op) => {
80
80
  var _a;
81
- return op.type === "section" ? (_a = op.items) != null ? _a : [] : op;
81
+ return op.type === "option-group" ? (_a = op.items) != null ? _a : [] : op;
82
82
  }
83
83
  );
84
84
  }
@@ -88,7 +88,7 @@ function makeOptionsPropType() {
88
88
  type: "array",
89
89
  itemType: {
90
90
  type: "object",
91
- nameFunc: (item) => item.label || item.value,
91
+ nameFunc: (item) => item.label || item.id,
92
92
  fields: {
93
93
  type: {
94
94
  type: "choice",
@@ -98,7 +98,7 @@ function makeOptionsPropType() {
98
98
  ],
99
99
  defaultValue: "option"
100
100
  },
101
- value: {
101
+ id: {
102
102
  type: "string",
103
103
  hidden: (_ps, _ctx, { item }) => item.type !== "option"
104
104
  },
@@ -111,9 +111,9 @@ function makeOptionsPropType() {
111
111
  },
112
112
  itemType: {
113
113
  type: "object",
114
- nameFunc: (item) => item.label || item.value,
114
+ nameFunc: (item) => item.label || item.id,
115
115
  fields: {
116
- value: "string",
116
+ id: "string",
117
117
  label: "string"
118
118
  }
119
119
  }
@@ -122,12 +122,12 @@ function makeOptionsPropType() {
122
122
  },
123
123
  defaultValue: [
124
124
  {
125
- value: "option1",
125
+ id: "option1",
126
126
  label: "Option 1",
127
127
  type: "option"
128
128
  },
129
129
  {
130
- value: "option2",
130
+ id: "option2",
131
131
  label: "Option 2",
132
132
  type: "option"
133
133
  }
@@ -141,7 +141,7 @@ function makeValuePropType() {
141
141
  options: (ps) => {
142
142
  const { options, optionText } = deriveStrictOptions(ps);
143
143
  return flattenOptions(options).map((op) => ({
144
- value: op.value,
144
+ value: op.id,
145
145
  label: optionText(op)
146
146
  }));
147
147
  }
@@ -150,4 +150,4 @@ function makeValuePropType() {
150
150
  }
151
151
 
152
152
  export { makeValuePropType as a, flattenOptions as f, makeOptionsPropType as m, useStrictOptions as u };
153
- //# sourceMappingURL=option-utils-765a1782.esm.js.map
153
+ //# sourceMappingURL=option-utils-4f037568.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-utils-4f037568.esm.js","sources":["../src/option-utils.ts"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n"],"names":["_a"],"mappings":";;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,CAAA,CAAA;AAEnB,EAAM,MAAA,UAAA,GAAa,CAAC,EAAwD,KAAA;AAvD9E,IAAA,IAAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,E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AAE,CAAA;AAAA,OACpB,CAAA,CAAA,CAAA;AAAA,KACJ;AAAA,GACF,CAAA;AACA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -22,26 +22,26 @@ function deriveStrictOptions(props) {
22
22
  return void 0;
23
23
  } else if (typeof op === "string" || typeof op === "number") {
24
24
  const item = {
25
- value: op
25
+ id: op
26
26
  };
27
27
  return item;
28
28
  } else if (optionInfo) {
29
29
  const info = optionInfo(op);
30
- if (info.type === "section") {
30
+ if (info.type === "option-group") {
31
31
  const section = {
32
- type: "section",
32
+ type: "option-group",
33
33
  items: (_c = (_b = (_a2 = info.items) == null ? void 0 : _a2.map) == null ? void 0 : _b.call(_a2, (item) => makeStrict(item))) == null ? void 0 : _c.filter((x) => !!x),
34
34
  label: info.label,
35
- key: `section-${sectionCount}`
35
+ key: `option-group-${sectionCount}`
36
36
  };
37
37
  sectionCount += 1;
38
38
  return section;
39
39
  } else {
40
40
  let item = info;
41
- if (!("value" in item)) {
41
+ if (!("id" in item)) {
42
42
  item = {
43
- type: "item",
44
- value: JSON.stringify(item)
43
+ type: "option",
44
+ id: JSON.stringify(item)
45
45
  };
46
46
  }
47
47
  return item;
@@ -49,19 +49,19 @@ function deriveStrictOptions(props) {
49
49
  } else if (typeof op === "object") {
50
50
  if ("items" in op) {
51
51
  const section = {
52
- type: "section",
52
+ type: "option-group",
53
53
  items: (_f = (_e = (_d = op.items) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (item) => makeStrict(item))) == null ? void 0 : _f.filter((x) => !!x),
54
54
  label: op.label,
55
- key: `section-${sectionCount}`
55
+ key: `option-group-${sectionCount}`
56
56
  };
57
57
  sectionCount += 1;
58
58
  return section;
59
59
  } else {
60
60
  let item = op;
61
- if (!("value" in item)) {
61
+ if (!("id" in item)) {
62
62
  item = {
63
- type: "item",
64
- value: JSON.stringify(item)
63
+ type: "option",
64
+ id: JSON.stringify(item)
65
65
  };
66
66
  }
67
67
  return item;
@@ -73,7 +73,7 @@ function deriveStrictOptions(props) {
73
73
  const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
74
74
  const optionText = (op) => {
75
75
  var _a2;
76
- return (_a2 = op.label) != null ? _a2 : op.value;
76
+ return (_a2 = op.label) != null ? _a2 : op.id;
77
77
  };
78
78
  return { options: strictOptions, optionText };
79
79
  }
@@ -84,7 +84,7 @@ function flattenOptions(options) {
84
84
  return options.flatMap(
85
85
  (op) => {
86
86
  var _a;
87
- return op.type === "section" ? (_a = op.items) != null ? _a : [] : op;
87
+ return op.type === "option-group" ? (_a = op.items) != null ? _a : [] : op;
88
88
  }
89
89
  );
90
90
  }
@@ -94,7 +94,7 @@ function makeOptionsPropType() {
94
94
  type: "array",
95
95
  itemType: {
96
96
  type: "object",
97
- nameFunc: (item) => item.label || item.value,
97
+ nameFunc: (item) => item.label || item.id,
98
98
  fields: {
99
99
  type: {
100
100
  type: "choice",
@@ -104,7 +104,7 @@ function makeOptionsPropType() {
104
104
  ],
105
105
  defaultValue: "option"
106
106
  },
107
- value: {
107
+ id: {
108
108
  type: "string",
109
109
  hidden: (_ps, _ctx, { item }) => item.type !== "option"
110
110
  },
@@ -117,9 +117,9 @@ function makeOptionsPropType() {
117
117
  },
118
118
  itemType: {
119
119
  type: "object",
120
- nameFunc: (item) => item.label || item.value,
120
+ nameFunc: (item) => item.label || item.id,
121
121
  fields: {
122
- value: "string",
122
+ id: "string",
123
123
  label: "string"
124
124
  }
125
125
  }
@@ -128,12 +128,12 @@ function makeOptionsPropType() {
128
128
  },
129
129
  defaultValue: [
130
130
  {
131
- value: "option1",
131
+ id: "option1",
132
132
  label: "Option 1",
133
133
  type: "option"
134
134
  },
135
135
  {
136
- value: "option2",
136
+ id: "option2",
137
137
  label: "Option 2",
138
138
  type: "option"
139
139
  }
@@ -147,7 +147,7 @@ function makeValuePropType() {
147
147
  options: (ps) => {
148
148
  const { options, optionText } = deriveStrictOptions(ps);
149
149
  return flattenOptions(options).map((op) => ({
150
- value: op.value,
150
+ value: op.id,
151
151
  label: optionText(op)
152
152
  }));
153
153
  }
@@ -159,4 +159,4 @@ exports.flattenOptions = flattenOptions;
159
159
  exports.makeOptionsPropType = makeOptionsPropType;
160
160
  exports.makeValuePropType = makeValuePropType;
161
161
  exports.useStrictOptions = useStrictOptions;
162
- //# sourceMappingURL=option-utils-0db61f6d.cjs.js.map
162
+ //# sourceMappingURL=option-utils-5e4e85bd.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-utils-5e4e85bd.cjs.js","sources":["../src/option-utils.ts"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n"],"names":["React","_a"],"mappings":";;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAAA,sBAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,CAAA,CAAA;AAEnB,EAAM,MAAA,UAAA,GAAa,CAAC,EAAwD,KAAA;AAvD9E,IAAA,IAAAC,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAwDI,IAAA,IAAI,CAAC,EAAI,EAAA;AACP,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,eACE,OAAO,EAAA,KAAO,QAAY,IAAA,OAAO,OAAO,QAAU,EAAA;AAC3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13
  export type ObjectOptionType<T extends object> = ObjectSectionType<T> | ObjectItemType<T>;
14
14
  export interface HasOptions<T extends object> {
15
15
  options?: FlexOptionType<T>[];
16
- optionInfo?: (option: FlexOptionType<T>) => {
17
- type?: "item";
18
- value: string;
19
- label?: string;
20
- isDisabled?: boolean;
21
- } | {
22
- type: "section";
23
- label?: string;
24
- items?: FlexOptionType<T>[];
25
- };
16
+ optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;
26
17
  }
27
18
  export interface StrictItemType {
28
- type?: "item";
29
- value: string;
19
+ type?: "option";
20
+ id: string;
30
21
  label?: string;
31
22
  isDisabled?: boolean;
32
23
  }
33
24
  export interface StrictSectionType {
34
- type: "section";
25
+ type: "option-group";
35
26
  label?: string;
36
27
  items?: StrictItemType[];
37
28
  key: string;
@@ -3,7 +3,7 @@
3
3
  var React = require('react');
4
4
  var reactAriaComponents = require('react-aria-components');
5
5
  var common = require('./common-e74a9214.cjs.js');
6
- var interactionVariantUtils = require('./interaction-variant-utils-80bf1cfd.cjs.js');
6
+ var interactionVariantUtils = require('./interaction-variant-utils-0f05190f.cjs.js');
7
7
  var utils = require('./utils-18b2465b.cjs.js');
8
8
  require('@plasmicapp/host/registerComponent');
9
9
 
@@ -105,6 +105,10 @@ function registerButton(loader, overrides) {
105
105
  hidden: (ps) => Boolean(ps.submitsForm),
106
106
  description: "Whether clicking this button should reset the enclosing form.",
107
107
  advanced: true
108
+ },
109
+ onPress: {
110
+ type: "eventHandler",
111
+ argTypes: [{ name: "event", type: "object" }]
108
112
  }
109
113
  }),
110
114
  trapsFocus: true
@@ -1 +1 @@
1
- {"version":3,"file":"registerButton.cjs.js","sources":["../src/registerButton.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ButtonProps } from \"react-aria-components\";\nimport { Button } from \"react-aria-components\";\nimport { getCommonInputProps } from \"./common\";\nimport {\n UpdateInteractionVariant,\n pickAriaComponentVariants,\n} from \"./interaction-variant-utils\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n makeComponentName,\n registerComponentHelper,\n} from \"./utils\";\n\nconst BUTTON_INTERACTION_VARIANTS = [\n \"hovered\" as const,\n \"pressed\" as const,\n \"focused\" as const,\n \"focusVisible\" as const,\n];\n\nconst { interactionVariants, withObservedValues } = pickAriaComponentVariants(\n BUTTON_INTERACTION_VARIANTS\n);\n\ninterface BaseButtonProps extends ButtonProps {\n children: React.ReactNode;\n resetsForm?: boolean;\n submitsForm?: boolean;\n // Optional callback to update the interaction variant state\n // as it's only provided if the component is the root of a Studio component\n updateInteractionVariant?: UpdateInteractionVariant<\n typeof BUTTON_INTERACTION_VARIANTS\n >;\n}\n\nexport function BaseButton(props: BaseButtonProps) {\n const {\n submitsForm,\n resetsForm,\n children,\n updateInteractionVariant,\n ...rest\n } = props;\n\n const type = submitsForm ? \"submit\" : resetsForm ? \"reset\" : \"button\";\n\n return (\n <Button type={type} {...rest}>\n {({ isHovered, isPressed, isFocused, isFocusVisible }) =>\n withObservedValues(\n children,\n {\n hovered: isHovered,\n pressed: isPressed,\n focused: isFocused,\n focusVisible: isFocusVisible,\n },\n updateInteractionVariant\n )\n }\n </Button>\n );\n}\n\nexport function registerButton(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseButton>\n) {\n registerComponentHelper(\n loader,\n BaseButton,\n {\n name: makeComponentName(\"button\"),\n displayName: \"Aria Button\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerButton\",\n importName: \"BaseButton\",\n interactionVariants,\n props: {\n ...getCommonInputProps<BaseButtonProps>(\"button\", [\n \"isDisabled\",\n \"aria-label\",\n \"children\",\n ]),\n submitsForm: {\n type: \"boolean\",\n displayName: \"Submits form?\",\n defaultValueHint: false,\n hidden: (ps: BaseButtonProps) => Boolean(ps.resetsForm),\n description:\n \"Whether clicking this button should submit the enclosing form.\",\n advanced: true,\n },\n resetsForm: {\n type: \"boolean\",\n displayName: \"Resets form?\",\n defaultValueHint: false,\n hidden: (ps: BaseButtonProps) => Boolean(ps.submitsForm),\n description:\n \"Whether clicking this button should reset the enclosing form.\",\n advanced: true,\n },\n },\n trapsFocus: true,\n },\n overrides\n );\n}\n"],"names":["pickAriaComponentVariants","React","Button","registerComponentHelper","makeComponentName","getCommonInputProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,2BAA8B,GAAA;AAAA,EAClC,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AACF,CAAA,CAAA;AAEA,MAAM,EAAE,mBAAqB,EAAA,kBAAA,EAAuB,GAAAA,iDAAA;AAAA,EAClD,2BAAA;AACF,CAAA,CAAA;AAaO,SAAS,WAAW,KAAwB,EAAA;AACjD,EAAA,MAMI,EALF,GAAA,KAAA,EAAA;AAAA,IAAA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,wBAAA;AAAA,GA1CJ,GA4CM,EADC,EAAA,IAAA,GAAA,SAAA,CACD,EADC,EAAA;AAAA,IAJH,aAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA,0BAAA;AAAA,GAAA,CAAA,CAAA;AAIF,EAAA,MAAM,IAAO,GAAA,WAAA,GAAc,QAAW,GAAA,UAAA,GAAa,OAAU,GAAA,QAAA,CAAA;AAE7D,EACE,uBAAAC,sBAAA,CAAA,aAAA,CAACC,0BAAO,EAAA,cAAA,CAAA,EAAA,IAAA,EAAA,EAAgB,IACrB,CAAA,EAAA,CAAC,EAAE,SAAW,EAAA,SAAA,EAAW,SAAW,EAAA,cAAA,EACnC,KAAA,kBAAA;AAAA,IACE,QAAA;AAAA,IACA;AAAA,MACE,OAAS,EAAA,SAAA;AAAA,MACT,OAAS,EAAA,SAAA;AAAA,MACT,OAAS,EAAA,SAAA;AAAA,MACT,YAAc,EAAA,cAAA;AAAA,KAChB;AAAA,IACA,wBAAA;AAAA,GAGN,CAAA,CAAA;AAEJ,CAAA;AAEgB,SAAA,cAAA,CACd,QACA,SACA,EAAA;AACA,EAAAC,6BAAA;AAAA,IACE,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,MACE,IAAA,EAAMC,wBAAkB,QAAQ,CAAA;AAAA,MAChC,WAAa,EAAA,aAAA;AAAA,MACb,UAAY,EAAA,+CAAA;AAAA,MACZ,UAAY,EAAA,YAAA;AAAA,MACZ,mBAAA;AAAA,MACA,KAAA,EAAO,aACF,CAAA,cAAA,CAAA,EAAA,EAAAC,0BAAA,CAAqC,QAAU,EAAA;AAAA,QAChD,YAAA;AAAA,QACA,YAAA;AAAA,QACA,UAAA;AAAA,OACD,CALI,CAAA,EAAA;AAAA,QAML,WAAa,EAAA;AAAA,UACX,IAAM,EAAA,SAAA;AAAA,UACN,WAAa,EAAA,eAAA;AAAA,UACb,gBAAkB,EAAA,KAAA;AAAA,UAClB,MAAQ,EAAA,CAAC,EAAwB,KAAA,OAAA,CAAQ,GAAG,UAAU,CAAA;AAAA,UACtD,WACE,EAAA,gEAAA;AAAA,UACF,QAAU,EAAA,IAAA;AAAA,SACZ;AAAA,QACA,UAAY,EAAA;AAAA,UACV,IAAM,EAAA,SAAA;AAAA,UACN,WAAa,EAAA,cAAA;AAAA,UACb,gBAAkB,EAAA,KAAA;AAAA,UAClB,MAAQ,EAAA,CAAC,EAAwB,KAAA,OAAA,CAAQ,GAAG,WAAW,CAAA;AAAA,UACvD,WACE,EAAA,+DAAA;AAAA,UACF,QAAU,EAAA,IAAA;AAAA,SACZ;AAAA,OACF,CAAA;AAAA,MACA,UAAY,EAAA,IAAA;AAAA,KACd;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;"}
1
+ {"version":3,"file":"registerButton.cjs.js","sources":["../src/registerButton.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ButtonProps } from \"react-aria-components\";\nimport { Button } from \"react-aria-components\";\nimport { getCommonInputProps } from \"./common\";\nimport {\n UpdateInteractionVariant,\n pickAriaComponentVariants,\n} from \"./interaction-variant-utils\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n makeComponentName,\n registerComponentHelper,\n} from \"./utils\";\n\nconst BUTTON_INTERACTION_VARIANTS = [\n \"hovered\" as const,\n \"pressed\" as const,\n \"focused\" as const,\n \"focusVisible\" as const,\n];\n\nconst { interactionVariants, withObservedValues } = pickAriaComponentVariants(\n BUTTON_INTERACTION_VARIANTS\n);\n\ninterface BaseButtonProps extends ButtonProps {\n children: React.ReactNode;\n resetsForm?: boolean;\n submitsForm?: boolean;\n // Optional callback to update the interaction variant state\n // as it's only provided if the component is the root of a Studio component\n updateInteractionVariant?: UpdateInteractionVariant<\n typeof BUTTON_INTERACTION_VARIANTS\n >;\n}\n\nexport function BaseButton(props: BaseButtonProps) {\n const {\n submitsForm,\n resetsForm,\n children,\n updateInteractionVariant,\n ...rest\n } = props;\n\n const type = submitsForm ? \"submit\" : resetsForm ? \"reset\" : \"button\";\n\n return (\n <Button type={type} {...rest}>\n {({ isHovered, isPressed, isFocused, isFocusVisible }) =>\n withObservedValues(\n children,\n {\n hovered: isHovered,\n pressed: isPressed,\n focused: isFocused,\n focusVisible: isFocusVisible,\n },\n updateInteractionVariant\n )\n }\n </Button>\n );\n}\n\nexport function registerButton(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseButton>\n) {\n registerComponentHelper(\n loader,\n BaseButton,\n {\n name: makeComponentName(\"button\"),\n displayName: \"Aria Button\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerButton\",\n importName: \"BaseButton\",\n interactionVariants,\n props: {\n ...getCommonInputProps<BaseButtonProps>(\"button\", [\n \"isDisabled\",\n \"aria-label\",\n \"children\",\n ]),\n submitsForm: {\n type: \"boolean\",\n displayName: \"Submits form?\",\n defaultValueHint: false,\n hidden: (ps: BaseButtonProps) => Boolean(ps.resetsForm),\n description:\n \"Whether clicking this button should submit the enclosing form.\",\n advanced: true,\n },\n resetsForm: {\n type: \"boolean\",\n displayName: \"Resets form?\",\n defaultValueHint: false,\n hidden: (ps: BaseButtonProps) => Boolean(ps.submitsForm),\n description:\n \"Whether clicking this button should reset the enclosing form.\",\n advanced: true,\n },\n onPress: {\n type: \"eventHandler\",\n argTypes: [{ name: \"event\", type: \"object\" }],\n },\n },\n trapsFocus: true,\n },\n overrides\n );\n}\n"],"names":["pickAriaComponentVariants","React","Button","registerComponentHelper","makeComponentName","getCommonInputProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,2BAA8B,GAAA;AAAA,EAClC,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AACF,CAAA,CAAA;AAEA,MAAM,EAAE,mBAAqB,EAAA,kBAAA,EAAuB,GAAAA,iDAAA;AAAA,EAClD,2BAAA;AACF,CAAA,CAAA;AAaO,SAAS,WAAW,KAAwB,EAAA;AACjD,EAAA,MAMI,EALF,GAAA,KAAA,EAAA;AAAA,IAAA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,wBAAA;AAAA,GA1CJ,GA4CM,EADC,EAAA,IAAA,GAAA,SAAA,CACD,EADC,EAAA;AAAA,IAJH,aAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA,0BAAA;AAAA,GAAA,CAAA,CAAA;AAIF,EAAA,MAAM,IAAO,GAAA,WAAA,GAAc,QAAW,GAAA,UAAA,GAAa,OAAU,GAAA,QAAA,CAAA;AAE7D,EACE,uBAAAC,sBAAA,CAAA,aAAA,CAACC,0BAAO,EAAA,cAAA,CAAA,EAAA,IAAA,EAAA,EAAgB,IACrB,CAAA,EAAA,CAAC,EAAE,SAAW,EAAA,SAAA,EAAW,SAAW,EAAA,cAAA,EACnC,KAAA,kBAAA;AAAA,IACE,QAAA;AAAA,IACA;AAAA,MACE,OAAS,EAAA,SAAA;AAAA,MACT,OAAS,EAAA,SAAA;AAAA,MACT,OAAS,EAAA,SAAA;AAAA,MACT,YAAc,EAAA,cAAA;AAAA,KA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;;;"}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Button } from 'react-aria-components';
3
3
  import { g as getCommonInputProps } from './common-52c26d37.esm.js';
4
- import { p as pickAriaComponentVariants } from './interaction-variant-utils-608d984b.esm.js';
4
+ import { p as pickAriaComponentVariants } from './interaction-variant-utils-909267e5.esm.js';
5
5
  import { r as registerComponentHelper, m as makeComponentName } from './utils-cf2632c9.esm.js';
6
6
  import '@plasmicapp/host/registerComponent';
7
7
 
@@ -99,6 +99,10 @@ function registerButton(loader, overrides) {
99
99
  hidden: (ps) => Boolean(ps.submitsForm),
100
100
  description: "Whether clicking this button should reset the enclosing form.",
101
101
  advanced: true
102
+ },
103
+ onPress: {
104
+ type: "eventHandler",
105
+ argTypes: [{ name: "event", type: "object" }]
102
106
  }
103
107
  }),
104
108
  trapsFocus: true