ng-blatui 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,15 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
3
  import * as i0 from '@angular/core';
4
- import { input, computed, Directive, Component, signal, model, inject, PLATFORM_ID, effect, Injectable } from '@angular/core';
4
+ import { input, computed, Directive, Component, signal, model, inject, PLATFORM_ID, effect, Injectable, ElementRef } from '@angular/core';
5
5
  import { cva } from 'class-variance-authority';
6
6
  export { AccordionContent, AccordionGroup, AccordionPanel, AccordionTrigger, ɵɵDeferredContent, ɵɵDeferredContentAware } from '@angular/aria/accordion';
7
7
  export { Tab, TabContent, TabList, TabPanel, Tabs } from '@angular/aria/tabs';
8
8
  export { DIALOG_DATA, Dialog, DialogModule, DialogRef } from '@angular/cdk/dialog';
9
9
  import { isPlatformBrowser } from '@angular/common';
10
+ import { _IdGenerator } from '@angular/cdk/a11y';
11
+ import { Overlay } from '@angular/cdk/overlay';
12
+ import { ComponentPortal } from '@angular/cdk/portal';
10
13
 
11
14
  /**
12
15
  * Merge class names with `clsx` semantics and resolve Tailwind conflicts with
@@ -1819,6 +1822,181 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
1819
1822
  }]
1820
1823
  }] });
1821
1824
 
1825
+ /**
1826
+ * BlatUI radio group. `role="radiogroup"` with arrow-key roving focus across the
1827
+ * `buiRadioItem` buttons; `[(value)]` two-way binds the selected value.
1828
+ */
1829
+ class BuiRadioGroup {
1830
+ value = model(null, /* @ts-ignore */
1831
+ ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1832
+ userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
1833
+ host = inject(ElementRef);
1834
+ computedClass = computed(() => cn('grid gap-3', this.userClass()), /* @ts-ignore */
1835
+ ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
1836
+ select(next) {
1837
+ this.value.set(next);
1838
+ }
1839
+ onKeydown(event) {
1840
+ if (!['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(event.key)) {
1841
+ return;
1842
+ }
1843
+ event.preventDefault();
1844
+ const items = [
1845
+ ...this.host.nativeElement.querySelectorAll('[role="radio"]:not([disabled])'),
1846
+ ];
1847
+ if (items.length === 0) {
1848
+ return;
1849
+ }
1850
+ const current = items.indexOf(document.activeElement);
1851
+ const isForward = event.key === 'ArrowDown' || event.key === 'ArrowRight';
1852
+ const next = items[(current + (isForward ? 1 : -1) + items.length) % items.length];
1853
+ next.focus();
1854
+ next.click();
1855
+ }
1856
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiRadioGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1857
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", type: BuiRadioGroup, isStandalone: true, selector: "[buiRadioGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { attributes: { "role": "radiogroup", "data-slot": "radio-group" }, listeners: { "keydown": "onKeydown($event)" }, properties: { "class": "computedClass()" } }, exportAs: ["buiRadioGroup"], ngImport: i0 });
1858
+ }
1859
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiRadioGroup, decorators: [{
1860
+ type: Directive,
1861
+ args: [{
1862
+ selector: '[buiRadioGroup]',
1863
+ exportAs: 'buiRadioGroup',
1864
+ host: {
1865
+ role: 'radiogroup',
1866
+ 'data-slot': 'radio-group',
1867
+ '[class]': 'computedClass()',
1868
+ '(keydown)': 'onKeydown($event)',
1869
+ },
1870
+ }]
1871
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
1872
+ const ITEM = 'border-input text-primary dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex aspect-square size-4 shrink-0 items-center justify-center rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50';
1873
+ class BuiRadioGroupItem {
1874
+ value = input.required(/* @ts-ignore */
1875
+ ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1876
+ disabled = input(false, /* @ts-ignore */
1877
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
1878
+ userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
1879
+ group = inject(BuiRadioGroup);
1880
+ checked = computed(() => this.group.value() === this.value(), /* @ts-ignore */
1881
+ ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
1882
+ tabIndex = computed(() => this.checked() || this.group.value() === null ? 0 : -1, /* @ts-ignore */
1883
+ ...(ngDevMode ? [{ debugName: "tabIndex" }] : /* istanbul ignore next */ []));
1884
+ computedClass = computed(() => cn(ITEM, this.userClass()), /* @ts-ignore */
1885
+ ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
1886
+ select() {
1887
+ if (!this.disabled()) {
1888
+ this.group.select(this.value());
1889
+ }
1890
+ }
1891
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiRadioGroupItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
1892
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: BuiRadioGroupItem, isStandalone: true, selector: "button[buiRadioItem]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "button", "role": "radio", "data-slot": "radio-group-item" }, listeners: { "click": "select()" }, properties: { "attr.aria-checked": "checked()", "attr.data-state": "checked() ? 'checked' : 'unchecked'", "attr.tabindex": "tabIndex()", "disabled": "disabled()", "class": "computedClass()" } }, ngImport: i0, template: `
1893
+ @if (checked()) {
1894
+ <span data-slot="radio-group-indicator" class="flex items-center justify-center">
1895
+ <svg viewBox="0 0 24 24" fill="currentColor" class="size-2" aria-hidden="true">
1896
+ <circle cx="12" cy="12" r="10" />
1897
+ </svg>
1898
+ </span>
1899
+ }
1900
+ `, isInline: true });
1901
+ }
1902
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiRadioGroupItem, decorators: [{
1903
+ type: Component,
1904
+ args: [{
1905
+ selector: 'button[buiRadioItem]',
1906
+ host: {
1907
+ type: 'button',
1908
+ role: 'radio',
1909
+ 'data-slot': 'radio-group-item',
1910
+ '[attr.aria-checked]': 'checked()',
1911
+ '[attr.data-state]': "checked() ? 'checked' : 'unchecked'",
1912
+ '[attr.tabindex]': 'tabIndex()',
1913
+ '[disabled]': 'disabled()',
1914
+ '[class]': 'computedClass()',
1915
+ '(click)': 'select()',
1916
+ },
1917
+ template: `
1918
+ @if (checked()) {
1919
+ <span data-slot="radio-group-indicator" class="flex items-center justify-center">
1920
+ <svg viewBox="0 0 24 24" fill="currentColor" class="size-2" aria-hidden="true">
1921
+ <circle cx="12" cy="12" r="10" />
1922
+ </svg>
1923
+ </span>
1924
+ }
1925
+ `,
1926
+ }]
1927
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
1928
+
1929
+ /** Floating tooltip bubble rendered into a CDK overlay. */
1930
+ class BuiTooltipContent {
1931
+ text = input('', /* @ts-ignore */
1932
+ ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
1933
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiTooltipContent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1934
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.2", type: BuiTooltipContent, isStandalone: true, selector: "bui-tooltip-content", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tooltip" }, classAttribute: "bg-primary text-primary-foreground z-50 w-fit max-w-xs rounded-md px-3 py-1.5 text-xs shadow-md" }, ngImport: i0, template: `{{ text() }}`, isInline: true });
1935
+ }
1936
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiTooltipContent, decorators: [{
1937
+ type: Component,
1938
+ args: [{
1939
+ selector: 'bui-tooltip-content',
1940
+ host: {
1941
+ role: 'tooltip',
1942
+ class: 'bg-primary text-primary-foreground z-50 w-fit max-w-xs rounded-md px-3 py-1.5 text-xs shadow-md',
1943
+ },
1944
+ template: `{{ text() }}`,
1945
+ }]
1946
+ }], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }] } });
1947
+ /**
1948
+ * BlatUI tooltip. Shows an accessible `role="tooltip"` bubble on hover/focus via the
1949
+ * Angular CDK overlay and wires `aria-describedby` on the host. SSR-safe (the overlay
1950
+ * is only created in the browser, on interaction).
1951
+ */
1952
+ class BuiTooltip {
1953
+ text = input.required({ ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'buiTooltip' });
1954
+ overlay = inject(Overlay);
1955
+ idGenerator = inject(_IdGenerator);
1956
+ host = inject(ElementRef);
1957
+ overlayRef = null;
1958
+ describedBy = signal(null, /* @ts-ignore */
1959
+ ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
1960
+ show() {
1961
+ if (this.overlayRef || !this.text()) {
1962
+ return;
1963
+ }
1964
+ const positionStrategy = this.overlay
1965
+ .position()
1966
+ .flexibleConnectedTo(this.host)
1967
+ .withPositions([
1968
+ { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom', offsetY: -6 },
1969
+ { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top', offsetY: 6 },
1970
+ ]);
1971
+ this.overlayRef = this.overlay.create({ positionStrategy });
1972
+ const reference = this.overlayRef.attach(new ComponentPortal(BuiTooltipContent));
1973
+ reference.setInput('text', this.text());
1974
+ const id = this.idGenerator.getId('bui-tooltip-');
1975
+ reference.location.nativeElement.id = id;
1976
+ this.describedBy.set(id);
1977
+ }
1978
+ hide() {
1979
+ this.overlayRef?.dispose();
1980
+ this.overlayRef = null;
1981
+ this.describedBy.set(null);
1982
+ }
1983
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1984
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", type: BuiTooltip, isStandalone: true, selector: "[buiTooltip]", inputs: { text: { classPropertyName: "text", publicName: "buiTooltip", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "mouseenter": "show()", "mouseleave": "hide()", "focusin": "show()", "focusout": "hide()" }, properties: { "attr.aria-describedby": "describedBy()" } }, ngImport: i0 });
1985
+ }
1986
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: BuiTooltip, decorators: [{
1987
+ type: Directive,
1988
+ args: [{
1989
+ selector: '[buiTooltip]',
1990
+ host: {
1991
+ '[attr.aria-describedby]': 'describedBy()',
1992
+ '(mouseenter)': 'show()',
1993
+ '(mouseleave)': 'hide()',
1994
+ '(focusin)': 'show()',
1995
+ '(focusout)': 'hide()',
1996
+ },
1997
+ }]
1998
+ }], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "buiTooltip", required: true }] }] } });
1999
+
1822
2000
  /*
1823
2001
  * Public API Surface of ng-blatui
1824
2002
  */
@@ -1827,5 +2005,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
1827
2005
  * Generated bundle index. Do not edit.
1828
2006
  */
1829
2007
 
1830
- export { BuiAccordion, BuiAccordionContent, BuiAccordionItem, BuiAccordionTrigger, BuiAlert, BuiAlertDescription, BuiAlertTitle, BuiAvatar, BuiBadge, BuiButton, BuiCard, BuiCardAction, BuiCardContent, BuiCardDescription, BuiCardFooter, BuiCardHeader, BuiCardTitle, BuiCheckbox, BuiDialogContent, BuiDialogDescription, BuiDialogFooter, BuiDialogHeader, BuiDialogTitle, BuiInput, BuiLabel, BuiProgress, BuiSeparator, BuiSkeleton, BuiSwitch, BuiTabList, BuiTabPanel, BuiTabTrigger, BuiTabs, BuiTextarea, BuiThemeCustomizer, THEME_TOKENS, ThemeStore, buttonVariants, cn };
2008
+ export { BuiAccordion, BuiAccordionContent, BuiAccordionItem, BuiAccordionTrigger, BuiAlert, BuiAlertDescription, BuiAlertTitle, BuiAvatar, BuiBadge, BuiButton, BuiCard, BuiCardAction, BuiCardContent, BuiCardDescription, BuiCardFooter, BuiCardHeader, BuiCardTitle, BuiCheckbox, BuiDialogContent, BuiDialogDescription, BuiDialogFooter, BuiDialogHeader, BuiDialogTitle, BuiInput, BuiLabel, BuiProgress, BuiRadioGroup, BuiRadioGroupItem, BuiSeparator, BuiSkeleton, BuiSwitch, BuiTabList, BuiTabPanel, BuiTabTrigger, BuiTabs, BuiTextarea, BuiThemeCustomizer, BuiTooltip, BuiTooltipContent, THEME_TOKENS, ThemeStore, buttonVariants, cn };
1831
2009
  //# sourceMappingURL=ng-blatui.mjs.map