MCPcopy Create free account
hub / github.com/Snaacky/theindex / ArrayValue

Function ArrayValue

components/data/ArrayValue.tsx:12–57  ·  view source on GitHub ↗
({ data, column, onChange })

Source from the content-addressed store, hash-verified

10}
11
12const ArrayValue: FC<Props> = ({ data, column, onChange }) => {
13 if (column.type !== ColumnType.array) {
14 console.error('Called ArrayValue but column type is', column.type)
15 return
16 }
17
18 if (typeof onChange === 'undefined') {
19 return (
20 <>
21 {data.map((v) => (
22 <Link
23 href={'/column/' + column.urlId + '?v=' + v}
24 key={v}
25 className={'me-2'}
26 data-tooltip-content={column.name + ': ' + v}
27 >
28 <DataBadge name={v} />
29 </Link>
30 ))}
31 </>
32 )
33 }
34
35 return (
36 <>
37 {column.values.map((v) => {
38 return (
39 <button
40 data-tooltip-content={v}
41 className={'me-2'}
42 key={v}
43 onClick={() => {
44 if (data.includes(v)) {
45 onChange(data.filter((d) => d !== v))
46 } else {
47 onChange(data.concat([v]))
48 }
49 }}
50 >
51 <DataBadge data={data.includes(v) ? true : undefined} name={v} />
52 </button>
53 )
54 })}
55 </>
56 )
57}
58
59export default ArrayValue

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected