@kirana-ui/web 0.0.0 → 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/LICENSE +1 -1
- package/llms.txt +3000 -0
- package/package.json +231 -6
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.d.ts +23 -0
- package/src/accordion.js +68 -0
- package/src/accordion.js.map +1 -0
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +17 -0
- package/src/alert-dialog.js +36 -0
- package/src/alert-dialog.js.map +1 -0
- package/src/around.d.ts +46 -0
- package/src/around.js +95 -0
- package/src/around.js.map +1 -0
- package/src/autocomplete.d.ts +19 -0
- package/src/autocomplete.js +43 -0
- package/src/autocomplete.js.map +1 -0
- package/src/autosize.d.ts +15 -0
- package/src/autosize.js +18 -0
- package/src/autosize.js.map +1 -0
- package/src/avatar.d.ts +19 -0
- package/src/avatar.js +38 -0
- package/src/avatar.js.map +1 -0
- package/src/button.d.ts +15 -0
- package/src/button.js +21 -0
- package/src/button.js.map +1 -0
- package/src/calendar.d.ts +22 -0
- package/src/calendar.js +60 -0
- package/src/calendar.js.map +1 -0
- package/src/carousel.d.ts +16 -0
- package/src/carousel.js +34 -0
- package/src/carousel.js.map +1 -0
- package/src/checkbox.d.ts +19 -0
- package/src/checkbox.js +42 -0
- package/src/checkbox.js.map +1 -0
- package/src/collapsible.d.ts +16 -0
- package/src/collapsible.js +32 -0
- package/src/collapsible.js.map +1 -0
- package/src/combobox.d.ts +44 -0
- package/src/combobox.js +124 -0
- package/src/combobox.js.map +1 -0
- package/src/command.d.ts +20 -0
- package/src/command.js +61 -0
- package/src/command.js.map +1 -0
- package/src/context-menu.d.ts +18 -0
- package/src/context-menu.js +11 -0
- package/src/context-menu.js.map +1 -0
- package/src/date-field.d.ts +18 -0
- package/src/date-field.js +41 -0
- package/src/date-field.js.map +1 -0
- package/src/date-picker.d.ts +23 -0
- package/src/date-picker.js +69 -0
- package/src/date-picker.js.map +1 -0
- package/src/dates.d.ts +19 -0
- package/src/dates.js +70 -0
- package/src/dates.js.map +1 -0
- package/src/dialog.d.ts +19 -0
- package/src/dialog.js +40 -0
- package/src/dialog.js.map +1 -0
- package/src/drawer.d.ts +24 -0
- package/src/drawer.js +62 -0
- package/src/drawer.js.map +1 -0
- package/src/field.d.ts +16 -0
- package/src/field.js +47 -0
- package/src/field.js.map +1 -0
- package/src/fieldset.d.ts +12 -0
- package/src/fieldset.js +17 -0
- package/src/fieldset.js.map +1 -0
- package/src/form.d.ts +19 -0
- package/src/form.js +30 -0
- package/src/form.js.map +1 -0
- package/src/hover-card.d.ts +15 -0
- package/src/hover-card.js +12 -0
- package/src/hover-card.js.map +1 -0
- package/src/hover-popup.d.ts +6 -0
- package/src/hover-popup.js +37 -0
- package/src/hover-popup.js.map +1 -0
- package/src/index.d.ts +60 -0
- package/src/index.js +49 -0
- package/src/input.d.ts +17 -0
- package/src/input.js +22 -0
- package/src/input.js.map +1 -0
- package/src/label.d.ts +11 -0
- package/src/label.js +15 -0
- package/src/label.js.map +1 -0
- package/src/listbox.d.ts +22 -0
- package/src/listbox.js +54 -0
- package/src/listbox.js.map +1 -0
- package/src/menu.d.ts +26 -0
- package/src/menu.js +133 -0
- package/src/menu.js.map +1 -0
- package/src/menubar.d.ts +16 -0
- package/src/menubar.js +22 -0
- package/src/menubar.js.map +1 -0
- package/src/message-scroller.d.ts +16 -0
- package/src/message-scroller.js +30 -0
- package/src/message-scroller.js.map +1 -0
- package/src/meter.d.ts +16 -0
- package/src/meter.js +40 -0
- package/src/meter.js.map +1 -0
- package/src/navigation-menu.d.ts +20 -0
- package/src/navigation-menu.js +71 -0
- package/src/navigation-menu.js.map +1 -0
- package/src/number-field.d.ts +21 -0
- package/src/number-field.js +57 -0
- package/src/number-field.js.map +1 -0
- package/src/otp.d.ts +19 -0
- package/src/otp.js +64 -0
- package/src/otp.js.map +1 -0
- package/src/pagination.d.ts +18 -0
- package/src/pagination.js +45 -0
- package/src/pagination.js.map +1 -0
- package/src/popover.d.ts +20 -0
- package/src/popover.js +34 -0
- package/src/popover.js.map +1 -0
- package/src/progress.d.ts +16 -0
- package/src/progress.js +40 -0
- package/src/progress.js.map +1 -0
- package/src/qr-code.d.ts +13 -0
- package/src/qr-code.js +24 -0
- package/src/qr-code.js.map +1 -0
- package/src/radio-group.d.ts +17 -0
- package/src/radio-group.js +40 -0
- package/src/radio-group.js.map +1 -0
- package/src/resizable.d.ts +16 -0
- package/src/resizable.js +38 -0
- package/src/resizable.js.map +1 -0
- package/src/runtime.d.ts +157 -0
- package/src/runtime.js +477 -0
- package/src/runtime.js.map +1 -0
- package/src/scroll-area.d.ts +18 -0
- package/src/scroll-area.js +37 -0
- package/src/scroll-area.js.map +1 -0
- package/src/select.d.ts +33 -0
- package/src/select.js +107 -0
- package/src/select.js.map +1 -0
- package/src/separator.d.ts +12 -0
- package/src/separator.js +14 -0
- package/src/separator.js.map +1 -0
- package/src/slider.d.ts +25 -0
- package/src/slider.js +71 -0
- package/src/slider.js.map +1 -0
- package/src/switch.d.ts +18 -0
- package/src/switch.js +37 -0
- package/src/switch.js.map +1 -0
- package/src/tabs.d.ts +16 -0
- package/src/tabs.js +31 -0
- package/src/tabs.js.map +1 -0
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +30 -0
- package/src/toast.js +93 -0
- package/src/toast.js.map +1 -0
- package/src/toggle-group.d.ts +22 -0
- package/src/toggle-group.js +37 -0
- package/src/toggle-group.js.map +1 -0
- package/src/toggle.d.ts +18 -0
- package/src/toggle.js +32 -0
- package/src/toggle.js.map +1 -0
- package/src/toolbar.d.ts +17 -0
- package/src/toolbar.js +31 -0
- package/src/toolbar.js.map +1 -0
- package/src/tooltip.d.ts +15 -0
- package/src/tooltip.js +12 -0
- package/src/tooltip.js.map +1 -0
- package/README.md +0 -7
- package/index.js +0 -5
package/src/otp.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineElement, partAround } from "./runtime.js";
|
|
2
|
+
import { effect } from "@kirana-ui/core";
|
|
3
|
+
import { createOtp } from "@kirana-ui/core/otp";
|
|
4
|
+
// src/otp.ts
|
|
5
|
+
const indexOf = (element) => Number(element?.getAttribute("kui-index") ?? 0);
|
|
6
|
+
/**
|
|
7
|
+
* `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
|
|
8
|
+
* each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
|
|
9
|
+
* the page while the next character goes there. Slots may be in `group`s with a `separator`
|
|
10
|
+
* between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells
|
|
11
|
+
* `value-change` and `complete`.
|
|
12
|
+
*/
|
|
13
|
+
const tag = defineElement({
|
|
14
|
+
tag: "kui-otp",
|
|
15
|
+
props: {
|
|
16
|
+
length: "number",
|
|
17
|
+
value: "string",
|
|
18
|
+
"default-value": "string",
|
|
19
|
+
mode: "string",
|
|
20
|
+
disabled: "boolean",
|
|
21
|
+
name: "string",
|
|
22
|
+
form: "string"
|
|
23
|
+
},
|
|
24
|
+
create: (props) => createOtp(props),
|
|
25
|
+
changes: {
|
|
26
|
+
onValueChange: {
|
|
27
|
+
event: "value-change",
|
|
28
|
+
prop: "value"
|
|
29
|
+
},
|
|
30
|
+
onComplete: {
|
|
31
|
+
event: "complete",
|
|
32
|
+
prop: "value",
|
|
33
|
+
hold: false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
parts: {
|
|
37
|
+
root: (controller) => controller.root,
|
|
38
|
+
input: (controller) => controller.input,
|
|
39
|
+
group: (controller) => controller.group,
|
|
40
|
+
separator: (controller) => controller.separator,
|
|
41
|
+
slot(controller, element) {
|
|
42
|
+
const slot = controller.slot(indexOf(element));
|
|
43
|
+
return {
|
|
44
|
+
part: slot.part,
|
|
45
|
+
mount() {
|
|
46
|
+
const text = element.ownerDocument.createTextNode("");
|
|
47
|
+
element.prepend(text);
|
|
48
|
+
const stop = effect(() => void (text.data = slot.char.get()));
|
|
49
|
+
return () => {
|
|
50
|
+
stop();
|
|
51
|
+
text.remove();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
caret: (controller, element) => ({
|
|
57
|
+
part: controller.caretPart,
|
|
58
|
+
mounted: controller.slot(indexOf(partAround(element, "slot"))).caret
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
export { tag };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=otp.js.map
|
package/src/otp.js.map
ADDED
|
@@ -0,0 +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\"\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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Pagination, PaginationProps } from "@kirana-ui/core/pagination";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-pagination>` around a `kui-part="root"` nav with `previous` and `next` buttons and,
|
|
5
|
+
* between them, a `<template kui-each="items">` holding an `item` button for a page
|
|
6
|
+
* (`kui-when="page"`; `{page}` is its number) and an `ellipsis` for a gap
|
|
7
|
+
* (`kui-when="ellipsis"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,
|
|
8
|
+
* `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.
|
|
9
|
+
*/
|
|
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
|
+
}
|
|
18
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineElement, entryAround } from "./runtime.js";
|
|
2
|
+
import { createPagination } from "@kirana-ui/core/pagination";
|
|
3
|
+
// src/pagination.ts
|
|
4
|
+
/**
|
|
5
|
+
* `<kui-pagination>` around a `kui-part="root"` nav with `previous` and `next` buttons and,
|
|
6
|
+
* between them, a `<template kui-each="items">` holding an `item` button for a page
|
|
7
|
+
* (`kui-when="page"`; `{page}` is its number) and an `ellipsis` for a gap
|
|
8
|
+
* (`kui-when="ellipsis"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,
|
|
9
|
+
* `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.
|
|
10
|
+
*/
|
|
11
|
+
const tag = defineElement({
|
|
12
|
+
tag: "kui-pagination",
|
|
13
|
+
props: {
|
|
14
|
+
page: "number",
|
|
15
|
+
"default-page": "number",
|
|
16
|
+
count: "number",
|
|
17
|
+
"page-size": "number",
|
|
18
|
+
"sibling-count": "number",
|
|
19
|
+
"boundary-count": "number",
|
|
20
|
+
disabled: "boolean"
|
|
21
|
+
},
|
|
22
|
+
create: (props) => createPagination(props),
|
|
23
|
+
changes: { onPageChange: {
|
|
24
|
+
event: "page-change",
|
|
25
|
+
prop: "page"
|
|
26
|
+
} },
|
|
27
|
+
lists: { items: (controller) => ({
|
|
28
|
+
entries: controller.entries,
|
|
29
|
+
key: (entry) => entry.key,
|
|
30
|
+
type: (entry) => entry.type
|
|
31
|
+
}) },
|
|
32
|
+
parts: {
|
|
33
|
+
root: (controller) => controller.root,
|
|
34
|
+
previous: (controller) => controller.previous,
|
|
35
|
+
next: (controller) => controller.next,
|
|
36
|
+
ellipsis: (controller) => controller.ellipsis,
|
|
37
|
+
item(controller, element) {
|
|
38
|
+
const entry = entryAround(element);
|
|
39
|
+
return entry?.type === "page" ? controller.item(entry.page) : void 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
export { tag };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +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\"\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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { PopoverProps } from "@kirana-ui/core/popover";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
|
|
5
|
+
* page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
|
|
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`,
|
|
8
|
+
* a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
|
|
9
|
+
*/
|
|
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
|
+
}
|
|
20
|
+
//# sourceMappingURL=popover.d.ts.map
|
package/src/popover.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { positioner } from "./around.js";
|
|
2
|
+
import { defineElement } from "./runtime.js";
|
|
3
|
+
import { createPopover } from "@kirana-ui/core/popover";
|
|
4
|
+
// src/popover.ts
|
|
5
|
+
/**
|
|
6
|
+
* `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
|
|
7
|
+
* page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
|
|
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`,
|
|
10
|
+
* a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
|
|
11
|
+
*/
|
|
12
|
+
const tag = defineElement({
|
|
13
|
+
tag: "kui-popover",
|
|
14
|
+
props: {
|
|
15
|
+
open: "boolean",
|
|
16
|
+
"default-open": "boolean"
|
|
17
|
+
},
|
|
18
|
+
create: (props) => createPopover(props),
|
|
19
|
+
changes: { onOpenChange: {
|
|
20
|
+
event: "open-change",
|
|
21
|
+
prop: "open"
|
|
22
|
+
} },
|
|
23
|
+
parts: {
|
|
24
|
+
trigger: (controller) => controller.trigger,
|
|
25
|
+
positioner,
|
|
26
|
+
popup: (controller) => controller.popup,
|
|
27
|
+
title: (controller) => controller.title,
|
|
28
|
+
description: (controller) => controller.description,
|
|
29
|
+
close: (controller) => controller.close
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
export { tag };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { ProgressProps } from "@kirana-ui/core/progress";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-progress>` around `kui-part="root"`, a `label`, a `track` with its `indicator`, and a
|
|
5
|
+
* `value`, which says the value as it is written unless the page gave it something to say.
|
|
6
|
+
* `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.
|
|
7
|
+
*/
|
|
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
|
+
}
|
|
16
|
+
//# sourceMappingURL=progress.d.ts.map
|
package/src/progress.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineElement } from "./runtime.js";
|
|
2
|
+
import { computed } from "@kirana-ui/core";
|
|
3
|
+
import { createProgress } from "@kirana-ui/core/progress";
|
|
4
|
+
// src/progress.ts
|
|
5
|
+
/**
|
|
6
|
+
* `<kui-progress>` around `kui-part="root"`, a `label`, a `track` with its `indicator`, and a
|
|
7
|
+
* `value`, which says the value as it is written unless the page gave it something to say.
|
|
8
|
+
* `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.
|
|
9
|
+
*/
|
|
10
|
+
const tag = defineElement({
|
|
11
|
+
tag: "kui-progress",
|
|
12
|
+
props: {
|
|
13
|
+
value: "number",
|
|
14
|
+
min: "number",
|
|
15
|
+
max: "number",
|
|
16
|
+
locale: "string"
|
|
17
|
+
},
|
|
18
|
+
properties: ["format", "getAriaValueText"],
|
|
19
|
+
create: (props) => createProgress(computed(() => {
|
|
20
|
+
const own = props.get();
|
|
21
|
+
return {
|
|
22
|
+
...own,
|
|
23
|
+
value: own.value ?? null
|
|
24
|
+
};
|
|
25
|
+
})),
|
|
26
|
+
changes: {},
|
|
27
|
+
parts: {
|
|
28
|
+
root: (controller) => controller.root,
|
|
29
|
+
label: (controller) => controller.label,
|
|
30
|
+
track: (controller) => controller.track,
|
|
31
|
+
indicator: (controller) => controller.indicator,
|
|
32
|
+
value: (controller) => ({
|
|
33
|
+
part: controller.value,
|
|
34
|
+
text: controller.text
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export { tag };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +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\"\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
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { QrCode, QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-qr-code>` around `kui-part="root"`, a `frame` (an `<svg>`) and its `pattern` (a
|
|
5
|
+
* `<path>`). `value`, `correction`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const tag: Tag<QrCodeProps, QrCode>;
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
"kui-qr-code": ElementOf<typeof tag>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=qr-code.d.ts.map
|
package/src/qr-code.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineElement } from "./runtime.js";
|
|
2
|
+
import { createQrCode } from "@kirana-ui/core/qr-code";
|
|
3
|
+
// src/qr-code.ts
|
|
4
|
+
/**
|
|
5
|
+
* `<kui-qr-code>` around `kui-part="root"`, a `frame` (an `<svg>`) and its `pattern` (a
|
|
6
|
+
* `<path>`). `value`, `correction`.
|
|
7
|
+
*/
|
|
8
|
+
const tag = defineElement({
|
|
9
|
+
tag: "kui-qr-code",
|
|
10
|
+
props: {
|
|
11
|
+
value: "string",
|
|
12
|
+
correction: "string"
|
|
13
|
+
},
|
|
14
|
+
create: (props) => createQrCode(props),
|
|
15
|
+
changes: {},
|
|
16
|
+
parts: {
|
|
17
|
+
root: (controller) => controller.root,
|
|
18
|
+
frame: (controller) => controller.frame,
|
|
19
|
+
pattern: (controller) => controller.pattern
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export { tag };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=qr-code.js.map
|
|
@@ -0,0 +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\"\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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { RadioGroupProps } from "@kirana-ui/core/radio-group";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-radio-group>` around `kui-part="root"` and an `item` button for each `value`, with an
|
|
5
|
+
* `indicator` inside that is in the page while its item is the chosen one. An item draws the
|
|
6
|
+
* hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,
|
|
7
|
+
* `read-only`, `required`, `name`, `form`; it tells `value-change`.
|
|
8
|
+
*/
|
|
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
|
+
}
|
|
17
|
+
//# sourceMappingURL=radio-group.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fieldAround } from "./around.js";
|
|
2
|
+
import { defineElement, partAround } from "./runtime.js";
|
|
3
|
+
import { createRadioGroup } from "@kirana-ui/core/radio-group";
|
|
4
|
+
// src/radio-group.ts
|
|
5
|
+
const valueOf = (element) => partAround(element, "item")?.getAttribute("kui-value") ?? "";
|
|
6
|
+
const options = (element) => () => partAround(element, "item")?.hasAttribute("kui-disabled") ? { disabled: true } : {};
|
|
7
|
+
/**
|
|
8
|
+
* `<kui-radio-group>` around `kui-part="root"` and an `item` button for each `value`, with an
|
|
9
|
+
* `indicator` inside that is in the page while its item is the chosen one. An item draws the
|
|
10
|
+
* hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,
|
|
11
|
+
* `read-only`, `required`, `name`, `form`; it tells `value-change`.
|
|
12
|
+
*/
|
|
13
|
+
const tag = defineElement({
|
|
14
|
+
tag: "kui-radio-group",
|
|
15
|
+
props: {
|
|
16
|
+
value: "string",
|
|
17
|
+
"default-value": "string",
|
|
18
|
+
disabled: "boolean",
|
|
19
|
+
"read-only": "boolean",
|
|
20
|
+
required: "boolean",
|
|
21
|
+
name: "string",
|
|
22
|
+
form: "string"
|
|
23
|
+
},
|
|
24
|
+
create: (props, host) => createRadioGroup(props, { field: fieldAround(host) }),
|
|
25
|
+
changes: { onValueChange: {
|
|
26
|
+
event: "value-change",
|
|
27
|
+
prop: "value"
|
|
28
|
+
} },
|
|
29
|
+
parts: {
|
|
30
|
+
root: (controller) => controller.root,
|
|
31
|
+
item: (controller, element) => ({
|
|
32
|
+
part: controller.item(valueOf(element), options(element)),
|
|
33
|
+
inner: controller.itemInput(valueOf(element), options(element))
|
|
34
|
+
}),
|
|
35
|
+
indicator: (controller, element) => controller.indicator(valueOf(element))
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export { tag };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +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\"\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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Resizable, ResizableProps } from "@kirana-ui/core/resizable";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-resizable>` around `kui-part="group"`, its `panel`s (`kui-default-size`,
|
|
5
|
+
* `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two
|
|
6
|
+
* (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.
|
|
7
|
+
*/
|
|
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
|
+
}
|
|
16
|
+
//# sourceMappingURL=resizable.d.ts.map
|
package/src/resizable.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineElement } from "./runtime.js";
|
|
2
|
+
import { createResizable } from "@kirana-ui/core/resizable";
|
|
3
|
+
// src/resizable.ts
|
|
4
|
+
const number = (element, name) => {
|
|
5
|
+
const text = element.getAttribute(name);
|
|
6
|
+
return text === null ? {} : { [name.slice(4).replace(/-./g, (at) => at[1].toUpperCase())]: +text };
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `<kui-resizable>` around `kui-part="group"`, its `panel`s (`kui-default-size`,
|
|
10
|
+
* `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two
|
|
11
|
+
* (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.
|
|
12
|
+
*/
|
|
13
|
+
const tag = defineElement({
|
|
14
|
+
tag: "kui-resizable",
|
|
15
|
+
props: {
|
|
16
|
+
orientation: "string",
|
|
17
|
+
"keyboard-step": "number",
|
|
18
|
+
disabled: "boolean"
|
|
19
|
+
},
|
|
20
|
+
create: (props) => createResizable(props),
|
|
21
|
+
changes: { onSizesChange: {
|
|
22
|
+
event: "sizes-change",
|
|
23
|
+
prop: "sizes",
|
|
24
|
+
hold: false
|
|
25
|
+
} },
|
|
26
|
+
parts: {
|
|
27
|
+
group: (controller) => controller.group,
|
|
28
|
+
panel: (controller, element) => controller.panel(() => ({
|
|
29
|
+
...number(element, "kui-default-size"),
|
|
30
|
+
...number(element, "kui-min-size"),
|
|
31
|
+
...number(element, "kui-max-size")
|
|
32
|
+
})),
|
|
33
|
+
handle: (controller, element) => controller.handle(() => element.hasAttribute("kui-disabled") ? { disabled: true } : {})
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export { tag };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=resizable.js.map
|
|
@@ -0,0 +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\"\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
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ChangeDetails, Part, ReadonlySignal } from "@kirana-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* A component as a custom element, for a page with no framework.
|
|
4
|
+
*
|
|
5
|
+
* The custom element (`<kui-dialog>`) holds the component and draws nothing: it takes no room
|
|
6
|
+
* (`display: contents`) and no attribute of the component's. Its parts are the page's own
|
|
7
|
+
* elements, named by `kui-part` (`<button kui-part="trigger">`), the root among them. So a
|
|
8
|
+
* trigger is a real button and a switch a real button, and the page is the page the other
|
|
9
|
+
* adapters draw: nothing is wrapped, and there is no shadow root for a design to reach into.
|
|
10
|
+
*
|
|
11
|
+
* A part that is in the page only some of the time (a closed panel, a popup) is taken out of
|
|
12
|
+
* the page while it is not, and put back where it was; `kui-keep-mounted` keeps it.
|
|
13
|
+
*/
|
|
14
|
+
/** What a part's name gives: the part, and what comes with it. */
|
|
15
|
+
export interface Drawn {
|
|
16
|
+
readonly part: Part;
|
|
17
|
+
/** In the page only while this holds. */
|
|
18
|
+
readonly mounted?: ReadonlySignal<boolean> | undefined;
|
|
19
|
+
/** Runs while the part is the component's. Returns the stop. */
|
|
20
|
+
mount?(): () => void;
|
|
21
|
+
/** A hidden native input the part draws itself, as its last child. */
|
|
22
|
+
readonly inner?: Part | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Where the part is drawn while it is mounted, when that is not where it was written: a
|
|
25
|
+
* navigation menu's content, in the menu's one viewport. Out of the page while there is none.
|
|
26
|
+
*/
|
|
27
|
+
readonly into?: ReadonlySignal<HTMLElement | undefined> | undefined;
|
|
28
|
+
/** What the part's element says, when the page gave it nothing to say. */
|
|
29
|
+
readonly text?: ReadonlySignal<string | undefined> | undefined;
|
|
30
|
+
}
|
|
31
|
+
type Kind = "boolean" | "string" | "number";
|
|
32
|
+
/** A list a component draws from a `<template kui-each>`. */
|
|
33
|
+
export interface Each<Entry = any> {
|
|
34
|
+
readonly entries: ReadonlySignal<readonly Entry[]> | readonly Entry[];
|
|
35
|
+
/** What an entry is known by from one drawing to the next. */
|
|
36
|
+
key(entry: Entry): string | number;
|
|
37
|
+
/**
|
|
38
|
+
* Which of the template's elements an entry is drawn with, when they differ: the ones
|
|
39
|
+
* whose `kui-when` says so (a page, an ellipsis). Elements without `kui-when` are for all.
|
|
40
|
+
*/
|
|
41
|
+
type?(entry: Entry): string;
|
|
42
|
+
/**
|
|
43
|
+
* What `{name}` stands for in the template's text and attributes
|
|
44
|
+
* (`data-testid="row-{id}"`). Left out: the entry's own fields.
|
|
45
|
+
*/
|
|
46
|
+
values?(entry: Entry): Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/** The entry an element was stamped for, or the nearest around it: a part reads its own. */
|
|
49
|
+
export declare function entryAround<Entry>(element: Node): Entry | undefined;
|
|
50
|
+
export interface ElementSpec<Props extends {
|
|
51
|
+
id: string;
|
|
52
|
+
}, Controller> {
|
|
53
|
+
/** The custom element's name: `kui-dialog`. */
|
|
54
|
+
tag: string;
|
|
55
|
+
/** Its props by attribute name, each with how an attribute's text is read. */
|
|
56
|
+
props: Record<string, Kind>;
|
|
57
|
+
/** Props that are only properties: a function, an object. By their names as properties. */
|
|
58
|
+
properties?: readonly string[] | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* What the component draws a list of, by name: a calendar's weeks, a toast for each
|
|
61
|
+
* message. The page writes one of an entry as a `<template kui-each="name">` where the
|
|
62
|
+
* list goes, and the element stamps it for each entry, keyed, so an entry that stays keeps
|
|
63
|
+
* its elements. `around` is the entry of the list this one is written in (a week, for its
|
|
64
|
+
* days).
|
|
65
|
+
*/
|
|
66
|
+
lists?: Record<string, (controller: Controller, around: unknown) => Each | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* The hidden native input a form reads, for a component with no part to hold it: drawn as
|
|
69
|
+
* the element's last child, while `mounted` (a select with a name).
|
|
70
|
+
*/
|
|
71
|
+
inner?(controller: Controller): {
|
|
72
|
+
part: Part;
|
|
73
|
+
mounted?: ReadonlySignal<boolean> | undefined;
|
|
74
|
+
};
|
|
75
|
+
/** `host` is the custom element: what is around it (a field, a group) is found from it. */
|
|
76
|
+
create(props: ReadonlySignal<Props>, host: HTMLElement): Controller;
|
|
77
|
+
/**
|
|
78
|
+
* Its change callbacks: the event each is told as, and the prop the element then holds
|
|
79
|
+
* (`open`). The event is cancelable: `preventDefault()` keeps the value as it was.
|
|
80
|
+
*/
|
|
81
|
+
changes: Record<string, {
|
|
82
|
+
event: string;
|
|
83
|
+
prop: string;
|
|
84
|
+
hold?: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
/** Each part by its `kui-part` name. */
|
|
87
|
+
parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>;
|
|
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;
|
|
122
|
+
/**
|
|
123
|
+
* The controller of the component around a custom element: the field a control is in, the
|
|
124
|
+
* group a toggle is one of. Through a portal too: what was moved to the page's end is still
|
|
125
|
+
* inside what it was written in.
|
|
126
|
+
*/
|
|
127
|
+
export declare function controllerAround<Controller>(host: Element, tag: string): Controller | undefined;
|
|
128
|
+
/** The nearest component around a custom element that is one of `tags`: which, and its controller. */
|
|
129
|
+
export declare function hostAround(host: Element, tags: readonly string[]): {
|
|
130
|
+
tag: string;
|
|
131
|
+
controller: unknown;
|
|
132
|
+
} | undefined;
|
|
133
|
+
/** The nearest element around `element` (or itself) that is the part called `name`. */
|
|
134
|
+
export declare function partAround(element: Element, name: string): HTMLElement | null;
|
|
135
|
+
/**
|
|
136
|
+
* The props of something inside a component that has props of its own (a menu's checkbox
|
|
137
|
+
* item, its radio group), read from its element's `kui-` attributes: `kui-checked`,
|
|
138
|
+
* `kui-default-value`. What it tells is told from that element, and may be refused; a value
|
|
139
|
+
* its element was given is held there, and one the page writes later is followed.
|
|
140
|
+
*/
|
|
141
|
+
export declare function partProps<Props>(element: HTMLElement, kinds: Record<string, Kind>, changes: Record<string, {
|
|
142
|
+
event: string;
|
|
143
|
+
prop: string;
|
|
144
|
+
}>): {
|
|
145
|
+
props: ReadonlySignal<Props>;
|
|
146
|
+
mount(): () => void;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Defines a component's custom element, and gives its name (for
|
|
150
|
+
* `customElements.whenDefined`). Where there are no custom elements (a server) it defines
|
|
151
|
+
* nothing.
|
|
152
|
+
*/
|
|
153
|
+
export declare function defineElement<Props extends {
|
|
154
|
+
id: string;
|
|
155
|
+
}, Controller extends object>(spec: ElementSpec<Props, Controller>): Tag<Props, Controller>;
|
|
156
|
+
export {};
|
|
157
|
+
//# sourceMappingURL=runtime.d.ts.map
|