@fluentui/react-utilities 9.11.1 → 9.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,22 @@
|
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Wed, 23 Aug 2023 11:58:32 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v9.11.2",
|
7
|
+
"version": "9.11.2",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
12
|
+
"package": "@fluentui/react-utilities",
|
13
|
+
"commit": "f94b6d05d7642563cb96e2718402fbbbab65cbbc",
|
14
|
+
"comment": "bugfix: ensure interop between assertSlots and old API"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"date": "Fri, 11 Aug 2023 12:14:25 GMT",
|
6
21
|
"tag": "@fluentui/react-utilities_v9.11.1",
|
7
22
|
"version": "9.11.1",
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 23 Aug 2023 11:58:32 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.11.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.11.2)
|
8
|
+
|
9
|
+
Wed, 23 Aug 2023 11:58:32 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.11.1..@fluentui/react-utilities_v9.11.2)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- bugfix: ensure interop between assertSlots and old API ([PR #28957](https://github.com/microsoft/fluentui/pull/28957) by bernardo.sunderhus@gmail.com)
|
15
|
+
|
7
16
|
## [9.11.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.11.1)
|
8
17
|
|
9
|
-
Fri, 11 Aug 2023 12:
|
18
|
+
Fri, 11 Aug 2023 12:14:25 GMT
|
10
19
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.11.0..@fluentui/react-utilities_v9.11.1)
|
11
20
|
|
12
21
|
### Patches
|
@@ -1,5 +1,7 @@
|
|
1
|
+
import * as React from 'react';
|
1
2
|
import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';
|
2
3
|
import { isSlot } from './isSlot';
|
4
|
+
import { slot } from './index';
|
3
5
|
/**
|
4
6
|
* @internal
|
5
7
|
* Assertion method to ensure state slots properties are properly declared.
|
@@ -29,12 +31,23 @@ import { isSlot } from './isSlot';
|
|
29
31
|
if (slotElement === undefined) {
|
30
32
|
continue;
|
31
33
|
}
|
34
|
+
// this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,
|
35
|
+
// but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
|
36
|
+
// FIXME: this slot will still fail to support child render function scenario
|
32
37
|
if (!isSlot(slotElement)) {
|
33
|
-
|
38
|
+
typedState[slotName] = slot.always(slotElement, {
|
39
|
+
elementType: typedState.components[slotName]
|
40
|
+
});
|
41
|
+
// eslint-disable-next-line no-console
|
42
|
+
console.warn(`${assertSlots.name} warning: state.${slotName} is not a slot.\n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`);
|
34
43
|
} else {
|
44
|
+
// This means a slot is being declared by using resolveShorthand on the state hook,
|
45
|
+
// but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
|
35
46
|
const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;
|
36
47
|
if (elementType !== typedState.components[slotName]) {
|
37
|
-
|
48
|
+
slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName];
|
49
|
+
// eslint-disable-next-line no-console
|
50
|
+
console.warn(`${assertSlots.name} warning: 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
51
|
}
|
39
52
|
}
|
40
53
|
}
|
@@ -1 +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
|
1
|
+
{"version":3,"sources":["assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport { slot } from './index';\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 // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName as keyof ComponentState<Slots>] = slot.always(slotElement, {\n elementType: typedState.components[slotName] as React.ComponentType<{}>,\n }) as ComponentState<Slots>[keyof ComponentState<Slots>];\n // eslint-disable-next-line no-console\n console.warn(\n `${assertSlots.name} warning: 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 // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName] as React.ComponentType<{}>;\n // eslint-disable-next-line no-console\n console.warn(\n `${assertSlots.name} warning: 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":["React","SLOT_ELEMENT_TYPE_SYMBOL","isSlot","slot","assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","always","elementType","console","warn","name"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ,cAAc;AACvD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,IAAI,QAAQ,UAAU;AAM/B;;;;;;;;;;;;;;;;;;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,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACb,OAAOY,cAAc;gBACxBL,UAAU,CAACC,SAAwC,GAAGP,KAAKa,MAAM,CAACF,aAAa;oBAC7EG,aAAaR,WAAWI,UAAU,CAACH,SAAS;gBAC9C;gBACA,sCAAsC;gBACtCQ,QAAQC,IAAI,CACV,CAAC,EAAEf,YAAYgB,IAAI,CAAC,gBAAgB,EAAEV,SAAS,iBAAiB,CAAC,GAC/D,CAAC,2EAA2E,CAAC;YAEnF,OAAO;gBACL,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACT,yBAAyB,EAAEgB,YAAW,EAAE,GAAGH;gBACpD,IAAIG,gBAAgBR,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACnDI,WAAW,CAACb,yBAAyB,GAAGQ,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCQ,QAAQC,IAAI,CACV,CAAC,EAAEf,YAAYgB,IAAI,CAAC,gBAAgB,EAAEV,SAAS,4CAA4C,EAAEA,SAAS,EAAE,EAAEO,YAAY,KAAK,EAAER,WAAWI,UAAU,CAACH,SAAS,CAAC,IAAI,CAAC,GAChK,CAAC,uGAAuG,CAAC;gBAE/G,CAAC;YACH,CAAC;QACH;IACF,CAAC;AACH,CAAC"}
|
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "assertSlots", {
|
|
6
6
|
enumerable: true,
|
7
7
|
get: ()=>assertSlots
|
8
8
|
});
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
9
11
|
const _constants = require("./constants");
|
10
12
|
const _isSlot = require("./isSlot");
|
13
|
+
const _index = require("./index");
|
11
14
|
function assertSlots(state) {
|
12
15
|
/**
|
13
16
|
* This verification is not necessary in production
|
@@ -19,12 +22,23 @@ function assertSlots(state) {
|
|
19
22
|
if (slotElement === undefined) {
|
20
23
|
continue;
|
21
24
|
}
|
25
|
+
// this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,
|
26
|
+
// but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
|
27
|
+
// FIXME: this slot will still fail to support child render function scenario
|
22
28
|
if (!(0, _isSlot.isSlot)(slotElement)) {
|
23
|
-
|
29
|
+
typedState[slotName] = _index.slot.always(slotElement, {
|
30
|
+
elementType: typedState.components[slotName]
|
31
|
+
});
|
32
|
+
// eslint-disable-next-line no-console
|
33
|
+
console.warn(`${assertSlots.name} warning: state.${slotName} is not a slot.\n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`);
|
24
34
|
} else {
|
35
|
+
// This means a slot is being declared by using resolveShorthand on the state hook,
|
36
|
+
// but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
|
25
37
|
const { [_constants.SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;
|
26
38
|
if (elementType !== typedState.components[slotName]) {
|
27
|
-
|
39
|
+
slotElement[_constants.SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName];
|
40
|
+
// eslint-disable-next-line no-console
|
41
|
+
console.warn(`${assertSlots.name} warning: 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
42
|
}
|
29
43
|
}
|
30
44
|
}
|
@@ -1 +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
|
1
|
+
{"version":3,"sources":["assertSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { slot } from './index';\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 // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName] = slot.always(slotElement, {\n elementType: typedState.components[slotName]\n });\n // eslint-disable-next-line no-console\n console.warn(`${assertSlots.name} warning: state.${slotName} is not a slot.\\n` + `Be sure to create slots properly by using 'slot.always' or 'slot.optional'.`);\n } else {\n // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName];\n // eslint-disable-next-line no-console\n console.warn(`${assertSlots.name} warning: 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","slot","always","elementType","console","warn","name","SLOT_ELEMENT_TYPE_SYMBOL"],"mappings":";;;;+BAsBoBA;;aAAAA;;;6DAtBG;2BACkB;wBAClB;uBACF;AAmBV,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,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACC,IAAAA,cAAM,EAACF,cAAc;gBACtBL,UAAU,CAACC,SAAS,GAAGO,WAAI,CAACC,MAAM,CAACJ,aAAa;oBAC5CK,aAAaV,WAAWI,UAAU,CAACH,SAAS;gBAChD;gBACA,sCAAsC;gBACtCU,QAAQC,IAAI,CAAC,CAAC,EAAEjB,YAAYkB,IAAI,CAAC,gBAAgB,EAAEZ,SAAS,iBAAiB,CAAC,GAAG,CAAC,2EAA2E,CAAC;YAClK,OAAO;gBACH,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACa,mCAAwB,CAAC,EAAEJ,YAAW,EAAG,GAAGL;gBACrD,IAAIK,gBAAgBV,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACjDI,WAAW,CAACS,mCAAwB,CAAC,GAAGd,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCU,QAAQC,IAAI,CAAC,CAAC,EAAEjB,YAAYkB,IAAI,CAAC,gBAAgB,EAAEZ,SAAS,4CAA4C,EAAEA,SAAS,EAAE,EAAES,YAAY,KAAK,EAAEV,WAAWI,UAAU,CAACH,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,uGAAuG,CAAC;gBAC/R,CAAC;YACL,CAAC;QACL;IACJ,CAAC;AACL"}
|