@k2b/ui 0.36.0 → 0.37.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 (41) hide show
  1. package/dist/browser/actions/Dropdown.js +132 -116
  2. package/dist/browser/actions/Dropdown.js.map +1 -1
  3. package/dist/browser/actions/Tabs.js +18 -15
  4. package/dist/browser/actions/Tabs.js.map +1 -1
  5. package/dist/browser/chat/ChatComposer.js +58 -25
  6. package/dist/browser/chat/ChatComposer.js.map +1 -1
  7. package/dist/browser/content/MessageRow.js +164 -152
  8. package/dist/browser/content/MessageRow.js.map +1 -1
  9. package/dist/browser/feedback/prompts.js +23 -9
  10. package/dist/browser/feedback/prompts.js.map +1 -1
  11. package/dist/browser/inputs/Combobox.js +56 -51
  12. package/dist/browser/inputs/Combobox.js.map +1 -1
  13. package/dist/browser/inputs/RichSelect.js +86 -67
  14. package/dist/browser/inputs/RichSelect.js.map +1 -1
  15. package/dist/browser/internal/keyed-for.js +47 -0
  16. package/dist/browser/internal/keyed-for.js.map +1 -0
  17. package/dist/browser/text-editor/engine.js +13 -10
  18. package/dist/browser/text-editor/engine.js.map +1 -1
  19. package/dist/ssr/actions/Dropdown.js +101 -85
  20. package/dist/ssr/actions/Dropdown.js.map +1 -1
  21. package/dist/ssr/actions/Tabs.js +12 -9
  22. package/dist/ssr/actions/Tabs.js.map +1 -1
  23. package/dist/ssr/chat/ChatComposer.js +41 -15
  24. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  25. package/dist/ssr/content/MessageRow.js +9 -2
  26. package/dist/ssr/content/MessageRow.js.map +1 -1
  27. package/dist/ssr/feedback/prompts.js +22 -8
  28. package/dist/ssr/feedback/prompts.js.map +1 -1
  29. package/dist/ssr/inputs/Combobox.js +18 -13
  30. package/dist/ssr/inputs/Combobox.js.map +1 -1
  31. package/dist/ssr/inputs/RichSelect.js +47 -28
  32. package/dist/ssr/inputs/RichSelect.js.map +1 -1
  33. package/dist/ssr/internal/keyed-for.js +47 -0
  34. package/dist/ssr/internal/keyed-for.js.map +1 -0
  35. package/dist/ssr/text-editor/engine.js +13 -10
  36. package/dist/ssr/text-editor/engine.js.map +1 -1
  37. package/dist/types/content/MessageRow.d.ts +1 -1
  38. package/dist/types/feedback/prompts.d.ts +5 -0
  39. package/dist/types/internal/keyed-for.d.ts +13 -0
  40. package/dist/types/text-editor/engine.d.ts +1 -1
  41. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["feedback/prompts.tsx"],"sourcesContent":["import { mutation, timed } from \"@k2b/stdlib/solid\";\nimport { createEffect, createMemo, createSignal, createUniqueId, For, type JSX, onCleanup, Show } from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\nimport { Checkbox } from \"../inputs/Checkbox\";\nimport { PinInput } from \"../inputs/ChoiceInputs\";\nimport { DatePicker, DateTimePicker } from \"../inputs/DatePicker\";\nimport { ImageInput } from \"../inputs/FileInputs\";\nimport { NumberInput } from \"../inputs/NumberInput\";\nimport { Select } from \"../inputs/Select\";\nimport { resolveSelectMessages } from \"../inputs/select-messages\";\nimport { TagsInput } from \"../inputs/TagsInput\";\nimport { TextInput } from \"../inputs/TextInput\";\nimport { resolveUiMessages } from \"../intl/messages\";\nimport { type DialogRender, dialogCore, type OpenDialogOptions } from \"./dialog-core\";\nimport { resolvePromptMessages } from \"./prompt-messages\";\n\nexport interface DialogOptions {\n signal?: AbortSignal;\n title?: string;\n ariaLabel?: string;\n icon?: string;\n confirmText?: string;\n cancelText?: string | false;\n variant?: \"danger\" | \"primary\" | \"success\";\n /** `full` fills the available viewport and becomes edge-to-edge on narrow screens. */\n size?: \"small\" | \"medium\" | \"large\" | \"wide\" | \"full\";\n surface?: \"default\" | \"bare\";\n header?: false;\n cancelBehavior?: OpenDialogOptions[\"cancelBehavior\"];\n /** Back closes the prompt like Cancel, as in a phone app; see `OpenDialogOptions.history`. */\n history?: boolean;\n}\n\nexport interface ConfirmOptions extends DialogOptions {\n confirmationPhrase?: string;\n}\n\ntype PromptContent = string | HTMLElement | JSX.Element;\n\nexport type PromptSearchItem<T = unknown> = {\n label: string;\n desc?: string;\n icon?: string;\n previewUrl?: string;\n value?: T;\n};\n\nexport type PromptSearchInput = {\n query: string;\n abortSignal: AbortSignal;\n};\n\nexport type PromptSearchOptions = DialogOptions & {\n placeholder?: string;\n icon?: string;\n initialQuery?: string;\n minQueryLength?: number;\n debounceMs?: number;\n emptyText?: string;\n noResultsText?: string;\n};\n\nexport type PromptFieldBase<T = any> = {\n label?: string | false;\n description?: string;\n placeholder?: string;\n required?: boolean;\n default?: T;\n validate?: (value: T | undefined) => string | null;\n};\n\nexport type FieldSchema =\n | (PromptFieldBase<string> & {\n type: \"text\";\n multiline?: boolean;\n lines?: number;\n maxLength?: number;\n minLength?: number;\n icon?: string;\n activeIcon?: string;\n password?: boolean;\n markdown?: boolean;\n })\n | (PromptFieldBase<number> & {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number;\n })\n | (PromptFieldBase<string> & {\n type: \"image\";\n round?: boolean;\n ariaLabel?: string;\n accept?: string;\n })\n | (PromptFieldBase<string> & {\n type: \"pin\";\n length?: number;\n stretch?: boolean;\n })\n | (PromptFieldBase<string> & {\n type: \"select\";\n options: string[] | { id: string; label?: string; description?: string; icon?: string }[];\n icon?: string;\n activeIcon?: string;\n clearable?: boolean;\n })\n | (PromptFieldBase<string[]> & {\n type: \"tags\";\n maxTags?: number;\n minTags?: number;\n icon?: string;\n activeIcon?: string;\n })\n | (PromptFieldBase<boolean> & {\n type: \"boolean\";\n })\n | (PromptFieldBase<string> & {\n type: \"datetime\";\n dateOnly?: boolean;\n /** A date whose time is optional, as `DateTimePicker`'s `optionalTime`. */\n optionalTime?: boolean;\n })\n | {\n type: \"info\";\n content: string | JSX.Element | (() => JSX.Element);\n };\n\ntype InferFieldType<T extends FieldSchema> = T extends { type: \"text\" }\n ? string\n : T extends { type: \"number\" }\n ? number\n : T extends { type: \"image\" }\n ? string\n : T extends { type: \"pin\" }\n ? string\n : T extends { type: \"select\" }\n ? string\n : T extends { type: \"tags\" }\n ? string[]\n : T extends { type: \"boolean\" }\n ? boolean\n : T extends { type: \"datetime\" }\n ? string\n : T extends { type: \"currency\" }\n ? number\n : T extends { type: \"info\" }\n ? never\n : never;\n\ntype InferFormValues<T extends Record<string, FieldSchema>> = {\n [K in keyof T as T[K] extends { type: \"info\" } ? never : K]: T[K] extends { required: true }\n ? InferFieldType<T[K]>\n : InferFieldType<T[K]> | undefined;\n};\n\ntype PromptFormValue = string | number | boolean | string[] | undefined;\ntype PromptFormOptions<T extends Record<string, FieldSchema>> = {\n signal?: AbortSignal;\n title?: string;\n ariaLabel?: string;\n icon?: string;\n fields: T;\n confirmText?: string;\n cancelText?: string | false;\n variant?: \"danger\" | \"primary\" | \"success\";\n size?: DialogOptions[\"size\"];\n cancelBehavior?: DialogOptions[\"cancelBehavior\"];\n};\n\nconst PHRASE_SLOT = \"\\u0000\";\n\nconst isEmpty = (value: unknown): boolean =>\n value === undefined || value === null || value === \"\" || (Array.isArray(value) && value.length === 0);\n\nexport const createFormState = <T extends Record<string, FieldSchema>>(schema: T) => {\n const messages = resolveUiMessages();\n const promptMessages = resolvePromptMessages();\n const [values, setValues] = createStore<Record<string, PromptFormValue>>({});\n const [errors, setErrors] = createStore<Record<string, string | undefined>>({});\n // Errors appear with the first submit and then follow every change. Before that, a check that fails mid-input,\n // such as a URL still being typed, would interrupt the user with an alert on the first character.\n let submitted = false;\n\n for (const [key, field] of Object.entries(schema)) {\n if (field.type !== \"info\" && \"default\" in field) setValues(key, field.default as PromptFormValue);\n }\n\n const validateField = (key: string, value: PromptFormValue): string | null => {\n const field = schema[key];\n if (!field || field.type === \"info\") return null;\n if (field.type === \"boolean\" && field.required && value !== true) return messages.required;\n if (field.required && isEmpty(value)) return messages.required;\n if (\"validate\" in field && field.validate) {\n const customError = (field.validate as (next: never) => string | null)(value as never);\n if (customError) return customError;\n }\n if (field.type === \"text\" && typeof value === \"string\" && value.length > 0) {\n if (field.minLength !== undefined && value.length < field.minLength) return promptMessages.minCharacters({ count: field.minLength });\n if (field.maxLength !== undefined && value.length > field.maxLength) return promptMessages.maxCharacters({ count: field.maxLength });\n }\n if (field.type === \"tags\" && Array.isArray(value) && value.length > 0) {\n if (field.minTags !== undefined && value.length < field.minTags) return promptMessages.minTags({ count: field.minTags });\n if (field.maxTags !== undefined && value.length > field.maxTags) return promptMessages.maxTags({ count: field.maxTags });\n }\n return null;\n };\n\n const updateField = (key: string, value: PromptFormValue) => {\n setValues(key, value);\n if (submitted) setErrors(key, validateField(key, value) ?? undefined);\n };\n\n const validateAll = (): boolean => {\n submitted = true;\n let valid = true;\n for (const [key, field] of Object.entries(schema)) {\n if (field.type === \"info\") continue;\n const error = validateField(key, values[key]);\n setErrors(key, error ?? undefined);\n if (error) valid = false;\n }\n return valid;\n };\n\n const reset = () => {\n submitted = false;\n for (const [key, field] of Object.entries(schema)) {\n if (field.type === \"info\") continue;\n setValues(key, \"default\" in field ? (field.default as PromptFormValue) : undefined);\n setErrors(key, undefined);\n }\n };\n\n return { values, errors, updateField, validateAll, reset };\n};\n\nexport const DialogHeader = (props: { close: () => void; title?: string; icon?: string }): JSX.Element => (\n <header class=\"k2b-dialog__header\">\n <Show when={props.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n <Show when={props.title} fallback={<span class=\"k2b-dialog__header-spacer\" />}>\n {(title) => <h2>{title()}</h2>}\n </Show>\n <button type=\"button\" class=\"k2b-dialog__close\" aria-label={resolveUiMessages().closeDialog} onClick={props.close}>\n <i class=\"ti ti-x\" aria-hidden=\"true\" />\n </button>\n </header>\n);\n\nconst panelClass = (options?: Pick<DialogOptions, \"size\" | \"surface\" | \"variant\">): string => {\n const size = options?.size ?? \"medium\";\n const variant = options?.variant && options.variant !== \"primary\" ? ` k2b-dialog--${options.variant}` : \"\";\n return `k2b-dialog k2b-dialog--${size}${variant}${options?.surface === \"bare\" ? \" is-bare\" : \"\"}`;\n};\n\nconst contentClass = (surface?: DialogOptions[\"surface\"]): string =>\n surface === \"bare\" ? \"k2b-dialog__viewport is-bare\" : \"k2b-dialog__viewport\";\n\nconst renderInfo = (content: Extract<FieldSchema, { type: \"info\" }>[\"content\"]): JSX.Element => {\n if (typeof content === \"string\") return <p>{content}</p>;\n if (typeof content === \"function\") return content();\n return content;\n};\n\nconst PromptControl = (props: {\n field: Exclude<FieldSchema, { type: \"info\" }>;\n value: () => PromptFormValue;\n update: (value: PromptFormValue) => void;\n error: () => string | undefined;\n submit: () => void;\n}): JSX.Element => {\n const label = props.field.label || undefined;\n\n switch (props.field.type) {\n case \"text\":\n return (\n <TextInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={String(props.value() ?? \"\")}\n onValueChange={(value) => props.update(value ?? undefined)}\n onSubmit={props.submit}\n multiline={props.field.multiline}\n lines={props.field.lines}\n icon={props.field.icon}\n activeIcon={props.field.activeIcon}\n password={props.field.password}\n markdown={props.field.markdown}\n minLength={props.field.minLength}\n maxLength={props.field.maxLength}\n />\n );\n case \"number\":\n return (\n <NumberInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={typeof props.value() === \"number\" ? (props.value() as number) : null}\n onValueChange={(value) => props.update(value ?? undefined)}\n min={props.field.min}\n max={props.field.max}\n step={props.field.step}\n />\n );\n case \"image\":\n return (\n <ImageInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n error={props.error}\n value={() => (typeof props.value() === \"string\" ? (props.value() as string) : null)}\n onValueChange={(value) => props.update(value ?? undefined)}\n round={props.field.round}\n aria-label={props.field.ariaLabel}\n accept={props.field.accept}\n />\n );\n case \"pin\":\n return (\n <PinInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n error={props.error}\n value={() => String(props.value() ?? \"\")}\n onValueChange={props.update}\n length={props.field.length}\n stretch={props.field.stretch}\n />\n );\n case \"select\":\n return (\n <Select\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={() => (typeof props.value() === \"string\" ? (props.value() as string) : null)}\n onValueChange={(value) => props.update(value ?? undefined)}\n options={props.field.options}\n icon={props.field.icon}\n activeIcon={props.field.activeIcon}\n clearable={props.field.clearable}\n />\n );\n case \"tags\":\n return (\n <TagsInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={() => (Array.isArray(props.value()) ? (props.value() as string[]) : [])}\n onValueChange={props.update}\n maxTags={props.field.maxTags}\n icon={props.field.icon}\n activeIcon={props.field.activeIcon}\n />\n );\n case \"boolean\":\n return (\n <Checkbox\n label={label}\n description={props.field.description}\n required={props.field.required}\n error={props.error}\n value={() => Boolean(props.value())}\n onValueChange={props.update}\n />\n );\n case \"datetime\": {\n const pickerProps = {\n label,\n description: props.field.description,\n required: props.field.required,\n placeholder: props.field.placeholder,\n error: props.error,\n value: () => (typeof props.value() === \"string\" ? (props.value() as string) : null),\n onValueChange: (value: string | null) => props.update(value ?? \"\"),\n clearable: true,\n };\n return props.field.dateOnly ? (\n <DatePicker {...pickerProps} />\n ) : (\n <DateTimePicker {...pickerProps} optionalTime={props.field.optionalTime} />\n );\n }\n }\n};\n\nconst PromptFormDialog = <T extends Record<string, FieldSchema>>(props: {\n config: PromptFormOptions<T>;\n close: (value: InferFormValues<T> | null) => void;\n}): JSX.Element => {\n const state = createFormState(props.config.fields);\n const submit = () => {\n if (state.validateAll()) props.close(state.values as InferFormValues<T>);\n };\n const handleSubmit = (event: SubmitEvent) => {\n event.preventDefault();\n submit();\n };\n\n return (\n <form class=\"k2b-dialog__panel\" onSubmit={handleSubmit}>\n <DialogHeader title={props.config.title} icon={props.config.icon} close={() => props.close(null)} />\n <div class=\"k2b-dialog__body k2b-prompt-form\">\n <For each={Object.entries(props.config.fields)}>\n {([key, field]) => {\n if (field.type === \"info\") return <div class=\"k2b-prompt-form__info\">{renderInfo(field.content)}</div>;\n return (\n <PromptControl\n field={field}\n value={() => state.values[key]}\n update={(value) => state.updateField(key, value)}\n error={() => state.errors[key]}\n submit={submit}\n />\n );\n }}\n </For>\n </div>\n <footer class=\"k2b-dialog__actions\">\n <Show when={props.config.cancelText !== false}>\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" onClick={() => props.close(null)}>\n {props.config.cancelText || resolveUiMessages().cancel}\n </button>\n </Show>\n <button type=\"submit\" class=\"k2b-button\" data-variant={props.config.variant ?? \"primary\"}>\n {props.config.confirmText ?? resolveUiMessages().save}\n </button>\n </footer>\n </form>\n );\n};\n\ntype CloudSearchResolver<T> = (input: PromptSearchInput) => Promise<PromptSearchItem<T>[]> | PromptSearchItem<T>[];\n\nconst openSearchPrompt = <T extends unknown = unknown>(resolver: CloudSearchResolver<T>, options?: PromptSearchOptions) =>\n dialogCore.open<PromptSearchItem<T>>(\n (close) => {\n const [query, setQuery] = createSignal(options?.initialQuery ?? \"\");\n const [items, setItems] = createSignal<PromptSearchItem<T>[]>([]);\n const [activeIndex, setActiveIndex] = createSignal(0);\n const [hasLoaded, setHasLoaded] = createSignal(false);\n const [failedPreviews, setFailedPreviews] = createStore<Record<number, true>>({});\n const [activeSearchQuery, setActiveSearchQuery] = createSignal(\"\");\n const rowRefs = new Map<number, HTMLButtonElement>();\n const searchId = `k2b-prompt-search-${createUniqueId()}`;\n const listboxId = `${searchId}-listbox`;\n const optionId = (index: number) => `${searchId}-option-${index}`;\n\n const minQueryLength = options?.minQueryLength ?? 0;\n const debounceMs = options?.debounceMs ?? 180;\n const searchMutation = mutation.create<{ query: string; items: PromptSearchItem<T>[] }, string, { requestQuery: string }>({\n onBefore: (requestQuery) => ({ requestQuery }),\n mutation: async (requestQuery, context) => {\n const result = await resolver({\n query: requestQuery,\n abortSignal: context.abortSignal,\n });\n return { query: requestQuery, items: (result ?? []).slice() };\n },\n onSuccess: (result, context) => {\n if (!context || context.requestQuery !== activeSearchQuery()) return;\n setItems(result.items);\n setActiveIndex(0);\n setHasLoaded(true);\n },\n onError: (error, context) => {\n if (!context || context.requestQuery !== activeSearchQuery() || error.name === \"AbortError\") return;\n setItems([]);\n setActiveIndex(0);\n setHasLoaded(true);\n },\n });\n const searchError = createMemo(() => {\n const error = searchMutation.error();\n if (!error || error.name === \"AbortError\") return null;\n return error.message || resolvePromptMessages().searchFailed;\n });\n const shouldShowResults = createMemo(() => {\n if (query().trim().length < minQueryLength) return false;\n return hasLoaded() || searchError() !== null || items().length > 0;\n });\n const emptyStateText = createMemo(() => {\n if (!hasLoaded()) return options?.emptyText ?? resolveSelectMessages().typeToSearch;\n return options?.noResultsText ?? resolveUiMessages().noResults;\n });\n const { debouncedFn: debounceSearch, cancel: cancelDebounce } = timed.debounce((nextQuery: string) => {\n setActiveSearchQuery(nextQuery);\n searchMutation.abort();\n void searchMutation.mutate(nextQuery);\n }, debounceMs);\n\n const execute = (item?: PromptSearchItem<T>) => {\n if (!item) return;\n close(item);\n };\n const moveSelection = (delta: -1 | 1) => {\n const list = items();\n if (list.length === 0) return;\n setActiveIndex((activeIndex() + delta + list.length) % list.length);\n };\n\n createEffect(() => {\n const list = items();\n const maxIndex = list.length - 1;\n if (maxIndex < 0) {\n setActiveIndex(0);\n return;\n }\n if (activeIndex() > maxIndex) setActiveIndex(maxIndex);\n rowRefs.get(activeIndex())?.scrollIntoView({ block: \"nearest\" });\n });\n createEffect(() => {\n const nextQuery = query().trim();\n setFailedPreviews({});\n if (nextQuery.length < minQueryLength) {\n cancelDebounce();\n searchMutation.abort();\n setItems([]);\n setActiveIndex(0);\n setHasLoaded(false);\n setActiveSearchQuery(\"\");\n return;\n }\n debounceSearch(nextQuery);\n });\n onCleanup(() => {\n cancelDebounce();\n searchMutation.abort();\n });\n\n return (\n <div class=\"k2b-prompt-search-shell\">\n <Show when={options?.title}>{(title) => <p class=\"k2b-prompt-search-shell__title\">{title()}</p>}</Show>\n <div class=\"k2b-prompt-search\">\n <label class=\"k2b-prompt-search__input\">\n <i class={options?.icon ?? \"ti ti-search\"} aria-hidden=\"true\" />\n <input\n id={searchId}\n type=\"search\"\n role=\"combobox\"\n aria-label={options?.ariaLabel ?? options?.title ?? resolveUiMessages().search}\n aria-autocomplete=\"list\"\n aria-controls={listboxId}\n aria-expanded={shouldShowResults()}\n aria-activedescendant={shouldShowResults() && items().length > 0 ? optionId(activeIndex()) : undefined}\n aria-busy={searchMutation.loading()}\n value={query()}\n onInput={(event) => setQuery(event.currentTarget.value)}\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n moveSelection(1);\n } else if (event.key === \"ArrowUp\") {\n event.preventDefault();\n moveSelection(-1);\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n execute(items()[activeIndex()]);\n }\n }}\n placeholder={options?.placeholder ?? resolveUiMessages().search}\n spellcheck={false}\n autocapitalize=\"off\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n />\n <Show when={searchMutation.loading()}>\n <i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\" />\n </Show>\n </label>\n <div\n class=\"k2b-prompt-search__collapse\"\n style={{\n height: shouldShowResults() ? \"var(--k2b-search-body-max)\" : \"0px\",\n opacity: shouldShowResults() ? \"1\" : \"0\",\n }}\n >\n <div class=\"k2b-prompt-search__results\" onWheel={(event) => event.stopPropagation()}>\n <Show when={searchError()}>\n {(message) => (\n <div class=\"k2b-prompt-search__error\" role=\"status\" aria-live=\"polite\">\n {message()}\n </div>\n )}\n </Show>\n <Show\n when={items().length > 0}\n fallback={\n <p role=\"status\" aria-live=\"polite\">\n {emptyStateText()}\n </p>\n }\n >\n <div id={listboxId} class=\"k2b-prompt-search__list\" role=\"listbox\" aria-label={resolveUiMessages().searchResults}>\n <For each={items()}>\n {(item, index) => (\n <button\n ref={(element) => {\n if (!element) rowRefs.delete(index());\n else rowRefs.set(index(), element);\n }}\n type=\"button\"\n id={optionId(index())}\n role=\"option\"\n aria-selected={activeIndex() === index()}\n data-active={activeIndex() === index() ? \"true\" : undefined}\n data-has-description={item.desc ? \"true\" : undefined}\n onMouseEnter={() => setActiveIndex(index())}\n onClick={() => execute(item)}\n >\n {/* Cloud keeps the preview box mounted once a row declares an image, so a\n failed load swaps in the fallback glyph instead of collapsing the row. */}\n <Show when={item.previewUrl?.startsWith(\"/\") || item.icon}>\n <span class=\"k2b-prompt-search__preview\">\n <Show\n when={item.previewUrl?.startsWith(\"/\") && !failedPreviews[index()]}\n fallback={<i class={item.icon ?? \"ti ti-file\"} aria-hidden=\"true\" />}\n >\n <img src={item.previewUrl} alt=\"\" onError={() => setFailedPreviews(index(), true)} />\n </Show>\n </span>\n </Show>\n <span class=\"k2b-prompt-search__copy\">\n <strong>{item.label}</strong>\n <Show when={item.desc}>{(description) => <small>{description()}</small>}</Show>\n </span>\n </button>\n )}\n </For>\n </div>\n </Show>\n </div>\n </div>\n </div>\n </div>\n );\n },\n {\n panelClassName: \"k2b-dialog k2b-dialog--search is-bare\",\n contentClassName: \"k2b-dialog__viewport is-search\",\n initialFocus: \"first-input\",\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().search,\n },\n );\n\nconst promptText = (content: string, defaultValue?: string, options?: DialogOptions) =>\n prompts\n .form({\n ...options,\n fields: {\n message: { type: \"info\", content: () => <div class=\"k2b-prompt-copy\">{content}</div> },\n value: {\n type: \"text\",\n label: false,\n default: defaultValue || \"\",\n },\n },\n })\n .then((result) => result?.value ?? null);\n\nconst promptNumber = (\n content: string,\n defaultValue?: number,\n options?: DialogOptions & {\n min?: number;\n max?: number;\n },\n) =>\n prompts\n .form({\n ...options,\n fields: {\n message: { type: \"info\", content: () => <div class=\"k2b-prompt-copy\">{content}</div> },\n value: {\n type: \"number\",\n label: false,\n default: defaultValue || 0,\n min: options?.min,\n max: options?.max,\n },\n },\n })\n .then((result) => result?.value ?? null);\n\nexport const prompts = {\n alert: (content: PromptContent, options?: DialogOptions): Promise<void | undefined> =>\n dialogCore.open<void>(\n (close) => (\n <div class=\"k2b-dialog__panel\">\n <DialogHeader title={options?.title || resolveUiMessages().info} icon={options?.icon} close={() => close()} />\n <div class=\"k2b-dialog__body\">{content}</div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" data-variant={options?.variant ?? \"primary\"} onClick={() => close()}>\n {options?.confirmText || resolveUiMessages().ok}\n </button>\n </footer>\n </div>\n ),\n {\n panelClassName: panelClass(options),\n contentClassName: contentClass(options?.surface),\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().info,\n },\n ),\n\n success: (content: PromptContent, options?: Omit<DialogOptions, \"variant\">): Promise<void | undefined> =>\n prompts.alert(content, {\n ...options,\n variant: \"success\",\n title: options?.title ?? resolveUiMessages().success,\n icon: options?.icon ?? \"ti ti-check\",\n }),\n\n confirm: (content: PromptContent, options?: ConfirmOptions): Promise<boolean | undefined> => {\n const confirmationPhrase = options?.confirmationPhrase;\n if (confirmationPhrase !== undefined && (confirmationPhrase.trim().length === 0 || /[\\r\\n\\t]/.test(confirmationPhrase))) {\n throw new Error(\"confirmationPhrase must be non-empty, visible, and single-line\");\n }\n let confirmationInput: HTMLInputElement | undefined;\n\n return dialogCore.open<boolean>(\n (close) => {\n if (!confirmationPhrase) {\n return (\n <div class=\"k2b-dialog__panel\">\n <DialogHeader title={options?.title} icon={options?.icon} close={() => close(false)} />\n <div class=\"k2b-dialog__body\">{content}</div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" onClick={() => close(false)}>\n {options?.cancelText || resolveUiMessages().cancel}\n </button>\n <button type=\"button\" class=\"k2b-button\" data-variant={options?.variant ?? \"primary\"} onClick={() => close(true)}>\n {options?.confirmText || resolvePromptMessages().confirm}\n </button>\n </footer>\n </div>\n );\n }\n\n // The catalog owns word order; the slot marks where the verbatim phrase is rendered as code.\n const [labelBefore, labelAfter] = resolvePromptMessages().typeToConfirm({ phrase: PHRASE_SLOT }).split(PHRASE_SLOT);\n const [confirmationValue, setConfirmationValue] = createSignal(\"\");\n const canConfirm = () => confirmationValue() === confirmationPhrase;\n const submit = (event: SubmitEvent) => {\n event.preventDefault();\n if (canConfirm()) close(true);\n };\n\n return (\n <form class=\"k2b-dialog__panel\" onSubmit={submit}>\n <DialogHeader title={options?.title} icon={options?.icon} close={() => close(false)} />\n <div class=\"k2b-dialog__body k2b-prompt-form\">\n <div class=\"k2b-prompt-copy\">{content}</div>\n <TextInput\n ref={(element) => {\n confirmationInput = element;\n }}\n label={\n <>\n {labelBefore}\n <code class=\"k2b-confirmation-phrase\">{confirmationPhrase}</code>\n {labelAfter}\n </>\n }\n value={confirmationValue}\n onValueChange={setConfirmationValue}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck={false}\n monospace\n required\n />\n </div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" onClick={() => close(false)}>\n {options?.cancelText || resolveUiMessages().cancel}\n </button>\n <button type=\"submit\" class=\"k2b-button\" data-variant={options?.variant ?? \"primary\"} disabled={!canConfirm()}>\n {options?.confirmText || resolvePromptMessages().confirm}\n </button>\n </footer>\n </form>\n );\n },\n {\n panelClassName: panelClass(options),\n contentClassName: contentClass(options?.surface),\n initialFocus: confirmationPhrase ? () => confirmationInput ?? null : undefined,\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolvePromptMessages().confirmation,\n },\n );\n },\n\n prompt: promptText,\n promptNumber,\n\n form: async <T extends Record<string, FieldSchema>>(config: PromptFormOptions<T>): Promise<InferFormValues<T> | null> =>\n (await dialogCore.open<InferFormValues<T> | null>((close) => <PromptFormDialog config={config} close={(value) => close(value)} />, {\n panelClassName: panelClass(config),\n contentClassName: contentClass(),\n signal: config.signal,\n cancelBehavior: config.cancelBehavior,\n ariaLabel: config.ariaLabel ?? config.title ?? resolvePromptMessages().form,\n })) ?? null,\n\n /**\n * Open custom content with a typed close callback and the dialog render context.\n * Register a dismiss handler to guard Escape, backdrop clicks and the supplied header's close button,\n * for example while saving. Explicit close(result) bypasses the guard. Without a handler, dismissal\n * keeps its existing behavior, including a header close button independent of cancelBehavior.\n */\n dialog: <T extends unknown = unknown>(component: DialogRender<T>, options?: DialogOptions): Promise<T | undefined> =>\n dialogCore.open<T>(\n (close, context) => {\n // A dismiss handler the component sets guards the header's close button as well as Escape and the backdrop.\n let dismiss = () => close(undefined);\n const body = component(close, {\n ...context,\n setDismissHandler: (handler) => {\n context.setDismissHandler(handler);\n dismiss = () => void context.requestDismiss();\n },\n });\n if (options?.surface === \"bare\" && options.header === false) return body;\n return (\n <div class=\"k2b-dialog__panel k2b-dialog__stack\">\n <Show when={options?.header !== false}>\n <DialogHeader title={options?.title} icon={options?.icon} close={() => dismiss()} />\n </Show>\n <div class=\"k2b-dialog__content\">{body}</div>\n </div>\n );\n },\n {\n panelClassName: panelClass(options),\n contentClassName: contentClass(options?.surface),\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().dialog,\n },\n ),\n\n search: openSearchPrompt,\n\n error: (content: string | HTMLElement, options?: DialogOptions) =>\n dialogCore.open(\n (close) => (\n <div class=\"k2b-dialog__panel\">\n <DialogHeader title={options?.title ?? resolveUiMessages().error} icon={options?.icon ?? \"ti ti-alert-circle\"} close={close} />\n <div class=\"k2b-dialog__body\">{content}</div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" onClick={() => close()}>\n {options?.confirmText || resolveUiMessages().close}\n </button>\n </footer>\n </div>\n ),\n {\n panelClassName: panelClass({ ...options, variant: \"danger\" }),\n contentClassName: contentClass(options?.surface),\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?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,IAAI,oBAAoB;IAAA;IAAE,KAAK,EAAE;EAAK,cAC5F,OAAO,YAGjC,OAAO,EAAE,WAAW,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,EAIzD,EACD;IACE,cAAc,EAAE,UAAU,CAAC;MAAE,GAAG,OAAO;MAAE,OAAO,EAAE;IAAS,CAAC,CAAC;IAC7D,gBAAgB,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,MAAM,EAAE,OAAO,EAAE,MAAM;IACvB,cAAc,EAAE,OAAO,EAAE,cAAc;IACvC,OAAO,EAAE,OAAO,EAAE,OAAO;IACzB,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,KAAK,IAAI,iBAAiB,CAAC,CAAC,CAAC;EACzE,CACF;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["feedback/prompts.tsx"],"sourcesContent":["import { mutation, timed } from \"@k2b/stdlib/solid\";\nimport { createEffect, createMemo, createSignal, createUniqueId, For, type JSX, onCleanup, Show } from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\nimport { Checkbox } from \"../inputs/Checkbox\";\nimport { PinInput } from \"../inputs/ChoiceInputs\";\nimport { DatePicker, DateTimePicker } from \"../inputs/DatePicker\";\nimport { ImageInput } from \"../inputs/FileInputs\";\nimport { NumberInput } from \"../inputs/NumberInput\";\nimport { Select } from \"../inputs/Select\";\nimport { resolveSelectMessages } from \"../inputs/select-messages\";\nimport { TagsInput } from \"../inputs/TagsInput\";\nimport { TextInput } from \"../inputs/TextInput\";\nimport { KeyedFor } from \"../internal/keyed-for\";\nimport { resolveUiMessages } from \"../intl/messages\";\nimport { type DialogRender, dialogCore, type OpenDialogOptions } from \"./dialog-core\";\nimport { resolvePromptMessages } from \"./prompt-messages\";\n\nexport interface DialogOptions {\n signal?: AbortSignal;\n title?: string;\n ariaLabel?: string;\n icon?: string;\n confirmText?: string;\n cancelText?: string | false;\n variant?: \"danger\" | \"primary\" | \"success\";\n /** `full` fills the available viewport and becomes edge-to-edge on narrow screens. */\n size?: \"small\" | \"medium\" | \"large\" | \"wide\" | \"full\";\n surface?: \"default\" | \"bare\";\n header?: false;\n cancelBehavior?: OpenDialogOptions[\"cancelBehavior\"];\n /** Back closes the prompt like Cancel, as in a phone app; see `OpenDialogOptions.history`. */\n history?: boolean;\n}\n\nexport interface ConfirmOptions extends DialogOptions {\n confirmationPhrase?: string;\n}\n\ntype PromptContent = string | HTMLElement | JSX.Element;\n\nexport type PromptSearchItem<T = unknown> = {\n /**\n * Stable identity of the result, such as its record ID. With it, a newer answer that contains the same result keeps\n * its row, so a click in progress still lands. Without it, each answer replaces the rows.\n */\n id?: string;\n label: string;\n desc?: string;\n icon?: string;\n previewUrl?: string;\n value?: T;\n};\n\nexport type PromptSearchInput = {\n query: string;\n abortSignal: AbortSignal;\n};\n\nexport type PromptSearchOptions = DialogOptions & {\n placeholder?: string;\n icon?: string;\n initialQuery?: string;\n minQueryLength?: number;\n debounceMs?: number;\n emptyText?: string;\n noResultsText?: string;\n};\n\nexport type PromptFieldBase<T = any> = {\n label?: string | false;\n description?: string;\n placeholder?: string;\n required?: boolean;\n default?: T;\n validate?: (value: T | undefined) => string | null;\n};\n\nexport type FieldSchema =\n | (PromptFieldBase<string> & {\n type: \"text\";\n multiline?: boolean;\n lines?: number;\n maxLength?: number;\n minLength?: number;\n icon?: string;\n activeIcon?: string;\n password?: boolean;\n markdown?: boolean;\n })\n | (PromptFieldBase<number> & {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number;\n })\n | (PromptFieldBase<string> & {\n type: \"image\";\n round?: boolean;\n ariaLabel?: string;\n accept?: string;\n })\n | (PromptFieldBase<string> & {\n type: \"pin\";\n length?: number;\n stretch?: boolean;\n })\n | (PromptFieldBase<string> & {\n type: \"select\";\n options: string[] | { id: string; label?: string; description?: string; icon?: string }[];\n icon?: string;\n activeIcon?: string;\n clearable?: boolean;\n })\n | (PromptFieldBase<string[]> & {\n type: \"tags\";\n maxTags?: number;\n minTags?: number;\n icon?: string;\n activeIcon?: string;\n })\n | (PromptFieldBase<boolean> & {\n type: \"boolean\";\n })\n | (PromptFieldBase<string> & {\n type: \"datetime\";\n dateOnly?: boolean;\n /** A date whose time is optional, as `DateTimePicker`'s `optionalTime`. */\n optionalTime?: boolean;\n })\n | {\n type: \"info\";\n content: string | JSX.Element | (() => JSX.Element);\n };\n\ntype InferFieldType<T extends FieldSchema> = T extends { type: \"text\" }\n ? string\n : T extends { type: \"number\" }\n ? number\n : T extends { type: \"image\" }\n ? string\n : T extends { type: \"pin\" }\n ? string\n : T extends { type: \"select\" }\n ? string\n : T extends { type: \"tags\" }\n ? string[]\n : T extends { type: \"boolean\" }\n ? boolean\n : T extends { type: \"datetime\" }\n ? string\n : T extends { type: \"currency\" }\n ? number\n : T extends { type: \"info\" }\n ? never\n : never;\n\ntype InferFormValues<T extends Record<string, FieldSchema>> = {\n [K in keyof T as T[K] extends { type: \"info\" } ? never : K]: T[K] extends { required: true }\n ? InferFieldType<T[K]>\n : InferFieldType<T[K]> | undefined;\n};\n\ntype PromptFormValue = string | number | boolean | string[] | undefined;\ntype PromptFormOptions<T extends Record<string, FieldSchema>> = {\n signal?: AbortSignal;\n title?: string;\n ariaLabel?: string;\n icon?: string;\n fields: T;\n confirmText?: string;\n cancelText?: string | false;\n variant?: \"danger\" | \"primary\" | \"success\";\n size?: DialogOptions[\"size\"];\n cancelBehavior?: DialogOptions[\"cancelBehavior\"];\n};\n\nconst PHRASE_SLOT = \"\\u0000\";\n\nconst isEmpty = (value: unknown): boolean =>\n value === undefined || value === null || value === \"\" || (Array.isArray(value) && value.length === 0);\n\nexport const createFormState = <T extends Record<string, FieldSchema>>(schema: T) => {\n const messages = resolveUiMessages();\n const promptMessages = resolvePromptMessages();\n const [values, setValues] = createStore<Record<string, PromptFormValue>>({});\n const [errors, setErrors] = createStore<Record<string, string | undefined>>({});\n // Errors appear with the first submit and then follow every change. Before that, a check that fails mid-input,\n // such as a URL still being typed, would interrupt the user with an alert on the first character.\n let submitted = false;\n\n for (const [key, field] of Object.entries(schema)) {\n if (field.type !== \"info\" && \"default\" in field) setValues(key, field.default as PromptFormValue);\n }\n\n const validateField = (key: string, value: PromptFormValue): string | null => {\n const field = schema[key];\n if (!field || field.type === \"info\") return null;\n if (field.type === \"boolean\" && field.required && value !== true) return messages.required;\n if (field.required && isEmpty(value)) return messages.required;\n if (\"validate\" in field && field.validate) {\n const customError = (field.validate as (next: never) => string | null)(value as never);\n if (customError) return customError;\n }\n if (field.type === \"text\" && typeof value === \"string\" && value.length > 0) {\n if (field.minLength !== undefined && value.length < field.minLength) return promptMessages.minCharacters({ count: field.minLength });\n if (field.maxLength !== undefined && value.length > field.maxLength) return promptMessages.maxCharacters({ count: field.maxLength });\n }\n if (field.type === \"tags\" && Array.isArray(value) && value.length > 0) {\n if (field.minTags !== undefined && value.length < field.minTags) return promptMessages.minTags({ count: field.minTags });\n if (field.maxTags !== undefined && value.length > field.maxTags) return promptMessages.maxTags({ count: field.maxTags });\n }\n return null;\n };\n\n const updateField = (key: string, value: PromptFormValue) => {\n setValues(key, value);\n if (submitted) setErrors(key, validateField(key, value) ?? undefined);\n };\n\n const validateAll = (): boolean => {\n submitted = true;\n let valid = true;\n for (const [key, field] of Object.entries(schema)) {\n if (field.type === \"info\") continue;\n const error = validateField(key, values[key]);\n setErrors(key, error ?? undefined);\n if (error) valid = false;\n }\n return valid;\n };\n\n const reset = () => {\n submitted = false;\n for (const [key, field] of Object.entries(schema)) {\n if (field.type === \"info\") continue;\n setValues(key, \"default\" in field ? (field.default as PromptFormValue) : undefined);\n setErrors(key, undefined);\n }\n };\n\n return { values, errors, updateField, validateAll, reset };\n};\n\nexport const DialogHeader = (props: { close: () => void; title?: string; icon?: string }): JSX.Element => (\n <header class=\"k2b-dialog__header\">\n <Show when={props.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n <Show when={props.title} fallback={<span class=\"k2b-dialog__header-spacer\" />}>\n {(title) => <h2>{title()}</h2>}\n </Show>\n <button type=\"button\" class=\"k2b-dialog__close\" aria-label={resolveUiMessages().closeDialog} onClick={props.close}>\n <i class=\"ti ti-x\" aria-hidden=\"true\" />\n </button>\n </header>\n);\n\nconst panelClass = (options?: Pick<DialogOptions, \"size\" | \"surface\" | \"variant\">): string => {\n const size = options?.size ?? \"medium\";\n const variant = options?.variant && options.variant !== \"primary\" ? ` k2b-dialog--${options.variant}` : \"\";\n return `k2b-dialog k2b-dialog--${size}${variant}${options?.surface === \"bare\" ? \" is-bare\" : \"\"}`;\n};\n\nconst contentClass = (surface?: DialogOptions[\"surface\"]): string =>\n surface === \"bare\" ? \"k2b-dialog__viewport is-bare\" : \"k2b-dialog__viewport\";\n\nconst renderInfo = (content: Extract<FieldSchema, { type: \"info\" }>[\"content\"]): JSX.Element => {\n if (typeof content === \"string\") return <p>{content}</p>;\n if (typeof content === \"function\") return content();\n return content;\n};\n\nconst PromptControl = (props: {\n field: Exclude<FieldSchema, { type: \"info\" }>;\n value: () => PromptFormValue;\n update: (value: PromptFormValue) => void;\n error: () => string | undefined;\n submit: () => void;\n}): JSX.Element => {\n const label = props.field.label || undefined;\n\n switch (props.field.type) {\n case \"text\":\n return (\n <TextInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={String(props.value() ?? \"\")}\n onValueChange={(value) => props.update(value ?? undefined)}\n onSubmit={props.submit}\n multiline={props.field.multiline}\n lines={props.field.lines}\n icon={props.field.icon}\n activeIcon={props.field.activeIcon}\n password={props.field.password}\n markdown={props.field.markdown}\n minLength={props.field.minLength}\n maxLength={props.field.maxLength}\n />\n );\n case \"number\":\n return (\n <NumberInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={typeof props.value() === \"number\" ? (props.value() as number) : null}\n onValueChange={(value) => props.update(value ?? undefined)}\n min={props.field.min}\n max={props.field.max}\n step={props.field.step}\n />\n );\n case \"image\":\n return (\n <ImageInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n error={props.error}\n value={() => (typeof props.value() === \"string\" ? (props.value() as string) : null)}\n onValueChange={(value) => props.update(value ?? undefined)}\n round={props.field.round}\n aria-label={props.field.ariaLabel}\n accept={props.field.accept}\n />\n );\n case \"pin\":\n return (\n <PinInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n error={props.error}\n value={() => String(props.value() ?? \"\")}\n onValueChange={props.update}\n length={props.field.length}\n stretch={props.field.stretch}\n />\n );\n case \"select\":\n return (\n <Select\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={() => (typeof props.value() === \"string\" ? (props.value() as string) : null)}\n onValueChange={(value) => props.update(value ?? undefined)}\n options={props.field.options}\n icon={props.field.icon}\n activeIcon={props.field.activeIcon}\n clearable={props.field.clearable}\n />\n );\n case \"tags\":\n return (\n <TagsInput\n label={label}\n description={props.field.description}\n required={props.field.required}\n placeholder={props.field.placeholder}\n error={props.error}\n value={() => (Array.isArray(props.value()) ? (props.value() as string[]) : [])}\n onValueChange={props.update}\n maxTags={props.field.maxTags}\n icon={props.field.icon}\n activeIcon={props.field.activeIcon}\n />\n );\n case \"boolean\":\n return (\n <Checkbox\n label={label}\n description={props.field.description}\n required={props.field.required}\n error={props.error}\n value={() => Boolean(props.value())}\n onValueChange={props.update}\n />\n );\n case \"datetime\": {\n const pickerProps = {\n label,\n description: props.field.description,\n required: props.field.required,\n placeholder: props.field.placeholder,\n error: props.error,\n value: () => (typeof props.value() === \"string\" ? (props.value() as string) : null),\n onValueChange: (value: string | null) => props.update(value ?? \"\"),\n clearable: true,\n };\n return props.field.dateOnly ? (\n <DatePicker {...pickerProps} />\n ) : (\n <DateTimePicker {...pickerProps} optionalTime={props.field.optionalTime} />\n );\n }\n }\n};\n\nconst PromptFormDialog = <T extends Record<string, FieldSchema>>(props: {\n config: PromptFormOptions<T>;\n close: (value: InferFormValues<T> | null) => void;\n}): JSX.Element => {\n const state = createFormState(props.config.fields);\n const submit = () => {\n if (state.validateAll()) props.close(state.values as InferFormValues<T>);\n };\n const handleSubmit = (event: SubmitEvent) => {\n event.preventDefault();\n submit();\n };\n\n return (\n <form class=\"k2b-dialog__panel\" onSubmit={handleSubmit}>\n <DialogHeader title={props.config.title} icon={props.config.icon} close={() => props.close(null)} />\n <div class=\"k2b-dialog__body k2b-prompt-form\">\n <For each={Object.entries(props.config.fields)}>\n {([key, field]) => {\n if (field.type === \"info\") return <div class=\"k2b-prompt-form__info\">{renderInfo(field.content)}</div>;\n return (\n <PromptControl\n field={field}\n value={() => state.values[key]}\n update={(value) => state.updateField(key, value)}\n error={() => state.errors[key]}\n submit={submit}\n />\n );\n }}\n </For>\n </div>\n <footer class=\"k2b-dialog__actions\">\n <Show when={props.config.cancelText !== false}>\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" onClick={() => props.close(null)}>\n {props.config.cancelText || resolveUiMessages().cancel}\n </button>\n </Show>\n <button type=\"submit\" class=\"k2b-button\" data-variant={props.config.variant ?? \"primary\"}>\n {props.config.confirmText ?? resolveUiMessages().save}\n </button>\n </footer>\n </form>\n );\n};\n\n// Results without an ID keep today's behavior: each object is its own identity, so a new answer replaces the row.\nconst anonymousRows = new WeakMap<object, string>();\nlet anonymousRow = 0;\nconst searchRowIdentity = (item: PromptSearchItem<unknown>): string => {\n if (item.id !== undefined) return `id:${item.id}`;\n const known = anonymousRows.get(item);\n if (known !== undefined) return known;\n const key = `object:${anonymousRow++}`;\n anonymousRows.set(item, key);\n return key;\n};\n\ntype CloudSearchResolver<T> = (input: PromptSearchInput) => Promise<PromptSearchItem<T>[]> | PromptSearchItem<T>[];\n\nconst openSearchPrompt = <T extends unknown = unknown>(resolver: CloudSearchResolver<T>, options?: PromptSearchOptions) =>\n dialogCore.open<PromptSearchItem<T>>(\n (close) => {\n const [query, setQuery] = createSignal(options?.initialQuery ?? \"\");\n const [items, setItems] = createSignal<PromptSearchItem<T>[]>([]);\n const [activeIndex, setActiveIndex] = createSignal(0);\n const [hasLoaded, setHasLoaded] = createSignal(false);\n const [failedPreviews, setFailedPreviews] = createStore<Record<number, true>>({});\n const [activeSearchQuery, setActiveSearchQuery] = createSignal(\"\");\n const rowRefs = new Map<number, HTMLButtonElement>();\n const searchId = `k2b-prompt-search-${createUniqueId()}`;\n const listboxId = `${searchId}-listbox`;\n const optionId = (index: number) => `${searchId}-option-${index}`;\n\n const minQueryLength = options?.minQueryLength ?? 0;\n const debounceMs = options?.debounceMs ?? 180;\n const searchMutation = mutation.create<{ query: string; items: PromptSearchItem<T>[] }, string, { requestQuery: string }>({\n onBefore: (requestQuery) => ({ requestQuery }),\n mutation: async (requestQuery, context) => {\n const result = await resolver({\n query: requestQuery,\n abortSignal: context.abortSignal,\n });\n return { query: requestQuery, items: (result ?? []).slice() };\n },\n onSuccess: (result, context) => {\n if (!context || context.requestQuery !== activeSearchQuery()) return;\n setItems(result.items);\n setActiveIndex(0);\n setHasLoaded(true);\n },\n onError: (error, context) => {\n if (!context || context.requestQuery !== activeSearchQuery() || error.name === \"AbortError\") return;\n setItems([]);\n setActiveIndex(0);\n setHasLoaded(true);\n },\n });\n const searchError = createMemo(() => {\n const error = searchMutation.error();\n if (!error || error.name === \"AbortError\") return null;\n return error.message || resolvePromptMessages().searchFailed;\n });\n const shouldShowResults = createMemo(() => {\n if (query().trim().length < minQueryLength) return false;\n return hasLoaded() || searchError() !== null || items().length > 0;\n });\n const emptyStateText = createMemo(() => {\n if (!hasLoaded()) return options?.emptyText ?? resolveSelectMessages().typeToSearch;\n return options?.noResultsText ?? resolveUiMessages().noResults;\n });\n const { debouncedFn: debounceSearch, cancel: cancelDebounce } = timed.debounce((nextQuery: string) => {\n setActiveSearchQuery(nextQuery);\n searchMutation.abort();\n void searchMutation.mutate(nextQuery);\n }, debounceMs);\n\n const execute = (item?: PromptSearchItem<T>) => {\n if (!item) return;\n close(item);\n };\n const moveSelection = (delta: -1 | 1) => {\n const list = items();\n if (list.length === 0) return;\n setActiveIndex((activeIndex() + delta + list.length) % list.length);\n };\n\n createEffect(() => {\n const list = items();\n const maxIndex = list.length - 1;\n if (maxIndex < 0) {\n setActiveIndex(0);\n return;\n }\n if (activeIndex() > maxIndex) setActiveIndex(maxIndex);\n rowRefs.get(activeIndex())?.scrollIntoView({ block: \"nearest\" });\n });\n createEffect(() => {\n const nextQuery = query().trim();\n setFailedPreviews({});\n if (nextQuery.length < minQueryLength) {\n cancelDebounce();\n searchMutation.abort();\n setItems([]);\n setActiveIndex(0);\n setHasLoaded(false);\n setActiveSearchQuery(\"\");\n return;\n }\n debounceSearch(nextQuery);\n });\n onCleanup(() => {\n cancelDebounce();\n searchMutation.abort();\n });\n\n return (\n <div class=\"k2b-prompt-search-shell\">\n <Show when={options?.title}>{(title) => <p class=\"k2b-prompt-search-shell__title\">{title()}</p>}</Show>\n <div class=\"k2b-prompt-search\">\n <label class=\"k2b-prompt-search__input\">\n <i class={options?.icon ?? \"ti ti-search\"} aria-hidden=\"true\" />\n <input\n id={searchId}\n type=\"search\"\n role=\"combobox\"\n aria-label={options?.ariaLabel ?? options?.title ?? resolveUiMessages().search}\n aria-autocomplete=\"list\"\n aria-controls={listboxId}\n aria-expanded={shouldShowResults()}\n aria-activedescendant={shouldShowResults() && items().length > 0 ? optionId(activeIndex()) : undefined}\n aria-busy={searchMutation.loading()}\n value={query()}\n onInput={(event) => setQuery(event.currentTarget.value)}\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n moveSelection(1);\n } else if (event.key === \"ArrowUp\") {\n event.preventDefault();\n moveSelection(-1);\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n execute(items()[activeIndex()]);\n }\n }}\n placeholder={options?.placeholder ?? resolveUiMessages().search}\n spellcheck={false}\n autocapitalize=\"off\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n />\n <Show when={searchMutation.loading()}>\n <i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\" />\n </Show>\n </label>\n <div\n class=\"k2b-prompt-search__collapse\"\n style={{\n height: shouldShowResults() ? \"var(--k2b-search-body-max)\" : \"0px\",\n opacity: shouldShowResults() ? \"1\" : \"0\",\n }}\n >\n <div class=\"k2b-prompt-search__results\" onWheel={(event) => event.stopPropagation()}>\n <Show when={searchError()}>\n {(message) => (\n <div class=\"k2b-prompt-search__error\" role=\"status\" aria-live=\"polite\">\n {message()}\n </div>\n )}\n </Show>\n <Show\n when={items().length > 0}\n fallback={\n <p role=\"status\" aria-live=\"polite\">\n {emptyStateText()}\n </p>\n }\n >\n <div id={listboxId} class=\"k2b-prompt-search__list\" role=\"listbox\" aria-label={resolveUiMessages().searchResults}>\n <KeyedFor each={items()} by={searchRowIdentity}>\n {(item, index) => (\n <button\n ref={(element) => {\n if (!element) rowRefs.delete(index());\n else rowRefs.set(index(), element);\n }}\n type=\"button\"\n id={optionId(index())}\n role=\"option\"\n aria-selected={activeIndex() === index()}\n data-active={activeIndex() === index() ? \"true\" : undefined}\n data-has-description={item().desc ? \"true\" : undefined}\n onMouseEnter={() => setActiveIndex(index())}\n onClick={() => execute(item())}\n >\n {/* Cloud keeps the preview box mounted once a row declares an image, so a\n failed load swaps in the fallback glyph instead of collapsing the row. */}\n <Show when={item().previewUrl?.startsWith(\"/\") || item().icon}>\n <span class=\"k2b-prompt-search__preview\">\n <Show\n when={item().previewUrl?.startsWith(\"/\") && !failedPreviews[index()]}\n fallback={<i class={item().icon ?? \"ti ti-file\"} aria-hidden=\"true\" />}\n >\n <img src={item().previewUrl} alt=\"\" onError={() => setFailedPreviews(index(), true)} />\n </Show>\n </span>\n </Show>\n <span class=\"k2b-prompt-search__copy\">\n <strong>{item().label}</strong>\n <Show when={item().desc}>{(description) => <small>{description()}</small>}</Show>\n </span>\n </button>\n )}\n </KeyedFor>\n </div>\n </Show>\n </div>\n </div>\n </div>\n </div>\n );\n },\n {\n panelClassName: \"k2b-dialog k2b-dialog--search is-bare\",\n contentClassName: \"k2b-dialog__viewport is-search\",\n initialFocus: \"first-input\",\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().search,\n },\n );\n\nconst promptText = (content: string, defaultValue?: string, options?: DialogOptions) =>\n prompts\n .form({\n ...options,\n fields: {\n message: { type: \"info\", content: () => <div class=\"k2b-prompt-copy\">{content}</div> },\n value: {\n type: \"text\",\n label: false,\n default: defaultValue || \"\",\n },\n },\n })\n .then((result) => result?.value ?? null);\n\nconst promptNumber = (\n content: string,\n defaultValue?: number,\n options?: DialogOptions & {\n min?: number;\n max?: number;\n },\n) =>\n prompts\n .form({\n ...options,\n fields: {\n message: { type: \"info\", content: () => <div class=\"k2b-prompt-copy\">{content}</div> },\n value: {\n type: \"number\",\n label: false,\n default: defaultValue || 0,\n min: options?.min,\n max: options?.max,\n },\n },\n })\n .then((result) => result?.value ?? null);\n\nexport const prompts = {\n alert: (content: PromptContent, options?: DialogOptions): Promise<void | undefined> =>\n dialogCore.open<void>(\n (close) => (\n <div class=\"k2b-dialog__panel\">\n <DialogHeader title={options?.title || resolveUiMessages().info} icon={options?.icon} close={() => close()} />\n <div class=\"k2b-dialog__body\">{content}</div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" data-variant={options?.variant ?? \"primary\"} onClick={() => close()}>\n {options?.confirmText || resolveUiMessages().ok}\n </button>\n </footer>\n </div>\n ),\n {\n panelClassName: panelClass(options),\n contentClassName: contentClass(options?.surface),\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().info,\n },\n ),\n\n success: (content: PromptContent, options?: Omit<DialogOptions, \"variant\">): Promise<void | undefined> =>\n prompts.alert(content, {\n ...options,\n variant: \"success\",\n title: options?.title ?? resolveUiMessages().success,\n icon: options?.icon ?? \"ti ti-check\",\n }),\n\n confirm: (content: PromptContent, options?: ConfirmOptions): Promise<boolean | undefined> => {\n const confirmationPhrase = options?.confirmationPhrase;\n if (confirmationPhrase !== undefined && (confirmationPhrase.trim().length === 0 || /[\\r\\n\\t]/.test(confirmationPhrase))) {\n throw new Error(\"confirmationPhrase must be non-empty, visible, and single-line\");\n }\n let confirmationInput: HTMLInputElement | undefined;\n\n return dialogCore.open<boolean>(\n (close) => {\n if (!confirmationPhrase) {\n return (\n <div class=\"k2b-dialog__panel\">\n <DialogHeader title={options?.title} icon={options?.icon} close={() => close(false)} />\n <div class=\"k2b-dialog__body\">{content}</div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" onClick={() => close(false)}>\n {options?.cancelText || resolveUiMessages().cancel}\n </button>\n <button type=\"button\" class=\"k2b-button\" data-variant={options?.variant ?? \"primary\"} onClick={() => close(true)}>\n {options?.confirmText || resolvePromptMessages().confirm}\n </button>\n </footer>\n </div>\n );\n }\n\n // The catalog owns word order; the slot marks where the verbatim phrase is rendered as code.\n const [labelBefore, labelAfter] = resolvePromptMessages().typeToConfirm({ phrase: PHRASE_SLOT }).split(PHRASE_SLOT);\n const [confirmationValue, setConfirmationValue] = createSignal(\"\");\n const canConfirm = () => confirmationValue() === confirmationPhrase;\n const submit = (event: SubmitEvent) => {\n event.preventDefault();\n if (canConfirm()) close(true);\n };\n\n return (\n <form class=\"k2b-dialog__panel\" onSubmit={submit}>\n <DialogHeader title={options?.title} icon={options?.icon} close={() => close(false)} />\n <div class=\"k2b-dialog__body k2b-prompt-form\">\n <div class=\"k2b-prompt-copy\">{content}</div>\n <TextInput\n ref={(element) => {\n confirmationInput = element;\n }}\n label={\n <>\n {labelBefore}\n <code class=\"k2b-confirmation-phrase\">{confirmationPhrase}</code>\n {labelAfter}\n </>\n }\n value={confirmationValue}\n onValueChange={setConfirmationValue}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck={false}\n monospace\n required\n />\n </div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" onClick={() => close(false)}>\n {options?.cancelText || resolveUiMessages().cancel}\n </button>\n <button type=\"submit\" class=\"k2b-button\" data-variant={options?.variant ?? \"primary\"} disabled={!canConfirm()}>\n {options?.confirmText || resolvePromptMessages().confirm}\n </button>\n </footer>\n </form>\n );\n },\n {\n panelClassName: panelClass(options),\n contentClassName: contentClass(options?.surface),\n initialFocus: confirmationPhrase ? () => confirmationInput ?? null : undefined,\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolvePromptMessages().confirmation,\n },\n );\n },\n\n prompt: promptText,\n promptNumber,\n\n form: async <T extends Record<string, FieldSchema>>(config: PromptFormOptions<T>): Promise<InferFormValues<T> | null> =>\n (await dialogCore.open<InferFormValues<T> | null>((close) => <PromptFormDialog config={config} close={(value) => close(value)} />, {\n panelClassName: panelClass(config),\n contentClassName: contentClass(),\n signal: config.signal,\n cancelBehavior: config.cancelBehavior,\n ariaLabel: config.ariaLabel ?? config.title ?? resolvePromptMessages().form,\n })) ?? null,\n\n /**\n * Open custom content with a typed close callback and the dialog render context.\n * Register a dismiss handler to guard Escape, backdrop clicks and the supplied header's close button,\n * for example while saving. Explicit close(result) bypasses the guard. Without a handler, dismissal\n * keeps its existing behavior, including a header close button independent of cancelBehavior.\n */\n dialog: <T extends unknown = unknown>(component: DialogRender<T>, options?: DialogOptions): Promise<T | undefined> =>\n dialogCore.open<T>(\n (close, context) => {\n // A dismiss handler the component sets guards the header's close button as well as Escape and the backdrop.\n let dismiss = () => close(undefined);\n const body = component(close, {\n ...context,\n setDismissHandler: (handler) => {\n context.setDismissHandler(handler);\n dismiss = () => void context.requestDismiss();\n },\n });\n if (options?.surface === \"bare\" && options.header === false) return body;\n return (\n <div class=\"k2b-dialog__panel k2b-dialog__stack\">\n <Show when={options?.header !== false}>\n <DialogHeader title={options?.title} icon={options?.icon} close={() => dismiss()} />\n </Show>\n <div class=\"k2b-dialog__content\">{body}</div>\n </div>\n );\n },\n {\n panelClassName: panelClass(options),\n contentClassName: contentClass(options?.surface),\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().dialog,\n },\n ),\n\n search: openSearchPrompt,\n\n error: (content: string | HTMLElement, options?: DialogOptions) =>\n dialogCore.open(\n (close) => (\n <div class=\"k2b-dialog__panel\">\n <DialogHeader title={options?.title ?? resolveUiMessages().error} icon={options?.icon ?? \"ti ti-alert-circle\"} close={close} />\n <div class=\"k2b-dialog__body\">{content}</div>\n <footer class=\"k2b-dialog__actions\">\n <button type=\"button\" class=\"k2b-button\" onClick={() => close()}>\n {options?.confirmText || resolveUiMessages().close}\n </button>\n </footer>\n </div>\n ),\n {\n panelClassName: panelClass({ ...options, variant: \"danger\" }),\n contentClassName: contentClass(options?.surface),\n signal: options?.signal,\n cancelBehavior: options?.cancelBehavior,\n history: options?.history,\n ariaLabel: options?.ariaLabel ?? options?.title ?? resolveUiMessages().error,\n },\n ),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,EAAE,KAAK,QAAQ,mBAAmB;AACnD,SAAS,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,SAAS,EAAE,IAAI,QAAQ,UAAU;AACjH,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,QAAQ,QAAQ,oBAAoB;AAC7C,SAAS,QAAQ,QAAQ,wBAAwB;AACjD,SAAS,UAAU,EAAE,cAAc,QAAQ,sBAAsB;AACjE,SAAS,UAAU,QAAQ,sBAAsB;AACjD,SAAS,WAAW,QAAQ,uBAAuB;AACnD,SAAS,MAAM,QAAQ,kBAAkB;AACzC,SAAS,qBAAqB,QAAQ,2BAA2B;AACjE,SAAS,SAAS,QAAQ,qBAAqB;AAC/C,SAAS,SAAS,QAAQ,qBAAqB;AAC/C,SAAS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IAAI,IAAI,oBAAoB;IAAA;IAAE,KAAK,EAAE;EAAK,cAC5F,OAAO,YAGjC,OAAO,EAAE,WAAW,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,EAIzD,EACD;IACE,cAAc,EAAE,UAAU,CAAC;MAAE,GAAG,OAAO;MAAE,OAAO,EAAE;IAAS,CAAC,CAAC;IAC7D,gBAAgB,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,MAAM,EAAE,OAAO,EAAE,MAAM;IACvB,cAAc,EAAE,OAAO,EAAE,cAAc;IACvC,OAAO,EAAE,OAAO,EAAE,OAAO;IACzB,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,KAAK,IAAI,iBAAiB,CAAC,CAAC,CAAC;EACzE,CACF;AACJ,CAAC","ignoreList":[]}
@@ -17,7 +17,7 @@ var _tmpl$ = "<i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\"></i>",
17
17
  _tmpl$9 = ["<i", " aria-hidden=\"true\"></i>"],
18
18
  _tmpl$0 = ["<small>", "</small>"],
19
19
  _tmpl$1 = ["<div class=\"k2b-choice-footer\">", "</div>"];
20
- import { createEffect, createSignal, For, on, Show } from "solid-js";
20
+ import { createEffect, createMemo, createSignal, For, on, Show } from "solid-js";
21
21
  import { createFieldMeta, Field, fieldControlAria } from "../internal/field";
22
22
  import { useUiMessages } from "../intl/messages";
23
23
  import { createChoiceLoader, createChoicePopover, nextEnabledChoiceIndex } from "./choice";
@@ -51,6 +51,7 @@ export function Combobox(props) {
51
51
  const popover = createChoicePopover(() => Boolean(props.disabled || props.readOnly));
52
52
  // A host notice or an error replaces the results; hidden results are never selectable.
53
53
  const options = () => props.status || loader.error() ? [] : loader.options();
54
+ const optionsById = createMemo(() => new Map(options().map(option => [option.value, option])));
54
55
  const focusedOption = () => options()[focusedIndex()];
55
56
  const searchable = value => value.trim().length >= (props.minQueryLength ?? 0);
56
57
  const focus = index => {
@@ -194,7 +195,7 @@ export function Combobox(props) {
194
195
  children: message => _$ssr(_tmpl$5, _$escape(message()), _$escape(messages().retry))
195
196
  })), _$escape(_$createComponent(For, {
196
197
  get each() {
197
- return options();
198
+ return options().map(option => option.value);
198
199
  },
199
200
  get fallback() {
200
201
  return _$createComponent(Show, {
@@ -219,17 +220,21 @@ export function Combobox(props) {
219
220
  }
220
221
  });
221
222
  },
222
- children: (option, index) => _$ssr(_tmpl$8, `${_$escape(listboxId, true)}-${_$escape(index(), true)}`, _$ssrAttribute("aria-selected", _$escape(index(), true) === _$escape(focusedIndex(), true), false) + _$ssrAttribute("data-focused", index() === focusedIndex() ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
223
- get when() {
224
- return option.icon;
225
- },
226
- children: icon => _$ssr(_tmpl$9, _$ssrAttribute("class", _$escape(iconClass(icon()), true), false))
227
- })), _$escape(option.label), _$escape(_$createComponent(Show, {
228
- get when() {
229
- return option.description;
230
- },
231
- children: description => _$ssr(_tmpl$0, _$escape(description()))
232
- })))
223
+ children: (id, index) => {
224
+ const first = optionsById().get(id);
225
+ const option = () => optionsById().get(id) ?? first;
226
+ return _$ssr(_tmpl$8, `${_$escape(listboxId, true)}-${_$escape(index(), true)}`, _$ssrAttribute("aria-selected", _$escape(index(), true) === _$escape(focusedIndex(), true), false) + _$ssrAttribute("data-focused", index() === focusedIndex() ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
227
+ get when() {
228
+ return option().icon;
229
+ },
230
+ children: icon => _$ssr(_tmpl$9, _$ssrAttribute("class", _$escape(iconClass(icon()), true), false))
231
+ })), _$escape(option().label), _$escape(_$createComponent(Show, {
232
+ get when() {
233
+ return option().description;
234
+ },
235
+ children: description => _$ssr(_tmpl$0, _$escape(description()))
236
+ })));
237
+ }
233
238
  })), _$escape(_$createComponent(Show, {
234
239
  get when() {
235
240
  return props.footer;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["inputs/Combobox.tsx"],"sourcesContent":["import { createEffect, createSignal, For, type JSX, on, Show } from \"solid-js\";\nimport { createFieldMeta, Field, fieldControlAria } from \"../internal/field\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { type ChoiceOption, createChoiceLoader, createChoicePopover, nextEnabledChoiceIndex } from \"./choice\";\nimport type { FieldProps, MaybeAccessor } from \"./field-contract\";\nimport { resolveMaybeAccessor } from \"./field-contract\";\nimport { useSelectMessages } from \"./select-messages\";\n\nexport type ComboboxOption = { id: string; label: string; description?: string; icon?: string };\nexport type ComboboxProps = FieldProps & {\n readOnly?: boolean;\n query?: MaybeAccessor<string>;\n onQueryChange?: (query: string) => void;\n placeholder?: string;\n fetchData: (query: string, signal: AbortSignal) => Promise<ComboboxOption[]>;\n onSelect: (option: ComboboxOption) => void;\n debounceMs?: number;\n /** The query is the field's own value: picking or closing keeps the typed text, and Enter without an active option only closes the list. */\n freeText?: boolean;\n /** Below this many characters nothing loads and the list stays closed. */\n minQueryLength?: number;\n /** This result (by position) is active as soon as results arrive, so Enter takes it. */\n autoHighlight?: number;\n /** Replaces the results with a host-owned notice, such as an exhausted quota; nothing loads while it is set. */\n status?: JSX.Element;\n /** Shown instead of the default text when a search finds nothing. */\n empty?: JSX.Element;\n /** One line under the results, such as their source. */\n footer?: JSX.Element;\n};\n\nconst iconClass = (icon: string) => (icon.split(/\\s+/).includes(\"ti\") ? icon : `ti ${icon}`);\n\nexport function Combobox(props: ComboboxProps): JSX.Element {\n const messages = useUiMessages();\n const selectMessages = useSelectMessages();\n const meta = createFieldMeta(props.id);\n const listboxId = `${meta.controlId}-listbox`;\n const [localQuery, setLocalQuery] = createSignal(\"\");\n const query = () => resolveMaybeAccessor(props.query) ?? localQuery();\n const setQuery = (value: string) => {\n setLocalQuery(value);\n props.onQueryChange?.(value);\n };\n const error = () => resolveMaybeAccessor(props.error);\n const [focusedIndex, setFocusedIndex] = createSignal(-1);\n let inputRef: HTMLInputElement | undefined;\n let optionRefs: HTMLButtonElement[] = [];\n const loader = createChoiceLoader(\n () => async (value, signal) => (await props.fetchData(value, signal)).map((option) => ({ ...option, value: option.id })),\n // Cloud debounces at 200ms and then pads the response with a 200ms minimum\n // load time to stop the spinner flickering. The spinner here sits in the\n // chevron slot and stale results stay visible, so there is nothing to pad —\n // 150ms keeps typing responsive without hammering the loader.\n () => props.debounceMs ?? 150,\n );\n const popover = createChoicePopover(() => Boolean(props.disabled || props.readOnly));\n // A host notice or an error replaces the results; hidden results are never selectable.\n const options = () => (props.status || loader.error() ? [] : loader.options());\n const focusedOption = () => options()[focusedIndex()];\n const searchable = (value: string) => value.trim().length >= (props.minQueryLength ?? 0);\n const focus = (index: number) => {\n setFocusedIndex(index);\n optionRefs[index]?.scrollIntoView({ block: \"nearest\" });\n };\n /** `eager` loads the currently controlled query on open; typing supplies its\n * own query, so opening from `onInput` skips the duplicate request. */\n const open = (eager = true) => {\n if (props.disabled || props.readOnly || popover.open() || !searchable(query())) return;\n popover.show();\n if (eager && !props.status) loader.load(query(), true);\n focus(-1);\n };\n const reset = () => {\n loader.cancel();\n setQuery(\"\");\n focus(-1);\n };\n const close = () => {\n popover.hide();\n if (!props.freeText) return reset();\n loader.cancel();\n focus(-1);\n };\n createEffect(\n on(options, (list) => {\n const index = props.autoHighlight;\n if (index !== undefined && focusedIndex() < 0 && popover.open() && list.length > 0) setFocusedIndex(Math.min(index, list.length - 1));\n }),\n );\n createEffect(() => {\n if (props.readOnly) {\n popover.hide();\n loader.cancel();\n setFocusedIndex(-1);\n }\n });\n const select = (option: ChoiceOption<string>) => {\n if (props.disabled || props.readOnly) return;\n popover.hide();\n props.onSelect({ id: option.value, label: option.label, description: option.description, icon: option.icon });\n if (props.freeText) {\n loader.cancel();\n focus(-1);\n } else reset();\n inputRef?.focus();\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (props.disabled || props.readOnly) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n if (!popover.open()) open();\n else focus(nextEnabledChoiceIndex(options(), focusedIndex(), event.key === \"ArrowDown\" ? 1 : -1));\n } else if (event.key === \"Enter\" && popover.open()) {\n // While the results are open, Enter belongs to them: it never submits an enclosing form, even with no option active.\n event.preventDefault();\n const option = options()[focusedIndex()];\n if (option) select(option);\n else if (props.freeText) close();\n } else if ((event.key === \"Escape\" || event.key === \"Tab\") && popover.open()) {\n // Escape is only ours while the list is open; otherwise it has to reach an\n // enclosing dialog or drawer.\n if (event.key === \"Escape\") event.preventDefault();\n close();\n }\n };\n\n return (\n <Field\n class={props.class}\n label={props.label}\n description={props.description}\n error={error()}\n meta={meta}\n required={props.required}\n disabled={props.disabled}\n >\n <div class=\"k2b-combobox\" data-invalid={error() ? \"true\" : undefined}>\n <div ref={popover.setTrigger} class=\"k2b-combobox__input\">\n <i class=\"ti ti-search\" aria-hidden=\"true\" />\n {/* A click, typing, or an arrow key opens the list. Focus alone (Tab, a dialog's initial focus) does not, so Escape still closes the enclosing dialog. */}\n <input\n ref={(element) => {\n inputRef = element;\n }}\n id={meta.controlId}\n type=\"text\"\n value={query()}\n placeholder={props.placeholder ?? messages().search}\n disabled={props.disabled}\n readOnly={props.readOnly}\n aria-readonly={props.readOnly ? \"true\" : undefined}\n role=\"combobox\"\n autocomplete=\"off\"\n aria-autocomplete=\"list\"\n aria-expanded={popover.open()}\n aria-controls={listboxId}\n aria-activedescendant={focusedOption() ? `${listboxId}-${focusedIndex()}` : undefined}\n {...fieldControlAria(meta, props)}\n onClick={() => open()}\n onInput={(event) => {\n if (props.disabled || props.readOnly) {\n event.currentTarget.value = query();\n return;\n }\n const value = event.currentTarget.value;\n setQuery(value);\n focus(-1);\n if (!searchable(value)) {\n popover.hide();\n loader.cancel();\n return;\n }\n open(false);\n if (!props.status) loader.load(value);\n }}\n onKeyDown={onKeyDown}\n />\n <Show when={loader.loading()} fallback={<i class=\"ti ti-chevron-down\" aria-hidden=\"true\" />}>\n <i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\" />\n </Show>\n </div>\n <div ref={popover.setPopover} popover=\"manual\" class=\"k2b-choice-popover\">\n <div class=\"k2b-choice-options\" role=\"listbox\" id={listboxId}>\n <Show when={props.status}>{(status) => <div class=\"k2b-choice-status\">{status()}</div>}</Show>\n <Show when={!props.status && loader.error()}>\n {(message) => (\n <div class=\"k2b-choice-status\" data-tone=\"danger\">\n <span>{message()}</span>\n <button type=\"button\" onClick={loader.retry}>\n {messages().retry}\n </button>\n </div>\n )}\n </Show>\n <For\n each={options()}\n fallback={\n <Show when={!props.status && !loader.error()}>\n <Show\n when={loader.loading()}\n fallback={\n <div class=\"k2b-choice-status\">\n {query().length >= 2 ? (props.empty ?? selectMessages().noResultsFound) : selectMessages().typeToSearch}\n </div>\n }\n >\n {/* The first search has nothing to keep visible yet: rows of the final size wait in its place. */}\n <div class=\"k2b-choice-loading\" role=\"status\">\n <span class=\"k2b-sr-only\">{messages().loading}</span>\n <For each={[62, 48, 55]}>\n {(width) => (\n <div class=\"k2b-choice-loading__row\" aria-hidden=\"true\">\n <span class=\"k2b-skeleton\" />\n <span class=\"k2b-skeleton\" style={{ width: `${width}%` }} />\n </div>\n )}\n </For>\n </div>\n </Show>\n </Show>\n }\n >\n {(option, index) => (\n <button\n ref={(element) => (optionRefs[index()] = element)}\n type=\"button\"\n id={`${listboxId}-${index()}`}\n class=\"k2b-choice-option\"\n role=\"option\"\n aria-selected={index() === focusedIndex()}\n data-focused={index() === focusedIndex() ? \"true\" : undefined}\n onPointerMove={() => focus(index())}\n onPointerDown={(event) => event.preventDefault()}\n onClick={() => select(option)}\n >\n <Show when={option.icon}>{(icon) => <i class={iconClass(icon())} aria-hidden=\"true\" />}</Show>\n <span>\n <strong>{option.label}</strong>\n <Show when={option.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n </button>\n )}\n </For>\n </div>\n <Show when={props.footer}>{(footer) => <div class=\"k2b-choice-footer\">{footer()}</div>}</Show>\n </div>\n </div>\n </Field>\n );\n}\n\nexport default Combobox;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,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AK,YAAY,CAAC,CAAC,GAAG,MAAM,YAAG,SAAS,4CAK5D,IAAI;UAAA,IAAC,IAAI;YAAA,OAAE,MAAM,CAAC,IAAI;UAAA;UAAA,UAAI,IAAI,oDAAe,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAAuB,cAE3E,MAAM,CAAC,KAAK,8BACpB,IAAI;UAAA,IAAC,IAAI;YAAA,OAAE,MAAM,CAAC,WAAW;UAAA;UAAA,UAAI,WAAW,4BAAa,WAAW,CAAC,CAAC;QAAS;MAGrF,gCAGJ,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,MAAM;QAAA;QAAA,UAAI,MAAM,4BAAqC,MAAM,CAAC,CAAC;MAAO;IAAA;EAAA;AAKhG;AAEA,eAAe,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["inputs/Combobox.tsx"],"sourcesContent":["import { createEffect, createMemo, createSignal, For, type JSX, on, Show } from \"solid-js\";\nimport { createFieldMeta, Field, fieldControlAria } from \"../internal/field\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { type ChoiceOption, createChoiceLoader, createChoicePopover, nextEnabledChoiceIndex } from \"./choice\";\nimport type { FieldProps, MaybeAccessor } from \"./field-contract\";\nimport { resolveMaybeAccessor } from \"./field-contract\";\nimport { useSelectMessages } from \"./select-messages\";\n\nexport type ComboboxOption = { id: string; label: string; description?: string; icon?: string };\nexport type ComboboxProps = FieldProps & {\n readOnly?: boolean;\n query?: MaybeAccessor<string>;\n onQueryChange?: (query: string) => void;\n placeholder?: string;\n fetchData: (query: string, signal: AbortSignal) => Promise<ComboboxOption[]>;\n onSelect: (option: ComboboxOption) => void;\n debounceMs?: number;\n /** The query is the field's own value: picking or closing keeps the typed text, and Enter without an active option only closes the list. */\n freeText?: boolean;\n /** Below this many characters nothing loads and the list stays closed. */\n minQueryLength?: number;\n /** This result (by position) is active as soon as results arrive, so Enter takes it. */\n autoHighlight?: number;\n /** Replaces the results with a host-owned notice, such as an exhausted quota; nothing loads while it is set. */\n status?: JSX.Element;\n /** Shown instead of the default text when a search finds nothing. */\n empty?: JSX.Element;\n /** One line under the results, such as their source. */\n footer?: JSX.Element;\n};\n\nconst iconClass = (icon: string) => (icon.split(/\\s+/).includes(\"ti\") ? icon : `ti ${icon}`);\n\nexport function Combobox(props: ComboboxProps): JSX.Element {\n const messages = useUiMessages();\n const selectMessages = useSelectMessages();\n const meta = createFieldMeta(props.id);\n const listboxId = `${meta.controlId}-listbox`;\n const [localQuery, setLocalQuery] = createSignal(\"\");\n const query = () => resolveMaybeAccessor(props.query) ?? localQuery();\n const setQuery = (value: string) => {\n setLocalQuery(value);\n props.onQueryChange?.(value);\n };\n const error = () => resolveMaybeAccessor(props.error);\n const [focusedIndex, setFocusedIndex] = createSignal(-1);\n let inputRef: HTMLInputElement | undefined;\n let optionRefs: HTMLButtonElement[] = [];\n const loader = createChoiceLoader(\n () => async (value, signal) => (await props.fetchData(value, signal)).map((option) => ({ ...option, value: option.id })),\n // Cloud debounces at 200ms and then pads the response with a 200ms minimum\n // load time to stop the spinner flickering. The spinner here sits in the\n // chevron slot and stale results stay visible, so there is nothing to pad —\n // 150ms keeps typing responsive without hammering the loader.\n () => props.debounceMs ?? 150,\n );\n const popover = createChoicePopover(() => Boolean(props.disabled || props.readOnly));\n // A host notice or an error replaces the results; hidden results are never selectable.\n const options = () => (props.status || loader.error() ? [] : loader.options());\n const optionsById = createMemo(() => new Map(options().map((option) => [option.value, option])));\n const focusedOption = () => options()[focusedIndex()];\n const searchable = (value: string) => value.trim().length >= (props.minQueryLength ?? 0);\n const focus = (index: number) => {\n setFocusedIndex(index);\n optionRefs[index]?.scrollIntoView({ block: \"nearest\" });\n };\n /** `eager` loads the currently controlled query on open; typing supplies its\n * own query, so opening from `onInput` skips the duplicate request. */\n const open = (eager = true) => {\n if (props.disabled || props.readOnly || popover.open() || !searchable(query())) return;\n popover.show();\n if (eager && !props.status) loader.load(query(), true);\n focus(-1);\n };\n const reset = () => {\n loader.cancel();\n setQuery(\"\");\n focus(-1);\n };\n const close = () => {\n popover.hide();\n if (!props.freeText) return reset();\n loader.cancel();\n focus(-1);\n };\n createEffect(\n on(options, (list) => {\n const index = props.autoHighlight;\n if (index !== undefined && focusedIndex() < 0 && popover.open() && list.length > 0) setFocusedIndex(Math.min(index, list.length - 1));\n }),\n );\n createEffect(() => {\n if (props.readOnly) {\n popover.hide();\n loader.cancel();\n setFocusedIndex(-1);\n }\n });\n const select = (option: ChoiceOption<string>) => {\n if (props.disabled || props.readOnly) return;\n popover.hide();\n props.onSelect({ id: option.value, label: option.label, description: option.description, icon: option.icon });\n if (props.freeText) {\n loader.cancel();\n focus(-1);\n } else reset();\n inputRef?.focus();\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (props.disabled || props.readOnly) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n if (!popover.open()) open();\n else focus(nextEnabledChoiceIndex(options(), focusedIndex(), event.key === \"ArrowDown\" ? 1 : -1));\n } else if (event.key === \"Enter\" && popover.open()) {\n // While the results are open, Enter belongs to them: it never submits an enclosing form, even with no option active.\n event.preventDefault();\n const option = options()[focusedIndex()];\n if (option) select(option);\n else if (props.freeText) close();\n } else if ((event.key === \"Escape\" || event.key === \"Tab\") && popover.open()) {\n // Escape is only ours while the list is open; otherwise it has to reach an\n // enclosing dialog or drawer.\n if (event.key === \"Escape\") event.preventDefault();\n close();\n }\n };\n\n return (\n <Field\n class={props.class}\n label={props.label}\n description={props.description}\n error={error()}\n meta={meta}\n required={props.required}\n disabled={props.disabled}\n >\n <div class=\"k2b-combobox\" data-invalid={error() ? \"true\" : undefined}>\n <div ref={popover.setTrigger} class=\"k2b-combobox__input\">\n <i class=\"ti ti-search\" aria-hidden=\"true\" />\n {/* A click, typing, or an arrow key opens the list. Focus alone (Tab, a dialog's initial focus) does not, so Escape still closes the enclosing dialog. */}\n <input\n ref={(element) => {\n inputRef = element;\n }}\n id={meta.controlId}\n type=\"text\"\n value={query()}\n placeholder={props.placeholder ?? messages().search}\n disabled={props.disabled}\n readOnly={props.readOnly}\n aria-readonly={props.readOnly ? \"true\" : undefined}\n role=\"combobox\"\n autocomplete=\"off\"\n aria-autocomplete=\"list\"\n aria-expanded={popover.open()}\n aria-controls={listboxId}\n aria-activedescendant={focusedOption() ? `${listboxId}-${focusedIndex()}` : undefined}\n {...fieldControlAria(meta, props)}\n onClick={() => open()}\n onInput={(event) => {\n if (props.disabled || props.readOnly) {\n event.currentTarget.value = query();\n return;\n }\n const value = event.currentTarget.value;\n setQuery(value);\n focus(-1);\n if (!searchable(value)) {\n popover.hide();\n loader.cancel();\n return;\n }\n open(false);\n if (!props.status) loader.load(value);\n }}\n onKeyDown={onKeyDown}\n />\n <Show when={loader.loading()} fallback={<i class=\"ti ti-chevron-down\" aria-hidden=\"true\" />}>\n <i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\" />\n </Show>\n </div>\n <div ref={popover.setPopover} popover=\"manual\" class=\"k2b-choice-popover\">\n <div class=\"k2b-choice-options\" role=\"listbox\" id={listboxId}>\n <Show when={props.status}>{(status) => <div class=\"k2b-choice-status\">{status()}</div>}</Show>\n <Show when={!props.status && loader.error()}>\n {(message) => (\n <div class=\"k2b-choice-status\" data-tone=\"danger\">\n <span>{message()}</span>\n <button type=\"button\" onClick={loader.retry}>\n {messages().retry}\n </button>\n </div>\n )}\n </Show>\n {/* Keyed by option ID, not object: each fetch returns new objects, and a row replaced between press and release\n would swallow the click. */}\n <For\n each={options().map((option) => option.value)}\n fallback={\n <Show when={!props.status && !loader.error()}>\n <Show\n when={loader.loading()}\n fallback={\n <div class=\"k2b-choice-status\">\n {query().length >= 2 ? (props.empty ?? selectMessages().noResultsFound) : selectMessages().typeToSearch}\n </div>\n }\n >\n {/* The first search has nothing to keep visible yet: rows of the final size wait in its place. */}\n <div class=\"k2b-choice-loading\" role=\"status\">\n <span class=\"k2b-sr-only\">{messages().loading}</span>\n <For each={[62, 48, 55]}>\n {(width) => (\n <div class=\"k2b-choice-loading__row\" aria-hidden=\"true\">\n <span class=\"k2b-skeleton\" />\n <span class=\"k2b-skeleton\" style={{ width: `${width}%` }} />\n </div>\n )}\n </For>\n </div>\n </Show>\n </Show>\n }\n >\n {(id, index) => {\n const first = optionsById().get(id)!;\n const option = () => optionsById().get(id) ?? first;\n return (\n <button\n ref={(element) => (optionRefs[index()] = element)}\n type=\"button\"\n id={`${listboxId}-${index()}`}\n class=\"k2b-choice-option\"\n role=\"option\"\n aria-selected={index() === focusedIndex()}\n data-focused={index() === focusedIndex() ? \"true\" : undefined}\n onPointerMove={() => focus(index())}\n onPointerDown={(event) => event.preventDefault()}\n onClick={() => select(option())}\n >\n <Show when={option().icon}>{(icon) => <i class={iconClass(icon())} aria-hidden=\"true\" />}</Show>\n <span>\n <strong>{option().label}</strong>\n <Show when={option().description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n </button>\n );\n }}\n </For>\n </div>\n <Show when={props.footer}>{(footer) => <div class=\"k2b-choice-footer\">{footer()}</div>}</Show>\n </div>\n </div>\n </Field>\n );\n}\n\nexport default Combobox;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAY,EAAE,EAAE,IAAI,QAAQ,UAAU;AAC1F,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,QAAQ,mBAAmB;AAC5E,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAA4B,kBAAkB,EAAE,mBAAmB,EAAE,sBAAsB,QAAQ,UAAU;AAE7G,SAAS,oBAAoB,QAAQ,kBAAkB;AACvD,SAAS,iBAAiB,QAAQ,mBAAmB;AAyBrD,MAAM,SAAS,GAAI,IAAY,IAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,IAAI,EAAG;AAE5F,OAAO,SAAS,QAAQ,CAAC,KAAoB,E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OAAE,MAAM,CAAC,CAAC,CAAC,IAAI;YAAA;YAAA,UAAI,IAAI,oDAAe,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;UAAuB,cAE7E,MAAM,CAAC,CAAC,CAAC,KAAK,8BACtB,IAAI;YAAA,IAAC,IAAI;cAAA,OAAE,MAAM,CAAC,CAAC,CAAC,WAAW;YAAA;YAAA,UAAI,WAAW,4BAAa,WAAW,CAAC,CAAC;UAAS;QAI1F;MAAC,gCAGJ,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,MAAM;QAAA;QAAA,UAAI,MAAM,4BAAqC,MAAM,CAAC,CAAC;MAAO;IAAA;EAAA;AAKhG;AAEA,eAAe,QAAQ","ignoreList":[]}
@@ -63,6 +63,7 @@ import { useRichSelectMessages } from "./rich-select-messages";
63
63
  export const RICH_SELECT_SEARCH_FROM = 8;
64
64
  const PHONE_QUERY = "(max-width: 47.999rem)";
65
65
  const PLACEHOLDER_ROWS = 4;
66
+ const rowKey = row => row.kind === "heading" ? `heading:${row.id}` : `item:${row.item.value}`;
66
67
  const isPhone = () => typeof matchMedia === "function" && matchMedia(PHONE_QUERY).matches;
67
68
  function RichSelectVisual(props) {
68
69
  return _$createComponent(Switch, {
@@ -254,6 +255,9 @@ export function RichSelect(props) {
254
255
  });
255
256
  return result;
256
257
  });
258
+ // Rows are keyed by heading and value, not by object: a host that rebuilds equal items must not replace the option
259
+ // under a press, which would swallow its click.
260
+ const rowsByKey = createMemo(() => new Map(rows().map(row => [rowKey(row), row])));
257
261
  const selected = createMemo(() => {
258
262
  const current = value();
259
263
  return current === null ? undefined : props.items.find(item => item.value === current);
@@ -584,44 +588,59 @@ export function RichSelect(props) {
584
588
  get children() {
585
589
  return _$createComponent(For, {
586
590
  get each() {
587
- return rows();
591
+ return rows().map(rowKey);
588
592
  },
589
593
  get fallback() {
590
594
  return _$ssr(_tmpl$25, _$escape(messages().noResults));
591
595
  },
592
- children: row => row.kind === "heading" ? _$ssr(_tmpl$26, _$escape(row.label)) : // biome-ignore lint/a11y/useKeyWithClickEvents: the trigger or search field handles the keys through aria-activedescendant.
593
- _$ssr(_tmpl$27, _$ssrAttribute("id", _$escape(optionId(row.index), true), false), _$ssrAttribute("aria-selected", _$escape(row.item.value, true) === _$escape(value(), true), false) + _$ssrAttribute("aria-disabled", row.item.disabledReason ? "true" : _$escape(undefined, true), false), `${_$escape(optionId(row.index), true)}-label`, _$ssrAttribute("aria-describedby", _$escape([row.item.disabledReason || row.item.description ? `${optionId(row.index)}-line` : "", withPreview() && row.index === active() ? previewId : ""].filter(Boolean).join(" ") || undefined, true), false) + _$ssrAttribute("data-active", row.index === active() ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
594
- get when() {
595
- return anyVisual();
596
- },
597
- get children() {
598
- return _$createComponent(Show, {
596
+ children: key => {
597
+ const first = rowsByKey().get(key);
598
+ if (first.kind === "heading") {
599
+ const label = () => {
600
+ const current = rowsByKey().get(key);
601
+ return current?.kind === "heading" ? current.label : first.label;
602
+ };
603
+ return _$ssr(_tmpl$26, _$escape(label()));
604
+ }
605
+ const entry = () => {
606
+ const current = rowsByKey().get(key);
607
+ return current?.kind === "item" ? current : first;
608
+ };
609
+ return (// biome-ignore lint/a11y/useKeyWithClickEvents: the trigger or search field handles the keys through aria-activedescendant.
610
+ _$ssr(_tmpl$27, _$ssrAttribute("id", _$escape(optionId(entry().index), true), false), _$ssrAttribute("aria-selected", _$escape(entry().item.value, true) === _$escape(value(), true), false) + _$ssrAttribute("aria-disabled", entry().item.disabledReason ? "true" : _$escape(undefined, true), false), `${_$escape(optionId(entry().index), true)}-label`, _$ssrAttribute("aria-describedby", _$escape([entry().item.disabledReason || entry().item.description ? `${optionId(entry().index)}-line` : "", withPreview() && entry().index === active() ? previewId : ""].filter(Boolean).join(" ") || undefined, true), false) + _$ssrAttribute("data-active", entry().index === active() ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
599
611
  get when() {
600
- return hasVisual(row.item);
601
- },
602
- get fallback() {
603
- return _$ssr(_tmpl$28);
612
+ return anyVisual();
604
613
  },
605
614
  get children() {
606
- return _$createComponent(RichSelectVisual, {
607
- get item() {
608
- return row.item;
615
+ return _$createComponent(Show, {
616
+ get when() {
617
+ return hasVisual(entry().item);
618
+ },
619
+ get fallback() {
620
+ return _$ssr(_tmpl$28);
621
+ },
622
+ get children() {
623
+ return _$createComponent(RichSelectVisual, {
624
+ get item() {
625
+ return entry().item;
626
+ }
627
+ });
609
628
  }
610
629
  });
611
630
  }
612
- });
613
- }
614
- })), _$escape(_$createComponent(RichSelectRowText, {
615
- get item() {
616
- return row.item;
617
- },
618
- get labelId() {
619
- return `${optionId(row.index)}-label`;
620
- },
621
- get lineId() {
622
- return `${optionId(row.index)}-line`;
623
- }
624
- })))
631
+ })), _$escape(_$createComponent(RichSelectRowText, {
632
+ get item() {
633
+ return entry().item;
634
+ },
635
+ get labelId() {
636
+ return `${optionId(entry().index)}-label`;
637
+ },
638
+ get lineId() {
639
+ return `${optionId(entry().index)}-line`;
640
+ }
641
+ })))
642
+ );
643
+ }
625
644
  });
626
645
  }
627
646
  })), _$escape(_$createComponent(Show, {