@burdenoff/microfe-timecampus 2026.1206.1 → 2026.1206.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/timecampus/components/DateFields.d.ts +53 -0
- package/dist/timecampus/components/DateFields.js +87 -0
- package/dist/timecampus/components/DateFields.js.map +1 -0
- package/dist/timecampus/components/dateFieldValues.d.ts +39 -0
- package/dist/timecampus/components/dateFieldValues.js +49 -0
- package/dist/timecampus/components/dateFieldValues.js.map +1 -0
- package/dist/timecampus/pages/email-tracking/EmailTrackingPage.js +112 -111
- package/dist/timecampus/pages/email-tracking/EmailTrackingPage.js.map +1 -1
- package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js +65 -65
- package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js.map +1 -1
- package/dist/timecampus/pages/focus/FocusProtectionPage.js +250 -253
- package/dist/timecampus/pages/focus/FocusProtectionPage.js.map +1 -1
- package/dist/timecampus/pages/invoicing/InvoicingPage.js +259 -258
- package/dist/timecampus/pages/invoicing/InvoicingPage.js.map +1 -1
- package/dist/timecampus/pages/lifetime/FiniteLifePage.js +103 -103
- package/dist/timecampus/pages/lifetime/FiniteLifePage.js.map +1 -1
- package/dist/timecampus/pages/lifetime/LifeTimelinePage.js +38 -38
- package/dist/timecampus/pages/lifetime/LifeTimelinePage.js.map +1 -1
- package/dist/timecampus/pages/location-tracking/LocationTrackingPage.js +218 -216
- package/dist/timecampus/pages/location-tracking/LocationTrackingPage.js.map +1 -1
- package/dist/timecampus/pages/meetings/ActionItemFormModal.js +64 -63
- package/dist/timecampus/pages/meetings/ActionItemFormModal.js.map +1 -1
- package/dist/timecampus/pages/meetings/MeetingCreatePage.js +54 -54
- package/dist/timecampus/pages/meetings/MeetingCreatePage.js.map +1 -1
- package/dist/timecampus/pages/meetings/MeetingFormModal.js +98 -96
- package/dist/timecampus/pages/meetings/MeetingFormModal.js.map +1 -1
- package/dist/timecampus/pages/pomodoro/PomodoroPage.js +150 -149
- package/dist/timecampus/pages/pomodoro/PomodoroPage.js.map +1 -1
- package/dist/timecampus/pages/projects/TasksPage.js +183 -182
- package/dist/timecampus/pages/projects/TasksPage.js.map +1 -1
- package/dist/timecampus/pages/resource-planning/ResourcePlanningPage.js +346 -351
- package/dist/timecampus/pages/resource-planning/ResourcePlanningPage.js.map +1 -1
- package/dist/timecampus/pages/time/TimeEntriesPage.js +129 -127
- package/dist/timecampus/pages/time/TimeEntriesPage.js.map +1 -1
- package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js +46 -47
- package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js.map +1 -1
- package/dist/timecampus/pages/timeline/TimelinePage.js +231 -231
- package/dist/timecampus/pages/timeline/TimelinePage.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface DateFieldProps {
|
|
2
|
+
/** `YYYY-MM-DD`, or `""` for none. */
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
/** What the date is ("Due date"): the picker's accessible name. */
|
|
6
|
+
label: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
min?: string;
|
|
9
|
+
max?: string;
|
|
10
|
+
/** Show a clear button while there is a date. */
|
|
11
|
+
clearable?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Sits in a row of controls (a toolbar) instead of filling a form column under its label:
|
|
16
|
+
* no top margin, and the button keeps its own width.
|
|
17
|
+
*/
|
|
18
|
+
inline?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function DateField({ value, onChange, label, placeholder, min, max, clearable, disabled, id, inline, }: DateFieldProps): import('react').JSX.Element;
|
|
21
|
+
export interface TimeFieldProps {
|
|
22
|
+
/** `HH:mm`, 24-hour, or `""` for none. */
|
|
23
|
+
value: string;
|
|
24
|
+
onChange: (value: string) => void;
|
|
25
|
+
/** What the time is ("Workday start"): the picker's accessible name. */
|
|
26
|
+
label: string;
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Minutes between the listed times. Default 15. */
|
|
29
|
+
step?: number;
|
|
30
|
+
minTime?: string;
|
|
31
|
+
maxTime?: string;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
id?: string;
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function TimeField({ value, onChange, label, placeholder, step, minTime, maxTime, disabled, id, className, }: TimeFieldProps): import('react').JSX.Element;
|
|
37
|
+
export interface DateTimeFieldProps {
|
|
38
|
+
/** `YYYY-MM-DDTHH:mm` in local time, or `""` for none. */
|
|
39
|
+
value: string;
|
|
40
|
+
onChange: (value: string) => void;
|
|
41
|
+
/** What the moment is ("Start"): the pickers are named "<label> date" and "<label> time". */
|
|
42
|
+
label: string;
|
|
43
|
+
/** The latest moment, `YYYY-MM-DDTHH:mm`. */
|
|
44
|
+
max?: string;
|
|
45
|
+
/** Minutes between the listed times. Default 15. */
|
|
46
|
+
step?: number;
|
|
47
|
+
/** Show a clear button while there is a value. */
|
|
48
|
+
clearable?: boolean;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/** The day picker's id, for a `<label htmlFor>`. */
|
|
51
|
+
id?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function DateTimeField({ value, onChange, label, max, step, clearable, disabled, id, }: DateTimeFieldProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { isDateString as e, isTimeString as t, maxTimeOn as n, splitDateTime as r, withPickedDate as i, withPickedTime as a } from "./dateFieldValues.js";
|
|
2
|
+
import { X as o } from "lucide-react";
|
|
3
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
|
+
import { DatePicker as l, TimePicker as u } from "@burdenoff/fe-libs/ui";
|
|
5
|
+
// src/timecampus/components/DateFields.tsx
|
|
6
|
+
var d = "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-action-primary-bg/40";
|
|
7
|
+
function f({ label: e, onClear: t }) {
|
|
8
|
+
return /* @__PURE__ */ s("button", {
|
|
9
|
+
type: "button",
|
|
10
|
+
onClick: t,
|
|
11
|
+
"aria-label": `Clear ${e.toLowerCase()}`,
|
|
12
|
+
title: `Clear ${e.toLowerCase()}`,
|
|
13
|
+
className: d,
|
|
14
|
+
children: /* @__PURE__ */ s(o, {
|
|
15
|
+
className: "h-4 w-4",
|
|
16
|
+
"aria-hidden": !0
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
var p = "mt-1 flex w-full items-center gap-1";
|
|
21
|
+
function m({ value: t, onChange: n, label: r, placeholder: i, min: a, max: o, clearable: u = !1, disabled: d, id: m, inline: h = !1 }) {
|
|
22
|
+
let g = /* @__PURE__ */ s(l, {
|
|
23
|
+
id: m,
|
|
24
|
+
value: e(t) ? t : null,
|
|
25
|
+
onChange: n,
|
|
26
|
+
label: r,
|
|
27
|
+
placeholder: i,
|
|
28
|
+
min: e(a) ? a : void 0,
|
|
29
|
+
max: e(o) ? o : void 0,
|
|
30
|
+
disabled: d,
|
|
31
|
+
className: h ? void 0 : "min-w-0 flex-1"
|
|
32
|
+
});
|
|
33
|
+
return h && !u ? g : /* @__PURE__ */ c("span", {
|
|
34
|
+
className: h ? "flex items-center gap-1" : p,
|
|
35
|
+
children: [g, t && !d ? /* @__PURE__ */ s(f, {
|
|
36
|
+
label: r,
|
|
37
|
+
onClear: () => n("")
|
|
38
|
+
}) : null]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function h({ value: e, onChange: n, label: r, placeholder: i, step: a, minTime: o, maxTime: c, disabled: l, id: d, className: f }) {
|
|
42
|
+
return /* @__PURE__ */ s(u, {
|
|
43
|
+
id: d,
|
|
44
|
+
value: t(e) ? e : null,
|
|
45
|
+
onChange: (e) => n(e),
|
|
46
|
+
label: r,
|
|
47
|
+
placeholder: i,
|
|
48
|
+
step: a,
|
|
49
|
+
minTime: o,
|
|
50
|
+
maxTime: c,
|
|
51
|
+
disabled: l,
|
|
52
|
+
className: f
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function g({ value: e, onChange: t, label: o, max: d, step: p, clearable: m = !1, disabled: h, id: g }) {
|
|
56
|
+
let { date: _, time: v } = r(e), y = r(d).date ?? void 0;
|
|
57
|
+
return /* @__PURE__ */ c("span", {
|
|
58
|
+
className: "flex flex-wrap items-center gap-2",
|
|
59
|
+
"data-slot": "date-time-field",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ s(l, {
|
|
62
|
+
id: g,
|
|
63
|
+
value: _,
|
|
64
|
+
onChange: (n) => t(i(e, n, d)),
|
|
65
|
+
label: `${o} date`,
|
|
66
|
+
max: y,
|
|
67
|
+
disabled: h,
|
|
68
|
+
className: "min-w-0 flex-1"
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ s(u, {
|
|
71
|
+
value: v,
|
|
72
|
+
onChange: (n) => t(a(e, n, d)),
|
|
73
|
+
label: `${o} time`,
|
|
74
|
+
step: p,
|
|
75
|
+
maxTime: n(_, d),
|
|
76
|
+
disabled: h
|
|
77
|
+
}),
|
|
78
|
+
m && e && !h ? /* @__PURE__ */ s(f, {
|
|
79
|
+
label: o,
|
|
80
|
+
onClear: () => t("")
|
|
81
|
+
}) : null
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export { m as DateField, g as DateTimeField, h as TimeField };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=DateFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateFields.js","names":["CLEAR_BUTTON_CLASS","ClearButton","onClear","label","X","FORM_FIELD_CLASS","DateField","picker","DatePicker","isDateString","value","min","max","inline","clearable","disabled","onChange","TimeField","TimePicker","isTimeString","time","DateTimeField","splitDateTime","maxDate","date","withPickedDate","picked","withPickedTime","maxTimeOn"],"sources":["../../../src/timecampus/components/DateFields.tsx"],"sourcesContent":["/**\n * BOFF-18708: the module's date and time fields, on fe-libs' themed pickers.\n *\n * Native `<input type=\"date\">`, `type=\"time\"` and `type=\"datetime-local\"` fields draw the\n * browser's own control, which ignores the app theme in dark mode. These wrap fe-libs'\n * `DatePicker` and `TimePicker` and keep the native string values (see `dateFieldValues`), so a\n * page swaps its input for a field without touching its form state.\n *\n * - `DateField`: `YYYY-MM-DD`, `\"\"` when empty.\n * - `TimeField`: `HH:mm`, 24-hour.\n * - `DateTimeField`: `YYYY-MM-DDTHH:mm` in local time, a day picker and a time picker side by\n * side. Picking a day first keeps 09:00 as the time; picking a time first takes today.\n *\n * A field with `clearable` shows a clear button while it has a value, as the native optional\n * date fields could be emptied.\n */\nimport { DatePicker, TimePicker } from \"@burdenoff/fe-libs/ui\";\nimport { X } from \"lucide-react\";\n\nimport {\n isDateString,\n isTimeString,\n maxTimeOn,\n splitDateTime,\n withPickedDate,\n withPickedTime,\n} from \"./dateFieldValues\";\n\nconst CLEAR_BUTTON_CLASS =\n \"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-action-primary-bg/40\";\n\nfunction ClearButton({\n label,\n onClear,\n}: {\n label: string;\n onClear: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClear}\n aria-label={`Clear ${label.toLowerCase()}`}\n title={`Clear ${label.toLowerCase()}`}\n className={CLEAR_BUTTON_CLASS}\n >\n <X className=\"h-4 w-4\" aria-hidden />\n </button>\n );\n}\n\nexport interface DateFieldProps {\n /** `YYYY-MM-DD`, or `\"\"` for none. */\n value: string;\n onChange: (value: string) => void;\n /** What the date is (\"Due date\"): the picker's accessible name. */\n label: string;\n placeholder?: string;\n min?: string;\n max?: string;\n /** Show a clear button while there is a date. */\n clearable?: boolean;\n disabled?: boolean;\n id?: string;\n /**\n * Sits in a row of controls (a toolbar) instead of filling a form column under its label:\n * no top margin, and the button keeps its own width.\n */\n inline?: boolean;\n}\n\n/** A form field under its label: the gap the native inputs had (`mt-1`), the column's width. */\nconst FORM_FIELD_CLASS = \"mt-1 flex w-full items-center gap-1\";\n\nexport function DateField({\n value,\n onChange,\n label,\n placeholder,\n min,\n max,\n clearable = false,\n disabled,\n id,\n inline = false,\n}: DateFieldProps) {\n const picker = (\n <DatePicker\n id={id}\n value={isDateString(value) ? value : null}\n onChange={onChange}\n label={label}\n placeholder={placeholder}\n min={isDateString(min) ? min : undefined}\n max={isDateString(max) ? max : undefined}\n disabled={disabled}\n className={inline ? undefined : \"min-w-0 flex-1\"}\n />\n );\n if (inline && !clearable) return picker;\n return (\n <span className={inline ? \"flex items-center gap-1\" : FORM_FIELD_CLASS}>\n {picker}\n {value && !disabled ? (\n <ClearButton label={label} onClear={() => onChange(\"\")} />\n ) : null}\n </span>\n );\n}\n\nexport interface TimeFieldProps {\n /** `HH:mm`, 24-hour, or `\"\"` for none. */\n value: string;\n onChange: (value: string) => void;\n /** What the time is (\"Workday start\"): the picker's accessible name. */\n label: string;\n placeholder?: string;\n /** Minutes between the listed times. Default 15. */\n step?: number;\n minTime?: string;\n maxTime?: string;\n disabled?: boolean;\n id?: string;\n className?: string;\n}\n\nexport function TimeField({\n value,\n onChange,\n label,\n placeholder,\n step,\n minTime,\n maxTime,\n disabled,\n id,\n className,\n}: TimeFieldProps) {\n return (\n <TimePicker\n id={id}\n value={isTimeString(value) ? value : null}\n onChange={(time) => onChange(time)}\n label={label}\n placeholder={placeholder}\n step={step}\n minTime={minTime}\n maxTime={maxTime}\n disabled={disabled}\n className={className}\n />\n );\n}\n\nexport interface DateTimeFieldProps {\n /** `YYYY-MM-DDTHH:mm` in local time, or `\"\"` for none. */\n value: string;\n onChange: (value: string) => void;\n /** What the moment is (\"Start\"): the pickers are named \"<label> date\" and \"<label> time\". */\n label: string;\n /** The latest moment, `YYYY-MM-DDTHH:mm`. */\n max?: string;\n /** Minutes between the listed times. Default 15. */\n step?: number;\n /** Show a clear button while there is a value. */\n clearable?: boolean;\n disabled?: boolean;\n /** The day picker's id, for a `<label htmlFor>`. */\n id?: string;\n}\n\nexport function DateTimeField({\n value,\n onChange,\n label,\n max,\n step,\n clearable = false,\n disabled,\n id,\n}: DateTimeFieldProps) {\n const { date, time } = splitDateTime(value);\n const maxDate = splitDateTime(max).date ?? undefined;\n return (\n <span\n className=\"flex flex-wrap items-center gap-2\"\n data-slot=\"date-time-field\"\n >\n <DatePicker\n id={id}\n value={date}\n onChange={(picked) => onChange(withPickedDate(value, picked, max))}\n label={`${label} date`}\n max={maxDate}\n disabled={disabled}\n className=\"min-w-0 flex-1\"\n />\n <TimePicker\n value={time}\n onChange={(picked) => onChange(withPickedTime(value, picked, max))}\n label={`${label} time`}\n step={step}\n maxTime={maxTimeOn(date, max)}\n disabled={disabled}\n />\n {clearable && value && !disabled ? (\n <ClearButton label={label} onClear={() => onChange(\"\")} />\n ) : null}\n </span>\n );\n}\n"],"mappings":";;;;;AA4BA,IAAMA,IACJ;AAEF,SAASC,EAAY,EACnB,UACA,cAIC;CACD,OACE,kBAAC,UAAD;EACE,MAAK;EACL,SAASC;EACT,cAAY,SAASC,EAAM,YAAY;EACvC,OAAO,SAASA,EAAM,YAAY;EAClC,WAAWH;EAEX,UAAA,kBAACI,GAAD;GAAG,WAAU;GAAU,eAAA;EAAa,CAAA;CAC9B,CAAA;AAEZ;AAuBA,IAAMC,IAAmB;AAEzB,SAAgBC,EAAU,EACxB,UACA,aACA,UACA,gBACA,QACA,QACA,eAAY,IACZ,aACA,OACA,YAAS,MACQ;CACjB,IAAMC,IACJ,kBAACC,GAAD;EACM;EACJ,OAAOC,EAAaC,CAAK,IAAIA,IAAQ;EAC3B;EACH;EACM;EACb,KAAKD,EAAaE,CAAG,IAAIA,IAAM,KAAA;EAC/B,KAAKF,EAAaG,CAAG,IAAIA,IAAM,KAAA;EACrB;EACV,WAAWC,IAAS,KAAA,IAAY;CACjC,CAAA;CAGH,OADIA,KAAU,CAACC,IAAkBP,IAE/B,kBAAC,QAAD;EAAM,WAAWM,IAAS,4BAA4BR;EAAtD,UAAA,CACGE,GACAG,KAAS,CAACK,IACT,kBAACd,GAAD;GAAoB;GAAO,eAAee,EAAS,EAAE;EAAI,CAAA,IACvD,IACA;;AAEV;AAkBA,SAAgBC,EAAU,EACxB,UACA,aACA,UACA,gBACA,SACA,YACA,YACA,aACA,OACA,gBACiB;CACjB,OACE,kBAACC,GAAD;EACM;EACJ,OAAOC,EAAaT,CAAK,IAAIA,IAAQ;EACrC,WAAW,MAASM,EAASI,CAAI;EAC1B;EACM;EACP;EACG;EACA;EACC;EACC;CACZ,CAAA;AAEL;AAmBA,SAAgBC,EAAc,EAC5B,UACA,aACA,UACA,QACA,SACA,eAAY,IACZ,aACA,SACqB;CACrB,IAAM,EAAE,SAAM,YAASC,EAAcZ,CAAK,GACpCa,IAAUD,EAAcV,CAAG,CAAC,CAAC,QAAQ,KAAA;CAC3C,OACE,kBAAC,QAAD;EACE,WAAU;EACV,aAAU;EAFZ,UAAA;GAIE,kBAACJ,GAAD;IACM;IACJ,OAAOgB;IACP,WAAW,MAAWR,EAASS,EAAef,GAAOgB,GAAQd,CAAG,CAAC;IACjE,OAAO,GAAGT,EAAM;IAChB,KAAKoB;IACK;IACV,WAAU;GACX,CAAA;GACD,kBAACL,GAAD;IACE,OAAOE;IACP,WAAW,MAAWJ,EAASW,EAAejB,GAAOgB,GAAQd,CAAG,CAAC;IACjE,OAAO,GAAGT,EAAM;IACV;IACN,SAASyB,EAAUJ,GAAMZ,CAAG;IAClB;GACX,CAAA;GACAE,KAAaJ,KAAS,CAACK,IACtB,kBAACd,GAAD;IAAoB;IAAO,eAAee,EAAS,EAAE;GAAI,CAAA,IACvD;EACA;;AAEV"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOFF-18708: the value helpers behind the module's themed date and time fields.
|
|
3
|
+
*
|
|
4
|
+
* The fields keep the string shapes the native inputs used, so form state, validation and the
|
|
5
|
+
* GraphQL mapping stay as they were:
|
|
6
|
+
* - a date is `YYYY-MM-DD` (what `<input type="date">` produced), `""` when empty;
|
|
7
|
+
* - a time is `HH:mm` on a 24-hour clock (`<input type="time">`), `""` when empty;
|
|
8
|
+
* - a date and time is `YYYY-MM-DDTHH:mm` in local time (`<input type="datetime-local">`).
|
|
9
|
+
*/
|
|
10
|
+
/** The time a date-and-time field takes when a day is picked before any time. */
|
|
11
|
+
export declare const DEFAULT_TIME_OF_DAY = "09:00";
|
|
12
|
+
export declare function isDateString(value: string | null | undefined): value is string;
|
|
13
|
+
export declare function isTimeString(value: string | null | undefined): value is string;
|
|
14
|
+
export interface DateTimeParts {
|
|
15
|
+
/** `YYYY-MM-DD`, or `null` when the value has no valid day. */
|
|
16
|
+
date: string | null;
|
|
17
|
+
/** `HH:mm`, or `null` when the value has no valid time. */
|
|
18
|
+
time: string | null;
|
|
19
|
+
}
|
|
20
|
+
/** Splits a `YYYY-MM-DDTHH:mm` value (seconds are dropped) into its day and time. */
|
|
21
|
+
export declare function splitDateTime(value: string | null | undefined): DateTimeParts;
|
|
22
|
+
/** Joins a day and a time into a `YYYY-MM-DDTHH:mm` value. */
|
|
23
|
+
export declare function joinDateTime(date: string, time: string): string;
|
|
24
|
+
/** Today on this device, `YYYY-MM-DD`. */
|
|
25
|
+
export declare function localToday(now?: Date): string;
|
|
26
|
+
/**
|
|
27
|
+
* The value after a day is picked: the time already chosen is kept, else the default time,
|
|
28
|
+
* pulled back to the latest allowed time when the day is the `max` day.
|
|
29
|
+
*/
|
|
30
|
+
export declare function withPickedDate(current: string | null | undefined, date: string, max?: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* The value after a time is picked: the day already chosen is kept, else today, pulled back
|
|
33
|
+
* to `max` when it would pass it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function withPickedTime(current: string | null | undefined, time: string, max?: string, now?: Date): string;
|
|
36
|
+
/** `value`, or `max` when `value` is later. Both are `YYYY-MM-DDTHH:mm`, which sort as text. */
|
|
37
|
+
export declare function clampToMax(value: string, max?: string): string;
|
|
38
|
+
/** The latest time a time list offers on `date`: the `max` time on the `max` day, else none. */
|
|
39
|
+
export declare function maxTimeOn(date: string | null, max?: string): string | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/timecampus/components/dateFieldValues.ts
|
|
2
|
+
var e = /^\d{4}-\d{2}-\d{2}$/, t = /^([01]\d|2[0-3]):[0-5]\d$/, n = "09:00";
|
|
3
|
+
function r(t) {
|
|
4
|
+
return typeof t == "string" && e.test(t);
|
|
5
|
+
}
|
|
6
|
+
function i(e) {
|
|
7
|
+
return typeof e == "string" && t.test(e);
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
if (!e) return {
|
|
11
|
+
date: null,
|
|
12
|
+
time: null
|
|
13
|
+
};
|
|
14
|
+
let [t = "", n = ""] = e.split("T"), a = r(t) ? t : null, o = n.slice(0, 5);
|
|
15
|
+
return {
|
|
16
|
+
date: a,
|
|
17
|
+
time: i(o) ? o : null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function o(e, t) {
|
|
21
|
+
return `${e}T${t}`;
|
|
22
|
+
}
|
|
23
|
+
function s(e = /* @__PURE__ */ new Date()) {
|
|
24
|
+
let t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
|
|
25
|
+
return `${e.getFullYear()}-${t}-${n}`;
|
|
26
|
+
}
|
|
27
|
+
function c(e, t, n) {
|
|
28
|
+
let { time: r } = a(e);
|
|
29
|
+
return u(o(t, r ?? "09:00"), n);
|
|
30
|
+
}
|
|
31
|
+
function l(e, t, n, r = /* @__PURE__ */ new Date()) {
|
|
32
|
+
let { date: i } = a(e);
|
|
33
|
+
return u(o(i ?? s(r), t), n);
|
|
34
|
+
}
|
|
35
|
+
function u(e, t) {
|
|
36
|
+
if (!t) return e;
|
|
37
|
+
let { date: n, time: r } = a(t);
|
|
38
|
+
if (!n || !r) return e;
|
|
39
|
+
let i = o(n, r);
|
|
40
|
+
return e > i ? i : e;
|
|
41
|
+
}
|
|
42
|
+
function d(e, t) {
|
|
43
|
+
if (!e || !t) return;
|
|
44
|
+
let n = a(t);
|
|
45
|
+
return n.date === e && n.time ? n.time : void 0;
|
|
46
|
+
}
|
|
47
|
+
export { n as DEFAULT_TIME_OF_DAY, u as clampToMax, r as isDateString, i as isTimeString, o as joinDateTime, s as localToday, d as maxTimeOn, a as splitDateTime, c as withPickedDate, l as withPickedTime };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=dateFieldValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateFieldValues.js","names":["DATE_VALUE","TIME_VALUE","DEFAULT_TIME_OF_DAY","isDateString","value","isTimeString","splitDateTime","datePart","timePart","date","time","joinDateTime","localToday","month","now","day","withPickedDate","current","clampToMax","max","withPickedTime","limit","maxTimeOn"],"sources":["../../../src/timecampus/components/dateFieldValues.ts"],"sourcesContent":["/**\n * BOFF-18708: the value helpers behind the module's themed date and time fields.\n *\n * The fields keep the string shapes the native inputs used, so form state, validation and the\n * GraphQL mapping stay as they were:\n * - a date is `YYYY-MM-DD` (what `<input type=\"date\">` produced), `\"\"` when empty;\n * - a time is `HH:mm` on a 24-hour clock (`<input type=\"time\">`), `\"\"` when empty;\n * - a date and time is `YYYY-MM-DDTHH:mm` in local time (`<input type=\"datetime-local\">`).\n */\n\nconst DATE_VALUE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst TIME_VALUE = /^([01]\\d|2[0-3]):[0-5]\\d$/;\n\n/** The time a date-and-time field takes when a day is picked before any time. */\nexport const DEFAULT_TIME_OF_DAY = \"09:00\";\n\nexport function isDateString(\n value: string | null | undefined,\n): value is string {\n return typeof value === \"string\" && DATE_VALUE.test(value);\n}\n\nexport function isTimeString(\n value: string | null | undefined,\n): value is string {\n return typeof value === \"string\" && TIME_VALUE.test(value);\n}\n\nexport interface DateTimeParts {\n /** `YYYY-MM-DD`, or `null` when the value has no valid day. */\n date: string | null;\n /** `HH:mm`, or `null` when the value has no valid time. */\n time: string | null;\n}\n\n/** Splits a `YYYY-MM-DDTHH:mm` value (seconds are dropped) into its day and time. */\nexport function splitDateTime(value: string | null | undefined): DateTimeParts {\n if (!value) return { date: null, time: null };\n const [datePart = \"\", timePart = \"\"] = value.split(\"T\");\n const date = isDateString(datePart) ? datePart : null;\n const time = timePart.slice(0, 5);\n return { date, time: isTimeString(time) ? time : null };\n}\n\n/** Joins a day and a time into a `YYYY-MM-DDTHH:mm` value. */\nexport function joinDateTime(date: string, time: string): string {\n return `${date}T${time}`;\n}\n\n/** Today on this device, `YYYY-MM-DD`. */\nexport function localToday(now: Date = new Date()): string {\n const month = String(now.getMonth() + 1).padStart(2, \"0\");\n const day = String(now.getDate()).padStart(2, \"0\");\n return `${now.getFullYear()}-${month}-${day}`;\n}\n\n/**\n * The value after a day is picked: the time already chosen is kept, else the default time,\n * pulled back to the latest allowed time when the day is the `max` day.\n */\nexport function withPickedDate(\n current: string | null | undefined,\n date: string,\n max?: string,\n): string {\n const { time } = splitDateTime(current);\n return clampToMax(joinDateTime(date, time ?? DEFAULT_TIME_OF_DAY), max);\n}\n\n/**\n * The value after a time is picked: the day already chosen is kept, else today, pulled back\n * to `max` when it would pass it.\n */\nexport function withPickedTime(\n current: string | null | undefined,\n time: string,\n max?: string,\n now: Date = new Date(),\n): string {\n const { date } = splitDateTime(current);\n return clampToMax(joinDateTime(date ?? localToday(now), time), max);\n}\n\n/** `value`, or `max` when `value` is later. Both are `YYYY-MM-DDTHH:mm`, which sort as text. */\nexport function clampToMax(value: string, max?: string): string {\n if (!max) return value;\n const { date, time } = splitDateTime(max);\n if (!date || !time) return value;\n const limit = joinDateTime(date, time);\n return value > limit ? limit : value;\n}\n\n/** The latest time a time list offers on `date`: the `max` time on the `max` day, else none. */\nexport function maxTimeOn(\n date: string | null,\n max?: string,\n): string | undefined {\n if (!date || !max) return undefined;\n const limit = splitDateTime(max);\n return limit.date === date && limit.time ? limit.time : undefined;\n}\n"],"mappings":";AAUA,IAAMA,IAAa,uBACbC,IAAa,6BAGNC,IAAsB;AAEnC,SAAgBC,EACd,GACiB;CACjB,OAAO,OAAOC,KAAU,YAAYJ,EAAW,KAAKI,CAAK;AAC3D;AAEA,SAAgBC,EACd,GACiB;CACjB,OAAO,OAAOD,KAAU,YAAYH,EAAW,KAAKG,CAAK;AAC3D;AAUA,SAAgBE,EAAc,GAAiD;CAC7E,IAAI,CAACF,GAAO,OAAO;EAAE,MAAM;EAAM,MAAM;CAAK;CAC5C,IAAM,CAACG,IAAW,IAAIC,IAAW,MAAMJ,EAAM,MAAM,GAAG,GAChDK,IAAON,EAAaI,CAAQ,IAAIA,IAAW,MAC3CG,IAAOF,EAAS,MAAM,GAAG,CAAC;CAChC,OAAO;EAAE;EAAM,MAAMH,EAAaK,CAAI,IAAIA,IAAO;CAAK;AACxD;AAGA,SAAgBC,EAAa,GAAc,GAAsB;CAC/D,OAAO,GAAGF,EAAK,GAAGC;AACpB;AAGA,SAAgBE,EAAW,oBAAY,IAAI,KAAK,GAAW;CACzD,IAAMC,IAAQ,OAAOC,EAAI,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,GAClDC,IAAM,OAAOD,EAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;CACjD,OAAO,GAAGA,EAAI,YAAY,EAAE,GAAGD,EAAM,GAAGE;AAC1C;AAMA,SAAgBC,EACd,GACA,GACA,GACQ;CACR,IAAM,EAAE,YAASV,EAAcW,CAAO;CACtC,OAAOC,EAAWP,EAAaF,GAAMC,KAAA,OAA2B,GAAGS,CAAG;AACxE;AAMA,SAAgBC,EACd,GACA,GACA,GACA,oBAAY,IAAI,KAAK,GACb;CACR,IAAM,EAAE,YAASd,EAAcW,CAAO;CACtC,OAAOC,EAAWP,EAAaF,KAAQG,EAAWE,CAAG,GAAGJ,CAAI,GAAGS,CAAG;AACpE;AAGA,SAAgBD,EAAW,GAAe,GAAsB;CAC9D,IAAI,CAACC,GAAK,OAAOf;CACjB,IAAM,EAAE,SAAM,YAASE,EAAca,CAAG;CACxC,IAAI,CAACV,KAAQ,CAACC,GAAM,OAAON;CAC3B,IAAMiB,IAAQV,EAAaF,GAAMC,CAAI;CACrC,OAAON,IAAQiB,IAAQA,IAAQjB;AACjC;AAGA,SAAgBkB,EACd,GACA,GACoB;CACpB,IAAI,CAACb,KAAQ,CAACU,GAAK;CACnB,IAAME,IAAQf,EAAca,CAAG;CAC/B,OAAOE,EAAM,SAASZ,KAAQY,EAAM,OAAOA,EAAM,OAAO,KAAA;AAC1D"}
|