@yahoo/uds-mobile 1.3.0-beta.9 → 1.4.0-beta.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/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/bin/fixtures/dist/index.mjs +25 -1
- package/dist/bin/generateTheme.mjs +5 -5
- package/dist/bin/uds-mobile.mjs +10 -10
- package/dist/components/Avatar.cjs +12 -3
- package/dist/components/Avatar.d.cts +11 -3
- package/dist/components/Avatar.d.cts.map +1 -1
- package/dist/components/Avatar.d.mts +11 -3
- package/dist/components/Avatar.d.mts.map +1 -1
- package/dist/components/Avatar.mjs +10 -2
- package/dist/components/Avatar.mjs.map +1 -1
- package/dist/components/Badge.cjs +14 -3
- package/dist/components/Badge.d.cts +24 -6
- package/dist/components/Badge.d.cts.map +1 -1
- package/dist/components/Badge.d.mts +24 -6
- package/dist/components/Badge.d.mts.map +1 -1
- package/dist/components/Badge.mjs +12 -2
- package/dist/components/Badge.mjs.map +1 -1
- package/dist/components/Box.cjs +14 -10
- package/dist/components/Box.d.cts +15 -10
- package/dist/components/Box.d.cts.map +1 -1
- package/dist/components/Box.d.mts +15 -10
- package/dist/components/Box.d.mts.map +1 -1
- package/dist/components/Box.mjs +12 -9
- package/dist/components/Box.mjs.map +1 -1
- package/dist/components/Button.cjs +14 -4
- package/dist/components/Button.d.cts +21 -6
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.mts +21 -6
- package/dist/components/Button.d.mts.map +1 -1
- package/dist/components/Button.mjs +11 -2
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/Checkbox.cjs +15 -6
- package/dist/components/Checkbox.d.cts +14 -5
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.mts +14 -5
- package/dist/components/Checkbox.d.mts.map +1 -1
- package/dist/components/Checkbox.mjs +12 -4
- package/dist/components/Checkbox.mjs.map +1 -1
- package/dist/components/Chip.cjs +20 -3
- package/dist/components/Chip.d.cts +28 -6
- package/dist/components/Chip.d.cts.map +1 -1
- package/dist/components/Chip.d.mts +28 -6
- package/dist/components/Chip.d.mts.map +1 -1
- package/dist/components/Chip.mjs +18 -2
- package/dist/components/Chip.mjs.map +1 -1
- package/dist/components/HStack.cjs +8 -5
- package/dist/components/HStack.d.cts +9 -5
- package/dist/components/HStack.d.cts.map +1 -1
- package/dist/components/HStack.d.mts +9 -5
- package/dist/components/HStack.d.mts.map +1 -1
- package/dist/components/HStack.mjs +6 -4
- package/dist/components/HStack.mjs.map +1 -1
- package/dist/components/Icon.cjs +16 -5
- package/dist/components/Icon.d.cts +14 -3
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.mts +14 -3
- package/dist/components/Icon.d.mts.map +1 -1
- package/dist/components/Icon.mjs +14 -4
- package/dist/components/Icon.mjs.map +1 -1
- package/dist/components/IconButton.cjs +23 -4
- package/dist/components/IconButton.d.cts +28 -8
- package/dist/components/IconButton.d.cts.map +1 -1
- package/dist/components/IconButton.d.mts +28 -8
- package/dist/components/IconButton.d.mts.map +1 -1
- package/dist/components/IconButton.mjs +21 -3
- package/dist/components/IconButton.mjs.map +1 -1
- package/dist/components/IconSlot.cjs +8 -2
- package/dist/components/IconSlot.d.cts +7 -2
- package/dist/components/IconSlot.d.cts.map +1 -1
- package/dist/components/IconSlot.d.mts +7 -2
- package/dist/components/IconSlot.d.mts.map +1 -1
- package/dist/components/IconSlot.mjs +6 -1
- package/dist/components/IconSlot.mjs.map +1 -1
- package/dist/components/Image.cjs +18 -3
- package/dist/components/Image.d.cts +18 -3
- package/dist/components/Image.d.cts.map +1 -1
- package/dist/components/Image.d.mts +18 -3
- package/dist/components/Image.d.mts.map +1 -1
- package/dist/components/Image.mjs +16 -2
- package/dist/components/Image.mjs.map +1 -1
- package/dist/components/Input.cjs +19 -6
- package/dist/components/Input.d.cts +19 -6
- package/dist/components/Input.d.cts.map +1 -1
- package/dist/components/Input.d.mts +19 -6
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +17 -5
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Link.cjs +19 -4
- package/dist/components/Link.d.cts +21 -4
- package/dist/components/Link.d.cts.map +1 -1
- package/dist/components/Link.d.mts +21 -4
- package/dist/components/Link.d.mts.map +1 -1
- package/dist/components/Link.mjs +16 -2
- package/dist/components/Link.mjs.map +1 -1
- package/dist/components/Pressable.cjs +17 -5
- package/dist/components/Pressable.d.cts +18 -5
- package/dist/components/Pressable.d.cts.map +1 -1
- package/dist/components/Pressable.d.mts +18 -5
- package/dist/components/Pressable.d.mts.map +1 -1
- package/dist/components/Pressable.mjs +14 -3
- package/dist/components/Pressable.mjs.map +1 -1
- package/dist/components/Radio.cjs +15 -6
- package/dist/components/Radio.d.cts +14 -5
- package/dist/components/Radio.d.cts.map +1 -1
- package/dist/components/Radio.d.mts +14 -5
- package/dist/components/Radio.d.mts.map +1 -1
- package/dist/components/Radio.mjs +12 -4
- package/dist/components/Radio.mjs.map +1 -1
- package/dist/components/Screen.cjs +9 -3
- package/dist/components/Screen.d.cts +15 -3
- package/dist/components/Screen.d.cts.map +1 -1
- package/dist/components/Screen.d.mts +15 -3
- package/dist/components/Screen.d.mts.map +1 -1
- package/dist/components/Screen.mjs +7 -2
- package/dist/components/Screen.mjs.map +1 -1
- package/dist/components/Switch.cjs +20 -4
- package/dist/components/Switch.d.cts +18 -3
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.mts +18 -3
- package/dist/components/Switch.d.mts.map +1 -1
- package/dist/components/Switch.mjs +17 -2
- package/dist/components/Switch.mjs.map +1 -1
- package/dist/components/Text.cjs +16 -6
- package/dist/components/Text.d.cts +18 -6
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.mts +18 -6
- package/dist/components/Text.d.mts.map +1 -1
- package/dist/components/Text.mjs +14 -5
- package/dist/components/Text.mjs.map +1 -1
- package/dist/components/VStack.cjs +8 -5
- package/dist/components/VStack.d.cts +9 -5
- package/dist/components/VStack.d.cts.map +1 -1
- package/dist/components/VStack.d.mts +9 -5
- package/dist/components/VStack.d.mts.map +1 -1
- package/dist/components/VStack.mjs +6 -4
- package/dist/components/VStack.mjs.map +1 -1
- package/dist/icons/dist/glyphMap.d.cts +0 -1
- package/dist/icons/dist/glyphMap.d.cts.map +1 -1
- package/dist/icons/dist/glyphMap.d.mts +0 -1
- package/dist/icons/dist/glyphMap.d.mts.map +1 -1
- package/dist/icons/dist/svgMap.d.cts +0 -1
- package/dist/icons/dist/svgMap.d.cts.map +1 -1
- package/dist/icons/dist/svgMap.d.mts +0 -1
- package/dist/icons/dist/svgMap.d.mts.map +1 -1
- package/dist/motion-tokens/dist/index.d.cts +1 -3
- package/dist/motion-tokens/dist/index.d.cts.map +1 -1
- package/dist/motion-tokens/dist/index.d.mts +1 -3
- package/dist/motion-tokens/dist/index.d.mts.map +1 -1
- package/dist/motion.cjs +1 -0
- package/dist/motion.d.cts +0 -1
- package/dist/motion.d.cts.map +1 -1
- package/dist/motion.d.mts +0 -1
- package/dist/motion.d.mts.map +1 -1
- package/dist/types/dist/index.d.cts +1 -3
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.mts +1 -3
- package/dist/types/dist/index.d.mts.map +1 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts.map +1 -1
- package/generated/styles.cjs +96 -0
- package/generated/styles.d.ts +47 -0
- package/generated/styles.mjs +96 -0
- package/generated/unistyles.d.ts +79 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
const require_index = require('../motion-tokens/dist/index.cjs');
|
|
4
5
|
const require_motion = require('../motion.cjs');
|
|
5
6
|
const require_components_Text = require('./Text.cjs');
|
|
@@ -9,7 +10,7 @@ let react = require("react");
|
|
|
9
10
|
let generated_styles = require("../../generated/styles");
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
let react_native_reanimated = require("react-native-reanimated");
|
|
12
|
-
react_native_reanimated =
|
|
13
|
+
react_native_reanimated = require_runtime.__toESM(react_native_reanimated);
|
|
13
14
|
|
|
14
15
|
//#region src/components/Radio.tsx
|
|
15
16
|
const VARIANT_ERROR_MAP = {
|
|
@@ -19,13 +20,14 @@ const VARIANT_ERROR_MAP = {
|
|
|
19
20
|
/**
|
|
20
21
|
* **⚙️ A radio component**
|
|
21
22
|
*
|
|
22
|
-
* @componentType Client component
|
|
23
|
-
*
|
|
24
23
|
* @description
|
|
25
24
|
* A radio component allows users to select one option from a set.
|
|
26
25
|
* Unlike checkbox, radio buttons cannot have multiple selected in a group,
|
|
27
26
|
* allowing only one selection at a time.
|
|
28
27
|
*
|
|
28
|
+
* @category Form
|
|
29
|
+
* @platform mobile
|
|
30
|
+
*
|
|
29
31
|
* @example
|
|
30
32
|
* ```tsx
|
|
31
33
|
* import { Radio } from '@yahoo/uds-mobile';
|
|
@@ -38,9 +40,16 @@ const VARIANT_ERROR_MAP = {
|
|
|
38
40
|
* - Forms: For selecting a single option from multiple choices
|
|
39
41
|
* - Settings: For toggling between mutually exclusive preferences
|
|
40
42
|
*
|
|
41
|
-
* @
|
|
43
|
+
* @accessibility
|
|
44
|
+
* - Sets `accessibilityRole="radio"` automatically
|
|
45
|
+
* - Announces checked/unchecked state
|
|
46
|
+
* - Label is used as accessibility label
|
|
47
|
+
* - Supports `reduceMotion` for users who prefer reduced motion
|
|
48
|
+
*
|
|
49
|
+
* @see {@link Checkbox} for multi-select options
|
|
50
|
+
* @see {@link Switch} for binary toggles
|
|
42
51
|
*/
|
|
43
|
-
const Radio = (0, react.memo)(function Radio
|
|
52
|
+
const Radio = (0, react.memo)(function Radio({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, onChange, ref, ...viewProps }) {
|
|
44
53
|
const uid = `uds-radio-${(0, react.useId)()}`;
|
|
45
54
|
const isControlled = checkedProp !== void 0;
|
|
46
55
|
const [internalChecked, setInternalChecked] = (0, react.useState)(isControlled ? checkedProp : defaultChecked ?? false);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalRadioProps } from "../types/dist/index.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Radio.d.ts
|
|
8
8
|
interface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {
|
|
9
|
+
/** Ref to the underlying View */
|
|
9
10
|
ref?: Ref<View>;
|
|
10
11
|
/** Default checked state for uncontrolled mode */
|
|
11
12
|
defaultChecked?: boolean;
|
|
@@ -19,13 +20,14 @@ interface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {
|
|
|
19
20
|
/**
|
|
20
21
|
* **⚙️ A radio component**
|
|
21
22
|
*
|
|
22
|
-
* @componentType Client component
|
|
23
|
-
*
|
|
24
23
|
* @description
|
|
25
24
|
* A radio component allows users to select one option from a set.
|
|
26
25
|
* Unlike checkbox, radio buttons cannot have multiple selected in a group,
|
|
27
26
|
* allowing only one selection at a time.
|
|
28
27
|
*
|
|
28
|
+
* @category Form
|
|
29
|
+
* @platform mobile
|
|
30
|
+
*
|
|
29
31
|
* @example
|
|
30
32
|
* ```tsx
|
|
31
33
|
* import { Radio } from '@yahoo/uds-mobile';
|
|
@@ -38,9 +40,16 @@ interface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {
|
|
|
38
40
|
* - Forms: For selecting a single option from multiple choices
|
|
39
41
|
* - Settings: For toggling between mutually exclusive preferences
|
|
40
42
|
*
|
|
41
|
-
* @
|
|
43
|
+
* @accessibility
|
|
44
|
+
* - Sets `accessibilityRole="radio"` automatically
|
|
45
|
+
* - Announces checked/unchecked state
|
|
46
|
+
* - Label is used as accessibility label
|
|
47
|
+
* - Supports `reduceMotion` for users who prefer reduced motion
|
|
48
|
+
*
|
|
49
|
+
* @see {@link Checkbox} for multi-select options
|
|
50
|
+
* @see {@link Switch} for binary toggles
|
|
42
51
|
*/
|
|
43
|
-
declare const Radio:
|
|
52
|
+
declare const Radio: react.NamedExoticComponent<RadioProps>;
|
|
44
53
|
//#endregion
|
|
45
54
|
export { Radio, type RadioProps };
|
|
46
55
|
//# sourceMappingURL=Radio.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.cts","names":[],"sources":["../../src/components/Radio.tsx"],"
|
|
1
|
+
{"version":3,"file":"Radio.d.cts","names":[],"sources":["../../src/components/Radio.tsx"],"mappings":";;;;;;;UAwBU,UAAA,SAAmB,IAAA,CAAK,SAAA,YAAqB,mBAAA;;EAErD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR2B;EAU3B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;cAmDxB,KAAA,EAAK,KAAA,CAAA,oBAAA,CAAA,UAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalRadioProps } from "../types/dist/index.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Radio.d.ts
|
|
8
8
|
interface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {
|
|
9
|
+
/** Ref to the underlying View */
|
|
9
10
|
ref?: Ref<View>;
|
|
10
11
|
/** Default checked state for uncontrolled mode */
|
|
11
12
|
defaultChecked?: boolean;
|
|
@@ -19,13 +20,14 @@ interface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {
|
|
|
19
20
|
/**
|
|
20
21
|
* **⚙️ A radio component**
|
|
21
22
|
*
|
|
22
|
-
* @componentType Client component
|
|
23
|
-
*
|
|
24
23
|
* @description
|
|
25
24
|
* A radio component allows users to select one option from a set.
|
|
26
25
|
* Unlike checkbox, radio buttons cannot have multiple selected in a group,
|
|
27
26
|
* allowing only one selection at a time.
|
|
28
27
|
*
|
|
28
|
+
* @category Form
|
|
29
|
+
* @platform mobile
|
|
30
|
+
*
|
|
29
31
|
* @example
|
|
30
32
|
* ```tsx
|
|
31
33
|
* import { Radio } from '@yahoo/uds-mobile';
|
|
@@ -38,9 +40,16 @@ interface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {
|
|
|
38
40
|
* - Forms: For selecting a single option from multiple choices
|
|
39
41
|
* - Settings: For toggling between mutually exclusive preferences
|
|
40
42
|
*
|
|
41
|
-
* @
|
|
43
|
+
* @accessibility
|
|
44
|
+
* - Sets `accessibilityRole="radio"` automatically
|
|
45
|
+
* - Announces checked/unchecked state
|
|
46
|
+
* - Label is used as accessibility label
|
|
47
|
+
* - Supports `reduceMotion` for users who prefer reduced motion
|
|
48
|
+
*
|
|
49
|
+
* @see {@link Checkbox} for multi-select options
|
|
50
|
+
* @see {@link Switch} for binary toggles
|
|
42
51
|
*/
|
|
43
|
-
declare const Radio:
|
|
52
|
+
declare const Radio: react.NamedExoticComponent<RadioProps>;
|
|
44
53
|
//#endregion
|
|
45
54
|
export { Radio, type RadioProps };
|
|
46
55
|
//# sourceMappingURL=Radio.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.mts","names":[],"sources":["../../src/components/Radio.tsx"],"
|
|
1
|
+
{"version":3,"file":"Radio.d.mts","names":[],"sources":["../../src/components/Radio.tsx"],"mappings":";;;;;;;UAwBU,UAAA,SAAmB,IAAA,CAAK,SAAA,YAAqB,mBAAA;;EAErD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR2B;EAU3B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;cAmDxB,KAAA,EAAK,KAAA,CAAA,oBAAA,CAAA,UAAA"}
|
|
@@ -17,13 +17,14 @@ const VARIANT_ERROR_MAP = {
|
|
|
17
17
|
/**
|
|
18
18
|
* **⚙️ A radio component**
|
|
19
19
|
*
|
|
20
|
-
* @componentType Client component
|
|
21
|
-
*
|
|
22
20
|
* @description
|
|
23
21
|
* A radio component allows users to select one option from a set.
|
|
24
22
|
* Unlike checkbox, radio buttons cannot have multiple selected in a group,
|
|
25
23
|
* allowing only one selection at a time.
|
|
26
24
|
*
|
|
25
|
+
* @category Form
|
|
26
|
+
* @platform mobile
|
|
27
|
+
*
|
|
27
28
|
* @example
|
|
28
29
|
* ```tsx
|
|
29
30
|
* import { Radio } from '@yahoo/uds-mobile';
|
|
@@ -36,9 +37,16 @@ const VARIANT_ERROR_MAP = {
|
|
|
36
37
|
* - Forms: For selecting a single option from multiple choices
|
|
37
38
|
* - Settings: For toggling between mutually exclusive preferences
|
|
38
39
|
*
|
|
39
|
-
* @
|
|
40
|
+
* @accessibility
|
|
41
|
+
* - Sets `accessibilityRole="radio"` automatically
|
|
42
|
+
* - Announces checked/unchecked state
|
|
43
|
+
* - Label is used as accessibility label
|
|
44
|
+
* - Supports `reduceMotion` for users who prefer reduced motion
|
|
45
|
+
*
|
|
46
|
+
* @see {@link Checkbox} for multi-select options
|
|
47
|
+
* @see {@link Switch} for binary toggles
|
|
40
48
|
*/
|
|
41
|
-
const Radio = memo(function Radio
|
|
49
|
+
const Radio = memo(function Radio({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, onChange, ref, ...viewProps }) {
|
|
42
50
|
const uid = `uds-radio-${useId()}`;
|
|
43
51
|
const isControlled = checkedProp !== void 0;
|
|
44
52
|
const [internalChecked, setInternalChecked] = useState(isControlled ? checkedProp : defaultChecked ?? false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.mjs","names":["VARIANT_ERROR_MAP: Record<RadioVariant, RadioStyleVariant>","Radio","valueState: RadioValueState","styleVariant: RadioStyleVariant"],"sources":["../../src/components/Radio.tsx"],"sourcesContent":["import type { RadioVariant, UniversalRadioProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { radioStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { HStack } from './HStack';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from RadioValue - maps boolean to 'checked'/'unchecked' string literals */\ntype RadioValueState = 'checked' | 'unchecked';\n\ninterface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the radio is disabled */\n disabled?: boolean;\n /** Whether the radio is required */\n required?: boolean;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype RadioStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<RadioVariant, RadioStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Radio Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A radio component**\n *\n * @componentType Client component\n *\n * @description\n * A radio component allows users to select one option from a set.\n * Unlike checkbox, radio buttons cannot have multiple selected in a group,\n * allowing only one selection at a time.\n *\n * @example\n * ```tsx\n * import { Radio } from '@yahoo/uds-mobile';\n *\n * <Radio label=\"Option A\" />\n * <Radio label=\"Option B\" checked={true} onChange={setChecked} />\n * ```\n *\n * @usage\n * - Forms: For selecting a single option from multiple choices\n * - Settings: For toggling between mutually exclusive preferences\n *\n * @see The {@link https://uds.build/docs/components/radio Radio Docs} for more info\n */\nconst Radio = memo(function Radio({\n // Radio props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n onChange,\n ref,\n ...viewProps\n}: RadioProps) {\n const generatedId = useId();\n const uid = `uds-radio-${generatedId}`;\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<boolean>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: RadioValueState = useMemo(() => {\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n // Circle visibility animation (for the inner dot)\n // When reduceMotion is true, still show/hide the circle but without animation\n const circleProgress = useDerivedValue(\n () => (shouldAnimate ? withSpring(checked ? 1 : 0, BUTTON_SPRING_CONFIG) : checked ? 1 : 0),\n [checked, shouldAnimate],\n );\n\n const radioAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n const circleAnimatedStyle = useAnimatedStyle(() => ({\n opacity: interpolate(circleProgress.value, [0, 1], [0, 1]),\n transform: [{ scale: interpolate(circleProgress.value, [0, 1], [0.5, 1]) }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: RadioStyleVariant = hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp;\n\n radioStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked\n pressed,\n });\n\n const rootStyle = useMemo(\n () => [radioStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [radioStyles.root, disabled],\n );\n\n const radioBoxStyle = useMemo(\n () => [\n radioStyles.radio,\n {\n alignItems: 'center' as const,\n justifyContent: 'center' as const,\n borderRadius: 9999,\n },\n radioAnimatedStyle,\n ],\n [radioStyles.radio, radioAnimatedStyle],\n );\n\n // Inner circle size: fixed 8x8px to match web implementation\n const INNER_CIRCLE_SIZE = 8;\n\n const circleStyle = useMemo(\n () => [\n radioStyles.radioCircle,\n {\n width: INNER_CIRCLE_SIZE,\n height: INNER_CIRCLE_SIZE,\n borderRadius: 9999,\n },\n circleAnimatedStyle,\n ],\n [radioStyles.radioCircle, circleAnimatedStyle],\n );\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n const content =\n typeof label === 'function' ? label() : isValidElement(label) ? label : String(label);\n\n const textContent =\n typeof content === 'string' ? <Text style={radioStyles.text}>{content}</Text> : content;\n\n if (required) {\n return (\n <HStack columnGap=\"1\" alignItems=\"flex-start\">\n {textContent}\n <Text style={radioStyles.text}>*</Text>\n </HStack>\n );\n }\n\n return textContent;\n }, [label, required, radioStyles.text]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked,\n }),\n [disabled, checked],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf=\"flex-start\"\n accessibilityRole=\"radio\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={radioBoxStyle}>\n <Animated.View style={circleStyle} />\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nRadio.displayName = 'Radio';\n\nexport { Radio, type RadioProps };\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Radio.mjs","names":[],"sources":["../../src/components/Radio.tsx"],"sourcesContent":["import type { RadioVariant, UniversalRadioProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { radioStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { HStack } from './HStack';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from RadioValue - maps boolean to 'checked'/'unchecked' string literals */\ntype RadioValueState = 'checked' | 'unchecked';\n\ninterface RadioProps extends Omit<ViewProps, 'style'>, UniversalRadioProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the radio is disabled */\n disabled?: boolean;\n /** Whether the radio is required */\n required?: boolean;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype RadioStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<RadioVariant, RadioStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Radio Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A radio component**\n *\n * @description\n * A radio component allows users to select one option from a set.\n * Unlike checkbox, radio buttons cannot have multiple selected in a group,\n * allowing only one selection at a time.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Radio } from '@yahoo/uds-mobile';\n *\n * <Radio label=\"Option A\" />\n * <Radio label=\"Option B\" checked={true} onChange={setChecked} />\n * ```\n *\n * @usage\n * - Forms: For selecting a single option from multiple choices\n * - Settings: For toggling between mutually exclusive preferences\n *\n * @accessibility\n * - Sets `accessibilityRole=\"radio\"` automatically\n * - Announces checked/unchecked state\n * - Label is used as accessibility label\n * - Supports `reduceMotion` for users who prefer reduced motion\n *\n * @see {@link Checkbox} for multi-select options\n * @see {@link Switch} for binary toggles\n */\nconst Radio = memo(function Radio({\n // Radio props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n onChange,\n ref,\n ...viewProps\n}: RadioProps) {\n const generatedId = useId();\n const uid = `uds-radio-${generatedId}`;\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<boolean>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: RadioValueState = useMemo(() => {\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n // Circle visibility animation (for the inner dot)\n // When reduceMotion is true, still show/hide the circle but without animation\n const circleProgress = useDerivedValue(\n () => (shouldAnimate ? withSpring(checked ? 1 : 0, BUTTON_SPRING_CONFIG) : checked ? 1 : 0),\n [checked, shouldAnimate],\n );\n\n const radioAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n const circleAnimatedStyle = useAnimatedStyle(() => ({\n opacity: interpolate(circleProgress.value, [0, 1], [0, 1]),\n transform: [{ scale: interpolate(circleProgress.value, [0, 1], [0.5, 1]) }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: RadioStyleVariant = hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp;\n\n radioStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked\n pressed,\n });\n\n const rootStyle = useMemo(\n () => [radioStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [radioStyles.root, disabled],\n );\n\n const radioBoxStyle = useMemo(\n () => [\n radioStyles.radio,\n {\n alignItems: 'center' as const,\n justifyContent: 'center' as const,\n borderRadius: 9999,\n },\n radioAnimatedStyle,\n ],\n [radioStyles.radio, radioAnimatedStyle],\n );\n\n // Inner circle size: fixed 8x8px to match web implementation\n const INNER_CIRCLE_SIZE = 8;\n\n const circleStyle = useMemo(\n () => [\n radioStyles.radioCircle,\n {\n width: INNER_CIRCLE_SIZE,\n height: INNER_CIRCLE_SIZE,\n borderRadius: 9999,\n },\n circleAnimatedStyle,\n ],\n [radioStyles.radioCircle, circleAnimatedStyle],\n );\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n const content =\n typeof label === 'function' ? label() : isValidElement(label) ? label : String(label);\n\n const textContent =\n typeof content === 'string' ? <Text style={radioStyles.text}>{content}</Text> : content;\n\n if (required) {\n return (\n <HStack columnGap=\"1\" alignItems=\"flex-start\">\n {textContent}\n <Text style={radioStyles.text}>*</Text>\n </HStack>\n );\n }\n\n return textContent;\n }, [label, required, radioStyles.text]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked,\n }),\n [disabled, checked],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf=\"flex-start\"\n accessibilityRole=\"radio\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={radioBoxStyle}>\n <Animated.View style={circleStyle} />\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nRadio.displayName = 'Radio';\n\nexport { Radio, type RadioProps };\n"],"mappings":"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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
const require_components_HStack = require('./HStack.cjs');
|
|
4
5
|
const require_components_VStack = require('./VStack.cjs');
|
|
5
6
|
let react = require("react");
|
|
@@ -17,6 +18,9 @@ let react_native_unistyles = require("react-native-unistyles");
|
|
|
17
18
|
* consistent padding and background styling. Uses Unistyles' built-in
|
|
18
19
|
* safe area insets via the `rt` runtime object.
|
|
19
20
|
*
|
|
21
|
+
* @category Layout
|
|
22
|
+
* @platform mobile
|
|
23
|
+
*
|
|
20
24
|
* @example
|
|
21
25
|
* ```tsx
|
|
22
26
|
* import { Screen } from '@yahoo/uds-mobile';
|
|
@@ -38,10 +42,12 @@ let react_native_unistyles = require("react-native-unistyles");
|
|
|
38
42
|
* - Use as the root component for screens
|
|
39
43
|
* - Use stickyHeader for persistent header content
|
|
40
44
|
* - Content is automatically scrollable
|
|
45
|
+
* - Safe area insets are handled automatically
|
|
41
46
|
*
|
|
42
|
-
* @see
|
|
47
|
+
* @see {@link VStack} for non-scrollable vertical layouts
|
|
48
|
+
* @see {@link Box} for custom containers
|
|
43
49
|
*/
|
|
44
|
-
const Screen = (0, react.memo)(function Screen
|
|
50
|
+
const Screen = (0, react.memo)(function Screen({ children, backgroundColor = "primary", spacingHorizontal = "6", spacingTop = "6", gap, stickyHeader, stickyHeaderProps, style, ref, ...props }) {
|
|
45
51
|
const { style: stickyHeaderStyle, ...stickyHeaderPropsWithoutStyle } = stickyHeaderProps ?? {};
|
|
46
52
|
generated_styles.styles.useVariants({
|
|
47
53
|
backgroundColor,
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
|
|
2
2
|
import { HStackProps } from "./HStack.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { ReactNode, Ref } from "react";
|
|
5
5
|
import { ScrollView, ScrollViewProps } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
7
7
|
|
|
8
8
|
//#region src/components/Screen.d.ts
|
|
9
9
|
interface ScreenProps extends ScrollViewProps {
|
|
10
|
+
/** Ref to the underlying ScrollView */
|
|
10
11
|
ref?: Ref<ScrollView>;
|
|
12
|
+
/** Background color of the screen */
|
|
11
13
|
backgroundColor?: StyleProps['backgroundColor'];
|
|
14
|
+
/** Horizontal padding for screen content */
|
|
12
15
|
spacingHorizontal?: StyleProps['spacingHorizontal'];
|
|
16
|
+
/** Top padding for screen content */
|
|
13
17
|
spacingTop?: StyleProps['spacingTop'];
|
|
18
|
+
/** Gap between child elements */
|
|
14
19
|
gap?: StyleProps['columnGap'];
|
|
20
|
+
/** Content that sticks to the top of the screen when scrolling */
|
|
15
21
|
stickyHeader?: ReactNode;
|
|
22
|
+
/** Props passed to the sticky header container */
|
|
16
23
|
stickyHeaderProps?: HStackProps;
|
|
17
24
|
}
|
|
18
25
|
/**
|
|
@@ -23,6 +30,9 @@ interface ScreenProps extends ScrollViewProps {
|
|
|
23
30
|
* consistent padding and background styling. Uses Unistyles' built-in
|
|
24
31
|
* safe area insets via the `rt` runtime object.
|
|
25
32
|
*
|
|
33
|
+
* @category Layout
|
|
34
|
+
* @platform mobile
|
|
35
|
+
*
|
|
26
36
|
* @example
|
|
27
37
|
* ```tsx
|
|
28
38
|
* import { Screen } from '@yahoo/uds-mobile';
|
|
@@ -44,10 +54,12 @@ interface ScreenProps extends ScrollViewProps {
|
|
|
44
54
|
* - Use as the root component for screens
|
|
45
55
|
* - Use stickyHeader for persistent header content
|
|
46
56
|
* - Content is automatically scrollable
|
|
57
|
+
* - Safe area insets are handled automatically
|
|
47
58
|
*
|
|
48
|
-
* @see
|
|
59
|
+
* @see {@link VStack} for non-scrollable vertical layouts
|
|
60
|
+
* @see {@link Box} for custom containers
|
|
49
61
|
*/
|
|
50
|
-
declare const Screen:
|
|
62
|
+
declare const Screen: react.NamedExoticComponent<ScreenProps>;
|
|
51
63
|
//#endregion
|
|
52
64
|
export { Screen, type ScreenProps };
|
|
53
65
|
//# sourceMappingURL=Screen.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Screen.d.cts","names":[],"sources":["../../src/components/Screen.tsx"],"
|
|
1
|
+
{"version":3,"file":"Screen.d.cts","names":[],"sources":["../../src/components/Screen.tsx"],"mappings":";;;;;;;;UAYU,WAAA,SAAoB,eAAA;;EAE5B,GAAA,GAAM,GAAA,CAAI,UAAA;EAFU;EAIpB,eAAA,GAAkB,UAAA;EAFR;EAIV,iBAAA,GAAoB,UAAA;EAFF;EAIlB,UAAA,GAAa,UAAA;EAAA;EAEb,GAAA,GAAM,UAAA;EAES;EAAf,YAAA,GAAe,SAAA;EAZa;EAc5B,iBAAA,GAAoB,WAAA;AAAA;;;;;;;;;;;;;;;;;;;AAAW;;;;;;;;;;;;;;;;;;;cAwC3B,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
|
|
2
2
|
import { HStackProps } from "./HStack.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { ReactNode, Ref } from "react";
|
|
5
5
|
import { ScrollView, ScrollViewProps } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
7
7
|
|
|
8
8
|
//#region src/components/Screen.d.ts
|
|
9
9
|
interface ScreenProps extends ScrollViewProps {
|
|
10
|
+
/** Ref to the underlying ScrollView */
|
|
10
11
|
ref?: Ref<ScrollView>;
|
|
12
|
+
/** Background color of the screen */
|
|
11
13
|
backgroundColor?: StyleProps['backgroundColor'];
|
|
14
|
+
/** Horizontal padding for screen content */
|
|
12
15
|
spacingHorizontal?: StyleProps['spacingHorizontal'];
|
|
16
|
+
/** Top padding for screen content */
|
|
13
17
|
spacingTop?: StyleProps['spacingTop'];
|
|
18
|
+
/** Gap between child elements */
|
|
14
19
|
gap?: StyleProps['columnGap'];
|
|
20
|
+
/** Content that sticks to the top of the screen when scrolling */
|
|
15
21
|
stickyHeader?: ReactNode;
|
|
22
|
+
/** Props passed to the sticky header container */
|
|
16
23
|
stickyHeaderProps?: HStackProps;
|
|
17
24
|
}
|
|
18
25
|
/**
|
|
@@ -23,6 +30,9 @@ interface ScreenProps extends ScrollViewProps {
|
|
|
23
30
|
* consistent padding and background styling. Uses Unistyles' built-in
|
|
24
31
|
* safe area insets via the `rt` runtime object.
|
|
25
32
|
*
|
|
33
|
+
* @category Layout
|
|
34
|
+
* @platform mobile
|
|
35
|
+
*
|
|
26
36
|
* @example
|
|
27
37
|
* ```tsx
|
|
28
38
|
* import { Screen } from '@yahoo/uds-mobile';
|
|
@@ -44,10 +54,12 @@ interface ScreenProps extends ScrollViewProps {
|
|
|
44
54
|
* - Use as the root component for screens
|
|
45
55
|
* - Use stickyHeader for persistent header content
|
|
46
56
|
* - Content is automatically scrollable
|
|
57
|
+
* - Safe area insets are handled automatically
|
|
47
58
|
*
|
|
48
|
-
* @see
|
|
59
|
+
* @see {@link VStack} for non-scrollable vertical layouts
|
|
60
|
+
* @see {@link Box} for custom containers
|
|
49
61
|
*/
|
|
50
|
-
declare const Screen:
|
|
62
|
+
declare const Screen: react.NamedExoticComponent<ScreenProps>;
|
|
51
63
|
//#endregion
|
|
52
64
|
export { Screen, type ScreenProps };
|
|
53
65
|
//# sourceMappingURL=Screen.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Screen.d.mts","names":[],"sources":["../../src/components/Screen.tsx"],"
|
|
1
|
+
{"version":3,"file":"Screen.d.mts","names":[],"sources":["../../src/components/Screen.tsx"],"mappings":";;;;;;;;UAYU,WAAA,SAAoB,eAAA;;EAE5B,GAAA,GAAM,GAAA,CAAI,UAAA;EAFU;EAIpB,eAAA,GAAkB,UAAA;EAFR;EAIV,iBAAA,GAAoB,UAAA;EAFF;EAIlB,UAAA,GAAa,UAAA;EAAA;EAEb,GAAA,GAAM,UAAA;EAES;EAAf,YAAA,GAAe,SAAA;EAZa;EAc5B,iBAAA,GAAoB,WAAA;AAAA;;;;;;;;;;;;;;;;;;;AAAW;;;;;;;;;;;;;;;;;;;cAwC3B,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -16,6 +16,9 @@ import { StyleSheet } from "react-native-unistyles";
|
|
|
16
16
|
* consistent padding and background styling. Uses Unistyles' built-in
|
|
17
17
|
* safe area insets via the `rt` runtime object.
|
|
18
18
|
*
|
|
19
|
+
* @category Layout
|
|
20
|
+
* @platform mobile
|
|
21
|
+
*
|
|
19
22
|
* @example
|
|
20
23
|
* ```tsx
|
|
21
24
|
* import { Screen } from '@yahoo/uds-mobile';
|
|
@@ -37,10 +40,12 @@ import { StyleSheet } from "react-native-unistyles";
|
|
|
37
40
|
* - Use as the root component for screens
|
|
38
41
|
* - Use stickyHeader for persistent header content
|
|
39
42
|
* - Content is automatically scrollable
|
|
43
|
+
* - Safe area insets are handled automatically
|
|
40
44
|
*
|
|
41
|
-
* @see
|
|
45
|
+
* @see {@link VStack} for non-scrollable vertical layouts
|
|
46
|
+
* @see {@link Box} for custom containers
|
|
42
47
|
*/
|
|
43
|
-
const Screen = memo(function Screen
|
|
48
|
+
const Screen = memo(function Screen({ children, backgroundColor = "primary", spacingHorizontal = "6", spacingTop = "6", gap, stickyHeader, stickyHeaderProps, style, ref, ...props }) {
|
|
44
49
|
const { style: stickyHeaderStyle, ...stickyHeaderPropsWithoutStyle } = stickyHeaderProps ?? {};
|
|
45
50
|
styles.useVariants({
|
|
46
51
|
backgroundColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Screen.mjs","names":[
|
|
1
|
+
{"version":3,"file":"Screen.mjs","names":[],"sources":["../../src/components/Screen.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type { ScrollViewProps, ViewProps } from 'react-native';\nimport { ScrollView } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport type { HStackProps } from './HStack';\nimport { HStack } from './HStack';\nimport { VStack } from './VStack';\n\ninterface ScreenProps extends ScrollViewProps {\n /** Ref to the underlying ScrollView */\n ref?: Ref<ScrollView>;\n /** Background color of the screen */\n backgroundColor?: StyleProps['backgroundColor'];\n /** Horizontal padding for screen content */\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n /** Top padding for screen content */\n spacingTop?: StyleProps['spacingTop'];\n /** Gap between child elements */\n gap?: StyleProps['columnGap'];\n /** Content that sticks to the top of the screen when scrolling */\n stickyHeader?: ReactNode;\n /** Props passed to the sticky header container */\n stickyHeaderProps?: HStackProps;\n}\n\n/**\n * **📱 A screen container with safe area handling**\n *\n * @description\n * A scrollable screen component that handles safe area insets and provides\n * consistent padding and background styling. Uses Unistyles' built-in\n * safe area insets via the `rt` runtime object.\n *\n * @category Layout\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Screen } from '@yahoo/uds-mobile';\n *\n * <Screen backgroundColor=\"primary\" spacingHorizontal=\"6\">\n * <Text>Screen content</Text>\n * </Screen>\n *\n * // With sticky header\n * <Screen\n * stickyHeader={<Text>Header</Text>}\n * stickyHeaderProps={{ backgroundColor: 'secondary' }}\n * >\n * <Text>Content</Text>\n * </Screen>\n * ```\n *\n * @usage\n * - Use as the root component for screens\n * - Use stickyHeader for persistent header content\n * - Content is automatically scrollable\n * - Safe area insets are handled automatically\n *\n * @see {@link VStack} for non-scrollable vertical layouts\n * @see {@link Box} for custom containers\n */\nconst Screen = memo(function Screen({\n children,\n // Background\n backgroundColor = 'primary',\n // Spacing\n spacingHorizontal = '6',\n spacingTop = '6',\n gap,\n // Header\n stickyHeader,\n stickyHeaderProps,\n style,\n ref,\n ...props\n}: ScreenProps) {\n const { style: stickyHeaderStyle, ...stickyHeaderPropsWithoutStyle } = stickyHeaderProps ?? {};\n\n styles.useVariants({\n backgroundColor,\n flex: '1',\n flexDirection: 'column',\n columnGap: gap,\n });\n\n // styles.foundation must be in deps - it returns a new reference when variants change\n const scrollStyles = useMemo(\n () => [styles.foundation as ViewProps['style'], style],\n [styles.foundation, style],\n );\n\n return (\n <VStack backgroundColor=\"primary\" style={screenStyles.wrapper}>\n <ScrollView\n ref={ref}\n style={scrollStyles}\n stickyHeaderIndices={stickyHeader ? [0] : undefined}\n {...props}\n >\n {stickyHeader && (\n <HStack\n spacingHorizontal=\"6\"\n spacingBottom=\"4\"\n backgroundColor=\"primary\"\n justifyContent=\"flex-end\"\n style={stickyHeaderStyle}\n {...stickyHeaderPropsWithoutStyle}\n >\n {stickyHeader}\n </HStack>\n )}\n <VStack flex=\"1\" spacingHorizontal={spacingHorizontal} spacingTop={spacingTop} gap={gap}>\n {children}\n </VStack>\n </ScrollView>\n </VStack>\n );\n});\n\nScreen.displayName = 'Screen';\n\nconst screenStyles = StyleSheet.create((_theme, rt) => ({\n wrapper: {\n flex: 1, // apply insets to the container,\n // so it will add required paddings\n paddingTop: rt.insets.top,\n paddingBottom: rt.insets.bottom,\n paddingLeft: rt.insets.left,\n paddingRight: rt.insets.right,\n },\n}));\n\nexport { Screen, type ScreenProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAM,SAAS,KAAK,SAAS,OAAO,EAClC,UAEA,kBAAkB,WAElB,oBAAoB,KACpB,aAAa,KACb,KAEA,cACA,mBACA,OACA,KACA,GAAG,SACW;CACd,MAAM,EAAE,OAAO,mBAAmB,GAAG,kCAAkC,qBAAqB,EAAE;AAE9F,QAAO,YAAY;EACjB;EACA,MAAM;EACN,eAAe;EACf,WAAW;EACZ,CAAC;CAGF,MAAM,eAAe,cACb,CAAC,OAAO,YAAkC,MAAM,EACtD,CAAC,OAAO,YAAY,MAAM,CAC3B;AAED,QACE,oBAAC;EAAO,iBAAgB;EAAU,OAAO,aAAa;YACpD,qBAAC;GACM;GACL,OAAO;GACP,qBAAqB,eAAe,CAAC,EAAE,GAAG;GAC1C,GAAI;cAEH,gBACC,oBAAC;IACC,mBAAkB;IAClB,eAAc;IACd,iBAAgB;IAChB,gBAAe;IACf,OAAO;IACP,GAAI;cAEH;KACM,EAEX,oBAAC;IAAO,MAAK;IAAuB;IAA+B;IAAiB;IACjF;KACM;IACE;GACN;EAEX;AAEF,OAAO,cAAc;AAErB,MAAM,eAAe,WAAW,QAAQ,QAAQ,QAAQ,EACtD,SAAS;CACP,MAAM;CAEN,YAAY,GAAG,OAAO;CACtB,eAAe,GAAG,OAAO;CACzB,aAAa,GAAG,OAAO;CACvB,cAAc,GAAG,OAAO;CACzB,EACF,EAAE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
const require_components_IconSlot = require('./IconSlot.cjs');
|
|
4
5
|
const require_components_Text = require('./Text.cjs');
|
|
5
6
|
const require_components_HStack = require('./HStack.cjs');
|
|
@@ -9,7 +10,7 @@ let generated_styles = require("../../generated/styles");
|
|
|
9
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
11
|
let react_native_unistyles = require("react-native-unistyles");
|
|
11
12
|
let react_native_reanimated = require("react-native-reanimated");
|
|
12
|
-
react_native_reanimated =
|
|
13
|
+
react_native_reanimated = require_runtime.__toESM(react_native_reanimated);
|
|
13
14
|
let react_native_unistyles_reanimated = require("react-native-unistyles/reanimated");
|
|
14
15
|
|
|
15
16
|
//#region src/components/Switch.tsx
|
|
@@ -25,6 +26,9 @@ const ANIMATION_DURATION = 120;
|
|
|
25
26
|
* A switch (also called a toggle) is a binary on/off input control.
|
|
26
27
|
* It allows users to pick between two clearly opposite choices.
|
|
27
28
|
*
|
|
29
|
+
* @category Form
|
|
30
|
+
* @platform mobile
|
|
31
|
+
*
|
|
28
32
|
* @example
|
|
29
33
|
* ```tsx
|
|
30
34
|
* import { Switch } from '@yahoo/uds-mobile';
|
|
@@ -34,9 +38,21 @@ const ANIMATION_DURATION = 120;
|
|
|
34
38
|
* <Switch onIcon="Check" offIcon="Cross" label="Sync" />
|
|
35
39
|
* ```
|
|
36
40
|
*
|
|
37
|
-
* @
|
|
41
|
+
* @usage
|
|
42
|
+
* - Settings: For toggling preferences on/off
|
|
43
|
+
* - Feature flags: For enabling/disabling features
|
|
44
|
+
* - Immediate effect toggles (no submit button needed)
|
|
45
|
+
*
|
|
46
|
+
* @accessibility
|
|
47
|
+
* - Sets `accessibilityRole="switch"` automatically
|
|
48
|
+
* - Announces on/off state to screen readers
|
|
49
|
+
* - Respects system reduce motion preference
|
|
50
|
+
* - Supports `reduceMotion` prop to disable animations
|
|
51
|
+
*
|
|
52
|
+
* @see {@link Checkbox} for forms with submit actions
|
|
53
|
+
* @see {@link Radio} for single-select options
|
|
38
54
|
*/
|
|
39
|
-
const Switch = (0, react.memo)(function Switch
|
|
55
|
+
const Switch = (0, react.memo)(function Switch({ isOn: isOnProp, defaultIsOn = false, onChange, label, labelPosition = "start", size = "md", onIcon, offIcon, disabled = false, required, accessibilityHint, reduceMotion = false, ref }) {
|
|
40
56
|
const isControlled = isOnProp !== void 0;
|
|
41
57
|
const [internalIsOn, setInternalIsOn] = (0, react.useState)(defaultIsOn);
|
|
42
58
|
const [prefersReducedMotion, setPrefersReducedMotion] = (0, react.useState)(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalSwitchProps } from "../types/dist/index.cjs";
|
|
3
3
|
import { IconSlotType } from "./IconSlot.cjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as react from "react";
|
|
5
5
|
import { Ref } from "react";
|
|
6
6
|
import { AccessibilityProps, View } from "react-native";
|
|
7
7
|
|
|
@@ -25,6 +25,9 @@ interface SwitchProps extends UniversalSwitchProps<IconSlotType> {
|
|
|
25
25
|
* A switch (also called a toggle) is a binary on/off input control.
|
|
26
26
|
* It allows users to pick between two clearly opposite choices.
|
|
27
27
|
*
|
|
28
|
+
* @category Form
|
|
29
|
+
* @platform mobile
|
|
30
|
+
*
|
|
28
31
|
* @example
|
|
29
32
|
* ```tsx
|
|
30
33
|
* import { Switch } from '@yahoo/uds-mobile';
|
|
@@ -34,9 +37,21 @@ interface SwitchProps extends UniversalSwitchProps<IconSlotType> {
|
|
|
34
37
|
* <Switch onIcon="Check" offIcon="Cross" label="Sync" />
|
|
35
38
|
* ```
|
|
36
39
|
*
|
|
37
|
-
* @
|
|
40
|
+
* @usage
|
|
41
|
+
* - Settings: For toggling preferences on/off
|
|
42
|
+
* - Feature flags: For enabling/disabling features
|
|
43
|
+
* - Immediate effect toggles (no submit button needed)
|
|
44
|
+
*
|
|
45
|
+
* @accessibility
|
|
46
|
+
* - Sets `accessibilityRole="switch"` automatically
|
|
47
|
+
* - Announces on/off state to screen readers
|
|
48
|
+
* - Respects system reduce motion preference
|
|
49
|
+
* - Supports `reduceMotion` prop to disable animations
|
|
50
|
+
*
|
|
51
|
+
* @see {@link Checkbox} for forms with submit actions
|
|
52
|
+
* @see {@link Radio} for single-select options
|
|
38
53
|
*/
|
|
39
|
-
declare const Switch:
|
|
54
|
+
declare const Switch: react.NamedExoticComponent<SwitchProps>;
|
|
40
55
|
//#endregion
|
|
41
56
|
export { Switch, type SwitchProps };
|
|
42
57
|
//# sourceMappingURL=Switch.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.cts","names":[],"sources":["../../src/components/Switch.tsx"],"
|
|
1
|
+
{"version":3,"file":"Switch.d.cts","names":[],"sources":["../../src/components/Switch.tsx"],"mappings":";;;;;;;;UAeU,WAAA,SAAoB,oBAAA,CAAqB,YAAA;;EAEjD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,QAAA,IAAY,KAAA;;EAEZ,QAAA;EAJU;EAMV,QAAA;EAEoB;EAApB,iBAAA,GAAoB,kBAAA;AAAA;;;;;;;;;;;;;;;AAAkB;;;;;;;;;;;;;;;;;;;cA2ClC,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalSwitchProps } from "../types/dist/index.mjs";
|
|
3
3
|
import { IconSlotType } from "./IconSlot.mjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as react from "react";
|
|
5
5
|
import { Ref } from "react";
|
|
6
6
|
import { AccessibilityProps, View } from "react-native";
|
|
7
7
|
|
|
@@ -25,6 +25,9 @@ interface SwitchProps extends UniversalSwitchProps<IconSlotType> {
|
|
|
25
25
|
* A switch (also called a toggle) is a binary on/off input control.
|
|
26
26
|
* It allows users to pick between two clearly opposite choices.
|
|
27
27
|
*
|
|
28
|
+
* @category Form
|
|
29
|
+
* @platform mobile
|
|
30
|
+
*
|
|
28
31
|
* @example
|
|
29
32
|
* ```tsx
|
|
30
33
|
* import { Switch } from '@yahoo/uds-mobile';
|
|
@@ -34,9 +37,21 @@ interface SwitchProps extends UniversalSwitchProps<IconSlotType> {
|
|
|
34
37
|
* <Switch onIcon="Check" offIcon="Cross" label="Sync" />
|
|
35
38
|
* ```
|
|
36
39
|
*
|
|
37
|
-
* @
|
|
40
|
+
* @usage
|
|
41
|
+
* - Settings: For toggling preferences on/off
|
|
42
|
+
* - Feature flags: For enabling/disabling features
|
|
43
|
+
* - Immediate effect toggles (no submit button needed)
|
|
44
|
+
*
|
|
45
|
+
* @accessibility
|
|
46
|
+
* - Sets `accessibilityRole="switch"` automatically
|
|
47
|
+
* - Announces on/off state to screen readers
|
|
48
|
+
* - Respects system reduce motion preference
|
|
49
|
+
* - Supports `reduceMotion` prop to disable animations
|
|
50
|
+
*
|
|
51
|
+
* @see {@link Checkbox} for forms with submit actions
|
|
52
|
+
* @see {@link Radio} for single-select options
|
|
38
53
|
*/
|
|
39
|
-
declare const Switch:
|
|
54
|
+
declare const Switch: react.NamedExoticComponent<SwitchProps>;
|
|
40
55
|
//#endregion
|
|
41
56
|
export { Switch, type SwitchProps };
|
|
42
57
|
//# sourceMappingURL=Switch.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.mts","names":[],"sources":["../../src/components/Switch.tsx"],"
|
|
1
|
+
{"version":3,"file":"Switch.d.mts","names":[],"sources":["../../src/components/Switch.tsx"],"mappings":";;;;;;;;UAeU,WAAA,SAAoB,oBAAA,CAAqB,YAAA;;EAEjD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,QAAA,IAAY,KAAA;;EAEZ,QAAA;EAJU;EAMV,QAAA;EAEoB;EAApB,iBAAA,GAAoB,kBAAA;AAAA;;;;;;;;;;;;;;;AAAkB;;;;;;;;;;;;;;;;;;;cA2ClC,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|