@spunto/design-system 0.9.0 → 0.9.1
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.
package/package.json
CHANGED
|
@@ -14,9 +14,14 @@ import { tagColor } from "./tag-color"
|
|
|
14
14
|
|
|
15
15
|
export interface TagChipsProps {
|
|
16
16
|
tags: string[]
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Both callbacks receive the tag *and* the resulting list. Persist `next` —
|
|
19
|
+
* recomputing it caller-side from a polled `worker.tags` silently drops any
|
|
20
|
+
* edit made since the last refetch (two tags added in a row, then one removed,
|
|
21
|
+
* and the second one disappears with it).
|
|
22
|
+
*/
|
|
23
|
+
onAdd?: (tag: string, next: string[]) => void
|
|
24
|
+
onRemove?: (tag: string, next: string[]) => void
|
|
20
25
|
/** Longest accepted tag; anything past it is truncated on commit. */
|
|
21
26
|
maxLength?: number
|
|
22
27
|
className?: string
|
|
@@ -43,16 +48,18 @@ export function TagChips({ tags, onAdd, onRemove, maxLength = 32, className }: T
|
|
|
43
48
|
// them here keeps "one chip = one word" true without an error message.
|
|
44
49
|
const raw = input.trim().replace(/,/g, "").slice(0, maxLength)
|
|
45
50
|
if (raw && !local.includes(raw)) {
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
const next = [...local, raw]
|
|
52
|
+
setLocal(next)
|
|
53
|
+
onAdd?.(raw, next)
|
|
48
54
|
}
|
|
49
55
|
setInput("")
|
|
50
56
|
setAdding(false)
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
function remove(tag: string) {
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
const next = local.filter((t) => t !== tag)
|
|
61
|
+
setLocal(next)
|
|
62
|
+
onRemove?.(tag, next)
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
const shown = editable ? local : tags
|
|
@@ -47,9 +47,13 @@ export interface WorkerCardProps {
|
|
|
47
47
|
/** Chip → URL (e.g. code-server at that folder). Returning undefined renders a static chip. */
|
|
48
48
|
repoHref?: (repo: GitRepoStatus) => string | undefined
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Tags are read-only unless at least one of these is given. Both receive the
|
|
52
|
+
* tag *and* the resulting list — persist the list, don't recompute it from a
|
|
53
|
+
* polled `worker.tags` (see `TagChips`).
|
|
54
|
+
*/
|
|
55
|
+
onAddTag?: (tag: string, next: string[]) => void
|
|
56
|
+
onRemoveTag?: (tag: string, next: string[]) => void
|
|
53
57
|
|
|
54
58
|
/** Project's current config version — a worker below it gets the "Rebuild" banner. */
|
|
55
59
|
currentProjectVersion?: number
|