@kahitsan/ksui 0.49.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 +10 -7
- 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 +10 -4
- package/src/icons/arrow-down-left.tsx +2 -2
- package/src/icons/arrow-left.tsx +2 -2
- package/src/icons/arrow-right-left.tsx +1 -1
- package/src/icons/arrow-right.tsx +2 -2
- package/src/icons/arrow-up-down.tsx +2 -2
- package/src/icons/arrow-up-right.tsx +2 -2
- package/src/icons/arrow-up.tsx +2 -2
- package/src/icons/artwork/activity.ts +1 -1
- package/src/icons/artwork/app-window.png +0 -0
- package/src/icons/artwork/app-window.ts +2 -1
- package/src/icons/artwork/archive-restore.ts +1 -1
- package/src/icons/artwork/archive.ts +1 -1
- package/src/icons/artwork/arrow-down.ts +1 -1
- package/src/icons/artwork/arrow-left-right.ts +1 -1
- package/src/icons/artwork/at-sign.png +0 -0
- package/src/icons/artwork/at-sign.ts +2 -1
- package/src/icons/artwork/ban.png +0 -0
- package/src/icons/artwork/ban.ts +2 -1
- package/src/icons/artwork/banknote.ts +1 -1
- package/src/icons/artwork/bell.ts +1 -1
- package/src/icons/artwork/bir-form-0619-e.png +0 -0
- package/src/icons/artwork/bir-form-0619-e.ts +3 -0
- package/src/icons/artwork/bir-form-1601-eq.png +0 -0
- package/src/icons/artwork/bir-form-1601-eq.ts +3 -0
- package/src/icons/artwork/bir-form-2307.png +0 -0
- package/src/icons/artwork/bir-form-2307.ts +3 -0
- package/src/icons/artwork/bir-office.ts +2 -0
- package/src/icons/artwork/blocks.png +0 -0
- package/src/icons/artwork/blocks.ts +2 -1
- package/src/icons/artwork/book-open.ts +1 -1
- package/src/icons/artwork/boxes.ts +1 -1
- package/src/icons/artwork/briefcase.png +0 -0
- package/src/icons/artwork/briefcase.ts +2 -1
- package/src/icons/artwork/building-2.ts +1 -1
- package/src/icons/artwork/building.png +0 -0
- package/src/icons/artwork/building.ts +2 -1
- package/src/icons/artwork/calculator.png +0 -0
- package/src/icons/artwork/calculator.ts +2 -1
- package/src/icons/artwork/calendar-clock.png +0 -0
- package/src/icons/artwork/calendar-clock.ts +2 -1
- package/src/icons/artwork/calendar.png +0 -0
- package/src/icons/artwork/calendar.ts +2 -1
- package/src/icons/artwork/camera.ts +1 -1
- package/src/icons/artwork/chart-bar.ts +1 -1
- package/src/icons/artwork/check-bold.ts +1 -1
- package/src/icons/artwork/check-check.ts +1 -1
- package/src/icons/artwork/check.ts +1 -1
- package/src/icons/artwork/chevron-right.ts +1 -1
- package/src/icons/artwork/chevrons-up-down.ts +1 -1
- package/src/icons/artwork/circle-alert.ts +1 -1
- package/src/icons/artwork/circle-check-bold.png +0 -0
- package/src/icons/artwork/circle-check-bold.ts +2 -1
- package/src/icons/artwork/circle-check.png +0 -0
- package/src/icons/artwork/circle-check.ts +2 -1
- package/src/icons/artwork/circle-dot.ts +1 -1
- package/src/icons/artwork/circle-question-mark.png +0 -0
- package/src/icons/artwork/circle-question-mark.ts +2 -1
- package/src/icons/artwork/circle-x.ts +1 -1
- package/src/icons/artwork/circle.ts +1 -1
- package/src/icons/artwork/clipboard-list.ts +1 -1
- package/src/icons/artwork/clock.png +0 -0
- package/src/icons/artwork/clock.ts +2 -1
- package/src/icons/artwork/coins.ts +1 -1
- package/src/icons/artwork/compass.png +0 -0
- package/src/icons/artwork/compass.ts +2 -1
- package/src/icons/artwork/copy.png +0 -0
- package/src/icons/artwork/copy.ts +2 -1
- package/src/icons/artwork/corner-down-right.ts +1 -1
- package/src/icons/artwork/credit-card.png +0 -0
- package/src/icons/artwork/credit-card.ts +2 -1
- package/src/icons/artwork/crown.ts +1 -1
- package/src/icons/artwork/database.png +0 -0
- package/src/icons/artwork/database.ts +2 -1
- package/src/icons/artwork/dollar-sign.ts +1 -1
- package/src/icons/artwork/door-open.png +0 -0
- package/src/icons/artwork/door-open.ts +2 -1
- package/src/icons/artwork/download.ts +1 -1
- package/src/icons/artwork/ellipsis.ts +1 -1
- package/src/icons/artwork/equal.ts +1 -1
- package/src/icons/artwork/external-link.ts +1 -1
- package/src/icons/artwork/eye.ts +1 -1
- package/src/icons/artwork/file-spreadsheet.png +0 -0
- package/src/icons/artwork/file-spreadsheet.ts +2 -1
- package/src/icons/artwork/file-text.png +0 -0
- package/src/icons/artwork/file-text.ts +2 -1
- package/src/icons/artwork/file.ts +1 -1
- package/src/icons/artwork/funnel.ts +1 -1
- package/src/icons/artwork/globe.png +0 -0
- package/src/icons/artwork/globe.ts +2 -1
- package/src/icons/artwork/grip-vertical.ts +1 -1
- package/src/icons/artwork/history.png +0 -0
- package/src/icons/artwork/history.ts +2 -1
- package/src/icons/artwork/house.ts +1 -1
- package/src/icons/artwork/image-off.png +0 -0
- package/src/icons/artwork/image-off.ts +2 -1
- package/src/icons/artwork/inbox.ts +1 -1
- package/src/icons/artwork/info.ts +1 -1
- package/src/icons/artwork/key.ts +1 -1
- package/src/icons/artwork/landmark.ts +1 -1
- package/src/icons/artwork/layers.png +0 -0
- package/src/icons/artwork/layers.ts +2 -1
- package/src/icons/artwork/layout-dashboard.ts +1 -1
- package/src/icons/artwork/layout-grid.ts +1 -1
- package/src/icons/artwork/layout-list.png +0 -0
- package/src/icons/artwork/layout-list.ts +2 -1
- package/src/icons/artwork/link-2.ts +1 -1
- package/src/icons/artwork/list.ts +1 -1
- package/src/icons/artwork/loader-circle.ts +1 -1
- package/src/icons/artwork/lock.ts +1 -1
- package/src/icons/artwork/log-in.ts +1 -1
- package/src/icons/artwork/log-out.ts +1 -1
- package/src/icons/artwork/mail-open.ts +1 -1
- package/src/icons/artwork/mail.ts +1 -1
- package/src/icons/artwork/megaphone.ts +1 -1
- package/src/icons/artwork/message-square.ts +1 -1
- package/src/icons/artwork/minus.ts +1 -1
- package/src/icons/artwork/moon.ts +1 -1
- package/src/icons/artwork/mouse-pointer-click.ts +1 -1
- package/src/icons/artwork/move.ts +1 -1
- package/src/icons/artwork/package.ts +1 -1
- package/src/icons/artwork/palette.png +0 -0
- package/src/icons/artwork/palette.ts +2 -1
- package/src/icons/artwork/panel-left-close.ts +1 -1
- package/src/icons/artwork/panel-left.png +0 -0
- package/src/icons/artwork/panel-left.ts +2 -1
- package/src/icons/artwork/paperclip.png +0 -0
- package/src/icons/artwork/paperclip.ts +2 -1
- package/src/icons/artwork/pencil.ts +1 -1
- package/src/icons/artwork/phone-call.png +0 -0
- package/src/icons/artwork/phone-call.ts +2 -1
- package/src/icons/artwork/phone.ts +1 -1
- package/src/icons/artwork/piggy-bank.ts +1 -1
- package/src/icons/artwork/play.ts +1 -1
- package/src/icons/artwork/plus.ts +1 -1
- package/src/icons/artwork/power.ts +1 -1
- package/src/icons/artwork/radio.png +0 -0
- package/src/icons/artwork/radio.ts +2 -1
- package/src/icons/artwork/receipt.ts +1 -1
- package/src/icons/artwork/refresh-cw.ts +1 -1
- package/src/icons/artwork/rotate-ccw.ts +1 -1
- package/src/icons/artwork/sales.ts +2 -0
- package/src/icons/artwork/save.ts +1 -1
- package/src/icons/artwork/search.ts +1 -1
- package/src/icons/artwork/settings.ts +1 -1
- package/src/icons/artwork/shield-alert.ts +1 -1
- package/src/icons/artwork/shield-check.ts +1 -1
- package/src/icons/artwork/shield-off.ts +1 -1
- package/src/icons/artwork/shield.ts +1 -1
- package/src/icons/artwork/shopping-bag.png +0 -0
- package/src/icons/artwork/shopping-bag.ts +2 -1
- package/src/icons/artwork/shopping-cart.ts +1 -1
- package/src/icons/artwork/shuffle.ts +1 -1
- package/src/icons/artwork/sliders-horizontal.ts +1 -1
- package/src/icons/artwork/smartphone.ts +1 -1
- package/src/icons/artwork/sparkles.ts +1 -1
- package/src/icons/artwork/square.ts +1 -1
- package/src/icons/artwork/star-filled.ts +1 -1
- package/src/icons/artwork/star.ts +1 -1
- package/src/icons/artwork/sticky-note.png +0 -0
- package/src/icons/artwork/sticky-note.ts +2 -1
- package/src/icons/artwork/store.png +0 -0
- package/src/icons/artwork/store.ts +2 -1
- package/src/icons/artwork/sun.ts +1 -1
- package/src/icons/artwork/tag.ts +1 -1
- package/src/icons/artwork/target.png +0 -0
- package/src/icons/artwork/target.ts +2 -1
- package/src/icons/artwork/ticket.png +0 -0
- package/src/icons/artwork/ticket.ts +2 -1
- package/src/icons/artwork/trash-2.png +0 -0
- package/src/icons/artwork/trash-2.ts +2 -1
- package/src/icons/artwork/trending-up.ts +1 -1
- package/src/icons/artwork/triangle-alert.ts +1 -1
- package/src/icons/artwork/trophy.ts +1 -1
- package/src/icons/artwork/undo-2.ts +1 -1
- package/src/icons/artwork/upload.ts +1 -1
- package/src/icons/artwork/user-check.png +0 -0
- package/src/icons/artwork/user-check.ts +2 -1
- package/src/icons/artwork/user-plus.ts +1 -1
- package/src/icons/artwork/user.ts +1 -1
- package/src/icons/artwork/users.ts +1 -1
- package/src/icons/artwork/volume-2.ts +1 -1
- package/src/icons/artwork/volume-x.ts +1 -1
- package/src/icons/artwork/wallet.ts +1 -1
- package/src/icons/artwork/x.ts +1 -1
- package/src/icons/artwork/zap.ts +1 -1
- package/src/icons/artwork/zoom-in.png +0 -0
- package/src/icons/artwork/zoom-in.ts +2 -1
- package/src/icons/asset-modules.d.ts +4 -0
- package/src/icons/bir-form-0619-e.tsx +4 -0
- package/src/icons/bir-form-1601-eq.tsx +4 -0
- package/src/icons/bir-form-2307.tsx +4 -0
- package/src/icons/bir-office.tsx +4 -0
- package/src/icons/calendar-days.tsx +1 -1
- package/src/icons/check.tsx +2 -2
- package/src/icons/chevron-down.tsx +2 -2
- package/src/icons/chevron-left.tsx +2 -2
- package/src/icons/chevron-up.tsx +2 -2
- package/src/icons/circle-check-big.tsx +3 -2
- package/src/icons/circle-check.tsx +2 -2
- package/src/icons/circle-slash.tsx +1 -1
- package/src/icons/cloud-upload.tsx +1 -1
- package/src/icons/create-artwork-icon.test.tsx +33 -1
- package/src/icons/create-artwork-icon.tsx +35 -40
- package/src/icons/ellipsis-vertical.tsx +2 -2
- package/src/icons/index.ts +5 -0
- package/src/icons/key-round.tsx +1 -1
- package/src/icons/registry.ts +8 -3
- package/src/icons/sales.tsx +4 -0
- package/src/icons/settings-2.tsx +1 -1
- package/src/icons/star.tsx +2 -2
- package/src/icons/user-round.tsx +1 -1
- package/src/icons/users-round.tsx +1 -1
- 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
- package/src/icons/artwork/arrow-down-left.ts +0 -2
- package/src/icons/artwork/arrow-left.ts +0 -2
- package/src/icons/artwork/arrow-right-left.ts +0 -2
- package/src/icons/artwork/arrow-right.ts +0 -2
- package/src/icons/artwork/arrow-up-down.ts +0 -2
- package/src/icons/artwork/arrow-up-right.ts +0 -2
- package/src/icons/artwork/arrow-up.ts +0 -2
- package/src/icons/artwork/calendar-days.ts +0 -2
- package/src/icons/artwork/chevron-down.ts +0 -2
- package/src/icons/artwork/chevron-left.ts +0 -2
- package/src/icons/artwork/chevron-up.ts +0 -2
- package/src/icons/artwork/circle-check-big.ts +0 -2
- package/src/icons/artwork/circle-slash.ts +0 -2
- package/src/icons/artwork/cloud-upload.ts +0 -2
- package/src/icons/artwork/ellipsis-vertical.ts +0 -2
- package/src/icons/artwork/key-round.ts +0 -2
- package/src/icons/artwork/settings-2.ts +0 -2
- package/src/icons/artwork/user-round.ts +0 -2
- package/src/icons/artwork/users-round.ts +0 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import X from "../../icons/x";
|
|
2
|
+
import { ariaTri } from "../../utils/aria";
|
|
2
3
|
|
|
3
4
|
export interface TransferFeeChipProps {
|
|
4
5
|
enabled: boolean;
|
|
@@ -11,20 +12,20 @@ export default function TransferFeeChip(props: TransferFeeChipProps) {
|
|
|
11
12
|
type="button"
|
|
12
13
|
data-testid="transactions-form-transfer-fee-toggle"
|
|
13
14
|
onClick={props.onToggle}
|
|
14
|
-
class="flex items-center gap-1.5 self-center rounded-md border px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wider transition-colors cursor-pointer"
|
|
15
|
-
classList={{
|
|
15
|
+
class={["flex items-center gap-1.5 self-center rounded-md border px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wider transition-colors cursor-pointer", {
|
|
16
16
|
"border-[color-mix(in_srgb,var(--ks-info,#38bdf8)_50%,transparent)] bg-[color-mix(in_srgb,var(--ks-info,#38bdf8)_15%,transparent)] text-[var(--ks-info-fg,#7dd3fc)] hover:bg-[color-mix(in_srgb,var(--ks-info,#38bdf8)_25%,transparent)]":
|
|
17
17
|
props.enabled,
|
|
18
18
|
"border-[var(--ks-input-border,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-surface,#0f0f0f)_60%,transparent)] text-[var(--ks-fg-muted,#a1a1aa)] hover:border-[color-mix(in_srgb,var(--ks-info,#38bdf8)_40%,transparent)] hover:text-[var(--ks-info-fg,#7dd3fc)]":
|
|
19
19
|
!props.enabled,
|
|
20
|
-
}}
|
|
21
|
-
|
|
20
|
+
}]}
|
|
21
|
+
|
|
22
|
+
aria-pressed={ariaTri(props.enabled)}
|
|
22
23
|
aria-label={props.enabled ? "Remove transfer fee" : "Add transfer fee"}
|
|
23
24
|
>
|
|
24
25
|
<span>Fees</span>
|
|
25
26
|
<span
|
|
26
|
-
class="inline-flex items-center justify-center"
|
|
27
|
-
|
|
27
|
+
class={["inline-flex items-center justify-center", { hidden: !props.enabled }]}
|
|
28
|
+
|
|
28
29
|
aria-hidden="true"
|
|
29
30
|
>
|
|
30
31
|
<X size={11} />
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// The picker pages the list in from the server (page/limit) and delegates the
|
|
2
2
|
// search to it, so these assert the request contract as well as the rendering.
|
|
3
|
+
import { flush } from "solid-js";
|
|
3
4
|
import { describe, expect, it, vi } from "vitest";
|
|
4
5
|
import { createSignal } from "solid-js";
|
|
5
6
|
import { fireEvent, render, waitFor } from "@solidjs/testing-library";
|
|
6
7
|
import VoucherPicker, { type VoucherOption } from "./VoucherPicker";
|
|
7
8
|
|
|
9
|
+
// Solid 2 commits writes on a microtask; flush so the next assertion sees them.
|
|
10
|
+
const click = (el: Element) => {
|
|
11
|
+
fireEvent.click(el);
|
|
12
|
+
flush();
|
|
13
|
+
};
|
|
14
|
+
|
|
8
15
|
/** Captures every requested URL and serves pages out of `rows`. */
|
|
9
16
|
function mockPagedFetch(rows: VoucherOption[]) {
|
|
10
17
|
const calls: string[] = [];
|
|
@@ -59,7 +66,7 @@ describe("VoucherPicker fetchUrl", () => {
|
|
|
59
66
|
const { getByTestId } = render(() => (
|
|
60
67
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={100} packageIds={[]} />
|
|
61
68
|
));
|
|
62
|
-
|
|
69
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
63
70
|
|
|
64
71
|
await waitFor(() => expect(calls.length).toBeGreaterThan(0));
|
|
65
72
|
expect(calls[0]).toContain("/api/vouchers");
|
|
@@ -77,7 +84,7 @@ describe("VoucherPicker fetchUrl", () => {
|
|
|
77
84
|
fetchUrl="/api/counter/vouchers"
|
|
78
85
|
/>
|
|
79
86
|
));
|
|
80
|
-
|
|
87
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
81
88
|
|
|
82
89
|
await waitFor(() => expect(calls.length).toBeGreaterThan(0));
|
|
83
90
|
expect(calls[0]).toContain("/api/counter/vouchers");
|
|
@@ -88,7 +95,7 @@ describe("VoucherPicker fetchUrl", () => {
|
|
|
88
95
|
const { getByTestId, getAllByTestId } = render(() => (
|
|
89
96
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
90
97
|
));
|
|
91
|
-
|
|
98
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
92
99
|
|
|
93
100
|
await waitFor(() =>
|
|
94
101
|
expect(getAllByTestId(/^voucher-picker-result-/).length).toBeGreaterThan(0),
|
|
@@ -109,18 +116,18 @@ describe("VoucherPicker dialog", () => {
|
|
|
109
116
|
));
|
|
110
117
|
|
|
111
118
|
expect(queryByTestId("voucher-picker-popup")).toBeNull();
|
|
112
|
-
|
|
119
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
113
120
|
|
|
114
121
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
115
122
|
expect(getByTestId("voucher-picker-popup").closest("dialog")).not.toBeNull();
|
|
116
123
|
|
|
117
124
|
// Staging a row must not reach the consumer yet; the footer no longer
|
|
118
125
|
// repeats the code (it's in the listing), so the confirm enabling is the signal.
|
|
119
|
-
|
|
126
|
+
click(getByTestId("voucher-picker-result-1"));
|
|
120
127
|
expect(onChange).not.toHaveBeenCalled();
|
|
121
128
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(false);
|
|
122
129
|
|
|
123
|
-
|
|
130
|
+
click(getByTestId("voucher-picker-confirm"));
|
|
124
131
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ id: 1, code: "SAVE20" }));
|
|
125
132
|
await waitFor(() => expect(queryByTestId("voucher-picker-popup")).toBeNull());
|
|
126
133
|
});
|
|
@@ -131,11 +138,11 @@ describe("VoucherPicker dialog", () => {
|
|
|
131
138
|
const { getByTestId, queryByTestId } = render(() => (
|
|
132
139
|
<VoucherPicker selected={null} onChange={onChange} subtotal={1000} packageIds={[]} />
|
|
133
140
|
));
|
|
134
|
-
|
|
141
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
135
142
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
click(getByTestId("voucher-picker-result-1"));
|
|
145
|
+
click(getByTestId("voucher-picker-cancel"));
|
|
139
146
|
|
|
140
147
|
expect(onChange).not.toHaveBeenCalled();
|
|
141
148
|
await waitFor(() => expect(queryByTestId("voucher-picker-popup")).toBeNull());
|
|
@@ -146,13 +153,13 @@ describe("VoucherPicker dialog", () => {
|
|
|
146
153
|
const { getByTestId } = render(() => (
|
|
147
154
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
148
155
|
));
|
|
149
|
-
|
|
156
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
150
157
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
151
158
|
|
|
152
|
-
|
|
159
|
+
click(getByTestId("voucher-picker-result-1"));
|
|
153
160
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(false);
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
click(getByTestId("voucher-picker-result-1"));
|
|
156
163
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(true);
|
|
157
164
|
expect(getByTestId("voucher-picker-draft-summary").textContent).toContain("No voucher selected");
|
|
158
165
|
});
|
|
@@ -165,7 +172,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
165
172
|
const { getByTestId, queryByTestId } = render(() => (
|
|
166
173
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
167
174
|
));
|
|
168
|
-
|
|
175
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
169
176
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
170
177
|
|
|
171
178
|
fireEvent.input(getByTestId("voucher-picker-search"), { target: { value: "partner" } });
|
|
@@ -186,14 +193,14 @@ describe("VoucherPicker dialog", () => {
|
|
|
186
193
|
const { getByTestId } = render(() => (
|
|
187
194
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
188
195
|
));
|
|
189
|
-
|
|
196
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
190
197
|
|
|
191
198
|
await waitFor(() => expect(getByTestId("voucher-picker-result-50")).toBeTruthy());
|
|
192
199
|
expect(getByTestId("voucher-picker-result-50").textContent).toContain(
|
|
193
200
|
"BISCAST ACES outreach discount",
|
|
194
201
|
);
|
|
195
202
|
|
|
196
|
-
|
|
203
|
+
click(getByTestId("voucher-picker-result-50"));
|
|
197
204
|
// The footer shows the description under the summary, beside the buttons.
|
|
198
205
|
expect(getByTestId("voucher-picker-draft-description").textContent).toContain(
|
|
199
206
|
"BISCAST ACES outreach discount",
|
|
@@ -208,7 +215,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
208
215
|
const { getByTestId, queryByTestId } = render(() => (
|
|
209
216
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
210
217
|
));
|
|
211
|
-
|
|
218
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
212
219
|
await waitFor(() => expect(getByTestId("voucher-picker-result-51")).toBeTruthy());
|
|
213
220
|
|
|
214
221
|
fireEvent.input(getByTestId("voucher-picker-search"), {
|
|
@@ -232,7 +239,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
232
239
|
const { getByTestId } = render(() => (
|
|
233
240
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
234
241
|
));
|
|
235
|
-
|
|
242
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
236
243
|
|
|
237
244
|
await waitFor(() => expect(getByTestId("voucher-picker-result-53")).toBeTruthy());
|
|
238
245
|
// Identical rows — a whitespace-only description must render nothing extra.
|
|
@@ -247,7 +254,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
247
254
|
const { getByTestId } = render(() => (
|
|
248
255
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
249
256
|
));
|
|
250
|
-
|
|
257
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
251
258
|
|
|
252
259
|
await waitFor(() => expect(getByTestId("voucher-picker-result-9")).toBeTruthy());
|
|
253
260
|
expect(getByTestId("voucher-picker-result-9").textContent).toContain("Expires in 3 days");
|
|
@@ -261,7 +268,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
261
268
|
const { getByTestId } = render(() => (
|
|
262
269
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
263
270
|
));
|
|
264
|
-
|
|
271
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
265
272
|
|
|
266
273
|
await waitFor(() => expect(getByTestId("voucher-picker-result-10")).toBeTruthy());
|
|
267
274
|
const text = getByTestId("voucher-picker-result-10").textContent ?? "";
|
|
@@ -276,7 +283,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
276
283
|
const { getByTestId } = render(() => (
|
|
277
284
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
278
285
|
));
|
|
279
|
-
|
|
286
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
280
287
|
|
|
281
288
|
await waitFor(() => expect(getByTestId("voucher-picker-result-20")).toBeTruthy());
|
|
282
289
|
expect(getByTestId("voucher-picker-result-20").textContent).toContain("3/10 used");
|
|
@@ -287,7 +294,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
287
294
|
const { getByTestId } = render(() => (
|
|
288
295
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
289
296
|
));
|
|
290
|
-
|
|
297
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
291
298
|
|
|
292
299
|
await waitFor(() => expect(getByTestId("voucher-picker-result-21")).toBeTruthy());
|
|
293
300
|
expect(getByTestId("voucher-picker-result-21").textContent).not.toContain("used");
|
|
@@ -300,7 +307,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
300
307
|
const { getByTestId, queryByTestId } = render(() => (
|
|
301
308
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
302
309
|
));
|
|
303
|
-
|
|
310
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
304
311
|
|
|
305
312
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-22")).toBeTruthy());
|
|
306
313
|
// Never selectable — it would be rejected at charge time.
|
|
@@ -313,7 +320,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
313
320
|
const { getByTestId } = render(() => (
|
|
314
321
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
315
322
|
));
|
|
316
|
-
|
|
323
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
317
324
|
|
|
318
325
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-7")).toBeTruthy());
|
|
319
326
|
expect(getByTestId("voucher-picker-inapplicable-7").textContent).toContain("minimum");
|
|
@@ -330,7 +337,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
330
337
|
packageIds={[]}
|
|
331
338
|
/>
|
|
332
339
|
));
|
|
333
|
-
|
|
340
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
334
341
|
|
|
335
342
|
await waitFor(() => expect(getByTestId("voucher-picker-result-3")).toBeTruthy());
|
|
336
343
|
// 20% of 99 and of 118, both rounded the same way the server rounds.
|
|
@@ -348,7 +355,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
348
355
|
packageIds={[]}
|
|
349
356
|
/>
|
|
350
357
|
));
|
|
351
|
-
|
|
358
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
352
359
|
|
|
353
360
|
await waitFor(() => expect(getByTestId("voucher-picker-result-4")).toBeTruthy());
|
|
354
361
|
const text = getByTestId("voucher-picker-result-4").textContent ?? "";
|
|
@@ -369,7 +376,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
369
376
|
const { getByTestId } = render(() => (
|
|
370
377
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[1]} />
|
|
371
378
|
));
|
|
372
|
-
|
|
379
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
373
380
|
|
|
374
381
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-30")).toBeTruthy());
|
|
375
382
|
expect(getByTestId("voucher-picker-inapplicable-30").textContent).toContain("minimum");
|
|
@@ -399,7 +406,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
399
406
|
packageLineages={["day-pass"]}
|
|
400
407
|
/>
|
|
401
408
|
));
|
|
402
|
-
|
|
409
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
403
410
|
await waitFor(() => expect(getByTestId("voucher-picker-result-35")).toBeTruthy());
|
|
404
411
|
});
|
|
405
412
|
|
|
@@ -420,7 +427,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
420
427
|
packageLineages={["day-pass", "single-use", "day-pass"]}
|
|
421
428
|
/>
|
|
422
429
|
));
|
|
423
|
-
|
|
430
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
424
431
|
await waitFor(() => expect(getByTestId("voucher-picker-result-55")).toBeTruthy());
|
|
425
432
|
});
|
|
426
433
|
|
|
@@ -442,7 +449,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
442
449
|
packageLineages={[null, "day-pass", "single-use"]}
|
|
443
450
|
/>
|
|
444
451
|
));
|
|
445
|
-
|
|
452
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
446
453
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-56")).toBeTruthy());
|
|
447
454
|
expect(queryByTestId("voucher-picker-result-56")).toBeNull();
|
|
448
455
|
expect(getByTestId("voucher-picker-inapplicable-56").textContent).toContain(
|
|
@@ -468,12 +475,12 @@ describe("VoucherPicker dialog", () => {
|
|
|
468
475
|
/>
|
|
469
476
|
));
|
|
470
477
|
|
|
471
|
-
|
|
478
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
472
479
|
await waitFor(() => expect(getByTestId("voucher-picker-result-57")).toBeTruthy());
|
|
473
|
-
|
|
480
|
+
click(getByTestId("voucher-picker-cancel"));
|
|
474
481
|
|
|
475
482
|
setPackageLineage("single-use");
|
|
476
|
-
|
|
483
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
477
484
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-57")).toBeTruthy());
|
|
478
485
|
expect(queryByTestId("voucher-picker-result-57")).toBeNull();
|
|
479
486
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(true);
|
|
@@ -492,11 +499,11 @@ describe("VoucherPicker dialog", () => {
|
|
|
492
499
|
/>
|
|
493
500
|
));
|
|
494
501
|
|
|
495
|
-
|
|
502
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
496
503
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-59")).toBeTruthy());
|
|
497
504
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(true);
|
|
498
505
|
|
|
499
|
-
|
|
506
|
+
click(getByTestId("voucher-picker-confirm"));
|
|
500
507
|
expect(onChange).not.toHaveBeenCalled();
|
|
501
508
|
});
|
|
502
509
|
|
|
@@ -514,7 +521,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
514
521
|
packageLineages={["day-pass"]}
|
|
515
522
|
/>
|
|
516
523
|
));
|
|
517
|
-
|
|
524
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
518
525
|
await waitFor(() => expect(getByTestId("voucher-picker-result-37")).toBeTruthy());
|
|
519
526
|
expect(queryByTestId("voucher-picker-inapplicable-37")).toBeNull();
|
|
520
527
|
expect(getByTestId("voucher-picker-result-37").textContent).toContain("ENABLED_LINEAGE");
|
|
@@ -536,7 +543,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
536
543
|
packageLineages={["single-use"]}
|
|
537
544
|
/>
|
|
538
545
|
));
|
|
539
|
-
|
|
546
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
540
547
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-39")).toBeTruthy());
|
|
541
548
|
expect(queryByTestId("voucher-picker-result-39")).toBeNull();
|
|
542
549
|
expect(getByTestId("voucher-picker-inapplicable-39").getAttribute("aria-disabled")).toBe("true");
|
|
@@ -562,7 +569,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
562
569
|
packageLineages={["single-use"]}
|
|
563
570
|
/>
|
|
564
571
|
));
|
|
565
|
-
|
|
572
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
566
573
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-36")).toBeTruthy());
|
|
567
574
|
expect(queryByTestId("voucher-picker-result-36")).toBeNull();
|
|
568
575
|
expect(getByTestId("voucher-picker-inapplicable-36").textContent).toContain(
|
|
@@ -631,7 +638,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
631
638
|
packageLineages={packageLineages}
|
|
632
639
|
/>
|
|
633
640
|
));
|
|
634
|
-
|
|
641
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
635
642
|
await waitFor(() =>
|
|
636
643
|
expect(
|
|
637
644
|
result
|
|
@@ -649,7 +656,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
649
656
|
const { getByTestId, queryByTestId } = render(() => (
|
|
650
657
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
651
658
|
));
|
|
652
|
-
|
|
659
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
653
660
|
|
|
654
661
|
await waitFor(() =>
|
|
655
662
|
expect(getByTestId("voucher-picker-popup").textContent).toContain("Permission denied"),
|
|
@@ -665,7 +672,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
665
672
|
const { getByTestId } = render(() => (
|
|
666
673
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
667
674
|
));
|
|
668
|
-
|
|
675
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
669
676
|
await waitFor(() =>
|
|
670
677
|
expect(getByTestId("voucher-picker-popup").textContent).toContain("network down"),
|
|
671
678
|
);
|
|
@@ -678,7 +685,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
678
685
|
const { getByTestId } = render(() => (
|
|
679
686
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
680
687
|
));
|
|
681
|
-
|
|
688
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
682
689
|
await waitFor(() =>
|
|
683
690
|
expect(getByTestId("voucher-picker-popup").textContent).toContain(
|
|
684
691
|
"Vouchers module isn't available",
|
|
@@ -692,12 +699,12 @@ describe("VoucherPicker dialog", () => {
|
|
|
692
699
|
<VoucherPicker selected={null} onChange={onChange} subtotal={1000} packageIds={[]} />
|
|
693
700
|
));
|
|
694
701
|
|
|
695
|
-
|
|
702
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
696
703
|
await waitFor(() => expect(getByTestId("voucher-picker-result-40")).toBeTruthy());
|
|
697
|
-
|
|
698
|
-
|
|
704
|
+
click(getByTestId("voucher-picker-result-40"));
|
|
705
|
+
click(getByTestId("voucher-picker-cancel"));
|
|
699
706
|
|
|
700
|
-
|
|
707
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
701
708
|
await waitFor(() => expect(getByTestId("voucher-picker-result-40")).toBeTruthy());
|
|
702
709
|
expect(getByTestId("voucher-picker-draft-summary").textContent).toContain("No voucher selected");
|
|
703
710
|
expect(onChange).not.toHaveBeenCalled();
|
|
@@ -711,7 +718,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
711
718
|
const { getByTestId } = render(() => (
|
|
712
719
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={100} packageIds={[]} />
|
|
713
720
|
));
|
|
714
|
-
|
|
721
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
715
722
|
await waitFor(() => expect(getByTestId("voucher-picker-popup")).toBeTruthy());
|
|
716
723
|
|
|
717
724
|
fireEvent.keyDown(getByTestId("voucher-picker-search"), { key: "Escape" });
|
|
@@ -728,9 +735,9 @@ describe("VoucherPicker applyOnSelect", () => {
|
|
|
728
735
|
const { getByTestId, queryByTestId, findByTestId } = render(() => (
|
|
729
736
|
<VoucherPicker selected={null} onChange={onChange} subtotal={100} packageIds={[]} applyOnSelect />
|
|
730
737
|
));
|
|
731
|
-
|
|
738
|
+
click(getByTestId("voucher-picker-trigger"));
|
|
732
739
|
expect(queryByTestId("voucher-picker-confirm")).toBeNull();
|
|
733
|
-
|
|
740
|
+
click(await findByTestId("voucher-picker-result-1"));
|
|
734
741
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ id: 1 }));
|
|
735
742
|
await waitFor(() => expect(queryByTestId("voucher-picker-popup")).toBeNull());
|
|
736
743
|
});
|
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
import { Modal } from "../base/Modal";
|
|
11
11
|
import { highlightMatch } from "../../utils/highlight";
|
|
12
|
-
import { createEffect, createMemo, createSignal, For, onCleanup, Show
|
|
12
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js";
|
|
13
|
+
import type { JSX } from "@solidjs/web";
|
|
13
14
|
import Ticket from "../../icons/ticket";
|
|
14
15
|
import X from "../../icons/x";
|
|
15
16
|
import Search from "../../icons/search";
|
|
16
17
|
import Loader2 from "../../icons/loader-2";
|
|
17
18
|
import CalendarClock from "../../icons/calendar-clock";
|
|
19
|
+
import { ariaBool } from "../../utils/aria";
|
|
18
20
|
|
|
19
21
|
export interface VoucherOption {
|
|
20
22
|
id: number;
|
|
@@ -262,20 +264,24 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
262
264
|
|
|
263
265
|
// Debounce the keystrokes into a server-side search, so filtering spans the
|
|
264
266
|
// whole table rather than only the pages already pulled down.
|
|
265
|
-
createEffect(
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
createEffect(
|
|
268
|
+
() => ({ q: query(), isOpen: open() }),
|
|
269
|
+
({ q, isOpen }) => {
|
|
270
|
+
if (!isOpen) return;
|
|
268
271
|
clearTimeout(debounceTimer);
|
|
269
272
|
debounceTimer = setTimeout(() => setDebouncedQuery(q.trim()), SEARCH_DEBOUNCE_MS);
|
|
270
|
-
}
|
|
273
|
+
},
|
|
274
|
+
);
|
|
271
275
|
onCleanup(() => clearTimeout(debounceTimer));
|
|
272
276
|
|
|
273
277
|
// Refetch from page 1 whenever the dialog opens or the search term settles.
|
|
274
|
-
createEffect(
|
|
275
|
-
|
|
276
|
-
|
|
278
|
+
createEffect(
|
|
279
|
+
() => ({ isOpen: open(), search: debouncedQuery() }),
|
|
280
|
+
({ isOpen, search }) => {
|
|
281
|
+
if (!isOpen) return;
|
|
277
282
|
loadPage(1, search, false);
|
|
278
|
-
}
|
|
283
|
+
},
|
|
284
|
+
);
|
|
279
285
|
|
|
280
286
|
const hasMore = createMemo(() => vouchers().length < total());
|
|
281
287
|
|
|
@@ -288,10 +294,10 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
288
294
|
// Re-created after every append — an observer only reports a CHANGE in
|
|
289
295
|
// intersection, so a sentinel that stays on screen (list still shorter than
|
|
290
296
|
// the viewport) would never fire again and paging would stall.
|
|
291
|
-
createEffect(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
297
|
+
createEffect(
|
|
298
|
+
() => ({ loadedCount: vouchers().length, isOpen: open(), el: sentinel() }),
|
|
299
|
+
({ loadedCount, isOpen, el }) => {
|
|
300
|
+
if (!isOpen || loadedCount === 0) return;
|
|
295
301
|
if (!el || typeof IntersectionObserver === "undefined") return;
|
|
296
302
|
const io = new IntersectionObserver(
|
|
297
303
|
(entries) => {
|
|
@@ -300,8 +306,9 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
300
306
|
{ rootMargin: "120px" },
|
|
301
307
|
);
|
|
302
308
|
io.observe(el);
|
|
303
|
-
|
|
304
|
-
}
|
|
309
|
+
return () => io.disconnect();
|
|
310
|
+
},
|
|
311
|
+
);
|
|
305
312
|
|
|
306
313
|
const today = () => new Date().toISOString().slice(0, 10);
|
|
307
314
|
|
|
@@ -386,10 +393,10 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
386
393
|
if (e.key === "Escape") e.stopPropagation();
|
|
387
394
|
};
|
|
388
395
|
|
|
389
|
-
createEffect(() => {
|
|
390
|
-
if (!
|
|
396
|
+
createEffect(open, (isOpen) => {
|
|
397
|
+
if (!isOpen) return;
|
|
391
398
|
document.addEventListener("keydown", swallowEscape, true);
|
|
392
|
-
|
|
399
|
+
return () => document.removeEventListener("keydown", swallowEscape, true);
|
|
393
400
|
});
|
|
394
401
|
|
|
395
402
|
const metaLine = (v: VoucherOption): string =>
|
|
@@ -406,15 +413,17 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
406
413
|
|
|
407
414
|
// The footer clamps the description to two lines; offer "More" only when the
|
|
408
415
|
// text actually overflowed. Re-measured whenever the staged description changes.
|
|
409
|
-
createEffect(
|
|
410
|
-
|
|
416
|
+
createEffect(
|
|
417
|
+
() => draftNotes(),
|
|
418
|
+
(notes) => {
|
|
411
419
|
const el = descEl;
|
|
412
420
|
if (!notes || !el) {
|
|
413
421
|
setDescOverflowing(false);
|
|
414
422
|
return;
|
|
415
423
|
}
|
|
416
424
|
setDescOverflowing(el.scrollHeight > el.clientHeight);
|
|
417
|
-
}
|
|
425
|
+
},
|
|
426
|
+
);
|
|
418
427
|
|
|
419
428
|
const expiresSoon = (v: VoucherOption): boolean => {
|
|
420
429
|
if (!v.valid_until) return false;
|
|
@@ -436,7 +445,7 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
436
445
|
props.compact ? "px-2.5 py-2" : "px-3 py-2.5"
|
|
437
446
|
} rounded-lg bg-[color-mix(in_srgb,var(--ks-border,rgba(39,39,42,0.5))_30%,transparent)] border border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_50%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_40%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_5%,transparent)] transition-colors text-sm text-left cursor-pointer disabled:cursor-not-allowed disabled:opacity-60`}
|
|
438
447
|
aria-haspopup="dialog"
|
|
439
|
-
aria-expanded={open()}
|
|
448
|
+
aria-expanded={ariaBool(open())}
|
|
440
449
|
>
|
|
441
450
|
<Ticket size={16} class="shrink-0 text-[var(--ks-fg-muted,#a1a1aa)]" />
|
|
442
451
|
<Show when={props.selected} fallback={<span class="text-[var(--ks-fg-subtle,#71717a)] italic">No voucher</span>}>
|
|
@@ -538,16 +547,16 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
538
547
|
{(v) => {
|
|
539
548
|
const selected = () => draft()?.id === v.id;
|
|
540
549
|
return (
|
|
541
|
-
<li role="option" aria-selected={selected()}>
|
|
550
|
+
<li role="option" aria-selected={ariaBool(selected())}>
|
|
542
551
|
<button
|
|
543
552
|
type="button"
|
|
544
553
|
data-testid={`voucher-picker-result-${v.id}`}
|
|
545
554
|
onClick={() => stage(v)}
|
|
546
|
-
class="w-full text-left px-3 py-3 mb-1 rounded-lg border transition-colors flex items-center gap-3 cursor-pointer border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_40%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_50%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_8%,transparent)]"
|
|
547
|
-
classList={{
|
|
555
|
+
class={["w-full text-left px-3 py-3 mb-1 rounded-lg border transition-colors flex items-center gap-3 cursor-pointer border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_40%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_50%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_8%,transparent)]", {
|
|
548
556
|
"border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_60%,transparent)] bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_12%,transparent)]":
|
|
549
557
|
selected(),
|
|
550
|
-
}}
|
|
558
|
+
}]}
|
|
559
|
+
|
|
551
560
|
>
|
|
552
561
|
<span class="flex flex-col items-center gap-1 shrink-0">
|
|
553
562
|
<Ticket size={18} class="text-[var(--ks-success-fg,#34d399)]" aria-hidden="true" />
|
|
@@ -567,7 +576,7 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
567
576
|
aria-hidden="true"
|
|
568
577
|
/>
|
|
569
578
|
</Show>
|
|
570
|
-
<span class="truncate"
|
|
579
|
+
<span class={["truncate", { "text-[var(--ks-warning-fg,#fbbf24)]": runningOut(v) }]} >
|
|
571
580
|
{metaLine(v)}
|
|
572
581
|
</span>
|
|
573
582
|
</span>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// single- and multi-select renders drive this one engine so there is exactly
|
|
4
4
|
// one copy of the mechanics.
|
|
5
5
|
|
|
6
|
-
import { createEffect, createSignal, onCleanup
|
|
6
|
+
import { createEffect, createSignal, onCleanup } from "solid-js";
|
|
7
|
+
import type { JSX } from "@solidjs/web";
|
|
7
8
|
|
|
8
9
|
const POPUP_MAX_HEIGHT = 360;
|
|
9
10
|
const POPUP_MIN_WIDTH = 320;
|
|
@@ -35,18 +36,22 @@ export function createPickerPopup<T>(cfg: {
|
|
|
35
36
|
let debounceTimer: ReturnType<typeof setTimeout> | undefined;
|
|
36
37
|
let activeFetchToken = 0;
|
|
37
38
|
|
|
38
|
-
createEffect(
|
|
39
|
-
|
|
39
|
+
createEffect(
|
|
40
|
+
query,
|
|
41
|
+
(q) => {
|
|
40
42
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
41
43
|
debounceTimer = setTimeout(() => setDebouncedQuery(q), SEARCH_DEBOUNCE_MS);
|
|
42
|
-
|
|
44
|
+
return () => {
|
|
43
45
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
);
|
|
46
49
|
|
|
47
|
-
createEffect(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
createEffect(
|
|
51
|
+
() => ({ isOpen: open(), debounced: debouncedQuery() }),
|
|
52
|
+
({ isOpen, debounced }) => {
|
|
53
|
+
if (!isOpen) return;
|
|
54
|
+
const q = debounced.trim();
|
|
50
55
|
const token = ++activeFetchToken;
|
|
51
56
|
setLoading(true);
|
|
52
57
|
setError(null);
|
|
@@ -66,7 +71,8 @@ export function createPickerPopup<T>(cfg: {
|
|
|
66
71
|
if (token !== activeFetchToken) return;
|
|
67
72
|
setLoading(false);
|
|
68
73
|
});
|
|
69
|
-
}
|
|
74
|
+
},
|
|
75
|
+
);
|
|
70
76
|
|
|
71
77
|
const close = () => {
|
|
72
78
|
setOpen(false);
|
|
@@ -106,8 +112,8 @@ export function createPickerPopup<T>(cfg: {
|
|
|
106
112
|
});
|
|
107
113
|
};
|
|
108
114
|
|
|
109
|
-
createEffect(() => {
|
|
110
|
-
if (!
|
|
115
|
+
createEffect(open, (isOpen) => {
|
|
116
|
+
if (!isOpen) return;
|
|
111
117
|
updatePosition();
|
|
112
118
|
|
|
113
119
|
const onDocClick = (e: MouseEvent) => {
|
|
@@ -128,12 +134,12 @@ export function createPickerPopup<T>(cfg: {
|
|
|
128
134
|
document.addEventListener("keydown", onEsc, true);
|
|
129
135
|
window.addEventListener("resize", onReflow);
|
|
130
136
|
window.addEventListener("scroll", onReflow, true);
|
|
131
|
-
|
|
137
|
+
return () => {
|
|
132
138
|
document.removeEventListener("mousedown", onDocClick);
|
|
133
139
|
document.removeEventListener("keydown", onEsc, true);
|
|
134
140
|
window.removeEventListener("resize", onReflow);
|
|
135
141
|
window.removeEventListener("scroll", onReflow, true);
|
|
136
|
-
}
|
|
142
|
+
};
|
|
137
143
|
});
|
|
138
144
|
|
|
139
145
|
const trimmedQuery = () => query().trim();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { fireEvent, render, screen } from "@solidjs/testing-library";
|
|
3
|
-
import type { JSX } from "
|
|
3
|
+
import type { JSX } from "@solidjs/web";
|
|
4
4
|
import { ResourcePage } from "./ResourcePage";
|
|
5
5
|
import type { ResourceRow, ResourceUiSpec } from "./spec";
|
|
6
6
|
|