nish-ui 2.2.0 → 3.1.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 +10 -6
- package/dist/chart.d.ts +8 -3
- package/dist/chart.js +2 -417
- package/dist/elements-all.js +81 -80
- package/dist/elements-charts.d.ts +7 -1
- package/dist/elements-charts.js +16 -16
- package/dist/elements-data.d.ts +7 -1
- package/dist/elements-data.js +5 -5
- package/dist/elements-forms.d.ts +7 -1
- package/dist/elements-forms.js +18 -17
- package/dist/elements.d.ts +7 -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 +6 -5
- package/dist/esm/components/breadcrumbs.js +3 -2
- package/dist/esm/components/calendar-base.js +4 -3
- package/dist/esm/components/canvas/legend.js +7 -6
- package/dist/esm/components/canvas/node.js +3 -2
- package/dist/esm/components/canvas/system-canvas.js +27 -3
- package/dist/esm/components/carousel.js +24 -5
- package/dist/esm/components/charts.js +29 -20
- package/dist/esm/components/combobox.js +4 -3
- package/dist/esm/components/command.js +4 -3
- package/dist/esm/components/context-menu.js +3 -2
- package/dist/esm/components/data-classes.js +5 -4
- package/dist/esm/components/data.js +5 -8
- package/dist/esm/components/date-picker.js +5 -3
- package/dist/esm/components/date-range-picker.js +5 -3
- package/dist/esm/components/display.js +10 -9
- 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 +24 -3
- package/dist/esm/components/filters.js +7 -4
- package/dist/esm/components/flow.js +17 -15
- package/dist/esm/components/forms.js +37 -10
- package/dist/esm/components/hooks.js +22 -19
- package/dist/esm/components/hover-card.js +2 -2
- package/dist/esm/components/inbox.js +12 -8
- package/dist/esm/components/layout-vars.js +10 -7
- package/dist/esm/components/layout.js +5 -4
- package/dist/esm/components/media.js +3 -2
- package/dist/esm/components/menu.js +12 -8
- package/dist/esm/components/modal.js +4 -3
- package/dist/esm/components/more-sheet.js +3 -2
- package/dist/esm/components/multi-select.js +10 -6
- package/dist/esm/components/nav-items.js +4 -3
- package/dist/esm/components/nav.js +5 -4
- package/dist/esm/components/overlay-core.js +31 -10
- package/dist/esm/components/overlay-dialog.js +20 -4
- package/dist/esm/components/pagination.js +7 -3
- package/dist/esm/components/popover.js +17 -11
- package/dist/esm/components/portal.js +2 -2
- package/dist/esm/components/primitives.js +1 -1
- package/dist/esm/components/progress.js +5 -2
- package/dist/esm/components/provider.js +34 -5
- package/dist/esm/components/range-calendar.js +4 -3
- package/dist/esm/components/resource-classes.js +34 -16
- package/dist/esm/components/resource.js +5 -4
- package/dist/esm/components/service-tokens.js +4 -3
- package/dist/esm/components/settings.js +8 -5
- package/dist/esm/components/slider.js +4 -2
- package/dist/esm/components/split.js +4 -3
- package/dist/esm/components/strings.js +182 -65
- package/dist/esm/components/tag-input.js +18 -9
- package/dist/esm/components/theme-toggle.js +3 -2
- package/dist/esm/components/time-field-classes.js +5 -2
- package/dist/esm/components/time-field.js +19 -10
- 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 +3 -3
- package/dist/esm/components/url-state.js +1 -0
- package/dist/esm/components/virtual-table.js +11 -4
- package/dist/esm/components/virtual.js +16 -2
- package/dist/esm/format.js +17 -14
- package/dist/esm/index.js +0 -20
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/server/inbox/client.js +1 -1
- package/dist/esm/system-canvas.js +4 -0
- package/dist/esm/theme.js +73 -13
- package/dist/format.js +18 -15
- package/dist/inbox-client.js +1 -1
- package/dist/index.d.ts +43 -21
- package/dist/nish-components.css +41 -1
- package/dist/nish-components.min.css +1 -1
- package/dist/node/th-check.js +12 -3
- package/dist/server/hono.d.ts +1 -1
- package/dist/server/hono.js +20 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +19 -5
- package/dist/{spa-BLlMc0eI.d.ts → spa-7myD4xvA.d.ts} +3 -2
- package/dist/system-canvas.d.ts +179 -2
- package/dist/theme.d.ts +23 -5
- package/dist/theme.global.js +87 -151
- package/dist/theme.js +87 -151
- package/package.json +1 -1
- package/dist/system-canvas-BLuWd69H.d.ts +0 -183
|
@@ -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));
|
|
@@ -152,6 +153,7 @@ function NumberField({
|
|
|
152
153
|
const [pending, setPending] = useState(false);
|
|
153
154
|
const draftRef = useRef(draft);
|
|
154
155
|
const lastSent = useRef(null);
|
|
156
|
+
const seq = useRef(0);
|
|
155
157
|
const mounted = useRef(true);
|
|
156
158
|
const skipCommit = useRef(false);
|
|
157
159
|
const setDraft = (next) => {
|
|
@@ -204,6 +206,7 @@ function NumberField({
|
|
|
204
206
|
if (lastSent.current && lastSent.current.v === next) return;
|
|
205
207
|
setError(null);
|
|
206
208
|
lastSent.current = { v: next };
|
|
209
|
+
const mine = ++seq.current;
|
|
207
210
|
let result;
|
|
208
211
|
try {
|
|
209
212
|
result = onCommit(next);
|
|
@@ -215,10 +218,10 @@ function NumberField({
|
|
|
215
218
|
setPending(true);
|
|
216
219
|
result.then(
|
|
217
220
|
() => {
|
|
218
|
-
if (mounted.current) setPending(false);
|
|
221
|
+
if (mounted.current && mine === seq.current) setPending(false);
|
|
219
222
|
},
|
|
220
223
|
(e) => {
|
|
221
|
-
if (!mounted.current) return;
|
|
224
|
+
if (!mounted.current || mine !== seq.current) return;
|
|
222
225
|
setPending(false);
|
|
223
226
|
fail(e);
|
|
224
227
|
}
|
|
@@ -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);
|
|
@@ -113,6 +114,7 @@ function Slider({
|
|
|
113
114
|
const handlePointerDown = (e) => {
|
|
114
115
|
onPointerDown?.(e);
|
|
115
116
|
if (e.defaultPrevented || disabled || e.button !== 0) return;
|
|
117
|
+
e.preventDefault();
|
|
116
118
|
const v = valueAt(e.clientX);
|
|
117
119
|
const cur = live.current;
|
|
118
120
|
let i = 0;
|
|
@@ -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,78 @@
|
|
|
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
|
+
maxTags: (max) => `You can add up to ${max}`
|
|
68
|
+
};
|
|
69
|
+
var FILTER_STRINGS = {
|
|
70
|
+
filters: "Filters",
|
|
71
|
+
clearFilters: "Clear filters",
|
|
72
|
+
done: "Done",
|
|
73
|
+
activeCount: (n) => `${n} active`
|
|
74
|
+
};
|
|
75
|
+
var PICKER_STRINGS = {
|
|
26
76
|
invalidDate: "Enter a valid date.",
|
|
27
77
|
chooseDate: "Choose date",
|
|
28
78
|
changeDate: (date) => `Change date, ${date}`,
|
|
@@ -37,15 +87,15 @@ var DEFAULT_STRINGS = {
|
|
|
37
87
|
changeDates: (range) => `Change dates, ${range}`,
|
|
38
88
|
dateRange: (from, to) => `${from} to ${to}`,
|
|
39
89
|
rangeStarted: (start) => `Start date ${start}. Pick the end date.`,
|
|
40
|
-
invalidDateRange: "Enter a valid date range."
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
dayPeriod: "AM/PM",
|
|
44
|
-
invalidTime: "Enter a valid time.",
|
|
90
|
+
invalidDateRange: "Enter a valid date range."
|
|
91
|
+
};
|
|
92
|
+
var MULTI_SELECT_STRINGS = {
|
|
45
93
|
optionAdded: (l) => `Added ${l}`,
|
|
46
94
|
optionRemoved: (l) => `Removed ${l}`,
|
|
47
95
|
clearAll: "Clear all",
|
|
48
|
-
maxSelected: (n) => `You can pick up to ${n}
|
|
96
|
+
maxSelected: (n) => `You can pick up to ${n}`
|
|
97
|
+
};
|
|
98
|
+
var CAROUSEL_STRINGS = {
|
|
49
99
|
carouselRole: "carousel",
|
|
50
100
|
slideRole: "slide",
|
|
51
101
|
slideLabel: (n, c) => `${n} of ${c}`,
|
|
@@ -54,66 +104,60 @@ var DEFAULT_STRINGS = {
|
|
|
54
104
|
goToSlide: (n) => `Go to slide ${n}`,
|
|
55
105
|
slidePicker: "Choose slide",
|
|
56
106
|
startRotation: "Start slide rotation",
|
|
57
|
-
stopRotation: "Stop slide rotation"
|
|
107
|
+
stopRotation: "Stop slide rotation"
|
|
108
|
+
};
|
|
109
|
+
var COMMAND_STRINGS = {
|
|
58
110
|
searchPlaceholder: "Search\u2026",
|
|
59
111
|
noResults: "No results",
|
|
60
|
-
results: "Results"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
actions: "Actions",
|
|
65
|
-
offline: "You're offline",
|
|
66
|
-
nothingHere: "Nothing here yet",
|
|
67
|
-
loadingNamed: (label) => `Loading ${label}`,
|
|
112
|
+
results: "Results"
|
|
113
|
+
};
|
|
114
|
+
var TABLE_STRINGS = {
|
|
115
|
+
sortAnnounce: (header, dir) => dir ? `Sorted by ${header}, ${dir === "asc" ? "ascending" : "descending"}` : "Sorting cleared",
|
|
68
116
|
sortBy: "Sort by",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
clearFilters: "Clear filters",
|
|
74
|
-
done: "Done",
|
|
75
|
-
activeCount: (n) => `${n} active`,
|
|
76
|
-
newCount: (value) => `${value} new`,
|
|
77
|
-
sections: "Sections",
|
|
78
|
-
theme: "Theme",
|
|
79
|
-
sidebar: "Sidebar",
|
|
80
|
-
expandSidebar: "Expand sidebar",
|
|
81
|
-
collapseSidebar: "Collapse sidebar",
|
|
82
|
-
skipToContent: "Skip to content",
|
|
83
|
-
themeSystem: "System",
|
|
84
|
-
themeLight: "Light",
|
|
85
|
-
themeDark: "Dark",
|
|
86
|
-
themeToggleLabel: (current, next) => `Theme: ${current}. Switch to ${next}`,
|
|
87
|
-
themePreset: "Theme preset",
|
|
88
|
-
themePresetPlaceholder: "Preset\u2026",
|
|
89
|
-
errorStaleTitle: "A new version is available",
|
|
90
|
-
errorStaleBody: "Reload the page to get the latest version.",
|
|
91
|
-
errorTitle: "Something went wrong",
|
|
92
|
-
errorBody: "An unexpected error occurred.",
|
|
93
|
-
errorDetails: "Details",
|
|
94
|
-
errorTryAgain: "Try again",
|
|
95
|
-
errorReload: "Reload page",
|
|
117
|
+
sortToggle: (dir) => dir === "desc" ? "Sorted descending, switch to ascending" : "Sorted ascending, switch to descending",
|
|
118
|
+
sortDefault: "Default"
|
|
119
|
+
};
|
|
120
|
+
var SETTINGS_STRINGS = {
|
|
96
121
|
saving: "Saving\u2026",
|
|
97
122
|
saved: "Saved",
|
|
98
123
|
saveFailed: "Could not save",
|
|
99
|
-
enterNumber: "Enter a number"
|
|
124
|
+
enterNumber: "Enter a number"
|
|
125
|
+
};
|
|
126
|
+
var SPLIT_STRINGS = {
|
|
100
127
|
resizeColumns: "Resize columns",
|
|
101
128
|
resizeRows: "Resize rows",
|
|
102
|
-
layoutPresets: "Layout presets"
|
|
129
|
+
layoutPresets: "Layout presets"
|
|
130
|
+
};
|
|
131
|
+
var MEDIA_STRINGS = {
|
|
103
132
|
live: "Live",
|
|
104
|
-
offlineBadge: "Offline"
|
|
133
|
+
offlineBadge: "Offline"
|
|
134
|
+
};
|
|
135
|
+
var PROGRESS_STRINGS = {
|
|
105
136
|
progress: "Progress",
|
|
137
|
+
progressIndeterminate: "Loading"
|
|
138
|
+
};
|
|
139
|
+
var FLOW_STRINGS = {
|
|
140
|
+
agentQueued: "Queued",
|
|
141
|
+
agentRunning: "Running",
|
|
142
|
+
agentDone: "Done",
|
|
143
|
+
agentFailed: "Failed",
|
|
144
|
+
stepDone: ", done",
|
|
145
|
+
stepFailed: ", failed",
|
|
106
146
|
workflow: "Workflow",
|
|
107
147
|
activity: "Activity",
|
|
108
148
|
other: "Other",
|
|
109
149
|
waiting: "Waiting",
|
|
110
|
-
noActivity: "No activity yet"
|
|
150
|
+
noActivity: "No activity yet"
|
|
151
|
+
};
|
|
152
|
+
var CANVAS_STRINGS = {
|
|
111
153
|
systemMap: "System map",
|
|
112
154
|
zoomOut: "Zoom out",
|
|
113
155
|
zoomIn: "Zoom in",
|
|
114
156
|
fitToScreen: "Fit to screen",
|
|
115
157
|
followActivity: "Follow activity",
|
|
116
|
-
canvasLines: "Lines"
|
|
158
|
+
canvasLines: "Lines"
|
|
159
|
+
};
|
|
160
|
+
var TOKEN_STRINGS = {
|
|
117
161
|
serviceTokens: "Service tokens",
|
|
118
162
|
serviceTokensIntro: "Machine clients, like the nish MCP server, use these tokens to read this app. Revoking one stops it at once.",
|
|
119
163
|
loadingServiceTokens: "Loading service tokens",
|
|
@@ -122,7 +166,9 @@ var DEFAULT_STRINGS = {
|
|
|
122
166
|
tokenRevokedAt: (when) => `Revoked ${when}`,
|
|
123
167
|
tokenRevokeNamed: (name) => `Revoke ${name}`,
|
|
124
168
|
tokenRevokeTitle: (name) => `Revoke ${name}?`,
|
|
125
|
-
tokenRevokeFailed: "Could not revoke the token."
|
|
169
|
+
tokenRevokeFailed: "Could not revoke the token."
|
|
170
|
+
};
|
|
171
|
+
var INBOX_STRINGS = {
|
|
126
172
|
inboxMarkHandled: "Mark handled",
|
|
127
173
|
inboxSnooze: "Snooze",
|
|
128
174
|
inboxActions: "Actions",
|
|
@@ -131,23 +177,94 @@ var DEFAULT_STRINGS = {
|
|
|
131
177
|
inboxSnoozed: "Snoozed",
|
|
132
178
|
inboxHandled: "Handled",
|
|
133
179
|
inboxFilterBySource: "Filter by source",
|
|
134
|
-
inboxHappened: (count) => `Happened ${count} times
|
|
180
|
+
inboxHappened: (count) => `Happened ${count} times`
|
|
181
|
+
};
|
|
182
|
+
var PAGING_STRINGS = {
|
|
135
183
|
previousPage: "Previous page",
|
|
136
184
|
nextPage: "Next page",
|
|
137
185
|
pageLabel: (n) => `Page ${n}`,
|
|
138
186
|
paginationLabel: "Pagination",
|
|
139
|
-
breadcrumbs: "Breadcrumbs"
|
|
140
|
-
|
|
187
|
+
breadcrumbs: "Breadcrumbs"
|
|
188
|
+
};
|
|
189
|
+
var FILE_STRINGS = {
|
|
141
190
|
dropzoneLabel: "Drop files here or browse",
|
|
142
191
|
browseFiles: "Browse files",
|
|
143
|
-
removeFile: (name) => `Remove ${name}
|
|
192
|
+
removeFile: (name) => `Remove ${name}`
|
|
193
|
+
};
|
|
194
|
+
var AVATAR_STRINGS = {
|
|
144
195
|
avatar: "Avatar",
|
|
145
|
-
avatarMore: (count) => `${count} more
|
|
196
|
+
avatarMore: (count) => `${count} more`
|
|
197
|
+
};
|
|
198
|
+
var SLIDER_STRINGS = {
|
|
146
199
|
sliderMin: "Minimum",
|
|
147
|
-
sliderMax: "Maximum"
|
|
148
|
-
|
|
149
|
-
|
|
200
|
+
sliderMax: "Maximum"
|
|
201
|
+
};
|
|
202
|
+
var ACCORDION_STRINGS = {
|
|
203
|
+
accordion: "Accordion"
|
|
204
|
+
};
|
|
205
|
+
var TIME_STRINGS = {
|
|
206
|
+
hour: "Hour",
|
|
207
|
+
minute: "Minute",
|
|
208
|
+
dayPeriod: "AM/PM",
|
|
209
|
+
invalidTime: "Enter a valid time."
|
|
150
210
|
};
|
|
211
|
+
var DEFAULT_STRINGS = /* @__PURE__ */ Object.assign(
|
|
212
|
+
{},
|
|
213
|
+
OVERLAY_STRINGS,
|
|
214
|
+
SHELL_STRINGS,
|
|
215
|
+
STATUS_STRINGS,
|
|
216
|
+
THEME_STRINGS,
|
|
217
|
+
ERROR_STRINGS,
|
|
218
|
+
DISPLAY_STRINGS,
|
|
219
|
+
FIELD_STRINGS,
|
|
220
|
+
FILTER_STRINGS,
|
|
221
|
+
PICKER_STRINGS,
|
|
222
|
+
MULTI_SELECT_STRINGS,
|
|
223
|
+
CAROUSEL_STRINGS,
|
|
224
|
+
COMMAND_STRINGS,
|
|
225
|
+
TABLE_STRINGS,
|
|
226
|
+
SETTINGS_STRINGS,
|
|
227
|
+
SPLIT_STRINGS,
|
|
228
|
+
MEDIA_STRINGS,
|
|
229
|
+
PROGRESS_STRINGS,
|
|
230
|
+
FLOW_STRINGS,
|
|
231
|
+
CANVAS_STRINGS,
|
|
232
|
+
TOKEN_STRINGS,
|
|
233
|
+
INBOX_STRINGS,
|
|
234
|
+
PAGING_STRINGS,
|
|
235
|
+
FILE_STRINGS,
|
|
236
|
+
AVATAR_STRINGS,
|
|
237
|
+
SLIDER_STRINGS,
|
|
238
|
+
ACCORDION_STRINGS,
|
|
239
|
+
TIME_STRINGS
|
|
240
|
+
);
|
|
151
241
|
export {
|
|
152
|
-
|
|
242
|
+
ACCORDION_STRINGS,
|
|
243
|
+
AVATAR_STRINGS,
|
|
244
|
+
CANVAS_STRINGS,
|
|
245
|
+
CAROUSEL_STRINGS,
|
|
246
|
+
COMMAND_STRINGS,
|
|
247
|
+
DEFAULT_STRINGS,
|
|
248
|
+
DISPLAY_STRINGS,
|
|
249
|
+
ERROR_STRINGS,
|
|
250
|
+
FIELD_STRINGS,
|
|
251
|
+
FILE_STRINGS,
|
|
252
|
+
FILTER_STRINGS,
|
|
253
|
+
FLOW_STRINGS,
|
|
254
|
+
INBOX_STRINGS,
|
|
255
|
+
MEDIA_STRINGS,
|
|
256
|
+
MULTI_SELECT_STRINGS,
|
|
257
|
+
OVERLAY_STRINGS,
|
|
258
|
+
PAGING_STRINGS,
|
|
259
|
+
PICKER_STRINGS,
|
|
260
|
+
PROGRESS_STRINGS,
|
|
261
|
+
SETTINGS_STRINGS,
|
|
262
|
+
SHELL_STRINGS,
|
|
263
|
+
SLIDER_STRINGS,
|
|
264
|
+
SPLIT_STRINGS,
|
|
265
|
+
STATUS_STRINGS,
|
|
266
|
+
TABLE_STRINGS,
|
|
267
|
+
THEME_STRINGS,
|
|
268
|
+
TIME_STRINGS,
|
|
269
|
+
TOKEN_STRINGS
|
|
153
270
|
};
|
|
@@ -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;
|
|
@@ -68,23 +69,29 @@ function TagInput({
|
|
|
68
69
|
const add = (raw) => {
|
|
69
70
|
let next = tags;
|
|
70
71
|
let err = null;
|
|
72
|
+
const refused = [];
|
|
71
73
|
for (const r of raw) {
|
|
72
74
|
const t = r.trim();
|
|
73
75
|
if (!t || next.includes(t)) continue;
|
|
74
|
-
if (maxTags !== void 0 && next.length >= maxTags)
|
|
76
|
+
if (maxTags !== void 0 && next.length >= maxTags) {
|
|
77
|
+
err ??= strings.maxTags(maxTags);
|
|
78
|
+
refused.push(t);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
75
81
|
const message = validate?.(t) ?? null;
|
|
76
82
|
if (message) {
|
|
77
83
|
err ??= message;
|
|
84
|
+
refused.push(t);
|
|
78
85
|
continue;
|
|
79
86
|
}
|
|
80
87
|
next = [...next, t];
|
|
81
88
|
}
|
|
82
89
|
if (next !== tags) setTags(next);
|
|
83
90
|
setError(err);
|
|
84
|
-
return err;
|
|
91
|
+
return { error: err, refused };
|
|
85
92
|
};
|
|
86
93
|
const commitText = (raw) => {
|
|
87
|
-
if (!add([raw])) {
|
|
94
|
+
if (!add([raw]).error) {
|
|
88
95
|
setText("");
|
|
89
96
|
setActive(-1);
|
|
90
97
|
}
|
|
@@ -97,9 +104,10 @@ function TagInput({
|
|
|
97
104
|
const handleKeyDown = (e) => {
|
|
98
105
|
if (e.nativeEvent.isComposing) return;
|
|
99
106
|
if (e.key === "Enter") {
|
|
100
|
-
|
|
107
|
+
const pick = listOpen && active >= 0 ? filtered[active] : void 0;
|
|
108
|
+
if (pick !== void 0) {
|
|
101
109
|
e.preventDefault();
|
|
102
|
-
commitText(
|
|
110
|
+
commitText(pick);
|
|
103
111
|
} else if (text.trim()) {
|
|
104
112
|
e.preventDefault();
|
|
105
113
|
commitText(text);
|
|
@@ -136,7 +144,8 @@ function TagInput({
|
|
|
136
144
|
e.preventDefault();
|
|
137
145
|
const parts = pasted.split(SPLIT);
|
|
138
146
|
parts[0] = text + parts[0];
|
|
139
|
-
|
|
147
|
+
const { error: err, refused } = add(parts);
|
|
148
|
+
setText(err ? refused.join(", ") : "");
|
|
140
149
|
};
|
|
141
150
|
const handleBlur = (e) => {
|
|
142
151
|
onBlur?.(e);
|
|
@@ -200,7 +209,7 @@ function TagInput({
|
|
|
200
209
|
"aria-expanded": hasSuggestions ? listOpen : void 0,
|
|
201
210
|
"aria-controls": listOpen ? listId : void 0,
|
|
202
211
|
"aria-autocomplete": hasSuggestions ? "list" : void 0,
|
|
203
|
-
"aria-activedescendant": listOpen && active >= 0 ? `${auto}-opt-${active}` : void 0,
|
|
212
|
+
"aria-activedescendant": listOpen && active >= 0 && active < filtered.length ? `${auto}-opt-${active}` : void 0,
|
|
204
213
|
"aria-label": ariaLabel,
|
|
205
214
|
"aria-labelledby": ariaLabelledBy,
|
|
206
215
|
"aria-describedby": [ariaDescribedBy, error ? errorId : null].filter(Boolean).join(" ") || 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);
|
|
@@ -11,8 +11,11 @@ function toTime(h, m) {
|
|
|
11
11
|
return `${pad2(h)}:${pad2(m)}`;
|
|
12
12
|
}
|
|
13
13
|
function inTimeRange(t, min, max) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const lo = parseTime(min) ? min : null;
|
|
15
|
+
const hi = parseTime(max) ? max : null;
|
|
16
|
+
if (lo !== null && hi !== null && lo > hi) return t >= lo || t <= hi;
|
|
17
|
+
if (lo !== null && t < lo) return false;
|
|
18
|
+
if (hi !== null && t > hi) return false;
|
|
16
19
|
return true;
|
|
17
20
|
}
|
|
18
21
|
var cycles = /* @__PURE__ */ new Map();
|
|
@@ -9,7 +9,8 @@ import { useIsoLayoutEffect } from "./client.js";
|
|
|
9
9
|
import { setRef } from "./forms-classes.js";
|
|
10
10
|
import { fieldClass } from "./primitives-classes.js";
|
|
11
11
|
import { Select } from "./primitives.js";
|
|
12
|
-
import {
|
|
12
|
+
import { useStrings, useNishContext } from "./provider.js";
|
|
13
|
+
import { TIME_STRINGS } from "./strings.js";
|
|
13
14
|
import {
|
|
14
15
|
dayPeriodNames,
|
|
15
16
|
draftFromTime,
|
|
@@ -62,8 +63,8 @@ function TimeField({
|
|
|
62
63
|
className,
|
|
63
64
|
...rest
|
|
64
65
|
}) {
|
|
65
|
-
const strings =
|
|
66
|
-
const config =
|
|
66
|
+
const strings = useStrings(TIME_STRINGS);
|
|
67
|
+
const config = useNishContext();
|
|
67
68
|
const loc = resolveLocale(locale ?? config.locale ?? getDefaultLocale());
|
|
68
69
|
const cycle = hourCycle ?? hourCycleFor(loc);
|
|
69
70
|
const st = normalizeStep(step);
|
|
@@ -107,15 +108,17 @@ function TimeField({
|
|
|
107
108
|
};
|
|
108
109
|
const [own, setOwn] = useState(() => okProp("defaultValue", defaultValue));
|
|
109
110
|
const value = controlled ? okProp("value", valueProp) : own;
|
|
111
|
+
const hourRef = useRef(null);
|
|
112
|
+
const minuteRef = useRef(null);
|
|
110
113
|
const [draftState, setDraft] = useState(null);
|
|
111
114
|
const [bad, setBad] = useState(false);
|
|
112
|
-
|
|
115
|
+
const [focusInside, setFocusInside] = useState(false);
|
|
116
|
+
const draftKept = draftState !== null && (draftState.base === value || focusInside && draftState.prev === value);
|
|
117
|
+
if (draftState !== null && !draftKept) {
|
|
113
118
|
setDraft(null);
|
|
114
119
|
setBad(false);
|
|
115
120
|
}
|
|
116
|
-
const draft = draftState !== null &&
|
|
117
|
-
const hourRef = useRef(null);
|
|
118
|
-
const minuteRef = useRef(null);
|
|
121
|
+
const draft = draftState !== null && draftKept ? draftState.d : null;
|
|
119
122
|
const shown = draft ?? draftFromTime(value, cycle);
|
|
120
123
|
const draftBad = () => {
|
|
121
124
|
if (draft === null) return false;
|
|
@@ -146,14 +149,14 @@ function TimeField({
|
|
|
146
149
|
const t = draftTime(next, cycle);
|
|
147
150
|
if (t === null) {
|
|
148
151
|
if (value !== null) commit(null);
|
|
149
|
-
setDraft({ d: next, base: null });
|
|
152
|
+
setDraft({ d: next, base: null, prev: value });
|
|
150
153
|
setBad(false);
|
|
151
154
|
} else if (typeof t === "string" && inTimeRange(t, minT, maxT)) {
|
|
152
155
|
if (t !== value) commit(t);
|
|
153
|
-
setDraft({ d: next, base: t });
|
|
156
|
+
setDraft({ d: next, base: t, prev: value });
|
|
154
157
|
setBad(false);
|
|
155
158
|
} else {
|
|
156
|
-
setDraft({ d: next, base: value });
|
|
159
|
+
setDraft({ d: next, base: value, prev: value });
|
|
157
160
|
}
|
|
158
161
|
};
|
|
159
162
|
const focusMinute = () => {
|
|
@@ -163,6 +166,7 @@ function TimeField({
|
|
|
163
166
|
const onKey = (which) => (e) => {
|
|
164
167
|
if (disabled) return;
|
|
165
168
|
const key = e.key;
|
|
169
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
166
170
|
if (key === "Enter") {
|
|
167
171
|
if (draftBad()) {
|
|
168
172
|
e.preventDefault();
|
|
@@ -232,9 +236,14 @@ function TimeField({
|
|
|
232
236
|
"aria-labelledby": src,
|
|
233
237
|
"data-disabled": disabled ? "" : void 0,
|
|
234
238
|
className: cn("inline-flex items-center gap-2", className),
|
|
239
|
+
onFocus: (e) => {
|
|
240
|
+
rest.onFocus?.(e);
|
|
241
|
+
setFocusInside(true);
|
|
242
|
+
},
|
|
235
243
|
onBlur: (e) => {
|
|
236
244
|
rest.onBlur?.(e);
|
|
237
245
|
if (e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget)) return;
|
|
246
|
+
setFocusInside(false);
|
|
238
247
|
const isBad = draftBad();
|
|
239
248
|
setBad(isBad);
|
|
240
249
|
if (!isBad) setDraft(null);
|