@kraft.stitch/angular 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +41 -0
- package/README.md +97 -2
- package/ng-package.json +10 -0
- package/package.json +28 -17
- package/src/lib/Buttons/button/button.ts +152 -0
- package/src/lib/Buttons/button-group/button-group.ts +129 -0
- package/src/lib/Buttons/chips/chips.ts +131 -0
- package/src/lib/Buttons/fab/fab.ts +96 -0
- package/src/lib/Buttons/split-button/split-button.ts +111 -0
- package/src/lib/Calendars/datepicker/datepicker.ts +105 -0
- package/src/lib/Calendars/daterange/daterange.ts +112 -0
- package/src/lib/Calendars/timepicker/timepicker.ts +117 -0
- package/src/lib/Dropdowns/dropdown/dropdown.ts +121 -0
- package/src/lib/Dropdowns/listbox/listbox.ts +116 -0
- package/src/lib/Inputs/checkbox/checkbox.ts +126 -0
- package/src/lib/Inputs/colour-picker/colour-picker.ts +101 -0
- package/src/lib/Inputs/input/input.ts +139 -0
- package/src/lib/Inputs/otp-input/otp-input.ts +113 -0
- package/src/lib/Inputs/radio/radio.ts +115 -0
- package/src/lib/Inputs/rating/rating.ts +104 -0
- package/src/lib/Inputs/rolling-number/rolling-number.ts +136 -0
- package/src/lib/Inputs/slider/slider.ts +121 -0
- package/src/lib/Inputs/switch/switch.ts +100 -0
- package/src/lib/Inputs/textarea/textarea.ts +129 -0
- package/src/lib/Inputs/theme-switch/theme-switch.ts +61 -0
- package/src/lib/Inputs/uploader/uploader.ts +97 -0
- package/src/lib/Layout/avatar/avatar.ts +66 -0
- package/src/lib/Layout/card/card.ts +88 -0
- package/src/lib/Layout/code-view/code-view.ts +77 -0
- package/src/lib/Layout/dialog/dialog.ts +80 -0
- package/src/lib/Layout/not-found/not-found.ts +73 -0
- package/src/lib/Layout/sidebar/sidebar.ts +97 -0
- package/src/lib/Layout/table/table.ts +81 -0
- package/src/lib/Layout/tooltip/tooltip.ts +48 -0
- package/src/lib/Navigation/accordion/accordion.ts +80 -0
- package/src/lib/Navigation/breadcrumb/breadcrumb.ts +58 -0
- package/src/lib/Navigation/carousel/carousel.ts +70 -0
- package/src/lib/Navigation/context-menu/context-menu.ts +79 -0
- package/src/lib/Navigation/nav-bar/nav-bar.ts +72 -0
- package/src/lib/Navigation/pagination/pagination.ts +82 -0
- package/src/lib/Navigation/stepper/stepper.ts +77 -0
- package/src/lib/Navigation/tab/tab.ts +71 -0
- package/src/lib/Navigation/toolbar/toolbar.ts +60 -0
- package/src/lib/Navigation/top-nav-bar/top-nav-bar.ts +71 -0
- package/src/lib/Navigation/tree-view/tree-view.ts +75 -0
- package/src/lib/Notification/badge/badge.ts +55 -0
- package/src/lib/Notification/loader/loader.ts +41 -0
- package/src/lib/Notification/message/message.ts +60 -0
- package/src/lib/Notification/progress/progress.ts +65 -0
- package/src/lib/Notification/spinner/spinner.ts +50 -0
- package/src/lib/Notification/toast/toast.ts +56 -0
- package/src/public-api.ts +68 -0
- package/src/utils/theme-service.ts +11 -0
- package/tsconfig.json +23 -0
- package/fesm2022/kraft.stitch-angular.mjs +0 -2873
- package/fesm2022/kraft.stitch-angular.mjs.map +0 -1
- package/types/kraft.stitch-angular.d.ts +0 -2247
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-sidebar` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-sidebar.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, effect, inject, input, model, output } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
export type KsSidebarPosition = 'left' | 'right';
|
|
8
|
+
export type KsSidebarType = 'over' | 'push';
|
|
9
|
+
|
|
10
|
+
/** DOM shape of the real `<ks-sidebar>` custom element, typed for the wrapper. */
|
|
11
|
+
type KsSidebarElement = HTMLElement & {
|
|
12
|
+
position: KsSidebarPosition;
|
|
13
|
+
type: KsSidebarType;
|
|
14
|
+
open: boolean;
|
|
15
|
+
width: string;
|
|
16
|
+
target: string;
|
|
17
|
+
openPanel(): Promise<void>;
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
toggle(): Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Angular wrapper around the `<ks-sidebar>` Stencil custom element.
|
|
24
|
+
*
|
|
25
|
+
* `open` is a plain input/output pair, not `ControlValueAccessor` — panel
|
|
26
|
+
* open state isn't form data. The native event is literally `openChange`,
|
|
27
|
+
* so (per the double-fire rule in `Buttons/button.ts`) the Angular output
|
|
28
|
+
* can't reuse that name; bind explicitly instead:
|
|
29
|
+
* `[open]="isOpen" (ksOpenChange)="isOpen = $event"`.
|
|
30
|
+
*
|
|
31
|
+
* `<ks-sidebar>`'s own `@Method()`s (`openPanel`/`close`/`toggle`) are
|
|
32
|
+
* exposed here as real passthrough methods — grab the component instance
|
|
33
|
+
* with `@ViewChild(KsSidebarComponent)` and call them directly.
|
|
34
|
+
*
|
|
35
|
+
* ## Slots
|
|
36
|
+
* Renders real `<slot name="header" />`, `<slot />` (default) and
|
|
37
|
+
* `<slot name="footer" />`. Same single unfiltered `<ng-content>`
|
|
38
|
+
* pass-through as `Layout/card/card.ts`.
|
|
39
|
+
*/
|
|
40
|
+
@Component({
|
|
41
|
+
selector: 'ks-sidebar',
|
|
42
|
+
standalone: true,
|
|
43
|
+
template: '<ng-content></ng-content>',
|
|
44
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
45
|
+
})
|
|
46
|
+
export class KsSidebarComponent {
|
|
47
|
+
private readonly el: KsSidebarElement;
|
|
48
|
+
|
|
49
|
+
/** Which side the panel appears on */
|
|
50
|
+
readonly position = input<KsSidebarPosition>('left');
|
|
51
|
+
|
|
52
|
+
/** Behaviour type */
|
|
53
|
+
readonly type = input<KsSidebarType>('over');
|
|
54
|
+
|
|
55
|
+
/** Initial/controlled open state. Bind explicitly: `[open]="isOpen" (ksOpenChange)="isOpen = $event"`. */
|
|
56
|
+
readonly open = model(false);
|
|
57
|
+
|
|
58
|
+
/** Width of the sidebar panel */
|
|
59
|
+
readonly width = input('18rem');
|
|
60
|
+
|
|
61
|
+
/** Target element id (without #) or '' to use the page. */
|
|
62
|
+
readonly target = input('');
|
|
63
|
+
|
|
64
|
+
/** Fires whenever `open` changes. From the native `openChange` event. */
|
|
65
|
+
readonly ksOpenChange = output<boolean>();
|
|
66
|
+
|
|
67
|
+
constructor(ref: ElementRef<KsSidebarElement>) {
|
|
68
|
+
this.el = ref.nativeElement;
|
|
69
|
+
|
|
70
|
+
effect(() => (this.el.position = this.position()));
|
|
71
|
+
effect(() => (this.el.type = this.type()));
|
|
72
|
+
effect(() => (this.el.open = this.open()));
|
|
73
|
+
effect(() => (this.el.width = this.width()));
|
|
74
|
+
effect(() => (this.el.target = this.target()));
|
|
75
|
+
|
|
76
|
+
const onNativeOpenChange = (event: Event): void => {
|
|
77
|
+
this.ksOpenChange.emit((event as CustomEvent<boolean>).detail);
|
|
78
|
+
};
|
|
79
|
+
this.el.addEventListener('openChange', onNativeOpenChange);
|
|
80
|
+
inject(DestroyRef).onDestroy(() => this.el.removeEventListener('openChange', onNativeOpenChange));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Passthrough to `<ks-sidebar>`'s own `@Method() openPanel()`. */
|
|
84
|
+
openPanel(): Promise<void> {
|
|
85
|
+
return this.el.openPanel();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Passthrough to `<ks-sidebar>`'s own `@Method() close()`. */
|
|
89
|
+
close(): Promise<void> {
|
|
90
|
+
return this.el.close();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Passthrough to `<ks-sidebar>`'s own `@Method() toggle()`. */
|
|
94
|
+
toggle(): Promise<void> {
|
|
95
|
+
return this.el.toggle();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-table` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-table.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, effect, inject, input, output } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
/** Mirrors the inline unions used by `core/src/components/Layout/table/table.tsx`. */
|
|
8
|
+
export type KsTableVariant = 'default' | 'striped' | 'bordered' | 'compact';
|
|
9
|
+
export type KsTableSize = 'sm' | 'md' | 'lg';
|
|
10
|
+
|
|
11
|
+
/** DOM shape of the real `<ks-table>` custom element, typed for the wrapper. */
|
|
12
|
+
type KsTableElement = HTMLElement & {
|
|
13
|
+
data: Record<string, unknown>[];
|
|
14
|
+
columns: string[];
|
|
15
|
+
columnLabels: Record<string, string>;
|
|
16
|
+
variant: KsTableVariant;
|
|
17
|
+
size: KsTableSize;
|
|
18
|
+
caption: string;
|
|
19
|
+
scrollable: boolean;
|
|
20
|
+
hoverable: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Angular wrapper around the `<ks-table>` Stencil custom element.
|
|
25
|
+
* No `<slot>` in the wrapped Stencil render — data-driven only.
|
|
26
|
+
*/
|
|
27
|
+
@Component({
|
|
28
|
+
selector: 'ks-table',
|
|
29
|
+
standalone: true,
|
|
30
|
+
template: '',
|
|
31
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
32
|
+
})
|
|
33
|
+
export class KsTableComponent {
|
|
34
|
+
private readonly el: KsTableElement;
|
|
35
|
+
|
|
36
|
+
/** Array of objects to render as table rows */
|
|
37
|
+
readonly data = input<Record<string, unknown>[]>([]);
|
|
38
|
+
|
|
39
|
+
/** Optional explicit column order; defaults to keys of the first row */
|
|
40
|
+
readonly columns = input<string[]>([]);
|
|
41
|
+
|
|
42
|
+
/** Optional custom column header labels: { key: 'Display Label' } */
|
|
43
|
+
readonly columnLabels = input<Record<string, string>>({});
|
|
44
|
+
|
|
45
|
+
/** Visual variant */
|
|
46
|
+
readonly variant = input<KsTableVariant>('default');
|
|
47
|
+
|
|
48
|
+
/** Row size */
|
|
49
|
+
readonly size = input<KsTableSize>('md');
|
|
50
|
+
|
|
51
|
+
/** Show a caption / title above the table */
|
|
52
|
+
readonly caption = input('');
|
|
53
|
+
|
|
54
|
+
/** Make the table horizontally scrollable on overflow */
|
|
55
|
+
readonly scrollable = input(true);
|
|
56
|
+
|
|
57
|
+
/** Highlight row on hover */
|
|
58
|
+
readonly hoverable = input(true);
|
|
59
|
+
|
|
60
|
+
/** Emits the clicked row's data. From the native `rowClick` event. */
|
|
61
|
+
readonly ksRowClick = output<Record<string, unknown>>();
|
|
62
|
+
|
|
63
|
+
constructor(ref: ElementRef<KsTableElement>) {
|
|
64
|
+
this.el = ref.nativeElement;
|
|
65
|
+
|
|
66
|
+
effect(() => (this.el.data = this.data()));
|
|
67
|
+
effect(() => (this.el.columns = this.columns()));
|
|
68
|
+
effect(() => (this.el.columnLabels = this.columnLabels()));
|
|
69
|
+
effect(() => (this.el.variant = this.variant()));
|
|
70
|
+
effect(() => (this.el.size = this.size()));
|
|
71
|
+
effect(() => (this.el.caption = this.caption()));
|
|
72
|
+
effect(() => (this.el.scrollable = this.scrollable()));
|
|
73
|
+
effect(() => (this.el.hoverable = this.hoverable()));
|
|
74
|
+
|
|
75
|
+
const onNativeRowClick = (event: Event): void => {
|
|
76
|
+
this.ksRowClick.emit((event as CustomEvent<Record<string, unknown>>).detail);
|
|
77
|
+
};
|
|
78
|
+
this.el.addEventListener('rowClick', onNativeRowClick);
|
|
79
|
+
inject(DestroyRef).onDestroy(() => this.el.removeEventListener('rowClick', onNativeRowClick));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-tooltip` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-tooltip.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, ElementRef, effect, input } from '@angular/core';
|
|
6
|
+
import type { KsPosition } from '@kraft.stitch/core';
|
|
7
|
+
|
|
8
|
+
/** DOM shape of the real `<ks-tooltip>` custom element, typed for the wrapper. */
|
|
9
|
+
type KsTooltipElement = HTMLElement & {
|
|
10
|
+
text: string;
|
|
11
|
+
position: KsPosition;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Angular wrapper around the `<ks-tooltip>` Stencil custom element.
|
|
17
|
+
*
|
|
18
|
+
* `<ks-tooltip>` renders a real, consumer-facing default `<slot />` for
|
|
19
|
+
* the element the tooltip is attached to. Same single unfiltered
|
|
20
|
+
* `<ng-content>` pass-through as `Layout/card/card.ts` — wrap the
|
|
21
|
+
* trigger element as `<ks-tooltip text="Hi"><button>Hover me</button></ks-tooltip>`.
|
|
22
|
+
*/
|
|
23
|
+
@Component({
|
|
24
|
+
selector: 'ks-tooltip',
|
|
25
|
+
standalone: true,
|
|
26
|
+
template: '<ng-content></ng-content>',
|
|
27
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
28
|
+
})
|
|
29
|
+
export class KsTooltipComponent {
|
|
30
|
+
private readonly el: KsTooltipElement;
|
|
31
|
+
|
|
32
|
+
/** Tooltip text */
|
|
33
|
+
readonly text = input('');
|
|
34
|
+
|
|
35
|
+
/** Preferred placement */
|
|
36
|
+
readonly position = input<KsPosition>('top');
|
|
37
|
+
|
|
38
|
+
/** Show tooltip on demand (true = always visible) — leave false for hover behaviour */
|
|
39
|
+
readonly visible = input(false);
|
|
40
|
+
|
|
41
|
+
constructor(ref: ElementRef<KsTooltipElement>) {
|
|
42
|
+
this.el = ref.nativeElement;
|
|
43
|
+
|
|
44
|
+
effect(() => (this.el.text = this.text()));
|
|
45
|
+
effect(() => (this.el.position = this.position()));
|
|
46
|
+
effect(() => (this.el.visible = this.visible()));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-accordion` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-accordion.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, effect, inject, input, output } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mirrors `KsAccordionItem` exported by
|
|
9
|
+
* `core/src/components/Navigation/accordion/accordion.tsx`. Duplicated
|
|
10
|
+
* locally — see the note in `Buttons/button-group/button-group.ts` for why.
|
|
11
|
+
*/
|
|
12
|
+
export interface KsAccordionItem {
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
icon?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** DOM shape of the real `<ks-accordion>` custom element, typed for the wrapper. */
|
|
20
|
+
type KsAccordionElement = HTMLElement & {
|
|
21
|
+
items: KsAccordionItem[];
|
|
22
|
+
multi: boolean;
|
|
23
|
+
openKeys: string[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Angular wrapper around the `<ks-accordion>` Stencil custom element.
|
|
28
|
+
*
|
|
29
|
+
* ## Panel content — `ksPanel`, NOT a native `slot` attribute
|
|
30
|
+
* The Stencil source maps each light-DOM child carrying a `ksPanel="key"`
|
|
31
|
+
* attribute to a matching named `<slot>` internally (see
|
|
32
|
+
* `core/src/utils/ks-slots.util.ts`'s `getKsPanelMap()`) — it does NOT use
|
|
33
|
+
* the browser-native `slot="..."` attribute consumers would use for
|
|
34
|
+
* `Layout/card/card.ts`-style components. `template: '<ng-content></ng-content>'`
|
|
35
|
+
* still applies the same way: it's a single, unfiltered pass-through of
|
|
36
|
+
* whatever this Angular component's own template projects, as real
|
|
37
|
+
* light-DOM children of the `<ks-accordion>` host — the wrapper does no
|
|
38
|
+
* filtering itself, it just needs to exist so the projected content
|
|
39
|
+
* becomes real children for Stencil's `getKsPanelMap()` scan to find.
|
|
40
|
+
* Usage:
|
|
41
|
+
* `<ks-accordion [items]="items">
|
|
42
|
+
* <div ksPanel="profile">Profile body…</div>
|
|
43
|
+
* <div ksPanel="settings">Settings body…</div>
|
|
44
|
+
* </ks-accordion>`
|
|
45
|
+
*/
|
|
46
|
+
@Component({
|
|
47
|
+
selector: 'ks-accordion',
|
|
48
|
+
standalone: true,
|
|
49
|
+
template: '<ng-content></ng-content>',
|
|
50
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
51
|
+
})
|
|
52
|
+
export class KsAccordionComponent {
|
|
53
|
+
private readonly el: KsAccordionElement;
|
|
54
|
+
|
|
55
|
+
/** List of accordion panel definitions */
|
|
56
|
+
readonly items = input<KsAccordionItem[]>([]);
|
|
57
|
+
|
|
58
|
+
/** Allow multiple panels open simultaneously */
|
|
59
|
+
readonly multi = input(false);
|
|
60
|
+
|
|
61
|
+
/** Keys that should be open by default */
|
|
62
|
+
readonly openKeys = input<string[]>([]);
|
|
63
|
+
|
|
64
|
+
/** Emits the key that was toggled. From the native `toggled` event. */
|
|
65
|
+
readonly ksToggled = output<string>();
|
|
66
|
+
|
|
67
|
+
constructor(ref: ElementRef<KsAccordionElement>) {
|
|
68
|
+
this.el = ref.nativeElement;
|
|
69
|
+
|
|
70
|
+
effect(() => (this.el.items = this.items()));
|
|
71
|
+
effect(() => (this.el.multi = this.multi()));
|
|
72
|
+
effect(() => (this.el.openKeys = this.openKeys()));
|
|
73
|
+
|
|
74
|
+
const onNativeToggled = (event: Event): void => {
|
|
75
|
+
this.ksToggled.emit((event as CustomEvent<string>).detail);
|
|
76
|
+
};
|
|
77
|
+
this.el.addEventListener('toggled', onNativeToggled);
|
|
78
|
+
inject(DestroyRef).onDestroy(() => this.el.removeEventListener('toggled', onNativeToggled));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-breadcrumb` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-breadcrumb.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, ElementRef, effect, input } from '@angular/core';
|
|
6
|
+
import type { KsBaseSize } from '@kraft.stitch/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Mirrors `KsBreadcrumbItem` exported by
|
|
10
|
+
* `core/src/components/Navigation/breadcrumb/breadcrumb.tsx`. Duplicated
|
|
11
|
+
* locally — see the note in `Buttons/button-group/button-group.ts` for why.
|
|
12
|
+
*/
|
|
13
|
+
export interface KsBreadcrumbItem {
|
|
14
|
+
label: string;
|
|
15
|
+
/** Route path or href — omit for the active (last) item */
|
|
16
|
+
href?: string;
|
|
17
|
+
/** Optional icon class */
|
|
18
|
+
icon?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** DOM shape of the real `<ks-breadcrumb>` custom element, typed for the wrapper. */
|
|
22
|
+
type KsBreadcrumbElement = HTMLElement & {
|
|
23
|
+
items: KsBreadcrumbItem[];
|
|
24
|
+
separator: string;
|
|
25
|
+
size: KsBaseSize;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Angular wrapper around the `<ks-breadcrumb>` Stencil custom element.
|
|
30
|
+
* Purely presentational — no events, no `<slot>` in the wrapped Stencil
|
|
31
|
+
* render, plain inputs only.
|
|
32
|
+
*/
|
|
33
|
+
@Component({
|
|
34
|
+
selector: 'ks-breadcrumb',
|
|
35
|
+
standalone: true,
|
|
36
|
+
template: '',
|
|
37
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
38
|
+
})
|
|
39
|
+
export class KsBreadcrumbComponent {
|
|
40
|
+
private readonly el: KsBreadcrumbElement;
|
|
41
|
+
|
|
42
|
+
/** Ordered list of breadcrumb items */
|
|
43
|
+
readonly items = input<KsBreadcrumbItem[]>([]);
|
|
44
|
+
|
|
45
|
+
/** Separator character or symbol */
|
|
46
|
+
readonly separator = input('/');
|
|
47
|
+
|
|
48
|
+
/** Size */
|
|
49
|
+
readonly size = input<KsBaseSize>('lg');
|
|
50
|
+
|
|
51
|
+
constructor(ref: ElementRef<KsBreadcrumbElement>) {
|
|
52
|
+
this.el = ref.nativeElement;
|
|
53
|
+
|
|
54
|
+
effect(() => (this.el.items = this.items()));
|
|
55
|
+
effect(() => (this.el.separator = this.separator()));
|
|
56
|
+
effect(() => (this.el.size = this.size()));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-carousel` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-carousel.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, effect, inject, input, output } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mirrors `KsCarouselSlide` exported by
|
|
9
|
+
* `core/src/components/Navigation/carousel/carousel.tsx`. Duplicated
|
|
10
|
+
* locally — see the note in `Buttons/button-group/button-group.ts` for why.
|
|
11
|
+
*/
|
|
12
|
+
export interface KsCarouselSlide {
|
|
13
|
+
key: string;
|
|
14
|
+
imageUrl?: string;
|
|
15
|
+
alt?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
caption?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** DOM shape of the real `<ks-carousel>` custom element, typed for the wrapper. */
|
|
21
|
+
type KsCarouselElement = HTMLElement & {
|
|
22
|
+
slides: KsCarouselSlide[];
|
|
23
|
+
autoPlay: number;
|
|
24
|
+
showControls: boolean;
|
|
25
|
+
showDots: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Angular wrapper around the `<ks-carousel>` Stencil custom element.
|
|
30
|
+
* No `<slot>` in the wrapped Stencil render — data-driven only.
|
|
31
|
+
*/
|
|
32
|
+
@Component({
|
|
33
|
+
selector: 'ks-carousel',
|
|
34
|
+
standalone: true,
|
|
35
|
+
template: '',
|
|
36
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
37
|
+
})
|
|
38
|
+
export class KsCarouselComponent {
|
|
39
|
+
private readonly el: KsCarouselElement;
|
|
40
|
+
|
|
41
|
+
/** Slides to display */
|
|
42
|
+
readonly slides = input<KsCarouselSlide[]>([]);
|
|
43
|
+
|
|
44
|
+
/** Auto-play interval in ms (0 = disabled) */
|
|
45
|
+
readonly autoPlay = input(0);
|
|
46
|
+
|
|
47
|
+
/** Show prev/next arrow controls */
|
|
48
|
+
readonly showControls = input(true);
|
|
49
|
+
|
|
50
|
+
/** Show dot indicators */
|
|
51
|
+
readonly showDots = input(true);
|
|
52
|
+
|
|
53
|
+
/** Emits the current slide index on change. From the native `slideChange` event. */
|
|
54
|
+
readonly ksSlideChange = output<number>();
|
|
55
|
+
|
|
56
|
+
constructor(ref: ElementRef<KsCarouselElement>) {
|
|
57
|
+
this.el = ref.nativeElement;
|
|
58
|
+
|
|
59
|
+
effect(() => (this.el.slides = this.slides()));
|
|
60
|
+
effect(() => (this.el.autoPlay = this.autoPlay()));
|
|
61
|
+
effect(() => (this.el.showControls = this.showControls()));
|
|
62
|
+
effect(() => (this.el.showDots = this.showDots()));
|
|
63
|
+
|
|
64
|
+
const onNativeSlideChange = (event: Event): void => {
|
|
65
|
+
this.ksSlideChange.emit((event as CustomEvent<number>).detail);
|
|
66
|
+
};
|
|
67
|
+
this.el.addEventListener('slideChange', onNativeSlideChange);
|
|
68
|
+
inject(DestroyRef).onDestroy(() => this.el.removeEventListener('slideChange', onNativeSlideChange));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-context-menu` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-context-menu.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, effect, inject, input, output } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mirrors `KsContextMenuItem` / `KsContextMenuPosition` exported by
|
|
9
|
+
* `core/src/components/Navigation/context-menu/context-menu.tsx`.
|
|
10
|
+
* Duplicated locally — see the note in `Buttons/button-group/button-group.ts` for why.
|
|
11
|
+
*/
|
|
12
|
+
export interface KsContextMenuItem {
|
|
13
|
+
key: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
icon?: string;
|
|
16
|
+
divider?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
danger?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface KsContextMenuPosition {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** DOM shape of the real `<ks-context-menu>` custom element, typed for the wrapper. */
|
|
27
|
+
type KsContextMenuElement = HTMLElement & {
|
|
28
|
+
items: KsContextMenuItem[];
|
|
29
|
+
open(pos: KsContextMenuPosition): Promise<void>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Angular wrapper around the `<ks-context-menu>` Stencil custom element.
|
|
35
|
+
*
|
|
36
|
+
* `<ks-context-menu>`'s own `@Method()`s (`open(pos)`/`close()`) are
|
|
37
|
+
* exposed here as real passthrough methods — grab the component instance
|
|
38
|
+
* with `@ViewChild(KsContextMenuComponent)` and call them directly, e.g.
|
|
39
|
+
* `onContextMenu(e: MouseEvent) { menu.open({ x: e.clientX, y: e.clientY }); }`.
|
|
40
|
+
*
|
|
41
|
+
* No `<slot>` in the wrapped Stencil render — data-driven only.
|
|
42
|
+
*/
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'ks-context-menu',
|
|
45
|
+
standalone: true,
|
|
46
|
+
template: '',
|
|
47
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
48
|
+
})
|
|
49
|
+
export class KsContextMenuComponent {
|
|
50
|
+
private readonly el: KsContextMenuElement;
|
|
51
|
+
|
|
52
|
+
/** Menu items */
|
|
53
|
+
readonly items = input<KsContextMenuItem[]>([]);
|
|
54
|
+
|
|
55
|
+
/** Emits the clicked item key. From the native `itemClicked` event. */
|
|
56
|
+
readonly ksItemClicked = output<string>();
|
|
57
|
+
|
|
58
|
+
constructor(ref: ElementRef<KsContextMenuElement>) {
|
|
59
|
+
this.el = ref.nativeElement;
|
|
60
|
+
|
|
61
|
+
effect(() => (this.el.items = this.items()));
|
|
62
|
+
|
|
63
|
+
const onNativeItemClicked = (event: Event): void => {
|
|
64
|
+
this.ksItemClicked.emit((event as CustomEvent<string>).detail);
|
|
65
|
+
};
|
|
66
|
+
this.el.addEventListener('itemClicked', onNativeItemClicked);
|
|
67
|
+
inject(DestroyRef).onDestroy(() => this.el.removeEventListener('itemClicked', onNativeItemClicked));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Passthrough to `<ks-context-menu>`'s own `@Method() open(pos)`. */
|
|
71
|
+
open(pos: KsContextMenuPosition): Promise<void> {
|
|
72
|
+
return this.el.open(pos);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Passthrough to `<ks-context-menu>`'s own `@Method() close()`. */
|
|
76
|
+
close(): Promise<void> {
|
|
77
|
+
return this.el.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-nav-bar` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-nav-bar.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, ElementRef, effect, input } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mirrors the types exported by
|
|
9
|
+
* `core/src/components/Navigation/nav-bar/nav-bar.tsx`. Duplicated
|
|
10
|
+
* locally — see the note in `Buttons/button-group/button-group.ts` for why.
|
|
11
|
+
*/
|
|
12
|
+
export interface KsNavBarItem {
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
iconClass: string;
|
|
16
|
+
/** href to navigate to */
|
|
17
|
+
redirectLink: string;
|
|
18
|
+
activationFragment?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type KsNavBarSection = 'top' | 'mid' | 'bottom';
|
|
23
|
+
|
|
24
|
+
export interface KsNavBarSectionItem extends KsNavBarItem {
|
|
25
|
+
section: KsNavBarSection;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type KsNavBarMode = 'iconOnly' | 'hoverToExpand' | 'alwaysOpen';
|
|
29
|
+
|
|
30
|
+
/** DOM shape of the real `<ks-nav-bar>` custom element, typed for the wrapper. */
|
|
31
|
+
type KsNavBarElement = HTMLElement & {
|
|
32
|
+
items: KsNavBarSectionItem[];
|
|
33
|
+
mode: KsNavBarMode;
|
|
34
|
+
iconWidth: string;
|
|
35
|
+
expandedWidth: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Angular wrapper around the `<ks-nav-bar>` Stencil custom element.
|
|
40
|
+
* Renders a real, consumer-facing default `<slot />` — same single
|
|
41
|
+
* unfiltered `<ng-content>` pass-through as `Layout/card/card.ts`.
|
|
42
|
+
*/
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'ks-nav-bar',
|
|
45
|
+
standalone: true,
|
|
46
|
+
template: '<ng-content></ng-content>',
|
|
47
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
48
|
+
})
|
|
49
|
+
export class KsNavBarComponent {
|
|
50
|
+
private readonly el: KsNavBarElement;
|
|
51
|
+
|
|
52
|
+
/** All nav items with their section assignment */
|
|
53
|
+
readonly items = input<KsNavBarSectionItem[]>([]);
|
|
54
|
+
|
|
55
|
+
/** Expansion mode */
|
|
56
|
+
readonly mode = input<KsNavBarMode>('iconOnly');
|
|
57
|
+
|
|
58
|
+
/** Width of the icon-only rail */
|
|
59
|
+
readonly iconWidth = input('3.5rem');
|
|
60
|
+
|
|
61
|
+
/** Width of the expanded label panel */
|
|
62
|
+
readonly expandedWidth = input('13rem');
|
|
63
|
+
|
|
64
|
+
constructor(ref: ElementRef<KsNavBarElement>) {
|
|
65
|
+
this.el = ref.nativeElement;
|
|
66
|
+
|
|
67
|
+
effect(() => (this.el.items = this.items()));
|
|
68
|
+
effect(() => (this.el.mode = this.mode()));
|
|
69
|
+
effect(() => (this.el.iconWidth = this.iconWidth()));
|
|
70
|
+
effect(() => (this.el.expandedWidth = this.expandedWidth()));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Side-effect import: registers the `ks-pagination` tag — see
|
|
2
|
+
// `Buttons/button/button.ts` for the full explanation of this pattern.
|
|
3
|
+
import '@kraft.stitch/core/dist/components/ks-pagination.js';
|
|
4
|
+
|
|
5
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, effect, inject, input, output } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
/** DOM shape of the real `<ks-pagination>` custom element, typed for the wrapper. */
|
|
8
|
+
type KsPaginationElement = HTMLElement & {
|
|
9
|
+
total: number;
|
|
10
|
+
pageSize: number;
|
|
11
|
+
currentPage: number;
|
|
12
|
+
showPageSize: boolean;
|
|
13
|
+
pageSizeOptions: number[];
|
|
14
|
+
showQuickJumper: boolean;
|
|
15
|
+
maxPageButtons: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Angular wrapper around the `<ks-pagination>` Stencil custom element.
|
|
20
|
+
* No `<slot>` in the wrapped Stencil render — data-driven only.
|
|
21
|
+
*/
|
|
22
|
+
@Component({
|
|
23
|
+
selector: 'ks-pagination',
|
|
24
|
+
standalone: true,
|
|
25
|
+
template: '',
|
|
26
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
27
|
+
})
|
|
28
|
+
export class KsPaginationComponent {
|
|
29
|
+
private readonly el: KsPaginationElement;
|
|
30
|
+
|
|
31
|
+
/** Total number of items */
|
|
32
|
+
readonly total = input(0);
|
|
33
|
+
|
|
34
|
+
/** Items per page */
|
|
35
|
+
readonly pageSize = input(10);
|
|
36
|
+
|
|
37
|
+
/** Current page (1-indexed) */
|
|
38
|
+
readonly currentPage = input(1);
|
|
39
|
+
|
|
40
|
+
/** Show page size selector */
|
|
41
|
+
readonly showPageSize = input(false);
|
|
42
|
+
|
|
43
|
+
/** Available page sizes */
|
|
44
|
+
readonly pageSizeOptions = input<number[]>([10, 20, 50, 100]);
|
|
45
|
+
|
|
46
|
+
/** Show quick jumper */
|
|
47
|
+
readonly showQuickJumper = input(false);
|
|
48
|
+
|
|
49
|
+
/** Maximum number of page buttons to show */
|
|
50
|
+
readonly maxPageButtons = input(7);
|
|
51
|
+
|
|
52
|
+
/** Emits when page changes. From the native `pageChange` event. */
|
|
53
|
+
readonly ksPageChange = output<number>();
|
|
54
|
+
|
|
55
|
+
/** Emits when page size changes. From the native `pageSizeChange` event. */
|
|
56
|
+
readonly ksPageSizeChange = output<number>();
|
|
57
|
+
|
|
58
|
+
constructor(ref: ElementRef<KsPaginationElement>) {
|
|
59
|
+
this.el = ref.nativeElement;
|
|
60
|
+
|
|
61
|
+
effect(() => (this.el.total = this.total()));
|
|
62
|
+
effect(() => (this.el.pageSize = this.pageSize()));
|
|
63
|
+
effect(() => (this.el.currentPage = this.currentPage()));
|
|
64
|
+
effect(() => (this.el.showPageSize = this.showPageSize()));
|
|
65
|
+
effect(() => (this.el.pageSizeOptions = this.pageSizeOptions()));
|
|
66
|
+
effect(() => (this.el.showQuickJumper = this.showQuickJumper()));
|
|
67
|
+
effect(() => (this.el.maxPageButtons = this.maxPageButtons()));
|
|
68
|
+
|
|
69
|
+
const onNativePageChange = (event: Event): void => {
|
|
70
|
+
this.ksPageChange.emit((event as CustomEvent<number>).detail);
|
|
71
|
+
};
|
|
72
|
+
const onNativePageSizeChange = (event: Event): void => {
|
|
73
|
+
this.ksPageSizeChange.emit((event as CustomEvent<number>).detail);
|
|
74
|
+
};
|
|
75
|
+
this.el.addEventListener('pageChange', onNativePageChange);
|
|
76
|
+
this.el.addEventListener('pageSizeChange', onNativePageSizeChange);
|
|
77
|
+
inject(DestroyRef).onDestroy(() => {
|
|
78
|
+
this.el.removeEventListener('pageChange', onNativePageChange);
|
|
79
|
+
this.el.removeEventListener('pageSizeChange', onNativePageSizeChange);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|