| 96 | throw Error("Unknown Component type " + JSON.stringify({ props, type })); |
| 97 | } |
| 98 | appendInitialChild( |
| 99 | parentInstance: Instance, |
| 100 | child: Instance | TextInstance |
| 101 | ): void { |
| 102 | debug("appendInitialChild"); |
| 103 | |
| 104 | if (Array.isArray(parentInstance.blocks)) { |
| 105 | parentInstance.blocks.push(child); |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | if (parentInstance.type === "overflow") { |
| 110 | parentInstance.options.push(child); |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | if ( |
| 115 | parentInstance.type === "static_select" || |
| 116 | parentInstance.type === "multi_static_select" |
| 117 | ) { |
| 118 | if (child.isOptionGroup) { |
| 119 | if (!Array.isArray(parentInstance.option_groups)) { |
| 120 | parentInstance.option_groups = []; |
| 121 | } |
| 122 | |
| 123 | parentInstance.option_groups.push(child); |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | if (!Array.isArray(parentInstance.options)) { |
| 128 | parentInstance.options = []; |
| 129 | } |
| 130 | |
| 131 | parentInstance.options.push({ ...child, url: undefined }); |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | if ( |
| 136 | parentInstance.type === "checkboxes" || |
| 137 | parentInstance.type === "radio_buttons" || |
| 138 | parentInstance.isOptionGroup |
| 139 | ) { |
| 140 | parentInstance.options.push({ ...child, url: undefined }); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | if (parentInstance.type === "input") { |
| 145 | parentInstance.element = child; |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | if (parentInstance.type === "actions") { |
| 150 | parentInstance.elements.push(child); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | if (parentInstance.type === "context") { |
| 155 | parentInstance.elements.push(child); |