@orsetra/shared-ui 1.1.8 → 1.1.10
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/components/extends/ArrayItemGroup/index.tsx +56 -0
- package/components/extends/CPUNumber/index.tsx +33 -0
- package/components/extends/ClassStorageSelect/index.tsx +11 -0
- package/components/extends/ClusterSelect/index.tsx +11 -0
- package/components/extends/ComponentSelect/index.tsx +112 -0
- package/components/extends/DiskNumber/index.tsx +34 -0
- package/components/extends/EnvSelect/index.tsx +11 -0
- package/components/extends/Group/index.tsx +150 -0
- package/components/extends/Ignore/index.tsx +11 -0
- package/components/extends/ImageInput/index.less +49 -0
- package/components/extends/ImageInput/index.tsx +193 -0
- package/components/extends/ImageSecretSelect/index.tsx +168 -0
- package/components/extends/KV/index.tsx +23 -0
- package/components/extends/MemoryNumber/index.tsx +34 -0
- package/components/extends/Numbers/index.tsx +23 -0
- package/components/extends/PVCSelect/index.tsx +12 -0
- package/components/extends/PolicySelect/index.tsx +53 -0
- package/components/extends/SecretKeySelect/index.tsx +95 -0
- package/components/extends/SecretSelect/index.tsx +76 -0
- package/components/extends/StepSelect/index.tsx +74 -0
- package/components/extends/Strings/index.tsx +23 -0
- package/components/extends/Switch/index.tsx +23 -0
- package/components/extends/index.ts +21 -0
- package/components/ui/combobox.tsx +137 -0
- package/components/ui/index.ts +3 -0
- package/components/ui/kv-input.tsx +117 -0
- package/components/ui/multi-select.tsx +151 -0
- package/components/ui/numbers-input.tsx +87 -0
- package/components/ui/project-selector-modal.tsx +95 -37
- package/components/ui/strings-input.tsx +83 -0
- package/index.ts +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect } from "react"
|
|
4
|
+
import { Input } from "./input"
|
|
5
|
+
import { Button } from "./button"
|
|
6
|
+
import { X, Plus } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
interface StringsInputProps {
|
|
9
|
+
value?: string[]
|
|
10
|
+
onChange?: (value: string[]) => void
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
placeholder?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function StringsInput({
|
|
16
|
+
value = [],
|
|
17
|
+
onChange,
|
|
18
|
+
disabled = false,
|
|
19
|
+
placeholder = "Enter value",
|
|
20
|
+
}: StringsInputProps) {
|
|
21
|
+
const [items, setItems] = useState<string[]>(value.length > 0 ? value : [""])
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (value && value.length > 0 && JSON.stringify(value) !== JSON.stringify(items)) {
|
|
25
|
+
setItems(value)
|
|
26
|
+
}
|
|
27
|
+
}, [value])
|
|
28
|
+
|
|
29
|
+
const handleChange = (index: number, newValue: string) => {
|
|
30
|
+
const newItems = [...items]
|
|
31
|
+
newItems[index] = newValue
|
|
32
|
+
setItems(newItems)
|
|
33
|
+
onChange?.(newItems.filter(item => item !== ""))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const handleAdd = () => {
|
|
37
|
+
const newItems = [...items, ""]
|
|
38
|
+
setItems(newItems)
|
|
39
|
+
}
|
|
40
|
+
|
|
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 !== ""))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="space-y-2">
|
|
49
|
+
{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)}
|
|
54
|
+
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
|
+
)}
|
|
69
|
+
</div>
|
|
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>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
package/index.ts
CHANGED
|
@@ -8,8 +8,20 @@ export { default as HttpClient, useHttpClient, ApiError } from './lib/http-clien
|
|
|
8
8
|
// UI Components
|
|
9
9
|
export * from './components/ui'
|
|
10
10
|
|
|
11
|
+
// Extended Components for Dynamic Forms
|
|
12
|
+
export * from './components/extends'
|
|
13
|
+
|
|
11
14
|
// Layout Components
|
|
12
15
|
export * from './components/layout'
|
|
13
16
|
|
|
14
17
|
// Hooks
|
|
15
18
|
export * from './hooks'
|
|
19
|
+
|
|
20
|
+
// Context
|
|
21
|
+
export * from './context'
|
|
22
|
+
|
|
23
|
+
// Internationalization
|
|
24
|
+
export { default as i18n } from './i18n'
|
|
25
|
+
|
|
26
|
+
// Utilities (additional exports)
|
|
27
|
+
export { locale } from './utils/locale'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orsetra/shared-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "Shared UI components for Orsetra platform",
|
|
5
5
|
"main": "./index.ts",
|
|
6
6
|
"types": "./index.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@hookform/resolvers": "^3.9.1",
|
|
44
|
-
"@orsetra/shared-types": "^1.0.
|
|
44
|
+
"@orsetra/shared-types": "^1.0.4",
|
|
45
45
|
"@radix-ui/react-accordion": "1.2.2",
|
|
46
46
|
"@radix-ui/react-alert-dialog": "1.1.4",
|
|
47
47
|
"@radix-ui/react-aspect-ratio": "1.1.1",
|