@kahitsan/ksui 0.49.0 → 0.51.0-solid2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/package.json +10 -7
- package/src/components/base/AccountAvatar.tsx +1 -1
- package/src/components/base/ActionMenu.tsx +7 -5
- package/src/components/base/AddAttachmentTile.tsx +6 -6
- package/src/components/base/BadgeSelect.tsx +11 -9
- package/src/components/base/Button.test.tsx +23 -0
- package/src/components/base/Button.tsx +35 -41
- package/src/components/base/CameraCapture.tsx +5 -2
- package/src/components/base/CopyButton.tsx +2 -1
- package/src/components/base/DataTable.tsx +89 -112
- package/src/components/base/DatePicker.tsx +15 -17
- package/src/components/base/DateTile.tsx +14 -12
- package/src/components/base/Dropdown.tsx +6 -5
- package/src/components/base/ExistingAttachmentTile.test.tsx +3 -3
- package/src/components/base/ExistingAttachmentTile.tsx +6 -4
- package/src/components/base/EyebrowBadge.tsx +2 -1
- package/src/components/base/FormErrorBanner.tsx +2 -1
- package/src/components/base/FormField.tsx +1 -1
- package/src/components/base/ImageCropper.tsx +3 -3
- package/src/components/base/ImageViewer.test.tsx +2 -0
- package/src/components/base/ImageViewer.tsx +4 -3
- package/src/components/base/KpiCard.tsx +3 -2
- package/src/components/base/Modal.test.tsx +3 -2
- package/src/components/base/Modal.tsx +11 -12
- package/src/components/base/ModalHeader.tsx +2 -1
- package/src/components/base/MonthCalendar.tsx +2 -1
- package/src/components/base/MultiSelectGroup.tsx +7 -5
- package/src/components/base/ProgressBar.tsx +8 -17
- package/src/components/base/RadioCardGroup.tsx +14 -12
- package/src/components/base/SectionHeading.tsx +2 -1
- package/src/components/base/SegmentedFilter.tsx +10 -8
- package/src/components/base/SocialLinksBar.tsx +2 -1
- package/src/components/base/StatusIndicator.tsx +2 -1
- package/src/components/base/StatusPill.tsx +1 -1
- package/src/components/base/TagPill.tsx +1 -1
- package/src/components/base/ThemeToggle.tsx +5 -11
- package/src/components/base/Tooltip.tsx +2 -1
- package/src/components/composite/AccountRadioPicker.tsx +14 -11
- package/src/components/composite/ComboBox.tsx +18 -13
- package/src/components/composite/CustomRenderer.tsx +1 -1
- package/src/components/composite/FileField.tsx +6 -3
- package/src/components/composite/FlowGraph.tsx +15 -12
- package/src/components/composite/FlowRunner.test.tsx +2 -0
- package/src/components/composite/FlowRunner.tsx +2 -1
- package/src/components/composite/FormActions.tsx +1 -1
- package/src/components/composite/FormAdvancedSection.tsx +13 -13
- package/src/components/composite/LiveTimer.tsx +8 -14
- package/src/components/composite/MarkdownNotes.tsx +2 -1
- package/src/components/composite/MentionTextarea.tsx +31 -22
- package/src/components/composite/MultiPeriodPicker.tsx +11 -9
- package/src/components/composite/NotFound.tsx +4 -15
- package/src/components/composite/PaymentAccountPicker.tsx +19 -24
- package/src/components/composite/SalesBodyEditor.tsx +10 -7
- package/src/components/composite/SearchableSelect.tsx +14 -13
- package/src/components/composite/SecretReveal.tsx +2 -2
- package/src/components/composite/TransactionForm.tsx +52 -42
- package/src/components/composite/TransferAccountsPicker.tsx +11 -10
- package/src/components/composite/TransferFeeChip.tsx +7 -6
- package/src/components/composite/VoucherPicker.test.tsx +55 -48
- package/src/components/composite/VoucherPicker.tsx +36 -27
- package/src/components/composite/picker-engine.ts +20 -14
- package/src/components/composite/resource/ResourcePage.test.tsx +1 -1
- package/src/components/composite/resource/ResourcePage.tsx +21 -7
- package/src/components/composite/resource/cells.tsx +1 -1
- package/src/icons/README.md +10 -4
- package/src/icons/arrow-down-left.tsx +2 -2
- package/src/icons/arrow-left.tsx +2 -2
- package/src/icons/arrow-right-left.tsx +1 -1
- package/src/icons/arrow-right.tsx +2 -2
- package/src/icons/arrow-up-down.tsx +2 -2
- package/src/icons/arrow-up-right.tsx +2 -2
- package/src/icons/arrow-up.tsx +2 -2
- package/src/icons/artwork/activity.ts +1 -1
- package/src/icons/artwork/app-window.png +0 -0
- package/src/icons/artwork/app-window.ts +2 -1
- package/src/icons/artwork/archive-restore.ts +1 -1
- package/src/icons/artwork/archive.ts +1 -1
- package/src/icons/artwork/arrow-down.ts +1 -1
- package/src/icons/artwork/arrow-left-right.ts +1 -1
- package/src/icons/artwork/at-sign.png +0 -0
- package/src/icons/artwork/at-sign.ts +2 -1
- package/src/icons/artwork/ban.png +0 -0
- package/src/icons/artwork/ban.ts +2 -1
- package/src/icons/artwork/banknote.ts +1 -1
- package/src/icons/artwork/bell.ts +1 -1
- package/src/icons/artwork/bir-form-0619-e.png +0 -0
- package/src/icons/artwork/bir-form-0619-e.ts +3 -0
- package/src/icons/artwork/bir-form-1601-eq.png +0 -0
- package/src/icons/artwork/bir-form-1601-eq.ts +3 -0
- package/src/icons/artwork/bir-form-2307.png +0 -0
- package/src/icons/artwork/bir-form-2307.ts +3 -0
- package/src/icons/artwork/bir-office.ts +2 -0
- package/src/icons/artwork/blocks.png +0 -0
- package/src/icons/artwork/blocks.ts +2 -1
- package/src/icons/artwork/book-open.ts +1 -1
- package/src/icons/artwork/boxes.ts +1 -1
- package/src/icons/artwork/briefcase.png +0 -0
- package/src/icons/artwork/briefcase.ts +2 -1
- package/src/icons/artwork/building-2.ts +1 -1
- package/src/icons/artwork/building.png +0 -0
- package/src/icons/artwork/building.ts +2 -1
- package/src/icons/artwork/calculator.png +0 -0
- package/src/icons/artwork/calculator.ts +2 -1
- package/src/icons/artwork/calendar-clock.png +0 -0
- package/src/icons/artwork/calendar-clock.ts +2 -1
- package/src/icons/artwork/calendar.png +0 -0
- package/src/icons/artwork/calendar.ts +2 -1
- package/src/icons/artwork/camera.ts +1 -1
- package/src/icons/artwork/chart-bar.ts +1 -1
- package/src/icons/artwork/check-bold.ts +1 -1
- package/src/icons/artwork/check-check.ts +1 -1
- package/src/icons/artwork/check.ts +1 -1
- package/src/icons/artwork/chevron-right.ts +1 -1
- package/src/icons/artwork/chevrons-up-down.ts +1 -1
- package/src/icons/artwork/circle-alert.ts +1 -1
- package/src/icons/artwork/circle-check-bold.png +0 -0
- package/src/icons/artwork/circle-check-bold.ts +2 -1
- package/src/icons/artwork/circle-check.png +0 -0
- package/src/icons/artwork/circle-check.ts +2 -1
- package/src/icons/artwork/circle-dot.ts +1 -1
- package/src/icons/artwork/circle-question-mark.png +0 -0
- package/src/icons/artwork/circle-question-mark.ts +2 -1
- package/src/icons/artwork/circle-x.ts +1 -1
- package/src/icons/artwork/circle.ts +1 -1
- package/src/icons/artwork/clipboard-list.ts +1 -1
- package/src/icons/artwork/clock.png +0 -0
- package/src/icons/artwork/clock.ts +2 -1
- package/src/icons/artwork/coins.ts +1 -1
- package/src/icons/artwork/compass.png +0 -0
- package/src/icons/artwork/compass.ts +2 -1
- package/src/icons/artwork/copy.png +0 -0
- package/src/icons/artwork/copy.ts +2 -1
- package/src/icons/artwork/corner-down-right.ts +1 -1
- package/src/icons/artwork/credit-card.png +0 -0
- package/src/icons/artwork/credit-card.ts +2 -1
- package/src/icons/artwork/crown.ts +1 -1
- package/src/icons/artwork/database.png +0 -0
- package/src/icons/artwork/database.ts +2 -1
- package/src/icons/artwork/dollar-sign.ts +1 -1
- package/src/icons/artwork/door-open.png +0 -0
- package/src/icons/artwork/door-open.ts +2 -1
- package/src/icons/artwork/download.ts +1 -1
- package/src/icons/artwork/ellipsis.ts +1 -1
- package/src/icons/artwork/equal.ts +1 -1
- package/src/icons/artwork/external-link.ts +1 -1
- package/src/icons/artwork/eye.ts +1 -1
- package/src/icons/artwork/file-spreadsheet.png +0 -0
- package/src/icons/artwork/file-spreadsheet.ts +2 -1
- package/src/icons/artwork/file-text.png +0 -0
- package/src/icons/artwork/file-text.ts +2 -1
- package/src/icons/artwork/file.ts +1 -1
- package/src/icons/artwork/funnel.ts +1 -1
- package/src/icons/artwork/globe.png +0 -0
- package/src/icons/artwork/globe.ts +2 -1
- package/src/icons/artwork/grip-vertical.ts +1 -1
- package/src/icons/artwork/history.png +0 -0
- package/src/icons/artwork/history.ts +2 -1
- package/src/icons/artwork/house.ts +1 -1
- package/src/icons/artwork/image-off.png +0 -0
- package/src/icons/artwork/image-off.ts +2 -1
- package/src/icons/artwork/inbox.ts +1 -1
- package/src/icons/artwork/info.ts +1 -1
- package/src/icons/artwork/key.ts +1 -1
- package/src/icons/artwork/landmark.ts +1 -1
- package/src/icons/artwork/layers.png +0 -0
- package/src/icons/artwork/layers.ts +2 -1
- package/src/icons/artwork/layout-dashboard.ts +1 -1
- package/src/icons/artwork/layout-grid.ts +1 -1
- package/src/icons/artwork/layout-list.png +0 -0
- package/src/icons/artwork/layout-list.ts +2 -1
- package/src/icons/artwork/link-2.ts +1 -1
- package/src/icons/artwork/list.ts +1 -1
- package/src/icons/artwork/loader-circle.ts +1 -1
- package/src/icons/artwork/lock.ts +1 -1
- package/src/icons/artwork/log-in.ts +1 -1
- package/src/icons/artwork/log-out.ts +1 -1
- package/src/icons/artwork/mail-open.ts +1 -1
- package/src/icons/artwork/mail.ts +1 -1
- package/src/icons/artwork/megaphone.ts +1 -1
- package/src/icons/artwork/message-square.ts +1 -1
- package/src/icons/artwork/minus.ts +1 -1
- package/src/icons/artwork/moon.ts +1 -1
- package/src/icons/artwork/mouse-pointer-click.ts +1 -1
- package/src/icons/artwork/move.ts +1 -1
- package/src/icons/artwork/package.ts +1 -1
- package/src/icons/artwork/palette.png +0 -0
- package/src/icons/artwork/palette.ts +2 -1
- package/src/icons/artwork/panel-left-close.ts +1 -1
- package/src/icons/artwork/panel-left.png +0 -0
- package/src/icons/artwork/panel-left.ts +2 -1
- package/src/icons/artwork/paperclip.png +0 -0
- package/src/icons/artwork/paperclip.ts +2 -1
- package/src/icons/artwork/pencil.ts +1 -1
- package/src/icons/artwork/phone-call.png +0 -0
- package/src/icons/artwork/phone-call.ts +2 -1
- package/src/icons/artwork/phone.ts +1 -1
- package/src/icons/artwork/piggy-bank.ts +1 -1
- package/src/icons/artwork/play.ts +1 -1
- package/src/icons/artwork/plus.ts +1 -1
- package/src/icons/artwork/power.ts +1 -1
- package/src/icons/artwork/radio.png +0 -0
- package/src/icons/artwork/radio.ts +2 -1
- package/src/icons/artwork/receipt.ts +1 -1
- package/src/icons/artwork/refresh-cw.ts +1 -1
- package/src/icons/artwork/rotate-ccw.ts +1 -1
- package/src/icons/artwork/sales.ts +2 -0
- package/src/icons/artwork/save.ts +1 -1
- package/src/icons/artwork/search.ts +1 -1
- package/src/icons/artwork/settings.ts +1 -1
- package/src/icons/artwork/shield-alert.ts +1 -1
- package/src/icons/artwork/shield-check.ts +1 -1
- package/src/icons/artwork/shield-off.ts +1 -1
- package/src/icons/artwork/shield.ts +1 -1
- package/src/icons/artwork/shopping-bag.png +0 -0
- package/src/icons/artwork/shopping-bag.ts +2 -1
- package/src/icons/artwork/shopping-cart.ts +1 -1
- package/src/icons/artwork/shuffle.ts +1 -1
- package/src/icons/artwork/sliders-horizontal.ts +1 -1
- package/src/icons/artwork/smartphone.ts +1 -1
- package/src/icons/artwork/sparkles.ts +1 -1
- package/src/icons/artwork/square.ts +1 -1
- package/src/icons/artwork/star-filled.ts +1 -1
- package/src/icons/artwork/star.ts +1 -1
- package/src/icons/artwork/sticky-note.png +0 -0
- package/src/icons/artwork/sticky-note.ts +2 -1
- package/src/icons/artwork/store.png +0 -0
- package/src/icons/artwork/store.ts +2 -1
- package/src/icons/artwork/sun.ts +1 -1
- package/src/icons/artwork/tag.ts +1 -1
- package/src/icons/artwork/target.png +0 -0
- package/src/icons/artwork/target.ts +2 -1
- package/src/icons/artwork/ticket.png +0 -0
- package/src/icons/artwork/ticket.ts +2 -1
- package/src/icons/artwork/trash-2.png +0 -0
- package/src/icons/artwork/trash-2.ts +2 -1
- package/src/icons/artwork/trending-up.ts +1 -1
- package/src/icons/artwork/triangle-alert.ts +1 -1
- package/src/icons/artwork/trophy.ts +1 -1
- package/src/icons/artwork/undo-2.ts +1 -1
- package/src/icons/artwork/upload.ts +1 -1
- package/src/icons/artwork/user-check.png +0 -0
- package/src/icons/artwork/user-check.ts +2 -1
- package/src/icons/artwork/user-plus.ts +1 -1
- package/src/icons/artwork/user.ts +1 -1
- package/src/icons/artwork/users.ts +1 -1
- package/src/icons/artwork/volume-2.ts +1 -1
- package/src/icons/artwork/volume-x.ts +1 -1
- package/src/icons/artwork/wallet.ts +1 -1
- package/src/icons/artwork/x.ts +1 -1
- package/src/icons/artwork/zap.ts +1 -1
- package/src/icons/artwork/zoom-in.png +0 -0
- package/src/icons/artwork/zoom-in.ts +2 -1
- package/src/icons/asset-modules.d.ts +4 -0
- package/src/icons/bir-form-0619-e.tsx +4 -0
- package/src/icons/bir-form-1601-eq.tsx +4 -0
- package/src/icons/bir-form-2307.tsx +4 -0
- package/src/icons/bir-office.tsx +4 -0
- package/src/icons/calendar-days.tsx +1 -1
- package/src/icons/check.tsx +2 -2
- package/src/icons/chevron-down.tsx +2 -2
- package/src/icons/chevron-left.tsx +2 -2
- package/src/icons/chevron-up.tsx +2 -2
- package/src/icons/circle-check-big.tsx +3 -2
- package/src/icons/circle-check.tsx +2 -2
- package/src/icons/circle-slash.tsx +1 -1
- package/src/icons/cloud-upload.tsx +1 -1
- package/src/icons/create-artwork-icon.test.tsx +33 -1
- package/src/icons/create-artwork-icon.tsx +35 -40
- package/src/icons/ellipsis-vertical.tsx +2 -2
- package/src/icons/index.ts +5 -0
- package/src/icons/key-round.tsx +1 -1
- package/src/icons/registry.ts +8 -3
- package/src/icons/sales.tsx +4 -0
- package/src/icons/settings-2.tsx +1 -1
- package/src/icons/star.tsx +2 -2
- package/src/icons/user-round.tsx +1 -1
- package/src/icons/users-round.tsx +1 -1
- package/src/utils/account-icons.ts +2 -1
- package/src/utils/accounts-index.tsx +8 -5
- package/src/utils/aria.ts +13 -0
- package/src/utils/confirm.tsx +1 -1
- package/src/utils/dom.ts +7 -6
- package/src/utils/fetch-resource.ts +59 -0
- package/src/utils/highlight.tsx +1 -1
- package/src/utils/modal-layer.ts +3 -3
- package/src/utils/object-url-resource.ts +11 -8
- package/src/utils/top-layer.ts +9 -8
- package/src/icons/artwork/arrow-down-left.ts +0 -2
- package/src/icons/artwork/arrow-left.ts +0 -2
- package/src/icons/artwork/arrow-right-left.ts +0 -2
- package/src/icons/artwork/arrow-right.ts +0 -2
- package/src/icons/artwork/arrow-up-down.ts +0 -2
- package/src/icons/artwork/arrow-up-right.ts +0 -2
- package/src/icons/artwork/arrow-up.ts +0 -2
- package/src/icons/artwork/calendar-days.ts +0 -2
- package/src/icons/artwork/chevron-down.ts +0 -2
- package/src/icons/artwork/chevron-left.ts +0 -2
- package/src/icons/artwork/chevron-up.ts +0 -2
- package/src/icons/artwork/circle-check-big.ts +0 -2
- package/src/icons/artwork/circle-slash.ts +0 -2
- package/src/icons/artwork/cloud-upload.ts +0 -2
- package/src/icons/artwork/ellipsis-vertical.ts +0 -2
- package/src/icons/artwork/key-round.ts +0 -2
- package/src/icons/artwork/settings-2.ts +0 -2
- package/src/icons/artwork/user-round.ts +0 -2
- package/src/icons/artwork/users-round.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/calendar
|
|
3
|
+
import { artwork } from "./artwork/calendar";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("calendar-days", artwork);
|
package/src/icons/check.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
3
|
import { artwork } from "./artwork/check";
|
|
4
|
-
import { artwork as
|
|
5
|
-
export default /* @__PURE__ */ createArtworkIcon("check", artwork, { bold
|
|
4
|
+
import { artwork as bold } from "./artwork/check-bold";
|
|
5
|
+
export default /* @__PURE__ */ createArtworkIcon("check", artwork, { bold });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/chevron-
|
|
4
|
-
export default /* @__PURE__ */ createArtworkIcon("chevron-down", artwork);
|
|
3
|
+
import { artwork } from "./artwork/chevron-right";
|
|
4
|
+
export default /* @__PURE__ */ createArtworkIcon("chevron-down", artwork, { rotation: 90 });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/chevron-
|
|
4
|
-
export default /* @__PURE__ */ createArtworkIcon("chevron-left", artwork);
|
|
3
|
+
import { artwork } from "./artwork/chevron-right";
|
|
4
|
+
export default /* @__PURE__ */ createArtworkIcon("chevron-left", artwork, { rotation: 180 });
|
package/src/icons/chevron-up.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/chevron-
|
|
4
|
-
export default /* @__PURE__ */ createArtworkIcon("chevron-up", artwork);
|
|
3
|
+
import { artwork } from "./artwork/chevron-right";
|
|
4
|
+
export default /* @__PURE__ */ createArtworkIcon("chevron-up", artwork, { rotation: 270 });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/circle-check
|
|
4
|
-
|
|
3
|
+
import { artwork } from "./artwork/circle-check";
|
|
4
|
+
import { artwork as bold } from "./artwork/circle-check-bold";
|
|
5
|
+
export default /* @__PURE__ */ createArtworkIcon("circle-check-big", artwork, { bold });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
3
|
import { artwork } from "./artwork/circle-check";
|
|
4
|
-
import { artwork as
|
|
5
|
-
export default /* @__PURE__ */ createArtworkIcon("circle-check", artwork, { bold
|
|
4
|
+
import { artwork as bold } from "./artwork/circle-check-bold";
|
|
5
|
+
export default /* @__PURE__ */ createArtworkIcon("circle-check", artwork, { bold });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/
|
|
3
|
+
import { artwork } from "./artwork/ban";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("circle-slash", artwork);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/
|
|
3
|
+
import { artwork } from "./artwork/upload";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("cloud-upload", artwork);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cleanup, render } from "@solidjs/testing-library";
|
|
2
|
-
import { createSignal } from "solid-js";
|
|
2
|
+
import { createSignal, flush } from "solid-js";
|
|
3
3
|
import { afterEach, describe, expect, it } from "vitest";
|
|
4
4
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
5
5
|
|
|
@@ -10,6 +10,35 @@ const Glyph = createArtworkIcon("sample", regular, { bold, filled });
|
|
|
10
10
|
afterEach(cleanup);
|
|
11
11
|
|
|
12
12
|
describe("original artwork icon contract", () => {
|
|
13
|
+
it("rotates shared source geometry without changing caller SVG transforms or children", () => {
|
|
14
|
+
const Oriented = createArtworkIcon("left", "M72 12v120", { rotation: 90 });
|
|
15
|
+
const view = render(() => <Oriented transform="translate(2 3)"><desc>Previous page</desc></Oriented>);
|
|
16
|
+
expect(view.container.querySelector("svg")?.getAttribute("transform")).toBe("translate(2 3)");
|
|
17
|
+
expect(view.container.querySelector("path")?.parentElement?.getAttribute("transform")).toBe("rotate(90 72 72)");
|
|
18
|
+
expect(view.container.querySelector("desc")?.parentElement?.tagName.toLowerCase()).toBe("svg");
|
|
19
|
+
});
|
|
20
|
+
it("keeps accessible titles in the SVG namespace without changing the document title", () => {
|
|
21
|
+
const previousTitle = document.title;
|
|
22
|
+
document.title = "Application";
|
|
23
|
+
try {
|
|
24
|
+
const view = render(() => <Glyph title="Search" />);
|
|
25
|
+
const title = view.container.querySelector("title");
|
|
26
|
+
expect(title?.namespaceURI).toBe("http://www.w3.org/2000/svg");
|
|
27
|
+
expect(view.getByRole("img", { name: "Search" })).toBeTruthy();
|
|
28
|
+
expect(document.title).toBe("Application");
|
|
29
|
+
} finally {
|
|
30
|
+
document.title = previousTitle;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("uses an emitted image URL without mistaking it for vector geometry", () => {
|
|
35
|
+
const External = createArtworkIcon("external", { image: "/assets/original.png" });
|
|
36
|
+
const view = render(() => <External title="Original image" />);
|
|
37
|
+
expect(view.container.querySelector("path")).toBeNull();
|
|
38
|
+
expect(view.container.querySelector("image")?.getAttribute("href")).toBe("/assets/original.png");
|
|
39
|
+
expect(view.getByRole("img", { name: "Original image" })).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
13
42
|
it("changes delivery format when a reactive weight selects different artwork", () => {
|
|
14
43
|
const Mixed = createArtworkIcon("mixed", regular, {
|
|
15
44
|
bold: "M12 12h120v120H12z",
|
|
@@ -18,6 +47,7 @@ describe("original artwork icon contract", () => {
|
|
|
18
47
|
const view = render(() => <Mixed strokeWidth={weight()} />);
|
|
19
48
|
expect(view.container.querySelector("image")).not.toBeNull();
|
|
20
49
|
setWeight(3);
|
|
50
|
+
flush();
|
|
21
51
|
expect(view.container.querySelector("image")).toBeNull();
|
|
22
52
|
expect(view.container.querySelector("path")).not.toBeNull();
|
|
23
53
|
});
|
|
@@ -51,6 +81,7 @@ describe("original artwork icon contract", () => {
|
|
|
51
81
|
expect(svg.getAttribute("role")).toBe("img");
|
|
52
82
|
expect(svg.hasAttribute("aria-hidden")).toBe(false);
|
|
53
83
|
setSize(24);
|
|
84
|
+
flush();
|
|
54
85
|
expect(svg.getAttribute("width")).toBe("24");
|
|
55
86
|
expect(svg.getAttribute("class")).toContain("indicator");
|
|
56
87
|
});
|
|
@@ -80,6 +111,7 @@ describe("original artwork icon contract", () => {
|
|
|
80
111
|
const images = view.container.querySelectorAll("image");
|
|
81
112
|
expect(images[0].getAttribute("href")).toBe(regular);
|
|
82
113
|
setWeight(3);
|
|
114
|
+
flush();
|
|
83
115
|
expect(images[0].getAttribute("href")).toBe(bold);
|
|
84
116
|
expect(images[1].getAttribute("href")).toBe(filled);
|
|
85
117
|
expect(view.container.querySelector("svg")?.getAttribute("fill")).toBe(
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type Component,
|
|
6
|
-
type JSX,
|
|
7
|
-
} from "solid-js";
|
|
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";
|
|
8
5
|
|
|
9
6
|
export type IconProps = JSX.SvgSVGAttributes<SVGSVGElement> & {
|
|
10
7
|
size?: number | string;
|
|
8
|
+
transform?: string;
|
|
11
9
|
title?: string;
|
|
12
10
|
strokeWidth?: number | string;
|
|
13
11
|
absoluteStrokeWidth?: boolean;
|
|
@@ -16,18 +14,23 @@ export type IconProps = JSX.SvgSVGAttributes<SVGSVGElement> & {
|
|
|
16
14
|
|
|
17
15
|
export type ArtworkIconComponent = Component<IconProps>;
|
|
18
16
|
|
|
17
|
+
export type ArtworkSource = string | { readonly image: string };
|
|
18
|
+
|
|
19
19
|
export interface ArtworkVariants {
|
|
20
|
-
bold?:
|
|
21
|
-
filled?:
|
|
20
|
+
bold?: ArtworkSource;
|
|
21
|
+
filled?: ArtworkSource;
|
|
22
|
+
/** Intrinsic source orientation; native SVG transforms remain caller-controlled. */
|
|
23
|
+
rotation?: number;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
function ArtworkLayer(props: { source:
|
|
26
|
+
function ArtworkLayer(props: { source: ArtworkSource; id: string; fill: string }) {
|
|
27
|
+
const imageSource = () => typeof props.source === "string" ? props.source : props.source.image;
|
|
25
28
|
return (
|
|
26
29
|
<Show
|
|
27
|
-
when={props.source.startsWith("data:")}
|
|
30
|
+
when={typeof props.source !== "string" || props.source.startsWith("data:")}
|
|
28
31
|
fallback={
|
|
29
32
|
<path
|
|
30
|
-
d={props.source}
|
|
33
|
+
d={typeof props.source === "string" ? props.source : ""}
|
|
31
34
|
fill={props.fill}
|
|
32
35
|
fill-rule="evenodd"
|
|
33
36
|
stroke="none"
|
|
@@ -44,7 +47,7 @@ function ArtworkLayer(props: { source: string; id: string; fill: string }) {
|
|
|
44
47
|
maskUnits="userSpaceOnUse"
|
|
45
48
|
style={{ "mask-type": "alpha" }}
|
|
46
49
|
>
|
|
47
|
-
<image href={
|
|
50
|
+
<image href={imageSource()} x="0" y="0" width="144" height="144" />
|
|
48
51
|
</mask>
|
|
49
52
|
</defs>
|
|
50
53
|
<rect
|
|
@@ -67,33 +70,23 @@ function accessibility(props: IconProps, titleId: string) {
|
|
|
67
70
|
"aria-label": props["aria-label"],
|
|
68
71
|
"aria-labelledby":
|
|
69
72
|
props["aria-labelledby"] ?? (props.title ? titleId : undefined),
|
|
70
|
-
"aria-hidden":
|
|
73
|
+
"aria-hidden": ariaBool(
|
|
74
|
+
typeof props["aria-hidden"] === "string"
|
|
75
|
+
? props["aria-hidden"] === "true"
|
|
76
|
+
: (props["aria-hidden"] ?? (labelled ? undefined : true)),
|
|
77
|
+
),
|
|
71
78
|
} as const;
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
/** Render original generated artwork while retaining native SVG component props. */
|
|
75
82
|
export function createArtworkIcon(
|
|
76
83
|
name: string,
|
|
77
|
-
source:
|
|
84
|
+
source: ArtworkSource,
|
|
78
85
|
variants: ArtworkVariants = {}
|
|
79
86
|
): ArtworkIconComponent {
|
|
80
87
|
return function ArtworkIcon(props) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
"width",
|
|
84
|
-
"height",
|
|
85
|
-
"title",
|
|
86
|
-
"children",
|
|
87
|
-
"fill",
|
|
88
|
-
"role",
|
|
89
|
-
"aria-hidden",
|
|
90
|
-
"aria-label",
|
|
91
|
-
"aria-labelledby",
|
|
92
|
-
"strokeWidth",
|
|
93
|
-
"stroke-width",
|
|
94
|
-
"absoluteStrokeWidth",
|
|
95
|
-
"weight",
|
|
96
|
-
]);
|
|
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");
|
|
97
90
|
const id = `artwork-${createUniqueId()}`;
|
|
98
91
|
const titleId = `${id}-title`;
|
|
99
92
|
const artwork = () => {
|
|
@@ -114,16 +107,18 @@ export function createArtworkIcon(
|
|
|
114
107
|
stroke="none"
|
|
115
108
|
data-icon={name}
|
|
116
109
|
>
|
|
117
|
-
|
|
110
|
+
<title id={titleId}>{local.title}</title>
|
|
118
111
|
{local.children}
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
<g transform={variants.rotation ? `rotate(${variants.rotation} 72 72)` : undefined}>
|
|
113
|
+
<ArtworkLayer source={artwork()} id={id} fill="currentColor" />
|
|
114
|
+
{variants.filled && (
|
|
115
|
+
<ArtworkLayer
|
|
116
|
+
source={variants.filled}
|
|
117
|
+
id={`${id}-filled`}
|
|
118
|
+
fill="inherit"
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
</g>
|
|
127
122
|
</svg>
|
|
128
123
|
);
|
|
129
124
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/ellipsis
|
|
4
|
-
export default /* @__PURE__ */ createArtworkIcon("ellipsis-vertical", artwork);
|
|
3
|
+
import { artwork } from "./artwork/ellipsis";
|
|
4
|
+
export default /* @__PURE__ */ createArtworkIcon("ellipsis-vertical", artwork, { rotation: 90 });
|
package/src/icons/index.ts
CHANGED
|
@@ -164,6 +164,11 @@ export { default as CheckBold } from "./check-bold";
|
|
|
164
164
|
export { default as CircleCheckBold } from "./circle-check-bold";
|
|
165
165
|
export { default as TaxDocument } from "./tax-document";
|
|
166
166
|
export { default as Github } from "./github";
|
|
167
|
+
export { default as BirOffice } from "./bir-office";
|
|
168
|
+
export { default as Sales } from "./sales";
|
|
169
|
+
export { default as BirForm2307 } from "./bir-form-2307";
|
|
170
|
+
export { default as BirForm0619E } from "./bir-form-0619-e";
|
|
171
|
+
export { default as BirForm1601Eq } from "./bir-form-1601-eq";
|
|
167
172
|
export { default as AlertCircle } from "./circle-alert";
|
|
168
173
|
export { default as AlertTriangle } from "./triangle-alert";
|
|
169
174
|
export { default as BarChart3 } from "./chart-column";
|
package/src/icons/key-round.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/key
|
|
3
|
+
import { artwork } from "./artwork/key";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("key-round", artwork);
|
package/src/icons/registry.ts
CHANGED
|
@@ -167,6 +167,11 @@ const loaders = {
|
|
|
167
167
|
"circle-check-bold": () => import("./circle-check-bold"),
|
|
168
168
|
"tax-document": () => import("./tax-document"),
|
|
169
169
|
"github": () => import("./github"),
|
|
170
|
+
"bir-office": () => import("./bir-office"),
|
|
171
|
+
"sales": () => import("./sales"),
|
|
172
|
+
"bir-form-2307": () => import("./bir-form-2307"),
|
|
173
|
+
"bir-form-0619-e": () => import("./bir-form-0619-e"),
|
|
174
|
+
"bir-form-1601-eq": () => import("./bir-form-1601-eq"),
|
|
170
175
|
"bar-chart-3": () => import("./chart-column"),
|
|
171
176
|
"loader-2": () => import("./loader-circle"),
|
|
172
177
|
"alert-triangle": () => import("./triangle-alert"),
|
|
@@ -187,11 +192,11 @@ const loaders = {
|
|
|
187
192
|
|
|
188
193
|
export type IconName = keyof typeof loaders;
|
|
189
194
|
|
|
190
|
-
export function isIconName(name:
|
|
191
|
-
return Object.hasOwn(loaders, name);
|
|
195
|
+
export function isIconName(name: unknown): name is IconName {
|
|
196
|
+
return typeof name === "string" && Object.hasOwn(loaders, name);
|
|
192
197
|
}
|
|
193
198
|
|
|
194
|
-
export async function loadIcon(name:
|
|
199
|
+
export async function loadIcon(name: unknown): Promise<ArtworkIconComponent | null> {
|
|
195
200
|
if (!isIconName(name)) return null;
|
|
196
201
|
return (await loaders[name]()).default;
|
|
197
202
|
}
|
package/src/icons/settings-2.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/settings
|
|
3
|
+
import { artwork } from "./artwork/settings";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("settings-2", artwork);
|
package/src/icons/star.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
3
|
import { artwork } from "./artwork/star";
|
|
4
|
-
import { artwork as
|
|
5
|
-
export default /* @__PURE__ */ createArtworkIcon("star", artwork, { filled
|
|
4
|
+
import { artwork as filled } from "./artwork/star-filled";
|
|
5
|
+
export default /* @__PURE__ */ createArtworkIcon("star", artwork, { filled });
|
package/src/icons/user-round.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/user
|
|
3
|
+
import { artwork } from "./artwork/user";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("user-round", artwork);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/build-icon-assets.mjs.
|
|
2
2
|
import { createArtworkIcon } from "./create-artwork-icon";
|
|
3
|
-
import { artwork } from "./artwork/users
|
|
3
|
+
import { artwork } from "./artwork/users";
|
|
4
4
|
export default /* @__PURE__ */ createArtworkIcon("users-round", artwork);
|
|
@@ -12,7 +12,8 @@ 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
|
|
15
|
+
import type { Component } from "solid-js";
|
|
16
|
+
import type { JSX } from "@solidjs/web";
|
|
16
17
|
|
|
17
18
|
export type IconComponent = Component<JSX.SvgSVGAttributes<SVGSVGElement> & { size?: number }>;
|
|
18
19
|
|
|
@@ -17,7 +17,8 @@
|
|
|
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 {
|
|
20
|
+
import { createRoot, runWithOwner } from "solid-js";
|
|
21
|
+
import { createFetchResource, type FetchResource } from "./fetch-resource";
|
|
21
22
|
import { getActiveWorkspaceId } from "./integration";
|
|
22
23
|
import type { AvatarAccount } from "../components/base/AccountAvatar";
|
|
23
24
|
|
|
@@ -71,12 +72,14 @@ async function fetchAccountsIndex(wsId: number | string | null): Promise<IndexSh
|
|
|
71
72
|
|
|
72
73
|
// Module-level singletons so a page with N rows fires one fetch per org, not
|
|
73
74
|
// 2*N. Created on first useAccountsIndex() call.
|
|
74
|
-
let sharedResource:
|
|
75
|
+
let sharedResource: FetchResource<IndexShape> | undefined;
|
|
75
76
|
|
|
76
|
-
export function useAccountsIndex():
|
|
77
|
+
export function useAccountsIndex(): FetchResource<IndexShape> {
|
|
77
78
|
if (!sharedResource) {
|
|
78
|
-
|
|
79
|
-
sharedResource =
|
|
79
|
+
// Detached: the shared index must outlive whichever component asked first.
|
|
80
|
+
sharedResource = runWithOwner(null, () =>
|
|
81
|
+
createRoot(() => createFetchResource(() => getActiveWorkspaceId(), fetchAccountsIndex)),
|
|
82
|
+
)!;
|
|
80
83
|
}
|
|
81
84
|
return sharedResource;
|
|
82
85
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
package/src/utils/confirm.tsx
CHANGED
|
@@ -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 "
|
|
11
|
+
import { render } from "@solidjs/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,15 +69,16 @@ 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
|
|
72
|
+
* Use this from a ref callback, keeping the teardown for an owner-level
|
|
73
|
+
* onCleanup (Solid 2 forbids onCleanup inside a ref callback):
|
|
73
74
|
*
|
|
74
|
-
*
|
|
75
|
+
* let release: (() => void) | undefined;
|
|
76
|
+
* onCleanup(() => release?.());
|
|
77
|
+
* <div ref={(el) => { release = useFocusTrap(el); }}>
|
|
75
78
|
*
|
|
76
|
-
* Or from an effect:
|
|
79
|
+
* Or from an effect, returning the teardown:
|
|
77
80
|
*
|
|
78
|
-
* createEffect(() =>
|
|
79
|
-
* if (containerRef) onCleanup(useFocusTrap(containerRef));
|
|
80
|
-
* });
|
|
81
|
+
* createEffect(() => containerRef, (el) => (el ? useFocusTrap(el) : undefined));
|
|
81
82
|
*
|
|
82
83
|
* The trap only intercepts Tab. Escape, click-outside, and submit handling
|
|
83
84
|
* remain the modal's responsibility, the trap is purely a focus-keeper.
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
}
|
package/src/utils/highlight.tsx
CHANGED
|
@@ -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 {
|
|
11
|
+
import type { JSX } from "@solidjs/web";
|
|
12
12
|
import { injectCSS } from "./inject-css";
|
|
13
13
|
|
|
14
14
|
const MARK_STYLE_ID = "ksui-mark-style";
|
package/src/utils/modal-layer.ts
CHANGED
|
@@ -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;
|
|
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
|
|
23
|
+
* creation), so a plain element accessor — not a reactive signal — is enough.
|
|
24
24
|
*/
|
|
25
|
-
export function usePopoverMount(): () =>
|
|
25
|
+
export function usePopoverMount(): () => HTMLElement {
|
|
26
26
|
const layer = useContext(ModalLayerContext);
|
|
27
27
|
return () => layer() ?? document.body;
|
|
28
28
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createEffect, onCleanup } from "solid-js";
|
|
2
|
+
import { createFetchResource, type FetchResource } from "./fetch-resource";
|
|
2
3
|
|
|
3
4
|
export interface ObjectUrlOptions {
|
|
4
5
|
/** Extra fetch init, merged after `credentials: "include"` (e.g. tenant headers). */
|
|
@@ -25,8 +26,8 @@ export interface ObjectUrlOptions {
|
|
|
25
26
|
export function createObjectUrlResource(
|
|
26
27
|
href: () => string | null | undefined,
|
|
27
28
|
options: ObjectUrlOptions = {},
|
|
28
|
-
):
|
|
29
|
-
const
|
|
29
|
+
): FetchResource<string | null> {
|
|
30
|
+
const url = createFetchResource(
|
|
30
31
|
() => href() || null,
|
|
31
32
|
async (src) => {
|
|
32
33
|
const res = await fetch(src, { credentials: "include", ...options.init });
|
|
@@ -40,11 +41,13 @@ export function createObjectUrlResource(
|
|
|
40
41
|
// final one on unmount. During a refetch the resource holds its prior value
|
|
41
42
|
// (cur === prev), so an in-flight reload doesn't revoke a URL still on screen.
|
|
42
43
|
let prev: string | null = null;
|
|
43
|
-
createEffect(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
createEffect(
|
|
45
|
+
() => url() ?? null,
|
|
46
|
+
(cur) => {
|
|
47
|
+
if (prev && prev !== cur) URL.revokeObjectURL(prev);
|
|
48
|
+
prev = cur;
|
|
49
|
+
},
|
|
50
|
+
);
|
|
48
51
|
onCleanup(() => {
|
|
49
52
|
if (prev) URL.revokeObjectURL(prev);
|
|
50
53
|
});
|
package/src/utils/top-layer.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { onMount } from "solid-js";
|
|
2
1
|
import { injectCSS } from "./inject-css";
|
|
3
2
|
|
|
4
3
|
const STYLE_ID = "ksui-toplayer-style";
|
|
@@ -23,17 +22,16 @@ const STYLE_CSS = `
|
|
|
23
22
|
* ksui popup keeps its own mousedown/Escape listeners unchanged.
|
|
24
23
|
*
|
|
25
24
|
* Call from the portaled panel's ref, mirroring useFocusTrap's shape:
|
|
26
|
-
* ref={(el) => { popupRef = el;
|
|
25
|
+
* ref={(el) => { popupRef = el; useTopLayer(el); }}
|
|
27
26
|
*
|
|
28
|
-
* showPopover() is deferred to
|
|
27
|
+
* showPopover() is deferred to a microtask, not called inline here: this
|
|
29
28
|
* function runs synchronously inside <Portal>'s ref callback, which fires
|
|
30
29
|
* while the node is still detached (Portal appends its container to
|
|
31
30
|
* document.body *after* building the subtree) — el.isConnected is false
|
|
32
31
|
* and el.ownerDocument !== document at that point, so an inline call
|
|
33
|
-
* always throws InvalidStateError.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* the node is guaranteed connected. (Same fix shape as Modal's DialogModal,
|
|
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,
|
|
37
35
|
* which calls showModal() in onMount rather than in dialogEl's ref.)
|
|
38
36
|
*/
|
|
39
37
|
export function useTopLayer(el: HTMLElement | undefined): () => void {
|
|
@@ -41,7 +39,10 @@ export function useTopLayer(el: HTMLElement | undefined): () => void {
|
|
|
41
39
|
injectCSS(STYLE_ID, STYLE_CSS);
|
|
42
40
|
el.setAttribute("popover", "manual");
|
|
43
41
|
el.setAttribute("data-ksui-toplayer", "");
|
|
44
|
-
|
|
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;
|
|
45
46
|
// No Popover API (e.g. jsdom in unit tests) — nothing to promote, not an error.
|
|
46
47
|
if (typeof el.showPopover !== "function") return;
|
|
47
48
|
try {
|