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