@sixbell-telco/sdk 1.0.3 → 1.1.0
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/CHANGELOG.md +44 -0
- package/README.md +44 -0
- package/_index.css +52 -25
- package/components/avatar/src/avatar.component.d.ts +40 -26
- package/components/button/src/button.component.d.ts +2 -2
- package/components/dropdown/dropdown-chevron/dropdown-chevron.component.d.ts +39 -0
- package/components/dropdown/dropdown-content/dropdown-content.component.d.ts +41 -0
- package/components/dropdown/dropdown-group/dropdown-group.component.d.ts +9 -0
- package/components/dropdown/dropdown-item/dropdown-item.component.d.ts +23 -12
- package/components/dropdown/dropdown-item-checkbox/dropdown-item-checkbox.component.d.ts +49 -0
- package/components/dropdown/dropdown-item-radio/dropdown-item-radio.component.d.ts +53 -0
- package/components/dropdown/dropdown-label/dropdown-label.component.d.ts +17 -0
- package/components/dropdown/dropdown-separator/dropdown-separator.component.d.ts +21 -0
- package/components/dropdown/dropdown-trigger/dropdown-trigger.component.d.ts +121 -0
- package/components/dropdown/public-api.d.ts +9 -0
- package/components/dropdown/src/dropdown.component.d.ts +20 -174
- package/components/dropdown/src/services/dropdown.service.d.ts +22 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar/dropdown-menu-bar.component.d.ts +22 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-content/dropdown-menu-bar-content.component.d.ts +64 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-item/dropdown-menu-bar-item.component.d.ts +37 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-item-checkbox/dropdown-menu-bar-item-checkbox.component.d.ts +54 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-item-radio/dropdown-menu-bar-item-radio.component.d.ts +58 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-label/dropdown-menu-bar-label.component.d.ts +16 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-separator/dropdown-menu-bar-separator.component.d.ts +16 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-sub-trigger/dropdown-menu-bar-sub-trigger.component.d.ts +29 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-trigger/dropdown-menu-bar-trigger.component.d.ts +50 -0
- package/components/dropdown-menu/bar/index.d.ts +5 -0
- package/components/dropdown-menu/bar/public-api.d.ts +9 -0
- package/components/dropdown-menu/context/dropdown-context-menu-trigger/dropdown-context-menu-trigger.component.d.ts +23 -0
- package/components/dropdown-menu/context/index.d.ts +5 -0
- package/components/dropdown-menu/context/public-api.d.ts +1 -0
- package/components/dropdown-menu/dropdown-menu-chevron/dropdown-menu-chevron.component.d.ts +43 -0
- package/components/dropdown-menu/index.d.ts +5 -0
- package/components/dropdown-menu/public-api.d.ts +13 -0
- package/components/dropdown-menu/src/directives/dropdown-menu.directive.d.ts +40 -0
- package/components/dropdown-menu/src/dropdown-menu/dropdown-menu.component.d.ts +9 -0
- package/components/dropdown-menu/src/dropdown-menu-content/dropdown-menu-content.component.d.ts +40 -0
- package/components/dropdown-menu/src/dropdown-menu-group/dropdown-menu-group.component.d.ts +8 -0
- package/components/dropdown-menu/src/dropdown-menu-item/dropdown-menu-item.component.d.ts +38 -0
- package/components/dropdown-menu/src/dropdown-menu-label/dropdown-menu-label.component.d.ts +16 -0
- package/components/dropdown-menu/src/dropdown-menu-separator/dropdown-menu-separator.component.d.ts +16 -0
- package/components/dropdown-menu/src/dropdown-menu-sub/dropdown-menu-sub.component.d.ts +8 -0
- package/components/dropdown-menu/src/dropdown-menu-sub-content/dropdown-menu-sub-content.component.d.ts +31 -0
- package/components/dropdown-menu/src/dropdown-menu-sub-trigger/dropdown-menu-sub-trigger.component.d.ts +18 -0
- package/components/dropdown-menu/src/dropdown-menu-trigger/dropdown-menu-trigger.component.d.ts +19 -0
- package/components/dropdown-menu/src/services/dropdown-menu.service.d.ts +22 -0
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +75 -39
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-button.mjs +1 -0
- package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +529 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs +52 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +539 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +592 -213
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +139 -0
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +183 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -0
- package/package.json +21 -1
- package/sixbell-telco-sdk-1.1.0.tgz +0 -0
- package/utils/theme/index.d.ts +5 -0
- package/utils/theme/public-api.d.ts +1 -0
- package/utils/theme/src/theme.service.d.ts +55 -0
- package/utils/translation/index.d.ts +5 -0
- package/utils/translation/public-api.d.ts +1 -0
- package/utils/translation/src/translation.service.d.ts +112 -0
- package/sixbell-telco-sdk-1.0.3.tgz +0 -0
|
@@ -1,269 +1,589 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { signal, Injectable, inject, input, computed, Component, output, ViewChild, ContentChild } from '@angular/core';
|
|
4
3
|
import { IconComponent } from '@sixbell-telco/sdk/components/icon';
|
|
5
|
-
import {
|
|
4
|
+
import { matKeyboardArrowDown } from '@sixbell-telco/sdk/components/icon/material/baseline';
|
|
6
5
|
import { cn } from '@sixbell-telco/sdk/utils/cn';
|
|
7
|
-
import {
|
|
6
|
+
import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
|
|
7
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Service to manage dropdown state
|
|
11
|
+
* Used by dropdown components to communicate state to chevron
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
lg: ['btn-lg'],
|
|
39
|
-
xl: ['btn-xl'],
|
|
40
|
-
},
|
|
41
|
-
iconPosition: {
|
|
42
|
-
left: [''],
|
|
43
|
-
right: ['flex-row-reverse'],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
compoundVariants: [],
|
|
47
|
-
defaultVariants: {
|
|
48
|
-
variant: 'secondary',
|
|
49
|
-
size: 'md',
|
|
50
|
-
iconPosition: 'left',
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
* Generates base dropdown menu classes with positioning variants
|
|
56
|
-
*/
|
|
57
|
-
const dropdownMenu = cva(['dropdown'], {
|
|
58
|
-
variants: {
|
|
59
|
-
menuPosition: {
|
|
60
|
-
top: ['dropdown-top'],
|
|
61
|
-
bottom: ['dropdown-bottom'],
|
|
62
|
-
right: ['dropdown-right'],
|
|
63
|
-
left: ['dropdown-left'],
|
|
64
|
-
},
|
|
65
|
-
menuAlignment: {
|
|
66
|
-
start: [''],
|
|
67
|
-
end: ['dropdown-end'],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
compoundVariants: [],
|
|
71
|
-
defaultVariants: {
|
|
72
|
-
menuPosition: 'bottom',
|
|
73
|
-
menuAlignment: 'start',
|
|
74
|
-
},
|
|
75
|
-
});
|
|
13
|
+
class DropdownService {
|
|
14
|
+
_isOpen = signal(false);
|
|
15
|
+
/**
|
|
16
|
+
* Current open state of the dropdown
|
|
17
|
+
*/
|
|
18
|
+
isOpen = this._isOpen.asReadonly();
|
|
19
|
+
/**
|
|
20
|
+
* Set the open state
|
|
21
|
+
*/
|
|
22
|
+
setOpen(open) {
|
|
23
|
+
this._isOpen.set(open);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Toggle the open state
|
|
27
|
+
*/
|
|
28
|
+
toggle() {
|
|
29
|
+
this._isOpen.update((current) => !current);
|
|
30
|
+
}
|
|
31
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
32
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownService });
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownService, decorators: [{
|
|
35
|
+
type: Injectable
|
|
36
|
+
}] });
|
|
37
|
+
|
|
76
38
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
39
|
+
* DropdownChevron - Chevron indicator for dropdown triggers
|
|
40
|
+
* Automatically rotates based on dropdown state and positions itself correctly
|
|
79
41
|
*/
|
|
80
|
-
|
|
42
|
+
class DropdownChevronComponent {
|
|
43
|
+
dropdownService = inject(DropdownService, { optional: true });
|
|
44
|
+
/**
|
|
45
|
+
* Custom icon to use instead of default arrow down
|
|
46
|
+
*/
|
|
47
|
+
icon = input(matKeyboardArrowDown);
|
|
48
|
+
/**
|
|
49
|
+
* Additional CSS classes
|
|
50
|
+
*/
|
|
51
|
+
class = input('');
|
|
52
|
+
/**
|
|
53
|
+
* Size of the chevron using Icon component size types
|
|
54
|
+
*/
|
|
55
|
+
size = input('md');
|
|
56
|
+
/**
|
|
57
|
+
* Color of the chevron using Icon component color types
|
|
58
|
+
*/
|
|
59
|
+
color = input('inherit');
|
|
60
|
+
/**
|
|
61
|
+
* Position relative to content
|
|
62
|
+
*/
|
|
63
|
+
position = input('right');
|
|
64
|
+
/**
|
|
65
|
+
* Whether the chevron is open (rotated)
|
|
66
|
+
*/
|
|
67
|
+
isOpen = computed(() => this.dropdownService?.isOpen() ?? false);
|
|
68
|
+
/**
|
|
69
|
+
* Computed classes for the chevron
|
|
70
|
+
*/
|
|
71
|
+
chevronClasses = computed(() => {
|
|
72
|
+
const marginClasses = {
|
|
73
|
+
left: 'mr-2',
|
|
74
|
+
right: 'ml-2',
|
|
75
|
+
};
|
|
76
|
+
return cn(marginClasses[this.position()], 'transition-transform duration-200 ease-in-out', this.isOpen() && 'rotate-180', this.class());
|
|
77
|
+
});
|
|
78
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownChevronComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
79
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.0", type: DropdownChevronComponent, isStandalone: true, selector: "st-dropdown-chevron", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<st-icon [icon]=\"icon()\" [size]=\"size()\" [color]=\"color()\" [class]=\"chevronClasses()\"></st-icon>\n", dependencies: [{ kind: "component", type: IconComponent, selector: "st-icon", inputs: ["color", "size", "icon"] }] });
|
|
80
|
+
}
|
|
81
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownChevronComponent, decorators: [{
|
|
82
|
+
type: Component,
|
|
83
|
+
args: [{ selector: 'st-dropdown-chevron', standalone: true, imports: [IconComponent], template: "<st-icon [icon]=\"icon()\" [size]=\"size()\" [color]=\"color()\" [class]=\"chevronClasses()\"></st-icon>\n" }]
|
|
84
|
+
}] });
|
|
85
|
+
|
|
81
86
|
/**
|
|
82
|
-
*
|
|
87
|
+
* DropdownContent - Container for dropdown menu items
|
|
83
88
|
*
|
|
84
89
|
* @remarks
|
|
85
|
-
*
|
|
86
|
-
*
|
|
90
|
+
* This component contains the dropdown menu items and provides them as a template
|
|
91
|
+
* for the trigger component to display in the overlay.
|
|
87
92
|
*
|
|
88
93
|
* @example
|
|
89
94
|
* ```html
|
|
90
|
-
* <st-dropdown
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* >
|
|
96
|
-
* <button>Actions</button>
|
|
97
|
-
* <div slot="menu">
|
|
98
|
-
* <button class="menu-item">Edit</button>
|
|
99
|
-
* <button class="menu-item">Delete</button>
|
|
100
|
-
* </div>
|
|
101
|
-
* </st-dropdown>
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```html
|
|
106
|
-
* <st-dropdown
|
|
107
|
-
* variant="icon"
|
|
108
|
-
* menuPosition="right"
|
|
109
|
-
* icon="more-vertical"
|
|
110
|
-
* >
|
|
111
|
-
* <div slot="menu">...</div>
|
|
112
|
-
* </st-dropdown>
|
|
95
|
+
* <st-dropdown-content>
|
|
96
|
+
* <st-dropdown-item>Menu Item 1</st-dropdown-item>
|
|
97
|
+
* <st-dropdown-item>Menu Item 2</st-dropdown-item>
|
|
98
|
+
* <div class="divider"></div>
|
|
99
|
+
* <st-dropdown-item>Menu Item 3</st-dropdown-item>
|
|
100
|
+
* </st-dropdown-content>
|
|
113
101
|
* ```
|
|
114
102
|
*/
|
|
115
|
-
class
|
|
103
|
+
class DropdownContentComponent {
|
|
104
|
+
template;
|
|
105
|
+
/** Custom CSS classes */
|
|
106
|
+
class = input('');
|
|
107
|
+
/** Size variant */
|
|
108
|
+
size = input('md');
|
|
109
|
+
/** Whether to apply shadow */
|
|
110
|
+
shadow = input(true);
|
|
111
|
+
/** Event emitted when close is requested */
|
|
112
|
+
closeRequested = output();
|
|
116
113
|
/**
|
|
117
|
-
*
|
|
118
|
-
* @defaultValue 'secondary'
|
|
114
|
+
* Computed CSS classes for the content
|
|
119
115
|
*/
|
|
120
|
-
|
|
116
|
+
contentClass = () => cn('menu', 'bg-base-200', 'rounded-box', 'border', 'border-neutral', 'min-w-full', {
|
|
117
|
+
'menu-xs': this.size() === 'xs',
|
|
118
|
+
'menu-sm': this.size() === 'sm',
|
|
119
|
+
'menu-md': this.size() === 'md',
|
|
120
|
+
'menu-lg': this.size() === 'lg',
|
|
121
|
+
'menu-xl': this.size() === 'xl',
|
|
122
|
+
'shadow-main': this.shadow(),
|
|
123
|
+
}, this.class());
|
|
121
124
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
125
|
+
* Request to close the dropdown
|
|
126
|
+
* This will be handled by the parent dropdown component
|
|
124
127
|
*/
|
|
125
|
-
|
|
128
|
+
requestClose() {
|
|
129
|
+
this.closeRequested.emit();
|
|
130
|
+
}
|
|
131
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
132
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.0", type: DropdownContentComponent, isStandalone: true, selector: "st-dropdown-content", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shadow: { classPropertyName: "shadow", publicName: "shadow", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closeRequested: "closeRequested" }, viewQueries: [{ propertyName: "template", first: true, predicate: ["contentTemplate"], descendants: true, static: true }], exportAs: ["dropdownContent"], ngImport: i0, template: "<ng-template #contentTemplate>\n\t<ul [class]=\"contentClass()\">\n\t\t<ng-content></ng-content>\n\t</ul>\n</ng-template>\n" });
|
|
133
|
+
}
|
|
134
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownContentComponent, decorators: [{
|
|
135
|
+
type: Component,
|
|
136
|
+
args: [{ selector: 'st-dropdown-content', standalone: true, exportAs: 'dropdownContent', template: "<ng-template #contentTemplate>\n\t<ul [class]=\"contentClass()\">\n\t\t<ng-content></ng-content>\n\t</ul>\n</ng-template>\n" }]
|
|
137
|
+
}], propDecorators: { template: [{
|
|
138
|
+
type: ViewChild,
|
|
139
|
+
args: ['contentTemplate', { static: true }]
|
|
140
|
+
}] } });
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* DropdownGroup - Groups related dropdown items together
|
|
144
|
+
* Provides semantic grouping for dropdown items
|
|
145
|
+
*/
|
|
146
|
+
class DropdownGroupComponent {
|
|
147
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
148
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.0", type: DropdownGroupComponent, isStandalone: true, selector: "st-dropdown-group", ngImport: i0, template: "<ng-content></ng-content>\n" });
|
|
149
|
+
}
|
|
150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownGroupComponent, decorators: [{
|
|
151
|
+
type: Component,
|
|
152
|
+
args: [{ selector: 'st-dropdown-group', standalone: true, imports: [], template: "<ng-content></ng-content>\n" }]
|
|
153
|
+
}] });
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* DropdownItemCheckbox - Checkbox dropdown item
|
|
157
|
+
* Provides checkbox functionality for dropdown selections
|
|
158
|
+
*/
|
|
159
|
+
class DropdownItemCheckboxComponent {
|
|
126
160
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @defaultValue false
|
|
161
|
+
* Whether the checkbox is checked
|
|
129
162
|
*/
|
|
130
|
-
|
|
163
|
+
checked = input(false);
|
|
131
164
|
/**
|
|
132
|
-
*
|
|
133
|
-
* @defaultValue false
|
|
165
|
+
* Whether the menu item is disabled
|
|
134
166
|
*/
|
|
135
|
-
|
|
167
|
+
disabled = input(false);
|
|
136
168
|
/**
|
|
137
|
-
*
|
|
138
|
-
* @defaultValue false
|
|
169
|
+
* Custom indicator character or text
|
|
139
170
|
*/
|
|
140
|
-
|
|
171
|
+
indicator = input('✓');
|
|
141
172
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @defaultValue false
|
|
173
|
+
* Whether to show the indicator
|
|
144
174
|
*/
|
|
145
|
-
|
|
175
|
+
showIndicator = input(true);
|
|
146
176
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @defaultValue false
|
|
177
|
+
* Custom CSS classes
|
|
149
178
|
*/
|
|
150
|
-
|
|
179
|
+
class = input('');
|
|
151
180
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @defaultValue false
|
|
181
|
+
* Emitted when the checkbox state changes
|
|
154
182
|
*/
|
|
155
|
-
|
|
183
|
+
checkedChange = output();
|
|
156
184
|
/**
|
|
157
|
-
*
|
|
158
|
-
* @defaultValue 'md'
|
|
185
|
+
* Emitted when the menu item is triggered/clicked
|
|
159
186
|
*/
|
|
160
|
-
|
|
187
|
+
triggered = output();
|
|
161
188
|
/**
|
|
162
|
-
*
|
|
163
|
-
* @defaultValue false
|
|
189
|
+
* Computed data state for ARIA
|
|
164
190
|
*/
|
|
165
|
-
|
|
191
|
+
dataState = computed(() => {
|
|
192
|
+
return this.checked() ? 'checked' : 'unchecked';
|
|
193
|
+
});
|
|
166
194
|
/**
|
|
167
|
-
*
|
|
195
|
+
* Handle item click - toggle checkbox state
|
|
168
196
|
*/
|
|
169
|
-
|
|
197
|
+
onItemClick() {
|
|
198
|
+
if (!this.disabled()) {
|
|
199
|
+
const newChecked = !this.checked();
|
|
200
|
+
this.checkedChange.emit(newChecked);
|
|
201
|
+
this.triggered.emit();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
170
204
|
/**
|
|
171
|
-
*
|
|
205
|
+
* Computed CSS classes for the menu item
|
|
172
206
|
*/
|
|
173
|
-
|
|
207
|
+
itemClass = () => cn('group', 'transition-colors', 'duration-200', {
|
|
208
|
+
'menu-disabled pointer-events-none opacity-50': this.disabled(),
|
|
209
|
+
'menu-active': this.checked(),
|
|
210
|
+
}, this.class());
|
|
211
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownItemCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
212
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.0", type: DropdownItemCheckboxComponent, isStandalone: true, selector: "st-dropdown-item-checkbox", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, indicator: { classPropertyName: "indicator", publicName: "indicator", isSignal: true, isRequired: false, transformFunction: null }, showIndicator: { classPropertyName: "showIndicator", publicName: "showIndicator", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "checkedChange", triggered: "triggered" }, ngImport: i0, template: "<li\n\t[class]=\"itemClass()\"\n\t[attr.data-state]=\"dataState()\"\n\t(click)=\"onItemClick()\"\n\t(keydown.enter)=\"onItemClick()\"\n\t(keydown.space)=\"onItemClick()\"\n\t[attr.tabindex]=\"disabled() ? -1 : 0\"\n\trole=\"menuitemcheckbox\"\n\t[attr.aria-checked]=\"checked()\"\n\t[attr.aria-disabled]=\"disabled()\"\n>\n\t<a class=\"flex items-center justify-between\">\n\t\t<span class=\"flex-1\">\n\t\t\t<ng-content></ng-content>\n\t\t</span>\n\t\t@if (showIndicator()) {\n\t\t\t<span\n\t\t\t\tclass=\"ml-auto text-xs transition-opacity duration-300 ease-in-out group-aria-[checked=false]:opacity-0 group-aria-[checked=true]:opacity-100\"\n\t\t\t>\n\t\t\t\t{{ indicator() }}\n\t\t\t</span>\n\t\t}\n\t</a>\n</li>\n" });
|
|
213
|
+
}
|
|
214
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownItemCheckboxComponent, decorators: [{
|
|
215
|
+
type: Component,
|
|
216
|
+
args: [{ selector: 'st-dropdown-item-checkbox', standalone: true, imports: [], template: "<li\n\t[class]=\"itemClass()\"\n\t[attr.data-state]=\"dataState()\"\n\t(click)=\"onItemClick()\"\n\t(keydown.enter)=\"onItemClick()\"\n\t(keydown.space)=\"onItemClick()\"\n\t[attr.tabindex]=\"disabled() ? -1 : 0\"\n\trole=\"menuitemcheckbox\"\n\t[attr.aria-checked]=\"checked()\"\n\t[attr.aria-disabled]=\"disabled()\"\n>\n\t<a class=\"flex items-center justify-between\">\n\t\t<span class=\"flex-1\">\n\t\t\t<ng-content></ng-content>\n\t\t</span>\n\t\t@if (showIndicator()) {\n\t\t\t<span\n\t\t\t\tclass=\"ml-auto text-xs transition-opacity duration-300 ease-in-out group-aria-[checked=false]:opacity-0 group-aria-[checked=true]:opacity-100\"\n\t\t\t>\n\t\t\t\t{{ indicator() }}\n\t\t\t</span>\n\t\t}\n\t</a>\n</li>\n" }]
|
|
217
|
+
}] });
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* DropdownItemRadio - Radio dropdown item
|
|
221
|
+
* Provides radio button functionality for dropdown selections
|
|
222
|
+
*/
|
|
223
|
+
class DropdownItemRadioComponent {
|
|
174
224
|
/**
|
|
175
|
-
*
|
|
176
|
-
* @defaultValue 'bottom'
|
|
225
|
+
* Whether the radio is checked
|
|
177
226
|
*/
|
|
178
|
-
|
|
227
|
+
checked = input(false);
|
|
179
228
|
/**
|
|
180
|
-
*
|
|
229
|
+
* The value of this radio item
|
|
181
230
|
*/
|
|
182
|
-
|
|
231
|
+
value = input.required();
|
|
183
232
|
/**
|
|
184
|
-
*
|
|
233
|
+
* Whether the menu item is disabled
|
|
185
234
|
*/
|
|
186
|
-
|
|
235
|
+
disabled = input(false);
|
|
187
236
|
/**
|
|
188
|
-
*
|
|
189
|
-
* @defaultValue false
|
|
237
|
+
* Custom indicator character or text
|
|
190
238
|
*/
|
|
191
|
-
|
|
239
|
+
indicator = input('●');
|
|
192
240
|
/**
|
|
193
|
-
*
|
|
241
|
+
* Whether to show the indicator
|
|
194
242
|
*/
|
|
195
|
-
|
|
243
|
+
showIndicator = input(true);
|
|
196
244
|
/**
|
|
197
|
-
*
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
buttonClass = computed(() => {
|
|
201
|
-
return cn(dropdownButton({
|
|
202
|
-
variant: this.variant(),
|
|
203
|
-
size: this.size(),
|
|
204
|
-
iconPosition: this.iconPosition(),
|
|
205
|
-
}), {
|
|
206
|
-
'btn-ghost': this.ghost(),
|
|
207
|
-
'btn-outline': this.outline(),
|
|
208
|
-
'btn-soft': this.soft(),
|
|
209
|
-
'btn-dash': this.dash(),
|
|
210
|
-
'btn-circle': this.circle(),
|
|
211
|
-
'btn-square': this.square(),
|
|
212
|
-
glass: this.glass(),
|
|
213
|
-
'shadow-main': this.shadow(),
|
|
214
|
-
});
|
|
215
|
-
});
|
|
245
|
+
* Custom CSS classes
|
|
246
|
+
*/
|
|
247
|
+
class = input('');
|
|
216
248
|
/**
|
|
217
|
-
*
|
|
218
|
-
* Computed class string for the dropdown menu container
|
|
249
|
+
* Emitted when the radio state changes
|
|
219
250
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
checkedChange = output();
|
|
252
|
+
/**
|
|
253
|
+
* Emitted when the menu item is triggered/clicked
|
|
254
|
+
*/
|
|
255
|
+
triggered = output();
|
|
256
|
+
/**
|
|
257
|
+
* Computed data state for ARIA
|
|
258
|
+
*/
|
|
259
|
+
dataState = computed(() => {
|
|
260
|
+
return this.checked() ? 'checked' : 'unchecked';
|
|
225
261
|
});
|
|
226
262
|
/**
|
|
227
|
-
*
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
263
|
+
* Handle item click - select this radio option
|
|
264
|
+
*/
|
|
265
|
+
onItemClick() {
|
|
266
|
+
if (!this.disabled() && !this.checked()) {
|
|
267
|
+
this.checkedChange.emit(this.value());
|
|
268
|
+
this.triggered.emit();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Computed CSS classes for the menu item
|
|
273
|
+
*/
|
|
274
|
+
itemClass = () => cn('group', 'transition-colors', 'duration-200', {
|
|
275
|
+
'menu-disabled pointer-events-none opacity-50': this.disabled(),
|
|
276
|
+
'menu-active': this.checked(),
|
|
277
|
+
}, this.class());
|
|
278
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownItemRadioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
279
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.0", type: DropdownItemRadioComponent, isStandalone: true, selector: "st-dropdown-item-radio", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, indicator: { classPropertyName: "indicator", publicName: "indicator", isSignal: true, isRequired: false, transformFunction: null }, showIndicator: { classPropertyName: "showIndicator", publicName: "showIndicator", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "checkedChange", triggered: "triggered" }, ngImport: i0, template: "<li\n\t[class]=\"itemClass()\"\n\t[attr.data-state]=\"dataState()\"\n\t(click)=\"onItemClick()\"\n\t(keydown.enter)=\"onItemClick()\"\n\t(keydown.space)=\"onItemClick()\"\n\t[attr.tabindex]=\"disabled() ? -1 : 0\"\n\trole=\"menuitemradio\"\n\t[attr.aria-checked]=\"checked()\"\n\t[attr.aria-disabled]=\"disabled()\"\n>\n\t<a class=\"flex items-center justify-between\">\n\t\t<span class=\"flex-1\">\n\t\t\t<ng-content></ng-content>\n\t\t</span>\n\t\t@if (showIndicator()) {\n\t\t\t<span\n\t\t\t\tclass=\"ml-auto text-xs transition-opacity duration-300 ease-in-out group-aria-[checked=false]:opacity-0 group-aria-[checked=true]:opacity-100\"\n\t\t\t>\n\t\t\t\t{{ indicator() }}\n\t\t\t</span>\n\t\t}\n\t</a>\n</li>\n" });
|
|
280
|
+
}
|
|
281
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownItemRadioComponent, decorators: [{
|
|
282
|
+
type: Component,
|
|
283
|
+
args: [{ selector: 'st-dropdown-item-radio', standalone: true, imports: [], template: "<li\n\t[class]=\"itemClass()\"\n\t[attr.data-state]=\"dataState()\"\n\t(click)=\"onItemClick()\"\n\t(keydown.enter)=\"onItemClick()\"\n\t(keydown.space)=\"onItemClick()\"\n\t[attr.tabindex]=\"disabled() ? -1 : 0\"\n\trole=\"menuitemradio\"\n\t[attr.aria-checked]=\"checked()\"\n\t[attr.aria-disabled]=\"disabled()\"\n>\n\t<a class=\"flex items-center justify-between\">\n\t\t<span class=\"flex-1\">\n\t\t\t<ng-content></ng-content>\n\t\t</span>\n\t\t@if (showIndicator()) {\n\t\t\t<span\n\t\t\t\tclass=\"ml-auto text-xs transition-opacity duration-300 ease-in-out group-aria-[checked=false]:opacity-0 group-aria-[checked=true]:opacity-100\"\n\t\t\t>\n\t\t\t\t{{ indicator() }}\n\t\t\t</span>\n\t\t}\n\t</a>\n</li>\n" }]
|
|
284
|
+
}] });
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* DropdownTrigger - Trigger element for opening dropdown content
|
|
288
|
+
*
|
|
289
|
+
* @remarks
|
|
290
|
+
* This component acts as the trigger that opens/closes the dropdown content.
|
|
291
|
+
* It can contain any content (buttons, avatars, text, icons, etc.).
|
|
292
|
+
* Uses CdkConnectedOverlay for positioning and management.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```html
|
|
296
|
+
* <st-dropdown>
|
|
297
|
+
* <st-dropdown-trigger>
|
|
298
|
+
* <button class="btn btn-primary">
|
|
299
|
+
* Open Menu
|
|
300
|
+
* <st-icon [icon]="chevronDown"></st-icon>
|
|
301
|
+
* </button>
|
|
302
|
+
* </st-dropdown-trigger>
|
|
303
|
+
* <st-dropdown-content>
|
|
304
|
+
* <st-dropdown-item>Item 1</st-dropdown-item>
|
|
305
|
+
* </st-dropdown-content>
|
|
306
|
+
* </st-dropdown>
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
class DropdownTriggerComponent {
|
|
310
|
+
/** Offset X in pixels */
|
|
311
|
+
offsetX = input(0);
|
|
312
|
+
/** Offset Y in pixels */
|
|
313
|
+
offsetY = input(0);
|
|
314
|
+
/** Origin X position */
|
|
315
|
+
originX = input('start');
|
|
316
|
+
/** Origin Y position */
|
|
317
|
+
originY = input('bottom');
|
|
318
|
+
/** Overlay X position */
|
|
319
|
+
overlayX = input('start');
|
|
320
|
+
/** Overlay Y position */
|
|
321
|
+
overlayY = input('top');
|
|
322
|
+
/** Fallback positions configuration */
|
|
323
|
+
fallbacks = input({ enabled: true });
|
|
324
|
+
/** Event emitted when dropdown is opened */
|
|
325
|
+
opened = output();
|
|
326
|
+
/** Event emitted when dropdown is closed */
|
|
327
|
+
closed = output();
|
|
328
|
+
/** Current open state */
|
|
329
|
+
isOpen = signal(false);
|
|
330
|
+
/** Current active position configuration */
|
|
331
|
+
currentPosition = signal(null);
|
|
332
|
+
/** Content template reference */
|
|
333
|
+
contentTemplate = null;
|
|
334
|
+
/**
|
|
335
|
+
* Computed positions array based on signal inputs
|
|
336
|
+
*/
|
|
337
|
+
positions = computed(() => {
|
|
338
|
+
// Get current values and ensure they are strings
|
|
339
|
+
const originX = String(this.originX());
|
|
340
|
+
const originY = String(this.originY());
|
|
341
|
+
const overlayX = String(this.overlayX());
|
|
342
|
+
const overlayY = String(this.overlayY());
|
|
343
|
+
const offsetX = Number(this.offsetX());
|
|
344
|
+
const offsetY = Number(this.offsetY());
|
|
345
|
+
// Primary position using direct signal values
|
|
346
|
+
const primary = {
|
|
347
|
+
originX,
|
|
348
|
+
originY,
|
|
349
|
+
overlayX,
|
|
350
|
+
overlayY,
|
|
351
|
+
offsetX,
|
|
352
|
+
offsetY,
|
|
353
|
+
};
|
|
354
|
+
// If fallbacks are disabled, return only primary position
|
|
355
|
+
const fallbackConfig = this.fallbacks();
|
|
356
|
+
if (!fallbackConfig.enabled) {
|
|
357
|
+
return [primary];
|
|
358
|
+
}
|
|
359
|
+
// Use custom fallback positions if provided
|
|
360
|
+
if (fallbackConfig.positions && fallbackConfig.positions.length > 0) {
|
|
361
|
+
return [primary, ...fallbackConfig.positions];
|
|
362
|
+
}
|
|
363
|
+
// Generate default fallback positions
|
|
364
|
+
const fallbacks = this.generateDefaultFallbacks(primary);
|
|
365
|
+
return [primary, ...fallbacks];
|
|
237
366
|
});
|
|
238
367
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
368
|
+
* Generate default fallback positions based on the primary position
|
|
369
|
+
* Provides comprehensive fallback coverage for all space constraints
|
|
241
370
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
371
|
+
generateDefaultFallbacks(primary) {
|
|
372
|
+
const fallbacks = [];
|
|
373
|
+
const primaryOriginX = primary.originX;
|
|
374
|
+
const primaryOriginY = primary.originY;
|
|
375
|
+
const primaryOverlayX = primary.overlayX;
|
|
376
|
+
const primaryOverlayY = primary.overlayY;
|
|
377
|
+
// Add basic axis flips
|
|
378
|
+
this.addAxisFlips(fallbacks, primary, primaryOriginX, primaryOriginY, primaryOverlayX, primaryOverlayY);
|
|
379
|
+
// Add standard dropdown positions
|
|
380
|
+
this.addStandardPositions(fallbacks, primary);
|
|
381
|
+
// Add center alignment fallbacks
|
|
382
|
+
this.addCenterFallbacks(fallbacks, primary, primaryOriginX, primaryOriginY, primaryOverlayX, primaryOverlayY);
|
|
383
|
+
return fallbacks;
|
|
245
384
|
}
|
|
246
385
|
/**
|
|
247
|
-
*
|
|
248
|
-
|
|
386
|
+
* Helper to flip Y position
|
|
387
|
+
*/
|
|
388
|
+
getOppositeY(position) {
|
|
389
|
+
if (position === 'top')
|
|
390
|
+
return 'bottom';
|
|
391
|
+
if (position === 'bottom')
|
|
392
|
+
return 'top';
|
|
393
|
+
return 'center';
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Helper to flip X position
|
|
249
397
|
*/
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
398
|
+
getOppositeX(position) {
|
|
399
|
+
if (position === 'start')
|
|
400
|
+
return 'end';
|
|
401
|
+
if (position === 'end')
|
|
402
|
+
return 'start';
|
|
403
|
+
return 'center';
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Helper to create position variant
|
|
407
|
+
*/
|
|
408
|
+
createPosition(primary, originX, originY, overlayX, overlayY) {
|
|
409
|
+
return {
|
|
410
|
+
...primary,
|
|
411
|
+
originX,
|
|
412
|
+
originY,
|
|
413
|
+
overlayX,
|
|
414
|
+
overlayY,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Add axis flip fallbacks
|
|
419
|
+
*/
|
|
420
|
+
addAxisFlips(fallbacks, primary, primaryOriginX, primaryOriginY, primaryOverlayX, primaryOverlayY) {
|
|
421
|
+
// Flip Y axis
|
|
422
|
+
const oppositeY = this.getOppositeY(primaryOriginY);
|
|
423
|
+
const oppositeOverlayY = this.getOppositeY(primaryOverlayY);
|
|
424
|
+
fallbacks.push(this.createPosition(primary, primaryOriginX, oppositeY, primaryOverlayX, oppositeOverlayY));
|
|
425
|
+
// Flip X axis
|
|
426
|
+
const oppositeX = this.getOppositeX(primaryOriginX);
|
|
427
|
+
const oppositeOverlayX = this.getOppositeX(primaryOverlayX);
|
|
428
|
+
fallbacks.push(this.createPosition(primary, oppositeX, primaryOriginY, oppositeOverlayX, primaryOverlayY));
|
|
429
|
+
// Flip both axes
|
|
430
|
+
fallbacks.push(this.createPosition(primary, oppositeX, oppositeY, oppositeOverlayX, oppositeOverlayY));
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Add standard dropdown positions
|
|
434
|
+
*/
|
|
435
|
+
addStandardPositions(fallbacks, primary) {
|
|
436
|
+
const standardPositions = [
|
|
437
|
+
this.createPosition(primary, 'start', 'bottom', 'start', 'top'), // Classic dropdown
|
|
438
|
+
this.createPosition(primary, 'start', 'top', 'start', 'bottom'), // Dropup
|
|
439
|
+
this.createPosition(primary, 'end', 'top', 'start', 'top'), // Left side
|
|
440
|
+
this.createPosition(primary, 'start', 'top', 'end', 'top'), // Right side
|
|
441
|
+
this.createPosition(primary, 'center', 'bottom', 'center', 'top'), // Center dropdown
|
|
442
|
+
this.createPosition(primary, 'center', 'top', 'center', 'bottom'), // Center dropup
|
|
443
|
+
];
|
|
444
|
+
for (const pos of standardPositions) {
|
|
445
|
+
if (!this.isPositionDuplicate(pos, [primary, ...fallbacks])) {
|
|
446
|
+
fallbacks.push(pos);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Add center alignment fallbacks
|
|
452
|
+
*/
|
|
453
|
+
addCenterFallbacks(fallbacks, primary, primaryOriginX, primaryOriginY, primaryOverlayX, primaryOverlayY) {
|
|
454
|
+
// Center horizontally
|
|
455
|
+
if (primaryOriginX !== 'center' || primaryOverlayX !== 'center') {
|
|
456
|
+
fallbacks.push(this.createPosition(primary, 'center', primaryOriginY, 'center', primaryOverlayY));
|
|
457
|
+
}
|
|
458
|
+
// Center vertically
|
|
459
|
+
if (primaryOriginY !== 'center' || primaryOverlayY !== 'center') {
|
|
460
|
+
fallbacks.push(this.createPosition(primary, primaryOriginX, 'center', primaryOverlayX, 'center'));
|
|
461
|
+
}
|
|
462
|
+
// Fully centered as last resort
|
|
463
|
+
const fullyCentered = this.createPosition(primary, 'center', 'center', 'center', 'center');
|
|
464
|
+
if (!this.isPositionDuplicate(fullyCentered, [primary, ...fallbacks])) {
|
|
465
|
+
fallbacks.push(fullyCentered);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Check if position is duplicate
|
|
470
|
+
*/
|
|
471
|
+
isPositionDuplicate(position, existing) {
|
|
472
|
+
return existing.some((pos) => pos.originX === position.originX &&
|
|
473
|
+
pos.originY === position.originY &&
|
|
474
|
+
pos.overlayX === position.overlayX &&
|
|
475
|
+
pos.overlayY === position.overlayY);
|
|
476
|
+
} /**
|
|
477
|
+
* Set the content template to be displayed in the overlay
|
|
478
|
+
*/
|
|
479
|
+
setContentTemplate(template) {
|
|
480
|
+
this.contentTemplate = template;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Toggle the dropdown open/close state
|
|
484
|
+
*/
|
|
485
|
+
toggle() {
|
|
486
|
+
if (this.isOpen()) {
|
|
487
|
+
this.close();
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
this.open();
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Open the dropdown
|
|
495
|
+
*/
|
|
496
|
+
open() {
|
|
497
|
+
if (this.isOpen() || !this.contentTemplate)
|
|
498
|
+
return;
|
|
499
|
+
this.isOpen.set(true);
|
|
500
|
+
this.opened.emit();
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Close the dropdown
|
|
504
|
+
*/
|
|
505
|
+
close() {
|
|
506
|
+
if (!this.isOpen())
|
|
507
|
+
return;
|
|
508
|
+
this.isOpen.set(false);
|
|
509
|
+
this.closed.emit();
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Handle position changes from CDK overlay
|
|
513
|
+
*/
|
|
514
|
+
onPositionChange(position) {
|
|
515
|
+
if (position?.connectionPair) {
|
|
516
|
+
this.currentPosition.set(position.connectionPair);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownTriggerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
520
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.0", type: DropdownTriggerComponent, isStandalone: true, selector: "st-dropdown-trigger", inputs: { offsetX: { classPropertyName: "offsetX", publicName: "offsetX", isSignal: true, isRequired: false, transformFunction: null }, offsetY: { classPropertyName: "offsetY", publicName: "offsetY", isSignal: true, isRequired: false, transformFunction: null }, originX: { classPropertyName: "originX", publicName: "originX", isSignal: true, isRequired: false, transformFunction: null }, originY: { classPropertyName: "originY", publicName: "originY", isSignal: true, isRequired: false, transformFunction: null }, overlayX: { classPropertyName: "overlayX", publicName: "overlayX", isSignal: true, isRequired: false, transformFunction: null }, overlayY: { classPropertyName: "overlayY", publicName: "overlayY", isSignal: true, isRequired: false, transformFunction: null }, fallbacks: { classPropertyName: "fallbacks", publicName: "fallbacks", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { opened: "opened", closed: "closed" }, ngImport: i0, template: "<div\n\tcdkOverlayOrigin\n\t#trigger=\"cdkOverlayOrigin\"\n\tclass=\"inline-flex cursor-pointer items-center\"\n\t(click)=\"toggle()\"\n\t(keydown.enter)=\"toggle()\"\n\t(keydown.space)=\"toggle(); $event.preventDefault()\"\n\t[attr.aria-expanded]=\"isOpen()\"\n\t[attr.aria-haspopup]=\"true\"\n\ttabindex=\"0\"\n\trole=\"button\"\n>\n\t<ng-content></ng-content>\n</div>\n\n<ng-template\n\tcdkConnectedOverlay\n\t[cdkConnectedOverlayPositions]=\"positions()\"\n\t[cdkConnectedOverlayOrigin]=\"trigger\"\n\t[cdkConnectedOverlayOpen]=\"isOpen()\"\n\t[cdkConnectedOverlayHasBackdrop]=\"true\"\n\t[cdkConnectedOverlayBackdropClass]=\"'cdk-overlay-transparent-backdrop'\"\n\t(backdropClick)=\"close()\"\n\t(detach)=\"close()\"\n\t(positionChange)=\"onPositionChange($event)\"\n>\n\t<ng-container *ngTemplateOutlet=\"contentTemplate\"></ng-container>\n</ng-template>\n", dependencies: [{ kind: "directive", type: CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
521
|
+
}
|
|
522
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownTriggerComponent, decorators: [{
|
|
523
|
+
type: Component,
|
|
524
|
+
args: [{ selector: 'st-dropdown-trigger', standalone: true, imports: [CdkConnectedOverlay, CdkOverlayOrigin, NgTemplateOutlet], template: "<div\n\tcdkOverlayOrigin\n\t#trigger=\"cdkOverlayOrigin\"\n\tclass=\"inline-flex cursor-pointer items-center\"\n\t(click)=\"toggle()\"\n\t(keydown.enter)=\"toggle()\"\n\t(keydown.space)=\"toggle(); $event.preventDefault()\"\n\t[attr.aria-expanded]=\"isOpen()\"\n\t[attr.aria-haspopup]=\"true\"\n\ttabindex=\"0\"\n\trole=\"button\"\n>\n\t<ng-content></ng-content>\n</div>\n\n<ng-template\n\tcdkConnectedOverlay\n\t[cdkConnectedOverlayPositions]=\"positions()\"\n\t[cdkConnectedOverlayOrigin]=\"trigger\"\n\t[cdkConnectedOverlayOpen]=\"isOpen()\"\n\t[cdkConnectedOverlayHasBackdrop]=\"true\"\n\t[cdkConnectedOverlayBackdropClass]=\"'cdk-overlay-transparent-backdrop'\"\n\t(backdropClick)=\"close()\"\n\t(detach)=\"close()\"\n\t(positionChange)=\"onPositionChange($event)\"\n>\n\t<ng-container *ngTemplateOutlet=\"contentTemplate\"></ng-container>\n</ng-template>\n" }]
|
|
525
|
+
}] });
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Dropdown - Main container component for dropdown menus
|
|
529
|
+
*
|
|
530
|
+
* @remarks
|
|
531
|
+
* This is the root container that provides a wrapper for trigger and content components.
|
|
532
|
+
* The trigger and content components coordinate themselves through this parent component.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```html
|
|
536
|
+
* <st-dropdown>
|
|
537
|
+
* <st-dropdown-trigger [showChevron]="true">
|
|
538
|
+
* <button class="btn btn-primary">Open Menu</button>
|
|
539
|
+
* </st-dropdown-trigger>
|
|
540
|
+
* <st-dropdown-content>
|
|
541
|
+
* <st-dropdown-item>Item 1</st-dropdown-item>
|
|
542
|
+
* <st-dropdown-item>Item 2</st-dropdown-item>
|
|
543
|
+
* </st-dropdown-content>
|
|
544
|
+
* </st-dropdown>
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
class DropdownComponent {
|
|
548
|
+
dropdownService = inject(DropdownService);
|
|
549
|
+
trigger;
|
|
550
|
+
content;
|
|
551
|
+
ngAfterContentInit() {
|
|
552
|
+
// Connect trigger and content after they're available
|
|
553
|
+
if (this.trigger && this.content) {
|
|
554
|
+
this.trigger.setContentTemplate(this.content.template);
|
|
555
|
+
// Listen for close requests from content
|
|
556
|
+
this.content.closeRequested.subscribe(() => {
|
|
557
|
+
this.trigger.close();
|
|
558
|
+
});
|
|
559
|
+
// Sync trigger state with service
|
|
560
|
+
this.trigger.opened.subscribe(() => {
|
|
561
|
+
this.dropdownService.setOpen(true);
|
|
562
|
+
});
|
|
563
|
+
this.trigger.closed.subscribe(() => {
|
|
564
|
+
this.dropdownService.setOpen(false);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
253
567
|
}
|
|
254
568
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
255
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
569
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.0", type: DropdownComponent, isStandalone: true, selector: "st-dropdown", providers: [DropdownService], queries: [{ propertyName: "trigger", first: true, predicate: DropdownTriggerComponent, descendants: true }, { propertyName: "content", first: true, predicate: DropdownContentComponent, descendants: true }], ngImport: i0, template: "<ng-content></ng-content>\n" });
|
|
256
570
|
}
|
|
257
571
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownComponent, decorators: [{
|
|
258
572
|
type: Component,
|
|
259
|
-
args: [{ selector: 'st-dropdown',
|
|
260
|
-
}]
|
|
573
|
+
args: [{ selector: 'st-dropdown', standalone: true, providers: [DropdownService], template: "<ng-content></ng-content>\n" }]
|
|
574
|
+
}], propDecorators: { trigger: [{
|
|
575
|
+
type: ContentChild,
|
|
576
|
+
args: [DropdownTriggerComponent]
|
|
577
|
+
}], content: [{
|
|
578
|
+
type: ContentChild,
|
|
579
|
+
args: [DropdownContentComponent]
|
|
580
|
+
}] } });
|
|
261
581
|
|
|
262
582
|
/**
|
|
263
583
|
* A selectable item component for use within dropdown menus
|
|
264
584
|
*
|
|
265
585
|
* @remarks
|
|
266
|
-
* Designed to be used inside `<st-dropdown>` components. Handles selection events
|
|
586
|
+
* Designed to be used inside `<st-dropdown-content>` components. Handles selection events
|
|
267
587
|
* and automatically closes the parent dropdown when clicked.
|
|
268
588
|
*
|
|
269
589
|
* @example
|
|
@@ -276,45 +596,104 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImpor
|
|
|
276
596
|
*
|
|
277
597
|
* @example
|
|
278
598
|
* ```html
|
|
279
|
-
* <st-dropdown-item class="custom-item-style" (selected)="logSelection()">
|
|
280
|
-
*
|
|
599
|
+
* <st-dropdown-item class="custom-item-style" (selected)="logSelection()" [disabled]="true">
|
|
600
|
+
* Disabled item
|
|
281
601
|
* </st-dropdown-item>
|
|
282
602
|
* ```
|
|
283
603
|
*/
|
|
284
604
|
class DropdownItemComponent {
|
|
285
|
-
dropdown;
|
|
605
|
+
dropdown = inject(DropdownComponent, { optional: true });
|
|
286
606
|
/**
|
|
287
|
-
*
|
|
607
|
+
* Whether the menu item is active
|
|
288
608
|
*/
|
|
289
|
-
|
|
609
|
+
active = input(false);
|
|
290
610
|
/**
|
|
291
|
-
*
|
|
292
|
-
* Reference to parent dropdown component
|
|
611
|
+
* Custom CSS classes
|
|
293
612
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
613
|
+
class = input('');
|
|
614
|
+
/**
|
|
615
|
+
* Whether the item is disabled
|
|
616
|
+
* @defaultValue false
|
|
617
|
+
*/
|
|
618
|
+
disabled = input(false);
|
|
619
|
+
/**
|
|
620
|
+
* Event emitted when the item is selected
|
|
621
|
+
*/
|
|
622
|
+
selected = output();
|
|
297
623
|
/**
|
|
298
624
|
* @internal
|
|
299
625
|
* Handles item selection and dropdown state
|
|
300
626
|
*/
|
|
301
627
|
handleSelect() {
|
|
628
|
+
if (this.disabled())
|
|
629
|
+
return;
|
|
302
630
|
this.selected.emit();
|
|
303
|
-
this.dropdown
|
|
631
|
+
this.dropdown?.trigger?.close();
|
|
304
632
|
}
|
|
305
|
-
|
|
306
|
-
|
|
633
|
+
/**
|
|
634
|
+
* Computed CSS classes for the menu item
|
|
635
|
+
*/
|
|
636
|
+
itemClass = () => cn('transition-colors', 'duration-200', {
|
|
637
|
+
'menu-disabled pointer-events-none opacity-50': this.disabled(),
|
|
638
|
+
'menu-active': this.active(),
|
|
639
|
+
}, this.class());
|
|
640
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
641
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.0", type: DropdownItemComponent, isStandalone: true, selector: "st-dropdown-item", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected" }, ngImport: i0, template: "<li\n\t[class]=\"itemClass()\"\n\t(click)=\"handleSelect()\"\n\t(keydown.enter)=\"handleSelect()\"\n\t(keydown.space)=\"handleSelect(); $event.preventDefault()\"\n\t[attr.tabindex]=\"disabled() ? -1 : 0\"\n\trole=\"menuitem\"\n\t[attr.aria-disabled]=\"disabled()\"\n>\n\t<a>\n\t\t<ng-content></ng-content>\n\t</a>\n</li>\n" });
|
|
307
642
|
}
|
|
308
643
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownItemComponent, decorators: [{
|
|
309
644
|
type: Component,
|
|
310
|
-
args: [{ selector: 'st-dropdown-item', standalone: true, template: "
|
|
311
|
-
}]
|
|
312
|
-
|
|
313
|
-
|
|
645
|
+
args: [{ selector: 'st-dropdown-item', standalone: true, template: "<li\n\t[class]=\"itemClass()\"\n\t(click)=\"handleSelect()\"\n\t(keydown.enter)=\"handleSelect()\"\n\t(keydown.space)=\"handleSelect(); $event.preventDefault()\"\n\t[attr.tabindex]=\"disabled() ? -1 : 0\"\n\trole=\"menuitem\"\n\t[attr.aria-disabled]=\"disabled()\"\n>\n\t<a>\n\t\t<ng-content></ng-content>\n\t</a>\n</li>\n" }]
|
|
646
|
+
}] });
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* DropdownLabel - Label for dropdown sections
|
|
650
|
+
* Provides section headers for dropdown content
|
|
651
|
+
*/
|
|
652
|
+
class DropdownLabelComponent {
|
|
653
|
+
/**
|
|
654
|
+
* Custom CSS classes
|
|
655
|
+
*/
|
|
656
|
+
class = input('');
|
|
657
|
+
/**
|
|
658
|
+
* Computed CSS classes for the label
|
|
659
|
+
*/
|
|
660
|
+
labelClass = () => cn('menu-title', this.class());
|
|
661
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
662
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.0", type: DropdownLabelComponent, isStandalone: true, selector: "st-dropdown-label", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div [class]=\"labelClass()\">\n\t<ng-content></ng-content>\n</div>\n" });
|
|
663
|
+
}
|
|
664
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownLabelComponent, decorators: [{
|
|
665
|
+
type: Component,
|
|
666
|
+
args: [{ selector: 'st-dropdown-label', standalone: true, template: "<div [class]=\"labelClass()\">\n\t<ng-content></ng-content>\n</div>\n" }]
|
|
667
|
+
}] });
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* DropdownSeparator - Visual separator for dropdown menu sections
|
|
671
|
+
*
|
|
672
|
+
* @remarks
|
|
673
|
+
* A simple horizontal divider to separate groups of dropdown items.
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```html
|
|
677
|
+
* <st-dropdown-content>
|
|
678
|
+
* <st-dropdown-item>Item 1</st-dropdown-item>
|
|
679
|
+
* <st-dropdown-item>Item 2</st-dropdown-item>
|
|
680
|
+
* <st-dropdown-separator></st-dropdown-separator>
|
|
681
|
+
* <st-dropdown-item>Item 3</st-dropdown-item>
|
|
682
|
+
* </st-dropdown-content>
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
class DropdownSeparatorComponent {
|
|
686
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownSeparatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
687
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.0", type: DropdownSeparatorComponent, isStandalone: true, selector: "st-dropdown-separator", ngImport: i0, template: "<li class=\"pointer-events-none top-0 left-0 mx-0 my-1 w-full p-0\"></li>\n" });
|
|
688
|
+
}
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: DropdownSeparatorComponent, decorators: [{
|
|
690
|
+
type: Component,
|
|
691
|
+
args: [{ selector: 'st-dropdown-separator', standalone: true, template: "<li class=\"pointer-events-none top-0 left-0 mx-0 my-1 w-full p-0\"></li>\n" }]
|
|
692
|
+
}] });
|
|
314
693
|
|
|
315
694
|
/**
|
|
316
695
|
* Generated bundle index. Do not edit.
|
|
317
696
|
*/
|
|
318
697
|
|
|
319
|
-
export { DropdownComponent, DropdownItemComponent,
|
|
698
|
+
export { DropdownChevronComponent, DropdownComponent, DropdownContentComponent, DropdownGroupComponent, DropdownItemCheckboxComponent, DropdownItemComponent, DropdownItemRadioComponent, DropdownLabelComponent, DropdownSeparatorComponent, DropdownService, DropdownTriggerComponent };
|
|
320
699
|
//# sourceMappingURL=sixbell-telco-sdk-components-dropdown.mjs.map
|