@kirana-ui/vue 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/llms.txt +1619 -241
  2. package/package.json +14 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +142 -0
  4. package/src/accordion.d.ts +42 -75
  5. package/src/accordion.js +4 -2
  6. package/src/accordion.js.map +1 -1
  7. package/src/agent.d.ts +1 -0
  8. package/src/agent.js +1 -0
  9. package/src/alert-dialog.d.ts +3 -2
  10. package/src/autocomplete.d.ts +4 -2
  11. package/src/autosize.d.ts +9 -9
  12. package/src/autosize.js.map +1 -1
  13. package/src/avatar.d.ts +10 -13
  14. package/src/avatar.js.map +1 -1
  15. package/src/button.d.ts +4 -21
  16. package/src/button.js.map +1 -1
  17. package/src/calendar.d.ts +65 -99
  18. package/src/calendar.js +6 -1
  19. package/src/calendar.js.map +1 -1
  20. package/src/carousel.d.ts +36 -58
  21. package/src/carousel.js.map +1 -1
  22. package/src/checkbox.d.ts +28 -50
  23. package/src/checkbox.js +2 -2
  24. package/src/checkbox.js.map +1 -1
  25. package/src/collapsible.d.ts +26 -36
  26. package/src/collapsible.js.map +1 -1
  27. package/src/combobox.d.ts +139 -290
  28. package/src/combobox.js +11 -1
  29. package/src/combobox.js.map +1 -1
  30. package/src/command.d.ts +43 -86
  31. package/src/command.js.map +1 -1
  32. package/src/context-menu.d.ts +4 -2
  33. package/src/date-field.d.ts +31 -61
  34. package/src/date-field.js +7 -3
  35. package/src/date-field.js.map +1 -1
  36. package/src/date-picker.d.ts +83 -139
  37. package/src/date-picker.js.map +1 -1
  38. package/src/dialog.d.ts +74 -145
  39. package/src/dialog.js +3 -1
  40. package/src/dialog.js.map +1 -1
  41. package/src/direction.d.ts +5 -8
  42. package/src/direction.js.map +1 -1
  43. package/src/drawer.d.ts +3 -2
  44. package/src/element.d.ts +23 -0
  45. package/src/element.js +90 -0
  46. package/src/element.js.map +1 -0
  47. package/src/field.d.ts +63 -45
  48. package/src/field.js +3 -2
  49. package/src/field.js.map +1 -1
  50. package/src/fieldset.d.ts +12 -13
  51. package/src/fieldset.js.map +1 -1
  52. package/src/form.d.ts +5 -15
  53. package/src/form.js.map +1 -1
  54. package/src/hover-card.d.ts +29 -43
  55. package/src/hover-card.js.map +1 -1
  56. package/src/hover-popup.d.ts +27 -46
  57. package/src/hover-popup.js +4 -1
  58. package/src/hover-popup.js.map +1 -1
  59. package/src/index.d.ts +13 -3
  60. package/src/input.d.ts +12 -14
  61. package/src/input.js.map +1 -1
  62. package/src/label.d.ts +3 -3
  63. package/src/label.js.map +1 -1
  64. package/src/listbox.d.ts +34 -89
  65. package/src/listbox.js.map +1 -1
  66. package/src/menu.d.ts +170 -533
  67. package/src/menu.js.map +1 -1
  68. package/src/menubar.d.ts +6 -24
  69. package/src/menubar.js.map +1 -1
  70. package/src/message-scroller.d.ts +23 -17
  71. package/src/message-scroller.js.map +1 -1
  72. package/src/meter.d.ts +10 -31
  73. package/src/meter.js.map +1 -1
  74. package/src/navigation-menu.d.ts +77 -88
  75. package/src/navigation-menu.js +13 -12
  76. package/src/navigation-menu.js.map +1 -1
  77. package/src/number-field.d.ts +72 -68
  78. package/src/number-field.js +2 -2
  79. package/src/number-field.js.map +1 -1
  80. package/src/otp.d.ts +33 -54
  81. package/src/otp.js +2 -2
  82. package/src/otp.js.map +1 -1
  83. package/src/pagination.d.ts +31 -58
  84. package/src/pagination.js.map +1 -1
  85. package/src/popover.d.ts +60 -36
  86. package/src/popover.js +33 -5
  87. package/src/popover.js.map +1 -1
  88. package/src/primitive.d.ts +21 -0
  89. package/src/primitive.js +27 -0
  90. package/src/primitive.js.map +1 -0
  91. package/src/progress.d.ts +28 -31
  92. package/src/progress.js.map +1 -1
  93. package/src/qr-code.d.ts +12 -21
  94. package/src/qr-code.js.map +1 -1
  95. package/src/radio-group.d.ts +37 -75
  96. package/src/radio-group.js +2 -2
  97. package/src/radio-group.js.map +1 -1
  98. package/src/resizable.d.ts +26 -45
  99. package/src/resizable.js.map +1 -1
  100. package/src/runtime.d.ts +93 -21
  101. package/src/runtime.js +24 -25
  102. package/src/runtime.js.map +1 -1
  103. package/src/scroll-area.d.ts +33 -28
  104. package/src/scroll-area.js.map +1 -1
  105. package/src/select.d.ts +87 -147
  106. package/src/select.js +31 -6
  107. package/src/select.js.map +1 -1
  108. package/src/separator.d.ts +4 -9
  109. package/src/separator.js.map +1 -1
  110. package/src/slider.d.ts +61 -80
  111. package/src/slider.js +10 -10
  112. package/src/slider.js.map +1 -1
  113. package/src/switch.d.ts +21 -39
  114. package/src/switch.js +2 -2
  115. package/src/switch.js.map +1 -1
  116. package/src/tabs.d.ts +44 -98
  117. package/src/tabs.js.map +1 -1
  118. package/src/testing.d.ts +1 -0
  119. package/src/testing.js +1 -0
  120. package/src/toast.d.ts +58 -45
  121. package/src/toast.js +46 -17
  122. package/src/toast.js.map +1 -1
  123. package/src/toggle-group.d.ts +8 -39
  124. package/src/toggle-group.js.map +1 -1
  125. package/src/toggle.d.ts +5 -34
  126. package/src/toggle.js.map +1 -1
  127. package/src/toolbar.d.ts +31 -69
  128. package/src/toolbar.js.map +1 -1
  129. package/src/tooltip.d.ts +29 -43
  130. package/src/tooltip.js.map +1 -1
  131. package/src/value-bar.d.ts +26 -35
  132. package/src/value-bar.js +10 -3
  133. package/src/value-bar.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/vue/src/popover.ts"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { ChangeDetails, PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller } from \"@kirana-ui/core/popover\"\nimport { defineComponent, h, useId, watchEffect } from \"vue\"\nimport type { Component, PropType } from \"vue\"\n\nimport { context, controller, optional, partComponent, portalComponent } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"Popover\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as popoverScope }\n\nconst Root = defineComponent({\n name: \"PopoverRoot\",\n props: { open: optional(Boolean), defaultOpen: Boolean, id: String },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createPopover, () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n return () => slots.default?.()\n },\n})\n\n/** A positioner: the part's element, with where it goes as props. */\nexport function positionerComponent(\n name: string,\n use: () => { positioning: Controller[\"positioning\"] },\n element: Component\n): Component {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: {\n side: String as PropType<PositionOptions[\"side\"]>,\n align: String as PropType<PositionOptions[\"align\"]>,\n sideOffset: Number,\n alignOffset: Number,\n collisionPadding: Number,\n },\n setup(props, { attrs, slots }) {\n const { positioning } = use()\n // As they change, and before the element attaches: the first placement reads these.\n watchEffect(() => positioning.set(defined({ ...props })), { flush: \"sync\" })\n return () => h(element, attrs, slots)\n },\n })\n}\n\nexport const Popover = {\n Root,\n Trigger: partComponent(\"PopoverTrigger\", \"button\", () => scope.use().trigger),\n Portal: portalComponent(\"PopoverPortal\", () => scope.use().mounted),\n Positioner: positionerComponent(\n \"PopoverPositioner\",\n () => scope.use(),\n partComponent(\"PopoverPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent(\"PopoverPopup\", \"div\", () => scope.use().popup),\n Title: partComponent(\"PopoverTitle\", \"h2\", () => scope.use().title),\n Description: partComponent(\"PopoverDescription\", \"p\", () => scope.use().description),\n Close: partComponent(\"PopoverClose\", \"button\", () => scope.use().close),\n}\n"],"mappings":";;;;;AASA,MAAM,QAAQ,QAAoB,SAAS;AAI3C,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EAAE,MAAM,SAAS,OAAO;EAAG,aAAa;EAAS,IAAI;CAAO;CACnE,OAAO,CAAC,eAAe,YAAY;CACnC,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,sBAAsB;GAC/B,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,aAAa,MAAe,SAAwB;IAClD,KAAK,cAAc,MAAM,OAAO;IAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;GACjD;EACF,EAAE,CACJ;EACA,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAGD,SAAgB,oBACd,MACA,KACA,SACW;CACX,OAAO,gBAAgB;EACrB;EACA,cAAc;EACd,OAAO;GACL,MAAM;GACN,OAAO;GACP,YAAY;GACZ,aAAa;GACb,kBAAkB;EACpB;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,gBAAgB,IAAI;GAE5B,kBAAkB,YAAY,IAAI,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC;GAC3E,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAAC;AACH;AAEA,MAAa,UAAU;CACrB;CACA,SAAS,cAAc,kBAAkB,gBAAgB,MAAM,IAAI,CAAC,CAAC,OAAO;CAC5E,QAAQ,gBAAgB,uBAAuB,MAAM,IAAI,CAAC,CAAC,OAAO;CAClE,YAAY,oBACV,2BACM,MAAM,IAAI,GAChB,cAAc,4BAA4B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAC/E;CACA,OAAO,cAAc,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CACnE,OAAO,cAAc,gBAAgB,YAAY,MAAM,IAAI,CAAC,CAAC,KAAK;CAClE,aAAa,cAAc,sBAAsB,WAAW,MAAM,IAAI,CAAC,CAAC,WAAW;CACnF,OAAO,cAAc,gBAAgB,gBAAgB,MAAM,IAAI,CAAC,CAAC,KAAK;AACxE"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/vue/src/popover.ts"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { Anchor, ChangeDetails, PartState, PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller, PopoverProps } from \"@kirana-ui/core/popover\"\nimport { defineComponent, h, unref, useId, watchEffect } from \"vue\"\nimport type { Component, ComponentPublicInstance, PropType, Ref } from \"vue\"\n\nimport {\n context,\n controller,\n elementOf,\n optional,\n partComponent,\n portalComponent,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"popover\">\n\n/**\n * The popover its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the popover's parts).\n */\nconst scope = context<Controller>(\"Popover\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as popoverScope }\n\nexport type RootProps = Omit<PopoverProps, \"id\" | \"onOpenChange\"> & { id?: string | undefined }\n\nexport type RootEmits = Changes<\"open\", boolean>\n\nconst Root = defineComponent({\n name: \"PopoverRoot\",\n props: { open: optional(Boolean), defaultOpen: Boolean, id: String },\n emits: [\"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createPopover, () => ({\n id: props.id ?? generated,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<RootProps, RootEmits>\n\n/**\n * What a positioner's `anchor` may be: an element, a place in the viewport (an object with\n * `getBoundingClientRect`), a template ref to an element or a component (in a template that is\n * the element or the component's instance), or a function that gives an element or a place.\n */\nexport type PositionerAnchor =\n | Anchor\n | ComponentPublicInstance\n | Ref<Anchor | ComponentPublicInstance | null | undefined>\n | (() => Anchor | null | undefined)\n | null\n | undefined\n\nfunction anchorOf(given: unknown): PositionOptions[\"anchor\"] {\n const named: unknown = unref(given)\n // A function is asked here, so a change of what it reads is followed; and given whole while\n // it has nothing, to be asked again as the popup is placed.\n if (typeof named === \"function\") {\n const ask = named as () => Anchor | null | undefined\n return ask() ?? ask\n }\n if (!named || typeof named !== \"object\") return named as null | undefined\n if (\"getBoundingClientRect\" in named) return named as Anchor\n // A component's instance.\n return elementOf(named) ?? undefined\n}\n\n/** A positioner's own props: where its popup goes, and what it is placed against. */\nexport interface PositionerProps\n extends\n Partial<\n Pick<PositionOptions, \"side\" | \"align\" | \"sideOffset\" | \"alignOffset\" | \"collisionPadding\">\n >,\n PartComponentProps {\n /**\n * What the popup is placed against, when that is not its trigger. It may change while the\n * popup is open: the popup follows.\n */\n anchor?: PositionerAnchor\n}\n\n/**\n * A positioner: the part's element, with where it goes as props. The one place a positioner's\n * own props are named.\n */\nexport function positionerComponent<Placed = PartState>(\n name: string,\n use: () => { positioning: Controller[\"positioning\"] },\n element: Component\n): PartComponent<\"div\", Placed, PositionerProps> {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: {\n side: String as PropType<PositionOptions[\"side\"]>,\n align: String as PropType<PositionOptions[\"align\"]>,\n sideOffset: Number,\n alignOffset: Number,\n collisionPadding: Number,\n /**\n * What the popup is placed against, when that is not its trigger. It may change while\n * the popup is open: the popup follows.\n */\n anchor: {\n type: null as unknown as PropType<PositionerAnchor>,\n default: undefined as unknown,\n },\n },\n setup(props, { attrs, slots }) {\n const { positioning } = use()\n // As they change, and before the element attaches: the first placement reads these.\n watchEffect(() => positioning.set(defined({ ...props, anchor: anchorOf(props.anchor) })), {\n flush: \"sync\",\n })\n return () => h(element, attrs, slots)\n },\n }) as unknown as PartComponent<\"div\", Placed, PositionerProps>\n}\n\nexport type TriggerProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type TitleProps = PartComponentProps\nexport type DescriptionProps = PartComponentProps\nexport type CloseProps = PartComponentProps\nexport const Popover = {\n Root,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"PopoverTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Portal: portalComponent(\"PopoverPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"PopoverPositioner\",\n () => scope.use(),\n partComponent(\"PopoverPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"PopoverPopup\", \"div\", () => scope.use().popup),\n Title: partComponent<\"h2\", State[\"title\"]>(\"PopoverTitle\", \"h2\", () => scope.use().title),\n Description: partComponent<\"p\", State[\"description\"]>(\n \"PopoverDescription\",\n \"p\",\n () => scope.use().description\n ),\n Close: partComponent<\"button\", State[\"close\"]>(\"PopoverClose\", \"button\", () => scope.use().close),\n}\n"],"mappings":";;;;;;;;;AA+BA,MAAM,QAAQ,QAAoB,SAAS;AAQ3C,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EAAE,MAAM,SAAS,OAAO;EAAG,aAAa;EAAS,IAAI;CAAO;CACnE,OAAO,CAAC,eAAe,YAAY;CACnC,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,sBAAsB;GAC/B,IAAI,MAAM,MAAM;GAChB,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,aAAa,MAAe,SAAwB;IAClD,KAAK,cAAc,MAAM,OAAO;IAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;GACjD;EACF,EAAE,CACJ;EACA,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;AAeD,SAAS,SAAS,OAA2C;CAC3D,MAAM,QAAiB,MAAM,KAAK;CAGlC,IAAI,OAAO,UAAU,YAAY;EAC/B,MAAM,MAAM;EACZ,OAAO,IAAI,KAAK;CAClB;CACA,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,IAAI,2BAA2B,OAAO,OAAO;CAE7C,OAAO,UAAU,KAAK,KAAK,KAAA;AAC7B;;;;;AAoBA,SAAgB,oBACd,MACA,KACA,SAC+C;CAC/C,OAAO,gBAAgB;EACrB;EACA,cAAc;EACd,OAAO;GACL,MAAM;GACN,OAAO;GACP,YAAY;GACZ,aAAa;GACb,kBAAkB;;;;;GAKlB,QAAQ;IACN,MAAM;IACN,SAAS,KAAA;GACX;EACF;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,gBAAgB,IAAI;GAE5B,kBAAkB,YAAY,IAAI,QAAQ;IAAE,GAAG;IAAO,QAAQ,SAAS,MAAM,MAAM;GAAE,CAAC,CAAC,GAAG,EACxF,OAAO,OACT,CAAC;GACD,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAAC;AACH;AAOA,MAAa,UAAU;CACrB;CACA,SAAS,cACP,kBACA,gBACM,MAAM,IAAI,CAAC,CAAC,OACpB;CACA,QAAQ,gBAAgB,uBAAuB,MAAM,IAAI,CAAC,CAAC,OAAO;CAClE,YAAY,oBACV,2BACM,MAAM,IAAI,GAChB,cAAc,4BAA4B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAC/E;CACA,OAAO,cAAqC,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CAC1F,OAAO,cAAoC,gBAAgB,YAAY,MAAM,IAAI,CAAC,CAAC,KAAK;CACxF,aAAa,cACX,sBACA,WACM,MAAM,IAAI,CAAC,CAAC,WACpB;CACA,OAAO,cAAwC,gBAAgB,gBAAgB,MAAM,IAAI,CAAC,CAAC,KAAK;AAClG"}
@@ -0,0 +1,21 @@
1
+ import { DefaultSlot, ElementAttributes } from "./runtime.js";
2
+ import { Component, DefineSetupFnComponent, PublicProps } from "vue";
3
+ export interface PrimitiveProps {
4
+ /** Another tag for the element, or a component to draw in its place; a `div` when left out. */
5
+ as?: string | Component | undefined;
6
+ /** Draws the element in its slot in place of its own: it takes the attributes given here. */
7
+ asChild?: boolean | undefined;
8
+ }
9
+ /** What a `Primitive` drawn as `Tag` takes: its two props, and what the element takes. */
10
+ export type PrimitiveGiven<Tag extends string> = PrimitiveProps & Omit<ElementAttributes<Tag>, keyof PrimitiveProps>;
11
+ /**
12
+ * A plain element of one's own (a badge, a breadcrumb's link) with the composition a part
13
+ * has: `as` for another tag or component (a `div` unless said), or with `as-child` the
14
+ * caller's own element in its slot. By a part's rule: the slotted element's own props lie
15
+ * over the attributes on the `Primitive`, classes join, styles are merged, and both listeners
16
+ * of an event run, the `Primitive`'s first.
17
+ */
18
+ export declare const Primitive: new <As extends string = "div">(props: PrimitiveGiven<As> & {
19
+ as?: As | Component | undefined;
20
+ } & PublicProps) => InstanceType<DefineSetupFnComponent<PrimitiveGiven<As>, {}, DefaultSlot<{}>>>;
21
+ //# sourceMappingURL=primitive.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { draw } from "./element.js";
2
+ import { defineComponent } from "vue";
3
+ // src/primitive.ts
4
+ /**
5
+ * A plain element of one's own (a badge, a breadcrumb's link) with the composition a part
6
+ * has: `as` for another tag or component (a `div` unless said), or with `as-child` the
7
+ * caller's own element in its slot. By a part's rule: the slotted element's own props lie
8
+ * over the attributes on the `Primitive`, classes join, styles are merged, and both listeners
9
+ * of an event run, the `Primitive`'s first.
10
+ */
11
+ const Primitive = defineComponent({
12
+ name: "Primitive",
13
+ inheritAttrs: false,
14
+ props: {
15
+ as: {
16
+ type: [String, Object],
17
+ default: "div"
18
+ },
19
+ asChild: Boolean
20
+ },
21
+ setup(props, { attrs, slots }) {
22
+ return () => draw(props.as, props.asChild, attrs, slots.default?.());
23
+ }
24
+ });
25
+ export { Primitive };
26
+
27
+ //# sourceMappingURL=primitive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive.js","names":[],"sources":["../../../../packages/vue/src/primitive.ts"],"sourcesContent":["import { defineComponent } from \"vue\"\nimport type { Component, DefineSetupFnComponent, PropType, PublicProps } from \"vue\"\n\nimport { draw } from \"./element.ts\"\nimport type { DefaultSlot, ElementAttributes } from \"./runtime.ts\"\n\nexport interface PrimitiveProps {\n /** Another tag for the element, or a component to draw in its place; a `div` when left out. */\n as?: string | Component | undefined\n /** Draws the element in its slot in place of its own: it takes the attributes given here. */\n asChild?: boolean | undefined\n}\n\n/** What a `Primitive` drawn as `Tag` takes: its two props, and what the element takes. */\nexport type PrimitiveGiven<Tag extends string> = PrimitiveProps &\n Omit<ElementAttributes<Tag>, keyof PrimitiveProps>\n\n/**\n * A plain element of one's own (a badge, a breadcrumb's link) with the composition a part\n * has: `as` for another tag or component (a `div` unless said), or with `as-child` the\n * caller's own element in its slot. By a part's rule: the slotted element's own props lie\n * over the attributes on the `Primitive`, classes join, styles are merged, and both listeners\n * of an event run, the `Primitive`'s first.\n */\nexport const Primitive = defineComponent({\n name: \"Primitive\",\n inheritAttrs: false,\n props: {\n as: { type: [String, Object] as PropType<string | Component>, default: \"div\" },\n asChild: Boolean,\n },\n setup(props, { attrs, slots }) {\n return () => draw(props.as, props.asChild, attrs, slots.default?.())\n },\n}) as unknown as new <As extends string = \"div\">(\n props: PrimitiveGiven<As> & { as?: As | Component | undefined } & PublicProps\n) => InstanceType<DefineSetupFnComponent<PrimitiveGiven<As>, {}, DefaultSlot<{}>>>\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,YAAY,gBAAgB;CACvC,MAAM;CACN,cAAc;CACd,OAAO;EACL,IAAI;GAAE,MAAM,CAAC,QAAQ,MAAM;GAAmC,SAAS;EAAM;EAC7E,SAAS;CACX;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,aAAa,KAAK,MAAM,IAAI,MAAM,SAAS,OAAO,MAAM,UAAU,CAAC;CACrE;AACF,CAAC"}
package/src/progress.d.ts CHANGED
@@ -1,34 +1,31 @@
1
+ import { IndicatorProps, LabelProps, RootProps, TrackProps, ValueGiven, ValueProps, valueBar } from "./value-bar.js";
2
+ import { PartComponent, PartComponentProps } from "./runtime.js";
1
3
  export declare const Progress: {
2
- Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
- value: {
4
- type: import("vue").PropType<number | null>;
5
- required: true;
6
- };
7
- min: NumberConstructor;
8
- max: NumberConstructor;
9
- format: import("vue").PropType<Intl.NumberFormatOptions>;
10
- locale: StringConstructor;
11
- getAriaValueText: import("vue").PropType<import("@kirana-ui/core/meter").ValueBarProps["getAriaValueText"]>;
12
- id: StringConstructor;
13
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
14
- [key: string]: any;
15
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
- value: {
17
- type: import("vue").PropType<number | null>;
18
- required: true;
19
- };
20
- min: NumberConstructor;
21
- max: NumberConstructor;
22
- format: import("vue").PropType<Intl.NumberFormatOptions>;
23
- locale: StringConstructor;
24
- getAriaValueText: import("vue").PropType<import("@kirana-ui/core/meter").ValueBarProps["getAriaValueText"]>;
25
- id: StringConstructor;
26
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
27
- Track: import("vue").Component;
28
- Indicator: import("vue").Component;
29
- Value: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
30
- [key: string]: any;
31
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
- Label: import("vue").Component;
4
+ Root: PartComponent<"div", {
5
+ readonly progressing?: true | undefined;
6
+ readonly complete?: true | undefined;
7
+ readonly indeterminate?: true | undefined;
8
+ }, RootProps<number | null>>;
9
+ Track: PartComponent<"div", {
10
+ readonly progressing?: true | undefined;
11
+ readonly complete?: true | undefined;
12
+ readonly indeterminate?: true | undefined;
13
+ }, PartComponentProps, {}, unknown>;
14
+ Indicator: PartComponent<"div", {
15
+ readonly progressing?: true | undefined;
16
+ readonly complete?: true | undefined;
17
+ readonly indeterminate?: true | undefined;
18
+ }, PartComponentProps, {}, unknown>;
19
+ Value: PartComponent<"span", {
20
+ readonly progressing?: true | undefined;
21
+ readonly complete?: true | undefined;
22
+ readonly indeterminate?: true | undefined;
23
+ }, PartComponentProps, {}, ValueGiven>;
24
+ Label: PartComponent<"span", {
25
+ readonly progressing?: true | undefined;
26
+ readonly complete?: true | undefined;
27
+ readonly indeterminate?: true | undefined;
28
+ }, PartComponentProps, {}, unknown>;
33
29
  };
30
+ export type { IndicatorProps, LabelProps, RootProps, TrackProps, ValueGiven, ValueProps, valueBar };
34
31
  //# sourceMappingURL=progress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/vue/src/progress.ts"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { valueBar } from \"./value-bar.ts\"\n\nexport const Progress = valueBar(\"Progress\", createProgress)\n"],"mappings":";;;AAIA,MAAa,WAAW,SAAS,YAAY,cAAc"}
1
+ {"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/vue/src/progress.ts"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport type { StatesOf } from \"./runtime.ts\"\nimport { valueBar } from \"./value-bar.ts\"\n\nexport type * from \"./value-bar.ts\"\n\nexport const Progress = valueBar<StatesOf<\"progress\">>(\"Progress\", createProgress)\n"],"mappings":";;;AAOA,MAAa,WAAW,SAA+B,YAAY,cAAc"}
package/src/qr-code.d.ts CHANGED
@@ -1,24 +1,15 @@
1
- import { PropType } from "vue";
2
- import { QrCorrection } from "@kirana-ui/core/qr-code";
1
+ import { PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { QrCodeProps } from "@kirana-ui/core/qr-code";
3
+ export type RootProps = Omit<QrCodeProps, "id"> & {
4
+ id?: string | undefined;
5
+ } & PartComponentProps;
6
+ export type FrameProps = PartComponentProps;
7
+ export type PatternProps = PartComponentProps;
3
8
  export declare const QrCode: {
4
- Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
- value: {
6
- type: StringConstructor;
7
- required: true;
8
- };
9
- correction: PropType<QrCorrection>;
10
- id: StringConstructor;
11
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
12
- [key: string]: any;
13
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
14
- value: {
15
- type: StringConstructor;
16
- required: true;
17
- };
18
- correction: PropType<QrCorrection>;
19
- id: StringConstructor;
20
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
21
- Frame: import("vue").Component;
22
- Pattern: import("vue").Component;
9
+ Root: PartComponent<"div", {
10
+ readonly invalid?: true | undefined;
11
+ }, RootProps>;
12
+ Frame: PartComponent<"svg", Record<never, never>, PartComponentProps, {}, unknown>;
13
+ Pattern: PartComponent<"path", Record<never, never>, PartComponentProps, {}, unknown>;
23
14
  };
24
15
  //# sourceMappingURL=qr-code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/vue/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCorrection } from \"@kirana-ui/core/qr-code\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { context, controller, partComponent } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"QrCode\")\n\nconst RootElement = partComponent(\"QrCodeRootElement\", \"div\", () => scope.use().root)\n\nconst Root = defineComponent({\n name: \"QrCodeRoot\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n correction: String as PropType<QrCorrection>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n scope.provide(\n controller(createQrCode, () => ({\n id: props.id ?? generated,\n value: props.value,\n correction: props.correction,\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n})\n\nconst Frame = partComponent(\"QrCodeFrame\", \"svg\", () => scope.use().frame)\nconst Pattern = partComponent(\"QrCodePattern\", \"path\", () => scope.use().pattern)\n\nexport const QrCode = { Root, Frame, Pattern }\n"],"mappings":";;;;AAOA,MAAM,QAAQ,QAAoB,QAAQ;AAE1C,MAAM,cAAc,cAAc,qBAAqB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AA0BpF,MAAa,SAAS;CAAE,MAxBX,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAQ,UAAU;GAAK;GACtC,YAAY;GACZ,IAAI;EACN;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,YAAY,MAAM;GACxB,MAAM,QACJ,WAAW,qBAAqB;IAC9B,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,YAAY,MAAM;GACpB,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAKwB;CAAM,OAHhB,cAAc,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAGtC;CAAO,SAFrB,cAAc,iBAAiB,cAAc,MAAM,IAAI,CAAC,CAAC,OAEpC;AAAQ"}
1
+ {"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/vue/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCodeProps, QrCorrection } from \"@kirana-ui/core/qr-code\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { context, controller, partComponent } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"qrCode\">\n\nconst scope = context<Controller>(\"QrCode\")\n\nconst RootElement = partComponent(\"QrCodeRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<QrCodeProps, \"id\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nconst Root = defineComponent({\n name: \"QrCodeRoot\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n correction: String as PropType<QrCorrection>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n scope.provide(\n controller(createQrCode, () => ({\n id: props.id ?? generated,\n value: props.value,\n correction: props.correction,\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps>\n\nexport type FrameProps = PartComponentProps\nexport type PatternProps = PartComponentProps\nconst Frame = partComponent<\"svg\", State[\"frame\"]>(\"QrCodeFrame\", \"svg\", () => scope.use().frame)\nconst Pattern = partComponent<\"path\", State[\"pattern\"]>(\n \"QrCodePattern\",\n \"path\",\n () => scope.use().pattern\n)\n\nexport const QrCode = { Root, Frame, Pattern }\n"],"mappings":";;;;AAUA,MAAM,QAAQ,QAAoB,QAAQ;AAE1C,MAAM,cAAc,cAAc,qBAAqB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAoCpF,MAAa,SAAS;CAAE,MA9BX,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAQ,UAAU;GAAK;GACtC,YAAY;GACZ,IAAI;EACN;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,YAAY,MAAM;GACxB,MAAM,QACJ,WAAW,qBAAqB;IAC9B,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,YAAY,MAAM;GACpB,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAWwB;CAAM,OAPhB,cAAqC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAO7D;CAAO,SANrB,cACd,iBACA,cACM,MAAM,IAAI,CAAC,CAAC,OAGiB;AAAQ"}
@@ -1,78 +1,40 @@
1
- import { PropType } from "vue";
1
+ import { Changes, PartComponent, PartComponentProps, PartGiven, PartInstance, StatesOf } from "./runtime.js";
2
+ import { PublicProps } from "vue";
3
+ import { RadioGroupProps, RadioItemOptions } from "@kirana-ui/core/radio-group";
4
+ type State = StatesOf<"radioGroup">;
5
+ export type RootProps<Value = unknown> = Omit<RadioGroupProps<Value>, "id" | "onValueChange"> & {
6
+ id?: string | undefined;
7
+ } & PartComponentProps;
8
+ /** The value is `null` when the group is put back to none chosen. */
9
+ export type RootEmits<Value = unknown> = Changes<"value", Value | null>;
10
+ export interface ItemProps extends RadioItemOptions, PartComponentProps {
11
+ /** What the group's value is while this item is the chosen one. */
12
+ value: unknown;
13
+ }
14
+ export interface IndicatorProps extends PartComponentProps {
15
+ /** Keeps the mark in the page while its item is not the chosen one. */
16
+ keepMounted?: boolean | undefined;
17
+ }
2
18
  export declare const RadioGroup: {
3
- Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
- value: {
5
- type: PropType<unknown>;
6
- default: unknown;
7
- };
8
- defaultValue: {
9
- type: PropType<unknown>;
10
- default: unknown;
11
- };
12
- disabled: BooleanConstructor;
13
- readOnly: BooleanConstructor;
14
- required: BooleanConstructor;
15
- name: StringConstructor;
16
- form: StringConstructor;
17
- id: StringConstructor;
18
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
19
- [key: string]: any;
20
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "valueChange")[], "update:value" | "valueChange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
- value: {
22
- type: PropType<unknown>;
23
- default: unknown;
24
- };
25
- defaultValue: {
26
- type: PropType<unknown>;
27
- default: unknown;
28
- };
29
- disabled: BooleanConstructor;
30
- readOnly: BooleanConstructor;
31
- required: BooleanConstructor;
32
- name: StringConstructor;
33
- form: StringConstructor;
34
- id: StringConstructor;
35
- }>> & Readonly<{
36
- "onUpdate:value"?: ((...args: any[]) => any) | undefined;
37
- onValueChange?: ((...args: any[]) => any) | undefined;
38
- }>, {
39
- value: unknown;
40
- defaultValue: unknown;
41
- disabled: boolean;
42
- readOnly: boolean;
43
- required: boolean;
44
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
45
- Item: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
46
- value: {
47
- type: PropType<unknown>;
48
- required: true;
49
- };
50
- disabled: {
51
- type: BooleanConstructor;
52
- default: undefined;
53
- };
54
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
55
- [key: string]: any;
56
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
57
- value: {
58
- type: PropType<unknown>;
59
- required: true;
60
- };
61
- disabled: {
62
- type: BooleanConstructor;
63
- default: undefined;
64
- };
65
- }>> & Readonly<{}>, {
66
- disabled: boolean;
67
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
68
- Indicator: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
69
- keepMounted: BooleanConstructor;
70
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
71
- [key: string]: any;
72
- }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
73
- keepMounted: BooleanConstructor;
74
- }>> & Readonly<{}>, {
75
- keepMounted: boolean;
76
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
19
+ Root: new <Value = unknown, As extends string = "div">(props: PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps) => PartInstance<As, RootProps<Value>, RootEmits<Value>, {
20
+ state: State["root"];
21
+ }>;
22
+ Item: PartComponent<"span", {
23
+ readonly checked?: true | undefined;
24
+ readonly unchecked?: true | undefined;
25
+ readonly disabled?: true | undefined;
26
+ readonly readonly?: true | undefined;
27
+ readonly required?: true | undefined;
28
+ }, ItemProps>;
29
+ Indicator: PartComponent<"span", {
30
+ readonly checked?: true | undefined;
31
+ readonly unchecked?: true | undefined;
32
+ readonly disabled?: true | undefined;
33
+ readonly readonly?: true | undefined;
34
+ readonly required?: true | undefined;
35
+ readonly startingStyle?: true | undefined;
36
+ readonly endingStyle?: true | undefined;
37
+ }, IndicatorProps>;
77
38
  };
39
+ export {};
78
40
  //# sourceMappingURL=radio-group.d.ts.map
@@ -70,9 +70,9 @@ const RadioGroup = {
70
70
  const item = group.item(value, read);
71
71
  const input = group.itemInput(value, read);
72
72
  provide(ITEM, value);
73
- const Element = partComponent("RadioGroupItemElement", "span", () => item);
74
73
  const Input = partComponent("RadioGroupItemInput", "input", () => input);
75
- return () => h(Element, attrs, () => [slots.default?.(), h(Input)]);
74
+ const Element = partComponent("RadioGroupItemElement", "span", () => item, (content) => [content, h(Input)]);
75
+ return () => h(Element, attrs, slots);
76
76
  }
77
77
  }),
78
78
  Indicator: defineComponent({
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/vue/src/radio-group.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroup as Controller } from \"@kirana-ui/core/radio-group\"\nimport { defineComponent, h, inject, onBeforeUnmount, onMounted, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"RadioGroup\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"RadioGroupItem\")\n\nconst RootElement = partComponent(\"RadioGroupRootElement\", \"div\", () => scope.use().root)\n\n/** `v-model:value`, or `value` with `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"RadioGroupRoot\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, default: undefined as unknown },\n defaultValue: { type: null as unknown as PropType<unknown>, default: null as unknown },\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createRadioGroup, { field, direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\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})\n\nconst Item = defineComponent({\n name: \"RadioGroupItem\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, required: true },\n disabled: optional(Boolean),\n },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const options = toSignal(() => ({ disabled: props.disabled }))\n const read = () => defined(options.get())\n const group = scope.use()\n const item = group.item(value, read)\n const input = group.itemInput(value, read)\n provide(ITEM, value)\n const Element = partComponent(\"RadioGroupItemElement\", \"span\", () => item)\n const Input = partComponent(\"RadioGroupItemInput\", \"input\", () => input)\n return () => h(Element, attrs, () => [slots.default?.(), h(Input)])\n },\n})\n\n/** `keep-mounted` keeps the mark in the page while its item is not the chosen one. */\nconst Indicator = defineComponent({\n name: \"RadioGroupIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const indicator = scope.use().indicator(inject(ITEM))\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = indicator.mount()\n })\n onBeforeUnmount(() => stop?.())\n const mounted = fromSignal(indicator.mounted)\n const Element = partComponent(\"RadioGroupIndicatorElement\", \"span\", () => indicator.part)\n return () => (mounted.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n})\n\nexport const RadioGroup = { Root, Item, Indicator }\n"],"mappings":";;;;;;;AAWA,MAAM,QAAQ,QAAoB,YAAY;AAC9C,MAAM,OAA8B,OAAO,gBAAgB;AAE3D,MAAM,cAAc,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAgFxF,MAAa,aAAa;CAAE,MA7Ef,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAsC,SAAS,KAAA;GAAqB;GACnF,cAAc;IAAE,MAAM;IAAsC,SAAS;GAAgB;GACrF,UAAU;GACV,UAAU;GACV,UAAU;GACV,MAAM;GACN,MAAM;GACN,IAAI;EACN;EACA,OAAO,CAAC,gBAAgB,aAAa;EACrC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,QAAQ,eAAe;GAC7B,MAAM,QACJ,WAAW,OAAO,kBAAkB;IAAE;IAAO,WAAW,mBAAmB;GAAE,CAAC,UAAU;IACtF,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,cAAc,OAAgB,SAAwB;KACpD,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;GACF,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CA0C4B;CAAM,MAxCrB,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAsC,UAAU;GAAK;GACpE,UAAU,SAAS,OAAO;EAC5B;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAE7B,MAAM,QAAQ,MAAM;GACpB,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;GAC7D,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC;GACxC,MAAM,QAAQ,MAAM,IAAI;GACxB,MAAM,OAAO,MAAM,KAAK,OAAO,IAAI;GACnC,MAAM,QAAQ,MAAM,UAAU,OAAO,IAAI;GACzC,QAAQ,MAAM,KAAK;GACnB,MAAM,UAAU,cAAc,yBAAyB,cAAc,IAAI;GACzE,MAAM,QAAQ,cAAc,uBAAuB,eAAe,KAAK;GACvE,aAAa,EAAE,SAAS,aAAa,CAAC,MAAM,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC;EACpE;CACF,CAoBkC;CAAM,WAjBtB,gBAAgB;EAChC,MAAM;EACN,cAAc;EACd,OAAO,EAAE,aAAa,QAAQ;EAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,YAAY,MAAM,IAAI,CAAC,CAAC,UAAU,OAAO,IAAI,CAAC;GACpD,IAAI;GACJ,gBAAgB;IACd,OAAO,UAAU,MAAM;GACzB,CAAC;GACD,sBAAsB,OAAO,CAAC;GAC9B,MAAM,UAAU,WAAW,UAAU,OAAO;GAC5C,MAAM,UAAU,cAAc,8BAA8B,cAAc,UAAU,IAAI;GACxF,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,SAAS,OAAO,KAAK,IAAI;EAChF;CACF,CAEwC;AAAU"}
1
+ {"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/vue/src/radio-group.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type {\n RadioGroup as Controller,\n RadioGroupProps,\n RadioItemOptions,\n} from \"@kirana-ui/core/radio-group\"\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 { useFieldAround } from \"./field-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<\"radioGroup\">\n\nconst scope = context<Controller>(\"RadioGroup\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"RadioGroupItem\")\n\nconst RootElement = partComponent(\"RadioGroupRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps<Value = unknown> = Omit<RadioGroupProps<Value>, \"id\" | \"onValueChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\n/** The value is `null` when the group is put back to none chosen. */\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value | null>\n\n/** `v-model:value`, or `value` with `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"RadioGroupRoot\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, default: undefined as unknown },\n defaultValue: { type: null as unknown as PropType<unknown>, default: null as unknown },\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createRadioGroup, { field, direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\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 RadioItemOptions, PartComponentProps {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n}\n\nconst Item = defineComponent({\n name: \"RadioGroupItem\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, required: true },\n disabled: optional(Boolean),\n },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const options = toSignal(() => ({ disabled: props.disabled }))\n const read = () => defined(options.get())\n const group = scope.use()\n const item = group.item(value, read)\n const input = group.itemInput(value, read)\n provide(ITEM, value)\n const Input = partComponent(\"RadioGroupItemInput\", \"input\", () => input)\n // Its native input is the element's last child, whatever element the caller asked for.\n const Element = partComponent(\n \"RadioGroupItemElement\",\n \"span\",\n () => item,\n (content) => [content, h(Input)]\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"item\"], ItemProps>\n\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the mark in the page while its item is not the chosen one. */\nconst Indicator = defineComponent({\n name: \"RadioGroupIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const indicator = scope.use().indicator(inject(ITEM))\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = indicator.mount()\n })\n onBeforeUnmount(() => stop?.())\n const mounted = fromSignal(indicator.mounted)\n const Element = partComponent(\"RadioGroupIndicatorElement\", \"span\", () => indicator.part)\n return () => (mounted.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"indicator\"], IndicatorProps>\n\nexport const RadioGroup = { Root, Item, Indicator }\n"],"mappings":";;;;;;;AAyBA,MAAM,QAAQ,QAAoB,YAAY;AAC9C,MAAM,OAA8B,OAAO,gBAAgB;AAE3D,MAAM,cAAc,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAyGxF,MAAa,aAAa;CAAE,MA/Ff,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAsC,SAAS,KAAA;GAAqB;GACnF,cAAc;IAAE,MAAM;IAAsC,SAAS;GAAgB;GACrF,UAAU;GACV,UAAU;GACV,UAAU;GACV,MAAM;GACN,MAAM;GACN,IAAI;EACN;EACA,OAAO,CAAC,gBAAgB,aAAa;EACrC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,QAAQ,eAAe;GAC7B,MAAM,QACJ,WAAW,OAAO,kBAAkB;IAAE;IAAO,WAAW,mBAAmB;GAAE,CAAC,UAAU;IACtF,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,cAAc,OAAgB,SAAwB;KACpD,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;GACF,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CA4D4B;CAAM,MAnDrB,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO;IAAE,MAAM;IAAsC,UAAU;GAAK;GACpE,UAAU,SAAS,OAAO;EAC5B;EACA,MAAM,OAAO,EAAE,OAAO,SAAS;GAE7B,MAAM,QAAQ,MAAM;GACpB,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;GAC7D,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC;GACxC,MAAM,QAAQ,MAAM,IAAI;GACxB,MAAM,OAAO,MAAM,KAAK,OAAO,IAAI;GACnC,MAAM,QAAQ,MAAM,UAAU,OAAO,IAAI;GACzC,QAAQ,MAAM,KAAK;GACnB,MAAM,QAAQ,cAAc,uBAAuB,eAAe,KAAK;GAEvE,MAAM,UAAU,cACd,yBACA,cACM,OACL,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CACjC;GACA,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAyBkC;CAAM,WAjBtB,gBAAgB;EAChC,MAAM;EACN,cAAc;EACd,OAAO,EAAE,aAAa,QAAQ;EAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,YAAY,MAAM,IAAI,CAAC,CAAC,UAAU,OAAO,IAAI,CAAC;GACpD,IAAI;GACJ,gBAAgB;IACd,OAAO,UAAU,MAAM;GACzB,CAAC;GACD,sBAAsB,OAAO,CAAC;GAC9B,MAAM,UAAU,WAAW,UAAU,OAAO;GAC5C,MAAM,UAAU,cAAc,8BAA8B,cAAc,UAAU,IAAI;GACxF,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,SAAS,OAAO,KAAK,IAAI;EAChF;CACF,CAEwC;AAAU"}
@@ -1,48 +1,29 @@
1
- import { Orientation } from "@kirana-ui/core";
2
- import { PropType } from "vue";
1
+ import { PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { ChangeDetails } from "@kirana-ui/core";
3
+ import { ResizablePanelOptions, ResizableProps } from "@kirana-ui/core/resizable";
4
+ export type GroupProps = Omit<ResizableProps, "id" | "onSizesChange"> & {
5
+ id?: string | undefined;
6
+ } & PartComponentProps;
7
+ export type GroupEmits = {
8
+ /** The panels were resized: each one's share, in order. */
9
+ sizesChange: (sizes: number[], details: ChangeDetails) => void;
10
+ };
11
+ export interface PanelProps extends ResizablePanelOptions, PartComponentProps {}
12
+ export interface HandleProps extends PartComponentProps {
13
+ disabled?: boolean | undefined;
14
+ }
3
15
  export declare const Resizable: {
4
- Group: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
- orientation: PropType<Orientation>;
6
- keyboardStep: NumberConstructor;
7
- disabled: BooleanConstructor;
8
- id: StringConstructor;
9
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
10
- [key: string]: any;
11
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "sizesChange"[], "sizesChange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
12
- orientation: PropType<Orientation>;
13
- keyboardStep: NumberConstructor;
14
- disabled: BooleanConstructor;
15
- id: StringConstructor;
16
- }>> & Readonly<{
17
- onSizesChange?: ((...args: any[]) => any) | undefined;
18
- }>, {
19
- disabled: boolean;
20
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
21
- Panel: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
22
- defaultSize: NumberConstructor;
23
- minSize: NumberConstructor;
24
- maxSize: NumberConstructor;
25
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
26
- [key: string]: any;
27
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
28
- defaultSize: NumberConstructor;
29
- minSize: NumberConstructor;
30
- maxSize: NumberConstructor;
31
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
- Handle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
33
- disabled: {
34
- type: BooleanConstructor;
35
- default: undefined;
36
- };
37
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
38
- [key: string]: any;
39
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
40
- disabled: {
41
- type: BooleanConstructor;
42
- default: undefined;
43
- };
44
- }>> & Readonly<{}>, {
45
- disabled: boolean;
46
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
16
+ Group: PartComponent<"div", {
17
+ readonly orientation?: "horizontal" | "vertical" | undefined;
18
+ readonly disabled?: true | undefined;
19
+ }, GroupProps, GroupEmits>;
20
+ Panel: PartComponent<"div", {
21
+ readonly orientation?: "horizontal" | "vertical" | undefined;
22
+ }, PanelProps>;
23
+ Handle: PartComponent<"div", {
24
+ readonly orientation?: "horizontal" | "vertical" | undefined;
25
+ readonly dragging?: true | undefined;
26
+ readonly disabled?: true | undefined;
27
+ }, HandleProps>;
47
28
  };
48
29
  //# sourceMappingURL=resizable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/vue/src/resizable.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createResizable } from \"@kirana-ui/core/resizable\"\nimport type { Resizable as Controller } from \"@kirana-ui/core/resizable\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, optional, partComponent, toSignal } from \"./runtime.ts\"\n\nconst scope = context<Controller>(\"Resizable\")\n\nconst GroupElement = partComponent(\"ResizableGroupElement\", \"div\", () => scope.use().group)\n\n/** `@sizes-change=\"(sizes, details) => …\"` as the panels are resized. */\nconst Group = defineComponent({\n name: \"ResizableGroup\",\n inheritAttrs: false,\n props: {\n orientation: String as PropType<Orientation>,\n keyboardStep: Number,\n disabled: Boolean,\n id: String,\n },\n emits: [\"sizesChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createResizable, { direction }), () => ({\n id: props.id ?? generated,\n orientation: props.orientation,\n keyboardStep: props.keyboardStep,\n disabled: props.disabled,\n onSizesChange: (sizes: number[], details: ChangeDetails) =>\n emit(\"sizesChange\", sizes, details),\n }))\n )\n return () => h(GroupElement, attrs, slots)\n },\n})\n\nconst Panel = defineComponent({\n name: \"ResizablePanel\",\n inheritAttrs: false,\n props: { defaultSize: Number, minSize: Number, maxSize: Number },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().panel(() => defined(options.get()))\n const Element = partComponent(\"ResizablePanelElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n})\n\nconst Handle = defineComponent({\n name: \"ResizableHandle\",\n inheritAttrs: false,\n props: { disabled: optional(Boolean) },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const part = scope.use().handle(() => defined(options.get()))\n const Element = partComponent(\"ResizableHandleElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n})\n\nexport const Resizable = { Group, Panel, Handle }\n"],"mappings":";;;;;;AAUA,MAAM,QAAQ,QAAoB,WAAW;AAE7C,MAAM,eAAe,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;AAsD1F,MAAa,YAAY;CAAE,OAnDb,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GACL,aAAa;GACb,cAAc;GACd,UAAU;GACV,IAAI;EACN;EACA,OAAO,CAAC,aAAa;EACrB,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,YAAY,mBAAmB;GACrC,MAAM,QACJ,WAAW,OAAO,iBAAiB,EAAE,UAAU,CAAC,UAAU;IACxD,IAAI,MAAM,MAAM;IAChB,aAAa,MAAM;IACnB,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,gBAAgB,OAAiB,YAC/B,KAAK,eAAe,OAAO,OAAO;GACtC,EAAE,CACJ;GACA,aAAa,EAAE,cAAc,OAAO,KAAK;EAC3C;CACF,CA0B2B;CAAO,OAxBpB,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GAAE,aAAa;GAAQ,SAAS;GAAQ,SAAS;EAAO;EAC/D,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,gBAAgB,EAAE,GAAG,MAAM,EAAE;GAC7C,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,YAAY,QAAQ,QAAQ,IAAI,CAAC,CAAC;GAC3D,MAAM,UAAU,cAAc,yBAAyB,aAAa,IAAI;GACxE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAckC;CAAO,QAZ1B,gBAAgB;EAC7B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,UAAU,SAAS,OAAO,EAAE;EACrC,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;GAC7D,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC;GAC5D,MAAM,UAAU,cAAc,0BAA0B,aAAa,IAAI;GACzE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAEyC;AAAO"}
1
+ {"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/vue/src/resizable.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createResizable } from \"@kirana-ui/core/resizable\"\nimport type {\n Resizable as Controller,\n ResizablePanelOptions,\n ResizableProps,\n} from \"@kirana-ui/core/resizable\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type { PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"resizable\">\n\nconst scope = context<Controller>(\"Resizable\")\n\nconst GroupElement = partComponent(\"ResizableGroupElement\", \"div\", () => scope.use().group)\n\nexport type GroupProps = Omit<ResizableProps, \"id\" | \"onSizesChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type GroupEmits = {\n /** The panels were resized: each one's share, in order. */\n sizesChange: (sizes: number[], details: ChangeDetails) => void\n}\n\n/** `@sizes-change=\"(sizes, details) => …\"` as the panels are resized. */\nconst Group = defineComponent({\n name: \"ResizableGroup\",\n inheritAttrs: false,\n props: {\n orientation: String as PropType<Orientation>,\n keyboardStep: Number,\n disabled: Boolean,\n id: String,\n },\n emits: [\"sizesChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createResizable, { direction }), () => ({\n id: props.id ?? generated,\n orientation: props.orientation,\n keyboardStep: props.keyboardStep,\n disabled: props.disabled,\n onSizesChange: (sizes: number[], details: ChangeDetails) =>\n emit(\"sizesChange\", sizes, details),\n }))\n )\n return () => h(GroupElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps, GroupEmits>\n\nexport interface PanelProps extends ResizablePanelOptions, PartComponentProps {}\n\nconst Panel = defineComponent({\n name: \"ResizablePanel\",\n inheritAttrs: false,\n props: { defaultSize: Number, minSize: Number, maxSize: Number },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().panel(() => defined(options.get()))\n const Element = partComponent(\"ResizablePanelElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"panel\"], PanelProps>\n\nexport interface HandleProps extends PartComponentProps {\n disabled?: boolean | undefined\n}\n\nconst Handle = defineComponent({\n name: \"ResizableHandle\",\n inheritAttrs: false,\n props: { disabled: optional(Boolean) },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const part = scope.use().handle(() => defined(options.get()))\n const Element = partComponent(\"ResizableHandleElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"handle\"], HandleProps>\n\nexport const Resizable = { Group, Panel, Handle }\n"],"mappings":";;;;;;AAiBA,MAAM,QAAQ,QAAoB,WAAW;AAE7C,MAAM,eAAe,cAAc,yBAAyB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;AAqE1F,MAAa,YAAY;CAAE,OAzDb,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GACL,aAAa;GACb,cAAc;GACd,UAAU;GACV,IAAI;EACN;EACA,OAAO,CAAC,aAAa;EACrB,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,YAAY,mBAAmB;GACrC,MAAM,QACJ,WAAW,OAAO,iBAAiB,EAAE,UAAU,CAAC,UAAU;IACxD,IAAI,MAAM,MAAM;IAChB,aAAa,MAAM;IACnB,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,gBAAgB,OAAiB,YAC/B,KAAK,eAAe,OAAO,OAAO;GACtC,EAAE,CACJ;GACA,aAAa,EAAE,cAAc,OAAO,KAAK;EAC3C;CACF,CAgC2B;CAAO,OA5BpB,gBAAgB;EAC5B,MAAM;EACN,cAAc;EACd,OAAO;GAAE,aAAa;GAAQ,SAAS;GAAQ,SAAS;EAAO;EAC/D,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,gBAAgB,EAAE,GAAG,MAAM,EAAE;GAC7C,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,YAAY,QAAQ,QAAQ,IAAI,CAAC,CAAC;GAC3D,MAAM,UAAU,cAAc,yBAAyB,aAAa,IAAI;GACxE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAkBkC;CAAO,QAZ1B,gBAAgB;EAC7B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,UAAU,SAAS,OAAO,EAAE;EACrC,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,gBAAgB,EAAE,UAAU,MAAM,SAAS,EAAE;GAC7D,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC;GAC5D,MAAM,UAAU,cAAc,0BAA0B,aAAa,IAAI;GACzE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAEyC;AAAO"}
package/src/runtime.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { Part, ReadonlySignal } from "@kirana-ui/core";
2
- import { Component, PropType, ShallowRef, VNode } from "vue";
1
+ import { Hold, written } from "./element.js";
2
+ import { ChangeDetails, Part, PartDefinition, PartEvent, PartState, ReadonlySignal, StateOf } from "@kirana-ui/core";
3
+ import { DefineSetupFnComponent, HTMLAttributes, IntrinsicElementAttributes, ObjectEmitsOptions, PublicProps, ShallowRef, SlotsType, VNode } from "vue";
4
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
3
5
  /** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */
4
6
  export declare function fromSignal<T>(source: ReadonlySignal<T>): Readonly<ShallowRef<T>>;
5
7
  /** A core signal that follows Vue state: the core hears a changed prop as it changes. */
@@ -13,36 +15,106 @@ export declare function context<C>(name: string): {
13
15
  provide(controller: C): C;
14
16
  use(): C;
15
17
  };
18
+ /**
19
+ * The state of each part of a component, by their names in the vocabulary: what a part's
20
+ * `data-*` attributes say, and what its default slot is given as `state`.
21
+ */
22
+ export type StatesOf<Name extends keyof Vocabulary> = { [Each in keyof Vocabulary[Name]]: Vocabulary[Name][Each] extends (infer Definition extends PartDefinition) ? StateOf<Definition> : never; };
23
+ /** What every part takes besides its own props and its element's attributes. */
24
+ export interface PartComponentProps {
25
+ /** Another tag for the part's element (`as="a"`): its attributes are then that tag's. */
26
+ as?: string | undefined;
27
+ /** Draws the element in the part's slot in place of the part's own: it takes the part's props. */
28
+ asChild?: boolean | undefined;
29
+ }
30
+ type Hearing<Prop> = Prop extends ((event: infer Heard) => infer Answer) ? Heard extends Event ? (event: PartEvent<Heard>) => Answer : Prop : Prop;
31
+ type Heard<Attributes> = { [Name in keyof Attributes]: Hearing<Attributes[Name]>; };
32
+ /**
33
+ * What the element of a tag takes, listeners included (`onClick` is `@click`, its event a
34
+ * `MouseEvent` with `preventKiranaHandler()`, which keeps the part's own listener out of it):
35
+ * Vue's own attributes for the tag, a plain element's for a tag Vue does not know, and any
36
+ * `data-*` attribute.
37
+ */
38
+ export type ElementAttributes<Tag extends string> = Heard<Tag extends keyof IntrinsicElementAttributes ? IntrinsicElementAttributes[Tag] : HTMLAttributes> & {
39
+ [name: `data${string}`]: unknown;
40
+ };
41
+ /** A component's events as the listeners among its props: `openChange` is `onOpenChange`. */
42
+ export type Listeners<Emits> = { [Name in keyof Emits & string as `on${Capitalize<Name>}`]?: Emits[Name]; };
43
+ /**
44
+ * The two events of a value its caller may hold: `update:open`, which `v-model:open` hears,
45
+ * and `openChange`, which also carries the details and may cancel the change.
46
+ */
47
+ export type Changes<Name extends string, Value, Details = ChangeDetails> = { [Event in `update:${Name}`]: (value: Value) => void; } & { [Event in `${Name}Change`]: (value: Value, details: Details) => void; };
48
+ /**
49
+ * What a caller may hand a part drawn as `Tag`: the part's own props, a listener for each of
50
+ * its events, and what the element takes. A prop or an event of the part's that an attribute
51
+ * of the element shares a name with (`value`, `disabled`, `onSelect`) is the part's.
52
+ */
53
+ export type PartGiven<Tag extends string, Props, Emits = {}> = Props & {
54
+ as?: Tag | undefined;
55
+ } & Listeners<Emits> & Omit<ElementAttributes<Tag>, keyof Props | keyof Listeners<Emits>>;
56
+ /** A component's default slot, given `Slot`. */
57
+ export type DefaultSlot<Slot> = SlotsType<{
58
+ default?: (props: Slot) => VNode[];
59
+ }>;
60
+ /** A part's instance, as Vue's own tools read a component: its props, its events, its slot. */
61
+ export type PartInstance<Tag extends string, Props, Emits extends ObjectEmitsOptions, Slot> = InstanceType<DefineSetupFnComponent<PartGiven<Tag, Props, Emits>, Emits, DefaultSlot<Slot>, PartGiven<Tag, Props, Emits>>>;
62
+ /**
63
+ * A part as its callers see it. `Tag` is the element it draws, and `as` another: the part
64
+ * takes the attributes and listeners of whichever it is. `State` is what its default slot is
65
+ * given as `state` (`StateOf` its entry in the vocabulary), with `Given` beside it when the
66
+ * part hands its slot more. `Props` are the part's own, `Emits` its events with their payloads.
67
+ *
68
+ * A part whose value has a type of its caller's (a root with `value`) writes the same
69
+ * signature out with that type as a parameter: `new <Value, As extends string = "div">(props:
70
+ * PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps) => PartInstance<…>`.
71
+ */
72
+ export type PartComponent<Tag extends string, State = PartState, Props = PartComponentProps, Emits extends ObjectEmitsOptions = {}, Given = unknown> = new <As extends string = Tag>(props: PartGiven<As, Props, Emits> & PublicProps) => PartInstance<As, Props, Emits, {
73
+ state: State;
74
+ } & Given>;
75
+ /**
76
+ * A component that draws no element of its own (a root that only provides, a portal, a list
77
+ * that draws its slot once for each entry): its props, its events, what its slot is given.
78
+ */
79
+ export type PlainComponent<Props = {}, Emits extends ObjectEmitsOptions = {}, Slot = {}> = DefineSetupFnComponent<Props & Listeners<Emits>, Emits, DefaultSlot<Slot>, Props & Listeners<Emits>>;
80
+ /** The instance of a `PlainComponent`, for one whose value has a type of its caller's. */
81
+ export type PlainInstance<Props, Emits extends ObjectEmitsOptions, Slot> = InstanceType<PlainComponent<Props, Emits, Slot>>;
82
+ /**
83
+ * A component's instance as its element: its root, or with several roots the first element
84
+ * after the fragment's own mark.
85
+ */
86
+ export declare function elementOf(instance: unknown): Element | null;
16
87
  /**
17
88
  * A part as a component: its element (`as`, the part's own tag by default), or with `as-child`
18
- * the caller's own element in its slot, which takes the part's props. Either way the caller's
19
- * attributes are merged under the part's, and the part's DOM work is attached to the element.
89
+ * the caller's own element in its slot, which takes the part's props, and the part's DOM work
90
+ * attached to the element. Three layers of props, lowest first: the attributes on the part,
91
+ * the slotted element's own, the part's. A higher layer wins an attribute; classes join;
92
+ * styles are merged; every listener of an event runs, lowest first, and
93
+ * `event.preventKiranaHandler()` in a caller's stops the part's. The default slot is given the
94
+ * part's state (`{ state }`: `open`, `side` …, read from its `data-*` attributes), typed by
95
+ * `State`. `hold` is for a part that keeps something of its own in its element (a hidden
96
+ * input, the text it writes: `written`): it is given the content and returns what the element
97
+ * holds, whoever drew the element.
20
98
  */
21
- export declare function partComponent(name: string, tag: string, resolve: () => Part): Component;
99
+ export declare function partComponent<Tag extends string, State = PartState>(name: string, tag: Tag, resolve: () => Part, hold?: Hold): PartComponent<Tag, State>;
100
+ /** What `PortalProvider` takes. */
101
+ export interface PortalProviderProps {
102
+ /** Where the popups are drawn; `<body>` when left out, or while there is none. */
103
+ container?: HTMLElement | null | undefined;
104
+ }
22
105
  /**
23
106
  * Says where every popup inside it is drawn, the popups those open included: an element of
24
107
  * the page (a shadow root's host, a full-screen element) in place of `<body>`.
25
108
  */
26
- export declare const PortalProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
27
- container: {
28
- type: PropType<HTMLElement | null>;
29
- default: undefined;
30
- };
31
- }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
32
- [key: string]: any;
33
- }>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
34
- container: {
35
- type: PropType<HTMLElement | null>;
36
- default: undefined;
37
- };
38
- }>> & Readonly<{}>, {
39
- container: HTMLElement | null;
40
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
109
+ export declare const PortalProvider: PlainComponent<PortalProviderProps>;
110
+ /** A portal takes nothing: where it is drawn is its `PortalProvider`'s to say. */
111
+ export type PortalProps = Record<never, never>;
41
112
  /** Its slot in a container at the end of the page, while `mounted`. */
42
- export declare function portalComponent(name: string, mounted: () => ReadonlySignal<boolean>): Component;
113
+ export declare function portalComponent(name: string, mounted: () => ReadonlySignal<boolean>): PlainComponent<PortalProps>;
43
114
  /** A prop that is "not given" when absent, where Vue would make a boolean `false`. */
44
115
  export declare const optional: <T>(type: T) => {
45
116
  type: T;
46
117
  default: undefined;
47
118
  };
119
+ export { type Hold, type PartEvent, written };
48
120
  //# sourceMappingURL=runtime.d.ts.map