@kirana-ui/vue 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -0
- package/llms.txt +1779 -182
- package/package.json +48 -3
- package/skills/kirana-ui-primitives/SKILL.md +53 -12
- package/src/accordion.d.ts +4 -0
- package/src/accordion.js +6 -0
- package/src/accordion.js.map +1 -1
- package/src/alert-dialog.d.ts +2 -2
- package/src/autocomplete.d.ts +2 -2
- package/src/avatar.d.ts +31 -4
- package/src/avatar.js +40 -16
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -1
- package/src/button.js +4 -1
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +22 -13
- package/src/calendar.js +83 -12
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +5 -2
- package/src/carousel.js +1 -4
- 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 +17 -0
- package/src/checkbox.js +9 -2
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +2 -0
- package/src/color-picker.d.ts +118 -0
- package/src/color-picker.js +174 -0
- package/src/color-picker.js.map +1 -0
- package/src/combobox.d.ts +105 -5
- package/src/combobox.js +83 -12
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +2 -2
- package/src/command.js +3 -1
- package/src/command.js.map +1 -1
- package/src/date-field.d.ts +1 -1
- package/src/date-field.js +2 -0
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +39 -13
- package/src/date-picker.js +104 -51
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +41 -8
- package/src/dialog.js +44 -8
- package/src/dialog.js.map +1 -1
- package/src/drawer.d.ts +2 -2
- package/src/editable.d.ts +87 -0
- package/src/editable.js +83 -0
- package/src/editable.js.map +1 -0
- package/src/element.js +5 -5
- package/src/element.js.map +1 -1
- package/src/file-upload.d.ts +76 -0
- package/src/file-upload.js +139 -0
- package/src/file-upload.js.map +1 -0
- package/src/hover-card.d.ts +3 -0
- package/src/index.d.ts +28 -7
- package/src/index.js +12 -1
- package/src/menu.d.ts +10 -0
- package/src/menu.js +17 -6
- package/src/menu.js.map +1 -1
- package/src/menubar.js +10 -1
- package/src/menubar.js.map +1 -1
- package/src/navigation-menu.d.ts +14 -3
- package/src/navigation-menu.js +20 -2
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +33 -1
- package/src/number-field.js +98 -68
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +25 -3
- package/src/otp.js +22 -3
- package/src/otp.js.map +1 -1
- package/src/password-input.d.ts +37 -0
- package/src/password-input.js +44 -0
- package/src/password-input.js.map +1 -0
- package/src/popover.d.ts +32 -4
- package/src/popover.js +37 -5
- package/src/popover.js.map +1 -1
- package/src/radio-group.d.ts +12 -0
- package/src/radio-group.js +6 -2
- package/src/radio-group.js.map +1 -1
- package/src/rating.d.ts +34 -0
- package/src/rating.js +81 -0
- package/src/rating.js.map +1 -0
- package/src/runtime.d.ts +2 -1
- package/src/runtime.js +5 -2
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +24 -1
- package/src/select.d.ts +39 -5
- package/src/select.js +30 -9
- package/src/select.js.map +1 -1
- package/src/slider.d.ts +35 -0
- package/src/slider.js +1 -0
- package/src/slider.js.map +1 -1
- package/src/steps.d.ts +74 -0
- package/src/steps.js +84 -0
- package/src/steps.js.map +1 -0
- package/src/switch.d.ts +12 -0
- package/src/tabs.d.ts +2 -0
- package/src/tabs.js +5 -0
- package/src/tabs.js.map +1 -1
- package/src/tags-input.d.ts +69 -0
- package/src/tags-input.js +145 -0
- package/src/tags-input.js.map +1 -0
- package/src/time-field.d.ts +41 -0
- package/src/time-field.js +85 -0
- package/src/time-field.js.map +1 -0
- package/src/toast.d.ts +12 -4
- package/src/toggle-group.js +6 -0
- package/src/toggle-group.js.map +1 -1
- package/src/toolbar-context.d.ts +1 -1
- package/src/toolbar.d.ts +4 -1
- package/src/toolbar.js +17 -2
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +5 -0
- package/src/tour.d.ts +75 -0
- package/src/tour.js +95 -0
- package/src/tour.js.map +1 -0
- package/src/tree.d.ts +69 -0
- package/src/tree.js +118 -0
- package/src/tree.js.map +1 -0
package/src/dialog.d.ts
CHANGED
|
@@ -9,17 +9,22 @@ export type RootEmits = Changes<"open", boolean>;
|
|
|
9
9
|
export type AlertRootProps = Omit<AlertDialogProps, "id" | "onOpenChange"> & {
|
|
10
10
|
id?: string | undefined;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export interface TriggerProps extends PartComponentProps {
|
|
13
|
+
/** It cannot be pressed: the button is disabled, and says so (`data-disabled`). */
|
|
14
|
+
disabled?: boolean | undefined;
|
|
15
|
+
}
|
|
13
16
|
export type BackdropProps = PartComponentProps;
|
|
17
|
+
export type ViewportProps = PartComponentProps;
|
|
14
18
|
export type PopupProps = PartComponentProps;
|
|
15
19
|
export type TitleProps = PartComponentProps;
|
|
16
20
|
export type DescriptionProps = PartComponentProps;
|
|
17
|
-
export type CloseProps =
|
|
21
|
+
export type CloseProps = TriggerProps;
|
|
18
22
|
export declare const Dialog: {
|
|
19
23
|
Root: PlainComponent<RootProps, RootEmits>;
|
|
20
24
|
Trigger: PartComponent<"button", {
|
|
21
25
|
readonly popupOpen?: true | undefined;
|
|
22
|
-
|
|
26
|
+
readonly disabled?: true | undefined;
|
|
27
|
+
}, TriggerProps>;
|
|
23
28
|
Portal: PlainComponent<PortalProps, {}, {}>;
|
|
24
29
|
Backdrop: PartComponent<"div", {
|
|
25
30
|
readonly open?: true | undefined;
|
|
@@ -27,22 +32,35 @@ export declare const Dialog: {
|
|
|
27
32
|
readonly startingStyle?: true | undefined;
|
|
28
33
|
readonly endingStyle?: true | undefined;
|
|
29
34
|
}, PartComponentProps, {}, unknown>;
|
|
35
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
36
|
+
Viewport: PartComponent<"div", {
|
|
37
|
+
readonly open?: true | undefined;
|
|
38
|
+
readonly closed?: true | undefined;
|
|
39
|
+
readonly startingStyle?: true | undefined;
|
|
40
|
+
readonly endingStyle?: true | undefined;
|
|
41
|
+
readonly nested?: true | undefined;
|
|
42
|
+
readonly nestedDialogOpen?: true | undefined;
|
|
43
|
+
}, PartComponentProps, {}, unknown>;
|
|
30
44
|
Popup: PartComponent<"div", {
|
|
31
45
|
readonly open?: true | undefined;
|
|
32
46
|
readonly closed?: true | undefined;
|
|
33
47
|
readonly startingStyle?: true | undefined;
|
|
34
48
|
readonly endingStyle?: true | undefined;
|
|
49
|
+
readonly nested?: true | undefined;
|
|
35
50
|
readonly nestedDialogOpen?: true | undefined;
|
|
36
51
|
}, PartComponentProps, {}, unknown>;
|
|
37
52
|
Title: PartComponent<"h2", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
38
53
|
Description: PartComponent<"p", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
39
|
-
Close: PartComponent<"button",
|
|
54
|
+
Close: PartComponent<"button", {
|
|
55
|
+
readonly disabled?: true | undefined;
|
|
56
|
+
}, TriggerProps>;
|
|
40
57
|
};
|
|
41
58
|
/** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */
|
|
42
59
|
export declare const AlertDialog: {
|
|
43
60
|
Trigger: PartComponent<"button", {
|
|
44
61
|
readonly popupOpen?: true | undefined;
|
|
45
|
-
|
|
62
|
+
readonly disabled?: true | undefined;
|
|
63
|
+
}, TriggerProps>;
|
|
46
64
|
Portal: PlainComponent<PortalProps, {}, {}>;
|
|
47
65
|
Backdrop: PartComponent<"div", {
|
|
48
66
|
readonly open?: true | undefined;
|
|
@@ -50,16 +68,28 @@ export declare const AlertDialog: {
|
|
|
50
68
|
readonly startingStyle?: true | undefined;
|
|
51
69
|
readonly endingStyle?: true | undefined;
|
|
52
70
|
}, PartComponentProps, {}, unknown>;
|
|
71
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
72
|
+
Viewport: PartComponent<"div", {
|
|
73
|
+
readonly open?: true | undefined;
|
|
74
|
+
readonly closed?: true | undefined;
|
|
75
|
+
readonly startingStyle?: true | undefined;
|
|
76
|
+
readonly endingStyle?: true | undefined;
|
|
77
|
+
readonly nested?: true | undefined;
|
|
78
|
+
readonly nestedDialogOpen?: true | undefined;
|
|
79
|
+
}, PartComponentProps, {}, unknown>;
|
|
53
80
|
Popup: PartComponent<"div", {
|
|
54
81
|
readonly open?: true | undefined;
|
|
55
82
|
readonly closed?: true | undefined;
|
|
56
83
|
readonly startingStyle?: true | undefined;
|
|
57
84
|
readonly endingStyle?: true | undefined;
|
|
85
|
+
readonly nested?: true | undefined;
|
|
58
86
|
readonly nestedDialogOpen?: true | undefined;
|
|
59
87
|
}, PartComponentProps, {}, unknown>;
|
|
60
88
|
Title: PartComponent<"h2", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
61
89
|
Description: PartComponent<"p", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
62
|
-
Close: PartComponent<"button",
|
|
90
|
+
Close: PartComponent<"button", {
|
|
91
|
+
readonly disabled?: true | undefined;
|
|
92
|
+
}, TriggerProps>;
|
|
63
93
|
Root: PlainComponent<AlertRootProps, RootEmits>;
|
|
64
94
|
};
|
|
65
95
|
export type DrawerRootProps = Omit<DrawerProps, "id" | "onOpenChange" | "onSnapPointChange"> & {
|
|
@@ -70,11 +100,14 @@ export type DrawerRootEmits = Changes<"open", boolean> & Changes<"snapPoint", Dr
|
|
|
70
100
|
export declare const Drawer: {
|
|
71
101
|
Trigger: PartComponent<"button", {
|
|
72
102
|
readonly popupOpen?: true | undefined;
|
|
73
|
-
|
|
103
|
+
readonly disabled?: true | undefined;
|
|
104
|
+
}, TriggerProps>;
|
|
74
105
|
Portal: PlainComponent<PortalProps, {}, {}>;
|
|
75
106
|
Title: PartComponent<"h2", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
76
107
|
Description: PartComponent<"p", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
77
|
-
Close: PartComponent<"button",
|
|
108
|
+
Close: PartComponent<"button", {
|
|
109
|
+
readonly disabled?: true | undefined;
|
|
110
|
+
}, TriggerProps>;
|
|
78
111
|
Root: PlainComponent<DrawerRootProps, DrawerRootEmits>;
|
|
79
112
|
Backdrop: PartComponent<"div", StatesOf<"drawer">["backdrop"]>;
|
|
80
113
|
Popup: PartComponent<"div", StatesOf<"drawer">["popup"]>;
|
package/src/dialog.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useDirectionAround } from "./direction-context.js";
|
|
2
|
+
import { context, controller, optional, partComponent, portalComponent, toSignal } from "./runtime.js";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { defineComponent, h, useId } from "vue";
|
|
3
5
|
import { createAlertDialog } from "@kirana-ui/core/alert-dialog";
|
|
4
6
|
import { createDialog } from "@kirana-ui/core/dialog";
|
|
5
7
|
import { createDrawer } from "@kirana-ui/core/drawer";
|
|
@@ -14,6 +16,12 @@ const Root = defineComponent({
|
|
|
14
16
|
type: Boolean,
|
|
15
17
|
default: true
|
|
16
18
|
},
|
|
19
|
+
disablePointerDismissal: optional(Boolean),
|
|
20
|
+
/**
|
|
21
|
+
* Whether a press outside closes it.
|
|
22
|
+
* @deprecated Base UI's name is `disablePointerDismissal`, the other way round, which wins.
|
|
23
|
+
*/
|
|
24
|
+
closeOnOutsidePress: optional(Boolean),
|
|
17
25
|
dismissible: {
|
|
18
26
|
type: Boolean,
|
|
19
27
|
default: true
|
|
@@ -23,11 +31,13 @@ const Root = defineComponent({
|
|
|
23
31
|
emits: ["update:open", "openChange"],
|
|
24
32
|
setup(props, { slots, emit }) {
|
|
25
33
|
const generated = useId();
|
|
26
|
-
scope.provide(controller(createDialog, () => ({
|
|
34
|
+
scope.provide(controller(within(createDialog, { direction: useDirectionAround() }), () => ({
|
|
27
35
|
id: props.id ?? generated,
|
|
28
36
|
open: props.open,
|
|
29
37
|
defaultOpen: props.defaultOpen,
|
|
30
38
|
modal: props.modal,
|
|
39
|
+
disablePointerDismissal: props.disablePointerDismissal,
|
|
40
|
+
closeOnOutsidePress: props.closeOnOutsidePress,
|
|
31
41
|
dismissible: props.dismissible,
|
|
32
42
|
onOpenChange(open, details) {
|
|
33
43
|
emit("openChange", open, details);
|
|
@@ -47,7 +57,7 @@ const AlertRoot = defineComponent({
|
|
|
47
57
|
emits: ["update:open", "openChange"],
|
|
48
58
|
setup(props, { slots, emit }) {
|
|
49
59
|
const generated = useId();
|
|
50
|
-
scope.provide(controller(createAlertDialog, () => ({
|
|
60
|
+
scope.provide(controller(within(createAlertDialog, { direction: useDirectionAround() }), () => ({
|
|
51
61
|
id: props.id ?? generated,
|
|
52
62
|
open: props.open,
|
|
53
63
|
defaultOpen: props.defaultOpen,
|
|
@@ -59,15 +69,32 @@ const AlertRoot = defineComponent({
|
|
|
59
69
|
return () => slots.default?.();
|
|
60
70
|
}
|
|
61
71
|
});
|
|
72
|
+
/** A trigger or a close button, with its own `disabled`. */
|
|
73
|
+
function button(name, which) {
|
|
74
|
+
return defineComponent({
|
|
75
|
+
name,
|
|
76
|
+
inheritAttrs: false,
|
|
77
|
+
props: { disabled: Boolean },
|
|
78
|
+
setup(props, { attrs, slots }) {
|
|
79
|
+
const options = toSignal(() => ({ disabled: props.disabled }));
|
|
80
|
+
const made = scope.use();
|
|
81
|
+
const part = (which === "trigger" ? made.triggerPart : made.closePart)(() => options.get());
|
|
82
|
+
const Element = partComponent(`${name}Element`, "button", () => part);
|
|
83
|
+
return () => h(Element, attrs, slots);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
62
87
|
const Dialog = {
|
|
63
88
|
Root,
|
|
64
|
-
Trigger:
|
|
89
|
+
Trigger: button("DialogTrigger", "trigger"),
|
|
65
90
|
Portal: portalComponent("DialogPortal", () => scope.use().mounted),
|
|
66
91
|
Backdrop: partComponent("DialogBackdrop", "div", () => scope.use().backdrop),
|
|
92
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
93
|
+
Viewport: partComponent("DialogViewport", "div", () => scope.use().viewport),
|
|
67
94
|
Popup: partComponent("DialogPopup", "div", () => scope.use().popup),
|
|
68
95
|
Title: partComponent("DialogTitle", "h2", () => scope.use().title),
|
|
69
96
|
Description: partComponent("DialogDescription", "p", () => scope.use().description),
|
|
70
|
-
Close:
|
|
97
|
+
Close: button("DialogClose", "close")
|
|
71
98
|
};
|
|
72
99
|
/** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */
|
|
73
100
|
const AlertDialog = {
|
|
@@ -83,6 +110,12 @@ const DrawerRoot = defineComponent({
|
|
|
83
110
|
type: Boolean,
|
|
84
111
|
default: true
|
|
85
112
|
},
|
|
113
|
+
disablePointerDismissal: optional(Boolean),
|
|
114
|
+
/**
|
|
115
|
+
* Whether a press outside closes it.
|
|
116
|
+
* @deprecated Base UI's name is `disablePointerDismissal`, the other way round, which wins.
|
|
117
|
+
*/
|
|
118
|
+
closeOnOutsidePress: optional(Boolean),
|
|
86
119
|
dismissible: {
|
|
87
120
|
type: Boolean,
|
|
88
121
|
default: true
|
|
@@ -101,11 +134,13 @@ const DrawerRoot = defineComponent({
|
|
|
101
134
|
],
|
|
102
135
|
setup(props, { slots, emit }) {
|
|
103
136
|
const generated = useId();
|
|
104
|
-
scope.provide(controller(createDrawer, () => ({
|
|
137
|
+
scope.provide(controller(within(createDrawer, { direction: useDirectionAround() }), () => ({
|
|
105
138
|
id: props.id ?? generated,
|
|
106
139
|
open: props.open,
|
|
107
140
|
defaultOpen: props.defaultOpen,
|
|
108
141
|
modal: props.modal,
|
|
142
|
+
disablePointerDismissal: props.disablePointerDismissal,
|
|
143
|
+
closeOnOutsidePress: props.closeOnOutsidePress,
|
|
109
144
|
dismissible: props.dismissible,
|
|
110
145
|
swipeDirection: props.swipeDirection,
|
|
111
146
|
snapPoints: props.snapPoints,
|
|
@@ -123,9 +158,10 @@ const DrawerRoot = defineComponent({
|
|
|
123
158
|
return () => slots.default?.();
|
|
124
159
|
}
|
|
125
160
|
});
|
|
161
|
+
const { Viewport: _, ...shared } = Dialog;
|
|
126
162
|
/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
|
|
127
163
|
const Drawer = {
|
|
128
|
-
...
|
|
164
|
+
...shared,
|
|
129
165
|
Root: DrawerRoot,
|
|
130
166
|
Backdrop: Dialog.Backdrop,
|
|
131
167
|
Popup: Dialog.Popup
|
package/src/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":[],"sources":["../../../../packages/vue/src/dialog.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createAlertDialog } from \"@kirana-ui/core/alert-dialog\"\nimport type { AlertDialogProps } from \"@kirana-ui/core/alert-dialog\"\nimport { createDialog } from \"@kirana-ui/core/dialog\"\nimport { createDrawer } from \"@kirana-ui/core/drawer\"\nimport type { DrawerProps, DrawerSide, DrawerSnapPoint } from \"@kirana-ui/core/drawer\"\nimport type { Dialog as Controller, DialogProps } from \"@kirana-ui/core/dialog\"\nimport { defineComponent, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { context, controller, optional, partComponent, portalComponent } 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<\"dialog\">\n\nconst scope = context<Controller>(\"Dialog\")\n\nexport type RootProps = Omit<DialogProps, \"id\" | \"onOpenChange\"> & { id?: string | undefined }\n\nexport type RootEmits = Changes<\"open\", boolean>\n\nconst Root = defineComponent({\n name: \"DialogRoot\",\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n modal: { type: Boolean, default: true },\n dismissible: { type: Boolean, default: true },\n id: String,\n },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createDialog, () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n modal: props.modal,\n dismissible: props.dismissible,\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\nexport type AlertRootProps = Omit<AlertDialogProps, \"id\" | \"onOpenChange\"> & {\n id?: string | undefined\n}\n\nconst AlertRoot = defineComponent({\n name: \"AlertDialogRoot\",\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(createAlertDialog, () => ({\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}) as unknown as PlainComponent<AlertRootProps, RootEmits>\n\nexport type TriggerProps = PartComponentProps\nexport type BackdropProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type TitleProps = PartComponentProps\nexport type DescriptionProps = PartComponentProps\nexport type CloseProps = PartComponentProps\nexport const Dialog = {\n Root,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"DialogTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Portal: portalComponent(\"DialogPortal\", () => scope.use().mounted),\n Backdrop: partComponent<\"div\", State[\"backdrop\"]>(\n \"DialogBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"DialogPopup\", \"div\", () => scope.use().popup),\n Title: partComponent<\"h2\", State[\"title\"]>(\"DialogTitle\", \"h2\", () => scope.use().title),\n Description: partComponent<\"p\", State[\"description\"]>(\n \"DialogDescription\",\n \"p\",\n () => scope.use().description\n ),\n Close: partComponent<\"button\", State[\"close\"]>(\"DialogClose\", \"button\", () => scope.use().close),\n}\n\n/** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */\nexport const AlertDialog = { ...Dialog, Root: AlertRoot }\n\nexport type DrawerRootProps = Omit<DrawerProps, \"id\" | \"onOpenChange\" | \"onSnapPointChange\"> & {\n id?: string | undefined\n}\n\nexport type DrawerRootEmits = Changes<\"open\", boolean> & Changes<\"snapPoint\", DrawerSnapPoint>\n\nconst DrawerRoot = defineComponent({\n name: \"DrawerRoot\",\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n modal: { type: Boolean, default: true },\n dismissible: { type: Boolean, default: true },\n swipeDirection: String as PropType<DrawerSide>,\n snapPoints: Array as PropType<readonly DrawerSnapPoint[]>,\n snapPoint: optional([Number, String] as PropType<DrawerSnapPoint>),\n defaultSnapPoint: [Number, String] as PropType<DrawerSnapPoint>,\n id: String,\n },\n emits: [\"update:open\", \"openChange\", \"update:snapPoint\", \"snapPointChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createDrawer, () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n modal: props.modal,\n dismissible: props.dismissible,\n swipeDirection: props.swipeDirection,\n snapPoints: props.snapPoints,\n snapPoint: props.snapPoint,\n defaultSnapPoint: props.defaultSnapPoint,\n onSnapPointChange(snapPoint: DrawerSnapPoint, details: ChangeDetails) {\n emit(\"snapPointChange\", snapPoint, details)\n if (!details.canceled) emit(\"update:snapPoint\", snapPoint)\n },\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<DrawerRootProps, DrawerRootEmits>\n\n/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */\nexport const Drawer = {\n ...Dialog,\n Root: DrawerRoot,\n // The same two parts, with what they also say of a drag.\n Backdrop: Dialog.Backdrop as unknown as PartComponent<\"div\", StatesOf<\"drawer\">[\"backdrop\"]>,\n Popup: Dialog.Popup as unknown as PartComponent<\"div\", StatesOf<\"drawer\">[\"popup\"]>,\n}\n"],"mappings":";;;;;;AAuBA,MAAM,QAAQ,QAAoB,QAAQ;AAM1C,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,MAAM,SAAS,OAAO;EACtB,aAAa;EACb,OAAO;GAAE,MAAM;GAAS,SAAS;EAAK;EACtC,aAAa;GAAE,MAAM;GAAS,SAAS;EAAK;EAC5C,IAAI;CACN;CACA,OAAO,CAAC,eAAe,YAAY;CACnC,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,qBAAqB;GAC9B,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,OAAO,MAAM;GACb,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;AAMD,MAAM,YAAY,gBAAgB;CAChC,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,0BAA0B;GACnC,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,aAAa,MAAe,SAAwB;IAClD,KAAK,cAAc,MA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AAkB,WAA4B,SAAwB;IACpE,KAAK,mBAAmB,WAAW,OAAO;IAC1C,IAAI,CAAC,QAAQ,UAAU,KAAK,oBAAoB,SAAS;GAC3D;GACA,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,MAAa,SAAS;CACpB,GAAG;CACH,MAAM;CAEN,UAAU,OAAO;CACjB,OAAO,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"dialog.js","names":[],"sources":["../../../../packages/vue/src/dialog.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createAlertDialog } from \"@kirana-ui/core/alert-dialog\"\nimport type { AlertDialogProps } from \"@kirana-ui/core/alert-dialog\"\nimport { createDialog } from \"@kirana-ui/core/dialog\"\nimport { createDrawer } from \"@kirana-ui/core/drawer\"\nimport type { DrawerProps, DrawerSide, DrawerSnapPoint } from \"@kirana-ui/core/drawer\"\nimport type { Dialog as Controller, DialogProps } from \"@kirana-ui/core/dialog\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport {\n context,\n controller,\n optional,\n partComponent,\n portalComponent,\n toSignal,\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<\"dialog\">\n\nconst scope = context<Controller>(\"Dialog\")\n\nexport type RootProps = Omit<DialogProps, \"id\" | \"onOpenChange\"> & { id?: string | undefined }\n\nexport type RootEmits = Changes<\"open\", boolean>\n\nconst Root = defineComponent({\n name: \"DialogRoot\",\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n modal: { type: Boolean, default: true },\n disablePointerDismissal: optional(Boolean),\n /**\n * Whether a press outside closes it.\n * @deprecated Base UI's name is `disablePointerDismissal`, the other way round, which wins.\n */\n closeOnOutsidePress: optional(Boolean),\n dismissible: { type: Boolean, default: true },\n id: String,\n },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createDialog, { direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n modal: props.modal,\n disablePointerDismissal: props.disablePointerDismissal,\n closeOnOutsidePress: props.closeOnOutsidePress,\n dismissible: props.dismissible,\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\nexport type AlertRootProps = Omit<AlertDialogProps, \"id\" | \"onOpenChange\"> & {\n id?: string | undefined\n}\n\nconst AlertRoot = defineComponent({\n name: \"AlertDialogRoot\",\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(within(createAlertDialog, { direction: useDirectionAround() }), () => ({\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}) as unknown as PlainComponent<AlertRootProps, RootEmits>\n\nexport interface TriggerProps extends PartComponentProps {\n /** It cannot be pressed: the button is disabled, and says so (`data-disabled`). */\n disabled?: boolean | undefined\n}\nexport type BackdropProps = PartComponentProps\nexport type ViewportProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type TitleProps = PartComponentProps\nexport type DescriptionProps = PartComponentProps\nexport type CloseProps = TriggerProps\n\n/** A trigger or a close button, with its own `disabled`. */\nfunction button<Name extends \"trigger\" | \"close\">(name: string, which: Name) {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: { disabled: Boolean },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const made = scope.use()\n const part = (which === \"trigger\" ? made.triggerPart : made.closePart)(() => options.get())\n const Element = partComponent(`${name}Element`, \"button\", () => part)\n return () => h(Element, attrs, slots)\n },\n }) as unknown as PartComponent<\"button\", State[Name], TriggerProps>\n}\n\nexport const Dialog = {\n Root,\n Trigger: button(\"DialogTrigger\", \"trigger\"),\n Portal: portalComponent(\"DialogPortal\", () => scope.use().mounted),\n Backdrop: partComponent<\"div\", State[\"backdrop\"]>(\n \"DialogBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n /** What a long dialog scrolls in, around its popup: it may be left out. */\n Viewport: partComponent<\"div\", State[\"viewport\"]>(\n \"DialogViewport\",\n \"div\",\n () => scope.use().viewport\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"DialogPopup\", \"div\", () => scope.use().popup),\n Title: partComponent<\"h2\", State[\"title\"]>(\"DialogTitle\", \"h2\", () => scope.use().title),\n Description: partComponent<\"p\", State[\"description\"]>(\n \"DialogDescription\",\n \"p\",\n () => scope.use().description\n ),\n Close: button(\"DialogClose\", \"close\"),\n}\n\n/** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */\nexport const AlertDialog = { ...Dialog, Root: AlertRoot }\n\nexport type DrawerRootProps = Omit<DrawerProps, \"id\" | \"onOpenChange\" | \"onSnapPointChange\"> & {\n id?: string | undefined\n}\n\nexport type DrawerRootEmits = Changes<\"open\", boolean> & Changes<\"snapPoint\", DrawerSnapPoint>\n\nconst DrawerRoot = defineComponent({\n name: \"DrawerRoot\",\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n modal: { type: Boolean, default: true },\n disablePointerDismissal: optional(Boolean),\n /**\n * Whether a press outside closes it.\n * @deprecated Base UI's name is `disablePointerDismissal`, the other way round, which wins.\n */\n closeOnOutsidePress: optional(Boolean),\n dismissible: { type: Boolean, default: true },\n swipeDirection: String as PropType<DrawerSide>,\n snapPoints: Array as PropType<readonly DrawerSnapPoint[]>,\n snapPoint: optional([Number, String] as PropType<DrawerSnapPoint>),\n defaultSnapPoint: [Number, String] as PropType<DrawerSnapPoint>,\n id: String,\n },\n emits: [\"update:open\", \"openChange\", \"update:snapPoint\", \"snapPointChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createDrawer, { direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n modal: props.modal,\n disablePointerDismissal: props.disablePointerDismissal,\n closeOnOutsidePress: props.closeOnOutsidePress,\n dismissible: props.dismissible,\n swipeDirection: props.swipeDirection,\n snapPoints: props.snapPoints,\n snapPoint: props.snapPoint,\n defaultSnapPoint: props.defaultSnapPoint,\n onSnapPointChange(snapPoint: DrawerSnapPoint, details: ChangeDetails) {\n emit(\"snapPointChange\", snapPoint, details)\n if (!details.canceled) emit(\"update:snapPoint\", snapPoint)\n },\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<DrawerRootProps, DrawerRootEmits>\n\n// A drawer has no viewport: it lies at an edge of the page, and what scrolls is inside it.\nconst { Viewport: _, ...shared } = Dialog\n\n/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */\nexport const Drawer = {\n ...shared,\n Root: DrawerRoot,\n // The same two parts, with what they also say of a drag.\n Backdrop: Dialog.Backdrop as unknown as PartComponent<\"div\", StatesOf<\"drawer\">[\"backdrop\"]>,\n Popup: Dialog.Popup as unknown as PartComponent<\"div\", StatesOf<\"drawer\">[\"popup\"]>,\n}\n"],"mappings":";;;;;;;;AAgCA,MAAM,QAAQ,QAAoB,QAAQ;AAM1C,MA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AAM;EACjC,IAAI;CACN;CACA,OAAO;EAAC;EAAe;EAAc;EAAoB;CAAiB;CAC1E,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,OAAO,cAAc,EAAE,WAAW,mBAAmB,EAAE,CAAC,UAAU;GAC3E,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,OAAO,MAAM;GACb,yBAAyB,MAAM;GAC/B,qBAAqB,MAAM;GAC3B,aAAa,MAAM;GACnB,gBAAgB,MAAM;GACtB,YAAY,MAAM;GAClB,WAAW,MAAM;GACjB,kBAAkB,MAAM;GACxB,kBAAkB,WAA4B,SAAwB;IACpE,KAAK,mBAAmB,WAAW,OAAO;IAC1C,IAAI,CAAC,QAAQ,UAAU,KAAK,oBAAoB,SAAS;GAC3D;GACA,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,MAAM,EAAE,UAAU,GAAG,GAAG,WAAW;;AAGnC,MAAa,SAAS;CACpB,GAAG;CACH,MAAM;CAEN,UAAU,OAAO;CACjB,OAAO,OAAO;AAChB"}
|
package/src/drawer.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PortalProps } from "./runtime.js";
|
|
2
|
-
import { AlertDialog, AlertRootProps, BackdropProps, CloseProps, DescriptionProps, Dialog, Drawer, DrawerRootEmits, DrawerRootProps, PopupProps, TitleProps, TriggerProps } from "./dialog.js";
|
|
3
|
-
export { type AlertDialog, type AlertRootProps, type BackdropProps, type CloseProps, type DescriptionProps, type Dialog, Drawer, type DrawerRootEmits, type DrawerRootProps, type PopupProps, type PortalProps, type DrawerRootEmits as RootEmits, type DrawerRootProps as RootProps, type TitleProps, type TriggerProps };
|
|
2
|
+
import { AlertDialog, AlertRootProps, BackdropProps, CloseProps, DescriptionProps, Dialog, Drawer, DrawerRootEmits, DrawerRootProps, PopupProps, TitleProps, TriggerProps, ViewportProps } from "./dialog.js";
|
|
3
|
+
export { type AlertDialog, type AlertRootProps, type BackdropProps, type CloseProps, type DescriptionProps, type Dialog, Drawer, type DrawerRootEmits, type DrawerRootProps, type PopupProps, type PortalProps, type DrawerRootEmits as RootEmits, type DrawerRootProps as RootProps, type TitleProps, type TriggerProps, type ViewportProps };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { EditableProps } from "@kirana-ui/core/editable";
|
|
3
|
+
export type RootProps = Omit<EditableProps, "id" | "onValueChange" | "onEditingChange"> & {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
} & PartComponentProps;
|
|
6
|
+
export type RootEmits = Changes<"value", string> & Changes<"editing", boolean>;
|
|
7
|
+
export type PreviewProps = PartComponentProps;
|
|
8
|
+
export type InputProps = PartComponentProps;
|
|
9
|
+
export type EditTriggerProps = PartComponentProps;
|
|
10
|
+
export type SubmitTriggerProps = PartComponentProps;
|
|
11
|
+
export type CancelTriggerProps = PartComponentProps;
|
|
12
|
+
export declare const Editable: {
|
|
13
|
+
Root: PartComponent<"div", {
|
|
14
|
+
readonly editing?: true | undefined;
|
|
15
|
+
readonly disabled?: true | undefined;
|
|
16
|
+
readonly readonly?: true | undefined;
|
|
17
|
+
readonly placeholder?: true | undefined;
|
|
18
|
+
readonly touched?: true | undefined;
|
|
19
|
+
readonly dirty?: true | undefined;
|
|
20
|
+
readonly filled?: true | undefined;
|
|
21
|
+
readonly focused?: true | undefined;
|
|
22
|
+
readonly valid?: true | undefined;
|
|
23
|
+
readonly invalid?: true | undefined;
|
|
24
|
+
}, RootProps, RootEmits>;
|
|
25
|
+
Preview: PartComponent<"span", {
|
|
26
|
+
readonly editing?: true | undefined;
|
|
27
|
+
readonly disabled?: true | undefined;
|
|
28
|
+
readonly readonly?: true | undefined;
|
|
29
|
+
readonly placeholder?: true | undefined;
|
|
30
|
+
readonly touched?: true | undefined;
|
|
31
|
+
readonly dirty?: true | undefined;
|
|
32
|
+
readonly filled?: true | undefined;
|
|
33
|
+
readonly focused?: true | undefined;
|
|
34
|
+
readonly valid?: true | undefined;
|
|
35
|
+
readonly invalid?: true | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
/** An `<input>`; `as="textarea"` for a text of several lines. */
|
|
38
|
+
Input: PartComponent<"input", {
|
|
39
|
+
readonly editing?: true | undefined;
|
|
40
|
+
readonly disabled?: true | undefined;
|
|
41
|
+
readonly readonly?: true | undefined;
|
|
42
|
+
readonly placeholder?: true | undefined;
|
|
43
|
+
readonly touched?: true | undefined;
|
|
44
|
+
readonly dirty?: true | undefined;
|
|
45
|
+
readonly filled?: true | undefined;
|
|
46
|
+
readonly focused?: true | undefined;
|
|
47
|
+
readonly valid?: true | undefined;
|
|
48
|
+
readonly invalid?: true | undefined;
|
|
49
|
+
}, PartComponentProps, {}, unknown>;
|
|
50
|
+
EditTrigger: PartComponent<"button", {
|
|
51
|
+
readonly editing?: true | undefined;
|
|
52
|
+
readonly disabled?: true | undefined;
|
|
53
|
+
readonly readonly?: true | undefined;
|
|
54
|
+
readonly placeholder?: true | undefined;
|
|
55
|
+
readonly touched?: true | undefined;
|
|
56
|
+
readonly dirty?: true | undefined;
|
|
57
|
+
readonly filled?: true | undefined;
|
|
58
|
+
readonly focused?: true | undefined;
|
|
59
|
+
readonly valid?: true | undefined;
|
|
60
|
+
readonly invalid?: true | undefined;
|
|
61
|
+
}, PartComponentProps, {}, unknown>;
|
|
62
|
+
SubmitTrigger: PartComponent<"button", {
|
|
63
|
+
readonly editing?: true | undefined;
|
|
64
|
+
readonly disabled?: true | undefined;
|
|
65
|
+
readonly readonly?: true | undefined;
|
|
66
|
+
readonly placeholder?: true | undefined;
|
|
67
|
+
readonly touched?: true | undefined;
|
|
68
|
+
readonly dirty?: true | undefined;
|
|
69
|
+
readonly filled?: true | undefined;
|
|
70
|
+
readonly focused?: true | undefined;
|
|
71
|
+
readonly valid?: true | undefined;
|
|
72
|
+
readonly invalid?: true | undefined;
|
|
73
|
+
}, PartComponentProps, {}, unknown>;
|
|
74
|
+
CancelTrigger: PartComponent<"button", {
|
|
75
|
+
readonly editing?: true | undefined;
|
|
76
|
+
readonly disabled?: true | undefined;
|
|
77
|
+
readonly readonly?: true | undefined;
|
|
78
|
+
readonly placeholder?: true | undefined;
|
|
79
|
+
readonly touched?: true | undefined;
|
|
80
|
+
readonly dirty?: true | undefined;
|
|
81
|
+
readonly filled?: true | undefined;
|
|
82
|
+
readonly focused?: true | undefined;
|
|
83
|
+
readonly valid?: true | undefined;
|
|
84
|
+
readonly invalid?: true | undefined;
|
|
85
|
+
}, PartComponentProps, {}, unknown>;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=editable.d.ts.map
|
package/src/editable.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { written } from "./element.js";
|
|
2
|
+
import { useFieldAround } from "./field-context.js";
|
|
3
|
+
import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
|
|
4
|
+
import { within } from "@kirana-ui/core";
|
|
5
|
+
import { defineComponent, h, useId } from "vue";
|
|
6
|
+
import { createEditable } from "@kirana-ui/core/editable";
|
|
7
|
+
// src/editable.ts
|
|
8
|
+
const scope = context("Editable");
|
|
9
|
+
const RootElement = partComponent("EditableRootElement", "div", () => scope.use().root);
|
|
10
|
+
const Editable = {
|
|
11
|
+
Root: defineComponent({
|
|
12
|
+
name: "EditableRoot",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
value: optional(String),
|
|
16
|
+
defaultValue: String,
|
|
17
|
+
editing: optional(Boolean),
|
|
18
|
+
defaultEditing: Boolean,
|
|
19
|
+
placeholder: String,
|
|
20
|
+
activation: String,
|
|
21
|
+
submitOnBlur: optional(Boolean),
|
|
22
|
+
selectOnFocus: optional(Boolean),
|
|
23
|
+
disabled: Boolean,
|
|
24
|
+
readOnly: Boolean,
|
|
25
|
+
required: Boolean,
|
|
26
|
+
name: String,
|
|
27
|
+
form: String,
|
|
28
|
+
id: String
|
|
29
|
+
},
|
|
30
|
+
emits: [
|
|
31
|
+
"update:value",
|
|
32
|
+
"valueChange",
|
|
33
|
+
"update:editing",
|
|
34
|
+
"editingChange"
|
|
35
|
+
],
|
|
36
|
+
setup(props, { attrs, slots, emit }) {
|
|
37
|
+
const generated = useId();
|
|
38
|
+
scope.provide(controller(within(createEditable, { field: useFieldAround() }), () => ({
|
|
39
|
+
id: props.id ?? generated,
|
|
40
|
+
value: props.value,
|
|
41
|
+
defaultValue: props.defaultValue,
|
|
42
|
+
editing: props.editing,
|
|
43
|
+
defaultEditing: props.defaultEditing,
|
|
44
|
+
placeholder: props.placeholder,
|
|
45
|
+
activation: props.activation,
|
|
46
|
+
submitOnBlur: props.submitOnBlur,
|
|
47
|
+
selectOnFocus: props.selectOnFocus,
|
|
48
|
+
disabled: props.disabled,
|
|
49
|
+
readOnly: props.readOnly,
|
|
50
|
+
required: props.required,
|
|
51
|
+
name: props.name,
|
|
52
|
+
form: props.form,
|
|
53
|
+
onValueChange(value, details) {
|
|
54
|
+
emit("valueChange", value, details);
|
|
55
|
+
if (!details.canceled) emit("update:value", value);
|
|
56
|
+
},
|
|
57
|
+
onEditingChange(editing, details) {
|
|
58
|
+
emit("editingChange", editing, details);
|
|
59
|
+
if (!details.canceled) emit("update:editing", editing);
|
|
60
|
+
}
|
|
61
|
+
})));
|
|
62
|
+
return () => h(RootElement, attrs, slots);
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
Preview: defineComponent({
|
|
66
|
+
name: "EditablePreview",
|
|
67
|
+
inheritAttrs: false,
|
|
68
|
+
setup(_props, { attrs, slots }) {
|
|
69
|
+
const made = scope.use();
|
|
70
|
+
const text = fromSignal(made.text);
|
|
71
|
+
const Element = partComponent("EditablePreviewElement", "span", () => made.preview, written(() => text.value));
|
|
72
|
+
return () => h(Element, attrs, { default: (given) => slots.default?.(given) ?? text.value });
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
/** An `<input>`; `as="textarea"` for a text of several lines. */
|
|
76
|
+
Input: partComponent("EditableInput", "input", () => scope.use().input),
|
|
77
|
+
EditTrigger: partComponent("EditableEditTrigger", "button", () => scope.use().editTrigger),
|
|
78
|
+
SubmitTrigger: partComponent("EditableSubmitTrigger", "button", () => scope.use().submitTrigger),
|
|
79
|
+
CancelTrigger: partComponent("EditableCancelTrigger", "button", () => scope.use().cancelTrigger)
|
|
80
|
+
};
|
|
81
|
+
export { Editable };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=editable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editable.js","names":[],"sources":["../../../../packages/vue/src/editable.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createEditable } from \"@kirana-ui/core/editable\"\nimport type { Editable as Controller, EditableProps } from \"@kirana-ui/core/editable\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { written } from \"./element.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"editable\">\n\nconst scope = context<Controller>(\"Editable\")\n\nconst RootElement = partComponent(\"EditableRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<EditableProps, \"id\" | \"onValueChange\" | \"onEditingChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"value\", string> & Changes<\"editing\", boolean>\n\n/** `v-model:value` and `v-model:editing`, or each with its `@…-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"EditableRoot\",\n inheritAttrs: false,\n props: {\n value: optional(String),\n defaultValue: String,\n editing: optional(Boolean),\n defaultEditing: Boolean,\n placeholder: String,\n activation: String as PropType<EditableProps[\"activation\"]>,\n submitOnBlur: optional(Boolean),\n selectOnFocus: optional(Boolean),\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"update:editing\", \"editingChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createEditable, { field: useFieldAround() }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n editing: props.editing,\n defaultEditing: props.defaultEditing,\n placeholder: props.placeholder,\n activation: props.activation,\n submitOnBlur: props.submitOnBlur,\n selectOnFocus: props.selectOnFocus,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onEditingChange(editing: boolean, details: ChangeDetails) {\n emit(\"editingChange\", editing, details)\n if (!details.canceled) emit(\"update:editing\", editing)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\n/** Says the text, or the placeholder while there is none, unless its slot says something else. */\nconst Preview = defineComponent({\n name: \"EditablePreview\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const text = fromSignal(made.text)\n // With `as-child` the caller's element holds the text, unless it writes its own.\n const Element = partComponent(\n \"EditablePreviewElement\",\n \"span\",\n () => made.preview,\n written(() => text.value)\n )\n return () =>\n h(Element, attrs, {\n default: (given: object) => slots.default?.(given) ?? text.value,\n })\n },\n}) as unknown as PartComponent<\"span\", State[\"preview\"]>\n\nexport type PreviewProps = PartComponentProps\nexport type InputProps = PartComponentProps\nexport type EditTriggerProps = PartComponentProps\nexport type SubmitTriggerProps = PartComponentProps\nexport type CancelTriggerProps = PartComponentProps\nexport const Editable = {\n Root,\n Preview,\n /** An `<input>`; `as=\"textarea\"` for a text of several lines. */\n Input: partComponent<\"input\", State[\"input\"]>(\"EditableInput\", \"input\", () => scope.use().input),\n EditTrigger: partComponent<\"button\", State[\"editTrigger\"]>(\n \"EditableEditTrigger\",\n \"button\",\n () => scope.use().editTrigger\n ),\n SubmitTrigger: partComponent<\"button\", State[\"submitTrigger\"]>(\n \"EditableSubmitTrigger\",\n \"button\",\n () => scope.use().submitTrigger\n ),\n CancelTrigger: partComponent<\"button\", State[\"cancelTrigger\"]>(\n \"EditableCancelTrigger\",\n \"button\",\n () => scope.use().cancelTrigger\n ),\n}\n"],"mappings":";;;;;;;AAcA,MAAM,QAAQ,QAAoB,UAAU;AAE5C,MAAM,cAAc,cAAc,uBAAuB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAuFtF,MAAa,WAAW;CACtB,MA/EW,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO,SAAS,MAAM;GACtB,cAAc;GACd,SAAS,SAAS,OAAO;GACzB,gBAAgB;GAChB,aAAa;GACb,YAAY;GACZ,cAAc,SAAS,OAAO;GAC9B,eAAe,SAAS,OAAO;GAC/B,UAAU;GACV,UAAU;GACV,UAAU;GACV,MAAM;GACN,MAAM;GACN,IAAI;EACN;EACA,OAAO;GAAC;GAAgB;GAAe;GAAkB;EAAe;EACxE,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,QACJ,WAAW,OAAO,gBAAgB,EAAE,OAAO,eAAe,EAAE,CAAC,UAAU;IACrE,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,cAAc,MAAM;IACpB,SAAS,MAAM;IACf,gBAAgB,MAAM;IACtB,aAAa,MAAM;IACnB,YAAY,MAAM;IAClB,cAAc,MAAM;IACpB,eAAe,MAAM;IACrB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,cAAc,OAAe,SAAwB;KACnD,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;IACA,gBAAgB,SAAkB,SAAwB;KACxD,KAAK,iBAAiB,SAAS,OAAO;KACtC,IAAI,CAAC,QAAQ,UAAU,KAAK,kBAAkB,OAAO;IACvD;GACF,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CA6BE;CACA,SA3Bc,gBAAgB;EAC9B,MAAM;EACN,cAAc;EACd,MAAM,QAAQ,EAAE,OAAO,SAAS;GAC9B,MAAM,OAAO,MAAM,IAAI;GACvB,MAAM,OAAO,WAAW,KAAK,IAAI;GAEjC,MAAM,UAAU,cACd,0BACA,cACM,KAAK,SACX,cAAc,KAAK,KAAK,CAC1B;GACA,aACE,EAAE,SAAS,OAAO,EAChB,UAAU,UAAkB,MAAM,UAAU,KAAK,KAAK,KAAK,MAC7D,CAAC;EACL;CACF,CASE;;CAEA,OAAO,cAAuC,iBAAiB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;CAC/F,aAAa,cACX,uBACA,gBACM,MAAM,IAAI,CAAC,CAAC,WACpB;CACA,eAAe,cACb,yBACA,gBACM,MAAM,IAAI,CAAC,CAAC,aACpB;CACA,eAAe,cACb,yBACA,gBACM,MAAM,IAAI,CAAC,CAAC,aACpB;AACF"}
|
package/src/element.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { composeProps, mergeProps } from "@kirana-ui/core";
|
|
1
|
+
import { composeProps, forElement, mergeProps } from "@kirana-ui/core";
|
|
2
2
|
import { Comment, Fragment, cloneVNode, h } from "vue";
|
|
3
3
|
// src/element.ts
|
|
4
4
|
function firstElement(nodes) {
|
|
@@ -65,8 +65,8 @@ function holding(child, hold) {
|
|
|
65
65
|
* first. What the part keeps in its element (`hold`) is in it whichever element that is.
|
|
66
66
|
*/
|
|
67
67
|
function draw(as, asChild, attrs, content, own, ref, hold) {
|
|
68
|
-
const whole = (under) => {
|
|
69
|
-
const merged = own ? mergeProps(under, own) : under;
|
|
68
|
+
const whole = (under, tag) => {
|
|
69
|
+
const merged = own ? mergeProps(under, forElement(own, under, tag)) : under;
|
|
70
70
|
return ref ? {
|
|
71
71
|
...merged,
|
|
72
72
|
ref
|
|
@@ -74,7 +74,7 @@ function draw(as, asChild, attrs, content, own, ref, hold) {
|
|
|
74
74
|
};
|
|
75
75
|
if (!asChild) {
|
|
76
76
|
const inside = hold ? hold(content, false) : content;
|
|
77
|
-
return typeof as === "string" ? h(as, whole(single(attrs)), inside) : h(as, whole(single(attrs)), () => inside);
|
|
77
|
+
return typeof as === "string" ? h(as, whole(single(attrs), as), inside) : h(as, whole(single(attrs), void 0), () => inside);
|
|
78
78
|
}
|
|
79
79
|
const child = firstElement(content);
|
|
80
80
|
if (!child) return null;
|
|
@@ -83,7 +83,7 @@ function draw(as, asChild, attrs, content, own, ref, hold) {
|
|
|
83
83
|
...child,
|
|
84
84
|
props: null,
|
|
85
85
|
...hold ? holding(child, hold) : null
|
|
86
|
-
}, whole(composeProps(single(attrs), single(theirs))), true);
|
|
86
|
+
}, whole(composeProps(single(attrs), single(theirs)), typeof child.type === "string" ? child.type : void 0), true);
|
|
87
87
|
}
|
|
88
88
|
export { draw, written };
|
|
89
89
|
|
package/src/element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":[],"sources":["../../../../packages/vue/src/element.ts"],"sourcesContent":["import { composeProps, mergeProps } from \"@kirana-ui/core\"\nimport type { PartProps } from \"@kirana-ui/core\"\nimport { Comment, Fragment, cloneVNode, h } from \"vue\"\nimport type { Component, VNode, VNodeArrayChildren } from \"vue\"\n\nfunction firstElement(nodes: VNode[] | undefined): VNode | undefined {\n for (const node of nodes ?? []) {\n if (node.type === Comment) continue\n if (node.type === Fragment) return firstElement(node.children as VNode[])\n return node\n }\n return undefined\n}\n\ntype Listener = (...given: unknown[]) => void\n\n/** Vue keeps several listeners of one event as a list: one function, so each is merged as one. */\nfunction single(props: PartProps): PartProps {\n let out = props\n for (const key in props) {\n const value = props[key]\n if (!key.startsWith(\"on\") || !Array.isArray(value)) continue\n if (out === props) out = { ...props }\n out[key] = (...given: unknown[]) => {\n for (const each of value as Listener[]) each(...given)\n }\n }\n return out\n}\n\n/**\n * What a part keeps in its element beside its content (a control's native input, a code\n * cell's character, the text it writes): given the content, it returns what the element\n * holds. `composed` says the element is the caller's own (`as-child`), and the content that\n * element's.\n */\nexport type Hold = (\n content: VNodeArrayChildren | undefined,\n composed: boolean\n) => VNodeArrayChildren\n\n/**\n * What the element of a part that writes its own text holds: with `as-child`, the text while\n * the caller's element has no content of its own, as the part's own element would.\n */\nexport function written(text: () => unknown): Hold {\n return (content, composed) => {\n if (!composed || (content != null && content.length > 0)) return content ?? []\n const own = text() as VNodeArrayChildren[number]\n return own == null ? [] : [own]\n }\n}\n\ntype Slot = (...given: unknown[]) => VNodeArrayChildren | undefined\n\n/**\n * The caller's own element holding what the part keeps in it: among the children of an\n * element, in the default slot of a component. Its content is then a list this adapter made,\n * so nothing the compiler said of the element's children (which of them can change) stands.\n */\nfunction holding(child: VNode, hold: Hold): Partial<VNode> & { dynamicChildren: null } {\n const given = child.children\n let made: VNode\n if (typeof child.type === \"string\") {\n const content = typeof given === \"string\" ? [given] : (given as VNodeArrayChildren | null)\n made = h(child.type, null, hold(content ?? undefined, true))\n } else {\n // A component given no named slots takes whatever it was given as its default slot.\n const slots =\n given && typeof given === \"object\" && !Array.isArray(given)\n ? (given as Record<string, Slot | undefined>)\n : { default: (() => (typeof given === \"string\" ? [given] : (given ?? undefined))) as Slot }\n // Without the compiler's mark on the slots, which says they never change: these do.\n const { _: _mark, default: content, ...named } = slots\n made = h(child.type as Component, null, {\n ...named,\n default: (...handed: unknown[]) => hold(content?.(...handed), true),\n })\n }\n return { children: made.children, shapeFlag: made.shapeFlag, patchFlag: 0, dynamicChildren: null }\n}\n\n/**\n * The element a part draws, or a plain one (`own` left out): `as`, or with `asChild` the\n * caller's own element, the first in `content`. Three layers of props, lowest first: the\n * attributes on the component, the slotted element's own, the part's. A higher layer wins an\n * attribute, classes join, styles are merged, and every listener of an event runs, lowest\n * first. What the part keeps in its element (`hold`) is in it whichever element that is.\n */\nexport function draw(\n as: string | Component,\n asChild: boolean,\n attrs: PartProps,\n content: VNode[] | undefined,\n own?: PartProps,\n ref?: (target: unknown) => void,\n hold?: Hold\n): VNode | null {\n const whole = (under: PartProps) => {\n const merged = own ? mergeProps(under, own) : under\n return ref ? { ...merged, ref } : merged\n }\n if (!asChild) {\n const inside = hold ? hold(content, false) : content\n // A component takes its content as a slot.\n return typeof as === \"string\"\n ? h(as, whole(single(attrs)), inside)\n : h(as, whole(single(attrs)), () => inside)\n }\n const child = firstElement(content)\n if (!child) return null\n // Its ref is the element's own, which the clone keeps beside the part's.\n const { ref: _ref, ref_key: _key, ref_for: _for, ...theirs } = child.props ?? {}\n // Cloned with its props taken off: Vue would lay them under these a second time, its class\n // twice and its listener beside the one that already calls it.\n return cloneVNode(\n { ...child, props: null, ...(hold ? holding(child, hold) : null) },\n whole(composeProps(single(attrs), single(theirs))),\n true\n )\n}\n"],"mappings":";;;AAKA,SAAS,aAAa,OAA+C;CACnE,KAAK,MAAM,QAAQ,SAAS,CAAC,GAAG;EAC9B,IAAI,KAAK,SAAS,SAAS;EAC3B,IAAI,KAAK,SAAS,UAAU,OAAO,aAAa,KAAK,QAAmB;EACxE,OAAO;CACT;AAEF;;AAKA,SAAS,OAAO,OAA6B;CAC3C,IAAI,MAAM;CACV,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,QAAQ,KAAK,GAAG;EACpD,IAAI,QAAQ,OAAO,MAAM,EAAE,GAAG,MAAM;EACpC,IAAI,QAAQ,GAAG,UAAqB;GAClC,KAAK,MAAM,QAAQ,OAAqB,KAAK,GAAG,KAAK;EACvD;CACF;CACA,OAAO;AACT;;;;;AAiBA,SAAgB,QAAQ,MAA2B;CACjD,QAAQ,SAAS,aAAa;EAC5B,IAAI,CAAC,YAAa,WAAW,QAAQ,QAAQ,SAAS,GAAI,OAAO,WAAW,CAAC;EAC7E,MAAM,MAAM,KAAK;EACjB,OAAO,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG;CAChC;AACF;;;;;;AASA,SAAS,QAAQ,OAAc,MAAwD;CACrF,MAAM,QAAQ,MAAM;CACpB,IAAI;CACJ,IAAI,OAAO,MAAM,SAAS,UAAU;EAClC,MAAM,UAAU,OAAO,UAAU,WAAW,CAAC,KAAK,IAAK;EACvD,OAAO,EAAE,MAAM,MAAM,MAAM,KAAK,WAAW,KAAA,GAAW,IAAI,CAAC;CAC7D,OAAO;EAOL,MAAM,EAAE,GAAG,OAAO,SAAS,SAAS,GAAG,UAJrC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACrD,QACD,EAAE,gBAAiB,OAAO,UAAU,WAAW,CAAC,KAAK,IAAK,SAAS,KAAA,GAAqB;EAG9F,OAAO,EAAE,MAAM,MAAmB,MAAM;GACtC,GAAG;GACH,UAAU,GAAG,WAAsB,KAAK,UAAU,GAAG,MAAM,GAAG,IAAI;EACpE,CAAC;CACH;CACA,OAAO;EAAE,UAAU,KAAK;EAAU,WAAW,KAAK;EAAW,WAAW;EAAG,iBAAiB;CAAK;AACnG;;;;;;;;AASA,SAAgB,KACd,IACA,SACA,OACA,SACA,KACA,KACA,MACc;
|
|
1
|
+
{"version":3,"file":"element.js","names":[],"sources":["../../../../packages/vue/src/element.ts"],"sourcesContent":["import { composeProps, forElement, mergeProps } from \"@kirana-ui/core\"\nimport type { PartProps } from \"@kirana-ui/core\"\nimport { Comment, Fragment, cloneVNode, h } from \"vue\"\nimport type { Component, VNode, VNodeArrayChildren } from \"vue\"\n\nfunction firstElement(nodes: VNode[] | undefined): VNode | undefined {\n for (const node of nodes ?? []) {\n if (node.type === Comment) continue\n if (node.type === Fragment) return firstElement(node.children as VNode[])\n return node\n }\n return undefined\n}\n\ntype Listener = (...given: unknown[]) => void\n\n/** Vue keeps several listeners of one event as a list: one function, so each is merged as one. */\nfunction single(props: PartProps): PartProps {\n let out = props\n for (const key in props) {\n const value = props[key]\n if (!key.startsWith(\"on\") || !Array.isArray(value)) continue\n if (out === props) out = { ...props }\n out[key] = (...given: unknown[]) => {\n for (const each of value as Listener[]) each(...given)\n }\n }\n return out\n}\n\n/**\n * What a part keeps in its element beside its content (a control's native input, a code\n * cell's character, the text it writes): given the content, it returns what the element\n * holds. `composed` says the element is the caller's own (`as-child`), and the content that\n * element's.\n */\nexport type Hold = (\n content: VNodeArrayChildren | undefined,\n composed: boolean\n) => VNodeArrayChildren\n\n/**\n * What the element of a part that writes its own text holds: with `as-child`, the text while\n * the caller's element has no content of its own, as the part's own element would.\n */\nexport function written(text: () => unknown): Hold {\n return (content, composed) => {\n if (!composed || (content != null && content.length > 0)) return content ?? []\n const own = text() as VNodeArrayChildren[number]\n return own == null ? [] : [own]\n }\n}\n\ntype Slot = (...given: unknown[]) => VNodeArrayChildren | undefined\n\n/**\n * The caller's own element holding what the part keeps in it: among the children of an\n * element, in the default slot of a component. Its content is then a list this adapter made,\n * so nothing the compiler said of the element's children (which of them can change) stands.\n */\nfunction holding(child: VNode, hold: Hold): Partial<VNode> & { dynamicChildren: null } {\n const given = child.children\n let made: VNode\n if (typeof child.type === \"string\") {\n const content = typeof given === \"string\" ? [given] : (given as VNodeArrayChildren | null)\n made = h(child.type, null, hold(content ?? undefined, true))\n } else {\n // A component given no named slots takes whatever it was given as its default slot.\n const slots =\n given && typeof given === \"object\" && !Array.isArray(given)\n ? (given as Record<string, Slot | undefined>)\n : { default: (() => (typeof given === \"string\" ? [given] : (given ?? undefined))) as Slot }\n // Without the compiler's mark on the slots, which says they never change: these do.\n const { _: _mark, default: content, ...named } = slots\n made = h(child.type as Component, null, {\n ...named,\n default: (...handed: unknown[]) => hold(content?.(...handed), true),\n })\n }\n return { children: made.children, shapeFlag: made.shapeFlag, patchFlag: 0, dynamicChildren: null }\n}\n\n/**\n * The element a part draws, or a plain one (`own` left out): `as`, or with `asChild` the\n * caller's own element, the first in `content`. Three layers of props, lowest first: the\n * attributes on the component, the slotted element's own, the part's. A higher layer wins an\n * attribute, classes join, styles are merged, and every listener of an event runs, lowest\n * first. What the part keeps in its element (`hold`) is in it whichever element that is.\n */\nexport function draw(\n as: string | Component,\n asChild: boolean,\n attrs: PartProps,\n content: VNode[] | undefined,\n own?: PartProps,\n ref?: (target: unknown) => void,\n hold?: Hold\n): VNode | null {\n // `tag` is the element's, where it is known before it is drawn: a component draws its own.\n const whole = (under: PartProps, tag: string | undefined) => {\n const merged = own ? mergeProps(under, forElement(own, under, tag)) : under\n return ref ? { ...merged, ref } : merged\n }\n if (!asChild) {\n const inside = hold ? hold(content, false) : content\n // A component takes its content as a slot.\n return typeof as === \"string\"\n ? h(as, whole(single(attrs), as), inside)\n : h(as, whole(single(attrs), undefined), () => inside)\n }\n const child = firstElement(content)\n if (!child) return null\n // Its ref is the element's own, which the clone keeps beside the part's.\n const { ref: _ref, ref_key: _key, ref_for: _for, ...theirs } = child.props ?? {}\n // Cloned with its props taken off: Vue would lay them under these a second time, its class\n // twice and its listener beside the one that already calls it.\n return cloneVNode(\n { ...child, props: null, ...(hold ? holding(child, hold) : null) },\n whole(\n composeProps(single(attrs), single(theirs)),\n typeof child.type === \"string\" ? child.type : undefined\n ),\n true\n )\n}\n"],"mappings":";;;AAKA,SAAS,aAAa,OAA+C;CACnE,KAAK,MAAM,QAAQ,SAAS,CAAC,GAAG;EAC9B,IAAI,KAAK,SAAS,SAAS;EAC3B,IAAI,KAAK,SAAS,UAAU,OAAO,aAAa,KAAK,QAAmB;EACxE,OAAO;CACT;AAEF;;AAKA,SAAS,OAAO,OAA6B;CAC3C,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AAM,SAAS,OAAkB,QAA4B;EAC3D,MAAM,SAAS,MAAM,WAAW,OAAO,WAAW,KAAK,OAAO,GAAG,CAAC,IAAI;EACtE,OAAO,MAAM;GAAE,GAAG;GAAQ;EAAI,IAAI;CACpC;CACA,IAAI,CAAC,SAAS;EACZ,MAAM,SAAS,OAAO,KAAK,SAAS,KAAK,IAAI;EAE7C,OAAO,OAAO,OAAO,WACjB,EAAE,IAAI,MAAM,OAAO,KAAK,GAAG,EAAE,GAAG,MAAM,IACtC,EAAE,IAAI,MAAM,OAAO,KAAK,GAAG,KAAA,CAAS,SAAS,MAAM;CACzD;CACA,MAAM,QAAQ,aAAa,OAAO;CAClC,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,EAAE,KAAK,MAAM,SAAS,MAAM,SAAS,MAAM,GAAG,WAAW,MAAM,SAAS,CAAC;CAG/E,OAAO,WACL;EAAE,GAAG;EAAO,OAAO;EAAM,GAAI,OAAO,QAAQ,OAAO,IAAI,IAAI;CAAM,GACjE,MACE,aAAa,OAAO,KAAK,GAAG,OAAO,MAAM,CAAC,GAC1C,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO,KAAA,CAChD,GACA,IACF;AACF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps, PlainComponent } from "./runtime.js";
|
|
2
|
+
import { FileRejection, FileUploadEntry, FileUploadProps } from "@kirana-ui/core/file-upload";
|
|
3
|
+
export type RootProps = Omit<FileUploadProps, "id" | "onFilesChange" | "onFilesReject"> & {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
} & PartComponentProps;
|
|
6
|
+
export type RootEmits = Changes<"files", File[]> & {
|
|
7
|
+
/** The files that were not taken, each with its reasons. */
|
|
8
|
+
filesReject: (rejections: FileRejection[]) => void;
|
|
9
|
+
};
|
|
10
|
+
export type DropzoneProps = PartComponentProps;
|
|
11
|
+
export type ItemsProps = Record<never, never>;
|
|
12
|
+
export interface ItemProps extends PartComponentProps {
|
|
13
|
+
/** The file it is, as `Items` gave it. */
|
|
14
|
+
entry: FileUploadEntry;
|
|
15
|
+
}
|
|
16
|
+
export type ItemNameProps = PartComponentProps;
|
|
17
|
+
export interface ItemSizeProps extends PartComponentProps {
|
|
18
|
+
/** The language the number is written in. Default: the reader's. */
|
|
19
|
+
locale?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export type ItemRemoveProps = PartComponentProps;
|
|
22
|
+
export type TriggerProps = PartComponentProps;
|
|
23
|
+
export type ListProps = PartComponentProps;
|
|
24
|
+
export type ClearProps = PartComponentProps;
|
|
25
|
+
export declare const FileUpload: {
|
|
26
|
+
Root: PartComponent<"div", {
|
|
27
|
+
readonly disabled?: true | undefined;
|
|
28
|
+
readonly dragging?: true | undefined;
|
|
29
|
+
readonly required?: true | undefined;
|
|
30
|
+
readonly empty?: true | undefined;
|
|
31
|
+
}, RootProps, RootEmits>;
|
|
32
|
+
Dropzone: PartComponent<"div", {
|
|
33
|
+
readonly disabled?: true | undefined;
|
|
34
|
+
readonly dragging?: true | undefined;
|
|
35
|
+
readonly required?: true | undefined;
|
|
36
|
+
}, PartComponentProps, {}, unknown>;
|
|
37
|
+
Trigger: PartComponent<"button", {
|
|
38
|
+
readonly disabled?: true | undefined;
|
|
39
|
+
readonly dragging?: true | undefined;
|
|
40
|
+
readonly required?: true | undefined;
|
|
41
|
+
}, PartComponentProps, {}, unknown>;
|
|
42
|
+
List: PartComponent<"ul", {
|
|
43
|
+
readonly disabled?: true | undefined;
|
|
44
|
+
readonly dragging?: true | undefined;
|
|
45
|
+
readonly required?: true | undefined;
|
|
46
|
+
}, PartComponentProps, {}, unknown>;
|
|
47
|
+
Items: PlainComponent<ItemsProps, {}, {
|
|
48
|
+
entry: FileUploadEntry;
|
|
49
|
+
}>;
|
|
50
|
+
Item: PartComponent<"li", {
|
|
51
|
+
readonly disabled?: true | undefined;
|
|
52
|
+
readonly dragging?: true | undefined;
|
|
53
|
+
readonly required?: true | undefined;
|
|
54
|
+
}, ItemProps>;
|
|
55
|
+
ItemName: PartComponent<"span", {
|
|
56
|
+
readonly disabled?: true | undefined;
|
|
57
|
+
readonly dragging?: true | undefined;
|
|
58
|
+
readonly required?: true | undefined;
|
|
59
|
+
}, PartComponentProps>;
|
|
60
|
+
ItemSize: PartComponent<"span", {
|
|
61
|
+
readonly disabled?: true | undefined;
|
|
62
|
+
readonly dragging?: true | undefined;
|
|
63
|
+
readonly required?: true | undefined;
|
|
64
|
+
}, ItemSizeProps>;
|
|
65
|
+
ItemRemove: PartComponent<"button", {
|
|
66
|
+
readonly disabled?: true | undefined;
|
|
67
|
+
readonly dragging?: true | undefined;
|
|
68
|
+
readonly required?: true | undefined;
|
|
69
|
+
}, PartComponentProps>;
|
|
70
|
+
Clear: PartComponent<"button", {
|
|
71
|
+
readonly disabled?: true | undefined;
|
|
72
|
+
readonly dragging?: true | undefined;
|
|
73
|
+
readonly required?: true | undefined;
|
|
74
|
+
}, PartComponentProps, {}, unknown>;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=file-upload.d.ts.map
|