@rbxts/react-clean-ui 1.2.9 → 1.4.0
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/LICENSE +15 -0
- package/README.md +111 -1
- package/out/Components/Chart/Pie.luau +13 -20
- package/out/Components/Input/Button.d.ts +3 -1
- package/out/Components/Input/Button.luau +4 -0
- package/out/Components/Interaction/Tooltip.d.ts +2 -0
- package/out/Components/Interaction/Tooltip.luau +62 -34
- package/out/Components/Layout/Accordion.d.ts +14 -3
- package/out/Components/Layout/Accordion.luau +76 -10
- package/out/Components/Layout/Draggable.d.ts +7 -4
- package/out/Components/Layout/Draggable.luau +191 -98
- package/out/Components/Layout/Droppable.d.ts +5 -2
- package/out/Components/Layout/Droppable.luau +50 -10
- package/out/Components/Layout/FadeGroup.d.ts +6 -0
- package/out/Components/Layout/FadeGroup.luau +58 -0
- package/out/Components/Layout/Group.d.ts +2 -2
- package/out/Components/Layout/Tabs.d.ts +1 -0
- package/out/Components/Layout/Tabs.luau +1 -0
- package/out/Components/Layout/index.d.ts +1 -0
- package/out/Components/Layout/init.luau +3 -0
- package/out/Components/Surface/Card.d.ts +1 -3
- package/out/Components/Surface/Icon.luau +1 -0
- package/out/Components/Typography/Text.luau +2 -2
- package/out/Contexts/draggable.context.d.ts +11 -0
- package/out/Contexts/draggable.context.luau +5 -0
- package/out/Helpers/create-ui-story.d.ts +1 -1
- package/out/Helpers/element.helper.d.ts +8 -0
- package/out/Helpers/element.helper.luau +77 -0
- package/out/Helpers/gui.helper.d.ts +6 -0
- package/out/Helpers/gui.helper.luau +141 -7
- package/out/Helpers/index.d.ts +1 -0
- package/out/Helpers/init.luau +3 -0
- package/out/Helpers/size.helper.luau +2 -10
- package/out/Providers/registry.provider.d.ts +7 -3
- package/out/Providers/registry.provider.luau +15 -15
- package/out/Theme/themes/wooden.theme.luau +9 -0
- package/package.json +1 -1
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
-
local
|
|
4
|
+
local _ = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
5
|
+
local ElementHelper = _.ElementHelper
|
|
6
|
+
local GuiHelper = _.GuiHelper
|
|
5
7
|
local _Providers = TS.import(script, script.Parent.Parent.Parent, "Providers")
|
|
6
8
|
local DraggableRegistryKey = _Providers.DraggableRegistryKey
|
|
7
9
|
local DroppableRegistryKey = _Providers.DroppableRegistryKey
|
|
10
|
+
local GlobalRegistry = _Providers.GlobalRegistry
|
|
8
11
|
local RegistryContext = _Providers.RegistryContext
|
|
9
12
|
local _Contexts = TS.import(script, script.Parent.Parent.Parent, "Contexts")
|
|
10
13
|
local CleanThemeContext = _Contexts.CleanThemeContext
|
|
14
|
+
local DragStateContext = _Contexts.DragStateContext
|
|
11
15
|
local DraggableContext = _Contexts.DraggableContext
|
|
12
16
|
local OverlayConsumer = _Contexts.OverlayConsumer
|
|
13
17
|
local createPortal = TS.import(script, TS.getModule(script, "@rbxts", "react-roblox")).createPortal
|
|
14
18
|
local Corners = TS.import(script, script.Parent.Parent, "Decorator").Corners
|
|
15
19
|
local CustomInputService = TS.import(script, script.Parent.Parent.Parent, "Helpers").CustomInputService
|
|
20
|
+
local DEFAULT_INPUT_TYPES = { Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch }
|
|
21
|
+
local PREVIEW_DRAG_STATE = {
|
|
22
|
+
preview = true,
|
|
23
|
+
dragging = true,
|
|
24
|
+
}
|
|
25
|
+
local function toPoint(input)
|
|
26
|
+
return Vector2.new(input.Position.X, input.Position.Y)
|
|
27
|
+
end
|
|
28
|
+
local function createDragEventInfo(input, dragInformation, id)
|
|
29
|
+
return {
|
|
30
|
+
inputType = dragInformation.inputType,
|
|
31
|
+
input = input,
|
|
32
|
+
position = toPoint(input),
|
|
33
|
+
id = id,
|
|
34
|
+
}
|
|
35
|
+
end
|
|
16
36
|
local function isInteractiveDescendantAtInput(handle, input)
|
|
17
|
-
local point =
|
|
18
|
-
local _exp =
|
|
37
|
+
local point = toPoint(input)
|
|
38
|
+
local _exp = handle:GetDescendants()
|
|
19
39
|
-- ▼ ReadonlyArray.some ▼
|
|
20
40
|
local _result = false
|
|
21
|
-
local _callback = function(
|
|
22
|
-
return
|
|
41
|
+
local _callback = function(descendant)
|
|
42
|
+
return (descendant:IsA("GuiButton") or descendant:IsA("TextBox")) and GuiHelper:isGuiObjectHitAtPoint(descendant, point)
|
|
23
43
|
end
|
|
24
44
|
for _k, _v in _exp do
|
|
25
45
|
if _callback(_v, _k - 1, _exp) then
|
|
@@ -33,49 +53,41 @@ end
|
|
|
33
53
|
local function DragHandle(_param)
|
|
34
54
|
local children = _param.children
|
|
35
55
|
local draggable = React.useContext(DraggableContext)
|
|
56
|
+
local dragState = React.useContext(DragStateContext)
|
|
36
57
|
local _arg0 = draggable ~= nil
|
|
37
58
|
assert(_arg0, "Draggable.Handle must be used inside a Draggable component")
|
|
38
|
-
local
|
|
59
|
+
local inert = dragState.preview
|
|
39
60
|
React.useEffect(function()
|
|
61
|
+
if inert then
|
|
62
|
+
return nil
|
|
63
|
+
end
|
|
40
64
|
local inputChangedListener = CustomInputService.InputChanged:Connect(function(input)
|
|
41
65
|
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
|
|
42
66
|
draggable.updateDrag(input)
|
|
43
67
|
end
|
|
44
68
|
end)
|
|
45
69
|
local inputEndedListener = CustomInputService.InputEnded:Connect(function(input)
|
|
46
|
-
|
|
47
|
-
draggable.endDrag(input)
|
|
48
|
-
end
|
|
70
|
+
draggable.endDrag(input)
|
|
49
71
|
end)
|
|
50
72
|
return function()
|
|
51
73
|
inputChangedListener:Disconnect()
|
|
52
74
|
inputEndedListener:Disconnect()
|
|
53
75
|
end
|
|
54
|
-
end, { draggable })
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
local _object_1 = {}
|
|
60
|
-
if childEvents then
|
|
61
|
-
for _k, _v in childEvents do
|
|
62
|
-
_object_1[_k] = _v
|
|
63
|
-
end
|
|
76
|
+
end, { draggable, inert })
|
|
77
|
+
if inert then
|
|
78
|
+
return React.cloneElement(children, {
|
|
79
|
+
Active = true,
|
|
80
|
+
})
|
|
64
81
|
end
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if
|
|
70
|
-
|
|
82
|
+
return ElementHelper:cloneWithEvents(children, {
|
|
83
|
+
Active = true,
|
|
84
|
+
}, {
|
|
85
|
+
InputBegan = function(instance, input)
|
|
86
|
+
if not isInteractiveDescendantAtInput(instance, input) then
|
|
87
|
+
draggable.beginDrag(input, instance)
|
|
71
88
|
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
draggable.beginDrag(input, instance)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
_object[_left] = _object_1
|
|
78
|
-
return React.cloneElement(children, _object)
|
|
89
|
+
end,
|
|
90
|
+
})
|
|
79
91
|
end
|
|
80
92
|
local function Placeholder(props)
|
|
81
93
|
local theme = React.useContext(CleanThemeContext)
|
|
@@ -108,81 +120,75 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
108
120
|
ZIndex = 1,
|
|
109
121
|
})
|
|
110
122
|
local registry = React.useContext(RegistryContext)
|
|
123
|
+
local parentDragState = React.useContext(DragStateContext)
|
|
111
124
|
local rootRef = React.useRef()
|
|
112
125
|
local placeholderRef = React.useRef()
|
|
113
126
|
local dragInformationRef = React.useRef()
|
|
127
|
+
local hoveredRef = React.useRef()
|
|
128
|
+
local idRef = React.useRef()
|
|
129
|
+
idRef.current = props.id
|
|
114
130
|
local _condition = props.placeholder
|
|
115
131
|
if _condition == nil then
|
|
116
132
|
_condition = true
|
|
117
133
|
end
|
|
118
134
|
local usePlaceholder = _condition
|
|
135
|
+
local inputTypes = props.inputTypes or DEFAULT_INPUT_TYPES
|
|
119
136
|
local registrationRef = React.useRef()
|
|
120
|
-
local findDroppable = React.useCallback(function(
|
|
137
|
+
local findDroppable = React.useCallback(function(position)
|
|
121
138
|
local result
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
local _registryEntry = registry
|
|
126
|
-
if _registryEntry ~= nil then
|
|
127
|
-
_registryEntry = _registryEntry.get(guiObject, DroppableRegistryKey)
|
|
139
|
+
for _1, registryEntry in GlobalRegistry.getAll(DroppableRegistryKey) do
|
|
140
|
+
if not GuiHelper:isGuiObjectHitAtPoint(registryEntry.guiObject, position) then
|
|
141
|
+
continue
|
|
128
142
|
end
|
|
129
|
-
|
|
130
|
-
if registryEntry then
|
|
131
|
-
local _result = registryEntry
|
|
132
|
-
if _result ~= nil then
|
|
133
|
-
_result.drop(instance)
|
|
134
|
-
end
|
|
143
|
+
if result == nil or GuiHelper:isRenderedAbove(registryEntry.guiObject, result.guiObject) then
|
|
135
144
|
result = registryEntry
|
|
136
145
|
end
|
|
137
146
|
end
|
|
138
|
-
for _k, _v in _exp do
|
|
139
|
-
_callback(_v, _k - 1, _exp)
|
|
140
|
-
end
|
|
141
|
-
-- ▲ ReadonlyArray.forEach ▲
|
|
142
147
|
return result
|
|
143
|
-
end, {
|
|
144
|
-
local beginDrag = React.useCallback(function(input
|
|
148
|
+
end, {})
|
|
149
|
+
local beginDrag = React.useCallback(function(input)
|
|
145
150
|
local root = rootRef.current
|
|
146
151
|
local registration = registrationRef.current
|
|
147
|
-
if root == nil then
|
|
152
|
+
if root == nil or dragInformationRef.current ~= nil then
|
|
148
153
|
return nil
|
|
149
154
|
end
|
|
150
|
-
local
|
|
151
|
-
if
|
|
152
|
-
|
|
155
|
+
local _userInputType = input.UserInputType
|
|
156
|
+
if not (table.find(inputTypes, _userInputType) ~= nil) then
|
|
157
|
+
return nil
|
|
153
158
|
end
|
|
154
|
-
local allDraggables =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
_result_1 = true
|
|
165
|
-
break
|
|
166
|
-
end
|
|
159
|
+
local allDraggables = GlobalRegistry.getAll(DraggableRegistryKey)
|
|
160
|
+
-- ▼ ReadonlyArray.some ▼
|
|
161
|
+
local _result = false
|
|
162
|
+
local _callback = function(registration)
|
|
163
|
+
return registration.draggable.isDragging
|
|
164
|
+
end
|
|
165
|
+
for _k, _v in allDraggables do
|
|
166
|
+
if _callback(_v, _k - 1, allDraggables) then
|
|
167
|
+
_result = true
|
|
168
|
+
break
|
|
167
169
|
end
|
|
168
|
-
-- ▲ ReadonlyArray.some ▲
|
|
169
|
-
_result = _result_1
|
|
170
170
|
end
|
|
171
|
+
-- ▲ ReadonlyArray.some ▲
|
|
171
172
|
if _result then
|
|
172
173
|
return nil
|
|
173
174
|
end
|
|
174
175
|
if registration ~= nil then
|
|
175
176
|
registration.draggable.isDragging = true
|
|
176
177
|
end
|
|
177
|
-
|
|
178
|
+
local dragInformation = {
|
|
179
|
+
root = root,
|
|
178
180
|
input = input,
|
|
179
|
-
|
|
181
|
+
inputType = input.UserInputType,
|
|
182
|
+
keyCode = input.KeyCode,
|
|
183
|
+
inputStart = toPoint(input),
|
|
180
184
|
absolutePositionStart = root.AbsolutePosition,
|
|
181
185
|
positionStart = root.Position,
|
|
182
186
|
}
|
|
187
|
+
dragInformationRef.current = dragInformation
|
|
188
|
+
hoveredRef.current = nil
|
|
183
189
|
local _result_1 = props.onStartDrag
|
|
184
190
|
if _result_1 ~= nil then
|
|
185
|
-
_result_1()
|
|
191
|
+
_result_1(createDragEventInfo(input, dragInformation, props.id))
|
|
186
192
|
end
|
|
187
193
|
setDragging(true)
|
|
188
194
|
setOverlayPosition(root.AbsolutePosition)
|
|
@@ -193,23 +199,50 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
193
199
|
LayoutOrder = root.LayoutOrder,
|
|
194
200
|
ZIndex = root.ZIndex,
|
|
195
201
|
})
|
|
196
|
-
end, {
|
|
202
|
+
end, { props.onStartDrag, props.id, inputTypes })
|
|
197
203
|
local updateDrag = React.useCallback(function(input)
|
|
198
204
|
local root = rootRef.current
|
|
199
205
|
local dragInformation = dragInformationRef.current
|
|
200
206
|
if root == nil or dragInformation == nil then
|
|
201
207
|
return nil
|
|
202
208
|
end
|
|
203
|
-
local inputPosition =
|
|
209
|
+
local inputPosition = toPoint(input)
|
|
204
210
|
local _inputStart = dragInformation.inputStart
|
|
205
211
|
local delta = inputPosition - _inputStart
|
|
206
|
-
local
|
|
207
|
-
local
|
|
212
|
+
local info = createDragEventInfo(input, dragInformation, props.id)
|
|
213
|
+
local dropRegisteration = findDroppable(inputPosition)
|
|
214
|
+
local hovered = hoveredRef.current
|
|
215
|
+
local _result = hovered
|
|
208
216
|
if _result ~= nil then
|
|
209
|
-
_result
|
|
217
|
+
_result = _result.guiObject
|
|
218
|
+
end
|
|
219
|
+
local _result_1 = dropRegisteration
|
|
220
|
+
if _result_1 ~= nil then
|
|
221
|
+
_result_1 = _result_1.guiObject
|
|
222
|
+
end
|
|
223
|
+
if _result ~= _result_1 then
|
|
224
|
+
hoveredRef.current = dropRegisteration
|
|
225
|
+
local _result_2 = hovered
|
|
226
|
+
if _result_2 ~= nil then
|
|
227
|
+
_result_2 = _result_2.dragLeave
|
|
228
|
+
if _result_2 ~= nil then
|
|
229
|
+
_result_2(root, info)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
local _result_3 = dropRegisteration
|
|
233
|
+
if _result_3 ~= nil then
|
|
234
|
+
_result_3 = _result_3.dragEnter
|
|
235
|
+
if _result_3 ~= nil then
|
|
236
|
+
_result_3(root, info)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
local _result_2 = props.onDragged
|
|
241
|
+
if _result_2 ~= nil then
|
|
242
|
+
_result_2(dropRegisteration, info)
|
|
210
243
|
end
|
|
211
244
|
setOverlayPosition(dragInformation.absolutePositionStart + delta)
|
|
212
|
-
end, { findDroppable, props.onDragged })
|
|
245
|
+
end, { findDroppable, props.onDragged, props.id })
|
|
213
246
|
local endDrag = React.useCallback(function(input)
|
|
214
247
|
local root = rootRef.current
|
|
215
248
|
local dragInformation = dragInformationRef.current
|
|
@@ -217,23 +250,40 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
217
250
|
if root == nil or dragInformation == nil then
|
|
218
251
|
return nil
|
|
219
252
|
end
|
|
253
|
+
if input.UserInputType ~= dragInformation.inputType or input.KeyCode ~= dragInformation.keyCode then
|
|
254
|
+
return nil
|
|
255
|
+
end
|
|
220
256
|
if registration then
|
|
221
257
|
registration.draggable.isDragging = false
|
|
222
258
|
end
|
|
223
|
-
local
|
|
259
|
+
local inputPosition = toPoint(input)
|
|
260
|
+
local info = createDragEventInfo(input, dragInformation, props.id)
|
|
261
|
+
local dropRegisteration = findDroppable(inputPosition)
|
|
262
|
+
local hovered = hoveredRef.current
|
|
224
263
|
dragInformationRef.current = nil
|
|
225
|
-
|
|
264
|
+
hoveredRef.current = nil
|
|
265
|
+
local _result = dropRegisteration
|
|
226
266
|
if _result ~= nil then
|
|
227
|
-
_result(
|
|
267
|
+
_result.drop(root, info)
|
|
268
|
+
end
|
|
269
|
+
local _result_1 = hovered
|
|
270
|
+
if _result_1 ~= nil then
|
|
271
|
+
_result_1 = _result_1.dragLeave
|
|
272
|
+
if _result_1 ~= nil then
|
|
273
|
+
_result_1(root, info)
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
local _result_2 = props.onDropped
|
|
277
|
+
if _result_2 ~= nil then
|
|
278
|
+
_result_2(dropRegisteration, info)
|
|
228
279
|
end
|
|
229
280
|
if props.retainPosition then
|
|
230
281
|
local parent = root.Parent
|
|
231
|
-
local
|
|
232
|
-
if
|
|
233
|
-
|
|
282
|
+
local _result_3 = parent
|
|
283
|
+
if _result_3 ~= nil then
|
|
284
|
+
_result_3 = _result_3:IsA("GuiObject")
|
|
234
285
|
end
|
|
235
|
-
if
|
|
236
|
-
local inputPosition = Vector2.new(input.Position.X, input.Position.Y)
|
|
286
|
+
if _result_3 then
|
|
237
287
|
local _inputStart = dragInformation.inputStart
|
|
238
288
|
local delta = inputPosition - _inputStart
|
|
239
289
|
local finalOverlayPosition = dragInformation.absolutePositionStart + delta
|
|
@@ -246,10 +296,10 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
246
296
|
end
|
|
247
297
|
end
|
|
248
298
|
setDragging(false)
|
|
249
|
-
end, { findDroppable, props.onDropped, props.retainPosition })
|
|
299
|
+
end, { findDroppable, props.onDropped, props.retainPosition, props.id })
|
|
250
300
|
local contextValue = React.useMemo(function()
|
|
251
301
|
return {
|
|
252
|
-
isDragging =
|
|
302
|
+
isDragging = dragInformationRef.current ~= nil,
|
|
253
303
|
beginDrag = beginDrag,
|
|
254
304
|
updateDrag = updateDrag,
|
|
255
305
|
endDrag = endDrag,
|
|
@@ -257,7 +307,7 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
257
307
|
end, { beginDrag, updateDrag, endDrag })
|
|
258
308
|
React.useEffect(function()
|
|
259
309
|
local root = rootRef.current
|
|
260
|
-
if
|
|
310
|
+
if root == nil or parentDragState.preview then
|
|
261
311
|
return nil
|
|
262
312
|
end
|
|
263
313
|
local registration = {
|
|
@@ -266,14 +316,43 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
266
316
|
draggable = contextValue,
|
|
267
317
|
}
|
|
268
318
|
registrationRef.current = registration
|
|
269
|
-
|
|
319
|
+
local _result = registry
|
|
320
|
+
if _result ~= nil then
|
|
321
|
+
_result.register(root, DraggableRegistryKey, registration)
|
|
322
|
+
end
|
|
323
|
+
GlobalRegistry.register(root, DraggableRegistryKey, registration)
|
|
270
324
|
return function()
|
|
271
|
-
registry
|
|
325
|
+
local _result_1 = registry
|
|
326
|
+
if _result_1 ~= nil then
|
|
327
|
+
_result_1.unregister(registration.guiObject, DraggableRegistryKey)
|
|
328
|
+
end
|
|
329
|
+
if GlobalRegistry.get(registration.guiObject, DraggableRegistryKey) == registration then
|
|
330
|
+
GlobalRegistry.unregister(registration.guiObject, DraggableRegistryKey)
|
|
331
|
+
end
|
|
272
332
|
if registrationRef.current == registration then
|
|
273
333
|
registrationRef.current = nil
|
|
274
334
|
end
|
|
275
335
|
end
|
|
276
|
-
end, { registry, props.id, contextValue })
|
|
336
|
+
end, { registry, props.id, contextValue, parentDragState.preview })
|
|
337
|
+
React.useEffect(function()
|
|
338
|
+
return function()
|
|
339
|
+
local dragInformation = dragInformationRef.current
|
|
340
|
+
local hovered = hoveredRef.current
|
|
341
|
+
hoveredRef.current = nil
|
|
342
|
+
if dragInformation ~= nil and hovered ~= nil then
|
|
343
|
+
local _result = hovered.dragLeave
|
|
344
|
+
if _result ~= nil then
|
|
345
|
+
_result(dragInformation.root, createDragEventInfo(dragInformation.input, dragInformation, idRef.current))
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
end, {})
|
|
350
|
+
local dragStateValue = React.useMemo(function()
|
|
351
|
+
return {
|
|
352
|
+
preview = parentDragState.preview,
|
|
353
|
+
dragging = parentDragState.dragging or dragging,
|
|
354
|
+
}
|
|
355
|
+
end, { parentDragState.preview, parentDragState.dragging, dragging })
|
|
277
356
|
local original = React.cloneElement(props.children, {
|
|
278
357
|
ref = rootRef,
|
|
279
358
|
Visible = not dragging,
|
|
@@ -290,21 +369,35 @@ local Draggable = React.forwardRef(function(props, _ref)
|
|
|
290
369
|
}))
|
|
291
370
|
return React.createElement(DraggableContext.Provider, {
|
|
292
371
|
value = contextValue,
|
|
293
|
-
},
|
|
372
|
+
}, React.createElement(DragStateContext.Provider, {
|
|
373
|
+
value = dragStateValue,
|
|
374
|
+
}, usePlaceholder and dragging and placeholder, original), React.createElement(OverlayConsumer, {
|
|
294
375
|
render = function(overlay)
|
|
295
376
|
if not dragging or overlay == nil then
|
|
296
377
|
return nil
|
|
297
378
|
end
|
|
298
379
|
local _absolutePosition = overlay.AbsolutePosition
|
|
299
380
|
local localPosition = overlayPosition - _absolutePosition
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
381
|
+
local position = UDim2.fromOffset(localPosition.X, localPosition.Y)
|
|
382
|
+
local size = UDim2.fromOffset(overlaySize.X, overlaySize.Y)
|
|
383
|
+
local preview = if props.renderOverlay ~= nil then (React.createElement("frame", {
|
|
384
|
+
key = "DragOverlay",
|
|
385
|
+
Position = position,
|
|
386
|
+
Size = size,
|
|
387
|
+
BackgroundTransparency = 1,
|
|
388
|
+
BorderSizePixel = 0,
|
|
389
|
+
ZIndex = 100001,
|
|
390
|
+
}, props.renderOverlay())) else React.cloneElement(props.children, {
|
|
391
|
+
Position = position,
|
|
392
|
+
Size = size,
|
|
303
393
|
AnchorPoint = Vector2.zero,
|
|
304
394
|
AutomaticSize = Enum.AutomaticSize.None,
|
|
305
395
|
Visible = true,
|
|
306
396
|
ZIndex = 100001,
|
|
307
|
-
})
|
|
397
|
+
})
|
|
398
|
+
return createPortal(React.createElement(DragStateContext.Provider, {
|
|
399
|
+
value = PREVIEW_DRAG_STATE,
|
|
400
|
+
}, preview), overlay)
|
|
308
401
|
end,
|
|
309
402
|
}))
|
|
310
403
|
end)
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
+
import { DragEventInfo } from "../../Contexts";
|
|
2
3
|
type GuiObjectProps = React.InstanceProps<GuiObject>;
|
|
3
4
|
type GuiElement = React.ReactElement<GuiObjectProps>;
|
|
4
|
-
interface DroppableProps {
|
|
5
|
+
export interface DroppableProps {
|
|
5
6
|
id?: string;
|
|
6
7
|
children: GuiElement;
|
|
7
|
-
onDrop?: (draggedObject: GuiObject) => void;
|
|
8
|
+
onDrop?: (draggedObject: GuiObject, info?: DragEventInfo) => void;
|
|
9
|
+
onDragEnter?: (draggedObject: GuiObject, info: DragEventInfo) => void;
|
|
10
|
+
onDragLeave?: (draggedObject: GuiObject, info: DragEventInfo) => void;
|
|
8
11
|
}
|
|
9
12
|
export declare function Droppable(props: DroppableProps): React.JSX.Element;
|
|
10
13
|
export {};
|
|
@@ -3,25 +3,65 @@ local TS = _G[script]
|
|
|
3
3
|
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
4
|
local _ = TS.import(script, script.Parent.Parent.Parent, "Providers")
|
|
5
5
|
local DroppableRegistryKey = _.DroppableRegistryKey
|
|
6
|
-
local
|
|
7
|
-
local
|
|
6
|
+
local GlobalRegistry = _.GlobalRegistry
|
|
7
|
+
local RegistryContext = _.RegistryContext
|
|
8
|
+
local _Contexts = TS.import(script, script.Parent.Parent.Parent, "Contexts")
|
|
9
|
+
local DragStateContext = _Contexts.DragStateContext
|
|
10
|
+
local DroppableContext = _Contexts.DroppableContext
|
|
8
11
|
local function Droppable(props)
|
|
9
|
-
local
|
|
12
|
+
local registry = React.useContext(RegistryContext)
|
|
13
|
+
local dragState = React.useContext(DragStateContext)
|
|
14
|
+
local guiObject, setGuiObject = React.useState()
|
|
15
|
+
local propsRef = React.useRef(props)
|
|
16
|
+
propsRef.current = props
|
|
17
|
+
local registration = React.useMemo(function()
|
|
18
|
+
if guiObject == nil then
|
|
19
|
+
return nil
|
|
20
|
+
end
|
|
10
21
|
return {
|
|
11
22
|
guiObject = guiObject,
|
|
12
23
|
id = props.id,
|
|
13
|
-
drop = function(draggedObject)
|
|
14
|
-
local _result =
|
|
24
|
+
drop = function(draggedObject, info)
|
|
25
|
+
local _result = propsRef.current.onDrop
|
|
15
26
|
if _result ~= nil then
|
|
16
|
-
_result(draggedObject)
|
|
27
|
+
_result(draggedObject, info)
|
|
28
|
+
end
|
|
29
|
+
end,
|
|
30
|
+
dragEnter = function(draggedObject, info)
|
|
31
|
+
local _result = propsRef.current.onDragEnter
|
|
32
|
+
if _result ~= nil then
|
|
33
|
+
_result(draggedObject, info)
|
|
34
|
+
end
|
|
35
|
+
end,
|
|
36
|
+
dragLeave = function(draggedObject, info)
|
|
37
|
+
local _result = propsRef.current.onDragLeave
|
|
38
|
+
if _result ~= nil then
|
|
39
|
+
_result(draggedObject, info)
|
|
17
40
|
end
|
|
18
41
|
end,
|
|
19
42
|
}
|
|
20
|
-
end, {
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
end, { guiObject, props.id })
|
|
44
|
+
React.useEffect(function()
|
|
45
|
+
if registration == nil or dragState.preview then
|
|
46
|
+
return nil
|
|
47
|
+
end
|
|
48
|
+
local _result = registry
|
|
49
|
+
if _result ~= nil then
|
|
50
|
+
_result.register(registration.guiObject, DroppableRegistryKey, registration)
|
|
51
|
+
end
|
|
52
|
+
GlobalRegistry.register(registration.guiObject, DroppableRegistryKey, registration)
|
|
53
|
+
return function()
|
|
54
|
+
local _result_1 = registry
|
|
55
|
+
if _result_1 ~= nil then
|
|
56
|
+
_result_1.unregister(registration.guiObject, DroppableRegistryKey)
|
|
57
|
+
end
|
|
58
|
+
if GlobalRegistry.get(registration.guiObject, DroppableRegistryKey) == registration then
|
|
59
|
+
GlobalRegistry.unregister(registration.guiObject, DroppableRegistryKey)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end, { registry, registration, dragState.preview })
|
|
23
63
|
local child = React.cloneElement(props.children, {
|
|
24
|
-
ref =
|
|
64
|
+
ref = setGuiObject,
|
|
25
65
|
})
|
|
26
66
|
return React.createElement(DroppableContext.Provider, {
|
|
27
67
|
value = {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { PositionElementProps, SizeElementProps, ZIndexElementProps } from "../../Interfaces/";
|
|
3
|
+
export interface FadeGroupProps extends SizeElementProps, PositionElementProps, ZIndexElementProps, React.InstanceProps<CanvasGroup> {
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const FadeGroup: React.ForwardRefExoticComponent<Omit<FadeGroupProps, "ref"> & React.RefAttributes<CanvasGroup>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local SizeHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").SizeHelper
|
|
5
|
+
local FadeGroup = React.forwardRef(function(props, ref)
|
|
6
|
+
local _attributes = {}
|
|
7
|
+
local _condition = props.name
|
|
8
|
+
if _condition == nil then
|
|
9
|
+
_condition = "FadeGroup"
|
|
10
|
+
end
|
|
11
|
+
_attributes.key = _condition
|
|
12
|
+
_attributes.ref = ref
|
|
13
|
+
_attributes.Archivable = props.Archivable
|
|
14
|
+
_attributes.Tag = props.Tag
|
|
15
|
+
_attributes.Active = props.Active
|
|
16
|
+
_attributes.AnchorPoint = SizeHelper:GetAnchor(props)
|
|
17
|
+
_attributes.AutomaticSize = SizeHelper:GetAutoSize(props)
|
|
18
|
+
_attributes.BackgroundColor3 = props.BackgroundColor3
|
|
19
|
+
local _condition_1 = props.BackgroundTransparency
|
|
20
|
+
if _condition_1 == nil then
|
|
21
|
+
_condition_1 = 1
|
|
22
|
+
end
|
|
23
|
+
_attributes.BackgroundTransparency = _condition_1
|
|
24
|
+
_attributes.BorderColor3 = props.BorderColor3
|
|
25
|
+
_attributes.BorderMode = props.BorderMode
|
|
26
|
+
_attributes.BorderSizePixel = if props.BorderSizePixel == nil then 0 else props.BorderSizePixel
|
|
27
|
+
_attributes.ClipsDescendants = props.ClipsDescendants
|
|
28
|
+
_attributes.GroupColor3 = props.GroupColor3
|
|
29
|
+
local _condition_2 = props.GroupTransparency
|
|
30
|
+
if _condition_2 == nil then
|
|
31
|
+
_condition_2 = 0
|
|
32
|
+
end
|
|
33
|
+
_attributes.GroupTransparency = _condition_2
|
|
34
|
+
_attributes.Interactable = props.Interactable
|
|
35
|
+
_attributes.LayoutOrder = props.LayoutOrder
|
|
36
|
+
_attributes.NextSelectionDown = props.NextSelectionDown
|
|
37
|
+
_attributes.NextSelectionLeft = props.NextSelectionLeft
|
|
38
|
+
_attributes.NextSelectionRight = props.NextSelectionRight
|
|
39
|
+
_attributes.NextSelectionUp = props.NextSelectionUp
|
|
40
|
+
_attributes.Position = SizeHelper:GetPosition(props)
|
|
41
|
+
_attributes.Rotation = props.Rotation
|
|
42
|
+
_attributes.Selectable = props.Selectable
|
|
43
|
+
_attributes.SelectionGroup = props.SelectionGroup
|
|
44
|
+
_attributes.SelectionImageObject = props.SelectionImageObject
|
|
45
|
+
_attributes.SelectionOrder = props.SelectionOrder
|
|
46
|
+
_attributes.Size = SizeHelper:GetSize(props, UDim2.fromOffset(0, 0))
|
|
47
|
+
_attributes.SizeConstraint = props.SizeConstraint
|
|
48
|
+
_attributes.Visible = props.Visible
|
|
49
|
+
_attributes.ZIndex = props.ZIndex
|
|
50
|
+
_attributes.AutoLocalize = props.AutoLocalize
|
|
51
|
+
_attributes.RootLocalizationTable = props.RootLocalizationTable
|
|
52
|
+
_attributes.Change = props.Change
|
|
53
|
+
_attributes.Event = props.Event
|
|
54
|
+
return React.createElement("canvasgroup", _attributes, props.children)
|
|
55
|
+
end)
|
|
56
|
+
return {
|
|
57
|
+
FadeGroup = FadeGroup,
|
|
58
|
+
}
|
|
@@ -13,10 +13,10 @@ interface GroupElementProps {
|
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
name?: string;
|
|
15
15
|
}
|
|
16
|
-
declare function GroupElement(props: GroupElementProps): boolean |
|
|
16
|
+
declare function GroupElement(props: GroupElementProps): boolean | ReadonlyMap<React.Key, React.ReactNode> | {
|
|
17
17
|
readonly [key: string]: React.ReactNode;
|
|
18
18
|
readonly [key: number]: React.ReactNode;
|
|
19
|
-
} | readonly React.ReactNode[] | undefined;
|
|
19
|
+
} | readonly React.ReactNode[] | React.JSX.Element | undefined;
|
|
20
20
|
interface GroupProps {
|
|
21
21
|
children?: React.ReactNode;
|
|
22
22
|
BackgroundTransparency?: number;
|
|
@@ -20,6 +20,7 @@ interface TabsBodyProps extends ScalableElementProps {
|
|
|
20
20
|
backgroundImage?: CssBackgroundImage;
|
|
21
21
|
backgroundGradient?: CssBackgroundGradient;
|
|
22
22
|
children?: React.ReactNode;
|
|
23
|
+
LayoutOrder?: number;
|
|
23
24
|
}
|
|
24
25
|
declare const TabsBody: React.ForwardRefExoticComponent<TabsBodyProps & React.RefAttributes<ImageLabel>>;
|
|
25
26
|
export interface TabsProps {
|
|
@@ -216,6 +216,7 @@ local TabsBody = React.forwardRef(function(props, ref)
|
|
|
216
216
|
name = "TabsBody",
|
|
217
217
|
ref = ref,
|
|
218
218
|
width = "100%",
|
|
219
|
+
LayoutOrder = props.LayoutOrder,
|
|
219
220
|
backgroundImage = props.backgroundImage or theme.components.tabs.backgroundImage,
|
|
220
221
|
}, theme.components.tabs.borderThickness > 0 and (React.createElement("uistroke", {
|
|
221
222
|
key = "Stroke",
|
|
@@ -19,6 +19,9 @@ end
|
|
|
19
19
|
for _k, _v in TS.import(script, script, "Droppable") or {} do
|
|
20
20
|
exports[_k] = _v
|
|
21
21
|
end
|
|
22
|
+
for _k, _v in TS.import(script, script, "FadeGroup") or {} do
|
|
23
|
+
exports[_k] = _v
|
|
24
|
+
end
|
|
22
25
|
for _k, _v in TS.import(script, script, "Fieldset") or {} do
|
|
23
26
|
exports[_k] = _v
|
|
24
27
|
end
|
|
@@ -8,9 +8,7 @@ interface CardHeaderProps extends IntentElementProps, PositionElementProps, ZInd
|
|
|
8
8
|
resolvedPadding?: ResolvedPadding;
|
|
9
9
|
}
|
|
10
10
|
export declare const CardHeader: React.ForwardRefExoticComponent<CardHeaderProps & React.RefAttributes<ImageLabel>>;
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export declare const CardBody: React.ForwardRefExoticComponent<Omit<CardBodyProps, "ref"> & React.RefAttributes<ImageLabel>>;
|
|
11
|
+
export declare const CardBody: React.ForwardRefExoticComponent<Omit<BoxProps, "ref"> & React.RefAttributes<ImageLabel>>;
|
|
14
12
|
interface CardFooterProps extends BoxProps, IntentElementProps {
|
|
15
13
|
overlay?: boolean;
|
|
16
14
|
padding?: CssPadding;
|