@memberjunction/ng-shared-generic 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"exports.test.js","sourceRoot":"","sources":["../../src/__tests__/exports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,YAAY,IAAI,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"exports.test.js","sourceRoot":"","sources":["../../src/__tests__/exports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,YAAY,IAAI,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect } from 'vitest';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\n\ndescribe('@memberjunction/ng-shared-generic', () => {\n it('should have a public API entry point', () => {\n const pkgRoot = resolve(__dirname, '../..');\n const hasPublicApi = existsSync(resolve(pkgRoot, 'src/public-api.ts'));\n const hasIndex = existsSync(resolve(pkgRoot, 'src/index.ts'));\n expect(hasPublicApi || hasIndex).toBe(true);\n });\n\n it('should have a package.json with correct name', () => {\n const pkgRoot = resolve(__dirname, '../..');\n const pkg = require(resolve(pkgRoot, 'package.json'));\n expect(pkg.name).toBe('@memberjunction/ng-shared-generic');\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect } from 'vitest';\n\ndescribe('@memberjunction/ng-shared-generic', () => {\n it('should have a passing test', () => {\n expect(true).toBe(true);\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"loading.component.js","sourceRoot":"","sources":["../../../src/lib/loading/loading.component.ts","../../../src/lib/loading/loading.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;;;;ICMvC,AADF,4BAAM,qBAK4B;IAE9B,AADA,0BAAgE,cACA;IAEpE,AADE,iBAAiB,EACZ;;;IARW,cAAsB;;IAKlB,cAA2C;;IACzC,cAAyC;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AAK;;kBASL,KAAK;;kFAxDK,gBAAgB"}
1
+ {"version":3,"file":"loading.component.js","sourceRoot":"","sources":["../../../src/lib/loading/loading.component.ts","../../../src/lib/loading/loading.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;;;;ICMvC,AADF,4BAAM,qBAK4B;IAE9B,AADA,0BAAgE,cACA;IAEpE,AADE,iBAAiB,EACZ;;;IARW,cAAsB;;IAKlB,cAA2C;;IACzC,cAAyC;;;;IASrE,4BAA+C;IAAA,YAAU;IAAA,iBAAI;;;IAAlC,+BAAmB;IAAC,cAAU;IAAV,iCAAU;;ADN7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAOH,MAAM,OAAO,gBAAgB;IAC3B;;;OAGG;IACM,IAAI,GAAG,YAAY,CAAC;IAE7B;;;OAGG;IACM,QAAQ,GAAG,IAAI,CAAC;IAEzB;;;OAGG;IACM,iBAAiB,GAAG,GAAG,CAAC;IAEjC;;;;;;OAMG;IACM,IAAI,GAA0C,MAAM,CAAC;IAE9D;;;OAGG;IACM,SAAS,GAAG,SAAS,CAAC;IAE/B;;;;;OAKG;IACM,SAAS,GAAG,SAAS,CAAC;IAE/B;;;;OAIG;IACM,YAAY,GAAwB,IAAI,CAAC;IAElD;;;;;;OAMG;IACM,SAAS,GAA+C,OAAO,CAAC;IAEzE,+DAA+D;IACtD,UAAU,GAAG,oBAAoB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IAExF,IAAI,SAAS;QACX,OAAO,wBAAwB,IAAI,CAAC,IAAI,cAAc,IAAI,CAAC,SAAS,EAAE,CAAC;IACzE,CAAC;IAED,IAAI,SAAS;QACX,OAAO,uBAAuB,IAAI,CAAC,iBAAiB,GAAG,CAAC;IAC1D,CAAC;IAED,IAAI,SAAS;QACX,OAAO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C,AADE,iBAAM,EACF;YACN,gFAAwB;YAG1B,iBAAM;;YAtBqB,cAAmB;YAAnB,4BAAmB;YAAvC,4BAAmB;YAGpB,eAWC;YAXD,2CAWC;YACi2G,cAAsB;;YACh2E,cAAsB;;YAGljC,cAEC;YAFD,mDAEC;;;iFDmCU,gBAAgB;cAN5B,SAAS;6BACI,KAAK,YACP,YAAY;;kBASrB,KAAK;;kBAML,KAAK;;kBAML,KAAK;;kBASL,KAAK;;kBAML,KAAK;;kBAQL,KAAK;;kBAOL,KAAK;;kBASL,KAAK;;kFAxDK,gBAAgB","sourcesContent":["import { Component, Input } from '@angular/core';\n\n/**\n * Gradient configuration for the logo.\n * When provided, creates a linear gradient fill instead of solid color.\n */\nexport interface LogoGradient {\n /** Starting color of the gradient */\n startColor: string;\n /** Ending color of the gradient */\n endColor: string;\n /** Gradient angle in degrees (0 = left to right, 90 = top to bottom). Default: 45 */\n angle?: number;\n}\n\n/**\n * MJ Loading Component - Displays an animated MJ logo with optional text.\n *\n * Features:\n * - SVG logo with customizable animations (pulse, spin, bounce)\n * - Sizes to fit container (use CSS on host element)\n * - Optional loading text\n * - Customizable text and logo colors\n * - Gradient support for logo fill\n *\n * @example\n * ```html\n * <!-- Basic usage (fills container) -->\n * <mj-loading></mj-loading>\n *\n * <!-- With custom text -->\n * <mj-loading text=\"Loading data...\"></mj-loading>\n *\n * <!-- No text -->\n * <mj-loading [showText]=\"false\"></mj-loading>\n *\n * <!-- With custom colors -->\n * <mj-loading text=\"Loading...\" textColor=\"#4CAF50\" logoColor=\"#4CAF50\"></mj-loading>\n *\n * <!-- With gradient colors (holiday theme) -->\n * <mj-loading [logoGradient]=\"{startColor: '#228B22', endColor: '#C41E3A'}\"></mj-loading>\n *\n * <!-- With spinning animation -->\n * <mj-loading animation=\"spin\"></mj-loading>\n *\n * <!-- Fixed size container -->\n * <div style=\"width: 200px; height: 150px;\">\n * <mj-loading text=\"Please wait...\"></mj-loading>\n * </div>\n * ```\n */\n@Component({\n standalone: false,\n selector: 'mj-loading',\n templateUrl: './loading.component.html',\n styleUrls: ['./loading.component.css']\n})\nexport class LoadingComponent {\n /**\n * Text to display below the loading animation.\n * Set to empty string or use showText=false to hide text.\n */\n @Input() text = 'Loading...';\n\n /**\n * Whether to show the text below the logo.\n * When false, only the animated logo is shown.\n */\n @Input() showText = true;\n\n /**\n * Animation duration in seconds.\n * Default is 1.5 seconds for the pulse animation.\n */\n @Input() animationDuration = 1.5;\n\n /**\n * Size preset for quick sizing.\n * - 'small': 40x22px logo\n * - 'medium': 80x45px logo (default)\n * - 'large': 120x67px logo\n * - 'auto': fills container\n */\n @Input() size: 'small' | 'medium' | 'large' | 'auto' = 'auto';\n\n /**\n * CSS color for the loading text.\n * Accepts any valid CSS color value.\n */\n @Input() textColor = '#757575';\n\n /**\n * CSS color for the logo (solid color).\n * Accepts any valid CSS color value.\n * Default is MJ blue (#264FAF).\n * Ignored if logoGradient is provided.\n */\n @Input() logoColor = '#264FAF';\n\n /**\n * Gradient configuration for the logo.\n * When provided, creates a linear gradient fill instead of solid color.\n * Takes precedence over logoColor.\n */\n @Input() logoGradient: LogoGradient | null = null;\n\n /**\n * Animation type for the logo.\n * - 'pulse': Fade in/out with subtle scale (default)\n * - 'spin': Rotate continuously\n * - 'bounce': Bounce up and down\n * - 'pulse-spin': Pulse while slowly spinning\n */\n @Input() animation: 'pulse' | 'spin' | 'bounce' | 'pulse-spin' = 'pulse';\n\n /** Unique ID for the gradient definition to avoid conflicts */\n readonly gradientId = `mj-logo-gradient-${Math.random().toString(36).substring(2, 11)}`;\n\n get logoClass(): string {\n return `mj-loading-logo size-${this.size} animation-${this.animation}`;\n }\n\n get logoStyle(): string {\n return `animation-duration: ${this.animationDuration}s`;\n }\n\n get textStyle(): string {\n return `color: ${this.textColor}`;\n }\n\n /**\n * Get the fill value for the SVG paths.\n * Returns a gradient URL reference if gradient is set, otherwise the solid color.\n */\n get logoFill(): string {\n if (this.logoGradient) {\n return `url(#${this.gradientId})`;\n }\n return this.logoColor;\n }\n\n /**\n * Calculate gradient transform based on angle.\n * Converts angle to x1, y1, x2, y2 coordinates for SVG linearGradient.\n */\n get gradientCoords(): { x1: string; y1: string; x2: string; y2: string } {\n const angle = this.logoGradient?.angle ?? 45;\n // Convert angle to radians and calculate coordinates\n // SVG gradientUnits=\"objectBoundingBox\" uses 0-1 range\n const radians = (angle * Math.PI) / 180;\n const x1 = Math.round(50 - Math.cos(radians) * 50);\n const y1 = Math.round(50 + Math.sin(radians) * 50);\n const x2 = Math.round(50 + Math.cos(radians) * 50);\n const y2 = Math.round(50 - Math.sin(radians) * 50);\n\n return {\n x1: `${x1}%`,\n y1: `${y1}%`,\n x2: `${x2}%`,\n y2: `${y2}%`\n };\n }\n}\n","<div class=\"mj-loading-container\">\n <div [class]=\"logoClass\" [style]=\"logoStyle\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 230 128\" class=\"mj-logo-svg\">\n <!-- Gradient definition (only rendered when logoGradient is set) -->\n @if (logoGradient) {\n <defs>\n <linearGradient [attr.id]=\"gradientId\"\n [attr.x1]=\"gradientCoords.x1\"\n [attr.y1]=\"gradientCoords.y1\"\n [attr.x2]=\"gradientCoords.x2\"\n [attr.y2]=\"gradientCoords.y2\">\n <stop offset=\"0%\" [attr.stop-color]=\"logoGradient.startColor\" />\n <stop offset=\"100%\" [attr.stop-color]=\"logoGradient.endColor\" />\n </linearGradient>\n </defs>\n }\n <path d=\"M0 0 C1.197 0.668 2.394 1.336 3.592 2.004 C12.234 6.837 20.792 11.805 29.327 16.824 C37.26 21.476 45.269 25.98 53.312 30.438 C53.91 30.769 54.507 31.1 55.122 31.441 C61.234 34.87 61.234 34.87 67.438 38.125 C69.709 37.16 69.709 37.16 72.258 35.652 C73.255 35.09 74.253 34.527 75.281 33.948 C76.364 33.325 77.447 32.703 78.562 32.062 C79.685 31.426 80.808 30.789 81.965 30.133 C90.435 25.322 98.84 20.401 107.239 15.469 C118.242 9.027 129.394 2.857 140.566 -3.286 C142.41 -4.306 144.248 -5.338 146.079 -6.382 C146.869 -6.832 147.659 -7.282 148.473 -7.746 C149.148 -8.136 149.824 -8.526 150.52 -8.927 C156.448 -11.856 163.036 -11.676 169.188 -9.625 C175.638 -6.152 178.915 -2.712 181.438 4.125 C181.951 7.259 181.946 10.308 181.892 13.479 C181.892 14.377 181.893 15.276 181.893 16.201 C181.891 19.145 181.86 22.088 181.828 25.031 C181.821 27.082 181.815 29.134 181.811 31.185 C181.796 36.564 181.757 41.943 181.712 47.322 C181.671 52.819 181.653 58.316 181.633 63.812 C181.59 74.584 181.522 85.354 181.438 96.125 C178.573 94.739 175.729 93.326 172.901 91.867 C170.644 90.732 168.349 89.671 166.018 88.7 C162.628 87.127 160.12 85.736 157.438 83.125 C155.741 78.082 155.893 73.244 156.047 68.004 C156.047 66.534 156.041 65.064 156.031 63.595 C156.018 59.745 156.076 55.899 156.15 52.049 C156.213 48.114 156.207 44.18 156.207 40.244 C156.217 32.536 156.303 24.832 156.438 17.125 C152.485 19.335 148.534 21.546 144.582 23.758 C143.476 24.376 142.37 24.995 141.231 25.632 C131.895 30.857 122.601 36.151 113.321 41.472 C107.737 44.673 102.15 47.868 96.562 51.062 C95.965 51.404 95.367 51.746 94.751 52.098 C86.826 56.629 78.889 61.14 70.938 65.625 C62.527 70.37 54.133 75.144 45.75 79.938 C45.166 80.271 44.581 80.605 43.979 80.95 C37.987 84.375 31.996 87.803 26.011 91.241 C14.366 97.93 2.707 104.594 -9.062 111.062 C-9.97 111.565 -10.878 112.067 -11.814 112.585 C-12.649 113.04 -13.484 113.496 -14.344 113.965 C-15.066 114.36 -15.789 114.756 -16.533 115.164 C-22.269 117.881 -28.602 117.949 -34.625 116.125 C-39.398 114.15 -42.881 110.491 -45.562 106.125 C-45.562 104.805 -45.562 103.485 -45.562 102.125 C-45.022 101.835 -44.481 101.545 -43.924 101.246 C-32.122 94.897 -20.456 88.363 -8.907 81.566 C-0.017 76.35 8.975 71.333 18.003 66.362 C24.427 62.82 30.777 59.186 37.065 55.408 C39.438 54.125 39.438 54.125 41.438 54.125 C41.438 53.465 41.438 52.805 41.438 52.125 C40.704 51.843 39.971 51.561 39.216 51.271 C36.702 50.234 34.368 49.093 31.98 47.797 C30.7 47.102 30.7 47.102 29.395 46.394 C28.481 45.892 27.567 45.391 26.625 44.875 C25.666 44.351 24.707 43.826 23.719 43.286 C14.477 38.202 5.37 32.897 -3.719 27.547 C-8.103 24.968 -12.509 22.431 -16.928 19.911 C-17.89 19.362 -17.89 19.362 -18.871 18.802 C-20.435 17.909 -21.999 17.017 -23.562 16.125 C-23.525 16.942 -23.487 17.759 -23.448 18.601 C-23.106 26.338 -22.848 34.071 -22.682 41.814 C-22.593 45.794 -22.474 49.768 -22.28 53.745 C-21.06 79.461 -21.06 79.461 -25.205 85.53 C-29.148 89.11 -33.517 90.996 -38.581 92.49 C-41.159 93.316 -43.282 94.688 -45.562 96.125 C-46.222 96.125 -46.882 96.125 -47.562 96.125 C-47.655 84.546 -47.726 72.967 -47.77 61.388 C-47.791 56.01 -47.819 50.633 -47.864 45.256 C-47.908 40.062 -47.932 34.869 -47.942 29.675 C-47.949 27.698 -47.964 25.721 -47.985 23.744 C-48.015 20.965 -48.018 18.187 -48.017 15.408 C-48.031 14.599 -48.045 13.79 -48.06 12.956 C-48.013 6.348 -46.391 0.196 -41.823 -4.764 C-27.895 -17.466 -13.817 -7.747 0 0 Z\" [attr.fill]=\"logoFill\" transform=\"translate(47.5625,10.875)\"/>\n <path d=\"M0 0 C2.051 0.961 2.051 0.961 4.098 2.16 C5.278 2.843 5.278 2.843 6.481 3.541 C7.333 4.043 8.185 4.545 9.062 5.062 C10.954 6.16 12.846 7.258 14.738 8.355 C16.255 9.24 16.255 9.24 17.803 10.142 C22.848 13.074 27.913 15.969 32.979 18.863 C34.753 19.877 36.525 20.892 38.297 21.907 C44.243 25.311 50.205 28.681 56.203 31.992 C57.347 32.625 58.491 33.258 59.669 33.911 C61.837 35.108 64.008 36.299 66.183 37.484 C67.154 38.02 68.125 38.557 69.125 39.109 C69.973 39.573 70.821 40.037 71.695 40.515 C74.149 42.096 76.015 43.87 78 46 C74.984 51.808 72.395 55.457 66.25 58.25 C54.159 61.04 44.857 55.778 34.625 49.75 C32.781 48.681 30.938 47.612 29.094 46.543 C28.114 45.972 27.134 45.402 26.125 44.814 C21.068 41.878 15.989 38.98 10.91 36.082 C9.13 35.065 7.35 34.048 5.57 33.03 C-5.598 26.648 -16.794 20.315 -28 14 C-28 13.34 -28 12.68 -28 12 C-24.284 9.789 -20.551 7.61 -16.812 5.438 C-15.757 4.809 -14.702 4.181 -13.615 3.533 C-12.083 2.649 -12.083 2.649 -10.52 1.746 C-9.582 1.196 -8.645 0.646 -7.679 0.08 C-4.518 -1.194 -3.196 -1.069 0 0 Z\" [attr.fill]=\"logoFill\" transform=\"translate(150,69)\"/>\n </svg>\n </div>\n @if (showText && text) {\n <p class=\"mj-loading-text\" [style]=\"textStyle\">{{ text }}</p>\n }\n</div>\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;;AAa/D,MAAM,OAAO,mBAAmB;6GAAnB,mBAAmB;4DAAnB,mBAAmB;gEAN5B,YAAY;;iFAMH,mBAAmB;cAX/B,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,gBAAgB;iBACjB;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,gBAAgB;iBACjB;aACF;;wFACY,mBAAmB,mBAT5B,gBAAgB,aAGhB,YAAY,aAGZ,gBAAgB"}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;;AAa/D,MAAM,OAAO,mBAAmB;6GAAnB,mBAAmB;4DAAnB,mBAAmB;gEAN5B,YAAY;;iFAMH,mBAAmB;cAX/B,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,gBAAgB;iBACjB;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,gBAAgB;iBACjB;aACF;;wFACY,mBAAmB,mBAT5B,gBAAgB,aAGhB,YAAY,aAGZ,gBAAgB","sourcesContent":["import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { LoadingComponent } from './loading/loading.component';\n\n@NgModule({\n declarations: [\n LoadingComponent\n ],\n imports: [\n CommonModule\n ],\n exports: [\n LoadingComponent\n ]\n})\nexport class SharedGenericModule { }\n"]}
@@ -57,6 +57,18 @@ export declare class RecentAccessService {
57
57
  * Refresh recent items in background
58
58
  */
59
59
  refreshRecentItems(): Promise<void>;
60
+ /**
61
+ * Batch-resolve record names for a list of recent access items using GetEntityRecordNames().
62
+ * Mutates the items in-place to set recordName where resolved.
63
+ */
64
+ private resolveRecordNames;
65
+ /**
66
+ * Build a CompositeKey for a record. RecordID may be stored as either:
67
+ * - Concatenated format: "FieldName|Value" or "Field1|Val1||Field2|Val2"
68
+ * - Plain value: just the raw value (e.g. a GUID)
69
+ * Detects the format and constructs the key accordingly.
70
+ */
71
+ private buildCompositeKeyForRecord;
60
72
  /**
61
73
  * Determines the resource type based on entity name
62
74
  */
@@ -1 +1 @@
1
- {"version":3,"file":"recent-access.service.d.ts","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,YAAY,EAAY,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAmB,UAAU,EAAE,MAAM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G;IACU,eAAe,CAAC,QAAQ,GAAE,MAAW,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAgD/G;;OAEG;IACU,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhD;;;OAGG;YACW,kBAAkB;IA+BhC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA0BlC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAmB7B;;OAEG;IACI,UAAU,IAAI,IAAI;yCAxQd,mBAAmB;6CAAnB,mBAAmB;CA4Q/B"}
@@ -134,6 +134,8 @@ export class RecentAccessService {
134
134
  resourceType
135
135
  });
136
136
  }
137
+ // Batch-resolve record names for all items
138
+ await this.resolveRecordNames(items, md);
137
139
  this._recentItems$.next(items);
138
140
  this._isLoaded = true;
139
141
  return items;
@@ -152,6 +154,71 @@ export class RecentAccessService {
152
154
  async refreshRecentItems() {
153
155
  await this.loadRecentItems(15, true);
154
156
  }
157
+ /**
158
+ * Batch-resolve record names for a list of recent access items using GetEntityRecordNames().
159
+ * Mutates the items in-place to set recordName where resolved.
160
+ */
161
+ async resolveRecordNames(items, md) {
162
+ const nameInputs = [];
163
+ const indexMap = new Map();
164
+ for (let i = 0; i < items.length; i++) {
165
+ const item = items[i];
166
+ const compositeKey = this.buildCompositeKeyForRecord(item.entityName, item.recordId, md);
167
+ if (!compositeKey)
168
+ continue;
169
+ nameInputs.push({ EntityName: item.entityName, CompositeKey: compositeKey });
170
+ indexMap.set(`${item.entityName}||${compositeKey.ToConcatenatedString()}`, i);
171
+ }
172
+ if (nameInputs.length === 0)
173
+ return;
174
+ try {
175
+ const nameResults = await md.GetEntityRecordNames(nameInputs);
176
+ for (const result of nameResults) {
177
+ if (result.Success && result.RecordName) {
178
+ const key = `${result.EntityName}||${result.CompositeKey.ToConcatenatedString()}`;
179
+ const index = indexMap.get(key);
180
+ if (index !== undefined) {
181
+ items[index].recordName = result.RecordName;
182
+ }
183
+ }
184
+ }
185
+ }
186
+ catch (error) {
187
+ console.warn('RecentAccessService: Failed to resolve record names', error);
188
+ }
189
+ }
190
+ /**
191
+ * Build a CompositeKey for a record. RecordID may be stored as either:
192
+ * - Concatenated format: "FieldName|Value" or "Field1|Val1||Field2|Val2"
193
+ * - Plain value: just the raw value (e.g. a GUID)
194
+ * Detects the format and constructs the key accordingly.
195
+ */
196
+ buildCompositeKeyForRecord(entityName, recordId, md) {
197
+ if (!recordId)
198
+ return null;
199
+ // If recordId contains '|', it's in concatenated format
200
+ if (recordId.includes('|')) {
201
+ try {
202
+ const compositeKey = new CompositeKey();
203
+ compositeKey.LoadFromConcatenatedString(recordId);
204
+ if (compositeKey.KeyValuePairs.length > 0)
205
+ return compositeKey;
206
+ }
207
+ catch {
208
+ // Fall through to entity-based lookup
209
+ }
210
+ }
211
+ // Plain value — look up entity primary key field(s) to construct the key
212
+ const entityInfo = md.Entities.find(e => e.Name === entityName);
213
+ if (!entityInfo)
214
+ return null;
215
+ const pkField = entityInfo.FirstPrimaryKey;
216
+ if (!pkField)
217
+ return null;
218
+ const compositeKey = new CompositeKey();
219
+ compositeKey.KeyValuePairs = [{ FieldName: pkField.Name, Value: recordId }];
220
+ return compositeKey;
221
+ }
155
222
  /**
156
223
  * Determines the resource type based on entity name
157
224
  */
@@ -1 +1 @@
1
- {"version":3,"file":"recent-access.service.js","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAyB,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;;AAiBnD;;;GAGG;AAIH,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAC,SAAS,CAAsB;IACtC,aAAa,GAAG,IAAI,eAAe,CA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,UAAU,CAAC,eAAe,CAAC;QAC3C,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAE1B,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;QACxC,YAAY,CAAC,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5E,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,UAAkB;QAC9C,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QAEhD,IAAI,cAAc,KAAK,YAAY,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,cAAc,KAAK,YAAY,EAAE,CAAC;YACpC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,IAAI,cAAc,KAAK,4BAA4B,IAAI,cAAc,KAAK,wBAAwB,EAAE,CAAC;YACnG,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;6GA3QU,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB,mBAFlB,MAAM;;iFAEP,mBAAmB;cAH/B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Metadata, RunView, CompositeKey, LogError, EntityRecordNameInput } from '@memberjunction/core';\nimport { MJUserRecordLogEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\n/**\n * Represents a recently accessed resource\n */\nexport interface RecentAccessItem {\n id: string;\n entityId: string;\n entityName: string;\n recordId: string;\n recordName?: string;\n latestAt: Date;\n totalCount: number;\n /** Resource type for special handling (record, view, dashboard, artifact) */\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report';\n}\n\n/**\n * Service for tracking and retrieving recently accessed resources.\n * Uses the User Record Logs entity to persist access history.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class RecentAccessService {\n private static _instance: RecentAccessService;\n private _recentItems$ = new BehaviorSubject<RecentAccessItem[]>([]);\n private _isLoading$ = new BehaviorSubject<boolean>(false);\n private _isLoaded = false;\n\n constructor() {\n if (RecentAccessService._instance) {\n return RecentAccessService._instance;\n }\n RecentAccessService._instance = this;\n }\n\n public static get Instance(): RecentAccessService {\n return RecentAccessService._instance;\n }\n\n /**\n * Observable of recent access items, sorted by most recent first\n */\n public get RecentItems(): Observable<RecentAccessItem[]> {\n return this._recentItems$.asObservable();\n }\n\n /**\n * Current value of recent items\n */\n public get RecentItemsValue(): RecentAccessItem[] {\n return this._recentItems$.value;\n }\n\n /**\n * Observable loading state\n */\n public get IsLoading(): Observable<boolean> {\n return this._isLoading$.asObservable();\n }\n\n /**\n * Logs access to a record. Creates or updates the User Record Log entry.\n * This is a fire-and-forget operation - errors are logged but don't interrupt the user.\n *\n * @param entityName - The name of the entity being accessed\n * @param recordId - The record ID (single value or CompositeKey string)\n * @param resourceType - The type of resource being accessed\n */\n public async logAccess(\n entityName: string,\n recordId: string | CompositeKey,\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report' = 'record'\n ): Promise<void> {\n try {\n const md = new Metadata();\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo) {\n console.warn(`RecentAccessService: Entity \"${entityName}\" not found in metadata`);\n return;\n }\n\n // Convert CompositeKey to string if needed\n const recordIdString = recordId instanceof CompositeKey\n ? recordId.Values(',') // Values() returns joined string with specified delimiter\n : recordId;\n\n // Check if we already have a log entry for this user/entity/record combination\n const rv = new RunView();\n const existingResult = await rv.RunView<MJUserRecordLogEntity>({\n EntityName: 'MJ: User Record Logs',\n ExtraFilter: `UserID='${md.CurrentUser.ID}' AND EntityID='${entityInfo.ID}' AND RecordID='${recordIdString}'`,\n ResultType: 'entity_object',\n MaxRows: 1\n });\n\n if (!existingResult.Success) {\n console.error('RecentAccessService: Failed to check existing log', existingResult.ErrorMessage);\n return;\n }\n\n if (existingResult.Results && existingResult.Results.length > 0) {\n // Update existing entry\n const existing = existingResult.Results[0];\n existing.LatestAt = new Date();\n existing.TotalCount = (existing.TotalCount || 0) + 1;\n\n const saveResult = await existing.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to update log entry');\n }\n } else {\n // Create new entry\n const newLog = await md.GetEntityObject<MJUserRecordLogEntity>('MJ: User Record Logs');\n newLog.UserID = md.CurrentUser.ID;\n newLog.EntityID = entityInfo.ID;\n newLog.RecordID = recordIdString;\n // EarliestAt and LatestAt have default values of getdate() in the DB\n // TotalCount defaults to 0, so we set it to 1\n newLog.TotalCount = 1;\n\n const saveResult = await newLog.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to create log entry');\n }\n }\n\n // Refresh the recent items list in background\n this.refreshRecentItems();\n } catch (error) {\n // Don't throw - this is non-critical functionality\n console.error('RecentAccessService: Error logging access', error);\n }\n }\n\n /**\n * Loads recent access items for the current user using UserInfoEngine (cached).\n * @param maxItems - Maximum number of items to return (default 15)\n * @param forceRefresh - Force refresh even if already loaded\n */\n public async loadRecentItems(maxItems: number = 15, forceRefresh: boolean = false): Promise<RecentAccessItem[]> {\n if (this._isLoaded && !forceRefresh) {\n return this._recentItems$.value;\n }\n\n try {\n this._isLoading$.next(true);\n\n const md = new Metadata();\n\n // Get recent records, limited to maxItems (already ordered by LatestAt DESC in engine)\n const userRecordLogs = UserInfoEngine.Instance.UserRecordLogs.slice(0, maxItems);\n\n const items: RecentAccessItem[] = [];\n\n for (const log of userRecordLogs) {\n const entityInfo = md.Entities.find(e => e.ID === log.EntityID);\n if (!entityInfo) continue;\n\n // Determine resource type based on entity name\n const resourceType = this.determineResourceType(entityInfo.Name);\n\n items.push({\n id: log.ID,\n entityId: log.EntityID,\n entityName: entityInfo.Name,\n recordId: log.RecordID,\n latestAt: log.LatestAt,\n totalCount: log.TotalCount,\n resourceType\n });\n }\n\n // Batch-resolve record names for all items\n await this.resolveRecordNames(items, md);\n\n this._recentItems$.next(items);\n this._isLoaded = true;\n\n return items;\n } catch (error) {\n LogError('RecentAccessService: Error loading recent items', undefined, error);\n return [];\n } finally {\n this._isLoading$.next(false);\n }\n }\n\n /**\n * Refresh recent items in background\n */\n public async refreshRecentItems(): Promise<void> {\n await this.loadRecentItems(15, true);\n }\n\n /**\n * Batch-resolve record names for a list of recent access items using GetEntityRecordNames().\n * Mutates the items in-place to set recordName where resolved.\n */\n private async resolveRecordNames(items: RecentAccessItem[], md: Metadata): Promise<void> {\n const nameInputs: EntityRecordNameInput[] = [];\n const indexMap = new Map<string, number>();\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const compositeKey = this.buildCompositeKeyForRecord(item.entityName, item.recordId, md);\n if (!compositeKey) continue;\n\n nameInputs.push({ EntityName: item.entityName, CompositeKey: compositeKey });\n indexMap.set(`${item.entityName}||${compositeKey.ToConcatenatedString()}`, i);\n }\n\n if (nameInputs.length === 0) return;\n\n try {\n const nameResults = await md.GetEntityRecordNames(nameInputs);\n for (const result of nameResults) {\n if (result.Success && result.RecordName) {\n const key = `${result.EntityName}||${result.CompositeKey.ToConcatenatedString()}`;\n const index = indexMap.get(key);\n if (index !== undefined) {\n items[index].recordName = result.RecordName;\n }\n }\n }\n } catch (error) {\n console.warn('RecentAccessService: Failed to resolve record names', error);\n }\n }\n\n /**\n * Build a CompositeKey for a record. RecordID may be stored as either:\n * - Concatenated format: \"FieldName|Value\" or \"Field1|Val1||Field2|Val2\"\n * - Plain value: just the raw value (e.g. a GUID)\n * Detects the format and constructs the key accordingly.\n */\n private buildCompositeKeyForRecord(entityName: string, recordId: string, md: Metadata): CompositeKey | null {\n if (!recordId) return null;\n\n // If recordId contains '|', it's in concatenated format\n if (recordId.includes('|')) {\n try {\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromConcatenatedString(recordId);\n if (compositeKey.KeyValuePairs.length > 0) return compositeKey;\n } catch {\n // Fall through to entity-based lookup\n }\n }\n\n // Plain value — look up entity primary key field(s) to construct the key\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo) return null;\n\n const pkField = entityInfo.FirstPrimaryKey;\n if (!pkField) return null;\n\n const compositeKey = new CompositeKey();\n compositeKey.KeyValuePairs = [{ FieldName: pkField.Name, Value: recordId }];\n return compositeKey;\n }\n\n /**\n * Determines the resource type based on entity name\n */\n private determineResourceType(entityName: string): 'record' | 'view' | 'dashboard' | 'artifact' | 'report' {\n const normalizedName = entityName.toLowerCase();\n\n if (normalizedName === 'user views') {\n return 'view';\n }\n if (normalizedName === 'dashboards') {\n return 'dashboard';\n }\n if (normalizedName === 'mj: conversation artifacts' || normalizedName === 'conversation artifacts') {\n return 'artifact';\n }\n if (normalizedName === 'reports') {\n return 'report';\n }\n\n return 'record';\n }\n\n /**\n * Clears the cached recent items (useful for logout)\n */\n public clearCache(): void {\n this._recentItems$.next([]);\n this._isLoaded = false;\n }\n}\n"]}
@@ -0,0 +1,161 @@
1
+ import { Observable } from 'rxjs';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Defines a theme available in the application.
5
+ * Built-in themes (light/dark) have no CssUrl.
6
+ * Custom themes specify a BaseTheme to inherit from and a CssUrl with overrides.
7
+ */
8
+ export interface ThemeDefinition {
9
+ /** Unique identifier (e.g. 'light', 'dark', 'izzy-dark') */
10
+ Id: string;
11
+ /** Human-readable display name (e.g. 'Light', 'Dark', 'Izzy Dark') */
12
+ Name: string;
13
+ /** Which built-in theme this inherits from */
14
+ BaseTheme: 'light' | 'dark';
15
+ /** URL to the CSS file with token overrides (omit for built-in themes) */
16
+ CssUrl?: string;
17
+ /** Whether this is a built-in theme (light/dark) */
18
+ IsBuiltIn: boolean;
19
+ /** Optional description shown in theme picker */
20
+ Description?: string;
21
+ /** Optional preview swatch colors for a future theme picker UI */
22
+ PreviewColors?: string[];
23
+ }
24
+ /**
25
+ * Service to manage application themes with pluggable custom theme support.
26
+ *
27
+ * Built-in themes (light/dark) work identically to before. Custom themes
28
+ * inherit from a base theme and overlay additional CSS token overrides via
29
+ * a dynamically loaded stylesheet.
30
+ *
31
+ * CSS resolution for custom themes (e.g. "Izzy Dark" extending dark):
32
+ * 1. `:root` light defaults (from _tokens.scss)
33
+ * 2. `[data-theme="dark"]` dark overrides (from _tokens.scss)
34
+ * 3. `[data-theme-overlay="izzy-dark"]` custom overrides (loaded dynamically)
35
+ *
36
+ * Follows the DeveloperModeService pattern:
37
+ * - Settings persisted via UserInfoEngine
38
+ * - BehaviorSubject for reactive state
39
+ * - Initialize after login, Reset on logout
40
+ */
41
+ export declare class ThemeService {
42
+ private _preference$;
43
+ private _appliedTheme$;
44
+ private _initialized;
45
+ private systemMediaQuery;
46
+ private boundSystemThemeHandler;
47
+ /** Registry of available themes, seeded with built-in light and dark */
48
+ private themeRegistry;
49
+ /** Cache of loaded <link> elements by theme ID to avoid re-downloading */
50
+ private loadedCssLinks;
51
+ /**
52
+ * Observable for user's theme preference (theme ID or 'system')
53
+ */
54
+ get Preference$(): Observable<string>;
55
+ /**
56
+ * Observable for the actually applied theme (resolved theme ID)
57
+ */
58
+ get AppliedTheme$(): Observable<string>;
59
+ /**
60
+ * Current theme preference (synchronous access)
61
+ */
62
+ get Preference(): string;
63
+ /**
64
+ * Currently applied theme ID (synchronous access)
65
+ */
66
+ get AppliedTheme(): string;
67
+ /**
68
+ * Whether the service has been initialized
69
+ */
70
+ get IsInitialized(): boolean;
71
+ /**
72
+ * All registered themes, for UI consumption (e.g. theme picker menus)
73
+ */
74
+ get AvailableThemes(): ThemeDefinition[];
75
+ /**
76
+ * Look up a theme definition by ID.
77
+ * Returns undefined if the theme ID is not registered.
78
+ */
79
+ GetThemeDefinition(id: string): ThemeDefinition | undefined;
80
+ /**
81
+ * Register a custom theme. If a theme with the same ID already exists,
82
+ * it is replaced (allowing override of built-in themes if desired).
83
+ */
84
+ RegisterTheme(theme: ThemeDefinition): void;
85
+ /**
86
+ * Register multiple custom themes at once.
87
+ */
88
+ RegisterThemes(themes: ThemeDefinition[]): void;
89
+ /**
90
+ * Initialize the theme service.
91
+ * Call after login when UserInfoEngine is available.
92
+ */
93
+ Initialize(): Promise<void>;
94
+ /**
95
+ * Set the theme preference and apply it.
96
+ * @param preference - A registered theme ID or 'system'
97
+ */
98
+ SetTheme(preference: string): Promise<void>;
99
+ /**
100
+ * Reset the service (call on logout)
101
+ */
102
+ Reset(): void;
103
+ /**
104
+ * Apply a resolved theme ID to the DOM.
105
+ * Sets `data-theme` based on BaseTheme and `data-theme-overlay` for custom themes.
106
+ * Loads custom CSS if needed, disables previous custom CSS.
107
+ */
108
+ private applyTheme;
109
+ /**
110
+ * Apply the base theme attribute to <html>.
111
+ * 'dark' sets data-theme="dark"; 'light' removes it (matching existing convention).
112
+ */
113
+ private applyBaseThemeAttribute;
114
+ /**
115
+ * Shorthand for built-in theme application (no custom CSS)
116
+ */
117
+ private applyBuiltInTheme;
118
+ /**
119
+ * Load (or re-enable) a custom theme's CSS file.
120
+ * Injects a <link> element into <head> with a data-mj-theme attribute.
121
+ * Caches the link element to avoid re-downloading on theme switches.
122
+ * Returns a Promise that resolves once the stylesheet is loaded.
123
+ */
124
+ private loadThemeCss;
125
+ /**
126
+ * Disable (not remove) all custom theme CSS <link> elements.
127
+ * Disabling rather than removing avoids re-downloading when switching back.
128
+ */
129
+ private disableAllCustomCss;
130
+ /**
131
+ * Resolve a preference string to an actual theme ID.
132
+ * 'system' resolves to 'light' or 'dark' based on OS preference.
133
+ * Unrecognized IDs fall back to 'light'.
134
+ */
135
+ private resolveTheme;
136
+ /**
137
+ * Get system theme preference from OS
138
+ */
139
+ private getSystemTheme;
140
+ /**
141
+ * Setup listener for system theme changes
142
+ */
143
+ private setupSystemThemeListener;
144
+ /**
145
+ * Handle system theme change (only applies if in 'system' mode)
146
+ */
147
+ private onSystemThemeChange;
148
+ /**
149
+ * Load theme preference from User Settings.
150
+ * Accepts any registered theme ID or 'system'.
151
+ * Falls back to 'system' if saved value is not recognized.
152
+ */
153
+ private loadSetting;
154
+ /**
155
+ * Save theme preference to User Settings
156
+ */
157
+ private saveSetting;
158
+ static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
159
+ static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
160
+ }
161
+ //# sourceMappingURL=theme.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.service.d.ts","sourceRoot":"","sources":["../../src/lib/theme.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;;AAGnD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AA6BD;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,YAAY;IACrB,OAAO,CAAC,YAAY,CAAyC;IAC7D,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,uBAAuB,CAA6B;IAE5D,wEAAwE;IACxE,OAAO,CAAC,aAAa,CAGlB;IAEH,0EAA0E;IAC1E,OAAO,CAAC,cAAc,CAA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serInfoEngine } from '@memberjunction/core-entities';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Setting key for theme preference in MJ: User Settings entity
7
+ */
8
+ const THEME_SETTING_KEY = 'Explorer.Theme';
9
+ /**
10
+ * Built-in light theme definition
11
+ */
12
+ const LIGHT_THEME = {
13
+ Id: 'light',
14
+ Name: 'Light',
15
+ BaseTheme: 'light',
16
+ IsBuiltIn: true,
17
+ Description: 'Default light theme'
18
+ };
19
+ /**
20
+ * Built-in dark theme definition
21
+ */
22
+ const DARK_THEME = {
23
+ Id: 'dark',
24
+ Name: 'Dark',
25
+ BaseTheme: 'dark',
26
+ IsBuiltIn: true,
27
+ Description: 'Default dark theme'
28
+ };
29
+ /**
30
+ * Service to manage application themes with pluggable custom theme support.
31
+ *
32
+ * Built-in themes (light/dark) work identically to before. Custom themes
33
+ * inherit from a base theme and overlay additional CSS token overrides via
34
+ * a dynamically loaded stylesheet.
35
+ *
36
+ * CSS resolution for custom themes (e.g. "Izzy Dark" extending dark):
37
+ * 1. `:root` light defaults (from _tokens.scss)
38
+ * 2. `[data-theme="dark"]` dark overrides (from _tokens.scss)
39
+ * 3. `[data-theme-overlay="izzy-dark"]` custom overrides (loaded dynamically)
40
+ *
41
+ * Follows the DeveloperModeService pattern:
42
+ * - Settings persisted via UserInfoEngine
43
+ * - BehaviorSubject for reactive state
44
+ * - Initialize after login, Reset on logout
45
+ */
46
+ export class ThemeService {
47
+ _preference$ = new BehaviorSubject('system');
48
+ _appliedTheme$ = new BehaviorSubject('light');
49
+ _initialized = false;
50
+ systemMediaQuery = null;
51
+ boundSystemThemeHandler = null;
52
+ /** Registry of available themes, seeded with built-in light and dark */
53
+ themeRegistry = new Map([
54
+ ['light', LIGHT_THEME],
55
+ ['dark', DARK_THEME]
56
+ ]);
57
+ /** Cache of loaded <link> elements by theme ID to avoid re-downloading */
58
+ loadedCssLinks = new Map();
59
+ /**
60
+ * Observable for user's theme preference (theme ID or 'system')
61
+ */
62
+ get Preference$() {
63
+ return this._preference$.asObservable();
64
+ }
65
+ /**
66
+ * Observable for the actually applied theme (resolved theme ID)
67
+ */
68
+ get AppliedTheme$() {
69
+ return this._appliedTheme$.asObservable();
70
+ }
71
+ /**
72
+ * Current theme preference (synchronous access)
73
+ */
74
+ get Preference() {
75
+ return this._preference$.value;
76
+ }
77
+ /**
78
+ * Currently applied theme ID (synchronous access)
79
+ */
80
+ get AppliedTheme() {
81
+ return this._appliedTheme$.value;
82
+ }
83
+ /**
84
+ * Whether the service has been initialized
85
+ */
86
+ get IsInitialized() {
87
+ return this._initialized;
88
+ }
89
+ /**
90
+ * All registered themes, for UI consumption (e.g. theme picker menus)
91
+ */
92
+ get AvailableThemes() {
93
+ return Array.from(this.themeRegistry.values());
94
+ }
95
+ /**
96
+ * Look up a theme definition by ID.
97
+ * Returns undefined if the theme ID is not registered.
98
+ */
99
+ GetThemeDefinition(id) {
100
+ return this.themeRegistry.get(id);
101
+ }
102
+ // ========================================
103
+ // THEME REGISTRATION
104
+ // ========================================
105
+ /**
106
+ * Register a custom theme. If a theme with the same ID already exists,
107
+ * it is replaced (allowing override of built-in themes if desired).
108
+ */
109
+ RegisterTheme(theme) {
110
+ this.themeRegistry.set(theme.Id, theme);
111
+ }
112
+ /**
113
+ * Register multiple custom themes at once.
114
+ */
115
+ RegisterThemes(themes) {
116
+ for (const theme of themes) {
117
+ this.RegisterTheme(theme);
118
+ }
119
+ }
120
+ // ========================================
121
+ // LIFECYCLE
122
+ // ========================================
123
+ /**
124
+ * Initialize the theme service.
125
+ * Call after login when UserInfoEngine is available.
126
+ */
127
+ async Initialize() {
128
+ if (this._initialized) {
129
+ return;
130
+ }
131
+ this.setupSystemThemeListener();
132
+ const savedPreference = await this.loadSetting();
133
+ this._preference$.next(savedPreference);
134
+ const resolvedThemeId = this.resolveTheme(savedPreference);
135
+ await this.applyTheme(resolvedThemeId);
136
+ this._initialized = true;
137
+ }
138
+ /**
139
+ * Set the theme preference and apply it.
140
+ * @param preference - A registered theme ID or 'system'
141
+ */
142
+ async SetTheme(preference) {
143
+ if (preference === this._preference$.value) {
144
+ return;
145
+ }
146
+ this._preference$.next(preference);
147
+ const resolvedThemeId = this.resolveTheme(preference);
148
+ await this.applyTheme(resolvedThemeId);
149
+ await this.saveSetting(preference);
150
+ }
151
+ /**
152
+ * Reset the service (call on logout)
153
+ */
154
+ Reset() {
155
+ if (this.systemMediaQuery && this.boundSystemThemeHandler) {
156
+ this.systemMediaQuery.removeEventListener('change', this.boundSystemThemeHandler);
157
+ }
158
+ this.systemMediaQuery = null;
159
+ this.boundSystemThemeHandler = null;
160
+ this._preference$.next('system');
161
+ this._appliedTheme$.next('light');
162
+ this._initialized = false;
163
+ // Remove theme attributes
164
+ document.documentElement.removeAttribute('data-theme');
165
+ document.documentElement.removeAttribute('data-theme-overlay');
166
+ // Disable all custom CSS links
167
+ this.disableAllCustomCss();
168
+ }
169
+ // ========================================
170
+ // THEME APPLICATION
171
+ // ========================================
172
+ /**
173
+ * Apply a resolved theme ID to the DOM.
174
+ * Sets `data-theme` based on BaseTheme and `data-theme-overlay` for custom themes.
175
+ * Loads custom CSS if needed, disables previous custom CSS.
176
+ */
177
+ async applyTheme(themeId) {
178
+ const themeDef = this.themeRegistry.get(themeId);
179
+ // Fall back to 'light' if the theme ID isn't recognized
180
+ if (!themeDef) {
181
+ this.applyBuiltInTheme('light');
182
+ this._appliedTheme$.next('light');
183
+ return;
184
+ }
185
+ // Set the base theme attribute (drives existing [data-theme="dark"] selectors)
186
+ this.applyBaseThemeAttribute(themeDef.BaseTheme);
187
+ if (themeDef.IsBuiltIn) {
188
+ // Built-in theme: remove overlay, disable custom CSS
189
+ document.documentElement.removeAttribute('data-theme-overlay');
190
+ this.disableAllCustomCss();
191
+ }
192
+ else if (themeDef.CssUrl) {
193
+ // Custom theme: load/enable CSS and set overlay attribute
194
+ await this.loadThemeCss(themeDef);
195
+ document.documentElement.setAttribute('data-theme-overlay', themeDef.Id);
196
+ }
197
+ this._appliedTheme$.next(themeId);
198
+ }
199
+ /**
200
+ * Apply the base theme attribute to <html>.
201
+ * 'dark' sets data-theme="dark"; 'light' removes it (matching existing convention).
202
+ */
203
+ applyBaseThemeAttribute(baseTheme) {
204
+ if (baseTheme === 'dark') {
205
+ document.documentElement.setAttribute('data-theme', 'dark');
206
+ }
207
+ else {
208
+ document.documentElement.removeAttribute('data-theme');
209
+ }
210
+ }
211
+ /**
212
+ * Shorthand for built-in theme application (no custom CSS)
213
+ */
214
+ applyBuiltInTheme(baseTheme) {
215
+ this.applyBaseThemeAttribute(baseTheme);
216
+ document.documentElement.removeAttribute('data-theme-overlay');
217
+ this.disableAllCustomCss();
218
+ }
219
+ // ========================================
220
+ // DYNAMIC CSS LOADING
221
+ // ========================================
222
+ /**
223
+ * Load (or re-enable) a custom theme's CSS file.
224
+ * Injects a <link> element into <head> with a data-mj-theme attribute.
225
+ * Caches the link element to avoid re-downloading on theme switches.
226
+ * Returns a Promise that resolves once the stylesheet is loaded.
227
+ */
228
+ loadThemeCss(theme) {
229
+ if (!theme.CssUrl) {
230
+ return Promise.resolve();
231
+ }
232
+ // Disable all other custom CSS first
233
+ this.disableAllCustomCss();
234
+ // Check cache — if already loaded, just re-enable
235
+ const existingLink = this.loadedCssLinks.get(theme.Id);
236
+ if (existingLink) {
237
+ existingLink.disabled = false;
238
+ return Promise.resolve();
239
+ }
240
+ // Create and inject new <link> element
241
+ return new Promise((resolve, reject) => {
242
+ const link = document.createElement('link');
243
+ link.rel = 'stylesheet';
244
+ link.href = theme.CssUrl;
245
+ link.setAttribute('data-mj-theme', theme.Id);
246
+ link.onload = () => resolve();
247
+ link.onerror = () => {
248
+ console.warn(`Failed to load theme CSS: ${theme.CssUrl}`);
249
+ // Still resolve so the theme switch isn't blocked
250
+ resolve();
251
+ };
252
+ document.head.appendChild(link);
253
+ this.loadedCssLinks.set(theme.Id, link);
254
+ });
255
+ }
256
+ /**
257
+ * Disable (not remove) all custom theme CSS <link> elements.
258
+ * Disabling rather than removing avoids re-downloading when switching back.
259
+ */
260
+ disableAllCustomCss() {
261
+ for (const link of this.loadedCssLinks.values()) {
262
+ link.disabled = true;
263
+ }
264
+ }
265
+ // ========================================
266
+ // THEME RESOLUTION
267
+ // ========================================
268
+ /**
269
+ * Resolve a preference string to an actual theme ID.
270
+ * 'system' resolves to 'light' or 'dark' based on OS preference.
271
+ * Unrecognized IDs fall back to 'light'.
272
+ */
273
+ resolveTheme(preference) {
274
+ if (preference === 'system') {
275
+ return this.getSystemTheme();
276
+ }
277
+ // If the preference is a registered theme, use it directly
278
+ if (this.themeRegistry.has(preference)) {
279
+ return preference;
280
+ }
281
+ // Unrecognized theme ID — fall back to light
282
+ return 'light';
283
+ }
284
+ /**
285
+ * Get system theme preference from OS
286
+ */
287
+ getSystemTheme() {
288
+ if (typeof window === 'undefined') {
289
+ return 'light';
290
+ }
291
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
292
+ }
293
+ /**
294
+ * Setup listener for system theme changes
295
+ */
296
+ setupSystemThemeListener() {
297
+ if (typeof window === 'undefined') {
298
+ return;
299
+ }
300
+ this.systemMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
301
+ this.boundSystemThemeHandler = () => this.onSystemThemeChange();
302
+ this.systemMediaQuery.addEventListener('change', this.boundSystemThemeHandler);
303
+ }
304
+ /**
305
+ * Handle system theme change (only applies if in 'system' mode)
306
+ */
307
+ async onSystemThemeChange() {
308
+ if (this._preference$.value === 'system') {
309
+ const newThemeId = this.getSystemTheme();
310
+ await this.applyTheme(newThemeId);
311
+ }
312
+ }
313
+ // ========================================
314
+ // PERSISTENCE
315
+ // ========================================
316
+ /**
317
+ * Load theme preference from User Settings.
318
+ * Accepts any registered theme ID or 'system'.
319
+ * Falls back to 'system' if saved value is not recognized.
320
+ */
321
+ async loadSetting() {
322
+ try {
323
+ const engine = UserInfoEngine.Instance;
324
+ const settingValue = engine.GetSetting(THEME_SETTING_KEY);
325
+ if (!settingValue) {
326
+ return 'system';
327
+ }
328
+ // Accept 'system' or any registered theme ID
329
+ if (settingValue === 'system' || this.themeRegistry.has(settingValue)) {
330
+ return settingValue;
331
+ }
332
+ // Saved theme no longer registered — fall back
333
+ return 'system';
334
+ }
335
+ catch (error) {
336
+ console.warn('Failed to load theme setting:', error);
337
+ return 'system';
338
+ }
339
+ }
340
+ /**
341
+ * Save theme preference to User Settings
342
+ */
343
+ async saveSetting(preference) {
344
+ try {
345
+ const engine = UserInfoEngine.Instance;
346
+ await engine.SetSetting(THEME_SETTING_KEY, preference);
347
+ }
348
+ catch (error) {
349
+ console.warn('Failed to save theme setting:', error);
350
+ }
351
+ }
352
+ static ɵfac = function ThemeService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ThemeService)(); };
353
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ThemeService, factory: ThemeService.ɵfac, providedIn: 'root' });
354
+ }
355
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ThemeService, [{
356
+ type: Injectable,
357
+ args: [{ providedIn: 'root' }]
358
+ }], null, null); })();
359
+ //# sourceMappingURL=theme.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.service.js","sourceRoot":"","sources":["../../src/lib/theme.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;;AAwB/D;;GAEG;AACH,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,GAAoB;IACjC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,OAAO;IACb,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,qBAAqB;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAoB;IAChC,EAAE,EAAE,MAAM;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AC7C,IAAI,YAAY,KAAK,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBACpE,OAAO,YAAY,CAAC;YACxB,CAAC;YAED,+CAA+C;YAC/C,OAAO,QAAQ,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CAAC,UAAkB;QACxC,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;YACvC,MAAM,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;sGArWQ,YAAY;gEAAZ,YAAY,WAAZ,YAAY,mBADC,MAAM;;iFACnB,YAAY;cADxB,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { UserInfoEngine } from '@memberjunction/core-entities';\n\n/**\n * Defines a theme available in the application.\n * Built-in themes (light/dark) have no CssUrl.\n * Custom themes specify a BaseTheme to inherit from and a CssUrl with overrides.\n */\nexport interface ThemeDefinition {\n /** Unique identifier (e.g. 'light', 'dark', 'izzy-dark') */\n Id: string;\n /** Human-readable display name (e.g. 'Light', 'Dark', 'Izzy Dark') */\n Name: string;\n /** Which built-in theme this inherits from */\n BaseTheme: 'light' | 'dark';\n /** URL to the CSS file with token overrides (omit for built-in themes) */\n CssUrl?: string;\n /** Whether this is a built-in theme (light/dark) */\n IsBuiltIn: boolean;\n /** Optional description shown in theme picker */\n Description?: string;\n /** Optional preview swatch colors for a future theme picker UI */\n PreviewColors?: string[];\n}\n\n/**\n * Setting key for theme preference in MJ: User Settings entity\n */\nconst THEME_SETTING_KEY = 'Explorer.Theme';\n\n/**\n * Built-in light theme definition\n */\nconst LIGHT_THEME: ThemeDefinition = {\n Id: 'light',\n Name: 'Light',\n BaseTheme: 'light',\n IsBuiltIn: true,\n Description: 'Default light theme'\n};\n\n/**\n * Built-in dark theme definition\n */\nconst DARK_THEME: ThemeDefinition = {\n Id: 'dark',\n Name: 'Dark',\n BaseTheme: 'dark',\n IsBuiltIn: true,\n Description: 'Default dark theme'\n};\n\n/**\n * Service to manage application themes with pluggable custom theme support.\n *\n * Built-in themes (light/dark) work identically to before. Custom themes\n * inherit from a base theme and overlay additional CSS token overrides via\n * a dynamically loaded stylesheet.\n *\n * CSS resolution for custom themes (e.g. \"Izzy Dark\" extending dark):\n * 1. `:root` light defaults (from _tokens.scss)\n * 2. `[data-theme=\"dark\"]` dark overrides (from _tokens.scss)\n * 3. `[data-theme-overlay=\"izzy-dark\"]` custom overrides (loaded dynamically)\n *\n * Follows the DeveloperModeService pattern:\n * - Settings persisted via UserInfoEngine\n * - BehaviorSubject for reactive state\n * - Initialize after login, Reset on logout\n */\n@Injectable({ providedIn: 'root' })\nexport class ThemeService {\n private _preference$ = new BehaviorSubject<string>('system');\n private _appliedTheme$ = new BehaviorSubject<string>('light');\n private _initialized = false;\n private systemMediaQuery: MediaQueryList | null = null;\n private boundSystemThemeHandler: (() => void) | null = null;\n\n /** Registry of available themes, seeded with built-in light and dark */\n private themeRegistry = new Map<string, ThemeDefinition>([\n ['light', LIGHT_THEME],\n ['dark', DARK_THEME]\n ]);\n\n /** Cache of loaded <link> elements by theme ID to avoid re-downloading */\n private loadedCssLinks = new Map<string, HTMLLinkElement>();\n\n /**\n * Observable for user's theme preference (theme ID or 'system')\n */\n public get Preference$(): Observable<string> {\n return this._preference$.asObservable();\n }\n\n /**\n * Observable for the actually applied theme (resolved theme ID)\n */\n public get AppliedTheme$(): Observable<string> {\n return this._appliedTheme$.asObservable();\n }\n\n /**\n * Current theme preference (synchronous access)\n */\n public get Preference(): string {\n return this._preference$.value;\n }\n\n /**\n * Currently applied theme ID (synchronous access)\n */\n public get AppliedTheme(): string {\n return this._appliedTheme$.value;\n }\n\n /**\n * Whether the service has been initialized\n */\n public get IsInitialized(): boolean {\n return this._initialized;\n }\n\n /**\n * All registered themes, for UI consumption (e.g. theme picker menus)\n */\n public get AvailableThemes(): ThemeDefinition[] {\n return Array.from(this.themeRegistry.values());\n }\n\n /**\n * Look up a theme definition by ID.\n * Returns undefined if the theme ID is not registered.\n */\n public GetThemeDefinition(id: string): ThemeDefinition | undefined {\n return this.themeRegistry.get(id);\n }\n\n // ========================================\n // THEME REGISTRATION\n // ========================================\n\n /**\n * Register a custom theme. If a theme with the same ID already exists,\n * it is replaced (allowing override of built-in themes if desired).\n */\n public RegisterTheme(theme: ThemeDefinition): void {\n this.themeRegistry.set(theme.Id, theme);\n }\n\n /**\n * Register multiple custom themes at once.\n */\n public RegisterThemes(themes: ThemeDefinition[]): void {\n for (const theme of themes) {\n this.RegisterTheme(theme);\n }\n }\n\n // ========================================\n // LIFECYCLE\n // ========================================\n\n /**\n * Initialize the theme service.\n * Call after login when UserInfoEngine is available.\n */\n public async Initialize(): Promise<void> {\n if (this._initialized) {\n return;\n }\n\n this.setupSystemThemeListener();\n\n const savedPreference = await this.loadSetting();\n this._preference$.next(savedPreference);\n\n const resolvedThemeId = this.resolveTheme(savedPreference);\n await this.applyTheme(resolvedThemeId);\n\n this._initialized = true;\n }\n\n /**\n * Set the theme preference and apply it.\n * @param preference - A registered theme ID or 'system'\n */\n public async SetTheme(preference: string): Promise<void> {\n if (preference === this._preference$.value) {\n return;\n }\n\n this._preference$.next(preference);\n\n const resolvedThemeId = this.resolveTheme(preference);\n await this.applyTheme(resolvedThemeId);\n\n await this.saveSetting(preference);\n }\n\n /**\n * Reset the service (call on logout)\n */\n public Reset(): void {\n if (this.systemMediaQuery && this.boundSystemThemeHandler) {\n this.systemMediaQuery.removeEventListener('change', this.boundSystemThemeHandler);\n }\n this.systemMediaQuery = null;\n this.boundSystemThemeHandler = null;\n\n this._preference$.next('system');\n this._appliedTheme$.next('light');\n this._initialized = false;\n\n // Remove theme attributes\n document.documentElement.removeAttribute('data-theme');\n document.documentElement.removeAttribute('data-theme-overlay');\n\n // Disable all custom CSS links\n this.disableAllCustomCss();\n }\n\n // ========================================\n // THEME APPLICATION\n // ========================================\n\n /**\n * Apply a resolved theme ID to the DOM.\n * Sets `data-theme` based on BaseTheme and `data-theme-overlay` for custom themes.\n * Loads custom CSS if needed, disables previous custom CSS.\n */\n private async applyTheme(themeId: string): Promise<void> {\n const themeDef = this.themeRegistry.get(themeId);\n\n // Fall back to 'light' if the theme ID isn't recognized\n if (!themeDef) {\n this.applyBuiltInTheme('light');\n this._appliedTheme$.next('light');\n return;\n }\n\n // Set the base theme attribute (drives existing [data-theme=\"dark\"] selectors)\n this.applyBaseThemeAttribute(themeDef.BaseTheme);\n\n if (themeDef.IsBuiltIn) {\n // Built-in theme: remove overlay, disable custom CSS\n document.documentElement.removeAttribute('data-theme-overlay');\n this.disableAllCustomCss();\n } else if (themeDef.CssUrl) {\n // Custom theme: load/enable CSS and set overlay attribute\n await this.loadThemeCss(themeDef);\n document.documentElement.setAttribute('data-theme-overlay', themeDef.Id);\n }\n\n this._appliedTheme$.next(themeId);\n }\n\n /**\n * Apply the base theme attribute to <html>.\n * 'dark' sets data-theme=\"dark\"; 'light' removes it (matching existing convention).\n */\n private applyBaseThemeAttribute(baseTheme: 'light' | 'dark'): void {\n if (baseTheme === 'dark') {\n document.documentElement.setAttribute('data-theme', 'dark');\n } else {\n document.documentElement.removeAttribute('data-theme');\n }\n }\n\n /**\n * Shorthand for built-in theme application (no custom CSS)\n */\n private applyBuiltInTheme(baseTheme: 'light' | 'dark'): void {\n this.applyBaseThemeAttribute(baseTheme);\n document.documentElement.removeAttribute('data-theme-overlay');\n this.disableAllCustomCss();\n }\n\n // ========================================\n // DYNAMIC CSS LOADING\n // ========================================\n\n /**\n * Load (or re-enable) a custom theme's CSS file.\n * Injects a <link> element into <head> with a data-mj-theme attribute.\n * Caches the link element to avoid re-downloading on theme switches.\n * Returns a Promise that resolves once the stylesheet is loaded.\n */\n private loadThemeCss(theme: ThemeDefinition): Promise<void> {\n if (!theme.CssUrl) {\n return Promise.resolve();\n }\n\n // Disable all other custom CSS first\n this.disableAllCustomCss();\n\n // Check cache — if already loaded, just re-enable\n const existingLink = this.loadedCssLinks.get(theme.Id);\n if (existingLink) {\n existingLink.disabled = false;\n return Promise.resolve();\n }\n\n // Create and inject new <link> element\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = theme.CssUrl!;\n link.setAttribute('data-mj-theme', theme.Id);\n\n link.onload = () => resolve();\n link.onerror = () => {\n console.warn(`Failed to load theme CSS: ${theme.CssUrl}`);\n // Still resolve so the theme switch isn't blocked\n resolve();\n };\n\n document.head.appendChild(link);\n this.loadedCssLinks.set(theme.Id, link);\n });\n }\n\n /**\n * Disable (not remove) all custom theme CSS <link> elements.\n * Disabling rather than removing avoids re-downloading when switching back.\n */\n private disableAllCustomCss(): void {\n for (const link of this.loadedCssLinks.values()) {\n link.disabled = true;\n }\n }\n\n // ========================================\n // THEME RESOLUTION\n // ========================================\n\n /**\n * Resolve a preference string to an actual theme ID.\n * 'system' resolves to 'light' or 'dark' based on OS preference.\n * Unrecognized IDs fall back to 'light'.\n */\n private resolveTheme(preference: string): string {\n if (preference === 'system') {\n return this.getSystemTheme();\n }\n\n // If the preference is a registered theme, use it directly\n if (this.themeRegistry.has(preference)) {\n return preference;\n }\n\n // Unrecognized theme ID — fall back to light\n return 'light';\n }\n\n /**\n * Get system theme preference from OS\n */\n private getSystemTheme(): 'light' | 'dark' {\n if (typeof window === 'undefined') {\n return 'light';\n }\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n\n /**\n * Setup listener for system theme changes\n */\n private setupSystemThemeListener(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n this.systemMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n this.boundSystemThemeHandler = () => this.onSystemThemeChange();\n this.systemMediaQuery.addEventListener('change', this.boundSystemThemeHandler);\n }\n\n /**\n * Handle system theme change (only applies if in 'system' mode)\n */\n private async onSystemThemeChange(): Promise<void> {\n if (this._preference$.value === 'system') {\n const newThemeId = this.getSystemTheme();\n await this.applyTheme(newThemeId);\n }\n }\n\n // ========================================\n // PERSISTENCE\n // ========================================\n\n /**\n * Load theme preference from User Settings.\n * Accepts any registered theme ID or 'system'.\n * Falls back to 'system' if saved value is not recognized.\n */\n private async loadSetting(): Promise<string> {\n try {\n const engine = UserInfoEngine.Instance;\n const settingValue = engine.GetSetting(THEME_SETTING_KEY);\n\n if (!settingValue) {\n return 'system';\n }\n\n // Accept 'system' or any registered theme ID\n if (settingValue === 'system' || this.themeRegistry.has(settingValue)) {\n return settingValue;\n }\n\n // Saved theme no longer registered — fall back\n return 'system';\n } catch (error) {\n console.warn('Failed to load theme setting:', error);\n return 'system';\n }\n }\n\n /**\n * Save theme preference to User Settings\n */\n private async saveSetting(preference: string): Promise<void> {\n try {\n const engine = UserInfoEngine.Instance;\n await engine.SetSetting(THEME_SETTING_KEY, preference);\n } catch (error) {\n console.warn('Failed to save theme setting:', error);\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from './lib/module';
2
2
  export * from './lib/recent-access.service';
3
+ export * from './lib/theme.service';
3
4
  export * from './lib/loading/loading.component';
4
5
  //# sourceMappingURL=public-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAG7B,cAAc,6BAA6B,CAAC;AAG5C,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAG7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AAGpC,cAAc,iCAAiC,CAAC"}
@@ -5,6 +5,7 @@
5
5
  export * from './lib/module';
6
6
  // Services
7
7
  export * from './lib/recent-access.service';
8
+ export * from './lib/theme.service';
8
9
  // Components
9
10
  export * from './lib/loading/loading.component';
10
11
  //# sourceMappingURL=public-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,6BAA6B,CAAC;AAE5C,aAAa;AACb,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AAEpC,aAAa;AACb,cAAc,iCAAiC,CAAC","sourcesContent":["/*\n * Public API Surface for @memberjunction/ng-shared-generic\n */\n\n// Module\nexport * from './lib/module';\n\n// Services\nexport * from './lib/recent-access.service';\nexport * from './lib/theme.service';\n\n// Components\nexport * from './lib/loading/loading.component';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-shared-generic",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "description": "MemberJunction: Generic Angular Shared Package - utility services and reusable elements used in any Angular application.",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -29,8 +29,8 @@
29
29
  "rxjs": "^7.8.2"
30
30
  },
31
31
  "dependencies": {
32
- "@memberjunction/core": "5.3.0",
33
- "@memberjunction/core-entities": "5.3.0",
32
+ "@memberjunction/core": "5.4.0",
33
+ "@memberjunction/core-entities": "5.4.0",
34
34
  "tslib": "^2.8.1"
35
35
  },
36
36
  "sideEffects": false,