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
|
@@ -14,7 +14,8 @@ import { useIsoLayoutEffect } from "./client.js";
|
|
|
14
14
|
import { useMediaQuery, useNow } from "./hooks.js";
|
|
15
15
|
import { Tooltip } from "./tooltip.js";
|
|
16
16
|
import { Badge } from "./primitives.js";
|
|
17
|
-
import {
|
|
17
|
+
import { useStrings } from "./provider.js";
|
|
18
|
+
import { PROGRESS_STRINGS, FLOW_STRINGS } from "./strings.js";
|
|
18
19
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
20
|
var EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
20
21
|
function usePrefersReducedMotion() {
|
|
@@ -203,7 +204,7 @@ function StepRow({
|
|
|
203
204
|
);
|
|
204
205
|
}
|
|
205
206
|
function FlowSteps({ steps, orientation = "auto", label, statusLabels, className, ref, ...rest }) {
|
|
206
|
-
const s =
|
|
207
|
+
const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
|
|
207
208
|
const allDone = steps.length > 0 && steps.every((s2) => s2.status === "done");
|
|
208
209
|
const prevAll = useRef(null);
|
|
209
210
|
const [sweeping, setSweeping] = useState(false);
|
|
@@ -234,7 +235,7 @@ function FlowSteps({ steps, orientation = "auto", label, statusLabels, className
|
|
|
234
235
|
)) }) });
|
|
235
236
|
}
|
|
236
237
|
function StepBar({ total, done, active = false, label, className, ref, ...rest }) {
|
|
237
|
-
const s =
|
|
238
|
+
const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
|
|
238
239
|
const t = Number.isFinite(total) ? Math.max(0, Math.floor(total)) : 0;
|
|
239
240
|
const d = Number.isFinite(done) ? Math.min(t, Math.max(0, Math.floor(done))) : 0;
|
|
240
241
|
const props = {
|
|
@@ -397,7 +398,7 @@ function PhaseConnector({ flowing }) {
|
|
|
397
398
|
] });
|
|
398
399
|
}
|
|
399
400
|
function WorkflowBoard({ phases, agents, label, otherLabel, waitingLabel, className, ref, ...rest }) {
|
|
400
|
-
const s =
|
|
401
|
+
const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
|
|
401
402
|
const otherTitle = otherLabel ?? s.other;
|
|
402
403
|
const fresh = useFreshIds(
|
|
403
404
|
agents.map((a) => a.id),
|
|
@@ -507,7 +508,7 @@ var FEED_DOT = {
|
|
|
507
508
|
};
|
|
508
509
|
var FEED_DOT_FORCED = "forced-colors:bg-[color:CanvasText]";
|
|
509
510
|
function ActivityFeed({ items, max = 50, now, label, empty, className, ref, ...rest }) {
|
|
510
|
-
const s =
|
|
511
|
+
const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
|
|
511
512
|
const internalNow = useNow(15e3);
|
|
512
513
|
const clock = now ?? internalNow;
|
|
513
514
|
const shown = useMemo(() => [...items].sort((a, b) => b.at - a.at).slice(0, Math.max(0, max)), [items, max]);
|
|
@@ -15,7 +15,9 @@ import { cn } from "../cn.js";
|
|
|
15
15
|
import { FIELD, IconButton, Input } from "./primitives.js";
|
|
16
16
|
import { XIcon } from "./icons.js";
|
|
17
17
|
import { isRtl, useIsoLayoutEffect } from "./client.js";
|
|
18
|
-
import {
|
|
18
|
+
import { useStrings } from "./provider.js";
|
|
19
|
+
import { FIELD_STRINGS } from "./strings.js";
|
|
20
|
+
import { warnDev } from "./display-classes.js";
|
|
19
21
|
import { chipClass, setRef } from "./forms-classes.js";
|
|
20
22
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
23
|
function Svg({ size = 16, children, ...rest }) {
|
|
@@ -180,7 +182,6 @@ function Switch({
|
|
|
180
182
|
ref,
|
|
181
183
|
checked: checkedProp,
|
|
182
184
|
defaultChecked = false,
|
|
183
|
-
onChange,
|
|
184
185
|
onCheckedChange,
|
|
185
186
|
name,
|
|
186
187
|
value = "on",
|
|
@@ -194,8 +195,13 @@ function Switch({
|
|
|
194
195
|
className,
|
|
195
196
|
id,
|
|
196
197
|
onClick,
|
|
197
|
-
...
|
|
198
|
+
...allRest
|
|
198
199
|
}) {
|
|
200
|
+
const { onChange: removedOnChange, ...rest } = allRest;
|
|
201
|
+
const removed = removedOnChange !== void 0;
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (removed) warnDev("Switch: onChange was removed in nish-ui 3.0. Use onCheckedChange(checked).");
|
|
204
|
+
}, [removed]);
|
|
199
205
|
const auto = useId();
|
|
200
206
|
const btnId = id ?? `${auto}-switch`;
|
|
201
207
|
const labelId = `${auto}-label`;
|
|
@@ -229,7 +235,6 @@ function Switch({
|
|
|
229
235
|
if (e.defaultPrevented) return;
|
|
230
236
|
const next = !checked;
|
|
231
237
|
if (!controlled) setInner(next);
|
|
232
|
-
onChange?.(next, e);
|
|
233
238
|
onCheckedChange?.(next);
|
|
234
239
|
},
|
|
235
240
|
className: cn(
|
|
@@ -327,7 +332,7 @@ function Field({
|
|
|
327
332
|
...rest
|
|
328
333
|
}) {
|
|
329
334
|
const auto = useId();
|
|
330
|
-
const strings =
|
|
335
|
+
const strings = useStrings(FIELD_STRINGS);
|
|
331
336
|
const only = Children.count(children) === 1 && isValidElement(children) ? children : null;
|
|
332
337
|
const childId = only && typeof only.props.id === "string" ? only.props.id : void 0;
|
|
333
338
|
const controlId = htmlFor ?? childId ?? `${auto}-control`;
|
|
@@ -345,6 +350,7 @@ function Field({
|
|
|
345
350
|
const labelEl = /* @__PURE__ */ jsxs(
|
|
346
351
|
"label",
|
|
347
352
|
{
|
|
353
|
+
id: `${controlId}-label`,
|
|
348
354
|
htmlFor: controlId,
|
|
349
355
|
className: cn(
|
|
350
356
|
"flex flex-wrap items-baseline gap-x-1.5",
|
|
@@ -384,7 +390,7 @@ function Field({
|
|
|
384
390
|
}
|
|
385
391
|
function FieldGroup({ ref, label, hint, error, optional = false, className, children, ...rest }) {
|
|
386
392
|
const auto = useId();
|
|
387
|
-
const strings =
|
|
393
|
+
const strings = useStrings(FIELD_STRINGS);
|
|
388
394
|
const hasError = error != null && error !== false && error !== "";
|
|
389
395
|
const hintId = `${auto}-hint`;
|
|
390
396
|
const errorId = `${auto}-error`;
|
|
@@ -419,7 +425,7 @@ function SearchInput({
|
|
|
419
425
|
disabled,
|
|
420
426
|
...rest
|
|
421
427
|
}) {
|
|
422
|
-
const strings =
|
|
428
|
+
const strings = useStrings(FIELD_STRINGS);
|
|
423
429
|
const inner = useRef(null);
|
|
424
430
|
const [own, setOwn] = useState(defaultValue);
|
|
425
431
|
const controlled = valueProp !== void 0;
|
|
@@ -493,7 +499,7 @@ function SearchInput({
|
|
|
493
499
|
] });
|
|
494
500
|
}
|
|
495
501
|
function Chip({ ref, variant = "toggle", pressed, onRemove, removeLabel, icon, trailing, size = "md", className, children, type = "button", ...rest }) {
|
|
496
|
-
const strings =
|
|
502
|
+
const strings = useStrings(FIELD_STRINGS);
|
|
497
503
|
if (variant === "tag") {
|
|
498
504
|
const name = removeLabel ?? (typeof children === "string" ? strings.removeNamed(children) : strings.remove);
|
|
499
505
|
const spanProps = rest;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { cn } from "../cn.js";
|
|
12
12
|
import { ago, dateTime } from "../format.js";
|
|
13
13
|
import { BREAKPOINTS, NARROW_QUERY, PHONE_QUERY } from "./hooks-classes.js";
|
|
14
|
-
import {
|
|
14
|
+
import { useNishContext } from "./provider.js";
|
|
15
15
|
import { jsx } from "react/jsx-runtime";
|
|
16
16
|
var queries = /* @__PURE__ */ new Map();
|
|
17
17
|
function hasMatchMedia() {
|
|
@@ -215,7 +215,7 @@ function RelativeTime({
|
|
|
215
215
|
...rest
|
|
216
216
|
}) {
|
|
217
217
|
const now = useNow(refreshMs);
|
|
218
|
-
const config =
|
|
218
|
+
const config = useNishContext();
|
|
219
219
|
const loc = locale ?? config.locale;
|
|
220
220
|
const d = new Date(value);
|
|
221
221
|
const iso = Number.isNaN(d.getTime()) ? void 0 : d.toISOString();
|
|
@@ -20,7 +20,7 @@ import { mergeRefs, warnOnce } from "./data-classes.js";
|
|
|
20
20
|
import { useLatest } from "./latest.js";
|
|
21
21
|
import { place } from "./overlay-position.js";
|
|
22
22
|
import { keyboardFocused, touchTracker } from "./overlay-classes.js";
|
|
23
|
-
import {
|
|
23
|
+
import { useNishContext } from "./provider.js";
|
|
24
24
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
25
|
var openCard = () => shared("hoverCard", () => ({ close: null }));
|
|
26
26
|
function useCardPosition(anchor, card, open, side, align) {
|
|
@@ -74,7 +74,7 @@ function HoverCard({
|
|
|
74
74
|
}) {
|
|
75
75
|
const [openState, setOpenState] = useState(defaultOpen ?? false);
|
|
76
76
|
const open = openProp ?? openState;
|
|
77
|
-
const config =
|
|
77
|
+
const config = useNishContext();
|
|
78
78
|
const isClient = useIsClient();
|
|
79
79
|
const autoId = useId();
|
|
80
80
|
const id = rest.id ?? autoId;
|
|
@@ -14,11 +14,13 @@ import { CheckIcon, ClockIcon, MoreIcon } from "./icons.js";
|
|
|
14
14
|
import { DropdownMenu, MenuItem, MenuLabel, MenuSeparator } from "./menu.js";
|
|
15
15
|
import { ConfirmDialog } from "./modal.js";
|
|
16
16
|
import { Button, Card, IconButton } from "./primitives.js";
|
|
17
|
-
import {
|
|
17
|
+
import { useStrings } from "./provider.js";
|
|
18
|
+
import { INBOX_STRINGS, SHELL_STRINGS, STATUS_STRINGS, OVERLAY_STRINGS } from "./strings.js";
|
|
18
19
|
import { Tabs } from "./tabs.js";
|
|
19
20
|
import { DEFAULT_INBOX_LABELS } from "./inbox-classes.js";
|
|
20
21
|
import { DEFAULT_INBOX_LABELS as DEFAULT_INBOX_LABELS2 } from "./inbox-classes.js";
|
|
21
22
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var useInboxStrings = () => useStrings(INBOX_STRINGS, SHELL_STRINGS, STATUS_STRINGS, OVERLAY_STRINGS);
|
|
22
24
|
var DOT_TONE = {
|
|
23
25
|
urgent: "loss",
|
|
24
26
|
normal: "accent",
|
|
@@ -142,7 +144,7 @@ function Inbox({
|
|
|
142
144
|
ref,
|
|
143
145
|
...rest
|
|
144
146
|
}) {
|
|
145
|
-
const strings =
|
|
147
|
+
const strings = useInboxStrings();
|
|
146
148
|
const labels = { ...DEFAULT_INBOX_LABELS, ...labelOverrides };
|
|
147
149
|
const idBase = useId().replace(/:/g, "");
|
|
148
150
|
const wide = useMediaQuery("(min-width: 480px)");
|
|
@@ -13,7 +13,8 @@ import { mergeRefs } from "./data-classes.js";
|
|
|
13
13
|
import { Callout } from "./display.js";
|
|
14
14
|
import { useHeightVar, useStuck } from "./layout-vars.js";
|
|
15
15
|
import { Button } from "./primitives.js";
|
|
16
|
-
import {
|
|
16
|
+
import { useStrings } from "./provider.js";
|
|
17
|
+
import { STATUS_STRINGS } from "./strings.js";
|
|
17
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
19
|
function StickyBar({
|
|
19
20
|
children,
|
|
@@ -55,7 +56,7 @@ function StickyActionBar({
|
|
|
55
56
|
ref: refProp,
|
|
56
57
|
...rest
|
|
57
58
|
}) {
|
|
58
|
-
const strings =
|
|
59
|
+
const strings = useStrings(STATUS_STRINGS);
|
|
59
60
|
const ref = useRef(null);
|
|
60
61
|
useHeightVar(ref, "--nish-bottom-bar-h", open);
|
|
61
62
|
if (!open) return null;
|
|
@@ -97,7 +98,7 @@ function LoadingBar({
|
|
|
97
98
|
ref,
|
|
98
99
|
...rest
|
|
99
100
|
}) {
|
|
100
|
-
const strings =
|
|
101
|
+
const strings = useStrings(STATUS_STRINGS);
|
|
101
102
|
const [shown, setShown] = useState(false);
|
|
102
103
|
useEffect(() => {
|
|
103
104
|
if (!active) {
|
|
@@ -185,7 +186,7 @@ function ConnectionBanner({
|
|
|
185
186
|
onRetry,
|
|
186
187
|
...rest
|
|
187
188
|
}) {
|
|
188
|
-
const strings =
|
|
189
|
+
const strings = useStrings(STATUS_STRINGS);
|
|
189
190
|
const online = useOnline();
|
|
190
191
|
const [reachable, setReachable] = useState(true);
|
|
191
192
|
const [retrying, setRetrying] = useState(false);
|
|
@@ -6,7 +6,8 @@ import { cn } from "../cn.js";
|
|
|
6
6
|
import { safeUrl } from "../url.js";
|
|
7
7
|
import { ListRow } from "./data.js";
|
|
8
8
|
import { Badge } from "./primitives.js";
|
|
9
|
-
import {
|
|
9
|
+
import { useStrings } from "./provider.js";
|
|
10
|
+
import { MEDIA_STRINGS } from "./strings.js";
|
|
10
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
var THUMB_BOX = {
|
|
12
13
|
wide: {
|
|
@@ -61,7 +62,7 @@ function MediaRow({
|
|
|
61
62
|
ref,
|
|
62
63
|
...rest
|
|
63
64
|
}) {
|
|
64
|
-
const t =
|
|
65
|
+
const t = useStrings(MEDIA_STRINGS);
|
|
65
66
|
const small = dense || compact;
|
|
66
67
|
const size = thumbSize ?? (small ? "sm" : "md");
|
|
67
68
|
const badgeSize = small ? "xs" : "sm";
|
|
@@ -8,7 +8,8 @@ import { isRtl } from "./client.js";
|
|
|
8
8
|
import { useMediaQuery } from "./hooks.js";
|
|
9
9
|
import { useLatest } from "./latest.js";
|
|
10
10
|
import { lazyModule, useLazyModule } from "./lazy-module.js";
|
|
11
|
-
import {
|
|
11
|
+
import { useStrings, useNishContext } from "./provider.js";
|
|
12
|
+
import { OVERLAY_STRINGS } from "./strings.js";
|
|
12
13
|
import { MENU_ROW, PHONE_QUERY, menuItemClass } from "./overlay-classes.js";
|
|
13
14
|
import { layerHost, setRef, useMergedRef } from "./overlay-core.js";
|
|
14
15
|
import { useAnchoredPosition, floatingStyle, useDismiss, useReturnFocus } from "./overlay-position.js";
|
|
@@ -43,8 +44,8 @@ function DropdownMenu({
|
|
|
43
44
|
onKeyDown: userKeyDown,
|
|
44
45
|
...rest
|
|
45
46
|
}) {
|
|
46
|
-
const strings =
|
|
47
|
-
const config =
|
|
47
|
+
const strings = useStrings(OVERLAY_STRINGS);
|
|
48
|
+
const config = useNishContext();
|
|
48
49
|
const [openState, setOpenState] = useState(defaultOpen);
|
|
49
50
|
const open = openProp ?? openState;
|
|
50
51
|
const triggerRef = useRef(null);
|
|
@@ -291,7 +292,7 @@ function MenuSeparator({
|
|
|
291
292
|
return /* @__PURE__ */ jsx("div", { ...rest, ref, role: "separator", className: cn("my-1 h-px bg-th-line forced-colors:bg-[CanvasText]", className) });
|
|
292
293
|
}
|
|
293
294
|
function MenuSubHeader({ onBack, children, className, ref, onKeyDown, ...rest }) {
|
|
294
|
-
const strings =
|
|
295
|
+
const strings = useStrings(OVERLAY_STRINGS);
|
|
295
296
|
return /* @__PURE__ */ jsxs(
|
|
296
297
|
"button",
|
|
297
298
|
{
|
|
@@ -7,7 +7,8 @@ import { XIcon } from "./icons.js";
|
|
|
7
7
|
import { Button } from "./primitives.js";
|
|
8
8
|
import { useLatest } from "./latest.js";
|
|
9
9
|
import { Portal } from "./portal.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useStrings } from "./provider.js";
|
|
11
|
+
import { OVERLAY_STRINGS } from "./strings.js";
|
|
11
12
|
import { CLOSE_BUTTON, MODAL_SIZE, SHEET_HEIGHT_CLASS } from "./overlay-classes.js";
|
|
12
13
|
import { isPhoneViewport, closeVetoes, warnDev, useMergedRef, useScrollable } from "./overlay-core.js";
|
|
13
14
|
import { useDialog, useSheetExit, useSheetSwipe, SheetHandle } from "./overlay-dialog.js";
|
|
@@ -38,7 +39,7 @@ function ModalPanel({
|
|
|
38
39
|
ref,
|
|
39
40
|
...rest
|
|
40
41
|
}) {
|
|
41
|
-
const strings =
|
|
42
|
+
const strings = useStrings(OVERLAY_STRINGS);
|
|
42
43
|
const titleId = useId();
|
|
43
44
|
const [panelRef, setPanelRef] = useMergedRef(ref);
|
|
44
45
|
const scrimRef = useRef(null);
|
|
@@ -132,7 +133,7 @@ function ConfirmDialog({
|
|
|
132
133
|
open,
|
|
133
134
|
onOpenChange
|
|
134
135
|
}) {
|
|
135
|
-
const strings =
|
|
136
|
+
const strings = useStrings(OVERLAY_STRINGS);
|
|
136
137
|
const bodyId = useId();
|
|
137
138
|
const pendingRef = useLatest(pending);
|
|
138
139
|
const onOpenChangeRef = useLatest(onOpenChange);
|
|
@@ -5,11 +5,12 @@ import { cn } from "../cn.js";
|
|
|
5
5
|
import { FORCED_MARK } from "./display-classes.js";
|
|
6
6
|
import { Drawer } from "./drawer.js";
|
|
7
7
|
import { FOCUS, NavBadge, renderItem, visibleNavItems } from "./nav-items.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useStrings } from "./provider.js";
|
|
9
|
+
import { SHELL_STRINGS, THEME_STRINGS } from "./strings.js";
|
|
9
10
|
import { ThemeToggle } from "./theme-toggle.js";
|
|
10
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
function MoreSheet({ open, onClose, items, title, footer, renderLink }) {
|
|
12
|
-
const strings =
|
|
13
|
+
const strings = useStrings(SHELL_STRINGS, THEME_STRINGS);
|
|
13
14
|
if (!open) return null;
|
|
14
15
|
const shown = visibleNavItems(items);
|
|
15
16
|
const row = (active) => cn(
|
|
@@ -7,7 +7,8 @@ import { CheckIcon, XIcon } from "./icons.js";
|
|
|
7
7
|
import { Spinner } from "./feedback.js";
|
|
8
8
|
import { Chip } from "./forms.js";
|
|
9
9
|
import { fieldClass } from "./primitives.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useStrings } from "./provider.js";
|
|
11
|
+
import { FIELD_STRINGS, MULTI_SELECT_STRINGS } from "./strings.js";
|
|
11
12
|
import { indexComboboxOptions, setRef } from "./forms-classes.js";
|
|
12
13
|
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN } from "../combobox-filter.js";
|
|
13
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -42,7 +43,7 @@ function MultiSelect({
|
|
|
42
43
|
className,
|
|
43
44
|
...rest
|
|
44
45
|
}) {
|
|
45
|
-
const strings =
|
|
46
|
+
const strings = useStrings(FIELD_STRINGS, MULTI_SELECT_STRINGS);
|
|
46
47
|
const autoId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
47
48
|
const inputId = id ?? `nish-ms-${autoId}`;
|
|
48
49
|
const listId = `nish-ms-list-${autoId}`;
|
|
@@ -6,10 +6,11 @@ import { safeUrl } from "../url.js";
|
|
|
6
6
|
import { isRtl, useIsoLayoutEffect } from "./client.js";
|
|
7
7
|
import { navigateFromLayer } from "./navigate.js";
|
|
8
8
|
import { warnDev } from "./display-classes.js";
|
|
9
|
-
import {
|
|
9
|
+
import { useStrings, useNishContext } from "./provider.js";
|
|
10
|
+
import { SHELL_STRINGS } from "./strings.js";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
function useEndSide(ref) {
|
|
12
|
-
const dir =
|
|
13
|
+
const dir = useNishContext().dir;
|
|
13
14
|
const [rtl, setRtl] = useState(dir === "rtl");
|
|
14
15
|
useIsoLayoutEffect(() => {
|
|
15
16
|
setRtl(dir ? dir === "rtl" : isRtl(ref.current));
|
|
@@ -17,7 +18,7 @@ function useEndSide(ref) {
|
|
|
17
18
|
return rtl ? "left" : "right";
|
|
18
19
|
}
|
|
19
20
|
function NavBadge({ value }) {
|
|
20
|
-
const strings =
|
|
21
|
+
const strings = useStrings(SHELL_STRINGS);
|
|
21
22
|
if (value === void 0 || value === false || value === 0) return null;
|
|
22
23
|
if (value === true) {
|
|
23
24
|
return /* @__PURE__ */ jsx(
|
|
@@ -16,7 +16,8 @@ import { PanelLeftCloseIcon, PanelLeftOpenIcon } from "./icons.js";
|
|
|
16
16
|
import { useHeightVar, useScrollEdges } from "./layout-vars.js";
|
|
17
17
|
import { NavBadge, FOCUS, renderItem, useEndSide, visibleNavItems } from "./nav-items.js";
|
|
18
18
|
import { IconButton } from "./primitives.js";
|
|
19
|
-
import {
|
|
19
|
+
import { useStrings } from "./provider.js";
|
|
20
|
+
import { SHELL_STRINGS } from "./strings.js";
|
|
20
21
|
import { Tooltip } from "./tooltip.js";
|
|
21
22
|
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
|
|
22
23
|
var MAX_QUERY = {
|
|
@@ -44,7 +45,7 @@ function BottomNav({
|
|
|
44
45
|
ref: refProp,
|
|
45
46
|
...rest
|
|
46
47
|
}) {
|
|
47
|
-
const strings =
|
|
48
|
+
const strings = useStrings(SHELL_STRINGS);
|
|
48
49
|
const ref = useRef(null);
|
|
49
50
|
const visible = useMediaQuery(MAX_QUERY[hideFrom]);
|
|
50
51
|
useHeightVar(ref, "--nish-bottom-nav-h", visible);
|
|
@@ -115,7 +116,7 @@ function NavRail({
|
|
|
115
116
|
ref: refProp,
|
|
116
117
|
...rest
|
|
117
118
|
}) {
|
|
118
|
-
const strings =
|
|
119
|
+
const strings = useStrings(SHELL_STRINGS);
|
|
119
120
|
const ref = useRef(null);
|
|
120
121
|
const side = useEndSide(ref);
|
|
121
122
|
const shown = visibleNavItems(items);
|
|
@@ -179,7 +180,7 @@ function NavSidebar({
|
|
|
179
180
|
ref: refProp,
|
|
180
181
|
...rest
|
|
181
182
|
}) {
|
|
182
|
-
const strings =
|
|
183
|
+
const strings = useStrings(SHELL_STRINGS);
|
|
183
184
|
const ref = useRef(null);
|
|
184
185
|
const side = useEndSide(ref);
|
|
185
186
|
const shown = visibleNavItems(items);
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "../cn.js";
|
|
6
6
|
import { useLatest } from "./latest.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useStrings } from "./provider.js";
|
|
8
|
+
import { OVERLAY_STRINGS } from "./strings.js";
|
|
8
9
|
import { SHEET_EXIT_MS } from "./overlay-classes.js";
|
|
9
10
|
import { ov, isTop, syncLayerAttr, pushInert, popInert, acquireGuard, releaseGuard, prefersReducedMotion, closeVetoes, focusables, lockScroll, queueHistoryPush, cancelHistoryPush } from "./overlay-core.js";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -225,7 +226,7 @@ function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => tru
|
|
|
225
226
|
};
|
|
226
227
|
}
|
|
227
228
|
function SheetHandle({ onClose, swipe, className }) {
|
|
228
|
-
const strings =
|
|
229
|
+
const strings = useStrings(OVERLAY_STRINGS);
|
|
229
230
|
return /* @__PURE__ */ jsx(
|
|
230
231
|
"div",
|
|
231
232
|
{
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import { useCallback, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "../cn.js";
|
|
6
6
|
import { useIsoLayoutEffect } from "./client.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useStrings } from "./provider.js";
|
|
8
|
+
import { PAGING_STRINGS } from "./strings.js";
|
|
8
9
|
import { paginationRange } from "./pagination-classes.js";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
var SIZE = { sm: "h-8 min-w-8 text-xs", md: "h-9 min-w-9 text-sm" };
|
|
@@ -60,7 +61,7 @@ function Pagination({
|
|
|
60
61
|
ref,
|
|
61
62
|
...rest
|
|
62
63
|
}) {
|
|
63
|
-
const strings =
|
|
64
|
+
const strings = useStrings(PAGING_STRINGS);
|
|
64
65
|
const [pageState, setPageState] = useState(defaultPage);
|
|
65
66
|
const navRef = useRef(null);
|
|
66
67
|
const [narrow, setNarrow] = useState(false);
|
|
@@ -6,7 +6,7 @@ import { createPortal } from "react-dom";
|
|
|
6
6
|
import { cn } from "../cn.js";
|
|
7
7
|
import { useIsClient } from "./client.js";
|
|
8
8
|
import { useLatest } from "./latest.js";
|
|
9
|
-
import {
|
|
9
|
+
import { useNishContext } from "./provider.js";
|
|
10
10
|
import { focusables, layerHost, useMergedRef } from "./overlay-core.js";
|
|
11
11
|
import { useAnchoredPosition, floatingStyle, useDismiss, useReturnFocus } from "./overlay-position.js";
|
|
12
12
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -26,7 +26,7 @@ function Popover({
|
|
|
26
26
|
onKeyDown: userKeyDown,
|
|
27
27
|
...rest
|
|
28
28
|
}) {
|
|
29
|
-
const config =
|
|
29
|
+
const config = useNishContext();
|
|
30
30
|
const isClient = useIsClient();
|
|
31
31
|
const [panelRef, setPanelRef] = useMergedRef(ref);
|
|
32
32
|
const pos = useAnchoredPosition(anchor, panelRef, open, side, align);
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// src/components/portal.tsx
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { useIsClient } from "./client.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useNishContext } from "./provider.js";
|
|
7
7
|
function Portal({ children, container }) {
|
|
8
8
|
const isClient = useIsClient();
|
|
9
|
-
const config =
|
|
9
|
+
const config = useNishContext();
|
|
10
10
|
if (!isClient) return null;
|
|
11
11
|
const target = container ?? config.portalContainer ?? document.body;
|
|
12
12
|
return createPortal(children, target);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/components/progress.tsx
|
|
2
2
|
import { useId } from "react";
|
|
3
3
|
import { cn } from "../cn.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useStrings } from "./provider.js";
|
|
5
|
+
import { PROGRESS_STRINGS } from "./strings.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
var FILL = {
|
|
7
8
|
accent: "bg-th-accent",
|
|
@@ -27,7 +28,7 @@ function Progress({
|
|
|
27
28
|
"aria-labelledby": ariaLabelledBy,
|
|
28
29
|
...rest
|
|
29
30
|
}) {
|
|
30
|
-
const strings =
|
|
31
|
+
const strings = useStrings(PROGRESS_STRINGS);
|
|
31
32
|
const labelId = useId();
|
|
32
33
|
const indeterminate = value == null || Number.isNaN(value);
|
|
33
34
|
const clamped = indeterminate ? 0 : Math.min(Math.max(value, 0), max);
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { createContext, useContext, useMemo } from "react";
|
|
5
5
|
import { DEFAULT_STRINGS } from "./strings.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
var
|
|
8
|
-
var NishContext = /* @__PURE__ */ createContext(
|
|
7
|
+
var EMPTY = {};
|
|
8
|
+
var NishContext = /* @__PURE__ */ createContext({ strings: EMPTY });
|
|
9
9
|
function NishProvider({ strings, locale, dir, portalContainer, children }) {
|
|
10
10
|
const outer = useContext(NishContext);
|
|
11
11
|
const value = useMemo(
|
|
@@ -19,14 +19,43 @@ function NishProvider({ strings, locale, dir, portalContainer, children }) {
|
|
|
19
19
|
);
|
|
20
20
|
return /* @__PURE__ */ jsx(NishContext.Provider, { value, children });
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function useNishContext() {
|
|
23
23
|
return useContext(NishContext);
|
|
24
24
|
}
|
|
25
|
+
function pick(o, groups) {
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const key of Object.keys(o)) {
|
|
28
|
+
for (const g of groups) {
|
|
29
|
+
if (g && Object.hasOwn(g, key)) {
|
|
30
|
+
out[key] = o[key];
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function useStrings(a, b, c, d) {
|
|
38
|
+
const o = useContext(NishContext).strings;
|
|
39
|
+
return useMemo(
|
|
40
|
+
() => o === EMPTY && !b ? a : Object.assign({}, a, b, c, d, pick(o, [a, b, c, d])),
|
|
41
|
+
[a, b, c, d, o]
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function useNishConfig() {
|
|
45
|
+
const ctx = useContext(NishContext);
|
|
46
|
+
return useMemo(
|
|
47
|
+
() => ({ ...ctx, strings: ctx.strings === EMPTY ? DEFAULT_STRINGS : { ...DEFAULT_STRINGS, ...ctx.strings } }),
|
|
48
|
+
[ctx]
|
|
49
|
+
);
|
|
50
|
+
}
|
|
25
51
|
function useNishStrings() {
|
|
26
|
-
|
|
52
|
+
const o = useContext(NishContext).strings;
|
|
53
|
+
return useMemo(() => o === EMPTY ? DEFAULT_STRINGS : { ...DEFAULT_STRINGS, ...o }, [o]);
|
|
27
54
|
}
|
|
28
55
|
export {
|
|
29
56
|
NishProvider,
|
|
30
57
|
useNishConfig,
|
|
31
|
-
|
|
58
|
+
useNishContext,
|
|
59
|
+
useNishStrings,
|
|
60
|
+
useStrings
|
|
32
61
|
};
|