@tamagui/react-native-web-internals 1.114.3 → 1.115.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/dist/cjs/StyleSheet/__tests__/{compiler-createReactDOMStyle-test.js → compiler-createReactDOMStyle-test.cjs} +98 -50
- package/dist/cjs/StyleSheet/__tests__/{compiler-test.js → compiler-test.cjs} +158 -129
- package/dist/cjs/StyleSheet/__tests__/{dom-createOrderedCSSStyleSheet-test.js → dom-createOrderedCSSStyleSheet-test.cjs} +23 -19
- package/dist/cjs/StyleSheet/__tests__/{index-test.js → index-test.cjs} +173 -116
- 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 +99 -0
- package/dist/cjs/StyleSheet/compiler/hash.cjs +26 -0
- package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.cjs +37 -0
- package/dist/cjs/StyleSheet/compiler/index.cjs +329 -0
- package/dist/cjs/StyleSheet/compiler/{normalizeColor.js → normalizeColor.cjs} +30 -20
- package/dist/cjs/StyleSheet/compiler/{normalizeValueWithProperty.js → normalizeValueWithProperty.cjs} +24 -15
- package/dist/cjs/StyleSheet/compiler/resolveShadowValue.cjs +60 -0
- package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.cjs +48 -0
- package/dist/cjs/StyleSheet/dom/{createOrderedCSSStyleSheet.js → createOrderedCSSStyleSheet.cjs} +36 -20
- package/dist/cjs/StyleSheet/dom/index.cjs +78 -0
- package/dist/cjs/StyleSheet/{index.js → index.cjs} +24 -19
- package/dist/cjs/StyleSheet/preprocess.cjs +112 -0
- package/dist/cjs/StyleSheet/validate.cjs +69 -0
- package/dist/cjs/TextAncestorContext.cjs +29 -0
- package/dist/cjs/{colorProps.js → colorProps.cjs} +16 -11
- package/dist/cjs/index.cjs +113 -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.js → index.cjs} +25 -15
- package/dist/cjs/modules/AccessibilityUtil/isDisabled.cjs +27 -0
- package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.cjs +69 -0
- package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.cjs +48 -0
- package/dist/cjs/modules/AssetRegistry/{index.js → index.cjs} +16 -11
- package/dist/cjs/modules/ImageLoader/index.cjs +112 -0
- package/dist/cjs/modules/{InteractionManager.js → InteractionManager.cjs} +26 -20
- package/dist/cjs/modules/Platform/__tests__/index-test.cjs +48 -0
- package/dist/cjs/modules/Platform/index.cjs +31 -0
- package/dist/cjs/modules/TextInputState/{index.js → index.cjs} +23 -15
- package/dist/cjs/modules/UIManager/__tests__/{index-test.js → index-test.cjs} +56 -32
- package/dist/cjs/modules/UIManager/index.cjs +138 -0
- package/dist/cjs/modules/canUseDOM.cjs +28 -0
- package/dist/cjs/modules/createDOMProps/__tests__/index-test.cjs +156 -0
- package/dist/cjs/modules/createDOMProps/index.cjs +138 -0
- package/dist/cjs/modules/createEventHandle/__tests__/index-test.cjs +344 -0
- package/dist/cjs/modules/createEventHandle/{index.js → index.cjs} +38 -34
- package/dist/cjs/modules/dismissKeyboard/{index.js → index.cjs} +23 -15
- package/dist/cjs/modules/forwardedProps/index.cjs +160 -0
- package/dist/cjs/modules/getBoundingClientRect/index.cjs +29 -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 +27 -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.js → index-test.cjs} +20 -8
- package/dist/cjs/modules/modality/{index.js → index.cjs} +75 -19
- package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/{index-test.js → index-test.cjs} +16 -14
- package/dist/cjs/modules/multiplyStyleLengthValue/index.cjs +36 -0
- package/dist/cjs/modules/normalizeColor/{index.js → index.cjs} +29 -18
- package/dist/cjs/modules/pick/index.cjs +30 -0
- package/dist/cjs/modules/processColor/__tests__/{index-test.js → index-test.cjs} +17 -15
- package/dist/cjs/modules/processColor/{index.js → index.cjs} +25 -19
- package/dist/cjs/modules/requestIdleCallback/index.cjs +56 -0
- package/dist/cjs/modules/setValueForStyles/{dangerousStyleValue.js → dangerousStyleValue.cjs} +23 -15
- package/dist/cjs/modules/setValueForStyles/{index.js → index.cjs} +26 -18
- package/dist/cjs/modules/unitlessNumbers/index.cjs +87 -0
- package/dist/cjs/modules/useElementLayout/{index.js → index.cjs} +40 -23
- package/dist/cjs/modules/useEvent/__tests__/{index-test.js → index-test.cjs} +218 -99
- package/dist/cjs/modules/useEvent/index.cjs +56 -0
- package/dist/cjs/modules/useHover/__tests__/{index-test.js → index-test.cjs} +118 -40
- package/dist/cjs/modules/useHover/index.cjs +108 -0
- package/dist/cjs/modules/useLayoutEffect/{index.js → index.cjs} +24 -15
- package/dist/cjs/modules/useLocale/index.cjs +66 -0
- package/dist/cjs/modules/useLocale/{isLocaleRTL.js → isLocaleRTL.cjs} +23 -31
- 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 +48 -0
- package/dist/cjs/modules/useStable/__tests__/{index-test.js → index-test.cjs} +46 -23
- package/dist/cjs/modules/useStable/{index.js → index.cjs} +22 -14
- package/dist/cjs/styleTypes.cjs +16 -0
- package/dist/cjs/types.cjs +16 -0
- package/package.json +9 -8
- package/dist/cjs/StyleSheet/__tests__/preprocess-test.js +0 -77
- package/dist/cjs/StyleSheet/__tests__/validate-test.js +0 -18
- package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.js +0 -121
- package/dist/cjs/StyleSheet/compiler/hash.js +0 -21
- package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.js +0 -31
- package/dist/cjs/StyleSheet/compiler/index.js +0 -253
- package/dist/cjs/StyleSheet/compiler/resolveShadowValue.js +0 -35
- package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.js +0 -44
- package/dist/cjs/StyleSheet/dom/index.js +0 -74
- package/dist/cjs/StyleSheet/preprocess.js +0 -67
- package/dist/cjs/StyleSheet/validate.js +0 -66
- package/dist/cjs/TextAncestorContext.js +0 -24
- package/dist/cjs/index.js +0 -73
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.js +0 -46
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.js +0 -30
- package/dist/cjs/modules/AccessibilityUtil/isDisabled.js +0 -22
- package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.js +0 -60
- package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.js +0 -43
- package/dist/cjs/modules/ImageLoader/index.js +0 -102
- package/dist/cjs/modules/Platform/__tests__/index-test.js +0 -46
- package/dist/cjs/modules/Platform/index.js +0 -26
- package/dist/cjs/modules/UIManager/index.js +0 -101
- package/dist/cjs/modules/canUseDOM.js +0 -23
- package/dist/cjs/modules/createDOMProps/__tests__/index-test.js +0 -106
- package/dist/cjs/modules/createDOMProps/index.js +0 -121
- package/dist/cjs/modules/createEventHandle/__tests__/index-test.js +0 -242
- package/dist/cjs/modules/forwardedProps/index.js +0 -145
- package/dist/cjs/modules/getBoundingClientRect/index.js +0 -25
- package/dist/cjs/modules/invariant.js +0 -35
- package/dist/cjs/modules/isSelectionValid/index.js +0 -27
- package/dist/cjs/modules/isWebColor/index.js +0 -22
- package/dist/cjs/modules/mergeRefs/__tests__/index-test.js +0 -34
- package/dist/cjs/modules/mergeRefs/index.js +0 -41
- package/dist/cjs/modules/multiplyStyleLengthValue/index.js +0 -28
- package/dist/cjs/modules/pick/index.js +0 -26
- package/dist/cjs/modules/requestIdleCallback/index.js +0 -44
- package/dist/cjs/modules/unitlessNumbers/index.js +0 -80
- package/dist/cjs/modules/useEvent/index.js +0 -45
- package/dist/cjs/modules/useHover/index.js +0 -81
- package/dist/cjs/modules/useLocale/index.js +0 -54
- package/dist/cjs/modules/useMergeRefs/__tests__/index-test.js +0 -68
- package/dist/cjs/modules/useMergeRefs/index.js +0 -36
- package/dist/cjs/modules/usePlatformMethods/index.js +0 -39
- package/dist/cjs/styleTypes.js +0 -14
- package/dist/cjs/types.js +0 -14
- /package/dist/cjs/StyleSheet/__tests__/{compiler-createReactDOMStyle-test.js.map → compiler-createReactDOMStyle-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{compiler-test.js.map → compiler-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{dom-createOrderedCSSStyleSheet-test.js.map → dom-createOrderedCSSStyleSheet-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{preprocess-test.js.map → preprocess-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{validate-test.js.map → validate-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{createReactDOMStyle.js.map → createReactDOMStyle.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{hash.js.map → hash.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{hyphenateStyleName.js.map → hyphenateStyleName.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{normalizeColor.js.map → normalizeColor.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{normalizeValueWithProperty.js.map → normalizeValueWithProperty.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{resolveShadowValue.js.map → resolveShadowValue.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/dom/{createCSSStyleSheet.js.map → createCSSStyleSheet.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/dom/{createOrderedCSSStyleSheet.js.map → createOrderedCSSStyleSheet.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/dom/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/{preprocess.js.map → preprocess.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/{validate.js.map → validate.cjs.map} +0 -0
- /package/dist/cjs/{TextAncestorContext.js.map → TextAncestorContext.cjs.map} +0 -0
- /package/dist/cjs/{colorProps.js.map → colorProps.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/__tests__/{propsToAccessibilityComponent-test.js.map → propsToAccessibilityComponent-test.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/__tests__/{propsToAriaRole-test.js.map → propsToAriaRole-test.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{isDisabled.js.map → isDisabled.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{propsToAccessibilityComponent.js.map → propsToAccessibilityComponent.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{propsToAriaRole.js.map → propsToAriaRole.cjs.map} +0 -0
- /package/dist/cjs/modules/AssetRegistry/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/ImageLoader/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/{InteractionManager.js.map → InteractionManager.cjs.map} +0 -0
- /package/dist/cjs/modules/Platform/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/Platform/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/TextInputState/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/UIManager/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/UIManager/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/{canUseDOM.js.map → canUseDOM.cjs.map} +0 -0
- /package/dist/cjs/modules/createDOMProps/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/createDOMProps/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/createEventHandle/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/createEventHandle/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/dismissKeyboard/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/forwardedProps/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/getBoundingClientRect/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/{invariant.js.map → invariant.cjs.map} +0 -0
- /package/dist/cjs/modules/isSelectionValid/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/isWebColor/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/mergeRefs/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/mergeRefs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/modality/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/modality/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/multiplyStyleLengthValue/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/normalizeColor/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/pick/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/processColor/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/processColor/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/requestIdleCallback/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/setValueForStyles/{dangerousStyleValue.js.map → dangerousStyleValue.cjs.map} +0 -0
- /package/dist/cjs/modules/setValueForStyles/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/unitlessNumbers/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useElementLayout/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useEvent/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useEvent/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useHover/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useHover/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useLayoutEffect/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useLocale/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useLocale/{isLocaleRTL.js.map → isLocaleRTL.cjs.map} +0 -0
- /package/dist/cjs/modules/useMergeRefs/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useMergeRefs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/usePlatformMethods/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useStable/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useStable/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/{styleTypes.js.map → styleTypes.cjs.map} +0 -0
- /package/dist/cjs/{types.js.map → types.cjs.map} +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
return to;
|
|
11
|
-
};
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
13
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
14
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
15
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
16
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
18
|
-
mod
|
|
19
|
-
));
|
|
20
|
-
var import__ = __toESM(require(".."));
|
|
21
|
-
const createProps = (props) => (0, import__.default)(null, props);
|
|
22
|
-
describe("modules/createDOMProps", () => {
|
|
23
|
-
describe("focus-related accessibility attributes", () => {
|
|
24
|
-
test("with no accessibility props", () => {
|
|
25
|
-
expect(createProps({})).toEqual({});
|
|
26
|
-
}), describe('"accessibilityRole" of "link"', () => {
|
|
27
|
-
const accessibilityRole = "link";
|
|
28
|
-
test("default case", () => {
|
|
29
|
-
expect(createProps({ accessibilityRole })).toEqual(
|
|
30
|
-
expect.not.objectContaining({ tabIndex: "-1" })
|
|
31
|
-
);
|
|
32
|
-
}), test('when "focusable" is true', () => {
|
|
33
|
-
expect(createProps({ accessibilityRole, focusable: !0 })).toEqual(
|
|
34
|
-
expect.not.objectContaining({ tabIndex: "-1" })
|
|
35
|
-
);
|
|
36
|
-
}), test('when "focusable" is false', () => {
|
|
37
|
-
expect(createProps({ accessibilityRole, focusable: !1 })).toEqual(
|
|
38
|
-
expect.objectContaining({ tabIndex: "-1" })
|
|
39
|
-
);
|
|
40
|
-
}), test('when "accessibilityDisabled" is true', () => {
|
|
41
|
-
expect(createProps({ accessibilityRole, accessibilityDisabled: !0 })).toEqual(
|
|
42
|
-
expect.objectContaining({ "aria-disabled": !0 })
|
|
43
|
-
);
|
|
44
|
-
}), test('when "disabled" is false', () => {
|
|
45
|
-
expect(createProps({ accessibilityRole, accessibilityDisabled: !1 })).toEqual(
|
|
46
|
-
expect.not.objectContaining({ tabIndex: "-1" })
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
const testFocusableRole = (accessibilityRole) => {
|
|
51
|
-
test("default case", () => {
|
|
52
|
-
expect(createProps({ accessibilityRole })).toEqual(
|
|
53
|
-
expect.objectContaining({ tabIndex: "0" })
|
|
54
|
-
);
|
|
55
|
-
}), test('when "focusable" is true', () => {
|
|
56
|
-
expect(createProps({ accessibilityRole, focusable: !0 })).toEqual(
|
|
57
|
-
expect.objectContaining({ tabIndex: "0" })
|
|
58
|
-
);
|
|
59
|
-
}), test('when "focusable" is false', () => {
|
|
60
|
-
expect(createProps({ accessibilityRole, focusable: !1 })).toEqual(
|
|
61
|
-
expect.objectContaining({ tabIndex: "-1" })
|
|
62
|
-
);
|
|
63
|
-
}), test('when "accessibilityDisabled" is true', () => {
|
|
64
|
-
expect(createProps({ accessibilityRole, accessibilityDisabled: !0 })).toEqual(
|
|
65
|
-
expect.objectContaining({ "aria-disabled": !0 })
|
|
66
|
-
);
|
|
67
|
-
}), test('when "accessibilityDisabled" is false', () => {
|
|
68
|
-
expect(createProps({ accessibilityRole, accessibilityDisabled: !1 })).toEqual(
|
|
69
|
-
expect.objectContaining({ tabIndex: "0" })
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
describe('"accessibilityRole" of "button"', () => {
|
|
74
|
-
testFocusableRole("button");
|
|
75
|
-
}), describe("with unfocusable accessibilityRole", () => {
|
|
76
|
-
test('when "focusable" is true', () => {
|
|
77
|
-
expect(createProps({ focusable: !0 })).toEqual(
|
|
78
|
-
expect.objectContaining({ tabIndex: "0" })
|
|
79
|
-
);
|
|
80
|
-
}), test('when "focusable" is false', () => {
|
|
81
|
-
expect(createProps({ focusable: !1 })).toEqual(
|
|
82
|
-
expect.objectContaining({ tabIndex: "-1" })
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}), test('prop "accessibilityLabel" becomes "aria-label"', () => {
|
|
87
|
-
const accessibilityLabel = "accessibilityLabel", props = createProps({ accessibilityLabel });
|
|
88
|
-
expect(props["aria-label"]).toEqual(accessibilityLabel);
|
|
89
|
-
}), test('prop "accessibilityLiveRegion" becomes "aria-live"', () => {
|
|
90
|
-
const props = createProps({ accessibilityLiveRegion: "none" });
|
|
91
|
-
expect(props["aria-live"]).toEqual("off");
|
|
92
|
-
}), test('prop "accessibilityRole" becomes "role"', () => {
|
|
93
|
-
const props = createProps({ accessibilityRole: "button" });
|
|
94
|
-
expect(props.role).toEqual("button");
|
|
95
|
-
}), test('prop "className" is preserved', () => {
|
|
96
|
-
const className = "external-class-name", props = createProps({ className });
|
|
97
|
-
expect(props.className).toEqual(className);
|
|
98
|
-
}), test('prop "nativeID" becomes "id"', () => {
|
|
99
|
-
const nativeID = "Example.nativeID", props = createProps({ nativeID });
|
|
100
|
-
expect(props.id).toEqual(nativeID);
|
|
101
|
-
}), test('prop "testID" becomes "data-testid"', () => {
|
|
102
|
-
const testID = "Example.testID", props = createProps({ testID });
|
|
103
|
-
expect(props["data-testid"]).toEqual(testID);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
//# sourceMappingURL=index-test.js.map
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var createDOMProps_exports = {};
|
|
24
|
-
__export(createDOMProps_exports, {
|
|
25
|
-
default: () => createDOMProps_default,
|
|
26
|
-
stylesFromProps: () => stylesFromProps
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(createDOMProps_exports);
|
|
29
|
-
var import_AccessibilityUtil = __toESM(require("../AccessibilityUtil/index")), import_web = require("@tamagui/web");
|
|
30
|
-
const emptyObject = {}, hasOwnProperty = Object.prototype.hasOwnProperty, isArray = Array.isArray, uppercasePattern = /[A-Z]/g;
|
|
31
|
-
function toHyphenLower(match) {
|
|
32
|
-
return "-" + match.toLowerCase();
|
|
33
|
-
}
|
|
34
|
-
function hyphenateString(str) {
|
|
35
|
-
return str.replace(uppercasePattern, toHyphenLower);
|
|
36
|
-
}
|
|
37
|
-
function processIDRefList(idRefList) {
|
|
38
|
-
return isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
39
|
-
}
|
|
40
|
-
const stylesFromProps = /* @__PURE__ */ new WeakMap(), createDOMProps = (elementType, props, options) => {
|
|
41
|
-
props || (props = emptyObject);
|
|
42
|
-
const {
|
|
43
|
-
accessibilityActiveDescendant,
|
|
44
|
-
accessibilityAtomic,
|
|
45
|
-
accessibilityAutoComplete,
|
|
46
|
-
accessibilityBusy,
|
|
47
|
-
accessibilityChecked,
|
|
48
|
-
accessibilityColumnCount,
|
|
49
|
-
accessibilityColumnIndex,
|
|
50
|
-
accessibilityColumnSpan,
|
|
51
|
-
accessibilityControls,
|
|
52
|
-
accessibilityCurrent,
|
|
53
|
-
accessibilityDescribedBy,
|
|
54
|
-
accessibilityDetails,
|
|
55
|
-
accessibilityDisabled,
|
|
56
|
-
accessibilityErrorMessage,
|
|
57
|
-
accessibilityExpanded,
|
|
58
|
-
accessibilityFlowTo,
|
|
59
|
-
accessibilityHasPopup,
|
|
60
|
-
accessibilityHidden,
|
|
61
|
-
accessibilityInvalid,
|
|
62
|
-
accessibilityKeyShortcuts,
|
|
63
|
-
accessibilityLabel,
|
|
64
|
-
accessibilityLabelledBy,
|
|
65
|
-
accessibilityLevel,
|
|
66
|
-
accessibilityLiveRegion,
|
|
67
|
-
accessibilityModal,
|
|
68
|
-
accessibilityMultiline,
|
|
69
|
-
accessibilityMultiSelectable,
|
|
70
|
-
accessibilityOrientation,
|
|
71
|
-
accessibilityOwns,
|
|
72
|
-
accessibilityPlaceholder,
|
|
73
|
-
accessibilityPosInSet,
|
|
74
|
-
accessibilityPressed,
|
|
75
|
-
accessibilityReadOnly,
|
|
76
|
-
accessibilityRequired,
|
|
77
|
-
/* eslint-disable */
|
|
78
|
-
accessibilityRole,
|
|
79
|
-
/* eslint-enable */
|
|
80
|
-
accessibilityRoleDescription,
|
|
81
|
-
accessibilityRowCount,
|
|
82
|
-
accessibilityRowIndex,
|
|
83
|
-
accessibilityRowSpan,
|
|
84
|
-
accessibilitySelected,
|
|
85
|
-
accessibilitySetSize,
|
|
86
|
-
accessibilitySort,
|
|
87
|
-
accessibilityValueMax,
|
|
88
|
-
accessibilityValueMin,
|
|
89
|
-
accessibilityValueNow,
|
|
90
|
-
accessibilityValueText,
|
|
91
|
-
dataSet,
|
|
92
|
-
focusable,
|
|
93
|
-
nativeID,
|
|
94
|
-
pointerEvents,
|
|
95
|
-
style,
|
|
96
|
-
testID,
|
|
97
|
-
id,
|
|
98
|
-
// Rest
|
|
99
|
-
...domProps
|
|
100
|
-
} = props, disabled = accessibilityDisabled, role = import_AccessibilityUtil.default.propsToAriaRole(props);
|
|
101
|
-
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);
|
|
102
|
-
const tmgCN = dataSet ? dataSet.className : void 0, tmgID = dataSet ? dataSet.id : void 0;
|
|
103
|
-
if (dataSet != null) {
|
|
104
|
-
for (const dataProp in dataSet)
|
|
105
|
-
if (!(dataProp === "className" || dataProp === "id") && hasOwnProperty.call(dataSet, dataProp)) {
|
|
106
|
-
const dataName = hyphenateString(dataProp), dataValue = dataSet[dataProp];
|
|
107
|
-
dataValue != null && (domProps[`data-${dataName}`] = dataValue);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
focusable === !1 && (domProps.tabIndex = "-1"), // These native elements are keyboard focusable by default
|
|
111
|
-
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");
|
|
112
|
-
const flat = [].concat(style).flat().flat().flat().flat().reduce((acc, cur) => (cur && Object.assign(acc, cur), acc), {});
|
|
113
|
-
let className = tmgCN || "";
|
|
114
|
-
props.className && (className += ` ${props.className}`);
|
|
115
|
-
const stylesAtomic = (0, import_web.getStylesAtomic)(flat);
|
|
116
|
-
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);
|
|
117
|
-
const _id = tmgID || id || nativeID;
|
|
118
|
-
return _id && (domProps.id = _id), testID != null && (domProps["data-testid"] = testID), domProps;
|
|
119
|
-
};
|
|
120
|
-
var createDOMProps_default = createDOMProps;
|
|
121
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
return to;
|
|
11
|
-
};
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
13
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
14
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
15
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
16
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
18
|
-
mod
|
|
19
|
-
));
|
|
20
|
-
var import_dom_event_testing_library = require("dom-event-testing-library"), React = __toESM(require("react")), ReactDOM = __toESM(require("react-dom")), ReactDOMServer = __toESM(require("react-dom/server")), import_test_utils = require("react-dom/test-utils"), import__ = __toESM(require("..")), import_jsx_runtime = require("react/jsx-runtime");
|
|
21
|
-
function createRoot(rootNode) {
|
|
22
|
-
return {
|
|
23
|
-
render(element) {
|
|
24
|
-
ReactDOM.render(element, rootNode);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
describe("create-event-handle", () => {
|
|
29
|
-
let root, rootNode;
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
rootNode = document.createElement("div"), document.body.appendChild(rootNode), root = createRoot(rootNode);
|
|
32
|
-
}), afterEach(() => {
|
|
33
|
-
root.render(null), document.body.removeChild(rootNode), rootNode = null, root = null;
|
|
34
|
-
}), test("can render correctly using ReactDOMServer", () => {
|
|
35
|
-
const listener = jest.fn(), targetRef = React.createRef(), addClickListener = (0, import__.default)("click");
|
|
36
|
-
function Component() {
|
|
37
|
-
return React.useEffect(() => addClickListener(targetRef.current, listener)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef });
|
|
38
|
-
}
|
|
39
|
-
const output = ReactDOMServer.renderToString(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
40
|
-
expect(output).toBe('<div data-reactroot=""></div>');
|
|
41
|
-
}), describe("createEventTarget()", () => {
|
|
42
|
-
test("event dispatched on target", () => {
|
|
43
|
-
const listener = jest.fn(), targetRef = React.createRef(), addClickListener = (0, import__.default)("click");
|
|
44
|
-
function Component() {
|
|
45
|
-
return React.useEffect(() => addClickListener(targetRef.current, listener)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef });
|
|
46
|
-
}
|
|
47
|
-
(0, import_test_utils.act)(() => {
|
|
48
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
49
|
-
});
|
|
50
|
-
const target = (0, import_dom_event_testing_library.createEventTarget)(targetRef.current);
|
|
51
|
-
(0, import_test_utils.act)(() => {
|
|
52
|
-
target.click();
|
|
53
|
-
}), expect(listener).toBeCalledTimes(1);
|
|
54
|
-
}), test("event dispatched on parent", () => {
|
|
55
|
-
const listener = jest.fn(), listenerCapture = jest.fn(), targetRef = React.createRef(), parentRef = React.createRef(), addClickListener = (0, import__.default)("click"), addClickCaptureListener = (0, import__.default)("click", {
|
|
56
|
-
capture: !0
|
|
57
|
-
});
|
|
58
|
-
function Component() {
|
|
59
|
-
return React.useEffect(() => {
|
|
60
|
-
const removeClickListener = addClickListener(targetRef.current, listener), removeClickCaptureListener = addClickCaptureListener(
|
|
61
|
-
targetRef.current,
|
|
62
|
-
listenerCapture
|
|
63
|
-
);
|
|
64
|
-
return () => {
|
|
65
|
-
removeClickListener(), removeClickCaptureListener();
|
|
66
|
-
};
|
|
67
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: parentRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef }) });
|
|
68
|
-
}
|
|
69
|
-
(0, import_test_utils.act)(() => {
|
|
70
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
71
|
-
});
|
|
72
|
-
const parent = (0, import_dom_event_testing_library.createEventTarget)(parentRef.current);
|
|
73
|
-
(0, import_test_utils.act)(() => {
|
|
74
|
-
parent.click();
|
|
75
|
-
}), expect(listener).toBeCalledTimes(0), expect(listenerCapture).toBeCalledTimes(0);
|
|
76
|
-
}), test("event dispatched on child", () => {
|
|
77
|
-
const log = [], listener = jest.fn(() => {
|
|
78
|
-
log.push("bubble");
|
|
79
|
-
}), listenerCapture = jest.fn(() => {
|
|
80
|
-
log.push("capture");
|
|
81
|
-
}), targetRef = React.createRef(), childRef = React.createRef(), addClickListener = (0, import__.default)("click"), addClickCaptureListener = (0, import__.default)("click", {
|
|
82
|
-
capture: !0
|
|
83
|
-
});
|
|
84
|
-
function Component() {
|
|
85
|
-
return React.useEffect(() => {
|
|
86
|
-
const removeClickListener = addClickListener(targetRef.current, listener), removeClickCaptureListener = addClickCaptureListener(
|
|
87
|
-
targetRef.current,
|
|
88
|
-
listenerCapture
|
|
89
|
-
);
|
|
90
|
-
return () => {
|
|
91
|
-
removeClickListener(), removeClickCaptureListener();
|
|
92
|
-
};
|
|
93
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: childRef }) });
|
|
94
|
-
}
|
|
95
|
-
(0, import_test_utils.act)(() => {
|
|
96
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
97
|
-
});
|
|
98
|
-
const child = (0, import_dom_event_testing_library.createEventTarget)(childRef.current);
|
|
99
|
-
(0, import_test_utils.act)(() => {
|
|
100
|
-
child.click();
|
|
101
|
-
}), expect(listenerCapture).toBeCalledTimes(1), expect(listener).toBeCalledTimes(1), expect(log).toEqual(["capture", "bubble"]);
|
|
102
|
-
}), test("event dispatched on text node", () => {
|
|
103
|
-
const listener = jest.fn(), targetRef = React.createRef(), childRef = React.createRef(), addClickListener = (0, import__.default)("click");
|
|
104
|
-
function Component() {
|
|
105
|
-
return React.useEffect(() => addClickListener(targetRef.current, listener)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: childRef, children: "text" }) });
|
|
106
|
-
}
|
|
107
|
-
(0, import_test_utils.act)(() => {
|
|
108
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
109
|
-
});
|
|
110
|
-
const text = (0, import_dom_event_testing_library.createEventTarget)(childRef.current.firstChild);
|
|
111
|
-
(0, import_test_utils.act)(() => {
|
|
112
|
-
text.click();
|
|
113
|
-
}), expect(listener).toBeCalledTimes(1);
|
|
114
|
-
}), test("listener can be attached to document", () => {
|
|
115
|
-
const listener = jest.fn(), targetRef = React.createRef(), addClickListener = (0, import__.default)("click");
|
|
116
|
-
function Component({ target: target2 }) {
|
|
117
|
-
return React.useEffect(() => addClickListener(target2, listener)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef });
|
|
118
|
-
}
|
|
119
|
-
(0, import_test_utils.act)(() => {
|
|
120
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { target: document }));
|
|
121
|
-
});
|
|
122
|
-
const target = (0, import_dom_event_testing_library.createEventTarget)(targetRef.current);
|
|
123
|
-
(0, import_test_utils.act)(() => {
|
|
124
|
-
target.click();
|
|
125
|
-
}), expect(listener).toBeCalledTimes(1);
|
|
126
|
-
}), test("listener can be attached to window ", () => {
|
|
127
|
-
const listener = jest.fn(), targetRef = React.createRef(), addClickListener = (0, import__.default)("click");
|
|
128
|
-
function Component({ target: target2 }) {
|
|
129
|
-
return React.useEffect(() => addClickListener(target2, listener)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef });
|
|
130
|
-
}
|
|
131
|
-
(0, import_test_utils.act)(() => {
|
|
132
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { target: window }));
|
|
133
|
-
});
|
|
134
|
-
const target = (0, import_dom_event_testing_library.createEventTarget)(targetRef.current);
|
|
135
|
-
(0, import_test_utils.act)(() => {
|
|
136
|
-
target.click();
|
|
137
|
-
}), expect(listener).toBeCalledTimes(1);
|
|
138
|
-
}), test("custom event dispatched on target", () => {
|
|
139
|
-
const listener = jest.fn(), targetRef = React.createRef(), addMagicEventListener = (0, import__.default)("magic-event");
|
|
140
|
-
function Component() {
|
|
141
|
-
return React.useEffect(() => addMagicEventListener(targetRef.current, listener)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef });
|
|
142
|
-
}
|
|
143
|
-
(0, import_test_utils.act)(() => {
|
|
144
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
145
|
-
}), (0, import_test_utils.act)(() => {
|
|
146
|
-
const event = new CustomEvent("magic-event", { bubbles: !0 });
|
|
147
|
-
targetRef.current.dispatchEvent(event);
|
|
148
|
-
}), expect(listener).toBeCalledTimes(1);
|
|
149
|
-
}), test("listeners can be set on multiple targets simultaneously", () => {
|
|
150
|
-
const log = [], targetRef = React.createRef(), parentRef = React.createRef(), childRef = React.createRef(), addClickListener = (0, import__.default)("click"), addClickCaptureListener = (0, import__.default)("click", {
|
|
151
|
-
capture: !0
|
|
152
|
-
}), listener = jest.fn((e) => {
|
|
153
|
-
log.push(["bubble", e.currentTarget.id]);
|
|
154
|
-
}), listenerCapture = jest.fn((e) => {
|
|
155
|
-
log.push(["capture", e.currentTarget.id]);
|
|
156
|
-
});
|
|
157
|
-
function Component() {
|
|
158
|
-
return React.useEffect(() => {
|
|
159
|
-
addClickListener(targetRef.current, listener), addClickListener(parentRef.current, listener), addClickCaptureListener(targetRef.current, listenerCapture), addClickCaptureListener(parentRef.current, listenerCapture);
|
|
160
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "parent", ref: parentRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "target", ref: targetRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: childRef }) }) });
|
|
161
|
-
}
|
|
162
|
-
(0, import_test_utils.act)(() => {
|
|
163
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
164
|
-
});
|
|
165
|
-
const child = (0, import_dom_event_testing_library.createEventTarget)(childRef.current);
|
|
166
|
-
(0, import_test_utils.act)(() => {
|
|
167
|
-
child.click();
|
|
168
|
-
}), expect(listenerCapture).toBeCalledTimes(2), expect(listener).toBeCalledTimes(2), expect(log).toEqual([
|
|
169
|
-
["capture", "parent"],
|
|
170
|
-
["capture", "target"],
|
|
171
|
-
["bubble", "target"],
|
|
172
|
-
["bubble", "parent"]
|
|
173
|
-
]);
|
|
174
|
-
}), test("listeners are specific to each event handle", () => {
|
|
175
|
-
const log = [], targetRef = React.createRef(), childRef = React.createRef(), addClickListener = (0, import__.default)("click"), addClickAltListener = (0, import__.default)("click"), addClickCaptureListener = (0, import__.default)("click", {
|
|
176
|
-
capture: !0
|
|
177
|
-
}), addClickCaptureAltListener = (0, import__.default)("click", {
|
|
178
|
-
capture: !0
|
|
179
|
-
}), listener = jest.fn((e) => {
|
|
180
|
-
log.push(["bubble", "target"]);
|
|
181
|
-
}), listenerAlt = jest.fn((e) => {
|
|
182
|
-
log.push(["bubble", "target-alt"]);
|
|
183
|
-
}), listenerCapture = jest.fn((e) => {
|
|
184
|
-
log.push(["capture", "target"]);
|
|
185
|
-
}), listenerCaptureAlt = jest.fn((e) => {
|
|
186
|
-
log.push(["capture", "target-alt"]);
|
|
187
|
-
});
|
|
188
|
-
function Component() {
|
|
189
|
-
return React.useEffect(() => {
|
|
190
|
-
addClickListener(targetRef.current, listener), addClickAltListener(targetRef.current, listenerAlt), addClickCaptureListener(targetRef.current, listenerCapture), addClickCaptureAltListener(targetRef.current, listenerCaptureAlt);
|
|
191
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "target", ref: targetRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: childRef }) });
|
|
192
|
-
}
|
|
193
|
-
(0, import_test_utils.act)(() => {
|
|
194
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
195
|
-
});
|
|
196
|
-
const child = (0, import_dom_event_testing_library.createEventTarget)(childRef.current);
|
|
197
|
-
(0, import_test_utils.act)(() => {
|
|
198
|
-
child.click();
|
|
199
|
-
}), expect(listenerCapture).toBeCalledTimes(1), expect(listenerCaptureAlt).toBeCalledTimes(1), expect(listener).toBeCalledTimes(1), expect(listenerAlt).toBeCalledTimes(1), expect(log).toEqual([
|
|
200
|
-
["capture", "target"],
|
|
201
|
-
["capture", "target-alt"],
|
|
202
|
-
["bubble", "target"],
|
|
203
|
-
["bubble", "target-alt"]
|
|
204
|
-
]);
|
|
205
|
-
});
|
|
206
|
-
}), describe("stopPropagation and stopImmediatePropagation", () => {
|
|
207
|
-
test("stopPropagation works as expected", () => {
|
|
208
|
-
const childListener = jest.fn((e) => {
|
|
209
|
-
e.stopPropagation();
|
|
210
|
-
}), targetListener = jest.fn(), targetRef = React.createRef(), childRef = React.createRef(), addClickListener = (0, import__.default)("click");
|
|
211
|
-
function Component() {
|
|
212
|
-
return React.useEffect(() => {
|
|
213
|
-
addClickListener(childRef.current, childListener), addClickListener(targetRef.current, targetListener);
|
|
214
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: childRef }) });
|
|
215
|
-
}
|
|
216
|
-
(0, import_test_utils.act)(() => {
|
|
217
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
218
|
-
});
|
|
219
|
-
const child = (0, import_dom_event_testing_library.createEventTarget)(childRef.current);
|
|
220
|
-
(0, import_test_utils.act)(() => {
|
|
221
|
-
child.click();
|
|
222
|
-
}), expect(childListener).toBeCalledTimes(1), expect(targetListener).toBeCalledTimes(0);
|
|
223
|
-
}), test("stopImmediatePropagation works as expected", () => {
|
|
224
|
-
const firstListener = jest.fn((e) => {
|
|
225
|
-
e.stopImmediatePropagation();
|
|
226
|
-
}), secondListener = jest.fn(), targetRef = React.createRef(), addFirstClickListener = (0, import__.default)("click"), addSecondClickListener = (0, import__.default)("click");
|
|
227
|
-
function Component() {
|
|
228
|
-
return React.useEffect(() => {
|
|
229
|
-
addFirstClickListener(targetRef.current, firstListener), addSecondClickListener(targetRef.current, secondListener);
|
|
230
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: targetRef });
|
|
231
|
-
}
|
|
232
|
-
(0, import_test_utils.act)(() => {
|
|
233
|
-
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
234
|
-
});
|
|
235
|
-
const target = (0, import_dom_event_testing_library.createEventTarget)(targetRef.current);
|
|
236
|
-
(0, import_test_utils.act)(() => {
|
|
237
|
-
target.click();
|
|
238
|
-
}), expect(firstListener).toBeCalledTimes(1), expect(secondListener).toBeCalledTimes(0);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
//# sourceMappingURL=index-test.js.map
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var forwardedProps_exports = {};
|
|
16
|
-
__export(forwardedProps_exports, {
|
|
17
|
-
accessibilityProps: () => accessibilityProps,
|
|
18
|
-
clickProps: () => clickProps,
|
|
19
|
-
defaultProps: () => defaultProps,
|
|
20
|
-
focusProps: () => focusProps,
|
|
21
|
-
forwardPropsListText: () => forwardPropsListText,
|
|
22
|
-
forwardPropsListView: () => forwardPropsListView,
|
|
23
|
-
forwardedProps: () => forwardedProps,
|
|
24
|
-
keyboardProps: () => keyboardProps,
|
|
25
|
-
mouseProps: () => mouseProps,
|
|
26
|
-
styleProps: () => styleProps,
|
|
27
|
-
touchProps: () => touchProps
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(forwardedProps_exports);
|
|
30
|
-
const defaultProps = {
|
|
31
|
-
children: !0,
|
|
32
|
-
dataSet: !0,
|
|
33
|
-
nativeID: !0,
|
|
34
|
-
ref: !0,
|
|
35
|
-
suppressHydrationWarning: !0,
|
|
36
|
-
testID: !0,
|
|
37
|
-
id: !0
|
|
38
|
-
}, accessibilityProps = {
|
|
39
|
-
accessibilityActiveDescendant: !0,
|
|
40
|
-
accessibilityAtomic: !0,
|
|
41
|
-
accessibilityAutoComplete: !0,
|
|
42
|
-
accessibilityBusy: !0,
|
|
43
|
-
accessibilityChecked: !0,
|
|
44
|
-
accessibilityColumnCount: !0,
|
|
45
|
-
accessibilityColumnIndex: !0,
|
|
46
|
-
accessibilityColumnSpan: !0,
|
|
47
|
-
accessibilityControls: !0,
|
|
48
|
-
accessibilityCurrent: !0,
|
|
49
|
-
accessibilityDescribedBy: !0,
|
|
50
|
-
accessibilityDetails: !0,
|
|
51
|
-
accessibilityDisabled: !0,
|
|
52
|
-
accessibilityErrorMessage: !0,
|
|
53
|
-
accessibilityExpanded: !0,
|
|
54
|
-
accessibilityFlowTo: !0,
|
|
55
|
-
accessibilityHasPopup: !0,
|
|
56
|
-
accessibilityHidden: !0,
|
|
57
|
-
accessibilityInvalid: !0,
|
|
58
|
-
accessibilityKeyShortcuts: !0,
|
|
59
|
-
accessibilityLabel: !0,
|
|
60
|
-
accessibilityLabelledBy: !0,
|
|
61
|
-
accessibilityLevel: !0,
|
|
62
|
-
accessibilityLiveRegion: !0,
|
|
63
|
-
accessibilityModal: !0,
|
|
64
|
-
accessibilityMultiline: !0,
|
|
65
|
-
accessibilityMultiSelectable: !0,
|
|
66
|
-
accessibilityOrientation: !0,
|
|
67
|
-
accessibilityOwns: !0,
|
|
68
|
-
accessibilityPlaceholder: !0,
|
|
69
|
-
accessibilityPosInSet: !0,
|
|
70
|
-
accessibilityPressed: !0,
|
|
71
|
-
accessibilityReadOnly: !0,
|
|
72
|
-
accessibilityRequired: !0,
|
|
73
|
-
accessibilityRole: !0,
|
|
74
|
-
accessibilityRoleDescription: !0,
|
|
75
|
-
accessibilityRowCount: !0,
|
|
76
|
-
accessibilityRowIndex: !0,
|
|
77
|
-
accessibilityRowSpan: !0,
|
|
78
|
-
accessibilitySelected: !0,
|
|
79
|
-
accessibilitySetSize: !0,
|
|
80
|
-
accessibilitySort: !0,
|
|
81
|
-
accessibilityValueMax: !0,
|
|
82
|
-
accessibilityValueMin: !0,
|
|
83
|
-
accessibilityValueNow: !0,
|
|
84
|
-
accessibilityValueText: !0,
|
|
85
|
-
dir: !0,
|
|
86
|
-
focusable: !0
|
|
87
|
-
}, clickProps = {
|
|
88
|
-
onClick: !0,
|
|
89
|
-
onClickCapture: !0,
|
|
90
|
-
onContextMenu: !0
|
|
91
|
-
}, focusProps = {
|
|
92
|
-
onBlur: !0,
|
|
93
|
-
onFocus: !0
|
|
94
|
-
}, keyboardProps = {
|
|
95
|
-
onKeyDown: !0,
|
|
96
|
-
onKeyDownCapture: !0,
|
|
97
|
-
onKeyUp: !0,
|
|
98
|
-
onKeyUpCapture: !0
|
|
99
|
-
}, mouseProps = {
|
|
100
|
-
onMouseDown: !0,
|
|
101
|
-
onMouseEnter: !0,
|
|
102
|
-
onMouseLeave: !0,
|
|
103
|
-
onMouseMove: !0,
|
|
104
|
-
onMouseOver: !0,
|
|
105
|
-
onMouseOut: !0,
|
|
106
|
-
onMouseUp: !0
|
|
107
|
-
}, touchProps = {
|
|
108
|
-
onTouchCancel: !0,
|
|
109
|
-
onTouchCancelCapture: !0,
|
|
110
|
-
onTouchEnd: !0,
|
|
111
|
-
onTouchEndCapture: !0,
|
|
112
|
-
onTouchMove: !0,
|
|
113
|
-
onTouchMoveCapture: !0,
|
|
114
|
-
onTouchStart: !0,
|
|
115
|
-
onTouchStartCapture: !0
|
|
116
|
-
}, styleProps = {
|
|
117
|
-
classList: !0,
|
|
118
|
-
style: !0
|
|
119
|
-
}, forwardedProps = {
|
|
120
|
-
defaultProps,
|
|
121
|
-
accessibilityProps,
|
|
122
|
-
clickProps,
|
|
123
|
-
focusProps,
|
|
124
|
-
keyboardProps,
|
|
125
|
-
mouseProps,
|
|
126
|
-
touchProps,
|
|
127
|
-
styleProps
|
|
128
|
-
}, forwardPropsListText = {
|
|
129
|
-
...defaultProps,
|
|
130
|
-
...accessibilityProps,
|
|
131
|
-
...clickProps,
|
|
132
|
-
...focusProps,
|
|
133
|
-
...keyboardProps,
|
|
134
|
-
...mouseProps,
|
|
135
|
-
...touchProps,
|
|
136
|
-
...styleProps,
|
|
137
|
-
href: !0,
|
|
138
|
-
lang: !0,
|
|
139
|
-
pointerEvents: !0
|
|
140
|
-
}, forwardPropsListView = {
|
|
141
|
-
...forwardPropsListText,
|
|
142
|
-
onScroll: !0,
|
|
143
|
-
onWheel: !0
|
|
144
|
-
};
|
|
145
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var getBoundingClientRect_exports = {};
|
|
16
|
-
__export(getBoundingClientRect_exports, {
|
|
17
|
-
default: () => getBoundingClientRect_default
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(getBoundingClientRect_exports);
|
|
20
|
-
const getBoundingClientRect = (node) => {
|
|
21
|
-
if (node != null && node.nodeType === 1 && typeof node.getBoundingClientRect == "function")
|
|
22
|
-
return node.getBoundingClientRect();
|
|
23
|
-
};
|
|
24
|
-
var getBoundingClientRect_default = getBoundingClientRect;
|
|
25
|
-
//# sourceMappingURL=index.js.map
|