@kahitsan/ksui 0.51.0-solid2.1 → 0.52.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 -91
- 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 -21
- package/src/components/composite/resource/ResourcePage.tsx +8 -23
- package/src/components/composite/resource/cells.tsx +1 -1
- package/src/icons/README.md +5 -1
- package/src/icons/artwork/bir-croc.ts +2 -0
- package/src/icons/artwork/overview.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 +2 -0
- package/src/icons/overview.tsx +4 -0
- package/src/icons/registry.ts +2 -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
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { createMemo, createSignal, For, Show } from "solid-js";
|
|
2
|
-
import
|
|
3
|
-
import { Portal } from "@solidjs/web";
|
|
1
|
+
import { createMemo, createSignal, For, Show, type JSX } from "solid-js";
|
|
2
|
+
import { Portal } from "solid-js/web";
|
|
4
3
|
import CalendarDays from "../../icons/calendar-days";
|
|
5
4
|
import ChevronDown from "../../icons/chevron-down";
|
|
6
5
|
import ChevronLeft from "../../icons/chevron-left";
|
|
7
6
|
import ChevronRight from "../../icons/chevron-right";
|
|
8
7
|
import X from "../../icons/x";
|
|
9
8
|
import { injectCSS } from "../../utils/inject-css";
|
|
10
|
-
import { ariaBool, ariaTri } from "../../utils/aria";
|
|
11
9
|
|
|
12
10
|
export type MultiPeriodGranularity = "day" | "week" | "month" | "year";
|
|
13
11
|
|
|
@@ -220,11 +218,11 @@ export default function MultiPeriodPicker(props: MultiPeriodPickerProps): JSX.El
|
|
|
220
218
|
<div class={`ksui-mpp ${props.class ?? ""}`} data-testid="multi-period-picker">
|
|
221
219
|
<div class="ksui-mpp-tabs" role="tablist" aria-label={labels().period ?? "Period"}>
|
|
222
220
|
<For each={tabOptions}>{(granularity) => (
|
|
223
|
-
<button type="button" role="tab" aria-selected={
|
|
221
|
+
<button type="button" role="tab" aria-selected={props.granularity === granularity} classList={{ "ksui-mpp-selected": props.granularity === granularity }} class="ksui-mpp-tab" onClick={() => { props.onGranularityChange(granularity); setViewYear(current.year); setViewMonth(current.month); }}>
|
|
224
222
|
{defaultLabel(granularity, labels())}
|
|
225
223
|
</button>
|
|
226
224
|
)}</For>
|
|
227
|
-
<button ref={triggerRef} type="button" class="ksui-mpp-trigger" disabled={props.disabled} aria-haspopup="dialog" aria-expanded={
|
|
225
|
+
<button ref={triggerRef} type="button" class="ksui-mpp-trigger" disabled={props.disabled} aria-haspopup="dialog" aria-expanded={open()} onClick={openPicker}>
|
|
228
226
|
<CalendarDays size={14} aria-hidden="true" /> <span>{summary()}</span><ChevronDown size={14} aria-hidden="true" />
|
|
229
227
|
</button>
|
|
230
228
|
</div>
|
|
@@ -233,18 +231,18 @@ export default function MultiPeriodPicker(props: MultiPeriodPickerProps): JSX.El
|
|
|
233
231
|
<div ref={popupRef} class="ksui-mpp-popover" style={popupStyle()} role="dialog" aria-label={labels().period ?? "Pick periods"} tabindex={-1}>
|
|
234
232
|
<Show when={props.granularity === "day"}>
|
|
235
233
|
<div class="ksui-mpp-heading"><button class="ksui-mpp-nav" type="button" aria-label="Previous month" onClick={() => shiftMonth(-1)}><ChevronLeft size={14} /></button><span>{new Date(Date.UTC(viewYear(), viewMonth() - 1, 1)).toLocaleDateString("en-US", { month: "long", year: "numeric", timeZone: "UTC" })}</span><button class="ksui-mpp-nav" type="button" aria-label="Next month" onClick={() => shiftMonth(1)}><ChevronRight size={14} /></button></div>
|
|
236
|
-
<div class="ksui-mpp-grid ksui-mpp-grid-days"><For each={["S", "M", "T", "W", "T", "F", "S"]}>{(label) => <span class="ksui-mpp-token">{label}</span>}</For><For each={days()}>{(item) => <button type="button"
|
|
234
|
+
<div class="ksui-mpp-grid ksui-mpp-grid-days"><For each={["S", "M", "T", "W", "T", "F", "S"]}>{(label) => <span class="ksui-mpp-token">{label}</span>}</For><For each={days()}>{(item) => <button type="button" classList={{ "ksui-mpp-selected": props.selected.includes(item.token) }} class="ksui-mpp-token" aria-pressed={props.selected.includes(item.token)} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div>
|
|
237
235
|
</Show>
|
|
238
236
|
<Show when={props.granularity === "week"}>
|
|
239
237
|
<div class="ksui-mpp-heading"><button class="ksui-mpp-nav" type="button" aria-label="Previous year" onClick={() => setViewYear((year) => year - 1)}><ChevronLeft size={14} /></button><span>{viewYear()}</span><button class="ksui-mpp-nav" type="button" aria-label="Next year" onClick={() => setViewYear((year) => year + 1)}><ChevronRight size={14} /></button></div>
|
|
240
|
-
<div class="ksui-mpp-months"><For each={Array.from({ length: 12 }, (_, index) => index + 1)}>{(month) => <button type="button" class=
|
|
241
|
-
<div class="ksui-mpp-week-label">Weeks</div><div class="ksui-mpp-grid"><For each={weekOptions()}>{(item) => <button type="button"
|
|
238
|
+
<div class="ksui-mpp-months"><For each={Array.from({ length: 12 }, (_, index) => index + 1)}>{(month) => <button type="button" class="ksui-mpp-month" classList={{ "ksui-mpp-selected": month === viewMonth() }} onClick={() => setViewMonth(month)}>{new Date(Date.UTC(2000, month - 1, 1)).toLocaleDateString("en-US", { month: "short", timeZone: "UTC" })}</button>}</For></div>
|
|
239
|
+
<div class="ksui-mpp-week-label">Weeks</div><div class="ksui-mpp-grid"><For each={weekOptions()}>{(item) => <button type="button" classList={{ "ksui-mpp-selected": props.selected.includes(item.token) }} class="ksui-mpp-token" aria-pressed={props.selected.includes(item.token)} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div>
|
|
242
240
|
</Show>
|
|
243
241
|
<Show when={props.granularity === "month"}>
|
|
244
242
|
<div class="ksui-mpp-heading"><button class="ksui-mpp-nav" type="button" aria-label="Previous year" onClick={() => setViewYear((year) => year - 1)}><ChevronLeft size={14} /></button><span>{viewYear()}</span><button class="ksui-mpp-nav" type="button" aria-label="Next year" onClick={() => setViewYear((year) => year + 1)}><ChevronRight size={14} /></button></div>
|
|
245
|
-
<div class="ksui-mpp-grid ksui-mpp-grid-months"><For each={monthOptions()}>{(item) => <button type="button"
|
|
243
|
+
<div class="ksui-mpp-grid ksui-mpp-grid-months"><For each={monthOptions()}>{(item) => <button type="button" classList={{ "ksui-mpp-selected": props.selected.includes(item.token) }} class="ksui-mpp-token" aria-pressed={props.selected.includes(item.token)} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div>
|
|
246
244
|
</Show>
|
|
247
|
-
<Show when={props.granularity === "year"}><div class="ksui-mpp-grid ksui-mpp-grid-years"><For each={yearOptions()}>{(item) => <button type="button"
|
|
245
|
+
<Show when={props.granularity === "year"}><div class="ksui-mpp-grid ksui-mpp-grid-years"><For each={yearOptions()}>{(item) => <button type="button" classList={{ "ksui-mpp-selected": props.selected.includes(item.token) }} class="ksui-mpp-token" aria-pressed={props.selected.includes(item.token)} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div></Show>
|
|
248
246
|
<Show when={props.selected.length > 0}><div class="ksui-mpp-chips"><For each={props.selected}>{(token) => <button type="button" class="ksui-mpp-chip ksui-mpp-selected" aria-label={`Remove ${selectedLabel(token)}`} onClick={() => toggle(token)}><span>{selectedLabel(token)}</span><X size={11} aria-hidden="true" /></button>}</For></div></Show>
|
|
249
247
|
</div>
|
|
250
248
|
</Portal>
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// want the host Button can pass it through the `action` slot, which fully
|
|
12
12
|
// replaces the built-in button.
|
|
13
13
|
|
|
14
|
-
import type { JSX } from "
|
|
15
|
-
import { Show,
|
|
14
|
+
import type { JSX } from "solid-js";
|
|
15
|
+
import { Show, splitProps } from "solid-js";
|
|
16
16
|
import { ArrowLeft } from "../../icons/index";
|
|
17
17
|
|
|
18
18
|
export interface NotFoundProps
|
|
@@ -46,8 +46,19 @@ export interface NotFoundProps
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export default function NotFound(props: NotFoundProps): JSX.Element {
|
|
49
|
-
const local = props
|
|
50
|
-
|
|
49
|
+
const [local, others] = splitProps(props, [
|
|
50
|
+
"title",
|
|
51
|
+
"heading",
|
|
52
|
+
"message",
|
|
53
|
+
"buttonText",
|
|
54
|
+
"href",
|
|
55
|
+
"onButtonClick",
|
|
56
|
+
"logo",
|
|
57
|
+
"hideButton",
|
|
58
|
+
"action",
|
|
59
|
+
"testId",
|
|
60
|
+
"class",
|
|
61
|
+
]);
|
|
51
62
|
|
|
52
63
|
const showTitle = () => local.title !== "";
|
|
53
64
|
const buttonClass =
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { Portal } from "
|
|
1
|
+
import { Portal } from "solid-js/web";
|
|
2
2
|
import { useTopLayer } from "../../utils/top-layer";
|
|
3
3
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
createEffect,
|
|
6
|
+
createMemo,
|
|
7
|
+
createSignal,
|
|
8
|
+
For,
|
|
9
|
+
onCleanup,
|
|
10
|
+
onMount,
|
|
11
|
+
Show,
|
|
12
|
+
type JSX,
|
|
13
|
+
} from "solid-js";
|
|
6
14
|
import Banknote from "../../icons/banknote";
|
|
7
15
|
import Loader2 from "../../icons/loader-2";
|
|
8
16
|
import AccountAvatar from "../base/AccountAvatar";
|
|
9
|
-
import { ariaBool } from "../../utils/aria";
|
|
10
17
|
|
|
11
18
|
export interface PaymentAccountOption {
|
|
12
19
|
id: number;
|
|
@@ -102,21 +109,19 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
102
109
|
// and Charge gating already depends on the count it reports up via
|
|
103
110
|
// onCountChange. If the picker ever needs to refetch on org switch,
|
|
104
111
|
// swap this for a createEffect tracking the active-org signal.
|
|
105
|
-
|
|
112
|
+
onMount(() => {
|
|
106
113
|
void fetchAccounts();
|
|
107
114
|
});
|
|
108
115
|
|
|
109
116
|
// Auto-select the first account once the list loads, so a single-account
|
|
110
117
|
// org doesn't have to tap to charge. Skips when something is already
|
|
111
118
|
// selected (preserves an explicit reset to null).
|
|
112
|
-
createEffect(
|
|
113
|
-
|
|
114
|
-
(
|
|
115
|
-
|
|
116
|
-
if (isLoading) return;
|
|
119
|
+
createEffect(() => {
|
|
120
|
+
if (props.selected) return;
|
|
121
|
+
if (loading()) return;
|
|
122
|
+
const first = accounts()[0];
|
|
117
123
|
if (first) props.onChange(first);
|
|
118
|
-
}
|
|
119
|
-
);
|
|
124
|
+
});
|
|
120
125
|
|
|
121
126
|
const sections = createMemo(() => groupAndSort(accounts()));
|
|
122
127
|
const noAccounts = () => !loading() && accounts().length === 0;
|
|
@@ -145,8 +150,8 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
145
150
|
});
|
|
146
151
|
};
|
|
147
152
|
|
|
148
|
-
createEffect(
|
|
149
|
-
if (!
|
|
153
|
+
createEffect(() => {
|
|
154
|
+
if (!open()) return;
|
|
150
155
|
updatePosition();
|
|
151
156
|
|
|
152
157
|
const onDocClick = (e: MouseEvent) => {
|
|
@@ -167,12 +172,12 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
167
172
|
document.addEventListener("keydown", onEsc, true);
|
|
168
173
|
window.addEventListener("resize", onReflow);
|
|
169
174
|
window.addEventListener("scroll", onReflow, true);
|
|
170
|
-
|
|
175
|
+
onCleanup(() => {
|
|
171
176
|
document.removeEventListener("mousedown", onDocClick);
|
|
172
177
|
document.removeEventListener("keydown", onEsc, true);
|
|
173
178
|
window.removeEventListener("resize", onReflow);
|
|
174
179
|
window.removeEventListener("scroll", onReflow, true);
|
|
175
|
-
};
|
|
180
|
+
});
|
|
176
181
|
});
|
|
177
182
|
|
|
178
183
|
const select = (a: PaymentAccountOption) => {
|
|
@@ -197,7 +202,7 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
197
202
|
}
|
|
198
203
|
class="w-full flex items-center gap-2 px-3 py-2.5 rounded-lg bg-[color-mix(in_srgb,var(--ks-surface-raised,#1a1a1a)_30%,transparent)] border border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_50%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_40%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_5%,transparent)] transition-colors text-sm text-left cursor-pointer disabled:cursor-not-allowed disabled:opacity-60"
|
|
199
204
|
aria-haspopup="listbox"
|
|
200
|
-
aria-expanded={
|
|
205
|
+
aria-expanded={open()}
|
|
201
206
|
>
|
|
202
207
|
<Show when={loading()} fallback={null}>
|
|
203
208
|
<Loader2 size={14} class="animate-spin text-[var(--ks-fg-subtle,#71717a)] shrink-0" aria-hidden="true" />
|
|
@@ -240,7 +245,7 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
240
245
|
<div
|
|
241
246
|
ref={(el) => {
|
|
242
247
|
popupRef = el;
|
|
243
|
-
useTopLayer(el);
|
|
248
|
+
onCleanup(useTopLayer(el));
|
|
244
249
|
}}
|
|
245
250
|
data-testid="payment-account-picker-popup"
|
|
246
251
|
class="z-[100] rounded-md border border-[var(--ks-border-strong,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-surface-raised,#1a1a1a)_95%,transparent)] backdrop-blur shadow-xl overflow-hidden flex flex-col"
|
|
@@ -281,7 +286,7 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
281
286
|
{(a) => {
|
|
282
287
|
const selected = () => props.selected?.id === a.id;
|
|
283
288
|
return (
|
|
284
|
-
<li role="option" aria-selected={
|
|
289
|
+
<li role="option" aria-selected={selected()}>
|
|
285
290
|
<button
|
|
286
291
|
type="button"
|
|
287
292
|
data-testid={`payment-account-picker-result-${a.id}`}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
createEffect,
|
|
13
13
|
For,
|
|
14
14
|
Show,
|
|
15
|
-
|
|
15
|
+
onMount,
|
|
16
16
|
} from "solid-js";
|
|
17
17
|
import ComboBox from "./ComboBox";
|
|
18
18
|
import type { ClientOption } from "./picker-types";
|
|
@@ -123,8 +123,7 @@ export default function SalesBodyEditor(props: SalesBodyEditorProps) {
|
|
|
123
123
|
const [loadError, setLoadError] = createSignal<string | null>(null);
|
|
124
124
|
const [pickerOpen, setPickerOpen] = createSignal(false);
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
void (async () => {
|
|
126
|
+
onMount(async () => {
|
|
128
127
|
try {
|
|
129
128
|
const res = await fetch("/api/packages", { credentials: "include" });
|
|
130
129
|
if (!res.ok)
|
|
@@ -140,8 +139,6 @@ export default function SalesBodyEditor(props: SalesBodyEditorProps) {
|
|
|
140
139
|
} finally {
|
|
141
140
|
setLoading(false);
|
|
142
141
|
}
|
|
143
|
-
|
|
144
|
-
})();
|
|
145
142
|
});
|
|
146
143
|
|
|
147
144
|
function addVariant(pkg: Package, variant: Variant) {
|
|
@@ -210,19 +207,19 @@ export default function SalesBodyEditor(props: SalesBodyEditorProps) {
|
|
|
210
207
|
const total = createMemo(() => Math.max(0, subtotal() - effectiveDiscount()));
|
|
211
208
|
const cartPackageIds = createMemo(() => props.items.map((l) => l.package_id));
|
|
212
209
|
|
|
213
|
-
createEffect(
|
|
214
|
-
|
|
215
|
-
({ voucher: v, subtotal: sub, cartIds }) => {
|
|
210
|
+
createEffect(() => {
|
|
211
|
+
const v = props.voucher;
|
|
216
212
|
if (!v) return;
|
|
213
|
+
const sub = subtotal();
|
|
217
214
|
const minOk = sub >= Number(v.minimum_purchase ?? 0);
|
|
218
215
|
const allowed = v.applicable_packages;
|
|
216
|
+
const cartIds = cartPackageIds();
|
|
219
217
|
const pkgsOk =
|
|
220
218
|
!allowed ||
|
|
221
219
|
allowed.length === 0 ||
|
|
222
220
|
(cartIds.length > 0 && cartIds.every((id) => allowed.includes(id)));
|
|
223
221
|
if (!minOk || !pkgsOk) props.setVoucher(null);
|
|
224
|
-
}
|
|
225
|
-
);
|
|
222
|
+
});
|
|
226
223
|
|
|
227
224
|
return (
|
|
228
225
|
<div class="rounded-lg border border-[color-mix(in_srgb,var(--ks-success,#10b981)_20%,transparent)] bg-[color-mix(in_srgb,var(--ks-success,#10b981)_5%,transparent)] p-3 space-y-3">
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js";
|
|
2
|
-
import
|
|
3
|
-
import { Portal } from "@solidjs/web";
|
|
1
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, Show, type JSX } from "solid-js";
|
|
2
|
+
import { Portal } from "solid-js/web";
|
|
4
3
|
import { useTopLayer } from "../../utils/top-layer";
|
|
5
4
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
6
5
|
import ChevronsUpDown from "../../icons/chevrons-up-down";
|
|
@@ -94,8 +93,8 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
94
93
|
});
|
|
95
94
|
};
|
|
96
95
|
|
|
97
|
-
createEffect(
|
|
98
|
-
if (!
|
|
96
|
+
createEffect(() => {
|
|
97
|
+
if (!open()) return;
|
|
99
98
|
// Initial measurement + focus + listeners.
|
|
100
99
|
updatePosition();
|
|
101
100
|
queueMicrotask(() => inputRef?.focus());
|
|
@@ -120,12 +119,12 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
120
119
|
window.addEventListener("resize", onReflow);
|
|
121
120
|
// Capture phase so we catch scrolls in every ancestor.
|
|
122
121
|
window.addEventListener("scroll", onReflow, true);
|
|
123
|
-
|
|
122
|
+
onCleanup(() => {
|
|
124
123
|
document.removeEventListener("mousedown", onDocClick);
|
|
125
124
|
document.removeEventListener("keydown", onEsc);
|
|
126
125
|
window.removeEventListener("resize", onReflow);
|
|
127
126
|
window.removeEventListener("scroll", onReflow, true);
|
|
128
|
-
};
|
|
127
|
+
});
|
|
129
128
|
});
|
|
130
129
|
|
|
131
130
|
const emptyStateLabel = () => {
|
|
@@ -153,11 +152,11 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
153
152
|
data-testid={props.triggerTestId}
|
|
154
153
|
disabled={props.disabled || busy()}
|
|
155
154
|
onClick={() => !props.disabled && setOpen((o) => !o)}
|
|
156
|
-
class={
|
|
155
|
+
class={
|
|
157
156
|
props.triggerClass ??
|
|
158
157
|
"inline-flex items-center gap-1.5 text-xs text-[var(--ks-fg,#ffffff)] bg-[color-mix(in_srgb,var(--ks-border,rgba(39,39,42,0.5))_60%,transparent)] hover:bg-[var(--ks-surface-raised,#1a1a1a)] border border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_60%,transparent)] rounded px-2 py-1 cursor-pointer transition-colors"
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
}
|
|
159
|
+
classList={{ "cursor-not-allowed opacity-60": props.disabled }}
|
|
161
160
|
title={props.disabled ? undefined : "Click to select"}
|
|
162
161
|
>
|
|
163
162
|
<span class={props.triggerLabelClass ?? "truncate max-w-[180px]"}>
|
|
@@ -174,7 +173,7 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
174
173
|
<div
|
|
175
174
|
ref={(el) => {
|
|
176
175
|
popupRef = el;
|
|
177
|
-
useTopLayer(el);
|
|
176
|
+
onCleanup(useTopLayer(el));
|
|
178
177
|
}}
|
|
179
178
|
class="z-[10000] rounded-md border border-[var(--ks-input-border,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-overlay-surface,#18181b)_95%,transparent)] backdrop-blur shadow-xl overflow-hidden flex flex-col"
|
|
180
179
|
style={popupStyle()}
|
|
@@ -203,11 +202,11 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
203
202
|
<button
|
|
204
203
|
type="button"
|
|
205
204
|
onClick={() => select(opt)}
|
|
206
|
-
class=
|
|
205
|
+
class="w-full text-left px-3 py-2 text-xs hover:bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_10%,transparent)] transition-colors flex items-center justify-between gap-2"
|
|
206
|
+
classList={{
|
|
207
207
|
"text-[var(--ks-accent,#fbbf24)]": selected(),
|
|
208
208
|
"text-[var(--ks-fg,#ffffff)]": !selected(),
|
|
209
|
-
}
|
|
210
|
-
|
|
209
|
+
}}
|
|
211
210
|
>
|
|
212
211
|
<span class="flex flex-col min-w-0">
|
|
213
212
|
<span class="font-medium truncate">{opt.label}</span>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// <Show when={revealed()}>); this component holds no fetch, no plugin state.
|
|
7
7
|
|
|
8
8
|
import type { Component } from "solid-js";
|
|
9
|
-
import { Show, createSignal,
|
|
9
|
+
import { Show, createSignal, splitProps } from "solid-js";
|
|
10
10
|
import Copy from "../../icons/copy";
|
|
11
11
|
|
|
12
12
|
export interface SecretRevealProps {
|
|
@@ -23,7 +23,7 @@ export interface SecretRevealProps {
|
|
|
23
23
|
const DEFAULT_WARNING = "Save this now - it will not be shown again.";
|
|
24
24
|
|
|
25
25
|
const SecretReveal: Component<SecretRevealProps> = (props) => {
|
|
26
|
-
const local = props;
|
|
26
|
+
const [local] = splitProps(props, ["secret", "warning", "caption", "testId"]);
|
|
27
27
|
const [copied, setCopied] = createSignal(false);
|
|
28
28
|
|
|
29
29
|
const copy = () => {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// advanced-fields toggle entirely, for a caller that locks `category` to one
|
|
8
8
|
// value and never needs EWT/sharing (e.g. a "record my own expense" surface).
|
|
9
9
|
|
|
10
|
-
import { createEffect, createSignal, Show, For } from "solid-js";
|
|
10
|
+
import { batch, createEffect, createSignal, Show, For } from "solid-js";
|
|
11
11
|
import X from "../../icons/x";
|
|
12
12
|
import Upload from "../../icons/upload";
|
|
13
13
|
import FileIcon from "../../icons/file";
|
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
createPendingFile,
|
|
45
45
|
revokePendingFile,
|
|
46
46
|
} from "../../utils/pending-file";
|
|
47
|
-
import { ariaBool } from "../../utils/aria";
|
|
48
47
|
|
|
49
48
|
export type TransactionAccount = PaymentAccountOption & {
|
|
50
49
|
balance?: number | string | null;
|
|
@@ -123,7 +122,7 @@ function payeeSecondary(p: PayeeOption): string | null {
|
|
|
123
122
|
);
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
type IconComponent = (props: { size?: number; class?: string }) => import("
|
|
125
|
+
type IconComponent = (props: { size?: number; class?: string }) => import("solid-js").JSX.Element;
|
|
127
126
|
|
|
128
127
|
const CATEGORY_TONE: Record<
|
|
129
128
|
string,
|
|
@@ -364,9 +363,10 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
364
363
|
const [selectedPayee, setSelectedPayee] = createSignal<PayeeOption | null>(
|
|
365
364
|
null
|
|
366
365
|
);
|
|
367
|
-
createEffect(
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
createEffect(() => {
|
|
367
|
+
const name = props.payee;
|
|
368
|
+
const id = props.payeeId;
|
|
369
|
+
const sel = selectedPayee();
|
|
370
370
|
if (id != null && name && !sel) {
|
|
371
371
|
setSelectedPayee({ id, name, kind: "vendor" });
|
|
372
372
|
} else if (sel && sel.name !== name) {
|
|
@@ -374,14 +374,12 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
374
374
|
} else if (!name && sel) {
|
|
375
375
|
setSelectedPayee(null);
|
|
376
376
|
}
|
|
377
|
-
}
|
|
378
|
-
);
|
|
377
|
+
});
|
|
379
378
|
// A payee picked from search already carries its tax ID; one restored from a
|
|
380
379
|
// saved row does not, so load it before deciding what to show.
|
|
381
|
-
createEffect(
|
|
382
|
-
|
|
383
|
-
(
|
|
384
|
-
if (!enabled || !sel || sel.tin !== undefined) return;
|
|
380
|
+
createEffect(() => {
|
|
381
|
+
const sel = selectedPayee();
|
|
382
|
+
if (!props.setPayeeTin || !sel || sel.tin !== undefined) return;
|
|
385
383
|
const id = sel.id;
|
|
386
384
|
loadPayee(id)
|
|
387
385
|
.then((rec) => {
|
|
@@ -390,8 +388,7 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
390
388
|
setSelectedPayee({ ...cur, tin: rec.tin ?? null, address: rec.address ?? null });
|
|
391
389
|
})
|
|
392
390
|
.catch(() => {});
|
|
393
|
-
}
|
|
394
|
-
);
|
|
391
|
+
});
|
|
395
392
|
const taxPayee = () =>
|
|
396
393
|
props.setPayeeTin && props.category !== "sale" && catConfig().showPayee
|
|
397
394
|
? selectedPayee()
|
|
@@ -416,9 +413,8 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
416
413
|
{ id: number; name: string }[]
|
|
417
414
|
>();
|
|
418
415
|
let subcategoryRequestId = 0;
|
|
419
|
-
createEffect(
|
|
420
|
-
subcategoryAppliesTo
|
|
421
|
-
(appliesTo) => {
|
|
416
|
+
createEffect(() => {
|
|
417
|
+
const appliesTo = subcategoryAppliesTo();
|
|
422
418
|
const requestId = ++subcategoryRequestId;
|
|
423
419
|
if (!appliesTo) {
|
|
424
420
|
setSubcategoryOptions(undefined);
|
|
@@ -445,8 +441,7 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
445
441
|
subcategoryCache.set(appliesTo, options);
|
|
446
442
|
if (requestId === subcategoryRequestId) setSubcategoryOptions(options);
|
|
447
443
|
});
|
|
448
|
-
}
|
|
449
|
-
);
|
|
444
|
+
});
|
|
450
445
|
|
|
451
446
|
// True once the async resource has resolved at least once. Gates the
|
|
452
447
|
// SearchableSelect mount so the loading-state placeholder shows while the
|
|
@@ -458,20 +453,12 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
458
453
|
return props.allowPayable === false ? base : [...base, "payable"];
|
|
459
454
|
};
|
|
460
455
|
|
|
461
|
-
createEffect(
|
|
462
|
-
()
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
setEnabled: props.setTransferFeeEnabled,
|
|
466
|
-
setAmount: props.setTransferFeeAmount,
|
|
467
|
-
}),
|
|
468
|
-
({ category, enabled, setEnabled, setAmount }) => {
|
|
469
|
-
if (category !== "business" && enabled) {
|
|
470
|
-
setEnabled(false);
|
|
471
|
-
setAmount("");
|
|
456
|
+
createEffect(() => {
|
|
457
|
+
if (props.category !== "business" && props.transferFeeEnabled) {
|
|
458
|
+
props.setTransferFeeEnabled(false);
|
|
459
|
+
props.setTransferFeeAmount("");
|
|
472
460
|
}
|
|
473
|
-
}
|
|
474
|
-
);
|
|
461
|
+
});
|
|
475
462
|
|
|
476
463
|
function addFiles(files: File[]) {
|
|
477
464
|
const existing = new Set(
|
|
@@ -532,8 +519,8 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
532
519
|
|
|
533
520
|
return (
|
|
534
521
|
<div
|
|
535
|
-
class=
|
|
536
|
-
|
|
522
|
+
class="relative flex flex-col flex-1 min-h-0"
|
|
523
|
+
classList={{ "ks-transaction-compact": compact(), "ks-transaction-compact-details": compact() && viewMode() === "advanced" }}
|
|
537
524
|
onDragEnter={handleDragEnter}
|
|
538
525
|
onDragLeave={handleDragLeave}
|
|
539
526
|
onDragOver={handleDragOver}
|
|
@@ -557,7 +544,7 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
557
544
|
<Button
|
|
558
545
|
type="button"
|
|
559
546
|
role="tab"
|
|
560
|
-
aria-selected={
|
|
547
|
+
aria-selected={props.category === cat}
|
|
561
548
|
data-testid={`transactions-form-category-${cat}`}
|
|
562
549
|
intent="secondary"
|
|
563
550
|
variant="ghost"
|
|
@@ -565,7 +552,8 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
565
552
|
noGlow
|
|
566
553
|
noRipple
|
|
567
554
|
noScanline
|
|
568
|
-
class={`ks-transaction-type-button ks-transaction-type-${cat}
|
|
555
|
+
class={`ks-transaction-type-button ks-transaction-type-${cat}`}
|
|
556
|
+
classList={{ "ks-transaction-type-active": props.category === cat }}
|
|
569
557
|
onClick={() => {
|
|
570
558
|
props.setCategory(cat);
|
|
571
559
|
props.setSourceAccount("");
|
|
@@ -599,8 +587,8 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
599
587
|
}}
|
|
600
588
|
class="flex flex-col flex-1 min-h-0"
|
|
601
589
|
>
|
|
602
|
-
<div class=
|
|
603
|
-
>
|
|
590
|
+
<div class="flex-1 overflow-x-hidden overflow-y-auto px-5 sm:px-6 py-5 space-y-4"
|
|
591
|
+
classList={{ "ks-transaction-compact-body": compact() }}>
|
|
604
592
|
<Show when={props.error}>
|
|
605
593
|
<div
|
|
606
594
|
class="rounded-lg border border-[color-mix(in_srgb,var(--ks-danger,#ef4444)_30%,transparent)] bg-[color-mix(in_srgb,var(--ks-danger,#ef4444)_10%,transparent)] px-3 py-2 text-sm text-[var(--ks-danger-fg,#f87171)]"
|
|
@@ -800,14 +788,16 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
800
788
|
icon={Store}
|
|
801
789
|
noun="payee"
|
|
802
790
|
placeholder={catConfig().payeePlaceholder!}
|
|
803
|
-
onChange={(p) =>
|
|
804
|
-
//
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
791
|
+
onChange={(p) =>
|
|
792
|
+
// One batch so the sync effect never sees the new name with the old id.
|
|
793
|
+
batch(() => {
|
|
794
|
+
setSelectedPayee(p);
|
|
795
|
+
props.setPayee(p ? p.name : "");
|
|
796
|
+
props.setPayeeId(p ? p.id : null);
|
|
797
|
+
props.setPayeeTin?.("");
|
|
798
|
+
props.setPayeeAddress?.("");
|
|
799
|
+
})
|
|
800
|
+
}
|
|
811
801
|
/>
|
|
812
802
|
</FormField>
|
|
813
803
|
<FormField label={props.category === "sale" ? "Invoice ID" : "Receipt / Ref #"}>
|
|
@@ -1074,7 +1064,7 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
1074
1064
|
</div>
|
|
1075
1065
|
|
|
1076
1066
|
<Show when={!props.simpleMode}>
|
|
1077
|
-
<div class=
|
|
1067
|
+
<div class="flex justify-center pt-2" classList={{ "ks-transaction-compact-details-toggle": compact() }}>
|
|
1078
1068
|
<button
|
|
1079
1069
|
type="button"
|
|
1080
1070
|
onClick={() =>
|
|
@@ -1110,18 +1100,18 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
1110
1100
|
</Show>
|
|
1111
1101
|
</div>
|
|
1112
1102
|
|
|
1113
|
-
<div class=
|
|
1114
|
-
>
|
|
1103
|
+
<div class="px-5 sm:px-6 py-4 border-t border-[color-mix(in_srgb,var(--ks-border,rgba(39,39,42,0.5))_60%,transparent)] bg-[var(--ks-bg,#0a0a0a)] flex flex-col-reverse sm:flex-row sm:items-center sm:justify-between gap-3 shrink-0"
|
|
1104
|
+
classList={{ "ks-transaction-compact-footer": compact() }}>
|
|
1115
1105
|
<div class="text-xs text-[var(--ks-fg-subtle,#71717a)]">
|
|
1116
1106
|
<span class="text-[var(--ks-fg-subtle,#71717a)]">Will record as </span>
|
|
1117
1107
|
<span
|
|
1118
|
-
class=
|
|
1108
|
+
class="font-bold"
|
|
1109
|
+
classList={{
|
|
1119
1110
|
"text-[var(--ks-success-fg,#34d399)]": props.category === "sale",
|
|
1120
1111
|
"text-[var(--ks-danger-fg,#f87171)]": props.category === "expense",
|
|
1121
1112
|
"text-[var(--ks-accent,#fbbf24)]": props.category === "payable",
|
|
1122
1113
|
"text-[var(--ks-info,#38bdf8)]": props.category === "business",
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1114
|
+
}}
|
|
1125
1115
|
>
|
|
1126
1116
|
{(CATEGORY_FORM[props.category] || CATEGORY_FORM.expense).label}
|
|
1127
1117
|
</span>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Show } from "solid-js";
|
|
2
|
-
import type { JSX } from "@solidjs/web";
|
|
1
|
+
import { Show, type JSX } from "solid-js";
|
|
3
2
|
import ArrowRightLeft from "../../icons/arrow-right-left";
|
|
4
3
|
import Plus from "../../icons/plus";
|
|
5
4
|
import AccountAvatar from "../base/AccountAvatar";
|
|
@@ -39,15 +38,15 @@ function AccountTile(p: AccountTileProps): JSX.Element {
|
|
|
39
38
|
type="button"
|
|
40
39
|
data-testid={p.tileTestId}
|
|
41
40
|
onClick={p.onEditRequest}
|
|
42
|
-
class={
|
|
41
|
+
class={`group flex flex-1 min-w-0 items-center gap-3 border px-4 py-3 text-left transition-colors cursor-pointer ${p.clipClass}`}
|
|
42
|
+
classList={{
|
|
43
43
|
"border-[color-mix(in_srgb,var(--ks-info,#38bdf8)_40%,transparent)] bg-[color-mix(in_srgb,var(--ks-info,#38bdf8)_5%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-info,#38bdf8)_10%,transparent)]":
|
|
44
44
|
isFilled() && isFrom(),
|
|
45
45
|
"border-[color-mix(in_srgb,var(--ks-warning,#f59e0b)_40%,transparent)] bg-[color-mix(in_srgb,var(--ks-warning,#f59e0b)_5%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-warning,#f59e0b)_10%,transparent)]":
|
|
46
46
|
isFilled() && !isFrom(),
|
|
47
47
|
"border-dashed border-[var(--ks-input-border,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-overlay-surface,#18181b)_40%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-warning,#f59e0b)_50%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-overlay-surface,#18181b)_60%,transparent)]":
|
|
48
48
|
!isFilled(),
|
|
49
|
-
}
|
|
50
|
-
|
|
49
|
+
}}
|
|
51
50
|
aria-label={
|
|
52
51
|
isFilled()
|
|
53
52
|
? `${isFrom() ? "Source" : "Destination"}: ${p.account!.name} — tap to change`
|
|
@@ -73,12 +72,12 @@ function AccountTile(p: AccountTileProps): JSX.Element {
|
|
|
73
72
|
</Show>
|
|
74
73
|
<div class="flex min-w-0 flex-col">
|
|
75
74
|
<span
|
|
76
|
-
class=
|
|
75
|
+
class="text-[10px] font-semibold uppercase tracking-widest"
|
|
76
|
+
classList={{
|
|
77
77
|
"text-[var(--ks-info,#38bdf8)]": isFilled() && isFrom(),
|
|
78
78
|
"text-[var(--ks-accent-hover,#fcd34d)]": isFilled() && !isFrom(),
|
|
79
79
|
"text-[var(--ks-fg-subtle,#71717a)]": !isFilled(),
|
|
80
|
-
}
|
|
81
|
-
|
|
80
|
+
}}
|
|
82
81
|
>
|
|
83
82
|
{isFrom() ? "From" : "To"}
|
|
84
83
|
</span>
|
|
@@ -99,11 +98,11 @@ function AccountTile(p: AccountTileProps): JSX.Element {
|
|
|
99
98
|
<span class="truncate">{formatPHP(a.balance!)}</span>
|
|
100
99
|
<Show when={p.delta !== 0}>
|
|
101
100
|
<span
|
|
102
|
-
class=
|
|
101
|
+
class="whitespace-nowrap font-semibold"
|
|
102
|
+
classList={{
|
|
103
103
|
"text-[var(--ks-danger-fg,#f87171)]": p.delta < 0,
|
|
104
104
|
"text-[var(--ks-success-fg,#34d399)]": p.delta > 0,
|
|
105
|
-
}
|
|
106
|
-
|
|
105
|
+
}}
|
|
107
106
|
data-testid={`transactions-form-transfer-delta-${p.role}`}
|
|
108
107
|
>
|
|
109
108
|
({p.delta > 0 ? "+" : ""}
|