@commmerce/ui 1.23.1 → 1.25.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.
@@ -15,6 +15,7 @@ import { base, define, nextId, ignoreAlignHint } from '../base.js';
15
15
  import { CmLocalizedElement, defineStrings } from '../localize.js';
16
16
  import { readMenuItems, watchMenuItems } from './menu-item.js';
17
17
  import { TopLayer } from '../top-layer.js';
18
+ import { onRealMove } from '../popover.js';
18
19
  import './icon.js';
19
20
  import './spinner.js';
20
21
  const strings = defineStrings('actionMenu', {
@@ -279,9 +280,9 @@ _CmActionMenu_observer = new WeakMap(), _CmActionMenu_id = new WeakMap(), _CmAct
279
280
  };
280
281
  return it.href && !it.disabled
281
282
  ? html `<a class=${cls} part="item" role="menuitem" tabindex="-1" data-i=${i} href=${it.href}
282
- aria-keyshortcuts=${it.shortcut || nothing} @pointerenter=${common.over} @click=${common.click}>${inner}</a>`
283
+ aria-keyshortcuts=${it.shortcut || nothing} @pointermove=${onRealMove(common.over)} @click=${common.click}>${inner}</a>`
283
284
  : html `<button type="button" class=${cls} part="item" role="menuitem" tabindex="-1" data-i=${i}
284
- aria-disabled=${it.disabled ? 'true' : nothing} aria-keyshortcuts=${it.shortcut || nothing} @pointerenter=${common.over} @click=${common.click}>${inner}</button>`;
285
+ aria-disabled=${it.disabled ? 'true' : nothing} aria-keyshortcuts=${it.shortcut || nothing} @pointermove=${onRealMove(common.over)} @click=${common.click}>${inner}</button>`;
285
286
  }, _CmActionMenu_rows = function _CmActionMenu_rows(items) {
286
287
  const out = [];
287
288
  for (let i = 0; i < items.length; i++) {
@@ -16,7 +16,7 @@ import { fieldStyles, optionStyles } from '../field.js';
16
16
  import { base, define, nextId, logicalKey } from '../base.js';
17
17
  import { CmLocalizedElement, defineStrings } from '../localize.js';
18
18
  import { FieldValidity } from '../validation.js';
19
- import { popoverStyles, groupStyles, sortByGroup, groupRuns, closeOnOutsidePointer } from '../popover.js';
19
+ import { popoverStyles, groupStyles, sortByGroup, groupRuns, closeOnOutsidePointer, onRealMove } from '../popover.js';
20
20
  import { TopLayer, topLayerStyles } from '../top-layer.js';
21
21
  import './icon.js';
22
22
  import './tag.js';
@@ -353,7 +353,8 @@ export class CmCombobox extends CmLocalizedElement {
353
353
  const selected = (v) => (this.multiple ? this.values.includes(v) : v === this.value);
354
354
  const option = (o, i) => html `<li role="option" id="${__classPrivateFieldGet(this, _CmCombobox_id, "f")}-o${i}" class=${i === this._active ? 'active' : ''}
355
355
  aria-selected=${o.create ? 'false' : selected(o.value) ? 'true' : 'false'} aria-disabled=${o.disabled ? 'true' : nothing}
356
- @pointerenter=${() => !o.disabled && (this._active = i)} @click=${() => __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_choose).call(this, i)}>
356
+ @pointermove=${onRealMove(() => { if (!o.disabled)
357
+ this._active = i; })} @click=${() => __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_choose).call(this, i)}>
357
358
  ${o.create
358
359
  ? html `<cm-icon name="plus" size="16"></cm-icon><span class="create">${this.t('add', { value: o.label })}</span>`
359
360
  : html `${this.multiple ? html `<cm-icon class="check" name="check" size="16"></cm-icon>` : nothing}<span>${__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_highlight).call(this, o.label)}</span>`}</li>`;
@@ -14,7 +14,7 @@ import { LitElement, html, css, nothing } from 'lit';
14
14
  import { base, define, nextId } from '../base.js';
15
15
  import { CmLocalizedElement, defineStrings } from '../localize.js';
16
16
  import { FieldValidity } from '../validation.js';
17
- import { groupStyles, sortByGroup, groupRuns } from '../popover.js';
17
+ import { groupStyles, sortByGroup, groupRuns, onRealMove } from '../popover.js';
18
18
  import { fieldStyles, optionStyles } from '../field.js';
19
19
  import { TopLayer, topLayerStyles } from '../top-layer.js';
20
20
  import './icon.js';
@@ -243,7 +243,8 @@ export class CmSelect extends CmLocalizedElement {
243
243
  const hostLabel = this.getAttribute('aria-label');
244
244
  const option = (o, i) => html `<li role="option" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-o${i}" class=${i === this._active ? 'active' : ''}
245
245
  aria-selected=${o.value === this.value ? 'true' : 'false'} aria-disabled=${o.disabled ? 'true' : nothing}
246
- @pointerenter=${() => !o.disabled && (this._active = i)} @click=${() => __classPrivateFieldGet(this, _CmSelect_instances, "m", _CmSelect_commit).call(this, i)}>${o.label}</li>`;
246
+ @pointermove=${onRealMove(() => { if (!o.disabled)
247
+ this._active = i; })} @click=${() => __classPrivateFieldGet(this, _CmSelect_instances, "m", _CmSelect_commit).call(this, i)}>${o.label}</li>`;
247
248
  return html `<div class="field">
248
249
  ${this.label
249
250
  ? html `<span class="label" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-l" part="label" @click=${__classPrivateFieldGet(this, _CmSelect_focusBox, "f")}>${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</span>`
@@ -16,6 +16,7 @@ import { base, define, nextId } from '../base.js';
16
16
  import { CmLocalizedElement, defineStrings } from '../localize.js';
17
17
  import { FieldValidity } from '../validation.js';
18
18
  import { TopLayer, topLayerStyles } from '../top-layer.js';
19
+ import { onRealMove } from '../popover.js';
19
20
  import { optionStyles } from '../field.js';
20
21
  import { timeToMinutes, minutesToTime, timeFormat, timePattern, parseTime, resolveLocale, dateFieldStyles } from '../calendar.js';
21
22
  import './icon.js';
@@ -265,7 +266,7 @@ export class CmTimePicker extends CmLocalizedElement {
265
266
  <ul role="listbox" id=${listId} part="listbox" aria-label=${this.t(name ? 'timesFor' : 'times', { label: name })}>
266
267
  ${times.map((m, i) => html `<li role="option" id="${__classPrivateFieldGet(this, _CmTimePicker_id, "f")}-o${m}" data-value=${minutesToTime(m)}
267
268
  class=${i === this._active ? 'active' : ''} aria-selected=${m === chosen ? 'true' : 'false'}
268
- @pointerenter=${() => { this._active = i; }} @click=${() => __classPrivateFieldGet(this, _CmTimePicker_instances, "m", _CmTimePicker_pick).call(this, m)}>${tf.format(m)}</li>`)}
269
+ @pointermove=${onRealMove(() => { this._active = i; })} @click=${() => __classPrivateFieldGet(this, _CmTimePicker_instances, "m", _CmTimePicker_pick).call(this, m)}>${tf.format(m)}</li>`)}
269
270
  </ul>
270
271
  </div>
271
272
  </div>
package/dist/popover.d.ts CHANGED
@@ -47,6 +47,12 @@ export interface ResultContent {
47
47
  export declare function resultGroupHeading(id: string, label: string, count?: string, countLabel?: string): TemplateResult<1>;
48
48
  /** Icon, title and second line of a result, then `after` (e.g. key hints). The second line is read after a comma. */
49
49
  export declare function resultContent(it: ResultContent, after?: unknown): TemplateResult<1>;
50
+ /**
51
+ * A row listener that runs only when the pointer really moved. A list that opens (or scrolls) under a resting
52
+ * pointer gets pointerenter/pointermove with no movement; reacting to those let the row under the mouse take the
53
+ * highlight from the arrow keys. Rows use it as `@pointermove=${onRealMove(() => (this._active = i))}`.
54
+ */
55
+ export declare function onRealMove(fn: () => void): (e: PointerEvent) => void;
50
56
  /**
51
57
  * One option of a results listbox: a link when it has an `href` (choosing it follows the link unless `cm-select`
52
58
  * is cancelled), otherwise a plain option for an action your app runs.
package/dist/popover.js CHANGED
@@ -117,6 +117,15 @@ export function resultGroupHeading(id, label, count, countLabel) {
117
117
  export function resultContent(it, after = nothing) {
118
118
  return html `${it.icon ? html `<cm-icon name=${it.icon} size="16"></cm-icon>` : nothing}<span class="text"><span class="title">${it.title}</span>${it.description ? html `<span class="vh">, </span><span class="desc">${it.description}</span>` : nothing}</span>${after}`;
119
119
  }
120
+ /**
121
+ * A row listener that runs only when the pointer really moved. A list that opens (or scrolls) under a resting
122
+ * pointer gets pointerenter/pointermove with no movement; reacting to those let the row under the mouse take the
123
+ * highlight from the arrow keys. Rows use it as `@pointermove=${onRealMove(() => (this._active = i))}`.
124
+ */
125
+ export function onRealMove(fn) {
126
+ return (e) => { if (e.movementX || e.movementY)
127
+ fn(); };
128
+ }
120
129
  /**
121
130
  * One option of a results listbox: a link when it has an `href` (choosing it follows the link unless `cm-select`
122
131
  * is cancelled), otherwise a plain option for an action your app runs.
@@ -125,9 +134,9 @@ export function resultOption(o, content) {
125
134
  const cls = `${o.cls ?? ''}${o.active ? ' active' : ''}`;
126
135
  return o.href
127
136
  ? html `<a role="option" id=${o.id} class=${cls} href=${o.href} tabindex="-1" aria-selected=${o.active ? 'true' : 'false'}
128
- aria-keyshortcuts=${o.keyshortcuts || nothing} @pointerenter=${o.onHover} @click=${o.onChoose}>${content}</a>`
137
+ aria-keyshortcuts=${o.keyshortcuts || nothing} @pointermove=${onRealMove(o.onHover)} @click=${o.onChoose}>${content}</a>`
129
138
  : html `<div role="option" id=${o.id} class=${cls} tabindex="-1" aria-selected=${o.active ? 'true' : 'false'}
130
- aria-keyshortcuts=${o.keyshortcuts || nothing} @pointerenter=${o.onHover} @click=${o.onChoose}>${content}</div>`;
139
+ aria-keyshortcuts=${o.keyshortcuts || nothing} @pointermove=${onRealMove(o.onHover)} @click=${o.onChoose}>${content}</div>`;
131
140
  }
132
141
  /** The next highlighted row for a step (wrapping), or -1 when there are no rows. */
133
142
  export function moveActive(active, step, count) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commmerce/ui",
3
- "version": "1.23.1",
3
+ "version": "1.25.0",
4
4
  "description": "Commmerce UI web components: build apps that feel native to the Commmerce admin. Works in plain HTML, React, Vue and server-rendered pages.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -128,8 +128,8 @@
128
128
  "test": "vitest run"
129
129
  },
130
130
  "dependencies": {
131
- "@commmerce/icons": "1.23.1",
132
- "@commmerce/tokens": "1.23.1",
131
+ "@commmerce/icons": "1.25.0",
132
+ "@commmerce/tokens": "1.25.0",
133
133
  "lit": "3.2.1"
134
134
  },
135
135
  "devDependencies": {