@africanies/angular-web-sdk 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +456 -169
  2. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -0
  3. package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/package.json +5 -5
  4. package/.nx/cache/{5741611231803799383 → 14876618240301288353}/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +100 -20
  5. package/.nx/cache/{1275815545780424169 → 17626862048742598274}/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +6 -0
  6. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +1 -0
  7. package/.nx/cache/{14153928176747262656 → 17626862048742598274}/dist/libs/africanies-theme/package.json +3 -3
  8. package/.nx/cache/{1275815545780424169 → 17626862048742598274}/dist/libs/africanies-theme/tailwind-preset.cjs +15 -7
  9. package/.nx/cache/{14153928176747262656 → 17626862048742598274}/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +10 -1
  10. package/.nx/cache/{13524438527920092277 → 9040451482998546630}/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +9 -44
  11. package/.nx/cache/9040451482998546630/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +1 -0
  12. package/.nx/cache/{13524438527920092277 → 9040451482998546630}/dist/libs/africanies-core/package.json +3 -3
  13. package/.nx/cache/{13524438527920092277 → 9040451482998546630}/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +6 -5
  14. package/.nx/cache/run.json +19 -19
  15. package/.nx/cache/terminalOutputs/13555699813138069787 +6 -0
  16. package/.nx/cache/terminalOutputs/{12148417737220755248 → 14061940909886036014} +172 -174
  17. package/.nx/cache/terminalOutputs/{3064561615116090625 → 14876618240301288353} +7 -7
  18. package/.nx/cache/terminalOutputs/{1275815545780424169 → 17626862048742598274} +2 -2
  19. package/.nx/cache/terminalOutputs/7978448102466861029 +32 -0
  20. package/.nx/cache/terminalOutputs/{4011892767661954819 → 9040451482998546630} +1 -1
  21. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db +0 -0
  22. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-shm +0 -0
  23. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-wal +0 -0
  24. package/.nx/workspace-data/d/daemon.log +2370 -0
  25. package/.nx/workspace-data/d/server-process.json +2 -2
  26. package/.nx/workspace-data/file-map.json +3177 -3177
  27. package/.nx/workspace-data/nx_files.nxt +0 -0
  28. package/.nx/workspace-data/project-graph.json +2 -2
  29. package/apps/playground/src/app/app.routes.ts +15 -4
  30. package/apps/playground/src/app/app.ts +2 -2
  31. package/apps/playground/src/app/pages/home-page.ts +14 -14
  32. package/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +8 -43
  33. package/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +1 -1
  34. package/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +6 -5
  35. package/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +11 -11
  36. package/libs/africanies-core/src/lib/http/api-client.ts +4 -18
  37. package/libs/africanies-core/src/lib/http/is-retryable-get-error.ts +8 -4
  38. package/libs/africanies-core/src/lib/query/provide-africanies-query-defaults.ts +5 -6
  39. package/package.json +1 -1
  40. package/.nx/cache/1275815545780424169/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +0 -1
  41. package/.nx/cache/1275815545780424169/dist/libs/africanies-theme/package.json +0 -36
  42. package/.nx/cache/1275815545780424169/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +0 -157
  43. package/.nx/cache/13524438527920092277/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +0 -1
  44. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/README.md +0 -46
  45. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +0 -215
  46. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +0 -1
  47. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/tailwind-preset.cjs +0 -245
  48. package/.nx/cache/18132311043100376919/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +0 -1
  49. package/.nx/cache/18132311043100376919/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +0 -5410
  50. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/README.md +0 -69
  51. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/assets/icons.sprite.svg +0 -1844
  52. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/fesm2022/africanies-africanies-icons.mjs +0 -832
  53. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/fesm2022/africanies-africanies-icons.mjs.map +0 -1
  54. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/package.json +0 -31
  55. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/types/africanies-africanies-icons.d.ts +0 -108
  56. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/README.md +0 -31
  57. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/fesm2022/africanies-africanies-storage.mjs +0 -243
  58. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/fesm2022/africanies-africanies-storage.mjs.map +0 -1
  59. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/package.json +0 -27
  60. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/types/africanies-africanies-storage.d.ts +0 -210
  61. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/README.md +0 -85
  62. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +0 -4546
  63. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +0 -1
  64. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/package.json +0 -32
  65. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +0 -2740
  66. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/README.md +0 -68
  67. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  68. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  69. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +0 -5
  70. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/carriers/dhl.svg +0 -7
  71. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +0 -19088
  72. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +0 -1
  73. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/package.json +0 -36
  74. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/README.md +0 -60
  75. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/fesm2022/africanies-africanies-models.mjs +0 -599
  76. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/fesm2022/africanies-africanies-models.mjs.map +0 -1
  77. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/package.json +0 -24
  78. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/types/africanies-africanies-models.d.ts +0 -1452
  79. package/.nx/cache/terminalOutputs/11768036696192889608 +0 -8
  80. package/.nx/cache/terminalOutputs/1227201614544602906 +0 -23
  81. package/.nx/cache/terminalOutputs/12538607787148205787 +0 -19
  82. package/.nx/cache/terminalOutputs/13524438527920092277 +0 -196
  83. package/.nx/cache/terminalOutputs/14153928176747262656 +0 -45
  84. package/.nx/cache/terminalOutputs/17404566492103808557 +0 -8
  85. package/.nx/cache/terminalOutputs/18132311043100376919 +0 -315
  86. package/.nx/cache/terminalOutputs/2436781291243085315 +0 -8
  87. package/.nx/cache/terminalOutputs/2782605790118376385 +0 -21
  88. package/.nx/cache/terminalOutputs/3681975492957101833 +0 -8
  89. package/.nx/cache/terminalOutputs/5741611231803799383 +0 -21
  90. package/.nx/cache/terminalOutputs/6037166070823946880 +0 -8
  91. package/.nx/cache/terminalOutputs/6372470950255467653 +0 -21
  92. package/.nx/cache/terminalOutputs/665190206482526466 +0 -175
  93. package/.nx/cache/terminalOutputs/7756595539965457927 +0 -23
  94. package/.nx/cache/terminalOutputs/9200013119269230075 +0 -8
  95. /package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/README.md +0 -0
  96. /package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  97. /package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  98. /package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +0 -0
  99. /package/.nx/cache/{18132311043100376919 → 14876618240301288353}/dist/libs/africanies-ui/assets/carriers/dhl.svg +0 -0
  100. /package/.nx/cache/{1275815545780424169 → 17626862048742598274}/dist/libs/africanies-theme/README.md +0 -0
  101. /package/.nx/cache/{13524438527920092277 → 9040451482998546630}/dist/libs/africanies-core/README.md +0 -0
@@ -11,11 +11,9 @@ import {
11
11
  map,
12
12
  Observable,
13
13
  of,
14
- retry,
15
14
  tap,
16
15
  throwError,
17
16
  timeout,
18
- timer,
19
17
  } from 'rxjs';
20
18
 
21
19
  import {
@@ -30,7 +28,6 @@ import { AFRICANIES_SDK_CONFIG } from '../config/africanies-sdk.config';
30
28
  import { ShippingModeService } from '../shipping/shipping-mode.service';
31
29
  import { formatApiErrorMessage } from './api-error-message';
32
30
  import { HttpResponseCache } from './http-cache';
33
- import { isRetryableGetError } from './is-retryable-get-error';
34
31
  import { normalize } from './normalize';
35
32
  import {
36
33
  resolveApiRequestContext,
@@ -102,7 +99,8 @@ type ResponseMode = NonNullable<ApiRequestOptions['responseMode']>;
102
99
  * - HTTP failures rethrown as `Error` whose `.message` is already
103
100
  * user-facing ({@link formatApiErrorMessage}) — consumers do not need to
104
101
  * parse `HttpErrorResponse` bodies
105
- * - Exponential-backoff retry (max 1) for **GET only**
102
+ * - **No automatic retry** fail fast so UIs can show Select / table /
103
+ * error-state Retry instead of a stuck loading spinner
106
104
  * - Optional per-GET TTL cache via `cacheTtlMs`
107
105
  *
108
106
  * @example
@@ -474,20 +472,8 @@ export class ApiClient {
474
472
  break;
475
473
  }
476
474
 
477
- // Retry only idempotent GETs on transient failures never replay 401/404 etc.
478
- if (method === 'GET') {
479
- req$ = req$.pipe(
480
- retry({
481
- count: 1,
482
- delay: (err, retryCount) => {
483
- if (!isRetryableGetError(err)) {
484
- return throwError(() => err);
485
- }
486
- return timer(2 ** (retryCount - 1) * 1000);
487
- },
488
- }),
489
- );
490
- }
475
+ // No automatic GET retry admin shells own Retry via UI
476
+ // (`africanies-select` showRetry, table error→refreshClick, error-state).
491
477
 
492
478
  if (this.config.timeout != null) {
493
479
  req$ = req$.pipe(
@@ -1,11 +1,15 @@
1
1
  import { HttpErrorResponse } from '@angular/common/http';
2
2
 
3
3
  /**
4
- * Whether a failed GET should be retried by {@link ApiClient}.
4
+ * Whether a failed GET *would* be a candidate for automatic retry.
5
+ *
6
+ * {@link ApiClient} no longer auto-retries (fail fast for manual UI Retry).
7
+ * Kept for callers/tests that still want to classify transient vs permanent
8
+ * failures.
9
+ *
10
+ * Transient: network blips, timeouts, 408/429, 5xx.
11
+ * Auth and other 4xx fail fast — retrying 401 does not help.
5
12
  *
6
- * Retries transient failures only (network blips, timeouts, 408/429, 5xx).
7
- * Auth and other 4xx errors fail fast — retrying 401 does not help and causes
8
- * duplicate requests + toasts.
9
13
  * @param err
10
14
  */
11
15
  export function isRetryableGetError(err: unknown): boolean {
@@ -9,8 +9,8 @@
9
9
  * (no caret/tilde): TanStack marks the Angular adapter experimental and
10
10
  * breaking changes land without major bumps.
11
11
  *
12
- * Retry/backoff here mirrors {@link ApiClient}'s GET retry (max 3,
13
- * exponential) so HTTP-layer and query-layer behavior stay aligned.
12
+ * Query retries default to **0** to match {@link ApiClient} (fail fast;
13
+ * screens use manual Retry). Apps can override per `QueryClient` if needed.
14
14
  */
15
15
 
16
16
  /**
@@ -23,9 +23,9 @@ export interface AfricaniesQueryClientDefaults {
23
23
  staleTime: number;
24
24
  /** Unused-query garbage-collection time (ms). */
25
25
  gcTime: number;
26
- /** Max failed-fetch retries for queries. */
26
+ /** Max failed-fetch retries for queries (default 0 — fail fast). */
27
27
  retry: number;
28
- /** Exponential delay matching ApiClient GET backoff. */
28
+ /** Delay between retries when {@link AfricaniesQueryClientDefaults.queries.retry} > 0. */
29
29
  retryDelay: (attemptIndex: number) => number;
30
30
  };
31
31
  mutations: {
@@ -82,8 +82,7 @@ export function createAfricaniesQueryClientDefaults(): AfricaniesQueryClientDefa
82
82
  queries: {
83
83
  staleTime: 60_000,
84
84
  gcTime: 5 * 60_000,
85
- retry: 3,
86
- // attemptIndex is 0-based in TanStack; match 1s, 2s, 4s style backoff.
85
+ retry: 0,
87
86
  retryDelay: (attemptIndex: number) =>
88
87
  Math.min(1000 * 2 ** attemptIndex, 30_000),
89
88
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@africanies/angular-web-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"africanies-africanies-theme.mjs","sources":["../../../../libs/africanies-theme/src/lib/mode-color.safelist.ts","../../../../libs/africanies-theme/src/lib/mode-color.service.ts","../../../../libs/africanies-theme/src/lib/theme.service.ts","../../../../libs/africanies-theme/src/africanies-africanies-theme.ts"],"sourcesContent":["/**\n * Tailwind safelist side-effect for shipping-mode color utilities.\n *\n * WHY this file exists: JIT/content scanning only keeps class names that appear\n * as *literal strings* in scanned sources. {@link ModeColorService} already\n * returns these literals, but keeping a dedicated comment list makes the\n * contract obvious for consumers who configure `safelist` or purge plugins.\n *\n * Do not rename these strings without updating ModeColorService and THEME.md.\n *\n * SFN (export / green):\n * text-export bg-export bg-export-subtle bg-export-light border-export\n * hover:bg-export-light hover:bg-export-subtle dark:bg-export/15 dark:hover:bg-export/15\n *\n * STN (import / orange):\n * text-import bg-import bg-import-subtle bg-import-light border-import\n * hover:bg-import-light hover:bg-import-subtle dark:bg-import/15 dark:hover:bg-import/15\n */\nexport const MODE_COLOR_SAFELIST = [\n 'text-export',\n 'bg-export',\n 'bg-export-subtle',\n 'bg-export-light',\n 'border-export',\n 'hover:bg-export-light',\n 'hover:bg-export-subtle',\n 'dark:bg-export/15',\n 'dark:hover:bg-export/15',\n 'text-import',\n 'bg-import',\n 'bg-import-subtle',\n 'bg-import-light',\n 'border-import',\n 'hover:bg-import-light',\n 'hover:bg-import-subtle',\n 'dark:bg-import/15',\n 'dark:hover:bg-import/15',\n] as const;\n","import { computed, inject, Injectable } from '@angular/core';\n\nimport { ShippingModeService } from '@africanies/africanies-core';\n\n/**\n * Tailwind class bundle for the active shipping mode (SFN export / STN import).\n *\n * Use these for **primary** product chrome: CTAs, selected controls, progress,\n * and accent text. Semantic colors (danger / warning) stay mode-independent.\n */\nexport interface ModeColorClasses {\n /** Text color utility, e.g. `text-export`. */\n text: string;\n /** Solid background utility, e.g. `bg-export`. */\n bg: string;\n /** Soft background utility, e.g. `bg-export-subtle`. */\n bgSubtle: string;\n /** Border matching the mode accent, e.g. `border-export`. */\n border: string;\n /**\n * Filled primary CTA — `variant=\"primary\"` on buttons.\n * Includes hover utility as a literal so Tailwind keeps it.\n */\n primary: string;\n /**\n * Transparent / text-only CTA — `variant=\"ghost-primary\"` on buttons.\n * Mode accent text + soft hover fill.\n */\n ghostPrimary: string;\n /**\n * Soft highlight for selected / active rows (works in dark mode).\n */\n soft: string;\n /**\n * Soft hover highlight for menus and lists.\n */\n softHover: string;\n}\n\n/**\n * Maps {@link ShippingModeService} to mode-accent Tailwind classes.\n *\n * - **SFN** → export green is primary\n * - **STN** → import orange is primary\n *\n * WHY literal class strings: Tailwind's scanner cannot see dynamically built\n * names like `` `text-${token}` ``. Returning full literals (`text-export`, …)\n * keeps utilities in the compiled CSS. See {@link MODE_COLOR_SAFELIST}.\n *\n * @example\n * ```html\n * @let colors = modeColor.classes();\n * <button type=\"button\" [class]=\"colors.primary\">Save</button>\n * <span [class]=\"colors.text\">Mode accent</span>\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class ModeColorService {\n private readonly shippingMode = inject(ShippingModeService);\n\n /**\n * Mode-dependent utility classes. Recomputes when shipping mode changes.\n */\n readonly classes = computed<ModeColorClasses>(() => {\n // Literal strings required for Tailwind content detection — do not interpolate.\n if (this.shippingMode.mode() === 'sfn') {\n return {\n text: 'text-export',\n bg: 'bg-export',\n bgSubtle: 'bg-export-subtle',\n border: 'border-export',\n primary:\n 'bg-export text-white border-transparent hover:bg-export-light',\n ghostPrimary:\n 'bg-transparent text-export border-transparent hover:bg-export-subtle dark:hover:bg-export/15',\n soft: 'bg-export-subtle dark:bg-export/15',\n softHover: 'hover:bg-export-subtle dark:hover:bg-export/15',\n };\n }\n return {\n text: 'text-import',\n bg: 'bg-import',\n bgSubtle: 'bg-import-subtle',\n border: 'border-import',\n primary:\n 'bg-import text-white border-transparent hover:bg-import-light',\n ghostPrimary:\n 'bg-transparent text-import border-transparent hover:bg-import-subtle dark:hover:bg-import/15',\n soft: 'bg-import-subtle dark:bg-import/15',\n softHover: 'hover:bg-import-subtle dark:hover:bg-import/15',\n };\n });\n}\n","import { DOCUMENT } from '@angular/common';\nimport { inject, Injectable, signal } from '@angular/core';\n\nimport { AFRICANIES_THEME_KEY, STORAGE_TOKEN } from '@africanies/africanies-storage';\n\nimport type { Theme } from './theme.types';\n\n/**\n * Application light/dark theme preference.\n *\n * WHY signals (not BehaviorSubject): theme is synchronous UI state read from\n * templates and other services; a signal avoids RxJS subscription boilerplate\n * and matches Angular 22 change detection. Persistence goes through\n * {@link STORAGE_TOKEN} so tests can swap storage without touching `localStorage`.\n *\n * Applies the Tailwind `darkMode: 'class'` contract by toggling `dark` on\n * `document.documentElement`, and sets `color-scheme` so native UI (date\n * pickers, scrollbars, form controls) matches the app theme — class-based\n * dark mode alone does not restyle browser chrome.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { inject, provideAppInitializer } from '@angular/core';\n * import { ThemeService } from '@africanies/africanies-theme';\n *\n * export const appConfig = {\n * providers: [\n * provideAppInitializer(() => {\n * inject(ThemeService); // applies stored / system theme once\n * }),\n * ],\n * };\n *\n * // In a component\n * const theme = inject(ThemeService);\n * theme.toggle();\n * theme.setTheme('dark');\n * const current = theme.theme(); // 'light' | 'dark'\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class ThemeService {\n private readonly storage = inject(STORAGE_TOKEN);\n private readonly document = inject(DOCUMENT);\n\n /**\n * Current theme. Prefer reading via `theme()` in templates / computed values\n * rather than caching the string, so dark-class consumers stay in sync.\n */\n readonly theme = signal<Theme>(this.resolveInitialTheme());\n\n constructor() {\n this.applyToDocument(this.theme());\n }\n\n /**\n * Sets and persists the theme, updating the `dark` class and `color-scheme`\n * on `<html>`.\n *\n * @param theme - Absolute preference to store.\n */\n setTheme(theme: Theme): void {\n this.theme.set(theme);\n this.applyToDocument(theme);\n try {\n this.storage.set(AFRICANIES_THEME_KEY, theme);\n } catch {\n // Persistence failure must not block the in-session visual toggle —\n // private browsing / quota issues are transient for theme preference.\n }\n }\n\n /**\n * Flips between light and dark.\n *\n * @returns The theme after the toggle.\n */\n toggle(): Theme {\n const next: Theme = this.theme() === 'light' ? 'dark' : 'light';\n this.setTheme(next);\n return next;\n }\n\n private resolveInitialTheme(): Theme {\n try {\n const stored = this.storage.get<Theme>(AFRICANIES_THEME_KEY);\n if (stored === 'light' || stored === 'dark') {\n return stored;\n }\n } catch {\n // Fall through to system preference when storage is unavailable.\n }\n return this.prefersDark() ? 'dark' : 'light';\n }\n\n private prefersDark(): boolean {\n const win = this.document.defaultView;\n return !!win?.matchMedia?.('(prefers-color-scheme: dark)').matches;\n }\n\n private applyToDocument(theme: Theme): void {\n const root = this.document.documentElement;\n if (theme === 'dark') {\n root.classList.add('dark');\n } else {\n root.classList.remove('dark');\n }\n // Native date/time pickers follow `color-scheme`, not Tailwind's `dark` class.\n root.style.colorScheme = theme;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;AAiBG;AACI,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,WAAW;IACX,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,uBAAuB;IACvB,wBAAwB;IACxB,mBAAmB;IACnB,yBAAyB;IACzB,aAAa;IACb,WAAW;IACX,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,uBAAuB;IACvB,wBAAwB;IACxB,mBAAmB;IACnB,yBAAyB;;;ACG3B;;;;;;;;;;;;;;;;AAgBG;MAEU,gBAAgB,CAAA;AACV,IAAA,YAAY,GAAG,MAAM,CAAC,mBAAmB,CAAC;AAE3D;;AAEG;AACM,IAAA,OAAO,GAAG,QAAQ,CAAmB,MAAK;;QAEjD,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,KAAK,EAAE;YACtC,OAAO;AACL,gBAAA,IAAI,EAAE,aAAa;AACnB,gBAAA,EAAE,EAAE,WAAW;AACf,gBAAA,QAAQ,EAAE,kBAAkB;AAC5B,gBAAA,MAAM,EAAE,eAAe;AACvB,gBAAA,OAAO,EACL,+DAA+D;AACjE,gBAAA,YAAY,EACV,8FAA8F;AAChG,gBAAA,IAAI,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AA;AAAZ,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA;;2FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACzClC;;AAEG;;;;"}
@@ -1,36 +0,0 @@
1
- {
2
- "name": "@africanies/africanies-theme",
3
- "version": "0.0.1",
4
- "peerDependencies": {
5
- "@angular/common": "^22.0.0",
6
- "@angular/core": "^22.0.0",
7
- "@africanies/africanies-core": "^0.0.2",
8
- "@africanies/africanies-storage": "^0.0.1"
9
- },
10
- "sideEffects": false,
11
- "publishConfig": {
12
- "registry": "https://npm.pkg.github.com",
13
- "access": "restricted"
14
- },
15
- "exports": {
16
- "./tailwind-preset": "./tailwind-preset.cjs",
17
- "./package.json": {
18
- "default": "./package.json"
19
- },
20
- ".": {
21
- "types": "./types/africanies-africanies-theme.d.ts",
22
- "default": "./fesm2022/africanies-africanies-theme.mjs"
23
- }
24
- },
25
- "files": [
26
- "**/*",
27
- "tailwind-preset.cjs",
28
- "THEME.md"
29
- ],
30
- "module": "fesm2022/africanies-africanies-theme.mjs",
31
- "typings": "types/africanies-africanies-theme.d.ts",
32
- "type": "module",
33
- "dependencies": {
34
- "tslib": "^2.3.0"
35
- }
36
- }
@@ -1,157 +0,0 @@
1
- import * as i0 from '@angular/core';
2
-
3
- /**
4
- * Tailwind safelist side-effect for shipping-mode color utilities.
5
- *
6
- * WHY this file exists: JIT/content scanning only keeps class names that appear
7
- * as *literal strings* in scanned sources. {@link ModeColorService} already
8
- * returns these literals, but keeping a dedicated comment list makes the
9
- * contract obvious for consumers who configure `safelist` or purge plugins.
10
- *
11
- * Do not rename these strings without updating ModeColorService and THEME.md.
12
- *
13
- * SFN (export / green):
14
- * text-export bg-export bg-export-subtle bg-export-light border-export
15
- * hover:bg-export-light hover:bg-export-subtle dark:bg-export/15 dark:hover:bg-export/15
16
- *
17
- * STN (import / orange):
18
- * text-import bg-import bg-import-subtle bg-import-light border-import
19
- * hover:bg-import-light hover:bg-import-subtle dark:bg-import/15 dark:hover:bg-import/15
20
- */
21
- declare const MODE_COLOR_SAFELIST: readonly ["text-export", "bg-export", "bg-export-subtle", "bg-export-light", "border-export", "hover:bg-export-light", "hover:bg-export-subtle", "dark:bg-export/15", "dark:hover:bg-export/15", "text-import", "bg-import", "bg-import-subtle", "bg-import-light", "border-import", "hover:bg-import-light", "hover:bg-import-subtle", "dark:bg-import/15", "dark:hover:bg-import/15"];
22
-
23
- /**
24
- * Tailwind class bundle for the active shipping mode (SFN export / STN import).
25
- *
26
- * Use these for **primary** product chrome: CTAs, selected controls, progress,
27
- * and accent text. Semantic colors (danger / warning) stay mode-independent.
28
- */
29
- interface ModeColorClasses {
30
- /** Text color utility, e.g. `text-export`. */
31
- text: string;
32
- /** Solid background utility, e.g. `bg-export`. */
33
- bg: string;
34
- /** Soft background utility, e.g. `bg-export-subtle`. */
35
- bgSubtle: string;
36
- /** Border matching the mode accent, e.g. `border-export`. */
37
- border: string;
38
- /**
39
- * Filled primary CTA — `variant="primary"` on buttons.
40
- * Includes hover utility as a literal so Tailwind keeps it.
41
- */
42
- primary: string;
43
- /**
44
- * Transparent / text-only CTA — `variant="ghost-primary"` on buttons.
45
- * Mode accent text + soft hover fill.
46
- */
47
- ghostPrimary: string;
48
- /**
49
- * Soft highlight for selected / active rows (works in dark mode).
50
- */
51
- soft: string;
52
- /**
53
- * Soft hover highlight for menus and lists.
54
- */
55
- softHover: string;
56
- }
57
- /**
58
- * Maps {@link ShippingModeService} to mode-accent Tailwind classes.
59
- *
60
- * - **SFN** → export green is primary
61
- * - **STN** → import orange is primary
62
- *
63
- * WHY literal class strings: Tailwind's scanner cannot see dynamically built
64
- * names like `` `text-${token}` ``. Returning full literals (`text-export`, …)
65
- * keeps utilities in the compiled CSS. See {@link MODE_COLOR_SAFELIST}.
66
- *
67
- * @example
68
- * ```html
69
- * @let colors = modeColor.classes();
70
- * <button type="button" [class]="colors.primary">Save</button>
71
- * <span [class]="colors.text">Mode accent</span>
72
- * ```
73
- */
74
- declare class ModeColorService {
75
- private readonly shippingMode;
76
- /**
77
- * Mode-dependent utility classes. Recomputes when shipping mode changes.
78
- */
79
- readonly classes: i0.Signal<ModeColorClasses>;
80
- static ɵfac: i0.ɵɵFactoryDeclaration<ModeColorService, never>;
81
- static ɵprov: i0.ɵɵInjectableDeclaration<ModeColorService>;
82
- }
83
-
84
- /**
85
- * Supported UI color schemes for {@link ThemeService}.
86
- *
87
- * Kept as a closed string union so storage values and DOM class toggles stay
88
- * aligned — unknown persisted strings are ignored and fall back to system
89
- * preference / light.
90
- */
91
- type Theme = 'light' | 'dark';
92
-
93
- /**
94
- * Application light/dark theme preference.
95
- *
96
- * WHY signals (not BehaviorSubject): theme is synchronous UI state read from
97
- * templates and other services; a signal avoids RxJS subscription boilerplate
98
- * and matches Angular 22 change detection. Persistence goes through
99
- * {@link STORAGE_TOKEN} so tests can swap storage without touching `localStorage`.
100
- *
101
- * Applies the Tailwind `darkMode: 'class'` contract by toggling `dark` on
102
- * `document.documentElement`, and sets `color-scheme` so native UI (date
103
- * pickers, scrollbars, form controls) matches the app theme — class-based
104
- * dark mode alone does not restyle browser chrome.
105
- *
106
- * @example
107
- * ```ts
108
- * // app.config.ts
109
- * import { inject, provideAppInitializer } from '@angular/core';
110
- * import { ThemeService } from '@africanies/africanies-theme';
111
- *
112
- * export const appConfig = {
113
- * providers: [
114
- * provideAppInitializer(() => {
115
- * inject(ThemeService); // applies stored / system theme once
116
- * }),
117
- * ],
118
- * };
119
- *
120
- * // In a component
121
- * const theme = inject(ThemeService);
122
- * theme.toggle();
123
- * theme.setTheme('dark');
124
- * const current = theme.theme(); // 'light' | 'dark'
125
- * ```
126
- */
127
- declare class ThemeService {
128
- private readonly storage;
129
- private readonly document;
130
- /**
131
- * Current theme. Prefer reading via `theme()` in templates / computed values
132
- * rather than caching the string, so dark-class consumers stay in sync.
133
- */
134
- readonly theme: i0.WritableSignal<Theme>;
135
- constructor();
136
- /**
137
- * Sets and persists the theme, updating the `dark` class and `color-scheme`
138
- * on `<html>`.
139
- *
140
- * @param theme - Absolute preference to store.
141
- */
142
- setTheme(theme: Theme): void;
143
- /**
144
- * Flips between light and dark.
145
- *
146
- * @returns The theme after the toggle.
147
- */
148
- toggle(): Theme;
149
- private resolveInitialTheme;
150
- private prefersDark;
151
- private applyToDocument;
152
- static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
153
- static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
154
- }
155
-
156
- export { MODE_COLOR_SAFELIST, ModeColorService, ThemeService };
157
- export type { ModeColorClasses, Theme };