@kirana-ui/web 0.3.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 +1378 -97
- package/package.json +44 -3
- package/skills/kirana-ui-primitives/SKILL.md +24 -4
- package/src/accordion.d.ts +1 -1
- package/src/accordion.js +2 -1
- package/src/accordion.js.map +1 -1
- package/src/alert-dialog.js +3 -2
- package/src/alert-dialog.js.map +1 -1
- package/src/around.d.ts +7 -0
- package/src/around.js +13 -2
- package/src/around.js.map +1 -1
- package/src/autocomplete.d.ts +1 -1
- package/src/avatar.js +2 -2
- 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 +1 -1
- package/src/calendar.js +2 -1
- 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/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 +11 -4
- package/src/combobox.js +37 -12
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +2 -2
- package/src/command.js +4 -4
- package/src/command.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 +7 -4
- package/src/date-picker.js +37 -7
- package/src/date-picker.js.map +1 -1
- package/src/dates.d.ts +6 -3
- package/src/dates.js +8 -5
- package/src/dates.js.map +1 -1
- package/src/dialog.d.ts +3 -2
- package/src/dialog.js +8 -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/index.d.ts +27 -9
- package/src/index.js +10 -0
- package/src/menu.d.ts +2 -2
- 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 +2 -2
- package/src/navigation-menu.js +10 -6
- package/src/navigation-menu.js.map +1 -1
- package/src/otp.d.ts +4 -2
- package/src/otp.js +23 -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/rating.d.ts +18 -0
- package/src/rating.js +54 -0
- package/src/rating.js.map +1 -0
- package/src/runtime.d.ts +2 -2
- package/src/runtime.js +1 -1
- package/src/runtime.js.map +1 -1
- package/src/select.d.ts +10 -3
- package/src/select.js +32 -10
- package/src/select.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/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/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","names":[],"sources":["../../../../packages/web/src/menu.ts"],"sourcesContent":["import type { ReadonlySignal } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu,\n MenuAround,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\n\nimport { once, positioner, valueOf } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, hostAround, partAround, partProps } from \"./runtime.ts\"\nimport type { Drawn, ElementOf, Told } from \"./runtime.ts\"\n\nconst MENUS = [\"kui-menu\", \"kui-context-menu\"]\n\n
|
|
1
|
+
{"version":3,"file":"menu.js","names":[],"sources":["../../../../packages/web/src/menu.ts"],"sourcesContent":["import type { ReadonlySignal } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu,\n MenuAround,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\n\nimport { once, positioner, valueOf } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, hostAround, partAround, partProps } from \"./runtime.ts\"\nimport type { Drawn, ElementOf, Told } from \"./runtime.ts\"\n\nconst MENUS = [\"kui-menu\", \"kui-context-menu\"]\n\n/**\n * An item's own options: `kui-disabled`, `kui-label`, `kui-close-on-select=\"false\"`\n * (`kui-close-on-click`, its old name, still read).\n */\nconst options = (element: HTMLElement) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n ...(element.hasAttribute(\"kui-close-on-select\")\n ? { closeOnSelect: element.getAttribute(\"kui-close-on-select\") !== \"false\" }\n : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n})\n\ninterface Made<Controller> {\n controller: Controller\n mount(): () => void\n}\nconst groups = new WeakMap<HTMLElement, MenuGroup>()\nconst boxes = new WeakMap<HTMLElement, Made<MenuCheckboxItem>>()\nconst radios = new WeakMap<HTMLElement, Made<MenuRadioGroup<string>>>()\nlet made = 0\n\nconst ITEM = {\n disabled: \"boolean\",\n label: \"string\",\n \"close-on-select\": \"boolean\",\n \"close-on-click\": \"boolean\",\n} as const\n\nconst boxOf = (menu: Menu, element: HTMLElement | null) =>\n once(boxes, element, (item) => {\n const { props, mount } = partProps<MenuCheckboxItemProps>(\n item,\n { ...ITEM, checked: \"boolean\", \"default-checked\": \"boolean\" },\n { onCheckedChange: { event: \"checked-change\", prop: \"checked\" } }\n )\n const controller = menu.checkboxItem(props)\n return { controller, mount: both(mount, () => controller.mount()) }\n })\n\nconst radioOf = (menu: Menu, element: HTMLElement | null) =>\n once(radios, element, (group) => {\n const { props, mount } = partProps<MenuRadioGroupProps<string>>(\n group,\n { value: \"string\", \"default-value\": \"string\", disabled: \"boolean\" },\n { onValueChange: { event: \"value-change\", prop: \"value\" } }\n )\n const controller = menu.radioGroup<string>(props)\n return { controller, mount: both(mount, () => controller.mount()) }\n })\n\nconst both = (one: () => () => void, other: () => () => void) => () => {\n const stops = [one(), other()]\n return () => stops.forEach((stop) => stop())\n}\n\ntype Parts = Record<\n string,\n (controller: Menu, element: HTMLElement) => Drawn[\"part\"] | Drawn | undefined\n>\n\n/** A menu's parts but for its trigger, which a context menu has as an area. */\nconst PARTS: Parts = {\n positioner,\n popup: (controller) => controller.popup,\n arrow: (controller) => controller.arrow,\n separator: (controller) => controller.separator,\n item: (controller, element) => controller.item(options(element)),\n group: (controller, element) =>\n once(groups, element, (group) =>\n controller.group(group.getAttribute(\"kui-id\") ?? `kui-menu-group-${++made}`)\n )?.root,\n // With no group around it, it is plain text.\n \"group-label\": (controller, element) =>\n groups.get(partAround(element, \"group\")!)?.label ?? controller.label,\n \"checkbox-item\"(controller, element) {\n const box = boxOf(controller, element)!\n return { part: box.controller.part, mount: box.mount }\n },\n \"checkbox-item-indicator\"(controller, element) {\n const box = boxOf(controller, partAround(element, \"checkbox-item\"))\n // In the page while checked, and through its exit.\n const mark = box?.controller.indicator\n return mark && { part: mark, mounted: mark.mounted, mount: mark.mount }\n },\n \"radio-group\"(controller, element) {\n const group = radioOf(controller, element)!\n return { part: group.controller.root, mount: group.mount }\n },\n \"radio-item\"(controller, element) {\n const group = radioOf(controller, partAround(element, \"radio-group\"))\n return group?.controller.item(valueOf(element), options(element))\n },\n \"radio-item-indicator\"(controller, element) {\n const group = radioOf(controller, partAround(element, \"radio-group\"))?.controller\n const value = valueOf(partAround(element, \"radio-item\"))\n // In the page while chosen, and through its exit.\n const mark = group?.indicator(value)\n return mark && { part: mark, mounted: mark.mounted, mount: mark.mount }\n },\n}\n\nconst PROPS = {\n open: \"boolean\",\n \"default-open\": \"boolean\",\n disabled: \"boolean\",\n \"loop-focus\": \"boolean\",\n loop: \"boolean\",\n modal: \"boolean\",\n} as const\n\nconst menu = (\n tag: string,\n around: (host: HTMLElement) => MenuAround,\n trigger: (controller: Menu) => Drawn[\"part\"]\n) =>\n defineElement<MenuProps, Menu>({\n tag,\n props: PROPS,\n create: (props: ReadonlySignal<MenuProps>, host) => createMenu(props, around(host)),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: { ...PARTS, trigger },\n })\n\n/**\n * `<kui-menu>` around a `kui-part=\"trigger\"` and a `portal` with a `positioner` (its\n * `kui-side` and the like) around the `popup`, which holds its `item`s (`kui-disabled`,\n * `kui-label`, `kui-close-on-select=\"false\"`), `separator`s, `group`s with a `group-label`,\n * `checkbox-item`s (`kui-checked`, `kui-default-checked`; it tells `checked-change`) with a\n * `checkbox-item-indicator`, and a `radio-group` (`kui-value`, `kui-default-value`; it tells\n * `value-change`) of `radio-item`s (`kui-value`) with a `radio-item-indicator`. A `<kui-menu>`\n * inside a menu is its submenu, its trigger an item of the menu; inside a `<kui-menubar>`, one\n * of the bar's. `open`, `default-open`, `disabled`, `loop-focus` (`loop` is its older name), `modal`; it tells `open-change`.\n */\nexport const tag = menu(\n \"kui-menu\",\n (host) => {\n // The nearest: a menu written inside a bar's menu is that menu's, not the bar's.\n const around = hostAround(host, [...MENUS, \"kui-menubar\"])\n return around?.tag === \"kui-menubar\"\n ? { menubar: around.controller as NonNullable<MenuAround[\"menubar\"]> }\n : around\n ? { parent: around.controller as Menu }\n : {}\n },\n (controller) => controller.trigger\n)\n\nexport { menu as defineMenu }\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-menu\": ElementOf<\n typeof tag,\n { \"open-change\": [\"onOpenChange\", \"open\"] },\n { \"checked-change\": Told<\"checked\", boolean>; \"value-change\": Told<\"value\", string> }\n > &\n Placed\n }\n}\n"],"mappings":";;;;AAkBA,MAAM,QAAQ,CAAC,YAAY,kBAAkB;;;;;AAM7C,MAAM,WAAW,mBAAgC;CAC/C,GAAI,QAAQ,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACjE,GAAI,QAAQ,aAAa,WAAW,IAAI,EAAE,OAAO,QAAQ,aAAa,WAAW,EAAG,IAAI,CAAC;CACzF,GAAI,QAAQ,aAAa,qBAAqB,IAC1C,EAAE,eAAe,QAAQ,aAAa,qBAAqB,MAAM,QAAQ,IACzE,CAAC;CACL,GAAI,QAAQ,aAAa,oBAAoB,IACzC,EAAE,cAAc,QAAQ,aAAa,oBAAoB,MAAM,QAAQ,IACvE,CAAC;AACP;AAMA,MAAM,yBAAS,IAAI,QAAgC;AACnD,MAAM,wBAAQ,IAAI,QAA6C;AAC/D,MAAM,yBAAS,IAAI,QAAmD;AACtE,IAAI,OAAO;AAEX,MAAM,OAAO;CACX,UAAU;CACV,OAAO;CACP,mBAAmB;CACnB,kBAAkB;AACpB;AAEA,MAAM,SAAS,MAAY,YACzB,KAAK,OAAO,UAAU,SAAS;CAC7B,MAAM,EAAE,OAAO,UAAU,UACvB,MACA;EAAE,GAAG;EAAM,SAAS;EAAW,mBAAmB;CAAU,GAC5D,EAAE,iBAAiB;E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";
|
|
|
2
2
|
import { MenubarProps } from "@kirana-ui/core/menubar";
|
|
3
3
|
/**
|
|
4
4
|
* `<kui-menubar>` around `kui-part="root"` and its `<kui-menu>`s, which work as one: the
|
|
5
|
-
* arrows move between them, and with one open the pointer opens the next. `loop
|
|
6
|
-
* `orientation`.
|
|
5
|
+
* arrows move between them, and with one open the pointer opens the next. `loop-focus` (`loop` is its older name), `disabled`,
|
|
6
|
+
* `orientation`, `modal`.
|
|
7
7
|
*/
|
|
8
8
|
export declare const tag: Tag<{
|
|
9
9
|
id: string;
|
package/src/menubar.js
CHANGED
|
@@ -3,15 +3,17 @@ import { createMenubar } from "@kirana-ui/core/menubar";
|
|
|
3
3
|
// src/menubar.ts
|
|
4
4
|
/**
|
|
5
5
|
* `<kui-menubar>` around `kui-part="root"` and its `<kui-menu>`s, which work as one: the
|
|
6
|
-
* arrows move between them, and with one open the pointer opens the next. `loop
|
|
7
|
-
* `orientation`.
|
|
6
|
+
* arrows move between them, and with one open the pointer opens the next. `loop-focus` (`loop` is its older name), `disabled`,
|
|
7
|
+
* `orientation`, `modal`.
|
|
8
8
|
*/
|
|
9
9
|
const tag = defineElement({
|
|
10
10
|
tag: "kui-menubar",
|
|
11
11
|
props: {
|
|
12
|
+
"loop-focus": "boolean",
|
|
12
13
|
loop: "boolean",
|
|
13
14
|
disabled: "boolean",
|
|
14
|
-
orientation: "string"
|
|
15
|
+
orientation: "string",
|
|
16
|
+
modal: "boolean"
|
|
15
17
|
},
|
|
16
18
|
create: (props) => createMenubar(props),
|
|
17
19
|
changes: {},
|
package/src/menubar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menubar.js","names":[],"sources":["../../../../packages/web/src/menubar.ts"],"sourcesContent":["import { createMenubar } from \"@kirana-ui/core/menubar\"\nimport type { MenubarProps } from \"@kirana-ui/core/menubar\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-menubar>` around `kui-part=\"root\"` and its `<kui-menu>`s, which work as one: the\n * arrows move between them, and with one open the pointer opens the next. `loop
|
|
1
|
+
{"version":3,"file":"menubar.js","names":[],"sources":["../../../../packages/web/src/menubar.ts"],"sourcesContent":["import { createMenubar } from \"@kirana-ui/core/menubar\"\nimport type { MenubarProps } from \"@kirana-ui/core/menubar\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-menubar>` around `kui-part=\"root\"` and its `<kui-menu>`s, which work as one: the\n * arrows move between them, and with one open the pointer opens the next. `loop-focus` (`loop` is its older name), `disabled`,\n * `orientation`, `modal`.\n */\nexport const tag = defineElement({\n tag: \"kui-menubar\",\n props: {\n \"loop-focus\": \"boolean\",\n loop: \"boolean\",\n disabled: \"boolean\",\n orientation: \"string\",\n modal: \"boolean\",\n },\n create: (props) => createMenubar(props),\n changes: {},\n parts: { root: (controller) => controller.root },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-menubar\": ElementOf<As<typeof tag, MenubarProps>>\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,cAAc;EACd,MAAM;EACN,UAAU;EACV,aAAa;EACb,OAAO;CACT;CACA,SAAS,UAAU,cAAc,KAAK;CACtC,SAAS,CAAC;CACV,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
|
package/src/navigation-menu.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { Placed } from "./around.js";
|
|
|
3
3
|
import { NavigationMenu, NavigationMenuProps } from "@kirana-ui/core/navigation-menu";
|
|
4
4
|
/**
|
|
5
5
|
* `<kui-navigation-menu>` around a `kui-part="root"` nav with its `list`. An `item` has a
|
|
6
|
-
* `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one
|
|
6
|
+
* `trigger` (with an `icon` if it has one; `kui-disabled`) and a `content`, which is drawn in the menu's one
|
|
7
7
|
* `viewport` while its item is open; its `kui-value` tells it from the others, and an item
|
|
8
8
|
* that is given none makes its own. A `link` is a link (`kui-active`,
|
|
9
|
-
* `kui-close-on-
|
|
9
|
+
* `kui-close-on-select="false"`). The viewport is in a `portal` with a `positioner` around
|
|
10
10
|
* the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,
|
|
11
11
|
* `delay`, `close-delay`, `orientation`; it tells `value-change`.
|
|
12
12
|
*/
|
package/src/navigation-menu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { once, ownValue, positioner } from "./around.js";
|
|
2
|
-
import { defineElement, partAround } from "./runtime.js";
|
|
1
|
+
import { once, ownDisabled, ownValue, positioner } from "./around.js";
|
|
2
|
+
import { controllerAround, defineElement, partAround } from "./runtime.js";
|
|
3
3
|
import { computed } from "@kirana-ui/core";
|
|
4
4
|
import { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
|
|
5
5
|
// src/navigation-menu.ts
|
|
@@ -8,10 +8,10 @@ const items = /* @__PURE__ */ new WeakMap();
|
|
|
8
8
|
const itemOf = (controller, element) => once(items, partAround(element, "item"), (item) => controller.item(item.getAttribute("kui-value") ?? ownValue(item)));
|
|
9
9
|
/**
|
|
10
10
|
* `<kui-navigation-menu>` around a `kui-part="root"` nav with its `list`. An `item` has a
|
|
11
|
-
* `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one
|
|
11
|
+
* `trigger` (with an `icon` if it has one; `kui-disabled`) and a `content`, which is drawn in the menu's one
|
|
12
12
|
* `viewport` while its item is open; its `kui-value` tells it from the others, and an item
|
|
13
13
|
* that is given none makes its own. A `link` is a link (`kui-active`,
|
|
14
|
-
* `kui-close-on-
|
|
14
|
+
* `kui-close-on-select="false"`). The viewport is in a `portal` with a `positioner` around
|
|
15
15
|
* the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,
|
|
16
16
|
* `delay`, `close-delay`, `orientation`; it tells `value-change`.
|
|
17
17
|
*/
|
|
@@ -24,7 +24,7 @@ const tag = defineElement({
|
|
|
24
24
|
"close-delay": "number",
|
|
25
25
|
orientation: "string"
|
|
26
26
|
},
|
|
27
|
-
create: (props) => createNavigationMenu(props),
|
|
27
|
+
create: (props, host) => createNavigationMenu(props, { parent: controllerAround(host, "kui-navigation-menu") }),
|
|
28
28
|
changes: { onValueChange: {
|
|
29
29
|
event: "value-change",
|
|
30
30
|
prop: "value"
|
|
@@ -42,7 +42,10 @@ const tag = defineElement({
|
|
|
42
42
|
mount: () => item.mount()
|
|
43
43
|
};
|
|
44
44
|
},
|
|
45
|
-
trigger
|
|
45
|
+
trigger(controller, element) {
|
|
46
|
+
const item = itemOf(controller, element);
|
|
47
|
+
return item && ownDisabled(element, item.triggerPart);
|
|
48
|
+
},
|
|
46
49
|
icon: (controller, element) => itemOf(controller, element)?.icon,
|
|
47
50
|
content(controller, element) {
|
|
48
51
|
const item = itemOf(controller, element);
|
|
@@ -54,6 +57,7 @@ const tag = defineElement({
|
|
|
54
57
|
},
|
|
55
58
|
link: (controller, element) => controller.link(() => ({
|
|
56
59
|
...element.hasAttribute("kui-active") ? { active: true } : {},
|
|
60
|
+
...element.hasAttribute("kui-close-on-select") ? { closeOnSelect: element.getAttribute("kui-close-on-select") !== "false" } : {},
|
|
57
61
|
...element.hasAttribute("kui-close-on-click") ? { closeOnClick: element.getAttribute("kui-close-on-click") !== "false" } : {}
|
|
58
62
|
})),
|
|
59
63
|
positioner,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/web/src/navigation-menu.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\n\nimport { once, ownValue, positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst NOTHING = computed(() => ({}))\nconst items = new WeakMap<HTMLElement, NavigationMenuItem>()\nconst itemOf = (controller: NavigationMenu<string>, element: HTMLElement) =>\n once(items, partAround(element, \"item\"), (item) =>\n controller.item(item.getAttribute(\"kui-value\") ?? ownValue(item))\n )\n\n/**\n * `<kui-navigation-menu>` around a `kui-part=\"root\"` nav with its `list`. An `item` has a\n * `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one\n * `viewport` while its item is open; its `kui-value` tells it from the others, and an item\n * that is given none makes its own. A `link` is a link (`kui-active`,\n * `kui-close-on-
|
|
1
|
+
{"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/web/src/navigation-menu.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\n\nimport { once, ownDisabled, ownValue, positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { controllerAround, defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst NOTHING = computed(() => ({}))\nconst items = new WeakMap<HTMLElement, NavigationMenuItem>()\nconst itemOf = (controller: NavigationMenu<string>, element: HTMLElement) =>\n once(items, partAround(element, \"item\"), (item) =>\n controller.item(item.getAttribute(\"kui-value\") ?? ownValue(item))\n )\n\n/**\n * `<kui-navigation-menu>` around a `kui-part=\"root\"` nav with its `list`. An `item` has a\n * `trigger` (with an `icon` if it has one; `kui-disabled`) and a `content`, which is drawn in the menu's one\n * `viewport` while its item is open; its `kui-value` tells it from the others, and an item\n * that is given none makes its own. A `link` is a link (`kui-active`,\n * `kui-close-on-select=\"false\"`). The viewport is in a `portal` with a `positioner` around\n * the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,\n * `delay`, `close-delay`, `orientation`; it tells `value-change`.\n */\nexport const tag = defineElement<NavigationMenuProps<string>, NavigationMenu<string>>({\n tag: \"kui-navigation-menu\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n delay: \"number\",\n \"close-delay\": \"number\",\n orientation: \"string\",\n },\n // Inside another's content, it is nested.\n create: (props, host) =>\n createNavigationMenu<string>(props, {\n parent: controllerAround<NavigationMenu>(host, \"kui-navigation-menu\"),\n }),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n list: (controller) => controller.list,\n // The item's own element takes nothing: it is where the item is in the page.\n item(controller, element) {\n const item = itemOf(controller, element)!\n return { part: { props: NOTHING, attach: () => () => {} }, mount: () => item.mount() }\n },\n trigger(controller, element) {\n const item = itemOf(controller, element)\n return item && ownDisabled(element, item.triggerPart)\n },\n icon: (controller, element) => itemOf(controller, element)?.icon,\n content(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.content, mounted: item.mounted, into: controller.viewportElement }\n },\n link: (controller, element) =>\n controller.link(() => ({\n ...(element.hasAttribute(\"kui-active\") ? { active: true } : {}),\n ...(element.hasAttribute(\"kui-close-on-select\")\n ? { closeOnSelect: element.getAttribute(\"kui-close-on-select\") !== \"false\" }\n : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n })),\n positioner,\n popup: (controller) => controller.popup,\n viewport: (controller) => controller.viewport,\n arrow: (controller) => controller.arrow,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-navigation-menu\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }> &\n Placed\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,UAAU,gBAAgB,CAAC,EAAE;AACnC,MAAM,wBAAQ,IAAI,QAAyC;AAC3D,MAAM,UAAU,YAAoC,YAClD,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Q,eAAe,WAAW;EAClC,WAAW,eAAe,WAAW;EACrC,QAAQ,eAAe,WAAW;EAClC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;CACtF;AACF,CAAC"}
|
package/src/otp.d.ts
CHANGED
|
@@ -4,14 +4,16 @@ import { Otp, OtpProps } from "@kirana-ui/core/otp";
|
|
|
4
4
|
* `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
|
|
5
5
|
* each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
|
|
6
6
|
* the page while the next character goes there. Slots may be in `group`s with a `separator`
|
|
7
|
-
* between. `length`, `value`, `default-value`, `
|
|
8
|
-
* `value-change` and `complete
|
|
7
|
+
* between. `length`, `value`, `default-value`, `validation-type` (`mode`, its old name), `pattern`,
|
|
8
|
+
* `disabled`, `read-only`, `required`, `name`, `form`; it tells `value-change` and `value-complete` (and `complete`, its
|
|
9
|
+
* old name).
|
|
9
10
|
*/
|
|
10
11
|
export declare const tag: Tag<OtpProps, Otp>;
|
|
11
12
|
declare global {
|
|
12
13
|
interface HTMLElementTagNameMap {
|
|
13
14
|
"kui-otp": ElementOf<typeof tag, {
|
|
14
15
|
"value-change": ["onValueChange", "value"];
|
|
16
|
+
"value-complete": ["onValueComplete", "value"];
|
|
15
17
|
complete: ["onComplete", "value"];
|
|
16
18
|
}>;
|
|
17
19
|
}
|
package/src/otp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { fieldAround } from "./around.js";
|
|
1
2
|
import { defineElement, partAround } from "./runtime.js";
|
|
2
|
-
import { effect } from "@kirana-ui/core";
|
|
3
|
+
import { computed, effect } from "@kirana-ui/core";
|
|
3
4
|
import { createOtp } from "@kirana-ui/core/otp";
|
|
4
5
|
// src/otp.ts
|
|
5
6
|
const indexOf = (element) => Number(element?.getAttribute("kui-index") ?? 0);
|
|
@@ -7,8 +8,9 @@ const indexOf = (element) => Number(element?.getAttribute("kui-index") ?? 0);
|
|
|
7
8
|
* `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
|
|
8
9
|
* each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
|
|
9
10
|
* the page while the next character goes there. Slots may be in `group`s with a `separator`
|
|
10
|
-
* between. `length`, `value`, `default-value`, `
|
|
11
|
-
* `value-change` and `complete
|
|
11
|
+
* between. `length`, `value`, `default-value`, `validation-type` (`mode`, its old name), `pattern`,
|
|
12
|
+
* `disabled`, `read-only`, `required`, `name`, `form`; it tells `value-change` and `value-complete` (and `complete`, its
|
|
13
|
+
* old name).
|
|
12
14
|
*/
|
|
13
15
|
const tag = defineElement({
|
|
14
16
|
tag: "kui-otp",
|
|
@@ -16,18 +18,35 @@ const tag = defineElement({
|
|
|
16
18
|
length: "number",
|
|
17
19
|
value: "string",
|
|
18
20
|
"default-value": "string",
|
|
21
|
+
"validation-type": "string",
|
|
19
22
|
mode: "string",
|
|
20
23
|
pattern: "string",
|
|
21
24
|
disabled: "boolean",
|
|
25
|
+
"read-only": "boolean",
|
|
26
|
+
required: "boolean",
|
|
22
27
|
name: "string",
|
|
23
28
|
form: "string"
|
|
24
29
|
},
|
|
25
|
-
create: (props) => createOtp(
|
|
30
|
+
create: (props, host) => createOtp(computed(() => {
|
|
31
|
+
const own = props.get();
|
|
32
|
+
return {
|
|
33
|
+
...own,
|
|
34
|
+
onValueComplete(value, details) {
|
|
35
|
+
own.onValueComplete?.(value, details);
|
|
36
|
+
own.onComplete?.(value);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}), { field: fieldAround(host) }),
|
|
26
40
|
changes: {
|
|
27
41
|
onValueChange: {
|
|
28
42
|
event: "value-change",
|
|
29
43
|
prop: "value"
|
|
30
44
|
},
|
|
45
|
+
onValueComplete: {
|
|
46
|
+
event: "value-complete",
|
|
47
|
+
prop: "value",
|
|
48
|
+
hold: false
|
|
49
|
+
},
|
|
31
50
|
onComplete: {
|
|
32
51
|
event: "complete",
|
|
33
52
|
prop: "value",
|
package/src/otp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\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`, `pattern
|
|
1
|
+
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { computed, effect } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { fieldAround } from \"./around.ts\"\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`, `validation-type` (`mode`, its old name), `pattern`,\n * `disabled`, `read-only`, `required`, `name`, `form`; it tells `value-change` and `value-complete` (and `complete`, its\n * old name).\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n \"validation-type\": \"string\",\n mode: \"string\",\n pattern: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n // Both events are told: a listener cannot be told from none.\n create: (props, host) =>\n createOtp(\n computed(() => {\n const own = props.get()\n return {\n ...own,\n onValueComplete(value: string, details: ChangeDetails) {\n own.onValueComplete?.(value, details)\n own.onComplete?.(value)\n },\n }\n }),\n { field: fieldAround(host) }\n ),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValueComplete: { event: \"value-complete\", prop: \"value\", hold: false },\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 {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"value-complete\": [\"onValueComplete\", \"value\"]\n complete: [\"onComplete\", \"value\"]\n }\n >\n }\n}\n"],"mappings":";;;;;AASA,MAAM,WAAW,YAAgC,OAAO,SAAS,aAAa,WAAW,KAAK,CAAC;;;;;;;;;AAU/F,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,QAAQ;EACR,OAAO;EACP,iBAAiB;EACjB,mBAAmB;EACnB,MAAM;EACN,SAAS;EACT,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CAEA,SAAS,OAAO,SACd,UACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GACL,GAAG;GACH,gBAAgB,OAAe,SAAwB;IACrD,IAAI,kBAAkB,OAAO,OAAO;IACpC,IAAI,aAAa,KAAK;GACxB;EACF;CACF,CAAC,GACD,EAAE,OAAO,YAAY,IAAI,EAAE,CAC7B;CACF,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,iBAAiB;GAAE,OAAO;GAAkB,MAAM;GAAS,MAAM;EAAM;EACvE,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,20 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { PasswordInput, PasswordInputProps } from "@kirana-ui/core/password-input";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-password-input>` around `kui-part="root"`, an `input`, and a `toggle` button that shows
|
|
5
|
+
* the password and hides it again, with an `indicator` inside that says which it is. Inside a
|
|
6
|
+
* `<kui-field>` the input is the field's control. `visible`, `default-visible`, `disabled`; it
|
|
7
|
+
* tells `visible-change` and `value-change`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const tag: Tag<PasswordInputProps & {
|
|
10
|
+
id: string;
|
|
11
|
+
}, PasswordInput>;
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
"kui-password-input": ElementOf<typeof tag, {
|
|
15
|
+
"visible-change": ["onVisibleChange", "visible"];
|
|
16
|
+
"value-change": ["onValueChange", "value"];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=password-input.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { fieldAround } from "./around.js";
|
|
2
|
+
import { defineElement } from "./runtime.js";
|
|
3
|
+
import { createPasswordInput } from "@kirana-ui/core/password-input";
|
|
4
|
+
// src/password-input.ts
|
|
5
|
+
/**
|
|
6
|
+
* `<kui-password-input>` around `kui-part="root"`, an `input`, and a `toggle` button that shows
|
|
7
|
+
* the password and hides it again, with an `indicator` inside that says which it is. Inside a
|
|
8
|
+
* `<kui-field>` the input is the field's control. `visible`, `default-visible`, `disabled`; it
|
|
9
|
+
* tells `visible-change` and `value-change`.
|
|
10
|
+
*/
|
|
11
|
+
const tag = defineElement({
|
|
12
|
+
tag: "kui-password-input",
|
|
13
|
+
props: {
|
|
14
|
+
visible: "boolean",
|
|
15
|
+
"default-visible": "boolean",
|
|
16
|
+
disabled: "boolean"
|
|
17
|
+
},
|
|
18
|
+
create: (props, host) => createPasswordInput(props, { field: fieldAround(host) }),
|
|
19
|
+
changes: {
|
|
20
|
+
onVisibleChange: {
|
|
21
|
+
event: "visible-change",
|
|
22
|
+
prop: "visible"
|
|
23
|
+
},
|
|
24
|
+
onValueChange: {
|
|
25
|
+
event: "value-change",
|
|
26
|
+
prop: "value",
|
|
27
|
+
hold: false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
parts: {
|
|
31
|
+
root: (controller) => controller.root,
|
|
32
|
+
input: (controller) => controller.input,
|
|
33
|
+
toggle: (controller) => controller.toggle,
|
|
34
|
+
indicator: (controller) => controller.indicator
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export { tag };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=password-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-input.js","names":[],"sources":["../../../../packages/web/src/password-input.ts"],"sourcesContent":["import { createPasswordInput } from \"@kirana-ui/core/password-input\"\nimport type { PasswordInput, PasswordInputProps } from \"@kirana-ui/core/password-input\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-password-input>` around `kui-part=\"root\"`, an `input`, and a `toggle` button that shows\n * the password and hides it again, with an `indicator` inside that says which it is. Inside a\n * `<kui-field>` the input is the field's control. `visible`, `default-visible`, `disabled`; it\n * tells `visible-change` and `value-change`.\n */\nexport const tag = defineElement<PasswordInputProps & { id: string }, PasswordInput>({\n tag: \"kui-password-input\",\n props: { visible: \"boolean\", \"default-visible\": \"boolean\", disabled: \"boolean\" },\n create: (props, host) => createPasswordInput(props, { field: fieldAround(host) }),\n changes: {\n onVisibleChange: { event: \"visible-change\", prop: \"visible\" },\n onValueChange: { event: \"value-change\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n toggle: (controller) => controller.toggle,\n indicator: (controller) => controller.indicator,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-password-input\": ElementOf<\n typeof tag,\n {\n \"visible-change\": [\"onVisibleChange\", \"visible\"]\n \"value-change\": [\"onValueChange\", \"value\"]\n }\n >\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,MAAM,cAAkE;CACnF,KAAK;CACL,OAAO;EAAE,SAAS;EAAW,mBAAmB;EAAW,UAAU;CAAU;CAC/E,SAAS,OAAO,SAAS,oBAAoB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CAChF,SAAS;EACP,iBAAiB;GAAE,OAAO;GAAkB,MAAM;EAAU;EAC5D,eAAe;GAAE,OAAO;GAAgB,MAAM;GAAS,MAAM;EAAM;CACrE;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,SAAS,eAAe,WAAW;EACnC,YAAY,eAAe,WAAW;CACxC;AACF,CAAC"}
|
package/src/rating.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Rating, RatingProps } from "@kirana-ui/core/rating";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-rating>` around a `kui-part="root"` element holding a `<template kui-each="items">`
|
|
5
|
+
* with an `item` for a place (`{place}` is its number, from 1). The root draws the hidden input
|
|
6
|
+
* a form reads, as its last child. `value`, `default-value`, `count`, `allow-half`, `disabled`,
|
|
7
|
+
* `read-only`, `required`, `name`, `form`; it tells `value-change` and `hover-change`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const tag: Tag<RatingProps, Rating>;
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
"kui-rating": ElementOf<typeof tag, {
|
|
13
|
+
"value-change": ["onValueChange", "value"];
|
|
14
|
+
"hover-change": ["onHoverChange", "value"];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=rating.d.ts.map
|
package/src/rating.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { fieldAround } from "./around.js";
|
|
2
|
+
import { defineElement, entryAround } from "./runtime.js";
|
|
3
|
+
import { createRating } from "@kirana-ui/core/rating";
|
|
4
|
+
// src/rating.ts
|
|
5
|
+
/**
|
|
6
|
+
* `<kui-rating>` around a `kui-part="root"` element holding a `<template kui-each="items">`
|
|
7
|
+
* with an `item` for a place (`{place}` is its number, from 1). The root draws the hidden input
|
|
8
|
+
* a form reads, as its last child. `value`, `default-value`, `count`, `allow-half`, `disabled`,
|
|
9
|
+
* `read-only`, `required`, `name`, `form`; it tells `value-change` and `hover-change`.
|
|
10
|
+
*/
|
|
11
|
+
const tag = defineElement({
|
|
12
|
+
tag: "kui-rating",
|
|
13
|
+
props: {
|
|
14
|
+
value: "number",
|
|
15
|
+
"default-value": "number",
|
|
16
|
+
count: "number",
|
|
17
|
+
"allow-half": "boolean",
|
|
18
|
+
disabled: "boolean",
|
|
19
|
+
"read-only": "boolean",
|
|
20
|
+
required: "boolean",
|
|
21
|
+
name: "string",
|
|
22
|
+
form: "string"
|
|
23
|
+
},
|
|
24
|
+
create: (props, host) => createRating(props, { field: fieldAround(host) }),
|
|
25
|
+
changes: {
|
|
26
|
+
onValueChange: {
|
|
27
|
+
event: "value-change",
|
|
28
|
+
prop: "value"
|
|
29
|
+
},
|
|
30
|
+
onHoverChange: {
|
|
31
|
+
event: "hover-change",
|
|
32
|
+
prop: "value",
|
|
33
|
+
hold: false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
lists: { items: (controller) => ({
|
|
37
|
+
entries: controller.places,
|
|
38
|
+
key: (place) => place,
|
|
39
|
+
values: (place) => ({ place })
|
|
40
|
+
}) },
|
|
41
|
+
parts: {
|
|
42
|
+
root: (controller) => ({
|
|
43
|
+
part: controller.root,
|
|
44
|
+
inner: controller.input
|
|
45
|
+
}),
|
|
46
|
+
item(controller, element) {
|
|
47
|
+
const place = entryAround(element);
|
|
48
|
+
return place === void 0 ? void 0 : controller.item(place);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
export { tag };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=rating.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rating.js","names":[],"sources":["../../../../packages/web/src/rating.ts"],"sourcesContent":["import { createRating } from \"@kirana-ui/core/rating\"\nimport type { Rating, RatingProps } from \"@kirana-ui/core/rating\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement, entryAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-rating>` around a `kui-part=\"root\"` element holding a `<template kui-each=\"items\">`\n * with an `item` for a place (`{place}` is its number, from 1). The root draws the hidden input\n * a form reads, as its last child. `value`, `default-value`, `count`, `allow-half`, `disabled`,\n * `read-only`, `required`, `name`, `form`; it tells `value-change` and `hover-change`.\n */\nexport const tag = defineElement<RatingProps, Rating>({\n tag: \"kui-rating\",\n props: {\n value: \"number\",\n \"default-value\": \"number\",\n count: \"number\",\n \"allow-half\": \"boolean\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props, host) => createRating(props, { field: fieldAround(host) }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onHoverChange: { event: \"hover-change\", prop: \"value\", hold: false },\n },\n lists: {\n items: (controller) => ({\n entries: controller.places,\n key: (place: number) => place,\n values: (place: number) => ({ place }),\n }),\n },\n parts: {\n root: (controller) => ({ part: controller.root, inner: controller.input }),\n item(controller, element) {\n const place = entryAround<number>(element)\n return place === undefined ? undefined : controller.item(place)\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-rating\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; \"hover-change\": [\"onHoverChange\", \"value\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,MAAM,cAAmC;CACpD,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,OAAO;EACP,cAAc;EACd,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,OAAO,SAAS,aAAa,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACzE,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,eAAe;GAAE,OAAO;GAAgB,MAAM;GAAS,MAAM;EAAM;CACrE;CACA,OAAO,EACL,QAAQ,gBAAgB;EACtB,SAAS,WAAW;EACpB,MAAM,UAAkB;EACxB,SAAS,WAAmB,EAAE,MAAM;CACtC,GACF;CACA,OAAO;EACL,OAAO,gBAAgB;GAAE,MAAM,WAAW;GAAM,OAAO,WAAW;EAAM;EACxE,KAAK,YAAY,SAAS;GACxB,MAAM,QAAQ,YAAoB,OAAO;GACzC,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY,WAAW,KAAK,KAAK;EAChE;CACF;AACF,CAAC"}
|
package/src/runtime.d.ts
CHANGED
|
@@ -64,9 +64,9 @@ export interface ElementSpec<Props extends {
|
|
|
64
64
|
* message. The page writes one of an entry as a `<template kui-each="name">` where the
|
|
65
65
|
* list goes, and the element stamps it for each entry, keyed, so an entry that stays keeps
|
|
66
66
|
* its elements. `around` is the entry of the list this one is written in (a week, for its
|
|
67
|
-
* days).
|
|
67
|
+
* days); `template` is where the list is written (inside which of a date picker's fields).
|
|
68
68
|
*/
|
|
69
|
-
lists?: Record<string, (controller: Controller, around: unknown) => Each | undefined>;
|
|
69
|
+
lists?: Record<string, (controller: Controller, around: unknown, template: HTMLElement) => Each | undefined>;
|
|
70
70
|
/**
|
|
71
71
|
* The hidden native input a form reads, for a component with no part to hold it: drawn as
|
|
72
72
|
* the element's last child, while `mounted` (a select with a name).
|
package/src/runtime.js
CHANGED
|
@@ -274,7 +274,7 @@ function defineElement(spec) {
|
|
|
274
274
|
}
|
|
275
275
|
/** Draws a list from its template: a copy for each entry, where the template was. */
|
|
276
276
|
#each(template) {
|
|
277
|
-
const list = spec.lists?.[template.getAttribute("kui-each")]?.(this.controller, entryAround(template));
|
|
277
|
+
const list = spec.lists?.[template.getAttribute("kui-each")]?.(this.controller, entryAround(template), template);
|
|
278
278
|
if (!list) return;
|
|
279
279
|
const mark = this.ownerDocument.createComment("");
|
|
280
280
|
if (ENTRY.has(template)) ENTRY.set(mark, ENTRY.get(template));
|