@nrbx/topbar-components 1.0.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.txt +20 -0
- package/README.md +116 -0
- package/out/components/dropdown.d.ts +18 -0
- package/out/components/dropdown.luau +193 -0
- package/out/components/icon.d.ts +40 -0
- package/out/components/icon.luau +237 -0
- package/out/components/provider.d.ts +8 -0
- package/out/components/provider.luau +92 -0
- package/out/components/stylesheet.d.ts +10 -0
- package/out/components/stylesheet.luau +17 -0
- package/out/context.d.ts +29 -0
- package/out/context.luau +20 -0
- package/out/hooks/use-animateable-props.d.ts +8 -0
- package/out/hooks/use-animateable-props.luau +46 -0
- package/out/hooks/use-gui-inset.d.ts +1 -0
- package/out/hooks/use-gui-inset.luau +20 -0
- package/out/hooks/use-id.d.ts +1 -0
- package/out/hooks/use-id.luau +13 -0
- package/out/hooks/use-voicechat-enabled.d.ts +1 -0
- package/out/hooks/use-voicechat-enabled.luau +17 -0
- package/out/index.d.ts +4 -0
- package/out/init.luau +16 -0
- package/out/style.d.ts +70 -0
- package/out/style.luau +117 -0
- package/out/utilities/id-gen.d.ts +1 -0
- package/out/utilities/id-gen.luau +12 -0
- package/out/utilities/merge.d.ts +2 -0
- package/out/utilities/merge.luau +29 -0
- package/out/utilities/resolve-state-dependent.d.ts +2 -0
- package/out/utilities/resolve-state-dependent.luau +17 -0
- package/out/utilities/springs.d.ts +23 -0
- package/out/utilities/springs.luau +24 -0
- package/out/utilities/types.d.ts +5 -0
- package/out/utilities/types.luau +2 -0
- package/package.json +47 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local useState = _react.useState
|
|
6
|
+
local _context = TS.import(script, script.Parent.Parent, "context")
|
|
7
|
+
local LocationContext = _context.LocationContext
|
|
8
|
+
local useStylesheet = _context.useStylesheet
|
|
9
|
+
local useGuiInset = TS.import(script, script.Parent.Parent, "hooks", "use-gui-inset").useGuiInset
|
|
10
|
+
local useVoicechatEnabled = TS.import(script, script.Parent.Parent, "hooks", "use-voicechat-enabled").useVoicechatEnabled
|
|
11
|
+
local function TopbarProvider(_param)
|
|
12
|
+
local selectionMode = _param.selectionMode
|
|
13
|
+
if selectionMode == nil then
|
|
14
|
+
selectionMode = "Single"
|
|
15
|
+
end
|
|
16
|
+
local gameVoiceChatEnabled = _param.gameVoiceChatEnabled
|
|
17
|
+
local children = _param.children
|
|
18
|
+
local selectedIcons, setSelectedIcons = useState({})
|
|
19
|
+
local inset = useGuiInset()
|
|
20
|
+
local voiceChatEnabled = useVoicechatEnabled()
|
|
21
|
+
local stylesheet = useStylesheet().provider
|
|
22
|
+
local hasBetaLabel = gameVoiceChatEnabled and voiceChatEnabled
|
|
23
|
+
local leftPadding = if hasBetaLabel then stylesheet.paddingLeft + 16 else stylesheet.paddingLeft
|
|
24
|
+
local frameHeight = inset.Height - stylesheet.insetHeightOffset
|
|
25
|
+
return React.createElement(LocationContext.Provider, {
|
|
26
|
+
value = {
|
|
27
|
+
type = "provider",
|
|
28
|
+
selectedIcons = selectedIcons,
|
|
29
|
+
iconSelected = function(iconId)
|
|
30
|
+
if selectionMode == "Single" then
|
|
31
|
+
return setSelectedIcons({ iconId })
|
|
32
|
+
end
|
|
33
|
+
return setSelectedIcons(function(icons)
|
|
34
|
+
local _array = {}
|
|
35
|
+
local _length = #_array
|
|
36
|
+
local _iconsLength = #icons
|
|
37
|
+
table.move(icons, 1, _iconsLength, _length + 1, _array)
|
|
38
|
+
_length += _iconsLength
|
|
39
|
+
_array[_length + 1] = iconId
|
|
40
|
+
return _array
|
|
41
|
+
end)
|
|
42
|
+
end,
|
|
43
|
+
iconDeselected = function(iconId)
|
|
44
|
+
local _condition = selectionMode == "Single"
|
|
45
|
+
if _condition then
|
|
46
|
+
local _iconId = iconId
|
|
47
|
+
_condition = table.find(selectedIcons, _iconId) ~= nil
|
|
48
|
+
end
|
|
49
|
+
if _condition then
|
|
50
|
+
return setSelectedIcons({})
|
|
51
|
+
end
|
|
52
|
+
return setSelectedIcons(function(icons)
|
|
53
|
+
-- ▼ ReadonlyArray.filter ▼
|
|
54
|
+
local _newValue = {}
|
|
55
|
+
local _callback = function(T)
|
|
56
|
+
return T ~= iconId
|
|
57
|
+
end
|
|
58
|
+
local _length = 0
|
|
59
|
+
for _k, _v in icons do
|
|
60
|
+
if _callback(_v, _k - 1, icons) == true then
|
|
61
|
+
_length += 1
|
|
62
|
+
_newValue[_length] = _v
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
-- ▲ ReadonlyArray.filter ▲
|
|
66
|
+
return _newValue
|
|
67
|
+
end)
|
|
68
|
+
end,
|
|
69
|
+
},
|
|
70
|
+
}, React.createElement("frame", {
|
|
71
|
+
key = "TopbarProvider",
|
|
72
|
+
BackgroundTransparency = stylesheet.backgroundTransparency,
|
|
73
|
+
BackgroundColor3 = stylesheet.backgroundColor,
|
|
74
|
+
Size = UDim2.fromOffset(inset.Width * stylesheet.sizeScale.X, frameHeight * stylesheet.sizeScale.Y),
|
|
75
|
+
AnchorPoint = stylesheet.anchorPoint,
|
|
76
|
+
Position = stylesheet.position,
|
|
77
|
+
}, React.createElement("uipadding", {
|
|
78
|
+
key = "UIPadding",
|
|
79
|
+
PaddingLeft = UDim.new(0, leftPadding),
|
|
80
|
+
PaddingRight = UDim.new(0, stylesheet.paddingRight),
|
|
81
|
+
PaddingTop = UDim.new(0, stylesheet.paddingTop),
|
|
82
|
+
PaddingBottom = UDim.new(0, stylesheet.paddingBottom),
|
|
83
|
+
}), React.createElement("uilistlayout", {
|
|
84
|
+
key = "UIListLayout",
|
|
85
|
+
FillDirection = Enum.FillDirection.Horizontal,
|
|
86
|
+
SortOrder = Enum.SortOrder.LayoutOrder,
|
|
87
|
+
Padding = UDim.new(0, stylesheet.iconSpacing),
|
|
88
|
+
}), children))
|
|
89
|
+
end
|
|
90
|
+
return {
|
|
91
|
+
TopbarProvider = TopbarProvider,
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from '@rbxts/react';
|
|
2
|
+
import { DefaultStylesheet, type Stylesheet as StylesheetType } from '../style';
|
|
3
|
+
import type { DeepPartial } from '../utilities/types';
|
|
4
|
+
interface Props extends React.PropsWithChildren {
|
|
5
|
+
stylesheet: PartialStylesheet;
|
|
6
|
+
}
|
|
7
|
+
type PartialStylesheet = DeepPartial<StylesheetType>;
|
|
8
|
+
export { DefaultStylesheet };
|
|
9
|
+
export type { StylesheetType };
|
|
10
|
+
export declare function Stylesheet({ stylesheet, children }: Props): React.JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local StylesheetContext = TS.import(script, script.Parent.Parent, "context").StylesheetContext
|
|
5
|
+
local DefaultStylesheet = TS.import(script, script.Parent.Parent, "style").DefaultStylesheet
|
|
6
|
+
local reconcile = TS.import(script, script.Parent.Parent, "utilities", "merge")
|
|
7
|
+
local function Stylesheet(_param)
|
|
8
|
+
local stylesheet = _param.stylesheet
|
|
9
|
+
local children = _param.children
|
|
10
|
+
return React.createElement(StylesheetContext.Provider, {
|
|
11
|
+
value = reconcile(stylesheet, DefaultStylesheet),
|
|
12
|
+
}, children)
|
|
13
|
+
end
|
|
14
|
+
return {
|
|
15
|
+
Stylesheet = Stylesheet,
|
|
16
|
+
DefaultStylesheet = DefaultStylesheet,
|
|
17
|
+
}
|
package/out/context.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IconId } from './components/icon';
|
|
2
|
+
import { type Stylesheet } from './style';
|
|
3
|
+
type Location = {
|
|
4
|
+
type: 'provider';
|
|
5
|
+
selectedIcons: IconId[];
|
|
6
|
+
iconSelected: (icon: IconId) => void;
|
|
7
|
+
iconDeselected: (icon: IconId) => void;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'icon';
|
|
10
|
+
isVisible: boolean;
|
|
11
|
+
isUnderDropdown: boolean;
|
|
12
|
+
width: number;
|
|
13
|
+
setAnimationState: (current: boolean) => void;
|
|
14
|
+
setDropdownSize: (current: Vector2) => void;
|
|
15
|
+
setContentSize: (current: Vector2) => void;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'dropdown';
|
|
18
|
+
selectedIcons: IconId[];
|
|
19
|
+
iconSelected: (icon: IconId) => void;
|
|
20
|
+
iconDeselected: (icon: IconId) => void;
|
|
21
|
+
registerChild: (id: number, size: Vector2) => void;
|
|
22
|
+
removeChild: (id: number) => void;
|
|
23
|
+
desiredIconWidth: number;
|
|
24
|
+
};
|
|
25
|
+
export declare const LocationContext: import("@rbxts/react").Context<Location>;
|
|
26
|
+
export declare const StylesheetContext: import("@rbxts/react").Context<Stylesheet>;
|
|
27
|
+
export declare function useStylesheet(): Stylesheet;
|
|
28
|
+
export declare function useLocation(): Location;
|
|
29
|
+
export {};
|
package/out/context.luau
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local createContext = _react.createContext
|
|
5
|
+
local useContext = _react.useContext
|
|
6
|
+
local DefaultStylesheet = TS.import(script, script.Parent, "style").DefaultStylesheet
|
|
7
|
+
local LocationContext = createContext(nil)
|
|
8
|
+
local StylesheetContext = createContext(nil)
|
|
9
|
+
local function useStylesheet()
|
|
10
|
+
return useContext(StylesheetContext) or DefaultStylesheet
|
|
11
|
+
end
|
|
12
|
+
local function useLocation()
|
|
13
|
+
return useContext(LocationContext)
|
|
14
|
+
end
|
|
15
|
+
return {
|
|
16
|
+
useStylesheet = useStylesheet,
|
|
17
|
+
useLocation = useLocation,
|
|
18
|
+
LocationContext = LocationContext,
|
|
19
|
+
StylesheetContext = StylesheetContext,
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Binding } from '@rbxts/react';
|
|
2
|
+
import type { MotionGoal } from '@rbxts/ripple';
|
|
3
|
+
import type { FromStateDependent, IconState, StateDependent } from '../components/icon';
|
|
4
|
+
type Result<T extends Record<string, StateDependent<MotionGoal>>, K extends keyof T> = ExcludeMembers<{
|
|
5
|
+
[P in keyof T]: P extends K ? Binding<NonNullable<FromStateDependent<T[P]>>> : undefined;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export declare function useAnimateableProps<T extends Record<string, StateDependent<MotionGoal>>, K extends keyof T>(state: IconState, props: T, ...keys: K[]): Result<T, K>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local Object = TS.import(script, TS.getModule(script, "@rbxts", "object-utils"))
|
|
4
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
5
|
+
local useMotion = _pretty_react_hooks.useMotion
|
|
6
|
+
local usePrevious = _pretty_react_hooks.usePrevious
|
|
7
|
+
local useEffect = TS.import(script, TS.getModule(script, "@rbxts", "react")).useEffect
|
|
8
|
+
local stateful = TS.import(script, script.Parent.Parent, "utilities", "resolve-state-dependent").stateful
|
|
9
|
+
local springs = TS.import(script, script.Parent.Parent, "utilities", "springs").springs
|
|
10
|
+
local function useAnimateableProps(state, props, ...)
|
|
11
|
+
local keys = { ... }
|
|
12
|
+
local previousProps = usePrevious(props)
|
|
13
|
+
local motions = {}
|
|
14
|
+
for _, key in keys do
|
|
15
|
+
local binding, motion = useMotion(stateful(props[key], state))
|
|
16
|
+
local _arg0 = { binding, motion }
|
|
17
|
+
table.insert(motions, _arg0)
|
|
18
|
+
end
|
|
19
|
+
useEffect(function()
|
|
20
|
+
for _, key in keys do
|
|
21
|
+
local value = stateful(props[key], state)
|
|
22
|
+
local previousValue = stateful(previousProps, state)
|
|
23
|
+
if value == previousValue then
|
|
24
|
+
continue
|
|
25
|
+
end
|
|
26
|
+
motions[table.find(keys, key) or 0][2]:spring(value, springs.responsive)
|
|
27
|
+
end
|
|
28
|
+
end, { props })
|
|
29
|
+
-- ▼ ReadonlyArray.map ▼
|
|
30
|
+
local _newValue = table.create(#keys)
|
|
31
|
+
local _callback = function(key)
|
|
32
|
+
local _exp = key
|
|
33
|
+
local _exp_1 = motions
|
|
34
|
+
local _keys = keys
|
|
35
|
+
local _key = key
|
|
36
|
+
return { _exp, _exp_1[table.find(_keys, _key) or 0][1] }
|
|
37
|
+
end
|
|
38
|
+
for _k, _v in keys do
|
|
39
|
+
_newValue[_k] = _callback(_v, _k - 1, keys)
|
|
40
|
+
end
|
|
41
|
+
-- ▲ ReadonlyArray.map ▲
|
|
42
|
+
return Object.fromEntries(_newValue)
|
|
43
|
+
end
|
|
44
|
+
return {
|
|
45
|
+
useAnimateableProps = useAnimateableProps,
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useGuiInset(): Rect;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
4
|
+
local useEventListener = _pretty_react_hooks.useEventListener
|
|
5
|
+
local useMountEffect = _pretty_react_hooks.useMountEffect
|
|
6
|
+
local useState = TS.import(script, TS.getModule(script, "@rbxts", "react")).useState
|
|
7
|
+
local GuiService = TS.import(script, TS.getModule(script, "@rbxts", "services")).GuiService
|
|
8
|
+
local function useGuiInset()
|
|
9
|
+
local inset, setInset = useState(GuiService.TopbarInset)
|
|
10
|
+
useMountEffect(function()
|
|
11
|
+
setInset(GuiService.TopbarInset)
|
|
12
|
+
end)
|
|
13
|
+
useEventListener(GuiService:GetPropertyChangedSignal("TopbarInset"), function()
|
|
14
|
+
return setInset(GuiService.TopbarInset)
|
|
15
|
+
end)
|
|
16
|
+
return inset
|
|
17
|
+
end
|
|
18
|
+
return {
|
|
19
|
+
useGuiInset = useGuiInset,
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useId(): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local useMemo = TS.import(script, TS.getModule(script, "@rbxts", "react")).useMemo
|
|
4
|
+
local createIdGenerator = TS.import(script, script.Parent.Parent, "utilities", "id-gen").createIdGenerator
|
|
5
|
+
local nextId = createIdGenerator()
|
|
6
|
+
local function useId()
|
|
7
|
+
return useMemo(function()
|
|
8
|
+
return nextId()
|
|
9
|
+
end, {})
|
|
10
|
+
end
|
|
11
|
+
return {
|
|
12
|
+
useId = useId,
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useVoicechatEnabled(): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local useAsyncEffect = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out).useAsyncEffect
|
|
4
|
+
local useState = TS.import(script, TS.getModule(script, "@rbxts", "react")).useState
|
|
5
|
+
local _services = TS.import(script, TS.getModule(script, "@rbxts", "services"))
|
|
6
|
+
local Players = _services.Players
|
|
7
|
+
local VoiceChatService = _services.VoiceChatService
|
|
8
|
+
local function useVoicechatEnabled()
|
|
9
|
+
local enabled, setEnabled = useState(false)
|
|
10
|
+
useAsyncEffect(TS.async(function()
|
|
11
|
+
setEnabled(VoiceChatService:IsVoiceEnabledForUserIdAsync(Players.LocalPlayer.UserId))
|
|
12
|
+
end), {})
|
|
13
|
+
return enabled
|
|
14
|
+
end
|
|
15
|
+
return {
|
|
16
|
+
useVoicechatEnabled = useVoicechatEnabled,
|
|
17
|
+
}
|
package/out/index.d.ts
ADDED
package/out/init.luau
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local exports = {}
|
|
4
|
+
for _k, _v in TS.import(script, script, "components", "dropdown") or {} do
|
|
5
|
+
exports[_k] = _v
|
|
6
|
+
end
|
|
7
|
+
for _k, _v in TS.import(script, script, "components", "icon") or {} do
|
|
8
|
+
exports[_k] = _v
|
|
9
|
+
end
|
|
10
|
+
for _k, _v in TS.import(script, script, "components", "provider") or {} do
|
|
11
|
+
exports[_k] = _v
|
|
12
|
+
end
|
|
13
|
+
for _k, _v in TS.import(script, script, "components", "stylesheet") or {} do
|
|
14
|
+
exports[_k] = _v
|
|
15
|
+
end
|
|
16
|
+
return exports
|
package/out/style.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { SpringOptions } from '@rbxts/ripple';
|
|
2
|
+
import type { DropdownProps } from './components/dropdown';
|
|
3
|
+
import type { IconProps } from './components/icon';
|
|
4
|
+
export declare function noop(): void;
|
|
5
|
+
export interface Stylesheet {
|
|
6
|
+
icon: Required<IconProps>;
|
|
7
|
+
dropdown: Required<DropdownProps>;
|
|
8
|
+
/**
|
|
9
|
+
* Configure the top-level provider frame: padding, spacing, background, sizing.
|
|
10
|
+
*/
|
|
11
|
+
provider: {
|
|
12
|
+
paddingLeft: number;
|
|
13
|
+
paddingRight: number;
|
|
14
|
+
paddingTop: number;
|
|
15
|
+
paddingBottom: number;
|
|
16
|
+
iconSpacing: number;
|
|
17
|
+
backgroundTransparency: number;
|
|
18
|
+
backgroundColor: Color3;
|
|
19
|
+
anchorPoint: Vector2;
|
|
20
|
+
position: UDim2;
|
|
21
|
+
sizeScale: Vector2;
|
|
22
|
+
/** Offset subtracted from the gui inset height */
|
|
23
|
+
insetHeightOffset: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Fine-grained sizing & layout overrides for icon internals.
|
|
27
|
+
*/
|
|
28
|
+
sizing: {
|
|
29
|
+
/**
|
|
30
|
+
* Explicit icon height override.
|
|
31
|
+
* When defined, this replaces the automatic `forceHeight ?? inset.Height - 12` calculation.
|
|
32
|
+
*/
|
|
33
|
+
iconHeight: number | undefined;
|
|
34
|
+
/** Padding between the icon edge and the image (default 6) */
|
|
35
|
+
imagePadding: number;
|
|
36
|
+
/** Padding between the icon edge and the text label (default 6) */
|
|
37
|
+
labelPadding: number;
|
|
38
|
+
/** Gap between the image and the text label (default 6) */
|
|
39
|
+
imageToTextSpacing: number;
|
|
40
|
+
/** Max width passed to GetTextBoundsParams (default 99999) */
|
|
41
|
+
textMeasurementWidth: number;
|
|
42
|
+
/** Extra padding subtracted from the min label width inside a dropdown (default 12) */
|
|
43
|
+
minLabelWidthPadding: number;
|
|
44
|
+
/** Fraction of icon height used for the text button label size (default 0.8) */
|
|
45
|
+
buttonLabelHeightFraction: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Visual theming for the dropdown surface (background, border, position).
|
|
49
|
+
*/
|
|
50
|
+
dropdownTheme: {
|
|
51
|
+
backgroundColor: Color3;
|
|
52
|
+
backgroundTransparency: number;
|
|
53
|
+
cornerRadius: UDim;
|
|
54
|
+
borderSize: number;
|
|
55
|
+
borderColor: Color3;
|
|
56
|
+
borderTransparency: number;
|
|
57
|
+
/** Position of the dropdown relative to its parent icon (default (0, 1)) */
|
|
58
|
+
position: UDim2;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Global animation configuration.
|
|
62
|
+
*/
|
|
63
|
+
animation: {
|
|
64
|
+
/** Speed value used by the dropdown transition motion (default 10) */
|
|
65
|
+
dropdownTransitionSpeed: number;
|
|
66
|
+
/** Spring options for icon state transitions (color, transparency, etc.) */
|
|
67
|
+
stateSpring: SpringOptions;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export declare const DefaultStylesheet: Stylesheet;
|
package/out/style.luau
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local SoundService = TS.import(script, TS.getModule(script, "@rbxts", "services")).SoundService
|
|
4
|
+
local function defaultPlaySound(id)
|
|
5
|
+
local sound = Instance.new("Sound")
|
|
6
|
+
sound.SoundId = id
|
|
7
|
+
sound.Parent = SoundService
|
|
8
|
+
sound:Play()
|
|
9
|
+
sound.Ended:Once(function()
|
|
10
|
+
return sound:Destroy()
|
|
11
|
+
end)
|
|
12
|
+
end
|
|
13
|
+
local function noop()
|
|
14
|
+
end
|
|
15
|
+
local DefaultStylesheet = {
|
|
16
|
+
icon = {
|
|
17
|
+
fontFace = Font.new("rbxasset://fonts/families/GothamSSm.json", Enum.FontWeight.Medium, Enum.FontStyle.Normal),
|
|
18
|
+
strokeColor = Color3.fromRGB(0, 0, 0),
|
|
19
|
+
strokeThickness = 0,
|
|
20
|
+
strokeTransparency = 0,
|
|
21
|
+
textAlignment = Enum.TextXAlignment.Left,
|
|
22
|
+
cornerRadius = UDim.new(1, 0),
|
|
23
|
+
textColor = {
|
|
24
|
+
deselected = Color3.fromRGB(255, 255, 255),
|
|
25
|
+
selected = Color3.fromRGB(57, 60, 65),
|
|
26
|
+
},
|
|
27
|
+
backgroundColor = {
|
|
28
|
+
deselected = Color3.fromRGB(0, 0, 0),
|
|
29
|
+
selected = Color3.fromRGB(245, 245, 245),
|
|
30
|
+
},
|
|
31
|
+
backgroundTransparency = 0.3,
|
|
32
|
+
imageColor = {
|
|
33
|
+
deselected = Color3.fromRGB(255, 255, 255),
|
|
34
|
+
selected = Color3.fromRGB(57, 60, 65),
|
|
35
|
+
},
|
|
36
|
+
richText = false,
|
|
37
|
+
textSize = 20,
|
|
38
|
+
imageSizeOffset = -4,
|
|
39
|
+
imageRectOffset = Vector2.zero,
|
|
40
|
+
imageRectSize = Vector2.zero,
|
|
41
|
+
leftClickSound = "",
|
|
42
|
+
rightClickSound = "",
|
|
43
|
+
playSound = defaultPlaySound,
|
|
44
|
+
imageId = "",
|
|
45
|
+
imageTransparency = 0,
|
|
46
|
+
layoutOrder = 0,
|
|
47
|
+
text = "",
|
|
48
|
+
defaultState = "deselected",
|
|
49
|
+
forcedState = "deselected",
|
|
50
|
+
toggleStateOnClick = true,
|
|
51
|
+
selected = noop,
|
|
52
|
+
deselected = noop,
|
|
53
|
+
stateChanged = noop,
|
|
54
|
+
onClick = noop,
|
|
55
|
+
onRightClick = noop,
|
|
56
|
+
hover = noop,
|
|
57
|
+
unhover = noop,
|
|
58
|
+
children = {},
|
|
59
|
+
},
|
|
60
|
+
dropdown = {
|
|
61
|
+
maxWidth = 300,
|
|
62
|
+
minWidth = 200,
|
|
63
|
+
maxHeight = 200,
|
|
64
|
+
padding = UDim.new(0, 2.5),
|
|
65
|
+
forceHeight = 32,
|
|
66
|
+
iconCornerRadius = UDim.new(0, 0),
|
|
67
|
+
selectionMode = "Multiple",
|
|
68
|
+
children = {},
|
|
69
|
+
scrollBarThickness = 5,
|
|
70
|
+
scrollBarTransparency = 0,
|
|
71
|
+
scrollBarImageColor = Color3.new(1, 1, 1),
|
|
72
|
+
midImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
|
|
73
|
+
topImage = "rbxasset://textures/ui/Scroll/scroll-top.png",
|
|
74
|
+
bottomImage = "rbxasset://textures/ui/Scroll/scroll-bottom.png",
|
|
75
|
+
},
|
|
76
|
+
provider = {
|
|
77
|
+
paddingLeft = 8,
|
|
78
|
+
paddingRight = 12,
|
|
79
|
+
paddingTop = 11,
|
|
80
|
+
paddingBottom = 0,
|
|
81
|
+
iconSpacing = 12,
|
|
82
|
+
backgroundTransparency = 1,
|
|
83
|
+
backgroundColor = Color3.new(0, 0, 0),
|
|
84
|
+
anchorPoint = Vector2.new(1, 0),
|
|
85
|
+
position = UDim2.fromScale(1, 0),
|
|
86
|
+
sizeScale = Vector2.new(1, 1),
|
|
87
|
+
insetHeightOffset = 0,
|
|
88
|
+
},
|
|
89
|
+
sizing = {
|
|
90
|
+
iconHeight = nil,
|
|
91
|
+
imagePadding = 6,
|
|
92
|
+
labelPadding = 6,
|
|
93
|
+
imageToTextSpacing = 6,
|
|
94
|
+
textMeasurementWidth = 99999,
|
|
95
|
+
minLabelWidthPadding = 12,
|
|
96
|
+
buttonLabelHeightFraction = 0.8,
|
|
97
|
+
},
|
|
98
|
+
dropdownTheme = {
|
|
99
|
+
backgroundColor = Color3.new(1, 1, 1),
|
|
100
|
+
backgroundTransparency = 0,
|
|
101
|
+
cornerRadius = UDim.new(0, 0),
|
|
102
|
+
borderSize = 0,
|
|
103
|
+
borderColor = Color3.new(0, 0, 0),
|
|
104
|
+
borderTransparency = 1,
|
|
105
|
+
position = UDim2.fromScale(0, 1),
|
|
106
|
+
},
|
|
107
|
+
animation = {
|
|
108
|
+
dropdownTransitionSpeed = 10,
|
|
109
|
+
stateSpring = {
|
|
110
|
+
tension = 400,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
noop = noop,
|
|
116
|
+
DefaultStylesheet = DefaultStylesheet,
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createIdGenerator(): () => number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
local function deepCopy(original)
|
|
2
|
+
local copy = {}
|
|
3
|
+
|
|
4
|
+
for key, value in original do
|
|
5
|
+
copy[key] = type(value) == "table" and deepCopy(value) or value
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
return copy
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
local function reconcileTable(target, template)
|
|
12
|
+
for k, v in pairs(template) do
|
|
13
|
+
if type(k) == "string" then -- Only string keys will be reconciled
|
|
14
|
+
if target[k] == nil then
|
|
15
|
+
if type(v) == "table" then
|
|
16
|
+
target[k] = deepCopy(v)
|
|
17
|
+
else
|
|
18
|
+
target[k] = v
|
|
19
|
+
end
|
|
20
|
+
elseif type(target[k]) == "table" and type(v) == "table" then
|
|
21
|
+
reconcileTable(target[k], v)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
return target
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
return reconcileTable
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local t = TS.import(script, TS.getModule(script, "@rbxts", "t").lib.ts).t
|
|
4
|
+
local state_check = t.union(t.literal("selected"), t.literal("deselected"))
|
|
5
|
+
local object_check = t.interface({
|
|
6
|
+
selected = t.any,
|
|
7
|
+
deselected = t.any,
|
|
8
|
+
})
|
|
9
|
+
local function stateful(value, state)
|
|
10
|
+
local _arg0 = state_check(state)
|
|
11
|
+
local _arg1 = `Cannot resolve invalid state: {state}`
|
|
12
|
+
assert(_arg0, _arg1)
|
|
13
|
+
return if object_check(value) then value[state] else value
|
|
14
|
+
end
|
|
15
|
+
return {
|
|
16
|
+
stateful = stateful,
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SpringOptions } from '@rbxts/ripple';
|
|
2
|
+
export declare const springs: {
|
|
3
|
+
bubbly: {
|
|
4
|
+
tension: number;
|
|
5
|
+
friction: number;
|
|
6
|
+
};
|
|
7
|
+
responsive: {
|
|
8
|
+
tension: number;
|
|
9
|
+
};
|
|
10
|
+
gentle: {
|
|
11
|
+
tension: number;
|
|
12
|
+
friction: number;
|
|
13
|
+
};
|
|
14
|
+
world: {
|
|
15
|
+
tension: number;
|
|
16
|
+
friction: number;
|
|
17
|
+
};
|
|
18
|
+
default: SpringOptions;
|
|
19
|
+
wobbly: SpringOptions;
|
|
20
|
+
stiff: SpringOptions;
|
|
21
|
+
slow: SpringOptions;
|
|
22
|
+
molasses: SpringOptions;
|
|
23
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v1.0.2
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local config = TS.import(script, TS.getModule(script, "@rbxts", "ripple").src).config
|
|
4
|
+
local _object = table.clone(config.spring)
|
|
5
|
+
setmetatable(_object, nil)
|
|
6
|
+
_object.bubbly = {
|
|
7
|
+
tension = 400,
|
|
8
|
+
friction = 14,
|
|
9
|
+
}
|
|
10
|
+
_object.responsive = {
|
|
11
|
+
tension = 400,
|
|
12
|
+
}
|
|
13
|
+
_object.gentle = {
|
|
14
|
+
tension = 250,
|
|
15
|
+
friction = 30,
|
|
16
|
+
}
|
|
17
|
+
_object.world = {
|
|
18
|
+
tension = 180,
|
|
19
|
+
friction = 30,
|
|
20
|
+
}
|
|
21
|
+
local springs = _object
|
|
22
|
+
return {
|
|
23
|
+
springs = springs,
|
|
24
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type ContainsNominal<K> = K extends `_nominal_${string}` ? true : never;
|
|
2
|
+
export type DeepPartial<T> = true extends ContainsNominal<keyof T> ? T : T extends EnumItem ? T : T extends Map<any, any> ? T : T extends (...args: any[]) => any ? T : T extends object ? {
|
|
3
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
4
|
+
} : T;
|
|
5
|
+
export {};
|