@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirana-ui/vue",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Kirana UI Primitives for Vue",
5
5
  "license": "MIT",
6
6
  "author": "The Kirana authors",
@@ -47,6 +47,10 @@
47
47
  "types": "./src/checkbox.d.ts",
48
48
  "default": "./src/checkbox.js"
49
49
  },
50
+ "./checkbox-group": {
51
+ "types": "./src/checkbox-group.d.ts",
52
+ "default": "./src/checkbox-group.js"
53
+ },
50
54
  "./collapsible": {
51
55
  "types": "./src/collapsible.d.ts",
52
56
  "default": "./src/collapsible.js"
@@ -135,6 +139,46 @@
135
139
  "types": "./src/pagination.d.ts",
136
140
  "default": "./src/pagination.js"
137
141
  },
142
+ "./rating": {
143
+ "types": "./src/rating.d.ts",
144
+ "default": "./src/rating.js"
145
+ },
146
+ "./steps": {
147
+ "types": "./src/steps.d.ts",
148
+ "default": "./src/steps.js"
149
+ },
150
+ "./editable": {
151
+ "types": "./src/editable.d.ts",
152
+ "default": "./src/editable.js"
153
+ },
154
+ "./password-input": {
155
+ "types": "./src/password-input.d.ts",
156
+ "default": "./src/password-input.js"
157
+ },
158
+ "./tags-input": {
159
+ "types": "./src/tags-input.d.ts",
160
+ "default": "./src/tags-input.js"
161
+ },
162
+ "./file-upload": {
163
+ "types": "./src/file-upload.d.ts",
164
+ "default": "./src/file-upload.js"
165
+ },
166
+ "./time-field": {
167
+ "types": "./src/time-field.d.ts",
168
+ "default": "./src/time-field.js"
169
+ },
170
+ "./tree": {
171
+ "types": "./src/tree.d.ts",
172
+ "default": "./src/tree.js"
173
+ },
174
+ "./color-picker": {
175
+ "types": "./src/color-picker.d.ts",
176
+ "default": "./src/color-picker.js"
177
+ },
178
+ "./tour": {
179
+ "types": "./src/tour.d.ts",
180
+ "default": "./src/tour.js"
181
+ },
138
182
  "./date-picker": {
139
183
  "types": "./src/date-picker.d.ts",
140
184
  "default": "./src/date-picker.js"
@@ -226,7 +270,7 @@
226
270
  "./package.json": "./package.json"
227
271
  },
228
272
  "dependencies": {
229
- "@kirana-ui/core": "0.2.0"
273
+ "@kirana-ui/core": "0.4.0"
230
274
  },
231
275
  "peerDependencies": {
232
276
  "vue": "^3.5.0"
@@ -249,6 +293,7 @@
249
293
  "REFERENCE.md",
250
294
  "llms.txt",
251
295
  "skills",
252
- "LICENSE"
296
+ "LICENSE",
297
+ "CHANGELOG.md"
253
298
  ]
254
299
  }
@@ -33,10 +33,16 @@ from one core. The package for a framework is all a project installs.
33
33
  A popup that is placed against its trigger (a popover, a menu, a select, a combobox, a
34
34
  tooltip, a hover card) is `Portal > Positioner > Popup`: the `Positioner` takes `side`
35
35
  (also `inline-start` and `inline-end`, which turn with the reading direction, and which
36
- `data-side` then says), `align`, `sideOffset`, `alignOffset`, `collisionPadding`, and
36
+ `data-side` then says), `align`, `sideOffset` and `alignOffset` (a number, or a function
37
+ of the anchor's and the positioner's sizes), `collisionPadding` (a number, or one a side),
38
+ `collisionBoundary`, `collisionAvoidance`, `sticky`, `arrowPadding`, `positionMethod`, and
37
39
  `anchor` for another element than its trigger to be placed against (an element, the
38
- framework's own ref to one, or a function that gives one). A dialog, an alert dialog and a
39
- drawer have no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
40
+ framework's own ref to one, or a function that gives one). A popup that holds an `Arrow`
41
+ is given `position: relative`, so the arrow is placed in it through its entrance and
42
+ after. A popover may have a `Backdrop` in its portal, is `modal` (`true`: the page is
43
+ inert and does not scroll; `"trap-focus"`: only Tab is kept inside), and its trigger's
44
+ `openOnHover` lets the pointer open it too. A dialog, an alert dialog and a drawer have
45
+ no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
40
46
  3. Style by attributes and variables, never by guessing class names:
41
47
  - a boolean state is present or absent: `[data-open]`, never `[data-open="true"]`;
42
48
  - an entrance starts from `[data-starting-style]`, an exit ends at
@@ -46,17 +52,19 @@ from one core. The package for a framework is all a project installs.
46
52
  4. A value is controlled when given (`value` + `onValueChange`) and the component's own
47
53
  otherwise (`defaultValue`). A callback beside a value the component holds is
48
54
  `(value, details)`, and `details.cancel()` keeps the value as it was. A callback that
49
- reports something that happened (`onComplete`, `onClearErrors`, `onMonthChange`) takes only
50
- that.
55
+ reports something that happened (`onClearErrors`, `onMonthChange`) takes only that. The
56
+ names are Base UI's: `loopFocus`, `disablePointerDismissal`, a multiple Select's or
57
+ Combobox's list in `value`, One-Time Code's `validationType` and `onValueComplete`, a
58
+ toast's `timeout`; the older names still work and are marked deprecated.
51
59
  5. A control with a `name` is submitted with its form and follows the form's reset. Wrap it
52
60
  in `Field` for a label, a description and validation. `readOnly` and `keepMounted` are
53
61
  props of the parts `llms.txt` lists them for, and of no others.
54
62
 
55
63
  Per framework: React takes `render` for another element; Vue takes `as` / `as-child`, binds
56
64
  with `v-model:value` and names props in kebab case; Svelte takes a `child` snippet and
57
- `bind:value`; Solid takes `as` and `render`; Angular's parts are directives on your own
58
- elements (`<button kuiDialogTrigger>`), bound with `[(value)]`, with `[kuiId]` for an id, and
59
- a part that comes and goes is structural (`*kuiDialogPortal`, `*kuiTabsPanel`: the list is in
65
+ `bind:value`; Solid (2, with `@solidjs/web`) takes `as` and `render`; Angular's parts are directives on your own
66
+ elements (`<button kpDialogTrigger>`), bound with `[(value)]`, with `[kpId]` for an id, and
67
+ a part that comes and goes is structural (`*kpDialogPortal`, `*kpTabsPanel`: the list is in
60
68
  `llms.txt`); custom elements name each part with `kui-part` inside `<kui-dialog>`.
61
69
 
62
70
  Composing a part with another element: with React's `render={<a … />}` and Vue's `as-child`
@@ -72,9 +80,24 @@ the text a part writes (`Meter.Value`, `Select.Value`) stay inside it on React a
72
80
  `props().children` on Solid, and are given to a Svelte `child` snippet to render
73
81
  (`{ props, state, input }`, `{ props, state, text }`). A handler given to a part is typed
74
82
  with `preventKiranaHandler()` (`PartEvent`, exported by each package). For an element of the
75
- design system's own that takes `render` or `as-child`, use `useRender` and `mergeProps` from
76
- `@kirana-ui/react/use-render`, or `Primitive` from `@kirana-ui/vue/primitive`; never write
77
- another merge.
83
+ design system's own composed as a part is, use `useRender` and `mergeProps` from
84
+ `@kirana-ui/react/use-render`, `Primitive` from `@kirana-ui/vue/primitive`, or `Primitive`
85
+ and `mergeProps` from `@kirana-ui/solid/primitive` and `@kirana-ui/svelte/primitive` (Solid's
86
+ `as` and `render`, Svelte's `as` and `child`, a `state` written as `data-*`); never write
87
+ another merge. On Angular such an element is a directive of your own with host bindings, and
88
+ custom elements need nothing: the page writes its own element.
89
+
90
+ A design system on Angular hosts each primitive in a directive of its own
91
+ (`hostDirectives: [{ directive: KpDialog, inputs: [...], outputs: [...] }]`), exposing what
92
+ its callers set; gives the primitive the rest with `hostInputs(KpTooltip, { delay: () => 0 })`
93
+ in its constructor (each value a function read like a signal, so `computed` values follow;
94
+ an input the element binds wins), never a subclass of the primitive; draws a structural part
95
+ (`kpDialogPortal`) in a component's template around `<ng-content />` (a part given to it finds
96
+ its root where it is written); and names its own directives as it likes, `kui…` included:
97
+ the primitives are `kp…` so that no design system's selector is theirs (two directives with
98
+ one selector both match, silently, and a component whose selector is its host's recurses).
99
+ Tooltips need no provider on any
100
+ framework: a design system passes `delay` on its own tooltip root (`hostInputs` on Angular).
78
101
 
79
102
  ## When something is wrong
80
103
 
@@ -115,7 +138,25 @@ component's ref, kind, label, state and actions), `act({ steps: [{ ref, action,
115
138
  through the component's own handlers: its callback runs with `details.source === "agent"`
116
139
  and may cancel. Give every control an accessible name (a `<label>`, `aria-label`): it is how
117
140
  an agent finds it. Mark a destructive control `data-agent-confirm="what it does"`, private
118
- regions `data-agent-hidden`, secrets `data-agent-secret`. `allow(action)` is the policy,
141
+ regions `data-agent-hidden`, secrets `data-agent-secret` (whatever is inside is listed with its
142
+ name and its actions, never its value, its choices or whether it is checked). A bridge given a
143
+ `root` also reads what was opened from inside it (a dialog, a menu, a select's list), by the
144
+ `aria-controls` of what opened it. A step names its control by ref, by its label, by words of
145
+ the label, by the text of its row or by one of its choices; a name two controls answer to
146
+ fails with both. `subscribe((changed, changes) => …)` says of each change its `key`, `value`,
147
+ `previous`, `source` and `reason`; `record()` keeps a person's changes in `history()` beside
148
+ the agent's, each with its `source` and a sentence (`text`), and `undoSource("agent")` takes
149
+ back only the agent's. `stage({ steps })` shows a suggestion in the controls and gives
150
+ `revert()` and `keep()`. `act` takes a `signal`; `timeout` bounds a wait for `allow` or
151
+ `confirm`. A component of your own is read through `kinds` (`AgentKind`: a selector, `read`,
152
+ `perform`). A slider's `setValue` fails with what the slider holds when
153
+ its range or step does not hold the value asked for, and so does a spin button's (a Date or
154
+ Time Field's part, typed as a person types it). The thumbs of a range named by their group
155
+ are told apart by their place (`"Price, 1 of 2"`). A list of several values (a listbox, a
156
+ select with `multiple`, a tree) says `values` and takes a list in `setValue`; a closed
157
+ select's are known once its list has been read. A tree is one component: its shown nodes
158
+ are its `items` (with `level` below the top and `open` for a branch), and `setValue`,
159
+ `open` and `close` take a node's name. `allow(action)` is the policy,
119
160
  asked for every step; `confirm(action)` is a person's answer, asked for a step on something
120
161
  marked `data-agent-confirm`, and without it such a step fails with "Needs a person" whatever
121
162
  `allow` says. Never write `confirm: () => true`: open a dialog and resolve with what the
@@ -21,14 +21,17 @@ export declare const Accordion: {
21
21
  state: State["root"];
22
22
  }>;
23
23
  Item: PartComponent<"div", {
24
+ readonly index?: true | undefined;
24
25
  readonly open?: true | undefined;
25
26
  readonly disabled?: true | undefined;
26
27
  }, ItemProps>;
27
28
  Header: PartComponent<"h3", {
29
+ readonly index?: true | undefined;
28
30
  readonly open?: true | undefined;
29
31
  readonly disabled?: true | undefined;
30
32
  }, PartComponentProps, {}, unknown>;
31
33
  Trigger: PartComponent<"button", {
34
+ readonly index?: true | undefined;
32
35
  readonly panelOpen?: true | undefined;
33
36
  readonly disabled?: true | undefined;
34
37
  }, PartComponentProps, {}, unknown>;
@@ -39,6 +42,7 @@ export declare const Accordion: {
39
42
  readonly endingStyle?: true | undefined;
40
43
  readonly disabled?: true | undefined;
41
44
  readonly orientation?: "horizontal" | "vertical" | undefined;
45
+ readonly index?: true | undefined;
42
46
  }, PanelProps>;
43
47
  };
44
48
  export {};
package/src/accordion.js CHANGED
@@ -23,6 +23,11 @@ const Root = defineComponent({
23
23
  multiple: Boolean,
24
24
  disabled: Boolean,
25
25
  orientation: String,
26
+ loopFocus: optional(Boolean),
27
+ /**
28
+ * Whether the arrows wrap from the last item to the first.
29
+ * @deprecated Base UI's name is `loopFocus`, which wins when both are given.
30
+ */
26
31
  loop: optional(Boolean),
27
32
  id: String
28
33
  },
@@ -38,6 +43,7 @@ const Root = defineComponent({
38
43
  disabled: props.disabled,
39
44
  orientation: props.orientation,
40
45
  loop: props.loop,
46
+ loopFocus: props.loopFocus,
41
47
  onValueChange(value, details) {
42
48
  emit("valueChange", value, details);
43
49
  if (!details.canceled) emit("update:value", value);
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/vue/src/accordion.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type {\n AccordionItem,\n AccordionItemOptions,\n AccordionProps,\n Accordion as Controller,\n} from \"@kirana-ui/core/accordion\"\nimport { defineComponent, h, inject, onBeforeUnmount, onMounted, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"accordion\">\n\nconst scope = context<Controller>(\"Accordion\")\nconst ITEM: InjectionKey<AccordionItem> = Symbol(\"AccordionItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nfunction useItem(): AccordionItem {\n const item = inject(ITEM, undefined)\n if (!item) throw new Error(\"An Accordion part must be inside <Accordion.Item>\")\n return item\n}\n\nconst RootElement = partComponent(\"AccordionRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps<Value = unknown> = Omit<AccordionProps<Value>, \"id\" | \"onValueChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value[]>\n\n/** `v-model:value` (a list), or `value` with `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"AccordionRoot\",\n inheritAttrs: false,\n props: {\n value: optional(Array as PropType<readonly unknown[]>),\n defaultValue: Array as PropType<readonly unknown[]>,\n multiple: Boolean,\n disabled: Boolean,\n orientation: String as PropType<Orientation>,\n loop: optional(Boolean),\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createAccordion, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n multiple: props.multiple,\n disabled: props.disabled,\n orientation: props.orientation,\n loop: props.loop,\n onValueChange(value: unknown[], details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as new <Value = unknown, As extends string = \"div\">(\n props: PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps\n) => PartInstance<As, RootProps<Value>, RootEmits<Value>, { state: State[\"root\"] }>\n\nexport interface ItemProps extends AccordionItemOptions, PartComponentProps {\n /** What tells this item from the others; an item that is given none makes its own. */\n value?: unknown\n}\n\n/** `value` tells this item from the others; an item that is given none makes its own. */\nconst Item = defineComponent({\n name: \"AccordionItem\",\n inheritAttrs: false,\n props: { value: { type: ANY, default: undefined as unknown }, disabled: optional(Boolean) },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const generated = useId()\n // An item is its value for as long as it is in the page.\n const item = scope\n .use()\n .item(props.value === undefined ? generated : props.value, () => defined(options.get()))\n provide(ITEM, item)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = item.mount()\n })\n onBeforeUnmount(() => stop?.())\n const Element = partComponent(\"AccordionItemElement\", \"div\", () => item.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nconst PanelElement = partComponent(\"AccordionPanelElement\", \"div\", () => useItem().panel)\n\nexport interface PanelProps extends PartComponentProps {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the closed panel in the page, `hidden`. */\nconst Panel = defineComponent({\n name: \"AccordionPanel\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const mounted = fromSignal(useItem().mounted)\n return () => (mounted.value || props.keepMounted ? h(PanelElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"panel\"], PanelProps>\n\nexport type HeaderProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport const Accordion = {\n Root,\n Item,\n Header: partComponent<\"h3\", State[\"header\"]>(\"AccordionHeader\", \"h3\", () => useItem().header),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"AccordionTrigger\",\n \"button\",\n () => useItem().trigger\n ),\n Panel,\n}\n"],"mappings":";;;;;;AAyBA,MAAM,QAAQ,QAAoB,WAAW;AAC7C,MAAM,OAAoC,OAAO,eAAe;AAChE,MAAM,MAAM;AAEZ,SAAS,UAAyB;CAChC,MAAM,OAAO,OAAO,MAAM,KAAA,CAAS;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,mDAAmD;CAC9E,OAAO;AACT;AAEA,MAAM,cAAc,cAAc,wBAAwB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AASvF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS,KAAqC;EACrD,cAAc;EACd,UAAU;EACV,UAAU;EACV,aAAa;EACb,MAAM,SAAS,OAAO;EACtB,IAAI;CACN;CACA,OAAO,CAAC,gBAAgB,aAAa;CACrC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,QACJ,WAAW,OAAO,iBAAiB,EAAE,UAAU,CAAC,UAAU;GACxD,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,aAAa,MAAM;GACnB,MAAM,MAAM;GACZ,cAAc,OAAkB,SAAwB;IACtD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;EACF,EAAE,CACJ;EACA,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;;AAUD,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EAAE,OAAO;GAAE,MAAM;GAAK,SAAS,KAAA;EAAqB;EAAG,UAAU,SAAS,OAAO;CAAE;CAC1F,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;EAC7D,MAAM,YAAY,MAAM;EAExB,MAAM,OAAO,MACV,IAAI,CAAC,CACL,KAAK,MAAM,UAAU,KAAA,IAAY,YAAY,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC;EACzF,QAAQ,MAAM,IAAI;EAClB,IAAI;EACJ,gBAAgB;GACd,OAAO,KAAK,MAAM;EACpB,CAAC;EACD,sBAAsB,OAAO,CAAC;EAC9B,MAAM,UAAU,cAAc,wBAAwB,aAAa,KAAK,IAAI;EAC5E,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;AAED,MAAM,eAAe,cAAc,yBAAyB,aAAa,QAAQ,CAAC,CAAC,KAAK;;AAQxF,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,aAAa,QAAQ;CAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,UAAU,WAAW,QAAQ,CAAC,CAAC,OAAO;EAC5C,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,cAAc,OAAO,KAAK,IAAI;CACrF;AACF,CAAC;AAID,MAAa,YAAY;CACvB;CACA;CACA,QAAQ,cAAqC,mBAAmB,YAAY,QAAQ,CAAC,CAAC,MAAM;CAC5F,SAAS,cACP,oBACA,gBACM,QAAQ,CAAC,CAAC,OAClB;CACA;AACF"}
1
+ {"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/vue/src/accordion.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type {\n AccordionItem,\n AccordionItemOptions,\n AccordionProps,\n Accordion as Controller,\n} from \"@kirana-ui/core/accordion\"\nimport { defineComponent, h, inject, onBeforeUnmount, onMounted, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"accordion\">\n\nconst scope = context<Controller>(\"Accordion\")\nconst ITEM: InjectionKey<AccordionItem> = Symbol(\"AccordionItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nfunction useItem(): AccordionItem {\n const item = inject(ITEM, undefined)\n if (!item) throw new Error(\"An Accordion part must be inside <Accordion.Item>\")\n return item\n}\n\nconst RootElement = partComponent(\"AccordionRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps<Value = unknown> = Omit<AccordionProps<Value>, \"id\" | \"onValueChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value[]>\n\n/** `v-model:value` (a list), or `value` with `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"AccordionRoot\",\n inheritAttrs: false,\n props: {\n value: optional(Array as PropType<readonly unknown[]>),\n defaultValue: Array as PropType<readonly unknown[]>,\n multiple: Boolean,\n disabled: Boolean,\n orientation: String as PropType<Orientation>,\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 id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createAccordion, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n multiple: props.multiple,\n disabled: props.disabled,\n orientation: props.orientation,\n loop: props.loop,\n loopFocus: props.loopFocus,\n onValueChange(value: unknown[], details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as new <Value = unknown, As extends string = \"div\">(\n props: PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps\n) => PartInstance<As, RootProps<Value>, RootEmits<Value>, { state: State[\"root\"] }>\n\nexport interface ItemProps extends AccordionItemOptions, PartComponentProps {\n /** What tells this item from the others; an item that is given none makes its own. */\n value?: unknown\n}\n\n/** `value` tells this item from the others; an item that is given none makes its own. */\nconst Item = defineComponent({\n name: \"AccordionItem\",\n inheritAttrs: false,\n props: { value: { type: ANY, default: undefined as unknown }, disabled: optional(Boolean) },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const generated = useId()\n // An item is its value for as long as it is in the page.\n const item = scope\n .use()\n .item(props.value === undefined ? generated : props.value, () => defined(options.get()))\n provide(ITEM, item)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = item.mount()\n })\n onBeforeUnmount(() => stop?.())\n const Element = partComponent(\"AccordionItemElement\", \"div\", () => item.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nconst PanelElement = partComponent(\"AccordionPanelElement\", \"div\", () => useItem().panel)\n\nexport interface PanelProps extends PartComponentProps {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the closed panel in the page, `hidden`. */\nconst Panel = defineComponent({\n name: \"AccordionPanel\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const mounted = fromSignal(useItem().mounted)\n return () => (mounted.value || props.keepMounted ? h(PanelElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"panel\"], PanelProps>\n\nexport type HeaderProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport const Accordion = {\n Root,\n Item,\n Header: partComponent<\"h3\", State[\"header\"]>(\"AccordionHeader\", \"h3\", () => useItem().header),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"AccordionTrigger\",\n \"button\",\n () => useItem().trigger\n ),\n Panel,\n}\n"],"mappings":";;;;;;AAyBA,MAAM,QAAQ,QAAoB,WAAW;AAC7C,MAAM,OAAoC,OAAO,eAAe;AAChE,MAAM,MAAM;AAEZ,SAAS,UAAyB;CAChC,MAAM,OAAO,OAAO,MAAM,KAAA,CAAS;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,mDAAmD;CAC9E,OAAO;AACT;AAEA,MAAM,cAAc,cAAc,wBAAwB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AASvF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS,KAAqC;EACrD,cAAc;EACd,UAAU;EACV,UAAU;EACV,aAAa;EACb,WAAW,SAAS,OAAO;;;;;EAK3B,MAAM,SAAS,OAAO;EACtB,IAAI;CACN;CACA,OAAO,CAAC,gBAAgB,aAAa;CACrC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,QACJ,WAAW,OAAO,iBAAiB,EAAE,UAAU,CAAC,UAAU;GACxD,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,aAAa,MAAM;GACnB,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,cAAc,OAAkB,SAAwB;IACtD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;EACF,EAAE,CACJ;EACA,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;;AAUD,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EAAE,OAAO;GAAE,MAAM;GAAK,SAAS,KAAA;EAAqB;EAAG,UAAU,SAAS,OAAO;CAAE;CAC1F,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;EAC7D,MAAM,YAAY,MAAM;EAExB,MAAM,OAAO,MACV,IAAI,CAAC,CACL,KAAK,MAAM,UAAU,KAAA,IAAY,YAAY,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC;EACzF,QAAQ,MAAM,IAAI;EAClB,IAAI;EACJ,gBAAgB;GACd,OAAO,KAAK,MAAM;EACpB,CAAC;EACD,sBAAsB,OAAO,CAAC;EAC9B,MAAM,UAAU,cAAc,wBAAwB,aAAa,KAAK,IAAI;EAC5E,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;AAED,MAAM,eAAe,cAAc,yBAAyB,aAAa,QAAQ,CAAC,CAAC,KAAK;;AAQxF,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,aAAa,QAAQ;CAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,UAAU,WAAW,QAAQ,CAAC,CAAC,OAAO;EAC5C,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,cAAc,OAAO,KAAK,IAAI;CACrF;AACF,CAAC;AAID,MAAa,YAAY;CACvB;CACA;CACA,QAAQ,cAAqC,mBAAmB,YAAY,QAAQ,CAAC,CAAC,MAAM;CAC5F,SAAS,cACP,oBACA,gBACM,QAAQ,CAAC,CAAC,OAClB;CACA;AACF"}
@@ -1,3 +1,3 @@
1
1
  import { PortalProps } from "./runtime.js";
2
- import { AlertDialog, AlertRootProps, BackdropProps, CloseProps, DescriptionProps, Dialog, Drawer, DrawerRootEmits, DrawerRootProps, PopupProps, RootEmits, TitleProps, TriggerProps } from "./dialog.js";
3
- export { AlertDialog, type AlertRootProps, type BackdropProps, type CloseProps, type DescriptionProps, type Dialog, type Drawer, type DrawerRootEmits, type DrawerRootProps, type PopupProps, type PortalProps, type RootEmits, type AlertRootProps as RootProps, type TitleProps, type TriggerProps };
2
+ import { AlertDialog, AlertRootProps, BackdropProps, CloseProps, DescriptionProps, Dialog, Drawer, DrawerRootEmits, DrawerRootProps, PopupProps, RootEmits, TitleProps, TriggerProps, ViewportProps } from "./dialog.js";
3
+ export { AlertDialog, type AlertRootProps, type BackdropProps, type CloseProps, type DescriptionProps, type Dialog, type Drawer, type DrawerRootEmits, type DrawerRootProps, type PopupProps, type PortalProps, type RootEmits, type AlertRootProps as RootProps, type TitleProps, type TriggerProps, type ViewportProps };
@@ -1,4 +1,4 @@
1
1
  import { PortalProps } from "./runtime.js";
2
2
  import { PositionerProps } from "./popover.js";
3
- import { Autocomplete, AutocompleteRootEmits, AutocompleteRootProps, ChipProps, ChipRemoveProps, ChipsProps, ClearProps, Combobox, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemIndicatorProps, ItemProps, ListProps, PopupProps, SeparatorProps, TriggerProps } from "./combobox.js";
4
- export { Autocomplete, type AutocompleteRootEmits, type AutocompleteRootProps, type ChipProps, type ChipRemoveProps, type ChipsProps, type ClearProps, type Combobox, type EmptyProps, type GroupLabelProps, type GroupProps, type InputProps, type ItemIndicatorProps, type ItemProps, type ListProps, type PopupProps, type PortalProps, type PositionerProps, type AutocompleteRootEmits as RootEmits, type AutocompleteRootProps as RootProps, type SeparatorProps, type TriggerProps };
3
+ import { Autocomplete, AutocompleteRootEmits, AutocompleteRootProps, BackdropProps, ChipProps, ChipRemoveProps, ChipsProps, ClearProps, CollectionProps, Combobox, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemIndicatorProps, ItemProps, ListProps, PopupProps, SeparatorProps, StatusProps, TriggerProps, ValueProps } from "./combobox.js";
4
+ export { Autocomplete, type AutocompleteRootEmits, type AutocompleteRootProps, type BackdropProps, type ChipProps, type ChipRemoveProps, type ChipsProps, type ClearProps, type CollectionProps, type Combobox, type EmptyProps, type GroupLabelProps, type GroupProps, type InputProps, type ItemIndicatorProps, type ItemProps, type ListProps, type PopupProps, type PortalProps, type PositionerProps, type AutocompleteRootEmits as RootEmits, type AutocompleteRootProps as RootProps, type SeparatorProps, type StatusProps, type TriggerProps, type ValueProps };
package/src/avatar.d.ts CHANGED
@@ -1,13 +1,40 @@
1
1
  import { PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { ImageStatus } from "@kirana-ui/core/avatar";
2
3
  export type RootProps = PartComponentProps;
3
4
  export interface ImageProps extends PartComponentProps {
4
5
  /** The picture's address: the part is in the page once it has loaded. */
5
6
  src?: string | undefined;
7
+ /**
8
+ * Keeps the element in the page while the picture loads, as Base UI's: it loads the
9
+ * picture itself (`loading="lazy"` works), and until it has loaded it is `aria-hidden`,
10
+ * with `data-loading` or `data-error` for the design to hide or fade it by. Default:
11
+ * `false`, the element is drawn once the picture has loaded.
12
+ */
13
+ keepMounted?: boolean | undefined;
14
+ }
15
+ export type ImageEmits = {
16
+ /**
17
+ * `@loading-status-change`: each time the picture's loading status changes, `loading` once it
18
+ * has an address, then `loaded` or `error`; `idle` again when its address is taken away. The
19
+ * root says the same in `data-image-loading-status`.
20
+ */
21
+ loadingStatusChange: (status: ImageStatus) => void;
22
+ };
23
+ export interface FallbackProps extends PartComponentProps {
24
+ /**
25
+ * How long to wait before showing, in milliseconds, so a picture that loads sooner never
26
+ * lets the fallback be seen. Read once. Default: `0`, at once.
27
+ */
28
+ delay?: number | undefined;
6
29
  }
7
- export type FallbackProps = PartComponentProps;
8
30
  export declare const Avatar: {
9
- Root: PartComponent<"span", Record<never, never>, PartComponentProps>;
10
- Image: PartComponent<"img", Record<never, never>, ImageProps>;
11
- Fallback: PartComponent<"span", Record<never, never>, PartComponentProps>;
31
+ Root: PartComponent<"span", {
32
+ readonly imageLoadingStatus?: "error" | "idle" | "loaded" | "loading" | undefined;
33
+ }, PartComponentProps>;
34
+ Image: PartComponent<"img", {
35
+ readonly loading?: true | undefined;
36
+ readonly error?: true | undefined;
37
+ }, ImageProps, ImageEmits>;
38
+ Fallback: PartComponent<"span", Record<never, never>, FallbackProps>;
12
39
  };
13
40
  //# sourceMappingURL=avatar.d.ts.map
package/src/avatar.js CHANGED
@@ -1,37 +1,61 @@
1
1
  import { context, controller, fromSignal, partComponent } from "./runtime.js";
2
- import { defineComponent, h, watchEffect } from "vue";
2
+ import { defineComponent, h, onBeforeUnmount, onMounted, watchEffect } from "vue";
3
3
  import { createAvatar } from "@kirana-ui/core/avatar";
4
4
  // src/avatar.ts
5
5
  const scope = context("Avatar");
6
6
  const RootElement = partComponent("AvatarRootElement", "span", () => scope.use().root);
7
7
  const ImageElement = partComponent("AvatarImageElement", "img", () => scope.use().image);
8
+ const KeptImageElement = partComponent("AvatarKeptImageElement", "img", () => scope.use().keptImage);
8
9
  const FallbackElement = partComponent("AvatarFallbackElement", "span", () => scope.use().fallback);
10
+ const Root = defineComponent({
11
+ name: "AvatarRoot",
12
+ inheritAttrs: false,
13
+ setup(_props, { attrs, slots }) {
14
+ scope.provide(controller(createAvatar, () => ({})));
15
+ return () => h(RootElement, attrs, slots);
16
+ }
17
+ });
18
+ /** Runs something with a `mount()` for the component's life in the page. */
19
+ function whileMounted(made) {
20
+ let stop;
21
+ onMounted(() => {
22
+ stop = made.mount();
23
+ });
24
+ onBeforeUnmount(() => stop?.());
25
+ }
9
26
  const Avatar = {
10
- Root: defineComponent({
11
- name: "AvatarRoot",
12
- inheritAttrs: false,
13
- setup(_props, { attrs, slots }) {
14
- scope.provide(controller(createAvatar, () => ({})));
15
- return () => h(RootElement, attrs, slots);
16
- }
17
- }),
27
+ Root,
18
28
  Image: defineComponent({
19
29
  name: "AvatarImage",
20
30
  inheritAttrs: false,
21
- props: { src: String },
22
- setup(props, { attrs }) {
31
+ props: {
32
+ src: String,
33
+ keepMounted: Boolean
34
+ },
35
+ emits: ["loadingStatusChange"],
36
+ setup(props, { attrs, emit }) {
23
37
  const made = scope.use();
24
38
  watchEffect(() => made.source.set(props.src), { flush: "sync" });
25
- const status = fromSignal(made.status);
26
- return () => status.value === "loaded" ? h(ImageElement, attrs) : null;
39
+ whileMounted(made.statusReport(() => (status) => emit("loadingStatusChange", status)));
40
+ const mounted = fromSignal(made.imageMounted);
41
+ return () => props.keepMounted ? h(KeptImageElement, {
42
+ ...attrs,
43
+ src: props.src
44
+ }) : mounted.value ? h(ImageElement, attrs) : null;
27
45
  }
28
46
  }),
29
47
  Fallback: defineComponent({
30
48
  name: "AvatarFallback",
31
49
  inheritAttrs: false,
32
- setup(_props, { attrs, slots }) {
33
- const status = fromSignal(scope.use().status);
34
- return () => status.value === "loaded" ? null : h(FallbackElement, attrs, slots);
50
+ props: { delay: {
51
+ type: Number,
52
+ default: void 0
53
+ } },
54
+ setup(props, { attrs, slots }) {
55
+ const presence = scope.use().fallbackPresence({ delay: props.delay });
56
+ whileMounted(presence);
57
+ const shown = fromSignal(presence.shown);
58
+ return () => shown.value ? h(FallbackElement, attrs, slots) : null;
35
59
  }
36
60
  })
37
61
  };
package/src/avatar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/vue/src/avatar.ts"],"sourcesContent":["import { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type { Avatar as Controller } from \"@kirana-ui/core/avatar\"\nimport { defineComponent, h, watchEffect } from \"vue\"\n\nimport { context, controller, fromSignal, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"avatar\">\n\nconst scope = context<Controller>(\"Avatar\")\nconst RootElement = partComponent(\"AvatarRootElement\", \"span\", () => scope.use().root)\nconst ImageElement = partComponent(\"AvatarImageElement\", \"img\", () => scope.use().image)\nconst FallbackElement = partComponent(\"AvatarFallbackElement\", \"span\", () => scope.use().fallback)\n\nexport type RootProps = PartComponentProps\n\nconst Root = defineComponent({\n name: \"AvatarRoot\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n scope.provide(controller(createAvatar, () => ({})))\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"root\"], RootProps>\n\nexport interface ImageProps extends PartComponentProps {\n /** The picture's address: the part is in the page once it has loaded. */\n src?: string | undefined\n}\n\n/** The picture: in the page once `src` has loaded. */\nconst Image = defineComponent({\n name: \"AvatarImage\",\n inheritAttrs: false,\n props: { src: String },\n setup(props, { attrs }) {\n const made = scope.use()\n watchEffect(() => made.source.set(props.src), { flush: \"sync\" })\n const status = fromSignal(made.status)\n return () => (status.value === \"loaded\" ? h(ImageElement, attrs) : null)\n },\n}) as unknown as PartComponent<\"img\", State[\"image\"], ImageProps>\n\nexport type FallbackProps = PartComponentProps\n\n/** What shows until the picture has loaded, or when it cannot. */\nconst Fallback = defineComponent({\n name: \"AvatarFallback\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const status = fromSignal(scope.use().status)\n return () => (status.value === \"loaded\" ? null : h(FallbackElement, attrs, slots))\n },\n}) as unknown as PartComponent<\"span\", State[\"fallback\"], FallbackProps>\n\nexport const Avatar = { Root, Image, Fallback }\n"],"mappings":";;;;AASA,MAAM,QAAQ,QAAoB,QAAQ;AAC1C,MAAM,cAAc,cAAc,qBAAqB,cAAc,MAAM,IAAI,CAAC,CAAC,IAAI;AACrF,MAAM,eAAe,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;AACvF,MAAM,kBAAkB,cAAc,yBAAyB,cAAc,MAAM,IAAI,CAAC,CAAC,QAAQ;AA2CjG,MAAa,SAAS;CAAE,MAvCX,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,MAAM,QAAQ,EAAE,OAAO,SAAS;GAC9B,MAAM,QAAQ,WAAW,qBAAqB,CAAC,EAAE,CAAC;GAClD,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAgCwB;CAAM,OAxBhB,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,KAAK,OAAO;EACrB,MAAM,OAAO,EAAE,SAAS;GACtB,MAAM,OAAO,MAAM,IAAI;GACvB,kBAAkB,KAAK,OAAO,IAAI,MAAM,GAAG,GAAG,EAAE,OAAO,OAAO,CAAC;GAC/D,MAAM,SAAS,WAAW,KAAK,MAAM;GACrC,aAAc,OAAO,UAAU,WAAW,EAAE,cAAc,KAAK,IAAI;EACrE;CACF,CAc8B;CAAO,UATpB,gBAAgB;EAC/B,MAAM;EACN,cAAc;EACd,MAAM,QAAQ,EAAE,OAAO,SAAS;GAC9B,MAAM,SAAS,WAAW,MAAM,IAAI,CAAC,CAAC,MAAM;GAC5C,aAAc,OAAO,UAAU,WAAW,OAAO,EAAE,iBAAiB,OAAO,KAAK;EAClF;CACF,CAEqC;AAAS"}
1
+ {"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/vue/src/avatar.ts"],"sourcesContent":["import { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type { Avatar as Controller, ImageStatus } from \"@kirana-ui/core/avatar\"\nimport { defineComponent, h, onBeforeUnmount, onMounted, watchEffect } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { context, controller, fromSignal, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"avatar\">\n\nconst scope = context<Controller>(\"Avatar\")\nconst RootElement = partComponent(\"AvatarRootElement\", \"span\", () => scope.use().root)\nconst ImageElement = partComponent(\"AvatarImageElement\", \"img\", () => scope.use().image)\nconst KeptImageElement = partComponent(\"AvatarKeptImageElement\", \"img\", () => scope.use().keptImage)\nconst FallbackElement = partComponent(\"AvatarFallbackElement\", \"span\", () => scope.use().fallback)\n\nexport type RootProps = PartComponentProps\n\nconst Root = defineComponent({\n name: \"AvatarRoot\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n scope.provide(controller(createAvatar, () => ({})))\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"root\"], RootProps>\n\nexport interface ImageProps extends PartComponentProps {\n /** The picture's address: the part is in the page once it has loaded. */\n src?: string | undefined\n /**\n * Keeps the element in the page while the picture loads, as Base UI's: it loads the\n * picture itself (`loading=\"lazy\"` works), and until it has loaded it is `aria-hidden`,\n * with `data-loading` or `data-error` for the design to hide or fade it by. Default:\n * `false`, the element is drawn once the picture has loaded.\n */\n keepMounted?: boolean | undefined\n}\n\nexport type ImageEmits = {\n /**\n * `@loading-status-change`: each time the picture's loading status changes, `loading` once it\n * has an address, then `loaded` or `error`; `idle` again when its address is taken away. The\n * root says the same in `data-image-loading-status`.\n */\n loadingStatusChange: (status: ImageStatus) => void\n}\n\n/** Runs something with a `mount()` for the component's life in the page. */\nfunction whileMounted(made: { mount(): () => void }) {\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = made.mount()\n })\n onBeforeUnmount(() => stop?.())\n}\n\n/**\n * The picture: in the page once `src` has loaded, or all along with `keep-mounted`.\n * `@loading-status-change` hears its loading.\n */\nconst Image = defineComponent({\n name: \"AvatarImage\",\n inheritAttrs: false,\n props: { src: String, keepMounted: Boolean },\n emits: [\"loadingStatusChange\"],\n setup(props, { attrs, emit }) {\n const made = scope.use()\n watchEffect(() => made.source.set(props.src), { flush: \"sync\" })\n whileMounted(made.statusReport(() => (status) => emit(\"loadingStatusChange\", status)))\n const mounted = fromSignal(made.imageMounted)\n return () =>\n props.keepMounted\n ? h(KeptImageElement, { ...attrs, src: props.src })\n : mounted.value\n ? h(ImageElement, attrs)\n : null\n },\n}) as unknown as PartComponent<\"img\", State[\"image\"], ImageProps, ImageEmits>\n\nexport interface FallbackProps extends PartComponentProps {\n /**\n * How long to wait before showing, in milliseconds, so a picture that loads sooner never\n * lets the fallback be seen. Read once. Default: `0`, at once.\n */\n delay?: number | undefined\n}\n\n/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */\nconst Fallback = defineComponent({\n name: \"AvatarFallback\",\n inheritAttrs: false,\n props: { delay: { type: Number as PropType<number>, default: undefined as unknown } },\n setup(props, { attrs, slots }) {\n const presence = scope.use().fallbackPresence({ delay: props.delay as number | undefined })\n whileMounted(presence)\n const shown = fromSignal(presence.shown)\n return () => (shown.value ? h(FallbackElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"fallback\"], FallbackProps>\n\nexport const Avatar = { Root, Image, Fallback }\n"],"mappings":";;;;AAUA,MAAM,QAAQ,QAAoB,QAAQ;AAC1C,MAAM,cAAc,cAAc,qBAAqB,cAAc,MAAM,IAAI,CAAC,CAAC,IAAI;AACrF,MAAM,eAAe,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;AACvF,MAAM,mBAAmB,cAAc,0BAA0B,aAAa,MAAM,IAAI,CAAC,CAAC,SAAS;AACnG,MAAM,kBAAkB,cAAc,yBAAyB,cAAc,MAAM,IAAI,CAAC,CAAC,QAAQ;AAIjG,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,MAAM,QAAQ,EAAE,OAAO,SAAS;EAC9B,MAAM,QAAQ,WAAW,qBAAqB,CAAC,EAAE,CAAC;EAClD,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;;AAwBD,SAAS,aAAa,MAA+B;CACnD,IAAI;CACJ,gBAAgB;EACd,OAAO,KAAK,MAAM;CACpB,CAAC;CACD,sBAAsB,OAAO,CAAC;AAChC;AA8CA,MAAa,SAAS;CAAE;CAAM,OAxChB,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GAAE,KAAK;GAAQ,aAAa;EAAQ;EAC3C,OAAO,CAAC,qBAAqB;EAC7B,MAAM,OAAO,EAAE,OAAO,QAAQ;GAC5B,MAAM,OAAO,MAAM,IAAI;GACvB,kBAAkB,KAAK,OAAO,IAAI,MAAM,GAAG,GAAG,EAAE,OAAO,OAAO,CAAC;GAC/D,aAAa,KAAK,oBAAoB,WAAW,KAAK,uBAAuB,MAAM,CAAC,CAAC;GACrF,MAAM,UAAU,WAAW,KAAK,YAAY;GAC5C,aACE,MAAM,cACF,EAAE,kBAAkB;IAAE,GAAG;IAAO,KAAK,MAAM;GAAI,CAAC,IAChD,QAAQ,QACN,EAAE,cAAc,KAAK,IACrB;EACV;CACF,CAuB8B;CAAO,UAZpB,gBAAgB;EAC/B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,OAAO;GAAE,MAAM;GAA4B,SAAS,KAAA;EAAqB,EAAE;EACpF,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,WAAW,MAAM,IAAI,CAAC,CAAC,iBAAiB,EAAE,OAAO,MAAM,MAA4B,CAAC;GAC1F,aAAa,QAAQ;GACrB,MAAM,QAAQ,WAAW,SAAS,KAAK;GACvC,aAAc,MAAM,QAAQ,EAAE,iBAAiB,OAAO,KAAK,IAAI;EACjE;CACF,CAEqC;AAAS"}
package/src/button.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { PartComponent, PartComponentProps, StatesOf } from "./runtime.js";
2
2
  import { ButtonProps as ButtonProps$1 } from "@kirana-ui/core/button";
3
3
  export interface ButtonProps extends ButtonProps$1, PartComponentProps {}
4
- /** A `<button>`, or with `as` and `:native-button="false"` another element that acts as one. */
4
+ /**
5
+ * A `<button>`, or with `as` and `:native-button="false"` another element that acts as one; a
6
+ * link that navigates (`as="a" href="/x"`, `as-child` on an `<a href>`) stays a link.
7
+ */
5
8
  export declare const Button: PartComponent<"button", StatesOf<"button">["root"], ButtonProps>;
6
9
  //# sourceMappingURL=button.d.ts.map
package/src/button.js CHANGED
@@ -2,7 +2,10 @@ import { controller, optional, partComponent } from "./runtime.js";
2
2
  import { defineComponent, h } from "vue";
3
3
  import { createButton } from "@kirana-ui/core/button";
4
4
  // src/button.ts
5
- /** A `<button>`, or with `as` and `:native-button="false"` another element that acts as one. */
5
+ /**
6
+ * A `<button>`, or with `as` and `:native-button="false"` another element that acts as one; a
7
+ * link that navigates (`as="a" href="/x"`, `as-child` on an `<a href>`) stays a link.
8
+ */
6
9
  const Button = defineComponent({
7
10
  name: "Button",
8
11
  inheritAttrs: false,
package/src/button.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/vue/src/button.ts"],"sourcesContent":["import { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport { defineComponent, h } from \"vue\"\n\nimport { controller, optional, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\nexport interface ButtonProps extends CoreProps, PartComponentProps {}\n\n/** A `<button>`, or with `as` and `:native-button=\"false\"` another element that acts as one. */\nexport const Button = defineComponent({\n name: \"Button\",\n inheritAttrs: false,\n props: {\n disabled: Boolean,\n focusableWhenDisabled: Boolean,\n nativeButton: optional(Boolean),\n },\n setup(props, { attrs, slots }) {\n const made = controller(createButton, () => ({ ...props }))\n const Element = partComponent(\"ButtonElement\", \"button\", () => made.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", StatesOf<\"button\">[\"root\"], ButtonProps>\n"],"mappings":";;;;;AAUA,MAAa,SAAS,gBAAgB;CACpC,MAAM;CACN,cAAc;CACd,OAAO;EACL,UAAU;EACV,uBAAuB;EACvB,cAAc,SAAS,OAAO;CAChC;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,OAAO,WAAW,qBAAqB,EAAE,GAAG,MAAM,EAAE;EAC1D,MAAM,UAAU,cAAc,iBAAiB,gBAAgB,KAAK,IAAI;EACxE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC"}
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/vue/src/button.ts"],"sourcesContent":["import { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport { defineComponent, h } from \"vue\"\n\nimport { controller, optional, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\nexport interface ButtonProps extends CoreProps, PartComponentProps {}\n\n/**\n * A `<button>`, or with `as` and `:native-button=\"false\"` another element that acts as one; a\n * link that navigates (`as=\"a\" href=\"/x\"`, `as-child` on an `<a href>`) stays a link.\n */\nexport const Button = defineComponent({\n name: \"Button\",\n inheritAttrs: false,\n props: {\n disabled: Boolean,\n focusableWhenDisabled: Boolean,\n nativeButton: optional(Boolean),\n },\n setup(props, { attrs, slots }) {\n const made = controller(createButton, () => ({ ...props }))\n const Element = partComponent(\"ButtonElement\", \"button\", () => made.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", StatesOf<\"button\">[\"root\"], ButtonProps>\n"],"mappings":";;;;;;;;AAaA,MAAa,SAAS,gBAAgB;CACpC,MAAM;CACN,cAAc;CACd,OAAO;EACL,UAAU;EACV,uBAAuB;EACvB,cAAc,SAAS,OAAO;CAChC;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,OAAO,WAAW,qBAAqB,EAAE,GAAG,MAAM,EAAE;EAC1D,MAAM,UAAU,cAAc,iBAAiB,gBAAgB,KAAK,IAAI;EACxE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC"}
package/src/calendar.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { Changes, PartComponent, PartComponentProps, PlainComponent } from "./runtime.js";
2
- import { Calendar as Calendar$1, CalendarDay, CalendarProps, CalendarValue, CalendarWeekday } from "@kirana-ui/core/calendar";
1
+ import { Changes, PartComponent, PartComponentProps, PartGiven, PartInstance, PlainComponent, StatesOf } from "./runtime.js";
2
+ import { PublicProps } from "vue";
3
+ import { Calendar as Calendar$1, CalendarDay, CalendarMode, CalendarMonth, CalendarProps, CalendarValueOf, CalendarWeekday } from "@kirana-ui/core/calendar";
4
+ type State = StatesOf<"calendar">;
3
5
  /**
4
6
  * The calendar its parts are inside. Exported for a component that is made of one (a date picker
5
7
  * provides its own to the calendar's parts).
@@ -8,15 +10,14 @@ declare const scope: {
8
10
  provide(controller: Calendar$1): Calendar$1;
9
11
  use(): Calendar$1;
10
12
  };
11
- export type RootProps = Omit<CalendarProps, "id" | "onValueChange" | "onMonthChange"> & {
13
+ /** `value` and its events are typed by `mode`: a day, a range, or a list of days. */
14
+ export type RootProps<Mode extends CalendarMode = "single"> = Omit<CalendarProps<Mode>, "id" | "onValueChange" | "onMonthChange"> & {
12
15
  id?: string | undefined;
13
16
  } & PartComponentProps;
14
- export type RootEmits = Changes<"value", CalendarValue> & {
15
- /** The month shown has changed: its first day. */
16
- monthChange: (month: string) => void;
17
- };
17
+ export type RootEmits<Mode extends CalendarMode = "single"> = Changes<"value", CalendarValueOf<Mode>> & Changes<"month", string>;
18
18
  export type HeadingProps = PartComponentProps;
19
19
  export type WeekdaysProps = Record<never, never>;
20
+ export type MonthsProps = Record<never, never>;
20
21
  export type WeeksProps = Record<never, never>;
21
22
  export interface HeadCellProps extends PartComponentProps {
22
23
  /** The day of the week it names, as `Calendar.Weekdays` gives it. */
@@ -26,15 +27,18 @@ export interface CellProps extends PartComponentProps {
26
27
  /** The day it is for, as a week of `Calendar.Weeks` gives it. */
27
28
  date: string;
28
29
  }
29
- export type DayProps = CellProps;
30
+ export interface DayProps extends PartComponentProps {
31
+ /** The day it is the button of. Left out, the `Calendar.Cell`'s it is inside. */
32
+ date?: string | undefined;
33
+ }
30
34
  export type PreviousProps = PartComponentProps;
31
35
  export type NextProps = PartComponentProps;
32
36
  export type GridProps = PartComponentProps;
37
+ export type InputProps = PartComponentProps;
33
38
  export declare const Calendar: {
34
- Root: PartComponent<"div", {
35
- readonly disabled?: true | undefined;
36
- readonly readonly?: true | undefined;
37
- }, RootProps, RootEmits>;
39
+ Root: new <Mode extends CalendarMode = "single", As extends string = "div">(props: PartGiven<As, RootProps<Mode>, RootEmits<Mode>> & PublicProps) => PartInstance<As, RootProps<Mode>, RootEmits<Mode>, {
40
+ state: State["root"];
41
+ }>;
38
42
  Heading: PartComponent<"div", Record<never, never>, PartComponentProps>;
39
43
  Previous: PartComponent<"button", {
40
44
  readonly disabled?: true | undefined;
@@ -42,6 +46,9 @@ export declare const Calendar: {
42
46
  Next: PartComponent<"button", {
43
47
  readonly disabled?: true | undefined;
44
48
  }, PartComponentProps, {}, unknown>;
49
+ Months: PlainComponent<MonthsProps, {}, {
50
+ month: CalendarMonth;
51
+ }>;
45
52
  Grid: PartComponent<"table", Record<never, never>, PartComponentProps, {}, unknown>;
46
53
  Weekdays: PlainComponent<WeekdaysProps, {}, {
47
54
  weekday: CalendarWeekday;
@@ -67,7 +74,9 @@ export declare const Calendar: {
67
74
  readonly unavailable?: true | undefined;
68
75
  readonly rangeStart?: true | undefined;
69
76
  readonly rangeEnd?: true | undefined;
70
- }, CellProps>;
77
+ }, DayProps>;
78
+ /** The hidden input the value is submitted by, when the root has a `name`. */
79
+ Input: PartComponent<"input", Record<never, never>, PartComponentProps, {}, unknown>;
71
80
  };
72
81
  export { scope as calendarScope };
73
82
  //# sourceMappingURL=calendar.d.ts.map