@kirana-ui/vue 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/llms.txt +3216 -0
  2. package/package.json +124 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +142 -0
  4. package/src/accordion.d.ts +42 -75
  5. package/src/accordion.js +4 -2
  6. package/src/accordion.js.map +1 -1
  7. package/src/agent.d.ts +1 -0
  8. package/src/agent.js +1 -0
  9. package/src/alert-dialog.d.ts +3 -2
  10. package/src/autocomplete.d.ts +4 -0
  11. package/src/autocomplete.js +1 -0
  12. package/src/autosize.d.ts +12 -0
  13. package/src/autosize.js +24 -0
  14. package/src/autosize.js.map +1 -0
  15. package/src/avatar.d.ts +10 -13
  16. package/src/avatar.js.map +1 -1
  17. package/src/button.d.ts +4 -21
  18. package/src/button.js.map +1 -1
  19. package/src/calendar.d.ts +73 -0
  20. package/src/calendar.js +130 -0
  21. package/src/calendar.js.map +1 -0
  22. package/src/carousel.d.ts +39 -0
  23. package/src/carousel.js +75 -0
  24. package/src/carousel.js.map +1 -0
  25. package/src/checkbox.d.ts +28 -48
  26. package/src/checkbox.js +4 -2
  27. package/src/checkbox.js.map +1 -1
  28. package/src/collapsible.d.ts +26 -36
  29. package/src/collapsible.js.map +1 -1
  30. package/src/combobox.d.ts +147 -0
  31. package/src/combobox.js +296 -0
  32. package/src/combobox.js.map +1 -0
  33. package/src/command.d.ts +46 -0
  34. package/src/command.js +129 -0
  35. package/src/command.js.map +1 -0
  36. package/src/context-menu.d.ts +4 -0
  37. package/src/context-menu.js +1 -0
  38. package/src/date-field.d.ts +40 -0
  39. package/src/date-field.js +81 -0
  40. package/src/date-field.js.map +1 -0
  41. package/src/date-picker.d.ts +89 -0
  42. package/src/date-picker.js +82 -0
  43. package/src/date-picker.js.map +1 -0
  44. package/src/dialog.d.ts +77 -78
  45. package/src/dialog.js +58 -1
  46. package/src/dialog.js.map +1 -1
  47. package/src/direction.d.ts +5 -8
  48. package/src/direction.js.map +1 -1
  49. package/src/drawer.d.ts +3 -0
  50. package/src/drawer.js +1 -0
  51. package/src/element.d.ts +23 -0
  52. package/src/element.js +90 -0
  53. package/src/element.js.map +1 -0
  54. package/src/field.d.ts +63 -45
  55. package/src/field.js +3 -2
  56. package/src/field.js.map +1 -1
  57. package/src/fieldset.d.ts +12 -13
  58. package/src/fieldset.js.map +1 -1
  59. package/src/form.d.ts +5 -15
  60. package/src/form.js.map +1 -1
  61. package/src/hover-card.d.ts +29 -35
  62. package/src/hover-card.js.map +1 -1
  63. package/src/hover-popup.d.ts +27 -38
  64. package/src/hover-popup.js +45 -26
  65. package/src/hover-popup.js.map +1 -1
  66. package/src/index.d.ts +37 -2
  67. package/src/index.js +26 -2
  68. package/src/input.d.ts +17 -0
  69. package/src/input.js +36 -0
  70. package/src/input.js.map +1 -0
  71. package/src/label.d.ts +5 -0
  72. package/src/label.js +18 -0
  73. package/src/label.js.map +1 -0
  74. package/src/listbox.d.ts +37 -0
  75. package/src/listbox.js +104 -0
  76. package/src/listbox.js.map +1 -0
  77. package/src/menu.d.ts +179 -0
  78. package/src/menu.js +235 -0
  79. package/src/menu.js.map +1 -0
  80. package/src/menubar-context.d.ts +5 -0
  81. package/src/menubar-context.js +6 -0
  82. package/src/menubar-context.js.map +1 -0
  83. package/src/menubar.d.ts +8 -0
  84. package/src/menubar.js +34 -0
  85. package/src/menubar.js.map +1 -0
  86. package/src/message-scroller.d.ts +26 -0
  87. package/src/message-scroller.js +34 -0
  88. package/src/message-scroller.js.map +1 -0
  89. package/src/meter.d.ts +10 -31
  90. package/src/meter.js.map +1 -1
  91. package/src/navigation-menu.d.ts +80 -0
  92. package/src/navigation-menu.js +118 -0
  93. package/src/navigation-menu.js.map +1 -0
  94. package/src/number-field.d.ts +75 -0
  95. package/src/number-field.js +81 -0
  96. package/src/number-field.js.map +1 -0
  97. package/src/otp.d.ts +37 -0
  98. package/src/otp.js +86 -0
  99. package/src/otp.js.map +1 -0
  100. package/src/pagination.d.ts +34 -0
  101. package/src/pagination.js +70 -0
  102. package/src/pagination.js.map +1 -0
  103. package/src/popover.d.ts +64 -35
  104. package/src/popover.js +34 -6
  105. package/src/popover.js.map +1 -1
  106. package/src/primitive.d.ts +21 -0
  107. package/src/primitive.js +27 -0
  108. package/src/primitive.js.map +1 -0
  109. package/src/progress.d.ts +28 -31
  110. package/src/progress.js.map +1 -1
  111. package/src/qr-code.d.ts +15 -0
  112. package/src/qr-code.js +34 -0
  113. package/src/qr-code.js.map +1 -0
  114. package/src/radio-group.d.ts +37 -73
  115. package/src/radio-group.js +4 -2
  116. package/src/radio-group.js.map +1 -1
  117. package/src/resizable.d.ts +29 -0
  118. package/src/resizable.js +62 -0
  119. package/src/resizable.js.map +1 -0
  120. package/src/runtime.d.ts +97 -6
  121. package/src/runtime.js +43 -25
  122. package/src/runtime.js.map +1 -1
  123. package/src/scroll-area.d.ts +37 -0
  124. package/src/scroll-area.js +63 -0
  125. package/src/scroll-area.js.map +1 -0
  126. package/src/select.d.ts +91 -116
  127. package/src/select.js +99 -10
  128. package/src/select.js.map +1 -1
  129. package/src/separator.d.ts +4 -9
  130. package/src/separator.js.map +1 -1
  131. package/src/slider.d.ts +61 -76
  132. package/src/slider.js +12 -10
  133. package/src/slider.js.map +1 -1
  134. package/src/switch.d.ts +21 -37
  135. package/src/switch.js +4 -2
  136. package/src/switch.js.map +1 -1
  137. package/src/tabs.d.ts +44 -98
  138. package/src/tabs.js.map +1 -1
  139. package/src/testing.d.ts +1 -0
  140. package/src/testing.js +1 -0
  141. package/src/toast.d.ts +61 -0
  142. package/src/toast.js +95 -0
  143. package/src/toast.js.map +1 -0
  144. package/src/toggle-group.d.ts +10 -0
  145. package/src/toggle-group.js +46 -0
  146. package/src/toggle-group.js.map +1 -0
  147. package/src/toggle.d.ts +9 -25
  148. package/src/toggle.js +19 -4
  149. package/src/toggle.js.map +1 -1
  150. package/src/toolbar-context.d.ts +8 -0
  151. package/src/toolbar-context.js +8 -0
  152. package/src/toolbar-context.js.map +1 -0
  153. package/src/toolbar.d.ts +34 -0
  154. package/src/toolbar.js +55 -0
  155. package/src/toolbar.js.map +1 -0
  156. package/src/tooltip.d.ts +29 -35
  157. package/src/tooltip.js.map +1 -1
  158. package/src/value-bar.d.ts +26 -35
  159. package/src/value-bar.js +10 -3
  160. package/src/value-bar.js.map +1 -1
@@ -0,0 +1,147 @@
1
+ import { Changes, Listeners, PartComponent, PartComponentProps, PlainComponent, PlainInstance, PortalProps } from "./runtime.js";
2
+ import { PositionerProps } from "./popover.js";
3
+ import { ChangeDetails } from "@kirana-ui/core";
4
+ import { PublicProps } from "vue";
5
+ import { AutocompleteProps } from "@kirana-ui/core/autocomplete";
6
+ import { ComboboxItemOptions, ComboboxProps } from "@kirana-ui/core/combobox";
7
+ export interface GroupProps extends PartComponentProps {
8
+ id?: string | undefined;
9
+ }
10
+ export type RootProps<Value = unknown> = Omit<ComboboxProps<Value>, "id" | "onValueChange" | "onValuesChange" | "onInputValueChange" | "onOpenChange"> & {
11
+ id?: string | undefined;
12
+ };
13
+ /** 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>;
15
+ export interface ItemProps extends Omit<ComboboxItemOptions, "id">, PartComponentProps {
16
+ /** What the combobox's value is while this item is the chosen one. */
17
+ value: unknown;
18
+ id?: string | undefined;
19
+ }
20
+ export interface ItemIndicatorProps extends PartComponentProps {
21
+ /** Keeps the mark in the page while its item is not chosen. */
22
+ keepMounted?: boolean | undefined;
23
+ }
24
+ export interface ClearProps extends PartComponentProps {
25
+ /** Keeps the button in the page while there is nothing to clear. */
26
+ keepMounted?: boolean | undefined;
27
+ }
28
+ export interface ChipProps extends PartComponentProps {
29
+ /** The chosen value it stands for: what its remove button takes away. */
30
+ value: unknown;
31
+ }
32
+ export type EmptyProps = PartComponentProps;
33
+ export type AutocompleteRootProps = Omit<AutocompleteProps, "id" | "value" | "onValueChange" | "onOpenChange"> & {
34
+ /** The text, which is the value: `v-model`. */
35
+ modelValue?: string | undefined;
36
+ id?: string | undefined;
37
+ };
38
+ export type AutocompleteRootEmits = {
39
+ "update:modelValue": (value: string) => void;
40
+ valueChange: (value: string, details: ChangeDetails) => void;
41
+ } & Changes<"open", boolean>;
42
+ export type InputProps = PartComponentProps;
43
+ export type TriggerProps = PartComponentProps;
44
+ export type ChipsProps = PartComponentProps;
45
+ export type ChipRemoveProps = PartComponentProps;
46
+ export type PopupProps = PartComponentProps;
47
+ export type ListProps = PartComponentProps;
48
+ export type GroupLabelProps = PartComponentProps;
49
+ export type SeparatorProps = PartComponentProps;
50
+ export declare const Combobox: {
51
+ Root: new <Value = unknown>(props: RootProps<Value> & Listeners<RootEmits<Value>> & PublicProps) => PlainInstance<RootProps<Value>, RootEmits<Value>, {}>;
52
+ Input: PartComponent<"input", {
53
+ readonly popupOpen?: true | undefined;
54
+ readonly disabled?: true | undefined;
55
+ }, PartComponentProps, {}, unknown>;
56
+ Trigger: PartComponent<"button", {
57
+ readonly popupOpen?: true | undefined;
58
+ readonly disabled?: true | undefined;
59
+ }, PartComponentProps, {}, unknown>;
60
+ Clear: PartComponent<"button", {
61
+ readonly disabled?: true | undefined;
62
+ }, ClearProps>;
63
+ /** With `multiple`: what holds the chips and the input. */
64
+ Chips: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
65
+ Chip: PartComponent<"span", Record<never, never>, ChipProps>;
66
+ ChipRemove: PartComponent<"button", {
67
+ readonly disabled?: true | undefined;
68
+ }, PartComponentProps, {}, unknown>;
69
+ Portal: PlainComponent<PortalProps, {}, {}>;
70
+ Positioner: PartComponent<"div", {
71
+ readonly open?: true | undefined;
72
+ readonly closed?: true | undefined;
73
+ readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
74
+ readonly align?: "center" | "end" | "start" | undefined;
75
+ }, PositionerProps>;
76
+ Popup: PartComponent<"div", {
77
+ readonly open?: true | undefined;
78
+ readonly closed?: true | undefined;
79
+ readonly startingStyle?: true | undefined;
80
+ readonly endingStyle?: true | undefined;
81
+ readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
82
+ readonly align?: "center" | "end" | "start" | undefined;
83
+ readonly empty?: true | undefined;
84
+ }, PartComponentProps, {}, unknown>;
85
+ /**
86
+ * The items' own box inside the popup, when the popup holds more than items (an input): it
87
+ * is then the listbox.
88
+ */
89
+ List: PartComponent<"div", {
90
+ readonly empty?: true | undefined;
91
+ }, PartComponentProps, {}, unknown>;
92
+ Group: PartComponent<"div", Record<never, never>, GroupProps>;
93
+ GroupLabel: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
94
+ /** A line between groups. */
95
+ Separator: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
96
+ Item: PartComponent<"div", {
97
+ readonly selected?: true | undefined;
98
+ readonly highlighted?: true | undefined;
99
+ readonly disabled?: true | undefined;
100
+ }, ItemProps>;
101
+ ItemIndicator: PartComponent<"span", Record<never, never>, ItemIndicatorProps>;
102
+ Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
103
+ };
104
+ export declare const Autocomplete: {
105
+ Root: PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>;
106
+ Input: PartComponent<"input", {
107
+ readonly popupOpen?: true | undefined;
108
+ readonly disabled?: true | undefined;
109
+ }, PartComponentProps, {}, unknown>;
110
+ Trigger: PartComponent<"button", {
111
+ readonly popupOpen?: true | undefined;
112
+ readonly disabled?: true | undefined;
113
+ }, PartComponentProps, {}, unknown>;
114
+ Clear: PartComponent<"button", {
115
+ readonly disabled?: true | undefined;
116
+ }, ClearProps>;
117
+ Portal: PlainComponent<PortalProps, {}, {}>;
118
+ Positioner: PartComponent<"div", {
119
+ readonly open?: true | undefined;
120
+ readonly closed?: true | undefined;
121
+ readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
122
+ readonly align?: "center" | "end" | "start" | undefined;
123
+ }, PositionerProps>;
124
+ Popup: PartComponent<"div", {
125
+ readonly open?: true | undefined;
126
+ readonly closed?: true | undefined;
127
+ readonly startingStyle?: true | undefined;
128
+ readonly endingStyle?: true | undefined;
129
+ readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
130
+ readonly align?: "center" | "end" | "start" | undefined;
131
+ readonly empty?: true | undefined;
132
+ }, PartComponentProps, {}, unknown>;
133
+ List: PartComponent<"div", {
134
+ readonly empty?: true | undefined;
135
+ }, PartComponentProps, {}, unknown>;
136
+ Group: PartComponent<"div", Record<never, never>, GroupProps>;
137
+ GroupLabel: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
138
+ Separator: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
139
+ Item: PartComponent<"div", {
140
+ readonly selected?: true | undefined;
141
+ readonly highlighted?: true | undefined;
142
+ readonly disabled?: true | undefined;
143
+ }, ItemProps>;
144
+ Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
145
+ };
146
+ export type { PortalProps, PositionerProps };
147
+ //# sourceMappingURL=combobox.d.ts.map
@@ -0,0 +1,296 @@
1
+ import { useFieldAround } from "./field-context.js";
2
+ import { positionerComponent } from "./popover.js";
3
+ import { context, controller, fromSignal, optional, partComponent, portalComponent, toSignal } from "./runtime.js";
4
+ import { within } from "@kirana-ui/core";
5
+ import { defineComponent, h, inject, provide, useId } from "vue";
6
+ import { createAutocomplete } from "@kirana-ui/core/autocomplete";
7
+ import { createCombobox } from "@kirana-ui/core/combobox";
8
+ // src/combobox.ts
9
+ const scope = context("Combobox");
10
+ const ITEM = Symbol("ComboboxItem");
11
+ const ANY = null;
12
+ const GROUP = Symbol("ComboboxGroup");
13
+ /** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */
14
+ const Group = defineComponent({
15
+ name: "ComboboxGroup",
16
+ inheritAttrs: false,
17
+ props: { id: String },
18
+ setup(props, { attrs, slots }) {
19
+ const generated = useId();
20
+ const group = scope.use().group(props.id ?? generated);
21
+ provide(GROUP, group);
22
+ const Element = partComponent("ComboboxGroupElement", "div", () => group.root);
23
+ return () => h(Element, attrs, slots);
24
+ }
25
+ });
26
+ /** Names the group it is in. With no group around it, it is plain text. */
27
+ const GroupLabel = partComponent("ComboboxGroupLabel", "div", () => inject(GROUP, null)?.label ?? scope.use().groupLabel);
28
+ const HiddenInput = partComponent("ComboboxHiddenInput", "input", () => scope.use().hidden);
29
+ /** `v-model:value`, `v-model:inputValue`, `v-model:open`; the `-change` events carry the details. */
30
+ const Root = defineComponent({
31
+ name: "ComboboxRoot",
32
+ props: {
33
+ value: {
34
+ type: ANY,
35
+ default: void 0
36
+ },
37
+ defaultValue: {
38
+ type: ANY,
39
+ default: null
40
+ },
41
+ inputValue: String,
42
+ defaultInputValue: String,
43
+ open: optional(Boolean),
44
+ defaultOpen: Boolean,
45
+ disabled: Boolean,
46
+ required: Boolean,
47
+ multiple: Boolean,
48
+ values: optional(Array),
49
+ defaultValues: Array,
50
+ inline: Boolean,
51
+ virtualized: Object,
52
+ autoHighlight: Boolean,
53
+ name: String,
54
+ form: String,
55
+ items: [Array, Object],
56
+ filter: {
57
+ type: null,
58
+ default: void 0
59
+ },
60
+ id: String
61
+ },
62
+ emits: [
63
+ "update:value",
64
+ "valueChange",
65
+ "update:inputValue",
66
+ "inputValueChange",
67
+ "update:open",
68
+ "openChange",
69
+ "update:values",
70
+ "valuesChange"
71
+ ],
72
+ setup(props, { slots, emit }) {
73
+ const generated = useId();
74
+ const field = useFieldAround();
75
+ const made = scope.provide(controller(within(createCombobox, { field }), () => ({
76
+ id: props.id ?? generated,
77
+ value: props.value,
78
+ defaultValue: props.defaultValue,
79
+ inputValue: props.inputValue,
80
+ defaultInputValue: props.defaultInputValue,
81
+ open: props.open,
82
+ defaultOpen: props.defaultOpen,
83
+ disabled: props.disabled,
84
+ required: props.required,
85
+ multiple: props.multiple,
86
+ values: props.values,
87
+ defaultValues: props.defaultValues,
88
+ onValuesChange(values, details) {
89
+ emit("valuesChange", values, details);
90
+ if (!details.canceled) emit("update:values", values);
91
+ },
92
+ inline: props.inline,
93
+ virtualized: props.virtualized,
94
+ autoHighlight: props.autoHighlight,
95
+ name: props.name,
96
+ form: props.form,
97
+ items: props.items,
98
+ filter: props.filter,
99
+ onValueChange(value, details) {
100
+ emit("valueChange", value, details);
101
+ if (!details.canceled) emit("update:value", value);
102
+ },
103
+ onInputValueChange(value, details) {
104
+ emit("inputValueChange", value, details);
105
+ if (!details.canceled) emit("update:inputValue", value);
106
+ },
107
+ onOpenChange(open, details) {
108
+ emit("openChange", open, details);
109
+ if (!details.canceled) emit("update:open", open);
110
+ }
111
+ })));
112
+ const named = fromSignal(made.named);
113
+ return () => [slots.default?.(), named.value ? h(HiddenInput) : null];
114
+ }
115
+ });
116
+ /** `label` is what is filtered and what the input shows; the item's text when left out. */
117
+ const Item = defineComponent({
118
+ name: "ComboboxItem",
119
+ inheritAttrs: false,
120
+ props: {
121
+ value: {
122
+ type: ANY,
123
+ required: true
124
+ },
125
+ disabled: optional(Boolean),
126
+ label: String,
127
+ id: String,
128
+ index: Number
129
+ },
130
+ setup(props, { attrs, slots }) {
131
+ const value = props.value;
132
+ const generated = useId();
133
+ const options = toSignal(() => ({
134
+ disabled: props.disabled,
135
+ label: props.label,
136
+ index: props.index,
137
+ id: props.id ?? generated
138
+ }));
139
+ const part = scope.use().item(value, () => options.get(), inject(GROUP, null) ?? void 0);
140
+ provide(ITEM, value);
141
+ const Element = partComponent("ComboboxItemElement", "div", () => part);
142
+ return () => h(Element, attrs, slots);
143
+ }
144
+ });
145
+ const ItemIndicator = defineComponent({
146
+ name: "ComboboxItemIndicator",
147
+ inheritAttrs: false,
148
+ props: { keepMounted: Boolean },
149
+ setup(props, { attrs, slots }) {
150
+ const value = inject(ITEM);
151
+ const made = scope.use();
152
+ const selected = fromSignal(made.selected(value));
153
+ const Element = partComponent("ComboboxItemIndicatorElement", "span", () => made.itemIndicator(value));
154
+ return () => selected.value || props.keepMounted ? h(Element, attrs, slots) : null;
155
+ }
156
+ });
157
+ /** A button that empties the input and the value. Drawn while there is something to clear. */
158
+ const Clear = defineComponent({
159
+ name: "ComboboxClear",
160
+ inheritAttrs: false,
161
+ props: { keepMounted: Boolean },
162
+ setup(props, { attrs, slots }) {
163
+ const made = scope.use();
164
+ const clearable = fromSignal(made.clearable);
165
+ const Element = partComponent("ComboboxClearElement", "button", () => made.clear);
166
+ return () => clearable.value || props.keepMounted ? h(Element, attrs, slots) : null;
167
+ }
168
+ });
169
+ const CHIP = Symbol("ComboboxChip");
170
+ /** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */
171
+ const Chip = defineComponent({
172
+ name: "ComboboxChip",
173
+ inheritAttrs: false,
174
+ props: { value: {
175
+ type: ANY,
176
+ required: true
177
+ } },
178
+ setup(props, { attrs, slots }) {
179
+ const value = props.value;
180
+ provide(CHIP, value);
181
+ const part = scope.use().chip(value);
182
+ const Element = partComponent("ComboboxChipElement", "span", () => part);
183
+ return () => h(Element, attrs, slots);
184
+ }
185
+ });
186
+ /** Drawn while no item is shown for what was typed. */
187
+ const Empty = defineComponent({
188
+ name: "ComboboxEmpty",
189
+ inheritAttrs: false,
190
+ setup(_props, { attrs, slots }) {
191
+ const made = scope.use();
192
+ const empty = fromSignal(made.empty);
193
+ const Element = partComponent("ComboboxEmptyElement", "div", () => made.emptyPart);
194
+ return () => empty.value ? h(Element, attrs, slots) : null;
195
+ }
196
+ });
197
+ /** A combobox whose text is the value: `v-model` is the text. The list only suggests. */
198
+ const AutocompleteRoot = defineComponent({
199
+ name: "AutocompleteRoot",
200
+ props: {
201
+ modelValue: String,
202
+ defaultValue: String,
203
+ open: optional(Boolean),
204
+ defaultOpen: Boolean,
205
+ mode: String,
206
+ filter: {
207
+ type: null,
208
+ default: void 0
209
+ },
210
+ openOnInputClick: Boolean,
211
+ disabled: Boolean,
212
+ required: Boolean,
213
+ name: String,
214
+ form: String,
215
+ virtualized: Object,
216
+ autoHighlight: Boolean,
217
+ id: String
218
+ },
219
+ emits: [
220
+ "update:modelValue",
221
+ "valueChange",
222
+ "update:open",
223
+ "openChange"
224
+ ],
225
+ setup(props, { slots, emit }) {
226
+ const generated = useId();
227
+ scope.provide(controller(within(createAutocomplete, { field: useFieldAround() }), () => ({
228
+ id: props.id ?? generated,
229
+ value: props.modelValue,
230
+ defaultValue: props.defaultValue,
231
+ open: props.open,
232
+ defaultOpen: props.defaultOpen,
233
+ mode: props.mode,
234
+ filter: props.filter,
235
+ openOnInputClick: props.openOnInputClick,
236
+ disabled: props.disabled,
237
+ required: props.required,
238
+ name: props.name,
239
+ form: props.form,
240
+ virtualized: props.virtualized,
241
+ autoHighlight: props.autoHighlight,
242
+ onValueChange(value, details) {
243
+ emit("valueChange", value, details);
244
+ if (!details.canceled) emit("update:modelValue", value);
245
+ },
246
+ onOpenChange(open, details) {
247
+ emit("openChange", open, details);
248
+ if (!details.canceled) emit("update:open", open);
249
+ }
250
+ })));
251
+ return () => slots.default?.();
252
+ }
253
+ });
254
+ const Combobox = {
255
+ Root,
256
+ Input: partComponent("ComboboxInput", "input", () => scope.use().input),
257
+ Trigger: partComponent("ComboboxTrigger", "button", () => scope.use().trigger),
258
+ Clear,
259
+ /** With `multiple`: what holds the chips and the input. */
260
+ Chips: partComponent("ComboboxChips", "div", () => scope.use().chips),
261
+ Chip,
262
+ ChipRemove: partComponent("ComboboxChipRemove", "button", () => scope.use().chipRemove(inject(CHIP))),
263
+ Portal: portalComponent("ComboboxPortal", () => scope.use().mounted),
264
+ Positioner: positionerComponent("ComboboxPositioner", () => scope.use(), partComponent("ComboboxPositionerElement", "div", () => scope.use().positioner)),
265
+ Popup: partComponent("ComboboxPopup", "div", () => scope.use().popup),
266
+ /**
267
+ * The items' own box inside the popup, when the popup holds more than items (an input): it
268
+ * is then the listbox.
269
+ */
270
+ List: partComponent("ComboboxList", "div", () => scope.use().list),
271
+ Group,
272
+ GroupLabel,
273
+ /** A line between groups. */
274
+ Separator: partComponent("ComboboxSeparator", "div", () => scope.use().separator),
275
+ Item,
276
+ ItemIndicator,
277
+ Empty
278
+ };
279
+ const Autocomplete = {
280
+ Root: AutocompleteRoot,
281
+ Input: Combobox.Input,
282
+ Trigger: Combobox.Trigger,
283
+ Clear: Combobox.Clear,
284
+ Portal: Combobox.Portal,
285
+ Positioner: Combobox.Positioner,
286
+ Popup: Combobox.Popup,
287
+ List: Combobox.List,
288
+ Group: Combobox.Group,
289
+ GroupLabel: Combobox.GroupLabel,
290
+ Separator: Combobox.Separator,
291
+ Item: Combobox.Item,
292
+ Empty: Combobox.Empty
293
+ };
294
+ export { Autocomplete, Combobox };
295
+
296
+ //# sourceMappingURL=combobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combobox.js","names":[],"sources":["../../../../packages/vue/src/combobox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createAutocomplete } from \"@kirana-ui/core/autocomplete\"\nimport type { AutocompleteProps } from \"@kirana-ui/core/autocomplete\"\nimport { createCombobox } from \"@kirana-ui/core/combobox\"\nimport type {\n Combobox as Controller,\n ComboboxGroup,\n ComboboxItemOptions,\n ComboboxProps,\n} from \"@kirana-ui/core/combobox\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useFieldAround } from \"./field-context.ts\"\nimport { positionerComponent } from \"./popover.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n Listeners,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n PlainInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"combobox\">\n\nconst scope = context<Controller>(\"Combobox\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"ComboboxItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nconst GROUP: InjectionKey<ComboboxGroup | null> = Symbol(\"ComboboxGroup\")\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */\nconst Group = defineComponent({\n name: \"ComboboxGroup\",\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(\"ComboboxGroupElement\", \"div\", () => group.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\n/** Names the group it is in. With no group around it, it is plain text. */\nconst GroupLabel = partComponent<\"div\", State[\"groupLabel\"]>(\n \"ComboboxGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().groupLabel\n)\n\nconst HiddenInput = partComponent(\"ComboboxHiddenInput\", \"input\", () => scope.use().hidden)\n\nexport type RootProps<Value = unknown> = Omit<\n ComboboxProps<Value>,\n \"id\" | \"onValueChange\" | \"onValuesChange\" | \"onInputValueChange\" | \"onOpenChange\"\n> & { id?: string | undefined }\n\n/** The value is `null` when the combobox is cleared. */\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value | null> &\n Changes<\"values\", Value[]> &\n Changes<\"inputValue\", string> &\n Changes<\"open\", boolean>\n\n/** `v-model:value`, `v-model:inputValue`, `v-model:open`; the `-change` events carry the details. */\nconst Root = defineComponent({\n name: \"ComboboxRoot\",\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n inputValue: String,\n defaultInputValue: String,\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n required: Boolean,\n multiple: Boolean,\n values: optional(Array as PropType<readonly unknown[]>),\n defaultValues: Array as PropType<readonly unknown[]>,\n inline: Boolean,\n virtualized: Object as PropType<ComboboxProps[\"virtualized\"]>,\n autoHighlight: Boolean,\n name: String,\n form: String,\n items: [Array, Object] as PropType<ComboboxProps[\"items\"]>,\n filter: {\n type: null as unknown as PropType<((label: string, query: string) => boolean) | null>,\n default: undefined,\n },\n id: String,\n },\n emits: [\n \"update:value\",\n \"valueChange\",\n \"update:inputValue\",\n \"inputValueChange\",\n \"update:open\",\n \"openChange\",\n \"update:values\",\n \"valuesChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createCombobox, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n required: props.required,\n multiple: props.multiple,\n values: props.values,\n defaultValues: props.defaultValues,\n onValuesChange(values: unknown[], details: ChangeDetails) {\n emit(\"valuesChange\", values, details)\n if (!details.canceled) emit(\"update:values\", values)\n },\n inline: props.inline,\n virtualized: props.virtualized,\n autoHighlight: props.autoHighlight,\n name: props.name,\n form: props.form,\n items: props.items,\n filter: props.filter,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", 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}) as unknown as new <Value = unknown>(\n props: RootProps<Value> & Listeners<RootEmits<Value>> & PublicProps\n) => PlainInstance<RootProps<Value>, RootEmits<Value>, {}>\n\nexport interface ItemProps extends Omit<ComboboxItemOptions, \"id\">, PartComponentProps {\n /** What the combobox's value is while this item is the chosen one. */\n value: unknown\n id?: string | undefined\n}\n\n/** `label` is what is filtered and what the input shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"ComboboxItem\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, required: true },\n disabled: optional(Boolean),\n label: String,\n id: 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 generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n index: props.index,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(value, () => options.get(), inject(GROUP, null) ?? undefined)\n provide(ITEM, value)\n const Element = partComponent(\"ComboboxItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface ItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not chosen. */\n keepMounted?: boolean | undefined\n}\n\nconst ItemIndicator = defineComponent({\n name: \"ComboboxItemIndicator\",\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(\"ComboboxItemIndicatorElement\", \"span\", () =>\n made.itemIndicator(value)\n )\n return () => (selected.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"itemIndicator\"], ItemIndicatorProps>\n\nexport interface ClearProps extends PartComponentProps {\n /** Keeps the button in the page while there is nothing to clear. */\n keepMounted?: boolean | undefined\n}\n\n/** A button that empties the input and the value. Drawn while there is something to clear. */\nconst Clear = defineComponent({\n name: \"ComboboxClear\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const clearable = fromSignal(made.clearable)\n const Element = partComponent(\"ComboboxClearElement\", \"button\", () => made.clear)\n return () => (clearable.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"button\", State[\"clear\"], ClearProps>\n\nconst CHIP: InjectionKey<unknown> = Symbol(\"ComboboxChip\")\n\nexport interface ChipProps extends PartComponentProps {\n /** The chosen value it stands for: what its remove button takes away. */\n value: unknown\n}\n\n/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */\nconst Chip = defineComponent({\n name: \"ComboboxChip\",\n inheritAttrs: false,\n props: { value: { type: ANY, required: true } },\n setup(props, { attrs, slots }) {\n // A chip is its value for as long as it is in the page.\n const value = props.value\n provide(CHIP, value)\n const part = scope.use().chip(value)\n const Element = partComponent(\"ComboboxChipElement\", \"span\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"chip\"], ChipProps>\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"ComboboxEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const empty = fromSignal(made.empty)\n const Element = partComponent(\"ComboboxEmptyElement\", \"div\", () => made.emptyPart)\n return () => (empty.value ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport type AutocompleteRootProps = Omit<\n AutocompleteProps,\n \"id\" | \"value\" | \"onValueChange\" | \"onOpenChange\"\n> & {\n /** The text, which is the value: `v-model`. */\n modelValue?: string | undefined\n id?: string | undefined\n}\n\nexport type AutocompleteRootEmits = {\n \"update:modelValue\": (value: string) => void\n valueChange: (value: string, details: ChangeDetails) => void\n} & Changes<\"open\", boolean>\n\n/** A combobox whose text is the value: `v-model` is the text. The list only suggests. */\nconst AutocompleteRoot = defineComponent({\n name: \"AutocompleteRoot\",\n props: {\n modelValue: String,\n defaultValue: String,\n open: optional(Boolean),\n defaultOpen: Boolean,\n mode: String as PropType<AutocompleteProps[\"mode\"]>,\n filter: {\n type: null as unknown as PropType<AutocompleteProps[\"filter\"]>,\n default: undefined,\n },\n openOnInputClick: Boolean,\n disabled: Boolean,\n required: Boolean,\n name: String,\n form: String,\n virtualized: Object as PropType<AutocompleteProps[\"virtualized\"]>,\n autoHighlight: Boolean,\n id: String,\n },\n emits: [\"update:modelValue\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createAutocomplete, { field: useFieldAround() }), () => ({\n id: props.id ?? generated,\n value: props.modelValue,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n mode: props.mode,\n filter: props.filter,\n openOnInputClick: props.openOnInputClick,\n disabled: props.disabled,\n required: props.required,\n name: props.name,\n form: props.form,\n virtualized: props.virtualized,\n autoHighlight: props.autoHighlight,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:modelValue\", 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 return () => slots.default?.()\n },\n}) as unknown as PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>\n\nexport type InputProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport type ChipsProps = PartComponentProps\nexport type ChipRemoveProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport const Combobox = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"ComboboxInput\", \"input\", () => scope.use().input),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"ComboboxTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Clear,\n /** With `multiple`: what holds the chips and the input. */\n Chips: partComponent<\"div\", State[\"chips\"]>(\"ComboboxChips\", \"div\", () => scope.use().chips),\n Chip,\n ChipRemove: partComponent<\"button\", State[\"chipRemove\"]>(\"ComboboxChipRemove\", \"button\", () =>\n scope.use().chipRemove(inject(CHIP))\n ),\n Portal: portalComponent(\"ComboboxPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"ComboboxPositioner\",\n () => scope.use(),\n partComponent(\"ComboboxPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"ComboboxPopup\", \"div\", () => scope.use().popup),\n /**\n * The items' own box inside the popup, when the popup holds more than items (an input): it\n * is then the listbox.\n */\n List: partComponent<\"div\", State[\"list\"]>(\"ComboboxList\", \"div\", () => scope.use().list),\n Group,\n GroupLabel,\n /** A line between groups. */\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"ComboboxSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Item,\n ItemIndicator,\n Empty,\n}\n\nexport const Autocomplete = {\n Root: AutocompleteRoot,\n Input: Combobox.Input,\n Trigger: Combobox.Trigger,\n Clear: Combobox.Clear,\n Portal: Combobox.Portal,\n Positioner: Combobox.Positioner,\n Popup: Combobox.Popup,\n List: Combobox.List,\n Group: Combobox.Group,\n GroupLabel: Combobox.GroupLabel,\n Separator: Combobox.Separator,\n Item: Combobox.Item,\n Empty: Combobox.Empty,\n}\n"],"mappings":";;;;;;;;AAwCA,MAAM,QAAQ,QAAoB,UAAU;AAC5C,MAAM,OAA8B,OAAO,cAAc;AACzD,MAAM,MAAM;AAEZ,MAAM,QAA4C,OAAO,eAAe;;AAOxE,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,IAAI,OAAO;CACpB,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,SAAS;EACrD,QAAQ,OAAO,KAAK;EACpB,MAAM,UAAU,cAAc,wBAAwB,aAAa,MAAM,IAAI;EAC7E,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;;AAGD,MAAM,aAAa,cACjB,sBACA,aACM,OAAO,OAAO,IAAI,CAAC,EAAE,SA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AAO,IAAI,CAAC,CACrC;CACA,QAAQ,gBAAgB,wBAAwB,MAAM,IAAI,CAAC,CAAC,OAAO;CACnE,YAAY,oBACV,4BACM,MAAM,IAAI,GAChB,cAAc,6BAA6B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAChF;CACA,OAAO,cAAqC,iBAAiB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;;;;;CAK3F,MAAM,cAAoC,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACvF;CACA;;CAEA,WAAW,cACT,qBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;CACA;CACA;AACF;AAEA,MAAa,eAAe;CAC1B,MAAM;CACN,OAAO,SAAS;CAChB,SAAS,SAAS;CAClB,OAAO,SAAS;CAChB,QAAQ,SAAS;CACjB,YAAY,SAAS;CACrB,OAAO,SAAS;CAChB,MAAM,SAAS;CACf,OAAO,SAAS;CAChB,YAAY,SAAS;CACrB,WAAW,SAAS;CACpB,MAAM,SAAS;CACf,OAAO,SAAS;AAClB"}
@@ -0,0 +1,46 @@
1
+ import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { ChangeDetails } from "@kirana-ui/core";
3
+ import { CommandItemOptions, CommandProps } from "@kirana-ui/core/command";
4
+ export type RootProps = Omit<CommandProps, "id" | "onInputValueChange" | "onSelect"> & {
5
+ id?: string | undefined;
6
+ } & PartComponentProps;
7
+ export type RootEmits = Changes<"inputValue", string> & {
8
+ /** An item was chosen: its value. */
9
+ select: (value: string, details: ChangeDetails) => void;
10
+ };
11
+ export type EmptyProps = PartComponentProps;
12
+ export interface GroupProps extends PartComponentProps {
13
+ id?: string | undefined;
14
+ }
15
+ export type GroupHeadingProps = PartComponentProps;
16
+ export interface ItemProps extends Omit<CommandItemOptions, "id">, PartComponentProps {
17
+ /** What `@select` is told when this item is chosen. */
18
+ value: string;
19
+ id?: string | undefined;
20
+ }
21
+ export interface SeparatorProps extends PartComponentProps {
22
+ /** Keeps the line while something is typed. */
23
+ alwaysRender?: boolean | undefined;
24
+ }
25
+ export type InputProps = PartComponentProps;
26
+ export type ListProps = PartComponentProps;
27
+ export declare const Command: {
28
+ Root: PartComponent<"div", {
29
+ readonly disabled?: true | undefined;
30
+ }, RootProps, RootEmits>;
31
+ Input: PartComponent<"input", {
32
+ readonly disabled?: true | undefined;
33
+ }, PartComponentProps, {}, unknown>;
34
+ List: PartComponent<"div", {
35
+ readonly empty?: true | undefined;
36
+ }, PartComponentProps, {}, unknown>;
37
+ Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
38
+ Group: PartComponent<"div", Record<never, never>, GroupProps>;
39
+ GroupHeading: PartComponent<"div", Record<never, never>, PartComponentProps>;
40
+ Item: PartComponent<"div", {
41
+ readonly highlighted?: true | undefined;
42
+ readonly disabled?: true | undefined;
43
+ }, ItemProps>;
44
+ Separator: PartComponent<"div", Record<never, never>, SeparatorProps>;
45
+ };
46
+ //# sourceMappingURL=command.d.ts.map
package/src/command.js ADDED
@@ -0,0 +1,129 @@
1
+ import { context, controller, fromSignal, optional, partComponent, toSignal } from "./runtime.js";
2
+ import { defineComponent, h, inject, provide, useId } from "vue";
3
+ import { createCommand } from "@kirana-ui/core/command";
4
+ // src/command.ts
5
+ const scope = context("Command");
6
+ const GROUP = Symbol("CommandGroup");
7
+ const RootElement = partComponent("CommandRootElement", "div", () => scope.use().root);
8
+ /** `v-model:inputValue`; `@select` hears the item chosen. */
9
+ const Root = defineComponent({
10
+ name: "CommandRoot",
11
+ inheritAttrs: false,
12
+ props: {
13
+ inputValue: String,
14
+ defaultInputValue: String,
15
+ filter: {
16
+ type: null,
17
+ default: void 0
18
+ },
19
+ loop: Boolean,
20
+ disabled: Boolean,
21
+ id: String
22
+ },
23
+ emits: [
24
+ "update:inputValue",
25
+ "inputValueChange",
26
+ "select"
27
+ ],
28
+ setup(props, { attrs, slots, emit }) {
29
+ const generated = useId();
30
+ scope.provide(controller(createCommand, () => ({
31
+ id: props.id ?? generated,
32
+ inputValue: props.inputValue,
33
+ defaultInputValue: props.defaultInputValue,
34
+ filter: props.filter,
35
+ loop: props.loop,
36
+ disabled: props.disabled,
37
+ onInputValueChange(value, details) {
38
+ emit("inputValueChange", value, details);
39
+ if (!details.canceled) emit("update:inputValue", value);
40
+ },
41
+ onSelect: (value, details) => emit("select", value, details)
42
+ })));
43
+ return () => h(RootElement, attrs, slots);
44
+ }
45
+ });
46
+ const EmptyElement = partComponent("CommandEmptyElement", "div", () => scope.use().emptyPart);
47
+ /** Drawn while no item is shown for what was typed. */
48
+ const Empty = defineComponent({
49
+ name: "CommandEmpty",
50
+ inheritAttrs: false,
51
+ setup(_props, { attrs, slots }) {
52
+ const empty = fromSignal(scope.use().empty);
53
+ return () => empty.value ? h(EmptyElement, attrs, slots) : null;
54
+ }
55
+ });
56
+ /** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
57
+ const Group = defineComponent({
58
+ name: "CommandGroup",
59
+ inheritAttrs: false,
60
+ props: { id: String },
61
+ setup(props, { attrs, slots }) {
62
+ const generated = useId();
63
+ const group = scope.use().group(props.id ?? generated);
64
+ provide(GROUP, group);
65
+ const Element = partComponent("CommandGroupElement", "div", () => group.part);
66
+ return () => h(Element, attrs, slots);
67
+ }
68
+ });
69
+ const GroupHeading = defineComponent({
70
+ name: "CommandGroupHeading",
71
+ inheritAttrs: false,
72
+ setup(_props, { attrs, slots }) {
73
+ const part = inject(GROUP, void 0)?.heading ?? scope.use().heading;
74
+ const Element = partComponent("CommandGroupHeadingElement", "div", () => part);
75
+ return () => h(Element, attrs, slots);
76
+ }
77
+ });
78
+ /** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */
79
+ const Item = defineComponent({
80
+ name: "CommandItem",
81
+ inheritAttrs: false,
82
+ props: {
83
+ value: {
84
+ type: String,
85
+ required: true
86
+ },
87
+ disabled: optional(Boolean),
88
+ label: String,
89
+ keywords: Array,
90
+ id: String
91
+ },
92
+ setup(props, { attrs, slots }) {
93
+ const generated = useId();
94
+ const options = toSignal(() => ({
95
+ disabled: props.disabled,
96
+ label: props.label,
97
+ keywords: props.keywords,
98
+ id: props.id ?? generated
99
+ }));
100
+ const part = scope.use().item(props.value, () => options.get(), inject(GROUP, void 0));
101
+ const Element = partComponent("CommandItemElement", "div", () => part);
102
+ return () => h(Element, attrs, slots);
103
+ }
104
+ });
105
+ /** A line between groups: gone while something is typed, unless `always-render`. */
106
+ const Separator = defineComponent({
107
+ name: "CommandSeparator",
108
+ inheritAttrs: false,
109
+ props: { alwaysRender: Boolean },
110
+ setup(props, { attrs, slots }) {
111
+ const options = toSignal(() => ({ alwaysRender: props.alwaysRender }));
112
+ const part = scope.use().separator(() => options.get().alwaysRender);
113
+ const Element = partComponent("CommandSeparatorElement", "div", () => part);
114
+ return () => h(Element, attrs, slots);
115
+ }
116
+ });
117
+ const Command = {
118
+ Root,
119
+ Input: partComponent("CommandInput", "input", () => scope.use().input),
120
+ List: partComponent("CommandList", "div", () => scope.use().list),
121
+ Empty,
122
+ Group,
123
+ GroupHeading,
124
+ Item,
125
+ Separator
126
+ };
127
+ export { Command };
128
+
129
+ //# sourceMappingURL=command.js.map