@kahitsan/ksui 0.50.0 → 0.51.0-solid2.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 -0
- package/package.json +8 -6
- package/src/components/base/AccountAvatar.tsx +1 -1
- package/src/components/base/ActionMenu.tsx +7 -5
- package/src/components/base/AddAttachmentTile.tsx +6 -6
- package/src/components/base/BadgeSelect.tsx +11 -9
- package/src/components/base/Button.test.tsx +23 -0
- package/src/components/base/Button.tsx +35 -41
- package/src/components/base/CameraCapture.tsx +5 -2
- package/src/components/base/CopyButton.tsx +2 -1
- package/src/components/base/DataTable.tsx +89 -112
- package/src/components/base/DatePicker.tsx +15 -17
- package/src/components/base/DateTile.tsx +14 -12
- package/src/components/base/Dropdown.tsx +6 -5
- package/src/components/base/ExistingAttachmentTile.test.tsx +3 -3
- package/src/components/base/ExistingAttachmentTile.tsx +6 -4
- package/src/components/base/EyebrowBadge.tsx +2 -1
- package/src/components/base/FormErrorBanner.tsx +2 -1
- package/src/components/base/FormField.tsx +1 -1
- package/src/components/base/ImageCropper.tsx +3 -3
- package/src/components/base/ImageViewer.test.tsx +2 -0
- package/src/components/base/ImageViewer.tsx +4 -3
- package/src/components/base/KpiCard.tsx +3 -2
- package/src/components/base/Modal.test.tsx +3 -2
- package/src/components/base/Modal.tsx +11 -12
- package/src/components/base/ModalHeader.tsx +2 -1
- package/src/components/base/MonthCalendar.tsx +2 -1
- package/src/components/base/MultiSelectGroup.tsx +7 -5
- package/src/components/base/ProgressBar.tsx +8 -17
- package/src/components/base/RadioCardGroup.tsx +14 -12
- package/src/components/base/SectionHeading.tsx +2 -1
- package/src/components/base/SegmentedFilter.tsx +10 -8
- package/src/components/base/SocialLinksBar.tsx +2 -1
- package/src/components/base/StatusIndicator.tsx +2 -1
- package/src/components/base/StatusPill.tsx +1 -1
- package/src/components/base/TagPill.tsx +1 -1
- package/src/components/base/ThemeToggle.tsx +5 -11
- package/src/components/base/Tooltip.tsx +2 -1
- package/src/components/composite/AccountRadioPicker.tsx +14 -11
- package/src/components/composite/ComboBox.tsx +18 -13
- package/src/components/composite/CustomRenderer.tsx +1 -1
- package/src/components/composite/FileField.tsx +6 -3
- package/src/components/composite/FlowGraph.tsx +15 -12
- package/src/components/composite/FlowRunner.test.tsx +2 -0
- package/src/components/composite/FlowRunner.tsx +2 -1
- package/src/components/composite/FormActions.tsx +1 -1
- package/src/components/composite/FormAdvancedSection.tsx +13 -13
- package/src/components/composite/LiveTimer.tsx +8 -14
- package/src/components/composite/MarkdownNotes.tsx +2 -1
- package/src/components/composite/MentionTextarea.tsx +31 -22
- package/src/components/composite/MultiPeriodPicker.tsx +11 -9
- package/src/components/composite/NotFound.tsx +4 -15
- package/src/components/composite/PaymentAccountPicker.tsx +19 -24
- package/src/components/composite/SalesBodyEditor.tsx +10 -7
- package/src/components/composite/SearchableSelect.tsx +14 -13
- package/src/components/composite/SecretReveal.tsx +2 -2
- package/src/components/composite/TransactionForm.tsx +52 -42
- package/src/components/composite/TransferAccountsPicker.tsx +11 -10
- package/src/components/composite/TransferFeeChip.tsx +7 -6
- package/src/components/composite/VoucherPicker.test.tsx +55 -48
- package/src/components/composite/VoucherPicker.tsx +36 -27
- package/src/components/composite/picker-engine.ts +20 -14
- package/src/components/composite/resource/ResourcePage.test.tsx +1 -1
- package/src/components/composite/resource/ResourcePage.tsx +21 -7
- package/src/components/composite/resource/cells.tsx +1 -1
- package/src/icons/README.md +1 -1
- package/src/icons/create-artwork-icon.test.tsx +4 -1
- package/src/icons/create-artwork-icon.tsx +10 -24
- package/src/utils/account-icons.ts +2 -1
- package/src/utils/accounts-index.tsx +8 -5
- package/src/utils/aria.ts +13 -0
- package/src/utils/confirm.tsx +1 -1
- package/src/utils/dom.ts +7 -6
- package/src/utils/fetch-resource.ts +59 -0
- package/src/utils/highlight.tsx +1 -1
- package/src/utils/modal-layer.ts +3 -3
- package/src/utils/object-url-resource.ts +11 -8
- package/src/utils/top-layer.ts +9 -8
|
@@ -22,13 +22,12 @@ import {
|
|
|
22
22
|
createSignal,
|
|
23
23
|
createMemo,
|
|
24
24
|
createEffect,
|
|
25
|
-
on,
|
|
26
25
|
For,
|
|
27
26
|
Show,
|
|
28
|
-
|
|
27
|
+
onSettled,
|
|
29
28
|
onCleanup,
|
|
30
29
|
} from "solid-js";
|
|
31
|
-
import { Portal } from "
|
|
30
|
+
import { Portal } from "@solidjs/web";
|
|
32
31
|
import Calendar from "../../icons/calendar";
|
|
33
32
|
import ChevronLeft from "../../icons/chevron-left";
|
|
34
33
|
import ChevronRight from "../../icons/chevron-right";
|
|
@@ -45,6 +44,7 @@ import {
|
|
|
45
44
|
import { injectCSS } from "../../utils/inject-css";
|
|
46
45
|
import { useTopLayer } from "../../utils/top-layer";
|
|
47
46
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
47
|
+
import { ariaBool, ariaTri } from "../../utils/aria";
|
|
48
48
|
|
|
49
49
|
// ---------------------------------------------------------------------------
|
|
50
50
|
// Injected CSS
|
|
@@ -611,11 +611,9 @@ export default function DatePicker(props: DatePickerProps) {
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
createEffect(
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}),
|
|
618
|
-
);
|
|
614
|
+
createEffect(time, (t) => {
|
|
615
|
+
if (t) setTimeInput(formatTimeDisplay(t));
|
|
616
|
+
});
|
|
619
617
|
|
|
620
618
|
// ── Click outside ──────────────────────────────────────────────────────────
|
|
621
619
|
|
|
@@ -631,9 +629,9 @@ export default function DatePicker(props: DatePickerProps) {
|
|
|
631
629
|
}
|
|
632
630
|
}
|
|
633
631
|
|
|
634
|
-
|
|
632
|
+
onSettled(() => {
|
|
635
633
|
document.addEventListener("mousedown", handleClickOutside);
|
|
636
|
-
|
|
634
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
637
635
|
});
|
|
638
636
|
|
|
639
637
|
// ── Reposition on scroll / resize ──────────────────────────────────────────
|
|
@@ -648,14 +646,14 @@ export default function DatePicker(props: DatePickerProps) {
|
|
|
648
646
|
});
|
|
649
647
|
}
|
|
650
648
|
|
|
651
|
-
createEffect(() => {
|
|
652
|
-
if (!
|
|
649
|
+
createEffect(open, (isOpen) => {
|
|
650
|
+
if (!isOpen) return;
|
|
653
651
|
window.addEventListener("scroll", reposition, { passive: true, capture: true });
|
|
654
652
|
window.addEventListener("resize", reposition);
|
|
655
|
-
|
|
653
|
+
return () => {
|
|
656
654
|
window.removeEventListener("scroll", reposition, { capture: true } as EventListenerOptions);
|
|
657
655
|
window.removeEventListener("resize", reposition);
|
|
658
|
-
}
|
|
656
|
+
};
|
|
659
657
|
});
|
|
660
658
|
|
|
661
659
|
// ── Display value ──────────────────────────────────────────────────────────
|
|
@@ -728,7 +726,7 @@ export default function DatePicker(props: DatePickerProps) {
|
|
|
728
726
|
type="button"
|
|
729
727
|
aria-label={props.ariaLabel}
|
|
730
728
|
aria-haspopup="dialog"
|
|
731
|
-
aria-expanded={open()}
|
|
729
|
+
aria-expanded={ariaBool(open())}
|
|
732
730
|
disabled={props.disabled}
|
|
733
731
|
class={
|
|
734
732
|
props.triggerClass ??
|
|
@@ -753,7 +751,7 @@ export default function DatePicker(props: DatePickerProps) {
|
|
|
753
751
|
<div
|
|
754
752
|
ref={(el) => {
|
|
755
753
|
popoverPanelRef = el;
|
|
756
|
-
|
|
754
|
+
useTopLayer(el);
|
|
757
755
|
}}
|
|
758
756
|
data-testid="datepicker-popover"
|
|
759
757
|
class="ksui-datepicker-popover"
|
|
@@ -942,7 +940,7 @@ export default function DatePicker(props: DatePickerProps) {
|
|
|
942
940
|
type="button"
|
|
943
941
|
role="switch"
|
|
944
942
|
aria-label="End date"
|
|
945
|
-
aria-checked={endActive()}
|
|
943
|
+
aria-checked={ariaTri(endActive())}
|
|
946
944
|
data-testid="datepicker-end-date-toggle"
|
|
947
945
|
onClick={() => {
|
|
948
946
|
const next = !endActive();
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
// static, read-only cell that renders dimmed so a row can show which tiles are
|
|
14
14
|
// "in" vs "out" of a selection at a glance.
|
|
15
15
|
|
|
16
|
-
import { Show
|
|
17
|
-
import {
|
|
16
|
+
import { Show } from "solid-js";
|
|
17
|
+
import type { JSX } from "@solidjs/web";
|
|
18
|
+
import { Dynamic } from "@solidjs/web";
|
|
19
|
+
import { ariaTri } from "../../utils/aria";
|
|
18
20
|
|
|
19
21
|
export interface DateTileProps {
|
|
20
22
|
/** The big primary value — typically a day-of-month number, but any short
|
|
@@ -42,14 +44,14 @@ export default function DateTile(props: DateTileProps): JSX.Element {
|
|
|
42
44
|
component={interactive() ? "button" : "div"}
|
|
43
45
|
type={interactive() ? "button" : undefined}
|
|
44
46
|
onClick={props.onToggle}
|
|
45
|
-
aria-pressed={interactive() ? on() : undefined}
|
|
47
|
+
aria-pressed={ariaTri(interactive() ? on() : undefined)}
|
|
46
48
|
data-testid={interactive() ? props.testId : undefined}
|
|
47
49
|
style={{ width: "60px", height: "68px", flex: "0 0 auto" }}
|
|
48
|
-
class={`${interactive() ? "cursor-pointer" : ""} flex flex-col rounded-md overflow-hidden border transition-colors
|
|
49
|
-
classList={{
|
|
50
|
+
class={[`${interactive() ? "cursor-pointer" : ""} flex flex-col rounded-md overflow-hidden border transition-colors`, {
|
|
50
51
|
"border-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_25%,transparent)] bg-[color-mix(in_srgb,var(--ks-surface-raised,#1a1a1a)_40%,transparent)]": on(),
|
|
51
52
|
"border-[color-mix(in_srgb,var(--ks-border,rgba(39,39,42,0.5))_60%,transparent)] bg-[color-mix(in_srgb,var(--ks-surface,#0f0f0f)_40%,transparent)] opacity-50 hover:opacity-80": !on(),
|
|
52
|
-
}}
|
|
53
|
+
}]}
|
|
54
|
+
|
|
53
55
|
>
|
|
54
56
|
<div
|
|
55
57
|
style={{ height: "18px" }}
|
|
@@ -59,21 +61,21 @@ export default function DateTile(props: DateTileProps): JSX.Element {
|
|
|
59
61
|
</div>
|
|
60
62
|
<div class="flex-1 flex flex-col items-center justify-center">
|
|
61
63
|
<div
|
|
62
|
-
class="text-xl font-semibold leading-none tabular-nums"
|
|
63
|
-
classList={{
|
|
64
|
+
class={["text-xl font-semibold leading-none tabular-nums", {
|
|
64
65
|
"text-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_90%,transparent)]": on(),
|
|
65
66
|
"text-[var(--ks-fg-subtle,#71717a)]": !on(),
|
|
66
|
-
}}
|
|
67
|
+
}]}
|
|
68
|
+
|
|
67
69
|
>
|
|
68
70
|
{props.value}
|
|
69
71
|
</div>
|
|
70
72
|
<Show when={props.subLabel != null && props.subLabel !== ""}>
|
|
71
73
|
<div
|
|
72
|
-
class="text-[9px] mt-0.5 tabular-nums"
|
|
73
|
-
classList={{
|
|
74
|
+
class={["text-[9px] mt-0.5 tabular-nums", {
|
|
74
75
|
"text-[var(--ks-fg-subtle,#71717a)]": on(),
|
|
75
76
|
"text-[var(--ks-border-strong,#3f3f46)]": !on(),
|
|
76
|
-
}}
|
|
77
|
+
}]}
|
|
78
|
+
|
|
77
79
|
>
|
|
78
80
|
{props.subLabel}
|
|
79
81
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createSignal, For, onCleanup,
|
|
2
|
-
import {
|
|
1
|
+
import { createSignal, For, onCleanup, onSettled, Show, type Component } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { Dynamic } from "@solidjs/web";
|
|
3
4
|
import ChevronDown from "../../icons/chevron-down";
|
|
4
5
|
|
|
5
6
|
/** A owned icons icon component (or any component taking size/class). */
|
|
@@ -67,13 +68,13 @@ function statusColor(status?: DropdownItemStatus): string {
|
|
|
67
68
|
// Presentational only and domain-free — no baked-in copy or business literals.
|
|
68
69
|
export default function Dropdown(props: DropdownProps): JSX.Element {
|
|
69
70
|
const [isOpen, setIsOpen] = createSignal(false);
|
|
70
|
-
const [selectedItem, setSelectedItem] = createSignal<DropdownItem | undefined>(
|
|
71
|
+
const [selectedItem, setSelectedItem] = createSignal<DropdownItem | undefined>(() =>
|
|
71
72
|
props.items.find((item) => item.id === props.value),
|
|
72
73
|
);
|
|
73
74
|
|
|
74
75
|
const currentSelection = () => selectedItem() ?? props.items.find((i) => i.id === props.value) ?? props.items[0];
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
onSettled(() => {
|
|
77
78
|
const handleClickOutside = (e: MouseEvent) => {
|
|
78
79
|
const target = e.target as Element | null;
|
|
79
80
|
if (!target?.closest("[data-dropdown-container]")) {
|
|
@@ -81,7 +82,7 @@ export default function Dropdown(props: DropdownProps): JSX.Element {
|
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
document.addEventListener("click", handleClickOutside);
|
|
84
|
-
|
|
85
|
+
return () => document.removeEventListener("click", handleClickOutside);
|
|
85
86
|
});
|
|
86
87
|
|
|
87
88
|
const handleSelect = (item: DropdownItem) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { cleanup, render, screen } from "@solidjs/testing-library";
|
|
3
|
-
import {
|
|
3
|
+
import { Loading } from "solid-js";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
import ExistingAttachmentTile from "./ExistingAttachmentTile";
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ describe("ExistingAttachmentTile", () => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
render(() => (
|
|
31
|
-
<
|
|
31
|
+
<Loading fallback={<p>Modal fallback</p>}>
|
|
32
32
|
<div data-testid="modal-shell">
|
|
33
33
|
<ExistingAttachmentTile
|
|
34
34
|
attachment={{
|
|
@@ -41,7 +41,7 @@ describe("ExistingAttachmentTile", () => {
|
|
|
41
41
|
testId="attachment"
|
|
42
42
|
/>
|
|
43
43
|
</div>
|
|
44
|
-
</
|
|
44
|
+
</Loading>
|
|
45
45
|
));
|
|
46
46
|
|
|
47
47
|
expect(screen.getByTestId("modal-shell")).toBeTruthy();
|
|
@@ -49,8 +49,9 @@ export default function ExistingAttachmentTile(props: Props) {
|
|
|
49
49
|
if (currentUrl) URL.revokeObjectURL(currentUrl);
|
|
50
50
|
currentUrl = null;
|
|
51
51
|
};
|
|
52
|
-
createEffect(
|
|
53
|
-
|
|
52
|
+
createEffect(
|
|
53
|
+
() => ({ href: props.rawHref ?? null, init: props.rawInit }),
|
|
54
|
+
({ href, init }) => {
|
|
54
55
|
const id = ++requestId;
|
|
55
56
|
revokeUrl();
|
|
56
57
|
setBlob(null);
|
|
@@ -59,7 +60,7 @@ export default function ExistingAttachmentTile(props: Props) {
|
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
62
|
setBlobLoading(true);
|
|
62
|
-
void fetch(href, { credentials: "include", ...
|
|
63
|
+
void fetch(href, { credentials: "include", ...init })
|
|
63
64
|
.then(async (res) => (res.ok ? URL.createObjectURL(await res.blob()) : null))
|
|
64
65
|
.then((url) => {
|
|
65
66
|
if (id !== requestId) {
|
|
@@ -75,7 +76,8 @@ export default function ExistingAttachmentTile(props: Props) {
|
|
|
75
76
|
.finally(() => {
|
|
76
77
|
if (id === requestId) setBlobLoading(false);
|
|
77
78
|
});
|
|
78
|
-
}
|
|
79
|
+
},
|
|
80
|
+
);
|
|
79
81
|
onCleanup(() => {
|
|
80
82
|
requestId++;
|
|
81
83
|
revokeUrl();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// remote UI atoms; behavior is unchanged.
|
|
5
5
|
|
|
6
6
|
import { Show } from "solid-js";
|
|
7
|
-
import type { JSX } from "
|
|
7
|
+
import type { JSX } from "@solidjs/web";
|
|
8
8
|
|
|
9
9
|
export default function FormField(props: { label: string; id?: string; children: JSX.Element; hint?: string }) {
|
|
10
10
|
return (
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// The widget is self-contained: it uses ksui's own Modal + Button, solid-js,
|
|
8
8
|
// and a single lucide icon.
|
|
9
9
|
|
|
10
|
-
import { createSignal, onCleanup,
|
|
10
|
+
import { createSignal, onCleanup, onSettled, Show } from "solid-js";
|
|
11
11
|
import Modal from "./Modal";
|
|
12
12
|
import Button from "./Button";
|
|
13
13
|
import X from "../../icons/x";
|
|
@@ -48,7 +48,7 @@ export default function ImageCropper(props: ImageCropperProps) {
|
|
|
48
48
|
let pointerStartY = 0;
|
|
49
49
|
let selStart = { x: 0, y: 0, size: 0 };
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
onSettled(() => {
|
|
52
52
|
const url = URL.createObjectURL(props.file);
|
|
53
53
|
setImageUrl(url);
|
|
54
54
|
|
|
@@ -68,7 +68,7 @@ export default function ImageCropper(props: ImageCropperProps) {
|
|
|
68
68
|
};
|
|
69
69
|
el.onerror = () => setLoadError("Could not load this image. Try a different file.");
|
|
70
70
|
el.src = url;
|
|
71
|
-
|
|
71
|
+
return () => URL.revokeObjectURL(url);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
function clampMove(nextX: number, nextY: number) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cleanup, fireEvent, render } from "@solidjs/testing-library";
|
|
2
|
+
import { flush } from "solid-js";
|
|
2
3
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
4
|
import ImageViewer from "./ImageViewer";
|
|
4
5
|
|
|
@@ -19,6 +20,7 @@ describe("ImageViewer", () => {
|
|
|
19
20
|
expect(showModal).toHaveBeenCalledTimes(1);
|
|
20
21
|
|
|
21
22
|
fireEvent.load(image!);
|
|
23
|
+
flush();
|
|
22
24
|
expect(image?.style.opacity).toBe("1");
|
|
23
25
|
|
|
24
26
|
});
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
// with unscoped `ksui-imgviewer-*` class names. Mount === open, unmount === closed
|
|
14
14
|
// (wrap in `<Show when={…}>`).
|
|
15
15
|
|
|
16
|
-
import { createSignal, onCleanup,
|
|
16
|
+
import { createSignal, onCleanup, onSettled } from "solid-js";
|
|
17
17
|
import X from "../../icons/x";
|
|
18
18
|
import { lockPullToRefresh, unlockPullToRefresh } from "../../utils/dom";
|
|
19
19
|
import { injectCSS } from "../../utils/inject-css";
|
|
20
|
+
import { ariaBool } from "../../utils/aria";
|
|
20
21
|
|
|
21
22
|
const STYLE_ID = "ksui-image-viewer-style";
|
|
22
23
|
// The backdrop scrim maps to --ks-overlay (§6a); the img/close-button chrome
|
|
@@ -49,7 +50,7 @@ export default function ImageViewer(props: Props) {
|
|
|
49
50
|
lockPullToRefresh();
|
|
50
51
|
onCleanup(unlockPullToRefresh);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
onSettled(() => {
|
|
53
54
|
if (dialogEl && !dialogEl.open) {
|
|
54
55
|
try {
|
|
55
56
|
dialogEl.showModal();
|
|
@@ -91,7 +92,7 @@ export default function ImageViewer(props: Props) {
|
|
|
91
92
|
>
|
|
92
93
|
<X size={22} />
|
|
93
94
|
</button>
|
|
94
|
-
<div class="ksui-imgviewer-frame" aria-busy={!loaded()}>
|
|
95
|
+
<div class="ksui-imgviewer-frame" aria-busy={ariaBool(!loaded())}>
|
|
95
96
|
<img
|
|
96
97
|
src={props.src}
|
|
97
98
|
alt={props.alt || ""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createMemo, Show
|
|
2
|
-
import {
|
|
1
|
+
import { createMemo, Show } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { Dynamic } from "@solidjs/web";
|
|
3
4
|
|
|
4
5
|
type IconComponent = (props: { size?: number; class?: string }) => JSX.Element;
|
|
5
6
|
|
|
@@ -97,7 +97,7 @@ describe("Modal", () => {
|
|
|
97
97
|
expect(onClose).toHaveBeenCalledOnce();
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
it("leaves Escape to a dialog opened on top of it", () => {
|
|
100
|
+
it("leaves Escape to a dialog opened on top of it", async () => {
|
|
101
101
|
const onSheetClose = vi.fn();
|
|
102
102
|
const onDialogClose = vi.fn();
|
|
103
103
|
const { container } = render(() => (
|
|
@@ -108,7 +108,8 @@ describe("Modal", () => {
|
|
|
108
108
|
</Modal>
|
|
109
109
|
));
|
|
110
110
|
const dialog = container.querySelector("dialog")!;
|
|
111
|
-
|
|
111
|
+
// The dialog opens once the render settles, not during it.
|
|
112
|
+
await vi.waitFor(() => expect(dialog.open).toBe(true));
|
|
112
113
|
|
|
113
114
|
// A browser delivers Escape as keydown (bubbling to window) and then
|
|
114
115
|
// fires cancel on the topmost modal dialog.
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
// sheet variant uses a <div> overlay so child popovers Portaled into
|
|
16
16
|
// document.body still compose above the backdrop via z-index.
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { onCleanup, onSettled, omit } from "solid-js";
|
|
19
|
+
import type { JSX } from "@solidjs/web";
|
|
19
20
|
import { autoFocusOnMount, lockPullToRefresh, unlockPullToRefresh, useFocusTrap } from "../../utils/dom";
|
|
20
21
|
import { injectCSS } from "../../utils/inject-css";
|
|
21
22
|
import { ModalLayerProvider } from "../../utils/modal-layer";
|
|
@@ -72,14 +73,7 @@ type LocalProps = Omit<ModalProps, "variant">;
|
|
|
72
73
|
|
|
73
74
|
export function Modal(props: ModalProps): JSX.Element {
|
|
74
75
|
injectCSS(STYLE_ID, STYLE_CSS);
|
|
75
|
-
const
|
|
76
|
-
"onClose",
|
|
77
|
-
"dismissable",
|
|
78
|
-
"size",
|
|
79
|
-
"tone",
|
|
80
|
-
"ariaLabel",
|
|
81
|
-
"children",
|
|
82
|
-
]);
|
|
76
|
+
const local = props;
|
|
83
77
|
// Variant is read once at mount; call sites pick it statically.
|
|
84
78
|
if (props.variant === "sheet") return SheetModal(local, props.size);
|
|
85
79
|
return DialogModal(local);
|
|
@@ -87,11 +81,14 @@ export function Modal(props: ModalProps): JSX.Element {
|
|
|
87
81
|
|
|
88
82
|
function DialogModal(local: LocalProps): JSX.Element {
|
|
89
83
|
let dialogEl: HTMLDialogElement | undefined;
|
|
84
|
+
// onCleanup is not allowed in the ref callback that creates the trap.
|
|
85
|
+
let releaseTrap: (() => void) | undefined;
|
|
86
|
+
onCleanup(() => releaseTrap?.());
|
|
90
87
|
|
|
91
88
|
lockPullToRefresh();
|
|
92
89
|
onCleanup(unlockPullToRefresh);
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
onSettled(() => {
|
|
95
92
|
if (!dialogEl) return;
|
|
96
93
|
if (!dialogEl.open) {
|
|
97
94
|
try {
|
|
@@ -141,7 +138,7 @@ function DialogModal(local: LocalProps): JSX.Element {
|
|
|
141
138
|
<div
|
|
142
139
|
ref={(el) => {
|
|
143
140
|
autoFocusOnMount(el);
|
|
144
|
-
|
|
141
|
+
releaseTrap = useFocusTrap(el);
|
|
145
142
|
}}
|
|
146
143
|
class={`ksui-modal-card${local.tone === "danger" ? " danger" : ""}`}
|
|
147
144
|
style={{ "max-width": SIZE_MAX_WIDTH[local.size ?? "lg"] }}
|
|
@@ -167,6 +164,8 @@ function openModalDialogs(): HTMLDialogElement[] {
|
|
|
167
164
|
|
|
168
165
|
function SheetModal(local: LocalProps, size?: ModalSize): JSX.Element {
|
|
169
166
|
let overlayEl: HTMLDivElement | undefined;
|
|
167
|
+
let releaseTrap: (() => void) | undefined;
|
|
168
|
+
onCleanup(() => releaseTrap?.());
|
|
170
169
|
|
|
171
170
|
lockPullToRefresh();
|
|
172
171
|
onCleanup(unlockPullToRefresh);
|
|
@@ -200,7 +199,7 @@ function SheetModal(local: LocalProps, size?: ModalSize): JSX.Element {
|
|
|
200
199
|
<div
|
|
201
200
|
ref={(el) => {
|
|
202
201
|
autoFocusOnMount(el);
|
|
203
|
-
|
|
202
|
+
releaseTrap = useFocusTrap(el);
|
|
204
203
|
}}
|
|
205
204
|
role="dialog"
|
|
206
205
|
aria-modal="true"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { For, createMemo, createUniqueId
|
|
1
|
+
import { For, createMemo, createUniqueId } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
2
3
|
import ChevronLeft from "../../icons/chevron-left";
|
|
3
4
|
import ChevronRight from "../../icons/chevron-right";
|
|
4
5
|
import { injectCSS } from "../../utils/inject-css";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { For
|
|
1
|
+
import { For } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { ariaTri } from "../../utils/aria";
|
|
2
4
|
|
|
3
5
|
export interface MultiSelectOption {
|
|
4
6
|
value: string;
|
|
@@ -36,17 +38,17 @@ export default function MultiSelectGroup(props: MultiSelectGroupProps): JSX.Elem
|
|
|
36
38
|
{(option) => (
|
|
37
39
|
<button
|
|
38
40
|
type="button"
|
|
39
|
-
aria-pressed={selected(option.value)}
|
|
41
|
+
aria-pressed={ariaTri(selected(option.value))}
|
|
40
42
|
disabled={props.disabled || option.disabled}
|
|
41
43
|
title={option.disabledNote}
|
|
42
44
|
onClick={() => toggle(option)}
|
|
43
|
-
class={`rounded-md border px-2.5 py-1.5 text-xs transition-colors ${props.itemClass ?? ""}
|
|
44
|
-
classList={{
|
|
45
|
+
class={[`rounded-md border px-2.5 py-1.5 text-xs transition-colors ${props.itemClass ?? ""}`, {
|
|
45
46
|
"border-[var(--ks-info,#38bdf8)] bg-[var(--ks-info,#38bdf8)] text-[var(--ks-info-fg,#7dd3fc)]": selected(option.value) && (props.variant ?? "info") === "info",
|
|
46
47
|
"border-[var(--ks-accent,#fbbf24)] bg-[var(--ks-accent,#fbbf24)] font-semibold text-[var(--ks-fg-on-accent,#0a0a0a)]": selected(option.value) && props.variant === "accent",
|
|
47
48
|
"border-[var(--ks-border,rgba(39,39,42,0.5))] bg-[var(--ks-surface,#0f0f0f)] text-[var(--ks-fg-muted,#a1a1aa)] hover:border-[var(--ks-border-strong,#3f3f46)] hover:text-[var(--ks-fg,#ffffff)]": !selected(option.value),
|
|
48
49
|
"cursor-not-allowed opacity-50": !!props.disabled || !!option.disabled,
|
|
49
|
-
}}
|
|
50
|
+
}]}
|
|
51
|
+
|
|
50
52
|
>
|
|
51
53
|
{option.label}
|
|
52
54
|
</button>
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// progress visualization the session manager uses on the home page.
|
|
4
4
|
// Adapted to the library's TS + shared icon conventions.
|
|
5
5
|
|
|
6
|
-
import type { Component
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import type { Component } from "solid-js";
|
|
7
|
+
import type { JSX } from "@solidjs/web";
|
|
8
|
+
import { createMemo, omit, Show } from "solid-js";
|
|
9
|
+
import { Dynamic } from "@solidjs/web";
|
|
9
10
|
import { injectCSS } from "../../utils/inject-css";
|
|
10
11
|
|
|
11
12
|
// The monolith ships these as a CSS module (ProgressBar.module.css). The
|
|
@@ -164,19 +165,8 @@ function extractTextSize(className: string): number {
|
|
|
164
165
|
|
|
165
166
|
const DefaultProgressBar: Component<ProgressBarProps> = (props) => {
|
|
166
167
|
injectCSS(PROGRESS_STYLE_ID, PROGRESS_CSS);
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
"icon",
|
|
170
|
-
"label",
|
|
171
|
-
"statusLabel",
|
|
172
|
-
"shimmer",
|
|
173
|
-
"position",
|
|
174
|
-
"hidePercentage",
|
|
175
|
-
"rightLabel",
|
|
176
|
-
"color",
|
|
177
|
-
"variant",
|
|
178
|
-
"class",
|
|
179
|
-
]);
|
|
168
|
+
const local = props;
|
|
169
|
+
const others = omit(props, "progress", "icon", "label", "statusLabel", "shimmer", "position", "hidePercentage", "rightLabel", "color", "variant", "class");
|
|
180
170
|
|
|
181
171
|
const progressVal = createMemo(() => {
|
|
182
172
|
const value = local.progress;
|
|
@@ -350,7 +340,8 @@ type CompactProgressBarProps = ProgressBarProps;
|
|
|
350
340
|
|
|
351
341
|
const CompactProgressBar: Component<CompactProgressBarProps> = (props) => {
|
|
352
342
|
injectCSS(PROGRESS_STYLE_ID, PROGRESS_CSS);
|
|
353
|
-
const
|
|
343
|
+
const local = props;
|
|
344
|
+
const others = omit(props, "progress", "icon", "label", "statusLabel", "shimmer", "position", "hidePercentage", "rightLabel", "color", "variant", "class");
|
|
354
345
|
const value = createMemo(() => {
|
|
355
346
|
if (typeof local.progress !== "number" || Number.isNaN(local.progress)) return 0;
|
|
356
347
|
return Math.min(100, Math.max(0, Math.round(local.progress)));
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { For
|
|
1
|
+
import { For } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { ariaBool, ariaTri } from "../../utils/aria";
|
|
2
4
|
|
|
3
5
|
interface RadioCardGroupProps<T> {
|
|
4
6
|
/** The selectable options. */
|
|
@@ -101,11 +103,11 @@ export default function RadioCardGroup<T>(props: RadioCardGroupProps<T>): JSX.El
|
|
|
101
103
|
const defaultRender = (option: T, selected: boolean) => (
|
|
102
104
|
<>
|
|
103
105
|
<span
|
|
104
|
-
class="h-2 w-2 rounded-full shrink-0"
|
|
105
|
-
classList={{
|
|
106
|
+
class={["h-2 w-2 rounded-full shrink-0", {
|
|
106
107
|
"bg-[var(--ks-accent,#fbbf24)]": selected,
|
|
107
108
|
"bg-[var(--ks-fg-subtle,#71717a)] group-hover:bg-[var(--ks-fg-muted,#a1a1aa)]": !selected,
|
|
108
|
-
}}
|
|
109
|
+
}]}
|
|
110
|
+
|
|
109
111
|
/>
|
|
110
112
|
<span class="truncate">{label(option)}</span>
|
|
111
113
|
</>
|
|
@@ -115,8 +117,8 @@ export default function RadioCardGroup<T>(props: RadioCardGroupProps<T>): JSX.El
|
|
|
115
117
|
<div
|
|
116
118
|
role="radiogroup"
|
|
117
119
|
aria-label={props.ariaLabel}
|
|
118
|
-
aria-disabled={props.disabled}
|
|
119
|
-
|
|
120
|
+
aria-disabled={ariaBool(props.disabled)}
|
|
121
|
+
tabindex={-1}
|
|
120
122
|
class={`${gridClass()} ${props.class ?? ""}`}
|
|
121
123
|
onKeyDown={onKeyDown}
|
|
122
124
|
>
|
|
@@ -130,18 +132,18 @@ export default function RadioCardGroup<T>(props: RadioCardGroupProps<T>): JSX.El
|
|
|
130
132
|
ref={(el) => (buttonRefs[i()] = el)}
|
|
131
133
|
type="button"
|
|
132
134
|
role="radio"
|
|
133
|
-
aria-checked={selected()}
|
|
134
|
-
aria-disabled={props.disabled}
|
|
135
|
-
|
|
135
|
+
aria-checked={ariaTri(selected())}
|
|
136
|
+
aria-disabled={ariaBool(props.disabled)}
|
|
137
|
+
tabindex={isTabStop() ? 0 : -1}
|
|
136
138
|
onClick={() => !props.disabled && props.onChange(k)}
|
|
137
|
-
class={`group flex items-center gap-2 rounded-lg border px-3 py-3 text-left text-sm transition-colors cursor-pointer ${props.itemClass ?? ""}
|
|
138
|
-
classList={{
|
|
139
|
+
class={[`group flex items-center gap-2 rounded-lg border px-3 py-3 text-left text-sm transition-colors cursor-pointer ${props.itemClass ?? ""}`, {
|
|
139
140
|
"opacity-50 pointer-events-none cursor-not-allowed": !!props.disabled,
|
|
140
141
|
"border-[var(--ks-accent,#fbbf24)]/50 bg-[var(--ks-accent,#fbbf24)]/10 text-[var(--ks-accent,#fbbf24)]":
|
|
141
142
|
selected(),
|
|
142
143
|
"border-[var(--ks-border-strong,#3f3f46)] bg-[var(--ks-surface-raised,#1a1a1a)] text-[var(--ks-fg-muted,#a1a1aa)] hover:border-[var(--ks-fg-subtle,#71717a)] hover:bg-[var(--ks-surface-sunken,#141414)]":
|
|
143
144
|
!selected(),
|
|
144
|
-
}}
|
|
145
|
+
}]}
|
|
146
|
+
|
|
145
147
|
>
|
|
146
148
|
{(props.renderOption ?? defaultRender)(option, selected())}
|
|
147
149
|
</button>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { For, type Component
|
|
2
|
-
import {
|
|
1
|
+
import { For, type Component } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { Dynamic } from "@solidjs/web";
|
|
4
|
+
import { ariaBool, ariaTri } from "../../utils/aria";
|
|
3
5
|
export type SegmentedFilterIcon = Component<{ size?: number; class?: string }>;
|
|
4
6
|
|
|
5
7
|
/** One choice in the segmented row. A bare string uses the value as the label
|
|
@@ -109,18 +111,17 @@ export default function SegmentedFilter(props: SegmentedFilterProps): JSX.Elemen
|
|
|
109
111
|
ref={(el) => (buttonRefs[i()] = el)}
|
|
110
112
|
type="button"
|
|
111
113
|
role="radio"
|
|
112
|
-
aria-checked={selected()}
|
|
113
|
-
aria-disabled={opt.disabled}
|
|
114
|
+
aria-checked={ariaTri(selected())}
|
|
115
|
+
aria-disabled={ariaBool(opt.disabled)}
|
|
114
116
|
aria-describedby={opt.disabled && opt.disabledNote ? noteId : undefined}
|
|
115
117
|
title={opt.disabled ? opt.disabledNote : undefined}
|
|
116
|
-
|
|
118
|
+
tabindex={opt.disabled ? -1 : isTabStop() ? 0 : -1}
|
|
117
119
|
data-testid={props.testIdPrefix ? `${props.testIdPrefix}-${opt.value}` : undefined}
|
|
118
120
|
onClick={() => {
|
|
119
121
|
if (opt.disabled) return;
|
|
120
122
|
props.onChange(opt.value);
|
|
121
123
|
}}
|
|
122
|
-
class="inline-flex shrink-0 items-center justify-center gap-1.5 px-3 py-1.5 text-xs transition-colors"
|
|
123
|
-
classList={{
|
|
124
|
+
class={["inline-flex shrink-0 items-center justify-center gap-1.5 px-3 py-1.5 text-xs transition-colors", {
|
|
124
125
|
capitalize: opt.capitalize,
|
|
125
126
|
"cursor-not-allowed": opt.disabled,
|
|
126
127
|
"cursor-pointer": !opt.disabled,
|
|
@@ -128,7 +129,8 @@ export default function SegmentedFilter(props: SegmentedFilterProps): JSX.Elemen
|
|
|
128
129
|
"text-[var(--ks-fg-subtle,#71717a)]": opt.disabled,
|
|
129
130
|
"text-[var(--ks-fg-muted,#a1a1aa)] hover:text-[var(--ks-fg,#ffffff)] hover:bg-[var(--ks-surface-raised,#1a1a1a)]":
|
|
130
131
|
!selected() && !opt.disabled,
|
|
131
|
-
}}
|
|
132
|
+
}]}
|
|
133
|
+
|
|
132
134
|
>
|
|
133
135
|
{opt.icon ? <Dynamic component={opt.icon} size={14} aria-hidden="true" /> : null}
|
|
134
136
|
{opt.label}
|