@commmerce/ui 1.15.0 → 1.17.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.
@@ -117,6 +117,8 @@ export interface GridOptions {
117
117
  /** Accessible names of the month buttons, in the component's language. */
118
118
  previousLabel: string;
119
119
  nextLabel: string;
120
+ /** Hides one month button, for two months side by side (the left month keeps "previous", the right one "next"). */
121
+ hideNav?: 'previous' | 'next';
120
122
  }
121
123
  /**
122
124
  * The new focused date for a grid key (APG date picker dialog), or null if the key is not a grid key. Pass the key
package/dist/calendar.js CHANGED
@@ -63,7 +63,8 @@ export function timeFormat(locale, hourCycle) {
63
63
  const hit = timeFormats.get(key);
64
64
  if (hit)
65
65
  return hit;
66
- const opts = { hour: 'numeric', minute: '2-digit', numberingSystem: 'latn', ...(hc ? { hourCycle: hc } : {}) };
66
+ // A forced 24-hour clock reads 09:05 and 00:00 (1.16); Intl's numeric hour would give 9:05 and 0:00 in some locales.
67
+ const opts = { hour: hc === 'h23' ? '2-digit' : 'numeric', minute: '2-digit', numberingSystem: 'latn', ...(hc ? { hourCycle: hc } : {}) };
67
68
  const time = new Intl.DateTimeFormat(locale, opts);
68
69
  const cycle = time.resolvedOptions().hourCycle;
69
70
  const at = (h) => new Date(2000, 0, 1, h, 30);
@@ -283,9 +284,9 @@ export function renderGrid(o) {
283
284
  const prevOff = !!min && endOfMonth(addMonths(first, -1)) < min;
284
285
  const nextOff = !!max && addMonths(first, 1) > max;
285
286
  return html `<div class="cal-head">
286
- <button type="button" class="cal-nav" part="calendar-nav" aria-label=${o.previousLabel} ?disabled=${prevOff} @click=${() => o.onMonth(-1)}><cm-icon name="chevron-left" size="18"></cm-icon></button>
287
+ ${o.hideNav === 'previous' ? html `<span class="cal-nav-gap"></span>` : html `<button type="button" class="cal-nav" part="calendar-nav" aria-label=${o.previousLabel} ?disabled=${prevOff} @click=${() => o.onMonth(-1)}><cm-icon name="chevron-left" size="18"></cm-icon></button>`}
287
288
  <h2 id="${o.id}-month" class="cal-title" aria-live="polite">${fmt.monthYear(month)}</h2>
288
- <button type="button" class="cal-nav" part="calendar-nav" aria-label=${o.nextLabel} ?disabled=${nextOff} @click=${() => o.onMonth(1)}><cm-icon name="chevron-right" size="18"></cm-icon></button>
289
+ ${o.hideNav === 'next' ? html `<span class="cal-nav-gap"></span>` : html `<button type="button" class="cal-nav" part="calendar-nav" aria-label=${o.nextLabel} ?disabled=${nextOff} @click=${() => o.onMonth(1)}><cm-icon name="chevron-right" size="18"></cm-icon></button>`}
289
290
  </div>
290
291
  <table role="grid" class="cal-grid" part="calendar" aria-labelledby="${o.id}-month" @keydown=${o.onKey}>
291
292
  <thead><tr>${order.map((d) => html `<th scope="col" abbr=${fmt.weekdaysLong[d]}><span aria-hidden="true">${fmt.weekdaysShort[d]}</span><span class="vh">${fmt.weekdaysLong[d]}</span></th>`)}</tr></thead>
@@ -321,6 +322,7 @@ export const calendarStyles = css `
321
322
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--cm-radius-sm);
322
323
  background: none; color: var(--cm-icon-selected); cursor: pointer;
323
324
  }
325
+ .cal-nav-gap { flex: none; width: 32px; }
324
326
  .cal-nav:hover { background: var(--cm-bg-hover); }
325
327
  .cal-nav:disabled { color: var(--cm-text-secondary); cursor: not-allowed; background: none; }
326
328
  .cal-nav:focus-visible, .day:focus, .preset:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 0; }