react-native-tinyui 0.5.0 → 1.1.0
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 +468 -28
- package/ios/ConcentricView/TinyuiConcentricView.h +12 -0
- package/ios/ConcentricView/TinyuiConcentricView.mm +60 -0
- package/ios/Core/Tinyui.mm +54 -0
- package/ios/Core/TinyuiComponentClasses.mm +44 -0
- package/ios/Menu/TinyuiMenuBuilder.swift +238 -0
- package/ios/Menu/TinyuiMenuProvider.swift +141 -75
- package/ios/Menu/TinyuiMenuView.mm +24 -35
- package/ios/Popover/TinyuiPopoverProvider.swift +198 -44
- package/ios/Popover/TinyuiPopoverView.mm +26 -1
- package/ios/SFSymbol/TinyuiSFSymbolEffects.h +9 -0
- package/ios/SFSymbol/TinyuiSFSymbolEffects.mm +180 -0
- package/ios/SFSymbol/TinyuiSFSymbolImage.h +8 -0
- package/ios/SFSymbol/TinyuiSFSymbolImage.mm +141 -0
- package/ios/SFSymbol/TinyuiSFSymbolShadowNode.h +31 -0
- package/ios/SFSymbol/TinyuiSFSymbolShadowNode.mm +30 -0
- package/ios/SFSymbol/TinyuiSFSymbolView.h +4 -0
- package/ios/SFSymbol/TinyuiSFSymbolView.mm +173 -0
- package/ios/Stepper/TinyuiStepperShadowNode.h +32 -0
- package/ios/Stepper/TinyuiStepperShadowNode.mm +28 -0
- package/ios/Stepper/TinyuiStepperView.h +12 -0
- package/ios/Stepper/TinyuiStepperView.mm +128 -0
- package/ios/TipKit/TinyuiTip.swift +31 -0
- package/ios/TipKit/TinyuiTipPopoverProvider.swift +276 -0
- package/ios/TipKit/TinyuiTipPopoverView.h +8 -0
- package/ios/TipKit/TinyuiTipPopoverView.mm +114 -0
- package/ios/TipKit/TinyuiTipsRuntime.swift +148 -0
- package/lib/module/ConcentricView/ConcentricViewNativeComponent.ts +14 -0
- package/lib/module/ConcentricView/index.js +29 -0
- package/lib/module/ConcentricView/index.js.map +1 -0
- package/lib/module/ConcentricView/types.js +4 -0
- package/lib/module/ConcentricView/types.js.map +1 -0
- package/lib/module/Menu/MenuNativeComponent.ts +12 -3
- package/lib/module/Menu/index.js +17 -12
- package/lib/module/Menu/index.js.map +1 -1
- package/lib/module/Menu/options.js +4 -12
- package/lib/module/Menu/options.js.map +1 -1
- package/lib/module/NativeTinyui.js.map +1 -1
- package/lib/module/Popover/index.js +4 -2
- package/lib/module/Popover/index.js.map +1 -1
- package/lib/module/SFSymbol/SFSymbolNativeComponent.ts +20 -0
- package/lib/module/SFSymbol/index.js +73 -0
- package/lib/module/SFSymbol/index.js.map +1 -0
- package/lib/module/SFSymbol/options.js +79 -0
- package/lib/module/SFSymbol/options.js.map +1 -0
- package/lib/module/SFSymbol/types.js +4 -0
- package/lib/module/SFSymbol/types.js.map +1 -0
- package/lib/module/Stepper/StepperNativeComponent.ts +29 -0
- package/lib/module/Stepper/index.js +75 -0
- package/lib/module/Stepper/index.js.map +1 -0
- package/lib/module/Stepper/types.js +4 -0
- package/lib/module/Stepper/types.js.map +1 -0
- package/lib/module/TipKit/Popover.js +89 -0
- package/lib/module/TipKit/Popover.js.map +1 -0
- package/lib/module/TipKit/TipPopoverNativeComponent.ts +37 -0
- package/lib/module/TipKit/index.js +28 -0
- package/lib/module/TipKit/index.js.map +1 -0
- package/lib/module/TipKit/types.js +4 -0
- package/lib/module/TipKit/types.js.map +1 -0
- package/lib/module/TipKit/validation.js +24 -0
- package/lib/module/TipKit/validation.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/getNativeTinyui.js.map +1 -1
- package/lib/typescript/src/ConcentricView/ConcentricViewNativeComponent.d.ts +7 -0
- package/lib/typescript/src/ConcentricView/ConcentricViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/ConcentricView/index.d.ts +4 -0
- package/lib/typescript/src/ConcentricView/index.d.ts.map +1 -0
- package/lib/typescript/src/ConcentricView/types.d.ts +6 -0
- package/lib/typescript/src/ConcentricView/types.d.ts.map +1 -0
- package/lib/typescript/src/Menu/MenuNativeComponent.d.ts +8 -4
- package/lib/typescript/src/Menu/MenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/Menu/index.d.ts +1 -1
- package/lib/typescript/src/Menu/index.d.ts.map +1 -1
- package/lib/typescript/src/Menu/options.d.ts +1 -5
- package/lib/typescript/src/Menu/options.d.ts.map +1 -1
- package/lib/typescript/src/Menu/types.d.ts +26 -7
- package/lib/typescript/src/Menu/types.d.ts.map +1 -1
- package/lib/typescript/src/NativeTinyui.d.ts +2 -0
- package/lib/typescript/src/NativeTinyui.d.ts.map +1 -1
- package/lib/typescript/src/Popover/index.d.ts.map +1 -1
- package/lib/typescript/src/Popover/types.d.ts +2 -0
- package/lib/typescript/src/Popover/types.d.ts.map +1 -1
- package/lib/typescript/src/SFSymbol/SFSymbolNativeComponent.d.ts +11 -0
- package/lib/typescript/src/SFSymbol/SFSymbolNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/SFSymbol/index.d.ts +4 -0
- package/lib/typescript/src/SFSymbol/index.d.ts.map +1 -0
- package/lib/typescript/src/SFSymbol/options.d.ts +86 -0
- package/lib/typescript/src/SFSymbol/options.d.ts.map +1 -0
- package/lib/typescript/src/SFSymbol/types.d.ts +113 -0
- package/lib/typescript/src/SFSymbol/types.d.ts.map +1 -0
- package/lib/typescript/src/Stepper/StepperNativeComponent.d.ts +21 -0
- package/lib/typescript/src/Stepper/StepperNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/Stepper/index.d.ts +4 -0
- package/lib/typescript/src/Stepper/index.d.ts.map +1 -0
- package/lib/typescript/src/Stepper/types.d.ts +24 -0
- package/lib/typescript/src/Stepper/types.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/Popover.d.ts +3 -0
- package/lib/typescript/src/TipKit/Popover.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/TipPopoverNativeComponent.d.ts +38 -0
- package/lib/typescript/src/TipKit/TipPopoverNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/index.d.ts +10 -0
- package/lib/typescript/src/TipKit/index.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/types.d.ts +46 -0
- package/lib/typescript/src/TipKit/types.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/validation.d.ts +4 -0
- package/lib/typescript/src/TipKit/validation.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/getNativeTinyui.d.ts +1 -1
- package/lib/typescript/src/utils/getNativeTinyui.d.ts.map +1 -1
- package/package.json +37 -2
- package/{Tinyui.podspec → react-native-tinyui.podspec} +23 -2
- package/src/ConcentricView/ConcentricViewNativeComponent.ts +14 -0
- package/src/ConcentricView/index.tsx +34 -0
- package/src/ConcentricView/types.ts +6 -0
- package/src/Menu/MenuNativeComponent.ts +12 -3
- package/src/Menu/index.tsx +35 -12
- package/src/Menu/options.ts +2 -20
- package/src/Menu/types.ts +28 -7
- package/src/NativeTinyui.ts +2 -0
- package/src/Popover/index.tsx +8 -3
- package/src/Popover/types.ts +2 -0
- package/src/SFSymbol/SFSymbolNativeComponent.ts +20 -0
- package/src/SFSymbol/index.tsx +89 -0
- package/src/SFSymbol/options.ts +116 -0
- package/src/SFSymbol/types.ts +158 -0
- package/src/Stepper/StepperNativeComponent.ts +29 -0
- package/src/Stepper/index.tsx +91 -0
- package/src/Stepper/types.ts +24 -0
- package/src/TipKit/Popover.tsx +87 -0
- package/src/TipKit/TipPopoverNativeComponent.ts +37 -0
- package/src/TipKit/index.ts +47 -0
- package/src/TipKit/types.ts +57 -0
- package/src/TipKit/validation.ts +39 -0
- package/src/index.tsx +31 -0
- package/src/utils/getNativeTinyui.ts +8 -1
- package/ios/Core/TinyuiHostingHelpers.swift +0 -74
- package/ios/Menu/TinyuiMenuViewSwift.swift +0 -326
- package/ios/Popover/TinyuiPopoverViewSwift.swift +0 -88
package/src/Popover/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, useCallback, useState, type ComponentRef } from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Pressable, StyleSheet, View } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { assertComponentEnabled } from '../utils';
|
|
6
6
|
import { PopoverClose } from './PopoverClose';
|
|
@@ -59,7 +59,11 @@ const PopoverRoot = forwardRef<ComponentRef<typeof View>, PopoverProps>(
|
|
|
59
59
|
}}
|
|
60
60
|
>
|
|
61
61
|
<Pressable onPress={() => setOpen(true)}>{children}</Pressable>
|
|
62
|
-
<View
|
|
62
|
+
<View
|
|
63
|
+
collapsable={false}
|
|
64
|
+
style={styles.content}
|
|
65
|
+
pointerEvents="box-none"
|
|
66
|
+
>
|
|
63
67
|
{renderedContent}
|
|
64
68
|
</View>
|
|
65
69
|
</NativePopoverView>
|
|
@@ -78,7 +82,8 @@ function renderContent(
|
|
|
78
82
|
const styles = StyleSheet.create({
|
|
79
83
|
content: {
|
|
80
84
|
position: 'absolute',
|
|
81
|
-
|
|
85
|
+
top: 0,
|
|
86
|
+
left: 0,
|
|
82
87
|
overflow: 'hidden',
|
|
83
88
|
},
|
|
84
89
|
});
|
package/src/Popover/types.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface PopoverProps extends Omit<ViewProps, 'children'> {
|
|
|
27
27
|
/**
|
|
28
28
|
* Content shown inside the popover. Pass a node, or a render function that
|
|
29
29
|
* receives `{ close }` to dismiss the popover from within the content.
|
|
30
|
+
* The content's layout determines the popover size, including live updates.
|
|
31
|
+
* Leave its background transparent to reveal the system popover material.
|
|
30
32
|
*/
|
|
31
33
|
content: PopoverContent;
|
|
32
34
|
/** Controlled presentation state. */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
export interface NativeSFSymbolProps extends ViewProps {
|
|
8
|
+
configuration: CodegenTypes.UnsafeMixed;
|
|
9
|
+
effects: CodegenTypes.UnsafeMixed;
|
|
10
|
+
contentTransition: CodegenTypes.UnsafeMixed;
|
|
11
|
+
resizeMode?: CodegenTypes.WithDefault<string, 'center'>;
|
|
12
|
+
respectReduceMotion?: CodegenTypes.WithDefault<boolean, true>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default codegenNativeComponent<NativeSFSymbolProps>(
|
|
16
|
+
'TinyuiSFSymbolView',
|
|
17
|
+
{
|
|
18
|
+
excludedPlatforms: ['android'],
|
|
19
|
+
}
|
|
20
|
+
);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { forwardRef, type ComponentRef } from 'react';
|
|
2
|
+
import { StyleSheet, useWindowDimensions, type View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { assertComponentEnabled } from '../utils';
|
|
5
|
+
import NativeSFSymbolView from './SFSymbolNativeComponent';
|
|
6
|
+
import { serializeSFSymbol } from './options';
|
|
7
|
+
import type { SFSymbolProps } from './types';
|
|
8
|
+
|
|
9
|
+
export const SFSymbol = forwardRef<ComponentRef<typeof View>, SFSymbolProps>(
|
|
10
|
+
function SFSymbolRoot(
|
|
11
|
+
{
|
|
12
|
+
name,
|
|
13
|
+
source,
|
|
14
|
+
size,
|
|
15
|
+
weight,
|
|
16
|
+
scale,
|
|
17
|
+
textStyle,
|
|
18
|
+
fontFamily,
|
|
19
|
+
allowFontScaling,
|
|
20
|
+
maxFontSizeMultiplier,
|
|
21
|
+
renderingMode,
|
|
22
|
+
color,
|
|
23
|
+
paletteColors,
|
|
24
|
+
variableValue,
|
|
25
|
+
variableValueMode,
|
|
26
|
+
colorRenderingMode,
|
|
27
|
+
effect,
|
|
28
|
+
contentTransition,
|
|
29
|
+
respectReduceMotion = true,
|
|
30
|
+
resizeMode = 'center',
|
|
31
|
+
style,
|
|
32
|
+
accessible = false,
|
|
33
|
+
accessibilityRole = 'image',
|
|
34
|
+
...viewProps
|
|
35
|
+
},
|
|
36
|
+
ref
|
|
37
|
+
) {
|
|
38
|
+
assertComponentEnabled('SFSymbol');
|
|
39
|
+
const { fontScale } = useWindowDimensions();
|
|
40
|
+
const serialized = serializeSFSymbol(
|
|
41
|
+
{
|
|
42
|
+
name,
|
|
43
|
+
source,
|
|
44
|
+
size,
|
|
45
|
+
weight,
|
|
46
|
+
scale,
|
|
47
|
+
textStyle,
|
|
48
|
+
fontFamily,
|
|
49
|
+
allowFontScaling,
|
|
50
|
+
maxFontSizeMultiplier,
|
|
51
|
+
renderingMode,
|
|
52
|
+
color,
|
|
53
|
+
paletteColors,
|
|
54
|
+
variableValue,
|
|
55
|
+
variableValueMode,
|
|
56
|
+
colorRenderingMode,
|
|
57
|
+
effect,
|
|
58
|
+
contentTransition,
|
|
59
|
+
},
|
|
60
|
+
fontScale
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<NativeSFSymbolView
|
|
65
|
+
{...viewProps}
|
|
66
|
+
{...serialized}
|
|
67
|
+
ref={ref}
|
|
68
|
+
accessible={accessible}
|
|
69
|
+
accessibilityRole={accessibilityRole}
|
|
70
|
+
respectReduceMotion={respectReduceMotion}
|
|
71
|
+
resizeMode={resizeMode}
|
|
72
|
+
style={[styles.symbol, style]}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const styles = StyleSheet.create({ symbol: { alignSelf: 'flex-start' } });
|
|
79
|
+
|
|
80
|
+
export type {
|
|
81
|
+
SFSymbolContentTransition,
|
|
82
|
+
SFSymbolEffect,
|
|
83
|
+
SFSymbolEffectOptions,
|
|
84
|
+
SFSymbolProps,
|
|
85
|
+
SFSymbolRenderingMode,
|
|
86
|
+
SFSymbolScale,
|
|
87
|
+
SFSymbolTextStyle,
|
|
88
|
+
SFSymbolWeight,
|
|
89
|
+
} from './types';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { processColor } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { SFSymbolEffect, SFSymbolProps } from './types';
|
|
4
|
+
|
|
5
|
+
function finite(name: string, value: number | undefined, minimum: number) {
|
|
6
|
+
if (value !== undefined && (!Number.isFinite(value) || value < minimum)) {
|
|
7
|
+
throw new RangeError(
|
|
8
|
+
`[TinyUI] SFSymbol ${name} must be finite and >= ${minimum}.`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function positive(name: string, value: number | undefined) {
|
|
14
|
+
finite(name, value, 0);
|
|
15
|
+
if (value === 0) {
|
|
16
|
+
throw new RangeError(`[TinyUI] SFSymbol ${name} must be greater than 0.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function serializeSFSymbol(props: SFSymbolProps, fontScale: number) {
|
|
21
|
+
positive('size', props.size);
|
|
22
|
+
finite('variableValue', props.variableValue, 0);
|
|
23
|
+
if (props.variableValue !== undefined && props.variableValue > 1) {
|
|
24
|
+
throw new RangeError('[TinyUI] SFSymbol variableValue must be <= 1.');
|
|
25
|
+
}
|
|
26
|
+
if (props.maxFontSizeMultiplier !== 0) {
|
|
27
|
+
finite('maxFontSizeMultiplier', props.maxFontSizeMultiplier, 1);
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
props.paletteColors &&
|
|
31
|
+
(props.paletteColors.length < 1 ||
|
|
32
|
+
props.paletteColors.length > 3 ||
|
|
33
|
+
props.paletteColors.some((color) => color === undefined))
|
|
34
|
+
) {
|
|
35
|
+
throw new RangeError(
|
|
36
|
+
'[TinyUI] SFSymbol paletteColors needs 1 to 3 colors.'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const effects: readonly SFSymbolEffect[] = props.effect
|
|
41
|
+
? Array.isArray(props.effect)
|
|
42
|
+
? props.effect
|
|
43
|
+
: [props.effect as SFSymbolEffect]
|
|
44
|
+
: [];
|
|
45
|
+
const types = new Set<string>();
|
|
46
|
+
for (const effect of effects) {
|
|
47
|
+
if (types.has(effect.type)) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`[TinyUI] SFSymbol has duplicate ${effect.type} effects.`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
types.add(effect.type);
|
|
53
|
+
positive('effect.options.speed', effect.options?.speed);
|
|
54
|
+
finite('effect.options.repeatDelay', effect.options?.repeatDelay, 0);
|
|
55
|
+
const repeat = effect.options?.repeat;
|
|
56
|
+
if (typeof repeat === 'number') {
|
|
57
|
+
positive('effect.options.repeat', repeat);
|
|
58
|
+
if (!Number.isSafeInteger(repeat)) {
|
|
59
|
+
throw new RangeError(
|
|
60
|
+
'[TinyUI] SFSymbol repeat must be a safe integer.'
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (
|
|
65
|
+
effect.options?.repeatBehavior === 'continuous' &&
|
|
66
|
+
((repeat !== undefined && repeat !== 'forever') ||
|
|
67
|
+
effect.options.repeatDelay !== undefined)
|
|
68
|
+
) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
'[TinyUI] SFSymbol continuous repetition cannot have a count or delay.'
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
effect.type === 'wiggle' &&
|
|
75
|
+
effect.angle !== undefined &&
|
|
76
|
+
!Number.isFinite(effect.angle)
|
|
77
|
+
) {
|
|
78
|
+
throw new RangeError('[TinyUI] SFSymbol wiggle angle must be finite.');
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
typeof effect.trigger === 'number' &&
|
|
82
|
+
!Number.isFinite(effect.trigger)
|
|
83
|
+
) {
|
|
84
|
+
throw new RangeError('[TinyUI] SFSymbol effect trigger must be finite.');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
positive('contentTransition.speed', props.contentTransition?.speed);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
configuration: {
|
|
91
|
+
name: props.name,
|
|
92
|
+
source: props.source ?? 'system',
|
|
93
|
+
size: props.size ?? 17,
|
|
94
|
+
weight: props.weight ?? 'unspecified',
|
|
95
|
+
scale: props.scale ?? 'default',
|
|
96
|
+
textStyle: props.textStyle,
|
|
97
|
+
fontFamily: props.fontFamily,
|
|
98
|
+
fontScale:
|
|
99
|
+
props.allowFontScaling === false
|
|
100
|
+
? 1
|
|
101
|
+
: Math.min(fontScale, props.maxFontSizeMultiplier || Infinity),
|
|
102
|
+
renderingMode: props.renderingMode ?? 'automatic',
|
|
103
|
+
color: props.color === undefined ? undefined : processColor(props.color),
|
|
104
|
+
paletteColors: props.paletteColors?.map((color) => processColor(color)),
|
|
105
|
+
variableValue: props.variableValue,
|
|
106
|
+
variableValueMode: props.variableValueMode ?? 'automatic',
|
|
107
|
+
colorRenderingMode: props.colorRenderingMode ?? 'automatic',
|
|
108
|
+
},
|
|
109
|
+
effects: effects.map((effect) => ({
|
|
110
|
+
...effect,
|
|
111
|
+
active: effect.active ?? true,
|
|
112
|
+
animated: effect.animated ?? true,
|
|
113
|
+
})),
|
|
114
|
+
contentTransition: props.contentTransition ?? {},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type SFSymbolWeight =
|
|
4
|
+
| 'unspecified'
|
|
5
|
+
| 'ultraLight'
|
|
6
|
+
| 'thin'
|
|
7
|
+
| 'light'
|
|
8
|
+
| 'regular'
|
|
9
|
+
| 'medium'
|
|
10
|
+
| 'semibold'
|
|
11
|
+
| 'bold'
|
|
12
|
+
| 'heavy'
|
|
13
|
+
| 'black';
|
|
14
|
+
|
|
15
|
+
export type SFSymbolScale =
|
|
16
|
+
'default' | 'unspecified' | 'small' | 'medium' | 'large';
|
|
17
|
+
export type SFSymbolRenderingMode =
|
|
18
|
+
'automatic' | 'monochrome' | 'hierarchical' | 'palette' | 'multicolor';
|
|
19
|
+
export type SFSymbolTextStyle =
|
|
20
|
+
| 'extraLargeTitle'
|
|
21
|
+
| 'extraLargeTitle2'
|
|
22
|
+
| 'largeTitle'
|
|
23
|
+
| 'title1'
|
|
24
|
+
| 'title2'
|
|
25
|
+
| 'title3'
|
|
26
|
+
| 'headline'
|
|
27
|
+
| 'subheadline'
|
|
28
|
+
| 'body'
|
|
29
|
+
| 'callout'
|
|
30
|
+
| 'footnote'
|
|
31
|
+
| 'caption1'
|
|
32
|
+
| 'caption2';
|
|
33
|
+
|
|
34
|
+
export interface SFSymbolEffectOptions {
|
|
35
|
+
/** Positive speed multiplier. Defaults to the system speed (1). */
|
|
36
|
+
speed?: number;
|
|
37
|
+
/** Play count, forever, or false for one play. Omit for the system default. */
|
|
38
|
+
repeat?: number | 'forever' | false;
|
|
39
|
+
/** iOS 18+. Continuous repeats forever; periodic supports count and delay. */
|
|
40
|
+
repeatBehavior?: 'periodic' | 'continuous';
|
|
41
|
+
/** Seconds between periodic repetitions (iOS 18+). */
|
|
42
|
+
repeatDelay?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface EffectPlayback {
|
|
46
|
+
/** Whether this effect is applied. Defaults to true. */
|
|
47
|
+
active?: boolean;
|
|
48
|
+
/** Change this value to replay the same effect. Stable values do not replay. */
|
|
49
|
+
trigger?: string | number;
|
|
50
|
+
/** Animate applying/removing the effect. Defaults to true. */
|
|
51
|
+
animated?: boolean;
|
|
52
|
+
options?: SFSymbolEffectOptions;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type LayerBehavior = 'byLayer' | 'wholeSymbol';
|
|
56
|
+
type VerticalDirection = 'up' | 'down';
|
|
57
|
+
|
|
58
|
+
/** Only modifiers supported by each Apple preset are accepted. */
|
|
59
|
+
export type SFSymbolEffect = EffectPlayback &
|
|
60
|
+
(
|
|
61
|
+
| { type: 'pulse'; scope?: LayerBehavior }
|
|
62
|
+
| {
|
|
63
|
+
type: 'bounce' | 'scale' | 'appear' | 'disappear';
|
|
64
|
+
direction?: VerticalDirection;
|
|
65
|
+
scope?: LayerBehavior;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
type: 'variableColor';
|
|
69
|
+
iteration?: 'iterative' | 'cumulative';
|
|
70
|
+
reversing?: boolean;
|
|
71
|
+
inactiveLayers?: 'hide' | 'dim';
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
/** iOS 18+. */
|
|
75
|
+
type: 'wiggle';
|
|
76
|
+
direction?:
|
|
77
|
+
| VerticalDirection
|
|
78
|
+
| 'left'
|
|
79
|
+
| 'right'
|
|
80
|
+
| 'forward'
|
|
81
|
+
| 'backward'
|
|
82
|
+
| 'clockwise'
|
|
83
|
+
| 'counterClockwise';
|
|
84
|
+
/** Custom angle in degrees, clockwise from +x; overrides direction. */
|
|
85
|
+
angle?: number;
|
|
86
|
+
scope?: LayerBehavior;
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
/** iOS 18+. */
|
|
90
|
+
type: 'rotate';
|
|
91
|
+
direction?: 'clockwise' | 'counterClockwise';
|
|
92
|
+
scope?: LayerBehavior;
|
|
93
|
+
}
|
|
94
|
+
| {
|
|
95
|
+
/** iOS 18+. */
|
|
96
|
+
type: 'breathe';
|
|
97
|
+
style?: 'plain' | 'pulse';
|
|
98
|
+
scope?: LayerBehavior;
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
/** iOS 26+. */
|
|
102
|
+
type: 'drawOn';
|
|
103
|
+
scope?: LayerBehavior | 'individually';
|
|
104
|
+
}
|
|
105
|
+
| {
|
|
106
|
+
/** iOS 26+. */
|
|
107
|
+
type: 'drawOff';
|
|
108
|
+
scope?: LayerBehavior | 'individually';
|
|
109
|
+
reversed?: boolean;
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
export interface SFSymbolContentTransition {
|
|
114
|
+
/** Magic Replace requires iOS 18; earlier versions use the configured replace. */
|
|
115
|
+
type: 'automatic' | 'replace' | 'magicReplace';
|
|
116
|
+
/** Replace style, also used as the Magic Replace fallback. */
|
|
117
|
+
direction?: 'downUp' | 'upUp' | 'offUp';
|
|
118
|
+
scope?: LayerBehavior;
|
|
119
|
+
/** Positive transition speed multiplier. Defaults to 1. */
|
|
120
|
+
speed?: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface SFSymbolProps extends Omit<ViewProps, 'children'> {
|
|
124
|
+
/** Full SF Symbol name, including variants such as .circle.fill. */
|
|
125
|
+
name: string;
|
|
126
|
+
/** Load a system symbol (default) or a custom symbol in the app asset catalog. */
|
|
127
|
+
source?: 'system' | 'asset';
|
|
128
|
+
/** Point size before font scaling. Defaults to 17. textStyle takes precedence. */
|
|
129
|
+
size?: number;
|
|
130
|
+
weight?: SFSymbolWeight;
|
|
131
|
+
scale?: SFSymbolScale;
|
|
132
|
+
textStyle?: SFSymbolTextStyle;
|
|
133
|
+
/** Font/PostScript name used to derive the symbol's font metrics. */
|
|
134
|
+
fontFamily?: string;
|
|
135
|
+
/** Apply React Native's fontScale to the point size. Defaults to true. */
|
|
136
|
+
allowFontScaling?: boolean;
|
|
137
|
+
/** Maximum font scale, >= 1. Zero/undefined means no limit. */
|
|
138
|
+
maxFontSizeMultiplier?: number;
|
|
139
|
+
renderingMode?: SFSymbolRenderingMode;
|
|
140
|
+
/** Tint / primary hierarchical color. Defaults to the semantic label color. */
|
|
141
|
+
color?: ColorValue;
|
|
142
|
+
/** One to three colors for palette rendering, in primary-to-tertiary order. */
|
|
143
|
+
paletteColors?: readonly [ColorValue, ColorValue?, ColorValue?];
|
|
144
|
+
/** Variable color/draw progress, from 0 to 1. Omit for the symbol default. */
|
|
145
|
+
variableValue?: number;
|
|
146
|
+
/** iOS 26+. Earlier versions retain the system's variable color behavior. */
|
|
147
|
+
variableValueMode?: 'automatic' | 'color' | 'draw';
|
|
148
|
+
/** iOS 26+. Earlier versions use flat colors. */
|
|
149
|
+
colorRenderingMode?: 'automatic' | 'flat' | 'gradient';
|
|
150
|
+
/** Native image fitting within an explicitly sized frame. Defaults to center. */
|
|
151
|
+
resizeMode?: 'center' | 'contain' | 'cover' | 'stretch';
|
|
152
|
+
/** One preset or multiple distinct presets. Unsupported OS presets are ignored. */
|
|
153
|
+
effect?: SFSymbolEffect | readonly SFSymbolEffect[];
|
|
154
|
+
/** Animate changes to the name or image configuration. Omit to update instantly. */
|
|
155
|
+
contentTransition?: SFSymbolContentTransition;
|
|
156
|
+
/** Honor the system Reduce Motion setting. Defaults to true. */
|
|
157
|
+
respectReduceMotion?: boolean;
|
|
158
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
type StepperChangeEvent = Readonly<{
|
|
8
|
+
value: CodegenTypes.Double;
|
|
9
|
+
eventCount: CodegenTypes.Int32;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export interface NativeStepperProps extends ViewProps {
|
|
13
|
+
value?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
14
|
+
minimumValue?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
15
|
+
maximumValue?: CodegenTypes.WithDefault<CodegenTypes.Double, 100>;
|
|
16
|
+
stepValue?: CodegenTypes.WithDefault<CodegenTypes.Double, 1>;
|
|
17
|
+
isContinuous?: CodegenTypes.WithDefault<boolean, true>;
|
|
18
|
+
autorepeat?: CodegenTypes.WithDefault<boolean, true>;
|
|
19
|
+
wraps?: CodegenTypes.WithDefault<boolean, false>;
|
|
20
|
+
disabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
21
|
+
controlled?: CodegenTypes.WithDefault<boolean, false>;
|
|
22
|
+
mostRecentEventCount?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
23
|
+
// Match the bubbling topChange event inherited from React Native's base view.
|
|
24
|
+
onChange?: CodegenTypes.BubblingEventHandler<StepperChangeEvent>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default codegenNativeComponent<NativeStepperProps>('TinyuiStepperView', {
|
|
28
|
+
excludedPlatforms: ['android'],
|
|
29
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { forwardRef, useState, type ComponentRef } from 'react';
|
|
2
|
+
import { StyleSheet, type View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { assertComponentEnabled } from '../utils';
|
|
5
|
+
import NativeStepperView from './StepperNativeComponent';
|
|
6
|
+
import type { StepperProps } from './types';
|
|
7
|
+
|
|
8
|
+
export const Stepper = forwardRef<ComponentRef<typeof View>, StepperProps>(
|
|
9
|
+
function StepperRoot(
|
|
10
|
+
{
|
|
11
|
+
value,
|
|
12
|
+
defaultValue = 0,
|
|
13
|
+
minimumValue = 0,
|
|
14
|
+
maximumValue = 100,
|
|
15
|
+
stepValue = 1,
|
|
16
|
+
isContinuous = true,
|
|
17
|
+
autorepeat = true,
|
|
18
|
+
wraps = false,
|
|
19
|
+
disabled,
|
|
20
|
+
onValueChange,
|
|
21
|
+
style,
|
|
22
|
+
accessibilityState,
|
|
23
|
+
...viewProps
|
|
24
|
+
},
|
|
25
|
+
ref
|
|
26
|
+
) {
|
|
27
|
+
assertComponentEnabled('Stepper');
|
|
28
|
+
|
|
29
|
+
const [initialValue] = useState(defaultValue);
|
|
30
|
+
const [mostRecentEventCount, setMostRecentEventCount] = useState(0);
|
|
31
|
+
const resolvedValue = value ?? initialValue;
|
|
32
|
+
const resolvedDisabled = disabled ?? accessibilityState?.disabled ?? false;
|
|
33
|
+
|
|
34
|
+
for (const [name, number] of Object.entries({
|
|
35
|
+
value: resolvedValue,
|
|
36
|
+
minimumValue,
|
|
37
|
+
maximumValue,
|
|
38
|
+
stepValue,
|
|
39
|
+
})) {
|
|
40
|
+
if (!Number.isFinite(number)) {
|
|
41
|
+
throw new RangeError(
|
|
42
|
+
`[TinyUI] Stepper ${name} must be a finite number.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (maximumValue < minimumValue) {
|
|
47
|
+
throw new RangeError(
|
|
48
|
+
'[TinyUI] Stepper maximumValue must be greater than or equal to minimumValue.'
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (stepValue <= 0) {
|
|
52
|
+
throw new RangeError(
|
|
53
|
+
'[TinyUI] Stepper stepValue must be greater than 0.'
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<NativeStepperView
|
|
59
|
+
{...viewProps}
|
|
60
|
+
ref={ref}
|
|
61
|
+
accessibilityState={{
|
|
62
|
+
...accessibilityState,
|
|
63
|
+
disabled: resolvedDisabled,
|
|
64
|
+
}}
|
|
65
|
+
autorepeat={autorepeat}
|
|
66
|
+
isContinuous={isContinuous}
|
|
67
|
+
controlled={value !== undefined}
|
|
68
|
+
disabled={resolvedDisabled}
|
|
69
|
+
maximumValue={maximumValue}
|
|
70
|
+
minimumValue={minimumValue}
|
|
71
|
+
mostRecentEventCount={mostRecentEventCount}
|
|
72
|
+
onChange={(event) => {
|
|
73
|
+
// Acknowledge every event, even if the parent rejects a controlled
|
|
74
|
+
// change by keeping the same value. Native ignores stale replies.
|
|
75
|
+
setMostRecentEventCount(event.nativeEvent.eventCount);
|
|
76
|
+
onValueChange?.(event.nativeEvent.value);
|
|
77
|
+
}}
|
|
78
|
+
stepValue={stepValue}
|
|
79
|
+
style={[styles.stepper, style]}
|
|
80
|
+
value={Math.min(maximumValue, Math.max(minimumValue, resolvedValue))}
|
|
81
|
+
wraps={wraps}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const styles = StyleSheet.create({
|
|
88
|
+
stepper: { alignSelf: 'flex-start' },
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export type { StepperProps } from './types';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface StepperProps extends Omit<ViewProps, 'children'> {
|
|
4
|
+
/** Controlled value. Update it from onValueChange to accept user changes. */
|
|
5
|
+
value?: number;
|
|
6
|
+
/** Initial uncontrolled value. Defaults to 0. */
|
|
7
|
+
defaultValue?: number;
|
|
8
|
+
/** Lower bound. Defaults to 0. */
|
|
9
|
+
minimumValue?: number;
|
|
10
|
+
/** Upper bound, greater than or equal to minimumValue. Defaults to 100. */
|
|
11
|
+
maximumValue?: number;
|
|
12
|
+
/** Positive increment/decrement amount. Defaults to 1. */
|
|
13
|
+
stepValue?: number;
|
|
14
|
+
/** Emit changes while interacting, rather than only on release. Defaults to true. */
|
|
15
|
+
isContinuous?: boolean;
|
|
16
|
+
/** Repeatedly step while holding either button. Defaults to true. */
|
|
17
|
+
autorepeat?: boolean;
|
|
18
|
+
/** Wrap between the bounds instead of stopping at them. Defaults to false. */
|
|
19
|
+
wraps?: boolean;
|
|
20
|
+
/** Disable user interaction. Defaults to false. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Called with the new value after a user interaction. */
|
|
23
|
+
onValueChange?: (value: number) => void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { forwardRef, type ComponentRef } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { assertComponentEnabled } from '../utils';
|
|
5
|
+
import NativeTipPopoverView from './TipPopoverNativeComponent';
|
|
6
|
+
import type { TipPopoverProps, TipStatus } from './types';
|
|
7
|
+
import { validateTip } from './validation';
|
|
8
|
+
|
|
9
|
+
export const Popover = forwardRef<ComponentRef<typeof View>, TipPopoverProps>(
|
|
10
|
+
function TipPopoverRoot(props, ref) {
|
|
11
|
+
assertComponentEnabled('TipKit');
|
|
12
|
+
validateTip(props);
|
|
13
|
+
const {
|
|
14
|
+
children,
|
|
15
|
+
tipId,
|
|
16
|
+
title,
|
|
17
|
+
message,
|
|
18
|
+
systemImage,
|
|
19
|
+
actions,
|
|
20
|
+
enabled = true,
|
|
21
|
+
maxDisplayCount,
|
|
22
|
+
ignoresDisplayFrequency = false,
|
|
23
|
+
arrowEdge = 'auto',
|
|
24
|
+
onStatusChange,
|
|
25
|
+
onVisibleChange,
|
|
26
|
+
onActionPress,
|
|
27
|
+
onError,
|
|
28
|
+
...viewProps
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<NativeTipPopoverView
|
|
33
|
+
{...viewProps}
|
|
34
|
+
ref={ref}
|
|
35
|
+
collapsable={false}
|
|
36
|
+
tipId={tipId}
|
|
37
|
+
title={title}
|
|
38
|
+
message={message}
|
|
39
|
+
systemImage={systemImage}
|
|
40
|
+
actions={actions}
|
|
41
|
+
enabled={enabled}
|
|
42
|
+
maxDisplayCount={maxDisplayCount ?? 0}
|
|
43
|
+
ignoresDisplayFrequency={ignoresDisplayFrequency}
|
|
44
|
+
arrowEdge={arrowEdge}
|
|
45
|
+
onTipStatusChange={({ nativeEvent }) => {
|
|
46
|
+
if (nativeEvent.tipId !== tipId) return;
|
|
47
|
+
if (nativeEvent.status === 'invalidated') {
|
|
48
|
+
onStatusChange?.({
|
|
49
|
+
status: 'invalidated',
|
|
50
|
+
reason: nativeEvent.reason,
|
|
51
|
+
} as TipStatus);
|
|
52
|
+
} else if (
|
|
53
|
+
nativeEvent.status === 'pending' ||
|
|
54
|
+
nativeEvent.status === 'available'
|
|
55
|
+
) {
|
|
56
|
+
onStatusChange?.({ status: nativeEvent.status });
|
|
57
|
+
}
|
|
58
|
+
}}
|
|
59
|
+
onTipVisibleChange={({ nativeEvent }) => {
|
|
60
|
+
if (nativeEvent.tipId === tipId)
|
|
61
|
+
onVisibleChange?.(nativeEvent.visible);
|
|
62
|
+
}}
|
|
63
|
+
onTipAction={({ nativeEvent }) => {
|
|
64
|
+
if (nativeEvent.tipId === tipId) {
|
|
65
|
+
onActionPress?.({ id: nativeEvent.id, title: nativeEvent.title });
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
onTipError={({ nativeEvent }) => {
|
|
69
|
+
if (nativeEvent.tipId !== tipId) return;
|
|
70
|
+
const error = {
|
|
71
|
+
code: nativeEvent.code,
|
|
72
|
+
message: nativeEvent.message,
|
|
73
|
+
};
|
|
74
|
+
if (onError) onError(error);
|
|
75
|
+
else
|
|
76
|
+
console.warn(
|
|
77
|
+
`[TinyUI] TipKit.Popover ${error.code}: ${error.message}`
|
|
78
|
+
);
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<View collapsable={false}>{children}</View>
|
|
82
|
+
</NativeTipPopoverView>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
Popover.displayName = 'TipKit.Popover';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export interface NativeTipPopoverProps extends ViewProps {
|
|
9
|
+
tipId: string;
|
|
10
|
+
title: string;
|
|
11
|
+
message?: string;
|
|
12
|
+
systemImage?: string;
|
|
13
|
+
actions?: ReadonlyArray<Readonly<{ id: string; title: string }>>;
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
maxDisplayCount?: CodegenTypes.Int32;
|
|
16
|
+
ignoresDisplayFrequency?: boolean;
|
|
17
|
+
arrowEdge?: string;
|
|
18
|
+
onTipStatusChange?: DirectEventHandler<
|
|
19
|
+
Readonly<{ tipId: string; status: string; reason: string }>
|
|
20
|
+
>;
|
|
21
|
+
onTipVisibleChange?: DirectEventHandler<
|
|
22
|
+
Readonly<{ tipId: string; visible: boolean }>
|
|
23
|
+
>;
|
|
24
|
+
onTipAction?: DirectEventHandler<
|
|
25
|
+
Readonly<{ tipId: string; id: string; title: string }>
|
|
26
|
+
>;
|
|
27
|
+
onTipError?: DirectEventHandler<
|
|
28
|
+
Readonly<{ tipId: string; code: string; message: string }>
|
|
29
|
+
>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default codegenNativeComponent<NativeTipPopoverProps>(
|
|
33
|
+
'TinyuiTipPopoverView',
|
|
34
|
+
{
|
|
35
|
+
excludedPlatforms: ['android'],
|
|
36
|
+
}
|
|
37
|
+
);
|