@commmerce/ui 1.17.1 → 1.19.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.
package/README.md CHANGED
@@ -11,6 +11,8 @@ Docs: https://commmerce.com/commmerceui/
11
11
  npm install @commmerce/ui @commmerce/tokens
12
12
  ```
13
13
 
14
+ Using Bun? `bun add @commmerce/ui @commmerce/tokens` works the same, and so does bundling with `bun build`.
15
+
14
16
  ```js
15
17
  import '@commmerce/tokens/fonts.css'; // the Poppins typeface (self-hosted, ships with @commmerce/tokens)
16
18
  import '@commmerce/tokens/tokens.css';
@@ -119,6 +119,11 @@ export interface GridOptions {
119
119
  nextLabel: string;
120
120
  /** Hides one month button, for two months side by side (the left month keeps "previous", the right one "next"). */
121
121
  hideNav?: 'previous' | 'next';
122
+ /**
123
+ * `title`: only the month name as a heading, with the weekday names read by screen readers but not shown, for months
124
+ * listed one under another under one shared weekday row (the date range picker's report layout, 1.18).
125
+ */
126
+ head?: 'nav' | 'title';
122
127
  }
123
128
  /**
124
129
  * 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
@@ -283,13 +283,17 @@ export function renderGrid(o) {
283
283
  const today = todayISO();
284
284
  const prevOff = !!min && endOfMonth(addMonths(first, -1)) < min;
285
285
  const nextOff = !!max && addMonths(first, 1) > max;
286
- return html `<div class="cal-head">
286
+ const thead = html `<thead class=${o.head === 'title' ? 'vh-head' : ''}><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>`;
287
+ const head = o.head === 'title'
288
+ ? html `<h3 id="${o.id}-month" class="cal-month" part="calendar-month">${fmt.monthYear(month)}</h3>`
289
+ : html `<div class="cal-head">
287
290
  ${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>`}
288
291
  <h2 id="${o.id}-month" class="cal-title" aria-live="polite">${fmt.monthYear(month)}</h2>
289
292
  ${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>`}
290
- </div>
293
+ </div>`;
294
+ return html `${head}
291
295
  <table role="grid" class="cal-grid" part="calendar" aria-labelledby="${o.id}-month" @keydown=${o.onKey}>
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>
296
+ ${thead}
293
297
  <tbody>${weeks.map((w) => html `<tr>${w.map((d) => {
294
298
  if (!d)
295
299
  return html `<td class="empty"></td>`;
@@ -335,6 +339,7 @@ export const calendarStyles = css `
335
339
  .day.in-range { background: var(--cm-bg-attention-soft); border-radius: 0; }
336
340
  .day.selected, .day.start, .day.end { background: var(--cm-action-primary); color: var(--cm-action-primary-text); }
337
341
  .day[aria-disabled='true'] { color: var(--cm-text-secondary); cursor: not-allowed; background: none; text-decoration: line-through; }
342
+ .vh-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
338
343
  .vh {
339
344
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
340
345
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
@@ -345,7 +350,7 @@ export const calendarStyles = css `
345
350
  export function trapTab(e, pop) {
346
351
  if (e.key !== 'Tab')
347
352
  return;
348
- const stops = [...pop.querySelectorAll('button:not([disabled]), [role=grid] td[tabindex="0"]')];
353
+ const stops = [...pop.querySelectorAll('button:not([disabled]), input:not([disabled]), [role=grid] td[tabindex="0"]')];
349
354
  if (!stops.length)
350
355
  return;
351
356
  const root = pop.getRootNode();