@kirana-ui/web 0.2.0 → 0.4.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/CHANGELOG.md +140 -0
- package/llms.txt +1598 -143
- package/package.json +48 -3
- package/skills/kirana-ui-primitives/SKILL.md +53 -12
- package/src/accordion.d.ts +1 -1
- package/src/accordion.js +2 -1
- package/src/accordion.js.map +1 -1
- package/src/alert-dialog.d.ts +2 -2
- package/src/alert-dialog.js +9 -4
- package/src/alert-dialog.js.map +1 -1
- package/src/around.d.ts +28 -4
- package/src/around.js +46 -13
- package/src/around.js.map +1 -1
- package/src/autocomplete.d.ts +7 -4
- package/src/autocomplete.js +8 -4
- package/src/autocomplete.js.map +1 -1
- package/src/avatar.d.ts +11 -5
- package/src/avatar.js +41 -12
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +2 -1
- package/src/button.js +2 -1
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +9 -5
- package/src/calendar.js +22 -9
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +1 -1
- package/src/carousel.js +4 -2
- package/src/carousel.js.map +1 -1
- package/src/checkbox-group.d.ts +22 -0
- package/src/checkbox-group.js +36 -0
- package/src/checkbox-group.js.map +1 -0
- package/src/checkbox.d.ts +4 -2
- package/src/checkbox.js +10 -4
- package/src/checkbox.js.map +1 -1
- package/src/color-picker.d.ts +28 -0
- package/src/color-picker.js +81 -0
- package/src/color-picker.js.map +1 -0
- package/src/combobox.d.ts +27 -7
- package/src/combobox.js +79 -17
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +3 -3
- package/src/command.js +6 -5
- package/src/command.js.map +1 -1
- package/src/context-menu.d.ts +2 -1
- package/src/context-menu.js.map +1 -1
- package/src/date-field.d.ts +2 -2
- package/src/date-field.js +3 -3
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +14 -8
- package/src/date-picker.js +49 -10
- package/src/date-picker.js.map +1 -1
- package/src/dates.d.ts +11 -5
- package/src/dates.js +58 -20
- package/src/dates.js.map +1 -1
- package/src/dialog.d.ts +3 -2
- package/src/dialog.js +12 -4
- package/src/dialog.js.map +1 -1
- package/src/drawer.d.ts +2 -1
- package/src/drawer.js +7 -3
- package/src/drawer.js.map +1 -1
- package/src/editable.d.ts +21 -0
- package/src/editable.js +56 -0
- package/src/editable.js.map +1 -0
- package/src/file-upload.d.ts +23 -0
- package/src/file-upload.js +98 -0
- package/src/file-upload.js.map +1 -0
- package/src/hover-card.d.ts +2 -1
- package/src/hover-card.js.map +1 -1
- package/src/index.d.ts +29 -7
- package/src/index.js +11 -0
- package/src/menu.d.ts +4 -3
- package/src/menu.js +19 -10
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +2 -2
- package/src/menubar.js +5 -3
- package/src/menubar.js.map +1 -1
- package/src/navigation-menu.d.ts +4 -3
- package/src/navigation-menu.js +10 -6
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +5 -2
- package/src/number-field.js +23 -3
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +4 -2
- package/src/otp.js +24 -4
- package/src/otp.js.map +1 -1
- package/src/password-input.d.ts +20 -0
- package/src/password-input.js +39 -0
- package/src/password-input.js.map +1 -0
- package/src/popover.d.ts +8 -7
- package/src/popover.js +33 -5
- package/src/popover.js.map +1 -1
- package/src/radio-group.d.ts +2 -1
- package/src/radio-group.js +9 -2
- package/src/radio-group.js.map +1 -1
- package/src/rating.d.ts +18 -0
- package/src/rating.js +54 -0
- package/src/rating.js.map +1 -0
- package/src/runtime.d.ts +9 -4
- package/src/runtime.js +8 -5
- package/src/runtime.js.map +1 -1
- package/src/select.d.ts +12 -4
- package/src/select.js +33 -10
- package/src/select.js.map +1 -1
- package/src/slider.d.ts +2 -2
- package/src/slider.js +3 -2
- package/src/slider.js.map +1 -1
- package/src/steps.d.ts +17 -0
- package/src/steps.js +47 -0
- package/src/steps.js.map +1 -0
- package/src/tags-input.d.ts +35 -0
- package/src/tags-input.js +96 -0
- package/src/tags-input.js.map +1 -0
- package/src/time-field.d.ts +18 -0
- package/src/time-field.js +54 -0
- package/src/time-field.js.map +1 -0
- package/src/toast.d.ts +4 -3
- package/src/toast.js +6 -4
- package/src/toast.js.map +1 -1
- package/src/toggle-group.d.ts +1 -1
- package/src/toggle-group.js +2 -1
- package/src/toggle-group.js.map +1 -1
- package/src/toolbar.d.ts +0 -6
- package/src/toolbar.js +14 -3
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +2 -1
- package/src/tooltip.js.map +1 -1
- package/src/tour.d.ts +27 -0
- package/src/tour.js +62 -0
- package/src/tour.js.map +1 -0
- package/src/tree.d.ts +29 -0
- package/src/tree.js +99 -0
- package/src/tree.js.map +1 -0
package/src/toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","names":[],"sources":["../../../../packages/web/src/toast.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport type { Part } from \"@kirana-ui/core\"\nimport { createToast, createToaster } from \"@kirana-ui/core/toast\"\nimport type { Toast, ToastProps, ToastRecord, Toaster } from \"@kirana-ui/core/toast\"\n\nimport { defineElement, entryAround } from \"./runtime.ts\"\nimport type { Drawn, ElementOf } from \"./runtime.ts\"\n\nconst toasters = new WeakMap<Element, Toaster>()\n\n/**\n * The toaster a `<kui-toast>` draws: its own (made with the element's `
|
|
1
|
+
{"version":3,"file":"toast.js","names":[],"sources":["../../../../packages/web/src/toast.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport type { Part } from \"@kirana-ui/core\"\nimport { createToast, createToaster } from \"@kirana-ui/core/toast\"\nimport type { Toast, ToastProps, ToastRecord, Toaster } from \"@kirana-ui/core/toast\"\n\nimport { defineElement, entryAround } from \"./runtime.ts\"\nimport type { Drawn, ElementOf } from \"./runtime.ts\"\n\nconst toasters = new WeakMap<Element, Toaster>()\n\n/**\n * The toaster a `<kui-toast>` draws: its own (made with the element's `timeout`,\n * `duration`, its old name, and `limit`), unless it was given one as its `toaster` property before it began.\n * `toasterOf(element).add({ title: \"Saved\" })`.\n */\nexport function toasterOf(element: Element): Toaster {\n let toaster = toasters.get(element)\n if (!toaster) {\n const number = (name: string) =>\n element.hasAttribute(name) ? { [name]: Number(element.getAttribute(name)) } : {}\n toasters.set(\n element,\n (toaster = createToaster({ ...number(\"timeout\"), ...number(\"duration\"), ...number(\"limit\") }))\n )\n }\n return toaster\n}\n\nconst partsOf = (controller: Toast, element: HTMLElement) => {\n const toast = entryAround<ToastRecord>(element)\n return toast && controller.toast(toast.id)\n}\n\n/**\n * A part that says something of the toast's, when the page wrote nothing in its element: the\n * text the toast was added with, and out of the page while the toast has none. What the page\n * wrote there (`{title}`) stays the page's.\n */\nconst said =\n (name: \"title\" | \"description\" | \"action\") =>\n (controller: Toast, element: HTMLElement): Part | Drawn | undefined => {\n const parts = partsOf(controller, element)\n if (!parts || element.childNodes.length > 0) return parts?.[name]\n const text = computed(() => {\n const toast = parts.record.get()\n return name === \"action\" ? toast?.action?.label : toast?.[name]\n })\n return { part: parts[name], text, mounted: computed(() => text.get() !== undefined) }\n }\n\n/**\n * `<kui-toast>` around a `kui-part=\"viewport\"`, which holds a `<template kui-each=\"toasts\">`\n * with a `toast` for each message (`{id}`, `{type}`), its `content` with a `title` and a\n * `description`, and a `close` and an `action` button. A `title`, a `description` and an\n * `action` written empty say what the toast was added with, and are in the page only for a\n * toast that has one; one written with something in it (`{title}`) is always there. `label`,\n * `hotkey`, `swipe-direction`; `timeout` (`duration`, its old name) and `limit` for the toaster it makes, or `toaster`\n * as a property for one of the page's own. A title, a description and an action's label are\n * strings.\n */\nexport const tag = defineElement<\n Omit<ToastProps, \"toaster\"> & {\n toaster?: Toaster\n timeout?: number\n duration?: number\n limit?: number\n },\n Toast\n>({\n tag: \"kui-toast\",\n props: {\n label: \"string\",\n hotkey: \"string\",\n \"swipe-direction\": \"string\",\n timeout: \"number\",\n duration: \"number\",\n limit: \"number\",\n },\n properties: [\"toaster\"],\n create(props, host) {\n const given = props.peek().toaster\n if (given) toasters.set(host, given)\n const toaster = toasterOf(host)\n return createToast(\n computed(() => {\n const { timeout: _timeout, duration: _duration, limit: _limit, ...own } = props.get()\n return { ...own, toaster }\n })\n )\n },\n changes: {},\n lists: {\n toasts: (controller) => ({ entries: controller.toasts, key: (toast: ToastRecord) => toast.id }),\n },\n parts: {\n viewport: (controller) => controller.viewport,\n toast: (controller, element) => partsOf(controller, element)?.root,\n content: (controller, element) => partsOf(controller, element)?.content,\n title: said(\"title\"),\n description: said(\"description\"),\n close: (controller, element) => partsOf(controller, element)?.close,\n action: said(\"action\"),\n },\n})\n\nexport { createToaster }\nexport type { Toaster }\nexport type {\n ToastActionOptions,\n ToastOptions,\n ToastRecord,\n ToastState,\n ToasterOptions,\n} from \"@kirana-ui/core/toast\"\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-toast\": ElementOf<typeof tag>\n }\n}\n"],"mappings":";;;;AAQA,MAAM,2BAAW,IAAI,QAA0B;;;;;;AAO/C,SAAgB,UAAU,SAA2B;CACnD,IAAI,UAAU,SAAS,IAAI,OAAO;CAClC,IAAI,CAAC,SAAS;EACZ,MAAM,UAAU,SACd,QAAQ,aAAa,IAAI,IAAI,GAAG,OAAO,OAAO,QAAQ,aAAa,IAAI,CAAC,EAAE,IAAI,CAAC;EACjF,SAAS,IACP,SACC,UAAU,cAAc;GAAE,GAAG,OAAO,SAAS;GAAG,GAAG,OAAO,UAAU;GAAG,GAAG,OAAO,OAAO;EAAE,CAAC,CAC9F;CACF;CACA,OAAO;AACT;AAEA,MAAM,WAAW,YAAmB,YAAyB;CAC3D,MAAM,QAAQ,YAAyB,OAAO;CAC9C,OAAO,SAAS,WAAW,MAAM,MAAM,EAAE;AAC3C;;;;;;AAOA,MAAM,QACH,UACA,YAAmB,YAAmD;CACrE,MAAM,QAAQ,QAAQ,YAAY,OAAO;CACzC,IAAI,CAAC,SAAS,QAAQ,WAAW,SAAS,GAAG,OAAO,QAAQ;CAC5D,MAAM,OAAO,eAAe;EAC1B,MAAM,QAAQ,MAAM,OAAO,IAAI;EAC/B,OAAO,SAAS,WAAW,OAAO,QAAQ,QAAQ,QAAQ;CAC5D,CAAC;CACD,OAAO;EAAE,MAAM,MAAM;EAAO;EAAM,SAAS,eAAe,KAAK,IAAI,MAAM,KAAA,CAAS;CAAE;AACtF;;;;;;;;;;;AAYF,MAAa,MAAM,cAQjB;CACA,KAAK;CACL,OAAO;EACL,OAAO;EACP,QAAQ;EACR,mBAAmB;EACnB,SAAS;EACT,UAAU;EACV,OAAO;CACT;CACA,YAAY,CAAC,SAAS;CACtB,OAAO,OAAO,MAAM;EAClB,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC;EAC3B,IAAI,OAAO,SAAS,IAAI,MAAM,KAAK;EACnC,MAAM,UAAU,UAAU,IAAI;EAC9B,OAAO,YACL,eAAe;GACb,MAAM,EAAE,SAAS,UAAU,UAAU,WAAW,OAAO,QAAQ,GAAG,QAAQ,MAAM,IAAI;GACpF,OAAO;IAAE,GAAG;IAAK;GAAQ;EAC3B,CAAC,CACH;CACF;CACA,SAAS,CAAC;CACV,OAAO,EACL,SAAS,gBAAgB;EAAE,SAAS,WAAW;EAAQ,MAAM,UAAuB,MAAM;CAAG,GAC/F;CACA,OAAO;EACL,WAAW,eAAe,WAAW;EACrC,QAAQ,YAAY,YAAY,QAAQ,YAAY,OAAO,CAAC,EAAE;EAC9D,UAAU,YAAY,YAAY,QAAQ,YAAY,OAAO,CAAC,EAAE;EAChE,OAAO,KAAK,OAAO;EACnB,aAAa,KAAK,aAAa;EAC/B,QAAQ,YAAY,YAAY,QAAQ,YAAY,OAAO,CAAC,EAAE;EAC9D,QAAQ,KAAK,QAAQ;CACvB;AACF,CAAC"}
|
package/src/toggle-group.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type Props = Omit<ToggleGroupProps<string>, "value" | "defaultValue"> & {
|
|
|
8
8
|
/**
|
|
9
9
|
* `<kui-toggle-group>` around `kui-part="root"` and its `<kui-toggle>`s, each with a `value`.
|
|
10
10
|
* `value` and `default-value` (the pressed ones, with commas between), `multiple`, `disabled`,
|
|
11
|
-
* `orientation`, `loop
|
|
11
|
+
* `orientation`, `loop-focus` (`loop` is its older name); it tells `value-change`.
|
|
12
12
|
*/
|
|
13
13
|
export declare const tag: Tag<Props, ToggleGroup<string>>;
|
|
14
14
|
declare global {
|
package/src/toggle-group.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createToggleGroup } from "@kirana-ui/core/toggle-group";
|
|
|
6
6
|
/**
|
|
7
7
|
* `<kui-toggle-group>` around `kui-part="root"` and its `<kui-toggle>`s, each with a `value`.
|
|
8
8
|
* `value` and `default-value` (the pressed ones, with commas between), `multiple`, `disabled`,
|
|
9
|
-
* `orientation`, `loop
|
|
9
|
+
* `orientation`, `loop-focus` (`loop` is its older name); it tells `value-change`.
|
|
10
10
|
*/
|
|
11
11
|
const tag = defineElement({
|
|
12
12
|
tag: "kui-toggle-group",
|
|
@@ -16,6 +16,7 @@ const tag = defineElement({
|
|
|
16
16
|
multiple: "boolean",
|
|
17
17
|
disabled: "boolean",
|
|
18
18
|
orientation: "string",
|
|
19
|
+
"loop-focus": "boolean",
|
|
19
20
|
loop: "boolean"
|
|
20
21
|
},
|
|
21
22
|
create: (props, host) => createToggleGroup(computed(() => {
|
package/src/toggle-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.js","names":[],"sources":["../../../../packages/web/src/toggle-group.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type { ToggleGroup, ToggleGroupProps } from \"@kirana-ui/core/toggle-group\"\n\nimport { list } from \"./around.ts\"\nimport { controllerAround, defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\ntype Props = Omit<ToggleGroupProps<string>, \"value\" | \"defaultValue\"> & {\n id: string\n value?: string | readonly string[]\n defaultValue?: string | readonly string[]\n}\n\n/**\n * `<kui-toggle-group>` around `kui-part=\"root\"` and its `<kui-toggle>`s, each with a `value`.\n * `value` and `default-value` (the pressed ones, with commas between), `multiple`, `disabled`,\n * `orientation`, `loop
|
|
1
|
+
{"version":3,"file":"toggle-group.js","names":[],"sources":["../../../../packages/web/src/toggle-group.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type { ToggleGroup, ToggleGroupProps } from \"@kirana-ui/core/toggle-group\"\n\nimport { list } from \"./around.ts\"\nimport { controllerAround, defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\ntype Props = Omit<ToggleGroupProps<string>, \"value\" | \"defaultValue\"> & {\n id: string\n value?: string | readonly string[]\n defaultValue?: string | readonly string[]\n}\n\n/**\n * `<kui-toggle-group>` around `kui-part=\"root\"` and its `<kui-toggle>`s, each with a `value`.\n * `value` and `default-value` (the pressed ones, with commas between), `multiple`, `disabled`,\n * `orientation`, `loop-focus` (`loop` is its older name); it tells `value-change`.\n */\nexport const tag = defineElement<Props, ToggleGroup<string>>({\n tag: \"kui-toggle-group\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n multiple: \"boolean\",\n disabled: \"boolean\",\n orientation: \"string\",\n \"loop-focus\": \"boolean\",\n loop: \"boolean\",\n },\n create: (props, host) =>\n createToggleGroup<string>(\n computed(() => {\n const own = props.get()\n return { ...own, value: list(own.value), defaultValue: list(own.defaultValue) }\n }),\n { toolbar: controllerAround(host, \"kui-toolbar\") }\n ),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: { root: (controller) => controller.root },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-toggle-group\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAa,MAAM,cAA0C;CAC3D,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV,aAAa;EACb,cAAc;EACd,MAAM;CACR;CACA,SAAS,OAAO,SACd,kBACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,KAAK,IAAI,KAAK;GAAG,cAAc,KAAK,IAAI,YAAY;EAAE;CAChF,CAAC,GACD,EAAE,SAAS,iBAAiB,MAAM,aAAa,EAAE,CACnD;CACF,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
|
package/src/toolbar.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
2
|
import { ToolbarProps } from "@kirana-ui/core/toolbar";
|
|
3
|
-
/**
|
|
4
|
-
* `<kui-toolbar>` around `kui-part="root"` and its items: a `button`, a `link`, an `input`, a
|
|
5
|
-
* `group`, a `separator` (`kui-disabled` on one that is off), and `<kui-toggle>`s and
|
|
6
|
-
* `<kui-toggle-group>`s, which are the toolbar's items too. One stop for Tab; the arrows move
|
|
7
|
-
* between them. `orientation`, `loop`, `disabled`.
|
|
8
|
-
*/
|
|
9
3
|
export declare const tag: Tag<{
|
|
10
4
|
id: string;
|
|
11
5
|
}, import("@kirana-ui/core/toolbar").Toolbar>;
|
package/src/toolbar.js
CHANGED
|
@@ -6,12 +6,23 @@ import { createToolbar } from "@kirana-ui/core/toolbar";
|
|
|
6
6
|
* `<kui-toolbar>` around `kui-part="root"` and its items: a `button`, a `link`, an `input`, a
|
|
7
7
|
* `group`, a `separator` (`kui-disabled` on one that is off), and `<kui-toggle>`s and
|
|
8
8
|
* `<kui-toggle-group>`s, which are the toolbar's items too. One stop for Tab; the arrows move
|
|
9
|
-
* between them. `orientation`, `loop
|
|
9
|
+
* between them. `orientation`, `loop-focus` (`loop` is its older name), `disabled`. A disabled
|
|
10
|
+
* button or input stays focusable, as Base UI's; `kui-focusable-when-disabled="false"` on one
|
|
11
|
+
* disables it the element's own way, and the arrows pass it.
|
|
10
12
|
*/
|
|
13
|
+
/** A button's or an input's options: its part's own, and whether it keeps focus while disabled. */
|
|
14
|
+
const control = (element) => {
|
|
15
|
+
const own = options(element);
|
|
16
|
+
return () => ({
|
|
17
|
+
...own(),
|
|
18
|
+
...element.getAttribute("kui-focusable-when-disabled") === "false" ? { focusableWhenDisabled: false } : {}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
11
21
|
const tag = defineElement({
|
|
12
22
|
tag: "kui-toolbar",
|
|
13
23
|
props: {
|
|
14
24
|
orientation: "string",
|
|
25
|
+
"loop-focus": "boolean",
|
|
15
26
|
loop: "boolean",
|
|
16
27
|
disabled: "boolean"
|
|
17
28
|
},
|
|
@@ -19,8 +30,8 @@ const tag = defineElement({
|
|
|
19
30
|
changes: {},
|
|
20
31
|
parts: {
|
|
21
32
|
root: (controller) => controller.root,
|
|
22
|
-
button: (controller, element) => controller.button(
|
|
23
|
-
input: (controller, element) => controller.input(
|
|
33
|
+
button: (controller, element) => controller.button(control(element)),
|
|
34
|
+
input: (controller, element) => controller.input(control(element)),
|
|
24
35
|
group: (controller, element) => controller.group(options(element)),
|
|
25
36
|
link: (controller) => controller.link(),
|
|
26
37
|
separator: (controller) => controller.separator
|
package/src/toolbar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.js","names":[],"sources":["../../../../packages/web/src/toolbar.ts"],"sourcesContent":["import { createToolbar } from \"@kirana-ui/core/toolbar\"\nimport type { ToolbarProps } from \"@kirana-ui/core/toolbar\"\n\nimport { options } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-toolbar>` around `kui-part=\"root\"` and its items: a `button`, a `link`, an `input`, a\n * `group`, a `separator` (`kui-disabled` on one that is off), and `<kui-toggle>`s and\n * `<kui-toggle-group>`s, which are the toolbar's items too. One stop for Tab; the arrows move\n * between them. `orientation`, `loop
|
|
1
|
+
{"version":3,"file":"toolbar.js","names":[],"sources":["../../../../packages/web/src/toolbar.ts"],"sourcesContent":["import { createToolbar } from \"@kirana-ui/core/toolbar\"\nimport type { ToolbarProps } from \"@kirana-ui/core/toolbar\"\n\nimport { options } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-toolbar>` around `kui-part=\"root\"` and its items: a `button`, a `link`, an `input`, a\n * `group`, a `separator` (`kui-disabled` on one that is off), and `<kui-toggle>`s and\n * `<kui-toggle-group>`s, which are the toolbar's items too. One stop for Tab; the arrows move\n * between them. `orientation`, `loop-focus` (`loop` is its older name), `disabled`. A disabled\n * button or input stays focusable, as Base UI's; `kui-focusable-when-disabled=\"false\"` on one\n * disables it the element's own way, and the arrows pass it.\n */\n/** A button's or an input's options: its part's own, and whether it keeps focus while disabled. */\nconst control = (element: HTMLElement) => {\n const own = options(element)\n return () => ({\n ...own(),\n ...(element.getAttribute(\"kui-focusable-when-disabled\") === \"false\"\n ? { focusableWhenDisabled: false }\n : {}),\n })\n}\n\nexport const tag = defineElement({\n tag: \"kui-toolbar\",\n props: { orientation: \"string\", \"loop-focus\": \"boolean\", loop: \"boolean\", disabled: \"boolean\" },\n create: (props) => createToolbar(props as never),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n button: (controller, element) => controller.button(control(element)),\n input: (controller, element) => controller.input(control(element)),\n group: (controller, element) => controller.group(options(element)),\n link: (controller) => controller.link(),\n separator: (controller) => controller.separator,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-toolbar\": ElementOf<As<typeof tag, ToolbarProps>>\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,WAAW,YAAyB;CACxC,MAAM,MAAM,QAAQ,OAAO;CAC3B,cAAc;EACZ,GAAG,IAAI;EACP,GAAI,QAAQ,aAAa,6BAA6B,MAAM,UACxD,EAAE,uBAAuB,MAAM,IAC/B,CAAC;CACP;AACF;AAEA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,aAAa;EAAU,cAAc;EAAW,MAAM;EAAW,UAAU;CAAU;CAC9F,SAAS,UAAU,cAAc,KAAc;CAC/C,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,SAAS,YAAY,YAAY,WAAW,OAAO,QAAQ,OAAO,CAAC;EACnE,QAAQ,YAAY,YAAY,WAAW,MAAM,QAAQ,OAAO,CAAC;EACjE,QAAQ,YAAY,YAAY,WAAW,MAAM,QAAQ,OAAO,CAAC;EACjE,OAAO,eAAe,WAAW,KAAK;EACtC,YAAY,eAAe,WAAW;CACxC;AACF,CAAC"}
|
package/src/tooltip.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Placed } from "./around.js";
|
|
2
3
|
/**
|
|
3
4
|
* `<kui-tooltip>` around a `kui-part="trigger"` and a `portal` with a `positioner` (its
|
|
4
5
|
* `kui-side` and the like) around the `popup`, which may hold an `arrow`. `open`,
|
|
@@ -9,7 +10,7 @@ declare global {
|
|
|
9
10
|
interface HTMLElementTagNameMap {
|
|
10
11
|
"kui-tooltip": ElementOf<typeof tag, {
|
|
11
12
|
"open-change": ["onOpenChange", "open"];
|
|
12
|
-
}
|
|
13
|
+
}> & Placed;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=tooltip.d.ts.map
|
package/src/tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":[],"sources":["../../../../packages/web/src/tooltip.ts"],"sourcesContent":["import { createTooltip } from \"@kirana-ui/core/tooltip\"\n\nimport { hoverPopup } from \"./hover-popup.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-tooltip>` around a `kui-part=\"trigger\"` and a `portal` with a `positioner` (its\n * `kui-side` and the like) around the `popup`, which may hold an `arrow`. `open`,\n * `default-open`, `delay`, `close-delay`, `disabled`; it tells `open-change`.\n */\nexport const tag = hoverPopup(\"kui-tooltip\", createTooltip)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-tooltip\": ElementOf<typeof tag, { \"open-change\": [\"onOpenChange\", \"open\"] }
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":[],"sources":["../../../../packages/web/src/tooltip.ts"],"sourcesContent":["import { createTooltip } from \"@kirana-ui/core/tooltip\"\n\nimport { hoverPopup } from \"./hover-popup.ts\"\nimport type { Placed } from \"./around.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-tooltip>` around a `kui-part=\"trigger\"` and a `portal` with a `positioner` (its\n * `kui-side` and the like) around the `popup`, which may hold an `arrow`. `open`,\n * `default-open`, `delay`, `close-delay`, `disabled`; it tells `open-change`.\n */\nexport const tag = hoverPopup(\"kui-tooltip\", createTooltip)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-tooltip\": ElementOf<typeof tag, { \"open-change\": [\"onOpenChange\", \"open\"] }> & Placed\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,MAAM,WAAW,eAAe,aAAa"}
|
package/src/tour.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Placed } from "./around.js";
|
|
3
|
+
import { Tour, TourProps, TourStep } from "@kirana-ui/core/tour";
|
|
4
|
+
/**
|
|
5
|
+
* `<kui-tour>` around a `kui-part="portal"`, drawn at the end of the page while a step is
|
|
6
|
+
* shown, which holds a `spotlight` and a `positioner` (`kui-side`, `kui-align`,
|
|
7
|
+
* `kui-side-offset` and the like) around the `popup`, with an `arrow`, a `title`, a
|
|
8
|
+
* `description`, and `previous`, `next` and `close` buttons. What a step says is the page's to
|
|
9
|
+
* write: its `controller` has the step shown (`shown`), its place (`current`) and how many
|
|
10
|
+
* there are (`total`). `steps` as a property; `open`, `default-open`, `step`, `default-step`,
|
|
11
|
+
* `wait-for-target`, `spotlight-padding`, `close-on-outside-press`, `interactive`,
|
|
12
|
+
* `keyboard-navigation`; it tells `open-change` and `step-change`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const tag: Tag<Omit<TourProps<TourStep>, "steps"> & {
|
|
15
|
+
steps?: readonly TourStep[] | undefined;
|
|
16
|
+
} & {
|
|
17
|
+
id: string;
|
|
18
|
+
}, Tour<TourStep>>;
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
"kui-tour": ElementOf<typeof tag, {
|
|
22
|
+
"open-change": ["onOpenChange", "open"];
|
|
23
|
+
"step-change": ["onStepChange", "step"];
|
|
24
|
+
}> & Placed;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=tour.d.ts.map
|
package/src/tour.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { positioner } from "./around.js";
|
|
2
|
+
import { defineElement } from "./runtime.js";
|
|
3
|
+
import { computed } from "@kirana-ui/core";
|
|
4
|
+
import { createTour } from "@kirana-ui/core/tour";
|
|
5
|
+
// src/tour.ts
|
|
6
|
+
const NONE = [];
|
|
7
|
+
/**
|
|
8
|
+
* `<kui-tour>` around a `kui-part="portal"`, drawn at the end of the page while a step is
|
|
9
|
+
* shown, which holds a `spotlight` and a `positioner` (`kui-side`, `kui-align`,
|
|
10
|
+
* `kui-side-offset` and the like) around the `popup`, with an `arrow`, a `title`, a
|
|
11
|
+
* `description`, and `previous`, `next` and `close` buttons. What a step says is the page's to
|
|
12
|
+
* write: its `controller` has the step shown (`shown`), its place (`current`) and how many
|
|
13
|
+
* there are (`total`). `steps` as a property; `open`, `default-open`, `step`, `default-step`,
|
|
14
|
+
* `wait-for-target`, `spotlight-padding`, `close-on-outside-press`, `interactive`,
|
|
15
|
+
* `keyboard-navigation`; it tells `open-change` and `step-change`.
|
|
16
|
+
*/
|
|
17
|
+
const tag = defineElement({
|
|
18
|
+
tag: "kui-tour",
|
|
19
|
+
props: {
|
|
20
|
+
open: "boolean",
|
|
21
|
+
"default-open": "boolean",
|
|
22
|
+
step: "number",
|
|
23
|
+
"default-step": "number",
|
|
24
|
+
"wait-for-target": "number",
|
|
25
|
+
"spotlight-padding": "number",
|
|
26
|
+
"close-on-outside-press": "boolean",
|
|
27
|
+
interactive: "boolean",
|
|
28
|
+
"keyboard-navigation": "boolean"
|
|
29
|
+
},
|
|
30
|
+
properties: ["steps"],
|
|
31
|
+
create: (props) => createTour(computed(() => {
|
|
32
|
+
const own = props.get();
|
|
33
|
+
return {
|
|
34
|
+
...own,
|
|
35
|
+
steps: own.steps ?? NONE
|
|
36
|
+
};
|
|
37
|
+
})),
|
|
38
|
+
changes: {
|
|
39
|
+
onOpenChange: {
|
|
40
|
+
event: "open-change",
|
|
41
|
+
prop: "open"
|
|
42
|
+
},
|
|
43
|
+
onStepChange: {
|
|
44
|
+
event: "step-change",
|
|
45
|
+
prop: "step"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
parts: {
|
|
49
|
+
spotlight: (controller) => controller.spotlight,
|
|
50
|
+
positioner,
|
|
51
|
+
popup: (controller) => controller.popup,
|
|
52
|
+
arrow: (controller) => controller.arrow,
|
|
53
|
+
title: (controller) => controller.title,
|
|
54
|
+
description: (controller) => controller.description,
|
|
55
|
+
previous: (controller) => controller.previous,
|
|
56
|
+
next: (controller) => controller.next,
|
|
57
|
+
close: (controller) => controller.close
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export { tag };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=tour.js.map
|
package/src/tour.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tour.js","names":[],"sources":["../../../../packages/web/src/tour.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createTour } from \"@kirana-ui/core/tour\"\nimport type { Tour, TourProps, TourStep } from \"@kirana-ui/core/tour\"\n\nimport { positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\ntype Props = Omit<TourProps, \"steps\"> & { steps?: readonly TourStep[] | undefined }\n\nconst NONE: readonly TourStep[] = []\n\n/**\n * `<kui-tour>` around a `kui-part=\"portal\"`, drawn at the end of the page while a step is\n * shown, which holds a `spotlight` and a `positioner` (`kui-side`, `kui-align`,\n * `kui-side-offset` and the like) around the `popup`, with an `arrow`, a `title`, a\n * `description`, and `previous`, `next` and `close` buttons. What a step says is the page's to\n * write: its `controller` has the step shown (`shown`), its place (`current`) and how many\n * there are (`total`). `steps` as a property; `open`, `default-open`, `step`, `default-step`,\n * `wait-for-target`, `spotlight-padding`, `close-on-outside-press`, `interactive`,\n * `keyboard-navigation`; it tells `open-change` and `step-change`.\n */\nexport const tag = defineElement<Props & { id: string }, Tour>({\n tag: \"kui-tour\",\n props: {\n open: \"boolean\",\n \"default-open\": \"boolean\",\n step: \"number\",\n \"default-step\": \"number\",\n \"wait-for-target\": \"number\",\n \"spotlight-padding\": \"number\",\n \"close-on-outside-press\": \"boolean\",\n interactive: \"boolean\",\n \"keyboard-navigation\": \"boolean\",\n },\n properties: [\"steps\"],\n create: (props) =>\n createTour(\n computed(() => {\n const own = props.get()\n // Given as a property, which a page sets once the element is defined.\n return { ...own, steps: own.steps ?? NONE }\n })\n ),\n changes: {\n onOpenChange: { event: \"open-change\", prop: \"open\" },\n onStepChange: { event: \"step-change\", prop: \"step\" },\n },\n parts: {\n spotlight: (controller) => controller.spotlight,\n positioner,\n popup: (controller) => controller.popup,\n arrow: (controller) => controller.arrow,\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-tour\": ElementOf<\n typeof tag,\n { \"open-change\": [\"onOpenChange\", \"open\"]; \"step-change\": [\"onStepChange\", \"step\"] }\n > &\n Placed\n }\n}\n"],"mappings":";;;;;AAWA,MAAM,OAA4B,CAAC;;;;;;;;;;;AAYnC,MAAa,MAAM,cAA4C;CAC7D,KAAK;CACL,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,MAAM;EACN,gBAAgB;EAChB,mBAAmB;EACnB,qBAAqB;EACrB,0BAA0B;EAC1B,aAAa;EACb,uBAAuB;CACzB;CACA,YAAY,CAAC,OAAO;CACpB,SAAS,UACP,WACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EAEtB,OAAO;GAAE,GAAG;GAAK,OAAO,IAAI,SAAS;EAAK;CAC5C,CAAC,CACH;CACF,SAAS;EACP,cAAc;GAAE,OAAO;GAAe,MAAM;EAAO;EACnD,cAAc;GAAE,OAAO;GAAe,MAAM;EAAO;CACrD;CACA,OAAO;EACL,YAAY,eAAe,WAAW;EACtC;EACA,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,WAAW,eAAe,WAAW;EACrC,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
|
package/src/tree.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Tree, TreeProps } from "@kirana-ui/core/tree";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-tree>` around `kui-part="root"` and its nodes: each an `item` (`kui-value`, and
|
|
5
|
+
* `kui-branch`, `kui-disabled`, `kui-loading`, `kui-label` as it needs), nested as the page
|
|
6
|
+
* nests them, holding an `item-row` with an `item-indicator` and an `item-text`, and, for a
|
|
7
|
+
* branch, a `group` of its children, in the page while the branch is open (`kui-keep-mounted`
|
|
8
|
+
* keeps it). A node's depth is read from the nodes around it. `expanded-value`,
|
|
9
|
+
* `default-expanded-value`, `selected-value` and `default-selected-value` (with commas
|
|
10
|
+
* between), `selection-mode`, `expand-on-click`; it tells `expanded-change` and
|
|
11
|
+
* `selected-change`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const tag: Tag<Omit<TreeProps<string>, "defaultExpandedValue" | "defaultSelectedValue" | "expandedValue" | "selectedValue"> & {
|
|
14
|
+
expandedValue?: string | readonly string[];
|
|
15
|
+
defaultExpandedValue?: string | readonly string[];
|
|
16
|
+
selectedValue?: string | readonly string[];
|
|
17
|
+
defaultSelectedValue?: string | readonly string[];
|
|
18
|
+
} & {
|
|
19
|
+
id: string;
|
|
20
|
+
}, Tree<string>>;
|
|
21
|
+
declare global {
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
"kui-tree": ElementOf<typeof tag, {
|
|
24
|
+
"expanded-change": ["onExpandedChange", "expandedValue"];
|
|
25
|
+
"selected-change": ["onSelectedChange", "selectedValue"];
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=tree.d.ts.map
|
package/src/tree.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { list, ownValue } from "./around.js";
|
|
2
|
+
import { defineElement, partAround } from "./runtime.js";
|
|
3
|
+
import { computed } from "@kirana-ui/core";
|
|
4
|
+
import { createTree } from "@kirana-ui/core/tree";
|
|
5
|
+
// src/tree.ts
|
|
6
|
+
const items = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
/** How deep a node is, from 1: the nodes around it in the page, up to the tree's root. */
|
|
8
|
+
function levelOf(node) {
|
|
9
|
+
let level = 1;
|
|
10
|
+
for (let up = node.parentElement; up; up = up.parentElement) {
|
|
11
|
+
const name = up.getAttribute("kui-part");
|
|
12
|
+
if (name === "root") break;
|
|
13
|
+
if (name === "item") level++;
|
|
14
|
+
}
|
|
15
|
+
return level;
|
|
16
|
+
}
|
|
17
|
+
function itemOf(controller, element) {
|
|
18
|
+
const node = partAround(element, "item");
|
|
19
|
+
if (!node) return void 0;
|
|
20
|
+
let item = items.get(node);
|
|
21
|
+
if (!item) {
|
|
22
|
+
const level = levelOf(node);
|
|
23
|
+
item = controller.item(node.getAttribute("kui-value") ?? ownValue(node), () => {
|
|
24
|
+
const options = { level };
|
|
25
|
+
if (node.hasAttribute("kui-branch")) options.branch = true;
|
|
26
|
+
if (node.hasAttribute("kui-disabled")) options.disabled = true;
|
|
27
|
+
if (node.hasAttribute("kui-loading")) options.loading = true;
|
|
28
|
+
const label = node.getAttribute("kui-label");
|
|
29
|
+
if (label !== null) options.label = label;
|
|
30
|
+
return options;
|
|
31
|
+
});
|
|
32
|
+
items.set(node, item);
|
|
33
|
+
}
|
|
34
|
+
return item;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `<kui-tree>` around `kui-part="root"` and its nodes: each an `item` (`kui-value`, and
|
|
38
|
+
* `kui-branch`, `kui-disabled`, `kui-loading`, `kui-label` as it needs), nested as the page
|
|
39
|
+
* nests them, holding an `item-row` with an `item-indicator` and an `item-text`, and, for a
|
|
40
|
+
* branch, a `group` of its children, in the page while the branch is open (`kui-keep-mounted`
|
|
41
|
+
* keeps it). A node's depth is read from the nodes around it. `expanded-value`,
|
|
42
|
+
* `default-expanded-value`, `selected-value` and `default-selected-value` (with commas
|
|
43
|
+
* between), `selection-mode`, `expand-on-click`; it tells `expanded-change` and
|
|
44
|
+
* `selected-change`.
|
|
45
|
+
*/
|
|
46
|
+
const tag = defineElement({
|
|
47
|
+
tag: "kui-tree",
|
|
48
|
+
props: {
|
|
49
|
+
"expanded-value": "string",
|
|
50
|
+
"default-expanded-value": "string",
|
|
51
|
+
"selected-value": "string",
|
|
52
|
+
"default-selected-value": "string",
|
|
53
|
+
"selection-mode": "string",
|
|
54
|
+
"expand-on-click": "boolean"
|
|
55
|
+
},
|
|
56
|
+
create: (props) => createTree(computed(() => {
|
|
57
|
+
const own = props.get();
|
|
58
|
+
return {
|
|
59
|
+
...own,
|
|
60
|
+
expandedValue: list(own.expandedValue),
|
|
61
|
+
defaultExpandedValue: list(own.defaultExpandedValue),
|
|
62
|
+
selectedValue: list(own.selectedValue),
|
|
63
|
+
defaultSelectedValue: list(own.defaultSelectedValue)
|
|
64
|
+
};
|
|
65
|
+
})),
|
|
66
|
+
changes: {
|
|
67
|
+
onExpandedChange: {
|
|
68
|
+
event: "expanded-change",
|
|
69
|
+
prop: "expandedValue"
|
|
70
|
+
},
|
|
71
|
+
onSelectedChange: {
|
|
72
|
+
event: "selected-change",
|
|
73
|
+
prop: "selectedValue"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
parts: {
|
|
77
|
+
root: (controller) => controller.root,
|
|
78
|
+
item(controller, element) {
|
|
79
|
+
const item = itemOf(controller, element);
|
|
80
|
+
return item && {
|
|
81
|
+
part: item.root,
|
|
82
|
+
mount: () => item.mount()
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
"item-row": (controller, element) => itemOf(controller, element)?.row,
|
|
86
|
+
"item-indicator": (controller, element) => itemOf(controller, element)?.indicator,
|
|
87
|
+
"item-text": (controller, element) => itemOf(controller, element)?.text,
|
|
88
|
+
group(controller, element) {
|
|
89
|
+
const item = itemOf(controller, element);
|
|
90
|
+
return item && {
|
|
91
|
+
part: item.group,
|
|
92
|
+
mounted: item.mounted
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
export { tag };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=tree.js.map
|
package/src/tree.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","names":[],"sources":["../../../../packages/web/src/tree.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createTree } from \"@kirana-ui/core/tree\"\nimport type { Tree, TreeItem, TreeItemOptions, TreeProps } from \"@kirana-ui/core/tree\"\n\nimport { list, ownValue } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n// A node's parts share the node: made once for its element, when the first of them is met.\nconst items = new WeakMap<HTMLElement, TreeItem>()\n\n/** How deep a node is, from 1: the nodes around it in the page, up to the tree's root. */\nfunction levelOf(node: HTMLElement): number {\n let level = 1\n for (let up = node.parentElement; up; up = up.parentElement) {\n const name = up.getAttribute(\"kui-part\")\n if (name === \"root\") break\n if (name === \"item\") level++\n }\n return level\n}\n\nfunction itemOf(controller: Tree<string>, element: HTMLElement): TreeItem | undefined {\n const node = partAround(element, \"item\")\n if (!node) return undefined\n let item = items.get(node)\n if (!item) {\n // Known from how the nodes are nested, which does not change for an element.\n const level = levelOf(node)\n item = controller.item(node.getAttribute(\"kui-value\") ?? ownValue(node), () => {\n const options: TreeItemOptions = { level }\n if (node.hasAttribute(\"kui-branch\")) options.branch = true\n if (node.hasAttribute(\"kui-disabled\")) options.disabled = true\n if (node.hasAttribute(\"kui-loading\")) options.loading = true\n const label = node.getAttribute(\"kui-label\")\n if (label !== null) options.label = label\n return options\n })\n items.set(node, item)\n }\n return item\n}\n\ntype Props = Omit<\n TreeProps<string>,\n \"expandedValue\" | \"defaultExpandedValue\" | \"selectedValue\" | \"defaultSelectedValue\"\n> & {\n expandedValue?: string | readonly string[]\n defaultExpandedValue?: string | readonly string[]\n selectedValue?: string | readonly string[]\n defaultSelectedValue?: string | readonly string[]\n}\n\n/**\n * `<kui-tree>` around `kui-part=\"root\"` and its nodes: each an `item` (`kui-value`, and\n * `kui-branch`, `kui-disabled`, `kui-loading`, `kui-label` as it needs), nested as the page\n * nests them, holding an `item-row` with an `item-indicator` and an `item-text`, and, for a\n * branch, a `group` of its children, in the page while the branch is open (`kui-keep-mounted`\n * keeps it). A node's depth is read from the nodes around it. `expanded-value`,\n * `default-expanded-value`, `selected-value` and `default-selected-value` (with commas\n * between), `selection-mode`, `expand-on-click`; it tells `expanded-change` and\n * `selected-change`.\n */\nexport const tag = defineElement<Props & { id: string }, Tree<string>>({\n tag: \"kui-tree\",\n props: {\n \"expanded-value\": \"string\",\n \"default-expanded-value\": \"string\",\n \"selected-value\": \"string\",\n \"default-selected-value\": \"string\",\n \"selection-mode\": \"string\",\n \"expand-on-click\": \"boolean\",\n },\n create: (props) =>\n createTree<string>(\n computed(() => {\n const own = props.get()\n return {\n ...own,\n expandedValue: list(own.expandedValue),\n defaultExpandedValue: list(own.defaultExpandedValue),\n selectedValue: list(own.selectedValue),\n defaultSelectedValue: list(own.defaultSelectedValue),\n }\n })\n ),\n changes: {\n onExpandedChange: { event: \"expanded-change\", prop: \"expandedValue\" },\n onSelectedChange: { event: \"selected-change\", prop: \"selectedValue\" },\n },\n parts: {\n root: (controller) => controller.root,\n item(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.root, mount: () => item.mount() }\n },\n \"item-row\": (controller, element) => itemOf(controller, element)?.row,\n \"item-indicator\": (controller, element) => itemOf(controller, element)?.indicator,\n \"item-text\": (controller, element) => itemOf(controller, element)?.text,\n group(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.group, mounted: item.mounted }\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-tree\": ElementOf<\n typeof tag,\n {\n \"expanded-change\": [\"onExpandedChange\", \"expandedValue\"]\n \"selected-change\": [\"onSelectedChange\", \"selectedValue\"]\n }\n >\n }\n}\n"],"mappings":";;;;;AASA,MAAM,wBAAQ,IAAI,QAA+B;;AAGjD,SAAS,QAAQ,MAA2B;CAC1C,IAAI,QAAQ;CACZ,KAAK,IAAI,KAAK,KAAK,eAAe,IAAI,KAAK,GAAG,eAAe;EAC3D,MAAM,OAAO,GAAG,aAAa,UAAU;EACvC,IAAI,SAAS,QAAQ;EACrB,IAAI,SAAS,QAAQ;CACvB;CACA,OAAO;AACT;AAEA,SAAS,OAAO,YAA0B,SAA4C;CACpF,MAAM,OAAO,WAAW,SAAS,MAAM;CACvC,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,IAAI,OAAO,MAAM,IAAI,IAAI;CACzB,IAAI,CAAC,MAAM;EAET,MAAM,QAAQ,QAAQ,IAAI;EAC1B,OAAO,WAAW,KAAK,KAAK,aAAa,WAAW,KAAK,SAAS,IAAI,SAAS;GAC7E,MAAM,UAA2B,EAAE,MAAM;GACzC,IAAI,KAAK,aAAa,YAAY,GAAG,QAAQ,SAAS;GACtD,IAAI,KAAK,aAAa,cAAc,GAAG,QAAQ,WAAW;GAC1D,IAAI,KAAK,aAAa,aAAa,GAAG,QAAQ,UAAU;GACxD,MAAM,QAAQ,KAAK,aAAa,WAAW;GAC3C,IAAI,UAAU,MAAM,QAAQ,QAAQ;GACpC,OAAO;EACT,CAAC;EACD,MAAM,IAAI,MAAM,IAAI;CACtB;CACA,OAAO;AACT;;;;;;;;;;;AAsBA,MAAa,MAAM,cAAoD;CACrE,KAAK;CACL,OAAO;EACL,kBAAkB;EAClB,0BAA0B;EAC1B,kBAAkB;EAClB,0BAA0B;EAC1B,kBAAkB;EAClB,mBAAmB;CACrB;CACA,SAAS,UACP,WACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GACL,GAAG;GACH,eAAe,KAAK,IAAI,aAAa;GACrC,sBAAsB,KAAK,IAAI,oBAAoB;GACnD,eAAe,KAAK,IAAI,aAAa;GACrC,sBAAsB,KAAK,IAAI,oBAAoB;EACrD;CACF,CAAC,CACH;CACF,SAAS;EACP,kBAAkB;GAAE,OAAO;GAAmB,MAAM;EAAgB;EACpE,kBAAkB;GAAE,OAAO;GAAmB,MAAM;EAAgB;CACtE;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAM,aAAa,KAAK,MAAM;GAAE;EAC9D;EACA,aAAa,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAClE,mBAAmB,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EACxE,cAAc,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EACnE,MAAM,YAAY,SAAS;GACzB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAO,SAAS,KAAK;GAAQ;EAC3D;CACF;AACF,CAAC"}
|