@fluentui/react-utilities 9.7.4 → 9.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,30 @@
2
2
  "name": "@fluentui/react-utilities",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 12 Apr 2023 09:28:17 GMT",
5
+ "date": "Mon, 17 Apr 2023 17:50:12 GMT",
6
+ "tag": "@fluentui/react-utilities_v9.8.0",
7
+ "version": "9.8.0",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "behowell@microsoft.com",
12
+ "package": "@fluentui/react-utilities",
13
+ "commit": "c156e7682a89d7766bed3c0b9f231dc2e0a2058b",
14
+ "comment": "fix: Fix slot render functions"
15
+ }
16
+ ],
17
+ "minor": [
18
+ {
19
+ "author": "bernardo.sunderhus@gmail.com",
20
+ "package": "@fluentui/react-utilities",
21
+ "commit": "97af91aa7684bbfe149ace1b21b75fb7c04128a2",
22
+ "comment": "feat: ensure compatibility with custom JSX pragma"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "date": "Wed, 12 Apr 2023 09:31:45 GMT",
6
29
  "tag": "@fluentui/react-utilities_v9.7.4",
7
30
  "version": "9.7.4",
8
31
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,25 @@
1
1
  # Change Log - @fluentui/react-utilities
2
2
 
3
- This log was last generated on Wed, 12 Apr 2023 09:28:17 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 17 Apr 2023 17:50:12 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.8.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.8.0)
8
+
9
+ Mon, 17 Apr 2023 17:50:12 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.7.4..@fluentui/react-utilities_v9.8.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: ensure compatibility with custom JSX pragma ([PR #27472](https://github.com/microsoft/fluentui/pull/27472) by bernardo.sunderhus@gmail.com)
15
+
16
+ ### Patches
17
+
18
+ - fix: Fix slot render functions ([PR #27561](https://github.com/microsoft/fluentui/pull/27561) by behowell@microsoft.com)
19
+
7
20
  ## [9.7.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.7.4)
8
21
 
9
- Wed, 12 Apr 2023 09:28:17 GMT
22
+ Wed, 12 Apr 2023 09:31:45 GMT
10
23
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.7.3..@fluentui/react-utilities_v9.7.4)
11
24
 
12
25
  ### Patches
package/dist/index.d.ts CHANGED
@@ -155,6 +155,14 @@ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentStat
155
155
  slotProps: ObjectSlotProps<R>;
156
156
  };
157
157
 
158
+ /**
159
+ * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma
160
+ */
161
+ export declare function getSlotsNext<R extends SlotPropsRecord>(state: ComponentState<R>): {
162
+ slots: Slots<R>;
163
+ slotProps: ObjectSlotProps<R>;
164
+ };
165
+
158
166
  /**
159
167
  * @internal
160
168
  * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
@@ -435,6 +443,12 @@ export declare type Slot<Type extends keyof JSX.IntrinsicElements | React_2.Comp
435
443
  } & WithSlotRenderFunction<IntrinsicElementProps<As>>;
436
444
  }[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
437
445
 
446
+ /**
447
+ * @internal
448
+ * Internal reference for the render function
449
+ */
450
+ export declare const SLOT_RENDER_FUNCTION_SYMBOL: unique symbol;
451
+
438
452
  /**
439
453
  * Helper type to correctly define the slot class names object.
440
454
  */
@@ -494,7 +508,7 @@ declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never)
494
508
  * This should ONLY be used in type templates as in `extends UnknownSlotProps`;
495
509
  * it shouldn't be used as the type of a slot.
496
510
  */
497
- declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
511
+ export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
498
512
  as?: keyof JSX.IntrinsicElements;
499
513
  };
500
514
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @internal
3
+ * Internal reference for the render function
4
+ */export const SLOT_RENDER_FUNCTION_SYMBOL = /*#__PURE__*/Symbol('fui.slotRenderFunction');
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol"],"sources":["../../src/compose/constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');\n"],"mappings":"AAAA;;;GAIA,OAAO,MAAMA,2BAAA,gBAA8BC,MAAA,CAAO"}
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { omit } from '../utils/omit';
3
+ import { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';
3
4
  /**
4
5
  * Given the state and an array of slot names, will break out `slots` and `slotProps`
5
6
  * collections.
@@ -32,24 +33,26 @@ export function getSlots(state) {
32
33
  };
33
34
  }
34
35
  function getSlot(state, slotName) {
35
- var _state_components, _state_components1, _state_slotName;
36
- if (state[slotName] === undefined) {
36
+ var _state_components, _state_components1;
37
+ const props = state[slotName];
38
+ if (props === undefined) {
37
39
  return [null, undefined];
38
40
  }
39
41
  const {
40
42
  children,
41
43
  as: asProp,
44
+ [SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction,
42
45
  ...rest
43
- } = state[slotName];
46
+ } = props;
44
47
  const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
45
- if (typeof children === 'function') {
46
- const render = children;
48
+ if (renderFunction || typeof children === 'function') {
49
+ const render = renderFunction || children;
47
50
  return [React.Fragment, {
48
51
  children: render(slot, rest)
49
52
  }];
50
53
  }
51
- const shouldOmitAsProp = typeof slot === 'string' && ((_state_slotName = state[slotName]) === null || _state_slotName === void 0 ? void 0 : _state_slotName.as);
52
- const slotProps = shouldOmitAsProp ? omit(state[slotName], ['as']) : state[slotName];
54
+ const shouldOmitAsProp = typeof slot === 'string' && asProp;
55
+ const slotProps = shouldOmitAsProp ? omit(props, ['as']) : props;
53
56
  return [slot, slotProps];
54
57
  }
55
58
  //# sourceMappingURL=getSlots.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","omit","getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","_state_components","_state_components1","_state_slotName","undefined","children","as","asProp","rest","render","Fragment","shouldOmitAsProp"],"sources":["../../src/compose/getSlots.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]> // 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 * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (\n state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n {\n children: render(slot, rest as Omit<R[K], 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,SAASC,IAAI,QAAQ;AA6BrB;;;;;;;;;;;;;;;;;AAiBA,OAAO,SAASC,SACdC,KAAwB,EAIxB;EACA,MAAMC,KAAA,GAAQ,CAAC;EACf,MAAMC,SAAA,GAAY,CAAC;EAEnB,MAAMC,SAAA,GAAyBC,MAAA,CAAOC,IAAI,CAACL,KAAA,CAAMM,UAAU;EAC3D,KAAK,MAAMC,QAAA,IAAYJ,SAAA,EAAW;IAChC,MAAM,CAACK,IAAA,EAAMC,KAAA,CAAM,GAAGC,OAAA,CAAQV,KAAA,EAAOO,QAAA;IACrCN,KAAK,CAACM,QAAA,CAAS,GAAGC,IAAA;IAClBN,SAAS,CAACK,QAAA,CAAS,GAAGE,KAAA;EACxB;EACA,OAAO;IAAER,KAAA;IAAOC,SAAA,EAAWA;EAA2C;AACxE;AAEA,SAASQ,QACPV,KAAwB,EACxBO,QAAW,EACsC;MAO/CI,iBAAA,EACcC,kBAAA,EAcqCC,eAAA;EArBrD,IAAIb,KAAK,CAACO,QAAA,CAAS,KAAKO,SAAA,EAAW;IACjC,OAAO,CAAC,IAAI,EAAEA,SAAA,CAAkB;EAClC;EACA,MAAM;IAAEC,QAAA;IAAUC,EAAA,EAAIC,MAAA;IAAQ,GAAGC;EAAA,CAAM,GAAGlB,KAAK,CAACO,QAAA,CAAS;EAEzD,MAAMC,IAAA,GACJ,EAAAG,iBAAA,GAAAX,KAAA,CAAMM,UAAU,cAAhBK,iBAAA,uBAAAA,iBAAkB,CAACJ,QAAA,CAAS,MAAKO,SAAA,IAAa,OAAOd,KAAA,CAAMM,UAAU,CAACC,QAAA,CAAS,KAAK,WAChFU,MAAA,KAAU,CAAAL,kBAAA,GAAAZ,KAAA,CAAMM,UAAU,cAAhBM,kBAAA,uBAAAA,kBAAkB,CAACL,QAAA,CAAS,CAAD,IAAK,QAC1CP,KAAA,CAAMM,UAAU,CAACC,QAAA,CAAS;EAGhC,IAAI,OAAOQ,QAAA,KAAa,YAAY;IAClC,MAAMI,MAAA,GAASJ,QAAA;IACf,OAAO,CACLlB,KAAA,CAAMuB,QAAQ,EACd;MACEL,QAAA,EAAUI,MAAA,CAAOX,IAAA,EAAMU,IAAA;IACzB,EACD;EACH;EAEA,MAAMG,gBAAA,GAAmB,OAAOb,IAAA,KAAS,aAAY,CAAAK,eAAA,GAAAb,KAAK,CAACO,QAAA,CAAS,cAAfM,eAAA,uBAAAA,eAAA,CAAiBG,EAAE,CAAD;EACvE,MAAMd,SAAA,GAAamB,gBAAA,GAAmBvB,IAAA,CAAKE,KAAK,CAACO,QAAA,CAAS,EAAG,CAAC,KAAK,IAAIP,KAAK,CAACO,QAAA,CAAS;EAEtF,OAAO,CAACC,IAAA,EAAMN,SAAA,CAAU;AAC1B"}
1
+ {"version":3,"names":["React","omit","SLOT_RENDER_FUNCTION_SYMBOL","getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","_state_components","_state_components1","undefined","children","as","asProp","renderFunction","rest","render","Fragment","shouldOmitAsProp"],"sources":["../../src/compose/getSlots.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n UnknownSlotProps,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\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 * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n const {\n children,\n as: asProp,\n [SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction,\n ...rest\n } = props as typeof props & { [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<R[K]> };\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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,SAASC,IAAI,QAAQ;AACrB,SAASC,2BAA2B,QAAQ;AA8B5C;;;;;;;;;;;;;;;;;AAiBA,OAAO,SAASC,SACdC,KAAwB,EAIxB;EACA,MAAMC,KAAA,GAAQ,CAAC;EACf,MAAMC,SAAA,GAAY,CAAC;EAEnB,MAAMC,SAAA,GAAyBC,MAAA,CAAOC,IAAI,CAACL,KAAA,CAAMM,UAAU;EAC3D,KAAK,MAAMC,QAAA,IAAYJ,SAAA,EAAW;IAChC,MAAM,CAACK,IAAA,EAAMC,KAAA,CAAM,GAAGC,OAAA,CAAQV,KAAA,EAAOO,QAAA;IACrCN,KAAK,CAACM,QAAA,CAAS,GAAGC,IAAA;IAClBN,SAAS,CAACK,QAAA,CAAS,GAAGE,KAAA;EACxB;EACA,OAAO;IAAER,KAAA;IAAOC,SAAA,EAAWA;EAA2C;AACxE;AAEA,SAASQ,QACPV,KAAwB,EACxBO,QAAW,EACsC;MAe/CI,iBAAA,EACcC,kBAAA;EAfhB,MAAMH,KAAA,GAAQT,KAAK,CAACO,QAAA,CAAS;EAE7B,IAAIE,KAAA,KAAUI,SAAA,EAAW;IACvB,OAAO,CAAC,IAAI,EAAEA,SAAA,CAAkB;EAClC;EAEA,MAAM;IACJC,QAAA;IACAC,EAAA,EAAIC,MAAA;IACJ,CAAClB,2BAAA,GAA8BmB,cAAA;IAC/B,GAAGC;EAAA,CACJ,GAAGT,KAAA;EAEJ,MAAMD,IAAA,GACJ,EAAAG,iBAAA,GAAAX,KAAA,CAAMM,UAAU,cAAhBK,iBAAA,uBAAAA,iBAAkB,CAACJ,QAAA,CAAS,MAAKM,SAAA,IAAa,OAAOb,KAAA,CAAMM,UAAU,CAACC,QAAA,CAAS,KAAK,WAChFS,MAAA,KAAU,CAAAJ,kBAAA,GAAAZ,KAAA,CAAMM,UAAU,cAAhBM,kBAAA,uBAAAA,kBAAkB,CAACL,QAAA,CAAS,CAAD,IAAK,QAC1CP,KAAA,CAAMM,UAAU,CAACC,QAAA,CAAS;EAGhC,IAAIU,cAAA,IAAkB,OAAOH,QAAA,KAAa,YAAY;IACpD,MAAMK,MAAA,GAASF,cAAA,IAAmBH,QAAA;IAClC,OAAO,CACLlB,KAAA,CAAMwB,QAAQ,EACd;MACEN,QAAA,EAAUK,MAAA,CAAOX,IAAA,EAAMU,IAAA;IACzB,EACD;EACH;EAEA,MAAMG,gBAAA,GAAmB,OAAOb,IAAA,KAAS,YAAYQ,MAAA;EACrD,MAAMd,SAAA,GAAamB,gBAAA,GAAmBxB,IAAA,CAAKY,KAAA,EAAO,CAAC,KAAK,IAAKA,KAA0B;EACvF,OAAO,CAACD,IAAA,EAAMN,SAAA,CAAU;AAC1B"}
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma
4
+ */
5
+ export function getSlotsNext(state) {
6
+ const slots = {};
7
+ const slotProps = {};
8
+ const slotNames = Object.keys(state.components);
9
+ for (const slotName of slotNames) {
10
+ const [slot, props] = getSlotNext(state, slotName);
11
+ slots[slotName] = slot;
12
+ slotProps[slotName] = props;
13
+ }
14
+ return {
15
+ slots,
16
+ slotProps: slotProps
17
+ };
18
+ }
19
+ function getSlotNext(state, slotName) {
20
+ var _state_components, _state_components1;
21
+ const props = state[slotName];
22
+ if (props === undefined) {
23
+ return [null, undefined];
24
+ }
25
+ const {
26
+ as: asProp,
27
+ ...propsWithoutAs
28
+ } = props;
29
+ const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
30
+ const shouldOmitAsProp = typeof slot === 'string' && asProp;
31
+ const slotProps = shouldOmitAsProp ? propsWithoutAs : props;
32
+ return [slot, slotProps];
33
+ }
34
+ //# sourceMappingURL=getSlotsNext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","getSlotsNext","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","_state_components","_state_components1","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"sources":["../../src/compose/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 */\nexport function getSlotsNext<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlotNext(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction 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 const { as: asProp, ...propsWithoutAs } = 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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIvB;;;AAGA,OAAO,SAASC,aACdC,KAAwB,EAIxB;EACA,MAAMC,KAAA,GAAQ,CAAC;EACf,MAAMC,SAAA,GAAY,CAAC;EAEnB,MAAMC,SAAA,GAAyBC,MAAA,CAAOC,IAAI,CAACL,KAAA,CAAMM,UAAU;EAC3D,KAAK,MAAMC,QAAA,IAAYJ,SAAA,EAAW;IAChC,MAAM,CAACK,IAAA,EAAMC,KAAA,CAAM,GAAGC,WAAA,CAAYV,KAAA,EAAOO,QAAA;IACzCN,KAAK,CAACM,QAAA,CAAS,GAAGC,IAAA;IAClBN,SAAS,CAACK,QAAA,CAAS,GAAGE,KAAA;EACxB;EACA,OAAO;IAAER,KAAA;IAAOC,SAAA,EAAWA;EAA2C;AACxE;AAEA,SAASQ,YACPV,KAAwB,EACxBO,QAAW,EACsC;MAS/CI,iBAAA,EACcC,kBAAA;EAThB,MAAMH,KAAA,GAAQT,KAAK,CAACO,QAAA,CAAS;EAE7B,IAAIE,KAAA,KAAUI,SAAA,EAAW;IACvB,OAAO,CAAC,IAAI,EAAEA,SAAA,CAAkB;EAClC;EACA,MAAM;IAAEC,EAAA,EAAIC,MAAA;IAAQ,GAAGC;EAAA,CAAgB,GAAGP,KAAA;EAE1C,MAAMD,IAAA,GACJ,EAAAG,iBAAA,GAAAX,KAAA,CAAMM,UAAU,cAAhBK,iBAAA,uBAAAA,iBAAkB,CAACJ,QAAA,CAAS,MAAKM,SAAA,IAAa,OAAOb,KAAA,CAAMM,UAAU,CAACC,QAAA,CAAS,KAAK,WAChFQ,MAAA,KAAU,CAAAH,kBAAA,GAAAZ,KAAA,CAAMM,UAAU,cAAhBM,kBAAA,uBAAAA,kBAAkB,CAACL,QAAA,CAAS,CAAD,IAAK,QAC1CP,KAAA,CAAMM,UAAU,CAACC,QAAA,CAAS;EAGhC,MAAMU,gBAAA,GAAmB,OAAOT,IAAA,KAAS,YAAYO,MAAA;EACrD,MAAMb,SAAA,GAA8Be,gBAAA,GAAmBD,cAAA,GAAiBP,KAAK;EAE7E,OAAO,CAACD,IAAA,EAAMN,SAAA,CAAkB;AAClC"}
@@ -2,4 +2,6 @@ export * from './getSlots';
2
2
  export * from './resolveShorthand';
3
3
  export * from './types';
4
4
  export * from './isResolvedShorthand';
5
+ export * from './constants';
6
+ export * from './getSlotsNext';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/compose/index.ts"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
1
+ {"version":3,"names":[],"sources":["../../src/compose/index.ts"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\nexport * from './constants';\nexport * from './getSlotsNext';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
@@ -1,4 +1,5 @@
1
1
  import { isValidElement } from 'react';
2
+ import { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';
2
3
  /**
3
4
  * Resolves shorthands into slot props, to ensure normalization of the signature
4
5
  * being passed down to getSlots method
@@ -14,16 +15,20 @@ export const resolveShorthand = (value, options) => {
14
15
  return undefined;
15
16
  }
16
17
  let resolvedShorthand = {};
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
19
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/isValidElement(value)) {
18
20
  resolvedShorthand.children = value;
19
21
  } else if (typeof value === 'object') {
20
- resolvedShorthand = {
21
- ...value
22
- };
22
+ resolvedShorthand = value;
23
23
  }
24
- return defaultProps ? {
24
+ resolvedShorthand = {
25
25
  ...defaultProps,
26
26
  ...resolvedShorthand
27
- } : resolvedShorthand;
27
+ };
28
+ if (typeof resolvedShorthand.children === 'function') {
29
+ resolvedShorthand[SLOT_RENDER_FUNCTION_SYMBOL] = resolvedShorthand.children;
30
+ resolvedShorthand.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;
31
+ }
32
+ return resolvedShorthand;
28
33
  };
29
34
  //# sourceMappingURL=resolveShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isValidElement","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","children"],"sources":["../../src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): P;\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | P\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = { ...value };\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAc/B;;;;;;AAMA,OAAO,MAAMC,gBAAA,GAA6CA,CAACC,KAAA,EAAOC,OAAA,KAAY;EAC5E,MAAM;IAAEC,QAAA,GAAW,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAA,IAAW,CAAC;EACvD,IAAID,KAAA,KAAU,IAAI,IAAKA,KAAA,KAAUI,SAAA,IAAa,CAACF,QAAA,EAAW;IACxD,OAAOE,SAAA;EACT;EAEA,IAAIC,iBAAA,GAAoB,CAAC;EAEzB,IAAI,OAAOL,KAAA,KAAU,YAAY,OAAOA,KAAA,KAAU,YAAYM,KAAA,CAAMC,OAAO,CAACP,KAAA,kBAAUF,cAAA,CAAeE,KAAA,GAAQ;IAC3GK,iBAAA,CAAkBG,QAAQ,GAAGR,KAAA;EAC/B,OAAO,IAAI,OAAOA,KAAA,KAAU,UAAU;IACpCK,iBAAA,GAAoB;MAAE,GAAGL;IAAM;EACjC;EAEA,OAAOG,YAAA,GAAe;IAAE,GAAGA,YAAY;IAAE,GAAGE;EAAkB,IAAIA,iBAAiB;AACrF"}
1
+ {"version":3,"names":["isValidElement","SLOT_RENDER_FUNCTION_SYMBOL","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","children"],"sources":["../../src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { SlotRenderFunction, SlotShorthandValue, UnknownSlotProps } from './types';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): P;\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | P\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand: UnknownSlotProps & {\n [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<UnknownSlotProps>;\n } = {};\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement<any>(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = value;\n }\n\n resolvedShorthand = {\n ...defaultProps,\n ...resolvedShorthand,\n };\n\n if (typeof resolvedShorthand.children === 'function') {\n resolvedShorthand[SLOT_RENDER_FUNCTION_SYMBOL] = resolvedShorthand.children as SlotRenderFunction<UnknownSlotProps>;\n resolvedShorthand.children = defaultProps?.children;\n }\n\n return resolvedShorthand;\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAE/B,SAASC,2BAA2B,QAAQ;AAa5C;;;;;;AAMA,OAAO,MAAMC,gBAAA,GAA6CA,CAACC,KAAA,EAAOC,OAAA,KAAY;EAC5E,MAAM;IAAEC,QAAA,GAAW,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAA,IAAW,CAAC;EACvD,IAAID,KAAA,KAAU,IAAI,IAAKA,KAAA,KAAUI,SAAA,IAAa,CAACF,QAAA,EAAW;IACxD,OAAOE,SAAA;EACT;EAEA,IAAIC,iBAAA,GAEA,CAAC;EAEL;EACA,IAAI,OAAOL,KAAA,KAAU,YAAY,OAAOA,KAAA,KAAU,YAAYM,KAAA,CAAMC,OAAO,CAACP,KAAA,kBAAUH,cAAA,CAAoBG,KAAA,GAAQ;IAChHK,iBAAA,CAAkBG,QAAQ,GAAGR,KAAA;EAC/B,OAAO,IAAI,OAAOA,KAAA,KAAU,UAAU;IACpCK,iBAAA,GAAoBL,KAAA;EACtB;EAEAK,iBAAA,GAAoB;IAClB,GAAGF,YAAY;IACf,GAAGE;EACL;EAEA,IAAI,OAAOA,iBAAA,CAAkBG,QAAQ,KAAK,YAAY;IACpDH,iBAAiB,CAACP,2BAAA,CAA4B,GAAGO,iBAAA,CAAkBG,QAAQ;IAC3EH,iBAAA,CAAkBG,QAAQ,GAAGL,YAAA,aAAAA,YAAA,uBAAAA,YAAA,CAAcK,QAAQ;EACrD;EAEA,OAAOH,iBAAA;AACT"}
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';
1
+ export { getSlots, getSlotsNext, resolveShorthand, isResolvedShorthand, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';
2
2
  export { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';
3
3
  export { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';
4
4
  export { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit } from './utils/index';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["getSlots","resolveShorthand","isResolvedShorthand","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"sources":["../src/index.ts"],"sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,mBAAmB,QAAQ;AAgBhE,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL;AAGP,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ;AAEjD,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,QACC;AAEP,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ;AAQ9E,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ"}
1
+ {"version":3,"names":["getSlots","getSlotsNext","resolveShorthand","isResolvedShorthand","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"sources":["../src/index.ts"],"sourcesContent":["export {\n getSlots,\n getSlotsNext,\n resolveShorthand,\n isResolvedShorthand,\n SLOT_RENDER_FUNCTION_SYMBOL,\n} from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,YAAY,EACZC,gBAAgB,EAChBC,mBAAmB,EACnBC,2BAA2B,QACtB;AAiBP,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL;AAGP,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ;AAEjD,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,QACC;AAEP,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ;AAQ9E,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @internal
3
+ * Internal reference for the render function
4
+ */ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "SLOT_RENDER_FUNCTION_SYMBOL", {
9
+ enumerable: true,
10
+ get: ()=>SLOT_RENDER_FUNCTION_SYMBOL
11
+ });
12
+ const SLOT_RENDER_FUNCTION_SYMBOL = /*#__PURE__*/ Symbol('fui.slotRenderFunction'); //# sourceMappingURL=constants.js.map
13
+
14
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../lib/compose/constants.js"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */export const SLOT_RENDER_FUNCTION_SYMBOL = /*#__PURE__*/Symbol('fui.slotRenderFunction');\n//# sourceMappingURL=constants.js.map"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol"],"mappings":"AAAA;;;CAGC;;;;+BAAeA;;aAAAA;;AAAN,MAAMA,8BAA8B,WAAW,GAAEC,OAAO,2BAClE,qCAAqC"}
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "getSlots", {
9
9
  const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
10
  const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
11
  const _omit = require("../utils/omit");
12
+ const _constants = require("./constants");
12
13
  function getSlots(state) {
13
14
  const slots = {};
14
15
  const slotProps = {};
@@ -24,17 +25,18 @@ function getSlots(state) {
24
25
  };
25
26
  }
26
27
  function getSlot(state, slotName) {
27
- var _state_components, _state_components1, _state_slotName;
28
- if (state[slotName] === undefined) {
28
+ var _state_components, _state_components1;
29
+ const props = state[slotName];
30
+ if (props === undefined) {
29
31
  return [
30
32
  null,
31
33
  undefined
32
34
  ];
33
35
  }
34
- const { children , as: asProp , ...rest } = state[slotName];
36
+ const { children , as: asProp , [_constants.SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction , ...rest } = props;
35
37
  const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
36
- if (typeof children === 'function') {
37
- const render = children;
38
+ if (renderFunction || typeof children === 'function') {
39
+ const render = renderFunction || children;
38
40
  return [
39
41
  _react.Fragment,
40
42
  {
@@ -42,10 +44,10 @@ function getSlot(state, slotName) {
42
44
  }
43
45
  ];
44
46
  }
45
- const shouldOmitAsProp = typeof slot === 'string' && ((_state_slotName = state[slotName]) === null || _state_slotName === void 0 ? void 0 : _state_slotName.as);
46
- const slotProps = shouldOmitAsProp ? (0, _omit.omit)(state[slotName], [
47
+ const shouldOmitAsProp = typeof slot === 'string' && asProp;
48
+ const slotProps = shouldOmitAsProp ? (0, _omit.omit)(props, [
47
49
  'as'
48
- ]) : state[slotName];
50
+ ]) : props;
49
51
  return [
50
52
  slot,
51
53
  slotProps
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/compose/getSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../utils/omit';\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots(state) {\n const slots = {};\n const slotProps = {};\n const slotNames = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot;\n slotProps[slotName] = props;\n }\n return {\n slots,\n slotProps: slotProps\n };\n}\nfunction getSlot(state, slotName) {\n var _state_components, _state_components1, _state_slotName;\n if (state[slotName] === undefined) {\n return [null, undefined];\n }\n const {\n children,\n as: asProp,\n ...rest\n } = state[slotName];\n const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];\n if (typeof children === 'function') {\n const render = children;\n return [React.Fragment, {\n children: render(slot, rest)\n }];\n }\n const shouldOmitAsProp = typeof slot === 'string' && ((_state_slotName = state[slotName]) === null || _state_slotName === void 0 ? void 0 : _state_slotName.as);\n const slotProps = shouldOmitAsProp ? omit(state[slotName], ['as']) : state[slotName];\n return [slot, slotProps];\n}\n//# sourceMappingURL=getSlots.js.map"],"names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","_state_components","_state_components1","_state_slotName","undefined","children","as","asProp","rest","render","React","Fragment","shouldOmitAsProp","omit"],"mappings":";;;;+BAmBgBA;;aAAAA;;;6DAnBO;sBACF;AAkBd,SAASA,SAASC,KAAK,EAAE;IAC9B,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IACnB,MAAMC,YAAYC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC9C,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,OAAOO;QACrCN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,OAAO;QACLR;QACAC,WAAWA;IACb;AACF;AACA,SAASQ,QAAQV,KAAK,EAAEO,QAAQ,EAAE;IAChC,IAAII,mBAAmBC,oBAAoBC;IAC3C,IAAIb,KAAK,CAACO,SAAS,KAAKO,WAAW;QACjC,OAAO;YAAC,IAAI;YAAEA;SAAU;IAC1B,CAAC;IACD,MAAM,EACJC,SAAQ,EACRC,IAAIC,OAAM,EACV,GAAGC,MACJ,GAAGlB,KAAK,CAACO,SAAS;IACnB,MAAMC,OAAO,AAAC,CAAA,AAACG,CAAAA,oBAAoBX,MAAMM,UAAU,AAAD,MAAO,IAAI,IAAIK,sBAAsB,KAAK,IAAI,KAAK,IAAIA,iBAAiB,CAACJ,SAAS,AAAD,MAAOO,aAAa,OAAOd,MAAMM,UAAU,CAACC,SAAS,KAAK,WAAWU,UAAW,CAAA,AAACL,CAAAA,qBAAqBZ,MAAMM,UAAU,AAAD,MAAO,IAAI,IAAIM,uBAAuB,KAAK,IAAI,KAAK,IAAIA,kBAAkB,CAACL,SAAS,AAAD,KAAM,QAAQP,MAAMM,UAAU,CAACC,SAAS;IACnX,IAAI,OAAOQ,aAAa,YAAY;QAClC,MAAMI,SAASJ;QACf,OAAO;YAACK,OAAMC,QAAQ;YAAE;gBACtBN,UAAUI,OAAOX,MAAMU;YACzB;SAAE;IACJ,CAAC;IACD,MAAMI,mBAAmB,OAAOd,SAAS,YAAa,CAAA,AAACK,CAAAA,kBAAkBb,KAAK,CAACO,SAAS,AAAD,MAAO,IAAI,IAAIM,oBAAoB,KAAK,IAAI,KAAK,IAAIA,gBAAgBG,EAAE,AAAD;IAC7J,MAAMd,YAAYoB,mBAAmBC,IAAAA,UAAI,EAACvB,KAAK,CAACO,SAAS,EAAE;QAAC;KAAK,IAAIP,KAAK,CAACO,SAAS;IACpF,OAAO;QAACC;QAAMN;KAAU;AAC1B,EACA,oCAAoC"}
1
+ {"version":3,"sources":["../../lib/compose/getSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../utils/omit';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots(state) {\n const slots = {};\n const slotProps = {};\n const slotNames = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot;\n slotProps[slotName] = props;\n }\n return {\n slots,\n slotProps: slotProps\n };\n}\nfunction getSlot(state, slotName) {\n var _state_components, _state_components1;\n const props = state[slotName];\n if (props === undefined) {\n return [null, undefined];\n }\n const {\n children,\n as: asProp,\n [SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction,\n ...rest\n } = props;\n const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];\n if (renderFunction || typeof children === 'function') {\n const render = renderFunction || children;\n return [React.Fragment, {\n children: render(slot, rest)\n }];\n }\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps = shouldOmitAsProp ? omit(props, ['as']) : props;\n return [slot, slotProps];\n}\n//# sourceMappingURL=getSlots.js.map"],"names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","_state_components","_state_components1","undefined","children","as","asProp","SLOT_RENDER_FUNCTION_SYMBOL","renderFunction","rest","render","React","Fragment","shouldOmitAsProp","omit"],"mappings":";;;;+BAoBgBA;;aAAAA;;;6DApBO;sBACF;2BACuB;AAkBrC,SAASA,SAASC,KAAK,EAAE;IAC9B,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IACnB,MAAMC,YAAYC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC9C,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,OAAOO;QACrCN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,OAAO;QACLR;QACAC,WAAWA;IACb;AACF;AACA,SAASQ,QAAQV,KAAK,EAAEO,QAAQ,EAAE;IAChC,IAAII,mBAAmBC;IACvB,MAAMH,QAAQT,KAAK,CAACO,SAAS;IAC7B,IAAIE,UAAUI,WAAW;QACvB,OAAO;YAAC,IAAI;YAAEA;SAAU;IAC1B,CAAC;IACD,MAAM,EACJC,SAAQ,EACRC,IAAIC,OAAM,EACV,CAACC,sCAA2B,CAAC,EAAEC,eAAc,EAC7C,GAAGC,MACJ,GAAGV;IACJ,MAAMD,OAAO,AAAC,CAAA,AAACG,CAAAA,oBAAoBX,MAAMM,UAAU,AAAD,MAAO,IAAI,IAAIK,sBAAsB,KAAK,IAAI,KAAK,IAAIA,iBAAiB,CAACJ,SAAS,AAAD,MAAOM,aAAa,OAAOb,MAAMM,UAAU,CAACC,SAAS,KAAK,WAAWS,UAAW,CAAA,AAACJ,CAAAA,qBAAqBZ,MAAMM,UAAU,AAAD,MAAO,IAAI,IAAIM,uBAAuB,KAAK,IAAI,KAAK,IAAIA,kBAAkB,CAACL,SAAS,AAAD,KAAM,QAAQP,MAAMM,UAAU,CAACC,SAAS;IACnX,IAAIW,kBAAkB,OAAOJ,aAAa,YAAY;QACpD,MAAMM,SAASF,kBAAkBJ;QACjC,OAAO;YAACO,OAAMC,QAAQ;YAAE;gBACtBR,UAAUM,OAAOZ,MAAMW;YACzB;SAAE;IACJ,CAAC;IACD,MAAMI,mBAAmB,OAAOf,SAAS,YAAYQ;IACrD,MAAMd,YAAYqB,mBAAmBC,IAAAA,UAAI,EAACf,OAAO;QAAC;KAAK,IAAIA,KAAK;IAChE,OAAO;QAACD;QAAMN;KAAU;AAC1B,EACA,oCAAoC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getSlotsNext", {
6
+ enumerable: true,
7
+ get: ()=>getSlotsNext
8
+ });
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ function getSlotsNext(state) {
12
+ const slots = {};
13
+ const slotProps = {};
14
+ const slotNames = Object.keys(state.components);
15
+ for (const slotName of slotNames){
16
+ const [slot, props] = getSlotNext(state, slotName);
17
+ slots[slotName] = slot;
18
+ slotProps[slotName] = props;
19
+ }
20
+ return {
21
+ slots,
22
+ slotProps: slotProps
23
+ };
24
+ }
25
+ function getSlotNext(state, slotName) {
26
+ var _state_components, _state_components1;
27
+ const props = state[slotName];
28
+ if (props === undefined) {
29
+ return [
30
+ null,
31
+ undefined
32
+ ];
33
+ }
34
+ const { as: asProp , ...propsWithoutAs } = props;
35
+ const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
36
+ const shouldOmitAsProp = typeof slot === 'string' && asProp;
37
+ const slotProps = shouldOmitAsProp ? propsWithoutAs : props;
38
+ return [
39
+ slot,
40
+ slotProps
41
+ ];
42
+ } //# sourceMappingURL=getSlotsNext.js.map
43
+
44
+ //# sourceMappingURL=getSlotsNext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../lib/compose/getSlotsNext.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma\n */\nexport function getSlotsNext(state) {\n const slots = {};\n const slotProps = {};\n const slotNames = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlotNext(state, slotName);\n slots[slotName] = slot;\n slotProps[slotName] = props;\n }\n return {\n slots,\n slotProps: slotProps\n };\n}\nfunction getSlotNext(state, slotName) {\n var _state_components, _state_components1;\n const props = state[slotName];\n if (props === undefined) {\n return [null, undefined];\n }\n const {\n as: asProp,\n ...propsWithoutAs\n } = props;\n const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps = shouldOmitAsProp ? propsWithoutAs : props;\n return [slot, slotProps];\n}\n//# sourceMappingURL=getSlotsNext.js.map"],"names":["getSlotsNext","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","_state_components","_state_components1","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"mappings":";;;;+BAIgBA;;aAAAA;;;6DAJO;AAIhB,SAASA,aAAaC,KAAK,EAAE;IAClC,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IACnB,MAAMC,YAAYC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC9C,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,YAAYV,OAAOO;QACzCN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,OAAO;QACLR;QACAC,WAAWA;IACb;AACF;AACA,SAASQ,YAAYV,KAAK,EAAEO,QAAQ,EAAE;IACpC,IAAII,mBAAmBC;IACvB,MAAMH,QAAQT,KAAK,CAACO,SAAS;IAC7B,IAAIE,UAAUI,WAAW;QACvB,OAAO;YAAC,IAAI;YAAEA;SAAU;IAC1B,CAAC;IACD,MAAM,EACJC,IAAIC,OAAM,EACV,GAAGC,gBACJ,GAAGP;IACJ,MAAMD,OAAO,AAAC,CAAA,AAACG,CAAAA,oBAAoBX,MAAMM,UAAU,AAAD,MAAO,IAAI,IAAIK,sBAAsB,KAAK,IAAI,KAAK,IAAIA,iBAAiB,CAACJ,SAAS,AAAD,MAAOM,aAAa,OAAOb,MAAMM,UAAU,CAACC,SAAS,KAAK,WAAWQ,UAAW,CAAA,AAACH,CAAAA,qBAAqBZ,MAAMM,UAAU,AAAD,MAAO,IAAI,IAAIM,uBAAuB,KAAK,IAAI,KAAK,IAAIA,kBAAkB,CAACL,SAAS,AAAD,KAAM,QAAQP,MAAMM,UAAU,CAACC,SAAS;IACnX,MAAMU,mBAAmB,OAAOT,SAAS,YAAYO;IACrD,MAAMb,YAAYe,mBAAmBD,iBAAiBP,KAAK;IAC3D,OAAO;QAACD;QAAMN;KAAU;AAC1B,EACA,wCAAwC"}
@@ -7,6 +7,8 @@ _exportStar(require("./getSlots"), exports);
7
7
  _exportStar(require("./resolveShorthand"), exports);
8
8
  _exportStar(require("./types"), exports);
9
9
  _exportStar(require("./isResolvedShorthand"), exports);
10
+ _exportStar(require("./constants"), exports);
11
+ _exportStar(require("./getSlotsNext"), exports);
10
12
  //# sourceMappingURL=index.js.map
11
13
 
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/compose/index.js"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;CACd,iCAAiC"}
1
+ {"version":3,"sources":["../../lib/compose/index.js"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\nexport * from './constants';\nexport * from './getSlotsNext';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
@@ -7,23 +7,28 @@ Object.defineProperty(exports, "resolveShorthand", {
7
7
  get: ()=>resolveShorthand
8
8
  });
9
9
  const _react = require("react");
10
+ const _constants = require("./constants");
10
11
  const resolveShorthand = (value, options)=>{
11
12
  const { required =false , defaultProps } = options || {};
12
13
  if (value === null || value === undefined && !required) {
13
14
  return undefined;
14
15
  }
15
16
  let resolvedShorthand = {};
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
18
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/ (0, _react.isValidElement)(value)) {
17
19
  resolvedShorthand.children = value;
18
20
  } else if (typeof value === 'object') {
19
- resolvedShorthand = {
20
- ...value
21
- };
21
+ resolvedShorthand = value;
22
22
  }
23
- return defaultProps ? {
23
+ resolvedShorthand = {
24
24
  ...defaultProps,
25
25
  ...resolvedShorthand
26
- } : resolvedShorthand;
26
+ };
27
+ if (typeof resolvedShorthand.children === 'function') {
28
+ resolvedShorthand[_constants.SLOT_RENDER_FUNCTION_SYMBOL] = resolvedShorthand.children;
29
+ resolvedShorthand.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;
30
+ }
31
+ return resolvedShorthand;
27
32
  }; //# sourceMappingURL=resolveShorthand.js.map
28
33
 
29
34
  //# sourceMappingURL=resolveShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/compose/resolveShorthand.js"],"sourcesContent":["import { isValidElement } from 'react';\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand = (value, options) => {\n const {\n required = false,\n defaultProps\n } = options || {};\n if (value === null || value === undefined && !required) {\n return undefined;\n }\n let resolvedShorthand = {};\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = {\n ...value\n };\n }\n return defaultProps ? {\n ...defaultProps,\n ...resolvedShorthand\n } : resolvedShorthand;\n};\n//# sourceMappingURL=resolveShorthand.js.map"],"names":["resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","isValidElement","children"],"mappings":";;;;+BAOaA;;aAAAA;;uBAPkB;AAOxB,MAAMA,mBAAmB,CAACC,OAAOC,UAAY;IAClD,MAAM,EACJC,UAAW,KAAK,CAAA,EAChBC,aAAY,EACb,GAAGF,WAAW,CAAC;IAChB,IAAID,UAAU,IAAI,IAAIA,UAAUI,aAAa,CAACF,UAAU;QACtD,OAAOE;IACT,CAAC;IACD,IAAIC,oBAAoB,CAAC;IACzB,IAAI,OAAOL,UAAU,YAAY,OAAOA,UAAU,YAAYM,MAAMC,OAAO,CAACP,UAAU,WAAW,GAAEQ,IAAAA,qBAAc,EAACR,QAAQ;QACxHK,kBAAkBI,QAAQ,GAAGT;IAC/B,OAAO,IAAI,OAAOA,UAAU,UAAU;QACpCK,oBAAoB;YAClB,GAAGL,KAAK;QACV;IACF,CAAC;IACD,OAAOG,eAAe;QACpB,GAAGA,YAAY;QACf,GAAGE,iBAAiB;IACtB,IAAIA,iBAAiB;AACvB,GACA,4CAA4C"}
1
+ {"version":3,"sources":["../../lib/compose/resolveShorthand.js"],"sourcesContent":["import { isValidElement } from 'react';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand = (value, options) => {\n const {\n required = false,\n defaultProps\n } = options || {};\n if (value === null || value === undefined && !required) {\n return undefined;\n }\n let resolvedShorthand = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = value;\n }\n resolvedShorthand = {\n ...defaultProps,\n ...resolvedShorthand\n };\n if (typeof resolvedShorthand.children === 'function') {\n resolvedShorthand[SLOT_RENDER_FUNCTION_SYMBOL] = resolvedShorthand.children;\n resolvedShorthand.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;\n }\n return resolvedShorthand;\n};\n//# sourceMappingURL=resolveShorthand.js.map"],"names":["resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","isValidElement","children","SLOT_RENDER_FUNCTION_SYMBOL"],"mappings":";;;;+BAQaA;;aAAAA;;uBARkB;2BACa;AAOrC,MAAMA,mBAAmB,CAACC,OAAOC,UAAY;IAClD,MAAM,EACJC,UAAW,KAAK,CAAA,EAChBC,aAAY,EACb,GAAGF,WAAW,CAAC;IAChB,IAAID,UAAU,IAAI,IAAIA,UAAUI,aAAa,CAACF,UAAU;QACtD,OAAOE;IACT,CAAC;IACD,IAAIC,oBAAoB,CAAC;IACzB,8DAA8D;IAC9D,IAAI,OAAOL,UAAU,YAAY,OAAOA,UAAU,YAAYM,MAAMC,OAAO,CAACP,UAAU,WAAW,GAAEQ,IAAAA,qBAAc,EAACR,QAAQ;QACxHK,kBAAkBI,QAAQ,GAAGT;IAC/B,OAAO,IAAI,OAAOA,UAAU,UAAU;QACpCK,oBAAoBL;IACtB,CAAC;IACDK,oBAAoB;QAClB,GAAGF,YAAY;QACf,GAAGE,iBAAiB;IACtB;IACA,IAAI,OAAOA,kBAAkBI,QAAQ,KAAK,YAAY;QACpDJ,iBAAiB,CAACK,sCAA2B,CAAC,GAAGL,kBAAkBI,QAAQ;QAC3EJ,kBAAkBI,QAAQ,GAAGN,iBAAiB,IAAI,IAAIA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAaM,QAAQ;IAChH,CAAC;IACD,OAAOJ;AACT,GACA,4CAA4C"}
@@ -10,8 +10,10 @@ function _export(target, all) {
10
10
  }
11
11
  _export(exports, {
12
12
  getSlots: ()=>_index.getSlots,
13
+ getSlotsNext: ()=>_index.getSlotsNext,
13
14
  resolveShorthand: ()=>_index.resolveShorthand,
14
15
  isResolvedShorthand: ()=>_index.isResolvedShorthand,
16
+ SLOT_RENDER_FUNCTION_SYMBOL: ()=>_index.SLOT_RENDER_FUNCTION_SYMBOL,
15
17
  IdPrefixProvider: ()=>_index1.IdPrefixProvider,
16
18
  resetIdsForTests: ()=>_index1.resetIdsForTests,
17
19
  useControllableState: ()=>_index1.useControllableState,
@@ -1 +1 @@
1
- {"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\nexport { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n//# sourceMappingURL=index.js.map"],"names":["getSlots","resolveShorthand","isResolvedShorthand","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"mappings":";;;;;;;;;;;IAASA,QAAQ,MAARA,eAAQ;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAC/CC,gBAAgB,MAAhBA,wBAAgB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,oBAAoB,MAApBA,4BAAoB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,KAAK,MAALA,aAAK;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,kBAAkB,MAAlBA,0BAAkB;IAAEC,WAAW,MAAXA,mBAAW;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,UAAU,MAAVA,kBAAU;IAC7OC,SAAS,MAATA,iBAAS;IAAEC,QAAQ,MAARA,gBAAQ;IAAEC,WAAW,MAAXA,mBAAW;IAChCC,KAAK,MAALA,aAAK;IAAEC,qBAAqB,MAArBA,6BAAqB;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,wBAAwB,MAAxBA,gCAAwB;IAAEC,IAAI,MAAJA,YAAI;IACrIC,2BAA2B,MAA3BA,mCAA2B;IAAEC,eAAe,MAAfA,uBAAe;IAAEC,eAAe,MAAfA,uBAAe;IAC7DC,YAAY,MAAZA,oBAAY;IAAEC,YAAY,MAAZA,oBAAY;IAAEC,oBAAoB,MAApBA,4BAAoB;;uBALO;wBAC8L;wBAC7M;wBACqG;wBACxE;wBACb;CACjE,iCAAiC"}
1
+ {"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { getSlots, getSlotsNext, resolveShorthand, isResolvedShorthand, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';\nexport { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\nexport { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n//# sourceMappingURL=index.js.map"],"names":["getSlots","getSlotsNext","resolveShorthand","isResolvedShorthand","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"mappings":";;;;;;;;;;;IAASA,QAAQ,MAARA,eAAQ;IAAEC,YAAY,MAAZA,mBAAY;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAC1FC,gBAAgB,MAAhBA,wBAAgB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,oBAAoB,MAApBA,4BAAoB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,KAAK,MAALA,aAAK;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,kBAAkB,MAAlBA,0BAAkB;IAAEC,WAAW,MAAXA,mBAAW;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,UAAU,MAAVA,kBAAU;IAC7OC,SAAS,MAATA,iBAAS;IAAEC,QAAQ,MAARA,gBAAQ;IAAEC,WAAW,MAAXA,mBAAW;IAChCC,KAAK,MAALA,aAAK;IAAEC,qBAAqB,MAArBA,6BAAqB;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,wBAAwB,MAAxBA,gCAAwB;IAAEC,IAAI,MAAJA,YAAI;IACrIC,2BAA2B,MAA3BA,mCAA2B;IAAEC,eAAe,MAAfA,uBAAe;IAAEC,eAAe,MAAfA,uBAAe;IAC7DC,YAAY,MAAZA,oBAAY;IAAEC,YAAY,MAAZA,oBAAY;IAAEC,oBAAoB,MAApBA,4BAAoB;;uBALkD;wBACmJ;wBAC7M;wBACqG;wBACxE;wBACb;CACjE,iCAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-utilities",
3
- "version": "9.7.4",
3
+ "version": "9.8.0",
4
4
  "description": "A set of general React-specific utilities.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",