@vaadin/react-components 25.3.0-alpha3 → 25.3.0-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"MasterDetailLayout.d.ts","sourceRoot":"","sources":["src/MasterDetailLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,IAAI,mBAAmB,EAE1C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAuD,MAAM,OAAO,CAAC;AAE5E,cAAc,mCAAmC,CAAC;AAElD,KAAK,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAC/C,KAAK,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAC/C,KAAK,sBAAsB,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAsJ1D,QAAA,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,CAAC,CAIhG,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,QAAA,MAAM,kBAAkB,EAAuC,OAAO,gCAAgC,GAAG;IACvG,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9B,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC;CACrD,CAAC;AAMF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"MasterDetailLayout.d.ts","sourceRoot":"","sources":["src/MasterDetailLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,IAAI,mBAAmB,EAE1C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAuD,MAAM,OAAO,CAAC;AAE5E,cAAc,mCAAmC,CAAC;AAElD,KAAK,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAC/C,KAAK,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAC/C,KAAK,sBAAsB,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAiK1D,QAAA,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,CAAC,CAIhG,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,QAAA,MAAM,kBAAkB,EAAuC,OAAO,gCAAgC,GAAG;IACvG,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9B,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC;CACrD,CAAC;AAMF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/MasterDetailLayout.tsx", "src/generated/MasterDetailLayout.ts"],
4
- "sourcesContent": ["export * from \"@vaadin/master-detail-layout/vaadin-master-detail-layout.js\";\nimport {\n MasterDetailLayout as _MasterDetailLayout,\n MasterDetailLayoutElement,\n} from './generated/MasterDetailLayout.js';\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nexport * from './generated/MasterDetailLayout.js';\n\ntype MasterProps = React.PropsWithChildren<{}>;\ntype DetailProps = React.PropsWithChildren<{}>;\ntype DetailPlaceholderProps = React.PropsWithChildren<{}>;\n\ntype MasterDetailLayoutElementWithInternalAPI = MasterDetailLayoutElement & {\n _startTransition: (transitionType: 'add' | 'remove' | 'replace', callback: () => void) => Promise<void>;\n};\n\nfunction Master({ children }: MasterProps) {\n return children;\n}\n\nfunction DetailPlaceholder({ children }: DetailPlaceholderProps) {\n return <div slot=\"detail-placeholder\" style={{ height: '100%' }}>{children}</div>;\n}\n\n/**\n * Compares two sets of React children to detect meaningful changes, ignoring text nodes.\n * Compares by component type and key.\n *\n * @param prevChildren Previous children\n * @param nextChildren Current children\n * @returns True if the non-text children are meaningfully different, false otherwise\n */\nfunction areChildrenDifferent(prevChildren: React.ReactNode, nextChildren: React.ReactNode): boolean {\n // Convert to arrays and filter out text nodes\n const prevArray = React.Children.toArray(prevChildren).filter((child) => React.isValidElement(child));\n const nextArray = React.Children.toArray(nextChildren).filter((child) => React.isValidElement(child));\n\n // If lengths are different, children have changed\n if (prevArray.length !== nextArray.length) {\n return true;\n }\n\n // Compare each element by type and key\n for (let i = 0; i < prevArray.length; i++) {\n const prevChild = prevArray[i] as React.ReactElement;\n const nextChild = nextArray[i] as React.ReactElement;\n\n // Compare by type\n if (prevChild.type !== nextChild.type) {\n return true;\n }\n\n // Compare by key (React.Children.toArray adds keys if missing)\n if (prevChild.key !== nextChild.key) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction Detail({ children }: DetailProps) {\n const currentDetailsRef = useRef<HTMLDivElement>(null);\n const currentDetailsKey = useRef<number>(0);\n const nextDetailsRef = useRef<HTMLDivElement>(null);\n const nextDetailsKey = currentDetailsKey.current + 1;\n const [state, setState] = useState('idle');\n const [currentChildren, setCurrentChildren] = useState(children);\n\n useLayoutEffect(() => {\n const layout = currentDetailsRef.current?.closest(\n 'vaadin-master-detail-layout',\n ) as MasterDetailLayoutElementWithInternalAPI;\n if (!layout) {\n return;\n }\n\n if (state === 'idle') {\n // No transition in progress \u2014 just update slot name\n const hasChildren = currentDetailsRef.current!.childElementCount > 0;\n currentDetailsRef.current!.setAttribute('slot', hasChildren ? 'detail' : 'detail-hidden');\n } else if (state === 'starting') {\n // Transition is starting and old and (invisible) new details are rendered.\n // Determine the transition type based on old and new detail contents.\n const hasCurrentDetails = currentDetailsRef.current!.childElementCount > 0;\n const hasNextDetails = nextDetailsRef.current!.childElementCount > 0;\n const transitionType = hasCurrentDetails && hasNextDetails ? 'replace' : hasCurrentDetails ? 'remove' : 'add';\n\n // _startTransition calls the callback synchronously for add/replace,\n // and asynchronously for remove.\n layout._startTransition(transitionType, async () => {\n if (transitionType === 'replace' && currentDetailsRef.current) {\n // For replace, _startTransition moved the current div to the\n // detail-outgoing slot for the outgoing animation. Clone it so the\n // WC can animate the clone out, then hide the React-managed original\n // so the WC's post-animation cleanup won't remove it from the DOM.\n const clone = currentDetailsRef.current.cloneNode(true) as HTMLElement;\n clone.setAttribute('slot', 'detail-outgoing');\n layout.appendChild(clone);\n currentDetailsRef.current.setAttribute('slot', 'detail-hidden');\n } else if (currentDetailsRef.current) {\n currentDetailsRef.current.setAttribute('slot', 'detail-hidden');\n }\n if (nextDetailsRef.current) {\n nextDetailsRef.current.style.display = '';\n const hasNext = nextDetailsRef.current.childElementCount > 0;\n nextDetailsRef.current.setAttribute('slot', hasNext ? 'detail' : 'detail-hidden');\n }\n\n // Wait for Lit elements to render\n await Promise.resolve();\n\n // Recompute layout state with the new DOM\n layout.recalculateLayout();\n }).then(() => {\n // Animation finished \u2014 sync React state to match DOM reality\n setCurrentChildren(children);\n currentDetailsKey.current = nextDetailsKey;\n setState('idle');\n });\n }\n }, [state, currentChildren]);\n\n useEffect(() => {\n if (state !== 'idle') {\n return;\n }\n if (areChildrenDifferent(currentChildren, children)) {\n setState('starting');\n } else {\n setCurrentChildren(children);\n }\n }, [state, children]);\n\n return (\n <>\n <div ref={currentDetailsRef} key={currentDetailsKey.current} style={{ height: '100%' }}>\n {currentChildren}\n </div>\n {state === 'starting' && (\n <div ref={nextDetailsRef} key={nextDetailsKey} style={{ display: 'none', height: '100%' }}>\n {children}\n </div>\n )}\n </>\n );\n}\n\nfunction validateChildren(children: React.ReactNode) {\n React.Children.forEach(children, (child) => {\n // Ignore non-React elements\n // We especially want to ignore text nodes to allow for whitespace resulting from formatting\n if (React.isValidElement(child) && child.type !== Master && child.type !== Detail && child.type !== DetailPlaceholder) {\n throw new Error(\n 'Invalid child in MasterDetailLayout. Only <MasterDetailLayout.Master>, <MasterDetailLayout.Detail>, and <MasterDetailLayout.DetailPlaceholder> components are allowed. Check the component docs for proper usage.',\n );\n }\n });\n}\n\nconst MasterDetailLayoutWithValidation: React.FC<React.ComponentProps<typeof _MasterDetailLayout>> = (props) => {\n validateChildren(props.children);\n\n return <_MasterDetailLayout {...props} />;\n};\n\n/**\n * `MasterDetailLayout` is a React component for building UIs with a master\n * (or primary) area and a detail (or secondary) area that is displayed next to, or\n * overlaid on top of, the master area, depending on configuration and viewport size.\n *\n * Content for each area should be wrapped into the respective\n * `MasterDetailLayout.Master`, `MasterDetailLayout.Detail`, and optionally\n * `MasterDetailLayout.DetailPlaceholder` wrapper components.\n * Using any other component as a child will throw an error. To ensure that view\n * transitions are run properly, details content should be rendered conditionally\n * into the `MasterDetailLayout.Detail` component. The `DetailPlaceholder` is shown\n * in the detail area when no detail is selected, and is hidden when the viewport\n * is too narrow (unlike detail, it does not become an overlay).\n *\n * @example\n * ```tsx\n * const selectedProduct = useSignal<Product | null>(null);\n *\n * <MasterDetailLayout>\n * <MasterDetailLayout.Master>\n * <ProductList onSelect={(product) => { selectedProduct.value = product }} />\n * </MasterDetailLayout.Master>\n * <MasterDetailLayout.Detail>\n * { selectedProduct.value && <ProductDetail product={selectedProduct.value} /> }\n * </MasterDetailLayout.Detail>\n * </MasterDetailLayout>\n * ```\n */\nconst MasterDetailLayout = MasterDetailLayoutWithValidation as typeof MasterDetailLayoutWithValidation & {\n Master: React.FC<MasterProps>;\n Detail: React.FC<DetailProps>;\n DetailPlaceholder: React.FC<DetailPlaceholderProps>;\n};\n\nMasterDetailLayout.Master = Master;\nMasterDetailLayout.Detail = Detail;\nMasterDetailLayout.DetailPlaceholder = DetailPlaceholder;\n\nexport { MasterDetailLayout };\n", "import type { EventName } from \"@lit/react\";\nimport { MasterDetailLayout as MasterDetailLayoutElement, type MasterDetailLayoutEventMap as _MasterDetailLayoutEventMap, } from \"@vaadin/master-detail-layout/vaadin-master-detail-layout.js\";\nimport * as React from \"react\";\nimport { createComponent, type WebComponentProps } from \"../utils/createComponent.js\";\nexport { MasterDetailLayoutElement, };\nexport type MasterDetailLayoutEventMap = Readonly<{\n onBackdropClick: EventName<_MasterDetailLayoutEventMap[\"backdrop-click\"]>;\n onDetailEscapePress: EventName<_MasterDetailLayoutEventMap[\"detail-escape-press\"]>;\n}>;\nconst events = { onBackdropClick: \"backdrop-click\", onDetailEscapePress: \"detail-escape-press\" } as MasterDetailLayoutEventMap;\nexport type MasterDetailLayoutProps = WebComponentProps<MasterDetailLayoutElement, MasterDetailLayoutEventMap>;\nexport const MasterDetailLayout = createComponent({\n elementClass: MasterDetailLayoutElement, events, react: React, tagName: \"vaadin-master-detail-layout\"\n});\n"],
5
- "mappings": "AAAA,WAAc,8DCCd,OAAS,sBAAsBA,MAAkG,8DACjI,UAAYC,MAAW,QACvB,OAAS,mBAAAC,MAA+C,6BAMxD,IAAMC,EAAS,CAAE,gBAAiB,iBAAkB,oBAAqB,qBAAsB,EAElFC,EAAqBC,EAAgB,CAC9C,aAAcC,EAA2B,OAAAH,EAAQ,MAAOI,EAAO,QAAS,6BAC5E,CAAC,EDRD,OAAOC,GAAS,aAAAC,EAAW,mBAAAC,EAAiB,UAAAC,EAAQ,YAAAC,MAAgB,QAiB3D,OAkHL,YAAAC,EAlHK,OAAAC,EAkHL,QAAAC,MAlHK,oBALT,SAASC,EAAO,CAAE,SAAAC,CAAS,EAAgB,CACzC,OAAOA,CACT,CAEA,SAASC,EAAkB,CAAE,SAAAD,CAAS,EAA2B,CAC/D,OAAOH,EAAC,OAAI,KAAK,qBAAqB,MAAO,CAAE,OAAQ,MAAO,EAAI,SAAAG,EAAS,CAC7E,CAUA,SAASE,EAAqBC,EAA+BC,EAAwC,CAEnG,IAAMC,EAAYd,EAAM,SAAS,QAAQY,CAAY,EAAE,OAAQG,GAAUf,EAAM,eAAee,CAAK,CAAC,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"@vaadin/master-detail-layout/vaadin-master-detail-layout.js\";\nimport {\n MasterDetailLayout as _MasterDetailLayout,\n MasterDetailLayoutElement,\n} from './generated/MasterDetailLayout.js';\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nexport * from './generated/MasterDetailLayout.js';\n\ntype MasterProps = React.PropsWithChildren<{}>;\ntype DetailProps = React.PropsWithChildren<{}>;\ntype DetailPlaceholderProps = React.PropsWithChildren<{}>;\n\ntype MasterDetailLayoutElementWithInternalAPI = MasterDetailLayoutElement & {\n _startTransition: (transitionType: 'add' | 'remove' | 'replace', callback: () => void) => Promise<void>;\n};\n\nfunction Master({ children }: MasterProps) {\n return children;\n}\n\nfunction DetailPlaceholder({ children }: DetailPlaceholderProps) {\n return (\n <div slot=\"detail-placeholder\" style={{ height: '100%' }}>\n {children}\n </div>\n );\n}\n\n/**\n * Compares two sets of React children to detect meaningful changes, ignoring text nodes.\n * Compares by component type and key.\n *\n * @param prevChildren Previous children\n * @param nextChildren Current children\n * @returns True if the non-text children are meaningfully different, false otherwise\n */\nfunction areChildrenDifferent(prevChildren: React.ReactNode, nextChildren: React.ReactNode): boolean {\n // Convert to arrays and filter out text nodes\n const prevArray = React.Children.toArray(prevChildren).filter((child) => React.isValidElement(child));\n const nextArray = React.Children.toArray(nextChildren).filter((child) => React.isValidElement(child));\n\n // If lengths are different, children have changed\n if (prevArray.length !== nextArray.length) {\n return true;\n }\n\n // Compare each element by type and key\n for (let i = 0; i < prevArray.length; i++) {\n const prevChild = prevArray[i] as React.ReactElement;\n const nextChild = nextArray[i] as React.ReactElement;\n\n // Compare by type\n if (prevChild.type !== nextChild.type) {\n return true;\n }\n\n // Compare by key (React.Children.toArray adds keys if missing)\n if (prevChild.key !== nextChild.key) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction Detail({ children }: DetailProps) {\n const currentDetailsRef = useRef<HTMLDivElement>(null);\n const currentDetailsKey = useRef<number>(0);\n const nextDetailsRef = useRef<HTMLDivElement>(null);\n const nextDetailsKey = currentDetailsKey.current + 1;\n const [state, setState] = useState('idle');\n const [currentChildren, setCurrentChildren] = useState(children);\n\n useLayoutEffect(() => {\n const layout = currentDetailsRef.current?.closest(\n 'vaadin-master-detail-layout',\n ) as MasterDetailLayoutElementWithInternalAPI;\n if (!layout) {\n return;\n }\n\n if (state === 'idle') {\n // No transition in progress \u2014 just update slot name\n const hasChildren = currentDetailsRef.current!.childElementCount > 0;\n currentDetailsRef.current!.setAttribute('slot', hasChildren ? 'detail' : 'detail-hidden');\n } else if (state === 'starting') {\n // Transition is starting and old and (invisible) new details are rendered.\n // Determine the transition type based on old and new detail contents.\n const hasCurrentDetails = currentDetailsRef.current!.childElementCount > 0;\n const hasNextDetails = nextDetailsRef.current!.childElementCount > 0;\n const transitionType = hasCurrentDetails && hasNextDetails ? 'replace' : hasCurrentDetails ? 'remove' : 'add';\n\n // _startTransition calls the callback synchronously for add/replace,\n // and asynchronously for remove.\n layout\n ._startTransition(transitionType, async () => {\n if (transitionType === 'replace' && currentDetailsRef.current) {\n // For replace, _startTransition moved the current div to the\n // detail-outgoing slot for the outgoing animation. Clone it so the\n // WC can animate the clone out, then hide the React-managed original\n // so the WC's post-animation cleanup won't remove it from the DOM.\n const clone = currentDetailsRef.current.cloneNode(true) as HTMLElement;\n clone.setAttribute('slot', 'detail-outgoing');\n layout.appendChild(clone);\n currentDetailsRef.current.setAttribute('slot', 'detail-hidden');\n } else if (currentDetailsRef.current) {\n currentDetailsRef.current.setAttribute('slot', 'detail-hidden');\n }\n if (nextDetailsRef.current) {\n nextDetailsRef.current.style.display = '';\n const hasNext = nextDetailsRef.current.childElementCount > 0;\n nextDetailsRef.current.setAttribute('slot', hasNext ? 'detail' : 'detail-hidden');\n }\n\n // Wait for Lit elements to render\n await Promise.resolve();\n\n // Recompute layout state with the new DOM\n layout.recalculateLayout();\n })\n .then(() => {\n // Animation finished \u2014 sync React state to match DOM reality\n setCurrentChildren(children);\n currentDetailsKey.current = nextDetailsKey;\n setState('idle');\n });\n }\n }, [state, currentChildren]);\n\n useEffect(() => {\n if (state !== 'idle') {\n return;\n }\n if (areChildrenDifferent(currentChildren, children)) {\n setState('starting');\n } else {\n setCurrentChildren(children);\n }\n }, [state, children]);\n\n return (\n <>\n <div ref={currentDetailsRef} key={currentDetailsKey.current} style={{ height: '100%' }}>\n {currentChildren}\n </div>\n {state === 'starting' && (\n <div ref={nextDetailsRef} key={nextDetailsKey} style={{ display: 'none', height: '100%' }}>\n {children}\n </div>\n )}\n </>\n );\n}\n\nfunction validateChildren(children: React.ReactNode) {\n React.Children.forEach(children, (child) => {\n // Ignore non-React elements\n // We especially want to ignore text nodes to allow for whitespace resulting from formatting\n if (\n React.isValidElement(child) &&\n child.type !== Master &&\n child.type !== Detail &&\n child.type !== DetailPlaceholder\n ) {\n throw new Error(\n 'Invalid child in MasterDetailLayout. Only <MasterDetailLayout.Master>, <MasterDetailLayout.Detail>, and <MasterDetailLayout.DetailPlaceholder> components are allowed. Check the component docs for proper usage.',\n );\n }\n });\n}\n\nconst MasterDetailLayoutWithValidation: React.FC<React.ComponentProps<typeof _MasterDetailLayout>> = (props) => {\n validateChildren(props.children);\n\n return <_MasterDetailLayout {...props} />;\n};\n\n/**\n * `MasterDetailLayout` is a React component for building UIs with a master\n * (or primary) area and a detail (or secondary) area that is displayed next to, or\n * overlaid on top of, the master area, depending on configuration and viewport size.\n *\n * Content for each area should be wrapped into the respective\n * `MasterDetailLayout.Master`, `MasterDetailLayout.Detail`, and optionally\n * `MasterDetailLayout.DetailPlaceholder` wrapper components.\n * Using any other component as a child will throw an error. To ensure that view\n * transitions are run properly, details content should be rendered conditionally\n * into the `MasterDetailLayout.Detail` component. The `DetailPlaceholder` is shown\n * in the detail area when no detail is selected, and is hidden when the viewport\n * is too narrow (unlike detail, it does not become an overlay).\n *\n * @example\n * ```tsx\n * const selectedProduct = useSignal<Product | null>(null);\n *\n * <MasterDetailLayout>\n * <MasterDetailLayout.Master>\n * <ProductList onSelect={(product) => { selectedProduct.value = product }} />\n * </MasterDetailLayout.Master>\n * <MasterDetailLayout.Detail>\n * { selectedProduct.value && <ProductDetail product={selectedProduct.value} /> }\n * </MasterDetailLayout.Detail>\n * </MasterDetailLayout>\n * ```\n */\nconst MasterDetailLayout = MasterDetailLayoutWithValidation as typeof MasterDetailLayoutWithValidation & {\n Master: React.FC<MasterProps>;\n Detail: React.FC<DetailProps>;\n DetailPlaceholder: React.FC<DetailPlaceholderProps>;\n};\n\nMasterDetailLayout.Master = Master;\nMasterDetailLayout.Detail = Detail;\nMasterDetailLayout.DetailPlaceholder = DetailPlaceholder;\n\nexport { MasterDetailLayout };\n", "import type { EventName } from \"@lit/react\";\nimport { MasterDetailLayout as MasterDetailLayoutElement, type MasterDetailLayoutEventMap as _MasterDetailLayoutEventMap, } from \"@vaadin/master-detail-layout/vaadin-master-detail-layout.js\";\nimport * as React from \"react\";\nimport { createComponent, type WebComponentProps } from \"../utils/createComponent.js\";\nexport { MasterDetailLayoutElement, };\nexport type MasterDetailLayoutEventMap = Readonly<{\n onBackdropClick: EventName<_MasterDetailLayoutEventMap[\"backdrop-click\"]>;\n onDetailEscapePress: EventName<_MasterDetailLayoutEventMap[\"detail-escape-press\"]>;\n}>;\nconst events = { onBackdropClick: \"backdrop-click\", onDetailEscapePress: \"detail-escape-press\" } as MasterDetailLayoutEventMap;\nexport type MasterDetailLayoutProps = WebComponentProps<MasterDetailLayoutElement, MasterDetailLayoutEventMap>;\nexport const MasterDetailLayout = createComponent({\n elementClass: MasterDetailLayoutElement, events, react: React, tagName: \"vaadin-master-detail-layout\"\n});\n"],
5
+ "mappings": "AAAA,WAAc,8DCCd,OAAS,sBAAsBA,MAAkG,8DACjI,UAAYC,MAAW,QACvB,OAAS,mBAAAC,MAA+C,6BAMxD,IAAMC,EAAS,CAAE,gBAAiB,iBAAkB,oBAAqB,qBAAsB,EAElFC,EAAqBC,EAAgB,CAC9C,aAAcC,EAA2B,OAAAH,EAAQ,MAAOI,EAAO,QAAS,6BAC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AAQ,MAAO,EACrF,SAAAd,GAD4Be,CAE/B,GAEJ,CAEJ,CAEA,SAASY,EAAiB3B,EAA2B,CACnDT,EAAM,SAAS,QAAQS,EAAWM,GAAU,CAG1C,GACEf,EAAM,eAAee,CAAK,GAC1BA,EAAM,OAASP,GACfO,EAAM,OAASK,GACfL,EAAM,OAASL,EAEf,MAAM,IAAI,MACR,mNACF,CAEJ,CAAC,CACH,CAEA,IAAM2B,EAAgGC,IACpGF,EAAiBE,EAAM,QAAQ,EAExBhC,EAACiC,EAAA,CAAqB,GAAGD,EAAO,GA+BnCC,EAAqBF,EAM3BE,EAAmB,OAAS/B,EAC5B+B,EAAmB,OAASnB,EAC5BmB,EAAmB,kBAAoB7B",
6
6
  "names": ["MasterDetailLayoutElement", "React", "createComponent", "events", "MasterDetailLayout", "createComponent", "MasterDetailLayoutElement", "React", "React", "useEffect", "useLayoutEffect", "useRef", "useState", "Fragment", "jsx", "jsxs", "Master", "children", "DetailPlaceholder", "areChildrenDifferent", "prevChildren", "nextChildren", "prevArray", "child", "nextArray", "i", "prevChild", "nextChild", "Detail", "currentDetailsRef", "currentDetailsKey", "nextDetailsRef", "nextDetailsKey", "state", "setState", "currentChildren", "setCurrentChildren", "layout", "hasChildren", "hasCurrentDetails", "hasNextDetails", "transitionType", "clone", "hasNext", "validateChildren", "MasterDetailLayoutWithValidation", "props", "MasterDetailLayout"]
7
7
  }
package/MenuBar.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"MenuBar.d.ts","sourceRoot":"","sources":["src/MenuBar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,WAAW,IAAI,YAAY,EACjC,MAAM,wBAAwB,CAAC;AAGhC,cAAc,wBAAwB,CAAC;AA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,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;CACnE,CAAC,CAAC;AA4BL,QAAA,MAAM,gBAAgB,EAA0B,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EACtF,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,KACvD,YAAY,GAAG,IAAI,CAAC;AAEzB,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,CAAC"}
package/MenuBar.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/MenuBar.tsx", "src/generated/MenuBar.ts"],
4
- "sourcesContent": ["export * from \"@vaadin/menu-bar/vaadin-menu-bar.js\";\nimport { type ForwardedRef, forwardRef, type ReactElement, type RefAttributes } from 'react';\nimport {\n MenuBar as _MenuBar,\n type MenuBarElement,\n type MenuBarProps as _MenuBarProps,\n type MenuBarItem as _MenuBarItem,\n type SubMenuItem as _SubMenuItem,\n} from './generated/MenuBar.js';\nimport { getOriginalItem, mapItemsWithComponents } from './utils/mapItemsWithComponents.js';\n\nexport * from './generated/MenuBar.js';\n\nexport type SubMenuItem<TItemData extends object = object> = Omit<_SubMenuItem<TItemData>, 'component' | 'children'> & {\n component?: ReactElement | string;\n\n children?: Array<SubMenuItem<TItemData>>;\n};\n\nexport type MenuBarItem<TItemData extends object = object> = Omit<_MenuBarItem<TItemData>, 'component' | 'children'> & {\n component?: ReactElement | string;\n\n children?: Array<SubMenuItem<TItemData>>;\n};\n\nexport type MenuBarItemSelectedEvent<TItem extends MenuBarItem = MenuBarItem> = CustomEvent<{ value: MenuBarItem<TItem> }>;\n\nexport type MenuBarProps<TItem extends MenuBarItem = MenuBarItem> = Partial<Omit<_MenuBarProps, 'items' | 'onItemSelected'>> &\n Readonly<{\n items?: Array<TItem>;\n\n onItemSelected?: (event: MenuBarItemSelectedEvent<TItem>) => void;\n }>;\n\nfunction MenuBar<TItem extends MenuBarItem = MenuBarItem>(props: MenuBarProps<TItem>, ref: ForwardedRef<MenuBarElement>): ReactElement | null {\n const [itemPortals, webComponentItems] = mapItemsWithComponents(props.items, 'vaadin-menu-bar-item');\n\n const onItemSelected = props.onItemSelected;\n const mappedOnItemSelected = onItemSelected\n ? (event: CustomEvent<{ value: _MenuBarItem }>) => {\n // Replace the mapped web component item with the original item\n Object.assign(event.detail, {\n value: getOriginalItem(event.detail.value),\n });\n\n onItemSelected(event as MenuBarItemSelectedEvent<TItem>);\n }\n : undefined;\n\n return (\n <_MenuBar {...props} ref={ref} items={webComponentItems} onItemSelected={mappedOnItemSelected}>\n {props.children}\n {itemPortals}\n </_MenuBar>\n );\n}\n\nconst ForwardedMenuBar = forwardRef(MenuBar) as <TItem extends MenuBarItem = MenuBarItem>(\n props: MenuBarProps<TItem> & RefAttributes<MenuBarElement>,\n) => ReactElement | null;\n\nexport { ForwardedMenuBar as MenuBar };\n", "import type { EventName } from \"@lit/react\";\nimport { MenuBar as MenuBarElement, type MenuBarEventMap as _MenuBarEventMap, } from \"@vaadin/menu-bar/vaadin-menu-bar.js\";\nimport * as React from \"react\";\nimport { createComponent, type WebComponentProps } from \"../utils/createComponent.js\";\nexport { MenuBarElement, };\nexport type MenuBarEventMap = Readonly<{\n onItemSelected: EventName<_MenuBarEventMap[\"item-selected\"]>;\n}>;\nconst events = { onItemSelected: \"item-selected\" } as MenuBarEventMap;\nexport type MenuBarProps = WebComponentProps<MenuBarElement, MenuBarEventMap>;\nexport const MenuBar = createComponent({\n elementClass: MenuBarElement, events, react: React, tagName: \"vaadin-menu-bar\"\n});\n"],
5
- "mappings": "AAAA,WAAc,sCACd,OAA4B,cAAAA,MAAyD,QCArF,OAAS,WAAWC,MAAiE,sCACrF,UAAYC,MAAW,QACvB,OAAS,mBAAAC,MAA+C,6BAKxD,IAAMC,EAAS,CAAE,eAAgB,eAAgB,EAEpCC,EAAUC,EAAgB,CACnC,aAAcC,EAAgB,OAAAH,EAAQ,MAAOI,EAAO,QAAS,iBACjE,CAAC,EDHD,OAAS,mBAAAC,EAAiB,0BAAAC,MAA8B,oCAyCpD,eAAAC,MAAA,oBAhBJ,SAASC,EAAiDC,EAA4BC,EAAwD,CAC5I,GAAM,CAACC,EAAaC,CAAiB,EAAIN,EAAuBG,EAAM,MAAO,sBAAsB,EAE7FI,EAAiBJ,EAAM,eAY7B,OACEF,EAACC,EAAA,CAAU,GAAGC,EAAO,IAAKC,EAAK,MAAOE,EAAmB,eAZ9BC,EACxBC,GAAgD,CAE/C,OAAO,OAAOA,EAAM,OAAQ,CAC1B,MAAOT,EAAgBS,EAAM,OAAO,KAAK,CAC3C,CAAC,EAEDD,EAAeC,CAAwC,CACzD,EACA,OAIC,UAAAL,EAAM,SACNE,GACH,CAEJ,CAEA,IAAMI,EAAmBC,EAAWR,CAAO",
4
+ "sourcesContent": ["export * from \"@vaadin/menu-bar/vaadin-menu-bar.js\";\nimport { type ForwardedRef, forwardRef, type ReactElement, type RefAttributes } from 'react';\nimport {\n MenuBar as _MenuBar,\n type MenuBarElement,\n type MenuBarProps as _MenuBarProps,\n type MenuBarItem as _MenuBarItem,\n type SubMenuItem as _SubMenuItem,\n} from './generated/MenuBar.js';\nimport { getOriginalItem, mapItemsWithComponents } from './utils/mapItemsWithComponents.js';\n\nexport * from './generated/MenuBar.js';\n\nexport type SubMenuItem<TItemData extends object = object> = Omit<_SubMenuItem<TItemData>, 'component' | 'children'> & {\n component?: ReactElement | string;\n\n children?: Array<SubMenuItem<TItemData>>;\n};\n\nexport type MenuBarItem<TItemData extends object = object> = Omit<_MenuBarItem<TItemData>, 'component' | 'children'> & {\n component?: ReactElement | string;\n\n children?: Array<SubMenuItem<TItemData>>;\n};\n\nexport type MenuBarItemSelectedEvent<TItem extends MenuBarItem = MenuBarItem> = CustomEvent<{\n value: MenuBarItem<TItem>;\n}>;\n\nexport type MenuBarProps<TItem extends MenuBarItem = MenuBarItem> = Partial<\n Omit<_MenuBarProps, 'items' | 'onItemSelected'>\n> &\n Readonly<{\n items?: Array<TItem>;\n\n onItemSelected?: (event: MenuBarItemSelectedEvent<TItem>) => void;\n }>;\n\nfunction MenuBar<TItem extends MenuBarItem = MenuBarItem>(\n props: MenuBarProps<TItem>,\n ref: ForwardedRef<MenuBarElement>,\n): ReactElement | null {\n const [itemPortals, webComponentItems] = mapItemsWithComponents(props.items, 'vaadin-menu-bar-item');\n\n const onItemSelected = props.onItemSelected;\n const mappedOnItemSelected = onItemSelected\n ? (event: CustomEvent<{ value: _MenuBarItem }>) => {\n // Replace the mapped web component item with the original item\n Object.assign(event.detail, {\n value: getOriginalItem(event.detail.value),\n });\n\n onItemSelected(event as MenuBarItemSelectedEvent<TItem>);\n }\n : undefined;\n\n return (\n <_MenuBar {...props} ref={ref} items={webComponentItems} onItemSelected={mappedOnItemSelected}>\n {props.children}\n {itemPortals}\n </_MenuBar>\n );\n}\n\nconst ForwardedMenuBar = forwardRef(MenuBar) as <TItem extends MenuBarItem = MenuBarItem>(\n props: MenuBarProps<TItem> & RefAttributes<MenuBarElement>,\n) => ReactElement | null;\n\nexport { ForwardedMenuBar as MenuBar };\n", "import type { EventName } from \"@lit/react\";\nimport { MenuBar as MenuBarElement, type MenuBarEventMap as _MenuBarEventMap, } from \"@vaadin/menu-bar/vaadin-menu-bar.js\";\nimport * as React from \"react\";\nimport { createComponent, type WebComponentProps } from \"../utils/createComponent.js\";\nexport { MenuBarElement, };\nexport type MenuBarEventMap = Readonly<{\n onItemSelected: EventName<_MenuBarEventMap[\"item-selected\"]>;\n}>;\nconst events = { onItemSelected: \"item-selected\" } as MenuBarEventMap;\nexport type MenuBarProps = WebComponentProps<MenuBarElement, MenuBarEventMap>;\nexport const MenuBar = createComponent({\n elementClass: MenuBarElement, events, react: React, tagName: \"vaadin-menu-bar\"\n});\n"],
5
+ "mappings": "AAAA,WAAc,sCACd,OAA4B,cAAAA,MAAyD,QCArF,OAAS,WAAWC,MAAiE,sCACrF,UAAYC,MAAW,QACvB,OAAS,mBAAAC,MAA+C,6BAKxD,IAAMC,EAAS,CAAE,eAAgB,eAAgB,EAEpCC,EAAUC,EAAgB,CACnC,aAAcC,EAAgB,OAAAH,EAAQ,MAAOI,EAAO,QAAS,iBACjE,CAAC,EDHD,OAAS,mBAAAC,EAAiB,0BAAAC,MAA8B,oCAgDpD,eAAAC,MAAA,oBAnBJ,SAASC,EACPC,EACAC,EACqB,CACrB,GAAM,CAACC,EAAaC,CAAiB,EAAIN,EAAuBG,EAAM,MAAO,sBAAsB,EAE7FI,EAAiBJ,EAAM,eAY7B,OACEF,EAACC,EAAA,CAAU,GAAGC,EAAO,IAAKC,EAAK,MAAOE,EAAmB,eAZ9BC,EACxBC,GAAgD,CAE/C,OAAO,OAAOA,EAAM,OAAQ,CAC1B,MAAOT,EAAgBS,EAAM,OAAO,KAAK,CAC3C,CAAC,EAEDD,EAAeC,CAAwC,CACzD,EACA,OAIC,UAAAL,EAAM,SACNE,GACH,CAEJ,CAEA,IAAMI,EAAmBC,EAAWR,CAAO",
6
6
  "names": ["forwardRef", "MenuBarElement", "React", "createComponent", "events", "MenuBar", "createComponent", "MenuBarElement", "React", "getOriginalItem", "mapItemsWithComponents", "jsxs", "MenuBar", "props", "ref", "itemPortals", "webComponentItems", "onItemSelected", "event", "ForwardedMenuBar", "forwardRef"]
7
7
  }
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from "./AccordionHeading.js";
2
2
  export * from "./AccordionPanel.js";
3
3
  export * from "./Accordion.js";
4
- export * from "./AppLayout.js";
5
4
  export * from "./DrawerToggle.js";
5
+ export * from "./AppLayout.js";
6
6
  export * from "./Avatar.js";
7
7
  export * from "./AvatarGroup.js";
8
8
  export * from "./Badge.js";
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from "./AccordionHeading.js";
2
2
  export * from "./AccordionPanel.js";
3
3
  export * from "./Accordion.js";
4
- export * from "./AppLayout.js";
5
4
  export * from "./DrawerToggle.js";
5
+ export * from "./AppLayout.js";
6
6
  export * from "./Avatar.js";
7
7
  export * from "./AvatarGroup.js";
8
8
  export * from "./Badge.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/react-components",
3
- "version": "25.3.0-alpha3",
3
+ "version": "25.3.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,69 +27,69 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@lit/react": "^1.0.7",
30
- "@vaadin/a11y-base": "25.3.0-alpha3",
31
- "@vaadin/accordion": "25.3.0-alpha3",
32
- "@vaadin/app-layout": "25.3.0-alpha3",
33
- "@vaadin/avatar": "25.3.0-alpha3",
34
- "@vaadin/avatar-group": "25.3.0-alpha3",
35
- "@vaadin/badge": "25.3.0-alpha3",
36
- "@vaadin/breadcrumbs": "25.3.0-alpha3",
37
- "@vaadin/button": "25.3.0-alpha3",
38
- "@vaadin/card": "25.3.0-alpha3",
39
- "@vaadin/checkbox": "25.3.0-alpha3",
40
- "@vaadin/checkbox-group": "25.3.0-alpha3",
41
- "@vaadin/combo-box": "25.3.0-alpha3",
42
- "@vaadin/component-base": "25.3.0-alpha3",
43
- "@vaadin/confirm-dialog": "25.3.0-alpha3",
44
- "@vaadin/context-menu": "25.3.0-alpha3",
45
- "@vaadin/custom-field": "25.3.0-alpha3",
46
- "@vaadin/date-picker": "25.3.0-alpha3",
47
- "@vaadin/date-time-picker": "25.3.0-alpha3",
48
- "@vaadin/details": "25.3.0-alpha3",
49
- "@vaadin/dialog": "25.3.0-alpha3",
50
- "@vaadin/email-field": "25.3.0-alpha3",
51
- "@vaadin/field-base": "25.3.0-alpha3",
52
- "@vaadin/field-highlighter": "25.3.0-alpha3",
53
- "@vaadin/form-layout": "25.3.0-alpha3",
54
- "@vaadin/grid": "25.3.0-alpha3",
55
- "@vaadin/horizontal-layout": "25.3.0-alpha3",
56
- "@vaadin/icon": "25.3.0-alpha3",
57
- "@vaadin/icons": "25.3.0-alpha3",
58
- "@vaadin/input-container": "25.3.0-alpha3",
59
- "@vaadin/integer-field": "25.3.0-alpha3",
60
- "@vaadin/item": "25.3.0-alpha3",
61
- "@vaadin/list-box": "25.3.0-alpha3",
62
- "@vaadin/lit-renderer": "25.3.0-alpha3",
63
- "@vaadin/login": "25.3.0-alpha3",
64
- "@vaadin/markdown": "25.3.0-alpha3",
65
- "@vaadin/master-detail-layout": "25.3.0-alpha3",
66
- "@vaadin/menu-bar": "25.3.0-alpha3",
67
- "@vaadin/message-input": "25.3.0-alpha3",
68
- "@vaadin/message-list": "25.3.0-alpha3",
69
- "@vaadin/multi-select-combo-box": "25.3.0-alpha3",
70
- "@vaadin/notification": "25.3.0-alpha3",
71
- "@vaadin/number-field": "25.3.0-alpha3",
72
- "@vaadin/overlay": "25.3.0-alpha3",
73
- "@vaadin/password-field": "25.3.0-alpha3",
74
- "@vaadin/popover": "25.3.0-alpha3",
75
- "@vaadin/progress-bar": "25.3.0-alpha3",
76
- "@vaadin/radio-group": "25.3.0-alpha3",
77
- "@vaadin/scroller": "25.3.0-alpha3",
78
- "@vaadin/select": "25.3.0-alpha3",
79
- "@vaadin/side-nav": "25.3.0-alpha3",
80
- "@vaadin/slider": "25.3.0-alpha3",
81
- "@vaadin/split-layout": "25.3.0-alpha3",
82
- "@vaadin/tabs": "25.3.0-alpha3",
83
- "@vaadin/tabsheet": "25.3.0-alpha3",
84
- "@vaadin/text-area": "25.3.0-alpha3",
85
- "@vaadin/text-field": "25.3.0-alpha3",
86
- "@vaadin/time-picker": "25.3.0-alpha3",
87
- "@vaadin/tooltip": "25.3.0-alpha3",
88
- "@vaadin/upload": "25.3.0-alpha3",
89
- "@vaadin/vaadin-lumo-styles": "25.3.0-alpha3",
90
- "@vaadin/vaadin-themable-mixin": "25.3.0-alpha3",
91
- "@vaadin/vertical-layout": "25.3.0-alpha3",
92
- "@vaadin/virtual-list": "25.3.0-alpha3"
30
+ "@vaadin/a11y-base": "25.3.0-alpha4",
31
+ "@vaadin/accordion": "25.3.0-alpha4",
32
+ "@vaadin/app-layout": "25.3.0-alpha4",
33
+ "@vaadin/avatar": "25.3.0-alpha4",
34
+ "@vaadin/avatar-group": "25.3.0-alpha4",
35
+ "@vaadin/badge": "25.3.0-alpha4",
36
+ "@vaadin/breadcrumbs": "25.3.0-alpha4",
37
+ "@vaadin/button": "25.3.0-alpha4",
38
+ "@vaadin/card": "25.3.0-alpha4",
39
+ "@vaadin/checkbox": "25.3.0-alpha4",
40
+ "@vaadin/checkbox-group": "25.3.0-alpha4",
41
+ "@vaadin/combo-box": "25.3.0-alpha4",
42
+ "@vaadin/component-base": "25.3.0-alpha4",
43
+ "@vaadin/confirm-dialog": "25.3.0-alpha4",
44
+ "@vaadin/context-menu": "25.3.0-alpha4",
45
+ "@vaadin/custom-field": "25.3.0-alpha4",
46
+ "@vaadin/date-picker": "25.3.0-alpha4",
47
+ "@vaadin/date-time-picker": "25.3.0-alpha4",
48
+ "@vaadin/details": "25.3.0-alpha4",
49
+ "@vaadin/dialog": "25.3.0-alpha4",
50
+ "@vaadin/email-field": "25.3.0-alpha4",
51
+ "@vaadin/field-base": "25.3.0-alpha4",
52
+ "@vaadin/field-highlighter": "25.3.0-alpha4",
53
+ "@vaadin/form-layout": "25.3.0-alpha4",
54
+ "@vaadin/grid": "25.3.0-alpha4",
55
+ "@vaadin/horizontal-layout": "25.3.0-alpha4",
56
+ "@vaadin/icon": "25.3.0-alpha4",
57
+ "@vaadin/icons": "25.3.0-alpha4",
58
+ "@vaadin/input-container": "25.3.0-alpha4",
59
+ "@vaadin/integer-field": "25.3.0-alpha4",
60
+ "@vaadin/item": "25.3.0-alpha4",
61
+ "@vaadin/list-box": "25.3.0-alpha4",
62
+ "@vaadin/lit-renderer": "25.3.0-alpha4",
63
+ "@vaadin/login": "25.3.0-alpha4",
64
+ "@vaadin/markdown": "25.3.0-alpha4",
65
+ "@vaadin/master-detail-layout": "25.3.0-alpha4",
66
+ "@vaadin/menu-bar": "25.3.0-alpha4",
67
+ "@vaadin/message-input": "25.3.0-alpha4",
68
+ "@vaadin/message-list": "25.3.0-alpha4",
69
+ "@vaadin/multi-select-combo-box": "25.3.0-alpha4",
70
+ "@vaadin/notification": "25.3.0-alpha4",
71
+ "@vaadin/number-field": "25.3.0-alpha4",
72
+ "@vaadin/overlay": "25.3.0-alpha4",
73
+ "@vaadin/password-field": "25.3.0-alpha4",
74
+ "@vaadin/popover": "25.3.0-alpha4",
75
+ "@vaadin/progress-bar": "25.3.0-alpha4",
76
+ "@vaadin/radio-group": "25.3.0-alpha4",
77
+ "@vaadin/scroller": "25.3.0-alpha4",
78
+ "@vaadin/select": "25.3.0-alpha4",
79
+ "@vaadin/side-nav": "25.3.0-alpha4",
80
+ "@vaadin/slider": "25.3.0-alpha4",
81
+ "@vaadin/split-layout": "25.3.0-alpha4",
82
+ "@vaadin/tabs": "25.3.0-alpha4",
83
+ "@vaadin/tabsheet": "25.3.0-alpha4",
84
+ "@vaadin/text-area": "25.3.0-alpha4",
85
+ "@vaadin/text-field": "25.3.0-alpha4",
86
+ "@vaadin/time-picker": "25.3.0-alpha4",
87
+ "@vaadin/tooltip": "25.3.0-alpha4",
88
+ "@vaadin/upload": "25.3.0-alpha4",
89
+ "@vaadin/vaadin-lumo-styles": "25.3.0-alpha4",
90
+ "@vaadin/vaadin-themable-mixin": "25.3.0-alpha4",
91
+ "@vaadin/vertical-layout": "25.3.0-alpha4",
92
+ "@vaadin/virtual-list": "25.3.0-alpha4"
93
93
  },
94
94
  "author": "Vaadin Ltd.",
95
95
  "license": "Apache-2.0",
@@ -1,2 +1,2 @@
1
- import{createComponent as n}from"@lit/react";window.Vaadin??={},window.Vaadin.registrations??=[],window.Vaadin.registrations.push({is:"@vaadin/react-components",version:"25.3.0-alpha3"});function s(e){const{elementClass:t}=e;return n("_properties"in t?{...e,elementClass:{name:t.name,prototype:{...t._properties,hidden:Boolean}}}:e)}export{s as createComponent};
1
+ import{createComponent as n}from"@lit/react";window.Vaadin??={},window.Vaadin.registrations??=[],window.Vaadin.registrations.push({is:"@vaadin/react-components",version:"25.3.0-alpha4"});function s(e){const{elementClass:t}=e;return n("_properties"in t?{...e,elementClass:{name:t.name,prototype:{...t._properties,hidden:Boolean}}}:e)}export{s as createComponent};
2
2
  //# sourceMappingURL=createComponent.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/utils/createComponent.ts"],
4
- "sourcesContent": ["import { createComponent as _createComponent, type EventName } from '@lit/react';\nimport type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';\nimport type React from 'react';\nimport type { RefAttributes } from 'react';\n\ndeclare const __VERSION__: string;\n\ndeclare global {\n interface VaadinRegistration {\n is: string;\n version: string;\n }\n\n interface Vaadin {\n registrations?: VaadinRegistration[];\n }\n\n interface Window {\n // @ts-expect-error: Different declaration from one of the dependencies.\n Vaadin?: Vaadin;\n }\n}\n\nwindow.Vaadin ??= {};\nwindow.Vaadin.registrations ??= [];\nwindow.Vaadin.registrations.push({\n is: '@vaadin/react-components',\n version: /* updated-by-script */ '25.3.0-alpha3',\n});\n\n// TODO: Remove when types from @lit-labs/react are exported\nexport type EventNames = Record<string, EventName | string>;\ntype Constructor<T> = { new (): T; name: string };\ntype PolymerConstructor<T> = Constructor<T> & { _properties: Record<string, unknown> };\ntype Options<I extends HTMLElement, E extends EventNames = {}> = Readonly<{\n displayName?: string;\n elementClass: Constructor<I> | PolymerConstructor<I>;\n events?: E;\n react: typeof window.React;\n tagName: string;\n}>;\n\n// A map of expected event listener types based on EventNames.\ntype EventListeners<R extends EventNames> = {\n [K in keyof R]?: R[K] extends EventName ? (e: R[K]['__eventType']) => void : (e: Event) => void;\n};\n\n// Props derived from custom element class. Currently has limitations of making\n// all properties optional and also surfaces life cycle methods in autocomplete.\n// TODO: LoginOverlay has \"autofocus\" property, so we add it back manually.\ntype ElementProps<I> = Partial<Omit<I, keyof HTMLElement>> & { autofocus?: boolean };\n\n// Acceptable props to the React component.\ntype ComponentProps<I, E extends EventNames = {}> = Omit<\n React.HTMLAttributes<I>,\n // Prefer type of provided event handler props or those on element over\n // built-in HTMLAttributes\n keyof E | keyof ElementProps<I>\n> &\n EventListeners<E> &\n ElementProps<I>;\n\nexport type ThemedWebComponentProps<\n I extends ThemePropertyMixinClass & HTMLElement,\n E extends EventNames = {},\n> = ComponentProps<I, E> & {\n /**\n * Attribute that can be used by the component to apply built-in style variants,\n * or to propagate its value to the sub-components in Shadow DOM.\n *\n * @see ThemePropertyMixinClass#_theme\n */\n theme?: string;\n};\n\ntype AllWebComponentProps<I extends HTMLElement, E extends EventNames = {}> = I extends ThemePropertyMixinClass\n ? ThemedWebComponentProps<I, E>\n : ComponentProps<I, E>;\n\nexport type WebComponentProps<I extends HTMLElement, E extends EventNames = {}> = Partial<AllWebComponentProps<I, E>>;\n\n// We need a separate declaration here; otherwise, the TypeScript fails into the\n// endless loop trying to resolve the typings.\nexport function createComponent<I extends HTMLElement, E extends EventNames = {}>(\n options: Options<I, E>,\n): (props: WebComponentProps<I, E> & RefAttributes<I>) => React.ReactElement | null;\n\nexport function createComponent<I extends HTMLElement, E extends EventNames = {}>(options: Options<I, E>): any {\n const { elementClass } = options;\n\n return _createComponent(\n '_properties' in elementClass\n ? {\n ...options,\n // TODO: improve or remove the Polymer workaround\n // 'createComponent' relies on key presence on the custom element class,\n // but Polymer defines properties on the prototype when the first element\n // is created. Workaround: pass a mock object with properties in\n // the prototype.\n elementClass: {\n // @ts-expect-error: it is a specific workaround for Polymer classes.\n name: elementClass.name,\n prototype: { ...elementClass._properties, hidden: Boolean },\n },\n }\n : options,\n );\n}\n"],
4
+ "sourcesContent": ["import { createComponent as _createComponent, type EventName } from '@lit/react';\nimport type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';\nimport type React from 'react';\nimport type { RefAttributes } from 'react';\n\ndeclare const __VERSION__: string;\n\ndeclare global {\n interface VaadinRegistration {\n is: string;\n version: string;\n }\n\n interface Vaadin {\n registrations?: VaadinRegistration[];\n }\n\n interface Window {\n // @ts-expect-error: Different declaration from one of the dependencies.\n Vaadin?: Vaadin;\n }\n}\n\nwindow.Vaadin ??= {};\nwindow.Vaadin.registrations ??= [];\nwindow.Vaadin.registrations.push({\n is: '@vaadin/react-components',\n version: /* updated-by-script */ '25.3.0-alpha4',\n});\n\n// TODO: Remove when types from @lit-labs/react are exported\nexport type EventNames = Record<string, EventName | string>;\ntype Constructor<T> = { new (): T; name: string };\ntype PolymerConstructor<T> = Constructor<T> & { _properties: Record<string, unknown> };\ntype Options<I extends HTMLElement, E extends EventNames = {}> = Readonly<{\n displayName?: string;\n elementClass: Constructor<I> | PolymerConstructor<I>;\n events?: E;\n react: typeof window.React;\n tagName: string;\n}>;\n\n// A map of expected event listener types based on EventNames.\ntype EventListeners<R extends EventNames> = {\n [K in keyof R]?: R[K] extends EventName ? (e: R[K]['__eventType']) => void : (e: Event) => void;\n};\n\n// Props derived from custom element class. Currently has limitations of making\n// all properties optional and also surfaces life cycle methods in autocomplete.\n// TODO: LoginOverlay has \"autofocus\" property, so we add it back manually.\ntype ElementProps<I> = Partial<Omit<I, keyof HTMLElement>> & { autofocus?: boolean };\n\n// Acceptable props to the React component.\ntype ComponentProps<I, E extends EventNames = {}> = Omit<\n React.HTMLAttributes<I>,\n // Prefer type of provided event handler props or those on element over\n // built-in HTMLAttributes\n keyof E | keyof ElementProps<I>\n> &\n EventListeners<E> &\n ElementProps<I>;\n\nexport type ThemedWebComponentProps<\n I extends ThemePropertyMixinClass & HTMLElement,\n E extends EventNames = {},\n> = ComponentProps<I, E> & {\n /**\n * Attribute that can be used by the component to apply built-in style variants,\n * or to propagate its value to the sub-components in Shadow DOM.\n *\n * @see ThemePropertyMixinClass#_theme\n */\n theme?: string;\n};\n\ntype AllWebComponentProps<I extends HTMLElement, E extends EventNames = {}> = I extends ThemePropertyMixinClass\n ? ThemedWebComponentProps<I, E>\n : ComponentProps<I, E>;\n\nexport type WebComponentProps<I extends HTMLElement, E extends EventNames = {}> = Partial<AllWebComponentProps<I, E>>;\n\n// We need a separate declaration here; otherwise, the TypeScript fails into the\n// endless loop trying to resolve the typings.\nexport function createComponent<I extends HTMLElement, E extends EventNames = {}>(\n options: Options<I, E>,\n): (props: WebComponentProps<I, E> & RefAttributes<I>) => React.ReactElement | null;\n\nexport function createComponent<I extends HTMLElement, E extends EventNames = {}>(options: Options<I, E>): any {\n const { elementClass } = options;\n\n return _createComponent(\n '_properties' in elementClass\n ? {\n ...options,\n // TODO: improve or remove the Polymer workaround\n // 'createComponent' relies on key presence on the custom element class,\n // but Polymer defines properties on the prototype when the first element\n // is created. Workaround: pass a mock object with properties in\n // the prototype.\n elementClass: {\n // @ts-expect-error: it is a specific workaround for Polymer classes.\n name: elementClass.name,\n prototype: { ...elementClass._properties, hidden: Boolean },\n },\n }\n : options,\n );\n}\n"],
5
5
  "mappings": "AAAA,OAAS,mBAAmBA,MAAwC,aAuBpE,OAAO,SAAW,CAAC,EACnB,OAAO,OAAO,gBAAkB,CAAC,EACjC,OAAO,OAAO,cAAc,KAAK,CAC/B,GAAI,2BACJ,QAAiC,eACnC,CAAC,EA2DM,SAASC,EAAkEC,EAA6B,CAC7G,KAAM,CAAE,aAAAC,CAAa,EAAID,EAEzB,OAAOF,EACL,gBAAiBG,EACb,CACE,GAAGD,EAMH,aAAc,CAEZ,KAAMC,EAAa,KACnB,UAAW,CAAE,GAAGA,EAAa,YAAa,OAAQ,OAAQ,CAC5D,CACF,EACAD,CACN,CACF",
6
6
  "names": ["_createComponent", "createComponent", "options", "elementClass"]
7
7
  }