| 261 | * @param disabled If true, the input is disabled |
| 262 | */ |
| 263 | export const renderHiddenInput = ( |
| 264 | always: boolean, |
| 265 | container: HTMLElement, |
| 266 | name: string, |
| 267 | value: string | undefined | null, |
| 268 | disabled: boolean |
| 269 | ) => { |
| 270 | if (always || hasShadowDom(container)) { |
| 271 | let input = container.querySelector('input.aux-input') as HTMLInputElement | null; |
| 272 | if (!input) { |
| 273 | input = container.ownerDocument!.createElement('input'); |
| 274 | input.type = 'hidden'; |
| 275 | input.classList.add('aux-input'); |
| 276 | container.appendChild(input); |
| 277 | } |
| 278 | input.disabled = disabled; |
| 279 | input.name = name; |
| 280 | input.value = value || ''; |
| 281 | } |
| 282 | }; |
| 283 | |
| 284 | export const clamp = (min: number, n: number, max: number) => { |
| 285 | return Math.max(min, Math.min(n, max)); |