@keystone-sites/marketing-design-system 1.0.12 → 1.0.14

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/index.css CHANGED
@@ -60,6 +60,7 @@
60
60
  @import "./primitives/modal.css" layer(primitives);
61
61
  @import "./primitives/table.css" layer(primitives);
62
62
  @import "./primitives/disclosure.css" layer(primitives);
63
+ @import "./primitives/month-range.css" layer(primitives);
63
64
  @import "./primitives/strip.css" layer(primitives);
64
65
 
65
66
  /* Shared: the landing kit's frame, which its sections refine. */
@@ -0,0 +1,30 @@
1
+ "use client";
2
+
3
+ /** The open state of a toolbar popover (a filter checklist, a range
4
+ * picker): it closes on a pointer down outside its root and on Escape.
5
+ * The owner renders the trigger and the panel inside `rootRef`. */
6
+
7
+ import { useEffect, useRef, useState } from "react";
8
+
9
+ export function usePopover<Root extends HTMLElement>() {
10
+ const [open, setOpen] = useState(false);
11
+ const rootRef = useRef<Root>(null);
12
+
13
+ useEffect(() => {
14
+ if (!open) return;
15
+ const onDown = (event: PointerEvent) => {
16
+ if (!rootRef.current?.contains(event.target as Node)) setOpen(false);
17
+ };
18
+ const onKey = (event: KeyboardEvent) => {
19
+ if (event.key === "Escape") setOpen(false);
20
+ };
21
+ document.addEventListener("pointerdown", onDown);
22
+ document.addEventListener("keydown", onKey);
23
+ return () => {
24
+ document.removeEventListener("pointerdown", onDown);
25
+ document.removeEventListener("keydown", onKey);
26
+ };
27
+ }, [open]);
28
+
29
+ return { open, setOpen, rootRef };
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystone-sites/marketing-design-system",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Keystone's marketing design system: tokens, the tick grid, type, primitives, site chrome, and the landing kit. Source-shipped CSS and TSX for Next.js consumers.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -126,6 +126,8 @@
126
126
  "./primitives/grader": "./primitives/grader.tsx",
127
127
  "./primitives/modal.css": "./primitives/modal.css",
128
128
  "./primitives/modal": "./primitives/modal.tsx",
129
+ "./primitives/month-range.css": "./primitives/month-range.css",
130
+ "./primitives/month-range": "./primitives/month-range.tsx",
129
131
  "./primitives/notice.css": "./primitives/notice.css",
130
132
  "./primitives/notice": "./primitives/notice.tsx",
131
133
  "./primitives/persona-card.css": "./primitives/persona-card.css",
@@ -203,6 +205,7 @@
203
205
  "./lib/use-active-section": "./lib/use-active-section.ts",
204
206
  "./lib/use-count-up": "./lib/use-count-up.ts",
205
207
  "./lib/use-grader-search": "./lib/use-grader-search.ts",
208
+ "./lib/use-popover": "./lib/use-popover.ts",
206
209
  "./lib/use-video-carousel": "./lib/use-video-carousel.ts",
207
210
  "./themes/inverted.css": "./themes/inverted.css"
208
211
  }
@@ -1,7 +1,15 @@
1
1
  /* Disclosure: a hairline row that opens a body beneath it. Stacked
2
2
  disclosures share dividers through .rows. The filter is a toolbar
3
3
  trigger with a popover checklist; `.check` is the bare checkbox both
4
- the checklist and dense tables use. */
4
+ the checklist and dense tables use, and round as a radio in the menu
5
+ of one choice. The trigger and the popover frame (`.filter-trigger`,
6
+ `.filter-menu`) are shared with the choice menu and the month range. */
7
+
8
+ /* Designed constants for this file. */
9
+ :root {
10
+ /* The checklist scrolls past this rather than leaving the page. */
11
+ --filter-options-h: 20rem;
12
+ }
5
13
 
6
14
  .disclosure-head {
7
15
  appearance: none;
@@ -92,6 +100,12 @@
92
100
  transition-duration: var(--motion-hover-duration);
93
101
  transition-timing-function: var(--motion-hover-ease);
94
102
  }
103
+ .check[type="radio"] {
104
+ border-radius: var(--radius-full);
105
+ }
106
+ .check[type="radio"]:checked {
107
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='2.5' fill='%23f8f7f2'/%3E%3C/svg%3E");
108
+ }
95
109
  .check:checked,
96
110
  .check:indeterminate {
97
111
  background: var(--color-teal-500);
@@ -194,6 +208,79 @@
194
208
  transform: none;
195
209
  }
196
210
  }
211
+ .filter-search {
212
+ display: flex;
213
+ align-items: center;
214
+ gap: var(--space-sm);
215
+ padding: var(--space-xs) var(--space-md);
216
+ border-bottom: 1px solid var(--color-border-050);
217
+ color: var(--color-text-400);
218
+ }
219
+ .filter-search-glyph {
220
+ flex: none;
221
+ }
222
+ .filter-search-input {
223
+ flex: 1;
224
+ min-width: 0;
225
+ height: var(--field-h-sm, 40px);
226
+ margin: 0;
227
+ padding: 0;
228
+ border: 0;
229
+ background: none;
230
+ outline: none;
231
+ color: var(--color-text-100);
232
+ }
233
+ .filter-search-input::placeholder {
234
+ color: var(--color-text-400);
235
+ }
236
+ .filter-search-input::-webkit-search-cancel-button {
237
+ appearance: none;
238
+ }
239
+ .filter-actions {
240
+ display: flex;
241
+ align-items: center;
242
+ gap: var(--space-xs);
243
+ padding: var(--space-xs) var(--space-sm);
244
+ }
245
+ .filter-action {
246
+ appearance: none;
247
+ margin: 0;
248
+ padding: var(--space-xs) var(--space-sm);
249
+ border: 0;
250
+ border-radius: var(--radius-sm);
251
+ background: none;
252
+ color: var(--color-teal-600);
253
+ cursor: pointer;
254
+ transition:
255
+ background var(--motion-hover-duration) var(--motion-hover-ease),
256
+ color var(--motion-hover-duration) var(--motion-hover-ease);
257
+ }
258
+ @media (hover: hover) {
259
+ .filter-action:not(:disabled):hover {
260
+ background: var(--color-bg-300);
261
+ }
262
+ }
263
+ .filter-action:focus-visible {
264
+ outline: none;
265
+ box-shadow: 0 0 0 var(--ring-w) var(--color-teal-100);
266
+ }
267
+ .filter-action:disabled {
268
+ color: var(--color-text-500);
269
+ cursor: default;
270
+ }
271
+ .filter-tally {
272
+ margin-left: auto;
273
+ padding-inline: var(--space-sm);
274
+ color: var(--color-text-400);
275
+ font-variant-numeric: tabular-nums;
276
+ }
277
+ .filter-options {
278
+ display: flex;
279
+ flex-direction: column;
280
+ max-height: var(--filter-options-h);
281
+ overflow-y: auto;
282
+ scrollbar-width: thin;
283
+ }
197
284
  .filter-option {
198
285
  display: flex;
199
286
  align-items: center;
@@ -208,3 +295,8 @@
208
295
  background: var(--color-bg-300);
209
296
  }
210
297
  }
298
+ .filter-empty {
299
+ margin: 0;
300
+ padding: var(--space-sm) var(--space-md);
301
+ color: var(--color-text-400);
302
+ }
@@ -1,10 +1,12 @@
1
1
  "use client";
2
2
 
3
- /** Disclosure: a row that opens a body beneath it, and a popover menu of
4
- * checkboxes for toolbar filters. Styles live in disclosure.css. */
3
+ /** Disclosure: a row that opens a body beneath it, and the toolbar
4
+ * popovers: a menu of checkboxes for filters and a menu of one choice.
5
+ * Styles live in disclosure.css. */
5
6
 
6
- import { useEffect, useId, useRef, useState, type ReactNode } from "react";
7
- import { IconChevronDownSmall } from "../icons";
7
+ import { useId, useState, type ReactNode } from "react";
8
+ import { IconChevronDownSmall, IconSearchGlyph } from "../icons";
9
+ import { usePopover } from "../lib/use-popover";
8
10
 
9
11
  export function Disclosure({
10
12
  title,
@@ -66,7 +68,50 @@ export interface FilterOption<T extends string> {
66
68
  label: string;
67
69
  }
68
70
 
69
- /** A button that opens a checklist; the consumer owns the selection. */
71
+ /** A list this long is scanned through a search box; shorter ones by eye. */
72
+ const SEARCH_FROM = 8;
73
+
74
+ /** The trigger of a toolbar popover: its label, an optional count and the
75
+ * tick that turns when it is open. */
76
+ export function FilterTrigger({
77
+ label,
78
+ name,
79
+ count,
80
+ open,
81
+ menuId,
82
+ onToggle,
83
+ }: {
84
+ label: string;
85
+ /** What the trigger is called when its label is the value it shows. */
86
+ name?: string;
87
+ /** A number beside the label when the choice is narrower than everything. */
88
+ count?: number;
89
+ open: boolean;
90
+ menuId: string;
91
+ onToggle: () => void;
92
+ }) {
93
+ return (
94
+ <button
95
+ type="button"
96
+ className="type type-fixed ts-text-sm-regular filter-trigger"
97
+ aria-expanded={open}
98
+ aria-controls={menuId}
99
+ aria-haspopup="true"
100
+ aria-label={name}
101
+ onClick={onToggle}
102
+ >
103
+ <span>{label}</span>
104
+ {count !== undefined && (
105
+ <span className="type type-fixed ts-text-2xs-medium filter-count">{count}</span>
106
+ )}
107
+ <IconChevronDownSmall className="filter-tick" />
108
+ </button>
109
+ );
110
+ }
111
+
112
+ /** A button that opens a checklist; the consumer owns the selection. The
113
+ * list can be checked or cleared whole and, past a handful of options,
114
+ * searched; checking from a search touches only the options it shows. */
70
115
  export function FilterMenu<T extends string>({
71
116
  label,
72
117
  options,
@@ -78,65 +123,153 @@ export function FilterMenu<T extends string>({
78
123
  selected: readonly T[];
79
124
  onChange: (next: T[]) => void;
80
125
  }) {
81
- const [open, setOpen] = useState(false);
82
- const rootRef = useRef<HTMLDivElement>(null);
126
+ const { open, setOpen, rootRef } = usePopover<HTMLDivElement>();
127
+ const [query, setQuery] = useState("");
83
128
  const menuId = useId();
84
- const partial = selected.length > 0 && selected.length < options.length;
129
+ const searchId = useId();
130
+ const partial = selected.length < options.length;
131
+ const searchable = options.length >= SEARCH_FROM;
132
+ const needle = query.trim().toLowerCase();
133
+ const shown = needle ? options.filter((o) => o.label.toLowerCase().includes(needle)) : options;
134
+ const shownValues = shown.map((o) => o.value);
135
+ const allShown = shown.length > 0 && shown.every((o) => selected.includes(o.value));
136
+ const noneShown = shown.every((o) => !selected.includes(o.value));
85
137
 
86
- useEffect(() => {
87
- if (!open) return;
88
- const onDown = (event: PointerEvent) => {
89
- if (!rootRef.current?.contains(event.target as Node)) setOpen(false);
90
- };
91
- const onKey = (event: KeyboardEvent) => {
92
- if (event.key === "Escape") setOpen(false);
93
- };
94
- document.addEventListener("pointerdown", onDown);
95
- document.addEventListener("keydown", onKey);
96
- return () => {
97
- document.removeEventListener("pointerdown", onDown);
98
- document.removeEventListener("keydown", onKey);
99
- };
100
- }, [open]);
138
+ const toggle = () => {
139
+ setQuery("");
140
+ setOpen((v) => !v);
141
+ };
142
+ const checkAll = () => onChange([...new Set([...selected, ...shownValues])]);
143
+ const checkNone = () => onChange(selected.filter((v) => !shownValues.includes(v)));
101
144
 
102
145
  return (
103
146
  <div className="filter" ref={rootRef}>
104
- <button
105
- type="button"
106
- className="type type-fixed ts-text-sm-regular filter-trigger"
107
- aria-expanded={open}
108
- aria-controls={menuId}
109
- aria-haspopup="true"
110
- onClick={() => setOpen((v) => !v)}
111
- >
112
- <span>{label}</span>
113
- {partial && (
114
- <span className="type type-fixed ts-text-2xs-medium filter-count">{selected.length}</span>
115
- )}
116
- <IconChevronDownSmall className="filter-tick" />
117
- </button>
147
+ <FilterTrigger
148
+ label={label}
149
+ count={partial ? selected.length : undefined}
150
+ open={open}
151
+ menuId={menuId}
152
+ onToggle={toggle}
153
+ />
118
154
  {open && (
119
155
  <div className="filter-menu" id={menuId} role="group" aria-label={label}>
120
- {options.map((option) => {
121
- const checked = selected.includes(option.value);
122
- return (
156
+ {searchable && (
157
+ <div className="filter-search">
158
+ <IconSearchGlyph className="filter-search-glyph" />
159
+ <input
160
+ id={searchId}
161
+ className="type type-fixed ts-text-sm-light filter-search-input"
162
+ type="search"
163
+ autoComplete="off"
164
+ placeholder="Search…"
165
+ aria-label={`Search ${label.toLowerCase()}`}
166
+ value={query}
167
+ onChange={(event) => setQuery(event.target.value)}
168
+ autoFocus
169
+ />
170
+ </div>
171
+ )}
172
+ <div className="filter-actions">
173
+ <button
174
+ type="button"
175
+ className="type type-fixed ts-text-xs-medium filter-action"
176
+ disabled={allShown}
177
+ onClick={checkAll}
178
+ >
179
+ All
180
+ </button>
181
+ <button
182
+ type="button"
183
+ className="type type-fixed ts-text-xs-medium filter-action"
184
+ disabled={noneShown}
185
+ onClick={checkNone}
186
+ >
187
+ None
188
+ </button>
189
+ <span className="type type-fixed ts-text-xs-light filter-tally">
190
+ {selected.length} / {options.length}
191
+ </span>
192
+ </div>
193
+ <div className="filter-options">
194
+ {shown.map((option) => {
195
+ const checked = selected.includes(option.value);
196
+ return (
197
+ <label
198
+ key={option.value}
199
+ className="type type-fixed ts-text-sm-light filter-option"
200
+ >
201
+ <input
202
+ type="checkbox"
203
+ className="check"
204
+ checked={checked}
205
+ onChange={() =>
206
+ onChange(
207
+ checked
208
+ ? selected.filter((v) => v !== option.value)
209
+ : [...selected, option.value],
210
+ )
211
+ }
212
+ />
213
+ <span>{option.label}</span>
214
+ </label>
215
+ );
216
+ })}
217
+ {shown.length === 0 && (
218
+ <p className="type type-fixed ts-text-sm-light filter-empty">No matches</p>
219
+ )}
220
+ </div>
221
+ </div>
222
+ )}
223
+ </div>
224
+ );
225
+ }
226
+
227
+ /** A button named for the one option chosen, opening the list to choose
228
+ * another; the consumer owns the choice. For a view's few modes (a
229
+ * total or a rate, a sort), where a filter would check all but one. */
230
+ export function ChoiceMenu<T extends string>({
231
+ label,
232
+ options,
233
+ value,
234
+ onChange,
235
+ }: {
236
+ label: string;
237
+ options: readonly FilterOption<T>[];
238
+ value: T;
239
+ onChange: (next: T) => void;
240
+ }) {
241
+ const { open, setOpen, rootRef } = usePopover<HTMLDivElement>();
242
+ const menuId = useId();
243
+ const name = useId();
244
+ const chosen = options.find((o) => o.value === value)?.label ?? value;
245
+ return (
246
+ <div className="filter" ref={rootRef}>
247
+ <FilterTrigger
248
+ label={chosen}
249
+ name={`${label}: ${chosen}`}
250
+ open={open}
251
+ menuId={menuId}
252
+ onToggle={() => setOpen((v) => !v)}
253
+ />
254
+ {open && (
255
+ <div className="filter-menu" id={menuId} role="radiogroup" aria-label={label}>
256
+ <div className="filter-options">
257
+ {options.map((option) => (
123
258
  <label key={option.value} className="type type-fixed ts-text-sm-light filter-option">
124
259
  <input
125
- type="checkbox"
260
+ type="radio"
126
261
  className="check"
127
- checked={checked}
128
- onChange={() =>
129
- onChange(
130
- checked
131
- ? selected.filter((v) => v !== option.value)
132
- : [...selected, option.value],
133
- )
134
- }
262
+ name={name}
263
+ checked={option.value === value}
264
+ onChange={() => {
265
+ onChange(option.value);
266
+ setOpen(false);
267
+ }}
135
268
  />
136
269
  <span>{option.label}</span>
137
270
  </label>
138
- );
139
- })}
271
+ ))}
272
+ </div>
140
273
  </div>
141
274
  )}
142
275
  </div>
@@ -0,0 +1,80 @@
1
+ /* MonthRange: the filter's trigger and popover frame around a year of
2
+ months. The stepper is the pager's round button; a chosen end is inked solid and the months between are
3
+ tinted; the staged range reads beneath before Cancel / Apply. */
4
+
5
+ /* Designed constants for this file. */
6
+ :root {
7
+ /* A month cell: wide enough for `Sep` at the control type. */
8
+ --mr-cell-w: 4.25rem;
9
+ --mr-cell-h: 36px;
10
+ }
11
+
12
+ .mr-menu {
13
+ gap: var(--space-md);
14
+ padding: var(--space-lg);
15
+ }
16
+ .mr-year {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: space-between;
20
+ gap: var(--space-md);
21
+ }
22
+ .mr-year-label {
23
+ color: var(--color-text-100);
24
+ font-variant-numeric: tabular-nums;
25
+ }
26
+ .mr-grid {
27
+ display: grid;
28
+ grid-template-columns: repeat(3, var(--mr-cell-w));
29
+ gap: var(--space-xs);
30
+ }
31
+ .mr-month {
32
+ appearance: none;
33
+ box-sizing: border-box;
34
+ height: var(--mr-cell-h);
35
+ margin: 0;
36
+ padding: 0;
37
+ border: 0;
38
+ border-radius: var(--radius-sm);
39
+ background: transparent;
40
+ color: var(--color-text-200);
41
+ cursor: pointer;
42
+ transition:
43
+ background var(--motion-hover-duration) var(--motion-hover-ease),
44
+ color var(--motion-hover-duration) var(--motion-hover-ease);
45
+ }
46
+ @media (hover: hover) {
47
+ .mr-month:not(:disabled):hover {
48
+ background: var(--color-bg-300);
49
+ color: var(--color-text-100);
50
+ }
51
+ }
52
+ .mr-month:focus-visible {
53
+ outline: none;
54
+ box-shadow: 0 0 0 var(--ring-w) var(--color-teal-100);
55
+ }
56
+ .mr-month:disabled {
57
+ color: var(--color-text-500);
58
+ cursor: default;
59
+ }
60
+ .mr-month[data-state="in"] {
61
+ background: var(--color-teal-100);
62
+ color: var(--color-teal-700);
63
+ }
64
+ .mr-month[data-state="from"],
65
+ .mr-month[data-state="to"] {
66
+ background: var(--color-teal-500);
67
+ color: var(--color-bg-000);
68
+ }
69
+ .mr-staged {
70
+ margin: 0;
71
+ color: var(--color-text-400);
72
+ text-align: center;
73
+ }
74
+ .mr-actions {
75
+ display: flex;
76
+ justify-content: flex-end;
77
+ gap: var(--space-sm);
78
+ padding-top: var(--space-xs);
79
+ border-top: 1px solid var(--color-border-050);
80
+ }
@@ -0,0 +1,183 @@
1
+ "use client";
2
+
3
+ /** MonthRange: a toolbar trigger that opens a picker of whole months,
4
+ * for series reported by the month. A year of months is stepped through;
5
+ * the first month tapped opens the range and the second closes it. The
6
+ * choice is staged until Apply, as the console's date picker does, so a
7
+ * half-made range never reaches the consumer. Styles live in
8
+ * month-range.css; the trigger and the popover frame are the filter's. */
9
+
10
+ import { useId, useState } from "react";
11
+ import { IconChevronLeftSm, IconChevronRightSm } from "../icons";
12
+ import { usePopover } from "../lib/use-popover";
13
+ import { ButtonFill, ButtonGhost } from "./buttons";
14
+ import { FilterTrigger } from "./disclosure";
15
+
16
+ /** A month as `YYYY-MM`. */
17
+ export type Month = string;
18
+
19
+ /** A span of months, either end open: `from` null begins where the data
20
+ * does, `to` null runs to its latest month. */
21
+ export interface MonthRangeValue {
22
+ from: Month | null;
23
+ to: Month | null;
24
+ }
25
+
26
+ const MONTHS_IN_YEAR = 12;
27
+
28
+ const parse = (month: Month): { year: number; index: number } => {
29
+ const [y, m] = month.split("-").map(Number);
30
+ return { year: y, index: m - 1 };
31
+ };
32
+ const key = (year: number, index: number): Month => `${year}-${String(index + 1).padStart(2, "0")}`;
33
+ const toDate = (month: Month) => {
34
+ const { year, index } = parse(month);
35
+ return new Date(Date.UTC(year, index, 1));
36
+ };
37
+
38
+ /** `Jul 2026`, in the reader's language. */
39
+ export function formatMonth(month: Month): string {
40
+ return toDate(month).toLocaleDateString(undefined, {
41
+ month: "short",
42
+ year: "numeric",
43
+ timeZone: "UTC",
44
+ });
45
+ }
46
+
47
+ /** `Jul 2026 – Oct 2026`, `From Jul 2026`, `To Oct 2026`, or `All months`. */
48
+ export function formatMonthRange(value: MonthRangeValue): string {
49
+ if (value.from && value.to) {
50
+ return value.from === value.to
51
+ ? formatMonth(value.from)
52
+ : `${formatMonth(value.from)} – ${formatMonth(value.to)}`;
53
+ }
54
+ if (value.from) return `From ${formatMonth(value.from)}`;
55
+ if (value.to) return `To ${formatMonth(value.to)}`;
56
+ return "All months";
57
+ }
58
+
59
+ const same = (a: MonthRangeValue, b: MonthRangeValue) => a.from === b.from && a.to === b.to;
60
+
61
+ export function MonthRange({
62
+ label,
63
+ value,
64
+ onChange,
65
+ min,
66
+ max,
67
+ }: {
68
+ /** Names the control for assistive technology. */
69
+ label: string;
70
+ value: MonthRangeValue;
71
+ onChange: (next: MonthRangeValue) => void;
72
+ /** The first and last months on offer; the data's own span. */
73
+ min: Month;
74
+ max: Month;
75
+ }) {
76
+ const { open, setOpen, rootRef } = usePopover<HTMLDivElement>();
77
+ const menuId = useId();
78
+ const [staged, setStaged] = useState<MonthRangeValue>(value);
79
+ const [year, setYear] = useState(() => parse(value.from ?? max).year);
80
+ const { year: minYear } = parse(min);
81
+ const { year: maxYear } = parse(max);
82
+
83
+ const toggle = () => {
84
+ if (!open) {
85
+ setStaged(value);
86
+ setYear(parse(value.from ?? max).year);
87
+ }
88
+ setOpen((v) => !v);
89
+ };
90
+ const close = () => setOpen(false);
91
+ const apply = () => {
92
+ onChange(staged);
93
+ close();
94
+ };
95
+
96
+ /* The first tap opens a range, the second closes it (either order);
97
+ a third starts over. */
98
+ const pick = (month: Month) => {
99
+ if (staged.from && !staged.to) {
100
+ setStaged(month < staged.from ? { from: month, to: staged.from } : { ...staged, to: month });
101
+ } else {
102
+ setStaged({ from: month, to: null });
103
+ }
104
+ };
105
+
106
+ const text = formatMonthRange(value);
107
+ const monthNames = Array.from({ length: MONTHS_IN_YEAR }, (_, index) =>
108
+ toDate(key(year, index)).toLocaleDateString(undefined, { month: "short", timeZone: "UTC" }),
109
+ );
110
+
111
+ const state = (month: Month): "from" | "to" | "in" | undefined => {
112
+ if (month === staged.from) return "from";
113
+ if (month === staged.to) return "to";
114
+ const after = !staged.from || month > staged.from;
115
+ const before = !staged.to || month < staged.to;
116
+ return (staged.from || staged.to) && after && before ? "in" : undefined;
117
+ };
118
+
119
+ return (
120
+ <div className="filter mr" ref={rootRef}>
121
+ <FilterTrigger
122
+ label={text}
123
+ name={`${label}: ${text}`}
124
+ open={open}
125
+ menuId={menuId}
126
+ onToggle={toggle}
127
+ />
128
+ {open && (
129
+ <div className="filter-menu mr-menu" id={menuId} role="group" aria-label={label}>
130
+ <div className="mr-year">
131
+ <button
132
+ type="button"
133
+ className="pager-btn"
134
+ aria-label="Previous year"
135
+ disabled={year <= minYear}
136
+ onClick={() => setYear((y) => y - 1)}
137
+ >
138
+ <IconChevronLeftSm />
139
+ </button>
140
+ <span className="type type-fixed ts-text-sm-medium mr-year-label">{year}</span>
141
+ <button
142
+ type="button"
143
+ className="pager-btn"
144
+ aria-label="Next year"
145
+ disabled={year >= maxYear}
146
+ onClick={() => setYear((y) => y + 1)}
147
+ >
148
+ <IconChevronRightSm />
149
+ </button>
150
+ </div>
151
+ <div className="mr-grid">
152
+ {monthNames.map((name, index) => {
153
+ const month = key(year, index);
154
+ return (
155
+ <button
156
+ key={month}
157
+ type="button"
158
+ className="type type-fixed ts-text-sm-regular mr-month"
159
+ data-state={state(month)}
160
+ aria-pressed={month === staged.from || month === staged.to}
161
+ aria-label={formatMonth(month)}
162
+ disabled={month < min || month > max}
163
+ onClick={() => pick(month)}
164
+ >
165
+ {name}
166
+ </button>
167
+ );
168
+ })}
169
+ </div>
170
+ <p className="type type-fixed ts-text-xs-light mr-staged">{formatMonthRange(staged)}</p>
171
+ <div className="mr-actions">
172
+ <ButtonGhost size="sm" color="gray" icon={null} onClick={close}>
173
+ Cancel
174
+ </ButtonGhost>
175
+ <ButtonFill size="sm" shape="box" onClick={apply} disabled={same(staged, value)}>
176
+ Apply
177
+ </ButtonFill>
178
+ </div>
179
+ </div>
180
+ )}
181
+ </div>
182
+ );
183
+ }
@@ -3,7 +3,8 @@
3
3
  tick when active). The wrap scrolls sideways so columns keep their
4
4
  widths from the tablet band; below it, marked columns drop instead.
5
5
  The body's type is the table's ts- step; cells restate only the
6
- step that differs (head, primary, secondary, mono). */
6
+ step that differs (head, primary, secondary, mono). `.pager-btn` is
7
+ the round step button the month range's year stepper shares. */
7
8
 
8
9
  /* Designed constants for this file. */
9
10
  :root {