@fluentui/react-utilities 9.18.16 → 9.18.18

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 (152) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/dist/index.d.ts +1 -2
  3. package/lib/compose/assertSlots.js.map +1 -1
  4. package/lib/compose/constants.js.map +1 -1
  5. package/lib/compose/deprecated/getSlots.js.map +1 -1
  6. package/lib/compose/deprecated/getSlotsNext.js.map +1 -1
  7. package/lib/compose/deprecated/resolveShorthand.js.map +1 -1
  8. package/lib/compose/getIntrinsicElementProps.js.map +1 -1
  9. package/lib/compose/index.js +11 -9
  10. package/lib/compose/index.js.map +1 -1
  11. package/lib/compose/isResolvedShorthand.js +2 -2
  12. package/lib/compose/isResolvedShorthand.js.map +1 -1
  13. package/lib/compose/isSlot.js.map +1 -1
  14. package/lib/compose/slot.js.map +1 -1
  15. package/lib/compose/types.js.map +1 -1
  16. package/lib/events/index.js +1 -1
  17. package/lib/events/index.js.map +1 -1
  18. package/lib/events/mouseTouchHelpers.js.map +1 -1
  19. package/lib/hooks/index.js +13 -13
  20. package/lib/hooks/index.js.map +1 -1
  21. package/lib/hooks/useAnimationFrame.js.map +1 -1
  22. package/lib/hooks/useBrowserTimer.js.map +1 -1
  23. package/lib/hooks/useControllableState.js.map +1 -1
  24. package/lib/hooks/useEventCallback.js.map +1 -1
  25. package/lib/hooks/useFirstMount.js.map +1 -1
  26. package/lib/hooks/useForceUpdate.js +2 -2
  27. package/lib/hooks/useForceUpdate.js.map +1 -1
  28. package/lib/hooks/useId.js.map +1 -1
  29. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  30. package/lib/hooks/useMergedRefs.js.map +1 -1
  31. package/lib/hooks/useOnClickOutside.js.map +1 -1
  32. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  33. package/lib/hooks/usePrevious.js.map +1 -1
  34. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  35. package/lib/hooks/useTimeout.js.map +1 -1
  36. package/lib/index.js.map +1 -1
  37. package/lib/selection/index.js +1 -2
  38. package/lib/selection/index.js.map +1 -1
  39. package/lib/selection/types.js.map +1 -1
  40. package/lib/selection/useSelection.js.map +1 -1
  41. package/lib/ssr/SSRContext.js.map +1 -1
  42. package/lib/ssr/canUseDOM.js.map +1 -1
  43. package/lib/ssr/index.js +2 -2
  44. package/lib/ssr/index.js.map +1 -1
  45. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  46. package/lib/trigger/getTriggerChild.js.map +1 -1
  47. package/lib/trigger/index.js +3 -4
  48. package/lib/trigger/index.js.map +1 -1
  49. package/lib/trigger/isFluentTrigger.js.map +1 -1
  50. package/lib/trigger/types.js.map +1 -1
  51. package/lib/utils/clamp.js.map +1 -1
  52. package/lib/utils/createSetFromIterable.js.map +1 -1
  53. package/lib/utils/getNativeElementProps.js.map +1 -1
  54. package/lib/utils/getRTLSafeKey.js.map +1 -1
  55. package/lib/utils/getReactCallbackName.js.map +1 -1
  56. package/lib/utils/index.js +10 -9
  57. package/lib/utils/index.js.map +1 -1
  58. package/lib/utils/isHTMLElement.js.map +1 -1
  59. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  60. package/lib/utils/mergeCallbacks.js.map +1 -1
  61. package/lib/utils/omit.js.map +1 -1
  62. package/lib/utils/priorityQueue.js.map +1 -1
  63. package/lib/utils/properties.js.map +1 -1
  64. package/lib/utils/types.js.map +1 -1
  65. package/lib/virtualParent/elementContains.js.map +1 -1
  66. package/lib/virtualParent/getParent.js.map +1 -1
  67. package/lib/virtualParent/index.js +3 -3
  68. package/lib/virtualParent/index.js.map +1 -1
  69. package/lib/virtualParent/isVirtualElement.js.map +1 -1
  70. package/lib/virtualParent/setVirtualParent.js.map +1 -1
  71. package/lib/virtualParent/types.js.map +1 -1
  72. package/lib-commonjs/compose/assertSlots.js.map +1 -1
  73. package/lib-commonjs/compose/constants.js.map +1 -1
  74. package/lib-commonjs/compose/deprecated/getSlots.js.map +1 -1
  75. package/lib-commonjs/compose/deprecated/getSlotsNext.js.map +1 -1
  76. package/lib-commonjs/compose/deprecated/resolveShorthand.js.map +1 -1
  77. package/lib-commonjs/compose/getIntrinsicElementProps.js.map +1 -1
  78. package/lib-commonjs/compose/index.js +43 -13
  79. package/lib-commonjs/compose/index.js.map +1 -1
  80. package/lib-commonjs/compose/isResolvedShorthand.js +3 -2
  81. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  82. package/lib-commonjs/compose/isSlot.js.map +1 -1
  83. package/lib-commonjs/compose/slot.js +1 -1
  84. package/lib-commonjs/compose/slot.js.map +1 -1
  85. package/lib-commonjs/compose/types.js.map +1 -1
  86. package/lib-commonjs/events/index.js +18 -2
  87. package/lib-commonjs/events/index.js.map +1 -1
  88. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  89. package/lib-commonjs/hooks/index.js +66 -14
  90. package/lib-commonjs/hooks/index.js.map +1 -1
  91. package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -1
  92. package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -1
  93. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  94. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  95. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  96. package/lib-commonjs/hooks/useForceUpdate.js +3 -2
  97. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  98. package/lib-commonjs/hooks/useId.js +1 -1
  99. package/lib-commonjs/hooks/useId.js.map +1 -1
  100. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  101. package/lib-commonjs/hooks/useMergedRefs.js +2 -1
  102. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  103. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  104. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  105. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  106. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  107. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  108. package/lib-commonjs/index.js +4 -0
  109. package/lib-commonjs/index.js.map +1 -1
  110. package/lib-commonjs/selection/index.js +7 -3
  111. package/lib-commonjs/selection/index.js.map +1 -1
  112. package/lib-commonjs/selection/types.js.map +1 -1
  113. package/lib-commonjs/selection/useSelection.js.map +1 -1
  114. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  115. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  116. package/lib-commonjs/ssr/index.js +28 -3
  117. package/lib-commonjs/ssr/index.js.map +1 -1
  118. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +3 -3
  119. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  120. package/lib-commonjs/trigger/getTriggerChild.js +3 -2
  121. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  122. package/lib-commonjs/trigger/index.js +20 -5
  123. package/lib-commonjs/trigger/index.js.map +1 -1
  124. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  125. package/lib-commonjs/trigger/types.js.map +1 -1
  126. package/lib-commonjs/utils/clamp.js.map +1 -1
  127. package/lib-commonjs/utils/createSetFromIterable.js.map +1 -1
  128. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  129. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  130. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  131. package/lib-commonjs/utils/index.js +132 -10
  132. package/lib-commonjs/utils/index.js.map +1 -1
  133. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  134. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  135. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  136. package/lib-commonjs/utils/omit.js.map +1 -1
  137. package/lib-commonjs/utils/priorityQueue.js +0 -4
  138. package/lib-commonjs/utils/priorityQueue.js.map +1 -1
  139. package/lib-commonjs/utils/properties.js +2 -1
  140. package/lib-commonjs/utils/properties.js.map +1 -1
  141. package/lib-commonjs/utils/types.js +1 -4
  142. package/lib-commonjs/utils/types.js.map +1 -1
  143. package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
  144. package/lib-commonjs/virtualParent/getParent.js.map +1 -1
  145. package/lib-commonjs/virtualParent/index.js +20 -4
  146. package/lib-commonjs/virtualParent/index.js.map +1 -1
  147. package/lib-commonjs/virtualParent/isVirtualElement.js +1 -4
  148. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
  149. package/lib-commonjs/virtualParent/setVirtualParent.js +1 -7
  150. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
  151. package/lib-commonjs/virtualParent/types.js.map +1 -1
  152. package/package.json +3 -18
@@ -1 +1 @@
1
- {"version":3,"sources":["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 'onAnimationEnd',\n 'onAnimationStart',\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"],"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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,cAAc,CAAC,GAAGC;IACtB,MAAMC,SAAiC,CAAC;IAExC,KAAK,MAAMC,QAAQF,MAAO;QACxB,MAAMG,OAAOC,MAAMC,OAAO,CAACH,QAAQA,OAAOI,OAAOH,IAAI,CAACD;QAEtD,KAAK,MAAMK,OAAOJ,KAAM;YACtBF,MAAM,CAACM,IAAI,GAAG;QAChB;IACF;IAEA,OAAON;AACT;AAEA;;;;CAIC,GACD,OAAO,MAAMO,oBAAoBT,YAAY;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMU,wBAAwBV,YAAY;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMW,sBAAsBX,YAAY;IAC7C;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMY,wBAAwBZ,YAAYU,uBAAuBD,mBAAmBE,qBAAqB;AAEhH;;;;CAIC,GACD,OAAO,MAAME,kBAAkBb,YAAYY,uBAAuB;IAChE;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,kBAAkBd,YAAYY,uBAAuB;IAChE;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMG,kBAAkBf,YAAYc,iBAAiB;IAC1D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,eAAehB,YAAYY,uBAAuB;IAC7D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMK,eAAejB,YAAYY,uBAAuB;IAC7D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMM,mBAAmBlB,YAAYY,uBAAuB;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMO,iBAAiBnB,YAAYY,uBAAuB;IAC/D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMQ,mBAAmBpB,YAAYY,uBAAuB;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMS,kBAAkBrB,YAAYoB,kBAAkB;IAC3D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,qBAAqBtB,YAAYoB,kBAAkB;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMG,mBAAmBvB,YAAYoB,kBAAkB;IAC5D;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMI,mBAAmBxB,YAAYY,uBAAuB;IACjE;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMa,kBAAkBzB,YAAYY,uBAAuB;IAChE;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMc,eAAed,sBAAsB;AAElD;;;;CAIC,GACD,OAAO,MAAMe,eAAe3B,YAAYY,uBAAuB;IAC7D;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMgB,eAAe5B,YAAYY,uBAAuB;IAC7D;IACA;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMiB,qBAAqB7B,YAAYY,uBAAuB;IACnE;CACD,EAAE;AAEH,OAAO,MAAMkB,gBAAgB9B,YAAYY,uBAAuB;IAC9D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMmB,qBAAqB/B,YAAYY,uBAAuB;IACnE;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMoB,iBAAiBhC,YAAYY,uBAAuB;IAC/D;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMqB,mBAAmBjC,YAAYY,uBAAuB;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMsB,gBAAgBlC,YAAYY,uBAAuB;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMuB,mBAAmBnC,YAAYY,uBAAuB;IAAC;IAAQ;IAAY;CAAU,EAAE;AAEpG;;;;CAIC,GACD,OAAO,MAAMwB,gBAAgBxB,sBAAsB;AAEnD;;;;;;;;;;;;;;CAcC,GACD,8DAA8D;AAC9D,OAAO,SAASyB,eACd,8DAA8D;AAC9DC,KAA0B,EAC1BC,gBAAmD,EACnDC,iBAA4B;IAE5B,6GAA6G;IAC7G,2GAA2G;IAC3G,2GAA2G;IAC3G,uBAAuB;IACvB,0GAA0G;IAE1G,MAAMlC,UAAUD,MAAMC,OAAO,CAACiC;IAC9B,8DAA8D;IAC9D,MAAMrC,SAA8B,CAAC;IACrC,MAAME,OAAOG,OAAOH,IAAI,CAACkC;IAEzB,KAAK,MAAM9B,OAAOJ,KAAM;QACtB,MAAMqC,eACJ,AAAC,CAACnC,WAAW,AAACiC,gBAA2C,CAAC/B,IAAI,IAC7DF,WAAW,AAACiC,iBAA8BG,OAAO,CAAClC,QAAQ,KAC3DA,IAAIkC,OAAO,CAAC,aAAa,KACzBlC,IAAIkC,OAAO,CAAC,aAAa;QAE3B,IAAID,gBAAiB,CAAA,CAACD,qBAAqBA,CAAAA,8BAAAA,wCAAAA,kBAAmBE,OAAO,CAAClC,UAAS,CAAC,CAAA,GAAI;YAClF,8DAA8D;YAC9DN,MAAM,CAACM,IAAI,GAAG8B,KAAM,CAAC9B,IAAI;QAC3B;IACF;IAEA,OAAON;AACT"}
1
+ {"version":3,"sources":["../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 'onAnimationEnd',\n 'onAnimationStart',\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"],"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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,cAAc,CAAC,GAAGC;IACtB,MAAMC,SAAiC,CAAC;IAExC,KAAK,MAAMC,QAAQF,MAAO;QACxB,MAAMG,OAAOC,MAAMC,OAAO,CAACH,QAAQA,OAAOI,OAAOH,IAAI,CAACD;QAEtD,KAAK,MAAMK,OAAOJ,KAAM;YACtBF,MAAM,CAACM,IAAI,GAAG;QAChB;IACF;IAEA,OAAON;AACT;AAEA;;;;CAIC,GACD,OAAO,MAAMO,oBAAoBT,YAAY;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMU,wBAAwBV,YAAY;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMW,sBAAsBX,YAAY;IAC7C;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMY,wBAAwBZ,YAAYU,uBAAuBD,mBAAmBE,qBAAqB;AAEhH;;;;CAIC,GACD,OAAO,MAAME,kBAAkBb,YAAYY,uBAAuB;IAChE;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,kBAAkBd,YAAYY,uBAAuB;IAChE;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMG,kBAAkBf,YAAYc,iBAAiB;IAC1D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,eAAehB,YAAYY,uBAAuB;IAC7D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMK,eAAejB,YAAYY,uBAAuB;IAC7D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMM,mBAAmBlB,YAAYY,uBAAuB;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMO,iBAAiBnB,YAAYY,uBAAuB;IAC/D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMQ,mBAAmBpB,YAAYY,uBAAuB;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMS,kBAAkBrB,YAAYoB,kBAAkB;IAC3D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,qBAAqBtB,YAAYoB,kBAAkB;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMG,mBAAmBvB,YAAYoB,kBAAkB;IAC5D;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMI,mBAAmBxB,YAAYY,uBAAuB;IACjE;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMa,kBAAkBzB,YAAYY,uBAAuB;IAChE;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMc,eAAed,sBAAsB;AAElD;;;;CAIC,GACD,OAAO,MAAMe,eAAe3B,YAAYY,uBAAuB;IAC7D;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMgB,eAAe5B,YAAYY,uBAAuB;IAC7D;IACA;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMiB,qBAAqB7B,YAAYY,uBAAuB;IACnE;CACD,EAAE;AAEH,OAAO,MAAMkB,gBAAgB9B,YAAYY,uBAAuB;IAC9D;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMmB,qBAAqB/B,YAAYY,uBAAuB;IACnE;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMoB,iBAAiBhC,YAAYY,uBAAuB;IAC/D;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMqB,mBAAmBjC,YAAYY,uBAAuB;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMsB,gBAAgBlC,YAAYY,uBAAuB;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMuB,mBAAmBnC,YAAYY,uBAAuB;IAAC;IAAQ;IAAY;CAAU,EAAE;AAEpG;;;;CAIC,GACD,OAAO,MAAMwB,gBAAgBxB,sBAAsB;AAEnD;;;;;;;;;;;;;;CAcC,GACD,8DAA8D;AAC9D,OAAO,SAASyB,eACd,8DAA8D;AAC9DC,KAA0B,EAC1BC,gBAAmD,EACnDC,iBAA4B;IAE5B,6GAA6G;IAC7G,2GAA2G;IAC3G,2GAA2G;IAC3G,uBAAuB;IACvB,0GAA0G;IAE1G,MAAMlC,UAAUD,MAAMC,OAAO,CAACiC;IAC9B,8DAA8D;IAC9D,MAAMrC,SAA8B,CAAC;IACrC,MAAME,OAAOG,OAAOH,IAAI,CAACkC;IAEzB,KAAK,MAAM9B,OAAOJ,KAAM;QACtB,MAAMqC,eACJ,AAAC,CAACnC,WAAW,AAACiC,gBAA2C,CAAC/B,IAAI,IAC7DF,WAAW,AAACiC,iBAA8BG,OAAO,CAAClC,QAAQ,KAC3DA,IAAIkC,OAAO,CAAC,aAAa,KACzBlC,IAAIkC,OAAO,CAAC,aAAa;QAE3B,IAAID,gBAAiB,CAAA,CAACD,qBAAqBA,CAAAA,8BAAAA,wCAAAA,kBAAmBE,OAAO,CAAClC,UAAS,CAAC,CAAA,GAAI;YAClF,8DAA8D;YAC9DN,MAAM,CAACM,IAAI,GAAG8B,KAAM,CAAC9B,IAAI;QAC3B;IACF;IAEA,OAAON;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"sourcesContent":["/**\n * Helper type that works similar to Omit,\n * but when modifying an union type it will distribute the omission to all the union members.\n *\n * See [distributive conditional types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types) for more information\n */\n// Traditional Omit is basically equivalent to => Pick<T, Exclude<keyof T, K>>\n//\n// let's say we have Omit<{ a: string } | { b: string }, 'a'>\n// equivalent to: Pick<{ a: string } | { b: string }, Exclude<keyof ({ a: string } | { b: string }), 'a'>>\n// The expected result would be {} | { b: string }, the omission of 'a' from all the union members,\n// but keyof ({ a: string } | { b: string }) is never as they don't share common keys\n// so Exclude<never, 'a'> is never,\n// and Pick<{ a: string } | { b: string }, never> is {}.\n//\n// With DistributiveOmit on the other hand it becomes like this:\n// DistributiveOmit<{ a: string } | { b: string }, 'a'>\n// equivalent to: Omit<{ a: string }, 'a'> | Omit<{ b: string }, 'a'>\n// Since every single Omit clause in this case is being applied to a single union member there's no conflicts on keyof evaluation and in the second clause Omit<{ b: string }, 'a'> becomes { b: string },\n// so the result is {} | { b: string }, as expected.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : T;\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 * @internal\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"],"names":[],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;;CAKC,GACD,8EAA8E;AAC9E,EAAE;AACF,6DAA6D;AAC7D,0GAA0G;AAC1G,mGAAmG;AACnG,qFAAqF;AACrF,oCAAoC;AACpC,wDAAwD;AACxD,EAAE;AACF,gEAAgE;AAChE,uDAAuD;AACvD,qEAAqE;AACrE,0MAA0M;AAC1M,oDAAoD;AACpD,8DAA8D;AAQ9D;;;CAGC,GACD,WAA4F"}
1
+ {"version":3,"sources":["../src/utils/types.ts"],"sourcesContent":["/**\n * Helper type that works similar to Omit,\n * but when modifying an union type it will distribute the omission to all the union members.\n *\n * See [distributive conditional types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types) for more information\n */\n// Traditional Omit is basically equivalent to => Pick<T, Exclude<keyof T, K>>\n//\n// let's say we have Omit<{ a: string } | { b: string }, 'a'>\n// equivalent to: Pick<{ a: string } | { b: string }, Exclude<keyof ({ a: string } | { b: string }), 'a'>>\n// The expected result would be {} | { b: string }, the omission of 'a' from all the union members,\n// but keyof ({ a: string } | { b: string }) is never as they don't share common keys\n// so Exclude<never, 'a'> is never,\n// and Pick<{ a: string } | { b: string }, never> is {}.\n//\n// With DistributiveOmit on the other hand it becomes like this:\n// DistributiveOmit<{ a: string } | { b: string }, 'a'>\n// equivalent to: Omit<{ a: string }, 'a'> | Omit<{ b: string }, 'a'>\n// Since every single Omit clause in this case is being applied to a single union member there's no conflicts on keyof evaluation and in the second clause Omit<{ b: string }, 'a'> becomes { b: string },\n// so the result is {} | { b: string }, as expected.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : T;\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 * @internal\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"],"names":[],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;;CAKC,GACD,8EAA8E;AAC9E,EAAE;AACF,6DAA6D;AAC7D,0GAA0G;AAC1G,mGAAmG;AACnG,qFAAqF;AACrF,oCAAoC;AACpC,wDAAwD;AACxD,EAAE;AACF,gEAAgE;AAChE,uDAAuD;AACvD,qEAAqE;AACrE,0MAA0M;AAC1M,oDAAoD;AACpD,8DAA8D;AAQ9D;;;CAGC,GACD,WAA4F"}
@@ -1 +1 @@
1
- {"version":3,"sources":["elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @internal\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC;;;;;;CAMC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB;IACrE,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO;IACT;IAEA,IAAID,WAAWC,OAAO;QACpB,OAAO;IACT,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAEhB,MAAOF,MAAO;YACZ,MAAMG,aAA0BN,UAAUG,OAAO;gBAC/CI,aAAaH,IAAII,GAAG,CAACL;YACvB;YACAC,IAAIK,GAAG,CAACN;YAER,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO;YACT;YAEAC,QAAQG;QACV;IACF;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @internal\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC;;;;;;CAMC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB;IACrE,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO;IACT;IAEA,IAAID,WAAWC,OAAO;QACpB,OAAO;IACT,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAEhB,MAAOF,MAAO;YACZ,MAAMG,aAA0BN,UAAUG,OAAO;gBAC/CI,aAAaH,IAAII,GAAG,CAACL;YACvB;YACAC,IAAIK,GAAG,CAACN;YAER,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO;YACT;YAEAC,QAAQG;QACV;IACF;IAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n * @internal\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n * @internal\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n * @internal\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n const parent = child.parentNode;\n\n if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n return (parent as ShadowRoot).host;\n }\n\n return parent;\n}\n"],"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode","nodeType","Node","DOCUMENT_FRAGMENT_NODE","host"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB;AAUtD;;;CAGC,GACD,SAASC,iBAAiBC,KAAW;IACnC,OAAOF,iBAAiBE,SAASA,MAAMC,QAAQ,CAACC,MAAM,IAAI,OAAO;AACnE;AAEA;;;;CAIC,GACD,OAAO,SAASC,UAAUH,KAAkB,EAAEI,UAA4B,CAAC,CAAC;IAC1E,IAAI,CAACJ,OAAO;QACV,OAAO;IACT;IAEA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QAEvC,IAAIM,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,MAAMJ,SAASF,MAAMO,UAAU;IAE/B,IAAIL,UAAUA,OAAOM,QAAQ,KAAKC,KAAKC,sBAAsB,EAAE;QAC7D,OAAO,AAACR,OAAsBS,IAAI;IACpC;IAEA,OAAOT;AACT"}
1
+ {"version":3,"sources":["../src/virtualParent/getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n * @internal\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n * @internal\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n * @internal\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n const parent = child.parentNode;\n\n if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n return (parent as ShadowRoot).host;\n }\n\n return parent;\n}\n"],"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode","nodeType","Node","DOCUMENT_FRAGMENT_NODE","host"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB;AAUtD;;;CAGC,GACD,SAASC,iBAAiBC,KAAW;IACnC,OAAOF,iBAAiBE,SAASA,MAAMC,QAAQ,CAACC,MAAM,IAAI,OAAO;AACnE;AAEA;;;;CAIC,GACD,OAAO,SAASC,UAAUH,KAAkB,EAAEI,UAA4B,CAAC,CAAC;IAC1E,IAAI,CAACJ,OAAO;QACV,OAAO;IACT;IAEA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QAEvC,IAAIM,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,MAAMJ,SAASF,MAAMO,UAAU;IAE/B,IAAIL,UAAUA,OAAOM,QAAQ,KAAKC,KAAKC,sBAAsB,EAAE;QAC7D,OAAO,AAACR,OAAsBS,IAAI;IACpC;IAEA,OAAOT;AACT"}
@@ -1,3 +1,3 @@
1
- export * from './elementContains';
2
- export * from './setVirtualParent';
3
- export * from './getParent';
1
+ export { elementContains } from './elementContains';
2
+ export { setVirtualParent } from './setVirtualParent';
3
+ export { getParent } from './getParent';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\nexport * from './getParent';\n"],"names":[],"rangeMappings":";;","mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,cAAc"}
1
+ {"version":3,"sources":["../src/virtualParent/index.ts"],"sourcesContent":["export { elementContains } from './elementContains';\nexport { setVirtualParent } from './setVirtualParent';\nexport { getParent } from './getParent';\n"],"names":["elementContains","setVirtualParent","getParent"],"rangeMappings":";;","mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,SAAS,QAAQ,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"sources":["isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n * @internal\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"names":["isVirtualElement","element","_virtual"],"rangeMappings":";;;;;","mappings":"AAEA;;;CAGC,GACD,OAAO,SAASA,iBAAiBC,OAA8B;IAC7D,OAAOA,WAAW,CAAC,CAAC,AAAiBA,QAASC,QAAQ;AACxD"}
1
+ {"version":3,"sources":["../src/virtualParent/isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n * @internal\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"names":["isVirtualElement","element","_virtual"],"rangeMappings":";;;;;","mappings":"AAEA;;;CAGC,GACD,OAAO,SAASA,iBAAiBC,OAA8B;IAC7D,OAAOA,WAAW,CAAC,CAAC,AAAiBA,QAASC,QAAQ;AACxD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @internal\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAEA;;;;;;CAMC,GACD,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa;IACzD,IAAI,CAACD,OAAO;QACV;IACF;IAEA,MAAME,eAAeF;IAErB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QAC1BD,aAAaC,QAAQ,GAAG,CAAC;IAC3B;IAEAD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACjC"}
1
+ {"version":3,"sources":["../src/virtualParent/setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @internal\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAEA;;;;;;CAMC,GACD,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa;IACzD,IAAI,CAACD,OAAO;QACV;IACF;IAEA,MAAME,eAAeF;IAErB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QAC1BD,aAAaC,QAAQ,GAAG,CAAC;IAC3B;IAEAD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACjC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WAIC"}
1
+ {"version":3,"sources":["../src/virtualParent/types.ts"],"sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WAIC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport * as slot from './slot';\n\ntype SlotComponents<Slots extends SlotPropsRecord> = {\n [K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>> | (null extends Slots[K] ? undefined : never);\n};\n\n/**\n * @internal\n * Assertion method to ensure state slots properties are properly declared.\n * A properly declared slot must be declared by using the `slot` method.\n *\n * @example\n * ```tsx\n * export const renderInput_unstable = (state: InputState) => {\n assertSlots<InputSlots>(state);\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && <state.contentAfter />}\n </state.root>\n );\n };\n * ```\n */\nexport function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots> {\n /**\n * This verification is not necessary in production\n * as we're verifying static properties that will not change between environments\n */\n if (process.env.NODE_ENV !== 'production') {\n const typedState = state as ComponentState<Slots>;\n for (const slotName of Object.keys(typedState.components)) {\n const slotElement = typedState[slotName];\n if (slotElement === undefined) {\n continue;\n }\n // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName as keyof ComponentState<Slots>] = slot.always(slotElement, {\n elementType: typedState.components[slotName] as React.ComponentType<{}>,\n }) as ComponentState<Slots>[keyof ComponentState<Slots>];\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" is not a slot!\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\".\n `);\n } else {\n // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName] as React.ComponentType<{}>;\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" element type differs from \"state.components.${slotName}\",\n ${elementType} !== ${typedState.components[slotName]}.\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\" with the correct elementType.\n `);\n }\n }\n }\n }\n}\n"],"names":["assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","isSlot","slot","always","elementType","console","warn","name","SLOT_ELEMENT_TYPE_SYMBOL"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA6BgBA;;;eAAAA;;;;iEA7BO;2BACkB;wBAClB;gEAED;AAyBf,SAASA,YAA2CC,KAAc;IACvE;;;GAGC,GACD,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMC,aAAaJ;QACnB,KAAK,MAAMK,YAAYC,OAAOC,IAAI,CAACH,WAAWI,UAAU,EAAG;YACzD,MAAMC,cAAcL,UAAU,CAACC,SAAS;YACxC,IAAII,gBAAgBC,WAAW;gBAC7B;YACF;YACA,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACC,IAAAA,cAAAA,EAAOF,cAAc;gBACxBL,UAAU,CAACC,SAAwC,GAAGO,MAAKC,MAAM,CAACJ,aAAa;oBAC7EK,aAAaV,WAAWI,UAAU,CAACH,SAAS;gBAC9C;gBACA,sCAAsC;gBACtCU,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEjB,YAAYkB,IAAI,CAAC;OACvC,EAAEZ,SAAS;2EAEpB,CAAC;YACH,OAAO;gBACL,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACa,mCAAAA,CAAyB,EAAEJ,WAAW,EAAE,GAAGL;gBACpD,IAAIK,gBAAgBV,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACnDI,WAAW,CAACS,mCAAAA,CAAyB,GAAGd,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCU,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEjB,YAAYkB,IAAI,CAAC;OACvC,EAAEZ,SAAS,8CAA8C,EAAEA,SAAS;AAC3E,EAAES,YAAY,KAAK,EAAEV,WAAWI,UAAU,CAACH,SAAS,CAAC;wGAEvD,CAAC;gBACH;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/compose/assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport * as slot from './slot';\n\ntype SlotComponents<Slots extends SlotPropsRecord> = {\n [K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>> | (null extends Slots[K] ? undefined : never);\n};\n\n/**\n * @internal\n * Assertion method to ensure state slots properties are properly declared.\n * A properly declared slot must be declared by using the `slot` method.\n *\n * @example\n * ```tsx\n * export const renderInput_unstable = (state: InputState) => {\n assertSlots<InputSlots>(state);\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && <state.contentAfter />}\n </state.root>\n );\n };\n * ```\n */\nexport function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots> {\n /**\n * This verification is not necessary in production\n * as we're verifying static properties that will not change between environments\n */\n if (process.env.NODE_ENV !== 'production') {\n const typedState = state as ComponentState<Slots>;\n for (const slotName of Object.keys(typedState.components)) {\n const slotElement = typedState[slotName];\n if (slotElement === undefined) {\n continue;\n }\n // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName as keyof ComponentState<Slots>] = slot.always(slotElement, {\n elementType: typedState.components[slotName] as React.ComponentType<{}>,\n }) as ComponentState<Slots>[keyof ComponentState<Slots>];\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" is not a slot!\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\".\n `);\n } else {\n // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName] as React.ComponentType<{}>;\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" element type differs from \"state.components.${slotName}\",\n ${elementType} !== ${typedState.components[slotName]}.\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\" with the correct elementType.\n `);\n }\n }\n }\n }\n}\n"],"names":["assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","isSlot","slot","always","elementType","console","warn","name","SLOT_ELEMENT_TYPE_SYMBOL"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA6BgBA;;;eAAAA;;;;iEA7BO;2BACkB;wBAClB;gEAED;AAyBf,SAASA,YAA2CC,KAAc;IACvE;;;GAGC,GACD,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMC,aAAaJ;QACnB,KAAK,MAAMK,YAAYC,OAAOC,IAAI,CAACH,WAAWI,UAAU,EAAG;YACzD,MAAMC,cAAcL,UAAU,CAACC,SAAS;YACxC,IAAII,gBAAgBC,WAAW;gBAC7B;YACF;YACA,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACC,IAAAA,cAAM,EAACF,cAAc;gBACxBL,UAAU,CAACC,SAAwC,GAAGO,MAAKC,MAAM,CAACJ,aAAa;oBAC7EK,aAAaV,WAAWI,UAAU,CAACH,SAAS;gBAC9C;gBACA,sCAAsC;gBACtCU,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEjB,YAAYkB,IAAI,CAAC;OACvC,EAAEZ,SAAS;2EAEpB,CAAC;YACH,OAAO;gBACL,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACa,mCAAwB,CAAC,EAAEJ,WAAW,EAAE,GAAGL;gBACpD,IAAIK,gBAAgBV,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACnDI,WAAW,CAACS,mCAAwB,CAAC,GAAGd,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCU,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEjB,YAAYkB,IAAI,CAAC;OACvC,EAAEZ,SAAS,8CAA8C,EAAEA,SAAS;AAC3E,EAAES,YAAY,KAAK,EAAEV,WAAWI,UAAU,CAACH,SAAS,CAAC;wGAEvD,CAAC;gBACH;YACF;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol.for('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_ELEMENT_TYPE_SYMBOL = Symbol.for('fui.slotElementType');\n"],"names":["SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","Symbol","for"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;CAGC;;;;;;;;;;;IAMYA,wBAAAA;eAAAA;;IALAC,2BAAAA;eAAAA;;;AAAN,MAAMA,8BAA8BC,OAAOC,GAAG,CAAC;AAK/C,MAAMH,2BAA2BE,OAAOC,GAAG,CAAC"}
1
+ {"version":3,"sources":["../src/compose/constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol.for('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_ELEMENT_TYPE_SYMBOL = Symbol.for('fui.slotElementType');\n"],"names":["SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","Symbol","for"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;CAGC;;;;;;;;;;;IAMYA,wBAAwB;eAAxBA;;IALAC,2BAA2B;eAA3BA;;;AAAN,MAAMA,8BAA8BC,OAAOC,GAAG,CAAC;AAK/C,MAAMH,2BAA2BE,OAAOC,GAAG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["getSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnknownSlotProps,\n} from '../types';\nimport { isSlot } from '../isSlot';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '../constants';\nimport { UnionToIntersection } from '../../utils/types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\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\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type 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]> // Slot<'div', 'span'>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P // Slot<typeof Button>\n : ExtractSlotProps<S[K]>; // Slot<ButtonProps>\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 * @deprecated use slot.always or slot.optional combined with assertSlots instead\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 // eslint-disable-next-line deprecation/deprecation\n slots: Slots<R>;\n // eslint-disable-next-line deprecation/deprecation\n slotProps: ObjectSlotProps<R>;\n} {\n // eslint-disable-next-line deprecation/deprecation\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 // eslint-disable-next-line deprecation/deprecation\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line deprecation/deprecation\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 const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, children, ...rest } = props as NonUndefined<typeof props>;\n\n const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;\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 (renderFunction || typeof children === 'function') {\n const render = (renderFunction || children) as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n {\n children: render(slot, rest as Omit<R[K], 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps = (shouldOmitAsProp ? omit(props, ['as']) : (props as UnknownSlotProps)) as R[K];\n return [slot, slotProps];\n}\n"],"names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","undefined","as","asProp","children","rest","renderFunction","isSlot","SLOT_RENDER_FUNCTION_SYMBOL","render","React","Fragment","shouldOmitAsProp","omit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA0DgBA;;;eAAAA;;;;iEA1DO;sBACF;wBASE;2BACqB;AA+CrC,SAASA,SACdC,KAAwB;IAOxB,mDAAmD;IACnD,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC3D,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,OAAOO;QACrC,mDAAmD;QACnDN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,mDAAmD;IACnD,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA,SAASQ,QACPV,KAAwB,EACxBO,QAAW;QAeTP,mBACcA;IAdhB,MAAMS,QAAQT,KAAK,CAACO,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,MAAM,GAAGN;IAE1C,MAAMO,iBAAiBC,IAAAA,cAAAA,EAAOR,SAASA,KAAK,CAACS,sCAAAA,CAA4B,GAAGP;IAE5E,MAAMH,OACJR,CAAAA,CAAAA,oBAAAA,MAAMM,UAAU,AAAVA,MAAU,QAAhBN,sBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,iBAAkB,CAACO,SAAS,AAATA,MAAcI,aAAa,OAAOX,MAAMM,UAAU,CAACC,SAAS,KAAK,WAChFM,UAAAA,CAAAA,AAAUb,CAAAA,qBAAAA,MAAMM,UAAU,AAAVA,MAAU,QAAhBN,uBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,kBAAkB,CAACO,SAAS,AAATA,KAAa,QAC1CP,MAAMM,UAAU,CAACC,SAAS;IAGhC,IAAIS,kBAAkB,OAAOF,aAAa,YAAY;QACpD,MAAMK,SAAUH,kBAAkBF;QAClC,OAAO;YACLM,OAAMC,QAAQ;YACd;gBACEP,UAAUK,OAAOX,MAAMO;YACzB;SACD;IACH;IAEA,MAAMO,mBAAmB,OAAOd,SAAS,YAAYK;IACrD,MAAMX,YAAaoB,mBAAmBC,IAAAA,UAAAA,EAAKd,OAAO;QAAC;KAAK,IAAKA;IAC7D,OAAO;QAACD;QAAMN;KAAU;AAC1B"}
1
+ {"version":3,"sources":["../src/compose/deprecated/getSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnknownSlotProps,\n} from '../types';\nimport { isSlot } from '../isSlot';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '../constants';\nimport { UnionToIntersection } from '../../utils/types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\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\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type 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]> // Slot<'div', 'span'>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P // Slot<typeof Button>\n : ExtractSlotProps<S[K]>; // Slot<ButtonProps>\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 * @deprecated use slot.always or slot.optional combined with assertSlots instead\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 // eslint-disable-next-line deprecation/deprecation\n slots: Slots<R>;\n // eslint-disable-next-line deprecation/deprecation\n slotProps: ObjectSlotProps<R>;\n} {\n // eslint-disable-next-line deprecation/deprecation\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 // eslint-disable-next-line deprecation/deprecation\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line deprecation/deprecation\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 const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, children, ...rest } = props as NonUndefined<typeof props>;\n\n const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;\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 (renderFunction || typeof children === 'function') {\n const render = (renderFunction || children) as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n {\n children: render(slot, rest as Omit<R[K], 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps = (shouldOmitAsProp ? omit(props, ['as']) : (props as UnknownSlotProps)) as R[K];\n return [slot, slotProps];\n}\n"],"names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","undefined","as","asProp","children","rest","renderFunction","isSlot","SLOT_RENDER_FUNCTION_SYMBOL","render","React","Fragment","shouldOmitAsProp","omit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA0DgBA;;;eAAAA;;;;iEA1DO;sBACF;wBASE;2BACqB;AA+CrC,SAASA,SACdC,KAAwB;IAOxB,mDAAmD;IACnD,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC3D,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,OAAOO;QACrC,mDAAmD;QACnDN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,mDAAmD;IACnD,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA,SAASQ,QACPV,KAAwB,EACxBO,QAAW;QAeTP,mBACcA;IAdhB,MAAMS,QAAQT,KAAK,CAACO,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,MAAM,GAAGN;IAE1C,MAAMO,iBAAiBC,IAAAA,cAAM,EAACR,SAASA,KAAK,CAACS,sCAA2B,CAAC,GAAGP;IAE5E,MAAMH,OACJR,EAAAA,oBAAAA,MAAMM,UAAU,cAAhBN,wCAAAA,iBAAkB,CAACO,SAAS,MAAKI,aAAa,OAAOX,MAAMM,UAAU,CAACC,SAAS,KAAK,WAChFM,YAAUb,qBAAAA,MAAMM,UAAU,cAAhBN,yCAAAA,kBAAkB,CAACO,SAAS,KAAI,QAC1CP,MAAMM,UAAU,CAACC,SAAS;IAGhC,IAAIS,kBAAkB,OAAOF,aAAa,YAAY;QACpD,MAAMK,SAAUH,kBAAkBF;QAClC,OAAO;YACLM,OAAMC,QAAQ;YACd;gBACEP,UAAUK,OAAOX,MAAMO;YACzB;SACD;IACH;IAEA,MAAMO,mBAAmB,OAAOd,SAAS,YAAYK;IACrD,MAAMX,YAAaoB,mBAAmBC,IAAAA,UAAI,EAACd,OAAO;QAAC;KAAK,IAAKA;IAC7D,OAAO;QAACD;QAAMN;KAAU;AAC1B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["getSlotsNext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentState, SlotPropsRecord, UnknownSlotProps } from '../types';\nimport { ObjectSlotProps, Slots } from './getSlots';\n\n/**\n * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma\n *\n * @internal\n * This is an internal temporary method, this method will cease to exist eventually!\n *\n * * ❗️❗️ **DO NOT USE IT EXTERNALLY** ❗️❗️\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport function getSlotsNext<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n // eslint-disable-next-line deprecation/deprecation\n slots: Slots<R>;\n // eslint-disable-next-line deprecation/deprecation\n slotProps: ObjectSlotProps<R>;\n} {\n // eslint-disable-next-line deprecation/deprecation\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 // eslint-disable-next-line deprecation/deprecation\n const [slot, props] = getSlotNext(state, slotName);\n // eslint-disable-next-line deprecation/deprecation\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line deprecation/deprecation\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nfunction getSlotNext<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, ...propsWithoutAs } = props as NonUndefined<typeof props>;\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 const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps: UnknownSlotProps = shouldOmitAsProp ? propsWithoutAs : props;\n\n return [slot, slotProps as R[K]];\n}\n"],"names":["getSlotsNext","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAcgBA;;;eAAAA;;;;iEAdO;AAchB,SAASA,aACdC,KAAwB;IAOxB,mDAAmD;IACnD,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC3D,KAAK,MAAMC,YAAYJ,UAAW;QAChC,mDAAmD;QACnD,MAAM,CAACK,MAAMC,MAAM,GAAGC,YAAYV,OAAOO;QACzC,mDAAmD;QACnDN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,mDAAmD;IACnD,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA;;CAEC,GACD,SAASQ,YACPV,KAAwB,EACxBO,QAAW;QAaTP,mBACcA;IAZhB,MAAMS,QAAQT,KAAK,CAACO,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAE,GAAGC,gBAAgB,GAAGL;IAE1C,MAAMD,OACJR,CAAAA,CAAAA,oBAAAA,MAAMM,UAAU,AAAVA,MAAU,QAAhBN,sBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,iBAAkB,CAACO,SAAS,AAATA,MAAcI,aAAa,OAAOX,MAAMM,UAAU,CAACC,SAAS,KAAK,WAChFM,UAAAA,CAAAA,AAAUb,CAAAA,qBAAAA,MAAMM,UAAU,AAAVA,MAAU,QAAhBN,uBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,kBAAkB,CAACO,SAAS,AAATA,KAAa,QAC1CP,MAAMM,UAAU,CAACC,SAAS;IAGhC,MAAMQ,mBAAmB,OAAOP,SAAS,YAAYK;IACrD,MAAMX,YAA8Ba,mBAAmBD,iBAAiBL;IAExE,OAAO;QAACD;QAAMN;KAAkB;AAClC"}
1
+ {"version":3,"sources":["../src/compose/deprecated/getSlotsNext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentState, SlotPropsRecord, UnknownSlotProps } from '../types';\nimport { ObjectSlotProps, Slots } from './getSlots';\n\n/**\n * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma\n *\n * @internal\n * This is an internal temporary method, this method will cease to exist eventually!\n *\n * * ❗️❗️ **DO NOT USE IT EXTERNALLY** ❗️❗️\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport function getSlotsNext<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n // eslint-disable-next-line deprecation/deprecation\n slots: Slots<R>;\n // eslint-disable-next-line deprecation/deprecation\n slotProps: ObjectSlotProps<R>;\n} {\n // eslint-disable-next-line deprecation/deprecation\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 // eslint-disable-next-line deprecation/deprecation\n const [slot, props] = getSlotNext(state, slotName);\n // eslint-disable-next-line deprecation/deprecation\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line deprecation/deprecation\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nfunction getSlotNext<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, ...propsWithoutAs } = props as NonUndefined<typeof props>;\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 const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps: UnknownSlotProps = shouldOmitAsProp ? propsWithoutAs : props;\n\n return [slot, slotProps as R[K]];\n}\n"],"names":["getSlotsNext","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAcgBA;;;eAAAA;;;;iEAdO;AAchB,SAASA,aACdC,KAAwB;IAOxB,mDAAmD;IACnD,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC3D,KAAK,MAAMC,YAAYJ,UAAW;QAChC,mDAAmD;QACnD,MAAM,CAACK,MAAMC,MAAM,GAAGC,YAAYV,OAAOO;QACzC,mDAAmD;QACnDN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,mDAAmD;IACnD,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA;;CAEC,GACD,SAASQ,YACPV,KAAwB,EACxBO,QAAW;QAaTP,mBACcA;IAZhB,MAAMS,QAAQT,KAAK,CAACO,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAE,GAAGC,gBAAgB,GAAGL;IAE1C,MAAMD,OACJR,EAAAA,oBAAAA,MAAMM,UAAU,cAAhBN,wCAAAA,iBAAkB,CAACO,SAAS,MAAKI,aAAa,OAAOX,MAAMM,UAAU,CAACC,SAAS,KAAK,WAChFM,YAAUb,qBAAAA,MAAMM,UAAU,cAAhBN,yCAAAA,kBAAkB,CAACO,SAAS,KAAI,QAC1CP,MAAMM,UAAU,CAACC,SAAS;IAGhC,MAAMQ,mBAAmB,OAAOP,SAAS,YAAYK;IACrD,MAAMX,YAA8Ba,mBAAmBD,iBAAiBL;IAExE,OAAO;QAACD;QAAMN;KAAkB;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["resolveShorthand.ts"],"sourcesContent":["import * as slot from '../slot';\nimport type { SlotShorthandValue, UnknownSlotProps } from '../types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n // eslint-disable-next-line deprecation/deprecation\n <P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): P;\n // eslint-disable-next-line deprecation/deprecation\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | P\n | undefined;\n};\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 *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\n// eslint-disable-next-line deprecation/deprecation\nexport const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps> = (value, options) =>\n slot.optional<UnknownSlotProps>(value, {\n ...options,\n renderByDefault: options?.required,\n // elementType as undefined is the way to identify between a slot and a resolveShorthand call\n // in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.\n elementType: undefined!,\n });\n"],"names":["resolveShorthand","value","options","slot","optional","renderByDefault","required","elementType","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgCaA;;;eAAAA;;;;gEAhCS;AAgCf,MAAMA,mBAA+D,CAACC,OAAOC,UAClFC,MAAKC,QAAQ,CAAmBH,OAAO;QACrC,GAAGC,OAAO;QACVG,iBAAiBH,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASI,QAAQ;QAClC,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACf"}
1
+ {"version":3,"sources":["../src/compose/deprecated/resolveShorthand.ts"],"sourcesContent":["import * as slot from '../slot';\nimport type { SlotShorthandValue, UnknownSlotProps } from '../types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n // eslint-disable-next-line deprecation/deprecation\n <P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): P;\n // eslint-disable-next-line deprecation/deprecation\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | P\n | undefined;\n};\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 *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\n// eslint-disable-next-line deprecation/deprecation\nexport const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps> = (value, options) =>\n slot.optional<UnknownSlotProps>(value, {\n ...options,\n renderByDefault: options?.required,\n // elementType as undefined is the way to identify between a slot and a resolveShorthand call\n // in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.\n elementType: undefined!,\n });\n"],"names":["resolveShorthand","value","options","slot","optional","renderByDefault","required","elementType","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgCaA;;;eAAAA;;;;gEAhCS;AAgCf,MAAMA,mBAA+D,CAACC,OAAOC,UAClFC,MAAKC,QAAQ,CAAmBH,OAAO;QACrC,GAAGC,OAAO;QACVG,eAAe,EAAEH,oBAAAA,8BAAAA,QAASI,QAAQ;QAClC,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["getIntrinsicElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '../utils/getNativeElementProps';\nimport type { InferredElementRefType, UnknownSlotProps } from './types';\nimport type { DistributiveOmit } from '../utils/types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype HTMLAttributes = React.HTMLAttributes<any>;\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n *\n * Equivalent to {@link getNativeElementProps}, but more type-safe.\n */\nexport const getIntrinsicElementProps = <\n Props extends UnknownSlotProps,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>(\n /** The slot's default element type (e.g. 'div') */\n tagName: NonNullable<Props['as']>,\n /** The component's props object */\n props: Props & React.RefAttributes<InferredElementRefType<Props>>,\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[],\n) => {\n // eslint-disable-next-line deprecation/deprecation\n return getNativeElementProps<\n DistributiveOmit<Props, Exclude<keyof Props, keyof HTMLAttributes | keyof UnknownSlotProps> | ExcludedPropKeys>\n >(props.as ?? tagName, props, excludedPropNames);\n};\n"],"names":["getIntrinsicElementProps","tagName","props","excludedPropNames","getNativeElementProps","as"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";;;;+BAcaA;;;eAAAA;;;;iEAdU;uCACe;AAa/B,MAAMA,2BAA2B,CAItC,iDAAiD,GACjDC,SACA,iCAAiC,GACjCC,OACA,4DAA4D,GAC5DC;QAKED;IAHF,mDAAmD;IACnD,OAAOE,IAAAA,4CAAAA,EAELF,CAAAA,YAAAA,MAAMG,EAAE,AAAFA,MAAE,QAARH,cAAAA,KAAAA,IAAAA,YAAYD,SAASC,OAAOC;AAChC"}
1
+ {"version":3,"sources":["../src/compose/getIntrinsicElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '../utils/getNativeElementProps';\nimport type { InferredElementRefType, UnknownSlotProps } from './types';\nimport type { DistributiveOmit } from '../utils/types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype HTMLAttributes = React.HTMLAttributes<any>;\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n *\n * Equivalent to {@link getNativeElementProps}, but more type-safe.\n */\nexport const getIntrinsicElementProps = <\n Props extends UnknownSlotProps,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>(\n /** The slot's default element type (e.g. 'div') */\n tagName: NonNullable<Props['as']>,\n /** The component's props object */\n props: Props & React.RefAttributes<InferredElementRefType<Props>>,\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[],\n) => {\n // eslint-disable-next-line deprecation/deprecation\n return getNativeElementProps<\n DistributiveOmit<Props, Exclude<keyof Props, keyof HTMLAttributes | keyof UnknownSlotProps> | ExcludedPropKeys>\n >(props.as ?? tagName, props, excludedPropNames);\n};\n"],"names":["getIntrinsicElementProps","tagName","props","excludedPropNames","getNativeElementProps","as"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";;;;+BAcaA;;;eAAAA;;;;iEAdU;uCACe;AAa/B,MAAMA,2BAA2B,CAItC,iDAAiD,GACjDC,SACA,iCAAiC,GACjCC,OACA,4DAA4D,GAC5DC;QAKED;IAHF,mDAAmD;IACnD,OAAOE,IAAAA,4CAAqB,EAE1BF,CAAAA,YAAAA,MAAMG,EAAE,cAARH,uBAAAA,YAAYD,SAASC,OAAOC;AAChC"}
@@ -2,21 +2,51 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "slot", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ SLOT_ELEMENT_TYPE_SYMBOL: function() {
13
+ return _constants.SLOT_ELEMENT_TYPE_SYMBOL;
14
+ },
15
+ SLOT_RENDER_FUNCTION_SYMBOL: function() {
16
+ return _constants.SLOT_RENDER_FUNCTION_SYMBOL;
17
+ },
18
+ assertSlots: function() {
19
+ return _assertSlots.assertSlots;
20
+ },
21
+ getIntrinsicElementProps: function() {
22
+ return _getIntrinsicElementProps.getIntrinsicElementProps;
23
+ },
24
+ getSlots: function() {
25
+ return _getSlots.getSlots;
26
+ },
27
+ getSlotsNext: function() {
28
+ return _getSlotsNext.getSlotsNext;
29
+ },
30
+ isResolvedShorthand: function() {
31
+ return _isResolvedShorthand.isResolvedShorthand;
32
+ },
33
+ isSlot: function() {
34
+ return _isSlot.isSlot;
35
+ },
36
+ resolveShorthand: function() {
37
+ return _resolveShorthand.resolveShorthand;
38
+ },
39
+ slot: function() {
8
40
  return _slot;
9
41
  }
10
42
  });
11
- const _export_star = require("@swc/helpers/_/_export_star");
12
43
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
44
  const _slot = /*#__PURE__*/ _interop_require_wildcard._(require("./slot"));
14
- _export_star._(require("./types"), exports);
15
- _export_star._(require("./isResolvedShorthand"), exports);
16
- _export_star._(require("./constants"), exports);
17
- _export_star._(require("./isSlot"), exports);
18
- _export_star._(require("./assertSlots"), exports);
19
- _export_star._(require("./getIntrinsicElementProps"), exports);
20
- _export_star._(require("./deprecated/getSlots"), exports);
21
- _export_star._(require("./deprecated/resolveShorthand"), exports);
22
- _export_star._(require("./deprecated/getSlotsNext"), exports);
45
+ const _isResolvedShorthand = require("./isResolvedShorthand");
46
+ const _constants = require("./constants");
47
+ const _isSlot = require("./isSlot");
48
+ const _assertSlots = require("./assertSlots");
49
+ const _getIntrinsicElementProps = require("./getIntrinsicElementProps");
50
+ const _getSlots = require("./deprecated/getSlots");
51
+ const _resolveShorthand = require("./deprecated/resolveShorthand");
52
+ const _getSlotsNext = require("./deprecated/getSlotsNext");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["import * as slot from './slot';\n\nexport * from './types';\nexport * from './isResolvedShorthand';\nexport * from './constants';\nexport * from './isSlot';\nexport * from './assertSlots';\nexport * from './getIntrinsicElementProps';\n\nexport * from './deprecated/getSlots';\nexport * from './deprecated/resolveShorthand';\nexport * from './deprecated/getSlotsNext';\n\nexport { slot };\nexport type { SlotOptions } from './slot';\n"],"names":["slot"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAaSA;;;eAAAA;;;;;gEAba;uBAER;uBACA;uBACA;uBACA;uBACA;uBACA;uBAEA;uBACA;uBACA"}
1
+ {"version":3,"sources":["../src/compose/index.ts"],"sourcesContent":["import * as slot from './slot';\n\nexport type {\n AsIntrinsicElement,\n ComponentProps,\n ComponentState,\n EventData,\n EventHandler,\n ExtractSlotProps,\n ForwardRefComponent,\n InferredElementRefType,\n IsSingleton,\n PropsWithoutChildren,\n PropsWithoutRef,\n Slot,\n SlotClassNames,\n SlotComponentType,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\nexport { isResolvedShorthand } from './isResolvedShorthand';\nexport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nexport { isSlot } from './isSlot';\nexport { assertSlots } from './assertSlots';\nexport { getIntrinsicElementProps } from './getIntrinsicElementProps';\n\n// eslint-disable-next-line deprecation/deprecation\nexport type { ObjectSlotProps, Slots } from './deprecated/getSlots';\n// eslint-disable-next-line deprecation/deprecation\nexport { getSlots } from './deprecated/getSlots';\n// eslint-disable-next-line deprecation/deprecation\nexport type { ResolveShorthandFunction, ResolveShorthandOptions } from './deprecated/resolveShorthand';\n// eslint-disable-next-line deprecation/deprecation\nexport { resolveShorthand } from './deprecated/resolveShorthand';\n// eslint-disable-next-line deprecation/deprecation\nexport { getSlotsNext } from './deprecated/getSlotsNext';\n\nexport { slot };\nexport type { SlotOptions } from './slot';\n"],"names":["SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","assertSlots","getIntrinsicElementProps","getSlots","getSlotsNext","isResolvedShorthand","isSlot","resolveShorthand","slot"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAuBSA,wBAAwB;eAAxBA,mCAAwB;;IAAEC,2BAA2B;eAA3BA,sCAA2B;;IAErDC,WAAW;eAAXA,wBAAW;;IACXC,wBAAwB;eAAxBA,kDAAwB;;IAKxBC,QAAQ;eAARA,kBAAQ;;IAMRC,YAAY;eAAZA,0BAAY;;IAfZC,mBAAmB;eAAnBA,wCAAmB;;IAEnBC,MAAM;eAANA,cAAM;;IAWNC,gBAAgB;eAAhBA,kCAAgB;;IAIhBC,IAAI;eAAJA;;;;gEAvCa;qCAsBc;2BACkC;wBAC/C;6BACK;0CACa;0BAKhB;kCAIQ;8BAEJ"}
@@ -8,7 +8,8 @@ Object.defineProperty(exports, "isResolvedShorthand", {
8
8
  return isResolvedShorthand;
9
9
  }
10
10
  });
11
- const _react = require("react");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
12
13
  function isResolvedShorthand(shorthand) {
13
- return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !/*#__PURE__*/ (0, _react.isValidElement)(shorthand);
14
+ return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !_react.isValidElement(shorthand);
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["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"],"names":["isResolvedShorthand","shorthand","Array","isArray","isValidElement"],"rangeMappings":";;;;;;;;;;;;;","mappings":";;;;+BAiCgBA;;;eAAAA;;;uBAjCe;AAiCxB,SAASA,oBACdC,SAAqB;IAErB,OAAOA,cAAc,QAAQ,OAAOA,cAAc,YAAY,CAACC,MAAMC,OAAO,CAACF,cAAc,eAACG,IAAAA,qBAAAA,EAAeH;AAC7G"}
1
+ {"version":3,"sources":["../src/compose/isResolvedShorthand.ts"],"sourcesContent":["import * as React 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 (\n shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !React.isValidElement(shorthand)\n );\n}\n"],"names":["isResolvedShorthand","shorthand","Array","isArray","React","isValidElement"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BAiCgBA;;;eAAAA;;;;iEAjCO;AAiChB,SAASA,oBACdC,SAAqB;IAErB,OACEA,cAAc,QAAQ,OAAOA,cAAc,YAAY,CAACC,MAAMC,OAAO,CAACF,cAAc,CAACG,OAAMC,cAAc,CAACJ;AAE9G"}
@@ -1 +1 @@
1
- {"version":3,"sources":["isSlot.ts"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { SlotComponentType } from './types';\n\n/**\n * Guard method to ensure a given element is a slot.\n * This is mainly used internally to ensure a slot is being used as a component.\n */\nexport function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props> {\n return Boolean((element as {} | undefined)?.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));\n}\n"],"names":["isSlot","element","Boolean","hasOwnProperty","SLOT_ELEMENT_TYPE_SYMBOL"],"rangeMappings":";;;;;;;;;;;;;","mappings":";;;;+BAOgBA;;;eAAAA;;;2BAPyB;AAOlC,SAASA,OAAyBC,OAAgB;IACvD,OAAOC,QAASD,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAADA,QAA6BE,cAAc,CAACC,mCAAAA;AAC7D"}
1
+ {"version":3,"sources":["../src/compose/isSlot.ts"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { SlotComponentType } from './types';\n\n/**\n * Guard method to ensure a given element is a slot.\n * This is mainly used internally to ensure a slot is being used as a component.\n */\nexport function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props> {\n return Boolean((element as {} | undefined)?.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));\n}\n"],"names":["isSlot","element","Boolean","hasOwnProperty","SLOT_ELEMENT_TYPE_SYMBOL"],"rangeMappings":";;;;;;;;;;;;;","mappings":";;;;+BAOgBA;;;eAAAA;;;2BAPyB;AAOlC,SAASA,OAAyBC,OAAgB;IACvD,OAAOC,QAASD,oBAAAA,8BAAD,AAACA,QAA4BE,cAAc,CAACC,mCAAwB;AACrF"}
@@ -49,7 +49,7 @@ function optional(value, options) {
49
49
  }
50
50
  function resolveShorthand(value) {
51
51
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
- /*#__PURE__*/ _react.isValidElement(value)) {
52
+ _react.isValidElement(value)) {
53
53
  return {
54
54
  children: value
55
55
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["slot.ts"],"sourcesContent":["import type {\n AsIntrinsicElement,\n SlotComponentType,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\nimport * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n\nexport type SlotOptions<Props extends UnknownSlotProps> = {\n elementType:\n | React.ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n defaultProps?: Partial<Props>;\n};\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided.\n */\nexport function always<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined,\n options: SlotOptions<Props>,\n): SlotComponentType<Props> {\n const { defaultProps, elementType } = options;\n\n const props = resolveShorthand(value);\n\n /**\n * Casting is required here as SlotComponentType is a function, not an object.\n * Although SlotComponentType has a function signature, it is still just an object.\n * This is required to make a slot callable (JSX compatible), this is the exact same approach\n * that is used on `@types/react` components\n */\n const propsWithMetadata = {\n ...defaultProps,\n ...props,\n [SLOT_ELEMENT_TYPE_SYMBOL]: elementType,\n } as SlotComponentType<Props>;\n\n if (props && typeof props.children === 'function') {\n propsWithMetadata[SLOT_RENDER_FUNCTION_SYMBOL] = props.children as SlotRenderFunction<Props>;\n propsWithMetadata.children = defaultProps?.children;\n }\n\n return propsWithMetadata;\n}\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided\n * * `renderByDefault` - a boolean that indicates if a slot will be rendered even if it's base value is `undefined`.\n * By default if `props.SLOT_NAME` is `undefined` then `state.SLOT_NAME` becomes `undefined`\n * and nothing will be rendered, but if `renderByDefault = true` then `state.SLOT_NAME` becomes an object\n * with the values provided by `options.defaultProps` (or `{}`). This is useful for cases such as providing a default content\n * in case no shorthand is provided, like the case of the `expandIcon` slot for the `AccordionHeader`\n */\nexport function optional<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined | null,\n options: { renderByDefault?: boolean } & SlotOptions<Props>,\n): SlotComponentType<Props> | undefined {\n if (value === null || (value === undefined && !options.renderByDefault)) {\n return undefined;\n }\n return always(value, options);\n}\n\n/**\n * Helper function that converts a slot shorthand or properties to a slot properties object\n * The main difference between this function and `slot` is that this function does not return the metadata required for a slot to be considered a properly renderable slot, it only converts the value to a slot properties object\n * @param value - the value of the slot, it can be a slot shorthand or a slot properties object\n */\nexport function resolveShorthand<Props extends UnknownSlotProps | null | undefined>(\n value: Props | SlotShorthandValue,\n): Props {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n Array.isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.isValidElement<any>(value)\n ) {\n return { children: value } as Props;\n }\n if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {\n // TODO: would be nice to have a link to slot documentation in this error message\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [slot.${resolveShorthand.name}]:\n A slot got an invalid value \"${value}\" (${typeof value}).\n A valid value for a slot is a slot shorthand or slot properties object.\n Slot shorthands can be strings, numbers, arrays or JSX elements\n `);\n }\n\n return value;\n}\n"],"names":["always","optional","resolveShorthand","value","options","defaultProps","elementType","props","propsWithMetadata","SLOT_ELEMENT_TYPE_SYMBOL","children","SLOT_RENDER_FUNCTION_SYMBOL","undefined","renderByDefault","Array","isArray","React","isValidElement","process","env","NODE_ENV","console","error","name"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAyBgBA,MAAAA;eAAAA;;IAyCAC,QAAAA;eAAAA;;IAeAC,gBAAAA;eAAAA;;;;iEA1EO;2BAC+C;AAiB/D,SAASF,OACdG,KAA6C,EAC7CC,OAA2B;IAE3B,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAE,GAAGF;IAEtC,MAAMG,QAAQL,iBAAiBC;IAE/B;;;;;GAKC,GACD,MAAMK,oBAAoB;QACxB,GAAGH,YAAY;QACf,GAAGE,KAAK;QACR,CAACE,mCAAAA,CAAyB,EAAEH;IAC9B;IAEA,IAAIC,SAAS,OAAOA,MAAMG,QAAQ,KAAK,YAAY;QACjDF,iBAAiB,CAACG,sCAAAA,CAA4B,GAAGJ,MAAMG,QAAQ;QAC/DF,kBAAkBE,QAAQ,GAAGL,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAcK,QAAQ;IACrD;IAEA,OAAOF;AACT;AAeO,SAASP,SACdE,KAAoD,EACpDC,OAA2D;IAE3D,IAAID,UAAU,QAASA,UAAUS,aAAa,CAACR,QAAQS,eAAe,EAAG;QACvE,OAAOD;IACT;IACA,OAAOZ,OAAOG,OAAOC;AACvB;AAOO,SAASF,iBACdC,KAAiC;IAEjC,IACE,OAAOA,UAAU,YACjB,OAAOA,UAAU,YACjBW,MAAMC,OAAO,CAACZ,UACd,8DAA8D;kBAC9Da,OAAMC,cAAc,CAAMd,QAC1B;QACA,OAAO;YAAEO,UAAUP;QAAM;IAC3B;IACA,IAAIA,SAAS,OAAOA,UAAU,YAAYe,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC/E,iFAAiF;QACjF,sCAAsC;QACtCC,QAAQC,KAAK,CAAuB,CAAC,gCACH,EAAEpB,iBAAiBqB,IAAI,CAAC;6BAC3B,EAAEpB,MAAM,GAAG,EAAE,OAAOA,MAAM;;+DAGzD,CAAC;IACH;IAEA,OAAOA;AACT"}
1
+ {"version":3,"sources":["../src/compose/slot.ts"],"sourcesContent":["import type {\n AsIntrinsicElement,\n SlotComponentType,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\nimport * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n\nexport type SlotOptions<Props extends UnknownSlotProps> = {\n elementType:\n | React.ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n defaultProps?: Partial<Props>;\n};\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided.\n */\nexport function always<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined,\n options: SlotOptions<Props>,\n): SlotComponentType<Props> {\n const { defaultProps, elementType } = options;\n\n const props = resolveShorthand(value);\n\n /**\n * Casting is required here as SlotComponentType is a function, not an object.\n * Although SlotComponentType has a function signature, it is still just an object.\n * This is required to make a slot callable (JSX compatible), this is the exact same approach\n * that is used on `@types/react` components\n */\n const propsWithMetadata = {\n ...defaultProps,\n ...props,\n [SLOT_ELEMENT_TYPE_SYMBOL]: elementType,\n } as SlotComponentType<Props>;\n\n if (props && typeof props.children === 'function') {\n propsWithMetadata[SLOT_RENDER_FUNCTION_SYMBOL] = props.children as SlotRenderFunction<Props>;\n propsWithMetadata.children = defaultProps?.children;\n }\n\n return propsWithMetadata;\n}\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided\n * * `renderByDefault` - a boolean that indicates if a slot will be rendered even if it's base value is `undefined`.\n * By default if `props.SLOT_NAME` is `undefined` then `state.SLOT_NAME` becomes `undefined`\n * and nothing will be rendered, but if `renderByDefault = true` then `state.SLOT_NAME` becomes an object\n * with the values provided by `options.defaultProps` (or `{}`). This is useful for cases such as providing a default content\n * in case no shorthand is provided, like the case of the `expandIcon` slot for the `AccordionHeader`\n */\nexport function optional<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined | null,\n options: { renderByDefault?: boolean } & SlotOptions<Props>,\n): SlotComponentType<Props> | undefined {\n if (value === null || (value === undefined && !options.renderByDefault)) {\n return undefined;\n }\n return always(value, options);\n}\n\n/**\n * Helper function that converts a slot shorthand or properties to a slot properties object\n * The main difference between this function and `slot` is that this function does not return the metadata required for a slot to be considered a properly renderable slot, it only converts the value to a slot properties object\n * @param value - the value of the slot, it can be a slot shorthand or a slot properties object\n */\nexport function resolveShorthand<Props extends UnknownSlotProps | null | undefined>(\n value: Props | SlotShorthandValue,\n): Props {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n Array.isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.isValidElement<any>(value)\n ) {\n return { children: value } as Props;\n }\n if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {\n // TODO: would be nice to have a link to slot documentation in this error message\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [slot.${resolveShorthand.name}]:\n A slot got an invalid value \"${value}\" (${typeof value}).\n A valid value for a slot is a slot shorthand or slot properties object.\n Slot shorthands can be strings, numbers, arrays or JSX elements\n `);\n }\n\n return value;\n}\n"],"names":["always","optional","resolveShorthand","value","options","defaultProps","elementType","props","propsWithMetadata","SLOT_ELEMENT_TYPE_SYMBOL","children","SLOT_RENDER_FUNCTION_SYMBOL","undefined","renderByDefault","Array","isArray","React","isValidElement","process","env","NODE_ENV","console","error","name"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAyBgBA,MAAM;eAANA;;IAyCAC,QAAQ;eAARA;;IAeAC,gBAAgB;eAAhBA;;;;iEA1EO;2BAC+C;AAiB/D,SAASF,OACdG,KAA6C,EAC7CC,OAA2B;IAE3B,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAE,GAAGF;IAEtC,MAAMG,QAAQL,iBAAiBC;IAE/B;;;;;GAKC,GACD,MAAMK,oBAAoB;QACxB,GAAGH,YAAY;QACf,GAAGE,KAAK;QACR,CAACE,mCAAwB,CAAC,EAAEH;IAC9B;IAEA,IAAIC,SAAS,OAAOA,MAAMG,QAAQ,KAAK,YAAY;QACjDF,iBAAiB,CAACG,sCAA2B,CAAC,GAAGJ,MAAMG,QAAQ;QAC/DF,kBAAkBE,QAAQ,GAAGL,yBAAAA,mCAAAA,aAAcK,QAAQ;IACrD;IAEA,OAAOF;AACT;AAeO,SAASP,SACdE,KAAoD,EACpDC,OAA2D;IAE3D,IAAID,UAAU,QAASA,UAAUS,aAAa,CAACR,QAAQS,eAAe,EAAG;QACvE,OAAOD;IACT;IACA,OAAOZ,OAAOG,OAAOC;AACvB;AAOO,SAASF,iBACdC,KAAiC;IAEjC,IACE,OAAOA,UAAU,YACjB,OAAOA,UAAU,YACjBW,MAAMC,OAAO,CAACZ,UACd,8DAA8D;IAC9Da,OAAMC,cAAc,CAAMd,QAC1B;QACA,OAAO;YAAEO,UAAUP;QAAM;IAC3B;IACA,IAAIA,SAAS,OAAOA,UAAU,YAAYe,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC/E,iFAAiF;QACjF,sCAAsC;QACtCC,QAAQC,KAAK,CAAuB,CAAC,gCACH,EAAEpB,iBAAiBqB,IAAI,CAAC;6BAC3B,EAAEpB,MAAM,GAAG,EAAE,OAAOA,MAAM;;+DAGzD,CAAC;IACH;IAEA,OAAOA;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nimport { DistributiveOmit, ReplaceNullWithUndefined } from '../utils/types';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, '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> =\n | Props\n | ('children' extends keyof Props ? Extract<SlotShorthandValue, Props['children']> : never);\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?: ('children' extends keyof Props ? 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 * 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 ? DistributiveOmit<P, 'ref'> : 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 ? DistributiveOmit<P, 'children'> : 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 * 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 * Infers the element type from props that are declared using ComponentProps.\n */\nexport type InferredElementRefType<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? Element\n : never\n : never;\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = React.ForwardRefExoticComponent<\n Props & React.RefAttributes<InferredElementRefType<Props>>\n>;\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\n/**\n * A definition of a slot, as a component, very similar to how a React component is declared,\n * but with some additional metadata that is used to determine how to render the slot.\n */\nexport type SlotComponentType<Props> = Props & {\n /**\n * **NOTE**: Slot components are not callable.\n */\n (props: React.PropsWithChildren<{}>): React.ReactElement | null;\n /**\n * @internal\n */\n [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<Props>;\n /**\n * @internal\n */\n [SLOT_ELEMENT_TYPE_SYMBOL]:\n | React.ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n};\n\n/**\n * Data type for event handlers. It makes data a discriminated union, where each object requires `event` and `type` property.\n * - `event` is the specific event type\n * - `type` is a string literal. It serves as a clear identifier of the event type that reflects the component's state when the event occurred.\n * For example, the Tree component's `onNavigation` event handler has different `type` for different key presses: `{ event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowRight } | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowLeft }`.\n * Developers can use the `type` property to identify and filter events of interest.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnOpenChangeData = (\n * | EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\>\n * | EventData\\<'keydown', React.KeyboardEvent\\<MyComponentElement\\>\\>\n * ) & \\{ open: boolean; \\};\n */\nexport type EventData<Type extends string, TEvent> =\n | { type: undefined; event: React.SyntheticEvent | Event }\n | { type: Type; event: TEvent };\n\n/**\n * Type for props that are event handlers.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnSomeEventData = EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\> & \\{ open: boolean; \\};\n * type SomeProps = \\{ onSomeEvent?: EventHandler\\<OnSomeEventData\\>; \\};\n */\nexport type EventHandler<TData extends EventData<string, unknown>> = (\n ev: React.SyntheticEvent | Event,\n data: TData,\n) => void;\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;iEAAuB"}
1
+ {"version":3,"sources":["../src/compose/types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nimport { DistributiveOmit, ReplaceNullWithUndefined } from '../utils/types';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, '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> =\n | Props\n | ('children' extends keyof Props ? Extract<SlotShorthandValue, Props['children']> : never);\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?: ('children' extends keyof Props ? 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 * 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 ? DistributiveOmit<P, 'ref'> : 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 ? DistributiveOmit<P, 'children'> : 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 * 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 * Infers the element type from props that are declared using ComponentProps.\n */\nexport type InferredElementRefType<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? Element\n : never\n : never;\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = React.ForwardRefExoticComponent<\n Props & React.RefAttributes<InferredElementRefType<Props>>\n>;\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\n/**\n * A definition of a slot, as a component, very similar to how a React component is declared,\n * but with some additional metadata that is used to determine how to render the slot.\n */\nexport type SlotComponentType<Props> = Props & {\n /**\n * **NOTE**: Slot components are not callable.\n */\n (props: React.PropsWithChildren<{}>): React.ReactElement | null;\n /**\n * @internal\n */\n [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<Props>;\n /**\n * @internal\n */\n [SLOT_ELEMENT_TYPE_SYMBOL]:\n | React.ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n};\n\n/**\n * Data type for event handlers. It makes data a discriminated union, where each object requires `event` and `type` property.\n * - `event` is the specific event type\n * - `type` is a string literal. It serves as a clear identifier of the event type that reflects the component's state when the event occurred.\n * For example, the Tree component's `onNavigation` event handler has different `type` for different key presses: `{ event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowRight } | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowLeft }`.\n * Developers can use the `type` property to identify and filter events of interest.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnOpenChangeData = (\n * | EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\>\n * | EventData\\<'keydown', React.KeyboardEvent\\<MyComponentElement\\>\\>\n * ) & \\{ open: boolean; \\};\n */\nexport type EventData<Type extends string, TEvent> =\n | { type: undefined; event: React.SyntheticEvent | Event }\n | { type: Type; event: TEvent };\n\n/**\n * Type for props that are event handlers.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnSomeEventData = EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\> & \\{ open: boolean; \\};\n * type SomeProps = \\{ onSomeEvent?: EventHandler\\<OnSomeEventData\\>; \\};\n */\nexport type EventHandler<TData extends EventData<string, unknown>> = (\n ev: React.SyntheticEvent | Event,\n data: TData,\n) => void;\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;iEAAuB"}
@@ -2,5 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./mouseTouchHelpers"), exports);
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ getEventClientCoords: function() {
13
+ return _mouseTouchHelpers.getEventClientCoords;
14
+ },
15
+ isMouseEvent: function() {
16
+ return _mouseTouchHelpers.isMouseEvent;
17
+ },
18
+ isTouchEvent: function() {
19
+ return _mouseTouchHelpers.isTouchEvent;
20
+ }
21
+ });
22
+ const _mouseTouchHelpers = require("./mouseTouchHelpers");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './mouseTouchHelpers';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
1
+ {"version":3,"sources":["../src/events/index.ts"],"sourcesContent":["export type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './mouseTouchHelpers';\nexport { getEventClientCoords, isMouseEvent, isTouchEvent } from './mouseTouchHelpers';\n"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IACSA,oBAAoB;eAApBA,uCAAoB;;IAAEC,YAAY;eAAZA,+BAAY;;IAAEC,YAAY;eAAZA,+BAAY;;;mCAAQ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["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"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent","event","type","startsWith","indexOf","clientX","clientY","touches","process","env","NODE_ENV","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA0BgBA,oBAAAA;eAAAA;;IARAC,YAAAA;eAAAA;;IAPAC,YAAAA;eAAAA;;;;iEAXO;AAWhB,SAASA,aAAaC,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AAC/B;AAKO,SAASJ,aAAaE,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QAAC;QAAS;QAAe;KAAW,CAACC,OAAO,CAACH,MAAMC,IAAI,IAAI,CAAC;AACvG;AAMO,SAASJ,qBAAqBG,KAAwB;IAC3D,IAAIF,aAAaE,QAAQ;QACvB,OAAO;YAAEI,SAASJ,MAAMI,OAAO;YAAEC,SAASL,MAAMK,OAAO;QAAC;IAC1D,OAAO,IAAIN,aAAaC,QAAQ;QAC9B,OAAO;YAAEI,SAASJ,MAAMM,OAAO,CAAC,EAAE,CAACF,OAAO;YAAEC,SAASL,MAAMM,OAAO,CAAC,EAAE,CAACD,OAAO;QAAC;IAChF,OAAO;QACL,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MAAM;QAClB;QACA,OAAO;YAAEN,SAAS;YAAGC,SAAS;QAAE;IAClC;AACF"}
1
+ {"version":3,"sources":["../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"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent","event","type","startsWith","indexOf","clientX","clientY","touches","process","env","NODE_ENV","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA0BgBA,oBAAoB;eAApBA;;IARAC,YAAY;eAAZA;;IAPAC,YAAY;eAAZA;;;;iEAXO;AAWhB,SAASA,aAAaC,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AAC/B;AAKO,SAASJ,aAAaE,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QAAC;QAAS;QAAe;KAAW,CAACC,OAAO,CAACH,MAAMC,IAAI,IAAI,CAAC;AACvG;AAMO,SAASJ,qBAAqBG,KAAwB;IAC3D,IAAIF,aAAaE,QAAQ;QACvB,OAAO;YAAEI,SAASJ,MAAMI,OAAO;YAAEC,SAASL,MAAMK,OAAO;QAAC;IAC1D,OAAO,IAAIN,aAAaC,QAAQ;QAC9B,OAAO;YAAEI,SAASJ,MAAMM,OAAO,CAAC,EAAE,CAACF,OAAO;YAAEC,SAASL,MAAMM,OAAO,CAAC,EAAE,CAACD,OAAO;QAAC;IAChF,OAAO;QACL,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MAAM;QAClB;QACA,OAAO;YAAEN,SAAS;YAAGC,SAAS;QAAE;IAClC;AACF"}