@adecore/ui 0.33.3 → 0.34.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/Banner.d.ts +2 -1
- package/dist/Banner.js +92 -51
- package/dist/CopyButton.d.ts +24 -0
- package/dist/CopyButton.js +144 -0
- package/dist/ErrorBoundary.js +16 -18
- package/dist/ProjectSwitcher.js +66 -73
- package/dist/RelativeTime.d.ts +9 -0
- package/dist/RelativeTime.js +38 -0
- package/dist/Segmented.d.ts +4 -1
- package/dist/Segmented.js +111 -86
- package/dist/Toasts.js +1 -1
- package/dist/combobox/index.parts.d.ts +1 -0
- package/dist/combobox/index.parts.js +1 -0
- package/dist/combobox/parts.d.ts +32 -0
- package/dist/combobox/parts.js +556 -0
- package/dist/command-palette/index.parts.d.ts +2 -0
- package/dist/command-palette/index.parts.js +3 -0
- package/dist/command-palette/parts.d.ts +32 -0
- package/dist/command-palette/parts.js +422 -0
- package/dist/format/datetime.d.ts +1 -0
- package/dist/format/datetime.js +8 -0
- package/dist/format/duration.d.ts +1 -0
- package/dist/format/duration.js +24 -1
- package/dist/format/index.d.ts +2 -2
- package/dist/format/index.js +2 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/locales/en.d.ts +8 -0
- package/dist/locales/en.js +8 -0
- package/dist/locales/nl.d.ts +8 -0
- package/dist/locales/nl.js +8 -0
- package/dist/match.d.ts +1 -0
- package/dist/match.js +47 -0
- package/dist/segmented-keys.d.ts +3 -0
- package/dist/segmented-keys.js +33 -0
- package/dist/theme.css +15 -0
- package/dist/toast-store.d.ts +1 -0
- package/dist/toast-store.js +16 -6
- package/dist/workspace/TabStrip.d.ts +2 -1
- package/dist/workspace/TabStrip.js +432 -372
- package/package.json +1 -1
- package/src/Banner.tsx +33 -9
- package/src/CopyButton.tsx +86 -0
- package/src/ErrorBoundary.tsx +3 -4
- package/src/ProjectSwitcher.tsx +4 -2
- package/src/RelativeTime.tsx +44 -0
- package/src/Segmented.tsx +60 -33
- package/src/Toasts.tsx +1 -1
- package/src/combobox/index.parts.ts +12 -0
- package/src/combobox/parts.tsx +147 -0
- package/src/command-palette/index.parts.ts +16 -0
- package/src/command-palette/parts.tsx +145 -0
- package/src/format/datetime.ts +5 -0
- package/src/format/duration.ts +25 -1
- package/src/format/index.ts +2 -1
- package/src/index.ts +7 -0
- package/src/locales/en.ts +8 -0
- package/src/locales/nl.ts +8 -0
- package/src/match.ts +50 -0
- package/src/segmented-keys.ts +33 -0
- package/src/theme.css +15 -0
- package/src/toast-store.ts +16 -6
- package/src/workspace/TabStrip.tsx +31 -2
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Search } from 'lucide-react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Autocomplete } from '@base-ui/react/autocomplete';
|
|
7
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
8
|
+
import { withClass } from '../class-name.js';
|
|
9
|
+
import { DialogPopup, DialogRoot } from "../dialog/parts.js";
|
|
10
|
+
import { Icon } from "../Icon.js";
|
|
11
|
+
import { Kbd } from "../Kbd.js";
|
|
12
|
+
import { mergeRefs } from '../merge-refs.js';
|
|
13
|
+
import { KEY_SHORTCUTS } from '../shortcut.js';
|
|
14
|
+
/* The field, for the popup to put the focus in when it opens: a control before it would take it otherwise. */
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
const InputRefContext = createContext(null);
|
|
17
|
+
/* A palette asks for a few words and shows rows of one line; a search whose rows are lines of source needs the wider one. */
|
|
18
|
+
const SIZE = {
|
|
19
|
+
md: 'w-[576px]',
|
|
20
|
+
lg: 'w-[760px]'
|
|
21
|
+
};
|
|
22
|
+
/*
|
|
23
|
+
* A dialog around a list that is always open. `open` and its handlers are the dialog's; the rest
|
|
24
|
+
* is Base UI's autocomplete, so the query, the items and their filter work as in a combobox. The
|
|
25
|
+
* first row is highlighted and stays so while the pointer leaves the list, which is what Enter runs.
|
|
26
|
+
*/
|
|
27
|
+
export function CommandPaletteRoot(t0) {
|
|
28
|
+
const $ = _c(22);
|
|
29
|
+
let children;
|
|
30
|
+
let defaultOpen;
|
|
31
|
+
let items;
|
|
32
|
+
let onOpenChange;
|
|
33
|
+
let onOpenChangeComplete;
|
|
34
|
+
let open;
|
|
35
|
+
let props;
|
|
36
|
+
let t1;
|
|
37
|
+
let t2;
|
|
38
|
+
if ($[0] !== t0) {
|
|
39
|
+
({
|
|
40
|
+
open,
|
|
41
|
+
defaultOpen,
|
|
42
|
+
onOpenChange,
|
|
43
|
+
onOpenChangeComplete,
|
|
44
|
+
autoHighlight: t1,
|
|
45
|
+
keepHighlight: t2,
|
|
46
|
+
items,
|
|
47
|
+
children,
|
|
48
|
+
...props
|
|
49
|
+
} = t0);
|
|
50
|
+
$[0] = t0;
|
|
51
|
+
$[1] = children;
|
|
52
|
+
$[2] = defaultOpen;
|
|
53
|
+
$[3] = items;
|
|
54
|
+
$[4] = onOpenChange;
|
|
55
|
+
$[5] = onOpenChangeComplete;
|
|
56
|
+
$[6] = open;
|
|
57
|
+
$[7] = props;
|
|
58
|
+
$[8] = t1;
|
|
59
|
+
$[9] = t2;
|
|
60
|
+
} else {
|
|
61
|
+
children = $[1];
|
|
62
|
+
defaultOpen = $[2];
|
|
63
|
+
items = $[3];
|
|
64
|
+
onOpenChange = $[4];
|
|
65
|
+
onOpenChangeComplete = $[5];
|
|
66
|
+
open = $[6];
|
|
67
|
+
props = $[7];
|
|
68
|
+
t1 = $[8];
|
|
69
|
+
t2 = $[9];
|
|
70
|
+
}
|
|
71
|
+
const autoHighlight = t1 === undefined ? "always" : t1;
|
|
72
|
+
const keepHighlight = t2 === undefined ? true : t2;
|
|
73
|
+
const inputRef = useRef(null);
|
|
74
|
+
let t3;
|
|
75
|
+
if ($[10] !== autoHighlight || $[11] !== children || $[12] !== items || $[13] !== keepHighlight || $[14] !== props) {
|
|
76
|
+
t3 = /*#__PURE__*/_jsx(InputRefContext, {
|
|
77
|
+
value: inputRef,
|
|
78
|
+
children: /*#__PURE__*/_jsx(Autocomplete.Root, {
|
|
79
|
+
...props,
|
|
80
|
+
items: items,
|
|
81
|
+
inline: true,
|
|
82
|
+
open: true,
|
|
83
|
+
autoHighlight: autoHighlight,
|
|
84
|
+
keepHighlight: keepHighlight,
|
|
85
|
+
children: children
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
$[10] = autoHighlight;
|
|
89
|
+
$[11] = children;
|
|
90
|
+
$[12] = items;
|
|
91
|
+
$[13] = keepHighlight;
|
|
92
|
+
$[14] = props;
|
|
93
|
+
$[15] = t3;
|
|
94
|
+
} else {
|
|
95
|
+
t3 = $[15];
|
|
96
|
+
}
|
|
97
|
+
let t4;
|
|
98
|
+
if ($[16] !== defaultOpen || $[17] !== onOpenChange || $[18] !== onOpenChangeComplete || $[19] !== open || $[20] !== t3) {
|
|
99
|
+
t4 = /*#__PURE__*/_jsx(DialogRoot, {
|
|
100
|
+
open: open,
|
|
101
|
+
defaultOpen: defaultOpen,
|
|
102
|
+
onOpenChange: onOpenChange,
|
|
103
|
+
onOpenChangeComplete: onOpenChangeComplete,
|
|
104
|
+
children: t3
|
|
105
|
+
});
|
|
106
|
+
$[16] = defaultOpen;
|
|
107
|
+
$[17] = onOpenChange;
|
|
108
|
+
$[18] = onOpenChangeComplete;
|
|
109
|
+
$[19] = open;
|
|
110
|
+
$[20] = t3;
|
|
111
|
+
$[21] = t4;
|
|
112
|
+
} else {
|
|
113
|
+
t4 = $[21];
|
|
114
|
+
}
|
|
115
|
+
return t4;
|
|
116
|
+
}
|
|
117
|
+
/*
|
|
118
|
+
* The dialog's surface. It hangs from a fixed line near the top instead of the middle: the list
|
|
119
|
+
* changes height with every key, and a centered popup would walk up and down the screen.
|
|
120
|
+
*/
|
|
121
|
+
export function CommandPalettePopup(t0) {
|
|
122
|
+
const $ = _c(15);
|
|
123
|
+
let className;
|
|
124
|
+
let initialFocus;
|
|
125
|
+
let props;
|
|
126
|
+
let t1;
|
|
127
|
+
if ($[0] !== t0) {
|
|
128
|
+
({
|
|
129
|
+
size: t1,
|
|
130
|
+
initialFocus,
|
|
131
|
+
className,
|
|
132
|
+
...props
|
|
133
|
+
} = t0);
|
|
134
|
+
$[0] = t0;
|
|
135
|
+
$[1] = className;
|
|
136
|
+
$[2] = initialFocus;
|
|
137
|
+
$[3] = props;
|
|
138
|
+
$[4] = t1;
|
|
139
|
+
} else {
|
|
140
|
+
className = $[1];
|
|
141
|
+
initialFocus = $[2];
|
|
142
|
+
props = $[3];
|
|
143
|
+
t1 = $[4];
|
|
144
|
+
}
|
|
145
|
+
const size = t1 === undefined ? "md" : t1;
|
|
146
|
+
const {
|
|
147
|
+
t
|
|
148
|
+
} = useTranslation("ui");
|
|
149
|
+
const inputRef = useContext(InputRefContext);
|
|
150
|
+
let t2;
|
|
151
|
+
if ($[5] !== t) {
|
|
152
|
+
t2 = t("palette.label");
|
|
153
|
+
$[5] = t;
|
|
154
|
+
$[6] = t2;
|
|
155
|
+
} else {
|
|
156
|
+
t2 = $[6];
|
|
157
|
+
}
|
|
158
|
+
const t3 = initialFocus ?? inputRef ?? undefined;
|
|
159
|
+
let t4;
|
|
160
|
+
if ($[7] !== className || $[8] !== size) {
|
|
161
|
+
t4 = withClass(clsx("top-[18vh] flex flex-col [translate:-50%_0]", SIZE[size]), className);
|
|
162
|
+
$[7] = className;
|
|
163
|
+
$[8] = size;
|
|
164
|
+
$[9] = t4;
|
|
165
|
+
} else {
|
|
166
|
+
t4 = $[9];
|
|
167
|
+
}
|
|
168
|
+
let t5;
|
|
169
|
+
if ($[10] !== props || $[11] !== t2 || $[12] !== t3 || $[13] !== t4) {
|
|
170
|
+
t5 = /*#__PURE__*/_jsx(DialogPopup, {
|
|
171
|
+
"aria-label": t2,
|
|
172
|
+
initialFocus: t3,
|
|
173
|
+
className: t4,
|
|
174
|
+
...props
|
|
175
|
+
});
|
|
176
|
+
$[10] = props;
|
|
177
|
+
$[11] = t2;
|
|
178
|
+
$[12] = t3;
|
|
179
|
+
$[13] = t4;
|
|
180
|
+
$[14] = t5;
|
|
181
|
+
} else {
|
|
182
|
+
t5 = $[14];
|
|
183
|
+
}
|
|
184
|
+
return t5;
|
|
185
|
+
}
|
|
186
|
+
/* The field across the top. It keeps the keys while the arrows move the highlight; a control beside it should not take the focus on a click. */
|
|
187
|
+
export function CommandPaletteInput(t0) {
|
|
188
|
+
const $ = _c(29);
|
|
189
|
+
let className;
|
|
190
|
+
let leading;
|
|
191
|
+
let props;
|
|
192
|
+
let ref;
|
|
193
|
+
let t1;
|
|
194
|
+
let t2;
|
|
195
|
+
let trailing;
|
|
196
|
+
if ($[0] !== t0) {
|
|
197
|
+
({
|
|
198
|
+
leading,
|
|
199
|
+
trailing,
|
|
200
|
+
escapeHint: t1,
|
|
201
|
+
mono: t2,
|
|
202
|
+
className,
|
|
203
|
+
ref,
|
|
204
|
+
...props
|
|
205
|
+
} = t0);
|
|
206
|
+
$[0] = t0;
|
|
207
|
+
$[1] = className;
|
|
208
|
+
$[2] = leading;
|
|
209
|
+
$[3] = props;
|
|
210
|
+
$[4] = ref;
|
|
211
|
+
$[5] = t1;
|
|
212
|
+
$[6] = t2;
|
|
213
|
+
$[7] = trailing;
|
|
214
|
+
} else {
|
|
215
|
+
className = $[1];
|
|
216
|
+
leading = $[2];
|
|
217
|
+
props = $[3];
|
|
218
|
+
ref = $[4];
|
|
219
|
+
t1 = $[5];
|
|
220
|
+
t2 = $[6];
|
|
221
|
+
trailing = $[7];
|
|
222
|
+
}
|
|
223
|
+
const escapeHint = t1 === undefined ? true : t1;
|
|
224
|
+
const mono = t2 === undefined ? false : t2;
|
|
225
|
+
const inputRef = useContext(InputRefContext);
|
|
226
|
+
let t3;
|
|
227
|
+
if ($[8] !== className) {
|
|
228
|
+
t3 = clsx("relative flex shrink-0 items-center gap-2 border-b border-border px-3", className);
|
|
229
|
+
$[8] = className;
|
|
230
|
+
$[9] = t3;
|
|
231
|
+
} else {
|
|
232
|
+
t3 = $[9];
|
|
233
|
+
}
|
|
234
|
+
let t4;
|
|
235
|
+
if ($[10] !== leading) {
|
|
236
|
+
t4 = leading ?? /*#__PURE__*/_jsx(Icon, {
|
|
237
|
+
icon: Search,
|
|
238
|
+
size: 14,
|
|
239
|
+
className: "shrink-0 text-text-faint"
|
|
240
|
+
});
|
|
241
|
+
$[10] = leading;
|
|
242
|
+
$[11] = t4;
|
|
243
|
+
} else {
|
|
244
|
+
t4 = $[11];
|
|
245
|
+
}
|
|
246
|
+
const t5 = inputRef ?? undefined;
|
|
247
|
+
let t6;
|
|
248
|
+
if ($[12] !== ref || $[13] !== t5) {
|
|
249
|
+
t6 = mergeRefs(ref, t5);
|
|
250
|
+
$[12] = ref;
|
|
251
|
+
$[13] = t5;
|
|
252
|
+
$[14] = t6;
|
|
253
|
+
} else {
|
|
254
|
+
t6 = $[14];
|
|
255
|
+
}
|
|
256
|
+
const t7 = mono && "font-mono text-code";
|
|
257
|
+
let t8;
|
|
258
|
+
if ($[15] !== t7) {
|
|
259
|
+
t8 = clsx("h-11 min-w-0 flex-1 bg-transparent text-sm text-text outline-none placeholder:text-text-faint", t7);
|
|
260
|
+
$[15] = t7;
|
|
261
|
+
$[16] = t8;
|
|
262
|
+
} else {
|
|
263
|
+
t8 = $[16];
|
|
264
|
+
}
|
|
265
|
+
let t9;
|
|
266
|
+
if ($[17] !== props || $[18] !== t6 || $[19] !== t8) {
|
|
267
|
+
t9 = /*#__PURE__*/_jsx(Autocomplete.Input, {
|
|
268
|
+
ref: t6,
|
|
269
|
+
spellCheck: false,
|
|
270
|
+
className: t8,
|
|
271
|
+
...props
|
|
272
|
+
});
|
|
273
|
+
$[17] = props;
|
|
274
|
+
$[18] = t6;
|
|
275
|
+
$[19] = t8;
|
|
276
|
+
$[20] = t9;
|
|
277
|
+
} else {
|
|
278
|
+
t9 = $[20];
|
|
279
|
+
}
|
|
280
|
+
let t10;
|
|
281
|
+
if ($[21] !== escapeHint) {
|
|
282
|
+
t10 = escapeHint && /*#__PURE__*/_jsx(Kbd, {
|
|
283
|
+
shortcut: KEY_SHORTCUTS.escape,
|
|
284
|
+
variant: "inline",
|
|
285
|
+
className: "shrink-0"
|
|
286
|
+
});
|
|
287
|
+
$[21] = escapeHint;
|
|
288
|
+
$[22] = t10;
|
|
289
|
+
} else {
|
|
290
|
+
t10 = $[22];
|
|
291
|
+
}
|
|
292
|
+
let t11;
|
|
293
|
+
if ($[23] !== t10 || $[24] !== t3 || $[25] !== t4 || $[26] !== t9 || $[27] !== trailing) {
|
|
294
|
+
t11 = /*#__PURE__*/_jsxs("div", {
|
|
295
|
+
className: t3,
|
|
296
|
+
children: [t4, t9, trailing, t10]
|
|
297
|
+
});
|
|
298
|
+
$[23] = t10;
|
|
299
|
+
$[24] = t3;
|
|
300
|
+
$[25] = t4;
|
|
301
|
+
$[26] = t9;
|
|
302
|
+
$[27] = trailing;
|
|
303
|
+
$[28] = t11;
|
|
304
|
+
} else {
|
|
305
|
+
t11 = $[28];
|
|
306
|
+
}
|
|
307
|
+
return t11;
|
|
308
|
+
}
|
|
309
|
+
/* The rows. It scrolls on its own, so the field and the footer stay put. */
|
|
310
|
+
export function CommandPaletteList(t0) {
|
|
311
|
+
const $ = _c(11);
|
|
312
|
+
let className;
|
|
313
|
+
let props;
|
|
314
|
+
if ($[0] !== t0) {
|
|
315
|
+
({
|
|
316
|
+
className,
|
|
317
|
+
...props
|
|
318
|
+
} = t0);
|
|
319
|
+
$[0] = t0;
|
|
320
|
+
$[1] = className;
|
|
321
|
+
$[2] = props;
|
|
322
|
+
} else {
|
|
323
|
+
className = $[1];
|
|
324
|
+
props = $[2];
|
|
325
|
+
}
|
|
326
|
+
const {
|
|
327
|
+
t
|
|
328
|
+
} = useTranslation("ui");
|
|
329
|
+
let t1;
|
|
330
|
+
if ($[3] !== t) {
|
|
331
|
+
t1 = t("palette.results");
|
|
332
|
+
$[3] = t;
|
|
333
|
+
$[4] = t1;
|
|
334
|
+
} else {
|
|
335
|
+
t1 = $[4];
|
|
336
|
+
}
|
|
337
|
+
let t2;
|
|
338
|
+
if ($[5] !== className) {
|
|
339
|
+
t2 = withClass("max-h-[50vh] min-h-0 overflow-y-auto overscroll-contain scroll-py-1.5 not-empty:p-1.5", className);
|
|
340
|
+
$[5] = className;
|
|
341
|
+
$[6] = t2;
|
|
342
|
+
} else {
|
|
343
|
+
t2 = $[6];
|
|
344
|
+
}
|
|
345
|
+
let t3;
|
|
346
|
+
if ($[7] !== props || $[8] !== t1 || $[9] !== t2) {
|
|
347
|
+
t3 = /*#__PURE__*/_jsx(Autocomplete.List, {
|
|
348
|
+
"aria-label": t1,
|
|
349
|
+
className: t2,
|
|
350
|
+
...props
|
|
351
|
+
});
|
|
352
|
+
$[7] = props;
|
|
353
|
+
$[8] = t1;
|
|
354
|
+
$[9] = t2;
|
|
355
|
+
$[10] = t3;
|
|
356
|
+
} else {
|
|
357
|
+
t3 = $[10];
|
|
358
|
+
}
|
|
359
|
+
return t3;
|
|
360
|
+
}
|
|
361
|
+
/* Under the list: the keys that work here, a count, an action that leaves the palette. */
|
|
362
|
+
export function CommandPaletteFooter(t0) {
|
|
363
|
+
const $ = _c(14);
|
|
364
|
+
let className;
|
|
365
|
+
let props;
|
|
366
|
+
let ref;
|
|
367
|
+
let render;
|
|
368
|
+
if ($[0] !== t0) {
|
|
369
|
+
({
|
|
370
|
+
render,
|
|
371
|
+
className,
|
|
372
|
+
ref,
|
|
373
|
+
...props
|
|
374
|
+
} = t0);
|
|
375
|
+
$[0] = t0;
|
|
376
|
+
$[1] = className;
|
|
377
|
+
$[2] = props;
|
|
378
|
+
$[3] = ref;
|
|
379
|
+
$[4] = render;
|
|
380
|
+
} else {
|
|
381
|
+
className = $[1];
|
|
382
|
+
props = $[2];
|
|
383
|
+
ref = $[3];
|
|
384
|
+
render = $[4];
|
|
385
|
+
}
|
|
386
|
+
let t1;
|
|
387
|
+
if ($[5] !== className) {
|
|
388
|
+
t1 = clsx("flex shrink-0 items-center gap-3 border-t border-border px-3 py-2 text-xs text-text-faint", className);
|
|
389
|
+
$[5] = className;
|
|
390
|
+
$[6] = t1;
|
|
391
|
+
} else {
|
|
392
|
+
t1 = $[6];
|
|
393
|
+
}
|
|
394
|
+
let t2;
|
|
395
|
+
if ($[7] !== props || $[8] !== t1) {
|
|
396
|
+
t2 = {
|
|
397
|
+
...props,
|
|
398
|
+
className: t1
|
|
399
|
+
};
|
|
400
|
+
$[7] = props;
|
|
401
|
+
$[8] = t1;
|
|
402
|
+
$[9] = t2;
|
|
403
|
+
} else {
|
|
404
|
+
t2 = $[9];
|
|
405
|
+
}
|
|
406
|
+
let t3;
|
|
407
|
+
if ($[10] !== ref || $[11] !== render || $[12] !== t2) {
|
|
408
|
+
t3 = {
|
|
409
|
+
render,
|
|
410
|
+
ref,
|
|
411
|
+
defaultTagName: "div",
|
|
412
|
+
props: t2
|
|
413
|
+
};
|
|
414
|
+
$[10] = ref;
|
|
415
|
+
$[11] = render;
|
|
416
|
+
$[12] = t2;
|
|
417
|
+
$[13] = t3;
|
|
418
|
+
} else {
|
|
419
|
+
t3 = $[13];
|
|
420
|
+
}
|
|
421
|
+
return useRender(t3);
|
|
422
|
+
}
|
|
@@ -2,6 +2,7 @@ export declare const formatDateTime: (at: Date | number, options: Intl.DateTimeF
|
|
|
2
2
|
export declare const formatClock: (at: Date | number, timeZone?: string) => string;
|
|
3
3
|
export declare const formatWeekdayClock: (at: Date | number) => string;
|
|
4
4
|
export declare const formatHour: (at: Date | number) => string;
|
|
5
|
+
export declare const formatWeekday: (at: Date | number, width?: 'short' | 'long') => string;
|
|
5
6
|
export declare const formatDay: (at: Date | number, timeZone?: string) => string;
|
|
6
7
|
export declare const formatDayWithYear: (at: Date | number, timeZone?: string) => string;
|
|
7
8
|
export declare const formatWeekdayDay: (at: Date | number) => string;
|
package/dist/format/datetime.js
CHANGED
|
@@ -31,6 +31,12 @@ const WEEKDAY_CLOCK = {
|
|
|
31
31
|
const HOUR = {
|
|
32
32
|
hour: 'numeric'
|
|
33
33
|
};
|
|
34
|
+
const WEEKDAY = {
|
|
35
|
+
weekday: 'short'
|
|
36
|
+
};
|
|
37
|
+
const WEEKDAY_LONG = {
|
|
38
|
+
weekday: 'long'
|
|
39
|
+
};
|
|
34
40
|
const DAY = {
|
|
35
41
|
month: 'short',
|
|
36
42
|
day: 'numeric'
|
|
@@ -75,6 +81,8 @@ export const formatClock = (at, timeZone) => formatDateTime(at, timeZone === und
|
|
|
75
81
|
export const formatWeekdayClock = at => formatDateTime(at, WEEKDAY_CLOCK);
|
|
76
82
|
/* An hour of the day on its own, for the foot of a chart: `08`, or `8 AM` where that is the clock. */
|
|
77
83
|
export const formatHour = at => formatDateTime(at, HOUR);
|
|
84
|
+
/* The day of the week on its own, for the side of a grid by weekday: `Sat`, or `Saturday` when `long`. */
|
|
85
|
+
export const formatWeekday = (at, width = 'short') => formatDateTime(at, width === 'long' ? WEEKDAY_LONG : WEEKDAY);
|
|
78
86
|
/* `19 Sep`, the short date a row falls back to once "days ago" stops meaning anything. */
|
|
79
87
|
export const formatDay = (at, timeZone) => formatDateTime(at, timeZone === undefined ? DAY : {
|
|
80
88
|
...DAY,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const formatDuration: (ms: number) => string;
|
|
2
|
+
export declare const formatPreciseDuration: (ms: number) => string;
|
|
2
3
|
export declare const formatCountdown: (ms: number) => string;
|
|
3
4
|
export declare const formatElapsedShort: (ms: number) => string;
|
|
4
5
|
export declare const formatClockDuration: (ms: number) => string;
|
package/dist/format/duration.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relativeFormatter } from './locale.js';
|
|
2
|
-
import { formatDecimal, formatNumber } from './number.js';
|
|
2
|
+
import { formatDecimal, formatNumber, formatRounded } from './number.js';
|
|
3
3
|
const SECOND = 1000;
|
|
4
4
|
const MINUTE = 60 * SECOND;
|
|
5
5
|
const HOUR = 60 * MINUTE;
|
|
@@ -20,6 +20,29 @@ export const formatDuration = ms => {
|
|
|
20
20
|
}
|
|
21
21
|
return `${formatDecimal(minutes / 60)} h`;
|
|
22
22
|
};
|
|
23
|
+
/*
|
|
24
|
+
* How long a short measurement took, below a second too: `0.4 ms`, `123 ms`, `1.42 s`, and as `formatDuration` from a
|
|
25
|
+
* minute. Each unit rounds before it is chosen, so 999.6 ms reads as `1 s` and not as `1,000 ms`.
|
|
26
|
+
*/
|
|
27
|
+
export const formatPreciseDuration = ms => {
|
|
28
|
+
const value = Math.max(0, ms);
|
|
29
|
+
const tenths = Math.round(value * 10) / 10;
|
|
30
|
+
if (tenths < 10) {
|
|
31
|
+
return `${formatRounded(tenths, 1)} ms`;
|
|
32
|
+
}
|
|
33
|
+
if (Math.round(value) < SECOND) {
|
|
34
|
+
return `${formatNumber(Math.round(value))} ms`;
|
|
35
|
+
}
|
|
36
|
+
const hundredths = Math.round(value / 10) / 100;
|
|
37
|
+
if (hundredths < 10) {
|
|
38
|
+
return `${formatRounded(hundredths, 2)} s`;
|
|
39
|
+
}
|
|
40
|
+
const seconds = Math.round(value / 100) / 10;
|
|
41
|
+
if (seconds < 60) {
|
|
42
|
+
return `${formatRounded(seconds, 1)} s`;
|
|
43
|
+
}
|
|
44
|
+
return formatDuration(value);
|
|
45
|
+
};
|
|
23
46
|
/* How long a window still has, tight enough for the end of a bar: `4d 3h`, `12h 8m`, `9m`. */
|
|
24
47
|
export const formatCountdown = ms => {
|
|
25
48
|
const left = Math.max(0, ms);
|
package/dist/format/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { formatAge, formatClock, formatDateTime, formatDay, formatDayClock, formatDayClockWithYear, formatDayWithYear, formatHour, formatMoment, formatNumericDate, formatWeekdayClock, formatWeekdayDay, isSameDay } from './datetime.ts';
|
|
2
|
-
export { formatAgo, formatClockDuration, formatCountdown, formatDuration, formatElapsedShort } from './duration.ts';
|
|
1
|
+
export { formatAge, formatClock, formatDateTime, formatDay, formatDayClock, formatDayClockWithYear, formatDayWithYear, formatHour, formatMoment, formatNumericDate, formatWeekday, formatWeekdayClock, formatWeekdayDay, isSameDay } from './datetime.ts';
|
|
2
|
+
export { formatAgo, formatClockDuration, formatCountdown, formatDuration, formatElapsedShort, formatPreciseDuration } from './duration.ts';
|
|
3
3
|
export { formatLocale, labelCollator, setFormatSource, systemLocale, useFormatLocale, type FormatSource } from './locale.ts';
|
|
4
4
|
export { formatBytes, formatDecimal, formatMoney, formatNumber, formatNumeral, formatPercent, formatRounded, formatTokens, formatUsdSignificant } from './number.ts';
|
|
5
5
|
export { FORMAT_LANGUAGE, FORMAT_REGIONS, FORMAT_REGION_CHOICES, FORMAT_SYSTEM, formatRegionFrom, regionName } from './regions.ts';
|
package/dist/format/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Every number, date, time and duration a person reads, written the way the language and the region they set ask for. */
|
|
2
|
-
export { formatAge, formatClock, formatDateTime, formatDay, formatDayClock, formatDayClockWithYear, formatDayWithYear, formatHour, formatMoment, formatNumericDate, formatWeekdayClock, formatWeekdayDay, isSameDay } from './datetime.js';
|
|
3
|
-
export { formatAgo, formatClockDuration, formatCountdown, formatDuration, formatElapsedShort } from './duration.js';
|
|
2
|
+
export { formatAge, formatClock, formatDateTime, formatDay, formatDayClock, formatDayClockWithYear, formatDayWithYear, formatHour, formatMoment, formatNumericDate, formatWeekday, formatWeekdayClock, formatWeekdayDay, isSameDay } from './datetime.js';
|
|
3
|
+
export { formatAgo, formatClockDuration, formatCountdown, formatDuration, formatElapsedShort, formatPreciseDuration } from './duration.js';
|
|
4
4
|
export { formatLocale, labelCollator, setFormatSource, systemLocale, useFormatLocale } from './locale.js';
|
|
5
5
|
export { formatBytes, formatDecimal, formatMoney, formatNumber, formatNumeral, formatPercent, formatRounded, formatTokens, formatUsdSignificant } from './number.js';
|
|
6
6
|
export { FORMAT_LANGUAGE, FORMAT_REGIONS, FORMAT_REGION_CHOICES, FORMAT_SYSTEM, formatRegionFrom, regionName } from './regions.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * as Combobox from './combobox/index.parts.ts';
|
|
2
|
+
export * as CommandPalette from './command-palette/index.parts.ts';
|
|
1
3
|
export * as ContextMenu from './context-menu/index.parts.ts';
|
|
2
4
|
export * as FileTree from './file-tree/index.parts.ts';
|
|
3
5
|
export * as Tree from './tree/index.parts.ts';
|
|
@@ -7,6 +9,8 @@ export * as Menu from './menu/index.parts.ts';
|
|
|
7
9
|
export * as Popover from './popover/index.parts.ts';
|
|
8
10
|
export * as PreviewCard from './preview-card/index.parts.ts';
|
|
9
11
|
export * as Tabs from './tabs/index.parts.ts';
|
|
12
|
+
export type { ComboboxInputProps, ComboboxItemProps, ComboboxPopupProps } from './combobox/parts.tsx';
|
|
13
|
+
export type { CommandPaletteFooterProps, CommandPaletteInputProps, CommandPalettePopupProps, CommandPaletteRootProps } from './command-palette/parts.tsx';
|
|
10
14
|
export type { DialogDescriptionProps, DialogFooterProps, DialogPopupProps, DialogTextProps, DialogTitleProps } from './dialog/parts.tsx';
|
|
11
15
|
export type { MenuCheckProps, MenuHintProps, MenuLabelProps, MenuPopupProps, MenuRowActionProps, MenuRowProps, MenuRowSubmenuTriggerProps } from './menu/parts.tsx';
|
|
12
16
|
export type { KeyValueListItemProps, KeyValueListNameProps, KeyValueListRootProps, KeyValueListValueProps } from './key-value-list/parts.tsx';
|
|
@@ -20,6 +24,7 @@ export { Checkbox, type CheckboxProps } from './Checkbox.tsx';
|
|
|
20
24
|
export { ChoiceCards, type Choice, type ChoiceCardsProps } from './ChoiceCards.tsx';
|
|
21
25
|
export { CloseButton, type CloseButtonProps } from './CloseButton.tsx';
|
|
22
26
|
export { ColorSwatch, type ColorSwatchProps } from './ColorSwatch.tsx';
|
|
27
|
+
export { CopyButton, type CopyButtonProps } from './CopyButton.tsx';
|
|
23
28
|
export { ColorWheelPicker, type ColorWheelPickerProps } from './ColorWheelPicker.tsx';
|
|
24
29
|
export { ColumnResizeHandle, type ColumnResizeHandleProps } from './ColumnResizeHandle.tsx';
|
|
25
30
|
export { DisabledReason, type DisabledReasonProps } from './DisabledReason.tsx';
|
|
@@ -40,6 +45,7 @@ export { PanelEmpty, type PanelEmptyProps } from './PanelEmpty.tsx';
|
|
|
40
45
|
export { PanelHeader, type PanelHeaderProps } from './PanelHeader.tsx';
|
|
41
46
|
export { Pill, type PillProps } from './Pill.tsx';
|
|
42
47
|
export { PromptDialog, type PromptDialogProps } from './PromptDialog.tsx';
|
|
48
|
+
export { RelativeTime, type RelativeTimeProps } from './RelativeTime.tsx';
|
|
43
49
|
export { ProjectSwitcher, ProjectSwitcherGroups, type ProjectSwitcherItem, type ProjectSwitcherProps } from './ProjectSwitcher.tsx';
|
|
44
50
|
export { SectionLabel, type SectionLabelProps } from './SectionLabel.tsx';
|
|
45
51
|
export { SegmentBar, type SegmentBarPart, type SegmentBarProps } from './SegmentBar.tsx';
|
|
@@ -72,6 +78,7 @@ export type { LazyComponent } from './lazy.tsx';
|
|
|
72
78
|
export { LazyBoundary } from './LazyBoundary.tsx';
|
|
73
79
|
export type { LazyBoundaryProps } from './LazyBoundary.tsx';
|
|
74
80
|
export { UI_NAMESPACE, UI_RESOURCES } from './locales.ts';
|
|
81
|
+
export { matchScore } from './match.ts';
|
|
75
82
|
export { isApplePlatform } from './platform.ts';
|
|
76
83
|
export { prefetcher, type Loader, type WhenIdle } from './prefetch.ts';
|
|
77
84
|
export { selectAllWithin, selectionWithin } from './selection.ts';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* The components, hooks and helpers of the library. Every name here is public API; the snapshot in
|
|
3
3
|
* `exports.test.ts` turns any change to this list into a diff someone has to accept.
|
|
4
4
|
*/
|
|
5
|
+
export * as Combobox from './combobox/index.parts.js';
|
|
6
|
+
export * as CommandPalette from './command-palette/index.parts.js';
|
|
5
7
|
export * as ContextMenu from './context-menu/index.parts.js';
|
|
6
8
|
export * as FileTree from './file-tree/index.parts.js';
|
|
7
9
|
export * as Tree from './tree/index.parts.js';
|
|
@@ -19,6 +21,7 @@ export { Checkbox } from "./Checkbox.js";
|
|
|
19
21
|
export { ChoiceCards } from "./ChoiceCards.js";
|
|
20
22
|
export { CloseButton } from "./CloseButton.js";
|
|
21
23
|
export { ColorSwatch } from "./ColorSwatch.js";
|
|
24
|
+
export { CopyButton } from "./CopyButton.js";
|
|
22
25
|
export { ColorWheelPicker } from "./ColorWheelPicker.js";
|
|
23
26
|
export { ColumnResizeHandle } from "./ColumnResizeHandle.js";
|
|
24
27
|
export { DisabledReason } from "./DisabledReason.js";
|
|
@@ -39,6 +42,7 @@ export { PanelEmpty } from "./PanelEmpty.js";
|
|
|
39
42
|
export { PanelHeader } from "./PanelHeader.js";
|
|
40
43
|
export { Pill } from "./Pill.js";
|
|
41
44
|
export { PromptDialog } from "./PromptDialog.js";
|
|
45
|
+
export { RelativeTime } from "./RelativeTime.js";
|
|
42
46
|
export { ProjectSwitcher, ProjectSwitcherGroups } from "./ProjectSwitcher.js";
|
|
43
47
|
export { SectionLabel } from "./SectionLabel.js";
|
|
44
48
|
export { SegmentBar } from "./SegmentBar.js";
|
|
@@ -68,6 +72,7 @@ export { cameThroughPortal, isInFloatingLayer } from './floating.js';
|
|
|
68
72
|
export { LoadedComponent, lazyDialog, lazyNamed, onLazyOpenError } from "./lazy.js";
|
|
69
73
|
export { LazyBoundary } from "./LazyBoundary.js";
|
|
70
74
|
export { UI_NAMESPACE, UI_RESOURCES } from './locales.js';
|
|
75
|
+
export { matchScore } from './match.js';
|
|
71
76
|
export { isApplePlatform } from './platform.js';
|
|
72
77
|
export { prefetcher } from './prefetch.js';
|
|
73
78
|
export { selectAllWithin, selectionWithin } from './selection.js';
|
package/dist/locales/en.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare const _default: {
|
|
|
2
2
|
action: {
|
|
3
3
|
cancel: string;
|
|
4
4
|
copy: string;
|
|
5
|
+
copied: string;
|
|
5
6
|
copyError: string;
|
|
6
7
|
dismiss: string;
|
|
7
8
|
reload: string;
|
|
@@ -38,6 +39,13 @@ declare const _default: {
|
|
|
38
39
|
search: string;
|
|
39
40
|
noMatch: string;
|
|
40
41
|
};
|
|
42
|
+
combobox: {
|
|
43
|
+
suggestions: string;
|
|
44
|
+
};
|
|
45
|
+
palette: {
|
|
46
|
+
label: string;
|
|
47
|
+
results: string;
|
|
48
|
+
};
|
|
41
49
|
iconPicker: {
|
|
42
50
|
label: string;
|
|
43
51
|
none: string;
|
package/dist/locales/en.js
CHANGED
|
@@ -2,6 +2,7 @@ export default {
|
|
|
2
2
|
action: {
|
|
3
3
|
cancel: 'Cancel',
|
|
4
4
|
copy: 'Copy',
|
|
5
|
+
copied: 'Copied',
|
|
5
6
|
copyError: 'Copy error',
|
|
6
7
|
dismiss: 'Dismiss',
|
|
7
8
|
reload: 'Reload',
|
|
@@ -38,6 +39,13 @@ export default {
|
|
|
38
39
|
search: 'Search',
|
|
39
40
|
noMatch: 'No match for “{{query}}”'
|
|
40
41
|
},
|
|
42
|
+
combobox: {
|
|
43
|
+
suggestions: 'Suggestions'
|
|
44
|
+
},
|
|
45
|
+
palette: {
|
|
46
|
+
label: 'Command palette',
|
|
47
|
+
results: 'Results'
|
|
48
|
+
},
|
|
41
49
|
iconPicker: {
|
|
42
50
|
label: 'Icon',
|
|
43
51
|
none: 'No icon',
|
package/dist/locales/nl.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare const _default: {
|
|
|
2
2
|
action: {
|
|
3
3
|
cancel: string;
|
|
4
4
|
copy: string;
|
|
5
|
+
copied: string;
|
|
5
6
|
copyError: string;
|
|
6
7
|
dismiss: string;
|
|
7
8
|
reload: string;
|
|
@@ -38,6 +39,13 @@ declare const _default: {
|
|
|
38
39
|
search: string;
|
|
39
40
|
noMatch: string;
|
|
40
41
|
};
|
|
42
|
+
combobox: {
|
|
43
|
+
suggestions: string;
|
|
44
|
+
};
|
|
45
|
+
palette: {
|
|
46
|
+
label: string;
|
|
47
|
+
results: string;
|
|
48
|
+
};
|
|
41
49
|
iconPicker: {
|
|
42
50
|
label: string;
|
|
43
51
|
none: string;
|
package/dist/locales/nl.js
CHANGED
|
@@ -2,6 +2,7 @@ export default {
|
|
|
2
2
|
action: {
|
|
3
3
|
cancel: 'Annuleren',
|
|
4
4
|
copy: 'Kopiëren',
|
|
5
|
+
copied: 'Gekopieerd',
|
|
5
6
|
copyError: 'Fout kopiëren',
|
|
6
7
|
dismiss: 'Sluiten',
|
|
7
8
|
reload: 'Herladen',
|
|
@@ -38,6 +39,13 @@ export default {
|
|
|
38
39
|
search: 'Zoeken',
|
|
39
40
|
noMatch: 'Geen resultaat voor “{{query}}”'
|
|
40
41
|
},
|
|
42
|
+
combobox: {
|
|
43
|
+
suggestions: 'Suggesties'
|
|
44
|
+
},
|
|
45
|
+
palette: {
|
|
46
|
+
label: 'Opdrachtenpalet',
|
|
47
|
+
results: 'Resultaten'
|
|
48
|
+
},
|
|
41
49
|
iconPicker: {
|
|
42
50
|
label: 'Icoon',
|
|
43
51
|
none: 'Geen icoon',
|
package/dist/match.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function matchScore(text: string, query: string): number | null;
|