@orsetra/shared-ui 1.1.38 → 1.1.39
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Extended UI Components for Dynamic Forms
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// CamelRouteCode removed - causes SSR issues with Monaco Editor
|
|
3
|
+
// Use local implementation in project-manager instead
|
|
4
4
|
export { default as CPUNumber } from './CPUNumber'
|
|
5
5
|
export { default as ClassStorageSelect } from './ClassStorageSelect'
|
|
6
6
|
export { default as ClusterSelect } from './ClusterSelect'
|
|
@@ -18,66 +18,77 @@ export function StringsInput({
|
|
|
18
18
|
disabled = false,
|
|
19
19
|
placeholder = "Enter value",
|
|
20
20
|
}: StringsInputProps) {
|
|
21
|
-
const [items, setItems] = useState<string[]>(value.
|
|
21
|
+
const [items, setItems] = useState<string[]>(value.filter(v => v !== ""))
|
|
22
|
+
const [inputValue, setInputValue] = useState("")
|
|
22
23
|
|
|
23
24
|
useEffect(() => {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const filtered = value.filter(v => v !== "")
|
|
26
|
+
if (JSON.stringify(filtered) !== JSON.stringify(items)) {
|
|
27
|
+
setItems(filtered)
|
|
26
28
|
}
|
|
27
29
|
}, [value])
|
|
28
30
|
|
|
29
|
-
const
|
|
30
|
-
const newItems =
|
|
31
|
-
newItems[index] = newValue
|
|
31
|
+
const handleRemove = (index: number) => {
|
|
32
|
+
const newItems = items.filter((_, i) => i !== index)
|
|
32
33
|
setItems(newItems)
|
|
33
|
-
onChange?.(newItems
|
|
34
|
+
onChange?.(newItems)
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const handleAdd = () => {
|
|
37
|
-
const
|
|
38
|
+
const trimmed = inputValue.trim()
|
|
39
|
+
if (!trimmed) return
|
|
40
|
+
const newItems = [...items, trimmed]
|
|
38
41
|
setItems(newItems)
|
|
42
|
+
onChange?.(newItems)
|
|
43
|
+
setInputValue("")
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
47
|
+
if (e.key === "Enter") {
|
|
48
|
+
e.preventDefault()
|
|
49
|
+
handleAdd()
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
return (
|
|
48
54
|
<div className="space-y-2">
|
|
49
55
|
{items.map((item, index) => (
|
|
50
|
-
<div key={index} className="flex gap-2">
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
<div key={index} className="flex items-center gap-2">
|
|
57
|
+
<span className="flex-1 text-sm px-3 py-2 border border-ibm-gray-20 bg-ibm-gray-10 text-ibm-gray-100 truncate">
|
|
58
|
+
{item}
|
|
59
|
+
</span>
|
|
60
|
+
<Button
|
|
61
|
+
type="button"
|
|
62
|
+
variant="secondary"
|
|
63
|
+
onClick={() => handleRemove(index)}
|
|
54
64
|
disabled={disabled}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<Button
|
|
60
|
-
type="button"
|
|
61
|
-
variant="secondary"
|
|
62
|
-
onClick={() => handleRemove(index)}
|
|
63
|
-
disabled={disabled}
|
|
64
|
-
className="rounded-none h-9 w-9 p-0"
|
|
65
|
-
>
|
|
66
|
-
<X className="h-4 w-4" />
|
|
67
|
-
</Button>
|
|
68
|
-
)}
|
|
65
|
+
className="rounded-none h-9 w-9 p-0 shrink-0"
|
|
66
|
+
>
|
|
67
|
+
<X className="h-4 w-4" />
|
|
68
|
+
</Button>
|
|
69
69
|
</div>
|
|
70
70
|
))}
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
<div className="flex gap-2">
|
|
72
|
+
<Input
|
|
73
|
+
value={inputValue}
|
|
74
|
+
onChange={(e) => setInputValue(e.target.value)}
|
|
75
|
+
onKeyDown={handleKeyDown}
|
|
76
|
+
disabled={disabled}
|
|
77
|
+
placeholder={placeholder}
|
|
78
|
+
className="rounded-none flex-1"
|
|
79
|
+
/>
|
|
80
|
+
<Button
|
|
81
|
+
type="button"
|
|
82
|
+
variant="secondary"
|
|
83
|
+
leftIcon={<Plus className="h-4 w-4 mr-1" />}
|
|
84
|
+
onClick={handleAdd}
|
|
85
|
+
disabled={disabled || !inputValue.trim()}
|
|
86
|
+
className="rounded-none shrink-0"
|
|
87
|
+
>
|
|
88
|
+
|
|
89
|
+
Add
|
|
90
|
+
</Button>
|
|
91
|
+
</div>
|
|
81
92
|
</div>
|
|
82
93
|
)
|
|
83
94
|
}
|