@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.
@@ -23,6 +23,17 @@
23
23
  }
24
24
  cursor: default;
25
25
  }
26
+ .visually-hidden {
27
+ position: absolute;
28
+ width: 1px;
29
+ height: 1px;
30
+ padding: 0;
31
+ margin: -1px;
32
+ overflow: hidden;
33
+ clip-path: inset(50%);
34
+ white-space: nowrap;
35
+ border-width: 0;
36
+ }
26
37
  @property --tw-ordinal {
27
38
  syntax: "*";
28
39
  inherits: false;
package/dist/index.cjs CHANGED
@@ -3827,17 +3827,21 @@ function measureSpan(spanMs) {
3827
3827
  }
3828
3828
  return { value, unit };
3829
3829
  }
3830
- function formatDirected(date, now, mode, locale) {
3831
- const spanMs = mode === "until" ? date.getTime() - now.getTime() : now.getTime() - date.getTime();
3830
+ function formatCountdown(date, now, locale) {
3831
+ const spanMs = date.getTime() - now.getTime();
3832
3832
  if (spanMs <= 0) return null;
3833
- if (mode === "since" && spanMs < JUST_NOW_MS) return "Just now";
3834
3833
  const { value, unit } = measureSpan(spanMs);
3835
- if (mode === "until") {
3836
- return new Intl.NumberFormat(locale, { style: "unit", unit, unitDisplay: "long" }).format(
3837
- value
3838
- );
3839
- }
3840
- return new Intl.RelativeTimeFormat(locale, { numeric: "always" }).format(-value, unit);
3834
+ return new Intl.NumberFormat(locale, { style: "unit", unit, unitDisplay: "long" }).format(value);
3835
+ }
3836
+ function DatePlaceholder({
3837
+ label,
3838
+ className,
3839
+ ...props
3840
+ }) {
3841
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn(styles57__default.default["format-date"], className), ...props, children: [
3842
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles57__default.default["visually-hidden"], children: label }),
3843
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: NO_DATE_PLACEHOLDER })
3844
+ ] });
3841
3845
  }
3842
3846
  function FormatDate({
3843
3847
  date,
@@ -3862,7 +3866,7 @@ function FormatDate({
3862
3866
  return () => clearInterval(id);
3863
3867
  }, [isAbsolute, live]);
3864
3868
  if (missing) {
3865
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(styles57__default.default["format-date"], className), "aria-label": "No date", ...props, children: NO_DATE_PLACEHOLDER });
3869
+ return /* @__PURE__ */ jsxRuntime.jsx(DatePlaceholder, { label: "No date", className, ...props });
3866
3870
  }
3867
3871
  if (!parsed) {
3868
3872
  return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(styles57__default.default["format-date"], className), ...props, children: "Invalid date" });
@@ -3877,17 +3881,9 @@ function FormatDate({
3877
3881
  if (isAbsolute) {
3878
3882
  return /* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: machineValue, className: cn(styles57__default.default["format-date"], className), ...props, children: absolute });
3879
3883
  }
3880
- const measured = !mounted ? absolute : displayAs === "relative" ? formatRelative(parsed, now, locale) : formatDirected(parsed, now, displayAs, locale);
3884
+ const measured = !mounted ? absolute : displayAs === "relative" ? formatRelative(parsed, now, locale) : formatCountdown(parsed, now, locale);
3881
3885
  if (measured === null) {
3882
- return /* @__PURE__ */ jsxRuntime.jsx(
3883
- "span",
3884
- {
3885
- className: cn(styles57__default.default["format-date"], className),
3886
- "aria-label": displayAs === "until" ? "Date has passed" : "Date not yet reached",
3887
- ...props,
3888
- children: NO_DATE_PLACEHOLDER
3889
- }
3890
- );
3886
+ return /* @__PURE__ */ jsxRuntime.jsx(DatePlaceholder, { label: "Date has passed", className, ...props });
3891
3887
  }
3892
3888
  if (!tooltip) {
3893
3889
  return /* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: machineValue, className: cn(styles57__default.default["format-date"], className), ...props, children: measured });