@devvit/ui-renderer 0.9.0 → 0.9.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/blocks/attributes.d.ts +3 -1
- package/blocks/attributes.d.ts.map +1 -1
- package/blocks/attributes.js +29 -17
- package/blocks/components/devvit-blocks-webview.d.ts +2 -0
- package/blocks/components/devvit-blocks-webview.d.ts.map +1 -0
- package/blocks/components/devvit-blocks-webview.js +81 -0
- package/blocks/templates/index.d.ts +4 -5
- package/blocks/templates/index.d.ts.map +1 -1
- package/blocks/templates/index.js +5 -4
- package/blocks/templates/renderAnimationBlock.d.ts.map +1 -1
- package/blocks/templates/renderAnimationBlock.js +4 -1
- package/blocks/templates/renderAvatarBlock.d.ts.map +1 -1
- package/blocks/templates/renderAvatarBlock.js +4 -1
- package/blocks/templates/renderBlock.d.ts.map +1 -1
- package/blocks/templates/renderBlock.js +31 -10
- package/blocks/templates/renderButtonBlock.d.ts.map +1 -1
- package/blocks/templates/renderButtonBlock.js +11 -2
- package/blocks/templates/renderFullSnooBlock.d.ts.map +1 -1
- package/blocks/templates/renderFullSnooBlock.js +4 -1
- package/blocks/templates/renderIconBlock.d.ts.map +1 -1
- package/blocks/templates/renderIconBlock.js +6 -2
- package/blocks/templates/renderImageBlock.d.ts.map +1 -1
- package/blocks/templates/renderImageBlock.js +4 -1
- package/blocks/templates/renderSpacerBlock.d.ts.map +1 -1
- package/blocks/templates/renderSpacerBlock.js +8 -2
- package/blocks/templates/renderStackBlock.d.ts.map +1 -1
- package/blocks/templates/renderStackBlock.js +21 -2
- package/blocks/templates/renderTextBlock.d.ts.map +1 -1
- package/blocks/templates/renderTextBlock.js +4 -1
- package/blocks/templates/renderWebViewBlock.d.ts +1 -0
- package/blocks/templates/renderWebViewBlock.d.ts.map +1 -1
- package/blocks/templates/renderWebViewBlock.js +9 -16
- package/client/devvit-custom-post.d.ts +2 -2
- package/client/devvit-custom-post.d.ts.map +1 -1
- package/client/devvit-custom-post.js +23 -12
- package/client/effects/form-effect-handler.d.ts +1 -0
- package/client/effects/form-effect-handler.d.ts.map +1 -1
- package/client/effects/form-effect-handler.js +9 -5
- package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts +17 -0
- package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts.map +1 -0
- package/client/formbuilder/components/devvit-form-selection-dropdown.js +138 -0
- package/client/formbuilder/components/devvit-form-selection-list.d.ts +14 -0
- package/client/formbuilder/components/devvit-form-selection-list.d.ts.map +1 -0
- package/client/formbuilder/components/devvit-form-selection-list.js +91 -0
- package/client/formbuilder/devvit-form-dialog.d.ts +17 -0
- package/client/formbuilder/devvit-form-dialog.d.ts.map +1 -0
- package/client/formbuilder/devvit-form-dialog.js +152 -0
- package/client/formbuilder/fields/index.d.ts +12 -0
- package/client/formbuilder/fields/index.d.ts.map +1 -0
- package/client/formbuilder/fields/index.js +10 -0
- package/client/formbuilder/fields/renderBooleanField.d.ts +4 -0
- package/client/formbuilder/fields/renderBooleanField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderBooleanField.js +14 -0
- package/client/formbuilder/fields/renderFieldLabel.d.ts +3 -0
- package/client/formbuilder/fields/renderFieldLabel.d.ts.map +1 -0
- package/client/formbuilder/fields/renderFieldLabel.js +3 -0
- package/client/formbuilder/fields/renderFormFields.d.ts +4 -0
- package/client/formbuilder/fields/renderFormFields.d.ts.map +1 -0
- package/client/formbuilder/fields/renderFormFields.js +18 -0
- package/client/formbuilder/fields/renderGroupField.d.ts +3 -0
- package/client/formbuilder/fields/renderGroupField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderGroupField.js +13 -0
- package/client/formbuilder/fields/renderHelpText.d.ts +4 -0
- package/client/formbuilder/fields/renderHelpText.d.ts.map +1 -0
- package/client/formbuilder/fields/renderHelpText.js +3 -0
- package/client/formbuilder/fields/renderListField.d.ts +2 -0
- package/client/formbuilder/fields/renderListField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderListField.js +1 -0
- package/client/formbuilder/fields/renderNumberField.d.ts +4 -0
- package/client/formbuilder/fields/renderNumberField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderNumberField.js +23 -0
- package/client/formbuilder/fields/renderParagraphField.d.ts +5 -0
- package/client/formbuilder/fields/renderParagraphField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderParagraphField.js +25 -0
- package/client/formbuilder/fields/renderSelectionField.d.ts +5 -0
- package/client/formbuilder/fields/renderSelectionField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderSelectionField.js +18 -0
- package/client/formbuilder/fields/renderStringField.d.ts +4 -0
- package/client/formbuilder/fields/renderStringField.d.ts.map +1 -0
- package/client/formbuilder/fields/renderStringField.js +24 -0
- package/client/formbuilder/index.d.ts +2 -0
- package/client/formbuilder/index.d.ts.map +1 -0
- package/client/formbuilder/index.js +1 -0
- package/package.json +28 -22
- package/styles.css +793 -51
- package/styles.d.ts +2 -0
- package/styles.d.ts.map +1 -0
- package/styles.js +3 -0
- package/types/events.d.ts +20 -0
- package/types/events.d.ts.map +1 -0
- package/types/events.js +1 -0
- package/tailwind.devvit.cjs +0 -15
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TemplateLike } from '@reddit/baseplate/html.js';
|
|
2
2
|
import { Block } from '@devvit/protos';
|
|
3
3
|
import { RenderContext } from './index.js';
|
|
4
|
+
import '../components/devvit-blocks-webview.js';
|
|
4
5
|
export declare function renderWebViewBlock(block: Block, ctx: RenderContext): TemplateLike;
|
|
5
6
|
//# sourceMappingURL=renderWebViewBlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWebViewBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderWebViewBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"renderWebViewBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderWebViewBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,wCAAwC,CAAC;AAEhD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA2BjF"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { nothing } from '@reddit/baseplate/html.js';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import { sizingClass, sizingStyle } from '../attributes.js';
|
|
3
|
+
import { defaultClasses, sizingClass, sizingStyle, stackChildClass } from '../attributes.js';
|
|
4
4
|
import { classMap } from './index.js';
|
|
5
|
-
|
|
6
|
-
const postMessage = (src, ctx) => {
|
|
7
|
-
const iframe = iframeRefs[src];
|
|
8
|
-
iframe?.contentWindow?.postMessage(ctx, '*');
|
|
9
|
-
};
|
|
5
|
+
import '../components/devvit-blocks-webview.js';
|
|
10
6
|
export function renderWebViewBlock(block, ctx) {
|
|
11
7
|
const { html, styleMap } = getTemplateRenderingStrategy();
|
|
12
8
|
if (!block.config?.webviewConfig) {
|
|
@@ -15,22 +11,19 @@ export function renderWebViewBlock(block, ctx) {
|
|
|
15
11
|
}
|
|
16
12
|
const { url } = block.config.webviewConfig;
|
|
17
13
|
const classes = {
|
|
14
|
+
...defaultClasses(block.type),
|
|
15
|
+
...stackChildClass(ctx.stackDirection),
|
|
18
16
|
...sizingClass(block.size),
|
|
19
17
|
};
|
|
20
18
|
const styles = {
|
|
21
19
|
...sizingStyle(block.size),
|
|
22
20
|
};
|
|
23
|
-
|
|
24
|
-
iframeRefs[url] = evt.target;
|
|
25
|
-
postMessage(url, ctx);
|
|
26
|
-
};
|
|
27
|
-
const saveRef = (el) => (iframeRefs[url] = el);
|
|
28
|
-
return html `<iframe
|
|
21
|
+
return html `<devvit-blocks-webview
|
|
29
22
|
src="${url}"
|
|
30
|
-
sandbox="allow-scripts"
|
|
31
23
|
class="${classMap(classes)}"
|
|
32
24
|
style="${styleMap(styles)}"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
.request="${ctx.request}"
|
|
26
|
+
.state="${ctx.state}"
|
|
27
|
+
data-debug-block-type="webview"
|
|
28
|
+
></devvit-blocks-webview>`;
|
|
36
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, PropertyValues } from 'lit';
|
|
2
2
|
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Metadata } from '@devvit/protos';
|
|
4
4
|
import { Block, RenderPostResponse } from '@devvit/protos';
|
|
5
5
|
import type { ActorRef } from '@devvit/runtimes/common/runtime/ActorRef.js';
|
|
6
6
|
import './devvit-animation-player.js';
|
|
@@ -16,8 +16,8 @@ export declare class DevvitCustomPost extends LitElement {
|
|
|
16
16
|
postId?: string;
|
|
17
17
|
renderResponse?: RenderPostResponse;
|
|
18
18
|
rootBlock?: Block;
|
|
19
|
-
alphaRootBlock?: Element;
|
|
20
19
|
static get styles(): import("lit").CSSResult[];
|
|
20
|
+
connectedCallback(): void;
|
|
21
21
|
disconnectedCallback(): void;
|
|
22
22
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
23
23
|
render(): import("@reddit/baseplate/html.js").TemplateLike;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devvit-custom-post.d.ts","sourceRoot":"","sources":["../../src/client/devvit-custom-post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"devvit-custom-post.d.ts","sourceRoot":"","sources":["../../src/client/devvit-custom-post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKvD,OAAO,kEAAkE,CAAC;AAI1E,OAAO,KAAK,EAMV,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,EAML,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AAM5E,OAAO,8BAA8B,CAAC;AAEtC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,gBAAgB,CAAC;KACxC;CACF;AASD,qBAEa,gBAAiB,SAAQ,UAAU;;IAE9C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAGpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAGpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,cAAc,CAAC,EAAE,kBAAkB,CAAC;IAGpC,SAAS,CAAC,EAAE,KAAK,CAAC;IAalB,WAAoB,MAAM,8BAEzB;IAMQ,iBAAiB;IAKjB,oBAAoB;cAQV,UAAU,CAAC,iBAAiB,EAAE,cAAc;IAatD,MAAM;CAqGhB"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
var _DevvitCustomPost_instances, _DevvitCustomPost_postData, _DevvitCustomPost_appState, _DevvitCustomPost_customPostActor, _DevvitCustomPost_uiEventHandlerActor, _DevvitCustomPost_rpcQueue, _DevvitCustomPost_rerenderTimeout, _DevvitCustomPost_state_get, _DevvitCustomPost_handleUIEvent, _DevvitCustomPost_renderRequest, _DevvitCustomPost_initialRender, _DevvitCustomPost_userActionRender, _DevvitCustomPost_effectEventRender, _DevvitCustomPost_renderPost, _DevvitCustomPost_handleEffects;
|
|
1
|
+
var _DevvitCustomPost_instances, _DevvitCustomPost_postData, _DevvitCustomPost_appState, _DevvitCustomPost_lastRequest, _DevvitCustomPost_customPostActor, _DevvitCustomPost_uiEventHandlerActor, _DevvitCustomPost_rpcQueue, _DevvitCustomPost_rerenderTimeout, _DevvitCustomPost_state_get, _DevvitCustomPost_handleUIEvent, _DevvitCustomPost_handleUserAction, _DevvitCustomPost_renderRequest, _DevvitCustomPost_initialRender, _DevvitCustomPost_userActionRender, _DevvitCustomPost_effectEventRender, _DevvitCustomPost_renderPost, _DevvitCustomPost_handleEffects;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate, __metadata } from "tslib";
|
|
3
3
|
import { html, LitElement } from 'lit';
|
|
4
4
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
5
|
+
import { localized, msg } from '@lit/localize';
|
|
5
6
|
import PQueue from 'p-queue';
|
|
6
7
|
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
7
8
|
import { emptyState } from '@reddit/faceplate-ui/templates/empty-state.js';
|
|
8
9
|
import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
|
|
9
|
-
import tailwind from '@reddit/shreddit.styles';
|
|
10
10
|
import { Block, BlockRenderEventType, BlockStackDirection, BlockType, CustomPostDefinition, EffectType, RenderPostResponse, UIEventHandlerDefinition, } from '@devvit/protos';
|
|
11
11
|
import { renderBlocks } from '../blocks/index.js';
|
|
12
12
|
import { snooBlocks } from './assets/snooBlocks.js';
|
|
13
|
+
import { styles } from '../styles.js';
|
|
13
14
|
import './devvit-animation-player.js';
|
|
14
15
|
let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
15
16
|
constructor() {
|
|
@@ -17,6 +18,7 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
17
18
|
_DevvitCustomPost_instances.add(this);
|
|
18
19
|
_DevvitCustomPost_postData.set(this, void 0);
|
|
19
20
|
_DevvitCustomPost_appState.set(this, {});
|
|
21
|
+
_DevvitCustomPost_lastRequest.set(this, void 0);
|
|
20
22
|
_DevvitCustomPost_customPostActor.set(this, void 0);
|
|
21
23
|
_DevvitCustomPost_uiEventHandlerActor.set(this, void 0);
|
|
22
24
|
_DevvitCustomPost_rpcQueue.set(this, new PQueue({ concurrency: 1 }));
|
|
@@ -35,19 +37,27 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
});
|
|
40
|
+
_DevvitCustomPost_handleUserAction.set(this, (event) => {
|
|
41
|
+
__classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_userActionRender).call(this, event.detail.action.id, event.detail.action.data);
|
|
42
|
+
});
|
|
38
43
|
_DevvitCustomPost_renderRequest.set(this, (type, id, data = {}) => ({
|
|
39
44
|
blocks: { type, id, data },
|
|
40
45
|
state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
|
|
41
46
|
}));
|
|
42
47
|
}
|
|
43
48
|
static get styles() {
|
|
44
|
-
return [
|
|
49
|
+
return [styles];
|
|
50
|
+
}
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
super.connectedCallback();
|
|
53
|
+
this.addEventListener('devvit-user-action', __classPrivateFieldGet(this, _DevvitCustomPost_handleUserAction, "f"));
|
|
45
54
|
}
|
|
46
55
|
disconnectedCallback() {
|
|
47
56
|
super.disconnectedCallback();
|
|
48
57
|
if (__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f") !== undefined) {
|
|
49
58
|
window.clearTimeout(__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f"));
|
|
50
59
|
}
|
|
60
|
+
this.removeEventListener('devvit-user-action', __classPrivateFieldGet(this, _DevvitCustomPost_handleUserAction, "f"));
|
|
51
61
|
}
|
|
52
62
|
willUpdate(changedProperties) {
|
|
53
63
|
if (changedProperties.has('actorRef')) {
|
|
@@ -65,7 +75,7 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
65
75
|
}
|
|
66
76
|
if (this.rootBlock && this.rootBlock.type === BlockType.BLOCK_ROOT) {
|
|
67
77
|
return renderBlocks(this.rootBlock, {
|
|
68
|
-
|
|
78
|
+
request: __classPrivateFieldGet(this, _DevvitCustomPost_lastRequest, "f"),
|
|
69
79
|
state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
|
|
70
80
|
stackDirection: BlockStackDirection.UNRECOGNIZED,
|
|
71
81
|
onAction: (action) => {
|
|
@@ -74,13 +84,15 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
74
84
|
});
|
|
75
85
|
}
|
|
76
86
|
return html `${emptyState({
|
|
77
|
-
creative: html `<div class="w-
|
|
78
|
-
title: 'Whoops!',
|
|
79
|
-
description: 'Something went wrong while attempting to display this content.',
|
|
87
|
+
creative: html `<div class="w-3xl h-3xl">${snooBlocks}</div>`,
|
|
88
|
+
title: msg('Whoops!', { desc: 'Header for message to display when rendering fails' }),
|
|
89
|
+
description: msg('Something went wrong while attempting to display this content.', {
|
|
90
|
+
desc: 'Message for users to display when rendering fails',
|
|
91
|
+
}),
|
|
80
92
|
})}`;
|
|
81
93
|
}
|
|
82
94
|
};
|
|
83
|
-
_DevvitCustomPost_postData = new WeakMap(), _DevvitCustomPost_appState = new WeakMap(), _DevvitCustomPost_customPostActor = new WeakMap(), _DevvitCustomPost_uiEventHandlerActor = new WeakMap(), _DevvitCustomPost_rpcQueue = new WeakMap(), _DevvitCustomPost_rerenderTimeout = new WeakMap(), _DevvitCustomPost_handleUIEvent = new WeakMap(), _DevvitCustomPost_renderRequest = new WeakMap(), _DevvitCustomPost_instances = new WeakSet(), _DevvitCustomPost_state_get = function _DevvitCustomPost_state_get() {
|
|
95
|
+
_DevvitCustomPost_postData = new WeakMap(), _DevvitCustomPost_appState = new WeakMap(), _DevvitCustomPost_lastRequest = new WeakMap(), _DevvitCustomPost_customPostActor = new WeakMap(), _DevvitCustomPost_uiEventHandlerActor = new WeakMap(), _DevvitCustomPost_rpcQueue = new WeakMap(), _DevvitCustomPost_rerenderTimeout = new WeakMap(), _DevvitCustomPost_handleUIEvent = new WeakMap(), _DevvitCustomPost_handleUserAction = new WeakMap(), _DevvitCustomPost_renderRequest = new WeakMap(), _DevvitCustomPost_instances = new WeakSet(), _DevvitCustomPost_state_get = function _DevvitCustomPost_state_get() {
|
|
84
96
|
return Object.assign({}, __classPrivateFieldGet(this, _DevvitCustomPost_postData, "f"), __classPrivateFieldGet(this, _DevvitCustomPost_appState, "f"));
|
|
85
97
|
}, _DevvitCustomPost_initialRender = function _DevvitCustomPost_initialRender() {
|
|
86
98
|
__classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_INITIAL));
|
|
@@ -97,7 +109,9 @@ _DevvitCustomPost_postData = new WeakMap(), _DevvitCustomPost_appState = new Wea
|
|
|
97
109
|
__classPrivateFieldSet(this, _DevvitCustomPost_appState, this.renderResponse.state, "f");
|
|
98
110
|
}
|
|
99
111
|
if (this.renderResponse?.blocks?.ui) {
|
|
112
|
+
__classPrivateFieldSet(this, _DevvitCustomPost_lastRequest, req.blocks, "f");
|
|
100
113
|
this.rootBlock = this.renderResponse.blocks.ui;
|
|
114
|
+
await this.updateComplete;
|
|
101
115
|
}
|
|
102
116
|
await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, this.renderResponse.effects);
|
|
103
117
|
}
|
|
@@ -137,11 +151,8 @@ __decorate([
|
|
|
137
151
|
state(),
|
|
138
152
|
__metadata("design:type", Object)
|
|
139
153
|
], DevvitCustomPost.prototype, "rootBlock", void 0);
|
|
140
|
-
__decorate([
|
|
141
|
-
state(),
|
|
142
|
-
__metadata("design:type", Object)
|
|
143
|
-
], DevvitCustomPost.prototype, "alphaRootBlock", void 0);
|
|
144
154
|
DevvitCustomPost = __decorate([
|
|
155
|
+
localized(),
|
|
145
156
|
customElement('devvit-custom-post')
|
|
146
157
|
], DevvitCustomPost);
|
|
147
158
|
export { DevvitCustomPost };
|
|
@@ -4,6 +4,7 @@ import { ReactiveElement } from 'lit';
|
|
|
4
4
|
export declare class FormEffectHandler extends DevvitEffectHandler {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(host: ReactiveElement, queryString: string);
|
|
7
|
+
hostUpdated(): void;
|
|
7
8
|
protected onShowForm(form: Form, onEvent: (event: UIEvent) => void): void;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=form-effect-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-effect-handler.d.ts","sourceRoot":"","sources":["../../../src/client/effects/form-effect-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAGtC,qBAAa,iBAAkB,SAAQ,mBAAmB;;
|
|
1
|
+
{"version":3,"file":"form-effect-handler.d.ts","sourceRoot":"","sources":["../../../src/client/effects/form-effect-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAGtC,qBAAa,iBAAkB,SAAQ,mBAAmB;;gBAK5C,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM;IAK7C,WAAW;cAKD,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;CAG5E"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
var _FormEffectHandler_queryString;
|
|
2
|
-
import { __classPrivateFieldSet } from "tslib";
|
|
1
|
+
var _FormEffectHandler_queryString, _FormEffectHandler_dialog;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { DevvitEffectHandler } from './devvit-effect-handler.js';
|
|
4
|
-
import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
|
|
5
4
|
export class FormEffectHandler extends DevvitEffectHandler {
|
|
6
5
|
constructor(host, queryString) {
|
|
7
6
|
super(host);
|
|
8
7
|
_FormEffectHandler_queryString.set(this, void 0);
|
|
8
|
+
_FormEffectHandler_dialog.set(this, void 0);
|
|
9
9
|
__classPrivateFieldSet(this, _FormEffectHandler_queryString, queryString, "f");
|
|
10
10
|
}
|
|
11
|
+
hostUpdated() {
|
|
12
|
+
super.hostUpdated();
|
|
13
|
+
__classPrivateFieldSet(this, _FormEffectHandler_dialog, this.host.renderRoot.querySelector(__classPrivateFieldGet(this, _FormEffectHandler_queryString, "f")), "f");
|
|
14
|
+
}
|
|
11
15
|
onShowForm(form, onEvent) {
|
|
12
|
-
this
|
|
16
|
+
__classPrivateFieldGet(this, _FormEffectHandler_dialog, "f")?.showForm(form, onEvent);
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
|
-
_FormEffectHandler_queryString = new WeakMap();
|
|
19
|
+
_FormEffectHandler_queryString = new WeakMap(), _FormEffectHandler_dialog = new WeakMap();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { FormField } from '@devvit/protos';
|
|
3
|
+
import '@reddit/faceplate-ui/components/faceplate-dropdown-menu.js';
|
|
4
|
+
import '@reddit/faceplate-ui/components/faceplate-menu.js';
|
|
5
|
+
import '@reddit/faceplate-ui/components/faceplate-switch-input.js';
|
|
6
|
+
import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
|
|
7
|
+
export declare class DevvitFormSelectionDropdown extends InputElement {
|
|
8
|
+
#private;
|
|
9
|
+
field: FormField | undefined;
|
|
10
|
+
dropdownOpen: boolean;
|
|
11
|
+
currentLabel: string;
|
|
12
|
+
static get styles(): import("lit").CSSResultGroup[];
|
|
13
|
+
get value(): string;
|
|
14
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
15
|
+
render(): TemplateResult<1>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=devvit-form-selection-dropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devvit-form-selection-dropdown.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/components/devvit-form-selection-dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AASjE,OAAO,EAGL,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAIxB,OAAO,4DAA4D,CAAC;AACpE,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2DAA2D,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,qBAAa,2BAA4B,SAAQ,YAAY;;IAE3D,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAG7B,YAAY,UAAS;IAGrB,YAAY,SAAM;IAKlB,WAAoB,MAAM,mCAEzB;IAED,IAAI,KAAK,WAER;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc;IAwDnC,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAgDrC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
var _DevvitFormSelectionDropdown_selection, _DevvitFormSelectionDropdown_config, _DevvitFormSelectionDropdown_updateSelection, _DevvitFormSelectionDropdown_singleSelectListItem, _DevvitFormSelectionDropdown_multiSelectListItem;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate, __metadata } from "tslib";
|
|
3
|
+
import { property, state } from 'lit/decorators.js';
|
|
4
|
+
import { html, ifDefined } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
5
|
+
import { listItem } from '@reddit/faceplate-ui/templates/list-item.js';
|
|
6
|
+
import { button } from '@reddit/faceplate-ui/templates/button.js';
|
|
7
|
+
import { msg } from '@reddit/faceplate/lib/i18n/localize.js';
|
|
8
|
+
import { FieldConfig_Selection, FormFieldValue_SelectionValue, } from '@devvit/protos';
|
|
9
|
+
import { styles } from '../../../styles.js';
|
|
10
|
+
import '@reddit/faceplate-ui/components/faceplate-dropdown-menu.js';
|
|
11
|
+
import '@reddit/faceplate-ui/components/faceplate-menu.js';
|
|
12
|
+
import '@reddit/faceplate-ui/components/faceplate-switch-input.js';
|
|
13
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
14
|
+
import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
|
|
15
|
+
export class DevvitFormSelectionDropdown extends InputElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.dropdownOpen = false;
|
|
19
|
+
this.currentLabel = '';
|
|
20
|
+
_DevvitFormSelectionDropdown_selection.set(this, FormFieldValue_SelectionValue.fromPartial({}));
|
|
21
|
+
_DevvitFormSelectionDropdown_config.set(this, FieldConfig_Selection.fromPartial({}));
|
|
22
|
+
_DevvitFormSelectionDropdown_updateSelection.set(this, (choice, selected = true) => {
|
|
23
|
+
if (__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect) {
|
|
24
|
+
const index = __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values.indexOf(choice.value);
|
|
25
|
+
if (selected && index < 0) {
|
|
26
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values.push(choice.value);
|
|
27
|
+
}
|
|
28
|
+
else if (index >= 0) {
|
|
29
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values.splice(index, 1);
|
|
30
|
+
}
|
|
31
|
+
if (__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values.length === 0) {
|
|
32
|
+
this.currentLabel = '';
|
|
33
|
+
}
|
|
34
|
+
else if (__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values.length === 1) {
|
|
35
|
+
this.currentLabel =
|
|
36
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").choices.find((c) => c.value === __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values[0])?.label ?? '';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.currentLabel = msg('[Multiple Selections]', {
|
|
40
|
+
desc: 'Displayed on a drop down menu when multiple values are selected',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values = [choice.value];
|
|
46
|
+
this.currentLabel = choice.label;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
_DevvitFormSelectionDropdown_singleSelectListItem.set(this, (choice) => listItem({
|
|
50
|
+
label: choice.label,
|
|
51
|
+
onClick: () => __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_updateSelection, "f").call(this, choice),
|
|
52
|
+
}));
|
|
53
|
+
_DevvitFormSelectionDropdown_multiSelectListItem.set(this, (choice) => listItem({
|
|
54
|
+
label: html `
|
|
55
|
+
<faceplate-switch-input
|
|
56
|
+
@input="${(ev) => __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_updateSelection, "f").call(this, choice, ev.currentTarget.checked)}"
|
|
57
|
+
>
|
|
58
|
+
${choice.label}
|
|
59
|
+
</faceplate-switch-input>
|
|
60
|
+
`,
|
|
61
|
+
onClick: (ev) => ev.stopImmediatePropagation(),
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
static get styles() {
|
|
65
|
+
return [super.styles, styles];
|
|
66
|
+
}
|
|
67
|
+
get value() {
|
|
68
|
+
return __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values.join(',');
|
|
69
|
+
}
|
|
70
|
+
willUpdate(changedProperties) {
|
|
71
|
+
if (changedProperties.has('field')) {
|
|
72
|
+
__classPrivateFieldSet(this, _DevvitFormSelectionDropdown_config, this.field?.fieldConfig?.selectionConfig ?? FieldConfig_Selection.fromPartial({}), "f");
|
|
73
|
+
__classPrivateFieldSet(this, _DevvitFormSelectionDropdown_selection, this.field?.defaultValue?.selectionValue ?? FormFieldValue_SelectionValue.fromPartial({}), "f");
|
|
74
|
+
if (!__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect) {
|
|
75
|
+
this.currentLabel =
|
|
76
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").choices.find((c) => c.value === __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values?.[0])?.label ?? '';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
let formField;
|
|
82
|
+
if (this.field) {
|
|
83
|
+
const items = __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").choices?.map((choice) => __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect
|
|
84
|
+
? __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_multiSelectListItem, "f").call(this, choice)
|
|
85
|
+
: __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_singleSelectListItem, "f").call(this, choice));
|
|
86
|
+
const emptyItem = !__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect && !__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").minSelections
|
|
87
|
+
? listItem({
|
|
88
|
+
label: html ` `,
|
|
89
|
+
onClick: () => {
|
|
90
|
+
this.currentLabel = '';
|
|
91
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_selection, "f").values = [];
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
: undefined;
|
|
95
|
+
const classes = {
|
|
96
|
+
'flex-grow': true,
|
|
97
|
+
'z-auto': !this.dropdownOpen,
|
|
98
|
+
};
|
|
99
|
+
formField = html `
|
|
100
|
+
<faceplate-dropdown-menu
|
|
101
|
+
id="${this.field.fieldId}"
|
|
102
|
+
class="${classMap(classes)}"
|
|
103
|
+
.onopen="${() => (this.dropdownOpen = true)}"
|
|
104
|
+
.onclose="${() => (this.dropdownOpen = false)}"
|
|
105
|
+
?disabled="${ifDefined(this.field.disabled)}"
|
|
106
|
+
>
|
|
107
|
+
${button({
|
|
108
|
+
attributes: {
|
|
109
|
+
disabled: this.field.disabled === true,
|
|
110
|
+
className: 'flex-grow',
|
|
111
|
+
},
|
|
112
|
+
children: html `<span class="grow">${this.currentLabel}</span>`,
|
|
113
|
+
selected: this.dropdownOpen,
|
|
114
|
+
dropdown: true,
|
|
115
|
+
})}
|
|
116
|
+
<faceplate-menu slot="menu">${emptyItem}${items}</faceplate-menu>
|
|
117
|
+
</faceplate-dropdown-menu>
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
return html `${formField}${super.render()}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
_DevvitFormSelectionDropdown_selection = new WeakMap(), _DevvitFormSelectionDropdown_config = new WeakMap(), _DevvitFormSelectionDropdown_updateSelection = new WeakMap(), _DevvitFormSelectionDropdown_singleSelectListItem = new WeakMap(), _DevvitFormSelectionDropdown_multiSelectListItem = new WeakMap();
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ attribute: false }),
|
|
126
|
+
__metadata("design:type", Object)
|
|
127
|
+
], DevvitFormSelectionDropdown.prototype, "field", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
state(),
|
|
130
|
+
__metadata("design:type", Object)
|
|
131
|
+
], DevvitFormSelectionDropdown.prototype, "dropdownOpen", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
state(),
|
|
134
|
+
__metadata("design:type", Object)
|
|
135
|
+
], DevvitFormSelectionDropdown.prototype, "currentLabel", void 0);
|
|
136
|
+
// Faceplate's base classes and mixins aren't playing nice with type checking for some reason
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
customElements.define('devvit-form-selection-dropdown', DevvitFormSelectionDropdown);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { FormField } from '@devvit/protos';
|
|
3
|
+
import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
|
|
4
|
+
import '@reddit/faceplate-ui/components/faceplate-checkbox-input.js';
|
|
5
|
+
import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
|
|
6
|
+
export declare class DevvitFormSelectionList extends InputElement {
|
|
7
|
+
#private;
|
|
8
|
+
field: FormField | undefined;
|
|
9
|
+
static get styles(): import("lit").CSSResultGroup[];
|
|
10
|
+
get value(): string;
|
|
11
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
12
|
+
render(): TemplateResult<1>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=devvit-form-selection-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devvit-form-selection-list.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/components/devvit-form-selection-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAMjE,OAAO,EAGL,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAKxB,OAAO,0DAA0D,CAAC;AAClE,OAAO,6DAA6D,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,qBAAa,uBAAwB,SAAQ,YAAY;;IAEvD,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAK7B,WAAoB,MAAM,mCAEzB;IAED,IAAI,KAAK,WAER;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc;IAsBnC,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CA6CrC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var _DevvitFormSelectionList_config, _DevvitFormSelectionList_selection, _DevvitFormSelectionList_updateSelection;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate, __metadata } from "tslib";
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import { html, repeat } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
5
|
+
import { FieldConfig_Selection, FormFieldValue_SelectionValue, } from '@devvit/protos';
|
|
6
|
+
import { renderFieldLabel } from '../fields/index.js';
|
|
7
|
+
import { styles } from '../../../styles.js';
|
|
8
|
+
import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
|
|
9
|
+
import '@reddit/faceplate-ui/components/faceplate-checkbox-input.js';
|
|
10
|
+
import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
|
|
11
|
+
export class DevvitFormSelectionList extends InputElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
_DevvitFormSelectionList_config.set(this, FieldConfig_Selection.fromPartial({}));
|
|
15
|
+
_DevvitFormSelectionList_selection.set(this, FormFieldValue_SelectionValue.fromPartial({}));
|
|
16
|
+
_DevvitFormSelectionList_updateSelection.set(this, (choice, selected = true) => {
|
|
17
|
+
if (__classPrivateFieldGet(this, _DevvitFormSelectionList_config, "f").multiSelect) {
|
|
18
|
+
const index = __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.indexOf(choice.value);
|
|
19
|
+
if (selected && index < 0) {
|
|
20
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.push(choice.value);
|
|
21
|
+
}
|
|
22
|
+
else if (index >= 0) {
|
|
23
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.splice(index, 1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values = [choice.value];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
static get styles() {
|
|
32
|
+
return [super.styles, styles];
|
|
33
|
+
}
|
|
34
|
+
get value() {
|
|
35
|
+
return __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.join(',');
|
|
36
|
+
}
|
|
37
|
+
willUpdate(changedProperties) {
|
|
38
|
+
if (changedProperties.has('field')) {
|
|
39
|
+
__classPrivateFieldSet(this, _DevvitFormSelectionList_config, this.field?.fieldConfig?.selectionConfig ?? FieldConfig_Selection.fromPartial({}), "f");
|
|
40
|
+
__classPrivateFieldSet(this, _DevvitFormSelectionList_selection, this.field?.defaultValue?.selectionValue ?? FormFieldValue_SelectionValue.fromPartial({}), "f");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
let formField;
|
|
45
|
+
if (this.field) {
|
|
46
|
+
const renderRadio = (choice, index) => {
|
|
47
|
+
const id = `${this.field?.fieldId}_${index}`;
|
|
48
|
+
return html `
|
|
49
|
+
<faceplate-radio-input
|
|
50
|
+
id="${id}"
|
|
51
|
+
name="${this.field?.fieldId}"
|
|
52
|
+
data-value="${choice.value}"
|
|
53
|
+
?disabled="${this.field?.disabled}"
|
|
54
|
+
?required="${this.field?.required}"
|
|
55
|
+
@input="${() => {
|
|
56
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionList_updateSelection, "f").call(this, choice);
|
|
57
|
+
}}"
|
|
58
|
+
>
|
|
59
|
+
${choice.label}
|
|
60
|
+
</faceplate-radio-input>
|
|
61
|
+
`;
|
|
62
|
+
};
|
|
63
|
+
const renderCheckbox = (choice, index) => {
|
|
64
|
+
const id = `${this.field?.fieldId}_${index}`;
|
|
65
|
+
return html `
|
|
66
|
+
<faceplate-checkbox-input
|
|
67
|
+
id="${id}"
|
|
68
|
+
name="${this.field?.fieldId}"
|
|
69
|
+
class="m-sm"
|
|
70
|
+
data-value="${choice.value}"
|
|
71
|
+
@input="${(ev) => {
|
|
72
|
+
__classPrivateFieldGet(this, _DevvitFormSelectionList_updateSelection, "f").call(this, choice, ev.currentTarget.checked);
|
|
73
|
+
}}"
|
|
74
|
+
>
|
|
75
|
+
${choice.label}
|
|
76
|
+
</faceplate-checkbox-input>
|
|
77
|
+
`;
|
|
78
|
+
};
|
|
79
|
+
formField = html `${renderFieldLabel(this.field)}${repeat(__classPrivateFieldGet(this, _DevvitFormSelectionList_config, "f").choices ?? [], __classPrivateFieldGet(this, _DevvitFormSelectionList_config, "f").multiSelect === true ? renderCheckbox : renderRadio)}`;
|
|
80
|
+
}
|
|
81
|
+
return html `${formField}${super.render()}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_DevvitFormSelectionList_config = new WeakMap(), _DevvitFormSelectionList_selection = new WeakMap(), _DevvitFormSelectionList_updateSelection = new WeakMap();
|
|
85
|
+
__decorate([
|
|
86
|
+
property({ attribute: false }),
|
|
87
|
+
__metadata("design:type", Object)
|
|
88
|
+
], DevvitFormSelectionList.prototype, "field", void 0);
|
|
89
|
+
// Faceplate's base classes and mixins aren't playing nice with type checking for some reason
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
customElements.define('devvit-form-selection-list', DevvitFormSelectionList);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
3
|
+
import { FaceplateDialog } from '@reddit/faceplate-ui/components/faceplate-dialog.js';
|
|
4
|
+
import { FaceplateForm } from '@reddit/faceplate/components/faceplate-form.js';
|
|
5
|
+
import { Form, UIEvent } from '@devvit/protos';
|
|
6
|
+
import '@reddit/faceplate-ui/components/faceplate-dialog';
|
|
7
|
+
import '@reddit/faceplate/components/faceplate-form.js';
|
|
8
|
+
export declare class DevvitFormDialog extends LitElement {
|
|
9
|
+
#private;
|
|
10
|
+
form: Form | undefined;
|
|
11
|
+
$dialog?: FaceplateDialog;
|
|
12
|
+
$form?: FaceplateForm;
|
|
13
|
+
static get styles(): import("lit").CSSResult[];
|
|
14
|
+
showForm(form: Form, onEvent: (event: UIEvent) => void): void;
|
|
15
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=devvit-form-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devvit-form-dialog.d.ts","sourceRoot":"","sources":["../../../src/client/formbuilder/devvit-form-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,OAAO,kEAAkE,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAItF,OAAO,EAAE,aAAa,EAAoB,MAAM,gDAAgD,CAAC;AAEjG,OAAO,EAAE,IAAI,EAA4C,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAKzF,OAAO,kDAAkD,CAAC;AAC1D,OAAO,gDAAgD,CAAC;AAKxD,qBACa,gBAAiB,SAAQ,UAAU;;IAE9C,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IAGvB,OAAO,CAAC,EAAE,eAAe,CAAC;IAG1B,KAAK,CAAC,EAAE,aAAa,CAAC;IAKtB,WAAoB,MAAM,8BAEzB;IAED,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IA6E7C,MAAM;CA+ChB"}
|