@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// U7 — FlowRunner component tests: renders each node kind, calls advance with the
|
|
2
2
|
// node's input, handles a terminal node + an error.
|
|
3
|
+
import { flush } from "solid-js";
|
|
3
4
|
import { describe, expect, it, vi } from "vitest";
|
|
4
5
|
import { render, fireEvent, waitFor } from "@solidjs/testing-library";
|
|
5
6
|
import FlowRunner from "./FlowRunner";
|
|
@@ -26,6 +27,7 @@ describe("FlowRunner", () => {
|
|
|
26
27
|
/>
|
|
27
28
|
));
|
|
28
29
|
fireEvent.input(getByTestId("fr-field-amount"), { target: { value: "50" } });
|
|
30
|
+
flush(); // the input handler's write must commit before the click reads it
|
|
29
31
|
fireEvent.click(getByTestId("fr-submit"));
|
|
30
32
|
await waitFor(() => expect(advance).toHaveBeenCalledWith({ token: "abc" }, { amount: "50" }));
|
|
31
33
|
await waitFor(() => expect(getByTestId("fr-terminal")).toBeTruthy());
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// error UI. Self-contained CSS (ksui-fr-* unscoped classes + CSS custom props);
|
|
10
10
|
// no Tailwind, no host-brand classes (standalone-library rule).
|
|
11
11
|
|
|
12
|
-
import type { Component
|
|
12
|
+
import type { Component } from "solid-js";
|
|
13
|
+
import type { JSX } from "@solidjs/web";
|
|
13
14
|
import { For, Match, Show, Switch, createSignal } from "solid-js";
|
|
14
15
|
import {
|
|
15
16
|
collectsInput,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// tokens. Only the body chrome the Modal does not cover (FormErrorBanner +
|
|
14
14
|
// FormActions) is promoted.
|
|
15
15
|
|
|
16
|
-
import type { JSX } from "
|
|
16
|
+
import type { JSX } from "@solidjs/web";
|
|
17
17
|
import { Show } from "solid-js";
|
|
18
18
|
import Button from "../base/Button";
|
|
19
19
|
|
|
@@ -149,8 +149,8 @@ export default function FormAdvancedSection(props: FormAdvancedSectionProps) {
|
|
|
149
149
|
</div>
|
|
150
150
|
|
|
151
151
|
<div
|
|
152
|
-
class="rounded-lg border border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_50%,transparent)] bg-[color-mix(in_srgb,var(--ks-bg,#0a0a0a)_40%,transparent)] p-4 relative"
|
|
153
|
-
|
|
152
|
+
class={["rounded-lg border border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_50%,transparent)] bg-[color-mix(in_srgb,var(--ks-bg,#0a0a0a)_40%,transparent)] p-4 relative", { "opacity-60": !props.canShare }]}
|
|
153
|
+
|
|
154
154
|
title={
|
|
155
155
|
props.canShare
|
|
156
156
|
? undefined
|
|
@@ -177,8 +177,8 @@ export default function FormAdvancedSection(props: FormAdvancedSectionProps) {
|
|
|
177
177
|
if (!props.canShare) return;
|
|
178
178
|
props.setIsPrivate(!props.isPrivate);
|
|
179
179
|
}}
|
|
180
|
-
class="ks-theme-toggle shrink-0"
|
|
181
|
-
|
|
180
|
+
class={["ks-theme-toggle shrink-0", { "cursor-not-allowed": !props.canShare }]}
|
|
181
|
+
|
|
182
182
|
>
|
|
183
183
|
<span
|
|
184
184
|
class="ks-theme-toggle-track"
|
|
@@ -238,13 +238,13 @@ export default function FormAdvancedSection(props: FormAdvancedSectionProps) {
|
|
|
238
238
|
]);
|
|
239
239
|
}
|
|
240
240
|
}}
|
|
241
|
-
class="px-3 py-2 text-xs rounded-lg border cursor-pointer min-h-[36px] capitalize transition-colors active:opacity-80"
|
|
242
|
-
classList={{
|
|
241
|
+
class={["px-3 py-2 text-xs rounded-lg border cursor-pointer min-h-[36px] capitalize transition-colors active:opacity-80", {
|
|
243
242
|
"border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_40%,transparent)] bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_10%,transparent)] text-[var(--ks-accent,#fbbf24)]":
|
|
244
243
|
selected(),
|
|
245
244
|
"border-[var(--ks-border-strong,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-surface-raised,#1a1a1a)_50%,transparent)] text-[var(--ks-fg-muted,#a1a1aa)] hover:border-[var(--ks-border-strong,#3f3f46)]":
|
|
246
245
|
!selected(),
|
|
247
|
-
}}
|
|
246
|
+
}]}
|
|
247
|
+
|
|
248
248
|
>
|
|
249
249
|
All {role.label}s
|
|
250
250
|
<Show when={membersInRole().length > 0}>
|
|
@@ -279,23 +279,23 @@ export default function FormAdvancedSection(props: FormAdvancedSectionProps) {
|
|
|
279
279
|
props.sharedWith.includes(m.user_id) || !!coveringRole();
|
|
280
280
|
return (
|
|
281
281
|
<label
|
|
282
|
-
class="flex items-center gap-3 text-sm py-2 px-2 rounded-lg min-h-[40px] transition-colors"
|
|
283
|
-
classList={{
|
|
282
|
+
class={["flex items-center gap-3 text-sm py-2 px-2 rounded-lg min-h-[40px] transition-colors", {
|
|
284
283
|
"text-[var(--ks-fg-muted,#a1a1aa)] cursor-pointer hover:bg-[color-mix(in_srgb,var(--ks-surface-raised,#1a1a1a)_30%,transparent)] active:bg-[color-mix(in_srgb,var(--ks-surface-raised,#1a1a1a)_50%,transparent)]":
|
|
285
284
|
!coveringRole(),
|
|
286
285
|
"text-[var(--ks-fg-subtle,#71717a)] cursor-not-allowed bg-[color-mix(in_srgb,var(--ks-overlay-surface,#18181b)_40%,transparent)]":
|
|
287
286
|
!!coveringRole(),
|
|
288
|
-
}}
|
|
287
|
+
}]}
|
|
288
|
+
|
|
289
289
|
>
|
|
290
290
|
<div
|
|
291
|
-
class="w-5 h-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors"
|
|
292
|
-
classList={{
|
|
291
|
+
class={["w-5 h-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors", {
|
|
293
292
|
"border-[var(--ks-primary,#c9a961)] bg-[var(--ks-primary,#c9a961)]":
|
|
294
293
|
checked() && !coveringRole(),
|
|
295
294
|
"border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_40%,transparent)] bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_40%,transparent)]":
|
|
296
295
|
checked() && !!coveringRole(),
|
|
297
296
|
"border-[var(--ks-border-strong,#3f3f46)] bg-transparent": !checked(),
|
|
298
|
-
}}
|
|
297
|
+
}]}
|
|
298
|
+
|
|
299
299
|
>
|
|
300
300
|
<Show when={checked()}>
|
|
301
301
|
<svg
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// N intervals when N cards are on screen — the home page session
|
|
5
5
|
// manager already proved this pattern at scale, so we lift it as-is.
|
|
6
6
|
|
|
7
|
-
import type { Component
|
|
8
|
-
import {
|
|
7
|
+
import type { Component } from "solid-js";
|
|
8
|
+
import type { JSX } from "@solidjs/web";
|
|
9
|
+
import { Show, createMemo, createSignal, onCleanup, omit, untrack } from "solid-js";
|
|
9
10
|
import Clock from "../../icons/clock";
|
|
10
11
|
import Play from "../../icons/play";
|
|
11
12
|
import AlertTriangle from "../../icons/triangle-alert";
|
|
@@ -242,16 +243,8 @@ const COLOR_AMBER = "border border-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_6
|
|
|
242
243
|
const COLOR_RED = "border border-red-600/60 text-[var(--ks-danger-fg,#f87171)] hover:border-[var(--ks-danger,#ef4444)]";
|
|
243
244
|
|
|
244
245
|
const LiveTimer: Component<LiveTimerProps> = (props) => {
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
"endAt",
|
|
248
|
-
"overdue",
|
|
249
|
-
"icon",
|
|
250
|
-
"class",
|
|
251
|
-
"label",
|
|
252
|
-
"hidePercentage",
|
|
253
|
-
"totalLabel",
|
|
254
|
-
]);
|
|
246
|
+
const local = props;
|
|
247
|
+
const others = omit(props, "startAt", "endAt", "overdue", "icon", "class", "label", "hidePercentage", "totalLabel");
|
|
255
248
|
|
|
256
249
|
const timestamps = createMemo(() => {
|
|
257
250
|
const start = ensureDate(local.startAt);
|
|
@@ -264,8 +257,9 @@ const LiveTimer: Component<LiveTimerProps> = (props) => {
|
|
|
264
257
|
});
|
|
265
258
|
|
|
266
259
|
// Subscribe to the shared tickers.
|
|
267
|
-
|
|
268
|
-
const
|
|
260
|
+
// The shared ticker picks its cadence once, from the first mounted timer.
|
|
261
|
+
const { startSec, endSec, overdue } = untrack(() => ({ ...timestamps(), overdue: local.overdue ?? false }));
|
|
262
|
+
const dynamicTick = getDynamicTick(startSec, endSec, overdue);
|
|
269
263
|
const slowTick = getSlowTick();
|
|
270
264
|
|
|
271
265
|
const scenario = createMemo<Scenario>(() => {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// fetches the SIBLING clients plugin at /api/clients/:id and degrades to a
|
|
10
10
|
// non-hovering chip when that 404s.
|
|
11
11
|
|
|
12
|
-
import { For, Show, createMemo, createSignal, createUniqueId, onCleanup
|
|
12
|
+
import { For, Show, createMemo, createSignal, createUniqueId, onCleanup } from "solid-js";
|
|
13
|
+
import type { JSX } from "@solidjs/web";
|
|
13
14
|
import { highlightMatch } from "../../utils/highlight";
|
|
14
15
|
import { canAccess } from "../../utils/integration";
|
|
15
16
|
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
// /api/clients; when it 404s the popup just shows no results and the field
|
|
7
7
|
// still works as a plain notes editor.
|
|
8
8
|
|
|
9
|
-
import { Portal } from "
|
|
9
|
+
import { Portal } from "@solidjs/web";
|
|
10
10
|
import { useTopLayer } from "../../utils/top-layer";
|
|
11
11
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
12
|
-
import { createEffect, createSignal, createUniqueId, For, onCleanup,
|
|
12
|
+
import { createEffect, createSignal, createUniqueId, For, onCleanup, onSettled, Show } from "solid-js";
|
|
13
|
+
import type { JSX } from "@solidjs/web";
|
|
13
14
|
import UserRound from "../../icons/user-round";
|
|
14
15
|
import Loader2 from "../../icons/loader-2";
|
|
16
|
+
import { ariaBool } from "../../utils/aria";
|
|
15
17
|
|
|
16
18
|
const POPUP_MAX_HEIGHT = 240;
|
|
17
19
|
const POPUP_MIN_WIDTH = 280;
|
|
@@ -181,18 +183,22 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
181
183
|
});
|
|
182
184
|
};
|
|
183
185
|
|
|
184
|
-
createEffect(
|
|
185
|
-
|
|
186
|
+
createEffect(
|
|
187
|
+
query,
|
|
188
|
+
(q) => {
|
|
186
189
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
187
190
|
debounceTimer = setTimeout(() => setDebouncedQuery(q), SEARCH_DEBOUNCE_MS);
|
|
188
|
-
|
|
191
|
+
return () => {
|
|
189
192
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
);
|
|
192
196
|
|
|
193
|
-
createEffect(
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
createEffect(
|
|
198
|
+
() => ({ isOpen: open(), debounced: debouncedQuery() }),
|
|
199
|
+
({ isOpen, debounced }) => {
|
|
200
|
+
if (!isOpen) return;
|
|
201
|
+
const q = debounced.trim();
|
|
196
202
|
const token = ++activeFetchToken;
|
|
197
203
|
setLoading(true);
|
|
198
204
|
const params = new URLSearchParams({ status: "active", limit: String(FETCH_LIMIT) });
|
|
@@ -213,10 +219,11 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
213
219
|
if (token !== activeFetchToken) return;
|
|
214
220
|
setLoading(false);
|
|
215
221
|
});
|
|
216
|
-
}
|
|
222
|
+
},
|
|
223
|
+
);
|
|
217
224
|
|
|
218
|
-
createEffect(() => {
|
|
219
|
-
if (!
|
|
225
|
+
createEffect(open, (isOpen) => {
|
|
226
|
+
if (!isOpen) return;
|
|
220
227
|
updatePosition();
|
|
221
228
|
const onDocClick = (e: MouseEvent) => {
|
|
222
229
|
const t = e.target as Node;
|
|
@@ -228,15 +235,16 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
228
235
|
document.addEventListener("mousedown", onDocClick);
|
|
229
236
|
window.addEventListener("resize", onReflow);
|
|
230
237
|
window.addEventListener("scroll", onReflow, true);
|
|
231
|
-
|
|
238
|
+
return () => {
|
|
232
239
|
document.removeEventListener("mousedown", onDocClick);
|
|
233
240
|
window.removeEventListener("resize", onReflow);
|
|
234
241
|
window.removeEventListener("scroll", onReflow, true);
|
|
235
|
-
}
|
|
242
|
+
};
|
|
236
243
|
});
|
|
237
244
|
|
|
238
|
-
createEffect(
|
|
239
|
-
|
|
245
|
+
createEffect(
|
|
246
|
+
() => props.value,
|
|
247
|
+
(v) => {
|
|
240
248
|
if (!editorRef) return;
|
|
241
249
|
if (isHydrating) return;
|
|
242
250
|
if (serialize(editorRef) === v) {
|
|
@@ -247,9 +255,10 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
247
255
|
hydrateInto(editorRef, v);
|
|
248
256
|
isHydrating = false;
|
|
249
257
|
setIsEmpty(v.length === 0);
|
|
250
|
-
}
|
|
258
|
+
},
|
|
259
|
+
);
|
|
251
260
|
|
|
252
|
-
|
|
261
|
+
onSettled(() => {
|
|
253
262
|
if (!editorRef) return;
|
|
254
263
|
hydrateInto(editorRef, props.value);
|
|
255
264
|
setIsEmpty(props.value.length === 0);
|
|
@@ -393,7 +402,7 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
393
402
|
tabindex={props.disabled ? -1 : 0}
|
|
394
403
|
role="combobox"
|
|
395
404
|
aria-haspopup="listbox"
|
|
396
|
-
aria-expanded={open()}
|
|
405
|
+
aria-expanded={ariaBool(open())}
|
|
397
406
|
aria-controls={open() ? listboxId : undefined}
|
|
398
407
|
aria-autocomplete="list"
|
|
399
408
|
aria-label={props.ariaLabel}
|
|
@@ -433,7 +442,7 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
433
442
|
<div
|
|
434
443
|
ref={(el) => {
|
|
435
444
|
popupRef = el;
|
|
436
|
-
|
|
445
|
+
useTopLayer(el);
|
|
437
446
|
}}
|
|
438
447
|
data-testid="mention-popup"
|
|
439
448
|
class="z-[120] rounded-md border border-[var(--ks-border-strong,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-overlay-surface,#18181b)_95%,transparent)] backdrop-blur shadow-xl overflow-hidden flex flex-col"
|
|
@@ -460,7 +469,7 @@ export default function MentionTextarea(props: MentionTextareaProps): JSX.Elemen
|
|
|
460
469
|
>
|
|
461
470
|
<For each={results()}>
|
|
462
471
|
{(c, idx) => (
|
|
463
|
-
<li id={optionId(c.id)} role="option" aria-selected={idx() === activeIdx()}>
|
|
472
|
+
<li id={optionId(c.id)} role="option" aria-selected={ariaBool(idx() === activeIdx())}>
|
|
464
473
|
<button
|
|
465
474
|
type="button"
|
|
466
475
|
data-testid={`mention-result-${c.id}`}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { createMemo, createSignal, For, Show
|
|
2
|
-
import {
|
|
1
|
+
import { createMemo, createSignal, For, Show } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { Portal } from "@solidjs/web";
|
|
3
4
|
import CalendarDays from "../../icons/calendar-days";
|
|
4
5
|
import ChevronDown from "../../icons/chevron-down";
|
|
5
6
|
import ChevronLeft from "../../icons/chevron-left";
|
|
6
7
|
import ChevronRight from "../../icons/chevron-right";
|
|
7
8
|
import X from "../../icons/x";
|
|
8
9
|
import { injectCSS } from "../../utils/inject-css";
|
|
10
|
+
import { ariaBool, ariaTri } from "../../utils/aria";
|
|
9
11
|
|
|
10
12
|
export type MultiPeriodGranularity = "day" | "week" | "month" | "year";
|
|
11
13
|
|
|
@@ -218,11 +220,11 @@ export default function MultiPeriodPicker(props: MultiPeriodPickerProps): JSX.El
|
|
|
218
220
|
<div class={`ksui-mpp ${props.class ?? ""}`} data-testid="multi-period-picker">
|
|
219
221
|
<div class="ksui-mpp-tabs" role="tablist" aria-label={labels().period ?? "Period"}>
|
|
220
222
|
<For each={tabOptions}>{(granularity) => (
|
|
221
|
-
<button type="button" role="tab" aria-selected={props.granularity === granularity}
|
|
223
|
+
<button type="button" role="tab" aria-selected={ariaBool(props.granularity === granularity)} class={["ksui-mpp-tab", { "ksui-mpp-selected": props.granularity === granularity }]} onClick={() => { props.onGranularityChange(granularity); setViewYear(current.year); setViewMonth(current.month); }}>
|
|
222
224
|
{defaultLabel(granularity, labels())}
|
|
223
225
|
</button>
|
|
224
226
|
)}</For>
|
|
225
|
-
<button ref={triggerRef} type="button" class="ksui-mpp-trigger" disabled={props.disabled} aria-haspopup="dialog" aria-expanded={open()} onClick={openPicker}>
|
|
227
|
+
<button ref={triggerRef} type="button" class="ksui-mpp-trigger" disabled={props.disabled} aria-haspopup="dialog" aria-expanded={ariaBool(open())} onClick={openPicker}>
|
|
226
228
|
<CalendarDays size={14} aria-hidden="true" /> <span>{summary()}</span><ChevronDown size={14} aria-hidden="true" />
|
|
227
229
|
</button>
|
|
228
230
|
</div>
|
|
@@ -231,18 +233,18 @@ export default function MultiPeriodPicker(props: MultiPeriodPickerProps): JSX.El
|
|
|
231
233
|
<div ref={popupRef} class="ksui-mpp-popover" style={popupStyle()} role="dialog" aria-label={labels().period ?? "Pick periods"} tabindex={-1}>
|
|
232
234
|
<Show when={props.granularity === "day"}>
|
|
233
235
|
<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>
|
|
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"
|
|
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" class={["ksui-mpp-token", { "ksui-mpp-selected": props.selected.includes(item.token) }]} aria-pressed={ariaTri(props.selected.includes(item.token))} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div>
|
|
235
237
|
</Show>
|
|
236
238
|
<Show when={props.granularity === "week"}>
|
|
237
239
|
<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>
|
|
238
|
-
<div class="ksui-mpp-months"><For each={Array.from({ length: 12 }, (_, index) => index + 1)}>{(month) => <button type="button" class="ksui-mpp-month"
|
|
239
|
-
<div class="ksui-mpp-week-label">Weeks</div><div class="ksui-mpp-grid"><For each={weekOptions()}>{(item) => <button type="button"
|
|
240
|
+
<div class="ksui-mpp-months"><For each={Array.from({ length: 12 }, (_, index) => index + 1)}>{(month) => <button type="button" class={["ksui-mpp-month", { "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>
|
|
241
|
+
<div class="ksui-mpp-week-label">Weeks</div><div class="ksui-mpp-grid"><For each={weekOptions()}>{(item) => <button type="button" class={["ksui-mpp-token", { "ksui-mpp-selected": props.selected.includes(item.token) }]} aria-pressed={ariaTri(props.selected.includes(item.token))} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div>
|
|
240
242
|
</Show>
|
|
241
243
|
<Show when={props.granularity === "month"}>
|
|
242
244
|
<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>
|
|
243
|
-
<div class="ksui-mpp-grid ksui-mpp-grid-months"><For each={monthOptions()}>{(item) => <button type="button"
|
|
245
|
+
<div class="ksui-mpp-grid ksui-mpp-grid-months"><For each={monthOptions()}>{(item) => <button type="button" class={["ksui-mpp-token", { "ksui-mpp-selected": props.selected.includes(item.token) }]} aria-pressed={ariaTri(props.selected.includes(item.token))} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div>
|
|
244
246
|
</Show>
|
|
245
|
-
<Show when={props.granularity === "year"}><div class="ksui-mpp-grid ksui-mpp-grid-years"><For each={yearOptions()}>{(item) => <button type="button"
|
|
247
|
+
<Show when={props.granularity === "year"}><div class="ksui-mpp-grid ksui-mpp-grid-years"><For each={yearOptions()}>{(item) => <button type="button" class={["ksui-mpp-token", { "ksui-mpp-selected": props.selected.includes(item.token) }]} aria-pressed={ariaTri(props.selected.includes(item.token))} onClick={() => toggle(item.token)}>{tokenContent(item)}</button>}</For></div></Show>
|
|
246
248
|
<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>
|
|
247
249
|
</div>
|
|
248
250
|
</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 "@solidjs/web";
|
|
15
|
+
import { Show, omit } from "solid-js";
|
|
16
16
|
import { ArrowLeft } from "../../icons/index";
|
|
17
17
|
|
|
18
18
|
export interface NotFoundProps
|
|
@@ -46,19 +46,8 @@ export interface NotFoundProps
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export default function NotFound(props: NotFoundProps): JSX.Element {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
"heading",
|
|
52
|
-
"message",
|
|
53
|
-
"buttonText",
|
|
54
|
-
"href",
|
|
55
|
-
"onButtonClick",
|
|
56
|
-
"logo",
|
|
57
|
-
"hideButton",
|
|
58
|
-
"action",
|
|
59
|
-
"testId",
|
|
60
|
-
"class",
|
|
61
|
-
]);
|
|
49
|
+
const local = props;
|
|
50
|
+
const others = omit(props, "title", "heading", "message", "buttonText", "href", "onButtonClick", "logo", "hideButton", "action", "testId", "class");
|
|
62
51
|
|
|
63
52
|
const showTitle = () => local.title !== "";
|
|
64
53
|
const buttonClass =
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { Portal } from "
|
|
1
|
+
import { Portal } from "@solidjs/web";
|
|
2
2
|
import { useTopLayer } from "../../utils/top-layer";
|
|
3
3
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
createMemo,
|
|
7
|
-
createSignal,
|
|
8
|
-
For,
|
|
9
|
-
onCleanup,
|
|
10
|
-
onMount,
|
|
11
|
-
Show,
|
|
12
|
-
type JSX,
|
|
13
|
-
} from "solid-js";
|
|
4
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, onSettled, Show } from "solid-js";
|
|
5
|
+
import type { JSX } from "@solidjs/web";
|
|
14
6
|
import Banknote from "../../icons/banknote";
|
|
15
7
|
import Loader2 from "../../icons/loader-2";
|
|
16
8
|
import AccountAvatar from "../base/AccountAvatar";
|
|
9
|
+
import { ariaBool } from "../../utils/aria";
|
|
17
10
|
|
|
18
11
|
export interface PaymentAccountOption {
|
|
19
12
|
id: number;
|
|
@@ -109,19 +102,21 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
109
102
|
// and Charge gating already depends on the count it reports up via
|
|
110
103
|
// onCountChange. If the picker ever needs to refetch on org switch,
|
|
111
104
|
// swap this for a createEffect tracking the active-org signal.
|
|
112
|
-
|
|
105
|
+
onSettled(() => {
|
|
113
106
|
void fetchAccounts();
|
|
114
107
|
});
|
|
115
108
|
|
|
116
109
|
// Auto-select the first account once the list loads, so a single-account
|
|
117
110
|
// org doesn't have to tap to charge. Skips when something is already
|
|
118
111
|
// selected (preserves an explicit reset to null).
|
|
119
|
-
createEffect(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
createEffect(
|
|
113
|
+
() => ({ selected: props.selected, isLoading: loading(), first: accounts()[0] }),
|
|
114
|
+
({ selected, isLoading, first }) => {
|
|
115
|
+
if (selected) return;
|
|
116
|
+
if (isLoading) return;
|
|
123
117
|
if (first) props.onChange(first);
|
|
124
|
-
}
|
|
118
|
+
},
|
|
119
|
+
);
|
|
125
120
|
|
|
126
121
|
const sections = createMemo(() => groupAndSort(accounts()));
|
|
127
122
|
const noAccounts = () => !loading() && accounts().length === 0;
|
|
@@ -150,8 +145,8 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
150
145
|
});
|
|
151
146
|
};
|
|
152
147
|
|
|
153
|
-
createEffect(() => {
|
|
154
|
-
if (!
|
|
148
|
+
createEffect(open, (isOpen) => {
|
|
149
|
+
if (!isOpen) return;
|
|
155
150
|
updatePosition();
|
|
156
151
|
|
|
157
152
|
const onDocClick = (e: MouseEvent) => {
|
|
@@ -172,12 +167,12 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
172
167
|
document.addEventListener("keydown", onEsc, true);
|
|
173
168
|
window.addEventListener("resize", onReflow);
|
|
174
169
|
window.addEventListener("scroll", onReflow, true);
|
|
175
|
-
|
|
170
|
+
return () => {
|
|
176
171
|
document.removeEventListener("mousedown", onDocClick);
|
|
177
172
|
document.removeEventListener("keydown", onEsc, true);
|
|
178
173
|
window.removeEventListener("resize", onReflow);
|
|
179
174
|
window.removeEventListener("scroll", onReflow, true);
|
|
180
|
-
}
|
|
175
|
+
};
|
|
181
176
|
});
|
|
182
177
|
|
|
183
178
|
const select = (a: PaymentAccountOption) => {
|
|
@@ -202,7 +197,7 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
202
197
|
}
|
|
203
198
|
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"
|
|
204
199
|
aria-haspopup="listbox"
|
|
205
|
-
aria-expanded={open()}
|
|
200
|
+
aria-expanded={ariaBool(open())}
|
|
206
201
|
>
|
|
207
202
|
<Show when={loading()} fallback={null}>
|
|
208
203
|
<Loader2 size={14} class="animate-spin text-[var(--ks-fg-subtle,#71717a)] shrink-0" aria-hidden="true" />
|
|
@@ -245,7 +240,7 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
245
240
|
<div
|
|
246
241
|
ref={(el) => {
|
|
247
242
|
popupRef = el;
|
|
248
|
-
|
|
243
|
+
useTopLayer(el);
|
|
249
244
|
}}
|
|
250
245
|
data-testid="payment-account-picker-popup"
|
|
251
246
|
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"
|
|
@@ -286,7 +281,7 @@ export default function PaymentAccountPicker(props: PaymentAccountPickerProps):
|
|
|
286
281
|
{(a) => {
|
|
287
282
|
const selected = () => props.selected?.id === a.id;
|
|
288
283
|
return (
|
|
289
|
-
<li role="option" aria-selected={selected()}>
|
|
284
|
+
<li role="option" aria-selected={ariaBool(selected())}>
|
|
290
285
|
<button
|
|
291
286
|
type="button"
|
|
292
287
|
data-testid={`payment-account-picker-result-${a.id}`}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
createEffect,
|
|
13
13
|
For,
|
|
14
14
|
Show,
|
|
15
|
-
|
|
15
|
+
onSettled,
|
|
16
16
|
} from "solid-js";
|
|
17
17
|
import ComboBox from "./ComboBox";
|
|
18
18
|
import type { ClientOption } from "./picker-types";
|
|
@@ -123,7 +123,8 @@ 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
|
-
|
|
126
|
+
onSettled(() => {
|
|
127
|
+
void (async () => {
|
|
127
128
|
try {
|
|
128
129
|
const res = await fetch("/api/packages", { credentials: "include" });
|
|
129
130
|
if (!res.ok)
|
|
@@ -139,6 +140,8 @@ export default function SalesBodyEditor(props: SalesBodyEditorProps) {
|
|
|
139
140
|
} finally {
|
|
140
141
|
setLoading(false);
|
|
141
142
|
}
|
|
143
|
+
|
|
144
|
+
})();
|
|
142
145
|
});
|
|
143
146
|
|
|
144
147
|
function addVariant(pkg: Package, variant: Variant) {
|
|
@@ -207,19 +210,19 @@ export default function SalesBodyEditor(props: SalesBodyEditorProps) {
|
|
|
207
210
|
const total = createMemo(() => Math.max(0, subtotal() - effectiveDiscount()));
|
|
208
211
|
const cartPackageIds = createMemo(() => props.items.map((l) => l.package_id));
|
|
209
212
|
|
|
210
|
-
createEffect(
|
|
211
|
-
|
|
213
|
+
createEffect(
|
|
214
|
+
() => ({ voucher: props.voucher, subtotal: subtotal(), cartIds: cartPackageIds() }),
|
|
215
|
+
({ voucher: v, subtotal: sub, cartIds }) => {
|
|
212
216
|
if (!v) return;
|
|
213
|
-
const sub = subtotal();
|
|
214
217
|
const minOk = sub >= Number(v.minimum_purchase ?? 0);
|
|
215
218
|
const allowed = v.applicable_packages;
|
|
216
|
-
const cartIds = cartPackageIds();
|
|
217
219
|
const pkgsOk =
|
|
218
220
|
!allowed ||
|
|
219
221
|
allowed.length === 0 ||
|
|
220
222
|
(cartIds.length > 0 && cartIds.every((id) => allowed.includes(id)));
|
|
221
223
|
if (!minOk || !pkgsOk) props.setVoucher(null);
|
|
222
|
-
}
|
|
224
|
+
},
|
|
225
|
+
);
|
|
223
226
|
|
|
224
227
|
return (
|
|
225
228
|
<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,5 +1,6 @@
|
|
|
1
|
-
import { createEffect, createMemo, createSignal, For, onCleanup, Show
|
|
2
|
-
import {
|
|
1
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { Portal } from "@solidjs/web";
|
|
3
4
|
import { useTopLayer } from "../../utils/top-layer";
|
|
4
5
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
5
6
|
import ChevronsUpDown from "../../icons/chevrons-up-down";
|
|
@@ -93,8 +94,8 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
93
94
|
});
|
|
94
95
|
};
|
|
95
96
|
|
|
96
|
-
createEffect(() => {
|
|
97
|
-
if (!
|
|
97
|
+
createEffect(open, (isOpen) => {
|
|
98
|
+
if (!isOpen) return;
|
|
98
99
|
// Initial measurement + focus + listeners.
|
|
99
100
|
updatePosition();
|
|
100
101
|
queueMicrotask(() => inputRef?.focus());
|
|
@@ -119,12 +120,12 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
119
120
|
window.addEventListener("resize", onReflow);
|
|
120
121
|
// Capture phase so we catch scrolls in every ancestor.
|
|
121
122
|
window.addEventListener("scroll", onReflow, true);
|
|
122
|
-
|
|
123
|
+
return () => {
|
|
123
124
|
document.removeEventListener("mousedown", onDocClick);
|
|
124
125
|
document.removeEventListener("keydown", onEsc);
|
|
125
126
|
window.removeEventListener("resize", onReflow);
|
|
126
127
|
window.removeEventListener("scroll", onReflow, true);
|
|
127
|
-
}
|
|
128
|
+
};
|
|
128
129
|
});
|
|
129
130
|
|
|
130
131
|
const emptyStateLabel = () => {
|
|
@@ -152,11 +153,11 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
152
153
|
data-testid={props.triggerTestId}
|
|
153
154
|
disabled={props.disabled || busy()}
|
|
154
155
|
onClick={() => !props.disabled && setOpen((o) => !o)}
|
|
155
|
-
class={
|
|
156
|
+
class={[
|
|
156
157
|
props.triggerClass ??
|
|
157
158
|
"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"
|
|
158
|
-
}
|
|
159
|
-
|
|
159
|
+
, { "cursor-not-allowed opacity-60": props.disabled }]}
|
|
160
|
+
|
|
160
161
|
title={props.disabled ? undefined : "Click to select"}
|
|
161
162
|
>
|
|
162
163
|
<span class={props.triggerLabelClass ?? "truncate max-w-[180px]"}>
|
|
@@ -173,7 +174,7 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
173
174
|
<div
|
|
174
175
|
ref={(el) => {
|
|
175
176
|
popupRef = el;
|
|
176
|
-
|
|
177
|
+
useTopLayer(el);
|
|
177
178
|
}}
|
|
178
179
|
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"
|
|
179
180
|
style={popupStyle()}
|
|
@@ -202,11 +203,11 @@ export default function SearchableSelect(props: SearchableSelectProps): JSX.Elem
|
|
|
202
203
|
<button
|
|
203
204
|
type="button"
|
|
204
205
|
onClick={() => select(opt)}
|
|
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={{
|
|
206
|
+
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", {
|
|
207
207
|
"text-[var(--ks-accent,#fbbf24)]": selected(),
|
|
208
208
|
"text-[var(--ks-fg,#ffffff)]": !selected(),
|
|
209
|
-
}}
|
|
209
|
+
}]}
|
|
210
|
+
|
|
210
211
|
>
|
|
211
212
|
<span class="flex flex-col min-w-0">
|
|
212
213
|
<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, omit } 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
|
|
26
|
+
const local = props;
|
|
27
27
|
const [copied, setCopied] = createSignal(false);
|
|
28
28
|
|
|
29
29
|
const copy = () => {
|