@fluentui/react-utilities 9.17.0 → 9.18.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.md +20 -2
- package/lib/compose/assertSlots.js +1 -1
- package/lib/compose/assertSlots.js.map +1 -1
- package/lib/virtualParent/getParent.js +5 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/compose/assertSlots.js +2 -2
- package/lib-commonjs/compose/assertSlots.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +5 -1
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,30 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on Tue,
|
3
|
+
This log was last generated on Tue, 20 Feb 2024 14:15:32 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.18.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.18.1)
|
8
|
+
|
9
|
+
Tue, 20 Feb 2024 14:15:32 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.18.0..@fluentui/react-utilities_v9.18.1)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- fix: Remove import cycle between assertSlots.ts and index.ts ([PR #30555](https://github.com/microsoft/fluentui/pull/30555) by behowell@microsoft.com)
|
15
|
+
|
16
|
+
## [9.18.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.18.0)
|
17
|
+
|
18
|
+
Tue, 30 Jan 2024 23:16:54 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.17.0..@fluentui/react-utilities_v9.18.0)
|
20
|
+
|
21
|
+
### Minor changes
|
22
|
+
|
23
|
+
- getParent() version with ShadowDOM support. ([PR #30429](https://github.com/microsoft/fluentui/pull/30429) by marata@microsoft.com)
|
24
|
+
|
7
25
|
## [9.17.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.17.0)
|
8
26
|
|
9
|
-
Tue, 23 Jan 2024 15:
|
27
|
+
Tue, 23 Jan 2024 15:11:00 GMT
|
10
28
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.16.1..@fluentui/react-utilities_v9.17.0)
|
11
29
|
|
12
30
|
### Minor changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';
|
3
3
|
import { isSlot } from './isSlot';
|
4
|
-
import
|
4
|
+
import * as slot from './slot';
|
5
5
|
/**
|
6
6
|
* @internal
|
7
7
|
* Assertion method to ensure state slots properties are properly declared.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport
|
1
|
+
{"version":3,"sources":["assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport * as slot from './slot';\n\ntype SlotComponents<Slots extends SlotPropsRecord> = {\n [K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>>;\n};\n\n/**\n * @internal\n * Assertion method to ensure state slots properties are properly declared.\n * A properly declared slot must be declared by using the `slot` method.\n *\n * @example\n * ```tsx\n * export const renderInput_unstable = (state: InputState) => {\n assertSlots<InputSlots>(state);\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && <state.contentAfter />}\n </state.root>\n );\n };\n * ```\n */\nexport function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots> {\n /**\n * This verification is not necessary in production\n * as we're verifying static properties that will not change between environments\n */\n if (process.env.NODE_ENV !== 'production') {\n const typedState = state as ComponentState<Slots>;\n for (const slotName of Object.keys(typedState.components)) {\n const slotElement = typedState[slotName];\n if (slotElement === undefined) {\n continue;\n }\n // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName as keyof ComponentState<Slots>] = slot.always(slotElement, {\n elementType: typedState.components[slotName] as React.ComponentType<{}>,\n }) as ComponentState<Slots>[keyof ComponentState<Slots>];\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" is not a slot!\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\".\n `);\n } else {\n // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n if (elementType !== typedState.components[slotName]) {\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName] as React.ComponentType<{}>;\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" element type differs from \"state.components.${slotName}\",\n ${elementType} !== ${typedState.components[slotName]}.\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\" with the correct elementType.\n `);\n }\n }\n }\n }\n}\n"],"names":["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;AA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
|
}
|
22
|
-
|
22
|
+
const parent = child.parentNode;
|
23
|
+
if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
24
|
+
return parent.host;
|
25
|
+
}
|
26
|
+
return parent;
|
23
27
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n * @internal\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n * @internal\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n * @internal\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n
|
1
|
+
{"version":3,"sources":["getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n * @internal\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n * @internal\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n * @internal\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n const parent = child.parentNode;\n\n if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n return (parent as ShadowRoot).host;\n }\n\n return parent;\n}\n"],"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode","nodeType","Node","DOCUMENT_FRAGMENT_NODE","host"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB;AAUtD;;;CAGC,GACD,SAASC,iBAAiBC,KAAW;IACnC,OAAOF,iBAAiBE,SAASA,MAAMC,QAAQ,CAACC,MAAM,IAAI,OAAO;AACnE;AAEA;;;;CAIC,GACD,OAAO,SAASC,UAAUH,KAAkB,EAAEI,UAA4B,CAAC,CAAC;IAC1E,IAAI,CAACJ,OAAO;QACV,OAAO;IACT;IAEA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QAEvC,IAAIM,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,MAAMJ,SAASF,MAAMO,UAAU;IAE/B,IAAIL,UAAUA,OAAOM,QAAQ,KAAKC,KAAKC,sBAAsB,EAAE;QAC7D,OAAO,AAACR,OAAsBS,IAAI;IACpC;IAEA,OAAOT;AACT"}
|
@@ -12,7 +12,7 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
13
|
const _constants = require("./constants");
|
14
14
|
const _isSlot = require("./isSlot");
|
15
|
-
const
|
15
|
+
const _slot = /*#__PURE__*/ _interop_require_wildcard._(require("./slot"));
|
16
16
|
function assertSlots(state) {
|
17
17
|
/**
|
18
18
|
* This verification is not necessary in production
|
@@ -28,7 +28,7 @@ function assertSlots(state) {
|
|
28
28
|
// 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
|
29
29
|
// FIXME: this slot will still fail to support child render function scenario
|
30
30
|
if (!(0, _isSlot.isSlot)(slotElement)) {
|
31
|
-
typedState[slotName] =
|
31
|
+
typedState[slotName] = _slot.always(slotElement, {
|
32
32
|
elementType: typedState.components[slotName]
|
33
33
|
});
|
34
34
|
// eslint-disable-next-line no-console
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["assertSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport
|
1
|
+
{"version":3,"sources":["assertSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport * as slot from './slot';\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(`@fluentui/react-utilities [${assertSlots.name}]:\n\"state.${slotName}\" is not a slot!\nBe 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(`@fluentui/react-utilities [${assertSlots.name}]:\n\"state.${slotName}\" element type differs from \"state.components.${slotName}\",\n${elementType} !== ${typedState.components[slotName]}.\nBe 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;;;eAAAA;;;;iEAtBG;2BACkB;wBAClB;gEACD;AAmBX,SAASA,YAAYC,KAAK;IACjC;;;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;YACJ;YACA,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACC,IAAAA,cAAM,EAACF,cAAc;gBACtBL,UAAU,CAACC,SAAS,GAAGO,MAAKC,MAAM,CAACJ,aAAa;oBAC5CK,aAAaV,WAAWI,UAAU,CAACH,SAAS;gBAChD;gBACA,sCAAsC;gBACtCU,QAAQC,IAAI,CAAC,CAAC,2BAA2B,EAAEjB,YAAYkB,IAAI,CAAC;OACrE,EAAEZ,SAAS;2EACyD,CAAC;YAChE,OAAO;gBACH,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACa,mCAAwB,CAAC,EAAEJ,WAAW,EAAE,GAAGL;gBACpD,IAAIK,gBAAgBV,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACjDI,WAAW,CAACS,mCAAwB,CAAC,GAAGd,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCU,QAAQC,IAAI,CAAC,CAAC,2BAA2B,EAAEjB,YAAYkB,IAAI,CAAC;OACzE,EAAEZ,SAAS,8CAA8C,EAAEA,SAAS;AAC3E,EAAES,YAAY,KAAK,EAAEV,WAAWI,UAAU,CAACH,SAAS,CAAC;wGACmD,CAAC;gBACzF;YACJ;QACJ;IACJ;AACJ"}
|
@@ -25,5 +25,9 @@ function getParent(child, options = {}) {
|
|
25
25
|
return virtualParent;
|
26
26
|
}
|
27
27
|
}
|
28
|
-
|
28
|
+
const parent = child.parentNode;
|
29
|
+
if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
30
|
+
return parent.host;
|
31
|
+
}
|
32
|
+
return parent;
|
29
33
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n * @internal\n */ function getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n * @internal\n */ export function getParent(child, options = {}) {\n if (!child) {\n return null;\n }\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n if (virtualParent) {\n return virtualParent;\n }\n }\n
|
1
|
+
{"version":3,"sources":["getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n * @internal\n */ function getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n * @internal\n */ export function getParent(child, options = {}) {\n if (!child) {\n return null;\n }\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n if (virtualParent) {\n return virtualParent;\n }\n }\n const parent = child.parentNode;\n if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n return parent.host;\n }\n return parent;\n}\n"],"names":["getParent","getVirtualParent","child","isVirtualElement","_virtual","parent","options","skipVirtual","virtualParent","parentNode","nodeType","Node","DOCUMENT_FRAGMENT_NODE","host"],"mappings":";;;;+BAWoBA;;;eAAAA;;;kCAXa;AACjC;;;CAGC,GAAG,SAASC,iBAAiBC,KAAK;IAC/B,OAAOC,IAAAA,kCAAgB,EAACD,SAASA,MAAME,QAAQ,CAACC,MAAM,IAAI,OAAO;AACrE;AAKW,SAASL,UAAUE,KAAK,EAAEI,UAAU,CAAC,CAAC;IAC7C,IAAI,CAACJ,OAAO;QACR,OAAO;IACX;IACA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACtB,MAAMC,gBAAgBP,iBAAiBC;QACvC,IAAIM,eAAe;YACf,OAAOA;QACX;IACJ;IACA,MAAMH,SAASH,MAAMO,UAAU;IAC/B,IAAIJ,UAAUA,OAAOK,QAAQ,KAAKC,KAAKC,sBAAsB,EAAE;QAC3D,OAAOP,OAAOQ,IAAI;IACtB;IACA,OAAOR;AACX"}
|