@object-ui/core 17.6.0 → 18.0.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/CHANGELOG.md +7260 -0
- package/README.md +228 -14
- package/dist/actions/ActionEngine.d.ts +4 -2
- package/dist/actions/ActionEngine.js +13 -8
- package/dist/actions/ActionRunner.d.ts +473 -69
- package/dist/actions/ActionRunner.js +792 -125
- package/dist/actions/TransactionManager.d.ts +7 -2
- package/dist/actions/UndoManager.d.ts +8 -13
- package/dist/actions/actionKeys.d.ts +9 -7
- package/dist/actions/actionKeys.js +67 -14
- package/dist/actions/actionResponse.js +2 -2
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/navigationTarget.d.ts +41 -0
- package/dist/actions/navigationTarget.js +20 -0
- package/dist/actions/recordDelete.d.ts +154 -0
- package/dist/actions/recordDelete.js +110 -0
- package/dist/adapters/ApiDataSource.d.ts +8 -4
- package/dist/adapters/ApiDataSource.js +19 -7
- package/dist/adapters/ValueDataSource.d.ts +6 -1
- package/dist/adapters/ValueDataSource.js +1090 -98
- package/dist/adapters/batchTransaction.d.ts +1 -1
- package/dist/adapters/batchTransaction.js +1 -1
- package/dist/adapters/resolveDataSource.d.ts +9 -6
- package/dist/adapters/resolveDataSource.js +9 -12
- package/dist/builder/schema-builder.d.ts +38 -81
- package/dist/builder/schema-builder.js +33 -152
- package/dist/data-scope/ViewDataProvider.d.ts +8 -25
- package/dist/data-scope/ViewDataProvider.js +27 -54
- package/dist/data-scope/element-data-source.d.ts +261 -7
- package/dist/data-scope/element-data-source.js +342 -52
- package/dist/data-scope/index.d.ts +9 -4
- package/dist/data-scope/index.js +9 -4
- package/dist/evaluator/ExpressionEvaluator.d.ts +86 -0
- package/dist/evaluator/ExpressionEvaluator.js +184 -12
- package/dist/evaluator/FormulaFunctions.d.ts +0 -10
- package/dist/evaluator/FormulaFunctions.js +166 -27
- package/dist/evaluator/deadlineSettled.d.ts +40 -0
- package/dist/evaluator/deadlineSettled.js +45 -0
- package/dist/evaluator/declaredPredicate.d.ts +93 -9
- package/dist/evaluator/declaredPredicate.js +117 -16
- package/dist/evaluator/fieldRules.d.ts +88 -4
- package/dist/evaluator/fieldRules.js +208 -31
- package/dist/evaluator/index.d.ts +2 -0
- package/dist/evaluator/index.js +2 -0
- package/dist/evaluator/listConditional.d.ts +103 -34
- package/dist/evaluator/listConditional.js +127 -50
- package/dist/evaluator/optionRules.d.ts +77 -6
- package/dist/evaluator/optionRules.js +87 -10
- package/dist/evaluator/predicateInput.d.ts +15 -4
- package/dist/evaluator/predicateInput.js +35 -2
- package/dist/evaluator/rowPredicateCanon.d.ts +7 -18
- package/dist/evaluator/rowPredicateCanon.js +65 -115
- package/dist/evaluator/subjectPermissions.d.ts +105 -0
- package/dist/evaluator/subjectPermissions.js +86 -0
- package/dist/evaluator/unevaluablePredicate.d.ts +57 -0
- package/dist/evaluator/unevaluablePredicate.js +70 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +83 -2
- package/dist/protocols/index.d.ts +0 -1
- package/dist/protocols/index.js +9 -1
- package/dist/registry/Registry.d.ts +382 -34
- package/dist/registry/Registry.js +247 -12
- package/dist/registry/WidgetRegistry.js +7 -3
- package/dist/registry/html-tier-intrinsics.d.ts +90 -0
- package/dist/registry/html-tier-intrinsics.js +110 -0
- package/dist/registry/public-blocks.d.ts +8 -0
- package/dist/registry/public-blocks.js +57 -0
- package/dist/theme/ThemeEngine.js +1 -1
- package/dist/utils/affordanceGrants.d.ts +371 -0
- package/dist/utils/affordanceGrants.js +252 -0
- package/dist/utils/chart-category-key.d.ts +82 -0
- package/dist/utils/chart-category-key.js +84 -0
- package/dist/utils/chart-measure-key.d.ts +64 -0
- package/dist/utils/chart-measure-key.js +65 -0
- package/dist/utils/chart-presentation.d.ts +95 -112
- package/dist/utils/chart-presentation.js +169 -104
- package/dist/utils/chart-series.d.ts +165 -5
- package/dist/utils/chart-series.js +123 -18
- package/dist/utils/column-sortability.d.ts +157 -0
- package/dist/utils/column-sortability.js +217 -0
- package/dist/utils/dashboard-filters.d.ts +38 -6
- package/dist/utils/dashboard-filters.js +107 -61
- package/dist/utils/dataset-format.d.ts +211 -30
- package/dist/utils/dataset-format.js +389 -46
- package/dist/utils/date-display.d.ts +346 -0
- package/dist/utils/date-display.js +644 -0
- package/dist/utils/date-macros.js +7 -0
- package/dist/utils/drill-down.d.ts +78 -0
- package/dist/utils/drill-down.js +93 -0
- package/dist/utils/emptiness.d.ts +96 -0
- package/dist/utils/emptiness.js +101 -0
- package/dist/utils/expand-fields.d.ts +81 -9
- package/dist/utils/expand-fields.js +81 -9
- package/dist/utils/extract-records.d.ts +65 -5
- package/dist/utils/extract-records.js +65 -8
- package/dist/utils/filter-converter.d.ts +158 -6
- package/dist/utils/filter-converter.js +1098 -24
- package/dist/utils/filter-tokens.d.ts +49 -5
- package/dist/utils/filter-tokens.js +105 -33
- package/dist/utils/grouping-fields.d.ts +61 -0
- package/dist/utils/grouping-fields.js +84 -0
- package/dist/utils/managedBy.d.ts +3 -3
- package/dist/utils/managedBy.js +5 -5
- package/dist/utils/native-date-value.d.ts +48 -0
- package/dist/utils/native-date-value.js +167 -0
- package/dist/utils/non-grid-row-ceiling.d.ts +143 -0
- package/dist/utils/non-grid-row-ceiling.js +141 -0
- package/dist/utils/normalize-list-view.d.ts +135 -11
- package/dist/utils/normalize-list-view.js +243 -64
- package/dist/utils/number-display.d.ts +63 -14
- package/dist/utils/number-display.js +34 -12
- package/dist/utils/object-aggregate-query.d.ts +113 -0
- package/dist/utils/object-aggregate-query.js +50 -0
- package/dist/utils/parent-scope.d.ts +123 -0
- package/dist/utils/parent-scope.js +140 -0
- package/dist/utils/predicate-fields.d.ts +45 -12
- package/dist/utils/predicate-fields.js +141 -12
- package/dist/utils/record-color.d.ts +75 -0
- package/dist/utils/record-color.js +65 -0
- package/dist/utils/record-source.d.ts +298 -0
- package/dist/utils/record-source.js +331 -0
- package/dist/utils/record-title.d.ts +148 -8
- package/dist/utils/record-title.js +220 -26
- package/dist/utils/reference-keys.d.ts +21 -22
- package/dist/utils/reference-keys.js +532 -29
- package/dist/utils/sort-query.d.ts +115 -15
- package/dist/utils/sort-query.js +240 -13
- package/dist/utils/text-comparand.d.ts +92 -0
- package/dist/utils/text-comparand.js +99 -0
- package/dist/utils/without-denied-fields.d.ts +49 -0
- package/dist/utils/without-denied-fields.js +52 -0
- package/dist/validation/index.d.ts +8 -4
- package/dist/validation/index.js +8 -4
- package/dist/validation/schema-validator.d.ts +1 -1
- package/dist/validation/schema-validator.js +225 -83
- package/dist/validation/server-owned-value.d.ts +5 -1
- package/dist/validation/server-owned-value.js +5 -1
- package/dist/validation/validators/object-validation-engine.d.ts +1 -1
- package/dist/validation/validators/object-validation-engine.js +14 -3
- package/package.json +8 -9
- package/dist/data-scope/DataScopeManager.d.ts +0 -127
- package/dist/data-scope/DataScopeManager.js +0 -229
- package/dist/protocols/ResponsiveProtocol.d.ts +0 -73
- package/dist/protocols/ResponsiveProtocol.js +0 -158
- package/dist/validation/validation-engine.d.ts +0 -88
- package/dist/validation/validation-engine.js +0 -434
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Declare the zone instants render in — the host's half of objectui#11693.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the zone enters HERE and nowhere else
|
|
12
|
+
*
|
|
13
|
+
* Every date and datetime face in the console is a function of this module
|
|
14
|
+
* (see the header), and each caller threads only its `locale`. The zone the
|
|
15
|
+
* signed-in workspace configures (`localization.timezone`, served by
|
|
16
|
+
* `GET /api/v1/auth/me/localization`) is the same for every face on the
|
|
17
|
+
* page, so it is set once, here, and every face reads it — rather than
|
|
18
|
+
* threaded through each call site, where one forgotten caller renders the
|
|
19
|
+
* same instant in a second zone beside the first (objectui#4272 is that
|
|
20
|
+
* defect for the locale). `LocalizationProvider` (`@object-ui/i18n`) is the
|
|
21
|
+
* host that calls this; a renderer never does.
|
|
22
|
+
*
|
|
23
|
+
* `undefined` (or an empty string) clears it: instants render in the
|
|
24
|
+
* viewer's zone again. A name this runtime's `Intl` does not know — a zone
|
|
25
|
+
* newer than the browser's time-zone data, say — clears it too, with a
|
|
26
|
+
* warning, rather than make every face throw the `RangeError` `Intl` raises
|
|
27
|
+
* for it.
|
|
28
|
+
*
|
|
29
|
+
* ⛔ A date-only value never takes the zone; see {@link toDisplayDate}.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setDisplayTimeZone(timeZone: string | undefined): void;
|
|
32
|
+
/** The zone {@link setDisplayTimeZone} declared, or `undefined` for the viewer's own. */
|
|
33
|
+
export declare function getDisplayTimeZone(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Be told when the display zone changes; returns the unsubscribe. The shape is
|
|
36
|
+
* React's `useSyncExternalStore` contract, which is how `LocalizationProvider`
|
|
37
|
+
* re-renders its consumers once the zone they format in has moved.
|
|
38
|
+
*/
|
|
39
|
+
export declare function subscribeDisplayTimeZone(listener: () => void): () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Options shared by {@link formatDate} / {@link formatRelativeDate} /
|
|
42
|
+
* {@link formatDateTime}. One bag, and each function reads the keys it needs:
|
|
43
|
+
* `dueLike` and `t` only matter on the relative path, `style` is read by
|
|
44
|
+
* `formatDateTime` and by `formatDate` (see below).
|
|
45
|
+
*/
|
|
46
|
+
export interface DateDisplayOptions {
|
|
47
|
+
dueLike?: boolean;
|
|
48
|
+
/** BCP-47 display locale (ADR-0053 tenant default); falls back to the runtime locale. */
|
|
49
|
+
locale?: string;
|
|
50
|
+
/** i18n translate fn for phrases `Intl` can't produce (the "Overdue Nd" wording). */
|
|
51
|
+
t?: (key: string, params?: Record<string, unknown>) => string;
|
|
52
|
+
/**
|
|
53
|
+
* Named face, read by {@link formatDateTime} and {@link formatDate}. Each
|
|
54
|
+
* reads its own vocabulary: `'compact'` is `formatDateTime`'s dense grid
|
|
55
|
+
* cell face (objectui#7443), `'short'` and `'relative'` are `formatDate`'s;
|
|
56
|
+
* anything else, or absent, is that function's default face.
|
|
57
|
+
*
|
|
58
|
+
* It rides here rather than in a second positional parameter because
|
|
59
|
+
* `formatDateTime(value, options?)` is a PUBLISHED signature with `options`
|
|
60
|
+
* in position two (objectui#4272). A positional `style` would have displaced
|
|
61
|
+
* it: TypeScript would reject the old call, but a JavaScript caller would
|
|
62
|
+
* silently hand its options bag to the style slot and lose its locale —
|
|
63
|
+
* the #4272 defect again.
|
|
64
|
+
*
|
|
65
|
+
* ⚠️ On {@link formatDate} this key COLLIDES with a positional parameter of
|
|
66
|
+
* the same name, so the precedence is PINNED, not left to implementation
|
|
67
|
+
* order: **the positional argument wins**, and this key is consulted only
|
|
68
|
+
* when the positional slot is `undefined` (objectui#7745). See
|
|
69
|
+
* {@link formatDate}'s own note for why that direction and not the other.
|
|
70
|
+
*
|
|
71
|
+
* ⚠️ {@link formatRelativeDate} still does NOT read this key — the
|
|
72
|
+
* maintainer's long-run ruling on objectui#7443 names `formatDate` only, and
|
|
73
|
+
* whether the relative path's out-of-window fallback should honour it is a
|
|
74
|
+
* separate, deliberate call (objectui#7745's report).
|
|
75
|
+
*/
|
|
76
|
+
style?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A date that exists — the pattern alone would accept `2024-02-31`.
|
|
80
|
+
*
|
|
81
|
+
* `true` only for a date-only ISO string (`YYYY-MM-DD`, the shape
|
|
82
|
+
* {@link ISO_DATE_ONLY_RE} names) whose year, month and day read back
|
|
83
|
+
* unchanged from the calendar. Anything else — another shape, a time part, an
|
|
84
|
+
* out-of-range month, or a day its month does not have — is `false`.
|
|
85
|
+
*
|
|
86
|
+
* ## Why this lives here (objectui#10026)
|
|
87
|
+
*
|
|
88
|
+
* It used to be module-private in `@object-ui/components`' filter builder,
|
|
89
|
+
* which refused `2026-02-30` at the AUTHORING boundary, while this module — a
|
|
90
|
+
* package below it, unable to import it — ROLLED the same value into March 2nd
|
|
91
|
+
* on every display face. One concept, two answers. It moved down, exactly as
|
|
92
|
+
* `formatDate` itself moved into this package (see the header), so the filter
|
|
93
|
+
* builder and {@link toDisplayDate} now ask the one function. ⛔ A move, not a
|
|
94
|
+
* copy: `@object-ui/components` imports it from here.
|
|
95
|
+
*
|
|
96
|
+
* ## Why the engine cannot answer this on its own
|
|
97
|
+
*
|
|
98
|
+
* ECMAScript's date-string parse accepts a DAY of `01`-`31` for every month
|
|
99
|
+
* and rolls the surplus forward: `Date.parse('2026-02-30')` is March 2nd, not
|
|
100
|
+
* `NaN`. It rejects an out-of-range MONTH (`2026-13-01`), which is why a
|
|
101
|
+
* bad month was always a dash on the display path and a bad day never was.
|
|
102
|
+
* So the day is read back instead: build the date in UTC (no zone, so no DST
|
|
103
|
+
* gap can move it) and require all three parts to survive.
|
|
104
|
+
*
|
|
105
|
+
* `setUTCFullYear` rather than `Date.UTC(year, …)`: the latter maps years
|
|
106
|
+
* 0-99 onto 1900+y, so it answered `false` for `0026-08-01` — a real day,
|
|
107
|
+
* and one {@link toDisplayDate} renders (it undoes the same legacy mapping for
|
|
108
|
+
* the same reason). The move had to fix that, or refusing through this
|
|
109
|
+
* function would have dashed every year below 100.
|
|
110
|
+
*/
|
|
111
|
+
export declare function isRealCalendarDate(dateOnly: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The ONE `value -> Date` step behind every function below.
|
|
114
|
+
*
|
|
115
|
+
* ## The defect (objectui#10110)
|
|
116
|
+
*
|
|
117
|
+
* ECMAScript parses the two ISO shapes into two different zones: a DATE-ONLY
|
|
118
|
+
* form is UTC, while a date-TIME form without an offset is local. So
|
|
119
|
+
* `new Date('2026-08-01')` is UTC midnight, and every getter this module then
|
|
120
|
+
* uses — `getFullYear`, `getMonth`, `getDate`, and `toLocaleDateString`'s own
|
|
121
|
+
* internal ones — reads it back in the VIEWER's zone. West of UTC that lands
|
|
122
|
+
* on the previous calendar day: `2026-08-01` rendered `Jul 31` for a UTC-7
|
|
123
|
+
* viewer while the stored value, the API response and a UTC+8 viewer all said
|
|
124
|
+
* August 1st. The relative branch shifted with it, one day per day
|
|
125
|
+
* (`2026-08-31` read `4 days ago` on the 3rd instead of `3 days ago`),
|
|
126
|
+
* because it compares two LOCAL start-of-days.
|
|
127
|
+
*
|
|
128
|
+
* ## The repair, and why it is not an offset
|
|
129
|
+
*
|
|
130
|
+
* A date-only value names a CALENDAR DAY and carries no instant, so there is
|
|
131
|
+
* no conversion to perform: this rebuilds it at LOCAL midnight of the day it
|
|
132
|
+
* names, and every local getter downstream then reports that same day in
|
|
133
|
+
* every zone. ⛔ Nothing here adds or subtracts hours. An offset that
|
|
134
|
+
* cancels the shift would be wrong again at the next DST boundary and wrong
|
|
135
|
+
* in the opposite direction for a viewer EAST of UTC, where the UTC-midnight
|
|
136
|
+
* parse already lands on the right day — the co-located suite drives both.
|
|
137
|
+
* `GridField`'s sub-grid cell already parsed its own date-only values this
|
|
138
|
+
* way before reaching `formatDate`; this is that treatment, moved to the one
|
|
139
|
+
* place every caller passes through (the sub-grid reads it from here since
|
|
140
|
+
* objectui#10301).
|
|
141
|
+
*
|
|
142
|
+
* A value with a time part is not rebuilt, in both spellings: it HAS an
|
|
143
|
+
* instant, and rendering an instant in the viewer's zone is the whole point
|
|
144
|
+
* of a `datetime`. The regex is what separates them, so the split is the
|
|
145
|
+
* VALUE's shape and never the field's declared type, which this module (pure,
|
|
146
|
+
* no schema) cannot see.
|
|
147
|
+
*
|
|
148
|
+
* ## What it refuses (objectui#10026)
|
|
149
|
+
*
|
|
150
|
+
* The engine's own parse still decides what is a date at all (`2026-13-01`
|
|
151
|
+
* is an Invalid Date, and so every face below renders `—`), with ONE
|
|
152
|
+
* addition: a date-only value naming a day its month does not have. The
|
|
153
|
+
* engine accepts `2026-02-30` and rolls it into March 2nd, so before this
|
|
154
|
+
* card every date face showed a real day nobody wrote, with nothing to say
|
|
155
|
+
* so. This step hands back an Invalid Date for it instead — the same answer
|
|
156
|
+
* the engine gives a bad month — so every caller renders the face it already
|
|
157
|
+
* renders for an unparsable value: `—` from the functions below, `EmptyValue`
|
|
158
|
+
* from the field carriers that read validity here, the raw stored string from
|
|
159
|
+
* a caller whose unparsable face is the raw string. ⛔ No new marker.
|
|
160
|
+
*
|
|
161
|
+
* The maintainer's ruling on objectui#10026 (option A) placed the refusal on
|
|
162
|
+
* the SHARED path, in this step and not in any one consumer: refusing in a
|
|
163
|
+
* single face would re-create the list-cell-versus-measure split
|
|
164
|
+
* objectui#4576 recorded. {@link isRealCalendarDate} is the one judgement,
|
|
165
|
+
* shared with the filter builder's authoring boundary.
|
|
166
|
+
*
|
|
167
|
+
* A value that carries a TIME is refused the same way when the day it is
|
|
168
|
+
* written on does not exist (objectui#10301): `2026-02-30T10:00:00Z` parses
|
|
169
|
+
* too, and rendered `Mar 2, 2026, 10:00 AM` on every datetime face. Triage
|
|
170
|
+
* graded that an inherited branch of the same ruling. The judgement reads the
|
|
171
|
+
* value's leading `YYYY-MM-DD` AS WRITTEN, never the day its instant lands on
|
|
172
|
+
* in some zone: a parsed `Date` always names a real day, so a check made after
|
|
173
|
+
* any conversion could only miss the refusal, and a real day written with an
|
|
174
|
+
* offset (`2026-02-28T23:30:00-05:00`, March 1st in UTC) is kept. A real
|
|
175
|
+
* date-time is otherwise untouched — no rebuild, the engine's instant.
|
|
176
|
+
*
|
|
177
|
+
* ## Why it is exported (objectui#10183)
|
|
178
|
+
*
|
|
179
|
+
* A caller that formats with its own `Intl` options — a face none of the
|
|
180
|
+
* functions below produce, such as the record summary chip's
|
|
181
|
+
* `dateStyle: 'medium'` — or that compares a value against "today" needs the
|
|
182
|
+
* `Date` itself, not a string. Such callers used to parse the value on their
|
|
183
|
+
* own (`new Date(value)`, or `Date.parse` and then a `Date` handed to
|
|
184
|
+
* `formatDate`, which this step then leaves alone), so the objectui#10110
|
|
185
|
+
* repair never reached them and each still read a date-only value one day
|
|
186
|
+
* early west of UTC. They take the `Date` from here instead.
|
|
187
|
+
*
|
|
188
|
+
* ⛔ Read the result with LOCAL getters or local-zone `Intl` formatting only.
|
|
189
|
+
* For a date-only value it is local midnight of the named day, so its
|
|
190
|
+
* `toISOString()` / UTC getters name the previous day east of UTC — hand
|
|
191
|
+
* those the stored value, never this. The faces in this module know such a
|
|
192
|
+
* `Date` when they are handed one and keep it out of the display zone
|
|
193
|
+
* (objectui#11693, see `calendarDays`).
|
|
194
|
+
*/
|
|
195
|
+
export declare function toDisplayDate(value: string | Date | number): Date;
|
|
196
|
+
/**
|
|
197
|
+
* THE ONE READ of a stored END, where a bar or span is drawn to
|
|
198
|
+
* (objectui#11141): {@link toDisplayDate}'s read, and then, for a date-only
|
|
199
|
+
* value only, the next day's local midnight.
|
|
200
|
+
*
|
|
201
|
+
* ## The rule (objectui#11112's ruling, one home since objectui#11141)
|
|
202
|
+
*
|
|
203
|
+
* A date-only end is INCLUSIVE: `2024-01-01` to `2024-01-15` runs through
|
|
204
|
+
* January 15th, so the span is drawn to the start of the 16th, and a
|
|
205
|
+
* successor starting `2024-01-16` begins exactly where it ends. A span whose
|
|
206
|
+
* date-only start and end name the same day is one day long, across a DST
|
|
207
|
+
* change too: the step is a calendar day (`setDate`), never 24 hours, so it
|
|
208
|
+
* lands on the next local midnight, or on that day's first hour where its
|
|
209
|
+
* midnight does not exist. That is how a project plan and the schema
|
|
210
|
+
* catalog's gantt plans author an end.
|
|
211
|
+
*
|
|
212
|
+
* The result is the EXCLUSIVE end instant of a half-open span `[start, end)`,
|
|
213
|
+
* the form every gantt surface draws and schedules with. Date-only is decided
|
|
214
|
+
* by the value's own shape, with {@link isRealCalendarDate}, exactly as
|
|
215
|
+
* {@link toDisplayDate} decides it, so an end reads its day as a start does and
|
|
216
|
+
* then runs to that day's end. A value with a time part, a number or a `Date`
|
|
217
|
+
* is an instant: the span ends at it, and it is handed back as
|
|
218
|
+
* {@link toDisplayDate} hands it back.
|
|
219
|
+
*
|
|
220
|
+
* {@link toInclusiveEndDay} is the exact inverse: it names the day a span
|
|
221
|
+
* ending here runs through, so a read and a write of a date-only end agree.
|
|
222
|
+
*
|
|
223
|
+
* ⛔ One rule, one place: `plugin-timeline`'s gantt variant and
|
|
224
|
+
* `plugin-gantt` both read their ends here. A second copy of the step in a
|
|
225
|
+
* consumer is how the two gantt surfaces came to draw one plan a day apart.
|
|
226
|
+
* ⛔ Read the result with LOCAL getters only, as {@link toDisplayDate}'s is.
|
|
227
|
+
*/
|
|
228
|
+
export declare function toDisplayEndDate(value: string | Date | number): Date;
|
|
229
|
+
/**
|
|
230
|
+
* The day a span ending at `end` runs through: local midnight of the day that
|
|
231
|
+
* holds the last instant before `end` (objectui#11141).
|
|
232
|
+
*
|
|
233
|
+
* This is the exact inverse of {@link toDisplayEndDate} on a date-only end:
|
|
234
|
+
* the instant it reads `2024-01-15` as, local midnight of the 16th, names the
|
|
235
|
+
* 15th here, so a read, a drag and a write of a stored date-only end leave it
|
|
236
|
+
* the day it was, and a bar dragged to end at a day's local midnight names the
|
|
237
|
+
* day BEFORE it. An end inside a day (a `datetime` end, or a shift band's
|
|
238
|
+
* edge) names that day, the last one the span reaches into.
|
|
239
|
+
*
|
|
240
|
+
* It names a day for display and for a date-only write. ⛔ It is not a read of
|
|
241
|
+
* a stored value, and a `datetime` end still keeps its own instant: hand this
|
|
242
|
+
* only to a face that names a day, or to a field that stores one. Read the
|
|
243
|
+
* result with LOCAL getters only; an Invalid Date stays invalid.
|
|
244
|
+
*/
|
|
245
|
+
export declare function toInclusiveEndDay(end: Date): Date;
|
|
246
|
+
/**
|
|
247
|
+
* Format date as relative time (e.g., "3 days ago", "Today", "Overdue 3d"),
|
|
248
|
+
* localized via `Intl.RelativeTimeFormat` (objectstack-ai/objectstack#3040).
|
|
249
|
+
*
|
|
250
|
+
* `dueLike` gates the "Overdue" wording — a past `start_date`/`created_at`
|
|
251
|
+
* isn't overdue, only a past due/deadline-semantic field is. Non-due-like
|
|
252
|
+
* past dates render as plain "N days ago" instead. The overdue phrase has no
|
|
253
|
+
* `Intl` equivalent, so it resolves through `options.t` (key
|
|
254
|
+
* `fields.relativeDate.overdue`) with an English fallback.
|
|
255
|
+
*
|
|
256
|
+
* Days are counted in the display zone (objectui#11693): "today" is the
|
|
257
|
+
* display zone's today, and an instant falls on its day there. A date-only
|
|
258
|
+
* value keeps the day it names and is counted from that same today, so an
|
|
259
|
+
* instant and a date-only value on one day read one phrase.
|
|
260
|
+
*/
|
|
261
|
+
export declare function formatRelativeDate(value: string | Date | number, options?: DateDisplayOptions): string;
|
|
262
|
+
/**
|
|
263
|
+
* Format date value.
|
|
264
|
+
*
|
|
265
|
+
* The named face comes from EITHER spelling — the positional `style`
|
|
266
|
+
* parameter or `options.style` — and the precedence between them is pinned
|
|
267
|
+
* (objectui#7745):
|
|
268
|
+
*
|
|
269
|
+
* > **The positional argument wins. `options.style` is consulted only when the
|
|
270
|
+
* > positional slot is `undefined`.**
|
|
271
|
+
*
|
|
272
|
+
* Before #7745 only the positional spelling was read here, while
|
|
273
|
+
* {@link formatDateTime} read only the `options` one — one shared bag, two
|
|
274
|
+
* spellings for one concept, and on THIS function the options spelling did
|
|
275
|
+
* nothing at all: `formatDate(v, undefined, { style: 'short' })` silently
|
|
276
|
+
* rendered the default face with no diagnostic. Reading the key is the
|
|
277
|
+
* additive half of the maintainer's long-run ruling on objectui#7443.
|
|
278
|
+
*
|
|
279
|
+
* Why the positional wins, and not the newer key:
|
|
280
|
+
*
|
|
281
|
+
* - It is the ONLY direction that is purely additive. It fires exactly on
|
|
282
|
+
* the input that is a silent no-op today (positional absent, key present);
|
|
283
|
+
* every call that renders a face today renders the same face after.
|
|
284
|
+
* - The bag is SHARED across three functions, so it can legitimately carry a
|
|
285
|
+
* key meant for a sibling — that is this module's convention (`dueLike`
|
|
286
|
+
* and `t` are read by `formatRelativeDate` alone). A caller that built
|
|
287
|
+
* `{ style: 'compact', locale }` for `formatDateTime` and reused the bag
|
|
288
|
+
* for `formatDate(v, 'short', bag)` must keep its short face. A key aimed
|
|
289
|
+
* at a sibling function must not outrank an argument written for THIS
|
|
290
|
+
* call — that is objectui#7694's shape (an alias overwriting the canonical
|
|
291
|
+
* key), and the silent-override half of objectui#4272.
|
|
292
|
+
*
|
|
293
|
+
* `??`, not `||`, is what "absent" means here: `formatDate(v, '', bag)`
|
|
294
|
+
* renders the default face today and must keep doing so, so an empty string
|
|
295
|
+
* counts as GIVEN and does not fall through to the key.
|
|
296
|
+
*/
|
|
297
|
+
export declare function formatDate(value: string | Date | number, style?: string, options?: DateDisplayOptions): string;
|
|
298
|
+
/**
|
|
299
|
+
* The `'compact'` datetime face as the two halves a grid cell paints
|
|
300
|
+
* separately — `7/4/2024` and `7:00 am` for `2024-07-04T07:00:00Z` in `en-US`.
|
|
301
|
+
*
|
|
302
|
+
* `formatDateTime(value, { style: 'compact', ...options })` is exactly
|
|
303
|
+
* `date + ' ' + time` of what this returns, so a caller that wants the face
|
|
304
|
+
* as ONE string and a caller that wants to style the halves differently
|
|
305
|
+
* cannot drift apart. That drift is what objectui#7443 recorded:
|
|
306
|
+
* `DateTimeCellRenderer` inlined these two option bags and never called this
|
|
307
|
+
* module, so `datetime` had two display conventions while `date` had one —
|
|
308
|
+
* the same shape as objectui#4576, which this repo has already paid for once.
|
|
309
|
+
*
|
|
310
|
+
* `null` for a value this module renders as `'—'`; the cell renders its own
|
|
311
|
+
* empty state for those, so it never sees the dash.
|
|
312
|
+
*/
|
|
313
|
+
export declare function formatDateTimeCompactParts(value: string | Date | number, options?: DateDisplayOptions): {
|
|
314
|
+
date: string;
|
|
315
|
+
time: string;
|
|
316
|
+
} | null;
|
|
317
|
+
/**
|
|
318
|
+
* Format datetime value.
|
|
319
|
+
*
|
|
320
|
+
* `options.style` selects a named face:
|
|
321
|
+
*
|
|
322
|
+
* - `'compact'` — the dense grid face, `7/4/2024 7:00 am` in `en-US`. It is
|
|
323
|
+
* what every `datetime` CELL renders, and what `DateTimeCellRenderer`
|
|
324
|
+
* used to build from its own inlined `Intl` bags (objectui#7443).
|
|
325
|
+
* - anything else, including absent — the verbose default,
|
|
326
|
+
* `Jul 4, 2024, 07:00 AM` in `en-US`. Unchanged, and still what a
|
|
327
|
+
* non-cell caller (dataset measure, gantt tooltip, data-table) gets.
|
|
328
|
+
*
|
|
329
|
+
* The signature is `(value, options?)`, unchanged: `style` is a key of
|
|
330
|
+
* `options`, not a positional parameter, so every existing call —
|
|
331
|
+
* `formatDateTime(v, { locale })` included — keeps meaning exactly what it
|
|
332
|
+
* meant (see the note on `DateDisplayOptions.style` for why the positional
|
|
333
|
+
* shape `formatDate` uses was refused here).
|
|
334
|
+
*
|
|
335
|
+
* `options` is optional, so a caller that passes nothing keeps the exact
|
|
336
|
+
* runtime-default behavior it had. Before objectui#4272 the parameter did not
|
|
337
|
+
* exist at all, which meant no caller could localize this function however
|
|
338
|
+
* hard it tried — it always handed `Intl` an `undefined` tag, i.e. the
|
|
339
|
+
* MACHINE's locale, which is neither of the repo's two locale channels.
|
|
340
|
+
* Callers should pass the tag from `useDisplayLocale()`.
|
|
341
|
+
*
|
|
342
|
+
* The zone is NOT an option: an instant renders in the display zone the host
|
|
343
|
+
* declared with {@link setDisplayTimeZone}, else the viewer's, on every face
|
|
344
|
+
* this module produces (objectui#11693).
|
|
345
|
+
*/
|
|
346
|
+
export declare function formatDateTime(value: string | Date | number, options?: DateDisplayOptions): string;
|