@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 +39 -0
- package/dist/command.module.module.css.module.css +2 -132
- package/dist/dropdown-menu.module.module.css.module.css +6 -64
- package/dist/index.cjs +75 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +75 -47
- package/dist/index.js.map +1 -1
- package/dist/nav.module.module.css.module.css +16 -2
- package/dist/select.module.module.css.module.css +2 -60
- package/dist/table-components.module.module.css.module.css +3 -1
- package/dist/theme-utilities.css +1 -5
- package/dist/theme.module.module.css.module.css +45 -89
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -132,7 +132,7 @@ declare const AlertDialogDescription: React$1.ForwardRefExoticComponent<Omit<Ale
|
|
|
132
132
|
* [Alert Dialog documentation](https://equality.eqtylab.io/components/alert-dialog)
|
|
133
133
|
*/
|
|
134
134
|
declare const AlertDialogAction: React$1.ForwardRefExoticComponent<Omit<Omit<AlertDialogPrimitive.AlertDialogActionProps & React$1.RefAttributes<HTMLButtonElement>, "ref">, "prefix"> & VariantProps<(props?: ({
|
|
135
|
-
variant?: "
|
|
135
|
+
variant?: "primary" | "danger" | "success" | "warning" | "secondary" | "tertiary" | "link" | "navigation" | null | undefined;
|
|
136
136
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
137
137
|
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
138
138
|
prefix?: React$1.ReactNode;
|
|
@@ -151,7 +151,7 @@ declare const AlertDialogAction: React$1.ForwardRefExoticComponent<Omit<Omit<Ale
|
|
|
151
151
|
* [Alert Dialog documentation](https://equality.eqtylab.io/components/alert-dialog)
|
|
152
152
|
*/
|
|
153
153
|
declare const AlertDialogCancel: React$1.ForwardRefExoticComponent<Omit<Omit<AlertDialogPrimitive.AlertDialogCancelProps & React$1.RefAttributes<HTMLButtonElement>, "ref">, "prefix"> & VariantProps<(props?: ({
|
|
154
|
-
variant?: "
|
|
154
|
+
variant?: "primary" | "danger" | "success" | "warning" | "secondary" | "tertiary" | "link" | "navigation" | null | undefined;
|
|
155
155
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
156
156
|
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
157
157
|
prefix?: React$1.ReactNode;
|
|
@@ -452,7 +452,7 @@ declare const BgGradient: ({ theme, placement, }: {
|
|
|
452
452
|
}) => react_jsx_runtime.JSX.Element;
|
|
453
453
|
|
|
454
454
|
declare const buttonVariants: (props?: ({
|
|
455
|
-
variant?: "
|
|
455
|
+
variant?: "primary" | "danger" | "success" | "warning" | "secondary" | "tertiary" | "link" | "navigation" | null | undefined;
|
|
456
456
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
457
457
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
458
458
|
type ButtonBaseProps = Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, 'prefix'>;
|
|
@@ -881,19 +881,25 @@ interface DateRange {
|
|
|
881
881
|
to?: Date;
|
|
882
882
|
}
|
|
883
883
|
interface DateRangePickerProps {
|
|
884
|
+
/** The selected range; either end may be unset */
|
|
884
885
|
dateRange: DateRange;
|
|
886
|
+
/** Called with the new range when a day is picked or the range is cleared */
|
|
885
887
|
onSelect: (range: DateRange) => void;
|
|
888
|
+
/** Additional classes on the trigger button */
|
|
886
889
|
className?: string;
|
|
890
|
+
/** IANA time zone the days follow, such as `Europe/Paris`. @default the browser's zone */
|
|
891
|
+
timeZone?: string;
|
|
887
892
|
}
|
|
888
893
|
/**
|
|
889
894
|
* **Props**
|
|
890
|
-
* - `dateRange: DateRange`
|
|
891
|
-
* - `onSelect: (range: DateRange) => void`
|
|
892
|
-
* - `className?: string`
|
|
895
|
+
* - `dateRange: DateRange` — The selected range; either end may be unset
|
|
896
|
+
* - `onSelect: (range: DateRange) => void` — Called with the new range when a day is picked or the range is cleared
|
|
897
|
+
* - `className?: string` — Additional classes on the trigger button
|
|
898
|
+
* - `timeZone?: string` (default `the browser's zone`) — IANA time zone the days follow, such as `Europe/Paris`.
|
|
893
899
|
*
|
|
894
900
|
* [Date Range Picker documentation](https://equality.eqtylab.io/components/date-range-picker)
|
|
895
901
|
*/
|
|
896
|
-
declare const DateRangePicker: ({ dateRange, onSelect, className }: DateRangePickerProps) => react_jsx_runtime.JSX.Element;
|
|
902
|
+
declare const DateRangePicker: ({ dateRange, onSelect, className, timeZone }: DateRangePickerProps) => react_jsx_runtime.JSX.Element;
|
|
897
903
|
|
|
898
904
|
declare const displayFieldVariants: (props?: ({
|
|
899
905
|
variant?: "success" | "neutral" | "neutralCheck" | "failure" | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ declare const AlertDialogDescription: React$1.ForwardRefExoticComponent<Omit<Ale
|
|
|
132
132
|
* [Alert Dialog documentation](https://equality.eqtylab.io/components/alert-dialog)
|
|
133
133
|
*/
|
|
134
134
|
declare const AlertDialogAction: React$1.ForwardRefExoticComponent<Omit<Omit<AlertDialogPrimitive.AlertDialogActionProps & React$1.RefAttributes<HTMLButtonElement>, "ref">, "prefix"> & VariantProps<(props?: ({
|
|
135
|
-
variant?: "
|
|
135
|
+
variant?: "primary" | "danger" | "success" | "warning" | "secondary" | "tertiary" | "link" | "navigation" | null | undefined;
|
|
136
136
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
137
137
|
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
138
138
|
prefix?: React$1.ReactNode;
|
|
@@ -151,7 +151,7 @@ declare const AlertDialogAction: React$1.ForwardRefExoticComponent<Omit<Omit<Ale
|
|
|
151
151
|
* [Alert Dialog documentation](https://equality.eqtylab.io/components/alert-dialog)
|
|
152
152
|
*/
|
|
153
153
|
declare const AlertDialogCancel: React$1.ForwardRefExoticComponent<Omit<Omit<AlertDialogPrimitive.AlertDialogCancelProps & React$1.RefAttributes<HTMLButtonElement>, "ref">, "prefix"> & VariantProps<(props?: ({
|
|
154
|
-
variant?: "
|
|
154
|
+
variant?: "primary" | "danger" | "success" | "warning" | "secondary" | "tertiary" | "link" | "navigation" | null | undefined;
|
|
155
155
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
156
156
|
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
157
157
|
prefix?: React$1.ReactNode;
|
|
@@ -452,7 +452,7 @@ declare const BgGradient: ({ theme, placement, }: {
|
|
|
452
452
|
}) => react_jsx_runtime.JSX.Element;
|
|
453
453
|
|
|
454
454
|
declare const buttonVariants: (props?: ({
|
|
455
|
-
variant?: "
|
|
455
|
+
variant?: "primary" | "danger" | "success" | "warning" | "secondary" | "tertiary" | "link" | "navigation" | null | undefined;
|
|
456
456
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
457
457
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
458
458
|
type ButtonBaseProps = Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, 'prefix'>;
|
|
@@ -881,19 +881,25 @@ interface DateRange {
|
|
|
881
881
|
to?: Date;
|
|
882
882
|
}
|
|
883
883
|
interface DateRangePickerProps {
|
|
884
|
+
/** The selected range; either end may be unset */
|
|
884
885
|
dateRange: DateRange;
|
|
886
|
+
/** Called with the new range when a day is picked or the range is cleared */
|
|
885
887
|
onSelect: (range: DateRange) => void;
|
|
888
|
+
/** Additional classes on the trigger button */
|
|
886
889
|
className?: string;
|
|
890
|
+
/** IANA time zone the days follow, such as `Europe/Paris`. @default the browser's zone */
|
|
891
|
+
timeZone?: string;
|
|
887
892
|
}
|
|
888
893
|
/**
|
|
889
894
|
* **Props**
|
|
890
|
-
* - `dateRange: DateRange`
|
|
891
|
-
* - `onSelect: (range: DateRange) => void`
|
|
892
|
-
* - `className?: string`
|
|
895
|
+
* - `dateRange: DateRange` — The selected range; either end may be unset
|
|
896
|
+
* - `onSelect: (range: DateRange) => void` — Called with the new range when a day is picked or the range is cleared
|
|
897
|
+
* - `className?: string` — Additional classes on the trigger button
|
|
898
|
+
* - `timeZone?: string` (default `the browser's zone`) — IANA time zone the days follow, such as `Europe/Paris`.
|
|
893
899
|
*
|
|
894
900
|
* [Date Range Picker documentation](https://equality.eqtylab.io/components/date-range-picker)
|
|
895
901
|
*/
|
|
896
|
-
declare const DateRangePicker: ({ dateRange, onSelect, className }: DateRangePickerProps) => react_jsx_runtime.JSX.Element;
|
|
902
|
+
declare const DateRangePicker: ({ dateRange, onSelect, className, timeZone }: DateRangePickerProps) => react_jsx_runtime.JSX.Element;
|
|
897
903
|
|
|
898
904
|
declare const displayFieldVariants: (props?: ({
|
|
899
905
|
variant?: "success" | "neutral" | "neutralCheck" | "failure" | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1378,21 +1378,68 @@ var PopoverContent = React16.forwardRef(({ className, align = "center", sideOffs
|
|
|
1378
1378
|
}
|
|
1379
1379
|
) }));
|
|
1380
1380
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
1381
|
+
|
|
1382
|
+
// src/lib/zoned-day.ts
|
|
1383
|
+
var formatters = /* @__PURE__ */ new Map();
|
|
1384
|
+
var formatterFor = (timeZone) => {
|
|
1385
|
+
const key = timeZone ?? "";
|
|
1386
|
+
let formatter = formatters.get(key);
|
|
1387
|
+
if (!formatter) {
|
|
1388
|
+
formatter = new Intl.DateTimeFormat("en-US", {
|
|
1389
|
+
timeZone,
|
|
1390
|
+
year: "numeric",
|
|
1391
|
+
month: "numeric",
|
|
1392
|
+
day: "numeric"
|
|
1393
|
+
});
|
|
1394
|
+
formatters.set(key, formatter);
|
|
1395
|
+
}
|
|
1396
|
+
return formatter;
|
|
1397
|
+
};
|
|
1398
|
+
var dayOf = (instant, timeZone) => {
|
|
1399
|
+
const parts = formatterFor(timeZone).formatToParts(instant);
|
|
1400
|
+
const part = (type) => Number(parts.find((p) => p.type === type)?.value);
|
|
1401
|
+
return { year: part("year"), month: part("month") - 1, day: part("day") };
|
|
1402
|
+
};
|
|
1403
|
+
var dayKey = ({ year, month, day }) => year * 1e4 + month * 100 + day;
|
|
1404
|
+
var addDays = ({ year, month, day }, count2) => {
|
|
1405
|
+
const date = new Date(Date.UTC(year, month, day + count2));
|
|
1406
|
+
return { year: date.getUTCFullYear(), month: date.getUTCMonth(), day: date.getUTCDate() };
|
|
1407
|
+
};
|
|
1408
|
+
var SEARCH_WINDOW = 15 * 60 * 60 * 1e3;
|
|
1409
|
+
var startOfDay = (target, timeZone) => {
|
|
1410
|
+
const key = dayKey(target);
|
|
1411
|
+
const utcMidnight = Date.UTC(target.year, target.month, target.day);
|
|
1412
|
+
let low = utcMidnight - SEARCH_WINDOW;
|
|
1413
|
+
let high = utcMidnight + SEARCH_WINDOW;
|
|
1414
|
+
while (low < high) {
|
|
1415
|
+
const middle = Math.floor((low + high) / 2);
|
|
1416
|
+
if (dayKey(dayOf(new Date(middle), timeZone)) < key) low = middle + 1;
|
|
1417
|
+
else high = middle;
|
|
1418
|
+
}
|
|
1419
|
+
return new Date(low);
|
|
1420
|
+
};
|
|
1421
|
+
var endOfDay = (target, timeZone) => new Date(startOfDay(addDays(target, 1), timeZone).getTime() - 1);
|
|
1381
1422
|
var CalendarDaysIcon = CalendarDays;
|
|
1382
1423
|
var ChevronLeftIcon = ChevronLeft;
|
|
1383
1424
|
var ChevronRightIcon = ChevronRight;
|
|
1384
|
-
var
|
|
1425
|
+
var validDate = (date) => date && !Number.isNaN(date.getTime()) ? date : void 0;
|
|
1426
|
+
var DateRangePicker = ({ dateRange, onSelect, className, timeZone }) => {
|
|
1427
|
+
const today = dayOf(/* @__PURE__ */ new Date(), timeZone);
|
|
1385
1428
|
const [selecting, setSelecting] = useState(null);
|
|
1386
|
-
const [displayedMonth, setDisplayedMonth] = useState(
|
|
1387
|
-
const [displayedYear, setDisplayedYear] = useState(
|
|
1388
|
-
const
|
|
1389
|
-
const
|
|
1429
|
+
const [displayedMonth, setDisplayedMonth] = useState(today.month);
|
|
1430
|
+
const [displayedYear, setDisplayedYear] = useState(today.year);
|
|
1431
|
+
const from = validDate(dateRange.from);
|
|
1432
|
+
const to = validDate(dateRange.to);
|
|
1433
|
+
const daysInMonth = new Date(Date.UTC(displayedYear, displayedMonth + 1, 0)).getUTCDate();
|
|
1434
|
+
const firstDayOfMonth = new Date(Date.UTC(displayedYear, displayedMonth, 1)).getUTCDay();
|
|
1390
1435
|
const days = Array.from(
|
|
1391
1436
|
{ length: daysInMonth },
|
|
1392
|
-
(_, i) =>
|
|
1437
|
+
(_, i) => ({ year: displayedYear, month: displayedMonth, day: i + 1 })
|
|
1393
1438
|
);
|
|
1439
|
+
const fromKey = from && dayKey(dayOf(from, timeZone));
|
|
1440
|
+
const toKey = to && dayKey(dayOf(to, timeZone));
|
|
1394
1441
|
const paddingDays = Array.from({ length: firstDayOfMonth }, (_, _i) => null);
|
|
1395
|
-
const hasSelection =
|
|
1442
|
+
const hasSelection = from || to;
|
|
1396
1443
|
const MONTHS = [
|
|
1397
1444
|
"January",
|
|
1398
1445
|
"February",
|
|
@@ -1409,11 +1456,8 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
|
|
|
1409
1456
|
];
|
|
1410
1457
|
const DAY_HEADERS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
1411
1458
|
const formatDate = (date) => {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
month: "2-digit",
|
|
1415
|
-
day: "2-digit"
|
|
1416
|
-
});
|
|
1459
|
+
const { year, month, day } = dayOf(date, timeZone);
|
|
1460
|
+
return `${String(month + 1).padStart(2, "0")}/${String(day).padStart(2, "0")}/${year}`;
|
|
1417
1461
|
};
|
|
1418
1462
|
const formatRange = (range) => {
|
|
1419
1463
|
if (!range.from && !range.to) return "Select Date Range";
|
|
@@ -1421,15 +1465,9 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
|
|
|
1421
1465
|
if (!range.from) return `Until ${formatDate(range.to)}`;
|
|
1422
1466
|
return `${formatDate(range.from)} - ${formatDate(range.to)}`;
|
|
1423
1467
|
};
|
|
1424
|
-
const isDateSelected = (day
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
return !!matchesFrom || !!matchesTo;
|
|
1428
|
-
};
|
|
1429
|
-
const checkIsToday = (day) => {
|
|
1430
|
-
const today = /* @__PURE__ */ new Date();
|
|
1431
|
-
return day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear();
|
|
1432
|
-
};
|
|
1468
|
+
const isDateSelected = (day) => dayKey(day) === fromKey || dayKey(day) === toKey;
|
|
1469
|
+
const todayKey = dayKey(today);
|
|
1470
|
+
const checkIsToday = (day) => dayKey(day) === todayKey;
|
|
1433
1471
|
const goToPreviousMonth = () => {
|
|
1434
1472
|
if (displayedMonth === 0) {
|
|
1435
1473
|
setDisplayedMonth(11);
|
|
@@ -1446,34 +1484,23 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
|
|
|
1446
1484
|
setDisplayedMonth(displayedMonth + 1);
|
|
1447
1485
|
}
|
|
1448
1486
|
};
|
|
1449
|
-
const isInRange = (
|
|
1450
|
-
if (
|
|
1451
|
-
return
|
|
1487
|
+
const isInRange = (day) => {
|
|
1488
|
+
if (fromKey === void 0 || toKey === void 0) return false;
|
|
1489
|
+
return dayKey(day) >= fromKey && dayKey(day) <= toKey;
|
|
1452
1490
|
};
|
|
1453
|
-
const handleDateSelect = (
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
d.setHours(0, 0, 0, 0);
|
|
1457
|
-
return d;
|
|
1458
|
-
};
|
|
1459
|
-
const endOfDay = (date) => {
|
|
1460
|
-
const d = new Date(date);
|
|
1461
|
-
d.setHours(23, 59, 59, 999);
|
|
1462
|
-
return d;
|
|
1463
|
-
};
|
|
1464
|
-
if (!selecting || !dateRange) {
|
|
1465
|
-
onSelect({ from: startOfDay(selectedDate), to: void 0 });
|
|
1491
|
+
const handleDateSelect = (selectedDay) => {
|
|
1492
|
+
if (!selecting || !from) {
|
|
1493
|
+
onSelect({ from: startOfDay(selectedDay, timeZone), to: void 0 });
|
|
1466
1494
|
setSelecting("to");
|
|
1467
1495
|
return;
|
|
1468
1496
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1475
|
-
setSelecting(null);
|
|
1497
|
+
const fromDay = dayOf(from, timeZone);
|
|
1498
|
+
if (dayKey(selectedDay) < dayKey(fromDay)) {
|
|
1499
|
+
onSelect({ from: startOfDay(selectedDay, timeZone), to: endOfDay(fromDay, timeZone) });
|
|
1500
|
+
} else {
|
|
1501
|
+
onSelect({ from: startOfDay(fromDay, timeZone), to: endOfDay(selectedDay, timeZone) });
|
|
1476
1502
|
}
|
|
1503
|
+
setSelecting(null);
|
|
1477
1504
|
};
|
|
1478
1505
|
const clearSelection = () => {
|
|
1479
1506
|
onSelect({ from: void 0, to: void 0 });
|
|
@@ -1499,7 +1526,7 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
|
|
|
1499
1526
|
}
|
|
1500
1527
|
),
|
|
1501
1528
|
className,
|
|
1502
|
-
children: /* @__PURE__ */ jsx("span", { className: styles20["date-range"], children: formatRange(
|
|
1529
|
+
children: /* @__PURE__ */ jsx("span", { className: styles20["date-range"], children: formatRange({ from, to }) })
|
|
1503
1530
|
}
|
|
1504
1531
|
) }) }),
|
|
1505
1532
|
/* @__PURE__ */ jsxs(PopoverContent, { className: styles20["popover-content"], align: "end", children: [
|
|
@@ -1533,7 +1560,7 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
|
|
|
1533
1560
|
/* @__PURE__ */ jsxs("div", { className: styles20["calendar-grid"], children: [
|
|
1534
1561
|
paddingDays.map((_, index) => /* @__PURE__ */ jsx("div", {}, `padding-${index}`)),
|
|
1535
1562
|
days.map((day, index) => {
|
|
1536
|
-
const isSelected = isDateSelected(day
|
|
1563
|
+
const isSelected = isDateSelected(day);
|
|
1537
1564
|
const isToday = checkIsToday(day);
|
|
1538
1565
|
const inRange = isInRange(day);
|
|
1539
1566
|
return /* @__PURE__ */ jsx(
|
|
@@ -1546,8 +1573,9 @@ var DateRangePicker = ({ dateRange, onSelect, className }) => {
|
|
|
1546
1573
|
isToday && !isSelected && styles20["calendar-day-btn--today"],
|
|
1547
1574
|
inRange && !isSelected && styles20["calendar-day-btn--in-range"]
|
|
1548
1575
|
),
|
|
1576
|
+
"aria-current": isToday ? "date" : void 0,
|
|
1549
1577
|
onClick: () => handleDateSelect(day),
|
|
1550
|
-
children: day.
|
|
1578
|
+
children: day.day
|
|
1551
1579
|
},
|
|
1552
1580
|
index
|
|
1553
1581
|
);
|