1
+ import { nanoid } from "nanoid" ;
1
2
import { useId } from "react" ;
2
3
import { useStore } from "@nanostores/react" ;
3
4
import { InputField } from "@webstudio-is/design-system" ;
@@ -10,22 +11,20 @@ import {
10
11
import {
11
12
type ControlProps ,
12
13
useLocalValue ,
13
- ResponsiveLayout ,
14
- Label ,
15
14
humanizeAttribute ,
15
+ VerticalLayout ,
16
16
} from "../shared" ;
17
17
import { $resources } from "~/shared/nano-states" ;
18
18
import { $selectedInstanceResourceScope } from "../resource-panel" ;
19
19
import { computeExpression } from "~/shared/data-variables" ;
20
20
import { updateWebstudioData } from "~/shared/instance-utils" ;
21
- import { nanoid } from "nanoid " ;
21
+ import { PropertyLabel } from "../property-label " ;
22
22
23
23
export const ResourceControl = ( {
24
24
meta,
25
25
prop,
26
26
propName,
27
27
instanceId,
28
- deletable,
29
28
} : ControlProps < "resource" > ) => {
30
29
const resources = useStore ( $resources ) ;
31
30
const { variableValues, scope, aliases } = useStore (
@@ -98,17 +97,6 @@ export const ResourceControl = ({
98
97
} ) ;
99
98
} ;
100
99
101
- const deletePropAndResource = ( ) => {
102
- updateWebstudioData ( ( data ) => {
103
- if ( prop ?. type === "resource" ) {
104
- data . resources . delete ( prop . value ) ;
105
- }
106
- if ( prop ) {
107
- data . props . delete ( prop . id ) ;
108
- }
109
- } ) ;
110
- } ;
111
-
112
100
const id = useId ( ) ;
113
101
const label = humanizeAttribute ( meta . label || propName ) ;
114
102
let variant : BindingVariant = "bound" ;
@@ -122,14 +110,8 @@ export const ResourceControl = ({
122
110
) ;
123
111
124
112
return (
125
- < ResponsiveLayout
126
- label = {
127
- < Label htmlFor = { id } description = { meta . description } readOnly = { readOnly } >
128
- { label }
129
- </ Label >
130
- }
131
- deletable = { deletable }
132
- onDelete = { deletePropAndResource }
113
+ < VerticalLayout
114
+ label = { < PropertyLabel name = { propName } readOnly = { readOnly } /> }
133
115
>
134
116
< BindingControl >
135
117
< InputField
@@ -156,6 +138,6 @@ export const ResourceControl = ({
156
138
}
157
139
/>
158
140
</ BindingControl >
159
- </ ResponsiveLayout >
141
+ </ VerticalLayout >
160
142
) ;
161
143
} ;
0 commit comments