nativescript-web-adapter 0.1.3 → 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 (75) hide show
  1. package/README.md +39 -17
  2. package/angular/components/absolute-layout.component.ts +18 -0
  3. package/angular/components/action-bar.component.ts +16 -0
  4. package/angular/components/action-item.component.ts +22 -0
  5. package/angular/components/activity-indicator.component.ts +32 -0
  6. package/angular/components/button.component.ts +45 -0
  7. package/angular/components/date-picker.component.ts +35 -0
  8. package/angular/components/directives/absolute-position.directive.ts +31 -0
  9. package/angular/components/directives/grid-position.directive.ts +43 -0
  10. package/angular/components/dock-layout.component.ts +46 -0
  11. package/angular/components/flexbox-layout.component.ts +16 -0
  12. package/angular/components/frame.component.ts +9 -0
  13. package/angular/components/grid-layout.component.ts +48 -0
  14. package/angular/components/html-view.component.ts +23 -0
  15. package/angular/components/image-cache-it.component.ts +21 -0
  16. package/angular/components/image.component.ts +22 -0
  17. package/angular/components/index.ts +156 -0
  18. package/angular/components/label.component.ts +27 -0
  19. package/angular/components/list-picker.component.ts +33 -0
  20. package/angular/components/list-view.component.ts +22 -0
  21. package/angular/components/navigation-button.component.ts +36 -0
  22. package/angular/components/page.component.ts +21 -0
  23. package/angular/components/placeholder.component.ts +16 -0
  24. package/angular/components/progress.component.ts +20 -0
  25. package/angular/components/root-layout.component.ts +19 -0
  26. package/angular/components/scroll-view.component.ts +17 -0
  27. package/angular/components/search-bar.component.ts +34 -0
  28. package/angular/components/segmented-bar-item.component.ts +27 -0
  29. package/angular/components/segmented-bar.component.ts +101 -0
  30. package/angular/components/slider.component.ts +41 -0
  31. package/angular/components/stack-layout.component.ts +17 -0
  32. package/angular/components/switch.component.ts +62 -0
  33. package/angular/components/tab-view-item.component.ts +27 -0
  34. package/angular/components/tab-view.component.ts +89 -0
  35. package/angular/components/text-field.component.ts +38 -0
  36. package/angular/components/text-view.component.ts +29 -0
  37. package/angular/components/time-picker.component.ts +27 -0
  38. package/angular/components/web-view.component.ts +25 -0
  39. package/angular/components/wrap-layout.component.ts +17 -0
  40. package/angular/composables/dialogs.ts +54 -0
  41. package/angular/composables/index.ts +6 -0
  42. package/angular/composables/ref.ts +8 -0
  43. package/angular/composables/useActionBar.ts +20 -0
  44. package/angular/composables/useFrame.ts +26 -0
  45. package/angular/composables/usePage.ts +26 -0
  46. package/angular/index.ts +8 -0
  47. package/core/components/ActionBar.vue +1 -1
  48. package/core/components/Button.vue +2 -2
  49. package/core/components/GridLayout.vue +2 -2
  50. package/core/components/HtmlView.vue +2 -2
  51. package/core/components/Image.vue +2 -2
  52. package/core/components/ImageCacheIt.vue +2 -2
  53. package/core/components/Label.vue +2 -2
  54. package/core/components/ListPicker.vue +2 -2
  55. package/core/components/NavigationButton.vue +2 -2
  56. package/core/components/Progress.vue +2 -2
  57. package/core/components/SearchBar.vue +2 -2
  58. package/core/components/Slider.vue +2 -2
  59. package/core/components/Switch.vue +2 -2
  60. package/core/components/TextField.vue +2 -2
  61. package/core/components/TextView.vue +2 -2
  62. package/core/components/WebView.vue +2 -2
  63. package/core/composables/dialogs.ts +5 -5
  64. package/dist/nativescript-web-adapter.es.js +22375 -45
  65. package/dist/nativescript-web-adapter.umd.js +534 -1
  66. package/dist/style.css +1 -1
  67. package/package.json +37 -7
  68. package/tools/cli.cjs +34 -7
  69. package/tools/create-nuxt-platform.cjs +57 -0
  70. package/tools/create-web-platform.cjs +38 -16
  71. package/tools/modules/appPatch.cjs +125 -1
  72. package/tools/modules/templates-nuxt.cjs +63 -0
  73. package/tools/modules/templates.cjs +161 -84
  74. package/tools/modules/transform-nuxt.cjs +59 -0
  75. package/tools/modules/transform.cjs +69 -2
@@ -0,0 +1,156 @@
1
+ import { AbsoluteLayoutComponent } from './absolute-layout.component';
2
+ import { ActionBarComponent } from './action-bar.component';
3
+ import { ActionItemComponent } from './action-item.component';
4
+ import { ActivityIndicatorComponent } from './activity-indicator.component';
5
+ import { ButtonComponent } from './button.component';
6
+ import { DatePickerComponent } from './date-picker.component';
7
+ import { DockLayoutComponent } from './dock-layout.component';
8
+ import { FlexboxLayoutComponent } from './flexbox-layout.component';
9
+ import { FrameComponent } from './frame.component';
10
+ import { GridLayoutComponent } from './grid-layout.component';
11
+ import { HtmlViewComponent } from './html-view.component';
12
+ import { ImageComponent } from './image.component';
13
+ import { ImageCacheItComponent } from './image-cache-it.component';
14
+ import { LabelComponent } from './label.component';
15
+ import { ListPickerComponent } from './list-picker.component';
16
+ import { ListViewComponent } from './list-view.component';
17
+ import { NavigationButtonComponent } from './navigation-button.component';
18
+ import { PageComponent } from './page.component';
19
+ import { PlaceholderComponent } from './placeholder.component';
20
+ import { ProgressComponent } from './progress.component';
21
+ import { RootLayoutComponent } from './root-layout.component';
22
+ import { ScrollViewComponent } from './scroll-view.component';
23
+ import { SearchBarComponent } from './search-bar.component';
24
+ import { SegmentedBarComponent } from './segmented-bar.component';
25
+ import { SegmentedBarItemComponent } from './segmented-bar-item.component';
26
+ import { SliderComponent } from './slider.component';
27
+ import { StackLayoutComponent } from './stack-layout.component';
28
+ import { SwitchComponent } from './switch.component';
29
+ import { TabViewComponent } from './tab-view.component';
30
+ import { TabViewItemComponent } from './tab-view-item.component';
31
+ import { TextFieldComponent } from './text-field.component';
32
+ import { TextViewComponent } from './text-view.component';
33
+ import { TimePickerComponent } from './time-picker.component';
34
+ import { WebViewComponent } from './web-view.component';
35
+ import { WrapLayoutComponent } from './wrap-layout.component';
36
+ import { NsAbsolutePositionDirective } from './directives/absolute-position.directive';
37
+ import { NsGridPositionDirective } from './directives/grid-position.directive';
38
+
39
+ export const components = {
40
+ AbsoluteLayout: AbsoluteLayoutComponent,
41
+ ActionBar: ActionBarComponent,
42
+ ActionItem: ActionItemComponent,
43
+ ActivityIndicator: ActivityIndicatorComponent,
44
+ Button: ButtonComponent,
45
+ DatePicker: DatePickerComponent,
46
+ DockLayout: DockLayoutComponent,
47
+ FlexboxLayout: FlexboxLayoutComponent,
48
+ Frame: FrameComponent,
49
+ GridLayout: GridLayoutComponent,
50
+ HtmlView: HtmlViewComponent,
51
+ Image: ImageComponent,
52
+ ImageCacheIt: ImageCacheItComponent,
53
+ Label: LabelComponent,
54
+ ListPicker: ListPickerComponent,
55
+ ListView: ListViewComponent,
56
+ NavigationButton: NavigationButtonComponent,
57
+ Page: PageComponent,
58
+ Placeholder: PlaceholderComponent,
59
+ Progress: ProgressComponent,
60
+ RootLayout: RootLayoutComponent,
61
+ ScrollView: ScrollViewComponent,
62
+ SearchBar: SearchBarComponent,
63
+ SegmentedBar: SegmentedBarComponent,
64
+ SegmentedBarItem: SegmentedBarItemComponent,
65
+ Slider: SliderComponent,
66
+ StackLayout: StackLayoutComponent,
67
+ Switch: SwitchComponent,
68
+ TabView: TabViewComponent,
69
+ TabViewItem: TabViewItemComponent,
70
+ TextField: TextFieldComponent,
71
+ TextView: TextViewComponent,
72
+ TimePicker: TimePickerComponent,
73
+ WebView: WebViewComponent,
74
+ WrapLayout: WrapLayoutComponent,
75
+ };
76
+
77
+ export const imports = [
78
+ AbsoluteLayoutComponent,
79
+ ActionBarComponent,
80
+ ActionItemComponent,
81
+ ActivityIndicatorComponent,
82
+ ButtonComponent,
83
+ DatePickerComponent,
84
+ DockLayoutComponent,
85
+ FlexboxLayoutComponent,
86
+ FrameComponent,
87
+ GridLayoutComponent,
88
+ HtmlViewComponent,
89
+ ImageComponent,
90
+ ImageCacheItComponent,
91
+ LabelComponent,
92
+ ListPickerComponent,
93
+ ListViewComponent,
94
+ NavigationButtonComponent,
95
+ PageComponent,
96
+ PlaceholderComponent,
97
+ ProgressComponent,
98
+ RootLayoutComponent,
99
+ ScrollViewComponent,
100
+ SearchBarComponent,
101
+ SegmentedBarComponent,
102
+ SegmentedBarItemComponent,
103
+ SliderComponent,
104
+ StackLayoutComponent,
105
+ SwitchComponent,
106
+ TabViewComponent,
107
+ TabViewItemComponent,
108
+ TextFieldComponent,
109
+ TextViewComponent,
110
+ TimePickerComponent,
111
+ WebViewComponent,
112
+ WrapLayoutComponent,
113
+ NsAbsolutePositionDirective,
114
+ NsGridPositionDirective,
115
+ ] as const;
116
+
117
+ export {
118
+ AbsoluteLayoutComponent,
119
+ ActionBarComponent,
120
+ ActionItemComponent,
121
+ ActivityIndicatorComponent,
122
+ ButtonComponent,
123
+ DatePickerComponent,
124
+ DockLayoutComponent,
125
+ FlexboxLayoutComponent,
126
+ FrameComponent,
127
+ GridLayoutComponent,
128
+ HtmlViewComponent,
129
+ ImageComponent,
130
+ ImageCacheItComponent,
131
+ LabelComponent,
132
+ ListPickerComponent,
133
+ ListViewComponent,
134
+ NavigationButtonComponent,
135
+ PageComponent,
136
+ PlaceholderComponent,
137
+ ProgressComponent,
138
+ RootLayoutComponent,
139
+ ScrollViewComponent,
140
+ SearchBarComponent,
141
+ SegmentedBarComponent,
142
+ SegmentedBarItemComponent,
143
+ SliderComponent,
144
+ StackLayoutComponent,
145
+ SwitchComponent,
146
+ TabViewComponent,
147
+ TabViewItemComponent,
148
+ TextFieldComponent,
149
+ TextViewComponent,
150
+ TimePickerComponent,
151
+ WebViewComponent,
152
+ WrapLayoutComponent,
153
+ NsAbsolutePositionDirective,
154
+ NsGridPositionDirective,
155
+ };
156
+
@@ -0,0 +1,27 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
3
+
4
+ @Component({
5
+ selector: 'Label, label',
6
+ standalone: true,
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ imports: [CommonModule],
9
+ template: `
10
+ <span class="ns-label">
11
+ <ng-container *ngIf="text === undefined || text === null || text === ''; else textTpl">
12
+ <ng-content></ng-content>
13
+ </ng-container>
14
+ <ng-template #textTpl>{{ text }}</ng-template>
15
+ </span>
16
+ `,
17
+ styles: [
18
+ `
19
+ .ns-label {
20
+ display: inline-block;
21
+ }
22
+ `,
23
+ ],
24
+ })
25
+ export class LabelComponent {
26
+ @Input() text?: string;
27
+ }
@@ -0,0 +1,33 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
3
+
4
+ @Component({
5
+ selector: 'ListPicker, listpicker',
6
+ standalone: true,
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ imports: [CommonModule],
9
+ template: `
10
+ <select class="ns-listpicker" [value]="selectedIndex ?? 0" (change)="onChange($event)">
11
+ <option *ngFor="let item of items; let i = index" [value]="i">{{ item }}</option>
12
+ </select>
13
+ `,
14
+ styles: [
15
+ `
16
+ .ns-listpicker {
17
+ padding: 6px 8px;
18
+ }
19
+ `,
20
+ ],
21
+ })
22
+ export class ListPickerComponent {
23
+ @Input({ required: true }) items: string[] = [];
24
+ @Input() selectedIndex?: number;
25
+ @Output() selectedIndexChange = new EventEmitter<number>();
26
+ @Output() change = new EventEmitter<number>();
27
+
28
+ onChange(e: Event) {
29
+ const v = Number((e.target as HTMLSelectElement).value);
30
+ this.selectedIndexChange.emit(v);
31
+ this.change.emit(v);
32
+ }
33
+ }
@@ -0,0 +1,22 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'ListView, listview',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<ul class="ns-listview"><ng-content></ng-content></ul>`,
8
+ styles: [
9
+ `
10
+ .ns-listview {
11
+ list-style: none;
12
+ margin: 0;
13
+ padding: 0;
14
+ }
15
+ .ns-listview > li {
16
+ padding: 8px 12px;
17
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
18
+ }
19
+ `,
20
+ ],
21
+ })
22
+ export class ListViewComponent {}
@@ -0,0 +1,36 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
3
+
4
+ @Component({
5
+ selector: 'NavigationButton, navigationbutton',
6
+ standalone: true,
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ imports: [CommonModule],
9
+ template: `
10
+ <button class="ns-navbutton" (click)="onClick($event)">
11
+ <ng-content></ng-content>
12
+ <ng-container *ngIf="text">{{ text }}</ng-container>
13
+ </button>
14
+ `,
15
+ styles: [
16
+ `
17
+ .ns-navbutton {
18
+ background: transparent;
19
+ border: none;
20
+ color: inherit;
21
+ cursor: pointer;
22
+ padding: 8px;
23
+ }
24
+ `,
25
+ ],
26
+ })
27
+ export class NavigationButtonComponent {
28
+ @Input() text?: string;
29
+ @Output() tap = new EventEmitter<MouseEvent>();
30
+
31
+ onClick(e: MouseEvent) {
32
+ this.tap.emit(e);
33
+ if ((this.tap as any).observers?.length) return;
34
+ if (window?.history?.back) window.history.back();
35
+ }
36
+ }
@@ -0,0 +1,21 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'Page, page',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<div class="ns-page"><ng-content></ng-content></div>`,
8
+ styles: [
9
+ `
10
+ .ns-page {
11
+ top: 0;
12
+ left: 0;
13
+ position: absolute;
14
+ width: 100%;
15
+ min-height: 100%;
16
+ padding: 0px;
17
+ }
18
+ `,
19
+ ],
20
+ })
21
+ export class PageComponent {}
@@ -0,0 +1,16 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'Placeholder, placeholder',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<div class="ns-placeholder"><ng-content></ng-content></div>`,
8
+ styles: [
9
+ `
10
+ .ns-placeholder {
11
+ display: contents;
12
+ }
13
+ `,
14
+ ],
15
+ })
16
+ export class PlaceholderComponent {}
@@ -0,0 +1,20 @@
1
+ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'Progress, progress[nsProgress], ns-progress',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<progress class="ns-progress" [value]="value ?? null" [max]="max ?? null"></progress>`,
8
+ styles: [
9
+ `
10
+ .ns-progress {
11
+ width: 100%;
12
+ }
13
+ `,
14
+ ],
15
+ })
16
+ export class ProgressComponent {
17
+ @Input() value?: number;
18
+ @Input() max?: number;
19
+ }
20
+
@@ -0,0 +1,19 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'RootLayout, rootlayout',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<div class="ns-root"><ng-content></ng-content></div>`,
8
+ styles: [
9
+ `
10
+ .ns-root {
11
+ position: relative;
12
+ width: 100%;
13
+ height: 100%;
14
+ display: block;
15
+ }
16
+ `,
17
+ ],
18
+ })
19
+ export class RootLayoutComponent {}
@@ -0,0 +1,17 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'ScrollView, scrollview',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<div class="ns-scroll"><ng-content></ng-content></div>`,
8
+ styles: [
9
+ `
10
+ .ns-scroll {
11
+ overflow: auto;
12
+ max-height: 100%;
13
+ }
14
+ `,
15
+ ],
16
+ })
17
+ export class ScrollViewComponent {}
@@ -0,0 +1,34 @@
1
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'SearchBar, searchbar',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `
8
+ <div class="ns-searchbar">
9
+ <input type="search" [value]="text ?? ''" (input)="onInput($event)" (keyup.enter)="onSubmit($event)" />
10
+ </div>
11
+ `,
12
+ styles: [
13
+ `
14
+ .ns-searchbar input {
15
+ width: 100%;
16
+ padding: 6px 8px;
17
+ }
18
+ `,
19
+ ],
20
+ })
21
+ export class SearchBarComponent {
22
+ @Input() text?: string;
23
+ @Output() textChange = new EventEmitter<string>();
24
+ @Output() submit = new EventEmitter<string>();
25
+
26
+ onInput(e: Event) {
27
+ this.textChange.emit((e.target as HTMLInputElement).value);
28
+ }
29
+
30
+ onSubmit(e: KeyboardEvent) {
31
+ this.submit.emit((e.target as HTMLInputElement).value);
32
+ }
33
+ }
34
+
@@ -0,0 +1,27 @@
1
+ import { ChangeDetectionStrategy, Component, HostBinding, Input, Optional } from '@angular/core';
2
+ import { SegmentedBarComponent } from './segmented-bar.component';
3
+
4
+ @Component({
5
+ selector: 'SegmentedBarItem, segmentedbaritem',
6
+ standalone: true,
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ template: `<div class="ns-segmentedbar-item"><ng-content></ng-content></div>`,
9
+ styles: [
10
+ `
11
+ .ns-segmentedbar-item {
12
+ display: block;
13
+ }
14
+ `,
15
+ ],
16
+ })
17
+ export class SegmentedBarItemComponent {
18
+ @Input({ required: true }) title!: string;
19
+
20
+ constructor(@Optional() private readonly parent?: SegmentedBarComponent) {}
21
+
22
+ @HostBinding('style.display')
23
+ get display(): string {
24
+ if (!this.parent) return 'block';
25
+ return this.parent.isActive(this) ? 'block' : 'none';
26
+ }
27
+ }
@@ -0,0 +1,101 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import {
3
+ AfterContentInit,
4
+ ChangeDetectionStrategy,
5
+ Component,
6
+ ContentChildren,
7
+ EventEmitter,
8
+ Input,
9
+ Output,
10
+ QueryList,
11
+ } from '@angular/core';
12
+ import { SegmentedBarItemComponent } from './segmented-bar-item.component';
13
+
14
+ @Component({
15
+ selector: 'SegmentedBar, segmentedbar',
16
+ standalone: true,
17
+ changeDetection: ChangeDetectionStrategy.OnPush,
18
+ imports: [CommonModule],
19
+ template: `
20
+ <div class="ns-segmentedbar">
21
+ <div class="ns-segmentedbar-header">
22
+ <button
23
+ *ngFor="let t of displayItems; let i = index"
24
+ class="ns-segment"
25
+ [class.active]="i === currentIndex"
26
+ (click)="select(i)"
27
+ >
28
+ {{ t }}
29
+ </button>
30
+ </div>
31
+ <div class="ns-segmentedbar-body"><ng-content></ng-content></div>
32
+ </div>
33
+ `,
34
+ styles: [
35
+ `
36
+ .ns-segmentedbar {
37
+ display: block;
38
+ color: inherit;
39
+ }
40
+ .ns-segmentedbar-header {
41
+ display: flex;
42
+ gap: 8px;
43
+ border-bottom: 1px solid rgba(255, 255, 255, 0.3);
44
+ padding-bottom: 8px;
45
+ }
46
+ .ns-segment {
47
+ background: transparent;
48
+ border: none;
49
+ color: #fff;
50
+ padding: 8px 12px;
51
+ cursor: pointer;
52
+ opacity: 0.95;
53
+ }
54
+ .ns-segment.active {
55
+ opacity: 1;
56
+ border-bottom: 2px solid currentColor;
57
+ }
58
+ .ns-segmentedbar-body {
59
+ padding-top: 12px;
60
+ }
61
+ `,
62
+ ],
63
+ })
64
+ export class SegmentedBarComponent implements AfterContentInit {
65
+ @Input() items?: string[];
66
+ @Input() selectedIndex?: number;
67
+ @Output() selectedIndexChange = new EventEmitter<number>();
68
+ @Output() change = new EventEmitter<number>();
69
+
70
+ @ContentChildren(SegmentedBarItemComponent) private readonly contentItems?: QueryList<SegmentedBarItemComponent>;
71
+
72
+ currentIndex = 0;
73
+ displayItems: string[] = [];
74
+
75
+ ngAfterContentInit(): void {
76
+ this.currentIndex = typeof this.selectedIndex === 'number' ? this.selectedIndex : 0;
77
+ this.refreshItems();
78
+ this.contentItems?.changes.subscribe(() => this.refreshItems());
79
+ }
80
+
81
+ select(i: number) {
82
+ this.currentIndex = i;
83
+ this.selectedIndexChange.emit(i);
84
+ this.change.emit(i);
85
+ }
86
+
87
+ isActive(item: SegmentedBarItemComponent): boolean {
88
+ const list = this.contentItems?.toArray() ?? [];
89
+ const idx = list.indexOf(item);
90
+ if (idx < 0) return true;
91
+ return idx === this.currentIndex;
92
+ }
93
+
94
+ private refreshItems() {
95
+ if (this.items && this.items.length) {
96
+ this.displayItems = this.items;
97
+ return;
98
+ }
99
+ this.displayItems = (this.contentItems?.toArray() ?? []).map((it: SegmentedBarItemComponent) => it.title);
100
+ }
101
+ }
@@ -0,0 +1,41 @@
1
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'Slider, slider',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `
8
+ <input
9
+ class="ns-slider"
10
+ type="range"
11
+ [min]="min ?? 0"
12
+ [max]="max ?? 100"
13
+ [step]="step ?? 1"
14
+ [value]="value ?? 0"
15
+ (input)="onInput($event)"
16
+ />
17
+ `,
18
+ styles: [
19
+ `
20
+ .ns-slider {
21
+ width: 100%;
22
+ }
23
+ `,
24
+ ],
25
+ })
26
+ export class SliderComponent {
27
+ @Input() value?: number;
28
+ @Input() min?: number;
29
+ @Input() max?: number;
30
+ @Input() step?: number;
31
+
32
+ @Output() valueChange = new EventEmitter<number>();
33
+ @Output() change = new EventEmitter<number>();
34
+
35
+ onInput(e: Event) {
36
+ const v = Number((e.target as HTMLInputElement).value);
37
+ this.valueChange.emit(v);
38
+ this.change.emit(v);
39
+ }
40
+ }
41
+
@@ -0,0 +1,17 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'StackLayout, stacklayout',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `<div class="ns-stack"><ng-content></ng-content></div>`,
8
+ styles: [
9
+ `
10
+ .ns-stack {
11
+ display: flex;
12
+ flex-direction: column;
13
+ }
14
+ `,
15
+ ],
16
+ })
17
+ export class StackLayoutComponent {}
@@ -0,0 +1,62 @@
1
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'Switch, switch',
5
+ standalone: true,
6
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
+ template: `
8
+ <label class="ns-switch">
9
+ <input type="checkbox" [checked]="checked ?? false" (change)="onChange($event)" />
10
+ <span class="track"><span class="thumb"></span></span>
11
+ </label>
12
+ `,
13
+ styles: [
14
+ `
15
+ .ns-switch {
16
+ display: inline-flex;
17
+ align-items: center;
18
+ cursor: pointer;
19
+ }
20
+ .ns-switch input {
21
+ display: none;
22
+ }
23
+ .ns-switch .track {
24
+ width: 40px;
25
+ height: 22px;
26
+ background: rgba(255, 255, 255, 0.3);
27
+ border-radius: 11px;
28
+ position: relative;
29
+ transition: background 0.2s;
30
+ }
31
+ .ns-switch .thumb {
32
+ width: 18px;
33
+ height: 18px;
34
+ background: rgb(0, 255, 174);
35
+ border-radius: 50%;
36
+ position: absolute;
37
+ top: 2px;
38
+ left: 2px;
39
+ transition: left 0.2s;
40
+ }
41
+ .ns-switch input:checked + .track {
42
+ background: currentColor;
43
+ opacity: 0.5;
44
+ }
45
+ .ns-switch input:checked + .track .thumb {
46
+ left: 20px;
47
+ }
48
+ `,
49
+ ],
50
+ })
51
+ export class SwitchComponent {
52
+ @Input() checked?: boolean;
53
+ @Output() checkedChange = new EventEmitter<boolean>();
54
+ @Output() change = new EventEmitter<boolean>();
55
+
56
+ onChange(e: Event) {
57
+ const v = (e.target as HTMLInputElement).checked;
58
+ this.checkedChange.emit(v);
59
+ this.change.emit(v);
60
+ }
61
+ }
62
+
@@ -0,0 +1,27 @@
1
+ import { ChangeDetectionStrategy, Component, HostBinding, Input, Optional } from '@angular/core';
2
+ import { TabViewComponent } from './tab-view.component';
3
+
4
+ @Component({
5
+ selector: 'TabViewItem, tabviewitem',
6
+ standalone: true,
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ template: `<div class="ns-tabview-item"><ng-content></ng-content></div>`,
9
+ styles: [
10
+ `
11
+ .ns-tabview-item {
12
+ display: block;
13
+ }
14
+ `,
15
+ ],
16
+ })
17
+ export class TabViewItemComponent {
18
+ @Input({ required: true }) title!: string;
19
+
20
+ constructor(@Optional() private readonly parent?: TabViewComponent) {}
21
+
22
+ @HostBinding('style.display')
23
+ get display(): string {
24
+ if (!this.parent) return 'block';
25
+ return this.parent.isActive(this) ? 'block' : 'none';
26
+ }
27
+ }