@rbxts/react-clean-ui 1.0.14 → 1.0.36
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/out/Components/Chart/BarChart.d.ts +47 -0
- package/out/Components/Chart/BarChart.luau +880 -0
- package/out/Components/Chart/Pie.d.ts +27 -0
- package/out/Components/Chart/Pie.luau +281 -0
- package/out/Components/Chart/index.d.ts +2 -0
- package/out/Components/Chart/init.luau +10 -0
- package/out/Components/Decorator/BoxShadow.d.ts +2 -1
- package/out/Components/Decorator/BoxShadow.luau +51 -28
- package/out/Components/Input/Select.d.ts +6 -14
- package/out/Components/Input/Select.luau +111 -151
- package/out/Components/Input/Slider.d.ts +3 -37
- package/out/Components/Input/Slider.luau +271 -300
- package/out/Components/Interaction/Toast.d.ts +1 -1
- package/out/Components/Interaction/Toast.luau +4 -4
- package/out/Components/Interaction/Tooltip.d.ts +1 -1
- package/out/Components/Interaction/Tooltip.luau +8 -1
- package/out/Components/Layout/Accordion.d.ts +34 -0
- package/out/Components/Layout/Accordion.luau +430 -0
- package/out/Components/Layout/Column.d.ts +2 -8
- package/out/Components/Layout/Column.luau +28 -48
- package/out/Components/Layout/Container.luau +21 -5
- package/out/Components/Layout/Draggable.d.ts +7 -31
- package/out/Components/Layout/Draggable.luau +190 -214
- package/out/Components/Layout/Fieldset.d.ts +8 -18
- package/out/Components/Layout/Fieldset.luau +42 -84
- package/out/Components/Layout/Group.d.ts +7 -14
- package/out/Components/Layout/Group.luau +111 -129
- package/out/Components/Layout/HStack.d.ts +2 -1
- package/out/Components/Layout/HStack.luau +1 -2
- package/out/Components/Layout/Row.d.ts +2 -11
- package/out/Components/Layout/Row.luau +46 -71
- package/out/Components/Layout/Tabs.d.ts +10 -18
- package/out/Components/Layout/Tabs.luau +85 -104
- package/out/Components/Layout/VStack.d.ts +4 -1
- package/out/Components/Layout/VStack.luau +2 -2
- package/out/Components/Layout/index.d.ts +1 -0
- package/out/Components/Layout/init.luau +3 -0
- package/out/Components/Navigation/Menu.d.ts +6 -10
- package/out/Components/Navigation/Menu.luau +38 -65
- package/out/Components/Surface/Box.d.ts +2 -2
- package/out/Components/Surface/Card.d.ts +8 -11
- package/out/Components/Surface/Card.luau +40 -48
- package/out/Components/Surface/Icon.d.ts +1 -1
- package/out/Components/Surface/Icon.luau +1 -0
- package/out/Components/Surface/index.d.ts +0 -1
- package/out/Components/Surface/init.luau +0 -3
- package/out/Components/Typography/Text.luau +26 -13
- package/out/Components/index.d.ts +1 -0
- package/out/Components/init.luau +3 -0
- package/out/Helpers/create-ui-story.d.ts +6 -4
- package/out/Helpers/create-ui-story.luau +15 -4
- package/out/Helpers/css.helper.d.ts +2 -1
- package/out/Helpers/css.helper.luau +25 -0
- package/out/Helpers/size.helper.luau +1 -1
- package/out/Interfaces/clean.element.props.d.ts +7 -2
- package/out/Providers/registry.provider.d.ts +1 -0
- package/out/Providers/registry.provider.luau +5 -0
- package/out/Theme/theme.template.d.ts +72 -1
- package/out/Theme/themes/dark.theme.luau +47 -0
- package/out/Theme/themes/default.theme.luau +116 -1
- package/out/Theme/themes/sandstone.theme.luau +59 -0
- package/package.json +4 -2
- package/out/Components/Surface/Panel.d.ts +0 -4
- package/out/Components/Surface/Panel.luau +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { DroppableRegistration
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { DroppableRegistration } from "../../Providers";
|
|
3
3
|
type GuiObjectProps = React.InstanceProps<GuiObject>;
|
|
4
4
|
type GuiElement = React.ReactElement<GuiObjectProps>;
|
|
5
5
|
interface DragHandleProps {
|
|
@@ -15,32 +15,8 @@ interface DraggableProps {
|
|
|
15
15
|
children: GuiElement;
|
|
16
16
|
id?: string;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
placeholderAnchorPoint: Vector2;
|
|
24
|
-
placeholderLayoutOrder: number;
|
|
25
|
-
placeholderZIndex: number;
|
|
26
|
-
}
|
|
27
|
-
export declare class Draggable extends Component<DraggableProps, DraggableState> {
|
|
28
|
-
static Handle: typeof DragHandle;
|
|
29
|
-
readonly state: DraggableState;
|
|
30
|
-
static contextType: React.Context<import("../../Providers").RegistryContextValue | undefined>;
|
|
31
|
-
context: React.ContextType<typeof RegistryContext>;
|
|
32
|
-
rootRef: React.RefObject<GuiObject>;
|
|
33
|
-
private readonly placeholderRef;
|
|
34
|
-
private dragInformation;
|
|
35
|
-
private usePlaceholder;
|
|
36
|
-
private registration;
|
|
37
|
-
componentDidMount(): void;
|
|
38
|
-
componentWillUnmount(): void;
|
|
39
|
-
private beginDrag;
|
|
40
|
-
private updateDrag;
|
|
41
|
-
private endDrag;
|
|
42
|
-
private findDroppable;
|
|
43
|
-
private readonly contextValue;
|
|
44
|
-
render(): ReactNode;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
18
|
+
type DraggableComponent = React.ForwardRefExoticComponent<DraggableProps & React.RefAttributes<Frame>> & {
|
|
19
|
+
Handle: typeof DragHandle;
|
|
20
|
+
};
|
|
21
|
+
declare const Draggable: DraggableComponent;
|
|
22
|
+
export { Draggable };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local React = _react
|
|
5
|
-
local Component = _react.Component
|
|
6
|
-
local ReactComponent = _react.ReactComponent
|
|
7
|
-
local useContext = _react.useContext
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
8
4
|
local GuiHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").GuiHelper
|
|
9
5
|
local _Providers = TS.import(script, script.Parent.Parent.Parent, "Providers")
|
|
10
6
|
local DraggableRegistryKey = _Providers.DraggableRegistryKey
|
|
@@ -65,7 +61,7 @@ local function DragHandle(_param)
|
|
|
65
61
|
return React.cloneElement(children, _object)
|
|
66
62
|
end
|
|
67
63
|
local function Placeholder(props)
|
|
68
|
-
local theme = useContext(CleanThemeContext)
|
|
64
|
+
local theme = React.useContext(CleanThemeContext)
|
|
69
65
|
local _attributes = table.clone(props)
|
|
70
66
|
setmetatable(_attributes, nil)
|
|
71
67
|
_attributes.BackgroundTransparency = theme.components.draggable.placeholder.backgroundTransparency
|
|
@@ -78,180 +74,32 @@ local function Placeholder(props)
|
|
|
78
74
|
radius = theme.components.draggable.placeholder.cornerRadius,
|
|
79
75
|
}))
|
|
80
76
|
end
|
|
81
|
-
local Draggable
|
|
82
|
-
|
|
83
|
-
local
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
local Draggable = React.forwardRef(function(props, _ref)
|
|
78
|
+
local dragging, setDragging = React.useState(false)
|
|
79
|
+
local overlayPosition, setOverlayPosition = React.useState(Vector2.zero)
|
|
80
|
+
local overlaySize, setOverlaySize = React.useState(Vector2.zero)
|
|
81
|
+
local placeholderPosition, setPlaceholderPosition = React.useState({
|
|
82
|
+
Position = UDim2.fromOffset(0, 0),
|
|
83
|
+
AnchorPoint = Vector2.zero,
|
|
84
|
+
LayoutOrder = 0,
|
|
85
|
+
ZIndex = 1,
|
|
89
86
|
})
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
local registry = React.useContext(RegistryContext)
|
|
88
|
+
local rootRef = React.useRef()
|
|
89
|
+
local placeholderRef = React.useRef()
|
|
90
|
+
local dragInformationRef = React.useRef()
|
|
91
|
+
local _condition = props.placeholder
|
|
92
|
+
if _condition == nil then
|
|
93
|
+
_condition = true
|
|
94
94
|
end
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
dragging = false,
|
|
99
|
-
overlayPosition = Vector2.zero,
|
|
100
|
-
overlaySize = Vector2.zero,
|
|
101
|
-
placeholderPosition = UDim2.fromOffset(0, 0),
|
|
102
|
-
placeholderAnchorPoint = Vector2.zero,
|
|
103
|
-
placeholderLayoutOrder = 0,
|
|
104
|
-
placeholderZIndex = 1,
|
|
105
|
-
}
|
|
106
|
-
self.rootRef = React.createRef()
|
|
107
|
-
self.placeholderRef = React.createRef()
|
|
108
|
-
local _condition = self.props.placeholder
|
|
109
|
-
if _condition == nil then
|
|
110
|
-
_condition = true
|
|
111
|
-
end
|
|
112
|
-
self.usePlaceholder = _condition
|
|
113
|
-
self.beginDrag = function(input, handle)
|
|
114
|
-
local root = self.rootRef.current
|
|
115
|
-
if root == nil then
|
|
116
|
-
return nil
|
|
117
|
-
end
|
|
118
|
-
local _allDraggables = self.context
|
|
119
|
-
if _allDraggables ~= nil then
|
|
120
|
-
_allDraggables = _allDraggables.getAll(DraggableRegistryKey)
|
|
121
|
-
end
|
|
122
|
-
local allDraggables = _allDraggables
|
|
123
|
-
local _result = allDraggables
|
|
124
|
-
if _result ~= nil then
|
|
125
|
-
-- ▼ ReadonlyArray.some ▼
|
|
126
|
-
local _result_1 = false
|
|
127
|
-
local _callback = function(registration)
|
|
128
|
-
return registration.draggable.isDragging
|
|
129
|
-
end
|
|
130
|
-
for _k, _v in _result do
|
|
131
|
-
if _callback(_v, _k - 1, _result) then
|
|
132
|
-
_result_1 = true
|
|
133
|
-
break
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
-- ▲ ReadonlyArray.some ▲
|
|
137
|
-
_result = _result_1
|
|
138
|
-
end
|
|
139
|
-
if _result then
|
|
140
|
-
return nil
|
|
141
|
-
end
|
|
142
|
-
if self.registration ~= nil then
|
|
143
|
-
self.registration.draggable.isDragging = true
|
|
144
|
-
end
|
|
145
|
-
self.dragInformation = {
|
|
146
|
-
input = input,
|
|
147
|
-
inputStart = Vector2.new(input.Position.X, input.Position.Y),
|
|
148
|
-
absolutePositionStart = root.AbsolutePosition,
|
|
149
|
-
positionStart = root.Position,
|
|
150
|
-
}
|
|
151
|
-
local _result_1 = self.props.onStartDrag
|
|
152
|
-
if _result_1 ~= nil then
|
|
153
|
-
_result_1()
|
|
154
|
-
end
|
|
155
|
-
self:setState({
|
|
156
|
-
dragging = true,
|
|
157
|
-
overlayPosition = root.AbsolutePosition,
|
|
158
|
-
overlaySize = root.AbsoluteSize,
|
|
159
|
-
placeholderPosition = root.Position,
|
|
160
|
-
placeholderAnchorPoint = root.AnchorPoint,
|
|
161
|
-
placeholderLayoutOrder = root.LayoutOrder,
|
|
162
|
-
placeholderZIndex = root.ZIndex,
|
|
163
|
-
})
|
|
164
|
-
end
|
|
165
|
-
self.updateDrag = function(input)
|
|
166
|
-
local root = self.rootRef.current
|
|
167
|
-
local drag = self.dragInformation
|
|
168
|
-
if root == nil or drag == nil then
|
|
169
|
-
return nil
|
|
170
|
-
end
|
|
171
|
-
local inputPosition = Vector2.new(input.Position.X, input.Position.Y)
|
|
172
|
-
local _inputStart = drag.inputStart
|
|
173
|
-
local delta = inputPosition - _inputStart
|
|
174
|
-
local overlayPosition = drag.absolutePositionStart + delta
|
|
175
|
-
local dropRegisteration = self:findDroppable(root, Vector2.new(input.Position.X, input.Position.Y))
|
|
176
|
-
local _result = self.props.onDragged
|
|
177
|
-
if _result ~= nil then
|
|
178
|
-
_result(dropRegisteration)
|
|
179
|
-
end
|
|
180
|
-
self:setState({
|
|
181
|
-
overlayPosition = overlayPosition,
|
|
182
|
-
})
|
|
183
|
-
end
|
|
184
|
-
self.endDrag = function(input)
|
|
185
|
-
local root = self.rootRef.current
|
|
186
|
-
local drag = self.dragInformation
|
|
187
|
-
if root == nil or drag == nil then
|
|
188
|
-
return nil
|
|
189
|
-
end
|
|
190
|
-
if self.registration then
|
|
191
|
-
self.registration.draggable.isDragging = false
|
|
192
|
-
end
|
|
193
|
-
local dropRegisteration = self:findDroppable(root, Vector2.new(input.Position.X, input.Position.Y))
|
|
194
|
-
self.dragInformation = nil
|
|
195
|
-
local _result = self.props.onDropped
|
|
196
|
-
if _result ~= nil then
|
|
197
|
-
_result(dropRegisteration)
|
|
198
|
-
end
|
|
199
|
-
if self.props.retainPosition then
|
|
200
|
-
local parent = root.Parent
|
|
201
|
-
local _result_1 = parent
|
|
202
|
-
if _result_1 ~= nil then
|
|
203
|
-
_result_1 = _result_1:IsA("GuiObject")
|
|
204
|
-
end
|
|
205
|
-
if _result_1 then
|
|
206
|
-
local _overlayPosition = self.state.overlayPosition
|
|
207
|
-
local _absolutePosition = parent.AbsolutePosition
|
|
208
|
-
local localTopLeft = _overlayPosition - _absolutePosition
|
|
209
|
-
local _absoluteSize = root.AbsoluteSize
|
|
210
|
-
local _anchorPoint = root.AnchorPoint
|
|
211
|
-
local anchorOffset = _absoluteSize * _anchorPoint
|
|
212
|
-
root.Position = UDim2.fromOffset(localTopLeft.X + anchorOffset.X, localTopLeft.Y + anchorOffset.Y)
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
self:setState({
|
|
216
|
-
dragging = false,
|
|
217
|
-
})
|
|
218
|
-
end
|
|
219
|
-
self.contextValue = {
|
|
220
|
-
isDragging = false,
|
|
221
|
-
beginDrag = self.beginDrag,
|
|
222
|
-
updateDrag = self.updateDrag,
|
|
223
|
-
endDrag = self.endDrag,
|
|
224
|
-
}
|
|
225
|
-
end
|
|
226
|
-
function Draggable:componentDidMount()
|
|
227
|
-
local registry = self.context
|
|
228
|
-
local root = self.rootRef.current
|
|
229
|
-
if registry == nil or root == nil then
|
|
230
|
-
return nil
|
|
231
|
-
end
|
|
232
|
-
local registration = {
|
|
233
|
-
guiObject = root,
|
|
234
|
-
id = self.props.id,
|
|
235
|
-
draggable = self.contextValue,
|
|
236
|
-
}
|
|
237
|
-
self.registration = registration
|
|
238
|
-
registry.register(root, DraggableRegistryKey, registration)
|
|
239
|
-
end
|
|
240
|
-
function Draggable:componentWillUnmount()
|
|
241
|
-
local registry = self.context
|
|
242
|
-
local registration = self.registration
|
|
243
|
-
if registry == nil or registration == nil then
|
|
244
|
-
return nil
|
|
245
|
-
end
|
|
246
|
-
registry.unregister(registration.guiObject, DraggableRegistryKey)
|
|
247
|
-
self.registration = nil
|
|
248
|
-
end
|
|
249
|
-
function Draggable:findDroppable(instance, position)
|
|
95
|
+
local usePlaceholder = _condition
|
|
96
|
+
local registrationRef = React.useRef()
|
|
97
|
+
local findDroppable = React.useCallback(function(instance, position)
|
|
250
98
|
local result
|
|
251
99
|
local _exp = GuiHelper:getGuiObjectsAtPosition(instance, position)
|
|
252
100
|
-- ▼ ReadonlyArray.forEach ▼
|
|
253
101
|
local _callback = function(guiObject)
|
|
254
|
-
local _registryEntry =
|
|
102
|
+
local _registryEntry = registry
|
|
255
103
|
if _registryEntry ~= nil then
|
|
256
104
|
_registryEntry = _registryEntry.get(guiObject, DroppableRegistryKey)
|
|
257
105
|
end
|
|
@@ -269,47 +117,175 @@ do
|
|
|
269
117
|
end
|
|
270
118
|
-- ▲ ReadonlyArray.forEach ▲
|
|
271
119
|
return result
|
|
272
|
-
end
|
|
273
|
-
function
|
|
274
|
-
local
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if
|
|
293
|
-
|
|
120
|
+
end, { registry })
|
|
121
|
+
local beginDrag = React.useCallback(function(input, handle)
|
|
122
|
+
local root = rootRef.current
|
|
123
|
+
local registration = registrationRef.current
|
|
124
|
+
if root == nil then
|
|
125
|
+
return nil
|
|
126
|
+
end
|
|
127
|
+
local _allDraggables = registry
|
|
128
|
+
if _allDraggables ~= nil then
|
|
129
|
+
_allDraggables = _allDraggables.getAll(DraggableRegistryKey)
|
|
130
|
+
end
|
|
131
|
+
local allDraggables = _allDraggables
|
|
132
|
+
local _result = allDraggables
|
|
133
|
+
if _result ~= nil then
|
|
134
|
+
-- ▼ ReadonlyArray.some ▼
|
|
135
|
+
local _result_1 = false
|
|
136
|
+
local _callback = function(registration)
|
|
137
|
+
return registration.draggable.isDragging
|
|
138
|
+
end
|
|
139
|
+
for _k, _v in _result do
|
|
140
|
+
if _callback(_v, _k - 1, _result) then
|
|
141
|
+
_result_1 = true
|
|
142
|
+
break
|
|
294
143
|
end
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
144
|
+
end
|
|
145
|
+
-- ▲ ReadonlyArray.some ▲
|
|
146
|
+
_result = _result_1
|
|
147
|
+
end
|
|
148
|
+
if _result then
|
|
149
|
+
return nil
|
|
150
|
+
end
|
|
151
|
+
if registration ~= nil then
|
|
152
|
+
registration.draggable.isDragging = true
|
|
153
|
+
end
|
|
154
|
+
dragInformationRef.current = {
|
|
155
|
+
input = input,
|
|
156
|
+
inputStart = Vector2.new(input.Position.X, input.Position.Y),
|
|
157
|
+
absolutePositionStart = root.AbsolutePosition,
|
|
158
|
+
positionStart = root.Position,
|
|
159
|
+
}
|
|
160
|
+
local _result_1 = props.onStartDrag
|
|
161
|
+
if _result_1 ~= nil then
|
|
162
|
+
_result_1()
|
|
163
|
+
end
|
|
164
|
+
setDragging(true)
|
|
165
|
+
setOverlayPosition(root.AbsolutePosition)
|
|
166
|
+
setOverlaySize(root.AbsoluteSize)
|
|
167
|
+
setPlaceholderPosition({
|
|
168
|
+
Position = root.Position,
|
|
169
|
+
AnchorPoint = root.AnchorPoint,
|
|
170
|
+
LayoutOrder = root.LayoutOrder,
|
|
171
|
+
ZIndex = root.ZIndex,
|
|
172
|
+
})
|
|
173
|
+
end, { registry, props.onStartDrag })
|
|
174
|
+
local updateDrag = React.useCallback(function(input)
|
|
175
|
+
local root = rootRef.current
|
|
176
|
+
local dragInformation = dragInformationRef.current
|
|
177
|
+
if root == nil or dragInformation == nil then
|
|
178
|
+
return nil
|
|
179
|
+
end
|
|
180
|
+
local inputPosition = Vector2.new(input.Position.X, input.Position.Y)
|
|
181
|
+
local _inputStart = dragInformation.inputStart
|
|
182
|
+
local delta = inputPosition - _inputStart
|
|
183
|
+
local dropRegisteration = findDroppable(root, Vector2.new(input.Position.X, input.Position.Y))
|
|
184
|
+
local _result = props.onDragged
|
|
185
|
+
if _result ~= nil then
|
|
186
|
+
_result(dropRegisteration)
|
|
187
|
+
end
|
|
188
|
+
setOverlayPosition(dragInformation.absolutePositionStart + delta)
|
|
189
|
+
end, { findDroppable, props.onDragged })
|
|
190
|
+
local endDrag = React.useCallback(function(input)
|
|
191
|
+
local root = rootRef.current
|
|
192
|
+
local dragInformation = dragInformationRef.current
|
|
193
|
+
local registration = registrationRef.current
|
|
194
|
+
if root == nil or dragInformation == nil then
|
|
195
|
+
return nil
|
|
196
|
+
end
|
|
197
|
+
if registration then
|
|
198
|
+
registration.draggable.isDragging = false
|
|
199
|
+
end
|
|
200
|
+
local dropRegisteration = findDroppable(root, Vector2.new(input.Position.X, input.Position.Y))
|
|
201
|
+
dragInformationRef.current = nil
|
|
202
|
+
local _result = props.onDropped
|
|
203
|
+
if _result ~= nil then
|
|
204
|
+
_result(dropRegisteration)
|
|
205
|
+
end
|
|
206
|
+
if props.retainPosition then
|
|
207
|
+
local parent = root.Parent
|
|
208
|
+
local _result_1 = parent
|
|
209
|
+
if _result_1 ~= nil then
|
|
210
|
+
_result_1 = _result_1:IsA("GuiObject")
|
|
211
|
+
end
|
|
212
|
+
if _result_1 then
|
|
213
|
+
local inputPosition = Vector2.new(input.Position.X, input.Position.Y)
|
|
214
|
+
local _inputStart = dragInformation.inputStart
|
|
215
|
+
local delta = inputPosition - _inputStart
|
|
216
|
+
local finalOverlayPosition = dragInformation.absolutePositionStart + delta
|
|
217
|
+
local _absolutePosition = parent.AbsolutePosition
|
|
218
|
+
local localTopLeft = finalOverlayPosition - _absolutePosition
|
|
219
|
+
local _absoluteSize = root.AbsoluteSize
|
|
220
|
+
local _anchorPoint = root.AnchorPoint
|
|
221
|
+
local anchorOffset = _absoluteSize * _anchorPoint
|
|
222
|
+
root.Position = UDim2.fromOffset(localTopLeft.X + anchorOffset.X, localTopLeft.Y + anchorOffset.Y)
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
setDragging(false)
|
|
226
|
+
end, { findDroppable, props.onDropped, props.retainPosition })
|
|
227
|
+
local contextValue = React.useMemo(function()
|
|
228
|
+
return {
|
|
229
|
+
isDragging = false,
|
|
230
|
+
beginDrag = beginDrag,
|
|
231
|
+
updateDrag = updateDrag,
|
|
232
|
+
endDrag = endDrag,
|
|
233
|
+
}
|
|
234
|
+
end, { beginDrag, updateDrag, endDrag })
|
|
235
|
+
React.useEffect(function()
|
|
236
|
+
local root = rootRef.current
|
|
237
|
+
if registry == nil or root == nil then
|
|
238
|
+
return nil
|
|
239
|
+
end
|
|
240
|
+
local registration = {
|
|
241
|
+
guiObject = root,
|
|
242
|
+
id = props.id,
|
|
243
|
+
draggable = contextValue,
|
|
244
|
+
}
|
|
245
|
+
registrationRef.current = registration
|
|
246
|
+
registry.register(root, DraggableRegistryKey, registration)
|
|
247
|
+
return function()
|
|
248
|
+
registry.unregister(registration.guiObject, DraggableRegistryKey)
|
|
249
|
+
if registrationRef.current == registration then
|
|
250
|
+
registrationRef.current = nil
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end, { registry, props.id, contextValue })
|
|
254
|
+
local original = React.cloneElement(props.children, {
|
|
255
|
+
ref = rootRef,
|
|
256
|
+
Visible = not dragging,
|
|
257
|
+
})
|
|
258
|
+
local placeholder = (React.createElement(Placeholder, {
|
|
259
|
+
ref = placeholderRef,
|
|
260
|
+
Position = placeholderPosition.Position,
|
|
261
|
+
AnchorPoint = placeholderPosition.AnchorPoint,
|
|
262
|
+
Size = UDim2.fromOffset(overlaySize.X, overlaySize.Y),
|
|
263
|
+
AutomaticSize = Enum.AutomaticSize.None,
|
|
264
|
+
BackgroundTransparency = 0.3,
|
|
265
|
+
LayoutOrder = placeholderPosition.LayoutOrder,
|
|
266
|
+
ZIndex = placeholderPosition.ZIndex,
|
|
267
|
+
}))
|
|
268
|
+
return React.createElement(DraggableContext.Provider, {
|
|
269
|
+
value = contextValue,
|
|
270
|
+
}, usePlaceholder and dragging and placeholder, original, React.createElement(OverlayConsumer, {
|
|
271
|
+
render = function(overlay)
|
|
272
|
+
if not dragging or overlay == nil then
|
|
273
|
+
return nil
|
|
274
|
+
end
|
|
275
|
+
local _absolutePosition = overlay.AbsolutePosition
|
|
276
|
+
local localPosition = overlayPosition - _absolutePosition
|
|
277
|
+
return createPortal(React.cloneElement(props.children, {
|
|
278
|
+
Position = UDim2.fromOffset(localPosition.X, localPosition.Y),
|
|
279
|
+
Size = UDim2.fromOffset(overlaySize.X, overlaySize.Y),
|
|
280
|
+
AnchorPoint = Vector2.zero,
|
|
281
|
+
AutomaticSize = Enum.AutomaticSize.None,
|
|
282
|
+
Visible = true,
|
|
283
|
+
ZIndex = 100001,
|
|
284
|
+
}), overlay)
|
|
285
|
+
end,
|
|
286
|
+
}))
|
|
287
|
+
end)
|
|
288
|
+
Draggable.Handle = DragHandle
|
|
313
289
|
return {
|
|
314
290
|
Draggable = Draggable,
|
|
315
291
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { CleanThemeContext } from "../../Contexts";
|
|
1
|
+
import React from "@rbxts/react";
|
|
3
2
|
import { Breakpoint, BreakPointElementProps } from "../../Interfaces";
|
|
4
3
|
export interface FieldsetContextValue {
|
|
5
4
|
disabled: boolean;
|
|
6
5
|
checkbox: boolean;
|
|
7
|
-
labelActivated
|
|
6
|
+
labelActivated: BindableEvent;
|
|
8
7
|
}
|
|
9
8
|
export declare const FieldsetContext: React.Context<FieldsetContextValue | undefined>;
|
|
10
9
|
interface FieldsetProps extends BreakPointElementProps {
|
|
@@ -17,18 +16,9 @@ interface FieldsetSlotProps {
|
|
|
17
16
|
}
|
|
18
17
|
declare function FieldsetLabel(props: FieldsetSlotProps): React.JSX.Element;
|
|
19
18
|
declare function FieldsetControl(props: FieldsetSlotProps): React.JSX.Element;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static contextType: React.Context<import("../..").CleanTheme>;
|
|
27
|
-
context: React.ContextType<typeof CleanThemeContext>;
|
|
28
|
-
private readonly labelActivated;
|
|
29
|
-
private fieldsetContext;
|
|
30
|
-
private getFieldsetContext;
|
|
31
|
-
componentWillUnmount(): void;
|
|
32
|
-
render(): React.JSX.Element;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
19
|
+
type FieldsetComponent = React.ForwardRefExoticComponent<FieldsetProps & React.RefAttributes<Frame>> & {
|
|
20
|
+
Label: typeof FieldsetLabel;
|
|
21
|
+
Control: typeof FieldsetControl;
|
|
22
|
+
};
|
|
23
|
+
declare const Fieldset: FieldsetComponent;
|
|
24
|
+
export { Fieldset };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local React = _react
|
|
5
|
-
local Component = _react.Component
|
|
6
|
-
local ReactComponent = _react.ReactComponent
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
7
4
|
local FlexItem = TS.import(script, script.Parent, "FlexItem").FlexItem
|
|
8
5
|
local Container = TS.import(script, script.Parent, "Container").Container
|
|
9
6
|
local HStack = TS.import(script, script.Parent, "HStack").HStack
|
|
@@ -24,10 +21,7 @@ local function FieldsetLabel(props)
|
|
|
24
21
|
AutomaticSize = Enum.AutomaticSize.XY,
|
|
25
22
|
Event = {
|
|
26
23
|
Activated = function()
|
|
27
|
-
|
|
28
|
-
if _result ~= nil then
|
|
29
|
-
_result:Fire()
|
|
30
|
-
end
|
|
24
|
+
context.labelActivated:Fire()
|
|
31
25
|
end,
|
|
32
26
|
},
|
|
33
27
|
}, props.children))
|
|
@@ -42,88 +36,52 @@ local function FieldsetControl(props)
|
|
|
42
36
|
GrowRatio = if context.checkbox then 0 else 1,
|
|
43
37
|
}, props.children)
|
|
44
38
|
end
|
|
45
|
-
local Fieldset
|
|
46
|
-
|
|
47
|
-
local
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
local
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
function Fieldset:constructor(...)
|
|
60
|
-
super.constructor(self, ...)
|
|
61
|
-
self.labelActivated = Instance.new("BindableEvent")
|
|
62
|
-
self.fieldsetContext = {
|
|
63
|
-
disabled = false,
|
|
64
|
-
checkbox = false,
|
|
65
|
-
labelActivated = self.labelActivated,
|
|
66
|
-
}
|
|
67
|
-
end
|
|
68
|
-
function Fieldset:getFieldsetContext()
|
|
69
|
-
local _condition = self.props.disabled
|
|
39
|
+
local Fieldset = React.forwardRef(function(props, ref)
|
|
40
|
+
local theme = React.useContext(CleanThemeContext)
|
|
41
|
+
local width, setWidth = React.useState(0)
|
|
42
|
+
local labelActivated = React.useRef(Instance.new("BindableEvent")).current
|
|
43
|
+
React.useEffect(function()
|
|
44
|
+
return function()
|
|
45
|
+
labelActivated:Destroy()
|
|
46
|
+
end
|
|
47
|
+
end, {})
|
|
48
|
+
local fieldsetContext = React.useMemo(function()
|
|
49
|
+
local _object = {}
|
|
50
|
+
local _left = "disabled"
|
|
51
|
+
local _condition = props.disabled
|
|
70
52
|
if _condition == nil then
|
|
71
53
|
_condition = false
|
|
72
54
|
end
|
|
73
|
-
|
|
74
|
-
local
|
|
55
|
+
_object[_left] = _condition
|
|
56
|
+
local _left_1 = "checkbox"
|
|
57
|
+
local _condition_1 = props.checkbox
|
|
75
58
|
if _condition_1 == nil then
|
|
76
59
|
_condition_1 = false
|
|
77
60
|
end
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
end
|
|
103
|
-
return React.createElement(FieldsetContext.Provider, {
|
|
104
|
-
value = context,
|
|
105
|
-
}, React.createElement(Container, {
|
|
106
|
-
Change = {
|
|
107
|
-
AbsoluteSize = function(instance)
|
|
108
|
-
local width = instance.AbsoluteSize.X
|
|
109
|
-
if width ~= self.state.width then
|
|
110
|
-
self:setState({
|
|
111
|
-
width = width,
|
|
112
|
-
})
|
|
113
|
-
end
|
|
114
|
-
end,
|
|
115
|
-
},
|
|
116
|
-
}, React.createElement(HStack, {
|
|
117
|
-
Wraps = wrap,
|
|
118
|
-
valign = "Center",
|
|
119
|
-
HorizontalFlex = Enum.UIFlexAlignment.Fill,
|
|
120
|
-
}, self.props.children)))
|
|
121
|
-
end
|
|
122
|
-
Fieldset.Label = FieldsetLabel
|
|
123
|
-
Fieldset.Control = FieldsetControl
|
|
124
|
-
Fieldset.contextType = CleanThemeContext
|
|
125
|
-
Fieldset = ReactComponent(Fieldset) or Fieldset
|
|
126
|
-
end
|
|
61
|
+
_object[_left_1] = _condition_1
|
|
62
|
+
_object.labelActivated = labelActivated
|
|
63
|
+
return _object
|
|
64
|
+
end, { props.disabled, props.checkbox })
|
|
65
|
+
local breakpoints = props.breakpoints or theme.breakpoints
|
|
66
|
+
local breakpoint = BreakpointHelper:getBreakpoint(width, breakpoints)
|
|
67
|
+
local wrap = BreakpointHelper:compare(breakpoint, "<=", props.wrap or "lg")
|
|
68
|
+
return React.createElement(FieldsetContext.Provider, {
|
|
69
|
+
value = fieldsetContext,
|
|
70
|
+
}, React.createElement(Container, {
|
|
71
|
+
ref = ref,
|
|
72
|
+
Change = {
|
|
73
|
+
AbsoluteSize = function(instance)
|
|
74
|
+
setWidth(instance.AbsoluteSize.X)
|
|
75
|
+
end,
|
|
76
|
+
},
|
|
77
|
+
}, React.createElement(HStack, {
|
|
78
|
+
Wraps = wrap,
|
|
79
|
+
valign = "Center",
|
|
80
|
+
HorizontalFlex = Enum.UIFlexAlignment.Fill,
|
|
81
|
+
}, props.children)))
|
|
82
|
+
end)
|
|
83
|
+
Fieldset.Label = FieldsetLabel
|
|
84
|
+
Fieldset.Control = FieldsetControl
|
|
127
85
|
return {
|
|
128
86
|
FieldsetContext = FieldsetContext,
|
|
129
87
|
Fieldset = Fieldset,
|