@salesforce/ui-bundle-template-feature-angular-search 0.0.0-stage → 12.14.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.
- package/LICENSE.txt +82 -0
- package/README.md +75 -2
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +5375 -0
- package/dist/README.md +83 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/eslint.config.js +7 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/.forceignore +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/.postcssrc.json +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/.prettierignore +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/.prettierrc +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/CHANGELOG.md +4 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/README.md +85 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/angular.json +98 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/codegen.yml +95 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/components.json +6 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/e2e/app.spec.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/esbuild/api-version.mjs +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/esbuild/graphql-codegen.mjs +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/eslint-plugin-angular-graphql.js +148 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/eslint.config.js +77 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/feature-angular-search.uibundle-meta.xml +7 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/middleware/html.mjs +3 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/middleware/proxy.mjs +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/package.json +69 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/playwright.config.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/public/favicon.ico +0 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/scripts/get-graphql-schema.mjs +69 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/scripts/rewrite-e2e-assets.mjs +30 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/api/data-client.service.spec.ts +184 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/api/data-client.service.ts +74 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/app.config.ts +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/app.html +1 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/app.routes.ts +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/app.spec.ts +18 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/app.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/layout/app-layout/app-layout.html +51 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/layout/app-layout/app-layout.spec.ts +63 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/layout/app-layout/app-layout.ts +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/alert/alert.html +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/alert/alert.ts +41 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/button/button.html +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/button/button.ts +59 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/card/card.ts +100 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/collapsible/collapsible.html +38 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/collapsible/collapsible.ts +21 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/date-picker/date-picker.html +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/date-picker/date-picker.ts +49 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/date-range-picker/date-range-picker.html +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/date-range-picker/date-range-picker.ts +69 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/dialog/dialog.html +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/dialog/dialog.ts +40 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/dropdown-menu/dropdown-menu.html +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/dropdown-menu/dropdown-menu.ts +100 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/field/field.html +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/field/field.ts +28 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/field-appearance.ts +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/field-size.ts +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/icon/icon.ts +118 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/input/input.html +34 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/input/input.ts +79 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/label/label.ts +21 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/paginator/paginator.html +74 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/paginator/paginator.ts +93 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/paginator/types.ts +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/popover/popover.html +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/popover/popover.ts +37 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/select/select.html +36 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/select/select.ts +63 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/separator/separator.ts +31 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/skeleton/skeleton.ts +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/components/ui/spinner/spinner.ts +28 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/adapters/registry.ts +28 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/adapters/sobject/index.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/adapters/sobject/parse-response.ts +57 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/adapters/sobject/query-fragment.ts +169 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/adapters/types.ts +44 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/api/search-response.spec.ts +114 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/api/search-response.ts +73 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/api/search.service.spec.ts +124 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/api/search.service.ts +80 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/active-filters/active-filters.html +23 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/active-filters/active-filters.spec.ts +73 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/active-filters/active-filters.ts +77 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/filter-panel/default-filter-panel.html +49 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/filter-panel/default-filter-panel.ts +87 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/filter-panel/filter-box.html +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/filter-panel/filter-box.ts +39 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/global-search-box/global-search-box.html +16 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/global-search-box/global-search-box.ts +50 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/default-result-row.html +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/default-result-row.ts +91 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/merged-search-results.html +99 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/merged-search-results.ts +145 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/result-item.ts +53 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/search-results.html +10 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/search-results.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/source-section.html +84 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/results/source-section.ts +146 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/scope/scope-selector.html +9 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/scope/scope-selector.ts +45 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/search/search.html +55 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/search/search.ts +118 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/search-bar/search-bar.html +10 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/search-bar/search-bar.spec.ts +65 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/search-bar/search-bar.ts +72 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/sort-control/sort-control.html +24 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/sort-control/sort-control.spec.ts +67 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/components/sort-control/sort-control.ts +59 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/constants.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/default-search-config.ts +83 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/directives/search-result-template/search-result-template.ts +44 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/boolean-filter.html +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/boolean-filter.spec.ts +41 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/boolean-filter.ts +42 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/date-filter.html +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/date-filter.spec.ts +56 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/date-filter.ts +78 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/date-range-filter.html +43 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/date-range-filter.spec.ts +70 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/date-range-filter.ts +125 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/filter-field-wrapper.html +16 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/filter-field-wrapper.spec.ts +28 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/filter-field-wrapper.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/filter-types.spec.ts +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/filter-types.ts +64 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/multi-select-filter.html +11 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/multi-select-filter.spec.ts +42 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/multi-select-filter.ts +42 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/numeric-range-filter.html +32 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/numeric-range-filter.spec.ts +75 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/numeric-range-filter.ts +117 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/select-filter.html +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/select-filter.spec.ts +43 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/select-filter.ts +40 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/text-filter.html +9 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/text-filter.spec.ts +54 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/filters/text-filter.ts +70 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/index.ts +55 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/query/build-search-query.spec.ts +157 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/query/build-search-query.ts +95 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/state/filter-mapping.ts +48 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/state/search-state.service.spec.ts +293 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/state/search-state.service.ts +735 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/state/search-state.types.ts +48 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/types/filter.types.ts +57 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/types/index.ts +11 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/types/scope.types.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/types/search-config.types.ts +110 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/types/search-result.types.ts +68 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/types/sort.types.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/debounce.ts +23 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/field-utils.ts +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/filter-utils.spec.ts +335 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/filter-utils.ts +354 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/identifier.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/merge-utils.spec.ts +199 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/merge-utils.ts +177 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/scope-utils.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/sort-utils.ts +32 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/validate-config.spec.ts +48 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/features/search/utils/validate-config.ts +34 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/home/home.html +6 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/home/home.spec.ts +23 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/home/home.ts +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/not-found/not-found.html +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/not-found/not-found.spec.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/not-found/not-found.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/search/search-page.html +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/pages/search/search-page.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/alert/hlm-alert-action.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/alert/hlm-alert-description.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/alert/hlm-alert-title.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/alert/hlm-alert.ts +35 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/alert/index.ts +16 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/button/hlm-button.token.ts +22 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/button/hlm-button.ts +72 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/button/index.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/calendar/hlm-calendar-multi.ts +195 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/calendar/hlm-calendar-range.ts +194 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/calendar/hlm-calendar.ts +189 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/calendar/hlm-month-year-calendar.ts +119 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/calendar/index.ts +16 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-action.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-avatar.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-content.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-description.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-footer.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-header.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card-title.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card.token.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/hlm-card.ts +22 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/card/index.ts +28 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/collapsible/hlm-collapsible-content.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/collapsible/hlm-collapsible-trigger.ts +9 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/collapsible/hlm-collapsible.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/collapsible/index.ts +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-multi-input.ts +104 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker-anchor.ts +23 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker-input.ts +118 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker-multi.token.ts +109 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker-multi.ts +220 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker-trigger.ts +104 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker.token.ts +69 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-picker.ts +203 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-range-input.ts +120 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-range-picker.token.ts +86 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-date-range-picker.ts +252 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-month-year-input.ts +105 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-month-year-picker.token.ts +89 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/hlm-month-year-picker.ts +196 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/date-picker/index.ts +38 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-close.ts +9 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-content.ts +74 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-description.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-footer.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-header.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-overlay.ts +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-portal.ts +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-title.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog-trigger.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog.service.ts +46 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/hlm-dialog.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dialog/index.ts +35 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-checkbox-indicator.ts +21 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-checkbox.ts +54 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-focus-on-hover.ts +35 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-group.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-item-sub-indicator.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-item.ts +42 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-label.ts +20 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-radio-indicator.ts +21 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-radio.ts +49 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-separator.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-shortcut.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-sub-trigger.ts +52 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-sub.ts +53 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-token.ts +26 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu-trigger.ts +46 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/hlm-dropdown-menu.ts +57 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/dropdown-menu/index.ts +49 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-content.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-description.ts +53 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-error.ts +100 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-group.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-label.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-legend.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-separator.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-set.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field-title.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/hlm-field.ts +47 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/field/index.ts +34 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input/hlm-input.ts +21 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input/index.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input-group/hlm-input-group-addon.ts +40 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input-group/hlm-input-group-button.ts +47 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input-group/hlm-input-group-input.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input-group/hlm-input-group-text.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input-group/hlm-input-group.ts +18 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/input-group/index.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/label/hlm-label.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/label/index.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/label/label.html +11 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-numbered-pagination-query-params.ts +191 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-numbered-pagination.ts +290 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination-content.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination-ellipsis.ts +27 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination-item.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination-link.ts +51 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination-next.ts +65 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination-previous.ts +65 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/hlm-pagination.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/pagination/index.ts +31 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover-content.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover-description.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover-header.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover-portal.ts +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover-title.ts +12 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover-trigger.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/hlm-popover.ts +23 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/popover/index.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-content.ts +44 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-group.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-item.ts +36 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-label.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-multiple.ts +37 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-placeholder.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-portal.ts +8 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-scroll-down.ts +22 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-scroll-up.ts +22 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-separator.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-trigger.ts +59 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-value-template.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-value.ts +18 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-values-content.ts +9 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select-values.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/hlm-select.ts +37 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/select/index.ts +52 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/separator/hlm-separator.ts +19 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/separator/index.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/skeleton/hlm-skeleton.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/skeleton/index.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/spinner/hlm-spinner.ts +26 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/spinner/index.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/utils/hlm.ts +313 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/utils/index.ts +2 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/shared/utils/provide-spartan-hlm.ts +34 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/app/utils/async-data.ts +99 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/index.html +13 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/main.ts +5 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/styles.css +139 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/src/types/sf-globals.d.ts +9 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/tsconfig.app.json +11 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/tsconfig.json +36 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/tsconfig.spec.json +10 -0
- package/dist/force-app/main/default/uiBundles/feature-angular-search/ui-bundle.json +7 -0
- package/dist/jest.config.js +6 -0
- package/dist/package-lock.json +12554 -0
- package/dist/package.json +46 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/gitignore-templates.json +4 -0
- package/dist/scripts/graphql-search.sh +191 -0
- package/dist/scripts/network-senders.mjs +84 -0
- package/dist/scripts/org-setup-config-schema.mjs +132 -0
- package/dist/scripts/org-setup-dev.mjs +114 -0
- package/dist/scripts/org-setup-url.mjs +108 -0
- package/dist/scripts/org-setup-utils.mjs +569 -0
- package/dist/scripts/org-setup-xml.mjs +283 -0
- package/dist/scripts/org-setup.config.json +5 -0
- package/dist/scripts/org-setup.mjs +2545 -0
- package/dist/scripts/sf-project-setup.mjs +103 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/scripts/validate-org-setup-config.mjs +38 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +43 -4
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
ElementRef,
|
|
11
|
+
inject,
|
|
12
|
+
input,
|
|
13
|
+
viewChild,
|
|
14
|
+
} from "@angular/core";
|
|
15
|
+
import { AlertComponent } from "../../../../components/ui/alert/alert";
|
|
16
|
+
import { IconComponent } from "../../../../components/ui/icon/icon";
|
|
17
|
+
import {
|
|
18
|
+
PaginatorComponent,
|
|
19
|
+
type PageEvent,
|
|
20
|
+
} from "../../../../components/ui/paginator/paginator";
|
|
21
|
+
import { SkeletonComponent } from "../../../../components/ui/skeleton/skeleton";
|
|
22
|
+
import { ActiveFiltersComponent } from "../active-filters/active-filters";
|
|
23
|
+
import { FilterBoxComponent } from "../filter-panel/filter-box";
|
|
24
|
+
import { SortControlComponent } from "../sort-control/sort-control";
|
|
25
|
+
import { SearchStateService } from "../../state/search-state.service";
|
|
26
|
+
import type { SourceView } from "../../state/search-state.types";
|
|
27
|
+
import type { SourceConfig } from "../../types/search-config.types";
|
|
28
|
+
import type { SortState } from "../../types/sort.types";
|
|
29
|
+
import { nodeKey, ResultItemComponent, type ResultTemplates } from "./result-item";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One source's slice of the results: filter box, sort + active-filter chips,
|
|
33
|
+
* the result list, and the source's own cursor pagination. Orchestration only;
|
|
34
|
+
* how a node looks is up to the source's `appSearchResult` template.
|
|
35
|
+
*/
|
|
36
|
+
@Component({
|
|
37
|
+
selector: "app-source-section",
|
|
38
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
39
|
+
imports: [
|
|
40
|
+
AlertComponent,
|
|
41
|
+
IconComponent,
|
|
42
|
+
SkeletonComponent,
|
|
43
|
+
ActiveFiltersComponent,
|
|
44
|
+
FilterBoxComponent,
|
|
45
|
+
PaginatorComponent,
|
|
46
|
+
SortControlComponent,
|
|
47
|
+
ResultItemComponent,
|
|
48
|
+
],
|
|
49
|
+
templateUrl: "./source-section.html",
|
|
50
|
+
})
|
|
51
|
+
export class SourceSectionComponent {
|
|
52
|
+
protected readonly state = inject(SearchStateService);
|
|
53
|
+
|
|
54
|
+
readonly source = input.required<SourceConfig>();
|
|
55
|
+
readonly templates = input<ResultTemplates | undefined>(undefined);
|
|
56
|
+
/**
|
|
57
|
+
* Hide the filter box, sort control and chips. Selections stay in state (and
|
|
58
|
+
* keep applying to the query) so narrowing the scope restores them.
|
|
59
|
+
*/
|
|
60
|
+
readonly hideFilterChrome = input(false);
|
|
61
|
+
readonly emptyMessage = input<string | undefined>(undefined);
|
|
62
|
+
readonly shortQueryMessage = input("Start your search…");
|
|
63
|
+
|
|
64
|
+
private readonly region = viewChild<ElementRef<HTMLElement>>("region");
|
|
65
|
+
|
|
66
|
+
protected readonly view = computed<SourceView | undefined>(
|
|
67
|
+
() => this.state.sources()[this.source().key],
|
|
68
|
+
);
|
|
69
|
+
protected readonly loading = this.state.loading;
|
|
70
|
+
protected readonly nodes = computed(() => this.view()?.result?.nodes ?? []);
|
|
71
|
+
protected readonly totalCount = computed(() => this.view()?.result?.totalCount ?? null);
|
|
72
|
+
protected readonly error = computed(() => this.view()?.error ?? null);
|
|
73
|
+
protected readonly hasTotal = computed(() => this.totalCount() !== null);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Always a number for the paginator. Uses the server total when known; otherwise
|
|
77
|
+
* (cursor source without a count) the minimum that keeps Next enabled only while
|
|
78
|
+
* another page exists.
|
|
79
|
+
*/
|
|
80
|
+
protected readonly pagerLength = computed(() => {
|
|
81
|
+
const v = this.view();
|
|
82
|
+
if (!v) return 0;
|
|
83
|
+
const total = v.result?.totalCount;
|
|
84
|
+
if (total != null) return total;
|
|
85
|
+
return (v.pageIndex + 1) * v.pageSize + (v.hasNextPage ? 1 : 0);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
protected readonly showResults = computed(
|
|
89
|
+
() => !this.loading() && !this.error() && this.nodes().length > 0,
|
|
90
|
+
);
|
|
91
|
+
protected readonly showEmpty = computed(
|
|
92
|
+
() => !this.loading() && !this.error() && this.nodes().length === 0,
|
|
93
|
+
);
|
|
94
|
+
protected readonly emptyText = computed(
|
|
95
|
+
() => this.emptyMessage() ?? `No ${this.source().label.toLowerCase()} found.`,
|
|
96
|
+
);
|
|
97
|
+
protected readonly skeletonRows = computed(() =>
|
|
98
|
+
Array.from({ length: Math.min(this.view()?.pageSize ?? 5, 5) }, (_, i) => i),
|
|
99
|
+
);
|
|
100
|
+
protected readonly showFilters = computed(() => !this.hideFilterChrome());
|
|
101
|
+
protected readonly showChips = computed(
|
|
102
|
+
() => !this.hideFilterChrome() && (this.view()?.filters.length ?? 0) > 0,
|
|
103
|
+
);
|
|
104
|
+
protected readonly showSort = computed(
|
|
105
|
+
() => !this.hideFilterChrome() && (this.source().sortBy?.length ?? 0) > 0,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
protected readonly liveMessage = computed(() => {
|
|
109
|
+
const label = this.source().label;
|
|
110
|
+
const total = this.totalCount();
|
|
111
|
+
if (this.loading()) return "Searching…";
|
|
112
|
+
if (this.error()) return `Failed to load ${label}.`;
|
|
113
|
+
if (this.showEmpty()) {
|
|
114
|
+
return this.state.isShortQuery() ? this.shortQueryMessage() : this.emptyText();
|
|
115
|
+
}
|
|
116
|
+
return total != null ? `${label}: ${total} ${total === 1 ? "result" : "results"}` : "";
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
protected key(node: unknown, index: number): string | number {
|
|
120
|
+
return nodeKey(node, this.source().idField, index);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
protected onSort(sort: SortState | undefined): void {
|
|
124
|
+
this.state.setSort(this.source().key, sort ?? null);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Cursor paging: the paginator only ever steps one page or changes the size. */
|
|
128
|
+
protected onPage(event: PageEvent): void {
|
|
129
|
+
const key = this.source().key;
|
|
130
|
+
const view = this.view();
|
|
131
|
+
if (!view) return;
|
|
132
|
+
if (event.pageSize !== view.pageSize) {
|
|
133
|
+
this.state.setSourcePageSize(key, event.pageSize);
|
|
134
|
+
} else if (event.pageIndex > view.pageIndex) {
|
|
135
|
+
this.state.goToNextSourcePage(key);
|
|
136
|
+
} else if (event.pageIndex < view.pageIndex) {
|
|
137
|
+
this.state.goToPreviousSourcePage(key);
|
|
138
|
+
}
|
|
139
|
+
this.focusResults();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Moves focus to the list so screen-reader users land on the new page. */
|
|
143
|
+
private focusResults(): void {
|
|
144
|
+
this.region()?.nativeElement.focus();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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, input, output } from "@angular/core";
|
|
7
|
+
import {
|
|
8
|
+
SelectComponent,
|
|
9
|
+
type AppSelectOption,
|
|
10
|
+
} from "../../../../components/ui/select/select";
|
|
11
|
+
import { ALL_SCOPE, type SearchScope } from "../../types/scope.types";
|
|
12
|
+
|
|
13
|
+
/** A selectable source. */
|
|
14
|
+
export interface ScopeOption {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* State-agnostic dropdown that narrows the search to one source (or "All").
|
|
21
|
+
* The options are an "All" entry plus one per source.
|
|
22
|
+
*/
|
|
23
|
+
@Component({
|
|
24
|
+
selector: "app-scope-selector",
|
|
25
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
+
imports: [SelectComponent],
|
|
27
|
+
templateUrl: "./scope-selector.html",
|
|
28
|
+
})
|
|
29
|
+
export class ScopeSelectorComponent {
|
|
30
|
+
readonly sources = input.required<readonly ScopeOption[]>();
|
|
31
|
+
readonly scope = input<SearchScope>(ALL_SCOPE);
|
|
32
|
+
readonly allLabel = input("All");
|
|
33
|
+
/** Accessible name of the dropdown (visually hidden). */
|
|
34
|
+
readonly label = input("Search scope");
|
|
35
|
+
readonly scopeChange = output<SearchScope>();
|
|
36
|
+
|
|
37
|
+
protected readonly options = computed<AppSelectOption[]>(() => [
|
|
38
|
+
{ value: ALL_SCOPE, label: this.allLabel() },
|
|
39
|
+
...this.sources().map((s) => ({ value: s.key, label: s.label })),
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
protected onChange(value: string): void {
|
|
43
|
+
if (value && value !== this.scope()) this.scopeChange.emit(value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-6 space-y-6">
|
|
2
|
+
<header class="space-y-2">
|
|
3
|
+
<h1 class="text-2xl font-bold">{{ title() }}</h1>
|
|
4
|
+
@if (subtitle()) {
|
|
5
|
+
<p class="text-sm text-muted-foreground">{{ subtitle() }}</p>
|
|
6
|
+
}
|
|
7
|
+
</header>
|
|
8
|
+
|
|
9
|
+
@if (state.configError(); as invalid) {
|
|
10
|
+
<app-alert
|
|
11
|
+
role="alert"
|
|
12
|
+
variant="destructive"
|
|
13
|
+
icon="error"
|
|
14
|
+
title="Invalid search configuration"
|
|
15
|
+
[description]="invalid"
|
|
16
|
+
/>
|
|
17
|
+
} @else {
|
|
18
|
+
<div class="flex flex-wrap items-center gap-3" role="search">
|
|
19
|
+
<app-search-bar
|
|
20
|
+
[value]="state.q()"
|
|
21
|
+
[placeholder]="searchPlaceholder()"
|
|
22
|
+
(valueChange)="state.setQ($event)"
|
|
23
|
+
/>
|
|
24
|
+
@if (showScope()) {
|
|
25
|
+
<app-scope-selector
|
|
26
|
+
[sources]="scopeOptions()"
|
|
27
|
+
[scope]="state.scope()"
|
|
28
|
+
[allLabel]="allScopeLabel()"
|
|
29
|
+
(scopeChange)="state.setScope($event)"
|
|
30
|
+
/>
|
|
31
|
+
}
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
@if (merged()) {
|
|
35
|
+
<app-merged-search-results
|
|
36
|
+
[templates]="templates()"
|
|
37
|
+
[emptyMessage]="emptyMessages()[state.scope()]"
|
|
38
|
+
/>
|
|
39
|
+
} @else if (state.error(); as message) {
|
|
40
|
+
<!-- Page-level failure: one banner instead of a repeated error per source. -->
|
|
41
|
+
<app-alert
|
|
42
|
+
role="alert"
|
|
43
|
+
variant="destructive"
|
|
44
|
+
icon="error"
|
|
45
|
+
title="Search failed"
|
|
46
|
+
[description]="message"
|
|
47
|
+
/>
|
|
48
|
+
} @else { @if (showTotal()) {
|
|
49
|
+
<p class="text-sm text-muted-foreground" role="status">
|
|
50
|
+
{{ totalResults() }} total result{{ totalResults() === 1 ? '' : 's' }}
|
|
51
|
+
</p>
|
|
52
|
+
}
|
|
53
|
+
<app-search-results [templates]="templates()" [emptyMessages]="emptyMessages()" />
|
|
54
|
+
} }
|
|
55
|
+
</div>
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
contentChildren,
|
|
11
|
+
inject,
|
|
12
|
+
input,
|
|
13
|
+
type OnInit,
|
|
14
|
+
} from "@angular/core";
|
|
15
|
+
import { AlertComponent } from "../../../../components/ui/alert/alert";
|
|
16
|
+
import { SearchResultTemplateDirective } from "../../directives/search-result-template/search-result-template";
|
|
17
|
+
import { SearchStateService } from "../../state/search-state.service";
|
|
18
|
+
import type { RestrictTo } from "../../state/search-state.types";
|
|
19
|
+
import { ALL_SCOPE } from "../../types/scope.types";
|
|
20
|
+
import type { SearchConfig } from "../../types/search-config.types";
|
|
21
|
+
import { MergedSearchResultsComponent } from "../results/merged-search-results";
|
|
22
|
+
import type { ResultTemplates } from "../results/result-item";
|
|
23
|
+
import { SearchResultsComponent } from "../results/search-results";
|
|
24
|
+
import { ScopeSelectorComponent } from "../scope/scope-selector";
|
|
25
|
+
import { SearchBarComponent } from "../search-bar/search-bar";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Drop-in search. Given a {@link SearchConfig}, renders a complete experience:
|
|
29
|
+
* search bar, scope selector, an aggregate count, and the results.
|
|
30
|
+
*
|
|
31
|
+
* The results layout follows `config.pagination.mode`: `"per-source"` (default)
|
|
32
|
+
* stacks one section per source, each with its own filters, sort and paging;
|
|
33
|
+
* `"merged"` renders one combined grid with a single global pager.
|
|
34
|
+
*
|
|
35
|
+
* ```html
|
|
36
|
+
* <app-search [config]="config" title="Search">
|
|
37
|
+
* <ng-template appSearchResult="Property__c" let-node>...</ng-template>
|
|
38
|
+
* </app-search>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* `config` is read once; it must be stable for the component's lifetime.
|
|
42
|
+
*/
|
|
43
|
+
@Component({
|
|
44
|
+
selector: "app-search",
|
|
45
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
46
|
+
providers: [SearchStateService],
|
|
47
|
+
imports: [
|
|
48
|
+
AlertComponent,
|
|
49
|
+
SearchBarComponent,
|
|
50
|
+
ScopeSelectorComponent,
|
|
51
|
+
SearchResultsComponent,
|
|
52
|
+
MergedSearchResultsComponent,
|
|
53
|
+
],
|
|
54
|
+
templateUrl: "./search.html",
|
|
55
|
+
})
|
|
56
|
+
export class SearchComponent implements OnInit {
|
|
57
|
+
protected readonly state = inject(SearchStateService);
|
|
58
|
+
|
|
59
|
+
readonly config = input.required<SearchConfig>();
|
|
60
|
+
readonly title = input("Search");
|
|
61
|
+
readonly subtitle = input<string | undefined>(undefined);
|
|
62
|
+
readonly searchPlaceholder = input("Search…");
|
|
63
|
+
/**
|
|
64
|
+
* Lock the search to one source by `(kind, key)`: hides the scope selector
|
|
65
|
+
* and fetches only that source. An unknown pair warns and falls back to "all".
|
|
66
|
+
*/
|
|
67
|
+
readonly restrictTo = input<RestrictTo | undefined>(undefined);
|
|
68
|
+
/** Defaults to `true` with 2+ sources; always hidden when `restrictTo` is set. */
|
|
69
|
+
readonly showScopeSelector = input<boolean | undefined>(undefined);
|
|
70
|
+
readonly allScopeLabel = input("All");
|
|
71
|
+
/** Per source key (merged mode: per scope): message shown when nothing matches. */
|
|
72
|
+
readonly emptyMessages = input<Readonly<Record<string, string>>>({});
|
|
73
|
+
|
|
74
|
+
private readonly resultTemplates = contentChildren(SearchResultTemplateDirective);
|
|
75
|
+
|
|
76
|
+
protected readonly templates = computed<ResultTemplates>(
|
|
77
|
+
() => new Map(this.resultTemplates().map((t) => [t.sourceKey(), t.template])),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
protected readonly merged = computed(() => this.state.mergedMode());
|
|
81
|
+
protected readonly scopeOptions = computed(() =>
|
|
82
|
+
this.config().sources.map((s) => ({ key: s.key, label: s.label })),
|
|
83
|
+
);
|
|
84
|
+
protected readonly showScope = computed(
|
|
85
|
+
() =>
|
|
86
|
+
!this.state.scopeLocked() && (this.showScopeSelector() ?? this.config().sources.length >= 2),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Aggregate count: meaningful only when 2+ sources are combined. Merged mode
|
|
91
|
+
* renders its own count above the grid.
|
|
92
|
+
*/
|
|
93
|
+
protected readonly showTotal = computed(
|
|
94
|
+
() =>
|
|
95
|
+
!this.merged() &&
|
|
96
|
+
!this.state.loading() &&
|
|
97
|
+
(this.state.scope() === ALL_SCOPE ? this.config().sources.length : 1) >= 2,
|
|
98
|
+
);
|
|
99
|
+
protected readonly totalResults = computed(() =>
|
|
100
|
+
Object.values(this.state.sources()).reduce((sum, v) => sum + (v.result?.totalCount ?? 0), 0),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
ngOnInit(): void {
|
|
104
|
+
const config = this.config();
|
|
105
|
+
const restrict = this.restrictTo();
|
|
106
|
+
let lockedScope: string | undefined;
|
|
107
|
+
if (restrict) {
|
|
108
|
+
const match = config.sources.find((s) => s.kind === restrict.kind && s.key === restrict.key);
|
|
109
|
+
if (match) lockedScope = match.key;
|
|
110
|
+
else {
|
|
111
|
+
console.warn(
|
|
112
|
+
`<app-search restrictTo>: no source with kind="${restrict.kind}" and key="${restrict.key}" in config. Falling back to "all".`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
this.state.init(config, { lockedScope });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
import { TestBed } from "@angular/core/testing";
|
|
7
|
+
import { By } from "@angular/platform-browser";
|
|
8
|
+
import { afterEach, beforeEach, vi } from "vitest";
|
|
9
|
+
import { InputComponent } from "../../../../components/ui/input/input";
|
|
10
|
+
import { FILTER_DEBOUNCE_MS } from "../../utils/debounce";
|
|
11
|
+
import { SearchBarComponent } from "./search-bar";
|
|
12
|
+
|
|
13
|
+
describe("SearchBarComponent", () => {
|
|
14
|
+
beforeEach(() => vi.useFakeTimers());
|
|
15
|
+
afterEach(() => vi.useRealTimers());
|
|
16
|
+
|
|
17
|
+
function setup(inputs: Record<string, unknown> = {}) {
|
|
18
|
+
const fixture = TestBed.createComponent(SearchBarComponent);
|
|
19
|
+
for (const [k, v] of Object.entries(inputs)) fixture.componentRef.setInput(k, v);
|
|
20
|
+
const emitted: string[] = [];
|
|
21
|
+
fixture.componentInstance.valueChange.subscribe((v) => emitted.push(v));
|
|
22
|
+
fixture.detectChanges();
|
|
23
|
+
const input = fixture.debugElement.query(By.directive(InputComponent))
|
|
24
|
+
.componentInstance as InputComponent;
|
|
25
|
+
return { fixture, input, emitted };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
it("seeds the input from the value", () => {
|
|
29
|
+
const { input } = setup({ value: "acme" });
|
|
30
|
+
expect(input.value()).toBe("acme");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("debounces typing and emits the last value", () => {
|
|
34
|
+
const { fixture, input, emitted } = setup();
|
|
35
|
+
input.value.set("a");
|
|
36
|
+
input.value.set("ac");
|
|
37
|
+
fixture.detectChanges();
|
|
38
|
+
vi.advanceTimersByTime(FILTER_DEBOUNCE_MS - 1);
|
|
39
|
+
expect(emitted).toEqual([]);
|
|
40
|
+
vi.advanceTimersByTime(1);
|
|
41
|
+
expect(emitted).toEqual(["ac"]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("re-seeds the draft when the bound value changes externally", () => {
|
|
45
|
+
const { fixture, input } = setup({ value: "a" });
|
|
46
|
+
fixture.componentRef.setInput("value", "");
|
|
47
|
+
fixture.detectChanges();
|
|
48
|
+
expect(input.value()).toBe("");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("withholds non-empty values shorter than minLength but always emits empty", () => {
|
|
52
|
+
const { fixture, input, emitted } = setup({ minLength: 3 });
|
|
53
|
+
input.value.set("ab");
|
|
54
|
+
fixture.detectChanges();
|
|
55
|
+
vi.advanceTimersByTime(FILTER_DEBOUNCE_MS);
|
|
56
|
+
expect(emitted).toEqual([]);
|
|
57
|
+
input.value.set("abc");
|
|
58
|
+
fixture.detectChanges();
|
|
59
|
+
vi.advanceTimersByTime(FILTER_DEBOUNCE_MS);
|
|
60
|
+
input.value.set("");
|
|
61
|
+
fixture.detectChanges();
|
|
62
|
+
vi.advanceTimersByTime(FILTER_DEBOUNCE_MS);
|
|
63
|
+
expect(emitted).toEqual(["abc", ""]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -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 {
|
|
7
|
+
ChangeDetectionStrategy,
|
|
8
|
+
Component,
|
|
9
|
+
DestroyRef,
|
|
10
|
+
effect,
|
|
11
|
+
inject,
|
|
12
|
+
input,
|
|
13
|
+
output,
|
|
14
|
+
signal,
|
|
15
|
+
untracked,
|
|
16
|
+
} from "@angular/core";
|
|
17
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
18
|
+
import { Subject } from "rxjs";
|
|
19
|
+
import { debounceTime } from "rxjs/operators";
|
|
20
|
+
import { InputComponent } from "../../../../components/ui/input/input";
|
|
21
|
+
import { FILTER_DEBOUNCE_MS } from "../../utils/debounce";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* State-agnostic search box: a text input with a leading search icon. Keystrokes
|
|
25
|
+
* update a local draft immediately and are emitted on a trailing
|
|
26
|
+
* {@link FILTER_DEBOUNCE_MS}ms debounce. An empty value always emits (so the
|
|
27
|
+
* container can clear); when `minLength` is set, non-empty values whose trimmed
|
|
28
|
+
* length is below it are withheld.
|
|
29
|
+
*/
|
|
30
|
+
@Component({
|
|
31
|
+
selector: "app-search-bar",
|
|
32
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
33
|
+
imports: [InputComponent],
|
|
34
|
+
host: { class: "flex-1 block" },
|
|
35
|
+
templateUrl: "./search-bar.html",
|
|
36
|
+
})
|
|
37
|
+
export class SearchBarComponent {
|
|
38
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
39
|
+
|
|
40
|
+
readonly value = input<string>("");
|
|
41
|
+
readonly placeholder = input<string>("");
|
|
42
|
+
readonly label = input<string | undefined>(undefined);
|
|
43
|
+
readonly minLength = input<number | undefined>(undefined);
|
|
44
|
+
readonly valueChange = output<string>();
|
|
45
|
+
|
|
46
|
+
protected readonly draft = signal("");
|
|
47
|
+
private readonly commit$ = new Subject<string>();
|
|
48
|
+
|
|
49
|
+
constructor() {
|
|
50
|
+
this.commit$
|
|
51
|
+
.pipe(debounceTime(FILTER_DEBOUNCE_MS), takeUntilDestroyed(this.destroyRef))
|
|
52
|
+
.subscribe((v) => {
|
|
53
|
+
const min = this.minLength();
|
|
54
|
+
const len = v.trim().length;
|
|
55
|
+
if (min !== undefined && len > 0 && len < min) return;
|
|
56
|
+
this.valueChange.emit(v);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Re-seed the draft when the bound value changes externally (URL restore, reset).
|
|
60
|
+
effect(() => {
|
|
61
|
+
const external = this.value();
|
|
62
|
+
untracked(() => {
|
|
63
|
+
if (external !== this.draft()) this.draft.set(external);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected onInput(v: string): void {
|
|
69
|
+
this.draft.set(v);
|
|
70
|
+
this.commit$.next(v);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<div class="flex items-center gap-2" role="group" [attr.aria-label]="label()">
|
|
2
|
+
<span class="text-sm text-muted-foreground whitespace-nowrap">{{ label() }}</span>
|
|
3
|
+
<app-select
|
|
4
|
+
class="w-[160px]"
|
|
5
|
+
[options]="selectOptions()"
|
|
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
|
+
[ariaLabel]="'Sort ' + (active.direction === 'ASC' ? 'descending' : 'ascending')"
|
|
15
|
+
(clicked)="toggleDirection()"
|
|
16
|
+
>
|
|
17
|
+
@if (active.direction === "ASC") {
|
|
18
|
+
<app-icon name="arrowUp" />
|
|
19
|
+
} @else {
|
|
20
|
+
<app-icon name="arrowDown" />
|
|
21
|
+
}
|
|
22
|
+
</app-button>
|
|
23
|
+
}
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
import { TestBed } from "@angular/core/testing";
|
|
7
|
+
import { By } from "@angular/platform-browser";
|
|
8
|
+
import { ButtonComponent } from "../../../../components/ui/button/button";
|
|
9
|
+
import { SelectComponent } from "../../../../components/ui/select/select";
|
|
10
|
+
import type { SortFieldConfig, SortState } from "../../types/sort.types";
|
|
11
|
+
import { SortControlComponent } from "./sort-control";
|
|
12
|
+
|
|
13
|
+
const OPTIONS: SortFieldConfig[] = [
|
|
14
|
+
{ field: "Name", label: "Name" },
|
|
15
|
+
{ field: "Industry", label: "Industry" },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
describe("SortControlComponent", () => {
|
|
19
|
+
function setup(sort?: SortState) {
|
|
20
|
+
const fixture = TestBed.createComponent(SortControlComponent);
|
|
21
|
+
fixture.componentRef.setInput("options", OPTIONS);
|
|
22
|
+
fixture.componentRef.setInput("sort", sort);
|
|
23
|
+
const emitted: (SortState | undefined)[] = [];
|
|
24
|
+
fixture.componentInstance.sortChange.subscribe((v) => emitted.push(v));
|
|
25
|
+
fixture.detectChanges();
|
|
26
|
+
const select = () =>
|
|
27
|
+
fixture.debugElement.query(By.directive(SelectComponent))
|
|
28
|
+
.componentInstance as SelectComponent;
|
|
29
|
+
const button = () => fixture.debugElement.query(By.directive(ButtonComponent));
|
|
30
|
+
return { fixture, select, button, emitted };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
it("offers Default plus the configured fields", () => {
|
|
34
|
+
const { select } = setup();
|
|
35
|
+
expect(
|
|
36
|
+
select()
|
|
37
|
+
.options()
|
|
38
|
+
.map((o) => o.label),
|
|
39
|
+
).toEqual(["Default", "Name", "Industry"]);
|
|
40
|
+
expect(select().value()).toBe("__none__");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("emits ASC when a field is chosen with no active sort", () => {
|
|
44
|
+
const { select, emitted } = setup();
|
|
45
|
+
select().value.set("Name");
|
|
46
|
+
expect(emitted).toEqual([{ field: "Name", direction: "ASC" }]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("keeps the current direction when switching field", () => {
|
|
50
|
+
const { select, emitted } = setup({ field: "Name", direction: "DESC" });
|
|
51
|
+
select().value.set("Industry");
|
|
52
|
+
expect(emitted).toEqual([{ field: "Industry", direction: "DESC" }]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("emits undefined when Default is chosen", () => {
|
|
56
|
+
const { select, emitted } = setup({ field: "Name", direction: "ASC" });
|
|
57
|
+
select().value.set("__none__");
|
|
58
|
+
expect(emitted).toEqual([undefined]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("hides the direction button without a sort and toggles it with one", () => {
|
|
62
|
+
expect(setup().button()).toBeNull();
|
|
63
|
+
const { button, emitted } = setup({ field: "Name", direction: "ASC" });
|
|
64
|
+
button().componentInstance.clicked.emit(new MouseEvent("click"));
|
|
65
|
+
expect(emitted).toEqual([{ field: "Name", direction: "DESC" }]);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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, input, output } from "@angular/core";
|
|
7
|
+
import { ButtonComponent } from "../../../../components/ui/button/button";
|
|
8
|
+
import { IconComponent } from "../../../../components/ui/icon/icon";
|
|
9
|
+
import {
|
|
10
|
+
SelectComponent,
|
|
11
|
+
type AppSelectOption,
|
|
12
|
+
} from "../../../../components/ui/select/select";
|
|
13
|
+
import type { SortFieldConfig, SortState } from "../../types/sort.types";
|
|
14
|
+
|
|
15
|
+
/** Sentinel value used in the select to represent "no sort". */
|
|
16
|
+
const NONE_VALUE = "__none__";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* State-agnostic sort field + direction toggle. Choosing a field applies ASC by
|
|
20
|
+
* default (keeping the current direction if one is active); the direction button
|
|
21
|
+
* flips ASC/DESC and only appears while a sort is active. Selecting `Default`
|
|
22
|
+
* emits `undefined`.
|
|
23
|
+
*/
|
|
24
|
+
@Component({
|
|
25
|
+
selector: "app-sort-control",
|
|
26
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
27
|
+
imports: [ButtonComponent, IconComponent, SelectComponent],
|
|
28
|
+
templateUrl: "./sort-control.html",
|
|
29
|
+
})
|
|
30
|
+
export class SortControlComponent {
|
|
31
|
+
readonly options = input.required<SortFieldConfig[]>();
|
|
32
|
+
readonly sort = input<SortState | undefined>(undefined);
|
|
33
|
+
readonly label = input<string>("Sort by");
|
|
34
|
+
readonly sortChange = output<SortState | undefined>();
|
|
35
|
+
|
|
36
|
+
protected readonly selectOptions = computed<AppSelectOption[]>(() => [
|
|
37
|
+
{ value: NONE_VALUE, label: "Default" },
|
|
38
|
+
...this.options().map((c) => ({ value: c.field, label: c.label })),
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
protected readonly selectedValue = computed(() => this.sort()?.field ?? NONE_VALUE);
|
|
42
|
+
|
|
43
|
+
protected onFieldChange(field: string): void {
|
|
44
|
+
if (field === NONE_VALUE) {
|
|
45
|
+
this.sortChange.emit(undefined);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.sortChange.emit({ field, direction: this.sort()?.direction ?? "ASC" });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected toggleDirection(): void {
|
|
52
|
+
const current = this.sort();
|
|
53
|
+
if (!current) return;
|
|
54
|
+
this.sortChange.emit({
|
|
55
|
+
field: current.field,
|
|
56
|
+
direction: current.direction === "ASC" ? "DESC" : "ASC",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|