{"_id":"@cartridge-engine/search-bar","_rev":"4-5895757c25ba3d80ebd694f7e943641a","name":"@cartridge-engine/search-bar","dist-tags":{"latest":"3.0.0"},"versions":{"1.0.1":{"name":"@cartridge-engine/search-bar","version":"1.0.1","keywords":["ink","react","tui","cli","terminal"],"author":{"name":"BAIGAO"},"license":"MIT","_id":"@cartridge-engine/search-bar@1.0.1","maintainers":[{"name":"aigao","email":"3416238595@qq.com"}],"homepage":"https://github.com/BAIGAOa/ink-cartridge#readme","bugs":{"url":"https://github.com/BAIGAOa/ink-cartridge/issues"},"dist":{"shasum":"b09f1ca5856583017550cdf258eb44213bd02fb8","tarball":"https://registry.npmjs.org/@cartridge-engine/search-bar/-/search-bar-1.0.1.tgz","fileCount":8,"integrity":"sha512-CRoYS7fy8jm2FBbTwh1FkXyAztIV3KadC41nxGTDIs7tk5x8jFOD+dPIRstkcwGHemTBYcnw3g6cQnD1DPus+Q==","signatures":[{"sig":"MEQCIBzQTVgbdYgJhcyP3PADvVMw3UjO5t8KsSgCCCcnI/6zAiA5fFYuzq6EdLWdTR+RbMcVP07RxM4MHIEWB2AKW8yEfA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9056},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"e03365aa4e613615fb41921353a7ad2c216b4bfb","scripts":{"test":"vitest run","build":"tsc","clean":"rm -rf dist","watch":"tsc --watch","test:watch":"vitest"},"_npmUser":{"name":"aigao","email":"3416238595@qq.com"},"repository":{"url":"git+https://github.com/BAIGAOa/ink-cartridge.git","type":"git"},"_npmVersion":"10.9.8","description":"Text input with focus management","directories":{},"_nodeVersion":"22.23.1","dependencies":{"@cartridge-engine/text-input":"*"},"_hasShrinkwrap":false,"devDependencies":{"ink":"^7.1.1","react":"^19.2.4","vitest":"^4.1.5","typescript":"^5.9.3","@types/node":"^20.19.39","@types/react":"^19.2.14","ink-cartridge":"*","ink-testing-library":"^4.0.0"},"peerDependencies":{"ink":">=5","react":">=18","ink-cartridge":"*"},"_npmOperationalInternal":{"tmp":"tmp/search-bar_1.0.1_1785838765756_0.8730326847784866","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@cartridge-engine/search-bar","version":"1.0.2","keywords":["ink","react","tui","cli","terminal"],"author":{"name":"BAIGAO"},"license":"MIT","_id":"@cartridge-engine/search-bar@1.0.2","maintainers":[{"name":"aigao","email":"3416238595@qq.com"}],"homepage":"https://github.com/BAIGAOa/ink-cartridge#readme","bugs":{"url":"https://github.com/BAIGAOa/ink-cartridge/issues"},"dist":{"shasum":"889526b24dee3cf3b1384b0e24acf175e6661111","tarball":"https://registry.npmjs.org/@cartridge-engine/search-bar/-/search-bar-1.0.2.tgz","fileCount":8,"integrity":"sha512-dGObDh9en/DwdVXNq27psTtts+Ad0ipYgg/G2n7lKC58iIlqAJpqX9IvCSP9X/CkwHegIXBoSXTbWLpKvP1qvg==","signatures":[{"sig":"MEQCIAFyMNMHp1gyumYEdWxjwlrjYGll/OpW0XGek+owekx4AiAzPPJthynyuJjqKWMrWYWYS0E5h8KO9VQIIRbSj6Tiow==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9056},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"ec08d383348c45268edffc22779198282f03ce67","scripts":{"test":"vitest run","build":"tsc","clean":"rm -rf dist","watch":"tsc --watch","test:watch":"vitest"},"_npmUser":{"name":"aigao","email":"3416238595@qq.com"},"repository":{"url":"git+https://github.com/BAIGAOa/ink-cartridge.git","type":"git"},"_npmVersion":"10.9.8","description":"Text input with focus management","directories":{},"_nodeVersion":"22.23.1","dependencies":{"@cartridge-engine/text-input":"*"},"_hasShrinkwrap":false,"devDependencies":{"ink":"^7.1.1","react":"^19.2.4","vitest":"^4.1.5","typescript":"^5.9.3","@types/node":"^20.19.39","@types/react":"^19.2.14","ink-cartridge":"*","ink-testing-library":"^4.0.0"},"peerDependencies":{"ink":">=5","react":">=18","ink-cartridge":"*"},"_npmOperationalInternal":{"tmp":"tmp/search-bar_1.0.2_1786289321152_0.12031979593798248","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@cartridge-engine/search-bar","version":"2.0.0","keywords":["ink","react","tui","cli","terminal"],"author":{"name":"BAIGAO"},"license":"MIT","_id":"@cartridge-engine/search-bar@2.0.0","maintainers":[{"name":"aigao","email":"3416238595@qq.com"}],"homepage":"https://github.com/BAIGAOa/ink-cartridge#readme","bugs":{"url":"https://github.com/BAIGAOa/ink-cartridge/issues"},"dist":{"shasum":"cb659be3c92d08c5f4a16fc0567c5d7ec1c2074d","tarball":"https://registry.npmjs.org/@cartridge-engine/search-bar/-/search-bar-2.0.0.tgz","fileCount":8,"integrity":"sha512-K1+aXMml7oycBnULzagqYRYnOSxyyTzshOs/ZhoA1lEZs3Fl5e30YtkbuuPHjgbBhEAAh7lUvZ5bQ2Q9h+cNbw==","signatures":[{"sig":"MEYCIQD9W7yyqfRFejaEJnzsrkFhwkhKV5rrPyPkQoX9u/Yd/QIhAK5zOslsADDTgMRMVNzNw4cljAZyTa3WSsxJVIBqMUyq","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9056},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"255fde664de85742a58a04a3a817f82731951729","scripts":{"test":"vitest run","build":"tsc","clean":"rm -rf dist","watch":"tsc --watch","test:watch":"vitest"},"_npmUser":{"name":"aigao","email":"3416238595@qq.com"},"repository":{"url":"git+https://github.com/BAIGAOa/ink-cartridge.git","type":"git"},"_npmVersion":"10.9.8","description":"Text input with focus management","directories":{},"_nodeVersion":"22.23.2","dependencies":{"@cartridge-engine/text-input":"*"},"_hasShrinkwrap":false,"devDependencies":{"ink":"^7.1.1","react":"^19.2.4","vitest":"^4.1.5","typescript":"^5.9.3","@types/node":"^20.19.39","@types/react":"^19.2.14","ink-cartridge":"*","ink-testing-library":"^4.0.0"},"peerDependencies":{"ink":">=5","react":">=18","ink-cartridge":"*"},"_npmOperationalInternal":{"tmp":"tmp/search-bar_2.0.0_1787125093535_0.4254467737725034","host":"s3://npm-registry-packages-npm-production"}},"3.0.0":{"name":"@cartridge-engine/search-bar","version":"3.0.0","description":"Text input with focus management","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"repository":{"type":"git","url":"git+https://github.com/BAIGAOa/ink-cartridge.git"},"keywords":["ink","react","tui","cli","terminal"],"author":{"name":"BAIGAO"},"license":"MIT","engines":{"node":">=22"},"peerDependencies":{"ink-cartridge":"*","ink":">=5","react":">=18"},"dependencies":{"@cartridge-engine/text-input":"*"},"devDependencies":{"@types/node":"^20.19.39","@types/react":"^19.2.14","ink":"^7.1.1","ink-cartridge":"*","ink-testing-library":"^4.0.0","react":"^19.2.4","typescript":"^5.9.3","vitest":"^4.1.5"},"scripts":{"build":"tsc","watch":"tsc --watch","clean":"rm -rf dist","test":"vitest run","test:watch":"vitest"},"bugs":{"url":"https://github.com/BAIGAOa/ink-cartridge/issues"},"homepage":"https://github.com/BAIGAOa/ink-cartridge#readme","_id":"@cartridge-engine/search-bar@3.0.0","gitHead":"2ea845b1b6d9fc1d65b12cd21c6e08ba25570893","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-Uma6dPtjz5TjerTZNXsa4cW3kIUcM/NesIDkeMGyRHXP+HrJG+IcPsW0FA8nKpJsAG56dXP2cWZe+O1KQz3f2Q==","shasum":"8eeca9ebacdf558a15fb8f2e27359bb016d1c20a","tarball":"https://registry.npmjs.org/@cartridge-engine/search-bar/-/search-bar-3.0.0.tgz","fileCount":2,"unpackedSize":4312,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHqenb6IVQDsVnbEPg3Z4QNR0AoOlju3Q3YdKl3K33HmAiEA8B+QEynfUw72F/CoJaY4u/pbOmsfHkOWmnIUknftzpU="}]},"_npmUser":{"name":"aigao","email":"3416238595@qq.com"},"directories":{},"maintainers":[{"name":"aigao","email":"3416238595@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/search-bar_3.0.0_1787479898313_0.22524295326441468"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-04T10:19:25.582Z","modified":"2026-08-23T10:11:38.602Z","1.0.1":"2026-08-04T10:19:25.896Z","1.0.2":"2026-08-09T15:28:41.291Z","2.0.0":"2026-08-19T07:38:13.701Z","3.0.0":"2026-08-23T10:11:38.454Z"},"bugs":{"url":"https://github.com/BAIGAOa/ink-cartridge/issues"},"author":{"name":"BAIGAO"},"license":"MIT","homepage":"https://github.com/BAIGAOa/ink-cartridge#readme","keywords":["ink","react","tui","cli","terminal"],"repository":{"type":"git","url":"git+https://github.com/BAIGAOa/ink-cartridge.git"},"description":"Text input with focus management","maintainers":[{"name":"aigao","email":"3416238595@qq.com"}],"readme":"# SearchBar\n\nA search bar that filters items as you type and delegates result selection to a pluggable `selectBar` component.\n\n## Type Parameters\n\n| Param | Constraint | Default | Description |\n|-------|-----------|---------|-------------|\n| `T` | — | — | The value type of each search item. |\n| `I` | `SearchBarItem<T>` | `SearchBarItem<T>` | The item type (must have `label`, `value`, and optional `Key`). |\n\n## SearchBarItem\\<T\\>\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `label` | `string` | yes | Display text matched against the query. |\n| `value` | `T` | yes | Value returned to `onSubmit` on selection. |\n| `Key` | `string` | no | Stable key for React reconciliation. |\n\n## Props\n\n| Prop | Type | Required | Default | Description |\n|------|------|----------|---------|-------------|\n| `focusId` | `string` | yes | — | Focus identifier for the TextInput. A second focus (`${focusId}-results`) is created for the selectBar. |\n| `items` | `I[]` | no | `[]` | Items to search. Filtered and sorted by label as the user types. |\n| `onSubmit` | `(item: I) => void` | no | — | Called when the user confirms a selection in the selectBar. |\n| `selectBar` | `React.ComponentType<{ items: I[]; onSelect: (item: I) => void; focusId: string; query: string }>` | yes | — | Pluggable component that renders and manages the results list. |\n| `width` | `number` | no | `columns - 4` | Width of the input area in characters. |\n\n### selectBar component props\n\nThe `selectBar` component receives these props:\n\n| Prop | Type | Description |\n|------|------|-------------|\n| `items` | `I[]` | Filtered and sorted items matching the current query. |\n| `onSelect` | `(item: I) => void` | Call to confirm a selection. SearchBar wraps this to fire `onSubmit` and return focus to the input. |\n| `focusId` | `string` | Focus identifier (`${focusId}-results`) for the selectBar's keyboard bindings. |\n| `query` | `string` | Current search query string. |\n\n## Filtering & Sorting\n\nItems are filtered by case-insensitive substring match against `label`. Matches are sorted by priority:\n\n1. Exact match\n2. Prefix match (starts with query)\n3. Earlier substring position\n\n## Keyboard\n\n| Context | Key | Action |\n|---------|-----|--------|\n| TextInput | All TextInput keys | Edit search query normally. |\n| TextInput | `Enter` | Move focus to the selectBar results list. |\n| selectBar | Component-defined | Navigate and confirm selection. |\n| After selection | — | `onSubmit` fires, focus returns to TextInput. |\n\n## Best Practice\n\n```tsx\nimport { SearchBar, SelectInput } from 'ink-cartridge';\n\ninterface MyItem extends SearchBarItem<string> {\n  detail: string;\n}\n\nconst items: MyItem[] = [\n  { label: 'Alice', value: 'alice', detail: 'Engineer' },\n  { label: 'Bob', value: 'bob', detail: 'Designer' },\n];\n\n<SearchBar<string, MyItem>\n  focusId=\"user-search\"\n  items={items}\n  onSubmit={(item) => console.log('Selected:', item)}\n  selectBar={SelectInput}\n/>\n```\n","readmeFilename":"README.md"}