katalyst-navigation 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94cc7f739764b2d65865d91d0d6f1431671bee909e285b51238f4343dd15883e
4
- data.tar.gz: 51a2493050682848606784167c351865776daa9cc403e59e096e269b55afc208
3
+ metadata.gz: e67d176cb768b324a1be109e98dc001bd9ce8419abba00d4856cd0d3c84dc6c9
4
+ data.tar.gz: 35555b9bac352c1e21786dcdddc638ccc3929e314003c7859dc3be56ad13c03e
5
5
  SHA512:
6
- metadata.gz: 51127826086e93bdc9d6796f8eab5096c0d4a1d6af14a0623f3387a6c567263b6f28351507f5bcb683cce7f88f0a5832ac7583e2a28d59b31463eeeba8b09710
7
- data.tar.gz: 1b7b2e4b291da7ae044b6c5de3c5df0a0d56b5ba111d7fbf454648916baf2a8634cfbc2c94216a3f327ad5ffba51440b00ca5d052bcf0d55b070b345de2a72ea
6
+ metadata.gz: 4ba4e987c87e8dfe56def8ef4d2f9214c7376cd285385008079b82b84f2ed44e354248d1d8aceaa50f2ac0cad81311935b038c5cedaff9001ab38199bea61b8a
7
+ data.tar.gz: 0ac8744ff0e111c921974d82951f4c7b09f57df32d1c93d8c5cff0474de53b5254d53bbc2129d90ca81597ae08c8166e843f0609e58bd5c6311606da0fa1f4f7
@@ -41,9 +41,7 @@ export default class MenuController extends Controller {
41
41
  nest(event) {
42
42
  const item = getEventItem(event);
43
43
 
44
- item.traverse((child) => {
45
- child.depth += 1;
46
- });
44
+ item.nest();
47
45
 
48
46
  this.#update();
49
47
  event.preventDefault();
@@ -52,9 +50,7 @@ export default class MenuController extends Controller {
52
50
  deNest(event) {
53
51
  const item = getEventItem(event);
54
52
 
55
- item.traverse((child) => {
56
- child.depth -= 1;
57
- });
53
+ item.deNest();
58
54
 
59
55
  this.#update();
60
56
  event.preventDefault();
@@ -128,6 +128,39 @@ export default class Item {
128
128
  expanded.forEach((item) => item.traverse(callback));
129
129
  }
130
130
 
131
+ /**
132
+ * Increase the depth of this item and its descendants.
133
+ * If this causes it to become a child of a collapsed item, then collapse this item.
134
+ */
135
+ nest() {
136
+ this.traverse((child) => {
137
+ child.depth += 1;
138
+ });
139
+
140
+ if (this.previousItem.hasCollapsedDescendants()) {
141
+ this.previousItem.collapseChild(this);
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Move the given item into this element's hidden children list.
147
+ * Assumes the list already exists.
148
+ *
149
+ * @param item {Item}
150
+ */
151
+ collapseChild(item) {
152
+ this.#childrenListElement.appendChild(item.node);
153
+ }
154
+
155
+ /**
156
+ * Decrease the depth of this item (and its descendants).
157
+ */
158
+ deNest() {
159
+ this.traverse((child) => {
160
+ child.depth -= 1;
161
+ });
162
+ }
163
+
131
164
  /**
132
165
  * Collapses visible (logical) children into this element's hidden children
133
166
  * list, creating it if it doesn't already exist.
@@ -162,10 +195,12 @@ export default class Item {
162
195
  * @param deny {boolean}
163
196
  */
164
197
  toggleRule(rule, deny = false) {
165
- if (this.node.dataset.hasOwnProperty(rule) && !deny)
198
+ if (this.node.dataset.hasOwnProperty(rule) && !deny) {
166
199
  delete this.node.dataset[rule];
167
- if (!this.node.dataset.hasOwnProperty(rule) && deny)
200
+ }
201
+ if (!this.node.dataset.hasOwnProperty(rule) && deny) {
168
202
  this.node.dataset[rule] = "";
203
+ }
169
204
 
170
205
  if (rule === "denyDrag") {
171
206
  if (!this.node.hasAttribute("draggable") && !deny) {
@@ -143,7 +143,7 @@ export default class RulesEngine {
143
143
  * @param {Item} item
144
144
  */
145
145
  nestingCannotExceedMaxDepth(item) {
146
- if (this.maxDepth > 0 && this.maxDepth >= item.depth + 1) {
146
+ if (this.maxDepth > 0 && this.maxDepth <= item.depth + 1) {
147
147
  this.#deny("denyNest");
148
148
  }
149
149
  }
@@ -118,7 +118,7 @@ $status-dirty-color: #aaa !default;
118
118
  }
119
119
 
120
120
  // Ensures vertical alignment of header with rows
121
- [data-controller="navigation--editor-menu"] {
121
+ [data-controller="navigation--editor--menu"] {
122
122
  [role="rowheader"] {
123
123
  min-height: var(--row-height);
124
124
  background: var(--table-header-color);
@@ -14,13 +14,6 @@ module Katalyst
14
14
  end
15
15
  end
16
16
 
17
- def build_all(*items)
18
- render partial: "katalyst/navigation/menus/link_item",
19
- layout: "katalyst/navigation/menus/navigation_menu_link",
20
- collection: items,
21
- as: :item
22
- end
23
-
24
17
  def accordion_actions
25
18
  tag.div role: "toolbar", data: { tree_accordion_controls: "" } do
26
19
  concat tag.span(role: "button", value: "collapse",
@@ -2,7 +2,7 @@
2
2
  <div class="tree" data-invisible="<%= !item.visible? %>">
3
3
  <%= builder.accordion_actions %>
4
4
 
5
- <span role="img" value="<%= item.url.present? ? "link" : "title" %>" title="Hidden"></span>
5
+ <span role="img" value="<%= item.url.present? ? "link" : "title" %>" title="Type"></span>
6
6
  <h4 class="title" title="<%= item.title %>"><%= item.title %></h4>
7
7
  <span role="img" value="invisible" title="Hidden"></span>
8
8
  </div>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Navigation
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-09 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: