@skyux/lookup 8.7.2 → 9.0.0-alpha.1

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 (121) hide show
  1. package/documentation.json +244 -244
  2. package/esm2022/lib/modules/autocomplete/autocomplete-adapter.service.mjs +61 -0
  3. package/esm2022/lib/modules/autocomplete/autocomplete-input.directive.mjs +237 -0
  4. package/{esm2020 → esm2022}/lib/modules/autocomplete/autocomplete-search-async-disabled.pipe.mjs +4 -4
  5. package/esm2022/lib/modules/autocomplete/autocomplete.component.mjs +817 -0
  6. package/{esm2020 → esm2022}/lib/modules/autocomplete/autocomplete.module.mjs +27 -27
  7. package/esm2022/lib/modules/country-field/country-field.component.mjs +444 -0
  8. package/{esm2020 → esm2022}/lib/modules/country-field/country-field.module.mjs +19 -19
  9. package/{esm2020 → esm2022}/lib/modules/lookup/lookup-adapter.service.mjs +4 -4
  10. package/esm2022/lib/modules/lookup/lookup-autocomplete-adapter.mjs +114 -0
  11. package/esm2022/lib/modules/lookup/lookup-show-more-modal.component.mjs +270 -0
  12. package/{esm2020 → esm2022}/lib/modules/lookup/lookup.component.mjs +299 -280
  13. package/{esm2020 → esm2022}/lib/modules/lookup/lookup.module.mjs +37 -37
  14. package/esm2022/lib/modules/search/search-adapter.service.mjs +46 -0
  15. package/esm2022/lib/modules/search/search.component.mjs +285 -0
  16. package/{esm2020 → esm2022}/lib/modules/search/search.module.mjs +17 -17
  17. package/{esm2020 → esm2022}/lib/modules/selection-modal/selection-modal-item-selected.pipe.mjs +4 -4
  18. package/esm2022/lib/modules/selection-modal/selection-modal.component.mjs +201 -0
  19. package/{esm2020 → esm2022}/lib/modules/selection-modal/selection-modal.module.mjs +27 -27
  20. package/esm2022/lib/modules/selection-modal/selection-modal.service.mjs +89 -0
  21. package/esm2022/lib/modules/selection-modal/types/selection-modal-instance.mjs +45 -0
  22. package/esm2022/lib/modules/shared/sky-lookup-resources.module.mjs +71 -0
  23. package/esm2022/testing/autocomplete/autocomplete-harness.mjs +155 -0
  24. package/esm2022/testing/autocomplete/autocomplete-input-harness.mjs +63 -0
  25. package/esm2022/testing/autocomplete/autocomplete-search-result-harness.mjs +44 -0
  26. package/esm2022/testing/country-field/country-field-fixture.mjs +118 -0
  27. package/{esm2020 → esm2022}/testing/country-field/country-field-testing.module.mjs +5 -5
  28. package/esm2022/testing/lookup/lookup-harness.mjs +76 -0
  29. package/{esm2020 → esm2022}/testing/search/search-fixture.mjs +18 -19
  30. package/esm2022/testing/search/search-harness.mjs +80 -0
  31. package/{esm2020 → esm2022}/testing/search/search-testing.module.mjs +5 -5
  32. package/esm2022/testing/selection-modal/selection-modal-harness.mjs +122 -0
  33. package/{fesm2020 → fesm2022}/skyux-lookup-testing.mjs +171 -187
  34. package/{fesm2020 → fesm2022}/skyux-lookup-testing.mjs.map +1 -1
  35. package/fesm2022/skyux-lookup.mjs +3707 -0
  36. package/{fesm2015 → fesm2022}/skyux-lookup.mjs.map +1 -1
  37. package/lib/modules/autocomplete/autocomplete-input.directive.d.ts +1 -1
  38. package/lib/modules/autocomplete/autocomplete.component.d.ts +1 -1
  39. package/lib/modules/country-field/country-field.component.d.ts +1 -1
  40. package/lib/modules/lookup/lookup-autocomplete-adapter.d.ts +1 -1
  41. package/lib/modules/lookup/lookup.component.d.ts +1 -1
  42. package/lib/modules/search/search.component.d.ts +1 -1
  43. package/package.json +23 -31
  44. package/esm2020/lib/modules/autocomplete/autocomplete-adapter.service.mjs +0 -64
  45. package/esm2020/lib/modules/autocomplete/autocomplete-input.directive.mjs +0 -235
  46. package/esm2020/lib/modules/autocomplete/autocomplete.component.mjs +0 -775
  47. package/esm2020/lib/modules/country-field/country-field.component.mjs +0 -433
  48. package/esm2020/lib/modules/lookup/lookup-autocomplete-adapter.mjs +0 -115
  49. package/esm2020/lib/modules/lookup/lookup-show-more-modal.component.mjs +0 -271
  50. package/esm2020/lib/modules/search/search-adapter.service.mjs +0 -46
  51. package/esm2020/lib/modules/search/search.component.mjs +0 -279
  52. package/esm2020/lib/modules/selection-modal/selection-modal.component.mjs +0 -199
  53. package/esm2020/lib/modules/selection-modal/selection-modal.service.mjs +0 -92
  54. package/esm2020/lib/modules/selection-modal/types/selection-modal-instance.mjs +0 -48
  55. package/esm2020/lib/modules/shared/sky-lookup-resources.module.mjs +0 -71
  56. package/esm2020/testing/autocomplete/autocomplete-harness.mjs +0 -161
  57. package/esm2020/testing/autocomplete/autocomplete-input-harness.mjs +0 -63
  58. package/esm2020/testing/autocomplete/autocomplete-search-result-harness.mjs +0 -44
  59. package/esm2020/testing/country-field/country-field-fixture.mjs +0 -114
  60. package/esm2020/testing/lookup/lookup-harness.mjs +0 -82
  61. package/esm2020/testing/search/search-harness.mjs +0 -86
  62. package/esm2020/testing/selection-modal/selection-modal-harness.mjs +0 -128
  63. package/fesm2015/skyux-lookup-testing.mjs +0 -980
  64. package/fesm2015/skyux-lookup-testing.mjs.map +0 -1
  65. package/fesm2015/skyux-lookup.mjs +0 -3642
  66. package/fesm2020/skyux-lookup.mjs +0 -3625
  67. package/fesm2020/skyux-lookup.mjs.map +0 -1
  68. /package/{esm2020 → esm2022}/index.mjs +0 -0
  69. /package/{esm2020 → esm2022}/lib/modules/autocomplete/autocomplete-default-search-function.mjs +0 -0
  70. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-default-search-function-options.mjs +0 -0
  71. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-input-text-change.mjs +0 -0
  72. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-message-type.mjs +0 -0
  73. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-message.mjs +0 -0
  74. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-args.mjs +0 -0
  75. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-async-args.mjs +0 -0
  76. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-async-function.mjs +0 -0
  77. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-async-result-display-type.mjs +0 -0
  78. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-async-result.mjs +0 -0
  79. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-context.mjs +0 -0
  80. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-function-filter.mjs +0 -0
  81. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-function-response.mjs +0 -0
  82. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-search-function.mjs +0 -0
  83. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-selection-change.mjs +0 -0
  84. /package/{esm2020 → esm2022}/lib/modules/autocomplete/types/autocomplete-show-more-args.mjs +0 -0
  85. /package/{esm2020 → esm2022}/lib/modules/country-field/types/country-field-context-token.mjs +0 -0
  86. /package/{esm2020 → esm2022}/lib/modules/country-field/types/country-field-context.mjs +0 -0
  87. /package/{esm2020 → esm2022}/lib/modules/country-field/types/country.mjs +0 -0
  88. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-add-click-callback-args.mjs +0 -0
  89. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-add-click-event-args.mjs +0 -0
  90. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-select-mode-type.mjs +0 -0
  91. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-select-mode.mjs +0 -0
  92. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-show-more-config.mjs +0 -0
  93. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-show-more-custom-picker-context.mjs +0 -0
  94. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-show-more-custom-picker.mjs +0 -0
  95. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-show-more-native-picker-config.mjs +0 -0
  96. /package/{esm2020 → esm2022}/lib/modules/lookup/types/lookup-show-more-native-picker-context.mjs +0 -0
  97. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-add-click-callback-args.mjs +0 -0
  98. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-add-click-event-args.mjs +0 -0
  99. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-close-args.mjs +0 -0
  100. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-context.mjs +0 -0
  101. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-open-args.mjs +0 -0
  102. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-result.mjs +0 -0
  103. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-search-args.mjs +0 -0
  104. /package/{esm2020 → esm2022}/lib/modules/selection-modal/types/selection-modal-search-result.mjs +0 -0
  105. /package/{esm2020 → esm2022}/lib/modules/shared/sky-lookup-string-utils.mjs +0 -0
  106. /package/{esm2020 → esm2022}/skyux-lookup.mjs +0 -0
  107. /package/{esm2020 → esm2022}/testing/autocomplete/autocomplete-harness-filters.mjs +0 -0
  108. /package/{esm2020 → esm2022}/testing/autocomplete/autocomplete-search-result-harness-filters.mjs +0 -0
  109. /package/{esm2020 → esm2022}/testing/lookup/lookup-harness-filters.mjs +0 -0
  110. /package/{esm2020 → esm2022}/testing/lookup/lookup-selection-harness-filters.mjs +0 -0
  111. /package/{esm2020 → esm2022}/testing/lookup/lookup-selection-harness.mjs +0 -0
  112. /package/{esm2020 → esm2022}/testing/lookup/lookup-selections-list-harness.mjs +0 -0
  113. /package/{esm2020 → esm2022}/testing/lookup/lookup-show-more-picker-harness-filters.mjs +0 -0
  114. /package/{esm2020 → esm2022}/testing/lookup/lookup-show-more-picker-harness.mjs +0 -0
  115. /package/{esm2020 → esm2022}/testing/lookup/lookup-show-more-picker-search-result-harness-filters.mjs +0 -0
  116. /package/{esm2020 → esm2022}/testing/lookup/lookup-show-more-picker-search-result-harness.mjs +0 -0
  117. /package/{esm2020 → esm2022}/testing/public-api.mjs +0 -0
  118. /package/{esm2020 → esm2022}/testing/search/search-harness-filters.mjs +0 -0
  119. /package/{esm2020 → esm2022}/testing/selection-modal/selection-modal-search-result-harness-filters.mjs +0 -0
  120. /package/{esm2020 → esm2022}/testing/selection-modal/selection-modal-search-result-harness.mjs +0 -0
  121. /package/{esm2020 → esm2022}/testing/skyux-lookup-testing.mjs +0 -0
@@ -14555,214 +14555,204 @@
14555
14555
  },
14556
14556
  "codeExamples": [
14557
14557
  {
14558
- "fileName": "autocomplete-demo.component.html",
14559
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/autocomplete-demo.component.html",
14560
- "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <div class=\"sky-margin-stacked-lg\">\n The following field:<br />\n <ul>\n <li>utilizes a custom search result template,</li>\n <li>searches against the name and description properties,</li>\n <li>limits the search results to two,</li>\n <li>runs the search if the query is at least three characters long,</li>\n <li>and fires an event when a selection is made.</li>\n </ul>\n </div>\n\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"planetInput.id\">\n Farthest planet from the sun\n </label>\n <sky-autocomplete\n [data]=\"planets\"\n [propertiesToSearch]=\"['name', 'description']\"\n [searchResultsLimit]=\"2\"\n [searchResultTemplate]=\"planetSearchResultTemplate\"\n [searchTextMinimumCharacters]=\"3\"\n (selectionChange)=\"onPlanetSelection($event)\"\n >\n <input\n formControlName=\"farthestPlanet\"\n skyAutocomplete\n skyId\n type=\"text\"\n #planetInput\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n\n<ng-template let-item=\"item\" #planetSearchResultTemplate>\n <strong>\n {{ item.name }}\n </strong>\n <br />\n {{ item.description }}\n</ng-template>\n"
14561
- },
14562
- {
14563
- "fileName": "autocomplete-demo.component.ts",
14564
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/autocomplete-demo.component.ts",
14565
- "rawContents": "import { Component } from '@angular/core';\nimport {\n UntypedFormBuilder,\n UntypedFormControl,\n UntypedFormGroup,\n} from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunctionFilter,\n SkyAutocompleteSelectionChange,\n} from '@skyux/lookup';\n\nimport { Planet } from './planet';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public farthestPlanet: UntypedFormControl;\n\n public myForm: UntypedFormGroup;\n\n public planets: Planet[] = [\n {\n name: 'Mercury',\n description: 'Mercury is a planet in our solar system.',\n },\n { name: 'Venus', description: 'Venus is a planet in our solar system.' },\n { name: 'Earth', description: 'Earth is a planet in our solar system.' },\n { name: 'Mars', description: 'Mars is a planet in our solar system.' },\n {\n name: 'Jupiter',\n description: 'Jupiter is a planet in our solar system.',\n },\n { name: 'Saturn', description: 'Saturn is a planet in our solar system.' },\n { name: 'Uranus', description: 'Uranus is a planet in our solar system.' },\n {\n name: 'Neptune',\n description: 'Neptune is a planet in our solar system.',\n },\n ];\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[] = [\n (searchText: string, item: Planet): boolean => {\n return item.name !== 'Red';\n },\n ];\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.farthestPlanet = formBuilder.control({});\n this.myForm = formBuilder.group({\n farthestPlanet: this.farthestPlanet,\n });\n }\n\n public onPlanetSelection(args: SkyAutocompleteSelectionChange): void {\n alert(`You selected ${args.selectedItem.name}`);\n }\n}\n"
14558
+ "fileName": "selection-modal-demo.service.ts",
14559
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.service.ts",
14560
+ "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalAsyncDemoSearchResults } from './selection-modal-demo-search-results';\n\nconst people: SelectionModalDemoPerson[] = [\n { id: '1', name: 'Abed' },\n { id: '2', name: 'Alex' },\n { id: '3', name: 'Ben' },\n { id: '4', name: 'Britta' },\n { id: '5', name: 'Buzz' },\n { id: '6', name: 'Craig' },\n { id: '7', name: 'Elroy' },\n { id: '8', name: 'Garrett' },\n { id: '9', name: 'Ian' },\n { id: '10', name: 'Jeff' },\n { id: '11', name: 'Leonard' },\n { id: '12', name: 'Neil' },\n { id: '13', name: 'Pierce' },\n { id: '14', name: 'Preston' },\n { id: '15', name: 'Rachel' },\n { id: '16', name: 'Shirley' },\n { id: '17', name: 'Todd' },\n { id: '18', name: 'Troy' },\n { id: '19', name: 'Vaughn' },\n { id: '20', name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SelectionModalDemoService {\n public search(\n searchText: string\n ): Observable<SelectionModalAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n}\n"
14566
14561
  },
14567
14562
  {
14568
- "fileName": "autocomplete-demo.module.ts",
14569
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/autocomplete-demo.module.ts",
14570
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIconModule } from '@skyux/indicators';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutocompleteModule,\n SkyIconModule,\n ],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14563
+ "fileName": "selection-modal-demo.module.ts",
14564
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.module.ts",
14565
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { SkySelectionModalModule } from '@skyux/lookup';\n\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\n\n@NgModule({\n declarations: [SelectionModalDemoComponent],\n exports: [SelectionModalDemoComponent],\n imports: [CommonModule, SkySelectionModalModule],\n})\nexport class SelectionModalDemoModule {}\n"
14571
14566
  },
14572
14567
  {
14573
- "fileName": "planet.ts",
14574
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/planet.ts",
14575
- "rawContents": "export interface Planet {\n name?: string;\n description?: string;\n}\n"
14568
+ "fileName": "selection-modal-demo.component.ts",
14569
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.component.ts",
14570
+ "rawContents": "import { Component } from '@angular/core';\nimport {\n SkySelectionModalSearchResult,\n SkySelectionModalService,\n} from '@skyux/lookup';\n\nimport { map } from 'rxjs/operators';\n\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\n@Component({\n selector: 'app-selection-modal-demo',\n templateUrl: './selection-modal-demo.component.html',\n})\nexport class SelectionModalDemoComponent {\n public selectedPeople: SelectionModalDemoPerson[] | undefined;\n\n #searchSvc: SelectionModalDemoService;\n #selectionModalSvc: SkySelectionModalService;\n\n constructor(\n searchSvc: SelectionModalDemoService,\n selectionModalSvc: SkySelectionModalService\n ) {\n this.#searchSvc = searchSvc;\n this.#selectionModalSvc = selectionModalSvc;\n }\n\n public showSelectionModal(): void {\n const instance = this.#selectionModalSvc.open({\n descriptorProperty: 'name',\n idProperty: 'id',\n searchAsync: (args) =>\n this.#searchSvc.search(args.searchText).pipe(\n map(\n (results): SkySelectionModalSearchResult => ({\n hasMore: results.hasMore,\n items: results.people,\n totalCount: results.totalCount,\n })\n )\n ),\n selectMode: 'single',\n });\n\n instance.closed.subscribe((args) => {\n if (args.reason === 'save') {\n this.selectedPeople = args.selectedItems as SelectionModalDemoPerson[];\n }\n });\n }\n}\n"
14576
14571
  },
14577
14572
  {
14578
- "fileName": "autocomplete-demo.component.html",
14579
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/basic/autocomplete-demo.component.html",
14580
- "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"favoriteColorInput.id\">\n Favorite color\n </label>\n <sky-autocomplete [data]=\"colors\">\n <input\n formControlName=\"favoriteColor\"\n type=\"text\"\n skyAutocomplete\n skyId\n #favoriteColorInput\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n"
14573
+ "fileName": "selection-modal-demo.component.spec.ts",
14574
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.component.spec.ts",
14575
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkySelectionModalHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\nimport { SelectionModalDemoModule } from './selection-modal-demo.module';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\ndescribe('Selection modal demo', () => {\n let mockSvc: jasmine.SpyObj<SelectionModalDemoService>;\n\n async function setupTest(): Promise<{\n harness: SkySelectionModalHarness;\n fixture: ComponentFixture<SelectionModalDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(SelectionModalDemoComponent);\n const openBtn = fixture.nativeElement.querySelector(\n '.selection-modal-demo-show-btn'\n );\n\n openBtn.click();\n fixture.detectChanges();\n\n const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n\n const harness = await rootLoader.getHarness(SkySelectionModalHarness);\n return { harness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('SelectionModalDemoService', ['search']);\n\n mockSvc.search.and.callFake((searchText) => {\n return of({\n hasMore: false,\n people:\n searchText === 'ra'\n ? [\n {\n id: '1',\n name: 'Rachel',\n },\n ]\n : [],\n totalCount: 1,\n });\n });\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, SelectionModalDemoModule],\n });\n });\n\n it('should update the selected items list when an item is selected', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.saveAndClose();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(1);\n expect(selectedItemEls[0].innerText.trim()).toBe('Rachel');\n });\n\n it('should not update the selected items list when the user cancels the selection modal', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.cancel();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(0);\n });\n});\n"
14581
14576
  },
14582
14577
  {
14583
- "fileName": "autocomplete-demo.component.ts",
14584
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/basic/autocomplete-demo.component.ts",
14585
- "rawContents": "import { Component } from '@angular/core';\nimport { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public colors: { name: string }[] = [\n { name: 'Red' },\n { name: 'Blue' },\n { name: 'Green' },\n { name: 'Orange' },\n { name: 'Pink' },\n { name: 'Purple' },\n { name: 'Yellow' },\n { name: 'Brown' },\n { name: 'Turquoise' },\n { name: 'White' },\n { name: 'Black' },\n ];\n\n public myForm: UntypedFormGroup;\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.myForm = formBuilder.group({\n favoriteColor: undefined,\n });\n }\n}\n"
14578
+ "fileName": "selection-modal-demo.component.html",
14579
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.component.html",
14580
+ "rawContents": "<div class=\"sky-margin-stacked-xl\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default selection-modal-demo-show-btn\"\n (click)=\"showSelectionModal()\"\n >\n Select a value\n </button>\n</div>\n\n<div *ngIf=\"selectedPeople?.length\">\n Selected people:\n <ul class=\"selection-modal-demo-selected\">\n <li *ngFor=\"let selectedPerson of selectedPeople\">\n {{ selectedPerson.name }}\n </li>\n </ul>\n</div>\n"
14586
14581
  },
14587
14582
  {
14588
- "fileName": "autocomplete-demo.module.ts",
14589
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/basic/autocomplete-demo.module.ts",
14590
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [CommonModule, ReactiveFormsModule, SkyAutocompleteModule],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14583
+ "fileName": "selection-modal-demo-search-results.ts",
14584
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo-search-results.ts",
14585
+ "rawContents": "import { SelectionModalDemoPerson } from './selection-modal-demo-person';\n\nexport interface SelectionModalAsyncDemoSearchResults {\n hasMore: boolean;\n people: SelectionModalDemoPerson[];\n totalCount: number;\n}\n"
14591
14586
  },
14592
14587
  {
14593
- "fileName": "autocomplete-demo.component.html",
14594
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/autocomplete-demo.component.html",
14595
- "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <p>\n The following field has a preselected value and utilizes a custom search\n function, as well as a custom template for the search results.\n </p>\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"largestOceanInput.id\">\n Largest ocean\n </label>\n <sky-autocomplete\n descriptorProperty=\"title\"\n [data]=\"oceans\"\n [search]=\"getOceanSearchFunction()\"\n [searchResultTemplate]=\"oceanSearchResultTemplate\"\n >\n <input\n formControlName=\"largestOcean\"\n type=\"text\"\n skyAutocomplete\n skyId\n #largestOceanInput=\"skyId\"\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n\n<ng-template let-item=\"item\" #oceanSearchResultTemplate>\n <sky-icon icon=\"long-arrow-right\"></sky-icon>\n {{ item.title }} &bull; ID {{ item.id }}\n</ng-template>\n"
14588
+ "fileName": "selection-modal-demo-person.ts",
14589
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo-person.ts",
14590
+ "rawContents": "export interface SelectionModalDemoPerson {\n id: string;\n name: string;\n}\n"
14596
14591
  },
14597
14592
  {
14598
- "fileName": "autocomplete-demo.component.ts",
14599
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/autocomplete-demo.component.ts",
14600
- "rawContents": "import { Component } from '@angular/core';\nimport {\n UntypedFormBuilder,\n UntypedFormControl,\n UntypedFormGroup,\n} from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunction,\n SkyAutocompleteSearchFunctionResponse,\n} from '@skyux/lookup';\n\nimport { Ocean } from './ocean';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public myForm: UntypedFormGroup;\n\n public largestOcean: UntypedFormControl;\n\n public oceans: Ocean[] = [\n { title: 'Arctic', id: 1 },\n { title: 'Atlantic', id: 2 },\n { title: 'Indian', id: 3 },\n { title: 'Pacific', id: 4 },\n ];\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.largestOcean = formBuilder.control({ title: 'Arctic', id: 1 });\n this.myForm = formBuilder.group({\n largestOcean: this.largestOcean,\n });\n }\n\n public getOceanSearchFunction(): SkyAutocompleteSearchFunction {\n const searchFunction = (\n searchText: string,\n oceans: Ocean[]\n ): SkyAutocompleteSearchFunctionResponse => {\n return new Promise((resolve) => {\n const searchTextLower = searchText.toLowerCase();\n\n const results = oceans.filter((ocean: Ocean) => {\n const val = ocean.title;\n const isMatch =\n val && val.toString().toLowerCase().indexOf(searchTextLower) > -1;\n return isMatch;\n });\n\n // Simulate an async request.\n setTimeout(() => {\n resolve(results);\n }, 500);\n });\n };\n\n return searchFunction;\n }\n}\n"
14593
+ "fileName": "selection-modal-demo.service.ts",
14594
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.service.ts",
14595
+ "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalAsyncDemoSearchResults } from './selection-modal-demo-search-results';\n\nconst people: SelectionModalDemoPerson[] = [\n { id: '1', name: 'Abed' },\n { id: '2', name: 'Alex' },\n { id: '3', name: 'Ben' },\n { id: '4', name: 'Britta' },\n { id: '5', name: 'Buzz' },\n { id: '6', name: 'Craig' },\n { id: '7', name: 'Elroy' },\n { id: '8', name: 'Garrett' },\n { id: '9', name: 'Ian' },\n { id: '10', name: 'Jeff' },\n { id: '11', name: 'Leonard' },\n { id: '12', name: 'Neil' },\n { id: '13', name: 'Pierce' },\n { id: '14', name: 'Preston' },\n { id: '15', name: 'Rachel' },\n { id: '16', name: 'Shirley' },\n { id: '17', name: 'Todd' },\n { id: '18', name: 'Troy' },\n { id: '19', name: 'Vaughn' },\n { id: '20', name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SelectionModalDemoService {\n public addItem(item: SelectionModalDemoPerson): void {\n people.push(item);\n }\n\n public search(\n searchText: string\n ): Observable<SelectionModalAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n}\n"
14601
14596
  },
14602
14597
  {
14603
- "fileName": "autocomplete-demo.module.ts",
14604
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/autocomplete-demo.module.ts",
14605
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyIconModule } from '@skyux/indicators';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutocompleteModule,\n SkyIconModule,\n SkyIdModule,\n ],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14598
+ "fileName": "selection-modal-demo.module.ts",
14599
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.module.ts",
14600
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkySelectionModalModule } from '@skyux/lookup';\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { SelectionModalDemoAddItemComponent } from './selection-modal-demo-add-item.component';\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\n\n@NgModule({\n declarations: [\n SelectionModalDemoAddItemComponent,\n SelectionModalDemoComponent,\n ],\n exports: [SelectionModalDemoComponent],\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyModalModule,\n SkySelectionModalModule,\n ],\n})\nexport class SelectionModalDemoModule {}\n"
14606
14601
  },
14607
14602
  {
14608
- "fileName": "ocean.ts",
14609
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/ocean.ts",
14610
- "rawContents": "export interface Ocean {\n id: number;\n title: string;\n}\n"
14603
+ "fileName": "selection-modal-demo.component.ts",
14604
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.component.ts",
14605
+ "rawContents": "import { Component, OnDestroy, inject } from '@angular/core';\nimport {\n SkySelectionModalAddClickEventArgs,\n SkySelectionModalCloseArgs,\n SkySelectionModalSearchResult,\n SkySelectionModalService,\n} from '@skyux/lookup';\nimport { SkyModalCloseArgs, SkyModalService } from '@skyux/modals';\n\nimport { Subscription } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { SelectionModalDemoAddItemComponent } from './selection-modal-demo-add-item.component';\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\n@Component({\n selector: 'app-selection-modal-demo',\n templateUrl: './selection-modal-demo.component.html',\n})\nexport class SelectionModalDemoComponent implements OnDestroy {\n public selectedPeople: SelectionModalDemoPerson[] | undefined;\n\n #modalService = inject(SkyModalService);\n #searchSvc = inject(SelectionModalDemoService);\n #selectionModalSvc = inject(SkySelectionModalService);\n #subscriptions = new Subscription();\n\n public ngOnDestroy(): void {\n this.#subscriptions.unsubscribe();\n }\n\n public showSelectionModal(): void {\n const instance = this.#selectionModalSvc.open({\n descriptorProperty: 'name',\n idProperty: 'id',\n searchAsync: (args) =>\n this.#searchSvc.search(args.searchText).pipe(\n map(\n (results): SkySelectionModalSearchResult => ({\n hasMore: results.hasMore,\n items: results.people,\n totalCount: results.totalCount,\n })\n )\n ),\n selectMode: 'single',\n showAddButton: true,\n addClick: (args: SkySelectionModalAddClickEventArgs) => {\n const modal = this.#modalService.open(\n SelectionModalDemoAddItemComponent\n );\n this.#subscriptions.add(\n modal.closed.subscribe((close: SkyModalCloseArgs) => {\n if (close.reason === 'save') {\n this.#searchSvc.addItem(close.data);\n args.itemAdded({ item: close.data });\n }\n })\n );\n },\n });\n\n this.#subscriptions.add(\n instance.closed.subscribe((args: SkySelectionModalCloseArgs) => {\n if (args.reason === 'save') {\n this.selectedPeople =\n args.selectedItems as SelectionModalDemoPerson[];\n }\n })\n );\n }\n}\n"
14611
14606
  },
14612
14607
  {
14613
- "fileName": "autocomplete-demo.component.html",
14614
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/search-filters/autocomplete-demo.component.html",
14615
- "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <p>\n The following field provides a custom function that filters the data before\n every search attempt.\n </p>\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"favoriteColorInput.id\">\n Color (\"Red\" is not available)\n </label>\n <sky-autocomplete [data]=\"colors\" [searchFilters]=\"searchFilters\">\n <input\n formControlName=\"favoriteColor\"\n skyAutocomplete\n skyId\n type=\"text\"\n #favoriteColorInput=\"skyId\"\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n"
14608
+ "fileName": "selection-modal-demo.component.spec.ts",
14609
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.component.spec.ts",
14610
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkySelectionModalHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\nimport { SelectionModalDemoModule } from './selection-modal-demo.module';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\ndescribe('Selection modal demo', () => {\n let mockSvc: jasmine.SpyObj<SelectionModalDemoService>;\n\n async function setupTest(): Promise<{\n harness: SkySelectionModalHarness;\n fixture: ComponentFixture<SelectionModalDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(SelectionModalDemoComponent);\n const openBtn = fixture.nativeElement.querySelector(\n '.selection-modal-demo-show-btn'\n );\n\n openBtn.click();\n fixture.detectChanges();\n\n const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n\n const harness = await rootLoader.getHarness(SkySelectionModalHarness);\n return { harness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('SelectionModalDemoService', ['search']);\n\n mockSvc.search.and.callFake((searchText) => {\n return of({\n hasMore: false,\n people:\n searchText === 'ra'\n ? [\n {\n id: '1',\n name: 'Rachel',\n },\n ]\n : [],\n totalCount: 1,\n });\n });\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, SelectionModalDemoModule],\n });\n });\n\n it('should update the selected items list when an item is selected', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.saveAndClose();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(1);\n expect(selectedItemEls[0].innerText.trim()).toBe('Rachel');\n });\n\n it('should not update the selected items list when the user cancels the selection modal', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.cancel();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(0);\n });\n});\n"
14616
14611
  },
14617
14612
  {
14618
- "fileName": "autocomplete-demo.component.ts",
14619
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/search-filters/autocomplete-demo.component.ts",
14620
- "rawContents": "import { Component } from '@angular/core';\nimport { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';\nimport { SkyAutocompleteSearchFunctionFilter } from '@skyux/lookup';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public colors: { name: string }[] = [\n { name: 'Red' },\n { name: 'Blue' },\n { name: 'Green' },\n { name: 'Orange' },\n { name: 'Pink' },\n { name: 'Purple' },\n { name: 'Yellow' },\n { name: 'Brown' },\n { name: 'Turquoise' },\n { name: 'White' },\n { name: 'Black' },\n ];\n\n public myForm: UntypedFormGroup;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[] = [\n (searchText: string, item: { name: string }): boolean => {\n return item.name !== 'Red';\n },\n ];\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.myForm = formBuilder.group({\n favoriteColor: undefined,\n });\n }\n}\n"
14613
+ "fileName": "selection-modal-demo.component.html",
14614
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.component.html",
14615
+ "rawContents": "<div class=\"sky-margin-stacked-xl\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default selection-modal-demo-show-btn\"\n (click)=\"showSelectionModal()\"\n >\n Select a value\n </button>\n</div>\n\n<div *ngIf=\"selectedPeople?.length\">\n Selected people:\n <ul class=\"selection-modal-demo-selected\">\n <li *ngFor=\"let selectedPerson of selectedPeople\">\n {{ selectedPerson.name }}\n </li>\n </ul>\n</div>\n"
14621
14616
  },
14622
14617
  {
14623
- "fileName": "autocomplete-demo.module.ts",
14624
- "filePath": "/projects/lookup/documentation/code-examples/autocomplete/search-filters/autocomplete-demo.module.ts",
14625
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutocompleteModule,\n SkyIdModule,\n ],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14618
+ "fileName": "selection-modal-demo-search-results.ts",
14619
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-search-results.ts",
14620
+ "rawContents": "import { SelectionModalDemoPerson } from './selection-modal-demo-person';\n\nexport interface SelectionModalAsyncDemoSearchResults {\n hasMore: boolean;\n people: SelectionModalDemoPerson[];\n totalCount: number;\n}\n"
14626
14621
  },
14627
14622
  {
14628
- "fileName": "country-field-demo.component.html",
14629
- "filePath": "/projects/lookup/documentation/code-examples/country-field/basic/country-field-demo.component.html",
14630
- "rawContents": "<form [formGroup]=\"countryForm\">\n <sky-input-box>\n <sky-country-field formControlName=\"countryControl\"> </sky-country-field>\n </sky-input-box>\n</form>\n"
14623
+ "fileName": "selection-modal-demo-person.ts",
14624
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-person.ts",
14625
+ "rawContents": "export interface SelectionModalDemoPerson {\n id: string;\n name: string;\n}\n"
14631
14626
  },
14632
14627
  {
14633
- "fileName": "country-field-demo.component.ts",
14634
- "filePath": "/projects/lookup/documentation/code-examples/country-field/basic/country-field-demo.component.ts",
14635
- "rawContents": "import { Component } from '@angular/core';\nimport {\n UntypedFormControl,\n UntypedFormGroup,\n Validators,\n} from '@angular/forms';\n\n@Component({\n selector: 'app-country-field-demo',\n templateUrl: './country-field-demo.component.html',\n})\nexport class CountryFieldDemoComponent {\n public countryControl: UntypedFormControl;\n\n public countryForm: UntypedFormGroup;\n\n constructor() {\n this.countryControl = new UntypedFormControl();\n this.countryControl.setValue({\n name: 'Australia',\n iso2: 'au',\n });\n this.countryForm = new UntypedFormGroup({\n countryControl: this.countryControl,\n });\n\n this.countryControl.setValidators([Validators.required]);\n }\n}\n"
14628
+ "fileName": "selection-modal-demo-add-item.component.ts",
14629
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-add-item.component.ts",
14630
+ "rawContents": "import { Component, inject } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { SkyModalInstance } from '@skyux/modals';\n\nlet nextId = 21;\n\n@Component({\n selector: 'app-selection-modal-demo-add-item',\n templateUrl: './selection-modal-demo-add-item.component.html',\n})\nexport class SelectionModalDemoAddItemComponent {\n public readonly formGroup: FormGroup;\n\n #modal = inject(SkyModalInstance);\n\n constructor() {\n this.formGroup = inject(FormBuilder).group({\n id: [`${nextId++}`],\n name: ['', Validators.required],\n });\n }\n\n public close() {\n this.#modal.close();\n }\n\n public save() {\n if (this.formGroup.valid) {\n this.#modal.close(this.formGroup.value, 'save');\n } else {\n this.formGroup.markAllAsTouched();\n }\n }\n}\n"
14636
14631
  },
14637
14632
  {
14638
- "fileName": "country-field-demo.module.ts",
14639
- "filePath": "/projects/lookup/documentation/code-examples/country-field/basic/country-field-demo.module.ts",
14640
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyCountryFieldModule } from '@skyux/lookup';\n\nimport { CountryFieldDemoComponent } from './country-field-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyCountryFieldModule,\n SkyInputBoxModule,\n ],\n declarations: [CountryFieldDemoComponent],\n exports: [CountryFieldDemoComponent],\n})\nexport class CountryFieldDemoModule {}\n"
14633
+ "fileName": "selection-modal-demo-add-item.component.html",
14634
+ "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-add-item.component.html",
14635
+ "rawContents": "<sky-modal>\n <sky-modal-header>\n <h2>Add Item</h2>\n </sky-modal-header>\n <sky-modal-content>\n <form novalidate [formGroup]=\"formGroup\" (ngSubmit)=\"save()\">\n <sky-input-box>\n <label class=\"sky-control-label\">Name</label>\n <input\n type=\"text\"\n autocapitalize=\"words\"\n autocomplete=\"off\"\n formControlName=\"name\"\n class=\"sky-form-control\"\n />\n </sky-input-box>\n </form>\n </sky-modal-content>\n <sky-modal-footer>\n <button class=\"sky-btn sky-btn-default\" (click)=\"close()\">Cancel</button>\n <button class=\"sky-btn sky-btn-primary\" (click)=\"save()\">Add</button>\n </sky-modal-footer>\n</sky-modal>\n"
14641
14636
  },
14642
14637
  {
14643
- "fileName": "lookup-async-demo-search-results.ts",
14644
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo-search-results.ts",
14645
- "rawContents": "import { LookupDemoPerson } from './lookup-demo-person';\n\nexport interface LookupAsyncDemoSearchResults {\n hasMore: boolean;\n people: LookupDemoPerson[];\n totalCount: number;\n}\n"
14638
+ "fileName": "search-demo.module.ts",
14639
+ "filePath": "/projects/lookup/documentation/code-examples/search/basic/search-demo.module.ts",
14640
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { SkyToolbarModule } from '@skyux/layout';\nimport { SkyRepeaterModule } from '@skyux/lists';\nimport { SkySearchModule } from '@skyux/lookup';\n\nimport { SearchDemoComponent } from './search-demo.component';\n\n@NgModule({\n imports: [CommonModule, SkyRepeaterModule, SkySearchModule, SkyToolbarModule],\n declarations: [SearchDemoComponent],\n exports: [SearchDemoComponent],\n})\nexport class SearchDemoModule {}\n"
14646
14641
  },
14647
14642
  {
14648
- "fileName": "lookup-async-demo.component.html",
14649
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.html",
14650
- "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box data-sky-id=\"favorite-names-field\">\n <label class=\"sky-control-label\" skyId #favoriteNamesLabel=\"skyId\">\n Favorite name(s)\n </label>\n <sky-lookup\n formControlName=\"favoriteNames\"\n idProperty=\"name\"\n [ariaLabelledBy]=\"favoriteNamesLabel.id\"\n [enableShowMore]=\"true\"\n (searchAsync)=\"searchAsync($event)\"\n [showAddButton]=\"true\"\n (addClick)=\"addClick($event)\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14643
+ "fileName": "search-demo.component.ts",
14644
+ "filePath": "/projects/lookup/documentation/code-examples/search/basic/search-demo.component.ts",
14645
+ "rawContents": "import { Component } from '@angular/core';\n\nimport { LookupDemoItem } from './lookup-demo-item';\n\n@Component({\n selector: 'app-search-demo',\n templateUrl: './search-demo.component.html',\n})\nexport class SearchDemoComponent {\n public displayedItems: LookupDemoItem[];\n\n private items: LookupDemoItem[] = [\n {\n title: 'Call Robert Hernandez',\n note: 'Robert recently gave a very generous gift. We should call to thank him.',\n },\n {\n title: 'Send invitation to ball',\n note: \"The Spring Ball is coming up soon. Let's get those invitations out!\",\n },\n {\n title: 'Clean up desk',\n note: 'File and organize papers.',\n },\n {\n title: 'Investigate leads',\n note: 'Check out leads for important charity event funding.',\n },\n {\n title: 'Send thank you note',\n note: 'Send a thank you note to Timothy for his donation.',\n },\n ];\n\n public searchText = '';\n\n constructor() {\n this.displayedItems = this.items;\n }\n\n public searchApplied(searchText: string): void {\n let filteredItems = this.items;\n this.searchText = searchText;\n\n if (searchText) {\n filteredItems = this.items.filter(function (item: LookupDemoItem) {\n let property: keyof typeof item;\n\n for (property in item) {\n if (\n Object.prototype.hasOwnProperty.call(item, property) &&\n (property === 'title' || property === 'note')\n ) {\n if (item[property].indexOf(searchText) > -1) {\n return true;\n }\n }\n }\n\n return false;\n });\n }\n this.displayedItems = filteredItems;\n }\n}\n"
14651
14646
  },
14652
14647
  {
14653
- "fileName": "lookup-async-demo.component.scss",
14654
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.scss",
14655
- "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14648
+ "fileName": "search-demo.component.html",
14649
+ "filePath": "/projects/lookup/documentation/code-examples/search/basic/search-demo.component.html",
14650
+ "rawContents": "<sky-toolbar>\n <sky-toolbar-item>\n <button\n class=\"sky-btn sky-btn-default sky-demo-search-bar-item\"\n (click)=\"searchApplied('Robert')\"\n >\n Predefined search text\n </button>\n </sky-toolbar-item>\n <sky-toolbar-item>\n <sky-search\n [searchText]=\"searchText\"\n [debounceTime]=\"250\"\n (searchApply)=\"searchApplied($event)\"\n (searchChange)=\"searchApplied($event)\"\n >\n </sky-search>\n </sky-toolbar-item>\n</sky-toolbar>\n<sky-repeater expandMode=\"none\">\n <sky-repeater-item *ngFor=\"let item of displayedItems\">\n <sky-repeater-item-title>\n {{ item.title }}\n </sky-repeater-item-title>\n <sky-repeater-item-content>\n <div>\n {{ item.note }}\n </div>\n </sky-repeater-item-content>\n </sky-repeater-item>\n</sky-repeater>\n"
14656
14651
  },
14657
14652
  {
14658
- "fileName": "lookup-async-demo.component.spec.ts",
14659
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.spec.ts",
14660
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\nimport { LookupAsyncDemoModule } from './lookup-async-demo.module';\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\n\ndescribe('Lookup asynchronous search demo', () => {\n let mockSvc!: jasmine.SpyObj<LookupAsyncDemoService>;\n\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupAsyncDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupAsyncDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('LookupAsyncDemoService', ['search']);\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, LookupAsyncDemoModule],\n providers: [\n {\n provide: LookupAsyncDemoService,\n useValue: mockSvc,\n },\n ],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n mockSvc.search.and.callFake((searchText) =>\n of({\n hasMore: false,\n people:\n searchText === 'b'\n ? [\n {\n id: '21',\n name: 'Bernard',\n },\n ]\n : [],\n totalCount: 1,\n })\n );\n\n await lookupHarness?.enterText('b');\n await lookupHarness?.selectSearchResult({\n text: 'Bernard',\n });\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [\n { id: '16', name: 'Shirley' },\n { id: '21', name: 'Bernard' },\n ]\n );\n });\n});\n"
14653
+ "fileName": "lookup-demo-item.ts",
14654
+ "filePath": "/projects/lookup/documentation/code-examples/search/basic/lookup-demo-item.ts",
14655
+ "rawContents": "export interface LookupDemoItem {\n title: string;\n note: string;\n}\n"
14661
14656
  },
14662
14657
  {
14663
- "fileName": "lookup-async-demo.component.ts",
14664
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.ts",
14665
- "rawContents": "import { Component, OnDestroy, OnInit, inject } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyWaitService } from '@skyux/indicators';\nimport {\n SkyAutocompleteSearchAsyncArgs,\n SkyLookupAddClickEventArgs,\n} from '@skyux/lookup';\nimport { SkyModalCloseArgs, SkyModalService } from '@skyux/modals';\n\nimport { Subscription } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\nimport { LookupDemoAddItemComponent } from './lookup-demo-add-item.component';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-async-lookup-demo',\n templateUrl: './lookup-async-demo.component.html',\n styleUrls: ['./lookup-async-demo.component.scss'],\n})\nexport class LookupAsyncDemoComponent implements OnInit, OnDestroy {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n #modalService = inject(SkyModalService);\n #subscriptions = new Subscription();\n #svc = inject(LookupAsyncDemoService);\n #waitSvc = inject(SkyWaitService);\n\n constructor(formBuilder: FormBuilder) {\n const names = new FormControl<LookupDemoPerson[]>([\n { id: '16', name: 'Shirley' },\n ]);\n\n this.favoritesForm = formBuilder.group({\n favoriteNames: names,\n });\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public ngOnDestroy(): void {\n this.#subscriptions.unsubscribe();\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n\n public searchAsync(args: SkyAutocompleteSearchAsyncArgs): void {\n // In a real-world application the search service might return an Observable\n // created by calling HttpClient.get(). Assigning that Observable to the result\n // allows the lookup component to cancel the web request if it does not complete\n // before the user searches again.\n args.result = this.#svc.search(args.searchText).pipe(\n map((result) => ({\n hasMore: result.hasMore,\n items: result.people,\n totalCount: result.totalCount,\n }))\n );\n }\n\n public addClick(args: SkyLookupAddClickEventArgs): void {\n const modal = this.#modalService.open(LookupDemoAddItemComponent);\n this.#subscriptions.add(\n modal.closed.subscribe((close: SkyModalCloseArgs) => {\n if (close.reason === 'save') {\n this.#subscriptions.add(\n this.#waitSvc\n .blockingWrap(this.#svc.addPerson(close.data))\n .subscribe((data) => {\n args.itemAdded({\n item: close.data,\n data: data,\n });\n })\n );\n }\n })\n );\n }\n}\n"
14658
+ "fileName": "lookup-single-demo.module.ts",
14659
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.module.ts",
14660
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupSingleSelectDemoComponent } from './lookup-single-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupSingleSelectDemoComponent],\n exports: [LookupSingleSelectDemoComponent],\n})\nexport class LookupSingleSelectDemoModule {}\n"
14666
14661
  },
14667
14662
  {
14668
- "fileName": "lookup-async-demo.module.ts",
14669
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.module.ts",
14670
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\nimport { LookupDemoAddItemComponent } from './lookup-demo-add-item.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyIdModule,\n SkyInputBoxModule,\n SkyModalModule,\n SkyLookupModule,\n ],\n declarations: [LookupAsyncDemoComponent, LookupDemoAddItemComponent],\n exports: [LookupAsyncDemoComponent],\n})\nexport class LookupAsyncDemoModule {}\n"
14663
+ "fileName": "lookup-single-demo.component.ts",
14664
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.ts",
14665
+ "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyAutocompleteSearchFunctionFilter } from '@skyux/lookup';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-single-select-lookup-demo',\n templateUrl: './lookup-single-demo.component.html',\n styleUrls: ['./lookup-single-demo.component.scss'],\n})\nexport class LookupSingleSelectDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteName: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[];\n\n public people: LookupDemoPerson[] = [\n { name: 'Abed' },\n { name: 'Alex' },\n { name: 'Ben' },\n { name: 'Britta' },\n { name: 'Buzz' },\n { name: 'Craig' },\n { name: 'Elroy' },\n { name: 'Garrett' },\n { name: 'Ian' },\n { name: 'Jeff' },\n { name: 'Leonard' },\n { name: 'Neil' },\n { name: 'Pierce' },\n { name: 'Preston' },\n { name: 'Rachel' },\n { name: 'Shirley' },\n { name: 'Todd' },\n { name: 'Troy' },\n { name: 'Vaughn' },\n { name: 'Vicki' },\n ];\n\n public name: LookupDemoPerson[] = [this.people[15]];\n\n constructor(formBuilder: FormBuilder) {\n this.favoritesForm = formBuilder.group({\n favoriteName: [[this.people[15]]],\n });\n\n this.searchFilters = [\n (_, item): boolean => {\n const names = this.favoritesForm.value.favoriteName;\n\n // Only show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14671
14666
  },
14672
14667
  {
14673
- "fileName": "lookup-async-demo.service.ts",
14674
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.service.ts",
14675
- "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { LookupAsyncDemoSearchResults } from './lookup-async-demo-search-results';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\nconst people: LookupDemoPerson[] = [\n { id: '1', name: 'Abed' },\n { id: '2', name: 'Alex' },\n { id: '3', name: 'Ben' },\n { id: '4', name: 'Britta' },\n { id: '5', name: 'Buzz' },\n { id: '6', name: 'Craig' },\n { id: '7', name: 'Elroy' },\n { id: '8', name: 'Garrett' },\n { id: '9', name: 'Ian' },\n { id: '10', name: 'Jeff' },\n { id: '11', name: 'Leonard' },\n { id: '12', name: 'Neil' },\n { id: '13', name: 'Pierce' },\n { id: '14', name: 'Preston' },\n { id: '15', name: 'Rachel' },\n { id: '16', name: 'Shirley' },\n { id: '17', name: 'Todd' },\n { id: '18', name: 'Troy' },\n { id: '19', name: 'Vaughn' },\n { id: '20', name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LookupAsyncDemoService {\n public search(searchText: string): Observable<LookupAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n\n public addPerson(person: LookupDemoPerson): Observable<LookupDemoPerson[]> {\n // Simulate adding a person with a network call.\n if (!people.some((item) => item.name === person.name)) {\n people.unshift(person);\n }\n\n return of(people.slice()).pipe(delay(800));\n }\n}\n"
14668
+ "fileName": "lookup-single-demo.component.spec.ts",
14669
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.spec.ts",
14670
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupSingleSelectDemoComponent } from './lookup-single-demo.component';\nimport { LookupSingleSelectDemoModule } from './lookup-single-demo.module';\n\ndescribe('Lookup single select demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupSingleSelectDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupSingleSelectDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-name-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupSingleSelectDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getValue()).toBeResolvedTo('Shirley');\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('be');\n await lookupHarness?.selectSearchResult({\n text: 'Ben',\n });\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteName).toEqual([\n { name: 'Ben' },\n ]);\n });\n});\n"
14676
14671
  },
14677
14672
  {
14678
- "fileName": "lookup-demo-add-item.component.html",
14679
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-demo-add-item.component.html",
14680
- "rawContents": "<sky-modal>\n <sky-modal-header>\n <h2>Add Item</h2>\n </sky-modal-header>\n <sky-modal-content>\n <form novalidate [formGroup]=\"formGroup\" (ngSubmit)=\"save()\">\n <sky-input-box>\n <label class=\"sky-control-label\">Name</label>\n <input\n type=\"text\"\n autocapitalize=\"words\"\n autocomplete=\"off\"\n formControlName=\"name\"\n class=\"sky-form-control\"\n />\n </sky-input-box>\n </form>\n </sky-modal-content>\n <sky-modal-footer>\n <button class=\"sky-btn sky-btn-default\" (click)=\"close()\">Cancel</button>\n <button class=\"sky-btn sky-btn-primary\" (click)=\"save()\">Add</button>\n </sky-modal-footer>\n</sky-modal>\n"
14673
+ "fileName": "lookup-single-demo.component.scss",
14674
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.scss",
14675
+ "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14681
14676
  },
14682
14677
  {
14683
- "fileName": "lookup-demo-add-item.component.ts",
14684
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-demo-add-item.component.ts",
14685
- "rawContents": "import { Component, inject } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { SkyModalInstance } from '@skyux/modals';\n\nlet nextId = 21;\n\n@Component({\n selector: 'app-lookup-demo-add-item',\n templateUrl: './lookup-demo-add-item.component.html',\n})\nexport class LookupDemoAddItemComponent {\n public readonly formGroup: FormGroup;\n\n #modal = inject(SkyModalInstance);\n\n constructor() {\n this.formGroup = inject(FormBuilder).group({\n id: [`${nextId++}`],\n name: ['', Validators.required],\n });\n }\n\n public close() {\n this.#modal.close();\n }\n\n public save() {\n if (this.formGroup.valid) {\n this.#modal.close(this.formGroup.value, 'save');\n } else {\n this.formGroup.markAllAsTouched();\n }\n }\n}\n"
14678
+ "fileName": "lookup-single-demo.component.html",
14679
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.html",
14680
+ "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box data-sky-id=\"favorite-name-field\" labelText=\"Favorite name\">\n <sky-lookup\n formControlName=\"favoriteName\"\n selectMode=\"single\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [showAddButton]=\"true\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14686
14681
  },
14687
14682
  {
14688
14683
  "fileName": "lookup-demo-person.ts",
14689
- "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-demo-person.ts",
14690
- "rawContents": "export interface LookupDemoPerson {\n id: string;\n name: string;\n}\n"
14691
- },
14692
- {
14693
- "fileName": "lookup-async-demo-search-results.ts",
14694
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo-search-results.ts",
14695
- "rawContents": "import { LookupDemoPerson } from './lookup-demo-person';\n\nexport interface LookupAsyncDemoSearchResults {\n hasMore: boolean;\n people: LookupDemoPerson[];\n totalCount: number;\n}\n"
14684
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-demo-person.ts",
14685
+ "rawContents": "export interface LookupDemoPerson {\n name: string;\n}\n"
14696
14686
  },
14697
14687
  {
14698
- "fileName": "lookup-async-demo.component.html",
14699
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.html",
14700
- "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite name(s)\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n idProperty=\"name\"\n [enableShowMore]=\"true\"\n (searchAsync)=\"searchAsync($event)\"\n [showAddButton]=\"true\"\n (addClick)=\"addClick($event)\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14688
+ "fileName": "lookup-result-templates-item-harness.ts",
14689
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-item-harness.ts",
14690
+ "rawContents": "import { ComponentHarness } from '@angular/cdk/testing';\n\n/**\n * Harness for interacting with a lookup component in tests.\n * @internal\n */\nexport class LookupResultTemplatesItemHarness extends ComponentHarness {\n public static hostSelector = '.lookup-demo-template-item';\n\n #getName = this.locatorFor('.lookup-demo-template-name');\n #getFormalName = this.locatorFor('.lookup-demo-template-formal-name');\n\n public async getName(): Promise<string> {\n return (await this.#getName()).text();\n }\n\n public async getFormalName(): Promise<string> {\n return (await this.#getFormalName()).text();\n }\n}\n"
14701
14691
  },
14702
14692
  {
14703
- "fileName": "lookup-async-demo.component.scss",
14704
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.scss",
14705
- "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14693
+ "fileName": "lookup-result-templates-demo.module.ts",
14694
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.module.ts",
14695
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupResultTemplatesDemoComponent } from './lookup-result-templates-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupResultTemplatesDemoComponent],\n exports: [LookupResultTemplatesDemoComponent],\n})\nexport class LookupResultTemplatesDemoModule {}\n"
14706
14696
  },
14707
14697
  {
14708
- "fileName": "lookup-async-demo.component.spec.ts",
14709
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.spec.ts",
14710
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\nimport { LookupAsyncDemoModule } from './lookup-async-demo.module';\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\n\ndescribe('Lookup asynchronous search demo', () => {\n let mockSvc!: jasmine.SpyObj<LookupAsyncDemoService>;\n\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupAsyncDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupAsyncDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('LookupAsyncDemoService', ['search']);\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, LookupAsyncDemoModule],\n providers: [\n {\n provide: LookupAsyncDemoService,\n useValue: mockSvc,\n },\n ],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n mockSvc.search.and.callFake((searchText) =>\n of({\n hasMore: false,\n people:\n searchText === 'b'\n ? [\n {\n name: 'Bernard',\n },\n ]\n : [],\n totalCount: 1,\n })\n );\n\n await lookupHarness?.enterText('b');\n await lookupHarness?.selectSearchResult({\n text: 'Bernard',\n });\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [{ name: 'Shirley' }, { name: 'Bernard' }]\n );\n });\n});\n"
14698
+ "fileName": "lookup-result-templates-demo.component.ts",
14699
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.ts",
14700
+ "rawContents": "import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunctionFilter,\n SkyLookupShowMoreConfig,\n} from '@skyux/lookup';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo',\n templateUrl: './lookup-result-templates-demo.component.html',\n styleUrls: ['./lookup-result-templates-demo.component.scss'],\n})\nexport class LookupResultTemplatesDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[];\n\n public people: LookupDemoPerson[] = [\n {\n name: 'Abed',\n formal: 'Mr. Nadir',\n },\n {\n name: 'Alex',\n formal: 'Mr. Osbourne',\n },\n {\n name: 'Ben',\n formal: 'Mr. Chang',\n },\n {\n name: 'Britta',\n formal: 'Ms. Perry',\n },\n {\n name: 'Buzz',\n formal: 'Mr. Hickey',\n },\n {\n name: 'Craig',\n formal: 'Mr. Pelton',\n },\n {\n name: 'Elroy',\n formal: 'Mr. Patashnik',\n },\n {\n name: 'Garrett',\n formal: 'Mr. Lambert',\n },\n {\n name: 'Ian',\n formal: 'Mr. Duncan',\n },\n {\n name: 'Jeff',\n formal: 'Mr. Winger',\n },\n {\n name: 'Leonard',\n formal: 'Mr. Rodriguez',\n },\n {\n name: 'Neil',\n formal: 'Mr. Neil',\n },\n {\n name: 'Pierce',\n formal: 'Mr. Hawthorne',\n },\n {\n name: 'Preston',\n formal: 'Mr. Koogler',\n },\n {\n name: 'Rachel',\n formal: 'Ms. Rachel',\n },\n {\n name: 'Shirley',\n formal: 'Ms. Bennett',\n },\n {\n name: 'Todd',\n formal: 'Mr. Jacobson',\n },\n {\n name: 'Troy',\n formal: 'Mr. Barnes',\n },\n {\n name: 'Vaughn',\n formal: 'Mr. Miller',\n },\n {\n name: 'Vicki',\n formal: 'Ms. Jenkins',\n },\n ];\n\n public showMoreConfig: SkyLookupShowMoreConfig = {\n nativePickerConfig: {},\n };\n\n @ViewChild('modalItemTemplate')\n public set modalItemTemplate(template: TemplateRef<unknown>) {\n if (this.showMoreConfig.nativePickerConfig) {\n this.showMoreConfig.nativePickerConfig.itemTemplate = template;\n } else {\n this.showMoreConfig.nativePickerConfig = { itemTemplate: template };\n }\n }\n\n constructor(formBuilder: FormBuilder) {\n this.favoritesForm = formBuilder.group({\n favoriteNames: [[this.people[15]]],\n });\n\n this.searchFilters = [\n (_, item): boolean => {\n const names = this.favoritesForm.value.favoriteNames;\n\n // Only show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14711
14701
  },
14712
14702
  {
14713
- "fileName": "lookup-async-demo.component.ts",
14714
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.ts",
14715
- "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyWaitService } from '@skyux/indicators';\nimport {\n SkyAutocompleteSearchAsyncArgs,\n SkyLookupAddClickEventArgs,\n} from '@skyux/lookup';\n\nimport { map } from 'rxjs/operators';\n\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-async-lookup-demo',\n templateUrl: './lookup-async-demo.component.html',\n styleUrls: ['./lookup-async-demo.component.scss'],\n})\nexport class LookupAsyncDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n #svc: LookupAsyncDemoService;\n #waitSvc: SkyWaitService;\n\n constructor(\n formBuilder: FormBuilder,\n svc: LookupAsyncDemoService,\n waitSvc: SkyWaitService\n ) {\n this.#svc = svc;\n this.#waitSvc = waitSvc;\n\n const names = new FormControl<LookupDemoPerson[]>([{ name: 'Shirley' }]);\n\n this.favoritesForm = formBuilder.group({\n favoriteNames: names,\n });\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n\n public searchAsync(args: SkyAutocompleteSearchAsyncArgs): void {\n // In a real-world application the search service might return an Observable\n // created by calling HttpClient.get(). Assigning that Observable to the result\n // allows the lookup component to cancel the web request if it does not complete\n // before the user searches again.\n args.result = this.#svc.search(args.searchText).pipe(\n map((result) => ({\n hasMore: result.hasMore,\n items: result.people,\n totalCount: result.totalCount,\n }))\n );\n }\n\n public addClick(args: SkyLookupAddClickEventArgs): void {\n const person: LookupDemoPerson = {\n name: 'Newman',\n };\n\n this.#waitSvc.blockingWrap(this.#svc.addPerson(person)).subscribe(() => {\n args.itemAdded({\n item: person,\n });\n });\n }\n}\n"
14703
+ "fileName": "lookup-result-templates-demo.component.spec.ts",
14704
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.spec.ts",
14705
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupResultTemplatesDemoComponent } from './lookup-result-templates-demo.component';\nimport { LookupResultTemplatesDemoModule } from './lookup-result-templates-demo.module';\nimport { LookupResultTemplatesItemHarness } from './lookup-result-templates-item-harness';\n\ndescribe('Lookup result templates demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupResultTemplatesDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupResultTemplatesDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupResultTemplatesDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should use the expected dropdown item template', async () => {\n const { lookupHarness } = await setupTest();\n\n await lookupHarness?.enterText('be');\n\n const results = await lookupHarness?.getSearchResults();\n const templateItemHarness =\n results &&\n (await results[0].queryHarness(LookupResultTemplatesItemHarness));\n\n await expectAsync(templateItemHarness?.getName()).toBeResolvedTo('Abed');\n await expectAsync(templateItemHarness?.getFormalName()).toBeResolvedTo(\n 'Mr. Nadir'\n );\n });\n\n it('should use the expected modal item template', async () => {\n const { lookupHarness } = await setupTest();\n\n await lookupHarness?.clickShowMoreButton();\n\n const pickerHarness = await lookupHarness?.getShowMorePicker();\n await pickerHarness?.enterSearchText('be');\n\n const results = await pickerHarness?.getSearchResults();\n const templateItemHarness =\n results &&\n (await results[0].queryHarness(LookupResultTemplatesItemHarness));\n\n await expectAsync(templateItemHarness?.getName()).toBeResolvedTo('Abed');\n await expectAsync(templateItemHarness?.getFormalName()).toBeResolvedTo(\n 'Mr. Nadir'\n );\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('be');\n\n const allResultHarnesses = await lookupHarness?.getSearchResults();\n const firstResultHarness = allResultHarnesses && allResultHarnesses[0];\n await firstResultHarness?.select();\n\n expect(\n fixture.componentInstance.favoritesForm.controls.favoriteNames.value\n ).toEqual([\n { name: 'Shirley', formal: 'Ms. Bennett' },\n { name: 'Abed', formal: 'Mr. Nadir' },\n ]);\n });\n});\n"
14716
14706
  },
14717
14707
  {
14718
- "fileName": "lookup-async-demo.module.ts",
14719
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.module.ts",
14720
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupAsyncDemoComponent],\n exports: [LookupAsyncDemoComponent],\n})\nexport class LookupAsyncDemoModule {}\n"
14708
+ "fileName": "lookup-result-templates-demo.component.scss",
14709
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.scss",
14710
+ "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14721
14711
  },
14722
14712
  {
14723
- "fileName": "lookup-async-demo.service.ts",
14724
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.service.ts",
14725
- "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { LookupAsyncDemoSearchResults } from './lookup-async-demo-search-results';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\nconst people: LookupDemoPerson[] = [\n { name: 'Abed' },\n { name: 'Alex' },\n { name: 'Ben' },\n { name: 'Britta' },\n { name: 'Buzz' },\n { name: 'Craig' },\n { name: 'Elroy' },\n { name: 'Garrett' },\n { name: 'Ian' },\n { name: 'Jeff' },\n { name: 'Leonard' },\n { name: 'Neil' },\n { name: 'Pierce' },\n { name: 'Preston' },\n { name: 'Rachel' },\n { name: 'Shirley' },\n { name: 'Todd' },\n { name: 'Troy' },\n { name: 'Vaughn' },\n { name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LookupAsyncDemoService {\n public search(searchText: string): Observable<LookupAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n\n public addPerson(person: LookupDemoPerson): Observable<number> {\n // Simulate adding a person with a network call.\n if (!people.some((item) => item.name === person.name)) {\n people.unshift(person);\n }\n\n return of(1).pipe(delay(800));\n }\n}\n"
14713
+ "fileName": "lookup-result-templates-demo.component.html",
14714
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.html",
14715
+ "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite names\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [searchResultTemplate]=\"dropdownItemTemplate\"\n [showAddButton]=\"true\"\n [showMoreConfig]=\"showMoreConfig\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n\n<ng-template let-item=\"item\" #dropdownItemTemplate>\n <span class=\"lookup-demo-template-item\">\n <strong class=\"lookup-demo-template-name\">{{ item.name }}</strong\n ><br />\n <span class=\"lookup-demo-template-formal-name\">\n {{ item.formal }}\n </span>\n </span>\n</ng-template>\n<ng-template let-item=\"item\" #modalItemTemplate>\n <span class=\"lookup-demo-template-item\">\n <span class=\"lookup-demo-template-name\">{{ item.name }}</span\n ><br />\n <i class=\"lookup-demo-template-formal-name\">{{ item.formal }}</i>\n </span>\n</ng-template>\n"
14726
14716
  },
14727
14717
  {
14728
14718
  "fileName": "lookup-demo-person.ts",
14729
- "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-demo-person.ts",
14730
- "rawContents": "export interface LookupDemoPerson {\n name: string;\n}\n"
14719
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-demo-person.ts",
14720
+ "rawContents": "export interface LookupDemoPerson {\n name: string;\n formal?: string;\n}\n"
14731
14721
  },
14732
14722
  {
14733
- "fileName": "lookup-custom-picker-demo-modal.component.html",
14734
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo-modal.component.html",
14735
- "rawContents": "<sky-modal class=\"lookup-custom-picker-modal\">\n <sky-modal-header>Names</sky-modal-header>\n <sky-modal-content>\n <form [formGroup]=\"peopleForm\">\n <sky-selection-box-grid>\n <sky-selection-box\n *ngFor=\"\n let personControl of peopleForm.controls.people.controls;\n let i = index\n \"\n [control]=\"checkbox\"\n >\n <sky-icon icon=\"user\" iconType=\"skyux\"></sky-icon>\n <sky-selection-box-header>\n {{ people[i].name }}\n </sky-selection-box-header>\n <sky-selection-box-description>\n {{ people[i].formal }}\n </sky-selection-box-description>\n <sky-checkbox [formControl]=\"personControl\" #checkbox></sky-checkbox>\n </sky-selection-box>\n </sky-selection-box-grid>\n </form>\n </sky-modal-content>\n <sky-modal-footer>\n <button\n class=\"sky-btn sky-btn-primary lookup-custom-picker-save-button\"\n type=\"button\"\n (click)=\"save()\"\n >\n Save\n </button>\n </sky-modal-footer>\n</sky-modal>\n"
14723
+ "fileName": "lookup-multiple-demo.module.ts",
14724
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.module.ts",
14725
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupMultipleSelectDemoComponent } from './lookup-multiple-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupMultipleSelectDemoComponent],\n exports: [LookupMultipleSelectDemoComponent],\n})\nexport class LookupMultipleSelectDemoModule {}\n"
14736
14726
  },
14737
14727
  {
14738
- "fileName": "lookup-custom-picker-demo-modal.component.ts",
14739
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo-modal.component.ts",
14740
- "rawContents": "import { Component } from '@angular/core';\nimport { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyLookupShowMoreCustomPickerContext } from '@skyux/lookup';\nimport { SkyModalInstance } from '@skyux/modals';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo-modal',\n templateUrl: './lookup-custom-picker-demo-modal.component.html',\n})\nexport class LookupCustomPickerDemoModalComponent {\n public peopleForm: FormGroup<{\n people: FormArray<FormControl<boolean>>;\n }>;\n\n public people: LookupDemoPerson[];\n\n #modalInstance: SkyModalInstance;\n\n constructor(\n context: SkyLookupShowMoreCustomPickerContext,\n modalInstance: SkyModalInstance,\n formBuilder: FormBuilder\n ) {\n this.#modalInstance = modalInstance;\n\n // This list of people will be rendered as selection boxes.\n this.people = context.items;\n\n // Create a control for each selection box.\n this.peopleForm = formBuilder.group({\n people: formBuilder.array(\n context.items.map((item) =>\n formBuilder.control(context.initialValue?.includes(item))\n )\n ),\n });\n }\n\n public save(): void {\n // Return a list of selected people to the lookup component.\n const selectedPeople = this.people.filter(\n (_, index) =>\n this.peopleForm.value.people && this.peopleForm.value.people[index]\n );\n\n this.#modalInstance.save(selectedPeople);\n }\n}\n"
14728
+ "fileName": "lookup-multiple-demo.component.ts",
14729
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.ts",
14730
+ "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyAutocompleteSearchFunctionFilter } from '@skyux/lookup';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo',\n templateUrl: './lookup-multiple-demo.component.html',\n styleUrls: ['./lookup-multiple-demo.component.scss'],\n})\nexport class LookupMultipleSelectDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[] = [];\n\n public people: LookupDemoPerson[] = [\n { name: 'Abed' },\n { name: 'Alex' },\n { name: 'Ben' },\n { name: 'Britta' },\n { name: 'Buzz' },\n { name: 'Craig' },\n { name: 'Elroy' },\n { name: 'Garrett' },\n { name: 'Ian' },\n { name: 'Jeff' },\n { name: 'Leonard' },\n { name: 'Neil' },\n { name: 'Pierce' },\n { name: 'Preston' },\n { name: 'Rachel' },\n { name: 'Shirley' },\n { name: 'Todd' },\n { name: 'Troy' },\n { name: 'Vaughn' },\n { name: 'Vicki' },\n ];\n\n constructor(formBuilder: FormBuilder) {\n this.favoritesForm = formBuilder.group({\n favoriteNames: [[this.people[15]]],\n });\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n\n this.searchFilters = [\n (_, item, args): boolean => {\n // When in the modal view, show all people in the search results, regardless if they have been chosen already.\n if (args?.context === 'modal') {\n return true;\n }\n\n const names = this.favoritesForm.value.favoriteNames;\n\n // When in the popover view (or in any other view), show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14741
14731
  },
14742
14732
  {
14743
- "fileName": "lookup-custom-picker-demo.component.html",
14744
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.html",
14745
- "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite names\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [showAddButton]=\"true\"\n [showMoreConfig]=\"showMoreConfig\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14733
+ "fileName": "lookup-multiple-demo.component.spec.ts",
14734
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.spec.ts",
14735
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupMultipleSelectDemoComponent } from './lookup-multiple-demo.component';\nimport { LookupMultipleSelectDemoModule } from './lookup-multiple-demo.module';\n\ndescribe('Lookup multi-select demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupMultipleSelectDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupMultipleSelectDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupMultipleSelectDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('be');\n await lookupHarness?.selectSearchResult({\n text: 'Ben',\n });\n\n expect(\n fixture.componentInstance.favoritesForm.controls.favoriteNames.value\n ).toEqual([{ name: 'Shirley' }, { name: 'Ben' }]);\n });\n});\n"
14746
14736
  },
14747
14737
  {
14748
- "fileName": "lookup-custom-picker-demo.component.scss",
14749
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.scss",
14738
+ "fileName": "lookup-multiple-demo.component.scss",
14739
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.scss",
14750
14740
  "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14751
14741
  },
14752
14742
  {
14753
- "fileName": "lookup-custom-picker-demo.component.spec.ts",
14754
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.spec.ts",
14755
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupCustomPickerDemoComponent } from './lookup-custom-picker-demo.component';\nimport { LookupCustomPickerDemoModule } from './lookup-custom-picker-demo.module';\nimport { LookupCustomPickerHarness } from './lookup-custom-picker-harness';\n\ndescribe('Lookup custom picker demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupCustomPickerDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupCustomPickerDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupCustomPickerDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('Be');\n\n const allResultHarnesses = await lookupHarness?.getSearchResults();\n const firstResultHarness = allResultHarnesses && allResultHarnesses[0];\n\n if (firstResultHarness) {\n await firstResultHarness.select();\n }\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [\n { name: 'Shirley', formal: 'Ms. Bennett' },\n { name: 'Abed', formal: 'Mr. Nadir' },\n ]\n );\n });\n\n it('should use a custom picker', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n // Show the custom picker.\n await lookupHarness?.clickShowMoreButton();\n\n // Use the custom picker harness to validate that selecting/deselecting items\n // updates the lookup form field.\n const loader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n\n const customPickerHarness = await loader.getHarness(\n LookupCustomPickerHarness\n );\n\n await customPickerHarness.checkItemAt(2); // Ben (Mr. Chang)\n await customPickerHarness.checkItemAt(7); // Garret (Mr. Lambert)\n await customPickerHarness.uncheckItemAt(15); // Shirley (Ms. Bennett)\n\n await customPickerHarness.save();\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [\n { name: 'Ben', formal: 'Mr. Chang' },\n { name: 'Garrett', formal: 'Mr. Lambert' },\n ]\n );\n });\n});\n"
14743
+ "fileName": "lookup-multiple-demo.component.html",
14744
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.html",
14745
+ "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite names\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [showAddButton]=\"true\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14756
14746
  },
14757
14747
  {
14758
- "fileName": "lookup-custom-picker-demo.component.ts",
14759
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.ts",
14760
- "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunctionFilter,\n SkyLookupShowMoreConfig,\n SkyLookupShowMoreCustomPickerContext,\n} from '@skyux/lookup';\nimport { SkyModalService } from '@skyux/modals';\n\nimport { LookupCustomPickerDemoModalComponent } from './lookup-custom-picker-demo-modal.component';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo',\n templateUrl: './lookup-custom-picker-demo.component.html',\n styleUrls: ['./lookup-custom-picker-demo.component.scss'],\n})\nexport class LookupCustomPickerDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public showMoreConfig: SkyLookupShowMoreConfig;\n public searchFilters: SkyAutocompleteSearchFunctionFilter[];\n\n public people: LookupDemoPerson[] = [\n {\n name: 'Abed',\n formal: 'Mr. Nadir',\n },\n {\n name: 'Alex',\n formal: 'Mr. Osbourne',\n },\n {\n name: 'Ben',\n formal: 'Mr. Chang',\n },\n {\n name: 'Britta',\n formal: 'Ms. Perry',\n },\n {\n name: 'Buzz',\n formal: 'Mr. Hickey',\n },\n {\n name: 'Craig',\n formal: 'Mr. Pelton',\n },\n {\n name: 'Elroy',\n formal: 'Mr. Patashnik',\n },\n {\n name: 'Garrett',\n formal: 'Mr. Lambert',\n },\n {\n name: 'Ian',\n formal: 'Mr. Duncan',\n },\n {\n name: 'Jeff',\n formal: 'Mr. Winger',\n },\n {\n name: 'Leonard',\n formal: 'Mr. Rodriguez',\n },\n {\n name: 'Neil',\n formal: 'Mr. Neil',\n },\n {\n name: 'Pierce',\n formal: 'Mr. Hawthorne',\n },\n {\n name: 'Preston',\n formal: 'Mr. Koogler',\n },\n {\n name: 'Rachel',\n formal: 'Ms. Rachel',\n },\n {\n name: 'Shirley',\n formal: 'Ms. Bennett',\n },\n {\n name: 'Todd',\n formal: 'Mr. Jacobson',\n },\n {\n name: 'Troy',\n formal: 'Mr. Barnes',\n },\n {\n name: 'Vaughn',\n formal: 'Mr. Miller',\n },\n {\n name: 'Vicki',\n formal: 'Ms. Jenkins',\n },\n ];\n\n constructor(formBuilder: FormBuilder, modalService: SkyModalService) {\n this.favoritesForm = formBuilder.group({\n favoriteNames: [[this.people[15]]],\n });\n\n this.searchFilters = [\n (_, item): boolean => {\n const names = this.favoritesForm.value.favoriteNames;\n\n // Only show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n\n this.showMoreConfig = {\n customPicker: {\n open: (context): void => {\n const instance = modalService.open(\n LookupCustomPickerDemoModalComponent,\n {\n providers: [\n {\n provide: SkyLookupShowMoreCustomPickerContext,\n useValue: context,\n },\n ],\n size: 'large',\n }\n );\n\n instance.closed.subscribe((closeArgs) => {\n if (closeArgs.reason === 'save') {\n this.favoritesForm.controls.favoriteNames.setValue(\n closeArgs.data\n );\n }\n });\n },\n },\n };\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14748
+ "fileName": "lookup-demo-person.ts",
14749
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-demo-person.ts",
14750
+ "rawContents": "export interface LookupDemoPerson {\n name: string;\n}\n"
14761
14751
  },
14762
14752
  {
14763
- "fileName": "lookup-custom-picker-demo.module.ts",
14764
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.module.ts",
14765
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport {\n SkyCheckboxModule,\n SkyInputBoxModule,\n SkySelectionBoxModule,\n} from '@skyux/forms';\nimport { SkyIconModule } from '@skyux/indicators';\nimport { SkyLookupModule } from '@skyux/lookup';\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { LookupCustomPickerDemoModalComponent } from './lookup-custom-picker-demo-modal.component';\nimport { LookupCustomPickerDemoComponent } from './lookup-custom-picker-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyCheckboxModule,\n SkyIconModule,\n SkyInputBoxModule,\n SkyLookupModule,\n SkyModalModule,\n SkySelectionBoxModule,\n ],\n declarations: [\n LookupCustomPickerDemoComponent,\n LookupCustomPickerDemoModalComponent,\n ],\n exports: [LookupCustomPickerDemoComponent],\n})\nexport class LookupCustomPickerDemoModule {}\n"
14753
+ "fileName": "lookup-demo-person.ts",
14754
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-demo-person.ts",
14755
+ "rawContents": "export interface LookupDemoPerson {\n name: string;\n formal?: string;\n}\n"
14766
14756
  },
14767
14757
  {
14768
14758
  "fileName": "lookup-custom-picker-harness.ts",
@@ -14770,204 +14760,214 @@
14770
14760
  "rawContents": "import { ComponentHarness } from '@angular/cdk/testing';\nimport { SkyCheckboxHarness } from '@skyux/forms/testing';\n\nexport class LookupCustomPickerHarness extends ComponentHarness {\n public static hostSelector = '.lookup-custom-picker-modal';\n\n #getCheckboxes = this.locatorForAll(SkyCheckboxHarness);\n #getSaveButton = this.locatorFor('.lookup-custom-picker-save-button');\n\n public async checkItemAt(index: number): Promise<void> {\n return (await this.#getCheckboxes())[index].check();\n }\n\n public async uncheckItemAt(index: number): Promise<void> {\n return (await this.#getCheckboxes())[index].uncheck();\n }\n\n public async save(): Promise<void> {\n return (await this.#getSaveButton()).click();\n }\n}\n"
14771
14761
  },
14772
14762
  {
14773
- "fileName": "lookup-demo-person.ts",
14774
- "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-demo-person.ts",
14775
- "rawContents": "export interface LookupDemoPerson {\n name: string;\n formal?: string;\n}\n"
14763
+ "fileName": "lookup-custom-picker-demo.module.ts",
14764
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.module.ts",
14765
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport {\n SkyCheckboxModule,\n SkyInputBoxModule,\n SkySelectionBoxModule,\n} from '@skyux/forms';\nimport { SkyIconModule } from '@skyux/indicators';\nimport { SkyLookupModule } from '@skyux/lookup';\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { LookupCustomPickerDemoModalComponent } from './lookup-custom-picker-demo-modal.component';\nimport { LookupCustomPickerDemoComponent } from './lookup-custom-picker-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyCheckboxModule,\n SkyIconModule,\n SkyInputBoxModule,\n SkyLookupModule,\n SkyModalModule,\n SkySelectionBoxModule,\n ],\n declarations: [\n LookupCustomPickerDemoComponent,\n LookupCustomPickerDemoModalComponent,\n ],\n exports: [LookupCustomPickerDemoComponent],\n})\nexport class LookupCustomPickerDemoModule {}\n"
14776
14766
  },
14777
14767
  {
14778
- "fileName": "lookup-demo-person.ts",
14779
- "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-demo-person.ts",
14780
- "rawContents": "export interface LookupDemoPerson {\n name: string;\n}\n"
14768
+ "fileName": "lookup-custom-picker-demo.component.ts",
14769
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.ts",
14770
+ "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunctionFilter,\n SkyLookupShowMoreConfig,\n SkyLookupShowMoreCustomPickerContext,\n} from '@skyux/lookup';\nimport { SkyModalService } from '@skyux/modals';\n\nimport { LookupCustomPickerDemoModalComponent } from './lookup-custom-picker-demo-modal.component';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo',\n templateUrl: './lookup-custom-picker-demo.component.html',\n styleUrls: ['./lookup-custom-picker-demo.component.scss'],\n})\nexport class LookupCustomPickerDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public showMoreConfig: SkyLookupShowMoreConfig;\n public searchFilters: SkyAutocompleteSearchFunctionFilter[];\n\n public people: LookupDemoPerson[] = [\n {\n name: 'Abed',\n formal: 'Mr. Nadir',\n },\n {\n name: 'Alex',\n formal: 'Mr. Osbourne',\n },\n {\n name: 'Ben',\n formal: 'Mr. Chang',\n },\n {\n name: 'Britta',\n formal: 'Ms. Perry',\n },\n {\n name: 'Buzz',\n formal: 'Mr. Hickey',\n },\n {\n name: 'Craig',\n formal: 'Mr. Pelton',\n },\n {\n name: 'Elroy',\n formal: 'Mr. Patashnik',\n },\n {\n name: 'Garrett',\n formal: 'Mr. Lambert',\n },\n {\n name: 'Ian',\n formal: 'Mr. Duncan',\n },\n {\n name: 'Jeff',\n formal: 'Mr. Winger',\n },\n {\n name: 'Leonard',\n formal: 'Mr. Rodriguez',\n },\n {\n name: 'Neil',\n formal: 'Mr. Neil',\n },\n {\n name: 'Pierce',\n formal: 'Mr. Hawthorne',\n },\n {\n name: 'Preston',\n formal: 'Mr. Koogler',\n },\n {\n name: 'Rachel',\n formal: 'Ms. Rachel',\n },\n {\n name: 'Shirley',\n formal: 'Ms. Bennett',\n },\n {\n name: 'Todd',\n formal: 'Mr. Jacobson',\n },\n {\n name: 'Troy',\n formal: 'Mr. Barnes',\n },\n {\n name: 'Vaughn',\n formal: 'Mr. Miller',\n },\n {\n name: 'Vicki',\n formal: 'Ms. Jenkins',\n },\n ];\n\n constructor(formBuilder: FormBuilder, modalService: SkyModalService) {\n this.favoritesForm = formBuilder.group({\n favoriteNames: [[this.people[15]]],\n });\n\n this.searchFilters = [\n (_, item): boolean => {\n const names = this.favoritesForm.value.favoriteNames;\n\n // Only show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n\n this.showMoreConfig = {\n customPicker: {\n open: (context): void => {\n const instance = modalService.open(\n LookupCustomPickerDemoModalComponent,\n {\n providers: [\n {\n provide: SkyLookupShowMoreCustomPickerContext,\n useValue: context,\n },\n ],\n size: 'large',\n }\n );\n\n instance.closed.subscribe((closeArgs) => {\n if (closeArgs.reason === 'save') {\n this.favoritesForm.controls.favoriteNames.setValue(\n closeArgs.data\n );\n }\n });\n },\n },\n };\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14781
14771
  },
14782
14772
  {
14783
- "fileName": "lookup-multiple-demo.component.html",
14784
- "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.html",
14785
- "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite names\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [showAddButton]=\"true\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14773
+ "fileName": "lookup-custom-picker-demo.component.spec.ts",
14774
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.spec.ts",
14775
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupCustomPickerDemoComponent } from './lookup-custom-picker-demo.component';\nimport { LookupCustomPickerDemoModule } from './lookup-custom-picker-demo.module';\nimport { LookupCustomPickerHarness } from './lookup-custom-picker-harness';\n\ndescribe('Lookup custom picker demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupCustomPickerDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupCustomPickerDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupCustomPickerDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('Be');\n\n const allResultHarnesses = await lookupHarness?.getSearchResults();\n const firstResultHarness = allResultHarnesses && allResultHarnesses[0];\n\n if (firstResultHarness) {\n await firstResultHarness.select();\n }\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [\n { name: 'Shirley', formal: 'Ms. Bennett' },\n { name: 'Abed', formal: 'Mr. Nadir' },\n ]\n );\n });\n\n it('should use a custom picker', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n // Show the custom picker.\n await lookupHarness?.clickShowMoreButton();\n\n // Use the custom picker harness to validate that selecting/deselecting items\n // updates the lookup form field.\n const loader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n\n const customPickerHarness = await loader.getHarness(\n LookupCustomPickerHarness\n );\n\n await customPickerHarness.checkItemAt(2); // Ben (Mr. Chang)\n await customPickerHarness.checkItemAt(7); // Garret (Mr. Lambert)\n await customPickerHarness.uncheckItemAt(15); // Shirley (Ms. Bennett)\n\n await customPickerHarness.save();\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [\n { name: 'Ben', formal: 'Mr. Chang' },\n { name: 'Garrett', formal: 'Mr. Lambert' },\n ]\n );\n });\n});\n"
14786
14776
  },
14787
14777
  {
14788
- "fileName": "lookup-multiple-demo.component.scss",
14789
- "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.scss",
14778
+ "fileName": "lookup-custom-picker-demo.component.scss",
14779
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.scss",
14790
14780
  "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14791
14781
  },
14792
14782
  {
14793
- "fileName": "lookup-multiple-demo.component.spec.ts",
14794
- "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.spec.ts",
14795
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupMultipleSelectDemoComponent } from './lookup-multiple-demo.component';\nimport { LookupMultipleSelectDemoModule } from './lookup-multiple-demo.module';\n\ndescribe('Lookup multi-select demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupMultipleSelectDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupMultipleSelectDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupMultipleSelectDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('be');\n await lookupHarness?.selectSearchResult({\n text: 'Ben',\n });\n\n expect(\n fixture.componentInstance.favoritesForm.controls.favoriteNames.value\n ).toEqual([{ name: 'Shirley' }, { name: 'Ben' }]);\n });\n});\n"
14783
+ "fileName": "lookup-custom-picker-demo.component.html",
14784
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo.component.html",
14785
+ "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite names\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [showAddButton]=\"true\"\n [showMoreConfig]=\"showMoreConfig\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14796
14786
  },
14797
14787
  {
14798
- "fileName": "lookup-multiple-demo.component.ts",
14799
- "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.component.ts",
14800
- "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyAutocompleteSearchFunctionFilter } from '@skyux/lookup';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo',\n templateUrl: './lookup-multiple-demo.component.html',\n styleUrls: ['./lookup-multiple-demo.component.scss'],\n})\nexport class LookupMultipleSelectDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[] = [];\n\n public people: LookupDemoPerson[] = [\n { name: 'Abed' },\n { name: 'Alex' },\n { name: 'Ben' },\n { name: 'Britta' },\n { name: 'Buzz' },\n { name: 'Craig' },\n { name: 'Elroy' },\n { name: 'Garrett' },\n { name: 'Ian' },\n { name: 'Jeff' },\n { name: 'Leonard' },\n { name: 'Neil' },\n { name: 'Pierce' },\n { name: 'Preston' },\n { name: 'Rachel' },\n { name: 'Shirley' },\n { name: 'Todd' },\n { name: 'Troy' },\n { name: 'Vaughn' },\n { name: 'Vicki' },\n ];\n\n constructor(formBuilder: FormBuilder) {\n this.favoritesForm = formBuilder.group({\n favoriteNames: [[this.people[15]]],\n });\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n\n this.searchFilters = [\n (_, item, args): boolean => {\n // When in the modal view, show all people in the search results, regardless if they have been chosen already.\n if (args?.context === 'modal') {\n return true;\n }\n\n const names = this.favoritesForm.value.favoriteNames;\n\n // When in the popover view (or in any other view), show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14788
+ "fileName": "lookup-custom-picker-demo-modal.component.ts",
14789
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo-modal.component.ts",
14790
+ "rawContents": "import { Component } from '@angular/core';\nimport { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyLookupShowMoreCustomPickerContext } from '@skyux/lookup';\nimport { SkyModalInstance } from '@skyux/modals';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo-modal',\n templateUrl: './lookup-custom-picker-demo-modal.component.html',\n})\nexport class LookupCustomPickerDemoModalComponent {\n public peopleForm: FormGroup<{\n people: FormArray<FormControl<boolean>>;\n }>;\n\n public people: LookupDemoPerson[];\n\n #modalInstance: SkyModalInstance;\n\n constructor(\n context: SkyLookupShowMoreCustomPickerContext,\n modalInstance: SkyModalInstance,\n formBuilder: FormBuilder\n ) {\n this.#modalInstance = modalInstance;\n\n // This list of people will be rendered as selection boxes.\n this.people = context.items;\n\n // Create a control for each selection box.\n this.peopleForm = formBuilder.group({\n people: formBuilder.array(\n context.items.map((item) =>\n formBuilder.control(context.initialValue?.includes(item))\n )\n ),\n });\n }\n\n public save(): void {\n // Return a list of selected people to the lookup component.\n const selectedPeople = this.people.filter(\n (_, index) =>\n this.peopleForm.value.people && this.peopleForm.value.people[index]\n );\n\n this.#modalInstance.save(selectedPeople);\n }\n}\n"
14801
14791
  },
14802
14792
  {
14803
- "fileName": "lookup-multiple-demo.module.ts",
14804
- "filePath": "/projects/lookup/documentation/code-examples/lookup/multi-select/lookup-multiple-demo.module.ts",
14805
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupMultipleSelectDemoComponent } from './lookup-multiple-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupMultipleSelectDemoComponent],\n exports: [LookupMultipleSelectDemoComponent],\n})\nexport class LookupMultipleSelectDemoModule {}\n"
14793
+ "fileName": "lookup-custom-picker-demo-modal.component.html",
14794
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/custom-picker/lookup-custom-picker-demo-modal.component.html",
14795
+ "rawContents": "<sky-modal class=\"lookup-custom-picker-modal\">\n <sky-modal-header>Names</sky-modal-header>\n <sky-modal-content>\n <form [formGroup]=\"peopleForm\">\n <sky-selection-box-grid>\n <sky-selection-box\n *ngFor=\"\n let personControl of peopleForm.controls.people.controls;\n let i = index\n \"\n [control]=\"checkbox\"\n >\n <sky-icon icon=\"user\" iconType=\"skyux\"></sky-icon>\n <sky-selection-box-header>\n {{ people[i].name }}\n </sky-selection-box-header>\n <sky-selection-box-description>\n {{ people[i].formal }}\n </sky-selection-box-description>\n <sky-checkbox [formControl]=\"personControl\" #checkbox></sky-checkbox>\n </sky-selection-box>\n </sky-selection-box-grid>\n </form>\n </sky-modal-content>\n <sky-modal-footer>\n <button\n class=\"sky-btn sky-btn-primary lookup-custom-picker-save-button\"\n type=\"button\"\n (click)=\"save()\"\n >\n Save\n </button>\n </sky-modal-footer>\n</sky-modal>\n"
14806
14796
  },
14807
14797
  {
14808
14798
  "fileName": "lookup-demo-person.ts",
14809
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-demo-person.ts",
14810
- "rawContents": "export interface LookupDemoPerson {\n name: string;\n formal?: string;\n}\n"
14799
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-demo-person.ts",
14800
+ "rawContents": "export interface LookupDemoPerson {\n name: string;\n}\n"
14811
14801
  },
14812
14802
  {
14813
- "fileName": "lookup-result-templates-demo.component.html",
14814
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.html",
14815
- "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite names\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [searchResultTemplate]=\"dropdownItemTemplate\"\n [showAddButton]=\"true\"\n [showMoreConfig]=\"showMoreConfig\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n\n<ng-template let-item=\"item\" #dropdownItemTemplate>\n <span class=\"lookup-demo-template-item\">\n <strong class=\"lookup-demo-template-name\">{{ item.name }}</strong\n ><br />\n <span class=\"lookup-demo-template-formal-name\">\n {{ item.formal }}\n </span>\n </span>\n</ng-template>\n<ng-template let-item=\"item\" #modalItemTemplate>\n <span class=\"lookup-demo-template-item\">\n <span class=\"lookup-demo-template-name\">{{ item.name }}</span\n ><br />\n <i class=\"lookup-demo-template-formal-name\">{{ item.formal }}</i>\n </span>\n</ng-template>\n"
14803
+ "fileName": "lookup-async-demo.service.ts",
14804
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.service.ts",
14805
+ "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { LookupAsyncDemoSearchResults } from './lookup-async-demo-search-results';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\nconst people: LookupDemoPerson[] = [\n { name: 'Abed' },\n { name: 'Alex' },\n { name: 'Ben' },\n { name: 'Britta' },\n { name: 'Buzz' },\n { name: 'Craig' },\n { name: 'Elroy' },\n { name: 'Garrett' },\n { name: 'Ian' },\n { name: 'Jeff' },\n { name: 'Leonard' },\n { name: 'Neil' },\n { name: 'Pierce' },\n { name: 'Preston' },\n { name: 'Rachel' },\n { name: 'Shirley' },\n { name: 'Todd' },\n { name: 'Troy' },\n { name: 'Vaughn' },\n { name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LookupAsyncDemoService {\n public search(searchText: string): Observable<LookupAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n\n public addPerson(person: LookupDemoPerson): Observable<number> {\n // Simulate adding a person with a network call.\n if (!people.some((item) => item.name === person.name)) {\n people.unshift(person);\n }\n\n return of(1).pipe(delay(800));\n }\n}\n"
14816
14806
  },
14817
14807
  {
14818
- "fileName": "lookup-result-templates-demo.component.scss",
14819
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.scss",
14820
- "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14808
+ "fileName": "lookup-async-demo.module.ts",
14809
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.module.ts",
14810
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupAsyncDemoComponent],\n exports: [LookupAsyncDemoComponent],\n})\nexport class LookupAsyncDemoModule {}\n"
14821
14811
  },
14822
14812
  {
14823
- "fileName": "lookup-result-templates-demo.component.spec.ts",
14824
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.spec.ts",
14825
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupResultTemplatesDemoComponent } from './lookup-result-templates-demo.component';\nimport { LookupResultTemplatesDemoModule } from './lookup-result-templates-demo.module';\nimport { LookupResultTemplatesItemHarness } from './lookup-result-templates-item-harness';\n\ndescribe('Lookup result templates demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupResultTemplatesDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupResultTemplatesDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupResultTemplatesDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should use the expected dropdown item template', async () => {\n const { lookupHarness } = await setupTest();\n\n await lookupHarness?.enterText('be');\n\n const results = await lookupHarness?.getSearchResults();\n const templateItemHarness =\n results &&\n (await results[0].queryHarness(LookupResultTemplatesItemHarness));\n\n await expectAsync(templateItemHarness?.getName()).toBeResolvedTo('Abed');\n await expectAsync(templateItemHarness?.getFormalName()).toBeResolvedTo(\n 'Mr. Nadir'\n );\n });\n\n it('should use the expected modal item template', async () => {\n const { lookupHarness } = await setupTest();\n\n await lookupHarness?.clickShowMoreButton();\n\n const pickerHarness = await lookupHarness?.getShowMorePicker();\n await pickerHarness?.enterSearchText('be');\n\n const results = await pickerHarness?.getSearchResults();\n const templateItemHarness =\n results &&\n (await results[0].queryHarness(LookupResultTemplatesItemHarness));\n\n await expectAsync(templateItemHarness?.getName()).toBeResolvedTo('Abed');\n await expectAsync(templateItemHarness?.getFormalName()).toBeResolvedTo(\n 'Mr. Nadir'\n );\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('be');\n\n const allResultHarnesses = await lookupHarness?.getSearchResults();\n const firstResultHarness = allResultHarnesses && allResultHarnesses[0];\n await firstResultHarness?.select();\n\n expect(\n fixture.componentInstance.favoritesForm.controls.favoriteNames.value\n ).toEqual([\n { name: 'Shirley', formal: 'Ms. Bennett' },\n { name: 'Abed', formal: 'Mr. Nadir' },\n ]);\n });\n});\n"
14813
+ "fileName": "lookup-async-demo.component.ts",
14814
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.ts",
14815
+ "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyWaitService } from '@skyux/indicators';\nimport {\n SkyAutocompleteSearchAsyncArgs,\n SkyLookupAddClickEventArgs,\n} from '@skyux/lookup';\n\nimport { map } from 'rxjs/operators';\n\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-async-lookup-demo',\n templateUrl: './lookup-async-demo.component.html',\n styleUrls: ['./lookup-async-demo.component.scss'],\n})\nexport class LookupAsyncDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n #svc: LookupAsyncDemoService;\n #waitSvc: SkyWaitService;\n\n constructor(\n formBuilder: FormBuilder,\n svc: LookupAsyncDemoService,\n waitSvc: SkyWaitService\n ) {\n this.#svc = svc;\n this.#waitSvc = waitSvc;\n\n const names = new FormControl<LookupDemoPerson[]>([{ name: 'Shirley' }]);\n\n this.favoritesForm = formBuilder.group({\n favoriteNames: names,\n });\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n\n public searchAsync(args: SkyAutocompleteSearchAsyncArgs): void {\n // In a real-world application the search service might return an Observable\n // created by calling HttpClient.get(). Assigning that Observable to the result\n // allows the lookup component to cancel the web request if it does not complete\n // before the user searches again.\n args.result = this.#svc.search(args.searchText).pipe(\n map((result) => ({\n hasMore: result.hasMore,\n items: result.people,\n totalCount: result.totalCount,\n }))\n );\n }\n\n public addClick(args: SkyLookupAddClickEventArgs): void {\n const person: LookupDemoPerson = {\n name: 'Newman',\n };\n\n this.#waitSvc.blockingWrap(this.#svc.addPerson(person)).subscribe(() => {\n args.itemAdded({\n item: person,\n });\n });\n }\n}\n"
14826
14816
  },
14827
14817
  {
14828
- "fileName": "lookup-result-templates-demo.component.ts",
14829
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.component.ts",
14830
- "rawContents": "import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunctionFilter,\n SkyLookupShowMoreConfig,\n} from '@skyux/lookup';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-lookup-demo',\n templateUrl: './lookup-result-templates-demo.component.html',\n styleUrls: ['./lookup-result-templates-demo.component.scss'],\n})\nexport class LookupResultTemplatesDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[];\n\n public people: LookupDemoPerson[] = [\n {\n name: 'Abed',\n formal: 'Mr. Nadir',\n },\n {\n name: 'Alex',\n formal: 'Mr. Osbourne',\n },\n {\n name: 'Ben',\n formal: 'Mr. Chang',\n },\n {\n name: 'Britta',\n formal: 'Ms. Perry',\n },\n {\n name: 'Buzz',\n formal: 'Mr. Hickey',\n },\n {\n name: 'Craig',\n formal: 'Mr. Pelton',\n },\n {\n name: 'Elroy',\n formal: 'Mr. Patashnik',\n },\n {\n name: 'Garrett',\n formal: 'Mr. Lambert',\n },\n {\n name: 'Ian',\n formal: 'Mr. Duncan',\n },\n {\n name: 'Jeff',\n formal: 'Mr. Winger',\n },\n {\n name: 'Leonard',\n formal: 'Mr. Rodriguez',\n },\n {\n name: 'Neil',\n formal: 'Mr. Neil',\n },\n {\n name: 'Pierce',\n formal: 'Mr. Hawthorne',\n },\n {\n name: 'Preston',\n formal: 'Mr. Koogler',\n },\n {\n name: 'Rachel',\n formal: 'Ms. Rachel',\n },\n {\n name: 'Shirley',\n formal: 'Ms. Bennett',\n },\n {\n name: 'Todd',\n formal: 'Mr. Jacobson',\n },\n {\n name: 'Troy',\n formal: 'Mr. Barnes',\n },\n {\n name: 'Vaughn',\n formal: 'Mr. Miller',\n },\n {\n name: 'Vicki',\n formal: 'Ms. Jenkins',\n },\n ];\n\n public showMoreConfig: SkyLookupShowMoreConfig = {\n nativePickerConfig: {},\n };\n\n @ViewChild('modalItemTemplate')\n public set modalItemTemplate(template: TemplateRef<unknown>) {\n if (this.showMoreConfig.nativePickerConfig) {\n this.showMoreConfig.nativePickerConfig.itemTemplate = template;\n } else {\n this.showMoreConfig.nativePickerConfig = { itemTemplate: template };\n }\n }\n\n constructor(formBuilder: FormBuilder) {\n this.favoritesForm = formBuilder.group({\n favoriteNames: [[this.people[15]]],\n });\n\n this.searchFilters = [\n (_, item): boolean => {\n const names = this.favoritesForm.value.favoriteNames;\n\n // Only show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14818
+ "fileName": "lookup-async-demo.component.spec.ts",
14819
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.spec.ts",
14820
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\nimport { LookupAsyncDemoModule } from './lookup-async-demo.module';\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\n\ndescribe('Lookup asynchronous search demo', () => {\n let mockSvc!: jasmine.SpyObj<LookupAsyncDemoService>;\n\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupAsyncDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupAsyncDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('LookupAsyncDemoService', ['search']);\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, LookupAsyncDemoModule],\n providers: [\n {\n provide: LookupAsyncDemoService,\n useValue: mockSvc,\n },\n ],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n mockSvc.search.and.callFake((searchText) =>\n of({\n hasMore: false,\n people:\n searchText === 'b'\n ? [\n {\n name: 'Bernard',\n },\n ]\n : [],\n totalCount: 1,\n })\n );\n\n await lookupHarness?.enterText('b');\n await lookupHarness?.selectSearchResult({\n text: 'Bernard',\n });\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [{ name: 'Shirley' }, { name: 'Bernard' }]\n );\n });\n});\n"
14831
14821
  },
14832
14822
  {
14833
- "fileName": "lookup-result-templates-demo.module.ts",
14834
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-demo.module.ts",
14835
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupResultTemplatesDemoComponent } from './lookup-result-templates-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupResultTemplatesDemoComponent],\n exports: [LookupResultTemplatesDemoComponent],\n})\nexport class LookupResultTemplatesDemoModule {}\n"
14823
+ "fileName": "lookup-async-demo.component.scss",
14824
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.scss",
14825
+ "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14836
14826
  },
14837
14827
  {
14838
- "fileName": "lookup-result-templates-item-harness.ts",
14839
- "filePath": "/projects/lookup/documentation/code-examples/lookup/result-templates/lookup-result-templates-item-harness.ts",
14840
- "rawContents": "import { ComponentHarness } from '@angular/cdk/testing';\n\n/**\n * Harness for interacting with a lookup component in tests.\n * @internal\n */\nexport class LookupResultTemplatesItemHarness extends ComponentHarness {\n public static hostSelector = '.lookup-demo-template-item';\n\n #getName = this.locatorFor('.lookup-demo-template-name');\n #getFormalName = this.locatorFor('.lookup-demo-template-formal-name');\n\n public async getName(): Promise<string> {\n return (await this.#getName()).text();\n }\n\n public async getFormalName(): Promise<string> {\n return (await this.#getFormalName()).text();\n }\n}\n"
14828
+ "fileName": "lookup-async-demo.component.html",
14829
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo.component.html",
14830
+ "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box\n data-sky-id=\"favorite-names-field\"\n labelText=\"Favorite name(s)\"\n >\n <sky-lookup\n formControlName=\"favoriteNames\"\n idProperty=\"name\"\n [enableShowMore]=\"true\"\n (searchAsync)=\"searchAsync($event)\"\n [showAddButton]=\"true\"\n (addClick)=\"addClick($event)\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14831
+ },
14832
+ {
14833
+ "fileName": "lookup-async-demo-search-results.ts",
14834
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/async/lookup-async-demo-search-results.ts",
14835
+ "rawContents": "import { LookupDemoPerson } from './lookup-demo-person';\n\nexport interface LookupAsyncDemoSearchResults {\n hasMore: boolean;\n people: LookupDemoPerson[];\n totalCount: number;\n}\n"
14841
14836
  },
14842
14837
  {
14843
14838
  "fileName": "lookup-demo-person.ts",
14844
- "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-demo-person.ts",
14845
- "rawContents": "export interface LookupDemoPerson {\n name: string;\n}\n"
14839
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-demo-person.ts",
14840
+ "rawContents": "export interface LookupDemoPerson {\n id: string;\n name: string;\n}\n"
14846
14841
  },
14847
14842
  {
14848
- "fileName": "lookup-single-demo.component.html",
14849
- "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.html",
14850
- "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box data-sky-id=\"favorite-name-field\" labelText=\"Favorite name\">\n <sky-lookup\n formControlName=\"favoriteName\"\n selectMode=\"single\"\n (addClick)=\"onAddButtonClicked()\"\n [data]=\"people\"\n [enableShowMore]=\"true\"\n [searchFilters]=\"searchFilters\"\n [showAddButton]=\"true\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14843
+ "fileName": "lookup-demo-add-item.component.ts",
14844
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-demo-add-item.component.ts",
14845
+ "rawContents": "import { Component, inject } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { SkyModalInstance } from '@skyux/modals';\n\nlet nextId = 21;\n\n@Component({\n selector: 'app-lookup-demo-add-item',\n templateUrl: './lookup-demo-add-item.component.html',\n})\nexport class LookupDemoAddItemComponent {\n public readonly formGroup: FormGroup;\n\n #modal = inject(SkyModalInstance);\n\n constructor() {\n this.formGroup = inject(FormBuilder).group({\n id: [`${nextId++}`],\n name: ['', Validators.required],\n });\n }\n\n public close() {\n this.#modal.close();\n }\n\n public save() {\n if (this.formGroup.valid) {\n this.#modal.close(this.formGroup.value, 'save');\n } else {\n this.formGroup.markAllAsTouched();\n }\n }\n}\n"
14851
14846
  },
14852
14847
  {
14853
- "fileName": "lookup-single-demo.component.scss",
14854
- "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.scss",
14855
- "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14848
+ "fileName": "lookup-demo-add-item.component.html",
14849
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-demo-add-item.component.html",
14850
+ "rawContents": "<sky-modal>\n <sky-modal-header>\n <h2>Add Item</h2>\n </sky-modal-header>\n <sky-modal-content>\n <form novalidate [formGroup]=\"formGroup\" (ngSubmit)=\"save()\">\n <sky-input-box>\n <label class=\"sky-control-label\">Name</label>\n <input\n type=\"text\"\n autocapitalize=\"words\"\n autocomplete=\"off\"\n formControlName=\"name\"\n class=\"sky-form-control\"\n />\n </sky-input-box>\n </form>\n </sky-modal-content>\n <sky-modal-footer>\n <button class=\"sky-btn sky-btn-default\" (click)=\"close()\">Cancel</button>\n <button class=\"sky-btn sky-btn-primary\" (click)=\"save()\">Add</button>\n </sky-modal-footer>\n</sky-modal>\n"
14856
14851
  },
14857
14852
  {
14858
- "fileName": "lookup-single-demo.component.spec.ts",
14859
- "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.spec.ts",
14860
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { LookupSingleSelectDemoComponent } from './lookup-single-demo.component';\nimport { LookupSingleSelectDemoModule } from './lookup-single-demo.module';\n\ndescribe('Lookup single select demo', () => {\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupSingleSelectDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupSingleSelectDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-name-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [LookupSingleSelectDemoModule, NoopAnimationsModule],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getValue()).toBeResolvedTo('Shirley');\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n await lookupHarness?.enterText('be');\n await lookupHarness?.selectSearchResult({\n text: 'Ben',\n });\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteName).toEqual([\n { name: 'Ben' },\n ]);\n });\n});\n"
14853
+ "fileName": "lookup-async-demo.service.ts",
14854
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.service.ts",
14855
+ "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { LookupAsyncDemoSearchResults } from './lookup-async-demo-search-results';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\nconst people: LookupDemoPerson[] = [\n { id: '1', name: 'Abed' },\n { id: '2', name: 'Alex' },\n { id: '3', name: 'Ben' },\n { id: '4', name: 'Britta' },\n { id: '5', name: 'Buzz' },\n { id: '6', name: 'Craig' },\n { id: '7', name: 'Elroy' },\n { id: '8', name: 'Garrett' },\n { id: '9', name: 'Ian' },\n { id: '10', name: 'Jeff' },\n { id: '11', name: 'Leonard' },\n { id: '12', name: 'Neil' },\n { id: '13', name: 'Pierce' },\n { id: '14', name: 'Preston' },\n { id: '15', name: 'Rachel' },\n { id: '16', name: 'Shirley' },\n { id: '17', name: 'Todd' },\n { id: '18', name: 'Troy' },\n { id: '19', name: 'Vaughn' },\n { id: '20', name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LookupAsyncDemoService {\n public search(searchText: string): Observable<LookupAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n\n public addPerson(person: LookupDemoPerson): Observable<LookupDemoPerson[]> {\n // Simulate adding a person with a network call.\n if (!people.some((item) => item.name === person.name)) {\n people.unshift(person);\n }\n\n return of(people.slice()).pipe(delay(800));\n }\n}\n"
14861
14856
  },
14862
14857
  {
14863
- "fileName": "lookup-single-demo.component.ts",
14864
- "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.component.ts",
14865
- "rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyAutocompleteSearchFunctionFilter } from '@skyux/lookup';\n\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-single-select-lookup-demo',\n templateUrl: './lookup-single-demo.component.html',\n styleUrls: ['./lookup-single-demo.component.scss'],\n})\nexport class LookupSingleSelectDemoComponent implements OnInit {\n public favoritesForm: FormGroup<{\n favoriteName: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[];\n\n public people: LookupDemoPerson[] = [\n { name: 'Abed' },\n { name: 'Alex' },\n { name: 'Ben' },\n { name: 'Britta' },\n { name: 'Buzz' },\n { name: 'Craig' },\n { name: 'Elroy' },\n { name: 'Garrett' },\n { name: 'Ian' },\n { name: 'Jeff' },\n { name: 'Leonard' },\n { name: 'Neil' },\n { name: 'Pierce' },\n { name: 'Preston' },\n { name: 'Rachel' },\n { name: 'Shirley' },\n { name: 'Todd' },\n { name: 'Troy' },\n { name: 'Vaughn' },\n { name: 'Vicki' },\n ];\n\n public name: LookupDemoPerson[] = [this.people[15]];\n\n constructor(formBuilder: FormBuilder) {\n this.favoritesForm = formBuilder.group({\n favoriteName: [[this.people[15]]],\n });\n\n this.searchFilters = [\n (_, item): boolean => {\n const names = this.favoritesForm.value.favoriteName;\n\n // Only show people in the search results that have not been chosen already.\n return !names?.some((option) => option.name === item.name);\n },\n ];\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public onAddButtonClicked(): void {\n alert('Add button clicked!');\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n}\n"
14858
+ "fileName": "lookup-async-demo.module.ts",
14859
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.module.ts",
14860
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\nimport { LookupDemoAddItemComponent } from './lookup-demo-add-item.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyIdModule,\n SkyInputBoxModule,\n SkyModalModule,\n SkyLookupModule,\n ],\n declarations: [LookupAsyncDemoComponent, LookupDemoAddItemComponent],\n exports: [LookupAsyncDemoComponent],\n})\nexport class LookupAsyncDemoModule {}\n"
14866
14861
  },
14867
14862
  {
14868
- "fileName": "lookup-single-demo.module.ts",
14869
- "filePath": "/projects/lookup/documentation/code-examples/lookup/single-select/lookup-single-demo.module.ts",
14870
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyLookupModule } from '@skyux/lookup';\n\nimport { LookupSingleSelectDemoComponent } from './lookup-single-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyLookupModule,\n ],\n declarations: [LookupSingleSelectDemoComponent],\n exports: [LookupSingleSelectDemoComponent],\n})\nexport class LookupSingleSelectDemoModule {}\n"
14863
+ "fileName": "lookup-async-demo.component.ts",
14864
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.ts",
14865
+ "rawContents": "import { Component, OnDestroy, OnInit, inject } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup } from '@angular/forms';\nimport { SkyWaitService } from '@skyux/indicators';\nimport {\n SkyAutocompleteSearchAsyncArgs,\n SkyLookupAddClickEventArgs,\n} from '@skyux/lookup';\nimport { SkyModalCloseArgs, SkyModalService } from '@skyux/modals';\n\nimport { Subscription } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\nimport { LookupDemoAddItemComponent } from './lookup-demo-add-item.component';\nimport { LookupDemoPerson } from './lookup-demo-person';\n\n@Component({\n selector: 'app-async-lookup-demo',\n templateUrl: './lookup-async-demo.component.html',\n styleUrls: ['./lookup-async-demo.component.scss'],\n})\nexport class LookupAsyncDemoComponent implements OnInit, OnDestroy {\n public favoritesForm: FormGroup<{\n favoriteNames: FormControl<LookupDemoPerson[] | null>;\n }>;\n\n #modalService = inject(SkyModalService);\n #subscriptions = new Subscription();\n #svc = inject(LookupAsyncDemoService);\n #waitSvc = inject(SkyWaitService);\n\n constructor(formBuilder: FormBuilder) {\n const names = new FormControl<LookupDemoPerson[]>([\n { id: '16', name: 'Shirley' },\n ]);\n\n this.favoritesForm = formBuilder.group({\n favoriteNames: names,\n });\n }\n\n public ngOnInit(): void {\n // If you need to execute some logic after the lookup values change,\n // subscribe to Angular's built-in value changes observable.\n this.favoritesForm.valueChanges.subscribe((changes) => {\n console.log('Lookup value changes:', changes);\n });\n }\n\n public ngOnDestroy(): void {\n this.#subscriptions.unsubscribe();\n }\n\n public onSubmit(): void {\n alert('Form submitted with: ' + JSON.stringify(this.favoritesForm.value));\n }\n\n public searchAsync(args: SkyAutocompleteSearchAsyncArgs): void {\n // In a real-world application the search service might return an Observable\n // created by calling HttpClient.get(). Assigning that Observable to the result\n // allows the lookup component to cancel the web request if it does not complete\n // before the user searches again.\n args.result = this.#svc.search(args.searchText).pipe(\n map((result) => ({\n hasMore: result.hasMore,\n items: result.people,\n totalCount: result.totalCount,\n }))\n );\n }\n\n public addClick(args: SkyLookupAddClickEventArgs): void {\n const modal = this.#modalService.open(LookupDemoAddItemComponent);\n this.#subscriptions.add(\n modal.closed.subscribe((close: SkyModalCloseArgs) => {\n if (close.reason === 'save') {\n this.#subscriptions.add(\n this.#waitSvc\n .blockingWrap(this.#svc.addPerson(close.data))\n .subscribe((data) => {\n args.itemAdded({\n item: close.data,\n data: data,\n });\n })\n );\n }\n })\n );\n }\n}\n"
14871
14866
  },
14872
14867
  {
14873
- "fileName": "lookup-demo-item.ts",
14874
- "filePath": "/projects/lookup/documentation/code-examples/search/basic/lookup-demo-item.ts",
14875
- "rawContents": "export interface LookupDemoItem {\n title: string;\n note: string;\n}\n"
14868
+ "fileName": "lookup-async-demo.component.spec.ts",
14869
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.spec.ts",
14870
+ "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyInputBoxHarness } from '@skyux/forms/testing';\nimport { SkyLookupHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { LookupAsyncDemoComponent } from './lookup-async-demo.component';\nimport { LookupAsyncDemoModule } from './lookup-async-demo.module';\nimport { LookupAsyncDemoService } from './lookup-async-demo.service';\n\ndescribe('Lookup asynchronous search demo', () => {\n let mockSvc!: jasmine.SpyObj<LookupAsyncDemoService>;\n\n async function setupTest(): Promise<{\n lookupHarness: SkyLookupHarness | null;\n fixture: ComponentFixture<LookupAsyncDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(LookupAsyncDemoComponent);\n const loader = TestbedHarnessEnvironment.loader(fixture);\n\n const lookupHarness = await (\n await loader.getHarness(\n SkyInputBoxHarness.with({ dataSkyId: 'favorite-names-field' })\n )\n ).queryHarness(SkyLookupHarness);\n\n return { lookupHarness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('LookupAsyncDemoService', ['search']);\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, LookupAsyncDemoModule],\n providers: [\n {\n provide: LookupAsyncDemoService,\n useValue: mockSvc,\n },\n ],\n });\n });\n\n it('should set the expected initial value', async () => {\n const { lookupHarness } = await setupTest();\n\n await expectAsync(lookupHarness?.getSelectionsText()).toBeResolvedTo([\n 'Shirley',\n ]);\n });\n\n it('should update the form control when a favorite name is selected', async () => {\n const { lookupHarness, fixture } = await setupTest();\n\n mockSvc.search.and.callFake((searchText) =>\n of({\n hasMore: false,\n people:\n searchText === 'b'\n ? [\n {\n id: '21',\n name: 'Bernard',\n },\n ]\n : [],\n totalCount: 1,\n })\n );\n\n await lookupHarness?.enterText('b');\n await lookupHarness?.selectSearchResult({\n text: 'Bernard',\n });\n\n expect(fixture.componentInstance.favoritesForm.value.favoriteNames).toEqual(\n [\n { id: '16', name: 'Shirley' },\n { id: '21', name: 'Bernard' },\n ]\n );\n });\n});\n"
14876
14871
  },
14877
14872
  {
14878
- "fileName": "search-demo.component.html",
14879
- "filePath": "/projects/lookup/documentation/code-examples/search/basic/search-demo.component.html",
14880
- "rawContents": "<sky-toolbar>\n <sky-toolbar-item>\n <button\n class=\"sky-btn sky-btn-default sky-demo-search-bar-item\"\n (click)=\"searchApplied('Robert')\"\n >\n Predefined search text\n </button>\n </sky-toolbar-item>\n <sky-toolbar-item>\n <sky-search\n [searchText]=\"searchText\"\n [debounceTime]=\"250\"\n (searchApply)=\"searchApplied($event)\"\n (searchChange)=\"searchApplied($event)\"\n >\n </sky-search>\n </sky-toolbar-item>\n</sky-toolbar>\n<sky-repeater expandMode=\"none\">\n <sky-repeater-item *ngFor=\"let item of displayedItems\">\n <sky-repeater-item-title>\n {{ item.title }}\n </sky-repeater-item-title>\n <sky-repeater-item-content>\n <div>\n {{ item.note }}\n </div>\n </sky-repeater-item-content>\n </sky-repeater-item>\n</sky-repeater>\n"
14873
+ "fileName": "lookup-async-demo.component.scss",
14874
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.scss",
14875
+ "rawContents": ".lookup-demo-alert {\n padding: 10px;\n margin-bottom: 10px;\n border: 1px solid #cdcfd2;\n border-radius: 3px;\n}\n\n.lookup-demo-alert pre {\n margin: 0;\n}\n"
14881
14876
  },
14882
14877
  {
14883
- "fileName": "search-demo.component.ts",
14884
- "filePath": "/projects/lookup/documentation/code-examples/search/basic/search-demo.component.ts",
14885
- "rawContents": "import { Component } from '@angular/core';\n\nimport { LookupDemoItem } from './lookup-demo-item';\n\n@Component({\n selector: 'app-search-demo',\n templateUrl: './search-demo.component.html',\n})\nexport class SearchDemoComponent {\n public displayedItems: LookupDemoItem[];\n\n private items: LookupDemoItem[] = [\n {\n title: 'Call Robert Hernandez',\n note: 'Robert recently gave a very generous gift. We should call to thank him.',\n },\n {\n title: 'Send invitation to ball',\n note: \"The Spring Ball is coming up soon. Let's get those invitations out!\",\n },\n {\n title: 'Clean up desk',\n note: 'File and organize papers.',\n },\n {\n title: 'Investigate leads',\n note: 'Check out leads for important charity event funding.',\n },\n {\n title: 'Send thank you note',\n note: 'Send a thank you note to Timothy for his donation.',\n },\n ];\n\n public searchText = '';\n\n constructor() {\n this.displayedItems = this.items;\n }\n\n public searchApplied(searchText: string): void {\n let filteredItems = this.items;\n this.searchText = searchText;\n\n if (searchText) {\n filteredItems = this.items.filter(function (item: LookupDemoItem) {\n let property: keyof typeof item;\n\n for (property in item) {\n if (\n Object.prototype.hasOwnProperty.call(item, property) &&\n (property === 'title' || property === 'note')\n ) {\n if (item[property].indexOf(searchText) > -1) {\n return true;\n }\n }\n }\n\n return false;\n });\n }\n this.displayedItems = filteredItems;\n }\n}\n"
14878
+ "fileName": "lookup-async-demo.component.html",
14879
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo.component.html",
14880
+ "rawContents": "<form\n class=\"lookup-demo-form\"\n novalidate\n [formGroup]=\"favoritesForm\"\n (ngSubmit)=\"onSubmit()\"\n>\n <div class=\"sky-form-group\">\n <sky-input-box data-sky-id=\"favorite-names-field\">\n <label class=\"sky-control-label\" skyId #favoriteNamesLabel=\"skyId\">\n Favorite name(s)\n </label>\n <sky-lookup\n formControlName=\"favoriteNames\"\n idProperty=\"name\"\n [ariaLabelledBy]=\"favoriteNamesLabel.id\"\n [enableShowMore]=\"true\"\n (searchAsync)=\"searchAsync($event)\"\n [showAddButton]=\"true\"\n (addClick)=\"addClick($event)\"\n >\n </sky-lookup>\n </sky-input-box>\n </div>\n <div class=\"lookup-demo-alert\">\n <strong>Form model:</strong>\n <pre>{{ favoritesForm.value | json }}</pre>\n </div>\n <button class=\"sky-btn sky-btn-default\" type=\"submit\">Submit</button>\n</form>\n"
14886
14881
  },
14887
14882
  {
14888
- "fileName": "search-demo.module.ts",
14889
- "filePath": "/projects/lookup/documentation/code-examples/search/basic/search-demo.module.ts",
14890
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { SkyToolbarModule } from '@skyux/layout';\nimport { SkyRepeaterModule } from '@skyux/lists';\nimport { SkySearchModule } from '@skyux/lookup';\n\nimport { SearchDemoComponent } from './search-demo.component';\n\n@NgModule({\n imports: [CommonModule, SkyRepeaterModule, SkySearchModule, SkyToolbarModule],\n declarations: [SearchDemoComponent],\n exports: [SearchDemoComponent],\n})\nexport class SearchDemoModule {}\n"
14883
+ "fileName": "lookup-async-demo-search-results.ts",
14884
+ "filePath": "/projects/lookup/documentation/code-examples/lookup/add-item/lookup-async-demo-search-results.ts",
14885
+ "rawContents": "import { LookupDemoPerson } from './lookup-demo-person';\n\nexport interface LookupAsyncDemoSearchResults {\n hasMore: boolean;\n people: LookupDemoPerson[];\n totalCount: number;\n}\n"
14891
14886
  },
14892
14887
  {
14893
- "fileName": "selection-modal-demo-add-item.component.html",
14894
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-add-item.component.html",
14895
- "rawContents": "<sky-modal>\n <sky-modal-header>\n <h2>Add Item</h2>\n </sky-modal-header>\n <sky-modal-content>\n <form novalidate [formGroup]=\"formGroup\" (ngSubmit)=\"save()\">\n <sky-input-box>\n <label class=\"sky-control-label\">Name</label>\n <input\n type=\"text\"\n autocapitalize=\"words\"\n autocomplete=\"off\"\n formControlName=\"name\"\n class=\"sky-form-control\"\n />\n </sky-input-box>\n </form>\n </sky-modal-content>\n <sky-modal-footer>\n <button class=\"sky-btn sky-btn-default\" (click)=\"close()\">Cancel</button>\n <button class=\"sky-btn sky-btn-primary\" (click)=\"save()\">Add</button>\n </sky-modal-footer>\n</sky-modal>\n"
14888
+ "fileName": "country-field-demo.module.ts",
14889
+ "filePath": "/projects/lookup/documentation/code-examples/country-field/basic/country-field-demo.module.ts",
14890
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyCountryFieldModule } from '@skyux/lookup';\n\nimport { CountryFieldDemoComponent } from './country-field-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyCountryFieldModule,\n SkyInputBoxModule,\n ],\n declarations: [CountryFieldDemoComponent],\n exports: [CountryFieldDemoComponent],\n})\nexport class CountryFieldDemoModule {}\n"
14896
14891
  },
14897
14892
  {
14898
- "fileName": "selection-modal-demo-add-item.component.ts",
14899
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-add-item.component.ts",
14900
- "rawContents": "import { Component, inject } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { SkyModalInstance } from '@skyux/modals';\n\nlet nextId = 21;\n\n@Component({\n selector: 'app-selection-modal-demo-add-item',\n templateUrl: './selection-modal-demo-add-item.component.html',\n})\nexport class SelectionModalDemoAddItemComponent {\n public readonly formGroup: FormGroup;\n\n #modal = inject(SkyModalInstance);\n\n constructor() {\n this.formGroup = inject(FormBuilder).group({\n id: [`${nextId++}`],\n name: ['', Validators.required],\n });\n }\n\n public close() {\n this.#modal.close();\n }\n\n public save() {\n if (this.formGroup.valid) {\n this.#modal.close(this.formGroup.value, 'save');\n } else {\n this.formGroup.markAllAsTouched();\n }\n }\n}\n"
14893
+ "fileName": "country-field-demo.component.ts",
14894
+ "filePath": "/projects/lookup/documentation/code-examples/country-field/basic/country-field-demo.component.ts",
14895
+ "rawContents": "import { Component } from '@angular/core';\nimport {\n UntypedFormControl,\n UntypedFormGroup,\n Validators,\n} from '@angular/forms';\n\n@Component({\n selector: 'app-country-field-demo',\n templateUrl: './country-field-demo.component.html',\n})\nexport class CountryFieldDemoComponent {\n public countryControl: UntypedFormControl;\n\n public countryForm: UntypedFormGroup;\n\n constructor() {\n this.countryControl = new UntypedFormControl();\n this.countryControl.setValue({\n name: 'Australia',\n iso2: 'au',\n });\n this.countryForm = new UntypedFormGroup({\n countryControl: this.countryControl,\n });\n\n this.countryControl.setValidators([Validators.required]);\n }\n}\n"
14901
14896
  },
14902
14897
  {
14903
- "fileName": "selection-modal-demo-person.ts",
14904
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-person.ts",
14905
- "rawContents": "export interface SelectionModalDemoPerson {\n id: string;\n name: string;\n}\n"
14898
+ "fileName": "country-field-demo.component.html",
14899
+ "filePath": "/projects/lookup/documentation/code-examples/country-field/basic/country-field-demo.component.html",
14900
+ "rawContents": "<form [formGroup]=\"countryForm\">\n <sky-input-box>\n <sky-country-field formControlName=\"countryControl\"> </sky-country-field>\n </sky-input-box>\n</form>\n"
14906
14901
  },
14907
14902
  {
14908
- "fileName": "selection-modal-demo-search-results.ts",
14909
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo-search-results.ts",
14910
- "rawContents": "import { SelectionModalDemoPerson } from './selection-modal-demo-person';\n\nexport interface SelectionModalAsyncDemoSearchResults {\n hasMore: boolean;\n people: SelectionModalDemoPerson[];\n totalCount: number;\n}\n"
14903
+ "fileName": "autocomplete-demo.module.ts",
14904
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/search-filters/autocomplete-demo.module.ts",
14905
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutocompleteModule,\n SkyIdModule,\n ],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14911
14906
  },
14912
14907
  {
14913
- "fileName": "selection-modal-demo.component.html",
14914
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.component.html",
14915
- "rawContents": "<div class=\"sky-margin-stacked-xl\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default selection-modal-demo-show-btn\"\n (click)=\"showSelectionModal()\"\n >\n Select a value\n </button>\n</div>\n\n<div *ngIf=\"selectedPeople?.length\">\n Selected people:\n <ul class=\"selection-modal-demo-selected\">\n <li *ngFor=\"let selectedPerson of selectedPeople\">\n {{ selectedPerson.name }}\n </li>\n </ul>\n</div>\n"
14908
+ "fileName": "autocomplete-demo.component.ts",
14909
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/search-filters/autocomplete-demo.component.ts",
14910
+ "rawContents": "import { Component } from '@angular/core';\nimport { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';\nimport { SkyAutocompleteSearchFunctionFilter } from '@skyux/lookup';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public colors: { name: string }[] = [\n { name: 'Red' },\n { name: 'Blue' },\n { name: 'Green' },\n { name: 'Orange' },\n { name: 'Pink' },\n { name: 'Purple' },\n { name: 'Yellow' },\n { name: 'Brown' },\n { name: 'Turquoise' },\n { name: 'White' },\n { name: 'Black' },\n ];\n\n public myForm: UntypedFormGroup;\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[] = [\n (searchText: string, item: { name: string }): boolean => {\n return item.name !== 'Red';\n },\n ];\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.myForm = formBuilder.group({\n favoriteColor: undefined,\n });\n }\n}\n"
14916
14911
  },
14917
14912
  {
14918
- "fileName": "selection-modal-demo.component.spec.ts",
14919
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.component.spec.ts",
14920
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkySelectionModalHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\nimport { SelectionModalDemoModule } from './selection-modal-demo.module';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\ndescribe('Selection modal demo', () => {\n let mockSvc: jasmine.SpyObj<SelectionModalDemoService>;\n\n async function setupTest(): Promise<{\n harness: SkySelectionModalHarness;\n fixture: ComponentFixture<SelectionModalDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(SelectionModalDemoComponent);\n const openBtn = fixture.nativeElement.querySelector(\n '.selection-modal-demo-show-btn'\n );\n\n openBtn.click();\n fixture.detectChanges();\n\n const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n\n const harness = await rootLoader.getHarness(SkySelectionModalHarness);\n return { harness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('SelectionModalDemoService', ['search']);\n\n mockSvc.search.and.callFake((searchText) => {\n return of({\n hasMore: false,\n people:\n searchText === 'ra'\n ? [\n {\n id: '1',\n name: 'Rachel',\n },\n ]\n : [],\n totalCount: 1,\n });\n });\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, SelectionModalDemoModule],\n });\n });\n\n it('should update the selected items list when an item is selected', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.saveAndClose();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(1);\n expect(selectedItemEls[0].innerText.trim()).toBe('Rachel');\n });\n\n it('should not update the selected items list when the user cancels the selection modal', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.cancel();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(0);\n });\n});\n"
14913
+ "fileName": "autocomplete-demo.component.html",
14914
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/search-filters/autocomplete-demo.component.html",
14915
+ "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <p>\n The following field provides a custom function that filters the data before\n every search attempt.\n </p>\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"favoriteColorInput.id\">\n Color (\"Red\" is not available)\n </label>\n <sky-autocomplete [data]=\"colors\" [searchFilters]=\"searchFilters\">\n <input\n formControlName=\"favoriteColor\"\n skyAutocomplete\n skyId\n type=\"text\"\n #favoriteColorInput=\"skyId\"\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n"
14921
14916
  },
14922
14917
  {
14923
- "fileName": "selection-modal-demo.component.ts",
14924
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.component.ts",
14925
- "rawContents": "import { Component, OnDestroy, inject } from '@angular/core';\nimport {\n SkySelectionModalAddClickEventArgs,\n SkySelectionModalCloseArgs,\n SkySelectionModalSearchResult,\n SkySelectionModalService,\n} from '@skyux/lookup';\nimport { SkyModalCloseArgs, SkyModalService } from '@skyux/modals';\n\nimport { Subscription } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { SelectionModalDemoAddItemComponent } from './selection-modal-demo-add-item.component';\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\n@Component({\n selector: 'app-selection-modal-demo',\n templateUrl: './selection-modal-demo.component.html',\n})\nexport class SelectionModalDemoComponent implements OnDestroy {\n public selectedPeople: SelectionModalDemoPerson[] | undefined;\n\n #modalService = inject(SkyModalService);\n #searchSvc = inject(SelectionModalDemoService);\n #selectionModalSvc = inject(SkySelectionModalService);\n #subscriptions = new Subscription();\n\n public ngOnDestroy(): void {\n this.#subscriptions.unsubscribe();\n }\n\n public showSelectionModal(): void {\n const instance = this.#selectionModalSvc.open({\n descriptorProperty: 'name',\n idProperty: 'id',\n searchAsync: (args) =>\n this.#searchSvc.search(args.searchText).pipe(\n map(\n (results): SkySelectionModalSearchResult => ({\n hasMore: results.hasMore,\n items: results.people,\n totalCount: results.totalCount,\n })\n )\n ),\n selectMode: 'single',\n showAddButton: true,\n addClick: (args: SkySelectionModalAddClickEventArgs) => {\n const modal = this.#modalService.open(\n SelectionModalDemoAddItemComponent\n );\n this.#subscriptions.add(\n modal.closed.subscribe((close: SkyModalCloseArgs) => {\n if (close.reason === 'save') {\n this.#searchSvc.addItem(close.data);\n args.itemAdded({ item: close.data });\n }\n })\n );\n },\n });\n\n this.#subscriptions.add(\n instance.closed.subscribe((args: SkySelectionModalCloseArgs) => {\n if (args.reason === 'save') {\n this.selectedPeople =\n args.selectedItems as SelectionModalDemoPerson[];\n }\n })\n );\n }\n}\n"
14918
+ "fileName": "ocean.ts",
14919
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/ocean.ts",
14920
+ "rawContents": "export interface Ocean {\n id: number;\n title: string;\n}\n"
14926
14921
  },
14927
14922
  {
14928
- "fileName": "selection-modal-demo.module.ts",
14929
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.module.ts",
14930
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkySelectionModalModule } from '@skyux/lookup';\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { SelectionModalDemoAddItemComponent } from './selection-modal-demo-add-item.component';\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\n\n@NgModule({\n declarations: [\n SelectionModalDemoAddItemComponent,\n SelectionModalDemoComponent,\n ],\n exports: [SelectionModalDemoComponent],\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyModalModule,\n SkySelectionModalModule,\n ],\n})\nexport class SelectionModalDemoModule {}\n"
14923
+ "fileName": "autocomplete-demo.module.ts",
14924
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/autocomplete-demo.module.ts",
14925
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyIconModule } from '@skyux/indicators';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutocompleteModule,\n SkyIconModule,\n SkyIdModule,\n ],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14931
14926
  },
14932
14927
  {
14933
- "fileName": "selection-modal-demo.service.ts",
14934
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/add-item/selection-modal-demo.service.ts",
14935
- "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalAsyncDemoSearchResults } from './selection-modal-demo-search-results';\n\nconst people: SelectionModalDemoPerson[] = [\n { id: '1', name: 'Abed' },\n { id: '2', name: 'Alex' },\n { id: '3', name: 'Ben' },\n { id: '4', name: 'Britta' },\n { id: '5', name: 'Buzz' },\n { id: '6', name: 'Craig' },\n { id: '7', name: 'Elroy' },\n { id: '8', name: 'Garrett' },\n { id: '9', name: 'Ian' },\n { id: '10', name: 'Jeff' },\n { id: '11', name: 'Leonard' },\n { id: '12', name: 'Neil' },\n { id: '13', name: 'Pierce' },\n { id: '14', name: 'Preston' },\n { id: '15', name: 'Rachel' },\n { id: '16', name: 'Shirley' },\n { id: '17', name: 'Todd' },\n { id: '18', name: 'Troy' },\n { id: '19', name: 'Vaughn' },\n { id: '20', name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SelectionModalDemoService {\n public addItem(item: SelectionModalDemoPerson): void {\n people.push(item);\n }\n\n public search(\n searchText: string\n ): Observable<SelectionModalAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n}\n"
14928
+ "fileName": "autocomplete-demo.component.ts",
14929
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/autocomplete-demo.component.ts",
14930
+ "rawContents": "import { Component } from '@angular/core';\nimport {\n UntypedFormBuilder,\n UntypedFormControl,\n UntypedFormGroup,\n} from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunction,\n SkyAutocompleteSearchFunctionResponse,\n} from '@skyux/lookup';\n\nimport { Ocean } from './ocean';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public myForm: UntypedFormGroup;\n\n public largestOcean: UntypedFormControl;\n\n public oceans: Ocean[] = [\n { title: 'Arctic', id: 1 },\n { title: 'Atlantic', id: 2 },\n { title: 'Indian', id: 3 },\n { title: 'Pacific', id: 4 },\n ];\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.largestOcean = formBuilder.control({ title: 'Arctic', id: 1 });\n this.myForm = formBuilder.group({\n largestOcean: this.largestOcean,\n });\n }\n\n public getOceanSearchFunction(): SkyAutocompleteSearchFunction {\n const searchFunction = (\n searchText: string,\n oceans: Ocean[]\n ): SkyAutocompleteSearchFunctionResponse => {\n return new Promise((resolve) => {\n const searchTextLower = searchText.toLowerCase();\n\n const results = oceans.filter((ocean: Ocean) => {\n const val = ocean.title;\n const isMatch =\n val && val.toString().toLowerCase().indexOf(searchTextLower) > -1;\n return isMatch;\n });\n\n // Simulate an async request.\n setTimeout(() => {\n resolve(results);\n }, 500);\n });\n };\n\n return searchFunction;\n }\n}\n"
14936
14931
  },
14937
14932
  {
14938
- "fileName": "selection-modal-demo-person.ts",
14939
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo-person.ts",
14940
- "rawContents": "export interface SelectionModalDemoPerson {\n id: string;\n name: string;\n}\n"
14933
+ "fileName": "autocomplete-demo.component.html",
14934
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/custom-search/autocomplete-demo.component.html",
14935
+ "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <p>\n The following field has a preselected value and utilizes a custom search\n function, as well as a custom template for the search results.\n </p>\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"largestOceanInput.id\">\n Largest ocean\n </label>\n <sky-autocomplete\n descriptorProperty=\"title\"\n [data]=\"oceans\"\n [search]=\"getOceanSearchFunction()\"\n [searchResultTemplate]=\"oceanSearchResultTemplate\"\n >\n <input\n formControlName=\"largestOcean\"\n type=\"text\"\n skyAutocomplete\n skyId\n #largestOceanInput=\"skyId\"\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n\n<ng-template let-item=\"item\" #oceanSearchResultTemplate>\n <sky-icon icon=\"long-arrow-right\"></sky-icon>\n {{ item.title }} &bull; ID {{ item.id }}\n</ng-template>\n"
14941
14936
  },
14942
14937
  {
14943
- "fileName": "selection-modal-demo-search-results.ts",
14944
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo-search-results.ts",
14945
- "rawContents": "import { SelectionModalDemoPerson } from './selection-modal-demo-person';\n\nexport interface SelectionModalAsyncDemoSearchResults {\n hasMore: boolean;\n people: SelectionModalDemoPerson[];\n totalCount: number;\n}\n"
14938
+ "fileName": "autocomplete-demo.module.ts",
14939
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/basic/autocomplete-demo.module.ts",
14940
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [CommonModule, ReactiveFormsModule, SkyAutocompleteModule],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14946
14941
  },
14947
14942
  {
14948
- "fileName": "selection-modal-demo.component.html",
14949
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.component.html",
14950
- "rawContents": "<div class=\"sky-margin-stacked-xl\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default selection-modal-demo-show-btn\"\n (click)=\"showSelectionModal()\"\n >\n Select a value\n </button>\n</div>\n\n<div *ngIf=\"selectedPeople?.length\">\n Selected people:\n <ul class=\"selection-modal-demo-selected\">\n <li *ngFor=\"let selectedPerson of selectedPeople\">\n {{ selectedPerson.name }}\n </li>\n </ul>\n</div>\n"
14943
+ "fileName": "autocomplete-demo.component.ts",
14944
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/basic/autocomplete-demo.component.ts",
14945
+ "rawContents": "import { Component } from '@angular/core';\nimport { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public colors: { name: string }[] = [\n { name: 'Red' },\n { name: 'Blue' },\n { name: 'Green' },\n { name: 'Orange' },\n { name: 'Pink' },\n { name: 'Purple' },\n { name: 'Yellow' },\n { name: 'Brown' },\n { name: 'Turquoise' },\n { name: 'White' },\n { name: 'Black' },\n ];\n\n public myForm: UntypedFormGroup;\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.myForm = formBuilder.group({\n favoriteColor: undefined,\n });\n }\n}\n"
14951
14946
  },
14952
14947
  {
14953
- "fileName": "selection-modal-demo.component.spec.ts",
14954
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.component.spec.ts",
14955
- "rawContents": "import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';\nimport { ComponentFixture, TestBed } from '@angular/core/testing';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkySelectionModalHarness } from '@skyux/lookup/testing';\n\nimport { of } from 'rxjs';\n\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\nimport { SelectionModalDemoModule } from './selection-modal-demo.module';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\ndescribe('Selection modal demo', () => {\n let mockSvc: jasmine.SpyObj<SelectionModalDemoService>;\n\n async function setupTest(): Promise<{\n harness: SkySelectionModalHarness;\n fixture: ComponentFixture<SelectionModalDemoComponent>;\n }> {\n const fixture = TestBed.createComponent(SelectionModalDemoComponent);\n const openBtn = fixture.nativeElement.querySelector(\n '.selection-modal-demo-show-btn'\n );\n\n openBtn.click();\n fixture.detectChanges();\n\n const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n\n const harness = await rootLoader.getHarness(SkySelectionModalHarness);\n return { harness, fixture };\n }\n\n beforeEach(() => {\n // Create a mock search service. In a real-world application, the search\n // service would make a web request which should be avoided in unit tests.\n mockSvc = jasmine.createSpyObj('SelectionModalDemoService', ['search']);\n\n mockSvc.search.and.callFake((searchText) => {\n return of({\n hasMore: false,\n people:\n searchText === 'ra'\n ? [\n {\n id: '1',\n name: 'Rachel',\n },\n ]\n : [],\n totalCount: 1,\n });\n });\n\n TestBed.configureTestingModule({\n imports: [NoopAnimationsModule, SelectionModalDemoModule],\n });\n });\n\n it('should update the selected items list when an item is selected', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.saveAndClose();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(1);\n expect(selectedItemEls[0].innerText.trim()).toBe('Rachel');\n });\n\n it('should not update the selected items list when the user cancels the selection modal', async () => {\n const { harness, fixture } = await setupTest();\n\n await harness.enterSearchText('ra');\n await harness.selectSearchResult({\n contentText: 'Rachel',\n });\n await harness.cancel();\n\n const selectedItemEls = fixture.nativeElement.querySelectorAll(\n '.selection-modal-demo-selected li'\n );\n\n expect(selectedItemEls).toHaveSize(0);\n });\n});\n"
14948
+ "fileName": "autocomplete-demo.component.html",
14949
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/basic/autocomplete-demo.component.html",
14950
+ "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"favoriteColorInput.id\">\n Favorite color\n </label>\n <sky-autocomplete [data]=\"colors\">\n <input\n formControlName=\"favoriteColor\"\n type=\"text\"\n skyAutocomplete\n skyId\n #favoriteColorInput\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n"
14956
14951
  },
14957
14952
  {
14958
- "fileName": "selection-modal-demo.component.ts",
14959
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.component.ts",
14960
- "rawContents": "import { Component } from '@angular/core';\nimport {\n SkySelectionModalSearchResult,\n SkySelectionModalService,\n} from '@skyux/lookup';\n\nimport { map } from 'rxjs/operators';\n\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalDemoService } from './selection-modal-demo.service';\n\n@Component({\n selector: 'app-selection-modal-demo',\n templateUrl: './selection-modal-demo.component.html',\n})\nexport class SelectionModalDemoComponent {\n public selectedPeople: SelectionModalDemoPerson[] | undefined;\n\n #searchSvc: SelectionModalDemoService;\n #selectionModalSvc: SkySelectionModalService;\n\n constructor(\n searchSvc: SelectionModalDemoService,\n selectionModalSvc: SkySelectionModalService\n ) {\n this.#searchSvc = searchSvc;\n this.#selectionModalSvc = selectionModalSvc;\n }\n\n public showSelectionModal(): void {\n const instance = this.#selectionModalSvc.open({\n descriptorProperty: 'name',\n idProperty: 'id',\n searchAsync: (args) =>\n this.#searchSvc.search(args.searchText).pipe(\n map(\n (results): SkySelectionModalSearchResult => ({\n hasMore: results.hasMore,\n items: results.people,\n totalCount: results.totalCount,\n })\n )\n ),\n selectMode: 'single',\n });\n\n instance.closed.subscribe((args) => {\n if (args.reason === 'save') {\n this.selectedPeople = args.selectedItems as SelectionModalDemoPerson[];\n }\n });\n }\n}\n"
14953
+ "fileName": "planet.ts",
14954
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/planet.ts",
14955
+ "rawContents": "export interface Planet {\n name?: string;\n description?: string;\n}\n"
14961
14956
  },
14962
14957
  {
14963
- "fileName": "selection-modal-demo.module.ts",
14964
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.module.ts",
14965
- "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { SkySelectionModalModule } from '@skyux/lookup';\n\nimport { SelectionModalDemoComponent } from './selection-modal-demo.component';\n\n@NgModule({\n declarations: [SelectionModalDemoComponent],\n exports: [SelectionModalDemoComponent],\n imports: [CommonModule, SkySelectionModalModule],\n})\nexport class SelectionModalDemoModule {}\n"
14958
+ "fileName": "autocomplete-demo.module.ts",
14959
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/autocomplete-demo.module.ts",
14960
+ "rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIconModule } from '@skyux/indicators';\nimport { SkyAutocompleteModule } from '@skyux/lookup';\n\nimport { AutocompleteDemoComponent } from './autocomplete-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutocompleteModule,\n SkyIconModule,\n ],\n declarations: [AutocompleteDemoComponent],\n exports: [AutocompleteDemoComponent],\n})\nexport class AutocompleteDemoModule {}\n"
14966
14961
  },
14967
14962
  {
14968
- "fileName": "selection-modal-demo.service.ts",
14969
- "filePath": "/projects/lookup/documentation/code-examples/selection-modal/basic/selection-modal-demo.service.ts",
14970
- "rawContents": "import { Injectable } from '@angular/core';\n\nimport { Observable, of } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { SelectionModalDemoPerson } from './selection-modal-demo-person';\nimport { SelectionModalAsyncDemoSearchResults } from './selection-modal-demo-search-results';\n\nconst people: SelectionModalDemoPerson[] = [\n { id: '1', name: 'Abed' },\n { id: '2', name: 'Alex' },\n { id: '3', name: 'Ben' },\n { id: '4', name: 'Britta' },\n { id: '5', name: 'Buzz' },\n { id: '6', name: 'Craig' },\n { id: '7', name: 'Elroy' },\n { id: '8', name: 'Garrett' },\n { id: '9', name: 'Ian' },\n { id: '10', name: 'Jeff' },\n { id: '11', name: 'Leonard' },\n { id: '12', name: 'Neil' },\n { id: '13', name: 'Pierce' },\n { id: '14', name: 'Preston' },\n { id: '15', name: 'Rachel' },\n { id: '16', name: 'Shirley' },\n { id: '17', name: 'Todd' },\n { id: '18', name: 'Troy' },\n { id: '19', name: 'Vaughn' },\n { id: '20', name: 'Vicki' },\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SelectionModalDemoService {\n public search(\n searchText: string\n ): Observable<SelectionModalAsyncDemoSearchResults> {\n // Simulate a network call with latency. A real-world application might\n // use Angular's HttpClient to create an Observable from a call to a\n // web service.\n searchText = searchText.toUpperCase();\n\n const matchingPeople = people.filter((person) =>\n person.name.toUpperCase().includes(searchText)\n );\n\n return of({\n hasMore: false,\n people: matchingPeople,\n totalCount: matchingPeople.length,\n }).pipe(delay(800));\n }\n}\n"
14963
+ "fileName": "autocomplete-demo.component.ts",
14964
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/autocomplete-demo.component.ts",
14965
+ "rawContents": "import { Component } from '@angular/core';\nimport {\n UntypedFormBuilder,\n UntypedFormControl,\n UntypedFormGroup,\n} from '@angular/forms';\nimport {\n SkyAutocompleteSearchFunctionFilter,\n SkyAutocompleteSelectionChange,\n} from '@skyux/lookup';\n\nimport { Planet } from './planet';\n\n@Component({\n selector: 'app-autocomplete-demo',\n templateUrl: './autocomplete-demo.component.html',\n})\nexport class AutocompleteDemoComponent {\n public farthestPlanet: UntypedFormControl;\n\n public myForm: UntypedFormGroup;\n\n public planets: Planet[] = [\n {\n name: 'Mercury',\n description: 'Mercury is a planet in our solar system.',\n },\n { name: 'Venus', description: 'Venus is a planet in our solar system.' },\n { name: 'Earth', description: 'Earth is a planet in our solar system.' },\n { name: 'Mars', description: 'Mars is a planet in our solar system.' },\n {\n name: 'Jupiter',\n description: 'Jupiter is a planet in our solar system.',\n },\n { name: 'Saturn', description: 'Saturn is a planet in our solar system.' },\n { name: 'Uranus', description: 'Uranus is a planet in our solar system.' },\n {\n name: 'Neptune',\n description: 'Neptune is a planet in our solar system.',\n },\n ];\n\n public searchFilters: SkyAutocompleteSearchFunctionFilter[] = [\n (searchText: string, item: Planet): boolean => {\n return item.name !== 'Red';\n },\n ];\n\n constructor(formBuilder: UntypedFormBuilder) {\n this.farthestPlanet = formBuilder.control({});\n this.myForm = formBuilder.group({\n farthestPlanet: this.farthestPlanet,\n });\n }\n\n public onPlanetSelection(args: SkyAutocompleteSelectionChange): void {\n alert(`You selected ${args.selectedItem.name}`);\n }\n}\n"
14966
+ },
14967
+ {
14968
+ "fileName": "autocomplete-demo.component.html",
14969
+ "filePath": "/projects/lookup/documentation/code-examples/autocomplete/advanced/autocomplete-demo.component.html",
14970
+ "rawContents": "<form novalidate [formGroup]=\"myForm\">\n <div class=\"sky-margin-stacked-lg\">\n The following field:<br />\n <ul>\n <li>utilizes a custom search result template,</li>\n <li>searches against the name and description properties,</li>\n <li>limits the search results to two,</li>\n <li>runs the search if the query is at least three characters long,</li>\n <li>and fires an event when a selection is made.</li>\n </ul>\n </div>\n\n <div class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"planetInput.id\">\n Farthest planet from the sun\n </label>\n <sky-autocomplete\n [data]=\"planets\"\n [propertiesToSearch]=\"['name', 'description']\"\n [searchResultsLimit]=\"2\"\n [searchResultTemplate]=\"planetSearchResultTemplate\"\n [searchTextMinimumCharacters]=\"3\"\n (selectionChange)=\"onPlanetSelection($event)\"\n >\n <input\n formControlName=\"farthestPlanet\"\n skyAutocomplete\n skyId\n type=\"text\"\n #planetInput\n />\n </sky-autocomplete>\n </div>\n <p class=\"sky-font-emphasized\">Form model:</p>\n <pre>{{ myForm.value | json }}</pre>\n</form>\n\n<ng-template let-item=\"item\" #planetSearchResultTemplate>\n <strong>\n {{ item.name }}\n </strong>\n <br />\n {{ item.description }}\n</ng-template>\n"
14971
14971
  }
14972
14972
  ]
14973
14973
  }