@kirana-ui/vue 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -0
- package/llms.txt +1495 -119
- package/package.json +44 -3
- package/skills/kirana-ui-primitives/SKILL.md +24 -4
- package/src/accordion.d.ts +4 -0
- package/src/accordion.js +6 -0
- package/src/accordion.js.map +1 -1
- package/src/autocomplete.d.ts +2 -2
- package/src/avatar.js +2 -2
- 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 +5 -2
- package/src/calendar.js +8 -2
- 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.d.ts +16 -0
- 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 +82 -4
- package/src/combobox.js +32 -9
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +2 -2
- package/src/command.js +1 -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 +33 -10
- package/src/date-picker.js +103 -61
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +22 -8
- package/src/dialog.js +40 -7
- package/src/dialog.js.map +1 -1
- 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 +27 -9
- package/src/index.js +11 -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/otp.d.ts +25 -3
- package/src/otp.js +20 -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 +6 -1
- package/src/popover.js +1 -1
- package/src/radio-group.d.ts +12 -0
- 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 +38 -5
- package/src/select.js +28 -9
- package/src/select.js.map +1 -1
- package/src/slider.d.ts +30 -0
- 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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ChangeDetails, Orientation } from "@kirana-ui/core";
|
|
3
|
+
import { ColorFormat, ColorPickerInputChannel, ColorPickerProps, ColorPickerSliderChannel } from "@kirana-ui/core/color-picker";
|
|
4
|
+
export type RootProps = Omit<ColorPickerProps, "id" | "onValueChange" | "onValueCommitted" | "onFormatChange"> & {
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
export type RootEmits = Changes<"value", string> & Changes<"format", ColorFormat> & {
|
|
8
|
+
/** The pointer let go, a key moved a thumb, a typed channel was left: the value to save. */
|
|
9
|
+
valueCommitted: (value: string, details: ChangeDetails) => void;
|
|
10
|
+
};
|
|
11
|
+
export interface ChannelSliderProps extends PartComponentProps {
|
|
12
|
+
/** The channel it moves: the hue, or the alpha. */
|
|
13
|
+
channel: ColorPickerSliderChannel;
|
|
14
|
+
/** The way its track runs. Default `horizontal`. */
|
|
15
|
+
orientation?: Orientation | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface ChannelInputProps extends PartComponentProps {
|
|
18
|
+
/** The channel it is typed in, or `hex` for the whole colour. */
|
|
19
|
+
channel: ColorPickerInputChannel;
|
|
20
|
+
}
|
|
21
|
+
export interface SwatchTriggerProps extends PartComponentProps {
|
|
22
|
+
/** The preset's colour, in any format: pressed, the colour is this one. */
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
export type AreaProps = PartComponentProps;
|
|
26
|
+
export type AreaThumbProps = PartComponentProps;
|
|
27
|
+
export type ChannelSliderTrackProps = PartComponentProps;
|
|
28
|
+
export type ChannelSliderThumbProps = PartComponentProps;
|
|
29
|
+
export type SwatchProps = PartComponentProps;
|
|
30
|
+
export type EyeDropperTriggerProps = PartComponentProps;
|
|
31
|
+
export type ValueTextProps = PartComponentProps;
|
|
32
|
+
export type FormatTriggerProps = PartComponentProps;
|
|
33
|
+
export declare const ColorPicker: {
|
|
34
|
+
Root: PartComponent<"div", {
|
|
35
|
+
readonly disabled?: true | undefined;
|
|
36
|
+
readonly readonly?: true | undefined;
|
|
37
|
+
readonly required?: true | undefined;
|
|
38
|
+
readonly dragging?: true | undefined;
|
|
39
|
+
readonly format?: "hex" | "hsl" | "rgb" | undefined;
|
|
40
|
+
}, RootProps, RootEmits>;
|
|
41
|
+
Area: PartComponent<"div", {
|
|
42
|
+
readonly disabled?: true | undefined;
|
|
43
|
+
readonly readonly?: true | undefined;
|
|
44
|
+
readonly required?: true | undefined;
|
|
45
|
+
readonly dragging?: true | undefined;
|
|
46
|
+
}, PartComponentProps, {}, unknown>;
|
|
47
|
+
AreaThumb: PartComponent<"div", {
|
|
48
|
+
readonly disabled?: true | undefined;
|
|
49
|
+
readonly readonly?: true | undefined;
|
|
50
|
+
readonly required?: true | undefined;
|
|
51
|
+
readonly dragging?: true | undefined;
|
|
52
|
+
}, PartComponentProps, {}, unknown>;
|
|
53
|
+
ChannelSlider: PartComponent<"div", {
|
|
54
|
+
readonly disabled?: true | undefined;
|
|
55
|
+
readonly readonly?: true | undefined;
|
|
56
|
+
readonly required?: true | undefined;
|
|
57
|
+
readonly dragging?: true | undefined;
|
|
58
|
+
readonly channel?: "alpha" | "hue" | undefined;
|
|
59
|
+
readonly orientation?: "horizontal" | "vertical" | undefined;
|
|
60
|
+
}, ChannelSliderProps>;
|
|
61
|
+
ChannelSliderTrack: PartComponent<"div", {
|
|
62
|
+
readonly disabled?: true | undefined;
|
|
63
|
+
readonly readonly?: true | undefined;
|
|
64
|
+
readonly required?: true | undefined;
|
|
65
|
+
readonly dragging?: true | undefined;
|
|
66
|
+
readonly channel?: "alpha" | "hue" | undefined;
|
|
67
|
+
readonly orientation?: "horizontal" | "vertical" | undefined;
|
|
68
|
+
}, PartComponentProps, {}, unknown>;
|
|
69
|
+
ChannelSliderThumb: PartComponent<"div", {
|
|
70
|
+
readonly disabled?: true | undefined;
|
|
71
|
+
readonly readonly?: true | undefined;
|
|
72
|
+
readonly required?: true | undefined;
|
|
73
|
+
readonly dragging?: true | undefined;
|
|
74
|
+
readonly channel?: "alpha" | "hue" | undefined;
|
|
75
|
+
readonly orientation?: "horizontal" | "vertical" | undefined;
|
|
76
|
+
}, PartComponentProps, {}, unknown>;
|
|
77
|
+
ChannelInput: PartComponent<"input", {
|
|
78
|
+
readonly disabled?: true | undefined;
|
|
79
|
+
readonly readonly?: true | undefined;
|
|
80
|
+
readonly required?: true | undefined;
|
|
81
|
+
readonly dragging?: true | undefined;
|
|
82
|
+
readonly channel?: "alpha" | "blue" | "green" | "hex" | "hue" | "lightness" | "red" | "saturation" | undefined;
|
|
83
|
+
}, ChannelInputProps>;
|
|
84
|
+
Swatch: PartComponent<"div", {
|
|
85
|
+
readonly disabled?: true | undefined;
|
|
86
|
+
readonly readonly?: true | undefined;
|
|
87
|
+
readonly required?: true | undefined;
|
|
88
|
+
readonly dragging?: true | undefined;
|
|
89
|
+
}, PartComponentProps, {}, unknown>;
|
|
90
|
+
SwatchTrigger: PartComponent<"button", {
|
|
91
|
+
readonly disabled?: true | undefined;
|
|
92
|
+
readonly readonly?: true | undefined;
|
|
93
|
+
readonly required?: true | undefined;
|
|
94
|
+
readonly dragging?: true | undefined;
|
|
95
|
+
readonly selected?: true | undefined;
|
|
96
|
+
}, SwatchTriggerProps>;
|
|
97
|
+
EyeDropperTrigger: PartComponent<"button", {
|
|
98
|
+
readonly disabled?: true | undefined;
|
|
99
|
+
readonly readonly?: true | undefined;
|
|
100
|
+
readonly required?: true | undefined;
|
|
101
|
+
readonly dragging?: true | undefined;
|
|
102
|
+
}, PartComponentProps, {}, unknown>;
|
|
103
|
+
ValueText: PartComponent<"span", {
|
|
104
|
+
readonly disabled?: true | undefined;
|
|
105
|
+
readonly readonly?: true | undefined;
|
|
106
|
+
readonly required?: true | undefined;
|
|
107
|
+
readonly dragging?: true | undefined;
|
|
108
|
+
readonly format?: "hex" | "hsl" | "rgb" | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
FormatTrigger: PartComponent<"button", {
|
|
111
|
+
readonly disabled?: true | undefined;
|
|
112
|
+
readonly readonly?: true | undefined;
|
|
113
|
+
readonly required?: true | undefined;
|
|
114
|
+
readonly dragging?: true | undefined;
|
|
115
|
+
readonly format?: "hex" | "hsl" | "rgb" | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=color-picker.d.ts.map
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { useDirectionAround } from "./direction-context.js";
|
|
2
|
+
import { written } from "./element.js";
|
|
3
|
+
import { useFieldAround } from "./field-context.js";
|
|
4
|
+
import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
|
|
5
|
+
import { within } from "@kirana-ui/core";
|
|
6
|
+
import { defineComponent, h, inject, provide, useId } from "vue";
|
|
7
|
+
import { createColorPicker } from "@kirana-ui/core/color-picker";
|
|
8
|
+
// src/color-picker.ts
|
|
9
|
+
const scope = context("ColorPicker");
|
|
10
|
+
const SLIDER = Symbol("ColorPickerSlider");
|
|
11
|
+
function useSliderOf() {
|
|
12
|
+
const slider = inject(SLIDER, void 0);
|
|
13
|
+
if (!slider) throw new Error("A ColorPicker part must be inside <ColorPicker.ChannelSlider>");
|
|
14
|
+
return slider;
|
|
15
|
+
}
|
|
16
|
+
const Input = partComponent("ColorPickerInput", "input", () => scope.use().input);
|
|
17
|
+
const RootElement = partComponent("ColorPickerRootElement", "div", () => scope.use().root, (content) => [content, h(Input)]);
|
|
18
|
+
/** `v-model:value` and `v-model:format`, or each with its `@…-change="(value, details) => …"`. */
|
|
19
|
+
const Root = defineComponent({
|
|
20
|
+
name: "ColorPickerRoot",
|
|
21
|
+
inheritAttrs: false,
|
|
22
|
+
props: {
|
|
23
|
+
value: optional(String),
|
|
24
|
+
defaultValue: String,
|
|
25
|
+
format: optional(String),
|
|
26
|
+
defaultFormat: String,
|
|
27
|
+
alpha: Boolean,
|
|
28
|
+
thumbAlignment: String,
|
|
29
|
+
disabled: Boolean,
|
|
30
|
+
readOnly: Boolean,
|
|
31
|
+
required: Boolean,
|
|
32
|
+
name: String,
|
|
33
|
+
form: String,
|
|
34
|
+
getAriaValueText: Function,
|
|
35
|
+
id: String
|
|
36
|
+
},
|
|
37
|
+
emits: [
|
|
38
|
+
"update:value",
|
|
39
|
+
"valueChange",
|
|
40
|
+
"valueCommitted",
|
|
41
|
+
"update:format",
|
|
42
|
+
"formatChange"
|
|
43
|
+
],
|
|
44
|
+
setup(props, { attrs, slots, emit }) {
|
|
45
|
+
const generated = useId();
|
|
46
|
+
const field = useFieldAround();
|
|
47
|
+
scope.provide(controller(within(createColorPicker, {
|
|
48
|
+
field,
|
|
49
|
+
direction: useDirectionAround()
|
|
50
|
+
}), () => ({
|
|
51
|
+
id: props.id ?? generated,
|
|
52
|
+
value: props.value,
|
|
53
|
+
defaultValue: props.defaultValue,
|
|
54
|
+
format: props.format,
|
|
55
|
+
defaultFormat: props.defaultFormat,
|
|
56
|
+
alpha: props.alpha,
|
|
57
|
+
thumbAlignment: props.thumbAlignment,
|
|
58
|
+
disabled: props.disabled,
|
|
59
|
+
readOnly: props.readOnly,
|
|
60
|
+
required: props.required,
|
|
61
|
+
name: props.name,
|
|
62
|
+
form: props.form,
|
|
63
|
+
getAriaValueText: props.getAriaValueText,
|
|
64
|
+
onValueChange(value, details) {
|
|
65
|
+
emit("valueChange", value, details);
|
|
66
|
+
if (!details.canceled) emit("update:value", value);
|
|
67
|
+
},
|
|
68
|
+
onValueCommitted: (value, details) => emit("valueCommitted", value, details),
|
|
69
|
+
onFormatChange(format, details) {
|
|
70
|
+
emit("formatChange", format, details);
|
|
71
|
+
if (!details.canceled) emit("update:format", format);
|
|
72
|
+
}
|
|
73
|
+
})));
|
|
74
|
+
return () => h(RootElement, attrs, slots);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
/** `channel` is what it moves, `hue` or `alpha`; its track and thumb are inside it. */
|
|
78
|
+
const ChannelSlider = defineComponent({
|
|
79
|
+
name: "ColorPickerChannelSlider",
|
|
80
|
+
inheritAttrs: false,
|
|
81
|
+
props: {
|
|
82
|
+
channel: {
|
|
83
|
+
type: String,
|
|
84
|
+
required: true
|
|
85
|
+
},
|
|
86
|
+
orientation: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: "horizontal"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
setup(props, { attrs, slots }) {
|
|
92
|
+
const made = scope.use();
|
|
93
|
+
const { channel, orientation } = props;
|
|
94
|
+
provide(SLIDER, {
|
|
95
|
+
channel,
|
|
96
|
+
orientation
|
|
97
|
+
});
|
|
98
|
+
const Element = partComponent("ColorPickerChannelSliderElement", "div", () => made.channelSlider(channel, orientation));
|
|
99
|
+
return () => h(Element, attrs, slots);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const ChannelInput = defineComponent({
|
|
103
|
+
name: "ColorPickerChannelInput",
|
|
104
|
+
inheritAttrs: false,
|
|
105
|
+
props: { channel: {
|
|
106
|
+
type: String,
|
|
107
|
+
required: true
|
|
108
|
+
} },
|
|
109
|
+
setup(props, { attrs, slots }) {
|
|
110
|
+
const made = scope.use();
|
|
111
|
+
const { channel } = props;
|
|
112
|
+
const Element = partComponent("ColorPickerChannelInputElement", "input", () => made.channelInput(channel));
|
|
113
|
+
return () => h(Element, attrs, slots);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const SwatchTrigger = defineComponent({
|
|
117
|
+
name: "ColorPickerSwatchTrigger",
|
|
118
|
+
inheritAttrs: false,
|
|
119
|
+
props: { value: {
|
|
120
|
+
type: String,
|
|
121
|
+
required: true
|
|
122
|
+
} },
|
|
123
|
+
setup(props, { attrs, slots }) {
|
|
124
|
+
const made = scope.use();
|
|
125
|
+
const { value } = props;
|
|
126
|
+
const Element = partComponent("ColorPickerSwatchTriggerElement", "button", () => made.swatchTrigger(value));
|
|
127
|
+
return () => h(Element, attrs, slots);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
/** Says the colour in its format unless its slot says something else. */
|
|
131
|
+
const ValueText = defineComponent({
|
|
132
|
+
name: "ColorPickerValueText",
|
|
133
|
+
inheritAttrs: false,
|
|
134
|
+
setup(_props, { attrs, slots }) {
|
|
135
|
+
const made = scope.use();
|
|
136
|
+
const text = fromSignal(made.text);
|
|
137
|
+
const Element = partComponent("ColorPickerValueTextElement", "span", () => made.valueText, written(() => text.value));
|
|
138
|
+
return () => h(Element, attrs, { default: (given) => slots.default?.(given) ?? text.value });
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
/** Says the format the colour is written in unless its slot says something else. */
|
|
142
|
+
const FormatTrigger = defineComponent({
|
|
143
|
+
name: "ColorPickerFormatTrigger",
|
|
144
|
+
inheritAttrs: false,
|
|
145
|
+
setup(_props, { attrs, slots }) {
|
|
146
|
+
const made = scope.use();
|
|
147
|
+
const format = fromSignal(made.format);
|
|
148
|
+
const Element = partComponent("ColorPickerFormatTriggerElement", "button", () => made.formatTrigger, written(() => format.value));
|
|
149
|
+
return () => h(Element, attrs, { default: (given) => slots.default?.(given) ?? format.value });
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const ColorPicker = {
|
|
153
|
+
Root,
|
|
154
|
+
Area: partComponent("ColorPickerArea", "div", () => scope.use().area),
|
|
155
|
+
AreaThumb: partComponent("ColorPickerAreaThumb", "div", () => scope.use().areaThumb),
|
|
156
|
+
ChannelSlider,
|
|
157
|
+
ChannelSliderTrack: partComponent("ColorPickerChannelSliderTrack", "div", () => {
|
|
158
|
+
const { channel, orientation } = useSliderOf();
|
|
159
|
+
return scope.use().channelSliderTrack(channel, orientation);
|
|
160
|
+
}),
|
|
161
|
+
ChannelSliderThumb: partComponent("ColorPickerChannelSliderThumb", "div", () => {
|
|
162
|
+
const { channel, orientation } = useSliderOf();
|
|
163
|
+
return scope.use().channelSliderThumb(channel, orientation);
|
|
164
|
+
}),
|
|
165
|
+
ChannelInput,
|
|
166
|
+
Swatch: partComponent("ColorPickerSwatch", "div", () => scope.use().swatch),
|
|
167
|
+
SwatchTrigger,
|
|
168
|
+
EyeDropperTrigger: partComponent("ColorPickerEyeDropperTrigger", "button", () => scope.use().eyeDropperTrigger),
|
|
169
|
+
ValueText,
|
|
170
|
+
FormatTrigger
|
|
171
|
+
};
|
|
172
|
+
export { ColorPicker };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=color-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-picker.js","names":[],"sources":["../../../../packages/vue/src/color-picker.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createColorPicker } from \"@kirana-ui/core/color-picker\"\nimport type {\n ColorFormat,\n ColorPicker as Controller,\n ColorPickerInputChannel,\n ColorPickerProps,\n ColorPickerSliderChannel,\n} from \"@kirana-ui/core/color-picker\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\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<\"colorPicker\">\n\nconst scope = context<Controller>(\"ColorPicker\")\n\n/** The channel a slider moves and the way it runs, for its track and its thumb. */\ninterface SliderOf {\n channel: ColorPickerSliderChannel\n orientation: Orientation\n}\nconst SLIDER: InjectionKey<SliderOf> = Symbol(\"ColorPickerSlider\")\n\nfunction useSliderOf(): SliderOf {\n const slider = inject(SLIDER, undefined)\n if (!slider) throw new Error(\"A ColorPicker part must be inside <ColorPicker.ChannelSlider>\")\n return slider\n}\n\nconst Input = partComponent(\"ColorPickerInput\", \"input\", () => scope.use().input)\n\n// The input a form reads is the element's last child, whatever element was asked for.\nconst RootElement = partComponent(\n \"ColorPickerRootElement\",\n \"div\",\n () => scope.use().root,\n (content) => [content, h(Input)]\n)\n\nexport type RootProps = Omit<\n ColorPickerProps,\n \"id\" | \"onValueChange\" | \"onValueCommitted\" | \"onFormatChange\"\n> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"value\", string> &\n Changes<\"format\", ColorFormat> & {\n /** The pointer let go, a key moved a thumb, a typed channel was left: the value to save. */\n valueCommitted: (value: string, details: ChangeDetails) => void\n }\n\n/** `v-model:value` and `v-model:format`, or each with its `@…-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"ColorPickerRoot\",\n inheritAttrs: false,\n props: {\n value: optional(String),\n defaultValue: String,\n format: optional(String as PropType<ColorFormat>),\n defaultFormat: String as PropType<ColorFormat>,\n alpha: Boolean,\n thumbAlignment: String as PropType<ColorPickerProps[\"thumbAlignment\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n getAriaValueText: Function as PropType<ColorPickerProps[\"getAriaValueText\"]>,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"valueCommitted\", \"update:format\", \"formatChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createColorPicker, { field, direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n format: props.format,\n defaultFormat: props.defaultFormat,\n alpha: props.alpha,\n thumbAlignment: props.thumbAlignment,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n getAriaValueText: props.getAriaValueText,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onValueCommitted: (value: string, details: ChangeDetails) =>\n emit(\"valueCommitted\", value, details),\n onFormatChange(format: ColorFormat, details: ChangeDetails) {\n emit(\"formatChange\", format, details)\n if (!details.canceled) emit(\"update:format\", format)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport interface ChannelSliderProps extends PartComponentProps {\n /** The channel it moves: the hue, or the alpha. */\n channel: ColorPickerSliderChannel\n /** The way its track runs. Default `horizontal`. */\n orientation?: Orientation | undefined\n}\n\n/** `channel` is what it moves, `hue` or `alpha`; its track and thumb are inside it. */\nconst ChannelSlider = defineComponent({\n name: \"ColorPickerChannelSlider\",\n inheritAttrs: false,\n props: {\n channel: { type: String as PropType<ColorPickerSliderChannel>, required: true },\n orientation: { type: String as PropType<Orientation>, default: \"horizontal\" },\n },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n // A slider is its channel and its way for as long as it is in the page.\n const { channel, orientation } = props\n provide(SLIDER, { channel, orientation })\n const Element = partComponent(\"ColorPickerChannelSliderElement\", \"div\", () =>\n made.channelSlider(channel, orientation)\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"channelSlider\"], ChannelSliderProps>\n\nexport interface ChannelInputProps extends PartComponentProps {\n /** The channel it is typed in, or `hex` for the whole colour. */\n channel: ColorPickerInputChannel\n}\n\n// Its text is the core's own, written as the colour changes, as a number field's input is.\nconst ChannelInput = defineComponent({\n name: \"ColorPickerChannelInput\",\n inheritAttrs: false,\n props: {\n channel: { type: String as PropType<ColorPickerInputChannel>, required: true },\n },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const { channel } = props\n const Element = partComponent(\"ColorPickerChannelInputElement\", \"input\", () =>\n made.channelInput(channel)\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"input\", State[\"channelInput\"], ChannelInputProps>\n\nexport interface SwatchTriggerProps extends PartComponentProps {\n /** The preset's colour, in any format: pressed, the colour is this one. */\n value: string\n}\n\nconst SwatchTrigger = defineComponent({\n name: \"ColorPickerSwatchTrigger\",\n inheritAttrs: false,\n props: { value: { type: String, required: true } },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const { value } = props\n const Element = partComponent(\"ColorPickerSwatchTriggerElement\", \"button\", () =>\n made.swatchTrigger(value)\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"swatchTrigger\"], SwatchTriggerProps>\n\n/** Says the colour in its format unless its slot says something else. */\nconst ValueText = defineComponent({\n name: \"ColorPickerValueText\",\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 \"ColorPickerValueTextElement\",\n \"span\",\n () => made.valueText,\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[\"valueText\"]>\n\n/** Says the format the colour is written in unless its slot says something else. */\nconst FormatTrigger = defineComponent({\n name: \"ColorPickerFormatTrigger\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const format = fromSignal(made.format)\n const Element = partComponent(\n \"ColorPickerFormatTriggerElement\",\n \"button\",\n () => made.formatTrigger,\n written(() => format.value)\n )\n return () =>\n h(Element, attrs, {\n default: (given: object) => slots.default?.(given) ?? format.value,\n })\n },\n}) as unknown as PartComponent<\"button\", State[\"formatTrigger\"]>\n\nexport type AreaProps = PartComponentProps\nexport type AreaThumbProps = PartComponentProps\nexport type ChannelSliderTrackProps = PartComponentProps\nexport type ChannelSliderThumbProps = PartComponentProps\nexport type SwatchProps = PartComponentProps\nexport type EyeDropperTriggerProps = PartComponentProps\nexport type ValueTextProps = PartComponentProps\nexport type FormatTriggerProps = PartComponentProps\nexport const ColorPicker = {\n Root,\n Area: partComponent<\"div\", State[\"area\"]>(\"ColorPickerArea\", \"div\", () => scope.use().area),\n AreaThumb: partComponent<\"div\", State[\"areaThumb\"]>(\n \"ColorPickerAreaThumb\",\n \"div\",\n () => scope.use().areaThumb\n ),\n ChannelSlider,\n ChannelSliderTrack: partComponent<\"div\", State[\"channelSliderTrack\"]>(\n \"ColorPickerChannelSliderTrack\",\n \"div\",\n () => {\n const { channel, orientation } = useSliderOf()\n return scope.use().channelSliderTrack(channel, orientation)\n }\n ),\n ChannelSliderThumb: partComponent<\"div\", State[\"channelSliderThumb\"]>(\n \"ColorPickerChannelSliderThumb\",\n \"div\",\n () => {\n const { channel, orientation } = useSliderOf()\n return scope.use().channelSliderThumb(channel, orientation)\n }\n ),\n ChannelInput,\n Swatch: partComponent<\"div\", State[\"swatch\"]>(\n \"ColorPickerSwatch\",\n \"div\",\n () => scope.use().swatch\n ),\n SwatchTrigger,\n EyeDropperTrigger: partComponent<\"button\", State[\"eyeDropperTrigger\"]>(\n \"ColorPickerEyeDropperTrigger\",\n \"button\",\n () => scope.use().eyeDropperTrigger\n ),\n ValueText,\n FormatTrigger,\n}\n"],"mappings":"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"}
|
package/src/combobox.d.ts
CHANGED
|
@@ -7,11 +7,14 @@ import { ComboboxEntry, ComboboxItemOptions, ComboboxProps, ComboboxShown } from
|
|
|
7
7
|
export interface GroupProps extends PartComponentProps {
|
|
8
8
|
id?: string | undefined;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/** `Multiple` is read from `multiple`: with it, `value` and `@value-change` hold a list. */
|
|
11
|
+
export type RootProps<Value = unknown, Multiple extends boolean | undefined = false> = Omit<ComboboxProps<Value, Multiple>, "id" | "multiple" | "onValueChange" | "onValuesChange" | "onInputValueChange" | "onOpenChange"> & {
|
|
11
12
|
id?: string | undefined;
|
|
13
|
+
/** Several values: `value` and `@value-change` then hold a list. Read once. */
|
|
14
|
+
multiple?: Multiple | undefined;
|
|
12
15
|
};
|
|
13
16
|
/** The value is `null` when the combobox is cleared. */
|
|
14
|
-
export type RootEmits<Value = unknown> = Changes<"value", Value | null> & Changes<"values", Value[]> & Changes<"inputValue", string> & Changes<"open", boolean>;
|
|
17
|
+
export type RootEmits<Value = unknown, Multiple extends boolean | undefined = false> = Changes<"value", Multiple extends true ? Value[] : Value | null> & Changes<"values", Value[]> & Changes<"inputValue", string> & Changes<"open", boolean>;
|
|
15
18
|
export interface ItemProps extends Omit<ComboboxItemOptions, "id">, PartComponentProps {
|
|
16
19
|
/** What the combobox's value is while this item is the chosen one. */
|
|
17
20
|
value: unknown;
|
|
@@ -52,38 +55,78 @@ export type TriggerProps = PartComponentProps;
|
|
|
52
55
|
export type ChipsProps = PartComponentProps;
|
|
53
56
|
export type ChipRemoveProps = PartComponentProps;
|
|
54
57
|
export type PopupProps = PartComponentProps;
|
|
58
|
+
export type BackdropProps = PartComponentProps;
|
|
55
59
|
export type ListProps = PartComponentProps;
|
|
56
60
|
export type GroupLabelProps = PartComponentProps;
|
|
57
61
|
export type SeparatorProps = PartComponentProps;
|
|
58
62
|
export type StatusProps = PartComponentProps;
|
|
59
63
|
export declare const Combobox: {
|
|
60
|
-
Root: new <Value = unknown>(props: RootProps<Value> & Listeners<RootEmits<Value>> & PublicProps) => PlainInstance<RootProps<Value>, RootEmits<Value>, {}>;
|
|
64
|
+
Root: new <Value = unknown, Multiple extends boolean | undefined = false>(props: RootProps<Value, Multiple> & Listeners<RootEmits<Value, Multiple>> & PublicProps) => PlainInstance<RootProps<Value, Multiple>, RootEmits<Value, Multiple>, {}>;
|
|
61
65
|
Input: PartComponent<"input", {
|
|
66
|
+
readonly touched?: true | undefined;
|
|
67
|
+
readonly dirty?: true | undefined;
|
|
68
|
+
readonly filled?: true | undefined;
|
|
69
|
+
readonly focused?: true | undefined;
|
|
70
|
+
readonly valid?: true | undefined;
|
|
71
|
+
readonly invalid?: true | undefined;
|
|
62
72
|
readonly popupOpen?: true | undefined;
|
|
73
|
+
readonly pressed?: true | undefined;
|
|
74
|
+
readonly popupSide?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
|
|
75
|
+
readonly listEmpty?: true | undefined;
|
|
63
76
|
readonly disabled?: true | undefined;
|
|
64
77
|
readonly readonly?: true | undefined;
|
|
78
|
+
readonly required?: true | undefined;
|
|
65
79
|
}, PartComponentProps, {}, unknown>;
|
|
66
80
|
Trigger: PartComponent<"button", {
|
|
81
|
+
readonly touched?: true | undefined;
|
|
82
|
+
readonly dirty?: true | undefined;
|
|
83
|
+
readonly filled?: true | undefined;
|
|
84
|
+
readonly focused?: true | undefined;
|
|
85
|
+
readonly valid?: true | undefined;
|
|
86
|
+
readonly invalid?: true | undefined;
|
|
67
87
|
readonly popupOpen?: true | undefined;
|
|
88
|
+
readonly pressed?: true | undefined;
|
|
89
|
+
readonly popupSide?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
|
|
90
|
+
readonly listEmpty?: true | undefined;
|
|
68
91
|
readonly disabled?: true | undefined;
|
|
69
92
|
readonly readonly?: true | undefined;
|
|
93
|
+
readonly required?: true | undefined;
|
|
70
94
|
}, PartComponentProps, {}, unknown>;
|
|
71
95
|
Value: PlainComponent<ValueProps, {}, ComboboxShown<unknown>>;
|
|
72
96
|
Clear: PartComponent<"button", {
|
|
73
97
|
readonly disabled?: true | undefined;
|
|
98
|
+
readonly popupOpen?: true | undefined;
|
|
99
|
+
readonly visible?: true | undefined;
|
|
100
|
+
readonly startingStyle?: true | undefined;
|
|
101
|
+
readonly endingStyle?: true | undefined;
|
|
74
102
|
}, ClearProps>;
|
|
75
103
|
/** With `multiple`: what holds the chips and the input. */
|
|
76
104
|
Chips: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
|
|
77
|
-
Chip: PartComponent<"span",
|
|
105
|
+
Chip: PartComponent<"span", {
|
|
106
|
+
readonly disabled?: true | undefined;
|
|
107
|
+
}, ChipProps>;
|
|
78
108
|
ChipRemove: PartComponent<"button", {
|
|
79
109
|
readonly disabled?: true | undefined;
|
|
80
110
|
}, PartComponentProps, {}, unknown>;
|
|
81
111
|
Portal: PlainComponent<PortalProps, {}, {}>;
|
|
112
|
+
/** What lies over the page behind the list: a sheet's (`presentation`) is modal. */
|
|
113
|
+
Backdrop: PartComponent<"div", {
|
|
114
|
+
readonly open?: true | undefined;
|
|
115
|
+
readonly closed?: true | undefined;
|
|
116
|
+
readonly startingStyle?: true | undefined;
|
|
117
|
+
readonly endingStyle?: true | undefined;
|
|
118
|
+
readonly presentation?: "popup" | "sheet" | undefined;
|
|
119
|
+
readonly swiping?: true | undefined;
|
|
120
|
+
readonly swipeDismiss?: true | undefined;
|
|
121
|
+
}, PartComponentProps, {}, unknown>;
|
|
82
122
|
Positioner: PartComponent<"div", {
|
|
83
123
|
readonly open?: true | undefined;
|
|
84
124
|
readonly closed?: true | undefined;
|
|
85
125
|
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
86
126
|
readonly align?: "center" | "end" | "start" | undefined;
|
|
127
|
+
readonly presentation?: "popup" | "sheet" | undefined;
|
|
128
|
+
readonly anchorHidden?: true | undefined;
|
|
129
|
+
readonly empty?: true | undefined;
|
|
87
130
|
}, PositionerProps>;
|
|
88
131
|
Popup: PartComponent<"div", {
|
|
89
132
|
readonly open?: true | undefined;
|
|
@@ -92,6 +135,10 @@ export declare const Combobox: {
|
|
|
92
135
|
readonly endingStyle?: true | undefined;
|
|
93
136
|
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
94
137
|
readonly align?: "center" | "end" | "start" | undefined;
|
|
138
|
+
readonly presentation?: "popup" | "sheet" | undefined;
|
|
139
|
+
readonly swiping?: true | undefined;
|
|
140
|
+
readonly swipeDismiss?: true | undefined;
|
|
141
|
+
readonly anchorHidden?: true | undefined;
|
|
95
142
|
readonly empty?: true | undefined;
|
|
96
143
|
}, PartComponentProps, {}, unknown>;
|
|
97
144
|
/**
|
|
@@ -120,17 +167,41 @@ export declare const Combobox: {
|
|
|
120
167
|
export declare const Autocomplete: {
|
|
121
168
|
Root: PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>;
|
|
122
169
|
Input: PartComponent<"input", {
|
|
170
|
+
readonly touched?: true | undefined;
|
|
171
|
+
readonly dirty?: true | undefined;
|
|
172
|
+
readonly filled?: true | undefined;
|
|
173
|
+
readonly focused?: true | undefined;
|
|
174
|
+
readonly valid?: true | undefined;
|
|
175
|
+
readonly invalid?: true | undefined;
|
|
123
176
|
readonly popupOpen?: true | undefined;
|
|
177
|
+
readonly pressed?: true | undefined;
|
|
178
|
+
readonly popupSide?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
|
|
179
|
+
readonly listEmpty?: true | undefined;
|
|
124
180
|
readonly disabled?: true | undefined;
|
|
125
181
|
readonly readonly?: true | undefined;
|
|
182
|
+
readonly required?: true | undefined;
|
|
126
183
|
}, PartComponentProps, {}, unknown>;
|
|
127
184
|
Trigger: PartComponent<"button", {
|
|
185
|
+
readonly touched?: true | undefined;
|
|
186
|
+
readonly dirty?: true | undefined;
|
|
187
|
+
readonly filled?: true | undefined;
|
|
188
|
+
readonly focused?: true | undefined;
|
|
189
|
+
readonly valid?: true | undefined;
|
|
190
|
+
readonly invalid?: true | undefined;
|
|
128
191
|
readonly popupOpen?: true | undefined;
|
|
192
|
+
readonly pressed?: true | undefined;
|
|
193
|
+
readonly popupSide?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
|
|
194
|
+
readonly listEmpty?: true | undefined;
|
|
129
195
|
readonly disabled?: true | undefined;
|
|
130
196
|
readonly readonly?: true | undefined;
|
|
197
|
+
readonly required?: true | undefined;
|
|
131
198
|
}, PartComponentProps, {}, unknown>;
|
|
132
199
|
Clear: PartComponent<"button", {
|
|
133
200
|
readonly disabled?: true | undefined;
|
|
201
|
+
readonly popupOpen?: true | undefined;
|
|
202
|
+
readonly visible?: true | undefined;
|
|
203
|
+
readonly startingStyle?: true | undefined;
|
|
204
|
+
readonly endingStyle?: true | undefined;
|
|
134
205
|
}, ClearProps>;
|
|
135
206
|
Portal: PlainComponent<PortalProps, {}, {}>;
|
|
136
207
|
Positioner: PartComponent<"div", {
|
|
@@ -138,6 +209,9 @@ export declare const Autocomplete: {
|
|
|
138
209
|
readonly closed?: true | undefined;
|
|
139
210
|
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
140
211
|
readonly align?: "center" | "end" | "start" | undefined;
|
|
212
|
+
readonly presentation?: "popup" | "sheet" | undefined;
|
|
213
|
+
readonly anchorHidden?: true | undefined;
|
|
214
|
+
readonly empty?: true | undefined;
|
|
141
215
|
}, PositionerProps>;
|
|
142
216
|
Popup: PartComponent<"div", {
|
|
143
217
|
readonly open?: true | undefined;
|
|
@@ -146,6 +220,10 @@ export declare const Autocomplete: {
|
|
|
146
220
|
readonly endingStyle?: true | undefined;
|
|
147
221
|
readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
|
|
148
222
|
readonly align?: "center" | "end" | "start" | undefined;
|
|
223
|
+
readonly presentation?: "popup" | "sheet" | undefined;
|
|
224
|
+
readonly swiping?: true | undefined;
|
|
225
|
+
readonly swipeDismiss?: true | undefined;
|
|
226
|
+
readonly anchorHidden?: true | undefined;
|
|
149
227
|
readonly empty?: true | undefined;
|
|
150
228
|
}, PartComponentProps, {}, unknown>;
|
|
151
229
|
List: PartComponent<"div", {
|
package/src/combobox.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDirectionAround } from "./direction-context.js";
|
|
1
2
|
import { useFieldAround } from "./field-context.js";
|
|
2
3
|
import { positionerComponent } from "./popover.js";
|
|
3
4
|
import { context, controller, fromSignal, optional, partComponent, portalComponent, toSignal } from "./runtime.js";
|
|
@@ -26,7 +27,10 @@ const Group = defineComponent({
|
|
|
26
27
|
/** Names the group it is in. With no group around it, it is plain text. */
|
|
27
28
|
const GroupLabel = partComponent("ComboboxGroupLabel", "div", () => inject(GROUP, null)?.label ?? scope.use().groupLabel);
|
|
28
29
|
const HiddenInput = partComponent("ComboboxHiddenInput", "input", () => scope.use().hidden);
|
|
29
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `v-model:value`, `v-model:inputValue`, `v-model:open`; the `-change` events carry the details.
|
|
32
|
+
* With `multiple`, the value is a list (`v-model:values`, the older shape, is still emitted).
|
|
33
|
+
*/
|
|
30
34
|
const Root = defineComponent({
|
|
31
35
|
name: "ComboboxRoot",
|
|
32
36
|
props: {
|
|
@@ -50,6 +54,8 @@ const Root = defineComponent({
|
|
|
50
54
|
defaultValues: Array,
|
|
51
55
|
inline: Boolean,
|
|
52
56
|
virtualized: Object,
|
|
57
|
+
presentation: String,
|
|
58
|
+
sheetBelow: Number,
|
|
53
59
|
autoHighlight: Boolean,
|
|
54
60
|
name: String,
|
|
55
61
|
form: String,
|
|
@@ -58,6 +64,14 @@ const Root = defineComponent({
|
|
|
58
64
|
type: null,
|
|
59
65
|
default: void 0
|
|
60
66
|
},
|
|
67
|
+
itemToStringLabel: {
|
|
68
|
+
type: Function,
|
|
69
|
+
default: void 0
|
|
70
|
+
},
|
|
71
|
+
itemToStringValue: {
|
|
72
|
+
type: Function,
|
|
73
|
+
default: void 0
|
|
74
|
+
},
|
|
61
75
|
id: String
|
|
62
76
|
},
|
|
63
77
|
emits: [
|
|
@@ -73,7 +87,10 @@ const Root = defineComponent({
|
|
|
73
87
|
setup(props, { slots, emit }) {
|
|
74
88
|
const generated = useId();
|
|
75
89
|
const field = useFieldAround();
|
|
76
|
-
const made = scope.provide(controller(within(createCombobox, {
|
|
90
|
+
const made = scope.provide(controller(within(createCombobox, {
|
|
91
|
+
field,
|
|
92
|
+
direction: useDirectionAround()
|
|
93
|
+
}), () => ({
|
|
77
94
|
id: props.id ?? generated,
|
|
78
95
|
value: props.value,
|
|
79
96
|
defaultValue: props.defaultValue,
|
|
@@ -87,20 +104,23 @@ const Root = defineComponent({
|
|
|
87
104
|
multiple: props.multiple,
|
|
88
105
|
values: props.values,
|
|
89
106
|
defaultValues: props.defaultValues,
|
|
90
|
-
onValuesChange(values, details) {
|
|
91
|
-
emit("valuesChange", values, details);
|
|
92
|
-
if (!details.canceled) emit("update:values", values);
|
|
93
|
-
},
|
|
94
107
|
inline: props.inline,
|
|
95
108
|
virtualized: props.virtualized,
|
|
109
|
+
presentation: props.presentation,
|
|
110
|
+
sheetBelow: props.sheetBelow,
|
|
96
111
|
autoHighlight: props.autoHighlight,
|
|
97
112
|
name: props.name,
|
|
98
113
|
form: props.form,
|
|
99
114
|
items: props.items,
|
|
100
115
|
filter: props.filter,
|
|
116
|
+
itemToStringLabel: props.itemToStringLabel,
|
|
117
|
+
itemToStringValue: props.itemToStringValue,
|
|
101
118
|
onValueChange(value, details) {
|
|
102
119
|
emit("valueChange", value, details);
|
|
103
120
|
if (!details.canceled) emit("update:value", value);
|
|
121
|
+
if (!props.multiple || !Array.isArray(value)) return;
|
|
122
|
+
emit("valuesChange", value, details);
|
|
123
|
+
if (!details.canceled) emit("update:values", value);
|
|
104
124
|
},
|
|
105
125
|
onInputValueChange(value, details) {
|
|
106
126
|
emit("inputValueChange", value, details);
|
|
@@ -151,9 +171,10 @@ const ItemIndicator = defineComponent({
|
|
|
151
171
|
setup(props, { attrs, slots }) {
|
|
152
172
|
const value = inject(ITEM);
|
|
153
173
|
const made = scope.use();
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
|
|
174
|
+
const indicator = controller(() => made.itemIndicator(value), () => ({}));
|
|
175
|
+
const mounted = fromSignal(indicator.mounted);
|
|
176
|
+
const Element = partComponent("ComboboxItemIndicatorElement", "span", () => indicator);
|
|
177
|
+
return () => mounted.value || props.keepMounted ? h(Element, attrs, slots) : null;
|
|
157
178
|
}
|
|
158
179
|
});
|
|
159
180
|
/** A button that empties the input and the value. Drawn while there is something to clear. */
|
|
@@ -305,6 +326,8 @@ const Combobox = {
|
|
|
305
326
|
Chip,
|
|
306
327
|
ChipRemove: partComponent("ComboboxChipRemove", "button", () => scope.use().chipRemove(inject(CHIP))),
|
|
307
328
|
Portal: portalComponent("ComboboxPortal", () => scope.use().mounted),
|
|
329
|
+
/** What lies over the page behind the list: a sheet's (`presentation`) is modal. */
|
|
330
|
+
Backdrop: partComponent("ComboboxBackdrop", "div", () => scope.use().backdrop),
|
|
308
331
|
Positioner: positionerComponent("ComboboxPositioner", () => scope.use(), partComponent("ComboboxPositionerElement", "div", () => scope.use().positioner)),
|
|
309
332
|
Popup: partComponent("ComboboxPopup", "div", () => scope.use().popup),
|
|
310
333
|
/**
|