public/lookbook-assets/app.js in lookbook-3.0.0.alpha.0 vs public/lookbook-assets/app.js in lookbook-3.0.0.alpha.1

- old
+ new

@@ -5122,11 +5122,11 @@ nextTick2(() => { let hideAfterChildren = (el2) => { let carry = Promise.all([ el2._x_hidePromise, ...(el2._x_hideChildren || []).map(hideAfterChildren) - ]).then(([i5]) => i5()); + ]).then(([i5]) => i5?.()); delete el2._x_hidePromise; delete el2._x_hideChildren; return carry; }; hideAfterChildren(el).catch((e5) => { @@ -5635,11 +5635,11 @@ return effect; }, get raw() { return raw; }, - version: "3.13.10", + version: "3.14.0", flushAndStopDeferringMutations, dontAutoEvaluateFunctions, disableEffectScheduling, startObservingMutations, stopObservingMutations, @@ -6641,18 +6641,18 @@ } if (modifiers.includes("self")) handler4 = wrapHandler(handler4, (next, e5) => { e5.target === el && next(e5); }); - handler4 = wrapHandler(handler4, (next, e5) => { - if (isKeyEvent(event)) { + if (isKeyEvent(event) || isClickEvent(event)) { + handler4 = wrapHandler(handler4, (next, e5) => { if (isListeningForASpecificKeyThatHasntBeenPressed(e5, modifiers)) { return; } - } - next(e5); - }); + next(e5); + }); + } listenerTarget.addEventListener(event, handler4, options); return () => { listenerTarget.removeEventListener(event, handler4, options); }; } @@ -6673,13 +6673,16 @@ return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); } function isKeyEvent(event) { return ["keydown", "keyup"].includes(event); } + function isClickEvent(event) { + return ["contextmenu", "click", "mouse"].some((i5) => event.includes(i5)); + } function isListeningForASpecificKeyThatHasntBeenPressed(e5, modifiers) { let keyModifiers = modifiers.filter((i5) => { - return !["window", "document", "prevent", "stop", "once", "capture"].includes(i5); + return !["window", "document", "prevent", "stop", "once", "capture", "self", "away", "outside", "passive"].includes(i5); }); if (keyModifiers.includes("debounce")) { let debounceIndex = keyModifiers.indexOf("debounce"); keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); } @@ -6699,10 +6702,12 @@ if (modifier === "cmd" || modifier === "super") modifier = "meta"; return e5[`${modifier}Key`]; }); if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) { + if (isClickEvent(e5.type)) + return false; if (keyToModifiers(e5.key).includes(keyModifiers[0])) return false; } } return true; @@ -7739,14 +7744,14 @@ function getData(el) { const root2 = module_default.closestRoot(el); return root2 ? module_default.$data(root2) : null; } - // app/components/lookbook/ui/app/color_scheme_switcher/color_scheme_switcher.js - var color_scheme_switcher_exports = {}; - __export(color_scheme_switcher_exports, { - default: () => color_scheme_switcher_default + // app/components/lookbook/ui/app/app.js + var app_exports = {}; + __export(app_exports, { + default: () => app_default }); // assets/js/alpine/component.js function AlpineComponent(name, fn2) { fn2.componentName = name; @@ -7849,11 +7854,42 @@ } ); } var api = init(defaultConverter, { path: "/" }); - // app/components/lookbook/ui/app/color_scheme_switcher/color_scheme_switcher.js + // app/components/lookbook/ui/app/app.js + var app_default = AlpineComponent("app", () => { + return { + reflowing: false, + resetUI() { + api.remove("lookbook-display-options"); + api.remove("lookbook-color-scheme"); + Alpine.store("app").clear(); + window.location.reload(); + this.$logger.info(`Local storage cleared`); + }, + bindings: { + root: { + ["@ui:resizing-start"]() { + this.reflowing = true; + }, + ["@ui:resizing-end"]() { + this.reflowing = false; + }, + ["@ui:reset"]() { + this.resetUI(); + } + } + } + }; + }); + + // app/components/lookbook/ui/app/header/color_scheme_switcher/color_scheme_switcher.js + var color_scheme_switcher_exports = {}; + __export(color_scheme_switcher_exports, { + default: () => color_scheme_switcher_default + }); var colorSchemeCookie = "lookbook-color-scheme"; var color_scheme_switcher_default = AlpineComponent("colorSchemeSwitcher", () => { const store2 = Alpine.store("app"); store2.setDefault("colorScheme", "light"); return { @@ -7893,41 +7929,10 @@ }); var header_default = AlpineComponent("header", () => { return {}; }); - // app/components/lookbook/ui/app/layout/layout.js - var layout_exports = {}; - __export(layout_exports, { - default: () => layout_default - }); - var layout_default = AlpineComponent("layout", () => { - return { - appReflowing: false, - resetLayout() { - api.remove("lookbook-display-options"); - api.remove("lookbook-color-scheme"); - Alpine.store("app").clear(); - window.location.reload(); - this.$logger.info(`Local storage cleared`); - }, - bindings: { - root: { - ["@layout:resizing-start"]() { - this.appReflowing = true; - }, - ["@layout:resizing-end"]() { - this.appReflowing = false; - }, - ["@layout:reset"]() { - this.resetLayout(); - } - } - } - }; - }); - // app/components/lookbook/ui/app/router/router.js var router_exports = {}; __export(router_exports, { default: () => router_default }); @@ -17754,31 +17759,29 @@ return { id, empty: false, filteredOut: false, init() { - this.$nextTick(() => this.updateSelection(true)); + this.$nextTick(() => { + const currentElement = this.$el.querySelector( + `[data-component='nav-item'][data-url='${document.location.pathname}']` + ); + if (currentElement) { + let currentItem = getData(currentElement); + currentItem.selected = true; + this.expandParentsOfItem(currentItem); + } + }); }, - updateSelection(expandParents = false) { - if (this.selectedItem) { - this.selectedItem.selected = false; - } - const currentElement = this.$el.querySelector( - `[data-component='nav-item'][data-url='${document.location.pathname}']` - ); - if (currentElement) { - let currentItem = getData(currentElement); - currentItem.selected = true; - if (expandParents) { - while (currentItem) { - const parent = currentItem.parent; - if (!currentItem.selected) { - currentItem.expanded = true; - } - currentItem = parent; - } + expandParentsOfItem(item) { + let currentItem = item; + while (currentItem) { + const parent = currentItem.parent; + if (!currentItem.selected) { + currentItem.expanded = true; } + currentItem = parent; } }, collapseAll() { Array.from( this.$root.querySelectorAll("[data-component='nav-item']") @@ -17809,18 +17812,15 @@ }, get expandedItems() { return store2.expandedItems; }, get children() { - return Array.from(this.$refs.nav.children).map((node) => getData(node)); - }, - get selectedItem() { - return getData( - this.$el.querySelector( - `[data-component='nav-item'][aria-selected='true']` - ) - ); + if (this.$refs.nav) { + return Array.from(this.$refs.nav.children).map((node) => getData(node)); + } else { + return []; + } } }; }); // app/components/lookbook/ui/elements/nav/nav_item/nav_item.js @@ -17835,10 +17835,11 @@ filteredOut: false, selected: false, init() { this.keywords = keywords || []; this.isCollection = collection || false; + this.setSelectionState(); }, visit() { if (!this.selected && this.targetUrl) { this.$dispatch("lookbook:visit", { url: this.targetUrl }); } @@ -17862,10 +17863,14 @@ const matched = this.keywords.map((k3) => k3.includes(text2)); return matched.filter((m3) => m3).length; } return true; }, + setSelectionState() { + const selected = this.targetUrl === document.location.pathname; + this.selected = selected; + }, get targetUrl() { return this.$root.getAttribute("data-url"); }, get key() { return this.$root.getAttribute("key"); @@ -17890,10 +17895,29 @@ get parent() { const parentElement = this.$root.parentElement.closest( "[data-component='nav-item']" ); return parentElement ? getData(parentElement) : null; + }, + bindings: { + root: { + ["x-show"]() { + return !this.filteredOut; + }, + ["@page-update:complete.document"]() { + this.setSelectionState(); + }, + ["@page-load:complete.document"]() { + this.setSelectionState(); + }, + [":aria-expanded"]() { + return this.expanded; + }, + [":aria-selected"]() { + return this.selected; + } + } } }; }); // app/components/lookbook/ui/elements/pane/pane.js @@ -18916,11 +18940,11 @@ }, get parentHeight() { return Math.round(this.$root.clientHeight); }, get inert() { - return this.resizing || this.appReflowing; + return this.resizing || this.reflowing; }, get iframe() { return this.$refs.iframe; } }; @@ -19038,10 +19062,10 @@ } }; }); // import-glob:/Users/mark/Code/lookbook/lookbook/assets/js/alpine|../../../app/components/lookbook/ui/**/*.js - var modules = [color_scheme_switcher_exports, header_exports, layout_exports, router_exports, status_bar_exports, status_bar_item_exports, status_bar_notifications_exports, button_exports, code_exports, icon_exports, nav_exports, nav_item_exports, pane_exports, tab_panel_exports, pane_group_exports, prose_exports, toolbar_exports, toolbar_button_exports, toolbar_tab_exports, toolbar_tab_group_exports, viewport_exports, display_options_dropdown_exports, param_editor_exports, preview_embed_exports, preview_inspector_exports]; + var modules = [app_exports, color_scheme_switcher_exports, header_exports, router_exports, status_bar_exports, status_bar_item_exports, status_bar_notifications_exports, button_exports, code_exports, icon_exports, nav_exports, nav_item_exports, pane_exports, tab_panel_exports, pane_group_exports, prose_exports, toolbar_exports, toolbar_button_exports, toolbar_tab_exports, toolbar_tab_group_exports, viewport_exports, display_options_dropdown_exports, param_editor_exports, preview_embed_exports, preview_inspector_exports]; var __default = modules; // assets/js/alpine/app.js window.Alpine = module_default; function initAlpine({ logger: logger2 }) {