@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.
Files changed (84) hide show
  1. package/README.md +0 -10
  2. package/package.json +6 -8
  3. package/src/components/base/AccountAvatar.tsx +1 -1
  4. package/src/components/base/ActionMenu.tsx +5 -7
  5. package/src/components/base/AddAttachmentTile.tsx +6 -6
  6. package/src/components/base/BadgeSelect.tsx +9 -11
  7. package/src/components/base/Button.tsx +41 -35
  8. package/src/components/base/CameraCapture.tsx +2 -5
  9. package/src/components/base/CopyButton.tsx +1 -2
  10. package/src/components/base/DataTable.tsx +112 -91
  11. package/src/components/base/DatePicker.tsx +17 -15
  12. package/src/components/base/DateTile.tsx +12 -14
  13. package/src/components/base/Dropdown.tsx +5 -6
  14. package/src/components/base/ExistingAttachmentTile.test.tsx +3 -3
  15. package/src/components/base/ExistingAttachmentTile.tsx +4 -6
  16. package/src/components/base/EyebrowBadge.tsx +1 -2
  17. package/src/components/base/FormErrorBanner.tsx +1 -2
  18. package/src/components/base/FormField.tsx +1 -1
  19. package/src/components/base/ImageCropper.tsx +3 -3
  20. package/src/components/base/ImageViewer.test.tsx +0 -2
  21. package/src/components/base/ImageViewer.tsx +3 -4
  22. package/src/components/base/KpiCard.tsx +2 -3
  23. package/src/components/base/Modal.test.tsx +2 -3
  24. package/src/components/base/Modal.tsx +12 -11
  25. package/src/components/base/ModalHeader.tsx +1 -2
  26. package/src/components/base/MonthCalendar.tsx +1 -2
  27. package/src/components/base/MultiSelectGroup.tsx +5 -7
  28. package/src/components/base/ProgressBar.tsx +17 -8
  29. package/src/components/base/RadioCardGroup.tsx +12 -14
  30. package/src/components/base/SectionHeading.tsx +1 -2
  31. package/src/components/base/SegmentedFilter.tsx +8 -10
  32. package/src/components/base/SocialLinksBar.tsx +1 -2
  33. package/src/components/base/StatusIndicator.tsx +1 -2
  34. package/src/components/base/StatusPill.tsx +1 -1
  35. package/src/components/base/TagPill.tsx +1 -1
  36. package/src/components/base/ThemeToggle.tsx +11 -5
  37. package/src/components/base/Tooltip.tsx +1 -2
  38. package/src/components/composite/AccountRadioPicker.tsx +11 -14
  39. package/src/components/composite/ComboBox.tsx +13 -18
  40. package/src/components/composite/CustomRenderer.tsx +1 -1
  41. package/src/components/composite/FileField.tsx +3 -6
  42. package/src/components/composite/FlowGraph.tsx +12 -15
  43. package/src/components/composite/FlowRunner.test.tsx +0 -2
  44. package/src/components/composite/FlowRunner.tsx +1 -2
  45. package/src/components/composite/FormActions.tsx +1 -1
  46. package/src/components/composite/FormAdvancedSection.tsx +13 -13
  47. package/src/components/composite/LiveTimer.tsx +14 -8
  48. package/src/components/composite/MarkdownNotes.tsx +1 -2
  49. package/src/components/composite/MentionTextarea.tsx +22 -31
  50. package/src/components/composite/MultiPeriodPicker.tsx +9 -11
  51. package/src/components/composite/NotFound.tsx +15 -4
  52. package/src/components/composite/PaymentAccountPicker.tsx +24 -19
  53. package/src/components/composite/SalesBodyEditor.tsx +7 -10
  54. package/src/components/composite/SearchableSelect.tsx +13 -14
  55. package/src/components/composite/SecretReveal.tsx +2 -2
  56. package/src/components/composite/TransactionForm.tsx +42 -52
  57. package/src/components/composite/TransferAccountsPicker.tsx +10 -11
  58. package/src/components/composite/TransferFeeChip.tsx +6 -7
  59. package/src/components/composite/VoucherPicker.test.tsx +48 -55
  60. package/src/components/composite/VoucherPicker.tsx +27 -36
  61. package/src/components/composite/picker-engine.ts +14 -20
  62. package/src/components/composite/resource/ResourcePage.test.tsx +1 -21
  63. package/src/components/composite/resource/ResourcePage.tsx +8 -23
  64. package/src/components/composite/resource/cells.tsx +1 -1
  65. package/src/icons/README.md +5 -1
  66. package/src/icons/artwork/bir-croc.ts +2 -0
  67. package/src/icons/artwork/overview.ts +2 -0
  68. package/src/icons/bir-croc.tsx +4 -0
  69. package/src/icons/create-artwork-icon.test.tsx +1 -4
  70. package/src/icons/create-artwork-icon.tsx +24 -10
  71. package/src/icons/index.ts +2 -0
  72. package/src/icons/overview.tsx +4 -0
  73. package/src/icons/registry.ts +2 -0
  74. package/src/utils/account-icons.ts +1 -2
  75. package/src/utils/accounts-index.tsx +5 -8
  76. package/src/utils/confirm.tsx +1 -1
  77. package/src/utils/dom.ts +6 -7
  78. package/src/utils/highlight.tsx +1 -1
  79. package/src/utils/modal-layer.ts +3 -3
  80. package/src/utils/object-url-resource.ts +8 -11
  81. package/src/utils/top-layer.ts +8 -9
  82. package/src/components/base/Button.test.tsx +0 -23
  83. package/src/utils/aria.ts +0 -13
  84. package/src/utils/fetch-resource.ts +0 -59
@@ -8,9 +8,8 @@
8
8
  // layout, a permission check, per-request init (auth headers / credentials), a
9
9
  // refetch trigger, and any extra header actions — so the component carries no
10
10
  // app, transport, or auth assumptions of its own.
11
- import { createSignal, For, Show, type Component } from "solid-js";
12
- import type { JSX } from "@solidjs/web";
13
- import { createStore } from "solid-js";
11
+ import { createSignal, For, Show, type Component, type JSX } from "solid-js";
12
+ import { createStore } from "solid-js/store";
14
13
  import Plus from "../../../icons/plus";
15
14
  import X from "../../../icons/x";
16
15
  import Archive from "../../../icons/archive";
@@ -133,21 +132,14 @@ export function ResourcePage<T extends ResourceRow>(
133
132
  );
134
133
  const [saving, setSaving] = createSignal(false);
135
134
  const [error, setError] = createSignal("");
136
- const setValue = (key: string, value: string) =>
137
- setForm((draft) => {
138
- draft[key] = value;
139
- });
135
+ const setValue = (key: string, value: string) => setForm(key, value);
140
136
 
141
137
  function resetForm() {
142
- setForm((draft) => {
143
- Object.assign(draft, emptyFormValues(spec));
144
- });
138
+ setForm(emptyFormValues(spec));
145
139
  setError("");
146
140
  }
147
141
  function populateForm(row: ResourceRow) {
148
- setForm((draft) => {
149
- Object.assign(draft, rowToFormValues(spec, row));
150
- });
142
+ setForm(rowToFormValues(spec, row));
151
143
  setError("");
152
144
  }
153
145
 
@@ -300,8 +292,7 @@ export function ResourcePage<T extends ResourceRow>(
300
292
  }
301
293
  >
302
294
  <DataTable<ResourceRow>
303
- // The table runs fetchFn untracked, so filter changes must be part of the key.
304
- refetchKey={() => `${String(refetchKey?.())}|${JSON.stringify(filterState)}`}
295
+ refetchKey={refetchKey}
305
296
  fetchFn={async (
306
297
  params: FetchParams
307
298
  ): Promise<FetchResult<ResourceRow>> => {
@@ -326,20 +317,14 @@ export function ResourcePage<T extends ResourceRow>(
326
317
  <SegmentedFilter
327
318
  options={[...f.options]}
328
319
  value={filterState[f.param]}
329
- onChange={(v: string) =>
330
- setFilterState((draft) => {
331
- draft[f.param] = v;
332
- })
333
- }
320
+ onChange={(v: string) => setFilterState(f.param, v)}
334
321
  testIdPrefix={f.testIdPrefix}
335
322
  />
336
323
  ) : (
337
324
  <select
338
325
  value={filterState[f.param]}
339
326
  onChange={(e) =>
340
- setFilterState((draft) => {
341
- draft[f.param] = e.currentTarget.value;
342
- })
327
+ setFilterState(f.param, e.currentTarget.value)
343
328
  }
344
329
  class="rounded-lg border border-[var(--ks-border,rgba(39,39,42,0.5))] bg-[var(--ks-input-bg,#18181b)] px-3 py-1.5 text-xs text-[var(--ks-fg-muted,#a1a1aa)] cursor-pointer"
345
330
  >
@@ -1,6 +1,6 @@
1
1
  // Column-cell rendering for the datatable. One pure function maps a column's
2
2
  // declared render hint (title / enum / status / text) to its cell markup.
3
- import type { JSX } from "@solidjs/web";
3
+ import type { JSX } from "solid-js";
4
4
  import StatusPill from "../../base/StatusPill";
5
5
  import type { ResourceRow, ResourceUiSpec, UiColumn } from "./spec";
6
6
 
@@ -12,7 +12,7 @@ import Search from "@kahitsan/ksui/icons/search";
12
12
 
13
13
  Named imports are also available from `@kahitsan/ksui/icons`. A tree-shaking bundler can discard unused icon modules.
14
14
 
15
- The components retain an SVG root. `size`, `width`, `height`, `class` (string, array, or object form), SVG refs, style, events, and accessible attributes remain available. Artwork uses `currentColor`, so normal text and theme colors apply. Icons are decorative by default. Supply `title` or an accessible label when the image itself conveys information.
15
+ The components retain an SVG root. `size`, `width`, `height`, `class`, `classList`, SVG refs, style, events, and accessible attributes remain available. Artwork uses `currentColor`, so normal text and theme colors apply. Icons are decorative by default. Supply `title` or an accessible label when the image itself conveys information.
16
16
 
17
17
  The Star includes a distinct filled rendition. Its fill inherits the SVG fill value, including CSS classes. Use `fill="currentColor"` to show the filled rendition.
18
18
 
@@ -27,3 +27,7 @@ Raster imports use Vite's `?url&no-inline` asset support. Vite 6 builds are veri
27
27
  Directional components share an original source design with an intrinsic rotation. The public component name keeps its direction, and caller SVG transforms still apply. Existing public exports outside the refreshed set remain available. `Sales` provides a revenue meaning; `ShoppingBag` retains its existing public artwork.
28
28
 
29
29
  BIR document identities are available as `BirForm2307`, `BirForm0619E`, and `BirForm1601Eq`, or their `bir-form-*` deep imports. Use a visible form label or accessible name with each document identity.
30
+
31
+ `BirCroc` (`bir-croc`) is the section identity for BIR forms: a crocodile head with an open mouth. It is not a document identity, so pair it with a visible section label.
32
+
33
+ `Overview` (`overview`) is the identity for a page that gathers everything in one place: an almond eye with a four-cell cluster as its pupil. Pair it with a visible label.
@@ -0,0 +1,2 @@
1
+ // Generated by scripts/build-icon-assets.mjs.
2
+ export const artwork = "M50 33q-7 2-13 9l-8 8c-12 8-15 12-16 20q-2 7 4 7l6 1 9 8 11 9a186 186 0 0 0 61 15q8-3 4-7l-2-6q-1-5-2-5-1-4-6 3l-5 6-5-2q-4 0-6-8l-3-11q-2 0-5 6l-4 5-3-2c-4-2-18-15-20-18q-3-6 3-5l9-2c4-2 20-5 23-5l3 4 3 6 4-5c3-6 4-7 12-7q5-1 5 4l3 3q2 0 4-5c2-3 2-4 8-4q5-1 7-4t-3-10-14-4q-3 1-4 3-1 4-19 5c-14 1-16 0-22-6q-9-9-19-6m4 7-4 3q-2 5 2 9 4 5 10 0l2-2-2-1q-4 0-3-3 0-3 2-3 3 0 1-2a8 8 0 0 0-8-1m62 1q0 4 3 4 5 0 4-4z";
@@ -0,0 +1,2 @@
1
+ // Generated by scripts/build-icon-assets.mjs.
2
+ export const artwork = "M13 52v37l7-7q15-13 29-21 23-11 41-2c7 3 21 13 25 17l2 3-6 6q-12 12-26 17c-8 2-21 2-30-1-7-2-18-9-22-14l-4-3-9 7-8 6v16l1 15h28v-23l3 2q10 4 22 6c11 1 19-1 35-8l1 12v12h28V52l-3 3q-10 7-21 3l-3-1 5-1 9-3q7-4 12-11l3-15-4 2q-11 10-41 12-23 2-39 9l-7 3V15H13zm89-28v9h4c9-2 25-13 24-16-1-2-3-2-14-2h-14zM55 63q-2 1-2 7 0 5 2 6c3 2 10 2 13 0q3-1 2-6 1-6-2-7c-2-2-10-3-13 0m20-1q-2 0-2 8-1 7 3 7h11q3 0 2-7c-1-7 0-7-2-8zM54 82l-1 7 1 7 8 1q6 1 7-2l1-6-1-6q0-2-7-2zm20 0v14h14l1-8-1-7h-6z";
@@ -0,0 +1,4 @@
1
+ // Generated by scripts/build-icon-assets.mjs.
2
+ import { createArtworkIcon } from "./create-artwork-icon";
3
+ import { artwork } from "./artwork/bir-croc";
4
+ export default /* @__PURE__ */ createArtworkIcon("bir-croc", artwork);
@@ -1,5 +1,5 @@
1
1
  import { cleanup, render } from "@solidjs/testing-library";
2
- import { createSignal, flush } from "solid-js";
2
+ import { createSignal } from "solid-js";
3
3
  import { afterEach, describe, expect, it } from "vitest";
4
4
  import { createArtworkIcon } from "./create-artwork-icon";
5
5
 
@@ -47,7 +47,6 @@ describe("original artwork icon contract", () => {
47
47
  const view = render(() => <Mixed strokeWidth={weight()} />);
48
48
  expect(view.container.querySelector("image")).not.toBeNull();
49
49
  setWeight(3);
50
- flush();
51
50
  expect(view.container.querySelector("image")).toBeNull();
52
51
  expect(view.container.querySelector("path")).not.toBeNull();
53
52
  });
@@ -81,7 +80,6 @@ describe("original artwork icon contract", () => {
81
80
  expect(svg.getAttribute("role")).toBe("img");
82
81
  expect(svg.hasAttribute("aria-hidden")).toBe(false);
83
82
  setSize(24);
84
- flush();
85
83
  expect(svg.getAttribute("width")).toBe("24");
86
84
  expect(svg.getAttribute("class")).toContain("indicator");
87
85
  });
@@ -111,7 +109,6 @@ describe("original artwork icon contract", () => {
111
109
  const images = view.container.querySelectorAll("image");
112
110
  expect(images[0].getAttribute("href")).toBe(regular);
113
111
  setWeight(3);
114
- flush();
115
112
  expect(images[0].getAttribute("href")).toBe(bold);
116
113
  expect(images[1].getAttribute("href")).toBe(filled);
117
114
  expect(view.container.querySelector("svg")?.getAttribute("fill")).toBe(
@@ -1,7 +1,11 @@
1
1
  /// <reference path="./asset-modules.d.ts" />
2
- import { ariaBool } from "../utils/aria";
3
- import { Show, createUniqueId, omit, type Component } from "solid-js";
4
- import type { JSX } from "@solidjs/web";
2
+ import {
3
+ Show,
4
+ createUniqueId,
5
+ splitProps,
6
+ type Component,
7
+ type JSX,
8
+ } from "solid-js";
5
9
 
6
10
  export type IconProps = JSX.SvgSVGAttributes<SVGSVGElement> & {
7
11
  size?: number | string;
@@ -70,11 +74,7 @@ function accessibility(props: IconProps, titleId: string) {
70
74
  "aria-label": props["aria-label"],
71
75
  "aria-labelledby":
72
76
  props["aria-labelledby"] ?? (props.title ? titleId : undefined),
73
- "aria-hidden": ariaBool(
74
- typeof props["aria-hidden"] === "string"
75
- ? props["aria-hidden"] === "true"
76
- : (props["aria-hidden"] ?? (labelled ? undefined : true)),
77
- ),
77
+ "aria-hidden": props["aria-hidden"] ?? (labelled ? undefined : true),
78
78
  } as const;
79
79
  }
80
80
 
@@ -85,8 +85,22 @@ export function createArtworkIcon(
85
85
  variants: ArtworkVariants = {}
86
86
  ): ArtworkIconComponent {
87
87
  return function ArtworkIcon(props) {
88
- const local = props;
89
- const rest = omit(props, "size", "width", "height", "title", "children", "fill", "role", "aria-hidden", "aria-label", "aria-labelledby", "strokeWidth", "stroke-width", "absoluteStrokeWidth", "weight");
88
+ const [local, rest] = splitProps(props, [
89
+ "size",
90
+ "width",
91
+ "height",
92
+ "title",
93
+ "children",
94
+ "fill",
95
+ "role",
96
+ "aria-hidden",
97
+ "aria-label",
98
+ "aria-labelledby",
99
+ "strokeWidth",
100
+ "stroke-width",
101
+ "absoluteStrokeWidth",
102
+ "weight",
103
+ ]);
90
104
  const id = `artwork-${createUniqueId()}`;
91
105
  const titleId = `${id}-title`;
92
106
  const artwork = () => {
@@ -169,6 +169,8 @@ export { default as Sales } from "./sales";
169
169
  export { default as BirForm2307 } from "./bir-form-2307";
170
170
  export { default as BirForm0619E } from "./bir-form-0619-e";
171
171
  export { default as BirForm1601Eq } from "./bir-form-1601-eq";
172
+ export { default as BirCroc } from "./bir-croc";
173
+ export { default as Overview } from "./overview";
172
174
  export { default as AlertCircle } from "./circle-alert";
173
175
  export { default as AlertTriangle } from "./triangle-alert";
174
176
  export { default as BarChart3 } from "./chart-column";
@@ -0,0 +1,4 @@
1
+ // Generated by scripts/build-icon-assets.mjs.
2
+ import { createArtworkIcon } from "./create-artwork-icon";
3
+ import { artwork } from "./artwork/overview";
4
+ export default /* @__PURE__ */ createArtworkIcon("overview", artwork);
@@ -172,6 +172,8 @@ const loaders = {
172
172
  "bir-form-2307": () => import("./bir-form-2307"),
173
173
  "bir-form-0619-e": () => import("./bir-form-0619-e"),
174
174
  "bir-form-1601-eq": () => import("./bir-form-1601-eq"),
175
+ "bir-croc": () => import("./bir-croc"),
176
+ "overview": () => import("./overview"),
175
177
  "bar-chart-3": () => import("./chart-column"),
176
178
  "loader-2": () => import("./loader-circle"),
177
179
  "alert-triangle": () => import("./triangle-alert"),
@@ -12,8 +12,7 @@ import Coins from "../icons/coins";
12
12
  import PiggyBank from "../icons/piggy-bank";
13
13
  import DollarSign from "../icons/dollar-sign";
14
14
  import Receipt from "../icons/receipt";
15
- import type { Component } from "solid-js";
16
- import type { JSX } from "@solidjs/web";
15
+ import type { Component, JSX } from "solid-js";
17
16
 
18
17
  export type IconComponent = Component<JSX.SvgSVGAttributes<SVGSVGElement> & { size?: number }>;
19
18
 
@@ -17,8 +17,7 @@
17
17
  // fetch 404s/fails and the index stays empty, so resolveAccount() then falls back
18
18
  // to the type-default glyph.
19
19
 
20
- import { createRoot, runWithOwner } from "solid-js";
21
- import { createFetchResource, type FetchResource } from "./fetch-resource";
20
+ import { createResource, type Resource } from "solid-js";
22
21
  import { getActiveWorkspaceId } from "./integration";
23
22
  import type { AvatarAccount } from "../components/base/AccountAvatar";
24
23
 
@@ -72,14 +71,12 @@ async function fetchAccountsIndex(wsId: number | string | null): Promise<IndexSh
72
71
 
73
72
  // Module-level singletons so a page with N rows fires one fetch per org, not
74
73
  // 2*N. Created on first useAccountsIndex() call.
75
- let sharedResource: FetchResource<IndexShape> | undefined;
74
+ let sharedResource: Resource<IndexShape> | undefined;
76
75
 
77
- export function useAccountsIndex(): FetchResource<IndexShape> {
76
+ export function useAccountsIndex(): Resource<IndexShape> {
78
77
  if (!sharedResource) {
79
- // Detached: the shared index must outlive whichever component asked first.
80
- sharedResource = runWithOwner(null, () =>
81
- createRoot(() => createFetchResource(() => getActiveWorkspaceId(), fetchAccountsIndex)),
82
- )!;
78
+ const [data] = createResource(() => getActiveWorkspaceId(), fetchAccountsIndex);
79
+ sharedResource = data;
83
80
  }
84
81
  return sharedResource;
85
82
  }
@@ -8,7 +8,7 @@
8
8
  // kit, no Tailwind — Modal and Button inject their own styles.
9
9
 
10
10
  import { createSignal, Show } from "solid-js";
11
- import { render } from "@solidjs/web";
11
+ import { render } from "solid-js/web";
12
12
  import Modal from "../components/base/Modal";
13
13
  import Button from "../components/base/Button";
14
14
 
package/src/utils/dom.ts CHANGED
@@ -69,16 +69,15 @@ export function unlockPullToRefresh() {
69
69
  * a teardown function the caller can use to deactivate the trap explicitly
70
70
  * (also runs automatically when called inside a Solid `onCleanup`).
71
71
  *
72
- * Use this from a ref callback, keeping the teardown for an owner-level
73
- * onCleanup (Solid 2 forbids onCleanup inside a ref callback):
72
+ * Use this from a ref callback or Solid effect:
74
73
  *
75
- * let release: (() => void) | undefined;
76
- * onCleanup(() => release?.());
77
- * <div ref={(el) => { release = useFocusTrap(el); }}>
74
+ * <div ref={(el) => { onCleanup(useFocusTrap(el)); }}>
78
75
  *
79
- * Or from an effect, returning the teardown:
76
+ * Or from an effect:
80
77
  *
81
- * createEffect(() => containerRef, (el) => (el ? useFocusTrap(el) : undefined));
78
+ * createEffect(() => {
79
+ * if (containerRef) onCleanup(useFocusTrap(containerRef));
80
+ * });
82
81
  *
83
82
  * The trap only intercepts Tab. Escape, click-outside, and submit handling
84
83
  * remain the modal's responsibility, the trap is purely a focus-keeper.
@@ -8,7 +8,7 @@
8
8
  // /helper class is added once per page via a runtime <style> tag. Callers can
9
9
  // still pass their own `markClass` to override.
10
10
 
11
- import type { JSX } from "@solidjs/web";
11
+ import { type JSX } from "solid-js";
12
12
  import { injectCSS } from "./inject-css";
13
13
 
14
14
  const MARK_STYLE_ID = "ksui-mark-style";
@@ -14,15 +14,15 @@ import { createContext, useContext, type Accessor } from "solid-js";
14
14
  // both mean "mount to document.body", today's behavior.
15
15
  const ModalLayerContext = createContext<Accessor<HTMLElement | null>>(() => null);
16
16
 
17
- export const ModalLayerProvider = ModalLayerContext;
17
+ export const ModalLayerProvider = ModalLayerContext.Provider;
18
18
 
19
19
  /**
20
20
  * Mount target for a Portal-based popover: the nearest ancestor dialog's
21
21
  * element when rendered inside a dialog-variant Modal, else document.body.
22
22
  * Called once per popover-open (the Portal itself only reads `mount` at
23
- * creation), so a plain element accessor — not a reactive signal — is enough.
23
+ * creation), so a plain `Node` accessor — not a reactive signal — is enough.
24
24
  */
25
- export function usePopoverMount(): () => HTMLElement {
25
+ export function usePopoverMount(): () => Node {
26
26
  const layer = useContext(ModalLayerContext);
27
27
  return () => layer() ?? document.body;
28
28
  }
@@ -1,5 +1,4 @@
1
- import { createEffect, onCleanup } from "solid-js";
2
- import { createFetchResource, type FetchResource } from "./fetch-resource";
1
+ import { createResource, createEffect, onCleanup, type Resource } from "solid-js";
3
2
 
4
3
  export interface ObjectUrlOptions {
5
4
  /** Extra fetch init, merged after `credentials: "include"` (e.g. tenant headers). */
@@ -26,8 +25,8 @@ export interface ObjectUrlOptions {
26
25
  export function createObjectUrlResource(
27
26
  href: () => string | null | undefined,
28
27
  options: ObjectUrlOptions = {},
29
- ): FetchResource<string | null> {
30
- const url = createFetchResource(
28
+ ): Resource<string | null> {
29
+ const [url] = createResource(
31
30
  () => href() || null,
32
31
  async (src) => {
33
32
  const res = await fetch(src, { credentials: "include", ...options.init });
@@ -41,13 +40,11 @@ export function createObjectUrlResource(
41
40
  // final one on unmount. During a refetch the resource holds its prior value
42
41
  // (cur === prev), so an in-flight reload doesn't revoke a URL still on screen.
43
42
  let prev: string | null = null;
44
- createEffect(
45
- () => url() ?? null,
46
- (cur) => {
47
- if (prev && prev !== cur) URL.revokeObjectURL(prev);
48
- prev = cur;
49
- },
50
- );
43
+ createEffect(() => {
44
+ const cur = url() ?? null;
45
+ if (prev && prev !== cur) URL.revokeObjectURL(prev);
46
+ prev = cur;
47
+ });
51
48
  onCleanup(() => {
52
49
  if (prev) URL.revokeObjectURL(prev);
53
50
  });
@@ -1,3 +1,4 @@
1
+ import { onMount } from "solid-js";
1
2
  import { injectCSS } from "./inject-css";
2
3
 
3
4
  const STYLE_ID = "ksui-toplayer-style";
@@ -22,16 +23,17 @@ const STYLE_CSS = `
22
23
  * ksui popup keeps its own mousedown/Escape listeners unchanged.
23
24
  *
24
25
  * Call from the portaled panel's ref, mirroring useFocusTrap's shape:
25
- * ref={(el) => { popupRef = el; useTopLayer(el); }}
26
+ * ref={(el) => { popupRef = el; onCleanup(useTopLayer(el)); }}
26
27
  *
27
- * showPopover() is deferred to a microtask, not called inline here: this
28
+ * showPopover() is deferred to onMount, not called inline here: this
28
29
  * function runs synchronously inside <Portal>'s ref callback, which fires
29
30
  * while the node is still detached (Portal appends its container to
30
31
  * document.body *after* building the subtree) — el.isConnected is false
31
32
  * and el.ownerDocument !== document at that point, so an inline call
32
- * always throws InvalidStateError. A microtask runs only after the whole synchronous
33
- * render pass — including Portal's appendChild — has finished, so by the
34
- * time it runs the node is connected. (Same fix shape as Modal's DialogModal,
33
+ * always throws InvalidStateError. onMount queues onto Solid's render-effect
34
+ * list, which only flushes once the whole synchronous render pass —
35
+ * including Portal's appendChild — has finished, so by the time it runs
36
+ * the node is guaranteed connected. (Same fix shape as Modal's DialogModal,
35
37
  * which calls showModal() in onMount rather than in dialogEl's ref.)
36
38
  */
37
39
  export function useTopLayer(el: HTMLElement | undefined): () => void {
@@ -39,10 +41,7 @@ export function useTopLayer(el: HTMLElement | undefined): () => void {
39
41
  injectCSS(STYLE_ID, STYLE_CSS);
40
42
  el.setAttribute("popover", "manual");
41
43
  el.setAttribute("data-ksui-toplayer", "");
42
- // Primitives are forbidden in a ref callback, so a microtask stands in for
43
- // onSettled. The element leaves the top layer by itself when its portal is removed.
44
- queueMicrotask(() => {
45
- if (!el.isConnected) return;
44
+ onMount(() => {
46
45
  // No Popover API (e.g. jsdom in unit tests) — nothing to promote, not an error.
47
46
  if (typeof el.showPopover !== "function") return;
48
47
  try {
@@ -1,23 +0,0 @@
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
- });
package/src/utils/aria.ts DELETED
@@ -1,13 +0,0 @@
1
- // Solid 2 removes a boolean-false attribute, which would drop aria-expanded="false";
2
- // ARIA state attributes must be serialized as strings.
3
- export function ariaBool(value: boolean | undefined | null): "true" | "false" | undefined {
4
- if (value === undefined || value === null) return undefined;
5
- return value ? "true" : "false";
6
- }
7
-
8
- /** For aria-pressed / aria-checked, which also allow "mixed". */
9
- export function ariaTri(
10
- value: boolean | "mixed" | undefined | null,
11
- ): "true" | "false" | "mixed" | undefined {
12
- return value === "mixed" ? "mixed" : ariaBool(value);
13
- }
@@ -1,59 +0,0 @@
1
- import { createEffect, createSignal, onCleanup, untrack, type Accessor } from "solid-js";
2
-
3
- /**
4
- * Value accessor with load state, the shape `createResource` gave callers.
5
- * Solid 2 async memos throw to a <Loading> boundary instead; consumers of these
6
- * hooks read `value()` unguarded, so loading stays a plain flag here.
7
- */
8
- export interface FetchResource<T> extends Accessor<T | undefined> {
9
- readonly loading: boolean;
10
- readonly error: unknown;
11
- }
12
-
13
- /**
14
- * Fetch `fetcher(source())` whenever `source` changes to a truthy value.
15
- * A falsy source skips the fetch and keeps the last value; a refetch keeps the
16
- * previous value until the new one lands; a superseded response is dropped.
17
- */
18
- export function createFetchResource<S, T>(
19
- source: () => S | false | null | undefined,
20
- fetcher: (source: S) => Promise<T>,
21
- ): FetchResource<T> {
22
- const [value, setValue] = createSignal<T | undefined>(undefined);
23
- // Seeded from the source so an initial read matches createResource's loading=true.
24
- const [loading, setLoading] = createSignal(!!untrack(source));
25
- const [error, setError] = createSignal<unknown>(undefined);
26
- let token = 0;
27
-
28
- createEffect(source, (src) => {
29
- const mine = ++token;
30
- if (!src) {
31
- setLoading(false);
32
- return;
33
- }
34
- setLoading(true);
35
- setError(undefined);
36
- fetcher(src).then(
37
- (next) => {
38
- if (mine !== token) return;
39
- setValue(() => next);
40
- setLoading(false);
41
- },
42
- (err: unknown) => {
43
- if (mine !== token) return;
44
- setError(err);
45
- setLoading(false);
46
- },
47
- );
48
- });
49
- onCleanup(() => {
50
- token++;
51
- });
52
-
53
- const read = (() => value()) as FetchResource<T>;
54
- Object.defineProperties(read, {
55
- loading: { get: loading },
56
- error: { get: error },
57
- });
58
- return read;
59
- }