@plasmicapp/react-web 0.2.161 → 0.2.162

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.161",
3
+ "version": "0.2.162",
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,9 +40,9 @@
40
40
  },
41
41
  "prettier": {},
42
42
  "dependencies": {
43
- "@plasmicapp/data-sources": "0.1.39",
43
+ "@plasmicapp/data-sources": "0.1.40",
44
44
  "@plasmicapp/data-sources-context": "0.1.6",
45
- "@plasmicapp/host": "1.0.107",
45
+ "@plasmicapp/host": "1.0.108",
46
46
  "@plasmicapp/query": "0.1.61",
47
47
  "@react-aria/checkbox": "^3.5.0",
48
48
  "@react-aria/focus": "^3.7.0",
@@ -109,5 +109,5 @@
109
109
  "react": ">=16.8.0",
110
110
  "react-dom": ">=16.8.0"
111
111
  },
112
- "gitHead": "345916a2f99a5b4015f1415f26335d003d404715"
112
+ "gitHead": "42a82273c10229969e148da489db70aa88859c4a"
113
113
  }
@@ -60,6 +60,45 @@ import { g as getPlumeType, P as PLUME_STRICT_MODE } from './plume-utils-653f4b8
60
60
  * of list of Item/Section elements. This is for efficiency, but we are opting
61
61
  * to only support the composite-component pattern for now for simplicity.
62
62
  */
63
+ function deriveItemsFromProps(props, opts) {
64
+ if (opts.itemsProp && opts.itemsProp in props) {
65
+ if (!opts.ItemComponent || !opts.SectionComponent) {
66
+ throw new Error("You may need to re-generate your Plasmic* files");
67
+ }
68
+ var items = props[opts.itemsProp];
69
+ return deriveItemsFromItemsProp(items, {
70
+ ItemComponent: opts.ItemComponent,
71
+ SectionComponent: opts.SectionComponent
72
+ });
73
+ }
74
+ else {
75
+ return deriveItemsFromChildren(props.children, opts);
76
+ }
77
+ }
78
+ function deriveItemsFromItemsProp(items, opts) {
79
+ var _a;
80
+ var ItemComponent = opts.ItemComponent, SectionComponent = opts.SectionComponent;
81
+ var disabledKeys = [];
82
+ var transform = function (item) {
83
+ var _a;
84
+ if (typeof item === "string") {
85
+ return (React__default.createElement(ItemComponent, { key: item, value: item }, item));
86
+ }
87
+ else if ("children" in item) {
88
+ return (React__default.createElement(SectionComponent, { key: item.title, title: item.title }, item.children.map(function (x) { return transform(x); })));
89
+ }
90
+ else {
91
+ if (item.isDisabled) {
92
+ disabledKeys.push(item.value);
93
+ }
94
+ return (React__default.createElement(ItemComponent, { key: item.value, value: item.value, textValue: item.textValue, isDisabled: item.isDisabled }, (_a = item.label) !== null && _a !== void 0 ? _a : item.value));
95
+ }
96
+ };
97
+ return {
98
+ items: (_a = items === null || items === void 0 ? void 0 : items.map(function (x) { return transform(x); })) !== null && _a !== void 0 ? _a : [],
99
+ disabledKeys: disabledKeys
100
+ };
101
+ }
63
102
  /**
64
103
  * Given children of a component like Select or Menu, derive the items
65
104
  * that we will pass into the Collections API. These will be
@@ -132,6 +171,31 @@ function deriveItemsFromChildren(children, opts) {
132
171
  };
133
172
  return { items: flattenedChildren(children), disabledKeys: disabledKeys };
134
173
  }
174
+ function useDerivedItems(props, opts) {
175
+ var children = props.children;
176
+ var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError, requireItemValue = opts.requireItemValue, ItemComponent = opts.ItemComponent, SectionComponent = opts.SectionComponent, itemsProp = opts.itemsProp;
177
+ var items = itemsProp ? props[itemsProp] : undefined;
178
+ return React__default.useMemo(function () {
179
+ return deriveItemsFromProps(props, {
180
+ itemPlumeType: itemPlumeType,
181
+ sectionPlumeType: sectionPlumeType,
182
+ invalidChildError: invalidChildError,
183
+ requireItemValue: requireItemValue,
184
+ itemsProp: itemsProp,
185
+ ItemComponent: ItemComponent,
186
+ SectionComponent: SectionComponent
187
+ });
188
+ }, [
189
+ children,
190
+ items,
191
+ itemPlumeType,
192
+ sectionPlumeType,
193
+ invalidChildError,
194
+ requireItemValue,
195
+ ItemComponent,
196
+ SectionComponent,
197
+ ]);
198
+ }
135
199
  function useDerivedItemsFromChildren(children, opts) {
136
200
  var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError, requireItemValue = opts.requireItemValue;
137
201
  return React__default.useMemo(function () {
@@ -235,5 +299,5 @@ function cloneChild(child, props) {
235
299
  return React__default.cloneElement(child, props);
236
300
  }
237
301
 
238
- export { renderAsCollectionChild as a, getChildProp as g, renderCollectionNode as r, useDerivedItemsFromChildren as u };
239
- //# sourceMappingURL=collection-utils-b5d4be02.js.map
302
+ export { renderAsCollectionChild as a, useDerivedItems as b, getChildProp as g, renderCollectionNode as r, useDerivedItemsFromChildren as u };
303
+ //# sourceMappingURL=collection-utils-3496fd68.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-utils-3496fd68.js","sources":["../../src/plume/collection-utils.tsx"],"sourcesContent":["/**\n * In general, we try not to expose react-aria's Collections API to Plume users.\n * The Collections API is how react-aria users pass data about collections of\n * things using the built-in Item and Section components, which are abstract,\n * metadata-only components that don't render anything but only serve to specify\n * data. For example, here's how you would use react-spectrum's Picker:\n *\n * <Picker>\n * <Section title=\"Asia\">\n * <Item key=\"taiwan\">Taiwan</Item>\n * <Item key=\"japan\">Japan</Item>\n * <Item key=\"china\">China</Item>\n * </Section>\n * <Section title=\"Europe\">\n * <Item key=\"germany\">Germany</Item>\n * <Item key=\"france\">France</Item>\n * </Section>\n * </Picker>\n *\n * You would re-use this same Item/Section components to pass similar things to\n * Menu, Tabs, etc.\n *\n * For Plasmic, this API is too abstract. The user has explicitly designed components\n * like Select.Option and Select.OptionGroup, and it is weird that they don't actually\n * use these components. It is more natural to do:\n *\n * <Select>\n * <Select.OptionGroup title=\"Asia\">\n * <Select.Option key=\"taiwan\">Taiwan</Select>\n * </Select.OptionGroup>\n * </Select>\n *\n * For Plume, we let users directly use the components they designed, both to collect\n * information and to perform actual rendering. For example, for Plume,\n * you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.\n * This means that the Select.Option props will collect the same information Item\n * does.\n *\n * A component like Select.Option then serves two purposes:\n *\n * 1. Allow users to specify the collection of data, like in the above example\n * Here, we're mainly interested in the props in those ReactElements so\n * we can pass the Item/Section data onto react-aria's APIs. We are not\n * actually rendering these elements.\n * 2. Once react-aria's Collections API has gone through them and built\n * Collection \"nodes\", we then create cloned versions of these elements\n * with the corresponding node passed in as a secret prop. These ReactElements\n * are then actually used to _render_ the corresponding Option / OptionGroup.\n *\n * This file contains helper functions to help with implementing the above.\n *\n * Note also that most of the collections-based react-aria components expose\n * a parallel API that accepts a list of \"items\" and a render prop, instead\n * of list of Item/Section elements. This is for efficiency, but we are opting\n * to only support the composite-component pattern for now for simplicity.\n */\n\nimport { Item, Section } from \"@react-stately/collections\";\nimport { Node } from \"@react-types/shared\";\nimport React from \"react\";\nimport { isString } from \"../common\";\nimport { getElementTypeName, toChildArray } from \"../react-utils\";\nimport { getPlumeType, PLUME_STRICT_MODE } from \"./plume-utils\";\n\nexport interface PlasmicLoaderProps<T> {\n component: string;\n componentProps: T;\n}\n\n/**\n * Props for a Plume component that corresponds to an Item\n */\nexport interface ItemLikeProps {\n /**\n * value key corresponding to this item. Not required if you use the\n * `key` prop instead.\n */\n value?: string | null;\n\n /**\n * The text string value corresponding to this item. Used to support\n * keyboard type-ahead. If not specified, then will be derived from\n * `children` if it is a string, or the `value` or `key`.\n */\n textValue?: string;\n\n /**\n * aria-label for this item.\n */\n \"aria-label\"?: string;\n\n /**\n * Primary content label for this item.\n */\n children?: React.ReactNode;\n\n /**\n * If true, this item will not be selectable.\n */\n isDisabled?: boolean;\n}\n\ntype LoaderAwareItemLikeProps =\n | ItemLikeProps\n | PlasmicLoaderProps<ItemLikeProps>;\n\n/**\n * Props for a Plume component that corresponds to a Section\n */\nexport interface SectionLikeProps {\n /**\n * Heading content of the title\n */\n title?: React.ReactNode;\n\n /**\n * aria-label for this section\n */\n \"aria-label\"?: string;\n\n /**\n * A list of items that belong in this group\n */\n children?: React.ReactNode;\n}\n\ntype LoaderAwareSectionLikeProps =\n | SectionLikeProps\n | PlasmicLoaderProps<SectionLikeProps>;\n\nexport type ItemJson = LeafItemJson | SectionJson;\n\nexport type LeafItemJson =\n | string\n | {\n value: string;\n label?: string;\n textValue?: string;\n isDisabled?: boolean;\n };\n\nexport interface SectionJson {\n title: string;\n children: ItemJson[];\n}\n\nexport function deriveItemsFromProps(\n props: any,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n ItemComponent?: React.ComponentType<ItemLikeProps>;\n SectionComponent?: React.ComponentType<SectionLikeProps>;\n itemsProp?: string;\n }\n) {\n if (opts.itemsProp && opts.itemsProp in props) {\n if (!opts.ItemComponent || !opts.SectionComponent) {\n throw new Error(`You may need to re-generate your Plasmic* files`);\n }\n const items = props[opts.itemsProp] as ItemJson[] | undefined;\n return deriveItemsFromItemsProp(items, {\n ItemComponent: opts.ItemComponent,\n SectionComponent: opts.SectionComponent,\n });\n } else {\n return deriveItemsFromChildren(props.children as React.ReactNode, opts);\n }\n}\n\nfunction deriveItemsFromItemsProp(\n items: ItemJson[] | undefined,\n opts: {\n ItemComponent: React.ComponentType<ItemLikeProps>;\n SectionComponent: React.ComponentType<SectionLikeProps>;\n }\n) {\n const { ItemComponent, SectionComponent } = opts;\n const disabledKeys: string[] = [];\n const transform = (item: ItemJson) => {\n if (typeof item === \"string\") {\n return (\n <ItemComponent key={item} value={item}>\n {item}\n </ItemComponent>\n );\n } else if (\"children\" in item) {\n return (\n <SectionComponent key={item.title} title={item.title}>\n {item.children.map((x) => transform(x))}\n </SectionComponent>\n );\n } else {\n if (item.isDisabled) {\n disabledKeys.push(item.value);\n }\n return (\n <ItemComponent\n key={item.value}\n value={item.value}\n textValue={item.textValue}\n isDisabled={item.isDisabled}\n >\n {item.label ?? item.value}\n </ItemComponent>\n );\n }\n };\n return {\n items: items?.map((x) => transform(x)) ?? [],\n disabledKeys,\n };\n}\n\n/**\n * Given children of a component like Select or Menu, derive the items\n * that we will pass into the Collections API. These will be\n * ReactElement<ItemLikeProps|SectionLikeProps>[].\n *\n * Will also assign keys to items by their index in the collection,\n * and collect the keys of disabled items.\n */\nexport function deriveItemsFromChildren<T extends React.ReactElement>(\n children: React.ReactNode,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n }\n) {\n if (!children) {\n return {\n items: [] as T[],\n disabledKeys: [] as React.Key[],\n };\n }\n\n const { itemPlumeType, sectionPlumeType, invalidChildError } = opts;\n\n // For Plume items without an explicit key, we assign a key as the index\n // of the collection.\n let itemCount = 0;\n let sectionCount = 0;\n\n const ensureValue = (element: React.ReactElement) => {\n if (!propInChild(element, \"value\")) {\n if (opts.requireItemValue && PLUME_STRICT_MODE) {\n throw new Error(\n `Must specify a \"value\" prop for ${getElementTypeName(element)}`\n );\n } else {\n return cloneChild(element, { value: `${itemCount++}` });\n }\n } else {\n // Still increment count even if key is present, so that the\n // auto-assigned key really reflects the index\n itemCount++;\n return element;\n }\n };\n\n const disabledKeys: React.Key[] = [];\n\n const flattenedChildren = (\n children: React.ReactNode\n ): React.ReactElement[] => {\n return toChildArray(children).flatMap((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return flattenedChildren(\n (child as React.ReactElement<{ children: React.ReactNode }>).props\n .children\n );\n }\n const type = getPlumeType(child);\n if (type === itemPlumeType) {\n child = ensureValue(child);\n const childKey = getItemLikeKey(child);\n if (getChildProp(child, \"isDisabled\") && !!childKey) {\n disabledKeys.push(childKey);\n }\n return [child];\n }\n if (type === sectionPlumeType) {\n return [\n cloneChild(child, {\n // key of section doesn't actually matter, just needs\n // to be unique\n key: child.key ?? `section-${sectionCount++}`,\n children: flattenedChildren(getChildProp(child, \"children\")),\n }),\n ];\n }\n }\n\n if (PLUME_STRICT_MODE) {\n throw new Error(invalidChildError ?? `Unexpected child`);\n } else {\n return [];\n }\n });\n };\n\n return { items: flattenedChildren(children) as T[], disabledKeys };\n}\n\nexport function useDerivedItems(\n props: any,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n ItemComponent?: React.ComponentType<ItemLikeProps>;\n SectionComponent?: React.ComponentType<SectionLikeProps>;\n itemsProp?: string;\n }\n) {\n const { children } = props;\n const {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n ItemComponent,\n SectionComponent,\n itemsProp,\n } = opts;\n const items = itemsProp ? props[itemsProp] : undefined;\n return React.useMemo(() => {\n return deriveItemsFromProps(props, {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n itemsProp,\n ItemComponent,\n SectionComponent,\n });\n }, [\n children,\n items,\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n ItemComponent,\n SectionComponent,\n ]);\n}\n\nexport function useDerivedItemsFromChildren<T extends React.ReactElement>(\n children: React.ReactNode,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n }\n) {\n const {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n } = opts;\n return React.useMemo(() => {\n return deriveItemsFromChildren<T>(children, {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n });\n }, [\n children,\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n ]);\n}\n\n/**\n * Given a Collection node, create the React element that we should use\n * to render it.\n */\nexport function renderCollectionNode(node: Node<any>) {\n // node.rendered should already have our item-like or section-like Plume\n // component elements, so we just need to clone them with a secret\n // _node prop that we use to render.\n return cloneChild(node.rendered as React.ReactElement, {\n _node: node,\n key: node.key,\n });\n}\n\n/**\n * Renders a item-like or section-like Plume component element into an\n * Item or a Section element.\n */\nexport function renderAsCollectionChild<\n T extends React.ReactElement<\n LoaderAwareItemLikeProps | LoaderAwareSectionLikeProps\n >\n>(\n child: T,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n }\n) {\n const plumeType = getPlumeType(child);\n if (plumeType === opts.itemPlumeType) {\n const option = child as React.ReactElement<LoaderAwareItemLikeProps>;\n\n // We look at the children passed to the item-like element, and derive key\n // or textValue from it if it is a string\n const content = getChildProp(option, \"children\");\n\n // The children render prop needs to return an <Item/>\n return (\n <Item\n // We use ItemLike.value if the user explicitly specified a value,\n // and we fallback to key. If the user specified neither, then\n // the Collections API will generate a unique key for this item.\n key={getItemLikeKey(option)}\n // textValue is either explicitly specified by the user, or we\n // try to derive it if `content` is a string.\n textValue={\n getChildProp(option, \"textValue\") ??\n (isString(content)\n ? content\n : propInChild(option, \"value\")\n ? getChildProp(option, \"value\")\n : option.key)\n }\n aria-label={getChildProp(option, \"aria-label\")}\n >\n {\n // Note that what we setting the item-like element as the children\n // here, and not content; we want the entire item-like Plume element to\n // end up as Node.rendered.\n }\n {option}\n </Item>\n );\n } else {\n const group = child as React.ReactElement<LoaderAwareSectionLikeProps>;\n return (\n <Section\n // Note that we are using the whole section-like element as the title\n // here, and not group.props.title; we want the entire section-like\n // Plume element to end up as Node.rendered.\n title={group}\n aria-label={getChildProp(group, \"aria-label\")}\n // We are flattening and deriving the descendant Options as items here.\n // group.props.children should've already been cleaned up by\n // deriveItemsFromChildren()\n items={getChildProp(group, \"children\") as React.ReactElement[]}\n >\n {\n // We use the same render function to turn descendent Options into Items\n }\n {(c: React.ReactElement) => renderAsCollectionChild(c, opts)}\n </Section>\n );\n }\n}\n\nfunction getItemLikeKey(element: React.ReactElement<LoaderAwareItemLikeProps>) {\n return getChildProp(element, \"value\") ?? element.key;\n}\n\n// PlasmicLoader-aware function to get prop from child.\nexport function getChildProp(child: React.ReactElement, prop: string) {\n return \"componentProps\" in child.props\n ? child.props.componentProps[prop]\n : child.props[prop];\n}\n\n// PlasmicLoader-aware function to check `if (prop in element.props)`.\nfunction propInChild(child: React.ReactElement, prop: string): boolean {\n return \"componentProps\" in child.props\n ? prop in child.props.componentProps\n : prop in child.props;\n}\n\n// PlasmicLoader-aware function to clone React element.\nfunction cloneChild(child: React.ReactElement, props: Record<string, any>) {\n if ((child.type as any).getPlumeType) {\n // If React element has getPlumeType(), assume that it is PlasmicLoader,\n // so add nodeProps to componentProps instead of element props.\n return React.cloneElement(child, {\n componentProps: {\n ...child.props.componentProps,\n ...props,\n },\n ...(props.key ? { key: props.key } : {}),\n });\n }\n\n return React.cloneElement(child, props);\n}\n"],"names":["React"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAkJgB,oBAAoB,CAClC,KAAU,EACV,IAQC;IAED,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,IAAI,KAAK,EAAE;QAC7C,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACpE;QACD,IAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAA2B,CAAC;QAC9D,OAAO,wBAAwB,CAAC,KAAK,EAAE;YACrC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC,CAAC;KACJ;SAAM;QACL,OAAO,uBAAuB,CAAC,KAAK,CAAC,QAA2B,EAAE,IAAI,CAAC,CAAC;KACzE;AACH,CAAC;AAED,SAAS,wBAAwB,CAC/B,KAA6B,EAC7B,IAGC;;IAEO,IAAA,aAAa,GAAuB,IAAI,cAA3B,EAAE,gBAAgB,GAAK,IAAI,iBAAT,CAAU;IACjD,IAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAM,SAAS,GAAG,UAAC,IAAc;;QAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;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EAAE,KAAK,CAAC,CAAC;AAC1C;;;;"}
@@ -107,6 +107,32 @@ export interface SectionLikeProps {
107
107
  children?: React.ReactNode;
108
108
  }
109
109
  type LoaderAwareSectionLikeProps = SectionLikeProps | PlasmicLoaderProps<SectionLikeProps>;
110
+ export type ItemJson = LeafItemJson | SectionJson;
111
+ export type LeafItemJson = string | {
112
+ value: string;
113
+ label?: string;
114
+ textValue?: string;
115
+ isDisabled?: boolean;
116
+ };
117
+ export interface SectionJson {
118
+ title: string;
119
+ children: ItemJson[];
120
+ }
121
+ export declare function deriveItemsFromProps(props: any, opts: {
122
+ itemPlumeType: string;
123
+ sectionPlumeType?: string;
124
+ invalidChildError?: string;
125
+ requireItemValue: boolean;
126
+ ItemComponent?: React.ComponentType<ItemLikeProps>;
127
+ SectionComponent?: React.ComponentType<SectionLikeProps>;
128
+ itemsProp?: string;
129
+ }): {
130
+ items: JSX.Element[];
131
+ disabledKeys: string[];
132
+ } | {
133
+ items: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
134
+ disabledKeys: React.Key[];
135
+ };
110
136
  /**
111
137
  * Given children of a component like Select or Menu, derive the items
112
138
  * that we will pass into the Collections API. These will be
@@ -124,6 +150,21 @@ export declare function deriveItemsFromChildren<T extends React.ReactElement>(ch
124
150
  items: T[];
125
151
  disabledKeys: React.Key[];
126
152
  };
153
+ export declare function useDerivedItems(props: any, opts: {
154
+ itemPlumeType: string;
155
+ sectionPlumeType?: string;
156
+ invalidChildError?: string;
157
+ requireItemValue: boolean;
158
+ ItemComponent?: React.ComponentType<ItemLikeProps>;
159
+ SectionComponent?: React.ComponentType<SectionLikeProps>;
160
+ itemsProp?: string;
161
+ }): {
162
+ items: JSX.Element[];
163
+ disabledKeys: string[];
164
+ } | {
165
+ items: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
166
+ disabledKeys: React.Key[];
167
+ };
127
168
  export declare function useDerivedItemsFromChildren<T extends React.ReactElement>(children: React.ReactNode, opts: {
128
169
  itemPlumeType: string;
129
170
  sectionPlumeType?: string;
@@ -4,7 +4,7 @@ import { useTreeState } from '@react-stately/tree';
4
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
- import { r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-b5d4be02.js';
7
+ import { r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-3496fd68.js';
8
8
  import { n as noOutline, m as mergeVariantToggles } from '../../plume-utils-653f4b8a.js';
9
9
  import { g as getStyleProps } from '../../props-utils-70c2d02a.js';
10
10
  import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
@@ -1,4 +1,5 @@
1
1
  import { c as __assign, p as pick, d as __spreadArray, e as __read, b as __rest } from '../../common-c2744215.js';
2
+ import { usePlasmicCanvasContext } from '@plasmicapp/host';
2
3
  import { usePress } from '@react-aria/interactions';
3
4
  import { useListBox, useOption, useListBoxSection } from '@react-aria/listbox';
4
5
  import { useSelect as useSelect$1, HiddenSelect } from '@react-aria/select';
@@ -6,7 +7,7 @@ import { useSelectState } from '@react-stately/select';
6
7
  import * as React from 'react';
7
8
  import { m as mergeProps, d as mergeRefs } from '../../react-utils-76d05959.js';
8
9
  import { a as useEnsureSSRProvider } from '../../ssr-f6caec06.js';
9
- import { g as getChildProp, r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-b5d4be02.js';
10
+ import { g as getChildProp, r as renderCollectionNode, b as useDerivedItems, a as renderAsCollectionChild } from '../../collection-utils-3496fd68.js';
10
11
  import { m as mergeVariantToggles, n as noOutline } from '../../plume-utils-653f4b8a.js';
11
12
  import { g as getStyleProps } from '../../props-utils-70c2d02a.js';
12
13
  import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
@@ -58,9 +59,9 @@ var COLLECTION_OPTS = {
58
59
  * with the secret derived `_node` prop. That means Option and OptionGroup
59
60
  * render functions can assume that _node is passed in.
60
61
  */
61
- function useAriaSelectProps(props) {
62
- var value = props.value, defaultValue = props.defaultValue, children = props.children, onChange = props.onChange; props.placement; props.menuMatchTriggerWidth; props.menuWidth; var rest = __rest(props, ["value", "defaultValue", "children", "onChange", "placement", "menuMatchTriggerWidth", "menuWidth"]);
63
- var _a = useDerivedItemsFromChildren(children, __assign(__assign({}, COLLECTION_OPTS), { invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select", requireItemValue: true })), items = _a.items, disabledKeys = _a.disabledKeys;
62
+ function useAriaSelectProps(props, config) {
63
+ var value = props.value, defaultValue = props.defaultValue; props.children; var onChange = props.onChange; props.placement; props.menuMatchTriggerWidth; props.menuWidth; var rest = __rest(props, ["value", "defaultValue", "children", "onChange", "placement", "menuMatchTriggerWidth", "menuWidth"]);
64
+ var _a = useDerivedItems(props, __assign(__assign({}, COLLECTION_OPTS), { invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select", requireItemValue: true, ItemComponent: config.OptionComponent, SectionComponent: config.OptionGroupComponent, itemsProp: "options" })), items = _a.items, disabledKeys = _a.disabledKeys;
64
65
  var collectionChildRenderer = React.useCallback(function (child) { return renderAsCollectionChild(child, COLLECTION_OPTS); }, []);
65
66
  var onSelectionChange = React.useMemo(function () {
66
67
  if (onChange) {
@@ -80,12 +81,13 @@ function useSelect(plasmicClass, props, config, ref) {
80
81
  var _a, _b;
81
82
  if (ref === void 0) { ref = null; }
82
83
  useEnsureSSRProvider();
83
- var ariaProps = useAriaSelectProps(props).ariaProps;
84
+ var ariaProps = useAriaSelectProps(props, config).ariaProps;
84
85
  var placement = props.placement;
85
86
  var state = useSelectState(ariaProps);
86
87
  var triggerRef = React.useRef(null);
87
88
  var rootRef = React.useRef(null);
88
89
  var isDisabled = props.isDisabled, name = props.name, menuWidth = props.menuWidth, menuMatchTriggerWidth = props.menuMatchTriggerWidth, autoFocus = props.autoFocus, placeholder = props.placeholder, selectedContent = props.selectedContent;
90
+ var canvasCtx = usePlasmicCanvasContext();
89
91
  var _c = useSelect$1(ariaProps, state, triggerRef), triggerPressProps = _c.triggerProps, menuProps = _c.menuProps;
90
92
  var triggerProps = usePress(__assign(__assign({}, triggerPressProps), { isDisabled: isDisabled })).pressProps;
91
93
  var triggerContent = state.selectedItem
@@ -106,11 +108,11 @@ function useSelect(plasmicClass, props, config, ref) {
106
108
  ref: rootRef
107
109
  }),
108
110
  wrapChildren: function (children) { return (React.createElement(React.Fragment, null,
109
- React.createElement(HiddenSelect, { state: state, triggerRef: triggerRef, name: name, isDisabled: isDisabled }),
111
+ !canvasCtx && (React.createElement(HiddenSelect, { state: state, triggerRef: triggerRef, name: name, isDisabled: isDisabled })),
110
112
  children)); }
111
113
  },
112
114
  _a[config.trigger] = {
113
- props: mergeProps(triggerProps, {
115
+ props: mergeProps(canvasCtx ? {} : triggerProps, {
114
116
  ref: triggerRef,
115
117
  autoFocus: autoFocus,
116
118
  disabled: !!isDisabled,
@@ -158,8 +160,12 @@ function useSelect(plasmicClass, props, config, ref) {
158
160
  function ListBoxWrapper(props) {
159
161
  var state = props.state, menuProps = props.menuProps, children = props.children;
160
162
  var ref = React.useRef(null);
163
+ var canvasCtx = usePlasmicCanvasContext();
161
164
  var listBoxProps = useListBox(__assign(__assign({}, menuProps), { isVirtualized: false, autoFocus: state.focusStrategy || true, disallowEmptySelection: true }), state, ref).listBoxProps;
162
- return React.cloneElement(children, mergeProps(children.props, listBoxProps, { style: noOutline(), ref: ref }));
165
+ return React.cloneElement(children, mergeProps(children.props, canvasCtx ? {} : listBoxProps, {
166
+ style: noOutline(),
167
+ ref: ref
168
+ }));
163
169
  }
164
170
 
165
171
  function useSelectOption(plasmicClass, props, config, outerRef) {
@@ -175,6 +181,7 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
175
181
  }
176
182
  }
177
183
  var children = props.children;
184
+ var canvasCtx = usePlasmicCanvasContext();
178
185
  var rootRef = React.useRef(null);
179
186
  var onRef = mergeRefs(rootRef, outerRef);
180
187
  // We pass in the Node secretly as an undocumented prop from <Select />
@@ -190,13 +197,14 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
190
197
  key: node.key,
191
198
  shouldSelectOnPressUp: true,
192
199
  shouldFocusOnHover: true,
193
- isVirtualized: false
200
+ isVirtualized: false,
201
+ shouldUseVirtualFocus: !!canvasCtx
194
202
  }, state, rootRef), optionProps = _c.optionProps, labelProps = _c.labelProps;
195
203
  var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isSelectedVariant, active: isSelected }, { def: config.isDisabledVariant, active: isDisabled }, { def: config.isHighlightedVariant, active: isHighlighted }));
196
204
  var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.labelSlot] = children, _a));
197
205
  var overrides = (_b = {},
198
206
  _b[config.root] = {
199
- props: mergeProps(optionProps, getStyleProps(props), {
207
+ props: mergeProps(canvasCtx ? {} : optionProps, getStyleProps(props), {
200
208
  ref: onRef,
201
209
  style: noOutline()
202
210
  })
@@ -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 { 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":";;;;;;;;;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"}
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 { usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport { 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 ItemJson,\n ItemLikeProps,\n renderAsCollectionChild,\n renderCollectionNode,\n SectionLikeProps,\n useDerivedItems,\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 * List of options as an array, instead of using `children` prop. If this\n * is passed in, then `children` is ignored.\n *\n * The options can be a list of strings, or a list of objects with\n * fields `value` (for the value of the option), `label` (for what's rendered\n * in the option), and `isDisabled` (if the option should be disabled).\n */\n options?: ItemJson[];\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, config: SelectConfig<any>) {\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 } = useDerivedItems(props, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Select.Option and Select.OptionGroup as children to Select`,\n requireItemValue: true,\n ItemComponent: config.OptionComponent,\n SectionComponent: config.OptionGroupComponent,\n itemsProp: \"options\",\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 OptionComponent?: React.ComponentType<ItemLikeProps>;\n OptionGroupComponent?: React.ComponentType<SectionLikeProps>;\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, config);\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 canvasCtx = usePlasmicCanvasContext();\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 {!canvasCtx && (\n <HiddenSelect\n state={state}\n triggerRef={triggerRef}\n name={name}\n isDisabled={isDisabled}\n />\n )}\n {children}\n </>\n ),\n },\n [config.trigger]: {\n props: mergeProps(canvasCtx ? {} : 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 const canvasCtx = usePlasmicCanvasContext();\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, canvasCtx ? {} : listBoxProps, {\n style: noOutline(),\n ref,\n })\n );\n}\n","import { usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport { useOption as useAriaOption } from \"@react-aria/listbox\";\nimport { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\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 canvasCtx = usePlasmicCanvasContext();\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 shouldUseVirtualFocus: !!canvasCtx,\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(canvasCtx ? {} : 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;;ACqIX,IAAM,eAAe,GAAG;IACtB,aAAa,EAAE,eAAe;IAC9B,gB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M,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;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { Placement } from "@react-types/overlays";
2
2
  import { AriaLabelingProps, DOMProps, FocusableDOMProps, FocusableProps, InputBase } from "@react-types/shared";
3
3
  import * as React from "react";
4
+ import { ItemJson, ItemLikeProps, SectionLikeProps } from "../collection-utils";
4
5
  import { AnyPlasmicClass, PlasmicClassArgs, PlasmicClassOverrides, PlasmicClassVariants, VariantDef } from "../plume-utils";
5
6
  import { StyleProps } from "../props-utils";
6
7
  export interface BaseSelectProps extends DOMProps, AriaLabelingProps, FocusableDOMProps, InputBase, FocusableProps, StyleProps {
@@ -20,6 +21,15 @@ export interface BaseSelectProps extends DOMProps, AriaLabelingProps, FocusableD
20
21
  * List of Select.Options
21
22
  */
22
23
  children?: React.ReactNode;
24
+ /**
25
+ * List of options as an array, instead of using `children` prop. If this
26
+ * is passed in, then `children` is ignored.
27
+ *
28
+ * The options can be a list of strings, or a list of objects with
29
+ * fields `value` (for the value of the option), `label` (for what's rendered
30
+ * in the option), and `isDisabled` (if the option should be disabled).
31
+ */
32
+ options?: ItemJson[];
23
33
  /**
24
34
  * Whether the Select is currently open
25
35
  */
@@ -80,6 +90,8 @@ interface SelectConfig<C extends AnyPlasmicClass> {
80
90
  trigger: keyof PlasmicClassOverrides<C>;
81
91
  overlay: keyof PlasmicClassOverrides<C>;
82
92
  optionsContainer: keyof PlasmicClassOverrides<C>;
93
+ OptionComponent?: React.ComponentType<ItemLikeProps>;
94
+ OptionGroupComponent?: React.ComponentType<SectionLikeProps>;
83
95
  }
84
96
  interface SelectState {
85
97
  open: () => void;
@@ -1,7 +1,8 @@
1
1
  import { e as __read, c as __assign, p as pick, d as __spreadArray } from '../../common-c2744215.js';
2
- import * as React from 'react';
3
- import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
2
+ import { usePlasmicCanvasContext } from '@plasmicapp/host';
4
3
  import { FocusScope } from '@react-aria/focus';
4
+ import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
5
+ import * as React from 'react';
5
6
  import * as ReactDOM from 'react-dom';
6
7
  import { d as mergeRefs, u as useIsomorphicLayoutEffect, m as mergeProps } from '../../react-utils-76d05959.js';
7
8
  import { m as mergeVariantToggles } from '../../plume-utils-653f4b8a.js';
@@ -78,7 +79,8 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
78
79
  }
79
80
  }, overlayAriaProps, overlayPositionProps);
80
81
  var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isPlacedTopVariant, active: placementAxis === "top" }, { def: config.isPlacedBottomVariant, active: placementAxis === "bottom" }, { def: config.isPlacedLeftVariant, active: placementAxis === "left" }, { def: config.isPlacedRightVariant, active: placementAxis === "right" }));
81
- var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.contentSlot] = (React.createElement(FocusScope, { restoreFocus: true },
82
+ var canvasCtx = usePlasmicCanvasContext();
83
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.contentSlot] = canvasCtx ? (children) : (React.createElement(FocusScope, { restoreFocus: true },
82
84
  React.createElement(DismissButton, { onDismiss: state.close }),
83
85
  children)), _a));
84
86
  var overrides = (_b = {},
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/triggered-overlay/triggered-overlay.tsx"],"sourcesContent":["import { DOMProps } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport {\n DismissButton,\n useOverlay,\n useOverlayPosition,\n} from \"@react-aria/overlays\";\nimport { FocusScope } from \"@react-aria/focus\";\nimport * as ReactDOM from \"react-dom\";\nimport { pick } from \"../../common\";\nimport {\n mergeProps,\n mergeRefs,\n useIsomorphicLayoutEffect,\n} from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\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 { TriggeredOverlayContext } from \"./context\";\n\nexport interface BaseTriggeredOverlayProps extends StyleProps, DOMProps {\n children?: React.ReactNode;\n}\n\nexport interface TriggeredOverlayConfig<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 contentSlot: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n contentContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type TriggeredOverlayRef = React.Ref<HTMLElement>;\n\nexport function useTriggeredOverlay<\n P extends BaseTriggeredOverlayProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: TriggeredOverlayConfig<C>,\n outerRef: TriggeredOverlayRef = null,\n isDismissable = true\n) {\n const overlayRef = React.useRef<HTMLElement>(null);\n const onOverlayRef = mergeRefs(overlayRef, outerRef);\n\n const context = React.useContext(TriggeredOverlayContext);\n\n if (!context) {\n // If no context, then we are not being correctly used. Either complain, or\n // exit early. It's okay to exit early and break the rules of React hooks\n // because we won't suddenly have the appropriate context anyway for this instance.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a triggered overlay with a TriggeredOverlayContext\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n const {\n triggerRef,\n placement,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n overlayWidth,\n state,\n } = context;\n\n // Measure the width of the trigger to inform the width of the menu (below).\n const [isRendered, setRendered] = React.useState(false);\n const triggerWidth =\n triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ? triggerRef.current.offsetWidth\n : undefined;\n\n useIsomorphicLayoutEffect(() => {\n if (\n !isRendered &&\n triggerRef.current &&\n (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ) {\n setRendered(true);\n }\n }, [\n triggerRef,\n isRendered,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n ]);\n\n const { overlayProps: overlayAriaProps } = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n isDismissable,\n shouldCloseOnBlur: true,\n },\n overlayRef\n );\n\n const {\n overlayProps: overlayPositionProps,\n updatePosition,\n placement: placementAxis,\n } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n placement: placement ?? \"bottom left\",\n shouldFlip: true,\n isOpen: state.isOpen,\n onClose: state.close,\n containerPadding: 0,\n });\n\n useIsomorphicLayoutEffect(() => {\n if (state.isOpen) {\n requestAnimationFrame(() => {\n updatePosition();\n });\n }\n }, [state.isOpen, updatePosition]);\n\n const overlayProps = mergeProps(\n {\n style: {\n left: \"auto\",\n right: \"auto\",\n top: \"auto\",\n bottom: \"auto\",\n position: \"absolute\",\n width:\n overlayWidth ?? (overlayMatchTriggerWidth ? triggerWidth : \"auto\"),\n minWidth: overlayMinTriggerWidth ? triggerWidth : \"auto\",\n },\n },\n overlayAriaProps,\n overlayPositionProps\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isPlacedTopVariant, active: placementAxis === \"top\" },\n { def: config.isPlacedBottomVariant, active: placementAxis === \"bottom\" },\n { def: config.isPlacedLeftVariant, active: placementAxis === \"left\" },\n { def: config.isPlacedRightVariant, active: placementAxis === \"right\" }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.contentSlot]: (\n <FocusScope restoreFocus>\n <DismissButton onDismiss={state.close} />\n {children}\n {/* We don't use the DismissButton at the end because it ends up taking up 1px space :-/ */}\n {/* <DismissButton onDismiss={state.close} /> */}\n </FocusScope>\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(overlayProps, getStyleProps(props), {\n ref: onOverlayRef,\n }),\n wrap: (root) => {\n if (typeof document !== \"undefined\") {\n return ReactDOM.createPortal(root, document.body);\n } else {\n // Possibly being invoked on the server during SSR; no need to\n // bother with a portal in that case.\n return root;\n }\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":[],"mappings":";;;;;;;;;;;;SAiDgB,mBAAmB,CAIjC,YAAe,EACf,KAAQ,EACR,MAAiC,EACjC,QAAoC,EACpC,aAAoB;;IADpB,yBAAA,EAAA,eAAoC;IACpC,8BAAA,EAAA,oBAAoB;IAEpB,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IACnD,IAAM,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAErD,IAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;IAE1D,IAAI,CAAC,OAAO,EAAE;;;;QAIW;YACrB,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;SACH;KAEF;IAEO,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAEzB,IAAA,UAAU,GAMR,OAAO,WANC,EACV,SAAS,GAKP,OAAO,UALA,EACT,wBAAwB,GAItB,OAAO,yBAJe,EACxB,sBAAsB,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B,CAAC;YACF,IAAI,EAAE,UAAC,IAAI;gBACT,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;oBACnC,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;iBACnD;qBAAM;;;oBAGL,OAAO,IAAI,CAAC;iBACb;aACF;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/triggered-overlay/triggered-overlay.tsx"],"sourcesContent":["import { usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport { FocusScope } from \"@react-aria/focus\";\nimport {\n DismissButton,\n useOverlay,\n useOverlayPosition,\n} from \"@react-aria/overlays\";\nimport { DOMProps } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { pick } from \"../../common\";\nimport {\n mergeProps,\n mergeRefs,\n useIsomorphicLayoutEffect,\n} from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\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 { TriggeredOverlayContext } from \"./context\";\n\nexport interface BaseTriggeredOverlayProps extends StyleProps, DOMProps {\n children?: React.ReactNode;\n}\n\nexport interface TriggeredOverlayConfig<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 contentSlot: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n contentContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type TriggeredOverlayRef = React.Ref<HTMLElement>;\n\nexport function useTriggeredOverlay<\n P extends BaseTriggeredOverlayProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: TriggeredOverlayConfig<C>,\n outerRef: TriggeredOverlayRef = null,\n isDismissable = true\n) {\n const overlayRef = React.useRef<HTMLElement>(null);\n const onOverlayRef = mergeRefs(overlayRef, outerRef);\n\n const context = React.useContext(TriggeredOverlayContext);\n\n if (!context) {\n // If no context, then we are not being correctly used. Either complain, or\n // exit early. It's okay to exit early and break the rules of React hooks\n // because we won't suddenly have the appropriate context anyway for this instance.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a triggered overlay with a TriggeredOverlayContext\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n const {\n triggerRef,\n placement,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n overlayWidth,\n state,\n } = context;\n\n // Measure the width of the trigger to inform the width of the menu (below).\n const [isRendered, setRendered] = React.useState(false);\n const triggerWidth =\n triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ? triggerRef.current.offsetWidth\n : undefined;\n\n useIsomorphicLayoutEffect(() => {\n if (\n !isRendered &&\n triggerRef.current &&\n (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ) {\n setRendered(true);\n }\n }, [\n triggerRef,\n isRendered,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n ]);\n\n const { overlayProps: overlayAriaProps } = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n isDismissable,\n shouldCloseOnBlur: true,\n },\n overlayRef\n );\n\n const {\n overlayProps: overlayPositionProps,\n updatePosition,\n placement: placementAxis,\n } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n placement: placement ?? \"bottom left\",\n shouldFlip: true,\n isOpen: state.isOpen,\n onClose: state.close,\n containerPadding: 0,\n });\n\n useIsomorphicLayoutEffect(() => {\n if (state.isOpen) {\n requestAnimationFrame(() => {\n updatePosition();\n });\n }\n }, [state.isOpen, updatePosition]);\n\n const overlayProps = mergeProps(\n {\n style: {\n left: \"auto\",\n right: \"auto\",\n top: \"auto\",\n bottom: \"auto\",\n position: \"absolute\",\n width:\n overlayWidth ?? (overlayMatchTriggerWidth ? triggerWidth : \"auto\"),\n minWidth: overlayMinTriggerWidth ? triggerWidth : \"auto\",\n },\n },\n overlayAriaProps,\n overlayPositionProps\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isPlacedTopVariant, active: placementAxis === \"top\" },\n { def: config.isPlacedBottomVariant, active: placementAxis === \"bottom\" },\n { def: config.isPlacedLeftVariant, active: placementAxis === \"left\" },\n { def: config.isPlacedRightVariant, active: placementAxis === \"right\" }\n ),\n };\n\n const canvasCtx = usePlasmicCanvasContext();\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.contentSlot]: canvasCtx ? (\n children\n ) : (\n <FocusScope restoreFocus>\n <DismissButton onDismiss={state.close} />\n {children}\n {/* We don't use the DismissButton at the end because it ends up taking up 1px space :-/ */}\n {/* <DismissButton onDismiss={state.close} /> */}\n </FocusScope>\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(overlayProps, getStyleProps(props), {\n ref: onOverlayRef,\n }),\n wrap: (root) => {\n if (typeof document !== \"undefined\") {\n return ReactDOM.createPortal(root, document.body);\n } else {\n // Possibly being invoked on the server during SSR; no need to\n // bother with a portal in that case.\n return root;\n }\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":[],"mappings":";;;;;;;;;;;;;SAkDgB,mBAAmB,C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