@quenty/basicpane 13.17.0 → 13.17.1
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/CHANGELOG.md +11 -0
- package/package.json +9 -9
- package/src/Shared/BasicPane.lua +33 -16
- package/src/Shared/BasicPaneUtils.lua +23 -20
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [13.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/basicpane@13.17.0...@quenty/basicpane@13.17.1) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [13.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/basicpane@13.16.2...@quenty/basicpane@13.17.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/basicpane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/basicpane",
|
|
3
|
-
"version": "13.17.
|
|
3
|
+
"version": "13.17.1",
|
|
4
4
|
"description": "Base UI object with visibility and a maid",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/brio": "^14.17.
|
|
29
|
-
"@quenty/ducktype": "^5.8.
|
|
30
|
-
"@quenty/loader": "^10.8.
|
|
31
|
-
"@quenty/maid": "^3.4.
|
|
32
|
-
"@quenty/rx": "^13.17.
|
|
33
|
-
"@quenty/signal": "^7.10.
|
|
34
|
-
"@quenty/valueobject": "^13.17.
|
|
28
|
+
"@quenty/brio": "^14.17.1",
|
|
29
|
+
"@quenty/ducktype": "^5.8.2",
|
|
30
|
+
"@quenty/loader": "^10.8.1",
|
|
31
|
+
"@quenty/maid": "^3.4.1",
|
|
32
|
+
"@quenty/rx": "^13.17.1",
|
|
33
|
+
"@quenty/signal": "^7.10.1",
|
|
34
|
+
"@quenty/valueobject": "^13.17.1"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
40
40
|
}
|
package/src/Shared/BasicPane.lua
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Base UI object with visibility and a maid. BasicPane provides three points of utility.
|
|
3
4
|
|
|
@@ -21,22 +22,35 @@
|
|
|
21
22
|
|
|
22
23
|
local require = require(script.Parent.loader).load(script)
|
|
23
24
|
|
|
24
|
-
local Signal = require("Signal")
|
|
25
|
-
local Maid = require("Maid")
|
|
26
25
|
local DuckTypeUtils = require("DuckTypeUtils")
|
|
26
|
+
local Maid = require("Maid")
|
|
27
|
+
local Signal = require("Signal")
|
|
27
28
|
local ValueObject = require("ValueObject")
|
|
29
|
+
local _Brio = require("Brio")
|
|
30
|
+
local _Observable = require("Observable")
|
|
31
|
+
local _Rx = require("Rx")
|
|
28
32
|
|
|
29
33
|
local BasicPane = {}
|
|
30
34
|
BasicPane.ClassName = "BasicPane"
|
|
31
35
|
BasicPane.__index = BasicPane
|
|
32
36
|
|
|
37
|
+
export type BasicPane = typeof(setmetatable(
|
|
38
|
+
{} :: {
|
|
39
|
+
_maid: Maid.Maid,
|
|
40
|
+
_visible: ValueObject.ValueObject<boolean>,
|
|
41
|
+
Gui: GuiBase?,
|
|
42
|
+
VisibleChanged: Signal.Signal<(boolean, boolean)>,
|
|
43
|
+
},
|
|
44
|
+
BasicPane
|
|
45
|
+
))
|
|
46
|
+
|
|
33
47
|
--[=[
|
|
34
48
|
Constructs a new BasicPane with the .Gui property set.
|
|
35
49
|
|
|
36
50
|
@param gui GuiBase? -- Optional Gui object
|
|
37
51
|
@return BasicPane
|
|
38
52
|
]=]
|
|
39
|
-
function BasicPane.new(gui)
|
|
53
|
+
function BasicPane.new(gui: GuiBase?): BasicPane
|
|
40
54
|
local self = setmetatable({}, BasicPane)
|
|
41
55
|
|
|
42
56
|
self._maid = Maid.new()
|
|
@@ -69,7 +83,7 @@ function BasicPane.new(gui)
|
|
|
69
83
|
self.Gui = self._maid:Add(gui)
|
|
70
84
|
end
|
|
71
85
|
|
|
72
|
-
return self
|
|
86
|
+
return self :: any
|
|
73
87
|
end
|
|
74
88
|
|
|
75
89
|
--[=[
|
|
@@ -77,7 +91,7 @@ end
|
|
|
77
91
|
@param value any
|
|
78
92
|
@return boolean
|
|
79
93
|
]=]
|
|
80
|
-
function BasicPane.isBasicPane(value)
|
|
94
|
+
function BasicPane.isBasicPane(value: any): boolean
|
|
81
95
|
return DuckTypeUtils.isImplementation(BasicPane, value)
|
|
82
96
|
end
|
|
83
97
|
|
|
@@ -87,7 +101,7 @@ end
|
|
|
87
101
|
@param isVisible boolean -- Whether or not the pane should be visible
|
|
88
102
|
@param doNotAnimate boolean? -- True if this visiblity should not animate
|
|
89
103
|
]=]
|
|
90
|
-
function BasicPane
|
|
104
|
+
function BasicPane.SetVisible(self: BasicPane, isVisible: boolean, doNotAnimate: boolean?)
|
|
91
105
|
assert(type(isVisible) == "boolean", "Bad isVisible")
|
|
92
106
|
|
|
93
107
|
self._visible:SetValue(isVisible, doNotAnimate)
|
|
@@ -98,7 +112,7 @@ end
|
|
|
98
112
|
|
|
99
113
|
@return Observable<boolean, boolean?>
|
|
100
114
|
]=]
|
|
101
|
-
function BasicPane
|
|
115
|
+
function BasicPane.ObserveVisible(self: BasicPane): _Observable.Observable<boolean, boolean?>
|
|
102
116
|
return self._visible:Observe()
|
|
103
117
|
end
|
|
104
118
|
|
|
@@ -108,7 +122,10 @@ end
|
|
|
108
122
|
@param predicate function | nil -- Optional predicate. If not includeded returns the value.
|
|
109
123
|
@return Observable<Brio<boolean>>
|
|
110
124
|
]=]
|
|
111
|
-
function BasicPane
|
|
125
|
+
function BasicPane.ObserveVisibleBrio(
|
|
126
|
+
self: BasicPane,
|
|
127
|
+
predicate: _Rx.Predicate<boolean>?
|
|
128
|
+
): _Observable.Observable<_Brio.Brio<boolean>?>
|
|
112
129
|
return self._visible:ObserveBrio(predicate or function(isVisible)
|
|
113
130
|
return isVisible
|
|
114
131
|
end)
|
|
@@ -118,7 +135,7 @@ end
|
|
|
118
135
|
Shows the pane
|
|
119
136
|
@param doNotAnimate boolean? -- True if this visiblity should not animate
|
|
120
137
|
]=]
|
|
121
|
-
function BasicPane
|
|
138
|
+
function BasicPane.Show(self: BasicPane, doNotAnimate: boolean?)
|
|
122
139
|
self:SetVisible(true, doNotAnimate)
|
|
123
140
|
end
|
|
124
141
|
|
|
@@ -126,7 +143,7 @@ end
|
|
|
126
143
|
Hides the pane
|
|
127
144
|
@param doNotAnimate boolean? -- True if this visiblity should not animate
|
|
128
145
|
]=]
|
|
129
|
-
function BasicPane
|
|
146
|
+
function BasicPane.Hide(self: BasicPane, doNotAnimate: boolean?)
|
|
130
147
|
self:SetVisible(false, doNotAnimate)
|
|
131
148
|
end
|
|
132
149
|
|
|
@@ -134,7 +151,7 @@ end
|
|
|
134
151
|
Toggles the pane
|
|
135
152
|
@param doNotAnimate boolean? -- True if this visiblity should not animate
|
|
136
153
|
]=]
|
|
137
|
-
function BasicPane
|
|
154
|
+
function BasicPane.Toggle(self: BasicPane, doNotAnimate: boolean?)
|
|
138
155
|
self:SetVisible(not self._visible.Value, doNotAnimate)
|
|
139
156
|
end
|
|
140
157
|
|
|
@@ -142,7 +159,7 @@ end
|
|
|
142
159
|
Returns if the pane is visible
|
|
143
160
|
@return boolean
|
|
144
161
|
]=]
|
|
145
|
-
function BasicPane
|
|
162
|
+
function BasicPane.IsVisible(self: BasicPane): boolean
|
|
146
163
|
return self._visible.Value
|
|
147
164
|
end
|
|
148
165
|
|
|
@@ -150,10 +167,10 @@ end
|
|
|
150
167
|
Cleans up the BasicPane, invoking Maid:DoCleaning() on the BasicPane and
|
|
151
168
|
setting the metatable to nil.
|
|
152
169
|
]=]
|
|
153
|
-
function BasicPane
|
|
154
|
-
self._maid:DoCleaning()
|
|
155
|
-
self._maid = nil
|
|
156
|
-
setmetatable(self, nil)
|
|
170
|
+
function BasicPane.Destroy(self: BasicPane)
|
|
171
|
+
(self :: any)._maid:DoCleaning();
|
|
172
|
+
(self :: any)._maid = nil
|
|
173
|
+
setmetatable(self :: any, nil)
|
|
157
174
|
end
|
|
158
175
|
|
|
159
176
|
return BasicPane
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class BasicPaneUtils
|
|
3
4
|
]=]
|
|
@@ -9,6 +10,7 @@ local Maid = require("Maid")
|
|
|
9
10
|
local Rx = require("Rx")
|
|
10
11
|
local BasicPane = require("BasicPane")
|
|
11
12
|
local Brio = require("Brio")
|
|
13
|
+
local _Subscription = require("Subscription")
|
|
12
14
|
|
|
13
15
|
local BasicPaneUtils = {}
|
|
14
16
|
|
|
@@ -24,12 +26,14 @@ local BasicPaneUtils = {}
|
|
|
24
26
|
@param basicPane BasicPane
|
|
25
27
|
@return Observable<boolean>
|
|
26
28
|
]=]
|
|
27
|
-
function BasicPaneUtils.observeVisible(basicPane)
|
|
29
|
+
function BasicPaneUtils.observeVisible(basicPane: BasicPane.BasicPane): Observable.Observable<boolean>
|
|
28
30
|
assert(BasicPane.isBasicPane(basicPane), "Bad BasicPane")
|
|
29
31
|
|
|
30
32
|
return basicPane:ObserveVisible()
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
export type CreateBasicPane = (maid: Maid.Maid) -> BasicPane.BasicPane
|
|
36
|
+
|
|
33
37
|
--[=[
|
|
34
38
|
Shows the basic pane only when the emitting observable is visible. This
|
|
35
39
|
allows the basic pane 1 second to hide. If the pane gets reshown in that
|
|
@@ -55,14 +59,13 @@ end
|
|
|
55
59
|
@param createBasicPane (maid: Maid) -> BasicPane
|
|
56
60
|
@return (source: Observable<boolean>) -> Observable<Brio<GuiBase>>
|
|
57
61
|
]=]
|
|
58
|
-
function BasicPaneUtils.whenVisibleBrio(createBasicPane)
|
|
59
|
-
return function(source)
|
|
60
|
-
return Observable.new(function(sub)
|
|
62
|
+
function BasicPaneUtils.whenVisibleBrio(createBasicPane: CreateBasicPane) --: Observable.Transformer<(boolean), (Brio.Brio<GuiBase>)>
|
|
63
|
+
return function(source: Observable.Observable<boolean>): Observable.Observable<Brio.Brio<GuiBase>>
|
|
64
|
+
return Observable.new(function(sub: _Subscription.Subscription<Brio.Brio<GuiBase>>)
|
|
61
65
|
local maid = Maid.new()
|
|
66
|
+
local currentPane: BasicPane.BasicPane? = nil
|
|
62
67
|
|
|
63
|
-
local
|
|
64
|
-
|
|
65
|
-
local function ensurePane()
|
|
68
|
+
local function ensurePane(): BasicPane.BasicPane
|
|
66
69
|
if currentPane then
|
|
67
70
|
return currentPane
|
|
68
71
|
end
|
|
@@ -73,7 +76,7 @@ function BasicPaneUtils.whenVisibleBrio(createBasicPane)
|
|
|
73
76
|
assert(BasicPane.isBasicPane(basicPane), "Bad BasicPane")
|
|
74
77
|
paneMaid:GiveTask(basicPane)
|
|
75
78
|
|
|
76
|
-
local brio = Brio.new(basicPane.Gui)
|
|
79
|
+
local brio: Brio.Brio<GuiBase> = Brio.new(basicPane.Gui) :: any
|
|
77
80
|
paneMaid:GiveTask(brio)
|
|
78
81
|
|
|
79
82
|
do
|
|
@@ -89,10 +92,10 @@ function BasicPaneUtils.whenVisibleBrio(createBasicPane)
|
|
|
89
92
|
maid._currentPaneMaid = paneMaid
|
|
90
93
|
sub:Fire(brio)
|
|
91
94
|
|
|
92
|
-
return currentPane
|
|
95
|
+
return currentPane :: any
|
|
93
96
|
end
|
|
94
97
|
|
|
95
|
-
maid:GiveTask(source:Subscribe(function(isVisible)
|
|
98
|
+
maid:GiveTask(source:Subscribe(function(isVisible: boolean)
|
|
96
99
|
if isVisible then
|
|
97
100
|
maid._hideTask = nil
|
|
98
101
|
ensurePane():Show()
|
|
@@ -108,7 +111,7 @@ function BasicPaneUtils.whenVisibleBrio(createBasicPane)
|
|
|
108
111
|
end))
|
|
109
112
|
|
|
110
113
|
return maid
|
|
111
|
-
end)
|
|
114
|
+
end) :: any
|
|
112
115
|
end
|
|
113
116
|
end
|
|
114
117
|
|
|
@@ -118,15 +121,15 @@ end
|
|
|
118
121
|
@param basicPane BasicPane
|
|
119
122
|
@return Observable<number>
|
|
120
123
|
]=]
|
|
121
|
-
function BasicPaneUtils.observePercentVisible(basicPane)
|
|
124
|
+
function BasicPaneUtils.observePercentVisible(basicPane: BasicPane.BasicPane): Observable.Observable<number>
|
|
122
125
|
assert(BasicPane.isBasicPane(basicPane), "Bad BasicPane")
|
|
123
126
|
|
|
124
127
|
return BasicPaneUtils.observeVisible(basicPane):Pipe({
|
|
125
|
-
Rx.map(function(visible)
|
|
128
|
+
Rx.map(function(visible: boolean): number
|
|
126
129
|
return visible and 1 or 0
|
|
127
|
-
end)
|
|
128
|
-
Rx.startWith({0})
|
|
129
|
-
})
|
|
130
|
+
end) :: any,
|
|
131
|
+
Rx.startWith({ 0 }) :: any, -- Ensure fade in every time.
|
|
132
|
+
}) :: any
|
|
130
133
|
end
|
|
131
134
|
|
|
132
135
|
--[=[
|
|
@@ -148,12 +151,12 @@ end)
|
|
|
148
151
|
@param basicPane BasicPane
|
|
149
152
|
@return Observable<boolean>
|
|
150
153
|
]=]
|
|
151
|
-
function BasicPaneUtils.observeShow(basicPane)
|
|
154
|
+
function BasicPaneUtils.observeShow(basicPane: BasicPane.BasicPane): Observable.Observable<boolean>
|
|
152
155
|
return BasicPaneUtils.observeVisible(basicPane):Pipe({
|
|
153
156
|
Rx.where(function(isVisible)
|
|
154
157
|
return isVisible
|
|
155
|
-
end)
|
|
156
|
-
})
|
|
158
|
+
end) :: any,
|
|
159
|
+
}) :: any
|
|
157
160
|
end
|
|
158
161
|
|
|
159
|
-
return BasicPaneUtils
|
|
162
|
+
return BasicPaneUtils
|