From 9963fae47a8a1e8a9de80e4623ddbb806a865cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 4 Mar 2022 09:21:47 +0100 Subject: [PATCH] Update to Alpine 3.9.1 --- alpinejs/packages/alpinejs/builds/cdn.js | 7 + alpinejs/packages/alpinejs/builds/module.js | 3 + alpinejs/packages/alpinejs/dist/cdn.js | 655 ++++++++----- alpinejs/packages/alpinejs/dist/cdn.min.js | 4 +- alpinejs/packages/alpinejs/dist/module.cjs.js | 657 ++++++++----- alpinejs/packages/alpinejs/dist/module.esm.js | 657 ++++++++----- alpinejs/packages/alpinejs/package.json | 13 + alpinejs/packages/alpinejs/src/alpine.js | 67 ++ alpinejs/packages/alpinejs/src/binds.js | 20 + alpinejs/packages/alpinejs/src/clone.js | 61 ++ alpinejs/packages/alpinejs/src/datas.js | 22 + alpinejs/packages/alpinejs/src/directives.js | 188 ++++ .../packages/alpinejs/src/directives/index.js | 18 + .../alpinejs/src/directives/x-bind.js | 63 ++ .../alpinejs/src/directives/x-cloak.js | 4 + .../alpinejs/src/directives/x-data.js | 45 + .../alpinejs/src/directives/x-effect.js | 4 + .../packages/alpinejs/src/directives/x-for.js | 273 ++++++ .../alpinejs/src/directives/x-html.js | 13 + .../packages/alpinejs/src/directives/x-id.js | 8 + .../packages/alpinejs/src/directives/x-if.js | 55 ++ .../alpinejs/src/directives/x-ignore.js | 17 + .../alpinejs/src/directives/x-init.js | 13 + .../alpinejs/src/directives/x-model.js | 120 +++ .../alpinejs/src/directives/x-modelable.js | 26 + .../packages/alpinejs/src/directives/x-on.js | 22 + .../packages/alpinejs/src/directives/x-ref.js | 16 + .../alpinejs/src/directives/x-show.js | 56 ++ .../alpinejs/src/directives/x-teleport.js | 42 + .../alpinejs/src/directives/x-text.js | 14 + .../alpinejs/src/directives/x-transition.js | 334 +++++++ alpinejs/packages/alpinejs/src/evaluator.js | 132 +++ alpinejs/packages/alpinejs/src/ids.js | 20 + alpinejs/packages/alpinejs/src/index.js | 74 ++ alpinejs/packages/alpinejs/src/interceptor.js | 77 ++ alpinejs/packages/alpinejs/src/lifecycle.js | 84 ++ alpinejs/packages/alpinejs/src/magics.js | 36 + .../packages/alpinejs/src/magics/$data.js | 4 + .../packages/alpinejs/src/magics/$dispatch.js | 4 + alpinejs/packages/alpinejs/src/magics/$el.js | 3 + alpinejs/packages/alpinejs/src/magics/$id.js | 14 + .../packages/alpinejs/src/magics/$nextTick.js | 4 + .../packages/alpinejs/src/magics/$refs.js | 25 + .../packages/alpinejs/src/magics/$root.js | 4 + .../packages/alpinejs/src/magics/$store.js | 4 + .../packages/alpinejs/src/magics/$watch.js | 28 + .../packages/alpinejs/src/magics/index.js | 9 + alpinejs/packages/alpinejs/src/mutation.js | 217 +++++ alpinejs/packages/alpinejs/src/nextTick.js | 24 + alpinejs/packages/alpinejs/src/plugin.js | 5 + alpinejs/packages/alpinejs/src/reactivity.js | 62 ++ alpinejs/packages/alpinejs/src/scheduler.js | 38 + alpinejs/packages/alpinejs/src/scope.js | 105 +++ alpinejs/packages/alpinejs/src/store.js | 23 + alpinejs/packages/alpinejs/src/utils/bind.js | 149 +++ .../packages/alpinejs/src/utils/classes.js | 58 ++ .../packages/alpinejs/src/utils/debounce.js | 18 + .../packages/alpinejs/src/utils/dispatch.js | 12 + alpinejs/packages/alpinejs/src/utils/error.js | 15 + alpinejs/packages/alpinejs/src/utils/on.js | 167 ++++ alpinejs/packages/alpinejs/src/utils/once.js | 14 + .../packages/alpinejs/src/utils/styles.js | 50 + .../packages/alpinejs/src/utils/throttle.js | 16 + alpinejs/packages/alpinejs/src/utils/walk.js | 38 + alpinejs/packages/alpinejs/src/utils/warn.js | 4 + alpinejs/packages/collapse/builds/cdn.js | 5 + alpinejs/packages/collapse/builds/module.js | 3 + alpinejs/packages/collapse/dist/cdn.js | 23 +- alpinejs/packages/collapse/dist/cdn.min.js | 2 +- alpinejs/packages/collapse/dist/module.cjs.js | 23 +- alpinejs/packages/collapse/dist/module.esm.js | 23 +- alpinejs/packages/collapse/package.json | 11 + alpinejs/packages/collapse/src/index.js | 90 ++ alpinejs/packages/csp/builds/cdn.js | 7 + alpinejs/packages/csp/builds/module.js | 3 + alpinejs/packages/csp/dist/cdn.js | 659 ++++++++----- alpinejs/packages/csp/dist/cdn.min.js | 4 +- alpinejs/packages/csp/dist/module.cjs.js | 661 ++++++++----- alpinejs/packages/csp/dist/module.esm.js | 661 ++++++++----- alpinejs/packages/csp/package.json | 12 + alpinejs/packages/csp/src/index.js | 38 + alpinejs/packages/docs/package.json | 7 + alpinejs/packages/docs/src/en/advanced.md | 5 + .../packages/docs/src/en/advanced/async.md | 40 + alpinejs/packages/docs/src/en/advanced/csp.md | 72 ++ .../docs/src/en/advanced/extending.md | 360 +++++++ .../docs/src/en/advanced/reactivity.md | 101 ++ alpinejs/packages/docs/src/en/directives.md | 7 + .../packages/docs/src/en/directives/bind.md | 197 ++++ .../packages/docs/src/en/directives/cloak.md | 38 + .../packages/docs/src/en/directives/data.md | 170 ++++ .../packages/docs/src/en/directives/effect.md | 20 + .../packages/docs/src/en/directives/for.md | 87 ++ .../packages/docs/src/en/directives/html.md | 29 + .../packages/docs/src/en/directives/id.md | 33 + .../packages/docs/src/en/directives/if.md | 20 + .../packages/docs/src/en/directives/ignore.md | 20 + .../packages/docs/src/en/directives/init.md | 74 ++ .../packages/docs/src/en/directives/model.md | 374 ++++++++ .../docs/src/en/directives/modelable.md | 37 + .../packages/docs/src/en/directives/on.md | 299 ++++++ .../packages/docs/src/en/directives/ref.md | 24 + .../packages/docs/src/en/directives/show.md | 39 + .../docs/src/en/directives/teleport.md | 159 ++++ .../packages/docs/src/en/directives/text.md | 26 + .../docs/src/en/directives/transition.md | 175 ++++ alpinejs/packages/docs/src/en/essentials.md | 5 + .../packages/docs/src/en/essentials/events.md | 101 ++ .../docs/src/en/essentials/installation.md | 68 ++ .../docs/src/en/essentials/lifecycle.md | 96 ++ .../packages/docs/src/en/essentials/state.md | 133 +++ .../docs/src/en/essentials/templating.md | 368 ++++++++ alpinejs/packages/docs/src/en/globals.md | 7 + .../docs/src/en/globals/alpine-bind.md | 36 + .../docs/src/en/globals/alpine-data.md | 136 +++ .../docs/src/en/globals/alpine-store.md | 115 +++ alpinejs/packages/docs/src/en/magics.md | 7 + alpinejs/packages/docs/src/en/magics/data.md | 45 + .../packages/docs/src/en/magics/dispatch.md | 106 +++ alpinejs/packages/docs/src/en/magics/el.md | 21 + alpinejs/packages/docs/src/en/magics/id.md | 106 +++ .../packages/docs/src/en/magics/nextTick.md | 23 + alpinejs/packages/docs/src/en/magics/refs.md | 27 + alpinejs/packages/docs/src/en/magics/root.md | 21 + alpinejs/packages/docs/src/en/magics/store.md | 60 ++ alpinejs/packages/docs/src/en/magics/watch.md | 59 ++ alpinejs/packages/docs/src/en/plugins.md | 6 + .../packages/docs/src/en/plugins/collapse.md | 109 +++ .../packages/docs/src/en/plugins/focus.md | 420 +++++++++ .../packages/docs/src/en/plugins/intersect.md | 152 +++ .../packages/docs/src/en/plugins/morph.md | 252 +++++ .../packages/docs/src/en/plugins/persist.md | 207 +++++ alpinejs/packages/docs/src/en/start-here.md | 326 +++++++ .../packages/docs/src/en/upgrade-guide.md | 360 +++++++ alpinejs/packages/focus/.gitignore | 0 alpinejs/packages/focus/builds/cdn.js | 5 + alpinejs/packages/focus/builds/module.js | 3 + alpinejs/packages/focus/dist/cdn.js | 821 ++++++++++++++++ alpinejs/packages/focus/dist/cdn.min.js | 9 + alpinejs/packages/focus/dist/module.cjs.js | 879 ++++++++++++++++++ alpinejs/packages/focus/dist/module.esm.js | 872 +++++++++++++++++ alpinejs/packages/focus/package.json | 13 + alpinejs/packages/focus/src/index.js | 197 ++++ alpinejs/packages/history/builds/cdn.js | 5 + alpinejs/packages/history/builds/module.js | 3 + alpinejs/packages/history/package.json | 12 + alpinejs/packages/history/src/index.js | 76 ++ alpinejs/packages/history/src/url.js | 36 + alpinejs/packages/intersect/builds/cdn.js | 5 + alpinejs/packages/intersect/builds/module.js | 3 + alpinejs/packages/intersect/dist/cdn.js | 20 +- alpinejs/packages/intersect/dist/cdn.min.js | 2 +- .../packages/intersect/dist/module.cjs.js | 20 +- .../packages/intersect/dist/module.esm.js | 20 +- alpinejs/packages/intersect/package.json | 11 + alpinejs/packages/intersect/src/index.js | 60 ++ alpinejs/packages/morph/builds/cdn.js | 5 + alpinejs/packages/morph/builds/module.js | 5 + alpinejs/packages/morph/dist/cdn.js | 247 +++-- alpinejs/packages/morph/dist/cdn.min.js | 3 +- alpinejs/packages/morph/dist/module.cjs.js | 254 +++-- alpinejs/packages/morph/dist/module.esm.js | 247 +++-- alpinejs/packages/morph/package.json | 9 + alpinejs/packages/morph/src/index.js | 7 + alpinejs/packages/morph/src/morph.js | 432 +++++++++ alpinejs/packages/persist/builds/cdn.js | 5 + alpinejs/packages/persist/builds/module.js | 3 + alpinejs/packages/persist/package.json | 11 + alpinejs/packages/persist/src/index.js | 44 + alpinejs/packages/portal/builds/cdn.js | 5 + alpinejs/packages/portal/builds/module.js | 3 + alpinejs/packages/portal/package.json | 11 + alpinejs/packages/portal/src/index.js | 62 ++ 173 files changed, 15802 insertions(+), 1667 deletions(-) create mode 100644 alpinejs/packages/alpinejs/builds/cdn.js create mode 100644 alpinejs/packages/alpinejs/builds/module.js create mode 100644 alpinejs/packages/alpinejs/package.json create mode 100644 alpinejs/packages/alpinejs/src/alpine.js create mode 100644 alpinejs/packages/alpinejs/src/binds.js create mode 100644 alpinejs/packages/alpinejs/src/clone.js create mode 100644 alpinejs/packages/alpinejs/src/datas.js create mode 100644 alpinejs/packages/alpinejs/src/directives.js create mode 100644 alpinejs/packages/alpinejs/src/directives/index.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-bind.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-cloak.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-data.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-effect.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-for.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-html.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-id.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-if.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-ignore.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-init.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-model.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-modelable.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-on.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-ref.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-show.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-teleport.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-text.js create mode 100644 alpinejs/packages/alpinejs/src/directives/x-transition.js create mode 100644 alpinejs/packages/alpinejs/src/evaluator.js create mode 100644 alpinejs/packages/alpinejs/src/ids.js create mode 100644 alpinejs/packages/alpinejs/src/index.js create mode 100644 alpinejs/packages/alpinejs/src/interceptor.js create mode 100644 alpinejs/packages/alpinejs/src/lifecycle.js create mode 100644 alpinejs/packages/alpinejs/src/magics.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$data.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$dispatch.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$el.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$id.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$nextTick.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$refs.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$root.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$store.js create mode 100644 alpinejs/packages/alpinejs/src/magics/$watch.js create mode 100644 alpinejs/packages/alpinejs/src/magics/index.js create mode 100644 alpinejs/packages/alpinejs/src/mutation.js create mode 100644 alpinejs/packages/alpinejs/src/nextTick.js create mode 100644 alpinejs/packages/alpinejs/src/plugin.js create mode 100644 alpinejs/packages/alpinejs/src/reactivity.js create mode 100644 alpinejs/packages/alpinejs/src/scheduler.js create mode 100644 alpinejs/packages/alpinejs/src/scope.js create mode 100644 alpinejs/packages/alpinejs/src/store.js create mode 100644 alpinejs/packages/alpinejs/src/utils/bind.js create mode 100644 alpinejs/packages/alpinejs/src/utils/classes.js create mode 100644 alpinejs/packages/alpinejs/src/utils/debounce.js create mode 100644 alpinejs/packages/alpinejs/src/utils/dispatch.js create mode 100644 alpinejs/packages/alpinejs/src/utils/error.js create mode 100644 alpinejs/packages/alpinejs/src/utils/on.js create mode 100644 alpinejs/packages/alpinejs/src/utils/once.js create mode 100644 alpinejs/packages/alpinejs/src/utils/styles.js create mode 100644 alpinejs/packages/alpinejs/src/utils/throttle.js create mode 100644 alpinejs/packages/alpinejs/src/utils/walk.js create mode 100644 alpinejs/packages/alpinejs/src/utils/warn.js create mode 100644 alpinejs/packages/collapse/builds/cdn.js create mode 100644 alpinejs/packages/collapse/builds/module.js create mode 100644 alpinejs/packages/collapse/package.json create mode 100644 alpinejs/packages/collapse/src/index.js create mode 100644 alpinejs/packages/csp/builds/cdn.js create mode 100644 alpinejs/packages/csp/builds/module.js create mode 100644 alpinejs/packages/csp/package.json create mode 100644 alpinejs/packages/csp/src/index.js create mode 100644 alpinejs/packages/docs/package.json create mode 100644 alpinejs/packages/docs/src/en/advanced.md create mode 100644 alpinejs/packages/docs/src/en/advanced/async.md create mode 100644 alpinejs/packages/docs/src/en/advanced/csp.md create mode 100644 alpinejs/packages/docs/src/en/advanced/extending.md create mode 100644 alpinejs/packages/docs/src/en/advanced/reactivity.md create mode 100644 alpinejs/packages/docs/src/en/directives.md create mode 100644 alpinejs/packages/docs/src/en/directives/bind.md create mode 100644 alpinejs/packages/docs/src/en/directives/cloak.md create mode 100644 alpinejs/packages/docs/src/en/directives/data.md create mode 100644 alpinejs/packages/docs/src/en/directives/effect.md create mode 100644 alpinejs/packages/docs/src/en/directives/for.md create mode 100644 alpinejs/packages/docs/src/en/directives/html.md create mode 100644 alpinejs/packages/docs/src/en/directives/id.md create mode 100644 alpinejs/packages/docs/src/en/directives/if.md create mode 100644 alpinejs/packages/docs/src/en/directives/ignore.md create mode 100644 alpinejs/packages/docs/src/en/directives/init.md create mode 100644 alpinejs/packages/docs/src/en/directives/model.md create mode 100644 alpinejs/packages/docs/src/en/directives/modelable.md create mode 100644 alpinejs/packages/docs/src/en/directives/on.md create mode 100644 alpinejs/packages/docs/src/en/directives/ref.md create mode 100644 alpinejs/packages/docs/src/en/directives/show.md create mode 100644 alpinejs/packages/docs/src/en/directives/teleport.md create mode 100644 alpinejs/packages/docs/src/en/directives/text.md create mode 100644 alpinejs/packages/docs/src/en/directives/transition.md create mode 100644 alpinejs/packages/docs/src/en/essentials.md create mode 100644 alpinejs/packages/docs/src/en/essentials/events.md create mode 100644 alpinejs/packages/docs/src/en/essentials/installation.md create mode 100644 alpinejs/packages/docs/src/en/essentials/lifecycle.md create mode 100644 alpinejs/packages/docs/src/en/essentials/state.md create mode 100644 alpinejs/packages/docs/src/en/essentials/templating.md create mode 100644 alpinejs/packages/docs/src/en/globals.md create mode 100644 alpinejs/packages/docs/src/en/globals/alpine-bind.md create mode 100644 alpinejs/packages/docs/src/en/globals/alpine-data.md create mode 100644 alpinejs/packages/docs/src/en/globals/alpine-store.md create mode 100644 alpinejs/packages/docs/src/en/magics.md create mode 100644 alpinejs/packages/docs/src/en/magics/data.md create mode 100644 alpinejs/packages/docs/src/en/magics/dispatch.md create mode 100644 alpinejs/packages/docs/src/en/magics/el.md create mode 100644 alpinejs/packages/docs/src/en/magics/id.md create mode 100644 alpinejs/packages/docs/src/en/magics/nextTick.md create mode 100644 alpinejs/packages/docs/src/en/magics/refs.md create mode 100644 alpinejs/packages/docs/src/en/magics/root.md create mode 100644 alpinejs/packages/docs/src/en/magics/store.md create mode 100644 alpinejs/packages/docs/src/en/magics/watch.md create mode 100644 alpinejs/packages/docs/src/en/plugins.md create mode 100644 alpinejs/packages/docs/src/en/plugins/collapse.md create mode 100644 alpinejs/packages/docs/src/en/plugins/focus.md create mode 100644 alpinejs/packages/docs/src/en/plugins/intersect.md create mode 100644 alpinejs/packages/docs/src/en/plugins/morph.md create mode 100644 alpinejs/packages/docs/src/en/plugins/persist.md create mode 100644 alpinejs/packages/docs/src/en/start-here.md create mode 100644 alpinejs/packages/docs/src/en/upgrade-guide.md create mode 100644 alpinejs/packages/focus/.gitignore create mode 100644 alpinejs/packages/focus/builds/cdn.js create mode 100644 alpinejs/packages/focus/builds/module.js create mode 100644 alpinejs/packages/focus/dist/cdn.js create mode 100644 alpinejs/packages/focus/dist/cdn.min.js create mode 100644 alpinejs/packages/focus/dist/module.cjs.js create mode 100644 alpinejs/packages/focus/dist/module.esm.js create mode 100644 alpinejs/packages/focus/package.json create mode 100644 alpinejs/packages/focus/src/index.js create mode 100644 alpinejs/packages/history/builds/cdn.js create mode 100644 alpinejs/packages/history/builds/module.js create mode 100644 alpinejs/packages/history/package.json create mode 100644 alpinejs/packages/history/src/index.js create mode 100644 alpinejs/packages/history/src/url.js create mode 100644 alpinejs/packages/intersect/builds/cdn.js create mode 100644 alpinejs/packages/intersect/builds/module.js create mode 100644 alpinejs/packages/intersect/package.json create mode 100644 alpinejs/packages/intersect/src/index.js create mode 100644 alpinejs/packages/morph/builds/cdn.js create mode 100644 alpinejs/packages/morph/builds/module.js create mode 100644 alpinejs/packages/morph/package.json create mode 100644 alpinejs/packages/morph/src/index.js create mode 100644 alpinejs/packages/morph/src/morph.js create mode 100644 alpinejs/packages/persist/builds/cdn.js create mode 100644 alpinejs/packages/persist/builds/module.js create mode 100644 alpinejs/packages/persist/package.json create mode 100644 alpinejs/packages/persist/src/index.js create mode 100644 alpinejs/packages/portal/builds/cdn.js create mode 100644 alpinejs/packages/portal/builds/module.js create mode 100644 alpinejs/packages/portal/package.json create mode 100644 alpinejs/packages/portal/src/index.js diff --git a/alpinejs/packages/alpinejs/builds/cdn.js b/alpinejs/packages/alpinejs/builds/cdn.js new file mode 100644 index 0000000..a54e7e0 --- /dev/null +++ b/alpinejs/packages/alpinejs/builds/cdn.js @@ -0,0 +1,7 @@ +import Alpine from './../src/index' + +window.Alpine = Alpine + +queueMicrotask(() => { + Alpine.start() +}) diff --git a/alpinejs/packages/alpinejs/builds/module.js b/alpinejs/packages/alpinejs/builds/module.js new file mode 100644 index 0000000..0382080 --- /dev/null +++ b/alpinejs/packages/alpinejs/builds/module.js @@ -0,0 +1,3 @@ +import Alpine from './../src/index' + +export default Alpine diff --git a/alpinejs/packages/alpinejs/dist/cdn.js b/alpinejs/packages/alpinejs/dist/cdn.js index 800464c..4ba2177 100644 --- a/alpinejs/packages/alpinejs/dist/cdn.js +++ b/alpinejs/packages/alpinejs/dist/cdn.js @@ -11,6 +11,11 @@ queue.push(job); queueFlush(); } + function dequeueJob(job) { + let index = queue.indexOf(job); + if (index !== -1) + queue.splice(index, 1); + } function queueFlush() { if (!flushing && !flushPending) { flushPending = true; @@ -84,8 +89,15 @@ function onElAdded(callback) { onElAddeds.push(callback); } - function onElRemoved(callback) { - onElRemoveds.push(callback); + function onElRemoved(el, callback) { + if (typeof callback === "function") { + if (!el._x_cleanups) + el._x_cleanups = []; + el._x_cleanups.push(callback); + } else { + callback = el; + onElRemoveds.push(callback); + } } function onAttributesAdded(callback) { onAttributeAddeds.push(callback); @@ -198,16 +210,34 @@ addedAttributes.forEach((attrs, el) => { onAttributeAddeds.forEach((i) => i(el, attrs)); }); - for (let node of addedNodes) { - if (removedNodes.includes(node)) - continue; - onElAddeds.forEach((i) => i(node)); - } for (let node of removedNodes) { if (addedNodes.includes(node)) continue; onElRemoveds.forEach((i) => i(node)); + if (node._x_cleanups) { + while (node._x_cleanups.length) + node._x_cleanups.pop()(); + } + } + addedNodes.forEach((node) => { + node._x_ignoreSelf = true; + node._x_ignore = true; + }); + for (let node of addedNodes) { + if (removedNodes.includes(node)) + continue; + if (!node.isConnected) + continue; + delete node._x_ignoreSelf; + delete node._x_ignore; + onElAddeds.forEach((i) => i(node)); + node._x_ignore = true; + node._x_ignoreSelf = true; } + addedNodes.forEach((node) => { + delete node._x_ignoreSelf; + delete node._x_ignore; + }); addedNodes = null; removedNodes = null; addedAttributes = null; @@ -215,15 +245,18 @@ } // packages/alpinejs/src/scope.js + function scope(node) { + return mergeProxies(closestDataStack(node)); + } function addScopeToNode(node, data2, referenceNode) { node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)]; return () => { node._x_dataStack = node._x_dataStack.filter((i) => i !== data2); }; } - function refreshScope(element, scope) { + function refreshScope(element, scope2) { let existingScope = element._x_dataStack[0]; - Object.entries(scope).forEach(([key, value]) => { + Object.entries(scope2).forEach(([key, value]) => { existingScope[key] = value; }); } @@ -359,7 +392,10 @@ Object.entries(magics).forEach(([name, callback]) => { Object.defineProperty(obj, `$${name}`, { get() { - return callback(el, {Alpine: alpine_default, interceptor}); + let [utilities, cleanup2] = getElementBoundUtilities(el); + utilities = {interceptor, ...utilities}; + onElRemoved(el, cleanup2); + return callback(el, utilities); }, enumerable: false }); @@ -416,8 +452,8 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); } function generateEvaluatorFromFunction(dataStack, func) { return (receiver = () => { - }, {scope = {}, params = []} = {}) => { - let result = func.apply(mergeProxies([scope, ...dataStack]), params); + }, {scope: scope2 = {}, params = []} = {}) => { + let result = func.apply(mergeProxies([scope2, ...dataStack]), params); runIfTypeOfFunction(receiver, result); }; } @@ -444,27 +480,28 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); function generateEvaluatorFromString(dataStack, expression, el) { let func = generateFunctionFromString(expression, el); return (receiver = () => { - }, {scope = {}, params = []} = {}) => { + }, {scope: scope2 = {}, params = []} = {}) => { func.result = void 0; func.finished = false; - let completeScope = mergeProxies([scope, ...dataStack]); + let completeScope = mergeProxies([scope2, ...dataStack]); if (typeof func === "function") { let promise = func(func, completeScope).catch((error2) => handleError(error2, el, expression)); if (func.finished) { runIfTypeOfFunction(receiver, func.result, completeScope, params, el); + func.result = void 0; } else { promise.then((result) => { runIfTypeOfFunction(receiver, result, completeScope, params, el); - }).catch((error2) => handleError(error2, el, expression)); + }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0); } } }; } - function runIfTypeOfFunction(receiver, value, scope, params, el) { + function runIfTypeOfFunction(receiver, value, scope2, params, el) { if (typeof value === "function") { - let result = value.apply(scope, params); + let result = value.apply(scope2, params); if (result instanceof Promise) { - result.then((i) => runIfTypeOfFunction(receiver, i, scope, params)).catch((error2) => handleError(error2, el, value)); + result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value)); } else { receiver(result); } @@ -515,10 +552,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); callback(flushHandlers); stopDeferring(); } - function getDirectiveHandler(el, directive2) { - let noop = () => { - }; - let handler3 = directiveHandlers[directive2.type] || noop; + function getElementBoundUtilities(el) { let cleanups = []; let cleanup2 = (callback) => cleanups.push(callback); let [effect3, cleanupEffect] = elementBoundEffect(el); @@ -531,7 +565,14 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); evaluate: evaluate.bind(evaluate, el) }; let doCleanup = () => cleanups.forEach((i) => i()); - onAttributeRemoved(el, directive2.original, doCleanup); + return [utilities, doCleanup]; + } + function getDirectiveHandler(el, directive2) { + let noop = () => { + }; + let handler3 = directiveHandlers[directive2.type] || noop; + let [utilities, cleanup2] = getElementBoundUtilities(el); + onAttributeRemoved(el, directive2.original, cleanup2); let fullHandler = () => { if (el._x_ignore || el._x_ignoreSelf) return; @@ -539,7 +580,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); handler3 = handler3.bind(handler3, el, directive2, utilities); isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler3) : handler3(); }; - fullHandler.runCleanups = doCleanup; + fullHandler.runCleanups = cleanup2; return fullHandler; } var startingWith = (subject, replacement) => ({name, value}) => { @@ -587,14 +628,17 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); "ignore", "ref", "data", + "id", "bind", "init", "for", "model", + "modelable", "transition", "show", "if", DEFAULT, + "teleport", "element" ]; function byPriority(a, b) { @@ -663,7 +707,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); dispatch(document, "alpine:initializing"); startObservingMutations(); onElAdded((el) => initTree(el, walk)); - onElRemoved((el) => nextTick(() => destroyTree(el))); + onElRemoved((el) => destroyTree(el)); onAttributesAdded((el, attrs) => { directives(el, attrs).forEach((handle) => handle()); }); @@ -688,14 +732,22 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); initSelectorCallbacks.push(selectorCallback); } function closestRoot(el, includeInitSelectors = false) { + return findClosest(el, (element) => { + const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); + if (selectors.some((selector) => element.matches(selector))) + return true; + }); + } + function findClosest(el, callback) { if (!el) return; - const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); - if (selectors.some((selector) => el.matches(selector))) + if (callback(el)) return el; + if (el._x_teleportBack) + el = el._x_teleportBack; if (!el.parentElement) return; - return closestRoot(el.parentElement, includeInitSelectors); + return findClosest(el.parentElement, callback); } function isRoot(el) { return rootSelectors().some((selector) => el.matches(selector)); @@ -770,7 +822,10 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); let previousStyles = {}; Object.entries(value).forEach(([key, value2]) => { previousStyles[key] = el.style[key]; - el.style.setProperty(kebabCase(key), value2); + if (!key.startsWith("--")) { + key = kebabCase(key); + } + el.style.setProperty(key, value2); }); setTimeout(() => { if (el.style.length === 0) { @@ -785,7 +840,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); let cache = el.getAttribute("style", value); el.setAttribute("style", value); return () => { - el.setAttribute("style", cache); + el.setAttribute("style", cache || ""); }; } function kebabCase(subject) { @@ -1082,6 +1137,179 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); return rawValue; } + // packages/alpinejs/src/clone.js + var isCloning = false; + function skipDuringClone(callback, fallback = () => { + }) { + return (...args) => isCloning ? fallback(...args) : callback(...args); + } + function clone(oldEl, newEl) { + if (!newEl._x_dataStack) + newEl._x_dataStack = oldEl._x_dataStack; + isCloning = true; + dontRegisterReactiveSideEffects(() => { + cloneTree(newEl); + }); + isCloning = false; + } + function cloneTree(el) { + let hasRunThroughFirstEl = false; + let shallowWalker = (el2, callback) => { + walk(el2, (el3, skip) => { + if (hasRunThroughFirstEl && isRoot(el3)) + return skip(); + hasRunThroughFirstEl = true; + callback(el3, skip); + }); + }; + initTree(el, shallowWalker); + } + function dontRegisterReactiveSideEffects(callback) { + let cache = effect; + overrideEffect((callback2, el) => { + let storedEffect = cache(callback2); + release(storedEffect); + return () => { + }; + }); + callback(); + overrideEffect(cache); + } + + // packages/alpinejs/src/utils/bind.js + function bind(el, name, value, modifiers = []) { + if (!el._x_bindings) + el._x_bindings = reactive({}); + el._x_bindings[name] = value; + name = modifiers.includes("camel") ? camelCase(name) : name; + switch (name) { + case "value": + bindInputValue(el, value); + break; + case "style": + bindStyles(el, value); + break; + case "class": + bindClasses(el, value); + break; + default: + bindAttribute(el, name, value); + break; + } + } + function bindInputValue(el, value) { + if (el.type === "radio") { + if (el.attributes.value === void 0) { + el.value = value; + } + if (window.fromModel) { + el.checked = checkedAttrLooseCompare(el.value, value); + } + } else if (el.type === "checkbox") { + if (Number.isInteger(value)) { + el.value = value; + } else if (!Number.isInteger(value) && !Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) { + el.value = String(value); + } else { + if (Array.isArray(value)) { + el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value)); + } else { + el.checked = !!value; + } + } + } else if (el.tagName === "SELECT") { + updateSelect(el, value); + } else { + if (el.value === value) + return; + el.value = value; + } + } + function bindClasses(el, value) { + if (el._x_undoAddedClasses) + el._x_undoAddedClasses(); + el._x_undoAddedClasses = setClasses(el, value); + } + function bindStyles(el, value) { + if (el._x_undoAddedStyles) + el._x_undoAddedStyles(); + el._x_undoAddedStyles = setStyles(el, value); + } + function bindAttribute(el, name, value) { + if ([null, void 0, false].includes(value) && attributeShouldntBePreservedIfFalsy(name)) { + el.removeAttribute(name); + } else { + if (isBooleanAttr(name)) + value = name; + setIfChanged(el, name, value); + } + } + function setIfChanged(el, attrName, value) { + if (el.getAttribute(attrName) != value) { + el.setAttribute(attrName, value); + } + } + function updateSelect(el, value) { + const arrayWrappedValue = [].concat(value).map((value2) => { + return value2 + ""; + }); + Array.from(el.options).forEach((option) => { + option.selected = arrayWrappedValue.includes(option.value); + }); + } + function camelCase(subject) { + return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); + } + function checkedAttrLooseCompare(valueA, valueB) { + return valueA == valueB; + } + function isBooleanAttr(attrName) { + const booleanAttributes = [ + "disabled", + "checked", + "required", + "readonly", + "hidden", + "open", + "selected", + "autofocus", + "itemscope", + "multiple", + "novalidate", + "allowfullscreen", + "allowpaymentrequest", + "formnovalidate", + "autoplay", + "controls", + "loop", + "muted", + "playsinline", + "default", + "ismap", + "reversed", + "async", + "defer", + "nomodule" + ]; + return booleanAttributes.includes(attrName); + } + function attributeShouldntBePreservedIfFalsy(name) { + return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(name); + } + function getBinding(el, name, fallback) { + if (el._x_bindings && el._x_bindings[name] !== void 0) + return el._x_bindings[name]; + let attr = el.getAttribute(name); + if (attr === null) + return typeof fallback === "function" ? fallback() : fallback; + if (isBooleanAttr(name)) { + return !![name, "true"].includes(attr); + } + if (attr === "") + return true; + return attr; + } + // packages/alpinejs/src/utils/debounce.js function debounce(func, wait) { var timeout; @@ -1135,42 +1363,22 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); return stores; } - // packages/alpinejs/src/clone.js - var isCloning = false; - function skipDuringClone(callback, fallback = () => { - }) { - return (...args) => isCloning ? fallback(...args) : callback(...args); + // packages/alpinejs/src/binds.js + var binds = {}; + function bind2(name, object) { + binds[name] = typeof object !== "function" ? () => object : object; } - function clone(oldEl, newEl) { - newEl._x_dataStack = oldEl._x_dataStack; - isCloning = true; - dontRegisterReactiveSideEffects(() => { - cloneTree(newEl); - }); - isCloning = false; - } - function cloneTree(el) { - let hasRunThroughFirstEl = false; - let shallowWalker = (el2, callback) => { - walk(el2, (el3, skip) => { - if (hasRunThroughFirstEl && isRoot(el3)) - return skip(); - hasRunThroughFirstEl = true; - callback(el3, skip); + function injectBindingProviders(obj) { + Object.entries(binds).forEach(([name, callback]) => { + Object.defineProperty(obj, name, { + get() { + return (...args) => { + return callback(...args); + }; + } }); - }; - initTree(el, shallowWalker); - } - function dontRegisterReactiveSideEffects(callback) { - let cache = effect; - overrideEffect((callback2, el) => { - let storedEffect = cache(callback2); - release(storedEffect); - return () => { - }; }); - callback(); - overrideEffect(cache); + return obj; } // packages/alpinejs/src/datas.js @@ -1206,19 +1414,23 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); get raw() { return raw; }, - version: "3.5.1", + version: "3.9.1", flushAndStopDeferringMutations, disableEffectScheduling, stopObservingMutations, + destroyTree, setReactivityEngine, + closestDataStack, skipDuringClone, addRootSelector, + addInitSelector, + addScopeToNode, deferMutations, mapAttributes, evaluateLater, setEvaluator, mergeProxies, - destroyTree, + findClosest, closestRoot, interceptor, transition, @@ -1230,13 +1442,17 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); evaluate, initTree, nextTick, + prefixed: prefix, prefix: setPrefix, plugin, magic, store, start, clone, - data + bound: getBinding, + $data: scope, + data, + bind: bind2 }; var alpine_default = Alpine; @@ -1271,7 +1487,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); [3]: "FORWARDED" }; var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; - var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`); + var isBooleanAttr2 = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`); var EMPTY_OBJ = true ? Object.freeze({}) : {}; var EMPTY_ARR = true ? Object.freeze([]) : []; var extend = Object.assign; @@ -1926,15 +2142,12 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); magic("dispatch", (el) => dispatch.bind(dispatch, el)); // packages/alpinejs/src/magics/$watch.js - magic("watch", (el) => (key, callback) => { - let evaluate2 = evaluateLater(el, key); + magic("watch", (el, {evaluateLater: evaluateLater2, effect: effect3}) => (key, callback) => { + let evaluate2 = evaluateLater2(key); let firstTime = true; let oldValue; - let [effect3, cleanupEffect] = elementBoundEffect(el); - onAttributeRemoved(el, key, cleanupEffect); effect3(() => evaluate2((value) => { - let div = document.createElement("div"); - div.dataset.throwAway = value; + JSON.stringify(value); if (!firstTime) { queueMicrotask(() => { callback(value, oldValue); @@ -1951,9 +2164,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); magic("store", getStores); // packages/alpinejs/src/magics/$data.js - magic("data", (el) => { - return mergeProxies(closestDataStack(el)); - }); + magic("data", (el) => scope(el)); // packages/alpinejs/src/magics/$root.js magic("root", (el) => closestRoot(el)); @@ -1976,9 +2187,88 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); return refObjects; } + // packages/alpinejs/src/ids.js + var globalIdMemo = {}; + function findAndIncrementId(name) { + if (!globalIdMemo[name]) + globalIdMemo[name] = 0; + return ++globalIdMemo[name]; + } + function closestIdRoot(el, name) { + return findClosest(el, (element) => { + if (element._x_ids && element._x_ids[name]) + return true; + }); + } + function setIdRoot(el, name) { + if (!el._x_ids) + el._x_ids = {}; + if (!el._x_ids[name]) + el._x_ids[name] = findAndIncrementId(name); + } + + // packages/alpinejs/src/magics/$id.js + magic("id", (el) => (name, key = null) => { + let root = closestIdRoot(el, name); + let id = root ? root._x_ids[name] : findAndIncrementId(name); + return key ? `${name}-${id}-${key}` : `${name}-${id}`; + }); + // packages/alpinejs/src/magics/$el.js magic("el", (el) => el); + // packages/alpinejs/src/directives/x-modelable.js + directive("modelable", (el, {expression}, {effect: effect3, evaluate: evaluate2, evaluateLater: evaluateLater2}) => { + let func = evaluateLater2(expression); + let innerGet = () => { + let result; + func((i) => result = i); + return result; + }; + let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`); + let innerSet = (val) => evaluateInnerSet(() => { + }, {scope: {__placeholder: val}}); + let initialValue = innerGet(); + if (el._x_modelable_hook) + initialValue = el._x_modelable_hook(initialValue); + innerSet(initialValue); + queueMicrotask(() => { + if (!el._x_model) + return; + let outerGet = el._x_model.get; + let outerSet = el._x_model.set; + effect3(() => innerSet(outerGet())); + effect3(() => outerSet(innerGet())); + }); + }); + + // packages/alpinejs/src/directives/x-teleport.js + directive("teleport", (el, {expression}, {cleanup: cleanup2}) => { + if (el.tagName.toLowerCase() !== "template") + warn("x-teleport can only be used on a