Skip to content

Commit 89c243d

Browse files
durvesh1992cixzhang
authored andcommitted
docs(cli): make Typeahead/Tokenizer/FileInput showcases interactive
Completes the frozen-showcase fixes (after #3199, #3200). These rendered controlled components with a static value + no-op onChange. Wire local state: Typeahead useState<SearchableItem|null>, Tokenizer useState<SearchableItem[]>, FileInput useState<File|File[]|null>. Typeahead also gains 'use client'.
1 parent bdc7bd7 commit 89c243d

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@astryxdesign/cli': patch
3+
---
4+
5+
[docs] Wire local state into the Typeahead, Tokenizer, and FileInput showcase examples (static value + no-op onChange → frozen previews). Completes the interactive-showcase fixes started for Slider/Selector/MultiSelector (#3187-#3189) and the input/tab batch
6+
@durvesh1992

packages/cli/templates/blocks/components/FileInput/FileInputShowcase.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {FileInput} from '@astryxdesign/core/FileInput';
67

78
export default function FileInputShowcase() {
9+
const [value, setValue] = useState<File | File[] | null>(null);
810
return (
911
<div style={{width: 350}}>
1012
<FileInput
1113
label="Upload file"
12-
value={null}
13-
onChange={() => {}}
14+
value={value}
15+
onChange={setValue}
1416
placeholder="Drag files here or click to browse"
1517
/>
1618
</div>

packages/cli/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {Tokenizer} from '@astryxdesign/core/Tokenizer';
6-
import type {SearchSource} from '@astryxdesign/core/Typeahead';
7+
import type {SearchableItem, SearchSource} from '@astryxdesign/core/Typeahead';
78

89
const source: SearchSource = {
910
search: () => [],
1011
bootstrap: () => [],
1112
};
1213

1314
export default function TokenizerShowcase() {
15+
const [value, setValue] = useState<SearchableItem[]>([
16+
{id: '1', label: 'Design'},
17+
{id: '2', label: 'Engineering'},
18+
]);
1419
return (
1520
<Tokenizer
1621
label="Tags"
1722
placeholder="Search..."
1823
searchSource={source}
19-
value={[
20-
{id: '1', label: 'Design'},
21-
{id: '2', label: 'Engineering'},
22-
]}
23-
onChange={() => {}}
24+
value={value}
25+
onChange={setValue}
2426
style={{width: 400}}
2527
/>
2628
);

packages/cli/templates/blocks/components/Typeahead/TypeaheadShowcase.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Copyright (c) Meta Platforms, Inc. and affiliates.
22

3+
'use client';
4+
5+
import {useState} from 'react';
36
import {Typeahead} from '@astryxdesign/core/Typeahead';
47
import type {SearchableItem, SearchSource} from '@astryxdesign/core/Typeahead';
58

@@ -21,14 +24,15 @@ const fruitSource: SearchSource = {
2124
};
2225

2326
export default function TypeaheadShowcase() {
27+
const [value, setValue] = useState<SearchableItem | null>(null);
2428
return (
2529
<div style={{width: 320}}>
2630
<Typeahead
2731
label="Fruit"
2832
placeholder="Search fruits..."
2933
searchSource={fruitSource}
30-
value={null}
31-
onChange={() => {}}
34+
value={value}
35+
onChange={setValue}
3236
/>
3337
</div>
3438
);

0 commit comments

Comments
 (0)