@sectile/terminal 0.4.0 → 0.6.0
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/calendar.d.ts +36 -74
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +114 -196
- package/dist/calendar.js.map +1 -1
- package/dist/date-field.d.ts +4 -4
- package/dist/date-field.d.ts.map +1 -1
- package/dist/date-field.js +5 -5
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.d.ts +6 -5
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +9 -7
- package/dist/date-picker.js.map +1 -1
- package/dist/date-range-field.d.ts +5 -5
- package/dist/date-range-field.d.ts.map +1 -1
- package/dist/date-range-field.js +5 -5
- package/dist/date-range-field.js.map +1 -1
- package/dist/date-range-picker.d.ts +7 -6
- package/dist/date-range-picker.d.ts.map +1 -1
- package/dist/date-range-picker.js +9 -8
- package/dist/date-range-picker.js.map +1 -1
- package/dist/date-time-field.d.ts +4 -4
- package/dist/date-time-field.d.ts.map +1 -1
- package/dist/date-time-field.js +5 -5
- package/dist/date-time-field.js.map +1 -1
- package/dist/date-time-picker.d.ts +7 -6
- package/dist/date-time-picker.d.ts.map +1 -1
- package/dist/date-time-picker.js +12 -10
- package/dist/date-time-picker.js.map +1 -1
- package/dist/date-time-range-picker.d.ts +7 -6
- package/dist/date-time-range-picker.d.ts.map +1 -1
- package/dist/date-time-range-picker.js +12 -10
- package/dist/date-time-range-picker.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/reference-date.d.ts +3 -0
- package/dist/internal/reference-date.d.ts.map +1 -0
- package/dist/internal/reference-date.js +8 -0
- package/dist/internal/reference-date.js.map +1 -0
- package/dist/internal/result.d.ts +17 -0
- package/dist/internal/result.d.ts.map +1 -0
- package/dist/internal/result.js +8 -0
- package/dist/internal/result.js.map +1 -0
- package/dist/time-field.d.ts +4 -4
- package/dist/time-field.d.ts.map +1 -1
- package/dist/time-field.js +5 -5
- package/dist/time-field.js.map +1 -1
- package/dist/time-range-field.d.ts +4 -4
- package/dist/time-range-field.d.ts.map +1 -1
- package/dist/time-range-field.js +5 -5
- package/dist/time-range-field.js.map +1 -1
- package/package.json +3 -2
package/dist/calendar.d.ts
CHANGED
|
@@ -1,80 +1,42 @@
|
|
|
1
1
|
import { type FacadeConnection } from '@sectile/core/adapter-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
2
|
+
import { type TerminalTemporalResult } from './internal/result.js';
|
|
3
|
+
import type { RevisionSnapshot } from '@sectile/core/revision';
|
|
4
|
+
import { type CalendarEvent, type CalendarMonthValue, type CalendarPolicies, type CalendarState } from '@sectile/temporal/calendar';
|
|
5
|
+
import { type DateValue } from '@sectile/temporal/date-field';
|
|
6
6
|
import type { TerminalKeyboardInput } from './keyboard.js';
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
export interface CalendarValueChangeDetails<ID extends StableID = StableID> {
|
|
17
|
-
readonly value: ID | null;
|
|
18
|
-
readonly previousValue: ID | null;
|
|
19
|
-
}
|
|
20
|
-
export interface CalendarHighlightChangeDetails<ID extends StableID = StableID> {
|
|
21
|
-
readonly value: ID | null;
|
|
22
|
-
readonly previousValue: ID | null;
|
|
23
|
-
}
|
|
24
|
-
export interface CalendarControllerOptions<ID extends StableID = StableID> {
|
|
25
|
-
readonly grid: Grid<ID>;
|
|
7
|
+
export type { CalendarCommand, CalendarEvent, CalendarMonthValue, CalendarPolicies, CalendarState, CalendarView, CalendarViewMode, } from '@sectile/temporal/calendar';
|
|
8
|
+
export type { DateValue } from '@sectile/temporal/date-field';
|
|
9
|
+
export interface CalendarOptions {
|
|
10
|
+
readonly policies?: CalendarPolicies;
|
|
11
|
+
readonly value?: DateValue | null;
|
|
12
|
+
readonly defaultValue?: DateValue | null;
|
|
13
|
+
readonly highlightedValue?: DateValue;
|
|
14
|
+
readonly defaultHighlightedValue?: DateValue;
|
|
15
|
+
readonly referenceDate?: DateValue;
|
|
26
16
|
readonly disabled?: boolean;
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly
|
|
31
|
-
readonly defaultHighlightedValue?: ID | null;
|
|
32
|
-
readonly onValueChange?: (change: CalendarValueChangeDetails<ID>) => void;
|
|
33
|
-
readonly onHighlightedValueChange?: (change: CalendarHighlightChangeDetails<ID>) => void;
|
|
34
|
-
}
|
|
35
|
-
export type CalendarControllerValueChangeHandler<ID extends StableID = StableID> = NonNullable<CalendarControllerOptions<ID>['onValueChange']>;
|
|
36
|
-
export type CalendarControllerHighlightedValueChangeHandler<ID extends StableID = StableID> = NonNullable<CalendarControllerOptions<ID>['onHighlightedValueChange']>;
|
|
37
|
-
export interface CalendarControlledValues<ID extends StableID = StableID> {
|
|
38
|
-
readonly value?: ID | null;
|
|
39
|
-
readonly highlightedValue?: ID | null;
|
|
40
|
-
}
|
|
41
|
-
export interface CalendarController<ID extends StableID = StableID> {
|
|
42
|
-
readonly grid: Grid<ID>;
|
|
43
|
-
getSnapshot(): RevisionSnapshot<CalendarState<ID>>;
|
|
44
|
-
syncControlledValues(values: CalendarControlledValues<ID>): Result<RevisionSnapshot<CalendarState<ID>>>;
|
|
45
|
-
handleKeyboardInput(input: KeyboardInput, expectedRevision?: number): RevisionResult<CalendarState<ID>, CalendarEffect<ID>>;
|
|
46
|
-
}
|
|
47
|
-
export interface CalendarPageRequestDetails<ID extends StableID = StableID> {
|
|
48
|
-
readonly direction: -1 | 1;
|
|
49
|
-
readonly from: ID | null;
|
|
50
|
-
}
|
|
51
|
-
export interface CalendarTransitionDetails<ID extends StableID = StableID> {
|
|
52
|
-
readonly event: CalendarEvent<ID>;
|
|
53
|
-
readonly result: RevisionResult<CalendarState<ID>, CalendarEffect<ID>>;
|
|
54
|
-
}
|
|
55
|
-
export interface CalendarConnectionOptions<ID extends StableID = StableID> {
|
|
56
|
-
readonly controller: CalendarController<ID>;
|
|
57
|
-
readonly disabled?: boolean;
|
|
58
|
-
readonly onPageRequest?: (details: CalendarPageRequestDetails<ID>) => void;
|
|
59
|
-
readonly onTransition?: (details: CalendarTransitionDetails<ID>) => void;
|
|
17
|
+
readonly readOnly?: boolean;
|
|
18
|
+
readonly required?: boolean;
|
|
19
|
+
readonly onValueChange?: (value: DateValue | null) => void;
|
|
20
|
+
readonly onHighlightedValueChange?: (value: DateValue) => void;
|
|
60
21
|
readonly onUpdate?: () => void;
|
|
61
22
|
}
|
|
62
|
-
export type
|
|
63
|
-
export type
|
|
64
|
-
export type
|
|
65
|
-
export interface
|
|
66
|
-
readonly
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export declare function
|
|
79
|
-
export declare function
|
|
23
|
+
export type CalendarValueChangeHandler = NonNullable<CalendarOptions['onValueChange']>;
|
|
24
|
+
export type CalendarHighlightedValueChangeHandler = NonNullable<CalendarOptions['onHighlightedValueChange']>;
|
|
25
|
+
export type CalendarUpdateHandler = NonNullable<CalendarOptions['onUpdate']>;
|
|
26
|
+
export interface CalendarControlledValues {
|
|
27
|
+
readonly value?: DateValue | null;
|
|
28
|
+
readonly highlightedValue?: DateValue;
|
|
29
|
+
}
|
|
30
|
+
export interface CalendarConnection {
|
|
31
|
+
getSnapshot(): RevisionSnapshot<CalendarState>;
|
|
32
|
+
getMonth(): readonly (readonly DateValue[])[];
|
|
33
|
+
getWeek(): readonly DateValue[];
|
|
34
|
+
getYear(): readonly (readonly CalendarMonthValue[])[];
|
|
35
|
+
syncControlledValues(values: CalendarControlledValues): TerminalTemporalResult<RevisionSnapshot<CalendarState>>;
|
|
36
|
+
handleEvent(event: CalendarEvent): boolean;
|
|
37
|
+
handleKeyboardInput(input: TerminalKeyboardInput): boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function createCalendar(options?: CalendarOptions): FacadeConnection<CalendarConnection>;
|
|
40
|
+
export declare function tryCreateCalendar(options?: CalendarOptions): TerminalTemporalResult<FacadeConnection<CalendarConnection>>;
|
|
41
|
+
export declare function toCalendarEvent(input: TerminalKeyboardInput): CalendarEvent | null;
|
|
80
42
|
//# sourceMappingURL=calendar.d.ts.map
|
package/dist/calendar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAA6G,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9K,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3D,YAAY,EACV,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,C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AC9C,OAAO,IAAI,SAAS,SAAS,EAAE,CAAC;IAChC,OAAO,IAAI,SAAS,CAAC,SAAS,kBAAkB,EAAE,CAAC,EAAE,CAAC;IACtD,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;IAChH,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;IAC3C,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC;CAC5D;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAElG;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,eAAoB,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAE7H;AAiGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,qBAAqB,GAAG,aAAa,GAAG,IAAI,CAYlF"}
|
package/dist/calendar.js
CHANGED
|
@@ -1,217 +1,135 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from '@sectile/core/adapter-runtime';
|
|
2
2
|
import { unwrap } from '@sectile/core/result';
|
|
3
|
-
import {
|
|
4
|
-
import { applyCalendarEvent, tryCreateCalendarState, } from '@sectile/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export function createCalendarController(options) {
|
|
9
|
-
const value = options.value !== undefined ? options.value : options.defaultValue ?? null;
|
|
10
|
-
const current = options.highlightedValue !== undefined
|
|
11
|
-
? options.highlightedValue
|
|
12
|
-
: options.defaultHighlightedValue ?? null;
|
|
13
|
-
const initial = tryCreateCalendarState(options.grid, {
|
|
14
|
-
selected: value === null ? [] : [value],
|
|
15
|
-
anchor: value,
|
|
16
|
-
current,
|
|
17
|
-
});
|
|
18
|
-
if (!initial.ok)
|
|
19
|
-
return initial;
|
|
20
|
-
const snapshot = tryCreateRevisionSnapshot(initial.value);
|
|
21
|
-
if (!snapshot.ok)
|
|
22
|
-
return snapshot;
|
|
23
|
-
const interaction = tryCreateInteractionState(options);
|
|
24
|
-
if (!interaction.ok)
|
|
25
|
-
return interaction;
|
|
26
|
-
return { ok: true, value: new TerminalCalendarController(options, snapshot.value, interaction.value) };
|
|
27
|
-
}
|
|
28
|
-
export function createCalendar(options) {
|
|
3
|
+
import { createTerminalTemporalController, createTerminalTemporalFacadeConnection } from './internal/result.js';
|
|
4
|
+
import { applyCalendarEvent, createCalendarMonth, createCalendarWeek, createCalendarYear, tryCreateCalendarState, } from '@sectile/temporal/calendar';
|
|
5
|
+
import { compareDateValues } from '@sectile/temporal/date-field';
|
|
6
|
+
import { currentReferenceDate } from './internal/reference-date.js';
|
|
7
|
+
export function createCalendar(options = {}) {
|
|
29
8
|
return unwrap(tryCreateCalendar(options));
|
|
30
9
|
}
|
|
31
|
-
export function tryCreateCalendar(options) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
function tryCreateCalendarConnection(options) {
|
|
35
|
-
const grid = tryCreateGrid(options.rows);
|
|
36
|
-
if (!grid.ok)
|
|
37
|
-
return grid;
|
|
38
|
-
const controller = createCalendarController({ ...options, grid: grid.value });
|
|
39
|
-
if (!controller.ok)
|
|
40
|
-
return controller;
|
|
41
|
-
return { ok: true, value: connectCalendar({ ...options, controller: controller.value }) };
|
|
10
|
+
export function tryCreateCalendar(options = {}) {
|
|
11
|
+
return createTerminalTemporalFacadeConnection(options, constructCalendar);
|
|
42
12
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
13
|
+
function constructCalendar(options) {
|
|
14
|
+
const controls = {
|
|
15
|
+
value: options.value !== undefined,
|
|
16
|
+
highlighted: options.highlightedValue !== undefined,
|
|
17
|
+
};
|
|
18
|
+
const requestedValue = controls.value ? options.value : options.defaultValue;
|
|
19
|
+
const requestedHighlight = controls.highlighted ? options.highlightedValue : options.defaultHighlightedValue;
|
|
20
|
+
const initial = tryCreateCalendarState({
|
|
21
|
+
referenceDate: options.referenceDate ?? currentReferenceDate(),
|
|
22
|
+
...(requestedValue === undefined ? {} : { value: requestedValue }),
|
|
23
|
+
...(requestedHighlight === undefined ? {} : { highlighted: requestedHighlight }),
|
|
24
|
+
});
|
|
25
|
+
const runtime = createTerminalTemporalController({
|
|
26
|
+
initial,
|
|
27
|
+
reducer: (state, event) => applyCalendarEvent(state, event, {
|
|
28
|
+
...options.policies,
|
|
29
|
+
...(options.required === undefined ? {} : { required: options.required }),
|
|
30
|
+
}),
|
|
31
|
+
reconcile: (previous, proposed) => tryCreateCalendarState({
|
|
32
|
+
value: controls.value ? previous.value : proposed.value,
|
|
33
|
+
highlighted: controls.highlighted ? previous.highlighted : proposed.highlighted,
|
|
34
|
+
view: controls.highlighted ? previous.view : proposed.view,
|
|
35
|
+
viewMode: proposed.viewMode,
|
|
36
|
+
}),
|
|
37
|
+
notify: (previous, proposed) => {
|
|
38
|
+
if (compareNullable(previous.value, proposed.value) !== 0)
|
|
39
|
+
options.onValueChange?.(proposed.value);
|
|
40
|
+
if (compareDateValues(previous.highlighted, proposed.highlighted) !== 0)
|
|
41
|
+
options.onHighlightedValueChange?.(proposed.highlighted);
|
|
42
|
+
},
|
|
43
|
+
toEffect: (command) => command,
|
|
44
|
+
interaction: options,
|
|
45
|
+
interactionIntent: calendarInteractionIntent,
|
|
46
|
+
});
|
|
47
|
+
return runtime.ok
|
|
48
|
+
? { ok: true, value: new TerminalCalendar(options, runtime.value, controls) }
|
|
49
|
+
: runtime;
|
|
67
50
|
}
|
|
68
|
-
class
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.#
|
|
76
|
-
this.grid = options.controller.grid;
|
|
77
|
-
this.#onPageRequest = options.onPageRequest;
|
|
78
|
-
this.#onTransition = options.onTransition;
|
|
79
|
-
this.#onUpdate = options.onUpdate;
|
|
51
|
+
class TerminalCalendar {
|
|
52
|
+
#options;
|
|
53
|
+
#runtime;
|
|
54
|
+
#controls;
|
|
55
|
+
constructor(options, runtime, controls) {
|
|
56
|
+
this.#options = options;
|
|
57
|
+
this.#runtime = runtime;
|
|
58
|
+
this.#controls = controls;
|
|
80
59
|
}
|
|
81
|
-
getSnapshot() {
|
|
82
|
-
|
|
60
|
+
getSnapshot() { return this.#runtime.getSnapshot(); }
|
|
61
|
+
getMonth() {
|
|
62
|
+
return createCalendarMonth(this.getSnapshot().state.view, this.#options.policies?.weekStartsOn);
|
|
63
|
+
}
|
|
64
|
+
getWeek() {
|
|
65
|
+
return createCalendarWeek(this.getSnapshot().state.highlighted, this.#options.policies?.weekStartsOn);
|
|
66
|
+
}
|
|
67
|
+
getYear() {
|
|
68
|
+
return createCalendarYear(this.getSnapshot().state.view.year);
|
|
83
69
|
}
|
|
84
70
|
syncControlledValues(values) {
|
|
85
|
-
|
|
71
|
+
if (this.#controls.value !== (values.value !== undefined) || this.#controls.highlighted !== (values.highlightedValue !== undefined)) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: {
|
|
75
|
+
class: 'construction',
|
|
76
|
+
code: 'controlled-shape-mismatch',
|
|
77
|
+
message: 'Controlled calendar values must preserve their construction-time shape.',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const state = this.getSnapshot().state;
|
|
82
|
+
const highlighted = this.#controls.highlighted ? values.highlightedValue : state.highlighted;
|
|
83
|
+
const result = this.#runtime.replace(tryCreateCalendarState({
|
|
84
|
+
value: this.#controls.value ? values.value : state.value,
|
|
85
|
+
highlighted,
|
|
86
|
+
view: { year: highlighted.year, month: highlighted.month },
|
|
87
|
+
viewMode: state.viewMode,
|
|
88
|
+
}));
|
|
86
89
|
if (result.ok)
|
|
87
|
-
this.#onUpdate?.();
|
|
90
|
+
this.#options.onUpdate?.();
|
|
88
91
|
return result;
|
|
89
92
|
}
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
if (event === null)
|
|
93
|
-
return false;
|
|
94
|
-
const result = this.#controller.handleKeyboardInput(input);
|
|
95
|
-
if (result.ok) {
|
|
96
|
-
for (const effect of result.commands) {
|
|
97
|
-
if (effect.type !== 'request-page')
|
|
98
|
-
continue;
|
|
99
|
-
this.#onPageRequest?.(Object.freeze({ direction: effect.direction, from: effect.from }));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
this.#onTransition?.(Object.freeze({ event, result }));
|
|
93
|
+
handleEvent(event) {
|
|
94
|
+
const result = this.#runtime.handle(event);
|
|
103
95
|
if (result.ok)
|
|
104
|
-
this.#onUpdate?.();
|
|
96
|
+
this.#options.onUpdate?.();
|
|
105
97
|
return result.ok;
|
|
106
98
|
}
|
|
107
|
-
|
|
108
|
-
class TerminalCalendarController {
|
|
109
|
-
grid;
|
|
110
|
-
#grid;
|
|
111
|
-
#policies;
|
|
112
|
-
#valueControlled;
|
|
113
|
-
#highlightControlled;
|
|
114
|
-
#onValueChange;
|
|
115
|
-
#onHighlightedValueChange;
|
|
116
|
-
#interaction;
|
|
117
|
-
#snapshot;
|
|
118
|
-
constructor(options, snapshot, interaction) {
|
|
119
|
-
this.grid = options.grid;
|
|
120
|
-
this.#grid = options.grid;
|
|
121
|
-
this.#policies = options.policies ?? {};
|
|
122
|
-
this.#valueControlled = options.value !== undefined;
|
|
123
|
-
this.#highlightControlled = options.highlightedValue !== undefined;
|
|
124
|
-
this.#onValueChange = options.onValueChange;
|
|
125
|
-
this.#onHighlightedValueChange = options.onHighlightedValueChange;
|
|
126
|
-
this.#interaction = interaction;
|
|
127
|
-
this.#snapshot = snapshot;
|
|
128
|
-
}
|
|
129
|
-
getSnapshot() {
|
|
130
|
-
return this.#snapshot;
|
|
131
|
-
}
|
|
132
|
-
syncControlledValues(values) {
|
|
133
|
-
const error = controlledInputError(this.#valueControlled, this.#highlightControlled, values);
|
|
134
|
-
if (error !== null)
|
|
135
|
-
return { ok: false, error };
|
|
136
|
-
const selected = this.#valueControlled
|
|
137
|
-
? values.value
|
|
138
|
-
: selectedValue(this.#snapshot.state);
|
|
139
|
-
const state = tryCreateCalendarState(this.#grid, {
|
|
140
|
-
selected: selected === null ? [] : [selected],
|
|
141
|
-
anchor: this.#valueControlled ? selected : this.#snapshot.state.selection.anchor,
|
|
142
|
-
current: this.#highlightControlled
|
|
143
|
-
? values.highlightedValue
|
|
144
|
-
: this.#snapshot.state.cursor.current,
|
|
145
|
-
});
|
|
146
|
-
const snapshot = synchronizeControllerState(this.#snapshot, state);
|
|
147
|
-
if (!snapshot.ok)
|
|
148
|
-
return snapshot;
|
|
149
|
-
this.#snapshot = snapshot.value;
|
|
150
|
-
return snapshot;
|
|
151
|
-
}
|
|
152
|
-
handleKeyboardInput(input, expectedRevision = this.#snapshot.revision) {
|
|
99
|
+
handleKeyboardInput(input) {
|
|
153
100
|
const event = toCalendarEvent(input);
|
|
154
|
-
|
|
155
|
-
return rejectRevisionInput(this.#snapshot, {
|
|
156
|
-
class: 'transition-rejection',
|
|
157
|
-
code: 'unsupported-terminal-key',
|
|
158
|
-
message: 'Terminal keyboard input does not map to a calendar semantic event.',
|
|
159
|
-
details: { key: input.key },
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
const permitted = requireInteraction(this.#interaction, 'navigate');
|
|
163
|
-
if (!permitted.ok)
|
|
164
|
-
return rejectRevisionInput(this.#snapshot, permitted.error);
|
|
165
|
-
const result = applyControllerEvent(this.#snapshot, expectedRevision, event, (state, semanticEvent) => applyCalendarEvent(this.#grid, state, semanticEvent, this.#policies), (previous, proposed) => controlledState(this.#grid, previous, proposed, this.#valueControlled, this.#highlightControlled), (previous, proposed) => this.#notify(previous, proposed), toCalendarEffect);
|
|
166
|
-
if (result.ok)
|
|
167
|
-
this.#snapshot = result.snapshot;
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
#notify(previous, proposed) {
|
|
171
|
-
const previousValue = selectedValue(previous);
|
|
172
|
-
const value = selectedValue(proposed);
|
|
173
|
-
if (previousValue !== value) {
|
|
174
|
-
this.#onValueChange?.(Object.freeze({ value, previousValue }));
|
|
175
|
-
}
|
|
176
|
-
if (previous.cursor.current !== proposed.cursor.current) {
|
|
177
|
-
this.#onHighlightedValueChange?.(Object.freeze({
|
|
178
|
-
value: proposed.cursor.current,
|
|
179
|
-
previousValue: previous.cursor.current,
|
|
180
|
-
}));
|
|
181
|
-
}
|
|
101
|
+
return event !== null && this.handleEvent(event);
|
|
182
102
|
}
|
|
183
103
|
}
|
|
184
|
-
function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
104
|
+
export function toCalendarEvent(input) {
|
|
105
|
+
if (input.ctrlKey || input.altKey)
|
|
106
|
+
return null;
|
|
107
|
+
if (input.key === 'left')
|
|
108
|
+
return 'previous-day';
|
|
109
|
+
if (input.key === 'right')
|
|
110
|
+
return 'next-day';
|
|
111
|
+
if (input.key === 'up')
|
|
112
|
+
return 'previous-week';
|
|
113
|
+
if (input.key === 'down')
|
|
114
|
+
return 'next-week';
|
|
115
|
+
if (input.key === 'home')
|
|
116
|
+
return 'start-of-week';
|
|
117
|
+
if (input.key === 'end')
|
|
118
|
+
return 'end-of-week';
|
|
119
|
+
if (input.key === 'page-up')
|
|
120
|
+
return input.shiftKey ? 'previous-year' : 'previous-month';
|
|
121
|
+
if (input.key === 'page-down')
|
|
122
|
+
return input.shiftKey ? 'next-year' : 'next-month';
|
|
123
|
+
if (input.key === 'enter' || input.key === 'space')
|
|
124
|
+
return 'select-highlighted';
|
|
125
|
+
return null;
|
|
190
126
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
127
|
+
function calendarInteractionIntent(event) {
|
|
128
|
+
if (event === 'select-highlighted')
|
|
129
|
+
return 'mutate';
|
|
130
|
+
return typeof event === 'object' && (event.type === 'select' || event.type === 'set-value') ? 'mutate' : 'navigate';
|
|
193
131
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
class: 'construction',
|
|
198
|
-
code: valueControlled ? 'controlled-value-required' : 'uncontrolled-value-update',
|
|
199
|
-
message: valueControlled
|
|
200
|
-
? 'Controlled calendar selection sync requires value.'
|
|
201
|
-
: 'Uncontrolled calendar selection cannot be synchronized externally.',
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
if (highlightControlled !== (values.highlightedValue !== undefined)) {
|
|
205
|
-
return {
|
|
206
|
-
class: 'construction',
|
|
207
|
-
code: highlightControlled
|
|
208
|
-
? 'controlled-highlighted-value-required'
|
|
209
|
-
: 'uncontrolled-highlighted-value-update',
|
|
210
|
-
message: highlightControlled
|
|
211
|
-
? 'Controlled calendar highlight sync requires highlightedValue.'
|
|
212
|
-
: 'Uncontrolled calendar highlight cannot be synchronized externally.',
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return null;
|
|
132
|
+
function compareNullable(left, right) {
|
|
133
|
+
return left === null ? right === null ? 0 : -1 : right === null ? 1 : compareDateValues(left, right);
|
|
216
134
|
}
|
|
217
135
|
//# sourceMappingURL=calendar.js.map
|
package/dist/calendar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE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,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC;AACtH,CAAC;AACD,SAAS,eAAe,CAAC,IAAsB,EAAE,KAAuB;IACtE,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvG,CAAC"}
|
package/dist/date-field.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TerminalTemporalResult } from './internal/result.js';
|
|
2
2
|
import type { RevisionSnapshot } from '@sectile/core/revision';
|
|
3
3
|
import { type TextEditingState } from '@sectile/core/text';
|
|
4
|
-
import { type DateFieldEvent, type DateFieldPolicies, type DateFieldState, type DateValue } from '@sectile/
|
|
4
|
+
import { type DateFieldEvent, type DateFieldPolicies, type DateFieldState, type DateValue } from '@sectile/temporal/date-field';
|
|
5
5
|
import { type FacadeConnection } from '@sectile/core/adapter-runtime';
|
|
6
6
|
import type { TerminalKeyboardInput } from './keyboard.js';
|
|
7
7
|
export interface DateFieldOptions {
|
|
@@ -29,11 +29,11 @@ export interface DateFieldConnection {
|
|
|
29
29
|
getText(): string;
|
|
30
30
|
getValue(): DateValue | null;
|
|
31
31
|
getCaret(): number;
|
|
32
|
-
syncControlledValues(values: DateFieldControlledValues):
|
|
32
|
+
syncControlledValues(values: DateFieldControlledValues): TerminalTemporalResult<RevisionSnapshot<DateFieldState>>;
|
|
33
33
|
handleEvent(event: DateFieldEvent): boolean;
|
|
34
34
|
handleKeyboardInput(input: TerminalKeyboardInput): boolean;
|
|
35
35
|
handleTextInput(text: string): boolean;
|
|
36
36
|
}
|
|
37
37
|
export declare function createDateField(options?: DateFieldOptions): FacadeConnection<DateFieldConnection>;
|
|
38
|
-
export declare function tryCreateDateField(options?: DateFieldOptions):
|
|
38
|
+
export declare function tryCreateDateField(options?: DateFieldOptions): TerminalTemporalResult<FacadeConnection<DateFieldConnection>>;
|
|
39
39
|
//# sourceMappingURL=date-field.d.ts.map
|
package/dist/date-field.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-field.d.ts","sourceRoot":"","sources":["../src/date-field.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"date-field.d.ts","sourceRoot":"","sources":["../src/date-field.ts"],"names":[],"mappings":"AACA,OAAO,EAA6G,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9K,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAwB,KAAK,gBAAgB,EAA2C,MAAM,oBAAoB,CAAC;AAC1H,OAAO,EAAuE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACrM,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,WAAW,gBAAgB;IAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ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gBAAqB,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAgD;AACtJ,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,gBAAqB,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAuE"}
|
package/dist/date-field.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { unwrap } from '@sectile/core/result';
|
|
2
|
+
import { createTerminalTemporalController, createTerminalTemporalFacadeConnection } from './internal/result.js';
|
|
2
3
|
import { sameTextEditingState } from '@sectile/core/text';
|
|
3
|
-
import { applyDateFieldEvent, tryCreateDateFieldState } from '@sectile/
|
|
4
|
-
import {
|
|
5
|
-
import { createSemanticController } from '@sectile/core/adapter-runtime';
|
|
4
|
+
import { applyDateFieldEvent, tryCreateDateFieldState } from '@sectile/temporal/date-field';
|
|
5
|
+
import {} from '@sectile/core/adapter-runtime';
|
|
6
6
|
import { toTerminalTextInput } from './internal/text-input.js';
|
|
7
7
|
import { toTextEvent } from './text.js';
|
|
8
8
|
export function createDateField(options = {}) { return unwrap(tryCreateDateField(options)); }
|
|
9
|
-
export function tryCreateDateField(options = {}) { return
|
|
9
|
+
export function tryCreateDateField(options = {}) { return createTerminalTemporalFacadeConnection(options, construct); }
|
|
10
10
|
function construct(options) {
|
|
11
11
|
const valueControlled = options.value !== undefined;
|
|
12
12
|
const inputControlled = options.inputState !== undefined;
|
|
13
13
|
const policies = Object.freeze({ ...options.policies, ...(options.required === undefined ? {} : { required: options.required }) });
|
|
14
|
-
const runtime =
|
|
14
|
+
const runtime = createTerminalTemporalController({ initial: tryCreateDateFieldState(options.value !== undefined ? options.value : options.defaultValue ?? null, options.inputState !== undefined ? options.inputState : options.defaultInputState), reducer: (state, event) => applyDateFieldEvent(state, event, policies), reconcile: (previous, proposed) => tryCreateDateFieldState(valueControlled ? previous.value : proposed.value, inputControlled ? previous.inputState : proposed.inputState), notify: (previous, proposed) => { if (!sameTextEditingState(previous.inputState, proposed.inputState))
|
|
15
15
|
options.onInputStateChange?.(proposed.inputState, previous.inputState); }, toEffect: (command) => command, interaction: options });
|
|
16
16
|
return runtime.ok ? { ok: true, value: new TerminalDateField(options, runtime.value, valueControlled, inputControlled) } : runtime;
|
|
17
17
|
}
|