@kahitsan/ksui 0.50.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 +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 +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 +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
package/README.md
CHANGED
|
@@ -87,6 +87,16 @@ You also need a SolidJS app. If you are starting fresh, set one up with
|
|
|
87
87
|
[`vite-plugin-solid`](https://github.com/solidjs/vite-plugin-solid), which is the
|
|
88
88
|
tool that compiles Solid components.
|
|
89
89
|
|
|
90
|
+
### Solid 2 prerelease
|
|
91
|
+
|
|
92
|
+
The `solid2` dist-tag carries prereleases built for Solid 2 (`solid-js` and
|
|
93
|
+
`@solidjs/web` `^2.0.0`, `vite-plugin-solid` 3, Vite 8). Pin an exact version;
|
|
94
|
+
`latest` stays on Solid 1.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
npm install @kahitsan/ksui@solid2
|
|
98
|
+
```
|
|
99
|
+
|
|
90
100
|
## A tiny usage example
|
|
91
101
|
|
|
92
102
|
```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kahitsan/ksui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0-solid2.0",
|
|
4
4
|
"description": "Standalone SolidJS UI components with original owned icon artwork. Ships source for the consumer compiler and has no runtime dependency beyond solid-js.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"test:icon-sources": "node --test scripts/icon-source-manifest.test.mjs scripts/write-icon-modules.test.mjs scripts/trace-icon-artwork.test.mjs"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"
|
|
65
|
+
"@solidjs/web": "^2.0.0",
|
|
66
|
+
"solid-js": "^2.0.0",
|
|
66
67
|
"tailwindcss": ">=3.0.0"
|
|
67
68
|
},
|
|
68
69
|
"peerDependenciesMeta": {
|
|
@@ -73,15 +74,16 @@
|
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@changesets/cli": "^2.31.0",
|
|
75
76
|
"@playwright/test": "^1.50.0",
|
|
76
|
-
"@solidjs/testing-library": "
|
|
77
|
+
"@solidjs/testing-library": "1.0.0-rc.2",
|
|
78
|
+
"@solidjs/web": "2.0.4",
|
|
77
79
|
"jsdom": "^26.0.0",
|
|
78
80
|
"potrace": "^2.1.8",
|
|
79
81
|
"sharp": "^0.35.5",
|
|
80
|
-
"solid-js": "
|
|
82
|
+
"solid-js": "2.0.4",
|
|
81
83
|
"svgo": "^4.1.0",
|
|
82
84
|
"typescript": "^5.6.0",
|
|
83
|
-
"vite": "^
|
|
84
|
-
"vite-plugin-solid": "
|
|
85
|
+
"vite": "^8.4.0",
|
|
86
|
+
"vite-plugin-solid": "3.0.0-next.27",
|
|
85
87
|
"vitest": "^4.0.0"
|
|
86
88
|
},
|
|
87
89
|
"publishConfig": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// <img> so chip sizing is identical regardless of source.
|
|
21
21
|
|
|
22
22
|
import { Show } from "solid-js";
|
|
23
|
-
import { Dynamic } from "
|
|
23
|
+
import { Dynamic } from "@solidjs/web";
|
|
24
24
|
import { getAccountIcon } from "../../utils/account-icons";
|
|
25
25
|
import { buildLogoSrc } from "../../utils/account-logo-url";
|
|
26
26
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { For, Show, createSignal, createUniqueId, onCleanup,
|
|
2
|
-
import {
|
|
1
|
+
import { For, Show, createSignal, createUniqueId, onCleanup, onSettled, type Component } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { Dynamic, Portal } from "@solidjs/web";
|
|
3
4
|
import MoreHorizontal from "../../icons/more-horizontal";
|
|
4
5
|
import { injectCSS } from "../../utils/inject-css";
|
|
5
6
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
6
7
|
import { useTopLayer } from "../../utils/top-layer";
|
|
8
|
+
import { ariaBool } from "../../utils/aria";
|
|
7
9
|
|
|
8
10
|
const STYLE_ID = "ksui-action-menu-style";
|
|
9
11
|
const STYLE_CSS = `
|
|
@@ -117,7 +119,7 @@ export default function ActionMenu(props: ActionMenuProps): JSX.Element {
|
|
|
117
119
|
event.preventDefault();
|
|
118
120
|
items[next]?.focus();
|
|
119
121
|
};
|
|
120
|
-
|
|
122
|
+
onSettled(() => {
|
|
121
123
|
document.addEventListener("keydown", onDocumentKeyDown);
|
|
122
124
|
document.addEventListener("mousedown", onDocumentPointerDown);
|
|
123
125
|
window.addEventListener("resize", updatePosition);
|
|
@@ -136,7 +138,7 @@ export default function ActionMenu(props: ActionMenuProps): JSX.Element {
|
|
|
136
138
|
type="button"
|
|
137
139
|
aria-label={props.label}
|
|
138
140
|
aria-haspopup="menu"
|
|
139
|
-
aria-expanded={open()}
|
|
141
|
+
aria-expanded={ariaBool(open())}
|
|
140
142
|
aria-controls={open() ? menuId : undefined}
|
|
141
143
|
data-testid={props.testId}
|
|
142
144
|
class={`ksui-action-menu__trigger ${props.triggerClass ?? ""}`}
|
|
@@ -155,7 +157,7 @@ export default function ActionMenu(props: ActionMenuProps): JSX.Element {
|
|
|
155
157
|
<div
|
|
156
158
|
ref={(element) => {
|
|
157
159
|
menu = element;
|
|
158
|
-
|
|
160
|
+
useTopLayer(element);
|
|
159
161
|
queueMicrotask(updatePosition);
|
|
160
162
|
}}
|
|
161
163
|
id={menuId}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Vendored into plugin remotes.
|
|
2
2
|
// Dashed "Add" tile with a small Camera / Image-or-file popover menu.
|
|
3
3
|
|
|
4
|
-
import { createSignal, onCleanup,
|
|
5
|
-
import { Portal } from "
|
|
4
|
+
import { createSignal, onCleanup, onSettled, Show } from "solid-js";
|
|
5
|
+
import { Portal } from "@solidjs/web";
|
|
6
6
|
import { useTopLayer } from "../../utils/top-layer";
|
|
7
7
|
import { usePopoverMount } from "../../utils/modal-layer";
|
|
8
8
|
import Plus from "../../icons/plus";
|
|
@@ -28,7 +28,7 @@ export default function AddAttachmentTile(props: Props) {
|
|
|
28
28
|
setPos({ top: r.bottom + 8, left: r.left });
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
onSettled(() => {
|
|
32
32
|
const handler = (e: MouseEvent) => {
|
|
33
33
|
if (btn && !btn.contains(e.target as Node) && menu && !menu.contains(e.target as Node)) {
|
|
34
34
|
setOpen(false);
|
|
@@ -37,11 +37,11 @@ export default function AddAttachmentTile(props: Props) {
|
|
|
37
37
|
document.addEventListener("click", handler);
|
|
38
38
|
window.addEventListener("scroll", place, true);
|
|
39
39
|
window.addEventListener("resize", place);
|
|
40
|
-
|
|
40
|
+
return () => {
|
|
41
41
|
document.removeEventListener("click", handler);
|
|
42
42
|
window.removeEventListener("scroll", place, true);
|
|
43
43
|
window.removeEventListener("resize", place);
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
return (
|
|
@@ -67,7 +67,7 @@ export default function AddAttachmentTile(props: Props) {
|
|
|
67
67
|
<div
|
|
68
68
|
ref={(el) => {
|
|
69
69
|
menu = el;
|
|
70
|
-
|
|
70
|
+
useTopLayer(el);
|
|
71
71
|
}}
|
|
72
72
|
style={{ top: `${pos().top}px`, left: `${pos().left}px` }}
|
|
73
73
|
class="fixed z-[60] min-w-[160px] rounded-lg border border-[var(--ks-border-strong,#3f3f46)] bg-[var(--ks-surface-raised,#1a1a1a)] shadow-2xl p-1 ks-hud-clip-top-left-bottom-right"
|
|
@@ -1,7 +1,9 @@
|
|
|
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";
|
|
6
|
+
import { ariaBool } from "../../utils/aria";
|
|
5
7
|
|
|
6
8
|
export interface BadgeSelectOption {
|
|
7
9
|
/** Stable identity of the option (what `value` matches and `onChange` emits). */
|
|
@@ -111,8 +113,8 @@ export default function BadgeSelect(props: BadgeSelectProps): JSX.Element {
|
|
|
111
113
|
});
|
|
112
114
|
};
|
|
113
115
|
|
|
114
|
-
createEffect(() => {
|
|
115
|
-
if (!
|
|
116
|
+
createEffect(open, (isOpen) => {
|
|
117
|
+
if (!isOpen) return;
|
|
116
118
|
setQuery("");
|
|
117
119
|
updatePosition();
|
|
118
120
|
if (showSearch()) queueMicrotask(() => searchRef?.focus());
|
|
@@ -132,12 +134,12 @@ export default function BadgeSelect(props: BadgeSelectProps): JSX.Element {
|
|
|
132
134
|
document.addEventListener("keydown", onEsc);
|
|
133
135
|
window.addEventListener("resize", onReflow);
|
|
134
136
|
window.addEventListener("scroll", onReflow, true);
|
|
135
|
-
|
|
137
|
+
return () => {
|
|
136
138
|
document.removeEventListener("mousedown", onDocClick);
|
|
137
139
|
document.removeEventListener("keydown", onEsc);
|
|
138
140
|
window.removeEventListener("resize", onReflow);
|
|
139
141
|
window.removeEventListener("scroll", onReflow, true);
|
|
140
|
-
}
|
|
142
|
+
};
|
|
141
143
|
});
|
|
142
144
|
|
|
143
145
|
const handleSelect = async (next: string) => {
|
|
@@ -164,7 +166,7 @@ export default function BadgeSelect(props: BadgeSelectProps): JSX.Element {
|
|
|
164
166
|
type="button"
|
|
165
167
|
data-testid={props.testId}
|
|
166
168
|
aria-haspopup="listbox"
|
|
167
|
-
aria-expanded={open()}
|
|
169
|
+
aria-expanded={ariaBool(open())}
|
|
168
170
|
disabled={props.disabled || busy()}
|
|
169
171
|
onClick={() => !props.disabled && setOpen((o) => !o)}
|
|
170
172
|
class={`text-xs font-medium px-1.5 py-0.5 rounded cursor-pointer transition-colors hover:ring-1 hover:ring-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_40%,transparent)] ${badgeClass()} ${
|
|
@@ -179,7 +181,7 @@ export default function BadgeSelect(props: BadgeSelectProps): JSX.Element {
|
|
|
179
181
|
<div
|
|
180
182
|
ref={(el) => {
|
|
181
183
|
popupRef = el;
|
|
182
|
-
|
|
184
|
+
useTopLayer(el);
|
|
183
185
|
}}
|
|
184
186
|
role="listbox"
|
|
185
187
|
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"
|
|
@@ -207,7 +209,7 @@ export default function BadgeSelect(props: BadgeSelectProps): JSX.Element {
|
|
|
207
209
|
<button
|
|
208
210
|
type="button"
|
|
209
211
|
role="option"
|
|
210
|
-
aria-selected={opt.value === props.value}
|
|
212
|
+
aria-selected={ariaBool(opt.value === props.value)}
|
|
211
213
|
onClick={() => handleSelect(opt.value)}
|
|
212
214
|
class={`w-full text-left px-3 py-2 text-xs hover:bg-[color-mix(in_srgb,var(--ks-accent,#fbbf24)_10%,transparent)] transition-colors flex items-center justify-between gap-2 ${
|
|
213
215
|
opt.value === props.value ? "text-[var(--ks-accent,#fbbf24)]" : "text-[var(--ks-fg,#ffffff)]"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render } from "@solidjs/testing-library";
|
|
3
|
+
import Button from "./Button";
|
|
4
|
+
|
|
5
|
+
describe("Button defaults", () => {
|
|
6
|
+
// Wrappers forward optional props; an explicit undefined must keep the default.
|
|
7
|
+
it("keeps the default element when `as` is forwarded as undefined", () => {
|
|
8
|
+
const { container } = render(() => <Button as={undefined}>Go</Button>);
|
|
9
|
+
expect(container.querySelector("button")).not.toBeNull();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("keeps the left icon position when forwarded as undefined", () => {
|
|
13
|
+
const Icon = () => <svg data-testid="icon" />;
|
|
14
|
+
const { container } = render(() => (
|
|
15
|
+
<Button icon={Icon} iconPosition={undefined}>
|
|
16
|
+
Go
|
|
17
|
+
</Button>
|
|
18
|
+
));
|
|
19
|
+
const html = container.querySelector("button")!.innerHTML;
|
|
20
|
+
expect(html.indexOf("<svg")).toBeGreaterThanOrEqual(0);
|
|
21
|
+
expect(html.indexOf("<svg")).toBeLessThan(html.indexOf("Go"));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -11,18 +11,9 @@
|
|
|
11
11
|
// injected once per page via a runtime <style> tag and referenced with plain,
|
|
12
12
|
// unscoped class names so the bundle stays self-contained.
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onCleanup,
|
|
18
|
-
createMemo,
|
|
19
|
-
mergeProps,
|
|
20
|
-
Show,
|
|
21
|
-
For,
|
|
22
|
-
type JSX,
|
|
23
|
-
type Component,
|
|
24
|
-
} from "solid-js";
|
|
25
|
-
import { Dynamic } from "solid-js/web";
|
|
14
|
+
import { omit, createSignal, onCleanup, createMemo, merge, Show, For, type Component } from "solid-js";
|
|
15
|
+
import type { JSX } from "@solidjs/web";
|
|
16
|
+
import { Dynamic } from "@solidjs/web";
|
|
26
17
|
import { injectCSS } from "../../utils/inject-css";
|
|
27
18
|
|
|
28
19
|
const BUTTON_STYLE_ID = "ks-button-inline-style";
|
|
@@ -242,37 +233,40 @@ interface Ripple {
|
|
|
242
233
|
const Button = (props: ButtonProps): JSX.Element => {
|
|
243
234
|
ensureButtonStyle();
|
|
244
235
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
size: "md" as ButtonSize,
|
|
251
|
-
noRipple: false,
|
|
252
|
-
noScanline: false,
|
|
253
|
-
noGlow: false,
|
|
254
|
-
noPulse: false,
|
|
255
|
-
iconPosition: "left" as const,
|
|
236
|
+
// Getters, not merge defaults: Solid 2 merge lets an explicit `undefined`
|
|
237
|
+
// (a wrapper forwarding an optional prop) override the default.
|
|
238
|
+
const merged = merge(props, {
|
|
239
|
+
get as() {
|
|
240
|
+
return props.as ?? ("button" as ButtonProps["as"]);
|
|
256
241
|
},
|
|
257
|
-
|
|
258
|
-
|
|
242
|
+
get intent() {
|
|
243
|
+
return props.intent ?? ("primary" as ButtonIntent);
|
|
244
|
+
},
|
|
245
|
+
get variant() {
|
|
246
|
+
return props.variant ?? ("clip1" as ButtonVariant);
|
|
247
|
+
},
|
|
248
|
+
get size() {
|
|
249
|
+
return props.size ?? ("md" as ButtonSize);
|
|
250
|
+
},
|
|
251
|
+
get noRipple() {
|
|
252
|
+
return props.noRipple ?? false;
|
|
253
|
+
},
|
|
254
|
+
get noScanline() {
|
|
255
|
+
return props.noScanline ?? false;
|
|
256
|
+
},
|
|
257
|
+
get noGlow() {
|
|
258
|
+
return props.noGlow ?? false;
|
|
259
|
+
},
|
|
260
|
+
get noPulse() {
|
|
261
|
+
return props.noPulse ?? false;
|
|
262
|
+
},
|
|
263
|
+
get iconPosition() {
|
|
264
|
+
return props.iconPosition ?? ("left" as const);
|
|
265
|
+
},
|
|
266
|
+
});
|
|
259
267
|
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
"intent",
|
|
263
|
-
"variant",
|
|
264
|
-
"size",
|
|
265
|
-
"noRipple",
|
|
266
|
-
"noScanline",
|
|
267
|
-
"noGlow",
|
|
268
|
-
"noPulse",
|
|
269
|
-
"icon",
|
|
270
|
-
"iconPosition",
|
|
271
|
-
"class",
|
|
272
|
-
"children",
|
|
273
|
-
"onClick",
|
|
274
|
-
"disabled",
|
|
275
|
-
]);
|
|
268
|
+
const local = merged;
|
|
269
|
+
const others = omit(merged, "as", "intent", "variant", "size", "noRipple", "noScanline", "noGlow", "noPulse", "icon", "iconPosition", "class", "children", "onClick", "disabled");
|
|
276
270
|
|
|
277
271
|
const [ripples, setRipples] = createSignal<Ripple[]>([]);
|
|
278
272
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Vendored into plugin remotes.
|
|
2
2
|
// getUserMedia camera capture modal. Button is ksui's own base primitive.
|
|
3
3
|
|
|
4
|
-
import { createSignal, onCleanup,
|
|
4
|
+
import { createSignal, onCleanup, onSettled, Show } from "solid-js";
|
|
5
5
|
import Button from "./Button";
|
|
6
6
|
import Camera from "../../icons/camera";
|
|
7
7
|
import X from "../../icons/x";
|
|
@@ -18,7 +18,8 @@ export default function CameraCapture(props: Props) {
|
|
|
18
18
|
const [error, setError] = createSignal("");
|
|
19
19
|
const [captured, setCaptured] = createSignal<string | null>(null);
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
onSettled(() => {
|
|
22
|
+
void (async () => {
|
|
22
23
|
stream()
|
|
23
24
|
?.getTracks()
|
|
24
25
|
.forEach((t) => t.stop());
|
|
@@ -35,6 +36,8 @@ export default function CameraCapture(props: Props) {
|
|
|
35
36
|
} catch {
|
|
36
37
|
setError("Could not access camera. Check permissions or try the Browse button instead.");
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
})();
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
onCleanup(() => {
|
|
@@ -26,18 +26,8 @@
|
|
|
26
26
|
// `base/` (and is re-exported as base) to preserve its existing import path —
|
|
27
27
|
// the only ksui dependency is DatePicker, itself a self-contained primitive.
|
|
28
28
|
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
createSignal,
|
|
32
|
-
createMemo,
|
|
33
|
-
createEffect,
|
|
34
|
-
on,
|
|
35
|
-
untrack,
|
|
36
|
-
For,
|
|
37
|
-
Show,
|
|
38
|
-
type JSX,
|
|
39
|
-
type ParentComponent,
|
|
40
|
-
} from "solid-js";
|
|
29
|
+
import { createSignal, createMemo, createEffect, untrack, For, Show, type ParentComponent } from "solid-js";
|
|
30
|
+
import type { JSX } from "@solidjs/web";
|
|
41
31
|
import Search from "../../icons/search";
|
|
42
32
|
import Filter from "../../icons/filter";
|
|
43
33
|
import ChevronLeft from "../../icons/chevron-left";
|
|
@@ -401,48 +391,45 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
401
391
|
props.onRefetch?.({
|
|
402
392
|
refetch: () => triggerFetch(),
|
|
403
393
|
resetAndRefetch: () => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
triggerFetch();
|
|
408
|
-
});
|
|
394
|
+
setCurrentPage(1);
|
|
395
|
+
resetLoadMore();
|
|
396
|
+
triggerFetch();
|
|
409
397
|
},
|
|
410
398
|
});
|
|
411
399
|
|
|
412
400
|
// Watch refetchKey — when it changes, reset to page 1 and refetch.
|
|
413
401
|
createEffect(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
()
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
});
|
|
422
|
-
},
|
|
423
|
-
{ defer: true },
|
|
424
|
-
),
|
|
402
|
+
() => props.refetchKey?.(),
|
|
403
|
+
() => {
|
|
404
|
+
setCurrentPage(1);
|
|
405
|
+
resetLoadMore();
|
|
406
|
+
triggerFetch();
|
|
407
|
+
},
|
|
408
|
+
{ defer: true },
|
|
425
409
|
);
|
|
426
410
|
|
|
427
|
-
createEffect(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
411
|
+
createEffect(
|
|
412
|
+
() => {
|
|
413
|
+
void fetchTrigger(); // track
|
|
414
|
+
const fn = props.fetchFn;
|
|
415
|
+
if (!fn) return undefined;
|
|
416
|
+
const page = currentPage();
|
|
417
|
+
const limit = itemsPerPage();
|
|
418
|
+
const params: FetchParams = {
|
|
419
|
+
page,
|
|
420
|
+
limit,
|
|
421
|
+
search: searchTerm(),
|
|
422
|
+
sortBy: sortBy(),
|
|
423
|
+
sortDir: sortDir(),
|
|
424
|
+
dateFilter: props.dateRangeMode ? null : dateFilter(),
|
|
425
|
+
dateFrom: props.dateRangeMode ? dateFrom() : null,
|
|
426
|
+
dateTo: props.dateRangeMode ? dateTo() : null,
|
|
427
|
+
};
|
|
428
|
+
return { fn, params, page, limit, lm: loadMoreMode(), epoch: loadEpoch() };
|
|
429
|
+
},
|
|
430
|
+
(request) => {
|
|
431
|
+
if (!request) return;
|
|
432
|
+
const { fn, params, page, limit, lm, epoch } = request;
|
|
446
433
|
|
|
447
434
|
if (lm) {
|
|
448
435
|
const key = `${page}:${epoch}`;
|
|
@@ -491,7 +478,8 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
491
478
|
}
|
|
492
479
|
})
|
|
493
480
|
.finally(() => setLoading(false));
|
|
494
|
-
|
|
481
|
+
},
|
|
482
|
+
);
|
|
495
483
|
|
|
496
484
|
// ---- Auto-load (loadMore mode) ----
|
|
497
485
|
//
|
|
@@ -502,31 +490,32 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
502
490
|
// network fetch. The autoLoadCount cap protects a degenerate grouping from
|
|
503
491
|
// chaining to the end of the dataset.
|
|
504
492
|
createEffect(
|
|
505
|
-
|
|
493
|
+
() => ({ consumed: apiConsumed(), isLoading: loading() }),
|
|
494
|
+
({ isLoading }) => {
|
|
506
495
|
if (!loadMoreMode()) return;
|
|
507
|
-
if (
|
|
496
|
+
if (initialized() === false) return;
|
|
508
497
|
if (isLoading) return;
|
|
509
|
-
const visible =
|
|
510
|
-
if (visible >=
|
|
511
|
-
if (
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
});
|
|
518
|
-
}),
|
|
498
|
+
const visible = paginatedData().length;
|
|
499
|
+
if (visible >= loadTarget()) return;
|
|
500
|
+
if (apiConsumed() >= totalRecords()) return;
|
|
501
|
+
if (autoLoadCount() >= AUTO_LOAD_CAP) return;
|
|
502
|
+
setAutoLoadCount((c) => c + 1);
|
|
503
|
+
setCurrentPage((p) => p + 1);
|
|
504
|
+
triggerFetch();
|
|
505
|
+
},
|
|
519
506
|
);
|
|
520
507
|
|
|
521
508
|
// ---- Client-side data ----
|
|
522
509
|
|
|
523
|
-
createEffect(
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
510
|
+
createEffect(
|
|
511
|
+
() => (isServerSide() ? undefined : props.data || []),
|
|
512
|
+
(d) => {
|
|
513
|
+
if (!d) return;
|
|
514
|
+
setTableData(d as T[]);
|
|
515
|
+
setTotalRecords(d.length);
|
|
516
|
+
setInitialized(true);
|
|
517
|
+
},
|
|
518
|
+
);
|
|
530
519
|
|
|
531
520
|
// Post-fetch row transform. No-op passthrough when no transform is supplied.
|
|
532
521
|
const transformedData = createMemo(() => {
|
|
@@ -605,30 +594,24 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
605
594
|
// ---- Handlers ----
|
|
606
595
|
|
|
607
596
|
function handleDateFilter(date: string | null) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
if (isServerSide()) triggerFetch();
|
|
613
|
-
});
|
|
597
|
+
setDateFilter(date);
|
|
598
|
+
setCurrentPage(1);
|
|
599
|
+
resetLoadMore();
|
|
600
|
+
if (isServerSide()) triggerFetch();
|
|
614
601
|
}
|
|
615
602
|
|
|
616
603
|
function handleDateRangeFilter(range: { start: string | null; end: string | null }) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
if (isServerSide()) triggerFetch();
|
|
623
|
-
});
|
|
604
|
+
setDateFrom(range.start);
|
|
605
|
+
setDateTo(range.end);
|
|
606
|
+
setCurrentPage(1);
|
|
607
|
+
resetLoadMore();
|
|
608
|
+
if (isServerSide()) triggerFetch();
|
|
624
609
|
}
|
|
625
610
|
|
|
626
611
|
function handleSearch(value: string) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
resetLoadMore();
|
|
631
|
-
});
|
|
612
|
+
setSearchTerm(value);
|
|
613
|
+
setCurrentPage(1);
|
|
614
|
+
resetLoadMore();
|
|
632
615
|
if (isServerSide()) {
|
|
633
616
|
clearTimeout(debounceTimer);
|
|
634
617
|
debounceTimer = setTimeout(triggerFetch, debounceDelay());
|
|
@@ -637,17 +620,15 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
637
620
|
|
|
638
621
|
function handleSort(key: string) {
|
|
639
622
|
if (!ordering()) return;
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if (isServerSide()) triggerFetch();
|
|
650
|
-
});
|
|
623
|
+
if (sortBy() === key) {
|
|
624
|
+
setSortDir((d) => (d === "asc" ? "desc" : "asc"));
|
|
625
|
+
} else {
|
|
626
|
+
setSortBy(key);
|
|
627
|
+
setSortDir("desc");
|
|
628
|
+
}
|
|
629
|
+
setCurrentPage(1);
|
|
630
|
+
resetLoadMore();
|
|
631
|
+
if (isServerSide()) triggerFetch();
|
|
651
632
|
}
|
|
652
633
|
|
|
653
634
|
function handlePageChange(page: number) {
|
|
@@ -656,23 +637,19 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
656
637
|
}
|
|
657
638
|
|
|
658
639
|
function handlePageSize(size: number) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (isServerSide()) triggerFetch();
|
|
664
|
-
});
|
|
640
|
+
setItemsPerPage(size);
|
|
641
|
+
setCurrentPage(1);
|
|
642
|
+
resetLoadMore();
|
|
643
|
+
if (isServerSide()) triggerFetch();
|
|
665
644
|
}
|
|
666
645
|
|
|
667
646
|
function handleShowMore() {
|
|
668
647
|
if (!loadMoreMode() || loading()) return;
|
|
669
648
|
if (apiConsumed() >= totalRecords()) return;
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
triggerFetch();
|
|
675
|
-
});
|
|
649
|
+
setCurrentPage((p) => p + 1);
|
|
650
|
+
setAutoLoadCount(0);
|
|
651
|
+
setPendingLoadTargetBump(true);
|
|
652
|
+
triggerFetch();
|
|
676
653
|
}
|
|
677
654
|
|
|
678
655
|
// ---- Render helpers ----
|
|
@@ -823,7 +800,7 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
823
800
|
{/* Empty state */}
|
|
824
801
|
<Show when={initialized() && !loading() && paginatedData().length === 0}>
|
|
825
802
|
<tr>
|
|
826
|
-
<td
|
|
803
|
+
<td colspan={columns().length} class="ksui-datatable-empty">
|
|
827
804
|
{searchTerm()
|
|
828
805
|
? props.noResultsMessage || "No results found."
|
|
829
806
|
: props.emptyMessage || "No data available."}
|
|
@@ -839,8 +816,8 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
839
816
|
return (
|
|
840
817
|
<>
|
|
841
818
|
<tr
|
|
842
|
-
class="ksui-datatable-row"
|
|
843
|
-
|
|
819
|
+
class={["ksui-datatable-row", { "ksui-datatable-row-clickable": !!props.onRowClick }]}
|
|
820
|
+
|
|
844
821
|
onClick={() => props.onRowClick?.(row)}
|
|
845
822
|
>
|
|
846
823
|
<For each={columns()}>
|
|
@@ -860,7 +837,7 @@ export function DataTable<T extends DataTableRow>(props: DataTableProps<T>): JSX
|
|
|
860
837
|
class="ksui-datatable-expansion-row"
|
|
861
838
|
data-testid="datatable-expansion-row"
|
|
862
839
|
>
|
|
863
|
-
<td class="ksui-datatable-expansion-td"
|
|
840
|
+
<td class="ksui-datatable-expansion-td" colspan={columns().length}>
|
|
864
841
|
{expansion()}
|
|
865
842
|
</td>
|
|
866
843
|
</tr>
|