From 62fcc53f5c322a37038b03592e51465edccfb162 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 13 Jun 2026 22:33:50 +0200 Subject: [PATCH] refactor(shared): extract DatePrecisionField primitive from WhoWhenSection Pulls the date + precision + RANGE-end-date region into a generic primitive in $lib/shared/primitives/ so both document/ (WhoWhenSection) and timeline/ (EventForm, #781) can consume it without a cross-domain import. Preserves the aria-live="polite" outer wrapper, onMount one-time seeding, $bindable precision/endDateIso, the PRECISIONS array, and forwards data-testid attributes so the existing WhoWhenSection spec selectors survive. WhoWhenSection spec stays green (7/7). Refs #781 Co-Authored-By: Claude Opus 4.8 --- .../src/lib/document/WhoWhenSection.svelte | 150 ++------------ .../primitives/DatePrecisionField.svelte | 191 ++++++++++++++++++ 2 files changed, 208 insertions(+), 133 deletions(-) create mode 100644 frontend/src/lib/shared/primitives/DatePrecisionField.svelte diff --git a/frontend/src/lib/document/WhoWhenSection.svelte b/frontend/src/lib/document/WhoWhenSection.svelte index 4912f8d7..393705cd 100644 --- a/frontend/src/lib/document/WhoWhenSection.svelte +++ b/frontend/src/lib/document/WhoWhenSection.svelte @@ -1,9 +1,8 @@
@@ -104,79 +45,22 @@ $effect(() => {
{#if !hideDate} - -
- - - - {#if dateInvalid} -

{m.form_date_error()}

- {/if} -
- -
- - -
- - -
- {#if showEndDate} -
- - - {#if endBeforeStart} - -

- {m.error_invalid_date_range()} -

- {/if} -
- {/if} -
- + + {/if} diff --git a/frontend/src/lib/shared/primitives/DatePrecisionField.svelte b/frontend/src/lib/shared/primitives/DatePrecisionField.svelte new file mode 100644 index 00000000..36403ac4 --- /dev/null +++ b/frontend/src/lib/shared/primitives/DatePrecisionField.svelte @@ -0,0 +1,191 @@ + + + +
+ + + + {#if dateInvalid} +

+ {m.form_date_error()} +

+ {/if} +
+ + +
+ + +
+ + +
+ {#if showEndDate} +
+ + + {#if endBeforeStart} + +

+ {m.error_invalid_date_range()} +

+ {/if} +
+ {/if} +
+ +