@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/select.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Select, SelectProps } from "@kirana-ui/core/select";
|
|
3
|
+
type Props = Omit<SelectProps<string>, "values" | "defaultValues"> & {
|
|
4
|
+
values?: string | readonly string[];
|
|
5
|
+
defaultValues?: string | readonly string[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* `<kui-select>` around a `kui-part="trigger"` button holding a `value` (it says the chosen
|
|
9
|
+
* item's text, or its `kui-placeholder`; with `multiple`, the chosen items' texts with commas
|
|
10
|
+
* between), and a `portal` with a `positioner` (its `kui-side`
|
|
11
|
+
* and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an
|
|
12
|
+
* `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an
|
|
13
|
+
* `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s
|
|
14
|
+
* between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name
|
|
15
|
+
* it draws the hidden input a form reads. A `value` part that holds something says what the
|
|
16
|
+
* page wrote there: a `<template kui-each="values">` in it is drawn for each chosen value
|
|
17
|
+
* (`{value}`, `{label}`), in the items' order. `value`, `default-value`, `open`,
|
|
18
|
+
* `default-open`, `disabled`, `required`, `multiple`, `values` and `default-values` (with
|
|
19
|
+
* commas between), `name`, `form`; `items` as a property; it tells `value-change`,
|
|
20
|
+
* `values-change` and `open-change`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const tag: Tag<Props, Select<string>>;
|
|
23
|
+
declare global {
|
|
24
|
+
interface HTMLElementTagNameMap {
|
|
25
|
+
"kui-select": ElementOf<typeof tag, {
|
|
26
|
+
"value-change": ["onValueChange", "value"];
|
|
27
|
+
"values-change": ["onValuesChange", "values"];
|
|
28
|
+
"open-change": ["onOpenChange", "open"];
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=select.d.ts.map
|
package/src/select.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { MARK, fieldAround, itemOptions, list, once, positioner, valueOf } from "./around.js";
|
|
2
|
+
import { defineElement, partAround } from "./runtime.js";
|
|
3
|
+
import { computed } from "@kirana-ui/core";
|
|
4
|
+
import { createSelect } from "@kirana-ui/core/select";
|
|
5
|
+
// src/select.ts
|
|
6
|
+
const groups = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
let made = 0;
|
|
8
|
+
const arrow = (drawn) => ({
|
|
9
|
+
part: drawn.part,
|
|
10
|
+
mounted: drawn.mounted,
|
|
11
|
+
mount: () => drawn.mount()
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* `<kui-select>` around a `kui-part="trigger"` button holding a `value` (it says the chosen
|
|
15
|
+
* item's text, or its `kui-placeholder`; with `multiple`, the chosen items' texts with commas
|
|
16
|
+
* between), and a `portal` with a `positioner` (its `kui-side`
|
|
17
|
+
* and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an
|
|
18
|
+
* `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an
|
|
19
|
+
* `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s
|
|
20
|
+
* between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name
|
|
21
|
+
* it draws the hidden input a form reads. A `value` part that holds something says what the
|
|
22
|
+
* page wrote there: a `<template kui-each="values">` in it is drawn for each chosen value
|
|
23
|
+
* (`{value}`, `{label}`), in the items' order. `value`, `default-value`, `open`,
|
|
24
|
+
* `default-open`, `disabled`, `required`, `multiple`, `values` and `default-values` (with
|
|
25
|
+
* commas between), `name`, `form`; `items` as a property; it tells `value-change`,
|
|
26
|
+
* `values-change` and `open-change`.
|
|
27
|
+
*/
|
|
28
|
+
const tag = defineElement({
|
|
29
|
+
tag: "kui-select",
|
|
30
|
+
props: {
|
|
31
|
+
value: "string",
|
|
32
|
+
"default-value": "string",
|
|
33
|
+
open: "boolean",
|
|
34
|
+
"default-open": "boolean",
|
|
35
|
+
disabled: "boolean",
|
|
36
|
+
required: "boolean",
|
|
37
|
+
multiple: "boolean",
|
|
38
|
+
values: "string",
|
|
39
|
+
"default-values": "string",
|
|
40
|
+
name: "string",
|
|
41
|
+
form: "string"
|
|
42
|
+
},
|
|
43
|
+
properties: ["items"],
|
|
44
|
+
create: (props, host) => createSelect(computed(() => {
|
|
45
|
+
const own = props.get();
|
|
46
|
+
return {
|
|
47
|
+
...own,
|
|
48
|
+
values: list(own.values),
|
|
49
|
+
defaultValues: list(own.defaultValues)
|
|
50
|
+
};
|
|
51
|
+
}), { field: fieldAround(host) }),
|
|
52
|
+
lists: { values: (controller) => ({
|
|
53
|
+
entries: computed(() => {
|
|
54
|
+
const { values, labels } = controller.shown.get();
|
|
55
|
+
return values.map((value, at) => ({
|
|
56
|
+
value,
|
|
57
|
+
label: labels[at] ?? value
|
|
58
|
+
}));
|
|
59
|
+
}),
|
|
60
|
+
key: (chosen) => chosen.value
|
|
61
|
+
}) },
|
|
62
|
+
inner: (controller) => ({
|
|
63
|
+
part: controller.input,
|
|
64
|
+
mounted: controller.named
|
|
65
|
+
}),
|
|
66
|
+
changes: {
|
|
67
|
+
onValueChange: {
|
|
68
|
+
event: "value-change",
|
|
69
|
+
prop: "value"
|
|
70
|
+
},
|
|
71
|
+
onValuesChange: {
|
|
72
|
+
event: "values-change",
|
|
73
|
+
prop: "values"
|
|
74
|
+
},
|
|
75
|
+
onOpenChange: {
|
|
76
|
+
event: "open-change",
|
|
77
|
+
prop: "open"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
parts: {
|
|
81
|
+
trigger: (controller) => controller.trigger,
|
|
82
|
+
value: (controller, element) => ({
|
|
83
|
+
part: controller.valuePart,
|
|
84
|
+
text: computed(() => controller.label.get() ?? element.getAttribute("kui-placeholder") ?? void 0)
|
|
85
|
+
}),
|
|
86
|
+
positioner(controller, element) {
|
|
87
|
+
controller.alignItemWithTrigger.set(element.hasAttribute("kui-align-item-with-trigger"));
|
|
88
|
+
return positioner(controller, element);
|
|
89
|
+
},
|
|
90
|
+
popup: (controller) => controller.popup,
|
|
91
|
+
list: (controller) => controller.list,
|
|
92
|
+
"scroll-up-arrow": (controller) => arrow(controller.scrollArrow("up")),
|
|
93
|
+
"scroll-down-arrow": (controller) => arrow(controller.scrollArrow("down")),
|
|
94
|
+
group: (controller, element) => once(groups, element, (group) => controller.group(group.getAttribute("kui-id") ?? `kui-select-group-${++made}`))?.root,
|
|
95
|
+
"group-label": (controller, element) => groups.get(partAround(element, "group"))?.label ?? controller.groupLabel,
|
|
96
|
+
separator: (controller) => controller.separator,
|
|
97
|
+
item: (controller, element) => controller.item(valueOf(element), itemOptions(element)),
|
|
98
|
+
"item-text": (controller, element) => controller.itemText(valueOf(partAround(element, "item"))),
|
|
99
|
+
"item-indicator": (controller, element) => ({
|
|
100
|
+
part: MARK,
|
|
101
|
+
mounted: controller.selected(valueOf(partAround(element, "item")))
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
export { tag };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../../packages/web/src/select.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type { Select, SelectGroup, SelectProps, SelectScrollArrow } from \"@kirana-ui/core/select\"\n\nimport { fieldAround, itemOptions, list, MARK, once, positioner, valueOf } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { Drawn, Each, ElementOf } from \"./runtime.ts\"\n\ntype Props = Omit<SelectProps<string>, \"values\" | \"defaultValues\"> & {\n values?: string | readonly string[]\n defaultValues?: string | readonly string[]\n}\n\nconst groups = new WeakMap<HTMLElement, SelectGroup>()\nlet made = 0\n\nconst arrow = (drawn: SelectScrollArrow): Drawn => ({\n part: drawn.part,\n mounted: drawn.mounted,\n mount: () => drawn.mount(),\n})\n\n/**\n * `<kui-select>` around a `kui-part=\"trigger\"` button holding a `value` (it says the chosen\n * item's text, or its `kui-placeholder`; with `multiple`, the chosen items' texts with commas\n * between), and a `portal` with a `positioner` (its `kui-side`\n * and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an\n * `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an\n * `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s\n * between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name\n * it draws the hidden input a form reads. A `value` part that holds something says what the\n * page wrote there: a `<template kui-each=\"values\">` in it is drawn for each chosen value\n * (`{value}`, `{label}`), in the items' order. `value`, `default-value`, `open`,\n * `default-open`, `disabled`, `required`, `multiple`, `values` and `default-values` (with\n * commas between), `name`, `form`; `items` as a property; it tells `value-change`,\n * `values-change` and `open-change`.\n */\nexport const tag = defineElement<Props, Select<string>>({\n tag: \"kui-select\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n open: \"boolean\",\n \"default-open\": \"boolean\",\n disabled: \"boolean\",\n required: \"boolean\",\n multiple: \"boolean\",\n values: \"string\",\n \"default-values\": \"string\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"items\"],\n create: (props, host) =>\n createSelect<string>(\n computed(() => {\n const own = props.get()\n return { ...own, values: list(own.values), defaultValues: list(own.defaultValues) }\n }),\n { field: fieldAround(host) }\n ),\n lists: {\n values: (controller): Each<{ value: string; label: string }> => ({\n entries: computed(() => {\n const { values, labels } = controller.shown.get()\n return values.map((value, at) => ({ value, label: labels[at] ?? value }))\n }),\n key: (chosen) => chosen.value,\n }),\n },\n inner: (controller) => ({ part: controller.input, mounted: controller.named }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValuesChange: { event: \"values-change\", prop: \"values\" },\n onOpenChange: { event: \"open-change\", prop: \"open\" },\n },\n parts: {\n trigger: (controller) => controller.trigger,\n value: (controller, element) => ({\n part: controller.valuePart,\n text: computed(\n () => controller.label.get() ?? element.getAttribute(\"kui-placeholder\") ?? undefined\n ),\n }),\n positioner(controller, element) {\n controller.alignItemWithTrigger.set(element.hasAttribute(\"kui-align-item-with-trigger\"))\n return positioner(controller, element)\n },\n popup: (controller) => controller.popup,\n list: (controller) => controller.list,\n \"scroll-up-arrow\": (controller) => arrow(controller.scrollArrow(\"up\")),\n \"scroll-down-arrow\": (controller) => arrow(controller.scrollArrow(\"down\")),\n group: (controller, element) =>\n once(groups, element, (group) =>\n controller.group(group.getAttribute(\"kui-id\") ?? `kui-select-group-${++made}`)\n )?.root,\n // Outside a group it is plain text, and names nothing.\n \"group-label\": (controller, element) =>\n groups.get(partAround(element, \"group\")!)?.label ?? controller.groupLabel,\n separator: (controller) => controller.separator,\n item: (controller, element) => controller.item(valueOf(element), itemOptions(element)),\n \"item-text\": (controller, element) => controller.itemText(valueOf(partAround(element, \"item\"))),\n \"item-indicator\": (controller, element) => ({\n part: MARK,\n mounted: controller.selected(valueOf(partAround(element, \"item\"))),\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-select\": ElementOf<\n typeof tag,\n {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"values-change\": [\"onValuesChange\", \"values\"]\n \"open-change\": [\"onOpenChange\", \"open\"]\n }\n >\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,yBAAS,IAAI,QAAkC;AACrD,IAAI,OAAO;AAEX,MAAM,SAAS,WAAqC;CAClD,MAAM,MAAM;CACZ,SAAS,MAAM;CACf,aAAa,MAAM,MAAM;AAC3B;;;;;;;;;;;;;;;;AAiBA,MAAa,MAAM,cAAqC;CACtD,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,UAAU;EACV,UAAU;EACV,UAAU;EACV,QAAQ;EACR,kBAAkB;EAClB,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,OAAO;CACpB,SAAS,OAAO,SACd,aACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,QAAQ,KAAK,IAAI,MAAM;GAAG,eAAe,KAAK,IAAI,aAAa;EAAE;CACpF,CAAC,GACD,EAAE,OAAO,YAAY,IAAI,EAAE,CAC7B;CACF,OAAO,EACL,SAAS,gBAAwD;EAC/D,SAAS,eAAe;GACtB,MAAM,EAAE,QAAQ,WAAW,WAAW,MAAM,IAAI;GAChD,OAAO,OAAO,KAAK,OAAO,QAAQ;IAAE;IAAO,OAAO,OAAO,OAAO;GAAM,EAAE;EAC1E,CAAC;EACD,MAAM,WAAW,OAAO;CAC1B,GACF;CACA,QAAQ,gBAAgB;EAAE,MAAM,WAAW;EAAO,SAAS,WAAW;CAAM;CAC5E,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,gBAAgB;GAAE,OAAO;GAAiB,MAAM;EAAS;EACzD,cAAc;GAAE,OAAO;GAAe,MAAM;EAAO;CACrD;CACA,OAAO;EACL,UAAU,eAAe,WAAW;EACpC,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW;GACjB,MAAM,eACE,WAAW,MAAM,IAAI,KAAK,QAAQ,aAAa,iBAAiB,KAAK,KAAA,CAC7E;EACF;EACA,WAAW,YAAY,SAAS;GAC9B,WAAW,qBAAqB,IAAI,QAAQ,aAAa,6BAA6B,CAAC;GACvF,OAAO,WAAW,YAAY,OAAO;EACvC;EACA,QAAQ,eAAe,WAAW;EAClC,OAAO,eAAe,WAAW;EACjC,oBAAoB,eAAe,MAAM,WAAW,YAAY,IAAI,CAAC;EACrE,sBAAsB,eAAe,MAAM,WAAW,YAAY,MAAM,CAAC;EACzE,QAAQ,YAAY,YAClB,KAAK,QAAQ,UAAU,UACrB,WAAW,MAAM,MAAM,aAAa,QAAQ,KAAK,oBAAoB,EAAE,MAAM,CAC/E,CAAC,EAAE;EAEL,gBAAgB,YAAY,YAC1B,OAAO,IAAI,WAAW,SAAS,OAAO,CAAE,CAAC,EAAE,SAAS,WAAW;EACjE,YAAY,eAAe,WAAW;EACtC,OAAO,YAAY,YAAY,WAAW,KAAK,QAAQ,OAAO,GAAG,YAAY,OAAO,CAAC;EACrF,cAAc,YAAY,YAAY,WAAW,SAAS,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC;EAC9F,mBAAmB,YAAY,aAAa;GAC1C,MAAM;GACN,SAAS,WAAW,SAAS,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC;EACnE;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { SeparatorProps } from "@kirana-ui/core/separator";
|
|
3
|
+
/** `<kui-separator>` around `kui-part="root"`. `orientation`. */
|
|
4
|
+
export declare const tag: Tag<{
|
|
5
|
+
id: string;
|
|
6
|
+
}, import("@kirana-ui/core/separator").Separator>;
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
"kui-separator": ElementOf<As<typeof tag, SeparatorProps>>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=separator.d.ts.map
|
package/src/separator.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineElement } from "./runtime.js";
|
|
2
|
+
import { createSeparator } from "@kirana-ui/core/separator";
|
|
3
|
+
// src/separator.ts
|
|
4
|
+
/** `<kui-separator>` around `kui-part="root"`. `orientation`. */
|
|
5
|
+
const tag = defineElement({
|
|
6
|
+
tag: "kui-separator",
|
|
7
|
+
props: { orientation: "string" },
|
|
8
|
+
create: (props) => createSeparator(props),
|
|
9
|
+
changes: {},
|
|
10
|
+
parts: { root: (controller) => controller.root }
|
|
11
|
+
});
|
|
12
|
+
export { tag };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=separator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separator.js","names":[],"sources":["../../../../packages/web/src/separator.ts"],"sourcesContent":["import { createSeparator } from \"@kirana-ui/core/separator\"\nimport type { SeparatorProps } from \"@kirana-ui/core/separator\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/** `<kui-separator>` around `kui-part=\"root\"`. `orientation`. */\nexport const tag = defineElement({\n tag: \"kui-separator\",\n props: { orientation: \"string\" },\n create: (props) => createSeparator(props as never),\n changes: {},\n parts: { root: (controller) => controller.root },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-separator\": ElementOf<As<typeof tag, SeparatorProps>>\n }\n}\n"],"mappings":";;;;AAOA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO,EAAE,aAAa,SAAS;CAC/B,SAAS,UAAU,gBAAgB,KAAc;CACjD,SAAS,CAAC;CACV,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
|
package/src/slider.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Slider, SliderProps } from "@kirana-ui/core/slider";
|
|
3
|
+
type Props = Omit<SliderProps, "value" | "defaultValue"> & {
|
|
4
|
+
value?: string | number | number[];
|
|
5
|
+
defaultValue?: string | number | number[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* `<kui-slider>` around `kui-part="root"`, a `value` (which says the value as it is written),
|
|
9
|
+
* a `control` with its `track`, `indicator` and a `thumb` for each value, in the values'
|
|
10
|
+
* order (or each with its `kui-index`). A thumb draws the hidden input a form reads. `value` and
|
|
11
|
+
* `default-value` (a range with a comma), `min`, `max`, `step`, `large-step`,
|
|
12
|
+
* `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `name`, `form`,
|
|
13
|
+
* `locale`; it tells `value-change` and `value-committed`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const tag: Tag<Props, Slider>;
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
"kui-slider": ElementOf<typeof tag, {
|
|
19
|
+
"value-change": ["onValueChange", "value"];
|
|
20
|
+
"value-committed": ["onValueCommitted", "value"];
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=slider.d.ts.map
|
package/src/slider.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { fieldAround, ownValue } from "./around.js";
|
|
2
|
+
import { defineElement } from "./runtime.js";
|
|
3
|
+
import { computed } from "@kirana-ui/core";
|
|
4
|
+
import { createSlider } from "@kirana-ui/core/slider";
|
|
5
|
+
// src/slider.ts
|
|
6
|
+
/** A value as an attribute writes it: `"40"`, or for a range `"20,80"`. */
|
|
7
|
+
const read = (given) => typeof given === "string" ? given.includes(",") ? given.split(",").map(Number) : Number(given) : given;
|
|
8
|
+
const at = (element) => element.hasAttribute("kui-index") ? Number(element.getAttribute("kui-index")) : ownValue(element);
|
|
9
|
+
/**
|
|
10
|
+
* `<kui-slider>` around `kui-part="root"`, a `value` (which says the value as it is written),
|
|
11
|
+
* a `control` with its `track`, `indicator` and a `thumb` for each value, in the values'
|
|
12
|
+
* order (or each with its `kui-index`). A thumb draws the hidden input a form reads. `value` and
|
|
13
|
+
* `default-value` (a range with a comma), `min`, `max`, `step`, `large-step`,
|
|
14
|
+
* `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `name`, `form`,
|
|
15
|
+
* `locale`; it tells `value-change` and `value-committed`.
|
|
16
|
+
*/
|
|
17
|
+
const tag = defineElement({
|
|
18
|
+
tag: "kui-slider",
|
|
19
|
+
props: {
|
|
20
|
+
value: "string",
|
|
21
|
+
"default-value": "string",
|
|
22
|
+
min: "number",
|
|
23
|
+
max: "number",
|
|
24
|
+
step: "number",
|
|
25
|
+
"large-step": "number",
|
|
26
|
+
"min-steps-between-values": "number",
|
|
27
|
+
"thumb-alignment": "string",
|
|
28
|
+
orientation: "string",
|
|
29
|
+
disabled: "boolean",
|
|
30
|
+
name: "string",
|
|
31
|
+
form: "string",
|
|
32
|
+
locale: "string"
|
|
33
|
+
},
|
|
34
|
+
properties: ["format", "getAriaValueText"],
|
|
35
|
+
create: (props, host) => createSlider(computed(() => {
|
|
36
|
+
const own = props.get();
|
|
37
|
+
return {
|
|
38
|
+
...own,
|
|
39
|
+
value: read(own.value),
|
|
40
|
+
defaultValue: read(own.defaultValue)
|
|
41
|
+
};
|
|
42
|
+
}), { field: fieldAround(host) }),
|
|
43
|
+
changes: {
|
|
44
|
+
onValueChange: {
|
|
45
|
+
event: "value-change",
|
|
46
|
+
prop: "value"
|
|
47
|
+
},
|
|
48
|
+
onValueCommitted: {
|
|
49
|
+
event: "value-committed",
|
|
50
|
+
prop: "value",
|
|
51
|
+
hold: false
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
parts: {
|
|
55
|
+
root: (controller) => controller.root,
|
|
56
|
+
value: (controller) => ({
|
|
57
|
+
part: controller.value,
|
|
58
|
+
text: controller.text
|
|
59
|
+
}),
|
|
60
|
+
control: (controller) => controller.control,
|
|
61
|
+
track: (controller) => controller.track,
|
|
62
|
+
indicator: (controller) => controller.indicator,
|
|
63
|
+
thumb: (controller, element) => ({
|
|
64
|
+
part: controller.thumb(at(element)),
|
|
65
|
+
inner: controller.thumbInput(at(element))
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
export { tag };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.js","names":[],"sources":["../../../../packages/web/src/slider.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createSlider } from \"@kirana-ui/core/slider\"\nimport type { Slider, SliderProps } from \"@kirana-ui/core/slider\"\n\nimport { fieldAround, ownValue } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/** A value as an attribute writes it: `\"40\"`, or for a range `\"20,80\"`. */\nconst read = (given: unknown): number | number[] | undefined =>\n typeof given === \"string\"\n ? given.includes(\",\")\n ? given.split(\",\").map(Number)\n : Number(given)\n : (given as number | number[] | undefined)\n\n// A thumb with no `kui-index` takes its place among the slider's thumbs, in the page's order.\nconst at = (element: HTMLElement) =>\n element.hasAttribute(\"kui-index\") ? Number(element.getAttribute(\"kui-index\")) : ownValue(element)\n\ntype Props = Omit<SliderProps, \"value\" | \"defaultValue\"> & {\n value?: string | number | number[]\n defaultValue?: string | number | number[]\n}\n\n/**\n * `<kui-slider>` around `kui-part=\"root\"`, a `value` (which says the value as it is written),\n * a `control` with its `track`, `indicator` and a `thumb` for each value, in the values'\n * order (or each with its `kui-index`). A thumb draws the hidden input a form reads. `value` and\n * `default-value` (a range with a comma), `min`, `max`, `step`, `large-step`,\n * `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `name`, `form`,\n * `locale`; it tells `value-change` and `value-committed`.\n */\nexport const tag = defineElement<Props, Slider>({\n tag: \"kui-slider\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n min: \"number\",\n max: \"number\",\n step: \"number\",\n \"large-step\": \"number\",\n \"min-steps-between-values\": \"number\",\n \"thumb-alignment\": \"string\",\n orientation: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n locale: \"string\",\n },\n properties: [\"format\", \"getAriaValueText\"],\n create: (props, host) =>\n createSlider(\n computed(() => {\n const own = props.get()\n return { ...own, value: read(own.value), defaultValue: read(own.defaultValue) }\n }),\n { field: fieldAround(host) }\n ),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValueCommitted: { event: \"value-committed\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n value: (controller) => ({ part: controller.value, text: controller.text }),\n control: (controller) => controller.control,\n track: (controller) => controller.track,\n indicator: (controller) => controller.indicator,\n thumb: (controller, element) => ({\n part: controller.thumb(at(element)),\n inner: controller.thumbInput(at(element)),\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-slider\": ElementOf<\n typeof tag,\n {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"value-committed\": [\"onValueCommitted\", \"value\"]\n }\n >\n }\n}\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,UACZ,OAAO,UAAU,WACb,MAAM,SAAS,GAAG,IAChB,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,IAC3B,OAAO,KAAK,IACb;AAGP,MAAM,MAAM,YACV,QAAQ,aAAa,WAAW,IAAI,OAAO,QAAQ,aAAa,WAAW,CAAC,IAAI,SAAS,OAAO;;;;;;;;;AAelG,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,KAAK;EACL,KAAK;EACL,MAAM;EACN,cAAc;EACd,4BAA4B;EAC5B,mBAAmB;EACnB,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;EACN,QAAQ;CACV;CACA,YAAY,CAAC,UAAU,kBAAkB;CACzC,SAAS,OAAO,SACd,aACE,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,OAAO,YAAY,IAAI,EAAE,CAC7B;CACF,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,kBAAkB;GAAE,OAAO;GAAmB,MAAM;GAAS,MAAM;EAAM;CAC3E;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,gBAAgB;GAAE,MAAM,WAAW;GAAO,MAAM,WAAW;EAAK;EACxE,UAAU,eAAe,WAAW;EACpC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW,MAAM,GAAG,OAAO,CAAC;GAClC,OAAO,WAAW,WAAW,GAAG,OAAO,CAAC;EAC1C;CACF;AACF,CAAC"}
|
package/src/switch.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { As, ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { SwitchProps } from "@kirana-ui/core/switch";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-switch>` around a `kui-part="root"` button with a `thumb` inside. The root draws the
|
|
5
|
+
* hidden native input a form and a label reach. `checked`, `default-checked`, `disabled`,
|
|
6
|
+
* `read-only`, `required`, `name`, `form`, `value`; it tells `checked-change`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const tag: Tag<{
|
|
9
|
+
id: string;
|
|
10
|
+
}, import("@kirana-ui/core/switch").Switch>;
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
"kui-switch": ElementOf<As<typeof tag, SwitchProps>, {
|
|
14
|
+
"checked-change": ["onCheckedChange", "checked"];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=switch.d.ts.map
|
package/src/switch.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { fieldAround } from "./around.js";
|
|
2
|
+
import { defineElement } from "./runtime.js";
|
|
3
|
+
import { createSwitch } from "@kirana-ui/core/switch";
|
|
4
|
+
// src/switch.ts
|
|
5
|
+
/**
|
|
6
|
+
* `<kui-switch>` around a `kui-part="root"` button with a `thumb` inside. The root draws the
|
|
7
|
+
* hidden native input a form and a label reach. `checked`, `default-checked`, `disabled`,
|
|
8
|
+
* `read-only`, `required`, `name`, `form`, `value`; it tells `checked-change`.
|
|
9
|
+
*/
|
|
10
|
+
const tag = defineElement({
|
|
11
|
+
tag: "kui-switch",
|
|
12
|
+
props: {
|
|
13
|
+
checked: "boolean",
|
|
14
|
+
"default-checked": "boolean",
|
|
15
|
+
disabled: "boolean",
|
|
16
|
+
"read-only": "boolean",
|
|
17
|
+
required: "boolean",
|
|
18
|
+
name: "string",
|
|
19
|
+
form: "string",
|
|
20
|
+
value: "string"
|
|
21
|
+
},
|
|
22
|
+
create: (props, host) => createSwitch(props, { field: fieldAround(host) }),
|
|
23
|
+
changes: { onCheckedChange: {
|
|
24
|
+
event: "checked-change",
|
|
25
|
+
prop: "checked"
|
|
26
|
+
} },
|
|
27
|
+
parts: {
|
|
28
|
+
root: (controller) => ({
|
|
29
|
+
part: controller.root,
|
|
30
|
+
inner: controller.input
|
|
31
|
+
}),
|
|
32
|
+
thumb: (controller) => controller.thumb
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export { tag };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.js","names":[],"sources":["../../../../packages/web/src/switch.ts"],"sourcesContent":["import { createSwitch } from \"@kirana-ui/core/switch\"\nimport type { SwitchProps } from \"@kirana-ui/core/switch\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-switch>` around a `kui-part=\"root\"` button with a `thumb` inside. The root draws the\n * hidden native input a form and a label reach. `checked`, `default-checked`, `disabled`,\n * `read-only`, `required`, `name`, `form`, `value`; it tells `checked-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-switch\",\n props: {\n checked: \"boolean\",\n \"default-checked\": \"boolean\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n value: \"string\",\n },\n create: (props, host) => createSwitch(props, { field: fieldAround(host) }),\n changes: { onCheckedChange: { event: \"checked-change\", prop: \"checked\" } },\n parts: {\n root: (controller) => ({ part: controller.root, inner: controller.input }),\n thumb: (controller) => controller.thumb,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-switch\": ElementOf<\n As<typeof tag, SwitchProps>,\n { \"checked-change\": [\"onCheckedChange\", \"checked\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,SAAS;EACT,mBAAmB;EACnB,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;EACN,OAAO;CACT;CACA,SAAS,OAAO,SAAS,aAAa,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACzE,SAAS,EAAE,iBAAiB;EAAE,OAAO;EAAkB,MAAM;CAAU,EAAE;CACzE,OAAO;EACL,OAAO,gBAAgB;GAAE,MAAM,WAAW;GAAM,OAAO,WAAW;EAAM;EACxE,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
|
package/src/tabs.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { TabsProps } from "@kirana-ui/core/tabs";
|
|
3
|
+
/**
|
|
4
|
+
* `<kui-tabs>` around `kui-part="root"`, a `list` with a `tab` for each `value` and an
|
|
5
|
+
* `indicator`, and a `panel` for each `value`, in the page while its tab is the active one.
|
|
6
|
+
* `value`, `default-value`, `orientation`; it tells `value-change`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const tag: Tag<TabsProps<string>, import("@kirana-ui/core/tabs").Tabs<string>>;
|
|
9
|
+
declare global {
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
"kui-tabs": ElementOf<typeof tag, {
|
|
12
|
+
"value-change": ["onValueChange", "value"];
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=tabs.d.ts.map
|
package/src/tabs.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineElement } from "./runtime.js";
|
|
2
|
+
import { createTabs } from "@kirana-ui/core/tabs";
|
|
3
|
+
// src/tabs.ts
|
|
4
|
+
/**
|
|
5
|
+
* `<kui-tabs>` around `kui-part="root"`, a `list` with a `tab` for each `value` and an
|
|
6
|
+
* `indicator`, and a `panel` for each `value`, in the page while its tab is the active one.
|
|
7
|
+
* `value`, `default-value`, `orientation`; it tells `value-change`.
|
|
8
|
+
*/
|
|
9
|
+
const tag = defineElement({
|
|
10
|
+
tag: "kui-tabs",
|
|
11
|
+
props: {
|
|
12
|
+
value: "string",
|
|
13
|
+
"default-value": "string",
|
|
14
|
+
orientation: "string"
|
|
15
|
+
},
|
|
16
|
+
create: (props) => createTabs(props),
|
|
17
|
+
changes: { onValueChange: {
|
|
18
|
+
event: "value-change",
|
|
19
|
+
prop: "value"
|
|
20
|
+
} },
|
|
21
|
+
parts: {
|
|
22
|
+
root: (controller) => controller.root,
|
|
23
|
+
list: (controller) => controller.list,
|
|
24
|
+
indicator: (controller) => controller.indicator,
|
|
25
|
+
tab: (controller, element) => controller.tab(element.getAttribute("kui-value") ?? "", () => ({ disabled: element.hasAttribute("kui-disabled") })),
|
|
26
|
+
panel: (controller, element) => controller.panel(element.getAttribute("kui-value") ?? "")
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export { tag };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=tabs.js.map
|
package/src/tabs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","names":[],"sources":["../../../../packages/web/src/tabs.ts"],"sourcesContent":["import { createTabs } from \"@kirana-ui/core/tabs\"\nimport type { TabsProps } from \"@kirana-ui/core/tabs\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-tabs>` around `kui-part=\"root\"`, a `list` with a `tab` for each `value` and an\n * `indicator`, and a `panel` for each `value`, in the page while its tab is the active one.\n * `value`, `default-value`, `orientation`; it tells `value-change`.\n */\nexport const tag = defineElement<TabsProps<string>, ReturnType<typeof createTabs<string>>>({\n tag: \"kui-tabs\",\n props: { value: \"string\", \"default-value\": \"string\", orientation: \"string\" },\n create: (props) => createTabs<string>(props),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n list: (controller) => controller.list,\n indicator: (controller) => controller.indicator,\n tab: (controller, element) =>\n controller.tab(element.getAttribute(\"kui-value\") ?? \"\", () => ({\n disabled: element.hasAttribute(\"kui-disabled\"),\n })),\n panel: (controller, element) => controller.panel(element.getAttribute(\"kui-value\") ?? \"\"),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-tabs\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,MAAM,cAAwE;CACzF,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,iBAAiB;EAAU,aAAa;CAAS;CAC3E,SAAS,UAAU,WAAmB,KAAK;CAC3C,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,eAAe,WAAW;EACjC,YAAY,eAAe,WAAW;EACtC,MAAM,YAAY,YAChB,WAAW,IAAI,QAAQ,aAAa,WAAW,KAAK,WAAW,EAC7D,UAAU,QAAQ,aAAa,cAAc,EAC/C,EAAE;EACJ,QAAQ,YAAY,YAAY,WAAW,MAAM,QAAQ,aAAa,WAAW,KAAK,EAAE;CAC1F;AACF,CAAC"}
|
package/src/testing.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@kirana-ui/core/testing";
|
package/src/testing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@kirana-ui/core/testing";
|
package/src/toast.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { Toast, ToastActionOptions, ToastOptions, ToastProps, ToastRecord, ToastState, Toaster, ToasterOptions, createToaster } from "@kirana-ui/core/toast";
|
|
3
|
+
/**
|
|
4
|
+
* The toaster a `<kui-toast>` draws: its own (made with the element's `duration` and
|
|
5
|
+
* `limit`), unless it was given one as its `toaster` property before it began.
|
|
6
|
+
* `toasterOf(element).add({ title: "Saved" })`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toasterOf(element: Element): Toaster;
|
|
9
|
+
/**
|
|
10
|
+
* `<kui-toast>` around a `kui-part="viewport"`, which holds a `<template kui-each="toasts">`
|
|
11
|
+
* with a `toast` for each message (`{id}`, `{type}`), its `content` with a `title` and a
|
|
12
|
+
* `description`, and a `close` and an `action` button. A `title`, a `description` and an
|
|
13
|
+
* `action` written empty say what the toast was added with, and are in the page only for a
|
|
14
|
+
* toast that has one; one written with something in it (`{title}`) is always there. `label`,
|
|
15
|
+
* `hotkey`, `swipe-direction`; `duration` and `limit` for the toaster it makes, or `toaster`
|
|
16
|
+
* as a property for one of the page's own. A title, a description and an action's label are
|
|
17
|
+
* strings.
|
|
18
|
+
*/
|
|
19
|
+
export declare const tag: Tag<Omit<ToastProps<string>, "toaster"> & {
|
|
20
|
+
toaster?: Toaster;
|
|
21
|
+
duration?: number;
|
|
22
|
+
limit?: number;
|
|
23
|
+
}, Toast<string>>;
|
|
24
|
+
declare global {
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
"kui-toast": ElementOf<typeof tag>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export { type ToastActionOptions, type ToastOptions, type ToastRecord, type ToastState, type Toaster, type ToasterOptions, createToaster };
|
|
30
|
+
//# sourceMappingURL=toast.d.ts.map
|
package/src/toast.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineElement, entryAround } from "./runtime.js";
|
|
2
|
+
import { computed } from "@kirana-ui/core";
|
|
3
|
+
import { createToast, createToaster } from "@kirana-ui/core/toast";
|
|
4
|
+
// src/toast.ts
|
|
5
|
+
const toasters = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* The toaster a `<kui-toast>` draws: its own (made with the element's `duration` and
|
|
8
|
+
* `limit`), unless it was given one as its `toaster` property before it began.
|
|
9
|
+
* `toasterOf(element).add({ title: "Saved" })`.
|
|
10
|
+
*/
|
|
11
|
+
function toasterOf(element) {
|
|
12
|
+
let toaster = toasters.get(element);
|
|
13
|
+
if (!toaster) {
|
|
14
|
+
const number = (name) => element.hasAttribute(name) ? { [name]: Number(element.getAttribute(name)) } : {};
|
|
15
|
+
toasters.set(element, toaster = createToaster({
|
|
16
|
+
...number("duration"),
|
|
17
|
+
...number("limit")
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
return toaster;
|
|
21
|
+
}
|
|
22
|
+
const partsOf = (controller, element) => {
|
|
23
|
+
const toast = entryAround(element);
|
|
24
|
+
return toast && controller.toast(toast.id);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A part that says something of the toast's, when the page wrote nothing in its element: the
|
|
28
|
+
* text the toast was added with, and out of the page while the toast has none. What the page
|
|
29
|
+
* wrote there (`{title}`) stays the page's.
|
|
30
|
+
*/
|
|
31
|
+
const said = (name) => (controller, element) => {
|
|
32
|
+
const parts = partsOf(controller, element);
|
|
33
|
+
if (!parts || element.childNodes.length > 0) return parts?.[name];
|
|
34
|
+
const text = computed(() => {
|
|
35
|
+
const toast = parts.record.get();
|
|
36
|
+
return name === "action" ? toast?.action?.label : toast?.[name];
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
part: parts[name],
|
|
40
|
+
text,
|
|
41
|
+
mounted: computed(() => text.get() !== void 0)
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* `<kui-toast>` around a `kui-part="viewport"`, which holds a `<template kui-each="toasts">`
|
|
46
|
+
* with a `toast` for each message (`{id}`, `{type}`), its `content` with a `title` and a
|
|
47
|
+
* `description`, and a `close` and an `action` button. A `title`, a `description` and an
|
|
48
|
+
* `action` written empty say what the toast was added with, and are in the page only for a
|
|
49
|
+
* toast that has one; one written with something in it (`{title}`) is always there. `label`,
|
|
50
|
+
* `hotkey`, `swipe-direction`; `duration` and `limit` for the toaster it makes, or `toaster`
|
|
51
|
+
* as a property for one of the page's own. A title, a description and an action's label are
|
|
52
|
+
* strings.
|
|
53
|
+
*/
|
|
54
|
+
const tag = defineElement({
|
|
55
|
+
tag: "kui-toast",
|
|
56
|
+
props: {
|
|
57
|
+
label: "string",
|
|
58
|
+
hotkey: "string",
|
|
59
|
+
"swipe-direction": "string",
|
|
60
|
+
duration: "number",
|
|
61
|
+
limit: "number"
|
|
62
|
+
},
|
|
63
|
+
properties: ["toaster"],
|
|
64
|
+
create(props, host) {
|
|
65
|
+
const given = props.peek().toaster;
|
|
66
|
+
if (given) toasters.set(host, given);
|
|
67
|
+
const toaster = toasterOf(host);
|
|
68
|
+
return createToast(computed(() => {
|
|
69
|
+
const { duration: _duration, limit: _limit, ...own } = props.get();
|
|
70
|
+
return {
|
|
71
|
+
...own,
|
|
72
|
+
toaster
|
|
73
|
+
};
|
|
74
|
+
}));
|
|
75
|
+
},
|
|
76
|
+
changes: {},
|
|
77
|
+
lists: { toasts: (controller) => ({
|
|
78
|
+
entries: controller.toasts,
|
|
79
|
+
key: (toast) => toast.id
|
|
80
|
+
}) },
|
|
81
|
+
parts: {
|
|
82
|
+
viewport: (controller) => controller.viewport,
|
|
83
|
+
toast: (controller, element) => partsOf(controller, element)?.root,
|
|
84
|
+
content: (controller, element) => partsOf(controller, element)?.content,
|
|
85
|
+
title: said("title"),
|
|
86
|
+
description: said("description"),
|
|
87
|
+
close: (controller, element) => partsOf(controller, element)?.close,
|
|
88
|
+
action: said("action")
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
export { createToaster, tag, toasterOf };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=toast.js.map
|
package/src/toast.js.map
ADDED
|
@@ -0,0 +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 `duration` and\n * `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(element, (toaster = createToaster({ ...number(\"duration\"), ...number(\"limit\") })))\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`; `duration` 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\"> & { toaster?: Toaster; duration?: number; limit?: number },\n Toast\n>({\n tag: \"kui-toast\",\n props: {\n label: \"string\",\n hotkey: \"string\",\n \"swipe-direction\": \"string\",\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 { 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,IAAI,SAAU,UAAU,cAAc;GAAE,GAAG,OAAO,UAAU;GAAG,GAAG,OAAO,OAAO;EAAE,CAAC,CAAE;CAChG;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,cAGjB;CACA,KAAK;CACL,OAAO;EACL,OAAO;EACP,QAAQ;EACR,mBAAmB;EACnB,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,UAAU,WAAW,OAAO,QAAQ,GAAG,QAAQ,MAAM,IAAI;GACjE,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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ElementOf, Tag } from "./runtime.js";
|
|
2
|
+
import { ToggleGroup, ToggleGroupProps } from "@kirana-ui/core/toggle-group";
|
|
3
|
+
type Props = Omit<ToggleGroupProps<string>, "value" | "defaultValue"> & {
|
|
4
|
+
id: string;
|
|
5
|
+
value?: string | readonly string[];
|
|
6
|
+
defaultValue?: string | readonly string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `<kui-toggle-group>` around `kui-part="root"` and its `<kui-toggle>`s, each with a `value`.
|
|
10
|
+
* `value` and `default-value` (the pressed ones, with commas between), `multiple`, `disabled`,
|
|
11
|
+
* `orientation`, `loop`; it tells `value-change`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const tag: Tag<Props, ToggleGroup<string>>;
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
"kui-toggle-group": ElementOf<typeof tag, {
|
|
17
|
+
"value-change": ["onValueChange", "value"];
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=toggle-group.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { list } from "./around.js";
|
|
2
|
+
import { controllerAround, defineElement } from "./runtime.js";
|
|
3
|
+
import { computed } from "@kirana-ui/core";
|
|
4
|
+
import { createToggleGroup } from "@kirana-ui/core/toggle-group";
|
|
5
|
+
// src/toggle-group.ts
|
|
6
|
+
/**
|
|
7
|
+
* `<kui-toggle-group>` around `kui-part="root"` and its `<kui-toggle>`s, each with a `value`.
|
|
8
|
+
* `value` and `default-value` (the pressed ones, with commas between), `multiple`, `disabled`,
|
|
9
|
+
* `orientation`, `loop`; it tells `value-change`.
|
|
10
|
+
*/
|
|
11
|
+
const tag = defineElement({
|
|
12
|
+
tag: "kui-toggle-group",
|
|
13
|
+
props: {
|
|
14
|
+
value: "string",
|
|
15
|
+
"default-value": "string",
|
|
16
|
+
multiple: "boolean",
|
|
17
|
+
disabled: "boolean",
|
|
18
|
+
orientation: "string",
|
|
19
|
+
loop: "boolean"
|
|
20
|
+
},
|
|
21
|
+
create: (props, host) => createToggleGroup(computed(() => {
|
|
22
|
+
const own = props.get();
|
|
23
|
+
return {
|
|
24
|
+
...own,
|
|
25
|
+
value: list(own.value),
|
|
26
|
+
defaultValue: list(own.defaultValue)
|
|
27
|
+
};
|
|
28
|
+
}), { toolbar: controllerAround(host, "kui-toolbar") }),
|
|
29
|
+
changes: { onValueChange: {
|
|
30
|
+
event: "value-change",
|
|
31
|
+
prop: "value"
|
|
32
|
+
} },
|
|
33
|
+
parts: { root: (controller) => controller.root }
|
|
34
|
+
});
|
|
35
|
+
export { tag };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=toggle-group.js.map
|
|
@@ -0,0 +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`; 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: \"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,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"}
|