@kirana-ui/vue 0.3.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 (106) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1495 -119
  3. package/package.json +44 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +24 -4
  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/autocomplete.d.ts +2 -2
  9. package/src/avatar.js +2 -2
  10. package/src/avatar.js.map +1 -1
  11. package/src/button.d.ts +4 -1
  12. package/src/button.js +4 -1
  13. package/src/button.js.map +1 -1
  14. package/src/calendar.d.ts +5 -2
  15. package/src/calendar.js +8 -2
  16. package/src/calendar.js.map +1 -1
  17. package/src/carousel.d.ts +5 -2
  18. package/src/carousel.js +1 -4
  19. package/src/carousel.js.map +1 -1
  20. package/src/checkbox.d.ts +16 -0
  21. package/src/checkbox.js.map +1 -1
  22. package/src/collapsible.d.ts +2 -0
  23. package/src/color-picker.d.ts +118 -0
  24. package/src/color-picker.js +174 -0
  25. package/src/color-picker.js.map +1 -0
  26. package/src/combobox.d.ts +82 -4
  27. package/src/combobox.js +32 -9
  28. package/src/combobox.js.map +1 -1
  29. package/src/command.d.ts +2 -2
  30. package/src/command.js +1 -1
  31. package/src/command.js.map +1 -1
  32. package/src/date-field.d.ts +1 -1
  33. package/src/date-field.js +2 -0
  34. package/src/date-field.js.map +1 -1
  35. package/src/date-picker.d.ts +33 -10
  36. package/src/date-picker.js +103 -61
  37. package/src/date-picker.js.map +1 -1
  38. package/src/dialog.d.ts +22 -8
  39. package/src/dialog.js +40 -7
  40. package/src/dialog.js.map +1 -1
  41. package/src/editable.d.ts +87 -0
  42. package/src/editable.js +83 -0
  43. package/src/editable.js.map +1 -0
  44. package/src/element.js +5 -5
  45. package/src/element.js.map +1 -1
  46. package/src/file-upload.d.ts +76 -0
  47. package/src/file-upload.js +139 -0
  48. package/src/file-upload.js.map +1 -0
  49. package/src/hover-card.d.ts +3 -0
  50. package/src/index.d.ts +27 -9
  51. package/src/index.js +11 -1
  52. package/src/menu.d.ts +10 -0
  53. package/src/menu.js +17 -6
  54. package/src/menu.js.map +1 -1
  55. package/src/menubar.js +10 -1
  56. package/src/menubar.js.map +1 -1
  57. package/src/navigation-menu.d.ts +14 -3
  58. package/src/navigation-menu.js +20 -2
  59. package/src/navigation-menu.js.map +1 -1
  60. package/src/otp.d.ts +25 -3
  61. package/src/otp.js +20 -3
  62. package/src/otp.js.map +1 -1
  63. package/src/password-input.d.ts +37 -0
  64. package/src/password-input.js +44 -0
  65. package/src/password-input.js.map +1 -0
  66. package/src/popover.d.ts +6 -1
  67. package/src/popover.js +1 -1
  68. package/src/radio-group.d.ts +12 -0
  69. package/src/rating.d.ts +34 -0
  70. package/src/rating.js +81 -0
  71. package/src/rating.js.map +1 -0
  72. package/src/runtime.d.ts +2 -1
  73. package/src/runtime.js +5 -2
  74. package/src/runtime.js.map +1 -1
  75. package/src/scroll-area.d.ts +24 -1
  76. package/src/select.d.ts +38 -5
  77. package/src/select.js +28 -9
  78. package/src/select.js.map +1 -1
  79. package/src/slider.d.ts +30 -0
  80. package/src/steps.d.ts +74 -0
  81. package/src/steps.js +84 -0
  82. package/src/steps.js.map +1 -0
  83. package/src/switch.d.ts +12 -0
  84. package/src/tabs.d.ts +2 -0
  85. package/src/tabs.js +5 -0
  86. package/src/tabs.js.map +1 -1
  87. package/src/tags-input.d.ts +69 -0
  88. package/src/tags-input.js +145 -0
  89. package/src/tags-input.js.map +1 -0
  90. package/src/time-field.d.ts +41 -0
  91. package/src/time-field.js +85 -0
  92. package/src/time-field.js.map +1 -0
  93. package/src/toast.d.ts +12 -4
  94. package/src/toggle-group.js +6 -0
  95. package/src/toggle-group.js.map +1 -1
  96. package/src/toolbar-context.d.ts +1 -1
  97. package/src/toolbar.d.ts +4 -1
  98. package/src/toolbar.js +17 -2
  99. package/src/toolbar.js.map +1 -1
  100. package/src/tooltip.d.ts +5 -0
  101. package/src/tour.d.ts +75 -0
  102. package/src/tour.js +95 -0
  103. package/src/tour.js.map +1 -0
  104. package/src/tree.d.ts +69 -0
  105. package/src/tree.js +118 -0
  106. package/src/tree.js.map +1 -0
@@ -7,6 +7,7 @@ import { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
7
7
  // src/navigation-menu.ts
8
8
  const scope = context("NavigationMenu");
9
9
  const ITEM = Symbol("NavigationMenuItem");
10
+ const OUTER = Symbol("NavigationMenuOuter");
10
11
  const ANY = null;
11
12
  function useItem() {
12
13
  const item = inject(ITEM, void 0);
@@ -36,7 +37,11 @@ const Root = defineComponent({
36
37
  setup(props, { attrs, slots, emit }) {
37
38
  const generated = useId();
38
39
  const direction = useDirectionAround();
39
- scope.provide(controller(within(createNavigationMenu, { direction }), () => ({
40
+ const parent = inject(OUTER, void 0);
41
+ const made = scope.provide(controller(within(createNavigationMenu, {
42
+ direction,
43
+ parent
44
+ }), () => ({
40
45
  id: props.id ?? generated,
41
46
  value: props.value,
42
47
  defaultValue: props.defaultValue,
@@ -48,6 +53,7 @@ const Root = defineComponent({
48
53
  if (!details.canceled) emit("update:value", value);
49
54
  }
50
55
  })));
56
+ provide(OUTER, made);
51
57
  return () => h(RootElement, attrs, slots);
52
58
  }
53
59
  });
@@ -89,6 +95,7 @@ const Link = defineComponent({
89
95
  inheritAttrs: false,
90
96
  props: {
91
97
  active: optional(Boolean),
98
+ closeOnSelect: optional(Boolean),
92
99
  closeOnClick: optional(Boolean)
93
100
  },
94
101
  setup(props, { attrs, slots }) {
@@ -98,11 +105,22 @@ const Link = defineComponent({
98
105
  return () => h(Element, attrs, slots);
99
106
  }
100
107
  });
108
+ const Trigger = defineComponent({
109
+ name: "NavigationMenuTrigger",
110
+ inheritAttrs: false,
111
+ props: { disabled: Boolean },
112
+ setup(props, { attrs, slots }) {
113
+ const options = toSignal(() => ({ disabled: props.disabled }));
114
+ const part = useItem().triggerPart(() => options.get());
115
+ const Element = partComponent("NavigationMenuTriggerElement", "button", () => part);
116
+ return () => h(Element, attrs, slots);
117
+ }
118
+ });
101
119
  const NavigationMenu = {
102
120
  Root,
103
121
  List: partComponent("NavigationMenuList", "ul", () => scope.use().list),
104
122
  Item,
105
- Trigger: partComponent("NavigationMenuTrigger", "button", () => useItem().trigger),
123
+ Trigger,
106
124
  Icon: partComponent("NavigationMenuIcon", "span", () => useItem().icon),
107
125
  Content,
108
126
  Link,
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/vue/src/navigation-menu.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu as Controller,\n NavigationMenuItem,\n NavigationMenuLinkOptions,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\nimport {\n Teleport,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n useId,\n} from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { positionerComponent } from \"./popover.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"navigationMenu\">\n\nconst scope = context<Controller>(\"NavigationMenu\")\nconst ITEM: InjectionKey<NavigationMenuItem> = Symbol(\"NavigationMenuItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nfunction useItem(): NavigationMenuItem {\n const item = inject(ITEM, undefined)\n if (!item) throw new Error(\"A NavigationMenu part must be inside <NavigationMenu.Item>\")\n return item\n}\n\nconst RootElement = partComponent(\"NavigationMenuRootElement\", \"nav\", () => scope.use().root)\n\nexport type RootProps<Value = unknown> = Omit<\n NavigationMenuProps<Value>,\n \"id\" | \"onValueChange\"\n> & {\n id?: string | undefined\n} & PartComponentProps\n\n/** The value is `null` when the menu closes. */\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value | null>\n\n/** `v-model:value`; `@value-change` carries the details. */\nconst Root = defineComponent({\n name: \"NavigationMenuRoot\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n delay: Number,\n closeDelay: Number,\n orientation: String as PropType<Orientation>,\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(createNavigationMenu, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n delay: props.delay,\n closeDelay: props.closeDelay,\n orientation: props.orientation,\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 = \"nav\">(\n props: PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps\n) => PartInstance<As, RootProps<Value>, RootEmits<Value>, { state: State[\"root\"] }>\n\nconst ItemElement = partComponent(\"NavigationMenuItemElement\", \"li\", () => scope.use().itemPart)\n\nexport interface ItemProps extends PartComponentProps {\n /**\n * What tells this item from the others: the menu's `value` while its content is shown. An\n * item that is given none makes its own.\n */\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: \"NavigationMenuItem\",\n inheritAttrs: false,\n props: { value: { type: ANY, default: undefined as unknown } },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const item = scope.use().item(props.value === undefined ? generated : props.value)\n provide(ITEM, item)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = item.mount()\n })\n onBeforeUnmount(() => stop?.())\n return () => h(ItemElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"li\", State[\"item\"], ItemProps>\n\nexport type ContentProps = PartComponentProps\n\n/** An item's content: drawn in `NavigationMenu.Viewport`, while it is shown. */\nconst Content = defineComponent({\n name: \"NavigationMenuContent\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const item = useItem()\n const mounted = fromSignal(item.mounted)\n const viewport = fromSignal(scope.use().viewportElement)\n const Element = partComponent(\"NavigationMenuContentElement\", \"div\", () => item.content)\n return () =>\n mounted.value && viewport.value\n ? h(Teleport, { to: viewport.value }, h(Element, attrs, slots))\n : null\n },\n}) as unknown as PartComponent<\"div\", State[\"content\"], ContentProps>\n\nexport interface LinkProps extends NavigationMenuLinkOptions, PartComponentProps {}\n\nconst Link = defineComponent({\n name: \"NavigationMenuLink\",\n inheritAttrs: false,\n props: { active: optional(Boolean), closeOnClick: optional(Boolean) },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().link(() => defined(options.get()))\n const Element = partComponent(\"NavigationMenuLinkElement\", \"a\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"a\", State[\"link\"], LinkProps>\n\nexport type ListProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport type IconProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type ViewportProps = PartComponentProps\nexport type ArrowProps = PartComponentProps\nexport type BackdropProps = PartComponentProps\nexport const NavigationMenu = {\n Root,\n List: partComponent<\"ul\", State[\"list\"]>(\"NavigationMenuList\", \"ul\", () => scope.use().list),\n Item,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"NavigationMenuTrigger\",\n \"button\",\n () => useItem().trigger\n ),\n Icon: partComponent<\"span\", State[\"icon\"]>(\"NavigationMenuIcon\", \"span\", () => useItem().icon),\n Content,\n Link,\n Portal: portalComponent(\"NavigationMenuPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"NavigationMenuPositioner\",\n () => scope.use(),\n partComponent(\"NavigationMenuPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\n \"NavigationMenuPopup\",\n \"div\",\n () => scope.use().popup\n ),\n Viewport: partComponent<\"div\", State[\"viewport\"]>(\n \"NavigationMenuViewport\",\n \"div\",\n () => scope.use().viewport\n ),\n Arrow: partComponent<\"div\", State[\"arrow\"]>(\n \"NavigationMenuArrow\",\n \"div\",\n () => scope.use().arrow\n ),\n Backdrop: partComponent<\"div\", State[\"backdrop\"]>(\n \"NavigationMenuBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/vue/src/navigation-menu.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu as Controller,\n NavigationMenuItem,\n NavigationMenuLinkOptions,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\nimport {\n Teleport,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n useId,\n} from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { positionerComponent } from \"./popover.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"navigationMenu\">\n\nconst scope = context<Controller>(\"NavigationMenu\")\nconst ITEM: InjectionKey<NavigationMenuItem> = Symbol(\"NavigationMenuItem\")\n// The menu a root is inside, if any: a menu in another's content is nested.\nconst OUTER: InjectionKey<Controller> = Symbol(\"NavigationMenuOuter\")\nconst ANY = null as unknown as PropType<unknown>\n\nfunction useItem(): NavigationMenuItem {\n const item = inject(ITEM, undefined)\n if (!item) throw new Error(\"A NavigationMenu part must be inside <NavigationMenu.Item>\")\n return item\n}\n\nconst RootElement = partComponent(\"NavigationMenuRootElement\", \"nav\", () => scope.use().root)\n\nexport type RootProps<Value = unknown> = Omit<\n NavigationMenuProps<Value>,\n \"id\" | \"onValueChange\"\n> & {\n id?: string | undefined\n} & PartComponentProps\n\n/** The value is `null` when the menu closes. */\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value | null>\n\n/** `v-model:value`; `@value-change` carries the details. */\nconst Root = defineComponent({\n name: \"NavigationMenuRoot\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n delay: Number,\n closeDelay: Number,\n orientation: String as PropType<Orientation>,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n const parent = inject(OUTER, undefined)\n const made = scope.provide(\n controller(within(createNavigationMenu, { direction, parent }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n delay: props.delay,\n closeDelay: props.closeDelay,\n orientation: props.orientation,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n }))\n )\n provide(OUTER, made)\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as new <Value = unknown, As extends string = \"nav\">(\n props: PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps\n) => PartInstance<As, RootProps<Value>, RootEmits<Value>, { state: State[\"root\"] }>\n\nconst ItemElement = partComponent(\"NavigationMenuItemElement\", \"li\", () => scope.use().itemPart)\n\nexport interface ItemProps extends PartComponentProps {\n /**\n * What tells this item from the others: the menu's `value` while its content is shown. An\n * item that is given none makes its own.\n */\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: \"NavigationMenuItem\",\n inheritAttrs: false,\n props: { value: { type: ANY, default: undefined as unknown } },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const item = scope.use().item(props.value === undefined ? generated : props.value)\n provide(ITEM, item)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = item.mount()\n })\n onBeforeUnmount(() => stop?.())\n return () => h(ItemElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"li\", State[\"item\"], ItemProps>\n\nexport type ContentProps = PartComponentProps\n\n/** An item's content: drawn in `NavigationMenu.Viewport`, while it is shown. */\nconst Content = defineComponent({\n name: \"NavigationMenuContent\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const item = useItem()\n const mounted = fromSignal(item.mounted)\n const viewport = fromSignal(scope.use().viewportElement)\n const Element = partComponent(\"NavigationMenuContentElement\", \"div\", () => item.content)\n return () =>\n mounted.value && viewport.value\n ? h(Teleport, { to: viewport.value }, h(Element, attrs, slots))\n : null\n },\n}) as unknown as PartComponent<\"div\", State[\"content\"], ContentProps>\n\nexport interface LinkProps extends NavigationMenuLinkOptions, PartComponentProps {}\n\nconst Link = defineComponent({\n name: \"NavigationMenuLink\",\n inheritAttrs: false,\n props: {\n active: optional(Boolean),\n closeOnSelect: optional(Boolean),\n closeOnClick: optional(Boolean),\n },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ ...props }))\n const part = scope.use().link(() => defined(options.get()))\n const Element = partComponent(\"NavigationMenuLinkElement\", \"a\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"a\", State[\"link\"], LinkProps>\n\nexport type ListProps = PartComponentProps\nexport interface TriggerProps extends PartComponentProps {\n /** The trigger cannot be pressed, and the pointer resting on it shows nothing. */\n disabled?: boolean | undefined\n}\nexport type IconProps = PartComponentProps\n\nconst Trigger = defineComponent({\n name: \"NavigationMenuTrigger\",\n inheritAttrs: false,\n props: { disabled: Boolean },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ disabled: props.disabled }))\n const part = useItem().triggerPart(() => options.get())\n const Element = partComponent(\"NavigationMenuTriggerElement\", \"button\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"trigger\"], TriggerProps>\nexport type PopupProps = PartComponentProps\nexport type ViewportProps = PartComponentProps\nexport type ArrowProps = PartComponentProps\nexport type BackdropProps = PartComponentProps\nexport const NavigationMenu = {\n Root,\n List: partComponent<\"ul\", State[\"list\"]>(\"NavigationMenuList\", \"ul\", () => scope.use().list),\n Item,\n Trigger,\n Icon: partComponent<\"span\", State[\"icon\"]>(\"NavigationMenuIcon\", \"span\", () => useItem().icon),\n Content,\n Link,\n Portal: portalComponent(\"NavigationMenuPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"NavigationMenuPositioner\",\n () => scope.use(),\n partComponent(\"NavigationMenuPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\n \"NavigationMenuPopup\",\n \"div\",\n () => scope.use().popup\n ),\n Viewport: partComponent<\"div\", State[\"viewport\"]>(\n \"NavigationMenuViewport\",\n \"div\",\n () => scope.use().viewport\n ),\n Arrow: partComponent<\"div\", State[\"arrow\"]>(\n \"NavigationMenuArrow\",\n \"div\",\n () => scope.use().arrow\n ),\n Backdrop: partComponent<\"div\", State[\"backdrop\"]>(\n \"NavigationMenuBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n}\n"],"mappings":"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"}
package/src/otp.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { ChangeDetails } from "@kirana-ui/core";
2
3
  import { OtpProps } from "@kirana-ui/core/otp";
3
- export type RootProps = Omit<OtpProps, "id" | "onValueChange" | "onComplete"> & {
4
+ export type RootProps = Omit<OtpProps, "id" | "onValueChange" | "onValueComplete" | "onComplete"> & {
4
5
  id?: string | undefined;
5
6
  } & PartComponentProps;
6
7
  export type RootEmits = Changes<"value", string> & {
7
- /** The finished code, once every cell is filled. */
8
+ /** The finished code, once every cell is filled, with the details of the change that did it. */
9
+ valueComplete: (value: string, details: ChangeDetails) => void;
10
+ /**
11
+ * The finished code.
12
+ * @deprecated Base UI's name is `valueComplete`, which is told the details too. Both are
13
+ * emitted: a listener cannot be told from none.
14
+ */
8
15
  complete: (value: string) => void;
9
16
  };
10
17
  export interface SlotProps extends PartComponentProps {
@@ -18,18 +25,33 @@ export type SeparatorProps = PartComponentProps;
18
25
  export declare const Otp: {
19
26
  Root: PartComponent<"div", {
20
27
  readonly disabled?: true | undefined;
28
+ readonly readonly?: true | undefined;
29
+ readonly required?: true | undefined;
30
+ readonly touched?: true | undefined;
31
+ readonly dirty?: true | undefined;
32
+ readonly valid?: true | undefined;
33
+ readonly invalid?: true | undefined;
21
34
  readonly focused?: true | undefined;
22
35
  readonly complete?: true | undefined;
36
+ readonly filled?: true | undefined;
23
37
  }, RootProps, RootEmits>;
24
38
  Input: PartComponent<"input", {
25
39
  readonly disabled?: true | undefined;
26
40
  }, PartComponentProps, {}, unknown>;
27
41
  Group: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
28
42
  Slot: PartComponent<"div", {
43
+ readonly disabled?: true | undefined;
44
+ readonly readonly?: true | undefined;
45
+ readonly required?: true | undefined;
46
+ readonly touched?: true | undefined;
47
+ readonly dirty?: true | undefined;
48
+ readonly valid?: true | undefined;
49
+ readonly invalid?: true | undefined;
50
+ readonly focused?: true | undefined;
51
+ readonly complete?: true | undefined;
29
52
  readonly index?: true | undefined;
30
53
  readonly active?: true | undefined;
31
54
  readonly filled?: true | undefined;
32
- readonly disabled?: true | undefined;
33
55
  }, SlotProps>;
34
56
  Separator: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
35
57
  Caret: PartComponent<"div", Record<never, never>, PartComponentProps>;
package/src/otp.js CHANGED
@@ -1,11 +1,13 @@
1
+ import { useFieldAround } from "./field-context.js";
1
2
  import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
3
+ import { within } from "@kirana-ui/core";
2
4
  import { defineComponent, h, inject, provide, useId } from "vue";
3
5
  import { createOtp } from "@kirana-ui/core/otp";
4
6
  // src/otp.ts
5
7
  const scope = context("Otp");
6
8
  const SLOT = Symbol("OtpSlot");
7
9
  const RootElement = partComponent("OtpRootElement", "div", () => scope.use().root);
8
- /** `v-model:value`; `@value-change` carries the details, `@complete` the finished code. */
10
+ /** `v-model:value`; `@value-change` carries the details, `@value-complete` the finished code. */
9
11
  const Root = defineComponent({
10
12
  name: "OtpRoot",
11
13
  inheritAttrs: false,
@@ -13,9 +15,16 @@ const Root = defineComponent({
13
15
  length: Number,
14
16
  value: optional(String),
15
17
  defaultValue: String,
18
+ validationType: String,
19
+ /**
20
+ * What a character may be.
21
+ * @deprecated Base UI's name is `validationType`, which wins when both are given.
22
+ */
16
23
  mode: String,
17
24
  pattern: String,
18
25
  disabled: Boolean,
26
+ readOnly: Boolean,
27
+ required: Boolean,
19
28
  name: String,
20
29
  form: String,
21
30
  id: String
@@ -23,25 +32,33 @@ const Root = defineComponent({
23
32
  emits: [
24
33
  "update:value",
25
34
  "valueChange",
35
+ "valueComplete",
26
36
  "complete"
27
37
  ],
28
38
  setup(props, { attrs, slots, emit }) {
29
39
  const generated = useId();
30
- scope.provide(controller(createOtp, () => ({
40
+ const field = useFieldAround();
41
+ scope.provide(controller(within(createOtp, { field }), () => ({
31
42
  id: props.id ?? generated,
32
43
  length: props.length,
33
44
  value: props.value,
34
45
  defaultValue: props.defaultValue,
46
+ validationType: props.validationType,
35
47
  mode: props.mode,
36
48
  pattern: props.pattern,
37
49
  disabled: props.disabled,
50
+ readOnly: props.readOnly,
51
+ required: props.required,
38
52
  name: props.name,
39
53
  form: props.form,
40
54
  onValueChange(value, details) {
41
55
  emit("valueChange", value, details);
42
56
  if (!details.canceled) emit("update:value", value);
43
57
  },
44
- onComplete: (value) => emit("complete", value)
58
+ onValueComplete(value, details) {
59
+ emit("valueComplete", value, details);
60
+ emit("complete", value);
61
+ }
45
62
  })));
46
63
  return () => h(RootElement, attrs, slots);
47
64
  }
package/src/otp.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/vue/src/otp.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp as Controller, OtpProps, OtpSlot } from \"@kirana-ui/core/otp\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"otp\">\n\nconst scope = context<Controller>(\"Otp\")\nconst SLOT: InjectionKey<OtpSlot> = Symbol(\"OtpSlot\")\n\nconst RootElement = partComponent(\"OtpRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<OtpProps, \"id\" | \"onValueChange\" | \"onComplete\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"value\", string> & {\n /** The finished code, once every cell is filled. */\n complete: (value: string) => void\n}\n\n/** `v-model:value`; `@value-change` carries the details, `@complete` the finished code. */\nconst Root = defineComponent({\n name: \"OtpRoot\",\n inheritAttrs: false,\n props: {\n length: Number,\n value: optional(String),\n defaultValue: String,\n mode: String as PropType<OtpProps[\"mode\"]>,\n pattern: String,\n disabled: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"complete\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createOtp, () => ({\n id: props.id ?? generated,\n length: props.length,\n value: props.value,\n defaultValue: props.defaultValue,\n mode: props.mode,\n pattern: props.pattern,\n disabled: props.disabled,\n name: props.name,\n form: props.form,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onComplete: (value: string) => emit(\"complete\", value),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport interface SlotProps extends PartComponentProps {\n /** Which character of the code the cell shows, from 0. */\n index: number\n}\n\n/** One cell: it shows its character, then whatever it is given (a caret). */\nconst Slot = defineComponent({\n name: \"OtpSlot\",\n inheritAttrs: false,\n props: { index: { type: Number, required: true } },\n setup(props, { attrs, slots }) {\n const slot = scope.use().slot(props.index)\n provide(SLOT, slot)\n const char = fromSignal(slot.char)\n // Its character comes first, whatever element the caller asked for.\n const Element = partComponent(\n \"OtpSlotElement\",\n \"div\",\n () => slot.part,\n (content) => [char.value, content]\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"slot\"], SlotProps>\n\nexport type CaretProps = PartComponentProps\n\n/** Drawn in its cell while the cell is the active one and empty. */\nconst Caret = defineComponent({\n name: \"OtpCaret\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const slot = inject(SLOT, undefined)\n if (!slot) throw new Error(\"An Otp.Caret must be inside <Otp.Slot>\")\n const shown = fromSignal(slot.caret)\n const Element = partComponent(\"OtpCaretElement\", \"div\", () => made.caretPart)\n return () => (shown.value ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"caret\"], CaretProps>\n\nexport type InputProps = PartComponentProps\nexport type GroupProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport const Otp = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"OtpInput\", \"input\", () => scope.use().input),\n Group: partComponent<\"div\", State[\"group\"]>(\"OtpGroup\", \"div\", () => scope.use().group),\n Slot,\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"OtpSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Caret,\n}\n"],"mappings":";;;;AAWA,MAAM,QAAQ,QAAoB,KAAK;AACvC,MAAM,OAA8B,OAAO,SAAS;AAEpD,MAAM,cAAc,cAAc,kBAAkB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYjF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,QAAQ;EACR,OAAO,SAAS,MAAM;EACtB,cAAc;EACd,MAAM;EACN,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM;EACN,IAAI;CACN;CACA,OAAO;EAAC;EAAgB;EAAe;CAAU;CACjD,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,QACJ,WAAW,kBAAkB;GAC3B,IAAI,MAAM,MAAM;GAChB,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,UAAU,MAAM;GAChB,MAAM,MAAM;GACZ,MAAM,MAAM;GACZ,cAAc,OAAe,SAAwB;IACnD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;GACA,aAAa,UAAkB,KAAK,YAAY,KAAK;EACvD,EAAE,CACJ;EACA,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;;AAQD,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,OAAO;EAAE,MAAM;EAAQ,UAAU;CAAK,EAAE;CACjD,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,KAAK;EACzC,QAAQ,MAAM,IAAI;EAClB,MAAM,OAAO,WAAW,KAAK,IAAI;EAEjC,MAAM,UAAU,cACd,kBACA,aACM,KAAK,OACV,YAAY,CAAC,KAAK,OAAO,OAAO,CACnC;EACA,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;;AAKD,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,MAAM,QAAQ,EAAE,OAAO,SAAS;EAC9B,MAAM,OAAO,MAAM,IAAI;EACvB,MAAM,OAAO,OAAO,MAAM,KAAA,CAAS;EACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,wCAAwC;EACnE,MAAM,QAAQ,WAAW,KAAK,KAAK;EACnC,MAAM,UAAU,cAAc,mBAAmB,aAAa,KAAK,SAAS;EAC5E,aAAc,MAAM,QAAQ,EAAE,SAAS,OAAO,KAAK,IAAI;CACzD;AACF,CAAC;AAKD,MAAa,MAAM;CACjB;CACA,OAAO,cAAuC,YAAY,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;CAC1F,OAAO,cAAqC,YAAY,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CACtF;CACA,WAAW,cACT,gBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;AACF"}
1
+ {"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/vue/src/otp.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp as Controller, OtpProps, OtpSlot } from \"@kirana-ui/core/otp\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"otp\">\n\nconst scope = context<Controller>(\"Otp\")\nconst SLOT: InjectionKey<OtpSlot> = Symbol(\"OtpSlot\")\n\nconst RootElement = partComponent(\"OtpRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<\n OtpProps,\n \"id\" | \"onValueChange\" | \"onValueComplete\" | \"onComplete\"\n> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"value\", string> & {\n /** The finished code, once every cell is filled, with the details of the change that did it. */\n valueComplete: (value: string, details: ChangeDetails) => void\n /**\n * The finished code.\n * @deprecated Base UI's name is `valueComplete`, which is told the details too. Both are\n * emitted: a listener cannot be told from none.\n */\n complete: (value: string) => void\n}\n\n/** `v-model:value`; `@value-change` carries the details, `@value-complete` the finished code. */\nconst Root = defineComponent({\n name: \"OtpRoot\",\n inheritAttrs: false,\n props: {\n length: Number,\n value: optional(String),\n defaultValue: String,\n validationType: String as PropType<OtpProps[\"validationType\"]>,\n /**\n * What a character may be.\n * @deprecated Base UI's name is `validationType`, which wins when both are given.\n */\n mode: String as PropType<OtpProps[\"mode\"]>,\n pattern: String,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"valueComplete\", \"complete\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createOtp, { field }), () => ({\n id: props.id ?? generated,\n length: props.length,\n value: props.value,\n defaultValue: props.defaultValue,\n validationType: props.validationType,\n mode: props.mode,\n pattern: props.pattern,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onValueComplete(value: string, details: ChangeDetails) {\n emit(\"valueComplete\", value, details)\n emit(\"complete\", value)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport interface SlotProps extends PartComponentProps {\n /** Which character of the code the cell shows, from 0. */\n index: number\n}\n\n/** One cell: it shows its character, then whatever it is given (a caret). */\nconst Slot = defineComponent({\n name: \"OtpSlot\",\n inheritAttrs: false,\n props: { index: { type: Number, required: true } },\n setup(props, { attrs, slots }) {\n const slot = scope.use().slot(props.index)\n provide(SLOT, slot)\n const char = fromSignal(slot.char)\n // Its character comes first, whatever element the caller asked for.\n const Element = partComponent(\n \"OtpSlotElement\",\n \"div\",\n () => slot.part,\n (content) => [char.value, content]\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"slot\"], SlotProps>\n\nexport type CaretProps = PartComponentProps\n\n/** Drawn in its cell while the cell is the active one and empty. */\nconst Caret = defineComponent({\n name: \"OtpCaret\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const slot = inject(SLOT, undefined)\n if (!slot) throw new Error(\"An Otp.Caret must be inside <Otp.Slot>\")\n const shown = fromSignal(slot.caret)\n const Element = partComponent(\"OtpCaretElement\", \"div\", () => made.caretPart)\n return () => (shown.value ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"caret\"], CaretProps>\n\nexport type InputProps = PartComponentProps\nexport type GroupProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport const Otp = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"OtpInput\", \"input\", () => scope.use().input),\n Group: partComponent<\"div\", State[\"group\"]>(\"OtpGroup\", \"div\", () => scope.use().group),\n Slot,\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"OtpSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Caret,\n}\n"],"mappings":";;;;;;AAaA,MAAM,QAAQ,QAAoB,KAAK;AACvC,MAAM,OAA8B,OAAO,SAAS;AAEpD,MAAM,cAAc,cAAc,kBAAkB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAqBjF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,QAAQ;EACR,OAAO,SAAS,MAAM;EACtB,cAAc;EACd,gBAAgB;;;;;EAKhB,MAAM;EACN,SAAS;EACT,UAAU;EACV,UAAU;EACV,UAAU;EACV,MAAM;EACN,MAAM;EACN,IAAI;CACN;CACA,OAAO;EAAC;EAAgB;EAAe;EAAiB;CAAU;CAClE,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,eAAe;EAC7B,MAAM,QACJ,WAAW,OAAO,WAAW,EAAE,MAAM,CAAC,UAAU;GAC9C,IAAI,MAAM,MAAM;GAChB,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,gBAAgB,MAAM;GACtB,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,MAAM,MAAM;GACZ,MAAM,MAAM;GACZ,cAAc,OAAe,SAAwB;IACnD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;GACA,gBAAgB,OAAe,SAAwB;IACrD,KAAK,iBAAiB,OAAO,OAAO;IACpC,KAAK,YAAY,KAAK;GACxB;EACF,EAAE,CACJ;EACA,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;;AAQD,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,OAAO;EAAE,MAAM;EAAQ,UAAU;CAAK,EAAE;CACjD,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,KAAK;EACzC,QAAQ,MAAM,IAAI;EAClB,MAAM,OAAO,WAAW,KAAK,IAAI;EAEjC,MAAM,UAAU,cACd,kBACA,aACM,KAAK,OACV,YAAY,CAAC,KAAK,OAAO,OAAO,CACnC;EACA,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;;AAKD,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,MAAM,QAAQ,EAAE,OAAO,SAAS;EAC9B,MAAM,OAAO,MAAM,IAAI;EACvB,MAAM,OAAO,OAAO,MAAM,KAAA,CAAS;EACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,wCAAwC;EACnE,MAAM,QAAQ,WAAW,KAAK,KAAK;EACnC,MAAM,UAAU,cAAc,mBAAmB,aAAa,KAAK,SAAS;EAC5E,aAAc,MAAM,QAAQ,EAAE,SAAS,OAAO,KAAK,IAAI;CACzD;AACF,CAAC;AAKD,MAAa,MAAM;CACjB;CACA,OAAO,cAAuC,YAAY,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;CAC1F,OAAO,cAAqC,YAAY,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CACtF;CACA,WAAW,cACT,gBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;AACF"}
@@ -0,0 +1,37 @@
1
+ import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { ChangeDetails } from "@kirana-ui/core";
3
+ import { PasswordInputProps } from "@kirana-ui/core/password-input";
4
+ export type RootProps = Omit<PasswordInputProps, "onVisibleChange" | "onValueChange"> & PartComponentProps;
5
+ export type RootEmits = Changes<"visible", boolean> & {
6
+ /** What was typed, as text, each time it changes. */
7
+ valueChange: (value: string, details: ChangeDetails) => void;
8
+ };
9
+ export type InputProps = PartComponentProps;
10
+ export type ToggleProps = PartComponentProps;
11
+ export type IndicatorProps = PartComponentProps;
12
+ export declare const PasswordInput: {
13
+ Root: PartComponent<"div", {
14
+ readonly visible?: true | undefined;
15
+ readonly disabled?: true | undefined;
16
+ }, RootProps, RootEmits>;
17
+ /** It takes what an `<input>` takes (`value`, `autocomplete`). */
18
+ Input: PartComponent<"input", {
19
+ readonly visible?: true | undefined;
20
+ readonly disabled?: true | undefined;
21
+ readonly touched?: true | undefined;
22
+ readonly dirty?: true | undefined;
23
+ readonly filled?: true | undefined;
24
+ readonly focused?: true | undefined;
25
+ readonly valid?: true | undefined;
26
+ readonly invalid?: true | undefined;
27
+ }, PartComponentProps, {}, unknown>;
28
+ Toggle: PartComponent<"button", {
29
+ readonly visible?: true | undefined;
30
+ readonly disabled?: true | undefined;
31
+ }, PartComponentProps, {}, unknown>;
32
+ Indicator: PartComponent<"span", {
33
+ readonly visible?: true | undefined;
34
+ readonly disabled?: true | undefined;
35
+ }, PartComponentProps, {}, unknown>;
36
+ };
37
+ //# sourceMappingURL=password-input.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { useFieldAround } from "./field-context.js";
2
+ import { context, controller, optional, partComponent } from "./runtime.js";
3
+ import { within } from "@kirana-ui/core";
4
+ import { defineComponent, h } from "vue";
5
+ import { createPasswordInput } from "@kirana-ui/core/password-input";
6
+ // src/password-input.ts
7
+ const scope = context("PasswordInput");
8
+ const RootElement = partComponent("PasswordInputRootElement", "div", () => scope.use().root);
9
+ const PasswordInput = {
10
+ Root: defineComponent({
11
+ name: "PasswordInputRoot",
12
+ inheritAttrs: false,
13
+ props: {
14
+ visible: optional(Boolean),
15
+ defaultVisible: Boolean,
16
+ disabled: Boolean
17
+ },
18
+ emits: [
19
+ "update:visible",
20
+ "visibleChange",
21
+ "valueChange"
22
+ ],
23
+ setup(props, { attrs, slots, emit }) {
24
+ scope.provide(controller(within(createPasswordInput, { field: useFieldAround() }), () => ({
25
+ visible: props.visible,
26
+ defaultVisible: props.defaultVisible,
27
+ disabled: props.disabled,
28
+ onVisibleChange(visible, details) {
29
+ emit("visibleChange", visible, details);
30
+ if (!details.canceled) emit("update:visible", visible);
31
+ },
32
+ onValueChange: (value, details) => emit("valueChange", value, details)
33
+ })));
34
+ return () => h(RootElement, attrs, slots);
35
+ }
36
+ }),
37
+ /** It takes what an `<input>` takes (`value`, `autocomplete`). */
38
+ Input: partComponent("PasswordInputInput", "input", () => scope.use().input),
39
+ Toggle: partComponent("PasswordInputToggle", "button", () => scope.use().toggle),
40
+ Indicator: partComponent("PasswordInputIndicator", "span", () => scope.use().indicator)
41
+ };
42
+ export { PasswordInput };
43
+
44
+ //# sourceMappingURL=password-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-input.js","names":[],"sources":["../../../../packages/vue/src/password-input.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createPasswordInput } from \"@kirana-ui/core/password-input\"\nimport type {\n PasswordInput as Controller,\n PasswordInputProps,\n} from \"@kirana-ui/core/password-input\"\nimport { defineComponent, h } from \"vue\"\n\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"passwordInput\">\n\nconst scope = context<Controller>(\"PasswordInput\")\n\nconst RootElement = partComponent(\"PasswordInputRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<PasswordInputProps, \"onVisibleChange\" | \"onValueChange\"> &\n PartComponentProps\n\nexport type RootEmits = Changes<\"visible\", boolean> & {\n /** What was typed, as text, each time it changes. */\n valueChange: (value: string, details: ChangeDetails) => void\n}\n\n/** `v-model:visible`, or `visible` with `@visible-change=\"(visible, details) => …\"`. */\nconst Root = defineComponent({\n name: \"PasswordInputRoot\",\n inheritAttrs: false,\n props: {\n visible: optional(Boolean),\n defaultVisible: Boolean,\n disabled: Boolean,\n },\n emits: [\"update:visible\", \"visibleChange\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n scope.provide(\n controller(within(createPasswordInput, { field: useFieldAround() }), () => ({\n visible: props.visible,\n defaultVisible: props.defaultVisible,\n disabled: props.disabled,\n onVisibleChange(visible: boolean, details: ChangeDetails) {\n emit(\"visibleChange\", visible, details)\n if (!details.canceled) emit(\"update:visible\", visible)\n },\n onValueChange: (value: string, details: ChangeDetails) =>\n emit(\"valueChange\", value, details),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type InputProps = PartComponentProps\nexport type ToggleProps = PartComponentProps\nexport type IndicatorProps = PartComponentProps\nexport const PasswordInput = {\n Root,\n /** It takes what an `<input>` takes (`value`, `autocomplete`). */\n Input: partComponent<\"input\", State[\"input\"]>(\n \"PasswordInputInput\",\n \"input\",\n () => scope.use().input\n ),\n Toggle: partComponent<\"button\", State[\"toggle\"]>(\n \"PasswordInputToggle\",\n \"button\",\n () => scope.use().toggle\n ),\n Indicator: partComponent<\"span\", State[\"indicator\"]>(\n \"PasswordInputIndicator\",\n \"span\",\n () => scope.use().indicator\n ),\n}\n"],"mappings":";;;;;;AAeA,MAAM,QAAQ,QAAoB,eAAe;AAEjD,MAAM,cAAc,cAAc,4BAA4B,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAyC3F,MAAa,gBAAgB;CAC3B,MA/BW,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,SAAS,SAAS,OAAO;GACzB,gBAAgB;GAChB,UAAU;EACZ;EACA,OAAO;GAAC;GAAkB;GAAiB;EAAa;EACxD,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,QACJ,WAAW,OAAO,qBAAqB,EAAE,OAAO,eAAe,EAAE,CAAC,UAAU;IAC1E,SAAS,MAAM;IACf,gBAAgB,MAAM;IACtB,UAAU,MAAM;IAChB,gBAAgB,SAAkB,SAAwB;KACxD,KAAK,iBAAiB,SAAS,OAAO;KACtC,IAAI,CAAC,QAAQ,UAAU,KAAK,kBAAkB,OAAO;IACvD;IACA,gBAAgB,OAAe,YAC7B,KAAK,eAAe,OAAO,OAAO;GACtC,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAME;;CAEA,OAAO,cACL,sBACA,eACM,MAAM,IAAI,CAAC,CAAC,KACpB;CACA,QAAQ,cACN,uBACA,gBACM,MAAM,IAAI,CAAC,CAAC,MACpB;CACA,WAAW,cACT,0BACA,cACM,MAAM,IAAI,CAAC,CAAC,SACpB;AACF"}
package/src/popover.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Changes, PartComponent, PartComponentProps, PlainComponent, PortalProps } from "./runtime.js";
2
2
  import { Anchor, PartState, PositionOptions } from "@kirana-ui/core";
3
- import { Popover as Popover$1, PopoverProps } from "@kirana-ui/core/popover";
4
3
  import { Component, ComponentPublicInstance, Ref } from "vue";
4
+ import { Popover as Popover$1, PopoverProps } from "@kirana-ui/core/popover";
5
5
  /**
6
6
  * The popover its parts are inside. Exported for a component that is made of one (a date picker
7
7
  * provides its own to the popover's parts).
@@ -56,6 +56,7 @@ export declare const Popover: {
56
56
  Root: PlainComponent<RootProps, RootEmits>;
57
57
  Trigger: PartComponent<"button", {
58
58
  readonly popupOpen?: true | undefined;
59
+ readonly pressed?: true | undefined;
59
60
  }, TriggerProps>;
60
61
  Portal: PlainComponent<PortalProps, {}, {}>;
61
62
  Backdrop: PartComponent<"div", {
@@ -69,6 +70,7 @@ export declare const Popover: {
69
70
  readonly closed?: true | undefined;
70
71
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
71
72
  readonly align?: "center" | "end" | "start" | undefined;
73
+ readonly anchorHidden?: true | undefined;
72
74
  }, PositionerProps>;
73
75
  Popup: PartComponent<"div", {
74
76
  readonly open?: true | undefined;
@@ -77,8 +79,11 @@ export declare const Popover: {
77
79
  readonly endingStyle?: true | undefined;
78
80
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
79
81
  readonly align?: "center" | "end" | "start" | undefined;
82
+ readonly instant?: "click" | "dismiss" | undefined;
80
83
  }, PartComponentProps, {}, unknown>;
81
84
  Arrow: PartComponent<"div", {
85
+ readonly open?: true | undefined;
86
+ readonly closed?: true | undefined;
82
87
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
83
88
  readonly align?: "center" | "end" | "start" | undefined;
84
89
  readonly uncentered?: true | undefined;
package/src/popover.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { context, controller, elementOf, optional, partComponent, portalComponent } from "./runtime.js";
2
2
  import { defined } from "@kirana-ui/core";
3
- import { createPopover } from "@kirana-ui/core/popover";
4
3
  import { defineComponent, h, unref, useId, watchEffect } from "vue";
4
+ import { createPopover } from "@kirana-ui/core/popover";
5
5
  // src/popover.ts
6
6
  /**
7
7
  * The popover its parts are inside. Exported for a component that is made of one (a date picker
@@ -25,6 +25,12 @@ export declare const RadioGroup: {
25
25
  readonly disabled?: true | undefined;
26
26
  readonly readonly?: true | undefined;
27
27
  readonly required?: true | undefined;
28
+ readonly touched?: true | undefined;
29
+ readonly dirty?: true | undefined;
30
+ readonly filled?: true | undefined;
31
+ readonly focused?: true | undefined;
32
+ readonly valid?: true | undefined;
33
+ readonly invalid?: true | undefined;
28
34
  }, ItemProps>;
29
35
  Indicator: PartComponent<"span", {
30
36
  readonly checked?: true | undefined;
@@ -32,6 +38,12 @@ export declare const RadioGroup: {
32
38
  readonly disabled?: true | undefined;
33
39
  readonly readonly?: true | undefined;
34
40
  readonly required?: true | undefined;
41
+ readonly touched?: true | undefined;
42
+ readonly dirty?: true | undefined;
43
+ readonly filled?: true | undefined;
44
+ readonly focused?: true | undefined;
45
+ readonly valid?: true | undefined;
46
+ readonly invalid?: true | undefined;
35
47
  readonly startingStyle?: true | undefined;
36
48
  readonly endingStyle?: true | undefined;
37
49
  }, IndicatorProps>;
@@ -0,0 +1,34 @@
1
+ import { Changes, PartComponent, PartComponentProps, PlainComponent } from "./runtime.js";
2
+ import { RatingProps } from "@kirana-ui/core/rating";
3
+ export type RootProps = Omit<RatingProps, "id" | "onValueChange" | "onHoverChange"> & {
4
+ id?: string | undefined;
5
+ } & PartComponentProps;
6
+ export type RootEmits = Changes<"value", number> & {
7
+ /** The value the pointer is over, `null` once it leaves. */
8
+ hoverChange: (value: number | null) => void;
9
+ };
10
+ export type ItemsProps = Record<never, never>;
11
+ export interface ItemProps extends PartComponentProps {
12
+ /** Its place among the items, from 1. */
13
+ place: number;
14
+ }
15
+ export declare const Rating: {
16
+ Root: PartComponent<"div", {
17
+ readonly disabled?: true | undefined;
18
+ readonly readonly?: true | undefined;
19
+ readonly required?: true | undefined;
20
+ readonly hovering?: true | undefined;
21
+ }, RootProps, RootEmits>;
22
+ Items: PlainComponent<ItemsProps, {}, {
23
+ place: number;
24
+ }>;
25
+ Item: PartComponent<"span", {
26
+ readonly disabled?: true | undefined;
27
+ readonly readonly?: true | undefined;
28
+ readonly required?: true | undefined;
29
+ readonly checked?: true | undefined;
30
+ readonly filled?: true | undefined;
31
+ readonly half?: true | undefined;
32
+ }, ItemProps>;
33
+ };
34
+ //# sourceMappingURL=rating.d.ts.map
package/src/rating.js ADDED
@@ -0,0 +1,81 @@
1
+ import { useDirectionAround } from "./direction-context.js";
2
+ import { useFieldAround } from "./field-context.js";
3
+ import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
4
+ import { within } from "@kirana-ui/core";
5
+ import { Fragment, defineComponent, h, useId } from "vue";
6
+ import { createRating } from "@kirana-ui/core/rating";
7
+ // src/rating.ts
8
+ const scope = context("Rating");
9
+ const Input = partComponent("RatingInput", "input", () => scope.use().input);
10
+ const RootElement = partComponent("RatingRootElement", "div", () => scope.use().root, (content) => [content, h(Input)]);
11
+ const Rating = {
12
+ Root: defineComponent({
13
+ name: "RatingRoot",
14
+ inheritAttrs: false,
15
+ props: {
16
+ value: optional(Number),
17
+ defaultValue: Number,
18
+ count: Number,
19
+ allowHalf: Boolean,
20
+ disabled: Boolean,
21
+ readOnly: Boolean,
22
+ required: Boolean,
23
+ name: String,
24
+ form: String,
25
+ id: String
26
+ },
27
+ emits: [
28
+ "update:value",
29
+ "valueChange",
30
+ "hoverChange"
31
+ ],
32
+ setup(props, { attrs, slots, emit }) {
33
+ const generated = useId();
34
+ const field = useFieldAround();
35
+ scope.provide(controller(within(createRating, {
36
+ field,
37
+ direction: useDirectionAround()
38
+ }), () => ({
39
+ id: props.id ?? generated,
40
+ value: props.value,
41
+ defaultValue: props.defaultValue,
42
+ count: props.count,
43
+ allowHalf: props.allowHalf,
44
+ disabled: props.disabled,
45
+ readOnly: props.readOnly,
46
+ required: props.required,
47
+ name: props.name,
48
+ form: props.form,
49
+ onValueChange(value, details) {
50
+ emit("valueChange", value, details);
51
+ if (!details.canceled) emit("update:value", value);
52
+ },
53
+ onHoverChange: (value) => emit("hoverChange", value)
54
+ })));
55
+ return () => h(RootElement, attrs, slots);
56
+ }
57
+ }),
58
+ Items: defineComponent({
59
+ name: "RatingItems",
60
+ setup(_props, { slots }) {
61
+ const places = fromSignal(scope.use().places);
62
+ return () => places.value.map((place) => h(Fragment, { key: place }, slots.default?.({ place })));
63
+ }
64
+ }),
65
+ Item: defineComponent({
66
+ name: "RatingItem",
67
+ inheritAttrs: false,
68
+ props: { place: {
69
+ type: Number,
70
+ required: true
71
+ } },
72
+ setup(props, { attrs, slots }) {
73
+ const made = scope.use();
74
+ const Element = partComponent("RatingItemElement", "span", () => made.item(props.place));
75
+ return () => h(Element, attrs, slots);
76
+ }
77
+ })
78
+ };
79
+ export { Rating };
80
+
81
+ //# sourceMappingURL=rating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating.js","names":[],"sources":["../../../../packages/vue/src/rating.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createRating } from \"@kirana-ui/core/rating\"\nimport type { Rating as Controller, RatingProps } from \"@kirana-ui/core/rating\"\nimport { Fragment, defineComponent, h, useId } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"rating\">\n\nconst scope = context<Controller>(\"Rating\")\n\nconst Input = partComponent(\"RatingInput\", \"input\", () => scope.use().input)\n\n// The input a form reads is the element's last child, whatever element was asked for.\nconst RootElement = partComponent(\n \"RatingRootElement\",\n \"div\",\n () => scope.use().root,\n (content) => [content, h(Input)]\n)\n\nexport type RootProps = Omit<RatingProps, \"id\" | \"onValueChange\" | \"onHoverChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"value\", number> & {\n /** The value the pointer is over, `null` once it leaves. */\n hoverChange: (value: number | null) => void\n}\n\n/** `v-model:value`, or `value` with `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"RatingRoot\",\n inheritAttrs: false,\n props: {\n value: optional(Number),\n defaultValue: Number,\n count: Number,\n allowHalf: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"hoverChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createRating, { field, direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n count: props.count,\n allowHalf: props.allowHalf,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n onValueChange(value: number, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onHoverChange: (value: number | null) => emit(\"hoverChange\", value),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type ItemsProps = Record<never, never>\n\n/** Draws its slot once for each item, from 1 to `count` (`v-slot=\"{ place }\"`). */\nconst Items = defineComponent({\n name: \"RatingItems\",\n setup(_props, { slots }) {\n const places = fromSignal(scope.use().places)\n return () =>\n places.value.map((place) => h(Fragment, { key: place }, slots.default?.({ place })))\n },\n}) as unknown as PlainComponent<ItemsProps, {}, { place: number }>\n\nexport interface ItemProps extends PartComponentProps {\n /** Its place among the items, from 1. */\n place: number\n}\n\nconst Item = defineComponent({\n name: \"RatingItem\",\n inheritAttrs: false,\n props: { place: { type: Number, required: true } },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const Element = partComponent(\"RatingItemElement\", \"span\", () => made.item(props.place))\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"item\"], ItemProps>\n\nexport const Rating = { Root, Items, Item }\n"],"mappings":";;;;;;;AAmBA,MAAM,QAAQ,QAAoB,QAAQ;AAE1C,MAAM,QAAQ,cAAc,eAAe,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;AAG3E,MAAM,cAAc,cAClB,qBACA,aACM,MAAM,IAAI,CAAC,CAAC,OACjB,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CACjC;AAkFA,MAAa,SAAS;CAAE,MAtEX,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO,SAAS,MAAM;GACtB,cAAc;GACd,OAAO;GACP,WAAW;GACX,UAAU;GACV,UAAU;GACV,UAAU;GACV,MAAM;GACN,MAAM;GACN,IAAI;EACN;EACA,OAAO;GAAC;GAAgB;GAAe;EAAa;EACpD,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;GACnC,MAAM,YAAY,MAAM;GACxB,MAAM,QAAQ,eAAe;GAC7B,MAAM,QACJ,WAAW,OAAO,cAAc;IAAE;IAAO,WAAW,mBAAmB;GAAE,CAAC,UAAU;IAClF,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,cAAc,MAAM;IACpB,OAAO,MAAM;IACb,WAAW,MAAM;IACjB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,cAAc,OAAe,SAAwB;KACnD,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;IACA,gBAAgB,UAAyB,KAAK,eAAe,KAAK;GACpE,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CA8BwB;CAAM,OAzBhB,gBAAgB;EAC5B,MAAM;EACN,MAAM,QAAQ,EAAE,SAAS;GACvB,MAAM,SAAS,WAAW,MAAM,IAAI,CAAC,CAAC,MAAM;GAC5C,aACE,OAAO,MAAM,KAAK,UAAU,EAAE,UAAU,EAAE,KAAK,MAAM,GAAG,MAAM,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;EACvF;CACF,CAkB8B;CAAO,MAXxB,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,OAAO;GAAE,MAAM;GAAQ,UAAU;EAAK,EAAE;EACjD,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,OAAO,MAAM,IAAI;GACvB,MAAM,UAAU,cAAc,qBAAqB,cAAc,KAAK,KAAK,MAAM,KAAK,CAAC;GACvF,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAEqC;AAAK"}
package/src/runtime.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Hold, written } from "./element.js";
2
+ import { useDirectionAround } from "./direction-context.js";
2
3
  import { ChangeDetails, Part, PartDefinition, PartEvent, PartState, ReadonlySignal, StateOf } from "@kirana-ui/core";
3
4
  import { DefineSetupFnComponent, HTMLAttributes, IntrinsicElementAttributes, ObjectEmitsOptions, PublicProps, ShallowRef, SlotsType, VNode } from "vue";
4
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
@@ -116,5 +117,5 @@ export declare const optional: <T>(type: T) => {
116
117
  type: T;
117
118
  default: undefined;
118
119
  };
119
- export { type Hold, type PartEvent, written };
120
+ export { type Hold, type PartEvent, useDirectionAround, written };
120
121
  //# sourceMappingURL=runtime.d.ts.map
package/src/runtime.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { draw, written } from "./element.js";
2
- import { sameProps, signal, stateOf } from "@kirana-ui/core";
2
+ import { useDirectionAround } from "./direction-context.js";
3
+ import { sameProps, signal, stateOf, untype } from "@kirana-ui/core";
3
4
  import { Teleport, defineComponent, h, inject, onBeforeUnmount, onMounted, onScopeDispose, provide, queuePostFlushCb, shallowRef, watchEffect } from "vue";
4
5
  // src/runtime.ts
5
6
  /** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */
@@ -43,6 +44,7 @@ function context(name) {
43
44
  }
44
45
  function toVue(props) {
45
46
  const out = {};
47
+ for (const mark of Object.getOwnPropertySymbols(props)) out[mark] = props[mark];
46
48
  for (const key in props) {
47
49
  const value = props[key];
48
50
  if (typeof value === "function") {
@@ -95,6 +97,7 @@ function partComponent(name, tag, resolve, hold) {
95
97
  if (wanted === element) return;
96
98
  detach?.();
97
99
  element = wanted;
100
+ if (wanted) untype(wanted);
98
101
  detach = wanted ? part.attach(wanted) : void 0;
99
102
  };
100
103
  const attach = (target) => {
@@ -143,6 +146,6 @@ const optional = (type) => ({
143
146
  type,
144
147
  default: void 0
145
148
  });
146
- export { PortalProvider, context, controller, elementOf, fromSignal, optional, partComponent, portalComponent, toSignal, written };
149
+ export { PortalProvider, context, controller, elementOf, fromSignal, optional, partComponent, portalComponent, toSignal, useDirectionAround, written };
147
150
 
148
151
  //# sourceMappingURL=runtime.js.map