strata-react 2.1.21 → 2.1.23

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/UPGRADING.md CHANGED
@@ -11,6 +11,14 @@ time. While the version is 0.x, any release may break.
11
11
 
12
12
  Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
13
13
 
14
+ ## 2026-12-01 (PartialDateField compact input)
15
+
16
+ - `parsePartialDate` and `PartialDateField` now accept compact dates without hyphens (`YYYYMM`, `YYYYMMDD`) and `/` or `.` separators (`YYYY/MM/DD`), canonicalizing valid values to hyphenated ISO (`YYYY-MM`, `YYYY-MM-DD`) and normalizing the input text on blur. The malformed-input error message now reads `"Use YYYY, YYYY-MM, YYYY-MM-DD or YYYYMMDD (for example 1985 or 1985-06-15)."` (update any tests asserting the previous wording).
17
+
18
+ ## 2026-12-01 (ButtonLink and TextLink `href` under a router basename)
19
+
20
+ - `ButtonLink` and `TextLink` with `href` (downloads, files, external URLs) no longer pass through React Router's `RouterProvider`/`useHref`, so their `href` is rendered verbatim instead of having the router `basename` prepended. Pass `api.url(...)` (or an already base-prefixed URL) for server paths behind a reverse proxy; `to` links continue to prepend `basename` through React Router.
21
+
14
22
  ## 2026-12-01 (PartialDateField)
15
23
 
16
24
  - `PartialDateField` no longer sets `inputMode="numeric"` on its text input, so touch keyboards expose `-` for `YYYY-MM` and `YYYY-MM-DD` entry. `parsePartialDate` now accepts full calendar dates in years `0001`–`0099` (previously rejected due to `Date.UTC` mapping them to `1901`–`1999`).
package/dist/index.d.ts CHANGED
@@ -4441,11 +4441,11 @@ type TextLinkProps = BaseProps & Target & {
4441
4441
  /**
4442
4442
  * A link drawn as a `Button` (React Router `to`, or `href` for a download or another site): the same variants and heights, `variant="default"` is the filled one and counts for the one-filled-button rule (`data-variant` is set).
4443
4443
  */
4444
- export declare function ButtonLink(all: ButtonLinkProps): React.JSX.Element;
4444
+ export declare function ButtonLink(all: ButtonLinkProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
4445
4445
  /**
4446
4446
  * The house in-app link: accent ink, underlined, for a sentence, a table cell or an empty state's next step. `to` for a route, `href` for a file or another site.
4447
4447
  */
4448
- export declare function TextLink(all: TextLinkProps): React.JSX.Element;
4448
+ export declare function TextLink(all: TextLinkProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
4449
4449
  /** The caller's zoom and pan, and how to change them. */
4450
4450
  type ViewportState = {
4451
4451
  viewport: Viewport;
@@ -6387,7 +6387,7 @@ type PartialDateParseResult = {
6387
6387
  ok: false;
6388
6388
  error: string;
6389
6389
  };
6390
- /** Parse and validate a partial ISO date (`YYYY`, `YYYY-MM`, or `YYYY-MM-DD`), checking calendar month and day limits. */
6390
+ /** Parse and validate a partial ISO date (`YYYY`, `YYYY-MM`, `YYYY-MM-DD`, or compact `YYYYMM`/`YYYYMMDD`), checking calendar month and day limits and returning canonical hyphenated ISO format. */
6391
6391
  export declare function parsePartialDate(raw: string, circa?: boolean): PartialDateParseResult;
6392
6392
  /** Format a partial date for display (prefixes `circa` dates with `c. `). */
6393
6393
  export declare function formatPartialDate(value: PartialDateValue): string;
package/dist/index.js CHANGED
@@ -4829,12 +4829,13 @@ function releaseSound(el) {
4829
4829
  // src/components/link.tsx
4830
4830
  function useTarget(target, newTab, state) {
4831
4831
  const navigate = useNavigate();
4832
+ const isRoute = target.to !== void 0;
4832
4833
  return {
4833
- provide: (node) => /* @__PURE__ */ jsx(RouterProvider, {
4834
+ provide: (node) => isRoute ? /* @__PURE__ */ jsx(RouterProvider, {
4834
4835
  navigate: (to) => void navigate(to, state === void 0 ? void 0 : { state }),
4835
4836
  useHref,
4836
4837
  children: node
4837
- }),
4838
+ }) : node,
4838
4839
  props: {
4839
4840
  href: target.to ?? target.href,
4840
4841
  download: target.href === void 0 ? void 0 : target.download,
@@ -26132,8 +26133,8 @@ function TurnArrow({ facing, turn, label, className }) {
26132
26133
  }
26133
26134
 
26134
26135
  // src/components/partial-date-field.tsx
26135
- const PARTIAL_DATE_RE = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;
26136
- /** Parse and validate a partial ISO date (`YYYY`, `YYYY-MM`, or `YYYY-MM-DD`), checking calendar month and day limits. */
26136
+ const PARTIAL_DATE_RE = /^(\d{4})(?:([-/.])(\d{2})(?:\2(\d{2}))?|(\d{2})(\d{2})?)?$/;
26137
+ /** Parse and validate a partial ISO date (`YYYY`, `YYYY-MM`, `YYYY-MM-DD`, or compact `YYYYMM`/`YYYYMMDD`), checking calendar month and day limits and returning canonical hyphenated ISO format. */
26137
26138
  function parsePartialDate(raw, circa = false) {
26138
26139
  const trimmed = raw.trim();
26139
26140
  if (!trimmed) return {
@@ -26143,36 +26144,42 @@ function parsePartialDate(raw, circa = false) {
26143
26144
  const m = PARTIAL_DATE_RE.exec(trimmed);
26144
26145
  if (!m) return {
26145
26146
  ok: false,
26146
- error: "Use YYYY, YYYY-MM or YYYY-MM-DD (for example 1985 or 1985-06-15)."
26147
+ error: "Use YYYY, YYYY-MM, YYYY-MM-DD or YYYYMMDD (for example 1985 or 1985-06-15)."
26147
26148
  };
26148
- const year = Number(m[1]);
26149
+ const yearStr = m[1];
26150
+ const monthStr = m[3] ?? m[5];
26151
+ const dayStr = m[4] ?? m[6];
26152
+ const year = Number(yearStr);
26149
26153
  if (year < 1 || year > 9999) return {
26150
26154
  ok: false,
26151
26155
  error: "Enter a four-digit year between 0001 and 9999."
26152
26156
  };
26157
+ let canonical = yearStr;
26153
26158
  let inferred = "year";
26154
- if (m[2] !== void 0) {
26155
- const month = Number(m[2]);
26159
+ if (monthStr !== void 0) {
26160
+ const month = Number(monthStr);
26156
26161
  if (month < 1 || month > 12) return {
26157
26162
  ok: false,
26158
26163
  error: "Month must be between 01 and 12."
26159
26164
  };
26165
+ canonical = `${yearStr}-${monthStr}`;
26160
26166
  inferred = "month";
26161
- if (m[3] !== void 0) {
26162
- const day = Number(m[3]);
26167
+ if (dayStr !== void 0) {
26168
+ const day = Number(dayStr);
26163
26169
  const check = /* @__PURE__ */ new Date(0);
26164
26170
  check.setUTCFullYear(year, month - 1, day);
26165
26171
  if (check.getUTCFullYear() !== year || check.getUTCMonth() !== month - 1 || check.getUTCDate() !== day) return {
26166
26172
  ok: false,
26167
- error: `${trimmed} is not a valid calendar date.`
26173
+ error: `${canonical}-${dayStr} is not a valid calendar date.`
26168
26174
  };
26175
+ canonical = `${canonical}-${dayStr}`;
26169
26176
  inferred = "day";
26170
26177
  }
26171
26178
  }
26172
26179
  return {
26173
26180
  ok: true,
26174
26181
  value: {
26175
- date: trimmed,
26182
+ date: canonical,
26176
26183
  precision: circa ? "circa" : inferred
26177
26184
  }
26178
26185
  };
@@ -26187,7 +26194,16 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
26187
26194
  const { report } = useFieldControl();
26188
26195
  const [draft, setDraft] = React.useState(value?.date ?? "");
26189
26196
  const [circa, setCirca] = React.useState(value?.precision === "circa");
26197
+ const lastCommitted = React.useRef({
26198
+ date: value?.date,
26199
+ precision: value?.precision
26200
+ });
26190
26201
  React.useEffect(() => {
26202
+ if (value?.date === lastCommitted.current.date && value?.precision === lastCommitted.current.precision) return;
26203
+ lastCommitted.current = {
26204
+ date: value?.date,
26205
+ precision: value?.precision
26206
+ };
26191
26207
  setDraft(value?.date ?? "");
26192
26208
  setCirca(value?.precision === "circa");
26193
26209
  report(void 0);
@@ -26196,10 +26212,15 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
26196
26212
  value?.precision,
26197
26213
  report
26198
26214
  ]);
26199
- const commit = (nextDraft, nextCirca, showError) => {
26215
+ const commit = (nextDraft, nextCirca, showError, normalizeDraft = false) => {
26200
26216
  const parsed = parsePartialDate(nextDraft, allowCirca && nextCirca);
26201
26217
  if (parsed.ok) {
26202
26218
  report(void 0);
26219
+ lastCommitted.current = {
26220
+ date: parsed.value?.date,
26221
+ precision: parsed.value?.precision
26222
+ };
26223
+ if (normalizeDraft) setDraft(parsed.value?.date ?? "");
26203
26224
  onChange(parsed.value);
26204
26225
  } else if (showError) report(parsed.error);
26205
26226
  };
@@ -26215,7 +26236,7 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
26215
26236
  setDraft(next);
26216
26237
  commit(next, circa, false);
26217
26238
  },
26218
- onBlur: () => commit(draft, circa, true)
26239
+ onBlur: () => commit(draft, circa, true, true)
26219
26240
  }), allowCirca && /* @__PURE__ */ jsx(Checkbox, {
26220
26241
  label: circaLabel,
26221
26242
  checked: circa,