|
|
|
|
// @vitest-environment jsdom
|
|
|
|
|
|
|
|
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
|
|
|
|
|
|
import { createActiveDom } from '$adom';
|
|
|
|
|
import { CalendarDate } from '$libs/days';
|
|
|
|
|
import type {
|
|
|
|
|
DateMatcher,
|
|
|
|
|
DateOnInvalid,
|
|
|
|
|
DateRange,
|
|
|
|
|
DateRangeValidator,
|
|
|
|
|
DateValue,
|
|
|
|
|
EditableSegmentPart,
|
|
|
|
|
Granularity,
|
|
|
|
|
HourCycle,
|
|
|
|
|
WeekStartsOn
|
|
|
|
|
} from '$libs/days';
|
|
|
|
|
import { state } from '$libs/reactive';
|
|
|
|
|
import type { Morfo } from '$uix/morfo';
|
|
|
|
|
import { Soma } from '$soma/core/soma.svelte';
|
|
|
|
|
import { createSomaRuntime, type SomaRuntimeSources } from '$soma/runtime.svelte';
|
|
|
|
|
import type { Direction, OnChangeFn } from '../../types';
|
|
|
|
|
|
|
|
|
|
import { DateRangePickerProvider } from './date-range-picker-provider.svelte';
|
|
|
|
|
|
|
|
|
|
function withEffectRoot<T>(fn: () => T): { result: T; cleanup: () => void } {
|
|
|
|
|
let result!: T;
|
|
|
|
|
const cleanup = $effect.root(() => {
|
|
|
|
|
result = fn();
|
|
|
|
|
});
|
|
|
|
|
return { result, cleanup };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function installSomaHarness() {
|
|
|
|
|
const dom = createActiveDom();
|
|
|
|
|
const soma = {
|
|
|
|
|
dom,
|
|
|
|
|
langs: {
|
|
|
|
|
getLocale: () => 'en-US',
|
|
|
|
|
ts: (key: string) => key
|
|
|
|
|
},
|
|
|
|
|
runtime: (morfo: Morfo, sources: Omit<SomaRuntimeSources, 'dom' | 'eventEngine'>) =>
|
|
|
|
|
createSomaRuntime(morfo, {
|
|
|
|
|
dom,
|
|
|
|
|
translate: (key) => key,
|
|
|
|
|
...sources
|
|
|
|
|
})
|
|
|
|
|
} as unknown as Soma;
|
|
|
|
|
|
|
|
|
|
vi.spyOn(Soma, 'require').mockReturnValue(soma);
|
|
|
|
|
vi.spyOn(DateRangePickerProvider.ctx, 'set').mockImplementation((value) => value);
|
|
|
|
|
|
|
|
|
|
return { dom };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createDateRangePickerOpts() {
|
|
|
|
|
const placeholder = new CalendarDate(2026, 5, 15);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: state('date-range-picker-root'),
|
|
|
|
|
ref: state<HTMLElement | null>(null),
|
|
|
|
|
value: state<DateRange>({ start: undefined, end: undefined }),
|
|
|
|
|
placeholder: state<DateValue>(placeholder),
|
|
|
|
|
startValue: state<DateValue | undefined>(undefined),
|
|
|
|
|
endValue: state<DateValue | undefined>(undefined),
|
|
|
|
|
open: state(true),
|
|
|
|
|
validate: state<DateRangeValidator | undefined>(undefined),
|
|
|
|
|
onInvalid: state<DateOnInvalid | undefined>(undefined),
|
|
|
|
|
minValue: state<DateValue | undefined>(undefined),
|
|
|
|
|
maxValue: state<DateValue | undefined>(undefined),
|
|
|
|
|
minDays: state<number | undefined>(undefined),
|
|
|
|
|
maxDays: state<number | undefined>(undefined),
|
|
|
|
|
allowSingleDay: state(true),
|
|
|
|
|
isDateDisabled: state<DateMatcher | undefined>(undefined),
|
|
|
|
|
isDateUnavailable: state<DateMatcher | undefined>(undefined),
|
|
|
|
|
isDateHoliday: state<DateMatcher | undefined>(undefined),
|
|
|
|
|
disabled: state(false),
|
|
|
|
|
readonly: state(false),
|
|
|
|
|
startReadonlySegments: state<EditableSegmentPart[]>([]),
|
|
|
|
|
endReadonlySegments: state<EditableSegmentPart[]>([]),
|
|
|
|
|
required: state(false),
|
|
|
|
|
closeOnRangeSelect: state(true),
|
date-range-picker: mode prop + footer button props + revert group chrome
User feedback batch from incidencia 2026-05-20:
1. Modal vs inline mode
- New `mode: 'inline' | 'modal'` prop on the soma `DateRangePicker.Provider`.
- Modal wires the popover `modal: true` → outside-click and Escape are
ignored; user must commit via the footer Close button (or revert via
Cancel).
- Provider exposes helpers `clear()`, `cancel()`, `commit()` for the
footer. `cancel()` restores the value snapshot taken on the OPEN edge
(captured via a `watch` on `opts.open` true-edge transition).
2. Footer buttons as boolean props
- `clearButton`, `cancelButton`, `closeButton` props on the picker.
The footer renders only if at least one is true. In `mode='modal'`
the closeButton is forced on (the user always needs an exit).
- `picker-actions.svelte` in the demo reads the picker context via
`DateRangePickerProvider.require()` and renders the enabled buttons
against `provider.clear/cancel/commit`.
3. Range field shape (revert to Chakra-style two boxes)
- Removed the `data-date-range-field-group` wrapper from the demo so
the start and end inputs are rendered as two separate boxed fields
with the icon embedded in the end box, matching Chakra's layout.
- The recipe CSS rules for `data-date-range-field-group` stay
available as an opt-in for consumers who prefer the unified pill.
4. Demo defaults
- `open` starts at `false` so the picker exercises the real
open/close flow when the user clicks the trigger — the segments are
for direct keyboard entry, the popover is for visual exploration.
- Mode toggle (inline / modal) + footer button switches surfaced as
controls in the demo.
5. Plumbing
- DateRangePickerOpts gains `mode`, `clearButton`, `cancelButton`,
`closeButton` (StateProps for mode, ActiveProps for the booleans).
- `DateRangePickerProvider` and `DateRangePickerMode` are now re-
exported from the soma barrel for consumers that wire footer
actions in the calendar tree.
- Test factory updated to seed the new opts.
Verified in browser: trigger opens; click-outside in modal mode is
ignored; Close commits & closes; Cancel reverts to snapshot & closes;
Clear empties the range & keeps open. Heading "May – June 2026" (year
collapse) and centered per-calendar titles still working from the
previous commit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
|
|
|
mode: state<'inline' | 'modal'>('inline'),
|
|
|
|
|
kind: state<'date' | 'month' | 'year'>('date'),
|
|
|
|
|
granularity: state<Granularity | undefined>(undefined),
|
|
|
|
|
hideTimeZone: state(false),
|
|
|
|
|
hourCycle: state<HourCycle | undefined>(undefined),
|
|
|
|
|
locale: state<string | undefined>('en-US'),
|
|
|
|
|
dir: state<Direction>('ltr'),
|
|
|
|
|
pagedNavigation: state(false),
|
|
|
|
|
weekStartsOn: state<WeekStartsOn | undefined>(undefined),
|
|
|
|
|
weekdayFormat: state<Intl.DateTimeFormatOptions['weekday']>('narrow'),
|
|
|
|
|
fixedWeeks: state(false),
|
|
|
|
|
numberOfMonths: state(1),
|
|
|
|
|
calendarLabel: state<string | undefined>(undefined),
|
|
|
|
|
disableDaysOutsideMonth: state(false),
|
|
|
|
|
preventDeselect: state(false),
|
|
|
|
|
initialFocus: state(false),
|
|
|
|
|
monthFormat: state<Intl.DateTimeFormatOptions['month'] | ((month: number) => string)>('long'),
|
|
|
|
|
yearFormat: state<Intl.DateTimeFormatOptions['year'] | ((year: number) => string)>('numeric'),
|
|
|
|
|
showWeekNumbers: state(false),
|
|
|
|
|
weekNumberFormat: state<'iso' | 'simple'>('iso'),
|
|
|
|
|
announceNavigation: state(true),
|
|
|
|
|
errorMessageId: state<string | undefined>(undefined),
|
|
|
|
|
onOpenChangeComplete: state<OnChangeFn<boolean>>(() => {})
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('DateRangePickerProvider', () => {
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
vi.restoreAllMocks();
|
|
|
|
|
document.body.innerHTML = '';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('registers the provider part through SomaRuntime', () => {
|
|
|
|
|
const { dom } = installSomaHarness();
|
|
|
|
|
const opts = createDateRangePickerOpts();
|
|
|
|
|
|
|
|
|
|
const { result: provider, cleanup } = withEffectRoot(() =>
|
|
|
|
|
DateRangePickerProvider.create(opts)
|
|
|
|
|
);
|
uix: date-picker + date-range-picker components + component audit infra
Two new Eidos components shipped end-to-end (wrapper + recipe + demo +
Soma provider hardening) plus a checklist-driven audit pipeline that
scores all 67 morfo components against doctrinal completion criteria.
New components:
- date-picker: full popover-anchored picker over date-field + calendar,
with calendar/content/trigger parts and demo route.
- date-range-picker: standalone wrapper with own calendar/grid/segment
surface, demo route, and recipe CSS.
- Both wrappers follow Option C disciplined (root + parts attached via
explicit assignment, no Object.assign).
Supporting Soma changes:
- range-calendar provider tightened (211 LOC of behavior, 167 LOC of
tests), README brought up to component doctrine.
- date-field, date-picker, date-range-field, date-range-picker Soma
providers + READMEs updated for new wrappers.
- popover provider/close gain props needed by the picker wrappers.
Morfo updates:
- date-picker / date-range-picker / range-calendar morfos refined for
the new APIs (parts, events, ARIA).
Audit infrastructure (new):
- src/uix/COMPONENT_COMPLETION_CHECKLIST.md — 81 doctrinal rules across
morfo / eidos wrapper / recipe CSS / demo / README / cross-layer
scripts. Each rule keyed to active_architecture.md, GUIA_IMPLEMENTACION
and DEMO_AUTHORING_GUIDE.
- scripts/component-audit.ts + `npm run component:audit` — regex parser
over all 67 components, emits tmp/component-audit.md with summary
scoreboard + per-component findings. Validates against canonical
SEMA_FAMILIES / SEMA_VERBS / ARCHETYPE_VOCABULARY / INTENTS.
- Initial baseline: 1 PASS, 64 NEEDS-WORK, 2 BROKEN (tooltip,
date-range-picker). Top systemic gaps: translations.label (49),
README Gaps/Comparativa/Baseline sections (87 combined), keyboard
/event ratio under-declaration (15), apg URL absent (19).
Misc:
- src/uix/kimi-audit-eidos.md — supplementary audit notes.
- .gitignore: ignore .codex-* agent scratch artifacts at repo root.
- continue.md + READMEs updated through the migration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
|
|
|
const props = provider.props as Record<string, unknown>;
|
|
|
|
|
|
|
|
|
|
expect(provider.runtimePart.props.id).toBe('date-range-picker-root');
|
uix: date-picker + date-range-picker components + component audit infra
Two new Eidos components shipped end-to-end (wrapper + recipe + demo +
Soma provider hardening) plus a checklist-driven audit pipeline that
scores all 67 morfo components against doctrinal completion criteria.
New components:
- date-picker: full popover-anchored picker over date-field + calendar,
with calendar/content/trigger parts and demo route.
- date-range-picker: standalone wrapper with own calendar/grid/segment
surface, demo route, and recipe CSS.
- Both wrappers follow Option C disciplined (root + parts attached via
explicit assignment, no Object.assign).
Supporting Soma changes:
- range-calendar provider tightened (211 LOC of behavior, 167 LOC of
tests), README brought up to component doctrine.
- date-field, date-picker, date-range-field, date-range-picker Soma
providers + READMEs updated for new wrappers.
- popover provider/close gain props needed by the picker wrappers.
Morfo updates:
- date-picker / date-range-picker / range-calendar morfos refined for
the new APIs (parts, events, ARIA).
Audit infrastructure (new):
- src/uix/COMPONENT_COMPLETION_CHECKLIST.md — 81 doctrinal rules across
morfo / eidos wrapper / recipe CSS / demo / README / cross-layer
scripts. Each rule keyed to active_architecture.md, GUIA_IMPLEMENTACION
and DEMO_AUTHORING_GUIDE.
- scripts/component-audit.ts + `npm run component:audit` — regex parser
over all 67 components, emits tmp/component-audit.md with summary
scoreboard + per-component findings. Validates against canonical
SEMA_FAMILIES / SEMA_VERBS / ARCHETYPE_VOCABULARY / INTENTS.
- Initial baseline: 1 PASS, 64 NEEDS-WORK, 2 BROKEN (tooltip,
date-range-picker). Top systemic gaps: translations.label (49),
README Gaps/Comparativa/Baseline sections (87 combined), keyboard
/event ratio under-declaration (15), apg URL absent (19).
Misc:
- src/uix/kimi-audit-eidos.md — supplementary audit notes.
- .gitignore: ignore .codex-* agent scratch artifacts at repo root.
- continue.md + READMEs updated through the migration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
|
|
|
expect(props.id).toBe('date-range-picker-root');
|
|
|
|
|
expect(props['data-date-range-picker']).toBe('');
|
|
|
|
|
expect(props['data-state']).toBe('open');
|
|
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
dom.dispose();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('exposes root state flags for composed wrappers', () => {
|
|
|
|
|
const { dom } = installSomaHarness();
|
|
|
|
|
const opts = createDateRangePickerOpts();
|
|
|
|
|
|
|
|
|
|
const { result: provider, cleanup } = withEffectRoot(() =>
|
|
|
|
|
DateRangePickerProvider.create(opts)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
opts.open.current = false;
|
|
|
|
|
opts.disabled.current = true;
|
|
|
|
|
opts.readonly.current = true;
|
|
|
|
|
opts.required.current = true;
|
|
|
|
|
opts.value.current = {
|
|
|
|
|
start: new CalendarDate(2026, 4, 30),
|
|
|
|
|
end: new CalendarDate(2026, 5, 2)
|
|
|
|
|
};
|
|
|
|
|
opts.minValue.current = new CalendarDate(2026, 5, 1);
|
|
|
|
|
|
|
|
|
|
const props = provider.props as Record<string, unknown>;
|
|
|
|
|
expect(props['data-state']).toBe('closed');
|
|
|
|
|
expect(props['data-disabled']).toBe('');
|
|
|
|
|
expect(props['data-readonly']).toBe('');
|
|
|
|
|
expect(props['data-required']).toBe('');
|
|
|
|
|
expect(props['data-invalid']).toBe('');
|
|
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
dom.dispose();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('closes the popover only when closeOnRangeSelect is enabled', () => {
|
|
|
|
|
const { dom } = installSomaHarness();
|
|
|
|
|
const opts = createDateRangePickerOpts();
|
|
|
|
|
|
|
|
|
|
const { result: provider, cleanup } = withEffectRoot(() =>
|
|
|
|
|
DateRangePickerProvider.create(opts)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
provider.handleRangeSelect();
|
|
|
|
|
expect(opts.open.current).toBe(false);
|
|
|
|
|
|
|
|
|
|
opts.open.current = true;
|
|
|
|
|
opts.closeOnRangeSelect.current = false;
|
|
|
|
|
provider.handleRangeSelect();
|
|
|
|
|
expect(opts.open.current).toBe(true);
|
|
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
dom.dispose();
|
|
|
|
|
});
|
uix: date-picker + date-range-picker components + component audit infra
Two new Eidos components shipped end-to-end (wrapper + recipe + demo +
Soma provider hardening) plus a checklist-driven audit pipeline that
scores all 67 morfo components against doctrinal completion criteria.
New components:
- date-picker: full popover-anchored picker over date-field + calendar,
with calendar/content/trigger parts and demo route.
- date-range-picker: standalone wrapper with own calendar/grid/segment
surface, demo route, and recipe CSS.
- Both wrappers follow Option C disciplined (root + parts attached via
explicit assignment, no Object.assign).
Supporting Soma changes:
- range-calendar provider tightened (211 LOC of behavior, 167 LOC of
tests), README brought up to component doctrine.
- date-field, date-picker, date-range-field, date-range-picker Soma
providers + READMEs updated for new wrappers.
- popover provider/close gain props needed by the picker wrappers.
Morfo updates:
- date-picker / date-range-picker / range-calendar morfos refined for
the new APIs (parts, events, ARIA).
Audit infrastructure (new):
- src/uix/COMPONENT_COMPLETION_CHECKLIST.md — 81 doctrinal rules across
morfo / eidos wrapper / recipe CSS / demo / README / cross-layer
scripts. Each rule keyed to active_architecture.md, GUIA_IMPLEMENTACION
and DEMO_AUTHORING_GUIDE.
- scripts/component-audit.ts + `npm run component:audit` — regex parser
over all 67 components, emits tmp/component-audit.md with summary
scoreboard + per-component findings. Validates against canonical
SEMA_FAMILIES / SEMA_VERBS / ARCHETYPE_VOCABULARY / INTENTS.
- Initial baseline: 1 PASS, 64 NEEDS-WORK, 2 BROKEN (tooltip,
date-range-picker). Top systemic gaps: translations.label (49),
README Gaps/Comparativa/Baseline sections (87 combined), keyboard
/event ratio under-declaration (15), apg URL absent (19).
Misc:
- src/uix/kimi-audit-eidos.md — supplementary audit notes.
- .gitignore: ignore .codex-* agent scratch artifacts at repo root.
- continue.md + READMEs updated through the migration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
|
|
|
|
|
|
|
|
it('validates single-day and range length constraints', () => {
|
|
|
|
|
const { dom } = installSomaHarness();
|
|
|
|
|
const opts = createDateRangePickerOpts();
|
|
|
|
|
const start = new CalendarDate(2026, 5, 10);
|
|
|
|
|
|
|
|
|
|
const { result: provider, cleanup } = withEffectRoot(() =>
|
|
|
|
|
DateRangePickerProvider.create(opts)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
opts.allowSingleDay.current = false;
|
|
|
|
|
opts.value.current = { start, end: start };
|
|
|
|
|
expect(provider.validationStatus).toEqual({ reason: 'single-day' });
|
|
|
|
|
expect(provider.props['data-invalid']).toBe('');
|
|
|
|
|
|
|
|
|
|
opts.allowSingleDay.current = true;
|
|
|
|
|
opts.minDays.current = 3;
|
|
|
|
|
opts.value.current = { start, end: new CalendarDate(2026, 5, 11) };
|
|
|
|
|
expect(provider.validationStatus).toEqual({ reason: 'min-days' });
|
|
|
|
|
|
|
|
|
|
opts.minDays.current = undefined;
|
|
|
|
|
opts.maxDays.current = 3;
|
|
|
|
|
opts.value.current = { start, end: new CalendarDate(2026, 5, 20) };
|
|
|
|
|
expect(provider.validationStatus).toEqual({ reason: 'max-days' });
|
|
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
dom.dispose();
|
|
|
|
|
});
|
|
|
|
|
});
|