-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: vide and iris support, feat: control ordering
- Loading branch information
1 parent
213ae6e
commit a86ea4d
Showing
31 changed files
with
446 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
*.tsbuildinfo | ||
.DS_Store | ||
sourcemap.json | ||
/out | ||
|
||
/build.rbxm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { DatatypeControl, Datatypes, IsDatatype } from "./Datatypes"; | ||
import { IsPrimitive, PrimitiveControl, Primitives } from "./Primitives"; | ||
import { AllControls, ObjectControl } from "./Typing"; | ||
|
||
type ExtractWidenKeys<T, U> = { [K in keyof T]: U extends T[K] ? K : never }[keyof T]; | ||
|
||
type ConvertControl<T extends AllControls> = T extends IsPrimitive | ||
? PrimitiveControl<ExtractWidenKeys<Primitives, T>> | ||
: T extends IsDatatype | ||
? DatatypeControl<ExtractWidenKeys<Datatypes, T>> | ||
: T extends ObjectControl | ||
? T | ||
: never; | ||
|
||
declare function ConvertControl<T extends AllControls>(control: T): ConvertControl<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import { ControlsList } from "./Typing"; | ||
import { ConvertControl } from "./ControlConversion"; | ||
import { AllControls, ControlsList } from "./Typing"; | ||
|
||
interface ControlGroup<T extends ControlsList = ControlsList> { | ||
EntryType: "ControlGroup"; | ||
Order?: number; | ||
Controls: T; | ||
} | ||
|
||
declare function ControlGroup<T extends ControlsList>(controls: T): ControlGroup<T>; | ||
declare function ControlGroup<T extends ControlsList>(controls: T, order?: number): ControlGroup<T>; | ||
|
||
declare function Ordered<T extends AllControls>(control: T, order: number): ConvertControl<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local Primitive = require(script.Parent.PrimitiveControls).Primitive | ||
local Datatype = require(script.Parent.DatatypeControls) | ||
|
||
local ControlConversion = {} | ||
|
||
local function ConvertPrimitive(value: any, primitive: string) | ||
local converter = Primitive[primitive] | ||
|
||
assert(converter, `UI-Labs: Primitive ({primitive}) can't be converted to a control`) | ||
return converter(value) | ||
end | ||
|
||
local function ConvertDatatype(value: any, datatype: string) | ||
local converter = Datatype[datatype] | ||
|
||
assert(converter, `UI-Labs: Datatype ({datatype}) can't be converted to a control`) | ||
return converter(value) | ||
end | ||
|
||
function ControlConversion.ConvertControl(control: any) | ||
local controlType = typeof(control) | ||
|
||
if controlType == "table" then | ||
return control | ||
end | ||
|
||
if Primitive[controlType] then | ||
return ConvertPrimitive(control, controlType) | ||
elseif Datatype[controlType] then | ||
return ConvertDatatype(control, controlType) | ||
else | ||
error(`UI-Labs: Control ({control}) is not a valid control`) | ||
end | ||
end | ||
|
||
return ControlConversion |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local ControlConversion = require(script.Parent.ControlConversion) | ||
local ControlUtils = {} | ||
|
||
function ControlUtils.ControlGroup(controls: { [string]: any }) | ||
local group = { | ||
EntryType = "ControlGroup", | ||
Controls = controls, | ||
} | ||
return group | ||
end | ||
|
||
function ControlUtils.Ordered<T>(control: T, order: number): T | ||
local converted = ControlConversion.ConvertControl(control) | ||
converted.Order = order | ||
return converted | ||
end | ||
|
||
return ControlUtils |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,36 @@ | ||
//Types Borrowed from @rbxts/signal | ||
// types from @rbxts/lemon-signal | ||
|
||
export interface Signal<ConnectedFunctionSignature extends (...args: any) => any = () => void, Generic extends boolean = false> { | ||
/** | ||
* Fires the BindableEvent with any number of arguments | ||
* @param args The arguments to pass into the connected functions | ||
*/ | ||
Fire(...args: Parameters<ConnectedFunctionSignature>): void; | ||
export declare type SignalParameters<T> = Parameters< | ||
T extends unknown[] ? (...args: T) => never : T extends unknown ? (arg: T) => never : () => never | ||
>; | ||
|
||
/** | ||
* Establishes a function to be called when the event fires. | ||
* Returns a `RBXScriptConnection` object associated with the connection. | ||
* @param callback The function to connect to `BindableEvent.Event` | ||
*/ | ||
Connect<O extends Array<unknown> = Parameters<ConnectedFunctionSignature>>( | ||
callback: Generic extends true | ||
? Parameters<ConnectedFunctionSignature> extends Array<unknown> | ||
? (...args: O) => void | ||
: ConnectedFunctionSignature | ||
: ConnectedFunctionSignature, | ||
): RBXScriptConnection; | ||
export declare type SignalCallback<T> = (...args: SignalParameters<T>) => unknown; | ||
export declare type SignalWait<T> = T extends unknown[] ? LuaTuple<T> : T; | ||
|
||
/** | ||
* Establishes a function to be called when the event fires. | ||
* Returns a `RBXScriptConnection` object associated with the connection. | ||
* When the event fires, the signal callback is executed in a desynchronized state. | ||
* Using `ConnectParallel` is similar to, but more efficient than, using `Connect` followed by a call to `task.desynchronize()` in the signal handler. | ||
* Note: Scripts that connect in parallel must be rooted under an Actor. | ||
* @param callback The function to connect to `BindableEvent.Event` | ||
*/ | ||
ConnectParallel<O extends Array<unknown> = Parameters<ConnectedFunctionSignature>>( | ||
callback: Generic extends true | ||
? Parameters<ConnectedFunctionSignature> extends Array<unknown> | ||
? (...args: O) => void | ||
: ConnectedFunctionSignature | ||
: ConnectedFunctionSignature, | ||
): RBXScriptConnection; | ||
export declare class Connection<T> { | ||
public readonly Connected: boolean; | ||
|
||
/** | ||
* Establishes a function to be called when the event fires. | ||
* Returns a `RBXScriptConnection` object associated with the connection. | ||
* The behavior of `Once` is similar to `Connect`. | ||
* However, instead of allowing multiple events to be received by the specified function, only the first event will be delivered. | ||
* Using `Once` also ensures that the connection to the function will be automatically disconnected prior the function being called. | ||
* @param callback The function to connect to `BindableEvent.Event` | ||
*/ | ||
Once<O extends Array<unknown> = Parameters<ConnectedFunctionSignature>>( | ||
callback: Generic extends true | ||
? Parameters<ConnectedFunctionSignature> extends Array<unknown> | ||
? (...args: O) => void | ||
: ConnectedFunctionSignature | ||
: ConnectedFunctionSignature, | ||
): RBXScriptConnection; | ||
public Destroy(): void; | ||
public Disconnect(): void; | ||
public Reconnect(): void; | ||
} | ||
|
||
export declare class Signal<T> { | ||
public readonly RBXScriptConnection?: RBXScriptConnection; | ||
public readonly TotalConnections?: number; | ||
public readonly OnConnectionsChanged: Signal<number>; | ||
|
||
/** | ||
* Yields the current thread until the thread is fired. | ||
*/ | ||
Wait(): LuaTuple<Parameters<ConnectedFunctionSignature>>; | ||
public constructor(trackConnections?: boolean); | ||
public static is: <O extends object>(object: O) => boolean; | ||
public static wrap: <T extends Callback>( | ||
signal: RBXScriptSignal<T>, | ||
trackConnections?: boolean, | ||
) => Signal<Parameters<T>>; | ||
|
||
/** | ||
* Destroys the Signal | ||
*/ | ||
Destroy(): void; | ||
public Connect(fn: SignalCallback<T>): Connection<T>; | ||
public Once(fn: SignalCallback<T>): Connection<T>; | ||
public Wait(): SignalWait<T>; | ||
public Fire(...args: SignalParameters<T>): void; | ||
public DisconnectAll(): void; | ||
public Destroy(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.