@kahitsan/ksui 0.50.0 → 0.51.0-solid2.1
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 +91 -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 +21 -1
- package/src/components/composite/resource/ResourcePage.tsx +23 -8
- 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
|
@@ -26,18 +26,8 @@
|
|
|
26
26
|
// `base/` (and is re-exported as base) to preserve its existing import path —
|
|
27
27
|
// the only ksui dependency is DatePicker, itself a self-contained primitive.
|
|
28
28
|
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
createSignal,
|
|
32
|
-
createMemo,
|
|
33
|
-
createEffect,
|
|
34
|
-
on,
|
|
35
|
-
untrack,
|
|
36
|
-
For,
|
|
37
|
-
Show,
|
|
38
|
-
type JSX,
|
|
39
|
-
type ParentComponent,
|
|
40
|
-
} from "solid-js";
|
|
29
|
+
import { createSignal, createMemo, createEffect, untrack, For, Show, type ParentComponent } from "solid-js";
|
|
30
|
+
import type { JSX } from "@solidjs/web";
|
|
41
31
|
import Search from "../../icons/search";
|
|
42
32
|
import Filter from "../../icons/filter";
|
|
43
33
|
import ChevronLeft from "../../icons/chevron-left";
|
|
@@ -223,6 +213,8 @@ export interface DataTableProps<T extends DataTableRow> {
|
|
|
223
213
|
/**
|
|
224
214
|
* Reactive key that triggers a refetch + page-1 reset when it changes.
|
|
225
215
|
* Typical usage: `refetchKey={() => activeWorkspace()?.ws_id}`.
|
|
216
|
+
* `fetchFn` runs untracked, so any signal it reads (an external filter, say)
|
|
217
|
+
* must also be read in this key, or changing it will not refetch.
|
|
226
218
|
*/
|
|
227
219
|
refetchKey?: () => unknown;
|
|
228
220
|
|
|
@@ -401,48 +393,45 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
401
393
|
props.onRefetch?.({
|
|
402
394
|
refetch: () => triggerFetch(),
|
|
403
395
|
resetAndRefetch: () => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
triggerFetch();
|
|
408
|
-
});
|
|
396
|
+
setCurrentPage(1);
|
|
397
|
+
resetLoadMore();
|
|
398
|
+
triggerFetch();
|
|
409
399
|
},
|
|
410
400
|
});
|
|
411
401
|
|
|
412
402
|
// Watch refetchKey — when it changes, reset to page 1 and refetch.
|
|
413
403
|
createEffect(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
()
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
});
|
|
422
|
-
},
|
|
423
|
-
{ defer: true },
|
|
424
|
-
),
|
|
404
|
+
() => props.refetchKey?.(),
|
|
405
|
+
() => {
|
|
406
|
+
setCurrentPage(1);
|
|
407
|
+
resetLoadMore();
|
|
408
|
+
triggerFetch();
|
|
409
|
+
},
|
|
410
|
+
{ defer: true },
|
|
425
411
|
);
|
|
426
412
|
|
|
427
|
-
createEffect(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
413
|
+
createEffect(
|
|
414
|
+
() => {
|
|
415
|
+
void fetchTrigger(); // track
|
|
416
|
+
const fn = props.fetchFn;
|
|
417
|
+
if (!fn) return undefined;
|
|
418
|
+
const page = currentPage();
|
|
419
|
+
const limit = itemsPerPage();
|
|
420
|
+
const params: FetchParams = {
|
|
421
|
+
page,
|
|
422
|
+
limit,
|
|
423
|
+
search: searchTerm(),
|
|
424
|
+
sortBy: sortBy(),
|
|
425
|
+
sortDir: sortDir(),
|
|
426
|
+
dateFilter: props.dateRangeMode ? null : dateFilter(),
|
|
427
|
+
dateFrom: props.dateRangeMode ? dateFrom() : null,
|
|
428
|
+
dateTo: props.dateRangeMode ? dateTo() : null,
|
|
429
|
+
};
|
|
430
|
+
return { fn, params, page, limit, lm: loadMoreMode(), epoch: loadEpoch() };
|
|
431
|
+
},
|
|
432
|
+
(request) => {
|
|
433
|
+
if (!request) return;
|
|
434
|
+
const { fn, params, page, limit, lm, epoch } = request;
|
|
446
435
|
|
|
447
436
|
if (lm) {
|
|
448
437
|
const key = `${page}:${epoch}`;
|
|
@@ -491,7 +480,8 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
491
480
|
}
|
|
492
481
|
})
|
|
493
482
|
.finally(() => setLoading(false));
|
|
494
|
-
|
|
483
|
+
},
|
|
484
|
+
);
|
|
495
485
|
|
|
496
486
|
// ---- Auto-load (loadMore mode) ----
|
|
497
487
|
//
|
|
@@ -502,31 +492,32 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
502
492
|
// network fetch. The autoLoadCount cap protects a degenerate grouping from
|
|
503
493
|
// chaining to the end of the dataset.
|
|
504
494
|
createEffect(
|
|
505
|
-
|
|
495
|
+
() => ({ consumed: apiConsumed(), isLoading: loading() }),
|
|
496
|
+
({ isLoading }) => {
|
|
506
497
|
if (!loadMoreMode()) return;
|
|
507
|
-
if (
|
|
498
|
+
if (initialized() === false) return;
|
|
508
499
|
if (isLoading) return;
|
|
509
|
-
const visible =
|
|
510
|
-
if (visible >=
|
|
511
|
-
if (
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
});
|
|
518
|
-
}),
|
|
500
|
+
const visible = paginatedData().length;
|
|
501
|
+
if (visible >= loadTarget()) return;
|
|
502
|
+
if (apiConsumed() >= totalRecords()) return;
|
|
503
|
+
if (autoLoadCount() >= AUTO_LOAD_CAP) return;
|
|
504
|
+
setAutoLoadCount((c) => c + 1);
|
|
505
|
+
setCurrentPage((p) => p + 1);
|
|
506
|
+
triggerFetch();
|
|
507
|
+
},
|
|
519
508
|
);
|
|
520
509
|
|
|
521
510
|
// ---- Client-side data ----
|
|
522
511
|
|
|
523
|
-
createEffect(
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
512
|
+
createEffect(
|
|
513
|
+
() => (isServerSide() ? undefined : props.data || []),
|
|
514
|
+
(d) => {
|
|
515
|
+
if (!d) return;
|
|
516
|
+
setTableData(d as T[]);
|
|
517
|
+
setTotalRecords(d.length);
|
|
518
|
+
setInitialized(true);
|
|
519
|
+
},
|
|
520
|
+
);
|
|
530
521
|
|
|
531
522
|
// Post-fetch row transform. No-op passthrough when no transform is supplied.
|
|
532
523
|
const transformedData = createMemo(() => {
|
|
@@ -605,30 +596,24 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
605
596
|
// ---- Handlers ----
|
|
606
597
|
|
|
607
598
|
function handleDateFilter(date: string | null) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
if (isServerSide()) triggerFetch();
|
|
613
|
-
});
|
|
599
|
+
setDateFilter(date);
|
|
600
|
+
setCurrentPage(1);
|
|
601
|
+
resetLoadMore();
|
|
602
|
+
if (isServerSide()) triggerFetch();
|
|
614
603
|
}
|
|
615
604
|
|
|
616
605
|
function handleDateRangeFilter(range: { start: string | null; end: string | null }) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
if (isServerSide()) triggerFetch();
|
|
623
|
-
});
|
|
606
|
+
setDateFrom(range.start);
|
|
607
|
+
setDateTo(range.end);
|
|
608
|
+
setCurrentPage(1);
|
|
609
|
+
resetLoadMore();
|
|
610
|
+
if (isServerSide()) triggerFetch();
|
|
624
611
|
}
|
|
625
612
|
|
|
626
613
|
function handleSearch(value: string) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
resetLoadMore();
|
|
631
|
-
});
|
|
614
|
+
setSearchTerm(value);
|
|
615
|
+
setCurrentPage(1);
|
|
616
|
+
resetLoadMore();
|
|
632
617
|
if (isServerSide()) {
|
|
633
618
|
clearTimeout(debounceTimer);
|
|
634
619
|
debounceTimer = setTimeout(triggerFetch, debounceDelay());
|
|
@@ -637,17 +622,15 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
637
622
|
|
|
638
623
|
function handleSort(key: string) {
|
|
639
624
|
if (!ordering()) return;
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if (isServerSide()) triggerFetch();
|
|
650
|
-
});
|
|
625
|
+
if (sortBy() === key) {
|
|
626
|
+
setSortDir((d) => (d === "asc" ? "desc" : "asc"));
|
|
627
|
+
} else {
|
|
628
|
+
setSortBy(key);
|
|
629
|
+
setSortDir("desc");
|
|
630
|
+
}
|
|
631
|
+
setCurrentPage(1);
|
|
632
|
+
resetLoadMore();
|
|
633
|
+
if (isServerSide()) triggerFetch();
|
|
651
634
|
}
|
|
652
635
|
|
|
653
636
|
function handlePageChange(page: number) {
|
|
@@ -656,23 +639,19 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
656
639
|
}
|
|
657
640
|
|
|
658
641
|
function handlePageSize(size: number) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (isServerSide()) triggerFetch();
|
|
664
|
-
});
|
|
642
|
+
setItemsPerPage(size);
|
|
643
|
+
setCurrentPage(1);
|
|
644
|
+
resetLoadMore();
|
|
645
|
+
if (isServerSide()) triggerFetch();
|
|
665
646
|
}
|
|
666
647
|
|
|
667
648
|
function handleShowMore() {
|
|
668
649
|
if (!loadMoreMode() || loading()) return;
|
|
669
650
|
if (apiConsumed() >= totalRecords()) return;
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
triggerFetch();
|
|
675
|
-
});
|
|
651
|
+
setCurrentPage((p) => p + 1);
|
|
652
|
+
setAutoLoadCount(0);
|
|
653
|
+
setPendingLoadTargetBump(true);
|
|
654
|
+
triggerFetch();
|
|
676
655
|
}
|
|
677
656
|
|
|
678
657
|
// ---- Render helpers ----
|
|
@@ -823,7 +802,7 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
823
802
|
{/* Empty state */}
|
|
824
803
|
<Show when={initialized() && !loading() && paginatedData().length === 0}>
|
|
825
804
|
<tr>
|
|
826
|
-
<td
|
|
805
|
+
<td colspan={columns().length} class="ksui-datatable-empty">
|
|
827
806
|
{searchTerm()
|
|
828
807
|
? props.noResultsMessage || "No results found."
|
|
829
808
|
: props.emptyMessage || "No data available."}
|
|
@@ -839,8 +818,8 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
839
818
|
return (
|
|
840
819
|
<>
|
|
841
820
|
<tr
|
|
842
|
-
class="ksui-datatable-row"
|
|
843
|
-
|
|
821
|
+
class={["ksui-datatable-row", { "ksui-datatable-row-clickable": !!props.onRowClick }]}
|
|
822
|
+
|
|
844
823
|
onClick={() => props.onRowClick?.(row)}
|
|
845
824
|
>
|
|
846
825
|
<For each={columns()}>
|
|
@@ -860,7 +839,7 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
860
839
|
class="ksui-datatable-expansion-row"
|
|
861
840
|
data-testid="datatable-expansion-row"
|
|
862
841
|
>
|
|
863
|
-
<td class="ksui-datatable-expansion-td"
|
|
842
|
+
<td class="ksui-datatable-expansion-td" colspan={columns().length}>
|
|
864
843
|
{expansion()}
|
|
865
844
|
</td>
|
|
866
845
|
</tr>
|
|
@@ -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
|
|