@code-id-labs/composables 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +967 -0
- package/dist/index.d.cts +328 -0
- package/dist/index.d.ts +328 -0
- package/dist/index.js +964 -0
- package/package.json +41 -3
- package/README.md +0 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
//#region ../utils/dist/dom.d.ts
|
|
2
|
+
//#region src/dom.d.ts
|
|
3
|
+
type MiniAppRect = WechatMiniprogram.BoundingClientRectCallbackResult;
|
|
4
|
+
type MiniAppScrollOffset = WechatMiniprogram.ScrollOffsetCallbackResult;
|
|
5
|
+
type MiniAppNodeFields = WechatMiniprogram.IAnyObject;
|
|
6
|
+
type MiniAppComponent = WechatMiniprogram.Component.TrivialInstance;
|
|
7
|
+
interface DOMQueryHelpers {
|
|
8
|
+
query: () => WechatMiniprogram.SelectorQuery;
|
|
9
|
+
rect: (selector: string) => Promise<MiniAppRect | null>;
|
|
10
|
+
allRects: (selector: string) => Promise<MiniAppRect[]>;
|
|
11
|
+
scrollOffset: (selector: string) => Promise<MiniAppScrollOffset | null>;
|
|
12
|
+
viewportScrollOffset: () => Promise<MiniAppScrollOffset | null>;
|
|
13
|
+
fields: (selector: string, fields: WechatMiniprogram.Fields) => Promise<MiniAppNodeFields | null>;
|
|
14
|
+
computedStyle: (selector: string, properties: string[]) => Promise<Record<string, string> | null>;
|
|
15
|
+
animationDuration: (selector: string) => Promise<number>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ../core/dist/icons-CGWn5Sxv.d.ts
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/types.d.ts
|
|
21
|
+
type Dict$1 = Record<string, any>;
|
|
22
|
+
interface Scope {
|
|
23
|
+
id?: string | undefined;
|
|
24
|
+
ids?: Record<string, any> | undefined;
|
|
25
|
+
/** The component/page instance used to scope SelectorQuery */
|
|
26
|
+
component?: MiniAppComponent | undefined;
|
|
27
|
+
/** Optional DOM query helpers (use tree-shakeable queryRect/queryFields from @code-id-labs/utils directly) */
|
|
28
|
+
dom?: DOMQueryHelpers | undefined;
|
|
29
|
+
toJSON?: () => {
|
|
30
|
+
id?: string | undefined;
|
|
31
|
+
ids?: Record<string, any> | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
}
|
|
34
|
+
interface PropFn<T extends Dict$1> {
|
|
35
|
+
<K extends keyof T["props"]>(key: K): T["props"][K];
|
|
36
|
+
}
|
|
37
|
+
interface ComputedFn<T extends Dict$1> {
|
|
38
|
+
<K extends keyof T["computed"]>(key: K): T["computed"][K];
|
|
39
|
+
}
|
|
40
|
+
type ValueOrFn<T> = T | ((prev: T) => T);
|
|
41
|
+
interface Bindable<T> {
|
|
42
|
+
initial: T | undefined;
|
|
43
|
+
ref: any;
|
|
44
|
+
get: () => T;
|
|
45
|
+
set(value: ValueOrFn<T>): void;
|
|
46
|
+
invoke(nextValue: T, prevValue: T): void;
|
|
47
|
+
hash(value: T): string;
|
|
48
|
+
}
|
|
49
|
+
interface BindableRefs<T extends Dict$1> {
|
|
50
|
+
set<K extends keyof T["refs"]>(key: K, value: T["refs"][K]): void;
|
|
51
|
+
get<K extends keyof T["refs"]>(key: K): T["refs"][K];
|
|
52
|
+
}
|
|
53
|
+
interface BindableContext<T extends Dict$1> {
|
|
54
|
+
set<K extends keyof T["context"]>(key: K, value: ValueOrFn<T["context"][K]>): void;
|
|
55
|
+
get<K extends keyof T["context"]>(key: K): T["context"][K];
|
|
56
|
+
initial<K extends keyof T["context"]>(key: K): T["context"][K];
|
|
57
|
+
hash<K extends keyof T["context"]>(key: K): string;
|
|
58
|
+
}
|
|
59
|
+
type EventType<T = any> = T & {
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
interface MachineBaseProps {
|
|
63
|
+
id?: string | undefined;
|
|
64
|
+
ids?: Record<string, any> | undefined;
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}
|
|
67
|
+
interface MachineSchema {
|
|
68
|
+
props?: MachineBaseProps | undefined;
|
|
69
|
+
context?: Record<string, any> | undefined;
|
|
70
|
+
refs?: Record<string, any> | undefined;
|
|
71
|
+
computed?: Record<string, any> | undefined;
|
|
72
|
+
state?: string | undefined;
|
|
73
|
+
tag?: string | undefined;
|
|
74
|
+
guard?: string | undefined;
|
|
75
|
+
action?: string | undefined;
|
|
76
|
+
effect?: string | undefined;
|
|
77
|
+
event?: ({
|
|
78
|
+
type: string;
|
|
79
|
+
} & Dict$1) | undefined;
|
|
80
|
+
}
|
|
81
|
+
type State<T extends MachineSchema> = Bindable<T["state"]> & {
|
|
82
|
+
hasTag: (tag: T["tag"]) => boolean;
|
|
83
|
+
matches: (...values: T["state"][]) => boolean;
|
|
84
|
+
};
|
|
85
|
+
type Service<T extends MachineSchema> = {
|
|
86
|
+
getStatus: () => MachineStatus;
|
|
87
|
+
state: State<T>;
|
|
88
|
+
context: BindableContext<T>;
|
|
89
|
+
send: (event: EventType<T["event"]>) => void;
|
|
90
|
+
prop: PropFn<T>;
|
|
91
|
+
scope: Scope;
|
|
92
|
+
computed: ComputedFn<T>;
|
|
93
|
+
refs: BindableRefs<T>;
|
|
94
|
+
event: EventType<T["event"]> & {
|
|
95
|
+
current: () => EventType<T["event"]>;
|
|
96
|
+
previous: () => EventType<T["event"]>;
|
|
97
|
+
};
|
|
98
|
+
toJSON?: () => undefined;
|
|
99
|
+
};
|
|
100
|
+
declare enum MachineStatus {
|
|
101
|
+
NotStarted = "Not Started",
|
|
102
|
+
Started = "Started",
|
|
103
|
+
Stopped = "Stopped"
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../frameworks/miniapp/dist/behavior-ns672Wq_.d.ts
|
|
107
|
+
type ConnectFn<T extends MachineSchema, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> = (service: Service<T>, ...args: any[]) => Data;
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region ../frameworks/miniapp/dist/behaviors/theme.d.ts
|
|
110
|
+
//#region src/behaviors/theme.d.ts
|
|
111
|
+
type AppColorMode = "light" | "dark" | "system";
|
|
112
|
+
type ResolvedThemeMode = "light" | "dark";
|
|
113
|
+
type AppThemeColors = Record<string, string>;
|
|
114
|
+
interface AppThemeState {
|
|
115
|
+
colorMode: AppColorMode;
|
|
116
|
+
resolvedMode: ResolvedThemeMode;
|
|
117
|
+
colors: AppThemeColors;
|
|
118
|
+
cssVars: string;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/use-component-ref.d.ts
|
|
122
|
+
/**
|
|
123
|
+
* Universal MiniProgram instance type supporting both Page and Component contexts.
|
|
124
|
+
*/
|
|
125
|
+
type UseComponentRefInstance = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.Instance<any, any> | {
|
|
126
|
+
setData: (...args: any[]) => any;
|
|
127
|
+
selectComponent?: (...args: any[]) => any;
|
|
128
|
+
[key: string]: any;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Target selector string or component instance reference.
|
|
132
|
+
*/
|
|
133
|
+
type UseComponentRefTarget = string | WechatMiniprogram.Component.TrivialInstance | Record<string, any>;
|
|
134
|
+
interface UseComponentRefBaseOptions<Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> {
|
|
135
|
+
/**
|
|
136
|
+
* The data key under parent's `this.data` where the component snapshot is synced.
|
|
137
|
+
* e.g., key: 'email' -> access via `{{ email.value }}` in WXML.
|
|
138
|
+
*/
|
|
139
|
+
key?: string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Reactive callback triggered whenever the component machine transitions.
|
|
142
|
+
*/
|
|
143
|
+
onChange?: ((snapshot: Data) => void) | undefined;
|
|
144
|
+
}
|
|
145
|
+
interface UseComponentRefConnectOptions<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> extends UseComponentRefBaseOptions<Data> {
|
|
146
|
+
/**
|
|
147
|
+
* Custom connect function to format or project the snapshot.
|
|
148
|
+
*/
|
|
149
|
+
connect: ConnectFn<T, Data>;
|
|
150
|
+
}
|
|
151
|
+
interface UseComponentRefOptions<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> extends UseComponentRefBaseOptions<Data> {
|
|
152
|
+
/**
|
|
153
|
+
* Optional custom connect function to format or project the snapshot.
|
|
154
|
+
*/
|
|
155
|
+
connect?: ConnectFn<T, Data> | undefined;
|
|
156
|
+
}
|
|
157
|
+
type UseComponentRefApi<Data> = Data & {
|
|
158
|
+
clear?: () => void;
|
|
159
|
+
reset?: () => void;
|
|
160
|
+
[key: string]: any;
|
|
161
|
+
};
|
|
162
|
+
interface UseComponentRefReturn<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> {
|
|
163
|
+
/** Synchronous getter for the latest state snapshot in JS */
|
|
164
|
+
getSnapshot: () => Data | undefined;
|
|
165
|
+
/** Getter property for immediate read: `ref.snapshot` */
|
|
166
|
+
readonly snapshot: Data | undefined;
|
|
167
|
+
/** Callable public API methods of the component machine / component */
|
|
168
|
+
api: UseComponentRefApi<Data>;
|
|
169
|
+
/** Send events directly to the component machine */
|
|
170
|
+
send: (event: T["event"]) => void;
|
|
171
|
+
/** The underlying component service */
|
|
172
|
+
readonly service: Service<T> | undefined;
|
|
173
|
+
/** Stop the subscription and dispose reactive bindings */
|
|
174
|
+
stop: () => void;
|
|
175
|
+
/** Safe JSON serialization preventing circular structure errors if assigned to data */
|
|
176
|
+
toJSON?: () => undefined;
|
|
177
|
+
}
|
|
178
|
+
export declare function useComponentRef<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options: UseComponentRefConnectOptions<T, Data>): UseComponentRefReturn<T, Data>;
|
|
179
|
+
export declare function useComponentRef<Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options?: UseComponentRefBaseOptions<Data>): UseComponentRefReturn<any, Data>;
|
|
180
|
+
export declare function useComponentRef<T extends MachineSchema, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options?: UseComponentRefBaseOptions<Data>): UseComponentRefReturn<T, Data>;
|
|
181
|
+
export declare function useComponentRef<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options?: UseComponentRefOptions<T, Data>): UseComponentRefReturn<T, Data>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../frameworks/miniapp/dist/behaviors/toast.d.ts
|
|
184
|
+
//#region src/behaviors/toast.d.ts
|
|
185
|
+
interface ToastAction {
|
|
186
|
+
label: string;
|
|
187
|
+
onClick?: (() => void) | undefined;
|
|
188
|
+
color?: string | undefined;
|
|
189
|
+
variant?: string | undefined;
|
|
190
|
+
size?: string | undefined;
|
|
191
|
+
icon?: string | undefined;
|
|
192
|
+
leadingIcon?: string | undefined;
|
|
193
|
+
trailingIcon?: string | undefined;
|
|
194
|
+
loading?: boolean | undefined;
|
|
195
|
+
loadingIcon?: string | undefined;
|
|
196
|
+
disabled?: boolean | undefined;
|
|
197
|
+
ui?: Record<string, string> | undefined;
|
|
198
|
+
className?: string | undefined;
|
|
199
|
+
id?: string | undefined;
|
|
200
|
+
closeOnClick?: boolean | undefined;
|
|
201
|
+
}
|
|
202
|
+
interface ToastCloseProps {
|
|
203
|
+
icon?: string | undefined;
|
|
204
|
+
color?: string | undefined;
|
|
205
|
+
variant?: string | undefined;
|
|
206
|
+
size?: string | undefined;
|
|
207
|
+
ui?: Record<string, string> | undefined;
|
|
208
|
+
className?: string | undefined;
|
|
209
|
+
disabled?: boolean | undefined;
|
|
210
|
+
}
|
|
211
|
+
type ToastSlotName = "root" | "wrapper" | "title" | "description" | "icon" | "actions" | "action" | "closeTrigger" | "closeButton" | "closeIcon" | "progress" | "progressBar";
|
|
212
|
+
type ToastUI = Partial<Record<ToastSlotName, string>>;
|
|
213
|
+
type ToastPlacement = "top" | "center" | "bottom";
|
|
214
|
+
interface ToastEntry {
|
|
215
|
+
id: string;
|
|
216
|
+
title?: string | undefined;
|
|
217
|
+
description?: string | undefined;
|
|
218
|
+
icon?: string | undefined;
|
|
219
|
+
mode?: "default" | "native" | undefined;
|
|
220
|
+
color?: string | undefined;
|
|
221
|
+
variant?: string | undefined;
|
|
222
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
223
|
+
placement?: ToastPlacement | undefined;
|
|
224
|
+
duration?: number | undefined;
|
|
225
|
+
progress?: boolean | {
|
|
226
|
+
color?: string;
|
|
227
|
+
} | undefined;
|
|
228
|
+
progressPosition?: "top" | "bottom" | undefined;
|
|
229
|
+
open?: boolean | undefined;
|
|
230
|
+
close?: boolean | ToastCloseProps | undefined;
|
|
231
|
+
actions?: ToastAction[] | undefined;
|
|
232
|
+
ui?: ToastUI | undefined;
|
|
233
|
+
className?: string | undefined;
|
|
234
|
+
stackIndex?: number | undefined;
|
|
235
|
+
offset?: number | undefined;
|
|
236
|
+
updatedAt?: number | undefined;
|
|
237
|
+
onAction?: ((details: {
|
|
238
|
+
action: ToastAction;
|
|
239
|
+
index: number;
|
|
240
|
+
}) => void) | undefined;
|
|
241
|
+
onDismiss?: (() => void) | undefined;
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/use-toast.d.ts
|
|
245
|
+
interface ToastOptions {
|
|
246
|
+
id?: string | undefined;
|
|
247
|
+
title?: string | undefined;
|
|
248
|
+
description?: string | undefined;
|
|
249
|
+
icon?: string | undefined;
|
|
250
|
+
mode?: "default" | "native" | undefined;
|
|
251
|
+
color?: string | undefined;
|
|
252
|
+
variant?: string | undefined;
|
|
253
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
254
|
+
placement?: "top" | "center" | "bottom" | undefined;
|
|
255
|
+
duration?: number | undefined;
|
|
256
|
+
progress?: boolean | {
|
|
257
|
+
color?: string;
|
|
258
|
+
} | undefined;
|
|
259
|
+
progressPosition?: "top" | "bottom" | undefined;
|
|
260
|
+
close?: boolean | ToastCloseProps | undefined;
|
|
261
|
+
actions?: ToastAction[] | undefined;
|
|
262
|
+
ui?: ToastUI | undefined;
|
|
263
|
+
className?: string | undefined;
|
|
264
|
+
onAction?: ((details: {
|
|
265
|
+
action: ToastAction;
|
|
266
|
+
index: number;
|
|
267
|
+
}) => void) | undefined;
|
|
268
|
+
onDismiss?: (() => void) | undefined;
|
|
269
|
+
}
|
|
270
|
+
type ToastShorthandArg = string | (Omit<ToastOptions, "color"> & {
|
|
271
|
+
title?: string | undefined;
|
|
272
|
+
});
|
|
273
|
+
interface UseToastOptions {
|
|
274
|
+
/** Optional MiniProgram page or component instance owner */
|
|
275
|
+
target?: any;
|
|
276
|
+
/** Max toasts visible at a time */
|
|
277
|
+
max?: number | undefined;
|
|
278
|
+
}
|
|
279
|
+
interface UseToastReturn {
|
|
280
|
+
add: (toast: ToastOptions) => string;
|
|
281
|
+
show: (toast: ToastOptions) => string;
|
|
282
|
+
update: (id: string, patch: Partial<Omit<ToastOptions, "id">>) => void;
|
|
283
|
+
remove: (id: string) => void;
|
|
284
|
+
dismiss: (id: string) => void;
|
|
285
|
+
clear: () => void;
|
|
286
|
+
config: (options: {
|
|
287
|
+
max?: number | undefined;
|
|
288
|
+
}) => void;
|
|
289
|
+
success: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
290
|
+
error: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
291
|
+
warning: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
292
|
+
info: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
293
|
+
loading: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
294
|
+
}
|
|
295
|
+
export declare function useToast(optionsOrTarget?: UseToastOptions | any): UseToastReturn;
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/use-color-mode.d.ts
|
|
298
|
+
interface UseColorModeOptions {
|
|
299
|
+
/** Optional Page or Component instance (`this`) to sync state into `instance.data` */
|
|
300
|
+
target?: any;
|
|
301
|
+
/** Data key under `target.data` (e.g. `key: "colorMode"`) */
|
|
302
|
+
key?: string | undefined;
|
|
303
|
+
/** Initial color mode to apply if specified */
|
|
304
|
+
initialValue?: AppColorMode | undefined;
|
|
305
|
+
/** Callback fired whenever theme mode or colors change */
|
|
306
|
+
onChange?: ((state: AppThemeState) => void) | undefined;
|
|
307
|
+
}
|
|
308
|
+
interface UseColorModeReturn {
|
|
309
|
+
/** Current configured mode ("light" | "dark" | "system") */
|
|
310
|
+
readonly mode: AppColorMode;
|
|
311
|
+
/** Resolved effective mode ("light" | "dark") */
|
|
312
|
+
readonly resolvedMode: ResolvedThemeMode;
|
|
313
|
+
/** Active runtime color overrides */
|
|
314
|
+
readonly colors: AppThemeColors;
|
|
315
|
+
/** Compiled CSS variable string */
|
|
316
|
+
readonly cssVars: string;
|
|
317
|
+
/** Read full current theme state */
|
|
318
|
+
getState: () => AppThemeState;
|
|
319
|
+
/** Set color mode ("light" | "dark" | "system") */
|
|
320
|
+
setMode: (mode: AppColorMode) => void;
|
|
321
|
+
/** Toggle between "light" and "dark" */
|
|
322
|
+
toggle: () => void;
|
|
323
|
+
/** Stop any active subscription */
|
|
324
|
+
stop: () => void;
|
|
325
|
+
}
|
|
326
|
+
export declare function useColorMode(options?: UseColorModeOptions): UseColorModeReturn;
|
|
327
|
+
//#endregion
|
|
328
|
+
export type { AppColorMode, AppThemeColors, AppThemeState, ResolvedThemeMode, ToastAction, ToastEntry, ToastOptions, UseColorModeOptions, UseColorModeReturn, UseComponentRefApi, UseComponentRefBaseOptions, UseComponentRefConnectOptions, UseComponentRefInstance, UseComponentRefOptions, UseComponentRefReturn, UseComponentRefTarget, UseToastOptions, UseToastReturn };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
//#region ../utils/dist/dom.d.ts
|
|
2
|
+
//#region src/dom.d.ts
|
|
3
|
+
type MiniAppRect = WechatMiniprogram.BoundingClientRectCallbackResult;
|
|
4
|
+
type MiniAppScrollOffset = WechatMiniprogram.ScrollOffsetCallbackResult;
|
|
5
|
+
type MiniAppNodeFields = WechatMiniprogram.IAnyObject;
|
|
6
|
+
type MiniAppComponent = WechatMiniprogram.Component.TrivialInstance;
|
|
7
|
+
interface DOMQueryHelpers {
|
|
8
|
+
query: () => WechatMiniprogram.SelectorQuery;
|
|
9
|
+
rect: (selector: string) => Promise<MiniAppRect | null>;
|
|
10
|
+
allRects: (selector: string) => Promise<MiniAppRect[]>;
|
|
11
|
+
scrollOffset: (selector: string) => Promise<MiniAppScrollOffset | null>;
|
|
12
|
+
viewportScrollOffset: () => Promise<MiniAppScrollOffset | null>;
|
|
13
|
+
fields: (selector: string, fields: WechatMiniprogram.Fields) => Promise<MiniAppNodeFields | null>;
|
|
14
|
+
computedStyle: (selector: string, properties: string[]) => Promise<Record<string, string> | null>;
|
|
15
|
+
animationDuration: (selector: string) => Promise<number>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ../core/dist/icons-CGWn5Sxv.d.ts
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/types.d.ts
|
|
21
|
+
type Dict$1 = Record<string, any>;
|
|
22
|
+
interface Scope {
|
|
23
|
+
id?: string | undefined;
|
|
24
|
+
ids?: Record<string, any> | undefined;
|
|
25
|
+
/** The component/page instance used to scope SelectorQuery */
|
|
26
|
+
component?: MiniAppComponent | undefined;
|
|
27
|
+
/** Optional DOM query helpers (use tree-shakeable queryRect/queryFields from @code-id-labs/utils directly) */
|
|
28
|
+
dom?: DOMQueryHelpers | undefined;
|
|
29
|
+
toJSON?: () => {
|
|
30
|
+
id?: string | undefined;
|
|
31
|
+
ids?: Record<string, any> | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
}
|
|
34
|
+
interface PropFn<T extends Dict$1> {
|
|
35
|
+
<K extends keyof T["props"]>(key: K): T["props"][K];
|
|
36
|
+
}
|
|
37
|
+
interface ComputedFn<T extends Dict$1> {
|
|
38
|
+
<K extends keyof T["computed"]>(key: K): T["computed"][K];
|
|
39
|
+
}
|
|
40
|
+
type ValueOrFn<T> = T | ((prev: T) => T);
|
|
41
|
+
interface Bindable<T> {
|
|
42
|
+
initial: T | undefined;
|
|
43
|
+
ref: any;
|
|
44
|
+
get: () => T;
|
|
45
|
+
set(value: ValueOrFn<T>): void;
|
|
46
|
+
invoke(nextValue: T, prevValue: T): void;
|
|
47
|
+
hash(value: T): string;
|
|
48
|
+
}
|
|
49
|
+
interface BindableRefs<T extends Dict$1> {
|
|
50
|
+
set<K extends keyof T["refs"]>(key: K, value: T["refs"][K]): void;
|
|
51
|
+
get<K extends keyof T["refs"]>(key: K): T["refs"][K];
|
|
52
|
+
}
|
|
53
|
+
interface BindableContext<T extends Dict$1> {
|
|
54
|
+
set<K extends keyof T["context"]>(key: K, value: ValueOrFn<T["context"][K]>): void;
|
|
55
|
+
get<K extends keyof T["context"]>(key: K): T["context"][K];
|
|
56
|
+
initial<K extends keyof T["context"]>(key: K): T["context"][K];
|
|
57
|
+
hash<K extends keyof T["context"]>(key: K): string;
|
|
58
|
+
}
|
|
59
|
+
type EventType<T = any> = T & {
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
interface MachineBaseProps {
|
|
63
|
+
id?: string | undefined;
|
|
64
|
+
ids?: Record<string, any> | undefined;
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}
|
|
67
|
+
interface MachineSchema {
|
|
68
|
+
props?: MachineBaseProps | undefined;
|
|
69
|
+
context?: Record<string, any> | undefined;
|
|
70
|
+
refs?: Record<string, any> | undefined;
|
|
71
|
+
computed?: Record<string, any> | undefined;
|
|
72
|
+
state?: string | undefined;
|
|
73
|
+
tag?: string | undefined;
|
|
74
|
+
guard?: string | undefined;
|
|
75
|
+
action?: string | undefined;
|
|
76
|
+
effect?: string | undefined;
|
|
77
|
+
event?: ({
|
|
78
|
+
type: string;
|
|
79
|
+
} & Dict$1) | undefined;
|
|
80
|
+
}
|
|
81
|
+
type State<T extends MachineSchema> = Bindable<T["state"]> & {
|
|
82
|
+
hasTag: (tag: T["tag"]) => boolean;
|
|
83
|
+
matches: (...values: T["state"][]) => boolean;
|
|
84
|
+
};
|
|
85
|
+
type Service<T extends MachineSchema> = {
|
|
86
|
+
getStatus: () => MachineStatus;
|
|
87
|
+
state: State<T>;
|
|
88
|
+
context: BindableContext<T>;
|
|
89
|
+
send: (event: EventType<T["event"]>) => void;
|
|
90
|
+
prop: PropFn<T>;
|
|
91
|
+
scope: Scope;
|
|
92
|
+
computed: ComputedFn<T>;
|
|
93
|
+
refs: BindableRefs<T>;
|
|
94
|
+
event: EventType<T["event"]> & {
|
|
95
|
+
current: () => EventType<T["event"]>;
|
|
96
|
+
previous: () => EventType<T["event"]>;
|
|
97
|
+
};
|
|
98
|
+
toJSON?: () => undefined;
|
|
99
|
+
};
|
|
100
|
+
declare enum MachineStatus {
|
|
101
|
+
NotStarted = "Not Started",
|
|
102
|
+
Started = "Started",
|
|
103
|
+
Stopped = "Stopped"
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../frameworks/miniapp/dist/behavior-ns672Wq_.d.ts
|
|
107
|
+
type ConnectFn<T extends MachineSchema, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> = (service: Service<T>, ...args: any[]) => Data;
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region ../frameworks/miniapp/dist/behaviors/theme.d.ts
|
|
110
|
+
//#region src/behaviors/theme.d.ts
|
|
111
|
+
type AppColorMode = "light" | "dark" | "system";
|
|
112
|
+
type ResolvedThemeMode = "light" | "dark";
|
|
113
|
+
type AppThemeColors = Record<string, string>;
|
|
114
|
+
interface AppThemeState {
|
|
115
|
+
colorMode: AppColorMode;
|
|
116
|
+
resolvedMode: ResolvedThemeMode;
|
|
117
|
+
colors: AppThemeColors;
|
|
118
|
+
cssVars: string;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/use-component-ref.d.ts
|
|
122
|
+
/**
|
|
123
|
+
* Universal MiniProgram instance type supporting both Page and Component contexts.
|
|
124
|
+
*/
|
|
125
|
+
type UseComponentRefInstance = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.Instance<any, any> | {
|
|
126
|
+
setData: (...args: any[]) => any;
|
|
127
|
+
selectComponent?: (...args: any[]) => any;
|
|
128
|
+
[key: string]: any;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Target selector string or component instance reference.
|
|
132
|
+
*/
|
|
133
|
+
type UseComponentRefTarget = string | WechatMiniprogram.Component.TrivialInstance | Record<string, any>;
|
|
134
|
+
interface UseComponentRefBaseOptions<Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> {
|
|
135
|
+
/**
|
|
136
|
+
* The data key under parent's `this.data` where the component snapshot is synced.
|
|
137
|
+
* e.g., key: 'email' -> access via `{{ email.value }}` in WXML.
|
|
138
|
+
*/
|
|
139
|
+
key?: string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Reactive callback triggered whenever the component machine transitions.
|
|
142
|
+
*/
|
|
143
|
+
onChange?: ((snapshot: Data) => void) | undefined;
|
|
144
|
+
}
|
|
145
|
+
interface UseComponentRefConnectOptions<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> extends UseComponentRefBaseOptions<Data> {
|
|
146
|
+
/**
|
|
147
|
+
* Custom connect function to format or project the snapshot.
|
|
148
|
+
*/
|
|
149
|
+
connect: ConnectFn<T, Data>;
|
|
150
|
+
}
|
|
151
|
+
interface UseComponentRefOptions<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> extends UseComponentRefBaseOptions<Data> {
|
|
152
|
+
/**
|
|
153
|
+
* Optional custom connect function to format or project the snapshot.
|
|
154
|
+
*/
|
|
155
|
+
connect?: ConnectFn<T, Data> | undefined;
|
|
156
|
+
}
|
|
157
|
+
type UseComponentRefApi<Data> = Data & {
|
|
158
|
+
clear?: () => void;
|
|
159
|
+
reset?: () => void;
|
|
160
|
+
[key: string]: any;
|
|
161
|
+
};
|
|
162
|
+
interface UseComponentRefReturn<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject> {
|
|
163
|
+
/** Synchronous getter for the latest state snapshot in JS */
|
|
164
|
+
getSnapshot: () => Data | undefined;
|
|
165
|
+
/** Getter property for immediate read: `ref.snapshot` */
|
|
166
|
+
readonly snapshot: Data | undefined;
|
|
167
|
+
/** Callable public API methods of the component machine / component */
|
|
168
|
+
api: UseComponentRefApi<Data>;
|
|
169
|
+
/** Send events directly to the component machine */
|
|
170
|
+
send: (event: T["event"]) => void;
|
|
171
|
+
/** The underlying component service */
|
|
172
|
+
readonly service: Service<T> | undefined;
|
|
173
|
+
/** Stop the subscription and dispose reactive bindings */
|
|
174
|
+
stop: () => void;
|
|
175
|
+
/** Safe JSON serialization preventing circular structure errors if assigned to data */
|
|
176
|
+
toJSON?: () => undefined;
|
|
177
|
+
}
|
|
178
|
+
export declare function useComponentRef<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options: UseComponentRefConnectOptions<T, Data>): UseComponentRefReturn<T, Data>;
|
|
179
|
+
export declare function useComponentRef<Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options?: UseComponentRefBaseOptions<Data>): UseComponentRefReturn<any, Data>;
|
|
180
|
+
export declare function useComponentRef<T extends MachineSchema, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options?: UseComponentRefBaseOptions<Data>): UseComponentRefReturn<T, Data>;
|
|
181
|
+
export declare function useComponentRef<T extends MachineSchema = any, Data extends WechatMiniprogram.IAnyObject = WechatMiniprogram.IAnyObject>(instance: UseComponentRefInstance, target: UseComponentRefTarget, options?: UseComponentRefOptions<T, Data>): UseComponentRefReturn<T, Data>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../frameworks/miniapp/dist/behaviors/toast.d.ts
|
|
184
|
+
//#region src/behaviors/toast.d.ts
|
|
185
|
+
interface ToastAction {
|
|
186
|
+
label: string;
|
|
187
|
+
onClick?: (() => void) | undefined;
|
|
188
|
+
color?: string | undefined;
|
|
189
|
+
variant?: string | undefined;
|
|
190
|
+
size?: string | undefined;
|
|
191
|
+
icon?: string | undefined;
|
|
192
|
+
leadingIcon?: string | undefined;
|
|
193
|
+
trailingIcon?: string | undefined;
|
|
194
|
+
loading?: boolean | undefined;
|
|
195
|
+
loadingIcon?: string | undefined;
|
|
196
|
+
disabled?: boolean | undefined;
|
|
197
|
+
ui?: Record<string, string> | undefined;
|
|
198
|
+
className?: string | undefined;
|
|
199
|
+
id?: string | undefined;
|
|
200
|
+
closeOnClick?: boolean | undefined;
|
|
201
|
+
}
|
|
202
|
+
interface ToastCloseProps {
|
|
203
|
+
icon?: string | undefined;
|
|
204
|
+
color?: string | undefined;
|
|
205
|
+
variant?: string | undefined;
|
|
206
|
+
size?: string | undefined;
|
|
207
|
+
ui?: Record<string, string> | undefined;
|
|
208
|
+
className?: string | undefined;
|
|
209
|
+
disabled?: boolean | undefined;
|
|
210
|
+
}
|
|
211
|
+
type ToastSlotName = "root" | "wrapper" | "title" | "description" | "icon" | "actions" | "action" | "closeTrigger" | "closeButton" | "closeIcon" | "progress" | "progressBar";
|
|
212
|
+
type ToastUI = Partial<Record<ToastSlotName, string>>;
|
|
213
|
+
type ToastPlacement = "top" | "center" | "bottom";
|
|
214
|
+
interface ToastEntry {
|
|
215
|
+
id: string;
|
|
216
|
+
title?: string | undefined;
|
|
217
|
+
description?: string | undefined;
|
|
218
|
+
icon?: string | undefined;
|
|
219
|
+
mode?: "default" | "native" | undefined;
|
|
220
|
+
color?: string | undefined;
|
|
221
|
+
variant?: string | undefined;
|
|
222
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
223
|
+
placement?: ToastPlacement | undefined;
|
|
224
|
+
duration?: number | undefined;
|
|
225
|
+
progress?: boolean | {
|
|
226
|
+
color?: string;
|
|
227
|
+
} | undefined;
|
|
228
|
+
progressPosition?: "top" | "bottom" | undefined;
|
|
229
|
+
open?: boolean | undefined;
|
|
230
|
+
close?: boolean | ToastCloseProps | undefined;
|
|
231
|
+
actions?: ToastAction[] | undefined;
|
|
232
|
+
ui?: ToastUI | undefined;
|
|
233
|
+
className?: string | undefined;
|
|
234
|
+
stackIndex?: number | undefined;
|
|
235
|
+
offset?: number | undefined;
|
|
236
|
+
updatedAt?: number | undefined;
|
|
237
|
+
onAction?: ((details: {
|
|
238
|
+
action: ToastAction;
|
|
239
|
+
index: number;
|
|
240
|
+
}) => void) | undefined;
|
|
241
|
+
onDismiss?: (() => void) | undefined;
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/use-toast.d.ts
|
|
245
|
+
interface ToastOptions {
|
|
246
|
+
id?: string | undefined;
|
|
247
|
+
title?: string | undefined;
|
|
248
|
+
description?: string | undefined;
|
|
249
|
+
icon?: string | undefined;
|
|
250
|
+
mode?: "default" | "native" | undefined;
|
|
251
|
+
color?: string | undefined;
|
|
252
|
+
variant?: string | undefined;
|
|
253
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
254
|
+
placement?: "top" | "center" | "bottom" | undefined;
|
|
255
|
+
duration?: number | undefined;
|
|
256
|
+
progress?: boolean | {
|
|
257
|
+
color?: string;
|
|
258
|
+
} | undefined;
|
|
259
|
+
progressPosition?: "top" | "bottom" | undefined;
|
|
260
|
+
close?: boolean | ToastCloseProps | undefined;
|
|
261
|
+
actions?: ToastAction[] | undefined;
|
|
262
|
+
ui?: ToastUI | undefined;
|
|
263
|
+
className?: string | undefined;
|
|
264
|
+
onAction?: ((details: {
|
|
265
|
+
action: ToastAction;
|
|
266
|
+
index: number;
|
|
267
|
+
}) => void) | undefined;
|
|
268
|
+
onDismiss?: (() => void) | undefined;
|
|
269
|
+
}
|
|
270
|
+
type ToastShorthandArg = string | (Omit<ToastOptions, "color"> & {
|
|
271
|
+
title?: string | undefined;
|
|
272
|
+
});
|
|
273
|
+
interface UseToastOptions {
|
|
274
|
+
/** Optional MiniProgram page or component instance owner */
|
|
275
|
+
target?: any;
|
|
276
|
+
/** Max toasts visible at a time */
|
|
277
|
+
max?: number | undefined;
|
|
278
|
+
}
|
|
279
|
+
interface UseToastReturn {
|
|
280
|
+
add: (toast: ToastOptions) => string;
|
|
281
|
+
show: (toast: ToastOptions) => string;
|
|
282
|
+
update: (id: string, patch: Partial<Omit<ToastOptions, "id">>) => void;
|
|
283
|
+
remove: (id: string) => void;
|
|
284
|
+
dismiss: (id: string) => void;
|
|
285
|
+
clear: () => void;
|
|
286
|
+
config: (options: {
|
|
287
|
+
max?: number | undefined;
|
|
288
|
+
}) => void;
|
|
289
|
+
success: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
290
|
+
error: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
291
|
+
warning: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
292
|
+
info: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
293
|
+
loading: (titleOrOptions: ToastShorthandArg, options?: Omit<ToastOptions, "title" | "color">) => string;
|
|
294
|
+
}
|
|
295
|
+
export declare function useToast(optionsOrTarget?: UseToastOptions | any): UseToastReturn;
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/use-color-mode.d.ts
|
|
298
|
+
interface UseColorModeOptions {
|
|
299
|
+
/** Optional Page or Component instance (`this`) to sync state into `instance.data` */
|
|
300
|
+
target?: any;
|
|
301
|
+
/** Data key under `target.data` (e.g. `key: "colorMode"`) */
|
|
302
|
+
key?: string | undefined;
|
|
303
|
+
/** Initial color mode to apply if specified */
|
|
304
|
+
initialValue?: AppColorMode | undefined;
|
|
305
|
+
/** Callback fired whenever theme mode or colors change */
|
|
306
|
+
onChange?: ((state: AppThemeState) => void) | undefined;
|
|
307
|
+
}
|
|
308
|
+
interface UseColorModeReturn {
|
|
309
|
+
/** Current configured mode ("light" | "dark" | "system") */
|
|
310
|
+
readonly mode: AppColorMode;
|
|
311
|
+
/** Resolved effective mode ("light" | "dark") */
|
|
312
|
+
readonly resolvedMode: ResolvedThemeMode;
|
|
313
|
+
/** Active runtime color overrides */
|
|
314
|
+
readonly colors: AppThemeColors;
|
|
315
|
+
/** Compiled CSS variable string */
|
|
316
|
+
readonly cssVars: string;
|
|
317
|
+
/** Read full current theme state */
|
|
318
|
+
getState: () => AppThemeState;
|
|
319
|
+
/** Set color mode ("light" | "dark" | "system") */
|
|
320
|
+
setMode: (mode: AppColorMode) => void;
|
|
321
|
+
/** Toggle between "light" and "dark" */
|
|
322
|
+
toggle: () => void;
|
|
323
|
+
/** Stop any active subscription */
|
|
324
|
+
stop: () => void;
|
|
325
|
+
}
|
|
326
|
+
export declare function useColorMode(options?: UseColorModeOptions): UseColorModeReturn;
|
|
327
|
+
//#endregion
|
|
328
|
+
export type { AppColorMode, AppThemeColors, AppThemeState, ResolvedThemeMode, ToastAction, ToastEntry, ToastOptions, UseColorModeOptions, UseColorModeReturn, UseComponentRefApi, UseComponentRefBaseOptions, UseComponentRefConnectOptions, UseComponentRefInstance, UseComponentRefOptions, UseComponentRefReturn, UseComponentRefTarget, UseToastOptions, UseToastReturn };
|