mates 0.3.0-beta.3 → 0.3.0-beta.5
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/Directives/customEvent.d.ts +74 -0
- package/dist/Directives/customEvent.d.ts.map +1 -0
- package/dist/Directives/disappear.d.ts +23 -0
- package/dist/Directives/disappear.d.ts.map +1 -0
- package/dist/Directives/eleHook.d.ts.map +1 -1
- package/dist/Directives/htmlHook.d.ts.map +1 -1
- package/dist/Directives/index.d.ts +3 -1
- package/dist/Directives/index.d.ts.map +1 -1
- package/dist/Directives/timerDirective.d.ts +5 -5
- package/dist/Directives/timerDirective.d.ts.map +1 -1
- package/dist/Mutables/Extended Atoms/changeFlagAtom.d.ts +56 -0
- package/dist/Mutables/Extended Atoms/changeFlagAtom.d.ts.map +1 -0
- package/dist/Mutables/Extended Atoms/index.d.ts +1 -0
- package/dist/Mutables/Extended Atoms/index.d.ts.map +1 -1
- package/dist/Mutables/atom/delayAtom.d.ts +40 -0
- package/dist/Mutables/atom/delayAtom.d.ts.map +1 -0
- package/dist/Mutables/atom/index.d.ts +1 -0
- package/dist/Mutables/atom/index.d.ts.map +1 -1
- package/dist/Router/historyStateAtom.d.ts +40 -0
- package/dist/Router/historyStateAtom.d.ts.map +1 -0
- package/dist/Router/historyUtils.d.ts +25 -0
- package/dist/Router/historyUtils.d.ts.map +1 -0
- package/dist/Router/index.d.ts +3 -0
- package/dist/Router/index.d.ts.map +1 -1
- package/dist/Router/navigateTo.d.ts.map +1 -1
- package/dist/Router/navigationRequest.d.ts +75 -0
- package/dist/Router/navigationRequest.d.ts.map +1 -0
- package/dist/Router/pathAtom.d.ts.map +1 -1
- package/dist/Utils/countdown.d.ts +48 -0
- package/dist/Utils/countdown.d.ts.map +1 -0
- package/dist/Utils/index.d.ts +1 -0
- package/dist/Utils/index.d.ts.map +1 -1
- package/dist/index.d.ts +588 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +26 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/portals/floating-container.d.ts +129 -0
- package/dist/portals/floating-container.d.ts.map +1 -0
- package/dist/portals/index.d.ts +4 -2
- package/dist/portals/index.d.ts.map +1 -1
- package/dist/portals/popup.d.ts +20 -3
- package/dist/portals/popup.d.ts.map +1 -1
- package/dist/portals/popupPlacement.d.ts +52 -0
- package/dist/portals/popupPlacement.d.ts.map +1 -0
- package/dist/portals/portal.d.ts +40 -16
- package/dist/portals/portal.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/portals/tip.d.ts +0 -38
- package/dist/portals/tip.d.ts.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { DirectiveResult } from "lit-html/directive.js";
|
|
2
|
+
/**
|
|
3
|
+
* A typed custom event handler. Receives the `detail` payload directly —
|
|
4
|
+
* no need to unwrap `event.detail` manually.
|
|
5
|
+
*/
|
|
6
|
+
export type EleEventHandler<T = unknown> = (detail: T, event: CustomEvent<T>) => void;
|
|
7
|
+
export declare function onEleEvent<T = unknown>(eventName: string, handler: EleEventHandler<T>): DirectiveResult;
|
|
8
|
+
/**
|
|
9
|
+
* `useEleEvent` — call in the **outer function** of a mates component to get
|
|
10
|
+
* a `dispatch` function. Use `dispatch` anywhere in the component (event
|
|
11
|
+
* handlers, effects, async callbacks) to fire a bubbling `CustomEvent` from
|
|
12
|
+
* a specific element.
|
|
13
|
+
*
|
|
14
|
+
* The host element is passed as the first argument to `dispatch` — this is
|
|
15
|
+
* typically the element the event should originate from (e.g. the clicked
|
|
16
|
+
* `<li>`, the focused `<input>`). Events bubble upward and are composed, so
|
|
17
|
+
* any ancestor listening with `onEleEvent` will receive them.
|
|
18
|
+
*
|
|
19
|
+
* No cleanup is needed — `dispatch` just calls `dispatchEvent`, there are no
|
|
20
|
+
* persistent listeners to remove.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { onEleEvent, useEleEvent } from "mates";
|
|
25
|
+
*
|
|
26
|
+
* // ── Child ─────────────────────────────────────────────────────────────────
|
|
27
|
+
* const ListItem = (propsFn) => {
|
|
28
|
+
* const { dispatch } = useEleEvent();
|
|
29
|
+
*
|
|
30
|
+
* return () => html`
|
|
31
|
+
* <li
|
|
32
|
+
* @click=${(e: MouseEvent) =>
|
|
33
|
+
* dispatch(e.currentTarget as HTMLElement, "item-select", {
|
|
34
|
+
* id: propsFn().id,
|
|
35
|
+
* label: propsFn().label,
|
|
36
|
+
* })}
|
|
37
|
+
* >
|
|
38
|
+
* ${propsFn().label}
|
|
39
|
+
* </li>
|
|
40
|
+
* `;
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* // ── Parent ────────────────────────────────────────────────────────────────
|
|
44
|
+
* html`
|
|
45
|
+
* <ul ${onEleEvent("item-select", (detail: { id: string }) => {
|
|
46
|
+
* console.log("selected", detail.id);
|
|
47
|
+
* })}>
|
|
48
|
+
* ${items.map(item => x(ListItem, item))}
|
|
49
|
+
* </ul>
|
|
50
|
+
* `;
|
|
51
|
+
*
|
|
52
|
+
* // ── Dispatching without an element ref (from a button click) ─────────────
|
|
53
|
+
* html`
|
|
54
|
+
* <button @click=${(e: MouseEvent) =>
|
|
55
|
+
* dispatch(e.currentTarget as HTMLElement, "form-submit", { value })}>
|
|
56
|
+
* Submit
|
|
57
|
+
* </button>
|
|
58
|
+
* `;
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function useEleEvent(): {
|
|
62
|
+
/**
|
|
63
|
+
* Dispatch a named `CustomEvent` from the component's host `<x-x>` element.
|
|
64
|
+
*
|
|
65
|
+
* The host is captured once when `useEleEvent()` is called (outer function).
|
|
66
|
+
* The event bubbles and is composed so any ancestor with `onEleEvent` will
|
|
67
|
+
* receive it.
|
|
68
|
+
*
|
|
69
|
+
* @param eventName The custom event name.
|
|
70
|
+
* @param detail Optional typed payload attached as `event.detail`.
|
|
71
|
+
*/
|
|
72
|
+
dispatch<T = unknown>(eventName: string, detail?: T): void;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=customEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customEvent.d.ts","sourceRoot":"","sources":["../../lib/Directives/customEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAM7D;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,OAAO,IAAI,CACzC,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAClB,IAAI,CAAC;AA2EV,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EACpC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,eAAe,CAEjB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,WAAW;IAQvB;;;;;;;;;OASG;aACM,CAAC,uBAAuB,MAAM,WAAW,CAAC,GAAG,IAAI;EAY7D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* disappear — removes the host element from the DOM after `ms` milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* Useful for self-dismissing messages, temporary overlays, or any element
|
|
5
|
+
* that should vanish after a delay without any component re-render.
|
|
6
|
+
*
|
|
7
|
+
* The countdown is cancelled automatically if the element is removed from
|
|
8
|
+
* the DOM before the delay elapses (e.g. parent unmounts).
|
|
9
|
+
*
|
|
10
|
+
* If `ms` changes on re-render a fresh countdown is started from the new value.
|
|
11
|
+
*
|
|
12
|
+
* @param ms Delay in milliseconds before the element is removed.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Remove a toast message after 3 seconds
|
|
16
|
+
* html`<div class="toast" ${disappear(3000)}>Saved!</div>`
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Configurable delay
|
|
20
|
+
* html`<p class="hint" ${disappear(ttl)}>This hint disappears soon.</p>`
|
|
21
|
+
*/
|
|
22
|
+
export declare const disappear: (nextMs: number) => import("lit-html/directive").DirectiveResult;
|
|
23
|
+
//# sourceMappingURL=disappear.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disappear.d.ts","sourceRoot":"","sources":["../../lib/Directives/disappear.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,SAAS,kEAyBpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eleHook.d.ts","sourceRoot":"","sources":["../../lib/Directives/eleHook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAK,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAI1C;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,IAAI;IACnD,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,IAAI,CACjD,CAAC,EAAE,WAAW,EACd,GAAG,IAAI,EAAE,CAAC,KACP,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AAoB5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"eleHook.d.ts","sourceRoot":"","sources":["../../lib/Directives/eleHook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAK,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAI1C;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,IAAI;IACnD,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,IAAI,CACjD,CAAC,EAAE,WAAW,EACd,GAAG,IAAI,EAAE,CAAC,KACP,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AAoB5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,eAAe,CAwHjC;AAED,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlHook.d.ts","sourceRoot":"","sources":["../../lib/Directives/htmlHook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAM/B;;;;;;;;GAQG;AACH,MAAM,MAAM,iB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,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,IAAI,CAClD,MAAM,EAAE,gBAAgB,EACxB,GAAG,IAAI,EAAE,CAAC,KACP,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAoBjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,EAAE,EAC3C,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,eAAe,CAyGjC"}
|
|
@@ -2,6 +2,8 @@ export { $, type DollarChain } from "./$";
|
|
|
2
2
|
export { type AnimatedIfConfig, type AnimatedXConfig, animatedIf, animatedX, } from "./animatedConditional";
|
|
3
3
|
export { type AttrMap, type AttrValue, attr, removeAttr, } from "./attrDirective";
|
|
4
4
|
export { type ClassEntry, type ClassesInput, classes, removeClasses, } from "./classesDirective";
|
|
5
|
+
export { type EleEventHandler, onEleEvent, useEleEvent } from "./customEvent";
|
|
6
|
+
export { disappear } from "./disappear";
|
|
5
7
|
export { type EleHookLifecycle, type EleHookMountFn, eleHook } from "./eleHook";
|
|
6
8
|
export { type HtmlHookLifecycle, type HtmlHookMountFn, type HtmlHookRenderFn, htmlHook, } from "./htmlHook";
|
|
7
9
|
export { type IntersectCallback, type IntersectOptions, onHidden, onIntersect, onVisible, } from "./intersectDirective";
|
|
@@ -13,6 +15,6 @@ export { type MatesCustomEventMap, type OnEventMap, on, on as onEvent, removeOn,
|
|
|
13
15
|
export { type OnParentMap, onParent } from "./onParentDirective";
|
|
14
16
|
export { renderSwitch, type SwitchCase, type SwitchEntry, } from "./renderSwitch";
|
|
15
17
|
export { removeStyle, type StyleMap, type StyleValue, style, } from "./styleDirective";
|
|
16
|
-
export { type TimerContent,
|
|
18
|
+
export { type TimerContent, timerTemplate } from "./timerDirective";
|
|
17
19
|
export { type VirtualListOptions, type VirtualMasonryOptions, virtualList, virtualMasonry, } from "./virtualHelpers";
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/Directives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,UAAU,EACV,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,IAAI,EACJ,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,OAAO,EACP,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,QAAQ,EACR,WAAW,EACX,SAAS,GACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,QAAQ,EACR,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,KAAK,cAAc,GACpB,MAAM,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AM,kBAAkB,CAAC"}
|
|
@@ -20,12 +20,12 @@ export type TimerContent = () => unknown;
|
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
22
22
|
* import { html } from "mates";
|
|
23
|
-
* import {
|
|
23
|
+
* import { timerTemplate } from "mates";
|
|
24
24
|
*
|
|
25
25
|
* // Live clock — updates every second, no component re-render
|
|
26
26
|
* html`
|
|
27
27
|
* <div>
|
|
28
|
-
* Time: ${
|
|
28
|
+
* Time: ${timerTemplate(() => new Date().toLocaleTimeString(), 1000)}
|
|
29
29
|
* </div>
|
|
30
30
|
* `;
|
|
31
31
|
*
|
|
@@ -33,7 +33,7 @@ export type TimerContent = () => unknown;
|
|
|
33
33
|
* const end = Date.now() + 60_000;
|
|
34
34
|
* html`
|
|
35
35
|
* <span>
|
|
36
|
-
* ${
|
|
36
|
+
* ${timerTemplate(() => {
|
|
37
37
|
* const remaining = Math.max(0, Math.ceil((end - Date.now()) / 1000));
|
|
38
38
|
* return remaining === 0 ? "Done!" : `${remaining}s`;
|
|
39
39
|
* }, 1000)}
|
|
@@ -43,10 +43,10 @@ export type TimerContent = () => unknown;
|
|
|
43
43
|
* // Dynamic HTML content
|
|
44
44
|
* html`
|
|
45
45
|
* <div>
|
|
46
|
-
* ${
|
|
46
|
+
* ${timerTemplate(() => html`<strong>${new Date().toLocaleTimeString()}</strong>`, 500)}
|
|
47
47
|
* </div>
|
|
48
48
|
* `;
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
export declare function
|
|
51
|
+
export declare function timerTemplate(callback: TimerContent, ms: number): import("lit-html/directive").DirectiveResult<import("lit-html/directive").DirectiveClass>;
|
|
52
52
|
//# sourceMappingURL=timerDirective.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timerDirective.d.ts","sourceRoot":"","sources":["../../lib/Directives/timerDirective.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC;AA+CzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"timerDirective.d.ts","sourceRoot":"","sources":["../../lib/Directives/timerDirective.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC;AA+CzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,6FAE/D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AtomConfig, AtomType } from "../atom/atom";
|
|
2
|
+
export type ChangeFlagAtomType = AtomType<number> & {
|
|
3
|
+
/**
|
|
4
|
+
* Trigger a reactivity update.
|
|
5
|
+
*
|
|
6
|
+
* - Called with no argument: sets the value to `Math.random()`, guaranteeing
|
|
7
|
+
* a new value every call and forcing all subscribers / effects / views to
|
|
8
|
+
* re-run.
|
|
9
|
+
* - Called with a number: sets the value to that number. Useful when you
|
|
10
|
+
* want a meaningful version counter or a specific sentinel value.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* flag.change(); // random — always triggers
|
|
14
|
+
* flag.change(n + 1); // explicit increment
|
|
15
|
+
*/
|
|
16
|
+
change(value?: number): void;
|
|
17
|
+
/** Discriminator tag — always `"changeFlagAtom"`. */
|
|
18
|
+
readonly name: "changeFlagAtom";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* changeFlagAtom — a reactive number atom whose sole purpose is to force
|
|
22
|
+
* re-renders, effect re-runs, and subscription callbacks.
|
|
23
|
+
*
|
|
24
|
+
* The stored number is intentionally meaningless by default — only the fact
|
|
25
|
+
* that it changed matters. Call `change()` to trigger, or pass a value if
|
|
26
|
+
* you want a meaningful version counter.
|
|
27
|
+
*
|
|
28
|
+
* Pairs well with `disappear` to bring back a disappeared element:
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const flag = changeFlagAtom();
|
|
32
|
+
*
|
|
33
|
+
* // Re-render the element (and restart the disappear timer) each time flag changes
|
|
34
|
+
* return () => html`
|
|
35
|
+
* ${flag()} // read flag so the template re-runs when it changes
|
|
36
|
+
* <div ${disappear(3000)}>I vanish in 3 s</div>
|
|
37
|
+
* <button @click=${() => flag.change()}>Show again</button>
|
|
38
|
+
* `;
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Explicit version counter
|
|
42
|
+
* const version = changeFlagAtom(0);
|
|
43
|
+
* version.change(version() + 1);
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Pair with effect
|
|
47
|
+
* const refresh = changeFlagAtom();
|
|
48
|
+
* effect(() => {
|
|
49
|
+
* refresh(); // subscribe
|
|
50
|
+
* fetchData();
|
|
51
|
+
* });
|
|
52
|
+
* // later:
|
|
53
|
+
* refresh.change(); // re-triggers the effect
|
|
54
|
+
*/
|
|
55
|
+
export declare function changeFlagAtom(initial?: number, config?: AtomConfig): ChangeFlagAtomType;
|
|
56
|
+
//# sourceMappingURL=changeFlagAtom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeFlagAtom.d.ts","sourceRoot":"","sources":["../../../lib/Mutables/Extended Atoms/changeFlagAtom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKzD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG;IAClD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE,MAAU,EACnB,MAAM,CAAC,EAAE,UAAU,GAClB,kBAAkB,CAYpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/Mutables/Extended Atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/Mutables/Extended Atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AtomConfig, type AtomType } from "./atom";
|
|
2
|
+
/**
|
|
3
|
+
* delayAtom — a reactive atom whose `set()` and `update()` calls are applied
|
|
4
|
+
* after a fixed `delay` in milliseconds.
|
|
5
|
+
*
|
|
6
|
+
* Unlike `debouncedAtom`, **every call fires** — there is no cancellation of
|
|
7
|
+
* previous pending writes. Each call schedules its own independent timeout.
|
|
8
|
+
* This makes it useful for "apply this value after N ms" patterns rather than
|
|
9
|
+
* "apply only the last value after N ms of silence".
|
|
10
|
+
*
|
|
11
|
+
* Accepts either a plain initial value or a source {@link AtomType}. When a
|
|
12
|
+
* source atom is provided the delay atom mirrors the source's value, applying
|
|
13
|
+
* the delay to every propagated change.
|
|
14
|
+
*
|
|
15
|
+
* All pending timeouts are cancelled automatically when the atom is disposed
|
|
16
|
+
* via `registerCleanup`.
|
|
17
|
+
*
|
|
18
|
+
* @param initialAtomOrState - A plain initial value, or a source atom to mirror.
|
|
19
|
+
* @param delay - How long to wait (ms) before each `set` / `update` is applied.
|
|
20
|
+
* @param config - Optional atom configuration forwarded to the underlying atom.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Every set fires independently after 1 second:
|
|
24
|
+
* const status = delayAtom("idle", 1000);
|
|
25
|
+
* status.set("loading"); // applied after 1 s
|
|
26
|
+
* status.set("done"); // also applied after 1 s (both fire, in order)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Mirror a source with delay:
|
|
30
|
+
* const immediate = atom(0);
|
|
31
|
+
* const delayed = delayAtom(immediate, 500);
|
|
32
|
+
* immediate.set(42); // delayed reflects 42 after 500 ms
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Useful with disappear — update state after the animation finishes:
|
|
36
|
+
* const visible = delayAtom(true, 300);
|
|
37
|
+
* visible.set(false); // hides the element 300 ms later (after CSS transition)
|
|
38
|
+
*/
|
|
39
|
+
export declare function delayAtom<T>(initialAtomOrState: T | AtomType<T>, delay: number, config?: AtomConfig): AtomType<T>;
|
|
40
|
+
//# sourceMappingURL=delayAtom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delayAtom.d.ts","sourceRoot":"","sources":["../../../lib/Mutables/atom/delayAtom.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAQ,MAAM,QAAQ,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,kBAAkB,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EACnC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,UAAU,GAClB,QAAQ,CAAC,CAAC,CAAC,CA8Db"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/Mutables/atom/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/Mutables/atom/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `historyStateAtom` — a reactive atom that always reflects
|
|
3
|
+
* `window.history.state`.
|
|
4
|
+
*
|
|
5
|
+
* Updated in two situations:
|
|
6
|
+
*
|
|
7
|
+
* 1. **`popstate`** — the user pressed back / forward. The browser restores
|
|
8
|
+
* the state that was associated with that history entry and this atom is
|
|
9
|
+
* set to `event.state`.
|
|
10
|
+
*
|
|
11
|
+
* 2. **`navigateTo(path, replace, data)`** — called directly from
|
|
12
|
+
* `navigateTo.ts` before the pushState / replaceState call so any
|
|
13
|
+
* subscriber reading the atom during the subsequent `pathAtom` update
|
|
14
|
+
* already sees the new state.
|
|
15
|
+
*
|
|
16
|
+
* Hydrated from `window.history.state` at module load time so a hard
|
|
17
|
+
* refresh or direct URL load with pre-existing state is reflected
|
|
18
|
+
* correctly from the very first render.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Pass state when navigating:
|
|
22
|
+
* navigateTo("/users/42", false, { fromList: true, scrollY: 320 });
|
|
23
|
+
*
|
|
24
|
+
* // Read it on the destination page:
|
|
25
|
+
* historyStateAtom(); // { fromList: true, scrollY: 320 }
|
|
26
|
+
*
|
|
27
|
+
* // Back / forward automatically restores the state for that entry.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Drive slide direction based on navigation state:
|
|
31
|
+
* const { direction } = historyStateAtom() ?? {};
|
|
32
|
+
* html`<div class=${direction === "back" ? "slide-right" : "slide-left"}>…</div>`
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Guard: know whether the user arrived via in-app nav or direct load:
|
|
36
|
+
* const state = historyStateAtom();
|
|
37
|
+
* if (!state?.fromApp) navigateTo("/");
|
|
38
|
+
*/
|
|
39
|
+
export declare const historyStateAtom: import("../Mutables/atom/atom").AtomType<unknown>;
|
|
40
|
+
//# sourceMappingURL=historyStateAtom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historyStateAtom.d.ts","sourceRoot":"","sources":["../../lib/Router/historyStateAtom.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,gBAAgB,mDAE5B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace dynamic route params in the current URL using a **pattern** that
|
|
3
|
+
* describes which segments are params.
|
|
4
|
+
*
|
|
5
|
+
* The pattern tells `replaceParams` the *names* of the dynamic segments —
|
|
6
|
+
* the current path provides the *positions*. Together they let you swap out
|
|
7
|
+
* individual param values without touching the rest of the URL.
|
|
8
|
+
*
|
|
9
|
+
* Uses `replaceState` — no new history entry is created.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Current path: /users/42/posts/7
|
|
13
|
+
* replaceParams("/users/:id/posts/:postId", { id: 99 });
|
|
14
|
+
* // → /users/99/posts/7
|
|
15
|
+
*
|
|
16
|
+
* replaceParams("/users/:id/posts/:postId", { id: 99, postId: 3 });
|
|
17
|
+
* // → /users/99/posts/3
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param pattern Route pattern with `:param` segments (e.g. `"/users/:id"`).
|
|
21
|
+
* @param params Param names → new values. Only provided keys are replaced;
|
|
22
|
+
* all other segments are left unchanged.
|
|
23
|
+
*/
|
|
24
|
+
export declare function replaceParams(pattern: string, params: Record<string, string | number | boolean>): void;
|
|
25
|
+
//# sourceMappingURL=historyUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../lib/Router/historyUtils.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAChD,IAAI,CA0CN"}
|
package/dist/Router/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export { type AnimatedRouteConfig, type AnimatedRouterOptions, animatedRouter, } from "./animatedRouter";
|
|
2
2
|
export { buildPath } from "./buildPath";
|
|
3
3
|
export { hashAtom } from "./hashAtom";
|
|
4
|
+
export { historyStateAtom } from "./historyStateAtom";
|
|
5
|
+
export { replaceParams } from "./historyUtils";
|
|
4
6
|
export { isPathMatching } from "./isPathMatching";
|
|
5
7
|
export { location } from "./location";
|
|
6
8
|
export { navigateTo } from "./navigateTo";
|
|
7
9
|
export { lockNavigation, navigationLocked, unlockNavigation, } from "./navigationLock";
|
|
10
|
+
export { type NavigationRequestDetail, navigationRequestEvent, onNavigationRequest, } from "./navigationRequest";
|
|
8
11
|
export { pathAtom } from "./pathAtom";
|
|
9
12
|
export { qsAtom } from "./qsAtom";
|
|
10
13
|
export { Router, route } from "./Router";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/Router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,E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,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigateTo.d.ts","sourceRoot":"","sources":["../../lib/Router/navigateTo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"navigateTo.d.ts","sourceRoot":"","sources":["../../lib/Router/navigateTo.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CA8C5E"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface NavigationRequestDetail {
|
|
2
|
+
/** The path the user is navigating to. */
|
|
3
|
+
to: string;
|
|
4
|
+
/** The path the user is currently on. */
|
|
5
|
+
from: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fired by `navigateTo()` immediately before navigation is committed.
|
|
9
|
+
*
|
|
10
|
+
* Subscribe with `on()` in a component's outer function to react to every
|
|
11
|
+
* navigation attempt — for example to show a "leave page?" confirmation dialog
|
|
12
|
+
* before the route actually changes.
|
|
13
|
+
*
|
|
14
|
+
* The event carries `{ to, from }` so you always know both endpoints.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { navigationRequestEvent } from "mates";
|
|
19
|
+
* import { on } from "mates";
|
|
20
|
+
*
|
|
21
|
+
* const MyPage = () => {
|
|
22
|
+
* const confirm = useConfirmDialog({ danger: false });
|
|
23
|
+
*
|
|
24
|
+
* on(async ({ to }) => {
|
|
25
|
+
* const ok = await confirm.show(`Leave to ${to}?`);
|
|
26
|
+
* if (!ok) lockNavigation();
|
|
27
|
+
* }, [navigationRequestEvent]);
|
|
28
|
+
*
|
|
29
|
+
* return () => html`…`;
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const navigationRequestEvent: import("../Mutables/events/events").EventType<NavigationRequestDetail>;
|
|
34
|
+
/**
|
|
35
|
+
* `onNavigationRequest` — component-scoped hook that fires whenever
|
|
36
|
+
* `navigateTo()` is called, **before** the navigation is committed.
|
|
37
|
+
*
|
|
38
|
+
* Exactly mirrors the `onNavigate` pattern but fires at request time rather
|
|
39
|
+
* than after the route has already changed. Use it to:
|
|
40
|
+
* - Show a "you have unsaved changes" dialog
|
|
41
|
+
* - Conditionally lock navigation with `lockNavigation()`
|
|
42
|
+
* - Log analytics for navigation intent
|
|
43
|
+
*
|
|
44
|
+
* The callback receives `{ to, from }` and may optionally return a cleanup
|
|
45
|
+
* function that runs before the next invocation.
|
|
46
|
+
*
|
|
47
|
+
* Must be called in the **outer function** of a mates component.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { onNavigationRequest, lockNavigation, unlockNavigation } from "mates";
|
|
52
|
+
*
|
|
53
|
+
* const EditorPage = () => {
|
|
54
|
+
* const isDirty = atom(false);
|
|
55
|
+
* const confirm = useConfirmDialog();
|
|
56
|
+
*
|
|
57
|
+
* onNavigationRequest(async ({ to }) => {
|
|
58
|
+
* if (!isDirty()) return;
|
|
59
|
+
* const ok = await confirm.show("Leave without saving?", {
|
|
60
|
+
* yesLabel: "Leave",
|
|
61
|
+
* noLabel: "Stay",
|
|
62
|
+
* });
|
|
63
|
+
* if (!ok) {
|
|
64
|
+
* lockNavigation();
|
|
65
|
+
* // re-unlock so future navigation works after user decides to stay
|
|
66
|
+
* Promise.resolve().then(unlockNavigation);
|
|
67
|
+
* }
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* return () => html`…`;
|
|
71
|
+
* };
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare const onNavigationRequest: (fn: (detail: NavigationRequestDetail) => void | (() => void)) => void;
|
|
75
|
+
//# sourceMappingURL=navigationRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationRequest.d.ts","sourceRoot":"","sources":["../../lib/Router/navigationRequest.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAID;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,sBAAsB,wEAElC,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,mBAAmB,GAC9B,IAAI,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,KAC3D,IAUF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathAtom.d.ts","sourceRoot":"","sources":["../../lib/Router/pathAtom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pathAtom.d.ts","sourceRoot":"","sources":["../../lib/Router/pathAtom.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,uDAEpB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type CountdownState = "idle" | "running" | "paused" | "stopped";
|
|
2
|
+
export interface Countdown {
|
|
3
|
+
/** Start the timer from the full duration. No-op if already running. */
|
|
4
|
+
start(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Pause the timer. The remaining time is frozen at the current value.
|
|
7
|
+
* No-op if already paused, idle, or stopped.
|
|
8
|
+
*/
|
|
9
|
+
pause(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Resume a paused timer. Restarts a `setTimeout` for the remaining duration.
|
|
12
|
+
* No-op if already running, idle, or stopped.
|
|
13
|
+
*/
|
|
14
|
+
resume(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Stop and reset the timer. The callback will never fire.
|
|
17
|
+
* Remaining time is reset to the full duration.
|
|
18
|
+
* Calling start() after stop() begins a fresh countdown.
|
|
19
|
+
*/
|
|
20
|
+
stop(): void;
|
|
21
|
+
/** Current state of the timer. */
|
|
22
|
+
readonly state: CountdownState;
|
|
23
|
+
/**
|
|
24
|
+
* Milliseconds remaining.
|
|
25
|
+
* - While `running`: live value computed from wall-clock elapsed.
|
|
26
|
+
* - While `paused` / `idle` / `stopped`: last frozen snapshot.
|
|
27
|
+
*/
|
|
28
|
+
readonly remaining: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* timer — precise pausable countdown timer.
|
|
32
|
+
*
|
|
33
|
+
* @param callback Called once when the full duration has elapsed.
|
|
34
|
+
* @param duration Total countdown duration in milliseconds.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const { start, pause, resume, stop, remaining } = timer(() => {
|
|
38
|
+
* dismiss(id);
|
|
39
|
+
* }, 6000);
|
|
40
|
+
*
|
|
41
|
+
* start();
|
|
42
|
+
* // user hovers card
|
|
43
|
+
* pause();
|
|
44
|
+
* // user leaves card
|
|
45
|
+
* resume();
|
|
46
|
+
*/
|
|
47
|
+
export declare function countdown(callback: () => void, duration: number): Countdown;
|
|
48
|
+
//# sourceMappingURL=countdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countdown.d.ts","sourceRoot":"","sources":["../../lib/Utils/countdown.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEvE,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,KAAK,IAAI,IAAI,CAAC;IACd;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;;OAGG;IACH,MAAM,IAAI,IAAI,CAAC;IACf;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAAC;IACb,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CA6G3E"}
|
package/dist/Utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/Utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/Utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|