@rbxts/uiblox 0.2.0-alpha.22 → 0.2.0-alpha.23

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.
Files changed (30) hide show
  1. package/out/ui/packages/cframeEditor/components/CFrameEditor.luau +64 -38
  2. package/out/ui/packages/cframeEditor/components/CFrameEditor.styles.luau +26 -9
  3. package/out/ui/packages/checkbox/components/checkboxLook.d.ts +1 -1
  4. package/out/ui/packages/colorPicker/components/ColorPicker.luau +3 -3
  5. package/out/ui/packages/colorPicker/components/ColorPicker.styles.luau +34 -20
  6. package/out/ui/packages/colorPicker/components/ColorSequenceEditor.luau +23 -20
  7. package/out/ui/packages/colorPicker/components/NumberSequenceEditor.luau +54 -47
  8. package/out/ui/packages/gradientEditor/components/GradientEditor.luau +45 -27
  9. package/out/ui/packages/gradientEditor/components/GradientEditor.styles.luau +37 -4
  10. package/out/ui/packages/imageList/components/ImageList.luau +1 -1
  11. package/out/ui/packages/index.d.ts +1 -0
  12. package/out/ui/packages/init.luau +3 -0
  13. package/out/ui/packages/markdown/components/Markdown.d.ts +6 -0
  14. package/out/ui/packages/markdown/components/Markdown.luau +228 -0
  15. package/out/ui/packages/markdown/components/Markdown.styles.d.ts +2 -0
  16. package/out/ui/packages/markdown/components/Markdown.styles.luau +101 -0
  17. package/out/ui/packages/markdown/components/MarkdownEditor.d.ts +16 -0
  18. package/out/ui/packages/markdown/components/MarkdownEditor.luau +322 -0
  19. package/out/ui/packages/markdown/components/MarkdownEditor.styles.d.ts +6 -0
  20. package/out/ui/packages/markdown/components/MarkdownEditor.styles.luau +132 -0
  21. package/out/ui/packages/markdown/htmlToMarkdown.d.ts +2 -0
  22. package/out/ui/packages/markdown/htmlToMarkdown.luau +350 -0
  23. package/out/ui/packages/markdown/index.d.ts +8 -0
  24. package/out/ui/packages/markdown/init.luau +11 -0
  25. package/out/ui/packages/markdown/parseMarkdown.d.ts +42 -0
  26. package/out/ui/packages/markdown/parseMarkdown.luau +459 -0
  27. package/out/ui/packages/splitPane/components/splitLook.d.ts +1 -1
  28. package/out/ui/packages/stateMatrix.luau +42 -1
  29. package/out/ui/packages/switch/components/switchLook.d.ts +1 -1
  30. package/package.json +2 -2
@@ -0,0 +1,322 @@
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 React = _react
5
+ local useEffect = _react.useEffect
6
+ local useRef = _react.useRef
7
+ local useState = _react.useState
8
+ local useTheme = TS.import(script, script.Parent.Parent.Parent.Parent.Parent, "theme").useTheme
9
+ local Button = TS.import(script, script.Parent.Parent.Parent, "button").Button
10
+ local IconButton = TS.import(script, script.Parent.Parent.Parent, "iconButton").IconButton
11
+ local Icons = TS.import(script, script.Parent.Parent.Parent.Parent, "enums").Icons
12
+ local ToggleButtonGroup = TS.import(script, script.Parent.Parent.Parent, "toggleButton").ToggleButtonGroup
13
+ local htmlToMarkdown = TS.import(script, script.Parent.Parent, "htmlToMarkdown").htmlToMarkdown
14
+ local Markdown = TS.import(script, script.Parent, "Markdown").default
15
+ local useMarkdownEditorStyles = TS.import(script, script.Parent, "MarkdownEditor.styles").default
16
+ local MODE_OPTIONS = { {
17
+ label = "Split",
18
+ value = "split",
19
+ }, {
20
+ label = "Edit",
21
+ value = "edit",
22
+ }, {
23
+ label = "Preview",
24
+ value = "preview",
25
+ } }
26
+ local function looksLikeHtml(text)
27
+ local lower = string.lower(text)
28
+ return (string.find(lower, "<p", 1, true)) ~= nil or (string.find(lower, "<h1", 1, true)) ~= nil or (string.find(lower, "<h2", 1, true)) ~= nil or (string.find(lower, "<div", 1, true)) ~= nil or (string.find(lower, "<ul", 1, true)) ~= nil or (string.find(lower, "<ol", 1, true)) ~= nil or (string.find(lower, "<pre", 1, true)) ~= nil or (string.find(lower, "<blockquote", 1, true)) ~= nil or (string.find(lower, "<strong", 1, true)) ~= nil
29
+ end
30
+ local function MarkdownEditor(props)
31
+ local _binding = props
32
+ local value = _binding.value
33
+ local onChange = _binding.onChange
34
+ local modeProp = _binding.mode
35
+ local onModeChange = _binding.onModeChange
36
+ local fullscreenProp = _binding.fullscreen
37
+ local onFullscreenChange = _binding.onFullscreenChange
38
+ local preview = _binding.preview
39
+ local placeholder = _binding.placeholder
40
+ if placeholder == nil then
41
+ placeholder = "Write markdown…"
42
+ end
43
+ local className = _binding.className
44
+ local sx = _binding.sx
45
+ local id = _binding.id
46
+ local ref = _binding.ref
47
+ local _binding_1 = useTheme()
48
+ local theme = _binding_1.theme
49
+ local modeState, setModeState = useState("split")
50
+ local fullscreenState, setFullscreenState = useState(false)
51
+ local draft, setDraft = useState(value)
52
+ local htmlDraft, setHtmlDraft = useState(nil)
53
+ local focused = useRef(false)
54
+ local mode = modeProp or modeState
55
+ local _condition = fullscreenProp
56
+ if _condition == nil then
57
+ _condition = fullscreenState
58
+ end
59
+ local fullscreen = _condition
60
+ local compact = theme.density == "compact"
61
+ local styles = useMarkdownEditorStyles({
62
+ fullscreen = fullscreen,
63
+ compact = compact,
64
+ })
65
+ useEffect(function()
66
+ if not focused.current then
67
+ setDraft(value)
68
+ end
69
+ end, { value })
70
+ local setMode = function(modeNext)
71
+ if modeProp == nil then
72
+ setModeState(modeNext)
73
+ end
74
+ local _result = onModeChange
75
+ if _result ~= nil then
76
+ _result(modeNext)
77
+ end
78
+ end
79
+ local setFullscreen = function(fullNext)
80
+ if fullscreenProp == nil then
81
+ setFullscreenState(fullNext)
82
+ end
83
+ local _result = onFullscreenChange
84
+ if _result ~= nil then
85
+ _result(fullNext)
86
+ end
87
+ end
88
+ local showEdit = mode == "split" or mode == "edit"
89
+ local showPreview = mode == "split" or mode == "preview"
90
+ local previewNode = if preview ~= nil then preview(value) else React.createElement(Markdown, {
91
+ value = value,
92
+ })
93
+ local _attributes = {}
94
+ local _condition_1 = id
95
+ if not (_condition_1 ~= 0 and _condition_1 == _condition_1 and _condition_1 ~= "" and _condition_1) then
96
+ _condition_1 = "MarkdownEditor"
97
+ end
98
+ _attributes.key = _condition_1
99
+ _attributes.ref = ref
100
+ for _k, _v in styles.root do
101
+ _attributes[_k] = _v
102
+ end
103
+ if className then
104
+ for _k, _v in className do
105
+ _attributes[_k] = _v
106
+ end
107
+ end
108
+ if sx then
109
+ for _k, _v in sx do
110
+ _attributes[_k] = _v
111
+ end
112
+ end
113
+ local _attributes_1 = table.clone(styles.corner)
114
+ setmetatable(_attributes_1, nil)
115
+ local _exp = React.createElement("uicorner", _attributes_1)
116
+ local _attributes_2 = table.clone(styles.stroke)
117
+ setmetatable(_attributes_2, nil)
118
+ local _exp_1 = React.createElement("uistroke", _attributes_2)
119
+ local _attributes_3 = table.clone(styles.layout)
120
+ setmetatable(_attributes_3, nil)
121
+ local _exp_2 = React.createElement("uilistlayout", _attributes_3)
122
+ local _attributes_4 = {
123
+ key = "Toolbar",
124
+ }
125
+ for _k, _v in styles.toolbar do
126
+ _attributes_4[_k] = _v
127
+ end
128
+ local _attributes_5 = table.clone(styles.toolbarPad)
129
+ setmetatable(_attributes_5, nil)
130
+ local _exp_3 = React.createElement("uipadding", _attributes_5)
131
+ local _attributes_6 = table.clone(styles.toolbarRow)
132
+ setmetatable(_attributes_6, nil)
133
+ local _exp_4 = React.createElement("frame", _attributes_4, _exp_3, React.createElement("uilistlayout", _attributes_6), React.createElement(ToggleButtonGroup, {
134
+ value = mode,
135
+ options = MODE_OPTIONS,
136
+ size = if compact then "small" else "medium",
137
+ onChange = setMode,
138
+ className = {
139
+ LayoutOrder = 1,
140
+ AutomaticSize = Enum.AutomaticSize.XY,
141
+ Size = UDim2.fromScale(0, 0),
142
+ },
143
+ }), React.createElement(Button, {
144
+ text = "Paste HTML",
145
+ variant = "text",
146
+ size = if compact then "small" else "medium",
147
+ className = {
148
+ LayoutOrder = 2,
149
+ AutomaticSize = Enum.AutomaticSize.XY,
150
+ Size = UDim2.fromScale(0, 0),
151
+ },
152
+ onLeftClick = function()
153
+ if looksLikeHtml(value) then
154
+ onChange(htmlToMarkdown(value))
155
+ else
156
+ setHtmlDraft("")
157
+ end
158
+ end,
159
+ }), React.createElement(IconButton, {
160
+ icon = Icons.Expanded,
161
+ size = "sm",
162
+ tint = theme.palette.text.secondary,
163
+ selected = fullscreen,
164
+ onClick = function()
165
+ return setFullscreen(not fullscreen)
166
+ end,
167
+ className = {
168
+ LayoutOrder = 99,
169
+ },
170
+ }))
171
+ local _exp_5 = htmlDraft ~= nil and (React.createElement("frame", {
172
+ key = "HtmlPaste",
173
+ Size = UDim2.new(1, 0, 0, 96),
174
+ BackgroundColor3 = theme.palette.surface.elevated,
175
+ BorderSizePixel = 0,
176
+ LayoutOrder = 1,
177
+ }, React.createElement("uipadding", {
178
+ PaddingTop = UDim.new(0, theme.padding.calc(1)),
179
+ PaddingBottom = UDim.new(0, theme.padding.calc(1)),
180
+ PaddingLeft = UDim.new(0, theme.padding.calc(1)),
181
+ PaddingRight = UDim.new(0, theme.padding.calc(1)),
182
+ }), React.createElement("uilistlayout", {
183
+ FillDirection = Enum.FillDirection.Vertical,
184
+ SortOrder = Enum.SortOrder.LayoutOrder,
185
+ Padding = UDim.new(0, theme.padding.calc(1)),
186
+ }), React.createElement("textbox", {
187
+ key = "HtmlField",
188
+ Size = UDim2.new(1, 0, 0, 48),
189
+ BackgroundColor3 = theme.palette.surface.input,
190
+ BorderSizePixel = 0,
191
+ ClearTextOnFocus = false,
192
+ MultiLine = true,
193
+ Text = htmlDraft,
194
+ PlaceholderText = "Paste HTML here",
195
+ TextXAlignment = Enum.TextXAlignment.Left,
196
+ TextYAlignment = Enum.TextYAlignment.Top,
197
+ TextSize = theme.typography.fontSizes.caption,
198
+ TextColor3 = theme.palette.text.primary,
199
+ Font = Enum.Font.RobotoMono,
200
+ Change = {
201
+ Text = function(rbx)
202
+ return setHtmlDraft(rbx.Text)
203
+ end,
204
+ },
205
+ LayoutOrder = 1,
206
+ }), React.createElement("frame", {
207
+ key = "HtmlActions",
208
+ Size = UDim2.new(1, 0, 0, 28),
209
+ BackgroundTransparency = 1,
210
+ LayoutOrder = 2,
211
+ }, React.createElement("uilistlayout", {
212
+ FillDirection = Enum.FillDirection.Horizontal,
213
+ Padding = UDim.new(0, theme.padding.calc(1)),
214
+ SortOrder = Enum.SortOrder.LayoutOrder,
215
+ }), React.createElement(Button, {
216
+ text = "Convert",
217
+ size = "small",
218
+ className = {
219
+ LayoutOrder = 1,
220
+ AutomaticSize = Enum.AutomaticSize.XY,
221
+ Size = UDim2.fromScale(0, 0),
222
+ },
223
+ onLeftClick = function()
224
+ onChange(htmlToMarkdown(htmlDraft))
225
+ setHtmlDraft(nil)
226
+ setMode("preview")
227
+ end,
228
+ }), React.createElement(Button, {
229
+ text = "Cancel",
230
+ variant = "text",
231
+ size = "small",
232
+ className = {
233
+ LayoutOrder = 2,
234
+ AutomaticSize = Enum.AutomaticSize.XY,
235
+ Size = UDim2.fromScale(0, 0),
236
+ },
237
+ onLeftClick = function()
238
+ return setHtmlDraft(nil)
239
+ end,
240
+ }))))
241
+ local _attributes_7 = {
242
+ key = "Body",
243
+ }
244
+ for _k, _v in styles.body do
245
+ _attributes_7[_k] = _v
246
+ end
247
+ _attributes_7.LayoutOrder = 3
248
+ local _condition_2 = mode == "split"
249
+ if _condition_2 then
250
+ local _attributes_8 = table.clone(styles.split)
251
+ setmetatable(_attributes_8, nil)
252
+ _condition_2 = React.createElement("uilistlayout", _attributes_8)
253
+ end
254
+ local _condition_3 = showEdit
255
+ if _condition_3 then
256
+ local _attributes_8 = {
257
+ key = "EditPane",
258
+ }
259
+ for _k, _v in (if mode == "split" then styles.pane else styles.paneFull) do
260
+ _attributes_8[_k] = _v
261
+ end
262
+ _attributes_8.LayoutOrder = 1
263
+ local _attributes_9 = {
264
+ key = "Editor",
265
+ }
266
+ for _k, _v in styles.editor do
267
+ _attributes_9[_k] = _v
268
+ end
269
+ _attributes_9.Text = draft
270
+ _attributes_9.PlaceholderText = placeholder
271
+ _attributes_9.Change = {
272
+ Text = function(rbx)
273
+ setDraft(rbx.Text)
274
+ if focused.current and rbx.Text ~= value then
275
+ onChange(rbx.Text)
276
+ end
277
+ end,
278
+ }
279
+ _attributes_9.Event = {
280
+ Focused = function()
281
+ focused.current = true
282
+ end,
283
+ FocusLost = function(rbx)
284
+ focused.current = false
285
+ setDraft(rbx.Text)
286
+ onChange(rbx.Text)
287
+ end,
288
+ }
289
+ local _attributes_10 = table.clone(styles.editorPad)
290
+ setmetatable(_attributes_10, nil)
291
+ _condition_3 = (React.createElement("frame", _attributes_8, React.createElement("textbox", _attributes_9, React.createElement("uipadding", _attributes_10))))
292
+ end
293
+ local _condition_4 = mode == "split"
294
+ if _condition_4 then
295
+ local _attributes_8 = {
296
+ key = "SplitRule",
297
+ }
298
+ for _k, _v in styles.divider do
299
+ _attributes_8[_k] = _v
300
+ end
301
+ _condition_4 = React.createElement("frame", _attributes_8)
302
+ end
303
+ local _condition_5 = showPreview
304
+ if _condition_5 then
305
+ local _attributes_8 = {
306
+ key = "PreviewPane",
307
+ }
308
+ for _k, _v in styles.previewScroll do
309
+ _attributes_8[_k] = _v
310
+ end
311
+ _attributes_8.Size = if mode == "split" then UDim2.fromScale(0.5, 1) else UDim2.fromScale(1, 1)
312
+ _attributes_8.LayoutOrder = 3
313
+ local _attributes_9 = table.clone(styles.previewPad)
314
+ setmetatable(_attributes_9, nil)
315
+ _condition_5 = (React.createElement("scrollingframe", _attributes_8, React.createElement("uipadding", _attributes_9), previewNode))
316
+ end
317
+ return React.createElement("frame", _attributes, _exp, _exp_1, _exp_2, _exp_4, _exp_5, React.createElement("frame", _attributes_7, _condition_2, _condition_3, _condition_4, _condition_5))
318
+ end
319
+ local default = MarkdownEditor
320
+ return {
321
+ default = default,
322
+ }
@@ -0,0 +1,6 @@
1
+ export type MarkdownEditorMode = "split" | "edit" | "preview";
2
+ declare const useMarkdownEditorStyles: (props: {
3
+ fullscreen?: boolean;
4
+ compact?: boolean;
5
+ }) => import("../../../../theme/index").ClassNameMap<string>;
6
+ export default useMarkdownEditorStyles;
@@ -0,0 +1,132 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local _theme = TS.import(script, script.Parent.Parent.Parent.Parent.Parent, "theme")
4
+ local componentStyles = _theme.componentStyles
5
+ local createStyles = _theme.createStyles
6
+ local useMarkdownEditorStyles = componentStyles("MarkdownEditor", function(theme, _param)
7
+ local fullscreen = _param.fullscreen
8
+ local compact = _param.compact
9
+ local pad = if compact == true or theme.density == "compact" then theme.padding.calc(1) else theme.padding.calc(1.5)
10
+ local _object = {
11
+ root = {
12
+ Size = if fullscreen == true then UDim2.fromScale(1, 1) else UDim2.new(1, 0, 1, 0),
13
+ BackgroundColor3 = theme.palette.surface.paper,
14
+ BorderSizePixel = 0,
15
+ },
16
+ corner = {
17
+ CornerRadius = UDim.new(0, theme.shape.borderRadius),
18
+ },
19
+ stroke = {
20
+ Color = theme.palette.divider,
21
+ Thickness = 1,
22
+ ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
23
+ },
24
+ layout = {
25
+ FillDirection = Enum.FillDirection.Vertical,
26
+ HorizontalAlignment = Enum.HorizontalAlignment.Left,
27
+ VerticalAlignment = Enum.VerticalAlignment.Top,
28
+ SortOrder = Enum.SortOrder.LayoutOrder,
29
+ Padding = UDim.new(0, 0),
30
+ },
31
+ toolbar = {
32
+ Size = UDim2.new(1, 0, 0, if compact == true or theme.density == "compact" then 32 else 36),
33
+ BackgroundColor3 = theme.palette.surface.elevated,
34
+ BorderSizePixel = 0,
35
+ LayoutOrder = 1,
36
+ },
37
+ toolbarPad = {
38
+ PaddingLeft = UDim.new(0, pad),
39
+ PaddingRight = UDim.new(0, pad),
40
+ PaddingTop = UDim.new(0, theme.padding.calc(0.5)),
41
+ PaddingBottom = UDim.new(0, theme.padding.calc(0.5)),
42
+ },
43
+ toolbarRow = {
44
+ FillDirection = Enum.FillDirection.Horizontal,
45
+ HorizontalAlignment = Enum.HorizontalAlignment.Left,
46
+ VerticalAlignment = Enum.VerticalAlignment.Center,
47
+ SortOrder = Enum.SortOrder.LayoutOrder,
48
+ Padding = UDim.new(0, theme.padding.calc(1)),
49
+ },
50
+ spacer = {
51
+ Size = UDim2.new(1, 0, 1, 0),
52
+ BackgroundTransparency = 1,
53
+ BorderSizePixel = 0,
54
+ LayoutOrder = 50,
55
+ },
56
+ body = {
57
+ Size = UDim2.new(1, 0, 1, -(if compact == true or theme.density == "compact" then 32 else 36)),
58
+ BackgroundTransparency = 1,
59
+ BorderSizePixel = 0,
60
+ LayoutOrder = 2,
61
+ },
62
+ pane = {
63
+ Size = UDim2.fromScale(0.5, 1),
64
+ BackgroundTransparency = 1,
65
+ BorderSizePixel = 0,
66
+ },
67
+ paneFull = {
68
+ Size = UDim2.fromScale(1, 1),
69
+ BackgroundTransparency = 1,
70
+ BorderSizePixel = 0,
71
+ },
72
+ }
73
+ local _left = "editor"
74
+ local _object_1 = {
75
+ Size = UDim2.fromScale(1, 1),
76
+ BackgroundColor3 = theme.palette.surface.input,
77
+ BorderSizePixel = 0,
78
+ ClearTextOnFocus = false,
79
+ MultiLine = true,
80
+ TextXAlignment = Enum.TextXAlignment.Left,
81
+ TextYAlignment = Enum.TextYAlignment.Top,
82
+ TextWrapped = true,
83
+ Font = Enum.Font.RobotoMono,
84
+ }
85
+ local _left_1 = "TextSize"
86
+ local _condition = theme.typography.fontSizes.caption
87
+ if _condition == nil then
88
+ _condition = theme.typography.fontSizes.body
89
+ end
90
+ _object_1[_left_1] = _condition
91
+ _object_1.TextColor3 = theme.palette.text.primary
92
+ _object_1.PlaceholderColor3 = theme.palette.text.secondary
93
+ _object[_left] = _object_1
94
+ _object.editorPad = {
95
+ PaddingTop = UDim.new(0, pad),
96
+ PaddingBottom = UDim.new(0, pad),
97
+ PaddingLeft = UDim.new(0, pad),
98
+ PaddingRight = UDim.new(0, pad),
99
+ }
100
+ _object.previewScroll = {
101
+ Size = UDim2.fromScale(1, 1),
102
+ BackgroundTransparency = 1,
103
+ BorderSizePixel = 0,
104
+ ScrollBarThickness = 4,
105
+ CanvasSize = UDim2.new(0, 0, 0, 0),
106
+ AutomaticCanvasSize = Enum.AutomaticSize.Y,
107
+ }
108
+ _object.previewPad = {
109
+ PaddingTop = UDim.new(0, pad),
110
+ PaddingBottom = UDim.new(0, pad),
111
+ PaddingLeft = UDim.new(0, pad),
112
+ PaddingRight = UDim.new(0, pad),
113
+ }
114
+ _object.split = {
115
+ FillDirection = Enum.FillDirection.Horizontal,
116
+ HorizontalAlignment = Enum.HorizontalAlignment.Left,
117
+ VerticalAlignment = Enum.VerticalAlignment.Top,
118
+ SortOrder = Enum.SortOrder.LayoutOrder,
119
+ Padding = UDim.new(0, 0),
120
+ }
121
+ _object.divider = {
122
+ Size = UDim2.new(0, 1, 1, 0),
123
+ BackgroundColor3 = theme.palette.divider,
124
+ BorderSizePixel = 0,
125
+ LayoutOrder = 2,
126
+ }
127
+ return createStyles(_object)
128
+ end)
129
+ local default = useMarkdownEditorStyles
130
+ return {
131
+ default = default,
132
+ }
@@ -0,0 +1,2 @@
1
+ /** Map a small HTML subset to the markdown preview subset. Unknown tags unwrap to text. */
2
+ export declare function htmlToMarkdown(html: string): string;