resizable
zard/resizableFreeComponent
@zard publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by @zard on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.zardui.com/r/resizable.jsonSource
1import { DOCUMENT, isPlatformBrowser } from '@angular/common';2import {3 type AfterContentInit,4 booleanAttribute,5 ChangeDetectionStrategy,6 Component,7 computed,8 contentChildren,9 ElementRef,10 inject,11 input,12 type OnDestroy,13 output,14 PLATFORM_ID,15 signal,16 ViewEncapsulation,17} from '@angular/core';1819import type { ClassValue } from 'clsx';2021import { ZardResizablePanelComponent } from '@/shared/components/resizable/resizable-panel.component';22import { resizableVariants, type ZardResizableLayoutVariants } from '@/shared/components/resizable/resizable.variants';23import { mergeClasses } from '@/shared/utils/merge-classes';2425export interface ZardResizeEvent {26 sizes: number[];27 layout: 'horizontal' | 'vertical';28}2930@Component({31 selector: 'z-resizable, [z-resizable]',32 template: `33 <ng-content />34 `,35 changeDetection: ChangeDetectionStrategy.OnPush,36 encapsulation: ViewEncapsulation.None,37 host: {38 'data-slot': 'resizable-panel-group',39 '[attr.data-group]': 'true',40 '[class]': 'classes()',41 '[attr.aria-orientation]': 'zLayout()',42 },43 exportAs: 'zResizable',44})45export class ZardResizableComponent implements AfterContentInit, OnDestroy {46 private readonly elementRef = inject(ElementRef);47 private readonly platformId = inject(PLATFORM_ID);48 private readonly document = inject(DOCUMENT);4950 private readonly isBrowser = isPlatformBrowser(this.platformId);51 private readonly isResizing = signal(false);52 private listenersCleanup!: () => void | undefined;5354 readonly zLayout = input<ZardResizableLayoutVariants>('horizontal');55 readonly zLazy = input(false, { transform: booleanAttribute });56 readonly class = input<ClassValue>('');5758 readonly zResizeStart = output<ZardResizeEvent>();59 readonly zResize = output<ZardResizeEvent>();60 readonly zResizeEnd = output<ZardResizeEvent>();6162 readonly panels = contentChildren(ZardResizablePanelComponent);63 readonly panelSizes = signal<number[]>([]);64 protected readonly activeHandleIndex = signal<number | null>(null);65 protected readonly classes = computed(() =>66 mergeClasses(resizableVariants({ zLayout: this.zLayout() }), this.class()),67 );6869 ngAfterContentInit(): void {70 this.initializePanelSizes();71 }7273 ngOnDestroy(): void {74 this.listenersCleanup?.();75 }7677 convertToPercentage(value: number | string, containerSize: number): number {78 if (typeof value === 'number') {79 return value;80 }8182 if (typeof value === 'string') {83// … truncated
Files it writes
More from @zard
All 49 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | @zard | Components | Free | no deps · 5 files | |
| alertalert | @zard | Components | Free | no deps · 3 files | |
| alert-dialogalert-dialog | @zard | Components | Free | no deps · 5 files | |
| avataravatar | @zard | Components | Free | no deps · 4 files | |
| badgebadge | @zard | Components | Free | no deps · 3 files | |
| breadcrumbbreadcrumb | @zard | Components | Free | no deps · 4 files | |
| buttonbutton | @zard | Components | Free | no deps · 3 files | |
| button-groupbutton-group | @zard | Components | Free | no deps · 3 files |
