@devvit/ui-renderer 0.11.8-next-2025-03-03-b6dc5fcf8.0 → 0.11.8-next-2025-03-04-01aa12d52.0

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 (38) hide show
  1. package/client/formbuilder/devvit-form-dialog.d.ts +1 -0
  2. package/client/formbuilder/devvit-form-dialog.d.ts.map +1 -1
  3. package/client/formbuilder/devvit-form-dialog.js +27 -7
  4. package/client/formbuilder/devvit-form-dialog.js.map +1 -1
  5. package/client/formbuilder/fields/renderBooleanField.d.ts +1 -0
  6. package/client/formbuilder/fields/renderBooleanField.d.ts.map +1 -1
  7. package/client/formbuilder/fields/renderBooleanField.js +15 -10
  8. package/client/formbuilder/fields/renderBooleanField.js.map +1 -1
  9. package/client/formbuilder/fields/renderFieldLabel.js +1 -1
  10. package/client/formbuilder/fields/renderFieldLabel.js.map +1 -1
  11. package/client/formbuilder/fields/renderHelpText.d.ts.map +1 -1
  12. package/client/formbuilder/fields/renderHelpText.js +4 -1
  13. package/client/formbuilder/fields/renderHelpText.js.map +1 -1
  14. package/client/formbuilder/fields/renderImageField.d.ts.map +1 -1
  15. package/client/formbuilder/fields/renderImageField.js +2 -7
  16. package/client/formbuilder/fields/renderImageField.js.map +1 -1
  17. package/client/formbuilder/fields/renderNumberField.js +1 -1
  18. package/client/formbuilder/fields/renderNumberField.js.map +1 -1
  19. package/client/formbuilder/fields/renderParagraphField.d.ts.map +1 -1
  20. package/client/formbuilder/fields/renderParagraphField.js +2 -3
  21. package/client/formbuilder/fields/renderParagraphField.js.map +1 -1
  22. package/client/formbuilder/fields/renderSelectionField.d.ts +1 -2
  23. package/client/formbuilder/fields/renderSelectionField.d.ts.map +1 -1
  24. package/client/formbuilder/fields/renderSelectionField.js +21 -15
  25. package/client/formbuilder/fields/renderSelectionField.js.map +1 -1
  26. package/client/formbuilder/fields/renderStringField.d.ts.map +1 -1
  27. package/client/formbuilder/fields/renderStringField.js +0 -1
  28. package/client/formbuilder/fields/renderStringField.js.map +1 -1
  29. package/package.json +8 -8
  30. package/styles.js +1 -1
  31. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts +0 -18
  32. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts.map +0 -1
  33. package/client/formbuilder/components/devvit-form-selection-dropdown.js +0 -187
  34. package/client/formbuilder/components/devvit-form-selection-dropdown.js.map +0 -1
  35. package/client/formbuilder/components/devvit-form-selection-list.d.ts +0 -14
  36. package/client/formbuilder/components/devvit-form-selection-list.d.ts.map +0 -1
  37. package/client/formbuilder/components/devvit-form-selection-list.js +0 -112
  38. package/client/formbuilder/components/devvit-form-selection-list.js.map +0 -1
@@ -1,18 +0,0 @@
1
- import '@reddit/faceplate-ui/components/faceplate-dropdown-menu.js';
2
- import '@reddit/faceplate-ui/components/faceplate-menu.js';
3
- import '@reddit/faceplate-ui/components/faceplate-switch-input.js';
4
- import { FormField } from '@devvit/protos/types/devvit/ui/form_builder/v1alpha/field.js';
5
- import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
6
- import type { PropertyValues, TemplateResult } from 'lit';
7
- export declare class DevvitFormSelectionDropdown extends InputElement {
8
- #private;
9
- field: FormField | undefined;
10
- dropdownOpen: boolean;
11
- selectedValues: readonly string[];
12
- static get styles(): import("lit").CSSResultGroup[];
13
- get value(): string;
14
- willUpdate(changedProperties: PropertyValues<this>): void;
15
- formDisabledCallback(disabled: boolean): void;
16
- render(): TemplateResult<1>;
17
- }
18
- //# sourceMappingURL=devvit-form-selection-dropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devvit-form-selection-dropdown.d.ts","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,4DAA4D,CAAC;AACpE,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2DAA2D,CAAC;AAEnE,OAAO,EAGL,SAAS,EACV,MAAM,8DAA8D,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAM/E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ1D,qBAAa,2BAA4B,SAAQ,YAAY;;IAE3D,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAG7B,YAAY,UAAS;IAGrB,cAAc,EAAE,SAAS,MAAM,EAAE,CAAM;IAIvC,WAAoB,MAAM,mCAWzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAoEhD,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IA6B7C,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CA4CrC"}
@@ -1,187 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11
- if (kind === "m") throw new TypeError("Private method is not writable");
12
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
- };
16
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
- };
21
- var _DevvitFormSelectionDropdown_instances, _DevvitFormSelectionDropdown_config, _DevvitFormSelectionDropdown_getLabel, _DevvitFormSelectionDropdown_updateSelection, _DevvitFormSelectionDropdown_singleSelectListItem, _DevvitFormSelectionDropdown_multiSelectListItem, _DevvitFormSelectionDropdown_renderEmptyItem, _DevvitFormSelectionDropdown_validateFieldValue, _DevvitFormSelectionDropdown_setError;
22
- import '@reddit/faceplate-ui/components/faceplate-dropdown-menu.js';
23
- import '@reddit/faceplate-ui/components/faceplate-menu.js';
24
- import '@reddit/faceplate-ui/components/faceplate-switch-input.js';
25
- import { FieldConfig_Selection, FieldConfig_Selection_Item, FormField, } from '@devvit/protos/types/devvit/ui/form_builder/v1alpha/field.js';
26
- import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
27
- import { msg } from '@reddit/faceplate/lib/i18n/localize.js';
28
- import { html } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
29
- import { dropdownButton } from '@reddit/faceplate-ui/templates/client/dropdownButton.js';
30
- import { listItem } from '@reddit/faceplate-ui/templates/client/list-item.js';
31
- import { css } from 'lit';
32
- import { property, state } from 'lit/decorators.js';
33
- import { classMap } from 'lit/directives/class-map.js';
34
- import { styles } from '../../../styles.js';
35
- import { renderHelpText } from '../fields/renderHelpText.js';
36
- export class DevvitFormSelectionDropdown extends InputElement {
37
- constructor() {
38
- super(...arguments);
39
- _DevvitFormSelectionDropdown_instances.add(this);
40
- this.dropdownOpen = false;
41
- this.selectedValues = [];
42
- _DevvitFormSelectionDropdown_config.set(this, { choices: [] });
43
- _DevvitFormSelectionDropdown_singleSelectListItem.set(this, (option) => listItem({
44
- label: option.label,
45
- onClick: () => __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_updateSelection).call(this, option),
46
- }));
47
- _DevvitFormSelectionDropdown_multiSelectListItem.set(this, (option) => listItem({
48
- label: html `
49
- <faceplate-switch-input ?checked="${this.selectedValues.includes(option.value)}">
50
- ${option.label}
51
- </faceplate-switch-input>
52
- `,
53
- onClick: (e) => {
54
- __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_updateSelection).call(this, option, e.currentTarget.checked);
55
- e.stopImmediatePropagation();
56
- },
57
- }));
58
- }
59
- static get styles() {
60
- return [
61
- super.styles,
62
- styles,
63
- // fixes a layering bug when dropdown menus are too close together
64
- css `
65
- .button .dropdown-icon {
66
- transform: none;
67
- }
68
- `,
69
- ];
70
- }
71
- get value() {
72
- return this.selectedValues.join(',');
73
- }
74
- willUpdate(changedProperties) {
75
- if (changedProperties.has('field')) {
76
- __classPrivateFieldSet(this, _DevvitFormSelectionDropdown_config, this.field?.fieldConfig?.selectionConfig ?? { choices: [] }, "f");
77
- this.selectedValues = this.field?.defaultValue?.selectionValue?.values ?? [];
78
- }
79
- }
80
- formDisabledCallback(disabled) {
81
- __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_validateFieldValue).call(this, disabled);
82
- }
83
- render() {
84
- let formField;
85
- if (this.field) {
86
- const option = __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").choices ?? [];
87
- const items = __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect
88
- ? option.map((o) => __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_multiSelectListItem, "f").call(this, o))
89
- : option.map((o) => __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_singleSelectListItem, "f").call(this, o));
90
- const emptyItem = !__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect && !__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").minSelections && !this.field.required
91
- ? __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_renderEmptyItem).call(this)
92
- : undefined;
93
- const classes = {
94
- 'flex-grow': true,
95
- 'z-auto': !this.dropdownOpen,
96
- };
97
- formField = html `
98
- <faceplate-dropdown-menu
99
- id="${this.field.fieldId}"
100
- class="${classMap(classes)}"
101
- .onopen="${() => (this.dropdownOpen = true)}"
102
- .onclose="${() => (this.dropdownOpen = false)}"
103
- ?disabled="${this.field.disabled}"
104
- >
105
- ${dropdownButton({
106
- attributes: {
107
- disabled: Boolean(this.field.disabled),
108
- className: 'flex justify-between grow',
109
- },
110
- children: html `<span class="grow">${__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_getLabel).call(this)}</span>`,
111
- selected: this.dropdownOpen,
112
- })}
113
- <faceplate-menu slot="menu" class="max-h-[160px] max-w-[400px] overflow-y-auto"
114
- >${emptyItem}${items}
115
- </faceplate-menu>
116
- </faceplate-dropdown-menu>
117
- ${renderHelpText(this.field.helpText)}
118
- `;
119
- }
120
- return html `${formField}${super.render()}`;
121
- }
122
- }
123
- _DevvitFormSelectionDropdown_config = new WeakMap(), _DevvitFormSelectionDropdown_singleSelectListItem = new WeakMap(), _DevvitFormSelectionDropdown_multiSelectListItem = new WeakMap(), _DevvitFormSelectionDropdown_instances = new WeakSet(), _DevvitFormSelectionDropdown_getLabel = function _DevvitFormSelectionDropdown_getLabel() {
124
- const selectedCount = this.selectedValues.length;
125
- if (selectedCount === 0) {
126
- return '';
127
- }
128
- if (selectedCount === 1) {
129
- const value = this.selectedValues[0];
130
- return __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").choices.find((c) => c.value === value)?.label ?? '';
131
- }
132
- return msg(`[${selectedCount} items selected]`, {
133
- desc: 'Displayed on a drop down menu when multiple values are selected',
134
- });
135
- }, _DevvitFormSelectionDropdown_updateSelection = function _DevvitFormSelectionDropdown_updateSelection(option, selected = true) {
136
- if (__classPrivateFieldGet(this, _DevvitFormSelectionDropdown_config, "f").multiSelect) {
137
- const isAlreadySelected = this.selectedValues.includes(option.value);
138
- if (selected && !isAlreadySelected) {
139
- this.selectedValues = [...this.selectedValues, option.value];
140
- }
141
- else if (isAlreadySelected) {
142
- this.selectedValues = this.selectedValues.filter((v) => v !== option.value);
143
- }
144
- }
145
- else {
146
- this.selectedValues = [option.value];
147
- }
148
- __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_validateFieldValue).call(this, Boolean(this.field?.disabled));
149
- }, _DevvitFormSelectionDropdown_renderEmptyItem = function _DevvitFormSelectionDropdown_renderEmptyItem() {
150
- return listItem({
151
- label: html `&nbsp;`,
152
- onClick: () => {
153
- this.selectedValues = [];
154
- },
155
- });
156
- }, _DevvitFormSelectionDropdown_validateFieldValue = function _DevvitFormSelectionDropdown_validateFieldValue(disabled) {
157
- if (disabled || Boolean(this.value?.length)) {
158
- __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_setError).call(this, null);
159
- return;
160
- }
161
- if (this.value?.length === 0 && this.field?.required) {
162
- __classPrivateFieldGet(this, _DevvitFormSelectionDropdown_instances, "m", _DevvitFormSelectionDropdown_setError).call(this, msg('Please select an option', {
163
- desc: 'Message to user to select an option for a required field',
164
- }));
165
- }
166
- }, _DevvitFormSelectionDropdown_setError = function _DevvitFormSelectionDropdown_setError(error) {
167
- // @ts-expect-error copied from shreddit.
168
- this.setCustomValidity(error || '');
169
- // @ts-expect-error copied from shreddit.
170
- this.reportValidity();
171
- };
172
- __decorate([
173
- property({ attribute: false }),
174
- __metadata("design:type", Object)
175
- ], DevvitFormSelectionDropdown.prototype, "field", void 0);
176
- __decorate([
177
- state(),
178
- __metadata("design:type", Object)
179
- ], DevvitFormSelectionDropdown.prototype, "dropdownOpen", void 0);
180
- __decorate([
181
- state(),
182
- __metadata("design:type", Array)
183
- ], DevvitFormSelectionDropdown.prototype, "selectedValues", void 0);
184
- // Faceplate's base classes and mixins aren't playing nice with type checking for some reason
185
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
- customElements.define('devvit-form-selection-dropdown', DevvitFormSelectionDropdown);
187
- //# sourceMappingURL=devvit-form-selection-dropdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devvit-form-selection-dropdown.js","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-dropdown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,4DAA4D,CAAC;AACpE,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2DAA2D,CAAC;AAEnE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,SAAS,GACV,MAAM,8DAA8D,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,MAAM,wCAAwC,CAAC;AAE7D,OAAO,EAAE,IAAI,EAAE,MAAM,kEAAkE,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,oDAAoD,CAAC;AAE9E,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,OAAO,2BAA4B,SAAQ,YAAY;IAA7D;;;QAKE,iBAAY,GAAG,KAAK,CAAC;QAGrB,mBAAc,GAAsB,EAAE,CAAC;QAEvC,8CAAiC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAC;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;AACxB,CAAC;AA1HD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;0DACF;AAG7B;IADC,KAAK,EAAE;;iEACa;AAGrB;IADC,KAAK,EAAE;;mEAC+B;AAoKzC,6FAA6F;AAC7F,8DAA8D;AAC9D,cAAc,CAAC,MAAM,CAAC,gCAAgC,EAAE,2BAAkC,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import '@reddit/faceplate-ui/components/faceplate-checkbox-input.js';
2
- import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
3
- import { FormField } from '@devvit/protos/types/devvit/ui/form_builder/v1alpha/field.js';
4
- import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
5
- import type { PropertyValues, TemplateResult } from 'lit';
6
- export declare class DevvitFormSelectionList extends InputElement {
7
- #private;
8
- field: FormField | undefined;
9
- static get styles(): import("lit").CSSResultGroup[];
10
- get value(): string;
11
- willUpdate(changedProperties: PropertyValues<this>): void;
12
- render(): TemplateResult<1>;
13
- }
14
- //# sourceMappingURL=devvit-form-selection-list.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devvit-form-selection-list.d.ts","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-list.ts"],"names":[],"mappings":"AAAA,OAAO,6DAA6D,CAAC;AACrE,OAAO,0DAA0D,CAAC;AAElE,OAAO,EAGL,SAAS,EACV,MAAM,8DAA8D,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAG/E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAM1D,qBAAa,uBAAwB,SAAQ,YAAY;;IAEvD,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAK7B,WAAoB,MAAM,mCAEzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAoBhD,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAgDrC"}
@@ -1,112 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
13
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14
- };
15
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
16
- if (kind === "m") throw new TypeError("Private method is not writable");
17
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
18
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
19
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
20
- };
21
- var _DevvitFormSelectionList_config, _DevvitFormSelectionList_selection, _DevvitFormSelectionList_updateSelection;
22
- import '@reddit/faceplate-ui/components/faceplate-checkbox-input.js';
23
- import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
24
- import { FieldConfig_Selection, FieldConfig_Selection_Item, FormField, } from '@devvit/protos/types/devvit/ui/form_builder/v1alpha/field.js';
25
- import { FormFieldValue_SelectionValue } from '@devvit/protos/types/devvit/ui/form_builder/v1alpha/value.js';
26
- import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
27
- import { html, repeat } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
28
- import { property } from 'lit/decorators.js';
29
- import { styles } from '../../../styles.js';
30
- import { renderFieldLabel } from '../fields/renderFieldLabel.js';
31
- export class DevvitFormSelectionList extends InputElement {
32
- constructor() {
33
- super(...arguments);
34
- _DevvitFormSelectionList_config.set(this, { choices: [] });
35
- _DevvitFormSelectionList_selection.set(this, { values: [] });
36
- _DevvitFormSelectionList_updateSelection.set(this, (choice, selected = true) => {
37
- if (__classPrivateFieldGet(this, _DevvitFormSelectionList_config, "f").multiSelect) {
38
- const index = __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.indexOf(choice.value);
39
- if (selected && index < 0) {
40
- __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.push(choice.value);
41
- }
42
- else if (index >= 0) {
43
- __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.splice(index, 1);
44
- }
45
- }
46
- else {
47
- __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values = [choice.value];
48
- }
49
- });
50
- }
51
- static get styles() {
52
- return [super.styles, styles];
53
- }
54
- get value() {
55
- return __classPrivateFieldGet(this, _DevvitFormSelectionList_selection, "f").values.join(',');
56
- }
57
- willUpdate(changedProperties) {
58
- if (changedProperties.has('field')) {
59
- __classPrivateFieldSet(this, _DevvitFormSelectionList_config, this.field?.fieldConfig?.selectionConfig ?? { choices: [] }, "f");
60
- __classPrivateFieldSet(this, _DevvitFormSelectionList_selection, this.field?.defaultValue?.selectionValue ?? { values: [] }, "f");
61
- }
62
- }
63
- render() {
64
- let formField;
65
- if (this.field) {
66
- const renderRadio = (choice, index) => {
67
- const id = `${this.field?.fieldId}_${index}`;
68
- return html `
69
- <faceplate-radio-input
70
- id="${id}"
71
- name="${this.field?.fieldId}"
72
- data-value="${choice.value}"
73
- ?disabled="${this.field?.disabled}"
74
- ?required="${this.field?.required}"
75
- @input="${() => {
76
- __classPrivateFieldGet(this, _DevvitFormSelectionList_updateSelection, "f").call(this, choice);
77
- }}"
78
- >
79
- ${choice.label}
80
- </faceplate-radio-input>
81
- `;
82
- };
83
- const renderCheckbox = (choice, index) => {
84
- const id = `${this.field?.fieldId}_${index}`;
85
- return html `
86
- <faceplate-checkbox-input
87
- id="${id}"
88
- name="${this.field?.fieldId}"
89
- class="m-sm"
90
- data-value="${choice.value}"
91
- @input="${(ev) => {
92
- __classPrivateFieldGet(this, _DevvitFormSelectionList_updateSelection, "f").call(this, choice, ev.currentTarget.checked);
93
- }}"
94
- >
95
- ${choice.label}
96
- </faceplate-checkbox-input>
97
- `;
98
- };
99
- formField = html `${renderFieldLabel(this.field)}${repeat(__classPrivateFieldGet(this, _DevvitFormSelectionList_config, "f").choices ?? [], __classPrivateFieldGet(this, _DevvitFormSelectionList_config, "f").multiSelect === true ? renderCheckbox : renderRadio)}`;
100
- }
101
- return html `${formField}${super.render()}`;
102
- }
103
- }
104
- _DevvitFormSelectionList_config = new WeakMap(), _DevvitFormSelectionList_selection = new WeakMap(), _DevvitFormSelectionList_updateSelection = new WeakMap();
105
- __decorate([
106
- property({ attribute: false }),
107
- __metadata("design:type", Object)
108
- ], DevvitFormSelectionList.prototype, "field", void 0);
109
- // Faceplate's base classes and mixins aren't playing nice with type checking for some reason
110
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
- customElements.define('devvit-form-selection-list', DevvitFormSelectionList);
112
- //# sourceMappingURL=devvit-form-selection-list.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devvit-form-selection-list.js","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,6DAA6D,CAAC;AACrE,OAAO,0DAA0D,CAAC;AAElE,OAAO,EACL,qBA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