@hanzogui/react-native-web-internals 2.0.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/LICENSE +21 -0
- package/dist/cjs/StyleSheet/__tests__/compiler-createReactDOMStyle-test.cjs +240 -0
- package/dist/cjs/StyleSheet/__tests__/compiler-test.cjs +407 -0
- package/dist/cjs/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.cjs +121 -0
- package/dist/cjs/StyleSheet/__tests__/index-test.cjs +404 -0
- package/dist/cjs/StyleSheet/__tests__/preprocess-test.cjs +108 -0
- package/dist/cjs/StyleSheet/__tests__/validate-test.cjs +36 -0
- package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.cjs +87 -0
- package/dist/cjs/StyleSheet/compiler/hash.cjs +26 -0
- package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.cjs +36 -0
- package/dist/cjs/StyleSheet/compiler/index.cjs +318 -0
- package/dist/cjs/StyleSheet/compiler/normalizeColor.cjs +40 -0
- package/dist/cjs/StyleSheet/compiler/normalizeValueWithProperty.cjs +43 -0
- package/dist/cjs/StyleSheet/compiler/resolveShadowValue.cjs +48 -0
- package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.cjs +37 -0
- package/dist/cjs/StyleSheet/dom/createOrderedCSSStyleSheet.cjs +110 -0
- package/dist/cjs/StyleSheet/dom/index.cjs +67 -0
- package/dist/cjs/StyleSheet/index.cjs +57 -0
- package/dist/cjs/StyleSheet/preprocess.cjs +101 -0
- package/dist/cjs/StyleSheet/validate.cjs +69 -0
- package/dist/cjs/TextAncestorContext.cjs +27 -0
- package/dist/cjs/colorProps.cjs +37 -0
- package/dist/cjs/index.cjs +103 -0
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.cjs +50 -0
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.cjs +40 -0
- package/dist/cjs/modules/AccessibilityUtil/index.cjs +33 -0
- package/dist/cjs/modules/AccessibilityUtil/isDisabled.cjs +26 -0
- package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.cjs +57 -0
- package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.cjs +47 -0
- package/dist/cjs/modules/AssetRegistry/index.cjs +33 -0
- package/dist/cjs/modules/ImageLoader/index.cjs +111 -0
- package/dist/cjs/modules/InteractionManager.cjs +184 -0
- package/dist/cjs/modules/Platform/__tests__/index-test.cjs +48 -0
- package/dist/cjs/modules/Platform/index.cjs +30 -0
- package/dist/cjs/modules/TextInputState/index.cjs +55 -0
- package/dist/cjs/modules/UIManager/__tests__/index-test.cjs +90 -0
- package/dist/cjs/modules/UIManager/index.cjs +60 -0
- package/dist/cjs/modules/canUseDOM.cjs +26 -0
- package/dist/cjs/modules/createDOMProps/__tests__/index-test.cjs +156 -0
- package/dist/cjs/modules/createDOMProps/index.cjs +179 -0
- package/dist/cjs/modules/createEventHandle/__tests__/index-test.cjs +344 -0
- package/dist/cjs/modules/createEventHandle/index.cjs +67 -0
- package/dist/cjs/modules/dismissKeyboard/index.cjs +29 -0
- package/dist/cjs/modules/forwardedProps/index.cjs +161 -0
- package/dist/cjs/modules/getBoundingClientRect/index.cjs +28 -0
- package/dist/cjs/modules/invariant.cjs +36 -0
- package/dist/cjs/modules/isSelectionValid/index.cjs +35 -0
- package/dist/cjs/modules/isWebColor/index.cjs +26 -0
- package/dist/cjs/modules/mergeRefs/__tests__/index-test.cjs +42 -0
- package/dist/cjs/modules/mergeRefs/index.cjs +42 -0
- package/dist/cjs/modules/modality/__tests__/index-test.cjs +32 -0
- package/dist/cjs/modules/modality/index.cjs +135 -0
- package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/index-test.cjs +30 -0
- package/dist/cjs/modules/multiplyStyleLengthValue/index.cjs +35 -0
- package/dist/cjs/modules/normalizeColor/index.cjs +39 -0
- package/dist/cjs/modules/pick/index.cjs +30 -0
- package/dist/cjs/modules/processColor/__tests__/index-test.cjs +66 -0
- package/dist/cjs/modules/processColor/index.cjs +42 -0
- package/dist/cjs/modules/requestIdleCallback/index.cjs +44 -0
- package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.cjs +35 -0
- package/dist/cjs/modules/setValueForStyles/index.cjs +35 -0
- package/dist/cjs/modules/unitlessNumbers/index.cjs +85 -0
- package/dist/cjs/modules/useElementLayout/index.cjs +39 -0
- package/dist/cjs/modules/useEvent/__tests__/index-test.cjs +408 -0
- package/dist/cjs/modules/useEvent/index.cjs +45 -0
- package/dist/cjs/modules/useHover/__tests__/index-test.cjs +273 -0
- package/dist/cjs/modules/useHover/index.cjs +97 -0
- package/dist/cjs/modules/useLayoutEffect/index.cjs +39 -0
- package/dist/cjs/modules/useLocale/index.cjs +66 -0
- package/dist/cjs/modules/useLocale/isLocaleRTL.cjs +83 -0
- package/dist/cjs/modules/useMergeRefs/__tests__/index-test.cjs +102 -0
- package/dist/cjs/modules/useMergeRefs/index.cjs +43 -0
- package/dist/cjs/modules/usePlatformMethods/index.cjs +35 -0
- package/dist/cjs/modules/useStable/__tests__/index-test.cjs +92 -0
- package/dist/cjs/modules/useStable/index.cjs +42 -0
- package/dist/cjs/styleTypes.cjs +16 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.mjs +219 -0
- package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.mjs.map +1 -0
- package/dist/esm/StyleSheet/__tests__/compiler-test.mjs +408 -0
- package/dist/esm/StyleSheet/__tests__/compiler-test.mjs.map +1 -0
- package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.mjs +100 -0
- package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.mjs.map +1 -0
- package/dist/esm/StyleSheet/__tests__/index-test.mjs +383 -0
- package/dist/esm/StyleSheet/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/StyleSheet/__tests__/preprocess-test.mjs +109 -0
- package/dist/esm/StyleSheet/__tests__/preprocess-test.mjs.map +1 -0
- package/dist/esm/StyleSheet/__tests__/validate-test.mjs +37 -0
- package/dist/esm/StyleSheet/__tests__/validate-test.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/createReactDOMStyle.mjs +63 -0
- package/dist/esm/StyleSheet/compiler/createReactDOMStyle.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/hash.mjs +3 -0
- package/dist/esm/StyleSheet/compiler/hash.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/hyphenateStyleName.mjs +13 -0
- package/dist/esm/StyleSheet/compiler/hyphenateStyleName.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/index.mjs +292 -0
- package/dist/esm/StyleSheet/compiler/index.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/normalizeColor.mjs +17 -0
- package/dist/esm/StyleSheet/compiler/normalizeColor.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.mjs +20 -0
- package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.mjs.map +1 -0
- package/dist/esm/StyleSheet/compiler/resolveShadowValue.mjs +25 -0
- package/dist/esm/StyleSheet/compiler/resolveShadowValue.mjs.map +1 -0
- package/dist/esm/StyleSheet/dom/createCSSStyleSheet.mjs +14 -0
- package/dist/esm/StyleSheet/dom/createCSSStyleSheet.mjs.map +1 -0
- package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.mjs +87 -0
- package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.mjs.map +1 -0
- package/dist/esm/StyleSheet/dom/index.mjs +44 -0
- package/dist/esm/StyleSheet/dom/index.mjs.map +1 -0
- package/dist/esm/StyleSheet/index.mjs +33 -0
- package/dist/esm/StyleSheet/index.mjs.map +1 -0
- package/dist/esm/StyleSheet/preprocess.mjs +75 -0
- package/dist/esm/StyleSheet/preprocess.mjs.map +1 -0
- package/dist/esm/StyleSheet/validate.mjs +46 -0
- package/dist/esm/StyleSheet/validate.mjs.map +1 -0
- package/dist/esm/TextAncestorContext.mjs +4 -0
- package/dist/esm/TextAncestorContext.mjs.map +1 -0
- package/dist/esm/colorProps.mjs +14 -0
- package/dist/esm/colorProps.mjs.map +1 -0
- package/dist/esm/index.js +45 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +45 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.mjs +29 -0
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.mjs.map +1 -0
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.mjs +19 -0
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.mjs.map +1 -0
- package/dist/esm/modules/AccessibilityUtil/index.mjs +10 -0
- package/dist/esm/modules/AccessibilityUtil/index.mjs.map +1 -0
- package/dist/esm/modules/AccessibilityUtil/isDisabled.mjs +3 -0
- package/dist/esm/modules/AccessibilityUtil/isDisabled.mjs.map +1 -0
- package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.mjs +34 -0
- package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.mjs.map +1 -0
- package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.mjs +24 -0
- package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.mjs.map +1 -0
- package/dist/esm/modules/AssetRegistry/index.mjs +9 -0
- package/dist/esm/modules/AssetRegistry/index.mjs.map +1 -0
- package/dist/esm/modules/ImageLoader/index.mjs +87 -0
- package/dist/esm/modules/ImageLoader/index.mjs.map +1 -0
- package/dist/esm/modules/InteractionManager.mjs +161 -0
- package/dist/esm/modules/InteractionManager.mjs.map +1 -0
- package/dist/esm/modules/Platform/__tests__/index-test.mjs +27 -0
- package/dist/esm/modules/Platform/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/Platform/index.mjs +7 -0
- package/dist/esm/modules/Platform/index.mjs.map +1 -0
- package/dist/esm/modules/TextInputState/index.mjs +32 -0
- package/dist/esm/modules/TextInputState/index.mjs.map +1 -0
- package/dist/esm/modules/UIManager/__tests__/index-test.mjs +69 -0
- package/dist/esm/modules/UIManager/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/UIManager/index.mjs +37 -0
- package/dist/esm/modules/UIManager/index.mjs.map +1 -0
- package/dist/esm/modules/canUseDOM.mjs +3 -0
- package/dist/esm/modules/canUseDOM.mjs.map +1 -0
- package/dist/esm/modules/createDOMProps/__tests__/index-test.mjs +135 -0
- package/dist/esm/modules/createDOMProps/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/createDOMProps/index.mjs +155 -0
- package/dist/esm/modules/createDOMProps/index.mjs.map +1 -0
- package/dist/esm/modules/createEventHandle/__tests__/index-test.mjs +323 -0
- package/dist/esm/modules/createEventHandle/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/createEventHandle/index.mjs +42 -0
- package/dist/esm/modules/createEventHandle/index.mjs.map +1 -0
- package/dist/esm/modules/dismissKeyboard/index.mjs +6 -0
- package/dist/esm/modules/dismissKeyboard/index.mjs.map +1 -0
- package/dist/esm/modules/forwardedProps/index.mjs +128 -0
- package/dist/esm/modules/forwardedProps/index.mjs.map +1 -0
- package/dist/esm/modules/getBoundingClientRect/index.mjs +5 -0
- package/dist/esm/modules/getBoundingClientRect/index.mjs.map +1 -0
- package/dist/esm/modules/invariant.mjs +12 -0
- package/dist/esm/modules/invariant.mjs.map +1 -0
- package/dist/esm/modules/isSelectionValid/index.mjs +12 -0
- package/dist/esm/modules/isSelectionValid/index.mjs.map +1 -0
- package/dist/esm/modules/isWebColor/index.mjs +3 -0
- package/dist/esm/modules/isWebColor/index.mjs.map +1 -0
- package/dist/esm/modules/mergeRefs/__tests__/index-test.mjs +21 -0
- package/dist/esm/modules/mergeRefs/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/mergeRefs/index.mjs +19 -0
- package/dist/esm/modules/mergeRefs/index.mjs.map +1 -0
- package/dist/esm/modules/modality/__tests__/index-test.mjs +33 -0
- package/dist/esm/modules/modality/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/modality/index.mjs +109 -0
- package/dist/esm/modules/modality/index.mjs.map +1 -0
- package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.mjs +9 -0
- package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/multiplyStyleLengthValue/index.mjs +12 -0
- package/dist/esm/modules/multiplyStyleLengthValue/index.mjs.map +1 -0
- package/dist/esm/modules/normalizeColor/index.mjs +16 -0
- package/dist/esm/modules/normalizeColor/index.mjs.map +1 -0
- package/dist/esm/modules/pick/index.mjs +7 -0
- package/dist/esm/modules/pick/index.mjs.map +1 -0
- package/dist/esm/modules/processColor/__tests__/index-test.mjs +45 -0
- package/dist/esm/modules/processColor/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/processColor/index.mjs +8 -0
- package/dist/esm/modules/processColor/index.mjs.map +1 -0
- package/dist/esm/modules/requestIdleCallback/index.mjs +20 -0
- package/dist/esm/modules/requestIdleCallback/index.mjs.map +1 -0
- package/dist/esm/modules/setValueForStyles/dangerousStyleValue.mjs +12 -0
- package/dist/esm/modules/setValueForStyles/dangerousStyleValue.mjs.map +1 -0
- package/dist/esm/modules/setValueForStyles/index.mjs +12 -0
- package/dist/esm/modules/setValueForStyles/index.mjs.map +1 -0
- package/dist/esm/modules/unitlessNumbers/index.mjs +62 -0
- package/dist/esm/modules/unitlessNumbers/index.mjs.map +1 -0
- package/dist/esm/modules/useElementLayout/index.mjs +16 -0
- package/dist/esm/modules/useElementLayout/index.mjs.map +1 -0
- package/dist/esm/modules/useEvent/__tests__/index-test.mjs +387 -0
- package/dist/esm/modules/useEvent/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/useEvent/index.mjs +22 -0
- package/dist/esm/modules/useEvent/index.mjs.map +1 -0
- package/dist/esm/modules/useHover/__tests__/index-test.mjs +252 -0
- package/dist/esm/modules/useHover/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/useHover/index.mjs +74 -0
- package/dist/esm/modules/useHover/index.mjs.map +1 -0
- package/dist/esm/modules/useLayoutEffect/index.mjs +5 -0
- package/dist/esm/modules/useLayoutEffect/index.mjs.map +1 -0
- package/dist/esm/modules/useLocale/index.mjs +30 -0
- package/dist/esm/modules/useLocale/index.mjs.map +1 -0
- package/dist/esm/modules/useLocale/isLocaleRTL.mjs +60 -0
- package/dist/esm/modules/useLocale/isLocaleRTL.mjs.map +1 -0
- package/dist/esm/modules/useMergeRefs/__tests__/index-test.mjs +81 -0
- package/dist/esm/modules/useMergeRefs/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/useMergeRefs/index.mjs +9 -0
- package/dist/esm/modules/useMergeRefs/index.mjs.map +1 -0
- package/dist/esm/modules/usePlatformMethods/index.mjs +12 -0
- package/dist/esm/modules/usePlatformMethods/index.mjs.map +1 -0
- package/dist/esm/modules/useStable/__tests__/index-test.mjs +71 -0
- package/dist/esm/modules/useStable/__tests__/index-test.mjs.map +1 -0
- package/dist/esm/modules/useStable/index.mjs +8 -0
- package/dist/esm/modules/useStable/index.mjs.map +1 -0
- package/dist/esm/styleTypes.mjs +2 -0
- package/dist/esm/styleTypes.mjs.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/package.json +58 -0
- package/src/StyleSheet/__tests__/compiler-createReactDOMStyle-test.tsx +236 -0
- package/src/StyleSheet/__tests__/compiler-test.tsx +426 -0
- package/src/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.tsx +169 -0
- package/src/StyleSheet/__tests__/index-test.tsx +406 -0
- package/src/StyleSheet/__tests__/preprocess-test.tsx +107 -0
- package/src/StyleSheet/__tests__/validate-test.tsx +42 -0
- package/src/StyleSheet/compiler/createReactDOMStyle.tsx +215 -0
- package/src/StyleSheet/compiler/hash.tsx +1 -0
- package/src/StyleSheet/compiler/hyphenateStyleName.tsx +25 -0
- package/src/StyleSheet/compiler/index.tsx +478 -0
- package/src/StyleSheet/compiler/normalizeColor.tsx +35 -0
- package/src/StyleSheet/compiler/normalizeValueWithProperty.tsx +34 -0
- package/src/StyleSheet/compiler/resolveShadowValue.tsx +26 -0
- package/src/StyleSheet/dom/createCSSStyleSheet.tsx +42 -0
- package/src/StyleSheet/dom/createOrderedCSSStyleSheet.tsx +195 -0
- package/src/StyleSheet/dom/index.tsx +92 -0
- package/src/StyleSheet/index.tsx +99 -0
- package/src/StyleSheet/preprocess.tsx +119 -0
- package/src/StyleSheet/validate.tsx +90 -0
- package/src/TextAncestorContext.tsx +13 -0
- package/src/colorProps.tsx +12 -0
- package/src/index.tsx +58 -0
- package/src/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.tsx +44 -0
- package/src/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.tsx +25 -0
- package/src/modules/AccessibilityUtil/index.tsx +18 -0
- package/src/modules/AccessibilityUtil/isDisabled.tsx +13 -0
- package/src/modules/AccessibilityUtil/propsToAccessibilityComponent.tsx +54 -0
- package/src/modules/AccessibilityUtil/propsToAriaRole.tsx +37 -0
- package/src/modules/AssetRegistry/index.tsx +32 -0
- package/src/modules/ImageLoader/index.tsx +165 -0
- package/src/modules/InteractionManager.tsx +315 -0
- package/src/modules/Platform/__tests__/index-test.tsx +45 -0
- package/src/modules/Platform/index.tsx +15 -0
- package/src/modules/TextInputState/index.tsx +62 -0
- package/src/modules/UIManager/__tests__/index-test.tsx +87 -0
- package/src/modules/UIManager/index.tsx +68 -0
- package/src/modules/canUseDOM.tsx +14 -0
- package/src/modules/createDOMProps/__tests__/index-test.tsx +138 -0
- package/src/modules/createDOMProps/index.tsx +436 -0
- package/src/modules/createEventHandle/__tests__/index-test.tsx +459 -0
- package/src/modules/createEventHandle/index.tsx +100 -0
- package/src/modules/dismissKeyboard/index.tsx +14 -0
- package/src/modules/forwardedProps/index.tsx +145 -0
- package/src/modules/getBoundingClientRect/index.tsx +17 -0
- package/src/modules/invariant.ts +23 -0
- package/src/modules/isSelectionValid/index.tsx +20 -0
- package/src/modules/isWebColor/index.tsx +14 -0
- package/src/modules/mergeRefs/__tests__/index-test.tsx +32 -0
- package/src/modules/mergeRefs/index.tsx +36 -0
- package/src/modules/modality/__tests__/index-test.tsx +66 -0
- package/src/modules/modality/index.tsx +228 -0
- package/src/modules/multiplyStyleLengthValue/__tests__/index-test.tsx +23 -0
- package/src/modules/multiplyStyleLengthValue/index.tsx +26 -0
- package/src/modules/normalizeColor/index.tsx +32 -0
- package/src/modules/pick/index.tsx +25 -0
- package/src/modules/processColor/__tests__/index-test.tsx +78 -0
- package/src/modules/processColor/index.tsx +28 -0
- package/src/modules/requestIdleCallback/index.tsx +35 -0
- package/src/modules/setValueForStyles/dangerousStyleValue.tsx +74 -0
- package/src/modules/setValueForStyles/index.tsx +39 -0
- package/src/modules/unitlessNumbers/index.tsx +77 -0
- package/src/modules/useElementLayout/index.tsx +28 -0
- package/src/modules/useEvent/__tests__/index-test.tsx +511 -0
- package/src/modules/useEvent/index.tsx +64 -0
- package/src/modules/useHover/__tests__/index-test.tsx +342 -0
- package/src/modules/useHover/index.tsx +181 -0
- package/src/modules/useLayoutEffect/index.ts +15 -0
- package/src/modules/useLocale/index.tsx +57 -0
- package/src/modules/useLocale/isLocaleRTL.tsx +74 -0
- package/src/modules/useMergeRefs/__tests__/index-test.tsx +91 -0
- package/src/modules/useMergeRefs/index.tsx +22 -0
- package/src/modules/usePlatformMethods/index.tsx +40 -0
- package/src/modules/useStable/__tests__/index-test.tsx +101 -0
- package/src/modules/useStable/index.tsx +24 -0
- package/src/styleTypes.ts +321 -0
- package/src/types.ts +77 -0
- package/types/StyleSheet/compiler/createReactDOMStyle.d.ts +18 -0
- package/types/StyleSheet/compiler/createReactDOMStyle.d.ts.map +1 -0
- package/types/StyleSheet/compiler/hash.d.ts +2 -0
- package/types/StyleSheet/compiler/hash.d.ts.map +1 -0
- package/types/StyleSheet/compiler/hyphenateStyleName.d.ts +10 -0
- package/types/StyleSheet/compiler/hyphenateStyleName.d.ts.map +1 -0
- package/types/StyleSheet/compiler/index.d.ts +39 -0
- package/types/StyleSheet/compiler/index.d.ts.map +1 -0
- package/types/StyleSheet/compiler/normalizeColor.d.ts +10 -0
- package/types/StyleSheet/compiler/normalizeColor.d.ts.map +1 -0
- package/types/StyleSheet/compiler/normalizeValueWithProperty.d.ts +10 -0
- package/types/StyleSheet/compiler/normalizeValueWithProperty.d.ts.map +1 -0
- package/types/StyleSheet/compiler/resolveShadowValue.d.ts +10 -0
- package/types/StyleSheet/compiler/resolveShadowValue.d.ts.map +1 -0
- package/types/StyleSheet/dom/createCSSStyleSheet.d.ts +10 -0
- package/types/StyleSheet/dom/createCSSStyleSheet.d.ts.map +1 -0
- package/types/StyleSheet/dom/createOrderedCSSStyleSheet.d.ts +29 -0
- package/types/StyleSheet/dom/createOrderedCSSStyleSheet.d.ts.map +1 -0
- package/types/StyleSheet/dom/index.d.ts +15 -0
- package/types/StyleSheet/dom/index.d.ts.map +1 -0
- package/types/StyleSheet/index.d.ts +69 -0
- package/types/StyleSheet/index.d.ts.map +1 -0
- package/types/StyleSheet/preprocess.d.ts +16 -0
- package/types/StyleSheet/preprocess.d.ts.map +1 -0
- package/types/StyleSheet/validate.d.ts +10 -0
- package/types/StyleSheet/validate.d.ts.map +1 -0
- package/types/TextAncestorContext.d.ts +11 -0
- package/types/TextAncestorContext.d.ts.map +1 -0
- package/types/colorProps.d.ts +13 -0
- package/types/colorProps.d.ts.map +1 -0
- package/types/index.d.ts +45 -0
- package/types/index.d.ts.map +1 -0
- package/types/modules/AccessibilityUtil/index.d.ts +16 -0
- package/types/modules/AccessibilityUtil/index.d.ts.map +1 -0
- package/types/modules/AccessibilityUtil/isDisabled.d.ts +10 -0
- package/types/modules/AccessibilityUtil/isDisabled.d.ts.map +1 -0
- package/types/modules/AccessibilityUtil/propsToAccessibilityComponent.d.ts +10 -0
- package/types/modules/AccessibilityUtil/propsToAccessibilityComponent.d.ts.map +1 -0
- package/types/modules/AccessibilityUtil/propsToAriaRole.d.ts +12 -0
- package/types/modules/AccessibilityUtil/propsToAriaRole.d.ts.map +1 -0
- package/types/modules/AssetRegistry/index.d.ts +22 -0
- package/types/modules/AssetRegistry/index.d.ts.map +1 -0
- package/types/modules/ImageLoader/index.d.ts +27 -0
- package/types/modules/ImageLoader/index.d.ts.map +1 -0
- package/types/modules/InteractionManager.d.ts +48 -0
- package/types/modules/InteractionManager.d.ts.map +1 -0
- package/types/modules/Platform/index.d.ts +15 -0
- package/types/modules/Platform/index.d.ts.map +1 -0
- package/types/modules/TextInputState/index.d.ts +38 -0
- package/types/modules/TextInputState/index.d.ts.map +1 -0
- package/types/modules/UIManager/index.d.ts +23 -0
- package/types/modules/UIManager/index.d.ts.map +1 -0
- package/types/modules/canUseDOM.d.ts +10 -0
- package/types/modules/canUseDOM.d.ts.map +1 -0
- package/types/modules/createDOMProps/index.d.ts +12 -0
- package/types/modules/createDOMProps/index.d.ts.map +1 -0
- package/types/modules/createEventHandle/index.d.ts +20 -0
- package/types/modules/createEventHandle/index.d.ts.map +1 -0
- package/types/modules/dismissKeyboard/index.d.ts +10 -0
- package/types/modules/dismissKeyboard/index.d.ts.map +1 -0
- package/types/modules/forwardedProps/index.d.ts +383 -0
- package/types/modules/forwardedProps/index.d.ts.map +1 -0
- package/types/modules/getBoundingClientRect/index.d.ts +10 -0
- package/types/modules/getBoundingClientRect/index.d.ts.map +1 -0
- package/types/modules/invariant.d.ts +3 -0
- package/types/modules/invariant.d.ts.map +1 -0
- package/types/modules/isSelectionValid/index.d.ts +10 -0
- package/types/modules/isSelectionValid/index.d.ts.map +1 -0
- package/types/modules/isWebColor/index.d.ts +10 -0
- package/types/modules/isWebColor/index.d.ts.map +1 -0
- package/types/modules/mergeRefs/index.d.ts +11 -0
- package/types/modules/mergeRefs/index.d.ts.map +1 -0
- package/types/modules/modality/index.d.ts +17 -0
- package/types/modules/modality/index.d.ts.map +1 -0
- package/types/modules/multiplyStyleLengthValue/index.d.ts +10 -0
- package/types/modules/multiplyStyleLengthValue/index.d.ts.map +1 -0
- package/types/modules/normalizeColor/index.d.ts +10 -0
- package/types/modules/normalizeColor/index.d.ts.map +1 -0
- package/types/modules/pick/index.d.ts +12 -0
- package/types/modules/pick/index.d.ts.map +1 -0
- package/types/modules/processColor/index.d.ts +11 -0
- package/types/modules/processColor/index.d.ts.map +1 -0
- package/types/modules/requestIdleCallback/index.d.ts +3 -0
- package/types/modules/requestIdleCallback/index.d.ts.map +1 -0
- package/types/modules/setValueForStyles/dangerousStyleValue.d.ts +11 -0
- package/types/modules/setValueForStyles/dangerousStyleValue.d.ts.map +1 -0
- package/types/modules/setValueForStyles/index.d.ts +9 -0
- package/types/modules/setValueForStyles/index.d.ts.map +1 -0
- package/types/modules/unitlessNumbers/index.d.ts +60 -0
- package/types/modules/unitlessNumbers/index.d.ts.map +1 -0
- package/types/modules/useElementLayout/index.d.ts +4 -0
- package/types/modules/useElementLayout/index.d.ts.map +1 -0
- package/types/modules/useEvent/index.d.ts +24 -0
- package/types/modules/useEvent/index.d.ts.map +1 -0
- package/types/modules/useHover/index.d.ts +21 -0
- package/types/modules/useHover/index.d.ts.map +1 -0
- package/types/modules/useLayoutEffect/index.d.ts +13 -0
- package/types/modules/useLayoutEffect/index.d.ts.map +1 -0
- package/types/modules/useLocale/index.d.ts +14 -0
- package/types/modules/useLocale/index.d.ts.map +1 -0
- package/types/modules/useLocale/isLocaleRTL.d.ts +13 -0
- package/types/modules/useLocale/isLocaleRTL.d.ts.map +1 -0
- package/types/modules/useMergeRefs/index.d.ts +11 -0
- package/types/modules/useMergeRefs/index.d.ts.map +1 -0
- package/types/modules/usePlatformMethods/index.d.ts +18 -0
- package/types/modules/usePlatformMethods/index.d.ts.map +1 -0
- package/types/modules/useStable/index.d.ts +10 -0
- package/types/modules/useStable/index.d.ts.map +1 -0
- package/types/styleTypes.d.ts +211 -0
- package/types/styleTypes.d.ts.map +1 -0
- package/types/types.d.ts +46 -0
- package/types/types.d.ts.map +1 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { getCSSStylesAtomic } from "@hanzogui/web";
|
|
2
|
+
import { AccessibilityUtil } from "../AccessibilityUtil/index.mjs";
|
|
3
|
+
const emptyObject = {},
|
|
4
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
5
|
+
isArray = Array.isArray,
|
|
6
|
+
reactNativeOnlyProps = {
|
|
7
|
+
collapsable: !0,
|
|
8
|
+
contentContainerStyle: !0,
|
|
9
|
+
contentOffset: !0,
|
|
10
|
+
decelerationRate: !0,
|
|
11
|
+
maintainVisibleContentPosition: !0,
|
|
12
|
+
onLayout: !0,
|
|
13
|
+
onMomentumScrollBegin: !0,
|
|
14
|
+
onMomentumScrollEnd: !0,
|
|
15
|
+
onMoveShouldSetResponder: !0,
|
|
16
|
+
onMoveShouldSetResponderCapture: !0,
|
|
17
|
+
onResponderEnd: !0,
|
|
18
|
+
onResponderGrant: !0,
|
|
19
|
+
onResponderMove: !0,
|
|
20
|
+
onResponderReject: !0,
|
|
21
|
+
onResponderRelease: !0,
|
|
22
|
+
onResponderStart: !0,
|
|
23
|
+
onResponderTerminate: !0,
|
|
24
|
+
onResponderTerminationRequest: !0,
|
|
25
|
+
onScrollBeginDrag: !0,
|
|
26
|
+
onScrollEndDrag: !0,
|
|
27
|
+
onScrollShouldSetResponder: !0,
|
|
28
|
+
onScrollShouldSetResponderCapture: !0,
|
|
29
|
+
onSelectionChangeShouldSetResponder: !0,
|
|
30
|
+
onSelectionChangeShouldSetResponderCapture: !0,
|
|
31
|
+
onStartShouldSetResponder: !0,
|
|
32
|
+
onStartShouldSetResponderCapture: !0,
|
|
33
|
+
refreshControl: !0,
|
|
34
|
+
removeClippedSubviews: !0,
|
|
35
|
+
scrollEnabled: !0,
|
|
36
|
+
scrollEventThrottle: !0,
|
|
37
|
+
scrollIndicatorInsets: !0,
|
|
38
|
+
showsHorizontalScrollIndicator: !0,
|
|
39
|
+
showsVerticalScrollIndicator: !0,
|
|
40
|
+
snapToAlignment: !0,
|
|
41
|
+
snapToEnd: !0,
|
|
42
|
+
snapToInterval: !0,
|
|
43
|
+
snapToOffsets: !0,
|
|
44
|
+
snapToStart: !0,
|
|
45
|
+
stickyHeaderIndices: !0,
|
|
46
|
+
ScrollComponent: !0
|
|
47
|
+
},
|
|
48
|
+
uppercasePattern = /[A-Z]/g;
|
|
49
|
+
function toHyphenLower(match) {
|
|
50
|
+
return "-" + match.toLowerCase();
|
|
51
|
+
}
|
|
52
|
+
function hyphenateString(str) {
|
|
53
|
+
return str.replace(uppercasePattern, toHyphenLower);
|
|
54
|
+
}
|
|
55
|
+
function processIDRefList(idRefList) {
|
|
56
|
+
return isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
57
|
+
}
|
|
58
|
+
function flattenStyle(style) {
|
|
59
|
+
if (style === null || typeof style != "object") return;
|
|
60
|
+
if (!isArray(style)) return style;
|
|
61
|
+
const result = {};
|
|
62
|
+
for (let i = 0, styleLength = style.length; i < styleLength; ++i) {
|
|
63
|
+
const computedStyle = flattenStyle(style[i]);
|
|
64
|
+
if (computedStyle) for (const key in computedStyle) hasOwnProperty.call(computedStyle, key) && (result[key] = computedStyle[key]);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
const stylesFromProps = /* @__PURE__ */new WeakMap(),
|
|
69
|
+
createDOMProps = (elementType, props, options) => {
|
|
70
|
+
props || (props = emptyObject);
|
|
71
|
+
const {
|
|
72
|
+
accessibilityActiveDescendant,
|
|
73
|
+
accessibilityAtomic,
|
|
74
|
+
accessibilityAutoComplete,
|
|
75
|
+
accessibilityBusy,
|
|
76
|
+
accessibilityChecked,
|
|
77
|
+
accessibilityColumnCount,
|
|
78
|
+
accessibilityColumnIndex,
|
|
79
|
+
accessibilityColumnSpan,
|
|
80
|
+
accessibilityControls,
|
|
81
|
+
accessibilityCurrent,
|
|
82
|
+
accessibilityDescribedBy,
|
|
83
|
+
accessibilityDetails,
|
|
84
|
+
accessibilityDisabled,
|
|
85
|
+
accessibilityErrorMessage,
|
|
86
|
+
accessibilityExpanded,
|
|
87
|
+
accessibilityFlowTo,
|
|
88
|
+
accessibilityHasPopup,
|
|
89
|
+
accessibilityHidden,
|
|
90
|
+
accessibilityInvalid,
|
|
91
|
+
accessibilityKeyShortcuts,
|
|
92
|
+
accessibilityLabel,
|
|
93
|
+
accessibilityLabelledBy,
|
|
94
|
+
accessibilityLevel,
|
|
95
|
+
accessibilityLiveRegion,
|
|
96
|
+
accessibilityModal,
|
|
97
|
+
accessibilityMultiline,
|
|
98
|
+
accessibilityMultiSelectable,
|
|
99
|
+
accessibilityOrientation,
|
|
100
|
+
accessibilityOwns,
|
|
101
|
+
accessibilityPlaceholder,
|
|
102
|
+
accessibilityPosInSet,
|
|
103
|
+
accessibilityPressed,
|
|
104
|
+
accessibilityReadOnly,
|
|
105
|
+
accessibilityRequired,
|
|
106
|
+
/* eslint-disable */
|
|
107
|
+
accessibilityRole,
|
|
108
|
+
/* eslint-enable */
|
|
109
|
+
accessibilityRoleDescription,
|
|
110
|
+
accessibilityRowCount,
|
|
111
|
+
accessibilityRowIndex,
|
|
112
|
+
accessibilityRowSpan,
|
|
113
|
+
accessibilitySelected,
|
|
114
|
+
accessibilitySetSize,
|
|
115
|
+
accessibilitySort,
|
|
116
|
+
accessibilityValueMax,
|
|
117
|
+
accessibilityValueMin,
|
|
118
|
+
accessibilityValueNow,
|
|
119
|
+
accessibilityValueText,
|
|
120
|
+
dataSet,
|
|
121
|
+
focusable,
|
|
122
|
+
nativeID,
|
|
123
|
+
pointerEvents,
|
|
124
|
+
style,
|
|
125
|
+
testID,
|
|
126
|
+
id,
|
|
127
|
+
// Rest
|
|
128
|
+
...domProps
|
|
129
|
+
} = props;
|
|
130
|
+
for (const key in domProps) reactNativeOnlyProps[key] && delete domProps[key];
|
|
131
|
+
const disabled = accessibilityDisabled,
|
|
132
|
+
role = AccessibilityUtil.propsToAriaRole(props);
|
|
133
|
+
accessibilityActiveDescendant != null && (domProps["aria-activedescendant"] = accessibilityActiveDescendant), accessibilityAtomic != null && (domProps["aria-atomic"] = accessibilityAtomic), accessibilityAutoComplete != null && (domProps["aria-autocomplete"] = accessibilityAutoComplete), accessibilityBusy != null && (domProps["aria-busy"] = accessibilityBusy), accessibilityChecked != null && (domProps["aria-checked"] = accessibilityChecked), accessibilityColumnCount != null && (domProps["aria-colcount"] = accessibilityColumnCount), accessibilityColumnIndex != null && (domProps["aria-colindex"] = accessibilityColumnIndex), accessibilityColumnSpan != null && (domProps["aria-colspan"] = accessibilityColumnSpan), accessibilityControls != null && (domProps["aria-controls"] = processIDRefList(accessibilityControls)), accessibilityCurrent != null && (domProps["aria-current"] = accessibilityCurrent), accessibilityDescribedBy != null && (domProps["aria-describedby"] = processIDRefList(accessibilityDescribedBy)), accessibilityDetails != null && (domProps["aria-details"] = accessibilityDetails), disabled === !0 && (domProps["aria-disabled"] = !0, (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") && (domProps.disabled = !0)), accessibilityErrorMessage != null && (domProps["aria-errormessage"] = accessibilityErrorMessage), accessibilityExpanded != null && (domProps["aria-expanded"] = accessibilityExpanded), accessibilityFlowTo != null && (domProps["aria-flowto"] = processIDRefList(accessibilityFlowTo)), accessibilityHasPopup != null && (domProps["aria-haspopup"] = accessibilityHasPopup), accessibilityHidden === !0 && (domProps["aria-hidden"] = accessibilityHidden), accessibilityInvalid != null && (domProps["aria-invalid"] = accessibilityInvalid), accessibilityKeyShortcuts != null && Array.isArray(accessibilityKeyShortcuts) && (domProps["aria-keyshortcuts"] = accessibilityKeyShortcuts.join(" ")), accessibilityLabel != null && (domProps["aria-label"] = accessibilityLabel), accessibilityLabelledBy != null && (domProps["aria-labelledby"] = processIDRefList(accessibilityLabelledBy)), accessibilityLevel != null && (domProps["aria-level"] = accessibilityLevel), accessibilityLiveRegion != null && (domProps["aria-live"] = accessibilityLiveRegion === "none" ? "off" : accessibilityLiveRegion), accessibilityModal != null && (domProps["aria-modal"] = accessibilityModal), accessibilityMultiline != null && (domProps["aria-multiline"] = accessibilityMultiline), accessibilityMultiSelectable != null && (domProps["aria-multiselectable"] = accessibilityMultiSelectable), accessibilityOrientation != null && (domProps["aria-orientation"] = accessibilityOrientation), accessibilityOwns != null && (domProps["aria-owns"] = processIDRefList(accessibilityOwns)), accessibilityPlaceholder != null && (domProps["aria-placeholder"] = accessibilityPlaceholder), accessibilityPosInSet != null && (domProps["aria-posinset"] = accessibilityPosInSet), accessibilityPressed != null && (domProps["aria-pressed"] = accessibilityPressed), accessibilityReadOnly != null && (domProps["aria-readonly"] = accessibilityReadOnly, (elementType === "input" || elementType === "select" || elementType === "textarea") && (domProps.readOnly = !0)), accessibilityRequired != null && (domProps["aria-required"] = accessibilityRequired, (elementType === "input" || elementType === "select" || elementType === "textarea") && (domProps.required = !0)), role != null && (domProps.role = role === "none" ? "presentation" : role), accessibilityRoleDescription != null && (domProps["aria-roledescription"] = accessibilityRoleDescription), accessibilityRowCount != null && (domProps["aria-rowcount"] = accessibilityRowCount), accessibilityRowIndex != null && (domProps["aria-rowindex"] = accessibilityRowIndex), accessibilityRowSpan != null && (domProps["aria-rowspan"] = accessibilityRowSpan), accessibilitySelected != null && (domProps["aria-selected"] = accessibilitySelected), accessibilitySetSize != null && (domProps["aria-setsize"] = accessibilitySetSize), accessibilitySort != null && (domProps["aria-sort"] = accessibilitySort), accessibilityValueMax != null && (domProps["aria-valuemax"] = accessibilityValueMax), accessibilityValueMin != null && (domProps["aria-valuemin"] = accessibilityValueMin), accessibilityValueNow != null && (domProps["aria-valuenow"] = accessibilityValueNow), accessibilityValueText != null && (domProps["aria-valuetext"] = accessibilityValueText);
|
|
134
|
+
const tmgCN = dataSet ? dataSet.className : void 0,
|
|
135
|
+
tmgID = dataSet ? dataSet.id : void 0;
|
|
136
|
+
if (dataSet != null) {
|
|
137
|
+
for (const dataProp in dataSet) if (!(dataProp === "className" || dataProp === "id") && hasOwnProperty.call(dataSet, dataProp)) {
|
|
138
|
+
const dataName = hyphenateString(dataProp),
|
|
139
|
+
dataValue = dataSet[dataProp];
|
|
140
|
+
dataValue != null && (domProps[`data-${dataName}`] = dataValue);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
focusable === !1 && (domProps.tabIndex = "-1"),
|
|
144
|
+
// These native elements are keyboard focusable by default
|
|
145
|
+
elementType === "a" || elementType === "button" || elementType === "input" || elementType === "select" || elementType === "textarea" ? (focusable === !1 || accessibilityDisabled === !0) && (domProps.tabIndex = "-1") : /* These roles are made keyboard focusable by default */role === "button" || role === "checkbox" || role === "link" || role === "radio" || role === "textbox" || role === "switch" ? focusable !== !1 && (domProps.tabIndex = "0") : focusable === !0 && (domProps.tabIndex = "0");
|
|
146
|
+
const flat = flattenStyle(style);
|
|
147
|
+
let className = tmgCN || "";
|
|
148
|
+
props.className && (className += ` ${props.className}`);
|
|
149
|
+
const stylesAtomic = flat ? getCSSStylesAtomic(flat) : [];
|
|
150
|
+
stylesFromProps.set(domProps, stylesAtomic), domProps.style = stylesAtomic.reduce((acc, [key, value]) => key[0] === "_" || key.startsWith("is_") || key.startsWith("font_") ? (className += ` ${key}`, acc) : (key === "$$css" || key === "" || (acc[key] = value), acc), {}), className && (domProps.className = className);
|
|
151
|
+
const _id = tmgID || id || nativeID;
|
|
152
|
+
return _id && (domProps.id = _id), testID != null && (domProps["data-testid"] = testID), domProps;
|
|
153
|
+
};
|
|
154
|
+
export { createDOMProps, stylesFromProps };
|
|
155
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCSSStylesAtomic","AccessibilityUtil","emptyObject","hasOwnProperty","Object","prototype","isArray","Array","reactNativeOnlyProps","collapsable","contentContainerStyle","contentOffset","decelerationRate","maintainVisibleContentPosition","onLayout","onMomentumScrollBegin","onMomentumScrollEnd","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onResponderEnd","onResponderGrant","onResponderMove","onResponderReject","onResponderRelease","onResponderStart","onResponderTerminate","onResponderTerminationRequest","onScrollBeginDrag","onScrollEndDrag","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","refreshControl","removeClippedSubviews","scrollEnabled","scrollEventThrottle","scrollIndicatorInsets","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","snapToAlignment","snapToEnd","snapToInterval","snapToOffsets","snapToStart","stickyHeaderIndices","ScrollComponent","uppercasePattern","toHyphenLower","match","toLowerCase","hyphenateString","str","replace","processIDRefList","idRefList","join","flattenStyle","style","result","i","styleLength","length","computedStyle","key","call","stylesFromProps","WeakMap","createDOMProps","elementType","props","options","accessibilityActiveDescendant","accessibilityAtomic","accessibilityAutoComplete","accessibilityBusy","accessibilityChecked","accessibilityColumnCount","accessibilityColumnIndex","accessibilityColumnSpan","accessibilityControls","accessibilityCurrent","accessibilityDescribedBy","accessibilityDetails","accessibilityDisabled","accessibilityErrorMessage","accessibilityExpanded","accessibilityFlowTo","accessibilityHasPopup","accessibilityHidden","accessibilityInvalid","accessibilityKeyShortcuts","accessibilityLabel","accessibilityLabelledBy","accessibilityLevel","accessibilityLiveRegion","accessibilityModal","accessibilityMultiline","accessibilityMultiSelectable","accessibilityOrientation","accessibilityOwns","accessibilityPlaceholder","accessibilityPosInSet","accessibilityPressed","accessibilityReadOnly","accessibilityRequired","accessibilityRole","accessibilityRoleDescription","accessibilityRowCount","accessibilityRowIndex","accessibilityRowSpan","accessibilitySelected","accessibilitySetSize","accessibilitySort","accessibilityValueMax","accessibilityValueMin","accessibilityValueNow","accessibilityValueText","dataSet","focusable","nativeID","pointerEvents","testID","id","domProps","disabled","role","propsToAriaRole","readOnly","required","tmgCN","className","tmgID","dataProp","dataName","dataValue","tabIndex","flat","stylesAtomic","set","reduce","acc","value","startsWith","_id"],"sources":["../../../../src/modules/createDOMProps/index.tsx"],"sourcesContent":[null],"mappings":"AASA,SAASA,kBAAA,QAA4C;AACrD,SAASC,iBAAA,QAAyB;AAElC,MAAMC,WAAA,GAAc,CAAC;EACfC,cAAA,GAAiBC,MAAA,CAAOC,SAAA,CAAUF,cAAA;EAClCG,OAAA,GAAUC,KAAA,CAAMD,OAAA;EAGhBE,oBAAA,GAAgD;IACpDC,WAAA,EAAa;IACbC,qBAAA,EAAuB;IACvBC,aAAA,EAAe;IACfC,gBAAA,EAAkB;IAClBC,8BAAA,EAAgC;IAChCC,QAAA,EAAU;IACVC,qBAAA,EAAuB;IACvBC,mBAAA,EAAqB;IACrBC,wBAAA,EAA0B;IAC1BC,+BAAA,EAAiC;IACjCC,cAAA,EAAgB;IAChBC,gBAAA,EAAkB;IAClBC,eAAA,EAAiB;IACjBC,iBAAA,EAAmB;IACnBC,kBAAA,EAAoB;IACpBC,gBAAA,EAAkB;IAClBC,oBAAA,EAAsB;IACtBC,6BAAA,EAA+B;IAC/BC,iBAAA,EAAmB;IACnBC,eAAA,EAAiB;IACjBC,0BAAA,EAA4B;IAC5BC,iCAAA,EAAmC;IACnCC,mCAAA,EAAqC;IACrCC,0CAAA,EAA4C;IAC5CC,yBAAA,EAA2B;IAC3BC,gCAAA,EAAkC;IAClCC,cAAA,EAAgB;IAChBC,qBAAA,EAAuB;IACvBC,aAAA,EAAe;IACfC,mBAAA,EAAqB;IACrBC,qBAAA,EAAuB;IACvBC,8BAAA,EAAgC;IAChCC,4BAAA,EAA8B;IAC9BC,eAAA,EAAiB;IACjBC,SAAA,EAAW;IACXC,cAAA,EAAgB;IAChBC,aAAA,EAAe;IACfC,WAAA,EAAa;IACbC,mBAAA,EAAqB;IACrBC,eAAA,EAAiB;EACnB;EAEMC,gBAAA,GAAmB;AACzB,SAASC,cAAcC,KAAA,EAAO;EAC5B,OAAO,MAAMA,KAAA,CAAMC,WAAA,CAAY;AACjC;AACA,SAASC,gBAAgBC,GAA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
+
import * as ReactDOM from "react-dom";
|
|
4
|
+
import * as ReactDOMServer from "react-dom/server";
|
|
5
|
+
import { act } from "react-dom/test-utils";
|
|
6
|
+
import createEventHandle from "../index.mjs";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
function createRoot(rootNode) {
|
|
9
|
+
return {
|
|
10
|
+
render(element) {
|
|
11
|
+
ReactDOM.render(element, rootNode);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
describe("create-event-handle", () => {
|
|
16
|
+
let root, rootNode;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
rootNode = document.createElement("div"), document.body.appendChild(rootNode), root = createRoot(rootNode);
|
|
19
|
+
}), afterEach(() => {
|
|
20
|
+
root.render(null), document.body.removeChild(rootNode), rootNode = null, root = null;
|
|
21
|
+
}), test("can render correctly using ReactDOMServer", () => {
|
|
22
|
+
const listener = jest.fn(),
|
|
23
|
+
targetRef = React.createRef(),
|
|
24
|
+
addClickListener = createEventHandle("click");
|
|
25
|
+
function Component() {
|
|
26
|
+
return React.useEffect(() => addClickListener(targetRef.current, listener)), /* @__PURE__ */jsx("div", {
|
|
27
|
+
ref: targetRef
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const output = ReactDOMServer.renderToString(/* @__PURE__ */jsx(Component, {}));
|
|
31
|
+
expect(output).toBe('<div data-reactroot=""></div>');
|
|
32
|
+
}), describe("createEventTarget()", () => {
|
|
33
|
+
test("event dispatched on target", () => {
|
|
34
|
+
const listener = jest.fn(),
|
|
35
|
+
targetRef = React.createRef(),
|
|
36
|
+
addClickListener = createEventHandle("click");
|
|
37
|
+
function Component() {
|
|
38
|
+
return React.useEffect(() => addClickListener(targetRef.current, listener)), /* @__PURE__ */jsx("div", {
|
|
39
|
+
ref: targetRef
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
act(() => {
|
|
43
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
44
|
+
});
|
|
45
|
+
const target = createEventTarget(targetRef.current);
|
|
46
|
+
act(() => {
|
|
47
|
+
target.click();
|
|
48
|
+
}), expect(listener).toBeCalledTimes(1);
|
|
49
|
+
}), test("event dispatched on parent", () => {
|
|
50
|
+
const listener = jest.fn(),
|
|
51
|
+
listenerCapture = jest.fn(),
|
|
52
|
+
targetRef = React.createRef(),
|
|
53
|
+
parentRef = React.createRef(),
|
|
54
|
+
addClickListener = createEventHandle("click"),
|
|
55
|
+
addClickCaptureListener = createEventHandle("click", {
|
|
56
|
+
capture: !0
|
|
57
|
+
});
|
|
58
|
+
function Component() {
|
|
59
|
+
return React.useEffect(() => {
|
|
60
|
+
const removeClickListener = addClickListener(targetRef.current, listener),
|
|
61
|
+
removeClickCaptureListener = addClickCaptureListener(targetRef.current, listenerCapture);
|
|
62
|
+
return () => {
|
|
63
|
+
removeClickListener(), removeClickCaptureListener();
|
|
64
|
+
};
|
|
65
|
+
}), /* @__PURE__ */jsx("div", {
|
|
66
|
+
ref: parentRef,
|
|
67
|
+
children: /* @__PURE__ */jsx("div", {
|
|
68
|
+
ref: targetRef
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
act(() => {
|
|
73
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
74
|
+
});
|
|
75
|
+
const parent = createEventTarget(parentRef.current);
|
|
76
|
+
act(() => {
|
|
77
|
+
parent.click();
|
|
78
|
+
}), expect(listener).toBeCalledTimes(0), expect(listenerCapture).toBeCalledTimes(0);
|
|
79
|
+
}), test("event dispatched on child", () => {
|
|
80
|
+
const log = [],
|
|
81
|
+
listener = jest.fn(() => {
|
|
82
|
+
log.push("bubble");
|
|
83
|
+
}),
|
|
84
|
+
listenerCapture = jest.fn(() => {
|
|
85
|
+
log.push("capture");
|
|
86
|
+
}),
|
|
87
|
+
targetRef = React.createRef(),
|
|
88
|
+
childRef = React.createRef(),
|
|
89
|
+
addClickListener = createEventHandle("click"),
|
|
90
|
+
addClickCaptureListener = createEventHandle("click", {
|
|
91
|
+
capture: !0
|
|
92
|
+
});
|
|
93
|
+
function Component() {
|
|
94
|
+
return React.useEffect(() => {
|
|
95
|
+
const removeClickListener = addClickListener(targetRef.current, listener),
|
|
96
|
+
removeClickCaptureListener = addClickCaptureListener(targetRef.current, listenerCapture);
|
|
97
|
+
return () => {
|
|
98
|
+
removeClickListener(), removeClickCaptureListener();
|
|
99
|
+
};
|
|
100
|
+
}), /* @__PURE__ */jsx("div", {
|
|
101
|
+
ref: targetRef,
|
|
102
|
+
children: /* @__PURE__ */jsx("div", {
|
|
103
|
+
ref: childRef
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
act(() => {
|
|
108
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
109
|
+
});
|
|
110
|
+
const child = createEventTarget(childRef.current);
|
|
111
|
+
act(() => {
|
|
112
|
+
child.click();
|
|
113
|
+
}), expect(listenerCapture).toBeCalledTimes(1), expect(listener).toBeCalledTimes(1), expect(log).toEqual(["capture", "bubble"]);
|
|
114
|
+
}), test("event dispatched on text node", () => {
|
|
115
|
+
const listener = jest.fn(),
|
|
116
|
+
targetRef = React.createRef(),
|
|
117
|
+
childRef = React.createRef(),
|
|
118
|
+
addClickListener = createEventHandle("click");
|
|
119
|
+
function Component() {
|
|
120
|
+
return React.useEffect(() => addClickListener(targetRef.current, listener)), /* @__PURE__ */jsx("div", {
|
|
121
|
+
ref: targetRef,
|
|
122
|
+
children: /* @__PURE__ */jsx("div", {
|
|
123
|
+
ref: childRef,
|
|
124
|
+
children: "text"
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
act(() => {
|
|
129
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
130
|
+
});
|
|
131
|
+
const text = createEventTarget(childRef.current.firstChild);
|
|
132
|
+
act(() => {
|
|
133
|
+
text.click();
|
|
134
|
+
}), expect(listener).toBeCalledTimes(1);
|
|
135
|
+
}), test("listener can be attached to document", () => {
|
|
136
|
+
const listener = jest.fn(),
|
|
137
|
+
targetRef = React.createRef(),
|
|
138
|
+
addClickListener = createEventHandle("click");
|
|
139
|
+
function Component({
|
|
140
|
+
target: target2
|
|
141
|
+
}) {
|
|
142
|
+
return React.useEffect(() => addClickListener(target2, listener)), /* @__PURE__ */jsx("div", {
|
|
143
|
+
ref: targetRef
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
act(() => {
|
|
147
|
+
root.render(/* @__PURE__ */jsx(Component, {
|
|
148
|
+
target: document
|
|
149
|
+
}));
|
|
150
|
+
});
|
|
151
|
+
const target = createEventTarget(targetRef.current);
|
|
152
|
+
act(() => {
|
|
153
|
+
target.click();
|
|
154
|
+
}), expect(listener).toBeCalledTimes(1);
|
|
155
|
+
}), test("listener can be attached to window ", () => {
|
|
156
|
+
const listener = jest.fn(),
|
|
157
|
+
targetRef = React.createRef(),
|
|
158
|
+
addClickListener = createEventHandle("click");
|
|
159
|
+
function Component({
|
|
160
|
+
target: target2
|
|
161
|
+
}) {
|
|
162
|
+
return React.useEffect(() => addClickListener(target2, listener)), /* @__PURE__ */jsx("div", {
|
|
163
|
+
ref: targetRef
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
act(() => {
|
|
167
|
+
root.render(/* @__PURE__ */jsx(Component, {
|
|
168
|
+
target: window
|
|
169
|
+
}));
|
|
170
|
+
});
|
|
171
|
+
const target = createEventTarget(targetRef.current);
|
|
172
|
+
act(() => {
|
|
173
|
+
target.click();
|
|
174
|
+
}), expect(listener).toBeCalledTimes(1);
|
|
175
|
+
}), test("custom event dispatched on target", () => {
|
|
176
|
+
const listener = jest.fn(),
|
|
177
|
+
targetRef = React.createRef(),
|
|
178
|
+
addMagicEventListener = createEventHandle("magic-event");
|
|
179
|
+
function Component() {
|
|
180
|
+
return React.useEffect(() => addMagicEventListener(targetRef.current, listener)), /* @__PURE__ */jsx("div", {
|
|
181
|
+
ref: targetRef
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
act(() => {
|
|
185
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
186
|
+
}), act(() => {
|
|
187
|
+
const event = new CustomEvent("magic-event", {
|
|
188
|
+
bubbles: !0
|
|
189
|
+
});
|
|
190
|
+
targetRef.current.dispatchEvent(event);
|
|
191
|
+
}), expect(listener).toBeCalledTimes(1);
|
|
192
|
+
}), test("listeners can be set on multiple targets simultaneously", () => {
|
|
193
|
+
const log = [],
|
|
194
|
+
targetRef = React.createRef(),
|
|
195
|
+
parentRef = React.createRef(),
|
|
196
|
+
childRef = React.createRef(),
|
|
197
|
+
addClickListener = createEventHandle("click"),
|
|
198
|
+
addClickCaptureListener = createEventHandle("click", {
|
|
199
|
+
capture: !0
|
|
200
|
+
}),
|
|
201
|
+
listener = jest.fn(e => {
|
|
202
|
+
log.push(["bubble", e.currentTarget.id]);
|
|
203
|
+
}),
|
|
204
|
+
listenerCapture = jest.fn(e => {
|
|
205
|
+
log.push(["capture", e.currentTarget.id]);
|
|
206
|
+
});
|
|
207
|
+
function Component() {
|
|
208
|
+
return React.useEffect(() => {
|
|
209
|
+
addClickListener(targetRef.current, listener), addClickListener(parentRef.current, listener), addClickCaptureListener(targetRef.current, listenerCapture), addClickCaptureListener(parentRef.current, listenerCapture);
|
|
210
|
+
}), /* @__PURE__ */jsx("div", {
|
|
211
|
+
id: "parent",
|
|
212
|
+
ref: parentRef,
|
|
213
|
+
children: /* @__PURE__ */jsx("div", {
|
|
214
|
+
id: "target",
|
|
215
|
+
ref: targetRef,
|
|
216
|
+
children: /* @__PURE__ */jsx("div", {
|
|
217
|
+
ref: childRef
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
act(() => {
|
|
223
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
224
|
+
});
|
|
225
|
+
const child = createEventTarget(childRef.current);
|
|
226
|
+
act(() => {
|
|
227
|
+
child.click();
|
|
228
|
+
}), expect(listenerCapture).toBeCalledTimes(2), expect(listener).toBeCalledTimes(2), expect(log).toEqual([["capture", "parent"], ["capture", "target"], ["bubble", "target"], ["bubble", "parent"]]);
|
|
229
|
+
}), test("listeners are specific to each event handle", () => {
|
|
230
|
+
const log = [],
|
|
231
|
+
targetRef = React.createRef(),
|
|
232
|
+
childRef = React.createRef(),
|
|
233
|
+
addClickListener = createEventHandle("click"),
|
|
234
|
+
addClickAltListener = createEventHandle("click"),
|
|
235
|
+
addClickCaptureListener = createEventHandle("click", {
|
|
236
|
+
capture: !0
|
|
237
|
+
}),
|
|
238
|
+
addClickCaptureAltListener = createEventHandle("click", {
|
|
239
|
+
capture: !0
|
|
240
|
+
}),
|
|
241
|
+
listener = jest.fn(e => {
|
|
242
|
+
log.push(["bubble", "target"]);
|
|
243
|
+
}),
|
|
244
|
+
listenerAlt = jest.fn(e => {
|
|
245
|
+
log.push(["bubble", "target-alt"]);
|
|
246
|
+
}),
|
|
247
|
+
listenerCapture = jest.fn(e => {
|
|
248
|
+
log.push(["capture", "target"]);
|
|
249
|
+
}),
|
|
250
|
+
listenerCaptureAlt = jest.fn(e => {
|
|
251
|
+
log.push(["capture", "target-alt"]);
|
|
252
|
+
});
|
|
253
|
+
function Component() {
|
|
254
|
+
return React.useEffect(() => {
|
|
255
|
+
addClickListener(targetRef.current, listener), addClickAltListener(targetRef.current, listenerAlt), addClickCaptureListener(targetRef.current, listenerCapture), addClickCaptureAltListener(targetRef.current, listenerCaptureAlt);
|
|
256
|
+
}), /* @__PURE__ */jsx("div", {
|
|
257
|
+
id: "target",
|
|
258
|
+
ref: targetRef,
|
|
259
|
+
children: /* @__PURE__ */jsx("div", {
|
|
260
|
+
ref: childRef
|
|
261
|
+
})
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
act(() => {
|
|
265
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
266
|
+
});
|
|
267
|
+
const child = createEventTarget(childRef.current);
|
|
268
|
+
act(() => {
|
|
269
|
+
child.click();
|
|
270
|
+
}), expect(listenerCapture).toBeCalledTimes(1), expect(listenerCaptureAlt).toBeCalledTimes(1), expect(listener).toBeCalledTimes(1), expect(listenerAlt).toBeCalledTimes(1), expect(log).toEqual([["capture", "target"], ["capture", "target-alt"], ["bubble", "target"], ["bubble", "target-alt"]]);
|
|
271
|
+
});
|
|
272
|
+
}), describe("stopPropagation and stopImmediatePropagation", () => {
|
|
273
|
+
test("stopPropagation works as expected", () => {
|
|
274
|
+
const childListener = jest.fn(e => {
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
}),
|
|
277
|
+
targetListener = jest.fn(),
|
|
278
|
+
targetRef = React.createRef(),
|
|
279
|
+
childRef = React.createRef(),
|
|
280
|
+
addClickListener = createEventHandle("click");
|
|
281
|
+
function Component() {
|
|
282
|
+
return React.useEffect(() => {
|
|
283
|
+
addClickListener(childRef.current, childListener), addClickListener(targetRef.current, targetListener);
|
|
284
|
+
}), /* @__PURE__ */jsx("div", {
|
|
285
|
+
ref: targetRef,
|
|
286
|
+
children: /* @__PURE__ */jsx("div", {
|
|
287
|
+
ref: childRef
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
act(() => {
|
|
292
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
293
|
+
});
|
|
294
|
+
const child = createEventTarget(childRef.current);
|
|
295
|
+
act(() => {
|
|
296
|
+
child.click();
|
|
297
|
+
}), expect(childListener).toBeCalledTimes(1), expect(targetListener).toBeCalledTimes(0);
|
|
298
|
+
}), test("stopImmediatePropagation works as expected", () => {
|
|
299
|
+
const firstListener = jest.fn(e => {
|
|
300
|
+
e.stopImmediatePropagation();
|
|
301
|
+
}),
|
|
302
|
+
secondListener = jest.fn(),
|
|
303
|
+
targetRef = React.createRef(),
|
|
304
|
+
addFirstClickListener = createEventHandle("click"),
|
|
305
|
+
addSecondClickListener = createEventHandle("click");
|
|
306
|
+
function Component() {
|
|
307
|
+
return React.useEffect(() => {
|
|
308
|
+
addFirstClickListener(targetRef.current, firstListener), addSecondClickListener(targetRef.current, secondListener);
|
|
309
|
+
}), /* @__PURE__ */jsx("div", {
|
|
310
|
+
ref: targetRef
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
act(() => {
|
|
314
|
+
root.render(/* @__PURE__ */jsx(Component, {}));
|
|
315
|
+
});
|
|
316
|
+
const target = createEventTarget(targetRef.current);
|
|
317
|
+
act(() => {
|
|
318
|
+
target.click();
|
|
319
|
+
}), expect(firstListener).toBeCalledTimes(1), expect(secondListener).toBeCalledTimes(0);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
//# sourceMappingURL=index-test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEventTarget","React","ReactDOM","ReactDOMServer","act","createEventHandle","jsx","createRoot","rootNode","render","element","describe","root","beforeEach","document","createElement","body","appendChild","afterEach","removeChild","test","listener","jest","fn","targetRef","createRef","addClickListener","Component","useEffect","current","ref","output","renderToString","expect","toBe","target","click","toBeCalledTimes","listenerCapture","parentRef","addClickCaptureListener","capture","removeClickListener","removeClickCaptureListener","children","parent","log","push","childRef","child","toEqual","text","firstChild","target2","window","addMagicEventListener","event","CustomEvent","bubbles","dispatchEvent","e","currentTarget","id","addClickAltListener","addClickCaptureAltListener","listenerAlt","listenerCaptureAlt","childListener","stopPropagation","targetListener","firstListener","stopImmediatePropagation","secondListener","addFirstClickListener","addSecondClickListener"],"sources":["../../../../../src/modules/createEventHandle/__tests__/index-test.tsx"],"sourcesContent":[null],"mappings":"AASA,SAASA,iBAAA,QAAyB;AAClC,YAAYC,KAAA,MAAW;AACvB,YAAYC,QAAA,MAAc;AAC1B,YAAYC,cAAA,MAAoB;AAChC,SAASC,GAAA,QAAW;AAEpB,OAAOC,iBAAA,MAAuB;AAoCjB,SAAAC,GAAA;AAlCb,SAASC,WAAWC,QAAA,EAAU;EAC5B,OAAO;IACLC,OAAOC,O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IAAM;UACnCA,CAAA,CAAEW,wBAAA,CAAyB;QAC7B,CAAC;QACKC,cAAA,GAAiBlD,IAAA,CAAKC,EAAA,CAAG;QACzBC,SAAA,GAAYvB,KAAA,CAAMwB,SAAA,CAAU;QAC5BgD,qBAAA,GAAwBpE,iBAAA,CAAkB,OAAO;QACjDqE,sBAAA,GAAyBrE,iBAAA,CAAkB,OAAO;MAExD,SAASsB,UAAA,EAAY;QACnB,OAAA1B,KAAA,CAAM2B,SAAA,CAAU,MAAM;UACpB6C,qBAAA,CAAsBjD,SAAA,CAAUK,OAAA,EAASyC,aAAa,GACtDI,sBAAA,CAAuBlD,SAAA,CAAUK,OAAA,EAAS2C,cAAc;QAC1D,CAAC,GACM,eAAAlE,GAAA,CAAC;UAAIwB,GAAA,EAAKN;QAAA,CAAW;MAC9B;MAEApB,GAAA,CAAI,MAAM;QACRQ,IAAA,CAAKH,MAAA,CAAO,eAAAH,GAAA,CAACqB,SAAA,IAAU,CAAE;MAC3B,CAAC;MAED,MAAMQ,MAAA,GAASnC,iBAAA,CAAkBwB,SAAA,CAAUK,OAAO;MAElDzB,GAAA,CAAI,MAAM;QACR+B,MAAA,CAAOC,KAAA,CAAM;MACf,CAAC,GAEDH,MAAA,CAAOqC,aAAa,EAAEjC,eAAA,CAAgB,CAAC,GACvCJ,MAAA,CAAOuC,cAAc,EAAEnC,eAAA,CAAgB,CAAC;IAC1C,CAAC;EACH,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { canUseDOM } from "../canUseDOM.mjs";
|
|
2
|
+
const emptyFunction = () => {};
|
|
3
|
+
function supportsPassiveEvents() {
|
|
4
|
+
let supported = !1;
|
|
5
|
+
if (canUseDOM) try {
|
|
6
|
+
const options = {};
|
|
7
|
+
Object.defineProperty(options, "passive", {
|
|
8
|
+
get() {
|
|
9
|
+
return supported = !0, !1;
|
|
10
|
+
}
|
|
11
|
+
}), window.addEventListener("test", null, options), window.removeEventListener("test", null, options);
|
|
12
|
+
} catch {}
|
|
13
|
+
return supported;
|
|
14
|
+
}
|
|
15
|
+
const canUsePassiveEvents = supportsPassiveEvents();
|
|
16
|
+
function getOptions(options) {
|
|
17
|
+
return options == null ? !1 : canUsePassiveEvents ? options : !!options.capture;
|
|
18
|
+
}
|
|
19
|
+
function isPropagationStopped() {
|
|
20
|
+
return this.cancelBubble;
|
|
21
|
+
}
|
|
22
|
+
function isDefaultPrevented() {
|
|
23
|
+
return this.defaultPrevented;
|
|
24
|
+
}
|
|
25
|
+
function normalizeEvent(event) {
|
|
26
|
+
return event.nativeEvent = event, event.persist = emptyFunction, event.isDefaultPrevented = isDefaultPrevented, event.isPropagationStopped = isPropagationStopped, event;
|
|
27
|
+
}
|
|
28
|
+
function createEventHandle(type, options) {
|
|
29
|
+
const opts = getOptions(options);
|
|
30
|
+
return function (target, listener) {
|
|
31
|
+
if (target == null || typeof target.addEventListener != "function") throw new Error("createEventHandle: called on an invalid target.");
|
|
32
|
+
const element = target;
|
|
33
|
+
if (listener != null) {
|
|
34
|
+
const compatListener = e => listener(normalizeEvent(e));
|
|
35
|
+
return element.addEventListener(type, compatListener, opts), function () {
|
|
36
|
+
element?.removeEventListener(type, compatListener, opts);
|
|
37
|
+
};
|
|
38
|
+
} else return emptyFunction;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { createEventHandle };
|
|
42
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["canUseDOM","emptyFunction","supportsPassiveEvents","supported","options","Object","defineProperty","get","window","addEventListener","removeEventListener","canUsePassiveEvents","getOptions","capture","isPropagationStopped","cancelBubble","isDefaultPrevented","defaultPrevented","normalizeEvent","event","nativeEvent","persist","createEventHandle","type","opts","target","listener","Error","element","compatListener","e"],"sources":["../../../../src/modules/createEventHandle/index.tsx"],"sourcesContent":[null],"mappings":"AAYA,SAASA,SAAA,QAAiB;AAU1B,MAAMC,aAAA,GA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;MACpB,MAAMG,cAAA,GAAkBC,CAAA,IAAMJ,QAAA,CAASR,cAAA,CAAeY,CAAC,CAAC;MACxD,OAAAF,OAAA,CAAQnB,gBAAA,CAAiBc,IAAA,EAAMM,cAAA,EAAgBL,IAAI,GAC5C,YAA0B;QAE7BI,OAAA,EAAQlB,mBAAA,CAAoBa,IAAA,EAAMM,cAAA,EAAgBL,IAAI;MAE1D;IACF,OACE,OAAOvB,aAAA;EAEX;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TextInputState","dismissKeyboard","blurTextInput","currentlyFocusedField"],"sources":["../../../../src/modules/dismissKeyboard/index.tsx"],"sourcesContent":[null],"mappings":"AASA,SAASA,cAAA,QAAsB;AAExB,MAAMC,eAAA,GAAkBA,CAAA,KAAM;EACnCD,cAAA,CAAeE,aAAA,CAAcF,cAAA,CAAeG,qBAAA,CAAsB,CAAC;AACrE","ignoreList":[]}
|