@africanies/angular-web-sdk 0.1.9 → 0.1.11

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 (70) hide show
  1. package/.nx/cache/1149535958171016935/dist/libs/africanies-theme/README.md +46 -0
  2. package/.nx/cache/1149535958171016935/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +243 -0
  3. package/.nx/cache/1149535958171016935/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +1 -0
  4. package/.nx/cache/1149535958171016935/dist/libs/africanies-theme/package.json +35 -0
  5. package/.nx/cache/1149535958171016935/dist/libs/africanies-theme/tailwind-preset.cjs +330 -0
  6. package/.nx/cache/1149535958171016935/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +178 -0
  7. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/README.md +68 -0
  8. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  9. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  10. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +5 -0
  11. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/assets/carriers/dhl.svg +7 -0
  12. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +20013 -0
  13. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -0
  14. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/package.json +35 -0
  15. package/.nx/cache/14892813664845064572/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +5617 -0
  16. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/README.md +68 -0
  17. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  18. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  19. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +5 -0
  20. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/assets/carriers/dhl.svg +7 -0
  21. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +19998 -0
  22. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -0
  23. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/package.json +35 -0
  24. package/.nx/cache/3735952477975556635/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +5616 -0
  25. package/.nx/cache/run.json +18 -18
  26. package/.nx/cache/terminalOutputs/1149535958171016935 +21 -0
  27. package/.nx/cache/terminalOutputs/14892813664845064572 +21 -0
  28. package/.nx/cache/terminalOutputs/17909810599991457481 +40 -0
  29. package/.nx/cache/terminalOutputs/2927637324428060203 +42 -0
  30. package/.nx/cache/terminalOutputs/3735952477975556635 +21 -0
  31. package/.nx/cache/terminalOutputs/4787481949164239892 +8 -0
  32. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db +0 -0
  33. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-shm +0 -0
  34. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-wal +0 -0
  35. package/.nx/workspace-data/d/daemon.log +3807 -0
  36. package/.nx/workspace-data/d/server-process.json +2 -2
  37. package/.nx/workspace-data/file-map.json +3254 -3260
  38. package/.nx/workspace-data/nx_files.nxt +0 -0
  39. package/.nx/workspace-data/project-graph.json +2 -2
  40. package/README.md +0 -17
  41. package/apps/playground/src/app/pages/chip-page.ts +11 -1
  42. package/apps/playground/src/app/pages/tokens-page.ts +2 -2
  43. package/apps/playground/src/app/snippets/chip.snippets.ts +5 -0
  44. package/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +8 -8
  45. package/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +1 -1
  46. package/dist/libs/africanies-theme/tailwind-preset.cjs +3 -3
  47. package/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +5 -3
  48. package/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +986 -473
  49. package/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -1
  50. package/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +135 -39
  51. package/libs/africanies-theme/src/lib/mode-color.safelist.ts +2 -2
  52. package/libs/africanies-theme/src/lib/mode-color.service.spec.ts +9 -7
  53. package/libs/africanies-theme/src/lib/mode-color.service.ts +9 -7
  54. package/libs/africanies-theme/tailwind-preset.cjs +3 -3
  55. package/libs/africanies-ui/src/lib/avatar/avatar-menu.component.ts +25 -21
  56. package/libs/africanies-ui/src/lib/button/button.component.spec.ts +13 -8
  57. package/libs/africanies-ui/src/lib/chip/chip.component.ts +74 -6
  58. package/libs/africanies-ui/src/lib/layout/app-shell-header.component.ts +35 -12
  59. package/libs/africanies-ui/src/lib/layout/header-greeting.util.ts +2 -0
  60. package/libs/africanies-ui/src/lib/layout/header-weather.spec.ts +120 -9
  61. package/libs/africanies-ui/src/lib/layout/header-weather.ts +79 -18
  62. package/libs/africanies-ui/src/lib/navigation/segment/segment.component.ts +98 -22
  63. package/libs/africanies-ui/src/lib/navigation/shipping-mode-switch/shipping-mode-switch.component.spec.ts +15 -0
  64. package/libs/africanies-ui/src/lib/navigation/shipping-mode-switch/shipping-mode-switch.component.ts +195 -64
  65. package/libs/africanies-ui/src/lib/navigation/side-nav/africanies-side-nav.component.html +4 -2
  66. package/libs/africanies-ui/src/lib/navigation/side-nav/africanies-side-nav.component.ts +3 -1
  67. package/libs/africanies-ui/src/lib/table/table.component.spec.ts +3 -0
  68. package/libs/africanies-ui/src/lib/table/table.component.ts +254 -109
  69. package/package.json +1 -1
  70. package/tools/build-icon-sprite.mjs +1 -1
@@ -3,13 +3,46 @@ import {
3
3
  ChangeDetectionStrategy,
4
4
  Component,
5
5
  computed,
6
+ effect,
6
7
  inject,
7
8
  input,
9
+ model,
8
10
  } from '@angular/core';
9
11
 
10
12
  import { ShippingModeService } from '@africanies/africanies-core';
13
+ import { AfricaniesIconComponent } from '@africanies/africanies-icons';
11
14
  import type { ShippingMode } from '@africanies/africanies-models';
12
15
 
16
+ import { ChipComponent, type ChipVariant } from '../../chip/chip.component';
17
+
18
+ const PANEL_OPEN_STORAGE_KEY = 'africanies-shipping-mode-panel-open';
19
+
20
+ function readStoredPanelOpen(): boolean {
21
+ if (typeof localStorage === 'undefined') {
22
+ return true;
23
+ }
24
+ try {
25
+ const raw = localStorage.getItem(PANEL_OPEN_STORAGE_KEY);
26
+ if (raw === null) {
27
+ return true;
28
+ }
29
+ return raw !== '0' && raw !== 'false';
30
+ } catch {
31
+ return true;
32
+ }
33
+ }
34
+
35
+ function writeStoredPanelOpen(open: boolean): void {
36
+ if (typeof localStorage === 'undefined') {
37
+ return;
38
+ }
39
+ try {
40
+ localStorage.setItem(PANEL_OPEN_STORAGE_KEY, open ? '1' : '0');
41
+ } catch {
42
+ // Private mode / quota — panel still toggles in-session.
43
+ }
44
+ }
45
+
13
46
  /**
14
47
  * Shared globe + plane glyph for STN / SFN. STN paints it rotated 180°.
15
48
  *
@@ -25,12 +58,13 @@ const SHIPPING_MODE_GLYPH = `M88.42,68.75a48.8,48.8,0,0,1-4.74,11.1h9.89a7.67,7.
25
58
  * import orange; **from Nigeria** uses export green. Both tiles keep equal
26
59
  * chrome so unselected does not look like floating text.
27
60
  *
28
- * Project into `<africanies-side-nav>` with the `footer` attribute.
61
+ * Project into `<africanies-side-nav>` with the `pre-nav` attribute (above the
62
+ * nav list). `footer` still works for legacy placement under the list.
29
63
  *
30
64
  * @example
31
65
  * ```html
32
66
  * <africanies-side-nav [items]="nav" [(collapsed)]="collapsed">
33
- * <africanies-shipping-mode-switch footer [collapsed]="collapsed()" />
67
+ * <africanies-shipping-mode-switch pre-nav [collapsed]="collapsed()" />
34
68
  * </africanies-side-nav>
35
69
  * ```
36
70
  */
@@ -38,71 +72,143 @@ const SHIPPING_MODE_GLYPH = `M88.42,68.75a48.8,48.8,0,0,1-4.74,11.1h9.89a7.67,7.
38
72
  selector: 'africanies-shipping-mode-switch',
39
73
  standalone: true,
40
74
  changeDetection: ChangeDetectionStrategy.OnPush,
75
+ imports: [AfricaniesIconComponent, ChipComponent],
41
76
  host: {
42
77
  '[class]': 'hostClass()',
43
78
  },
44
79
  template: `
45
- @if (!collapsed()) {
46
- <p
47
- class="m-0 mb-2 px-1 text-caption font-semibold uppercase tracking-wide text-neutral-600 dark:text-neutral-400"
48
- >
49
- Shipping mode
50
- </p>
51
- }
52
- <div
53
- class="grid gap-1.5"
54
- [class.grid-cols-1]="collapsed()"
55
- [class.grid-cols-2]="!collapsed()"
56
- role="radiogroup"
57
- aria-label="Shipping mode"
58
- >
59
- <button
60
- type="button"
61
- role="radio"
62
- [attr.aria-checked]="mode() === 'stn'"
63
- aria-label="Shipping to Nigeria"
64
- [class]="cardClass('stn')"
65
- (click)="select('stn')"
80
+ @if (collapsed()) {
81
+ <!-- Narrow rail: icon tiles only — chip + chevron reads as cramped. -->
82
+ <div
83
+ class="grid grid-cols-1 gap-1.5"
84
+ role="radiogroup"
85
+ aria-label="Shipping mode"
66
86
  >
67
- <svg
68
- viewBox="0 0 122.88 107.54"
69
- class="h-6 w-6 shrink-0 rotate-180"
70
- aria-hidden="true"
71
- focusable="false"
87
+ <button
88
+ type="button"
89
+ role="radio"
90
+ [attr.aria-checked]="mode() === 'stn'"
91
+ aria-label="Shipping to Nigeria"
92
+ title="Shipping to Nigeria"
93
+ [class]="cardClass('stn')"
94
+ (click)="select('stn')"
72
95
  >
73
- <path [attr.d]="glyphPath()" fill="currentColor" />
74
- </svg>
75
- @if (!collapsed()) {
76
- <span class="flex flex-col leading-tight">
77
- <span>Shipping</span>
78
- <span>to Nigeria</span>
79
- </span>
80
- }
81
- </button>
82
- <button
83
- type="button"
84
- role="radio"
85
- [attr.aria-checked]="mode() === 'sfn'"
86
- aria-label="Shipping from Nigeria"
87
- [class]="cardClass('sfn')"
88
- (click)="select('sfn')"
89
- >
90
- <svg
91
- viewBox="0 0 122.88 107.54"
92
- class="h-6 w-6 shrink-0"
93
- aria-hidden="true"
94
- focusable="false"
96
+ <svg
97
+ viewBox="0 0 122.88 107.54"
98
+ class="h-5 w-5 shrink-0 rotate-180"
99
+ aria-hidden="true"
100
+ focusable="false"
101
+ >
102
+ <path [attr.d]="glyphPath()" fill="currentColor" />
103
+ </svg>
104
+ </button>
105
+ <button
106
+ type="button"
107
+ role="radio"
108
+ [attr.aria-checked]="mode() === 'sfn'"
109
+ aria-label="Shipping from Nigeria"
110
+ title="Shipping from Nigeria"
111
+ [class]="cardClass('sfn')"
112
+ (click)="select('sfn')"
113
+ >
114
+ <svg
115
+ viewBox="0 0 122.88 107.54"
116
+ class="h-5 w-5 shrink-0"
117
+ aria-hidden="true"
118
+ focusable="false"
119
+ >
120
+ <path [attr.d]="glyphPath()" fill="currentColor" />
121
+ </svg>
122
+ </button>
123
+ </div>
124
+ } @else {
125
+ <div class="mb-2 flex items-center gap-1.5">
126
+ <p
127
+ class="m-0 shrink-0 px-1 text-caption font-semibold uppercase tracking-wide text-neutral-600 dark:text-neutral-400"
95
128
  >
96
- <path [attr.d]="glyphPath()" fill="currentColor" />
97
- </svg>
98
- @if (!collapsed()) {
99
- <span class="flex flex-col leading-tight">
100
- <span>Shipping</span>
101
- <span>from Nigeria</span>
102
- </span>
129
+ Shipping mode
130
+ </p>
131
+ <!-- STN / SFN chip only when the tiles are collapsed — open panel already shows both modes. -->
132
+ @if (!panelOpen()) {
133
+ <africanies-chip [variant]="modeChipVariant()" size="sm">
134
+ {{ modeChipLabel() }}
135
+ </africanies-chip>
103
136
  }
104
- </button>
105
- </div>
137
+ <span class="min-w-0 flex-1" aria-hidden="true"></span>
138
+ <button
139
+ type="button"
140
+ class="inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-neutral-600 transition-colors hover:bg-background-hover hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus dark:text-neutral-400 dark:hover:bg-white/10 dark:hover:text-white"
141
+ [attr.aria-label]="
142
+ panelOpen() ? 'Hide shipping modes' : 'Show shipping modes'
143
+ "
144
+ [attr.aria-expanded]="panelOpen()"
145
+ (click)="togglePanel()"
146
+ >
147
+ <africanies-icon
148
+ [name]="panelOpen() ? 'chevron-up' : 'chevron-down'"
149
+ [size]="14"
150
+ />
151
+ </button>
152
+ </div>
153
+
154
+ <div
155
+ class="grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none"
156
+ [style.grid-template-rows]="panelOpen() ? '1fr' : '0fr'"
157
+ [attr.aria-hidden]="!panelOpen()"
158
+ [class.pointer-events-none]="!panelOpen()"
159
+ >
160
+ <div class="min-h-0 overflow-hidden">
161
+ <div
162
+ class="grid grid-cols-2 gap-1.5"
163
+ role="radiogroup"
164
+ aria-label="Shipping mode"
165
+ >
166
+ <button
167
+ type="button"
168
+ role="radio"
169
+ [attr.aria-checked]="mode() === 'stn'"
170
+ aria-label="Shipping to Nigeria"
171
+ [class]="cardClass('stn')"
172
+ (click)="select('stn')"
173
+ >
174
+ <svg
175
+ viewBox="0 0 122.88 107.54"
176
+ class="h-6 w-6 shrink-0 rotate-180"
177
+ aria-hidden="true"
178
+ focusable="false"
179
+ >
180
+ <path [attr.d]="glyphPath()" fill="currentColor" />
181
+ </svg>
182
+ <span class="flex flex-col leading-tight">
183
+ <span>Shipping</span>
184
+ <span>to Nigeria</span>
185
+ </span>
186
+ </button>
187
+ <button
188
+ type="button"
189
+ role="radio"
190
+ [attr.aria-checked]="mode() === 'sfn'"
191
+ aria-label="Shipping from Nigeria"
192
+ [class]="cardClass('sfn')"
193
+ (click)="select('sfn')"
194
+ >
195
+ <svg
196
+ viewBox="0 0 122.88 107.54"
197
+ class="h-6 w-6 shrink-0"
198
+ aria-hidden="true"
199
+ focusable="false"
200
+ >
201
+ <path [attr.d]="glyphPath()" fill="currentColor" />
202
+ </svg>
203
+ <span class="flex flex-col leading-tight">
204
+ <span>Shipping</span>
205
+ <span>from Nigeria</span>
206
+ </span>
207
+ </button>
208
+ </div>
209
+ </div>
210
+ </div>
211
+ }
106
212
  `,
107
213
  })
108
214
  export class ShippingModeSwitchComponent {
@@ -125,16 +231,41 @@ export class ShippingModeSwitchComponent {
125
231
  */
126
232
  readonly collapsed = input(false, { transform: booleanAttribute });
127
233
 
234
+ /**
235
+ * When true, the mode tiles are visible. Persisted in `localStorage`.
236
+ * Two-way bindable for hosts that need to force-open (e.g. onboarding).
237
+ */
238
+ readonly panelOpen = model(readStoredPanelOpen());
239
+
128
240
  /** Active mode from {@link ShippingModeService}. */
129
241
  protected readonly mode = this.shipping.mode;
130
242
 
131
- /** Host padding / divider — tighter when the rail is collapsed. */
243
+ protected readonly modeChipLabel = computed(() =>
244
+ this.mode() === 'stn' ? 'STN' : 'SFN',
245
+ );
246
+
247
+ protected readonly modeChipVariant = computed(
248
+ (): ChipVariant => (this.mode() === 'stn' ? 'import' : 'export'),
249
+ );
250
+
251
+ /** Host padding / divider — sits above the nav list (`border-b`). */
132
252
  protected readonly hostClass = computed(() =>
133
253
  this.collapsed()
134
- ? 'block shrink-0 border-t border-border px-1.5 py-3 dark:border-white/10'
135
- : 'block shrink-0 border-t border-border px-2 py-3 dark:border-white/10',
254
+ ? 'block shrink-0 border-b border-border px-1.5 py-2 dark:border-white/10'
255
+ : 'block shrink-0 border-b border-border px-2 py-2.5 dark:border-white/10',
136
256
  );
137
257
 
258
+ constructor() {
259
+ effect(() => {
260
+ writeStoredPanelOpen(this.panelOpen());
261
+ });
262
+ }
263
+
264
+ /** Show or hide the mode tiles. */
265
+ protected togglePanel(): void {
266
+ this.panelOpen.update((open) => !open);
267
+ }
268
+
138
269
  /**
139
270
  * Requests a mode change through {@link ShippingModeService.requestModeChange}
140
271
  * so feature guards (e.g. Create Shipment confirm) can run first.
@@ -160,7 +291,7 @@ export class ShippingModeSwitchComponent {
160
291
  const base =
161
292
  'flex w-full cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border text-center text-caption font-medium transition-colors ' +
162
293
  'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus ' +
163
- (compact ? 'min-h-9 px-1 py-1.5' : 'min-h-[4.5rem] px-1.5 py-2');
294
+ (compact ? 'size-9 min-h-0 px-0 py-0' : 'min-h-[4.5rem] px-1.5 py-2');
164
295
  const idle =
165
296
  'border-control bg-surface text-ink hover:bg-background-hover dark:border-white/15 dark:bg-ink-950 dark:text-white dark:hover:bg-white/10';
166
297
 
@@ -170,7 +301,7 @@ export class ShippingModeSwitchComponent {
170
301
  : `${base} ${idle}`;
171
302
  }
172
303
  return selected
173
- ? `${base} border-export-strong bg-export-strong text-white dark:border-export dark:bg-export`
304
+ ? `${base} border-export bg-export text-white dark:border-export dark:bg-export`
174
305
  : `${base} ${idle}`;
175
306
  }
176
307
  }
@@ -58,15 +58,17 @@
58
58
  </button>
59
59
  </div>
60
60
 
61
+ <ng-content select="[pre-nav]" />
62
+
61
63
  <nav
62
64
  class="africanies-overlay-scroll relative min-h-0 flex-1 overflow-y-auto overflow-x-visible px-3 py-3"
63
65
  >
64
66
  @if (!collapsed() && expandParents() && hasOpenBranches()) {
65
67
  <!-- Zero-height sticky host: keeps the control pinned without reserving a row. -->
66
- <div class="sticky top-0 z-10 h-0 overflow-visible">
68
+ <div class="sticky top-0 z-20 h-0 overflow-visible">
67
69
  <button
68
70
  type="button"
69
- class="absolute right-0 top-0 inline-flex size-7 cursor-pointer items-center justify-center rounded-md bg-surface text-neutral-600 shadow-sm ring-1 ring-border-strong transition-colors hover:bg-background-hover hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus dark:bg-ink-950 dark:text-neutral-400 dark:ring-white/15 dark:hover:bg-white/10 dark:hover:text-white"
71
+ class="absolute -right-2 -top-1 inline-flex size-7 cursor-pointer items-center justify-center rounded-md bg-surface text-neutral-600 shadow-sm ring-1 ring-border-strong transition-colors hover:bg-background-hover hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus dark:bg-ink-950 dark:text-neutral-400 dark:ring-white/15 dark:hover:bg-ink-surface dark:hover:text-white"
70
72
  data-onboarding="nav-branches-collapse"
71
73
  aria-label="Collapse all"
72
74
  (click)="collapseAllBranches()"
@@ -47,7 +47,9 @@ const DEFAULT_LINK_ACTIVE: IsActiveMatchOptions = {
47
47
  * **Expanded rail:** branches start open by default (`expandBranchesByDefault`).
48
48
  * Clicking a parent only opens/closes the branch (no route change). When any
49
49
  * branch is open, a sticky collapse-all control sits above the list (top right).
50
- * The rail expand/collapse control stays pinned in the logo header.
50
+ * The rail expand/collapse control stays pinned in the logo header. Project
51
+ * chrome above the scrollable list with `pre-nav` (e.g. shipping modes) or
52
+ * below with `footer`.
51
53
  * **Collapsed rail:** clicking a parent expands the rail, opens the
52
54
  * branch, and activates the first enabled child (router or `activeId`).
53
55
  *
@@ -1,6 +1,8 @@
1
1
  import { Component, signal } from '@angular/core';
2
2
  import { ComponentFixture, TestBed } from '@angular/core/testing';
3
3
 
4
+ import { of } from 'rxjs';
5
+
4
6
  import { ShippingModeService } from '@africanies/africanies-core';
5
7
  import type { ShippingMode } from '@africanies/africanies-models';
6
8
 
@@ -45,6 +47,7 @@ describe('TableComponent keep-rows loading', () => {
45
47
  provide: ShippingModeService,
46
48
  useValue: {
47
49
  mode: mode.asReadonly(),
50
+ requestModeChange: () => of(true),
48
51
  },
49
52
  },
50
53
  ],