circletone.mjs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. import * as i0 from '@angular/core';
  2. import { Component, ChangeDetectionStrategy, Input, EventEmitter, Output, Pipe, Injectable, inject, DestroyRef, ContentChildren, Directive, HostListener, forwardRef, ChangeDetectorRef, signal, ViewChild } from '@angular/core';
  3. import { NgClass, AsyncPipe, KeyValuePipe, JsonPipe } from '@angular/common';
  4. import * as i1 from '@angular/platform-browser';
  5. import { RouterLink } from '@angular/router';
  6. import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
  7. import { withLatestFrom, debounceTime, skip, BehaviorSubject, filter, Subject } from 'rxjs';
  8. import * as i1$1 from '@angular/forms';
  9. import { NG_VALUE_ACCESSOR, ControlContainer, FormGroupDirective } from '@angular/forms';
  10. /**
  11. * Used for some components to determine colouring of various elements. Relates to CSS classes to facilitate dev's life
  12. */
  13. var TypeEnum;
  14. (function (TypeEnum) {
  15. TypeEnum["PRIMARY"] = "primary";
  16. TypeEnum["SECONDARY"] = "secondary";
  17. TypeEnum["TERTIARY"] = "tertiary";
  18. TypeEnum["SUCCESS"] = "success";
  19. TypeEnum["WARNING"] = "warning";
  20. TypeEnum["ERROR"] = "error";
  21. })(TypeEnum || (TypeEnum = {}));
  22. /**
  23. * Used for some components to determine sizing of various elements. Relates to 'tailwind' classes to facilitate dev's life
  24. */
  25. var SizeEnum;
  26. (function (SizeEnum) {
  27. /** extra-small */
  28. SizeEnum["XS"] = "xs";
  29. /** small */
  30. SizeEnum["SM"] = "sm";
  31. /** default size */
  32. SizeEnum["BASE"] = "base";
  33. /** large */
  34. SizeEnum["LG"] = "lg";
  35. /** extra-large */
  36. SizeEnum["XL"] = "xl";
  37. })(SizeEnum || (SizeEnum = {}));
  38. /**
  39. * Used for some components to determine the variance of diverse elements.
  40. */
  41. var VariantEnum;
  42. (function (VariantEnum) {
  43. /** produces a non-styled element */
  44. VariantEnum["BLANK"] = "blank";
  45. /** produces a solid element */
  46. VariantEnum["SOLID"] = "solid";
  47. /** produces a bordered element */
  48. VariantEnum["OUTLINE"] = "outline";
  49. /** produces a solid-gradient element */
  50. VariantEnum["GRADIENT"] = "gradient";
  51. })(VariantEnum || (VariantEnum = {}));
  52. class IconComponent {
  53. constructor() {
  54. this.icon = '';
  55. this.fill = 'currentColor';
  56. this.strokeWidth = 1.5;
  57. this.strokeColor = 'currentColor';
  58. this.size = SizeEnum.BASE;
  59. this.variant = VariantEnum.OUTLINE;
  60. }
  61. ngOnInit() {
  62. this.strokeColor = this.getFormattedColor(this.strokeColor);
  63. this.fill = this.getFormattedColor(this.fill);
  64. }
  65. get iconPath() {
  66. const icon = this.variant === VariantEnum.SOLID ? `${this.icon}-solid` : this.icon;
  67. return `/assets/icons.svg#${icon}`;
  68. }
  69. getFormattedColor(color) {
  70. if (color.startsWith('--')) {
  71. const rgbValue = getComputedStyle(document.documentElement).getPropertyValue(color).trim();
  72. return `rgb(${rgbValue})`;
  73. }
  74. return color;
  75. }
  76. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: IconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  77. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.2", type: IconComponent, isStandalone: true, selector: "ct-icon", inputs: { icon: "icon", fill: "fill", strokeWidth: "strokeWidth", strokeColor: "strokeColor", size: "size", variant: "variant" }, ngImport: i0, template: "<svg\n [attr.fill]=\"variant === 'solid' ? fill : 'none'\"\n [attr.stroke-width]=\"variant === 'outline' ? strokeWidth : 0\"\n [attr.stroke]=\"strokeColor\"\n class=\"flex\"\n [class.size-3]=\"size === 'xs'\"\n [class.size-4]=\"size === 'sm'\"\n [class.size-5]=\"size === 'base'\"\n [class.size-6]=\"size === 'lg'\"\n [class.size-8]=\"size === 'xl'\">\n <use [attr.xlink:href]=\"iconPath\"></use>\n</svg>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  78. }
  79. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: IconComponent, decorators: [{
  80. type: Component,
  81. args: [{ selector: 'ct-icon', standalone: true, imports: [NgClass], changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg\n [attr.fill]=\"variant === 'solid' ? fill : 'none'\"\n [attr.stroke-width]=\"variant === 'outline' ? strokeWidth : 0\"\n [attr.stroke]=\"strokeColor\"\n class=\"flex\"\n [class.size-3]=\"size === 'xs'\"\n [class.size-4]=\"size === 'sm'\"\n [class.size-5]=\"size === 'base'\"\n [class.size-6]=\"size === 'lg'\"\n [class.size-8]=\"size === 'xl'\">\n <use [attr.xlink:href]=\"iconPath\"></use>\n</svg>\n" }]
  82. }], propDecorators: { icon: [{
  83. type: Input
  84. }], fill: [{
  85. type: Input
  86. }], strokeWidth: [{
  87. type: Input
  88. }], strokeColor: [{
  89. type: Input
  90. }], size: [{
  91. type: Input
  92. }], variant: [{
  93. type: Input
  94. }] } });
  95. /**
  96. * This is the ButtonComponent, widely used among other components
  97. */
  98. class ButtonComponent {
  99. constructor() {
  100. this.iconPosition = 'left';
  101. this.fullSize = false;
  102. this.size = 'base';
  103. this.type = 'primary';
  104. this.variant = 'solid';
  105. }
  106. get cssClassmap() {
  107. return {
  108. [`text-on-${this.type} dark:text-on-${this.type}-dark`]: this.variant === VariantEnum.SOLID || this.variant === VariantEnum.GRADIENT,
  109. [`text-neutral-950 dark:text-neutral-50 hover:text-${this.type}-dark dark:hover:text-${this.type}`]: this.variant === VariantEnum.GRADIENT || this.variant === VariantEnum.BLANK,
  110. [`bg-${this.type} dark:bg-${this.type}-dark hover:bg-${this.type}-variant hover:dark:bg-${this.type}-variant-dark`]: this.variant === VariantEnum.SOLID,
  111. [`from-${this.type}-variant from-30% to-${this.type} bg-gradient-to-tl hover:bg-gradient-to-br dark:from-${this.type}-variant-dark dark:to-${this.type}-dark`]: this.variant === VariantEnum.GRADIENT,
  112. [`border border-2 border-${this.type} hover:border-${this.type}-variant dark:border-${this.type}-dark`]: this.variant === VariantEnum.OUTLINE,
  113. 'px-3 py-2': (this.size === SizeEnum.XS || this.size === SizeEnum.SM) && !this.hasJustIcon(),
  114. 'px-5 py-2.5': (this.size === SizeEnum.BASE || this.size === SizeEnum.LG) && !this.hasJustIcon(),
  115. 'px-6 py-3': this.size === SizeEnum.XL && !this.hasJustIcon(),
  116. 'p-2': this.hasJustIcon() && this.variant !== 'blank',
  117. 'text-xs': this.size === SizeEnum.XS,
  118. 'text-sm': this.size === SizeEnum.SM || this.size === SizeEnum.BASE,
  119. 'text-base': this.size === SizeEnum.LG || this.size === SizeEnum.XL,
  120. 'w-full': this.fullSize,
  121. };
  122. }
  123. hasJustIcon() {
  124. return this.icon !== undefined && this.text === undefined;
  125. }
  126. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  127. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: ButtonComponent, isStandalone: true, selector: "ct-button", inputs: { text: "text", icon: "icon", iconPosition: "iconPosition", fullSize: "fullSize", size: "size", type: "type", variant: "variant" }, ngImport: i0, template: "<button class=\"flex flex-row items-center justify-center gap-1.5 rounded-md font-medium\" [ngClass]=\"cssClassmap\">\n @if (icon) {\n <ct-icon class=\"flex\" [size]=\"size\" [icon]=\"icon\" />\n }\n @if (text) {\n <span [class.order-first]=\"iconPosition === 'right'\">\n {{ text }}\n </span>\n }\n</button>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  128. }
  129. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: ButtonComponent, decorators: [{
  130. type: Component,
  131. args: [{ selector: 'ct-button', standalone: true, imports: [NgClass, IconComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"flex flex-row items-center justify-center gap-1.5 rounded-md font-medium\" [ngClass]=\"cssClassmap\">\n @if (icon) {\n <ct-icon class=\"flex\" [size]=\"size\" [icon]=\"icon\" />\n }\n @if (text) {\n <span [class.order-first]=\"iconPosition === 'right'\">\n {{ text }}\n </span>\n }\n</button>\n" }]
  132. }], propDecorators: { text: [{
  133. type: Input
  134. }], icon: [{
  135. type: Input
  136. }], iconPosition: [{
  137. type: Input
  138. }], fullSize: [{
  139. type: Input
  140. }], size: [{
  141. type: Input
  142. }], type: [{
  143. type: Input
  144. }], variant: [{
  145. type: Input
  146. }] } });
  147. /**
  148. * The alert component is responsible to show alerts for diverse elements. Including `FormErrorComponent` among others.
  149. */
  150. class AlertComponent {
  151. constructor() {
  152. this.dismissable = false;
  153. this.fullSize = true;
  154. this.text = '';
  155. this.type = TypeEnum.PRIMARY;
  156. this.variant = VariantEnum.SOLID;
  157. this.withIcon = true;
  158. this.dismiss = new EventEmitter();
  159. }
  160. get icon() {
  161. switch (this.type) {
  162. case TypeEnum.PRIMARY:
  163. case TypeEnum.SECONDARY:
  164. return 'information-circle';
  165. case TypeEnum.ERROR:
  166. return 'exclamation-triangle';
  167. case TypeEnum.WARNING:
  168. return 'exclamation-circle';
  169. case TypeEnum.SUCCESS:
  170. return 'check-circle';
  171. default:
  172. return '';
  173. }
  174. }
  175. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  176. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AlertComponent, isStandalone: true, selector: "ct-alert", inputs: { dismissable: "dismissable", fullSize: "fullSize", text: "text", type: "type", variant: "variant", withIcon: "withIcon" }, outputs: { dismiss: "dismiss" }, ngImport: i0, template: "<div\n class=\"mb-4 flex flex-row items-center gap-1 rounded-lg\"\n [class.w-fit]=\"!fullSize\"\n [class.w-full]=\"fullSize\"\n role=\"alert\"\n [ngClass]=\"{\n 'bg-surface-variant dark:bg-surface-variant-dark text-on-surface dark:text-on-surface-dark':\n type === 'primary' && variant === 'solid',\n 'bg-warning dark:bg-warning-dark text-on-warning dark:text-on-warning-dark':\n type === 'warning' && variant === 'solid',\n 'bg-error dark:bg-error-dark text-on-error dark:text-on-error-dark': type === 'error' && variant === 'solid',\n 'bg-success dark:bg-success-dark text-on-success dark:text-on-success-dark':\n type === 'success' && variant === 'solid',\n border: variant === 'outline',\n 'border-surface-variant dark:border-surface-variant-dark': type === 'primary' && variant === 'outline',\n 'border-warning dark:border-warning-dark': type === 'warning' && variant === 'outline',\n 'border-error dark:border-error-dark': type === 'error' && variant === 'outline',\n 'border-success dark:border-success-dark': type === 'success' && variant === 'outline',\n 'px-4 py-2': variant !== 'blank'\n }\">\n @if (withIcon) {\n <ct-icon [icon]=\"this.icon\" />\n }\n <span class=\"grow text-sm font-semibold\">{{ text }}</span>\n @if (dismissable) {\n <ct-button icon=\"x-mark\" size=\"sm\" variant=\"blank\" [type]=\"type\" (click)=\"dismiss.emit()\" />\n }\n</div>\n", dependencies: [{ kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }, { kind: "component", type: ButtonComponent, selector: "ct-button", inputs: ["text", "icon", "iconPosition", "fullSize", "size", "type", "variant"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  177. }
  178. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AlertComponent, decorators: [{
  179. type: Component,
  180. args: [{ selector: 'ct-alert', standalone: true, imports: [IconComponent, ButtonComponent, NgClass], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"mb-4 flex flex-row items-center gap-1 rounded-lg\"\n [class.w-fit]=\"!fullSize\"\n [class.w-full]=\"fullSize\"\n role=\"alert\"\n [ngClass]=\"{\n 'bg-surface-variant dark:bg-surface-variant-dark text-on-surface dark:text-on-surface-dark':\n type === 'primary' && variant === 'solid',\n 'bg-warning dark:bg-warning-dark text-on-warning dark:text-on-warning-dark':\n type === 'warning' && variant === 'solid',\n 'bg-error dark:bg-error-dark text-on-error dark:text-on-error-dark': type === 'error' && variant === 'solid',\n 'bg-success dark:bg-success-dark text-on-success dark:text-on-success-dark':\n type === 'success' && variant === 'solid',\n border: variant === 'outline',\n 'border-surface-variant dark:border-surface-variant-dark': type === 'primary' && variant === 'outline',\n 'border-warning dark:border-warning-dark': type === 'warning' && variant === 'outline',\n 'border-error dark:border-error-dark': type === 'error' && variant === 'outline',\n 'border-success dark:border-success-dark': type === 'success' && variant === 'outline',\n 'px-4 py-2': variant !== 'blank'\n }\">\n @if (withIcon) {\n <ct-icon [icon]=\"this.icon\" />\n }\n <span class=\"grow text-sm font-semibold\">{{ text }}</span>\n @if (dismissable) {\n <ct-button icon=\"x-mark\" size=\"sm\" variant=\"blank\" [type]=\"type\" (click)=\"dismiss.emit()\" />\n }\n</div>\n" }]
  181. }], propDecorators: { dismissable: [{
  182. type: Input
  183. }], fullSize: [{
  184. type: Input
  185. }], text: [{
  186. type: Input,
  187. args: [{ required: true }]
  188. }], type: [{
  189. type: Input
  190. }], variant: [{
  191. type: Input
  192. }], withIcon: [{
  193. type: Input
  194. }], dismiss: [{
  195. type: Output
  196. }] } });
  197. class SafeImagePipe {
  198. constructor(sanitizer) {
  199. this.sanitizer = sanitizer;
  200. }
  201. transform(value, type = 'image/webp') {
  202. const imageBase64 = `data:${type};base64,${value}`;
  203. return this.sanitizer.bypassSecurityTrustUrl(imageBase64);
  204. }
  205. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: SafeImagePipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe }); }
  206. static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.2", ngImport: i0, type: SafeImagePipe, isStandalone: true, name: "safeImage" }); }
  207. }
  208. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: SafeImagePipe, decorators: [{
  209. type: Pipe,
  210. args: [{
  211. name: 'safeImage',
  212. standalone: true,
  213. }]
  214. }], ctorParameters: () => [{ type: i1.DomSanitizer }] });
  215. class AvatarComponent {
  216. constructor() {
  217. this.picture = '';
  218. this.title = '';
  219. this.titleInitials = '';
  220. }
  221. ngOnInit() {
  222. this.titleInitials = this.title
  223. .split(' ')
  224. .map(word => word[0]?.toLocaleUpperCase())
  225. .splice(0, 2)
  226. .join('');
  227. }
  228. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  229. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AvatarComponent, isStandalone: true, selector: "ct-avatar", inputs: { picture: "picture", title: "title" }, ngImport: i0, template: "@if (picture) {\n <img\n [src]=\"picture\"\n alt=\"{{ title }}\"\n class=\"size-16 rounded-full border-2 border-primary object-cover dark:border-primary-dark\" />\n} @else {\n <div\n class=\"size-16 truncate text-ellipsis rounded-full border border-primary bg-primary-container p-4 text-on-primary-container dark:bg-primary-container-dark dark:text-on-primary-container-dark\">\n <span class=\"text-2xl font-medium\"> {{ titleInitials }}</span>\n </div>\n}\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  230. }
  231. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AvatarComponent, decorators: [{
  232. type: Component,
  233. args: [{ selector: 'ct-avatar', standalone: true, imports: [IconComponent, SafeImagePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (picture) {\n <img\n [src]=\"picture\"\n alt=\"{{ title }}\"\n class=\"size-16 rounded-full border-2 border-primary object-cover dark:border-primary-dark\" />\n} @else {\n <div\n class=\"size-16 truncate text-ellipsis rounded-full border border-primary bg-primary-container p-4 text-on-primary-container dark:bg-primary-container-dark dark:text-on-primary-container-dark\">\n <span class=\"text-2xl font-medium\"> {{ titleInitials }}</span>\n </div>\n}\n" }]
  234. }], propDecorators: { picture: [{
  235. type: Input
  236. }], title: [{
  237. type: Input
  238. }] } });
  239. class HeaderComponent {
  240. constructor() {
  241. this.title = '';
  242. }
  243. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: HeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  244. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.2", type: HeaderComponent, isStandalone: true, selector: "ct-header", inputs: { title: "title" }, ngImport: i0, template: "<div\n class=\"flex h-14 w-full items-center justify-between bg-gradient-to-b from-surface to-primary px-4 py-2 dark:from-surface-variant-dark dark:to-primary-container-dark\">\n <div class=\"flex grow font-logo\">{{ title }}</div>\n <ng-content />\n</div>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  245. }
  246. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: HeaderComponent, decorators: [{
  247. type: Component,
  248. args: [{ selector: 'ct-header', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"flex h-14 w-full items-center justify-between bg-gradient-to-b from-surface to-primary px-4 py-2 dark:from-surface-variant-dark dark:to-primary-container-dark\">\n <div class=\"flex grow font-logo\">{{ title }}</div>\n <ng-content />\n</div>\n" }]
  249. }], propDecorators: { title: [{
  250. type: Input
  251. }] } });
  252. class MenuItemComponent {
  253. constructor() {
  254. this.text = '';
  255. this.link = '';
  256. this.type = 'internal';
  257. this.icon = undefined;
  258. this.iconSize = SizeEnum.BASE;
  259. this.iconAlone = false;
  260. this.iconDirection = 'horizontal';
  261. }
  262. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: MenuItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  263. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: MenuItemComponent, isStandalone: true, selector: "ct-menu-item", inputs: { text: "text", link: "link", type: "type", icon: "icon", iconSize: "iconSize", iconAlone: "iconAlone", iconDirection: "iconDirection" }, ngImport: i0, template: "<a\n [routerLink]=\"(type === 'internal' && link)! || null\"\n [attr.href]=\"type === 'external' && link\"\n class=\"block rounded-md px-4 py-2 text-on-surface hover:bg-primary/25 dark:text-on-surface-dark dark:hover:bg-primary-dark/25\">\n <span\n class=\"flex items-center gap-3\"\n [class.flex-row]=\"iconDirection === 'horizontal'\"\n [class.flex-col]=\"iconDirection === 'vertical'\">\n @if (icon) {\n <ct-icon [icon]=\"icon\" variant=\"solid\" size=\"xl\" />\n }\n @if (text && !iconAlone) {\n <span>{{ text }}</span>\n }\n </span>\n</a>\n", dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  264. }
  265. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: MenuItemComponent, decorators: [{
  266. type: Component,
  267. args: [{ selector: 'ct-menu-item', standalone: true, imports: [RouterLink, IconComponent, ButtonComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<a\n [routerLink]=\"(type === 'internal' && link)! || null\"\n [attr.href]=\"type === 'external' && link\"\n class=\"block rounded-md px-4 py-2 text-on-surface hover:bg-primary/25 dark:text-on-surface-dark dark:hover:bg-primary-dark/25\">\n <span\n class=\"flex items-center gap-3\"\n [class.flex-row]=\"iconDirection === 'horizontal'\"\n [class.flex-col]=\"iconDirection === 'vertical'\">\n @if (icon) {\n <ct-icon [icon]=\"icon\" variant=\"solid\" size=\"xl\" />\n }\n @if (text && !iconAlone) {\n <span>{{ text }}</span>\n }\n </span>\n</a>\n" }]
  268. }], propDecorators: { text: [{
  269. type: Input
  270. }], link: [{
  271. type: Input,
  272. args: [{ required: true }]
  273. }], type: [{
  274. type: Input,
  275. args: [{ required: true }]
  276. }], icon: [{
  277. type: Input
  278. }], iconSize: [{
  279. type: Input
  280. }], iconAlone: [{
  281. type: Input
  282. }], iconDirection: [{
  283. type: Input
  284. }] } });
  285. class AccordionRegistryService {
  286. constructor() {
  287. this.accordions = new Map();
  288. }
  289. register(id, element) {
  290. this.accordions.set(id, element);
  291. }
  292. get(id) {
  293. return this.accordions.get(id);
  294. }
  295. unregister(id) {
  296. this.accordions.delete(id);
  297. }
  298. getItem(accordion, itemId) {
  299. const accordionObject = this.accordions.get(accordion);
  300. return accordionObject.accordionItems.find(item => item.id === itemId);
  301. }
  302. openItem(accordion, itemId) {
  303. this.accordions
  304. .get(accordion)
  305. ?.accordionItems.find(item => item.id === itemId)
  306. ?.isOpen.next(true);
  307. }
  308. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionRegistryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
  309. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionRegistryService, providedIn: 'any' }); }
  310. }
  311. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionRegistryService, decorators: [{
  312. type: Injectable,
  313. args: [{ providedIn: 'any' }]
  314. }] });
  315. class AccordionComponent {
  316. constructor() {
  317. this.destroyRef = inject(DestroyRef);
  318. this.accordionRegistryService = inject(AccordionRegistryService);
  319. this.label = '';
  320. this.policy = 'collapse';
  321. this.gap = 0;
  322. this.parentAccordion = '';
  323. this.parentTrigger = '';
  324. }
  325. ngAfterViewInit() {
  326. this.accordionItems.forEach(accordionItem => {
  327. accordionItem.toggle
  328. .pipe(takeUntilDestroyed(this.destroyRef), withLatestFrom(accordionItem.isOpen), debounceTime(10))
  329. .subscribe(([_, isOpen]) => {
  330. accordionItem.isOpen.next(!isOpen);
  331. });
  332. accordionItem.isOpen.pipe(takeUntilDestroyed(this.destroyRef), skip(1), debounceTime(10)).subscribe(isOpen => {
  333. if (isOpen) {
  334. if (this.parentTrigger) {
  335. this.accordionRegistryService.getItem(this.parentAccordion, this.parentTrigger)?.isOpen.next(true);
  336. }
  337. if (this.policy === 'collapse') {
  338. this.accordionItems.forEach(otherAccordionItem => {
  339. if (accordionItem.id !== otherAccordionItem.id && otherAccordionItem.isOpen) {
  340. otherAccordionItem.isOpen.next(false);
  341. }
  342. });
  343. }
  344. }
  345. });
  346. });
  347. this.accordionRegistryService.register(this.id, this);
  348. }
  349. ngOnDestroy() {
  350. this.accordionRegistryService.unregister(this.id);
  351. }
  352. closePanes() {
  353. this.accordionItems.forEach(accordionItem => accordionItem.isOpen.next(false));
  354. }
  355. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  356. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.2", type: AccordionComponent, isStandalone: true, selector: "ct-accordion", inputs: { label: "label", id: "id", policy: "policy", gap: "gap", parentAccordion: "parentAccordion", parentTrigger: "parentTrigger" }, queries: [{ propertyName: "accordionItems", predicate: AccordionItemComponent }], ngImport: i0, template: "<div class=\"flex flex-col gap-{{ gap }}\">\n <ng-content></ng-content>\n</div>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  357. }
  358. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionComponent, decorators: [{
  359. type: Component,
  360. args: [{ selector: 'ct-accordion', standalone: true, imports: [AsyncPipe, IconComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"flex flex-col gap-{{ gap }}\">\n <ng-content></ng-content>\n</div>\n" }]
  361. }], propDecorators: { label: [{
  362. type: Input
  363. }], id: [{
  364. type: Input,
  365. args: [{ required: true }]
  366. }], policy: [{
  367. type: Input
  368. }], gap: [{
  369. type: Input
  370. }], parentAccordion: [{
  371. type: Input
  372. }], parentTrigger: [{
  373. type: Input
  374. }], accordionItems: [{
  375. type: ContentChildren,
  376. args: [AccordionItemComponent]
  377. }] } });
  378. class AccordionItemComponent {
  379. constructor() {
  380. this.destroyRef = inject(DestroyRef);
  381. this.id = '';
  382. this.label = '';
  383. this.isOpen = new BehaviorSubject(false);
  384. this.toggle = new EventEmitter();
  385. }
  386. ngAfterViewInit() {
  387. this.isOpen
  388. .pipe(takeUntilDestroyed(this.destroyRef), skip(1), filter(isOpen => !isOpen))
  389. .subscribe(() => {
  390. this.accordions.forEach(accordion => {
  391. accordion.closePanes();
  392. });
  393. });
  394. }
  395. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  396. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AccordionItemComponent, isStandalone: true, selector: "ct-accordion-item", inputs: { id: "id", label: "label", isOpen: "isOpen" }, outputs: { toggle: "toggle" }, queries: [{ propertyName: "accordions", predicate: AccordionComponent }], ngImport: i0, template: "<div\n tabindex=\"0\"\n class=\"flex cursor-pointer flex-row items-center justify-between gap-1.5 bg-surface px-4 py-2 text-on-surface hover:bg-primary/50 dark:bg-surface-dark dark:text-on-surface-dark hover:dark:bg-surface-variant-dark\"\n [class.rounded-t-md]=\"isOpen | async\"\n [class.rounded-md]=\"(isOpen | async) === false\"\n (click)=\"toggle.emit()\">\n <span class=\"grow\">{{ label }}</span>\n <ct-icon size=\"sm\" [icon]=\"(isOpen | async) ? 'chevron-up' : 'chevron-down'\" />\n</div>\n@if (isOpen | async) {\n <div class=\"flex flex-col rounded-b-md bg-surface/35 p-4 dark:bg-surface-dark/50\">\n <ng-content></ng-content>\n </div>\n}\n", dependencies: [{ kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  397. }
  398. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AccordionItemComponent, decorators: [{
  399. type: Component,
  400. args: [{ selector: 'ct-accordion-item', standalone: true, imports: [IconComponent, AsyncPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n tabindex=\"0\"\n class=\"flex cursor-pointer flex-row items-center justify-between gap-1.5 bg-surface px-4 py-2 text-on-surface hover:bg-primary/50 dark:bg-surface-dark dark:text-on-surface-dark hover:dark:bg-surface-variant-dark\"\n [class.rounded-t-md]=\"isOpen | async\"\n [class.rounded-md]=\"(isOpen | async) === false\"\n (click)=\"toggle.emit()\">\n <span class=\"grow\">{{ label }}</span>\n <ct-icon size=\"sm\" [icon]=\"(isOpen | async) ? 'chevron-up' : 'chevron-down'\" />\n</div>\n@if (isOpen | async) {\n <div class=\"flex flex-col rounded-b-md bg-surface/35 p-4 dark:bg-surface-dark/50\">\n <ng-content></ng-content>\n </div>\n}\n" }]
  401. }], propDecorators: { id: [{
  402. type: Input,
  403. args: [{ required: true }]
  404. }], label: [{
  405. type: Input
  406. }], isOpen: [{
  407. type: Input
  408. }], toggle: [{
  409. type: Output
  410. }], accordions: [{
  411. type: ContentChildren,
  412. args: [AccordionComponent]
  413. }] } });
  414. class CardComponent {
  415. constructor() {
  416. this.header = '';
  417. this.subHeader = '';
  418. this.title = '';
  419. this.subTitle = '';
  420. this.avatar = '';
  421. this.image = '';
  422. this.imageThumbnail = '';
  423. this.withActions = false;
  424. }
  425. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: CardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  426. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: CardComponent, isStandalone: true, selector: "ct-card", inputs: { header: "header", subHeader: "subHeader", title: "title", subTitle: "subTitle", avatar: "avatar", image: "image", imageThumbnail: "imageThumbnail", withActions: "withActions" }, ngImport: i0, template: "<div class=\"flex w-full flex-col rounded-xl bg-surface text-on-surface dark:bg-surface-dark dark:text-on-surface-dark\">\n <div class=\"flex w-full flex-row items-stretch rounded-md\">\n <div class=\"flex w-full grow flex-row items-center gap-4 px-4 py-2\">\n <div class=\"items-center\">\n <ct-avatar [picture]=\"avatar\" [title]=\"title\" />\n </div>\n <div class=\"flex grow flex-col\">\n @if (header) {\n <span class=\"grow text-lg font-semibold\" [innerHTML]=\"header\"></span>\n }\n @if (subHeader) {\n <span class=\"grow text-sm\" [innerHTML]=\"subHeader\"></span>\n }\n </div>\n </div>\n <div class=\"flex flex-col justify-between rounded-r-xl\">\n @if (imageThumbnail) {\n <img class=\"flex max-w-24 rounded-tr-xl object-cover\" [src]=\"imageThumbnail\" [alt]=\"title\" />\n } @else {\n <ng-content select=\"[header-extra]\" />\n }\n </div>\n </div>\n @if (image) {\n <img class=\"size-full object-cover\" [src]=\"image\" [alt]=\"title\" />\n }\n @if (title || subTitle) {\n <div class=\"flex w-full flex-col px-4 py-2\">\n <div class=\"text-xl font-bold\" [innerHTML]=\"title\"></div>\n <div class=\"mb-2 text-base font-semibold\" [innerHTML]=\"subTitle\"></div>\n <div class=\"flex w-fit grow-0\"><ng-content select=\"[body]\" /></div>\n </div>\n }\n @if (withActions) {\n <div class=\"flex flex-row justify-end gap-2 px-4 py-2\">\n <ct-button text=\"test\" />\n <ct-button text=\"test\" type=\"secondary\" />\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: AvatarComponent, selector: "ct-avatar", inputs: ["picture", "title"] }, { kind: "component", type: ButtonComponent, selector: "ct-button", inputs: ["text", "icon", "iconPosition", "fullSize", "size", "type", "variant"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  427. }
  428. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: CardComponent, decorators: [{
  429. type: Component,
  430. args: [{ selector: 'ct-card', standalone: true, imports: [AvatarComponent, ButtonComponent, SafeImagePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"flex w-full flex-col rounded-xl bg-surface text-on-surface dark:bg-surface-dark dark:text-on-surface-dark\">\n <div class=\"flex w-full flex-row items-stretch rounded-md\">\n <div class=\"flex w-full grow flex-row items-center gap-4 px-4 py-2\">\n <div class=\"items-center\">\n <ct-avatar [picture]=\"avatar\" [title]=\"title\" />\n </div>\n <div class=\"flex grow flex-col\">\n @if (header) {\n <span class=\"grow text-lg font-semibold\" [innerHTML]=\"header\"></span>\n }\n @if (subHeader) {\n <span class=\"grow text-sm\" [innerHTML]=\"subHeader\"></span>\n }\n </div>\n </div>\n <div class=\"flex flex-col justify-between rounded-r-xl\">\n @if (imageThumbnail) {\n <img class=\"flex max-w-24 rounded-tr-xl object-cover\" [src]=\"imageThumbnail\" [alt]=\"title\" />\n } @else {\n <ng-content select=\"[header-extra]\" />\n }\n </div>\n </div>\n @if (image) {\n <img class=\"size-full object-cover\" [src]=\"image\" [alt]=\"title\" />\n }\n @if (title || subTitle) {\n <div class=\"flex w-full flex-col px-4 py-2\">\n <div class=\"text-xl font-bold\" [innerHTML]=\"title\"></div>\n <div class=\"mb-2 text-base font-semibold\" [innerHTML]=\"subTitle\"></div>\n <div class=\"flex w-fit grow-0\"><ng-content select=\"[body]\" /></div>\n </div>\n }\n @if (withActions) {\n <div class=\"flex flex-row justify-end gap-2 px-4 py-2\">\n <ct-button text=\"test\" />\n <ct-button text=\"test\" type=\"secondary\" />\n </div>\n }\n</div>\n" }]
  431. }], propDecorators: { header: [{
  432. type: Input
  433. }], subHeader: [{
  434. type: Input
  435. }], title: [{
  436. type: Input
  437. }], subTitle: [{
  438. type: Input
  439. }], avatar: [{
  440. type: Input
  441. }], image: [{
  442. type: Input
  443. }], imageThumbnail: [{
  444. type: Input
  445. }], withActions: [{
  446. type: Input
  447. }] } });
  448. class DropdownDirective {
  449. constructor(
  450. //private element: ElementRef,
  451. renderer) {
  452. this.renderer = renderer;
  453. this.targetId = '';
  454. this.isVisible = false;
  455. }
  456. onBlur() {
  457. this.close(document.getElementById(this.targetId));
  458. }
  459. onClick() {
  460. this.toggle(document.getElementById(this.targetId));
  461. }
  462. toggle(element) {
  463. this.isVisible = !this.isVisible;
  464. this.renderer.addClass(element, this.isVisible ? 'block' : 'hidden');
  465. this.renderer.removeClass(element, this.isVisible ? 'hidden' : 'block');
  466. }
  467. close(element) {
  468. this.isVisible = false;
  469. this.renderer.addClass(element, 'hidden');
  470. this.renderer.removeClass(element, 'block');
  471. }
  472. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: DropdownDirective, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
  473. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.2", type: DropdownDirective, isStandalone: true, selector: "[ctDropdown]", inputs: { targetId: "targetId" }, host: { listeners: { "blur": "onBlur()", "focusout": "onBlur()", "click": "onClick()" } }, ngImport: i0 }); }
  474. }
  475. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: DropdownDirective, decorators: [{
  476. type: Directive,
  477. args: [{
  478. selector: '[ctDropdown]',
  479. standalone: true,
  480. }]
  481. }], ctorParameters: () => [{ type: i0.Renderer2 }], propDecorators: { targetId: [{
  482. type: Input,
  483. args: [{ required: true }]
  484. }], onBlur: [{
  485. type: HostListener,
  486. args: ['blur']
  487. }, {
  488. type: HostListener,
  489. args: ['focusout']
  490. }], onClick: [{
  491. type: HostListener,
  492. args: ['click']
  493. }] } });
  494. class MenuComponent {
  495. constructor() {
  496. this.items = [];
  497. this.fullSize = true;
  498. this.direction = 'vertical';
  499. this.iconAlone = false;
  500. this.iconDirection = 'horizontal';
  501. }
  502. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: MenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  503. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: MenuComponent, isStandalone: true, selector: "ct-menu", inputs: { items: "items", fullSize: "fullSize", direction: "direction", iconAlone: "iconAlone", iconDirection: "iconDirection" }, ngImport: i0, template: "<div\n class=\"z-10 flex flex-col rounded-md bg-surface p-2 text-on-surface shadow-lg dark:bg-surface-dark\"\n [class.w-fit]=\"!fullSize\"\n [class.w-full]=\"fullSize\">\n <ul\n class=\"flex justify-around\"\n [class.flex-col]=\"direction === 'vertical'\"\n [class.flex-row]=\"direction === 'horizontal'\">\n @for (item of items; track item) {\n <li>\n <!-- @if (item.subMenu && item.subMenu.length > 0) {\n <button ctDropdown [targetId]=\"'test'\">{{ item.text }}</button>\n <ct-menu class=\"absolute hidden\" [id]=\"'test'\" [items]=\"item.subMenu\" />\n } @else { -->\n <ct-menu-item\n [text]=\"item.text\"\n [link]=\"item.link\"\n [type]=\"item.type\"\n [icon]=\"item.icon!\"\n [iconAlone]=\"iconAlone\"\n [iconDirection]=\"iconDirection\" />\n <!-- } -->\n </li>\n }\n </ul>\n</div>\n", dependencies: [{ kind: "component", type: MenuItemComponent, selector: "ct-menu-item", inputs: ["text", "link", "type", "icon", "iconSize", "iconAlone", "iconDirection"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  504. }
  505. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: MenuComponent, decorators: [{
  506. type: Component,
  507. args: [{ selector: 'ct-menu', standalone: true, imports: [MenuItemComponent, DropdownDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"z-10 flex flex-col rounded-md bg-surface p-2 text-on-surface shadow-lg dark:bg-surface-dark\"\n [class.w-fit]=\"!fullSize\"\n [class.w-full]=\"fullSize\">\n <ul\n class=\"flex justify-around\"\n [class.flex-col]=\"direction === 'vertical'\"\n [class.flex-row]=\"direction === 'horizontal'\">\n @for (item of items; track item) {\n <li>\n <!-- @if (item.subMenu && item.subMenu.length > 0) {\n <button ctDropdown [targetId]=\"'test'\">{{ item.text }}</button>\n <ct-menu class=\"absolute hidden\" [id]=\"'test'\" [items]=\"item.subMenu\" />\n } @else { -->\n <ct-menu-item\n [text]=\"item.text\"\n [link]=\"item.link\"\n [type]=\"item.type\"\n [icon]=\"item.icon!\"\n [iconAlone]=\"iconAlone\"\n [iconDirection]=\"iconDirection\" />\n <!-- } -->\n </li>\n }\n </ul>\n</div>\n" }]
  508. }], propDecorators: { items: [{
  509. type: Input,
  510. args: [{ required: true }]
  511. }], fullSize: [{
  512. type: Input
  513. }], direction: [{
  514. type: Input
  515. }], iconAlone: [{
  516. type: Input
  517. }], iconDirection: [{
  518. type: Input
  519. }] } });
  520. class OptionComponent {
  521. constructor() {
  522. this.label = '';
  523. this.icon = '';
  524. }
  525. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: OptionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  526. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: OptionComponent, isStandalone: true, selector: "ct-option", inputs: { label: "label", icon: "icon" }, ngImport: i0, template: "<div\n class=\"flex cursor-pointer flex-row rounded-md px-4 py-2 text-sm hover:bg-surface/35 dark:hover:bg-surface-dark/35\">\n @if (icon) {\n <ct-icon [icon]=\"icon\" />\n }\n {{ label }}\n</div>\n", dependencies: [{ kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  527. }
  528. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: OptionComponent, decorators: [{
  529. type: Component,
  530. args: [{ selector: 'ct-option', standalone: true, imports: [IconComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"flex cursor-pointer flex-row rounded-md px-4 py-2 text-sm hover:bg-surface/35 dark:hover:bg-surface-dark/35\">\n @if (icon) {\n <ct-icon [icon]=\"icon\" />\n }\n {{ label }}\n</div>\n" }]
  531. }], propDecorators: { label: [{
  532. type: Input,
  533. args: [{ required: true }]
  534. }], icon: [{
  535. type: Input
  536. }] } });
  537. class LabelComponent {
  538. constructor() {
  539. this.text = '';
  540. this.type = TypeEnum.PRIMARY;
  541. this.formControlName = '';
  542. this.hasError = false;
  543. }
  544. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: LabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  545. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.2", type: LabelComponent, isStandalone: true, selector: "ct-form-label", inputs: { text: "text", type: "type", formControlName: "formControlName", hasError: "hasError" }, ngImport: i0, template: "<label\n class=\"mb-1 flex font-medium\"\n [class.text-on-surface]=\"type === 'primary' && !hasError\"\n [class.text-secondary]=\"type === 'secondary'\"\n [class.text-warning-variation]=\"type === 'warning'\"\n [class.text-error-variation]=\"type === 'error' || hasError\"\n [class.text-success-variation]=\"type === 'success'\"\n [for]=\"formControlName\"\n >{{ text }}</label\n>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  546. }
  547. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: LabelComponent, decorators: [{
  548. type: Component,
  549. args: [{ selector: 'ct-form-label', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<label\n class=\"mb-1 flex font-medium\"\n [class.text-on-surface]=\"type === 'primary' && !hasError\"\n [class.text-secondary]=\"type === 'secondary'\"\n [class.text-warning-variation]=\"type === 'warning'\"\n [class.text-error-variation]=\"type === 'error' || hasError\"\n [class.text-success-variation]=\"type === 'success'\"\n [for]=\"formControlName\"\n >{{ text }}</label\n>\n" }]
  550. }], propDecorators: { text: [{
  551. type: Input,
  552. args: [{ required: true }]
  553. }], type: [{
  554. type: Input
  555. }], formControlName: [{
  556. type: Input
  557. }], hasError: [{
  558. type: Input
  559. }] } });
  560. /**
  561. * Creates a value accessor provider for a form component.
  562. * @param component - The component that implements the NG_VALUE_ACCESSOR interface.
  563. * @returns An ExistingProvider object for the value accessor.
  564. */
  565. const provideValueAccessor = (component) => ({
  566. provide: NG_VALUE_ACCESSOR,
  567. useExisting: forwardRef(() => component),
  568. multi: true,
  569. });
  570. /**
  571. * Creates a control container provider using FormGroupDirective.
  572. * @returns An ExistingProvider object for the control container.
  573. */
  574. const provideControlContainer = () => ({
  575. provide: ControlContainer,
  576. useExisting: FormGroupDirective,
  577. });
  578. class FormGenericComponent {
  579. constructor(formGroupDirective) {
  580. this.formGroupDirective = formGroupDirective;
  581. this.onChange = () => { };
  582. this.onTouched = () => { };
  583. this.changeDetectorRef = inject(ChangeDetectorRef);
  584. }
  585. hasErrors(formControl) {
  586. return (formControl && !formControl.pristine && formControl.touched && !!formControl.errors);
  587. }
  588. get formControl() {
  589. return this.formGroupDirective.form.get(this.formControlName);
  590. }
  591. registerOnChange(fn) {
  592. this.onChange = fn;
  593. }
  594. registerOnTouched(fn) {
  595. this.onTouched = fn;
  596. }
  597. triggerChange(value) {
  598. this.onChange(value);
  599. }
  600. triggerTouched() {
  601. this.onTouched();
  602. }
  603. triggerChangeDetection() {
  604. this.changeDetectorRef.markForCheck();
  605. }
  606. }
  607. class FormErrorComponent {
  608. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: FormErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  609. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: FormErrorComponent, isStandalone: true, selector: "ct-form-error", inputs: { errors: "errors" }, ngImport: i0, template: "<div class=\"my-2 flex flex-col gap-1\">\n @for (error of errors | keyvalue; track error) {\n @if (error.key === 'required') {\n <ct-alert [text]=\"'Field is required'\" type=\"error\" [withIcon]=\"true\" variant=\"blank\" />\n } @else {\n <ct-alert [text]=\"error.key\" type=\"error\" [withIcon]=\"true\" variant=\"blank\" />\n }\n }\n</div>\n", dependencies: [{ kind: "component", type: AlertComponent, selector: "ct-alert", inputs: ["dismissable", "fullSize", "text", "type", "variant", "withIcon"], outputs: ["dismiss"] }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  610. }
  611. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: FormErrorComponent, decorators: [{
  612. type: Component,
  613. args: [{ selector: 'ct-form-error', standalone: true, imports: [AlertComponent, KeyValuePipe, JsonPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"my-2 flex flex-col gap-1\">\n @for (error of errors | keyvalue; track error) {\n @if (error.key === 'required') {\n <ct-alert [text]=\"'Field is required'\" type=\"error\" [withIcon]=\"true\" variant=\"blank\" />\n } @else {\n <ct-alert [text]=\"error.key\" type=\"error\" [withIcon]=\"true\" variant=\"blank\" />\n }\n }\n</div>\n" }]
  614. }], propDecorators: { errors: [{
  615. type: Input,
  616. args: [{ required: true }]
  617. }] } });
  618. class SelectComponent extends FormGenericComponent {
  619. constructor(formGroupDirective, destroyRef) {
  620. super(formGroupDirective);
  621. this.destroyRef = destroyRef;
  622. this.focusOut$ = new Subject();
  623. this.isOpen = false;
  624. this.option = '';
  625. this.option$ = signal('');
  626. this.placeholder = '';
  627. this.label = '';
  628. this.value = '';
  629. this.type = TypeEnum.PRIMARY;
  630. this.fullSize = true;
  631. this.shouldShowError = true;
  632. this.key = '';
  633. this.options = [];
  634. this.selected = new EventEmitter();
  635. }
  636. ngOnInit() {
  637. this.selectOption(this.value, false);
  638. this.focusOut$.pipe(takeUntilDestroyed(this.destroyRef), debounceTime(200)).subscribe(() => {
  639. this.triggerChangeDetection();
  640. this.close();
  641. });
  642. }
  643. toggle() {
  644. this.isOpen = !this.isOpen;
  645. if (!this.isOpen) {
  646. this.triggerTouched();
  647. }
  648. }
  649. close() {
  650. this.isOpen = false;
  651. this.triggerTouched();
  652. }
  653. selectOption(key, propagate = true) {
  654. const selectedOption = this.options.find(option => option.key === key);
  655. this.option = key === null ? this.placeholder : selectedOption?.label;
  656. if (propagate) {
  657. this.selected.emit(key);
  658. this.triggerChange(selectedOption?.key ?? null);
  659. this.close();
  660. }
  661. }
  662. writeValue(value) {
  663. this.triggerChangeDetection();
  664. this.selectOption(value, false);
  665. }
  666. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: SelectComponent, deps: [{ token: i1$1.FormGroupDirective }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component }); }
  667. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: SelectComponent, isStandalone: true, selector: "ct-select", inputs: { formControlName: "formControlName", placeholder: "placeholder", label: "label", value: "value", type: "type", fullSize: "fullSize", shouldShowError: "shouldShowError", key: "key", options: "options" }, outputs: { selected: "selected" }, providers: [provideValueAccessor(forwardRef(() => SelectComponent))], viewQueries: [{ propertyName: "trigger", first: true, predicate: ["triggerElement"], descendants: true }, { propertyName: "panel", first: true, predicate: ["optionsPanel"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<ct-form-label [text]=\"label\" [hasError]=\"hasErrors(formControl)\" />\n<div\n class=\"flex flex-row items-center justify-between gap-1.5 rounded-md border bg-surface-variant px-4 py-2 text-sm text-on-surface-variant dark:bg-surface-variant-dark dark:text-on-surface-variant-dark\"\n [class.border-error]=\"hasErrors(formControl)\"\n [class.border-neutral-300]=\"!hasErrors(formControl)\"\n [class.text-neutral-400]=\"option === placeholder\"\n [class.text-on-surface-variant]=\"option !== placeholder\"\n #triggerElement\n tabindex=\"0\"\n (focusout)=\"focusOut$.next($event)\"\n (click)=\"toggle()\">\n {{ option }}\n <ct-icon class=\"flex\" [size]=\"'sm'\" [icon]=\"isOpen ? 'chevron-up' : 'chevron-down'\" />\n</div>\n@if (isOpen) {\n <div class=\"relative\">\n <div\n #optionsPanel\n [class.w-full]=\"fullSize\"\n [class.w-fit]=\"!fullSize\"\n class=\"absolute top-1 z-10 flex flex-col rounded-md border border-neutral-400 bg-surface-variant text-on-surface-variant dark:bg-surface-variant-dark dark:text-on-surface-variant-dark\">\n <ct-option (click)=\"selectOption(null)\" [label]=\"placeholder\" />\n @for (option of options; track option) {\n <ct-option (click)=\"selectOption(option.key)\" [label]=\"option.label\" [icon]=\"option.icon!\" />\n }\n </div>\n </div>\n}\n@if (hasErrors(formControl)) {\n <ct-form-error [errors]=\"formControl.errors ?? {}\" />\n}\n", dependencies: [{ kind: "component", type: OptionComponent, selector: "ct-option", inputs: ["label", "icon"] }, { kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }, { kind: "component", type: LabelComponent, selector: "ct-form-label", inputs: ["text", "type", "formControlName", "hasError"] }, { kind: "component", type: FormErrorComponent, selector: "ct-form-error", inputs: ["errors"] }], viewProviders: [provideControlContainer()], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  668. }
  669. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: SelectComponent, decorators: [{
  670. type: Component,
  671. args: [{ selector: 'ct-select', standalone: true, imports: [OptionComponent, ButtonComponent, IconComponent, LabelComponent, AlertComponent, FormErrorComponent], providers: [provideValueAccessor(forwardRef(() => SelectComponent))], viewProviders: [provideControlContainer()], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ct-form-label [text]=\"label\" [hasError]=\"hasErrors(formControl)\" />\n<div\n class=\"flex flex-row items-center justify-between gap-1.5 rounded-md border bg-surface-variant px-4 py-2 text-sm text-on-surface-variant dark:bg-surface-variant-dark dark:text-on-surface-variant-dark\"\n [class.border-error]=\"hasErrors(formControl)\"\n [class.border-neutral-300]=\"!hasErrors(formControl)\"\n [class.text-neutral-400]=\"option === placeholder\"\n [class.text-on-surface-variant]=\"option !== placeholder\"\n #triggerElement\n tabindex=\"0\"\n (focusout)=\"focusOut$.next($event)\"\n (click)=\"toggle()\">\n {{ option }}\n <ct-icon class=\"flex\" [size]=\"'sm'\" [icon]=\"isOpen ? 'chevron-up' : 'chevron-down'\" />\n</div>\n@if (isOpen) {\n <div class=\"relative\">\n <div\n #optionsPanel\n [class.w-full]=\"fullSize\"\n [class.w-fit]=\"!fullSize\"\n class=\"absolute top-1 z-10 flex flex-col rounded-md border border-neutral-400 bg-surface-variant text-on-surface-variant dark:bg-surface-variant-dark dark:text-on-surface-variant-dark\">\n <ct-option (click)=\"selectOption(null)\" [label]=\"placeholder\" />\n @for (option of options; track option) {\n <ct-option (click)=\"selectOption(option.key)\" [label]=\"option.label\" [icon]=\"option.icon!\" />\n }\n </div>\n </div>\n}\n@if (hasErrors(formControl)) {\n <ct-form-error [errors]=\"formControl.errors ?? {}\" />\n}\n" }]
  672. }], ctorParameters: () => [{ type: i1$1.FormGroupDirective }, { type: i0.DestroyRef }], propDecorators: { formControlName: [{
  673. type: Input
  674. }], placeholder: [{
  675. type: Input
  676. }], label: [{
  677. type: Input
  678. }], value: [{
  679. type: Input
  680. }], type: [{
  681. type: Input
  682. }], fullSize: [{
  683. type: Input
  684. }], shouldShowError: [{
  685. type: Input
  686. }], key: [{
  687. type: Input,
  688. args: [{ required: true }]
  689. }], options: [{
  690. type: Input,
  691. args: [{ required: true }]
  692. }], selected: [{
  693. type: Output
  694. }], trigger: [{
  695. type: ViewChild,
  696. args: ['triggerElement']
  697. }], panel: [{
  698. type: ViewChild,
  699. args: ['optionsPanel']
  700. }] } });
  701. class InputComponent extends FormGenericComponent {
  702. onFocusOut() {
  703. this.triggerTouched();
  704. }
  705. constructor(formGroupDirective) {
  706. super(formGroupDirective);
  707. this.key = '';
  708. this.label = '';
  709. this.placeholder = '';
  710. this.value = '';
  711. this.type = TypeEnum.PRIMARY;
  712. this.fullSize = true;
  713. this.typed = new EventEmitter();
  714. }
  715. input(event) {
  716. this.setValue(event.target.value);
  717. }
  718. setValue(value, propagate = true) {
  719. this.value = value;
  720. if (propagate) {
  721. this.triggerChange(value);
  722. this.typed.emit(value);
  723. }
  724. }
  725. writeValue(value) {
  726. this.triggerChangeDetection();
  727. this.setValue(value, false);
  728. }
  729. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: InputComponent, deps: [{ token: i1$1.FormGroupDirective }], target: i0.ɵɵFactoryTarget.Component }); }
  730. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: InputComponent, isStandalone: true, selector: "ct-input", inputs: { formControlName: "formControlName", key: "key", label: "label", placeholder: "placeholder", value: "value", type: "type", fullSize: "fullSize" }, outputs: { typed: "typed" }, host: { listeners: { "focusout": "onFocusOut()" } }, providers: [provideValueAccessor(forwardRef(() => InputComponent))], usesInheritance: true, ngImport: i0, template: "<ct-form-label [text]=\"label\" [hasError]=\"hasErrors(formControl)\" />\n<input\n tabindex=\"0\"\n class=\"rounded-md border bg-surface-variant px-4 py-2 text-sm text-on-surface-variant outline-none dark:bg-surface-variant-dark dark:text-on-surface-variant-dark\"\n [class.w-fit]=\"!fullSize\"\n [class.w-full]=\"fullSize\"\n [class.border-neutral-400]=\"formControl && (formControl.pristine || formControl.valid)\"\n [class.border-error]=\"hasErrors(formControl)\"\n [value]=\"value\"\n [placeholder]=\"placeholder\"\n (input)=\"input($event)\" />\n@if (hasErrors(formControl)) {\n <ct-form-error [errors]=\"formControl.errors ?? {}\" />\n}\n", dependencies: [{ kind: "component", type: LabelComponent, selector: "ct-form-label", inputs: ["text", "type", "formControlName", "hasError"] }, { kind: "component", type: FormErrorComponent, selector: "ct-form-error", inputs: ["errors"] }], viewProviders: [provideControlContainer()], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  731. }
  732. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: InputComponent, decorators: [{
  733. type: Component,
  734. args: [{ selector: 'ct-input', standalone: true, imports: [NgClass, LabelComponent, FormErrorComponent], providers: [provideValueAccessor(forwardRef(() => InputComponent))], viewProviders: [provideControlContainer()], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ct-form-label [text]=\"label\" [hasError]=\"hasErrors(formControl)\" />\n<input\n tabindex=\"0\"\n class=\"rounded-md border bg-surface-variant px-4 py-2 text-sm text-on-surface-variant outline-none dark:bg-surface-variant-dark dark:text-on-surface-variant-dark\"\n [class.w-fit]=\"!fullSize\"\n [class.w-full]=\"fullSize\"\n [class.border-neutral-400]=\"formControl && (formControl.pristine || formControl.valid)\"\n [class.border-error]=\"hasErrors(formControl)\"\n [value]=\"value\"\n [placeholder]=\"placeholder\"\n (input)=\"input($event)\" />\n@if (hasErrors(formControl)) {\n <ct-form-error [errors]=\"formControl.errors ?? {}\" />\n}\n" }]
  735. }], ctorParameters: () => [{ type: i1$1.FormGroupDirective }], propDecorators: { formControlName: [{
  736. type: Input,
  737. args: [{ required: true }]
  738. }], key: [{
  739. type: Input,
  740. args: [{ required: true }]
  741. }], label: [{
  742. type: Input
  743. }], placeholder: [{
  744. type: Input
  745. }], value: [{
  746. type: Input
  747. }], type: [{
  748. type: Input
  749. }], fullSize: [{
  750. type: Input
  751. }], typed: [{
  752. type: Output
  753. }], onFocusOut: [{
  754. type: HostListener,
  755. args: ['focusout']
  756. }] } });
  757. class FormBase {
  758. constructor(options = {}) {
  759. this.value = options.value;
  760. this.key = options.key || undefined;
  761. this.label = options.label || '';
  762. this.placeholder = options.placeholder || '';
  763. this.required = !!options.required;
  764. this.controlType = options.controlType || '';
  765. this.options = options.options || [];
  766. }
  767. }
  768. class SelectFormBase extends FormBase {
  769. constructor() {
  770. super(...arguments);
  771. this.controlType = 'select';
  772. }
  773. }
  774. class InputFormBase extends FormBase {
  775. constructor() {
  776. super(...arguments);
  777. this.controlType = 'input';
  778. }
  779. }
  780. /*
  781. * Public API Surface of circletone
  782. */
  783. // Atoms
  784. /**
  785. * Generated bundle index. Do not edit.
  786. */
  787. export { AccordionComponent, AccordionItemComponent, AccordionRegistryService, AlertComponent, AvatarComponent, ButtonComponent, CardComponent, DropdownDirective, FormBase, HeaderComponent, IconComponent, InputComponent, InputFormBase, MenuComponent, MenuItemComponent, SafeImagePipe, SelectComponent, SelectFormBase, SizeEnum, TypeEnum, VariantEnum };
  788. //# sourceMappingURL=circletone.mjs.map