@eqtylab/equality 2.1.2 → 2.1.3
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/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -781,8 +781,8 @@ declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedH
|
|
|
781
781
|
|
|
782
782
|
type FormatDateDisplayMode = 'relative' | 'absolute';
|
|
783
783
|
interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElement>, 'dateTime' | 'children'> {
|
|
784
|
-
/** The date to display. Accepts an ISO 8601 string, epoch milliseconds, or a Date. */
|
|
785
|
-
date: string | number | Date;
|
|
784
|
+
/** 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. */
|
|
785
|
+
date: string | number | Date | null | undefined;
|
|
786
786
|
/** Render relative ("2 weeks ago") or absolute ("Jun 9 2026, 18:42:03 UTC") time. */
|
|
787
787
|
displayAs?: FormatDateDisplayMode;
|
|
788
788
|
/** Time zone used for absolute formatting. Defaults to "UTC". */
|
package/dist/index.d.ts
CHANGED
|
@@ -781,8 +781,8 @@ declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedH
|
|
|
781
781
|
|
|
782
782
|
type FormatDateDisplayMode = 'relative' | 'absolute';
|
|
783
783
|
interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElement>, 'dateTime' | 'children'> {
|
|
784
|
-
/** The date to display. Accepts an ISO 8601 string, epoch milliseconds, or a Date. */
|
|
785
|
-
date: string | number | Date;
|
|
784
|
+
/** 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. */
|
|
785
|
+
date: string | number | Date | null | undefined;
|
|
786
786
|
/** Render relative ("2 weeks ago") or absolute ("Jun 9 2026, 18:42:03 UTC") time. */
|
|
787
787
|
displayAs?: FormatDateDisplayMode;
|
|
788
788
|
/** Time zone used for absolute formatting. Defaults to "UTC". */
|
package/dist/index.js
CHANGED
|
@@ -3185,6 +3185,10 @@ var RELATIVE_DIVISIONS = [
|
|
|
3185
3185
|
{ amount: Number.POSITIVE_INFINITY, unit: "year" }
|
|
3186
3186
|
];
|
|
3187
3187
|
var LIVE_INTERVAL_MS = 3e4;
|
|
3188
|
+
var NO_DATE_PLACEHOLDER = "---";
|
|
3189
|
+
function isMissing(value) {
|
|
3190
|
+
return value == null || typeof value === "string" && value.trim() === "";
|
|
3191
|
+
}
|
|
3188
3192
|
function toDate(value) {
|
|
3189
3193
|
const date = value instanceof Date ? value : new Date(value);
|
|
3190
3194
|
return Number.isNaN(date.getTime()) ? null : date;
|
|
@@ -3215,7 +3219,8 @@ function FormatDate({
|
|
|
3215
3219
|
className,
|
|
3216
3220
|
...props
|
|
3217
3221
|
}) {
|
|
3218
|
-
const
|
|
3222
|
+
const missing = isMissing(date);
|
|
3223
|
+
const parsed = React16.useMemo(() => isMissing(date) ? null : toDate(date), [date]);
|
|
3219
3224
|
const [now, setNow] = React16.useState(() => /* @__PURE__ */ new Date());
|
|
3220
3225
|
const [mounted, setMounted] = React16.useState(false);
|
|
3221
3226
|
const isRelative = displayAs === "relative";
|
|
@@ -3225,8 +3230,11 @@ function FormatDate({
|
|
|
3225
3230
|
const id = setInterval(() => setNow(/* @__PURE__ */ new Date()), LIVE_INTERVAL_MS);
|
|
3226
3231
|
return () => clearInterval(id);
|
|
3227
3232
|
}, [isRelative, live]);
|
|
3233
|
+
if (missing) {
|
|
3234
|
+
return /* @__PURE__ */ jsx("span", { className: cn(styles56["format-date"], className), "aria-label": "No date", ...props, children: NO_DATE_PLACEHOLDER });
|
|
3235
|
+
}
|
|
3228
3236
|
if (!parsed) {
|
|
3229
|
-
return /* @__PURE__ */ jsx("
|
|
3237
|
+
return /* @__PURE__ */ jsx("span", { className: cn(styles56["format-date"], className), ...props, children: "Invalid date" });
|
|
3230
3238
|
}
|
|
3231
3239
|
const machineValue = parsed.toISOString();
|
|
3232
3240
|
const absolute = formatAbsolute(
|