@eqtylab/equality 5.3.4 → 5.4.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  Notable changes to Equality are recorded here, following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
4
 
5
+ ## 5.4.1 - 2026-11-09
6
+
7
+ ### Added
8
+
9
+ - `DateRangePicker` takes `timeZone`, an IANA name. Its today, selected days, label and the
10
+ `from` and `to` it hands back follow that zone, so a range picked under a user's zone
11
+ preference starts and ends at that zone's midnights. Without it, days follow the browser's zone
12
+ as before.
13
+ - `DateRangePicker` marks today with `aria-current="date"`.
14
+
15
+ ### Fixed
16
+
17
+ - `DateRangePicker` treats an invalid `from` or `to` as unset. It had labelled the range
18
+ "Invalid Date".
19
+
20
+ ## 5.4.0 - 2026-11-09
21
+
22
+ ### Added
23
+
24
+ - `--eq-nav-offset`, a length, pins `NavRail` and `NavPanel` that far below the top of the viewport,
25
+ such as under a sticky header. It defaults to `0px`. Set it on the element around the sidebar.
26
+
27
+ ### Changed
28
+
29
+ - `DropdownMenu`, `Select` and `Command` items light grey on hover and keyboard focus, like a Nav
30
+ row, where they turned purple with purple text, and they no longer lift with a shadow. Danger and
31
+ warning items keep their own colours.
32
+ - A `CommandItem` lights when it is selected, from the keyboard or the pointer, where it lit only
33
+ under the pointer, so arrowing through a list showed nothing.
34
+ - A linked `Table` row draws keyboard focus in the focus-ring colour, like every other control,
35
+ where it used the paler brand purple.
36
+
37
+ ### Fixed
38
+
39
+ - A `NavSwitcher` in a `NavPanel` beside a `NavRail` centres on the rail's first item, where it sat
40
+ 4px high with a mouse or trackpad.
41
+ - A focused linked `Table` row draws one focus line, where the row's link drew the browser's own
42
+ outline just outside it as well.
43
+
5
44
  ## 5.3.4 - 2026-11-06
6
45
 
7
46
  ### Fixed
@@ -185,73 +185,8 @@
185
185
  &[data-disabled="true"] {
186
186
  opacity: 50%;
187
187
  }
188
- &:hover {
189
- @media (hover: hover) {
190
- &:not(*:disabled) {
191
- color: var(--color-lilac-700, color(display-p3 0.2927 0.172 0.4505)) !important;
192
- }
193
- }
194
- }
195
- &:focus {
196
- color: var(--color-lilac-700, color(display-p3 0.2927 0.172 0.4505)) !important;
197
- }
198
- &:hover {
199
- @media (hover: hover) {
200
- &:not(*:disabled) {
201
- background-color: color-mix(in srgb, color(display-p3 0.7319 0.6108 0.8873) 50%, transparent) !important;
202
- @supports (color: color-mix(in lab, red, red)) {
203
- background-color: color-mix(in oklab, var(--color-lilac-300, color(display-p3 0.7319 0.6108 0.8873)) 50%, transparent) !important;
204
- }
205
- }
206
- }
207
- }
208
- &:focus {
209
- background-color: color-mix(in srgb, color(display-p3 0.7319 0.6108 0.8873) 50%, transparent) !important;
210
- @supports (color: color-mix(in lab, red, red)) {
211
- background-color: color-mix(in oklab, var(--color-lilac-300, color(display-p3 0.7319 0.6108 0.8873)) 50%, transparent) !important;
212
- }
213
- }
214
- &:hover {
215
- @media (hover: hover) {
216
- &:not(*:disabled) {
217
- --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
218
- box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
219
- }
220
- }
221
- }
222
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
223
- &:hover {
224
- @media (hover: hover) {
225
- &:not(*:disabled) {
226
- background-color: color-mix(in srgb, color(display-p3 0.4045 0.2306 0.6077) 50%, transparent) !important;
227
- @supports (color: color-mix(in lab, red, red)) {
228
- background-color: color-mix(in oklab, var(--color-lilac-600, color(display-p3 0.4045 0.2306 0.6077)) 50%, transparent) !important;
229
- }
230
- }
231
- }
232
- }
233
- }
234
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
235
- &:focus {
236
- background-color: color-mix(in srgb, color(display-p3 0.4045 0.2306 0.6077) 50%, transparent) !important;
237
- @supports (color: color-mix(in lab, red, red)) {
238
- background-color: color-mix(in oklab, var(--color-lilac-600, color(display-p3 0.4045 0.2306 0.6077)) 50%, transparent) !important;
239
- }
240
- }
241
- }
242
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
243
- &:hover {
244
- @media (hover: hover) {
245
- &:not(*:disabled) {
246
- color: var(--color-lilac-100, color(display-p3 0.9492 0.917 0.9935)) !important;
247
- }
248
- }
249
- }
250
- }
251
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
252
- &:focus {
253
- color: var(--color-lilac-100, color(display-p3 0.9492 0.917 0.9935)) !important;
254
- }
188
+ &[data-selected="true"] {
189
+ background-color: var(--color-list-item-hover);
255
190
  }
256
191
  }
257
192
  .command-shortcut {
@@ -269,68 +204,3 @@
269
204
  syntax: "*";
270
205
  inherits: false;
271
206
  }
272
- @property --tw-shadow {
273
- syntax: "*";
274
- inherits: false;
275
- initial-value: 0 0 #0000;
276
- }
277
- @property --tw-shadow-color {
278
- syntax: "*";
279
- inherits: false;
280
- }
281
- @property --tw-shadow-alpha {
282
- syntax: "<percentage>";
283
- inherits: false;
284
- initial-value: 100%;
285
- }
286
- @property --tw-inset-shadow {
287
- syntax: "*";
288
- inherits: false;
289
- initial-value: 0 0 #0000;
290
- }
291
- @property --tw-inset-shadow-color {
292
- syntax: "*";
293
- inherits: false;
294
- }
295
- @property --tw-inset-shadow-alpha {
296
- syntax: "<percentage>";
297
- inherits: false;
298
- initial-value: 100%;
299
- }
300
- @property --tw-ring-color {
301
- syntax: "*";
302
- inherits: false;
303
- }
304
- @property --tw-ring-shadow {
305
- syntax: "*";
306
- inherits: false;
307
- initial-value: 0 0 #0000;
308
- }
309
- @property --tw-inset-ring-color {
310
- syntax: "*";
311
- inherits: false;
312
- }
313
- @property --tw-inset-ring-shadow {
314
- syntax: "*";
315
- inherits: false;
316
- initial-value: 0 0 #0000;
317
- }
318
- @property --tw-ring-inset {
319
- syntax: "*";
320
- inherits: false;
321
- }
322
- @property --tw-ring-offset-width {
323
- syntax: "<length>";
324
- inherits: false;
325
- initial-value: 0px;
326
- }
327
- @property --tw-ring-offset-color {
328
- syntax: "*";
329
- inherits: false;
330
- initial-value: #fff;
331
- }
332
- @property --tw-ring-offset-shadow {
333
- syntax: "*";
334
- inherits: false;
335
- initial-value: 0 0 #0000;
336
- }
@@ -106,70 +106,12 @@
106
106
  &:hover {
107
107
  @media (hover: hover) {
108
108
  &:not(*:disabled) {
109
- color: var(--color-lilac-700, color(display-p3 0.2927 0.172 0.4505)) !important;
109
+ background-color: var(--color-list-item-hover) !important;
110
110
  }
111
111
  }
112
112
  }
113
113
  &:focus {
114
- color: var(--color-lilac-700, color(display-p3 0.2927 0.172 0.4505)) !important;
115
- }
116
- &:hover {
117
- @media (hover: hover) {
118
- &:not(*:disabled) {
119
- background-color: color-mix(in srgb, color(display-p3 0.7319 0.6108 0.8873) 50%, transparent) !important;
120
- @supports (color: color-mix(in lab, red, red)) {
121
- background-color: color-mix(in oklab, var(--color-lilac-300, color(display-p3 0.7319 0.6108 0.8873)) 50%, transparent) !important;
122
- }
123
- }
124
- }
125
- }
126
- &:focus {
127
- background-color: color-mix(in srgb, color(display-p3 0.7319 0.6108 0.8873) 50%, transparent) !important;
128
- @supports (color: color-mix(in lab, red, red)) {
129
- background-color: color-mix(in oklab, var(--color-lilac-300, color(display-p3 0.7319 0.6108 0.8873)) 50%, transparent) !important;
130
- }
131
- }
132
- &:hover {
133
- @media (hover: hover) {
134
- &:not(*:disabled) {
135
- --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
136
- box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
137
- }
138
- }
139
- }
140
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
141
- &:hover {
142
- @media (hover: hover) {
143
- &:not(*:disabled) {
144
- background-color: color-mix(in srgb, color(display-p3 0.4045 0.2306 0.6077) 50%, transparent) !important;
145
- @supports (color: color-mix(in lab, red, red)) {
146
- background-color: color-mix(in oklab, var(--color-lilac-600, color(display-p3 0.4045 0.2306 0.6077)) 50%, transparent) !important;
147
- }
148
- }
149
- }
150
- }
151
- }
152
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
153
- &:focus {
154
- background-color: color-mix(in srgb, color(display-p3 0.4045 0.2306 0.6077) 50%, transparent) !important;
155
- @supports (color: color-mix(in lab, red, red)) {
156
- background-color: color-mix(in oklab, var(--color-lilac-600, color(display-p3 0.4045 0.2306 0.6077)) 50%, transparent) !important;
157
- }
158
- }
159
- }
160
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
161
- &:hover {
162
- @media (hover: hover) {
163
- &:not(*:disabled) {
164
- color: var(--color-lilac-100, color(display-p3 0.9492 0.917 0.9935)) !important;
165
- }
166
- }
167
- }
168
- }
169
- &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
170
- &:focus {
171
- color: var(--color-lilac-100, color(display-p3 0.9492 0.917 0.9935)) !important;
172
- }
114
+ background-color: var(--color-list-item-hover) !important;
173
115
  }
174
116
  }
175
117
  .dropdown-menu-item-danger {
@@ -442,6 +384,10 @@
442
384
  inherits: false;
443
385
  initial-value: solid;
444
386
  }
387
+ @property --tw-font-weight {
388
+ syntax: "*";
389
+ inherits: false;
390
+ }
445
391
  @property --tw-shadow {
446
392
  syntax: "*";
447
393
  inherits: false;
@@ -507,10 +453,6 @@
507
453
  inherits: false;
508
454
  initial-value: 0 0 #0000;
509
455
  }
510
- @property --tw-font-weight {
511
- syntax: "*";
512
- inherits: false;
513
- }
514
456
  @keyframes enter {
515
457
  from {
516
458
  opacity: var(--tw-enter-opacity,1);
package/dist/index.cjs CHANGED
@@ -1481,21 +1481,68 @@ var PopoverContent = React16__namespace.forwardRef(({ className, align = "center
1481
1481
  }
1482
1482
  ) }));
1483
1483
  PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
1484
+
1485
+ // src/lib/zoned-day.ts
1486
+ var formatters = /* @__PURE__ */ new Map();
1487
+ var formatterFor = (timeZone) => {
1488
+ const key = timeZone ?? "";
1489
+ let formatter = formatters.get(key);
1490
+ if (!formatter) {
1491
+ formatter = new Intl.DateTimeFormat("en-US", {
1492
+ timeZone,
1493
+ year: "numeric",
1494
+ month: "numeric",
1495
+ day: "numeric"
1496
+ });
1497
+ formatters.set(key, formatter);
1498
+ }
1499
+ return formatter;
1500
+ };
1501
+ var dayOf = (instant, timeZone) => {
1502
+ const parts = formatterFor(timeZone).formatToParts(instant);
1503
+ const part = (type) => Number(parts.find((p) => p.type === type)?.value);
1504
+ return { year: part("year"), month: part("month") - 1, day: part("day") };
1505
+ };
1506
+ var dayKey = ({ year, month, day }) => year * 1e4 + month * 100 + day;
1507
+ var addDays = ({ year, month, day }, count2) => {
1508
+ const date = new Date(Date.UTC(year, month, day + count2));
1509
+ return { year: date.getUTCFullYear(), month: date.getUTCMonth(), day: date.getUTCDate() };
1510
+ };
1511
+ var SEARCH_WINDOW = 15 * 60 * 60 * 1e3;
1512
+ var startOfDay = (target, timeZone) => {
1513
+ const key = dayKey(target);
1514
+ const utcMidnight = Date.UTC(target.year, target.month, target.day);
1515
+ let low = utcMidnight - SEARCH_WINDOW;
1516
+ let high = utcMidnight + SEARCH_WINDOW;
1517
+ while (low < high) {
1518
+ const middle = Math.floor((low + high) / 2);
1519
+ if (dayKey(dayOf(new Date(middle), timeZone)) < key) low = middle + 1;
1520
+ else high = middle;
1521
+ }
1522
+ return new Date(low);
1523
+ };
1524
+ var endOfDay = (target, timeZone) => new Date(startOfDay(addDays(target, 1), timeZone).getTime() - 1);
1484
1525
  var CalendarDaysIcon = LucideIcons.CalendarDays;
1485
1526
  var ChevronLeftIcon = LucideIcons.ChevronLeft;
1486
1527
  var ChevronRightIcon = LucideIcons.ChevronRight;
1487
- var DateRangePicker = ({ dateRange, onSelect, className }) => {
1528
+ var validDate = (date) => date && !Number.isNaN(date.getTime()) ? date : void 0;
1529
+ var DateRangePicker = ({ dateRange, onSelect, className, timeZone }) => {
1530
+ const today = dayOf(/* @__PURE__ */ new Date(), timeZone);
1488
1531
  const [selecting, setSelecting] = React16.useState(null);
1489
- const [displayedMonth, setDisplayedMonth] = React16.useState((/* @__PURE__ */ new Date()).getMonth());
1490
- const [displayedYear, setDisplayedYear] = React16.useState((/* @__PURE__ */ new Date()).getFullYear());
1491
- const daysInMonth = new Date(displayedYear, displayedMonth + 1, 0).getDate();
1492
- const firstDayOfMonth = new Date(displayedYear, displayedMonth, 1).getDay();
1532
+ const [displayedMonth, setDisplayedMonth] = React16.useState(today.month);
1533
+ const [displayedYear, setDisplayedYear] = React16.useState(today.year);
1534
+ const from = validDate(dateRange.from);
1535
+ const to = validDate(dateRange.to);
1536
+ const daysInMonth = new Date(Date.UTC(displayedYear, displayedMonth + 1, 0)).getUTCDate();
1537
+ const firstDayOfMonth = new Date(Date.UTC(displayedYear, displayedMonth, 1)).getUTCDay();
1493
1538
  const days = Array.from(
1494
1539
  { length: daysInMonth },
1495
- (_, i) => new Date(displayedYear, displayedMonth, i + 1)
1540
+ (_, i) => ({ year: displayedYear, month: displayedMonth, day: i + 1 })
1496
1541
  );
1542
+ const fromKey = from && dayKey(dayOf(from, timeZone));
1543
+ const toKey = to && dayKey(dayOf(to, timeZone));
1497
1544
  const paddingDays = Array.from({ length: firstDayOfMonth }, (_, _i) => null);
1498
- const hasSelection = dateRange.from || dateRange.to;
1545
+ const hasSelection = from || to;
1499
1546
  const MONTHS = [
1500
1547
  "January",
1501
1548
  "February",
@@ -1512,11 +1559,8 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
1512
1559
  ];
1513
1560
  const DAY_HEADERS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
1514
1561
  const formatDate = (date) => {
1515
- return date.toLocaleDateString("en-US", {
1516
- year: "numeric",
1517
- month: "2-digit",
1518
- day: "2-digit"
1519
- });
1562
+ const { year, month, day } = dayOf(date, timeZone);
1563
+ return `${String(month + 1).padStart(2, "0")}/${String(day).padStart(2, "0")}/${year}`;
1520
1564
  };
1521
1565
  const formatRange = (range) => {
1522
1566
  if (!range.from && !range.to) return "Select Date Range";
@@ -1524,15 +1568,9 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
1524
1568
  if (!range.from) return `Until ${formatDate(range.to)}`;
1525
1569
  return `${formatDate(range.from)} - ${formatDate(range.to)}`;
1526
1570
  };
1527
- const isDateSelected = (day, dateRange2) => {
1528
- const matchesFrom = dateRange2.from && day.getDate() === dateRange2.from.getDate() && day.getMonth() === dateRange2.from.getMonth() && day.getFullYear() === dateRange2.from.getFullYear();
1529
- const matchesTo = dateRange2.to && day.getDate() === dateRange2.to.getDate() && day.getMonth() === dateRange2.to.getMonth() && day.getFullYear() === dateRange2.to.getFullYear();
1530
- return !!matchesFrom || !!matchesTo;
1531
- };
1532
- const checkIsToday = (day) => {
1533
- const today = /* @__PURE__ */ new Date();
1534
- return day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear();
1535
- };
1571
+ const isDateSelected = (day) => dayKey(day) === fromKey || dayKey(day) === toKey;
1572
+ const todayKey = dayKey(today);
1573
+ const checkIsToday = (day) => dayKey(day) === todayKey;
1536
1574
  const goToPreviousMonth = () => {
1537
1575
  if (displayedMonth === 0) {
1538
1576
  setDisplayedMonth(11);
@@ -1549,34 +1587,23 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
1549
1587
  setDisplayedMonth(displayedMonth + 1);
1550
1588
  }
1551
1589
  };
1552
- const isInRange = (date) => {
1553
- if (!dateRange.from || !dateRange.to) return false;
1554
- return date >= dateRange.from && date <= dateRange.to;
1590
+ const isInRange = (day) => {
1591
+ if (fromKey === void 0 || toKey === void 0) return false;
1592
+ return dayKey(day) >= fromKey && dayKey(day) <= toKey;
1555
1593
  };
1556
- const handleDateSelect = (selectedDate) => {
1557
- const startOfDay = (date) => {
1558
- const d = new Date(date);
1559
- d.setHours(0, 0, 0, 0);
1560
- return d;
1561
- };
1562
- const endOfDay = (date) => {
1563
- const d = new Date(date);
1564
- d.setHours(23, 59, 59, 999);
1565
- return d;
1566
- };
1567
- if (!selecting || !dateRange) {
1568
- onSelect({ from: startOfDay(selectedDate), to: void 0 });
1594
+ const handleDateSelect = (selectedDay) => {
1595
+ if (!selecting || !from) {
1596
+ onSelect({ from: startOfDay(selectedDay, timeZone), to: void 0 });
1569
1597
  setSelecting("to");
1570
1598
  return;
1571
1599
  }
1572
- if (selecting === "to") {
1573
- if (dateRange.from && selectedDate < dateRange.from) {
1574
- onSelect({ from: startOfDay(selectedDate), to: endOfDay(dateRange.from) });
1575
- } else {
1576
- onSelect({ from: startOfDay(dateRange.from), to: endOfDay(selectedDate) });
1577
- }
1578
- setSelecting(null);
1600
+ const fromDay = dayOf(from, timeZone);
1601
+ if (dayKey(selectedDay) < dayKey(fromDay)) {
1602
+ onSelect({ from: startOfDay(selectedDay, timeZone), to: endOfDay(fromDay, timeZone) });
1603
+ } else {
1604
+ onSelect({ from: startOfDay(fromDay, timeZone), to: endOfDay(selectedDay, timeZone) });
1579
1605
  }
1606
+ setSelecting(null);
1580
1607
  };
1581
1608
  const clearSelection = () => {
1582
1609
  onSelect({ from: void 0, to: void 0 });
@@ -1602,7 +1629,7 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
1602
1629
  }
1603
1630
  ),
1604
1631
  className,
1605
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles20__default.default["date-range"], children: formatRange(dateRange) })
1632
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles20__default.default["date-range"], children: formatRange({ from, to }) })
1606
1633
  }
1607
1634
  ) }) }),
1608
1635
  /* @__PURE__ */ jsxRuntime.jsxs(PopoverContent, { className: styles20__default.default["popover-content"], align: "end", children: [
@@ -1636,7 +1663,7 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
1636
1663
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles20__default.default["calendar-grid"], children: [
1637
1664
  paddingDays.map((_, index) => /* @__PURE__ */ jsxRuntime.jsx("div", {}, `padding-${index}`)),
1638
1665
  days.map((day, index) => {
1639
- const isSelected = isDateSelected(day, dateRange);
1666
+ const isSelected = isDateSelected(day);
1640
1667
  const isToday = checkIsToday(day);
1641
1668
  const inRange = isInRange(day);
1642
1669
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -1649,8 +1676,9 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
1649
1676
  isToday && !isSelected && styles20__default.default["calendar-day-btn--today"],
1650
1677
  inRange && !isSelected && styles20__default.default["calendar-day-btn--in-range"]
1651
1678
  ),
1679
+ "aria-current": isToday ? "date" : void 0,
1652
1680
  onClick: () => handleDateSelect(day),
1653
- children: day.getDate()
1681
+ children: day.day
1654
1682
  },
1655
1683
  index
1656
1684
  );