@devvit/ui-renderer 0.9.1 → 0.9.3

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.
Files changed (65) hide show
  1. package/blocks/components/devvit-blocks-webview.d.ts +2 -0
  2. package/blocks/components/devvit-blocks-webview.d.ts.map +1 -0
  3. package/blocks/components/devvit-blocks-webview.js +81 -0
  4. package/blocks/templates/index.d.ts +3 -4
  5. package/blocks/templates/index.d.ts.map +1 -1
  6. package/blocks/templates/renderWebViewBlock.d.ts +1 -0
  7. package/blocks/templates/renderWebViewBlock.d.ts.map +1 -1
  8. package/blocks/templates/renderWebViewBlock.js +5 -15
  9. package/client/devvit-custom-post.d.ts +2 -2
  10. package/client/devvit-custom-post.d.ts.map +1 -1
  11. package/client/devvit-custom-post.js +22 -11
  12. package/client/effects/form-effect-handler.d.ts +1 -0
  13. package/client/effects/form-effect-handler.d.ts.map +1 -1
  14. package/client/effects/form-effect-handler.js +9 -5
  15. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts +17 -0
  16. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts.map +1 -0
  17. package/client/formbuilder/components/devvit-form-selection-dropdown.js +138 -0
  18. package/client/formbuilder/components/devvit-form-selection-list.d.ts +14 -0
  19. package/client/formbuilder/components/devvit-form-selection-list.d.ts.map +1 -0
  20. package/client/formbuilder/components/devvit-form-selection-list.js +91 -0
  21. package/client/formbuilder/devvit-form-dialog.d.ts +17 -0
  22. package/client/formbuilder/devvit-form-dialog.d.ts.map +1 -0
  23. package/client/formbuilder/devvit-form-dialog.js +155 -0
  24. package/client/formbuilder/fields/index.d.ts +12 -0
  25. package/client/formbuilder/fields/index.d.ts.map +1 -0
  26. package/client/formbuilder/fields/index.js +10 -0
  27. package/client/formbuilder/fields/renderBooleanField.d.ts +4 -0
  28. package/client/formbuilder/fields/renderBooleanField.d.ts.map +1 -0
  29. package/client/formbuilder/fields/renderBooleanField.js +14 -0
  30. package/client/formbuilder/fields/renderFieldLabel.d.ts +3 -0
  31. package/client/formbuilder/fields/renderFieldLabel.d.ts.map +1 -0
  32. package/client/formbuilder/fields/renderFieldLabel.js +3 -0
  33. package/client/formbuilder/fields/renderFormFields.d.ts +4 -0
  34. package/client/formbuilder/fields/renderFormFields.d.ts.map +1 -0
  35. package/client/formbuilder/fields/renderFormFields.js +18 -0
  36. package/client/formbuilder/fields/renderGroupField.d.ts +3 -0
  37. package/client/formbuilder/fields/renderGroupField.d.ts.map +1 -0
  38. package/client/formbuilder/fields/renderGroupField.js +13 -0
  39. package/client/formbuilder/fields/renderHelpText.d.ts +4 -0
  40. package/client/formbuilder/fields/renderHelpText.d.ts.map +1 -0
  41. package/client/formbuilder/fields/renderHelpText.js +3 -0
  42. package/client/formbuilder/fields/renderListField.d.ts +2 -0
  43. package/client/formbuilder/fields/renderListField.d.ts.map +1 -0
  44. package/client/formbuilder/fields/renderListField.js +1 -0
  45. package/client/formbuilder/fields/renderNumberField.d.ts +4 -0
  46. package/client/formbuilder/fields/renderNumberField.d.ts.map +1 -0
  47. package/client/formbuilder/fields/renderNumberField.js +23 -0
  48. package/client/formbuilder/fields/renderParagraphField.d.ts +5 -0
  49. package/client/formbuilder/fields/renderParagraphField.d.ts.map +1 -0
  50. package/client/formbuilder/fields/renderParagraphField.js +25 -0
  51. package/client/formbuilder/fields/renderSelectionField.d.ts +5 -0
  52. package/client/formbuilder/fields/renderSelectionField.d.ts.map +1 -0
  53. package/client/formbuilder/fields/renderSelectionField.js +18 -0
  54. package/client/formbuilder/fields/renderStringField.d.ts +4 -0
  55. package/client/formbuilder/fields/renderStringField.d.ts.map +1 -0
  56. package/client/formbuilder/fields/renderStringField.js +24 -0
  57. package/client/formbuilder/index.d.ts +2 -0
  58. package/client/formbuilder/index.d.ts.map +1 -0
  59. package/client/formbuilder/index.js +1 -0
  60. package/package.json +9 -8
  61. package/styles.css +15 -0
  62. package/styles.js +1 -1
  63. package/types/events.d.ts +20 -0
  64. package/types/events.d.ts.map +1 -0
  65. package/types/events.js +1 -0
@@ -0,0 +1,155 @@
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 {
24
+ ...map,
25
+ ...__classPrivateFieldGet(this, _DevvitFormDialog_makeIdMap, "f").call(this, field.fieldConfig?.groupConfig?.fields ?? []),
26
+ };
27
+ }
28
+ map[field.fieldId] = field;
29
+ return map;
30
+ }, {}));
31
+ _DevvitFormDialog_collectValues.set(this, () => {
32
+ const values = {};
33
+ if (!this.$form) {
34
+ return values;
35
+ }
36
+ for (const f of this.$form.elementsIterator()) {
37
+ const { name, value } = f;
38
+ const { fieldType } = __classPrivateFieldGet(this, _DevvitFormDialog_idMap, "f")[name];
39
+ const fieldValue = FormFieldValue.fromPartial({
40
+ fieldType,
41
+ });
42
+ switch (fieldType) {
43
+ case FormFieldType.STRING:
44
+ case FormFieldType.PARAGRAPH:
45
+ if (value === null || value.trim() === '') {
46
+ continue;
47
+ }
48
+ fieldValue.stringValue = value;
49
+ break;
50
+ case FormFieldType.NUMBER:
51
+ fieldValue.numberValue = Number(value || 0);
52
+ break;
53
+ case FormFieldType.BOOLEAN:
54
+ fieldValue.boolValue = value === 'true' || value === 'on';
55
+ break;
56
+ case FormFieldType.SELECTION:
57
+ if (value === null || value.trim() === '') {
58
+ continue;
59
+ }
60
+ fieldValue.selectionValue = { values: value.split(',') };
61
+ break;
62
+ }
63
+ values[name] = fieldValue;
64
+ }
65
+ return values;
66
+ });
67
+ _DevvitFormDialog_submitClicked.set(this, () => {
68
+ __classPrivateFieldGet(this, _DevvitFormDialog_onEvent, "f").call(this, UIEvent.fromPartial({
69
+ formSubmitted: {
70
+ formId: this.form?.id,
71
+ results: __classPrivateFieldGet(this, _DevvitFormDialog_collectValues, "f").call(this),
72
+ },
73
+ }));
74
+ __classPrivateFieldGet(this, _DevvitFormDialog_closeDialog, "f").call(this);
75
+ });
76
+ _DevvitFormDialog_cancelClicked.set(this, () => {
77
+ __classPrivateFieldGet(this, _DevvitFormDialog_closeDialog, "f").call(this);
78
+ });
79
+ _DevvitFormDialog_closeDialog.set(this, () => {
80
+ this.$dialog?.close();
81
+ this.form = undefined;
82
+ __classPrivateFieldSet(this, _DevvitFormDialog_idMap, {}, "f");
83
+ });
84
+ _DevvitFormDialog_renderTitle.set(this, () => html `<span class="text-32 py-sm">${this.form?.title}</span>`);
85
+ _DevvitFormDialog_renderDescription.set(this, () => html `<span class="pb-md">${this.form?.shortDescription}</span>`);
86
+ _DevvitFormDialog_renderButtons.set(this, () => html `
87
+ <div class="flex justify-end space-x-xs">
88
+ ${button({
89
+ appearance: 'primary',
90
+ size: ButtonSize.Medium,
91
+ children: this.form?.acceptLabel ?? msg('OK', { desc: 'Submit input for the custom action' }),
92
+ attributes: {
93
+ type: 'submit',
94
+ onclick: __classPrivateFieldGet(this, _DevvitFormDialog_submitClicked, "f"),
95
+ },
96
+ })}
97
+ ${button({
98
+ appearance: 'secondary',
99
+ size: ButtonSize.Medium,
100
+ children: this.form?.cancelLabel ??
101
+ msg('Cancel', { desc: 'Cancel custom action and dismiss dialog' }),
102
+ attributes: {
103
+ onclick: __classPrivateFieldGet(this, _DevvitFormDialog_cancelClicked, "f"),
104
+ },
105
+ })}
106
+ </div>
107
+ `);
108
+ }
109
+ static get styles() {
110
+ return [styles];
111
+ }
112
+ showForm(form, onEvent) {
113
+ if (this.$dialog) {
114
+ this.form = form;
115
+ __classPrivateFieldSet(this, _DevvitFormDialog_idMap, __classPrivateFieldGet(this, _DevvitFormDialog_makeIdMap, "f").call(this, form.fields), "f");
116
+ __classPrivateFieldSet(this, _DevvitFormDialog_onEvent, onEvent, "f");
117
+ this.$dialog.showModal();
118
+ }
119
+ }
120
+ render() {
121
+ return html `
122
+ <faceplate-dialog class="z-dialog w-[32rem] overflow-auto">
123
+ <div class="flex flex-col gap-y-sm">
124
+ ${when(this.form?.title, __classPrivateFieldGet(this, _DevvitFormDialog_renderTitle, "f"))}
125
+ ${when(this.form?.shortDescription, __classPrivateFieldGet(this, _DevvitFormDialog_renderDescription, "f"))}
126
+ <faceplate-form
127
+ @faceplate-submit="${(ev) => ev.preventDefault()}"
128
+ class="flex flex-col gap-y-sm"
129
+ >
130
+ ${renderFormFields(this.form?.fields ?? [])}
131
+ <!---->
132
+ ${__classPrivateFieldGet(this, _DevvitFormDialog_renderButtons, "f").call(this)}
133
+ </faceplate-form>
134
+ </div>
135
+ </faceplate-dialog>
136
+ `;
137
+ }
138
+ };
139
+ _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();
140
+ __decorate([
141
+ property({ attribute: false }),
142
+ __metadata("design:type", Object)
143
+ ], DevvitFormDialog.prototype, "form", void 0);
144
+ __decorate([
145
+ query('faceplate-dialog', true),
146
+ __metadata("design:type", FaceplateDialog)
147
+ ], DevvitFormDialog.prototype, "$dialog", void 0);
148
+ __decorate([
149
+ query('faceplate-form', true),
150
+ __metadata("design:type", FaceplateForm)
151
+ ], DevvitFormDialog.prototype, "$form", void 0);
152
+ DevvitFormDialog = __decorate([
153
+ customElement('devvit-form-dialog')
154
+ ], DevvitFormDialog);
155
+ 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,4 @@
1
+ import { FormField } from '@devvit/protos';
2
+ import '@reddit/faceplate-ui/components/faceplate-switch-input.js';
3
+ export declare const renderBooleanField: (field: FormField) => import("lit-html").TemplateResult<1>;
4
+ //# sourceMappingURL=renderBooleanField.d.ts.map
@@ -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,3 @@
1
+ import { FormField } from '@devvit/protos';
2
+ export declare const renderFieldLabel: (field: FormField) => import("lit-html").TemplateResult<1>;
3
+ //# sourceMappingURL=renderFieldLabel.d.ts.map
@@ -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,4 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { FormField } from '@devvit/protos';
3
+ export declare const renderFormFields: (fields: FormField[]) => TemplateResult;
4
+ //# sourceMappingURL=renderFormFields.d.ts.map
@@ -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,3 @@
1
+ import { FormField } from '@devvit/protos';
2
+ export declare const renderGroupField: (field: FormField) => import("lit-html").TemplateResult<1>;
3
+ //# sourceMappingURL=renderGroupField.d.ts.map
@@ -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,4 @@
1
+ import { TemplateResult } from 'lit';
2
+ import '@reddit/faceplate-ui/components/faceplate-form-helper-text.js';
3
+ export declare const renderHelpText: (helpText?: string | undefined) => TemplateResult;
4
+ //# sourceMappingURL=renderHelpText.d.ts.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=renderListField.d.ts.map
@@ -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,4 @@
1
+ import { FormField } from '@devvit/protos';
2
+ import '@reddit/faceplate-ui/components/faceplate-text-input.js';
3
+ export declare const renderNumberField: (field: FormField) => import("lit-html").TemplateResult<1>;
4
+ //# sourceMappingURL=renderNumberField.d.ts.map
@@ -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,4 @@
1
+ import { FormField } from '@devvit/protos';
2
+ import '@reddit/faceplate-ui/components/faceplate-text-input.js';
3
+ export declare const renderStringField: (field: FormField) => import("lit-html").TemplateResult<1>;
4
+ //# sourceMappingURL=renderStringField.d.ts.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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.1",
3
+ "version": "0.9.3",
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.1",
33
- "@devvit/runtimes": "0.9.1",
32
+ "@devvit/protos": "0.9.3",
33
+ "@devvit/runtimes": "0.9.3",
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.1",
59
- "@devvit/public-api": "0.9.1",
60
- "@devvit/repo-tools": "0.9.1",
61
- "@devvit/tsconfig": "0.9.1",
58
+ "@devvit/eslint-config": "0.9.3",
59
+ "@devvit/public-api": "0.9.3",
60
+ "@devvit/repo-tools": "0.9.3",
61
+ "@devvit/tsconfig": "0.9.3",
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": "9c3a31746cb435b9ec47f392e719b4335c8f3765"
82
+ "gitHead": "40b7a04ef208bc233775977a5a3a819875a153c1"
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)}