| 58 | private rejectPromise!: (reason?: unknown) => void; |
| 59 | |
| 60 | constructor( |
| 61 | app: App, |
| 62 | requirements: FieldRequirement[], |
| 63 | initial?: Map<string, unknown>, |
| 64 | computePreview?: PreviewComputer, |
| 65 | ) { |
| 66 | super(app); |
| 67 | this.requirements = requirements; |
| 68 | this.initialValues = new Map<string, string>(); |
| 69 | this.computePreview = computePreview; |
| 70 | initial?.forEach((v, k) => { |
| 71 | if (typeof v === "string") this.initialValues.set(k, v); |
| 72 | }); |
| 73 | |
| 74 | this.updatePreviewDebounced = debounce( |
| 75 | this.updatePreviews.bind(this), |
| 76 | 150, |
| 77 | true, |
| 78 | ); |
| 79 | |
| 80 | this.waitForClose = new Promise<Record<string, string>>( |
| 81 | (resolve, reject) => { |
| 82 | this.resolvePromise = resolve; |
| 83 | this.rejectPromise = reject; |
| 84 | }, |
| 85 | ); |
| 86 | |
| 87 | this.display(); |
| 88 | this.open(); |
| 89 | } |
| 90 | |
| 91 | private display() { |
| 92 | this.containerEl.addClass("quickAddModal", "onePageInputModal"); |