tailjng 0.1.6 → 0.1.8
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.
- package/README.md +27 -5
- package/cli/execute/init-app.js +5 -2
- package/cli/execute/sync-app.js +14 -2
- package/cli/settings/colors-config-utils.js +69 -11
- package/cli/settings/icons-config-utils.js +62 -0
- package/cli/settings/path-utils.js +32 -2
- package/cli/settings/project-utils.js +7 -1
- package/cli/templates/app.generator.js +8 -5
- package/fesm2022/tailjng.mjs +247 -80
- package/fesm2022/tailjng.mjs.map +1 -1
- package/lib/services/static/theme.service.d.ts +39 -1
- package/lib/utils/theme/theme-variables.util.d.ts +31 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -1
- package/registry/components.json +41 -18
- package/src/colors.safelist.css +2 -2
- package/src/lib/components/.config/README.md +11 -0
- package/src/lib/components/.config/colors/README.md +40 -0
- package/src/lib/components/{colors-config → .config/colors}/colors.config.ts +5 -5
- package/src/lib/components/{colors-config → .config/colors}/colors.safelist.css +2 -2
- package/src/lib/components/.config/icons/README.md +26 -0
- package/src/lib/components/.config/icons/icons.lucide.ts +134 -0
- package/src/lib/components/.config/input/README.md +24 -0
- package/src/lib/components/.config/input/input.classes.ts +119 -0
- package/src/lib/components/alert/alert-dialog/dialog-alert.component.css +177 -6
- package/src/lib/components/alert/alert-dialog/dialog-alert.component.html +24 -37
- package/src/lib/components/alert/alert-dialog/dialog-alert.component.ts +66 -56
- package/src/lib/components/alert/alert-dialog/dialog-alert.types.ts +19 -0
- package/src/lib/components/alert/alert-toast/toast-alert.component.css +494 -14
- package/src/lib/components/alert/alert-toast/toast-alert.component.html +106 -102
- package/src/lib/components/alert/alert-toast/toast-alert.component.ts +485 -128
- package/src/lib/components/alert/alert-toast/toast-alert.types.ts +25 -0
- package/src/lib/components/badge/badge.component.html +34 -21
- package/src/lib/components/badge/badge.component.ts +140 -31
- package/src/lib/components/button/button.component.html +16 -10
- package/src/lib/components/button/button.component.ts +162 -22
- package/src/lib/components/card/card-complete/complete-card.component.html +2 -2
- package/src/lib/components/card/card-complete/complete-card.component.ts +26 -16
- package/src/lib/components/card/card-crud-complete/complete-crud-card.component.html +2 -2
- package/src/lib/components/card/card-crud-complete/complete-crud-card.component.ts +26 -16
- package/src/lib/components/checkbox/checkbox-input/input-checkbox.component.css +30 -0
- package/src/lib/components/checkbox/checkbox-input/input-checkbox.component.html +58 -46
- package/src/lib/components/checkbox/checkbox-input/input-checkbox.component.ts +135 -64
- package/src/lib/components/checkbox/checkbox-input/input-checkbox.types.ts +3 -0
- package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.component.css +62 -0
- package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.component.html +39 -25
- package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.component.ts +74 -15
- package/src/lib/components/checkbox/checkbox-switch/switch-checkbox.types.ts +1 -0
- package/src/lib/components/coach-mark/coach-mark.component.html +6 -24
- package/src/lib/components/coach-mark/coach-mark.component.scss +1 -7
- package/src/lib/components/coach-mark/coach-mark.component.ts +51 -18
- package/src/lib/components/coach-mark/coach-mark.directive.ts +133 -78
- package/src/lib/components/coach-mark/coach-mark.types.ts +12 -0
- package/src/lib/components/dialog/dialog.component.css +1 -1
- package/src/lib/components/dialog/dialog.component.html +56 -65
- package/src/lib/components/dialog/dialog.component.ts +136 -110
- package/src/lib/components/dialog/dialog.types.ts +19 -0
- package/src/lib/components/filter/filter-complete/complete-filter.component.html +17 -20
- package/src/lib/components/filter/filter-complete/complete-filter.component.scss +25 -0
- package/src/lib/components/filter/filter-complete/complete-filter.component.ts +58 -34
- package/src/lib/components/filter/filter-complete/complete-filter.types.ts +7 -0
- package/src/lib/components/filter/filter-complete/complete-filter.util.ts +16 -0
- package/src/lib/components/form/form-container/container-form.component.css +4 -0
- package/src/lib/components/form/form-container/container-form.component.html +2 -2
- package/src/lib/components/form/form-container/container-form.component.ts +72 -16
- package/src/lib/components/form/form-container/container-form.types.ts +42 -0
- package/src/lib/components/form/form-container/form-col-span.directive.ts +25 -0
- package/src/lib/components/form/form-sidebar/sidebar-form.component.css +45 -0
- package/src/lib/components/form/form-sidebar/sidebar-form.component.html +128 -124
- package/src/lib/components/form/form-sidebar/sidebar-form.component.ts +114 -34
- package/src/lib/components/form/form-sidebar/sidebar-form.types.ts +3 -0
- package/src/lib/components/{toggle-radio/toggle-radio.component.css → form/form-validation/validation-form.component.css} +0 -1
- package/src/lib/components/form/form-validation/validation-form.component.html +10 -6
- package/src/lib/components/form/form-validation/validation-form.component.ts +99 -12
- package/src/lib/components/form/form-validation/validation-form.types.ts +33 -0
- package/src/lib/components/icon/icon.component.html +8 -5
- package/src/lib/components/icon/icon.component.ts +111 -9
- package/src/lib/components/input/input/input.component.css +0 -14
- package/src/lib/components/input/input/input.component.html +19 -16
- package/src/lib/components/input/input/input.component.ts +130 -53
- package/src/lib/components/input/input/input.types.ts +8 -0
- package/src/lib/components/input/input-file/file-input.component.html +65 -56
- package/src/lib/components/input/input-file/file-input.component.ts +276 -173
- package/src/lib/components/input/input-file/file-input.types.ts +2 -0
- package/src/lib/components/input/input-range/range-input.component.css +67 -0
- package/src/lib/components/input/input-range/range-input.component.html +50 -58
- package/src/lib/components/input/input-range/range-input.component.ts +148 -60
- package/src/lib/components/input/input-range/range-input.types.ts +7 -0
- package/src/lib/components/input/input-textarea/textarea-input.component.html +16 -7
- package/src/lib/components/input/input-textarea/textarea-input.component.ts +140 -50
- package/src/lib/components/input/input-textarea/textarea-input.types.ts +2 -0
- package/src/lib/components/label/label.component.html +17 -16
- package/src/lib/components/label/label.component.ts +94 -16
- package/src/lib/components/label/label.types.ts +2 -0
- package/src/lib/components/menu/menu-options-table/menu-options-defaults.ts +34 -0
- package/src/lib/components/menu/menu-options-table/options-table-menu.component.html +34 -20
- package/src/lib/components/menu/menu-options-table/options-table-menu.component.ts +211 -58
- package/src/lib/components/menu/menu-options-table/options-table-menu.types.ts +38 -0
- package/src/lib/components/menu/options-coach-menu/options-coach-menu.component.html +49 -52
- package/src/lib/components/menu/options-coach-menu/options-coach-menu.component.ts +112 -24
- package/src/lib/components/menu/options-coach-menu/options-coach-menu.types.ts +9 -0
- package/src/lib/components/mode-toggle/mode-toggle.component.html +11 -16
- package/src/lib/components/mode-toggle/mode-toggle.component.ts +69 -33
- package/src/lib/components/paginator/paginator-complete/complete-paginator.component.html +4 -4
- package/src/lib/components/paginator/paginator-complete/complete-paginator.component.ts +31 -7
- package/src/lib/components/paginator/paginator-complete/complete-paginator.types.ts +12 -0
- package/src/lib/components/paginator/paginator-complete/complete-paginator.util.ts +36 -0
- package/src/lib/components/progress-bar/progress-bar.component.html +41 -40
- package/src/lib/components/progress-bar/progress-bar.component.ts +95 -11
- package/src/lib/components/progress-bar/progress-bar.types.ts +2 -0
- package/src/lib/components/select/select-dropdown/dropdown-select.component.html +56 -46
- package/src/lib/components/select/select-dropdown/dropdown-select.component.ts +450 -509
- package/src/lib/components/select/select-dropdown/dropdown-select.types.ts +43 -0
- package/src/lib/components/select/select-dropdown/dropdown-select.util.ts +179 -0
- package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.html +131 -42
- package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.ts +491 -475
- package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.types.ts +22 -0
- package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.util.ts +20 -0
- package/src/lib/components/select/select-multi-table/multi-table-select.component.css +4 -0
- package/src/lib/components/select/select-multi-table/multi-table-select.component.html +76 -60
- package/src/lib/components/select/select-multi-table/multi-table-select.component.ts +250 -313
- package/src/lib/components/select/select-multi-table/multi-table-select.types.ts +10 -0
- package/src/lib/components/select/select-multi-table/multi-table-select.util.ts +5 -0
- package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.css +155 -0
- package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.html +72 -53
- package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.ts +84 -27
- package/src/lib/components/sidebar/sidebar-static/static-sidebar.types.ts +2 -0
- package/src/lib/components/table/table-complete/complete-table.component.html +21 -23
- package/src/lib/components/table/table-complete/complete-table.component.ts +190 -338
- package/src/lib/components/table/table-complete/complete-table.types.ts +28 -0
- package/src/lib/components/table/table-complete/complete-table.util.ts +236 -0
- package/src/lib/components/table/table-complete/index.ts +2 -0
- package/src/lib/components/table/table-crud-complete/complete-crud-table.animations.ts +34 -0
- package/src/lib/components/table/table-crud-complete/complete-crud-table.component.html +87 -142
- package/src/lib/components/table/table-crud-complete/complete-crud-table.component.scss +0 -63
- package/src/lib/components/table/table-crud-complete/complete-crud-table.component.ts +544 -831
- package/src/lib/components/table/table-crud-complete/complete-crud-table.types.ts +57 -0
- package/src/lib/components/table/table-crud-complete/complete-crud-table.util.ts +723 -0
- package/src/lib/components/table/table-crud-complete/index.ts +3 -0
- package/src/lib/components/theme-generator/theme-generator.component.css +21 -0
- package/src/lib/components/theme-generator/theme-generator.component.html +141 -116
- package/src/lib/components/theme-generator/theme-generator.component.ts +44 -24
- package/src/lib/components/toggle-radio/shared/toggle-options.types.ts +8 -0
- package/src/lib/components/toggle-radio/shared/toggle-options.util.ts +62 -0
- package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.component.css +22 -0
- package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.component.html +65 -0
- package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.component.ts +192 -0
- package/src/lib/components/toggle-radio/toggle-radio/toggle-radio.types.ts +1 -0
- package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.component.css +34 -0
- package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.component.html +47 -0
- package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.component.ts +187 -0
- package/src/lib/components/toggle-radio/toggle-segment/segment-toggle.types.ts +1 -0
- package/src/lib/components/tooltip/tooltip.directive.ts +12 -9
- package/src/lib/components/tooltip/tooltip.service.ts +331 -133
- package/src/lib/components/tooltip/tooltip.types.ts +9 -0
- package/src/lib/components/viewer/viewer-image/image-viewer.component.css +14 -4
- package/src/lib/components/viewer/viewer-image/image-viewer.component.html +61 -95
- package/src/lib/components/viewer/viewer-image/image-viewer.component.ts +182 -177
- package/src/lib/components/viewer/viewer-image/image-viewer.types.ts +3 -0
- package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.css +25 -0
- package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.html +95 -24
- package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.ts +168 -15
- package/src/lib/components/viewer/viewer-pdf/pdf-viewer.types.ts +1 -0
- package/src/styles.css +2 -2
- package/lib/services/static/icons.service.d.ts +0 -65
- package/src/lib/components/colors-config/README.md +0 -38
- package/src/lib/components/form/form-sidebar/sidebar-form.component.scss +0 -0
- package/src/lib/components/form/form-validation/validation-form.component.scss +0 -0
- package/src/lib/components/menu/menu-options-table/options-table-menu.component.scss +0 -0
- package/src/lib/components/menu/options-coach-menu/options-coach-menu.component.scss +0 -12
- package/src/lib/components/sidebar/sidebar-static/static-sidebar.component.scss +0 -0
- package/src/lib/components/toggle-radio/toggle-radio.component.html +0 -51
- package/src/lib/components/toggle-radio/toggle-radio.component.ts +0 -222
- package/src/lib/components/viewer/viewer-pdf/pdf-viewer.component.scss +0 -0
- package/tailjng-0.1.6.tgz +0 -0
package/fesm2022/tailjng.mjs
CHANGED
|
@@ -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
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
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(
|
|
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.
|
|
1368
|
+
this.applyThemeModeClass();
|
|
1321
1369
|
}
|
|
1322
1370
|
listenToExternalChanges() {
|
|
1323
1371
|
window.addEventListener('storage', (event) => {
|
|
1324
|
-
if (event.key ===
|
|
1372
|
+
if (event.key === THEME_MODE_STORAGE_KEY && event.newValue) {
|
|
1325
1373
|
const newTheme = event.newValue;
|
|
1326
1374
|
this._theme.set(newTheme);
|
|
1327
|
-
this.
|
|
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
|
-
|
|
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(
|
|
1499
|
+
localStorage.setItem(THEME_MODE_STORAGE_KEY, newTheme);
|
|
1338
1500
|
this._theme.set(newTheme);
|
|
1339
|
-
this.
|
|
1501
|
+
this.applyThemeModeClass();
|
|
1502
|
+
this.syncActiveColorsToDocument(true);
|
|
1340
1503
|
}
|
|
1341
1504
|
setTheme(theme) {
|
|
1342
|
-
localStorage.setItem(
|
|
1505
|
+
localStorage.setItem(THEME_MODE_STORAGE_KEY, theme);
|
|
1343
1506
|
this._theme.set(theme);
|
|
1344
|
-
this.
|
|
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,
|
|
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
|