@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
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/vue/src/runtime.ts"],"sourcesContent":["import { sameProps, signal, stateOf } from \"@kirana-ui/core\"\nimport type {\n ChangeDetails,\n Part,\n PartDefinition,\n PartEvent,\n PartProps,\n PartState,\n ReadonlySignal,\n StateOf,\n} from \"@kirana-ui/core\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport {\n Teleport,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n onScopeDispose,\n provide,\n queuePostFlushCb,\n shallowRef,\n watchEffect,\n} from \"vue\"\nimport type {\n DefineSetupFnComponent,\n HTMLAttributes,\n InjectionKey,\n IntrinsicElementAttributes,\n ObjectEmitsOptions,\n PropType,\n PublicProps,\n ShallowRef,\n SlotsType,\n VNode,\n} from \"vue\"\n\nimport { draw } from \"./element.ts\"\nimport type { Hold } from \"./element.ts\"\n\nexport { written } from \"./element.ts\"\nexport type { Hold } from \"./element.ts\"\n\n/** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */\nexport function fromSignal<T>(source: ReadonlySignal<T>): Readonly<ShallowRef<T>> {\n const ref = shallowRef(source.peek())\n // On a server nothing changes after the first read, and no scope is disposed to unsubscribe.\n if (typeof window !== \"undefined\") {\n onScopeDispose(\n source.subscribe(() => {\n ref.value = source.peek()\n })\n )\n }\n return ref\n}\n\n/** A core signal that follows Vue state: the core hears a changed prop as it changes. */\nexport function toSignal<T extends Record<string, unknown>>(read: () => T): ReadonlySignal<T> {\n const source = signal(read(), sameProps as (a: T, b: T) => boolean)\n watchEffect(() => source.set(read()), { flush: \"sync\" })\n return source\n}\n\n/** A component's controller, made once, following its props. */\nexport function controller<P extends Record<string, unknown>, C extends { mount(): () => void }>(\n create: (props: ReadonlySignal<P>) => C,\n read: () => P\n): C {\n const made = create(toSignal(read))\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = made.mount()\n })\n onBeforeUnmount(() => stop?.())\n return made\n}\n\n/** A controller its parts find: `provide` in the root, `use` in a part. */\nexport function context<C>(name: string): { provide(controller: C): C; use(): C } {\n const key: InjectionKey<C> = Symbol(name)\n return {\n provide(made) {\n provide(key, made)\n return made\n },\n use() {\n const made = inject(key, undefined)\n if (!made) throw new Error(`A ${name} part must be inside <${name}.Root>`)\n return made\n },\n }\n}\n\nfunction toVue(props: PartProps): PartProps {\n const out: PartProps = {}\n for (const key in props) {\n const value = props[key]\n if (typeof value === \"function\") {\n // Vue names an event from the listener's key, so `onKeyDown` would listen for `key-down`:\n // it is `onKeydown`. Focus and blur are the bubbling ones, as in the core.\n const name = key.slice(2).toLowerCase()\n const event = name === \"focus\" ? \"focusin\" : name === \"blur\" ? \"focusout\" : name\n out[`on${event[0]!.toUpperCase()}${event.slice(1)}`] = value\n } else {\n out[key] = value\n }\n }\n return out\n}\n\n/**\n * The state of each part of a component, by their names in the vocabulary: what a part's\n * `data-*` attributes say, and what its default slot is given as `state`.\n */\nexport type StatesOf<Name extends keyof Vocabulary> = {\n [Each in keyof Vocabulary[Name]]: Vocabulary[Name][Each] extends infer Definition extends\n PartDefinition\n ? StateOf<Definition>\n : never\n}\n\n/** What every part takes besides its own props and its element's attributes. */\nexport interface PartComponentProps {\n /** Another tag for the part's element (`as=\"a\"`): its attributes are then that tag's. */\n as?: string | undefined\n /** Draws the element in the part's slot in place of the part's own: it takes the part's props. */\n asChild?: boolean | undefined\n}\n\nexport type { PartEvent }\n\n// A listener takes the event with its `preventKiranaHandler()`; anything else is as it was.\ntype Hearing<Prop> = Prop extends (event: infer Heard) => infer Answer\n ? Heard extends Event\n ? (event: PartEvent<Heard>) => Answer\n : Prop\n : Prop\n\ntype Heard<Attributes> = { [Name in keyof Attributes]: Hearing<Attributes[Name]> }\n\n/**\n * What the element of a tag takes, listeners included (`onClick` is `@click`, its event a\n * `MouseEvent` with `preventKiranaHandler()`, which keeps the part's own listener out of it):\n * Vue's own attributes for the tag, a plain element's for a tag Vue does not know, and any\n * `data-*` attribute.\n */\nexport type ElementAttributes<Tag extends string> = Heard<\n Tag extends keyof IntrinsicElementAttributes ? IntrinsicElementAttributes[Tag] : HTMLAttributes\n> & { [name: `data${string}`]: unknown }\n\n/** A component's events as the listeners among its props: `openChange` is `onOpenChange`. */\nexport type Listeners<Emits> = {\n [Name in keyof Emits & string as `on${Capitalize<Name>}`]?: Emits[Name]\n}\n\n/**\n * The two events of a value its caller may hold: `update:open`, which `v-model:open` hears,\n * and `openChange`, which also carries the details and may cancel the change.\n */\nexport type Changes<Name extends string, Value, Details = ChangeDetails> = {\n [Event in `update:${Name}`]: (value: Value) => void\n} & { [Event in `${Name}Change`]: (value: Value, details: Details) => void }\n\n/**\n * What a caller may hand a part drawn as `Tag`: the part's own props, a listener for each of\n * its events, and what the element takes. A prop or an event of the part's that an attribute\n * of the element shares a name with (`value`, `disabled`, `onSelect`) is the part's.\n */\nexport type PartGiven<Tag extends string, Props, Emits = {}> = Props & {\n as?: Tag | undefined\n} & Listeners<Emits> &\n Omit<ElementAttributes<Tag>, keyof Props | keyof Listeners<Emits>>\n\n/** A component's default slot, given `Slot`. */\nexport type DefaultSlot<Slot> = SlotsType<{ default?: (props: Slot) => VNode[] }>\n\n/** A part's instance, as Vue's own tools read a component: its props, its events, its slot. */\nexport type PartInstance<\n Tag extends string,\n Props,\n Emits extends ObjectEmitsOptions,\n Slot,\n> = InstanceType<\n // Its listeners are the ones `PartGiven` names, each once.\n DefineSetupFnComponent<\n PartGiven<Tag, Props, Emits>,\n Emits,\n DefaultSlot<Slot>,\n PartGiven<Tag, Props, Emits>\n >\n>\n\n/**\n * A part as its callers see it. `Tag` is the element it draws, and `as` another: the part\n * takes the attributes and listeners of whichever it is. `State` is what its default slot is\n * given as `state` (`StateOf` its entry in the vocabulary), with `Given` beside it when the\n * part hands its slot more. `Props` are the part's own, `Emits` its events with their payloads.\n *\n * A part whose value has a type of its caller's (a root with `value`) writes the same\n * signature out with that type as a parameter: `new <Value, As extends string = \"div\">(props:\n * PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps) => PartInstance<…>`.\n */\nexport type PartComponent<\n Tag extends string,\n State = PartState,\n Props = PartComponentProps,\n Emits extends ObjectEmitsOptions = {},\n Given = unknown,\n> = new <As extends string = Tag>(\n props: PartGiven<As, Props, Emits> & PublicProps\n) => PartInstance<As, Props, Emits, { state: State } & Given>\n\n/**\n * A component that draws no element of its own (a root that only provides, a portal, a list\n * that draws its slot once for each entry): its props, its events, what its slot is given.\n */\nexport type PlainComponent<\n Props = {},\n Emits extends ObjectEmitsOptions = {},\n Slot = {},\n> = DefineSetupFnComponent<\n Props & Listeners<Emits>,\n Emits,\n DefaultSlot<Slot>,\n Props & Listeners<Emits>\n>\n\n/** The instance of a `PlainComponent`, for one whose value has a type of its caller's. */\nexport type PlainInstance<Props, Emits extends ObjectEmitsOptions, Slot> = InstanceType<\n PlainComponent<Props, Emits, Slot>\n>\n\n/**\n * A component's instance as its element: its root, or with several roots the first element\n * after the fragment's own mark.\n */\nexport function elementOf(instance: unknown): Element | null {\n let found = (instance as { $el?: Node | null } | null)?.$el ?? null\n while (found && found.nodeType !== 1) found = found.nextSibling\n return found as Element | null\n}\n\n/**\n * A part as a component: its element (`as`, the part's own tag by default), or with `as-child`\n * the caller's own element in its slot, which takes the part's props, and the part's DOM work\n * attached to the element. Three layers of props, lowest first: the attributes on the part,\n * the slotted element's own, the part's. A higher layer wins an attribute; classes join;\n * styles are merged; every listener of an event runs, lowest first, and\n * `event.preventKiranaHandler()` in a caller's stops the part's. The default slot is given the\n * part's state (`{ state }`: `open`, `side` …, read from its `data-*` attributes), typed by\n * `State`. `hold` is for a part that keeps something of its own in its element (a hidden\n * input, the text it writes: `written`): it is given the content and returns what the element\n * holds, whoever drew the element.\n */\nexport function partComponent<Tag extends string, State = PartState>(\n name: string,\n tag: Tag,\n resolve: () => Part,\n hold?: Hold\n): PartComponent<Tag, State> {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: { as: { type: String, default: tag as string }, asChild: Boolean },\n setup(props, { attrs, slots }) {\n const part = resolve()\n const own = fromSignal(part.props)\n let element: HTMLElement | null = null\n let detach: (() => void) | undefined\n\n // Vue calls a function ref as soon as the element exists, before the tree it is in reaches\n // the page: the part's DOM work (focus, measures, the starting style) waits for the flush\n // that follows the render, when it is there. An element that leaves detaches at once.\n let wanted: HTMLElement | null = null\n const sync = () => {\n if (wanted === element) return\n detach?.()\n element = wanted\n detach = wanted ? part.attach(wanted) : undefined\n }\n const attach = (target: unknown) => {\n // On a component (`as-child` over one), the ref is its instance.\n const found = target instanceof HTMLElement ? target : elementOf(target)\n wanted = found instanceof HTMLElement ? found : null\n if (wanted) queuePostFlushCb(sync)\n else sync()\n }\n\n return () =>\n draw(\n props.as,\n props.asChild,\n attrs,\n slots.default?.({ state: stateOf(own.value) }),\n toVue(own.value),\n attach,\n hold\n )\n },\n }) as unknown as PartComponent<Tag, State>\n}\n\nconst PORTAL_CONTAINER: InjectionKey<() => HTMLElement | null | undefined> =\n Symbol(\"PortalContainer\")\n\n/** What `PortalProvider` takes. */\nexport interface PortalProviderProps {\n /** Where the popups are drawn; `<body>` when left out, or while there is none. */\n container?: HTMLElement | null | undefined\n}\n\n/**\n * Says where every popup inside it is drawn, the popups those open included: an element of\n * the page (a shadow root's host, a full-screen element) in place of `<body>`.\n */\nexport const PortalProvider = defineComponent({\n name: \"PortalProvider\",\n props: {\n container: { type: null as unknown as PropType<HTMLElement | null>, default: undefined },\n },\n setup(props, { slots }) {\n provide(PORTAL_CONTAINER, () => props.container)\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<PortalProviderProps>\n\n/** A portal takes nothing: where it is drawn is its `PortalProvider`'s to say. */\nexport type PortalProps = Record<never, never>\n\n/** Its slot in a container at the end of the page, while `mounted`. */\nexport function portalComponent(\n name: string,\n mounted: () => ReadonlySignal<boolean>\n): PlainComponent<PortalProps> {\n return defineComponent({\n name,\n setup(_props, { slots }) {\n const shown = fromSignal(mounted())\n const container = inject(PORTAL_CONTAINER, undefined)\n // Only in a browser, once the page is in it: a server draws no portal, so hydration must\n // find none either. One that opens later is drawn at once.\n const ready = shallowRef(false)\n onMounted(() => {\n ready.value = true\n })\n return () =>\n shown.value && ready.value\n ? h(\n Teleport,\n { to: container?.() ?? \"body\" },\n h(\"div\", { \"data-kirana-portal\": \"\" }, slots.default?.())\n )\n : null\n },\n }) as unknown as PlainComponent<PortalProps>\n}\n\n/** A prop that is \"not given\" when absent, where Vue would make a boolean `false`. */\nexport const optional = <T>(type: T) => ({ type, default: undefined })\n"],"mappings":";;;;;AA6CA,SAAgB,WAAc,QAAoD;CAChF,MAAM,MAAM,WAAW,OAAO,KAAK,CAAC;CAEpC,IAAI,OAAO,WAAW,aACpB,eACE,OAAO,gBAAgB;EACrB,IAAI,QAAQ,OAAO,KAAK;CAC1B,CAAC,CACH;CAEF,OAAO;AACT;;AAGA,SAAgB,SAA4C,MAAkC;CAC5F,MAAM,SAAS,OAAO,KAAK,GAAG,SAAoC;CAClE,kBAAkB,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC;CACvD,OAAO;AACT;;AAGA,SAAgB,WACd,QACA,MACG;CACH,MAAM,OAAO,OAAO,SAAS,IAAI,CAAC;CAClC,IAAI;CACJ,gBAAgB;EACd,OAAO,KAAK,MAAM;CACpB,CAAC;CACD,sBAAsB,OAAO,CAAC;CAC9B,OAAO;AACT;;AAGA,SAAgB,QAAW,MAAuD;CAChF,MAAM,MAAuB,OAAO,IAAI;CACxC,OAAO;EACL,QAAQ,MAAM;GACZ,QAAQ,KAAK,IAAI;GACjB,OAAO;EACT;EACA,MAAM;GACJ,MAAM,OAAO,OAAO,KAAK,KAAA,CAAS;GAClC,IAAI,CAAC,MA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AAE,OAAO,QAAQ,IAAI,KAAK,EAAE,CAAC,GAC7C,MAAM,IAAI,KAAK,GACf,QACA,IACF;EACJ;CACF,CAAC;AACH;AAEA,MAAM,mBACJ,OAAO,iBAAiB;;;;;AAY1B,MAAa,iBAAiB,gBAAgB;CAC5C,MAAM;CACN,OAAO,EACL,WAAW;EAAE,MAAM;EAAiD,SAAS,KAAA;CAAU,EACzF;CACA,MAAM,OAAO,EAAE,SAAS;EACtB,QAAQ,wBAAwB,MAAM,SAAS;EAC/C,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAMD,SAAgB,gBACd,MACA,SAC6B;CAC7B,OAAO,gBAAgB;EACrB;EACA,MAAM,QAAQ,EAAE,SAAS;GACvB,MAAM,QAAQ,WAAW,QAAQ,CAAC;GAClC,MAAM,YAAY,OAAO,kBAAkB,KAAA,CAAS;GAGpD,MAAM,QAAQ,WAAW,KAAK;GAC9B,gBAAgB;IACd,MAAM,QAAQ;GAChB,CAAC;GACD,aACE,MAAM,SAAS,MAAM,QACjB,EACE,UACA,EAAE,IAAI,YAAY,KAAK,OAAO,GAC9B,EAAE,OAAO,EAAE,sBAAsB,GAAG,GAAG,MAAM,UAAU,CAAC,CAC1D,IACA;EACR;CACF,CAAC;AACH;;AAGA,MAAa,YAAe,UAAa;CAAE;CAAM,SAAS,KAAA;AAAU"}
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/vue/src/runtime.ts"],"sourcesContent":["import { sameProps, signal, stateOf, untype } from \"@kirana-ui/core\"\nimport type {\n ChangeDetails,\n Part,\n PartDefinition,\n PartEvent,\n PartProps,\n PartState,\n ReadonlySignal,\n StateOf,\n} from \"@kirana-ui/core\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport {\n Teleport,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n onScopeDispose,\n provide,\n queuePostFlushCb,\n shallowRef,\n watchEffect,\n} from \"vue\"\nimport type {\n DefineSetupFnComponent,\n HTMLAttributes,\n InjectionKey,\n IntrinsicElementAttributes,\n ObjectEmitsOptions,\n PropType,\n PublicProps,\n ShallowRef,\n SlotsType,\n VNode,\n} from \"vue\"\n\nimport { draw } from \"./element.ts\"\nimport type { Hold } from \"./element.ts\"\n\nexport { written } from \"./element.ts\"\n// The reading direction a `DirectionProvider` around a component states, as the signal a\n// controller takes (`{ direction }`); `undefined` outside one. The library's parts read the same.\nexport { useDirectionAround } from \"./direction-context.ts\"\nexport type { Hold } from \"./element.ts\"\n\n/** A core signal as a Vue ref, read-only: tracked by whatever reads `.value`. */\nexport function fromSignal<T>(source: ReadonlySignal<T>): Readonly<ShallowRef<T>> {\n const ref = shallowRef(source.peek())\n // On a server nothing changes after the first read, and no scope is disposed to unsubscribe.\n if (typeof window !== \"undefined\") {\n onScopeDispose(\n source.subscribe(() => {\n ref.value = source.peek()\n })\n )\n }\n return ref\n}\n\n/** A core signal that follows Vue state: the core hears a changed prop as it changes. */\nexport function toSignal<T extends Record<string, unknown>>(read: () => T): ReadonlySignal<T> {\n const source = signal(read(), sameProps as (a: T, b: T) => boolean)\n watchEffect(() => source.set(read()), { flush: \"sync\" })\n return source\n}\n\n/** A component's controller, made once, following its props. */\nexport function controller<P extends Record<string, unknown>, C extends { mount(): () => void }>(\n create: (props: ReadonlySignal<P>) => C,\n read: () => P\n): C {\n const made = create(toSignal(read))\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = made.mount()\n })\n onBeforeUnmount(() => stop?.())\n return made\n}\n\n/** A controller its parts find: `provide` in the root, `use` in a part. */\nexport function context<C>(name: string): { provide(controller: C): C; use(): C } {\n const key: InjectionKey<C> = Symbol(name)\n return {\n provide(made) {\n provide(key, made)\n return made\n },\n use() {\n const made = inject(key, undefined)\n if (!made) throw new Error(`A ${name} part must be inside <${name}.Root>`)\n return made\n },\n }\n}\n\nfunction toVue(props: PartProps): PartProps {\n const out: PartProps = {}\n // What is not an attribute (a default id's mark) goes on to `forElement` as it is.\n for (const mark of Object.getOwnPropertySymbols(props))\n (out as Record<symbol, unknown>)[mark] = (props as Record<symbol, unknown>)[mark]\n for (const key in props) {\n const value = props[key]\n if (typeof value === \"function\") {\n // Vue names an event from the listener's key, so `onKeyDown` would listen for `key-down`:\n // it is `onKeydown`. Focus and blur are the bubbling ones, as in the core.\n const name = key.slice(2).toLowerCase()\n const event = name === \"focus\" ? \"focusin\" : name === \"blur\" ? \"focusout\" : name\n out[`on${event[0]!.toUpperCase()}${event.slice(1)}`] = value\n } else {\n out[key] = value\n }\n }\n return out\n}\n\n/**\n * The state of each part of a component, by their names in the vocabulary: what a part's\n * `data-*` attributes say, and what its default slot is given as `state`.\n */\nexport type StatesOf<Name extends keyof Vocabulary> = {\n [Each in keyof Vocabulary[Name]]: Vocabulary[Name][Each] extends infer Definition extends\n PartDefinition\n ? StateOf<Definition>\n : never\n}\n\n/** What every part takes besides its own props and its element's attributes. */\nexport interface PartComponentProps {\n /** Another tag for the part's element (`as=\"a\"`): its attributes are then that tag's. */\n as?: string | undefined\n /** Draws the element in the part's slot in place of the part's own: it takes the part's props. */\n asChild?: boolean | undefined\n}\n\nexport type { PartEvent }\n\n// A listener takes the event with its `preventKiranaHandler()`; anything else is as it was.\ntype Hearing<Prop> = Prop extends (event: infer Heard) => infer Answer\n ? Heard extends Event\n ? (event: PartEvent<Heard>) => Answer\n : Prop\n : Prop\n\ntype Heard<Attributes> = { [Name in keyof Attributes]: Hearing<Attributes[Name]> }\n\n/**\n * What the element of a tag takes, listeners included (`onClick` is `@click`, its event a\n * `MouseEvent` with `preventKiranaHandler()`, which keeps the part's own listener out of it):\n * Vue's own attributes for the tag, a plain element's for a tag Vue does not know, and any\n * `data-*` attribute.\n */\nexport type ElementAttributes<Tag extends string> = Heard<\n Tag extends keyof IntrinsicElementAttributes ? IntrinsicElementAttributes[Tag] : HTMLAttributes\n> & { [name: `data${string}`]: unknown }\n\n/** A component's events as the listeners among its props: `openChange` is `onOpenChange`. */\nexport type Listeners<Emits> = {\n [Name in keyof Emits & string as `on${Capitalize<Name>}`]?: Emits[Name]\n}\n\n/**\n * The two events of a value its caller may hold: `update:open`, which `v-model:open` hears,\n * and `openChange`, which also carries the details and may cancel the change.\n */\nexport type Changes<Name extends string, Value, Details = ChangeDetails> = {\n [Event in `update:${Name}`]: (value: Value) => void\n} & { [Event in `${Name}Change`]: (value: Value, details: Details) => void }\n\n/**\n * What a caller may hand a part drawn as `Tag`: the part's own props, a listener for each of\n * its events, and what the element takes. A prop or an event of the part's that an attribute\n * of the element shares a name with (`value`, `disabled`, `onSelect`) is the part's.\n */\nexport type PartGiven<Tag extends string, Props, Emits = {}> = Props & {\n as?: Tag | undefined\n} & Listeners<Emits> &\n Omit<ElementAttributes<Tag>, keyof Props | keyof Listeners<Emits>>\n\n/** A component's default slot, given `Slot`. */\nexport type DefaultSlot<Slot> = SlotsType<{ default?: (props: Slot) => VNode[] }>\n\n/** A part's instance, as Vue's own tools read a component: its props, its events, its slot. */\nexport type PartInstance<\n Tag extends string,\n Props,\n Emits extends ObjectEmitsOptions,\n Slot,\n> = InstanceType<\n // Its listeners are the ones `PartGiven` names, each once.\n DefineSetupFnComponent<\n PartGiven<Tag, Props, Emits>,\n Emits,\n DefaultSlot<Slot>,\n PartGiven<Tag, Props, Emits>\n >\n>\n\n/**\n * A part as its callers see it. `Tag` is the element it draws, and `as` another: the part\n * takes the attributes and listeners of whichever it is. `State` is what its default slot is\n * given as `state` (`StateOf` its entry in the vocabulary), with `Given` beside it when the\n * part hands its slot more. `Props` are the part's own, `Emits` its events with their payloads.\n *\n * A part whose value has a type of its caller's (a root with `value`) writes the same\n * signature out with that type as a parameter: `new <Value, As extends string = \"div\">(props:\n * PartGiven<As, RootProps<Value>, RootEmits<Value>> & PublicProps) => PartInstance<…>`.\n */\nexport type PartComponent<\n Tag extends string,\n State = PartState,\n Props = PartComponentProps,\n Emits extends ObjectEmitsOptions = {},\n Given = unknown,\n> = new <As extends string = Tag>(\n props: PartGiven<As, Props, Emits> & PublicProps\n) => PartInstance<As, Props, Emits, { state: State } & Given>\n\n/**\n * A component that draws no element of its own (a root that only provides, a portal, a list\n * that draws its slot once for each entry): its props, its events, what its slot is given.\n */\nexport type PlainComponent<\n Props = {},\n Emits extends ObjectEmitsOptions = {},\n Slot = {},\n> = DefineSetupFnComponent<\n Props & Listeners<Emits>,\n Emits,\n DefaultSlot<Slot>,\n Props & Listeners<Emits>\n>\n\n/** The instance of a `PlainComponent`, for one whose value has a type of its caller's. */\nexport type PlainInstance<Props, Emits extends ObjectEmitsOptions, Slot> = InstanceType<\n PlainComponent<Props, Emits, Slot>\n>\n\n/**\n * A component's instance as its element: its root, or with several roots the first element\n * after the fragment's own mark.\n */\nexport function elementOf(instance: unknown): Element | null {\n let found = (instance as { $el?: Node | null } | null)?.$el ?? null\n while (found && found.nodeType !== 1) found = found.nextSibling\n return found as Element | null\n}\n\n/**\n * A part as a component: its element (`as`, the part's own tag by default), or with `as-child`\n * the caller's own element in its slot, which takes the part's props, and the part's DOM work\n * attached to the element. Three layers of props, lowest first: the attributes on the part,\n * the slotted element's own, the part's. A higher layer wins an attribute; classes join;\n * styles are merged; every listener of an event runs, lowest first, and\n * `event.preventKiranaHandler()` in a caller's stops the part's. The default slot is given the\n * part's state (`{ state }`: `open`, `side` …, read from its `data-*` attributes), typed by\n * `State`. `hold` is for a part that keeps something of its own in its element (a hidden\n * input, the text it writes: `written`): it is given the content and returns what the element\n * holds, whoever drew the element.\n */\nexport function partComponent<Tag extends string, State = PartState>(\n name: string,\n tag: Tag,\n resolve: () => Part,\n hold?: Hold\n): PartComponent<Tag, State> {\n return defineComponent({\n name,\n inheritAttrs: false,\n props: { as: { type: String, default: tag as string }, asChild: Boolean },\n setup(props, { attrs, slots }) {\n const part = resolve()\n const own = fromSignal(part.props)\n let element: HTMLElement | null = null\n let detach: (() => void) | undefined\n\n // Vue calls a function ref as soon as the element exists, before the tree it is in reaches\n // the page: the part's DOM work (focus, measures, the starting style) waits for the flush\n // that follows the render, when it is there. An element that leaves detaches at once.\n let wanted: HTMLElement | null = null\n const sync = () => {\n if (wanted === element) return\n detach?.()\n element = wanted\n if (wanted) untype(wanted)\n detach = wanted ? part.attach(wanted) : undefined\n }\n const attach = (target: unknown) => {\n // On a component (`as-child` over one), the ref is its instance.\n const found = target instanceof HTMLElement ? target : elementOf(target)\n wanted = found instanceof HTMLElement ? found : null\n if (wanted) queuePostFlushCb(sync)\n else sync()\n }\n\n return () =>\n draw(\n props.as,\n props.asChild,\n attrs,\n slots.default?.({ state: stateOf(own.value) }),\n toVue(own.value),\n attach,\n hold\n )\n },\n }) as unknown as PartComponent<Tag, State>\n}\n\nconst PORTAL_CONTAINER: InjectionKey<() => HTMLElement | null | undefined> =\n Symbol(\"PortalContainer\")\n\n/** What `PortalProvider` takes. */\nexport interface PortalProviderProps {\n /** Where the popups are drawn; `<body>` when left out, or while there is none. */\n container?: HTMLElement | null | undefined\n}\n\n/**\n * Says where every popup inside it is drawn, the popups those open included: an element of\n * the page (a shadow root's host, a full-screen element) in place of `<body>`.\n */\nexport const PortalProvider = defineComponent({\n name: \"PortalProvider\",\n props: {\n container: { type: null as unknown as PropType<HTMLElement | null>, default: undefined },\n },\n setup(props, { slots }) {\n provide(PORTAL_CONTAINER, () => props.container)\n return () => slots.default?.()\n },\n}) as unknown as PlainComponent<PortalProviderProps>\n\n/** A portal takes nothing: where it is drawn is its `PortalProvider`'s to say. */\nexport type PortalProps = Record<never, never>\n\n/** Its slot in a container at the end of the page, while `mounted`. */\nexport function portalComponent(\n name: string,\n mounted: () => ReadonlySignal<boolean>\n): PlainComponent<PortalProps> {\n return defineComponent({\n name,\n setup(_props, { slots }) {\n const shown = fromSignal(mounted())\n const container = inject(PORTAL_CONTAINER, undefined)\n // Only in a browser, once the page is in it: a server draws no portal, so hydration must\n // find none either. One that opens later is drawn at once.\n const ready = shallowRef(false)\n onMounted(() => {\n ready.value = true\n })\n return () =>\n shown.value && ready.value\n ? h(\n Teleport,\n { to: container?.() ?? \"body\" },\n h(\"div\", { \"data-kirana-portal\": \"\" }, slots.default?.())\n )\n : null\n },\n }) as unknown as PlainComponent<PortalProps>\n}\n\n/** A prop that is \"not given\" when absent, where Vue would make a boolean `false`. */\nexport const optional = <T>(type: T) => ({ type, default: undefined })\n"],"mappings":";;;;;;AAgDA,SAAgB,WAAc,QAAoD;CAChF,MAAM,MAAM,WAAW,OAAO,KAAK,CAAC;CAEpC,IAAI,OAAO,WAAW,aACpB,eACE,OAAO,gBAAgB;EACrB,IAAI,QAAQ,OAAO,KAAK;CAC1B,CAAC,CACH;CAEF,OAAO;AACT;;AAGA,SAAgB,SAA4C,MAAkC;CAC5F,MAAM,SAAS,OAAO,KAAK,GAAG,SAAoC;CAClE,kBAAkB,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC;CACvD,OAAO;AACT;;AAGA,SAAgB,WACd,QACA,MACG;CACH,MAAM,OAAO,OAAO,SAAS,IAAI,CAAC;CAClC,IAAI;CACJ,gBAAgB;EACd,OAAO,KAAK,MAAM;CACpB,CAAC;CACD,sBAAsB,OAAO,CAAC;CAC9B,OAAO;AACT;;AAGA,SAAgB,QAAW,MAAuD;CAChF,MAAM,MAAuB,OAAO,IAAI;CACxC,OAAO;EACL,QAAQ,MAAM;GACZ,QAAQ,KAAK,IAAI;GACjB,OAAO;EACT;EACA,MAAM;GACJ,MAAM,OAAO,OAAO,KAAK,KAAA,CAAS;GAClC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,KAAK,KAAK,wBAAwB,KAAK,OAAO;GACzE,OAAO;EACT;CACF;AACF;AAEA,SAAS,MAAM,OAA6B;CAC1C,MAAM,MAAiB,CAAC;CAExB,KAAK,MAAM,QAAQ,OAAO,sBAAsB,KAAK,GACnD,IAAiC,QAAS,MAAkC;CAC9E,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,QAAQ,MAAM;EACpB,IAAI,OAAO,UAAU,YAAY;GAG/B,MAAM,OAAO,IAAI,MAAM,CAAC,CAAC,CA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KAAA;CAAU,EACzF;CACA,MAAM,OAAO,EAAE,SAAS;EACtB,QAAQ,wBAAwB,MAAM,SAAS;EAC/C,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAMD,SAAgB,gBACd,MACA,SAC6B;CAC7B,OAAO,gBAAgB;EACrB;EACA,MAAM,QAAQ,EAAE,SAAS;GACvB,MAAM,QAAQ,WAAW,QAAQ,CAAC;GAClC,MAAM,YAAY,OAAO,kBAAkB,KAAA,CAAS;GAGpD,MAAM,QAAQ,WAAW,KAAK;GAC9B,gBAAgB;IACd,MAAM,QAAQ;GAChB,CAAC;GACD,aACE,MAAM,SAAS,MAAM,QACjB,EACE,UACA,EAAE,IAAI,YAAY,KAAK,OAAO,GAC9B,EAAE,OAAO,EAAE,sBAAsB,GAAG,GAAG,MAAM,UAAU,CAAC,CAC1D,IACA;EACR;CACF,CAAC;AACH;;AAGA,MAAa,YAAe,UAAa;CAAE;CAAM,SAAS,KAAA;AAAU"}
@@ -15,22 +15,45 @@ export declare const ScrollArea: {
15
15
  Root: PartComponent<"div", {
16
16
  readonly hasOverflowX?: true | undefined;
17
17
  readonly hasOverflowY?: true | undefined;
18
+ readonly overflowXStart?: true | undefined;
19
+ readonly overflowXEnd?: true | undefined;
20
+ readonly overflowYStart?: true | undefined;
21
+ readonly overflowYEnd?: true | undefined;
18
22
  readonly scrolling?: true | undefined;
19
23
  readonly hovering?: true | undefined;
20
24
  }, PartComponentProps>;
21
25
  Viewport: PartComponent<"div", {
22
26
  readonly hasOverflowX?: true | undefined;
23
27
  readonly hasOverflowY?: true | undefined;
28
+ readonly overflowXStart?: true | undefined;
29
+ readonly overflowXEnd?: true | undefined;
30
+ readonly overflowYStart?: true | undefined;
31
+ readonly overflowYEnd?: true | undefined;
32
+ readonly scrolling?: true | undefined;
33
+ }, PartComponentProps, {}, unknown>;
34
+ Content: PartComponent<"div", {
35
+ readonly hasOverflowX?: true | undefined;
36
+ readonly hasOverflowY?: true | undefined;
37
+ readonly overflowXStart?: true | undefined;
38
+ readonly overflowXEnd?: true | undefined;
39
+ readonly overflowYStart?: true | undefined;
40
+ readonly overflowYEnd?: true | undefined;
24
41
  readonly scrolling?: true | undefined;
25
42
  }, PartComponentProps, {}, unknown>;
26
- Content: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
27
43
  Scrollbar: PartComponent<"div", {
44
+ readonly hasOverflowX?: true | undefined;
45
+ readonly hasOverflowY?: true | undefined;
46
+ readonly overflowXStart?: true | undefined;
47
+ readonly overflowXEnd?: true | undefined;
48
+ readonly overflowYStart?: true | undefined;
49
+ readonly overflowYEnd?: true | undefined;
28
50
  readonly orientation?: "horizontal" | "vertical" | undefined;
29
51
  readonly hovering?: true | undefined;
30
52
  readonly scrolling?: true | undefined;
31
53
  }, ScrollbarProps>;
32
54
  Thumb: PartComponent<"div", {
33
55
  readonly orientation?: "horizontal" | "vertical" | undefined;
56
+ readonly scrolling?: true | undefined;
34
57
  }, PartComponentProps, {}, unknown>;
35
58
  Corner: PartComponent<"div", Record<never, never>, PartComponentProps>;
36
59
  };
package/src/select.d.ts CHANGED
@@ -3,11 +3,14 @@ import { PositionerProps as PositionerProps$1 } from "./popover.js";
3
3
  import { PublicProps } from "vue";
4
4
  import { SelectItemOptions, SelectProps, SelectShown } from "@kirana-ui/core/select";
5
5
  type State = StatesOf<"select">;
6
- export type RootProps<Value = unknown> = Omit<SelectProps<Value>, "id" | "onValueChange" | "onValuesChange" | "onOpenChange"> & {
6
+ /** `Multiple` is read from `multiple`: with it, `value` and `@value-change` hold a list. */
7
+ export type RootProps<Value = unknown, Multiple extends boolean | undefined = false> = Omit<SelectProps<Value, Multiple>, "id" | "multiple" | "onValueChange" | "onValuesChange" | "onOpenChange"> & {
7
8
  id?: string | undefined;
9
+ /** Several values: `value` and `@value-change` then hold a list. Read once. */
10
+ multiple?: Multiple | undefined;
8
11
  };
9
12
  /** The value is `null` when the select is put back to none chosen. */
10
- export type RootEmits<Value = unknown> = Changes<"value", Value | null> & Changes<"values", Value[]> & Changes<"open", boolean>;
13
+ export type RootEmits<Value = unknown, Multiple extends boolean | undefined = false> = Changes<"value", Multiple extends true ? Value[] : Value | null> & Changes<"values", Value[]> & Changes<"open", boolean>;
11
14
  export interface ValueProps extends PartComponentProps {
12
15
  /** What it shows while nothing is chosen. */
13
16
  placeholder?: string | undefined;
@@ -21,7 +24,12 @@ export interface ItemIndicatorProps extends PartComponentProps {
21
24
  keepMounted?: boolean | undefined;
22
25
  }
23
26
  export interface PositionerProps extends PositionerProps$1 {
24
- /** Opens the list over its trigger, the chosen item's text on the trigger's own. */
27
+ /**
28
+ * Opens the list over its trigger, the chosen item's text on the trigger's own, where there is
29
+ * room and unless a finger opened it. While it lies there the page's scroll is held (its
30
+ * scrollbar's room kept), and a scroll of a box around the trigger closes the list
31
+ * (`"ancestor-scroll"`), as a change of the window's size does (`"window-resize"`).
32
+ */
25
33
  alignItemWithTrigger?: boolean | undefined;
26
34
  }
27
35
  export interface GroupProps extends PartComponentProps {
@@ -29,6 +37,7 @@ export interface GroupProps extends PartComponentProps {
29
37
  }
30
38
  export type TriggerProps = PartComponentProps;
31
39
  export type PopupProps = PartComponentProps;
40
+ export type BackdropProps = PartComponentProps;
32
41
  export type ListProps = PartComponentProps;
33
42
  export type ScrollUpArrowProps = PartComponentProps;
34
43
  export type ScrollDownArrowProps = PartComponentProps;
@@ -36,30 +45,54 @@ export type GroupLabelProps = PartComponentProps;
36
45
  export type SeparatorProps = PartComponentProps;
37
46
  export type ItemTextProps = PartComponentProps;
38
47
  export declare const Select: {
39
- Root: new <Value = unknown>(props: RootProps<Value> & Listeners<RootEmits<Value>> & PublicProps) => PlainInstance<RootProps<Value>, RootEmits<Value>, {}>;
48
+ Root: new <Value = unknown, Multiple extends boolean | undefined = false>(props: RootProps<Value, Multiple> & Listeners<RootEmits<Value, Multiple>> & PublicProps) => PlainInstance<RootProps<Value, Multiple>, RootEmits<Value, Multiple>, {}>;
40
49
  Trigger: PartComponent<"button", {
50
+ readonly touched?: true | undefined;
51
+ readonly dirty?: true | undefined;
52
+ readonly filled?: true | undefined;
53
+ readonly focused?: true | undefined;
54
+ readonly valid?: true | undefined;
55
+ readonly invalid?: true | undefined;
41
56
  readonly popupOpen?: true | undefined;
57
+ readonly pressed?: true | undefined;
58
+ readonly popupSide?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
42
59
  readonly placeholder?: true | undefined;
43
60
  readonly disabled?: true | undefined;
44
61
  readonly readonly?: true | undefined;
62
+ readonly required?: true | undefined;
45
63
  }, PartComponentProps, {}, unknown>;
46
64
  Value: new <As extends string = "span">(props: PartGiven<As, ValueProps> & PublicProps) => PartInstance<As, ValueProps, {}, {
47
65
  state: State["value"];
48
66
  } & SelectShown>;
49
67
  Portal: PlainComponent<PortalProps, {}, {}>;
68
+ /** What lies over the page behind the list: a sheet's (`presentation`) is modal. */
69
+ Backdrop: PartComponent<"div", {
70
+ readonly open?: true | undefined;
71
+ readonly closed?: true | undefined;
72
+ readonly startingStyle?: true | undefined;
73
+ readonly endingStyle?: true | undefined;
74
+ readonly presentation?: "popup" | "sheet" | undefined;
75
+ readonly swiping?: true | undefined;
76
+ readonly swipeDismiss?: true | undefined;
77
+ }, PartComponentProps, {}, unknown>;
50
78
  Positioner: PartComponent<"div", {
51
79
  readonly open?: true | undefined;
52
80
  readonly closed?: true | undefined;
53
81
  readonly align?: "center" | "end" | "start" | undefined;
82
+ readonly presentation?: "popup" | "sheet" | undefined;
54
83
  readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
84
+ readonly anchorHidden?: true | undefined;
55
85
  }, PositionerProps>;
56
86
  Popup: PartComponent<"div", {
57
87
  readonly open?: true | undefined;
58
88
  readonly closed?: true | undefined;
59
89
  readonly startingStyle?: true | undefined;
60
90
  readonly endingStyle?: true | undefined;
61
- readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "right" | "top" | undefined;
62
91
  readonly align?: "center" | "end" | "start" | undefined;
92
+ readonly presentation?: "popup" | "sheet" | undefined;
93
+ readonly swiping?: true | undefined;
94
+ readonly swipeDismiss?: true | undefined;
95
+ readonly side?: "bottom" | "inline-end" | "inline-start" | "left" | "none" | "right" | "top" | undefined;
63
96
  }, PartComponentProps, {}, unknown>;
64
97
  /** The items' own box inside the popup, when the popup also holds scroll arrows. */
65
98
  List: PartComponent<"div", Record<never, never>, PartComponentProps, {}, unknown>;
package/src/select.js CHANGED
@@ -11,7 +11,8 @@ const ITEM = Symbol("SelectItem");
11
11
  const HiddenInput = partComponent("SelectHiddenInput", "input", () => scope.use().input);
12
12
  /**
13
13
  * `v-model:value`, `v-model:open`; `@value-change` and `@open-change` carry the details. With
14
- * `multiple`: `v-model:values` and `@values-change`.
14
+ * `multiple`, the value is a list (`v-model:values` and `@values-change`, the older shape, are
15
+ * still emitted).
15
16
  */
16
17
  const Root = defineComponent({
17
18
  name: "SelectRoot",
@@ -36,6 +37,16 @@ const Root = defineComponent({
36
37
  values: optional(Array),
37
38
  defaultValues: Array,
38
39
  virtualized: Object,
40
+ presentation: String,
41
+ sheetBelow: Number,
42
+ itemToStringLabel: {
43
+ type: Function,
44
+ default: void 0
45
+ },
46
+ itemToStringValue: {
47
+ type: Function,
48
+ default: void 0
49
+ },
39
50
  id: String
40
51
  },
41
52
  emits: [
@@ -65,13 +76,16 @@ const Root = defineComponent({
65
76
  values: props.values,
66
77
  defaultValues: props.defaultValues,
67
78
  virtualized: props.virtualized,
79
+ presentation: props.presentation,
80
+ sheetBelow: props.sheetBelow,
81
+ itemToStringLabel: props.itemToStringLabel,
82
+ itemToStringValue: props.itemToStringValue,
68
83
  onValueChange(value, details) {
69
84
  emit("valueChange", value, details);
70
85
  if (!details.canceled) emit("update:value", value);
71
- },
72
- onValuesChange(values, details) {
73
- emit("valuesChange", values, details);
74
- if (!details.canceled) emit("update:values", values);
86
+ if (!props.multiple || !Array.isArray(value)) return;
87
+ emit("valuesChange", value, details);
88
+ if (!details.canceled) emit("update:values", value);
75
89
  },
76
90
  onOpenChange(open, details) {
77
91
  emit("openChange", open, details);
@@ -139,15 +153,18 @@ const ItemIndicator = defineComponent({
139
153
  setup(props, { attrs, slots }) {
140
154
  const value = inject(ITEM);
141
155
  const made = scope.use();
142
- const selected = fromSignal(made.selected(value));
143
- const Element = partComponent("SelectItemIndicatorElement", "span", () => made.itemIndicator(value));
144
- return () => selected.value || props.keepMounted ? h(Element, attrs, slots) : null;
156
+ const indicator = controller(() => made.itemIndicator(value), () => ({}));
157
+ const mounted = fromSignal(indicator.mounted);
158
+ const Element = partComponent("SelectItemIndicatorElement", "span", () => indicator);
159
+ return () => mounted.value || props.keepMounted ? h(Element, attrs, slots) : null;
145
160
  }
146
161
  });
147
162
  const PlacedPositioner = positionerComponent("SelectPlacedPositioner", () => scope.use(), partComponent("SelectPositionerElement", "div", () => scope.use().positioner));
148
163
  /**
149
164
  * `align-item-with-trigger`: the list opens over its trigger, the chosen item's text on the
150
- * trigger's own, where there is room and unless a finger opened it.
165
+ * trigger's own, where there is room and unless a finger opened it. While it lies there the page's
166
+ * scroll is held (its scrollbar's room kept), and a scroll of a box around the trigger closes the
167
+ * list (`"ancestor-scroll"`), as a change of the window's size does (`"window-resize"`).
151
168
  */
152
169
  const Positioner = defineComponent({
153
170
  name: "SelectPositioner",
@@ -197,6 +214,8 @@ const Select = {
197
214
  Trigger: partComponent("SelectTrigger", "button", () => scope.use().trigger),
198
215
  Value,
199
216
  Portal: portalComponent("SelectPortal", () => scope.use().mounted),
217
+ /** What lies over the page behind the list: a sheet's (`presentation`) is modal. */
218
+ Backdrop: partComponent("SelectBackdrop", "div", () => scope.use().backdrop),
200
219
  Positioner,
201
220
  Popup: partComponent("SelectPopup", "div", () => scope.use().popup),
202
221
  /** The items' own box inside the popup, when the popup also holds scroll arrows. */
package/src/select.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","names":[],"sources":["../../../../packages/vue/src/select.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type {\n Select as Controller,\n SelectGroup,\n SelectItemOptions,\n SelectProps,\n SelectShown,\n} from \"@kirana-ui/core/select\"\nimport {\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n useId,\n watchEffect,\n} from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { positionerComponent } from \"./popover.ts\"\nimport type { PositionerProps as PlacedProps } from \"./popover.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { written } from \"./element.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 PartGiven,\n PartInstance,\n PlainInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"select\">\n\nconst scope = context<Controller>(\"Select\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"SelectItem\")\n\nconst HiddenInput = partComponent(\"SelectHiddenInput\", \"input\", () => scope.use().input)\n\nexport type RootProps<Value = unknown> = Omit<\n SelectProps<Value>,\n \"id\" | \"onValueChange\" | \"onValuesChange\" | \"onOpenChange\"\n> & { id?: string | undefined }\n\n/** The value is `null` when the select is put back to none chosen. */\nexport type RootEmits<Value = unknown> = Changes<\"value\", Value | null> &\n Changes<\"values\", Value[]> &\n Changes<\"open\", boolean>\n\n/**\n * `v-model:value`, `v-model:open`; `@value-change` and `@open-change` carry the details. With\n * `multiple`: `v-model:values` and `@values-change`.\n */\nconst Root = defineComponent({\n name: \"SelectRoot\",\n props: {\n value: { type: null as unknown as PropType<unknown>, default: undefined as unknown },\n defaultValue: { type: null as unknown as PropType<unknown>, default: null as unknown },\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n items: [Array, Object] as PropType<SelectProps[\"items\"]>,\n multiple: Boolean,\n values: optional(Array as PropType<readonly unknown[]>),\n defaultValues: Array as PropType<readonly unknown[]>,\n virtualized: Object as PropType<SelectProps[\"virtualized\"]>,\n id: String,\n },\n emits: [\n \"update:value\",\n \"valueChange\",\n \"update:values\",\n \"valuesChange\",\n \"update:open\",\n \"openChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createSelect, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n items: props.items,\n multiple: props.multiple,\n values: props.values,\n defaultValues: props.defaultValues,\n virtualized: props.virtualized,\n onValueChange(value: unknown, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onValuesChange(values: unknown[], details: ChangeDetails) {\n emit(\"valuesChange\", values, details)\n if (!details.canceled) emit(\"update:values\", values)\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 ValueProps extends PartComponentProps {\n /** What it shows while nothing is chosen. */\n placeholder?: string | undefined\n}\n\n/**\n * Shows the chosen value's label, or `placeholder` while nothing is chosen; with `multiple`,\n * the 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 items'\n * order), which is given the part's `state` too.\n */\nconst Value = defineComponent({\n name: \"SelectValue\",\n inheritAttrs: false,\n props: { placeholder: { type: String, default: \"\" } },\n setup(props, { attrs, slots }) {\n const shown = fromSignal(scope.use().shown)\n const label = () => shown.value.label ?? props.placeholder\n // With `as-child` the caller's element holds the label, unless it writes its own.\n const ValueElement = partComponent(\n \"SelectValueElement\",\n \"span\",\n () => scope.use().valuePart,\n written(label)\n )\n return () =>\n h(ValueElement, attrs, {\n default: (given: object) =>\n slots.default ? slots.default({ ...given, ...shown.value }) : label(),\n })\n },\n}) as unknown as new <As extends string = \"span\">(\n props: PartGiven<As, ValueProps> & PublicProps\n) => PartInstance<As, ValueProps, {}, { state: State[\"value\"] } & SelectShown>\n\nexport interface ItemProps extends SelectItemOptions, PartComponentProps {\n /** What the select's value is while this item is the chosen one. */\n value: unknown\n}\n\n/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"SelectItem\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, required: true },\n disabled: optional(Boolean),\n label: 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 options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n index: props.index,\n }))\n const part = scope.use().item(value, () => defined(options.get()))\n provide(ITEM, value)\n const Element = partComponent(\"SelectItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nconst ItemText = partComponent<\"span\", State[\"itemText\"]>(\"SelectItemText\", \"span\", () =>\n scope.use().itemText(inject(ITEM))\n)\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: \"SelectItemIndicator\",\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(\"SelectItemIndicatorElement\", \"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\nconst PlacedPositioner = positionerComponent<State[\"positioner\"]>(\n \"SelectPlacedPositioner\",\n () => scope.use(),\n partComponent(\"SelectPositionerElement\", \"div\", () => scope.use().positioner)\n)\n\nexport interface PositionerProps extends PlacedProps {\n /** Opens the list over its trigger, the chosen item's text on the trigger's own. */\n alignItemWithTrigger?: boolean | undefined\n}\n\n/**\n * `align-item-with-trigger`: the list opens over its trigger, the chosen item's text on the\n * trigger's own, where there is room and unless a finger opened it.\n */\nconst Positioner = defineComponent({\n name: \"SelectPositioner\",\n inheritAttrs: false,\n props: { alignItemWithTrigger: Boolean },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n watchEffect(() => made.alignItemWithTrigger.set(props.alignItemWithTrigger), {\n flush: \"sync\",\n })\n return () => h(PlacedPositioner, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"positioner\"], PositionerProps>\n\nconst GROUP: InjectionKey<SelectGroup | null> = Symbol(\"SelectGroup\")\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items that belong together, named by their `<Select.GroupLabel>`. */\nconst Group = defineComponent({\n name: \"SelectGroup\",\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(\"SelectGroupElement\", \"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 \"SelectGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().groupLabel\n)\n\nfunction scrollArrow<Arrow extends \"scrollUpArrow\" | \"scrollDownArrow\">(\n name: string,\n direction: \"up\" | \"down\"\n) {\n return defineComponent({\n name,\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const arrow = scope.use().scrollArrow(direction)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = arrow.mount()\n })\n onBeforeUnmount(() => stop?.())\n const mounted = fromSignal(arrow.mounted)\n const Element = partComponent(`${name}Element`, \"div\", () => arrow.part)\n return () => (mounted.value ? h(Element, attrs, slots) : null)\n },\n }) as unknown as PartComponent<\"div\", State[Arrow]>\n}\n\nexport type TriggerProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport type ScrollUpArrowProps = PartComponentProps\nexport type ScrollDownArrowProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport type ItemTextProps = PartComponentProps\nexport const Select = {\n Root,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"SelectTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Value,\n Portal: portalComponent(\"SelectPortal\", () => scope.use().mounted),\n Positioner,\n Popup: partComponent<\"div\", State[\"popup\"]>(\"SelectPopup\", \"div\", () => scope.use().popup),\n /** The items' own box inside the popup, when the popup also holds scroll arrows. */\n List: partComponent<\"div\", State[\"list\"]>(\"SelectList\", \"div\", () => scope.use().list),\n /** In the page while there is more of the list above: it scrolls it under a moving pointer. */\n ScrollUpArrow: scrollArrow<\"scrollUpArrow\">(\"SelectScrollUpArrow\", \"up\"),\n /** In the page while there is more of the list below. */\n ScrollDownArrow: scrollArrow<\"scrollDownArrow\">(\"SelectScrollDownArrow\", \"down\"),\n Group,\n GroupLabel,\n /** A line between groups. */\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"SelectSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Item,\n ItemText,\n ItemIndicator,\n}\n"],"mappings":";;;;;;;;AAkDA,MAAM,QAAQ,QAAoB,QAAQ;AAC1C,MAAM,OAA8B,OAAO,YAA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SAAS,MAAM,IAAI,CAAC,CAAC,UAClD;AAEA,SAAS,YACP,MACA,WACA;CACA,OAAO,gBAAgB;EACrB;EACA,cAAc;EACd,MAAM,QAAQ,EAAE,OAAO,SAAS;GAC9B,MAAM,QAAQ,MAAM,IAAI,CAAC,CAAC,YAAY,SAAS;GAC/C,IAAI;GACJ,gBAAgB;IACd,OAAO,MAAM,MAAM;GACrB,CAAC;GACD,sBAAsB,OAAO,CAAC;GAC9B,MAAM,UAAU,WAAW,MAAM,OAAO;GACxC,MAAM,UAAU,cAAc,GAAG,KAAK,UAAU,aAAa,MAAM,IAAI;GACvE,aAAc,QAAQ,QAAQ,EAAE,SAAS,OAAO,KAAK,IAAI;EAC3D;CACF,CAAC;AACH;AAUA,MAAa,SAAS;CACpB;CACA,SAAS,cACP,iBACA,gBACM,MAAM,IAAI,CAAC,CAAC,OACpB;CACA;CACA,QAAQ,gBAAgB,sBAAsB,MAAM,IAAI,CAAC,CAAC,OAAO;CACjE;CACA,OAAO,cAAqC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;;CAEzF,MAAM,cAAoC,cAAc,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;CAErF,eAAe,YAA6B,uBAAuB,IAAI;;CAEvE,iBAAiB,YAA+B,yBAAyB,MAAM;CAC/E;CACA;;CAEA,WAAW,cACT,mBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"select.js","names":[],"sources":["../../../../packages/vue/src/select.ts"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type {\n Select as Controller,\n SelectGroup,\n SelectItemOptions,\n SelectProps,\n SelectShown,\n} from \"@kirana-ui/core/select\"\nimport {\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n useId,\n watchEffect,\n} from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { positionerComponent } from \"./popover.ts\"\nimport type { PositionerProps as PlacedProps } from \"./popover.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { written } from \"./element.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 PartGiven,\n PartInstance,\n PlainInstance,\n StatesOf,\n} from \"./runtime.ts\"\n\nexport type { PortalProps } from \"./runtime.ts\"\n\ntype State = StatesOf<\"select\">\n\nconst scope = context<Controller>(\"Select\")\nconst ITEM: InjectionKey<unknown> = Symbol(\"SelectItem\")\n\nconst HiddenInput = partComponent(\"SelectHiddenInput\", \"input\", () => scope.use().input)\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 SelectProps<Value, Multiple>,\n \"id\" | \"multiple\" | \"onValueChange\" | \"onValuesChange\" | \"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 select is put back to none chosen. */\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<\"open\", boolean>\n\n/**\n * `v-model:value`, `v-model:open`; `@value-change` and `@open-change` carry the details. With\n * `multiple`, the value is a list (`v-model:values` and `@values-change`, the older shape, are\n * still emitted).\n */\nconst Root = defineComponent({\n name: \"SelectRoot\",\n props: {\n value: { type: null as unknown as PropType<unknown>, default: undefined as unknown },\n defaultValue: { type: null as unknown as PropType<unknown>, default: null as unknown },\n open: optional(Boolean),\n defaultOpen: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n items: [Array, Object] as PropType<SelectProps[\"items\"]>,\n multiple: Boolean,\n values: optional(Array as PropType<readonly unknown[]>),\n defaultValues: Array as PropType<readonly unknown[]>,\n virtualized: Object as PropType<SelectProps[\"virtualized\"]>,\n presentation: String as PropType<SelectProps[\"presentation\"]>,\n sheetBelow: Number,\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:values\",\n \"valuesChange\",\n \"update:open\",\n \"openChange\",\n ],\n setup(props, { slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = scope.provide(\n controller(within(createSelect, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n open: props.open,\n defaultOpen: props.defaultOpen,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n items: props.items,\n multiple: props.multiple,\n values: props.values,\n defaultValues: props.defaultValues,\n virtualized: props.virtualized,\n presentation: props.presentation,\n sheetBelow: props.sheetBelow,\n itemToStringLabel: props.itemToStringLabel as SelectProps[\"itemToStringLabel\"],\n itemToStringValue: props.itemToStringValue as SelectProps[\"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 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 ValueProps extends PartComponentProps {\n /** What it shows while nothing is chosen. */\n placeholder?: string | undefined\n}\n\n/**\n * Shows the chosen value's label, or `placeholder` while nothing is chosen; with `multiple`,\n * the 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 items'\n * order), which is given the part's `state` too.\n */\nconst Value = defineComponent({\n name: \"SelectValue\",\n inheritAttrs: false,\n props: { placeholder: { type: String, default: \"\" } },\n setup(props, { attrs, slots }) {\n const shown = fromSignal(scope.use().shown)\n const label = () => shown.value.label ?? props.placeholder\n // With `as-child` the caller's element holds the label, unless it writes its own.\n const ValueElement = partComponent(\n \"SelectValueElement\",\n \"span\",\n () => scope.use().valuePart,\n written(label)\n )\n return () =>\n h(ValueElement, attrs, {\n default: (given: object) =>\n slots.default ? slots.default({ ...given, ...shown.value }) : label(),\n })\n },\n}) as unknown as new <As extends string = \"span\">(\n props: PartGiven<As, ValueProps> & PublicProps\n) => PartInstance<As, ValueProps, {}, { state: State[\"value\"] } & SelectShown>\n\nexport interface ItemProps extends SelectItemOptions, PartComponentProps {\n /** What the select's value is while this item is the chosen one. */\n value: unknown\n}\n\n/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */\nconst Item = defineComponent({\n name: \"SelectItem\",\n inheritAttrs: false,\n props: {\n value: { type: null as unknown as PropType<unknown>, required: true },\n disabled: optional(Boolean),\n label: 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 options = toSignal(() => ({\n disabled: props.disabled,\n label: props.label,\n index: props.index,\n }))\n const part = scope.use().item(value, () => defined(options.get()))\n provide(ITEM, value)\n const Element = partComponent(\"SelectItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nconst ItemText = partComponent<\"span\", State[\"itemText\"]>(\"SelectItemText\", \"span\", () =>\n scope.use().itemText(inject(ITEM))\n)\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: \"SelectItemIndicator\",\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(\"SelectItemIndicatorElement\", \"span\", () => indicator)\n return () => (mounted.value || props.keepMounted ? h(Element, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"itemIndicator\"], ItemIndicatorProps>\n\nconst PlacedPositioner = positionerComponent<State[\"positioner\"]>(\n \"SelectPlacedPositioner\",\n () => scope.use(),\n partComponent(\"SelectPositionerElement\", \"div\", () => scope.use().positioner)\n)\n\nexport interface PositionerProps extends PlacedProps {\n /**\n * Opens the list over its trigger, the chosen item's text on the trigger's own, where there is\n * room and unless a finger opened it. While it lies there the page's scroll is held (its\n * scrollbar's room kept), and a scroll of a box around the trigger closes the list\n * (`\"ancestor-scroll\"`), as a change of the window's size does (`\"window-resize\"`).\n */\n alignItemWithTrigger?: boolean | undefined\n}\n\n/**\n * `align-item-with-trigger`: the list opens over its trigger, the chosen item's text on the\n * trigger's own, where there is room and unless a finger opened it. While it lies there the page's\n * scroll is held (its scrollbar's room kept), and a scroll of a box around the trigger closes the\n * list (`\"ancestor-scroll\"`), as a change of the window's size does (`\"window-resize\"`).\n */\nconst Positioner = defineComponent({\n name: \"SelectPositioner\",\n inheritAttrs: false,\n props: { alignItemWithTrigger: Boolean },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n watchEffect(() => made.alignItemWithTrigger.set(props.alignItemWithTrigger), {\n flush: \"sync\",\n })\n return () => h(PlacedPositioner, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"positioner\"], PositionerProps>\n\nconst GROUP: InjectionKey<SelectGroup | null> = Symbol(\"SelectGroup\")\n\nexport interface GroupProps extends PartComponentProps {\n id?: string | undefined\n}\n\n/** Items that belong together, named by their `<Select.GroupLabel>`. */\nconst Group = defineComponent({\n name: \"SelectGroup\",\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(\"SelectGroupElement\", \"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 \"SelectGroupLabel\",\n \"div\",\n () => inject(GROUP, null)?.label ?? scope.use().groupLabel\n)\n\nfunction scrollArrow<Arrow extends \"scrollUpArrow\" | \"scrollDownArrow\">(\n name: string,\n direction: \"up\" | \"down\"\n) {\n return defineComponent({\n name,\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const arrow = scope.use().scrollArrow(direction)\n let stop: (() => void) | undefined\n onMounted(() => {\n stop = arrow.mount()\n })\n onBeforeUnmount(() => stop?.())\n const mounted = fromSignal(arrow.mounted)\n const Element = partComponent(`${name}Element`, \"div\", () => arrow.part)\n return () => (mounted.value ? h(Element, attrs, slots) : null)\n },\n }) as unknown as PartComponent<\"div\", State[Arrow]>\n}\n\nexport type TriggerProps = PartComponentProps\nexport type PopupProps = PartComponentProps\nexport type BackdropProps = PartComponentProps\nexport type ListProps = PartComponentProps\nexport type ScrollUpArrowProps = PartComponentProps\nexport type ScrollDownArrowProps = PartComponentProps\nexport type GroupLabelProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport type ItemTextProps = PartComponentProps\nexport const Select = {\n Root,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\n \"SelectTrigger\",\n \"button\",\n () => scope.use().trigger\n ),\n Value,\n Portal: portalComponent(\"SelectPortal\", () => 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 \"SelectBackdrop\",\n \"div\",\n () => scope.use().backdrop\n ),\n Positioner,\n Popup: partComponent<\"div\", State[\"popup\"]>(\"SelectPopup\", \"div\", () => scope.use().popup),\n /** The items' own box inside the popup, when the popup also holds scroll arrows. */\n List: partComponent<\"div\", State[\"list\"]>(\"SelectList\", \"div\", () => scope.use().list),\n /** In the page while there is more of the list above: it scrolls it under a moving pointer. */\n ScrollUpArrow: scrollArrow<\"scrollUpArrow\">(\"SelectScrollUpArrow\", \"up\"),\n /** In the page while there is more of the list below. */\n ScrollDownArrow: scrollArrow<\"scrollDownArrow\">(\"SelectScrollDownArrow\", \"down\"),\n Group,\n GroupLabel,\n /** A line between groups. */\n Separator: partComponent<\"div\", State[\"separator\"]>(\n \"SelectSeparator\",\n \"div\",\n () => scope.use().separator\n ),\n Item,\n ItemText,\n ItemIndicator,\n}\n"],"mappings":";;;;;;;;AAkDA,MAAM,QAAQ,QAAoB,QAAQ;AAC1C,MAAM,OAA8B,OAAO,YAAY;AAEvD,MAAM,cAAc,cAAc,qBAAqB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;;;;;;AAyBvF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,OAAO;EACL,OAAO;GAAE,MAAM;GAAsC,SAAS,KAAA;EAAqB;EACnF,cAAc;GAAE,MAAM;GAAsC,SAAS;EAAgB;EACrF,MAAM,SAAS,OAAO;EACtB,aAAa;EACb,UAAU;EACV,UAAU;EACV,UAAU;EACV,MAAM;EACN,MAAM;EACN,OAAO,CAAC,OAAO,MAAM;EACrB,UAAU;EACV,QAAQ,SAAS,KAAqC;EACtD,eAAe;EACf,aAAa;EACb,cAAc;EACd,YAAY;EACZ,mBAAmB;GACjB,MAAM;G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C/C,IAAI;GACJ,gBAAgB;IACd,OAAO,MAAM,MAAM;GACrB,CAAC;GACD,sBAAsB,OAAO,CAAC;GAC9B,MAAM,UAAU,WAAW,MAAM,OAAO;GACxC,MAAM,UAAU,cAAc,GAAG,KAAK,UAAU,aAAa,MAAM,IAAI;GACvE,aAAc,QAAQ,QAAQ,EAAE,SAAS,OAAO,KAAK,IAAI;EAC3D;CACF,CAAC;AACH;AAWA,MAAa,SAAS;CACpB;CACA,SAAS,cACP,iBACA,gBACM,MAAM,IAAI,CAAC,CAAC,OACpB;CACA;CACA,QAAQ,gBAAgB,sBAAsB,MAAM,IAAI,CAAC,CAAC,OAAO;;CAEjE,UAAU,cACR,kBACA,aACM,MAAM,IAAI,CAAC,CAAC,QACpB;CACA;CACA,OAAO,cAAqC,eAAe,aAAa,MAAM,IAAI,CAAC,CAAC,KAAK;;CAEzF,MAAM,cAAoC,cAAc,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;CAErF,eAAe,YAA6B,uBAAuB,IAAI;;CAEvE,iBAAiB,YAA+B,yBAAyB,MAAM;CAC/E;CACA;;CAEA,WAAW,cACT,mBACA,aACM,MAAM,IAAI,CAAC,CAAC,SACpB;CACA;CACA;CACA;AACF"}
package/src/slider.d.ts CHANGED
@@ -34,30 +34,60 @@ export declare const Slider: {
34
34
  state: State["root"];
35
35
  }>;
36
36
  Value: PartComponent<"output", {
37
+ readonly touched?: true | undefined;
38
+ readonly dirty?: true | undefined;
39
+ readonly filled?: true | undefined;
40
+ readonly focused?: true | undefined;
41
+ readonly valid?: true | undefined;
42
+ readonly invalid?: true | undefined;
37
43
  readonly orientation?: "horizontal" | "vertical" | undefined;
38
44
  readonly disabled?: true | undefined;
39
45
  readonly readonly?: true | undefined;
40
46
  readonly dragging?: true | undefined;
41
47
  }, PartComponentProps, {}, ValueGiven>;
42
48
  Control: PartComponent<"div", {
49
+ readonly touched?: true | undefined;
50
+ readonly dirty?: true | undefined;
51
+ readonly filled?: true | undefined;
52
+ readonly focused?: true | undefined;
53
+ readonly valid?: true | undefined;
54
+ readonly invalid?: true | undefined;
43
55
  readonly orientation?: "horizontal" | "vertical" | undefined;
44
56
  readonly disabled?: true | undefined;
45
57
  readonly readonly?: true | undefined;
46
58
  readonly dragging?: true | undefined;
47
59
  }, PartComponentProps, {}, unknown>;
48
60
  Track: PartComponent<"div", {
61
+ readonly touched?: true | undefined;
62
+ readonly dirty?: true | undefined;
63
+ readonly filled?: true | undefined;
64
+ readonly focused?: true | undefined;
65
+ readonly valid?: true | undefined;
66
+ readonly invalid?: true | undefined;
49
67
  readonly orientation?: "horizontal" | "vertical" | undefined;
50
68
  readonly disabled?: true | undefined;
51
69
  readonly readonly?: true | undefined;
52
70
  readonly dragging?: true | undefined;
53
71
  }, PartComponentProps, {}, unknown>;
54
72
  Indicator: PartComponent<"div", {
73
+ readonly touched?: true | undefined;
74
+ readonly dirty?: true | undefined;
75
+ readonly filled?: true | undefined;
76
+ readonly focused?: true | undefined;
77
+ readonly valid?: true | undefined;
78
+ readonly invalid?: true | undefined;
55
79
  readonly orientation?: "horizontal" | "vertical" | undefined;
56
80
  readonly disabled?: true | undefined;
57
81
  readonly readonly?: true | undefined;
58
82
  readonly dragging?: true | undefined;
59
83
  }, PartComponentProps, {}, unknown>;
60
84
  Thumb: PartComponent<"div", {
85
+ readonly touched?: true | undefined;
86
+ readonly dirty?: true | undefined;
87
+ readonly filled?: true | undefined;
88
+ readonly focused?: true | undefined;
89
+ readonly valid?: true | undefined;
90
+ readonly invalid?: true | undefined;
61
91
  readonly orientation?: "horizontal" | "vertical" | undefined;
62
92
  readonly disabled?: true | undefined;
63
93
  readonly readonly?: true | undefined;
package/src/steps.d.ts ADDED
@@ -0,0 +1,74 @@
1
+ import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
2
+ import { StepsProps } from "@kirana-ui/core/steps";
3
+ export type RootProps = Omit<StepsProps, "id" | "onStepChange"> & {
4
+ id?: string | undefined;
5
+ } & PartComponentProps;
6
+ export type RootEmits = Changes<"step", number>;
7
+ export interface ItemProps extends PartComponentProps {
8
+ /**
9
+ * Which step it is, from 0. Left out, its place among the items in the page, once it is
10
+ * there: give it on a page a server draws, which cannot count them.
11
+ */
12
+ index?: number | undefined;
13
+ }
14
+ export interface ContentProps extends PartComponentProps {
15
+ /** The step it is shown for, from 0. */
16
+ index: number;
17
+ }
18
+ export type ListProps = PartComponentProps;
19
+ export type TriggerProps = PartComponentProps;
20
+ export type IndicatorProps = PartComponentProps;
21
+ export type SeparatorProps = PartComponentProps;
22
+ export type CompletedProps = PartComponentProps;
23
+ export type PreviousProps = PartComponentProps;
24
+ export type NextProps = PartComponentProps;
25
+ export declare const Steps: {
26
+ Root: PartComponent<"div", {
27
+ readonly orientation?: "horizontal" | "vertical" | undefined;
28
+ readonly complete?: true | undefined;
29
+ }, RootProps, RootEmits>;
30
+ List: PartComponent<"div", {
31
+ readonly orientation?: "horizontal" | "vertical" | undefined;
32
+ }, PartComponentProps, {}, unknown>;
33
+ Item: PartComponent<"div", {
34
+ readonly current?: true | undefined;
35
+ readonly complete?: true | undefined;
36
+ readonly incomplete?: true | undefined;
37
+ readonly orientation?: "horizontal" | "vertical" | undefined;
38
+ }, ItemProps>;
39
+ Trigger: PartComponent<"button", {
40
+ readonly current?: true | undefined;
41
+ readonly complete?: true | undefined;
42
+ readonly incomplete?: true | undefined;
43
+ readonly orientation?: "horizontal" | "vertical" | undefined;
44
+ readonly disabled?: true | undefined;
45
+ }, PartComponentProps, {}, unknown>;
46
+ Indicator: PartComponent<"span", {
47
+ readonly current?: true | undefined;
48
+ readonly complete?: true | undefined;
49
+ readonly incomplete?: true | undefined;
50
+ readonly orientation?: "horizontal" | "vertical" | undefined;
51
+ }, PartComponentProps, {}, unknown>;
52
+ Separator: PartComponent<"div", {
53
+ readonly current?: true | undefined;
54
+ readonly complete?: true | undefined;
55
+ readonly incomplete?: true | undefined;
56
+ readonly orientation?: "horizontal" | "vertical" | undefined;
57
+ }, PartComponentProps, {}, unknown>;
58
+ Content: PartComponent<"div", {
59
+ readonly current?: true | undefined;
60
+ readonly complete?: true | undefined;
61
+ readonly incomplete?: true | undefined;
62
+ readonly orientation?: "horizontal" | "vertical" | undefined;
63
+ }, ContentProps>;
64
+ Completed: PartComponent<"div", {
65
+ readonly orientation?: "horizontal" | "vertical" | undefined;
66
+ }, PartComponentProps, {}, unknown>;
67
+ Previous: PartComponent<"button", {
68
+ readonly disabled?: true | undefined;
69
+ }, PartComponentProps, {}, unknown>;
70
+ Next: PartComponent<"button", {
71
+ readonly disabled?: true | undefined;
72
+ }, PartComponentProps, {}, unknown>;
73
+ };
74
+ //# sourceMappingURL=steps.d.ts.map
package/src/steps.js ADDED
@@ -0,0 +1,84 @@
1
+ import { useDirectionAround } from "./direction-context.js";
2
+ import { context, controller, optional, partComponent } from "./runtime.js";
3
+ import { within } from "@kirana-ui/core";
4
+ import { defineComponent, h, inject, provide, useId } from "vue";
5
+ import { createSteps } from "@kirana-ui/core/steps";
6
+ // src/steps.ts
7
+ const scope = context("Steps");
8
+ const ITEM = Symbol("StepsItem");
9
+ function useIndex(part) {
10
+ const index = inject(ITEM, void 0);
11
+ if (index === void 0) throw new Error(`<Steps.${part}> must be inside <Steps.Item>`);
12
+ return index;
13
+ }
14
+ const RootElement = partComponent("StepsRootElement", "div", () => scope.use().root);
15
+ /** `v-model:step`, or `step` with `@step-change="(step, details) => …"`. */
16
+ const Root = defineComponent({
17
+ name: "StepsRoot",
18
+ inheritAttrs: false,
19
+ props: {
20
+ step: optional(Number),
21
+ defaultStep: Number,
22
+ count: Number,
23
+ linear: Boolean,
24
+ orientation: String,
25
+ id: String
26
+ },
27
+ emits: ["update:step", "stepChange"],
28
+ setup(props, { attrs, slots, emit }) {
29
+ const generated = useId();
30
+ const direction = useDirectionAround();
31
+ scope.provide(controller(within(createSteps, { direction }), () => ({
32
+ id: props.id ?? generated,
33
+ step: props.step,
34
+ defaultStep: props.defaultStep,
35
+ count: props.count,
36
+ linear: props.linear,
37
+ orientation: props.orientation,
38
+ onStepChange(step, details) {
39
+ emit("stepChange", step, details);
40
+ if (!details.canceled) emit("update:step", step);
41
+ }
42
+ })));
43
+ return () => h(RootElement, attrs, slots);
44
+ }
45
+ });
46
+ const Item = defineComponent({
47
+ name: "StepsItem",
48
+ inheritAttrs: false,
49
+ props: { index: Number },
50
+ setup(props, { attrs, slots }) {
51
+ const item = scope.use().item(props.index);
52
+ provide(ITEM, item.index);
53
+ const Element = partComponent("StepsItemElement", "div", () => item);
54
+ return () => h(Element, attrs, slots);
55
+ }
56
+ });
57
+ const Content = defineComponent({
58
+ name: "StepsContent",
59
+ inheritAttrs: false,
60
+ props: { index: {
61
+ type: Number,
62
+ required: true
63
+ } },
64
+ setup(props, { attrs, slots }) {
65
+ const made = scope.use();
66
+ const Element = partComponent("StepsContentElement", "div", () => made.content(props.index));
67
+ return () => h(Element, attrs, slots);
68
+ }
69
+ });
70
+ const Steps = {
71
+ Root,
72
+ List: partComponent("StepsList", "div", () => scope.use().list),
73
+ Item,
74
+ Trigger: partComponent("StepsTrigger", "button", () => scope.use().trigger(useIndex("Trigger"))),
75
+ Indicator: partComponent("StepsIndicator", "span", () => scope.use().indicator(useIndex("Indicator"))),
76
+ Separator: partComponent("StepsSeparator", "div", () => scope.use().separator(useIndex("Separator"))),
77
+ Content,
78
+ Completed: partComponent("StepsCompleted", "div", () => scope.use().completed),
79
+ Previous: partComponent("StepsPrevious", "button", () => scope.use().previous),
80
+ Next: partComponent("StepsNext", "button", () => scope.use().next)
81
+ };
82
+ export { Steps };
83
+
84
+ //# sourceMappingURL=steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.js","names":[],"sources":["../../../../packages/vue/src/steps.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation, ReadonlySignal } from \"@kirana-ui/core\"\nimport { createSteps } from \"@kirana-ui/core/steps\"\nimport type { Steps as Controller, StepsProps } from \"@kirana-ui/core/steps\"\nimport { defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"steps\">\n\nconst scope = context<Controller>(\"Steps\")\n// The step an item is, for the parts inside it: given, or counted from the page.\nconst ITEM: InjectionKey<ReadonlySignal<number>> = Symbol(\"StepsItem\")\n\nfunction useIndex(part: string): ReadonlySignal<number> {\n const index = inject(ITEM, undefined)\n if (index === undefined) throw new Error(`<Steps.${part}> must be inside <Steps.Item>`)\n return index\n}\n\nconst RootElement = partComponent(\"StepsRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<StepsProps, \"id\" | \"onStepChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"step\", number>\n\n/** `v-model:step`, or `step` with `@step-change=\"(step, details) => …\"`. */\nconst Root = defineComponent({\n name: \"StepsRoot\",\n inheritAttrs: false,\n props: {\n step: optional(Number),\n defaultStep: Number,\n count: Number,\n linear: Boolean,\n orientation: String as PropType<Orientation>,\n id: String,\n },\n emits: [\"update:step\", \"stepChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createSteps, { direction }), () => ({\n id: props.id ?? generated,\n step: props.step,\n defaultStep: props.defaultStep,\n count: props.count,\n linear: props.linear,\n orientation: props.orientation,\n onStepChange(step: number, details: ChangeDetails) {\n emit(\"stepChange\", step, details)\n if (!details.canceled) emit(\"update:step\", step)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport interface ItemProps extends PartComponentProps {\n /**\n * Which step it is, from 0. Left out, its place among the items in the page, once it is\n * there: give it on a page a server draws, which cannot count them.\n */\n index?: number | undefined\n}\n\nconst Item = defineComponent({\n name: \"StepsItem\",\n inheritAttrs: false,\n props: { index: Number },\n setup(props, { attrs, slots }) {\n // An item is its step for as long as it is in the page.\n const item = scope.use().item(props.index)\n provide(ITEM, item.index)\n const Element = partComponent(\"StepsItemElement\", \"div\", () => item)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface ContentProps extends PartComponentProps {\n /** The step it is shown for, from 0. */\n index: number\n}\n\nconst Content = defineComponent({\n name: \"StepsContent\",\n inheritAttrs: false,\n props: { index: { type: Number, required: true } },\n setup(props, { attrs, slots }) {\n const made = scope.use()\n const Element = partComponent(\"StepsContentElement\", \"div\", () => made.content(props.index))\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"content\"], ContentProps>\n\nexport type ListProps = PartComponentProps\nexport type TriggerProps = PartComponentProps\nexport type IndicatorProps = PartComponentProps\nexport type SeparatorProps = PartComponentProps\nexport type CompletedProps = PartComponentProps\nexport type PreviousProps = PartComponentProps\nexport type NextProps = PartComponentProps\nexport const Steps = {\n Root,\n List: partComponent<\"div\", State[\"list\"]>(\"StepsList\", \"div\", () => scope.use().list),\n Item,\n Trigger: partComponent<\"button\", State[\"trigger\"]>(\"StepsTrigger\", \"button\", () =>\n scope.use().trigger(useIndex(\"Trigger\"))\n ),\n Indicator: partComponent<\"span\", State[\"indicator\"]>(\"StepsIndicator\", \"span\", () =>\n scope.use().indicator(useIndex(\"Indicator\"))\n ),\n Separator: partComponent<\"div\", State[\"separator\"]>(\"StepsSeparator\", \"div\", () =>\n scope.use().separator(useIndex(\"Separator\"))\n ),\n Content,\n Completed: partComponent<\"div\", State[\"completed\"]>(\n \"StepsCompleted\",\n \"div\",\n () => scope.use().completed\n ),\n Previous: partComponent<\"button\", State[\"previous\"]>(\n \"StepsPrevious\",\n \"button\",\n () => scope.use().previous\n ),\n Next: partComponent<\"button\", State[\"next\"]>(\"StepsNext\", \"button\", () => scope.use().next),\n}\n"],"mappings":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