@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,139 @@
1
+ import { written } from "./element.js";
2
+ import { useFieldAround } from "./field-context.js";
3
+ import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
4
+ import { within } from "@kirana-ui/core";
5
+ import { Fragment, defineComponent, h, inject, provide, useId } from "vue";
6
+ import { createFileUpload, formatBytes } from "@kirana-ui/core/file-upload";
7
+ // src/file-upload.ts
8
+ const scope = context("FileUpload");
9
+ const ITEM = Symbol("FileUploadItem");
10
+ function useEntry(part) {
11
+ const entry = inject(ITEM, void 0);
12
+ if (!entry) throw new Error(`<FileUpload.${part}> must be inside <FileUpload.Item>`);
13
+ return entry;
14
+ }
15
+ const RootElement = partComponent("FileUploadRootElement", "div", () => scope.use().root);
16
+ /** `v-model:files`, or `files` with `@files-change="(files, details) => …"`. */
17
+ const Root = defineComponent({
18
+ name: "FileUploadRoot",
19
+ inheritAttrs: false,
20
+ props: {
21
+ files: optional(Array),
22
+ defaultFiles: Array,
23
+ accept: [String, Array],
24
+ multiple: Boolean,
25
+ maxFiles: Number,
26
+ maxSize: Number,
27
+ minSize: Number,
28
+ validate: Function,
29
+ disabled: Boolean,
30
+ required: Boolean,
31
+ name: String,
32
+ form: String,
33
+ id: String
34
+ },
35
+ emits: [
36
+ "update:files",
37
+ "filesChange",
38
+ "filesReject"
39
+ ],
40
+ setup(props, { attrs, slots, emit }) {
41
+ const generated = useId();
42
+ scope.provide(controller(within(createFileUpload, { field: useFieldAround() }), () => ({
43
+ id: props.id ?? generated,
44
+ files: props.files,
45
+ defaultFiles: props.defaultFiles,
46
+ accept: props.accept,
47
+ multiple: props.multiple,
48
+ maxFiles: props.maxFiles,
49
+ maxSize: props.maxSize,
50
+ minSize: props.minSize,
51
+ validate: props.validate,
52
+ disabled: props.disabled,
53
+ required: props.required,
54
+ name: props.name,
55
+ form: props.form,
56
+ onFilesChange(files, details) {
57
+ emit("filesChange", files, details);
58
+ if (!details.canceled) emit("update:files", files);
59
+ },
60
+ onFilesReject: (rejections) => emit("filesReject", rejections)
61
+ })));
62
+ return () => h(RootElement, attrs, slots);
63
+ }
64
+ });
65
+ const NativeInput = partComponent("FileUploadInput", "input", () => scope.use().input);
66
+ const Dropzone = partComponent("FileUploadDropzone", "div", () => scope.use().dropzone, (content) => [content, h(NativeInput)]);
67
+ /** Draws its slot once for each file, kept by the file's key (`v-slot="{ entry }"`). */
68
+ const Items = defineComponent({
69
+ name: "FileUploadItems",
70
+ setup(_props, { slots }) {
71
+ const entries = fromSignal(scope.use().entries);
72
+ return () => entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })));
73
+ }
74
+ });
75
+ const Item = defineComponent({
76
+ name: "FileUploadItem",
77
+ inheritAttrs: false,
78
+ props: { entry: {
79
+ type: Object,
80
+ required: true
81
+ } },
82
+ setup(props, { attrs, slots }) {
83
+ const key = props.entry.key;
84
+ const made = scope.use();
85
+ provide(ITEM, () => props.entry);
86
+ const Element = partComponent("FileUploadItemElement", "li", () => made.item(key));
87
+ return () => h(Element, attrs, slots);
88
+ }
89
+ });
90
+ /** Says the file's name unless its slot says something else. */
91
+ const ItemName = defineComponent({
92
+ name: "FileUploadItemName",
93
+ inheritAttrs: false,
94
+ setup(_props, { attrs, slots }) {
95
+ const entry = useEntry("ItemName");
96
+ const made = scope.use();
97
+ const text = () => entry().file.name;
98
+ const Element = partComponent("FileUploadItemNameElement", "span", () => made.itemName(entry().key), written(text));
99
+ return () => h(Element, attrs, { default: (given) => slots.default?.(given) ?? text() });
100
+ }
101
+ });
102
+ /** Says the file's size as people read one unless its slot says something else. */
103
+ const ItemSize = defineComponent({
104
+ name: "FileUploadItemSize",
105
+ inheritAttrs: false,
106
+ props: { locale: String },
107
+ setup(props, { attrs, slots }) {
108
+ const entry = useEntry("ItemSize");
109
+ const made = scope.use();
110
+ const text = () => formatBytes(entry().file.size, props.locale);
111
+ const Element = partComponent("FileUploadItemSizeElement", "span", () => made.itemSize(entry().key), written(text));
112
+ return () => h(Element, attrs, { default: (given) => slots.default?.(given) ?? text() });
113
+ }
114
+ });
115
+ const ItemRemove = defineComponent({
116
+ name: "FileUploadItemRemove",
117
+ inheritAttrs: false,
118
+ setup(_props, { attrs, slots }) {
119
+ const entry = useEntry("ItemRemove");
120
+ const made = scope.use();
121
+ const Element = partComponent("FileUploadItemRemoveElement", "button", () => made.itemRemove(entry().key));
122
+ return () => h(Element, attrs, slots);
123
+ }
124
+ });
125
+ const FileUpload = {
126
+ Root,
127
+ Dropzone,
128
+ Trigger: partComponent("FileUploadTrigger", "button", () => scope.use().trigger),
129
+ List: partComponent("FileUploadList", "ul", () => scope.use().list),
130
+ Items,
131
+ Item,
132
+ ItemName,
133
+ ItemSize,
134
+ ItemRemove,
135
+ Clear: partComponent("FileUploadClear", "button", () => scope.use().clear)
136
+ };
137
+ export { FileUpload };
138
+
139
+ //# sourceMappingURL=file-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-upload.js","names":[],"sources":["../../../../packages/vue/src/file-upload.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createFileUpload, formatBytes } from \"@kirana-ui/core/file-upload\"\nimport type {\n FileRejection,\n FileUpload as Controller,\n FileUploadEntry,\n FileUploadProps,\n} from \"@kirana-ui/core/file-upload\"\nimport { Fragment, defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { written } from \"./element.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"fileUpload\">\n\nconst scope = context<Controller>(\"FileUpload\")\n// The file an item is, for the parts inside it.\nconst ITEM: InjectionKey<() => FileUploadEntry> = Symbol(\"FileUploadItem\")\n\nfunction useEntry(part: string): () => FileUploadEntry {\n const entry = inject(ITEM, undefined)\n if (!entry) throw new Error(`<FileUpload.${part}> must be inside <FileUpload.Item>`)\n return entry\n}\n\nconst RootElement = partComponent(\"FileUploadRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<FileUploadProps, \"id\" | \"onFilesChange\" | \"onFilesReject\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"files\", File[]> & {\n /** The files that were not taken, each with its reasons. */\n filesReject: (rejections: FileRejection[]) => void\n}\n\n/** `v-model:files`, or `files` with `@files-change=\"(files, details) => …\"`. */\nconst Root = defineComponent({\n name: \"FileUploadRoot\",\n inheritAttrs: false,\n props: {\n files: optional(Array as PropType<readonly File[]>),\n defaultFiles: Array as PropType<readonly File[]>,\n accept: [String, Array] as PropType<string | readonly string[]>,\n multiple: Boolean,\n maxFiles: Number,\n maxSize: Number,\n minSize: Number,\n validate: Function as PropType<FileUploadProps[\"validate\"]>,\n disabled: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:files\", \"filesChange\", \"filesReject\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createFileUpload, { field: useFieldAround() }), () => ({\n id: props.id ?? generated,\n files: props.files,\n defaultFiles: props.defaultFiles,\n accept: props.accept,\n multiple: props.multiple,\n maxFiles: props.maxFiles,\n maxSize: props.maxSize,\n minSize: props.minSize,\n validate: props.validate,\n disabled: props.disabled,\n required: props.required,\n name: props.name,\n form: props.form,\n onFilesChange(files: File[], details: ChangeDetails) {\n emit(\"filesChange\", files, details)\n if (!details.canceled) emit(\"update:files\", files)\n },\n onFilesReject: (rejections: FileRejection[]) => emit(\"filesReject\", rejections),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nconst NativeInput = partComponent(\"FileUploadInput\", \"input\", () => scope.use().input)\n\nexport type DropzoneProps = PartComponentProps\n\n// The native file input is the element's last child, whatever element was asked for.\nconst Dropzone = partComponent<\"div\", State[\"dropzone\"]>(\n \"FileUploadDropzone\",\n \"div\",\n () => scope.use().dropzone,\n (content) => [content, h(NativeInput)]\n)\n\nexport type ItemsProps = Record<never, never>\n\n/** Draws its slot once for each file, kept by the file's key (`v-slot=\"{ entry }\"`). */\nconst Items = defineComponent({\n name: \"FileUploadItems\",\n setup(_props, { slots }) {\n const entries = fromSignal(scope.use().entries)\n return () =>\n entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })))\n },\n}) as unknown as PlainComponent<ItemsProps, {}, { entry: FileUploadEntry }>\n\nexport interface ItemProps extends PartComponentProps {\n /** The file it is, as `Items` gave it. */\n entry: FileUploadEntry\n}\n\nconst Item = defineComponent({\n name: \"FileUploadItem\",\n inheritAttrs: false,\n props: { entry: { type: Object as PropType<FileUploadEntry>, required: true } },\n setup(props, { attrs, slots }) {\n // An item is its file's key for as long as it is in the page.\n const key = props.entry.key\n const made = scope.use()\n provide(ITEM, () => props.entry)\n const Element = partComponent(\"FileUploadItemElement\", \"li\", () => made.item(key))\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"li\", State[\"item\"], ItemProps>\n\nexport type ItemNameProps = PartComponentProps\n\n/** Says the file's name unless its slot says something else. */\nconst ItemName = defineComponent({\n name: \"FileUploadItemName\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const entry = useEntry(\"ItemName\")\n const made = scope.use()\n const text = () => entry().file.name\n // With `as-child` the caller's element holds the text, unless it writes its own.\n const Element = partComponent(\n \"FileUploadItemNameElement\",\n \"span\",\n () => made.itemName(entry().key),\n written(text)\n )\n return () => h(Element, attrs, { default: (given: object) => slots.default?.(given) ?? text() })\n },\n}) as unknown as PartComponent<\"span\", State[\"itemName\"], ItemNameProps>\n\nexport interface ItemSizeProps extends PartComponentProps {\n /** The language the number is written in. Default: the reader's. */\n locale?: string | undefined\n}\n\n/** Says the file's size as people read one unless its slot says something else. */\nconst ItemSize = defineComponent({\n name: \"FileUploadItemSize\",\n inheritAttrs: false,\n props: { locale: String },\n setup(props, { attrs, slots }) {\n const entry = useEntry(\"ItemSize\")\n const made = scope.use()\n const text = () => formatBytes(entry().file.size, props.locale)\n // With `as-child` the caller's element holds the text, unless it writes its own.\n const Element = partComponent(\n \"FileUploadItemSizeElement\",\n \"span\",\n () => made.itemSize(entry().key),\n written(text)\n )\n return () => h(Element, attrs, { default: (given: object) => slots.default?.(given) ?? text() })\n },\n}) as unknown as PartComponent<\"span\", State[\"itemSize\"], ItemSizeProps>\n\nexport type ItemRemoveProps = PartComponentProps\n\nconst ItemRemove = defineComponent({\n name: \"FileUploadItemRemove\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const entry = useEntry(\"ItemRemove\")\n const made = scope.use()\n const Element = partComponent(\"FileUploadItemRemoveElement\", \"button\", () =>\n made.itemRemove(entry().key)\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"itemRemove\"], ItemRemoveProps>\n\nexport type TriggerProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport type ClearProps = PartComponentProps\nexport const FileUpload = {\n Root,\n Dropzone,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"FileUploadTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n List: partComponent<\"ul\", State[\"list\"]>(\"FileUploadList\", \"ul\", () => scope.use().list),\n Items,\n Item,\n ItemName,\n ItemSize,\n ItemRemove,\n Clear: partComponent<\"button\", State[\"clear\"]>(\n \"FileUploadClear\",\n \"button\",\n () => scope.use().clear\n ),\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,QAAQ,QAAoB,YAAY;AAE9C,MAAM,OAA4C,OAAO,gBAAgB;AAEzE,SAAS,SAAS,MAAqC;CACrD,MAAM,QAAQ,OAAO,MAAM,KAAA,CAAS;CACpC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACnF,OAAO;AACT;AAEA,MAAM,cAAc,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYxF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS,KAAkC;EAClD,cAAc;EACd,QAAQ,CAAC,QAAQ,KAAK;EACtB,UAAU;EACV,UAAU;EACV,SAAS;EACT,SAAS;EACT,UAAU;EACV,UAAU;EACV,UAAU;EACV,MAAM;EACN,MAAM;EACN,IAAI;CACN;CACA,OAAO;EAAC;EAAgB;EAAe;CAAa;CACpD,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,OAAO,kBAAkB,EAAE,OAAO,eAAe,EAAE,CAAC,UAAU;GACvE,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,QAAQ,MAAM;GACd,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,SAAS,MAAM;GACf,SAAS,MA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AC,KACpB;AACF"}
@@ -12,6 +12,7 @@ export declare const HoverCard: {
12
12
  readonly closed?: true | undefined;
13
13
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
14
14
  readonly align?: "center" | "end" | "start" | undefined;
15
+ readonly anchorHidden?: true | undefined;
15
16
  }, PositionerProps>;
16
17
  Popup: PartComponent<"div", {
17
18
  readonly open?: true | undefined;
@@ -23,6 +24,8 @@ export declare const HoverCard: {
23
24
  readonly instant?: "delay" | "dismiss" | "focus" | undefined;
24
25
  }, PartComponentProps, {}, unknown>;
25
26
  Arrow: PartComponent<"div", {
27
+ readonly open?: true | undefined;
28
+ readonly closed?: true | undefined;
26
29
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
27
30
  readonly align?: "center" | "end" | "start" | undefined;
28
31
  readonly uncentered?: true | undefined;
package/src/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Accordion } from "./accordion.js";
2
2
  import { Checkbox } from "./checkbox.js";
3
+ import { CheckboxGroup } from "./checkbox-group.js";
3
4
  import { Collapsible } from "./collapsible.js";
4
5
  import { AlertDialog, Dialog, Drawer } from "./dialog.js";
5
6
  import { MessageScroller } from "./message-scroller.js";
@@ -17,6 +18,16 @@ import { Command } from "./command.js";
17
18
  import { NumberField } from "./number-field.js";
18
19
  import "./autocomplete.js";
19
20
  import { Pagination } from "./pagination.js";
21
+ import { Rating } from "./rating.js";
22
+ import { Steps } from "./steps.js";
23
+ import { Editable } from "./editable.js";
24
+ import { PasswordInput } from "./password-input.js";
25
+ import { TagsInput } from "./tags-input.js";
26
+ import { FileUpload } from "./file-upload.js";
27
+ import { TimeField } from "./time-field.js";
28
+ import { Tree } from "./tree.js";
29
+ import { ColorPicker } from "./color-picker.js";
30
+ import { Tour } from "./tour.js";
20
31
  import { DatePicker } from "./date-picker.js";
21
32
  import { Calendar } from "./calendar.js";
22
33
  import { QrCode } from "./qr-code.js";
@@ -45,14 +56,24 @@ import { Fieldset } from "./fieldset.js";
45
56
  import { Form } from "./form.js";
46
57
  import { DirectionProvider, useDirection } from "./direction.js";
47
58
  import { PartEvent, PortalProvider } from "./runtime.js";
48
- import { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, ComponentDefinition, Direction, ItemLabels, ListCollection, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, ReadonlySignal, Side, Signal, StateDefinition, StateOf } from "@kirana-ui/core";
49
- import { DrawerSide, DrawerSnapPoint } from "@kirana-ui/core/drawer";
50
- import { PaginationEntry } from "@kirana-ui/core/pagination";
51
- import { DateFieldSegment, DateUnit } from "@kirana-ui/core/date-field";
52
- import { CalendarDay, CalendarValue, CalendarWeekday, DateRange, IsoDate } from "@kirana-ui/core/calendar";
59
+ import { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, CollisionAvoidance, CollisionBoundary, CollisionPadding, ComponentDefinition, Direction, ItemLabels, ListCollection, OffsetData, OffsetFunction, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, Presentation, ReadonlySignal, Side, Signal, StateDefinition, StateOf } from "@kirana-ui/core";
60
+ import { FileRejection, FileRejectionReason, FileUploadEntry } from "@kirana-ui/core/file-upload";
53
61
  import { QrCorrection } from "@kirana-ui/core/qr-code";
54
62
  import { SelectShown } from "@kirana-ui/core/select";
55
- import { SliderChangeDetails, SliderTold } from "@kirana-ui/core/slider";
63
+ import { DrawerSide, DrawerSnapPoint } from "@kirana-ui/core/drawer";
64
+ import { CalendarDay, CalendarMode, CalendarMonth, CalendarValue, CalendarValueOf, CalendarWeekday, DateRange, IsoDate } from "@kirana-ui/core/calendar";
65
+ import { TourStep, TourTarget } from "@kirana-ui/core/tour";
56
66
  import { FieldValidity, ValidityKey } from "@kirana-ui/core/field";
57
67
  import { FormErrors, FormValues, ValidationMode } from "@kirana-ui/core/form";
58
- export { Accordion, AlertDialog, type Align, type Anchor, type AnchorOption, Autocomplete, Autosize, Avatar, type Bindable, Button, Calendar, type CalendarDay, type CalendarValue, type CalendarWeekday, Carousel, type ChangeDetails, type ChangeSource, Checkbox, Collapsible, Combobox, Command, type ComponentDefinition, ContextMenu, DateField, type DateFieldSegment, DatePicker, type DateRange, type DateUnit, Dialog, type Direction, DirectionProvider, Drawer, type DrawerSide, type DrawerSnapPoint, Field, type FieldValidity, Fieldset, Form, type FormErrors, type FormValues, HoverCard, Input, type IsoDate, type ItemLabels, Label, type ListCollection, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, type Orientation, Otp, Pagination, type PaginationEntry, type Part, type PartDefinition, type PartEvent, type PartProps, type PartState, type PartStyle, type PhysicalSide, Popover, PortalProvider, type PositionOptions, Progress, QrCode, type QrCorrection, RadioGroup, type ReadonlySignal, Resizable, ScrollArea, Select, type SelectShown, Separator, type Side, type Signal, Slider, type SliderChangeDetails, type SliderTold, type StateDefinition, type StateOf, Switch, Tabs, Toast, type ToastActionOptions, type ToastContent, type ToastOptions, type ToastRecord, type ToastState, type Toaster, type ToasterOptions, Toggle, ToggleGroup, Toolbar, Tooltip, type ValidationMode, type ValidityKey, createToaster, useDirection };
68
+ import { ImageStatus } from "@kirana-ui/core/avatar";
69
+ import { ComboboxEntry, ComboboxGroupData, ComboboxGroupEntry, ComboboxItemData, ComboboxItemEntry, ComboboxShown } from "@kirana-ui/core/combobox";
70
+ import { PaginationEntry } from "@kirana-ui/core/pagination";
71
+ import { HourCycle, IsoTime, TimeFieldSegment, TimeGranularity, TimeUnit } from "@kirana-ui/core/time-field";
72
+ import { TagsInputEntry } from "@kirana-ui/core/tags-input";
73
+ import { SliderChangeDetails, SliderTold } from "@kirana-ui/core/slider";
74
+ import { OtpValidation } from "@kirana-ui/core/otp";
75
+ import { DateFieldSegment, DateUnit } from "@kirana-ui/core/date-field";
76
+ import { TreeSelectionMode } from "@kirana-ui/core/tree";
77
+ import { ColorFormat, ColorPickerInputChannel, ColorPickerSliderChannel, ColorPickerThumb, Hsva } from "@kirana-ui/core/color-picker";
78
+ import { DatePickerMode, DatePickerRange, DatePickerValue, DatePickerValueOf } from "@kirana-ui/core/date-picker";
79
+ export { Accordion, AlertDialog, type Align, type Anchor, type AnchorOption, Autocomplete, Autosize, Avatar, type Bindable, Button, Calendar, type CalendarDay, type CalendarMode, type CalendarMonth, type CalendarValue, type CalendarValueOf, type CalendarWeekday, Carousel, type ChangeDetails, type ChangeSource, Checkbox, CheckboxGroup, Collapsible, type CollisionAvoidance, type CollisionBoundary, type CollisionPadding, type ColorFormat, ColorPicker, type ColorPickerInputChannel, type ColorPickerSliderChannel, type ColorPickerThumb, Combobox, type ComboboxEntry, type ComboboxGroupData, type ComboboxGroupEntry, type ComboboxItemData, type ComboboxItemEntry, type ComboboxShown, Command, type ComponentDefinition, ContextMenu, DateField, type DateFieldSegment, DatePicker, type DatePickerMode, type DatePickerRange, type DatePickerValue, type DatePickerValueOf, type DateRange, type DateUnit, Dialog, type Direction, DirectionProvider, Drawer, type DrawerSide, type DrawerSnapPoint, Editable, Field, type FieldValidity, Fieldset, type FileRejection, type FileRejectionReason, FileUpload, type FileUploadEntry, Form, type FormErrors, type FormValues, type HourCycle, HoverCard, type Hsva, type ImageStatus, Input, type IsoDate, type IsoTime, type ItemLabels, Label, type ListCollection, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, type OffsetData, type OffsetFunction, type Orientation, Otp, type OtpValidation, Pagination, type PaginationEntry, type Part, type PartDefinition, type PartEvent, type PartProps, type PartState, type PartStyle, PasswordInput, type PhysicalSide, Popover, PortalProvider, type PositionOptions, type Presentation, Progress, QrCode, type QrCorrection, RadioGroup, Rating, type ReadonlySignal, Resizable, ScrollArea, Select, type SelectShown, Separator, type Side, type Signal, Slider, type SliderChangeDetails, type SliderTold, type StateDefinition, type StateOf, Steps, Switch, Tabs, TagsInput, type TagsInputEntry, TimeField, type TimeFieldSegment, type TimeGranularity, type TimeUnit, Toast, type ToastActionOptions, type ToastContent, type ToastOptions, type ToastRecord, type ToastState, type Toaster, type ToasterOptions, Toggle, ToggleGroup, Toolbar, Tooltip, Tour, type TourStep, type TourTarget, Tree, type TreeSelectionMode, type ValidationMode, type ValidityKey, createToaster, useDirection };
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Accordion } from "./accordion.js";
2
2
  import { Checkbox } from "./checkbox.js";
3
+ import { CheckboxGroup } from "./checkbox-group.js";
3
4
  import { Collapsible } from "./collapsible.js";
4
5
  import { AlertDialog, Dialog, Drawer } from "./dialog.js";
5
6
  import { MessageScroller } from "./message-scroller.js";
@@ -16,6 +17,16 @@ import { Label } from "./label.js";
16
17
  import { Command } from "./command.js";
17
18
  import { NumberField } from "./number-field.js";
18
19
  import { Pagination } from "./pagination.js";
20
+ import { Rating } from "./rating.js";
21
+ import { Steps } from "./steps.js";
22
+ import { Editable } from "./editable.js";
23
+ import { PasswordInput } from "./password-input.js";
24
+ import { TagsInput } from "./tags-input.js";
25
+ import { FileUpload } from "./file-upload.js";
26
+ import { TimeField } from "./time-field.js";
27
+ import { Tree } from "./tree.js";
28
+ import { ColorPicker } from "./color-picker.js";
29
+ import { Tour } from "./tour.js";
19
30
  import { DatePicker } from "./date-picker.js";
20
31
  import { Calendar } from "./calendar.js";
21
32
  import { QrCode } from "./qr-code.js";
@@ -44,4 +55,4 @@ import { Fieldset } from "./fieldset.js";
44
55
  import { Form } from "./form.js";
45
56
  import { DirectionProvider, useDirection } from "./direction.js";
46
57
  import { PortalProvider } from "./runtime.js";
47
- export { Accordion, AlertDialog, Autocomplete, Autosize, Avatar, Button, Calendar, Carousel, Checkbox, Collapsible, Combobox, Command, ContextMenu, DateField, DatePicker, Dialog, DirectionProvider, Drawer, Field, Fieldset, Form, HoverCard, Input, Label, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, Otp, Pagination, Popover, PortalProvider, Progress, QrCode, RadioGroup, Resizable, ScrollArea, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToaster, useDirection };
58
+ export { Accordion, AlertDialog, Autocomplete, Autosize, Avatar, Button, Calendar, Carousel, Checkbox, CheckboxGroup, Collapsible, ColorPicker, Combobox, Command, ContextMenu, DateField, DatePicker, Dialog, DirectionProvider, Drawer, Editable, Field, Fieldset, FileUpload, Form, HoverCard, Input, Label, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, Otp, Pagination, PasswordInput, Popover, PortalProvider, Progress, QrCode, RadioGroup, Rating, Resizable, ScrollArea, Select, Separator, Slider, Steps, Switch, Tabs, TagsInput, TimeField, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, Tour, Tree, createToaster, useDirection };
package/src/menu.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare const Menu: {
42
42
  Root: PlainComponent<RootProps, RootEmits>;
43
43
  Trigger: PartComponent<"button", {
44
44
  readonly popupOpen?: true | undefined;
45
+ readonly pressed?: true | undefined;
45
46
  readonly disabled?: true | undefined;
46
47
  }, PartComponentProps, {}, unknown>;
47
48
  Portal: PlainComponent<PortalProps, {}, {}>;
@@ -50,6 +51,7 @@ export declare const Menu: {
50
51
  readonly closed?: true | undefined;
51
52
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
52
53
  readonly align?: "center" | "end" | "start" | undefined;
54
+ readonly anchorHidden?: true | undefined;
53
55
  }, PositionerProps>;
54
56
  Popup: PartComponent<"div", {
55
57
  readonly open?: true | undefined;
@@ -58,8 +60,11 @@ export declare const Menu: {
58
60
  readonly endingStyle?: true | undefined;
59
61
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
60
62
  readonly align?: "center" | "end" | "start" | undefined;
63
+ readonly instant?: "click" | "dismiss" | "group" | undefined;
61
64
  }, PartComponentProps, {}, unknown>;
62
65
  Arrow: PartComponent<"div", {
66
+ readonly open?: true | undefined;
67
+ readonly closed?: true | undefined;
63
68
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
64
69
  readonly align?: "center" | "end" | "start" | undefined;
65
70
  readonly uncentered?: true | undefined;
@@ -113,6 +118,7 @@ export declare const ContextMenu: {
113
118
  readonly closed?: true | undefined;
114
119
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
115
120
  readonly align?: "center" | "end" | "start" | undefined;
121
+ readonly anchorHidden?: true | undefined;
116
122
  }, PositionerProps>;
117
123
  Popup: PartComponent<"div", {
118
124
  readonly open?: true | undefined;
@@ -121,8 +127,11 @@ export declare const ContextMenu: {
121
127
  readonly endingStyle?: true | undefined;
122
128
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
123
129
  readonly align?: "center" | "end" | "start" | undefined;
130
+ readonly instant?: "click" | "dismiss" | "group" | undefined;
124
131
  }, PartComponentProps, {}, unknown>;
125
132
  Arrow: PartComponent<"div", {
133
+ readonly open?: true | undefined;
134
+ readonly closed?: true | undefined;
126
135
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
127
136
  readonly align?: "center" | "end" | "start" | undefined;
128
137
  readonly uncentered?: true | undefined;
@@ -173,6 +182,7 @@ export declare const ContextMenu: {
173
182
  /** The area a secondary press, or a long press on a touch screen, opens the menu in. */
174
183
  Trigger: PartComponent<"div", {
175
184
  readonly popupOpen?: true | undefined;
185
+ readonly pressed?: true | undefined;
176
186
  }, PartComponentProps, {}, unknown>;
177
187
  };
178
188
  export type { PortalProps, PositionerProps };
package/src/menu.js CHANGED
@@ -25,6 +25,11 @@ function root(name, kind) {
25
25
  open: optional(Boolean),
26
26
  defaultOpen: Boolean,
27
27
  disabled: Boolean,
28
+ loopFocus: optional(Boolean),
29
+ /**
30
+ * Whether the arrows wrap from the last item to the first.
31
+ * @deprecated Base UI's name is `loopFocus`, which wins when both are given.
32
+ */
28
33
  loop: optional(Boolean),
29
34
  modal: Boolean,
30
35
  id: String
@@ -44,6 +49,7 @@ function root(name, kind) {
44
49
  defaultOpen: props.defaultOpen,
45
50
  disabled: props.disabled,
46
51
  loop: props.loop,
52
+ loopFocus: props.loopFocus,
47
53
  modal: props.modal,
48
54
  onOpenChange(open, details) {
49
55
  emit("openChange", open, details);
@@ -59,6 +65,7 @@ function root(name, kind) {
59
65
  const ITEM_PROPS = {
60
66
  disabled: optional(Boolean),
61
67
  label: String,
68
+ closeOnSelect: optional(Boolean),
62
69
  closeOnClick: optional(Boolean)
63
70
  };
64
71
  const Item = defineComponent({
@@ -114,6 +121,7 @@ const CheckboxItem = defineComponent({
114
121
  defaultChecked: props.defaultChecked,
115
122
  disabled: props.disabled,
116
123
  label: props.label,
124
+ closeOnSelect: props.closeOnSelect,
117
125
  closeOnClick: props.closeOnClick,
118
126
  onCheckedChange(checked, details) {
119
127
  emit("checkedChange", checked, details);
@@ -131,9 +139,10 @@ const CheckboxItemIndicator = defineComponent({
131
139
  props: { keepMounted: Boolean },
132
140
  setup(props, { attrs, slots }) {
133
141
  const item = inside(CHECKBOX, "CheckboxItem");
134
- const checked = fromSignal(item.checked);
135
- const Element = partComponent("MenuCheckboxItemIndicatorElement", "span", () => item.indicator);
136
- return () => checked.value || props.keepMounted ? h(Element, attrs, slots) : null;
142
+ const indicator = controller(() => item.indicator, () => ({}));
143
+ const mounted = fromSignal(indicator.mounted);
144
+ const Element = partComponent("MenuCheckboxItemIndicatorElement", "span", () => indicator);
145
+ return () => mounted.value || props.keepMounted ? h(Element, attrs, slots) : null;
137
146
  }
138
147
  });
139
148
  /** `v-model:value`; `@value-change` carries the details. */
@@ -182,6 +191,7 @@ const RadioItem = defineComponent({
182
191
  const options = toSignal(() => ({
183
192
  disabled: props.disabled,
184
193
  label: props.label,
194
+ closeOnSelect: props.closeOnSelect,
185
195
  closeOnClick: props.closeOnClick
186
196
  }));
187
197
  const part = inside(RADIO_GROUP, "RadioGroup").item(value, () => defined(options.get()));
@@ -197,9 +207,10 @@ const RadioItemIndicator = defineComponent({
197
207
  setup(props, { attrs, slots }) {
198
208
  const group = inside(RADIO_GROUP, "RadioGroup");
199
209
  const value = inject(RADIO_ITEM);
200
- const checked = fromSignal(group.checked(value));
201
- const Element = partComponent("MenuRadioItemIndicatorElement", "span", () => group.indicator(value));
202
- return () => checked.value || props.keepMounted ? h(Element, attrs, slots) : null;
210
+ const indicator = controller(() => group.indicator(value), () => ({}));
211
+ const mounted = fromSignal(indicator.mounted);
212
+ const Element = partComponent("MenuRadioItemIndicatorElement", "span", () => indicator);
213
+ return () => mounted.value || props.keepMounted ? h(Element, attrs, slots) : null;
203
214
  }
204
215
  });
205
216
  const Menu = {
package/src/menu.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","names":[],"sources":["../../../../packages/vue/src/menu.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu as Controller,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuItemOptions,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { MENUBAR } from \"./menubar-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 PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"menu\">\n\nconst scope = context<Controller>(\"Menu\")\nconst GROUP: InjectionKey<MenuGroup | null> = Symbol(\"MenuGroup\")\nconst CHECKBOX: InjectionKey<MenuCheckboxItem> = Symbol(\"MenuCheckboxItem\")\nconst RADIO_GROUP: InjectionKey<MenuRadioGroup> = Symbol(\"MenuRadioGroup\")\nconst RADIO_ITEM: InjectionKey<unknown> = Symbol(\"MenuRadioItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nfunction inside<T>(key: InjectionKey<T>, parent: string): T {\n const found = inject(key, undefined)\n if (!found) throw new Error(`A Menu part must be inside <Menu.${parent}>`)\n return found\n}\n\nexport type RootProps = Omit<MenuProps, \"id\" | \"onOpenChange\"> & { id?: string | undefined }\nexport type SubmenuRootProps = RootProps\nexport type ContextRootProps = RootProps\n\nexport type RootEmits = Changes<\"open\", boolean>\nexport type SubmenuRootEmits = RootEmits\n\n/** `v-model:open`; `@open-change` carries the details. */\nfunction root(name: string, kind: \"menu\" | \"submenu\" | \"context\") {\n return defineComponent({\n name,\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n loop: optional(Boolean),\n modal: Boolean,\n id: String,\n },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n const parent = kind === \"submenu\" ? scope.use() : undefined\n const direction = useDirectionAround()\n const menubar = kind === \"menu\" ? (inject(MENUBAR, null) ?? undefined) : undefined\n const around = { parent, direction, menubar, context: kind === \"context\" }\n scope.provide(\n controller(within(createMenu, around), () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n loop: props.loop,\n modal: props.modal,\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n // A group around a submenu is not a group of the submenu's own items; nor is a menu\n // written inside a bar's menu one of the bar's.\n provide(GROUP, null)\n provide(MENUBAR, null)\n return () => slots.default?.()\n },\n }) as unknown as PlainComponent<RootProps, RootEmits>\n}\n\nconst ITEM_PROPS = {\n disabled: optional(Boolean),\n label: String,\n closeOnClick: optional(Boolean),\n}\n\nexport interface ItemProps extends MenuItemOptions, PartComponentProps {}\n\nconst Item = defineComponent({\n name: \"MenuItem\",\n inheritAttrs: false,\n props: ITEM_PROPS,\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().item(() => defined(options.get()))\n const Element = partComponent(\"MenuItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport type LinkItemProps = ItemProps\n\n/** An item that is a link: `href` and the rest go to its `<a>`. */\nconst LinkItem = defineComponent({\n name: \"MenuLinkItem\",\n inheritAttrs: false,\n props: ITEM_PROPS,\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().item(() => defined(options.get()))\n const Element = partComponent(\"MenuLinkItemElement\", \"a\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"a\", State[\"linkItem\"], LinkItemProps>\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\nconst Group = defineComponent({\n name: \"MenuGroup\",\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(\"MenuGroupElement\", \"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 \"MenuGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().label\n)\n\nexport type CheckboxItemProps = Omit<MenuCheckboxItemProps, \"onCheckedChange\"> & PartComponentProps\n\nexport type CheckboxItemEmits = Changes<\"checked\", boolean>\n\n/** `v-model:checked`; `@checked-change` carries the details. */\nconst CheckboxItem = defineComponent({\n name: \"MenuCheckboxItem\",\n inheritAttrs: false,\n props: { ...ITEM_PROPS, checked: optional(Boolean), defaultChecked: Boolean },\n emits: [\"update:checked\", \"checkedChange\"],\n setup(props, { attrs, slots, emit }) {\n const item = controller(scope.use().checkboxItem, () => ({\n checked: props.checked,\n defaultChecked: props.defaultChecked,\n disabled: props.disabled,\n label: props.label,\n closeOnClick: props.closeOnClick,\n onCheckedChange(checked: boolean, details: ChangeDetails) {\n emit(\"checkedChange\", checked, details)\n if (!details.canceled) emit(\"update:checked\", checked)\n },\n }))\n provide(CHECKBOX, item)\n const Element = partComponent(\"MenuCheckboxItemElement\", \"div\", () => item.part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"checkboxItem\"], CheckboxItemProps, CheckboxItemEmits>\n\nexport interface CheckboxItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the item is unchecked. */\n keepMounted?: boolean | undefined\n}\n\nconst CheckboxItemIndicator = defineComponent({\n name: \"MenuCheckboxItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const item = inside(CHECKBOX, \"CheckboxItem\")\n const checked = fromSignal(item.checked)\n const Element = partComponent(\"MenuCheckboxItemIndicatorElement\", \"span\", () => item.indicator)\n return () => (checked.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"checkboxItemIndicator\"], CheckboxItemIndicatorProps>\n\nexport type RadioGroupProps<Value = unknown> = Omit<MenuRadioGroupProps<Value>, \"onValueChange\"> &\n PartComponentProps\n\nexport type RadioGroupEmits<Value = unknown> = Changes<\"value\", Value>\n\n/** `v-model:value`; `@value-change` carries the details. */\nconst RadioGroup = defineComponent({\n name: \"MenuRadioGroup\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n disabled: Boolean,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const group = controller(scope.use().radioGroup<unknown>, () => ({\n value: props.value,\n defaultValue: props.defaultValue,\n disabled: props.disabled,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n }))\n provide(RADIO_GROUP, group)\n const Element = partComponent(\"MenuRadioGroupElement\", \"div\", () => group.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as new <Value = unknown, As extends string = \"div\">(\n props: PartGiven<As, RadioGroupProps<Value>, RadioGroupEmits<Value>> & PublicProps\n) => PartInstance<\n As,\n RadioGroupProps<Value>,\n RadioGroupEmits<Value>,\n { state: State[\"radioGroup\"] }\n>\n\nexport interface RadioItemProps extends MenuItemOptions, PartComponentProps {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n}\n\nconst RadioItem = defineComponent({\n name: \"MenuRadioItem\",\n inheritAttrs: false,\n props: { ...ITEM_PROPS, value: { type: ANY, required: true } },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n closeOnClick: props.closeOnClick,\n }))\n const part = inside(RADIO_GROUP, \"RadioGroup\").item(value, () => defined(options.get()))\n provide(RADIO_ITEM, value)\n const Element = partComponent(\"MenuRadioItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"radioItem\"], RadioItemProps>\n\nexport interface RadioItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean | undefined\n}\n\nconst RadioItemIndicator = defineComponent({\n name: \"MenuRadioItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const group = inside(RADIO_GROUP, \"RadioGroup\")\n const value = inject(RADIO_ITEM)\n const checked = fromSignal(group.checked(value))\n const Element = partComponent(\"MenuRadioItemIndicatorElement\", \"span\", () =>\n group.indicator(value)\n )\n return () => (checked.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"radioItemIndicator\"], RadioItemIndicatorProps>\n\nexport type TriggerProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type ArrowProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport type SubmenuTriggerProps = PartComponentProps\nexport type ContextTriggerProps = PartComponentProps\nexport const Menu = {\n Root: root(\"MenuRoot\", \"menu\"),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"MenuTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Portal: portalComponent(\"MenuPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"MenuPositioner\",\n () => scope.use(),\n partComponent(\"MenuPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"MenuPopup\", \"div\", () => scope.use().popup),\n Arrow: partComponent<\"div\", State[\"arrow\"]>(\"MenuArrow\", \"div\", () => scope.use().arrow),\n Item,\n LinkItem,\n Group,\n GroupLabel,\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"MenuSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n CheckboxItem,\n CheckboxItemIndicator,\n RadioGroup,\n RadioItem,\n RadioItemIndicator,\n /** A menu that one of this menu's items opens. Its trigger is `Menu.SubmenuTrigger`. */\n SubmenuRoot: root(\"MenuSubmenuRoot\", \"submenu\"),\n SubmenuTrigger: partComponent<\"div\", State[\"submenuTrigger\"]>(\n \"MenuSubmenuTrigger\",\n \"div\",\n () => scope.use().trigger\n ),\n}\n\nexport const ContextMenu = {\n ...Menu,\n /** A menu for an area of the page, opened at the pointer. Its trigger is the area. */\n Root: root(\"ContextMenuRoot\", \"context\"),\n /** The area a secondary press, or a long press on a touch screen, opens the menu in. */\n Trigger: partComponent<\"div\", StatesOf<\"contextMenu\">[\"trigger\"]>(\n \"ContextMenuTrigger\",\n \"div\",\n () => scope.use().area\n ),\n}\n"],"mappings":";;;;;;;;A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,OAAO;CAC/D,YAAY,oBACV,wBACM,MAAM,IAAI,GAChB,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAC5E;CACA,OAAO,cAAqC,aAAa,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CACvF,OAAO,cAAqC,aAAa,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CACvF;CACA;CACA;CACA;CACA,WAAW,cACT,iBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;CACA;CACA;CACA;CACA;;CAEA,aAAa,KAAK,mBAAmB,SAAS;CAC9C,gBAAgB,cACd,sBACA,aACM,MAAM,IAAI,CAAC,CAAC,OACpB;AACF;AAEA,MAAa,cAAc;CACzB,GAAG;;CAEH,MAAM,KAAK,mBAAmB,SAAS;;CAEvC,SAAS,cACP,sBACA,aACM,MAAM,IAAI,CAAC,CAAC,IACpB;AACF"}
1
+ {"version":3,"file":"menu.js","names":[],"sources":["../../../../packages/vue/src/menu.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu as Controller,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuItemOptions,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { MENUBAR } from \"./menubar-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 PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"menu\">\n\nconst scope = context<Controller>(\"Menu\")\nconst GROUP: InjectionKey<MenuGroup | null> = Symbol(\"MenuGroup\")\nconst CHECKBOX: InjectionKey<MenuCheckboxItem> = Symbol(\"MenuCheckboxItem\")\nconst RADIO_GROUP: InjectionKey<MenuRadioGroup> = Symbol(\"MenuRadioGroup\")\nconst RADIO_ITEM: InjectionKey<unknown> = Symbol(\"MenuRadioItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nfunction inside<T>(key: InjectionKey<T>, parent: string): T {\n const found = inject(key, undefined)\n if (!found) throw new Error(`A Menu part must be inside <Menu.${parent}>`)\n return found\n}\n\nexport type RootProps = Omit<MenuProps, \"id\" | \"onOpenChange\"> & { id?: string | undefined }\nexport type SubmenuRootProps = RootProps\nexport type ContextRootProps = RootProps\n\nexport type RootEmits = Changes<\"open\", boolean>\nexport type SubmenuRootEmits = RootEmits\n\n/** `v-model:open`; `@open-change` carries the details. */\nfunction root(name: string, kind: \"menu\" | \"submenu\" | \"context\") {\n return defineComponent({\n name,\n props: {\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n loopFocus: optional(Boolean),\n /**\n * Whether the arrows wrap from the last item to the first.\n * @deprecated Base UI's name is `loopFocus`, which wins when both are given.\n */\n loop: optional(Boolean),\n modal: Boolean,\n id: String,\n },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n const parent = kind === \"submenu\" ? scope.use() : undefined\n const direction = useDirectionAround()\n const menubar = kind === \"menu\" ? (inject(MENUBAR, null) ?? undefined) : undefined\n const around = { parent, direction, menubar, context: kind === \"context\" }\n scope.provide(\n controller(within(createMenu, around), () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n loop: props.loop,\n loopFocus: props.loopFocus,\n modal: props.modal,\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n // A group around a submenu is not a group of the submenu's own items; nor is a menu\n // written inside a bar's menu one of the bar's.\n provide(GROUP, null)\n provide(MENUBAR, null)\n return () => slots.default?.()\n },\n }) as unknown as PlainComponent<RootProps, RootEmits>\n}\n\nconst ITEM_PROPS = {\n disabled: optional(Boolean),\n label: String,\n closeOnSelect: optional(Boolean),\n closeOnClick: optional(Boolean),\n}\n\nexport interface ItemProps extends MenuItemOptions, PartComponentProps {}\n\nconst Item = defineComponent({\n name: \"MenuItem\",\n inheritAttrs: false,\n props: ITEM_PROPS,\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().item(() => defined(options.get()))\n const Element = partComponent(\"MenuItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport type LinkItemProps = ItemProps\n\n/** An item that is a link: `href` and the rest go to its `<a>`. */\nconst LinkItem = defineComponent({\n name: \"MenuLinkItem\",\n inheritAttrs: false,\n props: ITEM_PROPS,\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().item(() => defined(options.get()))\n const Element = partComponent(\"MenuLinkItemElement\", \"a\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"a\", State[\"linkItem\"], LinkItemProps>\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\nconst Group = defineComponent({\n name: \"MenuGroup\",\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(\"MenuGroupElement\", \"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 \"MenuGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().label\n)\n\nexport type CheckboxItemProps = Omit<MenuCheckboxItemProps, \"onCheckedChange\"> & PartComponentProps\n\nexport type CheckboxItemEmits = Changes<\"checked\", boolean>\n\n/** `v-model:checked`; `@checked-change` carries the details. */\nconst CheckboxItem = defineComponent({\n name: \"MenuCheckboxItem\",\n inheritAttrs: false,\n props: { ...ITEM_PROPS, checked: optional(Boolean), defaultChecked: Boolean },\n emits: [\"update:checked\", \"checkedChange\"],\n setup(props, { attrs, slots, emit }) {\n const item = controller(scope.use().checkboxItem, () => ({\n checked: props.checked,\n defaultChecked: props.defaultChecked,\n disabled: props.disabled,\n label: props.label,\n closeOnSelect: props.closeOnSelect,\n closeOnClick: props.closeOnClick,\n onCheckedChange(checked: boolean, details: ChangeDetails) {\n emit(\"checkedChange\", checked, details)\n if (!details.canceled) emit(\"update:checked\", checked)\n },\n }))\n provide(CHECKBOX, item)\n const Element = partComponent(\"MenuCheckboxItemElement\", \"div\", () => item.part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"checkboxItem\"], CheckboxItemProps, CheckboxItemEmits>\n\nexport interface CheckboxItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the item is unchecked. */\n keepMounted?: boolean | undefined\n}\n\nconst CheckboxItemIndicator = defineComponent({\n name: \"MenuCheckboxItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const item = inside(CHECKBOX, \"CheckboxItem\")\n // In the page while checked, and through its exit.\n const indicator = controller(\n () => item.indicator,\n () => ({})\n )\n const mounted = fromSignal(indicator.mounted)\n const Element = partComponent(\"MenuCheckboxItemIndicatorElement\", \"span\", () => indicator)\n return () => (mounted.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"checkboxItemIndicator\"], CheckboxItemIndicatorProps>\n\nexport type RadioGroupProps<Value = unknown> = Omit<MenuRadioGroupProps<Value>, \"onValueChange\"> &\n PartComponentProps\n\nexport type RadioGroupEmits<Value = unknown> = Changes<\"value\", Value>\n\n/** `v-model:value`; `@value-change` carries the details. */\nconst RadioGroup = defineComponent({\n name: \"MenuRadioGroup\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n disabled: Boolean,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const group = controller(scope.use().radioGroup<unknown>, () => ({\n value: props.value,\n defaultValue: props.defaultValue,\n disabled: props.disabled,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n }))\n provide(RADIO_GROUP, group)\n const Element = partComponent(\"MenuRadioGroupElement\", \"div\", () => group.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as new <Value = unknown, As extends string = \"div\">(\n props: PartGiven<As, RadioGroupProps<Value>, RadioGroupEmits<Value>> & PublicProps\n) => PartInstance<\n As,\n RadioGroupProps<Value>,\n RadioGroupEmits<Value>,\n { state: State[\"radioGroup\"] }\n>\n\nexport interface RadioItemProps extends MenuItemOptions, PartComponentProps {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n}\n\nconst RadioItem = defineComponent({\n name: \"MenuRadioItem\",\n inheritAttrs: false,\n props: { ...ITEM_PROPS, value: { type: ANY, required: true } },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n closeOnSelect: props.closeOnSelect,\n closeOnClick: props.closeOnClick,\n }))\n const part = inside(RADIO_GROUP, \"RadioGroup\").item(value, () => defined(options.get()))\n provide(RADIO_ITEM, value)\n const Element = partComponent(\"MenuRadioItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"radioItem\"], RadioItemProps>\n\nexport interface RadioItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean | undefined\n}\n\nconst RadioItemIndicator = defineComponent({\n name: \"MenuRadioItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const group = inside(RADIO_GROUP, \"RadioGroup\")\n const value = inject(RADIO_ITEM)\n // In the page while chosen, and through its exit.\n const indicator = controller(\n () => group.indicator(value),\n () => ({})\n )\n const mounted = fromSignal(indicator.mounted)\n const Element = partComponent(\"MenuRadioItemIndicatorElement\", \"span\", () => indicator)\n return () => (mounted.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"radioItemIndicator\"], RadioItemIndicatorProps>\n\nexport type TriggerProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type ArrowProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport type SubmenuTriggerProps = PartComponentProps\nexport type ContextTriggerProps = PartComponentProps\nexport const Menu = {\n Root: root(\"MenuRoot\", \"menu\"),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"MenuTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Portal: portalComponent(\"MenuPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"MenuPositioner\",\n () => scope.use(),\n partComponent(\"MenuPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"MenuPopup\", \"div\", () => scope.use().popup),\n Arrow: partComponent<\"div\", State[\"arrow\"]>(\"MenuArrow\", \"div\", () => scope.use().arrow),\n Item,\n LinkItem,\n Group,\n GroupLabel,\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"MenuSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n CheckboxItem,\n CheckboxItemIndicator,\n RadioGroup,\n RadioItem,\n RadioItemIndicator,\n /** A menu that one of this menu's items opens. Its trigger is `Menu.SubmenuTrigger`. */\n SubmenuRoot: root(\"MenuSubmenuRoot\", \"submenu\"),\n SubmenuTrigger: partComponent<\"div\", State[\"submenuTrigger\"]>(\n \"MenuSubmenuTrigger\",\n \"div\",\n () => scope.use().trigger\n ),\n}\n\nexport const ContextMenu = {\n ...Menu,\n /** A menu for an area of the page, opened at the pointer. Its trigger is the area. */\n Root: root(\"ContextMenuRoot\", \"context\"),\n /** The area a secondary press, or a long press on a touch screen, opens the menu in. */\n Trigger: partComponent<\"div\", StatesOf<\"contextMenu\">[\"trigger\"]>(\n \"ContextMenuTrigger\",\n \"div\",\n () => scope.use().area\n ),\n}\n"],"mappings":";;;;;;;;AA2CA,MAAM,QAAQ,QAAoB,MAAM;AACxC,MAAM,QAAwC,OAAO,WAAW;AAChE,MAAM,WAA2C,OAAO,kBAAkB;AAC1E,MAAM,cAA4C,OAAO,gBAAgB;AACzE,MAAM,aAAoC,OAAO,eAAe;AAChE,MAAM,MAAM;AAEZ,SAAS,OAAU,KAAsB,QAAmB;CAC1D,MAAM,QAAQ,OAAO,KAAK,KAAA,CAAS;CACnC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,oCAAoC,OAAO,EAAE;CACzE,OAAO;AACT;;AAUA,SAAS,KAAK,MAAc,MAAsC;CAChE,OAAO,gBAAgB;EACrB;EACA,OAAO;GACL,MAAM,SAAS,OAAO;GACtB,aAAa;GACb,UAAU;GACV,WAAW,SAAS,OAAO;;;;;GAK3B,MAAM,SAAS,OAAO;GACtB,OAAO;GACP,IAAI;EACN;EACA,OAAO,CAAC,eAAe,YAAY;EACnC,MAAM,OAAO,EAAE,OAAO,QAAQ;GAC5B,MAAM,YAAY,MAAM;GAIxB,MAAM,SAAS;IAAE,QAHF,SAAS,YAAY,MAAM,IAAI,IAAI,KAAA;IAGzB,WAFP,mBAEe;IAAG,SADpB,SAAS,SAAU,OAAO,SAAS,IAAI,KAAK,KAAA,IAAa,KAAA;IAC5B,SAAS,SAAS;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"Menubar",
11
11
  inheritAttrs: false,
12
12
  props: {
13
+ loopFocus: optional(Boolean),
14
+ /**
15
+ * Whether the arrows wrap from the last item to the first.
16
+ * @deprecated Base UI's name is `loopFocus`, which wins when both are given.
17
+ */
13
18
  loop: optional(Boolean),
14
19
  disabled: Boolean,
15
20
  orientation: String,
21
+ /** Holds the page while one of its menus is open. Default `false`. */
22
+ modal: Boolean,
16
23
  id: String
17
24
  },
18
25
  setup(props, { attrs, slots }) {
@@ -21,8 +28,10 @@ const Menubar = defineComponent({
21
28
  const made = controller(within(createMenubar, { direction }), () => ({
22
29
  id: props.id ?? generated,
23
30
  loop: props.loop,
31
+ loopFocus: props.loopFocus,
24
32
  disabled: props.disabled,
25
- orientation: props.orientation
33
+ orientation: props.orientation,
34
+ modal: props.modal
26
35
  }));
27
36
  provide(MENUBAR, made);
28
37
  const Element = partComponent("MenubarElement", "div", () => made.root);
@@ -1 +1 @@
1
- {"version":3,"file":"menubar.js","names":[],"sources":["../../../../packages/vue/src/menubar.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createMenubar } from \"@kirana-ui/core/menubar\"\nimport type { MenubarProps as CoreProps } from \"@kirana-ui/core/menubar\"\nimport type { Orientation } from \"@kirana-ui/core\"\nimport { defineComponent, h, provide, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { MENUBAR } from \"./menubar-context.ts\"\nimport { controller, optional, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\nexport type MenubarProps = Omit<CoreProps, \"id\"> & { id?: string | undefined } & PartComponentProps\n\n/** A row of menus that work as one. Each `Menu.Root` inside it is one of its items. */\nexport const Menubar = defineComponent({\n name: \"Menubar\",\n inheritAttrs: false,\n props: {\n loop: optional(Boolean),\n disabled: Boolean,\n orientation: String as PropType<Orientation>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const direction = useDirectionAround()\n const made = controller(within(createMenubar, { direction }), () => ({\n id: props.id ?? generated,\n loop: props.loop,\n disabled: props.disabled,\n orientation: props.orientation,\n }))\n provide(MENUBAR, made)\n const Element = partComponent(\"MenubarElement\", \"div\", () => made.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", StatesOf<\"menubar\">[\"root\"], MenubarProps>\n"],"mappings":";;;;;;;;AAeA,MAAa,UAAU,gBAAgB;CACrC,MAAM;CACN,cAAc;CACd,OAAO;EACL,MAAM,SAAS,OAAO;EACtB,UAAU;EACV,aAAa;EACb,IAAI;CACN;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,OAAO,WAAW,OAAO,eAAe,EAAE,UAAU,CAAC,UAAU;GACnE,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,aAAa,MAAM;EACrB,EAAE;EACF,QAAQ,SAAS,IAAI;EACrB,MAAM,UAAU,cAAc,kBAAkB,aAAa,KAAK,IAAI;EACtE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC"}
1
+ {"version":3,"file":"menubar.js","names":[],"sources":["../../../../packages/vue/src/menubar.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createMenubar } from \"@kirana-ui/core/menubar\"\nimport type { MenubarProps as CoreProps } from \"@kirana-ui/core/menubar\"\nimport type { Orientation } from \"@kirana-ui/core\"\nimport { defineComponent, h, provide, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { MENUBAR } from \"./menubar-context.ts\"\nimport { controller, optional, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\nexport type MenubarProps = Omit<CoreProps, \"id\"> & { id?: string | undefined } & PartComponentProps\n\n/** A row of menus that work as one. Each `Menu.Root` inside it is one of its items. */\nexport const Menubar = defineComponent({\n name: \"Menubar\",\n inheritAttrs: false,\n props: {\n loopFocus: optional(Boolean),\n /**\n * Whether the arrows wrap from the last item to the first.\n * @deprecated Base UI's name is `loopFocus`, which wins when both are given.\n */\n loop: optional(Boolean),\n disabled: Boolean,\n orientation: String as PropType<Orientation>,\n /** Holds the page while one of its menus is open. Default `false`. */\n modal: Boolean,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const direction = useDirectionAround()\n const made = controller(within(createMenubar, { direction }), () => ({\n id: props.id ?? generated,\n loop: props.loop,\n loopFocus: props.loopFocus,\n disabled: props.disabled,\n orientation: props.orientation,\n modal: props.modal,\n }))\n provide(MENUBAR, made)\n const Element = partComponent(\"MenubarElement\", \"div\", () => made.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", StatesOf<\"menubar\">[\"root\"], MenubarProps>\n"],"mappings":";;;;;;;;AAeA,MAAa,UAAU,gBAAgB;CACrC,MAAM;CACN,cAAc;CACd,OAAO;EACL,WAAW,SAAS,OAAO;;;;;EAK3B,MAAM,SAAS,OAAO;EACtB,UAAU;EACV,aAAa;;EAEb,OAAO;EACP,IAAI;CACN;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,OAAO,WAAW,OAAO,eAAe,EAAE,UAAU,CAAC,UAAU;GACnE,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,UAAU,MAAM;GAChB,aAAa,MAAM;GACnB,OAAO,MAAM;EACf,EAAE;EACF,QAAQ,SAAS,IAAI;EACrB,MAAM,UAAU,cAAc,kBAAkB,aAAa,KAAK,IAAI;EACtE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC"}
@@ -18,7 +18,10 @@ export interface ItemProps extends PartComponentProps {
18
18
  export type ContentProps = PartComponentProps;
19
19
  export interface LinkProps extends NavigationMenuLinkOptions, PartComponentProps {}
20
20
  export type ListProps = PartComponentProps;
21
- export type TriggerProps = PartComponentProps;
21
+ export interface TriggerProps extends PartComponentProps {
22
+ /** The trigger cannot be pressed, and the pointer resting on it shows nothing. */
23
+ disabled?: boolean | undefined;
24
+ }
22
25
  export type IconProps = PartComponentProps;
23
26
  export type PopupProps = PartComponentProps;
24
27
  export type ViewportProps = PartComponentProps;
@@ -30,11 +33,14 @@ export declare const NavigationMenu: {
30
33
  }>;
31
34
  List: PartComponent<"ul", {
32
35
  readonly orientation?: "horizontal" | "vertical" | undefined;
36
+ readonly open?: true | undefined;
33
37
  }, PartComponentProps, {}, unknown>;
34
38
  Item: PartComponent<"li", Record<never, never>, ItemProps>;
35
39
  Trigger: PartComponent<"button", {
36
40
  readonly popupOpen?: true | undefined;
37
- }, PartComponentProps, {}, unknown>;
41
+ readonly pressed?: true | undefined;
42
+ readonly disabled?: true | undefined;
43
+ }, TriggerProps>;
38
44
  Icon: PartComponent<"span", {
39
45
  readonly popupOpen?: true | undefined;
40
46
  }, PartComponentProps, {}, unknown>;
@@ -43,7 +49,7 @@ export declare const NavigationMenu: {
43
49
  readonly closed?: true | undefined;
44
50
  readonly startingStyle?: true | undefined;
45
51
  readonly endingStyle?: true | undefined;
46
- readonly activationDirection?: "left" | "right" | undefined;
52
+ readonly activationDirection?: "down" | "left" | "right" | "up" | undefined;
47
53
  }, PartComponentProps>;
48
54
  Link: PartComponent<"a", {
49
55
  readonly active?: true | undefined;
@@ -54,6 +60,8 @@ export declare const NavigationMenu: {
54
60
  readonly closed?: true | undefined;
55
61
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
56
62
  readonly align?: "center" | "end" | "start" | undefined;
63
+ readonly anchorHidden?: true | undefined;
64
+ readonly instant?: true | undefined;
57
65
  }, PositionerProps>;
58
66
  Popup: PartComponent<"div", {
59
67
  readonly open?: true | undefined;
@@ -62,9 +70,12 @@ export declare const NavigationMenu: {
62
70
  readonly endingStyle?: true | undefined;
63
71
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
64
72
  readonly align?: "center" | "end" | "start" | undefined;
73
+ readonly anchorHidden?: true | undefined;
65
74
  }, PartComponentProps, {}, unknown>;
66
75
  Viewport: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
67
76
  Arrow: PartComponent<"div", {
77
+ readonly open?: true | undefined;
78
+ readonly closed?: true | undefined;
68
79
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
69
80
  readonly align?: "center" | "end" | "start" | undefined;
70
81
  readonly uncentered?: true | undefined;