@devvit/ui-renderer 0.9.1 → 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/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 +3 -4
- package/blocks/templates/index.d.ts.map +1 -1
- package/blocks/templates/renderWebViewBlock.d.ts +1 -0
- package/blocks/templates/renderWebViewBlock.d.ts.map +1 -1
- package/blocks/templates/renderWebViewBlock.js +5 -15
- 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 +22 -11
- 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 +9 -8
- package/styles.css +15 -0
- package/styles.js +1 -1
- package/types/events.d.ts +20 -0
- package/types/events.d.ts.map +1 -0
- package/types/events.js +1 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
var _DevvitFormDialog_onEvent, _DevvitFormDialog_idMap, _DevvitFormDialog_makeIdMap, _DevvitFormDialog_collectValues, _DevvitFormDialog_submitClicked, _DevvitFormDialog_cancelClicked, _DevvitFormDialog_closeDialog, _DevvitFormDialog_renderTitle, _DevvitFormDialog_renderDescription, _DevvitFormDialog_renderButtons;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate, __metadata } from "tslib";
|
|
3
|
+
import { html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
+
import { when } from 'lit/directives/when.js';
|
|
6
|
+
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
7
|
+
import { button, ButtonSize } from '@reddit/faceplate-ui/templates/button.js';
|
|
8
|
+
import { FaceplateDialog } from '@reddit/faceplate-ui/components/faceplate-dialog.js';
|
|
9
|
+
import { msg } from '@reddit/faceplate/lib/i18n/localize.js';
|
|
10
|
+
import { FaceplateForm } from '@reddit/faceplate/components/faceplate-form.js';
|
|
11
|
+
import { FormFieldType, FormFieldValue, UIEvent } from '@devvit/protos';
|
|
12
|
+
import { renderFormFields } from './fields/index.js';
|
|
13
|
+
import { styles } from '../../styles.js';
|
|
14
|
+
import '@reddit/faceplate-ui/components/faceplate-dialog';
|
|
15
|
+
import '@reddit/faceplate/components/faceplate-form.js';
|
|
16
|
+
let DevvitFormDialog = class DevvitFormDialog extends LitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
_DevvitFormDialog_onEvent.set(this, () => { });
|
|
20
|
+
_DevvitFormDialog_idMap.set(this, {});
|
|
21
|
+
_DevvitFormDialog_makeIdMap.set(this, (fields) => fields.reduce((map, field) => {
|
|
22
|
+
if (field.fieldType === FormFieldType.GROUP) {
|
|
23
|
+
return __classPrivateFieldGet(this, _DevvitFormDialog_makeIdMap, "f").call(this, field.fieldConfig?.groupConfig?.fields ?? []);
|
|
24
|
+
}
|
|
25
|
+
map[field.fieldId] = field;
|
|
26
|
+
return map;
|
|
27
|
+
}, {}));
|
|
28
|
+
_DevvitFormDialog_collectValues.set(this, () => {
|
|
29
|
+
const values = {};
|
|
30
|
+
if (!this.$form) {
|
|
31
|
+
return values;
|
|
32
|
+
}
|
|
33
|
+
for (const f of this.$form.elementsIterator()) {
|
|
34
|
+
const { name, value } = f;
|
|
35
|
+
const { fieldType } = __classPrivateFieldGet(this, _DevvitFormDialog_idMap, "f")[name];
|
|
36
|
+
const fieldValue = FormFieldValue.fromPartial({
|
|
37
|
+
fieldType,
|
|
38
|
+
});
|
|
39
|
+
switch (fieldType) {
|
|
40
|
+
case FormFieldType.STRING:
|
|
41
|
+
case FormFieldType.PARAGRAPH:
|
|
42
|
+
if (value === null || value.trim() === '') {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
fieldValue.stringValue = value;
|
|
46
|
+
break;
|
|
47
|
+
case FormFieldType.NUMBER:
|
|
48
|
+
fieldValue.numberValue = Number(value || 0);
|
|
49
|
+
break;
|
|
50
|
+
case FormFieldType.BOOLEAN:
|
|
51
|
+
fieldValue.boolValue = value === 'true' || value === 'on';
|
|
52
|
+
break;
|
|
53
|
+
case FormFieldType.SELECTION:
|
|
54
|
+
if (value === null || value.trim() === '') {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
fieldValue.selectionValue = { values: value.split(',') };
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
values[name] = fieldValue;
|
|
61
|
+
}
|
|
62
|
+
return values;
|
|
63
|
+
});
|
|
64
|
+
_DevvitFormDialog_submitClicked.set(this, () => {
|
|
65
|
+
__classPrivateFieldGet(this, _DevvitFormDialog_onEvent, "f").call(this, UIEvent.fromPartial({
|
|
66
|
+
formSubmitted: {
|
|
67
|
+
formId: this.form?.id,
|
|
68
|
+
results: __classPrivateFieldGet(this, _DevvitFormDialog_collectValues, "f").call(this),
|
|
69
|
+
},
|
|
70
|
+
}));
|
|
71
|
+
__classPrivateFieldGet(this, _DevvitFormDialog_closeDialog, "f").call(this);
|
|
72
|
+
});
|
|
73
|
+
_DevvitFormDialog_cancelClicked.set(this, () => {
|
|
74
|
+
__classPrivateFieldGet(this, _DevvitFormDialog_closeDialog, "f").call(this);
|
|
75
|
+
});
|
|
76
|
+
_DevvitFormDialog_closeDialog.set(this, () => {
|
|
77
|
+
this.$dialog?.close();
|
|
78
|
+
this.form = undefined;
|
|
79
|
+
__classPrivateFieldSet(this, _DevvitFormDialog_idMap, {}, "f");
|
|
80
|
+
});
|
|
81
|
+
_DevvitFormDialog_renderTitle.set(this, () => html `<span class="text-32 py-sm">${this.form?.title}</span>`);
|
|
82
|
+
_DevvitFormDialog_renderDescription.set(this, () => html `<span class="pb-md">${this.form?.shortDescription}</span>`);
|
|
83
|
+
_DevvitFormDialog_renderButtons.set(this, () => html `
|
|
84
|
+
<div class="flex justify-end space-x-xs">
|
|
85
|
+
${button({
|
|
86
|
+
appearance: 'primary',
|
|
87
|
+
size: ButtonSize.Medium,
|
|
88
|
+
children: this.form?.acceptLabel ?? msg('OK', { desc: 'Submit input for the custom action' }),
|
|
89
|
+
attributes: {
|
|
90
|
+
type: 'submit',
|
|
91
|
+
onclick: __classPrivateFieldGet(this, _DevvitFormDialog_submitClicked, "f"),
|
|
92
|
+
},
|
|
93
|
+
})}
|
|
94
|
+
${button({
|
|
95
|
+
appearance: 'secondary',
|
|
96
|
+
size: ButtonSize.Medium,
|
|
97
|
+
children: this.form?.cancelLabel ??
|
|
98
|
+
msg('Cancel', { desc: 'Cancel custom action and dismiss dialog' }),
|
|
99
|
+
attributes: {
|
|
100
|
+
onclick: __classPrivateFieldGet(this, _DevvitFormDialog_cancelClicked, "f"),
|
|
101
|
+
},
|
|
102
|
+
})}
|
|
103
|
+
</div>
|
|
104
|
+
`);
|
|
105
|
+
}
|
|
106
|
+
static get styles() {
|
|
107
|
+
return [styles];
|
|
108
|
+
}
|
|
109
|
+
showForm(form, onEvent) {
|
|
110
|
+
if (this.$dialog) {
|
|
111
|
+
this.form = form;
|
|
112
|
+
__classPrivateFieldSet(this, _DevvitFormDialog_idMap, __classPrivateFieldGet(this, _DevvitFormDialog_makeIdMap, "f").call(this, form.fields), "f");
|
|
113
|
+
__classPrivateFieldSet(this, _DevvitFormDialog_onEvent, onEvent, "f");
|
|
114
|
+
this.$dialog.showModal();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return html `
|
|
119
|
+
<faceplate-dialog class="z-dialog w-[32rem] overflow-auto">
|
|
120
|
+
<div class="flex flex-col gap-y-sm">
|
|
121
|
+
${when(this.form?.title, __classPrivateFieldGet(this, _DevvitFormDialog_renderTitle, "f"))}
|
|
122
|
+
${when(this.form?.shortDescription, __classPrivateFieldGet(this, _DevvitFormDialog_renderDescription, "f"))}
|
|
123
|
+
<faceplate-form
|
|
124
|
+
@faceplate-submit="${(ev) => ev.preventDefault()}"
|
|
125
|
+
class="flex flex-col gap-y-sm"
|
|
126
|
+
>
|
|
127
|
+
${renderFormFields(this.form?.fields ?? [])}
|
|
128
|
+
<!---->
|
|
129
|
+
${__classPrivateFieldGet(this, _DevvitFormDialog_renderButtons, "f").call(this)}
|
|
130
|
+
</faceplate-form>
|
|
131
|
+
</div>
|
|
132
|
+
</faceplate-dialog>
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
_DevvitFormDialog_onEvent = new WeakMap(), _DevvitFormDialog_idMap = new WeakMap(), _DevvitFormDialog_makeIdMap = new WeakMap(), _DevvitFormDialog_collectValues = new WeakMap(), _DevvitFormDialog_submitClicked = new WeakMap(), _DevvitFormDialog_cancelClicked = new WeakMap(), _DevvitFormDialog_closeDialog = new WeakMap(), _DevvitFormDialog_renderTitle = new WeakMap(), _DevvitFormDialog_renderDescription = new WeakMap(), _DevvitFormDialog_renderButtons = new WeakMap();
|
|
137
|
+
__decorate([
|
|
138
|
+
property({ attribute: false }),
|
|
139
|
+
__metadata("design:type", Object)
|
|
140
|
+
], DevvitFormDialog.prototype, "form", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
query('faceplate-dialog', true),
|
|
143
|
+
__metadata("design:type", FaceplateDialog)
|
|
144
|
+
], DevvitFormDialog.prototype, "$dialog", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
query('faceplate-form', true),
|
|
147
|
+
__metadata("design:type", FaceplateForm)
|
|
148
|
+
], DevvitFormDialog.prototype, "$form", void 0);
|
|
149
|
+
DevvitFormDialog = __decorate([
|
|
150
|
+
customElement('devvit-form-dialog')
|
|
151
|
+
], DevvitFormDialog);
|
|
152
|
+
export { DevvitFormDialog };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './renderBooleanField.js';
|
|
2
|
+
export * from './renderFieldLabel.js';
|
|
3
|
+
export * from './renderFormFields.js';
|
|
4
|
+
export * from './renderGroupField.js';
|
|
5
|
+
export * from './renderHelpText.js';
|
|
6
|
+
export * from './renderListField.js';
|
|
7
|
+
export * from './renderNumberField.js';
|
|
8
|
+
export * from './renderParagraphField.js';
|
|
9
|
+
export * from './renderSelectionField.js';
|
|
10
|
+
export * from './renderStringField.js';
|
|
11
|
+
export type OnInputDelegate = (event: InputEvent | CustomEvent) => void;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './renderBooleanField.js';
|
|
2
|
+
export * from './renderFieldLabel.js';
|
|
3
|
+
export * from './renderFormFields.js';
|
|
4
|
+
export * from './renderGroupField.js';
|
|
5
|
+
export * from './renderHelpText.js';
|
|
6
|
+
export * from './renderListField.js';
|
|
7
|
+
export * from './renderNumberField.js';
|
|
8
|
+
export * from './renderParagraphField.js';
|
|
9
|
+
export * from './renderSelectionField.js';
|
|
10
|
+
export * from './renderStringField.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderBooleanField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderBooleanField.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,2DAA2D,CAAC;AAEnE,eAAO,MAAM,kBAAkB,UAAW,SAAS,yCAWlD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { html } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
import '@reddit/faceplate-ui/components/faceplate-switch-input.js';
|
|
3
|
+
export const renderBooleanField = (field) => html `
|
|
4
|
+
<faceplate-switch-input
|
|
5
|
+
id="${field.fieldId}"
|
|
6
|
+
name="${field.fieldId}"
|
|
7
|
+
class="py-xs border-0"
|
|
8
|
+
?required="${field.required}"
|
|
9
|
+
?checked="${field.defaultValue?.boolValue}"
|
|
10
|
+
?disabled="${field.disabled}"
|
|
11
|
+
>
|
|
12
|
+
${field.label}
|
|
13
|
+
</faceplate-switch-input>
|
|
14
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderFieldLabel.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderFieldLabel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,eAAO,MAAM,gBAAgB,UAAW,SAAS,yCAC+B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { html } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
const isRequired = (field) => field.required === true ? html `<span class="text-danger-content">*</span>` : html ``;
|
|
3
|
+
export const renderFieldLabel = (field) => html `<label for="${field.fieldId}">${field.label}${isRequired(field)}</label>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderFormFields.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderFormFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKrC,OAAO,EAAE,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAuB1D,eAAO,MAAM,gBAAgB,WAAY,SAAS,EAAE,KAAG,cAEtD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { choose } from 'lit/directives/choose.js';
|
|
2
|
+
import { html, repeat } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
3
|
+
import { FormFieldType } from '@devvit/protos';
|
|
4
|
+
import { renderBooleanField, renderGroupField, renderNumberField, renderParagraphField, renderSelectionField, renderStringField, } from './index.js';
|
|
5
|
+
const renderFormField = (field) => html `
|
|
6
|
+
${choose(field.fieldType, [
|
|
7
|
+
[FormFieldType.STRING, () => renderStringField(field)],
|
|
8
|
+
[FormFieldType.PARAGRAPH, () => renderParagraphField(field)],
|
|
9
|
+
[FormFieldType.NUMBER, () => renderNumberField(field)],
|
|
10
|
+
[FormFieldType.BOOLEAN, () => renderBooleanField(field)],
|
|
11
|
+
// [FormFieldType.LIST, () => renderListField(field)],
|
|
12
|
+
[FormFieldType.SELECTION, () => renderSelectionField(field)],
|
|
13
|
+
[FormFieldType.GROUP, () => renderGroupField(field)],
|
|
14
|
+
])}
|
|
15
|
+
`;
|
|
16
|
+
export const renderFormFields = (fields) => {
|
|
17
|
+
return html `${repeat(fields, (field) => renderFormField(field))}`;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderGroupField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderGroupField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,eAAO,MAAM,gBAAgB,UAAW,SAAS,yCAShD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
import { renderFormFields } from './renderFormFields.js';
|
|
3
|
+
import { renderFieldLabel } from './renderFieldLabel.js';
|
|
4
|
+
export const renderGroupField = (field) => {
|
|
5
|
+
return html `
|
|
6
|
+
<div class="flex flex-col py-xs border-0 gap-y-xs">
|
|
7
|
+
${renderFieldLabel(field)}
|
|
8
|
+
<div class="flex flex-col border border-solid border-tone-4 rounded-sm px-xs">
|
|
9
|
+
${renderFormFields(field.fieldConfig?.groupConfig?.fields ?? [])}
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
`;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderHelpText.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderHelpText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrC,OAAO,+DAA+D,CAAC;AAEvE,eAAO,MAAM,cAAc,cAAe,MAAM,GAAG,SAAS,KAAG,cACiC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { html } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
import '@reddit/faceplate-ui/components/faceplate-form-helper-text.js';
|
|
3
|
+
export const renderHelpText = (helpText) => helpText ? html `<faceplate-form-helper-text>${helpText}</faceplate-form-helper-text>` : html ``;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderListField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderListField.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderNumberField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderNumberField.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI/D,OAAO,yDAAyD,CAAC;AAEjE,eAAO,MAAM,iBAAiB,UAAW,SAAS,yCAmBjD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { html, ifDefined } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
import { FieldConfig_Number } from '@devvit/protos';
|
|
3
|
+
import '@reddit/faceplate-ui/components/faceplate-text-input.js';
|
|
4
|
+
export const renderNumberField = (field) => {
|
|
5
|
+
const { min, max, step } = field.fieldConfig?.numberConfig ?? FieldConfig_Number.fromPartial({});
|
|
6
|
+
return html `
|
|
7
|
+
<faceplate-text-input
|
|
8
|
+
id="${field.fieldId}"
|
|
9
|
+
name="${field.fieldId}"
|
|
10
|
+
class="py-xs border-0"
|
|
11
|
+
type="number"
|
|
12
|
+
value="${field.defaultValue?.numberValue ?? 0}"
|
|
13
|
+
min="${ifDefined(min)}"
|
|
14
|
+
max="${ifDefined(max)}"
|
|
15
|
+
step="${ifDefined(step)}"
|
|
16
|
+
?required="${field.required}"
|
|
17
|
+
?disabled="${field.disabled}"
|
|
18
|
+
innerLabel
|
|
19
|
+
>
|
|
20
|
+
<span slot="label">${field.label}</span>
|
|
21
|
+
</faceplate-text-input>
|
|
22
|
+
`;
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FormField } from '@devvit/protos';
|
|
2
|
+
import '@reddit/faceplate-ui/components/faceplate-textarea-input.js';
|
|
3
|
+
import '@reddit/faceplate-ui/components/faceplate-form-helper-text.js';
|
|
4
|
+
export declare const renderParagraphField: (field: FormField) => import("lit-html").TemplateResult<1>;
|
|
5
|
+
//# sourceMappingURL=renderParagraphField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderParagraphField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderParagraphField.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIlE,OAAO,6DAA6D,CAAC;AACrE,OAAO,+DAA+D,CAAC;AAGvE,eAAO,MAAM,oBAAoB,UAAW,SAAS,yCAoBpD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { html, ifDefined } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
import { FieldConfig_Paragraph } from '@devvit/protos';
|
|
3
|
+
import '@reddit/faceplate-ui/components/faceplate-textarea-input.js';
|
|
4
|
+
import '@reddit/faceplate-ui/components/faceplate-form-helper-text.js';
|
|
5
|
+
import { renderHelpText } from './renderHelpText.js';
|
|
6
|
+
export const renderParagraphField = (field) => {
|
|
7
|
+
const { lineHeight, maxCharacters, placeholder } = field.fieldConfig?.paragraphConfig ?? FieldConfig_Paragraph.fromPartial({});
|
|
8
|
+
return html `
|
|
9
|
+
<faceplate-textarea-input
|
|
10
|
+
id="${field.fieldId}"
|
|
11
|
+
name="${field.fieldId}"
|
|
12
|
+
class="py-xs border-0"
|
|
13
|
+
value="${ifDefined(field.defaultValue?.stringValue)}"
|
|
14
|
+
placeholder="${ifDefined(placeholder)}"
|
|
15
|
+
rows="${ifDefined(lineHeight)}"
|
|
16
|
+
maxlength="${ifDefined(maxCharacters)}"
|
|
17
|
+
?disabled="${field.disabled}"
|
|
18
|
+
?required="${field.required}"
|
|
19
|
+
innerLabel
|
|
20
|
+
>
|
|
21
|
+
<span slot="label">${field.label}</span>
|
|
22
|
+
</faceplate-textarea-input>
|
|
23
|
+
${renderHelpText(field.helpText)}
|
|
24
|
+
`;
|
|
25
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FormField } from '@devvit/protos';
|
|
2
|
+
import '../components/devvit-form-selection-dropdown.js';
|
|
3
|
+
import '../components/devvit-form-selection-list.js';
|
|
4
|
+
export declare const renderSelectionField: (field: FormField) => import("lit-html").TemplateResult<1>;
|
|
5
|
+
//# sourceMappingURL=renderSelectionField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderSelectionField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderSelectionField.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,iDAAiD,CAAC;AACzD,OAAO,6CAA6C,CAAC;AAErD,eAAO,MAAM,oBAAoB,UAAW,SAAS,yCAapD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { renderFieldLabel } from './index.js';
|
|
2
|
+
import { html } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
3
|
+
import '../components/devvit-form-selection-dropdown.js';
|
|
4
|
+
import '../components/devvit-form-selection-list.js';
|
|
5
|
+
export const renderSelectionField = (field) => {
|
|
6
|
+
if (field.fieldConfig?.selectionConfig?.renderAsList === true) {
|
|
7
|
+
return html `<devvit-form-selection-list
|
|
8
|
+
name="${field.fieldId}"
|
|
9
|
+
.field="${field}"
|
|
10
|
+
></devvit-form-selection-list>`;
|
|
11
|
+
}
|
|
12
|
+
return html `${renderFieldLabel(field)}
|
|
13
|
+
<devvit-form-selection-dropdown
|
|
14
|
+
class="flex flex-row"
|
|
15
|
+
name="${field.fieldId}"
|
|
16
|
+
.field="${field}"
|
|
17
|
+
></devvit-form-selection-dropdown>`;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderStringField.d.ts","sourceRoot":"","sources":["../../../../src/client/formbuilder/fields/renderStringField.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI/D,OAAO,yDAAyD,CAAC;AAEjE,eAAO,MAAM,iBAAiB,UAAW,SAAS,yCAqBjD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { html, ifDefined } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
+
import { FieldConfig_String } from '@devvit/protos';
|
|
3
|
+
import '@reddit/faceplate-ui/components/faceplate-text-input.js';
|
|
4
|
+
export const renderStringField = (field) => {
|
|
5
|
+
const { minLength, maxLength, placeholder } = field.fieldConfig?.stringConfig ?? FieldConfig_String.fromPartial({});
|
|
6
|
+
return html `
|
|
7
|
+
<faceplate-text-input
|
|
8
|
+
id="${field.fieldId}"
|
|
9
|
+
name="${field.fieldId}"
|
|
10
|
+
class="py-xs border-0"
|
|
11
|
+
type="text"
|
|
12
|
+
value="${ifDefined(field.defaultValue?.stringValue)}"
|
|
13
|
+
placeholder="${ifDefined(placeholder)}"
|
|
14
|
+
helperText="${ifDefined(field.helpText)}"
|
|
15
|
+
minlength="${ifDefined(minLength)}"
|
|
16
|
+
maxlength="${ifDefined(maxLength)}"
|
|
17
|
+
?disabled="${field.disabled}"
|
|
18
|
+
?required="${field.required}"
|
|
19
|
+
innerLabel
|
|
20
|
+
>
|
|
21
|
+
<span slot="label">${field.label}</span>
|
|
22
|
+
</faceplate-text-input>
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/formbuilder/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/ui-renderer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"types": "./index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@devvit/protos": "0.9.
|
|
33
|
-
"@devvit/runtimes": "0.9.
|
|
32
|
+
"@devvit/protos": "0.9.2",
|
|
33
|
+
"@devvit/runtimes": "0.9.2",
|
|
34
34
|
"@lottiefiles/lottie-player": "1.7.1",
|
|
35
35
|
"p-queue": "7.3.4",
|
|
36
36
|
"rxjs": "7.5.7"
|
|
@@ -55,10 +55,11 @@
|
|
|
55
55
|
"lit": "^2.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@devvit/eslint-config": "0.9.
|
|
59
|
-
"@devvit/public-api": "0.9.
|
|
60
|
-
"@devvit/repo-tools": "0.9.
|
|
61
|
-
"@devvit/tsconfig": "0.9.
|
|
58
|
+
"@devvit/eslint-config": "0.9.2",
|
|
59
|
+
"@devvit/public-api": "0.9.2",
|
|
60
|
+
"@devvit/repo-tools": "0.9.2",
|
|
61
|
+
"@devvit/tsconfig": "0.9.2",
|
|
62
|
+
"@lit/localize": "0.11.4",
|
|
62
63
|
"@reddit/baseplate": "0.14.0",
|
|
63
64
|
"@reddit/eslint-plugin-i18n-shreddit": "0.1.0",
|
|
64
65
|
"autoprefixer": "10.4.14",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"directory": "dist"
|
|
79
80
|
},
|
|
80
81
|
"source": "./src/index.ts",
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "409f899e60151c9a3b01d0804419efc1e63fb507"
|
|
82
83
|
}
|
package/styles.css
CHANGED
|
@@ -483,9 +483,12 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
483
483
|
.isolate{isolation:isolate}
|
|
484
484
|
.z-\[2\]{z-index:2}
|
|
485
485
|
.z-\[3\]{z-index:3}
|
|
486
|
+
.z-auto{z-index:auto}
|
|
487
|
+
.z-dialog{z-index:100}
|
|
486
488
|
.col-start-1{grid-column-start:1}
|
|
487
489
|
.row-start-1{grid-row-start:1}
|
|
488
490
|
.m-0{margin:0px}
|
|
491
|
+
.m-sm{margin:0.75rem}
|
|
489
492
|
.mx-xs{margin-left:0.5rem;margin-right:0.5rem}
|
|
490
493
|
.-ml-\[var\(--rem10\)\]{margin-left:calc(var(--rem10) * -1)}
|
|
491
494
|
.-ml-\[var\(--rem12\)\]{margin-left:calc(var(--rem12) * -1)}
|
|
@@ -521,6 +524,7 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
521
524
|
.h-100{height:100%}
|
|
522
525
|
.h-2xl{height:3rem}
|
|
523
526
|
.h-2xs{height:0.25rem}
|
|
527
|
+
.h-3xl{height:4rem}
|
|
524
528
|
.h-\[\.25rem\]{height:.25rem}
|
|
525
529
|
.h-\[\.375rem\]{height:.375rem}
|
|
526
530
|
.h-\[\.625rem\]{height:.625rem}
|
|
@@ -561,6 +565,7 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
561
565
|
.w-\[2rem\]{width:2rem}
|
|
562
566
|
.w-\[3\.25rem\]{width:3.25rem}
|
|
563
567
|
.w-\[3\.5rem\]{width:3.5rem}
|
|
568
|
+
.w-\[32rem\]{width:32rem}
|
|
564
569
|
.w-\[3rem\]{width:3rem}
|
|
565
570
|
.w-\[4\.5rem\]{width:4.5rem}
|
|
566
571
|
.w-\[4rem\]{width:4rem}
|
|
@@ -613,6 +618,10 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
613
618
|
.gap-md{gap:1rem}
|
|
614
619
|
.gap-xl{gap:2rem}
|
|
615
620
|
.gap-xs{gap:0.5rem}
|
|
621
|
+
.gap-y-sm{row-gap:0.75rem}
|
|
622
|
+
.gap-y-xs{row-gap:0.5rem}
|
|
623
|
+
.space-x-xs > :not([hidden]) ~ :not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}
|
|
624
|
+
.overflow-auto{overflow:auto}
|
|
616
625
|
.overflow-hidden{overflow:hidden}
|
|
617
626
|
.overflow-visible{overflow:visible}
|
|
618
627
|
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
@@ -637,6 +646,7 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
637
646
|
.border-neutral-background{border-color:var(--color-neutral-background)}
|
|
638
647
|
.border-neutral-border{border-color:var(--color-neutral-border)}
|
|
639
648
|
.border-secondary-background-selected{border-color:var(--color-secondary-background-selected)}
|
|
649
|
+
.border-tone-4{border-color:var(--color-tone-4)}
|
|
640
650
|
.border-transparent{border-color:transparent}
|
|
641
651
|
.bg-\[color\:var\(--button-color-background-default\)\]{background-color:var(--button-color-background-default)}
|
|
642
652
|
.bg-\[color\:var\(--color-button-plain-background-disabled\)\]{background-color:var(--color-button-plain-background-disabled)}
|
|
@@ -683,6 +693,7 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
683
693
|
.py-\[length\:var\(--rem14\)\]{padding-top:var(--rem14);padding-bottom:var(--rem14)}
|
|
684
694
|
.py-\[length\:var\(--rem6\)\]{padding-top:var(--rem6);padding-bottom:var(--rem6)}
|
|
685
695
|
.py-\[length\:var\(--rem8\)\]{padding-top:var(--rem8);padding-bottom:var(--rem8)}
|
|
696
|
+
.py-sm{padding-top:0.75rem;padding-bottom:0.75rem}
|
|
686
697
|
.py-xs{padding-top:0.5rem;padding-bottom:0.5rem}
|
|
687
698
|
.pb-md{padding-bottom:1rem}
|
|
688
699
|
.pl-\[length\:var\(--rem10\)\]{padding-left:var(--rem10)}
|
|
@@ -708,6 +719,7 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
708
719
|
.text-18{font-size:1.125rem;line-height:1.5rem}
|
|
709
720
|
.text-20{font-size:1.25rem;line-height:1.25rem}
|
|
710
721
|
.text-24{font-size:1.5rem;line-height:1.75rem}
|
|
722
|
+
.text-32{font-size:2rem;line-height:2.25rem}
|
|
711
723
|
.font-bold{font-weight:700}
|
|
712
724
|
.font-normal{font-weight:400}
|
|
713
725
|
.font-semibold{font-weight:600}
|
|
@@ -763,6 +775,9 @@ dialog::backdrop{background:var(--color-scrim)}
|
|
|
763
775
|
text-shadow: #fff 1px 0 2px, #fff -1px 0 2px, #fff 0 1px 1px, #fff 0 -1px 1px, #fff 1px 0 2px,
|
|
764
776
|
#fff -1px 0 2px, #fff 0 1px 1px, #fff 0 -1px 1px;
|
|
765
777
|
}
|
|
778
|
+
.button .dropdown-icon {
|
|
779
|
+
transform: none;
|
|
780
|
+
}
|
|
766
781
|
.hover\:border-secondary-background-hover:hover{border-color:var(--color-secondary-background-hover)}
|
|
767
782
|
.hover\:border-secondary-background-selected:hover{border-color:var(--color-secondary-background-selected)}
|
|
768
783
|
.hover\:bg-brand-background-hover:hover{background-color:var(--color-brand-background-hover)}
|