@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.
Files changed (92) hide show
  1. package/blocks/attributes.d.ts +3 -1
  2. package/blocks/attributes.d.ts.map +1 -1
  3. package/blocks/attributes.js +29 -17
  4. package/blocks/components/devvit-blocks-webview.d.ts +2 -0
  5. package/blocks/components/devvit-blocks-webview.d.ts.map +1 -0
  6. package/blocks/components/devvit-blocks-webview.js +81 -0
  7. package/blocks/templates/index.d.ts +4 -5
  8. package/blocks/templates/index.d.ts.map +1 -1
  9. package/blocks/templates/index.js +5 -4
  10. package/blocks/templates/renderAnimationBlock.d.ts.map +1 -1
  11. package/blocks/templates/renderAnimationBlock.js +4 -1
  12. package/blocks/templates/renderAvatarBlock.d.ts.map +1 -1
  13. package/blocks/templates/renderAvatarBlock.js +4 -1
  14. package/blocks/templates/renderBlock.d.ts.map +1 -1
  15. package/blocks/templates/renderBlock.js +31 -10
  16. package/blocks/templates/renderButtonBlock.d.ts.map +1 -1
  17. package/blocks/templates/renderButtonBlock.js +11 -2
  18. package/blocks/templates/renderFullSnooBlock.d.ts.map +1 -1
  19. package/blocks/templates/renderFullSnooBlock.js +4 -1
  20. package/blocks/templates/renderIconBlock.d.ts.map +1 -1
  21. package/blocks/templates/renderIconBlock.js +6 -2
  22. package/blocks/templates/renderImageBlock.d.ts.map +1 -1
  23. package/blocks/templates/renderImageBlock.js +4 -1
  24. package/blocks/templates/renderSpacerBlock.d.ts.map +1 -1
  25. package/blocks/templates/renderSpacerBlock.js +8 -2
  26. package/blocks/templates/renderStackBlock.d.ts.map +1 -1
  27. package/blocks/templates/renderStackBlock.js +21 -2
  28. package/blocks/templates/renderTextBlock.d.ts.map +1 -1
  29. package/blocks/templates/renderTextBlock.js +4 -1
  30. package/blocks/templates/renderWebViewBlock.d.ts +1 -0
  31. package/blocks/templates/renderWebViewBlock.d.ts.map +1 -1
  32. package/blocks/templates/renderWebViewBlock.js +9 -16
  33. package/client/devvit-custom-post.d.ts +2 -2
  34. package/client/devvit-custom-post.d.ts.map +1 -1
  35. package/client/devvit-custom-post.js +23 -12
  36. package/client/effects/form-effect-handler.d.ts +1 -0
  37. package/client/effects/form-effect-handler.d.ts.map +1 -1
  38. package/client/effects/form-effect-handler.js +9 -5
  39. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts +17 -0
  40. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts.map +1 -0
  41. package/client/formbuilder/components/devvit-form-selection-dropdown.js +138 -0
  42. package/client/formbuilder/components/devvit-form-selection-list.d.ts +14 -0
  43. package/client/formbuilder/components/devvit-form-selection-list.d.ts.map +1 -0
  44. package/client/formbuilder/components/devvit-form-selection-list.js +91 -0
  45. package/client/formbuilder/devvit-form-dialog.d.ts +17 -0
  46. package/client/formbuilder/devvit-form-dialog.d.ts.map +1 -0
  47. package/client/formbuilder/devvit-form-dialog.js +152 -0
  48. package/client/formbuilder/fields/index.d.ts +12 -0
  49. package/client/formbuilder/fields/index.d.ts.map +1 -0
  50. package/client/formbuilder/fields/index.js +10 -0
  51. package/client/formbuilder/fields/renderBooleanField.d.ts +4 -0
  52. package/client/formbuilder/fields/renderBooleanField.d.ts.map +1 -0
  53. package/client/formbuilder/fields/renderBooleanField.js +14 -0
  54. package/client/formbuilder/fields/renderFieldLabel.d.ts +3 -0
  55. package/client/formbuilder/fields/renderFieldLabel.d.ts.map +1 -0
  56. package/client/formbuilder/fields/renderFieldLabel.js +3 -0
  57. package/client/formbuilder/fields/renderFormFields.d.ts +4 -0
  58. package/client/formbuilder/fields/renderFormFields.d.ts.map +1 -0
  59. package/client/formbuilder/fields/renderFormFields.js +18 -0
  60. package/client/formbuilder/fields/renderGroupField.d.ts +3 -0
  61. package/client/formbuilder/fields/renderGroupField.d.ts.map +1 -0
  62. package/client/formbuilder/fields/renderGroupField.js +13 -0
  63. package/client/formbuilder/fields/renderHelpText.d.ts +4 -0
  64. package/client/formbuilder/fields/renderHelpText.d.ts.map +1 -0
  65. package/client/formbuilder/fields/renderHelpText.js +3 -0
  66. package/client/formbuilder/fields/renderListField.d.ts +2 -0
  67. package/client/formbuilder/fields/renderListField.d.ts.map +1 -0
  68. package/client/formbuilder/fields/renderListField.js +1 -0
  69. package/client/formbuilder/fields/renderNumberField.d.ts +4 -0
  70. package/client/formbuilder/fields/renderNumberField.d.ts.map +1 -0
  71. package/client/formbuilder/fields/renderNumberField.js +23 -0
  72. package/client/formbuilder/fields/renderParagraphField.d.ts +5 -0
  73. package/client/formbuilder/fields/renderParagraphField.d.ts.map +1 -0
  74. package/client/formbuilder/fields/renderParagraphField.js +25 -0
  75. package/client/formbuilder/fields/renderSelectionField.d.ts +5 -0
  76. package/client/formbuilder/fields/renderSelectionField.d.ts.map +1 -0
  77. package/client/formbuilder/fields/renderSelectionField.js +18 -0
  78. package/client/formbuilder/fields/renderStringField.d.ts +4 -0
  79. package/client/formbuilder/fields/renderStringField.d.ts.map +1 -0
  80. package/client/formbuilder/fields/renderStringField.js +24 -0
  81. package/client/formbuilder/index.d.ts +2 -0
  82. package/client/formbuilder/index.d.ts.map +1 -0
  83. package/client/formbuilder/index.js +1 -0
  84. package/package.json +28 -22
  85. package/styles.css +793 -51
  86. package/styles.d.ts +2 -0
  87. package/styles.d.ts.map +1 -0
  88. package/styles.js +3 -0
  89. package/types/events.d.ts +20 -0
  90. package/types/events.d.ts.map +1 -0
  91. package/types/events.js +1 -0
  92. package/tailwind.devvit.cjs +0 -15
@@ -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,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.0",
3
+ "version": "0.9.2",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,34 +9,36 @@
9
9
  "type": "module",
10
10
  "main": "./index.js",
11
11
  "scripts": {
12
- "build": "tsc && yarn styles:copy",
12
+ "build": "yarn build:typescript && yarn build:styles",
13
+ "build:styles": "postcss -c postcss.config.cjs styles.css -o dist/styles.css && yarn build:styles-dist",
14
+ "build:styles-dist": "node scripts/make-styles.js",
15
+ "build:typescript": "tsc",
13
16
  "clean": "rm -rf .turbo coverage dist",
14
17
  "clobber": "yarn clean && rm -rf node_modules",
15
- "dev": "yarn styles:copy && tsc -w",
18
+ "dev": "concurrently -n 'styles,styles-dist,typescript' 'yarn watch:styles' 'yarn watch:styles-dist' 'yarn watch:typescript'",
16
19
  "lint": "redlint .",
17
20
  "lint:fix": "yarn lint --fix",
18
21
  "prepublishOnly": "publish-package-json",
19
- "styles:clean": "rm -f dist/styles.css",
20
- "styles:copy": "yarn styles:clean && cp styles.css dist/styles.css && cp tailwind.devvit.cjs dist/tailwind.devvit.cjs",
21
- "styles:dev": "echo 'todo make a filewatcher for styles.css or build it in less and use the preprocessor watch mode'",
22
22
  "test": "yarn test:unit && yarn test:types && yarn lint",
23
23
  "test:types": "tsc --noEmit",
24
24
  "test:unit": "vitest run",
25
- "test:unit-with-coverage": "vitest run --coverage"
25
+ "test:unit-with-coverage": "vitest run --coverage",
26
+ "watch:styles": "postcss -w -c postcss.config.cjs styles.css -o dist/styles.css",
27
+ "watch:styles-dist": "node scripts/make-styles.js --watch",
28
+ "watch:typescript": "tsc -w"
26
29
  },
27
30
  "types": "./index.d.ts",
28
31
  "dependencies": {
29
- "@devvit/protos": "0.9.0",
30
- "@devvit/runtimes": "0.9.0",
32
+ "@devvit/protos": "0.9.2",
33
+ "@devvit/runtimes": "0.9.2",
31
34
  "@lottiefiles/lottie-player": "1.7.1",
32
35
  "p-queue": "7.3.4",
33
36
  "rxjs": "7.5.7"
34
37
  },
35
38
  "peerDependencies": {
36
39
  "@reddit/baseplate": "0.14.0",
37
- "@reddit/faceplate": "2.0.0",
38
- "@reddit/faceplate-ui": "1.0.5-6",
39
- "@reddit/shreddit.styles": "^1.0.8"
40
+ "@reddit/faceplate": "2.x",
41
+ "@reddit/faceplate-ui": "2.x"
40
42
  },
41
43
  "peerDependenciesMeta": {
42
44
  "@reddit/baseplate": {
@@ -47,25 +49,29 @@
47
49
  },
48
50
  "@reddit/faceplate-ui": {
49
51
  "optional": true
50
- },
51
- "@reddit/shreddit.styles": {
52
- "optional": true
53
52
  }
54
53
  },
55
54
  "optionalDependencies": {
56
55
  "lit": "^2.0.0"
57
56
  },
58
57
  "devDependencies": {
59
- "@devvit/eslint-config": "0.9.0",
60
- "@devvit/public-api": "0.9.0",
61
- "@devvit/repo-tools": "0.9.0",
62
- "@devvit/tsconfig": "0.9.0",
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",
63
63
  "@reddit/baseplate": "0.14.0",
64
64
  "@reddit/eslint-plugin-i18n-shreddit": "0.1.0",
65
- "@reddit/faceplate": "2.0.0",
66
- "@reddit/faceplate-ui": "2.0.0",
65
+ "autoprefixer": "10.4.14",
66
+ "chokidar": "3.5.3",
67
+ "concurrently": "7.5.0",
68
+ "debounce": "1.2.1",
67
69
  "eslint": "8.9.0",
68
70
  "lit": "^2.0.0",
71
+ "postcss": "8.4.22",
72
+ "postcss-cli": "10.1.0",
73
+ "postcss-import": "15.1.0",
74
+ "tailwindcss": "3.3.1",
69
75
  "typescript": "4.9.3",
70
76
  "vitest": "0.8.2"
71
77
  },
@@ -73,5 +79,5 @@
73
79
  "directory": "dist"
74
80
  },
75
81
  "source": "./src/index.ts",
76
- "gitHead": "199c828f2632d9c09e6dc4182988cd7693704848"
82
+ "gitHead": "409f899e60151c9a3b01d0804419efc1e63fb507"
77
83
  }