@semcore/core 17.0.0 → 17.0.1-prerelease.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.md +3 -111
- package/README.md +35 -5
- package/lib/LastInteractionType.js +36 -22
- package/lib/LastInteractionType.js.map +1 -1
- package/lib/LastInteractionType.mjs +33 -19
- package/lib/LastInteractionType.mjs.map +1 -1
- package/lib/core-types/Component.js +41 -25
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +38 -18
- package/lib/core-types/Component.mjs.map +1 -1
- package/lib/core-types/symbols.js +9 -9
- package/lib/core-types/symbols.js.map +1 -1
- package/lib/core-types/symbols.mjs +9 -9
- package/lib/core-types/symbols.mjs.map +1 -1
- package/lib/coreFactory.js +238 -158
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +189 -133
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/decorators/propsObserver.js +64 -36
- package/lib/decorators/propsObserver.js.map +1 -1
- package/lib/decorators/propsObserver.mjs +61 -33
- package/lib/decorators/propsObserver.mjs.map +1 -1
- package/lib/decorators/reactive.js +17 -17
- package/lib/decorators/reactive.js.map +1 -1
- package/lib/decorators/reactive.mjs +15 -15
- package/lib/decorators/reactive.mjs.map +1 -1
- package/lib/enhancement/Children.js +59 -51
- package/lib/enhancement/Children.js.map +1 -1
- package/lib/enhancement/Children.mjs +41 -47
- package/lib/enhancement/Children.mjs.map +1 -1
- package/lib/enhancement/Root.js +37 -36
- package/lib/enhancement/Root.js.map +1 -1
- package/lib/enhancement/Root.mjs +18 -28
- package/lib/enhancement/Root.mjs.map +1 -1
- package/lib/enhancement/dataName.js +8 -7
- package/lib/enhancement/dataName.js.map +1 -1
- package/lib/enhancement/dataName.mjs +5 -5
- package/lib/enhancement/dataName.mjs.map +1 -1
- package/lib/enhancement/enhance.js +9 -6
- package/lib/enhancement/enhance.js.map +1 -1
- package/lib/enhancement/enhance.mjs +7 -4
- package/lib/enhancement/enhance.mjs.map +1 -1
- package/lib/enhancement/functionDefaultProps.js +6 -6
- package/lib/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/enhancement/functionDefaultProps.mjs.map +1 -1
- package/lib/enhancement/i18n.js +13 -13
- package/lib/enhancement/i18n.js.map +1 -1
- package/lib/enhancement/i18n.mjs +9 -10
- package/lib/enhancement/i18n.mjs.map +1 -1
- package/lib/enhancement/inheritedName.js +8 -7
- package/lib/enhancement/inheritedName.js.map +1 -1
- package/lib/enhancement/inheritedName.mjs +5 -5
- package/lib/enhancement/inheritedName.mjs.map +1 -1
- package/lib/enhancement/staticChildren.js +56 -47
- package/lib/enhancement/staticChildren.js.map +1 -1
- package/lib/enhancement/staticChildren.mjs +48 -43
- package/lib/enhancement/staticChildren.mjs.map +1 -1
- package/lib/enhancement/style.js +27 -29
- package/lib/enhancement/style.js.map +1 -1
- package/lib/enhancement/style.mjs +20 -26
- package/lib/enhancement/style.mjs.map +1 -1
- package/lib/enhancement/uncontrolledProps.js +65 -46
- package/lib/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/enhancement/uncontrolledProps.mjs +52 -43
- package/lib/enhancement/uncontrolledProps.mjs.map +1 -1
- package/lib/esm/LastInteractionType.mjs +33 -19
- package/lib/esm/core-types/Component.mjs +38 -18
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +189 -133
- package/lib/esm/enhancement/Children.mjs +41 -47
- package/lib/esm/enhancement/Root.mjs +18 -28
- package/lib/esm/enhancement/dataName.mjs +5 -5
- package/lib/esm/enhancement/enhance.mjs +7 -4
- package/lib/esm/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/esm/enhancement/i18n.mjs +9 -10
- package/lib/esm/enhancement/inheritedName.mjs +5 -5
- package/lib/esm/enhancement/staticChildren.mjs +48 -43
- package/lib/esm/enhancement/style.mjs +20 -26
- package/lib/esm/enhancement/uncontrolledProps.mjs +52 -43
- package/lib/esm/register.mjs +20 -12
- package/lib/esm/styled/reshadow-core.mjs +111 -98
- package/lib/esm/styled/sstyled.mjs +41 -31
- package/lib/esm/utils/assignProps.mjs +36 -32
- package/lib/esm/utils/enhances/WithI18n.mjs +17 -15
- package/lib/esm/utils/enhances/i18nEnhance.mjs +61 -47
- package/lib/esm/utils/logger.mjs +21 -13
- package/lib/esm/utils/pick.mjs +4 -4
- package/lib/esm/utils/ref.mjs +43 -27
- package/lib/esm/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/index.js +17 -17
- package/lib/register.js +24 -17
- package/lib/register.js.map +1 -1
- package/lib/register.mjs +20 -12
- package/lib/register.mjs.map +1 -1
- package/lib/styled/index.js +4 -4
- package/lib/styled/reshadow-core.js +104 -102
- package/lib/styled/reshadow-core.js.map +1 -1
- package/lib/styled/reshadow-core.mjs +111 -98
- package/lib/styled/reshadow-core.mjs.map +1 -1
- package/lib/styled/sstyled.js +53 -31
- package/lib/styled/sstyled.js.map +1 -1
- package/lib/styled/sstyled.mjs +41 -31
- package/lib/styled/sstyled.mjs.map +1 -1
- package/lib/theme/themes/dark.js +2 -2
- package/lib/theme/themes/dark.js.map +1 -1
- package/lib/theme/themes/default.js +2 -2
- package/lib/theme/themes/default.js.map +1 -1
- package/lib/theme/themes/highlights-dark.js +2 -2
- package/lib/theme/themes/highlights-dark.js.map +1 -1
- package/lib/theme/themes/highlights-light.js +2 -2
- package/lib/theme/themes/highlights-light.js.map +1 -1
- package/lib/theme/themes/light.js +2 -2
- package/lib/theme/themes/light.js.map +1 -1
- package/lib/utils/CSSinJS.js +10 -8
- package/lib/utils/CSSinJS.js.map +1 -1
- package/lib/utils/CSSinJS.mjs +7 -6
- package/lib/utils/CSSinJS.mjs.map +1 -1
- package/lib/utils/ThemeProvider.js +51 -44
- package/lib/utils/ThemeProvider.js.map +1 -1
- package/lib/utils/ThemeProvider.mjs +47 -36
- package/lib/utils/ThemeProvider.mjs.map +1 -1
- package/lib/utils/addonText.js +7 -4
- package/lib/utils/addonText.js.map +1 -1
- package/lib/utils/addonText.mjs +5 -2
- package/lib/utils/addonText.mjs.map +1 -1
- package/lib/utils/addonTextChildren.js +21 -15
- package/lib/utils/addonTextChildren.js.map +1 -1
- package/lib/utils/addonTextChildren.mjs +13 -7
- package/lib/utils/addonTextChildren.mjs.map +1 -1
- package/lib/utils/ariaProps.js +5 -7
- package/lib/utils/ariaProps.js.map +1 -1
- package/lib/utils/ariaProps.mjs +5 -7
- package/lib/utils/ariaProps.mjs.map +1 -1
- package/lib/utils/assignProps.js +37 -33
- package/lib/utils/assignProps.js.map +1 -1
- package/lib/utils/assignProps.mjs +36 -32
- package/lib/utils/assignProps.mjs.map +1 -1
- package/lib/utils/canUseDOM.js +1 -1
- package/lib/utils/capitalizeFirstLetter.js +1 -1
- package/lib/utils/color.js +95 -72
- package/lib/utils/color.js.map +1 -1
- package/lib/utils/color.mjs +94 -71
- package/lib/utils/color.mjs.map +1 -1
- package/lib/utils/compose.js +12 -3
- package/lib/utils/compose.js.map +1 -1
- package/lib/utils/compose.mjs +11 -2
- package/lib/utils/compose.mjs.map +1 -1
- package/lib/utils/createUUID.js +5 -5
- package/lib/utils/createUUID.js.map +1 -1
- package/lib/utils/createUUID.mjs +4 -4
- package/lib/utils/createUUID.mjs.map +1 -1
- package/lib/utils/cssToIntDefault.js +4 -3
- package/lib/utils/cssToIntDefault.js.map +1 -1
- package/lib/utils/cssToIntDefault.mjs +3 -2
- package/lib/utils/cssToIntDefault.mjs.map +1 -1
- package/lib/utils/enhances/WithCSS.js +8 -10
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +6 -7
- package/lib/utils/enhances/WithCSS.mjs.map +1 -1
- package/lib/utils/enhances/WithI18n.js +19 -19
- package/lib/utils/enhances/WithI18n.js.map +1 -1
- package/lib/utils/enhances/WithI18n.mjs +17 -15
- package/lib/utils/enhances/WithI18n.mjs.map +1 -1
- package/lib/utils/enhances/a11yEnhance.js +39 -34
- package/lib/utils/enhances/a11yEnhance.js.map +1 -1
- package/lib/utils/enhances/a11yEnhance.mjs +36 -32
- package/lib/utils/enhances/a11yEnhance.mjs.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.js +63 -55
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +58 -50
- package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
- package/lib/utils/enhances/contextEnhance.js +11 -12
- package/lib/utils/enhances/contextEnhance.js.map +1 -1
- package/lib/utils/enhances/contextEnhance.mjs +8 -9
- package/lib/utils/enhances/contextEnhance.mjs.map +1 -1
- package/lib/utils/enhances/i18nEnhance.js +67 -51
- package/lib/utils/enhances/i18nEnhance.js.map +1 -1
- package/lib/utils/enhances/i18nEnhance.mjs +61 -47
- package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.js +10 -12
- package/lib/utils/enhances/resolveColorEnhance.js.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.mjs +6 -8
- package/lib/utils/enhances/resolveColorEnhance.mjs.map +1 -1
- package/lib/utils/eventEmitter.js +57 -30
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +55 -26
- package/lib/utils/eventEmitter.mjs.map +1 -1
- package/lib/utils/findComponent.js +42 -35
- package/lib/utils/findComponent.js.map +1 -1
- package/lib/utils/findComponent.mjs +33 -26
- package/lib/utils/findComponent.mjs.map +1 -1
- package/lib/utils/fire.js +13 -7
- package/lib/utils/fire.js.map +1 -1
- package/lib/utils/fire.mjs +11 -5
- package/lib/utils/fire.mjs.map +1 -1
- package/lib/utils/focus-lock/focusBorders.js +32 -28
- package/lib/utils/focus-lock/focusBorders.js.map +1 -1
- package/lib/utils/focus-lock/focusBorders.mjs +32 -26
- package/lib/utils/focus-lock/focusBorders.mjs.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.js +6 -4
- package/lib/utils/focus-lock/getFocusableIn.js.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.mjs +6 -3
- package/lib/utils/focus-lock/getFocusableIn.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.js +6 -5
- package/lib/utils/focus-lock/isFocusInside.js.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.mjs +6 -4
- package/lib/utils/focus-lock/isFocusInside.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusable.js +12 -9
- package/lib/utils/focus-lock/isFocusable.js.map +1 -1
- package/lib/utils/focus-lock/isFocusable.mjs +11 -8
- package/lib/utils/focus-lock/isFocusable.mjs.map +1 -1
- package/lib/utils/focus-lock/setFocus.js +27 -21
- package/lib/utils/focus-lock/setFocus.js.map +1 -1
- package/lib/utils/focus-lock/setFocus.mjs +25 -19
- package/lib/utils/focus-lock/setFocus.mjs.map +1 -1
- package/lib/utils/getAccessibleName.js +22 -10
- package/lib/utils/getAccessibleName.js.map +1 -1
- package/lib/utils/getAccessibleName.mjs +21 -10
- package/lib/utils/getAccessibleName.mjs.map +1 -1
- package/lib/utils/getDisplayName.js +1 -1
- package/lib/utils/getEventTarget.js +32 -13
- package/lib/utils/getEventTarget.js.map +1 -1
- package/lib/utils/getEventTarget.mjs +31 -12
- package/lib/utils/getEventTarget.mjs.map +1 -1
- package/lib/utils/getOriginChildren.js +4 -4
- package/lib/utils/getOriginChildren.js.map +1 -1
- package/lib/utils/getRandomInt.js +1 -1
- package/lib/utils/getValue.js +6 -4
- package/lib/utils/getValue.js.map +1 -1
- package/lib/utils/getValue.mjs +5 -3
- package/lib/utils/getValue.mjs.map +1 -1
- package/lib/utils/hasLabels.js +27 -16
- package/lib/utils/hasLabels.js.map +1 -1
- package/lib/utils/hasLabels.mjs +24 -14
- package/lib/utils/hasLabels.mjs.map +1 -1
- package/lib/utils/hasParent.js +2 -3
- package/lib/utils/hasParent.js.map +1 -1
- package/lib/utils/hasParent.mjs +3 -2
- package/lib/utils/hasParent.mjs.map +1 -1
- package/lib/utils/ifChildren.js +4 -6
- package/lib/utils/ifChildren.js.map +1 -1
- package/lib/utils/ifChildren.mjs +2 -4
- package/lib/utils/ifChildren.mjs.map +1 -1
- package/lib/utils/indentStyles.js +10 -5
- package/lib/utils/indentStyles.js.map +1 -1
- package/lib/utils/indentStyles.mjs +9 -5
- package/lib/utils/indentStyles.mjs.map +1 -1
- package/lib/utils/injectStyle.js +13 -11
- package/lib/utils/injectStyle.js.map +1 -1
- package/lib/utils/injectStyle.mjs +10 -9
- package/lib/utils/injectStyle.mjs.map +1 -1
- package/lib/utils/inputProps.js +5 -5
- package/lib/utils/inputProps.js.map +1 -1
- package/lib/utils/inputProps.mjs +4 -4
- package/lib/utils/inputProps.mjs.map +1 -1
- package/lib/utils/isInteractiveElement.js +9 -7
- package/lib/utils/isInteractiveElement.js.map +1 -1
- package/lib/utils/isInteractiveElement.mjs +9 -7
- package/lib/utils/isInteractiveElement.mjs.map +1 -1
- package/lib/utils/isNode.js +5 -4
- package/lib/utils/isNode.js.map +1 -1
- package/lib/utils/isNode.mjs +2 -1
- package/lib/utils/isNode.mjs.map +1 -1
- package/lib/utils/isPromise.js +1 -1
- package/lib/utils/isRetina.js +2 -7
- package/lib/utils/isRetina.js.map +1 -1
- package/lib/utils/isRetina.mjs +1 -6
- package/lib/utils/isRetina.mjs.map +1 -1
- package/lib/utils/logger.js +25 -18
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.mjs +21 -13
- package/lib/utils/logger.mjs.map +1 -1
- package/lib/utils/numericChecker.js +18 -11
- package/lib/utils/numericChecker.js.map +1 -1
- package/lib/utils/numericChecker.mjs +17 -10
- package/lib/utils/numericChecker.mjs.map +1 -1
- package/lib/utils/ownerDocument.js +2 -2
- package/lib/utils/ownerDocument.js.map +1 -1
- package/lib/utils/ownerDocument.mjs +1 -1
- package/lib/utils/ownerDocument.mjs.map +1 -1
- package/lib/utils/pick.js +5 -5
- package/lib/utils/pick.js.map +1 -1
- package/lib/utils/pick.mjs +4 -4
- package/lib/utils/pick.mjs.map +1 -1
- package/lib/utils/propsForElement.js +12 -10
- package/lib/utils/propsForElement.js.map +1 -1
- package/lib/utils/propsForElement.mjs +10 -8
- package/lib/utils/propsForElement.mjs.map +1 -1
- package/lib/utils/rafTrottle.js +14 -9
- package/lib/utils/rafTrottle.js.map +1 -1
- package/lib/utils/rafTrottle.mjs +12 -7
- package/lib/utils/rafTrottle.mjs.map +1 -1
- package/lib/utils/reactToText.js +8 -5
- package/lib/utils/reactToText.js.map +1 -1
- package/lib/utils/reactToText.mjs +6 -3
- package/lib/utils/reactToText.mjs.map +1 -1
- package/lib/utils/ref.js +47 -29
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +43 -27
- package/lib/utils/ref.mjs.map +1 -1
- package/lib/utils/setRef.js +2 -2
- package/lib/utils/setRef.js.map +1 -1
- package/lib/utils/syncScroll.js +24 -24
- package/lib/utils/syncScroll.js.map +1 -1
- package/lib/utils/syncScroll.mjs +21 -21
- package/lib/utils/syncScroll.mjs.map +1 -1
- package/lib/utils/uncontroll.js +18 -8
- package/lib/utils/uncontroll.js.map +1 -1
- package/lib/utils/uncontroll.mjs +17 -8
- package/lib/utils/uncontroll.mjs.map +1 -1
- package/lib/utils/uniqueID.js +27 -22
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +25 -18
- package/lib/utils/uniqueID.mjs.map +1 -1
- package/lib/utils/use/useColorResolver.js +22 -21
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +19 -17
- package/lib/utils/use/useColorResolver.mjs.map +1 -1
- package/lib/utils/use/useEnhancedEffect.js +4 -4
- package/lib/utils/use/useEnhancedEffect.js.map +1 -1
- package/lib/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/utils/use/useEnhancedEffect.mjs.map +1 -1
- package/lib/utils/use/useEventCallback.js +10 -5
- package/lib/utils/use/useEventCallback.js.map +1 -1
- package/lib/utils/use/useEventCallback.mjs +8 -3
- package/lib/utils/use/useEventCallback.mjs.map +1 -1
- package/lib/utils/use/useEventListener.js +15 -11
- package/lib/utils/use/useEventListener.js.map +1 -1
- package/lib/utils/use/useEventListener.mjs +11 -7
- package/lib/utils/use/useEventListener.mjs.map +1 -1
- package/lib/utils/use/useFocusLock.js +94 -80
- package/lib/utils/use/useFocusLock.js.map +1 -1
- package/lib/utils/use/useFocusLock.mjs +88 -71
- package/lib/utils/use/useFocusLock.mjs.map +1 -1
- package/lib/utils/use/usePreventScroll.js +26 -24
- package/lib/utils/use/usePreventScroll.js.map +1 -1
- package/lib/utils/use/usePreventScroll.mjs +21 -19
- package/lib/utils/use/usePreventScroll.mjs.map +1 -1
- package/lib/utils/use/useScrollBarWidth.js +14 -8
- package/lib/utils/use/useScrollBarWidth.js.map +1 -1
- package/lib/utils/use/useScrollBarWidth.mjs +13 -8
- package/lib/utils/use/useScrollBarWidth.mjs.map +1 -1
- package/lib/utils/useCssVariable.js +37 -32
- package/lib/utils/useCssVariable.js.map +1 -1
- package/lib/utils/useCssVariable.mjs +34 -27
- package/lib/utils/useCssVariable.mjs.map +1 -1
- package/lib/utils/zIndexStacking.js +24 -28
- package/lib/utils/zIndexStacking.js.map +1 -1
- package/lib/utils/zIndexStacking.mjs +22 -23
- package/lib/utils/zIndexStacking.mjs.map +1 -1
- package/package.json +12 -316
- package/vite.config.ts +0 -22
- package/tsconfig-utils.json +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ariaProps.mjs","names":["extractAriaProps","props","title","ariaLabel","ariaLabelledby","ariaDescribedby","__excludeProps","extractedAriaProps"],"sources":["../../src/utils/ariaProps.ts"],"sourcesContent":["type AriaProps = {\n 'title'?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n};\ntype ExtractorAriaPropsReturn = {\n __excludeProps: ['title', 'aria-label', 'aria-labelledby', 'aria-describedby'];\n extractedAriaProps: AriaProps;\n};\n\nexport function extractAriaProps(props: any): ExtractorAriaPropsReturn {\n const {\n title,\n ['aria-label']: ariaLabel,\n ['aria-labelledby']: ariaLabelledby,\n ['aria-describedby']: ariaDescribedby,\n } = props;\n\n return {\n __excludeProps: ['title', 'aria-label', 'aria-labelledby', 'aria-describedby'],\n extractedAriaProps: {\n title,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n },\n };\n}\n"],"mappings":"AAWA,OAAO,SAASA,gBAAgBA,CAACC,KAAU,EAA4B;EACrE,
|
|
1
|
+
{"version":3,"file":"ariaProps.mjs","names":["extractAriaProps","props","title","ariaLabel","ariaLabelledby","ariaDescribedby","__excludeProps","extractedAriaProps"],"sources":["../../src/utils/ariaProps.ts"],"sourcesContent":["type AriaProps = {\n 'title'?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n};\ntype ExtractorAriaPropsReturn = {\n __excludeProps: ['title', 'aria-label', 'aria-labelledby', 'aria-describedby'];\n extractedAriaProps: AriaProps;\n};\n\nexport function extractAriaProps(props: any): ExtractorAriaPropsReturn {\n const {\n title,\n ['aria-label']: ariaLabel,\n ['aria-labelledby']: ariaLabelledby,\n ['aria-describedby']: ariaDescribedby,\n } = props;\n\n return {\n __excludeProps: ['title', 'aria-label', 'aria-labelledby', 'aria-describedby'],\n extractedAriaProps: {\n title,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n },\n };\n}\n"],"mappings":"AAWA,OAAO,SAASA,gBAAgBA,CAACC,KAAU,EAA4B;EACrE,IACEC,KAAK,GAIHD,KAAK,CAJPC,KAAK;IACWC,SAAS,GAGvBF,KAAK,CAHN,YAAY;IACQG,cAAc,GAEjCH,KAAK,CAFN,iBAAiB;IACII,eAAe,GACnCJ,KAAK,CADN,kBAAkB;EAGrB,OAAO;IACLK,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,CAAC;IAC9EC,kBAAkB,EAAE;MAClBL,KAAK,EAALA,KAAK;MACL,YAAY,EAAEC,SAAS;MACvB,iBAAiB,EAAEC,cAAc;MACjC,kBAAkB,EAAEC;IACtB;EACF,CAAC;AACH","ignoreList":[]}
|
package/lib/utils/assignProps.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.assignHandlers = assignHandlers;
|
|
8
8
|
exports.callAllEventHandlers = callAllEventHandlers;
|
|
9
|
-
exports
|
|
9
|
+
exports["default"] = assignProps;
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
12
|
var _ref = require("./ref");
|
|
12
13
|
var _index = require("../styled/index");
|
|
13
|
-
function callAllEventHandlers(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function callAllEventHandlers() {
|
|
15
|
+
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
fns[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
return function () {
|
|
19
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
20
|
+
args[_key2] = arguments[_key2];
|
|
18
21
|
}
|
|
19
|
-
return
|
|
20
|
-
|
|
22
|
+
return !fns.some(function (fn) {
|
|
23
|
+
var result;
|
|
24
|
+
if (fn) {
|
|
25
|
+
result = fn.apply(void 0, args);
|
|
26
|
+
}
|
|
27
|
+
return typeof result === 'boolean' && !result;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
21
30
|
}
|
|
22
31
|
function assignHandlers(props, source) {
|
|
23
|
-
return Object.keys(source).reduce((proxySource, propName)
|
|
32
|
+
return Object.keys(source).reduce(function (proxySource, propName) {
|
|
24
33
|
if (typeof source[propName] === 'function' && propName.startsWith('on')) {
|
|
25
34
|
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
|
|
26
35
|
}
|
|
@@ -28,7 +37,7 @@ function assignHandlers(props, source) {
|
|
|
28
37
|
}, {});
|
|
29
38
|
}
|
|
30
39
|
function assignHandlersInner(props, source) {
|
|
31
|
-
return Object.keys(source).reduce((proxySource, propName)
|
|
40
|
+
return Object.keys(source).reduce(function (proxySource, propName) {
|
|
32
41
|
if (propName !== 'ref' && propName.startsWith('on')) {
|
|
33
42
|
if (typeof source[propName] === 'function' && typeof props[propName] === 'function') {
|
|
34
43
|
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
|
|
@@ -41,31 +50,29 @@ function assignHandlersInner(props, source) {
|
|
|
41
50
|
return proxySource;
|
|
42
51
|
}, {});
|
|
43
52
|
}
|
|
44
|
-
function assignProps(
|
|
53
|
+
function assignProps() {
|
|
54
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
55
|
+
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
56
|
// @ts-ignore
|
|
46
57
|
if (props === source) return props;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (const key in source) {
|
|
53
|
-
if (key.startsWith('use:')) {
|
|
54
|
-
const originalKey = key.slice('use:'.length);
|
|
55
|
-
newProps[originalKey] = source[key];
|
|
58
|
+
var newProps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, source), props), assignHandlersInner(props, source));
|
|
59
|
+
for (var _key3 in source) {
|
|
60
|
+
if (_key3.startsWith('use:')) {
|
|
61
|
+
var originalKey = _key3.slice('use:'.length);
|
|
62
|
+
newProps[originalKey] = source[_key3];
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
|
-
for (
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
newProps[
|
|
65
|
+
for (var _key4 in props) {
|
|
66
|
+
if (_key4.startsWith('use:')) {
|
|
67
|
+
var _originalKey = _key4.slice('use:'.length);
|
|
68
|
+
newProps[_originalKey] = props[_key4];
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
// because react set getter for ref
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (sourceDescriptorRef
|
|
73
|
+
var sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, 'ref');
|
|
74
|
+
var propsDescriptorRef = Object.getOwnPropertyDescriptor(props, 'ref');
|
|
75
|
+
if (sourceDescriptorRef !== null && sourceDescriptorRef !== void 0 && sourceDescriptorRef.configurable && propsDescriptorRef !== null && propsDescriptorRef !== void 0 && propsDescriptorRef.configurable) {
|
|
69
76
|
newProps.ref = (0, _ref.forkRef)(source.ref, props.ref);
|
|
70
77
|
}
|
|
71
78
|
if (props.forwardRef) {
|
|
@@ -73,13 +80,10 @@ function assignProps(props = {}, source = {}) {
|
|
|
73
80
|
newProps.forwardRef = newProps.ref;
|
|
74
81
|
}
|
|
75
82
|
if (source.style && props.style) {
|
|
76
|
-
newProps.style = {
|
|
77
|
-
...source.style,
|
|
78
|
-
...props.style
|
|
79
|
-
};
|
|
83
|
+
newProps.style = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, source.style), props.style);
|
|
80
84
|
}
|
|
81
85
|
if (source.className) {
|
|
82
|
-
newProps.className = (0, _classnames
|
|
86
|
+
newProps.className = (0, _classnames["default"])(props.className, source.className);
|
|
83
87
|
}
|
|
84
88
|
if (source.styles && props.styles) {
|
|
85
89
|
newProps.styles = _index.sstyled.merge(source.styles, props.styles);
|
|
@@ -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","
|
|
1
|
+
{"version":3,"file":"assignProps.js","names":["_classnames","_interopRequireDefault","require","_ref","_index","callAllEventHandlers","_len","arguments","length","fns","Array","_key","_len2","args","_key2","some","fn","result","apply","assignHandlers","props","source","Object","keys","reduce","proxySource","propName","startsWith","assignHandlersInner","assignProps","undefined","newProps","_objectSpread2","key","originalKey","slice","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,CAAA,EAAsC;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAlCC,GAAG,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAHF,GAAG,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EACzC,OAAO;IAAA,SAAAC,KAAA,GAAAL,SAAA,CA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AK,CAAC3B,MAAM,CAACyB,MAAM,EAAE1B,KAAK,CAAC0B,MAAM,CAAC;EAC9D;EAEA,OAAOf,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _cn from "classnames";
|
|
2
3
|
import { forkRef } from "./ref.mjs";
|
|
3
4
|
import "../styled/index.mjs";
|
|
4
5
|
import { sstyled } from "../styled/sstyled.mjs";
|
|
5
|
-
function callAllEventHandlers(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
function callAllEventHandlers() {
|
|
7
|
+
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
+
fns[_key] = arguments[_key];
|
|
9
|
+
}
|
|
10
|
+
return function() {
|
|
11
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
12
|
+
args[_key2] = arguments[_key2];
|
|
10
13
|
}
|
|
11
|
-
return
|
|
12
|
-
|
|
14
|
+
return !fns.some(function(fn) {
|
|
15
|
+
var result;
|
|
16
|
+
if (fn) {
|
|
17
|
+
result = fn.apply(void 0, args);
|
|
18
|
+
}
|
|
19
|
+
return typeof result === "boolean" && !result;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
13
22
|
}
|
|
14
23
|
function assignHandlers(props, source) {
|
|
15
|
-
return Object.keys(source).reduce((proxySource, propName)
|
|
24
|
+
return Object.keys(source).reduce(function(proxySource, propName) {
|
|
16
25
|
if (typeof source[propName] === "function" && propName.startsWith("on")) {
|
|
17
26
|
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
|
|
18
27
|
}
|
|
@@ -20,7 +29,7 @@ function assignHandlers(props, source) {
|
|
|
20
29
|
}, {});
|
|
21
30
|
}
|
|
22
31
|
function assignHandlersInner(props, source) {
|
|
23
|
-
return Object.keys(source).reduce((proxySource, propName)
|
|
32
|
+
return Object.keys(source).reduce(function(proxySource, propName) {
|
|
24
33
|
if (propName !== "ref" && propName.startsWith("on")) {
|
|
25
34
|
if (typeof source[propName] === "function" && typeof props[propName] === "function") {
|
|
26
35
|
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
|
|
@@ -33,28 +42,26 @@ function assignHandlersInner(props, source) {
|
|
|
33
42
|
return proxySource;
|
|
34
43
|
}, {});
|
|
35
44
|
}
|
|
36
|
-
function assignProps(
|
|
45
|
+
function assignProps() {
|
|
46
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
47
|
+
var source = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
37
48
|
if (props === source) return props;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for (const key in source) {
|
|
44
|
-
if (key.startsWith("use:")) {
|
|
45
|
-
const originalKey = key.slice("use:".length);
|
|
46
|
-
newProps[originalKey] = source[key];
|
|
49
|
+
var newProps = _objectSpread(_objectSpread(_objectSpread({}, source), props), assignHandlersInner(props, source));
|
|
50
|
+
for (var _key3 in source) {
|
|
51
|
+
if (_key3.startsWith("use:")) {
|
|
52
|
+
var originalKey = _key3.slice("use:".length);
|
|
53
|
+
newProps[originalKey] = source[_key3];
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
|
-
for (
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
newProps[
|
|
56
|
+
for (var _key4 in props) {
|
|
57
|
+
if (_key4.startsWith("use:")) {
|
|
58
|
+
var _originalKey = _key4.slice("use:".length);
|
|
59
|
+
newProps[_originalKey] = props[_key4];
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (sourceDescriptorRef
|
|
62
|
+
var sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, "ref");
|
|
63
|
+
var propsDescriptorRef = Object.getOwnPropertyDescriptor(props, "ref");
|
|
64
|
+
if (sourceDescriptorRef !== null && sourceDescriptorRef !== void 0 && sourceDescriptorRef.configurable && propsDescriptorRef !== null && propsDescriptorRef !== void 0 && propsDescriptorRef.configurable) {
|
|
58
65
|
newProps.ref = forkRef(source.ref, props.ref);
|
|
59
66
|
}
|
|
60
67
|
if (props.forwardRef) {
|
|
@@ -62,13 +69,10 @@ function assignProps(props = {}, source = {}) {
|
|
|
62
69
|
newProps.forwardRef = newProps.ref;
|
|
63
70
|
}
|
|
64
71
|
if (source.style && props.style) {
|
|
65
|
-
newProps.style = {
|
|
66
|
-
...source.style,
|
|
67
|
-
...props.style
|
|
68
|
-
};
|
|
72
|
+
newProps.style = _objectSpread(_objectSpread({}, source.style), props.style);
|
|
69
73
|
}
|
|
70
74
|
if (source.className) {
|
|
71
|
-
newProps.className =
|
|
75
|
+
newProps.className = _cn(props.className, source.className);
|
|
72
76
|
}
|
|
73
77
|
if (source.styles && props.styles) {
|
|
74
78
|
newProps.styles = sstyled.merge(source.styles, props.styles);
|
|
@@ -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","
|
|
1
|
+
{"version":3,"file":"assignProps.mjs","names":["cn","forkRef","sstyled","callAllEventHandlers","_len","arguments","length","fns","Array","_key","_len2","args","_key2","some","fn","result","apply","assignHandlers","props","source","Object","keys","reduce","proxySource","propName","startsWith","assignHandlersInner","assignProps","undefined","newProps","_objectSpread","key","originalKey","slice","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,CAAA,EAAsC;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAlCC,GAAG,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAHF,GAAG,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EACzC,OAAO;IAAA,SAAAC,KAAA,GAAAL,SAAA,CAAAC,MAAA,EAAIK,IAAI,OAAAH,KAAA,CAAAE,KAAA,GAAAE,KAAA,MAAAA,KAAA,GAAAF,KAAA,EAAAE,KAAA;MAAJD,IAAI,CAAAC,KAAA,IAAAP,SAAA,CAAAO,KAAA;IAAA;IAAA,OACb,CAACL,GAAG,CAACM,IAAI,CAAC,UAACC,EAAE,EAAK;MAChB,IAAIC,MAAM;MACV,IAAID,EAAE,EAAE;QACNC,MAAM,GAAGD,EAAE,CAAAE,KAAA,SAAIL,IAAI,CAAC;MACtB;MACA,OAAO,OAAOI,MAAM,KAAK,SAAS,IAAI,CAACA,MAAM;IAC/C,CAAC,CAAC;EAAA;AACN;AAEA,OAAO,SAASE,cAAcA,CAACC,KAAU,EAAEC,MAAW,EAAE;EACtD,OAAOC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,UAACC,WAAgB,EAAEC,QAAQ,EAAK;IAChE,IAAI,OAAOL,MAAM,CAACK,Q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qB,UAAU,EAAE;IACpBV,QAAQ,CAACS,GAAG,GAAGrC,OAAO,CAAC4B,QAAQ,CAACS,GAAG,EAASpB,KAAK,CAACqB,UAAiB,CAAC;IACpEV,QAAQ,CAACU,UAAU,GAAGV,QAAQ,CAACS,GAAG;EACpC;EAEA,IAAInB,MAAM,CAACqB,KAAK,IAAItB,KAAK,CAACsB,KAAK,EAAE;IAC/BX,QAAQ,CAACW,KAAK,GAAAV,aAAA,CAAAA,aAAA,KACTX,MAAM,CAACqB,KAAK,GACZtB,KAAK,CAACsB,KAAK,CACf;EACH;EAEA,IAAIrB,MAAM,CAACsB,SAAS,EAAE;IACpBZ,QAAQ,CAACY,SAAS,GAAGzC,EAAE,CAACkB,KAAK,CAACuB,SAAS,EAAEtB,MAAM,CAACsB,SAAS,CAAC;EAC5D;EAEA,IAAItB,MAAM,CAACuB,MAAM,IAAIxB,KAAK,CAACwB,MAAM,EAAE;IACjCb,QAAQ,CAACa,MAAM,GAAGxC,OAAO,CAACyC,KAAK,CAACxB,MAAM,CAACuB,MAAM,EAAExB,KAAK,CAACwB,MAAM,CAAC;EAC9D;EAEA,OAAOb,QAAQ;AACjB","ignoreList":[]}
|
package/lib/utils/canUseDOM.js
CHANGED
package/lib/utils/color.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -8,73 +9,91 @@ exports.brightness = brightness;
|
|
|
8
9
|
exports.light = void 0;
|
|
9
10
|
exports.opacity = opacity;
|
|
10
11
|
exports.shade = shade;
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
14
|
function shadeHexColor(color, percent) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
15
|
+
var f = Number.parseInt(color.slice(1), 16);
|
|
16
|
+
var t = percent < 0 ? 0 : 255;
|
|
17
|
+
var p = percent < 0 ? percent * -1 : percent;
|
|
18
|
+
var R = f >> 16;
|
|
19
|
+
var G = f >> 8 & 0x00ff;
|
|
20
|
+
var B = f & 0x0000ff;
|
|
21
|
+
return "#".concat((0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1));
|
|
19
22
|
}
|
|
20
23
|
function shadeRGBColor(color, percent) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
var _colorRGB = colorRGB(color),
|
|
25
|
+
_colorRGB2 = (0, _slicedToArray2["default"])(_colorRGB, 3),
|
|
26
|
+
R = _colorRGB2[0],
|
|
27
|
+
G = _colorRGB2[1],
|
|
28
|
+
B = _colorRGB2[2];
|
|
29
|
+
var t = percent < 0 ? 0 : 255;
|
|
30
|
+
var p = percent < 0 ? percent * -1 : percent;
|
|
31
|
+
return "rgb(".concat(Math.round((t - R) * p) + R, ",").concat(Math.round((t - G) * p) + G, ",").concat(Math.round((t - B) * p) + B, ")");
|
|
25
32
|
}
|
|
26
|
-
function shade(color
|
|
33
|
+
function shade(color) {
|
|
34
|
+
var percent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
27
35
|
if (!color) return;
|
|
28
36
|
// TODO error for color name, example 'aqua'
|
|
29
37
|
if (color.length > 7) return shadeRGBColor(color, percent);
|
|
30
38
|
return shadeHexColor(color, percent);
|
|
31
39
|
}
|
|
32
40
|
function blendHexColors(colorOne, colorTwo, percent) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
41
|
+
var f = Number.parseInt(colorOne.slice(1), 16);
|
|
42
|
+
var t = Number.parseInt(colorTwo.slice(1), 16);
|
|
43
|
+
var R1 = f >> 16;
|
|
44
|
+
var G1 = f >> 8 & 0x00ff;
|
|
45
|
+
var B1 = f & 0x0000ff;
|
|
46
|
+
var R2 = t >> 16;
|
|
47
|
+
var G2 = t >> 8 & 0x00ff;
|
|
48
|
+
var B2 = t & 0x0000ff;
|
|
49
|
+
return "#".concat((0x1000000 + (Math.round((R2 - R1) * percent) + R1) * 0x10000 + (Math.round((G2 - G1) * percent) + G1) * 0x100 + (Math.round((B2 - B1) * percent) + B1)).toString(16).slice(1));
|
|
42
50
|
}
|
|
43
51
|
function blendRGBColors(colorOne, colorTwo, percent) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
var _colorRGB3 = colorRGB(colorOne),
|
|
53
|
+
_colorRGB4 = (0, _slicedToArray2["default"])(_colorRGB3, 3),
|
|
54
|
+
R = _colorRGB4[0],
|
|
55
|
+
G = _colorRGB4[1],
|
|
56
|
+
B = _colorRGB4[2];
|
|
57
|
+
var t = colorTwo.split(',');
|
|
58
|
+
return "rgb(".concat(Math.round((Number.parseInt(t[0].slice(4)) - R) * percent) + R, ",").concat(Math.round((Number.parseInt(t[1]) - G) * percent) + G, ",").concat(Math.round((Number.parseInt(t[2]) - B) * percent) + B, ")");
|
|
47
59
|
}
|
|
48
|
-
function blend(colorOne, colorTwo
|
|
60
|
+
function blend(colorOne, colorTwo) {
|
|
61
|
+
var percent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
49
62
|
if (!colorOne || !colorTwo) return;
|
|
50
63
|
if (colorOne.length > 7) {
|
|
51
64
|
if (colorTwo.length > 7) {
|
|
52
65
|
return blendRGBColors(colorOne, colorTwo, percent);
|
|
53
66
|
}
|
|
54
|
-
return blendRGBColors(colorOne,
|
|
67
|
+
return blendRGBColors(colorOne, "rgb(".concat(hex2rgb(colorTwo), ")"), percent);
|
|
55
68
|
}
|
|
56
69
|
if (colorTwo.length > 7) {
|
|
57
|
-
return blendRGBColors(
|
|
70
|
+
return blendRGBColors("rgb(".concat(hex2rgb(colorOne).join(','), ")"), colorTwo, percent);
|
|
58
71
|
}
|
|
59
72
|
return blendHexColors(colorOne, colorTwo, percent);
|
|
60
73
|
}
|
|
61
74
|
function colorRGB(color) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
var f = color.split(',');
|
|
76
|
+
var R = Number.parseInt(f[0].slice(4));
|
|
77
|
+
var G = Number.parseInt(f[1]);
|
|
78
|
+
var B = Number.parseInt(f[2]);
|
|
66
79
|
return [R, G, B];
|
|
67
80
|
}
|
|
68
81
|
function hex2rgb(hex) {
|
|
82
|
+
var _hex$replace$substrin;
|
|
69
83
|
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
70
|
-
return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (_m, r, g, b)
|
|
84
|
+
return (_hex$replace$substrin = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (_m, r, g, b) {
|
|
85
|
+
return "#".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
|
|
86
|
+
}).substring(1).match(/.{2}/g)) === null || _hex$replace$substrin === void 0 ? void 0 : _hex$replace$substrin.map(function (x) {
|
|
87
|
+
return Number.parseInt(x, 16);
|
|
88
|
+
});
|
|
71
89
|
}
|
|
72
|
-
function opacity(color
|
|
90
|
+
function opacity(color) {
|
|
91
|
+
var percent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
73
92
|
if (!color) return;
|
|
74
93
|
if (color.includes('#') && color.match(/^#?[a-fA-F\d]{6}$/)) {
|
|
75
|
-
color =
|
|
94
|
+
color = "rgba(".concat(hex2rgb(color).join(', '), ", ").concat(percent, ")");
|
|
76
95
|
} else if (color.includes('rgb')) {
|
|
77
|
-
color =
|
|
96
|
+
color = "rgba(".concat(colorRGB(color).join(', '), ", ").concat(percent, ")");
|
|
78
97
|
} else {
|
|
79
98
|
return;
|
|
80
99
|
}
|
|
@@ -89,60 +108,64 @@ function brightness(color) {
|
|
|
89
108
|
}
|
|
90
109
|
return Math.round((Number.parseInt(color[0]) * 299 + Number.parseInt(color[1]) * 587 + Number.parseInt(color[2]) * 114) / 1000);
|
|
91
110
|
}
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
var lightMemo = {};
|
|
112
|
+
var light = exports.light = function light(color) {
|
|
113
|
+
var factor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
94
114
|
if (!color) return;
|
|
95
|
-
|
|
115
|
+
var inputKey = "".concat(color, "_").concat(factor);
|
|
96
116
|
if (lightMemo[inputKey]) return lightMemo[inputKey];
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
var r = 0;
|
|
118
|
+
var g = 0;
|
|
119
|
+
var b = 0;
|
|
120
|
+
var a = 1;
|
|
101
121
|
if (color.startsWith('#')) {
|
|
102
122
|
if (color.length !== 4 && color.length !== 7) {
|
|
103
|
-
throw new Error(
|
|
123
|
+
throw new Error("Got invalid color ".concat(color));
|
|
104
124
|
}
|
|
105
|
-
|
|
125
|
+
var partSize = color.length === 4 ? 1 : 2;
|
|
106
126
|
r = Number.parseInt(color.substring(1, 1 + partSize), 16);
|
|
107
127
|
g = Number.parseInt(color.substring(1 + partSize, 1 + partSize * 2), 16);
|
|
108
128
|
b = Number.parseInt(color.substring(1 + partSize * 2, 1 + partSize * 3), 16);
|
|
109
129
|
a = 1; // not handled for now
|
|
110
130
|
} else if (color.startsWith('rgb(')) {
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
var trimmed = color.substring('rgb('.length, color.length - ')'.length);
|
|
132
|
+
var parts = trimmed.split(',').map(function (part) {
|
|
133
|
+
return Number.parseInt(part.trim(), 10);
|
|
134
|
+
});
|
|
113
135
|
r = parts[0];
|
|
114
136
|
g = parts[1];
|
|
115
137
|
b = parts[2];
|
|
116
138
|
a = 1;
|
|
117
139
|
} else if (color.startsWith('rgba(')) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
140
|
+
var _trimmed = color.substring('rgba('.length, color.length - ')'.length);
|
|
141
|
+
var _parts = _trimmed.split(',').map(function (part) {
|
|
142
|
+
return Number.parseInt(part.trim(), 10);
|
|
143
|
+
});
|
|
144
|
+
r = _parts[0];
|
|
145
|
+
g = _parts[1];
|
|
146
|
+
b = _parts[2];
|
|
147
|
+
a = _parts[2];
|
|
124
148
|
} else {
|
|
125
|
-
throw new Error(
|
|
149
|
+
throw new Error("Got invalid color ".concat(color));
|
|
126
150
|
}
|
|
127
|
-
|
|
151
|
+
var hsl = rgbToHsl(r, g, b);
|
|
128
152
|
hsl[2] += (1 - hsl[2]) * factor;
|
|
129
|
-
|
|
130
|
-
return lightMemo[inputKey] ===
|
|
153
|
+
var rgb = hslToRgb.apply(void 0, (0, _toConsumableArray2["default"])(hsl));
|
|
154
|
+
return lightMemo[inputKey] === "rgba(".concat(rgb[0], ", ").concat(rgb[1], ", ").concat(rgb[2], ", ").concat(a, ")");
|
|
131
155
|
};
|
|
132
|
-
|
|
133
|
-
const rgbToHsl = (r, g, b) => {
|
|
156
|
+
var rgbToHsl = function rgbToHsl(r, g, b) {
|
|
134
157
|
r /= 255;
|
|
135
158
|
g /= 255;
|
|
136
159
|
b /= 255;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
160
|
+
var max = Math.max(r, g, b);
|
|
161
|
+
var min = Math.min(r, g, b);
|
|
162
|
+
var h = 0;
|
|
163
|
+
var s = 0;
|
|
164
|
+
var l = (max + min) / 2;
|
|
142
165
|
if (max === min) {
|
|
143
166
|
h = s = 0;
|
|
144
167
|
} else {
|
|
145
|
-
|
|
168
|
+
var d = max - min;
|
|
146
169
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
147
170
|
switch (max) {
|
|
148
171
|
case r:
|
|
@@ -159,23 +182,23 @@ const rgbToHsl = (r, g, b) => {
|
|
|
159
182
|
}
|
|
160
183
|
return [h, s, l];
|
|
161
184
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
185
|
+
var hslToRgb = function hslToRgb(h, s, l) {
|
|
186
|
+
var r = 0;
|
|
187
|
+
var g = 0;
|
|
188
|
+
var b = 0;
|
|
166
189
|
if (s === 0) {
|
|
167
190
|
r = g = b = l;
|
|
168
191
|
} else {
|
|
169
|
-
function hue2rgb(p, q, t) {
|
|
192
|
+
var hue2rgb = function hue2rgb(p, q, t) {
|
|
170
193
|
if (t < 0) t += 1;
|
|
171
194
|
if (t > 1) t -= 1;
|
|
172
195
|
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
173
196
|
if (t < 1 / 2) return q;
|
|
174
197
|
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
175
198
|
return p;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
199
|
+
};
|
|
200
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
201
|
+
var p = 2 * l - q;
|
|
179
202
|
r = hue2rgb(p, q, h + 1 / 3);
|
|
180
203
|
g = hue2rgb(p, q, h);
|
|
181
204
|
b = hue2rgb(p, q, h - 1 / 3);
|