@rootnative/web 0.0.0-alpha.3 → 0.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/dist/apis/AccessibilityInfo/index.d.ts +30 -0
- package/dist/apis/AccessibilityInfo/index.js +84 -0
- package/dist/apis/AccessibilityInfo/index.js.map +1 -0
- package/dist/apis/Alert/index.d.ts +22 -0
- package/dist/apis/Alert/index.js +141 -0
- package/dist/apis/Alert/index.js.map +1 -0
- package/dist/apis/AppState/index.d.ts +21 -0
- package/dist/apis/AppState/index.js +86 -0
- package/dist/apis/AppState/index.js.map +1 -0
- package/dist/apis/Appearance/index.d.ts +14 -0
- package/dist/apis/Appearance/index.js +39 -0
- package/dist/apis/Appearance/index.js.map +1 -0
- package/dist/apis/BackHandler/index.d.ts +10 -0
- package/dist/apis/BackHandler/index.js +16 -0
- package/dist/apis/BackHandler/index.js.map +1 -0
- package/dist/apis/Clipboard/index.d.ts +9 -0
- package/dist/apis/Clipboard/index.js +45 -0
- package/dist/apis/Clipboard/index.js.map +1 -0
- package/dist/apis/Dimensions/index.d.ts +19 -0
- package/dist/apis/Dimensions/index.js +66 -0
- package/dist/apis/Dimensions/index.js.map +1 -0
- package/dist/apis/I18nManager/index.d.ts +14 -0
- package/dist/apis/I18nManager/index.js +33 -0
- package/dist/apis/I18nManager/index.js.map +1 -0
- package/dist/apis/Keyboard/index.d.ts +36 -0
- package/dist/apis/Keyboard/index.js +149 -0
- package/dist/apis/Keyboard/index.js.map +1 -0
- package/dist/apis/Linking/index.d.ts +29 -0
- package/dist/apis/Linking/index.js +86 -0
- package/dist/apis/Linking/index.js.map +1 -0
- package/dist/apis/PanResponder/index.d.ts +50 -0
- package/dist/apis/PanResponder/index.js +239 -0
- package/dist/apis/PanResponder/index.js.map +1 -0
- package/dist/apis/PixelRatio/index.d.ts +8 -0
- package/dist/apis/PixelRatio/index.js +15 -0
- package/dist/apis/PixelRatio/index.js.map +1 -0
- package/dist/apis/Platform/index.d.ts +4 -0
- package/dist/apis/Platform/index.js +28 -0
- package/dist/apis/Platform/index.js.map +1 -0
- package/dist/apis/Platform/types.d.ts +19 -0
- package/dist/apis/Share/index.d.ts +30 -0
- package/dist/apis/Share/index.js +34 -0
- package/dist/apis/Share/index.js.map +1 -0
- package/dist/apis/StyleSheet/index.d.ts +23 -0
- package/dist/apis/StyleSheet/index.js +29 -0
- package/dist/apis/StyleSheet/index.js.map +1 -0
- package/dist/apis/StyleSheet/types.d.ts +328 -0
- package/dist/apis/Vibration/index.d.ts +9 -0
- package/dist/apis/Vibration/index.js +40 -0
- package/dist/apis/Vibration/index.js.map +1 -0
- package/dist/apis/processColor/index.d.ts +3 -0
- package/dist/apis/processColor/index.js +12 -0
- package/dist/apis/processColor/index.js.map +1 -0
- package/dist/apis/useColorScheme/index.d.ts +3 -0
- package/dist/apis/useColorScheme/index.js +13 -0
- package/dist/apis/useColorScheme/index.js.map +1 -0
- package/dist/apis/useWindowDimensions/index.d.ts +3 -0
- package/dist/apis/useWindowDimensions/index.js +19 -0
- package/dist/apis/useWindowDimensions/index.js.map +1 -0
- package/dist/bundler/index.js +30 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/bundler/inlinePlatformOS.js +121 -0
- package/dist/bundler/inlinePlatformOS.js.map +1 -0
- package/dist/bundler/worklets.js +61 -0
- package/dist/bundler/worklets.js.map +1 -0
- package/dist/compat/TurboModuleRegistry/index.d.ts +16 -0
- package/dist/compat/TurboModuleRegistry/index.js +14 -0
- package/dist/compat/TurboModuleRegistry/index.js.map +1 -0
- package/dist/compat/createElement/index.d.ts +9 -0
- package/dist/compat/createElement/index.js +40 -0
- package/dist/compat/createElement/index.js.map +1 -0
- package/dist/compat/findNodeHandle/index.d.ts +7 -0
- package/dist/compat/findNodeHandle/index.js +19 -0
- package/dist/compat/findNodeHandle/index.js.map +1 -0
- package/dist/components/ActivityIndicator/index.d.ts +5 -0
- package/dist/components/ActivityIndicator/index.js +74 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/types.d.ts +8 -0
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.js +48 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/types.d.ts +31 -0
- package/dist/components/FlatList/index.d.ts +5 -0
- package/dist/components/FlatList/index.js +433 -0
- package/dist/components/FlatList/index.js.map +1 -0
- package/dist/components/FlatList/types.d.ts +138 -0
- package/dist/components/FlatList/viewability.js +86 -0
- package/dist/components/FlatList/viewability.js.map +1 -0
- package/dist/components/Image/index.d.ts +7 -0
- package/dist/components/Image/index.js +301 -0
- package/dist/components/Image/index.js.map +1 -0
- package/dist/components/Image/source.js +97 -0
- package/dist/components/Image/source.js.map +1 -0
- package/dist/components/Image/types.d.ts +96 -0
- package/dist/components/KeyboardAvoidingView/index.d.ts +10 -0
- package/dist/components/KeyboardAvoidingView/index.js +118 -0
- package/dist/components/KeyboardAvoidingView/index.js.map +1 -0
- package/dist/components/KeyboardAvoidingView/types.d.ts +14 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +271 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/types.d.ts +29 -0
- package/dist/components/Pressable/index.d.ts +5 -0
- package/dist/components/Pressable/index.js +106 -0
- package/dist/components/Pressable/index.js.map +1 -0
- package/dist/components/Pressable/types.d.ts +44 -0
- package/dist/components/RefreshControl/index.d.ts +5 -0
- package/dist/components/RefreshControl/index.js +176 -0
- package/dist/components/RefreshControl/index.js.map +1 -0
- package/dist/components/RefreshControl/pull.js +16 -0
- package/dist/components/RefreshControl/pull.js.map +1 -0
- package/dist/components/RefreshControl/types.d.ts +14 -0
- package/dist/components/ScrollView/index.d.ts +5 -0
- package/dist/components/ScrollView/index.js +318 -0
- package/dist/components/ScrollView/index.js.map +1 -0
- package/dist/components/ScrollView/snap.js +38 -0
- package/dist/components/ScrollView/snap.js.map +1 -0
- package/dist/components/ScrollView/types.d.ts +115 -0
- package/dist/components/StatusBar/index.d.ts +26 -0
- package/dist/components/StatusBar/index.js +113 -0
- package/dist/components/StatusBar/index.js.map +1 -0
- package/dist/components/Switch/index.d.ts +5 -0
- package/dist/components/Switch/index.js +89 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/types.d.ts +25 -0
- package/dist/components/Text/TextAncestorContext.d.ts +3 -0
- package/dist/components/Text/TextAncestorContext.js +6 -0
- package/dist/components/Text/TextAncestorContext.js.map +1 -0
- package/dist/components/Text/index.d.ts +6 -0
- package/dist/components/Text/index.js +133 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/types.d.ts +38 -0
- package/dist/components/TextInput/autocomplete.js +102 -0
- package/dist/components/TextInput/autocomplete.js.map +1 -0
- package/dist/components/TextInput/index.d.ts +8 -0
- package/dist/components/TextInput/index.js +290 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/types.d.ts +130 -0
- package/dist/components/TouchableHighlight/index.d.ts +5 -0
- package/dist/components/TouchableHighlight/index.js +109 -0
- package/dist/components/TouchableHighlight/index.js.map +1 -0
- package/dist/components/TouchableHighlight/types.d.ts +15 -0
- package/dist/components/TouchableNativeFeedback/index.d.ts +11 -0
- package/dist/components/TouchableNativeFeedback/index.js +29 -0
- package/dist/components/TouchableNativeFeedback/index.js.map +1 -0
- package/dist/components/TouchableNativeFeedback/types.d.ts +19 -0
- package/dist/components/TouchableOpacity/index.d.ts +5 -0
- package/dist/components/TouchableOpacity/index.js +122 -0
- package/dist/components/TouchableOpacity/index.js.map +1 -0
- package/dist/components/TouchableOpacity/types.d.ts +11 -0
- package/dist/components/TouchableWithoutFeedback/index.d.ts +5 -0
- package/dist/components/TouchableWithoutFeedback/index.js +70 -0
- package/dist/components/TouchableWithoutFeedback/index.js.map +1 -0
- package/dist/components/TouchableWithoutFeedback/types.d.ts +40 -0
- package/dist/components/View/index.d.ts +5 -0
- package/dist/components/View/index.js +50 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/types.d.ts +98 -0
- package/dist/dom/Head.d.ts +21 -0
- package/dist/dom/Head.js +53 -0
- package/dist/dom/Head.js.map +1 -0
- package/dist/dom/index.d.ts +2 -22
- package/dist/dom/index.js +1 -53
- package/dist/events/press/Pressability.d.ts +2 -0
- package/dist/events/press/Pressability.js +366 -0
- package/dist/events/press/Pressability.js.map +1 -0
- package/dist/events/press/cursorStyle.js +5 -0
- package/dist/events/press/cursorStyle.js.map +1 -0
- package/dist/events/press/index.d.ts +4 -0
- package/dist/events/press/mergeHandlers.js +30 -0
- package/dist/events/press/mergeHandlers.js.map +1 -0
- package/dist/events/press/types.d.ts +48 -0
- package/dist/events/press/usePressability.d.ts +4 -0
- package/dist/events/press/usePressability.js +18 -0
- package/dist/events/press/usePressability.js.map +1 -0
- package/dist/events/responderEvent.js +50 -0
- package/dist/events/responderEvent.js.map +1 -0
- package/dist/events/types.d.ts +33 -0
- package/dist/index.d.ts +66 -1597
- package/dist/index.js +42 -4864
- package/dist/reactNativeVersion.d.ts +7 -0
- package/dist/reactNativeVersion.js +10 -0
- package/dist/reactNativeVersion.js.map +1 -0
- package/dist/render/domProps.js +66 -0
- package/dist/render/domProps.js.map +1 -0
- package/dist/render/hitSlop.js +21 -0
- package/dist/render/hitSlop.js.map +1 -0
- package/dist/render/hostMethods.js +44 -0
- package/dist/render/hostMethods.js.map +1 -0
- package/dist/render/resolveTag.js +64 -0
- package/dist/render/resolveTag.js.map +1 -0
- package/dist/render/useElementLayout.js +25 -0
- package/dist/render/useElementLayout.js.map +1 -0
- package/dist/server/index.d.ts +2 -27
- package/dist/server/index.js +2 -2
- package/dist/{StyleRegistryContext-ROsMlY4O.js → style/StyleRegistryContext.js} +3 -3
- package/dist/style/StyleRegistryContext.js.map +1 -0
- package/dist/style/color.js +16 -0
- package/dist/style/color.js.map +1 -0
- package/dist/style/compile.js +72 -0
- package/dist/style/compile.js.map +1 -0
- package/dist/style/direction.js +33 -0
- package/dist/style/direction.js.map +1 -0
- package/dist/style/index.d.ts +1 -1
- package/dist/style/index.js +5 -2
- package/dist/style/index.js.map +1 -1
- package/dist/style/registry.d.ts +27 -0
- package/dist/{registry-Aa_Od5m0.js → style/registry.js} +3 -3
- package/dist/style/registry.js.map +1 -0
- package/dist/style/resolveStyle.js +181 -0
- package/dist/style/resolveStyle.js.map +1 -0
- package/dist/style/shadow.js +87 -0
- package/dist/style/shadow.js.map +1 -0
- package/dist/style/splitLayoutProps.js +52 -0
- package/dist/style/splitLayoutProps.js.map +1 -0
- package/dist/style/transform.js +35 -0
- package/dist/style/transform.js.map +1 -0
- package/dist/style/types.d.ts +4 -0
- package/dist/style/units.js +21 -0
- package/dist/style/units.js.map +1 -0
- package/dist/style/webStyle.js +9 -0
- package/dist/style/webStyle.js.map +1 -0
- package/dist/{env-DK5Mt9yX.js → utils/env.js} +2 -2
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/scrollLock.js +28 -0
- package/dist/utils/scrollLock.js.map +1 -0
- package/dist/utils/warn.js +11 -0
- package/dist/utils/warn.js.map +1 -0
- package/dist/vite/index.js +4 -202
- package/dist/vite/index.js.map +1 -1
- package/llms.txt +20 -0
- package/package.json +4 -3
- package/dist/StyleRegistryContext-ROsMlY4O.js.map +0 -1
- package/dist/compile-CVUjQrR9.js +0 -400
- package/dist/compile-CVUjQrR9.js.map +0 -1
- package/dist/dom/index.js.map +0 -1
- package/dist/env-DK5Mt9yX.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/registry-Aa_Od5m0.js.map +0 -1
- package/dist/types-BxTWbdj9.d.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactNativeVersion.js","names":[],"sources":["../src/reactNativeVersion.ts"],"sourcesContent":["export type ReactNativeVersion = {\n major: number\n minor: number\n patch: number\n prerelease: string | undefined\n}\n\n// The react-native release whose API this package matches. Update it with the pin.\nexport const reactNativeVersion: ReactNativeVersion = {\n major: 0,\n minor: 88,\n patch: 1,\n prerelease: undefined,\n}\n"],"mappings":";AAQA,MAAa,qBAAyC;CACpD,OAAO;CACP,OAAO;CACP,OAAO;CACP,YAAY,KAAA;AACd"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/render/domProps.ts
|
|
2
|
+
const liveRegionToAriaLive = {
|
|
3
|
+
none: "off",
|
|
4
|
+
polite: "polite",
|
|
5
|
+
assertive: "assertive"
|
|
6
|
+
};
|
|
7
|
+
const nativeHandler = /^on(Press|Layout|TextLayout|Accessibility|Magic|Responder|Refresh|.*ShouldSet)/;
|
|
8
|
+
const isNativeHandler = (name) => nativeHandler.test(name);
|
|
9
|
+
const passThrough = /* @__PURE__ */ new Set([
|
|
10
|
+
"lang",
|
|
11
|
+
"dir",
|
|
12
|
+
"target",
|
|
13
|
+
"rel",
|
|
14
|
+
"download"
|
|
15
|
+
]);
|
|
16
|
+
const domEventHandlers = /* @__PURE__ */ new Set([
|
|
17
|
+
..."abort animationEnd animationIteration animationStart auxClick beforeInput beforeToggle blur cancel canPlay canPlayThrough change click close compositionEnd compositionStart compositionUpdate contextMenu copy cut doubleClick drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error focus fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize scroll scrollEnd seeked seeking select stalled submit suspend timeUpdate toggle touchCancel touchEnd touchMove touchStart transitionCancel transitionEnd transitionRun transitionStart volumeChange waiting wheel".split(" ").flatMap((event) => {
|
|
18
|
+
const name = `on${event.charAt(0).toUpperCase()}${event.slice(1)}`;
|
|
19
|
+
return [name, `${name}Capture`];
|
|
20
|
+
}),
|
|
21
|
+
"onMouseEnter",
|
|
22
|
+
"onMouseLeave",
|
|
23
|
+
"onPointerEnter",
|
|
24
|
+
"onPointerLeave"
|
|
25
|
+
]);
|
|
26
|
+
const toDOMProps = (props) => {
|
|
27
|
+
const out = {};
|
|
28
|
+
for (const name in props) {
|
|
29
|
+
const value = props[name];
|
|
30
|
+
if (value === void 0) continue;
|
|
31
|
+
if (name.startsWith("aria-") || name.startsWith("data-") || passThrough.has(name) || domEventHandlers.has(name)) out[name] = value;
|
|
32
|
+
}
|
|
33
|
+
const { accessibilityLabel, accessibilityLabelledBy, accessibilityHint, accessibilityState, accessibilityValue, accessibilityLiveRegion, accessibilityElementsHidden, accessibilityViewIsModal, importantForAccessibility, id, nativeID, testID, tabIndex, focusable, href } = props;
|
|
34
|
+
if (accessibilityLabel !== void 0) out["aria-label"] ??= accessibilityLabel;
|
|
35
|
+
if (accessibilityLabelledBy !== void 0) out["aria-labelledby"] ??= Array.isArray(accessibilityLabelledBy) ? accessibilityLabelledBy.join(" ") : accessibilityLabelledBy;
|
|
36
|
+
if (accessibilityHint !== void 0) out["aria-description"] ??= accessibilityHint;
|
|
37
|
+
if (accessibilityLiveRegion !== void 0) out["aria-live"] ??= liveRegionToAriaLive[accessibilityLiveRegion];
|
|
38
|
+
if (accessibilityViewIsModal !== void 0) out["aria-modal"] ??= accessibilityViewIsModal;
|
|
39
|
+
if (accessibilityElementsHidden === true || importantForAccessibility === "no-hide-descendants") out["aria-hidden"] ??= true;
|
|
40
|
+
if (accessibilityState !== void 0) {
|
|
41
|
+
const { busy, checked, disabled, expanded, selected } = accessibilityState;
|
|
42
|
+
if (busy !== void 0) out["aria-busy"] ??= busy;
|
|
43
|
+
if (checked !== void 0) out["aria-checked"] ??= checked;
|
|
44
|
+
if (disabled !== void 0) out["aria-disabled"] ??= disabled;
|
|
45
|
+
if (expanded !== void 0) out["aria-expanded"] ??= expanded;
|
|
46
|
+
if (selected !== void 0) out["aria-selected"] ??= selected;
|
|
47
|
+
}
|
|
48
|
+
if (accessibilityValue !== void 0) {
|
|
49
|
+
const { max, min, now, text } = accessibilityValue;
|
|
50
|
+
if (max !== void 0) out["aria-valuemax"] ??= max;
|
|
51
|
+
if (min !== void 0) out["aria-valuemin"] ??= min;
|
|
52
|
+
if (now !== void 0) out["aria-valuenow"] ??= now;
|
|
53
|
+
if (text !== void 0) out["aria-valuetext"] ??= text;
|
|
54
|
+
}
|
|
55
|
+
const domId = id ?? nativeID;
|
|
56
|
+
if (domId !== void 0) out["id"] = domId;
|
|
57
|
+
if (testID !== void 0) out["data-testid"] = testID;
|
|
58
|
+
if (href !== void 0) out["href"] = href;
|
|
59
|
+
if (tabIndex !== void 0) out["tabIndex"] = tabIndex;
|
|
60
|
+
else if (focusable === true) out["tabIndex"] = 0;
|
|
61
|
+
else if (focusable === false) out["tabIndex"] = -1;
|
|
62
|
+
return out;
|
|
63
|
+
};
|
|
64
|
+
export { domEventHandlers, isNativeHandler, toDOMProps };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=domProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domProps.js","names":[],"sources":["../../src/render/domProps.ts"],"sourcesContent":["import type { AccessibilityProps } from '../components/View/types'\n\nexport type DOMProps = Record<string, unknown>\n\ntype Input = AccessibilityProps & Record<string, unknown>\n\nconst liveRegionToAriaLive: Record<string, string> = {\n none: 'off',\n polite: 'polite',\n assertive: 'assertive',\n}\n\n// React Native handlers that are not DOM events. A component maps them itself.\nconst nativeHandler =\n /^on(Press|Layout|TextLayout|Accessibility|Magic|Responder|Refresh|.*ShouldSet)/\n\nexport const isNativeHandler = (name: string): boolean => nativeHandler.test(name)\n\nconst passThrough = new Set(['lang', 'dir', 'target', 'rel', 'download'])\n\n// The events that React DOM 19 registers. Each has a handler prop and its `Capture` form. A\n// library can spread its own callback, such as `onValueChange`, onto a View: React Native and\n// react-native-web drop it, and React DOM logs an error for an `on*` prop that it doesn't know.\nconst reactDOMEvents =\n 'abort animationEnd animationIteration animationStart auxClick beforeInput beforeToggle blur ' +\n 'cancel canPlay canPlayThrough change click close compositionEnd compositionStart ' +\n 'compositionUpdate contextMenu copy cut doubleClick drag dragEnd dragEnter dragExit dragLeave ' +\n 'dragOver dragStart drop durationChange emptied encrypted ended error focus fullscreenChange ' +\n 'fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData ' +\n 'loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp ' +\n 'paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver ' +\n 'pointerUp progress rateChange reset resize scroll scrollEnd seeked seeking select stalled ' +\n 'submit suspend timeUpdate toggle touchCancel touchEnd touchMove touchStart transitionCancel ' +\n 'transitionEnd transitionRun transitionStart volumeChange waiting wheel'\n\nexport const domEventHandlers: ReadonlySet<string> = new Set([\n ...reactDOMEvents.split(' ').flatMap((event) => {\n const name = `on${event.charAt(0).toUpperCase()}${event.slice(1)}`\n return [name, `${name}Capture`]\n }),\n // These four have no capture phase.\n 'onMouseEnter',\n 'onMouseLeave',\n 'onPointerEnter',\n 'onPointerLeave',\n])\n\n// Maps React Native props to DOM attributes. Unknown props are dropped, so they never\n// reach the element. `aria-*` and `data-*` props, and the event handlers of React DOM, pass\n// through as they are.\nexport const toDOMProps = (props: Input): DOMProps => {\n const out: DOMProps = {}\n\n for (const name in props) {\n const value = props[name]\n if (value === undefined) continue\n if (\n name.startsWith('aria-') ||\n name.startsWith('data-') ||\n passThrough.has(name) ||\n domEventHandlers.has(name)\n ) {\n out[name] = value\n }\n }\n\n const {\n accessibilityLabel,\n accessibilityLabelledBy,\n accessibilityHint,\n accessibilityState,\n accessibilityValue,\n accessibilityLiveRegion,\n accessibilityElementsHidden,\n accessibilityViewIsModal,\n importantForAccessibility,\n id,\n nativeID,\n testID,\n tabIndex,\n focusable,\n href,\n } = props\n\n if (accessibilityLabel !== undefined) out['aria-label'] ??= accessibilityLabel\n if (accessibilityLabelledBy !== undefined) {\n out['aria-labelledby'] ??= Array.isArray(accessibilityLabelledBy)\n ? accessibilityLabelledBy.join(' ')\n : accessibilityLabelledBy\n }\n if (accessibilityHint !== undefined) out['aria-description'] ??= accessibilityHint\n if (accessibilityLiveRegion !== undefined) {\n out['aria-live'] ??= liveRegionToAriaLive[accessibilityLiveRegion]\n }\n if (accessibilityViewIsModal !== undefined) out['aria-modal'] ??= accessibilityViewIsModal\n if (accessibilityElementsHidden === true || importantForAccessibility === 'no-hide-descendants') {\n out['aria-hidden'] ??= true\n }\n\n if (accessibilityState !== undefined) {\n const { busy, checked, disabled, expanded, selected } = accessibilityState\n if (busy !== undefined) out['aria-busy'] ??= busy\n if (checked !== undefined) out['aria-checked'] ??= checked\n if (disabled !== undefined) out['aria-disabled'] ??= disabled\n if (expanded !== undefined) out['aria-expanded'] ??= expanded\n if (selected !== undefined) out['aria-selected'] ??= selected\n }\n\n if (accessibilityValue !== undefined) {\n const { max, min, now, text } = accessibilityValue\n if (max !== undefined) out['aria-valuemax'] ??= max\n if (min !== undefined) out['aria-valuemin'] ??= min\n if (now !== undefined) out['aria-valuenow'] ??= now\n if (text !== undefined) out['aria-valuetext'] ??= text\n }\n\n const domId = id ?? nativeID\n if (domId !== undefined) out['id'] = domId\n if (testID !== undefined) out['data-testid'] = testID\n if (href !== undefined) out['href'] = href\n\n if (tabIndex !== undefined) out['tabIndex'] = tabIndex\n else if (focusable === true) out['tabIndex'] = 0\n else if (focusable === false) out['tabIndex'] = -1\n\n return out\n}\n"],"mappings":";AAMA,MAAM,uBAA+C;CACnD,MAAM;CACN,QAAQ;CACR,WAAW;AACb;AAGA,MAAM,gBACJ;AAEF,MAAa,mBAAmB,SAA0B,cAAc,KAAK,IAAI;AAEjF,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAQ;CAAO;CAAU;CAAO;AAAU,CAAC;AAiBxE,MAAa,mCAAwC,IAAI,IAAI;CAC3D,GAAG,62BAAe,MAAM,GAAG,CAAC,CAAC,SAAS,UAAU;EAC9C,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;EAC/D,OAAO,CAAC,MAAM,GAAG,KAAK,QAAQ;CAChC,CAAC;CAED;CACA;CACA;CACA;AACF,CAAC;AAKD,MAAa,cAAc,UAA2B;CACpD,MAAM,MAAgB,CAAC;CAEvB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,MAAM;EACpB,IAAI,UAAU,KAAA,GAAW;EACzB,IACE,KAAK,WAAW,OAAO,KACvB,KAAK,WAAW,OAAO,KACvB,YAAY,IAAI,IAAI,KACpB,iBAAiB,IAAI,IAAI,GAEzB,IAAI,QAAQ;CAEhB;CAEA,MAAM,EACJ,oBACA,yBACA,mBACA,oBACA,oBACA,yBACA,6BACA,0BACA,2BACA,IACA,UACA,QACA,UACA,WACA,SACE;CAEJ,IAAI,uBAAuB,KAAA,GAAW,IAAI,kBAAkB;CAC5D,IAAI,4BAA4B,KAAA,GAC9B,IAAI,uBAAuB,MAAM,QAAQ,uBAAuB,IAC5D,wBAAwB,KAAK,GAAG,IAChC;CAEN,IAAI,sBAAsB,KAAA,GAAW,IAAI,wBAAwB;CACjE,IAAI,4BAA4B,KAAA,GAC9B,IAAI,iBAAiB,qBAAqB;CAE5C,IAAI,6BAA6B,KAAA,GAAW,IAAI,kBAAkB;CAClE,IAAI,gCAAgC,QAAQ,8BAA8B,uBACxE,IAAI,mBAAmB;CAGzB,IAAI,uBAAuB,KAAA,GAAW;EACpC,MAAM,EAAE,MAAM,SAAS,UAAU,UAAU,aAAa;EACxD,IAAI,SAAS,KAAA,GAAW,IAAI,iBAAiB;EAC7C,IAAI,YAAY,KAAA,GAAW,IAAI,oBAAoB;EACnD,IAAI,aAAa,KAAA,GAAW,IAAI,qBAAqB;EACrD,IAAI,aAAa,KAAA,GAAW,IAAI,qBAAqB;EACrD,IAAI,aAAa,KAAA,GAAW,IAAI,qBAAqB;CACvD;CAEA,IAAI,uBAAuB,KAAA,GAAW;EACpC,MAAM,EAAE,KAAK,KAAK,KAAK,SAAS;EAChC,IAAI,QAAQ,KAAA,GAAW,IAAI,qBAAqB;EAChD,IAAI,QAAQ,KAAA,GAAW,IAAI,qBAAqB;EAChD,IAAI,QAAQ,KAAA,GAAW,IAAI,qBAAqB;EAChD,IAAI,SAAS,KAAA,GAAW,IAAI,sBAAsB;CACpD;CAEA,MAAM,QAAQ,MAAM;CACpB,IAAI,UAAU,KAAA,GAAW,IAAI,QAAQ;CACrC,IAAI,WAAW,KAAA,GAAW,IAAI,iBAAiB;CAC/C,IAAI,SAAS,KAAA,GAAW,IAAI,UAAU;CAEtC,IAAI,aAAa,KAAA,GAAW,IAAI,cAAc;MACzC,IAAI,cAAc,MAAM,IAAI,cAAc;MAC1C,IAAI,cAAc,OAAO,IAAI,cAAc;CAEhD,OAAO;AACT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/render/hitSlop.ts
|
|
2
|
+
const hitSlopClass = (registry, hitSlop) => {
|
|
3
|
+
if (hitSlop === void 0) return void 0;
|
|
4
|
+
const { top = 0, right = 0, bottom = 0, left = 0 } = typeof hitSlop === "number" ? {
|
|
5
|
+
top: hitSlop,
|
|
6
|
+
right: hitSlop,
|
|
7
|
+
bottom: hitSlop,
|
|
8
|
+
left: hitSlop
|
|
9
|
+
} : hitSlop;
|
|
10
|
+
if (top === 0 && right === 0 && bottom === 0 && left === 0) return void 0;
|
|
11
|
+
const name = `rn-hs-${[
|
|
12
|
+
top,
|
|
13
|
+
right,
|
|
14
|
+
bottom,
|
|
15
|
+
left
|
|
16
|
+
].map((n) => String(n).replace(/[^0-9]/g, "_")).join("-")}`;
|
|
17
|
+
return registry.staticClass(name, [`.${name}::before{content:"";position:absolute;top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`]);
|
|
18
|
+
};
|
|
19
|
+
export { hitSlopClass };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=hitSlop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitSlop.js","names":[],"sources":["../../src/render/hitSlop.ts"],"sourcesContent":["import type { RectOrSize } from '../events/press/types'\nimport type { StyleRegistry } from '../style/registry'\n\n// The browser hit-tests a pseudo-element as part of its element, so an invisible ::before\n// box around the element grows its hit area. z-index -1 keeps it under the children, so it\n// never takes a press from them.\nexport const hitSlopClass = (\n registry: StyleRegistry,\n hitSlop: RectOrSize | undefined,\n): string | undefined => {\n if (hitSlop === undefined) return undefined\n const rect =\n typeof hitSlop === 'number'\n ? { top: hitSlop, right: hitSlop, bottom: hitSlop, left: hitSlop }\n : hitSlop\n const { top = 0, right = 0, bottom = 0, left = 0 } = rect\n if (top === 0 && right === 0 && bottom === 0 && left === 0) return undefined\n\n const name = `rn-hs-${[top, right, bottom, left].map((n) => String(n).replace(/[^0-9]/g, '_')).join('-')}`\n return registry.staticClass(name, [\n `.${name}::before{content:\"\";position:absolute;` +\n `top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`,\n ])\n}\n"],"mappings":";AAMA,MAAa,gBACX,UACA,YACuB;CACvB,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAKlC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,MAH7C,OAAO,YAAY,WACf;EAAE,KAAK;EAAS,OAAO;EAAS,QAAQ;EAAS,MAAM;CAAQ,IAC/D;CAEN,IAAI,QAAQ,KAAK,UAAU,KAAK,WAAW,KAAK,SAAS,GAAG,OAAO,KAAA;CAEnE,MAAM,OAAO,SAAS;EAAC;EAAK;EAAO;EAAQ;CAAI,CAAC,CAAC,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,QAAQ,WAAW,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;CACvG,OAAO,SAAS,YAAY,MAAM,CAChC,IAAI,KAAK,4CACA,CAAC,IAAI,WAAW,CAAC,MAAM,YAAY,CAAC,OAAO,UAAU,CAAC,KAAK,eACtE,CAAC;AACH"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { flattenStyle } from "../style/compile.js";
|
|
2
|
+
import { resolveStyle } from "../style/resolveStyle.js";
|
|
3
|
+
import { warnOnce } from "../utils/warn.js";
|
|
4
|
+
// src/render/hostMethods.ts
|
|
5
|
+
const applyNativeProps = (element, nativeProps) => {
|
|
6
|
+
const inline = element.style;
|
|
7
|
+
for (const [name, value] of Object.entries(nativeProps)) {
|
|
8
|
+
if (name !== "style") {
|
|
9
|
+
warnOnce(`set-native-props-${name}`, `setNativeProps: only \`style\` works on the web. \`${name}\` has no effect.`);
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const flat = flattenStyle(value);
|
|
13
|
+
if (flat !== void 0) Object.assign(inline, resolveStyle(flat));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const hostMethods = (element) => ({
|
|
17
|
+
measure: (callback) => {
|
|
18
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
19
|
+
const parent = element.parentElement?.getBoundingClientRect();
|
|
20
|
+
callback(left - (parent?.left ?? 0), top - (parent?.top ?? 0), width, height, left, top);
|
|
21
|
+
},
|
|
22
|
+
measureInWindow: (callback) => {
|
|
23
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
24
|
+
callback(left, top, width, height);
|
|
25
|
+
},
|
|
26
|
+
measureLayout: (relativeToNativeNode, onSuccess, onFail) => {
|
|
27
|
+
if (!(relativeToNativeNode instanceof Element) || !element.isConnected || !relativeToNativeNode.contains(element)) {
|
|
28
|
+
onFail?.();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
32
|
+
const ancestor = relativeToNativeNode.getBoundingClientRect();
|
|
33
|
+
onSuccess(left - ancestor.left, top - ancestor.top, width, height);
|
|
34
|
+
},
|
|
35
|
+
setNativeProps: (nativeProps) => applyNativeProps(element, nativeProps)
|
|
36
|
+
});
|
|
37
|
+
const withHostMethods = (element) => {
|
|
38
|
+
const instance = element;
|
|
39
|
+
if (instance.measureInWindow === void 0) Object.assign(instance, hostMethods(element));
|
|
40
|
+
return instance;
|
|
41
|
+
};
|
|
42
|
+
export { applyNativeProps, withHostMethods };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=hostMethods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostMethods.js","names":[],"sources":["../../src/render/hostMethods.ts"],"sourcesContent":["import type { HostInstance, HostMethods } from '../components/View/types'\nimport { flattenStyle } from '../style/compile'\nimport { resolveStyle } from '../style/resolveStyle'\nimport type { FlatStyle, StyleProp } from '../style/types'\nimport { warnOnce } from '../utils/warn'\n\n// Writes the `style` of `setNativeProps` as an inline style, so it stays until the next call, as\n// on native. Any other prop has no direct path to the element.\nexport const applyNativeProps = (element: HTMLElement, nativeProps: object): void => {\n const inline = element.style as unknown as Record<string, string>\n for (const [name, value] of Object.entries(nativeProps)) {\n if (name !== 'style') {\n warnOnce(\n `set-native-props-${name}`,\n `setNativeProps: only \\`style\\` works on the web. \\`${name}\\` has no effect.`,\n )\n continue\n }\n const flat = flattenStyle(value as StyleProp<FlatStyle>)\n if (flat !== undefined) Object.assign(inline, resolveStyle(flat))\n }\n}\n\nconst hostMethods = (element: HTMLElement): HostMethods => ({\n measure: (callback) => {\n const { left, top, width, height } = element.getBoundingClientRect()\n const parent = element.parentElement?.getBoundingClientRect()\n callback(left - (parent?.left ?? 0), top - (parent?.top ?? 0), width, height, left, top)\n },\n measureInWindow: (callback) => {\n const { left, top, width, height } = element.getBoundingClientRect()\n callback(left, top, width, height)\n },\n measureLayout: (relativeToNativeNode, onSuccess, onFail) => {\n // As on native, the other node must be an ancestor that is on screen.\n if (\n !(relativeToNativeNode instanceof Element) ||\n !element.isConnected ||\n !relativeToNativeNode.contains(element)\n ) {\n onFail?.()\n return\n }\n const { left, top, width, height } = element.getBoundingClientRect()\n const ancestor = relativeToNativeNode.getBoundingClientRect()\n onSuccess(left - ancestor.left, top - ancestor.top, width, height)\n },\n setNativeProps: (nativeProps) => applyNativeProps(element, nativeProps),\n})\n\n// Adds the methods of a React Native host instance to the element, once.\nexport const withHostMethods = <T extends HTMLElement>(element: T): T & HostMethods => {\n const instance = element as T & Partial<HostInstance>\n if (instance.measureInWindow === undefined) Object.assign(instance, hostMethods(element))\n return instance as T & HostMethods\n}\n"],"mappings":";;;;AAQA,MAAa,oBAAoB,SAAsB,gBAA8B;CACnF,MAAM,SAAS,QAAQ;CACvB,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,WAAW,GAAG;EACvD,IAAI,SAAS,SAAS;GACpB,SACE,oBAAoB,QACpB,sDAAsD,KAAK,kBAC7D;GACA;EACF;EACA,MAAM,OAAO,aAAa,KAA6B;EACvD,IAAI,SAAS,KAAA,GAAW,OAAO,OAAO,QAAQ,aAAa,IAAI,CAAC;CAClE;AACF;AAEA,MAAM,eAAe,aAAuC;CAC1D,UAAU,aAAa;EACrB,MAAM,EAAE,MAAM,KAAK,OAAO,WAAW,QAAQ,sBAAsB;EACnE,MAAM,SAAS,QAAQ,eAAe,sBAAsB;EAC5D,SAAS,QAAQ,QAAQ,QAAQ,IAAI,OAAO,QAAQ,OAAO,IAAI,OAAO,QAAQ,MAAM,GAAG;CACzF;CACA,kBAAkB,aAAa;EAC7B,MAAM,EAAE,MAAM,KAAK,OAAO,WAAW,QAAQ,sBAAsB;EACnE,SAAS,MAAM,KAAK,OAAO,MAAM;CACnC;CACA,gBAAgB,sBAAsB,WAAW,WAAW;EAE1D,IACE,EAAE,gCAAgC,YAClC,CAAC,QAAQ,eACT,CAAC,qBAAqB,SAAS,OAAO,GACtC;GACA,SAAS;GACT;EACF;EACA,MAAM,EAAE,MAAM,KAAK,OAAO,WAAW,QAAQ,sBAAsB;EACnE,MAAM,WAAW,qBAAqB,sBAAsB;EAC5D,UAAU,OAAO,SAAS,MAAM,MAAM,SAAS,KAAK,OAAO,MAAM;CACnE;CACA,iBAAiB,gBAAgB,iBAAiB,SAAS,WAAW;AACxE;AAGA,MAAa,mBAA0C,YAAgC;CACrF,MAAM,WAAW;CACjB,IAAI,SAAS,oBAAoB,KAAA,GAAW,OAAO,OAAO,UAAU,YAAY,OAAO,CAAC;CACxF,OAAO;AACT"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/render/resolveTag.ts
|
|
2
|
+
const legacyRoleToRole = {
|
|
3
|
+
header: "heading",
|
|
4
|
+
image: "img",
|
|
5
|
+
imagebutton: "button",
|
|
6
|
+
summary: "region",
|
|
7
|
+
text: "none",
|
|
8
|
+
adjustable: "slider",
|
|
9
|
+
search: "searchbox",
|
|
10
|
+
keyboardkey: "none"
|
|
11
|
+
};
|
|
12
|
+
const roleToTag = {
|
|
13
|
+
article: "article",
|
|
14
|
+
banner: "header",
|
|
15
|
+
button: "button",
|
|
16
|
+
complementary: "aside",
|
|
17
|
+
contentinfo: "footer",
|
|
18
|
+
figure: "figure",
|
|
19
|
+
form: "form",
|
|
20
|
+
list: "ul",
|
|
21
|
+
listitem: "li",
|
|
22
|
+
main: "main",
|
|
23
|
+
navigation: "nav",
|
|
24
|
+
separator: "hr"
|
|
25
|
+
};
|
|
26
|
+
const headingLevel = (level) => level !== void 0 && Number.isInteger(level) && level >= 1 && level <= 6 ? level : 2;
|
|
27
|
+
const voidTags = /* @__PURE__ */ new Set(["hr"]);
|
|
28
|
+
const resolveTag = (props, defaultTag, hasChildren = false) => {
|
|
29
|
+
const role = props.role ?? mapLegacyRole(props.accessibilityRole);
|
|
30
|
+
const resolved = tagForRole(role, props, defaultTag);
|
|
31
|
+
return hasChildren && voidTags.has(resolved.tag) ? {
|
|
32
|
+
tag: defaultTag,
|
|
33
|
+
role
|
|
34
|
+
} : resolved;
|
|
35
|
+
};
|
|
36
|
+
const tagForRole = (role, props, defaultTag) => {
|
|
37
|
+
if (role === "heading") return {
|
|
38
|
+
tag: `h${headingLevel(props["aria-level"])}`,
|
|
39
|
+
role: void 0
|
|
40
|
+
};
|
|
41
|
+
if (role === "link") return props.href === void 0 ? {
|
|
42
|
+
tag: defaultTag,
|
|
43
|
+
role: "link"
|
|
44
|
+
} : {
|
|
45
|
+
tag: "a",
|
|
46
|
+
role: void 0
|
|
47
|
+
};
|
|
48
|
+
if (role === void 0) return {
|
|
49
|
+
tag: props.href === void 0 ? defaultTag : "a",
|
|
50
|
+
role: void 0
|
|
51
|
+
};
|
|
52
|
+
const tag = roleToTag[role];
|
|
53
|
+
return tag === void 0 ? {
|
|
54
|
+
tag: defaultTag,
|
|
55
|
+
role
|
|
56
|
+
} : {
|
|
57
|
+
tag,
|
|
58
|
+
role: void 0
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const mapLegacyRole = (legacy) => legacy === void 0 ? void 0 : legacyRoleToRole[legacy] ?? legacy;
|
|
62
|
+
export { resolveTag };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=resolveTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveTag.js","names":[],"sources":["../../src/render/resolveTag.ts"],"sourcesContent":["export type ResolveTagInput = {\n role?: string | undefined\n accessibilityRole?: string | undefined\n 'aria-level'?: number | undefined\n href?: string | undefined\n}\n\nexport type ResolvedTag = {\n tag: string\n role: string | undefined\n}\n\n// Legacy accessibilityRole values that have an ARIA role with another name.\nconst legacyRoleToRole: Record<string, string> = {\n header: 'heading',\n image: 'img',\n imagebutton: 'button',\n summary: 'region',\n text: 'none',\n adjustable: 'slider',\n search: 'searchbox',\n keyboardkey: 'none',\n}\n\n// Roles whose HTML element carries the role on its own.\n//\n// The table roles are not here. The HTML parser moves any child of a <table> that is not a\n// row group out of the table, and wraps a bare <tr> in a <tbody>. Server-rendered markup\n// then does not match the React tree, and the flex reset breaks table layout. A div with\n// the ARIA table roles has the same semantics.\nconst roleToTag: Record<string, string> = {\n article: 'article',\n banner: 'header',\n button: 'button',\n complementary: 'aside',\n contentinfo: 'footer',\n figure: 'figure',\n form: 'form',\n list: 'ul',\n listitem: 'li',\n main: 'main',\n navigation: 'nav',\n separator: 'hr',\n}\n\nconst headingLevel = (level: number | undefined): number =>\n level !== undefined && Number.isInteger(level) && level >= 1 && level <= 6 ? level : 2\n\n// Elements that take no children. React throws when one gets children.\nconst voidTags = new Set(['hr'])\n\n// `hasChildren` matches React's check for a void element: children that are not null.\nexport const resolveTag = (\n props: ResolveTagInput,\n defaultTag: string,\n hasChildren = false,\n): ResolvedTag => {\n const role = props.role ?? mapLegacyRole(props.accessibilityRole)\n const resolved = tagForRole(role, props, defaultTag)\n return hasChildren && voidTags.has(resolved.tag) ? { tag: defaultTag, role } : resolved\n}\n\nconst tagForRole = (\n role: string | undefined,\n props: ResolveTagInput,\n defaultTag: string,\n): ResolvedTag => {\n if (role === 'heading') {\n return { tag: `h${headingLevel(props['aria-level'])}`, role: undefined }\n }\n\n if (role === 'link') {\n return props.href === undefined\n ? { tag: defaultTag, role: 'link' }\n : { tag: 'a', role: undefined }\n }\n\n if (role === undefined) {\n return { tag: props.href === undefined ? defaultTag : 'a', role: undefined }\n }\n\n const tag = roleToTag[role]\n return tag === undefined ? { tag: defaultTag, role } : { tag, role: undefined }\n}\n\nconst mapLegacyRole = (legacy: string | undefined): string | undefined =>\n legacy === undefined ? undefined : (legacyRoleToRole[legacy] ?? legacy)\n"],"mappings":";AAaA,MAAM,mBAA2C;CAC/C,QAAQ;CACR,OAAO;CACP,aAAa;CACb,SAAS;CACT,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,aAAa;AACf;AAQA,MAAM,YAAoC;CACxC,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,aAAa;CACb,QAAQ;CACR,MAAM;CACN,MAAM;CACN,UAAU;CACV,MAAM;CACN,YAAY;CACZ,WAAW;AACb;AAEA,MAAM,gBAAgB,UACpB,UAAU,KAAA,KAAa,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS,IAAI,QAAQ;AAGvF,MAAM,2BAAW,IAAI,IAAI,CAAC,IAAI,CAAC;AAG/B,MAAa,cACX,OACA,YACA,cAAc,UACE;CAChB,MAAM,OAAO,MAAM,QAAQ,cAAc,MAAM,iBAAiB;CAChE,MAAM,WAAW,WAAW,MAAM,OAAO,UAAU;CACnD,OAAO,eAAe,SAAS,IAAI,SAAS,GAAG,IAAI;EAAE,KAAK;EAAY;CAAK,IAAI;AACjF;AAEA,MAAM,cACJ,MACA,OACA,eACgB;CAChB,IAAI,SAAS,WACX,OAAO;EAAE,KAAK,IAAI,aAAa,MAAM,aAAa;EAAK,MAAM,KAAA;CAAU;CAGzE,IAAI,SAAS,QACX,OAAO,MAAM,SAAS,KAAA,IAClB;EAAE,KAAK;EAAY,MAAM;CAAO,IAChC;EAAE,KAAK;EAAK,MAAM,KAAA;CAAU;CAGlC,IAAI,SAAS,KAAA,GACX,OAAO;EAAE,KAAK,MAAM,SAAS,KAAA,IAAY,aAAa;EAAK,MAAM,KAAA;CAAU;CAG7E,MAAM,MAAM,UAAU;CACtB,OAAO,QAAQ,KAAA,IAAY;EAAE,KAAK;EAAY;CAAK,IAAI;EAAE;EAAK,MAAM,KAAA;CAAU;AAChF;AAEA,MAAM,iBAAiB,WACrB,WAAW,KAAA,IAAY,KAAA,IAAa,iBAAiB,WAAW"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
// src/render/useElementLayout.ts
|
|
3
|
+
const measure = (element) => ({ nativeEvent: { layout: {
|
|
4
|
+
x: element.offsetLeft,
|
|
5
|
+
y: element.offsetTop,
|
|
6
|
+
width: element.offsetWidth,
|
|
7
|
+
height: element.offsetHeight
|
|
8
|
+
} } });
|
|
9
|
+
const useElementLayout = (ref, onLayout) => {
|
|
10
|
+
const latest = useRef(onLayout);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
latest.current = onLayout;
|
|
13
|
+
}, [onLayout]);
|
|
14
|
+
const enabled = onLayout !== void 0;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const element = ref.current;
|
|
17
|
+
if (element === null || !enabled) return;
|
|
18
|
+
const observer = new ResizeObserver(() => latest.current?.(measure(element)));
|
|
19
|
+
observer.observe(element);
|
|
20
|
+
return () => observer.disconnect();
|
|
21
|
+
}, [ref, enabled]);
|
|
22
|
+
};
|
|
23
|
+
export { useElementLayout };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=useElementLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementLayout.js","names":[],"sources":["../../src/render/useElementLayout.ts"],"sourcesContent":["import { useEffect, useRef, type RefObject } from 'react'\n\nimport type { LayoutChangeEvent } from '../components/View/types'\n\nconst measure = (element: HTMLElement): LayoutChangeEvent => ({\n nativeEvent: {\n layout: {\n x: element.offsetLeft,\n y: element.offsetTop,\n width: element.offsetWidth,\n height: element.offsetHeight,\n },\n },\n})\n\n// Calls onLayout after mount and after each size change, as native does.\nexport const useElementLayout = (\n ref: RefObject<HTMLElement | null>,\n onLayout: ((event: LayoutChangeEvent) => void) | undefined,\n): void => {\n const latest = useRef(onLayout)\n useEffect(() => {\n latest.current = onLayout\n }, [onLayout])\n\n const enabled = onLayout !== undefined\n useEffect(() => {\n const element = ref.current\n if (element === null || !enabled) return\n\n const observer = new ResizeObserver(() => latest.current?.(measure(element)))\n observer.observe(element)\n return () => observer.disconnect()\n }, [ref, enabled])\n}\n"],"mappings":";;AAIA,MAAM,WAAW,aAA6C,EAC5D,aAAa,EACX,QAAQ;CACN,GAAG,QAAQ;CACX,GAAG,QAAQ;CACX,OAAO,QAAQ;CACf,QAAQ,QAAQ;AAClB,EACF,EACF;AAGA,MAAa,oBACX,KACA,aACS;CACT,MAAM,SAAS,OAAO,QAAQ;CAC9B,gBAAgB;EACd,OAAO,UAAU;CACnB,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,UAAU,aAAa,KAAA;CAC7B,gBAAgB;EACd,MAAM,UAAU,IAAI;EACpB,IAAI,YAAY,QAAQ,CAAC,SAAS;EAElC,MAAM,WAAW,IAAI,qBAAqB,OAAO,UAAU,QAAQ,OAAO,CAAC,CAAC;EAC5E,SAAS,QAAQ,OAAO;EACxB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,KAAK,OAAO,CAAC;AACnB"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyleRegistry } from "../style/registry.js";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
type StyleSheets = {
|
|
4
|
-
reset: CSSStyleSheet | null;
|
|
5
|
-
shorthand: CSSStyleSheet | null;
|
|
6
|
-
longhand: CSSStyleSheet | null;
|
|
7
|
-
};
|
|
8
|
-
export declare class StyleRegistry {
|
|
9
|
-
private readonly classNames;
|
|
10
|
-
private readonly adopted;
|
|
11
|
-
private readonly resetRules;
|
|
12
|
-
private readonly shorthandRules;
|
|
13
|
-
private readonly longhandRules;
|
|
14
|
-
private readonly sheets;
|
|
15
|
-
constructor(sheets?: StyleSheets);
|
|
16
|
-
classFor(property: string, value: string): string;
|
|
17
|
-
classesFor(declarations: CSSDeclarations): string;
|
|
18
|
-
staticClass(className: string, rules: ReadonlyArray<string>): string;
|
|
19
|
-
resetClass(className: string, declarations: CSSDeclarations): string;
|
|
20
|
-
cssText(): {
|
|
21
|
-
reset: string;
|
|
22
|
-
shorthand: string;
|
|
23
|
-
longhand: string;
|
|
24
|
-
};
|
|
25
|
-
get ruleCount(): number;
|
|
26
|
-
private adopt;
|
|
27
|
-
}
|
|
28
3
|
export declare const createStyleRegistry: () => StyleRegistry;
|
|
29
4
|
export declare function StyleRegistryProvider(props: {
|
|
30
5
|
registry: StyleRegistry;
|
|
@@ -32,5 +7,5 @@ export declare function StyleRegistryProvider(props: {
|
|
|
32
7
|
}): ReactElement;
|
|
33
8
|
export declare const renderStyleTags: (registry: StyleRegistry) => ReactElement;
|
|
34
9
|
export declare const styleTagsHTML: (registry: StyleRegistry) => string;
|
|
35
|
-
export {};
|
|
10
|
+
export { StyleRegistry };
|
|
36
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { LONGHAND_STYLE_ID, RESET_STYLE_ID, SHORTHAND_STYLE_ID, StyleRegistry } from "../style/registry.js";
|
|
2
|
+
import { StyleRegistryContext } from "../style/StyleRegistryContext.js";
|
|
3
3
|
import { Fragment, createElement } from "react";
|
|
4
4
|
// src/server/index.ts
|
|
5
5
|
const createStyleRegistry = () => new StyleRegistry();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStyleRegistry } from "./registry.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
// src/style/StyleRegistryContext.ts
|
|
4
4
|
const StyleRegistryContext = createContext(null);
|
|
5
5
|
const useStyleRegistry = () => useContext(StyleRegistryContext) ?? getStyleRegistry();
|
|
6
|
-
export {
|
|
6
|
+
export { StyleRegistryContext, useStyleRegistry };
|
|
7
7
|
|
|
8
|
-
//# sourceMappingURL=StyleRegistryContext
|
|
8
|
+
//# sourceMappingURL=StyleRegistryContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyleRegistryContext.js","names":[],"sources":["../../src/style/StyleRegistryContext.ts"],"sourcesContent":["import { createContext, useContext, type Context } from 'react'\n\nimport { getStyleRegistry, type StyleRegistry } from './registry'\n\nexport const StyleRegistryContext: Context<StyleRegistry | null> =\n createContext<StyleRegistry | null>(null)\n\nexport const useStyleRegistry = (): StyleRegistry =>\n useContext(StyleRegistryContext) ?? getStyleRegistry()\n"],"mappings":";;;AAIA,MAAa,uBACX,cAAoC,IAAI;AAE1C,MAAa,yBACX,WAAW,oBAAoB,KAAK,iBAAiB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import normalizeColor from "@react-native/normalize-colors";
|
|
2
|
+
// src/style/color.ts
|
|
3
|
+
const toCSSColor = (value) => {
|
|
4
|
+
if (typeof value !== "string" && typeof value !== "number") return void 0;
|
|
5
|
+
const packed = normalizeColor(value);
|
|
6
|
+
if (packed === null || packed === void 0) return void 0;
|
|
7
|
+
const r = packed >>> 24 & 255;
|
|
8
|
+
const g = packed >>> 16 & 255;
|
|
9
|
+
const b = packed >>> 8 & 255;
|
|
10
|
+
const a = (packed & 255) / 255;
|
|
11
|
+
return a === 1 ? `rgb(${r},${g},${b})` : `rgba(${r},${g},${b},${round(a)})`;
|
|
12
|
+
};
|
|
13
|
+
const round = (n) => Math.round(n * 1e3) / 1e3;
|
|
14
|
+
export { toCSSColor };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","names":[],"sources":["../../src/style/color.ts"],"sourcesContent":["import normalizeColor from '@react-native/normalize-colors'\n\nexport const toCSSColor = (value: unknown): string | undefined => {\n if (typeof value !== 'string' && typeof value !== 'number') return undefined\n const packed = normalizeColor(value)\n if (packed === null || packed === undefined) return undefined\n\n const r = (packed >>> 24) & 0xff\n const g = (packed >>> 16) & 0xff\n const b = (packed >>> 8) & 0xff\n const a = (packed & 0xff) / 255\n\n return a === 1 ? `rgb(${r},${g},${b})` : `rgba(${r},${g},${b},${round(a)})`\n}\n\nconst round = (n: number): number => Math.round(n * 1000) / 1000\n"],"mappings":";;AAEA,MAAa,cAAc,UAAuC;CAChE,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU,OAAO,KAAA;CACnE,MAAM,SAAS,eAAe,KAAK;CACnC,IAAI,WAAW,QAAQ,WAAW,KAAA,GAAW,OAAO,KAAA;CAEpD,MAAM,IAAK,WAAW,KAAM;CAC5B,MAAM,IAAK,WAAW,KAAM;CAC5B,MAAM,IAAK,WAAW,IAAK;CAC3B,MAAM,KAAK,SAAS,OAAQ;CAE5B,OAAO,MAAM,IAAI,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,EAAE;AAC3E;AAEA,MAAM,SAAS,MAAsB,KAAK,MAAM,IAAI,GAAI,IAAI"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getLeftAndRightSwap } from "./direction.js";
|
|
2
|
+
import { getStyleRegistry } from "./registry.js";
|
|
3
|
+
import { resolveStyle } from "./resolveStyle.js";
|
|
4
|
+
// src/style/compile.ts
|
|
5
|
+
const flattenStyle = (style) => {
|
|
6
|
+
if (style === null || style === void 0 || style === false || style === "") return void 0;
|
|
7
|
+
if (!Array.isArray(style)) return style;
|
|
8
|
+
let result;
|
|
9
|
+
for (const entry of style) {
|
|
10
|
+
const flat = flattenStyle(entry);
|
|
11
|
+
if (flat === void 0) continue;
|
|
12
|
+
result = result === void 0 ? { ...flat } : Object.assign(result, flat);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
const boxPointerEventsClass = (value, registry) => {
|
|
17
|
+
if (value === "box-none") return registry.staticClass("rn-pe-box-none", [".rn-pe-box-none{pointer-events:none}", ":where(.rn-pe-box-none)>*{pointer-events:auto}"]);
|
|
18
|
+
if (value === "box-only") return registry.staticClass("rn-pe-box-only", [".rn-pe-box-only{pointer-events:auto}", ".rn-pe-box-only>*{pointer-events:none!important}"]);
|
|
19
|
+
};
|
|
20
|
+
const pointerEventsStyle = Object.freeze({
|
|
21
|
+
auto: Object.freeze({ pointerEvents: "auto" }),
|
|
22
|
+
none: Object.freeze({ pointerEvents: "none" }),
|
|
23
|
+
"box-none": Object.freeze({ pointerEvents: "box-none" }),
|
|
24
|
+
"box-only": Object.freeze({ pointerEvents: "box-only" })
|
|
25
|
+
});
|
|
26
|
+
const caches = [/* @__PURE__ */ new WeakMap(), /* @__PURE__ */ new WeakMap()];
|
|
27
|
+
const collectFrozen = (style, out) => {
|
|
28
|
+
if (style === null || style === void 0 || style === false || style === "") return true;
|
|
29
|
+
if (Array.isArray(style)) {
|
|
30
|
+
for (const entry of style) if (!collectFrozen(entry, out)) return false;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (typeof style !== "object" || !Object.isFrozen(style)) return false;
|
|
34
|
+
out.push(style);
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
const compileFlat = (flat, registry) => flat === void 0 ? "" : joinClassNames(registry.classesFor(resolveStyle(flat)), boxPointerEventsClass(flat["pointerEvents"], registry));
|
|
38
|
+
const compileStyle = (style, registry = getStyleRegistry()) => {
|
|
39
|
+
const frozen = [];
|
|
40
|
+
if (!collectFrozen(style, frozen)) return compileFlat(flattenStyle(style), registry);
|
|
41
|
+
if (frozen.length === 0) return "";
|
|
42
|
+
const cache = caches[getLeftAndRightSwap() ? 1 : 0];
|
|
43
|
+
let level = cache.get(registry);
|
|
44
|
+
if (level === void 0) {
|
|
45
|
+
level = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
cache.set(registry, level);
|
|
47
|
+
}
|
|
48
|
+
let node;
|
|
49
|
+
for (const object of frozen) {
|
|
50
|
+
if (node !== void 0) level = node.next ??= /* @__PURE__ */ new WeakMap();
|
|
51
|
+
node = level.get(object);
|
|
52
|
+
if (node === void 0) {
|
|
53
|
+
node = {
|
|
54
|
+
classes: void 0,
|
|
55
|
+
next: void 0
|
|
56
|
+
};
|
|
57
|
+
level.set(object, node);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const leaf = node;
|
|
61
|
+
leaf.classes ??= compileFlat(frozen.length === 1 ? frozen[0] : flattenStyle(frozen), registry);
|
|
62
|
+
return leaf.classes;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The class of a component's default style, in the reset sheet. Any style of the app beats it,
|
|
66
|
+
* as any style beats the defaults of native layout.
|
|
67
|
+
*/
|
|
68
|
+
const compileReset = (className, style, registry = getStyleRegistry()) => registry.resetClass(className, resolveStyle(style));
|
|
69
|
+
const joinClassNames = (...names) => names.filter((name) => typeof name === "string" && name !== "").join(" ");
|
|
70
|
+
export { compileReset, compileStyle, flattenStyle, joinClassNames, pointerEventsStyle };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","names":[],"sources":["../../src/style/compile.ts"],"sourcesContent":["import { getLeftAndRightSwap } from './direction'\nimport { getStyleRegistry, type StyleRegistry } from './registry'\nimport { resolveStyle } from './resolveStyle'\nimport type { FlatStyle, StyleProp } from './types'\n\nexport const flattenStyle = <T extends object>(style: StyleProp<T>): T | undefined => {\n if (style === null || style === undefined || style === false || style === '') return undefined\n if (!Array.isArray(style)) return style as T\n\n let result: object | undefined\n for (const entry of style as ReadonlyArray<StyleProp<T>>) {\n const flat = flattenStyle(entry)\n if (flat === undefined) continue\n result = result === undefined ? { ...flat } : Object.assign(result, flat)\n }\n return result as T | undefined\n}\n\n// A child selector can't be an atomic class. The child rule of `box-none` has no specificity, so\n// a child with its own `pointerEvents` keeps it. The children of `box-only` are never a target.\nconst boxPointerEventsClass = (value: unknown, registry: StyleRegistry): string | undefined => {\n if (value === 'box-none') {\n return registry.staticClass('rn-pe-box-none', [\n '.rn-pe-box-none{pointer-events:none}',\n ':where(.rn-pe-box-none)>*{pointer-events:auto}',\n ])\n }\n if (value === 'box-only') {\n return registry.staticClass('rn-pe-box-only', [\n '.rn-pe-box-only{pointer-events:auto}',\n '.rn-pe-box-only>*{pointer-events:none!important}',\n ])\n }\n return undefined\n}\n\n// The `pointerEvents` prop as a style. The prop wins over the same key of `style`.\nexport const pointerEventsStyle: Readonly<\n Record<'auto' | 'none' | 'box-none' | 'box-only', FlatStyle>\n> = Object.freeze({\n auto: Object.freeze({ pointerEvents: 'auto' }),\n none: Object.freeze({ pointerEvents: 'none' }),\n 'box-none': Object.freeze({ pointerEvents: 'box-none' }),\n 'box-only': Object.freeze({ pointerEvents: 'box-only' }),\n})\n\n// A path through the cache, one frozen style object for each step. The classes of a node are the\n// classes of the objects on its path, flattened in that order.\ntype CacheNode = { classes: string | undefined; next: WeakMap<FlatStyle, CacheNode> | undefined }\n\n// One cache for each value of the left and right swap, because the classes of a style differ.\nconst caches = [\n new WeakMap<StyleRegistry, WeakMap<FlatStyle, CacheNode>>(),\n new WeakMap<StyleRegistry, WeakMap<FlatStyle, CacheNode>>(),\n] as const\n\n// Static objects from StyleSheet.create are frozen, so they can be cache keys. Returns false at\n// the first entry that isn't a frozen object. `Object.isFrozen` is true for a number, and a\n// WeakMap throws on it.\nconst collectFrozen = (style: StyleProp<object>, out: FlatStyle[]): boolean => {\n if (style === null || style === undefined || style === false || style === '') return true\n if (Array.isArray(style)) {\n for (const entry of style as ReadonlyArray<StyleProp<object>>) {\n if (!collectFrozen(entry, out)) return false\n }\n return true\n }\n if (typeof style !== 'object' || !Object.isFrozen(style)) return false\n out.push(style as FlatStyle)\n return true\n}\n\nconst compileFlat = (flat: FlatStyle | undefined, registry: StyleRegistry): string =>\n flat === undefined\n ? ''\n : joinClassNames(\n registry.classesFor(resolveStyle(flat)),\n boxPointerEventsClass(flat['pointerEvents'], registry),\n )\n\nexport const compileStyle = (\n style: StyleProp<object>,\n registry: StyleRegistry = getStyleRegistry(),\n): string => {\n const frozen: FlatStyle[] = []\n if (!collectFrozen(style, frozen)) {\n return compileFlat(flattenStyle(style) as FlatStyle | undefined, registry)\n }\n if (frozen.length === 0) return ''\n\n const cache = caches[getLeftAndRightSwap() ? 1 : 0]\n let level = cache.get(registry)\n if (level === undefined) {\n level = new WeakMap()\n cache.set(registry, level)\n }\n let node: CacheNode | undefined\n for (const object of frozen) {\n if (node !== undefined) level = node.next ??= new WeakMap()\n node = level.get(object)\n if (node === undefined) {\n node = { classes: undefined, next: undefined }\n level.set(object, node)\n }\n }\n const leaf = node as CacheNode\n leaf.classes ??= compileFlat(\n frozen.length === 1 ? frozen[0] : flattenStyle<FlatStyle>(frozen),\n registry,\n )\n return leaf.classes\n}\n\n/**\n * The class of a component's default style, in the reset sheet. Any style of the app beats it,\n * as any style beats the defaults of native layout.\n */\nexport const compileReset = (\n className: string,\n style: FlatStyle,\n registry: StyleRegistry = getStyleRegistry(),\n): string => registry.resetClass(className, resolveStyle(style))\n\n// Joins class names and skips the empty ones.\nexport const joinClassNames = (...names: ReadonlyArray<string | false | undefined>): string =>\n names.filter((name) => typeof name === 'string' && name !== '').join(' ')\n"],"mappings":";;;;AAKA,MAAa,gBAAkC,UAAuC;CACpF,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU,SAAS,UAAU,IAAI,OAAO,KAAA;CACrF,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO;CAElC,IAAI;CACJ,KAAK,MAAM,SAAS,OAAsC;EACxD,MAAM,OAAO,aAAa,KAAK;EAC/B,IAAI,SAAS,KAAA,GAAW;EACxB,SAAS,WAAW,KAAA,IAAY,EAAE,GAAG,KAAK,IAAI,OAAO,OAAO,QAAQ,IAAI;CAC1E;CACA,OAAO;AACT;AAIA,MAAM,yBAAyB,OAAgB,aAAgD;CAC7F,IAAI,UAAU,YACZ,OAAO,SAAS,YAAY,kBAAkB,CAC5C,wCACA,gDACF,CAAC;CAEH,IAAI,UAAU,YACZ,OAAO,SAAS,YAAY,kBAAkB,CAC5C,wCACA,kDACF,CAAC;AAGL;AAGA,MAAa,qBAET,OAAO,OAAO;CAChB,MAAM,OAAO,OAAO,EAAE,eAAe,OAAO,CAAC;CAC7C,MAAM,OAAO,OAAO,EAAE,eAAe,OAAO,CAAC;CAC7C,YAAY,OAAO,OAAO,EAAE,eAAe,WAAW,CAAC;CACvD,YAAY,OAAO,OAAO,EAAE,eAAe,WAAW,CAAC;AACzD,CAAC;AAOD,MAAM,SAAS,iBACb,IAAI,QAAsD,mBAC1D,IAAI,QAAsD,CAC5D;AAKA,MAAM,iBAAiB,OAA0B,QAA8B;CAC7E,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU,SAAS,UAAU,IAAI,OAAO;CACrF,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,KAAK,MAAM,SAAS,OAClB,IAAI,CAAC,cAAc,OAAO,GAAG,GAAG,OAAO;EAEzC,OAAO;CACT;CACA,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACjE,IAAI,KAAK,KAAkB;CAC3B,OAAO;AACT;AAEA,MAAM,eAAe,MAA6B,aAChD,SAAS,KAAA,IACL,KACA,eACE,SAAS,WAAW,aAAa,IAAI,CAAC,GACtC,sBAAsB,KAAK,kBAAkB,QAAQ,CACvD;AAEN,MAAa,gBACX,OACA,WAA0B,iBAAiB,MAChC;CACX,MAAM,SAAsB,CAAC;CAC7B,IAAI,CAAC,cAAc,OAAO,MAAM,GAC9B,OAAO,YAAY,aAAa,KAAK,GAA4B,QAAQ;CAE3E,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,MAAM,QAAQ,OAAO,oBAAoB,IAAI,IAAI;CACjD,IAAI,QAAQ,MAAM,IAAI,QAAQ;CAC9B,IAAI,UAAU,KAAA,GAAW;EACvB,wBAAQ,IAAI,QAAQ;EACpB,MAAM,IAAI,UAAU,KAAK;CAC3B;CACA,IAAI;CACJ,KAAK,MAAM,UAAU,QAAQ;EAC3B,IAAI,SAAS,KAAA,GAAW,QAAQ,KAAK,yBAAS,IAAI,QAAQ;EAC1D,OAAO,MAAM,IAAI,MAAM;EACvB,IAAI,SAAS,KAAA,GAAW;GACtB,OAAO;IAAE,SAAS,KAAA;IAAW,MAAM,KAAA;GAAU;GAC7C,MAAM,IAAI,QAAQ,IAAI;EACxB;CACF;CACA,MAAM,OAAO;CACb,KAAK,YAAY,YACf,OAAO,WAAW,IAAI,OAAO,KAAK,aAAwB,MAAM,GAChE,QACF;CACA,OAAO,KAAK;AACd;;;;;AAMA,MAAa,gBACX,WACA,OACA,WAA0B,iBAAiB,MAChC,SAAS,WAAW,WAAW,aAAa,KAAK,CAAC;AAG/D,MAAa,kBAAkB,GAAG,UAChC,MAAM,QAAQ,SAAS,OAAO,SAAS,YAAY,SAAS,EAAE,CAAC,CAAC,KAAK,GAAG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/style/direction.ts
|
|
2
|
+
let swap = true;
|
|
3
|
+
const getLeftAndRightSwap = () => swap;
|
|
4
|
+
const setLeftAndRightSwap = (value) => {
|
|
5
|
+
swap = value;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The logical CSS property of each physical left or right style. Fabric moves these styles to
|
|
9
|
+
* the start and end edges in a right-to-left layout. A logical property does the same in the
|
|
10
|
+
* browser: it is the left edge in a left-to-right layout, and the right edge in a right-to-left
|
|
11
|
+
* one. The class names stay the same in both, so the server render needs no direction.
|
|
12
|
+
*/
|
|
13
|
+
const swappedProperties = {
|
|
14
|
+
left: "insetInlineStart",
|
|
15
|
+
right: "insetInlineEnd",
|
|
16
|
+
marginLeft: "marginInlineStart",
|
|
17
|
+
marginRight: "marginInlineEnd",
|
|
18
|
+
paddingLeft: "paddingInlineStart",
|
|
19
|
+
paddingRight: "paddingInlineEnd",
|
|
20
|
+
borderLeftWidth: "borderInlineStartWidth",
|
|
21
|
+
borderRightWidth: "borderInlineEndWidth",
|
|
22
|
+
borderLeftColor: "borderInlineStartColor",
|
|
23
|
+
borderRightColor: "borderInlineEndColor",
|
|
24
|
+
borderLeftStyle: "borderInlineStartStyle",
|
|
25
|
+
borderRightStyle: "borderInlineEndStyle",
|
|
26
|
+
borderTopLeftRadius: "borderStartStartRadius",
|
|
27
|
+
borderTopRightRadius: "borderStartEndRadius",
|
|
28
|
+
borderBottomLeftRadius: "borderEndStartRadius",
|
|
29
|
+
borderBottomRightRadius: "borderEndEndRadius"
|
|
30
|
+
};
|
|
31
|
+
export { getLeftAndRightSwap, setLeftAndRightSwap, swappedProperties };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=direction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.js","names":[],"sources":["../../src/style/direction.ts"],"sourcesContent":["// `I18nManager.swapLeftAndRightInRTL` sets this. On by default, as on native.\nlet swap = true\n\nexport const getLeftAndRightSwap = (): boolean => swap\n\nexport const setLeftAndRightSwap = (value: boolean): void => {\n swap = value\n}\n\n/**\n * The logical CSS property of each physical left or right style. Fabric moves these styles to\n * the start and end edges in a right-to-left layout. A logical property does the same in the\n * browser: it is the left edge in a left-to-right layout, and the right edge in a right-to-left\n * one. The class names stay the same in both, so the server render needs no direction.\n */\nexport const swappedProperties: Readonly<Record<string, string>> = {\n left: 'insetInlineStart',\n right: 'insetInlineEnd',\n marginLeft: 'marginInlineStart',\n marginRight: 'marginInlineEnd',\n paddingLeft: 'paddingInlineStart',\n paddingRight: 'paddingInlineEnd',\n borderLeftWidth: 'borderInlineStartWidth',\n borderRightWidth: 'borderInlineEndWidth',\n borderLeftColor: 'borderInlineStartColor',\n borderRightColor: 'borderInlineEndColor',\n borderLeftStyle: 'borderInlineStartStyle',\n borderRightStyle: 'borderInlineEndStyle',\n borderTopLeftRadius: 'borderStartStartRadius',\n borderTopRightRadius: 'borderStartEndRadius',\n borderBottomLeftRadius: 'borderEndStartRadius',\n borderBottomRightRadius: 'borderEndEndRadius',\n}\n"],"mappings":";AACA,IAAI,OAAO;AAEX,MAAa,4BAAqC;AAElD,MAAa,uBAAuB,UAAyB;CAC3D,OAAO;AACT;;;;;;;AAQA,MAAa,oBAAsD;CACjE,MAAM;CACN,OAAO;CACP,YAAY;CACZ,aAAa;CACb,aAAa;CACb,cAAc;CACd,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;CAClB,qBAAqB;CACrB,sBAAsB;CACtB,wBAAwB;CACxB,yBAAyB;AAC3B"}
|
package/dist/style/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSDeclarations, FlatStyle, StyleProp } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Compat export. Compiles a React Native style to inline DOM style values, keyed by the
|
|
4
4
|
* camel-case names of `CSSStyleDeclaration`, with the same rules as the class names of `View`.
|
package/dist/style/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { flattenStyle } from "./compile.js";
|
|
2
|
+
import { isShorthandProperty } from "./registry.js";
|
|
3
|
+
import { resolveStyle } from "./resolveStyle.js";
|
|
4
|
+
import { toCSSTextShadow } from "./shadow.js";
|
|
5
|
+
import { toCSSTransform } from "./transform.js";
|
|
3
6
|
// src/style/index.ts
|
|
4
7
|
/**
|
|
5
8
|
* Compat export. Compiles a React Native style to inline DOM style values, keyed by the
|
package/dist/style/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/style/index.ts"],"sourcesContent":["import { flattenStyle } from './compile'\nimport { isShorthandProperty } from './registry'\nimport { resolveStyle } from './resolveStyle'\nimport { toCSSTextShadow } from './shadow'\nimport { toCSSTransform } from './transform'\nimport type { CSSDeclarations, FlatStyle, StyleProp } from './types'\n\nexport type { CSSDeclarations } from './types'\n\n/**\n * Compat export. Compiles a React Native style to inline DOM style values, keyed by the\n * camel-case names of `CSSStyleDeclaration`, with the same rules as the class names of `View`.\n * Libraries such as Reanimated write the result into `element.style` on each frame.\n *\n * Shorthands come first, so a longhand written after them wins, as it does in the class names.\n */\nexport const createReactDOMStyle = (style: StyleProp<FlatStyle>): CSSDeclarations => {\n const flat = flattenStyle(style)\n if (flat === undefined) return {}\n\n const resolved = resolveStyle(flat)\n const shorthands: CSSDeclarations = {}\n const longhands: CSSDeclarations = {}\n for (const name in resolved) {\n const target = isShorthandProperty(name) ? shorthands : longhands\n target[name] = resolved[name] as string\n }\n return Object.assign(shorthands, longhands)\n}\n\n/**\n * Compat export. Turns a React Native `transform` array into a CSS `transform` value. An empty\n * string for a value that has no valid transform.\n */\nexport const createTransformValue = (transform: unknown): string => toCSSTransform(transform) ?? ''\n\n/**\n * Compat export. Turns the three React Native text shadow props into a CSS `text-shadow` value.\n * `undefined` for a color that it can't parse.\n */\nexport const createTextShadowValue = (style: {\n readonly textShadowColor?: unknown\n readonly textShadowOffset?: unknown\n readonly textShadowRadius?: unknown\n}): string | undefined => toCSSTextShadow(style)\n\n// react-native-web's `createReactDOMStyle` module has the function as its default export. The\n// Vite plugin points that module name here, so the same shape must be here too.\nexport default createReactDOMStyle\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/style/index.ts"],"sourcesContent":["import { flattenStyle } from './compile'\nimport { isShorthandProperty } from './registry'\nimport { resolveStyle } from './resolveStyle'\nimport { toCSSTextShadow } from './shadow'\nimport { toCSSTransform } from './transform'\nimport type { CSSDeclarations, FlatStyle, StyleProp } from './types'\n\nexport type { CSSDeclarations } from './types'\n\n/**\n * Compat export. Compiles a React Native style to inline DOM style values, keyed by the\n * camel-case names of `CSSStyleDeclaration`, with the same rules as the class names of `View`.\n * Libraries such as Reanimated write the result into `element.style` on each frame.\n *\n * Shorthands come first, so a longhand written after them wins, as it does in the class names.\n */\nexport const createReactDOMStyle = (style: StyleProp<FlatStyle>): CSSDeclarations => {\n const flat = flattenStyle(style)\n if (flat === undefined) return {}\n\n const resolved = resolveStyle(flat)\n const shorthands: CSSDeclarations = {}\n const longhands: CSSDeclarations = {}\n for (const name in resolved) {\n const target = isShorthandProperty(name) ? shorthands : longhands\n target[name] = resolved[name] as string\n }\n return Object.assign(shorthands, longhands)\n}\n\n/**\n * Compat export. Turns a React Native `transform` array into a CSS `transform` value. An empty\n * string for a value that has no valid transform.\n */\nexport const createTransformValue = (transform: unknown): string => toCSSTransform(transform) ?? ''\n\n/**\n * Compat export. Turns the three React Native text shadow props into a CSS `text-shadow` value.\n * `undefined` for a color that it can't parse.\n */\nexport const createTextShadowValue = (style: {\n readonly textShadowColor?: unknown\n readonly textShadowOffset?: unknown\n readonly textShadowRadius?: unknown\n}): string | undefined => toCSSTextShadow(style)\n\n// react-native-web's `createReactDOMStyle` module has the function as its default export. The\n// Vite plugin points that module name here, so the same shape must be here too.\nexport default createReactDOMStyle\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,uBAAuB,UAAiD;CACnF,MAAM,OAAO,aAAa,KAAK;CAC/B,IAAI,SAAS,KAAA,GAAW,OAAO,CAAC;CAEhC,MAAM,WAAW,aAAa,IAAI;CAClC,MAAM,aAA8B,CAAC;CACrC,MAAM,YAA6B,CAAC;CACpC,KAAK,MAAM,QAAQ,UAAU;EAC3B,MAAM,SAAS,oBAAoB,IAAI,IAAI,aAAa;EACxD,OAAO,QAAQ,SAAS;CAC1B;CACA,OAAO,OAAO,OAAO,YAAY,SAAS;AAC5C;;;;;AAMA,MAAa,wBAAwB,cAA+B,eAAe,SAAS,KAAK;;;;;AAMjG,MAAa,yBAAyB,UAIZ,gBAAgB,KAAK"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CSSDeclarations } from "./types.js";
|
|
2
|
+
export type StyleSheets = {
|
|
3
|
+
reset: CSSStyleSheet | null;
|
|
4
|
+
shorthand: CSSStyleSheet | null;
|
|
5
|
+
longhand: CSSStyleSheet | null;
|
|
6
|
+
};
|
|
7
|
+
export declare class StyleRegistry {
|
|
8
|
+
private readonly classNames;
|
|
9
|
+
private readonly adopted;
|
|
10
|
+
private readonly resetRules;
|
|
11
|
+
private readonly shorthandRules;
|
|
12
|
+
private readonly longhandRules;
|
|
13
|
+
private readonly sheets;
|
|
14
|
+
constructor(sheets?: StyleSheets);
|
|
15
|
+
classFor(property: string, value: string): string;
|
|
16
|
+
classesFor(declarations: CSSDeclarations): string;
|
|
17
|
+
staticClass(className: string, rules: ReadonlyArray<string>): string;
|
|
18
|
+
resetClass(className: string, declarations: CSSDeclarations): string;
|
|
19
|
+
cssText(): {
|
|
20
|
+
reset: string;
|
|
21
|
+
shorthand: string;
|
|
22
|
+
longhand: string;
|
|
23
|
+
};
|
|
24
|
+
get ruleCount(): number;
|
|
25
|
+
private adopt;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasDOM } from "../utils/env.js";
|
|
2
2
|
// src/style/registry.ts
|
|
3
3
|
const RESET_STYLE_ID = "rootnative-style-reset";
|
|
4
4
|
const SHORTHAND_STYLE_ID = "rootnative-style-shorthand";
|
|
@@ -141,6 +141,6 @@ const domSheet = (id) => {
|
|
|
141
141
|
}
|
|
142
142
|
return element.sheet;
|
|
143
143
|
};
|
|
144
|
-
export {
|
|
144
|
+
export { LONGHAND_STYLE_ID, RESET_STYLE_ID, SHORTHAND_STYLE_ID, StyleRegistry, getStyleRegistry, isShorthandProperty };
|
|
145
145
|
|
|
146
|
-
//# sourceMappingURL=registry
|
|
146
|
+
//# sourceMappingURL=registry.js.map
|