| 150 | // tableChessboard → `(row, column)`). `never[]` in the contravariant |
| 151 | // arg position accepts any concrete callback shape. |
| 152 | show(reference: ReferenceElement, cb: (...args: never[]) => void = noop) { |
| 153 | const { floatBox } = this; |
| 154 | const { eventCenter } = this.muya; |
| 155 | const { placement, offsetOptions } = this.options; |
| 156 | if (!floatBox) { |
| 157 | throw new Error('The float box is not existed.'); |
| 158 | } |
| 159 | if (this._cleanup) { |
| 160 | this._cleanup(); |
| 161 | this._cleanup = null; |
| 162 | } |
| 163 | |
| 164 | // `cb` is declared with `never[]` args at the parameter so any |
| 165 | // concrete callback shape is accepted; the field stores it as |
| 166 | // `unknown[]` so internal call sites can forward arbitrary args. |
| 167 | this.cb = cb as (...args: unknown[]) => void; |
| 168 | |
| 169 | this._cleanup = autoUpdate(reference, floatBox, () => { |
| 170 | computePosition(reference, floatBox, { |
| 171 | placement, |
| 172 | middleware: [offset(offsetOptions), flip()], |
| 173 | }).then(({ x, y }) => { |
| 174 | Object.assign(floatBox.style, { |
| 175 | left: `${x}px`, |
| 176 | top: `${y}px`, |
| 177 | opacity: 1, |
| 178 | }); |
| 179 | }); |
| 180 | }); |
| 181 | |
| 182 | this.status = true; |
| 183 | |
| 184 | if (BUTTON_GROUP.includes(this.name)) |
| 185 | eventCenter.emit('muya-float-button', this, true); |
| 186 | else eventCenter.emit('muya-float', this, true); |
| 187 | } |
| 188 | |
| 189 | destroy() { |
| 190 | if (this.container && this._resizeObserver) |