@krak-stack/registry 0.10.5 → 0.10.7

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.
@@ -1,27 +1,36 @@
1
- export { TimeOnlySchema, MinuteStepSchema, getTimePickerState, parseTimeOnly, Time12HourSchema, parse12HourTime, } from "./time-picker.schema.js";
1
+ import { type TimePrecision } from "./time-picker.schema.js";
2
+ export { TimeOnlySchema, MinuteStepSchema, getTimePickerState, parseTimeOnly, Time12HourSchema, parse12HourTime, TimeSecondSchema, TimeMillisecondSchema, parseTimeValue, formatTimeValue, type TimePrecision, } from "./time-picker.schema.js";
2
3
  export type TimePickerMessages = {
3
4
  label: string;
4
5
  open: string;
5
6
  clear: string;
6
7
  hours: string;
7
8
  minutes: string;
9
+ seconds: string;
10
+ milliseconds: string;
8
11
  period: string;
9
12
  done: string;
10
13
  invalid: string;
11
14
  invalid12: string;
15
+ invalidSecond: string;
16
+ invalidMillisecond: string;
17
+ invalid12Second: string;
18
+ invalid12Millisecond: string;
12
19
  outOfRange: string;
13
20
  invalidRange: string;
14
21
  offStep: string;
15
22
  };
16
23
  export type TimePickerProps = {
17
- /** HH:mm, or an empty/incomplete draft while typing. */
24
+ /** Canonical 24-hour time at the selected precision, or a draft. */
18
25
  value: string;
19
26
  onValueChange: (value: string) => void;
20
27
  min?: string;
21
28
  max?: string;
22
29
  /** Allowed minute values start at 00 in each hour; integer from 1 to 60. */
23
30
  minuteStep?: number;
24
- /** Display and entry format. Values and bounds always use 24-hour HH:mm. */
31
+ /** Defaults to minute; seconds and milliseconds are opt-in. */
32
+ precision?: TimePrecision;
33
+ /** Display and entry format. Values and bounds always use 24-hour time. */
25
34
  hourCycle?: 12 | 24;
26
35
  label?: string;
27
36
  name?: string;
@@ -38,4 +47,4 @@ export type TimePickerProps = {
38
47
  columnClassName?: string;
39
48
  optionClassName?: string;
40
49
  };
41
- export declare const TimePicker: ({ value, onValueChange, min, max, minuteStep, hourCycle, label, name, required, disabled, readOnly, clearable, description, locale: override, messages, className, inputClassName, contentClassName, columnClassName, optionClassName, }: TimePickerProps) => import("react").JSX.Element;
50
+ export declare const TimePicker: ({ value, onValueChange, min, max, minuteStep, precision, hourCycle, label, name, required, disabled, readOnly, clearable, description, locale: override, messages, className, inputClassName, contentClassName, columnClassName, optionClassName, }: TimePickerProps) => import("react").JSX.Element;
@@ -115,14 +115,37 @@ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
115
115
  import { Option, Schema } from "effect";
116
116
  var TimeOnlySchema = Schema.String.check(Schema.isPattern(/^(?:[01]\d|2[0-3]):[0-5]\d$/)).annotate({ identifier: "TimeOnly" });
117
117
  var decodeTime = Schema.decodeUnknownOption(TimeOnlySchema);
118
+ var TimeSecondSchema = Schema.String.check(Schema.isPattern(/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/)).annotate({ identifier: "TimeSecond" });
119
+ var TimeMillisecondSchema = Schema.String.check(Schema.isPattern(/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d\.\d{3}$/)).annotate({ identifier: "TimeMillisecond" });
120
+ var timePrecisionUnit = (precision) => precision === "minute" ? 60000 : precision === "second" ? 1000 : 1;
121
+ var parseTimeValue = (value, precision = "minute") => {
122
+ const schema = precision === "minute" ? TimeOnlySchema : precision === "second" ? TimeSecondSchema : TimeMillisecondSchema;
123
+ if (!Schema.is(schema)(value))
124
+ return;
125
+ return Number(value.slice(0, 2)) * 3600000 + Number(value.slice(3, 5)) * 60000 + (precision === "minute" ? 0 : Number(value.slice(6, 8)) * 1000) + (precision === "millisecond" ? Number(value.slice(9)) : 0);
126
+ };
127
+ var formatTimeValue = (value, precision) => {
128
+ const pad = (value, width = 2) => String(value).padStart(width, "0");
129
+ const minute = `${pad(Math.floor(value / 3600000))}:${pad(Math.floor(value / 60000) % 60)}`;
130
+ const second = `${minute}:${pad(Math.floor(value / 1000) % 60)}`;
131
+ return precision === "minute" ? minute : precision === "second" ? second : `${second}.${pad(value % 1000, 3)}`;
132
+ };
118
133
  var Time12HourSchema = Schema.String.check(Schema.isPattern(/^(?:0?[1-9]|1[0-2]):[0-5]\d\s?(?:AM|PM)$/i)).annotate({ identifier: "Time12Hour" });
119
- var decode12Hour = Schema.decodeUnknownOption(Time12HourSchema);
120
- var parse12HourTime = (value) => {
121
- if (Option.isNone(decode12Hour(value)))
134
+ var Time12HourSecondSchema = Schema.String.check(Schema.isPattern(/^(?:0?[1-9]|1[0-2]):[0-5]\d:[0-5]\d\s?(?:AM|PM)$/i)).annotate({ identifier: "Time12HourSecond" });
135
+ var Time12HourMillisecondSchema = Schema.String.check(Schema.isPattern(/^(?:0?[1-9]|1[0-2]):[0-5]\d:[0-5]\d\.\d{3}\s?(?:AM|PM)$/i)).annotate({ identifier: "Time12HourMillisecond" });
136
+ var parse12HourTime = (value, precision = "minute") => {
137
+ const schema = precision === "minute" ? Time12HourSchema : precision === "second" ? Time12HourSecondSchema : Time12HourMillisecondSchema;
138
+ if (!Schema.is(schema)(value))
139
+ return;
140
+ const suffix = value.match(/\s?(AM|PM)$/i);
141
+ if (!suffix)
122
142
  return;
123
- const [hourText, rest] = value.split(":");
124
- const hour = Number(hourText) % 12 + (value.toUpperCase().endsWith("PM") ? 12 : 0);
125
- return `${String(hour).padStart(2, "0")}:${rest.slice(0, 2)}`;
143
+ const clock = value.slice(0, suffix.index);
144
+ const hourText = clock.split(":")[0];
145
+ const normalized = `${hourText.padStart(2, "0")}${clock.slice(hourText.length)}`;
146
+ const hour = Number(hourText);
147
+ const canonicalHour = hour % 12 + (value.toUpperCase().endsWith("PM") ? 12 : 0);
148
+ return `${String(canonicalHour).padStart(2, "0")}${normalized.slice(2)}`;
126
149
  };
127
150
  var parseTimeOnly = (value) => {
128
151
  const decoded = decodeTime(value);
@@ -133,26 +156,35 @@ var getTimePickerState = ({
133
156
  value,
134
157
  min,
135
158
  max,
136
- minuteStep = 1
159
+ minuteStep = 1,
160
+ precision = "minute"
137
161
  }) => {
138
- if (!Schema.is(MinuteStepSchema)(minuteStep) || min !== undefined && parseTimeOnly(min) === undefined || max !== undefined && parseTimeOnly(max) === undefined || min && max && min > max)
162
+ if (!Schema.is(MinuteStepSchema)(minuteStep) || min !== undefined && parseTimeValue(min, precision) === undefined || max !== undefined && parseTimeValue(max, precision) === undefined || min && max && min > max)
139
163
  return "invalid-range";
140
- const minimum = parseTimeOnly(min ?? "00:00");
141
- const maximum = parseTimeOnly(max ?? "23:59");
142
- const hasChoice = Array.from({ length: maximum - minimum + 1 }, (_, i) => minimum + i).some((time) => time % 60 % minuteStep === 0);
164
+ const minimum = min === undefined ? 0 : parseTimeValue(min, precision);
165
+ const maximum = max === undefined ? 86400000 - timePrecisionUnit(precision) : parseTimeValue(max, precision);
166
+ const hasChoice = getTimeIntervals(minimum, maximum, minuteStep, precision).length > 0;
143
167
  if (!hasChoice)
144
168
  return "invalid-range";
145
169
  if (!value)
146
170
  return "empty";
147
- const time = parseTimeOnly(value);
171
+ const time = parseTimeValue(value, precision);
148
172
  if (time === undefined)
149
173
  return "invalid";
150
174
  if (time < minimum || time > maximum)
151
175
  return "out-of-range";
152
- if (time % 60 % minuteStep !== 0)
176
+ if (Math.floor(time / 60000) % 60 % minuteStep !== 0)
153
177
  return "off-step";
154
178
  return "valid";
155
179
  };
180
+ var getTimeIntervals = (minimum, maximum, minuteStep, precision) => {
181
+ const unit = timePrecisionUnit(precision);
182
+ return Array.from({ length: 1440 }, (_, minute) => {
183
+ const start = Math.max(minimum, minute * 60000);
184
+ const end = Math.min(maximum, (minute + 1) * 60000 - unit);
185
+ return { start, end, minute };
186
+ }).filter(({ start, end, minute }) => start <= end && minute % 60 % minuteStep === 0);
187
+ };
156
188
 
157
189
  // ../../src/components/ui/time-picker.tsx
158
190
  import { jsx as jsx4, jsxs } from "react/jsx-runtime";
@@ -164,10 +196,16 @@ var labels = {
164
196
  clear: "Clear time",
165
197
  hours: "Hours",
166
198
  minutes: "Minutes",
199
+ seconds: "Seconds",
200
+ milliseconds: "Milliseconds",
167
201
  period: "AM/PM",
168
202
  done: "Done",
169
203
  invalid: "Enter a valid time as HH:mm (00:00–23:59).",
170
204
  invalid12: "Enter a valid time with AM or PM, such as 09:30 AM.",
205
+ invalidSecond: "Enter a valid time as HH:mm:ss (00:00:00–23:59:59).",
206
+ invalidMillisecond: "Enter a valid time as HH:mm:ss.SSS (00:00:00.000–23:59:59.999).",
207
+ invalid12Second: "Enter a valid time with seconds and AM or PM, such as 09:30:15 AM.",
208
+ invalid12Millisecond: "Enter a valid time with milliseconds and AM or PM, such as 09:30:15.123 AM.",
171
209
  outOfRange: "Choose a time within the allowed range.",
172
210
  invalidRange: "The allowed time range or minute step is invalid.",
173
211
  offStep: "Choose a time that matches the minute step."
@@ -178,17 +216,22 @@ var labels = {
178
216
  clear: "Effacer l’heure",
179
217
  hours: "Heures",
180
218
  minutes: "Minutes",
219
+ seconds: "Secondes",
220
+ milliseconds: "Millisecondes",
181
221
  period: "AM/PM",
182
222
  done: "Terminer",
183
223
  invalid: "Saisissez une heure valide au format HH:mm (00:00–23:59).",
184
224
  invalid12: "Saisissez une heure valide avec AM ou PM, par exemple 09:30 AM.",
225
+ invalidSecond: "Saisissez une heure valide au format HH:mm:ss (00:00:00–23:59:59).",
226
+ invalidMillisecond: "Saisissez une heure valide au format HH:mm:ss.SSS (00:00:00.000–23:59:59.999).",
227
+ invalid12Second: "Saisissez une heure valide avec les secondes et AM ou PM, par exemple 09:30:15 AM.",
228
+ invalid12Millisecond: "Saisissez une heure valide avec les millisecondes et AM ou PM, par exemple 09:30:15.123 AM.",
185
229
  outOfRange: "Choisissez une heure dans la plage autorisée.",
186
230
  invalidRange: "La plage horaire ou le pas des minutes est invalide.",
187
231
  offStep: "Choisissez une heure qui respecte le pas des minutes."
188
232
  }
189
233
  };
190
234
  var pad = (value) => String(value).padStart(2, "0");
191
- var formatTime = (value) => `${pad(Math.floor(value / 60))}:${pad(value % 60)}`;
192
235
  var TimeColumn = ({
193
236
  label,
194
237
  values,
@@ -264,6 +307,7 @@ var TimePicker = ({
264
307
  min,
265
308
  max,
266
309
  minuteStep = 1,
310
+ precision = "minute",
267
311
  hourCycle = 12,
268
312
  label,
269
313
  name,
@@ -289,28 +333,51 @@ var TimePicker = ({
289
333
  };
290
334
  const [open, setOpen] = useState(false);
291
335
  const [draft, setDraft] = useState();
292
- const activeDraft = draft?.value === value && draft.hourCycle === hourCycle ? draft : undefined;
293
- const canonicalStatus = getTimePickerState({ value, min, max, minuteStep });
294
- const status = canonicalStatus !== "invalid-range" && hourCycle === 12 && activeDraft?.text && !parse12HourTime(activeDraft.text) ? "invalid" : canonicalStatus;
295
- const parsedValue = parseTimeOnly(value);
296
- const displayValue = activeDraft?.text ?? (hourCycle === 12 && parsedValue !== undefined ? `${Math.floor(parsedValue / 60) % 12 || 12}:${pad(parsedValue % 60)} ${parsedValue < 720 ? "AM" : "PM"}` : value);
297
- const error = status === "invalid" ? hourCycle === 12 ? copy.invalid12 : copy.invalid : status === "invalid-range" ? copy.invalidRange : status === "out-of-range" ? copy.outOfRange : status === "off-step" ? copy.offStep : undefined;
298
- const locked = disabled || readOnly;
299
- const times = status === "invalid-range" ? [] : Array.from({ length: 1440 }, (_, time) => time).filter((time) => {
300
- const text = formatTime(time);
301
- return (!min || text >= min) && (!max || text <= max) && time % 60 % minuteStep === 0;
336
+ const activeDraft = draft?.value === value && draft.hourCycle === hourCycle && draft.precision === precision ? draft : undefined;
337
+ const canonicalStatus = getTimePickerState({
338
+ value,
339
+ min,
340
+ max,
341
+ minuteStep,
342
+ precision
302
343
  });
303
- const selected = status === "valid" ? parseTimeOnly(value) : times[0] ?? 0;
304
- const hour = Math.floor(selected / 60);
344
+ const status = canonicalStatus !== "invalid-range" && hourCycle === 12 && activeDraft?.text && !parse12HourTime(activeDraft.text, precision) ? "invalid" : canonicalStatus;
345
+ const parsedValue = parseTimeValue(value, precision);
346
+ const displayValue = activeDraft?.text ?? (hourCycle === 12 && parsedValue !== undefined ? `${Math.floor(parsedValue / 3600000) % 12 || 12}${value.slice(2)} ${parsedValue < 43200000 ? "AM" : "PM"}` : value);
347
+ const error = status === "invalid" ? hourCycle === 12 ? precision === "minute" ? copy.invalid12 : precision === "second" ? copy.invalid12Second : copy.invalid12Millisecond : precision === "minute" ? copy.invalid : precision === "second" ? copy.invalidSecond : copy.invalidMillisecond : status === "invalid-range" ? copy.invalidRange : status === "out-of-range" ? copy.outOfRange : status === "off-step" ? copy.offStep : undefined;
348
+ const locked = disabled || readOnly;
349
+ const unit = timePrecisionUnit(precision);
350
+ const intervals = status === "invalid-range" ? [] : getTimeIntervals(min === undefined ? 0 : parseTimeValue(min, precision), max === undefined ? 86400000 - unit : parseTimeValue(max, precision), minuteStep, precision);
351
+ const selected = status === "valid" ? parsedValue : intervals[0]?.start ?? 0;
352
+ const hour = Math.floor(selected / 3600000);
353
+ const minute = Math.floor(selected / 60000) % 60;
354
+ const second = Math.floor(selected / 1000) % 60;
305
355
  const period = Math.floor(hour / 12);
306
- const periods = [...new Set(times.map((time) => Math.floor(time / 720)))];
356
+ const periods = [
357
+ ...new Set(intervals.map(({ minute }) => Math.floor(minute / 720)))
358
+ ];
307
359
  const hours = [
308
- ...new Set(times.filter((time) => hourCycle === 24 || Math.floor(time / 720) === period).map((time) => Math.floor(time / 60)))
360
+ ...new Set(intervals.filter(({ minute }) => hourCycle === 24 || Math.floor(minute / 720) === period).map(({ minute }) => Math.floor(minute / 60)))
309
361
  ].sort((left, right) => hourCycle === 12 ? (left % 12 || 12) - (right % 12 || 12) : left - right);
310
- const minutes = times.filter((time) => Math.floor(time / 60) === hour).map((time) => time % 60);
362
+ const minutes = intervals.filter(({ minute }) => Math.floor(minute / 60) === hour).map(({ minute }) => minute % 60);
363
+ const current = intervals.find((interval) => interval.minute === Math.floor(selected / 60000));
364
+ const seconds = Array.from({ length: 60 }, (_, second) => second).filter((second) => {
365
+ const start = hour * 3600000 + minute * 60000 + second * 1000;
366
+ return current && start <= current.end && start + 1000 - unit >= current.start;
367
+ });
368
+ const milliseconds = Array.from({ length: 1000 }, (_, millisecond) => millisecond).filter((millisecond) => {
369
+ const time = Math.floor(selected / 1000) * 1000 + millisecond;
370
+ return current && time >= current.start && time <= current.end;
371
+ });
372
+ const selectClosest = (desired, choices = intervals) => {
373
+ const candidates = choices.map(({ start, end }) => Math.max(start, Math.min(end, desired)));
374
+ const closest = candidates.reduce((best, time) => best === undefined || Math.abs(time - desired) < Math.abs(best - desired) ? time : best, undefined);
375
+ if (closest !== undefined)
376
+ select(closest);
377
+ };
311
378
  const select = (time) => {
312
- const next = formatTime(time);
313
- if (!locked && getTimePickerState({ value: next, min, max, minuteStep }) === "valid") {
379
+ const next = formatTimeValue(time, precision);
380
+ if (!locked && getTimePickerState({ value: next, min, max, minuteStep, precision }) === "valid") {
314
381
  setDraft(undefined);
315
382
  onValueChange(next);
316
383
  }
@@ -340,7 +407,7 @@ var TimePicker = ({
340
407
  ref: (element) => {
341
408
  element?.setCustomValidity(error ?? "");
342
409
  },
343
- placeholder: hourCycle === 12 ? "hh:mm AM/PM" : "HH:mm",
410
+ placeholder: `${hourCycle === 12 ? "hh" : "HH"}:mm${precision === "minute" ? "" : ":ss"}${precision === "millisecond" ? ".SSS" : ""}${hourCycle === 12 ? " AM/PM" : ""}`,
344
411
  autoComplete: "off",
345
412
  spellCheck: false,
346
413
  "aria-invalid": Boolean(error),
@@ -351,12 +418,12 @@ var TimePicker = ({
351
418
  if (locked)
352
419
  return;
353
420
  const text = event.target.value;
354
- const next = hourCycle === 12 ? parse12HourTime(text) ?? text : text;
355
- setDraft({ text, value: next, hourCycle });
421
+ const next = hourCycle === 12 ? parse12HourTime(text, precision) ?? text : text;
422
+ setDraft({ text, value: next, hourCycle, precision });
356
423
  onValueChange(next);
357
424
  },
358
425
  onBlur: () => {
359
- if (activeDraft && (hourCycle === 24 || parse12HourTime(activeDraft.text)))
426
+ if (activeDraft && (hourCycle === 24 || parse12HourTime(activeDraft.text, precision)))
360
427
  setDraft(undefined);
361
428
  }
362
429
  }),
@@ -386,7 +453,7 @@ var TimePicker = ({
386
453
  /* @__PURE__ */ jsxs(PopoverContent, {
387
454
  align: "end",
388
455
  "data-component": "time-picker-content",
389
- className: cn("max-h-[calc(100dvh-2rem)] w-72 max-w-[calc(100vw-2rem)] gap-3 overflow-y-auto", contentClassName),
456
+ className: cn("max-h-[calc(100dvh-2rem)] max-w-[calc(100vw-2rem)] gap-3 overflow-y-auto", precision === "millisecond" ? "w-112" : precision === "second" ? "w-96" : "w-72", contentClassName),
390
457
  children: [
391
458
  /* @__PURE__ */ jsx4(PopoverTitle, {
392
459
  className: "sr-only",
@@ -394,7 +461,7 @@ var TimePicker = ({
394
461
  }),
395
462
  /* @__PURE__ */ jsxs("div", {
396
463
  "data-slot": "time-picker-columns",
397
- className: cn("grid gap-3", hourCycle === 12 ? "grid-cols-3" : "grid-cols-2"),
464
+ className: cn("grid gap-3", precision === "millisecond" ? hourCycle === 12 ? "grid-cols-5" : "grid-cols-4" : precision === "second" ? hourCycle === 12 ? "grid-cols-4" : "grid-cols-3" : hourCycle === 12 ? "grid-cols-3" : "grid-cols-2"),
398
465
  children: [
399
466
  /* @__PURE__ */ jsx4(TimeColumn, {
400
467
  label: copy.hours,
@@ -404,19 +471,44 @@ var TimePicker = ({
404
471
  format: hourCycle === 12 ? (hour) => String(hour % 12 || 12) : pad,
405
472
  optionClassName,
406
473
  onSelect: (nextHour) => {
407
- const choices = times.filter((time) => Math.floor(time / 60) === nextHour);
408
- const closest = choices.reduce((best, time) => Math.abs(time % 60 - selected % 60) < Math.abs(best % 60 - selected % 60) ? time : best, choices[0]);
409
- select(closest);
474
+ selectClosest(nextHour * 3600000 + selected % 3600000, intervals.filter(({ minute }) => Math.floor(minute / 60) === nextHour));
410
475
  }
411
476
  }),
412
477
  /* @__PURE__ */ jsx4(TimeColumn, {
413
478
  label: copy.minutes,
414
479
  values: minutes,
415
- selected: selected % 60,
480
+ selected: minute,
416
481
  className: columnClassName,
417
482
  optionClassName,
418
- onSelect: (minute) => select(hour * 60 + minute)
483
+ onSelect: (minute) => selectClosest(hour * 3600000 + minute * 60000 + selected % 60000, intervals.filter((interval) => interval.minute === hour * 60 + minute))
419
484
  }),
485
+ precision !== "minute" ? /* @__PURE__ */ jsx4(TimeColumn, {
486
+ label: copy.seconds,
487
+ values: seconds,
488
+ selected: second,
489
+ className: columnClassName,
490
+ optionClassName,
491
+ onSelect: (second) => {
492
+ const start = Math.floor(selected / 60000) * 60000 + second * 1000;
493
+ if (current)
494
+ selectClosest(start + selected % 1000, [
495
+ {
496
+ ...current,
497
+ start: Math.max(current.start, start),
498
+ end: Math.min(current.end, start + 1000 - unit)
499
+ }
500
+ ]);
501
+ }
502
+ }) : null,
503
+ precision === "millisecond" ? /* @__PURE__ */ jsx4(TimeColumn, {
504
+ label: copy.milliseconds,
505
+ values: milliseconds,
506
+ selected: selected % 1000,
507
+ format: (value) => String(value).padStart(3, "0"),
508
+ className: columnClassName,
509
+ optionClassName,
510
+ onSelect: (millisecond) => select(Math.floor(selected / 1000) * 1000 + millisecond)
511
+ }) : null,
420
512
  hourCycle === 12 ? /* @__PURE__ */ jsx4(TimeColumn, {
421
513
  label: copy.period,
422
514
  values: periods,
@@ -425,10 +517,8 @@ var TimePicker = ({
425
517
  className: columnClassName,
426
518
  optionClassName,
427
519
  onSelect: (nextPeriod) => {
428
- const desired = (hour % 12 + nextPeriod * 12) * 60 + selected % 60;
429
- const choices = times.filter((time) => Math.floor(time / 720) === nextPeriod);
430
- const closest = choices.reduce((best, time) => Math.abs(time - desired) < Math.abs(best - desired) ? time : best, choices[0]);
431
- select(closest);
520
+ const desired = (hour % 12 + nextPeriod * 12) * 3600000 + selected % 3600000;
521
+ selectClosest(desired, intervals.filter(({ minute }) => Math.floor(minute / 720) === nextPeriod));
432
522
  }
433
523
  }) : null
434
524
  ]
@@ -480,9 +570,13 @@ var TimePicker = ({
480
570
  export {
481
571
  MinuteStepSchema,
482
572
  Time12HourSchema,
573
+ TimeMillisecondSchema,
483
574
  TimeOnlySchema,
484
575
  TimePicker,
576
+ TimeSecondSchema,
577
+ formatTimeValue,
485
578
  getTimePickerState,
486
579
  parse12HourTime,
487
- parseTimeOnly
580
+ parseTimeOnly,
581
+ parseTimeValue
488
582
  };
@@ -1,14 +1,28 @@
1
1
  import { Schema } from "effect";
2
2
  /** A wall-clock time, never a date, instant or time zone. */
3
3
  export declare const TimeOnlySchema: Schema.String;
4
+ export type TimePrecision = "minute" | "second" | "millisecond";
5
+ export declare const TimeSecondSchema: Schema.String;
6
+ export declare const TimeMillisecondSchema: Schema.String;
7
+ export declare const timePrecisionUnit: (precision: TimePrecision) => 1 | 1000 | 60000;
8
+ /** Milliseconds since midnight; unlike parseTimeOnly, supports explicit precision. */
9
+ export declare const parseTimeValue: (value: string, precision?: TimePrecision) => number | undefined;
10
+ export declare const formatTimeValue: (value: number, precision: TimePrecision) => string;
4
11
  export declare const Time12HourSchema: Schema.String;
5
12
  /** Convert display text to canonical HH:mm; 12 AM is midnight, 12 PM is noon. */
6
- export declare const parse12HourTime: (value: string) => string | undefined;
13
+ export declare const parse12HourTime: (value: string, precision?: TimePrecision) => string | undefined;
7
14
  export declare const parseTimeOnly: (value: string) => number | undefined;
8
15
  export declare const MinuteStepSchema: Schema.Number;
9
- export declare const getTimePickerState: ({ value, min, max, minuteStep, }: {
16
+ export declare const getTimePickerState: ({ value, min, max, minuteStep, precision, }: {
10
17
  value: string;
11
18
  min?: string;
12
19
  max?: string;
13
20
  minuteStep?: number;
21
+ precision?: TimePrecision;
14
22
  }) => "empty" | "invalid" | "invalid-range" | "off-step" | "out-of-range" | "valid";
23
+ /** At most 1,440 minute buckets, never 86 million millisecond options. */
24
+ export declare const getTimeIntervals: (minimum: number, maximum: number, minuteStep: number, precision: TimePrecision) => {
25
+ start: number;
26
+ end: number;
27
+ minute: number;
28
+ }[];
@@ -0,0 +1,26 @@
1
+ import { type RichTextVariable, type RichTextDocument } from "../rich-text/schema.js";
2
+ import { EmailDocument, type EmailElement } from "./schema.js";
3
+ export declare const emailElementTypes: readonly ["text", "button", "code", "logo", "image", "divider", "spacer"];
4
+ export type EmailElementType = (typeof emailElementTypes)[number];
5
+ export declare const newEmailElement: (type: EmailElementType, input: {
6
+ id: string;
7
+ text: string;
8
+ button: string;
9
+ imageAlt: string;
10
+ codeVariable?: string;
11
+ urlVariable?: string;
12
+ }) => EmailElement;
13
+ export declare const interpolateEmailText: (text: string, values: Readonly<Record<string, string>>) => string;
14
+ /** Keep header templates as strings while editing variables as atomic rich-text nodes. */
15
+ export declare const richTextFromEmailText: (text: string) => RichTextDocument;
16
+ export declare const emailDocumentReferences: (document: EmailDocument) => string[];
17
+ export type EmailDocumentIssue = {
18
+ code: "invalid-document" | "unknown-variable" | "missing-variable" | "invalid-url" | "missing-required-variable";
19
+ key?: string;
20
+ };
21
+ export declare const validateEmailDocument: ({ document, variables, values, requiredVariables, }: {
22
+ document: EmailDocument;
23
+ variables: readonly RichTextVariable[];
24
+ values?: Readonly<Record<string, string>>;
25
+ requiredVariables?: readonly string[];
26
+ }) => EmailDocumentIssue[];