cordo 2.2.0 → 2.2.2
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/package.json
CHANGED
|
@@ -24,6 +24,15 @@ export function container(...components: AllowedComponentArray) {
|
|
|
24
24
|
spoiler: (value: boolean = true) => {
|
|
25
25
|
spoiler = value
|
|
26
26
|
return out
|
|
27
|
+
},
|
|
28
|
+
*[Symbol.iterator]() {
|
|
29
|
+
for (const component of components) {
|
|
30
|
+
if (Array.isArray(component)) {
|
|
31
|
+
yield* component
|
|
32
|
+
} else {
|
|
33
|
+
yield component
|
|
34
|
+
}
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ButtonStyle } from "discord-api-types/v10"
|
|
2
|
+
import { ComponentType, createComponent } from "../component"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function skuButton(skuId: string) {
|
|
6
|
+
const out = {
|
|
7
|
+
...createComponent('Button', () => ({
|
|
8
|
+
type: ComponentType.Button,
|
|
9
|
+
style: ButtonStyle.Premium,
|
|
10
|
+
sku_id: skuId
|
|
11
|
+
})),
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return out
|
|
15
|
+
}
|
|
@@ -38,7 +38,7 @@ export type CordoComponent<Type extends StringComponentType = StringComponentTyp
|
|
|
38
38
|
}
|
|
39
39
|
visible: (value: boolean) => CordoComponent<Type>
|
|
40
40
|
attributes: (attrs: Record<string, any>) => CordoComponent<Type>
|
|
41
|
-
}
|
|
41
|
+
} & (Type extends 'Container' ? { [Symbol.iterator]: () => Iterator<CordoComponent<StringComponentType>> } : { [Symbol.iterator]: never })
|
|
42
42
|
export type CordoComponentPayload<Type extends StringComponentType> = CordoComponent<Type>[typeof CordoComponentSymbol]
|
|
43
43
|
|
|
44
44
|
export function createComponent<Type extends StringComponentType>(
|
|
@@ -63,7 +63,7 @@ export function createComponent<Type extends StringComponentType>(
|
|
|
63
63
|
return this
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
return out
|
|
66
|
+
return out as any as CordoComponent<Type>
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export function readComponent<T extends CordoComponent<StringComponentType>>(comp: T): T[typeof CordoComponentSymbol] {
|
package/src/components/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { linkButton } from './builtin/link-button'
|
|
|
19
19
|
export { row } from './builtin/row'
|
|
20
20
|
export { section } from './builtin/section'
|
|
21
21
|
export { selectString } from './builtin/select-string'
|
|
22
|
+
export { skuButton } from './builtin/sku-button'
|
|
22
23
|
export { spacer } from './builtin/spacer'
|
|
23
24
|
export { text } from './builtin/text'
|
|
24
25
|
|