@kirana-ui/vue 0.2.0 → 0.3.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 (50) hide show
  1. package/llms.txt +303 -82
  2. package/package.json +6 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +29 -8
  4. package/src/alert-dialog.d.ts +2 -2
  5. package/src/autocomplete.d.ts +2 -2
  6. package/src/avatar.d.ts +31 -4
  7. package/src/avatar.js +39 -15
  8. package/src/avatar.js.map +1 -1
  9. package/src/calendar.d.ts +17 -11
  10. package/src/calendar.js +76 -11
  11. package/src/calendar.js.map +1 -1
  12. package/src/checkbox-group-context.d.ts +5 -0
  13. package/src/checkbox-group-context.js +6 -0
  14. package/src/checkbox-group-context.js.map +1 -0
  15. package/src/checkbox-group.d.ts +12 -0
  16. package/src/checkbox-group.js +44 -0
  17. package/src/checkbox-group.js.map +1 -0
  18. package/src/checkbox.d.ts +1 -0
  19. package/src/checkbox.js +9 -2
  20. package/src/checkbox.js.map +1 -1
  21. package/src/combobox.d.ts +23 -1
  22. package/src/combobox.js +51 -3
  23. package/src/combobox.js.map +1 -1
  24. package/src/command.js +2 -0
  25. package/src/command.js.map +1 -1
  26. package/src/date-picker.d.ts +8 -5
  27. package/src/date-picker.js +12 -1
  28. package/src/date-picker.js.map +1 -1
  29. package/src/dialog.d.ts +19 -0
  30. package/src/dialog.js +4 -1
  31. package/src/dialog.js.map +1 -1
  32. package/src/drawer.d.ts +2 -2
  33. package/src/index.d.ts +6 -3
  34. package/src/index.js +2 -1
  35. package/src/number-field.d.ts +33 -1
  36. package/src/number-field.js +98 -68
  37. package/src/number-field.js.map +1 -1
  38. package/src/otp.js +2 -0
  39. package/src/otp.js.map +1 -1
  40. package/src/popover.d.ts +26 -3
  41. package/src/popover.js +36 -4
  42. package/src/popover.js.map +1 -1
  43. package/src/radio-group.js +6 -2
  44. package/src/radio-group.js.map +1 -1
  45. package/src/select.d.ts +1 -0
  46. package/src/select.js +2 -0
  47. package/src/select.js.map +1 -1
  48. package/src/slider.d.ts +5 -0
  49. package/src/slider.js +1 -0
  50. package/src/slider.js.map +1 -1
package/src/checkbox.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare const Checkbox: {
16
16
  readonly readonly?: true | undefined;
17
17
  readonly required?: true | undefined;
18
18
  readonly indeterminate?: true | undefined;
19
+ readonly parent?: true | undefined;
19
20
  }, RootProps, RootEmits>;
20
21
  Indicator: PartComponent<"span", {
21
22
  readonly checked?: true | undefined;
package/src/checkbox.js CHANGED
@@ -1,7 +1,8 @@
1
+ import { CHECKBOX_GROUP } from "./checkbox-group-context.js";
1
2
  import { useFieldAround } from "./field-context.js";
2
3
  import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
3
4
  import { within } from "@kirana-ui/core";
4
- import { defineComponent, h, useId } from "vue";
5
+ import { defineComponent, h, inject, useId } from "vue";
5
6
  import { createCheckbox } from "@kirana-ui/core/checkbox";
6
7
  // src/checkbox.ts
7
8
  const scope = context("Checkbox");
@@ -15,6 +16,7 @@ const Root = defineComponent({
15
16
  checked: optional(Boolean),
16
17
  defaultChecked: Boolean,
17
18
  indeterminate: Boolean,
19
+ parent: Boolean,
18
20
  disabled: Boolean,
19
21
  readOnly: Boolean,
20
22
  required: Boolean,
@@ -27,11 +29,16 @@ const Root = defineComponent({
27
29
  setup(props, { attrs, slots, emit }) {
28
30
  const generated = useId();
29
31
  const field = useFieldAround();
30
- scope.provide(controller(within(createCheckbox, { field }), () => ({
32
+ const group = inject(CHECKBOX_GROUP, null) ?? void 0;
33
+ scope.provide(controller(within(createCheckbox, {
34
+ field,
35
+ group
36
+ }), () => ({
31
37
  id: props.id ?? generated,
32
38
  checked: props.checked,
33
39
  defaultChecked: props.defaultChecked,
34
40
  indeterminate: props.indeterminate,
41
+ parent: props.parent,
35
42
  disabled: props.disabled,
36
43
  readOnly: props.readOnly,
37
44
  required: props.required,
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.js","names":[],"sources":["../../../../packages/vue/src/checkbox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCheckbox } from \"@kirana-ui/core/checkbox\"\nimport type { CheckboxProps, Checkbox as Controller } from \"@kirana-ui/core/checkbox\"\nimport { defineComponent, h, useId } from \"vue\"\n\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<\"checkbox\">\n\nconst scope = context<Controller>(\"Checkbox\")\n\nconst Input = partComponent(\"CheckboxInput\", \"input\", () => scope.use().input)\n// Its native input is the element's last child, whatever element the caller asked for.\nconst RootElement = partComponent(\n \"CheckboxRootElement\",\n \"span\",\n () => scope.use().root,\n (content) => [content, h(Input)]\n)\n\nexport type RootProps = Omit<CheckboxProps, \"id\" | \"onCheckedChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"checked\", boolean>\n\n/** `v-model:checked`, or `checked` with `@checked-change=\"(checked, details) => …\"`. */\nconst Root = defineComponent({\n name: \"CheckboxRoot\",\n inheritAttrs: false,\n props: {\n checked: optional(Boolean),\n defaultChecked: Boolean,\n indeterminate: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n value: String,\n id: String,\n },\n emits: [\"update:checked\", \"checkedChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createCheckbox, { field }), () => ({\n id: props.id ?? generated,\n checked: props.checked,\n defaultChecked: props.defaultChecked,\n indeterminate: props.indeterminate,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n value: props.value,\n onCheckedChange(checked: boolean, details: ChangeDetails) {\n emit(\"checkedChange\", checked, details)\n if (!details.canceled) emit(\"update:checked\", checked)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"root\"], RootProps, RootEmits>\n\nconst IndicatorElement = partComponent(\n \"CheckboxIndicatorElement\",\n \"span\",\n () => scope.use().indicator\n)\n\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the box is unchecked. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the mark in the page while the box is unchecked. */\nconst Indicator = defineComponent({\n name: \"CheckboxIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const mounted = fromSignal(scope.use().indicatorMounted)\n return () => (mounted.value || props.keepMounted ? h(IndicatorElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"indicator\"], IndicatorProps>\n\nexport const Checkbox = { Root, Indicator }\n"],"mappings":";;;;;;AAYA,MAAM,QAAQ,QAAoB,UAAU;AAE5C,MAAM,QAAQ,cAAc,iBAAiB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;AAE7E,MAAM,cAAc,cAClB,uBACA,cACM,MAAM,IAAI,CAAC,CAAC,OACjB,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CACjC;;AASA,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,SAAS,SAAS,OAAO;EACzB,gBAAgB;EAChB,eAAe;EACf,UAAU;EACV,UAAU;EACV,UAAU;EACV,MAAM;EACN,MAAM;EACN,OAAO;EACP,IAAI;CACN;CACA,OAAO,CAAC,kBAAkB,eAAe;CACzC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,eAAe;EAC7B,MAAM,QACJ,WAAW,OAAO,gBAAgB,EAAE,MAAM,CAAC,UAAU;GACnD,IAAI,MAAM,MAAM;GAChB,SAAS,MAAM;GACf,gBAAgB,MAAM;GACtB,eAAe,MAAM;GACrB,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,MAAM,MAAM;GACZ,MAAM,MAAM;GACZ,OAAO,MAAM;GACb,gBAAgB,SAAkB,SAAwB;IACxD,KAAK,iBAAiB,SAAS,OAAO;IACtC,IAAI,CAAC,QAAQ,UAAU,KAAK,kBAAkB,OAAO;GACvD;EACF,EAAE,CACJ;EACA,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;AAED,MAAM,mBAAmB,cACvB,4BACA,cACM,MAAM,IAAI,CAAC,CAAC,SACpB;AAkBA,MAAa,WAAW;CAAE;CAAM,WAVd,gBAAgB;EAChC,MAAM;EACN,cAAc;EACd,OAAO,EAAE,aAAa,QAAQ;EAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,WAAW,MAAM,IAAI,CAAC,CAAC,gBAAgB;GACvD,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,kBAAkB,OAAO,KAAK,IAAI;EACzF;CACF,CAEgC;AAAU"}
1
+ {"version":3,"file":"checkbox.js","names":[],"sources":["../../../../packages/vue/src/checkbox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCheckbox } from \"@kirana-ui/core/checkbox\"\nimport type { CheckboxProps, Checkbox as Controller } from \"@kirana-ui/core/checkbox\"\nimport { defineComponent, h, inject, useId } from \"vue\"\n\nimport { CHECKBOX_GROUP } from \"./checkbox-group-context.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<\"checkbox\">\n\nconst scope = context<Controller>(\"Checkbox\")\n\nconst Input = partComponent(\"CheckboxInput\", \"input\", () => scope.use().input)\n// Its native input is the element's last child, whatever element the caller asked for.\nconst RootElement = partComponent(\n \"CheckboxRootElement\",\n \"span\",\n () => scope.use().root,\n (content) => [content, h(Input)]\n)\n\nexport type RootProps = Omit<CheckboxProps, \"id\" | \"onCheckedChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"checked\", boolean>\n\n/** `v-model:checked`, or `checked` with `@checked-change=\"(checked, details) => …\"`. */\nconst Root = defineComponent({\n name: \"CheckboxRoot\",\n inheritAttrs: false,\n props: {\n checked: optional(Boolean),\n defaultChecked: Boolean,\n indeterminate: Boolean,\n parent: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n value: String,\n id: String,\n },\n emits: [\"update:checked\", \"checkedChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const group = inject(CHECKBOX_GROUP, null) ?? undefined\n scope.provide(\n controller(within(createCheckbox, { field, group }), () => ({\n id: props.id ?? generated,\n checked: props.checked,\n defaultChecked: props.defaultChecked,\n indeterminate: props.indeterminate,\n parent: props.parent,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n value: props.value,\n onCheckedChange(checked: boolean, details: ChangeDetails) {\n emit(\"checkedChange\", checked, details)\n if (!details.canceled) emit(\"update:checked\", checked)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"root\"], RootProps, RootEmits>\n\nconst IndicatorElement = partComponent(\n \"CheckboxIndicatorElement\",\n \"span\",\n () => scope.use().indicator\n)\n\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the box is unchecked. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the mark in the page while the box is unchecked. */\nconst Indicator = defineComponent({\n name: \"CheckboxIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const mounted = fromSignal(scope.use().indicatorMounted)\n return () => (mounted.value || props.keepMounted ? h(IndicatorElement, attrs, slots) : null)\n },\n}) as unknown as PartCompon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Vd,gBAAgB;EAChC,MAAM;EACN,cAAc;EACd,OAAO,EAAE,aAAa,QAAQ;EAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,WAAW,MAAM,IAAI,CAAC,CAAC,gBAAgB;GACvD,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,kBAAkB,OAAO,KAAK,IAAI;EACzF;CACF,CAEgC;AAAU"}
package/src/combobox.d.ts CHANGED
@@ -3,7 +3,7 @@ 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
  }
@@ -30,6 +30,14 @@ export interface ChipProps extends PartComponentProps {
30
30
  value: unknown;
31
31
  }
32
32
  export type EmptyProps = PartComponentProps;
33
+ export interface ValueProps {
34
+ /** What it shows while nothing is chosen. */
35
+ placeholder?: string | undefined;
36
+ }
37
+ export interface CollectionProps {
38
+ /** A group the root's `items` gave: its items left are then what is drawn. */
39
+ of?: ComboboxEntry | undefined;
40
+ }
33
41
  export type AutocompleteRootProps = Omit<AutocompleteProps, "id" | "value" | "onValueChange" | "onOpenChange"> & {
34
42
  /** The text, which is the value: `v-model`. */
35
43
  modelValue?: string | undefined;
@@ -47,16 +55,20 @@ export type PopupProps = PartComponentProps;
47
55
  export type ListProps = PartComponentProps;
48
56
  export type GroupLabelProps = PartComponentProps;
49
57
  export type SeparatorProps = PartComponentProps;
58
+ export type StatusProps = PartComponentProps;
50
59
  export declare const Combobox: {
51
60
  Root: new <Value = unknown>(props: RootProps<Value> & Listeners<RootEmits<Value>> & PublicProps) => PlainInstance<RootProps<Value>, RootEmits<Value>, {}>;
52
61
  Input: PartComponent<"input", {
53
62
  readonly popupOpen?: true | undefined;
54
63
  readonly disabled?: true | undefined;
64
+ readonly readonly?: true | undefined;
55
65
  }, PartComponentProps, {}, unknown>;
56
66
  Trigger: PartComponent<"button", {
57
67
  readonly popupOpen?: true | undefined;
58
68
  readonly disabled?: true | undefined;
69
+ readonly readonly?: true | undefined;
59
70
  }, PartComponentProps, {}, unknown>;
71
+ Value: PlainComponent<ValueProps, {}, ComboboxShown<unknown>>;
60
72
  Clear: PartComponent<"button", {
61
73
  readonly disabled?: true | undefined;
62
74
  }, ClearProps>;
@@ -89,6 +101,9 @@ export declare const Combobox: {
89
101
  List: PartComponent<"div", {
90
102
  readonly empty?: true | undefined;
91
103
  }, PartComponentProps, {}, unknown>;
104
+ Collection: PlainComponent<CollectionProps, {}, {
105
+ entry: ComboboxEntry;
106
+ }>;
92
107
  Group: PartComponent<"div", Record<never, never>, GroupProps>;
93
108
  GroupLabel: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
94
109
  /** A line between groups. */
@@ -100,16 +115,19 @@ export declare const Combobox: {
100
115
  }, ItemProps>;
101
116
  ItemIndicator: PartComponent<"span", Record<never, never>, ItemIndicatorProps>;
102
117
  Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
118
+ Status: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
103
119
  };
104
120
  export declare const Autocomplete: {
105
121
  Root: PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>;
106
122
  Input: PartComponent<"input", {
107
123
  readonly popupOpen?: true | undefined;
108
124
  readonly disabled?: true | undefined;
125
+ readonly readonly?: true | undefined;
109
126
  }, PartComponentProps, {}, unknown>;
110
127
  Trigger: PartComponent<"button", {
111
128
  readonly popupOpen?: true | undefined;
112
129
  readonly disabled?: true | undefined;
130
+ readonly readonly?: true | undefined;
113
131
  }, PartComponentProps, {}, unknown>;
114
132
  Clear: PartComponent<"button", {
115
133
  readonly disabled?: true | undefined;
@@ -133,6 +151,9 @@ export declare const Autocomplete: {
133
151
  List: PartComponent<"div", {
134
152
  readonly empty?: true | undefined;
135
153
  }, PartComponentProps, {}, unknown>;
154
+ Collection: PlainComponent<CollectionProps, {}, {
155
+ entry: ComboboxEntry;
156
+ }>;
136
157
  Group: PartComponent<"div", Record<never, never>, GroupProps>;
137
158
  GroupLabel: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
138
159
  Separator: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
@@ -142,6 +163,7 @@ export declare const Autocomplete: {
142
163
  readonly disabled?: true | undefined;
143
164
  }, ItemProps>;
144
165
  Empty: PartComponent<"div", Record<never, never>, PartComponentProps>;
166
+ Status: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
145
167
  };
146
168
  export type { PortalProps, PositionerProps };
147
169
  //# sourceMappingURL=combobox.d.ts.map
package/src/combobox.js CHANGED
@@ -2,7 +2,7 @@ import { useFieldAround } from "./field-context.js";
2
2
  import { positionerComponent } from "./popover.js";
3
3
  import { context, controller, fromSignal, optional, partComponent, portalComponent, toSignal } from "./runtime.js";
4
4
  import { within } from "@kirana-ui/core";
5
- import { defineComponent, h, inject, provide, useId } from "vue";
5
+ import { Fragment, defineComponent, h, inject, provide, useId } from "vue";
6
6
  import { createAutocomplete } from "@kirana-ui/core/autocomplete";
7
7
  import { createCombobox } from "@kirana-ui/core/combobox";
8
8
  // src/combobox.ts
@@ -43,6 +43,7 @@ const Root = defineComponent({
43
43
  open: optional(Boolean),
44
44
  defaultOpen: Boolean,
45
45
  disabled: Boolean,
46
+ readOnly: Boolean,
46
47
  required: Boolean,
47
48
  multiple: Boolean,
48
49
  values: optional(Array),
@@ -81,6 +82,7 @@ const Root = defineComponent({
81
82
  open: props.open,
82
83
  defaultOpen: props.defaultOpen,
83
84
  disabled: props.disabled,
85
+ readOnly: props.readOnly,
84
86
  required: props.required,
85
87
  multiple: props.multiple,
86
88
  values: props.values,
@@ -194,6 +196,37 @@ const Empty = defineComponent({
194
196
  return () => empty.value ? h(Element, attrs, slots) : null;
195
197
  }
196
198
  });
199
+ /**
200
+ * The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the
201
+ * chosen labels with commas between. Or what its slot makes of them
202
+ * (`v-slot="{ value, label }"`, with `multiple` `v-slot="{ values, labels }"`, in the order
203
+ * they were chosen). For a button that is the combobox, its input inside the popup. It draws
204
+ * no element.
205
+ */
206
+ const Value = defineComponent({
207
+ name: "ComboboxValue",
208
+ props: { placeholder: {
209
+ type: String,
210
+ default: ""
211
+ } },
212
+ setup(props, { slots }) {
213
+ const shown = fromSignal(scope.use().shown);
214
+ return () => slots.default ? slots.default(shown.value) : shown.value.label ?? props.placeholder;
215
+ }
216
+ });
217
+ /**
218
+ * Draws the list from the root's `items`: its slot (`v-slot="{ entry }"`) once for each item
219
+ * left for what was typed, or for each group that has items left; with `of`, for each of that
220
+ * group's. The root then filters, and no item hides itself. It draws no element.
221
+ */
222
+ const Collection = defineComponent({
223
+ name: "ComboboxCollection",
224
+ props: { of: Object },
225
+ setup(props, { slots }) {
226
+ const entries = fromSignal(scope.use().entries(props.of));
227
+ return () => entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })));
228
+ }
229
+ });
197
230
  /** A combobox whose text is the value: `v-model` is the text. The list only suggests. */
198
231
  const AutocompleteRoot = defineComponent({
199
232
  name: "AutocompleteRoot",
@@ -209,6 +242,8 @@ const AutocompleteRoot = defineComponent({
209
242
  },
210
243
  openOnInputClick: Boolean,
211
244
  disabled: Boolean,
245
+ readOnly: Boolean,
246
+ items: [Array, Object],
212
247
  required: Boolean,
213
248
  name: String,
214
249
  form: String,
@@ -234,6 +269,8 @@ const AutocompleteRoot = defineComponent({
234
269
  filter: props.filter,
235
270
  openOnInputClick: props.openOnInputClick,
236
271
  disabled: props.disabled,
272
+ readOnly: props.readOnly,
273
+ items: props.items,
237
274
  required: props.required,
238
275
  name: props.name,
239
276
  form: props.form,
@@ -251,10 +288,17 @@ const AutocompleteRoot = defineComponent({
251
288
  return () => slots.default?.();
252
289
  }
253
290
  });
291
+ /**
292
+ * Says how the list stands ("3 results", "Loading") to software that reads the page, as its
293
+ * text changes. Keep it in the page and change what it holds: inside the popup, or beside the
294
+ * input.
295
+ */
296
+ const Status = partComponent("ComboboxStatus", "div", () => scope.use().status);
254
297
  const Combobox = {
255
298
  Root,
256
299
  Input: partComponent("ComboboxInput", "input", () => scope.use().input),
257
300
  Trigger: partComponent("ComboboxTrigger", "button", () => scope.use().trigger),
301
+ Value,
258
302
  Clear,
259
303
  /** With `multiple`: what holds the chips and the input. */
260
304
  Chips: partComponent("ComboboxChips", "div", () => scope.use().chips),
@@ -268,13 +312,15 @@ const Combobox = {
268
312
  * is then the listbox.
269
313
  */
270
314
  List: partComponent("ComboboxList", "div", () => scope.use().list),
315
+ Collection,
271
316
  Group,
272
317
  GroupLabel,
273
318
  /** A line between groups. */
274
319
  Separator: partComponent("ComboboxSeparator", "div", () => scope.use().separator),
275
320
  Item,
276
321
  ItemIndicator,
277
- Empty
322
+ Empty,
323
+ Status
278
324
  };
279
325
  const Autocomplete = {
280
326
  Root: AutocompleteRoot,
@@ -285,11 +331,13 @@ const Autocomplete = {
285
331
  Positioner: Combobox.Positioner,
286
332
  Popup: Combobox.Popup,
287
333
  List: Combobox.List,
334
+ Collection: Combobox.Collection,
288
335
  Group: Combobox.Group,
289
336
  GroupLabel: Combobox.GroupLabel,
290
337
  Separator: Combobox.Separator,
291
338
  Item: Combobox.Item,
292
- Empty: Combobox.Empty
339
+ Empty: Combobox.Empty,
340
+ Status: Combobox.Status
293
341
  };
294
342
  export { Autocomplete, Combobox };
295
343
 
@@ -1 +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: Comb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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 ComboboxEntry,\n ComboboxGroup,\n ComboboxItemOptions,\n ComboboxProps,\n ComboboxShown,\n} from \"@kirana-ui/core/combobox\"\nimport { defineComponent, Fragment, 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 readOnly: 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 readOnly: props.readOnly,\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 interface ValueProps {\n /** What it shows while nothing is chosen. */\n placeholder?: string | undefined\n}\n\n/**\n * The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the\n * chosen labels with commas between. Or what its slot makes of them\n * (`v-slot=\"{ value, label }\"`, with `multiple` `v-slot=\"{ values, labels }\"`, in the order\n * they were chosen). For a button that is the combobox, its input inside the popup. It draws\n * no element.\n */\nconst Value = defineComponent({\n name: \"ComboboxValue\",\n props: { placeholder: { type: String, default: \"\" } },\n setup(props, { slots }) {\n const shown = fromSignal(scope.use().shown)\n return () =>\n slots.default ? slots.default(shown.value) : (shown.value.label ?? props.placeholder)\n },\n}) as unknown as PlainComponent<ValueProps, {}, ComboboxShown>\n\nexport interface CollectionProps {\n /** A group the root's `items` gave: its items left are then what is drawn. */\n of?: ComboboxEntry | undefined\n}\n\n/**\n * Draws the list from the root's `items`: its slot (`v-slot=\"{ entry }\"`) once for each item\n * left for what was typed, or for each group that has items left; with `of`, for each of that\n * group's. The root then filters, and no item hides itself. It draws no element.\n */\nconst Collection = defineComponent({\n name: \"ComboboxCollection\",\n props: { of: Object as PropType<ComboboxEntry> },\n setup(props, { slots }) {\n // A group is known by its key, which is its own for as long as it is drawn.\n const entries = fromSignal(scope.use().entries(props.of))\n return () =>\n entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })))\n },\n}) as unknown as PlainComponent<CollectionProps, {}, { entry: ComboboxEntry }>\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 readOnly: Boolean,\n items: [Array, Object] as PropType<AutocompleteProps[\"items\"]>,\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 readOnly: props.readOnly,\n items: props.items,\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 type StatusProps = PartComponentProps\n\n/**\n * Says how the list stands (\"3 results\", \"Loading\") to software that reads the page, as its\n * text changes. Keep it in the page and change what it holds: inside the popup, or beside the\n * input.\n */\nconst Status = partComponent<\"div\", State[\"status\"]>(\n \"ComboboxStatus\",\n \"div\",\n () => scope.use().status\n)\n\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 Value,\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 Collection,\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 Status,\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 Collection: Combobox.Collection,\n Group: Combobox.Group,\n GroupLabel: Combobox.GroupLabel,\n Separator: Combobox.Separator,\n Item: Combobox.Item,\n Empty: Combobox.Empty,\n Status: Combobox.Status,\n}\n"],"mappings":";;;;;;;;AA0CA,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,SAAS,MAAM,IAAI,CAAC,CAAC,UAClD;AAEA,MAAM,cAAc,cAAc,uBAAuB,eAAe,MAAM,IAAI,CAAC,CAAC,MAAM;;AAc1F,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,OAAO;GAAE,MAAM;GAAK,SAAS,KAAA;EAAqB;EAClD,cAAc;GAAE,MAAM;GAAK,SAAS;EAAgB;EACpD,YAAY;EACZ,mBAAmB;EACnB,MAAM,SAAS,OAAO;EACtB,aAAa;EACb,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,QAAQ,SAAS,KAAqC;EACtD,eAAe;EACf,QAAQ;EACR,aAAa;EACb,eAAe;EACf,MAAM;EACN,MAAM;EACN,OAA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b,kBACA,aACM,MAAM,IAAI,CAAC,CAAC,MACpB;AAEA,MAAa,WAAW;CACtB;CACA,OAAO,cAAuC,iBAAiB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;CAC/F,SAAS,cACP,mBACA,gBACM,MAAM,IAAI,CAAC,CAAC,OACpB;CACA;CACA;;CAEA,OAAO,cAAqC,iBAAiB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CAC3F;CACA,YAAY,cAA6C,sBAAsB,gBAC7E,MAAM,IAAI,CAAC,CAAC,WAAW,OAAO,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;CACA;;CAEA,WAAW,cACT,qBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;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,YAAY,SAAS;CACrB,OAAO,SAAS;CAChB,YAAY,SAAS;CACrB,WAAW,SAAS;CACpB,MAAM,SAAS;CACf,OAAO,SAAS;CAChB,QAAQ,SAAS;AACnB"}
package/src/command.js CHANGED
@@ -17,6 +17,7 @@ const Root = defineComponent({
17
17
  default: void 0
18
18
  },
19
19
  loop: Boolean,
20
+ autoHighlight: optional(Boolean),
20
21
  disabled: Boolean,
21
22
  id: String
22
23
  },
@@ -33,6 +34,7 @@ const Root = defineComponent({
33
34
  defaultInputValue: props.defaultInputValue,
34
35
  filter: props.filter,
35
36
  loop: props.loop,
37
+ autoHighlight: props.autoHighlight,
36
38
  disabled: props.disabled,
37
39
  onInputValueChange(value, details) {
38
40
  emit("inputValueChange", value, details);
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","names":[],"sources":["../../../../packages/vue/src/command.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCommand } from \"@kirana-ui/core/command\"\nimport type {\n CommandGroup,\n CommandItemOptions,\n CommandProps,\n Command as Controller,\n} from \"@kirana-ui/core/command\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"command\">\n\nconst scope = context<Controller>(\"Command\")\nconst GROUP: InjectionKey<CommandGroup> = Symbol(\"CommandGroup\")\n\nconst RootElement = partComponent(\"CommandRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CommandProps, \"id\" | \"onInputValueChange\" | \"onSelect\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"inputValue\", string> & {\n /** An item was chosen: its value. */\n select: (value: string, details: ChangeDetails) => void\n}\n\n/** `v-model:inputValue`; `@select` hears the item chosen. */\nconst Root = defineComponent({\n name: \"CommandRoot\",\n inheritAttrs: false,\n props: {\n inputValue: String,\n defaultInputValue: String,\n filter: {\n type: null as unknown as PropType<CommandProps[\"filter\"]>,\n default: undefined,\n },\n loop: Boolean,\n disabled: Boolean,\n id: String,\n },\n emits: [\"update:inputValue\", \"inputValueChange\", \"select\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createCommand, () => ({\n id: props.id ?? generated,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n filter: props.filter,\n loop: props.loop,\n disabled: props.disabled,\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", value)\n },\n onSelect: (value: string, details: ChangeDetails) => emit(\"select\", value, details),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nconst EmptyElement = partComponent(\"CommandEmptyElement\", \"div\", () => scope.use().emptyPart)\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"CommandEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const empty = fromSignal(scope.use().empty)\n return () => (empty.value ? h(EmptyElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */\nconst Group = defineComponent({\n name: \"CommandGroup\",\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(\"CommandGroupElement\", \"div\", () => group.part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\nexport type GroupHeadingProps = PartComponentProps\n\nconst GroupHeading = defineComponent({\n name: \"CommandGroupHeading\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const part = inject(GROUP, undefined)?.heading ?? scope.use().heading\n const Element = partComponent(\"CommandGroupHeadingElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"groupHeading\"], GroupHeadingProps>\n\nexport interface ItemProps extends Omit<CommandItemOptions, \"id\">, PartComponentProps {\n /** What `@select` is told when this item is chosen. */\n value: string\n id?: string | undefined\n}\n\n/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */\nconst Item = defineComponent({\n name: \"CommandItem\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n disabled: optional(Boolean),\n label: String,\n keywords: Array as PropType<readonly string[]>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n keywords: props.keywords,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(props.value, () => options.get(), inject(GROUP, undefined))\n const Element = partComponent(\"CommandItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface SeparatorProps extends PartComponentProps {\n /** Keeps the line while something is typed. */\n alwaysRender?: boolean | undefined\n}\n\n/** A line between groups: gone while something is typed, unless `always-render`. */\nconst Separator = defineComponent({\n name: \"CommandSeparator\",\n inheritAttrs: false,\n props: { alwaysRender: Boolean },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ alwaysRender: props.alwaysRender }))\n const part = scope.use().separator(() => options.get().alwaysRender)\n const Element = partComponent(\"CommandSeparatorElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"separator\"], SeparatorProps>\n\nexport type InputProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport const Command = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"CommandInput\", \"input\", () => scope.use().input),\n List: partComponent<\"div\", State[\"list\"]>(\"CommandList\", \"div\", () => scope.use().list),\n Empty,\n Group,\n GroupHeading,\n Item,\n Separator,\n}\n"],"mappings":";;;;AAgBA,MAAM,QAAQ,QAAoB,SAAS;AAC3C,MAAM,QAAoC,OAAO,cAAc;AAE/D,MAAM,cAAc,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYrF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,YAAY;EACZ,mBAAmB;EACnB,QAAQ;GACN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AAoC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACtF;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"command.js","names":[],"sources":["../../../../packages/vue/src/command.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCommand } from \"@kirana-ui/core/command\"\nimport type {\n CommandGroup,\n CommandItemOptions,\n CommandProps,\n Command as Controller,\n} from \"@kirana-ui/core/command\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"command\">\n\nconst scope = context<Controller>(\"Command\")\nconst GROUP: InjectionKey<CommandGroup> = Symbol(\"CommandGroup\")\n\nconst RootElement = partComponent(\"CommandRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CommandProps, \"id\" | \"onInputValueChange\" | \"onSelect\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"inputValue\", string> & {\n /** An item was chosen: its value. */\n select: (value: string, details: ChangeDetails) => void\n}\n\n/** `v-model:inputValue`; `@select` hears the item chosen. */\nconst Root = defineComponent({\n name: \"CommandRoot\",\n inheritAttrs: false,\n props: {\n inputValue: String,\n defaultInputValue: String,\n filter: {\n type: null as unknown as PropType<CommandProps[\"filter\"]>,\n default: undefined,\n },\n loop: Boolean,\n autoHighlight: optional(Boolean),\n disabled: Boolean,\n id: String,\n },\n emits: [\"update:inputValue\", \"inputValueChange\", \"select\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createCommand, () => ({\n id: props.id ?? generated,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n filter: props.filter,\n loop: props.loop,\n autoHighlight: props.autoHighlight,\n disabled: props.disabled,\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", value)\n },\n onSelect: (value: string, details: ChangeDetails) => emit(\"select\", value, details),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nconst EmptyElement = partComponent(\"CommandEmptyElement\", \"div\", () => scope.use().emptyPart)\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"CommandEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const empty = fromSignal(scope.use().empty)\n return () => (empty.value ? h(EmptyElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */\nconst Group = defineComponent({\n name: \"CommandGroup\",\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(\"CommandGroupElement\", \"div\", () => group.part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\nexport type GroupHeadingProps = PartComponentProps\n\nconst GroupHeading = defineComponent({\n name: \"CommandGroupHeading\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const part = inject(GROUP, undefined)?.heading ?? scope.use().heading\n const Element = partComponent(\"CommandGroupHeadingElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"groupHeading\"], GroupHeadingProps>\n\nexport interface ItemProps extends Omit<CommandItemOptions, \"id\">, PartComponentProps {\n /** What `@select` is told when this item is chosen. */\n value: string\n id?: string | undefined\n}\n\n/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */\nconst Item = defineComponent({\n name: \"CommandItem\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n disabled: optional(Boolean),\n label: String,\n keywords: Array as PropType<readonly string[]>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n keywords: props.keywords,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(props.value, () => options.get(), inject(GROUP, undefined))\n const Element = partComponent(\"CommandItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface SeparatorProps extends PartComponentProps {\n /** Keeps the line while something is typed. */\n alwaysRender?: boolean | undefined\n}\n\n/** A line between groups: gone while something is typed, unless `always-render`. */\nconst Separator = defineComponent({\n name: \"CommandSeparator\",\n inheritAttrs: false,\n props: { alwaysRender: Boolean },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ alwaysRender: props.alwaysRender }))\n const part = scope.use().separator(() => options.get().alwaysRender)\n const Element = partComponent(\"CommandSeparatorElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"separator\"], SeparatorProps>\n\nexport type InputProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport const Command = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"CommandInput\", \"input\", () => scope.use().input),\n List: partComponent<\"div\", State[\"list\"]>(\"CommandList\", \"div\", () => scope.use().list),\n Empty,\n Group,\n GroupHeading,\n Item,\n Separator,\n}\n"],"mappings":";;;;AAgBA,MAAM,QAAQ,QAAoB,SAAS;AAC3C,MAAM,QAAoC,OAAO,cAAc;AAE/D,MAAM,cAAc,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYrF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,YAAY;EACZ,mBAAmB;EACnB,QAAQ;GACN,MAAM;GACN,SAAS,KAAA;EACX;EACA,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F,MAAM,cAAoC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACtF;CACA;CACA;CACA;CACA;AACF"}
@@ -1,13 +1,13 @@
1
1
  import { Changes, PartComponent, PartComponentProps, PlainComponent, PortalProps } from "./runtime.js";
2
2
  import { InputProps, SegmentProps, SegmentsProps } from "./date-field.js";
3
3
  import { PopupProps, PositionerProps, TriggerProps } from "./popover.js";
4
- import { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, NextProps, PreviousProps, WeekdaysProps, WeeksProps } from "./calendar.js";
4
+ import { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, MonthsProps, NextProps, PreviousProps, WeekdaysProps, WeeksProps } from "./calendar.js";
5
5
  import { DatePickerProps } from "@kirana-ui/core/date-picker";
6
- export type RootProps = Omit<DatePickerProps, "id" | "onValueChange" | "onOpenChange"> & {
6
+ export type RootProps = Omit<DatePickerProps, "id" | "onValueChange" | "onOpenChange" | "onMonthChange"> & {
7
7
  id?: string | undefined;
8
8
  };
9
9
  /** The value is `null` while the date is not whole. */
10
- export type RootEmits = Changes<"value", string | null> & Changes<"open", boolean>;
10
+ export type RootEmits = Changes<"value", string | null> & Changes<"open", boolean> & Changes<"month", string>;
11
11
  export type FieldProps = PartComponentProps;
12
12
  export type CalendarProps = PartComponentProps;
13
13
  export declare const DatePicker: {
@@ -30,7 +30,7 @@ export declare const DatePicker: {
30
30
  Input: PartComponent<"input", Record<never, never>, PartComponentProps, {}, unknown>;
31
31
  Trigger: PartComponent<"button", {
32
32
  readonly popupOpen?: true | undefined;
33
- }, PartComponentProps, {}, unknown>;
33
+ }, TriggerProps>;
34
34
  Portal: PlainComponent<PortalProps, {}, {}>;
35
35
  Positioner: PartComponent<"div", {
36
36
  readonly open?: true | undefined;
@@ -58,6 +58,9 @@ export declare const DatePicker: {
58
58
  Next: PartComponent<"button", {
59
59
  readonly disabled?: true | undefined;
60
60
  }, PartComponentProps, {}, unknown>;
61
+ Months: PlainComponent<MonthsProps, {}, {
62
+ month: import("@kirana-ui/core/calendar").CalendarMonth;
63
+ }>;
61
64
  Grid: PartComponent<"table", Record<never, never>, PartComponentProps, {}, unknown>;
62
65
  Weekdays: PlainComponent<WeekdaysProps, {}, {
63
66
  weekday: import("@kirana-ui/core/calendar").CalendarWeekday;
@@ -85,5 +88,5 @@ export declare const DatePicker: {
85
88
  readonly rangeEnd?: true | undefined;
86
89
  }, CellProps>;
87
90
  };
88
- export type { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, InputProps, NextProps, PopupProps, PortalProps, PositionerProps, PreviousProps, SegmentProps, SegmentsProps, TriggerProps, WeekdaysProps, WeeksProps };
91
+ export type { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, InputProps, MonthsProps, NextProps, PopupProps, PortalProps, PositionerProps, PreviousProps, SegmentProps, SegmentsProps, TriggerProps, WeekdaysProps, WeeksProps };
89
92
  //# sourceMappingURL=date-picker.d.ts.map
@@ -22,6 +22,10 @@ const DatePicker = {
22
22
  isDateUnavailable: Function,
23
23
  calendarSystem: Object,
24
24
  fixedWeeks: Boolean,
25
+ months: Number,
26
+ pagedNavigation: Boolean,
27
+ month: optional(String),
28
+ defaultMonth: String,
25
29
  placeholders: Object,
26
30
  disabled: Boolean,
27
31
  readOnly: Boolean,
@@ -34,7 +38,9 @@ const DatePicker = {
34
38
  "update:value",
35
39
  "valueChange",
36
40
  "update:open",
37
- "openChange"
41
+ "openChange",
42
+ "update:month",
43
+ "monthChange"
38
44
  ],
39
45
  setup(props, { slots, emit }) {
40
46
  const generated = useId();
@@ -48,6 +54,10 @@ const DatePicker = {
48
54
  onOpenChange(open, details) {
49
55
  emit("openChange", open, details);
50
56
  if (!details.canceled) emit("update:open", open);
57
+ },
58
+ onMonthChange(month, details) {
59
+ emit("monthChange", month, details);
60
+ if (!details.canceled) emit("update:month", month);
51
61
  }
52
62
  })));
53
63
  scope$2.provide(made.field);
@@ -70,6 +80,7 @@ const DatePicker = {
70
80
  Heading: Calendar.Heading,
71
81
  Previous: Calendar.Previous,
72
82
  Next: Calendar.Next,
83
+ Months: Calendar.Months,
73
84
  Grid: Calendar.Grid,
74
85
  Weekdays: Calendar.Weekdays,
75
86
  HeadCell: Calendar.HeadCell,
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.js","names":[],"sources":["../../../../packages/vue/src/date-picker.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createDatePicker } from \"@kirana-ui/core/date-picker\"\nimport type { DatePicker as Controller, DatePickerProps } from \"@kirana-ui/core/date-picker\"\nimport { defineComponent, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { Calendar, calendarScope } from \"./calendar.ts\"\nimport { DateField, dateFieldScope } from \"./date-field.ts\"\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { Popover, popoverScope } from \"./popover.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponentProps, PlainComponent, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"datePicker\">\n\nconst scope = context<Controller>(\"DatePicker\")\n\nexport type RootProps = Omit<DatePickerProps, \"id\" | \"onValueChange\" | \"onOpenChange\"> & {\n id?: string | undefined\n}\n\n/** The value is `null` while the date is not whole. */\nexport type RootEmits = Changes<\"value\", string | null> & Changes<\"open\", boolean>\n\n/**\n * A date field, and a calendar in a popover, with one value between them. It draws nothing.\n * `v-model:value`, `v-model:open`; the `-change` events carry the details.\n */\nconst Root = defineComponent({\n name: \"DatePickerRoot\",\n props: {\n value: optional([String, null] as unknown as PropType<string | null>),\n defaultValue: String as PropType<string | null>,\n open: optional(Boolean),\n defaultOpen: Boolean,\n locale: String,\n min: String,\n max: String,\n isDateUnavailable: Function as PropType<DatePickerProps[\"isDateUnavailable\"]>,\n calendarSystem: Object as PropType<DatePickerProps[\"calendarSystem\"]>,\n fixedWeeks: Boolean,\n placeholders: Object as PropType<DatePickerProps[\"placeholders\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n const made = scope.provide(\n controller(within(createDatePicker, { direction: useDirectionAround() }), () => ({\n ...props,\n id: props.id ?? generated,\n onValueChange(value: string | null, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n dateFieldScope.provide(made.field)\n popoverScope.provide(made.popover)\n calendarScope.provide(made.calendar)\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<RootProps, RootEmits>\n\nexport type FieldProps = PartComponentProps\nexport type CalendarProps = PartComponentProps\nexport type { SegmentProps, SegmentsProps, InputProps } from \"./date-field.ts\"\nexport type { PopupProps, PortalProps, PositionerProps, TriggerProps } from \"./popover.ts\"\nexport type {\n CellProps,\n DayProps,\n GridProps,\n HeadCellProps,\n HeadingProps,\n NextProps,\n PreviousProps,\n WeekdaysProps,\n WeeksProps,\n} from \"./calendar.ts\"\nexport const DatePicker = {\n Root,\n /** The typed date: what holds its segments and its hidden input. */\n Field: partComponent<\"div\", State[\"field\"]>(\n \"DatePickerField\",\n \"div\",\n () => scope.use().field.root\n ),\n Segments: DateField.Segments,\n Segment: DateField.Segment,\n Input: DateField.Input,\n Trigger: Popover.Trigger,\n Portal: Popover.Portal,\n Positioner: Popover.Positioner,\n Popup: Popover.Popup,\n /** The calendar: what holds its heading, its buttons and its grid. */\n Calendar: partComponent<\"div\", State[\"calendar\"]>(\n \"DatePickerCalendar\",\n \"div\",\n () => scope.use().calendar.root\n ),\n Heading: Calendar.Heading,\n Previous: Calendar.Previous,\n Next: Calendar.Next,\n Grid: Calendar.Grid,\n Weekdays: Calendar.Weekdays,\n HeadCell: Calendar.HeadCell,\n Weeks: Calend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cACR,sBACA,aACM,MAAM,IAAI,CAAC,CAAC,SAAS,IAC7B;CACA,SAAS,SAAS;CAClB,UAAU,SAAS;CACnB,MAAM,SAAS;CACf,MAAM,SAAS;CACf,UAAU,SAAS;CACnB,UAAU,SAAS;CACnB,OAAO,SAAS;CAChB,MAAM,SAAS;CACf,KAAK,SAAS;AAChB"}
1
+ {"version":3,"file":"date-picker.js","names":[],"sources":["../../../../packages/vue/src/date-picker.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createDatePicker } from \"@kirana-ui/core/date-picker\"\nimport type { DatePicker as Controller, DatePickerProps } from \"@kirana-ui/core/date-picker\"\nimport { defineComponent, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { Calendar, calendarScope } from \"./calendar.ts\"\nimport { DateField, dateFieldScope } from \"./date-field.ts\"\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { Popover, popoverScope } from \"./popover.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponentProps, PlainComponent, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"datePicker\">\n\nconst scope = context<Controller>(\"DatePicker\")\n\nexport type RootProps = Omit<\n DatePickerProps,\n \"id\" | \"onValueChange\" | \"onOpenChange\" | \"onMonthChange\"\n> & {\n id?: string | undefined\n}\n\n/** The value is `null` while the date is not whole. */\nexport type RootEmits = Changes<\"value\", string | null> &\n Changes<\"open\", boolean> &\n Changes<\"month\", string>\n\n/**\n * A date field, and a calendar in a popover, with one value between them. It draws nothing.\n * `v-model:value`, `v-model:open`, `v-model:month` (the first day of the month the calendar\n * shows); the `-change` events carry the details.\n */\nconst Root = defineComponent({\n name: \"DatePickerRoot\",\n props: {\n value: optional([String, null] as unknown as PropType<string | null>),\n defaultValue: String as PropType<string | null>,\n open: optional(Boolean),\n defaultOpen: Boolean,\n locale: String,\n min: String,\n max: String,\n isDateUnavailable: Function as PropType<DatePickerProps[\"isDateUnavailable\"]>,\n calendarSystem: Object as PropType<DatePickerProps[\"calendarSystem\"]>,\n fixedWeeks: Boolean,\n months: Number,\n pagedNavigation: Boolean,\n month: optional(String),\n defaultMonth: String,\n placeholders: Object as PropType<DatePickerProps[\"placeholders\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\n \"update:value\",\n \"valueChange\",\n \"update:open\",\n \"openChange\",\n \"update:month\",\n \"monthChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const made = scope.provide(\n controller(within(createDatePicker, { direction: useDirectionAround() }), () => ({\n ...props,\n id: props.id ?? generated,\n onValueChange(value: string | null, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n onMonthChange(month: string, details: ChangeDetails) {\n emit(\"monthChange\", month, details)\n if (!details.canceled) emit(\"update:month\", month)\n },\n }))\n )\n dateFieldScope.provide(made.field)\n popoverScope.provide(made.popover)\n calendarScope.provide(made.calendar)\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<RootProps, RootEmits>\n\nexport type FieldProps = PartComponentProps\nexport type CalendarProps = PartComponentProps\nexport type { SegmentProps, SegmentsProps, InputProps } from \"./date-field.ts\"\nexport type { PopupProps, PortalProps, PositionerProps, TriggerProps } from \"./popover.ts\"\nexport type {\n CellProps,\n DayProps,\n GridProps,\n HeadCellProps,\n HeadingProps,\n MonthsProps,\n NextProps,\n PreviousProps,\n WeekdaysProps,\n WeeksProps,\n} from \"./calendar.ts\"\nexport const DatePicker = {\n Root,\n /** The typed date: what holds its segments and its hidden input. */\n Field: partComponent<\"div\", State[\"field\"]>(\n \"DatePickerField\",\n \"div\",\n () => scope.use().field.root\n ),\n Segments: DateField.Segments,\n Segment: DateField.Segment,\n Input: DateField.Input,\n Trigger: Popover.Trigger,\n Portal: Popover.Portal,\n Positioner: Popover.Positioner,\n Popup: Popover.Popup,\n /** The calendar: what holds its heading, its buttons and its grid. */\n Calendar: partComponent<\"div\", State[\"calendar\"]>(\n \"DatePickerCalendar\",\n \"div\",\n () => scope.use().calendar.root\n ),\n Heading: Calendar.Heading,\n Previous: Calendar.Previous,\n Next: Calendar.Next,\n Months: Calendar.Months,\n Grid: Calendar.Grid,\n Weekdays: Calendar.Weekdays,\n HeadCell: Calendar.HeadCell,\n Weeks: Calendar.Weeks,\n Cell: Calendar.Cell,\n Day: Calendar.Day,\n}\n"],"mappings":";;;;;;;;;AAgBA,MAAM,QAAQ,QAAoB,YAAY;AA+F9C,MAAa,aAAa;CACxB,MA7EW,gBAAgB;EAC3B,MAAM;EACN,OAAO;GACL,OAAO,SAAS,CAAC,QAAQ,IAAI,CAAuC;GACpE,cAAc;GACd,MAAM,SAAS,OAAO;GACtB,aAAa;GACb,QAAQ;GACR,KAAK;GACL,KAAK;GACL,mBAAmB;GACnB,gBAAgB;GAChB,YAAY;GACZ,QAAQ;GACR,iBAAiB;GACjB,OAAO,SAAS,MAAM;GACtB,cAAc;GACd,cAAc;GACd,UAAU;GACV,UAAU;GACV,UAAU;GACV,MAAM;GACN,MAAM;GACN,IAAI;EACN;EACA,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;EACF;EACA,MAAM,OAAO,EAAE,OAAO,QAAQ;GAC5B,MAAM,YAAY,MAAM;GACxB,MAAM,OAAO,MAAM,QACjB,WAAW,OAAO,kBAAkB,EAAE,WAAW,mBAAmB,EAAE,CAAC,UAAU;IAC/E,GAAG;IACH,IAAI,MAAM,MAAM;IAChB,cAAc,OAAsB,SAAwB;KAC1D,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;IACA,aAAa,MAAe,SAAwB;KAClD,KAAK,cAAc,MAAM,OAAO;KAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;IACjD;IACA,cAAc,OAAe,SAAwB;KACnD,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;GACF,EAAE,CACJ;GACA,QAAe,QAAQ,KAAK,KAAK;GACjC,QAAa,QAAQ,KAAK,OAAO;GACjC,QAAc,QAAQ,KAAK,QAAQ;GACnC,aAAa,MAAM,UAAU;EAC/B;CACF,CAmBE;;CAEA,OAAO,cACL,mBACA,aACM,MAAM,IAAI,CAAC,CAAC,MAAM,IAC1B;CACA,UAAU,UAAU;CACpB,SAAS,UAAU;CACnB,OAAO,UAAU;CACjB,SAAS,QAAQ;CACjB,QAAQ,QAAQ;CAChB,YAAY,QAAQ;CACpB,OAAO,QAAQ;;CAEf,UAAU,cACR,sBACA,aACM,MAAM,IAAI,CAAC,CAAC,SAAS,IAC7B;CACA,SAAS,SAAS;CAClB,UAAU,SAAS;CACnB,MAAM,SAAS;CACf,QAAQ,SAAS;CACjB,MAAM,SAAS;CACf,UAAU,SAAS;CACnB,UAAU,SAAS;CACnB,OAAO,SAAS;CAChB,MAAM,SAAS;CACf,KAAK,SAAS;AAChB"}
package/src/dialog.d.ts CHANGED
@@ -11,6 +11,7 @@ export type AlertRootProps = Omit<AlertDialogProps, "id" | "onOpenChange"> & {
11
11
  };
12
12
  export type TriggerProps = PartComponentProps;
13
13
  export type BackdropProps = PartComponentProps;
14
+ export type ViewportProps = PartComponentProps;
14
15
  export type PopupProps = PartComponentProps;
15
16
  export type TitleProps = PartComponentProps;
16
17
  export type DescriptionProps = PartComponentProps;
@@ -27,6 +28,15 @@ export declare const Dialog: {
27
28
  readonly startingStyle?: true | undefined;
28
29
  readonly endingStyle?: true | undefined;
29
30
  }, PartComponentProps, {}, unknown>;
31
+ /** What a long dialog scrolls in, around its popup: it may be left out. */
32
+ Viewport: PartComponent<"div", {
33
+ readonly open?: true | undefined;
34
+ readonly closed?: true | undefined;
35
+ readonly startingStyle?: true | undefined;
36
+ readonly endingStyle?: true | undefined;
37
+ readonly nested?: true | undefined;
38
+ readonly nestedDialogOpen?: true | undefined;
39
+ }, PartComponentProps, {}, unknown>;
30
40
  Popup: PartComponent<"div", {
31
41
  readonly open?: true | undefined;
32
42
  readonly closed?: true | undefined;
@@ -50,6 +60,15 @@ export declare const AlertDialog: {
50
60
  readonly startingStyle?: true | undefined;
51
61
  readonly endingStyle?: true | undefined;
52
62
  }, PartComponentProps, {}, unknown>;
63
+ /** What a long dialog scrolls in, around its popup: it may be left out. */
64
+ Viewport: PartComponent<"div", {
65
+ readonly open?: true | undefined;
66
+ readonly closed?: true | undefined;
67
+ readonly startingStyle?: true | undefined;
68
+ readonly endingStyle?: true | undefined;
69
+ readonly nested?: true | undefined;
70
+ readonly nestedDialogOpen?: true | undefined;
71
+ }, PartComponentProps, {}, unknown>;
53
72
  Popup: PartComponent<"div", {
54
73
  readonly open?: true | undefined;
55
74
  readonly closed?: true | undefined;