@eqtylab/equality 3.9.1 → 4.0.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/dist/format-date.module.module.css.module.css +11 -0
- package/dist/index.cjs +16 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +16 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -838,7 +838,7 @@ declare const Tabs: ({ id, items, className, tabsListBackground, defaultValue, o
|
|
|
838
838
|
|
|
839
839
|
declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React$1.RefAttributes<HTMLTextAreaElement>>;
|
|
840
840
|
|
|
841
|
-
type FormatDateDisplayMode = 'relative' | 'absolute' | '
|
|
841
|
+
type FormatDateDisplayMode = 'relative' | 'absolute' | 'countdown';
|
|
842
842
|
interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElement>, 'dateTime' | 'children'> {
|
|
843
843
|
/** The date to display. Accepts an ISO 8601 string, epoch milliseconds, or a Date. A missing value (null, undefined, or empty string) renders a placeholder. */
|
|
844
844
|
date: string | number | Date | null | undefined;
|
|
@@ -846,8 +846,7 @@ interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElemen
|
|
|
846
846
|
* How to render the date:
|
|
847
847
|
* - `absolute` — the full date and time ("Jun 09 2026, 18:42:03 UTC")
|
|
848
848
|
* - `relative` — idiomatic distance from now, in either direction ("2 weeks ago", "next week")
|
|
849
|
-
* - `
|
|
850
|
-
* - `since` — exact time elapsed since a past date ("10 days ago"), a placeholder until it arrives
|
|
849
|
+
* - `countdown` — exact time left until a future date ("10 days"), a placeholder once it passes
|
|
851
850
|
*/
|
|
852
851
|
displayAs?: FormatDateDisplayMode;
|
|
853
852
|
/** Time zone used for absolute formatting. Defaults to "UTC". */
|
|
@@ -939,7 +938,7 @@ declare const TruncatedDescription: ({ className, description, maxLength, }: Tru
|
|
|
939
938
|
|
|
940
939
|
declare const iconVariants: (props?: ({
|
|
941
940
|
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
942
|
-
background?: "
|
|
941
|
+
background?: "circle" | "square" | "transparent" | null | undefined;
|
|
943
942
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
944
943
|
declare const iconElevationVariants: (props?: ({
|
|
945
944
|
elevation?: string | number | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -838,7 +838,7 @@ declare const Tabs: ({ id, items, className, tabsListBackground, defaultValue, o
|
|
|
838
838
|
|
|
839
839
|
declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React$1.RefAttributes<HTMLTextAreaElement>>;
|
|
840
840
|
|
|
841
|
-
type FormatDateDisplayMode = 'relative' | 'absolute' | '
|
|
841
|
+
type FormatDateDisplayMode = 'relative' | 'absolute' | 'countdown';
|
|
842
842
|
interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElement>, 'dateTime' | 'children'> {
|
|
843
843
|
/** The date to display. Accepts an ISO 8601 string, epoch milliseconds, or a Date. A missing value (null, undefined, or empty string) renders a placeholder. */
|
|
844
844
|
date: string | number | Date | null | undefined;
|
|
@@ -846,8 +846,7 @@ interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElemen
|
|
|
846
846
|
* How to render the date:
|
|
847
847
|
* - `absolute` — the full date and time ("Jun 09 2026, 18:42:03 UTC")
|
|
848
848
|
* - `relative` — idiomatic distance from now, in either direction ("2 weeks ago", "next week")
|
|
849
|
-
* - `
|
|
850
|
-
* - `since` — exact time elapsed since a past date ("10 days ago"), a placeholder until it arrives
|
|
849
|
+
* - `countdown` — exact time left until a future date ("10 days"), a placeholder once it passes
|
|
851
850
|
*/
|
|
852
851
|
displayAs?: FormatDateDisplayMode;
|
|
853
852
|
/** Time zone used for absolute formatting. Defaults to "UTC". */
|
|
@@ -939,7 +938,7 @@ declare const TruncatedDescription: ({ className, description, maxLength, }: Tru
|
|
|
939
938
|
|
|
940
939
|
declare const iconVariants: (props?: ({
|
|
941
940
|
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
942
|
-
background?: "
|
|
941
|
+
background?: "circle" | "square" | "transparent" | null | undefined;
|
|
943
942
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
944
943
|
declare const iconElevationVariants: (props?: ({
|
|
945
944
|
elevation?: string | number | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -3724,17 +3724,21 @@ function measureSpan(spanMs) {
|
|
|
3724
3724
|
}
|
|
3725
3725
|
return { value, unit };
|
|
3726
3726
|
}
|
|
3727
|
-
function
|
|
3728
|
-
const spanMs =
|
|
3727
|
+
function formatCountdown(date, now, locale) {
|
|
3728
|
+
const spanMs = date.getTime() - now.getTime();
|
|
3729
3729
|
if (spanMs <= 0) return null;
|
|
3730
|
-
if (mode === "since" && spanMs < JUST_NOW_MS) return "Just now";
|
|
3731
3730
|
const { value, unit } = measureSpan(spanMs);
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3731
|
+
return new Intl.NumberFormat(locale, { style: "unit", unit, unitDisplay: "long" }).format(value);
|
|
3732
|
+
}
|
|
3733
|
+
function DatePlaceholder({
|
|
3734
|
+
label,
|
|
3735
|
+
className,
|
|
3736
|
+
...props
|
|
3737
|
+
}) {
|
|
3738
|
+
return /* @__PURE__ */ jsxs("span", { className: cn(styles57["format-date"], className), ...props, children: [
|
|
3739
|
+
/* @__PURE__ */ jsx("span", { className: styles57["visually-hidden"], children: label }),
|
|
3740
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: NO_DATE_PLACEHOLDER })
|
|
3741
|
+
] });
|
|
3738
3742
|
}
|
|
3739
3743
|
function FormatDate({
|
|
3740
3744
|
date,
|
|
@@ -3759,7 +3763,7 @@ function FormatDate({
|
|
|
3759
3763
|
return () => clearInterval(id);
|
|
3760
3764
|
}, [isAbsolute, live]);
|
|
3761
3765
|
if (missing) {
|
|
3762
|
-
return /* @__PURE__ */ jsx(
|
|
3766
|
+
return /* @__PURE__ */ jsx(DatePlaceholder, { label: "No date", className, ...props });
|
|
3763
3767
|
}
|
|
3764
3768
|
if (!parsed) {
|
|
3765
3769
|
return /* @__PURE__ */ jsx("span", { className: cn(styles57["format-date"], className), ...props, children: "Invalid date" });
|
|
@@ -3774,17 +3778,9 @@ function FormatDate({
|
|
|
3774
3778
|
if (isAbsolute) {
|
|
3775
3779
|
return /* @__PURE__ */ jsx("time", { dateTime: machineValue, className: cn(styles57["format-date"], className), ...props, children: absolute });
|
|
3776
3780
|
}
|
|
3777
|
-
const measured = !mounted ? absolute : displayAs === "relative" ? formatRelative(parsed, now, locale) :
|
|
3781
|
+
const measured = !mounted ? absolute : displayAs === "relative" ? formatRelative(parsed, now, locale) : formatCountdown(parsed, now, locale);
|
|
3778
3782
|
if (measured === null) {
|
|
3779
|
-
return /* @__PURE__ */ jsx(
|
|
3780
|
-
"span",
|
|
3781
|
-
{
|
|
3782
|
-
className: cn(styles57["format-date"], className),
|
|
3783
|
-
"aria-label": displayAs === "until" ? "Date has passed" : "Date not yet reached",
|
|
3784
|
-
...props,
|
|
3785
|
-
children: NO_DATE_PLACEHOLDER
|
|
3786
|
-
}
|
|
3787
|
-
);
|
|
3783
|
+
return /* @__PURE__ */ jsx(DatePlaceholder, { label: "Date has passed", className, ...props });
|
|
3788
3784
|
}
|
|
3789
3785
|
if (!tooltip) {
|
|
3790
3786
|
return /* @__PURE__ */ jsx("time", { dateTime: machineValue, className: cn(styles57["format-date"], className), ...props, children: measured });
|