Refactor terra date utilities split

main
dev 6 months ago
parent 27bcc65eee
commit b3fc77a28e

@ -10,6 +10,8 @@
* governing permissions and limitations under the License.
*/
import type { HourCycle } from '$lib/util/dates/types';
let formatterCache = new Map<string, Intl.DateTimeFormat>();
interface DateRangeFormatPart extends Intl.DateTimeFormatPart {
@ -196,3 +198,5 @@ function getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOption
throw new Error('Unexpected hour cycle result');
}

@ -15,7 +15,7 @@
import type {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';
import {CalendarDate} from '../CalendarDate';
import type {Mutable} from '../utils';
import type {Mutable} from '$lib/util/objs';
const ETHIOPIC_EPOCH = 1723856;
const COPTIC_EPOCH = 1824665;

@ -15,8 +15,8 @@
import type {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';
import {CalendarDate} from '../CalendarDate';
import {mod} from '../utils';
import type {Mutable} from '../utils';
import {mod} from '$lib/util/numbers';
import type {Mutable} from '$lib/util/objs';
const EPOCH = 1721426; // 001/01/03 Julian C.E.
export function gregorianToJulianDay(era: string, year: number, month: number, day: number): number {

@ -15,8 +15,8 @@
import type {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';
import {CalendarDate} from '../CalendarDate';
import {mod} from '../utils';
import type {Mutable} from '../utils';
import {mod} from '$lib/util/numbers';
import type {Mutable} from '$lib/util/objs';
const HEBREW_EPOCH = 347997;

@ -16,7 +16,7 @@
import type {AnyCalendarDate, CalendarIdentifier} from '../types';
import {CalendarDate} from '../CalendarDate';
import {GregorianCalendar} from './GregorianCalendar';
import type {Mutable} from '../utils';
import type {Mutable} from '$lib/util/objs';
const ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];
const ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];

@ -15,7 +15,8 @@
import type {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';
import {CalendarDate} from '../CalendarDate';
import {mod} from '../utils';
import {mod} from '$lib/util/numbers';
const PERSIAN_EPOCH = 1948320;

@ -16,7 +16,7 @@
import type {AnyCalendarDate, CalendarIdentifier} from '../types';
import {CalendarDate} from '../CalendarDate';
import {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';
import type {Mutable} from '../utils';
import type {Mutable} from '$lib/util/objs';
const TAIWAN_ERA_START = 1911;

@ -1,7 +1,15 @@
import {CalendarDate, CalendarDateTime, Time} from './CalendarDate';
import type {DateValue, TimeValue} from './queries';
import {getLocalTimeZone} from './queries';
import type {Granularity, TimeGranularity, HourCycle} from './types';
import type {Granularity, TimeGranularity, HourCycle, DateOrder } from './types';
/** Valores por defecto compartidos para componentes desacoplados de contexto. */
export const DEFAULT_TIME_FORMAT: HourCycle = 24;
export const DEFAULT_DATE_ORDER: DateOrder = 'DMY';
// ─── Date defaults ────────────────────────────────────────────────────────────

@ -30,8 +30,10 @@ export type {
TimeGranularity,
HourCycle,
WeekStartsOn,
DateOrder,
} from './types';
export type {
DateValue,
TimeValue,
@ -125,6 +127,7 @@ export {
parseAbsoluteToLocal,
parseZonedDateTime,
parseDuration
} from './string';
export {DateFormatter} from './DateFormatter';
export {
@ -138,4 +141,12 @@ export {
inferGranularity,
inferTimeGranularity,
getDefaultHourCycle,
DEFAULT_TIME_FORMAT,
DEFAULT_DATE_ORDER,
} from './defaults';
export { timeFormatToHourCycle } from './utils';
export * from './placeholders.ts';

@ -150,6 +150,14 @@ export interface CycleOptions {
round?: boolean
}
/**
* Hour cycle for time display.
* - `12` — 12-hour clock (AM/PM)
* - `24` — 24-hour clock
*/
export type HourCycle = 12 | 24;
export interface CycleTimeOptions extends CycleOptions {
/**
* Whether to use 12 or 24 hour time. If 12 hour time is chosen, the resulting value
@ -157,9 +165,26 @@ export interface CycleTimeOptions extends CycleOptions {
* the resulting value also be AM).
* @default 24
*/
hourCycle?: 12 | 24
hourCycle?: HourCycle
}
/**
* Nivel de detalle en el formateo de fecha u hora.
* Mapea directamente a los valores que acepta `Intl.DateTimeFormat`.
*/
export type DateStyleType = 'short' | 'medium' | 'long' | 'full';
/** Orden preferido de los componentes de fecha (informativo para la UI). */
export type DateOrder = 'DMY' | 'MDY' | 'YMD';
// ─── Domain types ─────────────────────────────────────────────────────────────
/**
@ -171,12 +196,7 @@ export type Granularity = 'day' | 'hour' | 'minute' | 'second';
/** Time-only granularity (subset of Granularity). */
export type TimeGranularity = 'hour' | 'minute' | 'second';
/**
* Hour cycle for time display.
* - `12` — 12-hour clock (AM/PM)
* - `24` — 24-hour clock
*/
export type HourCycle = 12 | 24;
/**
* Day of the week that the calendar week starts on.

@ -0,0 +1,11 @@
import type { HourCycle } from '$lib/util/dates/types';
/** Convierte la preferencia de usuario `DatiTimeFormat` al `HourCycle` numérico de `Intl`. */
export function timeFormatToHourCycle(fmt: HourCycle): HourCycle {
return fmt === 12 ? 12 : 24;
}

@ -0,0 +1 @@
export * from './noop.ts';

@ -0,0 +1,4 @@
export * from './utilities';

@ -10,10 +10,9 @@
* governing permissions and limitations under the License.
*/
import type { HourCycle } from '$lib/util/dates/types';
export type Mutable<T> = {
-readonly[P in keyof T]: T[P]
};
export function mod(amount: number, numerator: number): number {
return amount - numerator * Math.floor(amount / numerator);
}

@ -1,8 +1,8 @@
<script lang="ts">
import { TerraConfig, Calendar } from '$uix/terra';
import type { DatiDateOrder } from '$lib/glob/lib';
import type { DateValue } from '$lib/glob/lib/date';
import { today, getLocalTimeZone, CalendarDate, isSameDay } from '$lib/glob/lib/date';
import type { DateOrder } from '$lib/util/dates';
import type { DateValue } from '$lib/util/dates';
import { today, getLocalTimeZone, CalendarDate, isSameDay } from '$lib/util/dates';
// ── Estado ──────────────────────────────────────────────────────────────────
let singleValue = $state<DateValue | undefined>(undefined);
@ -25,8 +25,8 @@
{ id: 'ar-SA', label: 'ar-SA', hint: 'RTL هـ' },
];
let locale = $state('es-ES');
const DATE_ORDERS: DatiDateOrder[] = ['DMY', 'MDY', 'YMD'];
let dateOrder = $state<DatiDateOrder>('DMY');
const DATE_ORDERS: DateOrder[] = ['DMY', 'MDY', 'YMD'];
let dateOrder = $state<DateOrder>('DMY');
// Fechas deshabilitadas: fines de semana (0 = dom, 6 = sáb en getDay())
function isWeekend(date: DateValue): boolean {

@ -1,255 +1,510 @@
<script lang="ts">
import { AcelConfig, DatePicker } from '$uix/terra';
import { CalendarDate, type DateValue, getLocalTimeZone, today, type DatiDateOrder } from '$lib/glob/lib';
import { TerraConfig, DatePicker } from '$uix/terra';
import { CalendarDate, type DateValue, getLocalTimeZone, today, type DateOrder } from '$lib/util/dates';
const tz = getLocalTimeZone();
const now = today(tz);
const LOCALES = [
{ id: 'es-ES', label: 'es-ES' },
{ id: 'en-US', label: 'en-US' },
{ id: 'de-DE', label: 'de-DE' },
];
const ORDERS: DatiDateOrder[] = ['DMY', 'MDY', 'YMD'];
const ORDERS: DateOrder[] = ['DMY', 'MDY', 'YMD'];
let locale = $state('es-ES');
let dateOrder = $state<DatiDateOrder>('DMY');
let dateOrder = $state<DateOrder>('DMY');
let value1 = $state<DateValue | undefined>(new CalendarDate(now.year, now.month, now.day));
let value2 = $state<DateValue | undefined>(new CalendarDate(now.year, now.month, Math.min(now.day + 3, 28)));
let value3 = $state<DateValue | undefined>(undefined);
let open3 = $state(false);
function fmt(value: DateValue | undefined) {
if (!value) return '—';
return `${value.year}-${String(value.month).padStart(2, '0')}-${String(value.day).padStart(2, '0')}`;
}
</script>
<div class="page">
<header class="hero">
<p class="eyebrow">acel · date-picker</p>
<h1>DatePicker</h1>
<p class="sub">Demo para probar picker simple con `locale`, `dateOrder` y herencia vía `AcelConfig`.</p>
<p class="sub">Demo para probar picker simple con `locale`, `dateOrder` y herencia vía `TerraConfig`.</p>
</header>
<section class="toolbar">
<div class="group">
<span>Locale</span>
{#each LOCALES as option}
<button class:selected={locale === option.id} onclick={() => (locale = option.id)}>{option.label}</button>
{/each}
</div>
<div class="group">
<span>Date order</span>
{#each ORDERS as order}
<button class:selected={dateOrder === order} onclick={() => (dateOrder = order)}>{order}</button>
{/each}
</div>
</section>
<main class="grid">
<section class="card">
<h2>Básico</h2>
<DatePicker.Root bind:value={value1} {locale} {dateOrder}>
<DatePicker.Label class="dp-label">Fecha</DatePicker.Label>
<div class="field-row">
<DatePicker.Input class="dp-input">
{#snippet children({ segments })}
{#each segments as { part, value }}
<DatePicker.Segment {part} class="dp-seg">{value}</DatePicker.Segment>
{/each}
{/snippet}
</DatePicker.Input>
<DatePicker.Trigger class="dp-trigger">📅</DatePicker.Trigger>
</div>
<DatePicker.Content class="dp-popover" sideOffset={8}>
<DatePicker.Calendar class="cal">
{#snippet children({ months, weekdays })}
<DatePicker.Header class="cal-hd">
<DatePicker.PrevButton class="cal-btn">‹</DatePicker.PrevButton>
<DatePicker.Heading class="cal-heading" />
<DatePicker.NextButton class="cal-btn">›</DatePicker.NextButton>
</DatePicker.Header>
{#each months as month}
<DatePicker.Grid class="cal-grid">
<DatePicker.GridHead>
<DatePicker.GridRow>
{#each weekdays as day}
<DatePicker.HeadCell class="cal-th">{day}</DatePicker.HeadCell>
{/each}
</DatePicker.GridRow>
</DatePicker.GridHead>
<DatePicker.GridBody>
{#each month.weeks as week}
<DatePicker.GridRow>
{#each week as date}
<DatePicker.Cell {date} month={month.value} class="cal-td">
<DatePicker.Day class="cal-day" />
</DatePicker.Cell>
{/each}
</DatePicker.GridRow>
{/each}
</DatePicker.GridBody>
</DatePicker.Grid>
{/each}
{/snippet}
</DatePicker.Calendar>
</DatePicker.Content>
</DatePicker.Root>
<div class="value">{fmt(value1)}</div>
</section>
<section class="card">
<h2>Dos meses</h2>
<DatePicker.Root bind:value={value2} {locale} {dateOrder} numberOfMonths={2}>
<DatePicker.Label class="dp-label">Fecha extendida</DatePicker.Label>
<div class="field-row">
<DatePicker.Input class="dp-input">
{#snippet children({ segments })}
{#each segments as { part, value }}
<DatePicker.Segment {part} class="dp-seg">{value}</DatePicker.Segment>
{/each}
{/snippet}
</DatePicker.Input>
<DatePicker.Trigger class="dp-trigger">📅</DatePicker.Trigger>
</div>
<DatePicker.Content class="dp-popover" sideOffset={8}>
<DatePicker.Calendar class="cal">
{#snippet children({ months, weekdays })}
<div class="two-month-layout">
{#each months as month, i}
<div class="month-col">
<div class="month-nav">
{#if i === 0}
<DatePicker.PrevButton class="cal-btn"><EFBFBD></DatePicker.PrevButton>
{:else}
<span></span>
{/if}
<DatePicker.Heading class="cal-heading" />
{#if i === months.length - 1}
<DatePicker.NextButton class="cal-btn"><EFBFBD></DatePicker.NextButton>
{:else}
<span></span>
{/if}
</div>
<DatePicker.Grid class="cal-grid">
<DatePicker.GridHead>
<DatePicker.GridRow>
{#each weekdays as day}
<DatePicker.HeadCell class="cal-th">{day}</DatePicker.HeadCell>
{/each}
</DatePicker.GridRow>
</DatePicker.GridHead>
<DatePicker.GridBody>
{#each month.weeks as week}
<DatePicker.GridRow>
{#each week as date}
<DatePicker.Cell {date} month={month.value} class="cal-td">
<DatePicker.Day class="cal-day" />
</DatePicker.Cell>
{/each}
</DatePicker.GridRow>
{/each}
</DatePicker.GridBody>
</DatePicker.Grid>
</div>
{/each}
</div>
{/snippet}
</DatePicker.Calendar>
</DatePicker.Content>
</DatePicker.Root>
<div class="value">{fmt(value2)}</div>
</section>
<section class="card">
<h2>Vía AcelConfig</h2>
<AcelConfig defaultLocale={locale} defaultDateOrder={dateOrder}>
<h2>Vía TerraConfig</h2>
<TerraConfig defaultLocale={locale} defaultDateOrder={dateOrder}>
<DatePicker.Root bind:value={value3} bind:open={open3}>
<DatePicker.Label class="dp-label">Fecha heredada</DatePicker.Label>
<div class="field-row">
<DatePicker.Input class="dp-input">
{#snippet children({ segments })}
{#each segments as { part, value }}
<DatePicker.Segment {part} class="dp-seg">{value}</DatePicker.Segment>
{/each}
{/snippet}
</DatePicker.Input>
<DatePicker.Trigger class="dp-trigger">📅</DatePicker.Trigger>
</div>
<DatePicker.Content class="dp-popover" sideOffset={8}>
<DatePicker.Calendar class="cal">
{#snippet children({ months, weekdays })}
<DatePicker.Header class="cal-hd">
<DatePicker.PrevButton class="cal-btn"><EFBFBD></DatePicker.PrevButton>
<DatePicker.Heading class="cal-heading" />
<DatePicker.NextButton class="cal-btn"><EFBFBD></DatePicker.NextButton>
</DatePicker.Header>
{#each months as month}
<DatePicker.Grid class="cal-grid">
<DatePicker.GridHead>
<DatePicker.GridRow>
{#each weekdays as day}
<DatePicker.HeadCell class="cal-th">{day}</DatePicker.HeadCell>
{/each}
</DatePicker.GridRow>
</DatePicker.GridHead>
<DatePicker.GridBody>
{#each month.weeks as week}
<DatePicker.GridRow>
{#each week as date}
<DatePicker.Cell {date} month={month.value} class="cal-td">
<DatePicker.Day class="cal-day" />
</DatePicker.Cell>
{/each}
</DatePicker.GridRow>
{/each}
</DatePicker.GridBody>
</DatePicker.Grid>
{/each}
{/snippet}
</DatePicker.Calendar>
</DatePicker.Content>
</DatePicker.Root>
</AcelConfig>
</TerraConfig>
<div class="value">{fmt(value3)}</div>
</section>
</main>
</div>
<style>
:global(*, *::before, *::after) { box-sizing: border-box; }
.page { min-height: 100vh; background: #0f1117; color: #e5e7eb; font-family: Inter, system-ui, sans-serif; padding: 1.5rem; }
.hero, .toolbar, .grid { max-width: 1100px; margin: 0 auto; }
.hero { margin-bottom: 1rem; }
.eyebrow { margin: 0 0 .35rem; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: #60a5fa; }
h1 { margin: 0; font-size: 2rem; }
.sub { margin: .4rem 0 0; color: #94a3b8; }
.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.group { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.group span { font-size: .8rem; color: #94a3b8; }
button { border: 1px solid #334155; background: #111827; color: #cbd5e1; border-radius: 999px; padding: .35rem .7rem; cursor: pointer; }
button.selected { border-color: #60a5fa; color: #eff6ff; background: #172554; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.card { background: #111827; border: 1px solid #1f2937; border-radius: 16px; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.card h2 { margin: 0; }
:global(.dp-label) { display: block; font-size: .78rem; color: #93c5fd; margin-bottom: .35rem; }
.field-row { display: flex; align-items: center; gap: .6rem; }
:global(.dp-input) { display: inline-flex; align-items: center; gap: .15rem; padding: .55rem .7rem; border-radius: 12px; border: 1px solid #334155; background: #020617; min-height: 44px; flex: 1; }
:global(.dp-seg) { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7em; padding: .1rem .2rem; border-radius: 8px; outline: none; }
:global(.dp-seg[data-type="literal"]) { min-width: auto; padding: 0; color: #64748b; }
:global(.dp-seg:focus), :global(.dp-seg[data-focused]) { background: #1d4ed8; color: white; }
:global(.dp-trigger) { border: 1px solid #334155; background: #020617; color: #cbd5e1; border-radius: 10px; width: 40px; height: 40px; }
:global(.dp-popover) { background: #111827; border: 1px solid #334155; border-radius: 16px; padding: .85rem; box-shadow: 0 16px 40px rgba(0,0,0,.35); }
:global(.cal-hd) { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
:global(.cal-heading) { font-weight: 700; }
:global(.cal-btn) { border: 1px solid #334155; background: transparent; color: #cbd5e1; border-radius: 10px; width: 32px; height: 32px; }
:global(.cal-grid) { width: 100%; border-collapse: collapse; }
:global(.cal-th) { padding: .25rem; font-size: .7rem; color: #94a3b8; }
:global(.cal-td) { padding: 2px; text-align: center; }
:global(.cal-day) { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 999px; }
.two-month-layout { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.month-col { display: flex; flex-direction: column; gap: .4rem; }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.value { font-family: 'DM Mono', monospace; font-size: .85rem; color: #86efac; }
</style>

@ -2,11 +2,11 @@
import { TerraConfig, DateRangeField } from '$uix/terra';
import type { DatiDateOrder, DatiTimeFormat } from '$lib/glob/lib';
import type { DateOrder, HourCycle } from '$lib/util/dates';
import type { DateValue } from '$lib/glob/lib/date';
import type { DateValue } from '$lib/util/dates';
import { today, getLocalTimeZone, CalendarDate } from '$lib/glob/lib/date';
import { today, getLocalTimeZone, CalendarDate } from '$lib/util/dates';
@ -38,13 +38,13 @@
let locale = $state('es-ES');
const DATE_ORDERS: DatiDateOrder[] = ['DMY', 'MDY', 'YMD'];
const DATE_ORDERS: DateOrder[] = ['DMY', 'MDY', 'YMD'];
const TIME_FORMATS: DatiTimeFormat[] = ['24h', '12h'];
const TIME_FORMATS: HourCycle[] = [24, 12];
let dateOrder = $state<DatiDateOrder>('DMY');
let dateOrder = $state<DateOrder>('DMY');
let timeFormat = $state<DatiTimeFormat>('24h');
let timeFormat = $state<HourCycle>(24);
@ -208,7 +208,7 @@
onclick={() => (timeFormat = format)}
>{format}</button>
>{format === 24 ? '24h' : '12h'}</button>
{/each}

@ -1,7 +1,7 @@
<script lang="ts">
import { DateRangePicker } from '$uix/terra';
import type { DateValue } from '$lib/glob/lib/date';
import { today, getLocalTimeZone, CalendarDate } from '$lib/glob/lib/date';
import type { DateValue } from '$lib/util/dates';
import { today, getLocalTimeZone, CalendarDate } from '$lib/util/dates';
const tz = getLocalTimeZone();
const now = today(tz);

@ -1,8 +1,8 @@
<script lang="ts">
import { TerraConfig, RangeCalendar } from '$uix/terra';
import type { DatiDateOrder } from '$lib/glob/lib';
import type { DateValue } from '$lib/glob/lib/date';
import { today, getLocalTimeZone, CalendarDate } from '$lib/glob/lib/date';
import type { DateOrder } from '$lib/util/dates';
import type { DateValue } from '$lib/util/dates';
import { today, getLocalTimeZone, CalendarDate } from '$lib/util/dates';
const tz = getLocalTimeZone();
const now = today(tz);
@ -18,8 +18,8 @@
{ id: 'ar-SA', label: 'ar-SA', hint: 'RTL هـ' },
];
let locale = $state('es-ES');
const DATE_ORDERS: DatiDateOrder[] = ['DMY', 'MDY', 'YMD'];
let dateOrder = $state<DatiDateOrder>('DMY');
const DATE_ORDERS: DateOrder[] = ['DMY', 'MDY', 'YMD'];
let dateOrder = $state<DateOrder>('DMY');
// ── 01. Básico ───────────────────────────────────────────────────────────
let value1 = $state<{ start: DateValue | undefined; end: DateValue | undefined }>({

@ -1,6 +1,6 @@
<script lang="ts">
import { AcelConfig, TimeField } from '$uix/terra';
import { Time, type TimeValue, type DatiTimeFormat } from '$lib/glob/lib';
import { TerraConfig, TimeField } from '$uix/terra';
import { Time, type TimeValue, type HourCycle } from '$lib/util/dates';
const LOCALES = [
{ id: 'es-ES', label: 'es-ES' },
@ -11,7 +11,7 @@
];
let locale = $state('es-ES');
let timeFormat = $state<DatiTimeFormat>('24h');
let timeFormat = $state<HourCycle>(24);
let value1 = $state<Time | undefined>(new Time(9, 30, 0));
let value2 = $state<Time | undefined>(new Time(14, 45, 20));
@ -31,7 +31,7 @@
<div>
<p class="eyebrow">acel · time-field</p>
<h1>TimeField</h1>
<p class="sub">Pruebas reactivas para `locale`, `timeFormat` y herencia desde `AcelConfig`.</p>
<p class="sub">Pruebas reactivas para `locale`, `timeFormat` y herencia desde `TerraConfig`.</p>
</div>
</header>
@ -48,8 +48,8 @@
<div class="group">
<span>Time format</span>
<button class:selected={timeFormat === '24h'} onclick={() => (timeFormat = '24h')}>24h</button>
<button class:selected={timeFormat === '12h'} onclick={() => (timeFormat = '12h')}>12h</button>
<button class:selected={timeFormat === 24} onclick={() => (timeFormat = 24)}>24h</button>
<button class:selected={timeFormat === 12} onclick={() => (timeFormat = 12)}>12h</button>
</div>
</section>
@ -115,10 +115,10 @@
</section>
<section class="card">
<h2>Vía AcelConfig</h2>
<h2>Vía TerraConfig</h2>
<p>Este ejemplo hereda `locale` y `timeFormat` del config global, sin props directas.</p>
<AcelConfig defaultLocale={locale} defaultTimeFormat={timeFormat}>
<TerraConfig defaultLocale={locale} defaultTimeFormat={timeFormat}>
<TimeField.Root bind:value={value4} granularity="minute">
<TimeField.Label class="tf-label">Hora heredada</TimeField.Label>
<TimeField.Input class="tf-input">
@ -129,7 +129,7 @@
{/snippet}
</TimeField.Input>
</TimeField.Root>
</AcelConfig>
</TerraConfig>
<div class="value">{fmt(value4)}</div>
</section>
@ -292,3 +292,7 @@

@ -1,6 +1,6 @@
<script lang="ts">
import { AcelConfig, TimeRangeField } from '$uix/terra';
import { Time, type DatiTimeFormat } from '$lib/glob/lib';
import { TerraConfig, TimeRangeField } from '$uix/terra';
import { Time, type HourCycle } from '$lib/util/dates';
const LOCALES = [
{ id: 'es-ES', label: 'es-ES' },
@ -10,7 +10,7 @@
];
let locale = $state('es-ES');
let timeFormat = $state<DatiTimeFormat>('24h');
let timeFormat = $state<HourCycle>(24);
let value1 = $state<{ start: Time | undefined; end: Time | undefined } | undefined>({
start: new Time(9, 30, 0),
@ -36,7 +36,7 @@
<header class="hero">
<p class="eyebrow">acel · time-range-field</p>
<h1>TimeRangeField</h1>
<p class="sub">Demo para probar rangos de hora, granularidad y herencia reactiva desde `AcelConfig`.</p>
<p class="sub">Demo para probar rangos de hora, granularidad y herencia reactiva desde `TerraConfig`.</p>
</header>
<section class="toolbar">
@ -48,8 +48,8 @@
</div>
<div class="group">
<span>Time format</span>
<button class:selected={timeFormat === '24h'} onclick={() => (timeFormat = '24h')}>24h</button>
<button class:selected={timeFormat === '12h'} onclick={() => (timeFormat = '12h')}>12h</button>
<button class:selected={timeFormat === 24} onclick={() => (timeFormat = 24)}>24h</button>
<button class:selected={timeFormat === 12} onclick={() => (timeFormat = 12)}>12h</button>
</div>
</section>
@ -105,8 +105,8 @@
</section>
<section class="card">
<h2>Vía AcelConfig</h2>
<AcelConfig defaultLocale={locale} defaultTimeFormat={timeFormat}>
<h2>Vía TerraConfig</h2>
<TerraConfig defaultLocale={locale} defaultTimeFormat={timeFormat}>
<TimeRangeField.Root bind:value={value3} granularity="minute">
<TimeRangeField.Label class="tf-label">Horario heredado</TimeRangeField.Label>
<div class="pair">
@ -127,7 +127,7 @@
</TimeRangeField.Input>
</div>
</TimeRangeField.Root>
</AcelConfig>
</TerraConfig>
<div class="value">{fmt(value3)}</div>
</section>
</main>
@ -160,3 +160,6 @@
</style>

@ -1 +1 @@
export * from "./exports.js";
export * from "./exports.ts";

@ -1,5 +1,5 @@
import { readableActive, type Active, type Getter } from '../../utils';
import { DEFAULT_DATI_DATE_ORDER, DEFAULT_DATI_TIME_FORMAT, datiTimeFormatToHourCycle, type DatiTimeFormat, type HourCycle } from '$lib/glob/lib';
import { DEFAULT_DATE_ORDER, DEFAULT_TIME_FORMAT, timeFormatToHourCycle, type HourCycle } from '$lib/util/dates';
import { type TerraConfigState, getTerraConfig } from './terra-config.ts';
/**
@ -45,27 +45,27 @@ export const resolvePortalToProp = createPropResolver((config) => config.default
/**
* Resolves a date order using the prop, the config default, or the library fallback.
*/
export const resolveDateOrderProp = createPropResolver((config) => config.defaultDateOrder, DEFAULT_DATI_DATE_ORDER);
export const resolveDateOrderProp = createPropResolver((config) => config.defaultDateOrder, DEFAULT_DATE_ORDER);
/**
* Resolves an hour cycle using explicit time/date props, config defaults, or the library fallback.
*/
export function resolveHourCycleProp(
getTimeFormat: Getter<DatiTimeFormat | undefined>,
getTimeFormat: Getter<HourCycle | undefined>,
getHourCycle: Getter<HourCycle | undefined>
): Active<HourCycle> {
const config = getTerraConfig();
return readableActive(() => {
const timeFormat = getTimeFormat();
if (timeFormat !== undefined) return datiTimeFormatToHourCycle(timeFormat);
if (timeFormat !== undefined) return timeFormatToHourCycle(timeFormat);
const hourCycle = getHourCycle();
if (hourCycle !== undefined) return hourCycle;
const configTimeFormat = config.defaultTimeFormat.current;
if (configTimeFormat !== undefined) return datiTimeFormatToHourCycle(configTimeFormat);
if (configTimeFormat !== undefined) return timeFormatToHourCycle(configTimeFormat);
return datiTimeFormatToHourCycle(DEFAULT_DATI_TIME_FORMAT);
return timeFormatToHourCycle(DEFAULT_TIME_FORMAT);
});
}

@ -1,5 +1,5 @@
import type { WithChildren } from '../../utils';
import type { DatiDateOrder, DatiTimeFormat, HourCycle } from '$lib/glob/lib';
import type { DateOrder, HourCycle } from '$lib/util/dates';
import type { PortalTarget } from '../portal/types.ts';
export type TerraConfigPropsWithoutChildren = {
@ -16,12 +16,12 @@ export type TerraConfigPropsWithoutChildren = {
/**
* The default date part order to use for date-aware components.
*/
defaultDateOrder?: DatiDateOrder;
defaultDateOrder?: DateOrder;
/**
* The default time format to use for time-aware components.
*/
defaultTimeFormat?: DatiTimeFormat;
defaultTimeFormat?: HourCycle;
};
export type TerraConfigProps = WithChildren<TerraConfigPropsWithoutChildren>;
@ -39,7 +39,7 @@ export type TerraDatePresentationProps = {
*
* @defaultValue 'DMY'
*/
dateOrder?: DatiDateOrder;
dateOrder?: DateOrder;
};
export type TerraDateTimePresentationProps = TerraDatePresentationProps & {
@ -56,6 +56,6 @@ export type TerraDateTimePresentationProps = TerraDatePresentationProps & {
*
* @defaultValue '24h'
*/
timeFormat?: DatiTimeFormat;
timeFormat?: HourCycle;
};

@ -1,5 +1,6 @@
<script lang="ts">
import { onMountEffect, noop } from "../utils";
import { onMountEffect } from "../utils";
import { noop } from "$lib/util/funcs";
let {

@ -1,11 +1,11 @@
import {
type DateValue,
type DatiDateOrder,
type DateOrder,
getLocalTimeZone,
isSameDay,
isSameMonth,
isToday,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import { DEV } from "esm-env";
import { onMount, untrack } from "svelte";
import {
@ -33,7 +33,7 @@ import {
getDateValueType,
isBefore,
dateValueToDate as toDate,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import { type Announcer, getAnnouncer } from "../utils/datetime/announcer";
import { type Formatter, createFormatter } from "../utils/datetime/formatter";
import {
@ -77,7 +77,7 @@ interface CalendarRootStateOpts
fixedWeeks: boolean;
numberOfMonths: number;
locale: string;
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
calendarLabel: string;
type: "single" | "multiple";
readonly: boolean;
@ -1157,3 +1157,5 @@ export class CalendarYearSelectState {
);
}

@ -1,12 +1,12 @@
<script lang="ts">
import { watch } from "runed";
import { readableActive, writableActive, mergeProps } from "../../utils";
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import { CalendarRootState } from "../calendar.svelte";
import type { CalendarRootProps } from "../types";
import { useId } from "../../utils/use-id";
import { noop } from "../../utils/noop";
import { getDefaultDate } from "$lib/glob/lib";
import { noop } from "$lib/util/funcs";
import { getDefaultDate } from "$lib/util/dates";
import { resolveDateOrderProp, resolveLocaleProp } from "../../base/config/prop-resolvers";
let {
@ -129,3 +129,4 @@
</div>
{/if}

@ -35,3 +35,4 @@ export type {
CalendarMonthSelectSnippetProps,
CalendarYearSelectSnippetProps,
} from "./types";

@ -1,2 +1,3 @@
export * as Calendar from "./exports";
export * from "./exports";

@ -1,4 +1,4 @@
import type { DateValue, DatiDateOrder } from "$lib/glob/lib";
import type { DateValue, DateOrder } from "$lib/util/dates";
import type { TerraDatePresentationProps } from "../base/config/types";
import type { OnChangeFn, WithChild, Without } from "../utils/types";
import type {
@ -13,12 +13,12 @@ import type {
TerraPrimitiveTheadAttributes,
TerraPrimitiveTrAttributes,
} from "../utils/attributes";
import type { DateMatcher, Month, WeekStartsOn } from "$lib/glob/lib";
import type { DateMatcher, Month, WeekStartsOn } from "$lib/util/dates";
export type CalendarRootSnippetProps = {
months: Month<DateValue>[];
weekdays: string[];
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
};
export type CalendarCellSnippetProps = {
@ -169,3 +169,4 @@ export type CalendarYearSelectPropsWithoutHTML = WithChild<
export type CalendarYearSelectProps = CalendarYearSelectPropsWithoutHTML &
Without<TerraPrimitiveSelectAttributes, CalendarYearSelectPropsWithoutHTML>;

@ -9,3 +9,4 @@
<HiddenInput {...hiddenInputState.props} />
{/if}

@ -3,11 +3,12 @@
import { readableActive, writableActive } from "../../utils";
import { DateFieldRootState } from "../date-field.svelte.js";
import type { DateFieldRootProps } from "../types.js";
import { noop } from "../../utils";
import { resolveDateOrderProp, resolveHourCycleProp, resolveLocaleProp } from "../../base/config/prop-resolvers.ts";
import {
getDefaultDate
} from "$lib/glob/lib";
} from "$lib/util/dates";
import { noop } from '$lib/util/funcs';
let {
disabled = false,
@ -103,3 +104,5 @@
{@render children?.()}

@ -24,7 +24,7 @@ import {
boolToStr,
boolToStrTrueOrUndef,
boolToEmptyStrOrUndef,
} from "../utils";
} from "../utils/attrs";
import { isBrowser, isNumberString } from "../utils";
import { kbd } from "../utils/keyboard/kbd.ts";
import { useId } from "../utils";
@ -33,8 +33,8 @@ import type {
DateValidator,
Granularity,
HourCycle,
DatiDateOrder,
} from "$lib/glob/lib";
DateOrder,
} from "$lib/util/dates";
import type {
DateAndTimeSegmentObj,
DateSegmentObj,
@ -44,7 +44,7 @@ import type {
TimeSegmentObj,
EditableTimeSegmentPart,
} from "../utils/datetime/types.ts";
import { type Formatter, createFormatter } from "../utils/datetime/formatter.ts";
import { type Formatter, createFormatter } from "../utils/datetime";
import { type Announcer, getAnnouncer } from "../utils/datetime/announcer.ts";
import {
areAllSegmentsFilled,
@ -60,20 +60,20 @@ import {
isFirstSegment,
removeDescriptionElement,
setDescription,
} from "../utils/datetime/field/helpers.ts";
} from "../utils/datetime/helpers.ts";
import {
DATE_SEGMENT_PARTS,
EDITABLE_TIME_SEGMENT_PARTS,
} from "../utils/datetime/field/parts.ts";
import { getDaysInMonth, isBefore, dateValueToDate as toDate } from "$lib/glob/lib";
} from "../utils/datetime/parts.ts";
import { getDaysInMonth, isBefore, dateValueToDate as toDate } from "$lib/util/dates";
import {
getFirstSegment,
handleSegmentNavigation,
isSegmentNavigationKey,
moveToNextSegment,
moveToPrevSegment,
} from "../utils/datetime/field/segments.ts";
import type { DateValue } from '@/glob/lib';
} from "../utils/datetime/segments.ts";
import type { DateValue } from '$lib/util/dates';
export const dateFieldAttrs = createTerraAttrs({
component: "date-field",
@ -175,7 +175,7 @@ interface DateFieldRootStateOpts
granularity: Granularity | undefined;
hourCycle: HourCycle | undefined;
locale: string;
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
hideTimeZone: boolean;
required: boolean;
errorMessageId: string | undefined;
@ -1580,3 +1580,4 @@ function prependYearZeros(year: number) {
return `${"0".repeat(diff)}${year}`;
}

@ -10,3 +10,4 @@ export type {
DateFieldSegmentProps as SegmentProps,
// DateFieldDescriptionProps as DescriptionProps,
} from "./types.js";

@ -1,2 +1,3 @@
export * as DateField from "./exports.js";
export * from "./exports.js";

@ -3,7 +3,7 @@ import type {
DateOnInvalid,
DateValidator,
Granularity,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import type { EditableSegmentPart, SegmentPart } from "../utils/datetime/types";
import type { TerraDateTimePresentationProps } from "../base/config/types";
import type { WithChildren, OnChangeFn, WithChild, Without } from "../utils/types";
@ -158,3 +158,5 @@ export type DateFieldLabelPropsWithoutHTML = WithChild;
export type DateFieldLabelProps = DateFieldLabelPropsWithoutHTML &
Without<TerraPrimitiveDivAttributes, DateFieldLabelPropsWithoutHTML>;

@ -56,3 +56,4 @@
{@render children?.(calendarState.snippetProps)}
</div>
{/if}

@ -5,7 +5,7 @@
import {
handleSegmentNavigation,
isSegmentNavigationKey,
} from "../../utils/datetime/field/segments.ts";
} from "../../utils/datetime/segments.ts";
let { ref = $bindable(null), onkeydown, ...restProps }: DatePickerTriggerProps = $props();
@ -23,3 +23,4 @@
<PopoverTrigger {...restProps} bind:ref data-segment="trigger" {...mergedProps} />

@ -1,14 +1,16 @@
<script lang="ts">
import { watch } from 'runed';
import type { DateValue } from '$lib/glob/lib';
import { readableActive, writableActive, mergeProps, noop, useId } from '../../utils';
import type { DateValue } from '$lib/util/dates';
import { readableActive, writableActive, mergeProps, useId } from '../../utils';
import { DatePickerRootState } from '../date-picker.svelte.ts';
import type { DatePickerRootProps } from '../types.ts';
import { PopoverRootState } from '../../popover/popover.svelte.ts';
import { DateFieldRootState } from '../../date-field/date-field.svelte.ts';
import FloatingLayer from '../../base/floating-layer/components/floating-layer.svelte';
import { getDefaultDate } from '$lib/glob/lib';
import { getDefaultDate } from '$lib/util/dates';
import { resolveDateOrderProp, resolveHourCycleProp, resolveLocaleProp } from '../../base/config/prop-resolvers.ts';
import { noop } from '$lib/util/funcs';
let {
open = $bindable(false),
@ -166,3 +168,4 @@
</div>
{/if}
</FloatingLayer>

@ -1,4 +1,4 @@
import type { DateValue } from '$lib/glob/lib';
import type { DateValue } from '$lib/util/dates';
import { Context } from 'runed';
import type { ActiveProps, StateProps } from '../utils';
import type {
@ -6,8 +6,8 @@ import type {
Granularity,
HourCycle,
WeekStartsOn,
DatiDateOrder,
} from '$lib/glob/lib';
DateOrder,
} from '$lib/util/dates';
import type { SegmentPart } from '../utils/datetime/types';
export const DatePickerRootContext = new Context<DatePickerRootState>('DatePicker.Root');
@ -29,7 +29,7 @@ interface DatePickerRootStateOpts
granularity: Granularity | undefined;
hourCycle: HourCycle | undefined;
locale: string;
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
hideTimeZone: boolean;
required: boolean;
preventDeselect: boolean;
@ -58,3 +58,4 @@ export class DatePickerRootState {
this.opts = opts;
}
}

@ -44,3 +44,4 @@ export type {
DatePickerMonthSelectProps as MonthSelectProps,
DatePickerYearSelectProps as YearSelectProps,
} from "./types.js";

@ -1,2 +1,3 @@
export * as DatePicker from "./exports.js";
export * from "./exports.js";

@ -1,4 +1,4 @@
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import type { OnChangeFn, WithChild, WithChildren, Without } from "../utils/types.ts";
import type { TerraPrimitiveDivAttributes } from "../utils/attributes";
import type {
@ -7,7 +7,7 @@ import type {
DateValidator,
Granularity,
WeekStartsOn,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import type { EditableSegmentPart } from "../utils/datetime/types";
import type { TerraDateTimePresentationProps } from "../base/config/types";
import type { CalendarRootSnippetProps } from "../calendar/types.ts";
@ -106,3 +106,4 @@ export type {
} from "../calendar/types";

@ -1,15 +1,17 @@
<script lang="ts">
import { watch } from "runed";
import { readableActive, writableActive, mergeProps } from "../../utils/index";
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import { DateRangeFieldRootState } from "../date-range-field.svelte.ts";
import type { DateRangeFieldRootProps } from "../types.js";
import { createId, noop } from "../../utils/index";
import type { DateRange } from "$lib/glob/lib";
import { createId } from "../../utils/index";
import type { DateRange } from "$lib/util/dates";
import {
getDefaultDate,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import { resolveDateOrderProp, resolveHourCycleProp, resolveLocaleProp } from "../../base/config/prop-resolvers.ts";
import { noop } from '$lib/util/funcs';
const uid = $props.id();
@ -149,3 +151,5 @@
{/if}

@ -1,5 +1,5 @@
import { Context, watch } from "runed";
import type { DateValue, DatiDateOrder } from "$lib/glob/lib";
import type { DateValue, DateOrder } from "$lib/util/dates";
import type {
ActiveProps,
@ -13,10 +13,9 @@ import {
onDestroyEffect,
attachRef,
DOMContext,
useId,
createTerraAttrs,
boolToEmptyStrOrUndef
useId
} from "../utils";
import { createTerraAttrs, boolToEmptyStrOrUndef } from "../utils/attrs";
import { DateFieldInputState, DateFieldRootState } from "../date-field/date-field.svelte.ts";
@ -26,12 +25,12 @@ import type {
DateRange,
DateRangeValidator,
Granularity,
} from "$lib/glob/lib";
import { isBefore } from "$lib/glob/lib";
} from "$lib/util/dates";
import { isBefore } from "$lib/util/dates";
import type { SegmentPart } from "../utils/datetime/types.ts";
import { type Formatter, createFormatter } from "../utils/datetime/formatter.js";
import { removeDescriptionElement } from "../utils/datetime/field/helpers.js";
import { getFirstSegment } from "../utils/datetime/field/segments.ts";
import { type Formatter, createFormatter } from "../utils/datetime";
import { removeDescriptionElement } from "../utils/datetime/helpers.ts";
import { getFirstSegment } from "../utils/datetime/segments.ts";
export const dateRangeFieldAttrs = createTerraAttrs({
component: "date-range-field",
@ -61,7 +60,7 @@ interface DateRangeFieldRootStateOpts
granularity: Granularity | undefined;
hourCycle: 12 | 24 | undefined;
locale: string;
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
hideTimeZone: boolean;
required: boolean;
errorMessageId: string | undefined;
@ -308,3 +307,4 @@ export class DateRangeFieldInputState {
}

@ -9,3 +9,4 @@ export type {
DateRangeFieldInputProps as InputProps,
DateRangeFieldSegmentProps as SegmentProps,
} from "./types.js";

@ -1,2 +1,3 @@
export * as DateRangeField from "./exports.js";
export * from "./exports.js";

@ -1,4 +1,4 @@
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import type { OnChangeFn, WithChild, Without } from "../utils";
import type {
TerraPrimitiveDivAttributes,
@ -9,7 +9,7 @@ import type {
DateRange,
DateRangeValidator,
Granularity,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import type { EditableSegmentPart, SegmentPart } from "../utils/datetime/types.ts";
import type { TerraDateTimePresentationProps } from "../base/config/types";
import type {
@ -180,3 +180,5 @@ export type DateRangeFieldSegmentPropsWithoutHTML = DateFieldSegmentPropsWithout
export type DateRangeFieldSegmentProps = DateFieldSegmentProps;

@ -6,7 +6,7 @@
import {
handleSegmentNavigation,
isSegmentNavigationKey,
} from "../../utils/datetime/field/segments.ts";
} from "../../utils/datetime/segments.ts";
let { ref = $bindable(null), onkeydown, ...restProps }: DateRangePickerTriggerProps = $props();
@ -26,3 +26,4 @@
<PopoverTrigger {...restProps} bind:ref data-segment="trigger" {...mergedProps} />

@ -1,14 +1,14 @@
<script lang="ts">
import { watch } from "runed";
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import {
readableActive,
writableActive,
mergeProps,
noop,
useId,
} from "../../utils/index";
import { DateRangePickerRootState } from "../date-range-picker.svelte.ts";
import type { DateRangePickerRootProps } from "../types.ts";
@ -19,8 +19,9 @@
import {
type DateRange,
getDefaultDate
} from "$lib/glob/lib";
} from "$lib/util/dates";
import { resolveDateOrderProp, resolveHourCycleProp, resolveLocaleProp } from "../../base/config/prop-resolvers.ts";
import { noop } from '$lib/util/funcs';
let {
open = $bindable(false),
@ -244,3 +245,4 @@

@ -1,4 +1,4 @@
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import { Context } from "runed";
import { type ActiveProps, type StateProps } from "../utils";
import type {
@ -7,8 +7,8 @@ import type {
Granularity,
HourCycle,
WeekStartsOn,
DatiDateOrder,
} from "$lib/glob/lib";
DateOrder,
} from "$lib/util/dates";
import type { SegmentPart } from "../utils/datetime/types";
export const DateRangePickerRootContext = new Context<DateRangePickerRootState>(
@ -36,7 +36,7 @@ interface DateRangePickerRootStateOpts
granularity: Granularity | undefined;
hourCycle: HourCycle | undefined;
locale: string;
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
hideTimeZone: boolean;
required: boolean;
preventDeselect: boolean;
@ -66,3 +66,4 @@ export class DateRangePickerRootState {
}
}

@ -44,3 +44,4 @@ export type {
DateRangePickerMonthSelectProps as MonthSelectProps,
DateRangePickerYearSelectProps as YearSelectProps,
} from "./types.js";

@ -1,2 +1,3 @@
export * as DateRangePicker from "./exports.js";
export * from "./exports.js";
export * as DateRangePicker from "./exports.ts";
export * from "./exports.ts";

@ -1,4 +1,4 @@
import type { DateValue } from "$lib/glob/lib";
import type { DateValue } from "$lib/util/dates";
import type { OnChangeFn, WithChild, Without } from "../utils/types.ts";
import type { TerraPrimitiveDivAttributes } from "../utils/attributes";
import type {
@ -8,7 +8,7 @@ import type {
DateRangeValidator,
Granularity,
WeekStartsOn,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import type { EditableSegmentPart } from "../utils/datetime/types";
import type { TerraDateTimePresentationProps } from "../base/config/types";
import type { CalendarRootSnippetProps } from "../calendar/types.ts";
@ -358,3 +358,4 @@ export type {
RangeCalendarYearSelectPropsWithoutHTML as DateRangePickerYearSelectPropsWithoutHTML,
} from "../range-calendar/types";

@ -1,12 +1,12 @@
<script lang="ts">
import { watch } from "runed";
import { readableActive, writableActive, mergeProps } from "../../utils/index";
import { type DateValue } from "$lib/glob/lib";
import { type DateValue } from "$lib/util/dates";
import type { RangeCalendarRootProps } from "../types.js";
import { RangeCalendarRootState } from "../range-calendar.svelte.ts";
import { noop } from "../../utils/noop";
import { noop } from "$lib/util/funcs";
import { createId } from "../../utils/create-id";
import { getDefaultDate } from "$lib/glob/lib";
import { getDefaultDate } from "$lib/util/dates";
import { resolveDateOrderProp, resolveLocaleProp } from "../../base/config/prop-resolvers";
const uid = $props.id();
@ -156,3 +156,4 @@
</div>
{/if}

@ -29,3 +29,4 @@ export type {
RangeCalendarMonthSelectProps as MonthSelectProps,
RangeCalendarYearSelectProps as YearSelectProps,
} from "./types.js";

@ -1,2 +1,3 @@
export * as RangeCalendar from "./exports.js";
export * from "./exports.js";
export * as RangeCalendar from "./exports.ts";
export * from "./exports.ts";

@ -3,7 +3,7 @@ import {
type DateRange,
type Month,
type WeekStartsOn,
type DatiDateOrder,
type DateOrder,
getLocalTimeZone,
isSameDay,
isSameMonth,
@ -14,7 +14,7 @@ import {
isBefore,
isBetweenInclusive,
dateValueToDate as toDate,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import {
attachRef,
DOMContext,
@ -76,7 +76,7 @@ interface RangeCalendarRootStateOpts
fixedWeeks: boolean;
numberOfMonths: number;
locale: string;
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
calendarLabel: string;
readonly: boolean;
disableDaysOutsideMonth: boolean;
@ -924,3 +924,5 @@ export class RangeCalendarDayState {
);
}

@ -1,13 +1,13 @@
import type { DateValue, DatiDateOrder } from "$lib/glob/lib";
import type { DateValue, DateOrder } from "$lib/util/dates";
import type { TerraDatePresentationProps } from "../base/config/types";
import type { OnChangeFn, WithChild, Without } from "../utils/types";
import type { DateMatcher, DateRange, Month } from "$lib/glob/lib";
import type { DateMatcher, DateRange, Month } from "$lib/util/dates";
import type { TerraPrimitiveDivAttributes } from "../utils/attributes";
export type RangeCalendarRootSnippetProps = {
months: Month<DateValue>[];
weekdays: string[];
dateOrder: DatiDateOrder;
dateOrder: DateOrder;
};
export type RangeCalendarRootPropsWithoutHTML = WithChild<
@ -267,3 +267,4 @@ export type {
CalendarYearSelectPropsWithoutHTML as RangeCalendarYearSelectPropsWithoutHTML,
} from "../calendar/types.js";

@ -9,3 +9,4 @@
<HiddenInput {...hiddenInputState.props} />
{/if}

@ -1,8 +1,9 @@
<script lang="ts">
import { watch } from "runed";
import { readableActive, writableActive, noop } from "../../utils";
import { readableActive, writableActive } from "../../utils";
const noop = () => {};
import { resolveHourCycleProp, resolveLocaleProp } from "../../base/config/prop-resolvers.ts";
import { getDefaultTime, type TimeValue } from "$lib/glob/lib";
import { getDefaultTime, type TimeValue } from "$lib/util/dates";
import { TimeFieldRootState } from "../time-field.svelte.js";
import type { TimeFieldRootProps } from "../types.js";
@ -90,3 +91,5 @@
{@render children?.()}

@ -9,3 +9,4 @@ export type {
TimeFieldLabelProps as LabelProps,
TimeFieldSegmentProps as SegmentProps,
} from "./types.js";

@ -1,2 +1,3 @@
export * as TimeField from "./exports.js";
export * from "./exports.js";

@ -11,7 +11,7 @@ import {
dateValueToDate as toDate,
getISOTimeValue,
isTimeBefore,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import {
type State,
onDestroyEffect,
@ -28,12 +28,14 @@ import {
type TerraMouseEvent,
type RefAttachment,
type WithRefOpts,
kbd,
} from "../utils";
import {
boolToEmptyStrOrUndef,
boolToStr,
boolToStrTrueOrUndef,
createTerraAttrs,
kbd,
} from "../utils";
} from "../utils/attrs";
import { onMount, untrack } from "svelte";
import { Context, watch } from "runed";
import type {
@ -42,7 +44,7 @@ import type {
TimeSegmentPart,
} from "../utils/datetime/types";
import { type Announcer, getAnnouncer } from "../utils/datetime/announcer.ts";
import { type TimeFormatter, createTimeFormatter } from "../utils/datetime/formatter.ts";
import { type TimeFormatter, createTimeFormatter } from "../utils/datetime";
import {
areAllTimeSegmentsFilled,
createTimeContent,
@ -51,14 +53,14 @@ import {
isFirstTimeSegment,
removeTimeDescriptionElement,
setTimeDescription,
} from "../utils/datetime/field/time-helpers.ts";
} from "../utils/datetime/time-helpers.ts";
import {
getFirstTimeSegment,
handleTimeSegmentNavigation,
isSegmentNavigationKey,
moveToNextTimeSegment,
moveToPrevTimeSegment,
} from "../utils/datetime/field/segments.ts";
} from "../utils/datetime/segments.ts";
export const timeFieldAttrs = createTerraAttrs({
component: "time-field",
@ -1106,3 +1108,4 @@ function isAcceptableDayPeriodKey(key: string) {
}

@ -4,7 +4,7 @@ import type {
TimeOnInvalid,
TimeValidator,
TimeValue,
} from "$lib/glob/lib";
} from "$lib/util/dates";
import type { EditableTimeSegmentPart, TimeSegmentPart } from "../utils/datetime/types";
import type { TerraDateTimePresentationProps } from "../base/config/types";
import type { WithChildren, OnChangeFn, WithChild, Without } from "../utils/types";
@ -61,3 +61,5 @@ export type TimeFieldLabelPropsWithoutHTML = WithChild;
export type TimeFieldLabelProps = TimeFieldLabelPropsWithoutHTML &
Without<TerraPrimitiveDivAttributes, TimeFieldLabelPropsWithoutHTML>;

@ -45,3 +45,4 @@
<HiddenInput {...hiddenInputProps} />
{/if}

@ -1,7 +1,8 @@
<script lang="ts">
import { watch } from "runed";
import { readableActive, writableActive, createId, mergeProps, noop } from "../../utils/index";
import { getDefaultTime, type TimeRange, type TimeValue } from "$lib/glob/lib";
import { readableActive, writableActive, createId, mergeProps } from "../../utils/index";
const noop = () => {};
import { getDefaultTime, type TimeRange, type TimeValue } from "$lib/util/dates";
import { resolveHourCycleProp, resolveLocaleProp } from "../../base/config/prop-resolvers.ts";
import { TimeRangeFieldRootState } from "../time-range-field.svelte.ts";
import type { TimeRangeFieldRootProps } from "../types.js";
@ -132,3 +133,5 @@
{/if}

@ -9,3 +9,4 @@ export type {
TimeRangeFieldLabelProps as LabelProps,
TimeRangeFieldSegmentProps as SegmentProps,
} from "./types.js";

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.