@tectra-ng/blocks 0.0.0-stage → 0.1.6

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 (101) hide show
  1. package/README.md +16 -2
  2. package/action-tile/README.md +33 -0
  3. package/actions-menu/README.md +42 -0
  4. package/app-footer/README.md +30 -0
  5. package/app-layout/README.md +51 -0
  6. package/command-palette/README.md +63 -0
  7. package/console-layout/README.md +70 -0
  8. package/cookie-notice/README.md +45 -0
  9. package/empty-state/README.md +35 -0
  10. package/fesm2022/tectra-ng-blocks-action-tile.mjs +294 -0
  11. package/fesm2022/tectra-ng-blocks-action-tile.mjs.map +1 -0
  12. package/fesm2022/tectra-ng-blocks-actions-menu.mjs +380 -0
  13. package/fesm2022/tectra-ng-blocks-actions-menu.mjs.map +1 -0
  14. package/fesm2022/tectra-ng-blocks-app-footer.mjs +276 -0
  15. package/fesm2022/tectra-ng-blocks-app-footer.mjs.map +1 -0
  16. package/fesm2022/tectra-ng-blocks-app-layout.mjs +544 -0
  17. package/fesm2022/tectra-ng-blocks-app-layout.mjs.map +1 -0
  18. package/fesm2022/tectra-ng-blocks-command-palette.mjs +663 -0
  19. package/fesm2022/tectra-ng-blocks-command-palette.mjs.map +1 -0
  20. package/fesm2022/tectra-ng-blocks-console-layout.mjs +1060 -0
  21. package/fesm2022/tectra-ng-blocks-console-layout.mjs.map +1 -0
  22. package/fesm2022/tectra-ng-blocks-cookie-notice.mjs +416 -0
  23. package/fesm2022/tectra-ng-blocks-cookie-notice.mjs.map +1 -0
  24. package/fesm2022/tectra-ng-blocks-empty-state.mjs +278 -0
  25. package/fesm2022/tectra-ng-blocks-empty-state.mjs.map +1 -0
  26. package/fesm2022/tectra-ng-blocks-filters-panel.mjs +959 -0
  27. package/fesm2022/tectra-ng-blocks-filters-panel.mjs.map +1 -0
  28. package/fesm2022/tectra-ng-blocks-kanban.mjs +864 -0
  29. package/fesm2022/tectra-ng-blocks-kanban.mjs.map +1 -0
  30. package/fesm2022/tectra-ng-blocks-network-status.mjs +303 -0
  31. package/fesm2022/tectra-ng-blocks-network-status.mjs.map +1 -0
  32. package/fesm2022/tectra-ng-blocks-page-header.mjs +195 -0
  33. package/fesm2022/tectra-ng-blocks-page-header.mjs.map +1 -0
  34. package/fesm2022/tectra-ng-blocks-pinned-tabs.mjs +692 -0
  35. package/fesm2022/tectra-ng-blocks-pinned-tabs.mjs.map +1 -0
  36. package/fesm2022/tectra-ng-blocks-public-header.mjs +372 -0
  37. package/fesm2022/tectra-ng-blocks-public-header.mjs.map +1 -0
  38. package/fesm2022/tectra-ng-blocks-qr-code.mjs +487 -0
  39. package/fesm2022/tectra-ng-blocks-qr-code.mjs.map +1 -0
  40. package/fesm2022/tectra-ng-blocks-switch-language.mjs +316 -0
  41. package/fesm2022/tectra-ng-blocks-switch-language.mjs.map +1 -0
  42. package/fesm2022/tectra-ng-blocks-switch-theme.mjs +416 -0
  43. package/fesm2022/tectra-ng-blocks-switch-theme.mjs.map +1 -0
  44. package/fesm2022/tectra-ng-blocks-topbar-preferences.mjs +260 -0
  45. package/fesm2022/tectra-ng-blocks-topbar-preferences.mjs.map +1 -0
  46. package/fesm2022/tectra-ng-blocks-wizard.mjs +1284 -0
  47. package/fesm2022/tectra-ng-blocks-wizard.mjs.map +1 -0
  48. package/fesm2022/tectra-ng-blocks.mjs +4 -0
  49. package/fesm2022/tectra-ng-blocks.mjs.map +1 -0
  50. package/filters-panel/README.md +68 -0
  51. package/kanban/README.md +55 -0
  52. package/network-status/README.md +33 -0
  53. package/package.json +137 -3
  54. package/page-header/README.md +32 -0
  55. package/pinned-tabs/README.md +42 -0
  56. package/public-header/README.md +44 -0
  57. package/qr-code/README.md +52 -0
  58. package/switch-language/README.md +33 -0
  59. package/switch-theme/README.md +32 -0
  60. package/topbar-preferences/README.md +35 -0
  61. package/types/tectra-ng-blocks-action-tile.d.ts +114 -0
  62. package/types/tectra-ng-blocks-action-tile.d.ts.map +1 -0
  63. package/types/tectra-ng-blocks-actions-menu.d.ts +112 -0
  64. package/types/tectra-ng-blocks-actions-menu.d.ts.map +1 -0
  65. package/types/tectra-ng-blocks-app-footer.d.ts +111 -0
  66. package/types/tectra-ng-blocks-app-footer.d.ts.map +1 -0
  67. package/types/tectra-ng-blocks-app-layout.d.ts +212 -0
  68. package/types/tectra-ng-blocks-app-layout.d.ts.map +1 -0
  69. package/types/tectra-ng-blocks-command-palette.d.ts +291 -0
  70. package/types/tectra-ng-blocks-command-palette.d.ts.map +1 -0
  71. package/types/tectra-ng-blocks-console-layout.d.ts +454 -0
  72. package/types/tectra-ng-blocks-console-layout.d.ts.map +1 -0
  73. package/types/tectra-ng-blocks-cookie-notice.d.ts +168 -0
  74. package/types/tectra-ng-blocks-cookie-notice.d.ts.map +1 -0
  75. package/types/tectra-ng-blocks-empty-state.d.ts +138 -0
  76. package/types/tectra-ng-blocks-empty-state.d.ts.map +1 -0
  77. package/types/tectra-ng-blocks-filters-panel.d.ts +314 -0
  78. package/types/tectra-ng-blocks-filters-panel.d.ts.map +1 -0
  79. package/types/tectra-ng-blocks-kanban.d.ts +260 -0
  80. package/types/tectra-ng-blocks-kanban.d.ts.map +1 -0
  81. package/types/tectra-ng-blocks-network-status.d.ts +108 -0
  82. package/types/tectra-ng-blocks-network-status.d.ts.map +1 -0
  83. package/types/tectra-ng-blocks-page-header.d.ts +86 -0
  84. package/types/tectra-ng-blocks-page-header.d.ts.map +1 -0
  85. package/types/tectra-ng-blocks-pinned-tabs.d.ts +159 -0
  86. package/types/tectra-ng-blocks-pinned-tabs.d.ts.map +1 -0
  87. package/types/tectra-ng-blocks-public-header.d.ts +142 -0
  88. package/types/tectra-ng-blocks-public-header.d.ts.map +1 -0
  89. package/types/tectra-ng-blocks-qr-code.d.ts +160 -0
  90. package/types/tectra-ng-blocks-qr-code.d.ts.map +1 -0
  91. package/types/tectra-ng-blocks-switch-language.d.ts +106 -0
  92. package/types/tectra-ng-blocks-switch-language.d.ts.map +1 -0
  93. package/types/tectra-ng-blocks-switch-theme.d.ts +108 -0
  94. package/types/tectra-ng-blocks-switch-theme.d.ts.map +1 -0
  95. package/types/tectra-ng-blocks-topbar-preferences.d.ts +103 -0
  96. package/types/tectra-ng-blocks-topbar-preferences.d.ts.map +1 -0
  97. package/types/tectra-ng-blocks-wizard.d.ts +682 -0
  98. package/types/tectra-ng-blocks-wizard.d.ts.map +1 -0
  99. package/types/tectra-ng-blocks.d.ts +2 -0
  100. package/types/tectra-ng-blocks.d.ts.map +1 -0
  101. package/wizard/README.md +77 -0
@@ -0,0 +1,316 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, booleanAttribute, computed, inject, input, model, viewChild } from "@angular/core";
3
+ import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
4
+ import { TxLocaleService, injectTranslations } from "@tectra-ng/core/i18n";
5
+ import { optionalBoolean } from "@tectra-ng/core/utils";
6
+ import { toStyleObject } from "@tectra-ng/themes";
7
+ const TX_LANGUAGES = [{
8
+ code: "us",
9
+ name: "English",
10
+ short: "EN"
11
+ }, {
12
+ code: "ua",
13
+ name: "Українська",
14
+ short: "UA"
15
+ }];
16
+ const NEXT_KEYS = /* @__PURE__ */ new Set(["ArrowRight", "ArrowDown"]);
17
+ const PREVIOUS_KEYS = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowUp"]);
18
+ var TxSwitchLanguage = class TxSwitchLanguage {
19
+ locale = inject(TxLocaleService);
20
+ group = viewChild.required("group", ...ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []);
21
+ languages = input(TX_LANGUAGES, ...ngDevMode ? [{ debugName: "languages" }] : /* istanbul ignore next */ []);
22
+ value = model(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
23
+ syncLocale = input(true, {
24
+ ...ngDevMode ? { debugName: "syncLocale" } : /* istanbul ignore next */ {},
25
+ transform: booleanAttribute
26
+ });
27
+ ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
28
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
29
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
30
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
31
+ unstyled = input(void 0, {
32
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
33
+ transform: optionalBoolean
34
+ });
35
+ isUnstyled = injectUnstyled(this.unstyled);
36
+ passThrough = injectPassThrough("switchLanguage", this, this.pt, this.ptOptions);
37
+ translations = injectTranslations();
38
+ hostStyle = computed(() => ({
39
+ ...toStyleObject(this.dt(), "--tx-switch-language"),
40
+ ...this.passThrough().root?.style
41
+ }), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
42
+ name = computed(() => this.ariaLabel() ?? this.translations().language, ...ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []);
43
+ current = computed(() => this.value() ?? this.locale.locale().code, ...ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []);
44
+ activeIndex = computed(() => Math.max(this.languages().findIndex((language) => language.code === this.current()), 0), ...ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []);
45
+ select(code) {
46
+ this.value.set(code);
47
+ if (this.syncLocale()) this.locale.setLocale(code);
48
+ }
49
+ onKeydown(event) {
50
+ const languages = this.languages();
51
+ const count = languages.length;
52
+ let index;
53
+ if (NEXT_KEYS.has(event.key)) index = (this.activeIndex() + 1) % count;
54
+ else if (PREVIOUS_KEYS.has(event.key)) index = (this.activeIndex() - 1 + count) % count;
55
+ else if (event.key === "Home" || event.key === "End") index = event.key === "Home" ? 0 : count - 1;
56
+ else return;
57
+ event.preventDefault();
58
+ this.select(languages[index].code);
59
+ this.group().nativeElement.querySelectorAll("[role=\"radio\"]")[index]?.focus();
60
+ }
61
+ static ɵfac = i0.ɵɵngDeclareFactory({
62
+ minVersion: "12.0.0",
63
+ version: "22.2.3",
64
+ ngImport: i0,
65
+ type: TxSwitchLanguage,
66
+ deps: [],
67
+ target: i0.ɵɵFactoryTarget.Component
68
+ });
69
+ static ɵcmp = i0.ɵɵngDeclareComponent({
70
+ minVersion: "17.0.0",
71
+ version: "22.2.3",
72
+ type: TxSwitchLanguage,
73
+ isStandalone: true,
74
+ selector: "tx-switch-language",
75
+ inputs: {
76
+ languages: {
77
+ classPropertyName: "languages",
78
+ publicName: "languages",
79
+ isSignal: true,
80
+ isRequired: false,
81
+ transformFunction: null
82
+ },
83
+ value: {
84
+ classPropertyName: "value",
85
+ publicName: "value",
86
+ isSignal: true,
87
+ isRequired: false,
88
+ transformFunction: null
89
+ },
90
+ syncLocale: {
91
+ classPropertyName: "syncLocale",
92
+ publicName: "syncLocale",
93
+ isSignal: true,
94
+ isRequired: false,
95
+ transformFunction: null
96
+ },
97
+ ariaLabel: {
98
+ classPropertyName: "ariaLabel",
99
+ publicName: "ariaLabel",
100
+ isSignal: true,
101
+ isRequired: false,
102
+ transformFunction: null
103
+ },
104
+ dt: {
105
+ classPropertyName: "dt",
106
+ publicName: "dt",
107
+ isSignal: true,
108
+ isRequired: false,
109
+ transformFunction: null
110
+ },
111
+ pt: {
112
+ classPropertyName: "pt",
113
+ publicName: "pt",
114
+ isSignal: true,
115
+ isRequired: false,
116
+ transformFunction: null
117
+ },
118
+ ptOptions: {
119
+ classPropertyName: "ptOptions",
120
+ publicName: "ptOptions",
121
+ isSignal: true,
122
+ isRequired: false,
123
+ transformFunction: null
124
+ },
125
+ unstyled: {
126
+ classPropertyName: "unstyled",
127
+ publicName: "unstyled",
128
+ isSignal: true,
129
+ isRequired: false,
130
+ transformFunction: null
131
+ }
132
+ },
133
+ outputs: { value: "valueChange" },
134
+ host: {
135
+ properties: {
136
+ "class": "passThrough().root?.class",
137
+ "style": "hostStyle()",
138
+ "attr.data-styled": "!isUnstyled() || null"
139
+ },
140
+ classAttribute: "tx-switch-language"
141
+ },
142
+ viewQueries: [{
143
+ propertyName: "group",
144
+ first: true,
145
+ predicate: ["group"],
146
+ descendants: true,
147
+ isSignal: true
148
+ }],
149
+ ngImport: i0,
150
+ template: `
151
+ <div
152
+ #group
153
+ class="tx-switch-language__group"
154
+ role="radiogroup"
155
+ tabindex="-1"
156
+ [attr.aria-label]="name()"
157
+ [style.--tx-switch-language-count]="languages().length"
158
+ [style.--tx-switch-language-index]="activeIndex()"
159
+ [class]="passThrough().group?.class"
160
+ [style]="passThrough().group?.style"
161
+ (keydown)="onKeydown($event)"
162
+ >
163
+ <span class="tx-switch-language__thumb" aria-hidden="true" [class]="passThrough().thumb?.class" [style]="passThrough().thumb?.style"></span>
164
+ @for (language of languages(); track language.code; let index = $index) {
165
+ <button
166
+ type="button"
167
+ role="radio"
168
+ class="tx-switch-language__option"
169
+ [class.tx-switch-language__option--active]="index === activeIndex()"
170
+ [attr.aria-checked]="index === activeIndex()"
171
+ [attr.aria-label]="language.name"
172
+ [attr.tabindex]="index === activeIndex() ? 0 : -1"
173
+ [title]="language.name"
174
+ [class]="passThrough().option?.class"
175
+ [style]="passThrough().option?.style"
176
+ (click)="select(language.code)"
177
+ >
178
+ {{ language.short }}
179
+ </button>
180
+ }
181
+ </div>
182
+ `,
183
+ isInline: true,
184
+ styles: [":host{display:inline-flex}.tx-switch-language__group{position:relative;display:inline-grid;grid-auto-columns:1fr;grid-auto-flow:column}.tx-switch-language__thumb{position:absolute;pointer-events:none}.tx-switch-language__option{position:relative;z-index:1;margin:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer}:host([data-styled]) .tx-switch-language__group{box-sizing:border-box;height:var(--tx-switch-language-height);padding:var(--tx-switch-language-padding);border-radius:var(--tx-switch-language-border-radius);background:var(--tx-switch-language-background);box-shadow:inset 0 0 0 1px var(--tx-switch-language-ring-color)}:host([data-styled]) .tx-switch-language__thumb{top:var(--tx-switch-language-padding);bottom:var(--tx-switch-language-padding);left:var(--tx-switch-language-padding);width:calc((100% - 2 * var(--tx-switch-language-padding)) / var(--tx-switch-language-count));border-radius:var(--tx-switch-language-border-radius);background:var(--tx-switch-language-thumb-background);box-shadow:0 0 0 1px var(--tx-switch-language-thumb-ring-color),var(--tx-switch-language-thumb-shadow);transform:translate(calc(var(--tx-switch-language-index) * 100%));transition:transform var(--tx-switch-language-thumb-duration) var(--tx-switch-language-thumb-easing)}:host([data-styled]) .tx-switch-language__option{min-width:var(--tx-switch-language-option-min-width);padding:0 var(--tx-switch-language-option-padding-x);border-radius:var(--tx-switch-language-border-radius);color:var(--tx-switch-language-option-color);font-family:var(--tx-font-family);font-size:var(--tx-switch-language-option-font-size);font-weight:var(--tx-switch-language-option-font-weight);letter-spacing:var(--tx-switch-language-option-letter-spacing);line-height:1;transition:color var(--tx-switch-language-option-transition-duration)}:host([data-styled]) .tx-switch-language__option:hover{color:var(--tx-switch-language-option-hover-color)}:host([data-styled]) .tx-switch-language__option:focus-visible{outline:none;box-shadow:var(--tx-switch-language-option-focus-ring-shadow)}:host([data-styled]) .tx-switch-language__option--active{color:var(--tx-switch-language-option-active-color)}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-switch-language__thumb,:host([data-styled]) .tx-switch-language__option{transition:none}}\n"],
185
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
186
+ });
187
+ };
188
+ i0.ɵɵngDeclareClassMetadata({
189
+ minVersion: "12.0.0",
190
+ version: "22.2.3",
191
+ ngImport: i0,
192
+ type: TxSwitchLanguage,
193
+ decorators: [{
194
+ type: Component,
195
+ args: [{
196
+ selector: "tx-switch-language",
197
+ template: `
198
+ <div
199
+ #group
200
+ class="tx-switch-language__group"
201
+ role="radiogroup"
202
+ tabindex="-1"
203
+ [attr.aria-label]="name()"
204
+ [style.--tx-switch-language-count]="languages().length"
205
+ [style.--tx-switch-language-index]="activeIndex()"
206
+ [class]="passThrough().group?.class"
207
+ [style]="passThrough().group?.style"
208
+ (keydown)="onKeydown($event)"
209
+ >
210
+ <span class="tx-switch-language__thumb" aria-hidden="true" [class]="passThrough().thumb?.class" [style]="passThrough().thumb?.style"></span>
211
+ @for (language of languages(); track language.code; let index = $index) {
212
+ <button
213
+ type="button"
214
+ role="radio"
215
+ class="tx-switch-language__option"
216
+ [class.tx-switch-language__option--active]="index === activeIndex()"
217
+ [attr.aria-checked]="index === activeIndex()"
218
+ [attr.aria-label]="language.name"
219
+ [attr.tabindex]="index === activeIndex() ? 0 : -1"
220
+ [title]="language.name"
221
+ [class]="passThrough().option?.class"
222
+ [style]="passThrough().option?.style"
223
+ (click)="select(language.code)"
224
+ >
225
+ {{ language.short }}
226
+ </button>
227
+ }
228
+ </div>
229
+ `,
230
+ changeDetection: ChangeDetectionStrategy.OnPush,
231
+ host: {
232
+ class: "tx-switch-language",
233
+ "[class]": "passThrough().root?.class",
234
+ "[style]": "hostStyle()",
235
+ "[attr.data-styled]": "!isUnstyled() || null"
236
+ },
237
+ styles: [":host{display:inline-flex}.tx-switch-language__group{position:relative;display:inline-grid;grid-auto-columns:1fr;grid-auto-flow:column}.tx-switch-language__thumb{position:absolute;pointer-events:none}.tx-switch-language__option{position:relative;z-index:1;margin:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer}:host([data-styled]) .tx-switch-language__group{box-sizing:border-box;height:var(--tx-switch-language-height);padding:var(--tx-switch-language-padding);border-radius:var(--tx-switch-language-border-radius);background:var(--tx-switch-language-background);box-shadow:inset 0 0 0 1px var(--tx-switch-language-ring-color)}:host([data-styled]) .tx-switch-language__thumb{top:var(--tx-switch-language-padding);bottom:var(--tx-switch-language-padding);left:var(--tx-switch-language-padding);width:calc((100% - 2 * var(--tx-switch-language-padding)) / var(--tx-switch-language-count));border-radius:var(--tx-switch-language-border-radius);background:var(--tx-switch-language-thumb-background);box-shadow:0 0 0 1px var(--tx-switch-language-thumb-ring-color),var(--tx-switch-language-thumb-shadow);transform:translate(calc(var(--tx-switch-language-index) * 100%));transition:transform var(--tx-switch-language-thumb-duration) var(--tx-switch-language-thumb-easing)}:host([data-styled]) .tx-switch-language__option{min-width:var(--tx-switch-language-option-min-width);padding:0 var(--tx-switch-language-option-padding-x);border-radius:var(--tx-switch-language-border-radius);color:var(--tx-switch-language-option-color);font-family:var(--tx-font-family);font-size:var(--tx-switch-language-option-font-size);font-weight:var(--tx-switch-language-option-font-weight);letter-spacing:var(--tx-switch-language-option-letter-spacing);line-height:1;transition:color var(--tx-switch-language-option-transition-duration)}:host([data-styled]) .tx-switch-language__option:hover{color:var(--tx-switch-language-option-hover-color)}:host([data-styled]) .tx-switch-language__option:focus-visible{outline:none;box-shadow:var(--tx-switch-language-option-focus-ring-shadow)}:host([data-styled]) .tx-switch-language__option--active{color:var(--tx-switch-language-option-active-color)}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-switch-language__thumb,:host([data-styled]) .tx-switch-language__option{transition:none}}\n"]
238
+ }]
239
+ }],
240
+ propDecorators: {
241
+ group: [{
242
+ type: i0.ViewChild,
243
+ args: ["group", { isSignal: true }]
244
+ }],
245
+ languages: [{
246
+ type: i0.Input,
247
+ args: [{
248
+ isSignal: true,
249
+ alias: "languages",
250
+ required: false
251
+ }]
252
+ }],
253
+ value: [{
254
+ type: i0.Input,
255
+ args: [{
256
+ isSignal: true,
257
+ alias: "value",
258
+ required: false
259
+ }]
260
+ }, {
261
+ type: i0.Output,
262
+ args: ["valueChange"]
263
+ }],
264
+ syncLocale: [{
265
+ type: i0.Input,
266
+ args: [{
267
+ isSignal: true,
268
+ alias: "syncLocale",
269
+ required: false
270
+ }]
271
+ }],
272
+ ariaLabel: [{
273
+ type: i0.Input,
274
+ args: [{
275
+ isSignal: true,
276
+ alias: "ariaLabel",
277
+ required: false
278
+ }]
279
+ }],
280
+ dt: [{
281
+ type: i0.Input,
282
+ args: [{
283
+ isSignal: true,
284
+ alias: "dt",
285
+ required: false
286
+ }]
287
+ }],
288
+ pt: [{
289
+ type: i0.Input,
290
+ args: [{
291
+ isSignal: true,
292
+ alias: "pt",
293
+ required: false
294
+ }]
295
+ }],
296
+ ptOptions: [{
297
+ type: i0.Input,
298
+ args: [{
299
+ isSignal: true,
300
+ alias: "ptOptions",
301
+ required: false
302
+ }]
303
+ }],
304
+ unstyled: [{
305
+ type: i0.Input,
306
+ args: [{
307
+ isSignal: true,
308
+ alias: "unstyled",
309
+ required: false
310
+ }]
311
+ }]
312
+ }
313
+ });
314
+ export { TX_LANGUAGES, TxSwitchLanguage };
315
+
316
+ //# sourceMappingURL=tectra-ng-blocks-switch-language.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tectra-ng-blocks-switch-language.mjs","names":[],"sources":["../../../../packages/blocks/switch-language/src/switch-language.types.ts","../../../../packages/blocks/switch-language/src/switch-language.component.ts"],"sourcesContent":["import { TxLocaleCode } from '@tectra-ng/core/config';\n\nexport interface TxLanguageOption {\n code: TxLocaleCode;\n name: string;\n short: string;\n}\n\nexport type TxSwitchLanguagePart = 'root' | 'group' | 'thumb' | 'option';\n\nexport const TX_LANGUAGES: readonly TxLanguageOption[] = [\n { code: 'us', name: 'English', short: 'EN' },\n { code: 'ua', name: 'Українська', short: 'UA' },\n];\n","import { ChangeDetectionStrategy, Component, ElementRef, booleanAttribute, computed, inject, input, model, viewChild } from '@angular/core';\nimport { TxPassThrough, TxPassThroughOptions, injectPassThrough, injectUnstyled } from '@tectra-ng/core/config';\nimport { TxLocaleService, injectTranslations } from '@tectra-ng/core/i18n';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraDeepPartial, TectraSwitchLanguageTokens, toStyleObject } from '@tectra-ng/themes';\nimport { TX_LANGUAGES, TxLanguageOption, TxSwitchLanguagePart } from './switch-language.types';\n\nconst NEXT_KEYS = new Set(['ArrowRight', 'ArrowDown']);\nconst PREVIOUS_KEYS = new Set(['ArrowLeft', 'ArrowUp']);\n\n@Component({\n selector: 'tx-switch-language',\n template: `\n <div\n #group\n class=\"tx-switch-language__group\"\n role=\"radiogroup\"\n tabindex=\"-1\"\n [attr.aria-label]=\"name()\"\n [style.--tx-switch-language-count]=\"languages().length\"\n [style.--tx-switch-language-index]=\"activeIndex()\"\n [class]=\"passThrough().group?.class\"\n [style]=\"passThrough().group?.style\"\n (keydown)=\"onKeydown($event)\"\n >\n <span class=\"tx-switch-language__thumb\" aria-hidden=\"true\" [class]=\"passThrough().thumb?.class\" [style]=\"passThrough().thumb?.style\"></span>\n @for (language of languages(); track language.code; let index = $index) {\n <button\n type=\"button\"\n role=\"radio\"\n class=\"tx-switch-language__option\"\n [class.tx-switch-language__option--active]=\"index === activeIndex()\"\n [attr.aria-checked]=\"index === activeIndex()\"\n [attr.aria-label]=\"language.name\"\n [attr.tabindex]=\"index === activeIndex() ? 0 : -1\"\n [title]=\"language.name\"\n [class]=\"passThrough().option?.class\"\n [style]=\"passThrough().option?.style\"\n (click)=\"select(language.code)\"\n >\n {{ language.short }}\n </button>\n }\n </div>\n `,\n styleUrl: './switch-language.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-switch-language',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n },\n})\nexport class TxSwitchLanguage {\n private readonly locale = inject(TxLocaleService);\n private readonly group = viewChild.required<ElementRef<HTMLElement>>('group');\n\n readonly languages = input<readonly TxLanguageOption[]>(TX_LANGUAGES);\n readonly value = model<string | undefined>(undefined);\n readonly syncLocale = input<boolean, unknown>(true, { transform: booleanAttribute });\n readonly ariaLabel = input<string | undefined>(undefined);\n readonly dt = input<TectraDeepPartial<TectraSwitchLanguageTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxSwitchLanguagePart, TxSwitchLanguage> | undefined>(undefined);\n readonly ptOptions = input<TxPassThroughOptions | undefined>(undefined);\n readonly unstyled = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n\n readonly isUnstyled = injectUnstyled(this.unstyled);\n readonly passThrough = injectPassThrough('switchLanguage', this, this.pt, this.ptOptions);\n protected readonly translations = injectTranslations();\n readonly hostStyle = computed(() => ({ ...toStyleObject(this.dt(), '--tx-switch-language'), ...this.passThrough().root?.style }));\n protected readonly name = computed(() => this.ariaLabel() ?? this.translations().language);\n readonly current = computed(() => this.value() ?? this.locale.locale().code);\n protected readonly activeIndex = computed(() => Math.max(this.languages().findIndex((language) => language.code === this.current()), 0));\n\n select(code: string): void {\n this.value.set(code);\n if (this.syncLocale()) {\n this.locale.setLocale(code);\n }\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n const languages = this.languages();\n const count = languages.length;\n let index: number;\n if (NEXT_KEYS.has(event.key)) {\n index = (this.activeIndex() + 1) % count;\n } else if (PREVIOUS_KEYS.has(event.key)) {\n index = (this.activeIndex() - 1 + count) % count;\n } else if (event.key === 'Home' || event.key === 'End') {\n index = event.key === 'Home' ? 0 : count - 1;\n } else {\n return;\n }\n event.preventDefault();\n this.select(languages[index].code);\n this.group().nativeElement.querySelectorAll<HTMLElement>('[role=\"radio\"]')[index]?.focus();\n }\n}\n"],"mappings":";;;;;;AAUA,MAAa,eAA4C,CACvD;CAAE,MAAM;CAAM,MAAM;CAAW,OAAO;AAAI,GAC1C;CAAE,MAAM;CAAM,MAAM;CAAc,OAAO;AAAI,CAC9C;ACND,MAAM,4BAAY,IAAI,IAAI,CAAC,cAAc,WAAW,CAAC;AACrD,MAAM,gCAAgB,IAAI,IAAI,CAAC,aAAa,SAAS,CAAC;AA8CtD,IAAa,mBAAb,MAAa,iBAAgB;CACV,SAAS,OAAO,eAAe;CAC/B,QAAQ,UAAU,SAAkC,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAEpE,YAAY,MAAmC,cAAa,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAC5D,QAAQ,MAA0B,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAC5C,aAAa,MAAwB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