strata-react 2.1.22 → 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 +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/UPGRADING.md
CHANGED
|
@@ -11,6 +11,10 @@ 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
|
+
|
|
14
18
|
## 2026-12-01 (ButtonLink and TextLink `href` under a router basename)
|
|
15
19
|
|
|
16
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.
|
package/dist/index.d.ts
CHANGED
|
@@ -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`,
|
|
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
|
@@ -26133,8 +26133,8 @@ function TurnArrow({ facing, turn, label, className }) {
|
|
|
26133
26133
|
}
|
|
26134
26134
|
|
|
26135
26135
|
// src/components/partial-date-field.tsx
|
|
26136
|
-
const PARTIAL_DATE_RE = /^(\d{4})(
|
|
26137
|
-
/** Parse and validate a partial ISO date (`YYYY`, `YYYY-MM`,
|
|
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. */
|
|
26138
26138
|
function parsePartialDate(raw, circa = false) {
|
|
26139
26139
|
const trimmed = raw.trim();
|
|
26140
26140
|
if (!trimmed) return {
|
|
@@ -26144,36 +26144,42 @@ function parsePartialDate(raw, circa = false) {
|
|
|
26144
26144
|
const m = PARTIAL_DATE_RE.exec(trimmed);
|
|
26145
26145
|
if (!m) return {
|
|
26146
26146
|
ok: false,
|
|
26147
|
-
error: "Use YYYY, YYYY-MM
|
|
26147
|
+
error: "Use YYYY, YYYY-MM, YYYY-MM-DD or YYYYMMDD (for example 1985 or 1985-06-15)."
|
|
26148
26148
|
};
|
|
26149
|
-
const
|
|
26149
|
+
const yearStr = m[1];
|
|
26150
|
+
const monthStr = m[3] ?? m[5];
|
|
26151
|
+
const dayStr = m[4] ?? m[6];
|
|
26152
|
+
const year = Number(yearStr);
|
|
26150
26153
|
if (year < 1 || year > 9999) return {
|
|
26151
26154
|
ok: false,
|
|
26152
26155
|
error: "Enter a four-digit year between 0001 and 9999."
|
|
26153
26156
|
};
|
|
26157
|
+
let canonical = yearStr;
|
|
26154
26158
|
let inferred = "year";
|
|
26155
|
-
if (
|
|
26156
|
-
const month = Number(
|
|
26159
|
+
if (monthStr !== void 0) {
|
|
26160
|
+
const month = Number(monthStr);
|
|
26157
26161
|
if (month < 1 || month > 12) return {
|
|
26158
26162
|
ok: false,
|
|
26159
26163
|
error: "Month must be between 01 and 12."
|
|
26160
26164
|
};
|
|
26165
|
+
canonical = `${yearStr}-${monthStr}`;
|
|
26161
26166
|
inferred = "month";
|
|
26162
|
-
if (
|
|
26163
|
-
const day = Number(
|
|
26167
|
+
if (dayStr !== void 0) {
|
|
26168
|
+
const day = Number(dayStr);
|
|
26164
26169
|
const check = /* @__PURE__ */ new Date(0);
|
|
26165
26170
|
check.setUTCFullYear(year, month - 1, day);
|
|
26166
26171
|
if (check.getUTCFullYear() !== year || check.getUTCMonth() !== month - 1 || check.getUTCDate() !== day) return {
|
|
26167
26172
|
ok: false,
|
|
26168
|
-
error: `${
|
|
26173
|
+
error: `${canonical}-${dayStr} is not a valid calendar date.`
|
|
26169
26174
|
};
|
|
26175
|
+
canonical = `${canonical}-${dayStr}`;
|
|
26170
26176
|
inferred = "day";
|
|
26171
26177
|
}
|
|
26172
26178
|
}
|
|
26173
26179
|
return {
|
|
26174
26180
|
ok: true,
|
|
26175
26181
|
value: {
|
|
26176
|
-
date:
|
|
26182
|
+
date: canonical,
|
|
26177
26183
|
precision: circa ? "circa" : inferred
|
|
26178
26184
|
}
|
|
26179
26185
|
};
|
|
@@ -26188,7 +26194,16 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
|
|
|
26188
26194
|
const { report } = useFieldControl();
|
|
26189
26195
|
const [draft, setDraft] = React.useState(value?.date ?? "");
|
|
26190
26196
|
const [circa, setCirca] = React.useState(value?.precision === "circa");
|
|
26197
|
+
const lastCommitted = React.useRef({
|
|
26198
|
+
date: value?.date,
|
|
26199
|
+
precision: value?.precision
|
|
26200
|
+
});
|
|
26191
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
|
+
};
|
|
26192
26207
|
setDraft(value?.date ?? "");
|
|
26193
26208
|
setCirca(value?.precision === "circa");
|
|
26194
26209
|
report(void 0);
|
|
@@ -26197,10 +26212,15 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
|
|
|
26197
26212
|
value?.precision,
|
|
26198
26213
|
report
|
|
26199
26214
|
]);
|
|
26200
|
-
const commit = (nextDraft, nextCirca, showError) => {
|
|
26215
|
+
const commit = (nextDraft, nextCirca, showError, normalizeDraft = false) => {
|
|
26201
26216
|
const parsed = parsePartialDate(nextDraft, allowCirca && nextCirca);
|
|
26202
26217
|
if (parsed.ok) {
|
|
26203
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 ?? "");
|
|
26204
26224
|
onChange(parsed.value);
|
|
26205
26225
|
} else if (showError) report(parsed.error);
|
|
26206
26226
|
};
|
|
@@ -26216,7 +26236,7 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
|
|
|
26216
26236
|
setDraft(next);
|
|
26217
26237
|
commit(next, circa, false);
|
|
26218
26238
|
},
|
|
26219
|
-
onBlur: () => commit(draft, circa, true)
|
|
26239
|
+
onBlur: () => commit(draft, circa, true, true)
|
|
26220
26240
|
}), allowCirca && /* @__PURE__ */ jsx(Checkbox, {
|
|
26221
26241
|
label: circaLabel,
|
|
26222
26242
|
checked: circa,
|