@salesforce/ui-bundle-template-app-angular-template-b2e 11.30.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.
Files changed (161) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/.forceignore +15 -0
  3. package/dist/.husky/pre-commit +4 -0
  4. package/dist/.prettierignore +11 -0
  5. package/dist/.prettierrc +17 -0
  6. package/dist/CHANGELOG.md +3966 -0
  7. package/dist/README.md +77 -0
  8. package/dist/config/project-scratch-def.json +13 -0
  9. package/dist/eslint.config.js +7 -0
  10. package/dist/force-app/main/default/applications/angularinternalapp.app-meta.xml +17 -0
  11. package/dist/force-app/main/default/permissionsets/angularinternalapp_Access.permissionset-meta.xml +13 -0
  12. package/dist/force-app/main/default/uiBundles/angularinternalapp/.forceignore +15 -0
  13. package/dist/force-app/main/default/uiBundles/angularinternalapp/.postcssrc.json +5 -0
  14. package/dist/force-app/main/default/uiBundles/angularinternalapp/.prettierignore +8 -0
  15. package/dist/force-app/main/default/uiBundles/angularinternalapp/.prettierrc +12 -0
  16. package/dist/force-app/main/default/uiBundles/angularinternalapp/CHANGELOG.md +4 -0
  17. package/dist/force-app/main/default/uiBundles/angularinternalapp/README.md +85 -0
  18. package/dist/force-app/main/default/uiBundles/angularinternalapp/angular.json +98 -0
  19. package/dist/force-app/main/default/uiBundles/angularinternalapp/angularinternalapp.uibundle-meta.xml +8 -0
  20. package/dist/force-app/main/default/uiBundles/angularinternalapp/e2e/app.spec.ts +15 -0
  21. package/dist/force-app/main/default/uiBundles/angularinternalapp/esbuild/api-version.mjs +17 -0
  22. package/dist/force-app/main/default/uiBundles/angularinternalapp/eslint.config.js +60 -0
  23. package/dist/force-app/main/default/uiBundles/angularinternalapp/middleware/html.mjs +3 -0
  24. package/dist/force-app/main/default/uiBundles/angularinternalapp/middleware/proxy.mjs +12 -0
  25. package/dist/force-app/main/default/uiBundles/angularinternalapp/package.json +57 -0
  26. package/dist/force-app/main/default/uiBundles/angularinternalapp/playwright.config.ts +25 -0
  27. package/dist/force-app/main/default/uiBundles/angularinternalapp/public/favicon.ico +0 -0
  28. package/dist/force-app/main/default/uiBundles/angularinternalapp/scripts/rewrite-e2e-assets.mjs +30 -0
  29. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/account/account-search.service.ts +196 -0
  30. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/account/distinctAccountIndustries.ts +26 -0
  31. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/account/distinctAccountTypes.ts +26 -0
  32. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/account/getAccountDetail.ts +128 -0
  33. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/account/searchAccounts.ts +58 -0
  34. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/data-client.service.spec.ts +184 -0
  35. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/api/data-client.service.ts +74 -0
  36. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/app.config.ts +22 -0
  37. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/app.html +1 -0
  38. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/app.routes.ts +31 -0
  39. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/app.spec.ts +18 -0
  40. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/app.ts +15 -0
  41. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/layout/app-layout/app-layout.component.html +52 -0
  42. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/layout/app-layout/app-layout.component.spec.ts +90 -0
  43. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/layout/app-layout/app-layout.component.ts +67 -0
  44. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/_field-size.scss +42 -0
  45. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/alert/alert.component.html +31 -0
  46. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/alert/alert.component.ts +53 -0
  47. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/button/button.component.html +18 -0
  48. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/button/button.component.scss +112 -0
  49. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/button/button.component.ts +57 -0
  50. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/card/card.component.scss +34 -0
  51. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/card/card.component.ts +110 -0
  52. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/collapsible/collapsible.component.html +10 -0
  53. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/collapsible/collapsible.component.ts +26 -0
  54. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/date-picker/date-picker.component.html +25 -0
  55. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/date-picker/date-picker.component.scss +36 -0
  56. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/date-picker/date-picker.component.ts +41 -0
  57. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/date-range-picker/date-range-picker.component.html +34 -0
  58. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/date-range-picker/date-range-picker.component.scss +33 -0
  59. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/date-range-picker/date-range-picker.component.ts +66 -0
  60. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/dialog/dialog.component.html +37 -0
  61. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/dialog/dialog.component.ts +55 -0
  62. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/field/field.component.html +21 -0
  63. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/field/field.component.ts +36 -0
  64. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/field-size.ts +8 -0
  65. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/input/input.component.html +19 -0
  66. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/input/input.component.scss +35 -0
  67. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/input/input.component.ts +36 -0
  68. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/label/label.component.html +3 -0
  69. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/label/label.component.ts +17 -0
  70. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/paginator/paginator.component.html +10 -0
  71. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/paginator/paginator.component.ts +37 -0
  72. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/popover/popover.component.html +41 -0
  73. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/popover/popover.component.ts +40 -0
  74. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/select/select.component.html +24 -0
  75. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/select/select.component.scss +35 -0
  76. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/select/select.component.ts +72 -0
  77. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/separator/separator.component.html +1 -0
  78. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/separator/separator.component.scss +23 -0
  79. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/separator/separator.component.ts +56 -0
  80. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/skeleton/skeleton.component.html +1 -0
  81. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/skeleton/skeleton.component.scss +28 -0
  82. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/skeleton/skeleton.component.ts +24 -0
  83. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/components/ui/spinner/spinner.component.ts +35 -0
  84. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/agentforce/agentforce-conversation-client/agentforce-conversation-client.component.html +3 -0
  85. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/agentforce/agentforce-conversation-client/agentforce-conversation-client.component.ts +119 -0
  86. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/agentforce/agentforce-embed.service.ts +177 -0
  87. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/active-filters/active-filters.component.html +23 -0
  88. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/active-filters/active-filters.component.ts +78 -0
  89. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/date-filter/date-filter.component.html +18 -0
  90. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/date-filter/date-filter.component.ts +137 -0
  91. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/date-range-filter/date-range-filter.component.html +11 -0
  92. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/date-range-filter/date-range-filter.component.ts +69 -0
  93. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/filter-field-wrapper/filter-field-wrapper.component.html +11 -0
  94. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/filter-field-wrapper/filter-field-wrapper.component.ts +36 -0
  95. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/multi-select-filter/multi-select-filter.component.html +10 -0
  96. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/multi-select-filter/multi-select-filter.component.ts +58 -0
  97. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/numeric-range-filter/numeric-range-filter.component.html +22 -0
  98. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/numeric-range-filter/numeric-range-filter.component.ts +146 -0
  99. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/search-filter/search-filter.component.html +8 -0
  100. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/search-filter/search-filter.component.ts +82 -0
  101. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/select-filter/select-filter.component.html +12 -0
  102. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/select-filter/select-filter.component.ts +65 -0
  103. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/text-filter/text-filter.component.html +12 -0
  104. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/filters/text-filter/text-filter.component.ts +90 -0
  105. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/object-breadcrumb/object-breadcrumb.component.html +55 -0
  106. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/object-breadcrumb/object-breadcrumb.component.ts +40 -0
  107. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/pagination-controls/pagination-controls.component.html +8 -0
  108. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/pagination-controls/pagination-controls.component.ts +61 -0
  109. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/search-bar/search-bar.component.html +59 -0
  110. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/search-bar/search-bar.component.ts +108 -0
  111. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/sort-control/sort-control.component.html +50 -0
  112. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/components/sort-control/sort-control.component.ts +72 -0
  113. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/object-search-state.service.ts +232 -0
  114. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/utils/debounce.ts +31 -0
  115. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/utils/field-utils.ts +54 -0
  116. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/utils/filter-utils.ts +354 -0
  117. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/utils/index.ts +12 -0
  118. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/features/object-search/utils/sort-utils.ts +46 -0
  119. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/account-detail/account-detail-page.component.html +174 -0
  120. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/account-detail/account-detail-page.component.scss +7 -0
  121. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/account-detail/account-detail-page.component.ts +199 -0
  122. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/account-search/account-search-page.component.html +111 -0
  123. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/account-search/account-search-page.component.ts +217 -0
  124. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/home/home-page.component.html +18 -0
  125. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/home/home-page.component.ts +47 -0
  126. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/home/home.component.html +6 -0
  127. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/home/home.component.spec.ts +23 -0
  128. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/home/home.component.ts +13 -0
  129. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/not-found/not-found.component.html +12 -0
  130. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/not-found/not-found.component.spec.ts +33 -0
  131. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/pages/not-found/not-found.component.ts +15 -0
  132. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/types/conversation.ts +55 -0
  133. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/types/globals.d.ts +13 -0
  134. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/app/utils/async-data.ts +99 -0
  135. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/index.html +14 -0
  136. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/index.ts +15 -0
  137. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/main.ts +5 -0
  138. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/styles.scss +170 -0
  139. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/theme.scss +39 -0
  140. package/dist/force-app/main/default/uiBundles/angularinternalapp/src/types/sf-globals.d.ts +9 -0
  141. package/dist/force-app/main/default/uiBundles/angularinternalapp/tsconfig.app.json +11 -0
  142. package/dist/force-app/main/default/uiBundles/angularinternalapp/tsconfig.json +33 -0
  143. package/dist/force-app/main/default/uiBundles/angularinternalapp/tsconfig.spec.json +10 -0
  144. package/dist/force-app/main/default/uiBundles/angularinternalapp/ui-bundle.json +7 -0
  145. package/dist/jest.config.js +6 -0
  146. package/dist/package-lock.json +10066 -0
  147. package/dist/package.json +46 -0
  148. package/dist/scripts/apex/hello.apex +10 -0
  149. package/dist/scripts/gitignore-templates.json +4 -0
  150. package/dist/scripts/graphql-search.sh +191 -0
  151. package/dist/scripts/org-setup-config-schema.mjs +103 -0
  152. package/dist/scripts/org-setup-dev.mjs +87 -0
  153. package/dist/scripts/org-setup-utils.mjs +369 -0
  154. package/dist/scripts/org-setup-xml.mjs +182 -0
  155. package/dist/scripts/org-setup.config.json +9 -0
  156. package/dist/scripts/org-setup.mjs +1702 -0
  157. package/dist/scripts/sf-project-setup.mjs +103 -0
  158. package/dist/scripts/soql/account.soql +6 -0
  159. package/dist/scripts/validate-org-setup-config.mjs +38 -0
  160. package/dist/sfdx-project.json +12 -0
  161. package/package.json +40 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import {
7
+ ChangeDetectionStrategy,
8
+ Component,
9
+ computed,
10
+ DestroyRef,
11
+ inject,
12
+ input,
13
+ type OnInit,
14
+ signal,
15
+ } from "@angular/core";
16
+ import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
17
+ import { debounceTime } from "rxjs/operators";
18
+ import { ButtonComponent } from "../../../../components/ui/button/button.component";
19
+ import { InputComponent } from "../../../../components/ui/input/input.component";
20
+ import { PopoverComponent } from "../../../../components/ui/popover/popover.component";
21
+ import { ObjectSearchStateService } from "../../object-search-state.service";
22
+ import type { FilterFieldConfig } from "../../utils/filter-utils";
23
+
24
+ /** How long to wait after the last keystroke before writing to state. */
25
+ const SEARCH_DEBOUNCE_MS = 300;
26
+
27
+ /**
28
+ * Search-bar header for an object-search page: a debounced text input bound to
29
+ * the `search` filter, plus an optional filter popover that content-projects
30
+ * the sibling filter components (owned by the filters wave).
31
+ *
32
+ * Mirrors the React `SearchBar`, with the composed additions from the ground-
33
+ * truth example page (filter panel toggle). Filter components are NOT imported
34
+ * here — the hosting page projects them via the `[filters]` slot so the
35
+ * feature can pick which filters it renders.
36
+ *
37
+ * ## Usage
38
+ * ```html
39
+ * <app-search-bar [searchConfig]="searchCfg" [filterConfigs]="filterCfgs">
40
+ * <div filters>
41
+ * <app-text-filter .../>
42
+ * <app-select-filter .../>
43
+ * </div>
44
+ * </app-search-bar>
45
+ * ```
46
+ */
47
+ @Component({
48
+ selector: "app-search-bar",
49
+ changeDetection: ChangeDetectionStrategy.OnPush,
50
+ imports: [ButtonComponent, InputComponent, PopoverComponent],
51
+ templateUrl: "./search-bar.component.html",
52
+ })
53
+ export class SearchBarComponent implements OnInit {
54
+ /** Config for the multi-field search filter (its label, placeholder, etc.). */
55
+ readonly searchConfig = input.required<FilterFieldConfig>();
56
+ /**
57
+ * Configs for the filters projected into the popover. Not consumed directly
58
+ * here — surfaced so the hosting page and this component agree on which
59
+ * filters exist, and reserved for a future filter-count badge.
60
+ */
61
+ readonly filterConfigs = input<FilterFieldConfig[]>([]);
62
+
63
+ private readonly state = inject(ObjectSearchStateService);
64
+ private readonly destroyRef = inject(DestroyRef);
65
+
66
+ /** Local, debounced mirror of the search filter's `value`. */
67
+ protected readonly term = signal<string>("");
68
+ protected readonly popoverOpen = signal<boolean>(false);
69
+
70
+ /** Count of currently active filters minus the search itself (for the badge). */
71
+ protected readonly nonSearchFilterCount = computed(
72
+ () => this.state.filters().filter((f) => f.type !== "search").length,
73
+ );
74
+
75
+ constructor() {
76
+ // Required inputs are not yet resolved in the constructor, so the search
77
+ // config is read lazily inside the subscription (which emits after init).
78
+ toObservable(this.term)
79
+ .pipe(debounceTime(SEARCH_DEBOUNCE_MS), takeUntilDestroyed(this.destroyRef))
80
+ .subscribe((value) => {
81
+ const cfg = this.searchConfig();
82
+ if (value) {
83
+ this.state.setFilter(cfg.field, {
84
+ field: cfg.field,
85
+ label: cfg.label,
86
+ type: cfg.type,
87
+ value,
88
+ });
89
+ } else {
90
+ this.state.removeFilter(cfg.field);
91
+ }
92
+ });
93
+ }
94
+
95
+ ngOnInit(): void {
96
+ // Seed the local term from any existing search filter (deep-link support).
97
+ // Done here (not the constructor) so the required `searchConfig` input is
98
+ // resolved before it is read.
99
+ const existing = this.state.filterFor(this.searchConfig().field);
100
+ if (existing?.value) {
101
+ this.term.set(existing.value);
102
+ }
103
+ }
104
+
105
+ protected togglePopover(): void {
106
+ this.popoverOpen.set(!this.popoverOpen());
107
+ }
108
+ }
@@ -0,0 +1,50 @@
1
+ <div class="flex items-center gap-2">
2
+ <span class="text-sm text-muted-foreground whitespace-nowrap">{{ label() }}</span>
3
+ <app-select
4
+ class="w-[160px]"
5
+ [options]="options()"
6
+ [value]="selectedValue()"
7
+ (valueChange)="onFieldChange($event)"
8
+ placeholder="Default"
9
+ />
10
+ @if (sort(); as active) {
11
+ <app-button
12
+ appearance="text"
13
+ size="icon-sm"
14
+ [attr.aria-label]="'Sort ' + (active.direction === 'ASC' ? 'descending' : 'ascending')"
15
+ (clicked)="toggleDirection()"
16
+ >
17
+ @if (active.direction === "ASC") {
18
+ <svg
19
+ xmlns="http://www.w3.org/2000/svg"
20
+ class="h-4 w-4"
21
+ viewBox="0 0 24 24"
22
+ fill="none"
23
+ stroke="currentColor"
24
+ stroke-width="2"
25
+ stroke-linecap="round"
26
+ stroke-linejoin="round"
27
+ aria-hidden="true"
28
+ >
29
+ <path d="m5 12 7-7 7 7" />
30
+ <path d="M12 19V5" />
31
+ </svg>
32
+ } @else {
33
+ <svg
34
+ xmlns="http://www.w3.org/2000/svg"
35
+ class="h-4 w-4"
36
+ viewBox="0 0 24 24"
37
+ fill="none"
38
+ stroke="currentColor"
39
+ stroke-width="2"
40
+ stroke-linecap="round"
41
+ stroke-linejoin="round"
42
+ aria-hidden="true"
43
+ >
44
+ <path d="M12 5v14" />
45
+ <path d="m19 12-7 7-7-7" />
46
+ </svg>
47
+ }
48
+ </app-button>
49
+ }
50
+ </div>
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import { ChangeDetectionStrategy, Component, computed, inject, input } from "@angular/core";
7
+ import { ButtonComponent } from "../../../../components/ui/button/button.component";
8
+ import {
9
+ SelectComponent,
10
+ type AppSelectOption,
11
+ } from "../../../../components/ui/select/select.component";
12
+ import { ObjectSearchStateService } from "../../object-search-state.service";
13
+ import type { SortFieldConfig, SortState } from "../../utils/sort-utils";
14
+
15
+ /** Sentinel value used in the select to represent "no sort". */
16
+ const NONE_VALUE = "__none__";
17
+
18
+ /**
19
+ * Sort field + direction toggle. Mirrors the React `SortControl`.
20
+ *
21
+ * Reads `sort()` from the {@link ObjectSearchStateService} and drives changes
22
+ * via `setSort`. Choosing a field applies ASC by default; the direction button
23
+ * flips ASC/DESC and only appears while a sort is active. Selecting `Default`
24
+ * clears the sort (`setSort(null)`).
25
+ */
26
+ @Component({
27
+ selector: "app-sort-control",
28
+ changeDetection: ChangeDetectionStrategy.OnPush,
29
+ imports: [ButtonComponent, SelectComponent],
30
+ templateUrl: "./sort-control.component.html",
31
+ })
32
+ export class SortControlComponent {
33
+ /** Sortable fields to expose in the select. */
34
+ readonly sortFields = input.required<SortFieldConfig[]>();
35
+ /** Override for the leading label (default `Sort by`). */
36
+ readonly label = input<string>("Sort by");
37
+
38
+ private readonly state = inject(ObjectSearchStateService);
39
+ /** Current sort state from the shared state service. */
40
+ protected readonly sort = this.state.sort;
41
+
42
+ /** Select options — the `Default` sentinel plus one per sortable field. */
43
+ protected readonly options = computed<AppSelectOption[]>(() => [
44
+ { value: NONE_VALUE, label: "Default" },
45
+ ...this.sortFields().map((c) => ({ value: c.field, label: c.label })),
46
+ ]);
47
+
48
+ /** Value shown in the select — either the current field or the sentinel. */
49
+ protected readonly selectedValue = computed(() => this.sort()?.field ?? NONE_VALUE);
50
+
51
+ protected onFieldChange(field: string): void {
52
+ if (field === NONE_VALUE) {
53
+ this.state.setSort(null);
54
+ return;
55
+ }
56
+ const current = this.sort();
57
+ const next: SortState = {
58
+ field,
59
+ direction: current?.direction ?? "ASC",
60
+ };
61
+ this.state.setSort(next);
62
+ }
63
+
64
+ protected toggleDirection(): void {
65
+ const current = this.sort();
66
+ if (!current) return;
67
+ this.state.setSort({
68
+ field: current.field,
69
+ direction: current.direction === "ASC" ? "DESC" : "ASC",
70
+ });
71
+ }
72
+ }
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import { computed, DestroyRef, inject, Injectable, signal, type Signal } from "@angular/core";
7
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
8
+ import { ActivatedRoute, Router } from "@angular/router";
9
+ import { Subject } from "rxjs";
10
+ import { debounceTime } from "rxjs/operators";
11
+ import {
12
+ buildFilter,
13
+ filtersToQueryParams,
14
+ queryParamsToFilters,
15
+ type ActiveFilterValue,
16
+ type FilterFieldConfig,
17
+ } from "./utils/filter-utils";
18
+ import { buildOrderBy, type SortState } from "./utils/sort-utils";
19
+
20
+ /** How long to wait before flushing state changes to the URL. */
21
+ const URL_SYNC_DEBOUNCE_MS = 300;
22
+
23
+ /** Cursor-pagination configuration for an object-search page. */
24
+ export interface PaginationConfig {
25
+ defaultPageSize: number;
26
+ validPageSizes: number[];
27
+ }
28
+
29
+ /** Derived, API-ready query signals returned from {@link ObjectSearchStateService.init}. */
30
+ export interface ObjectSearchQuery<TFilter, TOrderBy> {
31
+ where: Signal<TFilter | undefined>;
32
+ orderBy: Signal<TOrderBy | undefined>;
33
+ }
34
+
35
+ /**
36
+ * Filter / sort / cursor-pagination state for one object-search page — the
37
+ * Angular analogue of the React `useObjectSearchParams` hook plus
38
+ * `FilterContext`.
39
+ *
40
+ * ## State model
41
+ * Signals drive instant UI updates. The URL query params are the durable source
42
+ * of truth so a refresh or shared link restores the same view. URL writes are
43
+ * debounced (300 ms) to avoid history spam.
44
+ *
45
+ * Unlike the React reference, the pagination cursor (`after`) is part of the URL
46
+ * (see {@link filtersToQueryParams}), so a deep-linked page N fetches page N's
47
+ * rows rather than page 1's rows shown under a higher page number.
48
+ *
49
+ * ## Scope
50
+ * Provide per route/component (`providers: [ObjectSearchStateService]`), NOT in
51
+ * root — each search page owns its own state and cursor stack.
52
+ *
53
+ * ## Usage
54
+ * Call {@link init} once from the hosting component with the field/pagination
55
+ * config, then read the exposed signals and call the mutators.
56
+ */
57
+ @Injectable()
58
+ export class ObjectSearchStateService {
59
+ private readonly router = inject(Router);
60
+ private readonly route = inject(ActivatedRoute);
61
+ private readonly destroyRef = inject(DestroyRef);
62
+
63
+ private filterConfigs: FilterFieldConfig[] = [];
64
+ private defaultPageSize = 10;
65
+ private validPageSizes: number[] = [10];
66
+ private initialized = false;
67
+
68
+ // -- Core state signals -----------------------------------------------------
69
+ private readonly _filters = signal<ActiveFilterValue[]>([]);
70
+ private readonly _sort = signal<SortState | null>(null);
71
+ private readonly _pageSize = signal<number>(10);
72
+ private readonly _pageIndex = signal<number>(0);
73
+ private readonly _afterCursor = signal<string | undefined>(undefined);
74
+
75
+ /** Cursor stack for "previous page" — mirrors the React ref-held stack. */
76
+ private cursorStack: string[] = [];
77
+ /** Coalesces rapid state changes into a single debounced URL write. */
78
+ private readonly urlSync$ = new Subject<void>();
79
+
80
+ // -- Public read signals -----------------------------------------------------
81
+ readonly filters: Signal<ActiveFilterValue[]> = this._filters.asReadonly();
82
+ readonly sort: Signal<SortState | null> = this._sort.asReadonly();
83
+ readonly pageSize: Signal<number> = this._pageSize.asReadonly();
84
+ readonly pageIndex: Signal<number> = this._pageIndex.asReadonly();
85
+ readonly afterCursor: Signal<string | undefined> = this._afterCursor.asReadonly();
86
+ readonly hasActiveFilters = computed(() => this._filters().length > 0);
87
+ readonly hasPreviousPage = computed(() => this._pageIndex() > 0);
88
+
89
+ constructor() {
90
+ this.urlSync$
91
+ .pipe(debounceTime(URL_SYNC_DEBOUNCE_MS), takeUntilDestroyed(this.destroyRef))
92
+ .subscribe(() => this.flushToUrl());
93
+ }
94
+
95
+ /**
96
+ * Initializes the service from the given config and seeds state from the
97
+ * current URL. Safe to call once; subsequent calls only recompute the
98
+ * derived query signals.
99
+ */
100
+ init<TFilter, TOrderBy>(
101
+ filterConfigs: FilterFieldConfig[],
102
+ paginationConfig?: PaginationConfig,
103
+ ): ObjectSearchQuery<TFilter, TOrderBy> {
104
+ if (!this.initialized) {
105
+ this.initialized = true;
106
+ this.filterConfigs = filterConfigs;
107
+ this.defaultPageSize = paginationConfig?.defaultPageSize ?? 10;
108
+ this.validPageSizes = paginationConfig?.validPageSizes ?? [this.defaultPageSize];
109
+ this.seedFromUrl();
110
+ }
111
+
112
+ const where = computed(() => buildFilter<TFilter>(this._filters(), this.filterConfigs));
113
+ const orderBy = computed(() => buildOrderBy<TOrderBy>(this._sort()));
114
+ return { where, orderBy };
115
+ }
116
+
117
+ // -- Filter mutators ---------------------------------------------------------
118
+
119
+ /** Adds or replaces the filter for `field`; `undefined` removes it. */
120
+ setFilter(field: string, value: ActiveFilterValue | undefined): void {
121
+ this._filters.update((prev) => {
122
+ const next = prev.filter((f) => f.field !== field);
123
+ if (value) next.push(value);
124
+ return next;
125
+ });
126
+ this.resetPagination();
127
+ this.urlSync$.next();
128
+ }
129
+
130
+ /** Removes the active filter for `field`, if any. */
131
+ removeFilter(field: string): void {
132
+ this._filters.update((prev) => prev.filter((f) => f.field !== field));
133
+ this.resetPagination();
134
+ this.urlSync$.next();
135
+ }
136
+
137
+ /** Reads the active filter value for a field (for filter components). */
138
+ filterFor(field: string): ActiveFilterValue | undefined {
139
+ return this._filters().find((f) => f.field === field);
140
+ }
141
+
142
+ // -- Sort mutator ------------------------------------------------------------
143
+
144
+ /** Sets (or clears) the sort; resets pagination to the first page. */
145
+ setSort(sort: SortState | null): void {
146
+ this._sort.set(sort);
147
+ this.resetPagination();
148
+ this.urlSync$.next();
149
+ }
150
+
151
+ // -- Pagination mutators -----------------------------------------------------
152
+
153
+ /** Advances to the next page using the supplied `endCursor`. */
154
+ goToNextPage(endCursor: string): void {
155
+ this.cursorStack = [...this.cursorStack, endCursor];
156
+ this._afterCursor.set(endCursor);
157
+ this._pageIndex.update((i) => i + 1);
158
+ this.urlSync$.next();
159
+ }
160
+
161
+ /** Returns to the previous page by popping the cursor stack. */
162
+ goToPreviousPage(): void {
163
+ this.cursorStack = this.cursorStack.slice(0, -1);
164
+ const prev =
165
+ this.cursorStack.length > 0 ? this.cursorStack[this.cursorStack.length - 1] : undefined;
166
+ this._afterCursor.set(prev);
167
+ this._pageIndex.update((i) => Math.max(0, i - 1));
168
+ this.urlSync$.next();
169
+ }
170
+
171
+ /** Sets a validated page size and resets pagination. */
172
+ setPageSize(size: number): void {
173
+ this._pageSize.set(this.getValidPageSize(size));
174
+ this.resetPagination();
175
+ this.urlSync$.next();
176
+ }
177
+
178
+ // -- Reset -------------------------------------------------------------------
179
+
180
+ /** Clears all filters, sort, and pagination in one call (flushed at once). */
181
+ resetAll(): void {
182
+ this._filters.set([]);
183
+ this._sort.set(null);
184
+ this._pageSize.set(this.defaultPageSize);
185
+ this.resetPagination();
186
+ this.flushToUrl();
187
+ }
188
+
189
+ // -- Internals ---------------------------------------------------------------
190
+
191
+ private resetPagination(): void {
192
+ this._pageIndex.set(0);
193
+ this._afterCursor.set(undefined);
194
+ this.cursorStack = [];
195
+ }
196
+
197
+ private getValidPageSize(size: number): number {
198
+ return this.validPageSizes.includes(size) ? size : this.defaultPageSize;
199
+ }
200
+
201
+ private seedFromUrl(): void {
202
+ const params = this.route.snapshot.queryParams as Record<string, string | undefined>;
203
+ const parsed = queryParamsToFilters(params, this.filterConfigs);
204
+ this._filters.set(parsed.filters);
205
+ this._sort.set(parsed.sort);
206
+ this._pageSize.set(this.getValidPageSize(parsed.pageSize ?? this.defaultPageSize));
207
+ this._pageIndex.set(parsed.pageIndex);
208
+ this._afterCursor.set(parsed.afterCursor);
209
+ // Rebuild a minimal cursor stack so "previous" works after a deep link.
210
+ // Pages before the current one are unknown, so pad the stack with the
211
+ // current cursor; going back drains it and eventually returns to page 1.
212
+ if (parsed.pageIndex > 0 && parsed.afterCursor) {
213
+ this.cursorStack = Array<string>(parsed.pageIndex).fill(parsed.afterCursor);
214
+ }
215
+ }
216
+
217
+ private flushToUrl(): void {
218
+ const queryParams = filtersToQueryParams({
219
+ filters: this._filters(),
220
+ sort: this._sort(),
221
+ pageSize: this._pageSize(),
222
+ pageIndex: this._pageIndex(),
223
+ afterCursor: this._afterCursor(),
224
+ });
225
+ void this.router.navigate([], {
226
+ relativeTo: this.route,
227
+ queryParams,
228
+ // Replace so filter typing doesn't flood browser history.
229
+ replaceUrl: true,
230
+ });
231
+ }
232
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /** Default debounce delay for keystroke-driven filter inputs (search, text, numeric). */
8
+ export const FILTER_DEBOUNCE_MS = 300;
9
+
10
+ /**
11
+ * Creates a debounced version of the provided function.
12
+ *
13
+ * Each call to the returned function resets the internal timer. The wrapped
14
+ * function is only invoked once the timer expires without being reset. This
15
+ * makes it ideal for rate-limiting high-frequency events like input changes.
16
+ *
17
+ * @typeParam T - The function signature to debounce.
18
+ * @param fn - The function to debounce.
19
+ * @param ms - The debounce delay in milliseconds.
20
+ * @returns A new function with the same signature that delays execution.
21
+ */
22
+ export function debounce<T extends (...args: never[]) => void>(
23
+ fn: T,
24
+ ms: number,
25
+ ): (...args: Parameters<T>) => void {
26
+ let timer: ReturnType<typeof setTimeout> | undefined;
27
+ return (...args: Parameters<T>) => {
28
+ clearTimeout(timer);
29
+ timer = setTimeout(() => fn(...args), ms);
30
+ };
31
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /** A Salesforce GraphQL scalar field: `{ value, displayValue }`. */
8
+ export interface UiField {
9
+ displayValue?: string | null;
10
+ value?: unknown;
11
+ }
12
+
13
+ /**
14
+ * Extracts a human-readable string from a Salesforce GraphQL scalar field,
15
+ * preferring the server-formatted `displayValue` over the raw `value`.
16
+ *
17
+ * @returns The display string, or `null` when the field is empty.
18
+ */
19
+ export function fieldValue(field: UiField | null | undefined): string | null {
20
+ if (field?.displayValue != null) return field.displayValue;
21
+ if (field?.value != null) return String(field.value);
22
+ return null;
23
+ }
24
+
25
+ /**
26
+ * Formats a Salesforce address into display lines (street / city-state-zip /
27
+ * country), omitting empty parts. Returns `null` when nothing is present.
28
+ */
29
+ export function getAddressFieldLines(address: {
30
+ street?: string | null;
31
+ city?: string | null;
32
+ state?: string | null;
33
+ postalCode?: string | null;
34
+ country?: string | null;
35
+ }): string[] | null {
36
+ const cityStateZip = [address.city, address.state].filter(Boolean).join(", ");
37
+ const cityStateZipLine = [cityStateZip, address.postalCode].filter(Boolean).join(" ");
38
+ const lines = [address.street, cityStateZipLine, address.country].filter(Boolean) as string[];
39
+ if (lines.length === 0) return null;
40
+ return lines;
41
+ }
42
+
43
+ /**
44
+ * Formats an ISO datetime string via `Intl`/`toLocaleString`. Returns `null`
45
+ * for empty input so callers can fall back cleanly.
46
+ */
47
+ export function formatDateTimeField(
48
+ value: string | null | undefined,
49
+ locales?: Intl.LocalesArgument,
50
+ options?: Intl.DateTimeFormatOptions,
51
+ ): string | null {
52
+ if (!value) return null;
53
+ return new Date(value).toLocaleString(locales, options);
54
+ }