tailjng 0.1.5 → 0.1.7

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.
Files changed (176) hide show
  1. package/README.md +12 -4
  2. package/cli/execute/init-app.js +5 -3
  3. package/cli/execute/sync-app.js +14 -2
  4. package/cli/settings/colors-config-utils.js +43 -8
  5. package/cli/settings/icons-config-utils.js +62 -0
  6. package/cli/settings/path-utils.js +32 -2
  7. package/cli/settings/project-utils.js +7 -1
  8. package/cli/templates/app.generator.js +2 -2
  9. package/fesm2022/tailjng.mjs +247 -80
  10. package/fesm2022/tailjng.mjs.map +1 -1
  11. package/lib/services/static/theme.service.d.ts +39 -1
  12. package/lib/utils/theme/theme-variables.util.d.ts +31 -0
  13. package/package.json +1 -1
  14. package/public-api.d.ts +2 -1
  15. package/registry/components.json +41 -18
  16. package/src/colors.safelist.css +2 -2
  17. package/src/lib/components/.config/README.md +11 -0
  18. package/src/lib/components/.config/colors/README.md +38 -0
  19. package/src/lib/components/{colors-config → .config/colors}/colors.config.ts +5 -5
  20. package/src/lib/components/{colors-config → .config/colors}/colors.safelist.css +2 -2
  21. package/src/lib/components/.config/icons/README.md +26 -0
  22. package/src/lib/components/.config/icons/icons.lucide.ts +134 -0
  23. package/src/lib/components/.config/input/README.md +24 -0
  24. package/src/lib/components/.config/input/input.classes.ts +119 -0
  25. package/src/lib/components/alert/alert-dialog/dialog-alert.component.css +244 -2
  26. package/src/lib/components/alert/alert-dialog/dialog-alert.component.html +25 -38
  27. package/src/lib/components/alert/alert-dialog/dialog-alert.component.ts +66 -56
  28. package/src/lib/components/alert/alert-dialog/dialog-alert.types.ts +19 -0
  29. package/src/lib/components/alert/alert-toast/toast-alert.component.css +630 -12
  30. package/src/lib/components/alert/alert-toast/toast-alert.component.html +103 -102
  31. package/src/lib/components/alert/alert-toast/toast-alert.component.ts +485 -128
  32. package/src/lib/components/alert/alert-toast/toast-alert.types.ts +25 -0
  33. package/src/lib/components/badge/badge.component.html +34 -21
  34. package/src/lib/components/badge/badge.component.ts +140 -31
  35. package/src/lib/components/button/button.component.html +16 -10
  36. package/src/lib/components/button/button.component.ts +162 -22
  37. package/src/lib/components/card/card-complete/complete-card.component.html +2 -2
  38. package/src/lib/components/card/card-complete/complete-card.component.ts +26 -16
  39. package/src/lib/components/card/card-crud-complete/complete-crud-card.component.html +2 -2
  40. package/src/lib/components/card/card-crud-complete/complete-crud-card.component.ts +26 -16
  41. package/src/lib/components/checkbox/checkbox-input/input-checkbox.component.css +97 -0
  42. package/src/lib/components/checkbox/checkbox-input/input-checkbox.component.html +54 -46
  43. package/src/lib/components/checkbox/checkbox-input/input-checkbox.component.ts +135 -64
  44. package/src/lib/components/checkbox/checkbox-input/input-checkbox.types.ts +3 -0
  45. package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.component.css +112 -0
  46. package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.component.html +28 -25
  47. package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.component.ts +67 -15
  48. package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.types.ts +1 -0
  49. package/src/lib/components/coach-mark/coach-mark.component.html +4 -22
  50. package/src/lib/components/coach-mark/coach-mark.component.scss +1 -1
  51. package/src/lib/components/coach-mark/coach-mark.component.ts +51 -18
  52. package/src/lib/components/coach-mark/coach-mark.directive.ts +133 -78
  53. package/src/lib/components/coach-mark/coach-mark.types.ts +12 -0
  54. package/src/lib/components/dialog/dialog.component.css +103 -1
  55. package/src/lib/components/dialog/dialog.component.html +46 -66
  56. package/src/lib/components/dialog/dialog.component.ts +136 -110
  57. package/src/lib/components/dialog/dialog.types.ts +19 -0
  58. package/src/lib/components/filter/filter-complete/complete-filter.component.html +16 -19
  59. package/src/lib/components/filter/filter-complete/complete-filter.component.scss +35 -0
  60. package/src/lib/components/filter/filter-complete/complete-filter.component.ts +58 -34
  61. package/src/lib/components/filter/filter-complete/complete-filter.types.ts +7 -0
  62. package/src/lib/components/filter/filter-complete/complete-filter.util.ts +16 -0
  63. package/src/lib/components/form/form-container/container-form.component.css +4 -0
  64. package/src/lib/components/form/form-container/container-form.component.html +2 -2
  65. package/src/lib/components/form/form-container/container-form.component.ts +72 -16
  66. package/src/lib/components/form/form-container/container-form.types.ts +42 -0
  67. package/src/lib/components/form/form-container/form-col-span.directive.ts +25 -0
  68. package/src/lib/components/form/form-sidebar/sidebar-form.component.css +276 -0
  69. package/src/lib/components/form/form-sidebar/sidebar-form.component.html +117 -125
  70. package/src/lib/components/form/form-sidebar/sidebar-form.component.ts +109 -34
  71. package/src/lib/components/form/form-sidebar/sidebar-form.types.ts +3 -0
  72. package/src/lib/components/{toggle-radio/toggle-radio.component.css → form/form-validation/validation-form.component.css} +0 -1
  73. package/src/lib/components/form/form-validation/validation-form.component.html +10 -6
  74. package/src/lib/components/form/form-validation/validation-form.component.ts +99 -12
  75. package/src/lib/components/form/form-validation/validation-form.types.ts +33 -0
  76. package/src/lib/components/icon/icon.component.html +8 -5
  77. package/src/lib/components/icon/icon.component.ts +111 -9
  78. package/src/lib/components/input/input/input.component.html +19 -16
  79. package/src/lib/components/input/input/input.component.ts +130 -53
  80. package/src/lib/components/input/input/input.types.ts +8 -0
  81. package/src/lib/components/input/input-file/file-input.component.html +65 -56
  82. package/src/lib/components/input/input-file/file-input.component.ts +276 -173
  83. package/src/lib/components/input/input-file/file-input.types.ts +2 -0
  84. package/src/lib/components/input/input-range/range-input.component.css +67 -0
  85. package/src/lib/components/input/input-range/range-input.component.html +50 -58
  86. package/src/lib/components/input/input-range/range-input.component.ts +148 -60
  87. package/src/lib/components/input/input-range/range-input.types.ts +7 -0
  88. package/src/lib/components/input/input-textarea/textarea-input.component.html +16 -7
  89. package/src/lib/components/input/input-textarea/textarea-input.component.ts +140 -50
  90. package/src/lib/components/input/input-textarea/textarea-input.types.ts +2 -0
  91. package/src/lib/components/label/label.component.html +17 -16
  92. package/src/lib/components/label/label.component.ts +70 -16
  93. package/src/lib/components/label/label.types.ts +2 -0
  94. package/src/lib/components/menu/menu-options-table/menu-options-defaults.ts +34 -0
  95. package/src/lib/components/menu/menu-options-table/options-table-menu.component.html +34 -20
  96. package/src/lib/components/menu/menu-options-table/options-table-menu.component.ts +211 -58
  97. package/src/lib/components/menu/menu-options-table/options-table-menu.types.ts +38 -0
  98. package/src/lib/components/menu/options-coach-menu/options-coach-menu.component.html +49 -52
  99. package/src/lib/components/menu/options-coach-menu/options-coach-menu.component.ts +112 -24
  100. package/src/lib/components/menu/options-coach-menu/options-coach-menu.types.ts +9 -0
  101. package/src/lib/components/mode-toggle/mode-toggle.component.html +11 -16
  102. package/src/lib/components/mode-toggle/mode-toggle.component.ts +69 -33
  103. package/src/lib/components/paginator/paginator-complete/complete-paginator.component.html +4 -4
  104. package/src/lib/components/paginator/paginator-complete/complete-paginator.component.ts +31 -7
  105. package/src/lib/components/paginator/paginator-complete/complete-paginator.types.ts +12 -0
  106. package/src/lib/components/paginator/paginator-complete/complete-paginator.util.ts +36 -0
  107. package/src/lib/components/progress-bar/progress-bar.component.css +11 -0
  108. package/src/lib/components/progress-bar/progress-bar.component.html +41 -40
  109. package/src/lib/components/progress-bar/progress-bar.component.ts +95 -11
  110. package/src/lib/components/progress-bar/progress-bar.types.ts +2 -0
  111. package/src/lib/components/select/select-dropdown/dropdown-select.component.css +6 -0
  112. package/src/lib/components/select/select-dropdown/dropdown-select.component.html +54 -44
  113. package/src/lib/components/select/select-dropdown/dropdown-select.component.ts +450 -509
  114. package/src/lib/components/select/select-dropdown/dropdown-select.types.ts +43 -0
  115. package/src/lib/components/select/select-dropdown/dropdown-select.util.ts +179 -0
  116. package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.css +6 -0
  117. package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.html +131 -42
  118. package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.ts +491 -475
  119. package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.types.ts +22 -0
  120. package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.util.ts +20 -0
  121. package/src/lib/components/select/select-multi-table/multi-table-select.component.css +10 -0
  122. package/src/lib/components/select/select-multi-table/multi-table-select.component.html +76 -60
  123. package/src/lib/components/select/select-multi-table/multi-table-select.component.ts +250 -313
  124. package/src/lib/components/select/select-multi-table/multi-table-select.types.ts +10 -0
  125. package/src/lib/components/select/select-multi-table/multi-table-select.util.ts +5 -0
  126. package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.css +212 -0
  127. package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.html +62 -53
  128. package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.ts +84 -27
  129. package/src/lib/components/sidebar/sidebar-static/static-sidebar.types.ts +2 -0
  130. package/src/lib/components/table/table-complete/complete-table.component.html +15 -17
  131. package/src/lib/components/table/table-complete/complete-table.component.ts +190 -338
  132. package/src/lib/components/table/table-complete/complete-table.types.ts +28 -0
  133. package/src/lib/components/table/table-complete/complete-table.util.ts +236 -0
  134. package/src/lib/components/table/table-complete/index.ts +2 -0
  135. package/src/lib/components/table/table-crud-complete/complete-crud-table.animations.ts +34 -0
  136. package/src/lib/components/table/table-crud-complete/complete-crud-table.component.html +73 -128
  137. package/src/lib/components/table/table-crud-complete/complete-crud-table.component.ts +542 -829
  138. package/src/lib/components/table/table-crud-complete/complete-crud-table.types.ts +57 -0
  139. package/src/lib/components/table/table-crud-complete/complete-crud-table.util.ts +723 -0
  140. package/src/lib/components/table/table-crud-complete/index.ts +3 -0
  141. package/src/lib/components/theme-generator/theme-generator.component.css +21 -0
  142. package/src/lib/components/theme-generator/theme-generator.component.html +146 -116
  143. package/src/lib/components/theme-generator/theme-generator.component.ts +44 -24
  144. package/src/lib/components/toggle-radio/shared/toggle-options.types.ts +8 -0
  145. package/src/lib/components/toggle-radio/shared/toggle-options.util.ts +44 -0
  146. package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.component.css +135 -0
  147. package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.component.html +52 -0
  148. package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.component.ts +198 -0
  149. package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.types.ts +1 -0
  150. package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.component.css +108 -0
  151. package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.component.html +37 -0
  152. package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.component.ts +193 -0
  153. package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.types.ts +1 -0
  154. package/src/lib/components/tooltip/tooltip.directive.ts +12 -9
  155. package/src/lib/components/tooltip/tooltip.service.ts +331 -133
  156. package/src/lib/components/tooltip/tooltip.types.ts +9 -0
  157. package/src/lib/components/viewer/viewer-image/image-viewer.component.css +90 -4
  158. package/src/lib/components/viewer/viewer-image/image-viewer.component.html +52 -103
  159. package/src/lib/components/viewer/viewer-image/image-viewer.component.ts +182 -177
  160. package/src/lib/components/viewer/viewer-image/image-viewer.types.ts +3 -0
  161. package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.css +177 -0
  162. package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.html +74 -24
  163. package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.ts +168 -15
  164. package/src/lib/components/viewer/viewer-pdf/pdf-viewer.types.ts +1 -0
  165. package/src/styles.css +2 -2
  166. package/lib/services/static/icons.service.d.ts +0 -65
  167. package/src/lib/components/colors-config/README.md +0 -38
  168. package/src/lib/components/form/form-sidebar/sidebar-form.component.scss +0 -0
  169. package/src/lib/components/form/form-validation/validation-form.component.scss +0 -0
  170. package/src/lib/components/menu/menu-options-table/options-table-menu.component.scss +0 -0
  171. package/src/lib/components/menu/options-coach-menu/options-coach-menu.component.scss +0 -12
  172. package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.scss +0 -0
  173. package/src/lib/components/toggle-radio/toggle-radio.component.html +0 -51
  174. package/src/lib/components/toggle-radio/toggle-radio.component.ts +0 -222
  175. package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.scss +0 -0
  176. package/tailjng-0.1.5.tgz +0 -0
@@ -6,7 +6,6 @@ import { es } from 'date-fns/locale';
6
6
  import { map, firstValueFrom, isObservable, forkJoin } from 'rxjs';
7
7
  import * as i1 from '@angular/common/http';
8
8
  import { HttpParams } from '@angular/common/http';
9
- import { Link2Off, Link, Clipboard, CircleAlert, Clock, Calendar, EllipsisVertical, Trash, Edit, Pencil, PencilLine, ListRestart, FileUp, Download, MonitorUp, FileSpreadsheet, Cpu, Trash2, Eraser, ArrowDownWideNarrow, Filter, ArrowBigRight, ChevronsRight, ChevronRight, ChevronLeft, ChevronsLeft, ListFilter, Table, Loader2, Moon, Sun, Save, Copy, Search, SquareDashedMousePointer, ChevronsUpDown, ChevronDown, ChevronUp, Eye, Upload, ImageOff, Images, Image, Minimize2, Scan, RefreshCcw, RotateCcw, RotateCw, ZoomOut, ZoomIn, Check, X, CircleHelp, TriangleAlert, CircleX, CircleCheck, Info } from 'lucide-angular';
10
9
  import * as FileSaver from 'file-saver';
11
10
  import * as ExcelJS from 'exceljs';
12
11
 
@@ -1231,121 +1230,289 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
1231
1230
  }]
1232
1231
  }] });
1233
1232
 
1234
- class JIconsService {
1235
- icons = {
1236
- info: Info,
1237
- success: CircleCheck,
1238
- error: CircleX,
1239
- warning: TriangleAlert,
1240
- question: CircleHelp,
1241
- close: X,
1242
- check: Check,
1243
- zoomIn: ZoomIn,
1244
- zoomOut: ZoomOut,
1245
- rotateRight: RotateCw,
1246
- rotateLeft: RotateCcw,
1247
- reset: RefreshCcw,
1248
- fullscreen: Scan,
1249
- exitFullscreen: Minimize2,
1250
- img: Image,
1251
- imgs: Images,
1252
- imageOff: ImageOff,
1253
- upload: Upload,
1254
- view: Eye,
1255
- chevronUp: ChevronUp,
1256
- chevronDown: ChevronDown,
1257
- chevronsUpDown: ChevronsUpDown,
1258
- squareDashedMousePointer: SquareDashedMousePointer,
1259
- search: Search,
1260
- copy: Copy,
1261
- save: Save,
1262
- sun: Sun,
1263
- moon: Moon,
1264
- loading: Loader2,
1265
- table: Table,
1266
- listFilter: ListFilter,
1267
- firstPage: ChevronsLeft,
1268
- prevPage: ChevronLeft,
1269
- nextPage: ChevronRight,
1270
- lastPage: ChevronsRight,
1271
- arrowBigRight: ArrowBigRight,
1272
- filter: Filter,
1273
- filterList: ArrowDownWideNarrow,
1274
- eraser: Eraser,
1275
- transh: Trash2,
1276
- default: Cpu,
1277
- fileSpreadsheet: FileSpreadsheet,
1278
- monitorUp: MonitorUp,
1279
- download: Download,
1280
- fileUp: FileUp,
1281
- listRestart: ListRestart,
1282
- editRowLine: PencilLine,
1283
- editRow: Pencil,
1284
- edit: Edit,
1285
- delete: Trash,
1286
- ellipsisVertical: EllipsisVertical,
1287
- calendar: Calendar,
1288
- clock: Clock,
1289
- circleAlert: CircleAlert,
1290
- clipboard: Clipboard,
1291
- link: Link,
1292
- linkOff: Link2Off,
1293
- };
1294
- constructor() { }
1295
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: JIconsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1296
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: JIconsService, providedIn: 'root' });
1233
+ /** All keys emitted by the theme generator into `@theme`. */
1234
+ const GENERATED_COLOR_KEYS = [
1235
+ 'background',
1236
+ 'foreground',
1237
+ 'card',
1238
+ 'cardForeground',
1239
+ 'popover',
1240
+ 'popoverForeground',
1241
+ 'primary',
1242
+ 'primaryForeground',
1243
+ 'secondary',
1244
+ 'secondaryForeground',
1245
+ 'muted',
1246
+ 'mutedForeground',
1247
+ 'accent',
1248
+ 'accentForeground',
1249
+ 'destructive',
1250
+ 'destructiveForeground',
1251
+ 'border',
1252
+ 'input',
1253
+ 'ring',
1254
+ 'darkBackground',
1255
+ 'darkForeground',
1256
+ 'darkCard',
1257
+ 'darkCardForeground',
1258
+ 'darkPopover',
1259
+ 'darkPopoverForeground',
1260
+ 'darkPrimary',
1261
+ 'darkPrimaryForeground',
1262
+ 'darkSecondary',
1263
+ 'darkSecondaryForeground',
1264
+ 'darkMuted',
1265
+ 'darkMutedForeground',
1266
+ 'darkAccent',
1267
+ 'darkAccentForeground',
1268
+ 'darkDestructive',
1269
+ 'darkDestructiveForeground',
1270
+ 'darkBorder',
1271
+ 'darkInput',
1272
+ 'darkRing',
1273
+ ];
1274
+ const RADIUS_VARS = ['--color-radius', '--color-dark-radius'];
1275
+ const CUSTOM_THEME_STYLE_ID = 'tailjng-custom-theme';
1276
+ /**
1277
+ * Converts a generated color key to a Tailwind `@theme` CSS variable name.
1278
+ * @param key Generated palette key.
1279
+ * @returns CSS custom property name.
1280
+ */
1281
+ function generatedColorToCssVarName(key) {
1282
+ return `--color-${key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)}`;
1283
+ }
1284
+ /**
1285
+ * Builds a `:root` CSS block for the generated palette.
1286
+ * @param colors Generated palette.
1287
+ * @returns CSS rules for `:root`.
1288
+ */
1289
+ function buildRootThemeCss(colors) {
1290
+ const lines = GENERATED_COLOR_KEYS.map((key) => ` ${generatedColorToCssVarName(key)}: ${colors[key]};`);
1291
+ lines.push(' --color-radius: 0.5rem;');
1292
+ lines.push(' --color-dark-radius: 0.5rem;');
1293
+ return `:root {\n${lines.join('\n')}\n}`;
1294
+ }
1295
+ /**
1296
+ * Applies generated palette values through a dedicated stylesheet (reliable with Tailwind v4).
1297
+ * @param colors Generated palette.
1298
+ */
1299
+ function applyGeneratedColorsToDocument(colors) {
1300
+ const css = buildRootThemeCss(colors);
1301
+ let styleEl = document.getElementById(CUSTOM_THEME_STYLE_ID);
1302
+ if (!styleEl) {
1303
+ styleEl = document.createElement('style');
1304
+ styleEl.id = CUSTOM_THEME_STYLE_ID;
1305
+ document.head.appendChild(styleEl);
1306
+ }
1307
+ styleEl.textContent = css;
1308
+ document.head.appendChild(styleEl);
1309
+ clearInlineThemeOverrides();
1310
+ }
1311
+ /**
1312
+ * Removes custom theme overrides from the document.
1313
+ */
1314
+ function clearGeneratedColorsFromDocument() {
1315
+ document.getElementById(CUSTOM_THEME_STYLE_ID)?.remove();
1316
+ clearInlineThemeOverrides();
1317
+ }
1318
+ /**
1319
+ * Builds the `@theme { ... }` block copied by the theme generator.
1320
+ * @param colors Generated palette.
1321
+ * @returns Tailwind v4 `@theme` snippet.
1322
+ */
1323
+ function buildThemeCode(colors) {
1324
+ const lines = [];
1325
+ let darkStarted = false;
1326
+ for (const key of GENERATED_COLOR_KEYS) {
1327
+ if (!darkStarted && key.startsWith('dark')) {
1328
+ lines.push('');
1329
+ darkStarted = true;
1330
+ }
1331
+ lines.push(` ${generatedColorToCssVarName(key)}: ${colors[key]};`);
1332
+ }
1333
+ lines.push(' --color-radius: 0.5rem;');
1334
+ lines.push(' --color-dark-radius: 0.5rem;');
1335
+ return `@theme {\n${lines.join('\n')}\n}`;
1336
+ }
1337
+ /** Clears legacy inline overrides on `documentElement`. */
1338
+ function clearInlineThemeOverrides(root = document.documentElement) {
1339
+ for (const key of GENERATED_COLOR_KEYS) {
1340
+ root.style.removeProperty(generatedColorToCssVarName(key));
1341
+ }
1342
+ for (const cssVar of RADIUS_VARS) {
1343
+ root.style.removeProperty(cssVar);
1344
+ }
1297
1345
  }
1298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: JIconsService, decorators: [{
1299
- type: Injectable,
1300
- args: [{
1301
- providedIn: 'root'
1302
- }]
1303
- }], ctorParameters: () => [] });
1304
1346
 
1347
+ const THEME_MODE_STORAGE_KEY = 'theme';
1348
+ const CUSTOM_COLORS_STORAGE_KEY = 'tailjng-custom-colors';
1305
1349
  class JThemeService {
1306
1350
  _theme = signal('light');
1307
1351
  themeSignal = this._theme.asReadonly();
1352
+ previewColorsActive = false;
1353
+ persistedColors = null;
1354
+ activeColors = null;
1308
1355
  constructor() {
1309
1356
  this.initializeTheme();
1357
+ this.loadPersistedCustomColors();
1310
1358
  this.listenToExternalChanges();
1311
1359
  }
1312
1360
  initializeTheme() {
1313
- const savedTheme = localStorage.getItem('theme');
1361
+ const savedTheme = localStorage.getItem(THEME_MODE_STORAGE_KEY);
1314
1362
  if (savedTheme) {
1315
1363
  this._theme.set(savedTheme);
1316
1364
  }
1317
1365
  else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
1318
1366
  this._theme.set('dark');
1319
1367
  }
1320
- this.applyTheme();
1368
+ this.applyThemeModeClass();
1321
1369
  }
1322
1370
  listenToExternalChanges() {
1323
1371
  window.addEventListener('storage', (event) => {
1324
- if (event.key === 'theme' && event.newValue) {
1372
+ if (event.key === THEME_MODE_STORAGE_KEY && event.newValue) {
1325
1373
  const newTheme = event.newValue;
1326
1374
  this._theme.set(newTheme);
1327
- this.applyTheme();
1375
+ this.applyThemeModeClass();
1376
+ this.syncActiveColorsToDocument();
1377
+ return;
1378
+ }
1379
+ if (event.key === CUSTOM_COLORS_STORAGE_KEY) {
1380
+ this.loadPersistedCustomColors();
1328
1381
  }
1329
1382
  });
1330
1383
  }
1331
- applyTheme() {
1384
+ applyThemeModeClass() {
1332
1385
  const current = this._theme();
1333
1386
  document.documentElement.classList.toggle('dark', current === 'dark');
1334
1387
  }
1388
+ /**
1389
+ * Re-applies the `dark` class on the next frame so Tailwind re-evaluates tokens.
1390
+ */
1391
+ refreshThemeModeClass() {
1392
+ const isDark = this._theme() === 'dark';
1393
+ const html = document.documentElement;
1394
+ if (!isDark) {
1395
+ html.classList.remove('dark');
1396
+ return;
1397
+ }
1398
+ html.classList.remove('dark');
1399
+ requestAnimationFrame(() => html.classList.add('dark'));
1400
+ }
1401
+ syncActiveColorsToDocument(refreshMode = false) {
1402
+ if (!this.activeColors) {
1403
+ return;
1404
+ }
1405
+ applyGeneratedColorsToDocument(this.activeColors);
1406
+ if (refreshMode) {
1407
+ this.refreshThemeModeClass();
1408
+ }
1409
+ }
1410
+ setActiveColors(colors, refreshMode = false) {
1411
+ this.activeColors = colors;
1412
+ applyGeneratedColorsToDocument(colors);
1413
+ if (refreshMode) {
1414
+ this.refreshThemeModeClass();
1415
+ }
1416
+ }
1417
+ /**
1418
+ * Loads a previously saved custom palette from localStorage and applies it.
1419
+ */
1420
+ loadPersistedCustomColors() {
1421
+ const raw = localStorage.getItem(CUSTOM_COLORS_STORAGE_KEY);
1422
+ if (!raw) {
1423
+ this.persistedColors = null;
1424
+ if (!this.previewColorsActive) {
1425
+ this.activeColors = null;
1426
+ }
1427
+ return;
1428
+ }
1429
+ try {
1430
+ const parsed = JSON.parse(raw);
1431
+ if (!this.isValidGeneratedColors(parsed)) {
1432
+ localStorage.removeItem(CUSTOM_COLORS_STORAGE_KEY);
1433
+ this.persistedColors = null;
1434
+ return;
1435
+ }
1436
+ this.persistedColors = parsed;
1437
+ this.setActiveColors(this.persistedColors);
1438
+ }
1439
+ catch {
1440
+ localStorage.removeItem(CUSTOM_COLORS_STORAGE_KEY);
1441
+ this.persistedColors = null;
1442
+ }
1443
+ }
1444
+ /**
1445
+ * Whether a custom palette is saved in localStorage.
1446
+ * @returns `true` when a persisted palette exists.
1447
+ */
1448
+ hasPersistedCustomColors() {
1449
+ return this.persistedColors !== null;
1450
+ }
1451
+ /**
1452
+ * Saves and applies a custom palette for the whole app (survives reloads).
1453
+ * @param colors Generated palette from the theme generator.
1454
+ */
1455
+ saveCustomColors(colors) {
1456
+ localStorage.setItem(CUSTOM_COLORS_STORAGE_KEY, JSON.stringify(colors));
1457
+ this.persistedColors = colors;
1458
+ this.previewColorsActive = false;
1459
+ this.setActiveColors(colors, true);
1460
+ }
1461
+ /**
1462
+ * Removes the saved custom palette and restores `@theme` defaults from CSS.
1463
+ */
1464
+ clearPersistedCustomColors() {
1465
+ localStorage.removeItem(CUSTOM_COLORS_STORAGE_KEY);
1466
+ this.persistedColors = null;
1467
+ this.previewColorsActive = false;
1468
+ this.activeColors = null;
1469
+ clearGeneratedColorsFromDocument();
1470
+ this.refreshThemeModeClass();
1471
+ }
1472
+ /**
1473
+ * Applies generated palette CSS variables to the document for live preview.
1474
+ * @param colors Palette from the theme generator.
1475
+ */
1476
+ applyPreviewColors(colors) {
1477
+ this.setActiveColors(colors);
1478
+ this.previewColorsActive = true;
1479
+ }
1480
+ /**
1481
+ * Ends live preview — reverts to the saved palette or CSS defaults.
1482
+ */
1483
+ clearPreviewColors() {
1484
+ if (!this.previewColorsActive) {
1485
+ return;
1486
+ }
1487
+ if (this.persistedColors) {
1488
+ this.setActiveColors(this.persistedColors);
1489
+ }
1490
+ else {
1491
+ this.activeColors = null;
1492
+ clearGeneratedColorsFromDocument();
1493
+ this.refreshThemeModeClass();
1494
+ }
1495
+ this.previewColorsActive = false;
1496
+ }
1335
1497
  toggleTheme() {
1336
1498
  const newTheme = this._theme() === 'light' ? 'dark' : 'light';
1337
- localStorage.setItem('theme', newTheme);
1499
+ localStorage.setItem(THEME_MODE_STORAGE_KEY, newTheme);
1338
1500
  this._theme.set(newTheme);
1339
- this.applyTheme();
1501
+ this.applyThemeModeClass();
1502
+ this.syncActiveColorsToDocument(true);
1340
1503
  }
1341
1504
  setTheme(theme) {
1342
- localStorage.setItem('theme', theme);
1505
+ localStorage.setItem(THEME_MODE_STORAGE_KEY, theme);
1343
1506
  this._theme.set(theme);
1344
- this.applyTheme();
1507
+ this.applyThemeModeClass();
1508
+ this.syncActiveColorsToDocument(true);
1345
1509
  }
1346
1510
  getThemeMode() {
1347
1511
  return this._theme();
1348
1512
  }
1513
+ isValidGeneratedColors(value) {
1514
+ return GENERATED_COLOR_KEYS.every((key) => typeof value[key] === 'string' && value[key] !== '');
1515
+ }
1349
1516
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: JThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1350
1517
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: JThemeService, providedIn: 'root' });
1351
1518
  }
@@ -2334,5 +2501,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
2334
2501
  * Generated bundle index. Do not edit.
2335
2502
  */
2336
2503
 
2337
- export { JAlertDialogService, JAlertToastService, JCOLORS_DEFAULT_VARIANTS, JCalendarService, JColorsService, JConverterCrudService, JDialogShared, JErrorHandlerHttpService, JExcelFilterService, JExcelService, JFileHttpService, JFormShared, JGenericCrudService, JIconsService, JParamsHttpService, JThemeService, JTransformService, JUploadFilterService, TAILJNG_COLORS_CONFIG, TAILJNG_CONFIG };
2504
+ export { CUSTOM_THEME_STYLE_ID, GENERATED_COLOR_KEYS, JAlertDialogService, JAlertToastService, JCOLORS_DEFAULT_VARIANTS, JCalendarService, JColorsService, JConverterCrudService, JDialogShared, JErrorHandlerHttpService, JExcelFilterService, JExcelService, JFileHttpService, JFormShared, JGenericCrudService, JParamsHttpService, JThemeService, JTransformService, JUploadFilterService, TAILJNG_COLORS_CONFIG, TAILJNG_CONFIG, applyGeneratedColorsToDocument, buildRootThemeCss, buildThemeCode, clearGeneratedColorsFromDocument, generatedColorToCssVarName };
2338
2505
  //# sourceMappingURL=tailjng.mjs.map