@kirana-ui/vue 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1779 -182
  3. package/package.json +48 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +53 -12
  5. package/src/accordion.d.ts +4 -0
  6. package/src/accordion.js +6 -0
  7. package/src/accordion.js.map +1 -1
  8. package/src/alert-dialog.d.ts +2 -2
  9. package/src/autocomplete.d.ts +2 -2
  10. package/src/avatar.d.ts +31 -4
  11. package/src/avatar.js +40 -16
  12. package/src/avatar.js.map +1 -1
  13. package/src/button.d.ts +4 -1
  14. package/src/button.js +4 -1
  15. package/src/button.js.map +1 -1
  16. package/src/calendar.d.ts +22 -13
  17. package/src/calendar.js +83 -12
  18. package/src/calendar.js.map +1 -1
  19. package/src/carousel.d.ts +5 -2
  20. package/src/carousel.js +1 -4
  21. package/src/carousel.js.map +1 -1
  22. package/src/checkbox-group-context.d.ts +5 -0
  23. package/src/checkbox-group-context.js +6 -0
  24. package/src/checkbox-group-context.js.map +1 -0
  25. package/src/checkbox-group.d.ts +12 -0
  26. package/src/checkbox-group.js +44 -0
  27. package/src/checkbox-group.js.map +1 -0
  28. package/src/checkbox.d.ts +17 -0
  29. package/src/checkbox.js +9 -2
  30. package/src/checkbox.js.map +1 -1
  31. package/src/collapsible.d.ts +2 -0
  32. package/src/color-picker.d.ts +118 -0
  33. package/src/color-picker.js +174 -0
  34. package/src/color-picker.js.map +1 -0
  35. package/src/combobox.d.ts +105 -5
  36. package/src/combobox.js +83 -12
  37. package/src/combobox.js.map +1 -1
  38. package/src/command.d.ts +2 -2
  39. package/src/command.js +3 -1
  40. package/src/command.js.map +1 -1
  41. package/src/date-field.d.ts +1 -1
  42. package/src/date-field.js +2 -0
  43. package/src/date-field.js.map +1 -1
  44. package/src/date-picker.d.ts +39 -13
  45. package/src/date-picker.js +104 -51
  46. package/src/date-picker.js.map +1 -1
  47. package/src/dialog.d.ts +41 -8
  48. package/src/dialog.js +44 -8
  49. package/src/dialog.js.map +1 -1
  50. package/src/drawer.d.ts +2 -2
  51. package/src/editable.d.ts +87 -0
  52. package/src/editable.js +83 -0
  53. package/src/editable.js.map +1 -0
  54. package/src/element.js +5 -5
  55. package/src/element.js.map +1 -1
  56. package/src/file-upload.d.ts +76 -0
  57. package/src/file-upload.js +139 -0
  58. package/src/file-upload.js.map +1 -0
  59. package/src/hover-card.d.ts +3 -0
  60. package/src/index.d.ts +28 -7
  61. package/src/index.js +12 -1
  62. package/src/menu.d.ts +10 -0
  63. package/src/menu.js +17 -6
  64. package/src/menu.js.map +1 -1
  65. package/src/menubar.js +10 -1
  66. package/src/menubar.js.map +1 -1
  67. package/src/navigation-menu.d.ts +14 -3
  68. package/src/navigation-menu.js +20 -2
  69. package/src/navigation-menu.js.map +1 -1
  70. package/src/number-field.d.ts +33 -1
  71. package/src/number-field.js +98 -68
  72. package/src/number-field.js.map +1 -1
  73. package/src/otp.d.ts +25 -3
  74. package/src/otp.js +22 -3
  75. package/src/otp.js.map +1 -1
  76. package/src/password-input.d.ts +37 -0
  77. package/src/password-input.js +44 -0
  78. package/src/password-input.js.map +1 -0
  79. package/src/popover.d.ts +32 -4
  80. package/src/popover.js +37 -5
  81. package/src/popover.js.map +1 -1
  82. package/src/radio-group.d.ts +12 -0
  83. package/src/radio-group.js +6 -2
  84. package/src/radio-group.js.map +1 -1
  85. package/src/rating.d.ts +34 -0
  86. package/src/rating.js +81 -0
  87. package/src/rating.js.map +1 -0
  88. package/src/runtime.d.ts +2 -1
  89. package/src/runtime.js +5 -2
  90. package/src/runtime.js.map +1 -1
  91. package/src/scroll-area.d.ts +24 -1
  92. package/src/select.d.ts +39 -5
  93. package/src/select.js +30 -9
  94. package/src/select.js.map +1 -1
  95. package/src/slider.d.ts +35 -0
  96. package/src/slider.js +1 -0
  97. package/src/slider.js.map +1 -1
  98. package/src/steps.d.ts +74 -0
  99. package/src/steps.js +84 -0
  100. package/src/steps.js.map +1 -0
  101. package/src/switch.d.ts +12 -0
  102. package/src/tabs.d.ts +2 -0
  103. package/src/tabs.js +5 -0
  104. package/src/tabs.js.map +1 -1
  105. package/src/tags-input.d.ts +69 -0
  106. package/src/tags-input.js +145 -0
  107. package/src/tags-input.js.map +1 -0
  108. package/src/time-field.d.ts +41 -0
  109. package/src/time-field.js +85 -0
  110. package/src/time-field.js.map +1 -0
  111. package/src/toast.d.ts +12 -4
  112. package/src/toggle-group.js +6 -0
  113. package/src/toggle-group.js.map +1 -1
  114. package/src/toolbar-context.d.ts +1 -1
  115. package/src/toolbar.d.ts +4 -1
  116. package/src/toolbar.js +17 -2
  117. package/src/toolbar.js.map +1 -1
  118. package/src/tooltip.d.ts +5 -0
  119. package/src/tour.d.ts +75 -0
  120. package/src/tour.js +95 -0
  121. package/src/tour.js.map +1 -0
  122. package/src/tree.d.ts +69 -0
  123. package/src/tree.js +118 -0
  124. package/src/tree.js.map +1 -0
@@ -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
@@ -3,15 +3,18 @@ import { PositionerProps } from "./popover.js";
3
3
  import { ChangeDetails } from "@kirana-ui/core";
4
4
  import { PublicProps } from "vue";
5
5
  import { AutocompleteProps } from "@kirana-ui/core/autocomplete";
6
- import { ComboboxItemOptions, ComboboxProps } from "@kirana-ui/core/combobox";
6
+ import { ComboboxEntry, ComboboxItemOptions, ComboboxProps, ComboboxShown } from "@kirana-ui/core/combobox";
7
7
  export interface GroupProps extends PartComponentProps {
8
8
  id?: string | undefined;
9
9
  }
10
- export type RootProps<Value = unknown> = Omit<ComboboxProps<Value>, "id" | "onValueChange" | "onValuesChange" | "onInputValueChange" | "onOpenChange"> & {
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;
@@ -30,6 +33,14 @@ export interface ChipProps extends PartComponentProps {
30
33
  value: unknown;
31
34
  }
32
35
  export type EmptyProps = PartComponentProps;
36
+ export interface ValueProps {
37
+ /** What it shows while nothing is chosen. */
38
+ placeholder?: string | undefined;
39
+ }
40
+ export interface CollectionProps {
41
+ /** A group the root's `items` gave: its items left are then what is drawn. */
42
+ of?: ComboboxEntry | undefined;
43
+ }
33
44
  export type AutocompleteRootProps = Omit<AutocompleteProps, "id" | "value" | "onValueChange" | "onOpenChange"> & {
34
45
  /** The text, which is the value: `v-model`. */
35
46
  modelValue?: string | undefined;
@@ -44,34 +55,78 @@ export type TriggerProps = PartComponentProps;
44
55
  export type ChipsProps = PartComponentProps;
45
56
  export type ChipRemoveProps = PartComponentProps;
46
57
  export type PopupProps = PartComponentProps;
58
+ export type BackdropProps = PartComponentProps;
47
59
  export type ListProps = PartComponentProps;
48
60
  export type GroupLabelProps = PartComponentProps;
49
61
  export type SeparatorProps = PartComponentProps;
62
+ export type StatusProps = PartComponentProps;
50
63
  export declare const Combobox: {
51
- 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>, {}>;
52
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;
53
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;
54
76
  readonly disabled?: true | undefined;
77
+ readonly readonly?: true | undefined;
78
+ readonly required?: true | undefined;
55
79
  }, PartComponentProps, {}, unknown>;
56
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;
57
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;
58
91
  readonly disabled?: true | undefined;
92
+ readonly readonly?: true | undefined;
93
+ readonly required?: true | undefined;
59
94
  }, PartComponentProps, {}, unknown>;
95
+ Value: PlainComponent<ValueProps, {}, ComboboxShown<unknown>>;
60
96
  Clear: PartComponent<"button", {
61
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;
62
102
  }, ClearProps>;
63
103
  /** With `multiple`: what holds the chips and the input. */
64
104
  Chips: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
65
- Chip: PartComponent<"span", Record<never, never>, ChipProps>;
105
+ Chip: PartComponent<"span", {
106
+ readonly disabled?: true | undefined;
107
+ }, ChipProps>;
66
108
  ChipRemove: PartComponent<"button", {
67
109
  readonly disabled?: true | undefined;
68
110
  }, PartComponentProps, {}, unknown>;
69
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>;
70
122
  Positioner: PartComponent<"div", {
71
123
  readonly open?: true | undefined;
72
124
  readonly closed?: true | undefined;
73
125
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
74
126
  readonly align?: "center" | "end" | "start" | undefined;
127
+ readonly presentation?: "popup" | "sheet" | undefined;
128
+ readonly anchorHidden?: true | undefined;
129
+ readonly empty?: true | undefined;
75
130
  }, PositionerProps>;
76
131
  Popup: PartComponent<"div", {
77
132
  readonly open?: true | undefined;
@@ -80,6 +135,10 @@ export declare const Combobox: {
80
135
  readonly endingStyle?: true | undefined;
81
136
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
82
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;
83
142
  readonly empty?: true | undefined;
84
143
  }, PartComponentProps, {}, unknown>;
85
144
  /**
@@ -89,6 +148,9 @@ export declare const Combobox: {
89
148
  List: PartComponent<"div", {
90
149
  readonly empty?: true | undefined;
91
150
  }, PartComponentProps, {}, unknown>;
151
+ Collection: PlainComponent<CollectionProps, {}, {
152
+ entry: ComboboxEntry;
153
+ }>;
92
154
  Group: PartComponent<"div", Record<never, never>, GroupProps>;
93
155
  GroupLabel: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
94
156
  /** A line between groups. */
@@ -100,19 +162,46 @@ export declare const Combobox: {
100
162
  }, ItemProps>;
101
163
  ItemIndicator: PartComponent<"span", Record<never, never>, ItemIndicatorProps>;
102
164
  Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
165
+ Status: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
103
166
  };
104
167
  export declare const Autocomplete: {
105
168
  Root: PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>;
106
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;
107
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;
108
180
  readonly disabled?: true | undefined;
181
+ readonly readonly?: true | undefined;
182
+ readonly required?: true | undefined;
109
183
  }, PartComponentProps, {}, unknown>;
110
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;
111
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;
112
195
  readonly disabled?: true | undefined;
196
+ readonly readonly?: true | undefined;
197
+ readonly required?: true | undefined;
113
198
  }, PartComponentProps, {}, unknown>;
114
199
  Clear: PartComponent<"button", {
115
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;
116
205
  }, ClearProps>;
117
206
  Portal: PlainComponent<PortalProps, {}, {}>;
118
207
  Positioner: PartComponent<"div", {
@@ -120,6 +209,9 @@ export declare const Autocomplete: {
120
209
  readonly closed?: true | undefined;
121
210
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
122
211
  readonly align?: "center" | "end" | "start" | undefined;
212
+ readonly presentation?: "popup" | "sheet" | undefined;
213
+ readonly anchorHidden?: true | undefined;
214
+ readonly empty?: true | undefined;
123
215
  }, PositionerProps>;
124
216
  Popup: PartComponent<"div", {
125
217
  readonly open?: true | undefined;
@@ -128,11 +220,18 @@ export declare const Autocomplete: {
128
220
  readonly endingStyle?: true | undefined;
129
221
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
130
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;
131
227
  readonly empty?: true | undefined;
132
228
  }, PartComponentProps, {}, unknown>;
133
229
  List: PartComponent<"div", {
134
230
  readonly empty?: true | undefined;
135
231
  }, PartComponentProps, {}, unknown>;
232
+ Collection: PlainComponent<CollectionProps, {}, {
233
+ entry: ComboboxEntry;
234
+ }>;
136
235
  Group: PartComponent<"div", Record<never, never>, GroupProps>;
137
236
  GroupLabel: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
138
237
  Separator: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
@@ -142,6 +241,7 @@ export declare const Autocomplete: {
142
241
  readonly disabled?: true | undefined;
143
242
  }, ItemProps>;
144
243
  Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
244
+ Status: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
145
245
  };
146
246
  export type { PortalProps, PositionerProps };
147
247
  //# sourceMappingURL=combobox.d.ts.map
package/src/combobox.js CHANGED
@@ -1,8 +1,9 @@
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";
4
5
  import { within } from "@kirana-ui/core";
5
- import { defineComponent, h, inject, provide, useId } from "vue";
6
+ import { Fragment, defineComponent, h, inject, provide, useId } from "vue";
6
7
  import { createAutocomplete } from "@kirana-ui/core/autocomplete";
7
8
  import { createCombobox } from "@kirana-ui/core/combobox";
8
9
  // src/combobox.ts
@@ -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
- /** `v-model:value`, `v-model:inputValue`, `v-model:open`; the `-change` events carry the details. */
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: {
@@ -43,12 +47,15 @@ const Root = defineComponent({
43
47
  open: optional(Boolean),
44
48
  defaultOpen: Boolean,
45
49
  disabled: Boolean,
50
+ readOnly: Boolean,
46
51
  required: Boolean,
47
52
  multiple: Boolean,
48
53
  values: optional(Array),
49
54
  defaultValues: Array,
50
55
  inline: Boolean,
51
56
  virtualized: Object,
57
+ presentation: String,
58
+ sheetBelow: Number,
52
59
  autoHighlight: Boolean,
53
60
  name: String,
54
61
  form: String,
@@ -57,6 +64,14 @@ const Root = defineComponent({
57
64
  type: null,
58
65
  default: void 0
59
66
  },
67
+ itemToStringLabel: {
68
+ type: Function,
69
+ default: void 0
70
+ },
71
+ itemToStringValue: {
72
+ type: Function,
73
+ default: void 0
74
+ },
60
75
  id: String
61
76
  },
62
77
  emits: [
@@ -72,7 +87,10 @@ const Root = defineComponent({
72
87
  setup(props, { slots, emit }) {
73
88
  const generated = useId();
74
89
  const field = useFieldAround();
75
- const made = scope.provide(controller(within(createCombobox, { field }), () => ({
90
+ const made = scope.provide(controller(within(createCombobox, {
91
+ field,
92
+ direction: useDirectionAround()
93
+ }), () => ({
76
94
  id: props.id ?? generated,
77
95
  value: props.value,
78
96
  defaultValue: props.defaultValue,
@@ -81,24 +99,28 @@ const Root = defineComponent({
81
99
  open: props.open,
82
100
  defaultOpen: props.defaultOpen,
83
101
  disabled: props.disabled,
102
+ readOnly: props.readOnly,
84
103
  required: props.required,
85
104
  multiple: props.multiple,
86
105
  values: props.values,
87
106
  defaultValues: props.defaultValues,
88
- onValuesChange(values, details) {
89
- emit("valuesChange", values, details);
90
- if (!details.canceled) emit("update:values", values);
91
- },
92
107
  inline: props.inline,
93
108
  virtualized: props.virtualized,
109
+ presentation: props.presentation,
110
+ sheetBelow: props.sheetBelow,
94
111
  autoHighlight: props.autoHighlight,
95
112
  name: props.name,
96
113
  form: props.form,
97
114
  items: props.items,
98
115
  filter: props.filter,
116
+ itemToStringLabel: props.itemToStringLabel,
117
+ itemToStringValue: props.itemToStringValue,
99
118
  onValueChange(value, details) {
100
119
  emit("valueChange", value, details);
101
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);
102
124
  },
103
125
  onInputValueChange(value, details) {
104
126
  emit("inputValueChange", value, details);
@@ -149,9 +171,10 @@ const ItemIndicator = defineComponent({
149
171
  setup(props, { attrs, slots }) {
150
172
  const value = inject(ITEM);
151
173
  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;
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;
155
178
  }
156
179
  });
157
180
  /** A button that empties the input and the value. Drawn while there is something to clear. */
@@ -194,6 +217,37 @@ const Empty = defineComponent({
194
217
  return () => empty.value ? h(Element, attrs, slots) : null;
195
218
  }
196
219
  });
220
+ /**
221
+ * The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the
222
+ * chosen labels with commas between. Or what its slot makes of them
223
+ * (`v-slot="{ value, label }"`, with `multiple` `v-slot="{ values, labels }"`, in the order
224
+ * they were chosen). For a button that is the combobox, its input inside the popup. It draws
225
+ * no element.
226
+ */
227
+ const Value = defineComponent({
228
+ name: "ComboboxValue",
229
+ props: { placeholder: {
230
+ type: String,
231
+ default: ""
232
+ } },
233
+ setup(props, { slots }) {
234
+ const shown = fromSignal(scope.use().shown);
235
+ return () => slots.default ? slots.default(shown.value) : shown.value.label ?? props.placeholder;
236
+ }
237
+ });
238
+ /**
239
+ * Draws the list from the root's `items`: its slot (`v-slot="{ entry }"`) once for each item
240
+ * left for what was typed, or for each group that has items left; with `of`, for each of that
241
+ * group's. The root then filters, and no item hides itself. It draws no element.
242
+ */
243
+ const Collection = defineComponent({
244
+ name: "ComboboxCollection",
245
+ props: { of: Object },
246
+ setup(props, { slots }) {
247
+ const entries = fromSignal(scope.use().entries(props.of));
248
+ return () => entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })));
249
+ }
250
+ });
197
251
  /** A combobox whose text is the value: `v-model` is the text. The list only suggests. */
198
252
  const AutocompleteRoot = defineComponent({
199
253
  name: "AutocompleteRoot",
@@ -209,6 +263,8 @@ const AutocompleteRoot = defineComponent({
209
263
  },
210
264
  openOnInputClick: Boolean,
211
265
  disabled: Boolean,
266
+ readOnly: Boolean,
267
+ items: [Array, Object],
212
268
  required: Boolean,
213
269
  name: String,
214
270
  form: String,
@@ -234,6 +290,8 @@ const AutocompleteRoot = defineComponent({
234
290
  filter: props.filter,
235
291
  openOnInputClick: props.openOnInputClick,
236
292
  disabled: props.disabled,
293
+ readOnly: props.readOnly,
294
+ items: props.items,
237
295
  required: props.required,
238
296
  name: props.name,
239
297
  form: props.form,
@@ -251,16 +309,25 @@ const AutocompleteRoot = defineComponent({
251
309
  return () => slots.default?.();
252
310
  }
253
311
  });
312
+ /**
313
+ * Says how the list stands ("3 results", "Loading") to software that reads the page, as its
314
+ * text changes. Keep it in the page and change what it holds: inside the popup, or beside the
315
+ * input.
316
+ */
317
+ const Status = partComponent("ComboboxStatus", "div", () => scope.use().status);
254
318
  const Combobox = {
255
319
  Root,
256
320
  Input: partComponent("ComboboxInput", "input", () => scope.use().input),
257
321
  Trigger: partComponent("ComboboxTrigger", "button", () => scope.use().trigger),
322
+ Value,
258
323
  Clear,
259
324
  /** With `multiple`: what holds the chips and the input. */
260
325
  Chips: partComponent("ComboboxChips", "div", () => scope.use().chips),
261
326
  Chip,
262
327
  ChipRemove: partComponent("ComboboxChipRemove", "button", () => scope.use().chipRemove(inject(CHIP))),
263
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),
264
331
  Positioner: positionerComponent("ComboboxPositioner", () => scope.use(), partComponent("ComboboxPositionerElement", "div", () => scope.use().positioner)),
265
332
  Popup: partComponent("ComboboxPopup", "div", () => scope.use().popup),
266
333
  /**
@@ -268,13 +335,15 @@ const Combobox = {
268
335
  * is then the listbox.
269
336
  */
270
337
  List: partComponent("ComboboxList", "div", () => scope.use().list),
338
+ Collection,
271
339
  Group,
272
340
  GroupLabel,
273
341
  /** A line between groups. */
274
342
  Separator: partComponent("ComboboxSeparator", "div", () => scope.use().separator),
275
343
  Item,
276
344
  ItemIndicator,
277
- Empty
345
+ Empty,
346
+ Status
278
347
  };
279
348
  const Autocomplete = {
280
349
  Root: AutocompleteRoot,
@@ -285,11 +354,13 @@ const Autocomplete = {
285
354
  Positioner: Combobox.Positioner,
286
355
  Popup: Combobox.Popup,
287
356
  List: Combobox.List,
357
+ Collection: Combobox.Collection,
288
358
  Group: Combobox.Group,
289
359
  GroupLabel: Combobox.GroupLabel,
290
360
  Separator: Combobox.Separator,
291
361
  Item: Combobox.Item,
292
- Empty: Combobox.Empty
362
+ Empty: Combobox.Empty,
363
+ Status: Combobox.Status
293
364
  };
294
365
  export { Autocomplete, Combobox };
295
366