@ktfth/stickjs 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +169 -0
- package/README.md +449 -0
- package/bin/registry.json +20 -0
- package/bin/stickjs.js +158 -0
- package/llms.txt +244 -0
- package/package.json +38 -0
- package/stick-ui/components/accordion.html +25 -0
- package/stick-ui/components/autocomplete.html +82 -0
- package/stick-ui/components/command-palette.html +28 -0
- package/stick-ui/components/copy-button.html +12 -0
- package/stick-ui/components/data-table.html +191 -0
- package/stick-ui/components/dialog.html +23 -0
- package/stick-ui/components/dropdown.html +16 -0
- package/stick-ui/components/notification.html +11 -0
- package/stick-ui/components/skeleton.html +11 -0
- package/stick-ui/components/stepper.html +102 -0
- package/stick-ui/components/tabs.html +26 -0
- package/stick-ui/components/toast.html +10 -0
- package/stick-ui/components/toggle-group.html +16 -0
- package/stick-ui/components/toggle.html +9 -0
- package/stick-ui/components/tooltip.html +12 -0
- package/stick-ui/plugins/autocomplete.js +422 -0
- package/stick-ui/plugins/command-palette.js +289 -0
- package/stick-ui/plugins/data-table.js +426 -0
- package/stick-ui/plugins/dropdown.js +70 -0
- package/stick-ui/plugins/stepper.js +155 -0
- package/stick-ui/plugins/toast.js +51 -0
- package/stick-ui/plugins/tooltip.js +67 -0
- package/stick-ui/stick-ui.css +825 -0
- package/stick.d.ts +105 -0
- package/stick.js +655 -0
package/stick.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stick.js — declarative behavior for HTML elements
|
|
3
|
+
* https://github.com/kaiquekandykoga/Stickjs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Stick.js 3.0.0
|
|
8
|
+
*
|
|
9
|
+
* New in 3.0: error boundary, fire(), on(), group, transition, set-aria, toggle-aria
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Synthetic event passed for the "ready", "watch", and "intersect" events */
|
|
13
|
+
export type StickSyntheticEvent =
|
|
14
|
+
| { type: 'ready' }
|
|
15
|
+
| { type: 'watch' }
|
|
16
|
+
| { type: 'intersect'; entry: IntersectionObserverEntry };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Handler function signature.
|
|
20
|
+
* @param el The trigger element (the one with data-stick)
|
|
21
|
+
* @param param The resolved param string ({{tokens}} already interpolated)
|
|
22
|
+
* @param event The DOM Event, or a synthetic event object
|
|
23
|
+
* @param target The resolved data-stick-target element (falls back to el)
|
|
24
|
+
*/
|
|
25
|
+
export type StickHandler = (
|
|
26
|
+
el: Element,
|
|
27
|
+
param: string,
|
|
28
|
+
event: Event | StickSyntheticEvent,
|
|
29
|
+
target: Element
|
|
30
|
+
) => void | Promise<void>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A Stick plugin. One of:
|
|
34
|
+
* - A function that receives the Stick instance and calls `.add()` on it
|
|
35
|
+
* - An object with an `install(stick)` method (Vue-style)
|
|
36
|
+
* - A plain object mapping handler names to functions
|
|
37
|
+
*/
|
|
38
|
+
export type StickPlugin =
|
|
39
|
+
| ((stick: StickInstance) => void)
|
|
40
|
+
| { install(stick: StickInstance): void }
|
|
41
|
+
| Record<string, StickHandler>;
|
|
42
|
+
|
|
43
|
+
export interface StickInstance {
|
|
44
|
+
/** Semver string, e.g. "2.5.0" */
|
|
45
|
+
readonly version: string;
|
|
46
|
+
|
|
47
|
+
/** Register a named handler. Chainable. */
|
|
48
|
+
add(name: string, fn: StickHandler): this;
|
|
49
|
+
|
|
50
|
+
/** Unregister a named handler. Chainable. */
|
|
51
|
+
remove(name: string): this;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Register a plugin.
|
|
55
|
+
* Accepts: fn(stick), { install(stick) {} }, or { 'handler-name': fn, … }
|
|
56
|
+
* Chainable.
|
|
57
|
+
*/
|
|
58
|
+
use(plugin: StickPlugin): this;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Remove all event listeners from el and clear its data-stick-bound attribute,
|
|
62
|
+
* allowing it to be re-bound cleanly. Chainable.
|
|
63
|
+
*/
|
|
64
|
+
unbind(el: Element): this;
|
|
65
|
+
|
|
66
|
+
/** Enable or disable verbose console logging (dev mode). Chainable. */
|
|
67
|
+
debug(enabled?: boolean): this;
|
|
68
|
+
|
|
69
|
+
/** Register a lifecycle hook. Events: 'bind', 'unbind'. Chainable. */
|
|
70
|
+
on(event: 'bind' | 'unbind', fn: (el: Element) => void): this;
|
|
71
|
+
|
|
72
|
+
/** Frozen snapshot of all registered handler names → functions. */
|
|
73
|
+
readonly handlers: Readonly<Record<string, StickHandler>>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Parse a data-stick attribute value.
|
|
77
|
+
* Returns { event, handler, param } or null if the format is invalid.
|
|
78
|
+
*/
|
|
79
|
+
parse(value: string): { event: string; handler: string; param: string } | null;
|
|
80
|
+
|
|
81
|
+
/** Invoke a handler programmatically on an element. Chainable. */
|
|
82
|
+
fire(el: Element, handler: string, param?: string, event?: Event | StickSyntheticEvent): this;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Bind a single element (attaches its declared listeners).
|
|
86
|
+
* No-op if already bound (data-stick-bound present).
|
|
87
|
+
*/
|
|
88
|
+
bind(el: Element): void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Scan root for [data-stick] elements and bind them.
|
|
92
|
+
* @param root Defaults to document. Chainable.
|
|
93
|
+
*/
|
|
94
|
+
init(root?: Document | Element): this;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Watch root for new [data-stick] elements via MutationObserver and auto-bind them.
|
|
98
|
+
* Called automatically on DOMContentLoaded.
|
|
99
|
+
* @param root Defaults to document.body. Chainable.
|
|
100
|
+
*/
|
|
101
|
+
observe(root?: Element): this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare const Stick: StickInstance;
|
|
105
|
+
export default Stick;
|