@yahoo/uds-mobile 2.2.0 → 2.3.1
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/README.md +92 -0
- package/dist/_virtual/_rolldown/runtime.cjs +14 -0
- package/dist/_virtual/_rolldown/runtime.js +19 -0
- package/dist/components/Switch.cjs +2 -2
- package/dist/components/Switch.js +2 -2
- package/dist/components/Switch.js.map +1 -1
- package/dist/jest/index.cjs +27 -0
- package/dist/jest/index.d.cts +19 -0
- package/dist/jest/index.d.cts.map +1 -0
- package/dist/jest/index.d.ts +19 -0
- package/dist/jest/index.d.ts.map +1 -0
- package/dist/jest/index.js +25 -0
- package/dist/jest/index.js.map +1 -0
- package/dist/jest/mocks/icons.cjs +56 -0
- package/dist/jest/mocks/icons.d.cts +24 -0
- package/dist/jest/mocks/icons.d.cts.map +1 -0
- package/dist/jest/mocks/icons.d.ts +24 -0
- package/dist/jest/mocks/icons.d.ts.map +1 -0
- package/dist/jest/mocks/icons.js +46 -0
- package/dist/jest/mocks/icons.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +212 -0
- package/dist/jest/mocks/react-native.d.cts +293 -0
- package/dist/jest/mocks/react-native.d.cts.map +1 -0
- package/dist/jest/mocks/react-native.d.ts +293 -0
- package/dist/jest/mocks/react-native.d.ts.map +1 -0
- package/dist/jest/mocks/react-native.js +180 -0
- package/dist/jest/mocks/react-native.js.map +1 -0
- package/dist/jest/mocks/reanimated.cjs +249 -0
- package/dist/jest/mocks/reanimated.d.cts +150 -0
- package/dist/jest/mocks/reanimated.d.cts.map +1 -0
- package/dist/jest/mocks/reanimated.d.ts +150 -0
- package/dist/jest/mocks/reanimated.d.ts.map +1 -0
- package/dist/jest/mocks/reanimated.js +210 -0
- package/dist/jest/mocks/reanimated.js.map +1 -0
- package/dist/jest/mocks/styles.cjs +327 -0
- package/dist/jest/mocks/styles.d.cts +33 -0
- package/dist/jest/mocks/styles.d.cts.map +1 -0
- package/dist/jest/mocks/styles.d.ts +33 -0
- package/dist/jest/mocks/styles.d.ts.map +1 -0
- package/dist/jest/mocks/styles.js +310 -0
- package/dist/jest/mocks/styles.js.map +1 -0
- package/dist/jest/mocks/svg.cjs +133 -0
- package/dist/jest/mocks/svg.d.cts +137 -0
- package/dist/jest/mocks/svg.d.cts.map +1 -0
- package/dist/jest/mocks/svg.d.ts +137 -0
- package/dist/jest/mocks/svg.d.ts.map +1 -0
- package/dist/jest/mocks/svg.js +100 -0
- package/dist/jest/mocks/svg.js.map +1 -0
- package/dist/jest/mocks/unistyles.cjs +143 -0
- package/dist/jest/mocks/unistyles.d.cts +197 -0
- package/dist/jest/mocks/unistyles.d.cts.map +1 -0
- package/dist/jest/mocks/unistyles.d.ts +197 -0
- package/dist/jest/mocks/unistyles.d.ts.map +1 -0
- package/dist/jest/mocks/unistyles.js +132 -0
- package/dist/jest/mocks/unistyles.js.map +1 -0
- package/dist/jest/setup.cjs +40 -0
- package/dist/jest/setup.d.cts +11 -0
- package/dist/jest/setup.d.cts.map +1 -0
- package/dist/jest/setup.d.ts +11 -0
- package/dist/jest/setup.d.ts.map +1 -0
- package/dist/jest/setup.js +39 -0
- package/dist/jest/setup.js.map +1 -0
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/generated/styles.cjs +46 -0
- package/generated/styles.d.ts +17 -0
- package/generated/styles.mjs +46 -0
- package/generated/unistyles.d.ts +25 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- [Icons](#icons)
|
|
10
10
|
- [Fonts](#fonts)
|
|
11
11
|
- [CLI](#cli)
|
|
12
|
+
- [Testing](#testing)
|
|
12
13
|
- [Contributing](#contributing)
|
|
13
14
|
- [API Reference](#api-reference)
|
|
14
15
|
|
|
@@ -553,6 +554,97 @@ export const breakpoints = {
|
|
|
553
554
|
};
|
|
554
555
|
```
|
|
555
556
|
|
|
557
|
+
## Testing
|
|
558
|
+
|
|
559
|
+
### Jest Setup
|
|
560
|
+
|
|
561
|
+
UDS Mobile ships Jest mocks for native dependencies that don't work in Jest/JSDOM, allowing **real UDS components** to be tested without native module errors. This approach ensures your tests validate actual component behavior.
|
|
562
|
+
|
|
563
|
+
#### Quick Start
|
|
564
|
+
|
|
565
|
+
Add the setup file to your Jest config:
|
|
566
|
+
|
|
567
|
+
```js
|
|
568
|
+
// jest.config.js
|
|
569
|
+
module.exports = {
|
|
570
|
+
preset: 'react-native',
|
|
571
|
+
setupFilesAfterEnv: ['@yahoo/uds-mobile/jest'],
|
|
572
|
+
transformIgnorePatterns: [
|
|
573
|
+
'node_modules/(?!(@yahoo/uds-mobile|@yahoo/uds-icons|react-native|@react-native)/)',
|
|
574
|
+
],
|
|
575
|
+
};
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
Or import manually in your setup file:
|
|
579
|
+
|
|
580
|
+
```js
|
|
581
|
+
// jest.setup.js
|
|
582
|
+
import '@yahoo/uds-mobile/jest';
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
#### What Gets Mocked
|
|
586
|
+
|
|
587
|
+
The setup automatically mocks these native dependencies:
|
|
588
|
+
|
|
589
|
+
| Package | What's Mocked |
|
|
590
|
+
| ------------------------- | ----------------------------------------------------------------------------------- |
|
|
591
|
+
| `react-native-unistyles` | `useUnistyles()`, `StyleSheet.create()`, `UnistylesRuntime` |
|
|
592
|
+
| `react-native-reanimated` | Animated components, hooks (`useSharedValue`, `useAnimatedStyle`), timing functions |
|
|
593
|
+
| `react-native-svg` | `SvgXml`, SVG shape components |
|
|
594
|
+
| `@yahoo/uds-icons` | `glyphMap`, `svgMap`, `ICON_SIZE_MAP` |
|
|
595
|
+
|
|
596
|
+
#### Example Test
|
|
597
|
+
|
|
598
|
+
```tsx
|
|
599
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
600
|
+
import { Button } from '@yahoo/uds-mobile/Button';
|
|
601
|
+
import { Text } from '@yahoo/uds-mobile/Text';
|
|
602
|
+
import { VStack } from '@yahoo/uds-mobile/VStack';
|
|
603
|
+
|
|
604
|
+
test('renders button with text and handles press', () => {
|
|
605
|
+
const onPress = jest.fn();
|
|
606
|
+
|
|
607
|
+
const { getByRole, getByText } = render(
|
|
608
|
+
<VStack>
|
|
609
|
+
<Button variant="primary" onPress={onPress}>
|
|
610
|
+
Save
|
|
611
|
+
</Button>
|
|
612
|
+
</VStack>,
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
expect(getByText('Save')).toBeTruthy();
|
|
616
|
+
|
|
617
|
+
fireEvent.press(getByRole('button'));
|
|
618
|
+
expect(onPress).toHaveBeenCalled();
|
|
619
|
+
});
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
#### Benefits
|
|
623
|
+
|
|
624
|
+
- **Real component testing**: Tests validate actual component behavior, not stubs
|
|
625
|
+
- **No native module errors**: Required native dependencies are properly mocked
|
|
626
|
+
- **Zero configuration**: Just add the setup file and transformIgnorePatterns
|
|
627
|
+
- **Catches regressions**: Tests break when component behavior changes
|
|
628
|
+
|
|
629
|
+
#### Manual Mock Access
|
|
630
|
+
|
|
631
|
+
If you need to customize mocks, individual modules are exported:
|
|
632
|
+
|
|
633
|
+
```js
|
|
634
|
+
import { mocks } from '@yahoo/uds-mobile/jest';
|
|
635
|
+
|
|
636
|
+
// Override a specific mock
|
|
637
|
+
jest.mock('react-native-unistyles', () => ({
|
|
638
|
+
...mocks.unistyles,
|
|
639
|
+
useUnistyles: () => ({
|
|
640
|
+
theme: {
|
|
641
|
+
/* custom theme */
|
|
642
|
+
},
|
|
643
|
+
rt: { themeName: 'dark' },
|
|
644
|
+
}),
|
|
645
|
+
}));
|
|
646
|
+
```
|
|
647
|
+
|
|
556
648
|
## Contributing
|
|
557
649
|
|
|
558
650
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development workflow, architecture details, and internal documentation.
|
|
@@ -6,6 +6,19 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) {
|
|
12
|
+
__defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (!no_symbols) {
|
|
18
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
9
22
|
var __copyProps = (to, from, except, desc) => {
|
|
10
23
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
24
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -27,4 +40,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
40
|
|
|
28
41
|
//#endregion
|
|
29
42
|
|
|
43
|
+
exports.__exportAll = __exportAll;
|
|
30
44
|
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) {
|
|
7
|
+
__defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (!no_symbols) {
|
|
13
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { __exportAll };
|
|
@@ -134,7 +134,7 @@ const Switch = (0, react.memo)(function Switch({ isOn: isOnProp, defaultIsOn = f
|
|
|
134
134
|
...viewProps,
|
|
135
135
|
style: rootStyle,
|
|
136
136
|
children: [
|
|
137
|
-
labelPosition === "
|
|
137
|
+
labelPosition === "start" && labelContent,
|
|
138
138
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
139
139
|
style: trackStyle,
|
|
140
140
|
importantForAccessibility: "no-hide-descendants",
|
|
@@ -157,7 +157,7 @@ const Switch = (0, react.memo)(function Switch({ isOn: isOnProp, defaultIsOn = f
|
|
|
157
157
|
})]
|
|
158
158
|
})
|
|
159
159
|
}),
|
|
160
|
-
labelPosition === "
|
|
160
|
+
labelPosition === "end" && labelContent
|
|
161
161
|
]
|
|
162
162
|
});
|
|
163
163
|
});
|
|
@@ -131,7 +131,7 @@ const Switch = memo(function Switch({ isOn: isOnProp, defaultIsOn = false, onCha
|
|
|
131
131
|
...viewProps,
|
|
132
132
|
style: rootStyle,
|
|
133
133
|
children: [
|
|
134
|
-
labelPosition === "
|
|
134
|
+
labelPosition === "start" && labelContent,
|
|
135
135
|
/* @__PURE__ */ jsx(Animated.View, {
|
|
136
136
|
style: trackStyle,
|
|
137
137
|
importantForAccessibility: "no-hide-descendants",
|
|
@@ -154,7 +154,7 @@ const Switch = memo(function Switch({ isOn: isOnProp, defaultIsOn = false, onCha
|
|
|
154
154
|
})]
|
|
155
155
|
})
|
|
156
156
|
}),
|
|
157
|
-
labelPosition === "
|
|
157
|
+
labelPosition === "end" && labelContent
|
|
158
158
|
]
|
|
159
159
|
});
|
|
160
160
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","names":["Text","StyleSheet"],"sources":["../../src/components/Switch.tsx"],"sourcesContent":["import type { SwitchSize, UniversalSwitchProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport type { AccessibilityProps, StyleProp, View, ViewProps, ViewStyle } from 'react-native';\nimport { AccessibilityInfo, Pressable } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withTiming } from 'react-native-reanimated';\nimport { StyleSheet } from 'react-native-unistyles';\nimport { useAnimatedVariantColor } from 'react-native-unistyles/reanimated';\n\nimport { switchStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Text } from './Text';\n\ninterface SwitchProps extends Omit<ViewProps, 'style'>, UniversalSwitchProps<IconSlotType> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Callback when the switch value changes */\n onChange?: (value: boolean) => void;\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Whether the switch is required (shows asterisk with label) */\n required?: boolean;\n /** Accessibility hint describing what happens when activated */\n accessibilityHint?: AccessibilityProps['accessibilityHint'];\n}\n\nconst HANDLE_TRAVEL: Record<SwitchSize, number> = {\n md: 20,\n sm: 12,\n};\n\nconst ANIMATION_DURATION = 120;\n\n/**\n * **Switch component for toggling options**\n *\n * @description\n * A switch (also called a toggle) is a binary on/off input control.\n * It allows users to pick between two clearly opposite choices.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Switch } from '@yahoo/uds-mobile';\n *\n * <Switch label=\"Notifications\" />\n * <Switch isOn={enabled} onChange={setEnabled} label=\"Dark mode\" />\n * <Switch onIcon=\"Check\" offIcon=\"Cross\" label=\"Sync\" />\n * ```\n *\n * @usage\n * - Settings: For toggling preferences on/off\n * - Feature flags: For enabling/disabling features\n * - Immediate effect toggles (no submit button needed)\n *\n * @accessibility\n * - Sets `accessibilityRole=\"switch\"` automatically\n * - Announces on/off state to screen readers\n * - Respects system reduce motion preference\n * - Supports `reduceMotion` prop to disable animations\n *\n * @see {@link Checkbox} for forms with submit actions\n * @see {@link Radio} for single-select options\n */\nconst Switch = memo(function Switch({\n isOn: isOnProp,\n defaultIsOn = false,\n onChange,\n label,\n labelPosition = 'start',\n size = 'md',\n onIcon,\n offIcon,\n disabled = false,\n required,\n accessibilityHint,\n reduceMotion = false,\n ref,\n ...viewProps\n}: SwitchProps) {\n const isControlled = isOnProp !== undefined;\n const [internalIsOn, setInternalIsOn] = useState(defaultIsOn);\n const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);\n const isOn = isControlled ? isOnProp : internalIsOn;\n\n // Check system reduced motion preference\n useEffect(() => {\n const checkReducedMotion = async () => {\n const isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();\n setPrefersReducedMotion(isReduceMotionEnabled);\n };\n checkReducedMotion();\n\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n setPrefersReducedMotion,\n );\n return () => subscription.remove();\n }, []);\n\n const shouldReduceMotion = reduceMotion || prefersReducedMotion;\n const animationDuration = shouldReduceMotion ? 0 : ANIMATION_DURATION;\n\n const progress = useDerivedValue(\n () => withTiming(isOn ? 1 : 0, { duration: animationDuration }),\n [isOn, animationDuration],\n );\n\n const travelDistance = HANDLE_TRAVEL[size];\n\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newValue = !isOn;\n\n if (!isControlled) {\n setInternalIsOn(newValue);\n }\n\n onChange?.(newValue);\n }, [disabled, isOn, isControlled, onChange]);\n\n switchStyles.useVariants({\n size,\n variant: isOn ? 'on' : 'off',\n });\n\n // Get animated track color from design tokens (changes when variant changes)\n const trackBackgroundColor = useAnimatedVariantColor(switchStyles.switch, 'backgroundColor');\n\n const animatedTrackStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n backgroundColor: withTiming(trackBackgroundColor.value, { duration: animationDuration }),\n };\n });\n\n const animatedHandleStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n transform: [{ translateX: progress.value * travelDistance }],\n };\n });\n\n const rootStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.root, switchStaticStyles.root({ disabled })],\n [switchStyles.root, disabled],\n );\n\n const trackStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.switch, switchStaticStyles.track, animatedTrackStyle],\n [switchStyles.switch, animatedTrackStyle],\n );\n\n const handleStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.handle, switchStaticStyles.handle, animatedHandleStyle],\n [switchStyles.handle, animatedHandleStyle],\n );\n\n const accessibilityLabel = typeof label === 'string' ? label : undefined;\n const resolvedAccessibilityHint = accessibilityHint ?? 'Double tap to toggle';\n\n const resolvedLabel = typeof label === 'function' ? label() : label;\n const labelContent = resolvedLabel && (\n <HStack gap=\"2\" alignItems=\"center\">\n <Text style={switchStyles.text}>{resolvedLabel}</Text>\n {required && <Text color=\"alert\">*</Text>}\n </HStack>\n );\n\n const a11yValue = useMemo(() => ({ text: isOn ? 'On' : 'Off' }), [isOn]);\n\n return (\n <Pressable\n ref={ref}\n onPress={handlePress}\n disabled={disabled}\n accessible\n accessibilityRole=\"switch\"\n accessibilityState={{ checked: isOn, disabled }}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={resolvedAccessibilityHint}\n accessibilityValue={a11yValue}\n {...viewProps}\n style={rootStyle}\n >\n {labelPosition === 'end' && labelContent}\n\n <Animated.View style={trackStyle} importantForAccessibility=\"no-hide-descendants\">\n <Animated.View style={handleStyle}>\n {onIcon && isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={onIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n {offIcon && !isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={offIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n </Animated.View>\n </Animated.View>\n\n {labelPosition === 'start' && labelContent}\n </Pressable>\n );\n});\n\nSwitch.displayName = 'Switch';\n\nconst switchStaticStyles = StyleSheet.create((theme) => ({\n handle: {\n borderRadius: theme.borderRadius.full,\n alignItems: 'center',\n justifyContent: 'center',\n },\n iconContainer: {\n position: 'absolute',\n alignItems: 'center',\n justifyContent: 'center',\n },\n track: {\n justifyContent: 'center',\n borderRadius: theme.borderRadius.full,\n },\n root: ({ disabled }: { disabled: boolean }) => ({\n flexDirection: 'row',\n alignItems: 'center',\n alignSelf: 'flex-start',\n opacity: disabled ? 0.5 : 1,\n }),\n}));\n\nexport { Switch, type SwitchProps };\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,gBAA4C;CAChD,IAAI;CACJ,IAAI;CACL;AAED,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC3B,MAAM,SAAS,KAAK,SAAS,OAAO,EAClC,MAAM,UACN,cAAc,OACd,UACA,OACA,gBAAgB,SAChB,OAAO,MACP,QACA,SACA,WAAW,OACX,UACA,mBACA,eAAe,OACf,KACA,GAAG,aACW;CACd,MAAM,eAAe,aAAa;CAClC,MAAM,CAAC,cAAc,mBAAmB,SAAS,YAAY;CAC7D,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,MAAM;CACvE,MAAM,OAAO,eAAe,WAAW;AAGvC,iBAAgB;EACd,MAAM,qBAAqB,YAAY;AAErC,2BAD8B,MAAM,kBAAkB,uBAAuB,CAC/B;;AAEhD,sBAAoB;EAEpB,MAAM,eAAe,kBAAkB,iBACrC,uBACA,wBACD;AACD,eAAa,aAAa,QAAQ;IACjC,EAAE,CAAC;CAGN,MAAM,oBADqB,gBAAgB,uBACI,IAAI;CAEnD,MAAM,WAAW,sBACT,WAAW,OAAO,IAAI,GAAG,EAAE,UAAU,mBAAmB,CAAC,EAC/D,CAAC,MAAM,kBAAkB,CAC1B;CAED,MAAM,iBAAiB,cAAc;CAErC,MAAM,cAAc,kBAAkB;AACpC,MAAI,SACF;EAGF,MAAM,WAAW,CAAC;AAElB,MAAI,CAAC,aACH,iBAAgB,SAAS;AAG3B,aAAW,SAAS;IACnB;EAAC;EAAU;EAAM;EAAc;EAAS,CAAC;AAE5C,cAAa,YAAY;EACvB;EACA,SAAS,OAAO,OAAO;EACxB,CAAC;CAGF,MAAM,uBAA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oBAAC,SAAS;MAAK,OAAO,mBAAmB;gBACvC,oBAAC;OAAS,MAAM;OAAQ,SAAQ;OAAO,OAAO,aAAa;QAAc;OAC3D,EAEjB,WAAW,CAAC,QACX,oBAAC,SAAS;MAAK,OAAO,mBAAmB;gBACvC,oBAAC;OAAS,MAAM;OAAS,SAAQ;OAAO,OAAO,aAAa;QAAc;OAC5D;MAEJ;KACF;GAEf,kBAAkB,WAAW;;GACpB;EAEd;AAEF,OAAO,cAAc;AAErB,MAAM,qBAAqBC,aAAW,QAAQ,WAAW;CACvD,QAAQ;EACN,cAAc,MAAM,aAAa;EACjC,YAAY;EACZ,gBAAgB;EACjB;CACD,eAAe;EACb,UAAU;EACV,YAAY;EACZ,gBAAgB;EACjB;CACD,OAAO;EACL,gBAAgB;EAChB,cAAc,MAAM,aAAa;EAClC;CACD,OAAO,EAAE,gBAAuC;EAC9C,eAAe;EACf,YAAY;EACZ,WAAW;EACX,SAAS,WAAW,KAAM;EAC3B;CACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"Switch.js","names":["Text","StyleSheet"],"sources":["../../src/components/Switch.tsx"],"sourcesContent":["import type { SwitchSize, UniversalSwitchProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport type { AccessibilityProps, StyleProp, View, ViewProps, ViewStyle } from 'react-native';\nimport { AccessibilityInfo, Pressable } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withTiming } from 'react-native-reanimated';\nimport { StyleSheet } from 'react-native-unistyles';\nimport { useAnimatedVariantColor } from 'react-native-unistyles/reanimated';\n\nimport { switchStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Text } from './Text';\n\ninterface SwitchProps extends Omit<ViewProps, 'style'>, UniversalSwitchProps<IconSlotType> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Callback when the switch value changes */\n onChange?: (value: boolean) => void;\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Whether the switch is required (shows asterisk with label) */\n required?: boolean;\n /** Accessibility hint describing what happens when activated */\n accessibilityHint?: AccessibilityProps['accessibilityHint'];\n}\n\nconst HANDLE_TRAVEL: Record<SwitchSize, number> = {\n md: 20,\n sm: 12,\n};\n\nconst ANIMATION_DURATION = 120;\n\n/**\n * **Switch component for toggling options**\n *\n * @description\n * A switch (also called a toggle) is a binary on/off input control.\n * It allows users to pick between two clearly opposite choices.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Switch } from '@yahoo/uds-mobile';\n *\n * <Switch label=\"Notifications\" />\n * <Switch isOn={enabled} onChange={setEnabled} label=\"Dark mode\" />\n * <Switch onIcon=\"Check\" offIcon=\"Cross\" label=\"Sync\" />\n * ```\n *\n * @usage\n * - Settings: For toggling preferences on/off\n * - Feature flags: For enabling/disabling features\n * - Immediate effect toggles (no submit button needed)\n *\n * @accessibility\n * - Sets `accessibilityRole=\"switch\"` automatically\n * - Announces on/off state to screen readers\n * - Respects system reduce motion preference\n * - Supports `reduceMotion` prop to disable animations\n *\n * @see {@link Checkbox} for forms with submit actions\n * @see {@link Radio} for single-select options\n */\nconst Switch = memo(function Switch({\n isOn: isOnProp,\n defaultIsOn = false,\n onChange,\n label,\n labelPosition = 'start',\n size = 'md',\n onIcon,\n offIcon,\n disabled = false,\n required,\n accessibilityHint,\n reduceMotion = false,\n ref,\n ...viewProps\n}: SwitchProps) {\n const isControlled = isOnProp !== undefined;\n const [internalIsOn, setInternalIsOn] = useState(defaultIsOn);\n const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);\n const isOn = isControlled ? isOnProp : internalIsOn;\n\n // Check system reduced motion preference\n useEffect(() => {\n const checkReducedMotion = async () => {\n const isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();\n setPrefersReducedMotion(isReduceMotionEnabled);\n };\n checkReducedMotion();\n\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n setPrefersReducedMotion,\n );\n return () => subscription.remove();\n }, []);\n\n const shouldReduceMotion = reduceMotion || prefersReducedMotion;\n const animationDuration = shouldReduceMotion ? 0 : ANIMATION_DURATION;\n\n const progress = useDerivedValue(\n () => withTiming(isOn ? 1 : 0, { duration: animationDuration }),\n [isOn, animationDuration],\n );\n\n const travelDistance = HANDLE_TRAVEL[size];\n\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newValue = !isOn;\n\n if (!isControlled) {\n setInternalIsOn(newValue);\n }\n\n onChange?.(newValue);\n }, [disabled, isOn, isControlled, onChange]);\n\n switchStyles.useVariants({\n size,\n variant: isOn ? 'on' : 'off',\n });\n\n // Get animated track color from design tokens (changes when variant changes)\n const trackBackgroundColor = useAnimatedVariantColor(switchStyles.switch, 'backgroundColor');\n\n const animatedTrackStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n backgroundColor: withTiming(trackBackgroundColor.value, { duration: animationDuration }),\n };\n });\n\n const animatedHandleStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n transform: [{ translateX: progress.value * travelDistance }],\n };\n });\n\n const rootStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.root, switchStaticStyles.root({ disabled })],\n [switchStyles.root, disabled],\n );\n\n const trackStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.switch, switchStaticStyles.track, animatedTrackStyle],\n [switchStyles.switch, animatedTrackStyle],\n );\n\n const handleStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.handle, switchStaticStyles.handle, animatedHandleStyle],\n [switchStyles.handle, animatedHandleStyle],\n );\n\n const accessibilityLabel = typeof label === 'string' ? label : undefined;\n const resolvedAccessibilityHint = accessibilityHint ?? 'Double tap to toggle';\n\n const resolvedLabel = typeof label === 'function' ? label() : label;\n const labelContent = resolvedLabel && (\n <HStack gap=\"2\" alignItems=\"center\">\n <Text style={switchStyles.text}>{resolvedLabel}</Text>\n {required && <Text color=\"alert\">*</Text>}\n </HStack>\n );\n\n const a11yValue = useMemo(() => ({ text: isOn ? 'On' : 'Off' }), [isOn]);\n\n return (\n <Pressable\n ref={ref}\n onPress={handlePress}\n disabled={disabled}\n accessible\n accessibilityRole=\"switch\"\n accessibilityState={{ checked: isOn, disabled }}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={resolvedAccessibilityHint}\n accessibilityValue={a11yValue}\n {...viewProps}\n style={rootStyle}\n >\n {labelPosition === 'start' && labelContent}\n\n <Animated.View style={trackStyle} importantForAccessibility=\"no-hide-descendants\">\n <Animated.View style={handleStyle}>\n {onIcon && isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={onIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n {offIcon && !isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={offIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n </Animated.View>\n </Animated.View>\n\n {labelPosition === 'end' && labelContent}\n </Pressable>\n );\n});\n\nSwitch.displayName = 'Switch';\n\nconst switchStaticStyles = StyleSheet.create((theme) => ({\n handle: {\n borderRadius: theme.borderRadius.full,\n alignItems: 'center',\n justifyContent: 'center',\n },\n iconContainer: {\n position: 'absolute',\n alignItems: 'center',\n justifyContent: 'center',\n },\n track: {\n justifyContent: 'center',\n borderRadius: theme.borderRadius.full,\n },\n root: ({ disabled }: { disabled: boolean }) => ({\n flexDirection: 'row',\n alignItems: 'center',\n alignSelf: 'flex-start',\n opacity: disabled ? 0.5 : 1,\n }),\n}));\n\nexport { Switch, type SwitchProps };\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,gBAA4C;CAChD,IAAI;CACJ,IAAI;CACL;AAED,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC3B,MAAM,SAAS,KAAK,SAAS,OAAO,EAClC,MAAM,UACN,cAAc,OACd,UACA,OACA,gBAAgB,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EACjB;CACD,eAAe;EACb,UAAU;EACV,YAAY;EACZ,gBAAgB;EACjB;CACD,OAAO;EACL,gBAAgB;EAChB,cAAc,MAAM,aAAa;EAClC;CACD,OAAO,EAAE,gBAAuC;EAC9C,eAAe;EACf,YAAY;EACZ,WAAW;EACX,SAAS,WAAW,KAAM;EAC3B;CACF,EAAE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_jest_mocks_icons = require('./mocks/icons.cjs');
|
|
4
|
+
const require_jest_mocks_reanimated = require('./mocks/reanimated.cjs');
|
|
5
|
+
const require_jest_mocks_styles = require('./mocks/styles.cjs');
|
|
6
|
+
const require_jest_mocks_svg = require('./mocks/svg.cjs');
|
|
7
|
+
const require_jest_mocks_unistyles = require('./mocks/unistyles.cjs');
|
|
8
|
+
const require_jest_setup = require('./setup.cjs');
|
|
9
|
+
|
|
10
|
+
//#region src/jest/index.ts
|
|
11
|
+
/**
|
|
12
|
+
* Jest testing support for UDS Mobile.
|
|
13
|
+
* Mocks native dependencies so real components can be tested.
|
|
14
|
+
*/
|
|
15
|
+
const mocks = {
|
|
16
|
+
unistyles: require_jest_mocks_unistyles.unistyles_exports,
|
|
17
|
+
reanimated: require_jest_mocks_reanimated.reanimated_exports,
|
|
18
|
+
svg: require_jest_mocks_svg.svg_exports,
|
|
19
|
+
icons: require_jest_mocks_icons.icons_exports,
|
|
20
|
+
styles: require_jest_mocks_styles.styles_exports
|
|
21
|
+
};
|
|
22
|
+
require_jest_setup.setupUDSMobileJest();
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.mocks = mocks;
|
|
26
|
+
exports.resetSetupState = require_jest_setup.resetSetupState;
|
|
27
|
+
exports.setupUDSMobileJest = require_jest_setup.setupUDSMobileJest;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { icons_d_exports } from "./mocks/icons.cjs";
|
|
3
|
+
import { reanimated_d_exports } from "./mocks/reanimated.cjs";
|
|
4
|
+
import { styles_d_exports } from "./mocks/styles.cjs";
|
|
5
|
+
import { svg_d_exports } from "./mocks/svg.cjs";
|
|
6
|
+
import { unistyles_d_exports } from "./mocks/unistyles.cjs";
|
|
7
|
+
import { resetSetupState, setupUDSMobileJest } from "./setup.cjs";
|
|
8
|
+
|
|
9
|
+
//#region src/jest/index.d.ts
|
|
10
|
+
declare const mocks: {
|
|
11
|
+
unistyles: typeof unistyles_d_exports;
|
|
12
|
+
reanimated: typeof reanimated_d_exports;
|
|
13
|
+
svg: typeof svg_d_exports;
|
|
14
|
+
icons: typeof icons_d_exports;
|
|
15
|
+
styles: typeof styles_d_exports;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { mocks, resetSetupState, setupUDSMobileJest };
|
|
19
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/jest/index.ts"],"mappings":";;;;;;;;;cAYM,KAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { icons_d_exports } from "./mocks/icons.js";
|
|
3
|
+
import { reanimated_d_exports } from "./mocks/reanimated.js";
|
|
4
|
+
import { styles_d_exports } from "./mocks/styles.js";
|
|
5
|
+
import { svg_d_exports } from "./mocks/svg.js";
|
|
6
|
+
import { unistyles_d_exports } from "./mocks/unistyles.js";
|
|
7
|
+
import { resetSetupState, setupUDSMobileJest } from "./setup.js";
|
|
8
|
+
|
|
9
|
+
//#region src/jest/index.d.ts
|
|
10
|
+
declare const mocks: {
|
|
11
|
+
unistyles: typeof unistyles_d_exports;
|
|
12
|
+
reanimated: typeof reanimated_d_exports;
|
|
13
|
+
svg: typeof svg_d_exports;
|
|
14
|
+
icons: typeof icons_d_exports;
|
|
15
|
+
styles: typeof styles_d_exports;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { mocks, resetSetupState, setupUDSMobileJest };
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/jest/index.ts"],"mappings":";;;;;;;;;cAYM,KAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { icons_exports } from "./mocks/icons.js";
|
|
3
|
+
import { reanimated_exports } from "./mocks/reanimated.js";
|
|
4
|
+
import { styles_exports } from "./mocks/styles.js";
|
|
5
|
+
import { svg_exports } from "./mocks/svg.js";
|
|
6
|
+
import { unistyles_exports } from "./mocks/unistyles.js";
|
|
7
|
+
import { resetSetupState, setupUDSMobileJest } from "./setup.js";
|
|
8
|
+
|
|
9
|
+
//#region src/jest/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* Jest testing support for UDS Mobile.
|
|
12
|
+
* Mocks native dependencies so real components can be tested.
|
|
13
|
+
*/
|
|
14
|
+
const mocks = {
|
|
15
|
+
unistyles: unistyles_exports,
|
|
16
|
+
reanimated: reanimated_exports,
|
|
17
|
+
svg: svg_exports,
|
|
18
|
+
icons: icons_exports,
|
|
19
|
+
styles: styles_exports
|
|
20
|
+
};
|
|
21
|
+
setupUDSMobileJest();
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { mocks, resetSetupState, setupUDSMobileJest };
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/jest/index.ts"],"sourcesContent":["/**\n * Jest testing support for UDS Mobile.\n * Mocks native dependencies so real components can be tested.\n */\n\nimport * as icons from './mocks/icons';\nimport * as reanimated from './mocks/reanimated';\nimport * as styles from './mocks/styles';\nimport * as svg from './mocks/svg';\nimport * as unistyles from './mocks/unistyles';\nimport { resetSetupState, setupUDSMobileJest } from './setup';\n\nconst mocks = {\n unistyles,\n reanimated,\n svg,\n icons,\n styles,\n};\n\n// Auto-run setup when this module is imported\nsetupUDSMobileJest();\n\nexport { mocks, resetSetupState, setupUDSMobileJest };\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,QAAQ;CACZ;CACA;CACA;CACA;CACA;CACD;AAGD,oBAAoB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/jest/mocks/icons.ts
|
|
6
|
+
var icons_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
7
|
+
ICON_SIZE_MAP: () => ICON_SIZE_MAP,
|
|
8
|
+
glyphMap: () => glyphMap,
|
|
9
|
+
glyphNames: () => glyphNames,
|
|
10
|
+
svgGlyphNames: () => svgGlyphNames,
|
|
11
|
+
svgMap: () => svgMap
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Jest mock for @yahoo/uds-icons.
|
|
15
|
+
*
|
|
16
|
+
* Provides proxy-based mocks for glyph and SVG maps
|
|
17
|
+
* so any icon name returns a valid placeholder.
|
|
18
|
+
*/
|
|
19
|
+
const glyphMapProxy = new Proxy({}, {
|
|
20
|
+
get: (_target, prop) => {
|
|
21
|
+
if (typeof prop === "string") return "";
|
|
22
|
+
},
|
|
23
|
+
has: () => true,
|
|
24
|
+
ownKeys: () => []
|
|
25
|
+
});
|
|
26
|
+
const svgMapProxy = new Proxy({}, {
|
|
27
|
+
get: (_target, prop) => {
|
|
28
|
+
if (typeof prop === "string") return "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><rect width=\"24\" height=\"24\" fill=\"currentColor\"/></svg>";
|
|
29
|
+
},
|
|
30
|
+
has: () => true,
|
|
31
|
+
ownKeys: () => []
|
|
32
|
+
});
|
|
33
|
+
const ICON_SIZE_MAP = {
|
|
34
|
+
xs: 12,
|
|
35
|
+
sm: 16,
|
|
36
|
+
md: 24,
|
|
37
|
+
lg: 32,
|
|
38
|
+
xl: 48
|
|
39
|
+
};
|
|
40
|
+
const glyphMap = glyphMapProxy;
|
|
41
|
+
const glyphNames = [];
|
|
42
|
+
const svgMap = svgMapProxy;
|
|
43
|
+
const svgGlyphNames = [];
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.ICON_SIZE_MAP = ICON_SIZE_MAP;
|
|
47
|
+
exports.glyphMap = glyphMap;
|
|
48
|
+
exports.glyphNames = glyphNames;
|
|
49
|
+
Object.defineProperty(exports, 'icons_exports', {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return icons_exports;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
exports.svgGlyphNames = svgGlyphNames;
|
|
56
|
+
exports.svgMap = svgMap;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
declare namespace icons_d_exports {
|
|
3
|
+
export { ICON_SIZE_MAP, glyphMap, glyphNames, svgGlyphNames, svgMap };
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Jest mock for @yahoo/uds-icons.
|
|
7
|
+
*
|
|
8
|
+
* Provides proxy-based mocks for glyph and SVG maps
|
|
9
|
+
* so any icon name returns a valid placeholder.
|
|
10
|
+
*/
|
|
11
|
+
declare const ICON_SIZE_MAP: {
|
|
12
|
+
readonly xs: 12;
|
|
13
|
+
readonly sm: 16;
|
|
14
|
+
readonly md: 24;
|
|
15
|
+
readonly lg: 32;
|
|
16
|
+
readonly xl: 48;
|
|
17
|
+
};
|
|
18
|
+
declare const glyphMap: {};
|
|
19
|
+
declare const glyphNames: string[];
|
|
20
|
+
declare const svgMap: {};
|
|
21
|
+
declare const svgGlyphNames: string[];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ICON_SIZE_MAP, glyphMap, glyphNames, icons_d_exports, svgGlyphNames, svgMap };
|
|
24
|
+
//# sourceMappingURL=icons.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.cts","names":[],"sources":["../../../src/jest/mocks/icons.ts"],"mappings":";;;;;;;;;;cAyCa,aAAA;EAAA;;;;;;cASA,QAAA;AAAA,cACA,UAAA;AAAA,cAGA,MAAA;AAAA,cACA,aAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
declare namespace icons_d_exports {
|
|
3
|
+
export { ICON_SIZE_MAP, glyphMap, glyphNames, svgGlyphNames, svgMap };
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Jest mock for @yahoo/uds-icons.
|
|
7
|
+
*
|
|
8
|
+
* Provides proxy-based mocks for glyph and SVG maps
|
|
9
|
+
* so any icon name returns a valid placeholder.
|
|
10
|
+
*/
|
|
11
|
+
declare const ICON_SIZE_MAP: {
|
|
12
|
+
readonly xs: 12;
|
|
13
|
+
readonly sm: 16;
|
|
14
|
+
readonly md: 24;
|
|
15
|
+
readonly lg: 32;
|
|
16
|
+
readonly xl: 48;
|
|
17
|
+
};
|
|
18
|
+
declare const glyphMap: {};
|
|
19
|
+
declare const glyphNames: string[];
|
|
20
|
+
declare const svgMap: {};
|
|
21
|
+
declare const svgGlyphNames: string[];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ICON_SIZE_MAP, glyphMap, glyphNames, icons_d_exports, svgGlyphNames, svgMap };
|
|
24
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","names":[],"sources":["../../../src/jest/mocks/icons.ts"],"mappings":";;;;;;;;;;cAyCa,aAAA;EAAA;;;;;;cASA,QAAA;AAAA,cACA,UAAA;AAAA,cAGA,MAAA;AAAA,cACA,aAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
+
|
|
4
|
+
//#region src/jest/mocks/icons.ts
|
|
5
|
+
var icons_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
ICON_SIZE_MAP: () => ICON_SIZE_MAP,
|
|
7
|
+
glyphMap: () => glyphMap,
|
|
8
|
+
glyphNames: () => glyphNames,
|
|
9
|
+
svgGlyphNames: () => svgGlyphNames,
|
|
10
|
+
svgMap: () => svgMap
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Jest mock for @yahoo/uds-icons.
|
|
14
|
+
*
|
|
15
|
+
* Provides proxy-based mocks for glyph and SVG maps
|
|
16
|
+
* so any icon name returns a valid placeholder.
|
|
17
|
+
*/
|
|
18
|
+
const glyphMapProxy = new Proxy({}, {
|
|
19
|
+
get: (_target, prop) => {
|
|
20
|
+
if (typeof prop === "string") return "";
|
|
21
|
+
},
|
|
22
|
+
has: () => true,
|
|
23
|
+
ownKeys: () => []
|
|
24
|
+
});
|
|
25
|
+
const svgMapProxy = new Proxy({}, {
|
|
26
|
+
get: (_target, prop) => {
|
|
27
|
+
if (typeof prop === "string") return "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><rect width=\"24\" height=\"24\" fill=\"currentColor\"/></svg>";
|
|
28
|
+
},
|
|
29
|
+
has: () => true,
|
|
30
|
+
ownKeys: () => []
|
|
31
|
+
});
|
|
32
|
+
const ICON_SIZE_MAP = {
|
|
33
|
+
xs: 12,
|
|
34
|
+
sm: 16,
|
|
35
|
+
md: 24,
|
|
36
|
+
lg: 32,
|
|
37
|
+
xl: 48
|
|
38
|
+
};
|
|
39
|
+
const glyphMap = glyphMapProxy;
|
|
40
|
+
const glyphNames = [];
|
|
41
|
+
const svgMap = svgMapProxy;
|
|
42
|
+
const svgGlyphNames = [];
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ICON_SIZE_MAP, glyphMap, glyphNames, icons_exports, svgGlyphNames, svgMap };
|
|
46
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","names":[],"sources":["../../../src/jest/mocks/icons.ts"],"sourcesContent":["/**\n * Jest mock for @yahoo/uds-icons.\n *\n * Provides proxy-based mocks for glyph and SVG maps\n * so any icon name returns a valid placeholder.\n */\n\n// Proxy that returns a placeholder glyph character for any icon name\nconst glyphMapProxy = new Proxy(\n {},\n {\n get: (_target, prop) => {\n // Return a placeholder glyph character\n // Using a simple character that works in Jest/JSDOM\n if (typeof prop === 'string') {\n return '\\uE000'; // Private use area character\n }\n return undefined;\n },\n has: () => true,\n ownKeys: () => [],\n },\n);\n\n// Proxy that returns placeholder SVG content for any icon name\nconst svgMapProxy = new Proxy(\n {},\n {\n get: (_target, prop) => {\n // Return minimal valid SVG for any key\n if (typeof prop === 'string') {\n return '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><rect width=\"24\" height=\"24\" fill=\"currentColor\"/></svg>';\n }\n return undefined;\n },\n has: () => true,\n ownKeys: () => [],\n },\n);\n\n// Icon size mapping (matches actual package)\nexport const ICON_SIZE_MAP = {\n xs: 12,\n sm: 16,\n md: 24,\n lg: 32,\n xl: 48,\n} as const;\n\n// Export glyph map and names\nexport const glyphMap = glyphMapProxy;\nexport const glyphNames: string[] = [];\n\n// Export SVG map and names\nexport const svgMap = svgMapProxy;\nexport const svgGlyphNames: string[] = [];\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,MAAM,gBAAgB,IAAI,MACxB,EAAE,EACF;CACE,MAAM,SAAS,SAAS;AAGtB,MAAI,OAAO,SAAS,SAClB,QAAO;;CAIX,WAAW;CACX,eAAe,EAAE;CAClB,CACF;AAGD,MAAM,cAAc,IAAI,MACtB,EAAE,EACF;CACE,MAAM,SAAS,SAAS;AAEtB,MAAI,OAAO,SAAS,SAClB,QAAO;;CAIX,WAAW;CACX,eAAe,EAAE;CAClB,CACF;AAGD,MAAa,gBAAgB;CAC3B,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAGD,MAAa,WAAW;AACxB,MAAa,aAAuB,EAAE;AAGtC,MAAa,SAAS;AACtB,MAAa,gBAA0B,EAAE"}
|