@semcore/core 17.0.0-prerelease.19 → 17.0.0-prerelease.20-prerelease.20
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 +1 -1
- 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 +205 -143
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +164 -118
- 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 -5
- 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 +164 -118
- 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 -5
- 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/processor.js +222 -150
- package/lib/theme/processor.js.map +1 -1
- package/lib/theme/processor.mjs +221 -148
- package/lib/theme/processor.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/theme/utils.js +215 -140
- package/lib/theme/utils.js.map +1 -1
- package/lib/theme/utils.mjs +214 -135
- package/lib/theme/utils.mjs.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/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 +21 -20
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +18 -16
- 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 +28 -26
- package/lib/utils/use/usePreventScroll.js.map +1 -1
- package/lib/utils/use/usePreventScroll.mjs +23 -21
- 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 +1 -1
package/lib/utils/ariaProps.js
CHANGED
|
@@ -5,16 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.extractAriaProps = extractAriaProps;
|
|
7
7
|
function extractAriaProps(props) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
['aria-
|
|
11
|
-
['aria-
|
|
12
|
-
['aria-describedby']: ariaDescribedby
|
|
13
|
-
} = props;
|
|
8
|
+
var title = props.title,
|
|
9
|
+
ariaLabel = props['aria-label'],
|
|
10
|
+
ariaLabelledby = props['aria-labelledby'],
|
|
11
|
+
ariaDescribedby = props['aria-describedby'];
|
|
14
12
|
return {
|
|
15
13
|
__excludeProps: ['title', 'aria-label', 'aria-labelledby', 'aria-describedby'],
|
|
16
14
|
extractedAriaProps: {
|
|
17
|
-
title,
|
|
15
|
+
title: title,
|
|
18
16
|
'aria-label': ariaLabel,
|
|
19
17
|
'aria-labelledby': ariaLabelledby,
|
|
20
18
|
'aria-describedby': ariaDescribedby
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ariaProps.js","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":";;;;;;AAWO,SAASA,gBAAgBA,CAACC,KAAU,EAA4B;EACrE,
|
|
1
|
+
{"version":3,"file":"ariaProps.js","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":";;;;;;AAWO,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/ariaProps.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export function extractAriaProps(props) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
['aria-
|
|
5
|
-
['aria-
|
|
6
|
-
['aria-describedby']: ariaDescribedby
|
|
7
|
-
} = props;
|
|
2
|
+
var title = props.title,
|
|
3
|
+
ariaLabel = props['aria-label'],
|
|
4
|
+
ariaLabelledby = props['aria-labelledby'],
|
|
5
|
+
ariaDescribedby = props['aria-describedby'];
|
|
8
6
|
return {
|
|
9
7
|
__excludeProps: ['title', 'aria-label', 'aria-labelledby', 'aria-describedby'],
|
|
10
8
|
extractedAriaProps: {
|
|
11
|
-
title,
|
|
9
|
+
title: title,
|
|
12
10
|
'aria-label': ariaLabel,
|
|
13
11
|
'aria-labelledby': ariaLabelledby,
|
|
14
12
|
'aria-describedby': ariaDescribedby
|
|
@@ -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,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;AAEO,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,QAAQ,CAAC,KAAK,UAAU,IAAIA,QAAQ,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;MACvEF,WAAW,CAACC,QAAQ,CAAC,GAAGrB,oBAAoB,CAAC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X,QAAQ,CAACW,UAAU,GAAGX,QAAQ,CAACS,GAAG;EACpC;EAEA,IAAInB,MAAM,CAACsB,KAAK,IAAIvB,KAAK,CAACuB,KAAK,EAAE;IAC/BZ,QAAQ,CAACY,KAAK,OAAAX,cAAA,iBAAAA,cAAA,iBACTX,MAAM,CAACsB,KAAK,GACZvB,KAAK,CAACuB,KAAK,CACf;EACH;EAEA,IAAItB,MAAM,CAACuB,SAAS,EAAE;IACpBb,QAAQ,CAACa,SAAS,GAAG,IAAAC,sBAAE,EAACzB,KAAK,CAACwB,SAAS,EAAEvB,MAAM,CAACuB,SAAS,CAAC;EAC5D;EAEA,IAAIvB,MAAM,CAACyB,MAAM,IAAI1B,KAAK,CAAC0B,MAAM,EAAE;IACjCf,QAAQ,CAACe,MAAM,GAAGC,cAAO,CAACC,KAAK,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 (
|
|
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;M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