@nolikein/types-livewire3 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/LICENCE +7 -0
- package/dist/Alpine.d.ts +15 -0
- package/dist/AlpineWired.d.ts +23 -0
- package/dist/Livewire.d.ts +572 -0
- package/dist/index.d.ts +4 -0
- package/package.json +26 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright © 2025 Côme Wasik
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/Alpine.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Alpine from "alpinejs";
|
|
2
|
+
export default Alpine;
|
|
3
|
+
export type Alpine = typeof Alpine;
|
|
4
|
+
/**
|
|
5
|
+
* Represent the component AlpineJs self instance (this). Usefull to pass "this" as argument to another function as "self".
|
|
6
|
+
*
|
|
7
|
+
* Usage: function myCallback(self: AlpineComponentSelf<AlpineData>) { ... }
|
|
8
|
+
*/
|
|
9
|
+
export type AlpineComponentSelf<AlpineData> = Alpine.InferInterceptors<AlpineData> & Alpine.XDataContext & Alpine.Magics<AlpineData>;
|
|
10
|
+
/**
|
|
11
|
+
* Define a Alpine component.
|
|
12
|
+
*
|
|
13
|
+
* The generic AlpineData describe the whole Alpine component content (data + methods).
|
|
14
|
+
*/
|
|
15
|
+
export type AlpineComponent<AlpineData> = AlpineData & Alpine.XDataContext & ThisType<AlpineComponentSelf<AlpineData>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InferInterceptors, Magics as AlpineMagics, XDataContext } from "alpinejs";
|
|
2
|
+
import { LivewireMagics } from "./Livewire";
|
|
3
|
+
/**
|
|
4
|
+
* An instance of all AlpineJs magics intended to be used with Laravel Livewire.
|
|
5
|
+
*/
|
|
6
|
+
export interface Magics<LivewireData, LivewireMethods> {
|
|
7
|
+
$wire: LivewireMagics<LivewireData, LivewireMethods>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represent the component AlpineJs self instance (this). Usefull to pass "this" as argument to another function as "self".
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* function myCallback(self: AlpineComponentSelf<AlpineData, LivewireData, LivewireMethods>) { ... }
|
|
14
|
+
*/
|
|
15
|
+
export type AlpineComponentSelf<AlpineData, LivewireData, LivewireMethods> = InferInterceptors<AlpineData> & XDataContext & AlpineMagics<AlpineData> & Magics<LivewireData, LivewireMethods>;
|
|
16
|
+
/**
|
|
17
|
+
* Define a Alpine + Livewire component.
|
|
18
|
+
*
|
|
19
|
+
* The generic AlpineData describe the whole Alpine component content (data + methods).
|
|
20
|
+
*
|
|
21
|
+
* The generics LivewireData and LivewireMethods describe the Livewire public properties and public methods.
|
|
22
|
+
*/
|
|
23
|
+
export type AlpineComponent<AlpineData, LivewireData, LivewireMethods> = AlpineData & XDataContext & ThisType<AlpineComponentSelf<AlpineData, LivewireData, LivewireMethods>>;
|
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import { AlpineComponent as NativeAlpineComponent, reactive } from "alpinejs";
|
|
2
|
+
export declare class Livewire {
|
|
3
|
+
/**
|
|
4
|
+
* Tell if the page rendering is finished
|
|
5
|
+
*/
|
|
6
|
+
initialRenderIsFinished: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Allows to nagivate to another page.
|
|
9
|
+
* Use the Livewire's Alpinejs plugin "navigate" which is also an Alpinejs directive
|
|
10
|
+
*/
|
|
11
|
+
get navigate(): (url: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Retrive all the instances of Livewire component in the page
|
|
14
|
+
*/
|
|
15
|
+
all: () => Array<Component<unknown, unknown>>;
|
|
16
|
+
/**
|
|
17
|
+
* Add a livewire directive dynamically.
|
|
18
|
+
*/
|
|
19
|
+
directive: (name: string, callback: (obj: DirectiveContent) => void) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Dispatch an event to a given component.
|
|
22
|
+
*/
|
|
23
|
+
dispatchTo: (name: string, event: string, ...params: Array<unknown>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Start Livewire
|
|
26
|
+
*/
|
|
27
|
+
start: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieve the first found instance of Livewire component or (throws an error ?).
|
|
30
|
+
*/
|
|
31
|
+
first: () => LivewireProxy<unknown, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieve a Livewire component instance from id.
|
|
34
|
+
*/
|
|
35
|
+
find: (componentId: string) => LivewireProxy<unknown, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve a Livewire component instance from name.
|
|
38
|
+
*/
|
|
39
|
+
getByName: (name: string) => Array<LivewireProxy<unknown, unknown>>;
|
|
40
|
+
/**
|
|
41
|
+
* Register a callback to run when an internal event is triggered.
|
|
42
|
+
* The callback can return values that are stored as "finishers" and returned by the hook function.
|
|
43
|
+
*/
|
|
44
|
+
hook: (name: HookNames, callback: (...params: Array<unknown>) => void) => () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Dispatch an event to all components.
|
|
47
|
+
*/
|
|
48
|
+
dispatch: (event: string, ...params: Array<unknown>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Register an event listener.
|
|
51
|
+
* The returned function allows to remove the event listener.
|
|
52
|
+
*/
|
|
53
|
+
on: (event: string, callback: (customEvent: CustomEvent) => void) => () => void;
|
|
54
|
+
/**
|
|
55
|
+
* In addition to triggering an event, this method allows you to
|
|
56
|
+
* defer running callbacks returned from listeners and pass a
|
|
57
|
+
* value through each one so they can act like middleware.
|
|
58
|
+
*
|
|
59
|
+
* An example of using this combination to the fullest:
|
|
60
|
+
*
|
|
61
|
+
* // First let's look at the triggering phase:
|
|
62
|
+
* let finish = trigger([event name], ...[event params])
|
|
63
|
+
*
|
|
64
|
+
* return finish([pass-through value])
|
|
65
|
+
*
|
|
66
|
+
* // Now, let's look at the "listening" phase:
|
|
67
|
+
* on([event name], (...[event params]) => {
|
|
68
|
+
* // The contents of this callback will be run immediately on trigger.
|
|
69
|
+
*
|
|
70
|
+
* return ([pass-through value]) => {
|
|
71
|
+
* // This callback will be run when "finish()" is called.
|
|
72
|
+
*
|
|
73
|
+
* // The [pass-through value] can be mutated and must
|
|
74
|
+
* // be returned for the next callback to process.
|
|
75
|
+
* return [pass-through value]
|
|
76
|
+
* }
|
|
77
|
+
* })
|
|
78
|
+
*/
|
|
79
|
+
trigger: (name: string, ...params: Array<unknown>) => (result: unknown) => unknown;
|
|
80
|
+
/**
|
|
81
|
+
* The asynchrone version of the trigger() function.
|
|
82
|
+
*/
|
|
83
|
+
triggerAsync: (name: string, ...params: Array<unknown>) => Promise<(result: unknown) => unknown>;
|
|
84
|
+
}
|
|
85
|
+
type HookNames = 'component.init' | 'element.init' | 'morph.updating' | 'morph.updated' | 'morph.removing' | 'morph.removed' | 'morph.adding' | 'morph.added' | 'morph' | 'morphed' | 'commit' | 'commit.prepare' | 'request';
|
|
86
|
+
export interface DirectiveContent {
|
|
87
|
+
/** The node that called the directive */
|
|
88
|
+
el: HTMLElement;
|
|
89
|
+
/**
|
|
90
|
+
* The directive content parsed.
|
|
91
|
+
*/
|
|
92
|
+
directive: {
|
|
93
|
+
/** The whole directive content */
|
|
94
|
+
raw: string;
|
|
95
|
+
/** The action. By example: "click" */
|
|
96
|
+
value: string;
|
|
97
|
+
/** Access the modifiers. By exemple: "prevent" */
|
|
98
|
+
modifiers: Array<string>;
|
|
99
|
+
/** The dynamic expression. By exemple: "deletePost(1)"" */
|
|
100
|
+
expression: string;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Access the current Livewire component instance.
|
|
104
|
+
*/
|
|
105
|
+
component: Component<unknown, unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* Register a callback to know how to destroy the component.
|
|
108
|
+
*/
|
|
109
|
+
cleanup: (callback: () => void) => void;
|
|
110
|
+
}
|
|
111
|
+
export interface Effects {
|
|
112
|
+
listeners: Array<string>;
|
|
113
|
+
/** Contains the query string metadata of the Livewire Query string feature */
|
|
114
|
+
url?: {
|
|
115
|
+
/** Allows to always show the query string argument */
|
|
116
|
+
alwaysShow: boolean;
|
|
117
|
+
/** The query name argument */
|
|
118
|
+
as: string;
|
|
119
|
+
/** The value that remove the query string argument from the url */
|
|
120
|
+
except: string;
|
|
121
|
+
/** The method used. Can be "push" */
|
|
122
|
+
use: string;
|
|
123
|
+
};
|
|
124
|
+
scripts?: unknown;
|
|
125
|
+
}
|
|
126
|
+
export interface Snapshot {
|
|
127
|
+
data: Record<string, unknown>;
|
|
128
|
+
memo: {
|
|
129
|
+
/** The component id */
|
|
130
|
+
id: string;
|
|
131
|
+
/** The component name */
|
|
132
|
+
name: string;
|
|
133
|
+
/** The uri path */
|
|
134
|
+
path: string;
|
|
135
|
+
/** The http method */
|
|
136
|
+
method: string;
|
|
137
|
+
/** The request locale (e.g. "en", "fr") */
|
|
138
|
+
locale: string;
|
|
139
|
+
/**
|
|
140
|
+
* A list of any nested "child" components. Keyed by
|
|
141
|
+
* internal template ID with the component ID as the values
|
|
142
|
+
*/
|
|
143
|
+
children: Record<string, Component<unknown, unknown>>;
|
|
144
|
+
/** Weather or not this component was "lazy loaded"... */
|
|
145
|
+
lazyLoaded: boolean;
|
|
146
|
+
/** A list of any validation errors thrown during the last request */
|
|
147
|
+
errors: Record<string, unknown>;
|
|
148
|
+
/** The list of */
|
|
149
|
+
scripts?: Record<string, unknown>;
|
|
150
|
+
assets?: Record<string, unknown>;
|
|
151
|
+
};
|
|
152
|
+
/** A securely encrypted hash of the current snapshot */
|
|
153
|
+
checksum: string;
|
|
154
|
+
}
|
|
155
|
+
export declare class Component<LivewireData, LivewireMethods> {
|
|
156
|
+
/**
|
|
157
|
+
* A Proxy object that is typically used inside Alpine
|
|
158
|
+
* expressions as `$wire`. This is meant to provide a
|
|
159
|
+
* friendly JS object interface for Livewire components
|
|
160
|
+
*/
|
|
161
|
+
$wire: LivewireProxy<LivewireData, LivewireMethods>;
|
|
162
|
+
/**
|
|
163
|
+
* The livewire component id
|
|
164
|
+
*/
|
|
165
|
+
__livewireId: string;
|
|
166
|
+
/**
|
|
167
|
+
* it represents the last-known server-side state.
|
|
168
|
+
*/
|
|
169
|
+
canonical: Record<string, LivewireData>;
|
|
170
|
+
/**
|
|
171
|
+
* The component's mutable data object representing its live
|
|
172
|
+
* client-side state. More exactly, it represents the most current
|
|
173
|
+
* state of the component data. (This can be freely manipulated by end users)
|
|
174
|
+
*/
|
|
175
|
+
ephemeral: Record<string, LivewireData>;
|
|
176
|
+
/**
|
|
177
|
+
* The cleanups are callbacks that are executed the component is destroying.
|
|
178
|
+
* You can add one by using addCleaup()
|
|
179
|
+
*/
|
|
180
|
+
cleanups: Array<() => void>;
|
|
181
|
+
/**
|
|
182
|
+
* Add a callback that will be executed while component is destroying.
|
|
183
|
+
*/
|
|
184
|
+
addCleanup: () => void;
|
|
185
|
+
/**
|
|
186
|
+
* Destroy the Livewire component.
|
|
187
|
+
*/
|
|
188
|
+
cleanup(): void;
|
|
189
|
+
/**
|
|
190
|
+
* The content of the "wire:effects" html attribute.
|
|
191
|
+
* Generally filled with "listeners" and "url" when having query string.
|
|
192
|
+
*/
|
|
193
|
+
effects: Effects;
|
|
194
|
+
/**
|
|
195
|
+
* The component DOM element
|
|
196
|
+
*/
|
|
197
|
+
el: LivewireHTMLElement;
|
|
198
|
+
/**
|
|
199
|
+
* Retrieve the nearest Livewire parent component.
|
|
200
|
+
* Throws Error otherwise.
|
|
201
|
+
* @throws
|
|
202
|
+
*/
|
|
203
|
+
get parent(): Component<unknown, unknown>;
|
|
204
|
+
/**
|
|
205
|
+
* A list of any nested "child" components. Keyed by
|
|
206
|
+
* internal template ID with the component ID as the values
|
|
207
|
+
*/
|
|
208
|
+
get children(): Array<Component<unknown, unknown>>;
|
|
209
|
+
/**
|
|
210
|
+
* The livewire component id.
|
|
211
|
+
*/
|
|
212
|
+
id: string;
|
|
213
|
+
/**
|
|
214
|
+
* The component name.
|
|
215
|
+
*/
|
|
216
|
+
name: string;
|
|
217
|
+
/** The original state of the "effects" attribute */
|
|
218
|
+
originalEffects: {
|
|
219
|
+
listeners: Array<string>;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Contains every user registered requests when defering requests.
|
|
223
|
+
* Supposed to be empty after each defered request.
|
|
224
|
+
*/
|
|
225
|
+
queuedUpdates: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* A reactive version of `this.ephemeral`. Changes to
|
|
228
|
+
* this object will be picked up by AlpineJS expressions.
|
|
229
|
+
*/
|
|
230
|
+
reactive: typeof reactive;
|
|
231
|
+
/**
|
|
232
|
+
* The un-parsed version of the above snapshot. This is used to send back to the
|
|
233
|
+
* server on the next roundtrip because JS parsing messes with PHP encoding
|
|
234
|
+
* which often results in checksum mis-matches.
|
|
235
|
+
*
|
|
236
|
+
* Also the content of the "wire:snapshot" html attribute.
|
|
237
|
+
*/
|
|
238
|
+
snapshotEncoded: string;
|
|
239
|
+
/**
|
|
240
|
+
* The JSON decoded content of the "wire:snapshot" html attribute.
|
|
241
|
+
*/
|
|
242
|
+
snapshot: Snapshot;
|
|
243
|
+
/**
|
|
244
|
+
* Merge the current snapshot with a given new with effects and updates.
|
|
245
|
+
* Return the dirty data.
|
|
246
|
+
* @param snapshotEncoded
|
|
247
|
+
* @param effects
|
|
248
|
+
* @param updates
|
|
249
|
+
*/
|
|
250
|
+
mergeNewSnapshot(snapshotEncoded: string, effects: Effects, updates: Record<string, unknown>): Record<string, unknown>;
|
|
251
|
+
/**
|
|
252
|
+
* Queue a server update
|
|
253
|
+
* @param propertyName
|
|
254
|
+
* @param value
|
|
255
|
+
*/
|
|
256
|
+
queueUpdate(propertyName: string, value: unknown): void;
|
|
257
|
+
/**
|
|
258
|
+
* Merge the queued updates with the given diff records.
|
|
259
|
+
* Note: Queued updates will take priority against ephemeral
|
|
260
|
+
* updates that have happend since them
|
|
261
|
+
* @param diff
|
|
262
|
+
*/
|
|
263
|
+
mergeQueuedUpdates(diff: Record<string, unknown>): Record<string, unknown>;
|
|
264
|
+
/**
|
|
265
|
+
* Apply updates to a given objects.
|
|
266
|
+
* Supports dot-notation. (by exemple "one.two")
|
|
267
|
+
* @param object
|
|
268
|
+
* @param updates
|
|
269
|
+
*/
|
|
270
|
+
applyUpdates(object: Record<string, unknown>, updates: Record<string, unknown>): Record<string, unknown>;
|
|
271
|
+
/**
|
|
272
|
+
* Merge given snapshot and html into the component then process effects.
|
|
273
|
+
* @param snapshot
|
|
274
|
+
* @param html
|
|
275
|
+
*/
|
|
276
|
+
replayUpdate(snapshot: Snapshot, html: string): void;
|
|
277
|
+
/**
|
|
278
|
+
* Take the new state and side effects from the server and use them
|
|
279
|
+
* to update the existing data that users interact with.
|
|
280
|
+
* Also trigger reactive effects.
|
|
281
|
+
* @param effects
|
|
282
|
+
*/
|
|
283
|
+
processEffects(effects: Effects): void;
|
|
284
|
+
/**
|
|
285
|
+
* Write the current snapshot encoded into the "wire:snapshot" html
|
|
286
|
+
* attribute and rewrite "wire:effects" with original effects.
|
|
287
|
+
*/
|
|
288
|
+
inscribeSnapshotAndEffectsOnElement(): void;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* A Reactive Alpine instance.
|
|
292
|
+
*/
|
|
293
|
+
export type LivewireProxy<LivewireData, LivewireMethods> = typeof Proxy & LivewireMagics<LivewireData, LivewireMethods>;
|
|
294
|
+
/**
|
|
295
|
+
* The callback that will be called when the component is destroyed.
|
|
296
|
+
*/
|
|
297
|
+
export type CleanupCallback = () => unknown;
|
|
298
|
+
/**
|
|
299
|
+
* Will store any event listener and livewire/alpinejs initializer as "x-data" or "wire:id"
|
|
300
|
+
*/
|
|
301
|
+
export type CleanupAttributes = Record<string, CleanupCallback>;
|
|
302
|
+
/**
|
|
303
|
+
* An HTMLElement that has a Livewire component registered.
|
|
304
|
+
*/
|
|
305
|
+
export interface LivewireHTMLElement extends HTMLElement {
|
|
306
|
+
__livewire: Component<unknown, unknown>;
|
|
307
|
+
/**
|
|
308
|
+
* Callbacks that are run when the component is destroyed registered by attribute name
|
|
309
|
+
*/
|
|
310
|
+
_x_attributeCleanups: CleanupAttributes;
|
|
311
|
+
/**
|
|
312
|
+
* Callbacks that are run when the component is destroyed.
|
|
313
|
+
*/
|
|
314
|
+
_x_cleanups: Array<CleanupCallback>;
|
|
315
|
+
/**
|
|
316
|
+
* Contains all the Alpinejs detected from here.
|
|
317
|
+
*/
|
|
318
|
+
_x_dataStack: Array<NativeAlpineComponent<unknown>>;
|
|
319
|
+
/**
|
|
320
|
+
* ???
|
|
321
|
+
*/
|
|
322
|
+
_x_marker: number;
|
|
323
|
+
}
|
|
324
|
+
export interface Commit {
|
|
325
|
+
/** A snapshot object */
|
|
326
|
+
snapshot: Snapshot;
|
|
327
|
+
/** The properties to update and their values */
|
|
328
|
+
updates: Record<string, unknown>;
|
|
329
|
+
/** An array of methods (with parameters) to call server-side */
|
|
330
|
+
calls: Array<{
|
|
331
|
+
/** The method to call */
|
|
332
|
+
method: string;
|
|
333
|
+
/** A list of parameters */
|
|
334
|
+
params: Array<unknown>;
|
|
335
|
+
}>;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* An HTMLElement that has an AlpineJs component registered
|
|
339
|
+
*/
|
|
340
|
+
export interface AlpineHTMLElement extends HTMLElement {
|
|
341
|
+
/**
|
|
342
|
+
* Callbacks that are run when the component is destroyed registered by attribute name
|
|
343
|
+
*/
|
|
344
|
+
_x_attributeCleanups: CleanupAttributes;
|
|
345
|
+
/**
|
|
346
|
+
* Callbacks that are run when the component is destroyed.
|
|
347
|
+
*/
|
|
348
|
+
_x_cleanups: Array<CleanupCallback>;
|
|
349
|
+
/**
|
|
350
|
+
* Contains all the Alpinejs detected from here.
|
|
351
|
+
*/
|
|
352
|
+
_x_dataStack: Array<NativeAlpineComponent<unknown>>;
|
|
353
|
+
/**
|
|
354
|
+
* ???
|
|
355
|
+
*/
|
|
356
|
+
_x_marker: number;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* The instance created when using $entangle.
|
|
360
|
+
*/
|
|
361
|
+
export interface EntangleInstance {
|
|
362
|
+
_x_interceptor: boolean;
|
|
363
|
+
initialValue: unknown;
|
|
364
|
+
initialize: (a: unknown, b: unknown, c: unknown) => unknown;
|
|
365
|
+
live: EntangleInstance;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The Livewire tools known as $wire.
|
|
369
|
+
*
|
|
370
|
+
* The generics LivewireData and LivewireMethods describe the Livewire public properties and public methods.
|
|
371
|
+
*/
|
|
372
|
+
export interface LivewireMagics<LivewireData, LivewireMethods> {
|
|
373
|
+
/**
|
|
374
|
+
* Accessing the underlying Livewire component JavaScript instance
|
|
375
|
+
*/
|
|
376
|
+
__instance: Component<LivewireData, LivewireMethods>;
|
|
377
|
+
parent: LivewireMagics<unknown, unknown>;
|
|
378
|
+
$el: AlpineHTMLElement;
|
|
379
|
+
$id: string;
|
|
380
|
+
/**
|
|
381
|
+
* Get the value of a property by name...
|
|
382
|
+
* Usage: $wire.$get('count')
|
|
383
|
+
*
|
|
384
|
+
* @param name
|
|
385
|
+
*/
|
|
386
|
+
$get(name: string & keyof LivewireData): unknown;
|
|
387
|
+
/**
|
|
388
|
+
* Set a property on the component by name...
|
|
389
|
+
* Usage: $wire.$set('count', 5)
|
|
390
|
+
*
|
|
391
|
+
* @param name
|
|
392
|
+
* @param value The value to set
|
|
393
|
+
* @param live True by default
|
|
394
|
+
*/
|
|
395
|
+
$set(name: string & keyof LivewireData, value: unknown, live?: boolean): Promise<unknown>;
|
|
396
|
+
/**
|
|
397
|
+
* Toggle the value of a boolean property...
|
|
398
|
+
* @param name
|
|
399
|
+
* @param live true by default
|
|
400
|
+
*/
|
|
401
|
+
$toggle(name: string & keyof LivewireData, live?: boolean): Promise<unknown>;
|
|
402
|
+
/**
|
|
403
|
+
* Call the method
|
|
404
|
+
* Usage: $wire.$call('increment')
|
|
405
|
+
*
|
|
406
|
+
* @param method
|
|
407
|
+
* @param params
|
|
408
|
+
*/
|
|
409
|
+
$call(method: string & keyof LivewireMethods, ...params: Array<unknown>): Promise<LivewireMethods[keyof LivewireMethods]>;
|
|
410
|
+
/**
|
|
411
|
+
* Entangle the value of a Livewire property with a different,
|
|
412
|
+
* arbitrary, Alpine property...
|
|
413
|
+
* Usage: <div x-data="{ count: $wire.$entangle('count') }">
|
|
414
|
+
*
|
|
415
|
+
* @param name
|
|
416
|
+
* @param live false by default
|
|
417
|
+
*/
|
|
418
|
+
$entangle(name: string, live?: boolean): EntangleInstance;
|
|
419
|
+
/**
|
|
420
|
+
* Watch the value of a property for changes...
|
|
421
|
+
* Usage: Alpine.$watch('count', (value, old) => { ... })
|
|
422
|
+
*
|
|
423
|
+
* @param name
|
|
424
|
+
* @param callback
|
|
425
|
+
*/
|
|
426
|
+
$watch(name: string, callback: (value: unknown, old: unknown) => void): Promise<unknown>;
|
|
427
|
+
/**
|
|
428
|
+
* Refresh a component by sending a commit to the server
|
|
429
|
+
* to re-render the HTML and swap it into the page...
|
|
430
|
+
*/
|
|
431
|
+
$refresh(): Promise<unknown>;
|
|
432
|
+
/**
|
|
433
|
+
* Identical to the above `$refresh`. Just a more technical name...
|
|
434
|
+
*/
|
|
435
|
+
$commit(): Promise<unknown>;
|
|
436
|
+
/**
|
|
437
|
+
* Listen for a an event dispatched from this component or its children...
|
|
438
|
+
* Usage: $wire.$on('post-created', () => { ... })
|
|
439
|
+
*
|
|
440
|
+
* @param event
|
|
441
|
+
* @param callback
|
|
442
|
+
*/
|
|
443
|
+
$on(event: string, callback: (...param: Array<unknown>) => unknown): void;
|
|
444
|
+
/**
|
|
445
|
+
* Dispatch an event from this component...
|
|
446
|
+
* Usage: $wire.$dispatch('post-created', { postId: 2 })
|
|
447
|
+
*
|
|
448
|
+
* @param event
|
|
449
|
+
* @param params
|
|
450
|
+
*/
|
|
451
|
+
$dispatch(event: string, ...params: Array<unknown>): void;
|
|
452
|
+
/**
|
|
453
|
+
* Dispatch an event onto another component...
|
|
454
|
+
* Usage: $wire.$dispatchTo('dashboard', 'post-created', { postId: 2 })
|
|
455
|
+
*
|
|
456
|
+
* @param otherComponentName
|
|
457
|
+
* @param event
|
|
458
|
+
* @param params
|
|
459
|
+
*/
|
|
460
|
+
$dispatchTo(otherComponentName: string, event: string, params: Record<string, unknown>): void;
|
|
461
|
+
/**
|
|
462
|
+
* Dispatch an event onto this component and no others...
|
|
463
|
+
* @param event
|
|
464
|
+
* @param params
|
|
465
|
+
*/
|
|
466
|
+
$dispatchSelf(event: string, params: Record<string, unknown>): void;
|
|
467
|
+
/**
|
|
468
|
+
* A JS API to upload a file directly to component
|
|
469
|
+
* rather than through `wire:model`...
|
|
470
|
+
*
|
|
471
|
+
* @param name
|
|
472
|
+
* @param file
|
|
473
|
+
* @param finish
|
|
474
|
+
* @param */
|
|
475
|
+
$upload(
|
|
476
|
+
/** The property name */
|
|
477
|
+
name: string & keyof LivewireData,
|
|
478
|
+
/** The File JavaScript object */
|
|
479
|
+
file: File,
|
|
480
|
+
/** Runs when the upload is finished... */
|
|
481
|
+
finish: (uploadedFilename: string) => void,
|
|
482
|
+
/** Runs if an error is triggered mid-upload... */
|
|
483
|
+
error: () => void,
|
|
484
|
+
/** Runs as the upload progresses... */
|
|
485
|
+
progress: (event: CustomEvent) => void): void;
|
|
486
|
+
$uploadMultiple(
|
|
487
|
+
/** The property name */
|
|
488
|
+
name: string & keyof LivewireData,
|
|
489
|
+
/** An array of the File JavaScript object */
|
|
490
|
+
files: Array<File>,
|
|
491
|
+
/** Runs when the upload is finished... */
|
|
492
|
+
finish: (uploadedFilename: string) => void,
|
|
493
|
+
/** Runs if an error is triggered mid-upload... */
|
|
494
|
+
error: () => void,
|
|
495
|
+
/** Runs as the upload progresses... */
|
|
496
|
+
progress: (event: CustomEvent) => void): void;
|
|
497
|
+
$removeUpload(name: string & keyof LivewireData, tmpFilename: string,
|
|
498
|
+
/** Runs when the upload is finished... */
|
|
499
|
+
finish: (uploadedFilename: string) => void,
|
|
500
|
+
/** Runs if an error is triggered mid-upload... */
|
|
501
|
+
error: () => void): void;
|
|
502
|
+
/**
|
|
503
|
+
* Livewire 2 support
|
|
504
|
+
*/
|
|
505
|
+
/**
|
|
506
|
+
* Retrieve a Livewire property
|
|
507
|
+
* @param property
|
|
508
|
+
* @deprecated Use $ version of the method
|
|
509
|
+
*/
|
|
510
|
+
get: (property: string & keyof LivewireData) => unknown;
|
|
511
|
+
/**
|
|
512
|
+
* Set a value for a Livewire property.
|
|
513
|
+
* @param property The Livewire property name
|
|
514
|
+
* @param value The value to set
|
|
515
|
+
* @param defer Defer set the property
|
|
516
|
+
* @deprecated Use $ version of the method
|
|
517
|
+
*/
|
|
518
|
+
set: (property: string & keyof LivewireData, value: unknown, defer?: boolean) => void;
|
|
519
|
+
/**
|
|
520
|
+
* Listening for a Livewire event
|
|
521
|
+
* @param event The event name
|
|
522
|
+
* @param callback The action to perform when the event is emitted
|
|
523
|
+
* @returns
|
|
524
|
+
* @deprecated Use $ version of the method
|
|
525
|
+
*/
|
|
526
|
+
on: (event: string, callback: (...param: Array<unknown>) => unknown) => void;
|
|
527
|
+
/**
|
|
528
|
+
* Dispatch a Livewire event
|
|
529
|
+
* @param event The event name
|
|
530
|
+
* @param params Arguments passed to the event
|
|
531
|
+
* @deprecated Use $ version of the method
|
|
532
|
+
*/
|
|
533
|
+
dispatch: (event: string, ...params: Array<unknown>) => void;
|
|
534
|
+
/**
|
|
535
|
+
* Call a Livewire method
|
|
536
|
+
* @param method The method name
|
|
537
|
+
* @param params Arguments passed to the method
|
|
538
|
+
* @deprecated Use $ version of the method
|
|
539
|
+
*/
|
|
540
|
+
call: (method: string & keyof LivewireMethods, ...params: Array<unknown>) => Promise<LivewireMethods[keyof LivewireMethods]>;
|
|
541
|
+
/**
|
|
542
|
+
* Upload a file and set a Livewire property
|
|
543
|
+
* @param property The property name
|
|
544
|
+
* @param file The file to upload
|
|
545
|
+
* @param finishCallback Called when the upload is finished
|
|
546
|
+
* @param errorCallback Called when the upload encountered an error
|
|
547
|
+
* @param progressCallback Called while processing
|
|
548
|
+
* @deprecated Use $ version of the method
|
|
549
|
+
*/
|
|
550
|
+
upload: (property: string & keyof LivewireData, file: File, finishCallback: (uploadedFilename: string) => void, errorCallback: () => void, progressCallback: (event: CustomEvent) => void) => void;
|
|
551
|
+
/**
|
|
552
|
+
* Upload multiple files at one and set a Livewire property
|
|
553
|
+
* @param property The property name
|
|
554
|
+
* @param files The files to upload
|
|
555
|
+
* @param finishCallback Called when the upload is finished
|
|
556
|
+
* @param errorCallback Called when the upload encountered an error
|
|
557
|
+
* @param progressCallback Called while processing
|
|
558
|
+
* @deprecated Use $ version of the method
|
|
559
|
+
*/
|
|
560
|
+
uploadMultiple: (property: string & keyof LivewireData, files: Array<File>, finishCallback: (uploadedFilenames: Array<string>) => void, errorCallback: () => void, progressCallback: (event: CustomEvent) => void) => void;
|
|
561
|
+
/**
|
|
562
|
+
* Removing (one of) uploaded file(s) and update a Livewire property
|
|
563
|
+
* @param property The property name
|
|
564
|
+
* @param file The file to upload
|
|
565
|
+
* @param finishCallback Called when the upload is finished
|
|
566
|
+
* @param errorCallback Called when the upload encountered an error
|
|
567
|
+
* @param progressCallback Called while processing
|
|
568
|
+
* @deprecated Use $ version of the method
|
|
569
|
+
*/
|
|
570
|
+
removeUpload: (property: string & keyof LivewireData, files: File, finishCallback: (uploadedFilename: string) => void, errorCallback: () => void) => void;
|
|
571
|
+
}
|
|
572
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nolikein/types-livewire3",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Typescript content for Laravel Livewire 3",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Côme Wasik",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"typescript",
|
|
12
|
+
"alpinejs",
|
|
13
|
+
"livewire",
|
|
14
|
+
"livewire 3"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/alpinejs": "^3.13.11",
|
|
24
|
+
"typescript": "^5.9.2"
|
|
25
|
+
}
|
|
26
|
+
}
|