react-native-tinyui 2.0.0 → 3.0.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 +117 -41
- package/ios/Core/TinyuiComponentClasses.mm +7 -0
- package/ios/TipKit/TinyuiTip.swift +16 -0
- package/ios/TipKit/TinyuiTipPopoverProvider.swift +66 -135
- package/ios/TipKit/TinyuiTipPopoverView.mm +0 -18
- package/ios/TipKit/TinyuiTipView.h +8 -0
- package/ios/TipKit/TinyuiTipView.mm +93 -0
- package/ios/TipKit/TinyuiTipViewProvider.swift +140 -0
- package/ios/TipKit/TinyuiTipViewShadowNode.h +48 -0
- package/ios/TipKit/TinyuiTipsRuntime.swift +2 -74
- package/lib/module/TipKit/Popover.js +0 -22
- package/lib/module/TipKit/Popover.js.map +1 -1
- package/lib/module/TipKit/TipPopoverNativeComponent.ts +0 -6
- package/lib/module/TipKit/TipViewNativeComponent.ts +28 -0
- package/lib/module/TipKit/View.js +62 -0
- package/lib/module/TipKit/View.js.map +1 -0
- package/lib/module/TipKit/index.js +2 -0
- package/lib/module/TipKit/index.js.map +1 -1
- package/lib/module/TipKit/validation.js +4 -4
- package/lib/module/TipKit/validation.js.map +1 -1
- package/lib/typescript/src/TipKit/Popover.d.ts.map +1 -1
- package/lib/typescript/src/TipKit/TipPopoverNativeComponent.d.ts +0 -9
- package/lib/typescript/src/TipKit/TipPopoverNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/TipKit/TipViewNativeComponent.d.ts +29 -0
- package/lib/typescript/src/TipKit/TipViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/View.d.ts +3 -0
- package/lib/typescript/src/TipKit/View.d.ts.map +1 -0
- package/lib/typescript/src/TipKit/index.d.ts +2 -1
- package/lib/typescript/src/TipKit/index.d.ts.map +1 -1
- package/lib/typescript/src/TipKit/types.d.ts +17 -15
- package/lib/typescript/src/TipKit/types.d.ts.map +1 -1
- package/lib/typescript/src/TipKit/validation.d.ts +2 -2
- package/lib/typescript/src/TipKit/validation.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/TipKit/Popover.tsx +1 -21
- package/src/TipKit/TipPopoverNativeComponent.ts +0 -6
- package/src/TipKit/TipViewNativeComponent.ts +28 -0
- package/src/TipKit/View.tsx +64 -0
- package/src/TipKit/index.ts +3 -1
- package/src/TipKit/types.ts +19 -20
- package/src/TipKit/validation.ts +8 -5
- package/src/index.tsx +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CodegenTypes, type ViewProps } from 'react-native';
|
|
2
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export interface NativeTipViewProps extends ViewProps {
|
|
4
|
+
tipId: string;
|
|
5
|
+
title: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
systemImage?: string;
|
|
8
|
+
actions?: ReadonlyArray<Readonly<{
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
}>>;
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
maxDisplayCount?: CodegenTypes.Int32;
|
|
14
|
+
ignoresDisplayFrequency?: boolean;
|
|
15
|
+
arrowEdge?: string;
|
|
16
|
+
onTipAction?: DirectEventHandler<Readonly<{
|
|
17
|
+
tipId: string;
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
}>>;
|
|
21
|
+
onTipError?: DirectEventHandler<Readonly<{
|
|
22
|
+
tipId: string;
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}>>;
|
|
26
|
+
}
|
|
27
|
+
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeTipViewProps>;
|
|
28
|
+
export default _default;
|
|
29
|
+
//# sourceMappingURL=TipViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TipViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/TipViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,kBAAkB,CAC9B,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CACvD,CAAC;IACF,UAAU,CAAC,EAAE,kBAAkB,CAC7B,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAC3D,CAAC;CACH;;AAED,wBAEG"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { TipViewProps } from './types.js';
|
|
2
|
+
export declare const View: import("react").ForwardRefExoticComponent<TipViewProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
3
|
+
//# sourceMappingURL=View.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/View.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC;AAG5C,eAAO,MAAM,IAAI,0LAqDf,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TipInvalidationReason, TipKitConfiguration } from './types.js';
|
|
2
2
|
export declare const TipKit: {
|
|
3
3
|
Popover: import("react").ForwardRefExoticComponent<import("./types.js").TipPopoverProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
4
|
+
View: import("react").ForwardRefExoticComponent<import("./types.js").TipViewProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
4
5
|
/**
|
|
5
6
|
* Clear all persisted tip, event and parameter records for testing.
|
|
6
7
|
* Call and await this before configure(); rejects if already configured,
|
|
@@ -12,5 +13,5 @@ export declare const TipKit: {
|
|
|
12
13
|
/** Persistently invalidate a tip, including when its view is not mounted. */
|
|
13
14
|
invalidate(tipId: string, reason?: TipInvalidationReason): Promise<void>;
|
|
14
15
|
};
|
|
15
|
-
export type { TipAction, TipDisplayFrequency, TipError, TipInvalidationReason, TipKitConfiguration, TipPopoverProps,
|
|
16
|
+
export type { TipAction, TipDisplayFrequency, TipError, TipInvalidationReason, TipKitConfiguration, TipPopoverProps, TipViewProps, } from './types.js';
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAS,CAAC;AAK1E,eAAO,MAAM,MAAM;;;IAGjB;;;;OAIG;sBACqB,OAAO,CAAC,IAAI,CAAC;IAKrC,sFAAsF;sCAGnF,mBAAmB,GAAQ,OAAO,CAAC,IAAI,CAAC;IAc3C,6EAA6E;sBAEpE,MAAM,WACL,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC;CAQjB,CAAC;AAEF,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,YAAY,GACb,MAAM,YAAS,CAAC"}
|
|
@@ -6,41 +6,43 @@ export interface TipKitConfiguration {
|
|
|
6
6
|
displayFrequency?: TipDisplayFrequency;
|
|
7
7
|
}
|
|
8
8
|
export type TipInvalidationReason = 'actionPerformed' | 'tipClosed';
|
|
9
|
-
export type TipStatus = {
|
|
10
|
-
status: 'pending' | 'available';
|
|
11
|
-
} | {
|
|
12
|
-
status: 'invalidated';
|
|
13
|
-
reason: TipInvalidationReason | 'displayCountExceeded' | 'displayDurationExceeded' | 'unknown';
|
|
14
|
-
};
|
|
15
9
|
export interface TipAction {
|
|
10
|
+
/** Unique nonempty identity within this tip, returned by `onActionPress`. */
|
|
16
11
|
id: string;
|
|
12
|
+
/** Nonempty button label, already localized by the app. */
|
|
17
13
|
title: string;
|
|
18
14
|
}
|
|
19
15
|
export interface TipError {
|
|
20
16
|
code: string;
|
|
21
17
|
message: string;
|
|
22
18
|
}
|
|
23
|
-
export interface
|
|
24
|
-
/** Anchor content. Its existing touch handlers are preserved. */
|
|
25
|
-
children: ReactNode;
|
|
19
|
+
export interface TipContentProps extends Omit<ViewProps, 'children'> {
|
|
26
20
|
/** Stable identity used by TipKit to persist this tip's history. */
|
|
27
21
|
tipId: string;
|
|
28
22
|
title: string;
|
|
29
23
|
message?: string;
|
|
30
24
|
systemImage?: string;
|
|
25
|
+
/** Native action buttons, each with its own id and title; TipKit controls their layout. */
|
|
31
26
|
actions?: readonly TipAction[];
|
|
32
27
|
/** Allows presentation when TipKit is also eligible. Defaults to true. */
|
|
33
28
|
enabled?: boolean;
|
|
34
29
|
/** Omit to leave the number of presentations unlimited. */
|
|
35
30
|
maxDisplayCount?: number;
|
|
36
31
|
ignoresDisplayFrequency?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
arrowEdge?: 'top' | 'bottom' | 'leading' | 'trailing' | 'auto';
|
|
39
|
-
/** TipKit eligibility, independent of whether the bubble is on screen. */
|
|
40
|
-
onStatusChange?: (status: TipStatus) => void;
|
|
41
|
-
onVisibleChange?: (visible: boolean) => void;
|
|
42
|
-
/** Actions do not automatically invalidate the tip. */
|
|
32
|
+
/** Receives the tapped button's id and title; does not automatically invalidate the tip. */
|
|
43
33
|
onActionPress?: (action: TipAction) => void;
|
|
44
34
|
onError?: (error: TipError) => void;
|
|
45
35
|
}
|
|
36
|
+
export interface TipPopoverProps extends TipContentProps {
|
|
37
|
+
/** Anchor content. Its existing touch handlers are preserved. */
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
/** Preferred arrow edge on the bubble; UIKit may adapt to available space. */
|
|
40
|
+
arrowEdge?: 'top' | 'bottom' | 'leading' | 'trailing' | 'auto';
|
|
41
|
+
}
|
|
42
|
+
export interface TipViewProps extends TipContentProps {
|
|
43
|
+
/** Inline tips render native content and do not take anchor children. */
|
|
44
|
+
children?: never;
|
|
45
|
+
/** Optional arrow on the inline view. Defaults to no arrow. */
|
|
46
|
+
arrowEdge?: 'top' | 'bottom' | 'leading' | 'trailing' | 'none';
|
|
47
|
+
}
|
|
46
48
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAC7B,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,WAAW,CAAC;AAEpE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAC7B,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,WAAW,CAAC;AAEpE,MAAM,WAAW,SAAS;IACxB,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IAClE,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC/B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,4FAA4F;IAC5F,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,iEAAiE;IACjE,QAAQ,EAAE,SAAS,CAAC;IACpB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;CAChE;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,yEAAyE;IACzE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;CAChE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TipContentProps } from './types.js';
|
|
2
2
|
export declare function validateTipId(tipId: string): void;
|
|
3
|
-
export declare function validateTip(props:
|
|
3
|
+
export declare function validateTip(props: TipContentProps, component?: string): void;
|
|
4
4
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAS,CAAC;AAE/C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/TipKit/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAS,CAAC;AAE/C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,SAAS,SAAmB,GAC3B,IAAI,CA8BN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Menu } from './Menu/index.js';
|
|
2
2
|
export { TipKit } from './TipKit/index.js';
|
|
3
|
-
export type { TipAction, TipDisplayFrequency, TipError, TipInvalidationReason, TipPopoverProps,
|
|
3
|
+
export type { TipAction, TipDisplayFrequency, TipError, TipInvalidationReason, TipPopoverProps, TipViewProps, TipKitConfiguration, } from './TipKit/index.js';
|
|
4
4
|
export type { MenuActionOption, MenuActionPressEvent, MenuActionPressEventData, MenuDividerOption, MenuItemState, MenuOption, MenuProps, MenuRef, MenuSectionOption, MenuSubmenuOption, } from './Menu/index.js';
|
|
5
5
|
export { Stepper } from './Stepper/index.js';
|
|
6
6
|
export type { StepperProps } from './Stepper/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAU,CAAC;AAClC,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAU,CAAC;AAClC,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,mBAAmB,GACpB,MAAM,mBAAU,CAAC;AAClB,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iBAAQ,CAAC;AAEhB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAW,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAAkB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAY,CAAC;AACtC,YAAY,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,cAAc,GACf,MAAM,qBAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAW,CAAC;AAClD,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,YAAY,GACb,MAAM,oBAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,kBAAS,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAS,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAAmB,CAAC;AACpD,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,4BAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-tinyui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Dependency-free native iOS Menu, Popover, TipKit, Stepper, ConcentricView, SFSymbol and LiquidGlassText components for React Native",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -172,6 +172,9 @@
|
|
|
172
172
|
},
|
|
173
173
|
"TinyuiTipPopoverView": {
|
|
174
174
|
"className": "TinyuiTipPopoverView"
|
|
175
|
+
},
|
|
176
|
+
"TinyuiTipView": {
|
|
177
|
+
"className": "TinyuiTipView"
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
}
|
package/src/TipKit/Popover.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { View } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { assertComponentEnabled } from '../utils';
|
|
5
5
|
import NativeTipPopoverView from './TipPopoverNativeComponent';
|
|
6
|
-
import type { TipPopoverProps
|
|
6
|
+
import type { TipPopoverProps } from './types';
|
|
7
7
|
import { validateTip } from './validation';
|
|
8
8
|
|
|
9
9
|
export const Popover = forwardRef<ComponentRef<typeof View>, TipPopoverProps>(
|
|
@@ -21,8 +21,6 @@ export const Popover = forwardRef<ComponentRef<typeof View>, TipPopoverProps>(
|
|
|
21
21
|
maxDisplayCount,
|
|
22
22
|
ignoresDisplayFrequency = false,
|
|
23
23
|
arrowEdge = 'auto',
|
|
24
|
-
onStatusChange,
|
|
25
|
-
onVisibleChange,
|
|
26
24
|
onActionPress,
|
|
27
25
|
onError,
|
|
28
26
|
...viewProps
|
|
@@ -42,24 +40,6 @@ export const Popover = forwardRef<ComponentRef<typeof View>, TipPopoverProps>(
|
|
|
42
40
|
maxDisplayCount={maxDisplayCount ?? 0}
|
|
43
41
|
ignoresDisplayFrequency={ignoresDisplayFrequency}
|
|
44
42
|
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
43
|
onTipAction={({ nativeEvent }) => {
|
|
64
44
|
if (nativeEvent.tipId === tipId) {
|
|
65
45
|
onActionPress?.({ id: nativeEvent.id, title: nativeEvent.title });
|
|
@@ -15,12 +15,6 @@ export interface NativeTipPopoverProps extends ViewProps {
|
|
|
15
15
|
maxDisplayCount?: CodegenTypes.Int32;
|
|
16
16
|
ignoresDisplayFrequency?: boolean;
|
|
17
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
18
|
onTipAction?: DirectEventHandler<
|
|
25
19
|
Readonly<{ tipId: string; id: string; title: string }>
|
|
26
20
|
>;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 NativeTipViewProps 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
|
+
onTipAction?: DirectEventHandler<
|
|
19
|
+
Readonly<{ tipId: string; id: string; title: string }>
|
|
20
|
+
>;
|
|
21
|
+
onTipError?: DirectEventHandler<
|
|
22
|
+
Readonly<{ tipId: string; code: string; message: string }>
|
|
23
|
+
>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default codegenNativeComponent<NativeTipViewProps>('TinyuiTipView', {
|
|
27
|
+
excludedPlatforms: ['android'],
|
|
28
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { forwardRef, type ComponentRef } from 'react';
|
|
2
|
+
import type { View as ReactNativeView } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { assertComponentEnabled } from '../utils';
|
|
5
|
+
import NativeTipView from './TipViewNativeComponent';
|
|
6
|
+
import type { TipViewProps } from './types';
|
|
7
|
+
import { validateTip } from './validation';
|
|
8
|
+
|
|
9
|
+
export const View = forwardRef<
|
|
10
|
+
ComponentRef<typeof ReactNativeView>,
|
|
11
|
+
TipViewProps
|
|
12
|
+
>(function TipViewRoot(props, ref) {
|
|
13
|
+
assertComponentEnabled('TipKit');
|
|
14
|
+
validateTip(props, 'TipKit.View');
|
|
15
|
+
const {
|
|
16
|
+
tipId,
|
|
17
|
+
title,
|
|
18
|
+
message,
|
|
19
|
+
systemImage,
|
|
20
|
+
actions,
|
|
21
|
+
enabled = true,
|
|
22
|
+
maxDisplayCount,
|
|
23
|
+
ignoresDisplayFrequency = false,
|
|
24
|
+
arrowEdge = 'none',
|
|
25
|
+
onActionPress,
|
|
26
|
+
onError,
|
|
27
|
+
...viewProps
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<NativeTipView
|
|
32
|
+
{...viewProps}
|
|
33
|
+
children={undefined}
|
|
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
|
+
onTipAction={({ nativeEvent }) => {
|
|
46
|
+
if (nativeEvent.tipId === tipId) {
|
|
47
|
+
onActionPress?.({ id: nativeEvent.id, title: nativeEvent.title });
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
onTipError={({ nativeEvent }) => {
|
|
51
|
+
if (nativeEvent.tipId !== tipId) return;
|
|
52
|
+
const error = {
|
|
53
|
+
code: nativeEvent.code,
|
|
54
|
+
message: nativeEvent.message,
|
|
55
|
+
};
|
|
56
|
+
if (onError) onError(error);
|
|
57
|
+
else
|
|
58
|
+
console.warn(`[TinyUI] TipKit.View ${error.code}: ${error.message}`);
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
View.displayName = 'TipKit.View';
|
package/src/TipKit/index.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { assertComponentEnabled, getNativeTinyui } from '../utils';
|
|
|
2
2
|
import type { TipInvalidationReason, TipKitConfiguration } from './types';
|
|
3
3
|
import { validateTipId } from './validation';
|
|
4
4
|
import { Popover } from './Popover';
|
|
5
|
+
import { View } from './View';
|
|
5
6
|
|
|
6
7
|
export const TipKit = {
|
|
7
8
|
Popover,
|
|
9
|
+
View,
|
|
8
10
|
/**
|
|
9
11
|
* Clear all persisted tip, event and parameter records for testing.
|
|
10
12
|
* Call and await this before configure(); rejects if already configured,
|
|
@@ -53,5 +55,5 @@ export type {
|
|
|
53
55
|
TipInvalidationReason,
|
|
54
56
|
TipKitConfiguration,
|
|
55
57
|
TipPopoverProps,
|
|
56
|
-
|
|
58
|
+
TipViewProps,
|
|
57
59
|
} from './types';
|
package/src/TipKit/types.ts
CHANGED
|
@@ -11,19 +11,10 @@ export interface TipKitConfiguration {
|
|
|
11
11
|
|
|
12
12
|
export type TipInvalidationReason = 'actionPerformed' | 'tipClosed';
|
|
13
13
|
|
|
14
|
-
export type TipStatus =
|
|
15
|
-
| { status: 'pending' | 'available' }
|
|
16
|
-
| {
|
|
17
|
-
status: 'invalidated';
|
|
18
|
-
reason:
|
|
19
|
-
| TipInvalidationReason
|
|
20
|
-
| 'displayCountExceeded'
|
|
21
|
-
| 'displayDurationExceeded'
|
|
22
|
-
| 'unknown';
|
|
23
|
-
};
|
|
24
|
-
|
|
25
14
|
export interface TipAction {
|
|
15
|
+
/** Unique nonempty identity within this tip, returned by `onActionPress`. */
|
|
26
16
|
id: string;
|
|
17
|
+
/** Nonempty button label, already localized by the app. */
|
|
27
18
|
title: string;
|
|
28
19
|
}
|
|
29
20
|
|
|
@@ -32,26 +23,34 @@ export interface TipError {
|
|
|
32
23
|
message: string;
|
|
33
24
|
}
|
|
34
25
|
|
|
35
|
-
export interface
|
|
36
|
-
/** Anchor content. Its existing touch handlers are preserved. */
|
|
37
|
-
children: ReactNode;
|
|
26
|
+
export interface TipContentProps extends Omit<ViewProps, 'children'> {
|
|
38
27
|
/** Stable identity used by TipKit to persist this tip's history. */
|
|
39
28
|
tipId: string;
|
|
40
29
|
title: string;
|
|
41
30
|
message?: string;
|
|
42
31
|
systemImage?: string;
|
|
32
|
+
/** Native action buttons, each with its own id and title; TipKit controls their layout. */
|
|
43
33
|
actions?: readonly TipAction[];
|
|
44
34
|
/** Allows presentation when TipKit is also eligible. Defaults to true. */
|
|
45
35
|
enabled?: boolean;
|
|
46
36
|
/** Omit to leave the number of presentations unlimited. */
|
|
47
37
|
maxDisplayCount?: number;
|
|
48
38
|
ignoresDisplayFrequency?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
arrowEdge?: 'top' | 'bottom' | 'leading' | 'trailing' | 'auto';
|
|
51
|
-
/** TipKit eligibility, independent of whether the bubble is on screen. */
|
|
52
|
-
onStatusChange?: (status: TipStatus) => void;
|
|
53
|
-
onVisibleChange?: (visible: boolean) => void;
|
|
54
|
-
/** Actions do not automatically invalidate the tip. */
|
|
39
|
+
/** Receives the tapped button's id and title; does not automatically invalidate the tip. */
|
|
55
40
|
onActionPress?: (action: TipAction) => void;
|
|
56
41
|
onError?: (error: TipError) => void;
|
|
57
42
|
}
|
|
43
|
+
|
|
44
|
+
export interface TipPopoverProps extends TipContentProps {
|
|
45
|
+
/** Anchor content. Its existing touch handlers are preserved. */
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
/** Preferred arrow edge on the bubble; UIKit may adapt to available space. */
|
|
48
|
+
arrowEdge?: 'top' | 'bottom' | 'leading' | 'trailing' | 'auto';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface TipViewProps extends TipContentProps {
|
|
52
|
+
/** Inline tips render native content and do not take anchor children. */
|
|
53
|
+
children?: never;
|
|
54
|
+
/** Optional arrow on the inline view. Defaults to no arrow. */
|
|
55
|
+
arrowEdge?: 'top' | 'bottom' | 'leading' | 'trailing' | 'none';
|
|
56
|
+
}
|
package/src/TipKit/validation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TipContentProps } from './types';
|
|
2
2
|
|
|
3
3
|
export function validateTipId(tipId: string): void {
|
|
4
4
|
if (typeof tipId !== 'string' || tipId.trim().length === 0) {
|
|
@@ -6,10 +6,13 @@ export function validateTipId(tipId: string): void {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function validateTip(
|
|
9
|
+
export function validateTip(
|
|
10
|
+
props: TipContentProps,
|
|
11
|
+
component = 'TipKit.Popover'
|
|
12
|
+
): void {
|
|
10
13
|
validateTipId(props.tipId);
|
|
11
14
|
if (typeof props.title !== 'string' || props.title.trim().length === 0) {
|
|
12
|
-
throw new Error(
|
|
15
|
+
throw new Error(`[TinyUI] ${component} title must be a nonempty string.`);
|
|
13
16
|
}
|
|
14
17
|
if (
|
|
15
18
|
props.maxDisplayCount !== undefined &&
|
|
@@ -18,7 +21,7 @@ export function validateTip(props: TipPopoverProps): void {
|
|
|
18
21
|
props.maxDisplayCount > 2147483647)
|
|
19
22
|
) {
|
|
20
23
|
throw new Error(
|
|
21
|
-
|
|
24
|
+
`[TinyUI] ${component} maxDisplayCount must be a positive 32-bit integer.`
|
|
22
25
|
);
|
|
23
26
|
}
|
|
24
27
|
const ids = new Set<string>();
|
|
@@ -31,7 +34,7 @@ export function validateTip(props: TipPopoverProps): void {
|
|
|
31
34
|
ids.has(action.id)
|
|
32
35
|
) {
|
|
33
36
|
throw new Error(
|
|
34
|
-
|
|
37
|
+
`[TinyUI] ${component} actions need unique nonempty ids and nonempty titles.`
|
|
35
38
|
);
|
|
36
39
|
}
|
|
37
40
|
ids.add(action.id);
|