@semcore/core 16.0.0-prerelease.16 → 16.0.0-prerelease.18

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 CHANGED
@@ -9,6 +9,10 @@ CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangel
9
9
  - `utils` functions as part of Core.
10
10
  - `LastInteractionType` class to check last interaction was from keyboard or mouse.
11
11
 
12
+ ### Fixed
13
+
14
+ - Return type for `fincComponent` util. It could be only `ReactElement` or `undefined`.
15
+
12
16
  ## [2.39.2] - 2025-04-04
13
17
 
14
18
  ### Changed
@@ -74,6 +74,7 @@ function getNodeByRef(ref) {
74
74
  if (!node) return null;
75
75
  if (node.nodeType === 1) return node;
76
76
  if (Object.keys(node).length === 1 && "getBoundingClientRect" in node) return null;
77
+ if (!/* @__PURE__ */ React.isValidElement(node)) return null;
77
78
  return findDOMNode(node);
78
79
  }
79
80
  export {
@@ -1,5 +1,5 @@
1
- import { ReactElement, ReactNode, MutableRefObject } from 'react';
2
- declare function findComponent(Children: any, names: string[], recursively?: boolean, limit?: number): Exclude<ReactNode, boolean | null | undefined> | undefined;
1
+ import { ReactElement, MutableRefObject } from 'react';
2
+ declare function findComponent<P = any>(Children: any, names: string[], recursively?: boolean, limit?: number): ReactElement<P> | undefined;
3
3
  export declare function isAdvanceMode(Children: any, name: string[], recursively?: boolean): boolean;
4
4
  type IntergalacticComponent = ReactElement & {
5
5
  ref?: MutableRefObject<HTMLElement>;
@@ -1 +1 @@
1
- {"version":3,"file":"findComponent.js","names":["_react","_interopRequireDefault","require","_getOriginChildren","_symbols","findComponent","Children","names","recursively","limit","arguments","length","undefined","children","CHILDREN_COMPONENT","getOriginChildren","React","toArray","find","child","isValidElement","type","Fragment","props","inheritedNames","INHERITED_NAME","displayName","result","name","includes","isAdvanceMode","findAllComponents","findAllAndAdd","forEach","component","push","extractFrom","extracted","rest","extractor","_default","exports"],"sources":["../../src/utils/findComponent.ts"],"sourcesContent":["import React, { ReactElement, ReactNode, MutableRefObject } from 'react';\nimport getOriginChildren from './getOriginChildren';\nimport { CHILDREN_COMPONENT, INHERITED_NAME } from '../core-types/symbols';\n\nfunction findComponent(\n Children: any,\n names: string[],\n recursively?: boolean,\n limit = 100,\n): Exclude<ReactNode, boolean | null | undefined> | undefined {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n return React.Children.toArray(children).find((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return findComponent(child.props.children, names, recursively, limit);\n }\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const result = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (!result && child.props.children && recursively && limit > 0) {\n return findComponent(child.props.children, names, recursively, limit - 1);\n }\n\n return result;\n }\n });\n}\n\nexport function isAdvanceMode(Children: any, name: string[], recursively?: boolean) {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n if (!children) return false;\n if (typeof children === 'function') {\n return true;\n }\n return !!findComponent(children, name, recursively);\n}\n\ntype IntergalacticComponent = ReactElement & {\n ref?: MutableRefObject<HTMLElement>;\n};\n\nexport function findAllComponents(Children: any, names: string[]): IntergalacticComponent[] {\n const result: IntergalacticComponent[] = [];\n\n const findAllAndAdd = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n findAllAndAdd(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n findAllAndAdd(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n result.push(child);\n }\n\n if (child.props.children) {\n return findAllAndAdd(child.props.children);\n }\n }\n }\n });\n };\n\n findAllAndAdd(Children);\n\n return result;\n}\n\n/**\n * Extract some components from Children and return them and rest of components as tuple.\n */\nexport function extractFrom(Children: any, names: string[]): IntergalacticComponent[][] {\n const extracted: IntergalacticComponent[] = [];\n const rest: IntergalacticComponent[] = [];\n\n const extractor = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n extractor(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n extractor(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n extracted.push(child);\n } else {\n rest.push(child);\n }\n }\n }\n });\n };\n\n extractor(Children);\n\n return [extracted, rest];\n}\n\nexport default findComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,SAASG,aAAaA,CACpBC,QAAa,EACbC,KAAe,EACfC,WAAqB,EAEuC;EAAA,IAD5DC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;EAEX,IAAMG,QAAQ,GAAGP,QAAQ,CAACQ,2BAAkB,CAAC,GAAG,IAAAC,6BAAiB,EAACT,QAAQ,CAAC,GAAGA,QAAQ;EACtF,OAAOU,iBAAK,CAACV,QAAQ,CAACW,OAAO,CAACJ,QAAQ,CAAC,CAACK,IAAI,CAAC,UAACC,KAAK,EAAK;IACtD,kBAAIH,iBAAK,CAACI,cAAc,CAACD,KAAK,CAAC,EAAE;MAC/B,IAAIA,KAAK,CAACE,IAAI,KAAKL,iBAAK,CAACM,Q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GAEcnC,aAAa;AAAAoC,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"findComponent.js","names":["_react","_interopRequireDefault","require","_getOriginChildren","_symbols","findComponent","Children","names","recursively","limit","arguments","length","undefined","children","CHILDREN_COMPONENT","getOriginChildren","React","toArray","find","child","isValidElement","type","Fragment","props","inheritedNames","INHERITED_NAME","displayName","result","name","includes","isAdvanceMode","findAllComponents","findAllAndAdd","forEach","component","push","extractFrom","extracted","rest","extractor","_default","exports"],"sources":["../../src/utils/findComponent.ts"],"sourcesContent":["import React, { ReactElement, MutableRefObject } from 'react';\nimport getOriginChildren from './getOriginChildren';\nimport { CHILDREN_COMPONENT, INHERITED_NAME } from '../core-types/symbols';\n\nfunction findComponent<P = any>(\n Children: any,\n names: string[],\n recursively?: boolean,\n limit = 100,\n): ReactElement<P> | undefined {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n return React.Children.toArray(children).find((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return findComponent(child.props.children, names, recursively, limit);\n }\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const result = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (!result && child.props.children && recursively && limit > 0) {\n return findComponent(child.props.children, names, recursively, limit - 1);\n }\n\n return result;\n }\n }) as ReactElement<P> | undefined;\n}\n\nexport function isAdvanceMode(Children: any, name: string[], recursively?: boolean) {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n if (!children) return false;\n if (typeof children === 'function') {\n return true;\n }\n return !!findComponent(children, name, recursively);\n}\n\ntype IntergalacticComponent = ReactElement & {\n ref?: MutableRefObject<HTMLElement>;\n};\n\nexport function findAllComponents(Children: any, names: string[]): IntergalacticComponent[] {\n const result: IntergalacticComponent[] = [];\n\n const findAllAndAdd = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n findAllAndAdd(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n findAllAndAdd(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n result.push(child);\n }\n\n if (child.props.children) {\n return findAllAndAdd(child.props.children);\n }\n }\n }\n });\n };\n\n findAllAndAdd(Children);\n\n return result;\n}\n\n/**\n * Extract some components from Children and return them and rest of components as tuple.\n */\nexport function extractFrom(Children: any, names: string[]): IntergalacticComponent[][] {\n const extracted: IntergalacticComponent[] = [];\n const rest: IntergalacticComponent[] = [];\n\n const extractor = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n extractor(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n extractor(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n extracted.push(child);\n } else {\n rest.push(child);\n }\n }\n }\n });\n };\n\n extractor(Children);\n\n return [extracted, rest];\n}\n\nexport default findComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,SAASG,aAAaA,CACpBC,QAAa,EACbC,KAAe,EACfC,WAAqB,EAEQ;EAAA,IAD7BC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAA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AACsB,QAAQ,CAACD,IAAI,CAAC;UAAA,EAAC;UAE/E,IAAIM,SAAS,EAAE;YACbG,SAAS,CAACF,IAAI,CAAChB,KAAK,CAAC;UACvB,CAAC,MAAM;YACLmB,IAAI,CAACH,IAAI,CAAChB,KAAK,CAAC;UAClB;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAEDoB,SAAS,CAACjC,QAAQ,CAAC;EAEnB,OAAO,CAAC+B,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAAC,IAAAE,QAAA,GAEcnC,aAAa;AAAAoC,OAAA,cAAAD,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"findComponent.mjs","names":["React","getOriginChildren","CHILDREN_COMPONENT","INHERITED_NAME","findComponent","Children","names","recursively","limit","arguments","length","undefined","children","toArray","find","child","isValidElement","type","Fragment","props","inheritedNames","displayName","result","name","includes","isAdvanceMode","findAllComponents","findAllAndAdd","forEach","component","push","extractFrom","extracted","rest","extractor"],"sources":["../../src/utils/findComponent.ts"],"sourcesContent":["import React, { ReactElement, ReactNode, MutableRefObject } from 'react';\nimport getOriginChildren from './getOriginChildren';\nimport { CHILDREN_COMPONENT, INHERITED_NAME } from '../core-types/symbols';\n\nfunction findComponent(\n Children: any,\n names: string[],\n recursively?: boolean,\n limit = 100,\n): Exclude<ReactNode, boolean | null | undefined> | undefined {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n return React.Children.toArray(children).find((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return findComponent(child.props.children, names, recursively, limit);\n }\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const result = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (!result && child.props.children && recursively && limit > 0) {\n return findComponent(child.props.children, names, recursively, limit - 1);\n }\n\n return result;\n }\n });\n}\n\nexport function isAdvanceMode(Children: any, name: string[], recursively?: boolean) {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n if (!children) return false;\n if (typeof children === 'function') {\n return true;\n }\n return !!findComponent(children, name, recursively);\n}\n\ntype IntergalacticComponent = ReactElement & {\n ref?: MutableRefObject<HTMLElement>;\n};\n\nexport function findAllComponents(Children: any, names: string[]): IntergalacticComponent[] {\n const result: IntergalacticComponent[] = [];\n\n const findAllAndAdd = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n findAllAndAdd(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n findAllAndAdd(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n result.push(child);\n }\n\n if (child.props.children) {\n return findAllAndAdd(child.props.children);\n }\n }\n }\n });\n };\n\n findAllAndAdd(Children);\n\n return result;\n}\n\n/**\n * Extract some components from Children and return them and rest of components as tuple.\n */\nexport function extractFrom(Children: any, names: string[]): IntergalacticComponent[][] {\n const extracted: IntergalacticComponent[] = [];\n const rest: IntergalacticComponent[] = [];\n\n const extractor = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n extractor(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n extractor(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n extracted.push(child);\n } else {\n rest.push(child);\n }\n }\n }\n });\n };\n\n extractor(Children);\n\n return [extracted, rest];\n}\n\nexport default findComponent;\n"],"mapp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AS,CAACnB,KAAK,CAACE,IAAI,CAAC;QACvB,CAAC,MAAM;UACL;UACA,IAAMG,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACd,cAAc,CAAC,IAAI,CAACY,KAAK,CAACE,IAAI,CAACI,WAAW,CAAC;UAC7E,IAAMQ,SAAS,GAAG,CAAC,CAACT,cAAc,CAACN,IAAI,CAAC,UAACS,IAAY;YAAA,OAAKjB,KAAK,CAACkB,QAAQ,CAACD,IAAI,CAAC;UAAA,EAAC;UAE/E,IAAIM,SAAS,EAAE;YACbG,SAAS,CAACF,IAAI,CAACf,KAAK,CAAC;UACvB,CAAC,MAAM;YACLkB,IAAI,CAACH,IAAI,CAACf,KAAK,CAAC;UAClB;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAEDmB,SAAS,CAAC7B,QAAQ,CAAC;EAEnB,OAAO,CAAC2B,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAEA,eAAe7B,aAAa"}
1
+ {"version":3,"file":"findComponent.mjs","names":["React","getOriginChildren","CHILDREN_COMPONENT","INHERITED_NAME","findComponent","Children","names","recursively","limit","arguments","length","undefined","children","toArray","find","child","isValidElement","type","Fragment","props","inheritedNames","displayName","result","name","includes","isAdvanceMode","findAllComponents","findAllAndAdd","forEach","component","push","extractFrom","extracted","rest","extractor"],"sources":["../../src/utils/findComponent.ts"],"sourcesContent":["import React, { ReactElement, MutableRefObject } from 'react';\nimport getOriginChildren from './getOriginChildren';\nimport { CHILDREN_COMPONENT, INHERITED_NAME } from '../core-types/symbols';\n\nfunction findComponent<P = any>(\n Children: any,\n names: string[],\n recursively?: boolean,\n limit = 100,\n): ReactElement<P> | undefined {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n return React.Children.toArray(children).find((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return findComponent(child.props.children, names, recursively, limit);\n }\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const result = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (!result && child.props.children && recursively && limit > 0) {\n return findComponent(child.props.children, names, recursively, limit - 1);\n }\n\n return result;\n }\n }) as ReactElement<P> | undefined;\n}\n\nexport function isAdvanceMode(Children: any, name: string[], recursively?: boolean) {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n if (!children) return false;\n if (typeof children === 'function') {\n return true;\n }\n return !!findComponent(children, name, recursively);\n}\n\ntype IntergalacticComponent = ReactElement & {\n ref?: MutableRefObject<HTMLElement>;\n};\n\nexport function findAllComponents(Children: any, names: string[]): IntergalacticComponent[] {\n const result: IntergalacticComponent[] = [];\n\n const findAllAndAdd = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n findAllAndAdd(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n findAllAndAdd(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n result.push(child);\n }\n\n if (child.props.children) {\n return findAllAndAdd(child.props.children);\n }\n }\n }\n });\n };\n\n findAllAndAdd(Children);\n\n return result;\n}\n\n/**\n * Extract some components from Children and return them and rest of components as tuple.\n */\nexport function extractFrom(Children: any, names: string[]): IntergalacticComponent[][] {\n const extracted: IntergalacticComponent[] = [];\n const rest: IntergalacticComponent[] = [];\n\n const extractor = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n extractor(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n extractor(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n extracted.push(child);\n } else {\n rest.push(child);\n }\n }\n }\n });\n };\n\n extractor(Children);\n\n return [extracted, rest];\n}\n\nexport default findComponent;\n"],"mappings":"AAAA,OAAOA,KAAK,MAA0C,OAAO;AAC7D,OAAOC,iBAAiB,MAAM,yBAAqB;AACnD,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,2BAAuB;AAE1E,SAASC,aAAaA,CACpBC,QAAa,EACbC,KAAe,EACfC,WAAqB,EAEQ;EAAA,IAD7BC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;EAEX,IAAMG,QAAQ,GAAGP,QAAQ,CAACH,kBAAkB,CAAC,GAAGD,iBAAiB,CAACI,QAAQ,CAAC,GAAGA,QAAQ;EACtF,OAAOL,KAAK,CAACK,QAAQ,CAACQ,OAAO,CAACD,QAAQ,CAAC,CAACE,IAAI,CAAC,UAACC,KAAK,EAAK;IACtD,kBAAIf,KAAK,CAACgB,cAAc,CAACD,KAAK,CAAC,EAAE;MAC/B,IAAIA,KAAK,CAACE,IAAI,KAAKjB,KAAK,CAACkB,QAAQ,EAAE;QACjC,OAAOd,aAAa,CAACW,KAAK,CAACI,KAAK,CAACP,QAAQ,EAAEN,KAAK,EAAEC,WAAW,EAAEC,KAAK,CAAC;MACvE;MACA;MACA,IAAMY,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACd,cAAc,CAAC,IAAI,CAACY,KAAK,CAACE,IAAI,CAACI,WAAW,CAAC;MAC7E,IAAMC,MAAM,GAAG,CAAC,CAACF,cAAc,CAACN,IAAI,CAAC,UAACS,IAAY;QAAA,OAAKjB,KAAK,CAACkB,QAAQ,CAACD,IAAI,CAAC;MAAA,EAAC;MAE5E,IAAI,CAACD,MAAM,IAAIP,KAAK,CA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AS,CAACnB,KAAK,CAACI,KAAK,CAACP,QAAQ,CAAC;QACjC,CAAC,MAAM,IACL,OAAOG,KAAK,CAACE,IAAI,KAAK,UAAU,IAChCf,kBAAkB,IAAIa,KAAK,CAACE,IAAI,IAChCF,KAAK,CAACE,IAAI,CAACf,kBAAkB,CAAC,EAC9B;UACAgC,SAAS,CAACnB,KAAK,CAACE,IAAI,CAAC;QACvB,CAAC,MAAM;UACL;UACA,IAAMG,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACd,cAAc,CAAC,IAAI,CAACY,KAAK,CAACE,IAAI,CAACI,WAAW,CAAC;UAC7E,IAAMQ,SAAS,GAAG,CAAC,CAACT,cAAc,CAACN,IAAI,CAAC,UAACS,IAAY;YAAA,OAAKjB,KAAK,CAACkB,QAAQ,CAACD,IAAI,CAAC;UAAA,EAAC;UAE/E,IAAIM,SAAS,EAAE;YACbG,SAAS,CAACF,IAAI,CAACf,KAAK,CAAC;UACvB,CAAC,MAAM;YACLkB,IAAI,CAACH,IAAI,CAACf,KAAK,CAAC;UAClB;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAEDmB,SAAS,CAAC7B,QAAQ,CAAC;EAEnB,OAAO,CAAC2B,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAEA,eAAe7B,aAAa"}
package/lib/utils/ref.js CHANGED
@@ -90,6 +90,7 @@ function getNodeByRef(ref) {
90
90
  if (!node) return null;
91
91
  if (node.nodeType === 1) return node;
92
92
  if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;
93
+ if (! /*#__PURE__*/_react["default"].isValidElement(node)) return null;
93
94
  return (0, _reactDom.findDOMNode)(node);
94
95
  }
95
96
  //# sourceMappingURL=ref.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ref.js","names":["_react","_interopRequireDefault","require","_reactDom","setRef","ref","value","hasOwnProperty","getRef","current","useCallbackRef","initialValue","callback","_React$useState","React","useState","facade","last","_React$useState2","_slicedToArray2","useForkRef","_len","arguments","length","refs","Array","_key","useCallback","refValue","uniqueRefs","_toConsumableArray2","Set","forEach","forkRef","_len2","_key2","every","getNodeByRef","node","nodeType","Object","keys","findDOMNode"],"sources":["../../src/utils/ref.ts"],"sourcesContent":["import React, { MutableRefObject, Ref, RefObject } from 'react';\nimport { findDOMNode } from 'react-dom';\n\nexport function setRef<T>(ref: Ref<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref?.hasOwnProperty('current')) {\n // @ts-ignore\n ref['current'] = value;\n }\n}\n\nexport function getRef(ref: RefObject<Element> | Element): Element | null {\n if (!ref) return null;\n return 'current' in ref ? ref.current : ref;\n}\n\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n): MutableRefObject<T | null> {\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n if (last !== value) {\n ref.value = value;\n ref.callback(value, last);\n }\n },\n },\n }));\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n\nexport function useForkRef<T>(...refs: Ref<T>[]): Ref<T> {\n return React.useCallback((refValue: any) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n }, refs);\n}\n\nexport function forkRef<T>(...refs: Ref<T>[]): Ref<T> {\n if (refs.every((ref) => ref == null)) {\n return null;\n }\n return (refValue) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n };\n}\n\nexport type NodeByRef = RefObject<Element> | Element | (() => RefObject<Element> | Element);\n\nexport function getNodeByRef(ref: NodeByRef): Element | null {\n if (typeof ref === 'function') {\n ref = ref();\n }\n if (!ref) return null;\n\n const node = getRef(ref);\n if (!node) return null;\n if (node.nodeType === 1) return node;\n if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;\n\n return findDOMNode(node) as Element;\n}\n"],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GAAG,EAAE;EACb;EACA,IAAI,CAACA,GAAG,EAAE,OAAO,IAAI;EAErB,IAAMiC,IAAI,GAAG9B,MAAM,CAACH,GAAG,CAAC;EACxB,IAAI,CAACiC,IAAI,EAAE,OAAO,IAAI;EACtB,IAAIA,IAAI,CAACC,QAAQ,KAAK,CAAC,EAAE,OAAOD,IAAI;EACpC,IAAIE,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACf,MAAM,KAAK,CAAC,IAAI,uBAAuB,IAAIe,IAAI,EAAE,OAAO,IAAI;EAElF,OAAO,IAAAI,qBAAW,EAACJ,IAAI,CAAC;AAC1B"}
1
+ {"version":3,"file":"ref.js","names":["_react","_interopRequireDefault","require","_reactDom","setRef","ref","value","hasOwnProperty","getRef","current","useCallbackRef","initialValue","callback","_React$useState","React","useState","facade","last","_React$useState2","_slicedToArray2","useForkRef","_len","arguments","length","refs","Array","_key","useCallback","refValue","uniqueRefs","_toConsumableArray2","Set","forEach","forkRef","_len2","_key2","every","getNodeByRef","node","nodeType","Object","keys","isValidElement","findDOMNode"],"sources":["../../src/utils/ref.ts"],"sourcesContent":["import React, { MutableRefObject, Ref, RefObject } from 'react';\nimport { findDOMNode } from 'react-dom';\n\nexport function setRef<T>(ref: Ref<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref?.hasOwnProperty('current')) {\n // @ts-ignore\n ref['current'] = value;\n }\n}\n\nexport function getRef(ref: RefObject<Element> | Element): Element | null {\n if (!ref) return null;\n return 'current' in ref ? ref.current : ref;\n}\n\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n): MutableRefObject<T | null> {\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n if (last !== value) {\n ref.value = value;\n ref.callback(value, last);\n }\n },\n },\n }));\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n\nexport function useForkRef<T>(...refs: Ref<T>[]): Ref<T> {\n return React.useCallback((refValue: any) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n }, refs);\n}\n\nexport function forkRef<T>(...refs: Ref<T>[]): Ref<T> {\n if (refs.every((ref) => ref == null)) {\n return null;\n }\n return (refValue) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n };\n}\n\nexport type NodeByRef = RefObject<Element> | Element | (() => RefObject<Element> | Element);\n\nexport function getNodeByRef(ref: NodeByRef): Element | null {\n if (typeof ref === 'function') {\n ref = ref();\n }\n if (!ref) return null;\n\n const node = getRef(ref);\n if (!node) return null;\n if (node.nodeType === 1) return node;\n if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;\n if (!React.isValidElement(node)) return null;\n\n return findDOMNode(node) as Element;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEO,SAASE,MAAMA,CAAIC,GAAW,EAAEC,KAAQ,EAAE;EAC/C,IAAI,OAAOD,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,CAACC,KAAK,CAAC;EACZ,CAAC,MAAM,IAAID,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAEE,cAAc,CAAC,SAAS,CAAC,EAAE;IACzC;IACAF,GAAG,CAAC,SAAS,CAAC,GAAGC,KAAK;EACxB;AACF;AAEO,SAASE,MAAMA,CAACH,GAAiC,EAAkB;EACxE,IAAI,CAACA,GAAG,EAAE,OAAO,IAAI;EACrB,OAAO,SAAS,IAAIA,GAAG,GAAGA,GAAG,CAACI,OAAO,GAAGJ,GAAG;AAC7C;AAEO,SAASK,cAAcA,CAC5BC,YAAsB,EACtBC,QAA2D,EAC/B;EAC5B,IAAAC,eAAA,GAAcC,iBAAK,CAACC,QAAQ,CAAC;M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AAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;IAAJX,IAAI,CAAAW,KAAA,IAAAb,SAAA,CAAAa,KAAA;EAAA;EAChC,IAAIX,IAAI,CAACY,KAAK,CAAC,UAAC/B,GAAG;IAAA,OAAKA,GAAG,IAAI,IAAI;EAAA,EAAC,EAAE;IACpC,OAAO,IAAI;EACb;EACA,OAAO,UAACuB,QAAQ,EAAK;IACnB,IAAMC,UAAU,OAAAC,mBAAA,aAAO,IAAIC,GAAG,CAACP,IAAI,CAAC,CAAC;IACrCK,UAAU,CAACG,OAAO,CAAC,UAAC3B,GAAG;MAAA,OAAKD,MAAM,CAACC,GAAG,EAAEuB,QAAQ,CAAC;IAAA,EAAC;EACpD,CAAC;AACH;AAIO,SAASS,YAAYA,CAAChC,GAAc,EAAkB;EAC3D,IAAI,OAAOA,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,GAAGA,GAAG,EAAE;EACb;EACA,IAAI,CAACA,GAAG,EAAE,OAAO,IAAI;EAErB,IAAMiC,IAAI,GAAG9B,MAAM,CAACH,GAAG,CAAC;EACxB,IAAI,CAACiC,IAAI,EAAE,OAAO,IAAI;EACtB,IAAIA,IAAI,CAACC,QAAQ,KAAK,CAAC,EAAE,OAAOD,IAAI;EACpC,IAAIE,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACf,MAAM,KAAK,CAAC,IAAI,uBAAuB,IAAIe,IAAI,EAAE,OAAO,IAAI;EAClF,IAAI,eAACxB,iBAAK,CAAC4B,cAAc,CAACJ,IAAI,CAAC,EAAE,OAAO,IAAI;EAE5C,OAAO,IAAAK,qBAAW,EAACL,IAAI,CAAC;AAC1B"}
package/lib/utils/ref.mjs CHANGED
@@ -74,6 +74,7 @@ function getNodeByRef(ref) {
74
74
  if (!node) return null;
75
75
  if (node.nodeType === 1) return node;
76
76
  if (Object.keys(node).length === 1 && "getBoundingClientRect" in node) return null;
77
+ if (!/* @__PURE__ */ React.isValidElement(node)) return null;
77
78
  return findDOMNode(node);
78
79
  }
79
80
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"ref.mjs","names":["React","findDOMNode","setRef","ref","value","hasOwnProperty","getRef","current","useCallbackRef","initialValue","callback","_React$useState","useState","facade","last","_React$useState2","_slicedToArray","useForkRef","_len","arguments","length","refs","Array","_key","useCallback","refValue","uniqueRefs","_toConsumableArray","Set","forEach","forkRef","_len2","_key2","every","getNodeByRef","node","nodeType","Object","keys"],"sources":["../../src/utils/ref.ts"],"sourcesContent":["import React, { MutableRefObject, Ref, RefObject } from 'react';\nimport { findDOMNode } from 'react-dom';\n\nexport function setRef<T>(ref: Ref<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref?.hasOwnProperty('current')) {\n // @ts-ignore\n ref['current'] = value;\n }\n}\n\nexport function getRef(ref: RefObject<Element> | Element): Element | null {\n if (!ref) return null;\n return 'current' in ref ? ref.current : ref;\n}\n\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n): MutableRefObject<T | null> {\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n if (last !== value) {\n ref.value = value;\n ref.callback(value, last);\n }\n },\n },\n }));\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n\nexport function useForkRef<T>(...refs: Ref<T>[]): Ref<T> {\n return React.useCallback((refValue: any) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n }, refs);\n}\n\nexport function forkRef<T>(...refs: Ref<T>[]): Ref<T> {\n if (refs.every((ref) => ref == null)) {\n return null;\n }\n return (refValue) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n };\n}\n\nexport type NodeByRef = RefObject<Element> | Element | (() => RefObject<Element> | Element);\n\nexport function getNodeByRef(ref: NodeByRef): Element | null {\n if (typeof ref === 'function') {\n ref = ref();\n }\n if (!ref) return null;\n\n const node = getRef(ref);\n if (!node) return null;\n if (node.nodeType === 1) return node;\n if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;\n\n return findDOMNode(node) as Element;\n}\n"],"mappings":";;AAAA,OAAOA,KAAK,MAA4C,OAAO;AAC/D,SAASC,WAAW,QAAQ,WAAW;AAEvC,OAAO,SAASC,MAAMA,CAAIC,GAAW,EAAEC,KAAQ,EAAE;EAC/C,IAAI,OAAOD,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,CAACC,KAAK,CAAC;EACZ,CAAC,MAAM,IAAID,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAEE,cAAc,CAAC,SAAS,CAAC,EAAE;IACzC;IACAF,GAAG,CAAC,SAAS,CAAC,GAAGC,KAAK;EACxB;AACF;AAEA,OAAO,SAASE,MAAMA,CAACH,GAAiC,EAAkB;EACxE,IAAI,CAACA,GAAG,EAAE,OAAO,IAAI;EACrB,OAAO,SAAS,IAAIA,GAAG,GAAGA,GAAG,CAACI,OAAO,GAAGJ,GAAG;AAC7C;AAEA,OAAO,SAASK,cAAcA,CAC5BC,YAAsB,EACtBC,QAA2D,EAC/B;EAC5B,IAAAC,eAAA,GAAcX,KAAK,CAACY,QAAQ,CAAC;MAAA,OAAO;QAClC;QACAR,KAAK,EAAEK,YAAY;QACnB;QACAC,QAAQ,EAARA,QAAQ;QACR;QACAG,MAAM,EAAE;UACN,IAAIN,OAAOA,CAAA,EAAG;YACZ,OAAOJ,GAAG,CAACC,KAAK;UAClB,CAAC;UACD,IAAIG,OAAOA,CAACH,KAAK,EAAE;YACjB,IAAMU,IAAI,GAAGX,GAAG,CAACC,KAAK;YACtB,IAAIU,IAAI,KAAKV,KAAK,EAAE;cAClBD,GAAG,CAACC,KAAK,GAAGA,KAAK;cACjBD,GAAG,CAACO,QAAQ,CAACN,KAAK,EAAEU,IAAI,CAAC;YAC3B;UACF;QAC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,OAAKD,MAAM,CAACC,GAAG,EAAEsB,QAAQ,CAAC;IAAA,EAAC;EACpD,CAAC;AACH;AAIA,OAAO,SAASS,YAAYA,CAAC/B,GAAc,EAAkB;EAC3D,IAAI,OAAOA,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,GAAGA,GAAG,EAAE;EACb;EACA,IAAI,CAACA,GAAG,EAAE,OAAO,IAAI;EAErB,IAAMgC,IAAI,GAAG7B,MAAM,CAACH,GAAG,CAAC;EACxB,IAAI,CAACgC,IAAI,EAAE,OAAO,IAAI;EACtB,IAAIA,IAAI,CAACC,QAAQ,KAAK,CAAC,EAAE,OAAOD,IAAI;EACpC,IAAIE,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACf,MAAM,KAAK,CAAC,IAAI,uBAAuB,IAAIe,IAAI,EAAE,OAAO,IAAI;EAElF,OAAOlC,WAAW,CAACkC,IAAI,CAAC;AAC1B"}
1
+ {"version":3,"file":"ref.mjs","names":["React","findDOMNode","setRef","ref","value","hasOwnProperty","getRef","current","useCallbackRef","initialValue","callback","_React$useState","useState","facade","last","_React$useState2","_slicedToArray","useForkRef","_len","arguments","length","refs","Array","_key","useCallback","refValue","uniqueRefs","_toConsumableArray","Set","forEach","forkRef","_len2","_key2","every","getNodeByRef","node","nodeType","Object","keys","isValidElement"],"sources":["../../src/utils/ref.ts"],"sourcesContent":["import React, { MutableRefObject, Ref, RefObject } from 'react';\nimport { findDOMNode } from 'react-dom';\n\nexport function setRef<T>(ref: Ref<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref?.hasOwnProperty('current')) {\n // @ts-ignore\n ref['current'] = value;\n }\n}\n\nexport function getRef(ref: RefObject<Element> | Element): Element | null {\n if (!ref) return null;\n return 'current' in ref ? ref.current : ref;\n}\n\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n): MutableRefObject<T | null> {\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n if (last !== value) {\n ref.value = value;\n ref.callback(value, last);\n }\n },\n },\n }));\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n\nexport function useForkRef<T>(...refs: Ref<T>[]): Ref<T> {\n return React.useCallback((refValue: any) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n }, refs);\n}\n\nexport function forkRef<T>(...refs: Ref<T>[]): Ref<T> {\n if (refs.every((ref) => ref == null)) {\n return null;\n }\n return (refValue) => {\n const uniqueRefs = [...new Set(refs)];\n uniqueRefs.forEach((ref) => setRef(ref, refValue));\n };\n}\n\nexport type NodeByRef = RefObject<Element> | Element | (() => RefObject<Element> | Element);\n\nexport function getNodeByRef(ref: NodeByRef): Element | null {\n if (typeof ref === 'function') {\n ref = ref();\n }\n if (!ref) return null;\n\n const node = getRef(ref);\n if (!node) return null;\n if (node.nodeType === 1) return node;\n if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;\n if (!React.isValidElement(node)) return null;\n\n return findDOMNode(node) as Element;\n}\n"],"mappings":";;AAAA,OAAOA,KAAK,MAA4C,OAAO;AAC/D,SAASC,WAAW,QAAQ,WAAW;AAEvC,OAAO,SAASC,MAAMA,CAAIC,GAAW,EAAEC,KAAQ,EAAE;EAC/C,IAAI,OAAOD,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,CAACC,KAAK,CAAC;EACZ,CAAC,MAAM,IAAID,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAEE,cAAc,CAAC,SAAS,CAAC,EAAE;IACzC;IACAF,GAAG,CAAC,SAAS,CAAC,GAAGC,KAAK;EACxB;AACF;AAEA,OAAO,SAASE,MAAMA,CAACH,GAAiC,EAAkB;EACxE,IAAI,CAACA,GAAG,EAAE,OAAO,IAAI;EACrB,OAAO,SAAS,IAAIA,GAAG,GAAGA,GAAG,C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,7 @@
1
1
  {
2
2
  "name": "@semcore/core",
3
3
  "description": "Semrush Core Component",
4
- "version": "16.0.0-prerelease.16",
4
+ "version": "16.0.0-prerelease.18",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -18,19 +18,19 @@
18
18
  "import": "./src/index.ts",
19
19
  "types": "./src/index.ts"
20
20
  },
21
- "./lib/themes/default.css": {
21
+ "./lib/theme/themes/default.css": {
22
22
  "require": "./lib/theme/themes/default.css",
23
23
  "import": "./lib/theme/themes/default.css"
24
24
  },
25
- "./lib/themes/light.css": {
25
+ "./lib/theme/themes/light.css": {
26
26
  "require": "./lib/theme/themes/light.css",
27
27
  "import": "./lib/theme/themes/light.css"
28
28
  },
29
- "./lib/themes/dark.css": {
29
+ "./lib/theme/themes/dark.css": {
30
30
  "require": "./lib/theme/themes/dark.css",
31
31
  "import": "./lib/theme/themes/dark.css"
32
32
  },
33
- "./lib/themes/auto.css": {
33
+ "./lib/theme/themes/auto.css": {
34
34
  "require": "./lib/theme/themes/auto.css",
35
35
  "import": "./lib/theme/themes/auto.css"
36
36
  },
@@ -44,6 +44,11 @@
44
44
  "import": "./lib/utils/focus-lock/isFocusable.mjs",
45
45
  "types": "./lib/utils/focus-lock/isFocusable.d.ts"
46
46
  },
47
+ "./lib/utils/focus-lock/isFocusInside": {
48
+ "require": "./lib/utils/focus-lock/isFocusInside.js",
49
+ "import": "./lib/utils/focus-lock/isFocusInside.mjs",
50
+ "types": "./lib/utils/focus-lock/isFocusInside.d.ts"
51
+ },
47
52
  "./lib/utils/enhances/a11yEnhance": {
48
53
  "require": "./lib/utils/enhances/a11yEnhance.js",
49
54
  "import": "./lib/utils/enhances/a11yEnhance.mjs",