devnonla-ui 0.13.0 → 0.14.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/package.json +1 -1
- package/src/app/App.tsx +2 -2
- package/src/app/context.ts +1 -12
- package/src/avatar/avatar.css +107 -0
- package/src/button/Button.tsx +4 -4
- package/src/button/ButtonCopy.tsx +1 -1
- package/src/calendar/Calendar.tsx +1 -1
- package/src/card/Card.tsx +1 -1
- package/src/chat/message-ui/ChatError.tsx +1 -1
- package/src/chat/message-ui/ChatInput.tsx +5 -4
- package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +3 -3
- package/src/chat/tool-ui/CallAgentToolUI.tsx +2 -2
- package/src/chat/tool-ui/ChatToolCall.tsx +3 -3
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +2 -2
- package/src/chat/tool-ui/RunJsToolUI.tsx +1 -1
- package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
- package/src/chat/tool-ui/WebFetchToolUI.tsx +1 -1
- package/src/checkbox/Checkbox.tsx +2 -2
- package/src/codeblock/CodeBlock.tsx +1 -1
- package/src/colorpicker/ColorPicker.tsx +10 -8
- package/src/datepicker/DatePicker.tsx +3 -3
- package/src/desktop/DesktopHeader.tsx +2 -2
- package/src/desktop/DesktopStage.tsx +1 -1
- package/src/desktop/DesktopWindow.tsx +3 -3
- package/src/desktop/MeadowDesktop.tsx +2 -2
- package/src/drawer/Drawer.tsx +6 -2
- package/src/dropdown/menuClasses.ts +1 -1
- package/src/empty/Empty.tsx +1 -1
- package/src/form/variants/FieldRadio.tsx +1 -1
- package/src/form/variants/FieldRepeaterItem.tsx +1 -1
- package/src/index.ts +3 -3
- package/src/input/EditableInput.tsx +3 -2
- package/src/input/Input.tsx +15 -7
- package/src/lib/sizes.ts +6 -6
- package/src/lib/surface.ts +14 -4
- package/src/markdown-editor/MarkdownDiff.tsx +4 -4
- package/src/markdown-editor/MarkdownPreview.tsx +4 -4
- package/src/markdown-editor/MarkdownSource.tsx +1 -1
- package/src/markdown-editor/MarkdownTable.tsx +1 -1
- package/src/markdown-editor/MarkdownViewer.tsx +7 -7
- package/src/markdown-editor/MermaidBlock.tsx +1 -1
- package/src/markdown-editor/ReactCodeFrame.tsx +8 -4
- package/src/markdown-editor/markdownScale.ts +30 -25
- package/src/menu/Menu.tsx +1 -1
- package/src/message/message.tsx +18 -8
- package/src/modal/Modal.tsx +13 -7
- package/src/pagination/Pagination.tsx +3 -3
- package/src/popover/Popover.tsx +1 -1
- package/src/scroll/OverlayScroll.tsx +2 -2
- package/src/segmented/Segmented.tsx +1 -1
- package/src/select/Select.tsx +4 -4
- package/src/sidebar/Sidebar.tsx +35 -32
- package/src/skeleton/Skeleton.tsx +4 -4
- package/src/spin/Spin.tsx +14 -2
- package/src/splitter/Splitter.tsx +1 -1
- package/src/styles.css +166 -842
- package/src/table/Table.tsx +12 -12
- package/src/tabs/Tabs.tsx +3 -3
- package/src/tag/Tag.tsx +3 -3
- package/src/theme.ts +53 -147
- package/src/timepicker/TimePicker.tsx +2 -2
- package/src/typography/Typography.tsx +6 -6
package/src/table/Table.tsx
CHANGED
|
@@ -394,7 +394,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
394
394
|
setThumbInset((prev) => (prev === next ? prev : next));
|
|
395
395
|
}, [headSticky, showHeader, size, flexLayout]);
|
|
396
396
|
/** Opaque fill so a sticky header does not show body text, and every header matches. */
|
|
397
|
-
const headBg: CSSProperties = { backgroundColor: "var(--nonla-
|
|
397
|
+
const headBg: CSSProperties = { backgroundColor: "var(--nonla-fill)" };
|
|
398
398
|
|
|
399
399
|
const colStyle = (col: ColumnType<T>, key: string): CSSProperties => {
|
|
400
400
|
const measured = flexLayout?.cols[key];
|
|
@@ -406,7 +406,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
406
406
|
<div className={cn("relative w-full", className)}>
|
|
407
407
|
{titleNode != null ? <div className="mb-3 text-sm font-medium text-foreground">{titleNode}</div> : null}
|
|
408
408
|
|
|
409
|
-
<div className={cn(bordered && "overflow-hidden rounded-xl border border-
|
|
409
|
+
<div className={cn(bordered && "overflow-hidden rounded-xl border border-border-secondary")}>
|
|
410
410
|
<Spin spinning={Boolean(loading)}>
|
|
411
411
|
<div ref={containerRef} data-slot="table-container" className={cn("relative w-full", flexLayout ? "overflow-x-hidden" : "overflow-x-auto")} style={scroll?.x != null ? { overflowX: "auto" } : undefined}>
|
|
412
412
|
<TableBodyScroll y={scroll?.y} x={scroll?.x} scrollRef={scrollBodyRef} insetTop={thumbInset}>
|
|
@@ -421,10 +421,10 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
421
421
|
</colgroup>
|
|
422
422
|
) : null}
|
|
423
423
|
{showHeader ? (
|
|
424
|
-
<thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-
|
|
425
|
-
<tr data-slot="table-row" className="border-b border-
|
|
424
|
+
<thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-border-secondary", headSticky && "relative z-20")}>
|
|
425
|
+
<tr data-slot="table-row" className="border-b border-border-secondary transition-colors hover:bg-transparent">
|
|
426
426
|
{rowSelection ? (
|
|
427
|
-
<th data-slot="table-head" className={cn(sz.head, sz.check, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-
|
|
427
|
+
<th data-slot="table-head" className={cn(sz.head, sz.check, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border-secondary", bordered && "border-b border-border-secondary")} style={{ ...(selectionColWidth != null ? { width: selectionColWidth } : undefined), ...headBg }}>
|
|
428
428
|
<div className="flex items-center justify-center">
|
|
429
429
|
{rowSelection.type === "radio" ? null : (
|
|
430
430
|
<Checkbox
|
|
@@ -449,7 +449,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
449
449
|
<th
|
|
450
450
|
key={key}
|
|
451
451
|
data-slot="table-head"
|
|
452
|
-
className={cn(sz.head, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-
|
|
452
|
+
className={cn(sz.head, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border-secondary", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), bordered && "border-b border-border-secondary", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
|
|
453
453
|
style={{
|
|
454
454
|
...colStyle(col, key),
|
|
455
455
|
...headBg,
|
|
@@ -470,7 +470,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
470
470
|
|
|
471
471
|
<tbody data-slot="table-body" className={cn("[&_tr:last-child]:border-0", headSticky && "relative z-0")}>
|
|
472
472
|
{pageData.length === 0 ? (
|
|
473
|
-
<tr data-slot="table-row" className="border-b border-
|
|
473
|
+
<tr data-slot="table-row" className="border-b border-border-secondary">
|
|
474
474
|
<td data-slot="table-cell" colSpan={colCount} className={cn(sz.cell, "text-center align-middle")}>
|
|
475
475
|
{locale?.emptyText ?? <Empty description="No data" className="py-10" />}
|
|
476
476
|
</td>
|
|
@@ -489,7 +489,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
489
489
|
key={key}
|
|
490
490
|
data-slot="table-row"
|
|
491
491
|
data-state={selected ? "selected" : undefined}
|
|
492
|
-
className={cn("border-b border-
|
|
492
|
+
className={cn("border-b border-border-secondary transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", inSelectionMode && !rowDisabled && "cursor-pointer", rowProps?.className, extraClass)}
|
|
493
493
|
style={rowProps?.style}
|
|
494
494
|
onClick={inSelectionMode ? undefined : rowProps?.onClick}
|
|
495
495
|
onClickCapture={
|
|
@@ -506,7 +506,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
506
506
|
}
|
|
507
507
|
>
|
|
508
508
|
{rowSelection ? (
|
|
509
|
-
<td data-row-select data-slot="table-cell" className={cn(sz.cell, sz.check, "align-middle", headSticky && "border-b border-
|
|
509
|
+
<td data-row-select data-slot="table-cell" className={cn(sz.cell, sz.check, "align-middle", headSticky && "border-b border-border-secondary")} style={selectionColWidth != null ? { width: selectionColWidth } : undefined} onClick={(e) => e.stopPropagation()}>
|
|
510
510
|
<div className="flex items-center justify-center">
|
|
511
511
|
{rowSelection.type === "radio" ? (
|
|
512
512
|
<input type="radio" name="nonla-table-row-select" checked={selected} disabled={rowSelection.getCheckboxProps?.(record)?.disabled} aria-label="Select row" className="size-3.5 accent-foreground" onChange={() => emitSelection([key])} />
|
|
@@ -531,7 +531,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
531
531
|
<td
|
|
532
532
|
key={getColumnKey(col, i)}
|
|
533
533
|
data-slot="table-cell"
|
|
534
|
-
className={cn(sz.cell, "align-middle", headSticky && "border-b border-
|
|
534
|
+
className={cn(sz.cell, "align-middle", headSticky && "border-b border-border-secondary", alignClass(col.align), flexLayout && flexWeight(col) > 0 ? (col.ellipsis ? "max-w-0 truncate" : "min-w-0 whitespace-normal wrap-break-word") : col.ellipsis ? "max-w-0 truncate" : "whitespace-nowrap", col.className)}
|
|
535
535
|
style={colStyle(col, getColumnKey(col, i))}
|
|
536
536
|
title={col.ellipsis && (typeof content === "string" || typeof content === "number") ? String(content) : undefined}
|
|
537
537
|
>
|
|
@@ -546,7 +546,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
546
546
|
</tbody>
|
|
547
547
|
|
|
548
548
|
{footerNode != null ? (
|
|
549
|
-
<tfoot data-slot="table-footer" className="border-t border-
|
|
549
|
+
<tfoot data-slot="table-footer" className="border-t border-border-secondary bg-muted/50 font-medium [&>tr]:last:border-b-0">
|
|
550
550
|
<tr>
|
|
551
551
|
<td colSpan={colCount} className={cn(sz.cell, "align-middle text-muted-foreground")}>
|
|
552
552
|
{footerNode}
|
|
@@ -560,7 +560,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
|
|
|
560
560
|
</Spin>
|
|
561
561
|
|
|
562
562
|
{showPagination ? (
|
|
563
|
-
<div className={cn("flex flex-wrap items-center justify-between gap-3 px-3 py-2", bordered && "border-t border-
|
|
563
|
+
<div className={cn("flex flex-wrap items-center justify-between gap-3 px-3 py-2", bordered && "border-t border-border-secondary", pageConfig.className)}>
|
|
564
564
|
<div className="flex items-center gap-3">
|
|
565
565
|
{pageConfig.showSizeChanger !== false ? (
|
|
566
566
|
<Select
|
package/src/tabs/Tabs.tsx
CHANGED
|
@@ -203,12 +203,12 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
|
|
|
203
203
|
<div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-px bg-border" />
|
|
204
204
|
<div
|
|
205
205
|
ref={scrollerRef}
|
|
206
|
-
className="
|
|
206
|
+
className="relative overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden [&::-webkit-scrollbar]:h-0 [&::-webkit-scrollbar]:w-0"
|
|
207
207
|
style={mask ? { maskImage: mask, WebkitMaskImage: mask } : undefined}
|
|
208
208
|
onScroll={updateOverflow}
|
|
209
209
|
>
|
|
210
210
|
<div ref={rowRef} role="tablist" aria-label={ariaLabel} aria-orientation="horizontal" className="relative flex w-max gap-3" onKeyDown={onKeyDown}>
|
|
211
|
-
{ink ? <span aria-hidden className="
|
|
211
|
+
{ink ? <span aria-hidden className="pointer-events-none absolute bottom-0 left-0 z-1 h-0.5 rounded-t-xs bg-brand transition-[transform,width] duration-380 ease-[cubic-bezier(0.3,1.25,0.5,1)] motion-reduce:transition-none" style={{ width: ink.width, transform: `translateX(${ink.left}px)` }} /> : null}
|
|
212
212
|
{items.map((item) => {
|
|
213
213
|
const selected = item.key === active;
|
|
214
214
|
return (
|
|
@@ -227,7 +227,7 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
|
|
|
227
227
|
disabled={item.disabled}
|
|
228
228
|
className={cn(
|
|
229
229
|
"relative z-10 inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-normal text-tertiary-foreground transition-colors select-none",
|
|
230
|
-
"hover:text-foreground focus-visible:ring-
|
|
230
|
+
"hover:text-foreground focus-visible:ring-brand/55 focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset",
|
|
231
231
|
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
232
232
|
selected && "text-foreground",
|
|
233
233
|
)}
|
package/src/tag/Tag.tsx
CHANGED
|
@@ -43,7 +43,7 @@ const NAMED_VAR: Record<string, string> = {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const SOFT = "bg-[color-mix(in_oklab,var(--nonla-tag)_12%,transparent)] text-[color-mix(in_oklab,var(--nonla-tag)_72%,black)]";
|
|
46
|
-
const SOLID = "bg-(--nonla-tag) text-[var(--nonla-solid
|
|
46
|
+
const SOLID = "bg-(--nonla-tag) text-[var(--nonla-text-on-solid)]";
|
|
47
47
|
|
|
48
48
|
function resolveVariant(variant: TagProps["variant"]): TagVariant {
|
|
49
49
|
if (variant === "solid") return "solid";
|
|
@@ -79,7 +79,7 @@ export function Tag({
|
|
|
79
79
|
<span
|
|
80
80
|
className={cn(
|
|
81
81
|
"inline-flex h-5.5 max-w-full items-center gap-1.5 rounded-full px-2.5 text-[11px] font-medium tracking-[0.01em]",
|
|
82
|
-
isDefault && (solid ? "bg-foreground/10 text-
|
|
82
|
+
isDefault && (solid ? "bg-foreground/10 text-foreground" : "bg-muted text-muted-foreground"),
|
|
83
83
|
!isDefault && (solid ? SOLID : SOFT),
|
|
84
84
|
className,
|
|
85
85
|
)}
|
|
@@ -87,7 +87,7 @@ export function Tag({
|
|
|
87
87
|
>
|
|
88
88
|
{showDot ? (
|
|
89
89
|
<span
|
|
90
|
-
className={cn("size-1.5 shrink-0 rounded-full", isDefault ? "bg-(--nonla-
|
|
90
|
+
className={cn("size-1.5 shrink-0 rounded-full", isDefault ? "bg-(--nonla-text-secondary)" : "bg-(--nonla-tag)")}
|
|
91
91
|
aria-hidden
|
|
92
92
|
/>
|
|
93
93
|
) : null}
|
package/src/theme.ts
CHANGED
|
@@ -1,74 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Defaults live in `styles.css` on `:root` / `.nonla-ui`.
|
|
5
|
-
* Consumers retheme by overriding `--nonla-*` in CSS. Aliases follow those knobs.
|
|
6
|
-
* `--brand-50`…`--brand-800` follow `--nonla-brand` (500 = the knob).
|
|
7
|
-
* Color mode is `light` | `dark` on `<html>` (`setColorMode`, `<ThemeToggle>`). Dark is the default.
|
|
8
|
-
* `<ThemeSwitcher>` also stores `system`, which follows the OS and still paints `light` or `dark`.
|
|
2
|
+
* Paint `light` or `dark` on `<html>`. Dark is the default.
|
|
3
|
+
* The stored choice may be `system`, which follows the OS and still paints one of those two.
|
|
9
4
|
*/
|
|
10
5
|
|
|
11
|
-
export const NONLA_THEME_KEYS = {
|
|
12
|
-
bg: "--nonla-bg",
|
|
13
|
-
fg: "--nonla-fg",
|
|
14
|
-
fgMuted: "--nonla-fg-muted",
|
|
15
|
-
fgTertiary: "--nonla-fg-tertiary",
|
|
16
|
-
fgQuaternary: "--nonla-fg-quaternary",
|
|
17
|
-
brand: "--nonla-brand",
|
|
18
|
-
solidFg: "--nonla-solid-fg",
|
|
19
|
-
danger: "--nonla-danger",
|
|
20
|
-
success: "--nonla-success",
|
|
21
|
-
warn: "--nonla-warn",
|
|
22
|
-
link: "--nonla-link",
|
|
23
|
-
radius: "--nonla-radius",
|
|
24
|
-
height: "--nonla-height",
|
|
25
|
-
heightSm: "--nonla-height-sm",
|
|
26
|
-
heightLg: "--nonla-height-lg",
|
|
27
|
-
ink: "--nonla-ink",
|
|
28
|
-
sidebar: "--nonla-sidebar",
|
|
29
|
-
surface: "--nonla-surface",
|
|
30
|
-
elevated: "--nonla-elevated",
|
|
31
|
-
chip: "--nonla-chip",
|
|
32
|
-
chipHover: "--nonla-chip-hover",
|
|
33
|
-
border: "--nonla-border",
|
|
34
|
-
borderInput: "--nonla-input",
|
|
35
|
-
composer: "--nonla-composer",
|
|
36
|
-
chatBg: "--nonla-chat-bg",
|
|
37
|
-
meadow: "--nonla-meadow",
|
|
38
|
-
glass: "--nonla-glass",
|
|
39
|
-
glassBar: "--nonla-glass-bar",
|
|
40
|
-
glassMenu: "--nonla-glass-menu",
|
|
41
|
-
glassBorder: "--nonla-glass-border",
|
|
42
|
-
glassHighlight: "--nonla-glass-highlight",
|
|
43
|
-
inkHover: "--nonla-ink-hover",
|
|
44
|
-
inkActive: "--nonla-ink-active",
|
|
45
|
-
inkLine: "--nonla-ink-line",
|
|
46
|
-
desktopBarHeight: "--nonla-desktop-bar-height",
|
|
47
|
-
windowHeader: "--nonla-window-header",
|
|
48
|
-
zBase: "--nonla-z-base",
|
|
49
|
-
zDesktop: "--nonla-z-desktop",
|
|
50
|
-
zWindow: "--nonla-z-window",
|
|
51
|
-
zHeader: "--nonla-z-header",
|
|
52
|
-
zPopupBase: "--nonla-z-popup-base",
|
|
53
|
-
} as const;
|
|
54
|
-
|
|
55
|
-
export type NonlaThemeKnobName = keyof typeof NONLA_THEME_KEYS;
|
|
56
|
-
export type NonlaThemeKnob = (typeof NONLA_THEME_KEYS)[NonlaThemeKnobName];
|
|
57
|
-
|
|
58
|
-
export const NONLA_THEME_KNOBS = Object.values(NONLA_THEME_KEYS);
|
|
59
|
-
|
|
60
|
-
export type NonlaTokenSnapshot = { [K in NonlaThemeKnobName]: string };
|
|
61
|
-
|
|
62
|
-
/** Read computed `--nonla-*` knobs (`getDesignToken`). */
|
|
63
|
-
export function getDesignToken(target?: HTMLElement): NonlaTokenSnapshot {
|
|
64
|
-
const el = target ?? (typeof document === "undefined" ? null : document.documentElement);
|
|
65
|
-
const token = {} as NonlaTokenSnapshot;
|
|
66
|
-
for (const name of Object.keys(NONLA_THEME_KEYS) as NonlaThemeKnobName[]) {
|
|
67
|
-
token[name] = el ? getComputedStyle(el).getPropertyValue(NONLA_THEME_KEYS[name]).trim() : "";
|
|
68
|
-
}
|
|
69
|
-
return token;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
6
|
export type NonlaColorMode = "light" | "dark";
|
|
73
7
|
|
|
74
8
|
/** Stored choice. `system` follows the OS and still applies `light` or `dark` on `<html>`. */
|
|
@@ -77,117 +11,90 @@ export type NonlaColorPreference = NonlaColorMode | "system";
|
|
|
77
11
|
/** `localStorage` key written by `setColorMode` / `setColorPreference`. */
|
|
78
12
|
export const NONLA_COLOR_MODE_KEY = "nonla-color-mode";
|
|
79
13
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let colorMode: NonlaColorMode = "dark";
|
|
85
|
-
let colorPreference: NonlaColorPreference = "dark";
|
|
86
|
-
let colorModeReady = false;
|
|
14
|
+
const listeners = new Set<() => void>();
|
|
15
|
+
let mode: NonlaColorMode = "dark";
|
|
16
|
+
let preference: NonlaColorPreference = "dark";
|
|
17
|
+
let ready = false;
|
|
87
18
|
let schemeQuery: MediaQueryList | null = null;
|
|
88
19
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function getColorPreference(): NonlaColorPreference {
|
|
94
|
-
return colorPreference;
|
|
20
|
+
function notify() {
|
|
21
|
+
for (const listener of listeners) listener();
|
|
95
22
|
}
|
|
96
23
|
|
|
97
|
-
|
|
98
|
-
|
|
24
|
+
function subscribe(listener: () => void) {
|
|
25
|
+
listeners.add(listener);
|
|
99
26
|
return () => {
|
|
100
|
-
|
|
27
|
+
listeners.delete(listener);
|
|
101
28
|
};
|
|
102
29
|
}
|
|
103
30
|
|
|
104
|
-
export
|
|
105
|
-
|
|
106
|
-
return () => {
|
|
107
|
-
preferenceListeners.delete(listener);
|
|
108
|
-
};
|
|
109
|
-
}
|
|
31
|
+
export const subscribeColorMode = subscribe;
|
|
32
|
+
export const subscribeColorPreference = subscribe;
|
|
110
33
|
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function notifyColorPreference() {
|
|
116
|
-
for (const listener of preferenceListeners) listener();
|
|
34
|
+
export function getColorMode(): NonlaColorMode {
|
|
35
|
+
return mode;
|
|
117
36
|
}
|
|
118
37
|
|
|
119
|
-
function
|
|
120
|
-
return
|
|
38
|
+
export function getColorPreference(): NonlaColorPreference {
|
|
39
|
+
return preference;
|
|
121
40
|
}
|
|
122
41
|
|
|
123
|
-
function
|
|
42
|
+
function readStored(): NonlaColorPreference | null {
|
|
124
43
|
try {
|
|
125
44
|
// Sandboxed iframes throw on the property access itself, before getItem.
|
|
126
45
|
const value = localStorage.getItem(NONLA_COLOR_MODE_KEY);
|
|
127
|
-
return
|
|
46
|
+
return value === "light" || value === "dark" || value === "system" ? value : null;
|
|
128
47
|
} catch {
|
|
129
48
|
return null;
|
|
130
49
|
}
|
|
131
50
|
}
|
|
132
51
|
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
52
|
+
function writeStored(next: NonlaColorPreference) {
|
|
53
|
+
try {
|
|
54
|
+
localStorage.setItem(NONLA_COLOR_MODE_KEY, next);
|
|
55
|
+
} catch {
|
|
56
|
+
/* private mode or sandboxed iframe */
|
|
57
|
+
}
|
|
136
58
|
}
|
|
137
59
|
|
|
138
|
-
function
|
|
139
|
-
|
|
60
|
+
function systemMode(): NonlaColorMode {
|
|
61
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "dark";
|
|
62
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
140
63
|
}
|
|
141
64
|
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
const next = systemColorMode();
|
|
145
|
-
if (typeof document === "undefined") {
|
|
146
|
-
colorMode = next;
|
|
147
|
-
notifyColorMode();
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
applyColorMode(next);
|
|
65
|
+
function resolved(next: NonlaColorPreference): NonlaColorMode {
|
|
66
|
+
return next === "system" ? systemMode() : next;
|
|
151
67
|
}
|
|
152
68
|
|
|
153
|
-
function
|
|
69
|
+
function watchSystem() {
|
|
154
70
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function" || schemeQuery) return;
|
|
155
|
-
schemeQuery = window.matchMedia(
|
|
156
|
-
schemeQuery.addEventListener("change",
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
function rememberPreference(next: NonlaColorPreference) {
|
|
160
|
-
try {
|
|
161
|
-
localStorage.setItem(NONLA_COLOR_MODE_KEY, next);
|
|
162
|
-
} catch {
|
|
163
|
-
/* private mode */
|
|
164
|
-
}
|
|
71
|
+
schemeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
72
|
+
schemeQuery.addEventListener("change", () => {
|
|
73
|
+
if (preference === "system") applyColorMode(systemMode());
|
|
74
|
+
});
|
|
165
75
|
}
|
|
166
76
|
|
|
167
77
|
/** Set `light` or `dark` on `target` (default `<html>`) so portals inherit the palette. */
|
|
168
78
|
export function applyColorMode(next: NonlaColorMode, target: HTMLElement = document.documentElement) {
|
|
169
|
-
|
|
79
|
+
mode = next;
|
|
170
80
|
target.classList.toggle("light", next === "light");
|
|
171
81
|
target.classList.toggle("dark", next === "dark");
|
|
172
82
|
target.style.colorScheme = next;
|
|
173
|
-
|
|
83
|
+
notify();
|
|
174
84
|
}
|
|
175
85
|
|
|
176
86
|
/** Switch the stored choice. `system` follows the OS and still paints `light` or `dark`. */
|
|
177
87
|
export function setColorPreference(next: NonlaColorPreference, target?: HTMLElement) {
|
|
178
|
-
|
|
179
|
-
if (next === "system")
|
|
180
|
-
const resolved = resolvedMode(next);
|
|
88
|
+
preference = next;
|
|
89
|
+
if (next === "system") watchSystem();
|
|
181
90
|
if (typeof document === "undefined") {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
notifyColorPreference();
|
|
91
|
+
mode = resolved(next);
|
|
92
|
+
notify();
|
|
185
93
|
return;
|
|
186
94
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
notifyColorPreference();
|
|
95
|
+
ready = true;
|
|
96
|
+
writeStored(next);
|
|
97
|
+
applyColorMode(resolved(next), target);
|
|
191
98
|
}
|
|
192
99
|
|
|
193
100
|
/** Switch mode and remember it. */
|
|
@@ -197,14 +104,13 @@ export function setColorMode(next: NonlaColorMode, target?: HTMLElement) {
|
|
|
197
104
|
|
|
198
105
|
/** Apply the saved mode once. Falls back to dark. A stored `system` choice follows the OS. */
|
|
199
106
|
export function initColorMode(target?: HTMLElement): NonlaColorMode {
|
|
200
|
-
if (typeof document === "undefined") return
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const fromClass =
|
|
204
|
-
const next =
|
|
205
|
-
|
|
206
|
-
if (next === "system")
|
|
207
|
-
applyColorMode(
|
|
208
|
-
|
|
209
|
-
return colorMode;
|
|
107
|
+
if (typeof document === "undefined" || ready) return mode;
|
|
108
|
+
ready = true;
|
|
109
|
+
const root = document.documentElement;
|
|
110
|
+
const fromClass = root.classList.contains("light") ? "light" : root.classList.contains("dark") ? "dark" : null;
|
|
111
|
+
const next = readStored() ?? fromClass ?? "dark";
|
|
112
|
+
preference = next;
|
|
113
|
+
if (next === "system") watchSystem();
|
|
114
|
+
applyColorMode(resolved(next), target);
|
|
115
|
+
return mode;
|
|
210
116
|
}
|
|
@@ -632,7 +632,7 @@ export const TimePicker = forwardRef<HTMLInputElement, TimePickerProps>(function
|
|
|
632
632
|
onKeyDown={handleKeyDown}
|
|
633
633
|
onKeyUp={(e) => syncPartFromCaret(e.currentTarget)}
|
|
634
634
|
onClick={(e) => syncPartFromCaret(e.currentTarget)}
|
|
635
|
-
className="min-w-0 flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-
|
|
635
|
+
className="min-w-0 flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-quaternary-foreground outline-none disabled:cursor-not-allowed"
|
|
636
636
|
style={{ fontSize: fieldStyle.fontSize, lineHeight: fieldStyle.lineHeight }}
|
|
637
637
|
/>
|
|
638
638
|
{allowClear && selected && !disabled ? (
|
|
@@ -745,7 +745,7 @@ export const TimePicker = forwardRef<HTMLInputElement, TimePickerProps>(function
|
|
|
745
745
|
</div>
|
|
746
746
|
)}
|
|
747
747
|
</div>
|
|
748
|
-
<PopoverPrimitive.Arrow width={12} height={7} className="fill-
|
|
748
|
+
<PopoverPrimitive.Arrow width={12} height={7} className="fill-card drop-shadow-[0_1px_0_var(--border)]" />
|
|
749
749
|
</PopoverPrimitive.Content>
|
|
750
750
|
</PopoverPrimitive.Portal>
|
|
751
751
|
</PopoverPrimitive.Root>
|
|
@@ -20,10 +20,10 @@ type Decorations = {
|
|
|
20
20
|
|
|
21
21
|
/** Same ink as MarkdownViewer. Status tones sit on top of that. */
|
|
22
22
|
const INK = {
|
|
23
|
-
title: "var(--
|
|
24
|
-
body: "var(--
|
|
25
|
-
secondary: "var(--nonla-
|
|
26
|
-
quiet: "var(--nonla-
|
|
23
|
+
title: "var(--nonla-text-main)",
|
|
24
|
+
body: "var(--nonla-text-main)",
|
|
25
|
+
secondary: "var(--nonla-text-tertiary)",
|
|
26
|
+
quiet: "var(--nonla-text-quaternary)",
|
|
27
27
|
success: "var(--nonla-success)",
|
|
28
28
|
warning: "var(--nonla-warn)",
|
|
29
29
|
danger: "var(--nonla-danger)",
|
|
@@ -40,10 +40,10 @@ const TITLE_TAG = {
|
|
|
40
40
|
6: "h6",
|
|
41
41
|
} as const;
|
|
42
42
|
|
|
43
|
-
/** Same scale as MarkdownViewer `docs`. Body
|
|
43
|
+
/** Same scale as MarkdownViewer `docs`. Body size is `--nonla-base-text-size`. Inline code reads `--md-inline-size` (14px). */
|
|
44
44
|
const BODY = markdownBodyClass;
|
|
45
45
|
|
|
46
|
-
const INLINE_CODE = "nonla-inline-code";
|
|
46
|
+
const INLINE_CODE = "nonla-inline-code rounded-sm bg-muted px-[0.35em] py-[0.12em] align-baseline font-mono text-(length:--md-inline-size,14px) leading-none whitespace-nowrap [box-decoration-break:clone] [-webkit-box-decoration-break:clone]";
|
|
47
47
|
|
|
48
48
|
const TITLE_SPACE = "nonla-typo";
|
|
49
49
|
|