@kirana-ui/web 0.1.1 → 0.2.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/llms.txt +3000 -0
- package/package.json +10 -2
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.d.ts +18 -3
- package/src/accordion.js +5 -4
- package/src/accordion.js.map +1 -1
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +12 -1
- package/src/alert-dialog.js.map +1 -1
- package/src/around.d.ts +19 -3
- package/src/around.js +45 -3
- package/src/around.js.map +1 -1
- package/src/autocomplete.d.ts +13 -2
- package/src/autocomplete.js +2 -1
- package/src/autocomplete.js.map +1 -1
- package/src/autosize.d.ts +10 -1
- package/src/autosize.js.map +1 -1
- package/src/avatar.d.ts +13 -1
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +10 -1
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +11 -1
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +10 -1
- package/src/carousel.js.map +1 -1
- package/src/checkbox.d.ts +12 -1
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +10 -1
- package/src/collapsible.js.map +1 -1
- package/src/combobox.d.ts +23 -6
- package/src/combobox.js +10 -11
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +11 -1
- package/src/command.js.map +1 -1
- package/src/context-menu.d.ts +12 -1
- package/src/context-menu.js.map +1 -1
- package/src/date-field.d.ts +10 -1
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +13 -1
- package/src/date-picker.js +2 -8
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +12 -1
- package/src/dialog.js.map +1 -1
- package/src/drawer.d.ts +17 -1
- package/src/drawer.js.map +1 -1
- package/src/field.d.ts +8 -1
- package/src/field.js.map +1 -1
- package/src/fieldset.d.ts +10 -1
- package/src/fieldset.js.map +1 -1
- package/src/form.d.ts +13 -1
- package/src/form.js.map +1 -1
- package/src/hover-card.d.ts +9 -1
- package/src/hover-card.js.map +1 -1
- package/src/hover-popup.d.ts +2 -1
- package/src/hover-popup.js +2 -8
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +56 -1
- package/src/input.d.ts +12 -1
- package/src/input.js.map +1 -1
- package/src/label.d.ts +9 -1
- package/src/label.js.map +1 -1
- package/src/listbox.d.ts +15 -1
- package/src/listbox.js.map +1 -1
- package/src/menu.d.ts +14 -4
- package/src/menu.js +2 -8
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +10 -1
- package/src/menubar.js.map +1 -1
- package/src/message-scroller.d.ts +10 -1
- package/src/message-scroller.js.map +1 -1
- package/src/meter.d.ts +10 -1
- package/src/meter.js.map +1 -1
- package/src/navigation-menu.d.ts +14 -4
- package/src/navigation-menu.js +7 -13
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +13 -1
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +11 -1
- package/src/otp.js.map +1 -1
- package/src/pagination.d.ts +10 -1
- package/src/pagination.js.map +1 -1
- package/src/popover.d.ts +14 -2
- package/src/popover.js +4 -9
- package/src/popover.js.map +1 -1
- package/src/progress.d.ts +10 -1
- package/src/progress.js.map +1 -1
- package/src/qr-code.d.ts +8 -1
- package/src/qr-code.js.map +1 -1
- package/src/radio-group.d.ts +10 -1
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +10 -1
- package/src/resizable.js.map +1 -1
- package/src/runtime.d.ts +35 -2
- package/src/runtime.js +28 -3
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +13 -2
- package/src/scroll-area.js +3 -1
- package/src/scroll-area.js.map +1 -1
- package/src/select.d.ts +25 -5
- package/src/select.js +35 -11
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +10 -1
- package/src/separator.js.map +1 -1
- package/src/slider.d.ts +18 -3
- package/src/slider.js +6 -6
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +12 -1
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +10 -1
- package/src/tabs.js.map +1 -1
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +20 -7
- package/src/toast.js +28 -7
- package/src/toast.js.map +1 -1
- package/src/toggle-group.d.ts +16 -1
- package/src/toggle-group.js.map +1 -1
- package/src/toggle.d.ts +12 -1
- package/src/toggle.js.map +1 -1
- package/src/toolbar.d.ts +10 -1
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +9 -1
- package/src/tooltip.js.map +1 -1
package/src/otp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement | null) => Number(element?.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-otp>` around `kui-part=\"root\"`, the one `input` that is typed in, and a `slot` for\n * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in\n * the page while the next character goes there. Slots may be in `group`s with a `separator`\n * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells\n * `value-change` and `complete`.\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props) => createOtp(props),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onComplete: { event: \"complete\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n group: (controller) => controller.group,\n separator: (controller) => controller.separator,\n slot(controller, element) {\n const slot = controller.slot(indexOf(element))\n return {\n part: slot.part,\n // Its character comes before what the page wrote in it: a caret.\n mount() {\n const text = element.ownerDocument.createTextNode(\"\")\n element.prepend(text)\n const stop = effect(() => void (text.data = slot.char.get()))\n return () => {\n stop()\n text.remove()\n }\n },\n }\n },\n caret: (controller, element) => ({\n part: controller.caretPart,\n mounted: controller.slot(indexOf(partAround(element, \"slot\"))).caret,\n }),\n },\n})\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement | null) => Number(element?.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-otp>` around `kui-part=\"root\"`, the one `input` that is typed in, and a `slot` for\n * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in\n * the page while the next character goes there. Slots may be in `group`s with a `separator`\n * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells\n * `value-change` and `complete`.\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props) => createOtp(props),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onComplete: { event: \"complete\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n group: (controller) => controller.group,\n separator: (controller) => controller.separator,\n slot(controller, element) {\n const slot = controller.slot(indexOf(element))\n return {\n part: slot.part,\n // Its character comes before what the page wrote in it: a caret.\n mount() {\n const text = element.ownerDocument.createTextNode(\"\")\n element.prepend(text)\n const stop = effect(() => void (text.data = slot.char.get()))\n return () => {\n stop()\n text.remove()\n }\n },\n }\n },\n caret: (controller, element) => ({\n part: controller.caretPart,\n mounted: controller.slot(indexOf(partAround(element, \"slot\"))).caret,\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-otp\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; complete: [\"onComplete\", \"value\"] }\n >\n }\n}\n"],"mappings":";;;;AAOA,MAAM,WAAW,YAAgC,OAAO,SAAS,aAAa,WAAW,KAAK,CAAC;;;;;;;;AAS/F,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,QAAQ;EACR,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,UAAU,UAAU,KAAK;CAClC,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,YAAY;GAAE,OAAO;GAAY,MAAM;GAAS,MAAM;EAAM;CAC9D;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,WAAW,KAAK,QAAQ,OAAO,CAAC;GAC7C,OAAO;IACL,MAAM,KAAK;IAEX,QAAQ;KACN,MAAM,OAAO,QAAQ,cAAc,eAAe,EAAE;KACpD,QAAQ,QAAQ,IAAI;KACpB,MAAM,OAAO,aAAa,MAAM,KAAK,OAAO,KAAK,KAAK,IAAI,EAAE;KAC5D,aAAa;MACX,KAAK;MACL,KAAK,OAAO;KACd;IACF;GACF;EACF;EACA,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW;GACjB,SAAS,WAAW,KAAK,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC,CAAC,CAAC;EACjE;CACF;AACF,CAAC"}
|
package/src/pagination.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Pagination, PaginationProps } from "@kirana-ui/core/pagination";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-pagination>` around a `kui-part="root"` nav with `previous` and `next` buttons and,
|
|
3
5
|
* between them, a `<template kui-each="items">` holding an `item` button for a page
|
|
@@ -5,5 +7,12 @@
|
|
|
5
7
|
* (`kui-when="ellipsis"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,
|
|
6
8
|
* `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.
|
|
7
9
|
*/
|
|
8
|
-
export declare const tag:
|
|
10
|
+
export declare const tag: Tag<PaginationProps, Pagination>;
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
"kui-pagination": ElementOf<typeof tag, {
|
|
14
|
+
"page-change": ["onPageChange", "page"];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
9
18
|
//# sourceMappingURL=pagination.d.ts.map
|
package/src/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/web/src/pagination.ts"],"sourcesContent":["import { createPagination } from \"@kirana-ui/core/pagination\"\nimport type { Pagination, PaginationEntry, PaginationProps } from \"@kirana-ui/core/pagination\"\n\nimport { defineElement, entryAround } from \"./runtime.ts\"\n\n/**\n * `<kui-pagination>` around a `kui-part=\"root\"` nav with `previous` and `next` buttons and,\n * between them, a `<template kui-each=\"items\">` holding an `item` button for a page\n * (`kui-when=\"page\"`; `{page}` is its number) and an `ellipsis` for a gap\n * (`kui-when=\"ellipsis\"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,\n * `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.\n */\nexport const tag = defineElement<PaginationProps, Pagination>({\n tag: \"kui-pagination\",\n props: {\n page: \"number\",\n \"default-page\": \"number\",\n count: \"number\",\n \"page-size\": \"number\",\n \"sibling-count\": \"number\",\n \"boundary-count\": \"number\",\n disabled: \"boolean\",\n },\n create: (props) => createPagination(props),\n changes: { onPageChange: { event: \"page-change\", prop: \"page\" } },\n lists: {\n items: (controller) => ({\n entries: controller.entries,\n key: (entry: PaginationEntry) => entry.key,\n type: (entry: PaginationEntry) => entry.type,\n }),\n },\n parts: {\n root: (controller) => controller.root,\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n ellipsis: (controller) => controller.ellipsis,\n item(controller, element) {\n const entry = entryAround<PaginationEntry>(element)\n return entry?.type === \"page\" ? controller.item(entry.page) : undefined\n },\n },\n})\n"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/web/src/pagination.ts"],"sourcesContent":["import { createPagination } from \"@kirana-ui/core/pagination\"\nimport type { Pagination, PaginationEntry, PaginationProps } from \"@kirana-ui/core/pagination\"\n\nimport { defineElement, entryAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-pagination>` around a `kui-part=\"root\"` nav with `previous` and `next` buttons and,\n * between them, a `<template kui-each=\"items\">` holding an `item` button for a page\n * (`kui-when=\"page\"`; `{page}` is its number) and an `ellipsis` for a gap\n * (`kui-when=\"ellipsis\"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,\n * `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.\n */\nexport const tag = defineElement<PaginationProps, Pagination>({\n tag: \"kui-pagination\",\n props: {\n page: \"number\",\n \"default-page\": \"number\",\n count: \"number\",\n \"page-size\": \"number\",\n \"sibling-count\": \"number\",\n \"boundary-count\": \"number\",\n disabled: \"boolean\",\n },\n create: (props) => createPagination(props),\n changes: { onPageChange: { event: \"page-change\", prop: \"page\" } },\n lists: {\n items: (controller) => ({\n entries: controller.entries,\n key: (entry: PaginationEntry) => entry.key,\n type: (entry: PaginationEntry) => entry.type,\n }),\n },\n parts: {\n root: (controller) => controller.root,\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n ellipsis: (controller) => controller.ellipsis,\n item(controller, element) {\n const entry = entryAround<PaginationEntry>(element)\n return entry?.type === \"page\" ? controller.item(entry.page) : undefined\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-pagination\": ElementOf<typeof tag, { \"page-change\": [\"onPageChange\", \"page\"] }>\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,MAAM,cAA2C;CAC5D,KAAK;CACL,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,OAAO;EACP,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,UAAU;CACZ;CACA,SAAS,UAAU,iBAAiB,KAAK;CACzC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO,EACL,QAAQ,gBAAgB;EACtB,SAAS,WAAW;EACpB,MAAM,UAA2B,MAAM;EACvC,OAAO,UAA2B,MAAM;CAC1C,GACF;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,KAAK,YAAY,SAAS;GACxB,MAAM,QAAQ,YAA6B,OAAO;GAClD,OAAO,OAAO,SAAS,SAAS,WAAW,KAAK,MAAM,IAAI,IAAI,KAAA;EAChE;CACF;AACF,CAAC"}
|
package/src/popover.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { PopoverProps } from "@kirana-ui/core/popover";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
|
|
3
5
|
* page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
|
|
4
|
-
* `kui-align-offset`, `kui-collision-padding`
|
|
6
|
+
* `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is
|
|
7
|
+
* placed against, when that is not the trigger) around the `popup`, which may hold a `title`,
|
|
5
8
|
* a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
|
|
6
9
|
*/
|
|
7
|
-
export declare const tag:
|
|
10
|
+
export declare const tag: Tag<{
|
|
11
|
+
id: string;
|
|
12
|
+
}, import("@kirana-ui/core/popover").Popover>;
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
"kui-popover": ElementOf<As<typeof tag, PopoverProps>, {
|
|
16
|
+
"open-change": ["onOpenChange", "open"];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
//# sourceMappingURL=popover.d.ts.map
|
package/src/popover.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { positioner } from "./around.js";
|
|
2
2
|
import { defineElement } from "./runtime.js";
|
|
3
3
|
import { createPopover } from "@kirana-ui/core/popover";
|
|
4
4
|
// src/popover.ts
|
|
5
5
|
/**
|
|
6
6
|
* `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
|
|
7
7
|
* page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
|
|
8
|
-
* `kui-align-offset`, `kui-collision-padding`
|
|
8
|
+
* `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is
|
|
9
|
+
* placed against, when that is not the trigger) around the `popup`, which may hold a `title`,
|
|
9
10
|
* a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
|
|
10
11
|
*/
|
|
11
12
|
const tag = defineElement({
|
|
@@ -21,13 +22,7 @@ const tag = defineElement({
|
|
|
21
22
|
} },
|
|
22
23
|
parts: {
|
|
23
24
|
trigger: (controller) => controller.trigger,
|
|
24
|
-
positioner
|
|
25
|
-
place(controller.positioning, element);
|
|
26
|
-
return {
|
|
27
|
-
mounted: controller.mounted,
|
|
28
|
-
part: controller.positioner
|
|
29
|
-
};
|
|
30
|
-
},
|
|
25
|
+
positioner,
|
|
31
26
|
popup: (controller) => controller.popup,
|
|
32
27
|
title: (controller) => controller.title,
|
|
33
28
|
description: (controller) => controller.description,
|
package/src/popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/web/src/popover.ts"],"sourcesContent":["import { createPopover } from \"@kirana-ui/core/popover\"\n\nimport {
|
|
1
|
+
{"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/web/src/popover.ts"],"sourcesContent":["import { createPopover } from \"@kirana-ui/core/popover\"\nimport type { PopoverProps } from \"@kirana-ui/core/popover\"\n\nimport { positioner } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-popover>` around a `kui-part=\"trigger\"` button and a `portal`, drawn at the end of the\n * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,\n * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is\n * placed against, when that is not the trigger) around the `popup`, which may hold a `title`,\n * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-popover\",\n props: { open: \"boolean\", \"default-open\": \"boolean\" },\n create: (props) => createPopover(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller) => controller.trigger,\n positioner,\n popup: (controller) => controller.popup,\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-popover\": ElementOf<\n As<typeof tag, PopoverProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;CAAU;CACpD,SAAS,UAAU,cAAc,KAAK;CACtC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,eAAe,WAAW;EACpC;EACA,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
|
package/src/progress.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { ProgressProps } from "@kirana-ui/core/progress";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-progress>` around `kui-part="root"`, a `label`, a `track` with its `indicator`, and a
|
|
3
5
|
* `value`, which says the value as it is written unless the page gave it something to say.
|
|
4
6
|
* `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.
|
|
5
7
|
*/
|
|
6
|
-
export declare const tag:
|
|
8
|
+
export declare const tag: Tag<{
|
|
9
|
+
id: string;
|
|
10
|
+
}, import("@kirana-ui/core/meter").ValueBar>;
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
"kui-progress": ElementOf<As<typeof tag, ProgressProps>>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
//# sourceMappingURL=progress.d.ts.map
|
package/src/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/web/src/progress.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { defineElement } from \"./runtime.ts\"\n\n/**\n * `<kui-progress>` around `kui-part=\"root\"`, a `label`, a `track` with its `indicator`, and a\n * `value`, which says the value as it is written unless the page gave it something to say.\n * `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.\n */\nexport const tag = defineElement({\n tag: \"kui-progress\",\n props: { value: \"number\", min: \"number\", max: \"number\", locale: \"string\" },\n properties: [\"format\", \"getAriaValueText\"],\n create: (props) =>\n createProgress(\n computed(() => {\n const own = props.get() as { id: string; value?: number | null }\n return { ...own, value: own.value ?? null }\n }) as never\n ),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n label: (controller) => controller.label,\n track: (controller) => controller.track,\n indicator: (controller) => controller.indicator,\n value: (controller) => ({ part: controller.value, text: controller.text }),\n },\n})\n"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/web/src/progress.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createProgress } from \"@kirana-ui/core/progress\"\nimport type { ProgressProps } from \"@kirana-ui/core/progress\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-progress>` around `kui-part=\"root\"`, a `label`, a `track` with its `indicator`, and a\n * `value`, which says the value as it is written unless the page gave it something to say.\n * `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.\n */\nexport const tag = defineElement({\n tag: \"kui-progress\",\n props: { value: \"number\", min: \"number\", max: \"number\", locale: \"string\" },\n properties: [\"format\", \"getAriaValueText\"],\n create: (props) =>\n createProgress(\n computed(() => {\n const own = props.get() as { id: string; value?: number | null }\n return { ...own, value: own.value ?? null }\n }) as never\n ),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n label: (controller) => controller.label,\n track: (controller) => controller.track,\n indicator: (controller) => controller.indicator,\n value: (controller) => ({ part: controller.value, text: controller.text }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-progress\": ElementOf<As<typeof tag, ProgressProps>>\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,KAAK;EAAU,KAAK;EAAU,QAAQ;CAAS;CACzE,YAAY,CAAC,UAAU,kBAAkB;CACzC,SAAS,UACP,eACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,IAAI,SAAS;EAAK;CAC5C,CAAC,CACH;CACF,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,QAAQ,gBAAgB;GAAE,MAAM,WAAW;GAAO,MAAM,WAAW;EAAK;CAC1E;AACF,CAAC"}
|
package/src/qr-code.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { QrCode, QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-qr-code>` around `kui-part="root"`, a `frame` (an `<svg>`) and its `pattern` (a
|
|
3
5
|
* `<path>`). `value`, `correction`.
|
|
4
6
|
*/
|
|
5
|
-
export declare const tag:
|
|
7
|
+
export declare const tag: Tag<QrCodeProps, QrCode>;
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
"kui-qr-code": ElementOf<typeof tag>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
6
13
|
//# sourceMappingURL=qr-code.d.ts.map
|
package/src/qr-code.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/web/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode, QrCodeProps } from \"@kirana-ui/core/qr-code\"\n\nimport { defineElement } from \"./runtime.ts\"\n\n/**\n * `<kui-qr-code>` around `kui-part=\"root\"`, a `frame` (an `<svg>`) and its `pattern` (a\n * `<path>`). `value`, `correction`.\n */\nexport const tag = defineElement<QrCodeProps, QrCode>({\n tag: \"kui-qr-code\",\n props: { value: \"string\", correction: \"string\" },\n create: (props) => createQrCode(props),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n frame: (controller) => controller.frame,\n pattern: (controller) => controller.pattern,\n },\n})\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/web/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode, QrCodeProps } from \"@kirana-ui/core/qr-code\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-qr-code>` around `kui-part=\"root\"`, a `frame` (an `<svg>`) and its `pattern` (a\n * `<path>`). `value`, `correction`.\n */\nexport const tag = defineElement<QrCodeProps, QrCode>({\n tag: \"kui-qr-code\",\n props: { value: \"string\", correction: \"string\" },\n create: (props) => createQrCode(props),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n frame: (controller) => controller.frame,\n pattern: (controller) => controller.pattern,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-qr-code\": ElementOf<typeof tag>\n }\n}\n"],"mappings":";;;;;;;AAUA,MAAa,MAAM,cAAmC;CACpD,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,YAAY;CAAS;CAC/C,SAAS,UAAU,aAAa,KAAK;CACrC,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,UAAU,eAAe,WAAW;CACtC;AACF,CAAC"}
|
package/src/radio-group.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { RadioGroupProps } from "@kirana-ui/core/radio-group";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-radio-group>` around `kui-part="root"` and an `item` button for each `value`, with an
|
|
3
5
|
* `indicator` inside that is in the page while its item is the chosen one. An item draws the
|
|
4
6
|
* hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,
|
|
5
7
|
* `read-only`, `required`, `name`, `form`; it tells `value-change`.
|
|
6
8
|
*/
|
|
7
|
-
export declare const tag: string
|
|
9
|
+
export declare const tag: Tag<RadioGroupProps<string>, import("@kirana-ui/core/radio-group").RadioGroup<string>>;
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
"kui-radio-group": ElementOf<typeof tag, {
|
|
13
|
+
"value-change": ["onValueChange", "value"];
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
//# sourceMappingURL=radio-group.d.ts.map
|
package/src/radio-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/web/src/radio-group.ts"],"sourcesContent":["import { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroupProps } from \"@kirana-ui/core/radio-group\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\n\nconst valueOf = (element: HTMLElement) =>\n partAround(element, \"item\")?.getAttribute(\"kui-value\") ?? \"\"\nconst options = (element: HTMLElement) => () =>\n partAround(element, \"item\")?.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}\n\n/**\n * `<kui-radio-group>` around `kui-part=\"root\"` and an `item` button for each `value`, with an\n * `indicator` inside that is in the page while its item is the chosen one. An item draws the\n * hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,\n * `read-only`, `required`, `name`, `form`; it tells `value-change`.\n */\nexport const tag = defineElement<\n RadioGroupProps<string>,\n ReturnType<typeof createRadioGroup<string>>\n>({\n tag: \"kui-radio-group\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props, host) => createRadioGroup<string>(props, { field: fieldAround(host) }),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n item: (controller, element) => ({\n part: controller.item(valueOf(element), options(element)),\n inner: controller.itemInput(valueOf(element), options(element)),\n }),\n indicator: (controller, element) => controller.indicator(valueOf(element)),\n },\n})\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/web/src/radio-group.ts"],"sourcesContent":["import { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroupProps } from \"@kirana-ui/core/radio-group\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst valueOf = (element: HTMLElement) =>\n partAround(element, \"item\")?.getAttribute(\"kui-value\") ?? \"\"\nconst options = (element: HTMLElement) => () =>\n partAround(element, \"item\")?.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}\n\n/**\n * `<kui-radio-group>` around `kui-part=\"root\"` and an `item` button for each `value`, with an\n * `indicator` inside that is in the page while its item is the chosen one. An item draws the\n * hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,\n * `read-only`, `required`, `name`, `form`; it tells `value-change`.\n */\nexport const tag = defineElement<\n RadioGroupProps<string>,\n ReturnType<typeof createRadioGroup<string>>\n>({\n tag: \"kui-radio-group\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props, host) => createRadioGroup<string>(props, { field: fieldAround(host) }),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n item: (controller, element) => ({\n part: controller.item(valueOf(element), options(element)),\n inner: controller.itemInput(valueOf(element), options(element)),\n }),\n indicator: (controller, element) => controller.indicator(valueOf(element)),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-radio-group\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;AAOA,MAAM,WAAW,YACf,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,WAAW,KAAK;AAC5D,MAAM,WAAW,kBACf,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;;;;;;;AAQpF,MAAa,MAAM,cAGjB;CACA,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,OAAO,SAAS,iBAAyB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACrF,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,YAAY,aAAa;GAC9B,MAAM,WAAW,KAAK,QAAQ,OAAO,GAAG,QAAQ,OAAO,CAAC;GACxD,OAAO,WAAW,UAAU,QAAQ,OAAO,GAAG,QAAQ,OAAO,CAAC;EAChE;EACA,YAAY,YAAY,YAAY,WAAW,UAAU,QAAQ,OAAO,CAAC;CAC3E;AACF,CAAC"}
|
package/src/resizable.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Resizable, ResizableProps } from "@kirana-ui/core/resizable";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-resizable>` around `kui-part="group"`, its `panel`s (`kui-default-size`,
|
|
3
5
|
* `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two
|
|
4
6
|
* (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.
|
|
5
7
|
*/
|
|
6
|
-
export declare const tag:
|
|
8
|
+
export declare const tag: Tag<ResizableProps, Resizable>;
|
|
9
|
+
declare global {
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
"kui-resizable": ElementOf<typeof tag, {
|
|
12
|
+
"sizes-change": ["onSizesChange", "sizes"];
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
//# sourceMappingURL=resizable.d.ts.map
|
package/src/resizable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/web/src/resizable.ts"],"sourcesContent":["import { createResizable } from \"@kirana-ui/core/resizable\"\nimport type { Resizable, ResizableProps } from \"@kirana-ui/core/resizable\"\n\nimport { defineElement } from \"./runtime.ts\"\n\nconst number = (element: HTMLElement, name: string) => {\n const text = element.getAttribute(name)\n return text === null\n ? {}\n : { [name.slice(4).replace(/-./g, (at) => at[1]!.toUpperCase())]: +text }\n}\n\n/**\n * `<kui-resizable>` around `kui-part=\"group\"`, its `panel`s (`kui-default-size`,\n * `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two\n * (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.\n */\nexport const tag = defineElement<ResizableProps, Resizable>({\n tag: \"kui-resizable\",\n props: { orientation: \"string\", \"keyboard-step\": \"number\", disabled: \"boolean\" },\n create: (props) => createResizable(props),\n changes: { onSizesChange: { event: \"sizes-change\", prop: \"sizes\", hold: false } },\n parts: {\n group: (controller) => controller.group,\n panel: (controller, element) =>\n controller.panel(() => ({\n ...number(element, \"kui-default-size\"),\n ...number(element, \"kui-min-size\"),\n ...number(element, \"kui-max-size\"),\n })),\n handle: (controller, element) =>\n controller.handle(() => (element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {})),\n },\n})\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/web/src/resizable.ts"],"sourcesContent":["import { createResizable } from \"@kirana-ui/core/resizable\"\nimport type { Resizable, ResizableProps } from \"@kirana-ui/core/resizable\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst number = (element: HTMLElement, name: string) => {\n const text = element.getAttribute(name)\n return text === null\n ? {}\n : { [name.slice(4).replace(/-./g, (at) => at[1]!.toUpperCase())]: +text }\n}\n\n/**\n * `<kui-resizable>` around `kui-part=\"group\"`, its `panel`s (`kui-default-size`,\n * `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two\n * (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.\n */\nexport const tag = defineElement<ResizableProps, Resizable>({\n tag: \"kui-resizable\",\n props: { orientation: \"string\", \"keyboard-step\": \"number\", disabled: \"boolean\" },\n create: (props) => createResizable(props),\n changes: { onSizesChange: { event: \"sizes-change\", prop: \"sizes\", hold: false } },\n parts: {\n group: (controller) => controller.group,\n panel: (controller, element) =>\n controller.panel(() => ({\n ...number(element, \"kui-default-size\"),\n ...number(element, \"kui-min-size\"),\n ...number(element, \"kui-max-size\"),\n })),\n handle: (controller, element) =>\n controller.handle(() => (element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {})),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-resizable\": ElementOf<typeof tag, { \"sizes-change\": [\"onSizesChange\", \"sizes\"] }>\n }\n}\n"],"mappings":";;;AAMA,MAAM,UAAU,SAAsB,SAAiB;CACrD,MAAM,OAAO,QAAQ,aAAa,IAAI;CACtC,OAAO,SAAS,OACZ,CAAC,IACD,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,QAAQ,OAAO,GAAG,EAAE,CAAE,YAAY,CAAC,IAAI,CAAC,KAAK;AAC5E;;;;;;AAOA,MAAa,MAAM,cAAyC;CAC1D,KAAK;CACL,OAAO;EAAE,aAAa;EAAU,iBAAiB;EAAU,UAAU;CAAU;CAC/E,SAAS,UAAU,gBAAgB,KAAK;CACxC,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;EAAS,MAAM;CAAM,EAAE;CAChF,OAAO;EACL,QAAQ,eAAe,WAAW;EAClC,QAAQ,YAAY,YAClB,WAAW,aAAa;GACtB,GAAG,OAAO,SAAS,kBAAkB;GACrC,GAAG,OAAO,SAAS,cAAc;GACjC,GAAG,OAAO,SAAS,cAAc;EACnC,EAAE;EACJ,SAAS,YAAY,YACnB,WAAW,aAAc,QAAQ,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAAE;CAC5F;AACF,CAAC"}
|
package/src/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Part, ReadonlySignal } from "@kirana-ui/core";
|
|
1
|
+
import { ChangeDetails, Part, ReadonlySignal } from "@kirana-ui/core";
|
|
2
2
|
/**
|
|
3
3
|
* A component as a custom element, for a page with no framework.
|
|
4
4
|
*
|
|
@@ -86,6 +86,39 @@ export interface ElementSpec<Props extends {
|
|
|
86
86
|
/** Each part by its `kui-part` name. */
|
|
87
87
|
parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>;
|
|
88
88
|
}
|
|
89
|
+
declare const DEFINED: unique symbol;
|
|
90
|
+
/**
|
|
91
|
+
* A custom element's name as `defineElement` gives it. For TypeScript it also says what the
|
|
92
|
+
* element was defined from, which `ElementOf` reads back; in the page it is the name alone.
|
|
93
|
+
*/
|
|
94
|
+
export type Tag<Props = unknown, Controller = unknown> = string & {
|
|
95
|
+
readonly [DEFINED]?: readonly [Props, Controller];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* What a component tells: an event whose `detail` holds the value under its prop's name
|
|
99
|
+
* (`detail.open`, `detail.values`) and why it changed (`detail.details.reason`).
|
|
100
|
+
* `preventDefault()` keeps the value as it was.
|
|
101
|
+
*/
|
|
102
|
+
export type Told<Prop extends string, Value> = CustomEvent<{ readonly [Name in Prop]: Value; } & {
|
|
103
|
+
readonly details: ChangeDetails;
|
|
104
|
+
}>;
|
|
105
|
+
/** A tag with its props said, where `defineElement` was left to work them out. */
|
|
106
|
+
export type As<Defined, Props> = Defined extends Tag<unknown, infer Controller> ? Tag<Props, Controller> : never;
|
|
107
|
+
type Callback<Props, Name> = Name extends keyof Props ? Extract<Props[Name], (...given: never[]) => unknown> : never;
|
|
108
|
+
interface Listens<Events> {
|
|
109
|
+
addEventListener<Type extends keyof Events>(type: Type, listener: (this: HTMLElement, event: Events[Type]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
110
|
+
removeEventListener<Type extends keyof Events>(type: Type, listener: (this: HTMLElement, event: Events[Type]) => void, options?: boolean | EventListenerOptions): void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A component's custom element as TypeScript knows it, from its `tag`: its props as properties
|
|
114
|
+
* (`element.open = true`), its controller once it has begun, and its events with their
|
|
115
|
+
* `detail`. `Changes` names each event with the callback it tells and the prop it holds
|
|
116
|
+
* (`{ "open-change": ["onOpenChange", "open"] }`), as the element's `changes` do; `More` is
|
|
117
|
+
* for events its parts tell from their own elements, which reach it too.
|
|
118
|
+
*/
|
|
119
|
+
export type ElementOf<Defined, Changes = {}, More = {}> = Defined extends Tag<infer Props, infer Controller> ? Listens<{ readonly [Event in keyof Changes]: Changes[Event] extends readonly [infer Name, infer Prop extends string] ? Told<Prop, Parameters<Callback<Props, Name>>[0]> : never; } & More> & { -readonly [Name in keyof Props as Name extends "id" | `on${Capitalize<string>}` ? never : Name]?: Props[Name]; } & {
|
|
120
|
+
controller?: Controller;
|
|
121
|
+
} & HTMLElement : never;
|
|
89
122
|
/**
|
|
90
123
|
* The controller of the component around a custom element: the field a control is in, the
|
|
91
124
|
* group a toggle is one of. Through a portal too: what was moved to the page's end is still
|
|
@@ -119,6 +152,6 @@ export declare function partProps<Props>(element: HTMLElement, kinds: Record<str
|
|
|
119
152
|
*/
|
|
120
153
|
export declare function defineElement<Props extends {
|
|
121
154
|
id: string;
|
|
122
|
-
}, Controller extends object>(spec: ElementSpec<Props, Controller>):
|
|
155
|
+
}, Controller extends object>(spec: ElementSpec<Props, Controller>): Tag<Props, Controller>;
|
|
123
156
|
export {};
|
|
124
157
|
//# sourceMappingURL=runtime.d.ts.map
|
package/src/runtime.js
CHANGED
|
@@ -45,14 +45,34 @@ function hostAround(host, tags) {
|
|
|
45
45
|
function partAround(element, name) {
|
|
46
46
|
return element.closest(`[kui-part="${name}"]`);
|
|
47
47
|
}
|
|
48
|
+
let settling;
|
|
49
|
+
/**
|
|
50
|
+
* A page's markup is drawn before its components begin, so a part's style (a slider thumb's
|
|
51
|
+
* place) reaches an element the browser has already styled, and a design's `transition` on it
|
|
52
|
+
* would run as the page begins: each thumb gliding to where it was all along. A framework's
|
|
53
|
+
* element has its style before it is first drawn; here what the first style started is ended
|
|
54
|
+
* before the page is drawn again, once for all the parts of a pass.
|
|
55
|
+
*/
|
|
56
|
+
function settle(element) {
|
|
57
|
+
if (typeof element.getAnimations !== "function") return;
|
|
58
|
+
if (!settling) {
|
|
59
|
+
const written = settling = [];
|
|
60
|
+
queueMicrotask(() => {
|
|
61
|
+
settling = void 0;
|
|
62
|
+
for (const each of written) for (const animation of each.getAnimations()) if (animation instanceof CSSTransition) animation.cancel();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
settling.push(element);
|
|
66
|
+
}
|
|
48
67
|
/**
|
|
49
68
|
* Puts a part on an element, and takes it off whole: what the part wrote is gone with it. A
|
|
50
69
|
* framework draws a new element each time a part comes back; here the same element is the
|
|
51
70
|
* part again, and must not still say what it said before (`data-closed`, `aria-controls`).
|
|
52
71
|
*/
|
|
53
|
-
function put(element, part) {
|
|
72
|
+
function put(element, part, drawn = false) {
|
|
54
73
|
const before = new Map(Array.from(element.attributes, (each) => [each.name, each.value]));
|
|
55
74
|
const unbind = bind(element, part);
|
|
75
|
+
if (drawn && part.props.peek().style) settle(element);
|
|
56
76
|
return () => {
|
|
57
77
|
unbind();
|
|
58
78
|
for (const { name } of Array.from(element.attributes)) if (!before.has(name) && name !== "class") element.removeAttribute(name);
|
|
@@ -138,6 +158,7 @@ function defineElement(spec) {
|
|
|
138
158
|
#held = /* @__PURE__ */ new Map();
|
|
139
159
|
#stops = [];
|
|
140
160
|
#leaving = false;
|
|
161
|
+
#first = false;
|
|
141
162
|
#watch = () => {};
|
|
142
163
|
connectedCallback() {
|
|
143
164
|
this.#leaving = false;
|
|
@@ -186,7 +207,9 @@ function defineElement(spec) {
|
|
|
186
207
|
subtree: true
|
|
187
208
|
});
|
|
188
209
|
this.#stops.push(() => observer.disconnect());
|
|
210
|
+
this.#first = true;
|
|
189
211
|
for (const each of Array.from(this.children)) if (drawable(each)) this.#scan(each);
|
|
212
|
+
this.#first = false;
|
|
190
213
|
const inner = spec.inner?.(this.controller);
|
|
191
214
|
if (inner) {
|
|
192
215
|
const input = this.ownerDocument.createElement("input");
|
|
@@ -359,11 +382,13 @@ function defineElement(spec) {
|
|
|
359
382
|
stops.push(effect(() => void (element.textContent = text.get() ?? "")), () => void (element.textContent = ""));
|
|
360
383
|
}
|
|
361
384
|
const mounted = element.hasAttribute("kui-keep-mounted") ? void 0 : drawn.mounted;
|
|
362
|
-
|
|
385
|
+
const first = this.#first;
|
|
386
|
+
if (!mounted) return void stops.push(put(element, drawn.part, first));
|
|
363
387
|
const home = this.ownerDocument.createComment("");
|
|
364
388
|
let unbind;
|
|
365
389
|
stops.push(effect(() => {
|
|
366
390
|
const elsewhere = drawn.into?.get();
|
|
391
|
+
const own = first && !elsewhere && !held.parked && !unbind;
|
|
367
392
|
if (mounted.get() && (!drawn.into || elsewhere)) {
|
|
368
393
|
if (elsewhere) {
|
|
369
394
|
if (!held.parked && element.parentNode) element.replaceWith(home);
|
|
@@ -373,7 +398,7 @@ function defineElement(spec) {
|
|
|
373
398
|
held.parked = false;
|
|
374
399
|
home.replaceWith(element);
|
|
375
400
|
}
|
|
376
|
-
unbind ??= put(element, drawn.part);
|
|
401
|
+
unbind ??= put(element, drawn.part, own);
|
|
377
402
|
} else {
|
|
378
403
|
unbind?.();
|
|
379
404
|
unbind = void 0;
|
package/src/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/web/src/runtime.ts"],"sourcesContent":["import { bind, effect, sameProps, signal } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Part, ReadonlySignal, Signal } from \"@kirana-ui/core\"\n\n/**\n * A component as a custom element, for a page with no framework.\n *\n * The custom element (`<kui-dialog>`) holds the component and draws nothing: it takes no room\n * (`display: contents`) and no attribute of the component's. Its parts are the page's own\n * elements, named by `kui-part` (`<button kui-part=\"trigger\">`), the root among them. So a\n * trigger is a real button and a switch a real button, and the page is the page the other\n * adapters draw: nothing is wrapped, and there is no shadow root for a design to reach into.\n *\n * A part that is in the page only some of the time (a closed panel, a popup) is taken out of\n * the page while it is not, and put back where it was; `kui-keep-mounted` keeps it.\n */\n\n/** What a part's name gives: the part, and what comes with it. */\nexport interface Drawn {\n readonly part: Part\n /** In the page only while this holds. */\n readonly mounted?: ReadonlySignal<boolean> | undefined\n /** Runs while the part is the component's. Returns the stop. */\n mount?(): () => void\n /** A hidden native input the part draws itself, as its last child. */\n readonly inner?: Part | undefined\n /**\n * Where the part is drawn while it is mounted, when that is not where it was written: a\n * navigation menu's content, in the menu's one viewport. Out of the page while there is none.\n */\n readonly into?: ReadonlySignal<HTMLElement | undefined> | undefined\n /** What the part's element says, when the page gave it nothing to say. */\n readonly text?: ReadonlySignal<string | undefined> | undefined\n}\n\ntype Kind = \"boolean\" | \"string\" | \"number\"\n\n/** A list a component draws from a `<template kui-each>`. */\nexport interface Each<Entry = any> {\n readonly entries: ReadonlySignal<readonly Entry[]> | readonly Entry[]\n /** What an entry is known by from one drawing to the next. */\n key(entry: Entry): string | number\n /**\n * Which of the template's elements an entry is drawn with, when they differ: the ones\n * whose `kui-when` says so (a page, an ellipsis). Elements without `kui-when` are for all.\n */\n type?(entry: Entry): string\n /**\n * What `{name}` stands for in the template's text and attributes\n * (`data-testid=\"row-{id}\"`). Left out: the entry's own fields.\n */\n values?(entry: Entry): Record<string, unknown>\n}\n\nconst ENTRY = new WeakMap<Node, unknown>()\n\n/** The entry an element was stamped for, or the nearest around it: a part reads its own. */\nexport function entryAround<Entry>(element: Node): Entry | undefined {\n for (let each: Node | null = element; each; each = each.parentNode) {\n if (ENTRY.has(each)) return ENTRY.get(each) as Entry\n }\n return undefined\n}\n\n/** `{name}` in a text, for each name there is a value for; another brace is the page's own. */\nconst fill = (text: string, values: Record<string, unknown>) =>\n text.replace(/\\{([A-Za-z_][\\w-]*)\\}/g, (whole, name: string) =>\n name in values ? String(values[name] ?? \"\") : whole\n )\n\ninterface Row {\n entry: unknown\n nodes: ChildNode[]\n /** Where a `{name}` was written: read again when the entry changes. */\n written: (readonly [Attr | Text, string])[]\n}\n\nexport interface ElementSpec<Props extends { id: string }, Controller> {\n /** The custom element's name: `kui-dialog`. */\n tag: string\n /** Its props by attribute name, each with how an attribute's text is read. */\n props: Record<string, Kind>\n /** Props that are only properties: a function, an object. By their names as properties. */\n properties?: readonly string[] | undefined\n /**\n * What the component draws a list of, by name: a calendar's weeks, a toast for each\n * message. The page writes one of an entry as a `<template kui-each=\"name\">` where the\n * list goes, and the element stamps it for each entry, keyed, so an entry that stays keeps\n * its elements. `around` is the entry of the list this one is written in (a week, for its\n * days).\n */\n lists?: Record<string, (controller: Controller, around: unknown) => Each | undefined>\n /**\n * The hidden native input a form reads, for a component with no part to hold it: drawn as\n * the element's last child, while `mounted` (a select with a name).\n */\n inner?(controller: Controller): { part: Part; mounted?: ReadonlySignal<boolean> | undefined }\n /** `host` is the custom element: what is around it (a field, a group) is found from it. */\n create(props: ReadonlySignal<Props>, host: HTMLElement): Controller\n /**\n * Its change callbacks: the event each is told as, and the prop the element then holds\n * (`open`). The event is cancelable: `preventDefault()` keeps the value as it was.\n */\n changes: Record<string, { event: string; prop: string; hold?: boolean }>\n /** Each part by its `kui-part` name. */\n parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>\n}\n\nconst camel = (name: string) =>\n name.replace(/-([a-z])/g, (_all, letter: string) => letter.toUpperCase())\nconst hosts = new Set<string>()\nconst OWNER = Symbol(\"kui-owner\")\nlet made = 0\n\ntype Owned = HTMLElement & { [OWNER]?: HTMLElement }\n\n/**\n * Whether an element is a component's: one that was defined, or a `kui-` one that is yet to\n * be (its entry is imported later). What is inside it is its own from the start, and not a\n * part of the component around it that happens to have a part of the same name.\n */\nconst ours = (element: Element) =>\n hosts.has(element.localName) || element.localName.startsWith(\"kui-\")\n\n/** The component a part belongs to: the nearest around it, or the one that moved it to the page's end. */\nfunction ownerOf(element: Element): HTMLElement | null {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n if (ours(each)) return each as HTMLElement\n const moved = (each as Owned)[OWNER]\n if (moved) return moved\n }\n return null\n}\n\n/**\n * The controller of the component around a custom element: the field a control is in, the\n * group a toggle is one of. Through a portal too: what was moved to the page's end is still\n * inside what it was written in.\n */\nexport function controllerAround<Controller>(host: Element, tag: string): Controller | undefined {\n return hostAround(host, [tag])?.controller as Controller | undefined\n}\n\n/** The nearest component around a custom element that is one of `tags`: which, and its controller. */\nexport function hostAround(\n host: Element,\n tags: readonly string[]\n): { tag: string; controller: unknown } | undefined {\n for (let each: Element | null = ownerOf(host); each; each = ownerOf(each)) {\n if (tags.includes(each.localName))\n return { tag: each.localName, controller: (each as { controller?: unknown }).controller }\n }\n return undefined\n}\n\n/** The nearest element around `element` (or itself) that is the part called `name`. */\nexport function partAround(element: Element, name: string): HTMLElement | null {\n return element.closest<HTMLElement>(`[kui-part=\"${name}\"]`)\n}\n\n/**\n * Puts a part on an element, and takes it off whole: what the part wrote is gone with it. A\n * framework draws a new element each time a part comes back; here the same element is the\n * part again, and must not still say what it said before (`data-closed`, `aria-controls`).\n */\nfunction put(element: HTMLElement, part: Part): () => void {\n const before = new Map(Array.from(element.attributes, (each) => [each.name, each.value]))\n const unbind = bind(element, part)\n return () => {\n unbind()\n for (const { name } of Array.from(element.attributes)) {\n // Its classes are the page's own, whatever was added to them since.\n if (!before.has(name) && name !== \"class\") element.removeAttribute(name)\n }\n for (const [name, value] of before) {\n if (name !== \"class\" && element.getAttribute(name) !== value)\n element.setAttribute(name, value)\n }\n }\n}\n\n/**\n * The props of something inside a component that has props of its own (a menu's checkbox\n * item, its radio group), read from its element's `kui-` attributes: `kui-checked`,\n * `kui-default-value`. What it tells is told from that element, and may be refused; a value\n * its element was given is held there, and one the page writes later is followed.\n */\nexport function partProps<Props>(\n element: HTMLElement,\n kinds: Record<string, Kind>,\n changes: Record<string, { event: string; prop: string }>\n): { props: ReadonlySignal<Props>; mount(): () => void } {\n const attribute = (name: string) => `kui-${name}`\n const told: Record<string, unknown> = {}\n const all = () => {\n const next: Record<string, unknown> = { ...told }\n for (const [name, kind] of Object.entries(kinds)) {\n const text = element.getAttribute(attribute(name))\n if (text !== null) next[camel(name)] = read(kind, text)\n }\n return next as Props\n }\n const source = signal<Props>({} as Props, sameProps as (a: Props, b: Props) => boolean)\n for (const [callback, { event, prop }] of Object.entries(changes)) {\n told[callback] = (value: unknown, details?: ChangeDetails) => {\n const heard = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!element.dispatchEvent(heard)) return details?.cancel()\n const held = attribute(prop.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`))\n if (element.hasAttribute(held)) element.setAttribute(held, String(value))\n source.set(all())\n }\n }\n source.set(all())\n return {\n props: source,\n mount() {\n const observer = new MutationObserver(() => source.set(all()))\n observer.observe(element, {\n attributes: true,\n attributeFilter: Object.keys(kinds).map(attribute),\n })\n return () => observer.disconnect()\n },\n }\n}\n\nfunction read(kind: Kind, text: string | null): unknown {\n if (kind === \"boolean\") return text !== null && text !== \"false\"\n if (text === null) return undefined\n return kind === \"number\" ? Number(text) : text\n}\n\n// Components written inside one that has not begun: its element is not defined yet (its\n// entry is imported later), or it waits itself. They begin when it has.\nconst waiting = new Set<{ begin(): void }>()\n\n/** Whether a component around `element` has yet to begin: what is inside it reads it. */\nfunction early(element: Element): boolean {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n // Moved to the page's end by a component that had begun: on from that one.\n const moved = (each as Owned)[OWNER]\n if (moved) return early(moved)\n if (ours(each) && !(each as { controller?: unknown }).controller) return true\n }\n return false\n}\n\n/** What can be a part: an element of the page, one of a drawing (`<svg>`, `<path>`) too. */\nconst drawable = (node: Node): node is HTMLElement => node instanceof Element\n\ninterface Held {\n stop(): void\n /** Taken out of the page by the component itself: still its part. */\n parked: boolean\n}\n\n/**\n * Defines a component's custom element, and gives its name (for\n * `customElements.whenDefined`). Where there are no custom elements (a server) it defines\n * nothing.\n */\nexport function defineElement<Props extends { id: string }, Controller extends object>(\n spec: ElementSpec<Props, Controller>\n): string {\n if (typeof customElements === \"undefined\" || customElements.get(spec.tag)) return spec.tag\n hosts.add(spec.tag)\n const names = Object.keys(spec.props)\n\n class KuiElement extends HTMLElement {\n static observedAttributes = names\n controller?: Controller\n #props?: Signal<Props> | undefined\n // Set as properties before the element was upgraded, or before it joined the page.\n #given: Record<string, unknown> = {}\n #held = new Map<HTMLElement, Held>()\n #stops: (() => void)[] = []\n #leaving = false\n #watch: (element: HTMLElement) => void = () => {}\n\n connectedCallback() {\n this.#leaving = false\n this.begin()\n }\n\n /** Begins, unless a component around it has not: then it waits for that one. */\n begin() {\n if (this.controller || !this.isConnected) return\n if (early(this)) return void waiting.add(this)\n waiting.delete(this)\n // It holds its parts and draws nothing: no box of its own between them and the page.\n if (!this.style.display) this.style.display = \"contents\"\n const initial: Record<string, unknown> = {\n id: this.getAttribute(\"kui-id\") || `kui-${++made}`,\n }\n for (const name of names) {\n const text = this.getAttribute(name)\n // An attribute that is not there says nothing: the component's own default holds.\n if (text !== null) initial[camel(name)] = read(spec.props[name]!, text)\n }\n Object.assign(initial, this.#given)\n for (const [callback, { event, prop, hold }] of Object.entries(spec.changes)) {\n initial[callback] = (value: unknown, details?: ChangeDetails) => {\n const told = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!this.dispatchEvent(told)) return details?.cancel()\n // A value that was given is held by the element from then on, as `<details open>`\n // holds its own: it follows what happens to it.\n if (hold !== false && this.given(prop) !== undefined) this.give(prop, value)\n }\n }\n this.#props = signal(initial as Props, sameProps as (a: Props, b: Props) => boolean)\n this.controller = spec.create(this.#props, this)\n const unmount = (this.controller as { mount?(): () => void }).mount?.()\n if (unmount) this.#stops.push(unmount)\n // Parts that come and go: a page that draws its rows later, a list that changes.\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of record.removedNodes) {\n if (drawable(node)) this.#release(node)\n }\n for (const node of record.addedNodes) if (drawable(node)) this.#scan(node)\n }\n })\n observer.observe(this, { childList: true, subtree: true })\n this.#watch = (element) => observer.observe(element, { childList: true, subtree: true })\n this.#stops.push(() => observer.disconnect())\n // A copy: a part that is not in the page yet is taken out as it is met.\n for (const each of Array.from(this.children)) if (drawable(each)) this.#scan(each)\n const inner = spec.inner?.(this.controller)\n if (inner) {\n const input = this.ownerDocument.createElement(\"input\")\n let unbind: (() => void) | undefined\n const drawn = effect(() => {\n const wanted = inner.mounted?.get() ?? true\n if (wanted && !unbind) {\n this.append(input)\n unbind = bind(input, inner.part)\n } else if (!wanted && unbind) {\n unbind()\n unbind = undefined\n input.remove()\n }\n })\n this.#stops.push(() => {\n drawn()\n unbind?.()\n input.remove()\n })\n }\n for (const each of Array.from(waiting)) each.begin()\n }\n\n disconnectedCallback() {\n // Moved, it comes straight back: only an element that has left is taken apart.\n this.#leaving = true\n queueMicrotask(() => {\n if (!this.#leaving || this.isConnected) return\n waiting.delete(this)\n for (const held of this.#held.values()) held.stop()\n this.#held.clear()\n for (const stop of this.#stops.splice(0).reverse()) stop()\n delete this.controller\n this.#props = undefined\n })\n }\n\n attributeChangedCallback(name: string, _before: string | null, text: string | null) {\n this.give(camel(name), read(spec.props[name]!, text))\n }\n\n /** A prop as it was last given: by an attribute, or as a property. */\n given(prop: string): unknown {\n return this.#props ? (this.#props.peek() as Record<string, unknown>)[prop] : this.#given[prop]\n }\n\n give(prop: string, value: unknown) {\n if (!this.#props) return void (this.#given[prop] = value)\n if (!Object.is((this.#props.peek() as Record<string, unknown>)[prop], value))\n this.#props.set({ ...this.#props.peek(), [prop]: value })\n }\n\n /** Takes the parts in a subtree, in the page's order: one that leaves takes its own with it. */\n #scan(element: HTMLElement) {\n if (!element.isConnected) return\n if (element instanceof HTMLTemplateElement) {\n if (element.hasAttribute(\"kui-each\") && ownerOf(element) === this) this.#each(element)\n return\n }\n if (element.hasAttribute(\"kui-part\")) this.#adopt(element)\n for (const each of Array.from(element.children)) if (drawable(each)) this.#scan(each)\n }\n\n /** Draws a list from its template: a copy for each entry, where the template was. */\n #each(template: HTMLTemplateElement) {\n const list = spec.lists?.[template.getAttribute(\"kui-each\")!]?.(\n this.controller!,\n entryAround(template)\n )\n if (!list) return\n // The template leaves the page for a mark: what is drawn is the page a framework draws.\n const mark = this.ownerDocument.createComment(\"\")\n if (ENTRY.has(template)) ENTRY.set(mark, ENTRY.get(template))\n template.replaceWith(mark)\n const rows = new Map<string | number, Row>()\n const stamp = (entry: unknown): Row => {\n const type = list.type?.(entry)\n const copy = template.content.cloneNode(true) as DocumentFragment\n for (const node of Array.from(copy.childNodes)) {\n const blank = node.nodeType === Node.TEXT_NODE && !node.textContent!.trim()\n const other =\n node instanceof Element &&\n node.hasAttribute(\"kui-when\") &&\n node.getAttribute(\"kui-when\") !== type\n if (blank || other || node.nodeType === Node.COMMENT_NODE) node.remove()\n }\n const written: (readonly [Attr | Text, string])[] = []\n const walker = this.ownerDocument.createTreeWalker(\n copy,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT\n )\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n // A list written in this one is filled when it is drawn, for its own entries.\n if (node instanceof Text) {\n if (node.data.includes(\"{\")) written.push([node, node.data])\n } else if (!(node instanceof HTMLTemplateElement)) {\n for (const attribute of Array.from((node as Element).attributes))\n if (attribute.value.includes(\"{\")) written.push([attribute, attribute.value])\n }\n }\n const nodes = Array.from(copy.childNodes)\n for (const node of nodes) ENTRY.set(node, entry)\n return { entry, nodes, written }\n }\n const write = (row: Row) => {\n const values =\n list.values?.(row.entry) ?? (row.entry as Record<string, unknown> | undefined) ?? {}\n for (const [node, text] of row.written) {\n const next = fill(text, values)\n if (node instanceof Text) {\n if (node.data !== next) node.data = next\n } else if (node.value !== next) node.value = next\n }\n }\n const draw = () => {\n const { entries } = list\n const next = \"get\" in entries ? entries.get() : entries\n const parent = mark.parentNode\n if (!parent) return\n const kept = new Set<string | number>()\n const fresh: Row[] = []\n const ordered = next.map((entry) => {\n const key = list.key(entry)\n kept.add(key)\n let row = rows.get(key)\n if (!row) {\n rows.set(key, (row = stamp(entry)))\n fresh.push(row)\n write(row)\n } else if (row.entry !== entry) {\n row.entry = entry\n for (const node of row.nodes) ENTRY.set(node, entry)\n write(row)\n }\n return row\n })\n for (const [key, row] of rows) {\n if (kept.has(key)) continue\n rows.delete(key)\n for (const node of row.nodes) node.remove()\n }\n // From the end: a copy that is where it belongs is not moved, and keeps focus.\n let before: ChildNode = mark\n for (const row of ordered.reverse()) {\n for (const node of row.nodes.toReversed()) {\n if (node.nextSibling !== before || node.parentNode !== parent)\n parent.insertBefore(node, before)\n before = node\n }\n }\n for (const row of fresh) for (const node of row.nodes) if (drawable(node)) this.#scan(node)\n }\n const stop = effect(draw)\n this.#stops.push(() => {\n stop()\n for (const row of rows.values()) for (const node of row.nodes) node.remove()\n rows.clear()\n mark.replaceWith(template)\n })\n }\n\n #adopt(element: HTMLElement) {\n if (this.#held.has(element) || ownerOf(element) !== this || !this.controller) return\n const name = element.getAttribute(\"kui-part\")!\n if (name === \"portal\") return this.#portal(element)\n const given = spec.parts[name]?.(this.controller, element)\n if (!given) return\n const drawn: Drawn = \"attach\" in given ? { part: given } : given\n const stops: (() => void)[] = []\n const held: Held = {\n parked: false,\n stop: () => {\n for (const stop of stops.splice(0).reverse()) stop()\n },\n }\n this.#held.set(element, held)\n const unmount = drawn.mount?.()\n if (unmount) stops.push(unmount)\n if (drawn.inner) {\n // One a server wrote there is taken over.\n const last = element.lastElementChild\n const taken = last instanceof HTMLInputElement && last.type === \"hidden\" ? last : undefined\n const input = taken ?? this.ownerDocument.createElement(\"input\")\n if (!taken) element.append(input)\n stops.push(bind(input, drawn.inner), () => {\n if (!taken) input.remove()\n })\n }\n if (drawn.text && element.childNodes.length === 0) {\n const { text } = drawn\n // Taken off, the element says nothing again: put back on (a popup opened a second\n // time), the text is the part's to write still, and not taken for the page's.\n stops.push(\n effect(() => void (element.textContent = text.get() ?? \"\")),\n () => void (element.textContent = \"\")\n )\n }\n const mounted = element.hasAttribute(\"kui-keep-mounted\") ? undefined : drawn.mounted\n if (!mounted) return void stops.push(put(element, drawn.part))\n // In the page only while it is mounted: out of it otherwise, its place kept by a mark.\n const home = this.ownerDocument.createComment(\"\")\n let unbind: (() => void) | undefined\n stops.push(\n effect(() => {\n const elsewhere = drawn.into?.get()\n if (mounted.get() && (!drawn.into || elsewhere)) {\n if (elsewhere) {\n // Its place where it was written is kept by the mark all the while.\n if (!held.parked && element.parentNode) element.replaceWith(home)\n held.parked = true\n if (element.parentNode !== elsewhere) elsewhere.append(element)\n } else if (held.parked) {\n held.parked = false\n home.replaceWith(element)\n }\n unbind ??= put(element, drawn.part)\n } else {\n unbind?.()\n unbind = undefined\n if (!held.parked && element.parentNode) {\n held.parked = true\n element.replaceWith(home)\n } else if (drawn.into) element.remove()\n }\n }),\n () => {\n unbind?.()\n if (held.parked) home.replaceWith(element)\n }\n )\n }\n\n /** What is inside is drawn at the end of the page while the component is mounted. */\n #portal(element: HTMLElement) {\n const mounted = (this.controller as { mounted?: ReadonlySignal<boolean> }).mounted\n if (!mounted) return\n ;(element as Owned)[OWNER] = this\n const home = this.ownerDocument.createComment(\"\")\n const held: Held = { parked: false, stop: () => {} }\n this.#held.set(element, held)\n this.#watch(element)\n const body = this.ownerDocument.body\n const stop = effect(() => {\n if (mounted.get()) {\n if (element.parentNode === body) return\n // Its place in the page is kept by a mark, for when the component leaves.\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n held.parked = false\n element.setAttribute(\"data-kirana-portal\", \"\")\n body.append(element)\n this.#scan(element)\n } else if (!held.parked) {\n held.parked = true\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n else element.remove()\n }\n })\n held.stop = () => {\n stop()\n element.removeAttribute(\"data-kirana-portal\")\n if (home.parentNode) home.replaceWith(element)\n else element.remove()\n }\n }\n\n #release(element: HTMLElement) {\n // Moved to the page's end by its own portal, or put back: still this component's.\n if (element.isConnected) return\n for (const [each, held] of this.#held) {\n if (each !== element && !element.contains(each)) continue\n // Taken out by the component itself: it is still the component's, to be put back.\n if (each === element && held.parked) continue\n held.stop()\n this.#held.delete(each)\n }\n }\n }\n\n // Each prop as a property too: `element.open = true`, and what the element holds read back.\n for (const name of [...names, ...(spec.properties ?? [])]) {\n const prop = camel(name)\n Object.defineProperty(KuiElement.prototype, prop, {\n configurable: true,\n get(this: KuiElement) {\n const state = (this.controller as Record<string, unknown> | undefined)?.[prop] as\n | ReadonlySignal<unknown>\n | undefined\n return typeof state?.peek === \"function\" ? state.peek() : this.given(prop)\n },\n set(this: KuiElement, value: unknown) {\n this.give(prop, value)\n },\n })\n }\n customElements.define(spec.tag, KuiElement)\n return spec.tag\n}\n"],"mappings":";;AAqDA,MAAM,wBAAQ,IAAI,QAAuB;;AAGzC,SAAgB,YAAmB,SAAkC;CACnE,KAAK,IAAI,OAAoB,SAAS,MAAM,OAAO,KAAK,YACtD,IAAI,MAAM,IAAI,IAAI,GAAG,OAAO,MAAM,IAAI,IAAI;AAG9C;;AAGA,MAAM,QAAQ,MAAc,WAC1B,KAAK,QAAQ,2BAA2B,OAAO,SAC7C,QAAQ,SAAS,OAAO,OAAO,SAAS,EAAE,IAAI,KAChD;AAwCF,MAAM,SAAS,SACb,KAAK,QAAQ,cAAc,MAAM,WAAmB,OAAO,YAAY,CAAC;AAC1E,MAAM,wBAAQ,IAAI,IAAY;AAC9B,MAAM,QAAQ,OAAO,WAAW;AAChC,IAAI,OAAO;;;;;;AASX,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AAc;GACd,MAAsB;IACpB,MAAM,QAAS,KAAK,aAAqD;IAGzE,OAAO,OAAO,OAAO,SAAS,aAAa,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI;GAC3E;GACA,IAAsB,OAAgB;IACpC,KAAK,KAAK,MAAM,KAAK;GACvB;EACF,CAAC;CACH;CACA,eAAe,OAAO,KAAK,KAAK,UAAU;CAC1C,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/web/src/runtime.ts"],"sourcesContent":["import { bind, effect, sameProps, signal } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Part, ReadonlySignal, Signal } from \"@kirana-ui/core\"\n\n/**\n * A component as a custom element, for a page with no framework.\n *\n * The custom element (`<kui-dialog>`) holds the component and draws nothing: it takes no room\n * (`display: contents`) and no attribute of the component's. Its parts are the page's own\n * elements, named by `kui-part` (`<button kui-part=\"trigger\">`), the root among them. So a\n * trigger is a real button and a switch a real button, and the page is the page the other\n * adapters draw: nothing is wrapped, and there is no shadow root for a design to reach into.\n *\n * A part that is in the page only some of the time (a closed panel, a popup) is taken out of\n * the page while it is not, and put back where it was; `kui-keep-mounted` keeps it.\n */\n\n/** What a part's name gives: the part, and what comes with it. */\nexport interface Drawn {\n readonly part: Part\n /** In the page only while this holds. */\n readonly mounted?: ReadonlySignal<boolean> | undefined\n /** Runs while the part is the component's. Returns the stop. */\n mount?(): () => void\n /** A hidden native input the part draws itself, as its last child. */\n readonly inner?: Part | undefined\n /**\n * Where the part is drawn while it is mounted, when that is not where it was written: a\n * navigation menu's content, in the menu's one viewport. Out of the page while there is none.\n */\n readonly into?: ReadonlySignal<HTMLElement | undefined> | undefined\n /** What the part's element says, when the page gave it nothing to say. */\n readonly text?: ReadonlySignal<string | undefined> | undefined\n}\n\ntype Kind = \"boolean\" | \"string\" | \"number\"\n\n/** A list a component draws from a `<template kui-each>`. */\nexport interface Each<Entry = any> {\n readonly entries: ReadonlySignal<readonly Entry[]> | readonly Entry[]\n /** What an entry is known by from one drawing to the next. */\n key(entry: Entry): string | number\n /**\n * Which of the template's elements an entry is drawn with, when they differ: the ones\n * whose `kui-when` says so (a page, an ellipsis). Elements without `kui-when` are for all.\n */\n type?(entry: Entry): string\n /**\n * What `{name}` stands for in the template's text and attributes\n * (`data-testid=\"row-{id}\"`). Left out: the entry's own fields.\n */\n values?(entry: Entry): Record<string, unknown>\n}\n\nconst ENTRY = new WeakMap<Node, unknown>()\n\n/** The entry an element was stamped for, or the nearest around it: a part reads its own. */\nexport function entryAround<Entry>(element: Node): Entry | undefined {\n for (let each: Node | null = element; each; each = each.parentNode) {\n if (ENTRY.has(each)) return ENTRY.get(each) as Entry\n }\n return undefined\n}\n\n/** `{name}` in a text, for each name there is a value for; another brace is the page's own. */\nconst fill = (text: string, values: Record<string, unknown>) =>\n text.replace(/\\{([A-Za-z_][\\w-]*)\\}/g, (whole, name: string) =>\n name in values ? String(values[name] ?? \"\") : whole\n )\n\ninterface Row {\n entry: unknown\n nodes: ChildNode[]\n /** Where a `{name}` was written: read again when the entry changes. */\n written: (readonly [Attr | Text, string])[]\n}\n\nexport interface ElementSpec<Props extends { id: string }, Controller> {\n /** The custom element's name: `kui-dialog`. */\n tag: string\n /** Its props by attribute name, each with how an attribute's text is read. */\n props: Record<string, Kind>\n /** Props that are only properties: a function, an object. By their names as properties. */\n properties?: readonly string[] | undefined\n /**\n * What the component draws a list of, by name: a calendar's weeks, a toast for each\n * message. The page writes one of an entry as a `<template kui-each=\"name\">` where the\n * list goes, and the element stamps it for each entry, keyed, so an entry that stays keeps\n * its elements. `around` is the entry of the list this one is written in (a week, for its\n * days).\n */\n lists?: Record<string, (controller: Controller, around: unknown) => Each | undefined>\n /**\n * The hidden native input a form reads, for a component with no part to hold it: drawn as\n * the element's last child, while `mounted` (a select with a name).\n */\n inner?(controller: Controller): { part: Part; mounted?: ReadonlySignal<boolean> | undefined }\n /** `host` is the custom element: what is around it (a field, a group) is found from it. */\n create(props: ReadonlySignal<Props>, host: HTMLElement): Controller\n /**\n * Its change callbacks: the event each is told as, and the prop the element then holds\n * (`open`). The event is cancelable: `preventDefault()` keeps the value as it was.\n */\n changes: Record<string, { event: string; prop: string; hold?: boolean }>\n /** Each part by its `kui-part` name. */\n parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>\n}\n\ndeclare const DEFINED: unique symbol\n\n/**\n * A custom element's name as `defineElement` gives it. For TypeScript it also says what the\n * element was defined from, which `ElementOf` reads back; in the page it is the name alone.\n */\nexport type Tag<Props = unknown, Controller = unknown> = string & {\n readonly [DEFINED]?: readonly [Props, Controller]\n}\n\n/**\n * What a component tells: an event whose `detail` holds the value under its prop's name\n * (`detail.open`, `detail.values`) and why it changed (`detail.details.reason`).\n * `preventDefault()` keeps the value as it was.\n */\nexport type Told<Prop extends string, Value> = CustomEvent<\n { readonly [Name in Prop]: Value } & { readonly details: ChangeDetails }\n>\n\n/** A tag with its props said, where `defineElement` was left to work them out. */\nexport type As<Defined, Props> =\n Defined extends Tag<unknown, infer Controller> ? Tag<Props, Controller> : never\n\ntype Callback<Props, Name> = Name extends keyof Props\n ? Extract<Props[Name], (...given: never[]) => unknown>\n : never\n\ninterface Listens<Events> {\n addEventListener<Type extends keyof Events>(\n type: Type,\n listener: (this: HTMLElement, event: Events[Type]) => void,\n options?: boolean | AddEventListenerOptions\n ): void\n removeEventListener<Type extends keyof Events>(\n type: Type,\n listener: (this: HTMLElement, event: Events[Type]) => void,\n options?: boolean | EventListenerOptions\n ): void\n}\n\n/**\n * A component's custom element as TypeScript knows it, from its `tag`: its props as properties\n * (`element.open = true`), its controller once it has begun, and its events with their\n * `detail`. `Changes` names each event with the callback it tells and the prop it holds\n * (`{ \"open-change\": [\"onOpenChange\", \"open\"] }`), as the element's `changes` do; `More` is\n * for events its parts tell from their own elements, which reach it too.\n */\nexport type ElementOf<Defined, Changes = {}, More = {}> =\n Defined extends Tag<infer Props, infer Controller>\n ? Listens<\n {\n readonly [Event in keyof Changes]: Changes[Event] extends readonly [\n infer Name,\n infer Prop extends string,\n ]\n ? Told<Prop, Parameters<Callback<Props, Name>>[0]>\n : never\n } & More\n > & {\n -readonly [\n Name in keyof Props as Name extends \"id\" | `on${Capitalize<string>}` ? never : Name\n ]?: Props[Name]\n } & { controller?: Controller } & HTMLElement\n : never\n\nconst camel = (name: string) =>\n name.replace(/-([a-z])/g, (_all, letter: string) => letter.toUpperCase())\nconst hosts = new Set<string>()\nconst OWNER = Symbol(\"kui-owner\")\nlet made = 0\n\ntype Owned = HTMLElement & { [OWNER]?: HTMLElement }\n\n/**\n * Whether an element is a component's: one that was defined, or a `kui-` one that is yet to\n * be (its entry is imported later). What is inside it is its own from the start, and not a\n * part of the component around it that happens to have a part of the same name.\n */\nconst ours = (element: Element) =>\n hosts.has(element.localName) || element.localName.startsWith(\"kui-\")\n\n/** The component a part belongs to: the nearest around it, or the one that moved it to the page's end. */\nfunction ownerOf(element: Element): HTMLElement | null {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n if (ours(each)) return each as HTMLElement\n const moved = (each as Owned)[OWNER]\n if (moved) return moved\n }\n return null\n}\n\n/**\n * The controller of the component around a custom element: the field a control is in, the\n * group a toggle is one of. Through a portal too: what was moved to the page's end is still\n * inside what it was written in.\n */\nexport function controllerAround<Controller>(host: Element, tag: string): Controller | undefined {\n return hostAround(host, [tag])?.controller as Controller | undefined\n}\n\n/** The nearest component around a custom element that is one of `tags`: which, and its controller. */\nexport function hostAround(\n host: Element,\n tags: readonly string[]\n): { tag: string; controller: unknown } | undefined {\n for (let each: Element | null = ownerOf(host); each; each = ownerOf(each)) {\n if (tags.includes(each.localName))\n return { tag: each.localName, controller: (each as { controller?: unknown }).controller }\n }\n return undefined\n}\n\n/** The nearest element around `element` (or itself) that is the part called `name`. */\nexport function partAround(element: Element, name: string): HTMLElement | null {\n return element.closest<HTMLElement>(`[kui-part=\"${name}\"]`)\n}\n\n// Elements the page had drawn before their part gave them a style of its own.\nlet settling: HTMLElement[] | undefined\n\n/**\n * A page's markup is drawn before its components begin, so a part's style (a slider thumb's\n * place) reaches an element the browser has already styled, and a design's `transition` on it\n * would run as the page begins: each thumb gliding to where it was all along. A framework's\n * element has its style before it is first drawn; here what the first style started is ended\n * before the page is drawn again, once for all the parts of a pass.\n */\nfunction settle(element: HTMLElement): void {\n if (typeof element.getAnimations !== \"function\") return\n if (!settling) {\n const written: HTMLElement[] = (settling = [])\n queueMicrotask(() => {\n settling = undefined\n for (const each of written) {\n for (const animation of each.getAnimations()) {\n if (animation instanceof CSSTransition) animation.cancel()\n }\n }\n })\n }\n settling.push(element)\n}\n\n/**\n * Puts a part on an element, and takes it off whole: what the part wrote is gone with it. A\n * framework draws a new element each time a part comes back; here the same element is the\n * part again, and must not still say what it said before (`data-closed`, `aria-controls`).\n */\nfunction put(element: HTMLElement, part: Part, drawn = false): () => void {\n const before = new Map(Array.from(element.attributes, (each) => [each.name, each.value]))\n const unbind = bind(element, part)\n if (drawn && part.props.peek().style) settle(element)\n return () => {\n unbind()\n for (const { name } of Array.from(element.attributes)) {\n // Its classes are the page's own, whatever was added to them since.\n if (!before.has(name) && name !== \"class\") element.removeAttribute(name)\n }\n for (const [name, value] of before) {\n if (name !== \"class\" && element.getAttribute(name) !== value)\n element.setAttribute(name, value)\n }\n }\n}\n\n/**\n * The props of something inside a component that has props of its own (a menu's checkbox\n * item, its radio group), read from its element's `kui-` attributes: `kui-checked`,\n * `kui-default-value`. What it tells is told from that element, and may be refused; a value\n * its element was given is held there, and one the page writes later is followed.\n */\nexport function partProps<Props>(\n element: HTMLElement,\n kinds: Record<string, Kind>,\n changes: Record<string, { event: string; prop: string }>\n): { props: ReadonlySignal<Props>; mount(): () => void } {\n const attribute = (name: string) => `kui-${name}`\n const told: Record<string, unknown> = {}\n const all = () => {\n const next: Record<string, unknown> = { ...told }\n for (const [name, kind] of Object.entries(kinds)) {\n const text = element.getAttribute(attribute(name))\n if (text !== null) next[camel(name)] = read(kind, text)\n }\n return next as Props\n }\n const source = signal<Props>({} as Props, sameProps as (a: Props, b: Props) => boolean)\n for (const [callback, { event, prop }] of Object.entries(changes)) {\n told[callback] = (value: unknown, details?: ChangeDetails) => {\n const heard = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!element.dispatchEvent(heard)) return details?.cancel()\n const held = attribute(prop.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`))\n if (element.hasAttribute(held)) element.setAttribute(held, String(value))\n source.set(all())\n }\n }\n source.set(all())\n return {\n props: source,\n mount() {\n const observer = new MutationObserver(() => source.set(all()))\n observer.observe(element, {\n attributes: true,\n attributeFilter: Object.keys(kinds).map(attribute),\n })\n return () => observer.disconnect()\n },\n }\n}\n\nfunction read(kind: Kind, text: string | null): unknown {\n if (kind === \"boolean\") return text !== null && text !== \"false\"\n if (text === null) return undefined\n return kind === \"number\" ? Number(text) : text\n}\n\n// Components written inside one that has not begun: its element is not defined yet (its\n// entry is imported later), or it waits itself. They begin when it has.\nconst waiting = new Set<{ begin(): void }>()\n\n/** Whether a component around `element` has yet to begin: what is inside it reads it. */\nfunction early(element: Element): boolean {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n // Moved to the page's end by a component that had begun: on from that one.\n const moved = (each as Owned)[OWNER]\n if (moved) return early(moved)\n if (ours(each) && !(each as { controller?: unknown }).controller) return true\n }\n return false\n}\n\n/** What can be a part: an element of the page, one of a drawing (`<svg>`, `<path>`) too. */\nconst drawable = (node: Node): node is HTMLElement => node instanceof Element\n\ninterface Held {\n stop(): void\n /** Taken out of the page by the component itself: still its part. */\n parked: boolean\n}\n\n/**\n * Defines a component's custom element, and gives its name (for\n * `customElements.whenDefined`). Where there are no custom elements (a server) it defines\n * nothing.\n */\nexport function defineElement<Props extends { id: string }, Controller extends object>(\n spec: ElementSpec<Props, Controller>\n): Tag<Props, Controller> {\n if (typeof customElements === \"undefined\" || customElements.get(spec.tag)) return spec.tag\n hosts.add(spec.tag)\n const names = Object.keys(spec.props)\n\n class KuiElement extends HTMLElement {\n static observedAttributes = names\n controller?: Controller\n #props?: Signal<Props> | undefined\n // Set as properties before the element was upgraded, or before it joined the page.\n #given: Record<string, unknown> = {}\n #held = new Map<HTMLElement, Held>()\n #stops: (() => void)[] = []\n #leaving = false\n // While the parts the page wrote are first taken: they were drawn before they were parts.\n #first = false\n #watch: (element: HTMLElement) => void = () => {}\n\n connectedCallback() {\n this.#leaving = false\n this.begin()\n }\n\n /** Begins, unless a component around it has not: then it waits for that one. */\n begin() {\n if (this.controller || !this.isConnected) return\n if (early(this)) return void waiting.add(this)\n waiting.delete(this)\n // It holds its parts and draws nothing: no box of its own between them and the page.\n if (!this.style.display) this.style.display = \"contents\"\n const initial: Record<string, unknown> = {\n id: this.getAttribute(\"kui-id\") || `kui-${++made}`,\n }\n for (const name of names) {\n const text = this.getAttribute(name)\n // An attribute that is not there says nothing: the component's own default holds.\n if (text !== null) initial[camel(name)] = read(spec.props[name]!, text)\n }\n Object.assign(initial, this.#given)\n for (const [callback, { event, prop, hold }] of Object.entries(spec.changes)) {\n initial[callback] = (value: unknown, details?: ChangeDetails) => {\n const told = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!this.dispatchEvent(told)) return details?.cancel()\n // A value that was given is held by the element from then on, as `<details open>`\n // holds its own: it follows what happens to it.\n if (hold !== false && this.given(prop) !== undefined) this.give(prop, value)\n }\n }\n this.#props = signal(initial as Props, sameProps as (a: Props, b: Props) => boolean)\n this.controller = spec.create(this.#props, this)\n const unmount = (this.controller as { mount?(): () => void }).mount?.()\n if (unmount) this.#stops.push(unmount)\n // Parts that come and go: a page that draws its rows later, a list that changes.\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of record.removedNodes) {\n if (drawable(node)) this.#release(node)\n }\n for (const node of record.addedNodes) if (drawable(node)) this.#scan(node)\n }\n })\n observer.observe(this, { childList: true, subtree: true })\n this.#watch = (element) => observer.observe(element, { childList: true, subtree: true })\n this.#stops.push(() => observer.disconnect())\n // A copy: a part that is not in the page yet is taken out as it is met.\n this.#first = true\n for (const each of Array.from(this.children)) if (drawable(each)) this.#scan(each)\n this.#first = false\n const inner = spec.inner?.(this.controller)\n if (inner) {\n const input = this.ownerDocument.createElement(\"input\")\n let unbind: (() => void) | undefined\n const drawn = effect(() => {\n const wanted = inner.mounted?.get() ?? true\n if (wanted && !unbind) {\n this.append(input)\n unbind = bind(input, inner.part)\n } else if (!wanted && unbind) {\n unbind()\n unbind = undefined\n input.remove()\n }\n })\n this.#stops.push(() => {\n drawn()\n unbind?.()\n input.remove()\n })\n }\n for (const each of Array.from(waiting)) each.begin()\n }\n\n disconnectedCallback() {\n // Moved, it comes straight back: only an element that has left is taken apart.\n this.#leaving = true\n queueMicrotask(() => {\n if (!this.#leaving || this.isConnected) return\n waiting.delete(this)\n for (const held of this.#held.values()) held.stop()\n this.#held.clear()\n for (const stop of this.#stops.splice(0).reverse()) stop()\n delete this.controller\n this.#props = undefined\n })\n }\n\n attributeChangedCallback(name: string, _before: string | null, text: string | null) {\n this.give(camel(name), read(spec.props[name]!, text))\n }\n\n /** A prop as it was last given: by an attribute, or as a property. */\n given(prop: string): unknown {\n return this.#props ? (this.#props.peek() as Record<string, unknown>)[prop] : this.#given[prop]\n }\n\n give(prop: string, value: unknown) {\n if (!this.#props) return void (this.#given[prop] = value)\n if (!Object.is((this.#props.peek() as Record<string, unknown>)[prop], value))\n this.#props.set({ ...this.#props.peek(), [prop]: value })\n }\n\n /** Takes the parts in a subtree, in the page's order: one that leaves takes its own with it. */\n #scan(element: HTMLElement) {\n if (!element.isConnected) return\n if (element instanceof HTMLTemplateElement) {\n if (element.hasAttribute(\"kui-each\") && ownerOf(element) === this) this.#each(element)\n return\n }\n if (element.hasAttribute(\"kui-part\")) this.#adopt(element)\n for (const each of Array.from(element.children)) if (drawable(each)) this.#scan(each)\n }\n\n /** Draws a list from its template: a copy for each entry, where the template was. */\n #each(template: HTMLTemplateElement) {\n const list = spec.lists?.[template.getAttribute(\"kui-each\")!]?.(\n this.controller!,\n entryAround(template)\n )\n if (!list) return\n // The template leaves the page for a mark: what is drawn is the page a framework draws.\n const mark = this.ownerDocument.createComment(\"\")\n if (ENTRY.has(template)) ENTRY.set(mark, ENTRY.get(template))\n template.replaceWith(mark)\n const rows = new Map<string | number, Row>()\n const stamp = (entry: unknown): Row => {\n const type = list.type?.(entry)\n const copy = template.content.cloneNode(true) as DocumentFragment\n for (const node of Array.from(copy.childNodes)) {\n const blank = node.nodeType === Node.TEXT_NODE && !node.textContent!.trim()\n const other =\n node instanceof Element &&\n node.hasAttribute(\"kui-when\") &&\n node.getAttribute(\"kui-when\") !== type\n if (blank || other || node.nodeType === Node.COMMENT_NODE) node.remove()\n }\n const written: (readonly [Attr | Text, string])[] = []\n const walker = this.ownerDocument.createTreeWalker(\n copy,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT\n )\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n // A list written in this one is filled when it is drawn, for its own entries.\n if (node instanceof Text) {\n if (node.data.includes(\"{\")) written.push([node, node.data])\n } else if (!(node instanceof HTMLTemplateElement)) {\n for (const attribute of Array.from((node as Element).attributes))\n if (attribute.value.includes(\"{\")) written.push([attribute, attribute.value])\n }\n }\n const nodes = Array.from(copy.childNodes)\n for (const node of nodes) ENTRY.set(node, entry)\n return { entry, nodes, written }\n }\n const write = (row: Row) => {\n const values =\n list.values?.(row.entry) ?? (row.entry as Record<string, unknown> | undefined) ?? {}\n for (const [node, text] of row.written) {\n const next = fill(text, values)\n if (node instanceof Text) {\n if (node.data !== next) node.data = next\n } else if (node.value !== next) node.value = next\n }\n }\n const draw = () => {\n const { entries } = list\n const next = \"get\" in entries ? entries.get() : entries\n const parent = mark.parentNode\n if (!parent) return\n const kept = new Set<string | number>()\n const fresh: Row[] = []\n const ordered = next.map((entry) => {\n const key = list.key(entry)\n kept.add(key)\n let row = rows.get(key)\n if (!row) {\n rows.set(key, (row = stamp(entry)))\n fresh.push(row)\n write(row)\n } else if (row.entry !== entry) {\n row.entry = entry\n for (const node of row.nodes) ENTRY.set(node, entry)\n write(row)\n }\n return row\n })\n for (const [key, row] of rows) {\n if (kept.has(key)) continue\n rows.delete(key)\n for (const node of row.nodes) node.remove()\n }\n // From the end: a copy that is where it belongs is not moved, and keeps focus.\n let before: ChildNode = mark\n for (const row of ordered.reverse()) {\n for (const node of row.nodes.toReversed()) {\n if (node.nextSibling !== before || node.parentNode !== parent)\n parent.insertBefore(node, before)\n before = node\n }\n }\n for (const row of fresh) for (const node of row.nodes) if (drawable(node)) this.#scan(node)\n }\n const stop = effect(draw)\n this.#stops.push(() => {\n stop()\n for (const row of rows.values()) for (const node of row.nodes) node.remove()\n rows.clear()\n mark.replaceWith(template)\n })\n }\n\n #adopt(element: HTMLElement) {\n if (this.#held.has(element) || ownerOf(element) !== this || !this.controller) return\n const name = element.getAttribute(\"kui-part\")!\n if (name === \"portal\") return this.#portal(element)\n const given = spec.parts[name]?.(this.controller, element)\n if (!given) return\n const drawn: Drawn = \"attach\" in given ? { part: given } : given\n const stops: (() => void)[] = []\n const held: Held = {\n parked: false,\n stop: () => {\n for (const stop of stops.splice(0).reverse()) stop()\n },\n }\n this.#held.set(element, held)\n const unmount = drawn.mount?.()\n if (unmount) stops.push(unmount)\n if (drawn.inner) {\n // One a server wrote there is taken over.\n const last = element.lastElementChild\n const taken = last instanceof HTMLInputElement && last.type === \"hidden\" ? last : undefined\n const input = taken ?? this.ownerDocument.createElement(\"input\")\n if (!taken) element.append(input)\n stops.push(bind(input, drawn.inner), () => {\n if (!taken) input.remove()\n })\n }\n if (drawn.text && element.childNodes.length === 0) {\n const { text } = drawn\n // Taken off, the element says nothing again: put back on (a popup opened a second\n // time), the text is the part's to write still, and not taken for the page's.\n stops.push(\n effect(() => void (element.textContent = text.get() ?? \"\")),\n () => void (element.textContent = \"\")\n )\n }\n const mounted = element.hasAttribute(\"kui-keep-mounted\") ? undefined : drawn.mounted\n const first = this.#first\n if (!mounted) return void stops.push(put(element, drawn.part, first))\n // In the page only while it is mounted: out of it otherwise, its place kept by a mark.\n const home = this.ownerDocument.createComment(\"\")\n let unbind: (() => void) | undefined\n stops.push(\n effect(() => {\n const elsewhere = drawn.into?.get()\n // Still where the page drew it: not moved, and never yet taken out.\n const own = first && !elsewhere && !held.parked && !unbind\n if (mounted.get() && (!drawn.into || elsewhere)) {\n if (elsewhere) {\n // Its place where it was written is kept by the mark all the while.\n if (!held.parked && element.parentNode) element.replaceWith(home)\n held.parked = true\n if (element.parentNode !== elsewhere) elsewhere.append(element)\n } else if (held.parked) {\n held.parked = false\n home.replaceWith(element)\n }\n unbind ??= put(element, drawn.part, own)\n } else {\n unbind?.()\n unbind = undefined\n if (!held.parked && element.parentNode) {\n held.parked = true\n element.replaceWith(home)\n } else if (drawn.into) element.remove()\n }\n }),\n () => {\n unbind?.()\n if (held.parked) home.replaceWith(element)\n }\n )\n }\n\n /** What is inside is drawn at the end of the page while the component is mounted. */\n #portal(element: HTMLElement) {\n const mounted = (this.controller as { mounted?: ReadonlySignal<boolean> }).mounted\n if (!mounted) return\n ;(element as Owned)[OWNER] = this\n const home = this.ownerDocument.createComment(\"\")\n const held: Held = { parked: false, stop: () => {} }\n this.#held.set(element, held)\n this.#watch(element)\n const body = this.ownerDocument.body\n const stop = effect(() => {\n if (mounted.get()) {\n if (element.parentNode === body) return\n // Its place in the page is kept by a mark, for when the component leaves.\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n held.parked = false\n element.setAttribute(\"data-kirana-portal\", \"\")\n body.append(element)\n this.#scan(element)\n } else if (!held.parked) {\n held.parked = true\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n else element.remove()\n }\n })\n held.stop = () => {\n stop()\n element.removeAttribute(\"data-kirana-portal\")\n if (home.parentNode) home.replaceWith(element)\n else element.remove()\n }\n }\n\n #release(element: HTMLElement) {\n // Moved to the page's end by its own portal, or put back: still this component's.\n if (element.isConnected) return\n for (const [each, held] of this.#held) {\n if (each !== element && !element.contains(each)) continue\n // Taken out by the component itself: it is still the component's, to be put back.\n if (each === element && held.parked) continue\n held.stop()\n this.#held.delete(each)\n }\n }\n }\n\n // Each prop as a property too: `element.open = true`, and what the element holds read back.\n for (const name of [...names, ...(spec.properties ?? [])]) {\n const prop = camel(name)\n Object.defineProperty(KuiElement.prototype, prop, {\n configurable: true,\n get(this: KuiElement) {\n const state = (this.controller as Record<string, unknown> | undefined)?.[prop] as\n | ReadonlySignal<unknown>\n | undefined\n return typeof state?.peek === \"function\" ? state.peek() : this.given(prop)\n },\n set(this: KuiElement, value: unknown) {\n this.give(prop, value)\n },\n })\n }\n customElements.define(spec.tag, KuiElement)\n return spec.tag\n}\n"],"mappings":";;AAqDA,MAAM,wBAAQ,IAAI,QAAuB;;AAGzC,SAAgB,YAAmB,SAAkC;CACnE,KAAK,IAAI,OAAoB,SAAS,MAAM,OAAO,KAAK,YACtD,IAAI,MAAM,IAAI,IAAI,GAAG,OAAO,MAAM,IAAI,IAAI;AAG9C;;AAGA,MAAM,QAAQ,MAAc,WAC1B,KAAK,QAAQ,2BAA2B,OAAO,SAC7C,QAAQ,SAAS,OAAO,OAAO,SAAS,EAAE,IAAI,KAChD;AAyGF,MAAM,SAAS,SACb,KAAK,QAAQ,cAAc,MAAM,WAAmB,OAAO,YAAY,CAAC;AAC1E,MAAM,wBAAQ,IAAI,IAAY;AAC9B,MAAM,QAAQ,OAAO,WAAW;AAChC,IAAI,OAAO;;;;;;AASX,MAAM,QAAQ,YACZ,MAAM,IAAI,QAAQ,SAAS,KAAK,QAAQ,UAAU,WAAW,MAAM;;AAGrE,SAAS,QAAQ,SAAsC;CACrD,KAAK,IAAI,OAAuB,QAAQ,eAAe,MAAM,OAAO,KAAK,eAAe;EACtF,IAAI,KAAK,IAAI,GAAG,OAAO;EACvB,MAAM,QAAS,KAAe;EAC9B,IAAI,OAAO,OAAO;CACpB;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,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jD,IAAI,SAAS,WAAW,KAAK,QAAQ;IACrC,KAAK,KAAK;IACV,KAAK,MAAM,OAAO,IAAI;GACxB;EACF;CACF;CAGA,KAAK,MAAM,QAAQ,CAAC,GAAG,OAAO,GAAI,KAAK,cAAc,CAAC,CAAE,GAAG;EACzD,MAAM,OAAO,MAAM,IAAI;EACvB,OAAO,eAAe,WAAW,WAAW,MAAM;GAChD,cAAc;GACd,MAAsB;IACpB,MAAM,QAAS,KAAK,aAAqD;IAGzE,OAAO,OAAO,OAAO,SAAS,aAAa,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI;GAC3E;GACA,IAAsB,OAAgB;IACpC,KAAK,KAAK,MAAM,KAAK;GACvB;EACF,CAAC;CACH;CACA,eAAe,OAAO,KAAK,KAAK,UAAU;CAC1C,OAAO,KAAK;AACd"}
|
package/src/scroll-area.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { ScrollAreaProps } from "@kirana-ui/core/scroll-area";
|
|
1
3
|
/**
|
|
2
4
|
* `<kui-scroll-area>` around `kui-part="root"`, a `viewport` with its `content`, a `scrollbar`
|
|
3
5
|
* for each way (`kui-orientation="horizontal"` for the one across) with its `thumb`, and a
|
|
4
|
-
* `corner`. A scrollbar is in the page while there is something to scroll its way.
|
|
6
|
+
* `corner`. A scrollbar is in the page while there is something to scroll its way. The
|
|
7
|
+
* library places the scrollbars and the corner against the root; the page gives a scrollbar
|
|
8
|
+
* its thickness and draws it.
|
|
5
9
|
*/
|
|
6
|
-
export declare const tag:
|
|
10
|
+
export declare const tag: Tag<{
|
|
11
|
+
id: string;
|
|
12
|
+
}, import("@kirana-ui/core/scroll-area").ScrollArea>;
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
"kui-scroll-area": ElementOf<As<typeof tag, ScrollAreaProps>>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
7
18
|
//# sourceMappingURL=scroll-area.d.ts.map
|