@kirana-ui/vue 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/llms.txt +1867 -268
- package/package.json +18 -2
- package/skills/kirana-ui-primitives/SKILL.md +163 -0
- package/src/accordion.d.ts +42 -75
- package/src/accordion.js +4 -2
- package/src/accordion.js.map +1 -1
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +3 -2
- package/src/autocomplete.d.ts +4 -2
- package/src/autosize.d.ts +9 -9
- package/src/autosize.js.map +1 -1
- package/src/avatar.d.ts +37 -13
- package/src/avatar.js +39 -15
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -21
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +71 -99
- package/src/calendar.js +81 -11
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +36 -58
- package/src/carousel.js.map +1 -1
- package/src/checkbox-group-context.d.ts +5 -0
- package/src/checkbox-group-context.js +6 -0
- package/src/checkbox-group-context.js.map +1 -0
- package/src/checkbox-group.d.ts +12 -0
- package/src/checkbox-group.js +44 -0
- package/src/checkbox-group.js.map +1 -0
- package/src/checkbox.d.ts +29 -50
- package/src/checkbox.js +11 -4
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +26 -36
- package/src/collapsible.js.map +1 -1
- package/src/combobox.d.ts +161 -290
- package/src/combobox.js +62 -4
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +43 -86
- package/src/command.js +2 -0
- package/src/command.js.map +1 -1
- package/src/context-menu.d.ts +4 -2
- package/src/date-field.d.ts +31 -61
- package/src/date-field.js +7 -3
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +86 -139
- package/src/date-picker.js +12 -1
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +93 -145
- package/src/dialog.js +7 -2
- package/src/dialog.js.map +1 -1
- package/src/direction.d.ts +5 -8
- package/src/direction.js.map +1 -1
- package/src/drawer.d.ts +3 -2
- package/src/element.d.ts +23 -0
- package/src/element.js +90 -0
- package/src/element.js.map +1 -0
- package/src/field.d.ts +63 -45
- package/src/field.js +3 -2
- package/src/field.js.map +1 -1
- package/src/fieldset.d.ts +12 -13
- package/src/fieldset.js.map +1 -1
- package/src/form.d.ts +5 -15
- package/src/form.js.map +1 -1
- package/src/hover-card.d.ts +29 -43
- package/src/hover-card.js.map +1 -1
- package/src/hover-popup.d.ts +27 -46
- package/src/hover-popup.js +4 -1
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +16 -3
- package/src/index.js +2 -1
- package/src/input.d.ts +12 -14
- package/src/input.js.map +1 -1
- package/src/label.d.ts +3 -3
- package/src/label.js.map +1 -1
- package/src/listbox.d.ts +34 -89
- package/src/listbox.js.map +1 -1
- package/src/menu.d.ts +170 -533
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +6 -24
- package/src/menubar.js.map +1 -1
- package/src/message-scroller.d.ts +23 -17
- package/src/message-scroller.js.map +1 -1
- package/src/meter.d.ts +10 -31
- package/src/meter.js.map +1 -1
- package/src/navigation-menu.d.ts +77 -88
- package/src/navigation-menu.js +13 -12
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +104 -68
- package/src/number-field.js +98 -68
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +33 -54
- package/src/otp.js +4 -2
- package/src/otp.js.map +1 -1
- package/src/pagination.d.ts +31 -58
- package/src/pagination.js.map +1 -1
- package/src/popover.d.ts +83 -36
- package/src/popover.js +68 -8
- package/src/popover.js.map +1 -1
- package/src/primitive.d.ts +21 -0
- package/src/primitive.js +27 -0
- package/src/primitive.js.map +1 -0
- package/src/progress.d.ts +28 -31
- package/src/progress.js.map +1 -1
- package/src/qr-code.d.ts +12 -21
- package/src/qr-code.js.map +1 -1
- package/src/radio-group.d.ts +37 -75
- package/src/radio-group.js +8 -4
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +26 -45
- package/src/resizable.js.map +1 -1
- package/src/runtime.d.ts +93 -21
- package/src/runtime.js +24 -25
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +33 -28
- package/src/scroll-area.js.map +1 -1
- package/src/select.d.ts +88 -147
- package/src/select.js +33 -6
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +4 -9
- package/src/separator.js.map +1 -1
- package/src/slider.d.ts +66 -80
- package/src/slider.js +11 -10
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +21 -39
- package/src/switch.js +2 -2
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +44 -98
- package/src/tabs.js.map +1 -1
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +58 -45
- package/src/toast.js +46 -17
- package/src/toast.js.map +1 -1
- package/src/toggle-group.d.ts +8 -39
- package/src/toggle-group.js.map +1 -1
- package/src/toggle.d.ts +5 -34
- package/src/toggle.js.map +1 -1
- package/src/toolbar.d.ts +31 -69
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +29 -43
- package/src/tooltip.js.map +1 -1
- package/src/value-bar.d.ts +26 -35
- package/src/value-bar.js +10 -3
- package/src/value-bar.js.map +1 -1
package/src/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/vue/src/pagination.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createPagination } from \"@kirana-ui/core/pagination\"\nimport type {
|
|
1
|
+
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/vue/src/pagination.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createPagination } from \"@kirana-ui/core/pagination\"\nimport type {\n Pagination as Controller,\n PaginationEntry,\n PaginationProps,\n} from \"@kirana-ui/core/pagination\"\nimport { Fragment, defineComponent, h, useId } from \"vue\"\n\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"pagination\">\n\nconst scope = context<Controller>(\"Pagination\")\n\nconst RootElement = partComponent(\"PaginationRootElement\", \"nav\", () => scope.use().root)\n\nexport type RootProps = Omit<PaginationProps, \"id\" | \"onPageChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"page\", number>\n\n/** `v-model:page`, and `@page-change=\"(page, details) => …\"`. */\nconst Root = defineComponent({\n name: \"PaginationRoot\",\n inheritAttrs: false,\n props: {\n page: optional(Number),\n defaultPage: Number,\n count: { type: Number, required: true },\n pageSize: Number,\n siblingCount: Number,\n boundaryCount: Number,\n disabled: Boolean,\n id: String,\n },\n emits: [\"update:page\", \"pageChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createPagination, () => ({\n id: props.id ?? generated,\n page: props.page,\n defaultPage: props.defaultPage,\n count: props.count,\n pageSize: props.pageSize,\n siblingCount: props.siblingCount,\n boundaryCount: props.boundaryCount,\n disabled: props.disabled,\n onPageChange(page: number, details: ChangeDetails) {\n emit(\"pageChange\", page, details)\n if (!details.canceled) emit(\"update:page\", page)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"nav\", State[\"root\"], RootProps, RootEmits>\n\nexport type ItemsProps = Record<never, never>\n\n/** Draws its slot once for each piece of the row (`v-slot=\"{ entry }\"`). */\nconst Items = defineComponent({\n name: \"PaginationItems\",\n setup(_props, { slots }) {\n const entries = fromSignal(scope.use().entries)\n return () =>\n entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })))\n },\n}) as unknown as PlainComponent<ItemsProps, {}, { entry: PaginationEntry }>\n\nexport interface ItemProps extends PartComponentProps {\n /** The page it goes to. */\n page: number\n}\n\nconst Item = defineComponent({\n name: \"PaginationItem\",\n inheritAttrs: false,\n props: { page: { type: Number, required: true } },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const Element = partComponent(\"PaginationItemElement\", \"button\", () => made.item(props.page))\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"item\"], ItemProps>\n\nexport type EllipsisProps = PartComponentProps\nexport type PreviousProps = PartComponentProps\nexport type NextProps = PartComponentProps\nexport const Pagination = {\n Root,\n Items,\n Item,\n Ellipsis: partComponent<\"span\", State[\"ellipsis\"]>(\n \"PaginationEllipsis\",\n \"span\",\n () => scope.use().ellipsis\n ),\n Previous: partComponent<\"button\", State[\"previous\"]>(\n \"PaginationPrevious\",\n \"button\",\n () => scope.use().previous\n ),\n Next: partComponent<\"button\", State[\"next\"]>(\"PaginationNext\", \"button\", () => scope.use().next),\n}\n"],"mappings":";;;;AAoBA,MAAM,QAAQ,QAAoB,YAAY;AAE9C,MAAM,cAAc,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AA4ExF,MAAa,aAAa;CACxB,MApEW,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,MAAM,SAAS,MAAM;GACrB,aAAa;GACb,OAAO;IAAE,MAAM;IAAQ,UAAU;GAAK;GACtC,UAAU;GACV,cAAc;GACd,eAAe;GACf,UAAU;GACV,IAAI;EACN;EACA,OAAO,CAAC,eAAe,YAAY;EACnC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,QACJ,WAAW,yBAAyB;IAClC,IAAI,MAAM,MAAM;IAChB,MAAM,MAAM;IACZ,aAAa,MAAM;IACnB,OAAO,MAAM;IACb,UAAU,MAAM;IAChB,cAAc,MAAM;IACpB,eAAe,MAAM;IACrB,UAAU,MAAM;IAChB,aAAa,MAAc,SAAwB;KACjD,KAAK,cAAc,MAAM,OAAO;KAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;IACjD;GACF,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAkCE;CACA,OA9BY,gBAAgB;EAC5B,MAAM;EACN,MAAM,QAAQ,EAAE,SAAS;GACvB,MAAM,UAAU,WAAW,MAAM,IAAI,CAAC,CAAC,OAAO;GAC9C,aACE,QAAQ,MAAM,KAAK,UAAU,EAAE,UAAU,EAAE,KAAK,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;EAC5F;CACF,CAuBE;CACA,MAjBW,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,MAAM;GAAE,MAAM;GAAQ,UAAU;EAAK,EAAE;EAChD,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,OAAO,MAAM,IAAI;GACvB,MAAM,UAAU,cAAc,yBAAyB,gBAAgB,KAAK,KAAK,MAAM,IAAI,CAAC;GAC5F,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAQE;CACA,UAAU,cACR,sBACA,cACM,MAAM,IAAI,CAAC,CAAC,QACpB;CACA,UAAU,cACR,sBACA,gBACM,MAAM,IAAI,CAAC,CAAC,QACpB;CACA,MAAM,cAAuC,kBAAkB,gBAAgB,MAAM,IAAI,CAAC,CAAC,IAAI;AACjG"}
|
package/src/popover.d.ts
CHANGED
|
@@ -1,44 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps, PlainComponent, PortalProps } from "./runtime.js";
|
|
2
|
+
import { Anchor, PartState, PositionOptions } from "@kirana-ui/core";
|
|
3
|
+
import { Popover as Popover$1, PopoverProps } from "@kirana-ui/core/popover";
|
|
4
|
+
import { Component, ComponentPublicInstance, Ref } from "vue";
|
|
5
|
+
/**
|
|
6
|
+
* The popover its parts are inside. Exported for a component that is made of one (a date picker
|
|
7
|
+
* provides its own to the popover's parts).
|
|
8
|
+
*/
|
|
3
9
|
declare const scope: {
|
|
4
10
|
provide(controller: Popover$1): Popover$1;
|
|
5
11
|
use(): Popover$1;
|
|
6
12
|
};
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
export type RootProps = Omit<PopoverProps, "id" | "onOpenChange"> & {
|
|
14
|
+
id?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type RootEmits = Changes<"open", boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* What a positioner's `anchor` may be: an element, a place in the viewport (an object with
|
|
19
|
+
* `getBoundingClientRect`), a template ref to an element or a component (in a template that is
|
|
20
|
+
* the element or the component's instance), or a function that gives an element or a place.
|
|
21
|
+
*/
|
|
22
|
+
export type PositionerAnchor = Anchor | ComponentPublicInstance | Ref<Anchor | ComponentPublicInstance | null | undefined> | (() => Anchor | null | undefined) | null | undefined;
|
|
23
|
+
/** A positioner's own props: where its popup goes, and what it is placed against. */
|
|
24
|
+
export interface PositionerProps extends Partial<Pick<PositionOptions, "side" | "align" | "sideOffset" | "alignOffset" | "collisionPadding" | "collisionBoundary" | "collisionAvoidance" | "sticky" | "arrowPadding" | "positionMethod">>, PartComponentProps {
|
|
25
|
+
/**
|
|
26
|
+
* What the popup is placed against, when that is not its trigger. It may change while the
|
|
27
|
+
* popup is open: the popup follows.
|
|
28
|
+
*/
|
|
29
|
+
anchor?: PositionerAnchor;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A positioner: the part's element, with where it goes as props. The one place a positioner's
|
|
33
|
+
* own props are named.
|
|
34
|
+
*/
|
|
35
|
+
export declare function positionerComponent<Placed = PartState>(name: string, use: () => {
|
|
9
36
|
positioning: Popover$1["positioning"];
|
|
10
|
-
}, element: Component):
|
|
37
|
+
}, element: Component): PartComponent<"div", Placed, PositionerProps>;
|
|
38
|
+
export interface TriggerProps extends PartComponentProps {
|
|
39
|
+
/**
|
|
40
|
+
* Whether the pointer resting on the trigger opens the popover too. A press and the keyboard
|
|
41
|
+
* still open it, and a press on one the pointer opened keeps it open. Default `false`.
|
|
42
|
+
*/
|
|
43
|
+
openOnHover?: boolean | undefined;
|
|
44
|
+
/** How long the pointer rests on the trigger before the popover opens, in milliseconds. Default 300. */
|
|
45
|
+
delay?: number | undefined;
|
|
46
|
+
/** How long after the pointer leaves a popover it opened closes, in milliseconds. Default 0. */
|
|
47
|
+
closeDelay?: number | undefined;
|
|
48
|
+
}
|
|
49
|
+
export type BackdropProps = PartComponentProps;
|
|
50
|
+
export type ArrowProps = PartComponentProps;
|
|
51
|
+
export type PopupProps = PartComponentProps;
|
|
52
|
+
export type TitleProps = PartComponentProps;
|
|
53
|
+
export type DescriptionProps = PartComponentProps;
|
|
54
|
+
export type CloseProps = PartComponentProps;
|
|
11
55
|
export declare const Popover: {
|
|
12
|
-
Root:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
Root: PlainComponent<RootProps, RootEmits>;
|
|
57
|
+
Trigger: PartComponent<"button", {
|
|
58
|
+
readonly popupOpen?: true | undefined;
|
|
59
|
+
}, TriggerProps>;
|
|
60
|
+
Portal: PlainComponent<PortalProps, {}, {}>;
|
|
61
|
+
Backdrop: PartComponent<"div", {
|
|
62
|
+
readonly open?: true | undefined;
|
|
63
|
+
readonly closed?: true | undefined;
|
|
64
|
+
readonly startingStyle?: true | undefined;
|
|
65
|
+
readonly endingStyle?: true | undefined;
|
|
66
|
+
}, PartComponentProps, {}, unknown>;
|
|
67
|
+
Positioner: PartComponent<"div", {
|
|
68
|
+
readonly open?: true | undefined;
|
|
69
|
+
readonly closed?: true | undefined;
|
|
70
|
+
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
71
|
+
readonly align?: "center" | "end" | "start" | undefined;
|
|
72
|
+
}, PositionerProps>;
|
|
73
|
+
Popup: PartComponent<"div", {
|
|
74
|
+
readonly open?: true | undefined;
|
|
75
|
+
readonly closed?: true | undefined;
|
|
76
|
+
readonly startingStyle?: true | undefined;
|
|
77
|
+
readonly endingStyle?: true | undefined;
|
|
78
|
+
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
79
|
+
readonly align?: "center" | "end" | "start" | undefined;
|
|
80
|
+
}, PartComponentProps, {}, unknown>;
|
|
81
|
+
Arrow: PartComponent<"div", {
|
|
82
|
+
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
83
|
+
readonly align?: "center" | "end" | "start" | undefined;
|
|
84
|
+
readonly uncentered?: true | undefined;
|
|
85
|
+
}, PartComponentProps, {}, unknown>;
|
|
86
|
+
Title: PartComponent<"h2", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
87
|
+
Description: PartComponent<"p", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
88
|
+
Close: PartComponent<"button", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
42
89
|
};
|
|
43
|
-
export { scope as popoverScope };
|
|
90
|
+
export { type PortalProps, scope as popoverScope };
|
|
44
91
|
//# sourceMappingURL=popover.d.ts.map
|
package/src/popover.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { context, controller, optional, partComponent, portalComponent } from "./runtime.js";
|
|
1
|
+
import { context, controller, elementOf, optional, partComponent, portalComponent } from "./runtime.js";
|
|
2
2
|
import { defined } from "@kirana-ui/core";
|
|
3
3
|
import { createPopover } from "@kirana-ui/core/popover";
|
|
4
|
-
import { defineComponent, h, useId, watchEffect } from "vue";
|
|
4
|
+
import { defineComponent, h, unref, useId, watchEffect } from "vue";
|
|
5
5
|
// src/popover.ts
|
|
6
|
+
/**
|
|
7
|
+
* The popover its parts are inside. Exported for a component that is made of one (a date picker
|
|
8
|
+
* provides its own to the popover's parts).
|
|
9
|
+
*/
|
|
6
10
|
const scope = context("Popover");
|
|
7
11
|
const Root = defineComponent({
|
|
8
12
|
name: "PopoverRoot",
|
|
9
13
|
props: {
|
|
10
14
|
open: optional(Boolean),
|
|
11
15
|
defaultOpen: Boolean,
|
|
16
|
+
modal: {
|
|
17
|
+
type: [Boolean, String],
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
12
20
|
id: String
|
|
13
21
|
},
|
|
14
22
|
emits: ["update:open", "openChange"],
|
|
@@ -18,6 +26,7 @@ const Root = defineComponent({
|
|
|
18
26
|
id: props.id ?? generated,
|
|
19
27
|
open: props.open,
|
|
20
28
|
defaultOpen: props.defaultOpen,
|
|
29
|
+
modal: props.modal,
|
|
21
30
|
onOpenChange(open, details) {
|
|
22
31
|
emit("openChange", open, details);
|
|
23
32
|
if (!details.canceled) emit("update:open", open);
|
|
@@ -26,7 +35,20 @@ const Root = defineComponent({
|
|
|
26
35
|
return () => slots.default?.();
|
|
27
36
|
}
|
|
28
37
|
});
|
|
29
|
-
|
|
38
|
+
function anchorOf(given) {
|
|
39
|
+
const named = unref(given);
|
|
40
|
+
if (typeof named === "function") {
|
|
41
|
+
const ask = named;
|
|
42
|
+
return ask() ?? ask;
|
|
43
|
+
}
|
|
44
|
+
if (!named || typeof named !== "object") return named;
|
|
45
|
+
if ("getBoundingClientRect" in named) return named;
|
|
46
|
+
return elementOf(named) ?? void 0;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A positioner: the part's element, with where it goes as props. The one place a positioner's
|
|
50
|
+
* own props are named.
|
|
51
|
+
*/
|
|
30
52
|
function positionerComponent(name, use, element) {
|
|
31
53
|
return defineComponent({
|
|
32
54
|
name,
|
|
@@ -34,23 +56,61 @@ function positionerComponent(name, use, element) {
|
|
|
34
56
|
props: {
|
|
35
57
|
side: String,
|
|
36
58
|
align: String,
|
|
37
|
-
sideOffset: Number,
|
|
38
|
-
alignOffset: Number,
|
|
39
|
-
collisionPadding: Number
|
|
59
|
+
sideOffset: [Number, Function],
|
|
60
|
+
alignOffset: [Number, Function],
|
|
61
|
+
collisionPadding: [Number, Object],
|
|
62
|
+
collisionBoundary: {
|
|
63
|
+
type: null,
|
|
64
|
+
default: void 0
|
|
65
|
+
},
|
|
66
|
+
collisionAvoidance: Object,
|
|
67
|
+
sticky: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: void 0
|
|
70
|
+
},
|
|
71
|
+
arrowPadding: Number,
|
|
72
|
+
positionMethod: String,
|
|
73
|
+
/**
|
|
74
|
+
* What the popup is placed against, when that is not its trigger. It may change while
|
|
75
|
+
* the popup is open: the popup follows.
|
|
76
|
+
*/
|
|
77
|
+
anchor: {
|
|
78
|
+
type: null,
|
|
79
|
+
default: void 0
|
|
80
|
+
}
|
|
40
81
|
},
|
|
41
82
|
setup(props, { attrs, slots }) {
|
|
42
83
|
const { positioning } = use();
|
|
43
|
-
watchEffect(() => positioning.set(defined({
|
|
84
|
+
watchEffect(() => positioning.set(defined({
|
|
85
|
+
...props,
|
|
86
|
+
anchor: anchorOf(props.anchor)
|
|
87
|
+
})), { flush: "sync" });
|
|
44
88
|
return () => h(element, attrs, slots);
|
|
45
89
|
}
|
|
46
90
|
});
|
|
47
91
|
}
|
|
92
|
+
const TriggerElement = partComponent("PopoverTriggerElement", "button", () => scope.use().trigger);
|
|
48
93
|
const Popover = {
|
|
49
94
|
Root,
|
|
50
|
-
Trigger:
|
|
95
|
+
Trigger: defineComponent({
|
|
96
|
+
name: "PopoverTrigger",
|
|
97
|
+
inheritAttrs: false,
|
|
98
|
+
props: {
|
|
99
|
+
openOnHover: Boolean,
|
|
100
|
+
delay: Number,
|
|
101
|
+
closeDelay: Number
|
|
102
|
+
},
|
|
103
|
+
setup(props, { attrs, slots }) {
|
|
104
|
+
const { hovering } = scope.use();
|
|
105
|
+
watchEffect(() => hovering.set(defined({ ...props })), { flush: "sync" });
|
|
106
|
+
return () => h(TriggerElement, attrs, slots);
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
51
109
|
Portal: portalComponent("PopoverPortal", () => scope.use().mounted),
|
|
110
|
+
Backdrop: partComponent("PopoverBackdrop", "div", () => scope.use().backdrop),
|
|
52
111
|
Positioner: positionerComponent("PopoverPositioner", () => scope.use(), partComponent("PopoverPositionerElement", "div", () => scope.use().positioner)),
|
|
53
112
|
Popup: partComponent("PopoverPopup", "div", () => scope.use().popup),
|
|
113
|
+
Arrow: partComponent("PopoverArrow", "div", () => scope.use().arrow),
|
|
54
114
|
Title: partComponent("PopoverTitle", "h2", () => scope.use().title),
|
|
55
115
|
Description: partComponent("PopoverDescription", "p", () => scope.use().description),
|
|
56
116
|
Close: partComponent("PopoverClose", "button", () => scope.use().close)
|
package/src/popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/vue/src/popover.ts"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { ChangeDetails, PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller } from \"@kirana-ui/core/popover\"\nimport { defineComponent, h, useId, watchEffect } from \"vue\"\nimport type { Component, PropType } from \"vue\"\n\nimport { context, controller, optional, partComponent, portalComponent } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"Popover\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as popoverScope }\n\nconst Root = defineComponent({\n name: \"PopoverRoot\",\n props: { open: optional(Boolean), defaultOpen: Boolean, id: String },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createPopover, () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n return () => slots.default?.()\n },\n})\n\n/** A positioner: the part's element, with where it goes as props. */\nexport function positionerComponent(\n name: string,\n use: () => { positioning: Controller[\"positioning\"] },\n element: Component\n): Component {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: {\n side: String as PropType<PositionOptions[\"side\"]>,\n align: String as PropType<PositionOptions[\"align\"]>,\n sideOffset: Number,\n alignOffset: Number,\n collisionPadding: Number,\n },\n setup(props, { attrs, slots }) {\n const { positioning } = use()\n // As they change, and before the element attaches: the first placement reads these.\n watchEffect(() => positioning.set(defined({ ...props })), { flush: \"sync\" })\n return () => h(element, attrs, slots)\n },\n })\n}\n\nexport const Popover = {\n Root,\n Trigger: partComponent(\"PopoverTrigger\", \"button\", () => scope.use().trigger),\n Portal: portalComponent(\"PopoverPortal\", () => scope.use().mounted),\n Positioner: positionerComponent(\n \"PopoverPositioner\",\n () => scope.use(),\n partComponent(\"PopoverPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent(\"PopoverPopup\", \"div\", () => scope.use().popup),\n Title: partComponent(\"PopoverTitle\", \"h2\", () => scope.use().title),\n Description: partComponent(\"PopoverDescription\", \"p\", () => scope.use().description),\n Close: partComponent(\"PopoverClose\", \"button\", () => scope.use().close),\n}\n"],"mappings":";;;;;AASA,MAAM,QAAQ,QAAoB,SAAS;AAI3C,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EAAE,MAAM,SAAS,OAAO;EAAG,aAAa;EAAS,IAAI;CAAO;CACnE,OAAO,CAAC,eAAe,YAAY;CACnC,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,sBAAsB;GAC/B,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,aAAa,MAAe,SAAwB;IAClD,KAAK,cAAc,MAAM,OAAO;IAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;GACjD;EACF,EAAE,CACJ;EACA,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAGD,SAAgB,oBACd,MACA,KACA,SACW;CACX,OAAO,gBAAgB;EACrB;EACA,cAAc;EACd,OAAO;GACL,MAAM;GACN,OAAO;GACP,YAAY;GACZ,aAAa;GACb,kBAAkB;EACpB;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,gBAAgB,IAAI;GAE5B,kBAAkB,YAAY,IAAI,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC;GAC3E,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAAC;AACH;AAEA,MAAa,UAAU;CACrB;CACA,SAAS,cAAc,kBAAkB,gBAAgB,MAAM,IAAI,CAAC,CAAC,OAAO;CAC5E,QAAQ,gBAAgB,uBAAuB,MAAM,IAAI,CAAC,CAAC,OAAO;CAClE,YAAY,oBACV,2BACM,MAAM,IAAI,GAChB,cAAc,4BAA4B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAC/E;CACA,OAAO,cAAc,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CACnE,OAAO,cAAc,gBAAgB,YAAY,MAAM,IAAI,CAAC,CAAC,KAAK;CAClE,aAAa,cAAc,sBAAsB,WAAW,MAAM,IAAI,CAAC,CAAC,WAAW;CACnF,OAAO,cAAc,gBAAgB,gBAAgB,MAAM,IAAI,CAAC,CAAC,KAAK;AACxE"}
|
|
1
|
+
{"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/vue/src/popover.ts"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { Anchor, ChangeDetails, PartState, PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller, PopoverProps } from \"@kirana-ui/core/popover\"\nimport { defineComponent, h, unref, useId, watchEffect } from \"vue\"\nimport type { Component, ComponentPublicInstance, PropType, Ref } from \"vue\"\n\nimport {\n context,\n controller,\n elementOf,\n optional,\n partComponent,\n portalComponent,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"popover\">\n\n/**\n * The popover its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the popover's parts).\n */\nconst scope = context<Controller>(\"Popover\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as popoverScope }\n\nexport type RootProps = Omit<PopoverProps, \"id\" | \"onOpenChange\"> & { id?: string | undefined }\n\nexport type RootEmits = Changes<\"open\", boolean>\n\nconst Root = defineComponent({\n name: \"PopoverRoot\",\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n modal: { type: [Boolean, String] as PropType<PopoverProps[\"modal\"]>, default: false },\n id: String,\n },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createPopover, () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n modal: props.modal,\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<RootProps, RootEmits>\n\n/**\n * What a positioner's `anchor` may be: an element, a place in the viewport (an object with\n * `getBoundingClientRect`), a template ref to an element or a component (in a template that is\n * the element or the component's instance), or a function that gives an element or a place.\n */\nexport type PositionerAnchor =\n | Anchor\n | ComponentPublicInstance\n | Ref<Anchor | ComponentPublicInstance | null | undefined>\n | (() => Anchor | null | undefined)\n | null\n | undefined\n\nfunction anchorOf(given: unknown): PositionOptions[\"anchor\"] {\n const named: unknown = unref(given)\n // A function is asked here, so a change of what it reads is followed; and given whole while\n // it has nothing, to be asked again as the popup is placed.\n if (typeof named === \"function\") {\n const ask = named as () => Anchor | null | undefined\n return ask() ?? ask\n }\n if (!named || typeof named !== \"object\") return named as null | undefined\n if (\"getBoundingClientRect\" in named) return named as Anchor\n // A component's instance.\n return elementOf(named) ?? undefined\n}\n\n/** A positioner's own props: where its popup goes, and what it is placed against. */\nexport interface PositionerProps\n extends\n Partial<\n Pick<\n PositionOptions,\n | \"side\"\n | \"align\"\n | \"sideOffset\"\n | \"alignOffset\"\n | \"collisionPadding\"\n | \"collisionBoundary\"\n | \"collisionAvoidance\"\n | \"sticky\"\n | \"arrowPadding\"\n | \"positionMethod\"\n >\n >,\n PartComponentProps {\n /**\n * What the popup is placed against, when that is not its trigger. It may change while the\n * popup is open: the popup follows.\n */\n anchor?: PositionerAnchor\n}\n\n/**\n * A positioner: the part's element, with where it goes as props. The one place a positioner's\n * own props are named.\n */\nexport function positionerComponent<Placed = PartState>(\n name: string,\n use: () => { positioning: Controller[\"positioning\"] },\n element: Component\n): PartComponent<\"div\", Placed, PositionerProps> {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: {\n side: String as PropType<PositionOptions[\"side\"]>,\n align: String as PropType<PositionOptions[\"align\"]>,\n sideOffset: [Number, Function] as PropType<PositionOptions[\"sideOffset\"]>,\n alignOffset: [Number, Function] as PropType<PositionOptions[\"alignOffset\"]>,\n collisionPadding: [Number, Object] as PropType<PositionOptions[\"collisionPadding\"]>,\n collisionBoundary: {\n type: null as unknown as PropType<PositionOptions[\"collisionBoundary\"]>,\n default: undefined as unknown,\n },\n collisionAvoidance: Object as PropType<PositionOptions[\"collisionAvoidance\"]>,\n // Left out is nothing said, not `false`: the component's own default stands.\n sticky: { type: Boolean, default: undefined as unknown },\n arrowPadding: Number,\n positionMethod: String as PropType<PositionOptions[\"positionMethod\"]>,\n /**\n * What the popup is placed against, when that is not its trigger. It may change while\n * the popup is open: the popup follows.\n */\n anchor: {\n type: null as unknown as PropType<PositionerAnchor>,\n default: undefined as unknown,\n },\n },\n setup(props, { attrs, slots }) {\n const { positioning } = use()\n // As they change, and before the element attaches: the first placement reads these.\n watchEffect(() => positioning.set(defined({ ...props, anchor: anchorOf(props.anchor) })), {\n flush: \"sync\",\n })\n return () => h(element, attrs, slots)\n },\n }) as unknown as PartComponent<\"div\", Placed, PositionerProps>\n}\n\nexport interface TriggerProps extends PartComponentProps {\n /**\n * Whether the pointer resting on the trigger opens the popover too. A press and the keyboard\n * still open it, and a press on one the pointer opened keeps it open. Default `false`.\n */\n openOnHover?: boolean | undefined\n /** How long the pointer rests on the trigger before the popover opens, in milliseconds. Default 300. */\n delay?: number | undefined\n /** How long after the pointer leaves a popover it opened closes, in milliseconds. Default 0. */\n closeDelay?: number | undefined\n}\nexport type BackdropProps = PartComponentProps\nexport type ArrowProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type TitleProps = PartComponentProps\nexport type DescriptionProps = PartComponentProps\nexport type CloseProps = PartComponentProps\n\nconst TriggerElement = partComponent<\"button\">(\n \"PopoverTriggerElement\",\n \"button\",\n () => scope.use().trigger\n)\n\nconst Trigger = defineComponent({\n name: \"PopoverTrigger\",\n inheritAttrs: false,\n props: { openOnHover: Boolean, delay: Number, closeDelay: Number },\n setup(props, { attrs, slots }) {\n const { hovering } = scope.use()\n watchEffect(() => hovering.set(defined({ ...props })), { flush: \"sync\" })\n return () => h(TriggerElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"trigger\"], TriggerProps>\n\nexport const Popover = {\n Root,\n Trigger,\n Portal: portalComponent(\"PopoverPortal\", () => scope.use().mounted),\n Backdrop: partComponent<\"div\", State[\"backdrop\"]>(\n \"PopoverBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"PopoverPositioner\",\n () => scope.use(),\n partComponent(\"PopoverPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"PopoverPopup\", \"div\", () => scope.use().popup),\n Arrow: partComponent<\"div\", State[\"arrow\"]>(\"PopoverArrow\", \"div\", () => scope.use().arrow),\n Title: partComponent<\"h2\", State[\"title\"]>(\"PopoverTitle\", \"h2\", () => scope.use().title),\n Description: partComponent<\"p\", State[\"description\"]>(\n \"PopoverDescription\",\n \"p\",\n () => scope.use().description\n ),\n Close: partComponent<\"button\", State[\"close\"]>(\"PopoverClose\", \"button\", () => scope.use().close),\n}\n"],"mappings":";;;;;;;;;AA+BA,MAAM,QAAQ,QAAoB,SAAS;AAQ3C,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,MAAM,SAAS,OAAO;EACtB,aAAa;EACb,OAAO;GAAE,MAAM,CAAC,SAAS,MAAM;GAAsC,SAAS;EAAM;EACpF,IAAI;CACN;CACA,OAAO,CAAC,eAAe,YAAY;CACnC,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,sBAAsB;GAC/B,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,OAAO,MAAM;GACb,aAAa,MAAe,SAAwB;IAClD,KAAK,cAAc,MAAM,OAAO;IAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;GACjD;EACF,EAAE,CACJ;EACA,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;AAeD,SAAS,SAAS,OAA2C;CAC3D,MAAM,QAAiB,MAAM,KAAK;CAGlC,IAAI,OAAO,UAAU,YAAY;EAC/B,MAAM,MAAM;EACZ,OAAO,IAAI,KAAK;CAClB;CACA,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,IAAI,2BAA2B,OAAO,OAAO;CAE7C,OAAO,UAAU,KAAK,KAAK,KAAA;AAC7B;;;;;AAgCA,SAAgB,oBACd,MACA,KACA,SAC+C;CAC/C,OAAO,gBAAgB;EACrB;EACA,cAAc;EACd,OAAO;GACL,MAAM;GACN,OAAO;GACP,YAAY,CAAC,QAAQ,QAAQ;GAC7B,aAAa,CAAC,QAAQ,QAAQ;GAC9B,kBAAkB,CAAC,QAAQ,MAAM;GACjC,mBAAmB;IACjB,MAAM;IACN,SAAS,KAAA;GACX;GACA,oBAAoB;GAEpB,QAAQ;IAAE,MAAM;IAAS,SAAS,KAAA;GAAqB;GACvD,cAAc;GACd,gBAAgB;;;;;GAKhB,QAAQ;IACN,MAAM;IACN,SAAS,KAAA;GACX;EACF;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,gBAAgB,IAAI;GAE5B,kBAAkB,YAAY,IAAI,QAAQ;IAAE,GAAG;IAAO,QAAQ,SAAS,MAAM,MAAM;GAAE,CAAC,CAAC,GAAG,EACxF,OAAO,OACT,CAAC;GACD,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAAC;AACH;AAoBA,MAAM,iBAAiB,cACrB,yBACA,gBACM,MAAM,IAAI,CAAC,CAAC,OACpB;AAaA,MAAa,UAAU;CACrB;CACA,SAbc,gBAAgB;EAC9B,MAAM;EACN,cAAc;EACd,OAAO;GAAE,aAAa;GAAS,OAAO;GAAQ,YAAY;EAAO;EACjE,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,aAAa,MAAM,IAAI;GAC/B,kBAAkB,SAAS,IAAI,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC;GACxE,aAAa,EAAE,gBAAgB,OAAO,KAAK;EAC7C;CACF,CAIE;CACA,QAAQ,gBAAgB,uBAAuB,MAAM,IAAI,CAAC,CAAC,OAAO;CAClE,UAAU,cACR,mBACA,aACM,MAAM,IAAI,CAAC,CAAC,QACpB;CACA,YAAY,oBACV,2BACM,MAAM,IAAI,GAChB,cAAc,4BAA4B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAC/E;CACA,OAAO,cAAqC,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CAC1F,OAAO,cAAqC,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CAC1F,OAAO,cAAoC,gBAAgB,YAAY,MAAM,IAAI,CAAC,CAAC,KAAK;CACxF,aAAa,cACX,sBACA,WACM,MAAM,IAAI,CAAC,CAAC,WACpB;CACA,OAAO,cAAwC,gBAAgB,gBAAgB,MAAM,IAAI,CAAC,CAAC,KAAK;AAClG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DefaultSlot, ElementAttributes } from "./runtime.js";
|
|
2
|
+
import { Component, DefineSetupFnComponent, PublicProps } from "vue";
|
|
3
|
+
export interface PrimitiveProps {
|
|
4
|
+
/** Another tag for the element, or a component to draw in its place; a `div` when left out. */
|
|
5
|
+
as?: string | Component | undefined;
|
|
6
|
+
/** Draws the element in its slot in place of its own: it takes the attributes given here. */
|
|
7
|
+
asChild?: boolean | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** What a `Primitive` drawn as `Tag` takes: its two props, and what the element takes. */
|
|
10
|
+
export type PrimitiveGiven<Tag extends string> = PrimitiveProps & Omit<ElementAttributes<Tag>, keyof PrimitiveProps>;
|
|
11
|
+
/**
|
|
12
|
+
* A plain element of one's own (a badge, a breadcrumb's link) with the composition a part
|
|
13
|
+
* has: `as` for another tag or component (a `div` unless said), or with `as-child` the
|
|
14
|
+
* caller's own element in its slot. By a part's rule: the slotted element's own props lie
|
|
15
|
+
* over the attributes on the `Primitive`, classes join, styles are merged, and both listeners
|
|
16
|
+
* of an event run, the `Primitive`'s first.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Primitive: new <As extends string = "div">(props: PrimitiveGiven<As> & {
|
|
19
|
+
as?: As | Component | undefined;
|
|
20
|
+
} & PublicProps) => InstanceType<DefineSetupFnComponent<PrimitiveGiven<As>, {}, DefaultSlot<{}>>>;
|
|
21
|
+
//# sourceMappingURL=primitive.d.ts.map
|
package/src/primitive.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { draw } from "./element.js";
|
|
2
|
+
import { defineComponent } from "vue";
|
|
3
|
+
// src/primitive.ts
|
|
4
|
+
/**
|
|
5
|
+
* A plain element of one's own (a badge, a breadcrumb's link) with the composition a part
|
|
6
|
+
* has: `as` for another tag or component (a `div` unless said), or with `as-child` the
|
|
7
|
+
* caller's own element in its slot. By a part's rule: the slotted element's own props lie
|
|
8
|
+
* over the attributes on the `Primitive`, classes join, styles are merged, and both listeners
|
|
9
|
+
* of an event run, the `Primitive`'s first.
|
|
10
|
+
*/
|
|
11
|
+
const Primitive = defineComponent({
|
|
12
|
+
name: "Primitive",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
as: {
|
|
16
|
+
type: [String, Object],
|
|
17
|
+
default: "div"
|
|
18
|
+
},
|
|
19
|
+
asChild: Boolean
|
|
20
|
+
},
|
|
21
|
+
setup(props, { attrs, slots }) {
|
|
22
|
+
return () => draw(props.as, props.asChild, attrs, slots.default?.());
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export { Primitive };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=primitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.js","names":[],"sources":["../../../../packages/vue/src/primitive.ts"],"sourcesContent":["import { defineComponent } from \"vue\"\nimport type { Component, DefineSetupFnComponent, PropType, PublicProps } from \"vue\"\n\nimport { draw } from \"./element.ts\"\nimport type { DefaultSlot, ElementAttributes } from \"./runtime.ts\"\n\nexport interface PrimitiveProps {\n /** Another tag for the element, or a component to draw in its place; a `div` when left out. */\n as?: string | Component | undefined\n /** Draws the element in its slot in place of its own: it takes the attributes given here. */\n asChild?: boolean | undefined\n}\n\n/** What a `Primitive` drawn as `Tag` takes: its two props, and what the element takes. */\nexport type PrimitiveGiven<Tag extends string> = PrimitiveProps &\n Omit<ElementAttributes<Tag>, keyof PrimitiveProps>\n\n/**\n * A plain element of one's own (a badge, a breadcrumb's link) with the composition a part\n * has: `as` for another tag or component (a `div` unless said), or with `as-child` the\n * caller's own element in its slot. By a part's rule: the slotted element's own props lie\n * over the attributes on the `Primitive`, classes join, styles are merged, and both listeners\n * of an event run, the `Primitive`'s first.\n */\nexport const Primitive = defineComponent({\n name: \"Primitive\",\n inheritAttrs: false,\n props: {\n as: { type: [String, Object] as PropType<string | Component>, default: \"div\" },\n asChild: Boolean,\n },\n setup(props, { attrs, slots }) {\n return () => draw(props.as, props.asChild, attrs, slots.default?.())\n },\n}) as unknown as new <As extends string = \"div\">(\n props: PrimitiveGiven<As> & { as?: As | Component | undefined } & PublicProps\n) => InstanceType<DefineSetupFnComponent<PrimitiveGiven<As>, {}, DefaultSlot<{}>>>\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,YAAY,gBAAgB;CACvC,MAAM;CACN,cAAc;CACd,OAAO;EACL,IAAI;GAAE,MAAM,CAAC,QAAQ,MAAM;GAAmC,SAAS;EAAM;EAC7E,SAAS;CACX;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,aAAa,KAAK,MAAM,IAAI,MAAM,SAAS,OAAO,MAAM,UAAU,CAAC;CACrE;AACF,CAAC"}
|
package/src/progress.d.ts
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
|
+
import { IndicatorProps, LabelProps, RootProps, TrackProps, ValueGiven, ValueProps, valueBar } from "./value-bar.js";
|
|
2
|
+
import { PartComponent, PartComponentProps } from "./runtime.js";
|
|
1
3
|
export declare const Progress: {
|
|
2
|
-
Root:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
Track: import("vue").Component;
|
|
28
|
-
Indicator: import("vue").Component;
|
|
29
|
-
Value: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
30
|
-
[key: string]: any;
|
|
31
|
-
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
32
|
-
Label: import("vue").Component;
|
|
4
|
+
Root: PartComponent<"div", {
|
|
5
|
+
readonly progressing?: true | undefined;
|
|
6
|
+
readonly complete?: true | undefined;
|
|
7
|
+
readonly indeterminate?: true | undefined;
|
|
8
|
+
}, RootProps<number | null>>;
|
|
9
|
+
Track: PartComponent<"div", {
|
|
10
|
+
readonly progressing?: true | undefined;
|
|
11
|
+
readonly complete?: true | undefined;
|
|
12
|
+
readonly indeterminate?: true | undefined;
|
|
13
|
+
}, PartComponentProps, {}, unknown>;
|
|
14
|
+
Indicator: PartComponent<"div", {
|
|
15
|
+
readonly progressing?: true | undefined;
|
|
16
|
+
readonly complete?: true | undefined;
|
|
17
|
+
readonly indeterminate?: true | undefined;
|
|
18
|
+
}, PartComponentProps, {}, unknown>;
|
|
19
|
+
Value: PartComponent<"span", {
|
|
20
|
+
readonly progressing?: true | undefined;
|
|
21
|
+
readonly complete?: true | undefined;
|
|
22
|
+
readonly indeterminate?: true | undefined;
|
|
23
|
+
}, PartComponentProps, {}, ValueGiven>;
|
|
24
|
+
Label: PartComponent<"span", {
|
|
25
|
+
readonly progressing?: true | undefined;
|
|
26
|
+
readonly complete?: true | undefined;
|
|
27
|
+
readonly indeterminate?: true | undefined;
|
|
28
|
+
}, PartComponentProps, {}, unknown>;
|
|
33
29
|
};
|
|
30
|
+
export type { IndicatorProps, LabelProps, RootProps, TrackProps, ValueGiven, ValueProps, valueBar };
|
|
34
31
|
//# sourceMappingURL=progress.d.ts.map
|
package/src/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/vue/src/progress.ts"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { valueBar } from \"./value-bar.ts\"\n\nexport const Progress = valueBar(\"Progress\", createProgress)\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/vue/src/progress.ts"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport type { StatesOf } from \"./runtime.ts\"\nimport { valueBar } from \"./value-bar.ts\"\n\nexport type * from \"./value-bar.ts\"\n\nexport const Progress = valueBar<StatesOf<\"progress\">>(\"Progress\", createProgress)\n"],"mappings":";;;AAOA,MAAa,WAAW,SAA+B,YAAY,cAAc"}
|
package/src/qr-code.d.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PartComponent, PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
3
|
+
export type RootProps = Omit<QrCodeProps, "id"> & {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
} & PartComponentProps;
|
|
6
|
+
export type FrameProps = PartComponentProps;
|
|
7
|
+
export type PatternProps = PartComponentProps;
|
|
3
8
|
export declare const QrCode: {
|
|
4
|
-
Root:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
correction: PropType<QrCorrection>;
|
|
10
|
-
id: StringConstructor;
|
|
11
|
-
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
-
value: {
|
|
15
|
-
type: StringConstructor;
|
|
16
|
-
required: true;
|
|
17
|
-
};
|
|
18
|
-
correction: PropType<QrCorrection>;
|
|
19
|
-
id: StringConstructor;
|
|
20
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
21
|
-
Frame: import("vue").Component;
|
|
22
|
-
Pattern: import("vue").Component;
|
|
9
|
+
Root: PartComponent<"div", {
|
|
10
|
+
readonly invalid?: true | undefined;
|
|
11
|
+
}, RootProps>;
|
|
12
|
+
Frame: PartComponent<"svg", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
13
|
+
Pattern: PartComponent<"path", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
23
14
|
};
|
|
24
15
|
//# sourceMappingURL=qr-code.d.ts.map
|
package/src/qr-code.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/vue/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCorrection } from \"@kirana-ui/core/qr-code\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { context, controller, partComponent } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"QrCode\")\n\nconst RootElement = partComponent(\"QrCodeRootElement\", \"div\", () => scope.use().root)\n\nconst Root = defineComponent({\n name: \"QrCodeRoot\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n correction: String as PropType<QrCorrection>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n scope.provide(\n controller(createQrCode, () => ({\n id: props.id ?? generated,\n value: props.value,\n correction: props.correction,\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n})\n\nconst Frame = partComponent(\"QrCodeFrame\", \"svg\", () => scope.use().frame)\nconst Pattern = partComponent(\"QrCodePattern\"
|
|
1
|
+
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/vue/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCodeProps, QrCorrection } from \"@kirana-ui/core/qr-code\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { context, controller, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"qrCode\">\n\nconst scope = context<Controller>(\"QrCode\")\n\nconst RootElement = partComponent(\"QrCodeRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<QrCodeProps, \"id\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nconst Root = defineComponent({\n name: \"QrCodeRoot\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n correction: String as PropType<QrCorrection>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n scope.provide(\n controller(createQrCode, () => ({\n id: props.id ?? generated,\n value: props.value,\n correction: props.correction,\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps>\n\nexport type FrameProps = PartComponentProps\nexport type PatternProps = PartComponentProps\nconst Frame = partComponent<\"svg\", State[\"frame\"]>(\"QrCodeFrame\", \"svg\", () => scope.use().frame)\nconst Pattern = partComponent<\"path\", State[\"pattern\"]>(\n \"QrCodePattern\",\n \"path\",\n () => scope.use().pattern\n)\n\nexport const QrCode = { Root, Frame, Pattern }\n"],"mappings":";;;;AAUA,MAAM,QAAQ,QAAoB,QAAQ;AAE1C,MAAM,cAAc,cAAc,qBAAqB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAoCpF,MAAa,SAAS;CAAE,MA9BX,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAQ,UAAU;GAAK;GACtC,YAAY;GACZ,IAAI;EACN;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,YAAY,MAAM;GACxB,MAAM,QACJ,WAAW,qBAAqB;IAC9B,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,YAAY,MAAM;GACpB,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAWwB;CAAM,OAPhB,cAAqC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAO7D;CAAO,SANrB,cACd,iBACA,cACM,MAAM,IAAI,CAAC,CAAC,OAGiB;AAAQ"}
|
package/src/radio-group.d.ts
CHANGED
|
@@ -1,78 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps, PartGiven, PartInstance, StatesOf } from "./runtime.js";
|
|
2
|
+
import { PublicProps } from "vue";
|
|
3
|
+
import { RadioGroupProps, RadioItemOptions } from "@kirana-ui/core/radio-group";
|
|
4
|
+
type State = StatesOf<"radioGroup">;
|
|
5
|
+
export type RootProps<Value = unknown> = Omit<RadioGroupProps<Value>, "id" | "onValueChange"> & {
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
} & PartComponentProps;
|
|
8
|
+
/** The value is `null` when the group is put back to none chosen. */
|
|
9
|
+
export type RootEmits<Value = unknown> = Changes<"value", Value | null>;
|
|
10
|
+
export interface ItemProps extends RadioItemOptions, PartComponentProps {
|
|
11
|
+
/** What the group's value is while this item is the chosen one. */
|
|
12
|
+
value: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface IndicatorProps extends PartComponentProps {
|
|
15
|
+
/** Keeps the mark in the page while its item is not the chosen one. */
|
|
16
|
+
keepMounted?: boolean | undefined;
|
|
17
|
+
}
|
|
2
18
|
export declare const RadioGroup: {
|
|
3
|
-
Root:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: PropType<unknown>;
|
|
23
|
-
default: unknown;
|
|
24
|
-
};
|
|
25
|
-
defaultValue: {
|
|
26
|
-
type: PropType<unknown>;
|
|
27
|
-
default: unknown;
|
|
28
|
-
};
|
|
29
|
-
disabled: BooleanConstructor;
|
|
30
|
-
readOnly: BooleanConstructor;
|
|
31
|
-
required: BooleanConstructor;
|
|
32
|
-
name: StringConstructor;
|
|
33
|
-
form: StringConstructor;
|
|
34
|
-
id: StringConstructor;
|
|
35
|
-
}>> & Readonly<{
|
|
36
|
-
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
37
|
-
onValueChange?: ((...args: any[]) => any) | undefined;
|
|
38
|
-
}>, {
|
|
39
|
-
value: unknown;
|
|
40
|
-
defaultValue: unknown;
|
|
41
|
-
disabled: boolean;
|
|
42
|
-
readOnly: boolean;
|
|
43
|
-
required: boolean;
|
|
44
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
45
|
-
Item: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
46
|
-
value: {
|
|
47
|
-
type: PropType<unknown>;
|
|
48
|
-
required: true;
|
|
49
|
-
};
|
|
50
|
-
disabled: {
|
|
51
|
-
type: BooleanConstructor;
|
|
52
|
-
default: undefined;
|
|
53
|
-
};
|
|
54
|
-
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
55
|
-
[key: string]: any;
|
|
56
|
-
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
57
|
-
value: {
|
|
58
|
-
type: PropType<unknown>;
|
|
59
|
-
required: true;
|
|
60
|
-
};
|
|
61
|
-
disabled: {
|
|
62
|
-
type: BooleanConstructor;
|
|
63
|
-
default: undefined;
|
|
64
|
-
};
|
|
65
|
-
}>> & Readonly<{}>, {
|
|
66
|
-
disabled: boolean;
|
|
67
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
68
|
-
Indicator: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
69
|
-
keepMounted: BooleanConstructor;
|
|
70
|
-
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
71
|
-
[key: string]: any;
|
|
72
|
-
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
73
|
-
keepMounted: BooleanConstructor;
|
|
74
|
-
}>> & Readonly<{}>, {
|
|
75
|
-
keepMounted: boolean;
|
|
76
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
19
|
+
Root: new <Value = unknown, As extends string = "div">(props: PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps) => PartInstance<As, RootProps<Value>, RootEmits<Value>, {
|
|
20
|
+
state: State["root"];
|
|
21
|
+
}>;
|
|
22
|
+
Item: PartComponent<"span", {
|
|
23
|
+
readonly checked?: true | undefined;
|
|
24
|
+
readonly unchecked?: true | undefined;
|
|
25
|
+
readonly disabled?: true | undefined;
|
|
26
|
+
readonly readonly?: true | undefined;
|
|
27
|
+
readonly required?: true | undefined;
|
|
28
|
+
}, ItemProps>;
|
|
29
|
+
Indicator: PartComponent<"span", {
|
|
30
|
+
readonly checked?: true | undefined;
|
|
31
|
+
readonly unchecked?: true | undefined;
|
|
32
|
+
readonly disabled?: true | undefined;
|
|
33
|
+
readonly readonly?: true | undefined;
|
|
34
|
+
readonly required?: true | undefined;
|
|
35
|
+
readonly startingStyle?: true | undefined;
|
|
36
|
+
readonly endingStyle?: true | undefined;
|
|
37
|
+
}, IndicatorProps>;
|
|
77
38
|
};
|
|
39
|
+
export {};
|
|
78
40
|
//# sourceMappingURL=radio-group.d.ts.map
|