@plasmicapp/react-web 0.2.151 → 0.2.153

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,5 +1,5 @@
1
1
  import * as React from "react";
2
- export declare const Stack: (<T extends "symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" = "div">(props: {
2
+ export declare const Stack: (<T extends "symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "center" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" = "div">(props: {
3
3
  as?: T | undefined;
4
4
  hasGap?: boolean | undefined;
5
5
  } & React.ComponentProps<T>) => React.ReactElement) & {
@@ -45,8 +45,10 @@ export declare function hasVariant<V extends Variants>(variants: V | undefined,
45
45
  export declare function wrapFlexContainerChildren(children: React.ReactNode, hasGap: boolean): React.DetailedReactHTMLElement<{
46
46
  className: string;
47
47
  }, HTMLElement> | null;
48
- export declare function createPlasmicElementProxy<DefaultElementType extends React.ElementType>(defaultElement: DefaultElementType, props: Partial<React.ComponentProps<DefaultElementType>>, ...children: React.ReactNode[]): {} | null | undefined;
49
- export declare function makeFragment(...children: React.ReactNode[]): React.FunctionComponentElement<{}>;
48
+ export declare function createPlasmicElementProxy<DefaultElementType extends React.ElementType>(defaultElement: DefaultElementType, props: Partial<React.ComponentProps<DefaultElementType>>, ...children: React.ReactNode[]): number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactFragment | null | undefined;
49
+ export declare function makeFragment(...children: React.ReactNode[]): React.FunctionComponentElement<{
50
+ children?: React.ReactNode;
51
+ }>;
50
52
  export declare const UNSET: unique symbol;
51
53
  export declare function wrapWithClassName(element: React.ReactNode, className: string): React.DetailedReactHTMLElement<{
52
54
  key: string | number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.151",
3
+ "version": "0.2.153",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "prettier": {},
42
42
  "dependencies": {
43
- "@plasmicapp/data-sources": "0.1.32",
44
- "@plasmicapp/data-sources-context": "0.1.5",
45
- "@plasmicapp/host": "1.0.101",
46
- "@plasmicapp/query": "0.1.59",
43
+ "@plasmicapp/data-sources": "0.1.34",
44
+ "@plasmicapp/data-sources-context": "0.1.6",
45
+ "@plasmicapp/host": "1.0.103",
46
+ "@plasmicapp/query": "0.1.61",
47
47
  "@react-aria/checkbox": "^3.5.0",
48
48
  "@react-aria/focus": "^3.7.0",
49
49
  "@react-aria/interactions": "^3.10.0",
@@ -88,15 +88,15 @@
88
88
  "@types/classnames": "^2.2.9",
89
89
  "@types/clone": "^2.1.1",
90
90
  "@types/dlv": "^1.1.2",
91
- "@types/react": "^17.0.39",
92
- "@types/react-dom": "^17.0.11",
91
+ "@types/react": "^18.0.27",
92
+ "@types/react-dom": "^18.0.10",
93
93
  "babel-jest": "^27.0.6",
94
94
  "babel-loader": "^8.2.2",
95
95
  "eslint": "^7.26.0",
96
96
  "eslint-plugin-valtio": "^0.5.1",
97
97
  "husky": "^6.0.0",
98
- "react": "^16.13.1",
99
- "react-dom": "^16.13.1",
98
+ "react": "^18.2.0",
99
+ "react-dom": "^18.2.0",
100
100
  "rollup": "^2.47.0",
101
101
  "rollup-plugin-dts": "^5.1.0",
102
102
  "rollup-plugin-typescript2": "^0.30.0",
@@ -109,5 +109,5 @@
109
109
  "react": ">=16.8.0",
110
110
  "react-dom": ">=16.8.0"
111
111
  },
112
- "gitHead": "56c15e54ed33294aaef992171bbb1b3ab1aa6c3a"
112
+ "gitHead": "2badf5ec47566e84eb4ef8c27b2a48524516edc9"
113
113
  }
@@ -6,5 +6,5 @@ interface PlasmicPageGuardProps {
6
6
  canTriggerLogin: boolean;
7
7
  children: React.ReactNode;
8
8
  }
9
- export declare function PlasmicPageGuard(props: PlasmicPageGuardProps): React.ReactNode;
9
+ export declare function PlasmicPageGuard(props: PlasmicPageGuardProps): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
10
10
  export {};
@@ -1,7 +1,7 @@
1
1
  import { c as __assign, p as pick, d as __spreadArray, e as __read, b as __rest } from '../../common-c2744215.js';
2
- import * as React from 'react';
3
2
  import { useMenu as useMenu$1, useMenuSection, useMenuItem as useMenuItem$1 } from '@react-aria/menu';
4
3
  import { useTreeState } from '@react-stately/tree';
4
+ import * as React from 'react';
5
5
  import { m as mergeProps } from '../../react-utils-76d05959.js';
6
6
  import { a as useEnsureSSRProvider } from '../../ssr-f6caec06.js';
7
7
  import { r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-b5d4be02.js';
@@ -42,7 +42,10 @@ function useMenu(plasmicClass, props, config, ref) {
42
42
  var state = useTreeState(ariaProps);
43
43
  var menuListRef = React.useRef(null);
44
44
  var menuProps = useMenu$1(__assign(__assign({}, ariaProps), { autoFocus: triggerContext === null || triggerContext === void 0 ? void 0 : triggerContext.autoFocus }), state, menuListRef).menuProps;
45
- var contextValue = React.useMemo(function () { return ({ state: state, menuProps: props }); }, [state, props]);
45
+ var contextValue = React.useMemo(function () { return ({ state: state, menuProps: props }); }, [
46
+ state,
47
+ props,
48
+ ]);
46
49
  var variants = __assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false)));
47
50
  var overrides = (_a = {},
48
51
  _a[config.root] = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/menu/context.tsx","../../../../src/plume/menu/menu.tsx","../../../../src/plume/menu/menu-group.tsx","../../../../src/plume/menu/menu-item.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { TreeState } from \"@react-stately/tree\";\nimport type { BaseMenuProps } from \"./menu\";\n\nexport interface MenuContextValue {\n menuProps: BaseMenuProps;\n state: TreeState<any>;\n}\n\nexport const MenuContext = React.createContext<MenuContextValue | undefined>(\n undefined\n);\n","import { AriaMenuProps } from \"@react-types/menu\";\nimport { AriaLabelingProps, DOMProps } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useMenu as useAriaMenu } from \"@react-aria/menu\";\nimport { useTreeState } from \"@react-stately/tree\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n renderAsCollectionChild,\n renderCollectionNode,\n useDerivedItemsFromChildren,\n} from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\nimport { TriggeredOverlayContext } from \"../triggered-overlay/context\";\nimport { MenuContext } from \"./context\";\n\nexport interface BaseMenuProps extends DOMProps, AriaLabelingProps, StyleProps {\n /**\n * List of `Menu.Item`s or `Menu.Group`s that make up the menu\n */\n children?: React.ReactNode;\n\n /**\n * Called with the value of a `Menu.Item` when it is selected.\n */\n onAction?: (value: string) => void;\n}\n\nexport type MenuRef = React.Ref<MenuRefValue>;\nexport interface MenuRefValue extends MenuState {\n getRoot: () => HTMLElement | null;\n}\n\nconst COLLECTION_OPTS = {\n itemPlumeType: \"menu-item\",\n sectionPlumeType: \"menu-group\",\n};\n\nexport interface MenuConfig<C extends AnyPlasmicClass> {\n isPlacedTopVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedBottomVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedLeftVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedRightVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n itemsSlot: keyof PlasmicClassArgs<C>;\n itemsContainer: keyof PlasmicClassOverrides<C>;\n root: keyof PlasmicClassOverrides<C>;\n}\n\n/**\n * Converts props from BaseMenuProps to react-aria's useMenu() props.\n */\nfunction asAriaMenuProps(props: BaseMenuProps) {\n const { children, ...rest } = props;\n const { items, disabledKeys } = useDerivedItemsFromChildren(children, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Menu.Item and Menu.Group as children to Menu`,\n requireItemValue: false,\n });\n\n const collectionChildRenderer = React.useCallback(\n (child) => renderAsCollectionChild(child, COLLECTION_OPTS),\n []\n );\n\n return {\n ariaProps: {\n ...rest,\n children: collectionChildRenderer,\n items,\n disabledKeys,\n } as AriaMenuProps<any>,\n };\n}\n\nexport interface MenuState {\n getFocusedValue: () => string | null;\n setFocusedValue: (value: string) => void;\n}\n\nexport function useMenu<P extends BaseMenuProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: MenuConfig<C>,\n ref: MenuRef = null\n) {\n useEnsureSSRProvider();\n const { ariaProps } = asAriaMenuProps(props);\n const triggerContext = React.useContext(TriggeredOverlayContext);\n const rootRef = React.useRef<HTMLElement>(null);\n\n const state = useTreeState(ariaProps);\n\n const menuListRef = React.useRef<HTMLUListElement>(null);\n\n const { menuProps } = useAriaMenu(\n {\n ...ariaProps,\n autoFocus: triggerContext?.autoFocus,\n },\n state,\n menuListRef\n );\n\n const contextValue = React.useMemo(\n () => ({ state, menuProps: props }),\n [state, props]\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n },\n [config.itemsContainer]: {\n as: \"ul\",\n props: mergeProps(menuProps, {\n ref: menuListRef,\n style: {\n ...noOutline(),\n },\n }),\n },\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.itemsSlot]: (\n <MenuContext.Provider value={contextValue}>\n {Array.from(state.collection).map((node) => renderCollectionNode(node))}\n </MenuContext.Provider>\n ),\n };\n\n const plumeState: MenuState = React.useMemo(\n () => ({\n getFocusedValue: () => state.selectionManager.focusedKey as string | null,\n setFocusedValue: (value: string) =>\n state.selectionManager.setFocusedKey(value),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n getFocusedValue: () => plumeState.getFocusedValue(),\n setFocusedValue: (key) => plumeState.setFocusedValue(key),\n }),\n [rootRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n state: plumeState,\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useMenuSection } from \"@react-aria/menu\";\nimport { useSeparator } from \"@react-aria/separator\";\nimport { pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport { renderCollectionNode, SectionLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { MenuContext } from \"./context\";\n\nexport interface BaseMenuGroupProps extends SectionLikeProps, StyleProps {}\n\ninterface MenuGroupConfig<C extends AnyPlasmicClass> {\n noTitleVariant: PlasmicClassVariants<C>;\n isFirstVariant: PlasmicClassVariants<C>;\n\n itemsSlot: keyof PlasmicClassArgs<C>;\n titleSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n separator: keyof PlasmicClassOverrides<C>;\n titleContainer: keyof PlasmicClassOverrides<C>;\n itemsContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useMenuGroup<\n P extends BaseMenuGroupProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: MenuGroupConfig<C>) {\n const context = React.useContext(MenuContext);\n\n const node = (props as any)._node as\n | Node<React.ReactElement<BaseMenuGroupProps>>\n | undefined;\n\n if (!context || !node) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\"You can only use a Menu.Group within a Menu component.\");\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { headingProps, groupProps } = useMenuSection({\n heading: props.title,\n \"aria-label\": props[\"aria-label\"],\n });\n\n const { separatorProps } = useSeparator({\n elementType: \"li\",\n });\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.noTitleVariant, active: !props.title },\n {\n def: config.isFirstVariant,\n active: context.state.collection.getFirstKey() === node.key,\n }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.titleSlot]: props.title,\n [config.itemsSlot]: Array.from(node.childNodes).map((childNode) =>\n renderCollectionNode(childNode)\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: getStyleProps(props),\n },\n [config.separator]: {\n props: {\n ...separatorProps,\n },\n as: \"li\",\n },\n [config.titleContainer]: {\n props: {\n role: \"presentation\",\n ...headingProps,\n },\n ...(!props.title && {\n render: () => null,\n }),\n },\n [config.itemsContainer]: {\n props: {\n ...groupProps,\n },\n as: \"ul\",\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useMenuItem as useAriaMenuItem } from \"@react-aria/menu\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { ItemLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport { getDefaultPlasmicProps } from \"../props-utils\";\nimport { TriggeredOverlayContext } from \"../triggered-overlay/context\";\nimport { MenuContext } from \"./context\";\n\nexport interface BaseMenuItemProps extends ItemLikeProps {\n /**\n * Called when this item is selected\n */\n onAction?: (key: string) => void;\n}\n\ninterface MenuItemConfig<C extends AnyPlasmicClass> {\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n isHighlightedVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n labelSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n labelContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useMenuItem<\n P extends BaseMenuItemProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: MenuItemConfig<C>) {\n const menuContext = React.useContext(MenuContext);\n const triggerContext = React.useContext(TriggeredOverlayContext);\n\n if (!menuContext) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\"You can only use a Menu.Item within a Menu component.\");\n }\n\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children, onAction } = props;\n\n const { state, menuProps } = menuContext;\n\n // We pass in the Node secretly as an undocumented prop from <Select />\n const node = (props as any)._node as Node<\n React.ReactElement<BaseMenuItemProps>\n >;\n\n const isDisabled = state.disabledKeys.has(node.key);\n const isHighlighted =\n state.selectionManager.isFocused &&\n state.selectionManager.focusedKey === node.key;\n\n const ref = React.useRef<HTMLLIElement>(null);\n\n const { menuItemProps, labelProps } = useAriaMenuItem(\n mergeProps(\n {\n // We need to merge both the onAction on MenuItem and the onAction\n // on Menu\n onAction,\n },\n {\n onAction: menuProps.onAction,\n onClose: triggerContext?.state.close,\n },\n {\n isDisabled,\n \"aria-label\": node && node[\"aria-label\"],\n key: node.key,\n isVirtualized: false,\n closeOnSelect: true,\n }\n ),\n state,\n ref\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isDisabledVariant, active: isDisabled },\n { def: config.isHighlightedVariant, active: isHighlighted }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.labelSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n as: \"li\",\n props: mergeProps(menuItemProps, { ref, style: noOutline() }),\n },\n [config.labelContainer]: {\n props: { ...labelProps },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":["useAriaMenu","useAriaMenuItem"],"mappings":";;;;;;;;;;;;;;;;;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F,CAAC;IAEF,IAAM,IAAI,yBACL,IAAI,8BAAC,KAAK,UAAK,YAAY,CAAC,gBAAgB,0BAC9C,MAAM,CAAC,SAAS,IAAG,QAAQ,MAC7B,CAAC;IAEF,IAAM,SAAS;QACb,GAAC,MAAM,CAAC,IAAI,IAAG;YACb,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,UAAU,CAAC,aAAa,EAAE,EAAE,GAAG,KAAA,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC;SAC9D;QACD,GAAC,MAAM,CAAC,cAAc,IAAG;YACvB,KAAK,eAAO,UAAU,CAAE;SACzB;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/plume/menu/context.tsx","../../../../src/plume/menu/menu.tsx","../../../../src/plume/menu/menu-group.tsx","../../../../src/plume/menu/menu-item.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { TreeState } from \"@react-stately/tree\";\nimport type { BaseMenuProps } from \"./menu\";\n\nexport interface MenuContextValue {\n menuProps: BaseMenuProps;\n state: TreeState<any>;\n}\n\nexport const MenuContext = React.createContext<MenuContextValue | undefined>(\n undefined\n);\n","import { useMenu as useAriaMenu } from \"@react-aria/menu\";\nimport { useTreeState } from \"@react-stately/tree\";\nimport { AriaMenuProps } from \"@react-types/menu\";\nimport { AriaLabelingProps, DOMProps } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n renderAsCollectionChild,\n renderCollectionNode,\n useDerivedItemsFromChildren,\n} from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\nimport { TriggeredOverlayContext } from \"../triggered-overlay/context\";\nimport { MenuContext } from \"./context\";\n\nexport interface BaseMenuProps extends DOMProps, AriaLabelingProps, StyleProps {\n /**\n * List of `Menu.Item`s or `Menu.Group`s that make up the menu\n */\n children?: React.ReactNode;\n\n /**\n * Called with the value of a `Menu.Item` when it is selected.\n */\n onAction?: (value: string) => void;\n}\n\nexport type MenuRef = React.Ref<MenuRefValue>;\nexport interface MenuRefValue extends MenuState {\n getRoot: () => HTMLElement | null;\n}\n\nconst COLLECTION_OPTS = {\n itemPlumeType: \"menu-item\",\n sectionPlumeType: \"menu-group\",\n};\n\nexport interface MenuConfig<C extends AnyPlasmicClass> {\n isPlacedTopVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedBottomVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedLeftVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedRightVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n itemsSlot: keyof PlasmicClassArgs<C>;\n itemsContainer: keyof PlasmicClassOverrides<C>;\n root: keyof PlasmicClassOverrides<C>;\n}\n\n/**\n * Converts props from BaseMenuProps to react-aria's useMenu() props.\n */\nfunction asAriaMenuProps(props: BaseMenuProps) {\n const { children, ...rest } = props;\n const { items, disabledKeys } = useDerivedItemsFromChildren(children, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Menu.Item and Menu.Group as children to Menu`,\n requireItemValue: false,\n });\n\n const collectionChildRenderer = React.useCallback(\n (child: any) => renderAsCollectionChild(child, COLLECTION_OPTS),\n []\n );\n\n return {\n ariaProps: {\n ...rest,\n children: collectionChildRenderer,\n items,\n disabledKeys,\n } as AriaMenuProps<any>,\n };\n}\n\nexport interface MenuState {\n getFocusedValue: () => string | null;\n setFocusedValue: (value: string) => void;\n}\n\nexport function useMenu<P extends BaseMenuProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: MenuConfig<C>,\n ref: MenuRef = null\n) {\n useEnsureSSRProvider();\n const { ariaProps } = asAriaMenuProps(props);\n const triggerContext = React.useContext(TriggeredOverlayContext);\n const rootRef = React.useRef<HTMLElement>(null);\n\n const state = useTreeState(ariaProps);\n\n const menuListRef = React.useRef<HTMLUListElement>(null);\n\n const { menuProps } = useAriaMenu(\n {\n ...ariaProps,\n autoFocus: triggerContext?.autoFocus,\n },\n state,\n menuListRef\n );\n\n const contextValue = React.useMemo(() => ({ state, menuProps: props }), [\n state,\n props,\n ]);\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n },\n [config.itemsContainer]: {\n as: \"ul\",\n props: mergeProps(menuProps, {\n ref: menuListRef,\n style: {\n ...noOutline(),\n },\n }),\n },\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.itemsSlot]: (\n <MenuContext.Provider value={contextValue}>\n {Array.from(state.collection).map((node) => renderCollectionNode(node))}\n </MenuContext.Provider>\n ),\n };\n\n const plumeState: MenuState = React.useMemo(\n () => ({\n getFocusedValue: () => state.selectionManager.focusedKey as string | null,\n setFocusedValue: (value: string) =>\n state.selectionManager.setFocusedKey(value),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n getFocusedValue: () => plumeState.getFocusedValue(),\n setFocusedValue: (key) => plumeState.setFocusedValue(key),\n }),\n [rootRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n state: plumeState,\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useMenuSection } from \"@react-aria/menu\";\nimport { useSeparator } from \"@react-aria/separator\";\nimport { pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport { renderCollectionNode, SectionLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { MenuContext } from \"./context\";\n\nexport interface BaseMenuGroupProps extends SectionLikeProps, StyleProps {}\n\ninterface MenuGroupConfig<C extends AnyPlasmicClass> {\n noTitleVariant: PlasmicClassVariants<C>;\n isFirstVariant: PlasmicClassVariants<C>;\n\n itemsSlot: keyof PlasmicClassArgs<C>;\n titleSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n separator: keyof PlasmicClassOverrides<C>;\n titleContainer: keyof PlasmicClassOverrides<C>;\n itemsContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useMenuGroup<\n P extends BaseMenuGroupProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: MenuGroupConfig<C>) {\n const context = React.useContext(MenuContext);\n\n const node = (props as any)._node as\n | Node<React.ReactElement<BaseMenuGroupProps>>\n | undefined;\n\n if (!context || !node) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\"You can only use a Menu.Group within a Menu component.\");\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { headingProps, groupProps } = useMenuSection({\n heading: props.title,\n \"aria-label\": props[\"aria-label\"],\n });\n\n const { separatorProps } = useSeparator({\n elementType: \"li\",\n });\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.noTitleVariant, active: !props.title },\n {\n def: config.isFirstVariant,\n active: context.state.collection.getFirstKey() === node.key,\n }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.titleSlot]: props.title,\n [config.itemsSlot]: Array.from(node.childNodes).map((childNode) =>\n renderCollectionNode(childNode)\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: getStyleProps(props),\n },\n [config.separator]: {\n props: {\n ...separatorProps,\n },\n as: \"li\",\n },\n [config.titleContainer]: {\n props: {\n role: \"presentation\",\n ...headingProps,\n },\n ...(!props.title && {\n render: () => null,\n }),\n },\n [config.itemsContainer]: {\n props: {\n ...groupProps,\n },\n as: \"ul\",\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useMenuItem as useAriaMenuItem } from \"@react-aria/menu\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { ItemLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport { getDefaultPlasmicProps } from \"../props-utils\";\nimport { TriggeredOverlayContext } from \"../triggered-overlay/context\";\nimport { MenuContext } from \"./context\";\n\nexport interface BaseMenuItemProps extends ItemLikeProps {\n /**\n * Called when this item is selected\n */\n onAction?: (key: string) => void;\n}\n\ninterface MenuItemConfig<C extends AnyPlasmicClass> {\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n isHighlightedVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n labelSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n labelContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useMenuItem<\n P extends BaseMenuItemProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: MenuItemConfig<C>) {\n const menuContext = React.useContext(MenuContext);\n const triggerContext = React.useContext(TriggeredOverlayContext);\n\n if (!menuContext) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\"You can only use a Menu.Item within a Menu component.\");\n }\n\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children, onAction } = props;\n\n const { state, menuProps } = menuContext;\n\n // We pass in the Node secretly as an undocumented prop from <Select />\n const node = (props as any)._node as Node<\n React.ReactElement<BaseMenuItemProps>\n >;\n\n const isDisabled = state.disabledKeys.has(node.key);\n const isHighlighted =\n state.selectionManager.isFocused &&\n state.selectionManager.focusedKey === node.key;\n\n const ref = React.useRef<HTMLLIElement>(null);\n\n const { menuItemProps, labelProps } = useAriaMenuItem(\n mergeProps(\n {\n // We need to merge both the onAction on MenuItem and the onAction\n // on Menu\n onAction,\n },\n {\n onAction: menuProps.onAction,\n onClose: triggerContext?.state.close,\n },\n {\n isDisabled,\n \"aria-label\": node && node[\"aria-label\"],\n key: node.key,\n isVirtualized: false,\n closeOnSelect: true,\n }\n ),\n state,\n ref\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isDisabledVariant, active: isDisabled },\n { def: config.isHighlightedVariant, active: isHighlighted }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.labelSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n as: \"li\",\n props: mergeProps(menuItemProps, { ref, style: noOutline() }),\n },\n [config.labelContainer]: {\n props: { ...labelProps },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":["useAriaMenu","useAriaMenuItem"],"mappings":";;;;;;;;;;;;;;;;;AASO,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAC5C,SAAS,CACV;;ACgCD,IAAM,eAAe,GAAG;IACtB,aAAa,EAAE,WAAW;IAC1B,gBAAgB,EAAE,YAAY;CAC/B,CAAC;AAaF;;;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MAAM,CAAC,IAAI,IAAG;YACb,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,UAAU,CAAC,aAAa,EAAE,EAAE,GAAG,KAAA,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC;SAC9D;QACD,GAAC,MAAM,CAAC,cAAc,IAAG;YACvB,KAAK,eAAO,UAAU,CAAE;SACzB;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
@@ -1,9 +1,9 @@
1
1
  import { c as __assign, p as pick, d as __spreadArray, e as __read, b as __rest } from '../../common-c2744215.js';
2
- import * as React from 'react';
3
- import { useSelect as useSelect$1, HiddenSelect } from '@react-aria/select';
4
- import { useListBox, useOption, useListBoxSection } from '@react-aria/listbox';
5
2
  import { usePress } from '@react-aria/interactions';
3
+ import { useListBox, useOption, useListBoxSection } from '@react-aria/listbox';
4
+ import { useSelect as useSelect$1, HiddenSelect } from '@react-aria/select';
6
5
  import { useSelectState } from '@react-stately/select';
6
+ import * as React from 'react';
7
7
  import { m as mergeProps, d as mergeRefs } from '../../react-utils-76d05959.js';
8
8
  import { a as useEnsureSSRProvider } from '../../ssr-f6caec06.js';
9
9
  import { g as getChildProp, r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-b5d4be02.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/select/context.tsx","../../../../src/plume/select/select.tsx","../../../../src/plume/select/select-option.tsx","../../../../src/plume/select/select-option-group.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ListState } from \"@react-stately/list\";\n\nexport const SelectContext = React.createContext<ListState<any> | undefined>(\n undefined\n);\n","import { Placement } from \"@react-types/overlays\";\nimport { AriaSelectProps } from \"@react-types/select\";\nimport {\n AriaLabelingProps,\n DOMProps,\n FocusableDOMProps,\n FocusableProps,\n InputBase,\n} from \"@react-types/shared\";\nimport * as React from \"react\";\nimport {\n HiddenSelect,\n useSelect as useAriaSelect,\n} from \"@react-aria/select\";\nimport {\n useListBox\n} from \"@react-aria/listbox\";\nimport {\n usePress\n} from \"@react-aria/interactions\";\nimport {\n SelectState as AriaSelectState,\n useSelectState as useAriaSelectState,\n} from \"@react-stately/select\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n getChildProp,\n renderAsCollectionChild,\n renderCollectionNode,\n useDerivedItemsFromChildren,\n} from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\nimport {\n TriggeredOverlayContext,\n TriggeredOverlayContextValue,\n} from \"../triggered-overlay/context\";\nimport { SelectContext } from \"./context\";\nimport { BaseSelectOptionProps } from \"./select-option\";\nimport { BaseSelectOptionGroupProps } from \"./select-option-group\";\n\nexport interface BaseSelectProps\n extends DOMProps,\n AriaLabelingProps,\n FocusableDOMProps,\n InputBase,\n FocusableProps,\n StyleProps {\n /**\n * Key of the currently selected value\n */\n value?: string | null;\n\n /**\n * Event handler fired when currently selected value changes\n */\n onChange?: (value: string | null) => void;\n\n /**\n * Uncontrolled key of the default selected value\n */\n defaultValue?: string;\n\n /**\n * List of Select.Options\n */\n children?: React.ReactNode;\n\n /**\n * Whether the Select is currently open\n */\n isOpen?: boolean;\n\n /**\n * Event handler fired when Select's open state changes\n */\n onOpenChange?: (isOpen: boolean) => void;\n\n /**\n * Uncontrolled default open state\n */\n defaultOpen?: boolean;\n\n /**\n * Form name of the select element\n */\n name?: string;\n\n /**\n * By default, Select will render whatever is in Select.Option as the\n * content in the trigger button when it is selected. You can override\n * what content by passing in `selectedContent` here.\n */\n selectedContent?: React.ReactNode;\n\n /**\n * Desired placement location of the Select dropdown\n */\n placement?: Placement;\n\n /**\n * If true, menu width will always match the trigger button width.\n * If false, then menu width will have min-width matching the\n * trigger button width.\n */\n menuMatchTriggerWidth?: boolean;\n\n /**\n * If set, menu width will be exactly this width, overriding\n * menuMatchTriggerWidth.\n */\n menuWidth?: number;\n\n /**\n * Content to display when nothing is selected.\n */\n placeholder?: React.ReactNode;\n}\n\nconst COLLECTION_OPTS = {\n itemPlumeType: \"select-option\",\n sectionPlumeType: \"select-option-group\",\n};\n\ntype AriaOptionType = React.ReactElement<BaseSelectOptionProps>;\ntype AriaGroupType = React.ReactElement<BaseSelectOptionGroupProps>;\ntype AriaSelectItemType = AriaOptionType | AriaGroupType;\n\n/**\n * Converts props in our BaseSelectProps into props that react-aria's\n * useSelect() understands.\n *\n * Because we're not exposing the Collections API (see ./index.tsx),\n * we are converting our own API into props for useSelect.\n *\n * Specifically, in Plume's API,\n * - `children` flattens to a list of ReactElements of type Select.Option\n * or Select.OptionGroup\n *\n * and we map it this way to the Collections API:\n * - `items` is a list of those flattened ReactElements from `children`!\n * - `children`, as a render prop, is supposed to take one of the `items`\n * and return a `Section` or `Item` element. We take an Option/OptionGroup\n * element, and use its props to render the appropriate `Section` or\n * `Item`. The \"trick\" here is that we then stuff the Option element as\n * `Item.children`, and the OptionGroup element as `Section.title`.\n *\n * When the Collections API does its work deriving `Node`s, the corresponding\n * Option/OptionGroup ReactElements will end up as `Node.rendered`.\n *\n * Then, when we are actually rendering the content of the dropdown, we\n * iterate through each collected `Node`, and renders\n * React.cloneElement(Node.rendered, {_node: node}). This \"secretly\" passes\n * the derived collection `Node` as a prop to Option and OptionGroup, and they\n * can make use of the derived `Node.key` etc in their rendering functions.\n *\n * One thing to note here is that we never \"rendered\" the Option/OptionGroup\n * React elements that the user constructed; instead, we just looked at the\n * props used on those elements, and passed those onto the Collections API.\n * What gets rendered to the screen is the cloned version of these elements\n * with the secret derived `_node` prop. That means Option and OptionGroup\n * render functions can assume that _node is passed in.\n */\nfunction useAriaSelectProps(props: BaseSelectProps) {\n let {\n value,\n defaultValue,\n children,\n onChange,\n placement,\n menuMatchTriggerWidth,\n menuWidth,\n ...rest\n } = props;\n\n const { items, disabledKeys } = useDerivedItemsFromChildren(children, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Select.Option and Select.OptionGroup as children to Select`,\n requireItemValue: true,\n });\n\n const collectionChildRenderer = React.useCallback(\n (child) => renderAsCollectionChild(child, COLLECTION_OPTS),\n []\n );\n\n const onSelectionChange = React.useMemo(() => {\n if (onChange) {\n return (val: string | null) =>\n onChange!(\n (val == null || val === \"null\" ? null : val) as string | null\n );\n } else {\n return undefined;\n }\n }, [onChange]);\n\n return {\n ariaProps: {\n ...rest,\n children: collectionChildRenderer,\n onSelectionChange,\n items,\n disabledKeys,\n defaultSelectedKey: defaultValue,\n\n // react-aria is picky about selectedKey; if it is null, it means \"no selection\";\n // if it is undefined, it means \"uncontrolled\". So here, if the user passes in a\n // value prop, then we make sure selectedKey will be null and not undefined, so\n // we don't accidentally enter uncontrolled mode.\n ...(\"value\" in props && { selectedKey: value ?? null }),\n } as AriaSelectProps<AriaSelectItemType>,\n };\n}\n\nexport type SelectRef = React.Ref<SelectRefValue>;\n\nexport interface SelectRefValue extends SelectState {\n getTrigger: () => HTMLElement | null;\n getRoot: () => HTMLElement | null;\n focus: () => void;\n blur: () => void;\n}\n\ninterface SelectConfig<C extends AnyPlasmicClass> {\n placeholderVariant?: VariantDef<PlasmicClassVariants<C>>;\n isOpenVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n triggerContentSlot: keyof PlasmicClassArgs<C>;\n optionsSlot: keyof PlasmicClassArgs<C>;\n placeholderSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n trigger: keyof PlasmicClassOverrides<C>;\n overlay: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\ninterface SelectState {\n open: () => void;\n close: () => void;\n isOpen: () => boolean;\n getSelectedValue: () => string | null;\n setSelectedValue: (value: string | null) => void;\n}\n\nexport function useSelect<P extends BaseSelectProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: SelectConfig<C>,\n ref: React.Ref<SelectRefValue> = null\n) {\n useEnsureSSRProvider();\n const { ariaProps } = useAriaSelectProps(props);\n const { placement } = props;\n const state = useAriaSelectState<AriaSelectItemType>(ariaProps);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const rootRef = React.useRef<HTMLElement>(null);\n\n const {\n isDisabled,\n name,\n menuWidth,\n menuMatchTriggerWidth,\n autoFocus,\n placeholder,\n selectedContent,\n } = props;\n\n const { triggerProps: triggerPressProps, menuProps } = useAriaSelect(\n ariaProps,\n state,\n triggerRef\n );\n\n const { pressProps: triggerProps } = usePress({\n ...triggerPressProps,\n isDisabled,\n });\n\n const triggerContent = state.selectedItem\n ? selectedContent ?? getChildProp(state.selectedItem.value, \"children\")\n : null;\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isOpenVariant, active: state.isOpen },\n { def: config.placeholderVariant, active: !state.selectedItem },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const triggerContext: TriggeredOverlayContextValue = React.useMemo(\n () => ({\n triggerRef,\n state,\n placement,\n overlayMatchTriggerWidth: menuMatchTriggerWidth,\n overlayMinTriggerWidth: true,\n overlayWidth: menuWidth,\n }),\n [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]\n );\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n wrapChildren: (children) => (\n <>\n <HiddenSelect\n state={state}\n triggerRef={triggerRef}\n name={name}\n isDisabled={isDisabled}\n />\n {children}\n </>\n ),\n },\n [config.trigger]: {\n props: mergeProps(triggerProps, {\n ref: triggerRef,\n autoFocus,\n disabled: !!isDisabled,\n // Don't trigger form submission!\n type: \"button\",\n }),\n },\n [config.overlay]: {\n wrap: (content) => (\n <TriggeredOverlayContext.Provider value={triggerContext}>\n {content}\n </TriggeredOverlayContext.Provider>\n ),\n },\n [config.optionsContainer]: {\n wrap: (content) => (\n <ListBoxWrapper state={state} menuProps={menuProps}>\n {content as React.ReactElement}\n </ListBoxWrapper>\n ),\n },\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.triggerContentSlot]: triggerContent,\n [config.placeholderSlot]: placeholder,\n [config.optionsSlot]: (\n <SelectContext.Provider value={state}>\n {Array.from(state.collection).map((node) => renderCollectionNode(node))}\n </SelectContext.Provider>\n ),\n };\n\n const plumeState: SelectState = React.useMemo(\n () => ({\n open: () => state.open(),\n close: () => state.close(),\n isOpen: () => state.isOpen,\n getSelectedValue: () =>\n state.selectedKey ? `${state.selectedKey}` : null,\n setSelectedValue: (key) => state.setSelectedKey(key as any),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n getTrigger: () => triggerRef.current,\n focus: () => triggerRef.current?.focus(),\n blur: () => triggerRef.current?.blur(),\n open: () => plumeState.open(),\n close: () => plumeState.close(),\n isOpen: () => plumeState.isOpen(),\n getSelectedValue: () => plumeState.getSelectedValue(),\n setSelectedValue: (key) => plumeState.setSelectedValue(key),\n }),\n [rootRef, triggerRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n state: plumeState,\n };\n}\n\nfunction ListBoxWrapper(props: {\n state: AriaSelectState<any>;\n menuProps: React.HTMLAttributes<Element>;\n children: React.ReactElement;\n}) {\n const { state, menuProps, children } = props;\n\n const ref = React.useRef<HTMLElement>(null);\n\n const { listBoxProps } = useListBox(\n {\n ...menuProps,\n isVirtualized: false,\n autoFocus: state.focusStrategy || true,\n disallowEmptySelection: true,\n },\n state,\n ref\n );\n\n return React.cloneElement(\n children,\n mergeProps(children.props, listBoxProps, { style: noOutline(), ref })\n );\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useOption as useAriaOption } from \"@react-aria/listbox\";\nimport { pick } from \"../../common\";\nimport { mergeProps, mergeRefs } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { ItemLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionProps extends ItemLikeProps, StyleProps {}\n\ninterface SelectOptionConfig<C extends AnyPlasmicClass> {\n isSelectedVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n isHighlightedVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n labelSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n labelContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type SelectOptionRef = React.Ref<HTMLElement>;\n\nexport function useSelectOption<\n P extends BaseSelectOptionProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: SelectOptionConfig<C>,\n outerRef: SelectOptionRef = null\n) {\n const state = React.useContext(SelectContext);\n\n if (!state) {\n // If no context, then we are being incorrectly used. Complain or just don't\n // bother installing any hooks. It's okay to violate rules of hooks here\n // because this instance won't suddenly be used correctly in another render.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.Option within a Select component.\"\n );\n }\n\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n\n const rootRef = React.useRef<HTMLElement>(null);\n const onRef = mergeRefs(rootRef, outerRef);\n\n // We pass in the Node secretly as an undocumented prop from <Select />\n const node = (props as any)._node as Node<\n React.ReactElement<BaseSelectOptionProps>\n >;\n\n const isSelected = state.selectionManager.isSelected(node.key);\n const isDisabled = state.disabledKeys.has(node.key);\n const isHighlighted =\n state.selectionManager.isFocused &&\n state.selectionManager.focusedKey === node.key;\n\n const { optionProps, labelProps } = useAriaOption(\n {\n isSelected,\n isDisabled,\n \"aria-label\": node && node[\"aria-label\"],\n key: node.key,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n isVirtualized: false,\n },\n state,\n rootRef\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isSelectedVariant, active: isSelected },\n { def: config.isDisabledVariant, active: isDisabled },\n { def: config.isHighlightedVariant, active: isHighlighted }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.labelSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(optionProps, getStyleProps(props), {\n ref: onRef,\n style: noOutline(),\n }),\n },\n [config.labelContainer]: {\n props: labelProps,\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useListBoxSection } from \"@react-aria/listbox\";\nimport { useSeparator } from \"@react-aria/separator\";\nimport { pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport { renderCollectionNode, SectionLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionGroupProps\n extends SectionLikeProps,\n StyleProps {}\n\ninterface SelectOptionGroupConfig<C extends AnyPlasmicClass> {\n noTitleVariant: PlasmicClassVariants<C>;\n isFirstVariant: PlasmicClassVariants<C>;\n\n optionsSlot: keyof PlasmicClassArgs<C>;\n titleSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n separator: keyof PlasmicClassOverrides<C>;\n titleContainer: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useSelectOptionGroup<\n P extends BaseSelectOptionGroupProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: SelectOptionGroupConfig<C>) {\n const state = React.useContext(SelectContext);\n\n // `node` should exist if the OptionGroup was instantiated properly\n // within a Select\n const node = (props as any)._node as\n | Node<React.ReactElement<BaseSelectOptionGroupProps>>\n | undefined;\n\n if (!state || !node) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.OptionGroup within a Select component.\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { headingProps, groupProps } = useListBoxSection({\n heading: props.title,\n \"aria-label\": props[\"aria-label\"],\n });\n\n const { separatorProps } = useSeparator({\n elementType: \"li\",\n });\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.noTitleVariant, active: !props.title },\n {\n def: config.isFirstVariant,\n active: state.collection.getFirstKey() === node.key,\n }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.titleSlot]: props.title,\n [config.optionsSlot]: Array.from(node.childNodes).map((childNode) =>\n renderCollectionNode(childNode)\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: getStyleProps(props),\n },\n [config.separator]: {\n props: {\n ...separatorProps,\n },\n },\n [config.titleContainer]: {\n props: {\n role: \"presentation\",\n ...headingProps,\n },\n ...(!props.title && {\n render: () => null,\n }),\n },\n [config.optionsContainer]: {\n props: {\n ...groupProps,\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":["useAriaSelectState","useAriaSelect","useAriaOption"],"mappings":";;;;;;;;;;;;;;;;;;;IAGa,aAAa,GAAG,KAAK,CAAC,aAAa,CAC9C,SAAS;;AC8HX,IAAM,eAAe,GAAG;IACtB,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,qBAAqB;CACxC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,kBAAkB,CAAC,KAAsB;QAE9C,KAAK,GAQH,KAAK,MARF,EACL,YAAY,GAOV,KAAK,aAPK,EACZ,QAAQ,GAMN,KAAK,SANC,EACR,QAAQ,GAKN,KAAK,SALC,EAKN,KAAK,UAJE,EAIP,KAAK,sBAHc,EAGnB,KAAK,UAFE,MACN,IAAI,UACL,KAAK,EATL,oGASH,EAAS;IAEJ,IAAA,KAA0B,2BAA2B,CAAC,QAAQ,wBAC/D,eAAe,KAClB,iBAAiB,EAAE,yEAAyE,EAC5F,gBAAgB,EAAE,IAAI,IACtB,EAJM,KAAK,WAAA,EAAE,YAAY,kBAIzB,CAAC;IAEH,IAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAC/C,UAAC,KAAK,IAAK,OAAA,uBAAuB,CAAC,KAAK,EAAE,eAAe,CAAC,GAAA,EAC1D,EAAE,CACH,CAAC;IAEF,IAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC;QACtC,IAAI,QAAQ,EAAE;YACZ,OAAO,UAAC,GAAkB;gBACxB,OAAA,QAAS,EACN,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,MAAM,GAAG,IAAI,GAAG,GAAG,EAC5C;aAAA,CAAC;SACL;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;KACF,EAAE,C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QACD,GAAC,MAAM,CAAC,gBAAgB,IAAG;YACzB,KAAK,eACA,UAAU,CACd;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/plume/select/context.tsx","../../../../src/plume/select/select.tsx","../../../../src/plume/select/select-option.tsx","../../../../src/plume/select/select-option-group.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ListState } from \"@react-stately/list\";\n\nexport const SelectContext = React.createContext<ListState<any> | undefined>(\n undefined\n);\n","import { usePress } from \"@react-aria/interactions\";\nimport { useListBox } from \"@react-aria/listbox\";\nimport { HiddenSelect, useSelect as useAriaSelect } from \"@react-aria/select\";\nimport {\n SelectState as AriaSelectState,\n useSelectState as useAriaSelectState,\n} from \"@react-stately/select\";\nimport { Placement } from \"@react-types/overlays\";\nimport { AriaSelectProps } from \"@react-types/select\";\nimport {\n AriaLabelingProps,\n DOMProps,\n FocusableDOMProps,\n FocusableProps,\n InputBase,\n} from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n getChildProp,\n renderAsCollectionChild,\n renderCollectionNode,\n useDerivedItemsFromChildren,\n} from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\nimport {\n TriggeredOverlayContext,\n TriggeredOverlayContextValue,\n} from \"../triggered-overlay/context\";\nimport { SelectContext } from \"./context\";\nimport { BaseSelectOptionProps } from \"./select-option\";\nimport { BaseSelectOptionGroupProps } from \"./select-option-group\";\n\nexport interface BaseSelectProps\n extends DOMProps,\n AriaLabelingProps,\n FocusableDOMProps,\n InputBase,\n FocusableProps,\n StyleProps {\n /**\n * Key of the currently selected value\n */\n value?: string | null;\n\n /**\n * Event handler fired when currently selected value changes\n */\n onChange?: (value: string | null) => void;\n\n /**\n * Uncontrolled key of the default selected value\n */\n defaultValue?: string;\n\n /**\n * List of Select.Options\n */\n children?: React.ReactNode;\n\n /**\n * Whether the Select is currently open\n */\n isOpen?: boolean;\n\n /**\n * Event handler fired when Select's open state changes\n */\n onOpenChange?: (isOpen: boolean) => void;\n\n /**\n * Uncontrolled default open state\n */\n defaultOpen?: boolean;\n\n /**\n * Form name of the select element\n */\n name?: string;\n\n /**\n * By default, Select will render whatever is in Select.Option as the\n * content in the trigger button when it is selected. You can override\n * what content by passing in `selectedContent` here.\n */\n selectedContent?: React.ReactNode;\n\n /**\n * Desired placement location of the Select dropdown\n */\n placement?: Placement;\n\n /**\n * If true, menu width will always match the trigger button width.\n * If false, then menu width will have min-width matching the\n * trigger button width.\n */\n menuMatchTriggerWidth?: boolean;\n\n /**\n * If set, menu width will be exactly this width, overriding\n * menuMatchTriggerWidth.\n */\n menuWidth?: number;\n\n /**\n * Content to display when nothing is selected.\n */\n placeholder?: React.ReactNode;\n}\n\nconst COLLECTION_OPTS = {\n itemPlumeType: \"select-option\",\n sectionPlumeType: \"select-option-group\",\n};\n\ntype AriaOptionType = React.ReactElement<BaseSelectOptionProps>;\ntype AriaGroupType = React.ReactElement<BaseSelectOptionGroupProps>;\ntype AriaSelectItemType = AriaOptionType | AriaGroupType;\n\n/**\n * Converts props in our BaseSelectProps into props that react-aria's\n * useSelect() understands.\n *\n * Because we're not exposing the Collections API (see ./index.tsx),\n * we are converting our own API into props for useSelect.\n *\n * Specifically, in Plume's API,\n * - `children` flattens to a list of ReactElements of type Select.Option\n * or Select.OptionGroup\n *\n * and we map it this way to the Collections API:\n * - `items` is a list of those flattened ReactElements from `children`!\n * - `children`, as a render prop, is supposed to take one of the `items`\n * and return a `Section` or `Item` element. We take an Option/OptionGroup\n * element, and use its props to render the appropriate `Section` or\n * `Item`. The \"trick\" here is that we then stuff the Option element as\n * `Item.children`, and the OptionGroup element as `Section.title`.\n *\n * When the Collections API does its work deriving `Node`s, the corresponding\n * Option/OptionGroup ReactElements will end up as `Node.rendered`.\n *\n * Then, when we are actually rendering the content of the dropdown, we\n * iterate through each collected `Node`, and renders\n * React.cloneElement(Node.rendered, {_node: node}). This \"secretly\" passes\n * the derived collection `Node` as a prop to Option and OptionGroup, and they\n * can make use of the derived `Node.key` etc in their rendering functions.\n *\n * One thing to note here is that we never \"rendered\" the Option/OptionGroup\n * React elements that the user constructed; instead, we just looked at the\n * props used on those elements, and passed those onto the Collections API.\n * What gets rendered to the screen is the cloned version of these elements\n * with the secret derived `_node` prop. That means Option and OptionGroup\n * render functions can assume that _node is passed in.\n */\nfunction useAriaSelectProps(props: BaseSelectProps) {\n let {\n value,\n defaultValue,\n children,\n onChange,\n placement,\n menuMatchTriggerWidth,\n menuWidth,\n ...rest\n } = props;\n\n const { items, disabledKeys } = useDerivedItemsFromChildren(children, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Select.Option and Select.OptionGroup as children to Select`,\n requireItemValue: true,\n });\n\n const collectionChildRenderer = React.useCallback(\n (child: any) => renderAsCollectionChild(child, COLLECTION_OPTS),\n []\n );\n\n const onSelectionChange = React.useMemo(() => {\n if (onChange) {\n return (val: string | null) =>\n onChange!(\n (val == null || val === \"null\" ? null : val) as string | null\n );\n } else {\n return undefined;\n }\n }, [onChange]);\n\n return {\n ariaProps: {\n ...rest,\n children: collectionChildRenderer,\n onSelectionChange,\n items,\n disabledKeys,\n defaultSelectedKey: defaultValue,\n\n // react-aria is picky about selectedKey; if it is null, it means \"no selection\";\n // if it is undefined, it means \"uncontrolled\". So here, if the user passes in a\n // value prop, then we make sure selectedKey will be null and not undefined, so\n // we don't accidentally enter uncontrolled mode.\n ...(\"value\" in props && { selectedKey: value ?? null }),\n } as AriaSelectProps<AriaSelectItemType>,\n };\n}\n\nexport type SelectRef = React.Ref<SelectRefValue>;\n\nexport interface SelectRefValue extends SelectState {\n getTrigger: () => HTMLElement | null;\n getRoot: () => HTMLElement | null;\n focus: () => void;\n blur: () => void;\n}\n\ninterface SelectConfig<C extends AnyPlasmicClass> {\n placeholderVariant?: VariantDef<PlasmicClassVariants<C>>;\n isOpenVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n triggerContentSlot: keyof PlasmicClassArgs<C>;\n optionsSlot: keyof PlasmicClassArgs<C>;\n placeholderSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n trigger: keyof PlasmicClassOverrides<C>;\n overlay: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\ninterface SelectState {\n open: () => void;\n close: () => void;\n isOpen: () => boolean;\n getSelectedValue: () => string | null;\n setSelectedValue: (value: string | null) => void;\n}\n\nexport function useSelect<P extends BaseSelectProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: SelectConfig<C>,\n ref: React.Ref<SelectRefValue> = null\n) {\n useEnsureSSRProvider();\n const { ariaProps } = useAriaSelectProps(props);\n const { placement } = props;\n const state = useAriaSelectState<AriaSelectItemType>(ariaProps);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const rootRef = React.useRef<HTMLElement>(null);\n\n const {\n isDisabled,\n name,\n menuWidth,\n menuMatchTriggerWidth,\n autoFocus,\n placeholder,\n selectedContent,\n } = props;\n\n const { triggerProps: triggerPressProps, menuProps } = useAriaSelect(\n ariaProps,\n state,\n triggerRef\n );\n\n const { pressProps: triggerProps } = usePress({\n ...triggerPressProps,\n isDisabled,\n });\n\n const triggerContent = state.selectedItem\n ? selectedContent ?? getChildProp(state.selectedItem.value, \"children\")\n : null;\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isOpenVariant, active: state.isOpen },\n { def: config.placeholderVariant, active: !state.selectedItem },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const triggerContext: TriggeredOverlayContextValue = React.useMemo(\n () => ({\n triggerRef,\n state,\n placement,\n overlayMatchTriggerWidth: menuMatchTriggerWidth,\n overlayMinTriggerWidth: true,\n overlayWidth: menuWidth,\n }),\n [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]\n );\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n wrapChildren: (children) => (\n <>\n <HiddenSelect\n state={state}\n triggerRef={triggerRef}\n name={name}\n isDisabled={isDisabled}\n />\n {children}\n </>\n ),\n },\n [config.trigger]: {\n props: mergeProps(triggerProps, {\n ref: triggerRef,\n autoFocus,\n disabled: !!isDisabled,\n // Don't trigger form submission!\n type: \"button\",\n }),\n },\n [config.overlay]: {\n wrap: (content) => (\n <TriggeredOverlayContext.Provider value={triggerContext}>\n {content}\n </TriggeredOverlayContext.Provider>\n ),\n },\n [config.optionsContainer]: {\n wrap: (content) => (\n <ListBoxWrapper state={state} menuProps={menuProps}>\n {content as React.ReactElement}\n </ListBoxWrapper>\n ),\n },\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.triggerContentSlot]: triggerContent,\n [config.placeholderSlot]: placeholder,\n [config.optionsSlot]: (\n <SelectContext.Provider value={state}>\n {Array.from(state.collection).map((node) => renderCollectionNode(node))}\n </SelectContext.Provider>\n ),\n };\n\n const plumeState: SelectState = React.useMemo(\n () => ({\n open: () => state.open(),\n close: () => state.close(),\n isOpen: () => state.isOpen,\n getSelectedValue: () =>\n state.selectedKey ? `${state.selectedKey}` : null,\n setSelectedValue: (key) => state.setSelectedKey(key as any),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n getTrigger: () => triggerRef.current,\n focus: () => triggerRef.current?.focus(),\n blur: () => triggerRef.current?.blur(),\n open: () => plumeState.open(),\n close: () => plumeState.close(),\n isOpen: () => plumeState.isOpen(),\n getSelectedValue: () => plumeState.getSelectedValue(),\n setSelectedValue: (key) => plumeState.setSelectedValue(key),\n }),\n [rootRef, triggerRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n state: plumeState,\n };\n}\n\nfunction ListBoxWrapper(props: {\n state: AriaSelectState<any>;\n menuProps: React.HTMLAttributes<Element>;\n children: React.ReactElement;\n}) {\n const { state, menuProps, children } = props;\n\n const ref = React.useRef<HTMLElement>(null);\n\n const { listBoxProps } = useListBox(\n {\n ...menuProps,\n isVirtualized: false,\n autoFocus: state.focusStrategy || true,\n disallowEmptySelection: true,\n },\n state,\n ref\n );\n\n return React.cloneElement(\n children,\n mergeProps(children.props, listBoxProps, { style: noOutline(), ref })\n );\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useOption as useAriaOption } from \"@react-aria/listbox\";\nimport { pick } from \"../../common\";\nimport { mergeProps, mergeRefs } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { ItemLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionProps extends ItemLikeProps, StyleProps {}\n\ninterface SelectOptionConfig<C extends AnyPlasmicClass> {\n isSelectedVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n isHighlightedVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n labelSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n labelContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type SelectOptionRef = React.Ref<HTMLElement>;\n\nexport function useSelectOption<\n P extends BaseSelectOptionProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: SelectOptionConfig<C>,\n outerRef: SelectOptionRef = null\n) {\n const state = React.useContext(SelectContext);\n\n if (!state) {\n // If no context, then we are being incorrectly used. Complain or just don't\n // bother installing any hooks. It's okay to violate rules of hooks here\n // because this instance won't suddenly be used correctly in another render.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.Option within a Select component.\"\n );\n }\n\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n\n const rootRef = React.useRef<HTMLElement>(null);\n const onRef = mergeRefs(rootRef, outerRef);\n\n // We pass in the Node secretly as an undocumented prop from <Select />\n const node = (props as any)._node as Node<\n React.ReactElement<BaseSelectOptionProps>\n >;\n\n const isSelected = state.selectionManager.isSelected(node.key);\n const isDisabled = state.disabledKeys.has(node.key);\n const isHighlighted =\n state.selectionManager.isFocused &&\n state.selectionManager.focusedKey === node.key;\n\n const { optionProps, labelProps } = useAriaOption(\n {\n isSelected,\n isDisabled,\n \"aria-label\": node && node[\"aria-label\"],\n key: node.key,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n isVirtualized: false,\n },\n state,\n rootRef\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isSelectedVariant, active: isSelected },\n { def: config.isDisabledVariant, active: isDisabled },\n { def: config.isHighlightedVariant, active: isHighlighted }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.labelSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(optionProps, getStyleProps(props), {\n ref: onRef,\n style: noOutline(),\n }),\n },\n [config.labelContainer]: {\n props: labelProps,\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useListBoxSection } from \"@react-aria/listbox\";\nimport { useSeparator } from \"@react-aria/separator\";\nimport { pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport { renderCollectionNode, SectionLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionGroupProps\n extends SectionLikeProps,\n StyleProps {}\n\ninterface SelectOptionGroupConfig<C extends AnyPlasmicClass> {\n noTitleVariant: PlasmicClassVariants<C>;\n isFirstVariant: PlasmicClassVariants<C>;\n\n optionsSlot: keyof PlasmicClassArgs<C>;\n titleSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n separator: keyof PlasmicClassOverrides<C>;\n titleContainer: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useSelectOptionGroup<\n P extends BaseSelectOptionGroupProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: SelectOptionGroupConfig<C>) {\n const state = React.useContext(SelectContext);\n\n // `node` should exist if the OptionGroup was instantiated properly\n // within a Select\n const node = (props as any)._node as\n | Node<React.ReactElement<BaseSelectOptionGroupProps>>\n | undefined;\n\n if (!state || !node) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.OptionGroup within a Select component.\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { headingProps, groupProps } = useListBoxSection({\n heading: props.title,\n \"aria-label\": props[\"aria-label\"],\n });\n\n const { separatorProps } = useSeparator({\n elementType: \"li\",\n });\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.noTitleVariant, active: !props.title },\n {\n def: config.isFirstVariant,\n active: state.collection.getFirstKey() === node.key,\n }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.titleSlot]: props.title,\n [config.optionsSlot]: Array.from(node.childNodes).map((childNode) =>\n renderCollectionNode(childNode)\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: getStyleProps(props),\n },\n [config.separator]: {\n props: {\n ...separatorProps,\n },\n },\n [config.titleContainer]: {\n props: {\n role: \"presentation\",\n ...headingProps,\n },\n ...(!props.title && {\n render: () => null,\n }),\n },\n [config.optionsContainer]: {\n props: {\n ...groupProps,\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":["useAriaSelectState","useAriaSelect","useAriaOption"],"mappings":";;;;;;;;;;;;;;;;;;;IAGa,aAAa,GAAG,KAAK,CAAC,aAAa,CAC9C,SAAS;;ACuHX,IAAM,eAAe,GAAG;IACtB,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,qBAAqB;CACxC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,kBAAkB,CAAC,KAAsB;QAE9C,KAAK,GAQH,KAAK,MARF,EACL,YAAY,GAOV,KAAK,aAPK,EACZ,QAAQ,GAMN,KAAK,SANC,EACR,QAAQ,GAKN,KAAK,SALC,EAKN,KAAK,UAJE,EAIP,KAAK,sBAHc,EAGnB,KAAK,UAFE,MACN,IAAI,UACL,KAAK,EATL,oGASH,EAAS;IAEJ,IAAA,KAA0B,2BAA2B,CAAC,QAAQ,wBAC/D,eAA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C,KAAK,KAC9B,MAAM,CAAC,WAAW,IAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,UAAC,SAAS;QAC9D,OAAA,oBAAoB,CAAC,SAAS,CAAC;KAAA,CAChC,MACF,CAAC;IAEF,IAAM,SAAS;QACb,GAAC,MAAM,CAAC,IAAI,IAAG;YACb,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;SAC5B;QACD,GAAC,MAAM,CAAC,SAAS,IAAG;YAClB,KAAK,eACA,cAAc,CAClB;SACF;QACD,GAAC,MAAM,CAAC,cAAc,eACpB,KAAK,aACH,IAAI,EAAE,cAAc,IACjB,YAAY,MAEb,CAAC,KAAK,CAAC,KAAK,IAAI;YAClB,MAAM,EAAE,cAAM,OAAA,IAAI,GAAA;SACnB,EACF;QACD,GAAC,MAAM,CAAC,gBAAgB,IAAG;YACzB,KAAK,eACA,UAAU,CACd;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
@@ -46,7 +46,9 @@ export declare function wrapFlexContainerChildren(children: React.ReactNode, has
46
46
  className: string;
47
47
  }, HTMLElement> | null;
48
48
  export declare function createPlasmicElementProxy<DefaultElementType extends React.ElementType>(defaultElement: DefaultElementType, props: Partial<React.ComponentProps<DefaultElementType>>, ...children: React.ReactNode[]): React.ReactNode;
49
- export declare function makeFragment(...children: React.ReactNode[]): React.FunctionComponentElement<{}>;
49
+ export declare function makeFragment(...children: React.ReactNode[]): React.FunctionComponentElement<{
50
+ children?: React.ReactNode;
51
+ }>;
50
52
  export declare const UNSET: unique symbol;
51
53
  export declare function wrapWithClassName(element: React.ReactNode, className: string): React.DetailedReactHTMLElement<{
52
54
  key: React.Key | undefined;