@fluentui/react-utilities 9.6.0 → 9.6.1

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 (82) hide show
  1. package/CHANGELOG.json +30 -1
  2. package/CHANGELOG.md +12 -2
  3. package/dist/index.d.ts +32 -10
  4. package/lib/compose/getSlots.js.map +1 -1
  5. package/lib/compose/isResolvedShorthand.js.map +1 -1
  6. package/lib/compose/resolveShorthand.js.map +1 -1
  7. package/lib/compose/types.js.map +1 -1
  8. package/lib/events/mouseTouchHelpers.js.map +1 -1
  9. package/lib/hooks/useControllableState.js.map +1 -1
  10. package/lib/hooks/useEventCallback.js.map +1 -1
  11. package/lib/hooks/useFirstMount.js.map +1 -1
  12. package/lib/hooks/useForceUpdate.js.map +1 -1
  13. package/lib/hooks/useId.js.map +1 -1
  14. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  15. package/lib/hooks/useMergedRefs.js.map +1 -1
  16. package/lib/hooks/useOnClickOutside.js.map +1 -1
  17. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  18. package/lib/hooks/usePrevious.js.map +1 -1
  19. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  20. package/lib/hooks/useTimeout.js.map +1 -1
  21. package/lib/index.js +1 -1
  22. package/lib/index.js.map +1 -1
  23. package/lib/ssr/SSRContext.js.map +1 -1
  24. package/lib/ssr/canUseDOM.js.map +1 -1
  25. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  26. package/lib/trigger/getTriggerChild.js.map +1 -1
  27. package/lib/trigger/isFluentTrigger.js.map +1 -1
  28. package/lib/utils/getNativeElementProps.js.map +1 -1
  29. package/lib/utils/getRTLSafeKey.js.map +1 -1
  30. package/lib/utils/getReactCallbackName.js.map +1 -1
  31. package/lib/utils/isHTMLElement.js.map +1 -1
  32. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  33. package/lib/utils/mergeCallbacks.js.map +1 -1
  34. package/lib/utils/omit.js.map +1 -1
  35. package/lib/utils/properties.js.map +1 -1
  36. package/lib-amd/compose/getSlots.js.map +1 -1
  37. package/lib-amd/compose/types.js.map +1 -1
  38. package/lib-amd/hooks/useMergedRefs.js.map +1 -1
  39. package/lib-amd/index.js +2 -1
  40. package/lib-amd/index.js.map +1 -1
  41. package/lib-amd/utils/getNativeElementProps.js.map +1 -1
  42. package/lib-commonjs/compose/getSlots.js.map +1 -1
  43. package/lib-commonjs/compose/index.js.map +1 -1
  44. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  45. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  46. package/lib-commonjs/compose/types.js.map +1 -1
  47. package/lib-commonjs/events/index.js.map +1 -1
  48. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  49. package/lib-commonjs/hooks/index.js.map +1 -1
  50. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  51. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  52. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  53. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  54. package/lib-commonjs/hooks/useId.js.map +1 -1
  55. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  56. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  57. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  58. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  59. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  60. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  61. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  62. package/lib-commonjs/index.js +7 -1
  63. package/lib-commonjs/index.js.map +1 -1
  64. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  65. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  66. package/lib-commonjs/ssr/index.js.map +1 -1
  67. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  68. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  69. package/lib-commonjs/trigger/index.js.map +1 -1
  70. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  71. package/lib-commonjs/trigger/types.js.map +1 -1
  72. package/lib-commonjs/utils/clamp.js.map +1 -1
  73. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  74. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  75. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  76. package/lib-commonjs/utils/index.js.map +1 -1
  77. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  78. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  79. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  80. package/lib-commonjs/utils/omit.js.map +1 -1
  81. package/lib-commonjs/utils/properties.js.map +1 -1
  82. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,mBAAmB;AAGnD;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAM,SAAUC,eAAe,CAC7BC,QAAqD;EAGrD,IAAI,eAACH,KAAK,CAACI,cAAc,CAAoBD,QAAQ,CAAC,EAAE;IACtD,OAAO,IAAI;;EAEb,OAAOF,eAAe,CAACE,QAAQ,CAAC,GAC5BD,eAAe;EACb;EACA;EACCC,QAAQ,CAACE,KAAsB,CAACF,QAAQ,CAC1C,GACDA,QAAQ;AACd","names":["React","isFluentTrigger","getTriggerChild","children","isValidElement","props"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/trigger/getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\n}\n"]}
1
+ {"version":3,"names":["React","isFluentTrigger","getTriggerChild","children","isValidElement","props"],"sources":["../src/packages/react-components/react-utilities/src/trigger/getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,mBAAmB;AAGnD;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAM,SAAUC,eAAeA,CAC7BC,QAAqD;EAGrD,IAAI,eAACH,KAAK,CAACI,cAAc,CAAoBD,QAAQ,CAAC,EAAE;IACtD,OAAO,IAAI;;EAEb,OAAOF,eAAe,CAACE,QAAQ,CAAC,GAC5BD,eAAe;EACb;EACA;EACCC,QAAQ,CAACE,KAAsB,CAACF,QAAQ,CAC1C,GACDA,QAAQ;AACd"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAGA;;;;;AAKA,OAAM,SAAUA,eAAe,CAACC,OAA2B;EACzD,OAAOC,OAAO,CAAED,OAAO,CAACE,IAA+B,CAACC,wBAAwB,CAAC;AACnF","names":["isFluentTrigger","element","Boolean","type","isFluentTriggerComponent"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/trigger/isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"]}
1
+ {"version":3,"names":["isFluentTrigger","element","Boolean","type","isFluentTriggerComponent"],"sources":["../src/packages/react-components/react-utilities/src/trigger/isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"],"mappings":"AAGA;;;;;AAKA,OAAM,SAAUA,eAAeA,CAACC,OAA2B;EACzD,OAAOC,OAAO,CAAED,OAAO,CAACE,IAA+B,CAACC,wBAAwB,CAAC;AACnF"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AACA,SACEA,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,kBAAkB,EAClBC,aAAa,EACbC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,qBAAqB,EACrBC,cAAc,EACdC,cAAc,EACdC,gBAAgB,QACX,cAAc;AAErB,MAAMC,gBAAgB,GAA2C;EAC/DC,KAAK,EAAE1B,eAAe;EACtB2B,KAAK,EAAE1B,eAAe;EACtB2B,KAAK,EAAE1B,eAAe;EACtB2B,EAAE,EAAE1B,YAAY;EAChB2B,EAAE,EAAE1B,YAAY;EAChB2B,CAAC,EAAE1B,gBAAgB;EACnB2B,MAAM,EAAE1B,gBAAgB;EACxB2B,KAAK,EAAE1B,eAAe;EACtB2B,QAAQ,EAAE1B,kBAAkB;EAC5B2B,MAAM,EAAE1B,gBAAgB;EACxB2B,MAAM,EAAE1B,gBAAgB;EACxB2B,KAAK,EAAE1B,eAAe;EACtB2B,EAAE,EAAE1B,YAAY;EAChB2B,EAAE,EAAE1B,YAAY;EAChB2B,EAAE,EAAE1B,YAAY;EAChB2B,QAAQ,EAAE1B,kBAAkB;EAC5B2B,GAAG,EAAE1B,aAAa;EAClB2B,QAAQ,EAAE1B,kBAAkB;EAC5B2B,IAAI,EAAE1B,cAAc;EACpB2B,MAAM,EAAE1B,gBAAgB;EACxB2B,GAAG,EAAE1B,aAAa;EAClB2B,IAAI,EAAExB,cAAc;EACpByB,MAAM,EAAExB;CACT;AAED;;;;;;;AAOA;AACA,OAAM,SAAUyB,qBAAqB,CACnCC,OAAe,EACfC,KAAS,EACTC,iBAA4B;EAE5B,MAAMC,gBAAgB,GAAIH,OAAO,IAAIzB,gBAAgB,CAACyB,OAAO,CAAC,IAAK7B,qBAAqB;EACxFgC,gBAAgB,CAACC,EAAE,GAAG,CAAC;EAEvB,OAAOhC,cAAc,CAAC6B,KAAK,EAAEE,gBAAgB,EAAED,iBAAiB,CAAC;AACnE;AAEA;;;;;;;;AAQA,OAAO,MAAMG,yBAAyB,GAAG,CAGvC;EACAC,kBAAkB;EAClBL,KAAK;EACLC;AAAiB,CAUlB,KAAI;EACH,OAAO;IACLK,IAAI,EAAE;MAAEC,KAAK,EAAEP,KAAK,CAACO,KAAK;MAAEC,SAAS,EAAER,KAAK,CAACQ;IAAS,CAAE;IACxDC,OAAO,EAAEX,qBAAqB,CAAgCO,kBAAkB,EAAEL,KAAK,EAAE,CACvF,IAAIC,iBAAiB,IAAI,EAAE,CAAC,EAC5B,OAAO,EACP,WAAW,CACZ;GACF;AACH,CAAC","names":["labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","htmlElementProperties","getNativeProps","timeProperties","dialogProperties","nativeElementMap","label","audio","video","ol","li","a","button","input","textarea","select","option","table","tr","th","td","colGroup","col","fieldset","form","iframe","img","time","dialog","getNativeElementProps","tagName","props","excludedPropNames","allowedPropNames","as","getPartitionedNativeProps","primarySlotTagName","root","style","className","primary"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/getNativeElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n fieldsetProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n timeProperties,\n dialogProperties,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n fieldset: fieldsetProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n time: timeProperties,\n dialog: dialogProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n allowedPropNames.as = 1;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n\n/**\n * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.\n *\n * This function is only for use with components that have a primary slot other than `root`.\n * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.\n *\n * @returns An object containing the native props for the `root` and primary slots.\n */\nexport const getPartitionedNativeProps = <\n Props extends Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>,\n ExcludedPropKeys extends Extract<keyof Props, string> = never\n>({\n primarySlotTagName,\n props,\n excludedPropNames,\n}: {\n /** The primary slot's element type (e.g. 'div') */\n primarySlotTagName: keyof JSX.IntrinsicElements;\n\n /** The component's props object */\n props: Props;\n\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[];\n}) => {\n return {\n root: { style: props.style, className: props.className },\n primary: getNativeElementProps<Omit<Props, ExcludedPropKeys>>(primarySlotTagName, props, [\n ...(excludedPropNames || []),\n 'style',\n 'className',\n ]),\n };\n};\n"]}
1
+ {"version":3,"names":["labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","htmlElementProperties","getNativeProps","timeProperties","dialogProperties","nativeElementMap","label","audio","video","ol","li","a","button","input","textarea","select","option","table","tr","th","td","colGroup","col","fieldset","form","iframe","img","time","dialog","getNativeElementProps","tagName","props","excludedPropNames","allowedPropNames","as","getPartitionedNativeProps","primarySlotTagName","root","style","className","primary"],"sources":["../src/packages/react-components/react-utilities/src/utils/getNativeElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n fieldsetProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n timeProperties,\n dialogProperties,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n fieldset: fieldsetProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n time: timeProperties,\n dialog: dialogProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n allowedPropNames.as = 1;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n\n/**\n * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.\n *\n * This function is only for use with components that have a primary slot other than `root`.\n * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.\n *\n * @returns An object containing the native props for the `root` and primary slots.\n */\nexport const getPartitionedNativeProps = <\n Props extends Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>({\n primarySlotTagName,\n props,\n excludedPropNames,\n}: {\n /** The primary slot's element type (e.g. 'div') */\n primarySlotTagName: keyof JSX.IntrinsicElements;\n\n /** The component's props object */\n props: Props;\n\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[];\n}) => {\n return {\n root: { style: props.style, className: props.className },\n primary: getNativeElementProps<Omit<Props, ExcludedPropKeys>>(primarySlotTagName, props, [\n ...(excludedPropNames || []),\n 'style',\n 'className',\n ]),\n };\n};\n"],"mappings":"AACA,SACEA,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,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yB,GAAGA,CAGvC;EACAC,kBAAkB;EAClBL,KAAK;EACLC;AAAiB,CAUlB,KAAI;EACH,OAAO;IACLK,IAAI,EAAE;MAAEC,KAAK,EAAEP,KAAK,CAACO,KAAK;MAAEC,SAAS,EAAER,KAAK,CAACQ;IAAS,CAAE;IACxDC,OAAO,EAAEX,qBAAqB,CAAgCO,kBAAkB,EAAEL,KAAK,EAAE,CACvF,IAAIC,iBAAiB,IAAI,EAAE,CAAC,EAC5B,OAAO,EACP,WAAW,CACZ;GACF;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA;;;;AAIA,OAAO,MAAMA,aAAa,GAAG,CAACC,GAAW,EAAEC,GAAkB,KAAI;EAC/D,IAAIA,GAAG,KAAK,KAAK,EAAE;IACjB,QAAQD,GAAG;MACT,KAAK,WAAW;QAAE;UAChB,OAAO,YAAY;;MAGrB,KAAK,YAAY;QAAE;UACjB,OAAO,WAAW;;IACnB;;EAIL,OAAOA,GAAG;AACZ,CAAC","names":["getRTLSafeKey","key","dir"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/getRTLSafeKey.ts"],"sourcesContent":["/**\n * @internal\n * Finds and swaps a provided key for it's right to left format.\n */\nexport const getRTLSafeKey = (key: string, dir: 'ltr' | 'rtl') => {\n if (dir === 'rtl') {\n switch (key) {\n case 'ArrowLeft': {\n return 'ArrowRight';\n }\n\n case 'ArrowRight': {\n return 'ArrowLeft';\n }\n }\n }\n\n return key;\n};\n"]}
1
+ {"version":3,"names":["getRTLSafeKey","key","dir"],"sources":["../src/packages/react-components/react-utilities/src/utils/getRTLSafeKey.ts"],"sourcesContent":["/**\n * @internal\n * Finds and swaps a provided key for it's right to left format.\n */\nexport const getRTLSafeKey = (key: string, dir: 'ltr' | 'rtl') => {\n if (dir === 'rtl') {\n switch (key) {\n case 'ArrowLeft': {\n return 'ArrowRight';\n }\n\n case 'ArrowRight': {\n return 'ArrowLeft';\n }\n }\n }\n\n return key;\n};\n"],"mappings":"AAAA;;;;AAIA,OAAO,MAAMA,aAAa,GAAGA,CAACC,GAAW,EAAEC,GAAkB,KAAI;EAC/D,IAAIA,GAAG,KAAK,KAAK,EAAE;IACjB,QAAQD,GAAG;MACT,KAAK,WAAW;QAAE;UAChB,OAAO,YAAY;;MAGrB,KAAK,YAAY;QAAE;UACjB,OAAO,WAAW;;IACnB;;EAIL,OAAOA,GAAG;AACZ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAwBA;;;;;;;AAOA,OAAM,SAAUA,oBAAoB,CAACC,KAA0B;EAC7D,IAAIA,KAAK,CAACC,UAAU,EAAE;IACpB,OAAOD,KAAK,CAACC,UAA+B;;EAG9C,IAAID,KAAK,CAACE,cAAc,EAAE;IACxB,IAAIF,KAAK,CAACE,cAAc,CAACC,gBAAgB,EAAE;MACzC,OAAOH,KAAK,CAACE,cAAc,CAACC,gBAAqC;;IAGnE,OAAOH,KAAK,CAACE,cAAc,CAACE,uBAAuB,CAACC,OAA4B;;EAGlF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACAC,OAAO,CAACC,KAAK,CAAC,CACZ,kFAAkF,EAClF,mFAAmF,CACpF,CAAC;;AAEN","names":["getReactCallbackName","event","_reactName","dispatchConfig","registrationName","phasedRegistrationNames","bubbled","process","env","NODE_ENV","console","error"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/getReactCallbackName.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {\n // React 17/18\n // See https://github.com/facebook/react/pull/19236\n _reactName?: string;\n\n // React 16\n dispatchConfig?: {\n registrationName: string;\n phasedRegistrationNames: {\n bubbled: string;\n captured: string;\n };\n };\n}\n\ntype NonUndefined<A> = A extends undefined ? never : A;\ntype FunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;\n}[keyof T];\n\nexport type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;\n\n/**\n * React.SyntheticEvent contains name of a callback that should be fired, this function returns it.\n *\n * Ideally, it should also distinguish regular and \"capture\" callbacks, but it's possible only with React 17 as\n * \".eventPhase\" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events\n * are handled in bubble phase.\n */\nexport function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined {\n if (event._reactName) {\n return event._reactName as ReactCallbackName;\n }\n\n if (event.dispatchConfig) {\n if (event.dispatchConfig.registrationName) {\n return event.dispatchConfig.registrationName as ReactCallbackName;\n }\n\n return event.dispatchConfig.phasedRegistrationNames.bubbled as ReactCallbackName;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error([\n 'Passed React.SyntheticEvent does not contain \".dispatchConfig\" or \"._reactName\".',\n 'This should not happen, please report it to https://github.com/microsoft/fluentui',\n ]);\n }\n}\n"]}
1
+ {"version":3,"names":["getReactCallbackName","event","_reactName","dispatchConfig","registrationName","phasedRegistrationNames","bubbled","process","env","NODE_ENV","console","error"],"sources":["../src/packages/react-components/react-utilities/src/utils/getReactCallbackName.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {\n // React 17/18\n // See https://github.com/facebook/react/pull/19236\n _reactName?: string;\n\n // React 16\n dispatchConfig?: {\n registrationName: string;\n phasedRegistrationNames: {\n bubbled: string;\n captured: string;\n };\n };\n}\n\ntype NonUndefined<A> = A extends undefined ? never : A;\ntype FunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;\n}[keyof T];\n\nexport type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;\n\n/**\n * React.SyntheticEvent contains name of a callback that should be fired, this function returns it.\n *\n * Ideally, it should also distinguish regular and \"capture\" callbacks, but it's possible only with React 17 as\n * \".eventPhase\" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events\n * are handled in bubble phase.\n */\nexport function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined {\n if (event._reactName) {\n return event._reactName as ReactCallbackName;\n }\n\n if (event.dispatchConfig) {\n if (event.dispatchConfig.registrationName) {\n return event.dispatchConfig.registrationName as ReactCallbackName;\n }\n\n return event.dispatchConfig.phasedRegistrationNames.bubbled as ReactCallbackName;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error([\n 'Passed React.SyntheticEvent does not contain \".dispatchConfig\" or \"._reactName\".',\n 'This should not happen, please report it to https://github.com/microsoft/fluentui',\n ]);\n }\n}\n"],"mappings":"AAwBA;;;;;;;AAOA,OAAM,SAAUA,oBAAoBA,CAACC,KAA0B;EAC7D,IAAIA,KAAK,CAACC,UAAU,EAAE;IACpB,OAAOD,KAAK,CAACC,UAA+B;;EAG9C,IAAID,KAAK,CAACE,cAAc,EAAE;IACxB,IAAIF,KAAK,CAACE,cAAc,CAACC,gBAAgB,EAAE;MACzC,OAAOH,KAAK,CAACE,cAAc,CAACC,gBAAqC;;IAGnE,OAAOH,KAAK,CAACE,cAAc,CAACE,uBAAuB,CAACC,OAA4B;;EAGlF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACAC,OAAO,CAACC,KAAK,CAAC,CACZ,kFAAkF,EAClF,mFAAmF,CACpF,CAAC;;AAEN"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA;;;;;;;;;AASA,OAAM,SAAUA,aAAa,CAACC,OAAiB;;EAC7C,MAAMC,YAAY,GAAGD,OAAkC;EACvD,OAAOE,OAAO,CACZD,YAAY,KAAK,IAAI,KACnB,kBAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEE,aAAa,0CAAEC,WAAW,KACxCH,YAAY,YAAYA,YAAY,CAACE,aAAa,CAACC,WAAW,CAACC,WAAW,CAC7E;AACH","names":["isHTMLElement","element","typedElement","Boolean","ownerDocument","defaultView","HTMLElement"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement(element?: unknown): element is HTMLElement {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement !== null &&\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement,\n );\n}\n"]}
1
+ {"version":3,"names":["isHTMLElement","element","typedElement","Boolean","_a","ownerDocument","defaultView","HTMLElement"],"sources":["../src/packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement(element?: unknown): element is HTMLElement {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement !== null &&\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement,\n );\n}\n"],"mappings":"AAAA;;;;;;;;;AASA,OAAM,SAAUA,aAAaA,CAACC,OAAiB;;EAC7C,MAAMC,YAAY,GAAGD,OAAkC;EACvD,OAAOE,OAAO,CACZD,YAAY,KAAK,IAAI,KACnB,CAAAE,EAAA,GAAAF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,aAAa,cAAAD,EAAA,uBAAAA,EAAA,CAAEE,WAAW,KACxCJ,YAAY,YAAYA,YAAY,CAACG,aAAa,CAACC,WAAW,CAACC,WAAW,CAC7E;AACH"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C;;;;AAIA,OAAM,SAAUC,wBAAwB,CAACC,OAAgB;EACvD,IAAI,CAACF,aAAa,CAACE,OAAO,CAAC,EAAE;IAC3B,OAAO,KAAK;;EAGd,MAAM;IAAEC;EAAO,CAAE,GAAGD,OAAO;EAC3B,QAAQC,OAAO;IACb,KAAK,QAAQ;IACb,KAAK,GAAG;IACR,KAAK,OAAO;IACZ,KAAK,UAAU;MACb,OAAO,IAAI;EAAC;EAGhB,OAAOD,OAAO,CAACE,iBAAiB;AAClC","names":["isHTMLElement","isInteractiveHTMLElement","element","tagName","isContentEditable"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"]}
1
+ {"version":3,"names":["isHTMLElement","isInteractiveHTMLElement","element","tagName","isContentEditable"],"sources":["../src/packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C;;;;AAIA,OAAM,SAAUC,wBAAwBA,CAACC,OAAgB;EACvD,IAAI,CAACF,aAAa,CAACE,OAAO,CAAC,EAAE;IAC3B,OAAO,KAAK;;EAGd,MAAM;IAAEC;EAAO,CAAE,GAAGD,OAAO;EAC3B,QAAQC,OAAO;IACb,KAAK,QAAQ;IACb,KAAK,GAAG;IACR,KAAK,OAAO;IACZ,KAAK,UAAU;MACb,OAAO,IAAI;EAAC;EAGhB,OAAOD,OAAO,CAACE,iBAAiB;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAM,SAAUA,cAAc,CAC5BC,SAAgD,EAChDC,SAAgD;EAEhD,OAAO,CAAC,GAAGC,IAAU,KAAI;IACvBF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,GAAGE,IAAI,CAAC;IACpBD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,GAAGC,IAAI,CAAC;EACtB,CAAC;AACH","names":["mergeCallbacks","callback1","callback2","args"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/mergeCallbacks.ts"],"sourcesContent":["/**\n * @internal\n * Combine two event callbacks into a single callback function that calls each one in order.\n *\n * Usage example:\n * ```ts\n * state.slot.onChange = mergeCallbacks(state.slot.onChange, ev => {\n * // Handle onChange\n * });\n * ```\n *\n * The primary use is to avoid the need to capture an existing callback (`state.slot.onChange` in the example) to a\n * local variable before replacing with a new listener that calls the existing one. This helps avoid bugs like:\n * * Infinite recursion by calling the re-assigned state.slot.onChange if it's not captured to a local variable.\n * * Missing a call to the original onChange due to an early return or other conditional.\n *\n * If you need a callback that is stable between renders, wrap the result in {@link useEventCallback}.\n *\n * @param callback1 - The first callback to be called, or undefined\n * @param callback2 - The second callback to be called, or undefined\n *\n * @returns A function that that calls the provided functions in order\n */\nexport function mergeCallbacks<Args extends unknown[]>(\n callback1: ((...args: Args) => void) | undefined,\n callback2: ((...args: Args) => void) | undefined,\n) {\n return (...args: Args) => {\n callback1?.(...args);\n callback2?.(...args);\n };\n}\n"]}
1
+ {"version":3,"names":["mergeCallbacks","callback1","callback2","args"],"sources":["../src/packages/react-components/react-utilities/src/utils/mergeCallbacks.ts"],"sourcesContent":["/**\n * @internal\n * Combine two event callbacks into a single callback function that calls each one in order.\n *\n * Usage example:\n * ```ts\n * state.slot.onChange = mergeCallbacks(state.slot.onChange, ev => {\n * // Handle onChange\n * });\n * ```\n *\n * The primary use is to avoid the need to capture an existing callback (`state.slot.onChange` in the example) to a\n * local variable before replacing with a new listener that calls the existing one. This helps avoid bugs like:\n * * Infinite recursion by calling the re-assigned state.slot.onChange if it's not captured to a local variable.\n * * Missing a call to the original onChange due to an early return or other conditional.\n *\n * If you need a callback that is stable between renders, wrap the result in {@link useEventCallback}.\n *\n * @param callback1 - The first callback to be called, or undefined\n * @param callback2 - The second callback to be called, or undefined\n *\n * @returns A function that that calls the provided functions in order\n */\nexport function mergeCallbacks<Args extends unknown[]>(\n callback1: ((...args: Args) => void) | undefined,\n callback2: ((...args: Args) => void) | undefined,\n) {\n return (...args: Args) => {\n callback1?.(...args);\n callback2?.(...args);\n };\n}\n"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAM,SAAUA,cAAcA,CAC5BC,SAAgD,EAChDC,SAAgD;EAEhD,OAAO,CAAC,GAAGC,IAAU,KAAI;IACvBF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,GAAGE,IAAI,CAAC;IACpBD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,GAAGC,IAAI,CAAC;EACtB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA;;;;;;;;;;;;;AAaA;AACA,OAAM,SAAUA,IAAI,CAClBC,GAAS,EACTC,UAAsB;EAEtB;EACA,MAAMC,MAAM,GAAwB,EAAE;EAEtC,KAAK,MAAMC,GAAG,IAAIH,GAAG,EAAE;IACrB,IAAIC,UAAU,CAACG,OAAO,CAACD,GAAG,CAAC,KAAK,CAAC,CAAC,IAAIH,GAAG,CAACK,cAAc,CAACF,GAAG,CAAC,EAAE;MAC7DD,MAAM,CAACC,GAAG,CAAC,GAAGH,GAAG,CAACG,GAAG,CAAC;;;EAI1B,OAAOD,MAAc;AACvB","names":["omit","obj","exclusions","result","key","indexOf","hasOwnProperty"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/omit.ts"],"sourcesContent":["/**\n * Tiny helper to do the minimal amount of work in duplicating an object but omitting some\n * props. This ends up faster than using object ...rest or reduce to filter.\n *\n * This behaves very much like filteredAssign, but does not merge many objects together,\n * uses an exclusion object map, and avoids spreads all for optimal performance.\n *\n * See perf test for background:\n * https://jsperf.com/omit-vs-rest-vs-reduce/1\n *\n * @param obj - The object to clone\n * @param exclusions - The array of keys to exclude\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(\n obj: TObj,\n exclusions: Exclusions,\n): Omit<TObj, Exclusions[number]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const key in obj) {\n if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {\n result[key] = obj[key];\n }\n }\n\n return result as TObj;\n}\n"]}
1
+ {"version":3,"names":["omit","obj","exclusions","result","key","indexOf","hasOwnProperty"],"sources":["../src/packages/react-components/react-utilities/src/utils/omit.ts"],"sourcesContent":["/**\n * Tiny helper to do the minimal amount of work in duplicating an object but omitting some\n * props. This ends up faster than using object ...rest or reduce to filter.\n *\n * This behaves very much like filteredAssign, but does not merge many objects together,\n * uses an exclusion object map, and avoids spreads all for optimal performance.\n *\n * See perf test for background:\n * https://jsperf.com/omit-vs-rest-vs-reduce/1\n *\n * @param obj - The object to clone\n * @param exclusions - The array of keys to exclude\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(\n obj: TObj,\n exclusions: Exclusions,\n): Omit<TObj, Exclusions[number]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const key in obj) {\n if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {\n result[key] = obj[key];\n }\n }\n\n return result as TObj;\n}\n"],"mappings":"AAAA;;;;;;;;;;;;;AAaA;AACA,OAAM,SAAUA,IAAIA,CAClBC,GAAS,EACTC,UAAsB;EAEtB;EACA,MAAMC,MAAM,GAAwB,EAAE;EAEtC,KAAK,MAAMC,GAAG,IAAIH,GAAG,EAAE;IACrB,IAAIC,UAAU,CAACG,OAAO,CAACD,GAAG,CAAC,KAAK,CAAC,CAAC,IAAIH,GAAG,CAACK,cAAc,CAACF,GAAG,CAAC,EAAE;MAC7DD,MAAM,CAACC,GAAG,CAAC,GAAGH,GAAG,CAACG,GAAG,CAAC;;;EAI1B,OAAOD,MAAc;AACvB"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA,MAAMA,WAAW,GAAG,CAAC,GAAGC,KAA4C,KAAI;EACtE,MAAMC,MAAM,GAA2B,EAAE;EAEzC,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;IACxB,MAAMG,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,GAAGA,IAAI,GAAGI,MAAM,CAACH,IAAI,CAACD,IAAI,CAAC;IAE3D,KAAK,MAAMK,GAAG,IAAIJ,IAAI,EAAE;MACtBF,MAAM,CAACM,GAAG,CAAC,GAAG,CAAC;;;EAInB,OAAON,MAAM;AACf,CAAC;AAED;;;;;AAKA,OAAO,MAAMO,iBAAiB,gBAAGT,WAAW,CAAC,CAC3C,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,UAAU,EACV,SAAS,EACT,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,SAAS,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AE;EACtC,MAAME,IAAI,GAAGG,MAAM,CAACH,IAAI,CAACkC,KAAK,CAAC;EAE/B,KAAK,MAAM9B,GAAG,IAAIJ,IAAI,EAAE;IACtB,MAAMqC,YAAY,GACf,CAACnC,OAAO,IAAKiC,gBAA2C,CAAC/B,GAAG,CAAC,IAC7DF,OAAO,IAAKiC,gBAA6B,CAACG,OAAO,CAAClC,GAAG,CAAC,IAAI,CAAE,IAC7DA,GAAG,CAACkC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAC1BlC,GAAG,CAACkC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;IAE5B,IAAID,YAAY,KAAK,CAACD,iBAAiB,IAAI,kBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEE,OAAO,CAAClC,GAAG,CAAC,MAAK,CAAC,CAAC,CAAC,EAAE;MAClF;MACAN,MAAM,CAACM,GAAG,CAAC,GAAG8B,KAAM,CAAC9B,GAAG,CAAQ;;;EAIpC,OAAON,MAAW;AACpB","names":["toObjectMap","items","result","item","keys","Array","isArray","Object","key","baseElementEvents","baseElementProperties","microdataProperties","htmlElementProperties","labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","timeProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","dialogProperties","divProperties","getNativeProps","props","allowedPropNames","excludedPropNames","isNativeProp","indexOf"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/properties.ts"],"sourcesContent":["const toObjectMap = (...items: (string[] | Record<string, number>)[]) => {\n const result: Record<string, number> = {};\n\n for (const item of items) {\n const keys = Array.isArray(item) ? item : Object.keys(item);\n\n for (const key of keys) {\n result[key] = 1;\n }\n }\n\n return result;\n};\n\n/**\n * An array of events that are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementEvents = toObjectMap([\n 'onAuxClick',\n 'onCopy',\n 'onCut',\n 'onPaste',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onFocus',\n 'onFocusCapture',\n 'onBlur',\n 'onBlurCapture',\n 'onChange',\n 'onInput',\n 'onSubmit',\n 'onLoad',\n 'onError',\n 'onKeyDown',\n 'onKeyDownCapture',\n 'onKeyPress',\n 'onKeyUp',\n 'onAbort',\n 'onCanPlay',\n 'onCanPlayThrough',\n 'onDurationChange',\n 'onEmptied',\n 'onEncrypted',\n 'onEnded',\n 'onLoadedData',\n 'onLoadedMetadata',\n 'onLoadStart',\n 'onPause',\n 'onPlay',\n 'onPlaying',\n 'onProgress',\n 'onRateChange',\n 'onSeeked',\n 'onSeeking',\n 'onStalled',\n 'onSuspend',\n 'onTimeUpdate',\n 'onVolumeChange',\n 'onWaiting',\n 'onClick',\n 'onClickCapture',\n 'onContextMenu',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragExit',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onMouseDown',\n 'onMouseDownCapture',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onMouseUpCapture',\n 'onSelect',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onScroll',\n 'onWheel',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onGotPointerCapture',\n 'onLostPointerCapture',\n]);\n\n/**\n * An array of element attributes which are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementProperties = toObjectMap([\n 'accessKey', // global\n 'children', // global\n 'className', // global\n 'contentEditable', // global\n 'dir', // global\n 'draggable', // global\n 'hidden', // global\n 'htmlFor', // global\n 'id', // global\n 'lang', // global\n 'ref', // global\n 'role', // global\n 'style', // global\n 'tabIndex', // global\n 'title', // global\n 'translate', // global\n 'spellCheck', // global\n 'name', // global\n]);\n\n/**\n * An array of microdata attributes that are allowed on every html element type.\n *\n * @public\n */\nexport const microdataProperties = toObjectMap([\n 'itemID', // global\n 'itemProp', // global\n 'itemRef', // global\n 'itemScope', // global\n 'itemType', // global\n]);\n\n/**\n * An array of HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);\n\n/**\n * An array of LABEL tag properties and events.\n *\n * @public\n */\nexport const labelProperties = toObjectMap(htmlElementProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of AUDIO tag properties and events.\n\n * @public\n */\nexport const audioProperties = toObjectMap(htmlElementProperties, [\n 'height', // canvas, embed, iframe, img, input, object, video\n 'loop', // audio, video\n 'muted', // audio, video\n 'preload', // audio, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of VIDEO tag properties and events.\n *\n * @public\n */\nexport const videoProperties = toObjectMap(audioProperties, [\n 'poster', // video\n]);\n\n/**\n * An array of OL tag properties and events.\n *\n * @public\n */\nexport const olProperties = toObjectMap(htmlElementProperties, [\n 'start', // ol\n]);\n\n/**\n * An array of LI tag properties and events.\n *\n * @public\n */\nexport const liProperties = toObjectMap(htmlElementProperties, [\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of A tag properties and events.\n *\n * @public\n */\nexport const anchorProperties = toObjectMap(htmlElementProperties, [\n 'download', // a, area\n 'href', // a, area, base, link\n 'hrefLang', // a, area, link\n 'media', // a, area, link, source, style\n 'rel', // a, area, link\n 'target', // a, area, base, form\n 'type', // a, button, input, link, menu, object, script, source, style\n]);\n\n/**\n * An array of TIME tag properties and events.\n *\n * @public\n */\nexport const timeProperties = toObjectMap(htmlElementProperties, [\n 'dateTime', // time\n]);\n\n/**\n * An array of BUTTON tag properties and events.\n *\n * @public\n */\nexport const buttonProperties = toObjectMap(htmlElementProperties, [\n 'autoFocus', // button, input, select, textarea\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'formAction', // input, button\n 'formEncType', // input, button\n 'formMethod', // input, button\n 'formNoValidate', // input, button\n 'formTarget', // input, button\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param,\n]);\n\n/**\n * An array of INPUT tag properties and events.\n *\n * @public\n */\nexport const inputProperties = toObjectMap(buttonProperties, [\n 'accept', // input\n 'alt', // area, img, input\n 'autoCapitalize', // input, textarea\n 'autoComplete', // form, input\n 'checked', // input\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'height', // canvas, embed, iframe, img, input, object, video\n 'inputMode', // input\n 'list', // input\n 'max', // input, meter\n 'maxLength', // input, textarea\n 'min', // input, meter\n 'multiple', // input, select\n 'pattern', // input\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'step', // input\n 'size', // input\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of TEXTAREA tag properties and events.\n *\n * @public\n */\nexport const textAreaProperties = toObjectMap(buttonProperties, [\n 'autoCapitalize', // input, textarea\n 'cols', // textarea\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'maxLength', // input, textarea\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'rows', // textarea\n 'wrap', // textarea\n]);\n\n/**\n * An array of SELECT tag properties and events.\n *\n * @public\n */\nexport const selectProperties = toObjectMap(buttonProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'multiple', // input, select\n 'required', // input, select, textarea\n]);\n\nexport const optionProperties = toObjectMap(htmlElementProperties, [\n 'selected', // option\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of TABLE tag properties and events.\n *\n * @public\n */\nexport const tableProperties = toObjectMap(htmlElementProperties, [\n 'cellPadding', // table\n 'cellSpacing', // table\n]);\n\n/**\n * An array of TR tag properties and events.\n *\n * @public\n */\nexport const trProperties = htmlElementProperties;\n\n/**\n * An array of TH tag properties and events.\n *\n * @public\n */\nexport const thProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td, th\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\n/**\n * An array of TD tag properties and events.\n *\n * @public\n */\nexport const tdProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td\n 'headers', // td\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\nexport const colGroupProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\nexport const colProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\n/**\n * An array of FIELDSET tag properties and events.\n *\n * @public\n */\nexport const fieldsetProperties = toObjectMap(htmlElementProperties, [\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of FORM tag properties and events.\n *\n * @public\n */\nexport const formProperties = toObjectMap(htmlElementProperties, [\n 'acceptCharset', // form\n 'action', // form\n 'encType', // form\n 'encType', // form\n 'method', // form\n 'noValidate', // form\n 'target', // form\n]);\n\n/**\n * An array of IFRAME tag properties and events.\n *\n * @public\n */\nexport const iframeProperties = toObjectMap(htmlElementProperties, [\n 'allow', // iframe\n 'allowFullScreen', // iframe\n 'allowPaymentRequest', // iframe\n 'allowTransparency', // iframe\n 'csp', // iframe\n 'height', // canvas, embed, iframe, img, input, object, video\n 'importance', // iframe\n 'referrerPolicy', // iframe\n 'sandbox', // iframe\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcDoc', // iframe\n 'width', // canvas, embed, iframe, img, input, object, video,\n]);\n\n/**\n * An array of IMAGE tag properties and events.\n *\n * @public\n */\nexport const imgProperties = toObjectMap(htmlElementProperties, [\n 'alt', // area, img, input\n 'crossOrigin', // img\n 'height', // canvas, embed, iframe, img, input, object, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcSet', // img, source\n 'useMap', // img, object,\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of DIALOG tag properties and events.\n *\n * @public\n */\nexport const dialogProperties = toObjectMap(htmlElementProperties, ['open', 'onCancel', 'onClose']);\n\n/**\n * An array of DIV tag properties and events.\n *\n * @public\n */\nexport const divProperties = htmlElementProperties;\n\n/**\n * Gets native supported props for an html element provided the allowance set. Use one of the property\n * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given\n * props set. Note that all data- and aria- prefixed attributes will be allowed.\n * NOTE: getNativeProps should always be applied first when adding props to a react component. The\n * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.\n * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to\n * the component after an onClick function is added, then the getNativeProps onClick will override it.\n *\n * @public\n * @param props - The unfiltered input props\n * @param allowedPropNames - The array or record of allowed prop names.\n * @param excludedPropNames\n * @returns The filtered props\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeProps<T extends Record<string, any>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n allowedPropNames: string[] | Record<string, number>,\n excludedPropNames?: string[],\n): T {\n // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for\n // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.\n // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then\n // return native props.\n // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797\n\n const isArray = Array.isArray(allowedPropNames);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n const keys = Object.keys(props);\n\n for (const key of keys) {\n const isNativeProp =\n (!isArray && (allowedPropNames as Record<string, number>)[key]) ||\n (isArray && (allowedPropNames as string[]).indexOf(key) >= 0) ||\n key.indexOf('data-') === 0 ||\n key.indexOf('aria-') === 0;\n\n if (isNativeProp && (!excludedPropNames || excludedPropNames?.indexOf(key) === -1)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = props![key] as any;\n }\n }\n\n return result as T;\n}\n"]}
1
+ {"version":3,"names":["toObjectMap","items","result","item","keys","Array","isArray","Object","key","baseElementEvents","baseElementProperties","microdataProperties","htmlElementProperties","labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","timeProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","dialogProperties","divProperties","getNativeProps","props","allowedPropNames","excludedPropNames","isNativeProp","indexOf"],"sources":["../src/packages/react-components/react-utilities/src/utils/properties.ts"],"sourcesContent":["const toObjectMap = (...items: (string[] | Record<string, number>)[]) => {\n const result: Record<string, number> = {};\n\n for (const item of items) {\n const keys = Array.isArray(item) ? item : Object.keys(item);\n\n for (const key of keys) {\n result[key] = 1;\n }\n }\n\n return result;\n};\n\n/**\n * An array of events that are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementEvents = toObjectMap([\n 'onAuxClick',\n 'onCopy',\n 'onCut',\n 'onPaste',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onFocus',\n 'onFocusCapture',\n 'onBlur',\n 'onBlurCapture',\n 'onChange',\n 'onInput',\n 'onSubmit',\n 'onLoad',\n 'onError',\n 'onKeyDown',\n 'onKeyDownCapture',\n 'onKeyPress',\n 'onKeyUp',\n 'onAbort',\n 'onCanPlay',\n 'onCanPlayThrough',\n 'onDurationChange',\n 'onEmptied',\n 'onEncrypted',\n 'onEnded',\n 'onLoadedData',\n 'onLoadedMetadata',\n 'onLoadStart',\n 'onPause',\n 'onPlay',\n 'onPlaying',\n 'onProgress',\n 'onRateChange',\n 'onSeeked',\n 'onSeeking',\n 'onStalled',\n 'onSuspend',\n 'onTimeUpdate',\n 'onVolumeChange',\n 'onWaiting',\n 'onClick',\n 'onClickCapture',\n 'onContextMenu',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragExit',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onMouseDown',\n 'onMouseDownCapture',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onMouseUpCapture',\n 'onSelect',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onScroll',\n 'onWheel',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onGotPointerCapture',\n 'onLostPointerCapture',\n]);\n\n/**\n * An array of element attributes which are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementProperties = toObjectMap([\n 'accessKey', // global\n 'children', // global\n 'className', // global\n 'contentEditable', // global\n 'dir', // global\n 'draggable', // global\n 'hidden', // global\n 'htmlFor', // global\n 'id', // global\n 'lang', // global\n 'ref', // global\n 'role', // global\n 'style', // global\n 'tabIndex', // global\n 'title', // global\n 'translate', // global\n 'spellCheck', // global\n 'name', // global\n]);\n\n/**\n * An array of microdata attributes that are allowed on every html element type.\n *\n * @public\n */\nexport const microdataProperties = toObjectMap([\n 'itemID', // global\n 'itemProp', // global\n 'itemRef', // global\n 'itemScope', // global\n 'itemType', // global\n]);\n\n/**\n * An array of HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);\n\n/**\n * An array of LABEL tag properties and events.\n *\n * @public\n */\nexport const labelProperties = toObjectMap(htmlElementProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of AUDIO tag properties and events.\n\n * @public\n */\nexport const audioProperties = toObjectMap(htmlElementProperties, [\n 'height', // canvas, embed, iframe, img, input, object, video\n 'loop', // audio, video\n 'muted', // audio, video\n 'preload', // audio, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of VIDEO tag properties and events.\n *\n * @public\n */\nexport const videoProperties = toObjectMap(audioProperties, [\n 'poster', // video\n]);\n\n/**\n * An array of OL tag properties and events.\n *\n * @public\n */\nexport const olProperties = toObjectMap(htmlElementProperties, [\n 'start', // ol\n]);\n\n/**\n * An array of LI tag properties and events.\n *\n * @public\n */\nexport const liProperties = toObjectMap(htmlElementProperties, [\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of A tag properties and events.\n *\n * @public\n */\nexport const anchorProperties = toObjectMap(htmlElementProperties, [\n 'download', // a, area\n 'href', // a, area, base, link\n 'hrefLang', // a, area, link\n 'media', // a, area, link, source, style\n 'rel', // a, area, link\n 'target', // a, area, base, form\n 'type', // a, button, input, link, menu, object, script, source, style\n]);\n\n/**\n * An array of TIME tag properties and events.\n *\n * @public\n */\nexport const timeProperties = toObjectMap(htmlElementProperties, [\n 'dateTime', // time\n]);\n\n/**\n * An array of BUTTON tag properties and events.\n *\n * @public\n */\nexport const buttonProperties = toObjectMap(htmlElementProperties, [\n 'autoFocus', // button, input, select, textarea\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'formAction', // input, button\n 'formEncType', // input, button\n 'formMethod', // input, button\n 'formNoValidate', // input, button\n 'formTarget', // input, button\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param,\n]);\n\n/**\n * An array of INPUT tag properties and events.\n *\n * @public\n */\nexport const inputProperties = toObjectMap(buttonProperties, [\n 'accept', // input\n 'alt', // area, img, input\n 'autoCapitalize', // input, textarea\n 'autoComplete', // form, input\n 'checked', // input\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'height', // canvas, embed, iframe, img, input, object, video\n 'inputMode', // input\n 'list', // input\n 'max', // input, meter\n 'maxLength', // input, textarea\n 'min', // input, meter\n 'multiple', // input, select\n 'pattern', // input\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'step', // input\n 'size', // input\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of TEXTAREA tag properties and events.\n *\n * @public\n */\nexport const textAreaProperties = toObjectMap(buttonProperties, [\n 'autoCapitalize', // input, textarea\n 'cols', // textarea\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'maxLength', // input, textarea\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'rows', // textarea\n 'wrap', // textarea\n]);\n\n/**\n * An array of SELECT tag properties and events.\n *\n * @public\n */\nexport const selectProperties = toObjectMap(buttonProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'multiple', // input, select\n 'required', // input, select, textarea\n]);\n\nexport const optionProperties = toObjectMap(htmlElementProperties, [\n 'selected', // option\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of TABLE tag properties and events.\n *\n * @public\n */\nexport const tableProperties = toObjectMap(htmlElementProperties, [\n 'cellPadding', // table\n 'cellSpacing', // table\n]);\n\n/**\n * An array of TR tag properties and events.\n *\n * @public\n */\nexport const trProperties = htmlElementProperties;\n\n/**\n * An array of TH tag properties and events.\n *\n * @public\n */\nexport const thProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td, th\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\n/**\n * An array of TD tag properties and events.\n *\n * @public\n */\nexport const tdProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td\n 'headers', // td\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\nexport const colGroupProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\nexport const colProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\n/**\n * An array of FIELDSET tag properties and events.\n *\n * @public\n */\nexport const fieldsetProperties = toObjectMap(htmlElementProperties, [\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of FORM tag properties and events.\n *\n * @public\n */\nexport const formProperties = toObjectMap(htmlElementProperties, [\n 'acceptCharset', // form\n 'action', // form\n 'encType', // form\n 'encType', // form\n 'method', // form\n 'noValidate', // form\n 'target', // form\n]);\n\n/**\n * An array of IFRAME tag properties and events.\n *\n * @public\n */\nexport const iframeProperties = toObjectMap(htmlElementProperties, [\n 'allow', // iframe\n 'allowFullScreen', // iframe\n 'allowPaymentRequest', // iframe\n 'allowTransparency', // iframe\n 'csp', // iframe\n 'height', // canvas, embed, iframe, img, input, object, video\n 'importance', // iframe\n 'referrerPolicy', // iframe\n 'sandbox', // iframe\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcDoc', // iframe\n 'width', // canvas, embed, iframe, img, input, object, video,\n]);\n\n/**\n * An array of IMAGE tag properties and events.\n *\n * @public\n */\nexport const imgProperties = toObjectMap(htmlElementProperties, [\n 'alt', // area, img, input\n 'crossOrigin', // img\n 'height', // canvas, embed, iframe, img, input, object, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcSet', // img, source\n 'useMap', // img, object,\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of DIALOG tag properties and events.\n *\n * @public\n */\nexport const dialogProperties = toObjectMap(htmlElementProperties, ['open', 'onCancel', 'onClose']);\n\n/**\n * An array of DIV tag properties and events.\n *\n * @public\n */\nexport const divProperties = htmlElementProperties;\n\n/**\n * Gets native supported props for an html element provided the allowance set. Use one of the property\n * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given\n * props set. Note that all data- and aria- prefixed attributes will be allowed.\n * NOTE: getNativeProps should always be applied first when adding props to a react component. The\n * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.\n * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to\n * the component after an onClick function is added, then the getNativeProps onClick will override it.\n *\n * @public\n * @param props - The unfiltered input props\n * @param allowedPropNames - The array or record of allowed prop names.\n * @param excludedPropNames\n * @returns The filtered props\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeProps<T extends Record<string, any>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n allowedPropNames: string[] | Record<string, number>,\n excludedPropNames?: string[],\n): T {\n // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for\n // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.\n // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then\n // return native props.\n // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797\n\n const isArray = Array.isArray(allowedPropNames);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n const keys = Object.keys(props);\n\n for (const key of keys) {\n const isNativeProp =\n (!isArray && (allowedPropNames as Record<string, number>)[key]) ||\n (isArray && (allowedPropNames as string[]).indexOf(key) >= 0) ||\n key.indexOf('data-') === 0 ||\n key.indexOf('aria-') === 0;\n\n if (isNativeProp && (!excludedPropNames || excludedPropNames?.indexOf(key) === -1)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = props![key] as any;\n }\n }\n\n return result as T;\n}\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGA,CAAC,GAAGC,KAA4C,KAAI;EACtE,MAAMC,MAAM,GAA2B,EAAE;EAE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pB"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSlots.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/getSlots.ts"],"names":[],"mappings":";;;;IA+BA;;;;;;;;;;;;;;;;OAgBG;IACH,SAAgB,QAAQ,CACtB,KAAwB;QAKxB,IAAM,KAAK,GAAG,EAAc,CAAC;QAC7B,IAAM,SAAS,GAAG,EAAO,CAAC;QAE1B,IAAM,SAAS,GAAgB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC7D,KAAuB,UAAS,EAAT,uBAAS,EAAT,uBAAS,EAAT,IAAS,EAAE;YAA7B,IAAM,QAAQ,kBAAA;YACX,IAAA,KAAgB,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAvC,IAAI,QAAA,EAAE,KAAK,QAA4B,CAAC;YAC/C,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAiC,CAAC;YACpD,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;SAC7B;QACD,OAAO,EAAE,KAAK,OAAA,EAAE,SAAS,EAAG,SAA2C,EAAE,CAAC;IAC5E,CAAC;IAhBD,4BAgBC;IAED,SAAS,OAAO,CACd,KAAwB,EACxB,QAAW;;QAEX,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;YACjC,OAAO,CAAC,IAAI,EAAE,SAAiB,CAAC,CAAC;SAClC;QACD,IAAM,KAAoC,KAAK,CAAC,QAAQ,CAAE,EAAlD,QAAQ,cAAA,EAAM,MAAM,QAAA,EAAK,IAAI,sBAA/B,kBAAiC,CAAmB,CAAC;QAE3D,IAAM,IAAI,GAAG,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,0CAAG,QAAQ,CAAC,MAAK,SAAS,IAAI,OAAO,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,QAAQ;YACxG,CAAC,CAAC,MAAM,KAAI,MAAA,KAAK,CAAC,UAAU,0CAAG,QAAQ,CAAC,CAAA,IAAI,KAAK;YACjD,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAA4B,CAAC;QAE3D,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YAClC,IAAM,MAAM,GAAG,QAAoC,CAAC;YACpD,OAAO;gBACL,KAAK,CAAC,QAAQ;gBACb;oBACC,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,IAAqC,CAAC;iBAC1C;aACtB,CAAC;SACH;QAED,IAAM,gBAAgB,GAAG,OAAO,IAAI,KAAK,QAAQ,KAAI,MAAA,KAAK,CAAC,QAAQ,CAAC,0CAAE,EAAE,CAAA,CAAC;QACzE,IAAM,SAAS,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAI,CAAC,KAAK,CAAC,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAS,CAAC;QAEhG,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: (slotProps as unknown) as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"]}
1
+ {"version":3,"file":"getSlots.js","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C,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CACJ,CAAC;QAE7B,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YAClC,IAAM,MAAM,GAAG,QAAoC,CAAC;YACpD,OAAO;gBACL,KAAK,CAAC,QAAQ;gBACd;oBACE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,IAAqC,CAAC;iBAC3C;aACrB,CAAC;SACH;QAED,IAAM,gBAAgB,GAAG,OAAO,IAAI,KAAK,QAAQ,KAAI,MAAA,KAAK,CAAC,QAAQ,CAAC,0CAAE,EAAE,CAAA,CAAC;QACzE,IAAM,SAAS,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAI,CAAC,KAAK,CAAC,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAS,CAAC;QAEhG,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (\n state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n {\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, 'children' | 'as'>,\n) => React.ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactChild | React.ReactNode[] | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props extends { children?: unknown }> = Props & {\n children?: Props['children'] | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrisicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React.PropsWithRef<JSX.IntrinsicElements[Type]> &\n (Type extends EmptyIntrisicElements ? { children?: never } : {});\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrisicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrisicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, 'children' | 'as'>,\n) => React.ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactChild | React.ReactNode[] | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props> = Props & {\n children?: (Props extends { children?: unknown } ? Props['children'] : never) | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrinsicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrinsicElementProps<Type extends keyof JSX.IntrinsicElements> = Type extends EmptyIntrinsicElements\n ? PropsWithoutChildren<React.PropsWithRef<JSX.IntrinsicElements[Type]>>\n : React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never,\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrinsicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrinsicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutChildren<P> = 'children' extends keyof P ? (P extends unknown ? Omit<P, 'children'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useMergedRefs.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useMergedRefs.ts"],"names":[],"mappings":";;;;IAQA;;;;;OAKG;IACH,SAAgB,aAAa;QAAI,cAAqC;aAArC,UAAqC,EAArC,qBAAqC,EAArC,IAAqC;YAArC,yBAAqC;;QACpE,IAAM,cAAc,GAA0B,KAAK,CAAC,WAAW,CAC7D,UAAC,KAAQ;YACP,qDAAqD;YACnD,cAAwD,CAAC,OAAO,GAAG,KAAK,CAAC;YAE3E,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;gBAAnB,IAAM,GAAG,aAAA;gBACZ,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;oBAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;iBACZ;qBAAM,IAAI,GAAG,EAAE;oBACd,qDAAqD;oBACnD,GAA6C,CAAC,OAAO,GAAG,KAAK,CAAC;iBACjE;aACF;QACH,CAAC,4BAEG,IAAI,EAC2B,CAAC;QAEtC,OAAO,cAAc,CAAC;IACxB,CAAC;IApBD,sCAoBC","sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = (React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n ((mergedCallback as unknown) as React.MutableRefObject<T>).current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n ((ref as unknown) as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown) as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"]}
1
+ {"version":3,"file":"useMergedRefs.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useMergedRefs.ts"],"names":[],"mappings":";;;;IAQA;;;;;OAKG;IACH,SAAgB,aAAa;QAAI,cAAqC;aAArC,UAAqC,EAArC,qBAAqC,EAArC,IAAqC;YAArC,yBAAqC;;QACpE,IAAM,cAAc,GAAyB,KAAK,CAAC,WAAW,CAC5D,UAAC,KAAQ;YACP,qDAAqD;YACpD,cAAuD,CAAC,OAAO,GAAG,KAAK,CAAC;YAEzE,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;gBAAnB,IAAM,GAAG,aAAA;gBACZ,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;oBAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;iBACZ;qBAAM,IAAI,GAAG,EAAE;oBACd,qDAAqD;oBACpD,GAA4C,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC/D;aACF;QACH,CAAC,4BAEG,IAAI,EAC0B,CAAC;QAErC,OAAO,cAAc,CAAC;IACxB,CAAC;IApBD,sCAoBC","sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n (mergedCallback as unknown as React.MutableRefObject<T>).current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n (ref as unknown as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"]}
package/lib-amd/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  define(["require", "exports", "./compose/index", "./hooks/index", "./ssr/index", "./utils/index", "./trigger/index", "./events/index"], function (require, exports, index_1, index_2, index_3, index_4, index_5, index_6) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getEventClientCoords = exports.isMouseEvent = exports.isTouchEvent = exports.isFluentTrigger = exports.getTriggerChild = exports.applyTriggerPropsToChildren = exports.isInteractiveHTMLElement = exports.isHTMLElement = exports.mergeCallbacks = exports.getRTLSafeKey = exports.getPartitionedNativeProps = exports.getNativeElementProps = exports.clamp = exports.SSRProvider = exports.useIsSSR = exports.canUseDOM = exports.useTimeout = exports.useScrollbarWidth = exports.usePrevious = exports.useOnScrollOutside = exports.useOnClickOutside = exports.useMergedRefs = exports.useIsomorphicLayoutEffect = exports.useId = exports.useForceUpdate = exports.useFirstMount = exports.useEventCallback = exports.useControllableState = exports.resetIdsForTests = exports.IdPrefixProvider = exports.isResolvedShorthand = exports.resolveShorthand = exports.getSlots = void 0;
4
+ exports.getEventClientCoords = exports.isMouseEvent = exports.isTouchEvent = exports.isFluentTrigger = exports.getTriggerChild = exports.applyTriggerPropsToChildren = exports.omit = exports.isInteractiveHTMLElement = exports.isHTMLElement = exports.mergeCallbacks = exports.getRTLSafeKey = exports.getPartitionedNativeProps = exports.getNativeElementProps = exports.clamp = exports.SSRProvider = exports.useIsSSR = exports.canUseDOM = exports.useTimeout = exports.useScrollbarWidth = exports.usePrevious = exports.useOnScrollOutside = exports.useOnClickOutside = exports.useMergedRefs = exports.useIsomorphicLayoutEffect = exports.useId = exports.useForceUpdate = exports.useFirstMount = exports.useEventCallback = exports.useControllableState = exports.resetIdsForTests = exports.IdPrefixProvider = exports.isResolvedShorthand = exports.resolveShorthand = exports.getSlots = void 0;
5
5
  Object.defineProperty(exports, "getSlots", { enumerable: true, get: function () { return index_1.getSlots; } });
6
6
  Object.defineProperty(exports, "resolveShorthand", { enumerable: true, get: function () { return index_1.resolveShorthand; } });
7
7
  Object.defineProperty(exports, "isResolvedShorthand", { enumerable: true, get: function () { return index_1.isResolvedShorthand; } });
@@ -29,6 +29,7 @@ define(["require", "exports", "./compose/index", "./hooks/index", "./ssr/index",
29
29
  Object.defineProperty(exports, "mergeCallbacks", { enumerable: true, get: function () { return index_4.mergeCallbacks; } });
30
30
  Object.defineProperty(exports, "isHTMLElement", { enumerable: true, get: function () { return index_4.isHTMLElement; } });
31
31
  Object.defineProperty(exports, "isInteractiveHTMLElement", { enumerable: true, get: function () { return index_4.isInteractiveHTMLElement; } });
32
+ Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return index_4.omit; } });
32
33
  Object.defineProperty(exports, "applyTriggerPropsToChildren", { enumerable: true, get: function () { return index_5.applyTriggerPropsToChildren; } });
33
34
  Object.defineProperty(exports, "getTriggerChild", { enumerable: true, get: function () { return index_5.getTriggerChild; } });
34
35
  Object.defineProperty(exports, "isFluentTrigger", { enumerable: true, get: function () { return index_5.isFluentTrigger; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-utilities/src/index.ts"],"names":[],"mappings":";;;;IAAS,iGAAA,QAAQ,OAAA;IAAE,yGAAA,gBAAgB,OAAA;IAAE,4GAAA,mBAAmB,OAAA;IAiBtD,yGAAA,gBAAgB,OAAA;IAChB,yGAAA,gBAAgB,OAAA;IAChB,6GAAA,oBAAoB,OAAA;IACpB,yGAAA,gBAAgB,OAAA;IAChB,sGAAA,aAAa,OAAA;IACb,uGAAA,cAAc,OAAA;IACd,8FAAA,KAAK,OAAA;IACL,kHAAA,yBAAyB,OAAA;IACzB,sGAAA,aAAa,OAAA;IACb,0GAAA,iBAAiB,OAAA;IACjB,2GAAA,kBAAkB,OAAA;IAClB,oGAAA,WAAW,OAAA;IACX,0GAAA,iBAAiB,OAAA;IACjB,mGAAA,UAAU,OAAA;IAIH,kGAAA,SAAS,OAAA;IAAE,iGAAA,QAAQ,OAAA;IAAE,oGAAA,WAAW,OAAA;IAGvC,8FAAA,KAAK,OAAA;IACL,8GAAA,qBAAqB,OAAA;IACrB,kHAAA,yBAAyB,OAAA;IACzB,sGAAA,aAAa,OAAA;IACb,uGAAA,cAAc,OAAA;IACd,sGAAA,aAAa,OAAA;IACb,iHAAA,wBAAwB,OAAA;IAGjB,oHAAA,2BAA2B,OAAA;IAAE,wGAAA,eAAe,OAAA;IAAE,wGAAA,eAAe,OAAA;IAQ7D,qGAAA,YAAY,OAAA;IAAE,qGAAA,YAAY,OAAA;IAAE,6GAAA,oBAAoB,OAAA","sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n} from './utils/index';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-utilities/src/index.ts"],"names":[],"mappings":";;;;IAAS,iGAAA,QAAQ,OAAA;IAAE,yGAAA,gBAAgB,OAAA;IAAE,4GAAA,mBAAmB,OAAA;IAiBtD,yGAAA,gBAAgB,OAAA;IAChB,yGAAA,gBAAgB,OAAA;IAChB,6GAAA,oBAAoB,OAAA;IACpB,yGAAA,gBAAgB,OAAA;IAChB,sGAAA,aAAa,OAAA;IACb,uGAAA,cAAc,OAAA;IACd,8FAAA,KAAK,OAAA;IACL,kHAAA,yBAAyB,OAAA;IACzB,sGAAA,aAAa,OAAA;IACb,0GAAA,iBAAiB,OAAA;IACjB,2GAAA,kBAAkB,OAAA;IAClB,oGAAA,WAAW,OAAA;IACX,0GAAA,iBAAiB,OAAA;IACjB,mGAAA,UAAU,OAAA;IAIH,kGAAA,SAAS,OAAA;IAAE,iGAAA,QAAQ,OAAA;IAAE,oGAAA,WAAW,OAAA;IAGvC,8FAAA,KAAK,OAAA;IACL,8GAAA,qBAAqB,OAAA;IACrB,kHAAA,yBAAyB,OAAA;IACzB,sGAAA,aAAa,OAAA;IACb,uGAAA,cAAc,OAAA;IACd,sGAAA,aAAa,OAAA;IACb,iHAAA,wBAAwB,OAAA;IACxB,6FAAA,IAAI,OAAA;IAGG,oHAAA,2BAA2B,OAAA;IAAE,wGAAA,eAAe,OAAA;IAAE,wGAAA,eAAe,OAAA;IAQ7D,qGAAA,YAAY,OAAA;IAAE,qGAAA,YAAY,OAAA;IAAE,6GAAA,oBAAoB,OAAA","sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getNativeElementProps.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/getNativeElementProps.ts"],"names":[],"mappings":";;;;IA6BA,IAAM,gBAAgB,GAA2C;QAC/D,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,CAAC,EAAE,6BAAgB;QACnB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,QAAQ,EAAE,+BAAkB;QAC5B,MAAM,EAAE,6BAAgB;QACxB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,QAAQ,EAAE,+BAAkB;QAC5B,GAAG,EAAE,0BAAa;QAClB,QAAQ,EAAE,+BAAkB;QAC5B,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;QACxB,GAAG,EAAE,0BAAa;QAClB,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;KACzB,CAAC;IAEF;;;;;;OAMG;IACH,8DAA8D;IAC9D,SAAgB,qBAAqB,CACnC,OAAe,EACf,KAAS,EACT,iBAA4B;QAE5B,IAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,kCAAqB,CAAC;QACzF,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC;QAExB,OAAO,2BAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACpE,CAAC;IATD,sDASC;IAED;;;;;;;OAOG;IACI,IAAM,yBAAyB,GAAG,UAGvC,EAaD;YAZC,kBAAkB,wBAAA,EAClB,KAAK,WAAA,EACL,iBAAiB,uBAAA;QAWjB,OAAO;YACL,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;YACxD,OAAO,EAAE,qBAAqB,CAAgC,kBAAkB,EAAE,KAAK,kDAClF,CAAC,iBAAiB,IAAI,EAAE,CAAC;gBAC5B,OAAO;gBACP,WAAW;eACX;SACH,CAAC;IACJ,CAAC,CAAC;IAzBW,QAAA,yBAAyB,6BAyBpC","sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n fieldsetProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n timeProperties,\n dialogProperties,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n fieldset: fieldsetProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n time: timeProperties,\n dialog: dialogProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n allowedPropNames.as = 1;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n\n/**\n * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.\n *\n * This function is only for use with components that have a primary slot other than `root`.\n * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.\n *\n * @returns An object containing the native props for the `root` and primary slots.\n */\nexport const getPartitionedNativeProps = <\n Props extends Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>,\n ExcludedPropKeys extends Extract<keyof Props, string> = never\n>({\n primarySlotTagName,\n props,\n excludedPropNames,\n}: {\n /** The primary slot's element type (e.g. 'div') */\n primarySlotTagName: keyof JSX.IntrinsicElements;\n\n /** The component's props object */\n props: Props;\n\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[];\n}) => {\n return {\n root: { style: props.style, className: props.className },\n primary: getNativeElementProps<Omit<Props, ExcludedPropKeys>>(primarySlotTagName, props, [\n ...(excludedPropNames || []),\n 'style',\n 'className',\n ]),\n };\n};\n"]}
1
+ {"version":3,"file":"getNativeElementProps.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/getNativeElementProps.ts"],"names":[],"mappings":";;;;IA6BA,IAAM,gBAAgB,GAA2C;QAC/D,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,CAAC,EAAE,6BAAgB;QACnB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,QAAQ,EAAE,+BAAkB;QAC5B,MAAM,EAAE,6BAAgB;QACxB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,QAAQ,EAAE,+BAAkB;QAC5B,GAAG,EAAE,0BAAa;QAClB,QAAQ,EAAE,+BAAkB;QAC5B,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;QACxB,GAAG,EAAE,0BAAa;QAClB,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;KACzB,CAAC;IAEF;;;;;;OAMG;IACH,8DAA8D;IAC9D,SAAgB,qBAAqB,CACnC,OAAe,EACf,KAAS,EACT,iBAA4B;QAE5B,IAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,kCAAqB,CAAC;QACzF,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC;QAExB,OAAO,2BAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACpE,CAAC;IATD,sDASC;IAED;;;;;;;OAOG;IACI,IAAM,yBAAyB,GAAG,UAGvC,EAaD;YAZC,kBAAkB,wBAAA,EAClB,KAAK,WAAA,EACL,iBAAiB,uBAAA;QAWjB,OAAO;YACL,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;YACxD,OAAO,EAAE,qBAAqB,CAAgC,kBAAkB,EAAE,KAAK,kDAClF,CAAC,iBAAiB,IAAI,EAAE,CAAC;gBAC5B,OAAO;gBACP,WAAW;eACX;SACH,CAAC;IACJ,CAAC,CAAC;IAzBW,QAAA,yBAAyB,6BAyBpC","sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n fieldsetProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n timeProperties,\n dialogProperties,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n fieldset: fieldsetProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n time: timeProperties,\n dialog: dialogProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n allowedPropNames.as = 1;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n\n/**\n * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.\n *\n * This function is only for use with components that have a primary slot other than `root`.\n * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.\n *\n * @returns An object containing the native props for the `root` and primary slots.\n */\nexport const getPartitionedNativeProps = <\n Props extends Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>({\n primarySlotTagName,\n props,\n excludedPropNames,\n}: {\n /** The primary slot's element type (e.g. 'div') */\n primarySlotTagName: keyof JSX.IntrinsicElements;\n\n /** The component's props object */\n props: Props;\n\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[];\n}) => {\n return {\n root: { style: props.style, className: props.className },\n primary: getNativeElementProps<Omit<Props, ExcludedPropKeys>>(primarySlotTagName, props, [\n ...(excludedPropNames || []),\n 'style',\n 'className',\n ]),\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AAEA;AA6BA;;;;;;;;;;;;;;;;;AAiBA,SAAgBA,QAAQ,CACtBC,KAAwB;EAKxB,MAAMC,KAAK,GAAG,EAAc;EAC5B,MAAMC,SAAS,GAAG,EAAO;EAEzB,MAAMC,SAAS,GAAgBC,MAAM,CAACC,IAAI,CAACL,KAAK,CAACM,UAAU,CAAC;EAC5D,KAAK,MAAMC,QAAQ,IAAIJ,SAAS,EAAE;IAChC,MAAM,CAACK,IAAI,EAAEC,KAAK,CAAC,GAAGC,OAAO,CAACV,KAAK,EAAEO,QAAQ,CAAC;IAC9CN,KAAK,CAACM,QAAQ,CAAC,GAAGC,IAAiC;IACnDN,SAAS,CAACK,QAAQ,CAAC,GAAGE,KAAK;;EAE7B,OAAO;IAAER,KAAK;IAAEC,SAAS,EAAGA;EAA2C,CAAE;AAC3E;AAhBAS;AAkBA,SAASD,OAAO,CACdV,KAAwB,EACxBO,QAAW;;EAEX,IAAIP,KAAK,CAACO,QAAQ,CAAC,KAAKK,SAAS,EAAE;IACjC,OAAO,CAAC,IAAI,EAAEA,SAAiB,CAAC;;EAElC,MAAM;IAAEC,QAAQ;IAAEC,EAAE,EAAEC,MAAM;IAAE,GAAGC;EAAI,CAAE,GAAGhB,KAAK,CAACO,QAAQ,CAAE;EAE1D,MAAMC,IAAI,GAAI,YAAK,CAACF,UAAU,0CAAGC,QAAQ,CAAC,MAAKK,SAAS,IAAI,OAAOZ,KAAK,CAACM,UAAU,CAACC,QAAQ,CAAC,KAAK,QAAQ,GACtGQ,MAAM,KAAI,WAAK,CAACT,UAAU,0CAAGC,QAAQ,CAAC,KAAI,KAAK,GAC/CP,KAAK,CAACM,UAAU,CAACC,QAAQ,CAA6B;EAE1D,IAAI,OAAOM,QAAQ,KAAK,UAAU,EAAE;IAClC,MAAMI,MAAM,GAAGJ,QAAoC;IACnD,OAAO,CACLK,KAAK,CAACC,QAAQ,EACb;MACCN,QAAQ,EAAEI,MAAM,CAACT,IAAI,EAAEQ,IAAqC;KACzC,CACtB;;EAGH,MAAMI,gBAAgB,GAAG,OAAOZ,IAAI,KAAK,QAAQ,KAAI,WAAK,CAACD,QAAQ,CAAC,0CAAEO,EAAE;EACxE,MAAMZ,SAAS,GAAIkB,gBAAgB,GAAGC,WAAI,CAACrB,KAAK,CAACO,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,GAAGP,KAAK,CAACO,QAAQ,CAAU;EAE/F,OAAO,CAACC,IAAI,EAAEN,SAAS,CAAC;AAC1B","names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","exports","undefined","children","as","asProp","rest","render","React","Fragment","shouldOmitAsProp","omit_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/getSlots.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: (slotProps as unknown) as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"]}
1
+ {"version":3,"names":["React","require","omit_1","getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","exports","undefined","children","as","asProp","rest","_a","_b","render","Fragment","shouldOmitAsProp","_c","omit"],"sources":["../src/packages/react-components/react-utilities/src/compose/getSlots.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (\n state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n {\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"],"mappings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Q,CACH;EAE5B,IAAI,OAAOM,QAAQ,KAAK,UAAU,EAAE;IAClC,MAAMM,MAAM,GAAGN,QAAoC;IACnD,OAAO,CACLjB,KAAK,CAACwB,QAAQ,EACd;MACEP,QAAQ,EAAEM,MAAM,CAACX,IAAI,EAAEQ,IAAqC;KAC1C,CACrB;;EAGH,MAAMK,gBAAgB,GAAG,OAAOb,IAAI,KAAK,QAAQ,KAAI,CAAAc,EAAA,GAAAtB,KAAK,CAACO,QAAQ,CAAC,cAAAe,EAAA,uBAAAA,EAAA,CAAER,EAAE;EACxE,MAAMZ,SAAS,GAAImB,gBAAgB,GAAGvB,MAAA,CAAAyB,IAAI,CAACvB,KAAK,CAACO,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,GAAGP,KAAK,CAACO,QAAQ,CAAU;EAE/F,OAAO,CAACC,IAAI,EAAEN,SAAS,CAAC;AAC1B"}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/index.ts"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n"]}
1
+ {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-utilities/src/compose/index.ts"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,gBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,wBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,aAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,2BAAAC,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgBA,mBAAmB,CACjCC,SAAqB;EAErB,OAAOA,SAAS,KAAK,IAAI,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,IAAI,CAACG,sBAAc,CAACH,SAAS,CAAC;AACvH;AAJAI","names":["isResolvedShorthand","shorthand","Array","isArray","react_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/isResolvedShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ExtractSlotProps, Slot, UnknownSlotProps } from './types';\n\n/**\n * Guard method that validates if a shorthand is a slot\n * can be used to extends properties provided by a slot\n *\n * @example\n * ```\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(event => {\n * if (isResolvedShorthand(backdrop)) {\n * backdrop.onClick?.(event)\n * }\n * // do something after passing click down the line\n * }),\n * },\n * })\n * ```\n * @example\n * ```\n * const handleBackDropClick = (event) => {\n * // do your thing\n * }\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(\n * mergeCallbacks(isResolvedShorthand(backdrop) ? backdrop.onClick : undefined, handleBackdropClick)\n * )\n * })\n * ```\n */\nexport function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(\n shorthand?: Shorthand,\n): shorthand is ExtractSlotProps<Shorthand> {\n return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !isValidElement(shorthand);\n}\n"]}
1
+ {"version":3,"names":["react_1","require","isResolvedShorthand","shorthand","Array","isArray","isValidElement","exports"],"sources":["../src/packages/react-components/react-utilities/src/compose/isResolvedShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ExtractSlotProps, Slot, UnknownSlotProps } from './types';\n\n/**\n * Guard method that validates if a shorthand is a slot\n * can be used to extends properties provided by a slot\n *\n * @example\n * ```\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(event => {\n * if (isResolvedShorthand(backdrop)) {\n * backdrop.onClick?.(event)\n * }\n * // do something after passing click down the line\n * }),\n * },\n * })\n * ```\n * @example\n * ```\n * const handleBackDropClick = (event) => {\n * // do your thing\n * }\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(\n * mergeCallbacks(isResolvedShorthand(backdrop) ? backdrop.onClick : undefined, handleBackdropClick)\n * )\n * })\n * ```\n */\nexport function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(\n shorthand?: Shorthand,\n): shorthand is ExtractSlotProps<Shorthand> {\n return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !isValidElement(shorthand);\n}\n"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgBC,mBAAmBA,CACjCC,SAAqB;EAErB,OAAOA,SAAS,KAAK,IAAI,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,IAAI,CAACH,OAAA,CAAAM,cAAc,CAACH,SAAS,CAAC;AACvH;AAJAI,OAAA,CAAAL,mBAAA,GAAAA,mBAAA"}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AAkBA;;;;;;AAMO,MAAMA,gBAAgB,GAA6B,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,IAAIQ,sBAAc,CAACR,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACI,QAAQ,GAAGT,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAG;MAAE,GAAGL;IAAK,CAAE;;EAGlC,OAAOG,YAAY,GAAG;IAAE,GAAGA,YAAY;IAAE,GAAGE;EAAiB,CAAE,GAAGA,iBAAiB;AACrF,CAAC;AAfYK,wBAAgB","names":["resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","react_1","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = { ...value };\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"]}
1
+ {"version":3,"names":["react_1","require","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","isValidElement","children","exports"],"sources":["../src/packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = { ...value };\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AAkBA;;;;;;AAMO,MAAMC,gBAAgB,GAA6BA,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,IAAIH,OAAA,CAAAW,cAAc,CAACR,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACI,QAAQ,GAAGT,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAG;MAAE,GAAGL;IAAK,CAAE;;EAGlC,OAAOG,YAAY,GAAG;IAAE,GAAGA,YAAY;IAAE,GAAGE;EAAiB,CAAE,GAAGA,iBAAiB;AACrF,CAAC;AAfYK,OAAA,CAAAX,gBAAgB,GAAAA,gBAAA"}
@@ -1 +1 @@
1
- {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["../src/packages/react-components/react-utilities/src/compose/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, 'children' | 'as'>,\n) => React.ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactChild | React.ReactNode[] | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props> = Props & {\n children?: (Props extends { children?: unknown } ? Props['children'] : never) | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrinsicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrinsicElementProps<Type extends keyof JSX.IntrinsicElements> = Type extends EmptyIntrinsicElements\n ? PropsWithoutChildren<React.PropsWithRef<JSX.IntrinsicElements[Type]>>\n : React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never,\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrinsicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrinsicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutChildren<P> = 'children' extends keyof P ? (P extends unknown ? Omit<P, 'children'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/events/index.ts"],"sourcesContent":["export * from './mouseTouchHelpers';\n"]}
1
+ {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-utilities/src/events/index.ts"],"sourcesContent":["export * from './mouseTouchHelpers';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAQA;;;AAGA,SAAgBA,YAAY,CAACC,KAAwB;EACnD,OAAOA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACvC;AAFAC;AAIA;;;AAGA,SAAgBC,YAAY,CAACJ,KAAwB;EACnD,OAAOA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,CAAC,CAACG,OAAO,CAACL,KAAK,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxG;AAFAE;AAIA;;;;AAIA,SAAgBG,oBAAoB,CAACN,KAAwB;EAC3D,IAAII,YAAY,CAACJ,KAAK,CAAC,EAAE;IACvB,OAAO;MAAEO,OAAO,EAAEP,KAAK,CAACO,OAAO;MAAEC,OAAO,EAAER,KAAK,CAACQ;IAAO,CAAE;GAC1D,MAAM,IAAIT,YAAY,CAACC,KAAK,CAAC,EAAE;IAC9B,OAAO;MAAEO,OAAO,EAAEP,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC,CAACF,OAAO;MAAEC,OAAO,EAAER,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC,CAACD;IAAO,CAAE;GAChF,MAAM;IACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,wEAAwE,CAAC;;IAE3F,OAAO;MAAEN,OAAO,EAAE,CAAC;MAAEC,OAAO,EAAE;IAAC,CAAE;;AAErC;AAXAL","names":["isTouchEvent","event","type","startsWith","exports","isMouseEvent","indexOf","getEventClientCoords","clientX","clientY","touches","process","env","NODE_ENV","Error"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/events/mouseTouchHelpers.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;\n\nexport type ReactTouchOrMouseEvent = React.MouseEvent | React.TouchEvent;\n\nexport type TouchOrMouseEvent = NativeTouchOrMouseEvent | ReactTouchOrMouseEvent;\n\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React.TouchEvent {\n return event.type.startsWith('touch');\n}\n\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isMouseEvent(event: TouchOrMouseEvent): event is MouseEvent | React.MouseEvent {\n return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;\n}\n\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */\nexport function getEventClientCoords(event: TouchOrMouseEvent): { clientX: number; clientY: number } {\n if (isMouseEvent(event)) {\n return { clientX: event.clientX, clientY: event.clientY };\n } else if (isTouchEvent(event)) {\n return { clientX: event.touches[0].clientX, clientY: event.touches[0].clientY };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return { clientX: 0, clientY: 0 };\n }\n}\n"]}
1
+ {"version":3,"names":["isTouchEvent","event","type","startsWith","exports","isMouseEvent","indexOf","getEventClientCoords","clientX","clientY","touches","process","env","NODE_ENV","Error"],"sources":["../src/packages/react-components/react-utilities/src/events/mouseTouchHelpers.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;\n\nexport type ReactTouchOrMouseEvent = React.MouseEvent | React.TouchEvent;\n\nexport type TouchOrMouseEvent = NativeTouchOrMouseEvent | ReactTouchOrMouseEvent;\n\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React.TouchEvent {\n return event.type.startsWith('touch');\n}\n\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isMouseEvent(event: TouchOrMouseEvent): event is MouseEvent | React.MouseEvent {\n return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;\n}\n\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */\nexport function getEventClientCoords(event: TouchOrMouseEvent): { clientX: number; clientY: number } {\n if (isMouseEvent(event)) {\n return { clientX: event.clientX, clientY: event.clientY };\n } else if (isTouchEvent(event)) {\n return { clientX: event.touches[0].clientX, clientY: event.touches[0].clientY };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return { clientX: 0, clientY: 0 };\n }\n}\n"],"mappings":";;;;;;AAQA;;;AAGA,SAAgBA,YAAYA,CAACC,KAAwB;EACnD,OAAOA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACvC;AAFAC,OAAA,CAAAJ,YAAA,GAAAA,YAAA;AAIA;;;AAGA,SAAgBK,YAAYA,CAACJ,KAAwB;EACnD,OAAOA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,CAAC,CAACG,OAAO,CAACL,KAAK,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxG;AAFAE,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAIA;;;;AAIA,SAAgBE,oBAAoBA,CAACN,KAAwB;EAC3D,IAAII,YAAY,CAACJ,KAAK,CAAC,EAAE;IACvB,OAAO;MAAEO,OAAO,EAAEP,KAAK,CAACO,OAAO;MAAEC,OAAO,EAAER,KAAK,CAACQ;IAAO,CAAE;GAC1D,MAAM,IAAIT,YAAY,CAACC,KAAK,CAAC,EAAE;IAC9B,OAAO;MAAEO,OAAO,EAAEP,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC,CAACF,OAAO;MAAEC,OAAO,EAAER,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC,CAACD;IAAO,CAAE;GAChF,MAAM;IACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,wEAAwE,CAAC;;IAE3F,OAAO;MAAEN,OAAO,EAAE,CAAC;MAAEC,OAAO,EAAE;IAAC,CAAE;;AAErC;AAXAL,OAAA,CAAAG,oBAAA,GAAAA,oBAAA"}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/hooks/index.ts"],"sourcesContent":["export * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"]}
1
+ {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-utilities/src/hooks/index.ts"],"sourcesContent":["export * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,4BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,wBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,qBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,aAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,iCAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,qBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,0BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA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,CAAC;AAC1B,CAAC;AA7BYE,4BAAoB;AA+BjC;;;;;AAKA,MAAMd,eAAe,GAAIe,eAAwB,IAAI;EACnD,MAAM,CAAChB,YAAY,CAAC,GAAGO,KAAK,CAACC,QAAQ,CAAU,MAAMQ,eAAe,KAAKC,SAAS,CAAC;EAEnF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACA;IACAb,KAAK,CAACI,SAAS,CAAC,MAAK;MACnB,IAAIX,YAAY,MAAMgB,eAAe,KAAKC,SAAS,CAAC,EAAE;QACpD,MAAMI,KAAK,GAAG,IAAIC,KAAK,EAAE;QAEzB,MAAMC,cAAc,GAAGvB,YAAY,GAC/B,uCAAuC,GACvC,wCAAwC;QAE5C,MAAMwB,gBAAgB,GAAGxB,YAAY,GAAG,yBAAyB,GAAG,wBAAwB;QAE5F;QACAyB,OAAO,CAACJ,KAAK,CACX;QACE;QACA,0BAA0B,GAAGE,cAAc,GAAG,sCAAsC,EACpF,gBAAgB,GAAGC,gBAAgB,GAAG,kCAAkC,EACxE,oGAAoG,EACpG,2DAA2D,EAC3DH,KAAK,CAACK,KAAK,CACZ,CAACC,IAAI,CAAC,GAAG,CAAC,CACZ;;IAEL,CAAC,EAAE,CAAC3B,YAAY,EAAEgB,eAAe,CAAC,CAAC;;EAGrC,OAAOhB,YAAY;AACrB,CAAC","names":["isFactoryDispatch","newState","useControllableState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","React","useState","stateRef","useRef","useEffect","current","setState","useCallback","exports","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/hooks/useControllableState.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport type UseControllableStateOptions<State> = {\n /**\n * User-provided default state or initializer, for uncontrolled usage.\n */\n defaultState?: State | (() => State);\n /**\n * User-provided controlled state. `undefined` means internal state will be used.\n */\n state: State | undefined;\n /**\n * Used as the initial state if `state` and `defaultState` are both `undefined`.\n * If `undefined` is the correct initial state, pass that here.\n */\n initialState: State;\n};\n\nfunction isFactoryDispatch<State>(newState: React.SetStateAction<State>): newState is (prevState: State) => State {\n return typeof newState === 'function';\n}\n\n/**\n * @internal\n *\n * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,\n * such as a checked state or text input string.\n *\n * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a\n * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.\n *\n * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array\n * of the current value and an updater (dispatch) function. The updater function is referentially\n * stable (won't change during the component's lifecycle). It can take either a new value, or a\n * function which is passed the previous value and returns the new value. Unlike `setState`, calls\n * to the updater function will only be respected if the component is uncontrolled.\n * @see https://reactjs.org/docs/uncontrolled-components.html\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n const isControlled = useIsControlled(options.state);\n const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;\n const [internalState, setInternalState] = React.useState<State>(initialState);\n\n const state = isControlled ? (options.state as State) : internalState;\n\n const stateRef = React.useRef(state);\n React.useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n // To match the behavior of the setter returned by React.useState, this callback's identity\n // should never change. This means it MUST NOT directly reference variables that can change.\n const setState = React.useCallback((newState: React.SetStateAction<State>) => {\n // React dispatch can use a factory\n // https://reactjs.org/docs/hooks-reference.html#functional-updates\n if (isFactoryDispatch(newState)) {\n stateRef.current = newState(stateRef.current);\n } else {\n stateRef.current = newState;\n }\n\n setInternalState(stateRef.current);\n }, []);\n\n return [state, setState];\n};\n\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */\nconst useIsControlled = (controlledValue: unknown) => {\n const [isControlled] = React.useState<boolean>(() => controlledValue !== undefined);\n\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n\n const controlWarning = isControlled\n ? 'a controlled value to be uncontrolled'\n : 'an uncontrolled value to be controlled';\n\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n\n // eslint-disable-next-line no-console\n console.error(\n [\n // Default react error\n 'A component is changing ' + controlWarning + '. This is likely caused by the value',\n 'changing from ' + undefinedWarning + ' value, which should not happen.',\n 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.',\n 'More info: https://reactjs.org/link/controlled-components',\n error.stack,\n ].join(' '),\n );\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"]}
1
+ {"version":3,"names":["React","require","isFactoryDispatch","newState","useControllableState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","useState","stateRef","useRef","useEffect","current","setState","useCallback","exports","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"sources":["../src/packages/react-components/react-utilities/src/hooks/useControllableState.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport type UseControllableStateOptions<State> = {\n /**\n * User-provided default state or initializer, for uncontrolled usage.\n */\n defaultState?: State | (() => State);\n /**\n * User-provided controlled state. `undefined` means internal state will be used.\n */\n state: State | undefined;\n /**\n * Used as the initial state if `state` and `defaultState` are both `undefined`.\n * If `undefined` is the correct initial state, pass that here.\n */\n initialState: State;\n};\n\nfunction isFactoryDispatch<State>(newState: React.SetStateAction<State>): newState is (prevState: State) => State {\n return typeof newState === 'function';\n}\n\n/**\n * @internal\n *\n * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,\n * such as a checked state or text input string.\n *\n * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a\n * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.\n *\n * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array\n * of the current value and an updater (dispatch) function. The updater function is referentially\n * stable (won't change during the component's lifecycle). It can take either a new value, or a\n * function which is passed the previous value and returns the new value. Unlike `setState`, calls\n * to the updater function will only be respected if the component is uncontrolled.\n * @see https://reactjs.org/docs/uncontrolled-components.html\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n const isControlled = useIsControlled(options.state);\n const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;\n const [internalState, setInternalState] = React.useState<State>(initialState);\n\n const state = isControlled ? (options.state as State) : internalState;\n\n const stateRef = React.useRef(state);\n React.useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n // To match the behavior of the setter returned by React.useState, this callback's identity\n // should never change. This means it MUST NOT directly reference variables that can change.\n const setState = React.useCallback((newState: React.SetStateAction<State>) => {\n // React dispatch can use a factory\n // https://reactjs.org/docs/hooks-reference.html#functional-updates\n if (isFactoryDispatch(newState)) {\n stateRef.current = newState(stateRef.current);\n } else {\n stateRef.current = newState;\n }\n\n setInternalState(stateRef.current);\n }, []);\n\n return [state, setState];\n};\n\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */\nconst useIsControlled = (controlledValue: unknown) => {\n const [isControlled] = React.useState<boolean>(() => controlledValue !== undefined);\n\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n\n const controlWarning = isControlled\n ? 'a controlled value to be uncontrolled'\n : 'an uncontrolled value to be controlled';\n\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n\n // eslint-disable-next-line no-console\n console.error(\n [\n // Default react error\n 'A component is changing ' + controlWarning + '. This is likely caused by the value',\n 'changing from ' + undefinedWarning + ' value, which should not happen.',\n 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.',\n 'More info: https://reactjs.org/link/controlled-components',\n error.stack,\n ].join(' '),\n );\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAqBA,SAASC,iBAAiBA,CAAQC,QAAqC;EACrE,OAAO,OAAOA,QAAQ,KAAK,UAAU;AACvC;AAEA;;;;;;;;;;;;;;;;AAgBO,MAAMC,oBAAoB,GAC/BC,OAA2C,IACa;EACxD,MAAMC,YAAY,GAAGC,eAAe,CAACF,OAAO,CAACG,KAAK,CAAC;EACnD,MAAMC,YAAY,GAAG,OAAOJ,OAAO,CAACK,YAAY,KAAK,WAAW,GAAGL,OAAO,CAACI,YAAY,GAAGJ,OAAO,CAACK,YAAY;EAC9G,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGZ,KAAK,CAACa,QAAQ,CAAQJ,YAAY,CAAC;EAE7E,MAAMD,KAAK,GAAGF,YAAY,GAAID,OAAO,CAACG,KAAe,GAAGG,aAAa;EAErE,MAAMG,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACP,KAAK,CAAC;EACpCR,KAAK,CAACgB,SAAS,CAAC,MAAK;IACnBF,QAAQ,CAACG,OAAO,GAAGT,KAAK;EAC1B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX;EACA;EACA,MAAMU,QAAQ,GAAGlB,KAAK,CAACmB,WAAW,CAAEhB,QAAqC,IAAI;IAC3E;IACA;IACA,IAAID,iBAAiB,CAACC,QAAQ,CAAC,EAAE;MAC/BW,QAAQ,CAACG,OAAO,GAAGd,QAAQ,CAACW,QAAQ,CAACG,OAAO,CAAC;KAC9C,MAAM;MACLH,QAAQ,CAACG,OAAO,GAAGd,QAAQ;;IAG7BS,gBAAgB,CAACE,QAAQ,CAACG,OAAO,CAAC;EACp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