@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,29 @@
|
|
|
1
|
+
import { processColor } from "../../apis/processColor/index.js";
|
|
2
|
+
import { TouchableWithoutFeedback } from "../TouchableWithoutFeedback/index.js";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
// src/components/TouchableNativeFeedback/index.tsx
|
|
5
|
+
const TouchableNativeFeedback = Object.assign(function TouchableNativeFeedback(props) {
|
|
6
|
+
const { background: _background, hasTVPreferredFocus: _hasTVPreferredFocus, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, useForeground: _useForeground, ...rest } = props;
|
|
7
|
+
return createElement(TouchableWithoutFeedback, rest);
|
|
8
|
+
}, {
|
|
9
|
+
SelectableBackground: (rippleRadius) => ({
|
|
10
|
+
type: "ThemeAttrAndroid",
|
|
11
|
+
attribute: "selectableItemBackground",
|
|
12
|
+
rippleRadius
|
|
13
|
+
}),
|
|
14
|
+
SelectableBackgroundBorderless: (rippleRadius) => ({
|
|
15
|
+
type: "ThemeAttrAndroid",
|
|
16
|
+
attribute: "selectableItemBackgroundBorderless",
|
|
17
|
+
rippleRadius
|
|
18
|
+
}),
|
|
19
|
+
Ripple: (color, borderless, rippleRadius) => ({
|
|
20
|
+
type: "RippleAndroid",
|
|
21
|
+
color: processColor(color),
|
|
22
|
+
borderless,
|
|
23
|
+
rippleRadius
|
|
24
|
+
}),
|
|
25
|
+
canUseNativeForeground: () => false
|
|
26
|
+
});
|
|
27
|
+
export { TouchableNativeFeedback };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/TouchableNativeFeedback/index.tsx"],"sourcesContent":["import { createElement, type ReactElement } from 'react'\n\nimport { processColor } from '../../apis/processColor'\nimport { TouchableWithoutFeedback } from '../TouchableWithoutFeedback'\nimport type {\n RippleBackgroundPropType,\n ThemeAttributeBackgroundPropType,\n TouchableNativeFeedbackProps,\n} from './types'\n\nexport type { TouchableNativeFeedbackProps } from './types'\n\ntype TouchableNativeFeedbackStatics = {\n SelectableBackground: (rippleRadius?: number | null) => ThemeAttributeBackgroundPropType\n SelectableBackgroundBorderless: (rippleRadius?: number | null) => ThemeAttributeBackgroundPropType\n Ripple: (\n color: string,\n borderless: boolean,\n rippleRadius?: number | null,\n ) => RippleBackgroundPropType\n canUseNativeForeground: () => boolean\n}\n\n// The ripple is Android's. Elsewhere React Native shows no feedback, and the press works as on\n// TouchableWithoutFeedback. The web does the same as iOS.\nexport const TouchableNativeFeedback: ((props: TouchableNativeFeedbackProps) => ReactElement) &\n TouchableNativeFeedbackStatics = Object.assign(\n function TouchableNativeFeedback(props: TouchableNativeFeedbackProps): ReactElement {\n const {\n background: _background,\n hasTVPreferredFocus: _hasTVPreferredFocus,\n nextFocusDown: _nextFocusDown,\n nextFocusForward: _nextFocusForward,\n nextFocusLeft: _nextFocusLeft,\n nextFocusRight: _nextFocusRight,\n nextFocusUp: _nextFocusUp,\n useForeground: _useForeground,\n ...rest\n } = props\n return createElement(TouchableWithoutFeedback, rest)\n },\n {\n SelectableBackground: (rippleRadius?: number | null): ThemeAttributeBackgroundPropType => ({\n type: 'ThemeAttrAndroid',\n attribute: 'selectableItemBackground',\n rippleRadius,\n }),\n SelectableBackgroundBorderless: (\n rippleRadius?: number | null,\n ): ThemeAttributeBackgroundPropType => ({\n type: 'ThemeAttrAndroid',\n attribute: 'selectableItemBackgroundBorderless',\n rippleRadius,\n }),\n Ripple: (\n color: string,\n borderless: boolean,\n rippleRadius?: number | null,\n ): RippleBackgroundPropType => ({\n type: 'RippleAndroid',\n color: processColor(color),\n borderless,\n rippleRadius,\n }),\n canUseNativeForeground: (): boolean => false,\n },\n)\n"],"mappings":";;;;AAyBA,MAAa,0BACsB,OAAO,OACxC,SAAS,wBAAwB,OAAmD;CAClF,MAAM,EACJ,YAAY,aACZ,qBAAqB,sBACrB,eAAe,gBACf,kBAAkB,mBAClB,eAAe,gBACf,gBAAgB,iBAChB,aAAa,cACb,eAAe,gBACf,GAAG,SACD;CACJ,OAAO,cAAc,0BAA0B,IAAI;AACrD,GACA;CACE,uBAAuB,kBAAoE;EACzF,MAAM;EACN,WAAW;EACX;CACF;CACA,iCACE,kBACsC;EACtC,MAAM;EACN,WAAW;EACX;CACF;CACA,SACE,OACA,YACA,kBAC8B;EAC9B,MAAM;EACN,OAAO,aAAa,KAAK;EACzB;EACA;CACF;CACA,8BAAuC;AACzC,CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ProcessedColorValue } from "../../apis/processColor/index.js";
|
|
2
|
+
import { TouchableTVProps, TouchableWithoutFeedbackProps } from "../TouchableWithoutFeedback/types.js";
|
|
3
|
+
export type ThemeAttributeBackgroundPropType = Readonly<{
|
|
4
|
+
type: "ThemeAttrAndroid";
|
|
5
|
+
attribute: "selectableItemBackground" | "selectableItemBackgroundBorderless";
|
|
6
|
+
rippleRadius: number | null | undefined;
|
|
7
|
+
}>;
|
|
8
|
+
export type RippleBackgroundPropType = Readonly<{
|
|
9
|
+
type: "RippleAndroid";
|
|
10
|
+
color: ProcessedColorValue | null | undefined;
|
|
11
|
+
borderless: boolean;
|
|
12
|
+
rippleRadius: number | null | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export type BackgroundPropType = ThemeAttributeBackgroundPropType | RippleBackgroundPropType;
|
|
15
|
+
export type TouchableNativeFeedbackProps = TouchableWithoutFeedbackProps & TouchableTVProps & {
|
|
16
|
+
background?: BackgroundPropType | undefined;
|
|
17
|
+
useForeground?: boolean | undefined;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { pointerCursorStyle } from "../../events/press/cursorStyle.js";
|
|
2
|
+
import { usePressability } from "../../events/press/usePressability.js";
|
|
3
|
+
import { mergeHandlers } from "../../events/press/mergeHandlers.js";
|
|
4
|
+
import { hitSlopClass } from "../../render/hitSlop.js";
|
|
5
|
+
import { flattenStyle } from "../../style/compile.js";
|
|
6
|
+
import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
|
|
7
|
+
import { useViewElement } from "../View/index.js";
|
|
8
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
9
|
+
// src/components/TouchableOpacity/index.tsx
|
|
10
|
+
const EASE_IN_OUT_QUAD = "cubic-bezier(0.455, 0.03, 0.515, 0.955)";
|
|
11
|
+
const DEFAULT_ACTIVE_OPACITY = .2;
|
|
12
|
+
const notCancelableStyle = Object.freeze({ touchAction: "none" });
|
|
13
|
+
const isTrue = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
14
|
+
const restingOpacity = (style) => {
|
|
15
|
+
const opacity = flattenStyle(style)?.opacity;
|
|
16
|
+
return typeof opacity === "number" ? opacity : 1;
|
|
17
|
+
};
|
|
18
|
+
function TouchableOpacity(props) {
|
|
19
|
+
const { activeOpacity, children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hasTVPreferredFocus: _hasTVPreferredFocus, hitSlop, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut, pressRetentionOffset, ref, rejectResponderTermination, style, touchSoundDisabled, ...rest } = props;
|
|
20
|
+
const element = useRef(null);
|
|
21
|
+
const animation = useRef(null);
|
|
22
|
+
const resting = restingOpacity(style);
|
|
23
|
+
const resolvedDisabled = disabled ?? isTrue(props["aria-disabled"]) ?? props.accessibilityState?.disabled;
|
|
24
|
+
const fadeTo = useCallback((opacity, duration, settle) => {
|
|
25
|
+
const node = element.current;
|
|
26
|
+
if (node === null || typeof node.animate !== "function") return;
|
|
27
|
+
const from = getComputedStyle(node).opacity;
|
|
28
|
+
animation.current?.cancel();
|
|
29
|
+
const next = node.animate([{ opacity: from }, { opacity: String(opacity) }], {
|
|
30
|
+
duration,
|
|
31
|
+
easing: EASE_IN_OUT_QUAD,
|
|
32
|
+
fill: "forwards"
|
|
33
|
+
});
|
|
34
|
+
animation.current = next;
|
|
35
|
+
if (settle) next.onfinish = () => {
|
|
36
|
+
if (animation.current !== next) return;
|
|
37
|
+
next.cancel();
|
|
38
|
+
animation.current = null;
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
const config = useMemo(() => ({
|
|
42
|
+
cancelable: rejectResponderTermination !== true,
|
|
43
|
+
disabled: resolvedDisabled,
|
|
44
|
+
hitSlop,
|
|
45
|
+
delayLongPress,
|
|
46
|
+
delayPressIn,
|
|
47
|
+
delayPressOut,
|
|
48
|
+
minPressDuration: 0,
|
|
49
|
+
pressRectOffset: pressRetentionOffset,
|
|
50
|
+
android_disableSound: touchSoundDisabled,
|
|
51
|
+
onBlur,
|
|
52
|
+
onFocus,
|
|
53
|
+
onLongPress,
|
|
54
|
+
onPress,
|
|
55
|
+
onPressIn: (event) => {
|
|
56
|
+
const starts = event.type === "pointerdown" || event.type === "keydown";
|
|
57
|
+
fadeTo(activeOpacity ?? DEFAULT_ACTIVE_OPACITY, starts ? 0 : 150, false);
|
|
58
|
+
onPressIn?.(event);
|
|
59
|
+
},
|
|
60
|
+
onPressOut: (event) => {
|
|
61
|
+
fadeTo(resting, 250, true);
|
|
62
|
+
onPressOut?.(event);
|
|
63
|
+
}
|
|
64
|
+
}), [
|
|
65
|
+
activeOpacity,
|
|
66
|
+
delayLongPress,
|
|
67
|
+
delayPressIn,
|
|
68
|
+
delayPressOut,
|
|
69
|
+
fadeTo,
|
|
70
|
+
hitSlop,
|
|
71
|
+
onBlur,
|
|
72
|
+
onFocus,
|
|
73
|
+
onLongPress,
|
|
74
|
+
onPress,
|
|
75
|
+
onPressIn,
|
|
76
|
+
onPressOut,
|
|
77
|
+
pressRetentionOffset,
|
|
78
|
+
rejectResponderTermination,
|
|
79
|
+
resolvedDisabled,
|
|
80
|
+
resting,
|
|
81
|
+
touchSoundDisabled
|
|
82
|
+
]);
|
|
83
|
+
const handlers = usePressability(config);
|
|
84
|
+
const registry = useStyleRegistry();
|
|
85
|
+
const previous = useRef({
|
|
86
|
+
disabled,
|
|
87
|
+
resting
|
|
88
|
+
});
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (previous.current.disabled === disabled && previous.current.resting === resting) return;
|
|
91
|
+
previous.current = {
|
|
92
|
+
disabled,
|
|
93
|
+
resting
|
|
94
|
+
};
|
|
95
|
+
fadeTo(resting, 250, true);
|
|
96
|
+
}, [
|
|
97
|
+
disabled,
|
|
98
|
+
fadeTo,
|
|
99
|
+
resting
|
|
100
|
+
]);
|
|
101
|
+
useEffect(() => () => {
|
|
102
|
+
animation.current?.cancel();
|
|
103
|
+
}, []);
|
|
104
|
+
const view = useViewElement({
|
|
105
|
+
...rest,
|
|
106
|
+
...mergeHandlers(rest, handlers),
|
|
107
|
+
ref: element,
|
|
108
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true,
|
|
109
|
+
style: [
|
|
110
|
+
resolvedDisabled !== true && pointerCursorStyle,
|
|
111
|
+
style,
|
|
112
|
+
rejectResponderTermination === true && notCancelableStyle
|
|
113
|
+
],
|
|
114
|
+
children,
|
|
115
|
+
...resolvedDisabled === true && { "aria-disabled": true }
|
|
116
|
+
}, hitSlopClass(registry, hitSlop));
|
|
117
|
+
useImperativeHandle(ref, () => element.current, []);
|
|
118
|
+
return view;
|
|
119
|
+
}
|
|
120
|
+
export { TouchableOpacity };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/TouchableOpacity/index.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n type ReactElement,\n} from 'react'\n\nimport type { ViewStyle } from '../../apis/StyleSheet/types'\nimport { pointerCursorStyle, usePressability } from '../../events/press'\nimport { mergeHandlers } from '../../events/press/mergeHandlers'\nimport type { PressabilityConfig } from '../../events/press/types'\nimport { hitSlopClass } from '../../render/hitSlop'\nimport { flattenStyle } from '../../style/compile'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport type { StyleProp } from '../../style/types'\nimport { useViewElement } from '../View'\nimport type { HostInstance } from '../View/types'\nimport type { TouchableOpacityProps } from './types'\n\nexport type { TouchableOpacityProps } from './types'\n\n// Easing.inOut(Easing.quad), the curve of React Native's TouchableOpacity, as a cubic Bézier.\nconst EASE_IN_OUT_QUAD = 'cubic-bezier(0.455, 0.03, 0.515, 0.955)'\nconst DEFAULT_ACTIVE_OPACITY = 0.2\n\nconst notCancelableStyle = Object.freeze({ touchAction: 'none' })\n\nconst isTrue = (value: unknown): boolean | undefined =>\n value === undefined ? undefined : value === true || value === 'true'\n\nconst restingOpacity = (style: StyleProp<ViewStyle> | undefined): number => {\n const opacity = flattenStyle(style)?.opacity\n return typeof opacity === 'number' ? opacity : 1\n}\n\nexport function TouchableOpacity(props: TouchableOpacityProps): ReactElement {\n const {\n activeOpacity,\n children,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n disabled,\n focusable,\n hasTVPreferredFocus: _hasTVPreferredFocus,\n hitSlop,\n nextFocusDown: _nextFocusDown,\n nextFocusForward: _nextFocusForward,\n nextFocusLeft: _nextFocusLeft,\n nextFocusRight: _nextFocusRight,\n nextFocusUp: _nextFocusUp,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n pressRetentionOffset,\n ref,\n rejectResponderTermination,\n style,\n touchSoundDisabled,\n ...rest\n } = props\n\n const element = useRef<HostInstance | null>(null)\n const animation = useRef<Animation | null>(null)\n const resting = restingOpacity(style)\n const resolvedDisabled =\n disabled ?? isTrue(props['aria-disabled']) ?? props.accessibilityState?.disabled\n\n // An imperative animation, as with the native driver: a press doesn't render again. It starts\n // from the current opacity, so a new press takes over a running fade.\n const fadeTo = useCallback((opacity: number, duration: number, settle: boolean) => {\n const node = element.current\n if (node === null || typeof node.animate !== 'function') return\n const from = getComputedStyle(node).opacity\n animation.current?.cancel()\n const next = node.animate([{ opacity: from }, { opacity: String(opacity) }], {\n duration,\n easing: EASE_IN_OUT_QUAD,\n fill: 'forwards',\n })\n animation.current = next\n // Back at rest, the style's opacity takes over again.\n if (settle) {\n next.onfinish = () => {\n if (animation.current !== next) return\n next.cancel()\n animation.current = null\n }\n }\n }, [])\n\n const config = useMemo<PressabilityConfig>(\n () => ({\n cancelable: rejectResponderTermination !== true,\n disabled: resolvedDisabled,\n hitSlop,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n minPressDuration: 0,\n pressRectOffset: pressRetentionOffset,\n android_disableSound: touchSoundDisabled,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn: (event) => {\n // As in React Native: at once when the press starts, over 150 ms when the pointer comes\n // back into the press area.\n const starts = event.type === 'pointerdown' || event.type === 'keydown'\n fadeTo(activeOpacity ?? DEFAULT_ACTIVE_OPACITY, starts ? 0 : 150, false)\n onPressIn?.(event)\n },\n onPressOut: (event) => {\n fadeTo(resting, 250, true)\n onPressOut?.(event)\n },\n }),\n [\n activeOpacity,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n fadeTo,\n hitSlop,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n pressRetentionOffset,\n rejectResponderTermination,\n resolvedDisabled,\n resting,\n touchSoundDisabled,\n ],\n )\n const handlers = usePressability(config)\n const registry = useStyleRegistry()\n\n // As in React Native, a change of `disabled` or of the style's opacity fades to rest.\n const previous = useRef({ disabled, resting })\n useEffect(() => {\n if (previous.current.disabled === disabled && previous.current.resting === resting) return\n previous.current = { disabled, resting }\n fadeTo(resting, 250, true)\n }, [disabled, fadeTo, resting])\n\n useEffect(\n () => () => {\n animation.current?.cancel()\n },\n [],\n )\n\n const view = useViewElement(\n {\n ...rest,\n ...mergeHandlers(rest, handlers),\n ref: element,\n focusable: focusable !== false && onPress !== undefined && disabled !== true,\n style: [\n resolvedDisabled !== true && pointerCursorStyle,\n style,\n rejectResponderTermination === true && notCancelableStyle,\n ],\n children,\n ...(resolvedDisabled === true && { 'aria-disabled': true }),\n },\n hitSlopClass(registry, hitSlop),\n )\n // After useViewElement, which fills `element` in its own imperative handle.\n useImperativeHandle(ref, () => element.current as HostInstance, [])\n return view\n}\n"],"mappings":";;;;;;;;;AAwBA,MAAM,mBAAmB;AACzB,MAAM,yBAAyB;AAE/B,MAAM,qBAAqB,OAAO,OAAO,EAAE,aAAa,OAAO,CAAC;AAEhE,MAAM,UAAU,UACd,UAAU,KAAA,IAAY,KAAA,IAAY,UAAU,QAAQ,UAAU;AAEhE,MAAM,kBAAkB,UAAoD;CAC1E,MAAM,UAAU,aAAa,KAAK,CAAC,EAAE;CACrC,OAAO,OAAO,YAAY,WAAW,UAAU;AACjD;AAEA,SAAgB,iBAAiB,OAA4C;CAC3E,MAAM,EACJ,eACA,UACA,gBACA,cACA,eACA,UACA,WACA,qBAAqB,sBACrB,SACA,eAAe,gBACf,kBAAkB,mBAClB,eAAe,gBACf,gBAAgB,iBAChB,aAAa,cACb,QACA,SACA,aACA,SACA,WACA,YACA,sBACA,KACA,4BACA,OACA,oBACA,GAAG,SACD;CAEJ,MAAM,UAAU,OAA4B,IAAI;CAChD,MAAM,YAAY,OAAyB,IAAI;CAC/C,MAAM,UAAU,eAAe,KAAK;CACpC,MAAM,mBACJ,YAAY,OAAO,MAAM,gBAAgB,KAAK,MAAM,oBAAoB;CAI1E,MAAM,SAAS,aAAa,SAAiB,UAAkB,WAAoB;EACjF,MAAM,OAAO,QAAQ;EACrB,IAAI,SAAS,QAAQ,OAAO,KAAK,YAAY,YAAY;EACzD,MAAM,OAAO,iBAAiB,IAAI,CAAC,CAAC;EACpC,UAAU,SAAS,OAAO;EAC1B,MAAM,OAAO,KAAK,QAAQ,CAAC,EAAE,SAAS,KAAK,GAAG,EAAE,SAAS,OAAO,OAAO,EAAE,CAAC,GAAG;GAC3E;GACA,QAAQ;GACR,MAAM;EACR,CAAC;EACD,UAAU,UAAU;EAEpB,IAAI,QACF,KAAK,iBAAiB;GACpB,IAAI,UAAU,YAAY,MAAM;GAChC,KAAK,OAAO;GACZ,UAAU,UAAU;EACtB;CAEJ,GAAG,CAAC,CAAC;CAEL,MAAM,SAAS,eACN;EACL,YAAY,+BAA+B;EAC3C,UAAU;EACV;EACA;EACA;EACA;EACA,kBAAkB;EAClB,iBAAiB;EACjB,sBAAsB;EACtB;EACA;EACA;EACA;EACA,YAAY,UAAU;GAGpB,MAAM,SAAS,MAAM,SAAS,iBAAiB,MAAM,SAAS;GAC9D,OAAO,iBAAiB,wBAAwB,SAAS,IAAI,KAAK,KAAK;GACvE,YAAY,KAAK;EACnB;EACA,aAAa,UAAU;GACrB,OAAO,SAAS,KAAK,IAAI;GACzB,aAAa,KAAK;EACpB;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,WAAW,gBAAgB,MAAM;CACvC,MAAM,WAAW,iBAAiB;CAGlC,MAAM,WAAW,OAAO;EAAE;EAAU;CAAQ,CAAC;CAC7C,gBAAgB;EACd,IAAI,SAAS,QAAQ,aAAa,YAAY,SAAS,QAAQ,YAAY,SAAS;EACpF,SAAS,UAAU;GAAE;GAAU;EAAQ;EACvC,OAAO,SAAS,KAAK,IAAI;CAC3B,GAAG;EAAC;EAAU;EAAQ;CAAO,CAAC;CAE9B,sBACc;EACV,UAAU,SAAS,OAAO;CAC5B,GACA,CAAC,CACH;CAEA,MAAM,OAAO,eACX;EACE,GAAG;EACH,GAAG,cAAc,MAAM,QAAQ;EAC/B,KAAK;EACL,WAAW,cAAc,SAAS,YAAY,KAAA,KAAa,aAAa;EACxE,OAAO;GACL,qBAAqB,QAAQ;GAC7B;GACA,+BAA+B,QAAQ;EACzC;EACA;EACA,GAAI,qBAAqB,QAAQ,EAAE,iBAAiB,KAAK;CAC3D,GACA,aAAa,UAAU,OAAO,CAChC;CAEA,oBAAoB,WAAW,QAAQ,SAAyB,CAAC,CAAC;CAClE,OAAO;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ViewStyle } from "../../apis/StyleSheet/types.js";
|
|
2
|
+
import { StyleProp } from "../../style/types.js";
|
|
3
|
+
import { TouchablePressProps, TouchableTVProps } from "../TouchableWithoutFeedback/types.js";
|
|
4
|
+
import { ViewProps } from "../View/types.js";
|
|
5
|
+
import { ReactNode } from "react";
|
|
6
|
+
export type TouchableOpacityProps = Omit<ViewProps, "children" | "style" | "onBlur" | "onFocus"> & TouchablePressProps & TouchableTVProps & {
|
|
7
|
+
children?: ReactNode | undefined;
|
|
8
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
9
|
+
activeOpacity?: number | undefined;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TouchableWithoutFeedbackProps } from "./types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
export declare function TouchableWithoutFeedback(props: TouchableWithoutFeedbackProps): ReactElement;
|
|
4
|
+
export type { TouchableWithoutFeedbackProps };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { usePressability } from "../../events/press/usePressability.js";
|
|
2
|
+
import { mergeHandlers } from "../../events/press/mergeHandlers.js";
|
|
3
|
+
import { Children, cloneElement, useMemo } from "react";
|
|
4
|
+
// src/components/TouchableWithoutFeedback/index.tsx
|
|
5
|
+
const isTrue = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
6
|
+
function TouchableWithoutFeedback(props) {
|
|
7
|
+
const { children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hitSlop, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut, pressRetentionOffset, rejectResponderTermination, style: _style, touchSoundDisabled, ...rest } = props;
|
|
8
|
+
const resolvedDisabled = disabled ?? isTrue(props["aria-disabled"]) ?? props.accessibilityState?.disabled;
|
|
9
|
+
const config = useMemo(() => ({
|
|
10
|
+
cancelable: rejectResponderTermination !== true,
|
|
11
|
+
disabled: resolvedDisabled,
|
|
12
|
+
hitSlop,
|
|
13
|
+
delayLongPress,
|
|
14
|
+
delayPressIn,
|
|
15
|
+
delayPressOut,
|
|
16
|
+
minPressDuration: 0,
|
|
17
|
+
pressRectOffset: pressRetentionOffset,
|
|
18
|
+
android_disableSound: touchSoundDisabled,
|
|
19
|
+
onBlur,
|
|
20
|
+
onFocus,
|
|
21
|
+
onLongPress,
|
|
22
|
+
onPress,
|
|
23
|
+
onPressIn,
|
|
24
|
+
onPressOut
|
|
25
|
+
}), [
|
|
26
|
+
delayLongPress,
|
|
27
|
+
delayPressIn,
|
|
28
|
+
delayPressOut,
|
|
29
|
+
hitSlop,
|
|
30
|
+
onBlur,
|
|
31
|
+
onFocus,
|
|
32
|
+
onLongPress,
|
|
33
|
+
onPress,
|
|
34
|
+
onPressIn,
|
|
35
|
+
onPressOut,
|
|
36
|
+
pressRetentionOffset,
|
|
37
|
+
rejectResponderTermination,
|
|
38
|
+
resolvedDisabled,
|
|
39
|
+
touchSoundDisabled
|
|
40
|
+
]);
|
|
41
|
+
const handlers = usePressability(config);
|
|
42
|
+
const element = Children.only(children);
|
|
43
|
+
const passed = {};
|
|
44
|
+
for (const [name, value] of Object.entries(rest)) if (value !== void 0) passed[name] = value;
|
|
45
|
+
if (hitSlop !== void 0) passed["hitSlop"] = hitSlop;
|
|
46
|
+
if (disabled != null) passed["accessibilityState"] = {
|
|
47
|
+
...rest.accessibilityState,
|
|
48
|
+
disabled
|
|
49
|
+
};
|
|
50
|
+
const merged = mergeHandlers(element.props, handlers);
|
|
51
|
+
const childFocus = onFocus === void 0 ? element.props.onFocus : void 0;
|
|
52
|
+
const childBlur = onBlur === void 0 ? element.props.onBlur : void 0;
|
|
53
|
+
return cloneElement(element, {
|
|
54
|
+
...passed,
|
|
55
|
+
...merged,
|
|
56
|
+
onFocus: childFocus === void 0 ? merged.onFocus : (event) => {
|
|
57
|
+
merged.onFocus(event);
|
|
58
|
+
childFocus(event);
|
|
59
|
+
},
|
|
60
|
+
onBlur: childBlur === void 0 ? merged.onBlur : (event) => {
|
|
61
|
+
merged.onBlur(event);
|
|
62
|
+
childBlur(event);
|
|
63
|
+
},
|
|
64
|
+
accessible: rest.accessible !== false,
|
|
65
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export { TouchableWithoutFeedback };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/TouchableWithoutFeedback/index.tsx"],"sourcesContent":["import { Children, cloneElement, useMemo, type ReactElement } from 'react'\n\nimport { usePressability } from '../../events/press'\nimport { mergeHandlers } from '../../events/press/mergeHandlers'\nimport type { PressabilityConfig } from '../../events/press/types'\nimport type { BlurEvent, FocusEvent } from '../../events/types'\nimport type { TouchableWithoutFeedbackProps } from './types'\n\nexport type { TouchableWithoutFeedbackProps } from './types'\n\ntype ChildProps = Record<string, unknown> & {\n onBlur?: ((event: BlurEvent) => unknown) | undefined\n onFocus?: ((event: FocusEvent) => unknown) | undefined\n}\n\nconst isTrue = (value: unknown): boolean | undefined =>\n value === undefined ? undefined : value === true || value === 'true'\n\n// Renders no element of its own. As in React Native, it gives its only child the press\n// handlers and its accessibility props.\nexport function TouchableWithoutFeedback(props: TouchableWithoutFeedbackProps): ReactElement {\n const {\n children,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n disabled,\n focusable,\n hitSlop,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n pressRetentionOffset,\n rejectResponderTermination,\n style: _style,\n touchSoundDisabled,\n ...rest\n } = props\n\n const resolvedDisabled =\n disabled ?? isTrue(props['aria-disabled']) ?? props.accessibilityState?.disabled\n\n const config = useMemo<PressabilityConfig>(\n () => ({\n cancelable: rejectResponderTermination !== true,\n disabled: resolvedDisabled,\n hitSlop,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n minPressDuration: 0,\n pressRectOffset: pressRetentionOffset,\n android_disableSound: touchSoundDisabled,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n }),\n [\n delayLongPress,\n delayPressIn,\n delayPressOut,\n hitSlop,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n pressRetentionOffset,\n rejectResponderTermination,\n resolvedDisabled,\n touchSoundDisabled,\n ],\n )\n const handlers = usePressability(config)\n\n const element = Children.only(children) as ReactElement<ChildProps>\n const passed: Record<string, unknown> = {}\n for (const [name, value] of Object.entries(rest)) {\n if (value !== undefined) passed[name] = value\n }\n if (hitSlop !== undefined) passed['hitSlop'] = hitSlop\n if (disabled != null) passed['accessibilityState'] = { ...rest.accessibilityState, disabled }\n\n const merged = mergeHandlers(element.props, handlers)\n // As in React Native, a focus handler of the Touchable replaces the one of the child. With\n // none, the child keeps its own.\n const childFocus = onFocus === undefined ? element.props.onFocus : undefined\n const childBlur = onBlur === undefined ? element.props.onBlur : undefined\n\n return cloneElement(element, {\n ...passed,\n ...merged,\n onFocus:\n childFocus === undefined\n ? merged.onFocus\n : (event: FocusEvent) => {\n merged.onFocus(event)\n childFocus(event)\n },\n onBlur:\n childBlur === undefined\n ? merged.onBlur\n : (event: BlurEvent) => {\n merged.onBlur(event)\n childBlur(event)\n },\n accessible: rest.accessible !== false,\n focusable: focusable !== false && onPress !== undefined && disabled !== true,\n })\n}\n"],"mappings":";;;;AAeA,MAAM,UAAU,UACd,UAAU,KAAA,IAAY,KAAA,IAAY,UAAU,QAAQ,UAAU;AAIhE,SAAgB,yBAAyB,OAAoD;CAC3F,MAAM,EACJ,UACA,gBACA,cACA,eACA,UACA,WACA,SACA,QACA,SACA,aACA,SACA,WACA,YACA,sBACA,4BACA,OAAO,QACP,oBACA,GAAG,SACD;CAEJ,MAAM,mBACJ,YAAY,OAAO,MAAM,gBAAgB,KAAK,MAAM,oBAAoB;CAE1E,MAAM,SAAS,eACN;EACL,YAAY,+BAA+B;EAC3C,UAAU;EACV;EACA;EACA;EACA;EACA,kBAAkB;EAClB,iBAAiB;EACjB,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,WAAW,gBAAgB,MAAM;CAEvC,MAAM,UAAU,SAAS,KAAK,QAAQ;CACtC,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,IAAI,GAC7C,IAAI,UAAU,KAAA,GAAW,OAAO,QAAQ;CAE1C,IAAI,YAAY,KAAA,GAAW,OAAO,aAAa;CAC/C,IAAI,YAAY,MAAM,OAAO,wBAAwB;EAAE,GAAG,KAAK;EAAoB;CAAS;CAE5F,MAAM,SAAS,cAAc,QAAQ,OAAO,QAAQ;CAGpD,MAAM,aAAa,YAAY,KAAA,IAAY,QAAQ,MAAM,UAAU,KAAA;CACnE,MAAM,YAAY,WAAW,KAAA,IAAY,QAAQ,MAAM,SAAS,KAAA;CAEhE,OAAO,aAAa,SAAS;EAC3B,GAAG;EACH,GAAG;EACH,SACE,eAAe,KAAA,IACX,OAAO,WACN,UAAsB;GACrB,OAAO,QAAQ,KAAK;GACpB,WAAW,KAAK;EAClB;EACN,QACE,cAAc,KAAA,IACV,OAAO,UACN,UAAqB;GACpB,OAAO,OAAO,KAAK;GACnB,UAAU,KAAK;EACjB;EACN,YAAY,KAAK,eAAe;EAChC,WAAW,cAAc,SAAS,YAAY,KAAA,KAAa,aAAa;CAC1E,CAAC;AACH"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ViewStyle } from "../../apis/StyleSheet/types.js";
|
|
2
|
+
import { RectOrSize } from "../../events/press/types.js";
|
|
3
|
+
import { BlurEvent, FocusEvent as FocusEvent$1, GestureResponderEvent } from "../../events/types.js";
|
|
4
|
+
import { StyleProp } from "../../style/types.js";
|
|
5
|
+
import { AccessibilityProps, LayoutChangeEvent } from "../View/types.js";
|
|
6
|
+
import { ReactNode } from "react";
|
|
7
|
+
export type TouchablePressProps = {
|
|
8
|
+
delayLongPress?: number | undefined;
|
|
9
|
+
delayPressIn?: number | undefined;
|
|
10
|
+
delayPressOut?: number | undefined;
|
|
11
|
+
disabled?: boolean | undefined;
|
|
12
|
+
hitSlop?: RectOrSize | undefined;
|
|
13
|
+
onBlur?: ((event: BlurEvent) => unknown) | undefined;
|
|
14
|
+
onFocus?: ((event: FocusEvent$1) => unknown) | undefined;
|
|
15
|
+
onLongPress?: ((event: GestureResponderEvent) => unknown) | undefined;
|
|
16
|
+
onPress?: ((event: GestureResponderEvent) => unknown) | undefined;
|
|
17
|
+
onPressIn?: ((event: GestureResponderEvent) => unknown) | undefined;
|
|
18
|
+
onPressOut?: ((event: GestureResponderEvent) => unknown) | undefined;
|
|
19
|
+
pressRetentionOffset?: RectOrSize | undefined;
|
|
20
|
+
rejectResponderTermination?: boolean | undefined;
|
|
21
|
+
touchSoundDisabled?: boolean | undefined;
|
|
22
|
+
};
|
|
23
|
+
export type TouchableTVProps = {
|
|
24
|
+
hasTVPreferredFocus?: boolean | undefined;
|
|
25
|
+
nextFocusDown?: number | undefined;
|
|
26
|
+
nextFocusForward?: number | undefined;
|
|
27
|
+
nextFocusLeft?: number | undefined;
|
|
28
|
+
nextFocusRight?: number | undefined;
|
|
29
|
+
nextFocusUp?: number | undefined;
|
|
30
|
+
};
|
|
31
|
+
export interface TouchableWithoutFeedbackProps extends AccessibilityProps, TouchablePressProps {
|
|
32
|
+
children?: ReactNode | undefined;
|
|
33
|
+
focusable?: boolean | undefined;
|
|
34
|
+
id?: string | undefined;
|
|
35
|
+
nativeID?: string | undefined;
|
|
36
|
+
testID?: string | undefined;
|
|
37
|
+
onLayout?: ((event: LayoutChangeEvent) => unknown) | undefined;
|
|
38
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AccessibilityActionEvent, AccessibilityProps, AccessibilityState, AccessibilityValue, DOMEventHandlers, HostComponent, HostInstance, HostMethods, LayoutChangeEvent, LayoutRectangle, MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, Role, ViewInstance, ViewProps } from "./types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
export declare function View(props: ViewProps): ReactElement;
|
|
4
|
+
export type { AccessibilityActionEvent, AccessibilityProps, AccessibilityState, AccessibilityValue, DOMEventHandlers, HostComponent, HostInstance, HostMethods, LayoutChangeEvent, LayoutRectangle, MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, Role, ViewInstance, ViewProps };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { toDOMProps } from "../../render/domProps.js";
|
|
2
|
+
import { withHostMethods } from "../../render/hostMethods.js";
|
|
3
|
+
import { resolveTag } from "../../render/resolveTag.js";
|
|
4
|
+
import { useElementLayout } from "../../render/useElementLayout.js";
|
|
5
|
+
import { compileReset, compileStyle, joinClassNames, pointerEventsStyle } from "../../style/compile.js";
|
|
6
|
+
import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
|
|
7
|
+
import { createElement, useImperativeHandle, useRef } from "react";
|
|
8
|
+
// src/components/View/index.tsx
|
|
9
|
+
const resetStyle = Object.freeze({
|
|
10
|
+
alignContent: "flex-start",
|
|
11
|
+
alignItems: "stretch",
|
|
12
|
+
backgroundColor: "transparent",
|
|
13
|
+
border: "0 solid black",
|
|
14
|
+
boxSizing: "border-box",
|
|
15
|
+
display: "flex",
|
|
16
|
+
flexBasis: "auto",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
flexShrink: 0,
|
|
19
|
+
listStyle: "none",
|
|
20
|
+
margin: 0,
|
|
21
|
+
minHeight: 0,
|
|
22
|
+
minWidth: 0,
|
|
23
|
+
padding: 0,
|
|
24
|
+
position: "relative",
|
|
25
|
+
textDecoration: "none",
|
|
26
|
+
zIndex: 0
|
|
27
|
+
});
|
|
28
|
+
function View(props) {
|
|
29
|
+
return useViewElement(props);
|
|
30
|
+
}
|
|
31
|
+
function useViewElement(props, extraClassName) {
|
|
32
|
+
const { children, onLayout, pointerEvents, ref, style, ...rest } = props;
|
|
33
|
+
const element = useRef(null);
|
|
34
|
+
useImperativeHandle(ref, () => withHostMethods(element.current), []);
|
|
35
|
+
useElementLayout(element, onLayout);
|
|
36
|
+
const registry = useStyleRegistry();
|
|
37
|
+
const { tag, role } = resolveTag(rest, "div", children != null);
|
|
38
|
+
let className = joinClassNames(compileReset("rn-view", resetStyle, registry), compileStyle(pointerEvents === void 0 ? style : [style, pointerEventsStyle[pointerEvents]], registry));
|
|
39
|
+
if (extraClassName !== void 0) className = `${className} ${extraClassName}`;
|
|
40
|
+
const domProps = toDOMProps(rest);
|
|
41
|
+
if (role !== void 0) domProps["role"] = role;
|
|
42
|
+
if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
|
|
43
|
+
if (tag === "button") domProps["type"] = "button";
|
|
44
|
+
domProps["className"] = className;
|
|
45
|
+
domProps["ref"] = element;
|
|
46
|
+
return createElement(tag, domProps, children);
|
|
47
|
+
}
|
|
48
|
+
export { View, useViewElement };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/View/index.tsx"],"sourcesContent":["import { createElement, useImperativeHandle, useRef, type ReactElement } from 'react'\n\nimport { toDOMProps } from '../../render/domProps'\nimport { withHostMethods } from '../../render/hostMethods'\nimport { resolveTag } from '../../render/resolveTag'\nimport { useElementLayout } from '../../render/useElementLayout'\nimport { compileReset, compileStyle, joinClassNames, pointerEventsStyle } from '../../style/compile'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport type { ViewProps } from './types'\n\nexport type {\n AccessibilityActionEvent,\n AccessibilityProps,\n AccessibilityState,\n AccessibilityValue,\n DOMEventHandlers,\n HostComponent,\n HostInstance,\n HostMethods,\n LayoutChangeEvent,\n LayoutRectangle,\n MeasureInWindowOnSuccessCallback,\n MeasureLayoutOnSuccessCallback,\n MeasureOnSuccessCallback,\n Role,\n ViewInstance,\n ViewProps,\n} from './types'\n\n// What a native View looks like before any style is applied.\nconst resetStyle = Object.freeze({\n alignContent: 'flex-start',\n alignItems: 'stretch',\n backgroundColor: 'transparent',\n border: '0 solid black',\n boxSizing: 'border-box',\n display: 'flex',\n flexBasis: 'auto',\n flexDirection: 'column',\n flexShrink: 0,\n listStyle: 'none',\n margin: 0,\n minHeight: 0,\n minWidth: 0,\n padding: 0,\n position: 'relative',\n textDecoration: 'none',\n zIndex: 0,\n})\n\nexport function View(props: ViewProps): ReactElement {\n return useViewElement(props)\n}\n\n// Internal. The body of View, with an extra class for components built on it.\nexport function useViewElement(props: ViewProps, extraClassName?: string): ReactElement {\n const { children, onLayout, pointerEvents, ref, style, ...rest } = props\n\n const element = useRef<HTMLElement | null>(null)\n useImperativeHandle(ref, () => withHostMethods(element.current as HTMLElement), [])\n useElementLayout(element, onLayout)\n const registry = useStyleRegistry()\n\n const { tag, role } = resolveTag(rest, 'div', children != null)\n\n let className = joinClassNames(\n compileReset('rn-view', resetStyle, registry),\n compileStyle(\n pointerEvents === undefined ? style : [style, pointerEventsStyle[pointerEvents]],\n registry,\n ),\n )\n if (extraClassName !== undefined) className = `${className} ${extraClassName}`\n\n const domProps = toDOMProps(rest)\n if (role !== undefined) domProps['role'] = role\n if (tag.length === 2 && tag[0] === 'h') delete domProps['aria-level']\n // A button submits its form by default. A React Native button never does.\n if (tag === 'button') domProps['type'] = 'button'\n domProps['className'] = className\n domProps['ref'] = element\n\n return createElement(tag, domProps, children)\n}\n"],"mappings":";;;;;;;;AA8BA,MAAM,aAAa,OAAO,OAAO;CAC/B,cAAc;CACd,YAAY;CACZ,iBAAiB;CACjB,QAAQ;CACR,WAAW;CACX,SAAS;CACT,WAAW;CACX,eAAe;CACf,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,WAAW;CACX,UAAU;CACV,SAAS;CACT,UAAU;CACV,gBAAgB;CAChB,QAAQ;AACV,CAAC;AAED,SAAgB,KAAK,OAAgC;CACnD,OAAO,eAAe,KAAK;AAC7B;AAGA,SAAgB,eAAe,OAAkB,gBAAuC;CACtF,MAAM,EAAE,UAAU,UAAU,eAAe,KAAK,OAAO,GAAG,SAAS;CAEnE,MAAM,UAAU,OAA2B,IAAI;CAC/C,oBAAoB,WAAW,gBAAgB,QAAQ,OAAsB,GAAG,CAAC,CAAC;CAClF,iBAAiB,SAAS,QAAQ;CAClC,MAAM,WAAW,iBAAiB;CAElC,MAAM,EAAE,KAAK,SAAS,WAAW,MAAM,OAAO,YAAY,IAAI;CAE9D,IAAI,YAAY,eACd,aAAa,WAAW,YAAY,QAAQ,GAC5C,aACE,kBAAkB,KAAA,IAAY,QAAQ,CAAC,OAAO,mBAAmB,cAAc,GAC/E,QACF,CACF;CACA,IAAI,mBAAmB,KAAA,GAAW,YAAY,GAAG,UAAU,GAAG;CAE9D,MAAM,WAAW,WAAW,IAAI;CAChC,IAAI,SAAS,KAAA,GAAW,SAAS,UAAU;CAC3C,IAAI,IAAI,WAAW,KAAK,IAAI,OAAO,KAAK,OAAO,SAAS;CAExD,IAAI,QAAQ,UAAU,SAAS,UAAU;CACzC,SAAS,eAAe;CACxB,SAAS,SAAS;CAElB,OAAO,cAAc,KAAK,UAAU,QAAQ;AAC9C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ViewStyle } from "../../apis/StyleSheet/types.js";
|
|
2
|
+
import { NativeSyntheticEvent } from "../../events/types.js";
|
|
3
|
+
import { StyleProp } from "../../style/types.js";
|
|
4
|
+
import { DOMAttributes, ReactNode, Ref } from "react";
|
|
5
|
+
export type MeasureOnSuccessCallback = (x: number, y: number, width: number, height: number, pageX: number, pageY: number) => void;
|
|
6
|
+
export type MeasureInWindowOnSuccessCallback = (x: number, y: number, width: number, height: number) => void;
|
|
7
|
+
export type MeasureLayoutOnSuccessCallback = (left: number, top: number, width: number, height: number) => void;
|
|
8
|
+
export type HostMethods = {
|
|
9
|
+
measure: (callback: MeasureOnSuccessCallback) => void;
|
|
10
|
+
measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void;
|
|
11
|
+
measureLayout: (relativeToNativeNode: Element | number, onSuccess: MeasureLayoutOnSuccessCallback, onFail?: () => void) => void;
|
|
12
|
+
setNativeProps: (nativeProps: object) => void;
|
|
13
|
+
};
|
|
14
|
+
export type HostInstance = HTMLElement & HostMethods;
|
|
15
|
+
export type ViewInstance = HostInstance;
|
|
16
|
+
/**
|
|
17
|
+
* Compat type. The type of a component that a library gets from a native component spec. Its
|
|
18
|
+
* `ref` is the host instance.
|
|
19
|
+
*/
|
|
20
|
+
export type HostComponent<Config extends object> = (props: Omit<Config, "ref"> & {
|
|
21
|
+
ref?: Ref<HostInstance> | undefined;
|
|
22
|
+
}) => ReactNode;
|
|
23
|
+
export type AccessibilityActionEvent = NativeSyntheticEvent<Readonly<{
|
|
24
|
+
actionName: string;
|
|
25
|
+
}>>;
|
|
26
|
+
export type LayoutRectangle = {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
export type LayoutChangeEvent = {
|
|
33
|
+
nativeEvent: {
|
|
34
|
+
layout: LayoutRectangle;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type AccessibilityState = {
|
|
38
|
+
disabled?: boolean | undefined;
|
|
39
|
+
selected?: boolean | undefined;
|
|
40
|
+
checked?: boolean | "mixed" | undefined;
|
|
41
|
+
busy?: boolean | undefined;
|
|
42
|
+
expanded?: boolean | undefined;
|
|
43
|
+
};
|
|
44
|
+
export type AccessibilityValue = {
|
|
45
|
+
min?: number | undefined;
|
|
46
|
+
max?: number | undefined;
|
|
47
|
+
now?: number | undefined;
|
|
48
|
+
text?: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
export type Role = "alert" | "alertdialog" | "application" | "article" | "banner" | "button" | "cell" | "checkbox" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "dialog" | "directory" | "document" | "feed" | "figure" | "form" | "grid" | "group" | "heading" | "img" | "link" | "list" | "listitem" | "log" | "main" | "marquee" | "math" | "menu" | "menubar" | "menuitem" | "meter" | "navigation" | "none" | "note" | "option" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "summary" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem";
|
|
51
|
+
export type DOMEventHandlers<T> = Omit<DOMAttributes<T>, "children" | "dangerouslySetInnerHTML">;
|
|
52
|
+
export interface AccessibilityProps {
|
|
53
|
+
[key: `aria-${string}`]: string | number | boolean | undefined;
|
|
54
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
55
|
+
accessible?: boolean | undefined;
|
|
56
|
+
accessibilityLabel?: string | undefined;
|
|
57
|
+
accessibilityLabelledBy?: string | ReadonlyArray<string> | undefined;
|
|
58
|
+
accessibilityHint?: string | undefined;
|
|
59
|
+
accessibilityRole?: string | undefined;
|
|
60
|
+
accessibilityState?: AccessibilityState | undefined;
|
|
61
|
+
accessibilityValue?: AccessibilityValue | undefined;
|
|
62
|
+
accessibilityLiveRegion?: "none" | "polite" | "assertive" | undefined;
|
|
63
|
+
accessibilityElementsHidden?: boolean | undefined;
|
|
64
|
+
accessibilityViewIsModal?: boolean | undefined;
|
|
65
|
+
importantForAccessibility?: "auto" | "yes" | "no" | "no-hide-descendants" | undefined;
|
|
66
|
+
role?: Role | undefined;
|
|
67
|
+
"aria-busy"?: boolean | undefined;
|
|
68
|
+
"aria-checked"?: boolean | "mixed" | undefined;
|
|
69
|
+
"aria-disabled"?: boolean | undefined;
|
|
70
|
+
"aria-expanded"?: boolean | undefined;
|
|
71
|
+
"aria-hidden"?: boolean | undefined;
|
|
72
|
+
"aria-label"?: string | undefined;
|
|
73
|
+
"aria-labelledby"?: string | undefined;
|
|
74
|
+
"aria-live"?: "polite" | "assertive" | "off" | undefined;
|
|
75
|
+
"aria-modal"?: boolean | undefined;
|
|
76
|
+
"aria-selected"?: boolean | undefined;
|
|
77
|
+
"aria-valuemax"?: number | undefined;
|
|
78
|
+
"aria-valuemin"?: number | undefined;
|
|
79
|
+
"aria-valuenow"?: number | undefined;
|
|
80
|
+
"aria-valuetext"?: string | undefined;
|
|
81
|
+
}
|
|
82
|
+
export interface ViewProps extends AccessibilityProps, DOMEventHandlers<HTMLElement> {
|
|
83
|
+
children?: ReactNode;
|
|
84
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
85
|
+
ref?: Ref<ViewInstance> | undefined;
|
|
86
|
+
id?: string | undefined;
|
|
87
|
+
nativeID?: string | undefined;
|
|
88
|
+
testID?: string | undefined;
|
|
89
|
+
tabIndex?: 0 | -1 | undefined;
|
|
90
|
+
focusable?: boolean | undefined;
|
|
91
|
+
pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
|
|
92
|
+
collapsable?: boolean | undefined;
|
|
93
|
+
onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
|
|
94
|
+
onKeyDown?: DOMEventHandlers<HTMLElement>["onKeyDown"];
|
|
95
|
+
"aria-level"?: number | undefined;
|
|
96
|
+
href?: string | undefined;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
export type OpenGraph = {
|
|
3
|
+
title?: string | undefined;
|
|
4
|
+
description?: string | undefined;
|
|
5
|
+
image?: string | undefined;
|
|
6
|
+
url?: string | undefined;
|
|
7
|
+
type?: string | undefined;
|
|
8
|
+
siteName?: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
export type HeadProps = {
|
|
11
|
+
title?: string | undefined;
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
canonical?: string | undefined;
|
|
14
|
+
robots?: string | undefined;
|
|
15
|
+
themeColor?: string | undefined;
|
|
16
|
+
openGraph?: OpenGraph | undefined;
|
|
17
|
+
jsonLd?: Record<string, unknown> | ReadonlyArray<Record<string, unknown>> | undefined;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
export declare function Head(props: HeadProps): ReactElement;
|
|
21
|
+
//# sourceMappingURL=Head.d.ts.map
|
package/dist/dom/Head.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fragment, createElement } from "react";
|
|
2
|
+
// src/dom/Head.tsx
|
|
3
|
+
const openGraphKeys = [
|
|
4
|
+
["title", "og:title"],
|
|
5
|
+
["description", "og:description"],
|
|
6
|
+
["image", "og:image"],
|
|
7
|
+
["url", "og:url"],
|
|
8
|
+
["type", "og:type"],
|
|
9
|
+
["siteName", "og:site_name"]
|
|
10
|
+
];
|
|
11
|
+
const escapeJSON = (json) => json.replace(/</g, "\\u003c");
|
|
12
|
+
function Head(props) {
|
|
13
|
+
const { canonical, children, description, jsonLd, openGraph, robots, themeColor, title } = props;
|
|
14
|
+
const nodes = [];
|
|
15
|
+
if (title !== void 0) nodes.push(createElement("title", { key: "title" }, title));
|
|
16
|
+
if (description !== void 0) nodes.push(createElement("meta", {
|
|
17
|
+
key: "description",
|
|
18
|
+
name: "description",
|
|
19
|
+
content: description
|
|
20
|
+
}));
|
|
21
|
+
if (robots !== void 0) nodes.push(createElement("meta", {
|
|
22
|
+
key: "robots",
|
|
23
|
+
name: "robots",
|
|
24
|
+
content: robots
|
|
25
|
+
}));
|
|
26
|
+
if (themeColor !== void 0) nodes.push(createElement("meta", {
|
|
27
|
+
key: "theme-color",
|
|
28
|
+
name: "theme-color",
|
|
29
|
+
content: themeColor
|
|
30
|
+
}));
|
|
31
|
+
if (canonical !== void 0) nodes.push(createElement("link", {
|
|
32
|
+
key: "canonical",
|
|
33
|
+
rel: "canonical",
|
|
34
|
+
href: canonical
|
|
35
|
+
}));
|
|
36
|
+
if (openGraph !== void 0) for (const [key, property] of openGraphKeys) {
|
|
37
|
+
const content = openGraph[key];
|
|
38
|
+
if (content !== void 0) nodes.push(createElement("meta", {
|
|
39
|
+
key: property,
|
|
40
|
+
property,
|
|
41
|
+
content
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
if (jsonLd !== void 0) nodes.push(createElement("script", {
|
|
45
|
+
key: "json-ld",
|
|
46
|
+
type: "application/ld+json",
|
|
47
|
+
dangerouslySetInnerHTML: { __html: escapeJSON(JSON.stringify(jsonLd)) }
|
|
48
|
+
}));
|
|
49
|
+
return createElement(Fragment, null, ...nodes, children);
|
|
50
|
+
}
|
|
51
|
+
export { Head };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=Head.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Head.js","names":[],"sources":["../../src/dom/Head.tsx"],"sourcesContent":["import { createElement, Fragment, type ReactElement, type ReactNode } from 'react'\n\nexport type OpenGraph = {\n title?: string | undefined\n description?: string | undefined\n image?: string | undefined\n url?: string | undefined\n type?: string | undefined\n siteName?: string | undefined\n}\n\nexport type HeadProps = {\n title?: string | undefined\n description?: string | undefined\n canonical?: string | undefined\n robots?: string | undefined\n themeColor?: string | undefined\n openGraph?: OpenGraph | undefined\n // One or more schema.org objects, rendered as JSON-LD.\n jsonLd?: Record<string, unknown> | ReadonlyArray<Record<string, unknown>> | undefined\n // Extra head elements: <meta>, <link>, <title>. React moves them into <head>.\n children?: ReactNode\n}\n\nconst openGraphKeys: ReadonlyArray<[keyof OpenGraph, string]> = [\n ['title', 'og:title'],\n ['description', 'og:description'],\n ['image', 'og:image'],\n ['url', 'og:url'],\n ['type', 'og:type'],\n ['siteName', 'og:site_name'],\n]\n\n// A closing tag inside a script would end it early.\nconst escapeJSON = (json: string): string => json.replace(/</g, '\\\\u003c')\n\n// Use one Head per page. React 19 hoists <title>, <meta>, and <link> into <head> on the\n// server and the client, but it does not merge two Heads.\nexport function Head(props: HeadProps): ReactElement {\n const { canonical, children, description, jsonLd, openGraph, robots, themeColor, title } = props\n const nodes: ReactNode[] = []\n\n if (title !== undefined) nodes.push(createElement('title', { key: 'title' }, title))\n if (description !== undefined) {\n nodes.push(\n createElement('meta', { key: 'description', name: 'description', content: description }),\n )\n }\n if (robots !== undefined) {\n nodes.push(createElement('meta', { key: 'robots', name: 'robots', content: robots }))\n }\n if (themeColor !== undefined) {\n nodes.push(\n createElement('meta', { key: 'theme-color', name: 'theme-color', content: themeColor }),\n )\n }\n if (canonical !== undefined) {\n nodes.push(createElement('link', { key: 'canonical', rel: 'canonical', href: canonical }))\n }\n if (openGraph !== undefined) {\n for (const [key, property] of openGraphKeys) {\n const content = openGraph[key]\n if (content !== undefined)\n nodes.push(createElement('meta', { key: property, property, content }))\n }\n }\n if (jsonLd !== undefined) {\n nodes.push(\n createElement('script', {\n key: 'json-ld',\n type: 'application/ld+json',\n dangerouslySetInnerHTML: { __html: escapeJSON(JSON.stringify(jsonLd)) },\n }),\n )\n }\n\n return createElement(Fragment, null, ...nodes, children)\n}\n"],"mappings":";;AAwBA,MAAM,gBAA0D;CAC9D,CAAC,SAAS,UAAU;CACpB,CAAC,eAAe,gBAAgB;CAChC,CAAC,SAAS,UAAU;CACpB,CAAC,OAAO,QAAQ;CAChB,CAAC,QAAQ,SAAS;CAClB,CAAC,YAAY,cAAc;AAC7B;AAGA,MAAM,cAAc,SAAyB,KAAK,QAAQ,MAAM,SAAS;AAIzE,SAAgB,KAAK,OAAgC;CACnD,MAAM,EAAE,WAAW,UAAU,aAAa,QAAQ,WAAW,QAAQ,YAAY,UAAU;CAC3F,MAAM,QAAqB,CAAC;CAE5B,IAAI,UAAU,KAAA,GAAW,MAAM,KAAK,cAAc,SAAS,EAAE,KAAK,QAAQ,GAAG,KAAK,CAAC;CACnF,IAAI,gBAAgB,KAAA,GAClB,MAAM,KACJ,cAAc,QAAQ;EAAE,KAAK;EAAe,MAAM;EAAe,SAAS;CAAY,CAAC,CACzF;CAEF,IAAI,WAAW,KAAA,GACb,MAAM,KAAK,cAAc,QAAQ;EAAE,KAAK;EAAU,MAAM;EAAU,SAAS;CAAO,CAAC,CAAC;CAEtF,IAAI,eAAe,KAAA,GACjB,MAAM,KACJ,cAAc,QAAQ;EAAE,KAAK;EAAe,MAAM;EAAe,SAAS;CAAW,CAAC,CACxF;CAEF,IAAI,cAAc,KAAA,GAChB,MAAM,KAAK,cAAc,QAAQ;EAAE,KAAK;EAAa,KAAK;EAAa,MAAM;CAAU,CAAC,CAAC;CAE3F,IAAI,cAAc,KAAA,GAChB,KAAK,MAAM,CAAC,KAAK,aAAa,eAAe;EAC3C,MAAM,UAAU,UAAU;EAC1B,IAAI,YAAY,KAAA,GACd,MAAM,KAAK,cAAc,QAAQ;GAAE,KAAK;GAAU;GAAU;EAAQ,CAAC,CAAC;CAC1E;CAEF,IAAI,WAAW,KAAA,GACb,MAAM,KACJ,cAAc,UAAU;EACtB,KAAK;EACL,MAAM;EACN,yBAAyB,EAAE,QAAQ,WAAW,KAAK,UAAU,MAAM,CAAC,EAAE;CACxE,CAAC,CACH;CAGF,OAAO,cAAc,UAAU,MAAM,GAAG,OAAO,QAAQ;AACzD"}
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type OpenGraph
|
|
3
|
-
title?: string | undefined;
|
|
4
|
-
description?: string | undefined;
|
|
5
|
-
image?: string | undefined;
|
|
6
|
-
url?: string | undefined;
|
|
7
|
-
type?: string | undefined;
|
|
8
|
-
siteName?: string | undefined;
|
|
9
|
-
};
|
|
10
|
-
type HeadProps = {
|
|
11
|
-
title?: string | undefined;
|
|
12
|
-
description?: string | undefined;
|
|
13
|
-
canonical?: string | undefined;
|
|
14
|
-
robots?: string | undefined;
|
|
15
|
-
themeColor?: string | undefined;
|
|
16
|
-
openGraph?: OpenGraph | undefined;
|
|
17
|
-
jsonLd?: Record<string, unknown> | ReadonlyArray<Record<string, unknown>> | undefined;
|
|
18
|
-
children?: ReactNode;
|
|
19
|
-
};
|
|
20
|
-
export declare function Head(props: HeadProps): ReactElement;
|
|
21
|
-
export type { HeadProps, OpenGraph };
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { Head, HeadProps, OpenGraph } from "./Head.js";
|
|
2
|
+
export { Head, type HeadProps, type OpenGraph };
|