@rbxts/react-clean-ui 1.0.19 → 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.
Files changed (31) hide show
  1. package/out/Components/Chart/BarChart.d.ts +47 -0
  2. package/out/Components/Chart/BarChart.luau +880 -0
  3. package/out/Components/Chart/Pie.luau +12 -12
  4. package/out/Components/Chart/index.d.ts +1 -0
  5. package/out/Components/Chart/init.luau +3 -0
  6. package/out/Components/Interaction/Toast.d.ts +1 -1
  7. package/out/Components/Interaction/Toast.luau +4 -4
  8. package/out/Components/Interaction/Tooltip.d.ts +1 -1
  9. package/out/Components/Interaction/Tooltip.luau +8 -1
  10. package/out/Components/Layout/Accordion.d.ts +34 -0
  11. package/out/Components/Layout/Accordion.luau +430 -0
  12. package/out/Components/Layout/Container.luau +21 -5
  13. package/out/Components/Layout/HStack.d.ts +2 -1
  14. package/out/Components/Layout/HStack.luau +1 -2
  15. package/out/Components/Layout/VStack.d.ts +4 -1
  16. package/out/Components/Layout/VStack.luau +2 -2
  17. package/out/Components/Layout/index.d.ts +1 -0
  18. package/out/Components/Layout/init.luau +3 -0
  19. package/out/Components/Surface/Box.d.ts +2 -2
  20. package/out/Components/Surface/Card.luau +16 -4
  21. package/out/Components/Surface/Icon.d.ts +1 -1
  22. package/out/Components/Surface/Icon.luau +1 -0
  23. package/out/Components/Typography/Text.luau +26 -13
  24. package/out/Helpers/create-ui-story.d.ts +6 -4
  25. package/out/Helpers/create-ui-story.luau +15 -4
  26. package/out/Interfaces/clean.element.props.d.ts +2 -2
  27. package/out/Theme/theme.template.d.ts +67 -10
  28. package/out/Theme/themes/dark.theme.luau +45 -1
  29. package/out/Theme/themes/default.theme.luau +111 -11
  30. package/out/Theme/themes/sandstone.theme.luau +56 -10
  31. package/package.json +4 -2
@@ -0,0 +1,880 @@
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 useTween = TS.import(script, TS.getModule(script, "@rbxts", "react-ripple").src).useTween
5
+ local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
6
+ local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
7
+ local SizeHelper = _Helpers.SizeHelper
8
+ local SpacingHelper = _Helpers.SpacingHelper
9
+ local _Layout = TS.import(script, script.Parent.Parent, "Layout")
10
+ local Container = _Layout.Container
11
+ local HStack = _Layout.HStack
12
+ local VStack = _Layout.VStack
13
+ local Tooltip = TS.import(script, script.Parent.Parent, "Interaction").Tooltip
14
+ local Text = TS.import(script, script.Parent.Parent, "Typography").Text
15
+ local function niceStep(max, targetTicks)
16
+ if targetTicks == nil then
17
+ targetTicks = 5
18
+ end
19
+ if max <= 0 or targetTicks <= 0 then
20
+ return 0
21
+ end
22
+ local rawStep = max / targetTicks
23
+ local magnitude = math.pow(10, math.floor(math.log10(rawStep)))
24
+ local residual = rawStep / magnitude
25
+ local niceResidual
26
+ if residual <= 1 then
27
+ niceResidual = 1
28
+ elseif residual <= 2 then
29
+ niceResidual = 2
30
+ elseif residual <= 5 then
31
+ niceResidual = 5
32
+ else
33
+ niceResidual = 10
34
+ end
35
+ return niceResidual * magnitude
36
+ end
37
+ local function BarChart(props)
38
+ local theme = React.useContext(CleanThemeContext)
39
+ local barTheme = theme.components.charts.bar
40
+ local xAxis = if props.data.xAxis == false then nil else props.data.xAxis
41
+ local yAxis = if props.data.yAxis == false then nil else props.data.yAxis
42
+ local showXAxis = props.data.xAxis ~= false
43
+ local showYAxis = props.data.yAxis ~= false
44
+ local stacked = props.data.stacked ~= false
45
+ local _result = props.data.tooltips
46
+ if _result ~= nil then
47
+ _result = _result.combined
48
+ end
49
+ local combinedTooltips = _result == true
50
+ local _exp = props.data.labels
51
+ -- ▼ ReadonlyArray.map ▼
52
+ local _newValue = table.create(#_exp)
53
+ local _callback = function(_, index)
54
+ local _exp_1 = props.data.datasets
55
+ -- ▼ ReadonlyArray.reduce ▼
56
+ local _result_1 = 0
57
+ local _callback_1 = function(sum, dataset)
58
+ local _exp_2 = sum
59
+ local _condition = dataset.values[index + 1]
60
+ if _condition == nil then
61
+ _condition = 0
62
+ end
63
+ return _exp_2 + math.max(_condition, 0)
64
+ end
65
+ for _i = 1, #_exp_1 do
66
+ _result_1 = _callback_1(_result_1, _exp_1[_i], _i - 1, _exp_1)
67
+ end
68
+ -- ▲ ReadonlyArray.reduce ▲
69
+ return _result_1
70
+ end
71
+ for _k, _v in _exp do
72
+ _newValue[_k] = _callback(_v, _k - 1, _exp)
73
+ end
74
+ -- ▲ ReadonlyArray.map ▲
75
+ local positiveSums = _newValue
76
+ local _exp_1 = props.data.labels
77
+ -- ▼ ReadonlyArray.map ▼
78
+ local _newValue_1 = table.create(#_exp_1)
79
+ local _callback_1 = function(_, index)
80
+ local _exp_2 = props.data.datasets
81
+ -- ▼ ReadonlyArray.reduce ▼
82
+ local _result_1 = 0
83
+ local _callback_2 = function(sum, dataset)
84
+ local _exp_3 = sum
85
+ local _condition = dataset.values[index + 1]
86
+ if _condition == nil then
87
+ _condition = 0
88
+ end
89
+ return _exp_3 + math.min(_condition, 0)
90
+ end
91
+ for _i = 1, #_exp_2 do
92
+ _result_1 = _callback_2(_result_1, _exp_2[_i], _i - 1, _exp_2)
93
+ end
94
+ -- ▲ ReadonlyArray.reduce ▲
95
+ return _result_1
96
+ end
97
+ for _k, _v in _exp_1 do
98
+ _newValue_1[_k] = _callback_1(_v, _k - 1, _exp_1)
99
+ end
100
+ -- ▲ ReadonlyArray.map ▲
101
+ local negativeSums = _newValue_1
102
+ local _result_1
103
+ if stacked then
104
+ _result_1 = positiveSums
105
+ else
106
+ local _exp_2 = props.data.labels
107
+ -- ▼ ReadonlyArray.map ▼
108
+ local _newValue_2 = table.create(#_exp_2)
109
+ local _callback_2 = function(_, index)
110
+ local _exp_3 = props.data.datasets
111
+ -- ▼ ReadonlyArray.reduce ▼
112
+ local _result_2 = 0
113
+ local _callback_3 = function(currentMax, dataset)
114
+ local _exp_4 = currentMax
115
+ local _condition = dataset.values[index + 1]
116
+ if _condition == nil then
117
+ _condition = 0
118
+ end
119
+ return math.max(_exp_4, _condition)
120
+ end
121
+ for _i = 1, #_exp_3 do
122
+ _result_2 = _callback_3(_result_2, _exp_3[_i], _i - 1, _exp_3)
123
+ end
124
+ -- ▲ ReadonlyArray.reduce ▲
125
+ return _result_2
126
+ end
127
+ for _k, _v in _exp_2 do
128
+ _newValue_2[_k] = _callback_2(_v, _k - 1, _exp_2)
129
+ end
130
+ -- ▲ ReadonlyArray.map ▲
131
+ _result_1 = _newValue_2
132
+ end
133
+ local positiveExtents = _result_1
134
+ local _result_2
135
+ if stacked then
136
+ _result_2 = negativeSums
137
+ else
138
+ local _exp_2 = props.data.labels
139
+ -- ▼ ReadonlyArray.map ▼
140
+ local _newValue_2 = table.create(#_exp_2)
141
+ local _callback_2 = function(_, index)
142
+ local _exp_3 = props.data.datasets
143
+ -- ▼ ReadonlyArray.reduce ▼
144
+ local _result_3 = 0
145
+ local _callback_3 = function(currentMin, dataset)
146
+ local _exp_4 = currentMin
147
+ local _condition = dataset.values[index + 1]
148
+ if _condition == nil then
149
+ _condition = 0
150
+ end
151
+ return math.min(_exp_4, _condition)
152
+ end
153
+ for _i = 1, #_exp_3 do
154
+ _result_3 = _callback_3(_result_3, _exp_3[_i], _i - 1, _exp_3)
155
+ end
156
+ -- ▲ ReadonlyArray.reduce ▲
157
+ return _result_3
158
+ end
159
+ for _k, _v in _exp_2 do
160
+ _newValue_2[_k] = _callback_2(_v, _k - 1, _exp_2)
161
+ end
162
+ -- ▲ ReadonlyArray.map ▲
163
+ _result_2 = _newValue_2
164
+ end
165
+ local negativeExtents = _result_2
166
+ -- ▼ ReadonlyArray.reduce ▼
167
+ local _result_3 = 0
168
+ local _callback_2 = function(currentMax, value)
169
+ return math.max(currentMax, value)
170
+ end
171
+ for _i = 1, #positiveExtents do
172
+ _result_3 = _callback_2(_result_3, positiveExtents[_i], _i - 1, positiveExtents)
173
+ end
174
+ -- ▲ ReadonlyArray.reduce ▲
175
+ local max = _result_3
176
+ -- ▼ ReadonlyArray.reduce ▼
177
+ local _result_4 = 0
178
+ local _callback_3 = function(currentMin, value)
179
+ return math.min(currentMin, value)
180
+ end
181
+ for _i = 1, #negativeExtents do
182
+ _result_4 = _callback_3(_result_4, negativeExtents[_i], _i - 1, negativeExtents)
183
+ end
184
+ -- ▲ ReadonlyArray.reduce ▲
185
+ local min = _result_4
186
+ local _specifiedGridValues = yAxis
187
+ if _specifiedGridValues ~= nil then
188
+ _specifiedGridValues = _specifiedGridValues.gridLines
189
+ if _specifiedGridValues ~= nil then
190
+ _specifiedGridValues = _specifiedGridValues.values
191
+ end
192
+ end
193
+ local specifiedGridValues = _specifiedGridValues
194
+ local _result_5 = specifiedGridValues
195
+ if _result_5 ~= nil then
196
+ -- ▼ ReadonlyArray.reduce ▼
197
+ local _result_6 = 0
198
+ local _callback_4 = function(currentMax, value)
199
+ return math.max(currentMax, value)
200
+ end
201
+ for _i = 1, #_result_5 do
202
+ _result_6 = _callback_4(_result_6, _result_5[_i], _i - 1, _result_5)
203
+ end
204
+ -- ▲ ReadonlyArray.reduce ▲
205
+ _result_5 = _result_6
206
+ end
207
+ local _condition = _result_5
208
+ if _condition == nil then
209
+ _condition = 0
210
+ end
211
+ local specifiedMax = _condition
212
+ local _result_6 = specifiedGridValues
213
+ if _result_6 ~= nil then
214
+ -- ▼ ReadonlyArray.reduce ▼
215
+ local _result_7 = 0
216
+ local _callback_4 = function(currentMin, value)
217
+ return math.min(currentMin, value)
218
+ end
219
+ for _i = 1, #_result_6 do
220
+ _result_7 = _callback_4(_result_7, _result_6[_i], _i - 1, _result_6)
221
+ end
222
+ -- ▲ ReadonlyArray.reduce ▲
223
+ _result_6 = _result_7
224
+ end
225
+ local _condition_1 = _result_6
226
+ if _condition_1 == nil then
227
+ _condition_1 = 0
228
+ end
229
+ local specifiedMin = _condition_1
230
+ local _exp_2 = max - min
231
+ local _result_7 = yAxis
232
+ if _result_7 ~= nil then
233
+ _result_7 = _result_7.ticks
234
+ end
235
+ local step = niceStep(_exp_2, _result_7)
236
+ local chartMax = math.max(if step > 0 then math.ceil(max / step) * step else max, specifiedMax)
237
+ local chartMin = math.min(if step > 0 then math.floor(min / step) * step else min, specifiedMin)
238
+ local chartRange = chartMax - chartMin
239
+ local gridValues = {}
240
+ if specifiedGridValues ~= nil then
241
+ -- ▼ ReadonlyArray.forEach ▼
242
+ local _callback_4 = function(value)
243
+ local _value = value
244
+ table.insert(gridValues, _value)
245
+ return #gridValues
246
+ end
247
+ for _k, _v in specifiedGridValues do
248
+ _callback_4(_v, _k - 1, specifiedGridValues)
249
+ end
250
+ -- ▲ ReadonlyArray.forEach ▲
251
+ elseif step > 0 then
252
+ do
253
+ local value = chartMin
254
+ local _shouldIncrement = false
255
+ while true do
256
+ if _shouldIncrement then
257
+ value += step
258
+ else
259
+ _shouldIncrement = true
260
+ end
261
+ if not (value <= chartMax) then
262
+ break
263
+ end
264
+ local _value = value
265
+ table.insert(gridValues, _value)
266
+ end
267
+ end
268
+ end
269
+ local _result_8
270
+ if showXAxis then
271
+ local _result_9 = xAxis
272
+ if _result_9 ~= nil then
273
+ _result_9 = _result_9.size
274
+ end
275
+ local _condition_2 = _result_9
276
+ if _condition_2 == nil then
277
+ _condition_2 = barTheme.xAxis.size
278
+ end
279
+ _result_8 = _condition_2
280
+ else
281
+ _result_8 = 0
282
+ end
283
+ local xAxisSize = _result_8
284
+ local _result_9
285
+ if showYAxis then
286
+ local _result_10 = yAxis
287
+ if _result_10 ~= nil then
288
+ _result_10 = _result_10.size
289
+ end
290
+ local _condition_2 = _result_10
291
+ if _condition_2 == nil then
292
+ _condition_2 = barTheme.yAxis.size
293
+ end
294
+ _result_9 = _condition_2
295
+ else
296
+ _result_9 = 0
297
+ end
298
+ local yAxisSize = _result_9
299
+ local _result_10 = xAxis
300
+ if _result_10 ~= nil then
301
+ _result_10 = _result_10.gap
302
+ end
303
+ local _condition_2 = _result_10
304
+ if _condition_2 == nil then
305
+ _condition_2 = SpacingHelper:GetPadding(theme, nil, barTheme.spacing)
306
+ end
307
+ local barSpacing = UDim.new(0, _condition_2)
308
+ local _result_11 = xAxis
309
+ if _result_11 ~= nil then
310
+ _result_11 = _result_11.spacing
311
+ end
312
+ local _condition_3 = _result_11
313
+ if _condition_3 == nil then
314
+ _condition_3 = barTheme.xAxis.spacing
315
+ end
316
+ local xAxisSpacing = _condition_3
317
+ local _result_12 = yAxis
318
+ if _result_12 ~= nil then
319
+ _result_12 = _result_12.spacing
320
+ end
321
+ local _condition_4 = _result_12
322
+ if _condition_4 == nil then
323
+ _condition_4 = barTheme.yAxis.spacing
324
+ end
325
+ local yAxisSpacing = _condition_4
326
+ local _condition_5 = props.data.unstackedTransparency
327
+ if _condition_5 == nil then
328
+ _condition_5 = barTheme.unstackedTransparency
329
+ end
330
+ local unstackedTransparency = _condition_5
331
+ local xLine = xAxis or {}
332
+ local yLine = yAxis or {}
333
+ local _gridStyle = yAxis
334
+ if _gridStyle ~= nil then
335
+ _gridStyle = _gridStyle.gridLines
336
+ end
337
+ local gridStyle = _gridStyle
338
+ local getLineColor = function(style, fallback)
339
+ return style.color or fallback.color or barTheme.axis.color
340
+ end
341
+ local getLineTransparency = function(style, fallback)
342
+ local _condition_6 = style.transparency
343
+ if _condition_6 == nil then
344
+ _condition_6 = fallback.transparency
345
+ if _condition_6 == nil then
346
+ _condition_6 = barTheme.axis.transparency
347
+ end
348
+ end
349
+ return _condition_6
350
+ end
351
+ local getLineThickness = function(style, fallback)
352
+ local _condition_6 = style.thickness
353
+ if _condition_6 == nil then
354
+ _condition_6 = fallback.thickness
355
+ if _condition_6 == nil then
356
+ _condition_6 = barTheme.axis.thickness
357
+ end
358
+ end
359
+ return _condition_6
360
+ end
361
+ local getYPosition = function(value)
362
+ return (chartMax - value) / chartRange
363
+ end
364
+ local getBarColor = function(dataset, datasetIndex, valueIndex)
365
+ if dataset.color ~= nil then
366
+ return dataset.color
367
+ end
368
+ if dataset.colors ~= nil and dataset.colors[valueIndex + 1] ~= nil then
369
+ return dataset.colors[valueIndex + 1]
370
+ end
371
+ if props.data.colors ~= nil and #props.data.colors > 0 then
372
+ return props.data.colors[datasetIndex % #props.data.colors + 1]
373
+ end
374
+ return theme.components.charts.colors[datasetIndex % #theme.components.charts.colors + 1]
375
+ end
376
+ local getCombinedTooltip = function(index)
377
+ local _exp_3 = props.data.datasets
378
+ -- ▼ ReadonlyArray.map ▼
379
+ local _newValue_2 = table.create(#_exp_3)
380
+ local _callback_4 = function(dataset)
381
+ local _condition_6 = dataset.values[index + 1]
382
+ if _condition_6 == nil then
383
+ _condition_6 = 0
384
+ end
385
+ local value = _condition_6
386
+ local _result_13 = dataset.labels
387
+ if _result_13 ~= nil then
388
+ _result_13 = _result_13[index + 1]
389
+ end
390
+ local _condition_7 = _result_13
391
+ if _condition_7 == nil then
392
+ _condition_7 = props.data.labels[index + 1]
393
+ end
394
+ return `{_condition_7}: {value}`
395
+ end
396
+ for _k, _v in _exp_3 do
397
+ _newValue_2[_k] = _callback_4(_v, _k - 1, _exp_3)
398
+ end
399
+ -- ▲ ReadonlyArray.map ▲
400
+ return table.concat(_newValue_2, "\n")
401
+ end
402
+ local barCornerRadius = SizeHelper:toUDim(barTheme.cornerRadius)
403
+ local animationProgress, animationTween = useTween(if barTheme.tweenTime > 0 then 0 else 1, {
404
+ duration = barTheme.tweenTime,
405
+ easing = "quadOut",
406
+ })
407
+ React.useEffect(function()
408
+ if barTheme.tweenTime > 0 then
409
+ animationTween:setGoal(1)
410
+ end
411
+ end, { animationTween, barTheme.tweenTime })
412
+ local _exp_3 = showYAxis and React.createElement(Container, {
413
+ Size = UDim2.new(0, yAxisSize, 1, -xAxisSize),
414
+ }, React.createElement("frame", {
415
+ Size = UDim2.new(0, getLineThickness(yLine, barTheme.axis), 1, 0),
416
+ Position = UDim2.new(1, -yAxisSpacing, 0, 0),
417
+ AnchorPoint = Vector2.new(1, 0),
418
+ BorderSizePixel = 0,
419
+ BackgroundColor3 = getLineColor(yLine, barTheme.axis),
420
+ BackgroundTransparency = getLineTransparency(yLine, barTheme.axis),
421
+ }))
422
+ local _condition_6 = showYAxis and chartRange > 0
423
+ if _condition_6 then
424
+ -- ▼ ReadonlyArray.map ▼
425
+ local _newValue_2 = table.create(#gridValues)
426
+ local _callback_4 = function(value)
427
+ local _attributes = {}
428
+ local _result_13 = yAxis
429
+ if _result_13 ~= nil then
430
+ _result_13 = _result_13.tickSize
431
+ end
432
+ local _condition_7 = _result_13
433
+ if _condition_7 == nil then
434
+ _condition_7 = barTheme.yAxis.tickSize
435
+ end
436
+ local _result_14 = yAxis
437
+ if _result_14 ~= nil then
438
+ _result_14 = _result_14.tickThickness
439
+ end
440
+ local _condition_8 = _result_14
441
+ if _condition_8 == nil then
442
+ _condition_8 = barTheme.yAxis.tickThickness
443
+ end
444
+ _attributes.Size = UDim2.new(0, _condition_7, 0, _condition_8)
445
+ _attributes.Position = UDim2.new(0, -yAxisSpacing, 0, 0)
446
+ _attributes.AnchorPoint = Vector2.new(1, 0)
447
+ _attributes.BorderSizePixel = 0
448
+ local _result_15 = yAxis
449
+ if _result_15 ~= nil then
450
+ _result_15 = _result_15.tickColor
451
+ end
452
+ local _condition_9 = _result_15
453
+ if _condition_9 == nil then
454
+ _condition_9 = barTheme.yAxis.tickColor
455
+ end
456
+ _attributes.BackgroundColor3 = _condition_9
457
+ local _result_16 = yAxis
458
+ if _result_16 ~= nil then
459
+ _result_16 = _result_16.tickTransparency
460
+ end
461
+ local _condition_10 = _result_16
462
+ if _condition_10 == nil then
463
+ _condition_10 = barTheme.yAxis.tickTransparency
464
+ end
465
+ _attributes.BackgroundTransparency = _condition_10
466
+ return React.createElement("frame", {
467
+ Size = UDim2.new(1, 0, 0, getLineThickness(gridStyle or {}, barTheme.gridLines)),
468
+ Position = UDim2.new(0, 0, getYPosition(value), 0),
469
+ BorderSizePixel = 0,
470
+ BackgroundColor3 = getLineColor(gridStyle or {}, barTheme.gridLines),
471
+ BackgroundTransparency = getLineTransparency(gridStyle or {}, barTheme.gridLines),
472
+ }, React.createElement("frame", _attributes), React.createElement(Text, {
473
+ text = `{value}`,
474
+ TextWrap = false,
475
+ AnchorPoint = Vector2.new(1, 0.5),
476
+ Position = UDim2.new(0, -15 - yAxisSpacing, 0, 0),
477
+ }))
478
+ end
479
+ for _k, _v in gridValues do
480
+ _newValue_2[_k] = _callback_4(_v, _k - 1, gridValues)
481
+ end
482
+ -- ▲ ReadonlyArray.map ▲
483
+ _condition_6 = _newValue_2
484
+ end
485
+ local _condition_7 = chartRange > 0
486
+ if _condition_7 then
487
+ local _exp_4 = props.data.labels
488
+ -- ▼ ReadonlyArray.map ▼
489
+ local _newValue_2 = table.create(#_exp_4)
490
+ local _callback_4 = function(label, index)
491
+ local _result_13
492
+ if stacked then
493
+ local _exp_5 = props.data.datasets
494
+ -- ▼ ReadonlyArray.map ▼
495
+ local _newValue_3 = table.create(#_exp_5)
496
+ local _callback_5 = function(dataset, datasetIndex)
497
+ local _condition_8 = dataset.values[index + 1]
498
+ if _condition_8 == nil then
499
+ _condition_8 = 0
500
+ end
501
+ local value = _condition_8
502
+ local _result_14 = dataset.labels
503
+ if _result_14 ~= nil then
504
+ _result_14 = _result_14[index + 1]
505
+ end
506
+ local _condition_9 = _result_14
507
+ if _condition_9 == nil then
508
+ _condition_9 = label
509
+ end
510
+ local tooltipLabel = _condition_9
511
+ local _exp_6 = props.data.datasets
512
+ -- ▼ ReadonlyArray.reduce ▼
513
+ local _result_15 = 0
514
+ local _callback_6 = function(sum, previousDataset, previousIndex)
515
+ if previousIndex >= datasetIndex then
516
+ return sum
517
+ end
518
+ local _condition_10 = previousDataset.values[index + 1]
519
+ if _condition_10 == nil then
520
+ _condition_10 = 0
521
+ end
522
+ local previousValue = _condition_10
523
+ return if (value >= 0) == (previousValue >= 0) then sum + previousValue else sum
524
+ end
525
+ for _i = 1, #_exp_6 do
526
+ _result_15 = _callback_6(_result_15, _exp_6[_i], _i - 1, _exp_6)
527
+ end
528
+ -- ▲ ReadonlyArray.reduce ▲
529
+ local start = _result_15
530
+ local segmentEnd = start + value
531
+ local top = math.max(start, segmentEnd)
532
+ local _result_16
533
+ if value > 0 then
534
+ local _exp_7 = props.data.datasets
535
+ -- ▼ ReadonlyArray.some ▼
536
+ local _result_17 = false
537
+ local _callback_7 = function(otherDataset, otherIndex)
538
+ local _condition_10 = otherIndex > datasetIndex
539
+ if _condition_10 then
540
+ local _condition_11 = otherDataset.values[index + 1]
541
+ if _condition_11 == nil then
542
+ _condition_11 = 0
543
+ end
544
+ _condition_10 = _condition_11 > 0
545
+ end
546
+ return _condition_10
547
+ end
548
+ for _k, _v in _exp_7 do
549
+ if _callback_7(_v, _k - 1, _exp_7) then
550
+ _result_17 = true
551
+ break
552
+ end
553
+ end
554
+ -- ▲ ReadonlyArray.some ▲
555
+ _result_16 = not _result_17
556
+ else
557
+ local _condition_10 = positiveSums[index + 1] <= 0 and value < 0
558
+ if _condition_10 then
559
+ local _exp_7 = props.data.datasets
560
+ -- ▼ ReadonlyArray.some ▼
561
+ local _result_17 = false
562
+ local _callback_7 = function(otherDataset, otherIndex)
563
+ local _condition_11 = otherIndex < datasetIndex
564
+ if _condition_11 then
565
+ local _condition_12 = otherDataset.values[index + 1]
566
+ if _condition_12 == nil then
567
+ _condition_12 = 0
568
+ end
569
+ _condition_11 = _condition_12 < 0
570
+ end
571
+ return _condition_11
572
+ end
573
+ for _k, _v in _exp_7 do
574
+ if _callback_7(_v, _k - 1, _exp_7) then
575
+ _result_17 = true
576
+ break
577
+ end
578
+ end
579
+ -- ▲ ReadonlyArray.some ▲
580
+ _condition_10 = not _result_17
581
+ end
582
+ _result_16 = _condition_10
583
+ end
584
+ local isTopSegment = _result_16
585
+ local segment = React.createElement(Container, {
586
+ Size = animationProgress:map(function(progress)
587
+ return UDim2.fromScale(1, math.abs(value) / chartRange * progress)
588
+ end),
589
+ Position = animationProgress:map(function(progress)
590
+ return UDim2.fromScale(0, getYPosition(top * progress))
591
+ end),
592
+ BackgroundTransparency = 0,
593
+ BackgroundColor3 = getBarColor(dataset, datasetIndex, index),
594
+ }, React.createElement("uistroke", {
595
+ Color = barTheme.borderColor,
596
+ Thickness = barTheme.borderThickness,
597
+ ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
598
+ }), isTopSegment and React.createElement("uicorner", {
599
+ TopLeftRadius = barCornerRadius,
600
+ TopRightRadius = barCornerRadius,
601
+ BottomLeftRadius = UDim.new(0, 0),
602
+ BottomRightRadius = UDim.new(0, 0),
603
+ }))
604
+ return if combinedTooltips then segment else React.createElement(Tooltip, {
605
+ content = `{tooltipLabel}: {value}`,
606
+ placement = "Center",
607
+ }, segment)
608
+ end
609
+ for _k, _v in _exp_5 do
610
+ _newValue_3[_k] = _callback_5(_v, _k - 1, _exp_5)
611
+ end
612
+ -- ▲ ReadonlyArray.map ▲
613
+ _result_13 = React.createElement(Container, {
614
+ Size = UDim2.fromScale(1, 1),
615
+ }, _newValue_3, combinedTooltips and React.createElement(Tooltip, {
616
+ content = getCombinedTooltip(index),
617
+ placement = "Center",
618
+ }, React.createElement(Container, {
619
+ Size = animationProgress:map(function(progress)
620
+ return UDim2.fromScale(1, (positiveExtents[index + 1] - negativeExtents[index + 1]) / chartRange * progress)
621
+ end),
622
+ Position = animationProgress:map(function(progress)
623
+ return UDim2.fromScale(0, getYPosition(positiveExtents[index + 1] * progress))
624
+ end),
625
+ BackgroundTransparency = 1,
626
+ })))
627
+ else
628
+ local _exp_5 = props.data.datasets
629
+ -- ▼ ReadonlyArray.map ▼
630
+ local _newValue_3 = table.create(#_exp_5)
631
+ local _callback_5 = function(dataset, datasetIndex)
632
+ local _condition_8 = dataset.values[index + 1]
633
+ if _condition_8 == nil then
634
+ _condition_8 = 0
635
+ end
636
+ local value = _condition_8
637
+ local _result_14 = dataset.labels
638
+ if _result_14 ~= nil then
639
+ _result_14 = _result_14[index + 1]
640
+ end
641
+ local _condition_9 = _result_14
642
+ if _condition_9 == nil then
643
+ _condition_9 = label
644
+ end
645
+ local tooltipLabel = _condition_9
646
+ local magnitude = math.abs(value)
647
+ local _exp_6 = props.data.datasets
648
+ -- ▼ ReadonlyArray.some ▼
649
+ local _result_15 = false
650
+ local _callback_6 = function(otherDataset, otherIndex)
651
+ local _condition_10 = otherIndex > datasetIndex
652
+ if _condition_10 then
653
+ local _condition_11 = otherDataset.values[index + 1]
654
+ if _condition_11 == nil then
655
+ _condition_11 = 0
656
+ end
657
+ _condition_10 = _condition_11 == value
658
+ end
659
+ return _condition_10
660
+ end
661
+ for _k, _v in _exp_6 do
662
+ if _callback_6(_v, _k - 1, _exp_6) then
663
+ _result_15 = true
664
+ break
665
+ end
666
+ end
667
+ -- ▲ ReadonlyArray.some ▲
668
+ local hasLaterEqualValue = _result_15
669
+ if magnitude == 0 or hasLaterEqualValue then
670
+ return nil
671
+ end
672
+ local _exp_7 = props.data.datasets
673
+ -- ▼ ReadonlyArray.reduce ▼
674
+ local _result_16 = 0
675
+ local _callback_7 = function(covered, otherDataset)
676
+ local _condition_10 = otherDataset.values[index + 1]
677
+ if _condition_10 == nil then
678
+ _condition_10 = 0
679
+ end
680
+ local otherValue = _condition_10
681
+ local otherMagnitude = math.abs(otherValue)
682
+ local sameDirection = (value >= 0) == (otherValue >= 0)
683
+ return if sameDirection and otherMagnitude < magnitude then math.max(covered, otherMagnitude) else covered
684
+ end
685
+ for _i = 1, #_exp_7 do
686
+ _result_16 = _callback_7(_result_16, _exp_7[_i], _i - 1, _exp_7)
687
+ end
688
+ -- ▲ ReadonlyArray.reduce ▲
689
+ local coveredMagnitude = _result_16
690
+ local visibleMagnitude = magnitude - coveredMagnitude
691
+ local _exp_8 = props.data.datasets
692
+ -- ▼ ReadonlyArray.filter ▼
693
+ local _newValue_4 = {}
694
+ local _callback_8 = function(otherDataset)
695
+ local _condition_10 = otherDataset.values[index + 1]
696
+ if _condition_10 == nil then
697
+ _condition_10 = 0
698
+ end
699
+ return math.abs(_condition_10) > magnitude
700
+ end
701
+ local _length = 0
702
+ for _k, _v in _exp_8 do
703
+ if _callback_8(_v, _k - 1, _exp_8) == true then
704
+ _length += 1
705
+ _newValue_4[_length] = _v
706
+ end
707
+ end
708
+ -- ▲ ReadonlyArray.filter ▲
709
+ local zIndex = #_newValue_4
710
+ local top = if value >= 0 then value else -coveredMagnitude
711
+ local _exp_9 = props.data.datasets
712
+ -- ▼ ReadonlyArray.some ▼
713
+ local _result_17 = false
714
+ local _callback_9 = function(otherDataset)
715
+ local _condition_10 = otherDataset.values[index + 1]
716
+ if _condition_10 == nil then
717
+ _condition_10 = 0
718
+ end
719
+ local otherValue = _condition_10
720
+ return (value >= 0) == (otherValue >= 0) and math.abs(otherValue) > magnitude
721
+ end
722
+ for _k, _v in _exp_9 do
723
+ if _callback_9(_v, _k - 1, _exp_9) then
724
+ _result_17 = true
725
+ break
726
+ end
727
+ end
728
+ -- ▲ ReadonlyArray.some ▲
729
+ local isTallest = not _result_17
730
+ local visibleSection = React.createElement(Container, {
731
+ Size = animationProgress:map(function(progress)
732
+ return UDim2.fromScale(1, visibleMagnitude / chartRange * progress)
733
+ end),
734
+ Position = animationProgress:map(function(progress)
735
+ return UDim2.fromScale(0, getYPosition(top * progress))
736
+ end),
737
+ ZIndex = zIndex,
738
+ BackgroundTransparency = unstackedTransparency,
739
+ BackgroundColor3 = getBarColor(dataset, datasetIndex, index),
740
+ }, React.createElement("uistroke", {
741
+ Color = barTheme.borderColor,
742
+ Thickness = barTheme.borderThickness,
743
+ ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
744
+ }), isTallest and React.createElement("uicorner", {
745
+ TopLeftRadius = barCornerRadius,
746
+ TopRightRadius = barCornerRadius,
747
+ BottomLeftRadius = UDim.new(0, 0),
748
+ BottomRightRadius = UDim.new(0, 0),
749
+ }))
750
+ return if combinedTooltips then visibleSection else React.createElement(Tooltip, {
751
+ content = `{tooltipLabel}: {value}`,
752
+ placement = "Center",
753
+ }, visibleSection)
754
+ end
755
+ for _k, _v in _exp_5 do
756
+ _newValue_3[_k] = _callback_5(_v, _k - 1, _exp_5)
757
+ end
758
+ -- ▲ ReadonlyArray.map ▲
759
+ _result_13 = React.createElement(Container, {
760
+ Size = UDim2.fromScale(1, 1),
761
+ }, _newValue_3, combinedTooltips and React.createElement(Tooltip, {
762
+ content = getCombinedTooltip(index),
763
+ placement = "Center",
764
+ }, React.createElement(Container, {
765
+ Size = animationProgress:map(function(progress)
766
+ return UDim2.fromScale(1, (positiveExtents[index + 1] - negativeExtents[index + 1]) / chartRange * progress)
767
+ end),
768
+ Position = animationProgress:map(function(progress)
769
+ return UDim2.fromScale(0, getYPosition(positiveExtents[index + 1] * progress))
770
+ end),
771
+ BackgroundTransparency = 1,
772
+ })))
773
+ end
774
+ return React.createElement(Container, {
775
+ Size = UDim2.fromScale(0, 1),
776
+ }, _result_13)
777
+ end
778
+ for _k, _v in _exp_4 do
779
+ _newValue_2[_k] = _callback_4(_v, _k - 1, _exp_4)
780
+ end
781
+ -- ▲ ReadonlyArray.map ▲
782
+ _condition_7 = React.createElement(Container, {
783
+ Size = UDim2.fromScale(1, 1),
784
+ }, React.createElement(HStack, {
785
+ HorizontalFlex = Enum.UIFlexAlignment.Fill,
786
+ valign = "Bottom",
787
+ Padding = barSpacing,
788
+ }, _newValue_2))
789
+ end
790
+ local _exp_4 = React.createElement(Container, {
791
+ Size = UDim2.new(1, 0, 1, -xAxisSize),
792
+ }, _condition_6, _condition_7)
793
+ local _condition_8 = showXAxis
794
+ if _condition_8 then
795
+ local _exp_5 = React.createElement("frame", {
796
+ Size = UDim2.new(1, 0, 0, getLineThickness(xLine, barTheme.axis)),
797
+ Position = UDim2.new(0, 0, 0, xAxisSpacing),
798
+ BorderSizePixel = 0,
799
+ BackgroundColor3 = getLineColor(xLine, barTheme.axis),
800
+ BackgroundTransparency = getLineTransparency(xLine, barTheme.axis),
801
+ })
802
+ local _exp_6 = props.data.labels
803
+ -- ▼ ReadonlyArray.map ▼
804
+ local _newValue_2 = table.create(#_exp_6)
805
+ local _callback_4 = function(label)
806
+ local _attributes = {}
807
+ local _result_13 = xAxis
808
+ if _result_13 ~= nil then
809
+ _result_13 = _result_13.tickThickness
810
+ end
811
+ local _condition_9 = _result_13
812
+ if _condition_9 == nil then
813
+ _condition_9 = barTheme.xAxis.tickThickness
814
+ end
815
+ local _result_14 = xAxis
816
+ if _result_14 ~= nil then
817
+ _result_14 = _result_14.tickSize
818
+ end
819
+ local _condition_10 = _result_14
820
+ if _condition_10 == nil then
821
+ _condition_10 = barTheme.xAxis.tickSize
822
+ end
823
+ _attributes.Size = UDim2.new(0, _condition_9, 0, _condition_10)
824
+ _attributes.Position = UDim2.new(0.5, 0, 0, xAxisSpacing)
825
+ _attributes.AnchorPoint = Vector2.new(0.5, 0)
826
+ _attributes.BorderSizePixel = 0
827
+ local _result_15 = xAxis
828
+ if _result_15 ~= nil then
829
+ _result_15 = _result_15.tickColor
830
+ end
831
+ local _condition_11 = _result_15
832
+ if _condition_11 == nil then
833
+ _condition_11 = barTheme.xAxis.tickColor
834
+ end
835
+ _attributes.BackgroundColor3 = _condition_11
836
+ local _result_16 = xAxis
837
+ if _result_16 ~= nil then
838
+ _result_16 = _result_16.tickTransparency
839
+ end
840
+ local _condition_12 = _result_16
841
+ if _condition_12 == nil then
842
+ _condition_12 = barTheme.xAxis.tickTransparency
843
+ end
844
+ _attributes.BackgroundTransparency = _condition_12
845
+ return React.createElement(Container, {
846
+ Size = UDim2.fromScale(0, 1),
847
+ }, React.createElement("frame", _attributes), React.createElement(Container, {
848
+ center = true,
849
+ }, React.createElement(Text, {
850
+ text = label,
851
+ TextWrapped = false,
852
+ })))
853
+ end
854
+ for _k, _v in _exp_6 do
855
+ _newValue_2[_k] = _callback_4(_v, _k - 1, _exp_6)
856
+ end
857
+ -- ▲ ReadonlyArray.map ▲
858
+ _condition_8 = React.createElement(Container, {
859
+ Size = UDim2.new(1, 0, 0, xAxisSize),
860
+ }, _exp_5, React.createElement(Container, {
861
+ Size = UDim2.fromScale(1, 1),
862
+ }, React.createElement(HStack, {
863
+ HorizontalFlex = Enum.UIFlexAlignment.Fill,
864
+ Padding = barSpacing,
865
+ }, _newValue_2)))
866
+ end
867
+ return React.createElement(Container, {
868
+ Size = UDim2.fromScale(1, 1),
869
+ }, React.createElement(HStack, {
870
+ HorizontalFlex = Enum.UIFlexAlignment.Fill,
871
+ spacing = "None",
872
+ }, _exp_3, React.createElement(Container, {
873
+ Size = UDim2.new(1, -yAxisSize, 1, 0),
874
+ }, React.createElement(VStack, {
875
+ spacing = "None",
876
+ }, _exp_4, _condition_8))))
877
+ end
878
+ return {
879
+ BarChart = BarChart,
880
+ }