juxscript 1.1.305 → 1.1.307

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.
@@ -1 +1 @@
1
- {"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../../lib/components/nav.ts"],"names":[],"mappings":"AAIA,UAAU,OAAO;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,UAAU,UAAU;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,cAAM,GAAG;IACL,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAiD;gBAEtD,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe;IA+BhD,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAY5B,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI;IAchC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAUtC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,E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this.opts.itemClass || 'jux-nav-item';
109
- el.textContent = item.label;
110
109
  el.setAttribute('role', 'link');
111
- if (item.path)
112
- el.setAttribute('data-path', item.path);
113
- if (item.disabled)
110
+ if (item.path) {
111
+ el.href = item.path;
112
+ }
113
+ if (item.disabled) {
114
114
  el.setAttribute('data-disabled', 'true');
115
- if (item.icon)
116
- el.setAttribute('data-icon', item.icon);
115
+ el.setAttribute('aria-disabled', 'true');
116
+ }
117
+ if (item.icon) {
118
+ const iconSpan = document.createElement('span');
119
+ iconSpan.className = 'jux-nav-item-icon';
120
+ iconSpan.textContent = item.icon;
121
+ el.appendChild(iconSpan);
122
+ const textSpan = document.createElement('span');
123
+ textSpan.className = 'jux-nav-item-text';
124
+ textSpan.textContent = item.label;
125
+ el.appendChild(textSpan);
126
+ }
127
+ else {
128
+ el.textContent = item.label;
129
+ }
117
130
  el.addEventListener('click', (e) => {
118
131
  e.preventDefault();
119
132
  if (item.disabled)
@@ -123,6 +136,16 @@ class Nav {
123
136
  if (this._onChange)
124
137
  this._onChange(this._value);
125
138
  this._element.dispatchEvent(new Event('change', { bubbles: false }));
139
+ // SPA navigation
140
+ if (item.path) {
141
+ if (typeof window.navigateTo === 'function') {
142
+ window.navigateTo(item.path);
143
+ }
144
+ else {
145
+ window.history.pushState({}, '', item.path);
146
+ window.dispatchEvent(new PopStateEvent('popstate'));
147
+ }
148
+ }
126
149
  });
127
150
  this._element.appendChild(el);
128
151
  }
@@ -134,16 +157,18 @@ class Nav {
134
157
  this._updateActiveState();
135
158
  }
136
159
  _updateActiveState() {
137
- const children = this._element.querySelectorAll('[role="link"]');
160
+ const children = this._element.querySelectorAll('a[href]');
138
161
  children.forEach(el => {
139
- const path = el.getAttribute('data-path') || el.id;
140
- if (path === this._value) {
162
+ const href = el.getAttribute('href');
163
+ if (href === this._value) {
141
164
  el.classList.add(this.opts.activeClass);
142
165
  el.setAttribute('data-active', 'true');
166
+ el.setAttribute('aria-current', 'page');
143
167
  }
144
168
  else {
145
169
  el.classList.remove(this.opts.activeClass);
146
170
  el.removeAttribute('data-active');
171
+ el.removeAttribute('aria-current');
147
172
  }
148
173
  });
149
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.305",
3
+ "version": "1.1.307",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "./dist/lib/index.js",