|
29 | 29 | minHeight?: number;
|
30 | 30 | /** Enabled, but does not set the width/height on the dom element */
|
31 | 31 | passive?: boolean;
|
32 |
| - /** Whether the resizer is hidden */ |
33 |
| - hidden?: boolean; |
| 32 | + /** Whether the resizer is disabled */ |
| 33 | + disabled?: boolean; |
| 34 | + /** Whether to show the resizer border */ |
| 35 | + showBorder?: boolean; |
34 | 36 | /** Optional manager that can coordinate multiple resizers */
|
35 | 37 | resizeGroup?: ResizeGroup;
|
36 | 38 | /** Optional ordering of resizer for use with `resizeManager` */
|
|
58 | 60 | syncName,
|
59 | 61 | persistId,
|
60 | 62 | passive,
|
61 |
| - hidden, |
| 63 | + disabled, |
| 64 | + showBorder = false, |
62 | 65 | resizeGroup,
|
63 | 66 | order,
|
64 | 67 | unsetMaxHeight,
|
|
82 | 85 | const resizerId = Symbol();
|
83 | 86 |
|
84 | 87 | let initial = 0;
|
85 |
| - let dragging = $state(false); |
| 88 | + let isResizing = $state(false); |
86 | 89 | let resizerDiv = $state<HTMLDivElement>();
|
87 | 90 |
|
88 | 91 | let unsubUp: () => void;
|
|
128 | 131 | }
|
129 | 132 |
|
130 | 133 | function onMouseMove(e: MouseEvent) {
|
131 |
| - dragging = true; |
| 134 | + isResizing = true; |
132 | 135 | let offsetPx: number | undefined;
|
133 | 136 | switch (direction) {
|
134 | 137 | case 'down':
|
|
159 | 162 |
|
160 | 163 | const { newValue, overflow } = applyLimits(offsetRem);
|
161 | 164 |
|
162 |
| - if (newValue && !passive && !hidden) { |
| 165 | + if (newValue && !passive && !disabled) { |
163 | 166 | setValue(newValue);
|
164 | 167 | }
|
165 | 168 | if (overflow) {
|
166 | 169 | onOverflow?.(overflow);
|
167 | 170 | }
|
168 |
| - if (e.shiftKey && syncName && newValue !== undefined && !passive && !hidden) { |
| 171 | + if (e.shiftKey && syncName && newValue !== undefined && !passive && !disabled) { |
169 | 172 | resizeSync.emit(syncName, resizerId, newValue);
|
170 | 173 | }
|
171 | 174 | }
|
172 | 175 |
|
173 | 176 | function onMouseUp() {
|
174 |
| - dragging = false; |
| 177 | + isResizing = false; |
175 | 178 | unsubUp?.();
|
176 | 179 | unsubMove?.();
|
177 | 180 | onResizing?.(false);
|
|
186 | 189 | if (!viewport) {
|
187 | 190 | return;
|
188 | 191 | }
|
189 |
| - if (passive || hidden) { |
| 192 | + if (passive || disabled) { |
190 | 193 | if (orientation === 'horizontal') {
|
191 | 194 | viewport.style.width = '';
|
192 | 195 | viewport.style.maxWidth = '';
|
|
297 | 300 | setValue(defaultValue);
|
298 | 301 | }}
|
299 | 302 | {onclick}
|
300 |
| - class:hidden |
| 303 | + class:disabled |
301 | 304 | class="resizer"
|
302 |
| - class:dragging |
| 305 | + class:is-resizing={isResizing} |
303 | 306 | class:vertical={orientation === 'vertical'}
|
304 | 307 | class:horizontal={orientation === 'horizontal'}
|
305 | 308 | class:up={direction === 'up'}
|
306 | 309 | class:down={direction === 'down'}
|
307 | 310 | class:left={direction === 'left'}
|
308 | 311 | class:right={direction === 'right'}
|
| 312 | + class:border={showBorder} |
309 | 313 | style:z-index={zIndex}
|
310 | 314 | ></div>
|
311 | 315 |
|
|
331 | 335 | height: var(--resizer-thickness);
|
332 | 336 | }
|
333 | 337 |
|
| 338 | + &.border.horizontal::after { |
| 339 | + position: absolute; |
| 340 | + top: 0; |
| 341 | + width: 1px; |
| 342 | + height: 100%; |
| 343 | + border-left: 1px solid var(--clr-border-2); |
| 344 | + content: ''; |
| 345 | + pointer-events: none; |
| 346 | + } |
| 347 | +
|
| 348 | + &.border.horizontal.left::after { |
| 349 | + left: 0; |
| 350 | + } |
| 351 | +
|
| 352 | + &.border.horizontal.right::after { |
| 353 | + right: 0; |
| 354 | + } |
| 355 | +
|
| 356 | + &.border.vertical::after { |
| 357 | + position: absolute; |
| 358 | + left: 0; |
| 359 | + width: 100%; |
| 360 | + height: 1px; |
| 361 | + border-top: 1px solid var(--clr-border-2); |
| 362 | + content: ''; |
| 363 | + pointer-events: none; |
| 364 | + } |
| 365 | +
|
| 366 | + &.border.vertical.up::after { |
| 367 | + top: 0; |
| 368 | + } |
| 369 | +
|
| 370 | + &.border.vertical.down::after { |
| 371 | + bottom: 0; |
| 372 | + } |
| 373 | +
|
334 | 374 | &.right {
|
335 | 375 | right: 0;
|
336 | 376 | }
|
|
344 | 384 | bottom: 0;
|
345 | 385 | }
|
346 | 386 |
|
347 |
| - &.hidden { |
| 387 | + &.disabled { |
348 | 388 | pointer-events: none;
|
349 | 389 | --resizer-cursor: default;
|
350 | 390 | }
|
|
0 commit comments