@semcore/core 17.3.1-prerelease.0 → 17.3.1-prerelease.11

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
@@ -2,10 +2,11 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [17.3.1] - 2026-08-26
5
+ ## [17.3.1] - 2026-09-10
6
6
 
7
7
  ### Fixed
8
8
 
9
+ - Style merging mechanism.
9
10
  - Performance regression for `useScrollBarWidth` hook.
10
11
 
11
12
  ## [17.3.0] - 2026-07-30
@@ -61,10 +61,10 @@ function assignProps(props = {}, source = {}) {
61
61
  newProps.ref = forkRef(newProps.ref, props.forwardRef);
62
62
  newProps.forwardRef = newProps.ref;
63
63
  }
64
- if (source.style && props.style) {
64
+ if (source.style || props.style) {
65
65
  newProps.style = {
66
- ...source.style,
67
- ...props.style
66
+ ...source.style ?? {},
67
+ ...props.style ?? {}
68
68
  };
69
69
  }
70
70
  if (source.className) {
@@ -72,10 +72,10 @@ function assignProps(props = {}, source = {}) {
72
72
  newProps.ref = (0, _ref.forkRef)(newProps.ref, props.forwardRef);
73
73
  newProps.forwardRef = newProps.ref;
74
74
  }
75
- if (source.style && props.style) {
75
+ if (source.style || props.style) {
76
76
  newProps.style = {
77
- ...source.style,
78
- ...props.style
77
+ ...(source.style ?? {}),
78
+ ...(props.style ?? {})
79
79
  };
80
80
  }
81
81
  if (source.className) {
@@ -1 +1 @@
1
- {"version":3,"file":"assignProps.js","names":["_classnames","_interopRequireDefault","require","_ref","_index","callAllEventHandlers","fns","args","some","fn","result","assignHandlers","props","source","Object","keys","reduce","proxySource","propName","startsWith","assignHandlersInner","assignProps","newProps","key","originalKey","slice","length","sourceDescriptorRef","getOwnPropertyDescriptor","propsDescriptorRef","configurable","ref","forkRef","forwardRef","style","className","cn","styles","sstyled","merge"],"sources":["../../src/utils/assignProps.ts"],"sourcesContent":["import cn from 'classnames';\nimport type { CSSProperties, DetailedHTMLProps, Ref, StyleHTMLAttributes } from 'react';\n\nimport { forkRef } from './ref';\nimport { sstyled } from '../styled/index';\n\nexport function callAllEventHandlers(...fns: Array<Function | undefined>) {\n return (...args: any[]) =>\n !fns.some((fn) => {\n let result;\n if (fn) {\n result = fn(...args);\n }\n return typeof result === 'boolean' && !result;\n });\n}\n\nexport function assignHandlers(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (typeof source[propName] === 'function' && propName.startsWith('on')) {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n }\n return proxySource;\n }, {});\n}\n\nfunction assignHandlersInner(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (propName !== 'ref' && propName.startsWith('on')) {\n if (typeof source[propName] === 'function' && typeof props[propName] === 'function') {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n } else if (typeof source[propName] === 'function') {\n proxySource[propName] = source[propName];\n } else if (typeof props[propName] === 'function') {\n proxySource[propName] = props[propName];\n }\n }\n return proxySource;\n }, {});\n}\n\nexport interface AssignableProps {\n ref?: Ref<any>;\n style?: CSSProperties;\n className?: string;\n styles?: DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;\n\n [key: string]: any;\n}\n\nexport default function assignProps<P extends AssignableProps, S extends AssignableProps>(\n props: P = {} as P,\n source: S = {} as S,\n) {\n // @ts-ignore\n if (props === source) return props;\n const newProps = {\n ...source,\n ...props,\n ...assignHandlersInner(props, source),\n };\n for (const key in source) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = source[key];\n }\n }\n for (const key in props) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = props[key];\n }\n }\n\n // because react set getter for ref\n const sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, 'ref');\n const propsDescriptorRef = Object.getOwnPropertyDescriptor(props, 'ref');\n if (sourceDescriptorRef?.configurable && propsDescriptorRef?.configurable) {\n newProps.ref = forkRef(source.ref as any, props.ref as any);\n }\n\n if (props.forwardRef) {\n newProps.ref = forkRef(newProps.ref as any, props.forwardRef as any);\n newProps.forwardRef = newProps.ref;\n }\n\n if (source.style && props.style) {\n newProps.style = {\n ...source.style,\n ...props.style,\n };\n }\n\n if (source.className) {\n newProps.className = cn(props.className, source.className);\n }\n\n if (source.styles && props.styles) {\n newProps.styles = sstyled.merge(source.styles, props.styles);\n }\n\n return newProps;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,oBAAoBA,CAAC,GAAGC,GAAgC,EAAE;EACxE,OAAO,CAAC,GAAGC,IAAW,KACpB,CAACD,GAAG,CAACE,IAAI,CAAEC,EAAE,IAAK;IAChB,IAAIC,MAAM;IACV,IAAID,EAAE,EAAE;MACNC,MAAM,GAAGD,EAAE,CAAC,GAAGF,IAAI,CAAC;IACtB;IACA,OAAO,OAAOG,MAAM,KAAK,SAAS,IAAI,CAACA,MAAM;EAC/C,CAAC,CAAC;AACN;AAEO,SAASC,cAAcA,CAACC,KAAU,EAAEC,MAAW,EAAE;EACtD,OAAOC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,CAACC,WAAgB,EAAEC,QAAQ,KAAK;IAChE,IAAI,OAAOL,MAAM,CAACK,QAAQ,CAAC,KAAK,UAAU,IAAIA,QAAQ,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;MACvEF,WAAW,CAACC,QAAQ,CAAC,GAAGb,oBAAoB,CAACO,KAAK,CAACM,QAAQ,CAAC,EAAEL,MAAM,CAACK,QAAQ,CAAC,CAAC;IACjF;IACA,OAAOD,WAAW;EACpB,CAAC,EAAE,CAAC,CAAC,CAAC;AACR;AAEA,SAASG,m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,MAAM,CAACwB,MAAM,IAAIzB,KAAK,CAACyB,MAAM,EAAE;IACjCf,QAAQ,CAACe,MAAM,GAAGC,cAAO,CAACC,KAAK,CAAC1B,MAAM,CAACwB,MAAM,EAAEzB,KAAK,CAACyB,MAAM,CAAC;EAC9D;EAEA,OAAOf,QAAQ;AACjB","ignoreList":[]}
1
+ {"version":3,"file":"assignProps.js","names":["_classnames","_interopRequireDefault","require","_ref","_index","callAllEventHandlers","fns","args","some","fn","result","assignHandlers","props","source","Object","keys","reduce","proxySource","propName","startsWith","assignHandlersInner","assignProps","newProps","key","originalKey","slice","length","sourceDescriptorRef","getOwnPropertyDescriptor","propsDescriptorRef","configurable","ref","forkRef","forwardRef","style","className","cn","styles","sstyled","merge"],"sources":["../../src/utils/assignProps.ts"],"sourcesContent":["import cn from 'classnames';\nimport type { CSSProperties, DetailedHTMLProps, Ref, StyleHTMLAttributes } from 'react';\n\nimport { forkRef } from './ref';\nimport { sstyled } from '../styled/index';\n\nexport function callAllEventHandlers(...fns: Array<Function | undefined>) {\n return (...args: any[]) =>\n !fns.some((fn) => {\n let result;\n if (fn) {\n result = fn(...args);\n }\n return typeof result === 'boolean' && !result;\n });\n}\n\nexport function assignHandlers(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (typeof source[propName] === 'function' && propName.startsWith('on')) {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n }\n return proxySource;\n }, {});\n}\n\nfunction assignHandlersInner(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (propName !== 'ref' && propName.startsWith('on')) {\n if (typeof source[propName] === 'function' && typeof props[propName] === 'function') {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n } else if (typeof source[propName] === 'function') {\n proxySource[propName] = source[propName];\n } else if (typeof props[propName] === 'function') {\n proxySource[propName] = props[propName];\n }\n }\n return proxySource;\n }, {});\n}\n\nexport interface AssignableProps {\n ref?: Ref<any>;\n style?: CSSProperties;\n className?: string;\n styles?: DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;\n\n [key: string]: any;\n}\n\nexport default function assignProps<P extends AssignableProps, S extends AssignableProps>(\n props: P = {} as P,\n source: S = {} as S,\n) {\n // @ts-ignore\n if (props === source) return props;\n const newProps = {\n ...source,\n ...props,\n ...assignHandlersInner(props, source),\n };\n for (const key in source) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = source[key];\n }\n }\n for (const key in props) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = props[key];\n }\n }\n\n // because react set getter for ref\n const sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, 'ref');\n const propsDescriptorRef = Object.getOwnPropertyDescriptor(props, 'ref');\n if (sourceDescriptorRef?.configurable && propsDescriptorRef?.configurable) {\n newProps.ref = forkRef(source.ref as any, props.ref as any);\n }\n\n if (props.forwardRef) {\n newProps.ref = forkRef(newProps.ref as any, props.forwardRef as any);\n newProps.forwardRef = newProps.ref;\n }\n\n if (source.style || props.style) {\n newProps.style = {\n ...(source.style ?? {}),\n ...(props.style ?? {}),\n };\n }\n\n if (source.className) {\n newProps.className = cn(props.className, source.className);\n }\n\n if (source.styles && props.styles) {\n newProps.styles = sstyled.merge(source.styles, props.styles);\n }\n\n return newProps;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,oBAAoBA,CAAC,GAAGC,GAAgC,EAAE;EACxE,OAAO,CAAC,GAAGC,IAAW,KACpB,CAACD,GAAG,CAACE,IAAI,CAAEC,EAAE,IAAK;IAChB,IAAIC,MAAM;IACV,IAAID,EAAE,EAAE;MACNC,MAAM,GAAGD,EAAE,CAAC,GAAGF,IAAI,CAAC;IACtB;IACA,OAAO,OAAOG,MAAM,KAAK,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pBX,QAAQ,CAACS,GAAG,GAAG,IAAAC,YAAO,EAACV,QAAQ,CAACS,GAAG,EAASnB,KAAK,CAACqB,UAAiB,CAAC;IACpEX,QAAQ,CAACW,UAAU,GAAGX,QAAQ,CAACS,GAAG;EACpC;EAEA,IAAIlB,MAAM,CAACqB,KAAK,IAAItB,KAAK,CAACsB,KAAK,EAAE;IAC/BZ,QAAQ,CAACY,KAAK,GAAG;MACf,IAAIrB,MAAM,CAACqB,KAAK,IAAI,CAAC,CAAC,CAAC;MACvB,IAAItB,KAAK,CAACsB,KAAK,IAAI,CAAC,CAAC;IACvB,CAAC;EACH;EAEA,IAAIrB,MAAM,CAACsB,SAAS,EAAE;IACpBb,QAAQ,CAACa,SAAS,GAAG,IAAAC,mBAAE,EAACxB,KAAK,CAACuB,SAAS,EAAEtB,MAAM,CAACsB,SAAS,CAAC;EAC5D;EAEA,IAAItB,MAAM,CAACwB,MAAM,IAAIzB,KAAK,CAACyB,MAAM,EAAE;IACjCf,QAAQ,CAACe,MAAM,GAAGC,cAAO,CAACC,KAAK,CAAC1B,MAAM,CAACwB,MAAM,EAAEzB,KAAK,CAACyB,MAAM,CAAC;EAC9D;EAEA,OAAOf,QAAQ;AACjB","ignoreList":[]}
@@ -61,10 +61,10 @@ function assignProps(props = {}, source = {}) {
61
61
  newProps.ref = forkRef(newProps.ref, props.forwardRef);
62
62
  newProps.forwardRef = newProps.ref;
63
63
  }
64
- if (source.style && props.style) {
64
+ if (source.style || props.style) {
65
65
  newProps.style = {
66
- ...source.style,
67
- ...props.style
66
+ ...source.style ?? {},
67
+ ...props.style ?? {}
68
68
  };
69
69
  }
70
70
  if (source.className) {
@@ -1 +1 @@
1
- {"version":3,"file":"assignProps.mjs","names":["cn","forkRef","sstyled","callAllEventHandlers","fns","args","some","fn","result","assignHandlers","props","source","Object","keys","reduce","proxySource","propName","startsWith","assignHandlersInner","assignProps","newProps","key","originalKey","slice","length","sourceDescriptorRef","getOwnPropertyDescriptor","propsDescriptorRef","configurable","ref","forwardRef","style","className","styles","merge"],"sources":["../../src/utils/assignProps.ts"],"sourcesContent":["import cn from 'classnames';\nimport type { CSSProperties, DetailedHTMLProps, Ref, StyleHTMLAttributes } from 'react';\n\nimport { forkRef } from './ref';\nimport { sstyled } from '../styled/index';\n\nexport function callAllEventHandlers(...fns: Array<Function | undefined>) {\n return (...args: any[]) =>\n !fns.some((fn) => {\n let result;\n if (fn) {\n result = fn(...args);\n }\n return typeof result === 'boolean' && !result;\n });\n}\n\nexport function assignHandlers(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (typeof source[propName] === 'function' && propName.startsWith('on')) {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n }\n return proxySource;\n }, {});\n}\n\nfunction assignHandlersInner(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (propName !== 'ref' && propName.startsWith('on')) {\n if (typeof source[propName] === 'function' && typeof props[propName] === 'function') {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n } else if (typeof source[propName] === 'function') {\n proxySource[propName] = source[propName];\n } else if (typeof props[propName] === 'function') {\n proxySource[propName] = props[propName];\n }\n }\n return proxySource;\n }, {});\n}\n\nexport interface AssignableProps {\n ref?: Ref<any>;\n style?: CSSProperties;\n className?: string;\n styles?: DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;\n\n [key: string]: any;\n}\n\nexport default function assignProps<P extends AssignableProps, S extends AssignableProps>(\n props: P = {} as P,\n source: S = {} as S,\n) {\n // @ts-ignore\n if (props === source) return props;\n const newProps = {\n ...source,\n ...props,\n ...assignHandlersInner(props, source),\n };\n for (const key in source) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = source[key];\n }\n }\n for (const key in props) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = props[key];\n }\n }\n\n // because react set getter for ref\n const sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, 'ref');\n const propsDescriptorRef = Object.getOwnPropertyDescriptor(props, 'ref');\n if (sourceDescriptorRef?.configurable && propsDescriptorRef?.configurable) {\n newProps.ref = forkRef(source.ref as any, props.ref as any);\n }\n\n if (props.forwardRef) {\n newProps.ref = forkRef(newProps.ref as any, props.forwardRef as any);\n newProps.forwardRef = newProps.ref;\n }\n\n if (source.style && props.style) {\n newProps.style = {\n ...source.style,\n ...props.style,\n };\n }\n\n if (source.className) {\n newProps.className = cn(props.className, source.className);\n }\n\n if (source.styles && props.styles) {\n newProps.styles = sstyled.merge(source.styles, props.styles);\n }\n\n return newProps;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,YAAY;AAG3B,SAASC,OAAO,QAAQ,WAAO;AAC/B,SAASC,OAAO,QAAQ,qBAAiB;AAEzC,OAAO,SAASC,oBAAoBA,CAAC,GAAGC,GAAgC,EAAE;EACxE,OAAO,CAAC,GAAGC,IAAW,KACpB,CAACD,GAAG,CAACE,IAAI,CAAEC,EAAE,IAAK;IAChB,IAAIC,MAAM;IACV,IAAID,EAAE,EAAE;MACNC,MAAM,GAAGD,EAAE,CAAC,GAAGF,IAAI,CAAC;IACtB;IACA,OAAO,OAAOG,MAAM,KAAK,SAAS,IAAI,CAACA,MAAM;EAC/C,CAAC,CAAC;AACN;AAEA,OAAO,SAASC,cAAcA,CAACC,KAAU,EAAEC,MAAW,EAAE;EACtD,OAAOC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,CAACC,WAAgB,EAAEC,QAAQ,KAAK;IAChE,IAAI,OAAOL,MAAM,CAACK,QAAQ,CAAC,KAAK,UAAU,IAAIA,QAAQ,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;MACvEF,WAAW,CAACC,QAAQ,CAAC,GAAGb,oBAAoB,CAACO,KAAK,CAACM,QAAQ,CAAC,EAAEL,MAAM,CAACK,QAAQ,CAAC,CAAC;IACjF;IACA,OAAOD,WAAW;EACpB,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AACqB,SAAS,CAAC;EAC5D;EAEA,IAAIrB,MAAM,CAACsB,MAAM,IAAIvB,KAAK,CAACuB,MAAM,EAAE;IACjCb,QAAQ,CAACa,MAAM,GAAG/B,OAAO,CAACgC,KAAK,CAACvB,MAAM,CAACsB,MAAM,EAAEvB,KAAK,CAACuB,MAAM,CAAC;EAC9D;EAEA,OAAOb,QAAQ;AACjB","ignoreList":[]}
1
+ {"version":3,"file":"assignProps.mjs","names":["cn","forkRef","sstyled","callAllEventHandlers","fns","args","some","fn","result","assignHandlers","props","source","Object","keys","reduce","proxySource","propName","startsWith","assignHandlersInner","assignProps","newProps","key","originalKey","slice","length","sourceDescriptorRef","getOwnPropertyDescriptor","propsDescriptorRef","configurable","ref","forwardRef","style","className","styles","merge"],"sources":["../../src/utils/assignProps.ts"],"sourcesContent":["import cn from 'classnames';\nimport type { CSSProperties, DetailedHTMLProps, Ref, StyleHTMLAttributes } from 'react';\n\nimport { forkRef } from './ref';\nimport { sstyled } from '../styled/index';\n\nexport function callAllEventHandlers(...fns: Array<Function | undefined>) {\n return (...args: any[]) =>\n !fns.some((fn) => {\n let result;\n if (fn) {\n result = fn(...args);\n }\n return typeof result === 'boolean' && !result;\n });\n}\n\nexport function assignHandlers(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (typeof source[propName] === 'function' && propName.startsWith('on')) {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n }\n return proxySource;\n }, {});\n}\n\nfunction assignHandlersInner(props: any, source: any) {\n return Object.keys(source).reduce((proxySource: any, propName) => {\n if (propName !== 'ref' && propName.startsWith('on')) {\n if (typeof source[propName] === 'function' && typeof props[propName] === 'function') {\n proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);\n } else if (typeof source[propName] === 'function') {\n proxySource[propName] = source[propName];\n } else if (typeof props[propName] === 'function') {\n proxySource[propName] = props[propName];\n }\n }\n return proxySource;\n }, {});\n}\n\nexport interface AssignableProps {\n ref?: Ref<any>;\n style?: CSSProperties;\n className?: string;\n styles?: DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;\n\n [key: string]: any;\n}\n\nexport default function assignProps<P extends AssignableProps, S extends AssignableProps>(\n props: P = {} as P,\n source: S = {} as S,\n) {\n // @ts-ignore\n if (props === source) return props;\n const newProps = {\n ...source,\n ...props,\n ...assignHandlersInner(props, source),\n };\n for (const key in source) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = source[key];\n }\n }\n for (const key in props) {\n if (key.startsWith('use:')) {\n const originalKey = key.slice('use:'.length);\n newProps[originalKey] = props[key];\n }\n }\n\n // because react set getter for ref\n const sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, 'ref');\n const propsDescriptorRef = Object.getOwnPropertyDescriptor(props, 'ref');\n if (sourceDescriptorRef?.configurable && propsDescriptorRef?.configurable) {\n newProps.ref = forkRef(source.ref as any, props.ref as any);\n }\n\n if (props.forwardRef) {\n newProps.ref = forkRef(newProps.ref as any, props.forwardRef as any);\n newProps.forwardRef = newProps.ref;\n }\n\n if (source.style || props.style) {\n newProps.style = {\n ...(source.style ?? {}),\n ...(props.style ?? {}),\n };\n }\n\n if (source.className) {\n newProps.className = cn(props.className, source.className);\n }\n\n if (source.styles && props.styles) {\n newProps.styles = sstyled.merge(source.styles, props.styles);\n }\n\n return newProps;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,YAAY;AAG3B,SAASC,OAAO,QAAQ,WAAO;AAC/B,SAASC,OAAO,QAAQ,qBAAiB;AAEzC,OAAO,SAASC,oBAAoBA,CAAC,GAAGC,GAAgC,EAAE;EACxE,OAAO,CAAC,GAAGC,IAAW,KACpB,CAACD,GAAG,CAACE,IAAI,CAAEC,EAAE,IAAK;IAChB,IAAIC,MAAM;IACV,IAAID,EAAE,EAAE;MACNC,MAAM,GAAGD,EAAE,CAAC,GAAGF,IAAI,CAAC;IACtB;IACA,OAAO,OAAOG,MAAM,KAAK,S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E;IACpBV,QAAQ,CAACS,GAAG,GAAG5B,OAAO,CAACmB,QAAQ,CAACS,GAAG,EAASnB,KAAK,CAACoB,UAAiB,CAAC;IACpEV,QAAQ,CAACU,UAAU,GAAGV,QAAQ,CAACS,GAAG;EACpC;EAEA,IAAIlB,MAAM,CAACoB,KAAK,IAAIrB,KAAK,CAACqB,KAAK,EAAE;IAC/BX,QAAQ,CAACW,KAAK,GAAG;MACf,IAAIpB,MAAM,CAACoB,KAAK,IAAI,CAAC,CAAC,CAAC;MACvB,IAAIrB,KAAK,CAACqB,KAAK,IAAI,CAAC,CAAC;IACvB,CAAC;EACH;EAEA,IAAIpB,MAAM,CAACqB,SAAS,EAAE;IACpBZ,QAAQ,CAACY,SAAS,GAAGhC,EAAE,CAACU,KAAK,CAACsB,SAAS,EAAErB,MAAM,CAACqB,SAAS,CAAC;EAC5D;EAEA,IAAIrB,MAAM,CAACsB,MAAM,IAAIvB,KAAK,CAACuB,MAAM,EAAE;IACjCb,QAAQ,CAACa,MAAM,GAAG/B,OAAO,CAACgC,KAAK,CAACvB,MAAM,CAACsB,MAAM,EAAEvB,KAAK,CAACuB,MAAM,CAAC;EAC9D;EAEA,OAAOb,QAAQ;AACjB","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/core",
3
3
  "description": "Semrush Core Component",
4
- "version": "17.3.1-prerelease.0",
4
+ "version": "17.3.1-prerelease.11",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -330,7 +330,7 @@
330
330
  "@types/classnames": "2.2.6",
331
331
  "@types/hoist-non-react-statics": "^3.3.6",
332
332
  "@semcore/testing-utils": "1.0.0",
333
- "@semcore/theme": "2.3.0"
333
+ "@semcore/theme": "2.3.1"
334
334
  },
335
335
  "scripts": {
336
336
  "build": "pnpm semcore-builder --coreUtils && pnpm vite build"