@nstudio/nativescript-effect-ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/crash/index.d.ts +49 -0
- package/dist/crash/index.d.ts.map +1 -0
- package/dist/crash/index.js +199 -0
- package/dist/crash/index.js.map +1 -0
- package/dist/devtools/index.d.ts +77 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/index.js +158 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard/index.d.ts +97 -0
- package/dist/keyboard/index.d.ts.map +1 -0
- package/dist/keyboard/index.js +226 -0
- package/dist/keyboard/index.js.map +1 -0
- package/dist/list/index.d.ts +91 -0
- package/dist/list/index.d.ts.map +1 -0
- package/dist/list/index.js +192 -0
- package/dist/list/index.js.map +1 -0
- package/dist/macos/MacosHost.d.ts +77 -0
- package/dist/macos/MacosHost.d.ts.map +1 -0
- package/dist/macos/MacosHost.js +878 -0
- package/dist/macos/MacosHost.js.map +1 -0
- package/dist/macos/index.d.ts +5 -0
- package/dist/macos/index.d.ts.map +1 -0
- package/dist/macos/index.js +5 -0
- package/dist/macos/index.js.map +1 -0
- package/dist/macos/layout.d.ts +39 -0
- package/dist/macos/layout.d.ts.map +1 -0
- package/dist/macos/layout.js +226 -0
- package/dist/macos/layout.js.map +1 -0
- package/dist/macos/platform.d.ts +12 -0
- package/dist/macos/platform.d.ts.map +1 -0
- package/dist/macos/platform.js +103 -0
- package/dist/macos/platform.js.map +1 -0
- package/dist/macos/styles.d.ts +66 -0
- package/dist/macos/styles.d.ts.map +1 -0
- package/dist/macos/styles.js +350 -0
- package/dist/macos/styles.js.map +1 -0
- package/dist/mason/MasonHost.d.ts +102 -0
- package/dist/mason/MasonHost.d.ts.map +1 -0
- package/dist/mason/MasonHost.js +413 -0
- package/dist/mason/MasonHost.js.map +1 -0
- package/dist/mason/dialog.d.ts +23 -0
- package/dist/mason/dialog.d.ts.map +1 -0
- package/dist/mason/dialog.js +186 -0
- package/dist/mason/dialog.js.map +1 -0
- package/dist/mason/elements.d.ts +50 -0
- package/dist/mason/elements.d.ts.map +1 -0
- package/dist/mason/elements.js +194 -0
- package/dist/mason/elements.js.map +1 -0
- package/dist/mason/events.d.ts +37 -0
- package/dist/mason/events.d.ts.map +1 -0
- package/dist/mason/events.js +304 -0
- package/dist/mason/events.js.map +1 -0
- package/dist/mason/index.d.ts +6 -0
- package/dist/mason/index.d.ts.map +1 -0
- package/dist/mason/index.js +6 -0
- package/dist/mason/index.js.map +1 -0
- package/dist/mason/services.d.ts +36 -0
- package/dist/mason/services.d.ts.map +1 -0
- package/dist/mason/services.js +268 -0
- package/dist/mason/services.js.map +1 -0
- package/dist/mason/styles.d.ts +20 -0
- package/dist/mason/styles.d.ts.map +1 -0
- package/dist/mason/styles.js +269 -0
- package/dist/mason/styles.js.map +1 -0
- package/dist/motion/index.d.ts +179 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +332 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/native/Native.d.ts +163 -0
- package/dist/native/Native.d.ts.map +1 -0
- package/dist/native/Native.js +144 -0
- package/dist/native/Native.js.map +1 -0
- package/dist/native/NativeCommand.d.ts +36 -0
- package/dist/native/NativeCommand.d.ts.map +1 -0
- package/dist/native/NativeCommand.js +38 -0
- package/dist/native/NativeCommand.js.map +1 -0
- package/dist/native/NativeHost.d.ts +46 -0
- package/dist/native/NativeHost.d.ts.map +1 -0
- package/dist/native/NativeHost.js +346 -0
- package/dist/native/NativeHost.js.map +1 -0
- package/dist/native/index.d.ts +4 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +4 -0
- package/dist/native/index.js.map +1 -0
- package/dist/platform/index.d.ts +86 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +131 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/native.d.ts +12 -0
- package/dist/platform/native.d.ts.map +1 -0
- package/dist/platform/native.js +127 -0
- package/dist/platform/native.js.map +1 -0
- package/dist/sheet/index.d.ts +113 -0
- package/dist/sheet/index.d.ts.map +1 -0
- package/dist/sheet/index.js +202 -0
- package/dist/sheet/index.js.map +1 -0
- package/dist/testing/MockMasonHost.d.ts +48 -0
- package/dist/testing/MockMasonHost.d.ts.map +1 -0
- package/dist/testing/MockMasonHost.js +142 -0
- package/dist/testing/MockMasonHost.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +116 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeScript implementations of the platform Effect services (`Haptics`,
|
|
3
|
+
* `DeviceInfo`, `AppLifecycle`, `Clipboard`) using direct iOS & Android native
|
|
4
|
+
* APIs: zero third-party native plugins required.
|
|
5
|
+
*/
|
|
6
|
+
import { Application, Device, isAndroid, isIOS, Utils } from '@nativescript/core';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import { AppLifecycle, Clipboard, DeviceInfo, Haptics, } from './index.js';
|
|
10
|
+
// Lazily instantiated iOS feedback generators (reused across calls).
|
|
11
|
+
let iosSelection = null;
|
|
12
|
+
let iosLight = null;
|
|
13
|
+
let iosMedium = null;
|
|
14
|
+
let iosNotify = null;
|
|
15
|
+
function androidVibrate(ms, amplitude = 80) {
|
|
16
|
+
try {
|
|
17
|
+
const ctx = Utils.android.getApplicationContext();
|
|
18
|
+
const vibrator = ctx?.getSystemService(android.content.Context.VIBRATOR_SERVICE);
|
|
19
|
+
if (vibrator?.hasVibrator()) {
|
|
20
|
+
vibrator.vibrate(android.os.VibrationEffect.createOneShot(ms, amplitude));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Ignore missing VIBRATE permission or emulator without vibrator.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Numeric constants for iOS UIKit feedback enums (avoids ambient const-enum access under isolatedModules/verbatimModuleSyntax).
|
|
28
|
+
const IOS_IMPACT_LIGHT = 0;
|
|
29
|
+
const IOS_IMPACT_MEDIUM = 1;
|
|
30
|
+
const IOS_NOTIFICATION_SUCCESS = 0;
|
|
31
|
+
const IOS_NOTIFICATION_WARNING = 1;
|
|
32
|
+
const IOS_NOTIFICATION_ERROR = 2;
|
|
33
|
+
function triggerNativeHaptic(style) {
|
|
34
|
+
try {
|
|
35
|
+
if (isIOS) {
|
|
36
|
+
switch (style) {
|
|
37
|
+
case 'tick':
|
|
38
|
+
(iosSelection ??= UISelectionFeedbackGenerator.new()).selectionChanged();
|
|
39
|
+
return;
|
|
40
|
+
case 'tap':
|
|
41
|
+
(iosLight ??= UIImpactFeedbackGenerator.alloc().initWithStyle(IOS_IMPACT_LIGHT)).impactOccurred();
|
|
42
|
+
return;
|
|
43
|
+
case 'thud':
|
|
44
|
+
(iosMedium ??= UIImpactFeedbackGenerator.alloc().initWithStyle(IOS_IMPACT_MEDIUM)).impactOccurred();
|
|
45
|
+
return;
|
|
46
|
+
case 'success':
|
|
47
|
+
(iosNotify ??= UINotificationFeedbackGenerator.new()).notificationOccurred(IOS_NOTIFICATION_SUCCESS);
|
|
48
|
+
return;
|
|
49
|
+
case 'warning':
|
|
50
|
+
(iosNotify ??= UINotificationFeedbackGenerator.new()).notificationOccurred(IOS_NOTIFICATION_WARNING);
|
|
51
|
+
return;
|
|
52
|
+
case 'error':
|
|
53
|
+
(iosNotify ??= UINotificationFeedbackGenerator.new()).notificationOccurred(IOS_NOTIFICATION_ERROR);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (isAndroid) {
|
|
58
|
+
switch (style) {
|
|
59
|
+
case 'tick':
|
|
60
|
+
androidVibrate(8, 40);
|
|
61
|
+
return;
|
|
62
|
+
case 'tap':
|
|
63
|
+
androidVibrate(12, 80);
|
|
64
|
+
return;
|
|
65
|
+
case 'thud':
|
|
66
|
+
androidVibrate(24, 150);
|
|
67
|
+
return;
|
|
68
|
+
case 'success':
|
|
69
|
+
androidVibrate(36, 200);
|
|
70
|
+
return;
|
|
71
|
+
case 'warning':
|
|
72
|
+
androidVibrate(28, 170);
|
|
73
|
+
return;
|
|
74
|
+
case 'error':
|
|
75
|
+
androidVibrate(50, 220);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Simulator / unavailable native haptic engine.
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export const HapticsNativeLayer = Layer.succeed(Haptics, Haptics.make((style) => Effect.sync(() => triggerNativeHaptic(style))));
|
|
85
|
+
export const DeviceInfoNativeLayer = Layer.sync(DeviceInfo, () => ({
|
|
86
|
+
info: {
|
|
87
|
+
platform: (isIOS ? 'ios' : isAndroid ? 'android' : 'ios'),
|
|
88
|
+
host: 'mason',
|
|
89
|
+
osVersion: `${Device.os} ${Device.osVersion}`,
|
|
90
|
+
model: Device.model || (isIOS ? 'iPhone (MasonHost)' : 'Android (MasonHost)'),
|
|
91
|
+
isNative: true,
|
|
92
|
+
},
|
|
93
|
+
}));
|
|
94
|
+
export const AppLifecycleNativeLayer = Layer.succeed(AppLifecycle, {
|
|
95
|
+
appearance: Effect.sync(() => Application.systemAppearance?.() === 'dark' ? 'dark' : 'light'),
|
|
96
|
+
state: Effect.sync(() => (Application.inBackground ? 'background' : 'active')),
|
|
97
|
+
});
|
|
98
|
+
export const ClipboardNativeLayer = Layer.succeed(Clipboard, {
|
|
99
|
+
copy: (text) => Effect.sync(() => {
|
|
100
|
+
if (isIOS) {
|
|
101
|
+
UIPasteboard.generalPasteboard.string = text;
|
|
102
|
+
}
|
|
103
|
+
else if (isAndroid) {
|
|
104
|
+
const ctx = Utils.android.getApplicationContext();
|
|
105
|
+
const mgr = ctx?.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
|
|
106
|
+
mgr?.setPrimaryClip(android.content.ClipData.newPlainText('text', text));
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
read: Effect.sync(() => {
|
|
110
|
+
if (isIOS) {
|
|
111
|
+
return UIPasteboard.generalPasteboard.string ?? '';
|
|
112
|
+
}
|
|
113
|
+
if (isAndroid) {
|
|
114
|
+
const ctx = Utils.android.getApplicationContext();
|
|
115
|
+
const mgr = ctx?.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
|
|
116
|
+
const item = mgr?.getPrimaryClip()?.getItemAt(0);
|
|
117
|
+
return item?.getText()?.toString() ?? '';
|
|
118
|
+
}
|
|
119
|
+
return '';
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
/**
|
|
123
|
+
* Combined NativeScript Layer providing `Haptics`, `DeviceInfo`, `AppLifecycle`,
|
|
124
|
+
* and `Clipboard` using direct iOS & Android APIs.
|
|
125
|
+
*/
|
|
126
|
+
export const NativePlatformLayer = Layer.mergeAll(HapticsNativeLayer, DeviceInfoNativeLayer, AppLifecycleNativeLayer, ClipboardNativeLayer);
|
|
127
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/platform/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,UAAU,EACV,OAAO,GAER,MAAM,YAAY,CAAC;AAEpB,qEAAqE;AACrE,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**
|
|
2
|
+
* Native OS bottom sheets for `@nstudio/nativescript-effect-ui`: zero plugins.
|
|
3
|
+
*
|
|
4
|
+
* - **iOS:** Configures real `UISheetPresentationController` (`medium` / `large`
|
|
5
|
+
* detents, native drag grabber, corner radius, interactive undimmed backdrop
|
|
6
|
+
* option, and transparent Liquid Glass passthrough on iOS 26+).
|
|
7
|
+
* - **Android:** Presents a bottom-docked rounded Material sheet modal with
|
|
8
|
+
* scrim tap and hardware back dismissal.
|
|
9
|
+
* - **HTML `<dialog>` integration:** `MasonHost` automatically uses this
|
|
10
|
+
* presenter whenever a `<dialog>` sets `data-presentation="sheet"`.
|
|
11
|
+
*/
|
|
12
|
+
import * as Command from '@effect/ui/Command';
|
|
13
|
+
import * as Component from '@effect/ui/Component';
|
|
14
|
+
import * as Context from 'effect/Context';
|
|
15
|
+
import * as Effect from 'effect/Effect';
|
|
16
|
+
import * as Layer from 'effect/Layer';
|
|
17
|
+
import * as Schema from 'effect/Schema';
|
|
18
|
+
export declare const SheetDetent: Schema.Literals<readonly ["medium", "large"]>;
|
|
19
|
+
export type SheetDetent = typeof SheetDetent.Type;
|
|
20
|
+
export declare const SheetOptionsSchema: Schema.Struct<{
|
|
21
|
+
readonly detents: Schema.optional<Schema.$Array<Schema.Literals<readonly ["medium", "large"]>>>;
|
|
22
|
+
readonly grabber: Schema.optional<Schema.Boolean>;
|
|
23
|
+
readonly cornerRadius: Schema.optional<Schema.Number>;
|
|
24
|
+
readonly undimmedMedium: Schema.optional<Schema.Boolean>;
|
|
25
|
+
readonly dismissable: Schema.optional<Schema.Boolean>;
|
|
26
|
+
}>;
|
|
27
|
+
export type SheetOptions = typeof SheetOptionsSchema.Type;
|
|
28
|
+
/**
|
|
29
|
+
* Configures an already-presented NativeScript modal view as a native iOS
|
|
30
|
+
* `UISheetPresentationController` (with Liquid Glass passthrough on iOS 26+).
|
|
31
|
+
*/
|
|
32
|
+
export declare function configureIOSSheetController(modalRoot: unknown, options?: SheetOptions | undefined): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Configures an already-presented NativeScript Android DialogFragment window as
|
|
35
|
+
* a bottom-docked rounded sheet.
|
|
36
|
+
*/
|
|
37
|
+
export declare function configureAndroidSheetWindow(modalRoot: unknown, options?: SheetOptions | undefined): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Parses `data-detents="medium,large"` and `data-grabber` attributes from an
|
|
40
|
+
* HTML `<dialog data-presentation="sheet">` element.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseSheetOptionsFromAttributes(attrs: Readonly<Record<string, string | undefined>>): SheetOptions;
|
|
43
|
+
export interface SheetEvent {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly action: 'open' | 'close';
|
|
46
|
+
readonly options?: SheetOptions | undefined;
|
|
47
|
+
}
|
|
48
|
+
export interface SheetServiceShape {
|
|
49
|
+
readonly open: (id: string, options?: SheetOptions) => Effect.Effect<void>;
|
|
50
|
+
readonly close: (id: string) => Effect.Effect<void>;
|
|
51
|
+
}
|
|
52
|
+
declare const SheetService_base: Context.ServiceClass<SheetService, "@nstudio/nativescript-effect-ui/SheetService", SheetServiceShape>;
|
|
53
|
+
/**
|
|
54
|
+
* Injectable Effect service for imperative native sheet presentation & testing.
|
|
55
|
+
*/
|
|
56
|
+
export declare class SheetService extends SheetService_base {
|
|
57
|
+
}
|
|
58
|
+
declare const OpenSheet_base: Command.Service<OpenSheet, "NativeSheet/Open", {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly options?: {
|
|
61
|
+
readonly detents?: readonly ("medium" | "large")[] | undefined;
|
|
62
|
+
readonly grabber?: boolean | undefined;
|
|
63
|
+
readonly cornerRadius?: number | undefined;
|
|
64
|
+
readonly undimmedMedium?: boolean | undefined;
|
|
65
|
+
readonly dismissable?: boolean | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
}, Component.NoopSchema, false, Schema.Never, never>;
|
|
68
|
+
export declare class OpenSheet extends OpenSheet_base {
|
|
69
|
+
static readonly layer: Layer.Layer<OpenSheet, never, SheetService>;
|
|
70
|
+
}
|
|
71
|
+
declare const CloseSheet_base: Command.Service<CloseSheet, "NativeSheet/Close", {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
}, Component.NoopSchema, false, Schema.Never, never>;
|
|
74
|
+
export declare class CloseSheet extends CloseSheet_base {
|
|
75
|
+
static readonly layer: Layer.Layer<CloseSheet, never, SheetService>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Deterministic in-memory `SheetService` for Node Vitest suites.
|
|
79
|
+
*/
|
|
80
|
+
export declare function makeTestSheetLayer(): {
|
|
81
|
+
readonly layer: Layer.Layer<SheetService>;
|
|
82
|
+
readonly events: Array<SheetEvent>;
|
|
83
|
+
readonly openIds: Set<string>;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Presents an arbitrary NativeScript `View` inside a native OS bottom sheet
|
|
87
|
+
* (`UISheetPresentationController` on iOS, bottom-docked sheet on Android).
|
|
88
|
+
*/
|
|
89
|
+
export declare function presentNativeSheet(presenter: {
|
|
90
|
+
showModal: (view: unknown, opts: Record<string, unknown>) => void;
|
|
91
|
+
}, contentView: unknown, options?: SheetOptions & {
|
|
92
|
+
readonly onClose?: () => void;
|
|
93
|
+
}): void;
|
|
94
|
+
export declare const NativeSheet: {
|
|
95
|
+
readonly SheetDetent: Schema.Literals<readonly ["medium", "large"]>;
|
|
96
|
+
readonly SheetOptionsSchema: Schema.Struct<{
|
|
97
|
+
readonly detents: Schema.optional<Schema.$Array<Schema.Literals<readonly ["medium", "large"]>>>;
|
|
98
|
+
readonly grabber: Schema.optional<Schema.Boolean>;
|
|
99
|
+
readonly cornerRadius: Schema.optional<Schema.Number>;
|
|
100
|
+
readonly undimmedMedium: Schema.optional<Schema.Boolean>;
|
|
101
|
+
readonly dismissable: Schema.optional<Schema.Boolean>;
|
|
102
|
+
}>;
|
|
103
|
+
readonly SheetService: typeof SheetService;
|
|
104
|
+
readonly OpenSheet: typeof OpenSheet;
|
|
105
|
+
readonly CloseSheet: typeof CloseSheet;
|
|
106
|
+
readonly configureIOSSheetController: typeof configureIOSSheetController;
|
|
107
|
+
readonly configureAndroidSheetWindow: typeof configureAndroidSheetWindow;
|
|
108
|
+
readonly parseSheetOptionsFromAttributes: typeof parseSheetOptionsFromAttributes;
|
|
109
|
+
readonly presentNativeSheet: typeof presentNativeSheet;
|
|
110
|
+
readonly makeTestSheetLayer: typeof makeTestSheetLayer;
|
|
111
|
+
};
|
|
112
|
+
export {};
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sheet/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,WAAW,+CAAuC,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAElD,eAAO,MAAM,kBAAkB;;;;;;EAM7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAI1D;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,GACjC,OAAO,CAkDT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,GACjC,OAAO,CA6BT;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,KA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,OAAO,EACpB,OAAO,CAAC,EAAE,YAAY,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,GACzD,IAAI,CAyBN;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;CAWd,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native OS bottom sheets for `@nstudio/nativescript-effect-ui`: zero plugins.
|
|
3
|
+
*
|
|
4
|
+
* - **iOS:** Configures real `UISheetPresentationController` (`medium` / `large`
|
|
5
|
+
* detents, native drag grabber, corner radius, interactive undimmed backdrop
|
|
6
|
+
* option, and transparent Liquid Glass passthrough on iOS 26+).
|
|
7
|
+
* - **Android:** Presents a bottom-docked rounded Material sheet modal with
|
|
8
|
+
* scrim tap and hardware back dismissal.
|
|
9
|
+
* - **HTML `<dialog>` integration:** `MasonHost` automatically uses this
|
|
10
|
+
* presenter whenever a `<dialog>` sets `data-presentation="sheet"`.
|
|
11
|
+
*/
|
|
12
|
+
import * as Command from '@effect/ui/Command';
|
|
13
|
+
import * as Component from '@effect/ui/Component';
|
|
14
|
+
import * as Context from 'effect/Context';
|
|
15
|
+
import * as Effect from 'effect/Effect';
|
|
16
|
+
import * as Layer from 'effect/Layer';
|
|
17
|
+
import * as Schema from 'effect/Schema';
|
|
18
|
+
export const SheetDetent = Schema.Literals(['medium', 'large']);
|
|
19
|
+
export const SheetOptionsSchema = Schema.Struct({
|
|
20
|
+
detents: Schema.optional(Schema.Array(SheetDetent)),
|
|
21
|
+
grabber: Schema.optional(Schema.Boolean),
|
|
22
|
+
cornerRadius: Schema.optional(Schema.Number),
|
|
23
|
+
undimmedMedium: Schema.optional(Schema.Boolean),
|
|
24
|
+
dismissable: Schema.optional(Schema.Boolean),
|
|
25
|
+
});
|
|
26
|
+
const IOS_PAGE_SHEET = 1; // UIModalPresentationStyle.PageSheet
|
|
27
|
+
/**
|
|
28
|
+
* Configures an already-presented NativeScript modal view as a native iOS
|
|
29
|
+
* `UISheetPresentationController` (with Liquid Glass passthrough on iOS 26+).
|
|
30
|
+
*/
|
|
31
|
+
export function configureIOSSheetController(modalRoot, options) {
|
|
32
|
+
if (typeof __APPLE__ === 'undefined' || !__APPLE__)
|
|
33
|
+
return false;
|
|
34
|
+
try {
|
|
35
|
+
const view = modalRoot;
|
|
36
|
+
const vc = view.viewController ?? view.page?.ios;
|
|
37
|
+
if (!vc)
|
|
38
|
+
return false;
|
|
39
|
+
vc.modalPresentationStyle = IOS_PAGE_SHEET;
|
|
40
|
+
const sheet = vc.sheetPresentationController ?? vc.parentViewController?.sheetPresentationController;
|
|
41
|
+
if (!sheet)
|
|
42
|
+
return false;
|
|
43
|
+
const detentsSpec = options?.detents?.length ? options.detents : ['medium', 'large'];
|
|
44
|
+
const nativeDetents = NSMutableArray.array();
|
|
45
|
+
for (const d of detentsSpec) {
|
|
46
|
+
nativeDetents.addObject(d === 'medium'
|
|
47
|
+
? UISheetPresentationControllerDetent.mediumDetent()
|
|
48
|
+
: UISheetPresentationControllerDetent.largeDetent());
|
|
49
|
+
}
|
|
50
|
+
sheet.detents = nativeDetents;
|
|
51
|
+
sheet.prefersGrabberVisible = options?.grabber !== false;
|
|
52
|
+
sheet.prefersScrollingExpandsWhenScrolledToEdge = true;
|
|
53
|
+
sheet.preferredCornerRadius = options?.cornerRadius ?? 24;
|
|
54
|
+
if (options?.undimmedMedium) {
|
|
55
|
+
sheet.largestUndimmedDetentIdentifier = UISheetPresentationControllerDetentIdentifierMedium;
|
|
56
|
+
}
|
|
57
|
+
if (options?.dismissable === false) {
|
|
58
|
+
vc.modalInPresentation = true;
|
|
59
|
+
}
|
|
60
|
+
// iOS 26+ Liquid Glass: clear controller background so system glass shines through.
|
|
61
|
+
const majorVersion = Number.parseInt(String(UIDevice.currentDevice.systemVersion ?? '0').split('.')[0] ?? '0', 10);
|
|
62
|
+
if (majorVersion >= 26) {
|
|
63
|
+
if (vc.view)
|
|
64
|
+
vc.view.backgroundColor = UIColor.clearColor;
|
|
65
|
+
view.backgroundColor = 'transparent';
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Configures an already-presented NativeScript Android DialogFragment window as
|
|
75
|
+
* a bottom-docked rounded sheet.
|
|
76
|
+
*/
|
|
77
|
+
export function configureAndroidSheetWindow(modalRoot, options) {
|
|
78
|
+
if (typeof __ANDROID__ === 'undefined' || !__ANDROID__)
|
|
79
|
+
return false;
|
|
80
|
+
try {
|
|
81
|
+
const root = modalRoot;
|
|
82
|
+
const dialog = root._dialogFragment?.getDialog?.();
|
|
83
|
+
const win = dialog?.getWindow?.();
|
|
84
|
+
if (!win)
|
|
85
|
+
return false;
|
|
86
|
+
win.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
|
|
87
|
+
win.setGravity(android.view.Gravity.BOTTOM);
|
|
88
|
+
win.setLayout(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
89
|
+
if (options?.dismissable === false) {
|
|
90
|
+
dialog?.setCancelable(false);
|
|
91
|
+
dialog?.setCanceledOnTouchOutside(false);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parses `data-detents="medium,large"` and `data-grabber` attributes from an
|
|
101
|
+
* HTML `<dialog data-presentation="sheet">` element.
|
|
102
|
+
*/
|
|
103
|
+
export function parseSheetOptionsFromAttributes(attrs) {
|
|
104
|
+
const rawDetents = attrs['data-detents'];
|
|
105
|
+
const detents = rawDetents
|
|
106
|
+
? rawDetents
|
|
107
|
+
.split(',')
|
|
108
|
+
.map((s) => s.trim())
|
|
109
|
+
.filter((s) => s === 'medium' || s === 'large')
|
|
110
|
+
: ['medium', 'large'];
|
|
111
|
+
const cornerRadius = attrs['data-corner-radius']
|
|
112
|
+
? Number.parseFloat(attrs['data-corner-radius'])
|
|
113
|
+
: undefined;
|
|
114
|
+
return {
|
|
115
|
+
detents: detents.length > 0 ? detents : ['medium', 'large'],
|
|
116
|
+
grabber: attrs['data-grabber'] !== 'false',
|
|
117
|
+
cornerRadius: Number.isFinite(cornerRadius) ? cornerRadius : 24,
|
|
118
|
+
undimmedMedium: attrs['data-undimmed-medium'] === 'true',
|
|
119
|
+
dismissable: attrs['data-dismissable'] !== 'false',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Injectable Effect service for imperative native sheet presentation & testing.
|
|
124
|
+
*/
|
|
125
|
+
export class SheetService extends Context.Service()('@nstudio/nativescript-effect-ui/SheetService') {
|
|
126
|
+
}
|
|
127
|
+
export class OpenSheet extends Command.Service()('NativeSheet/Open', {
|
|
128
|
+
args: {
|
|
129
|
+
id: Schema.String,
|
|
130
|
+
options: Schema.optional(SheetOptionsSchema),
|
|
131
|
+
},
|
|
132
|
+
success: Component.Noop,
|
|
133
|
+
}) {
|
|
134
|
+
static layer = this.toLayer(Effect.gen(function* () {
|
|
135
|
+
const sheets = yield* SheetService;
|
|
136
|
+
return ({ id, options }) => sheets.open(id, options).pipe(Effect.as(Component.noop));
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
export class CloseSheet extends Command.Service()('NativeSheet/Close', {
|
|
140
|
+
args: { id: Schema.String },
|
|
141
|
+
success: Component.Noop,
|
|
142
|
+
}) {
|
|
143
|
+
static layer = this.toLayer(Effect.gen(function* () {
|
|
144
|
+
const sheets = yield* SheetService;
|
|
145
|
+
return ({ id }) => sheets.close(id).pipe(Effect.as(Component.noop));
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Deterministic in-memory `SheetService` for Node Vitest suites.
|
|
150
|
+
*/
|
|
151
|
+
export function makeTestSheetLayer() {
|
|
152
|
+
const events = [];
|
|
153
|
+
const openIds = new Set();
|
|
154
|
+
const layer = Layer.succeed(SheetService, {
|
|
155
|
+
open: (id, options) => Effect.sync(() => {
|
|
156
|
+
openIds.add(id);
|
|
157
|
+
events.push({ id, action: 'open', options });
|
|
158
|
+
}),
|
|
159
|
+
close: (id) => Effect.sync(() => {
|
|
160
|
+
openIds.delete(id);
|
|
161
|
+
events.push({ id, action: 'close' });
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
164
|
+
return { layer, events, openIds };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Presents an arbitrary NativeScript `View` inside a native OS bottom sheet
|
|
168
|
+
* (`UISheetPresentationController` on iOS, bottom-docked sheet on Android).
|
|
169
|
+
*/
|
|
170
|
+
export function presentNativeSheet(presenter, contentView, options) {
|
|
171
|
+
const root = contentView;
|
|
172
|
+
const applySheetConfig = () => {
|
|
173
|
+
setTimeout(() => {
|
|
174
|
+
configureIOSSheetController(root, options);
|
|
175
|
+
configureAndroidSheetWindow(root, options);
|
|
176
|
+
}, 0);
|
|
177
|
+
};
|
|
178
|
+
root.on?.('loaded', applySheetConfig);
|
|
179
|
+
root.on?.('showingModally', applySheetConfig);
|
|
180
|
+
root.on?.('shownModally', applySheetConfig);
|
|
181
|
+
presenter.showModal(root, {
|
|
182
|
+
context: null,
|
|
183
|
+
closeCallback: () => options?.onClose?.(),
|
|
184
|
+
fullscreen: false,
|
|
185
|
+
animated: true,
|
|
186
|
+
cancelable: options?.dismissable !== false,
|
|
187
|
+
ios: { presentationStyle: IOS_PAGE_SHEET },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
export const NativeSheet = {
|
|
191
|
+
SheetDetent,
|
|
192
|
+
SheetOptionsSchema,
|
|
193
|
+
SheetService,
|
|
194
|
+
OpenSheet,
|
|
195
|
+
CloseSheet,
|
|
196
|
+
configureIOSSheetController,
|
|
197
|
+
configureAndroidSheetWindow,
|
|
198
|
+
parseSheetOptionsFromAttributes,
|
|
199
|
+
presentNativeSheet,
|
|
200
|
+
makeTestSheetLayer,
|
|
201
|
+
};
|
|
202
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sheet/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAGhE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnD,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;CAC7C,CAAC,CAAC;AAGH,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,qCAAqC;AAE/D;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAAkB,EAClB,OAAkC;IAElC,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS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E,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,EAAE,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAE5C,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE;QACxB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACzC,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,OAAO,EAAE,WAAW,KAAK,KAAK;QAC1C,GAAG,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE;KAC3C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW;IACX,kBAAkB;IAClB,YAAY;IACZ,SAAS;IACT,UAAU;IACV,2BAA2B;IAC3B,2BAA2B;IAC3B,+BAA+B;IAC/B,kBAAkB;IAClB,kBAAkB;CACV,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { DialogPresenter } from '../mason/dialog.js';
|
|
2
|
+
type Listener = (event?: Record<string, unknown>) => void;
|
|
3
|
+
export interface MockMasonView {
|
|
4
|
+
readonly tag: string;
|
|
5
|
+
readonly cssType: string;
|
|
6
|
+
readonly nativeChildren: Array<unknown>;
|
|
7
|
+
readonly style: Record<string, unknown>;
|
|
8
|
+
readonly pseudoClasses: Set<string>;
|
|
9
|
+
readonly listeners: Map<string, Array<Listener>>;
|
|
10
|
+
className: string;
|
|
11
|
+
id: string;
|
|
12
|
+
visibility: string;
|
|
13
|
+
isEnabled: boolean;
|
|
14
|
+
value: string;
|
|
15
|
+
checked: boolean;
|
|
16
|
+
open: boolean;
|
|
17
|
+
placeholder: string;
|
|
18
|
+
type: string;
|
|
19
|
+
name: string;
|
|
20
|
+
cssStateChanges: number;
|
|
21
|
+
insertBefore: (child: unknown, ref: unknown) => void;
|
|
22
|
+
addChild: (child: unknown) => void;
|
|
23
|
+
removeChild: (child: unknown) => void;
|
|
24
|
+
on: (event: string, listener: Listener) => void;
|
|
25
|
+
off: (event: string, listener: Listener) => void;
|
|
26
|
+
emit: (event: string, payload?: Record<string, unknown>) => void;
|
|
27
|
+
addSinglePseudoClass: (name: string) => void;
|
|
28
|
+
deleteSinglePseudoClass: (name: string) => void;
|
|
29
|
+
_onCssStateChange: () => void;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
export declare function createMockMasonView(tag: string): MockMasonView;
|
|
33
|
+
export interface MockDialogRecord {
|
|
34
|
+
readonly dialog: MockMasonView;
|
|
35
|
+
readonly mode: 'modal' | boolean;
|
|
36
|
+
readonly onCancel: () => void;
|
|
37
|
+
readonly onClose: () => void;
|
|
38
|
+
}
|
|
39
|
+
export declare function createMockDialogPresenter(): {
|
|
40
|
+
readonly presenter: DialogPresenter;
|
|
41
|
+
readonly openDialogs: Map<MockMasonView, MockDialogRecord>;
|
|
42
|
+
};
|
|
43
|
+
/** Collects visible text from a MockMasonView subtree for assertions. */
|
|
44
|
+
export declare function textContentOf(node: unknown): string;
|
|
45
|
+
/** Depth-first query helper over a MockMasonView subtree. */
|
|
46
|
+
export declare function findViews(root: MockMasonView, predicate: (view: MockMasonView) => boolean): Array<MockMasonView>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=MockMasonHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockMasonHost.d.ts","sourceRoot":"","sources":["../../src/testing/MockMasonHost.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,KAAK,QAAQ,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC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AE,MAAM,KAAK,IAAI,CAAC;IAC7C,uBAAuB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAuF9D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,wBAAgB,yBAAyB,IAAI;IAC3C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;CAC5D,CA2BA;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAMnD;AAED,6DAA6D;AAC7D,wBAAgB,SAAS,CACvB,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,GAC1C,KAAK,CAAC,aAAa,CAAC,CAYtB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { setTagName } from '../mason/elements.js';
|
|
2
|
+
export function createMockMasonView(tag) {
|
|
3
|
+
const lower = tag.toLowerCase();
|
|
4
|
+
const nativeChildren = [];
|
|
5
|
+
const listeners = new Map();
|
|
6
|
+
const pseudoClasses = new Set();
|
|
7
|
+
const view = {
|
|
8
|
+
tag: lower,
|
|
9
|
+
cssType: lower,
|
|
10
|
+
nativeChildren,
|
|
11
|
+
style: {},
|
|
12
|
+
pseudoClasses,
|
|
13
|
+
listeners,
|
|
14
|
+
className: '',
|
|
15
|
+
id: '',
|
|
16
|
+
visibility: 'visible',
|
|
17
|
+
isEnabled: true,
|
|
18
|
+
value: '',
|
|
19
|
+
checked: false,
|
|
20
|
+
open: false,
|
|
21
|
+
placeholder: '',
|
|
22
|
+
type: lower === 'button' ? 'submit' : 'text',
|
|
23
|
+
name: '',
|
|
24
|
+
cssStateChanges: 0,
|
|
25
|
+
insertBefore(child, ref) {
|
|
26
|
+
const existing = nativeChildren.indexOf(child);
|
|
27
|
+
if (existing >= 0)
|
|
28
|
+
nativeChildren.splice(existing, 1);
|
|
29
|
+
if (ref == null) {
|
|
30
|
+
nativeChildren.push(child);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const idx = nativeChildren.indexOf(ref);
|
|
34
|
+
if (idx < 0)
|
|
35
|
+
nativeChildren.push(child);
|
|
36
|
+
else
|
|
37
|
+
nativeChildren.splice(idx, 0, child);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
addChild(child) {
|
|
41
|
+
const existing = nativeChildren.indexOf(child);
|
|
42
|
+
if (existing >= 0)
|
|
43
|
+
nativeChildren.splice(existing, 1);
|
|
44
|
+
nativeChildren.push(child);
|
|
45
|
+
},
|
|
46
|
+
removeChild(child) {
|
|
47
|
+
const idx = nativeChildren.indexOf(child);
|
|
48
|
+
if (idx >= 0)
|
|
49
|
+
nativeChildren.splice(idx, 1);
|
|
50
|
+
},
|
|
51
|
+
on(event, listener) {
|
|
52
|
+
let list = listeners.get(event);
|
|
53
|
+
if (!list) {
|
|
54
|
+
list = [];
|
|
55
|
+
listeners.set(event, list);
|
|
56
|
+
}
|
|
57
|
+
list.push(listener);
|
|
58
|
+
},
|
|
59
|
+
off(event, listener) {
|
|
60
|
+
const list = listeners.get(event);
|
|
61
|
+
if (!list)
|
|
62
|
+
return;
|
|
63
|
+
const idx = list.indexOf(listener);
|
|
64
|
+
if (idx >= 0)
|
|
65
|
+
list.splice(idx, 1);
|
|
66
|
+
},
|
|
67
|
+
emit(event, payload) {
|
|
68
|
+
const list = listeners.get(event);
|
|
69
|
+
if (!list)
|
|
70
|
+
return;
|
|
71
|
+
for (const fn of [...list]) {
|
|
72
|
+
fn(payload);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
addSinglePseudoClass(name) {
|
|
76
|
+
pseudoClasses.add(name);
|
|
77
|
+
},
|
|
78
|
+
deleteSinglePseudoClass(name) {
|
|
79
|
+
pseudoClasses.delete(name);
|
|
80
|
+
},
|
|
81
|
+
_onCssStateChange() {
|
|
82
|
+
view.cssStateChanges++;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
setTagName(view, lower);
|
|
86
|
+
return view;
|
|
87
|
+
}
|
|
88
|
+
export function createMockDialogPresenter() {
|
|
89
|
+
const openDialogs = new Map();
|
|
90
|
+
const presenter = {
|
|
91
|
+
sync(dialog, desired, callbacks) {
|
|
92
|
+
const mock = dialog;
|
|
93
|
+
const wantOpen = desired === 'modal' || desired === true;
|
|
94
|
+
if (wantOpen) {
|
|
95
|
+
openDialogs.set(mock, {
|
|
96
|
+
dialog: mock,
|
|
97
|
+
mode: desired,
|
|
98
|
+
onCancel: callbacks.onCancel,
|
|
99
|
+
onClose: callbacks.onClose,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
openDialogs.delete(mock);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
dispose(dialog) {
|
|
107
|
+
openDialogs.delete(dialog);
|
|
108
|
+
},
|
|
109
|
+
disposeAll() {
|
|
110
|
+
openDialogs.clear();
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
return { presenter, openDialogs };
|
|
114
|
+
}
|
|
115
|
+
/** Collects visible text from a MockMasonView subtree for assertions. */
|
|
116
|
+
export function textContentOf(node) {
|
|
117
|
+
if (!node || typeof node !== 'object')
|
|
118
|
+
return '';
|
|
119
|
+
const n = node;
|
|
120
|
+
if (n['nodeType'] === 3)
|
|
121
|
+
return String(n['data'] ?? '');
|
|
122
|
+
const children = Array.isArray(n['nativeChildren']) ? n['nativeChildren'] : [];
|
|
123
|
+
return children.map(textContentOf).join('');
|
|
124
|
+
}
|
|
125
|
+
/** Depth-first query helper over a MockMasonView subtree. */
|
|
126
|
+
export function findViews(root, predicate) {
|
|
127
|
+
const out = [];
|
|
128
|
+
const visit = (node) => {
|
|
129
|
+
if (!node || typeof node !== 'object')
|
|
130
|
+
return;
|
|
131
|
+
const v = node;
|
|
132
|
+
if (typeof v.tag === 'string') {
|
|
133
|
+
if (predicate(v))
|
|
134
|
+
out.push(v);
|
|
135
|
+
for (const child of v.nativeChildren)
|
|
136
|
+
visit(child);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
visit(root);
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=MockMasonHost.js.map
|