@commmerce/ui 1.12.0 → 1.13.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.
@@ -75,7 +75,7 @@ CmActionBar.styles = [
75
75
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
76
76
  border-radius: var(--cm-radius-full); background: var(--cm-bg-surface); color: var(--cm-icon-critical);
77
77
  }
78
- .actions { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--cm-space-8); margin-inline-start: auto; }
78
+ .actions { flex: 0 1 auto; min-width: 0; max-width: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--cm-space-8); margin-inline-start: auto; }
79
79
  @media (max-width: 640px) {
80
80
  .bar { min-height: 56px; padding: var(--cm-space-8) var(--cm-space-12); gap: var(--cm-space-8); }
81
81
  .heading { font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14); }
@@ -134,6 +134,12 @@ export declare class CmDatePicker extends CmLocalizedElement {
134
134
  _text: {
135
135
  state: boolean;
136
136
  };
137
+ _dateError: {
138
+ state: boolean;
139
+ };
140
+ _timeError: {
141
+ state: boolean;
142
+ };
137
143
  _focus: {
138
144
  state: boolean;
139
145
  };
@@ -191,6 +197,9 @@ export declare class CmDatePicker extends CmLocalizedElement {
191
197
  /** With `time`: `h12` or `h23` to force a 12- or 24-hour clock. Empty: the locale's clock. */
192
198
  hourCycle: '' | 'h12' | 'h23';
193
199
  _text: string;
200
+ /** Shown after the user leaves a box holding text that isn't a date (or a time); an app's `error` wins. */
201
+ _dateError: string;
202
+ _timeError: string;
194
203
  _focus: Date;
195
204
  static styles: import("lit").CSSResult[];
196
205
  connectedCallback(): void;
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _CmDatePicker_instances, _CmDatePicker_localeProp, _CmDatePicker_internals, _CmDatePicker_id, _CmDatePicker_defaultValue, _CmDatePicker_keepText, _CmDatePicker_focusGrid, _CmDatePicker_date, _CmDatePicker_time, _CmDatePicker_keepTime, _CmDatePicker_timeTextValue, _CmDatePicker_timeText_get, _CmDatePicker_timeText_set, _CmDatePicker_ownValue, _CmDatePicker_locale_get, _CmDatePicker_fmt_get, _CmDatePicker_tf_get, _CmDatePicker_dateValue_get, _CmDatePicker_limit, _CmDatePicker_minDate_get, _CmDatePicker_maxDate_get, _CmDatePicker_step_get, _CmDatePicker_firstDay_get, _CmDatePicker_pattern_get, _CmDatePicker_format, _CmDatePicker_formatTime, _CmDatePicker_timePattern_get, _CmDatePicker_split, _CmDatePicker_prepareFocus, _CmDatePicker_validate, _CmDatePicker_validateTime, _CmDatePicker_layer, _CmDatePicker_setValue, _CmDatePicker_setParts, _CmDatePicker_setDate, _CmDatePicker_commitText, _CmDatePicker_commitTime, _CmDatePicker_stepTime, _CmDatePicker_onTimeKey, _CmDatePicker_pick, _CmDatePicker_focusTrigger, _CmDatePicker_toggle, _CmDatePicker_onInputKey, _CmDatePicker_onGridKey, _CmDatePicker_onPopKey, _CmDatePicker_onMonth, _CmDatePicker_onOutside;
12
+ var _CmDatePicker_instances, _CmDatePicker_localeProp, _CmDatePicker_internals, _CmDatePicker_id, _CmDatePicker_defaultValue, _CmDatePicker_keepText, _CmDatePicker_focusGrid, _CmDatePicker_date, _CmDatePicker_time, _CmDatePicker_keepTime, _CmDatePicker_timeTextValue, _CmDatePicker_timeText_get, _CmDatePicker_timeText_set, _CmDatePicker_ownValue, _CmDatePicker_locale_get, _CmDatePicker_fmt_get, _CmDatePicker_tf_get, _CmDatePicker_dateValue_get, _CmDatePicker_limit, _CmDatePicker_minDate_get, _CmDatePicker_maxDate_get, _CmDatePicker_step_get, _CmDatePicker_firstDay_get, _CmDatePicker_pattern_get, _CmDatePicker_format, _CmDatePicker_formatTime, _CmDatePicker_timePattern_get, _CmDatePicker_split, _CmDatePicker_prepareFocus, _CmDatePicker_validate, _CmDatePicker_validateTime, _CmDatePicker_layer, _CmDatePicker_selfSet, _CmDatePicker_setValue, _CmDatePicker_setParts, _CmDatePicker_setDate, _CmDatePicker_commitText, _CmDatePicker_commitTime, _CmDatePicker_stepTime, _CmDatePicker_onTimeKey, _CmDatePicker_pick, _CmDatePicker_focusTrigger, _CmDatePicker_toggle, _CmDatePicker_onInputKey, _CmDatePicker_onGridKey, _CmDatePicker_onPopKey, _CmDatePicker_onMonth, _CmDatePicker_onOutside;
13
13
  import { LitElement, html, css, nothing } from 'lit';
14
14
  import { live } from 'lit/directives/live.js';
15
15
  import { base, define, nextId, logicalKey } from '../base.js';
@@ -120,6 +120,9 @@ export class CmDatePicker extends CmLocalizedElement {
120
120
  /** With `time`: `h12` or `h23` to force a 12- or 24-hour clock. Empty: the locale's clock. */
121
121
  this.hourCycle = '';
122
122
  this._text = '';
123
+ /** Shown after the user leaves a box holding text that isn't a date (or a time); an app's `error` wins. */
124
+ this._dateError = '';
125
+ this._timeError = '';
123
126
  this._focus = new Date();
124
127
  _CmDatePicker_internals.set(this, this.attachInternals());
125
128
  _CmDatePicker_id.set(this, nextId('cm-dp'));
@@ -133,6 +136,7 @@ export class CmDatePicker extends CmLocalizedElement {
133
136
  _CmDatePicker_timeTextValue.set(this, '');
134
137
  _CmDatePicker_ownValue.set(this, false);
135
138
  _CmDatePicker_layer.set(this, new TopLayer());
139
+ _CmDatePicker_selfSet.set(this, false);
136
140
  _CmDatePicker_onTimeKey.set(this, (e) => {
137
141
  if (e.key === 'Enter')
138
142
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_commitTime).call(this);
@@ -262,6 +266,9 @@ export class CmDatePicker extends CmLocalizedElement {
262
266
  this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
263
267
  else if (changed.has('locale') && fromISO(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get)))
264
268
  this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
269
+ if (changed.has('value') && !__classPrivateFieldGet(this, _CmDatePicker_selfSet, "f"))
270
+ this._dateError = this._timeError = ''; // the app set a new value
271
+ __classPrivateFieldSet(this, _CmDatePicker_selfSet, false, "f");
265
272
  __classPrivateFieldSet(this, _CmDatePicker_keepText, false, "f");
266
273
  __classPrivateFieldSet(this, _CmDatePicker_keepTime, false, "f");
267
274
  __classPrivateFieldSet(this, _CmDatePicker_ownValue, false, "f");
@@ -286,7 +293,8 @@ export class CmDatePicker extends CmLocalizedElement {
286
293
  render() {
287
294
  const fmt = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get);
288
295
  const value = fromISO(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
289
- const described = [this.error && `${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-err`, this.helpText && `${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-help`].filter(Boolean).join(' ');
296
+ const err = this.error || [this._dateError, this._timeError].filter(Boolean).join(' ');
297
+ const described = [err && `${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-err`, this.helpText && `${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-help`].filter(Boolean).join(' ');
290
298
  const hostLabel = this.getAttribute('aria-label');
291
299
  const name = this.label || hostLabel || '';
292
300
  const month = startOfMonth(this._focus);
@@ -295,12 +303,12 @@ export class CmDatePicker extends CmLocalizedElement {
295
303
  ? html `<label class="label" for="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-in" part="label">${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</label>`
296
304
  : nothing}
297
305
  <div class="wrap ${this.time ? 'timed' : ''}">
298
- <div class="box" part="box">
306
+ <div class="box ${this._dateError && !this.error ? 'invalid' : ''}" part="box">
299
307
  <input id="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-in" part="input" type="text" autocomplete="off" spellcheck="false"
300
308
  .value=${live(this._text)} placeholder=${this.placeholder || __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_pattern_get)}
301
309
  aria-label=${!this.label && hostLabel ? hostLabel : nothing}
302
310
  ?required=${this.required} ?disabled=${this.disabled}
303
- aria-invalid=${this.error ? 'true' : nothing} aria-describedby=${described || nothing}
311
+ aria-invalid=${err ? 'true' : nothing} aria-describedby=${described || nothing}
304
312
  @input=${(e) => { e.stopPropagation(); this._text = e.target.value; }}
305
313
  @change=${() => __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_commitText).call(this)} @keydown=${__classPrivateFieldGet(this, _CmDatePicker_onInputKey, "f")} />
306
314
  <button type="button" class="trigger" part="trigger" ?disabled=${this.disabled}
@@ -308,12 +316,12 @@ export class CmDatePicker extends CmLocalizedElement {
308
316
  aria-haspopup="dialog" aria-expanded=${this.open ? 'true' : 'false'} aria-controls="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-pop"
309
317
  @click=${__classPrivateFieldGet(this, _CmDatePicker_toggle, "f")}><cm-icon name="calendar" size="16"></cm-icon></button>
310
318
  </div>
311
- ${this.time ? html `<div class="box time" part="time-box">
319
+ ${this.time ? html `<div class="box time ${this._timeError && !this.error ? 'invalid' : ''}" part="time-box">
312
320
  <input class="time-in" part="time-input" type="text" autocomplete="off" spellcheck="false"
313
321
  .value=${live(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timeText_get))} placeholder=${__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timePattern_get)}
314
322
  aria-label=${this.t(name ? 'timeFor' : 'time', { label: name })}
315
323
  ?required=${this.required} ?disabled=${this.disabled}
316
- aria-invalid=${this.error ? 'true' : nothing} aria-describedby=${described || nothing}
324
+ aria-invalid=${err ? 'true' : nothing} aria-describedby=${described || nothing}
317
325
  @input=${(e) => { e.stopPropagation(); __classPrivateFieldSet(this, _CmDatePicker_instances, e.target.value, "a", _CmDatePicker_timeText_set); }}
318
326
  @change=${() => __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_commitTime).call(this)} @keydown=${__classPrivateFieldGet(this, _CmDatePicker_onTimeKey, "f")} />
319
327
  </div>` : nothing}
@@ -329,12 +337,12 @@ export class CmDatePicker extends CmLocalizedElement {
329
337
  })}</div>` : nothing}
330
338
  </div>
331
339
  </div>
332
- ${this.error ? html `<p class="error" id="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-err" role="alert">${this.error}</p>` : nothing}
340
+ ${err ? html `<p class="error" id="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-err" role="alert">${err}</p>` : nothing}
333
341
  ${this.helpText ? html `<p class="help" id="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-help">${this.helpText}</p>` : nothing}
334
342
  </div>`;
335
343
  }
336
344
  }
337
- _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(), _CmDatePicker_id = new WeakMap(), _CmDatePicker_defaultValue = new WeakMap(), _CmDatePicker_keepText = new WeakMap(), _CmDatePicker_focusGrid = new WeakMap(), _CmDatePicker_date = new WeakMap(), _CmDatePicker_time = new WeakMap(), _CmDatePicker_keepTime = new WeakMap(), _CmDatePicker_timeTextValue = new WeakMap(), _CmDatePicker_ownValue = new WeakMap(), _CmDatePicker_layer = new WeakMap(), _CmDatePicker_onTimeKey = new WeakMap(), _CmDatePicker_toggle = new WeakMap(), _CmDatePicker_onInputKey = new WeakMap(), _CmDatePicker_onGridKey = new WeakMap(), _CmDatePicker_onPopKey = new WeakMap(), _CmDatePicker_onMonth = new WeakMap(), _CmDatePicker_onOutside = new WeakMap(), _CmDatePicker_instances = new WeakSet(), _CmDatePicker_timeText_get = function _CmDatePicker_timeText_get() { return __classPrivateFieldGet(this, _CmDatePicker_timeTextValue, "f"); }, _CmDatePicker_timeText_set = function _CmDatePicker_timeText_set(v) { if (v !== __classPrivateFieldGet(this, _CmDatePicker_timeTextValue, "f")) {
345
+ _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(), _CmDatePicker_id = new WeakMap(), _CmDatePicker_defaultValue = new WeakMap(), _CmDatePicker_keepText = new WeakMap(), _CmDatePicker_focusGrid = new WeakMap(), _CmDatePicker_date = new WeakMap(), _CmDatePicker_time = new WeakMap(), _CmDatePicker_keepTime = new WeakMap(), _CmDatePicker_timeTextValue = new WeakMap(), _CmDatePicker_ownValue = new WeakMap(), _CmDatePicker_layer = new WeakMap(), _CmDatePicker_selfSet = new WeakMap(), _CmDatePicker_onTimeKey = new WeakMap(), _CmDatePicker_toggle = new WeakMap(), _CmDatePicker_onInputKey = new WeakMap(), _CmDatePicker_onGridKey = new WeakMap(), _CmDatePicker_onPopKey = new WeakMap(), _CmDatePicker_onMonth = new WeakMap(), _CmDatePicker_onOutside = new WeakMap(), _CmDatePicker_instances = new WeakSet(), _CmDatePicker_timeText_get = function _CmDatePicker_timeText_get() { return __classPrivateFieldGet(this, _CmDatePicker_timeTextValue, "f"); }, _CmDatePicker_timeText_set = function _CmDatePicker_timeText_set(v) { if (v !== __classPrivateFieldGet(this, _CmDatePicker_timeTextValue, "f")) {
338
346
  __classPrivateFieldSet(this, _CmDatePicker_timeTextValue, v, "f");
339
347
  this.requestUpdate();
340
348
  } }, _CmDatePicker_locale_get = function _CmDatePicker_locale_get() { return resolveLocale(this, this.locale); }, _CmDatePicker_fmt_get = function _CmDatePicker_fmt_get() { return dateFormat(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_locale_get)); }, _CmDatePicker_tf_get = function _CmDatePicker_tf_get() { return timeFormat(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_locale_get), this.hourCycle); }, _CmDatePicker_dateValue_get = function _CmDatePicker_dateValue_get() { return this.time ? __classPrivateFieldGet(this, _CmDatePicker_date, "f") : this.value; }, _CmDatePicker_limit = function _CmDatePicker_limit(v) { return this.time && v.trim().toLowerCase() === 'now' ? nowISO() : v; }, _CmDatePicker_minDate_get = function _CmDatePicker_minDate_get() { return fromISO(splitDateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.min)).date || this.min); }, _CmDatePicker_maxDate_get = function _CmDatePicker_maxDate_get() { return fromISO(splitDateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.max)).date || this.max); }, _CmDatePicker_step_get = function _CmDatePicker_step_get() { const n = Math.trunc(Number(this.step)); return n >= 1 && n <= 1440 ? n : 1; }, _CmDatePicker_firstDay_get = function _CmDatePicker_firstDay_get() {
@@ -405,6 +413,7 @@ _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(
405
413
  }, _CmDatePicker_setValue = function _CmDatePicker_setValue(v) {
406
414
  if (v === this.value)
407
415
  return;
416
+ __classPrivateFieldSet(this, _CmDatePicker_selfSet, true, "f");
408
417
  this.value = v;
409
418
  this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
410
419
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
@@ -422,6 +431,7 @@ _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(
422
431
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setValue).call(this, iso);
423
432
  }, _CmDatePicker_commitText = function _CmDatePicker_commitText() {
424
433
  const text = this._text.trim();
434
+ this._dateError = '';
425
435
  if (!text) {
426
436
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, '');
427
437
  return;
@@ -434,6 +444,7 @@ _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(
434
444
  else {
435
445
  __classPrivateFieldSet(this, _CmDatePicker_keepText, true, "f");
436
446
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, '');
447
+ this._dateError = this.t('badInput', { pattern: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_pattern_get) });
437
448
  }
438
449
  }, _CmDatePicker_commitTime = function _CmDatePicker_commitTime() {
439
450
  const text = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timeText_get).trim();
@@ -442,8 +453,10 @@ _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(
442
453
  if (t === null) {
443
454
  __classPrivateFieldSet(this, _CmDatePicker_keepTime, true, "f");
444
455
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, __classPrivateFieldGet(this, _CmDatePicker_date, "f"), '');
456
+ this._timeError = this.t('badTime', { pattern: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timePattern_get) });
445
457
  return;
446
458
  }
459
+ this._timeError = '';
447
460
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, __classPrivateFieldGet(this, _CmDatePicker_date, "f"), t);
448
461
  __classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, t), "a", _CmDatePicker_timeText_set);
449
462
  }, _CmDatePicker_stepTime = function _CmDatePicker_stepTime(dir) {
@@ -475,6 +488,7 @@ _CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(
475
488
  this.open = false;
476
489
  __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, iso);
477
490
  this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, iso);
491
+ this._dateError = '';
478
492
  if (this.time && !__classPrivateFieldGet(this, _CmDatePicker_time, "f"))
479
493
  this.updateComplete.then(() => this.renderRoot.querySelector('input.time-in')?.focus());
480
494
  else
@@ -503,6 +517,8 @@ CmDatePicker.properties = {
503
517
  step: { type: Number },
504
518
  hourCycle: { attribute: 'hour-cycle' },
505
519
  _text: { state: true },
520
+ _dateError: { state: true },
521
+ _timeError: { state: true },
506
522
  _focus: { state: true },
507
523
  };
508
524
  CmDatePicker.styles = [base, topLayerStyles, dateFieldStyles, calendarStyles, css `.pop { min-width: 0; }`];
@@ -114,9 +114,9 @@ _CmMobileMenu_observer = new WeakMap(), _CmMobileMenu_id = new WeakMap(), _CmMob
114
114
  const badge = it.badge ? html `<span class="badge">${it.badge}</span>` : nothing;
115
115
  if (it.items?.length && !sub) {
116
116
  return html `<button type="button" class="row" part="row" data-row="${s}-${r}"
117
- @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_open).call(this, s, r)}>${icon}<span class="label">${it.label}</span>${badge}<cm-icon class="chev" name="chevron-right" size="16"></cm-icon></button>`;
117
+ @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_open).call(this, s, r)}>${icon}<span class="text"><span class="label">${it.label}</span>${badge}</span><cm-icon class="chev" name="chevron-right" size="16"></cm-icon></button>`;
118
118
  }
119
- const inner = html `${icon}<span class="label">${it.label}</span>${badge}${it.href && !sub ? html `<cm-icon class="chev" name="chevron-right" size="16"></cm-icon>` : nothing}`;
119
+ const inner = html `${icon}<span class="text"><span class="label">${it.label}</span>${badge}</span>${it.href && !sub ? html `<cm-icon class="chev" name="chevron-right" size="16"></cm-icon>` : nothing}`;
120
120
  return it.href
121
121
  ? html `<a class="row" part="row" href=${it.href} aria-current=${it.current ? 'page' : nothing} @click=${go}>${inner}</a>`
122
122
  : html `<button type="button" class="row" part="row" aria-current=${it.current ? 'page' : nothing} @click=${go}>${inner}</button>`;
@@ -165,7 +165,11 @@ CmMobileMenu.styles = [
165
165
  }
166
166
  .row:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; border-radius: var(--cm-radius-sm); }
167
167
  .row .icon { color: var(--cm-icon-responsive-menu); }
168
- .label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
168
+ /* Label and badge share a wrapping line (1.13): when both don't fit, the badge moves under the label instead of
169
+ squeezing it, and the label breaks between words, never inside one (unless a single word is wider than the row). */
170
+ .text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-4) var(--cm-space-8); }
171
+ .label { min-width: 0; overflow-wrap: break-word; }
172
+ .text .badge { margin-inline-start: auto; }
169
173
  .chev { color: var(--cm-icon-selected); }
170
174
  .badge {
171
175
  flex: none; padding: 2px var(--cm-space-8); border-radius: var(--cm-radius-full); font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12); font-weight: 500;
@@ -65,6 +65,9 @@ export declare class CmResourceItem extends CmLocalizedElement {
65
65
  type: BooleanConstructor;
66
66
  reflect: boolean;
67
67
  };
68
+ mobile: {
69
+ reflect: boolean;
70
+ };
68
71
  actions: {
69
72
  reflect: boolean;
70
73
  };
@@ -96,6 +99,12 @@ export declare class CmResourceItem extends CmLocalizedElement {
96
99
  * Rows with `columns` keep their actions inline unless `actions="wrap"`.
97
100
  */
98
101
  actions: 'auto' | 'wrap' | 'inline';
102
+ /**
103
+ * With `columns`, how the row lays out on phones (640px or less). Set by the parent list from its own `mobile`.
104
+ * `stack`: the first cell gets a line of its own and the other cells follow on the next line, side by side.
105
+ * Unset: the columns stay on one line.
106
+ */
107
+ mobile?: 'stack';
99
108
  _hasActions: boolean;
100
109
  constructor();
101
110
  connectedCallback(): void;
@@ -160,6 +169,9 @@ export declare class CmResourceList extends CmLocalizedElement {
160
169
  density: {
161
170
  reflect: boolean;
162
171
  };
172
+ mobile: {
173
+ reflect: boolean;
174
+ };
163
175
  _count: {
164
176
  state: boolean;
165
177
  };
@@ -197,6 +209,13 @@ export declare class CmResourceList extends CmLocalizedElement {
197
209
  * Unset: the nearest `data-cm-density` on an ancestor, else comfortable. On touch screens rows are at least 44px tall.
198
210
  */
199
211
  density?: 'comfortable' | 'compact';
212
+ /**
213
+ * How rows with `columns` (and a `cm-table-header` in the `header` slot) lay out on phones, 640px or less (since 1.13).
214
+ * `columns` (default): every column stays on the row's one line. `stack`: each row's first cell gets a line of its
215
+ * own and the other cells follow on the next line; the header's column names wrap the same way, so sorting still works.
216
+ * Use `stack` when the columns can't fit a phone.
217
+ */
218
+ mobile: 'columns' | 'stack';
200
219
  _count: number;
201
220
  _rows: number;
202
221
  _hasHeader: boolean;
@@ -151,6 +151,7 @@ CmResourceItem.properties = {
151
151
  label: {},
152
152
  selectable: { type: Boolean, reflect: true },
153
153
  columns: { type: Boolean, reflect: true },
154
+ mobile: { reflect: true },
154
155
  actions: { reflect: true },
155
156
  _hasActions: { state: true },
156
157
  };
@@ -202,6 +203,10 @@ CmResourceItem.styles = [
202
203
  .check { width: 20px; height: 20px; }
203
204
  ::slotted([slot='media']) { width: 32px; height: 32px; }
204
205
  ::slotted(cm-thumbnail[slot='media']) { --cm-thumbnail-size: 32px; }
206
+ /* mobile="stack" (1.13): the first cell on its own line, the others after it, wrapping as words, not letters. */
207
+ :host([columns][mobile='stack']) .content { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-4) var(--cm-space-12); }
208
+ :host([columns][mobile='stack']) ::slotted(*) { overflow-wrap: break-word; }
209
+ :host([columns][mobile='stack']) ::slotted(:first-child) { flex: 1 1 100%; }
205
210
  }
206
211
  `,
207
212
  ];
@@ -248,6 +253,13 @@ export class CmResourceList extends CmLocalizedElement {
248
253
  this.hideSelectMenu = false;
249
254
  /** Accessible name of the list, e.g. "Products". Defaults to the plural noun. */
250
255
  this.label = '';
256
+ /**
257
+ * How rows with `columns` (and a `cm-table-header` in the `header` slot) lay out on phones, 640px or less (since 1.13).
258
+ * `columns` (default): every column stays on the row's one line. `stack`: each row's first cell gets a line of its
259
+ * own and the other cells follow on the next line; the header's column names wrap the same way, so sorting still works.
260
+ * Use `stack` when the columns can't fit a phone.
261
+ */
262
+ this.mobile = 'columns';
251
263
  this._count = 0;
252
264
  this._rows = 0;
253
265
  this._hasHeader = false;
@@ -309,7 +321,7 @@ export class CmResourceList extends CmLocalizedElement {
309
321
  /** Clears the selection. */
310
322
  clearSelection() { this.selectPage(false); }
311
323
  updated(changed) {
312
- if (changed.has('selectable')) {
324
+ if (changed.has('selectable') || changed.has('mobile')) {
313
325
  __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this);
314
326
  __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_syncHeaders).call(this);
315
327
  }
@@ -385,15 +397,22 @@ _CmResourceList_id = new WeakMap(), _CmResourceList_headers = new WeakMap(), _Cm
385
397
  el.querySelectorAll('cm-table-header').forEach((h) => found.add(h));
386
398
  }
387
399
  for (const h of __classPrivateFieldGet(this, _CmResourceList_headers, "f"))
388
- if (!found.has(h))
400
+ if (!found.has(h)) {
389
401
  h.removeAttribute('resource-rows');
390
- for (const h of found)
402
+ h.removeAttribute('mobile');
403
+ }
404
+ for (const h of found) {
391
405
  h.setAttribute('resource-rows', this.selectable ? 'selectable' : 'plain');
406
+ if (this.mobile === 'stack')
407
+ h.setAttribute('mobile', 'stack');
408
+ else
409
+ h.removeAttribute('mobile');
410
+ }
392
411
  __classPrivateFieldSet(this, _CmResourceList_headers, found, "f");
393
412
  this._hasTable = found.size > 0;
394
413
  }, _CmResourceList_sync = function _CmResourceList_sync() {
395
414
  const items = this.items;
396
- items.forEach((i) => (i.selectable = this.selectable));
415
+ items.forEach((i) => { i.selectable = this.selectable; i.mobile = this.mobile === 'stack' ? 'stack' : undefined; });
397
416
  this._rows = items.length;
398
417
  this._count = items.filter((i) => i.selected).length;
399
418
  }, _CmResourceList_emit = function _CmResourceList_emit() {
@@ -409,6 +428,7 @@ CmResourceList.properties = {
409
428
  hideSelectMenu: { type: Boolean, attribute: 'hide-select-menu' },
410
429
  label: {},
411
430
  density: { reflect: true },
431
+ mobile: { reflect: true },
412
432
  _count: { state: true },
413
433
  _rows: { state: true },
414
434
  _hasHeader: { state: true },
@@ -181,6 +181,9 @@ CmTableHeader.styles = [
181
181
  :host([resource-rows]) .bar { padding-inline: var(--_rl) calc(var(--_rl) + var(--cm-space-8)); }
182
182
  :host([resource-rows='selectable']) .bar:not(.sel) { padding-inline-start: calc(var(--_rl) + 20px + var(--cm-space-8)); }
183
183
  :host([resource-rows]) .bar.sel { grid-template-columns: calc(20px + var(--cm-space-8) - var(--cm-space-20)) var(--cm-table-columns, var(--_cols)); }
184
+ /* The list's mobile="stack" (1.13): names wrap like the stacked rows, the first on a line of its own. */
185
+ :host([resource-rows][mobile='stack']) .bar:not(.sel) { display: flex; flex-wrap: wrap; gap: var(--cm-space-4) var(--cm-space-12); padding-block: var(--cm-space-8); }
186
+ :host([resource-rows][mobile='stack']) .bar:not(.sel) > .cell:first-child { flex: 1 1 100%; }
184
187
  }
185
188
  `,
186
189
  ];
@@ -14353,6 +14353,27 @@
14353
14353
  "default": "''",
14354
14354
  "attribute": "_text"
14355
14355
  },
14356
+ {
14357
+ "kind": "field",
14358
+ "name": "_dateError",
14359
+ "privacy": "public",
14360
+ "type": {
14361
+ "text": "string"
14362
+ },
14363
+ "default": "''",
14364
+ "description": "Shown after the user leaves a box holding text that isn't a date (or a time); an app's `error` wins.",
14365
+ "attribute": "_dateError"
14366
+ },
14367
+ {
14368
+ "kind": "field",
14369
+ "name": "_timeError",
14370
+ "privacy": "public",
14371
+ "type": {
14372
+ "text": "string"
14373
+ },
14374
+ "default": "''",
14375
+ "attribute": "_timeError"
14376
+ },
14356
14377
  {
14357
14378
  "kind": "field",
14358
14379
  "name": "_focus",
@@ -14694,6 +14715,15 @@
14694
14715
  "privacy": "private",
14695
14716
  "default": "new TopLayer()"
14696
14717
  },
14718
+ {
14719
+ "kind": "field",
14720
+ "name": "#selfSet",
14721
+ "privacy": "private",
14722
+ "type": {
14723
+ "text": "boolean"
14724
+ },
14725
+ "default": "false"
14726
+ },
14697
14727
  {
14698
14728
  "kind": "method",
14699
14729
  "name": "#setValue",
@@ -15091,6 +15121,23 @@
15091
15121
  "default": "''",
15092
15122
  "fieldName": "_text"
15093
15123
  },
15124
+ {
15125
+ "name": "_dateError",
15126
+ "type": {
15127
+ "text": "string"
15128
+ },
15129
+ "default": "''",
15130
+ "description": "Shown after the user leaves a box holding text that isn't a date (or a time); an app's `error` wins.",
15131
+ "fieldName": "_dateError"
15132
+ },
15133
+ {
15134
+ "name": "_timeError",
15135
+ "type": {
15136
+ "text": "string"
15137
+ },
15138
+ "default": "''",
15139
+ "fieldName": "_timeError"
15140
+ },
15094
15141
  {
15095
15142
  "name": "_focus",
15096
15143
  "type": {
@@ -26624,6 +26671,17 @@
26624
26671
  "attribute": "actions",
26625
26672
  "reflects": true
26626
26673
  },
26674
+ {
26675
+ "kind": "field",
26676
+ "name": "mobile",
26677
+ "privacy": "public",
26678
+ "type": {
26679
+ "text": "'stack' | undefined"
26680
+ },
26681
+ "description": "With `columns`, how the row lays out on phones (640px or less). Set by the parent list from its own `mobile`.\n`stack`: the first cell gets a line of its own and the other cells follow on the next line, side by side.\nUnset: the columns stay on one line.",
26682
+ "attribute": "mobile",
26683
+ "reflects": true
26684
+ },
26627
26685
  {
26628
26686
  "kind": "field",
26629
26687
  "name": "_hasActions",
@@ -26863,6 +26921,14 @@
26863
26921
  "description": "Lays the row's content out on the `--cm-table-columns` grid (set it on the list), one child element per column,\n`space-20` apart: the same grid as a `cm-table-header` in the list's `header` slot, so cells sit under their headings.",
26864
26922
  "fieldName": "columns"
26865
26923
  },
26924
+ {
26925
+ "name": "mobile",
26926
+ "type": {
26927
+ "text": "'stack' | undefined"
26928
+ },
26929
+ "description": "With `columns`, how the row lays out on phones (640px or less). Set by the parent list from its own `mobile`.\n`stack`: the first cell gets a line of its own and the other cells follow on the next line, side by side.\nUnset: the columns stay on one line.",
26930
+ "fieldName": "mobile"
26931
+ },
26866
26932
  {
26867
26933
  "name": "actions",
26868
26934
  "type": {
@@ -27028,6 +27094,18 @@
27028
27094
  "attribute": "density",
27029
27095
  "reflects": true
27030
27096
  },
27097
+ {
27098
+ "kind": "field",
27099
+ "name": "mobile",
27100
+ "privacy": "public",
27101
+ "type": {
27102
+ "text": "'columns' | 'stack'"
27103
+ },
27104
+ "default": "'columns'",
27105
+ "description": "How rows with `columns` (and a `cm-table-header` in the `header` slot) lay out on phones, 640px or less (since 1.13).\n`columns` (default): every column stays on the row's one line. `stack`: each row's first cell gets a line of its\nown and the other cells follow on the next line; the header's column names wrap the same way, so sorting still works.\nUse `stack` when the columns can't fit a phone.",
27106
+ "attribute": "mobile",
27107
+ "reflects": true
27108
+ },
27031
27109
  {
27032
27110
  "kind": "field",
27033
27111
  "name": "_count",
@@ -27356,6 +27434,15 @@
27356
27434
  "description": "Row height (since 1.6): `comfortable` 56px rows with 40px thumbnails, or `compact` 40px rows with 32px thumbnails.\nUnset: the nearest `data-cm-density` on an ancestor, else comfortable. On touch screens rows are at least 44px tall.",
27357
27435
  "fieldName": "density"
27358
27436
  },
27437
+ {
27438
+ "name": "mobile",
27439
+ "type": {
27440
+ "text": "'columns' | 'stack'"
27441
+ },
27442
+ "default": "'columns'",
27443
+ "description": "How rows with `columns` (and a `cm-table-header` in the `header` slot) lay out on phones, 640px or less (since 1.13).\n`columns` (default): every column stays on the row's one line. `stack`: each row's first cell gets a line of its\nown and the other cells follow on the next line; the header's column names wrap the same way, so sorting still works.\nUse `stack` when the columns can't fit a phone.",
27444
+ "fieldName": "mobile"
27445
+ },
27359
27446
  {
27360
27447
  "name": "_count",
27361
27448
  "type": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commmerce/ui",
3
- "version": "1.12.0",
3
+ "version": "1.13.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",
@@ -50,8 +50,8 @@
50
50
  "test": "vitest run"
51
51
  },
52
52
  "dependencies": {
53
- "@commmerce/icons": "1.12.0",
54
- "@commmerce/tokens": "1.12.0",
53
+ "@commmerce/icons": "1.13.0",
54
+ "@commmerce/tokens": "1.13.0",
55
55
  "lit": "3.2.1"
56
56
  },
57
57
  "devDependencies": {