nish-ui 2.1.3 → 3.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/README.md +6 -2
- package/dist/chart.js +1 -1
- package/dist/elements-all.js +58 -58
- package/dist/elements-charts.js +1 -1
- package/dist/elements-data.js +1 -1
- package/dist/elements-forms.js +1 -1
- package/dist/elements.js +4 -4
- package/dist/esm/components/accordion.js +3 -2
- package/dist/esm/components/app-shell.js +3 -2
- package/dist/esm/components/avatar.js +4 -3
- package/dist/esm/components/breadcrumbs.js +3 -2
- package/dist/esm/components/calendar-base.js +292 -0
- package/dist/esm/components/calendar-classes.js +78 -0
- package/dist/esm/components/calendar.js +22 -254
- package/dist/esm/components/canvas/legend.js +3 -2
- package/dist/esm/components/canvas/node.js +3 -2
- package/dist/esm/components/canvas/system-canvas.js +3 -2
- package/dist/esm/components/carousel.js +3 -2
- package/dist/esm/components/charts.js +8 -7
- package/dist/esm/components/combobox.js +3 -2
- package/dist/esm/components/command.js +4 -3
- package/dist/esm/components/context-menu.js +3 -2
- package/dist/esm/components/data.js +4 -3
- package/dist/esm/components/date-picker.js +4 -3
- package/dist/esm/components/date-range-picker.js +214 -0
- package/dist/esm/components/display.js +7 -6
- package/dist/esm/components/drawer.js +3 -2
- package/dist/esm/components/error-boundary.js +4 -2
- package/dist/esm/components/feedback.js +7 -6
- package/dist/esm/components/file-dropzone.js +3 -2
- package/dist/esm/components/filters.js +4 -3
- package/dist/esm/components/flow.js +6 -5
- package/dist/esm/components/forms.js +14 -8
- package/dist/esm/components/hooks.js +2 -2
- package/dist/esm/components/hover-card.js +2 -2
- package/dist/esm/components/inbox.js +4 -2
- package/dist/esm/components/layout.js +5 -4
- package/dist/esm/components/media.js +3 -2
- package/dist/esm/components/menu.js +5 -4
- package/dist/esm/components/modal.js +4 -3
- package/dist/esm/components/more-sheet.js +3 -2
- package/dist/esm/components/multi-select.js +3 -2
- package/dist/esm/components/nav-items.js +4 -3
- package/dist/esm/components/nav.js +5 -4
- package/dist/esm/components/overlay-dialog.js +3 -2
- package/dist/esm/components/pagination.js +3 -2
- package/dist/esm/components/popover.js +2 -2
- package/dist/esm/components/portal.js +2 -2
- package/dist/esm/components/progress.js +3 -2
- package/dist/esm/components/provider.js +34 -5
- package/dist/esm/components/range-calendar.js +123 -0
- package/dist/esm/components/service-tokens.js +4 -3
- package/dist/esm/components/settings.js +4 -3
- package/dist/esm/components/slider.js +3 -2
- package/dist/esm/components/split.js +4 -3
- package/dist/esm/components/strings.js +178 -60
- package/dist/esm/components/tag-input.js +3 -2
- package/dist/esm/components/theme-toggle.js +3 -2
- package/dist/esm/components/time-field-classes.js +110 -0
- package/dist/esm/components/time-field.js +309 -0
- package/dist/esm/components/toast-card.js +155 -0
- package/dist/esm/components/toast-store.js +136 -0
- package/dist/esm/components/toast.js +38 -241
- package/dist/esm/components/tooltip.js +2 -2
- package/dist/esm/components/tree-view.js +40 -46
- package/dist/esm/components/virtual-table.js +3 -2
- package/dist/esm/index.js +6 -20
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/system-canvas.js +4 -0
- package/dist/esm/theme.js +7 -7
- package/dist/format.js +1 -1
- package/dist/index.d.ts +172 -24
- package/dist/system-canvas.d.ts +183 -2
- package/dist/theme.d.ts +21 -3
- package/dist/theme.global.js +21 -136
- package/dist/theme.js +21 -136
- package/package.json +1 -1
- package/dist/system-canvas-BLuWd69H.d.ts +0 -183
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/range-calendar.tsx
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { getDefaultLocale } from "../format.js";
|
|
6
|
+
import {
|
|
7
|
+
firstDisabledIn,
|
|
8
|
+
fullDate,
|
|
9
|
+
inRange,
|
|
10
|
+
monthOf,
|
|
11
|
+
orderRange,
|
|
12
|
+
parseIso,
|
|
13
|
+
resolveLocale,
|
|
14
|
+
toRange
|
|
15
|
+
} from "./calendar-classes.js";
|
|
16
|
+
import { CalendarBase } from "./calendar-base.js";
|
|
17
|
+
import { useStrings, useNishContext } from "./provider.js";
|
|
18
|
+
import { PICKER_STRINGS } from "./strings.js";
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
var warned = /* @__PURE__ */ new Set();
|
|
21
|
+
var OUTSIDE = { filled: false, band: null, ariaSelected: false };
|
|
22
|
+
function warnOnce(key, message) {
|
|
23
|
+
if (process.env.NODE_ENV === "production" || warned.has(key)) return;
|
|
24
|
+
warned.add(key);
|
|
25
|
+
console.warn(message);
|
|
26
|
+
}
|
|
27
|
+
function checkRange(prop, v) {
|
|
28
|
+
if (v == null) return null;
|
|
29
|
+
const r = toRange(v);
|
|
30
|
+
if (!r) {
|
|
31
|
+
warnOnce(`${prop}:shape`, `RangeCalendar: "${prop}" must be { from, to } with YYYY-MM-DD days`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (v.from > v.to) warnOnce(`${prop}:order`, `RangeCalendar: "${prop}" has from after to; the days were swapped`);
|
|
35
|
+
return r;
|
|
36
|
+
}
|
|
37
|
+
function RangeCalendar({
|
|
38
|
+
value,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onValueChange,
|
|
41
|
+
allowDisabledInRange = false,
|
|
42
|
+
...shared
|
|
43
|
+
}) {
|
|
44
|
+
const strings = useStrings(PICKER_STRINGS);
|
|
45
|
+
const config = useNishContext();
|
|
46
|
+
const loc = resolveLocale(shared.locale ?? config.locale ?? getDefaultLocale());
|
|
47
|
+
const { min: minProp, max: maxProp, isDateDisabled } = shared;
|
|
48
|
+
const min = minProp != null && parseIso(minProp) ? minProp : null;
|
|
49
|
+
const max = maxProp != null && parseIso(maxProp) ? maxProp : null;
|
|
50
|
+
const controlled = value !== void 0;
|
|
51
|
+
const [own, setOwn] = useState(() => checkRange("defaultValue", defaultValue));
|
|
52
|
+
const [anchor, setAnchor] = useState(null);
|
|
53
|
+
const [hover, setHover] = useState(null);
|
|
54
|
+
const [focusDay, setFocusDay] = useState(null);
|
|
55
|
+
const [status, setStatus] = useState("");
|
|
56
|
+
const range = controlled ? checkRange("value", value) : own;
|
|
57
|
+
const off = (iso) => !inRange(iso, min, max) || isDateDisabled?.(iso) === true;
|
|
58
|
+
const blocks = (r) => !allowDisabledInRange && !!isDateDisabled && firstDisabledIn(r.from, r.to, isDateDisabled) !== null;
|
|
59
|
+
let band = range;
|
|
60
|
+
if (anchor) {
|
|
61
|
+
const target = hover ?? focusDay ?? anchor;
|
|
62
|
+
const r = orderRange(anchor, target);
|
|
63
|
+
band = off(target) || blocks(r) ? { from: anchor, to: anchor } : r;
|
|
64
|
+
}
|
|
65
|
+
const dayLook = (iso) => {
|
|
66
|
+
if (!band || iso < band.from || iso > band.to) return OUTSIDE;
|
|
67
|
+
const single = band.from === band.to;
|
|
68
|
+
return {
|
|
69
|
+
filled: anchor ? iso === anchor : iso === band.from || iso === band.to,
|
|
70
|
+
band: single ? null : iso === band.from ? "start" : iso === band.to ? "end" : "middle",
|
|
71
|
+
ariaSelected: anchor ? iso === anchor : true,
|
|
72
|
+
preview: !!anchor && iso !== anchor
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const start = (iso) => {
|
|
76
|
+
setAnchor(iso);
|
|
77
|
+
setStatus(strings.rangeStarted(fullDate(iso, loc)));
|
|
78
|
+
};
|
|
79
|
+
const onPick = (iso) => {
|
|
80
|
+
if (!anchor) {
|
|
81
|
+
start(iso);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const r = orderRange(anchor, iso);
|
|
85
|
+
if (blocks(r)) {
|
|
86
|
+
start(iso);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setAnchor(null);
|
|
90
|
+
setHover(null);
|
|
91
|
+
if (!controlled) setOwn(r);
|
|
92
|
+
setStatus(strings.dateRange(fullDate(r.from, loc), fullDate(r.to, loc)));
|
|
93
|
+
onValueChange?.(r);
|
|
94
|
+
};
|
|
95
|
+
const onGridKeyDown = (e) => {
|
|
96
|
+
if (e.key === "Escape" && anchor !== null) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
setAnchor(null);
|
|
100
|
+
setHover(null);
|
|
101
|
+
setStatus("");
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
CalendarBase,
|
|
106
|
+
{
|
|
107
|
+
...shared,
|
|
108
|
+
componentName: "RangeCalendar",
|
|
109
|
+
initialMonth: range ? monthOf(range.from) : null,
|
|
110
|
+
focusPreference: anchor ?? range?.from ?? null,
|
|
111
|
+
dayLook,
|
|
112
|
+
onPick,
|
|
113
|
+
onDayFocus: setFocusDay,
|
|
114
|
+
onDayHover: setHover,
|
|
115
|
+
onGridKeyDown,
|
|
116
|
+
multiselectable: true,
|
|
117
|
+
children: /* @__PURE__ */ jsx("p", { "aria-live": "polite", className: "sr-only", children: status })
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
RangeCalendar
|
|
123
|
+
};
|
|
@@ -14,11 +14,12 @@ import { ErrorState, SkeletonRows } from "./feedback.js";
|
|
|
14
14
|
import { ConfirmDialog } from "./overlay.js";
|
|
15
15
|
import { Badge, Button } from "./primitives.js";
|
|
16
16
|
import { apiFetch } from "./resource.js";
|
|
17
|
-
import {
|
|
17
|
+
import { useStrings } from "./provider.js";
|
|
18
|
+
import { TOKEN_STRINGS, STATUS_STRINGS, ERROR_STRINGS, OVERLAY_STRINGS } from "./strings.js";
|
|
18
19
|
import { SettingRow, SettingsSection } from "./settings.js";
|
|
19
20
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
21
|
function useServiceTokens(url = "/api/service-tokens") {
|
|
21
|
-
const strings =
|
|
22
|
+
const strings = useStrings(TOKEN_STRINGS, STATUS_STRINGS, ERROR_STRINGS, OVERLAY_STRINGS);
|
|
22
23
|
const [tokens, setTokens] = useState(
|
|
23
24
|
void 0
|
|
24
25
|
);
|
|
@@ -88,7 +89,7 @@ function ServiceTokensSection({
|
|
|
88
89
|
envSourceLabel = "from SERVICE_TOKENS",
|
|
89
90
|
...rest
|
|
90
91
|
}) {
|
|
91
|
-
const strings =
|
|
92
|
+
const strings = useStrings(TOKEN_STRINGS, STATUS_STRINGS, ERROR_STRINGS, OVERLAY_STRINGS);
|
|
92
93
|
const title = titleProp ?? strings.serviceTokens;
|
|
93
94
|
const description = descriptionProp ?? strings.serviceTokensIntro;
|
|
94
95
|
const [target, setTarget] = useState(null);
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
import { cn } from "../cn.js";
|
|
14
14
|
import { Spinner } from "./feedback.js";
|
|
15
15
|
import { Card, Input } from "./primitives.js";
|
|
16
|
-
import {
|
|
16
|
+
import { useStrings } from "./provider.js";
|
|
17
|
+
import { SETTINGS_STRINGS } from "./strings.js";
|
|
17
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
19
|
var CompactSettings = /* @__PURE__ */ createContext(false);
|
|
19
20
|
function SettingsSection({ title, description, id, actions, compact = false, children, className, ref, ...rest }) {
|
|
@@ -82,7 +83,7 @@ function SettingRow({
|
|
|
82
83
|
var SAVED_MS = 1500;
|
|
83
84
|
var ERROR_MS = 3e3;
|
|
84
85
|
function useSaveStatus() {
|
|
85
|
-
const strings =
|
|
86
|
+
const strings = useStrings(SETTINGS_STRINGS);
|
|
86
87
|
const [status, setStatus] = useState("idle");
|
|
87
88
|
const [error, setError] = useState(null);
|
|
88
89
|
const timer = useRef(void 0);
|
|
@@ -144,7 +145,7 @@ function NumberField({
|
|
|
144
145
|
ref,
|
|
145
146
|
...rest
|
|
146
147
|
}) {
|
|
147
|
-
const strings =
|
|
148
|
+
const strings = useStrings(SETTINGS_STRINGS);
|
|
148
149
|
const auto = useId();
|
|
149
150
|
const errId = `${id ?? auto}-error`;
|
|
150
151
|
const [draft, setDraftState] = useState(fmt(value));
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
import { cn } from "../cn.js";
|
|
10
10
|
import { isRtl, useIsoLayoutEffect } from "./client.js";
|
|
11
11
|
import { useLatest } from "./latest.js";
|
|
12
|
-
import {
|
|
12
|
+
import { useStrings } from "./provider.js";
|
|
13
|
+
import { SLIDER_STRINGS } from "./strings.js";
|
|
13
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
15
|
var decimals = (n) => {
|
|
15
16
|
const s = String(n);
|
|
@@ -69,7 +70,7 @@ function Slider({
|
|
|
69
70
|
onPointerCancel,
|
|
70
71
|
...rest
|
|
71
72
|
}) {
|
|
72
|
-
const strings =
|
|
73
|
+
const strings = useStrings(SLIDER_STRINGS);
|
|
73
74
|
const auto = useId();
|
|
74
75
|
const rootRef = useRef(null);
|
|
75
76
|
const trackRef = useRef(null);
|
|
@@ -19,7 +19,8 @@ import { isRtl, useIsoLayoutEffect } from "./client.js";
|
|
|
19
19
|
import { useMediaQuery } from "./hooks.js";
|
|
20
20
|
import { ScrollRow } from "./nav.js";
|
|
21
21
|
import { Tooltip } from "./tooltip.js";
|
|
22
|
-
import {
|
|
22
|
+
import { useStrings } from "./provider.js";
|
|
23
|
+
import { SPLIT_STRINGS } from "./strings.js";
|
|
23
24
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
24
25
|
function nodeAt(node, path) {
|
|
25
26
|
let cur = node;
|
|
@@ -45,7 +46,7 @@ function equalizeAt(node, path) {
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, barInset = 0, rtl = false, paneId }) {
|
|
48
|
-
const strings =
|
|
49
|
+
const strings = useStrings(SPLIT_STRINGS);
|
|
49
50
|
const coarse = useMediaQuery("(pointer: coarse)");
|
|
50
51
|
const drag = useRef(null);
|
|
51
52
|
const hit = coarse ? 44 : 24;
|
|
@@ -328,7 +329,7 @@ function LayoutPresetPicker({
|
|
|
328
329
|
ref,
|
|
329
330
|
...rest
|
|
330
331
|
}) {
|
|
331
|
-
const strings =
|
|
332
|
+
const strings = useStrings(SPLIT_STRINGS);
|
|
332
333
|
const label = labelProp ?? strings.layoutPresets;
|
|
333
334
|
const group = useRef(null);
|
|
334
335
|
const onKeyDown = (e) => {
|
|
@@ -1,28 +1,77 @@
|
|
|
1
1
|
// src/components/strings.ts
|
|
2
|
-
var
|
|
2
|
+
var OVERLAY_STRINGS = {
|
|
3
3
|
close: "Close",
|
|
4
4
|
cancel: "Cancel",
|
|
5
5
|
menu: "Menu",
|
|
6
6
|
back: "Back: ",
|
|
7
|
-
contextMenu: "Actions"
|
|
8
|
-
|
|
7
|
+
contextMenu: "Actions"
|
|
8
|
+
};
|
|
9
|
+
var SHELL_STRINGS = {
|
|
10
|
+
sections: "Sections",
|
|
11
|
+
more: "More",
|
|
12
|
+
hubTitle: "Back to nish.software",
|
|
13
|
+
hubLabel: "\u2190 nish.software",
|
|
14
|
+
moreActions: "More actions",
|
|
15
|
+
skipToContent: "Skip to content",
|
|
16
|
+
sidebar: "Sidebar",
|
|
17
|
+
expandSidebar: "Expand sidebar",
|
|
18
|
+
collapseSidebar: "Collapse sidebar",
|
|
19
|
+
newCount: (value) => `${value} new`
|
|
20
|
+
};
|
|
21
|
+
var STATUS_STRINGS = {
|
|
22
|
+
loading: "Loading",
|
|
23
|
+
failedToLoad: "Failed to load",
|
|
24
|
+
retry: "Retry",
|
|
25
|
+
nothingHere: "Nothing here yet",
|
|
26
|
+
loadingNamed: (label) => `Loading ${label}`,
|
|
27
|
+
offline: "You're offline",
|
|
28
|
+
actions: "Actions"
|
|
29
|
+
};
|
|
30
|
+
var THEME_STRINGS = {
|
|
31
|
+
theme: "Theme",
|
|
32
|
+
themeSystem: "System",
|
|
33
|
+
themeLight: "Light",
|
|
34
|
+
themeDark: "Dark",
|
|
35
|
+
themeToggleLabel: (current, next) => `Theme: ${current}. Switch to ${next}`,
|
|
36
|
+
themePreset: "Theme preset",
|
|
37
|
+
themePresetPlaceholder: "Preset\u2026"
|
|
38
|
+
};
|
|
39
|
+
var ERROR_STRINGS = {
|
|
40
|
+
errorStaleTitle: "A new version is available",
|
|
41
|
+
errorStaleBody: "Reload the page to get the latest version.",
|
|
42
|
+
errorTitle: "Something went wrong",
|
|
43
|
+
errorBody: "An unexpected error occurred.",
|
|
44
|
+
errorDetails: "Details",
|
|
45
|
+
errorTryAgain: "Try again",
|
|
46
|
+
errorReload: "Reload page"
|
|
47
|
+
};
|
|
48
|
+
var DISPLAY_STRINGS = {
|
|
9
49
|
dismiss: "Dismiss",
|
|
10
50
|
moreCount: (count) => `${count} more`,
|
|
11
51
|
copy: "Copy",
|
|
12
52
|
copied: "Copied",
|
|
13
|
-
hubTitle: "Back to nish.software",
|
|
14
|
-
hubLabel: "\u2190 nish.software",
|
|
15
|
-
moreActions: "More actions",
|
|
16
|
-
more: "More",
|
|
17
53
|
legend: "Legend",
|
|
54
|
+
noData: "No data",
|
|
55
|
+
noDataNamed: (label) => `${label}: no data`
|
|
56
|
+
};
|
|
57
|
+
var FIELD_STRINGS = {
|
|
18
58
|
optional: "Optional",
|
|
19
59
|
search: "Search",
|
|
20
60
|
clearSearch: "Clear search",
|
|
21
61
|
remove: "Remove",
|
|
22
62
|
removeNamed: (name) => `Remove ${name}`,
|
|
23
|
-
noMatches: "No matches",
|
|
24
63
|
clear: "Clear",
|
|
64
|
+
noMatches: "No matches",
|
|
25
65
|
searching: "Searching\u2026",
|
|
66
|
+
removeTag: (tag) => `Remove ${tag}`
|
|
67
|
+
};
|
|
68
|
+
var FILTER_STRINGS = {
|
|
69
|
+
filters: "Filters",
|
|
70
|
+
clearFilters: "Clear filters",
|
|
71
|
+
done: "Done",
|
|
72
|
+
activeCount: (n) => `${n} active`
|
|
73
|
+
};
|
|
74
|
+
var PICKER_STRINGS = {
|
|
26
75
|
invalidDate: "Enter a valid date.",
|
|
27
76
|
chooseDate: "Choose date",
|
|
28
77
|
changeDate: (date) => `Change date, ${date}`,
|
|
@@ -33,10 +82,19 @@ var DEFAULT_STRINGS = {
|
|
|
33
82
|
dayToken: "DD",
|
|
34
83
|
monthToken: "MM",
|
|
35
84
|
yearToken: "YYYY",
|
|
85
|
+
chooseDates: "Choose dates",
|
|
86
|
+
changeDates: (range) => `Change dates, ${range}`,
|
|
87
|
+
dateRange: (from, to) => `${from} to ${to}`,
|
|
88
|
+
rangeStarted: (start) => `Start date ${start}. Pick the end date.`,
|
|
89
|
+
invalidDateRange: "Enter a valid date range."
|
|
90
|
+
};
|
|
91
|
+
var MULTI_SELECT_STRINGS = {
|
|
36
92
|
optionAdded: (l) => `Added ${l}`,
|
|
37
93
|
optionRemoved: (l) => `Removed ${l}`,
|
|
38
94
|
clearAll: "Clear all",
|
|
39
|
-
maxSelected: (n) => `You can pick up to ${n}
|
|
95
|
+
maxSelected: (n) => `You can pick up to ${n}`
|
|
96
|
+
};
|
|
97
|
+
var CAROUSEL_STRINGS = {
|
|
40
98
|
carouselRole: "carousel",
|
|
41
99
|
slideRole: "slide",
|
|
42
100
|
slideLabel: (n, c) => `${n} of ${c}`,
|
|
@@ -45,66 +103,53 @@ var DEFAULT_STRINGS = {
|
|
|
45
103
|
goToSlide: (n) => `Go to slide ${n}`,
|
|
46
104
|
slidePicker: "Choose slide",
|
|
47
105
|
startRotation: "Start slide rotation",
|
|
48
|
-
stopRotation: "Stop slide rotation"
|
|
106
|
+
stopRotation: "Stop slide rotation"
|
|
107
|
+
};
|
|
108
|
+
var COMMAND_STRINGS = {
|
|
49
109
|
searchPlaceholder: "Search\u2026",
|
|
50
110
|
noResults: "No results",
|
|
51
|
-
results: "Results"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
actions: "Actions",
|
|
56
|
-
offline: "You're offline",
|
|
57
|
-
nothingHere: "Nothing here yet",
|
|
58
|
-
loadingNamed: (label) => `Loading ${label}`,
|
|
111
|
+
results: "Results"
|
|
112
|
+
};
|
|
113
|
+
var TABLE_STRINGS = {
|
|
114
|
+
sortAnnounce: (header, dir) => dir ? `Sorted by ${header}, ${dir === "asc" ? "ascending" : "descending"}` : "Sorting cleared",
|
|
59
115
|
sortBy: "Sort by",
|
|
60
|
-
sortDefault: "Default"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
filters: "Filters",
|
|
64
|
-
clearFilters: "Clear filters",
|
|
65
|
-
done: "Done",
|
|
66
|
-
activeCount: (n) => `${n} active`,
|
|
67
|
-
newCount: (value) => `${value} new`,
|
|
68
|
-
sections: "Sections",
|
|
69
|
-
theme: "Theme",
|
|
70
|
-
sidebar: "Sidebar",
|
|
71
|
-
expandSidebar: "Expand sidebar",
|
|
72
|
-
collapseSidebar: "Collapse sidebar",
|
|
73
|
-
skipToContent: "Skip to content",
|
|
74
|
-
themeSystem: "System",
|
|
75
|
-
themeLight: "Light",
|
|
76
|
-
themeDark: "Dark",
|
|
77
|
-
themeToggleLabel: (current, next) => `Theme: ${current}. Switch to ${next}`,
|
|
78
|
-
themePreset: "Theme preset",
|
|
79
|
-
themePresetPlaceholder: "Preset\u2026",
|
|
80
|
-
errorStaleTitle: "A new version is available",
|
|
81
|
-
errorStaleBody: "Reload the page to get the latest version.",
|
|
82
|
-
errorTitle: "Something went wrong",
|
|
83
|
-
errorBody: "An unexpected error occurred.",
|
|
84
|
-
errorDetails: "Details",
|
|
85
|
-
errorTryAgain: "Try again",
|
|
86
|
-
errorReload: "Reload page",
|
|
116
|
+
sortDefault: "Default"
|
|
117
|
+
};
|
|
118
|
+
var SETTINGS_STRINGS = {
|
|
87
119
|
saving: "Saving\u2026",
|
|
88
120
|
saved: "Saved",
|
|
89
121
|
saveFailed: "Could not save",
|
|
90
|
-
enterNumber: "Enter a number"
|
|
122
|
+
enterNumber: "Enter a number"
|
|
123
|
+
};
|
|
124
|
+
var SPLIT_STRINGS = {
|
|
91
125
|
resizeColumns: "Resize columns",
|
|
92
126
|
resizeRows: "Resize rows",
|
|
93
|
-
layoutPresets: "Layout presets"
|
|
127
|
+
layoutPresets: "Layout presets"
|
|
128
|
+
};
|
|
129
|
+
var MEDIA_STRINGS = {
|
|
94
130
|
live: "Live",
|
|
95
|
-
offlineBadge: "Offline"
|
|
131
|
+
offlineBadge: "Offline"
|
|
132
|
+
};
|
|
133
|
+
var PROGRESS_STRINGS = {
|
|
96
134
|
progress: "Progress",
|
|
135
|
+
progressIndeterminate: "Loading"
|
|
136
|
+
};
|
|
137
|
+
var FLOW_STRINGS = {
|
|
97
138
|
workflow: "Workflow",
|
|
98
139
|
activity: "Activity",
|
|
99
140
|
other: "Other",
|
|
100
141
|
waiting: "Waiting",
|
|
101
|
-
noActivity: "No activity yet"
|
|
142
|
+
noActivity: "No activity yet"
|
|
143
|
+
};
|
|
144
|
+
var CANVAS_STRINGS = {
|
|
102
145
|
systemMap: "System map",
|
|
103
146
|
zoomOut: "Zoom out",
|
|
104
147
|
zoomIn: "Zoom in",
|
|
105
148
|
fitToScreen: "Fit to screen",
|
|
106
149
|
followActivity: "Follow activity",
|
|
107
|
-
canvasLines: "Lines"
|
|
150
|
+
canvasLines: "Lines"
|
|
151
|
+
};
|
|
152
|
+
var TOKEN_STRINGS = {
|
|
108
153
|
serviceTokens: "Service tokens",
|
|
109
154
|
serviceTokensIntro: "Machine clients, like the nish MCP server, use these tokens to read this app. Revoking one stops it at once.",
|
|
110
155
|
loadingServiceTokens: "Loading service tokens",
|
|
@@ -113,7 +158,9 @@ var DEFAULT_STRINGS = {
|
|
|
113
158
|
tokenRevokedAt: (when) => `Revoked ${when}`,
|
|
114
159
|
tokenRevokeNamed: (name) => `Revoke ${name}`,
|
|
115
160
|
tokenRevokeTitle: (name) => `Revoke ${name}?`,
|
|
116
|
-
tokenRevokeFailed: "Could not revoke the token."
|
|
161
|
+
tokenRevokeFailed: "Could not revoke the token."
|
|
162
|
+
};
|
|
163
|
+
var INBOX_STRINGS = {
|
|
117
164
|
inboxMarkHandled: "Mark handled",
|
|
118
165
|
inboxSnooze: "Snooze",
|
|
119
166
|
inboxActions: "Actions",
|
|
@@ -122,23 +169,94 @@ var DEFAULT_STRINGS = {
|
|
|
122
169
|
inboxSnoozed: "Snoozed",
|
|
123
170
|
inboxHandled: "Handled",
|
|
124
171
|
inboxFilterBySource: "Filter by source",
|
|
125
|
-
inboxHappened: (count) => `Happened ${count} times
|
|
172
|
+
inboxHappened: (count) => `Happened ${count} times`
|
|
173
|
+
};
|
|
174
|
+
var PAGING_STRINGS = {
|
|
126
175
|
previousPage: "Previous page",
|
|
127
176
|
nextPage: "Next page",
|
|
128
177
|
pageLabel: (n) => `Page ${n}`,
|
|
129
178
|
paginationLabel: "Pagination",
|
|
130
|
-
breadcrumbs: "Breadcrumbs"
|
|
131
|
-
|
|
179
|
+
breadcrumbs: "Breadcrumbs"
|
|
180
|
+
};
|
|
181
|
+
var FILE_STRINGS = {
|
|
132
182
|
dropzoneLabel: "Drop files here or browse",
|
|
133
183
|
browseFiles: "Browse files",
|
|
134
|
-
removeFile: (name) => `Remove ${name}
|
|
184
|
+
removeFile: (name) => `Remove ${name}`
|
|
185
|
+
};
|
|
186
|
+
var AVATAR_STRINGS = {
|
|
135
187
|
avatar: "Avatar",
|
|
136
|
-
avatarMore: (count) => `${count} more
|
|
188
|
+
avatarMore: (count) => `${count} more`
|
|
189
|
+
};
|
|
190
|
+
var SLIDER_STRINGS = {
|
|
137
191
|
sliderMin: "Minimum",
|
|
138
|
-
sliderMax: "Maximum"
|
|
139
|
-
|
|
140
|
-
|
|
192
|
+
sliderMax: "Maximum"
|
|
193
|
+
};
|
|
194
|
+
var ACCORDION_STRINGS = {
|
|
195
|
+
accordion: "Accordion"
|
|
196
|
+
};
|
|
197
|
+
var TIME_STRINGS = {
|
|
198
|
+
hour: "Hour",
|
|
199
|
+
minute: "Minute",
|
|
200
|
+
dayPeriod: "AM/PM",
|
|
201
|
+
invalidTime: "Enter a valid time."
|
|
141
202
|
};
|
|
203
|
+
var DEFAULT_STRINGS = /* @__PURE__ */ Object.assign(
|
|
204
|
+
{},
|
|
205
|
+
OVERLAY_STRINGS,
|
|
206
|
+
SHELL_STRINGS,
|
|
207
|
+
STATUS_STRINGS,
|
|
208
|
+
THEME_STRINGS,
|
|
209
|
+
ERROR_STRINGS,
|
|
210
|
+
DISPLAY_STRINGS,
|
|
211
|
+
FIELD_STRINGS,
|
|
212
|
+
FILTER_STRINGS,
|
|
213
|
+
PICKER_STRINGS,
|
|
214
|
+
MULTI_SELECT_STRINGS,
|
|
215
|
+
CAROUSEL_STRINGS,
|
|
216
|
+
COMMAND_STRINGS,
|
|
217
|
+
TABLE_STRINGS,
|
|
218
|
+
SETTINGS_STRINGS,
|
|
219
|
+
SPLIT_STRINGS,
|
|
220
|
+
MEDIA_STRINGS,
|
|
221
|
+
PROGRESS_STRINGS,
|
|
222
|
+
FLOW_STRINGS,
|
|
223
|
+
CANVAS_STRINGS,
|
|
224
|
+
TOKEN_STRINGS,
|
|
225
|
+
INBOX_STRINGS,
|
|
226
|
+
PAGING_STRINGS,
|
|
227
|
+
FILE_STRINGS,
|
|
228
|
+
AVATAR_STRINGS,
|
|
229
|
+
SLIDER_STRINGS,
|
|
230
|
+
ACCORDION_STRINGS,
|
|
231
|
+
TIME_STRINGS
|
|
232
|
+
);
|
|
142
233
|
export {
|
|
143
|
-
|
|
234
|
+
ACCORDION_STRINGS,
|
|
235
|
+
AVATAR_STRINGS,
|
|
236
|
+
CANVAS_STRINGS,
|
|
237
|
+
CAROUSEL_STRINGS,
|
|
238
|
+
COMMAND_STRINGS,
|
|
239
|
+
DEFAULT_STRINGS,
|
|
240
|
+
DISPLAY_STRINGS,
|
|
241
|
+
ERROR_STRINGS,
|
|
242
|
+
FIELD_STRINGS,
|
|
243
|
+
FILE_STRINGS,
|
|
244
|
+
FILTER_STRINGS,
|
|
245
|
+
FLOW_STRINGS,
|
|
246
|
+
INBOX_STRINGS,
|
|
247
|
+
MEDIA_STRINGS,
|
|
248
|
+
MULTI_SELECT_STRINGS,
|
|
249
|
+
OVERLAY_STRINGS,
|
|
250
|
+
PAGING_STRINGS,
|
|
251
|
+
PICKER_STRINGS,
|
|
252
|
+
PROGRESS_STRINGS,
|
|
253
|
+
SETTINGS_STRINGS,
|
|
254
|
+
SHELL_STRINGS,
|
|
255
|
+
SLIDER_STRINGS,
|
|
256
|
+
SPLIT_STRINGS,
|
|
257
|
+
STATUS_STRINGS,
|
|
258
|
+
TABLE_STRINGS,
|
|
259
|
+
THEME_STRINGS,
|
|
260
|
+
TIME_STRINGS,
|
|
261
|
+
TOKEN_STRINGS
|
|
144
262
|
};
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
import { cn } from "../cn.js";
|
|
11
11
|
import { Chip } from "./forms.js";
|
|
12
12
|
import { fieldClass } from "./primitives.js";
|
|
13
|
-
import {
|
|
13
|
+
import { useStrings } from "./provider.js";
|
|
14
|
+
import { FIELD_STRINGS } from "./strings.js";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
16
|
function setRef(ref, node) {
|
|
16
17
|
if (typeof ref === "function") ref(node);
|
|
@@ -42,7 +43,7 @@ function TagInput({
|
|
|
42
43
|
"aria-invalid": ariaInvalid,
|
|
43
44
|
...rest
|
|
44
45
|
}) {
|
|
45
|
-
const strings =
|
|
46
|
+
const strings = useStrings(FIELD_STRINGS);
|
|
46
47
|
const auto = useId();
|
|
47
48
|
const input = useRef(null);
|
|
48
49
|
const controlled = value !== void 0;
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
} from "../theme.js";
|
|
18
18
|
import { MonitorIcon, MoonIcon, SunIcon } from "./icons.js";
|
|
19
19
|
import { IconButton } from "./primitives.js";
|
|
20
|
-
import {
|
|
20
|
+
import { useStrings } from "./provider.js";
|
|
21
|
+
import { THEME_STRINGS } from "./strings.js";
|
|
21
22
|
import { Segmented } from "./segmented.js";
|
|
22
23
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
24
|
var SERVER_SNAPSHOT = { choice: "system", theme: DEFAULT_THEME };
|
|
@@ -66,7 +67,7 @@ function ThemeToggle({
|
|
|
66
67
|
elsewhereLabel = "set on another site",
|
|
67
68
|
...rest
|
|
68
69
|
}) {
|
|
69
|
-
const strings =
|
|
70
|
+
const strings = useStrings(THEME_STRINGS);
|
|
70
71
|
const { choice, theme, scheme, setChoice } = useTheme();
|
|
71
72
|
const extra = PRESETS.filter((p) => p.id !== "dark" && p.id !== "light");
|
|
72
73
|
const isPreset = extra.some((p) => p.id === choice);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/components/time-field-classes.ts
|
|
2
|
+
var TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
3
|
+
var DIGITS_RE = /^\d{1,2}$/;
|
|
4
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
5
|
+
function parseTime(s) {
|
|
6
|
+
if (typeof s !== "string") return null;
|
|
7
|
+
const x = TIME_RE.exec(s);
|
|
8
|
+
return x ? { h: Number(x[1]), m: Number(x[2]) } : null;
|
|
9
|
+
}
|
|
10
|
+
function toTime(h, m) {
|
|
11
|
+
return `${pad2(h)}:${pad2(m)}`;
|
|
12
|
+
}
|
|
13
|
+
function inTimeRange(t, min, max) {
|
|
14
|
+
if (parseTime(min) && t < min) return false;
|
|
15
|
+
if (parseTime(max) && t > max) return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
var cycles = /* @__PURE__ */ new Map();
|
|
19
|
+
function hourCycleFor(locale) {
|
|
20
|
+
const hit = cycles.get(locale);
|
|
21
|
+
if (hit) return hit;
|
|
22
|
+
let c = 24;
|
|
23
|
+
try {
|
|
24
|
+
const o = new Intl.DateTimeFormat(locale, { hour: "numeric", timeZone: "UTC" }).resolvedOptions();
|
|
25
|
+
const twelve = o.hourCycle ? o.hourCycle === "h11" || o.hourCycle === "h12" : o.hour12 === true;
|
|
26
|
+
c = twelve ? 12 : 24;
|
|
27
|
+
} catch {
|
|
28
|
+
c = 24;
|
|
29
|
+
}
|
|
30
|
+
cycles.set(locale, c);
|
|
31
|
+
return c;
|
|
32
|
+
}
|
|
33
|
+
var periods = /* @__PURE__ */ new Map();
|
|
34
|
+
function dayPeriodNames(locale) {
|
|
35
|
+
const hit = periods.get(locale);
|
|
36
|
+
if (hit) return hit;
|
|
37
|
+
let r = ["AM", "PM"];
|
|
38
|
+
try {
|
|
39
|
+
const f = new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true, timeZone: "UTC" });
|
|
40
|
+
const word = (h) => f.formatToParts(new Date(Date.UTC(2026, 0, 1, h))).find((p) => p.type === "dayPeriod")?.value;
|
|
41
|
+
r = [word(1) || "AM", word(13) || "PM"];
|
|
42
|
+
} catch {
|
|
43
|
+
r = ["AM", "PM"];
|
|
44
|
+
}
|
|
45
|
+
periods.set(locale, r);
|
|
46
|
+
return r;
|
|
47
|
+
}
|
|
48
|
+
function to12(h) {
|
|
49
|
+
return { hour: h % 12 === 0 ? 12 : h % 12, pm: h >= 12 };
|
|
50
|
+
}
|
|
51
|
+
function from12(hour, pm) {
|
|
52
|
+
return hour % 12 + (pm ? 12 : 0);
|
|
53
|
+
}
|
|
54
|
+
function normalizeStep(step) {
|
|
55
|
+
return Number.isFinite(step) ? Math.min(60, Math.max(1, Math.floor(step))) : 1;
|
|
56
|
+
}
|
|
57
|
+
function lastMinute(step) {
|
|
58
|
+
return Math.floor(59 / step) * step;
|
|
59
|
+
}
|
|
60
|
+
function stepHour(h, dir) {
|
|
61
|
+
return h === null ? dir > 0 ? 0 : 23 : (h + dir + 24) % 24;
|
|
62
|
+
}
|
|
63
|
+
function stepMinute(m, dir, step) {
|
|
64
|
+
if (m === null) return dir > 0 ? 0 : lastMinute(step);
|
|
65
|
+
if (dir > 0) {
|
|
66
|
+
const n2 = (Math.floor(m / step) + 1) * step;
|
|
67
|
+
return n2 > 59 ? 0 : n2;
|
|
68
|
+
}
|
|
69
|
+
const n = Math.ceil(m / step) * step - step;
|
|
70
|
+
return n < 0 ? lastMinute(step) : n;
|
|
71
|
+
}
|
|
72
|
+
function hourText(h, cycle) {
|
|
73
|
+
return cycle === 24 ? pad2(h) : String(to12(h).hour);
|
|
74
|
+
}
|
|
75
|
+
function draftFromTime(t, cycle) {
|
|
76
|
+
const p = parseTime(t);
|
|
77
|
+
if (!p) return { h: "", m: "", pm: false };
|
|
78
|
+
return { h: hourText(p.h, cycle), m: pad2(p.m), pm: p.h >= 12 };
|
|
79
|
+
}
|
|
80
|
+
function draftTime(d, cycle) {
|
|
81
|
+
if (d.h === "" && d.m === "") return null;
|
|
82
|
+
if (d.h === "" || d.m === "") return void 0;
|
|
83
|
+
if (!DIGITS_RE.test(d.h) || !DIGITS_RE.test(d.m)) return void 0;
|
|
84
|
+
const hn = Number(d.h);
|
|
85
|
+
const mn = Number(d.m);
|
|
86
|
+
if (cycle === 24 ? hn > 23 : hn < 1 || hn > 12) return void 0;
|
|
87
|
+
if (mn > 59) return void 0;
|
|
88
|
+
return toTime(cycle === 12 ? from12(hn, d.pm) : hn, mn);
|
|
89
|
+
}
|
|
90
|
+
function hourAdvances(text, cycle) {
|
|
91
|
+
const max = cycle === 24 ? 23 : 12;
|
|
92
|
+
return text.length >= 2 || text.length === 1 && Number(text) * 10 > max;
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
dayPeriodNames,
|
|
96
|
+
draftFromTime,
|
|
97
|
+
draftTime,
|
|
98
|
+
from12,
|
|
99
|
+
hourAdvances,
|
|
100
|
+
hourCycleFor,
|
|
101
|
+
hourText,
|
|
102
|
+
inTimeRange,
|
|
103
|
+
lastMinute,
|
|
104
|
+
normalizeStep,
|
|
105
|
+
parseTime,
|
|
106
|
+
stepHour,
|
|
107
|
+
stepMinute,
|
|
108
|
+
to12,
|
|
109
|
+
toTime
|
|
110
|
+
};
|