@rbxts/react-clean-ui 1.0.12 → 1.0.19
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/Pie.d.ts +27 -0
- package/out/Components/Chart/Pie.luau +281 -0
- package/out/Components/Chart/index.d.ts +1 -0
- package/out/Components/Chart/init.luau +7 -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/Layout/Column.d.ts +2 -8
- package/out/Components/Layout/Column.luau +28 -48
- 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/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/Navigation/Menu.d.ts +6 -10
- package/out/Components/Navigation/Menu.luau +38 -65
- package/out/Components/Surface/Card.d.ts +8 -11
- package/out/Components/Surface/Card.luau +28 -48
- package/out/Components/Surface/index.d.ts +0 -1
- package/out/Components/Surface/init.luau +0 -3
- package/out/Components/index.d.ts +1 -0
- package/out/Components/init.luau +3 -0
- 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 +5 -0
- package/out/Providers/registry.provider.d.ts +1 -0
- package/out/Providers/registry.provider.luau +5 -0
- package/out/Theme/theme.template.d.ts +15 -1
- package/out/Theme/themes/dark.theme.luau +3 -0
- package/out/Theme/themes/default.theme.luau +15 -0
- package/out/Theme/themes/sandstone.theme.luau +13 -0
- package/package.json +1 -1
- package/out/Components/Surface/Panel.d.ts +0 -4
- package/out/Components/Surface/Panel.luau +0 -33
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { RowContext } from "../../Contexts/";
|
|
1
|
+
import React from "@rbxts/react";
|
|
3
2
|
import { ResponsiveGridSpan } from "../../Interfaces/";
|
|
4
3
|
interface ColumnProps {
|
|
5
4
|
span?: ResponsiveGridSpan | number | `${number}`;
|
|
6
5
|
}
|
|
7
|
-
export declare
|
|
8
|
-
static contextType: React.Context<import("../../Contexts/row.context").RowContextValue>;
|
|
9
|
-
context: React.ContextType<typeof RowContext>;
|
|
10
|
-
private getSpan;
|
|
11
|
-
render(): React.JSX.Element;
|
|
12
|
-
}
|
|
6
|
+
export declare const Column: React.ForwardRefExoticComponent<ColumnProps & React.RefAttributes<Frame>>;
|
|
13
7
|
export {};
|
|
@@ -1,60 +1,40 @@
|
|
|
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 RowContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").RowContext
|
|
8
5
|
local BreakpointHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").BreakpointHelper
|
|
9
|
-
local
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Column = setmetatable({}, {
|
|
13
|
-
__tostring = function()
|
|
14
|
-
return "Column"
|
|
15
|
-
end,
|
|
16
|
-
__index = super,
|
|
17
|
-
})
|
|
18
|
-
Column.__index = Column
|
|
19
|
-
function Column.new(...)
|
|
20
|
-
local self = setmetatable({}, Column)
|
|
21
|
-
return self:constructor(...) or self
|
|
6
|
+
local function resolveSpan(span, children, breakpoint)
|
|
7
|
+
if span == nil then
|
|
8
|
+
return math.floor(12 / math.max(children, 1))
|
|
22
9
|
end
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
local _span = span
|
|
11
|
+
if type(_span) == "number" then
|
|
12
|
+
return span
|
|
25
13
|
end
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
local _span_1 = span
|
|
15
|
+
if type(_span_1) == "string" then
|
|
16
|
+
local _condition = tonumber(span)
|
|
17
|
+
if _condition == nil then
|
|
18
|
+
_condition = 12
|
|
30
19
|
end
|
|
31
|
-
|
|
32
|
-
return span
|
|
33
|
-
end
|
|
34
|
-
if type(span) == "string" then
|
|
35
|
-
local _condition = tonumber(span)
|
|
36
|
-
if _condition == nil then
|
|
37
|
-
_condition = 12
|
|
38
|
-
end
|
|
39
|
-
return _condition
|
|
40
|
-
end
|
|
41
|
-
return BreakpointHelper:getValue(self.context.breakpoint, span) or 12
|
|
42
|
-
end
|
|
43
|
-
function Column:render()
|
|
44
|
-
local span = self:getSpan()
|
|
45
|
-
local fraction = math.floor((span / 12) * 1000) / 1000
|
|
46
|
-
local padding = self.context.padding
|
|
47
|
-
local widthScale = fraction + ((fraction - 1) * padding.Scale)
|
|
48
|
-
local widthOffset = (fraction - 1) * padding.Offset
|
|
49
|
-
return React.createElement("frame", {
|
|
50
|
-
Size = UDim2.new(widthScale, widthOffset, 0, 0),
|
|
51
|
-
AutomaticSize = Enum.AutomaticSize.Y,
|
|
52
|
-
BackgroundTransparency = 1,
|
|
53
|
-
}, self.props.children)
|
|
20
|
+
return _condition
|
|
54
21
|
end
|
|
55
|
-
|
|
56
|
-
Column = ReactComponent(Column) or Column
|
|
22
|
+
return BreakpointHelper:getValue(breakpoint, span) or 12
|
|
57
23
|
end
|
|
24
|
+
local Column = React.forwardRef(function(props, ref)
|
|
25
|
+
local context = React.useContext(RowContext)
|
|
26
|
+
local span = resolveSpan(props.span, context.children, context.breakpoint)
|
|
27
|
+
local fraction = math.floor((span / 12) * 1000) / 1000
|
|
28
|
+
local padding = context.padding
|
|
29
|
+
local widthScale = fraction + ((fraction - 1) * padding.Scale)
|
|
30
|
+
local widthOffset = (fraction - 1) * padding.Offset
|
|
31
|
+
return React.createElement("frame", {
|
|
32
|
+
ref = ref,
|
|
33
|
+
Size = UDim2.new(widthScale, widthOffset, 0, 0),
|
|
34
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
35
|
+
BackgroundTransparency = 1,
|
|
36
|
+
}, props.children)
|
|
37
|
+
end)
|
|
58
38
|
return {
|
|
59
39
|
Column = Column,
|
|
60
40
|
}
|
|
@@ -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 };
|