katalyst-navigation 1.8.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/app/assets/builds/katalyst/navigation.esm.js +207 -109
- data/app/assets/builds/katalyst/navigation.js +207 -109
- data/app/assets/builds/katalyst/navigation.min.js +1 -1
- data/app/assets/builds/katalyst/navigation.min.js.map +1 -1
- data/app/assets/images/katalyst/navigation/icons/button.svg +1 -0
- data/app/assets/images/katalyst/navigation/icons/collapse.svg +3 -0
- data/app/assets/images/katalyst/navigation/icons/edit.svg +1 -0
- data/app/assets/images/katalyst/navigation/icons/expand.svg +3 -0
- data/app/assets/images/katalyst/navigation/icons/heading.svg +1 -0
- data/app/assets/images/katalyst/navigation/icons/hidden.svg +1 -0
- data/app/assets/images/katalyst/navigation/icons/indent.svg +3 -0
- data/app/assets/images/katalyst/navigation/icons/link.svg +1 -0
- data/app/assets/images/katalyst/navigation/icons/outdent.svg +4 -0
- data/app/assets/images/katalyst/navigation/icons/remove.svg +1 -0
- data/app/assets/stylesheets/katalyst/_navigation.scss +3 -0
- data/app/assets/stylesheets/katalyst/navigation/editor.css +175 -0
- data/app/assets/stylesheets/katalyst/navigation/icons.css +54 -0
- data/app/assets/stylesheets/katalyst/navigation/{editor/_status-bar.scss → status-bar.css} +30 -34
- data/app/assets/stylesheets/katalyst/navigation.css +3 -0
- data/app/components/katalyst/navigation/editor/base_component.rb +0 -6
- data/app/components/katalyst/navigation/editor/item_component.html.erb +26 -16
- data/app/components/katalyst/navigation/editor/item_component.rb +2 -3
- data/app/components/katalyst/navigation/editor/item_editor_component.rb +16 -19
- data/app/components/katalyst/navigation/editor/new_item_component.html.erb +15 -14
- data/app/components/katalyst/navigation/editor/new_item_component.rb +7 -10
- data/app/components/katalyst/navigation/editor/new_items_component.html.erb +41 -2
- data/app/components/katalyst/navigation/editor/new_items_component.rb +0 -2
- data/app/components/katalyst/navigation/editor/row_component.html.erb +2 -1
- data/app/components/katalyst/navigation/editor/status_bar_component.rb +9 -11
- data/app/components/katalyst/navigation/editor/table_component.html.erb +0 -6
- data/app/components/katalyst/navigation/editor/table_component.rb +12 -14
- data/app/components/katalyst/navigation/editor_component.html.erb +7 -0
- data/app/components/katalyst/navigation/editor_component.rb +13 -16
- data/app/controllers/katalyst/navigation/items_controller.rb +1 -1
- data/app/controllers/katalyst/navigation/menus_controller.rb +1 -1
- data/app/javascript/navigation/application.js +8 -3
- data/app/javascript/navigation/editor/item.js +1 -1
- data/app/javascript/navigation/editor/item_editor_controller.js +54 -0
- data/app/javascript/navigation/editor/list_controller.js +11 -103
- data/app/javascript/navigation/editor/new_items_controller.js +145 -0
- data/app/views/katalyst/navigation/items/_button.html.erb +24 -28
- data/app/views/katalyst/navigation/items/_form.html.erb +6 -0
- data/app/views/katalyst/navigation/items/_form_errors.html.erb +1 -1
- data/app/views/katalyst/navigation/items/_heading.html.erb +12 -14
- data/app/views/katalyst/navigation/items/_link.html.erb +24 -26
- data/app/views/katalyst/navigation/items/edit.html.erb +40 -2
- data/app/views/katalyst/navigation/items/edit.turbo_stream.erb +2 -0
- data/app/views/katalyst/navigation/items/update.turbo_stream.erb +0 -1
- data/app/views/katalyst/navigation/menus/show.html.erb +0 -1
- data/lib/katalyst/navigation/engine.rb +0 -1
- metadata +21 -28
- data/app/assets/stylesheets/katalyst/navigation/editor/_icon.scss +0 -17
- data/app/assets/stylesheets/katalyst/navigation/editor/_index.scss +0 -145
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-actions.scss +0 -93
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss +0 -19
- data/app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss +0 -67
- data/app/javascript/navigation/editor/new_item_controller.js +0 -12
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"navigation.min.js","sources":["../../../javascript/navigation/editor/item.js","../../../javascript/navigation/editor/menu.js","../../../javascript/navigation/editor/rules-engine.js","../../../javascript/navigation/editor/menu_controller.js","../../../javascript/navigation/editor/list_controller.js","../../../javascript/navigation/application.js","../../../javascript/navigation/editor/item_controller.js","../../../javascript/navigation/editor/new_item_controller.js","../../../javascript/navigation/editor/status_bar_controller.js"],"sourcesContent":["export default class Item {\n /**\n * Sort items by their index.\n *\n * @param a {Item}\n * @param b {Item}\n * @returns {number}\n */\n static comparator(a, b) {\n return a.index - b.index;\n }\n\n /**\n * @param node {Element} li[data-navigation-index]\n */\n constructor(node) {\n this.node = node;\n }\n\n /**\n * @returns {String} id of the node's item (from data attributes)\n */\n get itemId() {\n return this.node.dataset[`navigationItemId`];\n }\n\n get #itemIdInput() {\n return this.node.querySelector(`input[name$=\"[id]\"]`);\n }\n\n /**\n * @param itemId {String} id\n */\n set itemId(id) {\n if (this.itemId === id) return;\n\n this.node.dataset[`navigationItemId`] = `${id}`;\n this.#itemIdInput.value = `${id}`;\n }\n\n /**\n * @returns {number} logical nesting depth of node in menu\n */\n get depth() {\n return parseInt(this.node.dataset[`navigationDepth`]) || 0;\n }\n\n get #depthInput() {\n return this.node.querySelector(`input[name$=\"[depth]\"]`);\n }\n\n /**\n * @param depth {number} depth >= 0\n */\n set depth(depth) {\n if (this.depth === depth) return;\n\n this.node.dataset[`navigationDepth`] = `${depth}`;\n this.#depthInput.value = `${depth}`;\n }\n\n /**\n * @returns {number} logical index of node in menu (pre-order traversal)\n */\n get index() {\n return parseInt(this.node.dataset[`navigationIndex`]);\n }\n\n get #indexInput() {\n return this.node.querySelector(`input[name$=\"[index]\"]`);\n }\n\n /**\n * @param index {number} index >= 0\n */\n set index(index) {\n if (this.index === index) return;\n\n this.node.dataset[`navigationIndex`] = `${index}`;\n this.#indexInput.value = `${index}`;\n }\n\n /**\n * @returns {boolean} true if this item can have children\n */\n get isLayout() {\n return this.node.hasAttribute(\"data-content-layout\");\n }\n\n /**\n * @returns {Item} nearest neighbour (index - 1)\n */\n get previousItem() {\n let sibling = this.node.previousElementSibling;\n if (sibling) return new Item(sibling);\n }\n\n /**\n * @returns {Item} nearest neighbour (index + 1)\n */\n get nextItem() {\n let sibling = this.node.nextElementSibling;\n if (sibling) return new Item(sibling);\n }\n\n /**\n * @returns {boolean} true if this item has any collapsed children\n */\n hasCollapsedDescendants() {\n let childrenList = this.#childrenListElement;\n return !!childrenList && childrenList.children.length > 0;\n }\n\n /**\n * @returns {boolean} true if this item has any expanded children\n */\n hasExpandedDescendants() {\n let sibling = this.nextItem;\n return !!sibling && sibling.depth > this.depth;\n }\n\n /**\n * Recursively traverse the node and its descendants.\n *\n * @callback {Item}\n */\n traverse(callback) {\n // capture descendants before traversal in case of side-effects\n // specifically, setting depth affects calculation\n const expanded = this.#expandedDescendants;\n\n callback(this);\n this.#traverseCollapsed(callback);\n expanded.forEach((item) => item.#traverseCollapsed(callback));\n }\n\n /**\n * Recursively traverse the node's collapsed descendants, if any.\n *\n * @callback {Item}\n */\n #traverseCollapsed(callback) {\n if (!this.hasCollapsedDescendants()) return;\n\n this.#collapsedDescendants.forEach((item) => {\n callback(item);\n item.#traverseCollapsed(callback);\n });\n }\n\n /**\n * Collapses visible (logical) children into this element's hidden children\n * list, creating it if it doesn't already exist.\n */\n collapse() {\n let listElement = this.#childrenListElement;\n\n if (!listElement) listElement = createChildrenList(this.node);\n\n this.#expandedDescendants.forEach((child) =>\n listElement.appendChild(child.node),\n );\n }\n\n /**\n * Moves any collapsed children back into the parent menu.\n */\n expand() {\n if (!this.hasCollapsedDescendants()) return;\n\n Array.from(this.#childrenListElement.children)\n .reverse()\n .forEach((node) => {\n this.node.insertAdjacentElement(\"afterend\", node);\n });\n }\n\n /**\n * Sets the state of a given rule on the target node.\n *\n * @param rule {String}\n * @param deny {boolean}\n */\n toggleRule(rule, deny = false) {\n if (this.node.dataset.hasOwnProperty(rule) && !deny) {\n delete this.node.dataset[rule];\n }\n if (!this.node.dataset.hasOwnProperty(rule) && deny) {\n this.node.dataset[rule] = \"\";\n }\n\n if (rule === \"denyDrag\") {\n if (!this.node.hasAttribute(\"draggable\") && !deny) {\n this.node.setAttribute(\"draggable\", \"true\");\n }\n if (this.node.hasAttribute(\"draggable\") && deny) {\n this.node.removeAttribute(\"draggable\");\n }\n }\n }\n\n /**\n * Detects turbo item changes by comparing the dataset id with the input\n */\n hasItemIdChanged() {\n return !(this.#itemIdInput.value === this.itemId);\n }\n\n /**\n * Updates inputs, in case they don't match the data values, e.g., when the\n * nested inputs have been hot-swapped by turbo with data from the server.\n *\n * Updates itemId from input as that is the canonical source.\n */\n updateAfterChange() {\n this.itemId = this.#itemIdInput.value;\n this.#indexInput.value = this.index;\n this.#depthInput.value = this.depth;\n }\n\n /**\n * Finds the dom container for storing collapsed (hidden) children, if present.\n *\n * @returns {Element} ol[data-navigation-children]\n */\n get #childrenListElement() {\n return this.node.querySelector(`:scope > [data-navigation-children]`);\n }\n\n /**\n * @returns {Item[]} all items that follow this element that have a greater depth.\n */\n get #expandedDescendants() {\n const descendants = [];\n\n let sibling = this.nextItem;\n while (sibling && sibling.depth > this.depth) {\n descendants.push(sibling);\n sibling = sibling.nextItem;\n }\n\n return descendants;\n }\n\n /**\n * @returns {Item[]} all items directly contained inside this element's hidden children element.\n */\n get #collapsedDescendants() {\n if (!this.hasCollapsedDescendants()) return [];\n\n return Array.from(this.#childrenListElement.children).map(\n (node) => new Item(node),\n );\n }\n}\n\n/**\n * Finds or creates a dom container for storing collapsed (hidden) children.\n *\n * @param node {Element} li[data-navigation-index]\n * @returns {Element} ol[data-navigation-children]\n */\nfunction createChildrenList(node) {\n const childrenList = document.createElement(\"ol\");\n childrenList.setAttribute(\"class\", \"hidden\");\n\n childrenList.dataset[`navigationChildren`] = \"\";\n\n node.appendChild(childrenList);\n\n return childrenList;\n}\n","import Item from \"./item\";\n\n/**\n * @param nodes {NodeList}\n * @returns {Item[]}\n */\nfunction createItemList(nodes) {\n return Array.from(nodes).map((node) => new Item(node));\n}\n\nexport default class Menu {\n /**\n * @param node {Element} navigation editor list\n */\n constructor(node) {\n this.node = node;\n }\n\n /**\n * @return {Item[]} an ordered list of all items in the menu\n */\n get items() {\n return createItemList(\n this.node.querySelectorAll(\"[data-navigation-index]\"),\n );\n }\n\n /**\n * @return {String} a serialized description of the structure of the menu\n */\n get state() {\n const inputs = this.node.querySelectorAll(\"li input[type=hidden]\");\n return Array.from(inputs)\n .map((e) => e.value)\n .join(\"/\");\n }\n\n /**\n * Set the index of items based on their current position.\n */\n reindex() {\n this.items.map((item, index) => (item.index = index));\n }\n\n /**\n * Resets the order of items to their defined index.\n * Useful after an aborted drag.\n */\n reset() {\n this.items.sort(Item.comparator).forEach((item) => {\n this.node.appendChild(item.node);\n });\n }\n}\n","export default class RulesEngine {\n static rules = [\n \"denyDeNest\",\n \"denyNest\",\n \"denyCollapse\",\n \"denyExpand\",\n \"denyRemove\",\n \"denyDrag\",\n \"denyEdit\",\n ];\n\n constructor(maxDepth = null, debug = false) {\n this.maxDepth = maxDepth;\n if (debug) {\n this.debug = (...args) => console.log(...args);\n } else {\n this.debug = () => {};\n }\n }\n\n /**\n * Enforce structural rules to ensure that the given item is currently in a\n * valid state.\n *\n * @param {Item} item\n */\n normalize(item) {\n // structural rules enforce a valid tree structure\n this.firstItemDepthZero(item);\n this.depthMustBeSet(item);\n this.itemCannotHaveInvalidDepth(item);\n this.itemCannotExceedDepthLimit(item);\n this.parentMustBeLayout(item);\n this.parentCannotHaveExpandedAndCollapsedChildren(item);\n }\n\n /**\n * Apply rules to the given item to determine what operations are permitted.\n *\n * @param {Item} item\n */\n update(item) {\n this.rules = {};\n\n // behavioural rules define what the user is allowed to do\n this.parentsCannotDeNest(item);\n this.rootsCannotDeNest(item);\n this.nestingNeedsParent(item);\n this.nestingCannotExceedMaxDepth(item);\n this.leavesCannotCollapse(item);\n this.needHiddenItemsToExpand(item);\n this.parentsCannotBeDeleted(item);\n this.parentsCannotBeDragged(item);\n\n RulesEngine.rules.forEach((rule) => {\n item.toggleRule(rule, !!this.rules[rule]);\n });\n }\n\n /**\n * First item can't have a parent, so its depth should always be 0\n */\n firstItemDepthZero(item) {\n if (item.index === 0 && item.depth !== 0) {\n this.debug(`enforce depth on item ${item.index}: ${item.depth} => 0`);\n\n item.depth = 0;\n }\n }\n\n /**\n * Every item should have a non-negative depth set.\n *\n * @param {Item} item\n */\n depthMustBeSet(item) {\n if (isNaN(item.depth) || item.depth < 0) {\n this.debug(`unset depth on item ${item.index}: => 0`);\n\n item.depth = 0;\n }\n }\n\n /**\n * Depth must increase stepwise.\n *\n * @param {Item} item\n */\n itemCannotHaveInvalidDepth(item) {\n const previous = item.previousItem;\n if (previous && previous.depth < item.depth - 1) {\n this.debug(\n `invalid depth on item ${item.index}: ${item.depth} => ${\n previous.depth + 1\n }`,\n );\n\n item.depth = previous.depth + 1;\n }\n }\n\n /**\n * Depth must not exceed menu's depth limit.\n *\n * @param {Item} item\n */\n itemCannotExceedDepthLimit(item) {\n if (this.maxDepth > 0 && this.maxDepth <= item.depth) {\n // Note: this change can cause an issue where the previous item is treated\n // like a parent even though it no longer has children. This is because\n // items are processed in order. This issue does not seem worth solving\n // as it only occurs if the max depth is altered. The issue can be worked\n // around by saving the menu.\n item.depth = this.maxDepth - 1;\n }\n }\n\n /**\n * Parent item, if any, must be a layout.\n *\n * @param {Item} item\n */\n parentMustBeLayout(item) {\n // if we're the first child, make sure our parent is a layout\n // if we're a sibling, we know the previous item is valid so we must be too\n const previous = item.previousItem;\n if (previous && previous.depth < item.depth && !previous.isLayout) {\n this.debug(\n `invalid parent for item ${item.index}: ${item.depth} => ${previous.depth}`,\n );\n\n item.depth = previous.depth;\n }\n }\n\n /**\n * If a parent has expanded and collapsed children, expand.\n *\n * @param {Item} item\n */\n parentCannotHaveExpandedAndCollapsedChildren(item) {\n if (item.hasCollapsedDescendants() && item.hasExpandedDescendants()) {\n this.debug(`expanding collapsed children of item ${item.index}`);\n\n item.expand();\n }\n }\n\n /**\n * De-nesting an item would create a gap of 2 between itself and its children\n *\n * @param {Item} item\n */\n parentsCannotDeNest(item) {\n if (item.hasExpandedDescendants()) this.#deny(\"denyDeNest\");\n }\n\n /**\n * Item depth can't go below 0.\n *\n * @param {Item} item\n */\n rootsCannotDeNest(item) {\n if (item.depth === 0) this.#deny(\"denyDeNest\");\n }\n\n /**\n * If an item doesn't have children it can't be collapsed.\n *\n * @param {Item} item\n */\n leavesCannotCollapse(item) {\n if (!item.hasExpandedDescendants()) this.#deny(\"denyCollapse\");\n }\n\n /**\n * If an item doesn't have any hidden descendants then it can't be expanded.\n *\n * @param {Item} item\n */\n needHiddenItemsToExpand(item) {\n if (!item.hasCollapsedDescendants()) this.#deny(\"denyExpand\");\n }\n\n /**\n * An item can't be nested (indented) if it doesn't have a valid parent.\n *\n * @param {Item} item\n */\n nestingNeedsParent(item) {\n const previous = item.previousItem;\n // no previous, so cannot nest\n if (!previous) this.#deny(\"denyNest\");\n // previous is too shallow, nesting would increase depth too much\n else if (previous.depth < item.depth) this.#deny(\"denyNest\");\n // new parent is not a layout\n else if (previous.depth === item.depth && !previous.isLayout)\n this.#deny(\"denyNest\");\n }\n\n /**\n * An item can't be nested (indented) if doing so would exceed the max depth.\n *\n * @param {Item} item\n */\n nestingCannotExceedMaxDepth(item) {\n if (this.maxDepth > 0 && this.maxDepth <= item.depth + 1) {\n this.#deny(\"denyNest\");\n }\n }\n\n /**\n * An item can't be deleted if it has visible children.\n *\n * @param {Item} item\n */\n parentsCannotBeDeleted(item) {\n if (!item.itemId || item.hasExpandedDescendants()) this.#deny(\"denyRemove\");\n }\n\n /**\n * Items cannot be dragged if they have visible children.\n *\n * @param {Item} item\n */\n parentsCannotBeDragged(item) {\n if (item.hasExpandedDescendants()) this.#deny(\"denyDrag\");\n }\n\n /**\n * Record a deny.\n *\n * @param rule {String}\n */\n #deny(rule) {\n this.rules[rule] = true;\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nimport Item from \"./item\";\nimport Menu from \"./menu\";\nimport RulesEngine from \"./rules-engine\";\n\nexport default class MenuController extends Controller {\n static targets = [\"menu\"];\n static values = {\n maxDepth: Number,\n };\n\n // Caution: connect is called on attachment, but also on morph/render\n connect() {\n this.state = this.menu.state;\n\n this.reindex();\n }\n\n get menu() {\n return new Menu(this.menuTarget);\n }\n\n reindex() {\n this.menu.reindex();\n this.#update();\n }\n\n reset() {\n this.menu.reset();\n }\n\n drop(event) {\n this.menu.reindex(); // set indexes before calculating previous\n\n const item = getEventItem(event);\n const previous = item.previousItem;\n\n let delta = 0;\n if (previous === undefined) {\n // if previous does not exist, set depth to 0\n delta = -item.depth;\n } else if (item.nextItem && item.nextItem.depth > previous.depth) {\n // if next is a child of previous, make item a child of previous\n delta = previous.depth - item.depth + 1;\n } else {\n // otherwise, make item a sibling of previous\n delta = previous.depth - item.depth;\n }\n\n item.traverse((child) => {\n child.depth += delta;\n });\n\n this.#update();\n event.preventDefault();\n }\n\n remove(event) {\n const item = getEventItem(event);\n\n item.node.remove();\n\n this.#update();\n event.preventDefault();\n }\n\n nest(event) {\n const item = getEventItem(event);\n\n item.traverse((child) => {\n child.depth += 1;\n });\n\n this.#update();\n event.preventDefault();\n }\n\n deNest(event) {\n const item = getEventItem(event);\n\n item.traverse((child) => {\n child.depth -= 1;\n });\n\n this.#update();\n event.preventDefault();\n }\n\n collapse(event) {\n const item = getEventItem(event);\n\n item.collapse();\n\n this.#update();\n event.preventDefault();\n }\n\n expand(event) {\n const item = getEventItem(event);\n\n item.expand();\n\n this.#update();\n event.preventDefault();\n }\n\n /**\n * Re-apply rules to items to enable/disable appropriate actions.\n */\n #update() {\n // debounce requests to ensure that we only update once per tick\n this.updateRequested = true;\n setTimeout(() => {\n if (!this.updateRequested) return;\n\n this.updateRequested = false;\n const engine = new RulesEngine(this.maxDepthValue);\n this.menu.items.forEach((item) => engine.normalize(item));\n this.menu.items.forEach((item) => engine.update(item));\n\n this.#notifyChange();\n }, 0);\n }\n\n #notifyChange() {\n this.dispatch(\"change\", {\n bubbles: true,\n prefix: \"navigation\",\n detail: { dirty: this.#isDirty() },\n });\n }\n\n #isDirty() {\n return this.menu.state !== this.state;\n }\n}\n\nfunction getEventItem(event) {\n return new Item(event.target.closest(\"[data-navigation-item]\"));\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nexport default class ListController extends Controller {\n connect() {\n this.enterCount = 0;\n }\n\n /**\n * When the user starts a drag within the list, set the item's dataTransfer\n * properties to indicate that it's being dragged and update its style.\n *\n * We delay setting the dataset property until the next animation frame\n * so that the style updates can be computed before the drag begins.\n *\n * @param event {DragEvent}\n */\n dragstart(event) {\n if (this.element !== event.target.parentElement) return;\n\n const target = event.target;\n event.dataTransfer.effectAllowed = \"move\";\n\n // update element style after drag has begun\n requestAnimationFrame(() => (target.dataset.dragging = \"\"));\n }\n\n /**\n * When the user drags an item over another item in the last, swap the\n * dragging item with the item under the cursor.\n *\n * As a special case, if the item is dragged over placeholder space at the end\n * of the list, move the item to the bottom of the list instead. This allows\n * users to hit the list element more easily when adding new items to an empty\n * list.\n *\n * @param event {DragEvent}\n */\n dragover(event) {\n const item = this.dragItem;\n if (!item) return;\n\n swap(dropTarget(event.target), item);\n\n event.preventDefault();\n return true;\n }\n\n /**\n * When the user drags an item into the list, create a placeholder item to\n * represent the new item. Note that we can't access the drag data\n * until drop, so we assume that this is our template item for now.\n *\n * Users can cancel the drag by dragging the item out of the list or by\n * pressing escape. Both are handled by `cancelDrag`.\n *\n * @param event {DragEvent}\n */\n dragenter(event) {\n event.preventDefault();\n\n // Safari doesn't support relatedTarget, so we count enter/leave pairs\n this.enterCount++;\n\n if (copyAllowed(event) && !this.dragItem) {\n const item = document.createElement(\"li\");\n item.dataset.dragging = \"\";\n item.dataset.newItem = \"\";\n this.element.appendChild(item);\n }\n }\n\n /**\n * When the user drags the item out of the list, remove the placeholder.\n * This allows users to cancel the drag by dragging the item out of the list.\n *\n * @param event {DragEvent}\n */\n dragleave(event) {\n // Safari doesn't support relatedTarget, so we count enter/leave pairs\n // https://bugs.webkit.org/show_bug.cgi?id=66547\n this.enterCount--;\n\n if (\n this.enterCount <= 0 &&\n this.dragItem.dataset.hasOwnProperty(\"newItem\")\n ) {\n this.cancelDrag(event);\n }\n }\n\n /**\n * When the user drops an item into the list, end the drag and reindex the list.\n *\n * If the item is a new item, we replace the placeholder with the template\n * item data from the dataTransfer API.\n *\n * @param event {DragEvent}\n */\n drop(event) {\n let item = this.dragItem;\n\n if (!item) return;\n\n event.preventDefault();\n delete item.dataset.dragging;\n swap(dropTarget(event.target), item);\n\n if (item.dataset.hasOwnProperty(\"newItem\")) {\n const placeholder = item;\n const template = document.createElement(\"template\");\n template.innerHTML = event.dataTransfer.getData(\"text/html\");\n item = template.content.querySelector(\"li\");\n\n this.element.replaceChild(item, placeholder);\n requestAnimationFrame(() =>\n item.querySelector(\"[role='button'][value='edit']\").click(),\n );\n }\n\n this.dispatch(\"drop\", {\n target: item,\n bubbles: true,\n prefix: \"navigation\",\n });\n }\n\n /**\n * End an in-progress drag. If the item is a new item, remove it, otherwise\n * reset the item's style and restore its original position in the list.\n */\n dragend() {\n const item = this.dragItem;\n\n if (!item) {\n } else if (item.dataset.hasOwnProperty(\"newItem\")) {\n item.remove();\n } else {\n delete item.dataset.dragging;\n this.reset();\n }\n }\n\n get isDragging() {\n return !!this.dragItem;\n }\n\n get dragItem() {\n return this.element.querySelector(\"[data-dragging]\");\n }\n\n reindex() {\n this.dispatch(\"reindex\", { bubbles: true, prefix: \"navigation\" });\n }\n\n reset() {\n this.dispatch(\"reset\", { bubbles: true, prefix: \"navigation\" });\n }\n}\n\n/**\n * Swaps two list items. If target is a list, the item is appended.\n *\n * @param target the target element to swap with\n * @param item the item the user is dragging\n */\nfunction swap(target, item) {\n if (!target) return;\n if (target === item) return;\n\n if (target.nodeName === \"LI\") {\n const positionComparison = target.compareDocumentPosition(item);\n if (positionComparison & Node.DOCUMENT_POSITION_FOLLOWING) {\n target.insertAdjacentElement(\"beforebegin\", item);\n } else if (positionComparison & Node.DOCUMENT_POSITION_PRECEDING) {\n target.insertAdjacentElement(\"afterend\", item);\n }\n }\n\n if (target.nodeName === \"OL\") {\n target.appendChild(item);\n }\n}\n\n/**\n * Returns true if the event supports copy or copy move.\n *\n * Chrome and Firefox use copy, but Safari only supports copyMove.\n */\nfunction copyAllowed(event) {\n return (\n event.dataTransfer.effectAllowed === \"copy\" ||\n event.dataTransfer.effectAllowed === \"copyMove\"\n );\n}\n\n/**\n * Given an event target, return the closest drop target, if any.\n */\nfunction dropTarget(e) {\n return (\n e &&\n (e.closest(\"[data-controller='navigation--editor--list'] > *\") ||\n e.closest(\"[data-controller='navigation--editor--list']\"))\n );\n}\n","import MenuController from \"./editor/menu_controller\";\nimport ItemController from \"./editor/item_controller\";\nimport ListController from \"./editor/list_controller\";\nimport NewItemController from \"./editor/new_item_controller\";\nimport StatusBarController from \"./editor/status_bar_controller\";\n\nconst Definitions = [\n {\n identifier: \"navigation--editor--menu\",\n controllerConstructor: MenuController,\n },\n {\n identifier: \"navigation--editor--item\",\n controllerConstructor: ItemController,\n },\n {\n identifier: \"navigation--editor--list\",\n controllerConstructor: ListController,\n },\n {\n identifier: \"navigation--editor--new-item\",\n controllerConstructor: NewItemController,\n },\n {\n identifier: \"navigation--editor--status-bar\",\n controllerConstructor: StatusBarController,\n },\n];\n\nexport { Definitions as default };\n","import { Controller } from \"@hotwired/stimulus\";\nimport Item from \"./item\";\n\nexport default class ItemController extends Controller {\n get item() {\n return new Item(this.li);\n }\n\n get ol() {\n return this.element.closest(\"ol\");\n }\n\n get li() {\n return this.element.closest(\"li\");\n }\n\n connect() {\n if (this.element.dataset.hasOwnProperty(\"delete\")) {\n this.remove();\n }\n // if index is not already set, re-index will set it\n else if (!(this.item.index >= 0)) {\n this.reindex();\n }\n // if item has been replaced via turbo, re-index will run the rules engine\n // update our depth and index with values from the li's data attributes\n else if (this.item.hasItemIdChanged()) {\n this.item.updateAfterChange();\n this.reindex();\n }\n }\n\n remove() {\n // capture ol\n const ol = this.ol;\n // remove self from dom\n this.li.remove();\n // reindex ol\n this.reindex();\n }\n\n reindex() {\n this.dispatch(\"reindex\", { bubbles: true, prefix: \"navigation\" });\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nexport default class NewItemController extends Controller {\n static targets = [\"template\"];\n\n dragstart(event) {\n if (this.element !== event.target) return;\n\n event.dataTransfer.setData(\"text/html\", this.templateTarget.innerHTML);\n event.dataTransfer.effectAllowed = \"copy\";\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nexport default class StatusBarController extends Controller {\n connect() {\n // cache the version's state in the controller on connect\n this.versionState = this.element.dataset.state;\n }\n\n morph(e) {\n if (e.target !== this.element) return;\n\n this.versionState = this.element.dataset.state;\n this.update({ dirty: false });\n }\n\n change(e) {\n if (e.detail && e.detail.hasOwnProperty(\"dirty\")) {\n this.update(e.detail);\n }\n }\n\n update({ dirty }) {\n if (dirty) {\n this.element.dataset.state = \"dirty\";\n } else {\n this.element.dataset.state = this.versionState;\n }\n }\n}\n"],"names":["Item","comparator","a","b","index","constructor","node","this","itemId","dataset","itemIdInput","querySelector","id","value","depth","parseInt","depthInput","indexInput","isLayout","hasAttribute","previousItem","sibling","previousElementSibling","nextItem","nextElementSibling","hasCollapsedDescendants","childrenList","childrenListElement","children","length","hasExpandedDescendants","traverse","callback","expanded","expandedDescendants","traverseCollapsed","forEach","item","collapsedDescendants","collapse","listElement","document","createElement","setAttribute","appendChild","createChildrenList","child","expand","Array","from","reverse","insertAdjacentElement","toggleRule","rule","deny","hasOwnProperty","removeAttribute","hasItemIdChanged","updateAfterChange","descendants","push","map","Menu","items","nodes","querySelectorAll","state","inputs","e","join","reindex","reset","sort","RulesEngine","static","maxDepth","debug","args","console","log","normalize","firstItemDepthZero","depthMustBeSet","itemCannotHaveInvalidDepth","itemCannotExceedDepthLimit","parentMustBeLayout","parentCannotHaveExpandedAndCollapsedChildren","update","rules","parentsCannotDeNest","rootsCannotDeNest","nestingNeedsParent","nestingCannotExceedMaxDepth","leavesCannotCollapse","needHiddenItemsToExpand","parentsCannotBeDeleted","parentsCannotBeDragged","isNaN","previous","getEventItem","event","target","closest","swap","nodeName","positionComparison","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","dropTarget","Definitions","identifier","controllerConstructor","Controller","Number","connect","menu","menuTarget","drop","delta","undefined","preventDefault","remove","nest","deNest","updateRequested","setTimeout","engine","maxDepthValue","notifyChange","dispatch","bubbles","prefix","detail","dirty","isDirty","li","ol","element","enterCount","dragstart","parentElement","dataTransfer","effectAllowed","requestAnimationFrame","dragging","dragover","dragItem","dragenter","copyAllowed","newItem","dragleave","cancelDrag","placeholder","template","innerHTML","getData","content","replaceChild","click","dragend","isDragging","setData","templateTarget","versionState","morph","change"],"mappings":"gDAAe,MAAMA,EAQnB,iBAAOC,CAAWC,EAAGC,GACnB,OAAOD,EAAEE,MAAQD,EAAEC,KACpB,CAKD,WAAAC,CAAYC,GACVC,KAAKD,KAAOA,CACb,CAKD,UAAIE,GACF,OAAOD,KAAKD,KAAKG,QAA0B,gBAC5C,CAED,KAAIC,GACF,OAAOH,KAAKD,KAAKK,cAAc,sBAChC,CAKD,UAAIH,CAAOI,GACLL,KAAKC,SAAWI,IAEpBL,KAAKD,KAAKG,QAA0B,iBAAI,GAAGG,IAC3CL,MAAKG,EAAaG,MAAQ,GAAGD,IAC9B,CAKD,SAAIE,GACF,OAAOC,SAASR,KAAKD,KAAKG,QAAyB,kBAAM,CAC1D,CAED,KAAIO,GACF,OAAOT,KAAKD,KAAKK,cAAc,yBAChC,CAKD,SAAIG,CAAMA,GACJP,KAAKO,QAAUA,IAEnBP,KAAKD,KAAKG,QAAyB,gBAAI,GAAGK,IAC1CP,MAAKS,EAAYH,MAAQ,GAAGC,IAC7B,CAKD,SAAIV,GACF,OAAOW,SAASR,KAAKD,KAAKG,QAAyB,gBACpD,CAED,KAAIQ,GACF,OAAOV,KAAKD,KAAKK,cAAc,yBAChC,CAKD,SAAIP,CAAMA,GACJG,KAAKH,QAAUA,IAEnBG,KAAKD,KAAKG,QAA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C7CxC,eAAiB,CAAC,YAElB,SAAAmE,CAAUzC,GACJ7F,KAAKoI,UAAYvC,EAAMC,SAE3BD,EAAM2C,aAAaoB,QAAQ,YAAa5J,KAAK6J,eAAeR,WAC5DxD,EAAM2C,aAAaC,cAAgB,OACpC,IFaD,CACEhC,WAAY,iCACZC,sBGvBW,cAAkCC,EAC/C,OAAAE,GAEE7G,KAAK8J,aAAe9J,KAAKoI,QAAQlI,QAAQyD,KAC1C,CAED,KAAAoG,CAAMlG,GACAA,EAAEiC,SAAW9F,KAAKoI,UAEtBpI,KAAK8J,aAAe9J,KAAKoI,QAAQlI,QAAQyD,MACzC3D,KAAKgF,OAAO,CAAEgD,OAAO,IACtB,CAED,MAAAgC,CAAOnG,GACDA,EAAEkE,QAAUlE,EAAEkE,OAAO/E,eAAe,UACtChD,KAAKgF,OAAOnB,EAAEkE,OAEjB,CAED,MAAA/C,EAAOgD,MAAEA,IAELhI,KAAKoI,QAAQlI,QAAQyD,MADnBqE,EAC2B,QAEAhI,KAAK8J,YAErC"}
|
1
|
+
{"version":3,"file":"navigation.min.js","sources":["../../../javascript/navigation/editor/item.js","../../../javascript/navigation/editor/menu.js","../../../javascript/navigation/editor/rules-engine.js","../../../javascript/navigation/editor/menu_controller.js","../../../javascript/navigation/editor/list_controller.js","../../../javascript/navigation/application.js","../../../javascript/navigation/editor/item_controller.js","../../../javascript/navigation/editor/item_editor_controller.js","../../../javascript/navigation/editor/new_items_controller.js","../../../javascript/navigation/editor/status_bar_controller.js"],"sourcesContent":["export default class Item {\n /**\n * Sort items by their index.\n *\n * @param a {Item}\n * @param b {Item}\n * @returns {number}\n */\n static comparator(a, b) {\n return a.index - b.index;\n }\n\n /**\n * @param node {Element} li[data-navigation-index]\n */\n constructor(node) {\n this.node = node;\n }\n\n /**\n * @returns {String} id of the node's item (from data attributes)\n */\n get itemId() {\n return this.node.dataset[`navigationItemId`];\n }\n\n get #itemIdInput() {\n return this.node.querySelector(`input[name$=\"[id]\"]`);\n }\n\n /**\n * @param itemId {String} id\n */\n set itemId(id) {\n if (this.itemId === id) return;\n\n this.node.dataset[`navigationItemId`] = `${id}`;\n this.#itemIdInput.value = `${id}`;\n }\n\n /**\n * @returns {number} logical nesting depth of node in menu\n */\n get depth() {\n return parseInt(this.node.dataset[`navigationDepth`]) || 0;\n }\n\n get #depthInput() {\n return this.node.querySelector(`input[name$=\"[depth]\"]`);\n }\n\n /**\n * @param depth {number} depth >= 0\n */\n set depth(depth) {\n if (this.depth === depth) return;\n\n this.node.dataset[`navigationDepth`] = `${depth}`;\n this.#depthInput.value = `${depth}`;\n }\n\n /**\n * @returns {number} logical index of node in menu (pre-order traversal)\n */\n get index() {\n return parseInt(this.node.dataset[`navigationIndex`]);\n }\n\n get #indexInput() {\n return this.node.querySelector(`input[name$=\"[index]\"]`);\n }\n\n /**\n * @param index {number} index >= 0\n */\n set index(index) {\n if (this.index === index) return;\n\n this.node.dataset[`navigationIndex`] = `${index}`;\n this.#indexInput.value = `${index}`;\n }\n\n /**\n * @returns {boolean} true if this item can have children\n */\n get isLayout() {\n return this.node.hasAttribute(\"data-content-layout\");\n }\n\n /**\n * @returns {Item} nearest neighbour (index - 1)\n */\n get previousItem() {\n let sibling = this.node.previousElementSibling;\n if (sibling) return new Item(sibling);\n }\n\n /**\n * @returns {Item} nearest neighbour (index + 1)\n */\n get nextItem() {\n let sibling = this.node.nextElementSibling;\n if (sibling) return new Item(sibling);\n }\n\n /**\n * @returns {boolean} true if this item has any collapsed children\n */\n hasCollapsedDescendants() {\n let childrenList = this.#childrenListElement;\n return !!childrenList && childrenList.children.length > 0;\n }\n\n /**\n * @returns {boolean} true if this item has any expanded children\n */\n hasExpandedDescendants() {\n let sibling = this.nextItem;\n return !!sibling && sibling.depth > this.depth;\n }\n\n /**\n * Recursively traverse the node and its descendants.\n *\n * @callback {Item}\n */\n traverse(callback) {\n // capture descendants before traversal in case of side-effects\n // specifically, setting depth affects calculation\n const expanded = this.#expandedDescendants;\n\n callback(this);\n this.#traverseCollapsed(callback);\n expanded.forEach((item) => item.#traverseCollapsed(callback));\n }\n\n /**\n * Recursively traverse the node's collapsed descendants, if any.\n *\n * @callback {Item}\n */\n #traverseCollapsed(callback) {\n if (!this.hasCollapsedDescendants()) return;\n\n this.#collapsedDescendants.forEach((item) => {\n callback(item);\n item.#traverseCollapsed(callback);\n });\n }\n\n /**\n * Collapses visible (logical) children into this element's hidden children\n * list, creating it if it doesn't already exist.\n */\n collapse() {\n let listElement = this.#childrenListElement;\n\n if (!listElement) listElement = createChildrenList(this.node);\n\n this.#expandedDescendants.forEach((child) =>\n listElement.appendChild(child.node),\n );\n }\n\n /**\n * Moves any collapsed children back into the parent menu.\n */\n expand() {\n if (!this.hasCollapsedDescendants()) return;\n\n Array.from(this.#childrenListElement.children)\n .reverse()\n .forEach((node) => {\n this.node.insertAdjacentElement(\"afterend\", node);\n });\n }\n\n /**\n * Sets the state of a given rule on the target node.\n *\n * @param rule {String}\n * @param deny {boolean}\n */\n toggleRule(rule, deny = false) {\n if (this.node.dataset.hasOwnProperty(rule) && !deny) {\n delete this.node.dataset[rule];\n }\n if (!this.node.dataset.hasOwnProperty(rule) && deny) {\n this.node.dataset[rule] = \"\";\n }\n\n if (rule === \"denyDrag\") {\n if (!this.node.hasAttribute(\"draggable\") && !deny) {\n this.node.setAttribute(\"draggable\", \"true\");\n }\n if (this.node.hasAttribute(\"draggable\") && deny) {\n this.node.removeAttribute(\"draggable\");\n }\n }\n }\n\n /**\n * Detects turbo item changes by comparing the dataset id with the input\n */\n hasItemIdChanged() {\n return !(this.#itemIdInput.value === this.itemId);\n }\n\n /**\n * Updates inputs, in case they don't match the data values, e.g., when the\n * nested inputs have been hot-swapped by turbo with data from the server.\n *\n * Updates itemId from input as that is the canonical source.\n */\n updateAfterChange() {\n this.itemId = this.#itemIdInput.value;\n this.#indexInput.value = this.index;\n this.#depthInput.value = this.depth;\n }\n\n /**\n * Finds the dom container for storing collapsed (hidden) children, if present.\n *\n * @returns {Element} ol[data-navigation-children]\n */\n get #childrenListElement() {\n return this.node.querySelector(`:scope > [data-navigation-children]`);\n }\n\n /**\n * @returns {Item[]} all items that follow this element that have a greater depth.\n */\n get #expandedDescendants() {\n const descendants = [];\n\n let sibling = this.nextItem;\n while (sibling && sibling.depth > this.depth) {\n descendants.push(sibling);\n sibling = sibling.nextItem;\n }\n\n return descendants;\n }\n\n /**\n * @returns {Item[]} all items directly contained inside this element's hidden children element.\n */\n get #collapsedDescendants() {\n if (!this.hasCollapsedDescendants()) return [];\n\n return Array.from(this.#childrenListElement.children).map(\n (node) => new Item(node),\n );\n }\n}\n\n/**\n * Finds or creates a dom container for storing collapsed (hidden) children.\n *\n * @param node {Element} li[data-navigation-index]\n * @returns {Element} ol[data-navigation-children]\n */\nfunction createChildrenList(node) {\n const childrenList = document.createElement(\"ol\");\n childrenList.toggleAttribute(\"hidden\", true);\n\n childrenList.dataset[`navigationChildren`] = \"\";\n\n node.appendChild(childrenList);\n\n return childrenList;\n}\n","import Item from \"./item\";\n\n/**\n * @param nodes {NodeList}\n * @returns {Item[]}\n */\nfunction createItemList(nodes) {\n return Array.from(nodes).map((node) => new Item(node));\n}\n\nexport default class Menu {\n /**\n * @param node {Element} navigation editor list\n */\n constructor(node) {\n this.node = node;\n }\n\n /**\n * @return {Item[]} an ordered list of all items in the menu\n */\n get items() {\n return createItemList(\n this.node.querySelectorAll(\"[data-navigation-index]\"),\n );\n }\n\n /**\n * @return {String} a serialized description of the structure of the menu\n */\n get state() {\n const inputs = this.node.querySelectorAll(\"li input[type=hidden]\");\n return Array.from(inputs)\n .map((e) => e.value)\n .join(\"/\");\n }\n\n /**\n * Set the index of items based on their current position.\n */\n reindex() {\n this.items.map((item, index) => (item.index = index));\n }\n\n /**\n * Resets the order of items to their defined index.\n * Useful after an aborted drag.\n */\n reset() {\n this.items.sort(Item.comparator).forEach((item) => {\n this.node.appendChild(item.node);\n });\n }\n}\n","export default class RulesEngine {\n static rules = [\n \"denyDeNest\",\n \"denyNest\",\n \"denyCollapse\",\n \"denyExpand\",\n \"denyRemove\",\n \"denyDrag\",\n \"denyEdit\",\n ];\n\n constructor(maxDepth = null, debug = false) {\n this.maxDepth = maxDepth;\n if (debug) {\n this.debug = (...args) => console.log(...args);\n } else {\n this.debug = () => {};\n }\n }\n\n /**\n * Enforce structural rules to ensure that the given item is currently in a\n * valid state.\n *\n * @param {Item} item\n */\n normalize(item) {\n // structural rules enforce a valid tree structure\n this.firstItemDepthZero(item);\n this.depthMustBeSet(item);\n this.itemCannotHaveInvalidDepth(item);\n this.itemCannotExceedDepthLimit(item);\n this.parentMustBeLayout(item);\n this.parentCannotHaveExpandedAndCollapsedChildren(item);\n }\n\n /**\n * Apply rules to the given item to determine what operations are permitted.\n *\n * @param {Item} item\n */\n update(item) {\n this.rules = {};\n\n // behavioural rules define what the user is allowed to do\n this.parentsCannotDeNest(item);\n this.rootsCannotDeNest(item);\n this.nestingNeedsParent(item);\n this.nestingCannotExceedMaxDepth(item);\n this.leavesCannotCollapse(item);\n this.needHiddenItemsToExpand(item);\n this.parentsCannotBeDeleted(item);\n this.parentsCannotBeDragged(item);\n\n RulesEngine.rules.forEach((rule) => {\n item.toggleRule(rule, !!this.rules[rule]);\n });\n }\n\n /**\n * First item can't have a parent, so its depth should always be 0\n */\n firstItemDepthZero(item) {\n if (item.index === 0 && item.depth !== 0) {\n this.debug(`enforce depth on item ${item.index}: ${item.depth} => 0`);\n\n item.depth = 0;\n }\n }\n\n /**\n * Every item should have a non-negative depth set.\n *\n * @param {Item} item\n */\n depthMustBeSet(item) {\n if (isNaN(item.depth) || item.depth < 0) {\n this.debug(`unset depth on item ${item.index}: => 0`);\n\n item.depth = 0;\n }\n }\n\n /**\n * Depth must increase stepwise.\n *\n * @param {Item} item\n */\n itemCannotHaveInvalidDepth(item) {\n const previous = item.previousItem;\n if (previous && previous.depth < item.depth - 1) {\n this.debug(\n `invalid depth on item ${item.index}: ${item.depth} => ${\n previous.depth + 1\n }`,\n );\n\n item.depth = previous.depth + 1;\n }\n }\n\n /**\n * Depth must not exceed menu's depth limit.\n *\n * @param {Item} item\n */\n itemCannotExceedDepthLimit(item) {\n if (this.maxDepth > 0 && this.maxDepth <= item.depth) {\n // Note: this change can cause an issue where the previous item is treated\n // like a parent even though it no longer has children. This is because\n // items are processed in order. This issue does not seem worth solving\n // as it only occurs if the max depth is altered. The issue can be worked\n // around by saving the menu.\n item.depth = this.maxDepth - 1;\n }\n }\n\n /**\n * Parent item, if any, must be a layout.\n *\n * @param {Item} item\n */\n parentMustBeLayout(item) {\n // if we're the first child, make sure our parent is a layout\n // if we're a sibling, we know the previous item is valid so we must be too\n const previous = item.previousItem;\n if (previous && previous.depth < item.depth && !previous.isLayout) {\n this.debug(\n `invalid parent for item ${item.index}: ${item.depth} => ${previous.depth}`,\n );\n\n item.depth = previous.depth;\n }\n }\n\n /**\n * If a parent has expanded and collapsed children, expand.\n *\n * @param {Item} item\n */\n parentCannotHaveExpandedAndCollapsedChildren(item) {\n if (item.hasCollapsedDescendants() && item.hasExpandedDescendants()) {\n this.debug(`expanding collapsed children of item ${item.index}`);\n\n item.expand();\n }\n }\n\n /**\n * De-nesting an item would create a gap of 2 between itself and its children\n *\n * @param {Item} item\n */\n parentsCannotDeNest(item) {\n if (item.hasExpandedDescendants()) this.#deny(\"denyDeNest\");\n }\n\n /**\n * Item depth can't go below 0.\n *\n * @param {Item} item\n */\n rootsCannotDeNest(item) {\n if (item.depth === 0) this.#deny(\"denyDeNest\");\n }\n\n /**\n * If an item doesn't have children it can't be collapsed.\n *\n * @param {Item} item\n */\n leavesCannotCollapse(item) {\n if (!item.hasExpandedDescendants()) this.#deny(\"denyCollapse\");\n }\n\n /**\n * If an item doesn't have any hidden descendants then it can't be expanded.\n *\n * @param {Item} item\n */\n needHiddenItemsToExpand(item) {\n if (!item.hasCollapsedDescendants()) this.#deny(\"denyExpand\");\n }\n\n /**\n * An item can't be nested (indented) if it doesn't have a valid parent.\n *\n * @param {Item} item\n */\n nestingNeedsParent(item) {\n const previous = item.previousItem;\n // no previous, so cannot nest\n if (!previous) this.#deny(\"denyNest\");\n // previous is too shallow, nesting would increase depth too much\n else if (previous.depth < item.depth) this.#deny(\"denyNest\");\n // new parent is not a layout\n else if (previous.depth === item.depth && !previous.isLayout)\n this.#deny(\"denyNest\");\n }\n\n /**\n * An item can't be nested (indented) if doing so would exceed the max depth.\n *\n * @param {Item} item\n */\n nestingCannotExceedMaxDepth(item) {\n if (this.maxDepth > 0 && this.maxDepth <= item.depth + 1) {\n this.#deny(\"denyNest\");\n }\n }\n\n /**\n * An item can't be deleted if it has visible children.\n *\n * @param {Item} item\n */\n parentsCannotBeDeleted(item) {\n if (!item.itemId || item.hasExpandedDescendants()) this.#deny(\"denyRemove\");\n }\n\n /**\n * Items cannot be dragged if they have visible children.\n *\n * @param {Item} item\n */\n parentsCannotBeDragged(item) {\n if (item.hasExpandedDescendants()) this.#deny(\"denyDrag\");\n }\n\n /**\n * Record a deny.\n *\n * @param rule {String}\n */\n #deny(rule) {\n this.rules[rule] = true;\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nimport Item from \"./item\";\nimport Menu from \"./menu\";\nimport RulesEngine from \"./rules-engine\";\n\nexport default class MenuController extends Controller {\n static targets = [\"menu\"];\n static values = {\n maxDepth: Number,\n };\n\n // Caution: connect is called on attachment, but also on morph/render\n connect() {\n this.state = this.menu.state;\n\n this.reindex();\n }\n\n get menu() {\n return new Menu(this.menuTarget);\n }\n\n reindex() {\n this.menu.reindex();\n this.#update();\n }\n\n reset() {\n this.menu.reset();\n }\n\n drop(event) {\n this.menu.reindex(); // set indexes before calculating previous\n\n const item = getEventItem(event);\n const previous = item.previousItem;\n\n let delta = 0;\n if (previous === undefined) {\n // if previous does not exist, set depth to 0\n delta = -item.depth;\n } else if (item.nextItem && item.nextItem.depth > previous.depth) {\n // if next is a child of previous, make item a child of previous\n delta = previous.depth - item.depth + 1;\n } else {\n // otherwise, make item a sibling of previous\n delta = previous.depth - item.depth;\n }\n\n item.traverse((child) => {\n child.depth += delta;\n });\n\n this.#update();\n event.preventDefault();\n }\n\n remove(event) {\n const item = getEventItem(event);\n\n item.node.remove();\n\n this.#update();\n event.preventDefault();\n }\n\n nest(event) {\n const item = getEventItem(event);\n\n item.traverse((child) => {\n child.depth += 1;\n });\n\n this.#update();\n event.preventDefault();\n }\n\n deNest(event) {\n const item = getEventItem(event);\n\n item.traverse((child) => {\n child.depth -= 1;\n });\n\n this.#update();\n event.preventDefault();\n }\n\n collapse(event) {\n const item = getEventItem(event);\n\n item.collapse();\n\n this.#update();\n event.preventDefault();\n }\n\n expand(event) {\n const item = getEventItem(event);\n\n item.expand();\n\n this.#update();\n event.preventDefault();\n }\n\n /**\n * Re-apply rules to items to enable/disable appropriate actions.\n */\n #update() {\n // debounce requests to ensure that we only update once per tick\n this.updateRequested = true;\n setTimeout(() => {\n if (!this.updateRequested) return;\n\n this.updateRequested = false;\n const engine = new RulesEngine(this.maxDepthValue);\n this.menu.items.forEach((item) => engine.normalize(item));\n this.menu.items.forEach((item) => engine.update(item));\n\n this.#notifyChange();\n }, 0);\n }\n\n #notifyChange() {\n this.dispatch(\"change\", {\n bubbles: true,\n prefix: \"navigation\",\n detail: { dirty: this.#isDirty() },\n });\n }\n\n #isDirty() {\n return this.menu.state !== this.state;\n }\n}\n\nfunction getEventItem(event) {\n return new Item(event.target.closest(\"[data-navigation-item]\"));\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nexport default class ListController extends Controller {\n /**\n * When the user starts a drag within the list, set the item's dataTransfer\n * properties to indicate that it's being dragged and update its style.\n *\n * We delay setting the dataset property until the next animation frame\n * so that the style updates can be computed before the drag begins.\n *\n * @param event {DragEvent}\n */\n dragstart(event) {\n if (this.element !== event.target.parentElement) return;\n\n const target = event.target;\n event.dataTransfer.effectAllowed = \"move\";\n\n // update element style after drag has begun\n requestAnimationFrame(() => (target.dataset.dragging = \"\"));\n }\n\n /**\n * When the user drags an item over another item in the last, swap the\n * dragging item with the item under the cursor.\n *\n * @param event {DragEvent}\n */\n dragover(event) {\n const item = this.dragItem;\n if (!item) return;\n\n swap(dropTarget(event.target), item);\n\n event.preventDefault();\n return true;\n }\n\n /**\n * When the user drops an item, end the drag and reindex the list.\n *\n * @param event {DragEvent}\n */\n drop(event) {\n let item = this.dragItem;\n\n if (!item) return;\n\n event.preventDefault();\n delete item.dataset.dragging;\n swap(dropTarget(event.target), item);\n\n this.dispatch(\"drop\", {\n target: item,\n bubbles: true,\n prefix: \"navigation\",\n });\n }\n\n /**\n * End an in-progress drag by resetting the item's style and restoring its\n * original position in the list.\n */\n dragend() {\n const item = this.dragItem;\n\n if (item) {\n delete item.dataset.dragging;\n this.reset();\n }\n }\n\n get isDragging() {\n return !!this.dragItem;\n }\n\n get dragItem() {\n return this.element.querySelector(\"[data-dragging]\");\n }\n\n reindex() {\n this.dispatch(\"reindex\", { bubbles: true, prefix: \"navigation\" });\n }\n\n reset() {\n this.dispatch(\"reset\", { bubbles: true, prefix: \"navigation\" });\n }\n}\n\n/**\n * Swaps two list items.\n *\n * @param target the target element to swap with\n * @param item the item the user is dragging\n */\nfunction swap(target, item) {\n if (!target) return;\n if (target === item) return;\n\n const positionComparison = target.compareDocumentPosition(item);\n if (positionComparison & Node.DOCUMENT_POSITION_FOLLOWING) {\n target.insertAdjacentElement(\"beforebegin\", item);\n } else if (positionComparison & Node.DOCUMENT_POSITION_PRECEDING) {\n target.insertAdjacentElement(\"afterend\", item);\n }\n}\n\n/**\n * Given an event target, return the closest drop target, if any.\n */\nfunction dropTarget(e) {\n return e && e.closest(\"[data-controller='navigation--editor--list'] > *\");\n}\n","import MenuController from \"./editor/menu_controller\";\nimport ItemController from \"./editor/item_controller\";\nimport ItemEditorController from \"./editor/item_editor_controller\";\nimport ListController from \"./editor/list_controller\";\nimport NewItemsController from \"./editor/new_items_controller\";\nimport StatusBarController from \"./editor/status_bar_controller\";\n\nconst Definitions = [\n {\n identifier: \"navigation--editor--menu\",\n controllerConstructor: MenuController,\n },\n {\n identifier: \"navigation--editor--item\",\n controllerConstructor: ItemController,\n },\n {\n identifier: \"navigation--editor--item-editor\",\n controllerConstructor: ItemEditorController,\n },\n {\n identifier: \"navigation--editor--list\",\n controllerConstructor: ListController,\n },\n {\n identifier: \"navigation--editor--new-items\",\n controllerConstructor: NewItemsController,\n },\n {\n identifier: \"navigation--editor--status-bar\",\n controllerConstructor: StatusBarController,\n },\n];\n\nexport { Definitions as default };\n","import { Controller } from \"@hotwired/stimulus\";\nimport Item from \"./item\";\n\nexport default class ItemController extends Controller {\n get item() {\n return new Item(this.li);\n }\n\n get ol() {\n return this.element.closest(\"ol\");\n }\n\n get li() {\n return this.element.closest(\"li\");\n }\n\n connect() {\n if (this.element.dataset.hasOwnProperty(\"delete\")) {\n this.remove();\n }\n // if index is not already set, re-index will set it\n else if (!(this.item.index >= 0)) {\n this.reindex();\n }\n // if item has been replaced via turbo, re-index will run the rules engine\n // update our depth and index with values from the li's data attributes\n else if (this.item.hasItemIdChanged()) {\n this.item.updateAfterChange();\n this.reindex();\n }\n }\n\n remove() {\n // capture ol\n const ol = this.ol;\n // remove self from dom\n this.li.remove();\n // reindex ol\n this.reindex();\n }\n\n reindex() {\n this.dispatch(\"reindex\", { bubbles: true, prefix: \"navigation\" });\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport Item from \"./item\";\n\nexport default class ItemEditorController extends Controller {\n static targets = [\"dialog\"];\n\n connect() {\n this.element.addEventListener(\"turbo:submit-end\", this.onSubmit);\n }\n\n disconnect() {\n this.element.removeEventListener(\"turbo:submit-end\", this.onSubmit);\n }\n\n dismiss() {\n if (!this.dialogTarget) return;\n if (!this.dialogTarget.open) this.dialogTarget.close();\n\n if (!(\"itemPersisted\" in this.dialogTarget.dataset)) {\n this.#removeTargetItem();\n }\n\n this.element.removeAttribute(\"src\");\n this.dialogTarget.remove();\n }\n\n dialogTargetConnected(dialog) {\n dialog.showModal();\n }\n\n onSubmit = (event) => {\n if (event.detail.success) {\n this.dialogTarget.close();\n this.element.removeAttribute(\"src\");\n this.dialogTarget.remove();\n }\n };\n\n noop() {}\n\n #removeTargetItem() {\n const el = document.getElementById(this.dialogTarget.dataset.itemId);\n const item = new Item(el.closest(\"[data-navigation-item]\"));\n const list = item.node.parentElement;\n\n item.node.remove();\n\n this.dispatch(\"reindex\", {\n target: list,\n bubbles: true,\n prefix: \"navigation\",\n });\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nconst EDGE_AREA = 24;\n\nexport default class NewItemsController extends Controller {\n static targets = [\"inline\"];\n\n connect() {\n this.form.addEventListener(\"mousemove\", this.move);\n }\n\n disconnect() {\n this.form?.removeEventListener(\"mousemove\", this.move);\n delete this.currentItem;\n }\n\n open(e) {\n e.preventDefault();\n this.dialog.showModal();\n }\n\n close(e) {\n e.preventDefault();\n this.dialog.close();\n }\n\n noop(e) {}\n\n /**\n * Add the selected item to the DOM at the current position or the end of the list.\n */\n add(e) {\n e.preventDefault();\n\n const template = e.target.querySelector(\"template\");\n const item = template.content.querySelector(\"li\").cloneNode(true);\n const target = this.currentItem;\n\n if (target) {\n target.insertAdjacentElement(\"beforebegin\", item);\n } else {\n this.list.insertAdjacentElement(\"beforeend\", item);\n }\n\n this.toggleInline(false);\n this.dialog.close();\n\n requestAnimationFrame(() => {\n item.querySelector(`[value=\"edit\"]`).click();\n });\n }\n\n morph(e) {\n e.preventDefault();\n this.dialog.close();\n }\n\n move = (e) => {\n if (this.isOverInlineTarget(e)) return;\n if (this.dialog.open) return;\n\n const target = this.getCurrentItem(e);\n\n // return if we're already showing this item\n if (this.currentItem === target) return;\n\n // hide the button if it's already visible\n if (this.currentItem) this.toggleInline(false);\n\n this.currentItem = target;\n\n // clear any previously set timer\n if (this.timer) clearTimeout(this.timer);\n\n // show the button after a debounce pause\n this.timer = setTimeout(() => {\n delete this.timer;\n this.toggleInline();\n }, 100);\n };\n\n toggleInline(show = !!this.currentItem) {\n if (show) {\n this.inlineTarget.style.top = `${this.currentItem.offsetTop}px`;\n this.inlineTarget.toggleAttribute(\"hidden\", false);\n } else {\n this.inlineTarget.toggleAttribute(\"hidden\", true);\n }\n }\n\n get dialog() {\n return this.element.querySelector(\"dialog\");\n }\n\n /**\n * @returns {HTMLFormElement}\n */\n get form() {\n return this.element.closest(\"form\");\n }\n\n /**\n * @returns {HTMLUListElement,null}\n */\n get list() {\n return this.form.querySelector(\n `[data-controller=\"navigation--editor--list\"]`,\n );\n }\n\n /**\n * @param {MouseEvent} e\n * @returns {HTMLLIElement,null}\n */\n getCurrentItem(e) {\n const item = document.elementFromPoint(e.clientX, e.clientY).closest(\"li\");\n if (!item) return null;\n\n const bounds = item.getBoundingClientRect();\n\n // check X for center(ish) mouse position\n if (e.clientX < bounds.left + bounds.width / 2 - 2 * EDGE_AREA) return null;\n if (e.clientX > bounds.left + bounds.width / 2 + 2 * EDGE_AREA) return null;\n\n // check Y for hits on this item or it's next sibling\n if (e.clientY - bounds.y <= EDGE_AREA) {\n return item;\n } else if (bounds.y + bounds.height - e.clientY <= EDGE_AREA) {\n return item.nextElementSibling;\n } else {\n return null;\n }\n }\n\n /**\n * @param {MouseEvent} e\n * @returns {Boolean} true when the target of the event is the floating button\n */\n isOverInlineTarget(e) {\n return (\n this.inlineTarget ===\n document.elementFromPoint(e.clientX, e.clientY).closest(\"div\")\n );\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\n\nexport default class StatusBarController extends Controller {\n connect() {\n // cache the version's state in the controller on connect\n this.versionState = this.element.dataset.state;\n }\n\n morph(e) {\n if (e.target !== this.element) return;\n\n this.versionState = this.element.dataset.state;\n this.update({ dirty: false });\n }\n\n change(e) {\n if (e.detail && e.detail.hasOwnProperty(\"dirty\")) {\n this.update(e.detail);\n }\n }\n\n update({ dirty }) {\n if (dirty) {\n this.element.dataset.state = \"dirty\";\n } else {\n this.element.dataset.state = this.versionState;\n }\n }\n}\n"],"names":["Item","comparator","a","b","index","constructor","node","this","itemId","dataset","itemIdInput","querySelector","id","value","depth","parseInt","depthInput","indexInput","isLayout","hasAttribute","previousItem","sibling","previousElementSibling","nextItem","nextElementSibling","hasCollapsedDescendants","childrenList","childrenListElement","children","length","hasExpandedDescendants","traverse","callback","expanded","expandedDescendants","traverseCollapsed","forEach","item","collapsedDescendants","collapse","listElement","document","createElement","toggleAttribute","appendChild","createChildrenList","child","expand","Array","from","reverse","insertAdjacentElement","toggleRule","rule","deny","hasOwnProperty","setAttribute","removeAttribute","hasItemIdChanged","updateAfterChange","descendants","push","map","Menu","items","nodes","querySelectorAll","state","inputs","e","join","reindex","reset","sort","RulesEngine","static","maxDepth","debug","args","console","log","normalize","firstItemDepthZero","depthMustBeSet","itemCannotHaveInvalidDepth","itemCannotExceedDepthLimit","parentMustBeLayout","parentCannotHaveExpandedAndCollapsedChildren","update","rules","parentsCannotDeNest","rootsCannotDeNest","nestingNeedsParent","nestingCannotExceedMaxDepth","leavesCannotCollapse","needHiddenItemsToExpand","parentsCannotBeDeleted","parentsCannotBeDragged","isNaN","previous","getEventItem","event","target","closest","swap","positionComparison","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","dropTarget","Definitions","identifier","controllerConstructor","Controller","Number","connect","menu","menuTarget","drop","delta","undefined","preventDefault","remove","nest","deNest","updateRequested","setTimeout","engine","maxDepthValue","notifyChange","dispatch","bubbles","prefix","detail","dirty","isDirty","li","ol","element","addEventListener","onSubmit","disconnect","removeEventListener","dismiss","dialogTarget","open","close","removeTargetItem","dialogTargetConnected","dialog","showModal","success","noop","el","getElementById","list","parentElement","dragstart","dataTransfer","effectAllowed","requestAnimationFrame","dragging","dragover","dragItem","dragend","isDragging","form","move","currentItem","add","content","cloneNode","toggleInline","click","morph","isOverInlineTarget","getCurrentItem","timer","clearTimeout","show","inlineTarget","style","top","offsetTop","elementFromPoint","clientX","clientY","bounds","getBoundingClientRect","left","width","y","height","versionState","change"],"mappings":"gDAAe,MAAMA,EAQnB,iBAAOC,CAAWC,EAAGC,GACnB,OAAOD,EAA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AIJ,EAAOK,OAAS5H,EAAEsH,SA7H1B,GA8HLtJ,EAAKb,mBAEL,IAEb,CAME,kBAAAwJ,CAAmB3G,GACjB,OACE9D,KAAK8K,eACL5I,SAASgJ,iBAAiBpH,EAAEqH,QAASrH,EAAEsH,SAASpF,QAAQ,MAE9D,IHnHE,CACES,WAAY,iCACZC,sBI5BW,cAAkCC,EAC/C,OAAAE,GAEE7G,KAAK2L,aAAe3L,KAAKoI,QAAQlI,QAAQ0D,KAC7C,CAEE,KAAA4G,CAAM1G,GACAA,EAAEiC,SAAW/F,KAAKoI,UAEtBpI,KAAK2L,aAAe3L,KAAKoI,QAAQlI,QAAQ0D,MACzC5D,KAAKiF,OAAO,CAAE+C,OAAO,IACzB,CAEE,MAAA4D,CAAO9H,GACDA,EAAEiE,QAAUjE,EAAEiE,OAAO/E,eAAe,UACtChD,KAAKiF,OAAOnB,EAAEiE,OAEpB,CAEE,MAAA9C,EAAO+C,MAAEA,IAELhI,KAAKoI,QAAQlI,QAAQ0D,MADnBoE,EAC2B,QAEAhI,KAAK2L,YAExC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 9h6m0 0-2 2m2-2L9 7M2 4h12c.5 0 1 .497 1 1.111V13c0 .5-.5 1-1 1H2c-.5 0-1-.5-1-1V5c0-.5.5-1 1-1"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m10.1 3.1 2.8 2.8m1.522-1.531a1.973 1.973 0 0 0-2.79-2.791l-9.343 9.344a1.4 1.4 0 0 0-.35.581l-.924 3.047a.35.35 0 0 0 .436.435l3.047-.924a1.4 1.4 0 0 0 .58-.348z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 4.111V2.556C1 1.7 1.7 1 2.556 1H4.11m7.778 0h1.555C14.3 1 15 1.7 15 2.556V4.11m0 7.778v1.555C15 14.3 14.3 15 13.444 15H11.89M4.11 15H2.556A1.56 1.56 0 0 1 1 13.444V11.89M4.889 4.11h3.889c.43 0 .778.348.778.778v2.333c0 .43-.349.778-.778.778h-3.89a.78.78 0 0 1-.777-.778V4.89c0-.43.348-.778.778-.778M7.222 8h3.89c.429 0 .777.348.777.778v2.333c0 .43-.348.778-.778.778H7.222a.78.78 0 0 1-.778-.778V8.778c0-.43.349-.778.778-.778"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7.113 3.153a7.52 7.52 0 0 1 7.843 4.603.7.7 0 0 1 0 .487 7.5 7.5 0 0 1-1.01 1.743M9.458 9.51a2.1 2.1 0 0 1-2.97-2.97m5.346 5.308A7.525 7.525 0 0 1 1.044 8.244a.7.7 0 0 1 0-.488 7.53 7.53 0 0 1 3.112-3.6M1 1l14 14"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.9 13H4.5a3.5 3.5 0 1 1 0-7h1.4m4.2 0h1.4a3.5 3.5 0 1 1 0 7h-1.4M5.2 9.5h5.6"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 4h12m-1.333 0v9.333c0 .667-.667 1.334-1.334 1.334H3.667c-.667 0-1.334-.667-1.334-1.334V4m2 0V2.667C4.333 2 5 1.333 5.667 1.333h2.666C9 1.333 9.667 2 9.667 2.667V4"/></svg>
|
@@ -0,0 +1,175 @@
|
|
1
|
+
.navigation--editor {
|
2
|
+
--row-inset: 2rem;
|
3
|
+
--row-hover-bg: var(--color-tint, #fff0eb);
|
4
|
+
--row-padding: 0 var(--space-2xs, 0.25rem);
|
5
|
+
|
6
|
+
position: relative;
|
7
|
+
}
|
8
|
+
|
9
|
+
/* Rows */
|
10
|
+
|
11
|
+
.navigation--editor--item {
|
12
|
+
/* https://github.com/react-dnd/react-dnd/issues/832 */
|
13
|
+
transform: translate3d(0, 0, 0);
|
14
|
+
|
15
|
+
&:hover {
|
16
|
+
background: var(--row-hover-bg);
|
17
|
+
}
|
18
|
+
|
19
|
+
&[draggable] {
|
20
|
+
cursor: grab;
|
21
|
+
}
|
22
|
+
|
23
|
+
/* Dragged visuals */
|
24
|
+
|
25
|
+
&[data-dragging] {
|
26
|
+
box-shadow: inset 0 0 0 2px var(--color-tint, #fff0eb);
|
27
|
+
|
28
|
+
> * {
|
29
|
+
visibility: hidden;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
/* Hidden items */
|
34
|
+
|
35
|
+
[data-invisible] {
|
36
|
+
color: var(--color-mid, #aaa);
|
37
|
+
}
|
38
|
+
|
39
|
+
/* row item controller */
|
40
|
+
|
41
|
+
> [data-controller] {
|
42
|
+
display: grid;
|
43
|
+
grid-template-columns: 1fr auto;
|
44
|
+
align-items: baseline;
|
45
|
+
padding: var(--row-padding);
|
46
|
+
}
|
47
|
+
|
48
|
+
/* row content */
|
49
|
+
|
50
|
+
.tree {
|
51
|
+
display: flex;
|
52
|
+
gap: var(--space-xs, 0.5rem);
|
53
|
+
align-items: baseline;
|
54
|
+
|
55
|
+
text-overflow: ellipsis;
|
56
|
+
overflow: hidden;
|
57
|
+
white-space: nowrap;
|
58
|
+
}
|
59
|
+
|
60
|
+
.actions-group {
|
61
|
+
display: flex;
|
62
|
+
gap: var(--space-3xs, 0.25em);
|
63
|
+
align-items: baseline;
|
64
|
+
}
|
65
|
+
|
66
|
+
/* Depth */
|
67
|
+
|
68
|
+
&[data-navigation-depth="1"] .tree {
|
69
|
+
padding-left: calc(var(--row-inset) * 1);
|
70
|
+
}
|
71
|
+
|
72
|
+
&[data-navigation-depth="2"] .tree {
|
73
|
+
padding-left: calc(var(--row-inset) * 2);
|
74
|
+
}
|
75
|
+
|
76
|
+
&[data-navigation-depth="3"] .tree {
|
77
|
+
padding-left: calc(var(--row-inset) * 3);
|
78
|
+
}
|
79
|
+
|
80
|
+
&[data-navigation-depth="4"] .tree {
|
81
|
+
padding-left: calc(var(--row-inset) * 4);
|
82
|
+
}
|
83
|
+
|
84
|
+
&[data-navigation-depth="5"] .tree {
|
85
|
+
padding-left: calc(var(--row-inset) * 5);
|
86
|
+
}
|
87
|
+
|
88
|
+
&[data-navigation-depth="6"] .tree {
|
89
|
+
padding-left: calc(var(--row-inset) * 6);
|
90
|
+
}
|
91
|
+
|
92
|
+
/* Lower opacity for buttons you can't use */
|
93
|
+
|
94
|
+
&[data-deny-de-nest] .button:has([data-icon="outdent"]),
|
95
|
+
&[data-deny-nest] .button:has([data-icon="indent"]),
|
96
|
+
&[data-deny-remove] .button:has([data-icon="remove"]),
|
97
|
+
&[data-deny-drag] .button:has([data-icon="drag"]),
|
98
|
+
&[data-deny-edit] .button:has([data-icon="edit"]) {
|
99
|
+
opacity: 0.2;
|
100
|
+
pointer-events: none;
|
101
|
+
}
|
102
|
+
|
103
|
+
&:not(:hover) .actions-group .button {
|
104
|
+
opacity: 0;
|
105
|
+
}
|
106
|
+
|
107
|
+
/* Only show 1 of the collapse / expand button */
|
108
|
+
|
109
|
+
&[data-deny-collapse] .button:has([data-icon="collapse"]),
|
110
|
+
&[data-deny-expand] .button:has([data-icon="expand"]) {
|
111
|
+
display: none !important;
|
112
|
+
pointer-events: none;
|
113
|
+
}
|
114
|
+
|
115
|
+
/* Always show the expand button when there are hidden children */
|
116
|
+
|
117
|
+
&:has([data-navigation-children]) .button:has([data-icon="expand"]) {
|
118
|
+
opacity: 1 !important;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
/* Inline add link */
|
123
|
+
|
124
|
+
.navigation--editor--inline-add {
|
125
|
+
position: absolute;
|
126
|
+
left: 0;
|
127
|
+
right: 0;
|
128
|
+
top: 0;
|
129
|
+
height: 0;
|
130
|
+
z-index: 1;
|
131
|
+
outline: 1px solid var(--color-dark-glare, #555);
|
132
|
+
|
133
|
+
button {
|
134
|
+
position: absolute;
|
135
|
+
top: 0;
|
136
|
+
left: 50%;
|
137
|
+
margin: 0;
|
138
|
+
padding: 0.25rem;
|
139
|
+
|
140
|
+
animation: navigation--editor--pulse 200ms ease;
|
141
|
+
transform: translate(-50%, -50%) scale(1);
|
142
|
+
}
|
143
|
+
|
144
|
+
button:active {
|
145
|
+
transform: translate(-50%, -50%) scale(99%);
|
146
|
+
}
|
147
|
+
|
148
|
+
&[hidden] button {
|
149
|
+
transform: translate(-50%, -50%) scale(0);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
@keyframes navigation--editor--pulse {
|
154
|
+
0% {
|
155
|
+
transform: translate(-50%, -50%) scale(0);
|
156
|
+
}
|
157
|
+
|
158
|
+
80% {
|
159
|
+
transform: translate(-50%, -50%) scale(1.1);
|
160
|
+
}
|
161
|
+
|
162
|
+
100% {
|
163
|
+
transform: translate(-50%, -50%) scale(1);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
/* New items picker */
|
168
|
+
|
169
|
+
.navigation--editor--new-items {
|
170
|
+
.items-list {
|
171
|
+
display: flex;
|
172
|
+
gap: var(--space-2xs, 0.25rem);
|
173
|
+
flex-wrap: wrap;
|
174
|
+
}
|
175
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
.navigation--editor {
|
2
|
+
[data-icon="outdent"] {
|
3
|
+
-webkit-mask: url("/katalyst/navigation/icons/outdent.svg");
|
4
|
+
mask: url("/katalyst/navigation/icons/outdent.svg");
|
5
|
+
}
|
6
|
+
|
7
|
+
[data-icon="indent"] {
|
8
|
+
-webkit-mask: url("/katalyst/navigation/icons/indent.svg");
|
9
|
+
mask: url("/katalyst/navigation/icons/indent.svg");
|
10
|
+
}
|
11
|
+
|
12
|
+
[data-icon="collapse"] {
|
13
|
+
-webkit-mask: url("/katalyst/navigation/icons/collapse.svg");
|
14
|
+
mask: url("/katalyst/navigation/icons/collapse.svg");
|
15
|
+
aspect-ratio: 12/16;
|
16
|
+
}
|
17
|
+
|
18
|
+
[data-icon="expand"] {
|
19
|
+
-webkit-mask: url("/katalyst/navigation/icons/expand.svg") no-repeat center;
|
20
|
+
mask: url("/katalyst/navigation/icons/expand.svg") no-repeat center;
|
21
|
+
aspect-ratio: 12/16;
|
22
|
+
}
|
23
|
+
|
24
|
+
[data-icon="edit"] {
|
25
|
+
-webkit-mask: url("/katalyst/navigation/icons/edit.svg");
|
26
|
+
mask: url("/katalyst/navigation/icons/edit.svg");
|
27
|
+
}
|
28
|
+
|
29
|
+
[data-icon="remove"] {
|
30
|
+
-webkit-mask: url("/katalyst/navigation/icons/remove.svg");
|
31
|
+
mask: url("/katalyst/navigation/icons/remove.svg");
|
32
|
+
aspect-ratio: 14/16;
|
33
|
+
}
|
34
|
+
|
35
|
+
[data-icon="hidden"] {
|
36
|
+
-webkit-mask: url("/katalyst/navigation/icons/hidden.svg");
|
37
|
+
mask: url("/katalyst/navigation/icons/hidden.svg");
|
38
|
+
}
|
39
|
+
|
40
|
+
[data-icon="heading"] {
|
41
|
+
-webkit-mask: url("/katalyst/navigation/icons/heading.svg");
|
42
|
+
mask: url("/katalyst/navigation/icons/heading.svg");
|
43
|
+
}
|
44
|
+
|
45
|
+
[data-icon="link"] {
|
46
|
+
-webkit-mask: url("/katalyst/navigation/icons/link.svg");
|
47
|
+
mask: url("/katalyst/navigation/icons/link.svg");
|
48
|
+
}
|
49
|
+
|
50
|
+
[data-icon="button"] {
|
51
|
+
-webkit-mask: url("/katalyst/navigation/icons/button.svg");
|
52
|
+
mask: url("/katalyst/navigation/icons/button.svg");
|
53
|
+
}
|
54
|
+
}
|
@@ -1,17 +1,33 @@
|
|
1
1
|
[data-controller="navigation--editor--status-bar"] {
|
2
|
+
--background: #ebf9eb;
|
3
|
+
--color: #4dd45c;
|
4
|
+
--border: #4dd45c;
|
5
|
+
|
6
|
+
display: grid;
|
7
|
+
grid-template-columns: 1fr auto;
|
8
|
+
grid-template-areas: "status actions";
|
9
|
+
align-items: baseline;
|
10
|
+
grid-column-gap: 2rem;
|
11
|
+
|
2
12
|
min-height: 3rem;
|
3
13
|
line-height: 3rem;
|
4
|
-
padding:
|
14
|
+
padding-inline: var(--space-m);
|
5
15
|
background: var(--background);
|
6
16
|
color: var(--color);
|
7
17
|
border: 1px solid var(--border);
|
8
18
|
margin-bottom: 1rem;
|
9
19
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
20
|
+
&[data-state="draft"] {
|
21
|
+
--background: #fefaf3;
|
22
|
+
--color: #ffa800;
|
23
|
+
--border: #ffa800;
|
24
|
+
}
|
25
|
+
|
26
|
+
&[data-state="dirty"] {
|
27
|
+
--background: #eee;
|
28
|
+
--color: #aaa;
|
29
|
+
--border: #888;
|
30
|
+
}
|
15
31
|
|
16
32
|
.status-text {
|
17
33
|
display: none;
|
@@ -25,44 +41,24 @@
|
|
25
41
|
display: unset;
|
26
42
|
}
|
27
43
|
|
44
|
+
button {
|
45
|
+
--button-bg: var(--color);
|
46
|
+
--button-hover-bg: var(--color);
|
47
|
+
}
|
48
|
+
|
28
49
|
menu {
|
29
|
-
display: inline;
|
50
|
+
display: inline-flex;
|
30
51
|
grid-area: actions;
|
31
52
|
margin: 0;
|
32
53
|
padding: 0;
|
54
|
+
gap: var(--space-3xs, 0.25rem);
|
55
|
+
align-items: baseline;
|
33
56
|
}
|
34
57
|
|
35
58
|
menu > li {
|
36
59
|
display: inline;
|
37
60
|
}
|
38
61
|
|
39
|
-
.button {
|
40
|
-
color: inherit;
|
41
|
-
line-height: 1rem;
|
42
|
-
margin-left: 0.5rem;
|
43
|
-
}
|
44
|
-
|
45
|
-
.button--primary {
|
46
|
-
background: var(--color);
|
47
|
-
border: 1px solid var(--border);
|
48
|
-
color: white;
|
49
|
-
|
50
|
-
&[disabled] {
|
51
|
-
background: var(--color);
|
52
|
-
opacity: 0.8;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
.button--secondary {
|
57
|
-
background: var(--background);
|
58
|
-
border: 1px solid var(--border);
|
59
|
-
color: var(--color);
|
60
|
-
|
61
|
-
&[disabled] {
|
62
|
-
background: var(--background);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
62
|
&[data-state="published"] {
|
67
63
|
[value="publish"],
|
68
64
|
[value="save"],
|
@@ -6,12 +6,6 @@ module Katalyst
|
|
6
6
|
class BaseComponent < ViewComponent::Base
|
7
7
|
include Katalyst::HtmlAttributes
|
8
8
|
|
9
|
-
MENU_CONTROLLER = "navigation--editor--menu"
|
10
|
-
LIST_CONTROLLER = "navigation--editor--list"
|
11
|
-
ITEM_CONTROLLER = "navigation--editor--item"
|
12
|
-
STATUS_BAR_CONTROLLER = "navigation--editor--status-bar"
|
13
|
-
NEW_ITEM_CONTROLLER = "navigation--editor--new-item"
|
14
|
-
|
15
9
|
attr_accessor :menu, :item
|
16
10
|
|
17
11
|
delegate :config, to: ::Katalyst::Navigation
|