ng-primitives 0.0.5
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/README.md +7 -0
- package/a11y/README.md +3 -0
- package/a11y/index.d.ts +8 -0
- package/a11y/visually-hidden/visually-hidden.directive.d.ts +5 -0
- package/accordion/README.md +3 -0
- package/accordion/accordion/accordion.directive.d.ts +45 -0
- package/accordion/accordion/accordion.token.d.ts +15 -0
- package/accordion/accordion-content/accordion-content.directive.d.ts +25 -0
- package/accordion/accordion-content/accordion-content.token.d.ts +15 -0
- package/accordion/accordion-item/accordion-item.directive.d.ts +45 -0
- package/accordion/accordion-item/accordion-item.token.d.ts +15 -0
- package/accordion/accordion-trigger/accordion-trigger.directive.d.ts +21 -0
- package/accordion/accordion-trigger/accordion-trigger.token.d.ts +15 -0
- package/accordion/config/accordion.config.d.ts +39 -0
- package/accordion/index.d.ts +16 -0
- package/avatar/README.md +3 -0
- package/avatar/avatar/avatar.directive.d.ts +22 -0
- package/avatar/avatar/avatar.token.d.ts +15 -0
- package/avatar/avatar-fallback/avatar-fallback.directive.d.ts +45 -0
- package/avatar/avatar-image/avatar-image.directive.d.ts +28 -0
- package/avatar/config/avatar.config.d.ts +28 -0
- package/avatar/index.d.ts +12 -0
- package/checkbox/README.md +3 -0
- package/checkbox/checkbox/checkbox.directive.d.ts +89 -0
- package/checkbox/checkbox/checkbox.token.d.ts +15 -0
- package/checkbox/checkbox-indicator/checkbox-indicator.directive.d.ts +19 -0
- package/checkbox/checkbox-indicator/checkbox-indicator.token.d.ts +15 -0
- package/checkbox/checkbox-input/checkbox-input.directive.d.ts +10 -0
- package/checkbox/checkbox-label/checkbox-label.directive.d.ts +9 -0
- package/checkbox/index.d.ts +13 -0
- package/esm2022/a11y/index.mjs +9 -0
- package/esm2022/a11y/ng-primitives-a11y.mjs +5 -0
- package/esm2022/a11y/visually-hidden/visually-hidden.directive.mjs +25 -0
- package/esm2022/accordion/accordion/accordion.directive.mjs +90 -0
- package/esm2022/accordion/accordion/accordion.token.mjs +17 -0
- package/esm2022/accordion/accordion-content/accordion-content.directive.mjs +55 -0
- package/esm2022/accordion/accordion-content/accordion-content.token.mjs +17 -0
- package/esm2022/accordion/accordion-item/accordion-item.directive.mjs +64 -0
- package/esm2022/accordion/accordion-item/accordion-item.token.mjs +17 -0
- package/esm2022/accordion/accordion-trigger/accordion-trigger.directive.mjs +58 -0
- package/esm2022/accordion/accordion-trigger/accordion-trigger.token.mjs +17 -0
- package/esm2022/accordion/config/accordion.config.mjs +35 -0
- package/esm2022/accordion/index.mjs +17 -0
- package/esm2022/accordion/ng-primitives-accordion.mjs +5 -0
- package/esm2022/avatar/avatar/avatar.directive.mjs +45 -0
- package/esm2022/avatar/avatar/avatar.token.mjs +17 -0
- package/esm2022/avatar/avatar-fallback/avatar-fallback.directive.mjs +61 -0
- package/esm2022/avatar/avatar-image/avatar-image.directive.mjs +64 -0
- package/esm2022/avatar/config/avatar.config.mjs +33 -0
- package/esm2022/avatar/index.mjs +13 -0
- package/esm2022/avatar/ng-primitives-avatar.mjs +5 -0
- package/esm2022/checkbox/checkbox/checkbox.directive.mjs +141 -0
- package/esm2022/checkbox/checkbox/checkbox.token.mjs +17 -0
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.directive.mjs +51 -0
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.token.mjs +17 -0
- package/esm2022/checkbox/checkbox-input/checkbox-input.directive.mjs +40 -0
- package/esm2022/checkbox/checkbox-label/checkbox-label.directive.mjs +32 -0
- package/esm2022/checkbox/index.mjs +14 -0
- package/esm2022/checkbox/ng-primitives-checkbox.mjs +5 -0
- package/esm2022/index.mjs +10 -0
- package/esm2022/ng-primitives.mjs +5 -0
- package/esm2022/progress/index.mjs +10 -0
- package/esm2022/progress/ng-primitives-progress.mjs +5 -0
- package/esm2022/progress/progress/progress.directive.mjs +60 -0
- package/esm2022/progress/progress/progress.token.mjs +16 -0
- package/esm2022/progress/progress-indicator/progress-indicator.directive.mjs +33 -0
- package/esm2022/radio/index.mjs +13 -0
- package/esm2022/radio/ng-primitives-radio.mjs +5 -0
- package/esm2022/radio/radio-group/radio-group.directive.mjs +100 -0
- package/esm2022/radio/radio-group/radio-group.token.mjs +17 -0
- package/esm2022/radio/radio-indicator/radio-indicator.directive.mjs +41 -0
- package/esm2022/radio/radio-item/radio-item.directive.mjs +68 -0
- package/esm2022/radio/radio-item/radio-item.token.mjs +17 -0
- package/esm2022/resize/index.mjs +10 -0
- package/esm2022/resize/ng-primitives-resize.mjs +5 -0
- package/esm2022/resize/resize/resize.directive.mjs +49 -0
- package/esm2022/resize/utils/resize.mjs +41 -0
- package/esm2022/roving-focus/index.mjs +12 -0
- package/esm2022/roving-focus/ng-primitives-roving-focus.mjs +5 -0
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.directive.mjs +244 -0
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.token.mjs +17 -0
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.directive.mjs +98 -0
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.token.mjs +17 -0
- package/esm2022/select/index.mjs +16 -0
- package/esm2022/select/ng-primitives-select.mjs +5 -0
- package/esm2022/select/select/select.directive.mjs +54 -0
- package/esm2022/select/select/select.token.mjs +16 -0
- package/esm2022/select/select-button/select-button.directive.mjs +84 -0
- package/esm2022/select/select-button/select-button.token.mjs +16 -0
- package/esm2022/select/select-option/select-option.directive.mjs +90 -0
- package/esm2022/select/select-option/select-option.token.mjs +16 -0
- package/esm2022/select/select-options/select-options.directive.mjs +157 -0
- package/esm2022/select/select-options/select-options.token.mjs +16 -0
- package/esm2022/slider/index.mjs +16 -0
- package/esm2022/slider/ng-primitives-slider.mjs +5 -0
- package/esm2022/slider/slider/slider.directive.mjs +68 -0
- package/esm2022/slider/slider/slider.token.mjs +16 -0
- package/esm2022/slider/slider-range/slider-range.directive.mjs +36 -0
- package/esm2022/slider/slider-range/slider-range.token.mjs +16 -0
- package/esm2022/slider/slider-thumb/slider-thumb.directive.mjs +109 -0
- package/esm2022/slider/slider-thumb/slider-thumb.token.mjs +16 -0
- package/esm2022/slider/slider-track/slider-track.directive.mjs +54 -0
- package/esm2022/slider/slider-track/slider-track.token.mjs +16 -0
- package/esm2022/switch/index.mjs +11 -0
- package/esm2022/switch/ng-primitives-switch.mjs +5 -0
- package/esm2022/switch/switch/switch.directive.mjs +126 -0
- package/esm2022/switch/switch/switch.token.mjs +17 -0
- package/esm2022/switch/switch-thumb/switch-thumb.directive.mjs +32 -0
- package/esm2022/tabs/config/tabs.config.mjs +35 -0
- package/esm2022/tabs/index.mjs +15 -0
- package/esm2022/tabs/ng-primitives-tabs.mjs +5 -0
- package/esm2022/tabs/tab-button/tab-button.directive.mjs +84 -0
- package/esm2022/tabs/tab-list/tab-list.directive.mjs +34 -0
- package/esm2022/tabs/tab-panel/tab-panel.directive.mjs +62 -0
- package/esm2022/tabs/tab-panel/tab-panel.token.mjs +17 -0
- package/esm2022/tabs/tabset/tabset.directive.mjs +91 -0
- package/esm2022/tabs/tabset/tabset.token.mjs +17 -0
- package/esm2022/toggle/index.mjs +9 -0
- package/esm2022/toggle/ng-primitives-toggle.mjs +5 -0
- package/esm2022/toggle/toggle/toggle.directive.mjs +48 -0
- package/esm2022/tooltip/config/tooltip.config.mjs +38 -0
- package/esm2022/tooltip/index.mjs +13 -0
- package/esm2022/tooltip/ng-primitives-tooltip.mjs +5 -0
- package/esm2022/tooltip/tooltip/tooltip.directive.mjs +57 -0
- package/esm2022/tooltip/tooltip/tooltip.token.mjs +16 -0
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.directive.mjs +190 -0
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.token.mjs +23 -0
- package/esm2022/utils/helpers/disposables.mjs +72 -0
- package/esm2022/utils/helpers/focus-manager.mjs +28 -0
- package/esm2022/utils/helpers/unique-id.mjs +22 -0
- package/esm2022/utils/hover/hover.directive.mjs +183 -0
- package/esm2022/utils/hover/hover.token.mjs +16 -0
- package/esm2022/utils/index.mjs +14 -0
- package/esm2022/utils/ng-primitives-utils.mjs +5 -0
- package/esm2022/utils/ui/dimensions.mjs +40 -0
- package/fesm2022/ng-primitives-a11y.mjs +40 -0
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -0
- package/fesm2022/ng-primitives-accordion.mjs +361 -0
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -0
- package/fesm2022/ng-primitives-avatar.mjs +223 -0
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -0
- package/fesm2022/ng-primitives-checkbox.mjs +299 -0
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -0
- package/fesm2022/ng-primitives-progress.mjs +119 -0
- package/fesm2022/ng-primitives-progress.mjs.map +1 -0
- package/fesm2022/ng-primitives-radio.mjs +245 -0
- package/fesm2022/ng-primitives-radio.mjs.map +1 -0
- package/fesm2022/ng-primitives-resize.mjs +104 -0
- package/fesm2022/ng-primitives-resize.mjs.map +1 -0
- package/fesm2022/ng-primitives-roving-focus.mjs +384 -0
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -0
- package/fesm2022/ng-primitives-select.mjs +442 -0
- package/fesm2022/ng-primitives-select.mjs.map +1 -0
- package/fesm2022/ng-primitives-slider.mjs +328 -0
- package/fesm2022/ng-primitives-slider.mjs.map +1 -0
- package/fesm2022/ng-primitives-switch.mjs +185 -0
- package/fesm2022/ng-primitives-switch.mjs.map +1 -0
- package/fesm2022/ng-primitives-tabs.mjs +337 -0
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -0
- package/fesm2022/ng-primitives-toggle.mjs +63 -0
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -0
- package/fesm2022/ng-primitives-tooltip.mjs +330 -0
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -0
- package/fesm2022/ng-primitives-utils.mjs +370 -0
- package/fesm2022/ng-primitives-utils.mjs.map +1 -0
- package/fesm2022/ng-primitives.mjs +14 -0
- package/fesm2022/ng-primitives.mjs.map +1 -0
- package/index.d.ts +9 -0
- package/package.json +120 -0
- package/progress/README.md +3 -0
- package/progress/index.d.ts +9 -0
- package/progress/progress/progress.directive.d.ts +40 -0
- package/progress/progress/progress.token.d.ts +14 -0
- package/progress/progress-indicator/progress-indicator.directive.d.ts +9 -0
- package/radio/README.md +3 -0
- package/radio/index.d.ts +12 -0
- package/radio/radio-group/radio-group.directive.d.ts +71 -0
- package/radio/radio-group/radio-group.token.d.ts +15 -0
- package/radio/radio-indicator/radio-indicator.directive.d.ts +17 -0
- package/radio/radio-item/radio-item.directive.d.ts +41 -0
- package/radio/radio-item/radio-item.token.d.ts +15 -0
- package/resize/README.md +3 -0
- package/resize/index.d.ts +9 -0
- package/resize/resize/resize.directive.d.ts +31 -0
- package/resize/utils/resize.d.ts +18 -0
- package/roving-focus/README.md +3 -0
- package/roving-focus/index.d.ts +11 -0
- package/roving-focus/roving-focus-group/roving-focus-group.directive.d.ts +94 -0
- package/roving-focus/roving-focus-group/roving-focus-group.token.d.ts +15 -0
- package/roving-focus/roving-focus-item/roving-focus-item.directive.d.ts +57 -0
- package/roving-focus/roving-focus-item/roving-focus-item.token.d.ts +15 -0
- package/select/README.md +3 -0
- package/select/index.d.ts +15 -0
- package/select/select/select.directive.d.ts +35 -0
- package/select/select/select.token.d.ts +14 -0
- package/select/select-button/select-button.directive.d.ts +51 -0
- package/select/select-button/select-button.token.d.ts +14 -0
- package/select/select-option/select-option.directive.d.ts +57 -0
- package/select/select-option/select-option.token.d.ts +14 -0
- package/select/select-options/select-options.directive.d.ts +65 -0
- package/select/select-options/select-options.token.d.ts +14 -0
- package/slider/README.md +3 -0
- package/slider/index.d.ts +15 -0
- package/slider/slider/slider.directive.d.ts +45 -0
- package/slider/slider/slider.token.d.ts +14 -0
- package/slider/slider-range/slider-range.directive.d.ts +9 -0
- package/slider/slider-range/slider-range.token.d.ts +14 -0
- package/slider/slider-thumb/slider-thumb.directive.d.ts +21 -0
- package/slider/slider-thumb/slider-thumb.token.d.ts +14 -0
- package/slider/slider-track/slider-track.directive.d.ts +26 -0
- package/slider/slider-track/slider-track.token.d.ts +14 -0
- package/switch/README.md +3 -0
- package/switch/index.d.ts +10 -0
- package/switch/switch/switch.directive.d.ts +82 -0
- package/switch/switch/switch.token.d.ts +15 -0
- package/switch/switch-thumb/switch-thumb.directive.d.ts +9 -0
- package/tabs/README.md +3 -0
- package/tabs/config/tabs.config.d.ts +38 -0
- package/tabs/index.d.ts +14 -0
- package/tabs/tab-button/tab-button.directive.d.ts +54 -0
- package/tabs/tab-list/tab-list.directive.d.ts +9 -0
- package/tabs/tab-panel/tab-panel.directive.d.ts +32 -0
- package/tabs/tab-panel/tab-panel.token.d.ts +15 -0
- package/tabs/tabset/tabset.directive.d.ts +53 -0
- package/tabs/tabset/tabset.token.d.ts +15 -0
- package/toggle/README.md +3 -0
- package/toggle/index.d.ts +8 -0
- package/toggle/toggle/toggle.directive.d.ts +27 -0
- package/tooltip/README.md +3 -0
- package/tooltip/config/tooltip.config.d.ts +54 -0
- package/tooltip/index.d.ts +12 -0
- package/tooltip/tooltip/tooltip.directive.d.ts +30 -0
- package/tooltip/tooltip/tooltip.token.d.ts +14 -0
- package/tooltip/tooltip-trigger/tooltip-trigger.directive.d.ts +111 -0
- package/tooltip/tooltip-trigger/tooltip-trigger.token.d.ts +22 -0
- package/utils/README.md +3 -0
- package/utils/helpers/disposables.d.ts +40 -0
- package/utils/helpers/focus-manager.d.ts +19 -0
- package/utils/helpers/unique-id.d.ts +13 -0
- package/utils/hover/hover.directive.d.ts +62 -0
- package/utils/hover/hover.token.d.ts +14 -0
- package/utils/index.d.ts +13 -0
- package/utils/ui/dimensions.d.ts +9 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, booleanAttribute, computed, Directive, HostListener, model, contentChildren } from '@angular/core';
|
|
3
|
+
import * as i1 from 'ng-primitives/roving-focus';
|
|
4
|
+
import { NgpRovingFocusItem, injectRovingFocusGroup, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';
|
|
5
|
+
import { uniqueId } from 'ng-primitives/utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright © 2024 Angular Primitives.
|
|
9
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
const defaultTabsConfig = {
|
|
15
|
+
orientation: 'horizontal',
|
|
16
|
+
activateOnFocus: true,
|
|
17
|
+
wrap: true,
|
|
18
|
+
};
|
|
19
|
+
const NgpTabsConfigToken = new InjectionToken('NgpTabsConfigToken');
|
|
20
|
+
/**
|
|
21
|
+
* Provide the default Tabs configuration
|
|
22
|
+
* @param config The Tabs configuration
|
|
23
|
+
* @returns The provider
|
|
24
|
+
*/
|
|
25
|
+
function provideTabsConfig(config) {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
provide: NgpTabsConfigToken,
|
|
29
|
+
useValue: { ...defaultTabsConfig, ...config },
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Inject the Tabs configuration
|
|
35
|
+
* @returns The global Tabs configuration
|
|
36
|
+
*/
|
|
37
|
+
function injectTabsConfig() {
|
|
38
|
+
return inject(NgpTabsConfigToken, { optional: true }) ?? defaultTabsConfig;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Copyright © 2024 Angular Primitives.
|
|
43
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
46
|
+
* LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/
|
|
48
|
+
const NgpTabsetToken = new InjectionToken('NgpTabsetToken');
|
|
49
|
+
/**
|
|
50
|
+
* Inject the Tabset directive instance
|
|
51
|
+
* @returns The Tabset directive instance
|
|
52
|
+
*/
|
|
53
|
+
function injectTabset() {
|
|
54
|
+
return inject(NgpTabsetToken);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class NgpTabButton {
|
|
58
|
+
constructor() {
|
|
59
|
+
/**
|
|
60
|
+
* Access the tabset
|
|
61
|
+
*/
|
|
62
|
+
this.tabset = injectTabset();
|
|
63
|
+
/**
|
|
64
|
+
* The value of the tab this trigger controls
|
|
65
|
+
*/
|
|
66
|
+
this.value = input.required({ alias: 'ngpTabButtonValue' });
|
|
67
|
+
/**
|
|
68
|
+
* Whether the tab is disabled
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
this.disabled = input(false, {
|
|
72
|
+
alias: 'ngpTabButtonDisabled',
|
|
73
|
+
transform: booleanAttribute,
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Determine the id of the tab button
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
this.id = input();
|
|
80
|
+
/**
|
|
81
|
+
* Determine a unique id for the tab button if not provided
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
this.defaultId = computed(() => `${this.tabset.id()}-button-${this.value()}`);
|
|
85
|
+
/**
|
|
86
|
+
* Determine the aria-controls of the tab button
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
this.ariaControls = computed(() => `${this.tabset.id()}-panel-${this.value()}`);
|
|
90
|
+
/**
|
|
91
|
+
* Whether the tab is active
|
|
92
|
+
*/
|
|
93
|
+
this.active = computed(() => this.tabset.value() === this.value());
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Select the tab this trigger controls
|
|
97
|
+
*/
|
|
98
|
+
select() {
|
|
99
|
+
this.tabset.select(this.value());
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* On focus select the tab this trigger controls if activateOnFocus is true
|
|
103
|
+
*/
|
|
104
|
+
activateOnFocus() {
|
|
105
|
+
if (this.tabset.activateOnFocus()) {
|
|
106
|
+
this.select();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabButton, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
110
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.2", type: NgpTabButton, isStandalone: true, selector: "[ngpTabButton]", inputs: { value: { classPropertyName: "value", publicName: "ngpTabButtonValue", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpTabButtonDisabled", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tab" }, listeners: { "click": "select()", "focus": "activateOnFocus()" }, properties: { "attr.id": "id() ?? defaultId()", "attr.aria-controls": "ariaControls()", "attr.data-state": "active() ? \"active\" : \"inactive\"", "attr.data-disabled": "disabled()", "attr.data-orientation": "tabset.orientation()" } }, exportAs: ["ngpTabButton"], hostDirectives: [{ directive: i1.NgpRovingFocusItem }], ngImport: i0 }); }
|
|
111
|
+
}
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabButton, decorators: [{
|
|
113
|
+
type: Directive,
|
|
114
|
+
args: [{
|
|
115
|
+
standalone: true,
|
|
116
|
+
selector: '[ngpTabButton]',
|
|
117
|
+
exportAs: 'ngpTabButton',
|
|
118
|
+
host: {
|
|
119
|
+
role: 'tab',
|
|
120
|
+
'[attr.id]': 'id() ?? defaultId()',
|
|
121
|
+
'[attr.aria-controls]': 'ariaControls()',
|
|
122
|
+
'[attr.data-state]': 'active() ? "active" : "inactive"',
|
|
123
|
+
'[attr.data-disabled]': 'disabled()',
|
|
124
|
+
'[attr.data-orientation]': 'tabset.orientation()',
|
|
125
|
+
},
|
|
126
|
+
hostDirectives: [NgpRovingFocusItem],
|
|
127
|
+
}]
|
|
128
|
+
}], propDecorators: { select: [{
|
|
129
|
+
type: HostListener,
|
|
130
|
+
args: ['click']
|
|
131
|
+
}], activateOnFocus: [{
|
|
132
|
+
type: HostListener,
|
|
133
|
+
args: ['focus']
|
|
134
|
+
}] } });
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Copyright © 2024 Angular Primitives.
|
|
138
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
141
|
+
* LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/
|
|
143
|
+
class NgpTabList {
|
|
144
|
+
constructor() {
|
|
145
|
+
/**
|
|
146
|
+
* Access the tabset
|
|
147
|
+
*/
|
|
148
|
+
this.tabset = injectTabset();
|
|
149
|
+
}
|
|
150
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabList, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
151
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.2", type: NgpTabList, isStandalone: true, selector: "[ngpTabList]", host: { attributes: { "role": "tablist" }, properties: { "attr.aria-orientation": "tabset.orientation()", "attr.data-orientation": "tabset.orientation()" } }, exportAs: ["ngpTabList"], ngImport: i0 }); }
|
|
152
|
+
}
|
|
153
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabList, decorators: [{
|
|
154
|
+
type: Directive,
|
|
155
|
+
args: [{
|
|
156
|
+
standalone: true,
|
|
157
|
+
selector: '[ngpTabList]',
|
|
158
|
+
exportAs: 'ngpTabList',
|
|
159
|
+
host: {
|
|
160
|
+
role: 'tablist',
|
|
161
|
+
'[attr.aria-orientation]': 'tabset.orientation()',
|
|
162
|
+
'[attr.data-orientation]': 'tabset.orientation()',
|
|
163
|
+
},
|
|
164
|
+
}]
|
|
165
|
+
}] });
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Copyright © 2024 Angular Primitives.
|
|
169
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
170
|
+
*
|
|
171
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
172
|
+
* LICENSE file in the root directory of this source tree.
|
|
173
|
+
*/
|
|
174
|
+
const NgpTabPanelToken = new InjectionToken('NgpTabPanelToken');
|
|
175
|
+
/**
|
|
176
|
+
* Inject the TabPanel directive instance
|
|
177
|
+
* @returns The TabPanel directive instance
|
|
178
|
+
*/
|
|
179
|
+
function injectTabPanel() {
|
|
180
|
+
return inject(NgpTabPanelToken);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Copyright © 2024 Angular Primitives.
|
|
185
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
186
|
+
*
|
|
187
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
188
|
+
* LICENSE file in the root directory of this source tree.
|
|
189
|
+
*/
|
|
190
|
+
class NgpTabPanel {
|
|
191
|
+
constructor() {
|
|
192
|
+
/**
|
|
193
|
+
* Access the tabset
|
|
194
|
+
*/
|
|
195
|
+
this.tabset = injectTabset();
|
|
196
|
+
/**
|
|
197
|
+
* The value of the tab
|
|
198
|
+
*/
|
|
199
|
+
this.value = input.required({ alias: 'ngpTabPanelValue' });
|
|
200
|
+
/**
|
|
201
|
+
* Determine the id of the tab panel
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
this.id = input();
|
|
205
|
+
/**
|
|
206
|
+
* Determine a unique id for the tab panel if not provided
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
this.defaultId = computed(() => `${this.tabset.id()}-panel-${this.value()}`);
|
|
210
|
+
/**
|
|
211
|
+
* Determine the aria-labelledby of the tab panel
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
this.labelledBy = computed(() => `${this.tabset.id()}-button-${this.value()}`);
|
|
215
|
+
/**
|
|
216
|
+
* Whether the tab is active
|
|
217
|
+
*/
|
|
218
|
+
this.active = computed(() => this.tabset.selectedTab() === this.value());
|
|
219
|
+
}
|
|
220
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabPanel, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
221
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.2", type: NgpTabPanel, isStandalone: true, selector: "[ngpTabPanel]", inputs: { value: { classPropertyName: "value", publicName: "ngpTabPanelValue", isSignal: true, isRequired: true, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tabpanel", "tabIndex": "0" }, properties: { "attr.aria-labelledby": "labelledBy()", "attr.data-state": "active() ? \"active\" : \"inactive\"", "attr.data-orientation": "tabset.orientation()", "hidden": "!active()" } }, providers: [{ provide: NgpTabPanelToken, useExisting: NgpTabPanel }], exportAs: ["ngpTabPanel"], ngImport: i0 }); }
|
|
222
|
+
}
|
|
223
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabPanel, decorators: [{
|
|
224
|
+
type: Directive,
|
|
225
|
+
args: [{
|
|
226
|
+
standalone: true,
|
|
227
|
+
selector: '[ngpTabPanel]',
|
|
228
|
+
exportAs: 'ngpTabPanel',
|
|
229
|
+
providers: [{ provide: NgpTabPanelToken, useExisting: NgpTabPanel }],
|
|
230
|
+
host: {
|
|
231
|
+
role: 'tabpanel',
|
|
232
|
+
tabIndex: '0',
|
|
233
|
+
'[attr.aria-labelledby]': 'labelledBy()',
|
|
234
|
+
'[attr.data-state]': 'active() ? "active" : "inactive"',
|
|
235
|
+
'[attr.data-orientation]': 'tabset.orientation()',
|
|
236
|
+
'[hidden]': '!active()',
|
|
237
|
+
},
|
|
238
|
+
}]
|
|
239
|
+
}] });
|
|
240
|
+
|
|
241
|
+
class NgpTabset {
|
|
242
|
+
constructor() {
|
|
243
|
+
/**
|
|
244
|
+
* Access the global tabset configuration
|
|
245
|
+
*/
|
|
246
|
+
this.config = injectTabsConfig();
|
|
247
|
+
/**
|
|
248
|
+
* Access the roving focus group directive
|
|
249
|
+
*/
|
|
250
|
+
this.rovingFocusGroup = injectRovingFocusGroup();
|
|
251
|
+
/**
|
|
252
|
+
* Define the id for the tabset
|
|
253
|
+
*/
|
|
254
|
+
this.id = input(uniqueId('ngp-tabset'));
|
|
255
|
+
/**
|
|
256
|
+
* Define the active tab
|
|
257
|
+
*/
|
|
258
|
+
this.value = model(null, {
|
|
259
|
+
alias: 'ngpTabsetValue',
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* The orientation of the tabset
|
|
263
|
+
* @default 'horizontal'
|
|
264
|
+
*/
|
|
265
|
+
this.orientation = input(this.config.orientation, {
|
|
266
|
+
alias: 'ngpTabsetOrientation',
|
|
267
|
+
});
|
|
268
|
+
/**
|
|
269
|
+
* Whether tabs should activate on focus
|
|
270
|
+
*/
|
|
271
|
+
this.activateOnFocus = input(this.config.activateOnFocus, {
|
|
272
|
+
alias: 'ngpTabsetActivateOnFocus',
|
|
273
|
+
transform: booleanAttribute,
|
|
274
|
+
});
|
|
275
|
+
/**
|
|
276
|
+
* Access the tabs within the tabset
|
|
277
|
+
*/
|
|
278
|
+
this.panels = contentChildren(NgpTabPanelToken, { descendants: true });
|
|
279
|
+
/**
|
|
280
|
+
* Get the id of the selected tab
|
|
281
|
+
*/
|
|
282
|
+
this.selectedTab = computed(() => {
|
|
283
|
+
const panels = this.panels();
|
|
284
|
+
// if there is a value set and a tab with that value exists, return the value
|
|
285
|
+
if (panels.some(panel => panel.value() === this.value())) {
|
|
286
|
+
return this.value();
|
|
287
|
+
}
|
|
288
|
+
// otherwise return the first tab
|
|
289
|
+
return panels[0]?.value();
|
|
290
|
+
});
|
|
291
|
+
// default the orientation to horizontal
|
|
292
|
+
this.rovingFocusGroup.orientation = this.orientation();
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Select a tab by its value
|
|
296
|
+
* @param value The value of the tab to select
|
|
297
|
+
*/
|
|
298
|
+
select(value) {
|
|
299
|
+
this.value.set(value);
|
|
300
|
+
}
|
|
301
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabset, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
302
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "18.0.2", type: NgpTabset, isStandalone: true, selector: "[ngpTabset]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpTabsetValue", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "ngpTabsetOrientation", isSignal: true, isRequired: false, transformFunction: null }, activateOnFocus: { classPropertyName: "activateOnFocus", publicName: "ngpTabsetActivateOnFocus", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "ngpTabsetValueChange" }, host: { properties: { "attr.id": "id()", "attr.data-orientation": "orientation()" } }, providers: [{ provide: NgpTabsetToken, useExisting: NgpTabset }], queries: [{ propertyName: "panels", predicate: NgpTabPanelToken, descendants: true, isSignal: true }], exportAs: ["ngpTabset"], hostDirectives: [{ directive: i1.NgpRovingFocusGroup, inputs: ["ngpRovingFocusGroupOrientation", "ngpTabsetOrientation"] }], ngImport: i0 }); }
|
|
303
|
+
}
|
|
304
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTabset, decorators: [{
|
|
305
|
+
type: Directive,
|
|
306
|
+
args: [{
|
|
307
|
+
standalone: true,
|
|
308
|
+
selector: '[ngpTabset]',
|
|
309
|
+
exportAs: 'ngpTabset',
|
|
310
|
+
providers: [{ provide: NgpTabsetToken, useExisting: NgpTabset }],
|
|
311
|
+
hostDirectives: [
|
|
312
|
+
{
|
|
313
|
+
directive: NgpRovingFocusGroup,
|
|
314
|
+
inputs: ['ngpRovingFocusGroupOrientation:ngpTabsetOrientation'],
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
host: {
|
|
318
|
+
'[attr.id]': 'id()',
|
|
319
|
+
'[attr.data-orientation]': 'orientation()',
|
|
320
|
+
},
|
|
321
|
+
}]
|
|
322
|
+
}], ctorParameters: () => [] });
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Copyright © 2024 Angular Primitives.
|
|
326
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
327
|
+
*
|
|
328
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
329
|
+
* LICENSE file in the root directory of this source tree.
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Generated bundle index. Do not edit.
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
export { NgpTabButton, NgpTabList, NgpTabPanel, NgpTabPanelToken, NgpTabset, NgpTabsetToken, provideTabsConfig };
|
|
337
|
+
//# sourceMappingURL=ng-primitives-tabs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-primitives-tabs.mjs","sources":["../../../../packages/ng-primitives/tabs/src/config/tabs.config.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.token.ts","../../../../packages/ng-primitives/tabs/src/tab-button/tab-button.directive.ts","../../../../packages/ng-primitives/tabs/src/tab-list/tab-list.directive.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.token.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.directive.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.directive.ts","../../../../packages/ng-primitives/tabs/src/index.ts","../../../../packages/ng-primitives/tabs/src/ng-primitives-tabs.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, Provider, inject } from '@angular/core';\n\nexport interface NgpTabsConfig {\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n orientation: 'horizontal' | 'vertical';\n\n /**\n * Whether tabs should activate on focus\n * @default true\n */\n activateOnFocus: boolean;\n\n /**\n * Whether focus should wrap within the tab list when using the keyboard.\n * @default true\n */\n wrap: boolean;\n}\n\nexport const defaultTabsConfig: NgpTabsConfig = {\n orientation: 'horizontal',\n activateOnFocus: true,\n wrap: true,\n};\n\nexport const NgpTabsConfigToken = new InjectionToken<NgpTabsConfig>('NgpTabsConfigToken');\n\n/**\n * Provide the default Tabs configuration\n * @param config The Tabs configuration\n * @returns The provider\n */\nexport function provideTabsConfig(config: Partial<NgpTabsConfig>): Provider[] {\n return [\n {\n provide: NgpTabsConfigToken,\n useValue: { ...defaultTabsConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tabs configuration\n * @returns The global Tabs configuration\n */\nexport function injectTabsConfig(): NgpTabsConfig {\n return inject(NgpTabsConfigToken, { optional: true }) ?? defaultTabsConfig;\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpTabset } from './tabset.directive';\n\nexport const NgpTabsetToken = new InjectionToken<NgpTabset>('NgpTabsetToken');\n\n/**\n * Inject the Tabset directive instance\n * @returns The Tabset directive instance\n */\nexport function injectTabset(): NgpTabset {\n return inject(NgpTabsetToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, computed, input } from '@angular/core';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectTabset } from '../tabset/tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabButton]',\n exportAs: 'ngpTabButton',\n host: {\n role: 'tab',\n '[attr.id]': 'id() ?? defaultId()',\n '[attr.aria-controls]': 'ariaControls()',\n '[attr.data-state]': 'active() ? \"active\" : \"inactive\"',\n '[attr.data-disabled]': 'disabled()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n hostDirectives: [NgpRovingFocusItem],\n})\nexport class NgpTabButton {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n\n /**\n * The value of the tab this trigger controls\n */\n readonly value = input.required<string>({ alias: 'ngpTabButtonValue' });\n\n /**\n * Whether the tab is disabled\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTabButtonDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Determine the id of the tab button\n * @internal\n */\n readonly id = input<string>();\n\n /**\n * Determine a unique id for the tab button if not provided\n * @internal\n */\n readonly defaultId = computed(() => `${this.tabset.id()}-button-${this.value()}`);\n\n /**\n * Determine the aria-controls of the tab button\n * @internal\n */\n readonly ariaControls = computed(() => `${this.tabset.id()}-panel-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.tabset.value() === this.value());\n\n /**\n * Select the tab this trigger controls\n */\n @HostListener('click')\n select(): void {\n this.tabset.select(this.value());\n }\n\n /**\n * On focus select the tab this trigger controls if activateOnFocus is true\n */\n @HostListener('focus')\n protected activateOnFocus(): void {\n if (this.tabset.activateOnFocus()) {\n this.select();\n }\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive } from '@angular/core';\nimport { injectTabset } from '../tabset/tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabList]',\n exportAs: 'ngpTabList',\n host: {\n role: 'tablist',\n '[attr.aria-orientation]': 'tabset.orientation()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n})\nexport class NgpTabList {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpTabPanel } from './tab-panel.directive';\n\nexport const NgpTabPanelToken = new InjectionToken<NgpTabPanel>('NgpTabPanelToken');\n\n/**\n * Inject the TabPanel directive instance\n * @returns The TabPanel directive instance\n */\nexport function injectTabPanel(): NgpTabPanel {\n return inject(NgpTabPanelToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, computed, input } from '@angular/core';\nimport { injectTabset } from '../tabset/tabset.token';\nimport { NgpTabPanelToken } from './tab-panel.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabPanel]',\n exportAs: 'ngpTabPanel',\n providers: [{ provide: NgpTabPanelToken, useExisting: NgpTabPanel }],\n host: {\n role: 'tabpanel',\n tabIndex: '0',\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.data-state]': 'active() ? \"active\" : \"inactive\"',\n '[attr.data-orientation]': 'tabset.orientation()',\n '[hidden]': '!active()',\n },\n})\nexport class NgpTabPanel {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n\n /**\n * The value of the tab\n */\n readonly value = input.required<string>({ alias: 'ngpTabPanelValue' });\n\n /**\n * Determine the id of the tab panel\n * @internal\n */\n readonly id = input<string>();\n\n /**\n * Determine a unique id for the tab panel if not provided\n * @internal\n */\n readonly defaultId = computed(() => `${this.tabset.id()}-panel-${this.value()}`);\n\n /**\n * Determine the aria-labelledby of the tab panel\n * @internal\n */\n readonly labelledBy = computed(() => `${this.tabset.id()}-button-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.tabset.selectedTab() === this.value());\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n booleanAttribute,\n computed,\n contentChildren,\n input,\n model,\n} from '@angular/core';\nimport { NgpRovingFocusGroup, injectRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectTabsConfig } from '../config/tabs.config';\nimport { NgpTabPanelToken } from '../tab-panel/tab-panel.token';\nimport { NgpTabsetToken } from './tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabset]',\n exportAs: 'ngpTabset',\n providers: [{ provide: NgpTabsetToken, useExisting: NgpTabset }],\n hostDirectives: [\n {\n directive: NgpRovingFocusGroup,\n inputs: ['ngpRovingFocusGroupOrientation:ngpTabsetOrientation'],\n },\n ],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-orientation]': 'orientation()',\n },\n})\nexport class NgpTabset {\n /**\n * Access the global tabset configuration\n */\n private readonly config = injectTabsConfig();\n\n /**\n * Access the roving focus group directive\n */\n private readonly rovingFocusGroup = injectRovingFocusGroup();\n\n /**\n * Define the id for the tabset\n */\n readonly id = input<string>(uniqueId('ngp-tabset'));\n\n /**\n * Define the active tab\n */\n readonly value = model<string | null>(null, {\n alias: 'ngpTabsetValue',\n });\n\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>(this.config.orientation, {\n alias: 'ngpTabsetOrientation',\n });\n\n /**\n * Whether tabs should activate on focus\n */\n readonly activateOnFocus = input<boolean, BooleanInput>(this.config.activateOnFocus, {\n alias: 'ngpTabsetActivateOnFocus',\n transform: booleanAttribute,\n });\n\n /**\n * Access the tabs within the tabset\n */\n readonly panels = contentChildren(NgpTabPanelToken, { descendants: true });\n\n /**\n * Get the id of the selected tab\n */\n readonly selectedTab = computed(() => {\n const panels = this.panels();\n\n // if there is a value set and a tab with that value exists, return the value\n if (panels.some(panel => panel.value() === this.value())) {\n return this.value();\n }\n\n // otherwise return the first tab\n return panels[0]?.value();\n });\n\n constructor() {\n // default the orientation to horizontal\n this.rovingFocusGroup.orientation = this.orientation();\n }\n\n /**\n * Select a tab by its value\n * @param value The value of the tab to select\n */\n select(value: string): void {\n this.value.set(value);\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpTabsConfig, provideTabsConfig } from './config/tabs.config';\nexport { NgpTabButton } from './tab-button/tab-button.directive';\nexport { NgpTabList } from './tab-list/tab-list.directive';\nexport { NgpTabPanel } from './tab-panel/tab-panel.directive';\nexport { NgpTabPanelToken } from './tab-panel/tab-panel.token';\nexport { NgpTabset } from './tabset/tabset.directive';\nexport { NgpTabsetToken } from './tabset/tabset.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;AAuBI,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,IAAI,EAAE,IAAI;CACX,CAAC;AAEK,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAgB,oBAAoB,CAAC,CAAC;AAE1F;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA8B,EAAA;IAC9D,OAAO;A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F,qBAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,yBAAyB,EAAE,eAAe;AAC3C,qBAAA;AACF,iBAAA,CAAA;;;ACrCD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { model, input, booleanAttribute, Directive, HostListener } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class NgpToggle {
|
|
5
|
+
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the toggle is pressed.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
this.pressed = model(false, { alias: 'ngpTogglePressed' });
|
|
11
|
+
/**
|
|
12
|
+
* Whether the toggle is disabled.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
this.disabled = input(false, {
|
|
16
|
+
alias: 'ngpToggleDisabled',
|
|
17
|
+
transform: booleanAttribute,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Toggle the pressed state.
|
|
22
|
+
*/
|
|
23
|
+
toggle() {
|
|
24
|
+
if (this.disabled()) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.pressed.set(!this.pressed());
|
|
28
|
+
}
|
|
29
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpToggle, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
30
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.2", type: NgpToggle, isStandalone: true, selector: "button[ngpToggle]", inputs: { pressed: { classPropertyName: "pressed", publicName: "ngpTogglePressed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpToggleDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pressed: "ngpTogglePressedChange" }, host: { attributes: { "type": "button" }, listeners: { "click": "toggle()" }, properties: { "attr.aria-pressed": "pressed()", "attr.data-state": "pressed() ? \"on\" : \"off\"", "attr.data-disabled": "disabled()" } }, exportAs: ["ngpToggle"], ngImport: i0 }); }
|
|
31
|
+
}
|
|
32
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpToggle, decorators: [{
|
|
33
|
+
type: Directive,
|
|
34
|
+
args: [{
|
|
35
|
+
selector: 'button[ngpToggle]',
|
|
36
|
+
exportAs: 'ngpToggle',
|
|
37
|
+
standalone: true,
|
|
38
|
+
host: {
|
|
39
|
+
type: 'button',
|
|
40
|
+
'[attr.aria-pressed]': 'pressed()',
|
|
41
|
+
'[attr.data-state]': 'pressed() ? "on" : "off"',
|
|
42
|
+
'[attr.data-disabled]': 'disabled()',
|
|
43
|
+
},
|
|
44
|
+
}]
|
|
45
|
+
}], propDecorators: { toggle: [{
|
|
46
|
+
type: HostListener,
|
|
47
|
+
args: ['click']
|
|
48
|
+
}] } });
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Copyright © 2024 Angular Primitives.
|
|
52
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
55
|
+
* LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Generated bundle index. Do not edit.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
export { NgpToggle };
|
|
63
|
+
//# sourceMappingURL=ng-primitives-toggle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-primitives-toggle.mjs","sources":["../../../../packages/ng-primitives/toggle/src/toggle/toggle.directive.ts","../../../../packages/ng-primitives/toggle/src/index.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, input, model } from '@angular/core';\n\n@Directive({\n selector: 'button[ngpToggle]',\n exportAs: 'ngpToggle',\n standalone: true,\n host: {\n type: 'button',\n '[attr.aria-pressed]': 'pressed()',\n '[attr.data-state]': 'pressed() ? \"on\" : \"off\"',\n '[attr.data-disabled]': 'disabled()',\n },\n})\nexport class NgpToggle {\n /**\n * Whether the toggle is pressed.\n * @default false\n */\n readonly pressed = model<boolean>(false, { alias: 'ngpTogglePressed' });\n\n /**\n * Whether the toggle is disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Toggle the pressed state.\n */\n @HostListener('click')\n toggle(): void {\n if (this.disabled()) {\n return;\n }\n\n this.pressed.set(!this.pressed());\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpToggle } from './toggle/toggle.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAqBa,SAAS,CAAA;AAXtB,IAAA,WAAA,GAAA;AAYE;;;AAGG;QACM,IAAO,CAAA,OAAA,GAAG,KAAK,CAAU,KAAK,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAExE;;;AAGG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,KAAK,EAAE,mBAAmB;AAC1B,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC,CAAC;AAaJ,KAAA;AAXC;;AAEG;IAEH,MAAM,G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