@plasmicapp/react-web 0.2.236 → 0.2.238

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/all.d.ts +2243 -2093
  2. package/dist/index.cjs.js +79 -101
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/react-web.esm.js +3 -3
  5. package/dist/react-web.esm.js.map +1 -1
  6. package/lib/auth/index.cjs.js +2 -6
  7. package/lib/auth/index.cjs.js.map +1 -1
  8. package/lib/data-sources/index.cjs.js +2 -6
  9. package/lib/data-sources/index.cjs.js.map +1 -1
  10. package/lib/host/index.cjs.js +2 -6
  11. package/lib/host/index.cjs.js.map +1 -1
  12. package/lib/prepass/index.cjs.js +2 -6
  13. package/lib/prepass/index.cjs.js.map +1 -1
  14. package/lib/query/index.cjs.js +2 -6
  15. package/lib/query/index.cjs.js.map +1 -1
  16. package/package.json +10 -10
  17. package/skinny/dist/{collection-utils-2f28e4eb.js → collection-utils-12be6625.js} +4 -4
  18. package/skinny/dist/{collection-utils-2f28e4eb.js.map → collection-utils-12be6625.js.map} +1 -1
  19. package/skinny/dist/{common-ed411407.js → common-e74df507.js} +4 -4
  20. package/skinny/dist/common-e74df507.js.map +1 -0
  21. package/skinny/dist/{context-034b8d25.js → context-e56b6773.js} +1 -1
  22. package/skinny/dist/{context-034b8d25.js.map → context-e56b6773.js.map} +1 -1
  23. package/skinny/dist/index.js +6 -7
  24. package/skinny/dist/index.js.map +1 -1
  25. package/skinny/dist/plume/button/index.js +2 -2
  26. package/skinny/dist/plume/button/index.js.map +1 -1
  27. package/skinny/dist/plume/checkbox/index.js +5 -5
  28. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  29. package/skinny/dist/plume/menu/index.js +7 -7
  30. package/skinny/dist/plume/menu/index.js.map +1 -1
  31. package/skinny/dist/plume/menu-button/index.js +6 -6
  32. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  33. package/skinny/dist/plume/select/index.js +7 -7
  34. package/skinny/dist/plume/select/index.js.map +1 -1
  35. package/skinny/dist/plume/switch/index.js +5 -5
  36. package/skinny/dist/plume/switch/index.js.map +1 -1
  37. package/skinny/dist/plume/text-input/index.js +2 -2
  38. package/skinny/dist/plume/text-input/index.js.map +1 -1
  39. package/skinny/dist/plume/triggered-overlay/index.js +6 -7
  40. package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
  41. package/skinny/dist/{plume-utils-e699cd08.js → plume-utils-3d2c0c98.js} +2 -2
  42. package/skinny/dist/{plume-utils-e699cd08.js.map → plume-utils-3d2c0c98.js.map} +1 -1
  43. package/skinny/dist/{props-utils-9d74371f.js → props-utils-30c7073a.js} +2 -2
  44. package/skinny/dist/{props-utils-9d74371f.js.map → props-utils-30c7073a.js.map} +1 -1
  45. package/skinny/dist/{react-utils-5ff031c2.js → react-utils-8796beba.js} +2 -2
  46. package/skinny/dist/{react-utils-5ff031c2.js.map → react-utils-8796beba.js.map} +1 -1
  47. package/skinny/dist/render/PlasmicHead/index.js.map +1 -1
  48. package/skinny/dist/render/PlasmicImg/index.js +2 -2
  49. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  50. package/skinny/dist/{ssr-d19c2950.js → ssr-90db5fad.js} +2 -2
  51. package/skinny/dist/{ssr-d19c2950.js.map → ssr-90db5fad.js.map} +1 -1
  52. package/skinny/dist/common-ed411407.js.map +0 -1
@@ -1,17 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var authReact = require('@plasmicapp/auth-react');
6
4
 
7
5
 
8
6
 
9
7
  Object.keys(authReact).forEach(function (k) {
10
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
9
  enumerable: true,
12
- get: function () {
13
- return authReact[k];
14
- }
10
+ get: function () { return authReact[k]; }
15
11
  });
16
12
  });
17
13
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,17 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var dataSources = require('@plasmicapp/data-sources');
6
4
 
7
5
 
8
6
 
9
7
  Object.keys(dataSources).forEach(function (k) {
10
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
9
  enumerable: true,
12
- get: function () {
13
- return dataSources[k];
14
- }
10
+ get: function () { return dataSources[k]; }
15
11
  });
16
12
  });
17
13
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,17 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var host = require('@plasmicapp/host');
6
4
 
7
5
 
8
6
 
9
7
  Object.keys(host).forEach(function (k) {
10
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
9
  enumerable: true,
12
- get: function () {
13
- return host[k];
14
- }
10
+ get: function () { return host[k]; }
15
11
  });
16
12
  });
17
13
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,17 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var prepass = require('@plasmicapp/prepass');
6
4
 
7
5
 
8
6
 
9
7
  Object.keys(prepass).forEach(function (k) {
10
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
9
  enumerable: true,
12
- get: function () {
13
- return prepass[k];
14
- }
10
+ get: function () { return prepass[k]; }
15
11
  });
16
12
  });
17
13
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,17 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var query = require('@plasmicapp/query');
6
4
 
7
5
 
8
6
 
9
7
  Object.keys(query).forEach(function (k) {
10
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
9
  enumerable: true,
12
- get: function () {
13
- return query[k];
14
- }
10
+ get: function () { return query[k]; }
15
11
  });
16
12
  });
17
13
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.236",
3
+ "version": "0.2.238",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -86,9 +86,9 @@
86
86
  "prettier": {},
87
87
  "dependencies": {
88
88
  "@plasmicapp/auth-react": "^0.0.5",
89
- "@plasmicapp/data-sources": "0.1.96",
89
+ "@plasmicapp/data-sources": "0.1.98",
90
90
  "@plasmicapp/data-sources-context": "0.1.11",
91
- "@plasmicapp/host": "1.0.151",
91
+ "@plasmicapp/host": "1.0.153",
92
92
  "@plasmicapp/prepass": "1.0.1",
93
93
  "@plasmicapp/query": "0.1.67",
94
94
  "@react-aria/checkbox": "^3.5.0",
@@ -120,9 +120,9 @@
120
120
  "@react-types/overlays": "^3.5.5",
121
121
  "@react-types/select": "^3.5.5",
122
122
  "@react-types/shared": "^3.12.0",
123
- "@rollup/plugin-commonjs": "^19.0.0",
124
- "@rollup/plugin-json": "^4.1.0",
125
- "@rollup/plugin-node-resolve": "^13.0.0",
123
+ "@rollup/plugin-commonjs": "^25.0.2",
124
+ "@rollup/plugin-json": "^6.0.0",
125
+ "@rollup/plugin-node-resolve": "^15.1.0",
126
126
  "@size-limit/preset-small-lib": "^4.10.2",
127
127
  "@storybook/addon-actions": "^6.3.4",
128
128
  "@storybook/addon-essentials": "^6.3.4",
@@ -144,9 +144,9 @@
144
144
  "husky": "^6.0.0",
145
145
  "react": "^18.2.0",
146
146
  "react-dom": "^18.2.0",
147
- "rollup": "^2.47.0",
148
- "rollup-plugin-dts": "^5.1.0",
149
- "rollup-plugin-typescript2": "^0.30.0",
147
+ "rollup": "^3.26.1",
148
+ "rollup-plugin-dts": "^5.3.0",
149
+ "rollup-plugin-typescript2": "^0.35.0",
150
150
  "size-limit": "^4.10.2",
151
151
  "tsdx": "^0.14.1",
152
152
  "tslib": "^2.3.1"
@@ -155,5 +155,5 @@
155
155
  "react": ">=16.8.0",
156
156
  "react-dom": ">=16.8.0"
157
157
  },
158
- "gitHead": "35d4595c6d82b47128fdb0c536fab54d7bbc609f"
158
+ "gitHead": "a00a74da4da1cd6ceb7b12646a7a3bf4e871e162"
159
159
  }
@@ -1,8 +1,8 @@
1
- import { b as __assign, l as isString } from './common-ed411407.js';
1
+ import { a as __assign, k as isString } from './common-e74df507.js';
2
2
  import { Item, Section } from '@react-stately/collections';
3
3
  import React__default from 'react';
4
- import { t as toChildArray, g as getElementTypeName } from './react-utils-5ff031c2.js';
5
- import { g as getPlumeType, P as PLUME_STRICT_MODE } from './plume-utils-e699cd08.js';
4
+ import { t as toChildArray, g as getElementTypeName } from './react-utils-8796beba.js';
5
+ import { g as getPlumeType, P as PLUME_STRICT_MODE } from './plume-utils-3d2c0c98.js';
6
6
 
7
7
  /**
8
8
  * In general, we try not to expose react-aria's Collections API to Plume users.
@@ -300,4 +300,4 @@ function cloneChild(child, props) {
300
300
  }
301
301
 
302
302
  export { renderAsCollectionChild as a, useDerivedItems as b, getChildProp as g, renderCollectionNode as r, useDerivedItemsFromChildren as u };
303
- //# sourceMappingURL=collection-utils-2f28e4eb.js.map
303
+ //# sourceMappingURL=collection-utils-12be6625.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-utils-2f28e4eb.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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C7B,cAAc,wBACT,KAAK,CAAC,KAAK,CAAC,cAAc,GAC1B,KAAK,MAEN,KAAK,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GACvC,CAAC;KACJ;IAED,OAAOA,cAAK,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1C;;;;"}
1
+ {"version":3,"file":"collection-utils-12be6625.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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1
- /*! *****************************************************************************
1
+ /******************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -68,7 +68,7 @@ function __generator(thisArg, body) {
68
68
  function verb(n) { return function (v) { return step([n, v]); }; }
69
69
  function step(op) {
70
70
  if (f) throw new TypeError("Generator is already executing.");
71
- while (_) try {
71
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
72
72
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
73
73
  if (y = 0, t) op = [op[0] & 2, t.value];
74
74
  switch (op[0]) {
@@ -260,5 +260,5 @@ function mapValues(obj, mapper) {
260
260
  return result;
261
261
  }
262
262
 
263
- export { __awaiter as _, __generator as a, __assign as b, __rest as c, __spreadArray as d, __read as e, __values as f, chainSingleArgFuncs as g, __extends as h, isSubset as i, ensure as j, groupBy as k, isString as l, mapValues as m, notNil as n, omit as o, pick as p };
264
- //# sourceMappingURL=common-ed411407.js.map
263
+ export { __awaiter as _, __assign as a, __generator as b, __rest as c, __spreadArray as d, __read as e, __values as f, chainSingleArgFuncs as g, __extends as h, isSubset as i, ensure as j, isString as k, groupBy as l, mapValues as m, notNil as n, omit as o, pick as p };
264
+ //# sourceMappingURL=common-e74df507.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-e74df507.js","sources":["../../src/common.ts"],"sourcesContent":["export function notNil<T>(x: T | undefined | null): x is T {\n return x != null;\n}\n\nexport function pick<T extends {}>(\n obj: T,\n ...keys: (string | number | symbol)[]\n): Partial<T> {\n if (Object.keys(obj).length === 0) {\n return obj;\n }\n const res: any = {};\n for (const key of keys) {\n if (key in obj) {\n res[key] = obj[key as keyof T];\n }\n }\n return res as Partial<T>;\n}\n\nexport function pickBy<T extends {}>(\n obj: T,\n func: (key: string, val: any) => boolean\n): Partial<T> {\n const res: any = {};\n for (const [key, val] of Object.entries(obj)) {\n if (func(key, val)) {\n res[key] = obj[key as keyof T];\n }\n }\n return res as Partial<T>;\n}\n\nexport function omit<T extends {}>(obj: T, ...keys: (keyof T)[]): Partial<T> {\n if (Object.keys(obj).length === 0) {\n return obj;\n }\n const res: Partial<T> = {};\n for (const key of Object.keys(obj) as (keyof T)[]) {\n if (!keys.includes(key)) {\n res[key] = obj[key];\n }\n }\n return res;\n}\n\nexport function isSubset<T>(a1: T[], a2: T[]) {\n return a1.every((x) => a2.includes(x));\n}\n\nexport function chainSingleArgFuncs<A>(...funcs: ((arg: A) => A)[]) {\n if (funcs.length === 0) {\n return undefined;\n }\n return (arg: A) => {\n let res: A = arg;\n for (const func of funcs) {\n res = func(res);\n }\n return res;\n };\n}\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nexport function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\nexport function groupBy<T>(\n collection: T[],\n keyFunc: (x: T) => string\n): Record<string, T[]> {\n const result: Record<string, T[]> = {};\n for (const obj of collection) {\n const key = keyFunc(obj);\n if (key in result) {\n result[key].push(obj);\n } else {\n result[key] = [obj];\n }\n }\n return result;\n}\n\nexport function mapValues<V, V2>(\n obj: Record<string, V>,\n mapper: (value: V) => V2\n): Record<string, V2> {\n const result: Record<string, V2> = {};\n for (const key in obj) {\n result[key] = mapper(obj[key]);\n }\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAM,SAAU,MAAM,CAAI,CAAuB,EAAA;IAC/C,OAAO,CAAC,IAAI,IAAI,CAAC;AACnB,CAAC;AAEK,SAAU,IAAI,CAClB,GAAM,EAAA;;IACN,IAAqC,IAAA,GAAA,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,GAAG,CAAC,CAAC,CAAC;AAChC,KAAA;AACD,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
@@ -3,4 +3,4 @@ import * as React from 'react';
3
3
  var TriggeredOverlayContext = React.createContext(undefined);
4
4
 
5
5
  export { TriggeredOverlayContext as T };
6
- //# sourceMappingURL=context-034b8d25.js.map
6
+ //# sourceMappingURL=context-e56b6773.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-034b8d25.js","sources":["../../src/plume/triggered-overlay/context.tsx"],"sourcesContent":["import type { Placement } from \"@react-types/overlays\";\nimport type { FocusStrategy } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport type { OverlayTriggerState } from \"@react-stately/overlays\";\n\nexport interface TriggeredOverlayContextValue {\n triggerRef: React.RefObject<HTMLElement>;\n state: OverlayTriggerState;\n autoFocus?: boolean | FocusStrategy;\n\n placement?: Placement;\n overlayMatchTriggerWidth?: boolean;\n overlayMinTriggerWidth?: boolean;\n overlayWidth?: number;\n}\n\nexport const TriggeredOverlayContext = React.createContext<\n TriggeredOverlayContextValue | undefined\n>(undefined);\n"],"names":[],"mappings":";;IAgBa,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAExD,SAAS;;;;"}
1
+ {"version":3,"file":"context-e56b6773.js","sources":["../../src/plume/triggered-overlay/context.tsx"],"sourcesContent":["import type { Placement } from \"@react-types/overlays\";\nimport type { FocusStrategy } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport type { OverlayTriggerState } from \"@react-stately/overlays\";\n\nexport interface TriggeredOverlayContextValue {\n triggerRef: React.RefObject<HTMLElement>;\n state: OverlayTriggerState;\n autoFocus?: boolean | FocusStrategy;\n\n placement?: Placement;\n overlayMatchTriggerWidth?: boolean;\n overlayMinTriggerWidth?: boolean;\n overlayWidth?: number;\n}\n\nexport const TriggeredOverlayContext = React.createContext<\n TriggeredOverlayContextValue | undefined\n>(undefined);\n"],"names":[],"mappings":";;AAgBa,IAAA,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAExD,SAAS;;;;"}
@@ -5,16 +5,15 @@ import * as React from 'react';
5
5
  import React__default, { useLayoutEffect, useEffect } from 'react';
6
6
  import get from 'dlv';
7
7
  export { default as get } from 'dlv';
8
- import { c as createElementWithChildren, m as mergeProps, e as ensureNotArray, N as NONE, a as mergePropVals, i as isReactNode, b as isBrowser, u as useIsomorphicLayoutEffect$1 } from './react-utils-5ff031c2.js';
9
- import { _ as __awaiter, a as __generator, b as __assign, c as __rest, d as __spreadArray, e as __read, o as omit, p as pick, f as __values, i as isSubset, g as chainSingleArgFuncs, n as notNil, h as __extends, j as ensure } from './common-ed411407.js';
10
- export { o as omit, p as pick } from './common-ed411407.js';
8
+ import { c as createElementWithChildren, m as mergeProps, e as ensureNotArray, N as NONE, a as mergePropVals, i as isReactNode, b as isBrowser, u as useIsomorphicLayoutEffect$1 } from './react-utils-8796beba.js';
9
+ import { _ as __awaiter, a as __assign, b as __generator, c as __rest, d as __spreadArray, e as __read, o as omit, p as pick, f as __values, i as isSubset, g as chainSingleArgFuncs, n as notNil, h as __extends, j as ensure } from './common-e74df507.js';
11
10
  export { PlasmicHead, plasmicHeadMeta } from './render/PlasmicHead/index.js';
12
11
  export { PlasmicImg } from './render/PlasmicImg/index.js';
13
- import { T as Trans } from './ssr-d19c2950.js';
14
- export { P as PlasmicLink, a as PlasmicRootProvider, T as Trans, g as genTranslatableString, u as useIsSSR, b as usePlasmicTranslator } from './ssr-d19c2950.js';
12
+ import { T as Trans } from './ssr-90db5fad.js';
13
+ export { P as PlasmicLink, a as PlasmicRootProvider, g as genTranslatableString, u as useIsSSR, b as usePlasmicTranslator } from './ssr-90db5fad.js';
15
14
  import ReactDOM__default from 'react-dom';
16
15
  import { useFocusRing } from '@react-aria/focus';
17
- import { proxy, ref, useSnapshot, getVersion, subscribe } from 'valtio';
16
+ import { proxy, useSnapshot, ref, getVersion, subscribe } from 'valtio';
18
17
  import clone from 'clone';
19
18
  import deepEqual from 'fast-deep-equal';
20
19
  import '@react-aria/ssr';
@@ -1601,5 +1600,5 @@ function assignValue(object, key, value) {
1601
1600
  // Utilities used by generated code
1602
1601
  var classNames = classNames$1;
1603
1602
 
1604
- export { PlasmicIcon, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateOnMutateForSpec, generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, hasVariant, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, resetToInitialValue, set, useDollarState, useTrigger, withPlasmicPageGuard, wrapWithClassName };
1603
+ export { PlasmicIcon, PlasmicPageGuard, PlasmicSlot, Stack, Trans, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateOnMutateForSpec, generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, hasVariant, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, omit, pick, renderPlasmicSlot, resetToInitialValue, set, useDollarState, useTrigger, withPlasmicPageGuard, wrapWithClassName };
1605
1604
  //# sourceMappingURL=index.js.map