@fluentui/react-utilities 9.10.1 → 9.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +46 -1
- package/CHANGELOG.md +20 -2
- package/dist/index.d.ts +106 -1
- package/lib/compose/assertSlots.js +42 -0
- package/lib/compose/assertSlots.js.map +1 -0
- package/lib/compose/constants.js +4 -0
- package/lib/compose/constants.js.map +1 -1
- package/lib/compose/getSlots.js +4 -1
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.js +4 -0
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isSlot.js +7 -0
- package/lib/compose/isSlot.js.map +1 -0
- package/lib/compose/resolveShorthand.js +8 -22
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/slot.js +68 -0
- package/lib/compose/slot.js.map +1 -0
- package/lib/compose/types.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/compose/assertSlots.js +32 -0
- package/lib-commonjs/compose/assertSlots.js.map +1 -0
- package/lib-commonjs/compose/constants.js +10 -3
- package/lib-commonjs/compose/constants.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +4 -1
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.js +8 -0
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isSlot.js +12 -0
- package/lib-commonjs/compose/isSlot.js.map +1 -0
- package/lib-commonjs/compose/resolveShorthand.js +9 -22
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/slot.js +61 -0
- package/lib-commonjs/compose/slot.js.map +1 -0
- package/lib-commonjs/index.js +4 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,52 @@
|
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Fri, 11 Aug 2023 12:10:20 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v9.11.1",
|
7
|
+
"version": "9.11.1",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
12
|
+
"package": "@fluentui/react-utilities",
|
13
|
+
"commit": "f9f2b69201c81811e8e4ce23f971d6174127d0ca",
|
14
|
+
"comment": "chore: tests for slot.resolveShorthand behavior"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"date": "Fri, 04 Aug 2023 08:52:58 GMT",
|
21
|
+
"tag": "@fluentui/react-utilities_v9.11.0",
|
22
|
+
"version": "9.11.0",
|
23
|
+
"comments": {
|
24
|
+
"minor": [
|
25
|
+
{
|
26
|
+
"author": "bernardo.sunderhus@gmail.com",
|
27
|
+
"package": "@fluentui/react-utilities",
|
28
|
+
"commit": "6a8afe2b7becaf1b10cbc9ae98b39d352b8c7026",
|
29
|
+
"comment": "feat: implement new slot methods (slot and assertSlots)"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"date": "Thu, 20 Jul 2023 18:27:36 GMT",
|
36
|
+
"tag": "@fluentui/react-utilities_v9.10.1",
|
37
|
+
"version": "9.10.1",
|
38
|
+
"comments": {
|
39
|
+
"none": [
|
40
|
+
{
|
41
|
+
"author": "olfedias@microsoft.com",
|
42
|
+
"package": "@fluentui/react-utilities",
|
43
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6",
|
44
|
+
"comment": "chore: migrate to monosize"
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"date": "Mon, 03 Jul 2023 11:57:14 GMT",
|
6
51
|
"tag": "@fluentui/react-utilities_v9.10.1",
|
7
52
|
"version": "9.10.1",
|
8
53
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,30 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 11 Aug 2023 12:10:20 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.11.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.11.1)
|
8
|
+
|
9
|
+
Fri, 11 Aug 2023 12:10:20 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.11.0..@fluentui/react-utilities_v9.11.1)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: tests for slot.resolveShorthand behavior ([PR #28819](https://github.com/microsoft/fluentui/pull/28819) by bernardo.sunderhus@gmail.com)
|
15
|
+
|
16
|
+
## [9.11.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.11.0)
|
17
|
+
|
18
|
+
Fri, 04 Aug 2023 08:52:58 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.10.1..@fluentui/react-utilities_v9.11.0)
|
20
|
+
|
21
|
+
### Minor changes
|
22
|
+
|
23
|
+
- feat: implement new slot methods (slot and assertSlots) ([PR #28373](https://github.com/microsoft/fluentui/pull/28373) by bernardo.sunderhus@gmail.com)
|
24
|
+
|
7
25
|
## [9.10.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.10.1)
|
8
26
|
|
9
|
-
Mon, 03 Jul 2023 11:
|
27
|
+
Mon, 03 Jul 2023 11:57:14 GMT
|
10
28
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.10.0..@fluentui/react-utilities_v9.10.1)
|
11
29
|
|
12
30
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
import { DispatchWithoutAction } from 'react';
|
2
2
|
import * as React_2 from 'react';
|
3
3
|
|
4
|
+
/**
|
5
|
+
* Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)
|
6
|
+
* @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties
|
7
|
+
* @param options - values you can pass to alter the signature of a slot, those values are:
|
8
|
+
*
|
9
|
+
* * `elementType` - the base element type of a slot, defaults to `'div'`
|
10
|
+
* * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided.
|
11
|
+
*/
|
12
|
+
declare function always<Props extends UnknownSlotProps>(value: Props | SlotShorthandValue | undefined, options: SlotOptions<Props>): SlotComponentType<Props>;
|
13
|
+
|
4
14
|
/**
|
5
15
|
* @internal
|
6
16
|
* resolve the trigger props to the children, either by calling the render function, or cloning with the new props.
|
@@ -19,6 +29,27 @@ declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
|
|
19
29
|
as?: As;
|
20
30
|
};
|
21
31
|
|
32
|
+
/**
|
33
|
+
* @internal
|
34
|
+
* Assertion method to ensure state slots properties are properly declared.
|
35
|
+
* A properly declared slot must be declared by using the `slot` method.
|
36
|
+
*
|
37
|
+
* @example
|
38
|
+
* ```tsx
|
39
|
+
* export const renderInput_unstable = (state: InputState) => {
|
40
|
+
assertSlots<InputSlots>(state);
|
41
|
+
return (
|
42
|
+
<state.root>
|
43
|
+
{state.contentBefore && <state.contentBefore />}
|
44
|
+
<state.input />
|
45
|
+
{state.contentAfter && <state.contentAfter />}
|
46
|
+
</state.root>
|
47
|
+
);
|
48
|
+
};
|
49
|
+
* ```
|
50
|
+
*/
|
51
|
+
export declare function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots>;
|
52
|
+
|
22
53
|
/**
|
23
54
|
* Verifies if an application can use DOM.
|
24
55
|
*/
|
@@ -303,6 +334,12 @@ declare type IsSingleton<T extends string> = {
|
|
303
334
|
[K in T]: Exclude<T, K> extends never ? true : false;
|
304
335
|
}[T];
|
305
336
|
|
337
|
+
/**
|
338
|
+
* Guard method to ensure a given element is a slot.
|
339
|
+
* This is mainly used internally to ensure a slot is being used as a component.
|
340
|
+
*/
|
341
|
+
export declare function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props>;
|
342
|
+
|
306
343
|
/**
|
307
344
|
* Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.
|
308
345
|
*/
|
@@ -374,6 +411,23 @@ export declare type OnSelectionChangeData = {
|
|
374
411
|
selectedItems: Set<SelectionItemId>;
|
375
412
|
};
|
376
413
|
|
414
|
+
/**
|
415
|
+
* Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)
|
416
|
+
* @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties
|
417
|
+
* @param options - values you can pass to alter the signature of a slot, those values are:
|
418
|
+
*
|
419
|
+
* * `elementType` - the base element type of a slot, defaults to `'div'`
|
420
|
+
* * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided
|
421
|
+
* * `renderByDefault` - a boolean that indicates if a slot will be rendered even if it's base value is `undefined`.
|
422
|
+
* By default if `props.SLOT_NAME` is `undefined` then `state.SLOT_NAME` becomes `undefined`
|
423
|
+
* and nothing will be rendered, but if `renderByDefault = true` then `state.SLOT_NAME` becomes an object
|
424
|
+
* with the values provided by `options.defaultProps` (or `{}`). This is useful for cases such as providing a default content
|
425
|
+
* in case no shorthand is provided, like the case of the `expandIcon` slot for the `AccordionHeader`
|
426
|
+
*/
|
427
|
+
declare function optional<Props extends UnknownSlotProps>(value: Props | SlotShorthandValue | undefined | null, options: {
|
428
|
+
renderByDefault?: boolean;
|
429
|
+
} & SlotOptions<Props>): SlotComponentType<Props> | undefined;
|
430
|
+
|
377
431
|
/**
|
378
432
|
* @internal
|
379
433
|
*/
|
@@ -435,7 +489,14 @@ export declare function resetIdsForTests(): void;
|
|
435
489
|
* @param value - the base shorthand props
|
436
490
|
* @param options - options to resolve shorthand props
|
437
491
|
*/
|
438
|
-
export declare const resolveShorthand: ResolveShorthandFunction
|
492
|
+
export declare const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps>;
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Helper function that converts a slot shorthand or properties to a slot properties object
|
496
|
+
* 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
|
497
|
+
* @param value - the value of the slot, it can be a slot shorthand or a slot properties object
|
498
|
+
*/
|
499
|
+
declare function resolveShorthand_2<Props extends UnknownSlotProps | null | undefined>(value: Props | SlotShorthandValue): Props;
|
439
500
|
|
440
501
|
export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
|
441
502
|
<P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): P;
|
@@ -510,6 +571,22 @@ export declare type Slot<Type extends keyof JSX.IntrinsicElements | React_2.Comp
|
|
510
571
|
} & WithSlotRenderFunction<IntrinsicElementProps<As>>;
|
511
572
|
}[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
|
512
573
|
|
574
|
+
declare namespace slot {
|
575
|
+
export {
|
576
|
+
always,
|
577
|
+
optional,
|
578
|
+
resolveShorthand_2 as resolveShorthand,
|
579
|
+
SlotOptions
|
580
|
+
}
|
581
|
+
}
|
582
|
+
export { slot }
|
583
|
+
|
584
|
+
/**
|
585
|
+
* @internal
|
586
|
+
* Internal reference for the render function
|
587
|
+
*/
|
588
|
+
export declare const SLOT_ELEMENT_TYPE_SYMBOL: unique symbol;
|
589
|
+
|
513
590
|
/**
|
514
591
|
* @internal
|
515
592
|
* Internal reference for the render function
|
@@ -523,6 +600,34 @@ export declare type SlotClassNames<Slots> = {
|
|
523
600
|
[SlotName in keyof Slots]-?: string;
|
524
601
|
};
|
525
602
|
|
603
|
+
declare type SlotComponents<Slots extends SlotPropsRecord> = {
|
604
|
+
[K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>>;
|
605
|
+
};
|
606
|
+
|
607
|
+
/**
|
608
|
+
* A definition of a slot, as a component, very similar to how a React component is declared,
|
609
|
+
* but with some additional metadata that is used to determine how to render the slot.
|
610
|
+
*/
|
611
|
+
export declare type SlotComponentType<Props extends UnknownSlotProps> = Props & {
|
612
|
+
/**
|
613
|
+
* **NOTE**: Slot components are not callable.
|
614
|
+
*/
|
615
|
+
(props: React_2.PropsWithChildren<{}>): React_2.ReactElement | null;
|
616
|
+
/**
|
617
|
+
* @internal
|
618
|
+
*/
|
619
|
+
[SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<Props>;
|
620
|
+
/**
|
621
|
+
* @internal
|
622
|
+
*/
|
623
|
+
[SLOT_ELEMENT_TYPE_SYMBOL]: React_2.ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
624
|
+
};
|
625
|
+
|
626
|
+
export declare type SlotOptions<Props extends UnknownSlotProps> = {
|
627
|
+
elementType: React_2.ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
628
|
+
defaultProps?: Partial<Props>;
|
629
|
+
};
|
630
|
+
|
526
631
|
/**
|
527
632
|
* Matches any component's Slots type (such as ButtonSlots).
|
528
633
|
*
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';
|
2
|
+
import { isSlot } from './isSlot';
|
3
|
+
/**
|
4
|
+
* @internal
|
5
|
+
* Assertion method to ensure state slots properties are properly declared.
|
6
|
+
* A properly declared slot must be declared by using the `slot` method.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* ```tsx
|
10
|
+
* export const renderInput_unstable = (state: InputState) => {
|
11
|
+
assertSlots<InputSlots>(state);
|
12
|
+
return (
|
13
|
+
<state.root>
|
14
|
+
{state.contentBefore && <state.contentBefore />}
|
15
|
+
<state.input />
|
16
|
+
{state.contentAfter && <state.contentAfter />}
|
17
|
+
</state.root>
|
18
|
+
);
|
19
|
+
};
|
20
|
+
* ```
|
21
|
+
*/ export function assertSlots(state) {
|
22
|
+
/**
|
23
|
+
* This verification is not necessary in production
|
24
|
+
* as we're verifying static properties that will not change between environments
|
25
|
+
*/ if (process.env.NODE_ENV !== 'production') {
|
26
|
+
const typedState = state;
|
27
|
+
for (const slotName of Object.keys(typedState.components)){
|
28
|
+
const slotElement = typedState[slotName];
|
29
|
+
if (slotElement === undefined) {
|
30
|
+
continue;
|
31
|
+
}
|
32
|
+
if (!isSlot(slotElement)) {
|
33
|
+
throw new Error(`${assertSlots.name} error: state.${slotName} is not a slot.\n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`);
|
34
|
+
} else {
|
35
|
+
const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;
|
36
|
+
if (elementType !== typedState.components[slotName]) {
|
37
|
+
throw new TypeError(`${assertSlots.name} error: state.${slotName} element type differs from state.components.${slotName}, ${elementType} !== ${typedState.components[slotName]}. \n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional' with the correct elementType`);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["assertSlots.ts"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\n\ntype SlotComponents<Slots extends SlotPropsRecord> = {\n [K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>>;\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 if (!isSlot(slotElement)) {\n throw new Error(\n `${assertSlots.name} error: state.${slotName} is not a slot.\\n` +\n `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`,\n );\n } else {\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n throw new TypeError(\n `${assertSlots.name} error: state.${slotName} element type differs from state.components.${slotName}, ${elementType} !== ${typedState.components[slotName]}. \\n` +\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":["SLOT_ELEMENT_TYPE_SYMBOL","isSlot","assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","Error","name","elementType","TypeError"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,cAAc;AACvD,SAASC,MAAM,QAAQ,WAAW;AAOlC;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,YAA2CC,KAAc,EAA0C;IACjH;;;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,QAAS;YACX,CAAC;YACD,IAAI,CAACZ,OAAOW,cAAc;gBACxB,MAAM,IAAIE,MACR,CAAC,EAAEZ,YAAYa,IAAI,CAAC,cAAc,EAAEP,SAAS,iBAAiB,CAAC,GAC7D,CAAC,2EAA2E,CAAC,EAC/E;YACJ,OAAO;gBACL,MAAM,EAAE,CAACR,yBAAyB,EAAEgB,YAAW,EAAE,GAAGJ;gBACpD,IAAII,gBAAgBT,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACnD,MAAM,IAAIS,UACR,CAAC,EAAEf,YAAYa,IAAI,CAAC,cAAc,EAAEP,SAAS,4CAA4C,EAAEA,SAAS,EAAE,EAAEQ,YAAY,KAAK,EAAET,WAAWI,UAAU,CAACH,SAAS,CAAC,IAAI,CAAC,GAC9J,CAAC,uGAAuG,CAAC,EAC3G;gBACJ,CAAC;YACH,CAAC;QACH;IACF,CAAC;AACH,CAAC"}
|
package/lib/compose/constants.js
CHANGED
@@ -2,3 +2,7 @@
|
|
2
2
|
* @internal
|
3
3
|
* Internal reference for the render function
|
4
4
|
*/ export const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
* Internal reference for the render function
|
8
|
+
*/ export const SLOT_ELEMENT_TYPE_SYMBOL = Symbol('fui.slotElementType');
|
@@ -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('fui.slotRenderFunction');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,8BAA8BC,OAAO,0BAA0B"}
|
1
|
+
{"version":3,"sources":["constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_ELEMENT_TYPE_SYMBOL = Symbol('fui.slotElementType');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol","SLOT_ELEMENT_TYPE_SYMBOL"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,8BAA8BC,OAAO,0BAA0B;AAC5E;;;CAGC,GACD,OAAO,MAAMC,2BAA2BD,OAAO,uBAAuB"}
|
package/lib/compose/getSlots.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { omit } from '../utils/omit';
|
3
|
+
import { isSlot } from './isSlot';
|
3
4
|
import { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';
|
4
5
|
/**
|
5
6
|
* Given the state and an array of slot names, will break out `slots` and `slotProps`
|
@@ -40,7 +41,9 @@ function getSlot(state, slotName) {
|
|
40
41
|
undefined
|
41
42
|
];
|
42
43
|
}
|
43
|
-
|
44
|
+
// TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)
|
45
|
+
const { as: asProp , children , ...rest } = props;
|
46
|
+
const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;
|
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
48
|
if (renderFunction || typeof children === 'function') {
|
46
49
|
const render = renderFunction || children;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getSlots.ts"],"sourcesContent":["import * as React from 'react';\
|
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 UnionToIntersection,\n UnknownSlotProps,\n} from './types';\nimport { isSlot } from './isSlot';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\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 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":["React","omit","isSlot","SLOT_RENDER_FUNCTION_SYMBOL","getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","undefined","as","asProp","children","rest","renderFunction","render","Fragment","shouldOmitAsProp"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,QAAQ,gBAAgB;AAUrC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,2BAA2B,QAAQ,cAAc;AAqB1D;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,SACdC,KAAwB,EAIxB;IACA,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;QACrCN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE,CAAC;AAED,SAASQ,QACPV,KAAwB,EACxBO,QAAW,EACsC;QAc/CP,mBACcA;IAdhB,MAAMS,QAAQT,KAAK,CAACO,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC,IAAI;YAAEA;SAAkB;IAClC,CAAC;IAGD,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,OAAM,EAAEC,SAAQ,EAAE,GAAGC,MAAM,GAAGN;IAE1C,MAAMO,iBAAiBnB,OAAOY,SAASA,KAAK,CAACX,4BAA4B,GAAGa,SAAS;IAErF,MAAMH,OACJR,CAAAA,CAAAA,oBAAAA,MAAMM,UAAU,cAAhBN,+BAAAA,KAAAA,IAAAA,iBAAkB,CAACO,SAAS,AAAD,MAAMI,aAAa,OAAOX,MAAMM,UAAU,CAACC,SAAS,KAAK,WAChFM,UAAUb,CAAAA,CAAAA,qBAAAA,MAAMM,UAAU,cAAhBN,gCAAAA,KAAAA,IAAAA,kBAAkB,CAACO,SAAS,AAAD,KAAK,QAC1CP,MAAMM,UAAU,CAACC,SAAS;IAGhC,IAAIS,kBAAkB,OAAOF,aAAa,YAAY;QACpD,MAAMG,SAAUD,kBAAkBF;QAClC,OAAO;YACLnB,MAAMuB,QAAQ;YACd;gBACEJ,UAAUG,OAAOT,MAAMO;YACzB;SACD;IACH,CAAC;IAED,MAAMI,mBAAmB,OAAOX,SAAS,YAAYK;IACrD,MAAMX,YAAaiB,mBAAmBvB,KAAKa,OAAO;QAAC;KAAK,IAAKA,KAA0B;IACvF,OAAO;QAACD;QAAMN;KAAU;AAC1B"}
|
package/lib/compose/index.js
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
import * as slot from './slot';
|
1
2
|
export * from './getSlots';
|
2
3
|
export * from './resolveShorthand';
|
3
4
|
export * from './types';
|
4
5
|
export * from './isResolvedShorthand';
|
5
6
|
export * from './constants';
|
6
7
|
export * from './getSlotsNext';
|
8
|
+
export * from './isSlot';
|
9
|
+
export * from './assertSlots';
|
10
|
+
export { slot };
|
package/lib/compose/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["import * as slot from './slot';\n\nexport * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\nexport * from './constants';\nexport * from './getSlotsNext';\nexport * from './isSlot';\nexport * from './assertSlots';\n\nexport { slot };\nexport type { SlotOptions } from './slot';\n"],"names":["slot"],"mappings":"AAAA,YAAYA,UAAU,SAAS;AAE/B,cAAc,aAAa;AAC3B,cAAc,qBAAqB;AACnC,cAAc,UAAU;AACxB,cAAc,wBAAwB;AACtC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAE9B,SAASA,IAAI,GAAG"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';
|
2
|
+
/**
|
3
|
+
* Guard method to ensure a given element is a slot.
|
4
|
+
* This is mainly used internally to ensure a slot is being used as a component.
|
5
|
+
*/ export function isSlot(element) {
|
6
|
+
return Boolean(element === null || element === void 0 ? void 0 : element.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));
|
7
|
+
}
|
@@ -0,0 +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":["SLOT_ELEMENT_TYPE_SYMBOL","isSlot","element","Boolean","hasOwnProperty"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,cAAc;AAGvD;;;CAGC,GACD,OAAO,SAASC,OAAyBC,OAAgB,EAAuC;IAC9F,OAAOC,QAAQ,AAACD,oBAAAA,qBAAD,KAAA,IAAA,AAACA,QAA4BE,cAAc,CAACJ;AAC7D,CAAC"}
|
@@ -1,29 +1,15 @@
|
|
1
|
-
import
|
2
|
-
import { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';
|
1
|
+
import * as slot from './slot';
|
3
2
|
/**
|
4
3
|
* Resolves shorthands into slot props, to ensure normalization of the signature
|
5
4
|
* being passed down to getSlots method
|
6
5
|
* @param value - the base shorthand props
|
7
6
|
* @param options - options to resolve shorthand props
|
8
7
|
*/ export const resolveShorthand = (value, options)=>{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
resolvedShorthand.children = value;
|
17
|
-
} else if (typeof value === 'object') {
|
18
|
-
resolvedShorthand = value;
|
19
|
-
}
|
20
|
-
resolvedShorthand = {
|
21
|
-
...defaultProps,
|
22
|
-
...resolvedShorthand
|
23
|
-
};
|
24
|
-
if (typeof resolvedShorthand.children === 'function') {
|
25
|
-
resolvedShorthand[SLOT_RENDER_FUNCTION_SYMBOL] = resolvedShorthand.children;
|
26
|
-
resolvedShorthand.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;
|
27
|
-
}
|
28
|
-
return resolvedShorthand;
|
8
|
+
return slot.optional(value, {
|
9
|
+
...options,
|
10
|
+
renderByDefault: options === null || options === void 0 ? void 0 : options.required,
|
11
|
+
// elementType as undefined is the way to identify between a slot and a resolveShorthand call
|
12
|
+
// in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.
|
13
|
+
elementType: undefined
|
14
|
+
});
|
29
15
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["resolveShorthand.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["resolveShorthand.ts"],"sourcesContent":["import * as slot from './slot';\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<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":["slot","resolveShorthand","value","options","optional","renderByDefault","required","elementType","undefined"],"mappings":"AAAA,YAAYA,UAAU,SAAS;AAc/B;;;;;CAKC,GACD,OAAO,MAAMC,mBAA+D,CAACC,OAAOC;IAClFH,OAAAA,KAAKI,QAAQ,CAAmBF,OAAO;QACrC,GAAGC,OAAO;QACVE,iBAAiBF,oBAAAA,qBAAAA,KAAAA,IAAAA,QAASG,QAAQ;QAClC,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACf;EAAG"}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';
|
3
|
+
/**
|
4
|
+
* Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)
|
5
|
+
* @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties
|
6
|
+
* @param options - values you can pass to alter the signature of a slot, those values are:
|
7
|
+
*
|
8
|
+
* * `elementType` - the base element type of a slot, defaults to `'div'`
|
9
|
+
* * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided.
|
10
|
+
*/ export function always(value, options) {
|
11
|
+
const { defaultProps , elementType } = options;
|
12
|
+
const props = resolveShorthand(value);
|
13
|
+
/**
|
14
|
+
* Casting is required here as SlotComponentType is a function, not an object.
|
15
|
+
* Although SlotComponentType has a function signature, it is still just an object.
|
16
|
+
* This is required to make a slot callable (JSX compatible), this is the exact same approach
|
17
|
+
* that is used on `@types/react` components
|
18
|
+
*/ const propsWithMetadata = {
|
19
|
+
...defaultProps,
|
20
|
+
...props,
|
21
|
+
[SLOT_ELEMENT_TYPE_SYMBOL]: elementType
|
22
|
+
};
|
23
|
+
if (props && typeof props.children === 'function') {
|
24
|
+
propsWithMetadata[SLOT_RENDER_FUNCTION_SYMBOL] = props.children;
|
25
|
+
propsWithMetadata.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;
|
26
|
+
}
|
27
|
+
return propsWithMetadata;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)
|
31
|
+
* @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties
|
32
|
+
* @param options - values you can pass to alter the signature of a slot, those values are:
|
33
|
+
*
|
34
|
+
* * `elementType` - the base element type of a slot, defaults to `'div'`
|
35
|
+
* * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided
|
36
|
+
* * `renderByDefault` - a boolean that indicates if a slot will be rendered even if it's base value is `undefined`.
|
37
|
+
* By default if `props.SLOT_NAME` is `undefined` then `state.SLOT_NAME` becomes `undefined`
|
38
|
+
* and nothing will be rendered, but if `renderByDefault = true` then `state.SLOT_NAME` becomes an object
|
39
|
+
* with the values provided by `options.defaultProps` (or `{}`). This is useful for cases such as providing a default content
|
40
|
+
* in case no shorthand is provided, like the case of the `expandIcon` slot for the `AccordionHeader`
|
41
|
+
*/ export function optional(value, options) {
|
42
|
+
if (value === null || value === undefined && !options.renderByDefault) {
|
43
|
+
return undefined;
|
44
|
+
}
|
45
|
+
return always(value, options);
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Helper function that converts a slot shorthand or properties to a slot properties object
|
49
|
+
* 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
|
50
|
+
* @param value - the value of the slot, it can be a slot shorthand or a slot properties object
|
51
|
+
*/ export function resolveShorthand(value) {
|
52
|
+
if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
53
|
+
React.isValidElement(value)) {
|
54
|
+
return {
|
55
|
+
children: value
|
56
|
+
};
|
57
|
+
}
|
58
|
+
if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {
|
59
|
+
// TODO: would be nice to have a link to slot documentation in this error message
|
60
|
+
// eslint-disable-next-line no-console
|
61
|
+
console.error([
|
62
|
+
`[slot.resolveShorthand]: A slot got invalid value "${value}" (${typeof value}).`,
|
63
|
+
'A valid value is a slot shorthand or slot properties object.',
|
64
|
+
'Slot shorthands can be strings, numbers, arrays or JSX elements'
|
65
|
+
].join('\n'));
|
66
|
+
}
|
67
|
+
return value;
|
68
|
+
}
|
@@ -0,0 +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(\n [\n `[slot.resolveShorthand]: A slot got invalid value \"${value}\" (${typeof value}).`,\n 'A valid value is a slot shorthand or slot properties object.',\n 'Slot shorthands can be strings, numbers, arrays or JSX elements',\n ].join('\\n'),\n );\n }\n\n return value;\n}\n"],"names":["React","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","always","value","options","defaultProps","elementType","props","resolveShorthand","propsWithMetadata","children","optional","undefined","renderByDefault","Array","isArray","isValidElement","process","env","NODE_ENV","console","error","join"],"mappings":"AAOA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,2BAA2B,QAAQ,cAAc;AASpF;;;;;;;CAOC,GACD,OAAO,SAASC,OACdC,KAA6C,EAC7CC,OAA2B,EACD;IAC1B,MAAM,EAAEC,aAAY,EAAEC,YAAW,EAAE,GAAGF;IAEtC,MAAMG,QAAQC,iBAAiBL;IAE/B;;;;;GAKC,GACD,MAAMM,oBAAoB;QACxB,GAAGJ,YAAY;QACf,GAAGE,KAAK;QACR,CAACP,yBAAyB,EAAEM;IAC9B;IAEA,IAAIC,SAAS,OAAOA,MAAMG,QAAQ,KAAK,YAAY;QACjDD,iBAAiB,CAACR,4BAA4B,GAAGM,MAAMG,QAAQ;QAC/DD,kBAAkBC,QAAQ,GAAGL,yBAAAA,0BAAAA,KAAAA,IAAAA,aAAcK,QAAQ;IACrD,CAAC;IAED,OAAOD;AACT,CAAC;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,SAASE,SACdR,KAAoD,EACpDC,OAA2D,EACrB;IACtC,IAAID,UAAU,IAAI,IAAKA,UAAUS,aAAa,CAACR,QAAQS,eAAe,EAAG;QACvE,OAAOD;IACT,CAAC;IACD,OAAOV,OAAOC,OAAOC;AACvB,CAAC;AAED;;;;CAIC,GACD,OAAO,SAASI,iBACdL,KAAiC,EAC1B;IACP,IACE,OAAOA,UAAU,YACjB,OAAOA,UAAU,YACjBW,MAAMC,OAAO,CAACZ,UACd,8DAA8D;IAC9DJ,MAAMiB,cAAc,CAAMb,QAC1B;QACA,OAAO;YAAEO,UAAUP;QAAM;IAC3B,CAAC;IACD,IAAIA,SAAS,OAAOA,UAAU,YAAYc,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC/E,iFAAiF;QACjF,sCAAsC;QACtCC,QAAQC,KAAK,CACX;YACE,CAAC,mDAAmD,EAAElB,MAAM,GAAG,EAAE,OAAOA,MAAM,EAAE,CAAC;YACjF;YACA;SACD,CAACmB,IAAI,CAAC;IAEX,CAAC;IAED,OAAOnB;AACT,CAAC"}
|
package/lib/compose/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\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 extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props> = Props & {\n children?: (Props extends { children?: unknown } ? Props['children'] : never) | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrinsicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrinsicElementProps<Type extends keyof JSX.IntrinsicElements> = Type extends EmptyIntrinsicElements\n ? PropsWithoutChildren<React.PropsWithRef<JSX.IntrinsicElements[Type]>>\n : React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never,\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrinsicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrinsicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutChildren<P> = 'children' extends keyof P ? (P extends unknown ? Omit<P, 'children'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\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 extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props> = Props & {\n children?: (Props extends { children?: unknown } ? Props['children'] : never) | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrinsicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrinsicElementProps<Type extends keyof JSX.IntrinsicElements> = Type extends EmptyIntrinsicElements\n ? PropsWithoutChildren<React.PropsWithRef<JSX.IntrinsicElements[Type]>>\n : React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never,\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrinsicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrinsicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutChildren<P> = 'children' extends keyof P ? (P extends unknown ? Omit<P, 'children'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n\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 extends UnknownSlotProps> = 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"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
package/lib/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { getSlots, getSlotsNext, resolveShorthand, isResolvedShorthand, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';
|
1
|
+
export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, 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, createPriorityQueue } from './utils/index';
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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 createPriorityQueue,\n} from './utils/index';\n\nexport type { PriorityQueue } from './utils/priorityQueue';\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\nexport type {\n SelectionMode,\n OnSelectionChangeCallback,\n OnSelectionChangeData,\n SelectionItemId,\n SelectionHookParams,\n SelectionMethods,\n} from './selection/index';\nexport { useSelection } from './selection/index';\n"],"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","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":"AAAA,SACEA,QAAQ,EACRC,YAAY,EACZC,gBAAgB,EAChBC,mBAAmB,EACnBC,2BAA2B,QACtB,kBAAkB;
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n slot,\n isSlot,\n getSlots,\n getSlotsNext,\n assertSlots,\n resolveShorthand,\n isResolvedShorthand,\n SLOT_ELEMENT_TYPE_SYMBOL,\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 SlotComponentType,\n SlotOptions,\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 createPriorityQueue,\n} from './utils/index';\n\nexport type { PriorityQueue } from './utils/priorityQueue';\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\nexport type {\n SelectionMode,\n OnSelectionChangeCallback,\n OnSelectionChangeData,\n SelectionItemId,\n SelectionHookParams,\n SelectionMethods,\n} from './selection/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","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","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":"AAAA,SACEA,IAAI,EACJC,MAAM,EACNC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,gBAAgB,EAChBC,mBAAmB,EACnBC,wBAAwB,EACxBC,2BAA2B,QACtB,kBAAkB;AAmBzB,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,gBAAgB;AAGvB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,cAAc;AAE/D,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,EACJC,mBAAmB,QACd,gBAAgB;AAIvB,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ,kBAAkB;AAQhG,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ,iBAAiB;AAUlF,SAASC,YAAY,QAAQ,oBAAoB"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "assertSlots", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>assertSlots
|
8
|
+
});
|
9
|
+
const _constants = require("./constants");
|
10
|
+
const _isSlot = require("./isSlot");
|
11
|
+
function assertSlots(state) {
|
12
|
+
/**
|
13
|
+
* This verification is not necessary in production
|
14
|
+
* as we're verifying static properties that will not change between environments
|
15
|
+
*/ if (process.env.NODE_ENV !== 'production') {
|
16
|
+
const typedState = state;
|
17
|
+
for (const slotName of Object.keys(typedState.components)){
|
18
|
+
const slotElement = typedState[slotName];
|
19
|
+
if (slotElement === undefined) {
|
20
|
+
continue;
|
21
|
+
}
|
22
|
+
if (!(0, _isSlot.isSlot)(slotElement)) {
|
23
|
+
throw new Error(`${assertSlots.name} error: state.${slotName} is not a slot.\n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`);
|
24
|
+
} else {
|
25
|
+
const { [_constants.SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;
|
26
|
+
if (elementType !== typedState.components[slotName]) {
|
27
|
+
throw new TypeError(`${assertSlots.name} error: state.${slotName} element type differs from state.components.${slotName}, ${elementType} !== ${typedState.components[slotName]}. \n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional' with the correct elementType`);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["assertSlots.js"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\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 */ export function assertSlots(state) {\n /**\n * This verification is not necessary in production\n * as we're verifying static properties that will not change between environments\n */ if (process.env.NODE_ENV !== 'production') {\n const typedState = state;\n for (const slotName of Object.keys(typedState.components)){\n const slotElement = typedState[slotName];\n if (slotElement === undefined) {\n continue;\n }\n if (!isSlot(slotElement)) {\n throw new Error(`${assertSlots.name} error: state.${slotName} is not a slot.\\n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`);\n } else {\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n throw new TypeError(`${assertSlots.name} error: state.${slotName} element type differs from state.components.${slotName}, ${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"],"names":["assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","isSlot","Error","name","SLOT_ELEMENT_TYPE_SYMBOL","elementType","TypeError"],"mappings":";;;;+BAoBoBA;;aAAAA;;2BApBqB;wBAClB;AAmBZ,SAASA,YAAYC,KAAK,EAAE;IACnC;;;GAGD,GAAG,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMC,aAAaJ;QACnB,KAAK,MAAMK,YAAYC,OAAOC,IAAI,CAACH,WAAWI,UAAU,EAAE;YACtD,MAAMC,cAAcL,UAAU,CAACC,SAAS;YACxC,IAAII,gBAAgBC,WAAW;gBAC3B,QAAS;YACb,CAAC;YACD,IAAI,CAACC,IAAAA,cAAM,EAACF,cAAc;gBACtB,MAAM,IAAIG,MAAM,CAAC,EAAEb,YAAYc,IAAI,CAAC,cAAc,EAAER,SAAS,iBAAiB,CAAC,GAAG,CAAC,2EAA2E,CAAC,EAAE;YACrK,OAAO;gBACH,MAAM,EAAE,CAACS,mCAAwB,CAAC,EAAEC,YAAW,EAAG,GAAGN;gBACrD,IAAIM,gBAAgBX,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACjD,MAAM,IAAIW,UAAU,CAAC,EAAEjB,YAAYc,IAAI,CAAC,cAAc,EAAER,SAAS,4CAA4C,EAAEA,SAAS,EAAE,EAAEU,YAAY,KAAK,EAAEX,WAAWI,UAAU,CAACH,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,uGAAuG,CAAC,EAAE;gBACtS,CAAC;YACL,CAAC;QACL;IACJ,CAAC;AACL"}
|
@@ -5,8 +5,15 @@
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
function _export(target, all) {
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
10
|
+
enumerable: true,
|
11
|
+
get: all[name]
|
12
|
+
});
|
13
|
+
}
|
14
|
+
_export(exports, {
|
15
|
+
SLOT_RENDER_FUNCTION_SYMBOL: ()=>SLOT_RENDER_FUNCTION_SYMBOL,
|
16
|
+
SLOT_ELEMENT_TYPE_SYMBOL: ()=>SLOT_ELEMENT_TYPE_SYMBOL
|
11
17
|
});
|
12
18
|
const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');
|
19
|
+
const SLOT_ELEMENT_TYPE_SYMBOL = Symbol('fui.slotElementType');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["constants.js"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */ export const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol"],"mappings":"AAAA;;;CAGC
|
1
|
+
{"version":3,"sources":["constants.js"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */ export const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */ export const SLOT_ELEMENT_TYPE_SYMBOL = Symbol('fui.slotElementType');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","Symbol"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;IAAgBA,2BAA2B,MAA3BA;IAIAC,wBAAwB,MAAxBA;;AAJN,MAAMD,8BAA8BE,OAAO;AAI3C,MAAMD,2BAA2BC,OAAO"}
|
@@ -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 _isSlot = require("./isSlot");
|
12
13
|
const _constants = require("./constants");
|
13
14
|
function getSlots(state) {
|
14
15
|
const slots = {};
|
@@ -33,7 +34,9 @@ function getSlot(state, slotName) {
|
|
33
34
|
undefined
|
34
35
|
];
|
35
36
|
}
|
36
|
-
|
37
|
+
// TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)
|
38
|
+
const { as: asProp , children , ...rest } = props;
|
39
|
+
const renderFunction = (0, _isSlot.isSlot)(props) ? props[_constants.SLOT_RENDER_FUNCTION_SYMBOL] : undefined;
|
37
40
|
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];
|
38
41
|
if (renderFunction || typeof children === 'function') {
|
39
42
|
const render = renderFunction || children;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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 */ export 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 [\n null,\n undefined\n ];\n }\n
|
1
|
+
{"version":3,"sources":["getSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../utils/omit';\nimport { isSlot } from './isSlot';\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 */ export 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 [\n null,\n undefined\n ];\n }\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp , children , ...rest } = props;\n const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;\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 [\n React.Fragment,\n {\n children: render(slot, rest)\n }\n ];\n }\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps = shouldOmitAsProp ? omit(props, [\n 'as'\n ]) : props;\n return [\n slot,\n slotProps\n ];\n}\n"],"names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","_state_components","_state_components1","undefined","as","asProp","children","rest","renderFunction","isSlot","SLOT_RENDER_FUNCTION_SYMBOL","render","React","Fragment","shouldOmitAsProp","omit"],"mappings":";;;;+BAoBoBA;;aAAAA;;;6DApBG;sBACF;wBACE;2BACqB;AAiBjC,SAASA,SAASC,KAAK,EAAE;IAChC,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IACnB,MAAMC,YAAYC,OAAOC,IAAI,CAACL,MAAMM,UAAU;IAC9C,KAAK,MAAMC,YAAYJ,UAAU;QAC7B,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,OAAOO;QACrCN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IAC1B;IACA,OAAO;QACHR;QACAC,WAAWA;IACf;AACJ;AACA,SAASQ,QAAQV,KAAK,EAAEO,QAAQ,EAAE;IAC9B,IAAII,mBAAmBC;IACvB,MAAMH,QAAQT,KAAK,CAACO,SAAS;IAC7B,IAAIE,UAAUI,WAAW;QACrB,OAAO;YACH,IAAI;YACJA;SACH;IACL,CAAC;IACD,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,OAAM,EAAGC,SAAQ,EAAG,GAAGC,MAAM,GAAGR;IAC5C,MAAMS,iBAAiBC,IAAAA,cAAM,EAACV,SAASA,KAAK,CAACW,sCAA2B,CAAC,GAAGP,SAAS;IACrF,MAAML,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,IAAIW,kBAAkB,OAAOF,aAAa,YAAY;QAClD,MAAMK,SAASH,kBAAkBF;QACjC,OAAO;YACHM,OAAMC,QAAQ;YACd;gBACIP,UAAUK,OAAOb,MAAMS;YAC3B;SACH;IACL,CAAC;IACD,MAAMO,mBAAmB,OAAOhB,SAAS,YAAYO;IACrD,MAAMb,YAAYsB,mBAAmBC,IAAAA,UAAI,EAAChB,OAAO;QAC7C;KACH,IAAIA,KAAK;IACV,OAAO;QACHD;QACAN;KACH;AACL"}
|
@@ -2,10 +2,18 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
+
Object.defineProperty(exports, "slot", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>_slot
|
8
|
+
});
|
5
9
|
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
10
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
11
|
+
const _slot = /*#__PURE__*/ _interopRequireWildcard(require("./slot"));
|
6
12
|
_exportStar(require("./getSlots"), exports);
|
7
13
|
_exportStar(require("./resolveShorthand"), exports);
|
8
14
|
_exportStar(require("./types"), exports);
|
9
15
|
_exportStar(require("./isResolvedShorthand"), exports);
|
10
16
|
_exportStar(require("./constants"), exports);
|
11
17
|
_exportStar(require("./getSlotsNext"), exports);
|
18
|
+
_exportStar(require("./isSlot"), exports);
|
19
|
+
_exportStar(require("./assertSlots"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["import * as slot from './slot';\nexport * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\nexport * from './constants';\nexport * from './getSlotsNext';\nexport * from './isSlot';\nexport * from './assertSlots';\nexport { slot };\n"],"names":["slot"],"mappings":";;;;+BASSA;;aAAAA;;;;4DATa;oBACR;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "isSlot", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>isSlot
|
8
|
+
});
|
9
|
+
const _constants = require("./constants");
|
10
|
+
function isSlot(element) {
|
11
|
+
return Boolean(element === null || element === void 0 ? void 0 : element.hasOwnProperty(_constants.SLOT_ELEMENT_TYPE_SYMBOL));
|
12
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["isSlot.js"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\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 */ export function isSlot(element) {\n return Boolean(element === null || element === void 0 ? void 0 : element.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));\n}\n"],"names":["isSlot","element","Boolean","hasOwnProperty","SLOT_ELEMENT_TYPE_SYMBOL"],"mappings":";;;;+BAIoBA;;aAAAA;;2BAJqB;AAI9B,SAASA,OAAOC,OAAO,EAAE;IAChC,OAAOC,QAAQD,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQE,cAAc,CAACC,mCAAwB,CAAC;AACrH"}
|
@@ -6,27 +6,14 @@ Object.defineProperty(exports, "resolveShorthand", {
|
|
6
6
|
enumerable: true,
|
7
7
|
get: ()=>resolveShorthand
|
8
8
|
});
|
9
|
-
const
|
10
|
-
const
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _slot = /*#__PURE__*/ _interopRequireWildcard(require("./slot"));
|
11
11
|
const resolveShorthand = (value, options)=>{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
resolvedShorthand.children = value;
|
20
|
-
} else if (typeof value === 'object') {
|
21
|
-
resolvedShorthand = value;
|
22
|
-
}
|
23
|
-
resolvedShorthand = {
|
24
|
-
...defaultProps,
|
25
|
-
...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;
|
12
|
+
return _slot.optional(value, {
|
13
|
+
...options,
|
14
|
+
renderByDefault: options === null || options === void 0 ? void 0 : options.required,
|
15
|
+
// elementType as undefined is the way to identify between a slot and a resolveShorthand call
|
16
|
+
// in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.
|
17
|
+
elementType: undefined
|
18
|
+
});
|
32
19
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["resolveShorthand.js"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["resolveShorthand.js"],"sourcesContent":["import * as slot from './slot';\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 */ export const resolveShorthand = (value, options)=>{\n return slot.optional(value, {\n ...options,\n renderByDefault: options === null || options === void 0 ? void 0 : 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};\n"],"names":["resolveShorthand","value","options","slot","optional","renderByDefault","required","elementType","undefined"],"mappings":";;;;+BAMiBA;;aAAAA;;;4DANK;AAMX,MAAMA,mBAAmB,CAACC,OAAOC,UAAU;IAClD,OAAOC,MAAKC,QAAQ,CAACH,OAAO;QACxB,GAAGC,OAAO;QACVG,iBAAiBH,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQI,QAAQ;QACnF,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACjB;AACJ"}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
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
|
+
always: ()=>always,
|
13
|
+
optional: ()=>optional,
|
14
|
+
resolveShorthand: ()=>resolveShorthand
|
15
|
+
});
|
16
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
17
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
18
|
+
const _constants = require("./constants");
|
19
|
+
function always(value, options) {
|
20
|
+
const { defaultProps , elementType } = options;
|
21
|
+
const props = resolveShorthand(value);
|
22
|
+
/**
|
23
|
+
* Casting is required here as SlotComponentType is a function, not an object.
|
24
|
+
* Although SlotComponentType has a function signature, it is still just an object.
|
25
|
+
* This is required to make a slot callable (JSX compatible), this is the exact same approach
|
26
|
+
* that is used on `@types/react` components
|
27
|
+
*/ const propsWithMetadata = {
|
28
|
+
...defaultProps,
|
29
|
+
...props,
|
30
|
+
[_constants.SLOT_ELEMENT_TYPE_SYMBOL]: elementType
|
31
|
+
};
|
32
|
+
if (props && typeof props.children === 'function') {
|
33
|
+
propsWithMetadata[_constants.SLOT_RENDER_FUNCTION_SYMBOL] = props.children;
|
34
|
+
propsWithMetadata.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;
|
35
|
+
}
|
36
|
+
return propsWithMetadata;
|
37
|
+
}
|
38
|
+
function optional(value, options) {
|
39
|
+
if (value === null || value === undefined && !options.renderByDefault) {
|
40
|
+
return undefined;
|
41
|
+
}
|
42
|
+
return always(value, options);
|
43
|
+
}
|
44
|
+
function resolveShorthand(value) {
|
45
|
+
if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
46
|
+
/*#__PURE__*/ _react.isValidElement(value)) {
|
47
|
+
return {
|
48
|
+
children: value
|
49
|
+
};
|
50
|
+
}
|
51
|
+
if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {
|
52
|
+
// TODO: would be nice to have a link to slot documentation in this error message
|
53
|
+
// eslint-disable-next-line no-console
|
54
|
+
console.error([
|
55
|
+
`[slot.resolveShorthand]: A slot got invalid value "${value}" (${typeof value}).`,
|
56
|
+
'A valid value is a slot shorthand or slot properties object.',
|
57
|
+
'Slot shorthands can be strings, numbers, arrays or JSX elements'
|
58
|
+
].join('\n'));
|
59
|
+
}
|
60
|
+
return value;
|
61
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["slot.js"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\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 */ export function always(value, options) {\n const { defaultProps , elementType } = options;\n const props = resolveShorthand(value);\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 */ const propsWithMetadata = {\n ...defaultProps,\n ...props,\n [SLOT_ELEMENT_TYPE_SYMBOL]: elementType\n };\n if (props && typeof props.children === 'function') {\n propsWithMetadata[SLOT_RENDER_FUNCTION_SYMBOL] = props.children;\n propsWithMetadata.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;\n }\n return propsWithMetadata;\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 */ export function optional(value, options) {\n if (value === null || value === undefined && !options.renderByDefault) {\n return undefined;\n }\n return always(value, options);\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 */ export function resolveShorthand(value) {\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.isValidElement(value)) {\n return {\n children: value\n };\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([\n `[slot.resolveShorthand]: A slot got invalid value \"${value}\" (${typeof value}).`,\n 'A valid value is a slot shorthand or slot properties object.',\n 'Slot shorthands can be strings, numbers, arrays or JSX elements'\n ].join('\\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","join"],"mappings":";;;;;;;;;;;IASoBA,MAAM,MAANA;IA+BAC,QAAQ,MAARA;IAUAC,gBAAgB,MAAhBA;;;6DAlDG;2BAC+C;AAQ3D,SAASF,OAAOG,KAAK,EAAEC,OAAO,EAAE;IACvC,MAAM,EAAEC,aAAY,EAAGC,YAAW,EAAG,GAAGF;IACxC,MAAMG,QAAQL,iBAAiBC;IAC/B;;;;;GAKD,GAAG,MAAMK,oBAAoB;QACxB,GAAGH,YAAY;QACf,GAAGE,KAAK;QACR,CAACE,mCAAwB,CAAC,EAAEH;IAChC;IACA,IAAIC,SAAS,OAAOA,MAAMG,QAAQ,KAAK,YAAY;QAC/CF,iBAAiB,CAACG,sCAA2B,CAAC,GAAGJ,MAAMG,QAAQ;QAC/DF,kBAAkBE,QAAQ,GAAGL,iBAAiB,IAAI,IAAIA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAaK,QAAQ;IAClH,CAAC;IACD,OAAOF;AACX;AAaW,SAASP,SAASE,KAAK,EAAEC,OAAO,EAAE;IACzC,IAAID,UAAU,IAAI,IAAIA,UAAUS,aAAa,CAACR,QAAQS,eAAe,EAAE;QACnE,OAAOD;IACX,CAAC;IACD,OAAOZ,OAAOG,OAAOC;AACzB;AAKW,SAASF,iBAAiBC,KAAK,EAAE;IACxC,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,YAAYW,MAAMC,OAAO,CAACZ,UAAU,8DAA8D;kBACpJa,OAAMC,cAAc,CAACd,QAAQ;QACzB,OAAO;YACHO,UAAUP;QACd;IACJ,CAAC;IACD,IAAIA,SAAS,OAAOA,UAAU,YAAYe,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC7E,iFAAiF;QACjF,sCAAsC;QACtCC,QAAQC,KAAK,CAAC;YACV,CAAC,mDAAmD,EAAEnB,MAAM,GAAG,EAAE,OAAOA,MAAM,EAAE,CAAC;YACjF;YACA;SACH,CAACoB,IAAI,CAAC;IACX,CAAC;IACD,OAAOpB;AACX"}
|
package/lib-commonjs/index.js
CHANGED
@@ -9,10 +9,14 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
+
slot: ()=>_index.slot,
|
13
|
+
isSlot: ()=>_index.isSlot,
|
12
14
|
getSlots: ()=>_index.getSlots,
|
13
15
|
getSlotsNext: ()=>_index.getSlotsNext,
|
16
|
+
assertSlots: ()=>_index.assertSlots,
|
14
17
|
resolveShorthand: ()=>_index.resolveShorthand,
|
15
18
|
isResolvedShorthand: ()=>_index.isResolvedShorthand,
|
19
|
+
SLOT_ELEMENT_TYPE_SYMBOL: ()=>_index.SLOT_ELEMENT_TYPE_SYMBOL,
|
16
20
|
SLOT_RENDER_FUNCTION_SYMBOL: ()=>_index.SLOT_RENDER_FUNCTION_SYMBOL,
|
17
21
|
IdPrefixProvider: ()=>_index1.IdPrefixProvider,
|
18
22
|
resetIdsForTests: ()=>_index1.resetIdsForTests,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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, createPriorityQueue } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\nexport { useSelection } from './selection/index';\n"],"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","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":";;;;;;;;;;;IAASA,QAAQ,MAARA,eAAQ;IAAEC,YAAY,MAAZA,mBAAY;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAAEC,2BAA2B,MAA3BA,kCAA2B;
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, 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, createPriorityQueue } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","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","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":";;;;;;;;;;;IAASA,IAAI,MAAJA,WAAI;IAAEC,MAAM,MAANA,aAAM;IAAEC,QAAQ,MAARA,eAAQ;IAAEC,YAAY,MAAZA,mBAAY;IAAEC,WAAW,MAAXA,kBAAW;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAAEC,wBAAwB,MAAxBA,+BAAwB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAC/IC,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;IAAEC,mBAAmB,MAAnBA,2BAAmB;IAC1JC,2BAA2B,MAA3BA,mCAA2B;IAAEC,eAAe,MAAfA,uBAAe;IAAEC,eAAe,MAAfA,uBAAe;IAC7DC,YAAY,MAAZA,oBAAY;IAAEC,YAAY,MAAZA,oBAAY;IAAEC,oBAAoB,MAApBA,4BAAoB;IAChDC,YAAY,MAAZA,oBAAY;;uBAN2I;wBAC8F;wBAC7M;wBAC0H;wBAC7F;wBACb;wBACpC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.11.1",
|
4
4
|
"description": "A set of general React-specific utilities.",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"license": "MIT",
|
14
14
|
"scripts": {
|
15
15
|
"build": "just-scripts build",
|
16
|
-
"bundle-size": "
|
16
|
+
"bundle-size": "monosize measure",
|
17
17
|
"clean": "just-scripts clean",
|
18
18
|
"code-style": "just-scripts code-style",
|
19
19
|
"just": "just-scripts",
|