@fluentui/react-utilities 9.5.1 → 9.5.3
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 +31 -1
- package/CHANGELOG.md +20 -2
- package/lib/compose/resolveShorthand.js +3 -1
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/hooks/useId.js +4 -1
- package/lib/hooks/useId.js.map +1 -1
- package/lib-amd/compose/resolveShorthand.js +1 -1
- package/lib-amd/compose/resolveShorthand.js.map +1 -1
- package/lib-amd/hooks/useId.js +4 -1
- package/lib-amd/hooks/useId.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +3 -1
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +4 -1
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,37 @@
|
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Mon, 13 Feb 2023 23:40:49 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v9.5.3",
|
7
|
+
"version": "9.5.3",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "yuanboxue@microsoft.com",
|
12
|
+
"package": "@fluentui/react-utilities",
|
13
|
+
"commit": "3d12f79c3d790ac28b00f54dd8fc6d23970cf6ed",
|
14
|
+
"comment": "fix: `resolveShorthand` should resolve an object as its copy"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"date": "Fri, 10 Feb 2023 08:50:01 GMT",
|
21
|
+
"tag": "@fluentui/react-utilities_v9.5.2",
|
22
|
+
"version": "9.5.2",
|
23
|
+
"comments": {
|
24
|
+
"patch": [
|
25
|
+
{
|
26
|
+
"author": "esteban.230@hotmail.com",
|
27
|
+
"package": "@fluentui/react-utilities",
|
28
|
+
"commit": "2043f6d0278192d009426549e6cb63dba4b93593",
|
29
|
+
"comment": "fix: Generate id first to avoid hook order mismatch in React 18 and remove colons from generated id in React 18."
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"date": "Tue, 31 Jan 2023 19:53:58 GMT",
|
6
36
|
"tag": "@fluentui/react-utilities_v9.5.1",
|
7
37
|
"version": "9.5.1",
|
8
38
|
"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 Mon, 13 Feb 2023 23:40:49 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.5.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.5.3)
|
8
|
+
|
9
|
+
Mon, 13 Feb 2023 23:40:49 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.5.2..@fluentui/react-utilities_v9.5.3)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- fix: `resolveShorthand` should resolve an object as its copy ([PR #26825](https://github.com/microsoft/fluentui/pull/26825) by yuanboxue@microsoft.com)
|
15
|
+
|
16
|
+
## [9.5.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.5.2)
|
17
|
+
|
18
|
+
Fri, 10 Feb 2023 08:50:01 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.5.1..@fluentui/react-utilities_v9.5.2)
|
20
|
+
|
21
|
+
### Patches
|
22
|
+
|
23
|
+
- fix: Generate id first to avoid hook order mismatch in React 18 and remove colons from generated id in React 18. ([PR #26745](https://github.com/microsoft/fluentui/pull/26745) by esteban.230@hotmail.com)
|
24
|
+
|
7
25
|
## [9.5.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.5.1)
|
8
26
|
|
9
|
-
Tue, 31 Jan 2023 19:
|
27
|
+
Tue, 31 Jan 2023 19:53:58 GMT
|
10
28
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.5.0..@fluentui/react-utilities_v9.5.1)
|
11
29
|
|
12
30
|
### Patches
|
@@ -17,7 +17,9 @@ export const resolveShorthand = (value, options) => {
|
|
17
17
|
if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/isValidElement(value)) {
|
18
18
|
resolvedShorthand.children = value;
|
19
19
|
} else if (typeof value === 'object') {
|
20
|
-
resolvedShorthand =
|
20
|
+
resolvedShorthand = {
|
21
|
+
...value
|
22
|
+
};
|
21
23
|
}
|
22
24
|
return defaultProps ? {
|
23
25
|
...defaultProps,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,SAASA,cAAc,QAAQ,OAAO;AAkBtC;;;;;;AAMA,OAAO,MAAMC,gBAAgB,GAA6B,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,iBAAIF,cAAc,CAACE,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACG,QAAQ,GAAGR,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAGL,
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,cAAc,QAAQ,OAAO;AAkBtC;;;;;;AAMA,OAAO,MAAMC,gBAAgB,GAA6B,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,iBAAIF,cAAc,CAACE,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACG,QAAQ,GAAGR,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAG;MAAE,GAAGL;IAAK,CAAE;;EAGlC,OAAOG,YAAY,GAAG;IAAE,GAAGA,YAAY;IAAE,GAAGE;EAAiB,CAAE,GAAGA,iBAAiB;AACrF,CAAC","names":["isValidElement","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","children"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = { ...value };\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"]}
|
package/lib/hooks/useId.js
CHANGED
@@ -30,7 +30,10 @@ export function useId(prefix = 'fui-', providedId) {
|
|
30
30
|
// prevent bundlers from complaining with older versions of React.
|
31
31
|
const _useId = React['use' + 'Id'];
|
32
32
|
if (_useId) {
|
33
|
-
|
33
|
+
const generatedId = _useId();
|
34
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
35
|
+
const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);
|
36
|
+
return providedId || `${idPrefix}${prefix}${escapedId}`;
|
34
37
|
}
|
35
38
|
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
|
36
39
|
// the version of React being used. This is safe to ignore.
|
package/lib/hooks/useId.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,cAAc;AAEpE,MAAMC,eAAe,gBAAGH,KAAK,CAACI,aAAa,CAAqBC,SAAS,CAAC;AAE1E;;;;AAIA,OAAO,MAAMC,gBAAgB,GAAGH,eAAe,CAACI,QAAQ;AAExD,SAASC,WAAW;EAClB,OAAOR,KAAK,CAACS,UAAU,CAACN,eAAe,CAAC,IAAI,EAAE;AAChD;AAEA;;;AAGA,OAAM,SAAUO,gBAAgB;EAC9BT,sBAAsB,CAACU,OAAO,GAAG,CAAC;AACpC;AAEA;;;;;;;;AAQA,OAAM,SAAUC,KAAK,CAACC,SAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGb,aAAa,EAAE;EACpC,MAAMc,QAAQ,GAAGR,WAAW,EAAE;EAE9B;EACA;EACA,MAAMS,MAAM,
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,cAAc;AAEpE,MAAMC,eAAe,gBAAGH,KAAK,CAACI,aAAa,CAAqBC,SAAS,CAAC;AAE1E;;;;AAIA,OAAO,MAAMC,gBAAgB,GAAGH,eAAe,CAACI,QAAQ;AAExD,SAASC,WAAW;EAClB,OAAOR,KAAK,CAACS,UAAU,CAACN,eAAe,CAAC,IAAI,EAAE;AAChD;AAEA;;;AAGA,OAAM,SAAUO,gBAAgB;EAC9BT,sBAAsB,CAACU,OAAO,GAAG,CAAC;AACpC;AAEA;;;;;;;;AAQA,OAAM,SAAUC,KAAK,CAACC,SAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGb,aAAa,EAAE;EACpC,MAAMc,QAAQ,GAAGR,WAAW,EAAE;EAE9B;EACA;EACA,MAAMS,MAAM,GAAIjB,KAAe,CAAC,KAAK,GAAG,IAAI,CAA+B;EAE3E,IAAIiB,MAAM,EAAE;IACV,MAAMC,WAAW,GAAGD,MAAM,EAAE;IAE5B;IACA,MAAME,SAAS,GAAGnB,KAAK,CAACoB,OAAO,CAAC,MAAMF,WAAW,CAACG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAACH,WAAW,CAAC,CAAC;IAEnF,OAAOJ,UAAU,IAAI,GAAGE,QAAQ,GAAGH,MAAM,GAAGM,SAAS,EAAE;;EAGzD;EACA;EACA;EACA,OAAOnB,KAAK,CAACoB,OAAO,CAAC,MAAK;IACxB,IAAIN,UAAU,EAAE;MACd,OAAOA,UAAU;;IAGnB,OAAO,GAAGE,QAAQ,GAAGH,MAAM,GAAG,EAAEE,YAAY,CAACJ,OAAO,EAAE;EACxD,CAAC,EAAE,CAACK,QAAQ,EAAEH,MAAM,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;AAClD","names":["React","defaultSSRContextValue","useSSRContext","IdPrefixContext","createContext","undefined","IdPrefixProvider","Provider","useIdPrefix","useContext","resetIdsForTests","current","useId","prefix","providedId","contextValue","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/hooks/useId.ts"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = (React as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"]}
|
@@ -18,7 +18,7 @@ define(["require", "exports", "tslib", "react"], function (require, exports, tsl
|
|
18
18
|
resolvedShorthand.children = value;
|
19
19
|
}
|
20
20
|
else if (typeof value === 'object') {
|
21
|
-
resolvedShorthand = value;
|
21
|
+
resolvedShorthand = tslib_1.__assign({}, value);
|
22
22
|
}
|
23
23
|
return defaultProps ? tslib_1.__assign(tslib_1.__assign({}, defaultProps), resolvedShorthand) : resolvedShorthand;
|
24
24
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolveShorthand.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"names":[],"mappings":";;;;IAkBA;;;;;OAKG;IACI,IAAM,gBAAgB,GAA6B,UAAC,KAAK,EAAE,OAAO;QACjE,IAAA,KAAqC,OAAO,IAAI,EAAE,EAAhD,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,YAAY,kBAAkB,CAAC;QACzD,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,EAAE;YACxD,OAAO,SAAS,CAAC;SAClB;QAED,IAAI,iBAAiB,GAAG,EAAsB,CAAC;QAE/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,sBAAc,CAAC,KAAK,CAAC,EAAE;YAC3G,iBAAiB,CAAC,QAAQ,GAAG,KAAK,CAAC;SACpC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACpC,iBAAiB,
|
1
|
+
{"version":3,"file":"resolveShorthand.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"names":[],"mappings":";;;;IAkBA;;;;;OAKG;IACI,IAAM,gBAAgB,GAA6B,UAAC,KAAK,EAAE,OAAO;QACjE,IAAA,KAAqC,OAAO,IAAI,EAAE,EAAhD,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,YAAY,kBAAkB,CAAC;QACzD,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,EAAE;YACxD,OAAO,SAAS,CAAC;SAClB;QAED,IAAI,iBAAiB,GAAG,EAAsB,CAAC;QAE/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,sBAAc,CAAC,KAAK,CAAC,EAAE;YAC3G,iBAAiB,CAAC,QAAQ,GAAG,KAAK,CAAC;SACpC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACpC,iBAAiB,wBAAQ,KAAK,CAAE,CAAC;SAClC;QAED,OAAO,YAAY,CAAC,CAAC,uCAAM,YAAY,GAAK,iBAAiB,EAAG,CAAC,CAAC,iBAAiB,CAAC;IACtF,CAAC,CAAC;IAfW,QAAA,gBAAgB,oBAe3B","sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = { ...value };\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"]}
|
package/lib-amd/hooks/useId.js
CHANGED
@@ -34,7 +34,10 @@ define(["require", "exports", "react", "../ssr/index"], function (require, expor
|
|
34
34
|
// prevent bundlers from complaining with older versions of React.
|
35
35
|
var _useId = React['use' + 'Id'];
|
36
36
|
if (_useId) {
|
37
|
-
|
37
|
+
var generatedId_1 = _useId();
|
38
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
39
|
+
var escapedId = React.useMemo(function () { return generatedId_1.replace(/:/g, ''); }, [generatedId_1]);
|
40
|
+
return providedId || "" + idPrefix + prefix + escapedId;
|
38
41
|
}
|
39
42
|
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
|
40
43
|
// the version of React being used. This is safe to ignore.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useId.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useId.ts"],"names":[],"mappings":";;;;IAGA,IAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAqB,SAAS,CAAC,CAAC;IAE3E;;;OAGG;IACU,QAAA,gBAAgB,GAAG,eAAe,CAAC,QAAQ,CAAC;IAEzD,SAAS,WAAW;QAClB,OAAO,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,SAAgB,gBAAgB;QAC9B,8BAAsB,CAAC,OAAO,GAAG,CAAC,CAAC;IACrC,CAAC;IAFD,4CAEC;IAED;;;;;;;OAOG;IACH,SAAgB,KAAK,CAAC,MAAuB,EAAE,UAAmB;QAA5C,uBAAA,EAAA,eAAuB;QAC3C,IAAM,YAAY,GAAG,qBAAa,EAAE,CAAC;QACrC,IAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAE/B,mHAAmH;QACnH,kEAAkE;QAClE,IAAM,MAAM,
|
1
|
+
{"version":3,"file":"useId.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useId.ts"],"names":[],"mappings":";;;;IAGA,IAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAqB,SAAS,CAAC,CAAC;IAE3E;;;OAGG;IACU,QAAA,gBAAgB,GAAG,eAAe,CAAC,QAAQ,CAAC;IAEzD,SAAS,WAAW;QAClB,OAAO,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,SAAgB,gBAAgB;QAC9B,8BAAsB,CAAC,OAAO,GAAG,CAAC,CAAC;IACrC,CAAC;IAFD,4CAEC;IAED;;;;;;;OAOG;IACH,SAAgB,KAAK,CAAC,MAAuB,EAAE,UAAmB;QAA5C,uBAAA,EAAA,eAAuB;QAC3C,IAAM,YAAY,GAAG,qBAAa,EAAE,CAAC;QACrC,IAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAE/B,mHAAmH;QACnH,kEAAkE;QAClE,IAAM,MAAM,GAAI,KAAe,CAAC,KAAK,GAAG,IAAI,CAA+B,CAAC;QAE5E,IAAI,MAAM,EAAE;YACV,IAAM,aAAW,GAAG,MAAM,EAAE,CAAC;YAE7B,sDAAsD;YACtD,IAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,cAAM,OAAA,aAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAA7B,CAA6B,EAAE,CAAC,aAAW,CAAC,CAAC,CAAC;YAEpF,OAAO,UAAU,IAAI,KAAG,QAAQ,GAAG,MAAM,GAAG,SAAW,CAAC;SACzD;QAED,2GAA2G;QAC3G,2DAA2D;QAC3D,sDAAsD;QACtD,OAAO,KAAK,CAAC,OAAO,CAAC;YACnB,IAAI,UAAU,EAAE;gBACd,OAAO,UAAU,CAAC;aACnB;YAED,OAAO,KAAG,QAAQ,GAAG,MAAM,GAAG,EAAE,YAAY,CAAC,OAAS,CAAC;QACzD,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IACnD,CAAC;IA3BD,sBA2BC","sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = (React as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"]}
|
@@ -23,7 +23,9 @@ const resolveShorthand = (value, options) => {
|
|
23
23
|
if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || react_1.isValidElement(value)) {
|
24
24
|
resolvedShorthand.children = value;
|
25
25
|
} else if (typeof value === 'object') {
|
26
|
-
resolvedShorthand =
|
26
|
+
resolvedShorthand = {
|
27
|
+
...value
|
28
|
+
};
|
27
29
|
}
|
28
30
|
return defaultProps ? {
|
29
31
|
...defaultProps,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AAkBA;;;;;;AAMO,MAAMA,gBAAgB,GAA6B,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,IAAIQ,sBAAc,CAACR,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACI,QAAQ,GAAGT,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAGL,
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAkBA;;;;;;AAMO,MAAMA,gBAAgB,GAA6B,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,IAAIQ,sBAAc,CAACR,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACI,QAAQ,GAAGT,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAG;MAAE,GAAGL;IAAK,CAAE;;EAGlC,OAAOG,YAAY,GAAG;IAAE,GAAGA,YAAY;IAAE,GAAGE;EAAiB,CAAE,GAAGA,iBAAiB;AACrF,CAAC;AAfYK,wBAAgB","names":["resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","react_1","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = { ...value };\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"]}
|
@@ -37,7 +37,10 @@ function useId(prefix = 'fui-', providedId) {
|
|
37
37
|
// prevent bundlers from complaining with older versions of React.
|
38
38
|
const _useId = React['use' + 'Id'];
|
39
39
|
if (_useId) {
|
40
|
-
|
40
|
+
const generatedId = _useId();
|
41
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
42
|
+
const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);
|
43
|
+
return providedId || `${idPrefix}${prefix}${escapedId}`;
|
41
44
|
}
|
42
45
|
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
|
43
46
|
// the version of React being used. This is safe to ignore.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AACA;AAEA,MAAMA,eAAe,gBAAGC,KAAK,CAACC,aAAa,CAAqBC,SAAS,CAAC;AAE1E;;;;AAIaC,wBAAgB,GAAGJ,eAAe,CAACK,QAAQ;AAExD,SAASC,WAAW;EAClB,OAAOL,KAAK,CAACM,UAAU,CAACP,eAAe,CAAC,IAAI,EAAE;AAChD;AAEA;;;AAGA,SAAgBQ,gBAAgB;EAC9BC,8BAAsB,CAACC,OAAO,GAAG,CAAC;AACpC;AAFAN;AAIA;;;;;;;;AAQA,SAAgBO,KAAK,CAACC,SAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGL,qBAAa,EAAE;EACpC,MAAMM,QAAQ,GAAGT,WAAW,EAAE;EAE9B;EACA;EACA,MAAMU,MAAM,
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAEA,MAAMA,eAAe,gBAAGC,KAAK,CAACC,aAAa,CAAqBC,SAAS,CAAC;AAE1E;;;;AAIaC,wBAAgB,GAAGJ,eAAe,CAACK,QAAQ;AAExD,SAASC,WAAW;EAClB,OAAOL,KAAK,CAACM,UAAU,CAACP,eAAe,CAAC,IAAI,EAAE;AAChD;AAEA;;;AAGA,SAAgBQ,gBAAgB;EAC9BC,8BAAsB,CAACC,OAAO,GAAG,CAAC;AACpC;AAFAN;AAIA;;;;;;;;AAQA,SAAgBO,KAAK,CAACC,SAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGL,qBAAa,EAAE;EACpC,MAAMM,QAAQ,GAAGT,WAAW,EAAE;EAE9B;EACA;EACA,MAAMU,MAAM,GAAIf,KAAe,CAAC,KAAK,GAAG,IAAI,CAA+B;EAE3E,IAAIe,MAAM,EAAE;IACV,MAAMC,WAAW,GAAGD,MAAM,EAAE;IAE5B;IACA,MAAME,SAAS,GAAGjB,KAAK,CAACkB,OAAO,CAAC,MAAMF,WAAW,CAACG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAACH,WAAW,CAAC,CAAC;IAEnF,OAAOJ,UAAU,IAAI,GAAGE,QAAQ,GAAGH,MAAM,GAAGM,SAAS,EAAE;;EAGzD;EACA;EACA;EACA,OAAOjB,KAAK,CAACkB,OAAO,CAAC,MAAK;IACxB,IAAIN,UAAU,EAAE;MACd,OAAOA,UAAU;;IAGnB,OAAO,GAAGE,QAAQ,GAAGH,MAAM,GAAG,EAAEE,YAAY,CAACJ,OAAO,EAAE;EACxD,CAAC,EAAE,CAACK,QAAQ,EAAEH,MAAM,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;AAClD;AA3BAV","names":["IdPrefixContext","React","createContext","undefined","exports","Provider","useIdPrefix","useContext","resetIdsForTests","index_1","current","useId","prefix","providedId","contextValue","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/hooks/useId.ts"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = (React as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"]}
|