@kirana-ui/vue 0.1.0 → 0.1.1
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 +1838 -0
- package/package.json +112 -2
- package/src/autocomplete.d.ts +2 -0
- package/src/autocomplete.js +1 -0
- package/src/autosize.d.ts +12 -0
- package/src/autosize.js +24 -0
- package/src/autosize.js.map +1 -0
- package/src/calendar.d.ts +107 -0
- package/src/calendar.js +125 -0
- package/src/calendar.js.map +1 -0
- package/src/carousel.d.ts +61 -0
- package/src/carousel.js +75 -0
- package/src/carousel.js.map +1 -0
- package/src/checkbox.d.ts +2 -0
- package/src/checkbox.js +2 -0
- package/src/checkbox.js.map +1 -1
- package/src/combobox.d.ts +298 -0
- package/src/combobox.js +286 -0
- package/src/combobox.js.map +1 -0
- package/src/command.d.ts +89 -0
- package/src/command.js +129 -0
- package/src/command.js.map +1 -0
- package/src/context-menu.d.ts +2 -0
- package/src/context-menu.js +1 -0
- package/src/date-field.d.ts +70 -0
- package/src/date-field.js +77 -0
- package/src/date-field.js.map +1 -0
- package/src/date-picker.d.ts +145 -0
- package/src/date-picker.js +82 -0
- package/src/date-picker.js.map +1 -0
- package/src/dialog.d.ts +70 -0
- package/src/dialog.js +56 -1
- package/src/dialog.js.map +1 -1
- package/src/drawer.d.ts +2 -0
- package/src/drawer.js +1 -0
- package/src/hover-card.d.ts +9 -1
- package/src/hover-popup.d.ts +9 -1
- package/src/hover-popup.js +41 -25
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +27 -2
- package/src/index.js +26 -2
- package/src/input.d.ts +19 -0
- package/src/input.js +36 -0
- package/src/input.js.map +1 -0
- package/src/label.d.ts +5 -0
- package/src/label.js +18 -0
- package/src/label.js.map +1 -0
- package/src/listbox.d.ts +92 -0
- package/src/listbox.js +104 -0
- package/src/listbox.js.map +1 -0
- package/src/menu.d.ts +542 -0
- package/src/menu.js +235 -0
- package/src/menu.js.map +1 -0
- package/src/menubar-context.d.ts +5 -0
- package/src/menubar-context.js +6 -0
- package/src/menubar-context.js.map +1 -0
- package/src/menubar.d.ts +26 -0
- package/src/menubar.js +34 -0
- package/src/menubar.js.map +1 -0
- package/src/message-scroller.d.ts +20 -0
- package/src/message-scroller.js +34 -0
- package/src/message-scroller.js.map +1 -0
- package/src/navigation-menu.d.ts +91 -0
- package/src/navigation-menu.js +117 -0
- package/src/navigation-menu.js.map +1 -0
- package/src/number-field.d.ts +71 -0
- package/src/number-field.js +81 -0
- package/src/number-field.js.map +1 -0
- package/src/otp.d.ts +58 -0
- package/src/otp.js +86 -0
- package/src/otp.js.map +1 -0
- package/src/pagination.d.ts +61 -0
- package/src/pagination.js +70 -0
- package/src/pagination.js.map +1 -0
- package/src/popover.d.ts +5 -0
- package/src/popover.js +1 -1
- package/src/popover.js.map +1 -1
- package/src/qr-code.d.ts +24 -0
- package/src/qr-code.js +34 -0
- package/src/qr-code.js.map +1 -0
- package/src/radio-group.d.ts +2 -0
- package/src/radio-group.js +2 -0
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +48 -0
- package/src/resizable.js +62 -0
- package/src/resizable.js.map +1 -0
- package/src/runtime.d.ts +20 -1
- package/src/runtime.js +22 -3
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +32 -0
- package/src/scroll-area.js +63 -0
- package/src/scroll-area.js.map +1 -0
- package/src/select.d.ts +36 -1
- package/src/select.js +68 -4
- package/src/select.js.map +1 -1
- package/src/slider.d.ts +4 -0
- package/src/slider.js +2 -0
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +2 -0
- package/src/switch.js +2 -0
- package/src/switch.js.map +1 -1
- package/src/toast.d.ts +48 -0
- package/src/toast.js +66 -0
- package/src/toast.js.map +1 -0
- package/src/toggle-group.d.ts +41 -0
- package/src/toggle-group.js +46 -0
- package/src/toggle-group.js.map +1 -0
- package/src/toggle.d.ts +14 -1
- package/src/toggle.js +19 -4
- package/src/toggle.js.map +1 -1
- package/src/toolbar-context.d.ts +8 -0
- package/src/toolbar-context.js +8 -0
- package/src/toolbar-context.js.map +1 -0
- package/src/toolbar.d.ts +72 -0
- package/src/toolbar.js +55 -0
- package/src/toolbar.js.map +1 -0
- package/src/tooltip.d.ts +9 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Orientation } from "@kirana-ui/core";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
export declare const Resizable: {
|
|
4
|
+
Group: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
orientation: PropType<Orientation>;
|
|
6
|
+
keyboardStep: NumberConstructor;
|
|
7
|
+
disabled: BooleanConstructor;
|
|
8
|
+
id: StringConstructor;
|
|
9
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "sizesChange"[], "sizesChange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
|
+
orientation: PropType<Orientation>;
|
|
13
|
+
keyboardStep: NumberConstructor;
|
|
14
|
+
disabled: BooleanConstructor;
|
|
15
|
+
id: StringConstructor;
|
|
16
|
+
}>> & Readonly<{
|
|
17
|
+
onSizesChange?: ((...args: any[]) => any) | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
21
|
+
Panel: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
22
|
+
defaultSize: NumberConstructor;
|
|
23
|
+
minSize: NumberConstructor;
|
|
24
|
+
maxSize: NumberConstructor;
|
|
25
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
28
|
+
defaultSize: NumberConstructor;
|
|
29
|
+
minSize: NumberConstructor;
|
|
30
|
+
maxSize: NumberConstructor;
|
|
31
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
32
|
+
Handle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
33
|
+
disabled: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
|
+
disabled: {
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
}>> & Readonly<{}>, {
|
|
45
|
+
disabled: boolean;
|
|
46
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=resizable.d.ts.map
|
package/src/resizable.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useDirectionAround } from "./direction-context.js";
|
|
2
|
+
import { context, controller, optional, partComponent, toSignal } from "./runtime.js";
|
|
3
|
+
import { defined, within } from "@kirana-ui/core";
|
|
4
|
+
import { defineComponent, h, useId } from "vue";
|
|
5
|
+
import { createResizable } from "@kirana-ui/core/resizable";
|
|
6
|
+
// src/resizable.ts
|
|
7
|
+
const scope = context("Resizable");
|
|
8
|
+
const GroupElement = partComponent("ResizableGroupElement", "div", () => scope.use().group);
|
|
9
|
+
const Resizable = {
|
|
10
|
+
Group: defineComponent({
|
|
11
|
+
name: "ResizableGroup",
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
props: {
|
|
14
|
+
orientation: String,
|
|
15
|
+
keyboardStep: Number,
|
|
16
|
+
disabled: Boolean,
|
|
17
|
+
id: String
|
|
18
|
+
},
|
|
19
|
+
emits: ["sizesChange"],
|
|
20
|
+
setup(props, { attrs, slots, emit }) {
|
|
21
|
+
const generated = useId();
|
|
22
|
+
const direction = useDirectionAround();
|
|
23
|
+
scope.provide(controller(within(createResizable, { direction }), () => ({
|
|
24
|
+
id: props.id ?? generated,
|
|
25
|
+
orientation: props.orientation,
|
|
26
|
+
keyboardStep: props.keyboardStep,
|
|
27
|
+
disabled: props.disabled,
|
|
28
|
+
onSizesChange: (sizes, details) => emit("sizesChange", sizes, details)
|
|
29
|
+
})));
|
|
30
|
+
return () => h(GroupElement, attrs, slots);
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
Panel: defineComponent({
|
|
34
|
+
name: "ResizablePanel",
|
|
35
|
+
inheritAttrs: false,
|
|
36
|
+
props: {
|
|
37
|
+
defaultSize: Number,
|
|
38
|
+
minSize: Number,
|
|
39
|
+
maxSize: Number
|
|
40
|
+
},
|
|
41
|
+
setup(props, { attrs, slots }) {
|
|
42
|
+
const options = toSignal(() => ({ ...props }));
|
|
43
|
+
const part = scope.use().panel(() => defined(options.get()));
|
|
44
|
+
const Element = partComponent("ResizablePanelElement", "div", () => part);
|
|
45
|
+
return () => h(Element, attrs, slots);
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
Handle: defineComponent({
|
|
49
|
+
name: "ResizableHandle",
|
|
50
|
+
inheritAttrs: false,
|
|
51
|
+
props: { disabled: optional(Boolean) },
|
|
52
|
+
setup(props, { attrs, slots }) {
|
|
53
|
+
const options = toSignal(() => ({ disabled: props.disabled }));
|
|
54
|
+
const part = scope.use().handle(() => defined(options.get()));
|
|
55
|
+
const Element = partComponent("ResizableHandleElement", "div", () => part);
|
|
56
|
+
return () => h(Element, attrs, slots);
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
export { Resizable };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=resizable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/vue/src/resizable.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createResizable } from \"@kirana-ui/core/resizable\"\nimport type { Resizable as Controller } from \"@kirana-ui/core/resizable\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, optional, partComponent, toSignal } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"Resizable\")\n\nconst GroupElement = partComponent(\"ResizableGroupElement\", \"div\", () => scope.use().group)\n\n/** `@sizes-change=\"(sizes, details) => …\"` as the panels are resized. */\nconst Group = defineComponent({\n name: \"ResizableGroup\",\n inheritAttrs: false,\n props: {\n orientation: String as PropType<Orientation>,\n keyboardStep: Number,\n disabled: Boolean,\n id: String,\n },\n emits: [\"sizesChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createResizable, { direction }), () => ({\n id: props.id ?? generated,\n orientation: props.orientation,\n keyboardStep: props.keyboardStep,\n disabled: props.disabled,\n onSizesChange: (sizes: number[], details: ChangeDetails) =>\n emit(\"sizesChange\", sizes, details),\n }))\n )\n return () => h(GroupElement, attrs, slots)\n },\n})\n\nconst Panel = defineComponent({\n name: \"ResizablePanel\",\n inheritAttrs: false,\n props: { defaultSize: Number, minSize: Number, maxSize: Number },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().panel(() => defined(options.get()))\n const Element = partComponent(\"ResizablePanelElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n})\n\nconst Handle = defineComponent({\n name: \"ResizableHandle\",\n inheritAttrs: false,\n props: { disabled: optional(Boolean) },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const part = scope.use().handle(() => defined(options.get()))\n const Element = partComponent(\"ResizableHandleElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n})\n\nexport const Resizable = { Group, Panel, Handle }\n"],"mappings":";;;;;;AAUA,MAAM,QAAQ,QAAoB,WAAW;AAE7C,MAAM,eAAe,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;AAsD1F,MAAa,YAAY;CAAE,OAnDb,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GACL,aAAa;GACb,cAAc;GACd,UAAU;GACV,IAAI;EACN;EACA,OAAO,CAAC,aAAa;EACrB,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,YAAY,mBAAmB;GACrC,MAAM,QACJ,WAAW,OAAO,iBAAiB,EAAE,UAAU,CAAC,UAAU;IACxD,IAAI,MAAM,MAAM;IAChB,aAAa,MAAM;IACnB,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,gBAAgB,OAAiB,YAC/B,KAAK,eAAe,OAAO,OAAO;GACtC,EAAE,CACJ;GACA,aAAa,EAAE,cAAc,OAAO,KAAK;EAC3C;CACF,CA0B2B;CAAO,OAxBpB,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GAAE,aAAa;GAAQ,SAAS;GAAQ,SAAS;EAAO;EAC/D,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,gBAAgB,EAAE,GAAG,MAAM,EAAE;GAC7C,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,YAAY,QAAQ,QAAQ,IAAI,CAAC,CAAC;GAC3D,MAAM,UAAU,cAAc,yBAAyB,aAAa,IAAI;GACxE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAckC;CAAO,QAZ1B,gBAAgB;EAC7B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,UAAU,SAAS,OAAO,EAAE;EACrC,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;GAC7D,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC;GAC5D,MAAM,UAAU,cAAc,0BAA0B,aAAa,IAAI;GACzE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAEyC;AAAO"}
|
package/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Part, ReadonlySignal } from "@kirana-ui/core";
|
|
2
|
-
import { Component, ShallowRef } from "vue";
|
|
2
|
+
import { Component, PropType, ShallowRef, VNode } from "vue";
|
|
3
3
|
/** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */
|
|
4
4
|
export declare function fromSignal<T>(source: ReadonlySignal<T>): Readonly<ShallowRef<T>>;
|
|
5
5
|
/** A core signal that follows Vue state: the core hears a changed prop as it changes. */
|
|
@@ -19,6 +19,25 @@ export declare function context<C>(name: string): {
|
|
|
19
19
|
* attributes are merged under the part's, and the part's DOM work is attached to the element.
|
|
20
20
|
*/
|
|
21
21
|
export declare function partComponent(name: string, tag: string, resolve: () => Part): Component;
|
|
22
|
+
/**
|
|
23
|
+
* Says where every popup inside it is drawn, the popups those open included: an element of
|
|
24
|
+
* the page (a shadow root's host, a full-screen element) in place of `<body>`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const PortalProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
27
|
+
container: {
|
|
28
|
+
type: PropType<HTMLElement | null>;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
|
+
container: {
|
|
35
|
+
type: PropType<HTMLElement | null>;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
}>> & Readonly<{}>, {
|
|
39
|
+
container: HTMLElement | null;
|
|
40
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
22
41
|
/** Its slot in a container at the end of the page, while `mounted`. */
|
|
23
42
|
export declare function portalComponent(name: string, mounted: () => ReadonlySignal<boolean>): Component;
|
|
24
43
|
/** A prop that is "not given" when absent, where Vue would make a boolean `false`. */
|
package/src/runtime.js
CHANGED
|
@@ -88,7 +88,9 @@ function partComponent(name, tag, resolve) {
|
|
|
88
88
|
detach = wanted ? part.attach(wanted) : void 0;
|
|
89
89
|
};
|
|
90
90
|
const attach = (target) => {
|
|
91
|
-
|
|
91
|
+
let found = target instanceof HTMLElement ? target : target?.$el;
|
|
92
|
+
while (found instanceof Node && !(found instanceof HTMLElement)) found = found.nextSibling;
|
|
93
|
+
wanted = found instanceof HTMLElement ? found : null;
|
|
92
94
|
if (wanted) queuePostFlushCb(sync);
|
|
93
95
|
else sync();
|
|
94
96
|
};
|
|
@@ -106,17 +108,34 @@ function partComponent(name, tag, resolve) {
|
|
|
106
108
|
}
|
|
107
109
|
});
|
|
108
110
|
}
|
|
111
|
+
const PORTAL_CONTAINER = Symbol("PortalContainer");
|
|
112
|
+
/**
|
|
113
|
+
* Says where every popup inside it is drawn, the popups those open included: an element of
|
|
114
|
+
* the page (a shadow root's host, a full-screen element) in place of `<body>`.
|
|
115
|
+
*/
|
|
116
|
+
const PortalProvider = defineComponent({
|
|
117
|
+
name: "PortalProvider",
|
|
118
|
+
props: { container: {
|
|
119
|
+
type: null,
|
|
120
|
+
default: void 0
|
|
121
|
+
} },
|
|
122
|
+
setup(props, { slots }) {
|
|
123
|
+
provide(PORTAL_CONTAINER, () => props.container);
|
|
124
|
+
return () => slots.default?.();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
109
127
|
/** Its slot in a container at the end of the page, while `mounted`. */
|
|
110
128
|
function portalComponent(name, mounted) {
|
|
111
129
|
return defineComponent({
|
|
112
130
|
name,
|
|
113
131
|
setup(_props, { slots }) {
|
|
114
132
|
const shown = fromSignal(mounted());
|
|
133
|
+
const container = inject(PORTAL_CONTAINER, void 0);
|
|
115
134
|
const ready = shallowRef(false);
|
|
116
135
|
onMounted(() => {
|
|
117
136
|
ready.value = true;
|
|
118
137
|
});
|
|
119
|
-
return () => shown.value && ready.value ? h(Teleport, { to: "body" }, h("div", { "data-kirana-portal": "" }, slots.default?.())) : null;
|
|
138
|
+
return () => shown.value && ready.value ? h(Teleport, { to: container?.() ?? "body" }, h("div", { "data-kirana-portal": "" }, slots.default?.())) : null;
|
|
120
139
|
}
|
|
121
140
|
});
|
|
122
141
|
}
|
|
@@ -125,6 +144,6 @@ const optional = (type) => ({
|
|
|
125
144
|
type,
|
|
126
145
|
default: void 0
|
|
127
146
|
});
|
|
128
|
-
export { context, controller, fromSignal, optional, partComponent, portalComponent, toSignal };
|
|
147
|
+
export { PortalProvider, context, controller, fromSignal, optional, partComponent, portalComponent, toSignal };
|
|
129
148
|
|
|
130
149
|
//# sourceMappingURL=runtime.js.map
|
package/src/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/vue/src/runtime.ts"],"sourcesContent":["import { mergeProps, sameProps, signal } from \"@kirana-ui/core\"\nimport type { Part, PartProps, ReadonlySignal } from \"@kirana-ui/core\"\nimport {\n Comment,\n Fragment,\n Teleport,\n cloneVNode,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n onScopeDispose,\n provide,\n queuePostFlushCb,\n shallowRef,\n watchEffect,\n} from \"vue\"\nimport type { Component, InjectionKey, ShallowRef, VNode } from \"vue\"\n\n/** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */\nexport function fromSignal<T>(source: ReadonlySignal<T>): Readonly<ShallowRef<T>> {\n const ref = shallowRef(source.peek())\n // On a server nothing changes after the first read, and no scope is disposed to unsubscribe.\n if (typeof window !== \"undefined\") {\n onScopeDispose(\n source.subscribe(() => {\n ref.value = source.peek()\n })\n )\n }\n return ref\n}\n\n/** A core signal that follows Vue state: the core hears a changed prop as it changes. */\nexport function toSignal<T extends Record<string, unknown>>(read: () => T): ReadonlySignal<T> {\n const source = signal(read(), sameProps as (a: T, b: T) => boolean)\n watchEffect(() => source.set(read()), { flush: \"sync\" })\n return source\n}\n\n/** A component's controller, made once, following its props. */\nexport function controller<P extends Record<string, unknown>, C extends { mount(): () => void }>(\n create: (props: ReadonlySignal<P>) => C,\n read: () => P\n): C {\n const made = create(toSignal(read))\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = made.mount()\n })\n onBeforeUnmount(() => stop?.())\n return made\n}\n\n/** A controller its parts find: `provide` in the root, `use` in a part. */\nexport function context<C>(name: string): { provide(controller: C): C; use(): C } {\n const key: InjectionKey<C> = Symbol(name)\n return {\n provide(made) {\n provide(key, made)\n return made\n },\n use() {\n const made = inject(key, undefined)\n if (!made) throw new Error(`A ${name} part must be inside <${name}.Root>`)\n return made\n },\n }\n}\n\nfunction toVue(props: PartProps): PartProps {\n const out: PartProps = {}\n for (const key in props) {\n const value = props[key]\n if (typeof value === \"function\") {\n // Vue names an event from the listener's key, so `onKeyDown` would listen for `key-down`:\n // it is `onKeydown`. Focus and blur are the bubbling ones, as in the core.\n const name = key.slice(2).toLowerCase()\n const event = name === \"focus\" ? \"focusin\" : name === \"blur\" ? \"focusout\" : name\n out[`on${event[0]!.toUpperCase()}${event.slice(1)}`] = value\n } else {\n out[key] = value\n }\n }\n return out\n}\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\n/**\n * A part as a component: its element (`as`, the part's own tag by default), or with `as-child`\n * the caller's own element in its slot, which takes the part's props. Either way the caller's\n * attributes are merged under the part's, and the part's DOM work is attached to the element.\n */\nexport function partComponent(name: string, tag: string, resolve: () => Part): Component {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: { as: { type: String, default: tag }, asChild: Boolean },\n setup(props, { attrs, slots }) {\n const part = resolve()\n const own = fromSignal(part.props)\n let element: HTMLElement | null = null\n let detach: (() => void) | undefined\n\n // Vue calls a function ref as soon as the element exists, before the tree it is in reaches\n // the page: the part's DOM work (focus, measures, the starting style) waits for the flush\n // that follows the render, when it is there. An element that leaves detaches at once.\n let wanted: HTMLElement | null = null\n const sync = () => {\n if (wanted === element) return\n detach?.()\n element = wanted\n detach = wanted ? part.attach(wanted) : undefined\n }\n const attach = (target: unknown) => {\n
|
|
1
|
+
{"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/vue/src/runtime.ts"],"sourcesContent":["import { mergeProps, sameProps, signal } from \"@kirana-ui/core\"\nimport type { Part, PartProps, ReadonlySignal } from \"@kirana-ui/core\"\nimport {\n Comment,\n Fragment,\n Teleport,\n cloneVNode,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n onScopeDispose,\n provide,\n queuePostFlushCb,\n shallowRef,\n watchEffect,\n} from \"vue\"\nimport type { Component, InjectionKey, PropType, ShallowRef, VNode } from \"vue\"\n\n/** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */\nexport function fromSignal<T>(source: ReadonlySignal<T>): Readonly<ShallowRef<T>> {\n const ref = shallowRef(source.peek())\n // On a server nothing changes after the first read, and no scope is disposed to unsubscribe.\n if (typeof window !== \"undefined\") {\n onScopeDispose(\n source.subscribe(() => {\n ref.value = source.peek()\n })\n )\n }\n return ref\n}\n\n/** A core signal that follows Vue state: the core hears a changed prop as it changes. */\nexport function toSignal<T extends Record<string, unknown>>(read: () => T): ReadonlySignal<T> {\n const source = signal(read(), sameProps as (a: T, b: T) => boolean)\n watchEffect(() => source.set(read()), { flush: \"sync\" })\n return source\n}\n\n/** A component's controller, made once, following its props. */\nexport function controller<P extends Record<string, unknown>, C extends { mount(): () => void }>(\n create: (props: ReadonlySignal<P>) => C,\n read: () => P\n): C {\n const made = create(toSignal(read))\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = made.mount()\n })\n onBeforeUnmount(() => stop?.())\n return made\n}\n\n/** A controller its parts find: `provide` in the root, `use` in a part. */\nexport function context<C>(name: string): { provide(controller: C): C; use(): C } {\n const key: InjectionKey<C> = Symbol(name)\n return {\n provide(made) {\n provide(key, made)\n return made\n },\n use() {\n const made = inject(key, undefined)\n if (!made) throw new Error(`A ${name} part must be inside <${name}.Root>`)\n return made\n },\n }\n}\n\nfunction toVue(props: PartProps): PartProps {\n const out: PartProps = {}\n for (const key in props) {\n const value = props[key]\n if (typeof value === \"function\") {\n // Vue names an event from the listener's key, so `onKeyDown` would listen for `key-down`:\n // it is `onKeydown`. Focus and blur are the bubbling ones, as in the core.\n const name = key.slice(2).toLowerCase()\n const event = name === \"focus\" ? \"focusin\" : name === \"blur\" ? \"focusout\" : name\n out[`on${event[0]!.toUpperCase()}${event.slice(1)}`] = value\n } else {\n out[key] = value\n }\n }\n return out\n}\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\n/**\n * A part as a component: its element (`as`, the part's own tag by default), or with `as-child`\n * the caller's own element in its slot, which takes the part's props. Either way the caller's\n * attributes are merged under the part's, and the part's DOM work is attached to the element.\n */\nexport function partComponent(name: string, tag: string, resolve: () => Part): Component {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: { as: { type: String, default: tag }, asChild: Boolean },\n setup(props, { attrs, slots }) {\n const part = resolve()\n const own = fromSignal(part.props)\n let element: HTMLElement | null = null\n let detach: (() => void) | undefined\n\n // Vue calls a function ref as soon as the element exists, before the tree it is in reaches\n // the page: the part's DOM work (focus, measures, the starting style) waits for the flush\n // that follows the render, when it is there. An element that leaves detaches at once.\n let wanted: HTMLElement | null = null\n const sync = () => {\n if (wanted === element) return\n detach?.()\n element = wanted\n detach = wanted ? part.attach(wanted) : undefined\n }\n const attach = (target: unknown) => {\n // On a component (`as-child` over one), the ref is its instance: its root element, or\n // with several roots the first element after the fragment's own mark.\n let found: unknown =\n target instanceof HTMLElement ? target : (target as { $el?: unknown } | null)?.$el\n while (found instanceof Node && !(found instanceof HTMLElement)) found = found.nextSibling\n wanted = found instanceof HTMLElement ? found : null\n if (wanted) queuePostFlushCb(sync)\n else sync()\n }\n\n return () => {\n const merged = { ...mergeProps(attrs, toVue(own.value)), ref: attach }\n if (props.asChild) {\n const child = firstElement(slots.default?.())\n return child ? cloneVNode(child, merged, true) : null\n }\n return h(props.as, merged, slots.default?.())\n }\n },\n })\n}\n\nconst PORTAL_CONTAINER: InjectionKey<() => HTMLElement | null | undefined> =\n Symbol(\"PortalContainer\")\n\n/**\n * Says where every popup inside it is drawn, the popups those open included: an element of\n * the page (a shadow root's host, a full-screen element) in place of `<body>`.\n */\nexport const PortalProvider = defineComponent({\n name: \"PortalProvider\",\n props: {\n container: { type: null as unknown as PropType<HTMLElement | null>, default: undefined },\n },\n setup(props, { slots }) {\n provide(PORTAL_CONTAINER, () => props.container)\n return () => slots.default?.()\n },\n})\n\n/** Its slot in a container at the end of the page, while `mounted`. */\nexport function portalComponent(name: string, mounted: () => ReadonlySignal<boolean>): Component {\n return defineComponent({\n name,\n setup(_props, { slots }) {\n const shown = fromSignal(mounted())\n const container = inject(PORTAL_CONTAINER, undefined)\n // Only in a browser, once the page is in it: a server draws no portal, so hydration must\n // find none either. One that opens later is drawn at once.\n const ready = shallowRef(false)\n onMounted(() => {\n ready.value = true\n })\n return () =>\n shown.value && ready.value\n ? h(\n Teleport,\n { to: container?.() ?? \"body\" },\n h(\"div\", { \"data-kirana-portal\": \"\" }, slots.default?.())\n )\n : null\n },\n })\n}\n\n/** A prop that is \"not given\" when absent, where Vue would make a boolean `false`. */\nexport const optional = <T>(type: T) => ({ type, default: undefined })\n"],"mappings":";;;;AAqBA,SAAgB,WAAc,QAAoD;CAChF,MAAM,MAAM,WAAW,OAAO,KAAK,CAAC;CAEpC,IAAI,OAAO,WAAW,aACpB,eACE,OAAO,gBAAgB;EACrB,IAAI,QAAQ,OAAO,KAAK;CAC1B,CAAC,CACH;CAEF,OAAO;AACT;;AAGA,SAAgB,SAA4C,MAAkC;CAC5F,MAAM,SAAS,OAAO,KAAK,GAAG,SAAoC;CAClE,kBAAkB,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC;CACvD,OAAO;AACT;;AAGA,SAAgB,WACd,QACA,MACG;CACH,MAAM,OAAO,OAAO,SAAS,IAAI,CAAC;CAClC,IAAI;CACJ,gBAAgB;EACd,OAAO,KAAK,MAAM;CACpB,CAAC;CACD,sBAAsB,OAAO,CAAC;CAC9B,OAAO;AACT;;AAGA,SAAgB,QAAW,MAAuD;CAChF,MAAM,MAAuB,OAAO,IAAI;CACxC,OAAO;EACL,QAAQ,MAAM;GACZ,QAAQ,KAAK,IAAI;GACjB,OAAO;EACT;EACA,MAAM;GACJ,MAAM,OAAO,OAAO,KAAK,KAAA,CAAS;GAClC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,KAAK,KAAK,wBAAwB,KAAK,OAAO;GACzE,OAAO;EACT;CACF;AACF;AAEA,SAAS,MAAM,OAA6B;CAC1C,MAAM,MAAiB,CAAC;CACxB,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,QAAQ,MAAM;EACpB,IAAI,OAAO,UAAU,YAAY;GAG/B,MAAM,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY;GACtC,MAAM,QAAQ,SAAS,UAAU,YAAY,SAAS,SAAS,aAAa;GAC5E,IAAI,KAAK,MAAM,EAAE,CAAE,YAAY,IAAI,MAAM,MAAM,CAAC,OAAO;EACzD,OACE,IAAI,OAAO;CAEf;CACA,OA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WAAW;EAAE,MAAM;EAAiD,SAAS,KAAA;CAAU,EACzF;CACA,MAAM,OAAO,EAAE,SAAS;EACtB,QAAQ,wBAAwB,MAAM,SAAS;EAC/C,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAGD,SAAgB,gBAAgB,MAAc,SAAmD;CAC/F,OAAO,gBAAgB;EACrB;EACA,MAAM,QAAQ,EAAE,SAAS;GACvB,MAAM,QAAQ,WAAW,QAAQ,CAAC;GAClC,MAAM,YAAY,OAAO,kBAAkB,KAAA,CAAS;GAGpD,MAAM,QAAQ,WAAW,KAAK;GAC9B,gBAAgB;IACd,MAAM,QAAQ;GAChB,CAAC;GACD,aACE,MAAM,SAAS,MAAM,QACjB,EACE,UACA,EAAE,IAAI,YAAY,KAAK,OAAO,GAC9B,EAAE,OAAO,EAAE,sBAAsB,GAAG,GAAG,MAAM,UAAU,CAAC,CAC1D,IACA;EACR;CACF,CAAC;AACH;;AAGA,MAAa,YAAe,UAAa;CAAE;CAAM,SAAS,KAAA;AAAU"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Orientation } from "@kirana-ui/core";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
export declare const ScrollArea: {
|
|
4
|
+
Root: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
7
|
+
Viewport: import("vue").Component;
|
|
8
|
+
Content: import("vue").Component;
|
|
9
|
+
Scrollbar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
orientation: {
|
|
11
|
+
type: PropType<Orientation>;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
keepMounted: BooleanConstructor;
|
|
15
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
18
|
+
orientation: {
|
|
19
|
+
type: PropType<Orientation>;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
keepMounted: BooleanConstructor;
|
|
23
|
+
}>> & Readonly<{}>, {
|
|
24
|
+
orientation: Orientation;
|
|
25
|
+
keepMounted: boolean;
|
|
26
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
27
|
+
Thumb: import("vue").Component;
|
|
28
|
+
Corner: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=scroll-area.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useDirectionAround } from "./direction-context.js";
|
|
2
|
+
import { context, controller, fromSignal, partComponent } from "./runtime.js";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { defineComponent, h, inject, provide } from "vue";
|
|
5
|
+
import { createScrollArea } from "@kirana-ui/core/scroll-area";
|
|
6
|
+
// src/scroll-area.ts
|
|
7
|
+
const scope = context("ScrollArea");
|
|
8
|
+
const SCROLLBAR = Symbol("ScrollAreaScrollbar");
|
|
9
|
+
const Root = defineComponent({
|
|
10
|
+
name: "ScrollAreaRoot",
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
setup(_props, { attrs, slots }) {
|
|
13
|
+
const direction = useDirectionAround();
|
|
14
|
+
const made = scope.provide(controller(within(createScrollArea, { direction }), () => ({})));
|
|
15
|
+
const Element = partComponent("ScrollAreaRootElement", "div", () => made.root);
|
|
16
|
+
return () => h(Element, attrs, slots);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/** `orientation` is which way it scrolls (`vertical` by default). */
|
|
20
|
+
const Scrollbar = defineComponent({
|
|
21
|
+
name: "ScrollAreaScrollbar",
|
|
22
|
+
inheritAttrs: false,
|
|
23
|
+
props: {
|
|
24
|
+
orientation: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "vertical"
|
|
27
|
+
},
|
|
28
|
+
keepMounted: Boolean
|
|
29
|
+
},
|
|
30
|
+
setup(props, { attrs, slots }) {
|
|
31
|
+
const bar = scope.use().scrollbar(props.orientation);
|
|
32
|
+
provide(SCROLLBAR, bar);
|
|
33
|
+
const shown = fromSignal(bar.shown);
|
|
34
|
+
const Element = partComponent("ScrollAreaScrollbarElement", "div", () => bar.part);
|
|
35
|
+
return () => shown.value || props.keepMounted ? h(Element, attrs, slots) : null;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const Thumb = partComponent("ScrollAreaThumb", "div", () => {
|
|
39
|
+
const bar = inject(SCROLLBAR, void 0);
|
|
40
|
+
if (!bar) throw new Error("A ScrollArea.Thumb must be inside <ScrollArea.Scrollbar>");
|
|
41
|
+
return bar.thumb;
|
|
42
|
+
});
|
|
43
|
+
const Corner = defineComponent({
|
|
44
|
+
name: "ScrollAreaCorner",
|
|
45
|
+
inheritAttrs: false,
|
|
46
|
+
setup(_props, { attrs, slots }) {
|
|
47
|
+
const { corner } = scope.use();
|
|
48
|
+
const shown = fromSignal(corner.shown);
|
|
49
|
+
const Element = partComponent("ScrollAreaCornerElement", "div", () => corner.part);
|
|
50
|
+
return () => shown.value ? h(Element, attrs, slots) : null;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const ScrollArea = {
|
|
54
|
+
Root,
|
|
55
|
+
Viewport: partComponent("ScrollAreaViewport", "div", () => scope.use().viewport),
|
|
56
|
+
Content: partComponent("ScrollAreaContent", "div", () => scope.use().content),
|
|
57
|
+
Scrollbar,
|
|
58
|
+
Thumb,
|
|
59
|
+
Corner
|
|
60
|
+
};
|
|
61
|
+
export { ScrollArea };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=scroll-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-area.js","names":[],"sources":["../../../../packages/vue/src/scroll-area.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { Orientation } from \"@kirana-ui/core\"\nimport { createScrollArea } from \"@kirana-ui/core/scroll-area\"\nimport type { ScrollArea as Controller, ScrollAreaScrollbar } from \"@kirana-ui/core/scroll-area\"\nimport { defineComponent, h, inject, provide } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, fromSignal, partComponent } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"ScrollArea\")\nconst SCROLLBAR: InjectionKey<ScrollAreaScrollbar> = Symbol(\"ScrollAreaScrollbar\")\n\nconst Root = defineComponent({\n name: \"ScrollAreaRoot\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const direction = useDirectionAround()\n const made = scope.provide(controller(within(createScrollArea, { direction }), () => ({})))\n const Element = partComponent(\"ScrollAreaRootElement\", \"div\", () => made.root)\n return () => h(Element, attrs, slots)\n },\n})\n\n/** `orientation` is which way it scrolls (`vertical` by default). */\nconst Scrollbar = defineComponent({\n name: \"ScrollAreaScrollbar\",\n inheritAttrs: false,\n props: {\n orientation: { type: String as PropType<Orientation>, default: \"vertical\" },\n keepMounted: Boolean,\n },\n setup(props, { attrs, slots }) {\n const bar = scope.use().scrollbar(props.orientation)\n provide(SCROLLBAR, bar)\n const shown = fromSignal(bar.shown)\n const Element = partComponent(\"ScrollAreaScrollbarElement\", \"div\", () => bar.part)\n return () => (shown.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n})\n\nconst Thumb = partComponent(\"ScrollAreaThumb\", \"div\", () => {\n const bar = inject(SCROLLBAR, undefined)\n if (!bar) throw new Error(\"A ScrollArea.Thumb must be inside <ScrollArea.Scrollbar>\")\n return bar.thumb\n})\n\nconst Corner = defineComponent({\n name: \"ScrollAreaCorner\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const { corner } = scope.use()\n const shown = fromSignal(corner.shown)\n const Element = partComponent(\"ScrollAreaCornerElement\", \"div\", () => corner.part)\n return () => (shown.value ? h(Element, attrs, slots) : null)\n },\n})\n\nexport const ScrollArea = {\n Root,\n Viewport: partComponent(\"ScrollAreaViewport\", \"div\", () => scope.use().viewport),\n Content: partComponent(\"ScrollAreaContent\", \"div\", () => scope.use().content),\n Scrollbar,\n Thumb,\n Corner,\n}\n"],"mappings":";;;;;;AAUA,MAAM,QAAQ,QAAoB,YAAY;AAC9C,MAAM,YAA+C,OAAO,qBAAqB;AAEjF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,MAAM,QAAQ,EAAE,OAAO,SAAS;EAC9B,MAAM,YAAY,mBAAmB;EACrC,MAAM,OAAO,MAAM,QAAQ,WAAW,OAAO,kBAAkB,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;EAC1F,MAAM,UAAU,cAAc,yBAAyB,aAAa,KAAK,IAAI;EAC7E,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;;AAGD,MAAM,YAAY,gBAAgB;CAChC,MAAM;CACN,cAAc;CACd,OAAO;EACL,aAAa;GAAE,MAAM;GAAiC,SAAS;EAAW;EAC1E,aAAa;CACf;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,MAAM,MAAM,IAAI,CAAC,CAAC,UAAU,MAAM,WAAW;EACnD,QAAQ,WAAW,GAAG;EACtB,MAAM,QAAQ,WAAW,IAAI,KAAK;EAClC,MAAM,UAAU,cAAc,8BAA8B,aAAa,IAAI,IAAI;EACjF,aAAc,MAAM,SAAS,MAAM,cAAc,EAAE,SAAS,OAAO,KAAK,IAAI;CAC9E;AACF,CAAC;AAED,MAAM,QAAQ,cAAc,mBAAmB,aAAa;CAC1D,MAAM,MAAM,OAAO,WAAW,KAAA,CAAS;CACvC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,0DAA0D;CACpF,OAAO,IAAI;AACb,CAAC;AAED,MAAM,SAAS,gBAAgB;CAC7B,MAAM;CACN,cAAc;CACd,MAAM,QAAQ,EAAE,OAAO,SAAS;EAC9B,MAAM,EAAE,WAAW,MAAM,IAAI;EAC7B,MAAM,QAAQ,WAAW,OAAO,KAAK;EACrC,MAAM,UAAU,cAAc,2BAA2B,aAAa,OAAO,IAAI;EACjF,aAAc,MAAM,QAAQ,EAAE,SAAS,OAAO,KAAK,IAAI;CACzD;AACF,CAAC;AAED,MAAa,aAAa;CACxB;CACA,UAAU,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,QAAQ;CAC/E,SAAS,cAAc,qBAAqB,aAAa,MAAM,IAAI,CAAC,CAAC,OAAO;CAC5E;CACA;CACA;AACF"}
|
package/src/select.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PropType } from "vue";
|
|
2
|
+
import { SelectProps } from "@kirana-ui/core/select";
|
|
2
3
|
export declare const Select: {
|
|
3
4
|
Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
5
|
value: {
|
|
@@ -17,10 +18,12 @@ export declare const Select: {
|
|
|
17
18
|
disabled: BooleanConstructor;
|
|
18
19
|
required: BooleanConstructor;
|
|
19
20
|
name: StringConstructor;
|
|
21
|
+
form: StringConstructor;
|
|
20
22
|
items: PropType<readonly {
|
|
21
23
|
value: unknown;
|
|
22
24
|
label: string;
|
|
23
25
|
}[]>;
|
|
26
|
+
virtualized: PropType<SelectProps["virtualized"]>;
|
|
24
27
|
id: StringConstructor;
|
|
25
28
|
}>, () => (import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
26
29
|
[key: string]: any;
|
|
@@ -43,10 +46,12 @@ export declare const Select: {
|
|
|
43
46
|
disabled: BooleanConstructor;
|
|
44
47
|
required: BooleanConstructor;
|
|
45
48
|
name: StringConstructor;
|
|
49
|
+
form: StringConstructor;
|
|
46
50
|
items: PropType<readonly {
|
|
47
51
|
value: unknown;
|
|
48
52
|
label: string;
|
|
49
53
|
}[]>;
|
|
54
|
+
virtualized: PropType<SelectProps["virtualized"]>;
|
|
50
55
|
id: StringConstructor;
|
|
51
56
|
}>> & Readonly<{
|
|
52
57
|
onOpenChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -78,8 +83,36 @@ export declare const Select: {
|
|
|
78
83
|
placeholder: string;
|
|
79
84
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
80
85
|
Portal: import("vue").Component;
|
|
81
|
-
Positioner: import("vue").
|
|
86
|
+
Positioner: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
87
|
+
alignItemWithTrigger: BooleanConstructor;
|
|
88
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
91
|
+
alignItemWithTrigger: BooleanConstructor;
|
|
92
|
+
}>> & Readonly<{}>, {
|
|
93
|
+
alignItemWithTrigger: boolean;
|
|
94
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
82
95
|
Popup: import("vue").Component;
|
|
96
|
+
/** The items' own box inside the popup, when the popup also holds scroll arrows. */
|
|
97
|
+
List: import("vue").Component;
|
|
98
|
+
/** In the page while there is more of the list above: it scrolls it under a moving pointer. */
|
|
99
|
+
ScrollUpArrow: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
100
|
+
[key: string]: any;
|
|
101
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
102
|
+
/** In the page while there is more of the list below. */
|
|
103
|
+
ScrollDownArrow: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
104
|
+
[key: string]: any;
|
|
105
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
106
|
+
Group: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
107
|
+
id: StringConstructor;
|
|
108
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
111
|
+
id: StringConstructor;
|
|
112
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
113
|
+
GroupLabel: import("vue").Component;
|
|
114
|
+
/** A line between groups. */
|
|
115
|
+
Separator: import("vue").Component;
|
|
83
116
|
Item: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
84
117
|
value: {
|
|
85
118
|
type: PropType<unknown>;
|
|
@@ -90,6 +123,7 @@ export declare const Select: {
|
|
|
90
123
|
default: undefined;
|
|
91
124
|
};
|
|
92
125
|
label: StringConstructor;
|
|
126
|
+
index: NumberConstructor;
|
|
93
127
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
94
128
|
[key: string]: any;
|
|
95
129
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -102,6 +136,7 @@ export declare const Select: {
|
|
|
102
136
|
default: undefined;
|
|
103
137
|
};
|
|
104
138
|
label: StringConstructor;
|
|
139
|
+
index: NumberConstructor;
|
|
105
140
|
}>> & Readonly<{}>, {
|
|
106
141
|
disabled: boolean;
|
|
107
142
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/src/select.js
CHANGED
|
@@ -2,7 +2,7 @@ import { positionerComponent } from "./popover.js";
|
|
|
2
2
|
import { useFieldAround } from "./field-context.js";
|
|
3
3
|
import { context, controller, fromSignal, optional, partComponent, portalComponent, toSignal } from "./runtime.js";
|
|
4
4
|
import { defined, within } from "@kirana-ui/core";
|
|
5
|
-
import { defineComponent, h, inject, provide, useId } from "vue";
|
|
5
|
+
import { defineComponent, h, inject, onBeforeUnmount, onMounted, provide, useId, watchEffect } from "vue";
|
|
6
6
|
import { createSelect } from "@kirana-ui/core/select";
|
|
7
7
|
// src/select.ts
|
|
8
8
|
const scope = context("Select");
|
|
@@ -25,7 +25,9 @@ const Root = defineComponent({
|
|
|
25
25
|
disabled: Boolean,
|
|
26
26
|
required: Boolean,
|
|
27
27
|
name: String,
|
|
28
|
+
form: String,
|
|
28
29
|
items: Array,
|
|
30
|
+
virtualized: Object,
|
|
29
31
|
id: String
|
|
30
32
|
},
|
|
31
33
|
emits: [
|
|
@@ -46,7 +48,9 @@ const Root = defineComponent({
|
|
|
46
48
|
disabled: props.disabled,
|
|
47
49
|
required: props.required,
|
|
48
50
|
name: props.name,
|
|
51
|
+
form: props.form,
|
|
49
52
|
items: props.items,
|
|
53
|
+
virtualized: props.virtualized,
|
|
50
54
|
onValueChange(value, details) {
|
|
51
55
|
emit("valueChange", value, details);
|
|
52
56
|
if (!details.canceled) emit("update:value", value);
|
|
@@ -84,13 +88,15 @@ const Item = defineComponent({
|
|
|
84
88
|
required: true
|
|
85
89
|
},
|
|
86
90
|
disabled: optional(Boolean),
|
|
87
|
-
label: String
|
|
91
|
+
label: String,
|
|
92
|
+
index: Number
|
|
88
93
|
},
|
|
89
94
|
setup(props, { attrs, slots }) {
|
|
90
95
|
const value = props.value;
|
|
91
96
|
const options = toSignal(() => ({
|
|
92
97
|
disabled: props.disabled,
|
|
93
|
-
label: props.label
|
|
98
|
+
label: props.label,
|
|
99
|
+
index: props.index
|
|
94
100
|
}));
|
|
95
101
|
const part = scope.use().item(value, () => defined(options.get()));
|
|
96
102
|
provide(ITEM, value);
|
|
@@ -111,13 +117,71 @@ const ItemIndicator = defineComponent({
|
|
|
111
117
|
return () => selected.value || props.keepMounted ? h(Element, attrs, slots) : null;
|
|
112
118
|
}
|
|
113
119
|
});
|
|
120
|
+
const PlacedPositioner = positionerComponent("SelectPlacedPositioner", () => scope.use(), partComponent("SelectPositionerElement", "div", () => scope.use().positioner));
|
|
121
|
+
/**
|
|
122
|
+
* `align-item-with-trigger`: the list opens over its trigger, the chosen item's text on the
|
|
123
|
+
* trigger's own, where there is room and unless a finger opened it.
|
|
124
|
+
*/
|
|
125
|
+
const Positioner = defineComponent({
|
|
126
|
+
name: "SelectPositioner",
|
|
127
|
+
inheritAttrs: false,
|
|
128
|
+
props: { alignItemWithTrigger: Boolean },
|
|
129
|
+
setup(props, { attrs, slots }) {
|
|
130
|
+
const made = scope.use();
|
|
131
|
+
watchEffect(() => made.alignItemWithTrigger.set(props.alignItemWithTrigger), { flush: "sync" });
|
|
132
|
+
return () => h(PlacedPositioner, attrs, slots);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const GROUP = Symbol("SelectGroup");
|
|
136
|
+
/** Items that belong together, named by their `<Select.GroupLabel>`. */
|
|
137
|
+
const Group = defineComponent({
|
|
138
|
+
name: "SelectGroup",
|
|
139
|
+
inheritAttrs: false,
|
|
140
|
+
props: { id: String },
|
|
141
|
+
setup(props, { attrs, slots }) {
|
|
142
|
+
const generated = useId();
|
|
143
|
+
const group = scope.use().group(props.id ?? generated);
|
|
144
|
+
provide(GROUP, group);
|
|
145
|
+
const Element = partComponent("SelectGroupElement", "div", () => group.root);
|
|
146
|
+
return () => h(Element, attrs, slots);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
/** Names the group it is in. With no group around it, it is plain text. */
|
|
150
|
+
const GroupLabel = partComponent("SelectGroupLabel", "div", () => inject(GROUP, null)?.label ?? scope.use().groupLabel);
|
|
151
|
+
function scrollArrow(name, direction) {
|
|
152
|
+
return defineComponent({
|
|
153
|
+
name,
|
|
154
|
+
inheritAttrs: false,
|
|
155
|
+
setup(_props, { attrs, slots }) {
|
|
156
|
+
const arrow = scope.use().scrollArrow(direction);
|
|
157
|
+
let stop;
|
|
158
|
+
onMounted(() => {
|
|
159
|
+
stop = arrow.mount();
|
|
160
|
+
});
|
|
161
|
+
onBeforeUnmount(() => stop?.());
|
|
162
|
+
const mounted = fromSignal(arrow.mounted);
|
|
163
|
+
const Element = partComponent(`${name}Element`, "div", () => arrow.part);
|
|
164
|
+
return () => mounted.value ? h(Element, attrs, slots) : null;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
114
168
|
const Select = {
|
|
115
169
|
Root,
|
|
116
170
|
Trigger: partComponent("SelectTrigger", "button", () => scope.use().trigger),
|
|
117
171
|
Value,
|
|
118
172
|
Portal: portalComponent("SelectPortal", () => scope.use().mounted),
|
|
119
|
-
Positioner
|
|
173
|
+
Positioner,
|
|
120
174
|
Popup: partComponent("SelectPopup", "div", () => scope.use().popup),
|
|
175
|
+
/** The items' own box inside the popup, when the popup also holds scroll arrows. */
|
|
176
|
+
List: partComponent("SelectList", "div", () => scope.use().list),
|
|
177
|
+
/** In the page while there is more of the list above: it scrolls it under a moving pointer. */
|
|
178
|
+
ScrollUpArrow: scrollArrow("SelectScrollUpArrow", "up"),
|
|
179
|
+
/** In the page while there is more of the list below. */
|
|
180
|
+
ScrollDownArrow: scrollArrow("SelectScrollDownArrow", "down"),
|
|
181
|
+
Group,
|
|
182
|
+
GroupLabel,
|
|
183
|
+
/** A line between groups. */
|
|
184
|
+
Separator: partComponent("SelectSeparator", "div", () => scope.use().separator),
|
|
121
185
|
Item,
|
|
122
186
|
ItemText,
|
|
123
187
|
ItemIndicator
|
package/src/select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../../packages/vue/src/select.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type { Select as Controller } from \"@kirana-ui/core/select\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { positionerComponent } from \"./popover.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"Select\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"SelectItem\")\n\nconst HiddenInput = partComponent(\"SelectHiddenInput\", \"input\", () => scope.use().input)\n\n/** `v-model:value`, `v-model:open`; `@value-change` and `@open-change` carry the details. */\nconst Root = defineComponent({\n name: \"SelectRoot\",\n props: {\n value: { type: null as unknown as PropType<unknown>, default: undefined as unknown },\n defaultValue: { type: null as unknown as PropType<unknown>, default: null as unknown },\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n required: Boolean,\n name: String,\n items: Array as PropType<readonly { value: unknown; label: string }[]>,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createSelect, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n required: props.required,\n name: props.name,\n items: props.items,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n const named = fromSignal(made.named)\n return () => [slots.default?.(), named.value ? h(HiddenInput) : null]\n },\n})\n\nconst ValueElement = partComponent(\"SelectValueElement\", \"span\", () => scope.use().valuePart)\n\n/** Shows the chosen value's label, or `placeholder` while nothing is chosen. */\nconst Value = defineComponent({\n name: \"SelectValue\",\n inheritAttrs: false,\n props: { placeholder: { type: String, default: \"\" } },\n setup(props, { attrs, slots }) {\n const label = fromSignal(scope.use().label)\n return () => h(ValueElement, attrs, slots.default ?? (() => label.value ?? props.placeholder))\n },\n})\n\n/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"SelectItem\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, required: true },\n disabled: optional(Boolean),\n label: String,\n },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const options = toSignal(() => ({ disabled: props.disabled, label: props.label }))\n const part = scope.use().item(value, () => defined(options.get()))\n provide(ITEM, value)\n const Element = partComponent(\"SelectItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n})\n\nconst ItemText = partComponent(\"SelectItemText\", \"span\", () => scope.use().itemText(inject(ITEM)))\n\nconst ItemIndicator = defineComponent({\n name: \"SelectItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const value = inject(ITEM)\n const made = scope.use()\n const selected = fromSignal(made.selected(value))\n const Element = partComponent(\"SelectItemIndicatorElement\", \"span\", () =>\n made.itemIndicator(value)\n )\n return () => (selected.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n})\n\nexport const Select = {\n Root,\n Trigger: partComponent(\"SelectTrigger\", \"button\", () => scope.use().trigger),\n Value,\n Portal: portalComponent(\"SelectPortal\", () => scope.use().mounted),\n Positioner: positionerComponent(\n \"SelectPositioner\",\n () => scope.use(),\n partComponent(\"SelectPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent(\"SelectPopup\", \"div\", () => scope.use().popup),\n Item,\n ItemText,\n ItemIndicator,\n}\n"],"mappings":";;;;;;;AAmBA,MAAM,QAAQ,QAAoB,QAAQ;AAC1C,MAAM,OAA8B,OAAO,YAAY;AAEvD,MAAM,cAAc,cAAc,qBAAqB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;;AAGvF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,OAAO;GAAE,MAAM;GAAsC,SAAS,KAAA;EAAqB;EACnF,cAAc;GAAE,MAAM;GAAsC,SAAS;EAAgB;EACrF,MAAM,SAAS,OAAO;EACtB,aAAa;EACb,UAAU;EACV,UAAU;EACV,MAAM;EACN,OAAO;EACP,IAAI;CACN;CACA,OAAO;EAAC;EAAgB;EAAe;EAAe;CAAY;CAClE,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,eAAe;EAC7B,MAAM,OAAO,MAAM,QACjB,WAAW,OAAO,cAAc,EAAE,MAAM,CAAC,UAAU;GACjD,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,MAAM,MAAM;GACZ,OAAO,MAAM;GACb,cAAc,OAAgB,SAAwB;IACpD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;GACA,a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M;CACN,cAAc;CACd,OAAO,EAAE,aAAa,QAAQ;CAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,QAAQ,OAAO,IAAI;EACzB,MAAM,OAAO,MAAM,IAAI;EACvB,MAAM,WAAW,WAAW,KAAK,SAAS,KAAK,CAAC;EAChD,MAAM,UAAU,cAAc,8BAA8B,cAC1D,KAAK,cAAc,KAAK,CAC1B;EACA,aAAc,SAAS,SAAS,MAAM,cAAc,EAAE,SAAS,OAAO,KAAK,IAAI;CACjF;AACF,CAAC;AAED,MAAa,SAAS;CACpB;CACA,SAAS,cAAc,iBAAiB,gBAAgB,MAAM,IAAI,CAAC,CAAC,OAAO;CAC3E;CACA,QAAQ,gBAAgB,sBAAsB,MAAM,IAAI,CAAC,CAAC,OAAO;CACjE,YAAY,oBACV,0BACM,MAAM,IAAI,GAChB,cAAc,2BAA2B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAC9E;CACA,OAAO,cAAc,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CAClE;CACA;CACA;AACF"}
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../../packages/vue/src/select.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type { Select as Controller, SelectGroup, SelectProps } from \"@kirana-ui/core/select\"\nimport {\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n useId,\n watchEffect,\n} from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { positionerComponent } from \"./popover.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"Select\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"SelectItem\")\n\nconst HiddenInput = partComponent(\"SelectHiddenInput\", \"input\", () => scope.use().input)\n\n/** `v-model:value`, `v-model:open`; `@value-change` and `@open-change` carry the details. */\nconst Root = defineComponent({\n name: \"SelectRoot\",\n props: {\n value: { type: null as unknown as PropType<unknown>, default: undefined as unknown },\n defaultValue: { type: null as unknown as PropType<unknown>, default: null as unknown },\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n required: Boolean,\n name: String,\n form: String,\n items: Array as PropType<readonly { value: unknown; label: string }[]>,\n virtualized: Object as PropType<SelectProps[\"virtualized\"]>,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createSelect, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n required: props.required,\n name: props.name,\n form: props.form,\n items: props.items,\n virtualized: props.virtualized,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n const named = fromSignal(made.named)\n return () => [slots.default?.(), named.value ? h(HiddenInput) : null]\n },\n})\n\nconst ValueElement = partComponent(\"SelectValueElement\", \"span\", () => scope.use().valuePart)\n\n/** Shows the chosen value's label, or `placeholder` while nothing is chosen. */\nconst Value = defineComponent({\n name: \"SelectValue\",\n inheritAttrs: false,\n props: { placeholder: { type: String, default: \"\" } },\n setup(props, { attrs, slots }) {\n const label = fromSignal(scope.use().label)\n return () => h(ValueElement, attrs, slots.default ?? (() => label.value ?? props.placeholder))\n },\n})\n\n/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"SelectItem\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, required: true },\n disabled: optional(Boolean),\n label: String,\n index: Number,\n },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n index: props.index,\n }))\n const part = scope.use().item(value, () => defined(options.get()))\n provide(ITEM, value)\n const Element = partComponent(\"SelectItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n})\n\nconst ItemText = partComponent(\"SelectItemText\", \"span\", () => scope.use().itemText(inject(ITEM)))\n\nconst ItemIndicator = defineComponent({\n name: \"SelectItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const value = inject(ITEM)\n const made = scope.use()\n const selected = fromSignal(made.selected(value))\n const Element = partComponent(\"SelectItemIndicatorElement\", \"span\", () =>\n made.itemIndicator(value)\n )\n return () => (selected.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n})\n\nconst PlacedPositioner = positionerComponent(\n \"SelectPlacedPositioner\",\n () => scope.use(),\n partComponent(\"SelectPositionerElement\", \"div\", () => scope.use().positioner)\n)\n\n/**\n * `align-item-with-trigger`: the list opens over its trigger, the chosen item's text on the\n * trigger's own, where there is room and unless a finger opened it.\n */\nconst Positioner = defineComponent({\n name: \"SelectPositioner\",\n inheritAttrs: false,\n props: { alignItemWithTrigger: Boolean },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n watchEffect(() => made.alignItemWithTrigger.set(props.alignItemWithTrigger), {\n flush: \"sync\",\n })\n return () => h(PlacedPositioner, attrs, slots)\n },\n})\n\nconst GROUP: InjectionKey<SelectGroup | null> = Symbol(\"SelectGroup\")\n\n/** Items that belong together, named by their `<Select.GroupLabel>`. */\nconst Group = defineComponent({\n name: \"SelectGroup\",\n inheritAttrs: false,\n props: { id: String },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const group = scope.use().group(props.id ?? generated)\n provide(GROUP, group)\n const Element = partComponent(\"SelectGroupElement\", \"div\", () => group.root)\n return () => h(Element, attrs, slots)\n },\n})\n\n/** Names the group it is in. With no group around it, it is plain text. */\nconst GroupLabel = partComponent(\n \"SelectGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().groupLabel\n)\n\nfunction scrollArrow(name: string, direction: \"up\" | \"down\") {\n return defineComponent({\n name,\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const arrow = scope.use().scrollArrow(direction)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = arrow.mount()\n })\n onBeforeUnmount(() => stop?.())\n const mounted = fromSignal(arrow.mounted)\n const Element = partComponent(`${name}Element`, \"div\", () => arrow.part)\n return () => (mounted.value ? h(Element, attrs, slots) : null)\n },\n })\n}\n\nexport const Select = {\n Root,\n Trigger: partComponent(\"SelectTrigger\", \"button\", () => scope.use().trigger),\n Value,\n Portal: portalComponent(\"SelectPortal\", () => scope.use().mounted),\n Positioner,\n Popup: partComponent(\"SelectPopup\", \"div\", () => scope.use().popup),\n /** The items' own box inside the popup, when the popup also holds scroll arrows. */\n List: partComponent(\"SelectList\", \"div\", () => scope.use().list),\n /** In the page while there is more of the list above: it scrolls it under a moving pointer. */\n ScrollUpArrow: scrollArrow(\"SelectScrollUpArrow\", \"up\"),\n /** In the page while there is more of the list below. */\n ScrollDownArrow: scrollArrow(\"SelectScrollDownArrow\", \"down\"),\n Group,\n GroupLabel,\n /** A line between groups. */\n Separator: partComponent(\"SelectSeparator\", \"div\", () => scope.use().separator),\n Item,\n ItemText,\n ItemIndicator,\n}\n"],"mappings":";;;;;;;AA4BA,MAAM,QAAQ,QAAoB,QAAQ;AAC1C,MAAM,OAA8B,OAAO,YAAY;AAEvD,MAAM,cAAc,cAAc,qBAAqB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;;AAGvF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,OAAO;GAAE,MAAM;GAAsC,SAAS,KAAA;EAAqB;EACnF,cAAc;GAAE,MAAM;GAAsC,SAAS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AO;CACjE;CACA,OAAO,cAAc,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;;CAElE,MAAM,cAAc,cAAc,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;CAE/D,eAAe,YAAY,uBAAuB,IAAI;;CAEtD,iBAAiB,YAAY,yBAAyB,MAAM;CAC5D;CACA;;CAEA,WAAW,cAAc,mBAAmB,aAAa,MAAM,IAAI,CAAC,CAAC,SAAS;CAC9E;CACA;CACA;AACF"}
|
package/src/slider.d.ts
CHANGED
|
@@ -15,9 +15,11 @@ export declare const Slider: {
|
|
|
15
15
|
step: NumberConstructor;
|
|
16
16
|
largeStep: NumberConstructor;
|
|
17
17
|
minStepsBetweenValues: NumberConstructor;
|
|
18
|
+
thumbAlignment: PropType<SliderProps["thumbAlignment"]>;
|
|
18
19
|
orientation: PropType<"horizontal" | "vertical">;
|
|
19
20
|
disabled: BooleanConstructor;
|
|
20
21
|
name: StringConstructor;
|
|
22
|
+
form: StringConstructor;
|
|
21
23
|
format: PropType<Intl.NumberFormatOptions>;
|
|
22
24
|
locale: StringConstructor;
|
|
23
25
|
getAriaValueText: PropType<SliderProps["getAriaValueText"]>;
|
|
@@ -38,9 +40,11 @@ export declare const Slider: {
|
|
|
38
40
|
step: NumberConstructor;
|
|
39
41
|
largeStep: NumberConstructor;
|
|
40
42
|
minStepsBetweenValues: NumberConstructor;
|
|
43
|
+
thumbAlignment: PropType<SliderProps["thumbAlignment"]>;
|
|
41
44
|
orientation: PropType<"horizontal" | "vertical">;
|
|
42
45
|
disabled: BooleanConstructor;
|
|
43
46
|
name: StringConstructor;
|
|
47
|
+
form: StringConstructor;
|
|
44
48
|
format: PropType<Intl.NumberFormatOptions>;
|
|
45
49
|
locale: StringConstructor;
|
|
46
50
|
getAriaValueText: PropType<SliderProps["getAriaValueText"]>;
|