@fluentui/react-utilities 0.0.0-nightly-20240607-1142.1 → 0.0.0-nightly-20240610-0945.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 +6 -6
- package/dist/index.d.ts +3 -3
- package/lib/compose/deprecated/getSlots.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +10 -1
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +8 -0
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Mon, 10 Jun 2024 10:03:58 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20240610-0945.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightly-20240610-0945.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.18.10..@fluentui/react-utilities_v0.0.0-nightly-
|
9
|
+
Mon, 10 Jun 2024 10:03:58 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.18.10..@fluentui/react-utilities_v0.0.0-nightly-20240610-0945.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20240610-0945.1 ([commit](https://github.com/microsoft/fluentui/commit/1ee1b563223767c589678be98ff0f9fa55554361) by beachball)
|
16
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20240610-0945.1 ([commit](https://github.com/microsoft/fluentui/commit/1ee1b563223767c589678be98ff0f9fa55554361) by beachball)
|
17
17
|
|
18
18
|
## [9.18.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.18.10)
|
19
19
|
|
package/dist/index.d.ts
CHANGED
@@ -507,7 +507,7 @@ export declare type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;
|
|
507
507
|
* @deprecated - use slot.always or slot.optional combined with assertSlots instead
|
508
508
|
*/
|
509
509
|
declare type ObjectSlotProps<S extends SlotPropsRecord> = {
|
510
|
-
[K in keyof S]-?:
|
510
|
+
[K in keyof S]-?: any;
|
511
511
|
};
|
512
512
|
|
513
513
|
/**
|
@@ -816,7 +816,7 @@ export declare type SlotRenderFunction<Props> = (Component: React_2.ElementType<
|
|
816
816
|
* @deprecated - use slot.always or slot.optional combined with assertSlots instead
|
817
817
|
*/
|
818
818
|
export declare type Slots<S extends SlotPropsRecord> = {
|
819
|
-
[K in keyof S]:
|
819
|
+
[K in keyof S]: React_2.ElementType<any>;
|
820
820
|
};
|
821
821
|
|
822
822
|
/**
|
@@ -977,7 +977,7 @@ export declare function useIsSSR(): boolean;
|
|
977
977
|
* @param refs - Refs to collectively update with one ref value.
|
978
978
|
* @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
|
979
979
|
*/
|
980
|
-
export declare function useMergedRefs<T>(...refs: (React_2.
|
980
|
+
export declare function useMergedRefs<T>(...refs: (React_2.LegacyRef<T> | undefined)[]): RefObjectFunction<T>;
|
981
981
|
|
982
982
|
/**
|
983
983
|
* @internal
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../../utils/omit';\nimport type {
|
1
|
+
{"version":3,"sources":["getSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../../utils/omit';\nimport type { ComponentState, SlotPropsRecord, SlotRenderFunction, UnknownSlotProps } from '../types';\nimport { isSlot } from '../isSlot';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '../constants';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type Slots<S extends SlotPropsRecord> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof S]: React.ElementType<any>;\n};\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ObjectSlotProps<S extends SlotPropsRecord> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof S]-?: any; // Slot<ButtonProps>\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: unknown,\n): {\n // eslint-disable-next-line deprecation/deprecation\n slots: Slots<R>;\n // eslint-disable-next-line deprecation/deprecation\n slotProps: ObjectSlotProps<R>;\n} {\n const typeState = state as ComponentState<R>;\n // eslint-disable-next-line deprecation/deprecation\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n // eslint-disable-next-line deprecation/deprecation\n const slotNames: (keyof R)[] = Object.keys(typeState.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(typeState, slotName);\n // eslint-disable-next-line deprecation/deprecation\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line deprecation/deprecation\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, children, ...rest } = props as NonUndefined<typeof props>;\n\n const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;\n\n const slot = (\n state.components?.[slotName] === undefined || // eslint-disable-line deprecation/deprecation\n // eslint-disable-next-line deprecation/deprecation\n typeof state.components[slotName] === 'string'\n ? // eslint-disable-next-line deprecation/deprecation\n asProp || state.components?.[slotName] || 'div'\n : // eslint-disable-next-line deprecation/deprecation\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 as React.ElementType<R[K]>,\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 // eslint-disable-next-line deprecation/deprecation\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","typeState","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,mBAAmB;AAExC,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,2BAA2B,QAAQ,eAAe;AAkB3D;;;;;;;;;;;;;;;;;;CAkBC,GACD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ACnD,MAAMX,YAAaiB,mBAAmBxB,KAAKc,OAAO;QAAC;KAAK,IAAKA;IAC7D,OAAO;QAACD;QAAMN;KAAU;AAC1B"}
|
@@ -4,11 +4,20 @@ import * as React from 'react';
|
|
4
4
|
* updates all provided refs
|
5
5
|
* @param refs - Refs to collectively update with one ref value.
|
6
6
|
* @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
|
7
|
-
*/
|
7
|
+
*/ // LegacyRef is actually not supported, but in React v18 types this is leaking directly from forwardRef component declaration
|
8
|
+
export function useMergedRefs(...refs) {
|
8
9
|
const mergedCallback = React.useCallback((value)=>{
|
9
10
|
// Update the "current" prop hanging on the function.
|
10
11
|
mergedCallback.current = value;
|
11
12
|
for (const ref of refs){
|
13
|
+
if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {
|
14
|
+
// eslint-disable-next-line no-console
|
15
|
+
console.error(`@fluentui/react-utilities [useMergedRefs]:
|
16
|
+
This hook does not support the usage of string refs. Please use React.useRef instead.
|
17
|
+
|
18
|
+
For more info on 'React.useRef', see https://react.dev/reference/react/useRef.
|
19
|
+
For more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.`);
|
20
|
+
}
|
12
21
|
if (typeof ref === 'function') {
|
13
22
|
ref(value);
|
14
23
|
} else if (ref) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMergedRefs.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.
|
1
|
+
{"version":3,"sources":["useMergedRefs.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/** @internal */\ntype MutableRefObjectFunction<T> = React.MutableRefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\n// LegacyRef is actually not supported, but in React v18 types this is leaking directly from forwardRef component declaration\nexport function useMergedRefs<T>(...refs: (React.LegacyRef<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback = React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n mergedCallback.current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useMergedRefs]:\n This hook does not support the usage of string refs. Please use React.useRef instead.\n\n For more info on 'React.useRef', see https://react.dev/reference/react/useRef.\n For more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.\n `);\n }\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n (ref as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as MutableRefObjectFunction<T>;\n\n return mergedCallback;\n}\n"],"names":["React","useMergedRefs","refs","mergedCallback","useCallback","value","current","ref","process","env","NODE_ENV","console","error"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAW/B;;;;;CAKC,GACD,6HAA6H;AAC7H,OAAO,SAASC,cAAiB,GAAGC,IAAwC;IAC1E,MAAMC,iBAAiBH,MAAMI,WAAW,CACtC,CAACC;QACC,qDAAqD;QACrDF,eAAeG,OAAO,GAAGD;QAEzB,KAAK,MAAME,OAAOL,KAAM;YACtB,IAAI,OAAOK,QAAQ,YAAYC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBACpE,sCAAsC;gBACtCC,QAAQC,KAAK,CAAuB,CAAC;;;;+GAMrC,CAAC;YACH;YACA,IAAI,OAAOL,QAAQ,YAAY;gBAC7BA,IAAIF;YACN,OAAO,IAAIE,KAAK;gBACd,qDAAqD;gBACpDA,IAAkCD,OAAO,GAAGD;YAC/C;QACF;IACF,GACA,6EAA6E;IAC7E;WAAIH;KAAK;IAGX,OAAOC;AACT"}
|
@@ -15,6 +15,14 @@ function useMergedRefs(...refs) {
|
|
15
15
|
// Update the "current" prop hanging on the function.
|
16
16
|
mergedCallback.current = value;
|
17
17
|
for (const ref of refs){
|
18
|
+
if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {
|
19
|
+
// eslint-disable-next-line no-console
|
20
|
+
console.error(`@fluentui/react-utilities [useMergedRefs]:
|
21
|
+
This hook does not support the usage of string refs. Please use React.useRef instead.
|
22
|
+
|
23
|
+
For more info on 'React.useRef', see https://react.dev/reference/react/useRef.
|
24
|
+
For more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.`);
|
25
|
+
}
|
18
26
|
if (typeof ref === 'function') {
|
19
27
|
ref(value);
|
20
28
|
} else if (ref) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMergedRefs.js"],"sourcesContent":["import * as React from 'react';\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */
|
1
|
+
{"version":3,"sources":["useMergedRefs.js"],"sourcesContent":["import * as React from 'react';\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */ // LegacyRef is actually not supported, but in React v18 types this is leaking directly from forwardRef component declaration\nexport function useMergedRefs(...refs) {\n const mergedCallback = React.useCallback((value)=>{\n // Update the \"current\" prop hanging on the function.\n mergedCallback.current = value;\n for (const ref of refs){\n if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error(`@fluentui/react-utilities [useMergedRefs]:\nThis hook does not support the usage of string refs. Please use React.useRef instead.\n\nFor more info on 'React.useRef', see https://react.dev/reference/react/useRef.\nFor more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.`);\n }\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n ref.current = value;\n }\n }\n }, // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [\n ...refs\n ]);\n return mergedCallback;\n}\n"],"names":["useMergedRefs","refs","mergedCallback","React","useCallback","value","current","ref","process","env","NODE_ENV","console","error"],"mappings":";;;;+BAOgBA;;;eAAAA;;;;iEAPO;AAOhB,SAASA,cAAc,GAAGC,IAAI;IACjC,MAAMC,iBAAiBC,OAAMC,WAAW,CAAC,CAACC;QACtC,qDAAqD;QACrDH,eAAeI,OAAO,GAAGD;QACzB,KAAK,MAAME,OAAON,KAAK;YACnB,IAAI,OAAOM,QAAQ,YAAYC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBAClE,sCAAsC;gBACtCC,QAAQC,KAAK,CAAC,CAAC;;;;+GAIgF,CAAC;YACpG;YACA,IAAI,OAAOL,QAAQ,YAAY;gBAC3BA,IAAIF;YACR,OAAO,IAAIE,KAAK;gBACZ,qDAAqD;gBACrDA,IAAID,OAAO,GAAGD;YAClB;QACJ;IACJ,GACA;WACOJ;KACN;IACD,OAAOC;AACX"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20240610-0945.1",
|
4
4
|
"description": "A set of general React-specific utilities.",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -31,8 +31,8 @@
|
|
31
31
|
"@fluentui/scripts-tasks": "*"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@fluentui/keyboard-keys": "0.0.0-nightly-
|
35
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
34
|
+
"@fluentui/keyboard-keys": "0.0.0-nightly-20240610-0945.1",
|
35
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20240610-0945.1",
|
36
36
|
"@swc/helpers": "^0.5.1"
|
37
37
|
},
|
38
38
|
"peerDependencies": {
|