decord/source/design/components/ContextMenu/native/ContextMenuItem.native.tsx

234 lines
9.7 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 13623
// Function ID: 13624
2026-07-20 16:05:17 +00:00
// Name: ContextMenuItem
2026-08-25 06:04:03 +00:00
// Dependencies: [19, 17, 21, 4120, 4380, 8747, 712, 1367, 8746, 4814, 4818, 4817, 4376, 2]
2026-07-20 16:05:17 +00:00
// Exports: ContextMenuItem
2026-08-25 06:04:03 +00:00
// Module 13623 (ContextMenuItem)
2026-08-24 06:08:38 +00:00
import ThemesDefault from "Themes" /* 712 */;
2026-08-25 06:04:03 +00:00
import CONTEXT_MENU_LONG_PRESS_DURATION_MS from "CONTEXT_MENU_LONG_PRESS_DURATION_MS" /* 8747 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "noop" /* 19 */;
import jsxProd from "jsxProd" /* 21 */;
2026-08-25 06:04:03 +00:00
import createCacheKey from "createCacheKey" /* 4380 */;
import importDefaultResult from "module_4120" /* 4120 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-29 08:29:29 +00:00
({ jsx: c4, jsxs: c5 } = jsxProd);
2026-08-24 06:08:38 +00:00
let closure_6 = importDefaultResult.createAnimatedComponent(require("get ActivityIndicator").Pressable);
2026-07-29 08:29:29 +00:00
let closure_7 = createCacheKey.createStyles((arg0) => {
let obj = { container: null, containerRefresh: null, roundedTop: null, roundedBottom: null, border: null, pressed: null, icon: null, label: null, trailingIndicator: null };
2026-08-24 06:08:38 +00:00
obj = { padding: CONTEXT_MENU_LONG_PRESS_DURATION_MS.CONTEXT_MENU_ITEM_PADDING, minHeight: CONTEXT_MENU_LONG_PRESS_DURATION_MS.CONTEXT_MENU_ITEM_BASE_HEIGHT, flexDirection: "row", justifyContent: "space-between", alignItems: "center", gap: 8 };
2026-07-29 08:29:29 +00:00
obj[0] = obj;
obj[1] = { justifyContent: "flex-start" };
2026-08-24 06:08:38 +00:00
obj = { borderTopLeftRadius: ThemesDefault.radii.lg, borderTopRightRadius: ThemesDefault.radii.lg };
2026-07-29 08:29:29 +00:00
obj[2] = obj;
2026-08-24 06:08:38 +00:00
obj[3] = { borderBottomLeftRadius: ThemesDefault.radii.lg, borderBottomRightRadius: ThemesDefault.radii.lg };
obj1 = { borderBottomLeftRadius: ThemesDefault.radii.lg, borderBottomRightRadius: ThemesDefault.radii.lg };
obj[4] = { borderBottomWidth: 1, borderBottomColor: ThemesDefault.colors.BORDER_SUBTLE };
const obj2 = { borderBottomWidth: 1, borderBottomColor: ThemesDefault.colors.BORDER_SUBTLE };
obj[5] = { backgroundColor: ThemesDefault.colors.BACKGROUND_MOD_SUBTLE };
2026-07-20 16:05:17 +00:00
if ("destructive" === arg0) {
2026-07-29 08:29:29 +00:00
let TEXT_STRONG = tmp2(712).colors.TEXT_FEEDBACK_CRITICAL;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
TEXT_STRONG = tmp2(712).colors.TEXT_STRONG;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[6] = { width: 20, height: 20, tintColor: TEXT_STRONG };
obj[7] = { flexShrink: 1 };
obj[8] = { marginLeft: "auto" };
2026-07-20 16:05:17 +00:00
return obj;
});
let closure_8 = { code: "function ContextMenuItemNativeTsx1(){const{pan}=this.__closure;return pan.get();}" };
let closure_9 = { code: "function ContextMenuItemNativeTsx2(_current,previous){const{measure,ref,index,INDEX_BOUNDS_OFFSET,itemMeasurements,INDEX_BOUNDS_PAGE_X_OFFSET,INDEX_BOUNDS_PAGE_Y_OFFSET,INDEX_BOUNDS_WIDTH_OFFSET,INDEX_BOUNDS_HEIGHT_OFFSET}=this.__closure;if(previous==null||_current===previous)return;const measurements=measure(ref);if(measurements!=null){const{pageX:pageX,pageY:pageY,width:width,height:height}=measurements;const offset=index*INDEX_BOUNDS_OFFSET;itemMeasurements.get()[offset+INDEX_BOUNDS_PAGE_X_OFFSET]=pageX;itemMeasurements.get()[offset+INDEX_BOUNDS_PAGE_Y_OFFSET]=pageY;itemMeasurements.get()[offset+INDEX_BOUNDS_WIDTH_OFFSET]=width;itemMeasurements.get()[offset+INDEX_BOUNDS_HEIGHT_OFFSET]=height;}}" };
let closure_10 = { code: "function ContextMenuItemNativeTsx3(){const{activeIndex,index,pressed,withSpring,backgroundColor,SUBTLE_SPRING}=this.__closure;const isActive=activeIndex.get()===index||pressed.get()===1;return{backgroundColor:withSpring(isActive?backgroundColor:'transparent',SUBTLE_SPRING,'animate-always')};}" };
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("design/components/ContextMenu/native/ContextMenuItem.native.tsx");
2026-07-20 16:05:17 +00:00
export const ContextMenuItem = function ContextMenuItem(accessibilityRole) {
({ IconComponent, trailingIndicator, iconSource, start, end, index } = accessibilityRole);
({ state, variant } = accessibilityRole);
({ label, lastInSection, onPress } = accessibilityRole);
if (variant === undefined) {
variant = "default";
}
let str = accessibilityRole.accessibilityRole;
if (str === undefined) {
str = "button";
}
2026-07-23 10:11:24 +00:00
let animatedRef;
let pan;
let itemMeasurements;
2026-07-20 16:05:17 +00:00
let activeIndex;
let sharedValue;
2026-07-23 10:11:24 +00:00
let backgroundColor;
let obj = index(pan[3]);
animatedRef = obj.useAnimatedRef();
2026-07-29 08:29:29 +00:00
const tmp4 = callback(variant);
const tmp6 = animatedRef(pan[7])("ContextMenuItem");
2026-07-23 10:11:24 +00:00
pan = state.pan;
itemMeasurements = state.itemMeasurements;
2026-07-20 16:05:17 +00:00
activeIndex = state.activeIndex;
2026-08-24 06:08:38 +00:00
obj1 = index(pan[3]);
2026-07-20 16:05:17 +00:00
sharedValue = obj1.useSharedValue(0);
2026-07-23 10:11:24 +00:00
let obj2 = index(pan[3]);
2026-07-20 16:05:17 +00:00
class U {
constructor() {
return pan.get();
}
}
U.__closure = { pan };
U.__workletHash = 11852115418144;
U.__initData = closure_8;
const fn = function p(arg0, arg1) {
if (null != arg1) {
if (arg0 !== arg1) {
const measureResult = index(pan[3]).measure(animatedRef);
if (null != measureResult) {
({ pageX, pageY, width, height } = measureResult);
2026-07-29 08:29:29 +00:00
const result = index * tmp2(tmp3[8]).INDEX_BOUNDS_OFFSET;
2026-07-20 16:05:17 +00:00
let value = itemMeasurements.get();
2026-07-29 08:29:29 +00:00
value[result + tmp2(tmp3[8]).INDEX_BOUNDS_PAGE_X_OFFSET] = pageX;
2026-07-20 16:05:17 +00:00
value = itemMeasurements.get();
2026-07-29 08:29:29 +00:00
value[result + tmp2(tmp3[8]).INDEX_BOUNDS_PAGE_Y_OFFSET] = pageY;
2026-07-20 16:05:17 +00:00
const value1 = itemMeasurements.get();
2026-07-29 08:29:29 +00:00
value1[result + tmp2(tmp3[8]).INDEX_BOUNDS_WIDTH_OFFSET] = width;
2026-07-20 16:05:17 +00:00
const value2 = itemMeasurements.get();
2026-07-29 08:29:29 +00:00
value2[result + tmp2(tmp3[8]).INDEX_BOUNDS_HEIGHT_OFFSET] = height;
2026-07-20 16:05:17 +00:00
}
const obj = index(pan[3]);
}
}
};
2026-07-23 10:11:24 +00:00
obj = { measure: index(pan[3]).measure, ref: animatedRef, index, INDEX_BOUNDS_OFFSET: index(pan[8]).INDEX_BOUNDS_OFFSET, itemMeasurements, INDEX_BOUNDS_PAGE_X_OFFSET: index(pan[8]).INDEX_BOUNDS_PAGE_X_OFFSET, INDEX_BOUNDS_PAGE_Y_OFFSET: index(pan[8]).INDEX_BOUNDS_PAGE_Y_OFFSET, INDEX_BOUNDS_WIDTH_OFFSET: index(pan[8]).INDEX_BOUNDS_WIDTH_OFFSET, INDEX_BOUNDS_HEIGHT_OFFSET: index(pan[8]).INDEX_BOUNDS_HEIGHT_OFFSET };
2026-07-20 16:05:17 +00:00
fn.__closure = obj;
fn.__workletHash = 9571959267234;
fn.__initData = closure_9;
const animatedReaction = obj2.useAnimatedReaction(U, fn);
2026-07-29 08:29:29 +00:00
backgroundColor = tmp4.pressed.backgroundColor;
2026-07-23 10:11:24 +00:00
let obj4 = index(pan[3]);
2026-07-20 16:05:17 +00:00
class R {
constructor() {
tmp = activeIndex.get() === index;
if (!tmp) {
2026-08-24 06:08:38 +00:00
tmp2 = closure_5;
2026-07-20 16:05:17 +00:00
num = 1;
2026-08-24 06:08:38 +00:00
tmp = 1 === closure_5.get();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp3 = index;
tmp4 = pan;
obj = index(pan[9]);
2026-07-20 16:05:17 +00:00
str = "transparent";
if (tmp) {
str = backgroundColor;
}
2026-07-29 08:29:29 +00:00
obj = { backgroundColor: obj.withSpring(str, tmp3(tmp4[10]).SUBTLE_SPRING, "animate-always") };
2026-07-20 16:05:17 +00:00
return obj;
}
}
2026-07-23 10:11:24 +00:00
obj = { activeIndex, index, pressed: sharedValue, withSpring: index(pan[9]).withSpring, backgroundColor, SUBTLE_SPRING: index(pan[10]).SUBTLE_SPRING };
2026-07-20 16:05:17 +00:00
R.__closure = obj;
R.__workletHash = 624481847983;
R.__initData = closure_10;
const animatedStyle = obj4.useAnimatedStyle(R);
if (null != IconComponent) {
2026-07-29 08:29:29 +00:00
obj1 = { size: "sm", color: null };
obj1[1] = tmp4.icon.tintColor;
let tmp10 = activeIndex(IconComponent, obj1);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
tmp10 = null;
2026-07-20 16:05:17 +00:00
if (null != iconSource) {
2026-07-29 08:29:29 +00:00
obj2 = { source: null, style: null };
obj2[0] = iconSource;
obj2[1] = tmp4.icon;
tmp10 = activeIndex(tmp5(tmp2[11]), obj2);
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
let tmp13 = null;
2026-07-20 16:05:17 +00:00
if (null != trailingIndicator) {
2026-07-29 08:29:29 +00:00
const obj3 = { size: "sm", color: null };
obj3[1] = tmp4.icon.tintColor;
tmp13 = activeIndex(trailingIndicator, obj3);
2026-07-20 16:05:17 +00:00
}
const items = [index, itemMeasurements];
const items1 = [activeIndex, index];
2026-07-23 10:11:24 +00:00
callback = itemMeasurements.useCallback((nativeEvent) => {
2026-07-20 16:05:17 +00:00
({ height, width } = nativeEvent.nativeEvent.layout);
if (0 !== height) {
if (0 !== width) {
const result = index * index(pan[8]).INDEX_BOUNDS_OFFSET;
let value = itemMeasurements.get();
value[result + index(pan[8]).INDEX_BOUNDS_HEIGHT_OFFSET] = height;
value = itemMeasurements.get();
value[result + index(pan[8]).INDEX_BOUNDS_WIDTH_OFFSET] = width;
}
}
}, items);
const items2 = [activeIndex];
2026-07-23 10:11:24 +00:00
const callback1 = itemMeasurements.useCallback(() => {
2026-07-20 16:05:17 +00:00
const result = activeIndex.set(index);
}, items1);
2026-07-29 08:29:29 +00:00
obj4 = { ref: animatedRef, style: null, onLayout: null, onPressIn: null, onPressOut: null, onPress: null, accessibilityRole: null, children: null };
const items3 = [tmp4.container, , , , , ];
let containerRefresh = tmp6;
2026-07-23 10:11:24 +00:00
const callback2 = itemMeasurements.useCallback(() => {
2026-07-20 16:05:17 +00:00
const result = activeIndex.set(-1);
}, items2);
2026-07-29 08:29:29 +00:00
if (tmp6) {
containerRefresh = tmp4.containerRefresh;
2026-07-20 16:05:17 +00:00
}
items3[1] = containerRefresh;
2026-07-29 08:29:29 +00:00
let border = !end;
if (!end) {
border = !lastInSection;
}
if (border) {
border = tmp4.border;
}
items3[2] = border;
2026-07-20 16:05:17 +00:00
if (start) {
2026-07-29 08:29:29 +00:00
start = tmp4.roundedTop;
2026-07-20 16:05:17 +00:00
}
items3[3] = start;
if (end) {
2026-07-29 08:29:29 +00:00
end = tmp4.roundedBottom;
2026-07-20 16:05:17 +00:00
}
items3[4] = end;
items3[5] = animatedStyle;
2026-07-29 08:29:29 +00:00
obj4[1] = items3;
obj4[2] = callback;
obj4[3] = callback1;
obj4[4] = callback2;
obj4[5] = onPress;
obj4[6] = str;
let tmp20 = tmp6;
if (tmp6) {
const obj5 = { children: null };
obj5[0] = tmp10;
tmp20 = activeIndex(tmp5(tmp2[3]).View, obj5);
}
const items4 = [tmp20, , , ];
const obj6 = { animated: true, variant: "text-md/medium", style: tmp4.label, color: null, children: null };
let str2 = "text-strong";
2026-07-20 16:05:17 +00:00
if ("destructive" === variant) {
2026-07-29 08:29:29 +00:00
str2 = "text-feedback-critical";
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj6[3] = str2;
obj6[4] = label;
2026-07-23 10:11:24 +00:00
items4[1] = activeIndex(index(pan[12]).Text, obj6);
2026-07-29 08:29:29 +00:00
let tmp22Result = !tmp6;
if (!tmp6) {
const obj7 = { children: null };
obj7[0] = tmp10;
tmp22Result = tmp22(tmp5(tmp2[3]).View, obj7);
}
items4[2] = tmp22Result;
tmp22Result = null != tmp13;
if (tmp22Result) {
const obj8 = { style: null, children: null };
obj8[0] = tmp4.trailingIndicator;
obj8[1] = tmp13;
tmp22Result = tmp22(tmp5(tmp2[3]).View, obj8);
}
items4[3] = tmp22Result;
obj4[7] = items4;
2026-07-23 10:11:24 +00:00
return sharedValue(backgroundColor, obj4);
2026-07-20 16:05:17 +00:00
};