@fluentui/react-utilities 9.6.1 → 9.7.0
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/dist/index.d.ts +11 -4
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/utils/isHTMLElement.js +3 -3
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib-amd/compose/resolveShorthand.js.map +1 -1
- package/lib-amd/utils/isHTMLElement.js +4 -5
- package/lib-amd/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +3 -3
- package/lib-commonjs/utils/isHTMLElement.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 Mar 2023 08:55:02 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v9.7.0",
|
7
|
+
"version": "9.7.0",
|
8
|
+
"comments": {
|
9
|
+
"minor": [
|
10
|
+
{
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
12
|
+
"package": "@fluentui/react-utilities",
|
13
|
+
"commit": "edf96a6b5d6f13843ada1400480e347b84384b8e",
|
14
|
+
"comment": "feat: isHTMLElement to support all HTMLElement classes"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"date": "Fri, 10 Mar 2023 07:14:01 GMT",
|
21
|
+
"tag": "@fluentui/react-utilities_v9.6.2",
|
22
|
+
"version": "9.6.2",
|
23
|
+
"comments": {
|
24
|
+
"patch": [
|
25
|
+
{
|
26
|
+
"author": "bernardo.sunderhus@gmail.com",
|
27
|
+
"package": "@fluentui/react-utilities",
|
28
|
+
"commit": "e42e534acb58ef98a4a0ea1c7d8c0cf7a49d70ac",
|
29
|
+
"comment": "fix: ResolveShorthandOptions type to better reflect implementation"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"date": "Wed, 08 Mar 2023 17:42:49 GMT",
|
6
36
|
"tag": "@fluentui/react-utilities_v9.6.1",
|
7
37
|
"version": "9.6.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 Mar 2023 08:55:02 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.7.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.7.0)
|
8
|
+
|
9
|
+
Mon, 13 Mar 2023 08:55:02 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.6.2..@fluentui/react-utilities_v9.7.0)
|
11
|
+
|
12
|
+
### Minor changes
|
13
|
+
|
14
|
+
- feat: isHTMLElement to support all HTMLElement classes ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by bernardo.sunderhus@gmail.com)
|
15
|
+
|
16
|
+
## [9.6.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.6.2)
|
17
|
+
|
18
|
+
Fri, 10 Mar 2023 07:14:01 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.6.1..@fluentui/react-utilities_v9.6.2)
|
20
|
+
|
21
|
+
### Patches
|
22
|
+
|
23
|
+
- fix: ResolveShorthandOptions type to better reflect implementation ([PR #27112](https://github.com/microsoft/fluentui/pull/27112) by bernardo.sunderhus@gmail.com)
|
24
|
+
|
7
25
|
## [9.6.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.6.1)
|
8
26
|
|
9
|
-
Wed, 08 Mar 2023 17:
|
27
|
+
Wed, 08 Mar 2023 17:42:49 GMT
|
10
28
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.6.0..@fluentui/react-utilities_v9.6.1)
|
11
29
|
|
12
30
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -181,6 +181,8 @@ export declare function getTriggerChild<TriggerChildProps>(children: TriggerProp
|
|
181
181
|
ref?: React_2.Ref<any>;
|
182
182
|
}) | null;
|
183
183
|
|
184
|
+
declare type HTMLElementConstructorName = 'HTMLElement' | 'HTMLAnchorElement' | 'HTMLAreaElement' | 'HTMLAudioElement' | 'HTMLBaseElement' | 'HTMLBodyElement' | 'HTMLBRElement' | 'HTMLButtonElement' | 'HTMLCanvasElement' | 'HTMLDataElement' | 'HTMLDataListElement' | 'HTMLDetailsElement' | 'HTMLDialogElement' | 'HTMLDivElement' | 'HTMLDListElement' | 'HTMLEmbedElement' | 'HTMLFieldSetElement' | 'HTMLFormElement' | 'HTMLHeadingElement' | 'HTMLHeadElement' | 'HTMLHRElement' | 'HTMLHtmlElement' | 'HTMLIFrameElement' | 'HTMLImageElement' | 'HTMLInputElement' | 'HTMLModElement' | 'HTMLLabelElement' | 'HTMLLegendElement' | 'HTMLLIElement' | 'HTMLLinkElement' | 'HTMLMapElement' | 'HTMLMetaElement' | 'HTMLMeterElement' | 'HTMLObjectElement' | 'HTMLOListElement' | 'HTMLOptGroupElement' | 'HTMLOptionElement' | 'HTMLOutputElement' | 'HTMLParagraphElement' | 'HTMLParamElement' | 'HTMLPreElement' | 'HTMLProgressElement' | 'HTMLQuoteElement' | 'HTMLSlotElement' | 'HTMLScriptElement' | 'HTMLSelectElement' | 'HTMLSourceElement' | 'HTMLSpanElement' | 'HTMLStyleElement' | 'HTMLTableElement' | 'HTMLTableColElement' | 'HTMLTableRowElement' | 'HTMLTableSectionElement' | 'HTMLTemplateElement' | 'HTMLTextAreaElement' | 'HTMLTimeElement' | 'HTMLTitleElement' | 'HTMLTrackElement' | 'HTMLUListElement' | 'HTMLVideoElement';
|
185
|
+
|
184
186
|
/**
|
185
187
|
* Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions
|
186
188
|
* between different bundles.
|
@@ -210,7 +212,9 @@ export declare function isFluentTrigger(element: React_2.ReactElement): element
|
|
210
212
|
* might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
|
211
213
|
*
|
212
214
|
*/
|
213
|
-
export declare function isHTMLElement(element?: unknown
|
215
|
+
export declare function isHTMLElement<ConstructorName extends HTMLElementConstructorName = 'HTMLElement'>(element?: unknown, options?: {
|
216
|
+
constructorName?: ConstructorName;
|
217
|
+
}): element is InstanceType<(typeof globalThis)[ConstructorName]>;
|
214
218
|
|
215
219
|
/**
|
216
220
|
* @internal
|
@@ -377,11 +381,14 @@ export declare function resetIdsForTests(): void;
|
|
377
381
|
export declare const resolveShorthand: ResolveShorthandFunction;
|
378
382
|
|
379
383
|
export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
|
380
|
-
<P extends Props
|
381
|
-
<P extends Props
|
384
|
+
<P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): P;
|
385
|
+
<P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>): P | undefined;
|
382
386
|
};
|
383
387
|
|
384
|
-
export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
|
388
|
+
export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true ? {
|
389
|
+
required: true;
|
390
|
+
defaultProps?: Props;
|
391
|
+
} : {
|
385
392
|
required?: Required;
|
386
393
|
defaultProps?: Props;
|
387
394
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isValidElement","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","children"],"sources":["../src/packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type {
|
1
|
+
{"version":3,"names":["isValidElement","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","children"],"sources":["../src/packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\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 = (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"],"mappings":"AAAA,SAASA,cAAc,QAAQ,OAAO;AActC;;;;;;AAMA,OAAO,MAAMC,gBAAgB,GAA6BA,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"}
|
@@ -7,9 +7,9 @@
|
|
7
7
|
* might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
|
8
8
|
*
|
9
9
|
*/
|
10
|
-
export function isHTMLElement(element) {
|
11
|
-
var _a;
|
10
|
+
export function isHTMLElement(element, options) {
|
11
|
+
var _a, _b;
|
12
12
|
const typedElement = element;
|
13
|
-
return Boolean(
|
13
|
+
return Boolean(((_a = typedElement === null || typedElement === void 0 ? void 0 : typedElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_b = options === null || options === void 0 ? void 0 : options.constructorName) !== null && _b !== void 0 ? _b : 'HTMLElement']);
|
14
14
|
}
|
15
15
|
//# sourceMappingURL=isHTMLElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isHTMLElement","element","typedElement","Boolean","_a","ownerDocument","defaultView","
|
1
|
+
{"version":3,"names":["isHTMLElement","element","options","typedElement","Boolean","_a","ownerDocument","defaultView","_b","constructorName"],"sources":["../src/packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement<ConstructorName extends HTMLElementConstructorName = 'HTMLElement'>(\n element?: unknown,\n options?: { constructorName?: ConstructorName },\n): element is InstanceType<(typeof globalThis)[ConstructorName]> {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView[options?.constructorName ?? 'HTMLElement'],\n );\n}\n\ntype HTMLElementConstructorName =\n | 'HTMLElement'\n | 'HTMLAnchorElement'\n | 'HTMLAreaElement'\n | 'HTMLAudioElement'\n | 'HTMLBaseElement'\n | 'HTMLBodyElement'\n | 'HTMLBRElement'\n | 'HTMLButtonElement'\n | 'HTMLCanvasElement'\n | 'HTMLDataElement'\n | 'HTMLDataListElement'\n | 'HTMLDetailsElement'\n | 'HTMLDialogElement'\n | 'HTMLDivElement'\n | 'HTMLDListElement'\n | 'HTMLEmbedElement'\n | 'HTMLFieldSetElement'\n | 'HTMLFormElement'\n | 'HTMLHeadingElement'\n | 'HTMLHeadElement'\n | 'HTMLHRElement'\n | 'HTMLHtmlElement'\n | 'HTMLIFrameElement'\n | 'HTMLImageElement'\n | 'HTMLInputElement'\n | 'HTMLModElement'\n | 'HTMLLabelElement'\n | 'HTMLLegendElement'\n | 'HTMLLIElement'\n | 'HTMLLinkElement'\n | 'HTMLMapElement'\n | 'HTMLMetaElement'\n | 'HTMLMeterElement'\n | 'HTMLObjectElement'\n | 'HTMLOListElement'\n | 'HTMLOptGroupElement'\n | 'HTMLOptionElement'\n | 'HTMLOutputElement'\n | 'HTMLParagraphElement'\n | 'HTMLParamElement'\n | 'HTMLPreElement'\n | 'HTMLProgressElement'\n | 'HTMLQuoteElement'\n | 'HTMLSlotElement'\n | 'HTMLScriptElement'\n | 'HTMLSelectElement'\n | 'HTMLSourceElement'\n | 'HTMLSpanElement'\n | 'HTMLStyleElement'\n | 'HTMLTableElement'\n | 'HTMLTableColElement'\n | 'HTMLTableRowElement'\n | 'HTMLTableSectionElement'\n | 'HTMLTemplateElement'\n | 'HTMLTextAreaElement'\n | 'HTMLTimeElement'\n | 'HTMLTitleElement'\n | 'HTMLTrackElement'\n | 'HTMLUListElement'\n | 'HTMLVideoElement';\n"],"mappings":"AAAA;;;;;;;;;AASA,OAAM,SAAUA,aAAaA,CAC3BC,OAAiB,EACjBC,OAA+C;;EAE/C,MAAMC,YAAY,GAAGF,OAAkC;EACvD,OAAOG,OAAO,CACZ,EAAAC,EAAA,GAAAF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,aAAa,cAAAD,EAAA,uBAAAA,EAAA,CAAEE,WAAW,KACtCJ,YAAY,YAAYA,YAAY,CAACG,aAAa,CAACC,WAAW,CAAC,CAAAC,EAAA,GAAAN,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEO,eAAe,cAAAD,EAAA,cAAAA,EAAA,GAAI,aAAa,CAAC,CAC5G;AACH"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolveShorthand.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"names":[],"mappings":";;;;
|
1
|
+
{"version":3,"file":"resolveShorthand.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"names":[],"mappings":";;;;IAcA;;;;;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 { 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 = (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"]}
|
@@ -11,12 +11,11 @@ define(["require", "exports"], function (require, exports) {
|
|
11
11
|
* might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
|
12
12
|
*
|
13
13
|
*/
|
14
|
-
function isHTMLElement(element) {
|
15
|
-
var _a;
|
14
|
+
function isHTMLElement(element, options) {
|
15
|
+
var _a, _b;
|
16
16
|
var typedElement = element;
|
17
|
-
return Boolean(typedElement
|
18
|
-
(
|
19
|
-
typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement);
|
17
|
+
return Boolean(((_a = typedElement === null || typedElement === void 0 ? void 0 : typedElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) &&
|
18
|
+
typedElement instanceof typedElement.ownerDocument.defaultView[(_b = options === null || options === void 0 ? void 0 : options.constructorName) !== null && _b !== void 0 ? _b : 'HTMLElement']);
|
20
19
|
}
|
21
20
|
exports.isHTMLElement = isHTMLElement;
|
22
21
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;OAQG;IACH,SAAgB,aAAa,
|
1
|
+
{"version":3,"file":"isHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAC3B,OAAiB,EACjB,OAA+C;;QAE/C,IAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,OAAO,OAAO,CACZ,CAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAa,0CAAE,WAAW;YACtC,YAAY,YAAY,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,mCAAI,aAAa,CAAC,CAC5G,CAAC;IACJ,CAAC;IATD,sCASC","sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement<ConstructorName extends HTMLElementConstructorName = 'HTMLElement'>(\n element?: unknown,\n options?: { constructorName?: ConstructorName },\n): element is InstanceType<(typeof globalThis)[ConstructorName]> {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView[options?.constructorName ?? 'HTMLElement'],\n );\n}\n\ntype HTMLElementConstructorName =\n | 'HTMLElement'\n | 'HTMLAnchorElement'\n | 'HTMLAreaElement'\n | 'HTMLAudioElement'\n | 'HTMLBaseElement'\n | 'HTMLBodyElement'\n | 'HTMLBRElement'\n | 'HTMLButtonElement'\n | 'HTMLCanvasElement'\n | 'HTMLDataElement'\n | 'HTMLDataListElement'\n | 'HTMLDetailsElement'\n | 'HTMLDialogElement'\n | 'HTMLDivElement'\n | 'HTMLDListElement'\n | 'HTMLEmbedElement'\n | 'HTMLFieldSetElement'\n | 'HTMLFormElement'\n | 'HTMLHeadingElement'\n | 'HTMLHeadElement'\n | 'HTMLHRElement'\n | 'HTMLHtmlElement'\n | 'HTMLIFrameElement'\n | 'HTMLImageElement'\n | 'HTMLInputElement'\n | 'HTMLModElement'\n | 'HTMLLabelElement'\n | 'HTMLLegendElement'\n | 'HTMLLIElement'\n | 'HTMLLinkElement'\n | 'HTMLMapElement'\n | 'HTMLMetaElement'\n | 'HTMLMeterElement'\n | 'HTMLObjectElement'\n | 'HTMLOListElement'\n | 'HTMLOptGroupElement'\n | 'HTMLOptionElement'\n | 'HTMLOutputElement'\n | 'HTMLParagraphElement'\n | 'HTMLParamElement'\n | 'HTMLPreElement'\n | 'HTMLProgressElement'\n | 'HTMLQuoteElement'\n | 'HTMLSlotElement'\n | 'HTMLScriptElement'\n | 'HTMLSelectElement'\n | 'HTMLSourceElement'\n | 'HTMLSpanElement'\n | 'HTMLStyleElement'\n | 'HTMLTableElement'\n | 'HTMLTableColElement'\n | 'HTMLTableRowElement'\n | 'HTMLTableSectionElement'\n | 'HTMLTemplateElement'\n | 'HTMLTextAreaElement'\n | 'HTMLTimeElement'\n | 'HTMLTitleElement'\n | 'HTMLTrackElement'\n | 'HTMLUListElement'\n | 'HTMLVideoElement';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["react_1","require","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","isValidElement","children","exports"],"sources":["../src/packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type {
|
1
|
+
{"version":3,"names":["react_1","require","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","isValidElement","children","exports"],"sources":["../src/packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\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 = (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"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AAcA;;;;;;AAMO,MAAMC,gBAAgB,GAA6BA,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,IAAIH,OAAA,CAAAW,cAAc,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,OAAA,CAAAX,gBAAgB,GAAAA,gBAAA"}
|
@@ -13,10 +13,10 @@ exports.isHTMLElement = void 0;
|
|
13
13
|
* might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
|
14
14
|
*
|
15
15
|
*/
|
16
|
-
function isHTMLElement(element) {
|
17
|
-
var _a;
|
16
|
+
function isHTMLElement(element, options) {
|
17
|
+
var _a, _b;
|
18
18
|
const typedElement = element;
|
19
|
-
return Boolean(
|
19
|
+
return Boolean(((_a = typedElement === null || typedElement === void 0 ? void 0 : typedElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_b = options === null || options === void 0 ? void 0 : options.constructorName) !== null && _b !== void 0 ? _b : 'HTMLElement']);
|
20
20
|
}
|
21
21
|
exports.isHTMLElement = isHTMLElement;
|
22
22
|
//# sourceMappingURL=isHTMLElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isHTMLElement","element","typedElement","Boolean","_a","ownerDocument","defaultView","
|
1
|
+
{"version":3,"names":["isHTMLElement","element","options","typedElement","Boolean","_a","ownerDocument","defaultView","_b","constructorName","exports"],"sources":["../src/packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement<ConstructorName extends HTMLElementConstructorName = 'HTMLElement'>(\n element?: unknown,\n options?: { constructorName?: ConstructorName },\n): element is InstanceType<(typeof globalThis)[ConstructorName]> {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView[options?.constructorName ?? 'HTMLElement'],\n );\n}\n\ntype HTMLElementConstructorName =\n | 'HTMLElement'\n | 'HTMLAnchorElement'\n | 'HTMLAreaElement'\n | 'HTMLAudioElement'\n | 'HTMLBaseElement'\n | 'HTMLBodyElement'\n | 'HTMLBRElement'\n | 'HTMLButtonElement'\n | 'HTMLCanvasElement'\n | 'HTMLDataElement'\n | 'HTMLDataListElement'\n | 'HTMLDetailsElement'\n | 'HTMLDialogElement'\n | 'HTMLDivElement'\n | 'HTMLDListElement'\n | 'HTMLEmbedElement'\n | 'HTMLFieldSetElement'\n | 'HTMLFormElement'\n | 'HTMLHeadingElement'\n | 'HTMLHeadElement'\n | 'HTMLHRElement'\n | 'HTMLHtmlElement'\n | 'HTMLIFrameElement'\n | 'HTMLImageElement'\n | 'HTMLInputElement'\n | 'HTMLModElement'\n | 'HTMLLabelElement'\n | 'HTMLLegendElement'\n | 'HTMLLIElement'\n | 'HTMLLinkElement'\n | 'HTMLMapElement'\n | 'HTMLMetaElement'\n | 'HTMLMeterElement'\n | 'HTMLObjectElement'\n | 'HTMLOListElement'\n | 'HTMLOptGroupElement'\n | 'HTMLOptionElement'\n | 'HTMLOutputElement'\n | 'HTMLParagraphElement'\n | 'HTMLParamElement'\n | 'HTMLPreElement'\n | 'HTMLProgressElement'\n | 'HTMLQuoteElement'\n | 'HTMLSlotElement'\n | 'HTMLScriptElement'\n | 'HTMLSelectElement'\n | 'HTMLSourceElement'\n | 'HTMLSpanElement'\n | 'HTMLStyleElement'\n | 'HTMLTableElement'\n | 'HTMLTableColElement'\n | 'HTMLTableRowElement'\n | 'HTMLTableSectionElement'\n | 'HTMLTemplateElement'\n | 'HTMLTextAreaElement'\n | 'HTMLTimeElement'\n | 'HTMLTitleElement'\n | 'HTMLTrackElement'\n | 'HTMLUListElement'\n | 'HTMLVideoElement';\n"],"mappings":";;;;;;AAAA;;;;;;;;;AASA,SAAgBA,aAAaA,CAC3BC,OAAiB,EACjBC,OAA+C;;EAE/C,MAAMC,YAAY,GAAGF,OAAkC;EACvD,OAAOG,OAAO,CACZ,EAAAC,EAAA,GAAAF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,aAAa,cAAAD,EAAA,uBAAAA,EAAA,CAAEE,WAAW,KACtCJ,YAAY,YAAYA,YAAY,CAACG,aAAa,CAACC,WAAW,CAAC,CAAAC,EAAA,GAAAN,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEO,eAAe,cAAAD,EAAA,cAAAA,EAAA,GAAI,aAAa,CAAC,CAC5G;AACH;AATAE,OAAA,CAAAV,aAAA,GAAAA,aAAA"}
|