phoenix_live_view 1.2.0 → 1.2.2

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.
Files changed (30) hide show
  1. package/assets/js/phoenix_live_view/dom.ts +3 -1
  2. package/assets/js/phoenix_live_view/dom_patch.ts +1 -1
  3. package/assets/js/phoenix_live_view/live_socket.ts +16 -9
  4. package/assets/js/phoenix_live_view/view.ts +6 -0
  5. package/assets/js/types/assets/js/phoenix_live_view/aria.d.ts +9 -0
  6. package/assets/js/types/assets/js/phoenix_live_view/browser.d.ts +20 -0
  7. package/assets/js/types/assets/js/phoenix_live_view/constants.d.ts +98 -0
  8. package/assets/js/types/assets/js/phoenix_live_view/dom.d.ts +82 -0
  9. package/assets/js/types/assets/js/phoenix_live_view/dom_patch.d.ts +65 -0
  10. package/assets/js/types/assets/js/phoenix_live_view/dom_post_morph_restorer.d.ts +8 -0
  11. package/assets/js/types/assets/js/phoenix_live_view/element_ref.d.ts +14 -0
  12. package/assets/js/types/assets/js/phoenix_live_view/entry_uploader.d.ts +16 -0
  13. package/assets/js/types/assets/js/phoenix_live_view/hooks.d.ts +3 -0
  14. package/assets/js/types/assets/js/phoenix_live_view/index.d.ts +48 -0
  15. package/assets/js/types/assets/js/phoenix_live_view/js.d.ts +99 -0
  16. package/assets/js/types/assets/js/phoenix_live_view/js_commands.d.ts +225 -0
  17. package/assets/js/types/assets/js/phoenix_live_view/live_socket.d.ts +315 -0
  18. package/assets/js/types/assets/js/phoenix_live_view/live_uploader.d.ts +29 -0
  19. package/assets/js/types/assets/js/phoenix_live_view/rendered.d.ts +50 -0
  20. package/assets/js/types/assets/js/phoenix_live_view/upload_entry.d.ts +42 -0
  21. package/assets/js/types/assets/js/phoenix_live_view/utils.d.ts +15 -0
  22. package/assets/js/types/assets/js/phoenix_live_view/view.d.ts +1 -0
  23. package/assets/js/types/assets/js/phoenix_live_view/view_hook.d.ts +279 -0
  24. package/package.json +2 -2
  25. package/priv/static/phoenix_live_view.cjs.js +16 -9
  26. package/priv/static/phoenix_live_view.cjs.js.map +2 -2
  27. package/priv/static/phoenix_live_view.esm.js +16 -9
  28. package/priv/static/phoenix_live_view.esm.js.map +2 -2
  29. package/priv/static/phoenix_live_view.js +16 -9
  30. package/priv/static/phoenix_live_view.min.js +4 -4
@@ -411,7 +411,9 @@ const DOM = {
411
411
  // we also clear the throttle timeout to prevent the callback
412
412
  // from being called again after the timeout fires
413
413
  clearTimeout(this.private(el, THROTTLED));
414
- this.triggerCycle(el, DEBOUNCE_TRIGGER);
414
+ if (asyncFilter()) {
415
+ this.triggerCycle(el, DEBOUNCE_TRIGGER);
416
+ }
415
417
  });
416
418
  }
417
419
  }
@@ -792,7 +792,7 @@ export default class DOMPatch {
792
792
  private transitionPendingRemoves() {
793
793
  const { pendingRemoves, liveSocket } = this;
794
794
  if (pendingRemoves.length > 0) {
795
- liveSocket.transitionRemoves(pendingRemoves, () => {
795
+ liveSocket.transitionRemoves(pendingRemoves, this.view, () => {
796
796
  pendingRemoves.forEach((el) => {
797
797
  const child = DOM.firstPhxChild(el);
798
798
  if (child) {
@@ -823,12 +823,15 @@ export default class LiveSocket {
823
823
  ).filter((el) => !DOM.isChildOfAny(el, stickies));
824
824
 
825
825
  const newMainEl = DOM.cloneNode(this.outgoingMainEl, "");
826
- this.main.showLoader(this.loaderTimeout);
827
- this.main.destroy();
826
+ const oldMainView = this.main;
827
+ oldMainView.showLoader(this.loaderTimeout);
828
+ oldMainView.destroy();
828
829
 
829
830
  this.main = this.newRootView(newMainEl, flash, liveReferer);
830
831
  this.main.setRedirect(href);
831
- this.transitionRemoves(removeEls);
832
+ // the old view is destroyed at this point; pass it explicitly so the
833
+ // phx-remove commands execute in the context of the outgoing view
834
+ this.transitionRemoves(removeEls, oldMainView);
832
835
  this.main.join((joinCount, onDone) => {
833
836
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
834
837
  this.requestDOMUpdate(() => {
@@ -845,7 +848,7 @@ export default class LiveSocket {
845
848
  }
846
849
 
847
850
  /** @internal */
848
- transitionRemoves(elements, callback?) {
851
+ transitionRemoves(elements, view: View, callback?) {
849
852
  const removeAttr = this.binding("remove");
850
853
  const silenceEvents = (e) => {
851
854
  e.preventDefault();
@@ -857,7 +860,8 @@ export default class LiveSocket {
857
860
  for (const event of this.boundEventNames) {
858
861
  el.addEventListener(event, silenceEvents, true);
859
862
  }
860
- this.execJS(el, el.getAttribute(removeAttr), "remove");
863
+ const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
864
+ JS.exec(e, "remove", el.getAttribute(removeAttr), view, el);
861
865
  });
862
866
  // remove the silenced listeners when transitions are done in case the element is re-used
863
867
  // and call caller's callback as soon as we are done with transitions
@@ -885,12 +889,15 @@ export default class LiveSocket {
885
889
 
886
890
  /** @internal */
887
891
  owner(childEl: Element, callback?: (view: View) => any) {
888
- let view: View;
892
+ let view: View | undefined;
889
893
  const viewEl = DOM.closestViewEl(childEl);
890
894
  if (viewEl) {
891
- // it can happen that we find a view that is already destroyed;
892
- // in that case we DO NOT want to fallback to the main element
893
- view = this.getViewByEl(viewEl);
895
+ // resolve the view by element identity instead of id; during live
896
+ // navigation the new view is registered under the same id while the
897
+ // old DOM is still attached, and events from the old DOM must not be
898
+ // routed to the new view. A destroyed view removes its element binding,
899
+ // in which case we DO NOT want to fallback to the main element
900
+ view = DOM.private(viewEl, "view");
894
901
  } else {
895
902
  if (!childEl.isConnected) {
896
903
  // if the element is not part of the DOM any more
@@ -408,6 +408,7 @@ export default class View {
408
408
  if (container) {
409
409
  const [tag, attrs] = container;
410
410
  this.el = DOM.replaceRootContainer(this.el, tag, attrs);
411
+ DOM.putPrivate(this.el, "view", this);
411
412
  }
412
413
  this.childJoins = 0;
413
414
  this.joinPending = true;
@@ -516,7 +517,10 @@ export default class View {
516
517
  if (!el) {
517
518
  throw new Error("unable to find root element for view");
518
519
  }
520
+ // child views are initially bound to an element inside the join HTML
521
+ // fragment (see onJoinComplete), so the binding must move to the real el
519
522
  this.el = el;
523
+ DOM.putPrivate(this.el, "view", this);
520
524
  this.el.setAttribute(PHX_ROOT_ID, this.root.id);
521
525
  }
522
526
 
@@ -746,6 +750,7 @@ export default class View {
746
750
  });
747
751
 
748
752
  // because we work with a template element, we must manually copy the attributes
753
+ // and bind the template root to this view,
749
754
  // otherwise the owner / target helpers don't work properly
750
755
  const rootEl = template.content.firstElementChild!;
751
756
  rootEl.id = this.id;
@@ -753,6 +758,7 @@ export default class View {
753
758
  rootEl.setAttribute(PHX_SESSION, this.getSession());
754
759
  rootEl.setAttribute(PHX_STATIC, this.getStatic() ?? "");
755
760
  this.parent && rootEl.setAttribute(PHX_PARENT_ID, this.parent.id);
761
+ DOM.putPrivate(rootEl, "view", this);
756
762
 
757
763
  // we go over all form elements in the new HTML for the LV
758
764
  // and look for old forms in the `formsForRecovery` object;
@@ -0,0 +1,9 @@
1
+ declare const ARIA: {
2
+ anyOf(instance: unknown, classes: (new (...args: any[]) => unknown)[]): boolean;
3
+ isFocusable(el: Element, interactiveOnly?: boolean): boolean;
4
+ attemptFocus(el: Element, interactiveOnly?: boolean): boolean;
5
+ focusFirstInteractive(el: Element): boolean;
6
+ focusFirst(el: Element): boolean;
7
+ focusLast(el: Element): boolean;
8
+ };
9
+ export default ARIA;
@@ -0,0 +1,20 @@
1
+ declare const Browser: {
2
+ canPushState(): boolean;
3
+ dropLocal(localStorage: any, namespace: any, subkey: any): any;
4
+ updateLocal(localStorage: any, namespace: any, subkey: any, initial: any, func: any): any;
5
+ getLocal(localStorage: any, namespace: any, subkey: any): any;
6
+ updateCurrentState(callback: any): void;
7
+ pushState(kind: "replace" | "push", meta: {
8
+ type: string;
9
+ scroll?: number;
10
+ id?: string;
11
+ position?: number;
12
+ }, to?: string): void;
13
+ setCookie(name: string, value: string | number, maxAgeSeconds?: number): void;
14
+ getCookie(name: string): string;
15
+ deleteCookie(name: string): void;
16
+ redirect(toURL: string, flash?: string | null, navigate?: (url: string) => void): void;
17
+ localKey(namespace: any, subkey: any): string;
18
+ getHashTargetEl(maybeHash: any): HTMLElement;
19
+ };
20
+ export default Browser;
@@ -0,0 +1,98 @@
1
+ export declare const CONSECUTIVE_RELOADS = "consecutive-reloads";
2
+ export declare const MAX_RELOADS = 10;
3
+ export declare const RELOAD_JITTER_MIN = 5000;
4
+ export declare const RELOAD_JITTER_MAX = 10000;
5
+ export declare const FAILSAFE_JITTER = 30000;
6
+ export declare const PHX_EVENT_CLASSES: string[];
7
+ export declare const PHX_DROP_TARGET_ACTIVE_CLASS = "phx-drop-target-active";
8
+ export declare const PHX_COMPONENT = "data-phx-component";
9
+ export declare const PHX_VIEW_REF = "data-phx-view";
10
+ export declare const PHX_LIVE_LINK = "data-phx-link";
11
+ export declare const PHX_TRACK_STATIC = "track-static";
12
+ export declare const PHX_LINK_STATE = "data-phx-link-state";
13
+ export declare const PHX_REF_LOADING = "data-phx-ref-loading";
14
+ export declare const PHX_REF_SRC = "data-phx-ref-src";
15
+ export declare const PHX_REF_LOCK = "data-phx-ref-lock";
16
+ export declare const PHX_PENDING_REFS = "phx-pending-refs";
17
+ export declare const PHX_TRACK_UPLOADS = "track-uploads";
18
+ export declare const PHX_UPLOAD_REF = "data-phx-upload-ref";
19
+ export declare const PHX_PREFLIGHTED_REFS = "data-phx-preflighted-refs";
20
+ export declare const PHX_DONE_REFS = "data-phx-done-refs";
21
+ export declare const PHX_DROP_TARGET = "drop-target";
22
+ export declare const PHX_ACTIVE_ENTRY_REFS = "data-phx-active-refs";
23
+ export declare const PHX_LIVE_FILE_UPDATED = "phx:live-file:updated";
24
+ export declare const PHX_SKIP = "data-phx-skip";
25
+ export declare const PHX_MAGIC_ID = "data-phx-id";
26
+ export declare const PHX_PRUNE = "data-phx-prune";
27
+ export declare const PHX_CONNECTED_CLASS = "phx-connected";
28
+ export declare const PHX_LOADING_CLASS = "phx-loading";
29
+ export declare const PHX_ERROR_CLASS = "phx-error";
30
+ export declare const PHX_CLIENT_ERROR_CLASS = "phx-client-error";
31
+ export declare const PHX_SERVER_ERROR_CLASS = "phx-server-error";
32
+ export declare const PHX_PARENT_ID = "data-phx-parent-id";
33
+ export declare const PHX_MAIN = "data-phx-main";
34
+ export declare const PHX_ROOT_ID = "data-phx-root-id";
35
+ export declare const PHX_VIEWPORT_TOP = "viewport-top";
36
+ export declare const PHX_VIEWPORT_BOTTOM = "viewport-bottom";
37
+ export declare const PHX_VIEWPORT_OVERRUN_TARGET = "viewport-overrun-target";
38
+ export declare const PHX_TRIGGER_ACTION = "trigger-action";
39
+ export declare const PHX_HAS_FOCUSED = "phx-has-focused";
40
+ export declare const FOCUSABLE_INPUTS: string[];
41
+ export declare const CHECKABLE_INPUTS: string[];
42
+ export declare const PHX_HAS_SUBMITTED = "phx-has-submitted";
43
+ export declare const PHX_SESSION = "data-phx-session";
44
+ export declare const PHX_VIEW_SELECTOR = "[data-phx-session]";
45
+ export declare const PHX_STICKY = "data-phx-sticky";
46
+ export declare const PHX_STATIC = "data-phx-static";
47
+ export declare const PHX_READONLY = "data-phx-readonly";
48
+ export declare const PHX_DISABLED = "data-phx-disabled";
49
+ export declare const PHX_DISABLE_WITH = "disable-with";
50
+ export declare const PHX_DISABLE_WITH_RESTORE = "data-phx-disable-with-restore";
51
+ export declare const PHX_HOOK = "hook";
52
+ export declare const PHX_DEBOUNCE = "debounce";
53
+ export declare const PHX_THROTTLE = "throttle";
54
+ export declare const PHX_UPDATE = "update";
55
+ export declare const PHX_STREAM = "stream";
56
+ export declare const PHX_STREAM_REF = "data-phx-stream";
57
+ export declare const PHX_PORTAL = "data-phx-portal";
58
+ export declare const PHX_TELEPORTED_REF = "data-phx-teleported";
59
+ export declare const PHX_TELEPORTED_SRC = "data-phx-teleported-src";
60
+ export declare const PHX_RUNTIME_HOOK = "data-phx-runtime-hook";
61
+ export declare const PHX_LV_PID = "data-phx-pid";
62
+ export declare const PHX_KEY = "key";
63
+ export declare const PHX_PRIVATE = "phxPrivate";
64
+ export declare const PHX_AUTO_RECOVER = "auto-recover";
65
+ export declare const PHX_NO_UNUSED_FIELD = "no-unused-field";
66
+ export declare const PHX_LV_DEBUG = "phx:live-socket:debug";
67
+ export declare const PHX_LV_PROFILE = "phx:live-socket:profiling";
68
+ export declare const PHX_LV_LATENCY_SIM = "phx:live-socket:latency-sim";
69
+ export declare const PHX_LV_HISTORY_POSITION = "phx:nav-history-position";
70
+ export declare const PHX_PROGRESS = "progress";
71
+ export declare const PHX_MOUNTED = "mounted";
72
+ export declare const PHX_RELOAD_STATUS = "__phoenix_reload_status__";
73
+ export declare const LOADER_TIMEOUT = 1;
74
+ export declare const MAX_CHILD_JOIN_ATTEMPTS = 3;
75
+ export declare const BEFORE_UNLOAD_LOADER_TIMEOUT = 200;
76
+ export declare const DISCONNECTED_TIMEOUT = 500;
77
+ export declare const BINDING_PREFIX = "phx-";
78
+ export declare const PUSH_TIMEOUT = 30000;
79
+ export declare const LINK_HEADER = "x-requested-with";
80
+ export declare const RESPONSE_URL_HEADER = "x-response-url";
81
+ export declare const DEBOUNCE_TRIGGER = "debounce-trigger";
82
+ export declare const THROTTLED = "throttled";
83
+ export declare const DEBOUNCE_PREV_KEY = "debounce-prev-key";
84
+ export declare const DEFAULTS: {
85
+ debounce: number;
86
+ throttle: number;
87
+ };
88
+ export declare const PHX_PENDING_ATTRS: string[];
89
+ export declare const STATIC = "s";
90
+ export declare const ROOT = "r";
91
+ export declare const COMPONENTS = "c";
92
+ export declare const KEYED = "k";
93
+ export declare const KEYED_COUNT = "kc";
94
+ export declare const EVENTS = "e";
95
+ export declare const REPLY = "r";
96
+ export declare const TITLE = "t";
97
+ export declare const TEMPLATES = "p";
98
+ export declare const STREAM = "stream";
@@ -0,0 +1,82 @@
1
+ export type FormInputLike = HTMLElement & {
2
+ readonly form?: HTMLFormElement | null;
3
+ readonly type?: string;
4
+ readonly validity?: ValidityState;
5
+ readonly name?: string;
6
+ };
7
+ export type QueryableNode = Element | Document | DocumentFragment;
8
+ declare const DOM: {
9
+ byId(id: any): void | HTMLElement;
10
+ elementFromTarget(target: EventTarget): Element | null;
11
+ removeClass(el: any, className: any): void;
12
+ all(node: QueryableNode | null, query: string, callback?: (el: Element) => void): Element[];
13
+ childNodeLength(html: any): number;
14
+ isUploadInput(el: any): el is HTMLInputElement;
15
+ isAutoUpload(inputEl: any): any;
16
+ findUploadInputs(node: any): HTMLInputElement[];
17
+ findComponent(viewId: string, cid: string | number, doc?: QueryableNode): Element | null;
18
+ getComponent(viewId: string, cid: number, doc?: QueryableNode): Element;
19
+ isPhxDestroyed(node: any): boolean;
20
+ wantsNewTab(e: any): any;
21
+ isUnloadableFormSubmit(e: any): boolean;
22
+ isNewPageClick(e: any, currentLocation: any): any;
23
+ markPhxChildDestroyed(el: any): void;
24
+ findPhxChildrenInFragment(html: any, parentId: any): any;
25
+ isIgnored(el: any, phxUpdate: any): boolean;
26
+ isPhxUpdate(el: any, phxUpdate: any, updateTypes: any): boolean;
27
+ findPhxSticky(el: any): any;
28
+ findPhxChildren(el: any, parentId: any): any;
29
+ findExistingParentCIDs(viewId: any, cids: any): Set<unknown>;
30
+ private(el: any, key: any): any;
31
+ deletePrivate(el: any, key: any): void;
32
+ putPrivate(el: any, key: any, value: any): void;
33
+ updatePrivate(el: any, key: any, defaultVal: any, updateFunc: any): void;
34
+ syncPendingAttrs(fromEl: any, toEl: any): void;
35
+ copyPrivates(target: any, source: any): void;
36
+ putTitle(str: any): void;
37
+ debounce(el: any, event: any, phxDebounce: any, defaultDebounce: any, phxThrottle: any, defaultThrottle: any, asyncFilter: any, callback: any): any;
38
+ triggerCycle(el: any, key: any, currentCycle?: any): void;
39
+ once(el: any, key: any): boolean;
40
+ incCycle(el: any, key: any, trigger?: () => void): any;
41
+ maintainPrivateHooks(fromEl: any, toEl: any, phxViewportTop: any, phxViewportBottom: any): void;
42
+ putCustomElHook(el: any, hook: any): void;
43
+ getCustomElHook(el: any): any;
44
+ isUsedInput(el: any): any;
45
+ resetForm(form: any): void;
46
+ isPhxChild(node: any): any;
47
+ isPhxSticky(node: any): boolean;
48
+ isChildOfAny(el: any, parents: any): boolean;
49
+ firstPhxChild(el: any): any;
50
+ isPortalTemplate(el: any): el is HTMLTemplateElement;
51
+ closestViewEl(el: any): any;
52
+ dispatchEvent(target: any, name: any, opts?: {
53
+ bubbles?: boolean;
54
+ detail?: any;
55
+ }): void;
56
+ cloneNode(node: any, html: any): any;
57
+ mergeAttrs(target: any, source: any, opts?: {
58
+ exclude?: string[];
59
+ isIgnored?: boolean;
60
+ }): void;
61
+ mergeFocusedInput(target: any, source: any): void;
62
+ hasSelectionRange(el: any): el is HTMLInputElement | HTMLTextAreaElement;
63
+ restoreFocus(focused: any, selectionStart: any, selectionEnd: any): void;
64
+ /**
65
+ * Returns true if the element is an input that can be focused and edited by the user,
66
+ * so we can skip patching it if it has focus.
67
+ */
68
+ isEditableInput(el: Element | EventTarget | null): el is FormInputLike;
69
+ isFormAssociated(el: Element | EventTarget | null): el is FormInputLike;
70
+ syncAttrsToProps(el: any): void;
71
+ isTextualInput(el: any): boolean;
72
+ isNowTriggerFormExternal(el: any, phxTriggerExternal: any): boolean;
73
+ cleanChildNodes(container: Element, phxUpdate: string): void;
74
+ replaceRootContainer(container: Element, tagName: string, attrs: Record<string, string>): Element;
75
+ getSticky(el: any, name: any, defaultVal: any): any;
76
+ deleteSticky(el: any, name: any): void;
77
+ putSticky(el: any, name: any, op: any): void;
78
+ applyStickyOperations(el: any): void;
79
+ isLocked(el: any): any;
80
+ attributeIgnored(attribute: any, ignoredAttributes: any): any;
81
+ };
82
+ export default DOM;
@@ -0,0 +1,65 @@
1
+ import View from "./view";
2
+ type Stream = Set<any>;
3
+ type BeforeUpdatedCallback = (fromEl: Element, toEl: Element) => void;
4
+ type AfterAddedCallback = (el: Node) => void;
5
+ type AfterUpdatedCallback = (el: Element) => void;
6
+ type AfterPhxChildAddedCallback = (el: Element) => void;
7
+ type AfterDiscardedCallback = (el: Node) => void;
8
+ type AfterTransitionsDiscardedCallback = (els: Element[]) => void;
9
+ export default class DOMPatch {
10
+ private view;
11
+ private liveSocket;
12
+ private container;
13
+ private rootID;
14
+ private html;
15
+ private streams;
16
+ private streamInserts;
17
+ private streamComponentRestore;
18
+ private targetCID;
19
+ private pendingRemoves;
20
+ private phxRemove;
21
+ private targetContainer;
22
+ private beforeUpdatedCallbacks;
23
+ private afterAddedCallbacks;
24
+ private afterUpdatedCallbacks;
25
+ private afterPhxChildAddedCallbacks;
26
+ private afterDiscardedCallbacks;
27
+ private afterTransitionsDiscardedCallbacks;
28
+ private withChildren;
29
+ private undoRef;
30
+ constructor(view: View, container: Element, html: string | Node, streams: Set<Stream>, targetCID: number | null, opts?: {
31
+ withChildren?: boolean;
32
+ undoRef?: number;
33
+ });
34
+ beforeUpdated(callback: BeforeUpdatedCallback): void;
35
+ afterAdded(callback: AfterAddedCallback): void;
36
+ afterUpdated(callback: AfterUpdatedCallback): void;
37
+ afterPhxChildAdded(callback: AfterPhxChildAddedCallback): void;
38
+ afterDiscarded(callback: AfterDiscardedCallback): void;
39
+ afterTransitionsDiscarded(callback: AfterTransitionsDiscardedCallback): void;
40
+ markPrunableContentForRemoval(): void;
41
+ perform(isJoinPatch: any): boolean;
42
+ private trackBeforeUpdated;
43
+ private trackAfterAdded;
44
+ private trackAfterUpdated;
45
+ private trackAfterPhxChildAdded;
46
+ private trackAfterDiscarded;
47
+ private trackAfterTransitionsDiscarded;
48
+ private onNodeDiscarded;
49
+ private maybePendingRemove;
50
+ private removeStreamChildElement;
51
+ private getStreamInsert;
52
+ private setStreamRef;
53
+ private maybeReOrderStream;
54
+ private moveOrInsertBefore;
55
+ private maybeLimitStream;
56
+ private transitionPendingRemoves;
57
+ private isChangedSelect;
58
+ private skipCIDSibling;
59
+ private maybeCloneLockedElement;
60
+ private copyNestedPrivateLock;
61
+ private indexOf;
62
+ private teleport;
63
+ private handleRuntimeHook;
64
+ }
65
+ export {};
@@ -0,0 +1,8 @@
1
+ export default class DOMPostMorphRestorer {
2
+ private containerId;
3
+ private updateType;
4
+ private elementsToModify;
5
+ private elementIdsToAdd;
6
+ constructor(containerBefore: Element, containerAfter: Element, updateType: "append" | "prepend");
7
+ perform(): void;
8
+ }
@@ -0,0 +1,14 @@
1
+ export default class ElementRef {
2
+ static onUnlock(el: any, callback: any): any;
3
+ private el;
4
+ private loadingRef;
5
+ private lockRef;
6
+ constructor(el: Element);
7
+ maybeUndo(ref: any, phxEvent: any, eachCloneCallback: any): void;
8
+ private isWithin;
9
+ private undoLocks;
10
+ private undoLoading;
11
+ private isLoadingUndoneBy;
12
+ private isFullyResolvedBy;
13
+ private canUndoLoading;
14
+ }
@@ -0,0 +1,16 @@
1
+ export default class EntryUploader {
2
+ constructor(entry: any, config: any, liveSocket: any);
3
+ liveSocket: any;
4
+ entry: any;
5
+ offset: number;
6
+ chunkSize: any;
7
+ chunkTimeout: any;
8
+ chunkTimer: NodeJS.Timeout;
9
+ errored: boolean;
10
+ uploadChannel: any;
11
+ error(reason: any): void;
12
+ upload(): void;
13
+ isDone(): boolean;
14
+ readNextChunk(): void;
15
+ pushChunk(chunk: any): void;
16
+ }
@@ -0,0 +1,3 @@
1
+ import type { Hook } from "./view_hook";
2
+ declare const Hooks: Record<string, Hook<any, any>>;
3
+ export default Hooks;
@@ -0,0 +1,48 @@
1
+ import LiveSocket, { type LiveSocketOptions, isUsedInput } from "./live_socket";
2
+ import { ViewHook } from "./view_hook";
3
+ import type { EncodedJS } from "./js_commands";
4
+ import type { Hook, HooksOptions, HookInterface } from "./view_hook";
5
+ export type { LiveSocketOptions, HookInterface, HooksOptions, EncodedJS };
6
+ /** Creates a hook instance for the given element and callbacks.
7
+ *
8
+ * @param el - The element to associate with the hook.
9
+ * @param callbacks - The list of hook callbacks, such as mounted,
10
+ * updated, destroyed, etc.
11
+ *
12
+ * *Note*: `createHook` must be called from the `connectedCallback` lifecycle
13
+ * which is triggered after the element has been added to the DOM. If you try
14
+ * to call `createHook` from the constructor, an error will be logged.
15
+ *
16
+ * Furthermore, you can only start using the hook's APIs after the `mounted`
17
+ * callback of the hook has been called. If you try to call them earlier,
18
+ * an error will be logged.
19
+ *
20
+ * @example
21
+ *
22
+ * class MyComponent extends HTMLElement {
23
+ * connectedCallback(){
24
+ * let onLiveViewMounted = () => this.hook.pushEvent(...))
25
+ * this.hook = createHook(this, {mounted: onLiveViewMounted})
26
+ * }
27
+ * }
28
+ *
29
+ * @returns Returns the Hook instance for the custom element.
30
+ *
31
+ * @category JavaScript Hooks
32
+ */
33
+ declare function createHook(el: HTMLElement, callbacks: Hook): ViewHook;
34
+ /** Returns an object URL for the file matching the given upload ref,
35
+ * or `null` if no matching file is found.
36
+ *
37
+ * @param input - The file input element associated with the upload.
38
+ * @param uploadRef - The upload ref identifying the file entry.
39
+ *
40
+ * @example
41
+ *
42
+ * import { getFileURLForUpload } from "phoenix_live_view"
43
+ *
44
+ * let url = getFileURLForUpload(inputEl, uploadRef)
45
+ * if (url) { imgEl.src = url }
46
+ */
47
+ declare function getFileURLForUpload(input: HTMLElement, uploadRef: string): string | null;
48
+ export { LiveSocket, isUsedInput, createHook, ViewHook, Hook, getFileURLForUpload, };
@@ -0,0 +1,99 @@
1
+ export default JS;
2
+ declare namespace JS {
3
+ function exec(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, defaults: any): void;
4
+ function isVisible(el: any): boolean;
5
+ function isInViewport(el: any): boolean;
6
+ function exec_exec(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { attr, to }: {
7
+ attr: any;
8
+ to: any;
9
+ }): void;
10
+ function exec_dispatch(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { event, detail, bubbles, blocking }: {
11
+ event: any;
12
+ detail: any;
13
+ bubbles: any;
14
+ blocking: any;
15
+ }): void;
16
+ function exec_push(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, args: any): void;
17
+ function exec_navigate(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { href, replace }: {
18
+ href: any;
19
+ replace: any;
20
+ }): void;
21
+ function exec_patch(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { href, replace }: {
22
+ href: any;
23
+ replace: any;
24
+ }): void;
25
+ function exec_focus(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any): void;
26
+ function exec_focus_first(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any): void;
27
+ function exec_push_focus(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any): void;
28
+ function exec_pop_focus(_e: any, _eventType: any, _phxEvent: any, _view: any, _sourceEl: any, _el: any): void;
29
+ function exec_add_class(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { names, transition, time, blocking }: {
30
+ names: any;
31
+ transition: any;
32
+ time: any;
33
+ blocking: any;
34
+ }): void;
35
+ function exec_remove_class(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { names, transition, time, blocking }: {
36
+ names: any;
37
+ transition: any;
38
+ time: any;
39
+ blocking: any;
40
+ }): void;
41
+ function exec_toggle_class(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { names, transition, time, blocking }: {
42
+ names: any;
43
+ transition: any;
44
+ time: any;
45
+ blocking: any;
46
+ }): void;
47
+ function exec_toggle_attr(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { attr: [attr, val1, val2] }: {
48
+ attr: [any, any, any];
49
+ }): void;
50
+ function exec_ignore_attrs(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { attrs }: {
51
+ attrs: any;
52
+ }): void;
53
+ function exec_transition(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { time, transition, blocking }: {
54
+ time: any;
55
+ transition: any;
56
+ blocking: any;
57
+ }): void;
58
+ function exec_toggle(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { display, ins, outs, time, blocking }: {
59
+ display: any;
60
+ ins: any;
61
+ outs: any;
62
+ time: any;
63
+ blocking: any;
64
+ }): void;
65
+ function exec_show(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { display, transition, time, blocking }: {
66
+ display: any;
67
+ transition: any;
68
+ time: any;
69
+ blocking: any;
70
+ }): void;
71
+ function exec_hide(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { display, transition, time, blocking }: {
72
+ display: any;
73
+ transition: any;
74
+ time: any;
75
+ blocking: any;
76
+ }): void;
77
+ function exec_set_attr(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { attr: [attr, val] }: {
78
+ attr: [any, any];
79
+ }): void;
80
+ function exec_remove_attr(e: any, eventType: any, phxEvent: any, view: any, sourceEl: any, el: any, { attr }: {
81
+ attr: any;
82
+ }): void;
83
+ function ignoreAttrs(el: any, attrs: any): void;
84
+ function onBeforeElUpdated(fromEl: any, toEl: any): void;
85
+ function show(eventType: any, view: any, el: any, display: any, transition: any, time: any, blocking: any): void;
86
+ function hide(eventType: any, view: any, el: any, display: any, transition: any, time: any, blocking: any): void;
87
+ function toggle(eventType: any, view: any, el: any, display: any, ins: any, outs: any, time: any, blocking: any): void;
88
+ function toggleClasses(el: any, classes: any, transition: any, time: any, view: any, blocking: any): void;
89
+ function toggleAttr(el: any, attr: any, val1: any, val2: any): void;
90
+ function addOrRemoveClasses(el: any, adds: any, removes: any, transition: any, time: any, view: any, blocking: any): void;
91
+ function setOrRemoveAttrs(el: any, sets: any, removes: any): void;
92
+ function hasAllClasses(el: any, classes: any): any;
93
+ function isToggledOut(el: any, outClasses: any): any;
94
+ function filterToEls(liveSocket: any, sourceEl: any, { to }: {
95
+ to: any;
96
+ }): any;
97
+ function defaultDisplay(el: any): any;
98
+ function transitionClasses(val: any): any[];
99
+ }