@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
- export { default as CamelRouteCode } from './CamelRouteCode'
3
- export type { ProjectItem, ContentItem } from './CamelRouteCode'
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.length > 0 ? value : [""])
21
+ const [items, setItems] = useState<string[]>(value.filter(v => v !== ""))
22
+ const [inputValue, setInputValue] = useState("")
22
23
 
23
24
  useEffect(() => {
24
- if (value && value.length > 0 && JSON.stringify(value) !== JSON.stringify(items)) {
25
- setItems(value)
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 handleChange = (index: number, newValue: string) => {
30
- const newItems = [...items]
31
- newItems[index] = newValue
31
+ const handleRemove = (index: number) => {
32
+ const newItems = items.filter((_, i) => i !== index)
32
33
  setItems(newItems)
33
- onChange?.(newItems.filter(item => item !== ""))
34
+ onChange?.(newItems)
34
35
  }
35
36
 
36
37
  const handleAdd = () => {
37
- const newItems = [...items, ""]
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 handleRemove = (index: number) => {
42
- const newItems = items.filter((_, i) => i !== index)
43
- setItems(newItems.length > 0 ? newItems : [""])
44
- onChange?.(newItems.filter(item => item !== ""))
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
- <Input
52
- value={item}
53
- onChange={(e) => handleChange(index, e.target.value)}
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
- placeholder={placeholder}
56
- className="rounded-none flex-1"
57
- />
58
- {items.length > 1 && (
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
- <Button
72
- type="button"
73
- variant="secondary"
74
- onClick={handleAdd}
75
- disabled={disabled}
76
- className="rounded-none"
77
- >
78
- <Plus className="h-4 w-4 mr-2" />
79
- Add Item
80
- </Button>
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.1.38",
3
+ "version": "1.1.39",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",