@kirana-ui/vue 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1779 -182
  3. package/package.json +48 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +53 -12
  5. package/src/accordion.d.ts +4 -0
  6. package/src/accordion.js +6 -0
  7. package/src/accordion.js.map +1 -1
  8. package/src/alert-dialog.d.ts +2 -2
  9. package/src/autocomplete.d.ts +2 -2
  10. package/src/avatar.d.ts +31 -4
  11. package/src/avatar.js +40 -16
  12. package/src/avatar.js.map +1 -1
  13. package/src/button.d.ts +4 -1
  14. package/src/button.js +4 -1
  15. package/src/button.js.map +1 -1
  16. package/src/calendar.d.ts +22 -13
  17. package/src/calendar.js +83 -12
  18. package/src/calendar.js.map +1 -1
  19. package/src/carousel.d.ts +5 -2
  20. package/src/carousel.js +1 -4
  21. package/src/carousel.js.map +1 -1
  22. package/src/checkbox-group-context.d.ts +5 -0
  23. package/src/checkbox-group-context.js +6 -0
  24. package/src/checkbox-group-context.js.map +1 -0
  25. package/src/checkbox-group.d.ts +12 -0
  26. package/src/checkbox-group.js +44 -0
  27. package/src/checkbox-group.js.map +1 -0
  28. package/src/checkbox.d.ts +17 -0
  29. package/src/checkbox.js +9 -2
  30. package/src/checkbox.js.map +1 -1
  31. package/src/collapsible.d.ts +2 -0
  32. package/src/color-picker.d.ts +118 -0
  33. package/src/color-picker.js +174 -0
  34. package/src/color-picker.js.map +1 -0
  35. package/src/combobox.d.ts +105 -5
  36. package/src/combobox.js +83 -12
  37. package/src/combobox.js.map +1 -1
  38. package/src/command.d.ts +2 -2
  39. package/src/command.js +3 -1
  40. package/src/command.js.map +1 -1
  41. package/src/date-field.d.ts +1 -1
  42. package/src/date-field.js +2 -0
  43. package/src/date-field.js.map +1 -1
  44. package/src/date-picker.d.ts +39 -13
  45. package/src/date-picker.js +104 -51
  46. package/src/date-picker.js.map +1 -1
  47. package/src/dialog.d.ts +41 -8
  48. package/src/dialog.js +44 -8
  49. package/src/dialog.js.map +1 -1
  50. package/src/drawer.d.ts +2 -2
  51. package/src/editable.d.ts +87 -0
  52. package/src/editable.js +83 -0
  53. package/src/editable.js.map +1 -0
  54. package/src/element.js +5 -5
  55. package/src/element.js.map +1 -1
  56. package/src/file-upload.d.ts +76 -0
  57. package/src/file-upload.js +139 -0
  58. package/src/file-upload.js.map +1 -0
  59. package/src/hover-card.d.ts +3 -0
  60. package/src/index.d.ts +28 -7
  61. package/src/index.js +12 -1
  62. package/src/menu.d.ts +10 -0
  63. package/src/menu.js +17 -6
  64. package/src/menu.js.map +1 -1
  65. package/src/menubar.js +10 -1
  66. package/src/menubar.js.map +1 -1
  67. package/src/navigation-menu.d.ts +14 -3
  68. package/src/navigation-menu.js +20 -2
  69. package/src/navigation-menu.js.map +1 -1
  70. package/src/number-field.d.ts +33 -1
  71. package/src/number-field.js +98 -68
  72. package/src/number-field.js.map +1 -1
  73. package/src/otp.d.ts +25 -3
  74. package/src/otp.js +22 -3
  75. package/src/otp.js.map +1 -1
  76. package/src/password-input.d.ts +37 -0
  77. package/src/password-input.js +44 -0
  78. package/src/password-input.js.map +1 -0
  79. package/src/popover.d.ts +32 -4
  80. package/src/popover.js +37 -5
  81. package/src/popover.js.map +1 -1
  82. package/src/radio-group.d.ts +12 -0
  83. package/src/radio-group.js +6 -2
  84. package/src/radio-group.js.map +1 -1
  85. package/src/rating.d.ts +34 -0
  86. package/src/rating.js +81 -0
  87. package/src/rating.js.map +1 -0
  88. package/src/runtime.d.ts +2 -1
  89. package/src/runtime.js +5 -2
  90. package/src/runtime.js.map +1 -1
  91. package/src/scroll-area.d.ts +24 -1
  92. package/src/select.d.ts +39 -5
  93. package/src/select.js +30 -9
  94. package/src/select.js.map +1 -1
  95. package/src/slider.d.ts +35 -0
  96. package/src/slider.js +1 -0
  97. package/src/slider.js.map +1 -1
  98. package/src/steps.d.ts +74 -0
  99. package/src/steps.js +84 -0
  100. package/src/steps.js.map +1 -0
  101. package/src/switch.d.ts +12 -0
  102. package/src/tabs.d.ts +2 -0
  103. package/src/tabs.js +5 -0
  104. package/src/tabs.js.map +1 -1
  105. package/src/tags-input.d.ts +69 -0
  106. package/src/tags-input.js +145 -0
  107. package/src/tags-input.js.map +1 -0
  108. package/src/time-field.d.ts +41 -0
  109. package/src/time-field.js +85 -0
  110. package/src/time-field.js.map +1 -0
  111. package/src/toast.d.ts +12 -4
  112. package/src/toggle-group.js +6 -0
  113. package/src/toggle-group.js.map +1 -1
  114. package/src/toolbar-context.d.ts +1 -1
  115. package/src/toolbar.d.ts +4 -1
  116. package/src/toolbar.js +17 -2
  117. package/src/toolbar.js.map +1 -1
  118. package/src/tooltip.d.ts +5 -0
  119. package/src/tour.d.ts +75 -0
  120. package/src/tour.js +95 -0
  121. package/src/tour.js.map +1 -0
  122. package/src/tree.d.ts +69 -0
  123. package/src/tree.js +118 -0
  124. package/src/tree.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.js","names":[],"sources":["../../../../packages/vue/src/combobox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createAutocomplete } from \"@kirana-ui/core/autocomplete\"\nimport type { AutocompleteProps } from \"@kirana-ui/core/autocomplete\"\nimport { createCombobox } from \"@kirana-ui/core/combobox\"\nimport type {\n Combobox as Controller,\n ComboboxGroup,\n ComboboxItemOptions,\n ComboboxProps,\n} from \"@kirana-ui/core/combobox\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useFieldAround } from \"./field-context.ts\"\nimport { positionerComponent } from \"./popover.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n Listeners,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n PlainInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"combobox\">\n\nconst scope = context<Controller>(\"Combobox\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"ComboboxItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nconst GROUP: InjectionKey<ComboboxGroup | null> = Symbol(\"ComboboxGroup\")\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */\nconst Group = defineComponent({\n name: \"ComboboxGroup\",\n inheritAttrs: false,\n props: { id: String },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const group = scope.use().group(props.id ?? generated)\n provide(GROUP, group)\n const Element = partComponent(\"ComboboxGroupElement\", \"div\", () => group.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\n/** Names the group it is in. With no group around it, it is plain text. */\nconst GroupLabel = partComponent<\"div\", State[\"groupLabel\"]>(\n \"ComboboxGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().groupLabel\n)\n\nconst HiddenInput = partComponent(\"ComboboxHiddenInput\", \"input\", () => scope.use().hidden)\n\nexport type RootProps<Value = unknown> = Omit<\n ComboboxProps<Value>,\n \"id\" | \"onValueChange\" | \"onValuesChange\" | \"onInputValueChange\" | \"onOpenChange\"\n> & { id?: string | undefined }\n\n/** The value is `null` when the combobox is cleared. */\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value | null> &\n Changes<\"values\", Value[]> &\n Changes<\"inputValue\", string> &\n Changes<\"open\", boolean>\n\n/** `v-model:value`, `v-model:inputValue`, `v-model:open`; the `-change` events carry the details. */\nconst Root = defineComponent({\n name: \"ComboboxRoot\",\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n inputValue: String,\n defaultInputValue: String,\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n required: Boolean,\n multiple: Boolean,\n values: optional(Array as PropType<readonly unknown[]>),\n defaultValues: Array as PropType<readonly unknown[]>,\n inline: Boolean,\n virtualized: Object as PropType<ComboboxProps[\"virtualized\"]>,\n autoHighlight: Boolean,\n name: String,\n form: String,\n items: [Array, Object] as PropType<ComboboxProps[\"items\"]>,\n filter: {\n type: null as unknown as PropType<((label: string, query: string) => boolean) | null>,\n default: undefined,\n },\n id: String,\n },\n emits: [\n \"update:value\",\n \"valueChange\",\n \"update:inputValue\",\n \"inputValueChange\",\n \"update:open\",\n \"openChange\",\n \"update:values\",\n \"valuesChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createCombobox, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n required: props.required,\n multiple: props.multiple,\n values: props.values,\n defaultValues: props.defaultValues,\n onValuesChange(values: unknown[], details: ChangeDetails) {\n emit(\"valuesChange\", values, details)\n if (!details.canceled) emit(\"update:values\", values)\n },\n inline: props.inline,\n virtualized: props.virtualized,\n autoHighlight: props.autoHighlight,\n name: props.name,\n form: props.form,\n items: props.items,\n filter: props.filter,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n const named = fromSignal(made.named)\n return () => [slots.default?.(), named.value ? h(HiddenInput) : null]\n },\n}) as unknown as new <Value = unknown>(\n props: RootProps<Value> & Listeners<RootEmits<Value>> & PublicProps\n) => PlainInstance<RootProps<Value>, RootEmits<Value>, {}>\n\nexport interface ItemProps extends Omit<ComboboxItemOptions, \"id\">, PartComponentProps {\n /** What the combobox's value is while this item is the chosen one. */\n value: unknown\n id?: string | undefined\n}\n\n/** `label` is what is filtered and what the input shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"ComboboxItem\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, required: true },\n disabled: optional(Boolean),\n label: String,\n id: String,\n index: Number,\n },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n index: props.index,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(value, () => options.get(), inject(GROUP, null) ?? undefined)\n provide(ITEM, value)\n const Element = partComponent(\"ComboboxItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface ItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not chosen. */\n keepMounted?: boolean | undefined\n}\n\nconst ItemIndicator = defineComponent({\n name: \"ComboboxItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const value = inject(ITEM)\n const made = scope.use()\n const selected = fromSignal(made.selected(value))\n const Element = partComponent(\"ComboboxItemIndicatorElement\", \"span\", () =>\n made.itemIndicator(value)\n )\n return () => (selected.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"itemIndicator\"], ItemIndicatorProps>\n\nexport interface ClearProps extends PartComponentProps {\n /** Keeps the button in the page while there is nothing to clear. */\n keepMounted?: boolean | undefined\n}\n\n/** A button that empties the input and the value. Drawn while there is something to clear. */\nconst Clear = defineComponent({\n name: \"ComboboxClear\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const clearable = fromSignal(made.clearable)\n const Element = partComponent(\"ComboboxClearElement\", \"button\", () => made.clear)\n return () => (clearable.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"button\", State[\"clear\"], ClearProps>\n\nconst CHIP: InjectionKey<unknown> = Symbol(\"ComboboxChip\")\n\nexport interface ChipProps extends PartComponentProps {\n /** The chosen value it stands for: what its remove button takes away. */\n value: unknown\n}\n\n/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */\nconst Chip = defineComponent({\n name: \"ComboboxChip\",\n inheritAttrs: false,\n props: { value: { type: ANY, required: true } },\n setup(props, { attrs, slots }) {\n // A chip is its value for as long as it is in the page.\n const value = props.value\n provide(CHIP, value)\n const part = scope.use().chip(value)\n const Element = partComponent(\"ComboboxChipElement\", \"span\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"chip\"], ChipProps>\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"ComboboxEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const empty = fromSignal(made.empty)\n const Element = partComponent(\"ComboboxEmptyElement\", \"div\", () => made.emptyPart)\n return () => (empty.value ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport type AutocompleteRootProps = Omit<\n AutocompleteProps,\n \"id\" | \"value\" | \"onValueChange\" | \"onOpenChange\"\n> & {\n /** The text, which is the value: `v-model`. */\n modelValue?: string | undefined\n id?: string | undefined\n}\n\nexport type AutocompleteRootEmits = {\n \"update:modelValue\": (value: string) => void\n valueChange: (value: string, details: ChangeDetails) => void\n} & Changes<\"open\", boolean>\n\n/** A combobox whose text is the value: `v-model` is the text. The list only suggests. */\nconst AutocompleteRoot = defineComponent({\n name: \"AutocompleteRoot\",\n props: {\n modelValue: String,\n defaultValue: String,\n open: optional(Boolean),\n defaultOpen: Boolean,\n mode: String as PropType<AutocompleteProps[\"mode\"]>,\n filter: {\n type: null as unknown as PropType<AutocompleteProps[\"filter\"]>,\n default: undefined,\n },\n openOnInputClick: Boolean,\n disabled: Boolean,\n required: Boolean,\n name: String,\n form: String,\n virtualized: Object as PropType<AutocompleteProps[\"virtualized\"]>,\n autoHighlight: Boolean,\n id: String,\n },\n emits: [\"update:modelValue\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createAutocomplete, { field: useFieldAround() }), () => ({\n id: props.id ?? generated,\n value: props.modelValue,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n mode: props.mode,\n filter: props.filter,\n openOnInputClick: props.openOnInputClick,\n disabled: props.disabled,\n required: props.required,\n name: props.name,\n form: props.form,\n virtualized: props.virtualized,\n autoHighlight: props.autoHighlight,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:modelValue\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>\n\nexport type InputProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport type ChipsProps = PartComponentProps\nexport type ChipRemoveProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport const Combobox = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"ComboboxInput\", \"input\", () => scope.use().input),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"ComboboxTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Clear,\n /** With `multiple`: what holds the chips and the input. */\n Chips: partComponent<\"div\", State[\"chips\"]>(\"ComboboxChips\", \"div\", () => scope.use().chips),\n Chip,\n ChipRemove: partComponent<\"button\", State[\"chipRemove\"]>(\"ComboboxChipRemove\", \"button\", () =>\n scope.use().chipRemove(inject(CHIP))\n ),\n Portal: portalComponent(\"ComboboxPortal\", () => scope.use().mounted),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"ComboboxPositioner\",\n () => scope.use(),\n partComponent(\"ComboboxPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"ComboboxPopup\", \"div\", () => scope.use().popup),\n /**\n * The items' own box inside the popup, when the popup holds more than items (an input): it\n * is then the listbox.\n */\n List: partComponent<\"div\", State[\"list\"]>(\"ComboboxList\", \"div\", () => scope.use().list),\n Group,\n GroupLabel,\n /** A line between groups. */\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"ComboboxSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Item,\n ItemIndicator,\n Empty,\n}\n\nexport const Autocomplete = {\n Root: AutocompleteRoot,\n Input: Combobox.Input,\n Trigger: Combobox.Trigger,\n Clear: Combobox.Clear,\n Portal: Combobox.Portal,\n Positioner: Combobox.Positioner,\n Popup: Combobox.Popup,\n List: Combobox.List,\n Group: Combobox.Group,\n GroupLabel: Combobox.GroupLabel,\n Separator: Combobox.Separator,\n Item: Combobox.Item,\n Empty: Combobox.Empty,\n}\n"],"mappings":";;;;;;;;AAwCA,MAAM,QAAQ,QAAoB,UAAU;AAC5C,MAAM,OAA8B,OAAO,cAAc;AACzD,MAAM,MAAM;AAEZ,MAAM,QAA4C,OAAO,eAAe;;AAOxE,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,IAAI,OAAO;CACpB,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,SAAS;EACrD,QAAQ,OAAO,KAAK;EACpB,MA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AI,CAAC,CAAC,OACpB;CACA;;CAEA,OAAO,cAAqC,iBAAiB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;CAC3F;CACA,YAAY,cAA6C,sBAAsB,gBAC7E,MAAM,IAAI,CAAC,CAAC,WAAW,OAAO,IAAI,CAAC,CACrC;CACA,QAAQ,gBAAgB,wBAAwB,MAAM,IAAI,CAAC,CAAC,OAAO;CACnE,YAAY,oBACV,4BACM,MAAM,IAAI,GAChB,cAAc,6BAA6B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAChF;CACA,OAAO,cAAqC,iBAAiB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;;;;;CAK3F,MAAM,cAAoC,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACvF;CACA;;CAEA,WAAW,cACT,qBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;CACA;CACA;AACF;AAEA,MAAa,eAAe;CAC1B,MAAM;CACN,OAAO,SAAS;CAChB,SAAS,SAAS;CAClB,OAAO,SAAS;CAChB,QAAQ,SAAS;CACjB,YAAY,SAAS;CACrB,OAAO,SAAS;CAChB,MAAM,SAAS;CACf,OAAO,SAAS;CAChB,YAAY,SAAS;CACrB,WAAW,SAAS;CACpB,MAAM,SAAS;CACf,OAAO,SAAS;AAClB"}
1
+ {"version":3,"file":"combobox.js","names":[],"sources":["../../../../packages/vue/src/combobox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createAutocomplete } from \"@kirana-ui/core/autocomplete\"\nimport type { AutocompleteProps } from \"@kirana-ui/core/autocomplete\"\nimport { createCombobox } from \"@kirana-ui/core/combobox\"\nimport type {\n Combobox as Controller,\n ComboboxEntry,\n ComboboxGroup,\n ComboboxItemOptions,\n ComboboxProps,\n ComboboxShown,\n} from \"@kirana-ui/core/combobox\"\nimport { defineComponent, Fragment, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { positionerComponent } from \"./popover.ts\"\nimport {\n context,\n controller,\n fromSignal,\n optional,\n partComponent,\n portalComponent,\n toSignal,\n} from \"./runtime.ts\"\nimport type {\n Changes,\n Listeners,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n PlainInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PositionerProps } from \"./popover.ts\"\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"combobox\">\n\nconst scope = context<Controller>(\"Combobox\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"ComboboxItem\")\nconst ANY = null as unknown as PropType<unknown>\n\nconst GROUP: InjectionKey<ComboboxGroup | null> = Symbol(\"ComboboxGroup\")\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */\nconst Group = defineComponent({\n name: \"ComboboxGroup\",\n inheritAttrs: false,\n props: { id: String },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const group = scope.use().group(props.id ?? generated)\n provide(GROUP, group)\n const Element = partComponent(\"ComboboxGroupElement\", \"div\", () => group.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\n/** Names the group it is in. With no group around it, it is plain text. */\nconst GroupLabel = partComponent<\"div\", State[\"groupLabel\"]>(\n \"ComboboxGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().groupLabel\n)\n\nconst HiddenInput = partComponent(\"ComboboxHiddenInput\", \"input\", () => scope.use().hidden)\n\n/** `Multiple` is read from `multiple`: with it, `value` and `@value-change` hold a list. */\nexport type RootProps<Value = unknown, Multiple extends boolean | undefined = false> = Omit<\n ComboboxProps<Value, Multiple>,\n \"id\" | \"multiple\" | \"onValueChange\" | \"onValuesChange\" | \"onInputValueChange\" | \"onOpenChange\"\n> & {\n id?: string | undefined\n /** Several values: `value` and `@value-change` then hold a list. Read once. */\n multiple?: Multiple | undefined\n}\n\n/** The value is `null` when the combobox is cleared. */\nexport type RootEmits<Value = unknown, Multiple extends boolean | undefined = false> = Changes<\n \"value\",\n Multiple extends true ? Value[] : Value | null\n> &\n Changes<\"values\", Value[]> &\n Changes<\"inputValue\", string> &\n Changes<\"open\", boolean>\n\n/**\n * `v-model:value`, `v-model:inputValue`, `v-model:open`; the `-change` events carry the details.\n * With `multiple`, the value is a list (`v-model:values`, the older shape, is still emitted).\n */\nconst Root = defineComponent({\n name: \"ComboboxRoot\",\n props: {\n value: { type: ANY, default: undefined as unknown },\n defaultValue: { type: ANY, default: null as unknown },\n inputValue: String,\n defaultInputValue: String,\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n multiple: Boolean,\n values: optional(Array as PropType<readonly unknown[]>),\n defaultValues: Array as PropType<readonly unknown[]>,\n inline: Boolean,\n virtualized: Object as PropType<ComboboxProps[\"virtualized\"]>,\n presentation: String as PropType<ComboboxProps[\"presentation\"]>,\n sheetBelow: Number,\n autoHighlight: Boolean,\n name: String,\n form: String,\n items: [Array, Object] as PropType<ComboboxProps[\"items\"]>,\n filter: {\n type: null as unknown as PropType<((label: string, query: string) => boolean) | null>,\n default: undefined,\n },\n itemToStringLabel: {\n type: Function as PropType<(value: unknown) => string>,\n default: undefined as unknown,\n },\n itemToStringValue: {\n type: Function as PropType<(value: unknown) => string>,\n default: undefined as unknown,\n },\n id: String,\n },\n emits: [\n \"update:value\",\n \"valueChange\",\n \"update:inputValue\",\n \"inputValueChange\",\n \"update:open\",\n \"openChange\",\n \"update:values\",\n \"valuesChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createCombobox, { field, direction: useDirectionAround() }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n multiple: props.multiple,\n values: props.values,\n defaultValues: props.defaultValues,\n inline: props.inline,\n virtualized: props.virtualized,\n presentation: props.presentation,\n sheetBelow: props.sheetBelow,\n autoHighlight: props.autoHighlight,\n name: props.name,\n form: props.form,\n items: props.items,\n filter: props.filter,\n itemToStringLabel: props.itemToStringLabel as ComboboxProps[\"itemToStringLabel\"],\n itemToStringValue: props.itemToStringValue as ComboboxProps[\"itemToStringValue\"],\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n // With `multiple` the core tells the list here, as Base UI's `onValueChange` is told\n // it; the older events too, as a listener cannot be told from none.\n if (!props.multiple || !Array.isArray(value)) return\n emit(\"valuesChange\", value, details)\n if (!details.canceled) emit(\"update:values\", value)\n },\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n const named = fromSignal(made.named)\n return () => [slots.default?.(), named.value ? h(HiddenInput) : null]\n },\n}) as unknown as new <Value = unknown, Multiple extends boolean | undefined = false>(\n props: RootProps<Value, Multiple> & Listeners<RootEmits<Value, Multiple>> & PublicProps\n) => PlainInstance<RootProps<Value, Multiple>, RootEmits<Value, Multiple>, {}>\n\nexport interface ItemProps extends Omit<ComboboxItemOptions, \"id\">, PartComponentProps {\n /** What the combobox's value is while this item is the chosen one. */\n value: unknown\n id?: string | undefined\n}\n\n/** `label` is what is filtered and what the input shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"ComboboxItem\",\n inheritAttrs: false,\n props: {\n value: { type: ANY, required: true },\n disabled: optional(Boolean),\n label: String,\n id: String,\n index: Number,\n },\n setup(props, { attrs, slots }) {\n // An item is its value for as long as it is in the page.\n const value = props.value\n const generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n index: props.index,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(value, () => options.get(), inject(GROUP, null) ?? undefined)\n provide(ITEM, value)\n const Element = partComponent(\"ComboboxItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface ItemIndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not chosen. */\n keepMounted?: boolean | undefined\n}\n\nconst ItemIndicator = defineComponent({\n name: \"ComboboxItemIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const value = inject(ITEM)\n const made = scope.use()\n // In the page while chosen, and through its exit.\n const indicator = controller(\n () => made.itemIndicator(value),\n () => ({})\n )\n const mounted = fromSignal(indicator.mounted)\n const Element = partComponent(\"ComboboxItemIndicatorElement\", \"span\", () => indicator)\n return () => (mounted.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"itemIndicator\"], ItemIndicatorProps>\n\nexport interface ClearProps extends PartComponentProps {\n /** Keeps the button in the page while there is nothing to clear. */\n keepMounted?: boolean | undefined\n}\n\n/** A button that empties the input and the value. Drawn while there is something to clear. */\nconst Clear = defineComponent({\n name: \"ComboboxClear\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const clearable = fromSignal(made.clearable)\n const Element = partComponent(\"ComboboxClearElement\", \"button\", () => made.clear)\n return () => (clearable.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"button\", State[\"clear\"], ClearProps>\n\nconst CHIP: InjectionKey<unknown> = Symbol(\"ComboboxChip\")\n\nexport interface ChipProps extends PartComponentProps {\n /** The chosen value it stands for: what its remove button takes away. */\n value: unknown\n}\n\n/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */\nconst Chip = defineComponent({\n name: \"ComboboxChip\",\n inheritAttrs: false,\n props: { value: { type: ANY, required: true } },\n setup(props, { attrs, slots }) {\n // A chip is its value for as long as it is in the page.\n const value = props.value\n provide(CHIP, value)\n const part = scope.use().chip(value)\n const Element = partComponent(\"ComboboxChipElement\", \"span\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"chip\"], ChipProps>\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"ComboboxEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const made = scope.use()\n const empty = fromSignal(made.empty)\n const Element = partComponent(\"ComboboxEmptyElement\", \"div\", () => made.emptyPart)\n return () => (empty.value ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport interface ValueProps {\n /** What it shows while nothing is chosen. */\n placeholder?: string | undefined\n}\n\n/**\n * The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the\n * chosen labels with commas between. Or what its slot makes of them\n * (`v-slot=\"{ value, label }\"`, with `multiple` `v-slot=\"{ values, labels }\"`, in the order\n * they were chosen). For a button that is the combobox, its input inside the popup. It draws\n * no element.\n */\nconst Value = defineComponent({\n name: \"ComboboxValue\",\n props: { placeholder: { type: String, default: \"\" } },\n setup(props, { slots }) {\n const shown = fromSignal(scope.use().shown)\n return () =>\n slots.default ? slots.default(shown.value) : (shown.value.label ?? props.placeholder)\n },\n}) as unknown as PlainComponent<ValueProps, {}, ComboboxShown>\n\nexport interface CollectionProps {\n /** A group the root's `items` gave: its items left are then what is drawn. */\n of?: ComboboxEntry | undefined\n}\n\n/**\n * Draws the list from the root's `items`: its slot (`v-slot=\"{ entry }\"`) once for each item\n * left for what was typed, or for each group that has items left; with `of`, for each of that\n * group's. The root then filters, and no item hides itself. It draws no element.\n */\nconst Collection = defineComponent({\n name: \"ComboboxCollection\",\n props: { of: Object as PropType<ComboboxEntry> },\n setup(props, { slots }) {\n // A group is known by its key, which is its own for as long as it is drawn.\n const entries = fromSignal(scope.use().entries(props.of))\n return () =>\n entries.value.map((entry) => h(Fragment, { key: entry.key }, slots.default?.({ entry })))\n },\n}) as unknown as PlainComponent<CollectionProps, {}, { entry: ComboboxEntry }>\n\nexport type AutocompleteRootProps = Omit<\n AutocompleteProps,\n \"id\" | \"value\" | \"onValueChange\" | \"onOpenChange\"\n> & {\n /** The text, which is the value: `v-model`. */\n modelValue?: string | undefined\n id?: string | undefined\n}\n\nexport type AutocompleteRootEmits = {\n \"update:modelValue\": (value: string) => void\n valueChange: (value: string, details: ChangeDetails) => void\n} & Changes<\"open\", boolean>\n\n/** A combobox whose text is the value: `v-model` is the text. The list only suggests. */\nconst AutocompleteRoot = defineComponent({\n name: \"AutocompleteRoot\",\n props: {\n modelValue: String,\n defaultValue: String,\n open: optional(Boolean),\n defaultOpen: Boolean,\n mode: String as PropType<AutocompleteProps[\"mode\"]>,\n filter: {\n type: null as unknown as PropType<AutocompleteProps[\"filter\"]>,\n default: undefined,\n },\n openOnInputClick: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n items: [Array, Object] as PropType<AutocompleteProps[\"items\"]>,\n required: Boolean,\n name: String,\n form: String,\n virtualized: Object as PropType<AutocompleteProps[\"virtualized\"]>,\n autoHighlight: Boolean,\n id: String,\n },\n emits: [\"update:modelValue\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(within(createAutocomplete, { field: useFieldAround() }), () => ({\n id: props.id ?? generated,\n value: props.modelValue,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n mode: props.mode,\n filter: props.filter,\n openOnInputClick: props.openOnInputClick,\n disabled: props.disabled,\n readOnly: props.readOnly,\n items: props.items,\n required: props.required,\n name: props.name,\n form: props.form,\n virtualized: props.virtualized,\n autoHighlight: props.autoHighlight,\n onValueChange(value: string, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:modelValue\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<AutocompleteRootProps, AutocompleteRootEmits>\n\nexport type InputProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport type ChipsProps = PartComponentProps\nexport type ChipRemoveProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type BackdropProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport type StatusProps = PartComponentProps\n\n/**\n * Says how the list stands (\"3 results\", \"Loading\") to software that reads the page, as its\n * text changes. Keep it in the page and change what it holds: inside the popup, or beside the\n * input.\n */\nconst Status = partComponent<\"div\", State[\"status\"]>(\n \"ComboboxStatus\",\n \"div\",\n () => scope.use().status\n)\n\nexport const Combobox = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"ComboboxInput\", \"input\", () => scope.use().input),\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"ComboboxTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Value,\n Clear,\n /** With `multiple`: what holds the chips and the input. */\n Chips: partComponent<\"div\", State[\"chips\"]>(\"ComboboxChips\", \"div\", () => scope.use().chips),\n Chip,\n ChipRemove: partComponent<\"button\", State[\"chipRemove\"]>(\"ComboboxChipRemove\", \"button\", () =>\n scope.use().chipRemove(inject(CHIP))\n ),\n Portal: portalComponent(\"ComboboxPortal\", () => scope.use().mounted),\n /** What lies over the page behind the list: a sheet's (`presentation`) is modal. */\n Backdrop: partComponent<\"div\", State[\"backdrop\"]>(\n \"ComboboxBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n Positioner: positionerComponent<State[\"positioner\"]>(\n \"ComboboxPositioner\",\n () => scope.use(),\n partComponent(\"ComboboxPositionerElement\", \"div\", () => scope.use().positioner)\n ),\n Popup: partComponent<\"div\", State[\"popup\"]>(\"ComboboxPopup\", \"div\", () => scope.use().popup),\n /**\n * The items' own box inside the popup, when the popup holds more than items (an input): it\n * is then the listbox.\n */\n List: partComponent<\"div\", State[\"list\"]>(\"ComboboxList\", \"div\", () => scope.use().list),\n Collection,\n Group,\n GroupLabel,\n /** A line between groups. */\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"ComboboxSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Item,\n ItemIndicator,\n Empty,\n Status,\n}\n\nexport const Autocomplete = {\n Root: AutocompleteRoot,\n Input: Combobox.Input,\n Trigger: Combobox.Trigger,\n Clear: Combobox.Clear,\n Portal: Combobox.Portal,\n Positioner: Combobox.Positioner,\n Popup: Combobox.Popup,\n List: Combobox.List,\n Collection: Combobox.Collection,\n Group: Combobox.Group,\n GroupLabel: Combobox.GroupLabel,\n Separator: Combobox.Separator,\n Item: Combobox.Item,\n Empty: Combobox.Empty,\n Status: Combobox.Status,\n}\n"],"mappings":";;;;;;;;;AA2CA,MAAM,QAAQ,QAAoB,UAAU;AAC5C,MAAM,OAA8B,OAAO,cAAc;AACzD,MAAM,MAAM;AAEZ,MAAM,QAA4C,OAAO,eAAe;;AAOxE,MAAM,QAAQ,gBAAgB;CAC5B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,IAAI,OAAO;CACpB,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,SAAS;EACrD,QAAQ,OAAO,KAAK;EACpB,MAAM,UAAU,cAAc,wBAAwB,aAAa,MAAM,IAAI;EAC7E,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;;AAGD,MAAM,aAAa,cACjB,sBACA,aACM,OAA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AAC,QACpB;CACA,YAAY,oBACV,4BACM,MAAM,IAAI,GAChB,cAAc,6BAA6B,aAAa,MAAM,IAAI,CAAC,CAAC,UAAU,CAChF;CACA,OAAO,cAAqC,iBAAiB,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;;;;;CAK3F,MAAM,cAAoC,gBAAgB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACvF;CACA;CACA;;CAEA,WAAW,cACT,qBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,eAAe;CAC1B,MAAM;CACN,OAAO,SAAS;CAChB,SAAS,SAAS;CAClB,OAAO,SAAS;CAChB,QAAQ,SAAS;CACjB,YAAY,SAAS;CACrB,OAAO,SAAS;CAChB,MAAM,SAAS;CACf,YAAY,SAAS;CACrB,OAAO,SAAS;CAChB,YAAY,SAAS;CACrB,WAAW,SAAS;CACpB,MAAM,SAAS;CACf,OAAO,SAAS;CAChB,QAAQ,SAAS;AACnB"}
package/src/command.d.ts CHANGED
@@ -14,8 +14,8 @@ export interface GroupProps extends PartComponentProps {
14
14
  }
15
15
  export type GroupHeadingProps = PartComponentProps;
16
16
  export interface ItemProps extends Omit<CommandItemOptions, "id">, PartComponentProps {
17
- /** What `@select` is told when this item is chosen. */
18
- value: string;
17
+ /** What `@select` is told when this item is chosen; its `label`, or its text, when left out. */
18
+ value?: string | undefined;
19
19
  id?: string | undefined;
20
20
  }
21
21
  export interface SeparatorProps extends PartComponentProps {
package/src/command.js CHANGED
@@ -17,6 +17,7 @@ const Root = defineComponent({
17
17
  default: void 0
18
18
  },
19
19
  loop: Boolean,
20
+ autoHighlight: optional(Boolean),
20
21
  disabled: Boolean,
21
22
  id: String
22
23
  },
@@ -33,6 +34,7 @@ const Root = defineComponent({
33
34
  defaultInputValue: props.defaultInputValue,
34
35
  filter: props.filter,
35
36
  loop: props.loop,
37
+ autoHighlight: props.autoHighlight,
36
38
  disabled: props.disabled,
37
39
  onInputValueChange(value, details) {
38
40
  emit("inputValueChange", value, details);
@@ -82,7 +84,7 @@ const Item = defineComponent({
82
84
  props: {
83
85
  value: {
84
86
  type: String,
85
- required: true
87
+ default: void 0
86
88
  },
87
89
  disabled: optional(Boolean),
88
90
  label: String,
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","names":[],"sources":["../../../../packages/vue/src/command.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCommand } from \"@kirana-ui/core/command\"\nimport type {\n CommandGroup,\n CommandItemOptions,\n CommandProps,\n Command as Controller,\n} from \"@kirana-ui/core/command\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"command\">\n\nconst scope = context<Controller>(\"Command\")\nconst GROUP: InjectionKey<CommandGroup> = Symbol(\"CommandGroup\")\n\nconst RootElement = partComponent(\"CommandRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CommandProps, \"id\" | \"onInputValueChange\" | \"onSelect\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"inputValue\", string> & {\n /** An item was chosen: its value. */\n select: (value: string, details: ChangeDetails) => void\n}\n\n/** `v-model:inputValue`; `@select` hears the item chosen. */\nconst Root = defineComponent({\n name: \"CommandRoot\",\n inheritAttrs: false,\n props: {\n inputValue: String,\n defaultInputValue: String,\n filter: {\n type: null as unknown as PropType<CommandProps[\"filter\"]>,\n default: undefined,\n },\n loop: Boolean,\n disabled: Boolean,\n id: String,\n },\n emits: [\"update:inputValue\", \"inputValueChange\", \"select\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createCommand, () => ({\n id: props.id ?? generated,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n filter: props.filter,\n loop: props.loop,\n disabled: props.disabled,\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", value)\n },\n onSelect: (value: string, details: ChangeDetails) => emit(\"select\", value, details),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nconst EmptyElement = partComponent(\"CommandEmptyElement\", \"div\", () => scope.use().emptyPart)\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"CommandEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const empty = fromSignal(scope.use().empty)\n return () => (empty.value ? h(EmptyElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */\nconst Group = defineComponent({\n name: \"CommandGroup\",\n inheritAttrs: false,\n props: { id: String },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const group = scope.use().group(props.id ?? generated)\n provide(GROUP, group)\n const Element = partComponent(\"CommandGroupElement\", \"div\", () => group.part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\nexport type GroupHeadingProps = PartComponentProps\n\nconst GroupHeading = defineComponent({\n name: \"CommandGroupHeading\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const part = inject(GROUP, undefined)?.heading ?? scope.use().heading\n const Element = partComponent(\"CommandGroupHeadingElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"groupHeading\"], GroupHeadingProps>\n\nexport interface ItemProps extends Omit<CommandItemOptions, \"id\">, PartComponentProps {\n /** What `@select` is told when this item is chosen. */\n value: string\n id?: string | undefined\n}\n\n/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */\nconst Item = defineComponent({\n name: \"CommandItem\",\n inheritAttrs: false,\n props: {\n value: { type: String, required: true },\n disabled: optional(Boolean),\n label: String,\n keywords: Array as PropType<readonly string[]>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n keywords: props.keywords,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(props.value, () => options.get(), inject(GROUP, undefined))\n const Element = partComponent(\"CommandItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface SeparatorProps extends PartComponentProps {\n /** Keeps the line while something is typed. */\n alwaysRender?: boolean | undefined\n}\n\n/** A line between groups: gone while something is typed, unless `always-render`. */\nconst Separator = defineComponent({\n name: \"CommandSeparator\",\n inheritAttrs: false,\n props: { alwaysRender: Boolean },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ alwaysRender: props.alwaysRender }))\n const part = scope.use().separator(() => options.get().alwaysRender)\n const Element = partComponent(\"CommandSeparatorElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"separator\"], SeparatorProps>\n\nexport type InputProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport const Command = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"CommandInput\", \"input\", () => scope.use().input),\n List: partComponent<\"div\", State[\"list\"]>(\"CommandList\", \"div\", () => scope.use().list),\n Empty,\n Group,\n GroupHeading,\n Item,\n Separator,\n}\n"],"mappings":";;;;AAgBA,MAAM,QAAQ,QAAoB,SAAS;AAC3C,MAAM,QAAoC,OAAO,cAAc;AAE/D,MAAM,cAAc,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYrF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,YAAY;EACZ,mB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C,KAAK;CAC9F,MAAM,cAAoC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACtF;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"command.js","names":[],"sources":["../../../../packages/vue/src/command.ts"],"sourcesContent":["import type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCommand } from \"@kirana-ui/core/command\"\nimport type {\n CommandGroup,\n CommandItemOptions,\n CommandProps,\n Command as Controller,\n} from \"@kirana-ui/core/command\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { context, controller, fromSignal, optional, partComponent, toSignal } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"command\">\n\nconst scope = context<Controller>(\"Command\")\nconst GROUP: InjectionKey<CommandGroup> = Symbol(\"CommandGroup\")\n\nconst RootElement = partComponent(\"CommandRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CommandProps, \"id\" | \"onInputValueChange\" | \"onSelect\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"inputValue\", string> & {\n /** An item was chosen: its value. */\n select: (value: string, details: ChangeDetails) => void\n}\n\n/** `v-model:inputValue`; `@select` hears the item chosen. */\nconst Root = defineComponent({\n name: \"CommandRoot\",\n inheritAttrs: false,\n props: {\n inputValue: String,\n defaultInputValue: String,\n filter: {\n type: null as unknown as PropType<CommandProps[\"filter\"]>,\n default: undefined,\n },\n loop: Boolean,\n autoHighlight: optional(Boolean),\n disabled: Boolean,\n id: String,\n },\n emits: [\"update:inputValue\", \"inputValueChange\", \"select\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n scope.provide(\n controller(createCommand, () => ({\n id: props.id ?? generated,\n inputValue: props.inputValue,\n defaultInputValue: props.defaultInputValue,\n filter: props.filter,\n loop: props.loop,\n autoHighlight: props.autoHighlight,\n disabled: props.disabled,\n onInputValueChange(value: string, details: ChangeDetails) {\n emit(\"inputValueChange\", value, details)\n if (!details.canceled) emit(\"update:inputValue\", value)\n },\n onSelect: (value: string, details: ChangeDetails) => emit(\"select\", value, details),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nconst EmptyElement = partComponent(\"CommandEmptyElement\", \"div\", () => scope.use().emptyPart)\n\nexport type EmptyProps = PartComponentProps\n\n/** Drawn while no item is shown for what was typed. */\nconst Empty = defineComponent({\n name: \"CommandEmpty\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const empty = fromSignal(scope.use().empty)\n return () => (empty.value ? h(EmptyElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"div\", State[\"empty\"], EmptyProps>\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */\nconst Group = defineComponent({\n name: \"CommandGroup\",\n inheritAttrs: false,\n props: { id: String },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const group = scope.use().group(props.id ?? generated)\n provide(GROUP, group)\n const Element = partComponent(\"CommandGroupElement\", \"div\", () => group.part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"group\"], GroupProps>\n\nexport type GroupHeadingProps = PartComponentProps\n\nconst GroupHeading = defineComponent({\n name: \"CommandGroupHeading\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const part = inject(GROUP, undefined)?.heading ?? scope.use().heading\n const Element = partComponent(\"CommandGroupHeadingElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"groupHeading\"], GroupHeadingProps>\n\nexport interface ItemProps extends Omit<CommandItemOptions, \"id\">, PartComponentProps {\n /** What `@select` is told when this item is chosen; its `label`, or its text, when left out. */\n value?: string | undefined\n id?: string | undefined\n}\n\n/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */\nconst Item = defineComponent({\n name: \"CommandItem\",\n inheritAttrs: false,\n props: {\n value: { type: String, default: undefined },\n disabled: optional(Boolean),\n label: String,\n keywords: Array as PropType<readonly string[]>,\n id: String,\n },\n setup(props, { attrs, slots }) {\n const generated = useId()\n const options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n keywords: props.keywords,\n id: props.id ?? generated,\n }))\n const part = scope.use().item(props.value, () => options.get(), inject(GROUP, undefined))\n const Element = partComponent(\"CommandItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface SeparatorProps extends PartComponentProps {\n /** Keeps the line while something is typed. */\n alwaysRender?: boolean | undefined\n}\n\n/** A line between groups: gone while something is typed, unless `always-render`. */\nconst Separator = defineComponent({\n name: \"CommandSeparator\",\n inheritAttrs: false,\n props: { alwaysRender: Boolean },\n setup(props, { attrs, slots }) {\n const options = toSignal(() => ({ alwaysRender: props.alwaysRender }))\n const part = scope.use().separator(() => options.get().alwaysRender)\n const Element = partComponent(\"CommandSeparatorElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"separator\"], SeparatorProps>\n\nexport type InputProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport const Command = {\n Root,\n Input: partComponent<\"input\", State[\"input\"]>(\"CommandInput\", \"input\", () => scope.use().input),\n List: partComponent<\"div\", State[\"list\"]>(\"CommandList\", \"div\", () => scope.use().list),\n Empty,\n Group,\n GroupHeading,\n Item,\n Separator,\n}\n"],"mappings":";;;;AAgBA,MAAM,QAAQ,QAAoB,SAAS;AAC3C,MAAM,QAAoC,OAAO,cAAc;AAE/D,MAAM,cAAc,cAAc,sBAAsB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYrF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,YAAY;EACZ,mBAAmB;EACn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AuC,gBAAgB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;CAC9F,MAAM,cAAoC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;CACtF;CACA;CACA;CACA;CACA;AACF"}
@@ -29,7 +29,7 @@ export declare const DateField: {
29
29
  segment: DateFieldSegment;
30
30
  }>;
31
31
  Segment: PartComponent<"span", {
32
- readonly segment?: "day" | "literal" | "month" | "year" | undefined;
32
+ readonly segment?: "day" | "era" | "literal" | "month" | "year" | undefined;
33
33
  readonly placeholder?: true | undefined;
34
34
  readonly disabled?: true | undefined;
35
35
  readonly invalid?: true | undefined;
package/src/date-field.js CHANGED
@@ -18,6 +18,7 @@ const DateField = {
18
18
  value: optional([String, null]),
19
19
  defaultValue: String,
20
20
  locale: String,
21
+ calendarSystem: Object,
21
22
  min: String,
22
23
  max: String,
23
24
  placeholders: Object,
@@ -37,6 +38,7 @@ const DateField = {
37
38
  value: props.value,
38
39
  defaultValue: props.defaultValue,
39
40
  locale: props.locale,
41
+ calendarSystem: props.calendarSystem,
40
42
  min: props.min,
41
43
  max: props.max,
42
44
  placeholders: props.placeholders,
@@ -1 +1 @@
1
- {"version":3,"file":"date-field.js","names":[],"sources":["../../../../packages/vue/src/date-field.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createDateField } from \"@kirana-ui/core/date-field\"\nimport type {\n DateField as Controller,\n DateFieldProps,\n DateFieldSegment,\n} from \"@kirana-ui/core/date-field\"\nimport { Fragment, defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-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<\"dateField\">\n\n/**\n * The date field its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the date field's parts).\n */\nconst scope = context<Controller>(\"DateField\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as dateFieldScope }\n\nconst RootElement = partComponent(\"DateFieldRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<DateFieldProps, \"id\" | \"onValueChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\n/** The value is `null` while the date is not whole. */\nexport type RootEmits = Changes<\"value\", string | null>\n\n/** `v-model:value`, and `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"DateFieldRoot\",\n inheritAttrs: false,\n props: {\n value: optional([String, null] as unknown as PropType<string | null>),\n defaultValue: String as PropType<string | null>,\n locale: String,\n min: String,\n max: String,\n placeholders: Object as PropType<DateFieldProps[\"placeholders\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createDateField, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n locale: props.locale,\n min: props.min,\n max: props.max,\n placeholders: props.placeholders,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n onValueChange(value: string | null, 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 PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type SegmentsProps = Record<never, never>\n\n/** Its slot once for each piece of the date, in the locale's order: `v-slot=\"{ segment }\"`. */\nconst Segments = defineComponent({\n name: \"DateFieldSegments\",\n setup(_, { slots }) {\n const segments = fromSignal(scope.use().segments)\n return () =>\n segments.value.map((segment) =>\n h(Fragment, { key: `${segment.index}-${segment.type}` }, slots.default?.({ segment }))\n )\n },\n}) as unknown as PlainComponent<SegmentsProps, {}, { segment: DateFieldSegment }>\n\nexport interface SegmentProps extends PartComponentProps {\n /** The piece it draws, as `DateField.Segments` gives it. */\n segment: DateFieldSegment\n}\n\n/** One piece: a part that is typed, or what stands between two. It writes its own text. */\nconst Segment = defineComponent({\n name: \"DateFieldSegment\",\n inheritAttrs: false,\n props: { segment: { type: Object as PropType<DateFieldSegment>, required: true } },\n setup(props, { attrs, slots }) {\n const { part, text } = scope.use().segment(props.segment)\n const shown = fromSignal(text)\n // Its text is the field's to write, whatever its slot holds: with `as-child` the slot is\n // the caller's element, which holds the text unless it writes its own.\n const Element = partComponent(\n \"DateFieldSegmentElement\",\n \"span\",\n () => part,\n (content, composed) =>\n composed && content != null && content.length > 0 ? content : [shown.value]\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"segment\"], SegmentProps>\n\nexport type InputProps = PartComponentProps\nconst Input = partComponent<\"input\", State[\"input\"]>(\n \"DateFieldInput\",\n \"input\",\n () => scope.use().input\n)\n\nexport const DateField = { Root, Segments, Segment, Input }\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,QAAQ,QAAoB,WAAW;AAI7C,MAAM,cAAc,cAAc,wBAAwB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;AAsGvF,MAAa,YAAY;CAAE,MA5Fd,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO;GACL,OAAO,SAAS,CAAC,QAAQ,IAAI,CAAuC;GACpE,cAAc;GACd,QAAQ;GACR,KAAK;GACL,KAAK;GACL,cAAc;GACd,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,YAAY,mBAAmB;GACrC,MAAM,QACJ,WAAW,OAAO,iBAAiB,EAAE,UAAU,CAAC,UAAU;IACxD,IAAI,MAAM,MAAM;IAChB,OAAO,MAAM;IACb,cAAc,MAAM;IACpB,QAAQ,MAAM;IACd,KAAK,MAAM;IACX,KAAK,MAAM;IACX,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,cAAc,OAAsB,SAAwB;KAC1D,KAAK,eAAe,OAAO,OAAO;KAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;IACnD;GACF,EAAE,CACJ;GACA,aAAa,EAAE,aAAa,OAAO,KAAK;EAC1C;CACF,CAiD2B;CAAM,UA5ChB,gBAAgB;EAC/B,MAAM;EACN,MAAM,GAAG,EAAE,SAAS;GAClB,MAAM,WAAW,WAAW,MAAM,IAAI,CAAC,CAAC,QAAQ;GAChD,aACE,SAAS,MAAM,KAAK,YAClB,EAAE,UAAU,EAAE,KAAK,GAAG,QAAQ,MAAM,GAAG,QAAQ,OAAO,GAAG,MAAM,UAAU,EAAE,QAAQ,CAAC,CAAC,CACvF;EACJ;CACF,CAmCiC;CAAU,SA3B3B,gBAAgB;EAC9B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,SAAS;GAAE,MAAM;GAAsC,UAAU;EAAK,EAAE;EACjF,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,MAAM,SAAS,MAAM,IAAI,CAAC,CAAC,QAAQ,MAAM,OAAO;GACxD,MAAM,QAAQ,WAAW,IAAI;GAG7B,MAAM,UAAU,cACd,2BACA,cACM,OACL,SAAS,aACR,YAAY,WAAW,QAAQ,QAAQ,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,CAC9E;GACA,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAS2C;CAAS,OANtC,cACZ,kBACA,eACM,MAAM,IAAI,CAAC,CAAC,KAGgC;AAAM"}
1
+ {"version":3,"file":"date-field.js","names":[],"sources":["../../../../packages/vue/src/date-field.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createDateField } from \"@kirana-ui/core/date-field\"\nimport type {\n DateField as Controller,\n DateFieldProps,\n DateFieldSegment,\n} from \"@kirana-ui/core/date-field\"\nimport { Fragment, defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-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<\"dateField\">\n\n/**\n * The date field its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the date field's parts).\n */\nconst scope = context<Controller>(\"DateField\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as dateFieldScope }\n\nconst RootElement = partComponent(\"DateFieldRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<DateFieldProps, \"id\" | \"onValueChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\n/** The value is `null` while the date is not whole. */\nexport type RootEmits = Changes<\"value\", string | null>\n\n/** `v-model:value`, and `@value-change=\"(value, details) => …\"`. */\nconst Root = defineComponent({\n name: \"DateFieldRoot\",\n inheritAttrs: false,\n props: {\n value: optional([String, null] as unknown as PropType<string | null>),\n defaultValue: String as PropType<string | null>,\n locale: String,\n calendarSystem: Object as PropType<DateFieldProps[\"calendarSystem\"]>,\n min: String,\n max: String,\n placeholders: Object as PropType<DateFieldProps[\"placeholders\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createDateField, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n locale: props.locale,\n calendarSystem: props.calendarSystem,\n min: props.min,\n max: props.max,\n placeholders: props.placeholders,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n onValueChange(value: string | null, 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 PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type SegmentsProps = Record<never, never>\n\n/** Its slot once for each piece of the date, in the locale's order: `v-slot=\"{ segment }\"`. */\nconst Segments = defineComponent({\n name: \"DateFieldSegments\",\n setup(_, { slots }) {\n const segments = fromSignal(scope.use().segments)\n return () =>\n segments.value.map((segment) =>\n h(Fragment, { key: `${segment.index}-${segment.type}` }, slots.default?.({ segment }))\n )\n },\n}) as unknown as PlainComponent<SegmentsProps, {}, { segment: DateFieldSegment }>\n\nexport interface SegmentProps extends PartComponentProps {\n /** The piece it draws, as `DateField.Segments` gives it. */\n segment: DateFieldSegment\n}\n\n/** One piece: a part that is typed, or what stands between two. It writes its own text. */\nconst Segment = defineComponent({\n name: \"DateFieldSegment\",\n inheritAttrs: false,\n props: { segment: { type: Object as PropType<DateFieldSegment>, required: true } },\n setup(props, { attrs, slots }) {\n const { part, text } = scope.use().segment(props.segment)\n const shown = fromSignal(text)\n // Its text is the field's to write, whatever its slot holds: with `as-child` the slot is\n // the caller's element, which holds the text unless it writes its own.\n const Element = partComponent(\n \"DateFieldSegmentElement\",\n \"span\",\n () => part,\n (content, composed) =>\n composed && content != null && content.length > 0 ? content : [shown.value]\n )\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"segment\"], SegmentProps>\n\nexport type InputProps = PartComponentProps\nconst Input = partComponent<\"input\", State[\"input\"]>(\n \"DateFieldInput\",\n \"input\",\n () => scope.use().input\n)\n\nexport const DateField = { Root, Segments, Segment, Input }\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,QAAQ,QAAoB,WAAW;AAI7C,MAAM,cAAc,cAA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;EAC9B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,SAAS;GAAE,MAAM;GAAsC,UAAU;EAAK,EAAE;EACjF,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,EAAE,MAAM,SAAS,MAAM,IAAI,CAAC,CAAC,QAAQ,MAAM,OAAO;GACxD,MAAM,QAAQ,WAAW,IAAI;GAG7B,MAAM,UAAU,cACd,2BACA,cACM,OACL,SAAS,aACR,YAAY,WAAW,QAAQ,QAAQ,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,CAC9E;GACA,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAS2C;CAAS,OANtC,cACZ,kBACA,eACM,MAAM,IAAI,CAAC,CAAC,KAGgC;AAAM"}
@@ -1,28 +1,40 @@
1
- import { Changes, PartComponent, PartComponentProps, PlainComponent, PortalProps } from "./runtime.js";
2
1
  import { InputProps, SegmentProps, SegmentsProps } from "./date-field.js";
2
+ import { Changes, Listeners, PartComponent, PartComponentProps, PlainComponent, PlainInstance, PortalProps } from "./runtime.js";
3
3
  import { PopupProps, PositionerProps, TriggerProps } from "./popover.js";
4
- import { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, NextProps, PreviousProps, WeekdaysProps, WeeksProps } from "./calendar.js";
5
- import { DatePickerProps } from "@kirana-ui/core/date-picker";
6
- export type RootProps = Omit<DatePickerProps, "id" | "onValueChange" | "onOpenChange"> & {
4
+ import { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, MonthsProps, NextProps, PreviousProps, WeekdaysProps, WeeksProps } from "./calendar.js";
5
+ import { PublicProps } from "vue";
6
+ import { DatePickerMode, DatePickerProps, DatePickerRange, DatePickerValueOf } from "@kirana-ui/core/date-picker";
7
+ /** `value` and its events are typed by `mode`: a day, or a range. */
8
+ export type RootProps<Mode extends DatePickerMode = "single"> = Omit<DatePickerProps<Mode>, "id" | "onValueChange" | "onOpenChange" | "onMonthChange"> & {
7
9
  id?: string | undefined;
8
10
  };
9
11
  /** The value is `null` while the date is not whole. */
10
- export type RootEmits = Changes<"value", string | null> & Changes<"open", boolean>;
11
- export type FieldProps = PartComponentProps;
12
+ export type RootEmits<Mode extends DatePickerMode = "single"> = Changes<"value", DatePickerValueOf<Mode>> & Changes<"open", boolean> & Changes<"month", string>;
13
+ export interface FieldProps extends PartComponentProps {
14
+ /**
15
+ * With `mode="range"`: which day of the range it is typed in, the first (`"start"`, the
16
+ * default) or the last (`"end"`).
17
+ */
18
+ range?: "start" | "end" | undefined;
19
+ }
12
20
  export type CalendarProps = PartComponentProps;
21
+ export type ClearProps = PartComponentProps;
22
+ export interface PresetProps extends PartComponentProps {
23
+ /** The value its press gives: a day, or with `mode="range"` a range. */
24
+ value: string | DatePickerRange;
25
+ }
13
26
  export declare const DatePicker: {
14
- Root: PlainComponent<RootProps, RootEmits>;
15
- /** The typed date: what holds its segments and its hidden input. */
27
+ Root: new <Mode extends DatePickerMode = "single">(props: RootProps<Mode> & Listeners<RootEmits<Mode>> & PublicProps) => PlainInstance<RootProps<Mode>, RootEmits<Mode>, {}>;
16
28
  Field: PartComponent<"div", {
17
29
  readonly disabled?: true | undefined;
18
30
  readonly readonly?: true | undefined;
19
31
  readonly invalid?: true | undefined;
20
- }, PartComponentProps, {}, unknown>;
32
+ }, FieldProps>;
21
33
  Segments: PlainComponent<SegmentsProps, {}, {
22
34
  segment: import("@kirana-ui/core/date-field").DateFieldSegment;
23
35
  }>;
24
36
  Segment: PartComponent<"span", {
25
- readonly segment?: "day" | "literal" | "month" | "year" | undefined;
37
+ readonly segment?: "day" | "era" | "literal" | "month" | "year" | undefined;
26
38
  readonly placeholder?: true | undefined;
27
39
  readonly disabled?: true | undefined;
28
40
  readonly invalid?: true | undefined;
@@ -30,13 +42,15 @@ export declare const DatePicker: {
30
42
  Input: PartComponent<"input", Record<never, never>, PartComponentProps, {}, unknown>;
31
43
  Trigger: PartComponent<"button", {
32
44
  readonly popupOpen?: true | undefined;
33
- }, PartComponentProps, {}, unknown>;
45
+ readonly pressed?: true | undefined;
46
+ }, TriggerProps>;
34
47
  Portal: PlainComponent<PortalProps, {}, {}>;
35
48
  Positioner: PartComponent<"div", {
36
49
  readonly open?: true | undefined;
37
50
  readonly closed?: true | undefined;
38
51
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
39
52
  readonly align?: "center" | "end" | "start" | undefined;
53
+ readonly anchorHidden?: true | undefined;
40
54
  }, PositionerProps>;
41
55
  Popup: PartComponent<"div", {
42
56
  readonly open?: true | undefined;
@@ -45,6 +59,7 @@ export declare const DatePicker: {
45
59
  readonly endingStyle?: true | undefined;
46
60
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
47
61
  readonly align?: "center" | "end" | "start" | undefined;
62
+ readonly instant?: "click" | "dismiss" | undefined;
48
63
  }, PartComponentProps, {}, unknown>;
49
64
  /** The calendar: what holds its heading, its buttons and its grid. */
50
65
  Calendar: PartComponent<"div", {
@@ -58,6 +73,9 @@ export declare const DatePicker: {
58
73
  Next: PartComponent<"button", {
59
74
  readonly disabled?: true | undefined;
60
75
  }, PartComponentProps, {}, unknown>;
76
+ Months: PlainComponent<MonthsProps, {}, {
77
+ month: import("@kirana-ui/core/calendar").CalendarMonth;
78
+ }>;
61
79
  Grid: PartComponent<"table", Record<never, never>, PartComponentProps, {}, unknown>;
62
80
  Weekdays: PlainComponent<WeekdaysProps, {}, {
63
81
  weekday: import("@kirana-ui/core/calendar").CalendarWeekday;
@@ -83,7 +101,15 @@ export declare const DatePicker: {
83
101
  readonly unavailable?: true | undefined;
84
102
  readonly rangeStart?: true | undefined;
85
103
  readonly rangeEnd?: true | undefined;
86
- }, CellProps>;
104
+ }, DayProps>;
105
+ /** Empties the value, and gives focus to the field. Disabled while there is none. */
106
+ Clear: PartComponent<"button", {
107
+ readonly disabled?: true | undefined;
108
+ }, PartComponentProps, {}, unknown>;
109
+ Preset: PartComponent<"button", {
110
+ readonly pressed?: true | undefined;
111
+ readonly disabled?: true | undefined;
112
+ }, PresetProps>;
87
113
  };
88
- export type { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, InputProps, NextProps, PopupProps, PortalProps, PositionerProps, PreviousProps, SegmentProps, SegmentsProps, TriggerProps, WeekdaysProps, WeeksProps };
114
+ export type { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, InputProps, MonthsProps, NextProps, PopupProps, PortalProps, PositionerProps, PreviousProps, SegmentProps, SegmentsProps, TriggerProps, WeekdaysProps, WeeksProps };
89
115
  //# sourceMappingURL=date-picker.d.ts.map
@@ -4,60 +4,109 @@ import { useDirectionAround } from "./direction-context.js";
4
4
  import { Popover, popoverScope as scope$3 } from "./popover.js";
5
5
  import { context, controller, optional, partComponent } from "./runtime.js";
6
6
  import { within } from "@kirana-ui/core";
7
- import { defineComponent, useId } from "vue";
7
+ import { defineComponent, h, useId } from "vue";
8
8
  import { createDatePicker } from "@kirana-ui/core/date-picker";
9
9
  // src/date-picker.ts
10
10
  const scope = context("DatePicker");
11
+ /**
12
+ * A date field, and a calendar in a popover, with one value between them. It draws nothing.
13
+ * `v-model:value`, `v-model:open`, `v-model:month` (the first day of the month the calendar
14
+ * shows); the `-change` events carry the details.
15
+ */
16
+ const Root = defineComponent({
17
+ name: "DatePickerRoot",
18
+ props: {
19
+ value: optional([
20
+ String,
21
+ Object,
22
+ null
23
+ ]),
24
+ defaultValue: [String, Object],
25
+ mode: String,
26
+ open: optional(Boolean),
27
+ defaultOpen: Boolean,
28
+ locale: String,
29
+ min: String,
30
+ max: String,
31
+ isDateUnavailable: Function,
32
+ calendarSystem: Object,
33
+ fixedWeeks: Boolean,
34
+ months: Number,
35
+ pagedNavigation: Boolean,
36
+ month: optional(String),
37
+ defaultMonth: String,
38
+ placeholders: Object,
39
+ disabled: Boolean,
40
+ readOnly: Boolean,
41
+ required: Boolean,
42
+ name: String,
43
+ form: String,
44
+ id: String
45
+ },
46
+ emits: [
47
+ "update:value",
48
+ "valueChange",
49
+ "update:open",
50
+ "openChange",
51
+ "update:month",
52
+ "monthChange"
53
+ ],
54
+ setup(props, { slots, emit }) {
55
+ const generated = useId();
56
+ const made = scope.provide(controller(within(createDatePicker, { direction: useDirectionAround() }), () => ({
57
+ ...props,
58
+ id: props.id ?? generated,
59
+ onValueChange(value, details) {
60
+ emit("valueChange", value, details);
61
+ if (!details.canceled) emit("update:value", value);
62
+ },
63
+ onOpenChange(open, details) {
64
+ emit("openChange", open, details);
65
+ if (!details.canceled) emit("update:open", open);
66
+ },
67
+ onMonthChange(month, details) {
68
+ emit("monthChange", month, details);
69
+ if (!details.canceled) emit("update:month", month);
70
+ }
71
+ })));
72
+ scope$2.provide(made.field);
73
+ scope$3.provide(made.popover);
74
+ scope$1.provide(made.calendar);
75
+ return () => slots.default?.();
76
+ }
77
+ });
78
+ const FieldElement = partComponent("DatePickerFieldElement", "div", () => scope$2.use().root);
79
+ /**
80
+ * The typed date: what holds its segments and its hidden input. With `mode="range"` there are
81
+ * two, `range="start"` and `range="end"`, each giving its own parts their field.
82
+ */
83
+ const Field = defineComponent({
84
+ name: "DatePickerField",
85
+ inheritAttrs: false,
86
+ props: { range: String },
87
+ setup(props, { attrs, slots }) {
88
+ const picker = scope.use();
89
+ scope$2.provide(props.range === "end" && picker.endField || picker.field);
90
+ return () => h(FieldElement, attrs, slots);
91
+ }
92
+ });
93
+ /** Makes the value the one it is given: pressed while it is. */
94
+ const Preset = defineComponent({
95
+ name: "DatePickerPreset",
96
+ inheritAttrs: false,
97
+ props: { value: {
98
+ type: [String, Object],
99
+ required: true
100
+ } },
101
+ setup(props, { attrs, slots }) {
102
+ const part = scope.use().preset(props.value);
103
+ const Element = partComponent("DatePickerPresetElement", "button", () => part);
104
+ return () => h(Element, attrs, slots);
105
+ }
106
+ });
11
107
  const DatePicker = {
12
- Root: defineComponent({
13
- name: "DatePickerRoot",
14
- props: {
15
- value: optional([String, null]),
16
- defaultValue: String,
17
- open: optional(Boolean),
18
- defaultOpen: Boolean,
19
- locale: String,
20
- min: String,
21
- max: String,
22
- isDateUnavailable: Function,
23
- calendarSystem: Object,
24
- fixedWeeks: Boolean,
25
- placeholders: Object,
26
- disabled: Boolean,
27
- readOnly: Boolean,
28
- required: Boolean,
29
- name: String,
30
- form: String,
31
- id: String
32
- },
33
- emits: [
34
- "update:value",
35
- "valueChange",
36
- "update:open",
37
- "openChange"
38
- ],
39
- setup(props, { slots, emit }) {
40
- const generated = useId();
41
- const made = scope.provide(controller(within(createDatePicker, { direction: useDirectionAround() }), () => ({
42
- ...props,
43
- id: props.id ?? generated,
44
- onValueChange(value, details) {
45
- emit("valueChange", value, details);
46
- if (!details.canceled) emit("update:value", value);
47
- },
48
- onOpenChange(open, details) {
49
- emit("openChange", open, details);
50
- if (!details.canceled) emit("update:open", open);
51
- }
52
- })));
53
- scope$2.provide(made.field);
54
- scope$3.provide(made.popover);
55
- scope$1.provide(made.calendar);
56
- return () => slots.default?.();
57
- }
58
- }),
59
- /** The typed date: what holds its segments and its hidden input. */
60
- Field: partComponent("DatePickerField", "div", () => scope.use().field.root),
108
+ Root,
109
+ Field,
61
110
  Segments: DateField.Segments,
62
111
  Segment: DateField.Segment,
63
112
  Input: DateField.Input,
@@ -70,12 +119,16 @@ const DatePicker = {
70
119
  Heading: Calendar.Heading,
71
120
  Previous: Calendar.Previous,
72
121
  Next: Calendar.Next,
122
+ Months: Calendar.Months,
73
123
  Grid: Calendar.Grid,
74
124
  Weekdays: Calendar.Weekdays,
75
125
  HeadCell: Calendar.HeadCell,
76
126
  Weeks: Calendar.Weeks,
77
127
  Cell: Calendar.Cell,
78
- Day: Calendar.Day
128
+ Day: Calendar.Day,
129
+ /** Empties the value, and gives focus to the field. Disabled while there is none. */
130
+ Clear: partComponent("DatePickerClear", "button", () => scope.use().clear),
131
+ Preset
79
132
  };
80
133
  export { DatePicker };
81
134
 
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.js","names":[],"sources":["../../../../packages/vue/src/date-picker.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createDatePicker } from \"@kirana-ui/core/date-picker\"\nimport type { DatePicker as Controller, DatePickerProps } from \"@kirana-ui/core/date-picker\"\nimport { defineComponent, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { Calendar, calendarScope } from \"./calendar.ts\"\nimport { DateField, dateFieldScope } from \"./date-field.ts\"\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { Popover, popoverScope } from \"./popover.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponentProps, PlainComponent, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"datePicker\">\n\nconst scope = context<Controller>(\"DatePicker\")\n\nexport type RootProps = Omit<DatePickerProps, \"id\" | \"onValueChange\" | \"onOpenChange\"> & {\n id?: string | undefined\n}\n\n/** The value is `null` while the date is not whole. */\nexport type RootEmits = Changes<\"value\", string | null> & Changes<\"open\", boolean>\n\n/**\n * A date field, and a calendar in a popover, with one value between them. It draws nothing.\n * `v-model:value`, `v-model:open`; the `-change` events carry the details.\n */\nconst Root = defineComponent({\n name: \"DatePickerRoot\",\n props: {\n value: optional([String, null] as unknown as PropType<string | null>),\n defaultValue: String as PropType<string | null>,\n open: optional(Boolean),\n defaultOpen: Boolean,\n locale: String,\n min: String,\n max: String,\n isDateUnavailable: Function as PropType<DatePickerProps[\"isDateUnavailable\"]>,\n calendarSystem: Object as PropType<DatePickerProps[\"calendarSystem\"]>,\n fixedWeeks: Boolean,\n placeholders: Object as PropType<DatePickerProps[\"placeholders\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"update:open\", \"openChange\"],\n setup(props, { slots, emit }) {\n const generated = useId()\n const made = scope.provide(\n controller(within(createDatePicker, { direction: useDirectionAround() }), () => ({\n ...props,\n id: props.id ?? generated,\n onValueChange(value: string | null, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n }))\n )\n dateFieldScope.provide(made.field)\n popoverScope.provide(made.popover)\n calendarScope.provide(made.calendar)\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<RootProps, RootEmits>\n\nexport type FieldProps = PartComponentProps\nexport type CalendarProps = PartComponentProps\nexport type { SegmentProps, SegmentsProps, InputProps } from \"./date-field.ts\"\nexport type { PopupProps, PortalProps, PositionerProps, TriggerProps } from \"./popover.ts\"\nexport type {\n CellProps,\n DayProps,\n GridProps,\n HeadCellProps,\n HeadingProps,\n NextProps,\n PreviousProps,\n WeekdaysProps,\n WeeksProps,\n} from \"./calendar.ts\"\nexport const DatePicker = {\n Root,\n /** The typed date: what holds its segments and its hidden input. */\n Field: partComponent<\"div\", State[\"field\"]>(\n \"DatePickerField\",\n \"div\",\n () => scope.use().field.root\n ),\n Segments: DateField.Segments,\n Segment: DateField.Segment,\n Input: DateField.Input,\n Trigger: Popover.Trigger,\n Portal: Popover.Portal,\n Positioner: Popover.Positioner,\n Popup: Popover.Popup,\n /** The calendar: what holds its heading, its buttons and its grid. */\n Calendar: partComponent<\"div\", State[\"calendar\"]>(\n \"DatePickerCalendar\",\n \"div\",\n () => scope.use().calendar.root\n ),\n Heading: Calendar.Heading,\n Previous: Calendar.Previous,\n Next: Calendar.Next,\n Grid: Calendar.Grid,\n Weekdays: Calendar.Weekdays,\n HeadCell: Calendar.HeadCell,\n Weeks: Calendar.Weeks,\n Cell: Calendar.Cell,\n Day: Calendar.Day,\n}\n"],"mappings":";;;;;;;;;AAgBA,MAAM,QAAQ,QAAoB,YAAY;AAyE9C,MAAa,aAAa;CACxB,MA7DW,gBAAgB;EAC3B,MAAM;EACN,OAAO;GACL,OAAO,SAAS,CAAC,QAAQ,IAAI,CAAuC;GACpE,cAAc;GACd,MAAM,SA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date-picker.js","names":["dateFieldScope"],"sources":["../../../../packages/vue/src/date-picker.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createDatePicker } from \"@kirana-ui/core/date-picker\"\nimport type {\n DatePicker as Controller,\n DatePickerMode,\n DatePickerProps,\n DatePickerRange,\n DatePickerValue,\n DatePickerValueOf,\n} from \"@kirana-ui/core/date-picker\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType, PublicProps } from \"vue\"\n\nimport { Calendar, calendarScope } from \"./calendar.ts\"\nimport { DateField, dateFieldScope } from \"./date-field.ts\"\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { Popover, popoverScope } from \"./popover.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type {\n Changes,\n Listeners,\n PartComponent,\n PartComponentProps,\n PlainInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"datePicker\">\n\nconst scope = context<Controller>(\"DatePicker\")\n\n/** `value` and its events are typed by `mode`: a day, or a range. */\nexport type RootProps<Mode extends DatePickerMode = \"single\"> = Omit<\n DatePickerProps<Mode>,\n \"id\" | \"onValueChange\" | \"onOpenChange\" | \"onMonthChange\"\n> & {\n id?: string | undefined\n}\n\n/** The value is `null` while the date is not whole. */\nexport type RootEmits<Mode extends DatePickerMode = \"single\"> = Changes<\n \"value\",\n DatePickerValueOf<Mode>\n> &\n Changes<\"open\", boolean> &\n Changes<\"month\", string>\n\n/**\n * A date field, and a calendar in a popover, with one value between them. It draws nothing.\n * `v-model:value`, `v-model:open`, `v-model:month` (the first day of the month the calendar\n * shows); the `-change` events carry the details.\n */\nconst Root = defineComponent({\n name: \"DatePickerRoot\",\n props: {\n value: optional([String, Object, null] as unknown as PropType<DatePickerValue>),\n defaultValue: [String, Object] as PropType<DatePickerValue>,\n mode: String as PropType<DatePickerMode>,\n open: optional(Boolean),\n defaultOpen: Boolean,\n locale: String,\n min: String,\n max: String,\n isDateUnavailable: Function as PropType<DatePickerProps[\"isDateUnavailable\"]>,\n calendarSystem: Object as PropType<DatePickerProps[\"calendarSystem\"]>,\n fixedWeeks: Boolean,\n months: Number,\n pagedNavigation: Boolean,\n month: optional(String),\n defaultMonth: String,\n placeholders: Object as PropType<DatePickerProps[\"placeholders\"]>,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\n \"update:value\",\n \"valueChange\",\n \"update:open\",\n \"openChange\",\n \"update:month\",\n \"monthChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const made = scope.provide(\n controller(within(createDatePicker, { direction: useDirectionAround() }), () => ({\n ...props,\n id: props.id ?? generated,\n onValueChange(value: DatePickerValue, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onOpenChange(open: boolean, details: ChangeDetails) {\n emit(\"openChange\", open, details)\n if (!details.canceled) emit(\"update:open\", open)\n },\n onMonthChange(month: string, details: ChangeDetails) {\n emit(\"monthChange\", month, details)\n if (!details.canceled) emit(\"update:month\", month)\n },\n }))\n )\n dateFieldScope.provide(made.field)\n popoverScope.provide(made.popover)\n calendarScope.provide(made.calendar)\n return () => slots.default?.()\n },\n}) as unknown as new <Mode extends DatePickerMode = \"single\">(\n props: RootProps<Mode> & Listeners<RootEmits<Mode>> & PublicProps\n) => PlainInstance<RootProps<Mode>, RootEmits<Mode>, {}>\n\nexport interface FieldProps extends PartComponentProps {\n /**\n * With `mode=\"range\"`: which day of the range it is typed in, the first (`\"start\"`, the\n * default) or the last (`\"end\"`).\n */\n range?: \"start\" | \"end\" | undefined\n}\nexport type CalendarProps = PartComponentProps\nexport type ClearProps = PartComponentProps\nexport interface PresetProps extends PartComponentProps {\n /** The value its press gives: a day, or with `mode=\"range\"` a range. */\n value: string | DatePickerRange\n}\n\nconst FieldElement = partComponent<\"div\", State[\"field\"]>(\n \"DatePickerFieldElement\",\n \"div\",\n () => dateFieldScope.use().root\n)\n\n/**\n * The typed date: what holds its segments and its hidden input. With `mode=\"range\"` there are\n * two, `range=\"start\"` and `range=\"end\"`, each giving its own parts their field.\n */\nconst Field = defineComponent({\n name: \"DatePickerField\",\n inheritAttrs: false,\n props: { range: String as PropType<\"start\" | \"end\"> },\n setup(props, { attrs, slots }) {\n const picker = scope.use()\n dateFieldScope.provide((props.range === \"end\" && picker.endField) || picker.field)\n return () => h(FieldElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"field\"], FieldProps>\n\n/** Makes the value the one it is given: pressed while it is. */\nconst Preset = defineComponent({\n name: \"DatePickerPreset\",\n inheritAttrs: false,\n props: {\n value: { type: [String, Object] as PropType<string | DatePickerRange>, required: true },\n },\n setup(props, { attrs, slots }) {\n const part = scope.use().preset(props.value)\n const Element = partComponent(\"DatePickerPresetElement\", \"button\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"preset\"], PresetProps>\nexport type { SegmentProps, SegmentsProps, InputProps } from \"./date-field.ts\"\nexport type { PopupProps, PortalProps, PositionerProps, TriggerProps } from \"./popover.ts\"\nexport type {\n CellProps,\n DayProps,\n GridProps,\n HeadCellProps,\n HeadingProps,\n MonthsProps,\n NextProps,\n PreviousProps,\n WeekdaysProps,\n WeeksProps,\n} from \"./calendar.ts\"\nexport const DatePicker = {\n Root,\n Field,\n Segments: DateField.Segments,\n Segment: DateField.Segment,\n Input: DateField.Input,\n Trigger: Popover.Trigger,\n Portal: Popover.Portal,\n Positioner: Popover.Positioner,\n Popup: Popover.Popup,\n /** The calendar: what holds its heading, its buttons and its grid. */\n Calendar: partComponent<\"div\", State[\"calendar\"]>(\n \"DatePickerCalendar\",\n \"div\",\n () => scope.use().calendar.root\n ),\n Heading: Calendar.Heading,\n Previous: Calendar.Previous,\n Next: Calendar.Next,\n Months: Calendar.Months,\n Grid: Calendar.Grid,\n Weekdays: Calendar.Weekdays,\n HeadCell: Calendar.HeadCell,\n Weeks: Calendar.Weeks,\n Cell: Calendar.Cell,\n Day: Calendar.Day,\n /** Empties the value, and gives focus to the field. Disabled while there is none. */\n Clear: partComponent<\"button\", State[\"clear\"]>(\n \"DatePickerClear\",\n \"button\",\n () => scope.use().clear\n ),\n Preset,\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,QAAQ,QAAoB,YAAY;;;;;;AAuB9C,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,OAAO,SAAS;GAAC;GAAQ;GAAQ;EAAI,CAAyC;EAC9E,cAAc,CAAC,QAAQ,MAAM;EAC7B,MAAM;EACN,MAAM,SAAS,OAAO;EACtB,aAAa;EACb,QAAQ;EACR,KAAK;EACL,KAAK;EACL,mBAAmB;EACnB,gBAAgB;EAChB,YAAY;EACZ,QAAQ;EACR,iBAAiB;EACjB,OAAO,SAAS,MAAM;EACtB,cAAc;EACd,cAAc;EACd,UAAU;EACV,UAAU;EACV,UAAU;EACV,MAAM;EACN,MAAM;EACN,IAAI;CACN;CACA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,YAAY,MAAM;EACxB,MAAM,OAAO,MAAM,QACjB,WAAW,OAAO,kBAAkB,EAAE,WAAW,mBAAmB,EAAE,CAAC,UAAU;GAC/E,GAAG;GACH,IAAI,MAAM,MAAM;GAChB,cAAc,OAAwB,SAAwB;IAC5D,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;GACA,aAAa,MAAe,SAAwB;IAClD,KAAK,cAAc,MAAM,OAAO;IAChC,IAAI,CAAC,QAAQ,UAAU,KAAK,eAAe,IAAI;GACjD;GACA,cAAc,OAAe,SAAwB;IACnD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;EACF,EAAE,CACJ;EACA,QAAe,Q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