diff --git a/packages/webui/components/field-renderer.tsx b/packages/webui/components/field-renderer.tsx index 698a4650..5fd540ce 100644 --- a/packages/webui/components/field-renderer.tsx +++ b/packages/webui/components/field-renderer.tsx @@ -12,6 +12,7 @@ import UserField from './fields/user-field' import UserMultiField from './fields/user-multi-field' interface FieldRendererProps { + fieldId?: string config: FieldInfo['config'] value: unknown onSave?: (value: unknown) => void diff --git a/packages/webui/components/fields/field-types.ts b/packages/webui/components/fields/field-types.ts index 9d55b36b..772e46fc 100644 --- a/packages/webui/components/fields/field-types.ts +++ b/packages/webui/components/fields/field-types.ts @@ -7,4 +7,5 @@ export interface FieldProps { config: FieldConfig onSave: (value: T) => void readOnly?: boolean + fieldId?: string } diff --git a/packages/webui/components/fields/long-text-field.test.tsx b/packages/webui/components/fields/long-text-field.test.tsx new file mode 100644 index 00000000..400a5bad --- /dev/null +++ b/packages/webui/components/fields/long-text-field.test.tsx @@ -0,0 +1,42 @@ +// @vitest-environment happy-dom +import { cleanup, fireEvent, render, screen } from '@testing-library/react' +import React from 'react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import LongTextField from './long-text-field' + +describe('LongTextField Component', () => { + afterEach(() => { + cleanup() + vi.clearAllMocks() + }) + + const dummyConfig = { + name: 'Description', + type: 'longText' as const, + } + + it('renders collapsed placeholder with fixed 2-row height and whitespace-pre-wrap', () => { + render() + const collapsed = screen.getByTitle('Click to expand') + expect(collapsed).toBeTruthy() + expect(collapsed.className).toContain('h-[48px]') + expect(collapsed.className).toContain('line-clamp-2') + expect(collapsed.className).toContain('whitespace-pre-wrap') + }) + + it('renders Empty state inside 2-row container when value is empty', () => { + render() + const collapsed = screen.getByTitle('Click to expand') + expect(collapsed.className).toContain('h-[48px]') + expect(screen.getByText('Empty')).toBeTruthy() + }) + + it('expands on click to show full content overlay', () => { + render() + const collapsed = screen.getByTitle('Click to expand') + fireEvent.click(collapsed) + + const elements = screen.getAllByText(/Line 1/) + expect(elements.length).toBe(2) + }) +}) diff --git a/packages/webui/components/fields/long-text-field.tsx b/packages/webui/components/fields/long-text-field.tsx index 5cff9ae1..0d161073 100644 --- a/packages/webui/components/fields/long-text-field.tsx +++ b/packages/webui/components/fields/long-text-field.tsx @@ -73,7 +73,7 @@ const LongTextField: React.FC> = ({ value, onSave, readOnly } {/* Placeholder */}
({ + client: { + api: { + fields: { + ':fieldId': { + $put: vi.fn(), + }, + }, + }, + }, +})) + +vi.mock('@/ui/stores/fields', () => ({ + useFieldStore: { + getState: () => ({ + fields: [], + updateFields: vi.fn(), + }), + }, +})) + +describe('SelectField Component', () => { + afterEach(() => { + cleanup() + vi.clearAllMocks() + }) + + const sampleConfig = { + name: 'Status', + type: 'select' as const, + select: { + options: [ + { id: 'foo', displayName: 'Foo', color: '#ff0000' }, + { id: 'bar', displayName: 'Bar', color: '#00ff00' }, + { id: 'abc', displayName: 'abc', color: '#0000ff' }, + ], + }, + } + + it('renders selected option badge correctly', () => { + render() + expect(screen.getByText('Foo')).toBeTruthy() + }) + + it('filters options based on search query', () => { + render() + + // Click trigger to open popover + const trigger = screen.getByText('Select an option') + fireEvent.click(trigger) + + // Search box should be visible + const searchInput = screen.getByPlaceholderText('Search options...') + expect(searchInput).toBeTruthy() + + // Type "bc" -> should only show "abc" and "Add options: bc" + fireEvent.change(searchInput, { target: { value: 'bc' } }) + expect(screen.getByText('abc')).toBeTruthy() + expect(screen.queryByText('Foo')).toBeNull() + expect(screen.queryByText('Bar')).toBeNull() + + // Add option action should be present for "bc" + expect(screen.getByText('Add options: bc')).toBeTruthy() + }) + + it('hides add option button when user input matches an option exactly', () => { + render() + + const trigger = screen.getByText('Select an option') + fireEvent.click(trigger) + + const searchInput = screen.getByPlaceholderText('Search options...') + + // Type "abc" -> exact match with option "abc" + fireEvent.change(searchInput, { target: { value: 'abc' } }) + expect(screen.getByText('abc')).toBeTruthy() + // "Add options: abc" button should be hidden + expect(screen.queryByText('Add options: abc')).toBeNull() + }) +}) diff --git a/packages/webui/components/fields/select-field.tsx b/packages/webui/components/fields/select-field.tsx index 347329a9..6fdbb963 100644 --- a/packages/webui/components/fields/select-field.tsx +++ b/packages/webui/components/fields/select-field.tsx @@ -1,15 +1,35 @@ -import type { SelectOption } from '@shumai/dtos' -import { ChevronDown, X } from 'lucide-react' +import type { FieldInfo, SelectOption } from '@shumai/dtos' +import { ChevronDown, Plus, Search, X } from 'lucide-react' import React, { useState } from 'react' +import { toast } from 'sonner' import type { FieldProps } from './field-types' +import { client } from '@/ui/api/client' import { Popover, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover' -import { getOptionStyle } from '../fields-manager' +import { m } from '@/ui/paraglide/messages.js' +import { useFieldStore } from '@/ui/stores/fields' +import { getOptionStyle, getRandomUnusedColor } from '../fields-manager' -const SelectField: React.FC> = ({ value, config, onSave, readOnly }) => { +const SelectField: React.FC> = ({ + value, + config, + onSave, + readOnly, + fieldId, +}) => { const selectConfig = config?.select + const options: SelectOption[] = selectConfig?.options || [] const [isEditing, setIsEditing] = useState(false) + const [searchQuery, setSearchQuery] = useState('') - const selectedOption = selectConfig?.options?.find((opt: SelectOption) => opt.id === value) + const selectedOption = options.find((opt: SelectOption) => opt.id === value) + + const trimmedSearch = searchQuery.trim() + const filteredOptions = options.filter((opt: SelectOption) => + opt.displayName.toLowerCase().includes(trimmedSearch.toLowerCase()), + ) + const hasExactMatch = options.some( + (opt: SelectOption) => opt.displayName.trim().toLowerCase() === trimmedSearch.toLowerCase(), + ) const handleStartEdit = () => { if (!readOnly) { @@ -20,11 +40,60 @@ const SelectField: React.FC> = ({ value, config, onSave, read const handleSelect = (optionId: string) => { onSave(optionId) setIsEditing(false) + setSearchQuery('') } const handleOpenChange = (open: boolean) => { if (readOnly) return setIsEditing(open) + if (!open) { + setSearchQuery('') + } + } + + const handleAddOption = async () => { + if (!trimmedSearch) return + const newOption: SelectOption = { + id: trimmedSearch.toLowerCase().replace(/\s+/g, '-'), + displayName: trimmedSearch, + color: getRandomUnusedColor(options), + } + const newOptions = [...options, newOption] + const updatedConfig = { + ...config, + select: { + ...selectConfig, + options: newOptions, + }, + } + + if (fieldId) { + try { + const res = await client.api.fields[':fieldId'].$put({ + param: { fieldId }, + json: { config: updatedConfig }, + }) + if (!res.ok) { + toast.error(m.failed_update_field()) + return + } + const updatedField = (await res.json()) as FieldInfo + const currentFields = useFieldStore.getState().fields + const newFields = currentFields.map((f) => + f.id === updatedField.id + ? { ...f, ...(updatedField as FieldInfo), visible: f.visible } + : f, + ) + useFieldStore.getState().updateFields(newFields) + } catch { + toast.error(m.failed_update_field()) + return + } + } + + onSave(newOption.id) + setSearchQuery('') + setIsEditing(false) } const renderOptionBadge = (option: SelectOption | undefined) => { @@ -57,29 +126,69 @@ const SelectField: React.FC> = ({ value, config, onSave, read
handleSelect('')} - className="px-3 py-2 text-sm text-muted-foreground hover:bg-accent cursor-pointer flex items-center gap-2" + className="relative pb-1.5 border-b border-border mb-1" + onClick={(e) => e.stopPropagation()} > - Clear + + setSearchQuery(e.target.value)} + autoFocus + />
- {selectConfig?.options?.map((option: SelectOption) => ( -
handleSelect(option.id)} - className="px-3 py-2 hover:bg-accent cursor-pointer flex items-center" - > - + {searchQuery === '' && ( +
handleSelect('')} + className="px-2.5 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded cursor-pointer flex items-center gap-2" > - {option.displayName} - -
- ))} + Clear +
+ )} + + {filteredOptions.map((option: SelectOption) => ( +
handleSelect(option.id)} + className={`px-2.5 py-1.5 text-xs hover:bg-accent rounded cursor-pointer flex items-center justify-between ${ + value === option.id ? 'bg-accent/50 font-medium' : '' + }`} + > + + {option.displayName} + +
+ ))} + + {filteredOptions.length === 0 && !trimmedSearch && ( +
+ {m.no_options_found()} +
+ )} + + {trimmedSearch !== '' && !hasExactMatch && ( +
+ + {m.add_option_with_name({ name: trimmedSearch })} +
+ )} +
diff --git a/packages/webui/components/fields/select-multi-field.test.tsx b/packages/webui/components/fields/select-multi-field.test.tsx new file mode 100644 index 00000000..0c6be46f --- /dev/null +++ b/packages/webui/components/fields/select-multi-field.test.tsx @@ -0,0 +1,83 @@ +// @vitest-environment happy-dom +import { cleanup, fireEvent, render, screen } from '@testing-library/react' +import React from 'react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import SelectMultiField from './select-multi-field' + +// Mock client and stores +vi.mock('@/ui/api/client', () => ({ + client: { + api: { + fields: { + ':fieldId': { + $put: vi.fn(), + }, + }, + }, + }, +})) + +vi.mock('@/ui/stores/fields', () => ({ + useFieldStore: { + getState: () => ({ + fields: [], + updateFields: vi.fn(), + }), + }, +})) + +describe('SelectMultiField Component', () => { + afterEach(() => { + cleanup() + vi.clearAllMocks() + }) + + const sampleConfig = { + name: 'Tags', + type: 'selectMulti' as const, + selectMulti: { + options: [ + { id: 'foo', displayName: 'Foo', color: '#ff0000' }, + { id: 'bar', displayName: 'Bar', color: '#00ff00' }, + { id: 'abc', displayName: 'abc', color: '#0000ff' }, + ], + }, + } + + it('renders Empty placeholder when no values selected', () => { + render() + expect(screen.getByText('Empty')).toBeTruthy() + }) + + it('filters options based on search query in MultiSelect', () => { + render() + + // Click trigger to open popover + const trigger = screen.getByText('Empty') + fireEvent.click(trigger) + + const searchInput = screen.getByPlaceholderText('Search options...') + expect(searchInput).toBeTruthy() + + // Type "bc" -> should show "abc" and "Add options: bc" + fireEvent.change(searchInput, { target: { value: 'bc' } }) + expect(screen.getByText('abc')).toBeTruthy() + expect(screen.queryByText('Foo')).toBeNull() + + expect(screen.getByText('Add options: bc')).toBeTruthy() + }) + + it('hides add option button when exact match exists in MultiSelect', () => { + render() + + const trigger = screen.getByText('Empty') + fireEvent.click(trigger) + + const searchInput = screen.getByPlaceholderText('Search options...') + + // Type "abc" -> exact match + fireEvent.change(searchInput, { target: { value: 'abc' } }) + expect(screen.getByText('abc')).toBeTruthy() + expect(screen.queryByText('Add options: abc')).toBeNull() + }) +}) diff --git a/packages/webui/components/fields/select-multi-field.tsx b/packages/webui/components/fields/select-multi-field.tsx index e3b297de..61d585b0 100644 --- a/packages/webui/components/fields/select-multi-field.tsx +++ b/packages/webui/components/fields/select-multi-field.tsx @@ -1,30 +1,43 @@ -import { Check } from 'lucide-react' +import type { FieldInfo, SelectOption } from '@shumai/dtos' +import { Check, Plus, Search } from 'lucide-react' import React, { useLayoutEffect, useRef, useState } from 'react' +import { toast } from 'sonner' import type { FieldProps } from './field-types' -import type { SelectOption } from '@shumai/dtos' +import { client } from '@/ui/api/client' import { Popover, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover' -import { getOptionStyle } from '../fields-manager' +import { m } from '@/ui/paraglide/messages.js' +import { useFieldStore } from '@/ui/stores/fields' +import { getOptionStyle, getRandomUnusedColor } from '../fields-manager' const SelectMultiField: React.FC> = ({ value = [], config, onSave, readOnly, + fieldId, }) => { const selectConfig = config?.selectMulti + const options: SelectOption[] = selectConfig?.options || [] const containerRef = useRef(null) const [isEditing, setIsEditing] = useState(false) const [expanded, setExpanded] = useState(false) const [visibleCount, setVisibleCount] = useState(value.length) + const [searchQuery, setSearchQuery] = useState('') const selectedOptions = - selectConfig?.options?.filter((opt: SelectOption) => (value || []).includes(opt.id)) || [] + options.filter((opt: SelectOption) => (value || []).includes(opt.id)) || [] + + const trimmedSearch = searchQuery.trim() + const filteredOptions = options.filter((opt: SelectOption) => + opt.displayName.toLowerCase().includes(trimmedSearch.toLowerCase()), + ) + const hasExactMatch = options.some( + (opt: SelectOption) => opt.displayName.trim().toLowerCase() === trimmedSearch.toLowerCase(), + ) // Dynamic calculation for how many items fit in one line useLayoutEffect(() => { if (isEditing || expanded) { - // When editing or expanded, we technically don't use visibleCount for rendering - // (we render all), but keeping state clean is good. setVisibleCount(selectedOptions.length) return } @@ -39,12 +52,11 @@ const SelectMultiField: React.FC> = ({ let currentWidth = 0 let count = 0 const moreBadgeWidth = 28 - // We use a small buffer to be safe const maxAvailableWidth = containerWidth - moreBadgeWidth for (let i = 0; i < selectedOptions.length; i++) { const textWidth = context.measureText(selectedOptions[i].displayName).width - const badgeWidth = textWidth + 16 + 4 // 16px padding, 4px gap + const badgeWidth = textWidth + 16 + 4 if (currentWidth + badgeWidth > maxAvailableWidth && i < selectedOptions.length - 1) { break @@ -75,16 +87,58 @@ const SelectMultiField: React.FC> = ({ onSave(newVal) } + const handleAddOption = async () => { + if (!trimmedSearch) return + const newOption: SelectOption = { + id: trimmedSearch.toLowerCase().replace(/\s+/g, '-'), + displayName: trimmedSearch, + color: getRandomUnusedColor(options), + } + const newOptions = [...options, newOption] + const updatedConfig = { + ...config, + selectMulti: { + ...selectConfig, + options: newOptions, + }, + } + + if (fieldId) { + try { + const res = await client.api.fields[':fieldId'].$put({ + param: { fieldId }, + json: { config: updatedConfig }, + }) + if (!res.ok) { + toast.error(m.failed_update_field()) + return + } + const updatedField = (await res.json()) as FieldInfo + const currentFields = useFieldStore.getState().fields + const newFields = currentFields.map((f) => + f.id === updatedField.id + ? { ...f, ...(updatedField as FieldInfo), visible: f.visible } + : f, + ) + useFieldStore.getState().updateFields(newFields) + } catch { + toast.error(m.failed_update_field()) + return + } + } + + onSave([...(value || []), newOption.id]) + setSearchQuery('') + } + const handlePlaceholderClick = (e: React.MouseEvent) => { e.stopPropagation() if (isEditing) return - // "if there is hidden items, first click will expand" const hiddenCount = selectedOptions.length - visibleCount if (!expanded && hiddenCount > 0) { setExpanded(true) } else { - // "if there is no hidden items, will change to edit mode" if (!readOnly) { setIsEditing(true) } @@ -93,7 +147,6 @@ const SelectMultiField: React.FC> = ({ const handleOverlayClick = (e: React.MouseEvent) => { e.stopPropagation() - // "second click (on expanded) will change to edit mode" if (!readOnly) { setIsEditing(true) } @@ -107,6 +160,7 @@ const SelectMultiField: React.FC> = ({ if (!open) { setExpanded(false) setIsEditing(false) + setSearchQuery('') } } @@ -148,12 +202,14 @@ const SelectMultiField: React.FC> = ({ {expanded && !isEditing ? ( @@ -172,24 +228,63 @@ const SelectMultiField: React.FC> = ({ ))} ) : ( - selectConfig?.options?.map((option: SelectOption) => { - const isSelected = (value || []).includes(option.id) - return ( -
toggleOption(option.id)} - className="px-3 py-2 hover:bg-accent cursor-pointer flex items-center justify-between" - > - +
e.stopPropagation()} + > + + setSearchQuery(e.target.value)} + autoFocus + /> +
+ +
+ {filteredOptions.map((option: SelectOption) => { + const isSelected = (value || []).includes(option.id) + return ( +
toggleOption(option.id)} + className={`px-2.5 py-1.5 hover:bg-accent rounded cursor-pointer flex items-center justify-between text-xs ${ + isSelected ? 'bg-accent/30 font-medium' : '' + }`} + > + + {option.displayName} + + {isSelected && } +
+ ) + })} + + {filteredOptions.length === 0 && !trimmedSearch && ( +
+ {m.no_options_found()} +
+ )} + + {trimmedSearch !== '' && !hasExactMatch && ( +
- {option.displayName} - - {isSelected && } -
- ) - }) + + + {m.add_option_with_name({ name: trimmedSearch })} + +
+ )} +
+ )}
diff --git a/packages/webui/components/file-browser/file-card.tsx b/packages/webui/components/file-browser/file-card.tsx index 187ab91c..64d4cd02 100644 --- a/packages/webui/components/file-browser/file-card.tsx +++ b/packages/webui/components/file-browser/file-card.tsx @@ -419,6 +419,7 @@ export function FileCard({
onSaveField(field.id!, val) : undefined} diff --git a/packages/webui/components/file-browser/file-list-item.tsx b/packages/webui/components/file-browser/file-list-item.tsx index 1193c39f..bddedf5c 100644 --- a/packages/webui/components/file-browser/file-list-item.tsx +++ b/packages/webui/components/file-browser/file-list-item.tsx @@ -303,6 +303,7 @@ export function FileListItem({ }} > onSaveField(field.id!, val) : undefined} diff --git a/packages/webui/components/file-viewer-right-sidebar.tsx b/packages/webui/components/file-viewer-right-sidebar.tsx index ceb58e04..88eb9399 100644 --- a/packages/webui/components/file-viewer-right-sidebar.tsx +++ b/packages/webui/components/file-viewer-right-sidebar.tsx @@ -449,6 +449,7 @@ export function FileViewerRightSidebar({
onSaveField(field.id!, val) : undefined} diff --git a/packages/webui/messages/en.json b/packages/webui/messages/en.json index a761d1c0..45276328 100644 --- a/packages/webui/messages/en.json +++ b/packages/webui/messages/en.json @@ -731,6 +731,9 @@ "visible_count": "({count} visible)", "option_name_placeholder": "Option name", "unknown_field_type": "Unknown Field Type", + "search_options_placeholder": "Search options...", + "add_option_with_name": "Add options: {name}", + "no_options_found": "No options found", "settings_updated": "Settings updated", "failed_update_settings": "Failed to update settings", diff --git a/packages/webui/messages/zh.json b/packages/webui/messages/zh.json index 072f6954..8138b71e 100644 --- a/packages/webui/messages/zh.json +++ b/packages/webui/messages/zh.json @@ -731,6 +731,9 @@ "visible_count": "({count} 个可见)", "option_name_placeholder": "选项名称", "unknown_field_type": "未知字段类型", + "search_options_placeholder": "搜索选项...", + "add_option_with_name": "添加选项:{name}", + "no_options_found": "未找到选项", "settings_updated": "设置已更新", "failed_update_settings": "更新设置失败", diff --git a/packages/webui/paraglide/messages/_index.d.ts b/packages/webui/paraglide/messages/_index.d.ts index 32ca8b8f..a87850a3 100644 --- a/packages/webui/paraglide/messages/_index.d.ts +++ b/packages/webui/paraglide/messages/_index.d.ts @@ -692,6 +692,9 @@ export * from "./search_fields_placeholder.js"; export * from "./visible_count.js"; export * from "./option_name_placeholder.js"; export * from "./unknown_field_type.js"; +export * from "./search_options_placeholder.js"; +export * from "./add_option_with_name.js"; +export * from "./no_options_found.js"; export * from "./settings_updated.js"; export * from "./failed_update_settings.js"; export * from "./unknown_user.js"; diff --git a/packages/webui/paraglide/messages/_index.js b/packages/webui/paraglide/messages/_index.js index 45c89723..958bd82d 100644 --- a/packages/webui/paraglide/messages/_index.js +++ b/packages/webui/paraglide/messages/_index.js @@ -694,6 +694,9 @@ export * from './search_fields_placeholder.js' export * from './visible_count.js' export * from './option_name_placeholder.js' export * from './unknown_field_type.js' +export * from './search_options_placeholder.js' +export * from './add_option_with_name.js' +export * from './no_options_found.js' export * from './settings_updated.js' export * from './failed_update_settings.js' export * from './unknown_user.js' diff --git a/packages/webui/paraglide/messages/add_option_with_name.d.ts b/packages/webui/paraglide/messages/add_option_with_name.d.ts new file mode 100644 index 00000000..64b4d811 --- /dev/null +++ b/packages/webui/paraglide/messages/add_option_with_name.d.ts @@ -0,0 +1,18 @@ +/** +* | output | +* | --- | +* | "Add options: {name}" | +* +* @param {Add_Option_With_NameInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const add_option_with_name: ((inputs: Add_Option_With_NameInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Add_Option_With_NameInputs = { + name: NonNullable; +}; diff --git a/packages/webui/paraglide/messages/add_option_with_name.js b/packages/webui/paraglide/messages/add_option_with_name.js new file mode 100644 index 00000000..6b4c20b2 --- /dev/null +++ b/packages/webui/paraglide/messages/add_option_with_name.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{ name: NonNullable }} Add_Option_With_NameInputs */ + +const en_add_option_with_name = /** @type {(inputs: Add_Option_With_NameInputs) => LocalizedString} */ (i) => { + return /** @type {LocalizedString} */ (`Add options: ${i?.name}`) +}; + +const zh_add_option_with_name = /** @type {(inputs: Add_Option_With_NameInputs) => LocalizedString} */ (i) => { + return /** @type {LocalizedString} */ (`添加选项:${i?.name}`) +}; + +/** +* | output | +* | --- | +* | "Add options: {name}" | +* +* @param {Add_Option_With_NameInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const add_option_with_name = /** @type {((inputs: Add_Option_With_NameInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_add_option_with_name(inputs) + return zh_add_option_with_name(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/no_options_found.d.ts b/packages/webui/paraglide/messages/no_options_found.d.ts new file mode 100644 index 00000000..9c0d133e --- /dev/null +++ b/packages/webui/paraglide/messages/no_options_found.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "No options found" | +* +* @param {No_Options_FoundInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const no_options_found: ((inputs?: No_Options_FoundInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type No_Options_FoundInputs = {}; diff --git a/packages/webui/paraglide/messages/no_options_found.js b/packages/webui/paraglide/messages/no_options_found.js new file mode 100644 index 00000000..6ebb3d7c --- /dev/null +++ b/packages/webui/paraglide/messages/no_options_found.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} No_Options_FoundInputs */ + +const en_no_options_found = /** @type {(inputs: No_Options_FoundInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`No options found`) +}; + +const zh_no_options_found = /** @type {(inputs: No_Options_FoundInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`未找到选项`) +}; + +/** +* | output | +* | --- | +* | "No options found" | +* +* @param {No_Options_FoundInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const no_options_found = /** @type {((inputs?: No_Options_FoundInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_no_options_found(inputs) + return zh_no_options_found(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/search_options_placeholder.d.ts b/packages/webui/paraglide/messages/search_options_placeholder.d.ts new file mode 100644 index 00000000..b29972da --- /dev/null +++ b/packages/webui/paraglide/messages/search_options_placeholder.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Search options..." | +* +* @param {Search_Options_PlaceholderInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const search_options_placeholder: ((inputs?: Search_Options_PlaceholderInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Search_Options_PlaceholderInputs = {}; diff --git a/packages/webui/paraglide/messages/search_options_placeholder.js b/packages/webui/paraglide/messages/search_options_placeholder.js new file mode 100644 index 00000000..eb55b67c --- /dev/null +++ b/packages/webui/paraglide/messages/search_options_placeholder.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Search_Options_PlaceholderInputs */ + +const en_search_options_placeholder = /** @type {(inputs: Search_Options_PlaceholderInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Search options...`) +}; + +const zh_search_options_placeholder = /** @type {(inputs: Search_Options_PlaceholderInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`搜索选项...`) +}; + +/** +* | output | +* | --- | +* | "Search options..." | +* +* @param {Search_Options_PlaceholderInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const search_options_placeholder = /** @type {((inputs?: Search_Options_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_search_options_placeholder(inputs) + return zh_search_options_placeholder(inputs) +}); \ No newline at end of file