@ks-digital/designsystem-angular 0.0.1-alpha.74 → 0.0.1-alpha.76

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 (77) hide show
  1. package/.npmignore +25 -0
  2. package/fesm2022/ks-digital-designsystem-angular-__internals.mjs +148 -78
  3. package/fesm2022/ks-digital-designsystem-angular-__internals.mjs.map +1 -1
  4. package/fesm2022/ks-digital-designsystem-angular-alert.mjs +59 -33
  5. package/fesm2022/ks-digital-designsystem-angular-alert.mjs.map +1 -1
  6. package/fesm2022/ks-digital-designsystem-angular-breadcrumbs.mjs +79 -43
  7. package/fesm2022/ks-digital-designsystem-angular-breadcrumbs.mjs.map +1 -1
  8. package/fesm2022/ks-digital-designsystem-angular-button.mjs +187 -61
  9. package/fesm2022/ks-digital-designsystem-angular-button.mjs.map +1 -1
  10. package/fesm2022/ks-digital-designsystem-angular-card.mjs +136 -86
  11. package/fesm2022/ks-digital-designsystem-angular-card.mjs.map +1 -1
  12. package/fesm2022/ks-digital-designsystem-angular-chip.mjs +76 -42
  13. package/fesm2022/ks-digital-designsystem-angular-chip.mjs.map +1 -1
  14. package/fesm2022/ks-digital-designsystem-angular-details.mjs +148 -64
  15. package/fesm2022/ks-digital-designsystem-angular-details.mjs.map +1 -1
  16. package/fesm2022/ks-digital-designsystem-angular-dialog.mjs +106 -48
  17. package/fesm2022/ks-digital-designsystem-angular-dialog.mjs.map +1 -1
  18. package/fesm2022/ks-digital-designsystem-angular-dropdown.mjs +147 -45
  19. package/fesm2022/ks-digital-designsystem-angular-dropdown.mjs.map +1 -1
  20. package/fesm2022/ks-digital-designsystem-angular-error-summary.mjs +83 -48
  21. package/fesm2022/ks-digital-designsystem-angular-error-summary.mjs.map +1 -1
  22. package/fesm2022/ks-digital-designsystem-angular-forms.mjs +495 -210
  23. package/fesm2022/ks-digital-designsystem-angular-forms.mjs.map +1 -1
  24. package/fesm2022/ks-digital-designsystem-angular-heading.mjs +69 -39
  25. package/fesm2022/ks-digital-designsystem-angular-heading.mjs.map +1 -1
  26. package/fesm2022/ks-digital-designsystem-angular-link.mjs +59 -30
  27. package/fesm2022/ks-digital-designsystem-angular-link.mjs.map +1 -1
  28. package/fesm2022/ks-digital-designsystem-angular-pagination.mjs +324 -157
  29. package/fesm2022/ks-digital-designsystem-angular-pagination.mjs.map +1 -1
  30. package/fesm2022/ks-digital-designsystem-angular-paragraph.mjs +41 -24
  31. package/fesm2022/ks-digital-designsystem-angular-paragraph.mjs.map +1 -1
  32. package/fesm2022/ks-digital-designsystem-angular-popover.mjs +147 -45
  33. package/fesm2022/ks-digital-designsystem-angular-popover.mjs.map +1 -1
  34. package/fesm2022/ks-digital-designsystem-angular-search.mjs +266 -144
  35. package/fesm2022/ks-digital-designsystem-angular-search.mjs.map +1 -1
  36. package/fesm2022/ks-digital-designsystem-angular-skeleton.mjs +78 -34
  37. package/fesm2022/ks-digital-designsystem-angular-skeleton.mjs.map +1 -1
  38. package/fesm2022/ks-digital-designsystem-angular-spinner.mjs +132 -53
  39. package/fesm2022/ks-digital-designsystem-angular-spinner.mjs.map +1 -1
  40. package/fesm2022/ks-digital-designsystem-angular-suggestion.mjs +561 -297
  41. package/fesm2022/ks-digital-designsystem-angular-suggestion.mjs.map +1 -1
  42. package/fesm2022/ks-digital-designsystem-angular-table.mjs +219 -76
  43. package/fesm2022/ks-digital-designsystem-angular-table.mjs.map +1 -1
  44. package/fesm2022/ks-digital-designsystem-angular-tabs.mjs +269 -120
  45. package/fesm2022/ks-digital-designsystem-angular-tabs.mjs.map +1 -1
  46. package/fesm2022/ks-digital-designsystem-angular-tag.mjs +84 -37
  47. package/fesm2022/ks-digital-designsystem-angular-tag.mjs.map +1 -1
  48. package/fesm2022/ks-digital-designsystem-angular-validation-message.mjs +42 -24
  49. package/fesm2022/ks-digital-designsystem-angular-validation-message.mjs.map +1 -1
  50. package/fesm2022/ks-digital-designsystem-angular.mjs +1 -6
  51. package/fesm2022/ks-digital-designsystem-angular.mjs.map +1 -1
  52. package/package.json +6 -5
  53. package/types/ks-digital-designsystem-angular-__internals.d.ts +51 -37
  54. package/types/ks-digital-designsystem-angular-alert.d.ts +18 -9
  55. package/types/ks-digital-designsystem-angular-breadcrumbs.d.ts +29 -13
  56. package/types/ks-digital-designsystem-angular-button.d.ts +67 -32
  57. package/types/ks-digital-designsystem-angular-card.d.ts +38 -23
  58. package/types/ks-digital-designsystem-angular-chip.d.ts +30 -15
  59. package/types/ks-digital-designsystem-angular-details.d.ts +32 -18
  60. package/types/ks-digital-designsystem-angular-dialog.d.ts +40 -18
  61. package/types/ks-digital-designsystem-angular-dropdown.d.ts +44 -13
  62. package/types/ks-digital-designsystem-angular-error-summary.d.ts +17 -14
  63. package/types/ks-digital-designsystem-angular-forms.d.ts +136 -71
  64. package/types/ks-digital-designsystem-angular-heading.d.ts +22 -19
  65. package/types/ks-digital-designsystem-angular-link.d.ts +18 -9
  66. package/types/ks-digital-designsystem-angular-pagination.d.ts +131 -75
  67. package/types/ks-digital-designsystem-angular-paragraph.d.ts +5 -8
  68. package/types/ks-digital-designsystem-angular-popover.d.ts +44 -13
  69. package/types/ks-digital-designsystem-angular-search.d.ts +62 -38
  70. package/types/ks-digital-designsystem-angular-skeleton.d.ts +18 -15
  71. package/types/ks-digital-designsystem-angular-spinner.d.ts +42 -23
  72. package/types/ks-digital-designsystem-angular-suggestion.d.ts +182 -116
  73. package/types/ks-digital-designsystem-angular-table.d.ts +67 -42
  74. package/types/ks-digital-designsystem-angular-tabs.d.ts +85 -56
  75. package/types/ks-digital-designsystem-angular-tag.d.ts +30 -15
  76. package/types/ks-digital-designsystem-angular-validation-message.d.ts +5 -8
  77. package/types/ks-digital-designsystem-angular.d.ts +2 -2
@@ -1,291 +1,456 @@
1
- import { NgTemplateOutlet } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { viewChild, ChangeDetectionStrategy, Component, input, CUSTOM_ELEMENTS_SCHEMA, contentChildren, contentChild, booleanAttribute, model, output, computed, signal, afterRenderEffect, effect, untracked } from '@angular/core';
4
- import '@digdir/designsystemet-web';
5
- import * as i1 from '@ks-digital/designsystem-angular/__internals';
6
- import { HostSize, HostColor } from '@ks-digital/designsystem-angular/__internals';
7
-
8
- class SuggestionListEmpty {
9
- /**
10
- * Hack to get the content from parent component so that we can
11
- * keep the dom structure needed without additional host elements
12
- */
13
- templateRef = viewChild('tpl', ...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
14
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SuggestionListEmpty, deps: [], target: i0.ɵɵFactoryTarget.Component });
15
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.8", type: SuggestionListEmpty, isStandalone: true, selector: "ksd-suggestion-list-empty", viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["tpl"], descendants: true, isSignal: true }], ngImport: i0, template: ` <ng-template #tpl><ng-content /></ng-template> `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
16
- }
17
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SuggestionListEmpty, decorators: [{
18
- type: Component,
19
- args: [{
20
- selector: 'ksd-suggestion-list-empty',
21
- changeDetection: ChangeDetectionStrategy.OnPush,
22
- template: ` <ng-template #tpl><ng-content /></ng-template> `,
23
- }]
24
- }], propDecorators: { templateRef: [{ type: i0.ViewChild, args: ['tpl', { isSignal: true }] }] } });
25
-
26
- class SuggestionListOption {
27
- /**
28
- * Hack to get the content from parent component so that we can
29
- * keep the dom structure needed without additional host elements
30
- */
31
- templateRef = viewChild('tpl', ...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
32
- value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
33
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SuggestionListOption, deps: [], target: i0.ɵɵFactoryTarget.Component });
34
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.8", type: SuggestionListOption, isStandalone: true, selector: "ksd-suggestion-list-option", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["tpl"], descendants: true, isSignal: true }], ngImport: i0, template: ` <ng-template #tpl><ng-content /></ng-template> `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
35
- }
36
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SuggestionListOption, decorators: [{
37
- type: Component,
38
- args: [{
39
- selector: 'ksd-suggestion-list-option',
40
- changeDetection: ChangeDetectionStrategy.OnPush,
41
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
42
- imports: [],
43
- template: ` <ng-template #tpl><ng-content /></ng-template> `,
44
- }]
45
- }], propDecorators: { templateRef: [{ type: i0.ViewChild, args: ['tpl', { isSignal: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }] } });
46
-
47
- class SuggestionList {
48
- /**
49
- * Screen reader announcement template for singular result count.
50
- *
51
- * @default '%d forslag'
52
- */
53
- singular = input('%d forslag', ...(ngDevMode ? [{ debugName: "singular" }] : /* istanbul ignore next */ []));
54
- /**
55
- * Screen reader announcement template for plural result count.
56
- *
57
- * @default '%d forslag'
58
- */
59
- plural = input('%d forslag', ...(ngDevMode ? [{ debugName: "plural" }] : /* istanbul ignore next */ []));
60
- options = contentChildren(SuggestionListOption, { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), descendants: true });
61
- empty = contentChild(SuggestionListEmpty, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
62
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SuggestionList, deps: [], target: i0.ɵɵFactoryTarget.Component });
63
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.8", type: SuggestionList, isStandalone: true, selector: "ksd-suggestion-list", inputs: { singular: { classPropertyName: "singular", publicName: "singular", isSignal: true, isRequired: false, transformFunction: null }, plural: { classPropertyName: "plural", publicName: "plural", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: none;" }, queries: [{ propertyName: "options", predicate: SuggestionListOption, descendants: true, isSignal: true }, { propertyName: "empty", first: true, predicate: SuggestionListEmpty, descendants: true, isSignal: true }], ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
64
- }
65
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SuggestionList, decorators: [{
66
- type: Component,
67
- args: [{
68
- selector: 'ksd-suggestion-list',
69
- changeDetection: ChangeDetectionStrategy.OnPush,
70
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
71
- host: {
72
- style: 'display: none;',
73
- },
74
- template: ``,
75
- }]
76
- }], propDecorators: { singular: [{ type: i0.Input, args: [{ isSignal: true, alias: "singular", required: false }] }], plural: [{ type: i0.Input, args: [{ isSignal: true, alias: "plural", required: false }] }], options: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => SuggestionListOption), { ...{
77
- descendants: true,
78
- }, isSignal: true }] }], empty: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SuggestionListEmpty), { isSignal: true }] }] } });
79
-
80
- const isSuggestionItem = (value) => typeof value === 'object' &&
81
- value !== null &&
82
- 'label' in value &&
83
- 'value' in value;
1
+ import { NgTemplateOutlet } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, Component, afterRenderEffect, booleanAttribute, computed, contentChild, contentChildren, effect, input, model, output, signal, untracked, viewChild } from "@angular/core";
4
+ import "@digdir/designsystemet-web";
5
+ import * as i1 from "@ks-digital/designsystem-angular/__internals";
6
+ import { HostColor, HostSize } from "@ks-digital/designsystem-angular/__internals";
7
+ var SuggestionListEmpty = class SuggestionListEmpty {
8
+ templateRef = viewChild("tpl", ...ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []);
9
+ static ɵfac = i0.ɵɵngDeclareFactory({
10
+ minVersion: "12.0.0",
11
+ version: "22.2.0",
12
+ ngImport: i0,
13
+ type: SuggestionListEmpty,
14
+ deps: [],
15
+ target: i0.ɵɵFactoryTarget.Component
16
+ });
17
+ static ɵcmp = i0.ɵɵngDeclareComponent({
18
+ minVersion: "17.2.0",
19
+ version: "22.2.0",
20
+ type: SuggestionListEmpty,
21
+ isStandalone: true,
22
+ selector: "ksd-suggestion-list-empty",
23
+ viewQueries: [{
24
+ propertyName: "templateRef",
25
+ first: true,
26
+ predicate: ["tpl"],
27
+ descendants: true,
28
+ isSignal: true
29
+ }],
30
+ ngImport: i0,
31
+ template: ` <ng-template #tpl><ng-content /></ng-template> `,
32
+ isInline: true,
33
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
34
+ });
35
+ };
36
+ i0.ɵɵngDeclareClassMetadata({
37
+ minVersion: "12.0.0",
38
+ version: "22.2.0",
39
+ ngImport: i0,
40
+ type: SuggestionListEmpty,
41
+ decorators: [{
42
+ type: Component,
43
+ args: [{
44
+ selector: "ksd-suggestion-list-empty",
45
+ changeDetection: ChangeDetectionStrategy.OnPush,
46
+ template: ` <ng-template #tpl><ng-content /></ng-template> `
47
+ }]
48
+ }],
49
+ propDecorators: { templateRef: [{
50
+ type: i0.ViewChild,
51
+ args: ["tpl", { isSignal: true }]
52
+ }] }
53
+ });
54
+ var SuggestionListOption = class SuggestionListOption {
55
+ templateRef = viewChild("tpl", ...ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []);
56
+ value = input.required(...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
57
+ static ɵfac = i0.ɵɵngDeclareFactory({
58
+ minVersion: "12.0.0",
59
+ version: "22.2.0",
60
+ ngImport: i0,
61
+ type: SuggestionListOption,
62
+ deps: [],
63
+ target: i0.ɵɵFactoryTarget.Component
64
+ });
65
+ static ɵcmp = i0.ɵɵngDeclareComponent({
66
+ minVersion: "17.2.0",
67
+ version: "22.2.0",
68
+ type: SuggestionListOption,
69
+ isStandalone: true,
70
+ selector: "ksd-suggestion-list-option",
71
+ inputs: { value: {
72
+ classPropertyName: "value",
73
+ publicName: "value",
74
+ isSignal: true,
75
+ isRequired: true,
76
+ transformFunction: null
77
+ } },
78
+ viewQueries: [{
79
+ propertyName: "templateRef",
80
+ first: true,
81
+ predicate: ["tpl"],
82
+ descendants: true,
83
+ isSignal: true
84
+ }],
85
+ ngImport: i0,
86
+ template: ` <ng-template #tpl><ng-content /></ng-template> `,
87
+ isInline: true,
88
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
89
+ });
90
+ };
91
+ i0.ɵɵngDeclareClassMetadata({
92
+ minVersion: "12.0.0",
93
+ version: "22.2.0",
94
+ ngImport: i0,
95
+ type: SuggestionListOption,
96
+ decorators: [{
97
+ type: Component,
98
+ args: [{
99
+ selector: "ksd-suggestion-list-option",
100
+ changeDetection: ChangeDetectionStrategy.OnPush,
101
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
102
+ imports: [],
103
+ template: ` <ng-template #tpl><ng-content /></ng-template> `
104
+ }]
105
+ }],
106
+ propDecorators: {
107
+ templateRef: [{
108
+ type: i0.ViewChild,
109
+ args: ["tpl", { isSignal: true }]
110
+ }],
111
+ value: [{
112
+ type: i0.Input,
113
+ args: [{
114
+ isSignal: true,
115
+ alias: "value",
116
+ required: true
117
+ }]
118
+ }]
119
+ }
120
+ });
121
+ var SuggestionList = class SuggestionList {
122
+ singular = input("%d forslag", ...ngDevMode ? [{ debugName: "singular" }] : /* istanbul ignore next */ []);
123
+ plural = input("%d forslag", ...ngDevMode ? [{ debugName: "plural" }] : /* istanbul ignore next */ []);
124
+ options = contentChildren(SuggestionListOption, {
125
+ ...ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {},
126
+ descendants: true
127
+ });
128
+ empty = contentChild(SuggestionListEmpty, ...ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []);
129
+ static ɵfac = i0.ɵɵngDeclareFactory({
130
+ minVersion: "12.0.0",
131
+ version: "22.2.0",
132
+ ngImport: i0,
133
+ type: SuggestionList,
134
+ deps: [],
135
+ target: i0.ɵɵFactoryTarget.Component
136
+ });
137
+ static ɵcmp = i0.ɵɵngDeclareComponent({
138
+ minVersion: "17.2.0",
139
+ version: "22.2.0",
140
+ type: SuggestionList,
141
+ isStandalone: true,
142
+ selector: "ksd-suggestion-list",
143
+ inputs: {
144
+ singular: {
145
+ classPropertyName: "singular",
146
+ publicName: "singular",
147
+ isSignal: true,
148
+ isRequired: false,
149
+ transformFunction: null
150
+ },
151
+ plural: {
152
+ classPropertyName: "plural",
153
+ publicName: "plural",
154
+ isSignal: true,
155
+ isRequired: false,
156
+ transformFunction: null
157
+ }
158
+ },
159
+ host: { styleAttribute: "display: none;" },
160
+ queries: [{
161
+ propertyName: "options",
162
+ predicate: SuggestionListOption,
163
+ descendants: true,
164
+ isSignal: true
165
+ }, {
166
+ propertyName: "empty",
167
+ first: true,
168
+ predicate: SuggestionListEmpty,
169
+ descendants: true,
170
+ isSignal: true
171
+ }],
172
+ ngImport: i0,
173
+ template: ``,
174
+ isInline: true,
175
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
176
+ });
177
+ };
178
+ i0.ɵɵngDeclareClassMetadata({
179
+ minVersion: "12.0.0",
180
+ version: "22.2.0",
181
+ ngImport: i0,
182
+ type: SuggestionList,
183
+ decorators: [{
184
+ type: Component,
185
+ args: [{
186
+ selector: "ksd-suggestion-list",
187
+ changeDetection: ChangeDetectionStrategy.OnPush,
188
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
189
+ host: { style: "display: none;" },
190
+ template: ``
191
+ }]
192
+ }],
193
+ propDecorators: {
194
+ singular: [{
195
+ type: i0.Input,
196
+ args: [{
197
+ isSignal: true,
198
+ alias: "singular",
199
+ required: false
200
+ }]
201
+ }],
202
+ plural: [{
203
+ type: i0.Input,
204
+ args: [{
205
+ isSignal: true,
206
+ alias: "plural",
207
+ required: false
208
+ }]
209
+ }],
210
+ options: [{
211
+ type: i0.ContentChildren,
212
+ args: [i0.forwardRef(() => SuggestionListOption), {
213
+ descendants: true,
214
+ isSignal: true
215
+ }]
216
+ }],
217
+ empty: [{
218
+ type: i0.ContentChild,
219
+ args: [i0.forwardRef(() => SuggestionListEmpty), { isSignal: true }]
220
+ }]
221
+ }
222
+ });
223
+ const isSuggestionItem = (value) => typeof value === "object" && value !== null && "label" in value && "value" in value;
84
224
  const sanitizeValues = (values) => values == null ? [] : Array.isArray(values) ? values : [values];
85
225
  const toValues = (value) => value == null ? [] : Array.isArray(value) ? value : [value];
86
- /** Extracts the labels carried by any items passed to `[selected]`. */
87
- const labelEntries = (values) => sanitizeValues(values)
88
- .filter(isSuggestionItem)
89
- .map((item) => [item.value, item.label]);
90
- /** Normalizes anything accepted by `[selected]` into the primitive value model. */
226
+ const labelEntries = (values) => sanitizeValues(values).filter(isSuggestionItem).map((item) => [item.value, item.label]);
91
227
  const toValue = (values) => {
92
- if (values == null)
93
- return undefined;
94
- const primitives = sanitizeValues(values).map((value) => isSuggestionItem(value) ? value.value : value);
95
- return Array.isArray(values) ? primitives : primitives[0];
228
+ if (values == null) return void 0;
229
+ const primitives = sanitizeValues(values).map((value) => isSuggestionItem(value) ? value.value : value);
230
+ return Array.isArray(values) ? primitives : primitives[0];
96
231
  };
97
232
  const resolveItems = (value, labels) => toValues(value).map((optionValue) => ({
98
- label: labels.get(optionValue) ?? optionValue,
99
- value: optionValue,
233
+ label: labels.get(optionValue) ?? optionValue,
234
+ value: optionValue
100
235
  }));
101
- /** Resolves a primitive value into items, using known labels where available. */
102
236
  const toSelected = (value, labels) => {
103
- if (value == null)
104
- return undefined;
105
- const items = resolveItems(value, labels);
106
- return Array.isArray(value) ? items : items[0];
237
+ if (value == null) return void 0;
238
+ const items = resolveItems(value, labels);
239
+ return Array.isArray(value) ? items : items[0];
107
240
  };
108
241
  const sameValue = (left, right) => {
109
- if (Array.isArray(left) && Array.isArray(right)) {
110
- return (left.length === right.length &&
111
- left.every((value, index) => value === right[index]));
112
- }
113
- return left === right;
242
+ if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((value, index) => value === right[index]);
243
+ return left === right;
114
244
  };
115
245
  const nextSelected = (data, previous, multiple) => {
116
- const value = data.value;
117
- if (!multiple)
118
- return data.isConnected ? undefined : value;
119
- const previousValues = toValues(previous);
120
- return data.isConnected
121
- ? previousValues.filter((previousValue) => previousValue !== value)
122
- : [...previousValues, value];
246
+ const value = data.value;
247
+ if (!multiple) return data.isConnected ? void 0 : value;
248
+ const previousValues = toValues(previous);
249
+ return data.isConnected ? previousValues.filter((previousValue) => previousValue !== value) : [...previousValues, value];
123
250
  };
124
-
125
251
  const defaultFilter = ({ label, input }) => label.toLowerCase().includes(input.value.trim().toLowerCase());
126
- // Distinguishes an unbound `selected` from one explicitly bound to `undefined`.
127
- const UNSET = Symbol('unset');
128
- class Suggestion {
129
- /**
130
- * Allows the user to select multiple items
131
- *
132
- * @default false
133
- */
134
- multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
135
- /**
136
- * Allows the user to create new items
137
- *
138
- * @default false
139
- */
140
- creatable = input(false, { ...(ngDevMode ? { debugName: "creatable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
141
- /**
142
- * Filter options; boolean or a custom callback.
143
- *
144
- * @default true
145
- */
146
- filter = input(true, ...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
147
- /**
148
- * Current value, as primitive option values. Bound by Angular signal forms.
149
- *
150
- * @default undefined
151
- */
152
- value = model(undefined, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
153
- /**
154
- * Controlled selection. Accepts items or raw option values.
155
- *
156
- * @default undefined
157
- */
158
- selected = input(UNSET, ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
159
- /**
160
- * Emits the resolved selection whenever the user changes it.
161
- */
162
- selectedChange = output();
163
- /**
164
- * Form-control dirty state.
165
- *
166
- * @default false
167
- */
168
- dirty = input(false, { ...(ngDevMode ? { debugName: "dirty" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
169
- /**
170
- * Whether the control has been touched. Synced with Angular signal forms.
171
- *
172
- * @default false
173
- */
174
- touched = model(false, ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
175
- selectedArray = computed(() => resolveItems(this.value(), this.labels()), ...(ngDevMode ? [{ debugName: "selectedArray" }] : /* istanbul ignore next */ []));
176
- suggestionElement = viewChild('suggestionElement', ...(ngDevMode ? [{ debugName: "suggestionElement" }] : /* istanbul ignore next */ []));
177
- labels = signal(new Map(), ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
178
- query = signal('', ...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
179
- suggestionList = contentChild(SuggestionList, ...(ngDevMode ? [{ debugName: "suggestionList" }] : /* istanbul ignore next */ []));
180
- constructor() {
181
- // Runs after render, so projected options are present in the DOM.
182
- afterRenderEffect(() => {
183
- this.query();
184
- this.filter();
185
- this.suggestionList()?.options();
186
- this.syncOptions();
187
- });
188
- // Apply the controlled `selected` input, when bound, to the value model.
189
- effect(() => {
190
- const selected = this.selected();
191
- if (selected === UNSET)
192
- return;
193
- untracked(() => this.learnLabels(labelEntries(selected)));
194
- const next = toValue(selected);
195
- if (sameValue(next, untracked(() => this.value())))
196
- return;
197
- untracked(() => this.value.set(next));
198
- });
199
- }
200
- onSelect(event) {
201
- const customEvent = event;
202
- customEvent.preventDefault();
203
- const data = customEvent.detail;
204
- if (!data)
205
- return;
206
- this.learnLabels([[data.value, data.textContent?.trim() || data.value]]);
207
- this.setValue(nextSelected(data, this.value(), this.multiple()));
208
- }
209
- onFocusOut(event) {
210
- const suggestionElement = this.suggestionElement()?.nativeElement;
211
- const nextTarget = event.relatedTarget;
212
- // Ignore focus changes within the composite widget; only mark touched
213
- // when focus leaves the suggestion control entirely.
214
- if (suggestionElement &&
215
- nextTarget instanceof Node &&
216
- suggestionElement.contains(nextTarget)) {
217
- return;
218
- }
219
- this.touched.set(true);
220
- }
221
- onInput(event) {
222
- const inputElement = event.target;
223
- this.query.set(inputElement?.value ?? '');
224
- }
225
- setValue(value) {
226
- if (sameValue(value, this.value()))
227
- return;
228
- this.value.set(value);
229
- this.selectedChange.emit(toSelected(value, this.labels()));
230
- }
231
- learnLabels(entries) {
232
- this.labels.update((current) => {
233
- let next = null;
234
- for (const [value, label] of entries) {
235
- if (current.get(value) === label)
236
- continue;
237
- next ??= new Map(current);
238
- next.set(value, label);
239
- }
240
- return next ?? current;
241
- });
242
- }
243
- syncOptions() {
244
- const suggestionElement = this.suggestionElement()?.nativeElement;
245
- if (!suggestionElement)
246
- return;
247
- const input = suggestionElement.querySelector('input');
248
- const options = Array.from(suggestionElement.querySelectorAll('u-option:not([data-empty])'));
249
- this.learnLabels(options.map((option) => [
250
- option.value,
251
- option.label ||
252
- option.text ||
253
- option.textContent?.trim() ||
254
- option.value,
255
- ]));
256
- const filter = this.filter();
257
- const filterFn = filter === true ? defaultFilter : filter;
258
- if (filterFn && input) {
259
- let index = 0;
260
- for (const option of options) {
261
- option.disabled = !filterFn({
262
- index,
263
- input,
264
- label: option.label,
265
- optionElement: option,
266
- text: option.text,
267
- value: option.value,
268
- });
269
- index++;
270
- }
271
- }
272
- else {
273
- for (const option of options) {
274
- option.disabled = false;
275
- }
276
- }
277
- const visibleOptions = options.filter((option) => !option.disabled && !option.hidden);
278
- const emptyOption = suggestionElement.querySelector('u-option[data-empty]');
279
- if (!emptyOption)
280
- return;
281
- if (visibleOptions.length === 0) {
282
- emptyOption.removeAttribute('hidden');
283
- return;
284
- }
285
- emptyOption.setAttribute('hidden', '');
286
- }
287
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Suggestion, deps: [], target: i0.ɵɵFactoryTarget.Component });
288
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: Suggestion, isStandalone: true, selector: "ksd-suggestion", inputs: { multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, creatable: { classPropertyName: "creatable", publicName: "creatable", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null }, dirty: { classPropertyName: "dirty", publicName: "dirty", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", selectedChange: "selectedChange", touched: "touchedChange" }, queries: [{ propertyName: "suggestionList", first: true, predicate: SuggestionList, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "suggestionElement", first: true, predicate: ["suggestionElement"], descendants: true, isSignal: true }], hostDirectives: [{ directive: i1.HostSize, inputs: ["data-size", "data-size"] }, { directive: i1.HostColor, inputs: ["data-color", "data-color"] }], ngImport: i0, template: `
252
+ const UNSET = Symbol("unset");
253
+ var Suggestion = class Suggestion {
254
+ multiple = input(false, {
255
+ ...ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {},
256
+ transform: booleanAttribute
257
+ });
258
+ creatable = input(false, {
259
+ ...ngDevMode ? { debugName: "creatable" } : /* istanbul ignore next */ {},
260
+ transform: booleanAttribute
261
+ });
262
+ filter = input(true, ...ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []);
263
+ value = model(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
264
+ selected = input(UNSET, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
265
+ selectedChange = output();
266
+ dirty = input(false, {
267
+ ...ngDevMode ? { debugName: "dirty" } : /* istanbul ignore next */ {},
268
+ transform: booleanAttribute
269
+ });
270
+ touched = input(false, {
271
+ ...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
272
+ transform: booleanAttribute
273
+ });
274
+ touch = output();
275
+ selectedArray = computed(() => resolveItems(this.value(), this.labels()), ...ngDevMode ? [{ debugName: "selectedArray" }] : /* istanbul ignore next */ []);
276
+ suggestionElement = viewChild("suggestionElement", ...ngDevMode ? [{ debugName: "suggestionElement" }] : /* istanbul ignore next */ []);
277
+ labels = signal(/* @__PURE__ */ new Map(), ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
278
+ query = signal("", ...ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []);
279
+ suggestionList = contentChild(SuggestionList, ...ngDevMode ? [{ debugName: "suggestionList" }] : /* istanbul ignore next */ []);
280
+ constructor() {
281
+ afterRenderEffect(() => {
282
+ this.query();
283
+ this.filter();
284
+ this.suggestionList()?.options();
285
+ this.syncOptions();
286
+ });
287
+ effect(() => {
288
+ const selected = this.selected();
289
+ if (selected === UNSET) return;
290
+ untracked(() => this.learnLabels(labelEntries(selected)));
291
+ const next = toValue(selected);
292
+ if (sameValue(next, untracked(() => this.value()))) return;
293
+ untracked(() => this.value.set(next));
294
+ });
295
+ }
296
+ onSelect(event) {
297
+ const customEvent = event;
298
+ customEvent.preventDefault();
299
+ const data = customEvent.detail;
300
+ if (!data) return;
301
+ this.learnLabels([[data.value, data.textContent?.trim() || data.value]]);
302
+ this.setValue(nextSelected(data, this.value(), this.multiple()));
303
+ }
304
+ onFocusOut(event) {
305
+ const suggestionElement = this.suggestionElement()?.nativeElement;
306
+ const nextTarget = event.relatedTarget;
307
+ if (suggestionElement && nextTarget instanceof Node && suggestionElement.contains(nextTarget)) return;
308
+ this.touch.emit();
309
+ }
310
+ onInput(event) {
311
+ const inputElement = event.target;
312
+ this.query.set(inputElement?.value ?? "");
313
+ }
314
+ setValue(value) {
315
+ if (sameValue(value, this.value())) return;
316
+ this.value.set(value);
317
+ this.selectedChange.emit(toSelected(value, this.labels()));
318
+ }
319
+ learnLabels(entries) {
320
+ this.labels.update((current) => {
321
+ let next = null;
322
+ for (const [value, label] of entries) {
323
+ if (current.get(value) === label) continue;
324
+ next ??= new Map(current);
325
+ next.set(value, label);
326
+ }
327
+ return next ?? current;
328
+ });
329
+ }
330
+ syncOptions() {
331
+ const suggestionElement = this.suggestionElement()?.nativeElement;
332
+ if (!suggestionElement) return;
333
+ const input = suggestionElement.querySelector("input");
334
+ const options = Array.from(suggestionElement.querySelectorAll("u-option:not([data-empty])"));
335
+ this.learnLabels(options.map((option) => [option.value, option.label || option.text || option.textContent?.trim() || option.value]));
336
+ const filter = this.filter();
337
+ const filterFn = filter === true ? defaultFilter : filter;
338
+ if (filterFn && input) {
339
+ let index = 0;
340
+ for (const option of options) {
341
+ option.disabled = !filterFn({
342
+ index,
343
+ input,
344
+ label: option.label,
345
+ optionElement: option,
346
+ text: option.text,
347
+ value: option.value
348
+ });
349
+ index++;
350
+ }
351
+ } else for (const option of options) option.disabled = false;
352
+ const visibleOptions = options.filter((option) => !option.disabled && !option.hidden);
353
+ const emptyOption = suggestionElement.querySelector("u-option[data-empty]");
354
+ if (!emptyOption) return;
355
+ if (visibleOptions.length === 0) {
356
+ emptyOption.removeAttribute("hidden");
357
+ return;
358
+ }
359
+ emptyOption.setAttribute("hidden", "");
360
+ }
361
+ static ɵfac = i0.ɵɵngDeclareFactory({
362
+ minVersion: "12.0.0",
363
+ version: "22.2.0",
364
+ ngImport: i0,
365
+ type: Suggestion,
366
+ deps: [],
367
+ target: i0.ɵɵFactoryTarget.Component
368
+ });
369
+ static ɵcmp = i0.ɵɵngDeclareComponent({
370
+ minVersion: "17.0.0",
371
+ version: "22.2.0",
372
+ type: Suggestion,
373
+ isStandalone: true,
374
+ selector: "ksd-suggestion",
375
+ inputs: {
376
+ multiple: {
377
+ classPropertyName: "multiple",
378
+ publicName: "multiple",
379
+ isSignal: true,
380
+ isRequired: false,
381
+ transformFunction: null
382
+ },
383
+ creatable: {
384
+ classPropertyName: "creatable",
385
+ publicName: "creatable",
386
+ isSignal: true,
387
+ isRequired: false,
388
+ transformFunction: null
389
+ },
390
+ filter: {
391
+ classPropertyName: "filter",
392
+ publicName: "filter",
393
+ isSignal: true,
394
+ isRequired: false,
395
+ transformFunction: null
396
+ },
397
+ value: {
398
+ classPropertyName: "value",
399
+ publicName: "value",
400
+ isSignal: true,
401
+ isRequired: false,
402
+ transformFunction: null
403
+ },
404
+ selected: {
405
+ classPropertyName: "selected",
406
+ publicName: "selected",
407
+ isSignal: true,
408
+ isRequired: false,
409
+ transformFunction: null
410
+ },
411
+ dirty: {
412
+ classPropertyName: "dirty",
413
+ publicName: "dirty",
414
+ isSignal: true,
415
+ isRequired: false,
416
+ transformFunction: null
417
+ },
418
+ touched: {
419
+ classPropertyName: "touched",
420
+ publicName: "touched",
421
+ isSignal: true,
422
+ isRequired: false,
423
+ transformFunction: null
424
+ }
425
+ },
426
+ outputs: {
427
+ value: "valueChange",
428
+ selectedChange: "selectedChange",
429
+ touch: "touch"
430
+ },
431
+ queries: [{
432
+ propertyName: "suggestionList",
433
+ first: true,
434
+ predicate: SuggestionList,
435
+ descendants: true,
436
+ isSignal: true
437
+ }],
438
+ viewQueries: [{
439
+ propertyName: "suggestionElement",
440
+ first: true,
441
+ predicate: ["suggestionElement"],
442
+ descendants: true,
443
+ isSignal: true
444
+ }],
445
+ hostDirectives: [{
446
+ directive: i1.HostSize,
447
+ inputs: ["data-size", "data-size"]
448
+ }, {
449
+ directive: i1.HostColor,
450
+ inputs: ["data-color", "data-color"]
451
+ }],
452
+ ngImport: i0,
453
+ template: `
289
454
  <ds-suggestion
290
455
  #suggestionElement
291
456
  class="ds-suggestion"
@@ -318,20 +483,42 @@ class Suggestion {
318
483
  }
319
484
  </u-datalist>
320
485
  </ds-suggestion>
321
- `, isInline: true, styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
322
- }
323
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Suggestion, decorators: [{
324
- type: Component,
325
- args: [{ selector: 'ksd-suggestion', changeDetection: ChangeDetectionStrategy.OnPush, hostDirectives: [
326
- {
327
- directive: HostSize,
328
- inputs: ['data-size'],
329
- },
330
- {
331
- directive: HostColor,
332
- inputs: ['data-color'],
333
- },
334
- ], schemas: [CUSTOM_ELEMENTS_SCHEMA], imports: [NgTemplateOutlet], template: `
486
+ `,
487
+ isInline: true,
488
+ styles: [":host{display:block}\n"],
489
+ dependencies: [{
490
+ kind: "directive",
491
+ type: NgTemplateOutlet,
492
+ selector: "[ngTemplateOutlet]",
493
+ inputs: [
494
+ "ngTemplateOutletContext",
495
+ "ngTemplateOutlet",
496
+ "ngTemplateOutletInjector"
497
+ ]
498
+ }],
499
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
500
+ });
501
+ };
502
+ i0.ɵɵngDeclareClassMetadata({
503
+ minVersion: "12.0.0",
504
+ version: "22.2.0",
505
+ ngImport: i0,
506
+ type: Suggestion,
507
+ decorators: [{
508
+ type: Component,
509
+ args: [{
510
+ selector: "ksd-suggestion",
511
+ changeDetection: ChangeDetectionStrategy.OnPush,
512
+ hostDirectives: [{
513
+ directive: HostSize,
514
+ inputs: ["data-size"]
515
+ }, {
516
+ directive: HostColor,
517
+ inputs: ["data-color"]
518
+ }],
519
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
520
+ imports: [NgTemplateOutlet],
521
+ template: `
335
522
  <ds-suggestion
336
523
  #suggestionElement
337
524
  class="ds-suggestion"
@@ -364,12 +551,89 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
364
551
  }
365
552
  </u-datalist>
366
553
  </ds-suggestion>
367
- `, styles: [":host{display:block}\n"] }]
368
- }], ctorParameters: () => [], propDecorators: { multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], creatable: [{ type: i0.Input, args: [{ isSignal: true, alias: "creatable", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }], selectedChange: [{ type: i0.Output, args: ["selectedChange"] }], dirty: [{ type: i0.Input, args: [{ isSignal: true, alias: "dirty", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }, { type: i0.Output, args: ["touchedChange"] }], suggestionElement: [{ type: i0.ViewChild, args: ['suggestionElement', { isSignal: true }] }], suggestionList: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SuggestionList), { isSignal: true }] }] } });
369
-
370
- /**
371
- * Generated bundle index. Do not edit.
372
- */
373
-
554
+ `,
555
+ styles: [":host{display:block}\n"]
556
+ }]
557
+ }],
558
+ ctorParameters: () => [],
559
+ propDecorators: {
560
+ multiple: [{
561
+ type: i0.Input,
562
+ args: [{
563
+ isSignal: true,
564
+ alias: "multiple",
565
+ required: false
566
+ }]
567
+ }],
568
+ creatable: [{
569
+ type: i0.Input,
570
+ args: [{
571
+ isSignal: true,
572
+ alias: "creatable",
573
+ required: false
574
+ }]
575
+ }],
576
+ filter: [{
577
+ type: i0.Input,
578
+ args: [{
579
+ isSignal: true,
580
+ alias: "filter",
581
+ required: false
582
+ }]
583
+ }],
584
+ value: [{
585
+ type: i0.Input,
586
+ args: [{
587
+ isSignal: true,
588
+ alias: "value",
589
+ required: false
590
+ }]
591
+ }, {
592
+ type: i0.Output,
593
+ args: ["valueChange"]
594
+ }],
595
+ selected: [{
596
+ type: i0.Input,
597
+ args: [{
598
+ isSignal: true,
599
+ alias: "selected",
600
+ required: false
601
+ }]
602
+ }],
603
+ selectedChange: [{
604
+ type: i0.Output,
605
+ args: ["selectedChange"]
606
+ }],
607
+ dirty: [{
608
+ type: i0.Input,
609
+ args: [{
610
+ isSignal: true,
611
+ alias: "dirty",
612
+ required: false
613
+ }]
614
+ }],
615
+ touched: [{
616
+ type: i0.Input,
617
+ args: [{
618
+ isSignal: true,
619
+ alias: "touched",
620
+ required: false
621
+ }]
622
+ }],
623
+ touch: [{
624
+ type: i0.Output,
625
+ args: ["touch"]
626
+ }],
627
+ suggestionElement: [{
628
+ type: i0.ViewChild,
629
+ args: ["suggestionElement", { isSignal: true }]
630
+ }],
631
+ suggestionList: [{
632
+ type: i0.ContentChild,
633
+ args: [i0.forwardRef(() => SuggestionList), { isSignal: true }]
634
+ }]
635
+ }
636
+ });
374
637
  export { Suggestion, SuggestionList, SuggestionListEmpty, SuggestionListOption };
375
- //# sourceMappingURL=ks-digital-designsystem-angular-suggestion.mjs.map
638
+
639
+ //# sourceMappingURL=ks-digital-designsystem-angular-suggestion.mjs.map