@ng-native/components 0.2.0 → 0.4.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/dist/content-container.d.ts +25 -0
- package/dist/content-container.js +35 -0
- package/dist/content-container.js.map +1 -0
- package/dist/gestures-web.d.ts +12 -0
- package/dist/gestures-web.js +32 -0
- package/dist/gestures-web.js.map +1 -0
- package/dist/gestures.d.ts +0 -1
- package/dist/gestures.js +5 -4
- package/dist/gestures.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/keyboard-avoiding-view.d.ts +6 -1
- package/dist/keyboard-avoiding-view.js +23 -6
- package/dist/keyboard-avoiding-view.js.map +1 -1
- package/dist/pressable.d.ts +56 -4
- package/dist/pressable.js +80 -7
- package/dist/pressable.js.map +1 -1
- package/dist/reanimated-web.d.ts +18 -0
- package/dist/reanimated-web.js +59 -0
- package/dist/reanimated-web.js.map +1 -0
- package/dist/reanimated.d.ts +4 -4
- package/dist/reanimated.js +3 -3
- package/dist/reanimated.js.map +1 -1
- package/dist/refresh-control.d.ts +4 -1
- package/dist/refresh-control.js +4 -1
- package/dist/refresh-control.js.map +1 -1
- package/dist/scroll-view.d.ts +17 -1
- package/dist/scroll-view.js +59 -6
- package/dist/scroll-view.js.map +1 -1
- package/dist/section-list.d.ts +14 -2
- package/dist/section-list.js +20 -4
- package/dist/section-list.js.map +1 -1
- package/dist/stand-ins/gesture-handler.d.ts +40 -0
- package/dist/stand-ins/gesture-handler.js +43 -0
- package/dist/stand-ins/gesture-handler.js.map +1 -0
- package/dist/stand-ins/reanimated.d.ts +62 -0
- package/dist/stand-ins/reanimated.js +95 -0
- package/dist/stand-ins/reanimated.js.map +1 -0
- package/dist/stand-ins/worklets.d.ts +11 -0
- package/dist/stand-ins/worklets.js +24 -0
- package/dist/stand-ins/worklets.js.map +1 -0
- package/dist/sticky-headers.d.ts +6 -0
- package/dist/sticky-headers.js +7 -2
- package/dist/sticky-headers.js.map +1 -1
- package/dist/switch.d.ts +11 -1
- package/dist/switch.js +16 -3
- package/dist/switch.js.map +1 -1
- package/dist/text.d.ts +11 -2
- package/dist/text.js +15 -1
- package/dist/text.js.map +1 -1
- package/dist/touchable-opacity.d.ts +2 -1
- package/dist/touchable-opacity.js +3 -0
- package/dist/touchable-opacity.js.map +1 -1
- package/dist/view-base.d.ts +36 -21
- package/dist/view-base.js +91 -23
- package/dist/view-base.js.map +1 -1
- package/dist/virtual-list.d.ts +52 -7
- package/dist/virtual-list.js +132 -44
- package/dist/virtual-list.js.map +1 -1
- package/dist/worklets.d.ts +11 -0
- package/dist/worklets.js.map +1 -1
- package/dist/written-props.js +1 -0
- package/dist/written-props.js.map +1 -1
- package/dist/zero-size-warning.d.ts +30 -0
- package/dist/zero-size-warning.js +58 -0
- package/dist/zero-size-warning.js.map +1 -0
- package/package.json +19 -4
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `react-native-reanimated` where there is no UI-thread runtime: a browser build and a test, which
|
|
3
|
+
* resolve the library here (`ngNativeWeb()` and `@ng-native/testing`).
|
|
4
|
+
*
|
|
5
|
+
* An animation finishes the moment it is assigned: `withTiming(100)` is `100`, and its callback
|
|
6
|
+
* is called with `true` at once, so the value is where the animation ends and what ends it runs.
|
|
7
|
+
* `interpolate` and `Extrapolation` are the library's own arithmetic; `Easing` curves are the
|
|
8
|
+
* identity, since nothing is ever between an animation's ends.
|
|
9
|
+
*
|
|
10
|
+
* ponytail: the functions apps call from components, not the React hooks; add one when an app
|
|
11
|
+
* imports it.
|
|
12
|
+
*/
|
|
13
|
+
export { sharedValue as makeMutable } from '../reanimated-web.ts';
|
|
14
|
+
export type { MutableValue as SharedValue } from '../worklets.ts';
|
|
15
|
+
type Done = ((finished?: boolean) => void) | undefined;
|
|
16
|
+
export declare function withTiming<T>(to: T, _config?: object, callback?: Done): T;
|
|
17
|
+
export declare function withSpring<T>(to: T, _config?: object, callback?: Done): T;
|
|
18
|
+
export declare function withDecay(_config: {
|
|
19
|
+
velocity?: number;
|
|
20
|
+
}, callback?: Done): number;
|
|
21
|
+
export declare function withDelay<T>(_delay: number, animation: T): T;
|
|
22
|
+
export declare function withSequence<T>(...animations: T[]): T;
|
|
23
|
+
export declare function withRepeat<T>(animation: T, _times?: number, _reverse?: boolean, callback?: Done): T;
|
|
24
|
+
export declare function cancelAnimation(_value: unknown): void;
|
|
25
|
+
/** What `@ng-native/components/reanimated` itself starts a style with; nothing runs it here. */
|
|
26
|
+
export declare function startMapper(_worklet: () => void, _inputs?: unknown[]): number;
|
|
27
|
+
export declare function stopMapper(_id: number): void;
|
|
28
|
+
export declare const Extrapolation: {
|
|
29
|
+
readonly IDENTITY: "identity";
|
|
30
|
+
readonly CLAMP: "clamp";
|
|
31
|
+
readonly EXTEND: "extend";
|
|
32
|
+
};
|
|
33
|
+
type Extrapolate = (typeof Extrapolation)[keyof typeof Extrapolation];
|
|
34
|
+
export declare function interpolate(x: number, input: readonly number[], output: readonly number[], extrapolate?: Extrapolate | {
|
|
35
|
+
extrapolateLeft?: Extrapolate;
|
|
36
|
+
extrapolateRight?: Extrapolate;
|
|
37
|
+
}): number;
|
|
38
|
+
export declare const Easing: {
|
|
39
|
+
linear: (t: number) => number;
|
|
40
|
+
ease: (t: number) => number;
|
|
41
|
+
quad: (t: number) => number;
|
|
42
|
+
cubic: (t: number) => number;
|
|
43
|
+
sin: (t: number) => number;
|
|
44
|
+
circle: (t: number) => number;
|
|
45
|
+
exp: (t: number) => number;
|
|
46
|
+
bounce: (t: number) => number;
|
|
47
|
+
poly: () => (t: number) => number;
|
|
48
|
+
elastic: () => (t: number) => number;
|
|
49
|
+
back: () => (t: number) => number;
|
|
50
|
+
bezier: () => (t: number) => number;
|
|
51
|
+
bezierFn: () => (t: number) => number;
|
|
52
|
+
in: (easing: (t: number) => number) => (t: number) => number;
|
|
53
|
+
out: (easing: (t: number) => number) => (t: number) => number;
|
|
54
|
+
inOut: (easing: (t: number) => number) => (t: number) => number;
|
|
55
|
+
};
|
|
56
|
+
export declare const ReduceMotion: {
|
|
57
|
+
readonly System: "system";
|
|
58
|
+
readonly Always: "always";
|
|
59
|
+
readonly Never: "never";
|
|
60
|
+
};
|
|
61
|
+
export declare function runOnJS<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
|
|
62
|
+
export declare function runOnUI<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `react-native-reanimated` where there is no UI-thread runtime: a browser build and a test, which
|
|
3
|
+
* resolve the library here (`ngNativeWeb()` and `@ng-native/testing`).
|
|
4
|
+
*
|
|
5
|
+
* An animation finishes the moment it is assigned: `withTiming(100)` is `100`, and its callback
|
|
6
|
+
* is called with `true` at once, so the value is where the animation ends and what ends it runs.
|
|
7
|
+
* `interpolate` and `Extrapolation` are the library's own arithmetic; `Easing` curves are the
|
|
8
|
+
* identity, since nothing is ever between an animation's ends.
|
|
9
|
+
*
|
|
10
|
+
* ponytail: the functions apps call from components, not the React hooks; add one when an app
|
|
11
|
+
* imports it.
|
|
12
|
+
*/
|
|
13
|
+
export { sharedValue as makeMutable } from "../reanimated-web.js";
|
|
14
|
+
const settle = (to, callback) => {
|
|
15
|
+
callback?.(true);
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
export function withTiming(to, _config, callback) {
|
|
19
|
+
return settle(to, callback);
|
|
20
|
+
}
|
|
21
|
+
export function withSpring(to, _config, callback) {
|
|
22
|
+
return settle(to, callback);
|
|
23
|
+
}
|
|
24
|
+
export function withDecay(_config, callback) {
|
|
25
|
+
return settle(0, callback);
|
|
26
|
+
}
|
|
27
|
+
export function withDelay(_delay, animation) {
|
|
28
|
+
return animation;
|
|
29
|
+
}
|
|
30
|
+
export function withSequence(...animations) {
|
|
31
|
+
return animations[animations.length - 1];
|
|
32
|
+
}
|
|
33
|
+
export function withRepeat(animation, _times, _reverse, callback) {
|
|
34
|
+
return settle(animation, callback);
|
|
35
|
+
}
|
|
36
|
+
export function cancelAnimation(_value) { }
|
|
37
|
+
/** What `@ng-native/components/reanimated` itself starts a style with; nothing runs it here. */
|
|
38
|
+
export function startMapper(_worklet, _inputs) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
export function stopMapper(_id) { }
|
|
42
|
+
export const Extrapolation = { IDENTITY: 'identity', CLAMP: 'clamp', EXTEND: 'extend' };
|
|
43
|
+
/** Past an end of the input range: the end's output, the input itself, or `undefined` to extend. */
|
|
44
|
+
function beyond(x, output, how) {
|
|
45
|
+
if (how === 'clamp')
|
|
46
|
+
return output;
|
|
47
|
+
if (how === 'identity')
|
|
48
|
+
return x;
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
export function interpolate(x, input, output, extrapolate) {
|
|
52
|
+
const left = typeof extrapolate === 'object' ? extrapolate.extrapolateLeft : extrapolate;
|
|
53
|
+
const right = typeof extrapolate === 'object' ? extrapolate.extrapolateRight : extrapolate;
|
|
54
|
+
const last = input.length - 1;
|
|
55
|
+
const outside = x < input[0]
|
|
56
|
+
? beyond(x, output[0], left)
|
|
57
|
+
: x > input[last]
|
|
58
|
+
? beyond(x, output[last], right)
|
|
59
|
+
: undefined;
|
|
60
|
+
if (outside !== undefined)
|
|
61
|
+
return outside;
|
|
62
|
+
let i = 0;
|
|
63
|
+
while (i < last - 1 && x > input[i + 1])
|
|
64
|
+
i++;
|
|
65
|
+
const [a, b, p, q] = [input[i], input[i + 1], output[i], output[i + 1]];
|
|
66
|
+
return b === a ? p : p + ((x - a) / (b - a)) * (q - p);
|
|
67
|
+
}
|
|
68
|
+
const identity = (t) => t;
|
|
69
|
+
const curve = () => identity;
|
|
70
|
+
export const Easing = {
|
|
71
|
+
linear: identity,
|
|
72
|
+
ease: identity,
|
|
73
|
+
quad: identity,
|
|
74
|
+
cubic: identity,
|
|
75
|
+
sin: identity,
|
|
76
|
+
circle: identity,
|
|
77
|
+
exp: identity,
|
|
78
|
+
bounce: identity,
|
|
79
|
+
poly: curve,
|
|
80
|
+
elastic: curve,
|
|
81
|
+
back: curve,
|
|
82
|
+
bezier: curve,
|
|
83
|
+
bezierFn: curve,
|
|
84
|
+
in: (easing) => easing,
|
|
85
|
+
out: (easing) => easing,
|
|
86
|
+
inOut: (easing) => easing,
|
|
87
|
+
};
|
|
88
|
+
export const ReduceMotion = { System: 'system', Always: 'always', Never: 'never' };
|
|
89
|
+
export function runOnJS(fn) {
|
|
90
|
+
return fn;
|
|
91
|
+
}
|
|
92
|
+
export function runOnUI(fn) {
|
|
93
|
+
return fn;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=reanimated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reanimated.js","sourceRoot":"","sources":["../../src/stand-ins/reanimated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKlE,MAAM,MAAM,GAAG,CAAI,EAAK,EAAE,QAAc,EAAK,EAAE;IAC7C,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,UAAU,UAAU,CAAI,EAAK,EAAE,OAAgB,EAAE,QAAe;IACpE,OAAO,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,EAAK,EAAE,OAAgB,EAAE,QAAe;IACpE,OAAO,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAA8B,EAAE,QAAe;IACvE,OAAO,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,MAAc,EAAE,SAAY;IACvD,OAAO,SAAS,CAAC;AACnB,C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AQ;IACb,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,KAAK;IACf,EAAE,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;IAC7C,GAAG,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;IAC9C,KAAK,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;CACjD,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC;AAE5F,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/**\n * `react-native-reanimated` where there is no UI-thread runtime: a browser build and a test, which\n * resolve the library here (`ngNativeWeb()` and `@ng-native/testing`).\n *\n * An animation finishes the moment it is assigned: `withTiming(100)` is `100`, and its callback\n * is called with `true` at once, so the value is where the animation ends and what ends it runs.\n * `interpolate` and `Extrapolation` are the library's own arithmetic; `Easing` curves are the\n * identity, since nothing is ever between an animation's ends.\n *\n * ponytail: the functions apps call from components, not the React hooks; add one when an app\n * imports it.\n */\nexport { sharedValue as makeMutable } from '../reanimated-web.ts';\nexport type { MutableValue as SharedValue } from '../worklets.ts';\n\ntype Done = ((finished?: boolean) => void) | undefined;\n\nconst settle = <T>(to: T, callback: Done): T => {\n callback?.(true);\n return to;\n};\n\nexport function withTiming<T>(to: T, _config?: object, callback?: Done): T {\n return settle(to, callback);\n}\n\nexport function withSpring<T>(to: T, _config?: object, callback?: Done): T {\n return settle(to, callback);\n}\n\nexport function withDecay(_config: { velocity?: number }, callback?: Done): number {\n return settle(0, callback);\n}\n\nexport function withDelay<T>(_delay: number, animation: T): T {\n return animation;\n}\n\nexport function withSequence<T>(...animations: T[]): T {\n return animations[animations.length - 1]!;\n}\n\nexport function withRepeat<T>(\n animation: T,\n _times?: number,\n _reverse?: boolean,\n callback?: Done,\n): T {\n return settle(animation, callback);\n}\n\nexport function cancelAnimation(_value: unknown): void {}\n\n/** What `@ng-native/components/reanimated` itself starts a style with; nothing runs it here. */\nexport function startMapper(_worklet: () => void, _inputs?: unknown[]): number {\n return 0;\n}\n\nexport function stopMapper(_id: number): void {}\n\nexport const Extrapolation = { IDENTITY: 'identity', CLAMP: 'clamp', EXTEND: 'extend' } as const;\ntype Extrapolate = (typeof Extrapolation)[keyof typeof Extrapolation];\n\n/** Past an end of the input range: the end's output, the input itself, or `undefined` to extend. */\nfunction beyond(x: number, output: number, how: Extrapolate | undefined): number | undefined {\n if (how === 'clamp') return output;\n if (how === 'identity') return x;\n return undefined;\n}\n\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n extrapolate?: Extrapolate | { extrapolateLeft?: Extrapolate; extrapolateRight?: Extrapolate },\n): number {\n const left = typeof extrapolate === 'object' ? extrapolate.extrapolateLeft : extrapolate;\n const right = typeof extrapolate === 'object' ? extrapolate.extrapolateRight : extrapolate;\n const last = input.length - 1;\n const outside =\n x < input[0]!\n ? beyond(x, output[0]!, left)\n : x > input[last]!\n ? beyond(x, output[last]!, right)\n : undefined;\n if (outside !== undefined) return outside;\n let i = 0;\n while (i < last - 1 && x > input[i + 1]!) i++;\n const [a, b, p, q] = [input[i]!, input[i + 1]!, output[i]!, output[i + 1]!];\n return b === a ? p : p + ((x - a) / (b - a)) * (q - p);\n}\n\nconst identity = (t: number) => t;\nconst curve = () => identity;\nexport const Easing = {\n linear: identity,\n ease: identity,\n quad: identity,\n cubic: identity,\n sin: identity,\n circle: identity,\n exp: identity,\n bounce: identity,\n poly: curve,\n elastic: curve,\n back: curve,\n bezier: curve,\n bezierFn: curve,\n in: (easing: (t: number) => number) => easing,\n out: (easing: (t: number) => number) => easing,\n inOut: (easing: (t: number) => number) => easing,\n};\n\nexport const ReduceMotion = { System: 'system', Always: 'always', Never: 'never' } as const;\n\nexport function runOnJS<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n\nexport function runOnUI<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `react-native-worklets` where there is no UI-thread runtime: a browser build and a test, which
|
|
3
|
+
* resolve the library here (`ngNativeWeb()` and `@ng-native/testing`). There is one runtime, so
|
|
4
|
+
* scheduling a function on either calls it at once.
|
|
5
|
+
*/
|
|
6
|
+
export declare function scheduleOnRN<A extends unknown[]>(fn: (...args: A) => unknown, ...args: A): void;
|
|
7
|
+
export declare function scheduleOnUI<A extends unknown[]>(fn: (...args: A) => unknown, ...args: A): void;
|
|
8
|
+
export declare function runOnUISync<A extends unknown[], R>(fn: (...args: A) => R, ...args: A): R;
|
|
9
|
+
export declare function runOnJS<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
|
|
10
|
+
export declare function runOnUI<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
|
|
11
|
+
export declare function isWorkletFunction(_value: unknown): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `react-native-worklets` where there is no UI-thread runtime: a browser build and a test, which
|
|
3
|
+
* resolve the library here (`ngNativeWeb()` and `@ng-native/testing`). There is one runtime, so
|
|
4
|
+
* scheduling a function on either calls it at once.
|
|
5
|
+
*/
|
|
6
|
+
export function scheduleOnRN(fn, ...args) {
|
|
7
|
+
fn(...args);
|
|
8
|
+
}
|
|
9
|
+
export function scheduleOnUI(fn, ...args) {
|
|
10
|
+
fn(...args);
|
|
11
|
+
}
|
|
12
|
+
export function runOnUISync(fn, ...args) {
|
|
13
|
+
return fn(...args);
|
|
14
|
+
}
|
|
15
|
+
export function runOnJS(fn) {
|
|
16
|
+
return fn;
|
|
17
|
+
}
|
|
18
|
+
export function runOnUI(fn) {
|
|
19
|
+
return fn;
|
|
20
|
+
}
|
|
21
|
+
export function isWorkletFunction(_value) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=worklets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worklets.js","sourceRoot":"","sources":["../../src/stand-ins/worklets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAsB,EAA2B,EAAE,GAAG,IAAO;IACvF,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,YAAY,CAAsB,EAA2B,EAAE,GAAG,IAAO;IACvF,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAyB,EAAqB,EAAE,GAAG,IAAO;IACnF,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * `react-native-worklets` where there is no UI-thread runtime: a browser build and a test, which\n * resolve the library here (`ngNativeWeb()` and `@ng-native/testing`). There is one runtime, so\n * scheduling a function on either calls it at once.\n */\nexport function scheduleOnRN<A extends unknown[]>(fn: (...args: A) => unknown, ...args: A): void {\n fn(...args);\n}\n\nexport function scheduleOnUI<A extends unknown[]>(fn: (...args: A) => unknown, ...args: A): void {\n fn(...args);\n}\n\nexport function runOnUISync<A extends unknown[], R>(fn: (...args: A) => R, ...args: A): R {\n return fn(...args);\n}\n\nexport function runOnJS<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n\nexport function runOnUI<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n\nexport function isWorkletFunction(_value: unknown): boolean {\n return false;\n}\n"]}
|
package/dist/sticky-headers.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type HostEngine, type HostNode } from '@ng-native/fabric';
|
|
2
|
+
/**
|
|
3
|
+
* How long scrolling has to pause before a natively moved header's translate is written, so the
|
|
4
|
+
* shadow tree, which a touch is hit-tested against, catches up with where native drew it. RN's
|
|
5
|
+
* `ScrollViewStickyHeader` debounces the same write, by 64 ms on iOS.
|
|
6
|
+
*/
|
|
7
|
+
export declare const STICKY_SETTLE_MS = 64;
|
|
2
8
|
/**
|
|
3
9
|
* `stickyHeaderIndices` for `<scroll-view>`, done the way RN's `ScrollView.js` does it.
|
|
4
10
|
*
|
package/dist/sticky-headers.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { pinnedRange } from '@ng-native/fabric';
|
|
2
|
+
/**
|
|
3
|
+
* How long scrolling has to pause before a natively moved header's translate is written, so the
|
|
4
|
+
* shadow tree, which a touch is hit-tested against, catches up with where native drew it. RN's
|
|
5
|
+
* `ScrollViewStickyHeader` debounces the same write, by 64 ms on iOS.
|
|
6
|
+
*/
|
|
7
|
+
export const STICKY_SETTLE_MS = 64;
|
|
2
8
|
/**
|
|
3
9
|
* `stickyHeaderIndices` for `<scroll-view>`, done the way RN's `ScrollView.js` does it.
|
|
4
10
|
*
|
|
@@ -54,9 +60,8 @@ export class StickyHeaders {
|
|
|
54
60
|
this.offset = offset;
|
|
55
61
|
if (!this.engine.drivesScroll)
|
|
56
62
|
return this.apply();
|
|
57
|
-
// RN's sticky header commits its translate after 64 ms without a scroll event.
|
|
58
63
|
clearTimeout(this.settleTimer);
|
|
59
|
-
this.settleTimer = setTimeout(() => this.apply(),
|
|
64
|
+
this.settleTimer = setTimeout(() => this.apply(), STICKY_SETTLE_MS);
|
|
60
65
|
}
|
|
61
66
|
destroy() {
|
|
62
67
|
clearTimeout(this.settleTimer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticky-headers.js","sourceRoot":"","sources":["../src/sticky-headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWlG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAa;IACP,MAAM,CAAa;IACnB,UAAU,CAAgB;IACnC,OAAO,GAAe,EAAE,CAAC;IAChB,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC7D,yFAAyF;IACxE,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,WAAW,CAA4C;IACvD,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,MAAkB,EAAE,MAAgB,EAAE,UAAyB;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEgB,MAAM,CAAW;IAElC,+EAA+E;IAC/E,KAAK,CAAC,OAA6B,EAAE,OAA0B;QAC7D,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QACvF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAClE,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,O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,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK;gBAAE,OAAO;YAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { type HostEngine, type HostNode, type ScrollDrive, pinnedRange } from '@ng-native/fabric';\n\ninterface Extent {\n readonly start: number;\n readonly size: number;\n}\n\ntype LayoutEvent = {\n nativeEvent?: { layout?: { x?: number; y?: number; width?: number; height?: number } };\n};\n\n/**\n * `stickyHeaderIndices` for `<scroll-view>`, done the way RN's `ScrollView.js` does it.\n *\n * There is no native prop for it on either platform. RN wraps each sticky child in\n * `ScrollViewStickyHeader`, which translates it by the scroll offset past its own position and\n * stops where the next sticky child would push it off. The same sums run here, over the content\n * view's element children: control-flow anchors are not children in RN's sense and are skipped,\n * so an index counts what is committed.\n *\n * Each sticky child's position comes from its own layout event, and the translation is written\n * as its `transform` prop, with RN's `zIndex: 10` so it draws over the content scrolling under\n * it. A style of the caller's own that sets either wins, as it would in RN.\n *\n * Where the host can, native moves each one on every frame the scroll view moves, as RN's\n * animated interpolation does, and the translation is written only once scrolling pauses: a\n * translate written from each scroll event lands late, and on a fast fling the header shudders.\n */\nexport class StickyHeaders {\n private readonly engine: HostEngine;\n private readonly horizontal: () => boolean;\n private headers: HostNode[] = [];\n private readonly extents = new Map<HostNode, Extent>();\n private readonly listening = new Map<HostNode, () => void>();\n /** The translation last written per header, so an unchanged one is not written again. */\n private readonly written = new Map<HostNode, number>();\n private readonly drives = new Map<HostNode, ScrollDrive>();\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n private offset = 0;\n\n constructor(engine: HostEngine, scroll: HostNode, horizontal: () => boolean) {\n this.engine = engine;\n this.scroll = scroll;\n this.horizontal = horizontal;\n }\n\n private readonly scroll: HostNode;\n\n /** Find the sticky children again, after a pass that may have changed them. */\n track(content: HostNode | undefined, indices: readonly number[]): void {\n const children = (content?.children ?? []).filter((child) => child.kind === 'element');\n const headers = indices.flatMap((index) => children[index] ?? []);\n for (const node of this.headers) {\n if (!headers.includes(node)) this.release(node);\n }\n for (const node of headers) {\n if (this.listening.has(node)) continue;\n this.engine.setProp(node, 'zIndex', 10);\n this.listening.set(\n node,\n this.engine.setEventListener(node, 'topLayout', (event) => this.measured(node, event)),\n );\n }\n this.headers = headers;\n this.apply();\n }\n\n scrolled(offset: number): void {\n this.offset = offset;\n if (!this.engine.drivesScroll) return this.apply();\n // RN's sticky header commits its translate after 64 ms without a scroll event.\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.apply(), 64);\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const node of this.headers) this.release(node);\n this.headers = [];\n }\n\n private measured(node: HostNode, event: unknown): void {\n const layout = (event as LayoutEvent).nativeEvent?.layout;\n if (!layout) return;\n const horizontal = this.horizontal();\n this.extents.set(node, {\n start: (horizontal ? layout.x : layout.y) ?? 0,\n size: (horizontal ? layout.width : layout.height) ?? 0,\n });\n this.apply();\n }\n\n private release(node: HostNode): void {\n this.listening.get(node)?.();\n this.listening.delete(node);\n this.extents.delete(node);\n this.written.delete(node);\n this.drives.get(node)?.stop();\n this.drives.delete(node);\n this.engine.setProp(node, 'zIndex', undefined);\n this.engine.setProp(node, 'transform', undefined);\n }\n\n private drive(node: HostNode, start: number, stop: number): void {\n if (!this.engine.drivesScroll) return;\n const range = pinnedRange(start, stop);\n const drive = this.drives.get(node);\n if (drive) return drive.update(range);\n const axis = this.horizontal() ? 'x' : 'y';\n const next = this.engine.driveByScroll(node, this.scroll, axis, range);\n if (next) this.drives.set(node, next);\n }\n\n /** `ScrollViewStickyHeader`'s interpolation, as plain arithmetic. */\n private apply(): void {\n const key = this.horizontal() ? 'translateX' : 'translateY';\n this.headers.forEach((node, at) => {\n const own = this.extents.get(node);\n if (!own) return;\n const next = this.extents.get(this.headers[at + 1]!);\n const stop = next ? next.start - own.size : Infinity;\n this.drive(node, own.start, stop);\n const shift = Math.min(Math.max(0, this.offset - own.start), Math.max(0, stop - own.start));\n if (this.written.get(node) === shift) return;\n this.written.set(node, shift);\n this.engine.setProp(node, 'transform', shift > 0 ? [{ [key]: shift }] : undefined);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sticky-headers.js","sourceRoot":"","sources":["../src/sticky-headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOlG;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAMnC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAa;IACP,MAAM,CAAa;IACnB,UAAU,CAAgB;IACnC,OAAO,GAAe,EAAE,CAAC;IAChB,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC7D,yFAAyF;IACxE,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,WAAW,CAA4C;IACvD,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,MAAkB,EAAE,MAAgB,EAAE,UAAyB;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAC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AI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,GAAG;gBAAE,OAAO;YACjB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAE,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;YACrD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK;gBAAE,OAAO;YAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { type HostEngine, type HostNode, type ScrollDrive, pinnedRange } from '@ng-native/fabric';\n\ninterface Extent {\n readonly start: number;\n readonly size: number;\n}\n\n/**\n * How long scrolling has to pause before a natively moved header's translate is written, so the\n * shadow tree, which a touch is hit-tested against, catches up with where native drew it. RN's\n * `ScrollViewStickyHeader` debounces the same write, by 64 ms on iOS.\n */\nexport const STICKY_SETTLE_MS = 64;\n\ntype LayoutEvent = {\n nativeEvent?: { layout?: { x?: number; y?: number; width?: number; height?: number } };\n};\n\n/**\n * `stickyHeaderIndices` for `<scroll-view>`, done the way RN's `ScrollView.js` does it.\n *\n * There is no native prop for it on either platform. RN wraps each sticky child in\n * `ScrollViewStickyHeader`, which translates it by the scroll offset past its own position and\n * stops where the next sticky child would push it off. The same sums run here, over the content\n * view's element children: control-flow anchors are not children in RN's sense and are skipped,\n * so an index counts what is committed.\n *\n * Each sticky child's position comes from its own layout event, and the translation is written\n * as its `transform` prop, with RN's `zIndex: 10` so it draws over the content scrolling under\n * it. A style of the caller's own that sets either wins, as it would in RN.\n *\n * Where the host can, native moves each one on every frame the scroll view moves, as RN's\n * animated interpolation does, and the translation is written only once scrolling pauses: a\n * translate written from each scroll event lands late, and on a fast fling the header shudders.\n */\nexport class StickyHeaders {\n private readonly engine: HostEngine;\n private readonly horizontal: () => boolean;\n private headers: HostNode[] = [];\n private readonly extents = new Map<HostNode, Extent>();\n private readonly listening = new Map<HostNode, () => void>();\n /** The translation last written per header, so an unchanged one is not written again. */\n private readonly written = new Map<HostNode, number>();\n private readonly drives = new Map<HostNode, ScrollDrive>();\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n private offset = 0;\n\n constructor(engine: HostEngine, scroll: HostNode, horizontal: () => boolean) {\n this.engine = engine;\n this.scroll = scroll;\n this.horizontal = horizontal;\n }\n\n private readonly scroll: HostNode;\n\n /** Find the sticky children again, after a pass that may have changed them. */\n track(content: HostNode | undefined, indices: readonly number[]): void {\n const children = (content?.children ?? []).filter((child) => child.kind === 'element');\n const headers = indices.flatMap((index) => children[index] ?? []);\n for (const node of this.headers) {\n if (!headers.includes(node)) this.release(node);\n }\n for (const node of headers) {\n if (this.listening.has(node)) continue;\n this.engine.setProp(node, 'zIndex', 10);\n this.listening.set(\n node,\n this.engine.setEventListener(node, 'topLayout', (event) => this.measured(node, event)),\n );\n }\n this.headers = headers;\n this.apply();\n }\n\n scrolled(offset: number): void {\n this.offset = offset;\n if (!this.engine.drivesScroll) return this.apply();\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.apply(), STICKY_SETTLE_MS);\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const node of this.headers) this.release(node);\n this.headers = [];\n }\n\n private measured(node: HostNode, event: unknown): void {\n const layout = (event as LayoutEvent).nativeEvent?.layout;\n if (!layout) return;\n const horizontal = this.horizontal();\n this.extents.set(node, {\n start: (horizontal ? layout.x : layout.y) ?? 0,\n size: (horizontal ? layout.width : layout.height) ?? 0,\n });\n this.apply();\n }\n\n private release(node: HostNode): void {\n this.listening.get(node)?.();\n this.listening.delete(node);\n this.extents.delete(node);\n this.written.delete(node);\n this.drives.get(node)?.stop();\n this.drives.delete(node);\n this.engine.setProp(node, 'zIndex', undefined);\n this.engine.setProp(node, 'transform', undefined);\n }\n\n private drive(node: HostNode, start: number, stop: number): void {\n if (!this.engine.drivesScroll) return;\n const range = pinnedRange(start, stop);\n const drive = this.drives.get(node);\n if (drive) return drive.update(range);\n const axis = this.horizontal() ? 'x' : 'y';\n const next = this.engine.driveByScroll(node, this.scroll, axis, range);\n if (next) this.drives.set(node, next);\n }\n\n /** `ScrollViewStickyHeader`'s interpolation, as plain arithmetic. */\n private apply(): void {\n const key = this.horizontal() ? 'translateX' : 'translateY';\n this.headers.forEach((node, at) => {\n const own = this.extents.get(node);\n if (!own) return;\n const next = this.extents.get(this.headers[at + 1]!);\n const stop = next ? next.start - own.size : Infinity;\n this.drive(node, own.start, stop);\n const shift = Math.min(Math.max(0, this.offset - own.start), Math.max(0, stop - own.start));\n if (this.written.get(node) === shift) return;\n this.written.set(node, shift);\n this.engine.setProp(node, 'transform', shift > 0 ? [{ [key]: shift }] : undefined);\n });\n }\n}\n"]}
|
package/dist/switch.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import * as i0 from "@angular/core";
|
|
|
6
6
|
* A toggle, wired for signal forms as a `FormCheckboxControl` (`checked`, not `value`). Commits
|
|
7
7
|
* as `Switch` on iOS and `AndroidSwitch` on Android.
|
|
8
8
|
*
|
|
9
|
+
* `invalid` and `touched` come out as `data-invalid` and `data-touched` for a stylesheet, as on
|
|
10
|
+
* `<text-input>`, and `touch` fires when the user flips it: a switch has no blur, so the flip is
|
|
11
|
+
* the moment the user has dealt with it, which a form that shows errors once touched waits for.
|
|
12
|
+
*
|
|
9
13
|
* The two platforms spell the same props differently, so both spellings are sent and each
|
|
10
14
|
* native side reads its own; a prop it does not know is ignored.
|
|
11
15
|
*
|
|
@@ -20,6 +24,12 @@ export declare class Switch extends ViewBase {
|
|
|
20
24
|
readonly checked: import("@angular/core").ModelSignal<boolean>;
|
|
21
25
|
/** Ignore touches and grey out. */
|
|
22
26
|
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
27
|
+
/** Published as `data-invalid`; nothing native reads it. */
|
|
28
|
+
readonly invalid: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
29
|
+
/** Published as `data-touched`; nothing native reads it. */
|
|
30
|
+
readonly touched: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
31
|
+
/** The user flipped it. What Signal Forms marks a field touched from. */
|
|
32
|
+
readonly touch: import("@angular/core").OutputEmitterRef<void>;
|
|
23
33
|
/** `Switch.js`: `accessibilityRole={props.accessibilityRole ?? 'switch'}`. */
|
|
24
34
|
protected roleByDefault(): 'switch';
|
|
25
35
|
protected disabledForAccessibility(): boolean | undefined;
|
|
@@ -50,5 +60,5 @@ export declare class Switch extends ViewBase {
|
|
|
50
60
|
*/
|
|
51
61
|
private reconcile;
|
|
52
62
|
static ɵfac: i0.ɵɵFactoryDeclaration<Switch, never>;
|
|
53
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<Switch, "switch", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "thumbColor": { "alias": "thumbColor"; "required": false; "isSignal": true; }; "trackColor": { "alias": "trackColor"; "required": false; "isSignal": true; }; "iosBackgroundColor": { "alias": "ios_backgroundColor"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; }, never, never, true, never>;
|
|
63
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Switch, "switch", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "thumbColor": { "alias": "thumbColor"; "required": false; "isSignal": true; }; "trackColor": { "alias": "trackColor"; "required": false; "isSignal": true; }; "iosBackgroundColor": { "alias": "ios_backgroundColor"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "touch": "touch"; }, never, never, true, never>;
|
|
54
64
|
}
|
package/dist/switch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Directive, Injector, afterNextRender, computed, effect, inject, input, model, } from '@angular/core';
|
|
1
|
+
import { Directive, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, model, output, } from '@angular/core';
|
|
2
2
|
import { nativePlatform } from '@ng-native/fabric';
|
|
3
3
|
import { ControlledModel } from "./controlled-model.js";
|
|
4
4
|
import { optionalBoolean } from "./transforms.js";
|
|
@@ -8,6 +8,10 @@ import * as i0 from "@angular/core";
|
|
|
8
8
|
* A toggle, wired for signal forms as a `FormCheckboxControl` (`checked`, not `value`). Commits
|
|
9
9
|
* as `Switch` on iOS and `AndroidSwitch` on Android.
|
|
10
10
|
*
|
|
11
|
+
* `invalid` and `touched` come out as `data-invalid` and `data-touched` for a stylesheet, as on
|
|
12
|
+
* `<text-input>`, and `touch` fires when the user flips it: a switch has no blur, so the flip is
|
|
13
|
+
* the moment the user has dealt with it, which a form that shows errors once touched waits for.
|
|
14
|
+
*
|
|
11
15
|
* The two platforms spell the same props differently, so both spellings are sent and each
|
|
12
16
|
* native side reads its own; a prop it does not know is ignored.
|
|
13
17
|
*
|
|
@@ -23,6 +27,12 @@ export class Switch extends ViewBase {
|
|
|
23
27
|
...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
24
28
|
/** Ignore touches and grey out. */
|
|
25
29
|
disabled = input(undefined, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
30
|
+
/** Published as `data-invalid`; nothing native reads it. */
|
|
31
|
+
invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
32
|
+
/** Published as `data-touched`; nothing native reads it. */
|
|
33
|
+
touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
34
|
+
/** The user flipped it. What Signal Forms marks a field touched from. */
|
|
35
|
+
touch = output();
|
|
26
36
|
/** `Switch.js`: `accessibilityRole={props.accessibilityRole ?? 'switch'}`. */
|
|
27
37
|
roleByDefault() {
|
|
28
38
|
return 'switch';
|
|
@@ -66,6 +76,7 @@ export class Switch extends ViewBase {
|
|
|
66
76
|
onNativeChange(event) {
|
|
67
77
|
this.nativeValue = event.nativeEvent?.value ?? false;
|
|
68
78
|
this.control.propose(this.nativeValue);
|
|
79
|
+
this.touch.emit();
|
|
69
80
|
afterNextRender({ write: () => this.reconcile() }, { injector: this.injector });
|
|
70
81
|
}
|
|
71
82
|
/**
|
|
@@ -83,7 +94,7 @@ export class Switch extends ViewBase {
|
|
|
83
94
|
this.engine.dispatchCommand(this.node, command, [desired]);
|
|
84
95
|
}
|
|
85
96
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Switch, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
86
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: Switch, isStandalone: true, selector: "switch", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, thumbColor: { classPropertyName: "thumbColor", publicName: "thumbColor", isSignal: true, isRequired: false, transformFunction: null }, trackColor: { classPropertyName: "trackColor", publicName: "trackColor", isSignal: true, isRequired: false, transformFunction: null }, iosBackgroundColor: { classPropertyName: "iosBackgroundColor", publicName: "ios_backgroundColor", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange" }, host: { listeners: { "change": "onNativeChange($event)" }, properties: { "accessibilityState": "accessibilityStateProp()", "value": "checked()", "disabled": "disabled()", "attr.data-disabled": "disabled() ? '' : null", "enabled": "enabled()", "thumbTintColor": "thumbColor()", "tintColor": "trackColor()?.false", "trackColorForTrue": "trackColor()?.true", "trackColorForFalse": "trackColor()?.false", "trackTintColor": "checked() ? trackColor()?.true : trackColor()?.false", "style.backgroundColor": "iosBackgroundColor()", "style.borderRadius": "iosBackgroundColor() ? 16 : undefined" } }, usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
97
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: Switch, isStandalone: true, selector: "switch", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, thumbColor: { classPropertyName: "thumbColor", publicName: "thumbColor", isSignal: true, isRequired: false, transformFunction: null }, trackColor: { classPropertyName: "trackColor", publicName: "trackColor", isSignal: true, isRequired: false, transformFunction: null }, iosBackgroundColor: { classPropertyName: "iosBackgroundColor", publicName: "ios_backgroundColor", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", touch: "touch" }, host: { listeners: { "change": "onNativeChange($event)" }, properties: { "accessibilityState": "accessibilityStateProp()", "value": "checked()", "disabled": "disabled()", "attr.data-disabled": "disabled() ? '' : null", "attr.data-invalid": "invalid() ? '' : null", "attr.data-touched": "touched() ? '' : null", "enabled": "enabled()", "thumbTintColor": "thumbColor()", "tintColor": "trackColor()?.false", "trackColorForTrue": "trackColor()?.true", "trackColorForFalse": "trackColor()?.false", "trackTintColor": "checked() ? trackColor()?.true : trackColor()?.false", "style.backgroundColor": "iosBackgroundColor()", "style.borderRadius": "iosBackgroundColor() ? 16 : undefined" } }, usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
87
98
|
}
|
|
88
99
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Switch, decorators: [{
|
|
89
100
|
type: Directive,
|
|
@@ -96,6 +107,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
96
107
|
'[value]': 'checked()',
|
|
97
108
|
'[disabled]': 'disabled()',
|
|
98
109
|
'[attr.data-disabled]': "disabled() ? '' : null",
|
|
110
|
+
'[attr.data-invalid]': "invalid() ? '' : null",
|
|
111
|
+
'[attr.data-touched]': "touched() ? '' : null",
|
|
99
112
|
'[enabled]': 'enabled()',
|
|
100
113
|
'[thumbTintColor]': 'thumbColor()',
|
|
101
114
|
'[tintColor]': 'trackColor()?.false',
|
|
@@ -107,5 +120,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
107
120
|
'(change)': 'onNativeChange($event)',
|
|
108
121
|
},
|
|
109
122
|
}]
|
|
110
|
-
}], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], thumbColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbColor", required: false }] }], trackColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackColor", required: false }] }], iosBackgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "ios_backgroundColor", required: false }] }] } });
|
|
123
|
+
}], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], thumbColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbColor", required: false }] }], trackColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackColor", required: false }] }], iosBackgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "ios_backgroundColor", required: false }] }] } });
|
|
111
124
|
//# sourceMappingURL=switch.js.map
|
package/dist/switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../src/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EAER,eAAe,EACf,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../src/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EAER,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAA6B,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAA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AClD,MAAM,OAAO,GAAG,cAAc,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;uGA1EU,MAAM;2FAAN,MAAM;;2FAAN,MAAM;kBAtBlB,SAAS;mBAAC;oBACT,QAAQ,EAAE,QAAQ;oBAClB,IAAI,EAAE;wBACJ,wFAAwF;wBACxF,kEAAkE;wBAClE,sBAAsB,EAAE,0BAA0B;wBAClD,SAAS,EAAE,WAAW;wBACtB,YAAY,EAAE,YAAY;wBAC1B,sBAAsB,EAAE,wBAAwB;wBAChD,qBAAqB,EAAE,uBAAuB;wBAC9C,qBAAqB,EAAE,uBAAuB;wBAC9C,WAAW,EAAE,WAAW;wBACxB,kBAAkB,EAAE,cAAc;wBAClC,aAAa,EAAE,qBAAqB;wBACpC,qBAAqB,EAAE,oBAAoB;wBAC3C,sBAAsB,EAAE,qBAAqB;wBAC7C,kBAAkB,EAAE,sDAAsD;wBAC1E,yBAAyB,EAAE,sBAAsB;wBACjD,sBAAsB,EAAE,uCAAuC;wBAC/D,UAAU,EAAE,wBAAwB;qBACrC;iBACF","sourcesContent":["import {\n Directive,\n Injector,\n type SimpleChanges,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n} from '@angular/core';\nimport { type NativeSyntheticEvent, nativePlatform } from '@ng-native/fabric';\nimport { ControlledModel } from './controlled-model.ts';\nimport { optionalBoolean } from './transforms.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * A toggle, wired for signal forms as a `FormCheckboxControl` (`checked`, not `value`). Commits\n * as `Switch` on iOS and `AndroidSwitch` on Android.\n *\n * `invalid` and `touched` come out as `data-invalid` and `data-touched` for a stylesheet, as on\n * `<text-input>`, and `touch` fires when the user flips it: a switch has no blur, so the flip is\n * the moment the user has dealt with it, which a form that shows errors once touched waits for.\n *\n * The two platforms spell the same props differently, so both spellings are sent and each\n * native side reads its own; a prop it does not know is ignored.\n *\n * Controlled as React Native's `Switch` is: bind `checked` and the app's value is what the switch\n * shows. The user flips it, the app keeps the old value, and a prop diff has nothing to send,\n * because the prop never changed; native is the only side that moved. So once the pass the flip\n * started has rendered, the switch compares the model with what native reported and, if they\n * differ, sends the command RN's wrapper sends - `setValue` on iOS, `setNativeValue` on Android.\n * See `ControlledModel` for how the model comes to say what the app says.\n */\n@Directive({\n selector: 'switch',\n host: {\n // `disabled` is an input of ours, so it cannot reach `ngOnChanges` on the base; this is\n // the one binding that keeps the announced state in step with it.\n '[accessibilityState]': 'accessibilityStateProp()',\n '[value]': 'checked()',\n '[disabled]': 'disabled()',\n '[attr.data-disabled]': \"disabled() ? '' : null\",\n '[attr.data-invalid]': \"invalid() ? '' : null\",\n '[attr.data-touched]': \"touched() ? '' : null\",\n '[enabled]': 'enabled()',\n '[thumbTintColor]': 'thumbColor()',\n '[tintColor]': 'trackColor()?.false',\n '[trackColorForTrue]': 'trackColor()?.true',\n '[trackColorForFalse]': 'trackColor()?.false',\n '[trackTintColor]': 'checked() ? trackColor()?.true : trackColor()?.false',\n '[style.backgroundColor]': 'iosBackgroundColor()',\n '[style.borderRadius]': 'iosBackgroundColor() ? 16 : undefined',\n '(change)': 'onNativeChange($event)',\n },\n})\nexport class Switch extends ViewBase {\n readonly checked = model<boolean>(false);\n /** Ignore touches and grey out. */\n readonly disabled = input(undefined, { transform: optionalBoolean });\n /** Published as `data-invalid`; nothing native reads it. */\n readonly invalid = input(false, { transform: booleanAttribute });\n /** Published as `data-touched`; nothing native reads it. */\n readonly touched = input(false, { transform: booleanAttribute });\n /** The user flipped it. What Signal Forms marks a field touched from. */\n readonly touch = output<void>();\n\n /** `Switch.js`: `accessibilityRole={props.accessibilityRole ?? 'switch'}`. */\n protected override roleByDefault(): 'switch' {\n return 'switch';\n }\n\n protected override disabledForAccessibility(): boolean | undefined {\n return this.disabled();\n }\n\n protected override checkedForAccessibility(): boolean {\n return this.checked();\n }\n /** The colour of the knob. */\n readonly thumbColor = input<string>();\n /** The track colour for each state. */\n readonly trackColor = input<{ readonly false?: string; readonly true?: string }>();\n /** iOS: the colour behind the track when off, seen where the track is transparent. */\n readonly iosBackgroundColor = input<string>(undefined, { alias: 'ios_backgroundColor' });\n\n protected readonly enabled = computed(() => {\n const disabled = this.disabled();\n return disabled === undefined ? undefined : !disabled;\n });\n\n private readonly injector = inject(Injector);\n private readonly control = new ControlledModel(this.checked, 'checked');\n /** What native reported last, until the pass it started has rendered and been compared. */\n private nativeValue: boolean | null = null;\n\n constructor() {\n super();\n effect(() => {\n // Android spells the value `on` and iOS the on-track colour `onTintColor`. Angular refuses\n // both as host bindings because they read as event handlers, so they go to the node.\n this.engine.setProp(this.node, 'on', this.checked());\n this.engine.setProp(this.node, 'onTintColor', this.trackColor()?.true);\n });\n }\n\n override ngOnChanges(changes: SimpleChanges): void {\n super.ngOnChanges(changes);\n this.control.noteChanges(changes);\n }\n\n protected onNativeChange(event: NativeSyntheticEvent<{ value?: boolean }>): void {\n this.nativeValue = event.nativeEvent?.value ?? false;\n this.control.propose(this.nativeValue);\n this.touch.emit();\n afterNextRender({ write: () => this.reconcile() }, { injector: this.injector });\n }\n\n /**\n * After the app's bindings have settled, not before: a flip the app accepts reaches the model\n * during change detection, and comparing any earlier would send native back the value it is\n * about to be given. A value set from code later needs none of this, as the prop changes.\n */\n private reconcile(): void {\n const native = this.nativeValue;\n this.nativeValue = null;\n const desired = this.checked();\n if (native === null || native === desired) return;\n const command = nativePlatform() === 'android' ? 'setNativeValue' : 'setValue';\n this.engine.dispatchCommand(this.node, command, [desired]);\n }\n}\n"]}
|
package/dist/text.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TouchableBase } from './pressable.ts';
|
|
2
|
+
import type { AccessibilityRole } from './view-base.ts';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
export type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip';
|
|
4
5
|
export type DynamicTypeRamp = 'caption2' | 'caption1' | 'footnote' | 'subheadline' | 'callout' | 'body' | 'headline' | 'title3' | 'title2' | 'title1' | 'largeTitle';
|
|
@@ -27,7 +28,14 @@ export declare class Text extends TouchableBase {
|
|
|
27
28
|
* `ngOnChanges` like the rest of the state, since `disabled` is an input of this directive: no
|
|
28
29
|
* host binding, which `ControlBase` needs and a text cannot afford.
|
|
29
30
|
*/
|
|
30
|
-
protected disabledForAccessibility(): boolean;
|
|
31
|
+
protected disabledForAccessibility(): boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* `Text.js`: a pressable text is a `link` unless a role is set or it is disabled, as the
|
|
34
|
+
* merged state says: `disabled` wins, and `aria-disabled`, `accessibilityState` or a
|
|
35
|
+
* contributing directive stand in when it is unset. Nested or not. Its inputs are this
|
|
36
|
+
* directive's, so `ngOnChanges` keeps it current without a host binding.
|
|
37
|
+
*/
|
|
38
|
+
protected roleByDefault(): AccessibilityRole | undefined;
|
|
31
39
|
/** Truncate after this many lines, with `ellipsizeMode` deciding where the ellipsis goes. */
|
|
32
40
|
readonly numberOfLines: import("@angular/core").InputSignalWithTransform<number | undefined, unknown>;
|
|
33
41
|
/**
|
|
@@ -55,7 +63,7 @@ export declare class Text extends TouchableBase {
|
|
|
55
63
|
/** Android: the line-breaking strategy. */
|
|
56
64
|
readonly textBreakStrategy: import("@angular/core").InputSignal<"simple" | "highQuality" | "balanced" | undefined>;
|
|
57
65
|
/** Android: turn phone numbers, links and addresses into tappable text. */
|
|
58
|
-
readonly dataDetectorType: import("@angular/core").InputSignal<"
|
|
66
|
+
readonly dataDetectorType: import("@angular/core").InputSignal<"link" | "none" | "phoneNumber" | "email" | "all" | undefined>;
|
|
59
67
|
/** Android: how often to hyphenate. */
|
|
60
68
|
readonly hyphenationFrequency: import("@angular/core").InputSignal<"none" | "normal" | "full" | undefined>;
|
|
61
69
|
/** Respond to presses. See the class note. */
|
|
@@ -70,6 +78,7 @@ export declare class Text extends TouchableBase {
|
|
|
70
78
|
/** The pass-through props, written when one of them changes. See `ViewBase.ngOnChanges`. */
|
|
71
79
|
ngOnChanges(): void;
|
|
72
80
|
protected claims(): boolean;
|
|
81
|
+
protected pressDisabled(): boolean;
|
|
73
82
|
protected measures(): boolean;
|
|
74
83
|
static ɵfac: i0.ɵɵFactoryDeclaration<Text, never>;
|
|
75
84
|
static ɵdir: i0.ɵɵDirectiveDeclaration<Text, "text", ["text"], { "numberOfLines": { "alias": "numberOfLines"; "required": false; "isSignal": true; }; "ellipsizeMode": { "alias": "ellipsizeMode"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "selectionColor": { "alias": "selectionColor"; "required": false; "isSignal": true; }; "allowFontScaling": { "alias": "allowFontScaling"; "required": false; "isSignal": true; }; "maxFontSizeMultiplier": { "alias": "maxFontSizeMultiplier"; "required": false; "isSignal": true; }; "dynamicTypeRamp": { "alias": "dynamicTypeRamp"; "required": false; "isSignal": true; }; "adjustsFontSizeToFit": { "alias": "adjustsFontSizeToFit"; "required": false; "isSignal": true; }; "minimumFontScale": { "alias": "minimumFontScale"; "required": false; "isSignal": true; }; "lineBreakStrategyIOS": { "alias": "lineBreakStrategyIOS"; "required": false; "isSignal": true; }; "textBreakStrategy": { "alias": "textBreakStrategy"; "required": false; "isSignal": true; }; "dataDetectorType": { "alias": "dataDetectorType"; "required": false; "isSignal": true; }; "hyphenationFrequency": { "alias": "android_hyphenationFrequency"; "required": false; "isSignal": true; }; "pressable": { "alias": "pressable"; "required": false; "isSignal": true; }; "suppressHighlighting": { "alias": "suppressHighlighting"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
package/dist/text.js
CHANGED
|
@@ -33,6 +33,17 @@ export class Text extends TouchableBase {
|
|
|
33
33
|
disabledForAccessibility() {
|
|
34
34
|
return this.disabled();
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* `Text.js`: a pressable text is a `link` unless a role is set or it is disabled, as the
|
|
38
|
+
* merged state says: `disabled` wins, and `aria-disabled`, `accessibilityState` or a
|
|
39
|
+
* contributing directive stand in when it is unset. Nested or not. Its inputs are this
|
|
40
|
+
* directive's, so `ngOnChanges` keeps it current without a host binding.
|
|
41
|
+
*/
|
|
42
|
+
roleByDefault() {
|
|
43
|
+
if (!this.pressable())
|
|
44
|
+
return undefined;
|
|
45
|
+
return this.accessibilityStateProp()?.disabled === true ? undefined : 'link';
|
|
46
|
+
}
|
|
36
47
|
/** Truncate after this many lines, with `ellipsizeMode` deciding where the ellipsis goes. */
|
|
37
48
|
numberOfLines = input(undefined, { ...(ngDevMode ? { debugName: "numberOfLines" } : /* istanbul ignore next */ {}), transform: optionalNumber });
|
|
38
49
|
/**
|
|
@@ -104,7 +115,10 @@ export class Text extends TouchableBase {
|
|
|
104
115
|
write('data-disabled', this.disabled() ? '' : undefined);
|
|
105
116
|
}
|
|
106
117
|
claims() {
|
|
107
|
-
return this.pressable() && !this.
|
|
118
|
+
return this.pressable() && !this.pressDisabled();
|
|
119
|
+
}
|
|
120
|
+
pressDisabled() {
|
|
121
|
+
return this.disabledByAnyState();
|
|
108
122
|
}
|
|
109
123
|
measures() {
|
|
110
124
|
return this.pressable();
|
package/dist/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;;AAgBlE;;;;;;;;;;;;GAYG;AAKH,MAAM,OAAO,IAAK,SAAQ,aAAa;IAC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CAAC,gBAAgB,EAAE,CAAC,CAAC;QACnD,KAAK,CAAC,sBAAsB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAC3D,KAAK,CAAC,mBAAmB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QACrD,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACnD,KAAK,CAAC,8BAA8B,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACnE,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,SAAS,CAAC,CAAC;QACpD,+FAA+F;QAC/F,uFAAuF;QACvF,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC;IAEkB,QAAQ;QACzB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;uGA9FU,IAAI;2FAAJ,IAAI;;2FAAJ,IAAI;kBAJhB,SAAS;mBAAC;oBACT,QAAQ,EAAE,MAAM;oBAChB,QAAQ,EAAE,MAAM;iBACjB","sourcesContent":["import { Directive, booleanAttribute, input } from '@angular/core';\nimport { nativePlatform } from '@ng-native/fabric';\nimport { TouchableBase } from './pressable.ts';\nimport { optionalBoolean, optionalNumber } from './transforms.ts';\n\nexport type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip';\nexport type DynamicTypeRamp =\n | 'caption2'\n | 'caption1'\n | 'footnote'\n | 'subheadline'\n | 'callout'\n | 'body'\n | 'headline'\n | 'title3'\n | 'title2'\n | 'title1'\n | 'largeTitle';\n\n/**\n * A run of text. Commits as `Paragraph`, or as a span (`VirtualText`) when nested in another\n * `<text>`, which the engine decides from the tree so a nested run inherits its parent's font\n * and sits on its baseline.\n *\n * Text inherits `color`, `fontSize` and the other text properties from CSS as it does on the\n * web; from an inline `[style]` on an ancestor view it does not, exactly as in RN.\n *\n * Presses: RN makes a text pressable when a press handler is present. Angular cannot see\n * whether `(press)` is bound, so set `pressable` to opt in; the handlers, delays and long press\n * are then the same as `<pressable>`'s. iOS highlights a pressed run unless\n * `suppressHighlighting` is set.\n */\n@Directive({\n selector: 'text',\n exportAs: 'text',\n})\nexport class Text extends TouchableBase {\n /**\n * `Text.js` splits by platform: on iOS every text is an accessibility element unless refused,\n * on Android only one that can be pressed. Nothing native can infer which, so the host's\n * `Platform.OS` decides, exactly as React Native's own wrapper does.\n */\n protected override accessibleByDefault(): boolean {\n return nativePlatform() === 'android' ? this.pressable() : true;\n }\n\n /**\n * `Text.js` announces `disabled` on every text, pressable or not, nested or not. Written from\n * `ngOnChanges` like the rest of the state, since `disabled` is an input of this directive: no\n * host binding, which `ControlBase` needs and a text cannot afford.\n */\n protected override disabledForAccessibility(): boolean {\n return this.disabled();\n }\n\n /** Truncate after this many lines, with `ellipsizeMode` deciding where the ellipsis goes. */\n readonly numberOfLines = input<number>(undefined, { transform: optionalNumber });\n /**\n * Where truncated text is cut. `clip` is iOS only. Defaults to `tail`, as React Native's `Text`\n * does in JavaScript: native's own default is to clip, with no ellipsis. The default is the\n * engine's, below `text-overflow` in a stylesheet, which in turn is below this input.\n */\n readonly ellipsizeMode = input<EllipsizeMode>();\n /** Let the user select and copy the text. */\n readonly selectable = input<boolean>(undefined, { transform: optionalBoolean });\n /** The highlight colour of a selection. */\n readonly selectionColor = input<string>();\n /** Scale with the system Text Size setting. Defaults to true. */\n readonly allowFontScaling = input<boolean>(undefined, { transform: optionalBoolean });\n /** The most `allowFontScaling` may scale by; 0 means no limit. */\n readonly maxFontSizeMultiplier = input<number>(undefined, { transform: optionalNumber });\n /** iOS: the Dynamic Type style this text follows. */\n readonly dynamicTypeRamp = input<DynamicTypeRamp>();\n /** iOS: shrink the font to fit `numberOfLines`. */\n readonly adjustsFontSizeToFit = input<boolean>(undefined, { transform: optionalBoolean });\n /** iOS: the smallest scale `adjustsFontSizeToFit` may shrink to, from 0.01 to 1. */\n readonly minimumFontScale = input<number>(undefined, { transform: optionalNumber });\n /** iOS: the line-breaking strategy. */\n readonly lineBreakStrategyIOS = input<'none' | 'standard' | 'hangul-word' | 'push-out'>();\n /** Android: the line-breaking strategy. */\n readonly textBreakStrategy = input<'simple' | 'highQuality' | 'balanced'>();\n /** Android: turn phone numbers, links and addresses into tappable text. */\n readonly dataDetectorType = input<'phoneNumber' | 'link' | 'email' | 'none' | 'all'>();\n /** Android: how often to hyphenate. */\n readonly hyphenationFrequency = input<'normal' | 'none' | 'full'>(undefined, {\n alias: 'android_hyphenationFrequency',\n });\n /** Respond to presses. See the class note. */\n readonly pressable = input(false, { transform: booleanAttribute });\n /** iOS: do not grey the text while it is pressed. */\n readonly suppressHighlighting = input(false, { transform: booleanAttribute });\n\n /**\n * Written when the press starts and ends rather than bound from the host: a host binding would\n * run for every text on screen on every pass, to follow a press that almost none of them get.\n */\n protected override pressedChanged(pressed: boolean): void {\n const highlight = pressed && !this.suppressHighlighting();\n this.engine.setProp(this.node, 'isHighlighted', highlight ? true : undefined);\n }\n\n /** The pass-through props, written when one of them changes. See `ViewBase.ngOnChanges`. */\n override ngOnChanges(): void {\n super.ngOnChanges();\n const write = (key: string, value: unknown) => this.engine.setProp(this.node, key, value);\n write('numberOfLines', this.numberOfLines());\n write('ellipsizeMode', this.ellipsizeMode());\n write('selectable', this.selectable());\n write('selectionColor', this.selectionColor());\n write('allowFontScaling', this.allowFontScaling());\n write('maxFontSizeMultiplier', this.maxFontSizeMultiplier());\n write('dynamicTypeRamp', this.dynamicTypeRamp());\n write('adjustsFontSizeToFit', this.adjustsFontSizeToFit());\n write('minimumFontScale', this.minimumFontScale());\n write('lineBreakStrategyIOS', this.lineBreakStrategyIOS());\n write('textBreakStrategy', this.textBreakStrategy());\n write('dataDetectorType', this.dataDetectorType());\n write('android_hyphenationFrequency', this.hyphenationFrequency());\n write('isPressable', this.pressable() || undefined);\n // `disabled` is consumed as an input, so this is what `[data-disabled]` and `disabled:` match,\n // as on a control. Written here rather than bound from the host; see `pressedChanged`.\n write('data-disabled', this.disabled() ? '' : undefined);\n }\n\n protected override claims(): boolean {\n return this.pressable() && !this.disabled();\n }\n\n protected override measures(): boolean {\n return this.pressable();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;;AAiBlE;;;;;;;;;;;;GAYG;AAKH,MAAM,OAAO,IAAK,SAAQ,aAAa;IACrC;;;;OAIG;IACgB,mBAAmB;QACpC,OAAO,cAAc,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACgB,wBAAwB;QACzC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACgB,aAAa;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YAAE,OAAO,SAAS,CAAC;QACxC,OAAO,IAAI,CAAC,sBAAsB,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/E,CAAC;IAED,6FAA6F;IACpF,aAAa,GAAG,KAAK,CAAS,SAAS,qFAAI,SAAS,EAAE,cAAc,GAAG,CAAC;IACjF;;;;OAIG;IACM,aAAa,GAAG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AI,CAAC,SAAS,EAAE,IAAI,SAAS,CAAC,CAAC;QACpD,+FAA+F;QAC/F,uFAAuF;QACvF,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IACnD,CAAC;IAEkB,aAAa;QAC9B,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;IAEkB,QAAQ;QACzB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;uGA7GU,IAAI;2FAAJ,IAAI;;2FAAJ,IAAI;kBAJhB,SAAS;mBAAC;oBACT,QAAQ,EAAE,MAAM;oBAChB,QAAQ,EAAE,MAAM;iBACjB","sourcesContent":["import { Directive, booleanAttribute, input } from '@angular/core';\nimport { nativePlatform } from '@ng-native/fabric';\nimport { TouchableBase } from './pressable.ts';\nimport { optionalBoolean, optionalNumber } from './transforms.ts';\nimport type { AccessibilityRole } from './view-base.ts';\n\nexport type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip';\nexport type DynamicTypeRamp =\n | 'caption2'\n | 'caption1'\n | 'footnote'\n | 'subheadline'\n | 'callout'\n | 'body'\n | 'headline'\n | 'title3'\n | 'title2'\n | 'title1'\n | 'largeTitle';\n\n/**\n * A run of text. Commits as `Paragraph`, or as a span (`VirtualText`) when nested in another\n * `<text>`, which the engine decides from the tree so a nested run inherits its parent's font\n * and sits on its baseline.\n *\n * Text inherits `color`, `fontSize` and the other text properties from CSS as it does on the\n * web; from an inline `[style]` on an ancestor view it does not, exactly as in RN.\n *\n * Presses: RN makes a text pressable when a press handler is present. Angular cannot see\n * whether `(press)` is bound, so set `pressable` to opt in; the handlers, delays and long press\n * are then the same as `<pressable>`'s. iOS highlights a pressed run unless\n * `suppressHighlighting` is set.\n */\n@Directive({\n selector: 'text',\n exportAs: 'text',\n})\nexport class Text extends TouchableBase {\n /**\n * `Text.js` splits by platform: on iOS every text is an accessibility element unless refused,\n * on Android only one that can be pressed. Nothing native can infer which, so the host's\n * `Platform.OS` decides, exactly as React Native's own wrapper does.\n */\n protected override accessibleByDefault(): boolean {\n return nativePlatform() === 'android' ? this.pressable() : true;\n }\n\n /**\n * `Text.js` announces `disabled` on every text, pressable or not, nested or not. Written from\n * `ngOnChanges` like the rest of the state, since `disabled` is an input of this directive: no\n * host binding, which `ControlBase` needs and a text cannot afford.\n */\n protected override disabledForAccessibility(): boolean | undefined {\n return this.disabled();\n }\n\n /**\n * `Text.js`: a pressable text is a `link` unless a role is set or it is disabled, as the\n * merged state says: `disabled` wins, and `aria-disabled`, `accessibilityState` or a\n * contributing directive stand in when it is unset. Nested or not. Its inputs are this\n * directive's, so `ngOnChanges` keeps it current without a host binding.\n */\n protected override roleByDefault(): AccessibilityRole | undefined {\n if (!this.pressable()) return undefined;\n return this.accessibilityStateProp()?.disabled === true ? undefined : 'link';\n }\n\n /** Truncate after this many lines, with `ellipsizeMode` deciding where the ellipsis goes. */\n readonly numberOfLines = input<number>(undefined, { transform: optionalNumber });\n /**\n * Where truncated text is cut. `clip` is iOS only. Defaults to `tail`, as React Native's `Text`\n * does in JavaScript: native's own default is to clip, with no ellipsis. The default is the\n * engine's, below `text-overflow` in a stylesheet, which in turn is below this input.\n */\n readonly ellipsizeMode = input<EllipsizeMode>();\n /** Let the user select and copy the text. */\n readonly selectable = input<boolean>(undefined, { transform: optionalBoolean });\n /** The highlight colour of a selection. */\n readonly selectionColor = input<string>();\n /** Scale with the system Text Size setting. Defaults to true. */\n readonly allowFontScaling = input<boolean>(undefined, { transform: optionalBoolean });\n /** The most `allowFontScaling` may scale by; 0 means no limit. */\n readonly maxFontSizeMultiplier = input<number>(undefined, { transform: optionalNumber });\n /** iOS: the Dynamic Type style this text follows. */\n readonly dynamicTypeRamp = input<DynamicTypeRamp>();\n /** iOS: shrink the font to fit `numberOfLines`. */\n readonly adjustsFontSizeToFit = input<boolean>(undefined, { transform: optionalBoolean });\n /** iOS: the smallest scale `adjustsFontSizeToFit` may shrink to, from 0.01 to 1. */\n readonly minimumFontScale = input<number>(undefined, { transform: optionalNumber });\n /** iOS: the line-breaking strategy. */\n readonly lineBreakStrategyIOS = input<'none' | 'standard' | 'hangul-word' | 'push-out'>();\n /** Android: the line-breaking strategy. */\n readonly textBreakStrategy = input<'simple' | 'highQuality' | 'balanced'>();\n /** Android: turn phone numbers, links and addresses into tappable text. */\n readonly dataDetectorType = input<'phoneNumber' | 'link' | 'email' | 'none' | 'all'>();\n /** Android: how often to hyphenate. */\n readonly hyphenationFrequency = input<'normal' | 'none' | 'full'>(undefined, {\n alias: 'android_hyphenationFrequency',\n });\n /** Respond to presses. See the class note. */\n readonly pressable = input(false, { transform: booleanAttribute });\n /** iOS: do not grey the text while it is pressed. */\n readonly suppressHighlighting = input(false, { transform: booleanAttribute });\n\n /**\n * Written when the press starts and ends rather than bound from the host: a host binding would\n * run for every text on screen on every pass, to follow a press that almost none of them get.\n */\n protected override pressedChanged(pressed: boolean): void {\n const highlight = pressed && !this.suppressHighlighting();\n this.engine.setProp(this.node, 'isHighlighted', highlight ? true : undefined);\n }\n\n /** The pass-through props, written when one of them changes. See `ViewBase.ngOnChanges`. */\n override ngOnChanges(): void {\n super.ngOnChanges();\n const write = (key: string, value: unknown) => this.engine.setProp(this.node, key, value);\n write('numberOfLines', this.numberOfLines());\n write('ellipsizeMode', this.ellipsizeMode());\n write('selectable', this.selectable());\n write('selectionColor', this.selectionColor());\n write('allowFontScaling', this.allowFontScaling());\n write('maxFontSizeMultiplier', this.maxFontSizeMultiplier());\n write('dynamicTypeRamp', this.dynamicTypeRamp());\n write('adjustsFontSizeToFit', this.adjustsFontSizeToFit());\n write('minimumFontScale', this.minimumFontScale());\n write('lineBreakStrategyIOS', this.lineBreakStrategyIOS());\n write('textBreakStrategy', this.textBreakStrategy());\n write('dataDetectorType', this.dataDetectorType());\n write('android_hyphenationFrequency', this.hyphenationFrequency());\n write('isPressable', this.pressable() || undefined);\n // `disabled` is consumed as an input, so this is what `[data-disabled]` and `disabled:` match,\n // as on a control. Written here rather than bound from the host; see `pressedChanged`.\n write('data-disabled', this.disabled() ? '' : undefined);\n }\n\n protected override claims(): boolean {\n return this.pressable() && !this.pressDisabled();\n }\n\n protected override pressDisabled(): boolean {\n return this.disabledByAnyState();\n }\n\n protected override measures(): boolean {\n return this.pressable();\n }\n}\n"]}
|
|
@@ -17,7 +17,8 @@ export declare class TouchableOpacity extends ControlBase {
|
|
|
17
17
|
/** `TouchableOpacity.js`: `accessible={this.props.accessible !== false}`, and focusable too. */
|
|
18
18
|
protected accessibleByDefault(): boolean;
|
|
19
19
|
protected focusableByDefault(): boolean;
|
|
20
|
-
protected disabledForAccessibility(): boolean;
|
|
20
|
+
protected disabledForAccessibility(): boolean | undefined;
|
|
21
|
+
protected pressDisabled(): boolean;
|
|
21
22
|
/** The opacity while pressed. */
|
|
22
23
|
readonly activeOpacity: import("@angular/core").InputSignalWithTransform<number, unknown>;
|
|
23
24
|
/** Undefined at rest, so the caller's own `[style]` opacity shows through. */
|
|
@@ -25,6 +25,9 @@ export class TouchableOpacity extends ControlBase {
|
|
|
25
25
|
disabledForAccessibility() {
|
|
26
26
|
return this.disabled();
|
|
27
27
|
}
|
|
28
|
+
pressDisabled() {
|
|
29
|
+
return this.disabledByAnyState();
|
|
30
|
+
}
|
|
28
31
|
/** The opacity while pressed. */
|
|
29
32
|
activeOpacity = input(0.2, { ...(ngDevMode ? { debugName: "activeOpacity" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
30
33
|
/** Undefined at rest, so the caller's own `[style]` opacity shows through. */
|