ng-primitives 0.35.0 → 0.36.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/a11y/visually-hidden/visually-hidden-state.d.ts +1 -1
- package/accordion/accordion/accordion-state.d.ts +1 -1
- package/accordion/accordion-item/accordion-item-state.d.ts +1 -1
- package/avatar/avatar/avatar-state.d.ts +1 -1
- package/button/button/button-state.d.ts +1 -1
- package/checkbox/checkbox/checkbox-state.d.ts +1 -1
- package/date-picker/date-picker/date-picker-state.d.ts +1 -1
- package/dialog/dialog/dialog-state.d.ts +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs +6 -4
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +73 -50
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-popover.mjs +95 -59
- package/fesm2022/ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/ng-primitives-radio.mjs +4 -0
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-state.mjs +10 -3
- package/fesm2022/ng-primitives-state.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs +17 -22
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +94 -43
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +18 -0
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/file-upload/file-dropzone/file-dropzone-state.d.ts +2 -2
- package/file-upload/file-dropzone/file-dropzone.d.ts +3 -2
- package/file-upload/file-upload/file-upload-state.d.ts +2 -2
- package/file-upload/file-upload/file-upload.d.ts +3 -2
- package/form-field/form-control/form-control-state.d.ts +1 -1
- package/form-field/form-field/form-field-state.d.ts +1 -1
- package/input/input/input-state.d.ts +1 -1
- package/internal/exit-animation/exit-animation-manager.d.ts +17 -0
- package/internal/exit-animation/exit-animation.d.ts +4 -17
- package/internal/index.d.ts +2 -1
- package/listbox/listbox/listbox-state.d.ts +2 -2
- package/package.json +5 -5
- package/pagination/pagination/pagination-state.d.ts +1 -1
- package/popover/index.d.ts +1 -0
- package/popover/popover/popover-token.d.ts +10 -0
- package/popover/popover/popover.d.ts +3 -2
- package/popover/popover-trigger/popover-trigger-state.d.ts +5 -3
- package/popover/popover-trigger/popover-trigger.d.ts +26 -18
- package/progress/progress/progress-state.d.ts +1 -1
- package/radio/radio-group/radio-group-state.d.ts +1 -1
- package/radio/radio-item/radio-item-state.d.ts +1 -1
- package/roving-focus/roving-focus-group/roving-focus-group-state.d.ts +1 -1
- package/schematics/ng-generate/schema.d.ts +3 -1
- package/schematics/ng-generate/schema.json +3 -1
- package/schematics/ng-generate/templates/toolbar/toolbar-button.__fileSuffix@dasherize__.ts.template +58 -0
- package/schematics/ng-generate/templates/toolbar/toolbar.__fileSuffix@dasherize__.ts.template +29 -0
- package/schematics/ng-generate/templates/tooltip/tooltip-trigger.__fileSuffix@dasherize__.ts.template +35 -0
- package/schematics/ng-generate/templates/tooltip/tooltip.__fileSuffix@dasherize__.ts.template +60 -0
- package/search/search/search-state.d.ts +1 -1
- package/select/select/select-state.d.ts +1 -1
- package/slider/slider/slider-state.d.ts +1 -1
- package/state/index.d.ts +7 -1
- package/switch/switch/switch-state.d.ts +1 -1
- package/tabs/index.d.ts +1 -2
- package/tabs/tab-button/tab-button.d.ts +2 -2
- package/tabs/tabset/tabset-state.d.ts +1 -1
- package/textarea/textarea/textarea-state.d.ts +1 -1
- package/toggle/toggle/toggle-state.d.ts +1 -1
- package/toggle-group/toggle-group/toggle-group-state.d.ts +1 -1
- package/toggle-group/toggle-group-item/toggle-group-item-state.d.ts +1 -1
- package/tooltip/index.d.ts +1 -0
- package/tooltip/tooltip/tooltip-token.d.ts +10 -0
- package/tooltip/tooltip/tooltip.d.ts +2 -1
- package/tooltip/tooltip-trigger/tooltip-trigger-state.d.ts +3 -3
- package/tooltip/tooltip-trigger/tooltip-trigger.d.ts +39 -18
- package/tabs/tabset/tabset-token.d.ts +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken,
|
|
1
|
+
import { InjectionToken, signal, inject, computed, isSignal, linkedSignal } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Create a new injection token for the state.
|
|
@@ -14,9 +14,16 @@ function createStateToken(description) {
|
|
|
14
14
|
* @param token The token for the state
|
|
15
15
|
*/
|
|
16
16
|
function createStateProvider(token) {
|
|
17
|
-
return () => ({
|
|
17
|
+
return ({ inherit } = {}) => ({
|
|
18
18
|
provide: token,
|
|
19
|
-
useFactory: () =>
|
|
19
|
+
useFactory: () => {
|
|
20
|
+
if (inherit === false) {
|
|
21
|
+
// if we are not checking the parent, we want to create a new state
|
|
22
|
+
return signal({});
|
|
23
|
+
}
|
|
24
|
+
// if we are checking the parent, we want to check if the state is already defined
|
|
25
|
+
return inject(token, { optional: true, skipSelf: true }) ?? signal({});
|
|
26
|
+
},
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
29
|
function createStateInjector(token, options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-state.mjs","sources":["../../../../packages/ng-primitives/state/src/index.ts","../../../../packages/ng-primitives/state/src/ng-primitives-state.ts"],"sourcesContent":["import {\n computed,\n FactoryProvider,\n inject,\n InjectionToken,\n InjectOptions,\n InputSignal,\n InputSignalWithTransform,\n isSignal,\n linkedSignal,\n ProviderToken,\n signal,\n Signal,\n WritableSignal,\n} from '@angular/core';\n\n/**\n * This converts the state object to a writable state object.\n * This means that inputs become signals which are writable.\n */\nexport type State<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : T[K];\n};\n\n/**\n * This is similar to the state object, but we don't expose properties that are not\n * inputs.\n */\nexport type CreatedState<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : never;\n};\n\nexport type InjectedState<T> = Signal<State<T>>;\n\n/**\n * Create a new injection token for the state.\n * @param description The description of the token\n */\nexport function createStateToken<T>(description: string): InjectionToken<T> {\n return new InjectionToken<Signal<State<T>>>(`Ngp${description}StateToken`);\n}\n\n/**\n * Create a new provider for the state. It first tries to inject the state from the parent injector,\n * as this allows for the state to be hoisted to a higher level in the component tree. This can\n * be useful to avoid issues where the injector can't be shared in some cases when ng-content is used.\n * @param token The token for the state\n */\nexport function createStateProvider<T>(token: ProviderToken<T
|
|
1
|
+
{"version":3,"file":"ng-primitives-state.mjs","sources":["../../../../packages/ng-primitives/state/src/index.ts","../../../../packages/ng-primitives/state/src/ng-primitives-state.ts"],"sourcesContent":["import {\n computed,\n FactoryProvider,\n inject,\n InjectionToken,\n InjectOptions,\n InputSignal,\n InputSignalWithTransform,\n isSignal,\n linkedSignal,\n ProviderToken,\n signal,\n Signal,\n WritableSignal,\n} from '@angular/core';\n\n/**\n * This converts the state object to a writable state object.\n * This means that inputs become signals which are writable.\n */\nexport type State<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : T[K];\n};\n\n/**\n * This is similar to the state object, but we don't expose properties that are not\n * inputs.\n */\nexport type CreatedState<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : never;\n};\n\nexport type InjectedState<T> = Signal<State<T>>;\n\n/**\n * Create a new injection token for the state.\n * @param description The description of the token\n */\nexport function createStateToken<T>(description: string): InjectionToken<T> {\n return new InjectionToken<Signal<State<T>>>(`Ngp${description}StateToken`);\n}\n\nexport interface CreateStateProviderOptions {\n /**\n * Whether we should check for the state in the parent injector.\n */\n inherit?: boolean;\n}\n\n/**\n * Create a new provider for the state. It first tries to inject the state from the parent injector,\n * as this allows for the state to be hoisted to a higher level in the component tree. This can\n * be useful to avoid issues where the injector can't be shared in some cases when ng-content is used.\n * @param token The token for the state\n */\nexport function createStateProvider<T>(\n token: ProviderToken<T>,\n): (options?: CreateStateProviderOptions) => FactoryProvider {\n return ({ inherit }: CreateStateProviderOptions = {}) => ({\n provide: token,\n useFactory: () => {\n if (inherit === false) {\n // if we are not checking the parent, we want to create a new state\n return signal({});\n }\n // if we are checking the parent, we want to check if the state is already defined\n return inject(token, { optional: true, skipSelf: true }) ?? signal({});\n },\n });\n}\n\ntype CreateStateInjectorOptions = {\n /**\n * Whether the state may not be immediately available. This can happen when the child is instantiated before the parent.\n */\n deferred?: boolean;\n};\n\n/**\n * Create a new state injector for the state.\n * @param token The token for the state\n */\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options: { deferred: true },\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined>;\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options?: CreateStateInjectorOptions,\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U>>;\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options: CreateStateInjectorOptions = {},\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined> {\n return <U = T>(injectOptions: InjectOptions = {}) => {\n const value = inject(token, injectOptions) as Signal<State<U> | undefined> | null;\n\n if (options.deferred) {\n return computed(() =>\n value && Object.keys(value() ?? {}).length === 0 ? undefined : value?.(),\n ) as Signal<State<U> | undefined>;\n }\n\n return (value as Signal<State<U>>) ?? signal(undefined);\n };\n}\n\n/**\n * Convert the original state object into a writable state object.\n * @param token The token for the state\n */\nexport function createState(token: ProviderToken<WritableSignal<State<unknown>>>) {\n return <U>(state: U): CreatedState<U> => {\n const internalState = inject(token);\n\n internalState.update(obj => {\n // Iterating over properties\n for (const key in state) {\n const value = state[key as keyof U];\n\n // If this is a signal but doesn't have a set method, we need to wrap it in a linked signal\n // This is because the signal is not writable\n // and we need to create a new signal that is writable\n // and linked to the original signal\n if (isSignal(value) && 'set' in value === false) {\n // @ts-ignore\n obj[key] = linkedSignal(() => value());\n } else {\n // @ts-ignore\n obj[key] = value;\n }\n }\n\n // Iterating over prototype methods\n const prototype = Object.getPrototypeOf(state);\n\n for (const key of Object.getOwnPropertyNames(prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, key);\n\n // if this is a getter or setter, we need to define it on the object\n if (descriptor?.get || descriptor?.set) {\n Object.defineProperty(obj, key, descriptor);\n } else if (typeof prototype[key as keyof U] === 'function') {\n (obj as Record<string, unknown>)[key] = prototype[key as keyof U].bind(state);\n } else {\n // @ts-ignore\n obj[key] = prototype[key as keyof U];\n }\n }\n\n return { ...obj };\n });\n\n return internalState() as unknown as CreatedState<U>;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AA4CA;;;AAGG;AACG,SAAU,gBAAgB,CAAI,WAAmB,EAAA;AACrD,IAAA,OAAO,IAAI,cAAc,CAAmB,MAAM,WAAW,CAAA,UAAA,CAAY,CAAC;AAC5E;AASA;;;;;AAKG;AACG,SAAU,mBAAmB,CACjC,KAAuB,EAAA;IAEvB,OAAO,CAAC,EAAE,OAAO,EAAA,GAAiC,EAAE,MAAM;AACxD,QAAA,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,MAAK;AACf,YAAA,IAAI,OAAO,KAAK,KAAK,EAAE;;AAErB,gBAAA,OAAO,MAAM,CAAC,EAAE,CAAC;;;AAGnB,YAAA,OAAO,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EA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,SAAS,EAAE,GAAG,CAAC;;gBAGlE,IAAI,UAAU,EAAE,GAAG,IAAI,UAAU,EAAE,GAAG,EAAE;oBACtC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC;;qBACtC,IAAI,OAAO,SAAS,CAAC,GAAc,CAAC,KAAK,UAAU,EAAE;AACzD,oBAAA,GAA+B,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAc,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;qBACxE;;oBAEL,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAc,CAAC;;;AAIxC,YAAA,OAAO,EAAE,GAAG,GAAG,EAAE;AACnB,SAAC,CAAC;QAEF,OAAO,aAAa,EAAgC;AACtD,KAAC;AACH;;ACrKA;;AAEG;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, input, booleanAttribute, computed, Directive, HostListener, output, signal } from '@angular/core';
|
|
3
|
-
import
|
|
4
|
-
import { NgpHover, NgpFocusVisible, NgpPress } from 'ng-primitives/interactions';
|
|
3
|
+
import { setupInteractions } from 'ng-primitives/internal';
|
|
5
4
|
import * as i1 from 'ng-primitives/roving-focus';
|
|
6
5
|
import { NgpRovingFocusItem, injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';
|
|
7
6
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
@@ -91,6 +90,12 @@ class NgpTabButton {
|
|
|
91
90
|
* Whether the tab is active
|
|
92
91
|
*/
|
|
93
92
|
this.active = computed(() => this.state().selectedTab() === this.value());
|
|
93
|
+
setupInteractions({
|
|
94
|
+
hover: true,
|
|
95
|
+
press: true,
|
|
96
|
+
focusVisible: true,
|
|
97
|
+
disabled: this.disabled,
|
|
98
|
+
});
|
|
94
99
|
}
|
|
95
100
|
ngOnInit() {
|
|
96
101
|
if (this.value() === undefined) {
|
|
@@ -112,7 +117,7 @@ class NgpTabButton {
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTabButton, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
115
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", type: NgpTabButton, isStandalone: true, selector: "[ngpTabButton]", inputs: { value: { classPropertyName: "value", publicName: "ngpTabButtonValue", isSignal: true, isRequired: false, 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-active": "active() ? \"\" : null", "attr.data-disabled": "disabled() ? \"\" : null", "attr.data-orientation": "state().orientation()" } }, exportAs: ["ngpTabButton"], hostDirectives: [{ directive: i1.NgpRovingFocusItem }
|
|
120
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", type: NgpTabButton, isStandalone: true, selector: "[ngpTabButton]", inputs: { value: { classPropertyName: "value", publicName: "ngpTabButtonValue", isSignal: true, isRequired: false, 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-active": "active() ? \"\" : null", "attr.data-disabled": "disabled() ? \"\" : null", "attr.data-orientation": "state().orientation()" } }, exportAs: ["ngpTabButton"], hostDirectives: [{ directive: i1.NgpRovingFocusItem }], ngImport: i0 }); }
|
|
116
121
|
}
|
|
117
122
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTabButton, decorators: [{
|
|
118
123
|
type: Directive,
|
|
@@ -127,9 +132,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
127
132
|
'[attr.data-disabled]': 'disabled() ? "" : null',
|
|
128
133
|
'[attr.data-orientation]': 'state().orientation()',
|
|
129
134
|
},
|
|
130
|
-
hostDirectives: [NgpRovingFocusItem
|
|
135
|
+
hostDirectives: [NgpRovingFocusItem],
|
|
131
136
|
}]
|
|
132
|
-
}], propDecorators: { select: [{
|
|
137
|
+
}], ctorParameters: () => [], propDecorators: { select: [{
|
|
133
138
|
type: HostListener,
|
|
134
139
|
args: ['click']
|
|
135
140
|
}], activateOnFocus: [{
|
|
@@ -233,20 +238,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
233
238
|
}]
|
|
234
239
|
}] });
|
|
235
240
|
|
|
236
|
-
const NgpTabsetToken = new InjectionToken('NgpTabsetToken');
|
|
237
|
-
/**
|
|
238
|
-
* Inject the Tabset directive instance
|
|
239
|
-
*/
|
|
240
|
-
function injectTabset() {
|
|
241
|
-
return inject(NgpTabsetToken);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Provide the Tabset directive instance
|
|
245
|
-
*/
|
|
246
|
-
function provideTabset(type) {
|
|
247
|
-
return { provide: NgpTabsetToken, useExisting: type };
|
|
248
|
-
}
|
|
249
|
-
|
|
250
241
|
/**
|
|
251
242
|
* Apply the `ngpTabset` directive to an element to manage the tabs.
|
|
252
243
|
*/
|
|
@@ -323,6 +314,10 @@ class NgpTabset {
|
|
|
323
314
|
* @param value The value of the tab to select
|
|
324
315
|
*/
|
|
325
316
|
select(value) {
|
|
317
|
+
// if the value is already selected, do nothing
|
|
318
|
+
if (this.state.value() === value) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
326
321
|
this.state.value.set(value);
|
|
327
322
|
this.valueChange.emit(value);
|
|
328
323
|
}
|
|
@@ -341,14 +336,14 @@ class NgpTabset {
|
|
|
341
336
|
this.panels.update(panels => panels.filter(panel => panel !== tab));
|
|
342
337
|
}
|
|
343
338
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTabset, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
344
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", 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: { valueChange: "ngpTabsetValueChange" }, host: { properties: { "attr.id": "state.id()", "attr.data-orientation": "state.orientation()" } }, providers: [
|
|
339
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", 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: { valueChange: "ngpTabsetValueChange" }, host: { properties: { "attr.id": "state.id()", "attr.data-orientation": "state.orientation()" } }, providers: [provideTabsetState()], exportAs: ["ngpTabset"], hostDirectives: [{ directive: i1.NgpRovingFocusGroup, inputs: ["ngpRovingFocusGroupOrientation", "ngpTabsetOrientation"] }], ngImport: i0 }); }
|
|
345
340
|
}
|
|
346
341
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTabset, decorators: [{
|
|
347
342
|
type: Directive,
|
|
348
343
|
args: [{
|
|
349
344
|
selector: '[ngpTabset]',
|
|
350
345
|
exportAs: 'ngpTabset',
|
|
351
|
-
providers: [
|
|
346
|
+
providers: [provideTabsetState()],
|
|
352
347
|
hostDirectives: [
|
|
353
348
|
{
|
|
354
349
|
directive: NgpRovingFocusGroup,
|
|
@@ -366,5 +361,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
366
361
|
* Generated bundle index. Do not edit.
|
|
367
362
|
*/
|
|
368
363
|
|
|
369
|
-
export { NgpTabButton, NgpTabList, NgpTabPanel, NgpTabPanelToken, NgpTabset,
|
|
364
|
+
export { NgpTabButton, NgpTabList, NgpTabPanel, NgpTabPanelToken, NgpTabset, injectTabPanel, injectTabsetState, provideTabsConfig, provideTabsetState };
|
|
370
365
|
//# sourceMappingURL=ng-primitives-tabs.mjs.map
|
|
@@ -1 +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-state.ts","../../../../packages/ng-primitives/tabs/src/tab-button/tab-button.ts","../../../../packages/ng-primitives/tabs/src/tab-list/tab-list.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel-token.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset-token.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.ts","../../../../packages/ng-primitives/tabs/src/ng-primitives-tabs.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\n\nexport interface NgpTabsConfig {\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n orientation: NgpOrientation;\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","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpTabset } from './tabset';\n\n/**\n * The state token for the Tabset primitive.\n */\nexport const NgpTabsetStateToken = createStateToken<NgpTabset>('Tabset');\n\n/**\n * Provides the Tabset state.\n */\nexport const provideTabsetState = createStateProvider(NgpTabsetStateToken);\n\n/**\n * Injects the Tabset state.\n */\nexport const injectTabsetState = createStateInjector(NgpTabsetStateToken);\n\n/**\n * The Tabset state registration function.\n */\nexport const tabsetState = createState(NgpTabsetStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, OnInit, booleanAttribute, computed, input } from '@angular/core';\nimport { NgpFocusVisible, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectTabsetState } from '../tabset/tabset-state';\n\n/**\n * Apply the `ngpTabButton` directive to an element within a tab list to represent a tab button. This directive should be applied to a button element.\n */\n@Directive({\n selector: '[ngpTabButton]',\n exportAs: 'ngpTabButton',\n host: {\n role: 'tab',\n '[attr.id]': 'id() ?? defaultId()',\n '[attr.aria-controls]': 'ariaControls()',\n '[attr.data-active]': 'active() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n '[attr.data-orientation]': 'state().orientation()',\n },\n hostDirectives: [NgpRovingFocusItem, NgpHover, NgpFocusVisible, NgpPress],\n})\nexport class NgpTabButton implements OnInit {\n /**\n * Access the tabset state\n */\n protected readonly state = injectTabsetState();\n\n /**\n * The value of the tab this trigger controls\n */\n readonly value = input<string>(undefined, { 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.state().id()}-button-${this.value()}`);\n\n /**\n * Determine the aria-controls of the tab button\n * @internal\n */\n readonly ariaControls = computed(() => `${this.state().id()}-panel-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.state().selectedTab() === this.value());\n\n ngOnInit(): void {\n if (this.value() === undefined) {\n throw new Error('ngpTabButton: value is required');\n }\n }\n\n /**\n * Select the tab this trigger controls\n */\n @HostListener('click')\n select(): void {\n this.state().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.state().activateOnFocus()) {\n this.select();\n }\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectTabsetState } from '../tabset/tabset-state';\n\n/**\n * Apply the `ngpTabList` directive to an element that represents the list of tab buttons.\n */\n@Directive({\n selector: '[ngpTabList]',\n exportAs: 'ngpTabList',\n host: {\n role: 'tablist',\n '[attr.aria-orientation]': 'state().orientation()',\n '[attr.data-orientation]': 'state().orientation()',\n },\n})\nexport class NgpTabList {\n /**\n * Access the tabset state\n */\n protected readonly state = injectTabsetState();\n}\n","import { InjectionToken, inject } from '@angular/core';\nimport type { NgpTabPanel } from './tab-panel';\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","import { Directive, OnDestroy, OnInit, computed, input } from '@angular/core';\nimport { injectTabsetState } from '../tabset/tabset-state';\nimport { NgpTabPanelToken } from './tab-panel-token';\n\n/**\n * Apply the `ngpTabPanel` directive to an element that represents the content of a tab.\n */\n@Directive({\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-active]': 'active() ? \"\" : null',\n '[attr.data-orientation]': 'state().orientation()',\n },\n})\nexport class NgpTabPanel implements OnInit, OnDestroy {\n /**\n * Access the tabset\n */\n protected readonly state = injectTabsetState();\n\n /**\n * The value of the tab\n */\n readonly value = input<string>(undefined, { 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 protected readonly defaultId = computed(() => `${this.state().id()}-panel-${this.value()}`);\n\n /**\n * Determine the aria-labelledby of the tab panel\n * @internal\n */\n protected readonly labelledBy = computed(() => `${this.state().id()}-button-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n protected readonly active = computed(() => this.state().selectedTab() === this.value());\n\n ngOnInit(): void {\n this.state().registerTab(this);\n\n if (this.value() === undefined) {\n throw new Error('ngpTabPanel: value is required');\n }\n }\n\n ngOnDestroy(): void {\n this.state().unregisterTab(this);\n }\n}\n","import { ExistingProvider, inject, InjectionToken, Type } from '@angular/core';\nimport type { NgpTabset } from './tabset';\n\nexport const NgpTabsetToken = new InjectionToken<NgpTabset>('NgpTabsetToken');\n\n/**\n * Inject the Tabset directive instance\n */\nexport function injectTabset(): NgpTabset {\n return inject(NgpTabsetToken);\n}\n\n/**\n * Provide the Tabset directive instance\n */\nexport function provideTabset(type: Type<NgpTabset>): ExistingProvider {\n return { provide: NgpTabsetToken, useExisting: type };\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n input,\n OnInit,\n output,\n signal,\n} from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectTabsConfig } from '../config/tabs-config';\nimport type { NgpTabPanel } from '../tab-panel/tab-panel';\nimport { provideTabsetState, tabsetState } from './tabset-state';\nimport { provideTabset } from './tabset-token';\n\n/**\n * Apply the `ngpTabset` directive to an element to manage the tabs.\n */\n@Directive({\n selector: '[ngpTabset]',\n exportAs: 'ngpTabset',\n providers: [provideTabset(NgpTabset), provideTabsetState()],\n hostDirectives: [\n {\n directive: NgpRovingFocusGroup,\n inputs: ['ngpRovingFocusGroupOrientation:ngpTabsetOrientation'],\n },\n ],\n host: {\n '[attr.id]': 'state.id()',\n '[attr.data-orientation]': 'state.orientation()',\n },\n})\nexport class NgpTabset implements OnInit {\n /**\n * Access the global tabset configuration\n */\n private readonly config = injectTabsConfig();\n\n /**\n * Access the roving focus group state\n */\n private readonly rovingFocusGroupState = injectRovingFocusGroupState();\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 = input<string>(undefined, {\n alias: 'ngpTabsetValue',\n });\n\n /**\n * Emit the value of the selected tab when it changes\n */\n readonly valueChange = output<string | undefined>({\n alias: 'ngpTabsetValueChange',\n });\n\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n readonly orientation = input<NgpOrientation>(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 * @internal\n */\n readonly panels = signal<NgpTabPanel[]>([]);\n\n /**\n * @internal\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.state.value())) {\n return this.state.value();\n }\n\n // otherwise return the first tab\n return panels[0]?.value();\n });\n\n /**\n * The state of the tabset\n */\n protected readonly state = tabsetState<NgpTabset>(this);\n\n ngOnInit(): void {\n // the roving focus group defaults to vertical orientation whereas\n // the default for the tabset may be different if provided via global config\n this.rovingFocusGroupState().orientation.set(this.state.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.state.value.set(value);\n this.valueChange.emit(value);\n }\n\n /**\n * @internal\n * Register a tab with the tabset\n */\n registerTab(tab: NgpTabPanel): void {\n this.panels.update(panels => [...panels, tab]);\n }\n\n /**\n * @internal\n * Unregister a tab with the tabset\n */\n unregisterTab(tab: NgpTabPanel): void {\n this.panels.update(panels => panels.filter(panel => panel !== tab));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAuBO,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,IAAI,EAAE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
{"version":3,"file":"ng-primitives-tabs.mjs","sources":["../../../../packages/ng-primitives/tabs/src/config/tabs-config.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset-state.ts","../../../../packages/ng-primitives/tabs/src/tab-button/tab-button.ts","../../../../packages/ng-primitives/tabs/src/tab-list/tab-list.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel-token.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.ts","../../../../packages/ng-primitives/tabs/src/ng-primitives-tabs.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\n\nexport interface NgpTabsConfig {\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n orientation: NgpOrientation;\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","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpTabset } from './tabset';\n\n/**\n * The state token for the Tabset primitive.\n */\nexport const NgpTabsetStateToken = createStateToken<NgpTabset>('Tabset');\n\n/**\n * Provides the Tabset state.\n */\nexport const provideTabsetState = createStateProvider(NgpTabsetStateToken);\n\n/**\n * Injects the Tabset state.\n */\nexport const injectTabsetState = createStateInjector(NgpTabsetStateToken);\n\n/**\n * The Tabset state registration function.\n */\nexport const tabsetState = createState(NgpTabsetStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, OnInit, booleanAttribute, computed, input } from '@angular/core';\nimport { setupInteractions } from 'ng-primitives/internal';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectTabsetState } from '../tabset/tabset-state';\n\n/**\n * Apply the `ngpTabButton` directive to an element within a tab list to represent a tab button. This directive should be applied to a button element.\n */\n@Directive({\n selector: '[ngpTabButton]',\n exportAs: 'ngpTabButton',\n host: {\n role: 'tab',\n '[attr.id]': 'id() ?? defaultId()',\n '[attr.aria-controls]': 'ariaControls()',\n '[attr.data-active]': 'active() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n '[attr.data-orientation]': 'state().orientation()',\n },\n hostDirectives: [NgpRovingFocusItem],\n})\nexport class NgpTabButton implements OnInit {\n /**\n * Access the tabset state\n */\n protected readonly state = injectTabsetState();\n\n /**\n * The value of the tab this trigger controls\n */\n readonly value = input<string>(undefined, { 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.state().id()}-button-${this.value()}`);\n\n /**\n * Determine the aria-controls of the tab button\n * @internal\n */\n readonly ariaControls = computed(() => `${this.state().id()}-panel-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.state().selectedTab() === this.value());\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focusVisible: true,\n disabled: this.disabled,\n });\n }\n\n ngOnInit(): void {\n if (this.value() === undefined) {\n throw new Error('ngpTabButton: value is required');\n }\n }\n\n /**\n * Select the tab this trigger controls\n */\n @HostListener('click')\n select(): void {\n this.state().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.state().activateOnFocus()) {\n this.select();\n }\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectTabsetState } from '../tabset/tabset-state';\n\n/**\n * Apply the `ngpTabList` directive to an element that represents the list of tab buttons.\n */\n@Directive({\n selector: '[ngpTabList]',\n exportAs: 'ngpTabList',\n host: {\n role: 'tablist',\n '[attr.aria-orientation]': 'state().orientation()',\n '[attr.data-orientation]': 'state().orientation()',\n },\n})\nexport class NgpTabList {\n /**\n * Access the tabset state\n */\n protected readonly state = injectTabsetState();\n}\n","import { InjectionToken, inject } from '@angular/core';\nimport type { NgpTabPanel } from './tab-panel';\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","import { Directive, OnDestroy, OnInit, computed, input } from '@angular/core';\nimport { injectTabsetState } from '../tabset/tabset-state';\nimport { NgpTabPanelToken } from './tab-panel-token';\n\n/**\n * Apply the `ngpTabPanel` directive to an element that represents the content of a tab.\n */\n@Directive({\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-active]': 'active() ? \"\" : null',\n '[attr.data-orientation]': 'state().orientation()',\n },\n})\nexport class NgpTabPanel implements OnInit, OnDestroy {\n /**\n * Access the tabset\n */\n protected readonly state = injectTabsetState();\n\n /**\n * The value of the tab\n */\n readonly value = input<string>(undefined, { 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 protected readonly defaultId = computed(() => `${this.state().id()}-panel-${this.value()}`);\n\n /**\n * Determine the aria-labelledby of the tab panel\n * @internal\n */\n protected readonly labelledBy = computed(() => `${this.state().id()}-button-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n protected readonly active = computed(() => this.state().selectedTab() === this.value());\n\n ngOnInit(): void {\n this.state().registerTab(this);\n\n if (this.value() === undefined) {\n throw new Error('ngpTabPanel: value is required');\n }\n }\n\n ngOnDestroy(): void {\n this.state().unregisterTab(this);\n }\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n input,\n OnInit,\n output,\n signal,\n} from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectTabsConfig } from '../config/tabs-config';\nimport type { NgpTabPanel } from '../tab-panel/tab-panel';\nimport { provideTabsetState, tabsetState } from './tabset-state';\n\n/**\n * Apply the `ngpTabset` directive to an element to manage the tabs.\n */\n@Directive({\n selector: '[ngpTabset]',\n exportAs: 'ngpTabset',\n providers: [provideTabsetState()],\n hostDirectives: [\n {\n directive: NgpRovingFocusGroup,\n inputs: ['ngpRovingFocusGroupOrientation:ngpTabsetOrientation'],\n },\n ],\n host: {\n '[attr.id]': 'state.id()',\n '[attr.data-orientation]': 'state.orientation()',\n },\n})\nexport class NgpTabset implements OnInit {\n /**\n * Access the global tabset configuration\n */\n private readonly config = injectTabsConfig();\n\n /**\n * Access the roving focus group state\n */\n private readonly rovingFocusGroupState = injectRovingFocusGroupState();\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 = input<string>(undefined, {\n alias: 'ngpTabsetValue',\n });\n\n /**\n * Emit the value of the selected tab when it changes\n */\n readonly valueChange = output<string | undefined>({\n alias: 'ngpTabsetValueChange',\n });\n\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n readonly orientation = input<NgpOrientation>(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 * @internal\n */\n readonly panels = signal<NgpTabPanel[]>([]);\n\n /**\n * @internal\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.state.value())) {\n return this.state.value();\n }\n\n // otherwise return the first tab\n return panels[0]?.value();\n });\n\n /**\n * The state of the tabset\n */\n protected readonly state = tabsetState<NgpTabset>(this);\n\n ngOnInit(): void {\n // the roving focus group defaults to vertical orientation whereas\n // the default for the tabset may be different if provided via global config\n this.rovingFocusGroupState().orientation.set(this.state.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 // if the value is already selected, do nothing\n if (this.state.value() === value) {\n return;\n }\n\n this.state.value.set(value);\n this.valueChange.emit(value);\n }\n\n /**\n * @internal\n * Register a tab with the tabset\n */\n registerTab(tab: NgpTabPanel): void {\n this.panels.update(panels => [...panels, tab]);\n }\n\n /**\n * @internal\n * Unregister a tab with the tabset\n */\n unregisterTab(tab: NgpTabPanel): void {\n this.panels.update(panels => panels.filter(panel => panel !== tab));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAuBO,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,eAAe,EAAE,I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Ref, Injector, input, booleanAttribute,
|
|
3
|
-
import { TemplatePortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
2
|
+
import { InjectionToken, inject, ElementRef, ViewContainerRef, Injector, input, booleanAttribute, numberAttribute, computed, signal, TemplateRef, Type, ComponentRef, Directive, PLATFORM_ID, isDevMode } from '@angular/core';
|
|
3
|
+
import { TemplatePortal, ComponentPortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
4
4
|
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
5
5
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
6
|
import { offset, shift, flip, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
7
|
+
import * as i1 from 'ng-primitives/internal';
|
|
8
|
+
import { injectExitAnimationManager, provideExitAnimationManager, NgpExitAnimation } from 'ng-primitives/internal';
|
|
7
9
|
import { fromResizeEvent } from 'ng-primitives/resize';
|
|
8
|
-
import { injectDisposables
|
|
10
|
+
import { injectDisposables } from 'ng-primitives/utils';
|
|
9
11
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
10
12
|
import { getTransformOrigin } from 'ng-primitives/popover';
|
|
11
13
|
|
|
@@ -39,6 +41,20 @@ function injectTooltipConfig() {
|
|
|
39
41
|
return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
const NgpTooltipContextToken = new InjectionToken('NgpTooltipContextToken');
|
|
45
|
+
/**
|
|
46
|
+
* Inject the Tooltip context
|
|
47
|
+
*/
|
|
48
|
+
function injectTooltipContext() {
|
|
49
|
+
return inject(NgpTooltipContextToken);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Provide the Tooltip directive instance
|
|
53
|
+
*/
|
|
54
|
+
function provideTooltipContext(context) {
|
|
55
|
+
return { provide: NgpTooltipContextToken, useValue: context };
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
/**
|
|
43
59
|
* The state token for the TooltipTrigger primitive.
|
|
44
60
|
*/
|
|
@@ -61,6 +77,10 @@ const tooltipTriggerState = createState(NgpTooltipTriggerStateToken);
|
|
|
61
77
|
*/
|
|
62
78
|
class NgpTooltipTrigger {
|
|
63
79
|
constructor() {
|
|
80
|
+
/**
|
|
81
|
+
* Access the exit animation manager.
|
|
82
|
+
*/
|
|
83
|
+
this.exitAnimationManager = injectExitAnimationManager();
|
|
64
84
|
/**
|
|
65
85
|
* Access the trigger element
|
|
66
86
|
*/
|
|
@@ -88,23 +108,9 @@ class NgpTooltipTrigger {
|
|
|
88
108
|
/**
|
|
89
109
|
* Access the tooltip template ref.
|
|
90
110
|
*/
|
|
91
|
-
this.tooltip = input
|
|
111
|
+
this.tooltip = input(null, {
|
|
92
112
|
alias: 'ngpTooltipTrigger',
|
|
93
113
|
});
|
|
94
|
-
/**
|
|
95
|
-
* The open state of the tooltip.
|
|
96
|
-
* @default false
|
|
97
|
-
*/
|
|
98
|
-
this.open = input(false, {
|
|
99
|
-
alias: 'ngpTooltipTriggerOpen',
|
|
100
|
-
transform: booleanAttribute,
|
|
101
|
-
});
|
|
102
|
-
/**
|
|
103
|
-
* Emit an event when the tooltip is opened or closed.
|
|
104
|
-
*/
|
|
105
|
-
this.openChange = output({
|
|
106
|
-
alias: 'ngpTooltipTriggerOpenChange',
|
|
107
|
-
});
|
|
108
114
|
/**
|
|
109
115
|
* Define if the trigger should be disabled.
|
|
110
116
|
* @default false
|
|
@@ -159,6 +165,13 @@ class NgpTooltipTrigger {
|
|
|
159
165
|
this.container = input(this.config.container, {
|
|
160
166
|
alias: 'ngpTooltipTriggerContainer',
|
|
161
167
|
});
|
|
168
|
+
/**
|
|
169
|
+
* Provide context to the tooltip.
|
|
170
|
+
* @default null
|
|
171
|
+
*/
|
|
172
|
+
this.context = input(null, {
|
|
173
|
+
alias: 'ngpTooltipTriggerContext',
|
|
174
|
+
});
|
|
162
175
|
/**
|
|
163
176
|
* Store the tooltip view ref.
|
|
164
177
|
*/
|
|
@@ -191,8 +204,6 @@ class NgpTooltipTrigger {
|
|
|
191
204
|
* @internal
|
|
192
205
|
*/
|
|
193
206
|
this.state = tooltipTriggerState(this);
|
|
194
|
-
// any time the open state changes then show or hide the tooltip
|
|
195
|
-
onBooleanChange(this.state.open, this.show.bind(this), this.hide.bind(this));
|
|
196
207
|
// update the width of the trigger when it resizes
|
|
197
208
|
fromResizeEvent(this.trigger.nativeElement)
|
|
198
209
|
.pipe(takeUntilDestroyed())
|
|
@@ -201,33 +212,72 @@ class NgpTooltipTrigger {
|
|
|
201
212
|
ngOnDestroy() {
|
|
202
213
|
this.destroyTooltip();
|
|
203
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Show the tooltip.
|
|
217
|
+
*/
|
|
204
218
|
show() {
|
|
219
|
+
// if closing is in progress then clear the timeout to stop the popover from closing
|
|
220
|
+
if (this.closeTimeout) {
|
|
221
|
+
this.closeTimeout();
|
|
222
|
+
this.closeTimeout = undefined;
|
|
223
|
+
}
|
|
205
224
|
// if the trigger is disabled or the tooltip is already open then do not show the tooltip
|
|
206
|
-
if (this.state.disabled() || this.
|
|
225
|
+
if (this.state.disabled() || this.openTimeout) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
// if the tooltip exists in the DOM then do not create it again
|
|
229
|
+
if (this.viewRef) {
|
|
207
230
|
return;
|
|
208
231
|
}
|
|
209
|
-
this.
|
|
210
|
-
this.openChange.emit(true);
|
|
211
|
-
this.disposables.setTimeout(() => this.createTooltip(), this.state.showDelay());
|
|
232
|
+
this.openTimeout = this.disposables.setTimeout(() => this.createTooltip(), this.state.showDelay());
|
|
212
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Hide the tooltip.
|
|
236
|
+
*/
|
|
213
237
|
hide() {
|
|
238
|
+
// if closing is in progress then clear the timeout to stop the popover from opening
|
|
239
|
+
if (this.openTimeout) {
|
|
240
|
+
this.openTimeout();
|
|
241
|
+
this.openTimeout = undefined;
|
|
242
|
+
}
|
|
214
243
|
// if the trigger is disabled or the tooltip is already closed then do not hide the tooltip
|
|
215
|
-
if (this.state.disabled() ||
|
|
244
|
+
if (this.state.disabled() || this.closeTimeout) {
|
|
216
245
|
return;
|
|
217
246
|
}
|
|
218
|
-
this.
|
|
219
|
-
this.openChange.emit(false);
|
|
220
|
-
this.disposables.setTimeout(() => this.destroyTooltip(), this.state.hideDelay());
|
|
247
|
+
this.closeTimeout = this.disposables.setTimeout(() => this.destroyTooltip(), this.state.hideDelay());
|
|
221
248
|
}
|
|
222
249
|
createTooltip() {
|
|
223
|
-
|
|
224
|
-
const
|
|
250
|
+
this.openTimeout = undefined;
|
|
251
|
+
const tooltip = this.state.tooltip();
|
|
252
|
+
let portal;
|
|
253
|
+
// Create a new inject with the tooltip context
|
|
254
|
+
const injector = Injector.create({
|
|
225
255
|
parent: this.injector,
|
|
226
|
-
providers: [],
|
|
227
|
-
})
|
|
256
|
+
providers: [provideTooltipContext(this.state.context())],
|
|
257
|
+
});
|
|
258
|
+
if (tooltip instanceof TemplateRef) {
|
|
259
|
+
portal = new TemplatePortal(tooltip, this.viewContainerRef, { $implicit: this.state.context() }, injector);
|
|
260
|
+
}
|
|
261
|
+
else if (tooltip instanceof Type) {
|
|
262
|
+
portal = new ComponentPortal(tooltip, this.viewContainerRef, injector);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
throw new Error('Tooltip must be either a TemplateRef or a ComponentType');
|
|
266
|
+
}
|
|
267
|
+
const domOutlet = new DomPortalOutlet(this.state.container() ?? this.document.body, undefined, undefined, injector);
|
|
228
268
|
this.viewRef = domOutlet.attach(portal);
|
|
229
|
-
|
|
230
|
-
|
|
269
|
+
let outletElement = null;
|
|
270
|
+
if (this.viewRef instanceof ComponentRef) {
|
|
271
|
+
this.viewRef.changeDetectorRef.detectChanges();
|
|
272
|
+
outletElement = this.viewRef.location.nativeElement;
|
|
273
|
+
}
|
|
274
|
+
else if (this.viewRef) {
|
|
275
|
+
this.viewRef.detectChanges();
|
|
276
|
+
outletElement = this.viewRef.rootNodes[0];
|
|
277
|
+
}
|
|
278
|
+
if (!outletElement) {
|
|
279
|
+
throw new Error('Outlet element is not available.');
|
|
280
|
+
}
|
|
231
281
|
// we want to determine the strategy to use. If the tooltip has position: fixed then we want to use
|
|
232
282
|
// fixed positioning. Otherwise we want to use absolute positioning.
|
|
233
283
|
const strategy = getComputedStyle(outletElement).position === 'fixed' ? 'fixed' : 'absolute';
|
|
@@ -240,25 +290,25 @@ class NgpTooltipTrigger {
|
|
|
240
290
|
this.position.set({ x: position.x, y: position.y });
|
|
241
291
|
});
|
|
242
292
|
}
|
|
243
|
-
destroyTooltip() {
|
|
244
|
-
this.
|
|
245
|
-
this.
|
|
293
|
+
async destroyTooltip() {
|
|
294
|
+
this.closeTimeout = undefined;
|
|
295
|
+
await this.exitAnimationManager.exit();
|
|
246
296
|
this.viewRef?.destroy();
|
|
247
297
|
this.viewRef = null;
|
|
248
298
|
this.dispose?.();
|
|
249
299
|
}
|
|
250
300
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTooltipTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
251
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", type: NgpTooltipTrigger, isStandalone: true, selector: "[ngpTooltipTrigger]", inputs: { tooltip: { classPropertyName: "tooltip", publicName: "ngpTooltipTrigger", isSignal: true, isRequired:
|
|
301
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", type: NgpTooltipTrigger, isStandalone: true, selector: "[ngpTooltipTrigger]", inputs: { tooltip: { classPropertyName: "tooltip", publicName: "ngpTooltipTrigger", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpTooltipTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpTooltipTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpTooltipTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpTooltipTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpTooltipTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpTooltipTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpTooltipTriggerContainer", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ngpTooltipTriggerContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "show()", "mouseleave": "hide()", "focus": "show()", "blur": "hide()" }, properties: { "attr.data-open": "viewRef !== null ? \"\" : null", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [provideTooltipTriggerState(), provideExitAnimationManager()], exportAs: ["ngpTooltipTrigger"], ngImport: i0 }); }
|
|
252
302
|
}
|
|
253
303
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTooltipTrigger, decorators: [{
|
|
254
304
|
type: Directive,
|
|
255
305
|
args: [{
|
|
256
306
|
selector: '[ngpTooltipTrigger]',
|
|
257
307
|
exportAs: 'ngpTooltipTrigger',
|
|
258
|
-
providers: [provideTooltipTriggerState()],
|
|
308
|
+
providers: [provideTooltipTriggerState(), provideExitAnimationManager()],
|
|
259
309
|
host: {
|
|
260
|
-
'[attr.data-open]': '
|
|
261
|
-
'[attr.data-disabled]': 'disabled() ? "" : null',
|
|
310
|
+
'[attr.data-open]': 'viewRef !== null ? "" : null',
|
|
311
|
+
'[attr.data-disabled]': 'state.disabled() ? "" : null',
|
|
262
312
|
'(mouseenter)': 'show()',
|
|
263
313
|
'(mouseleave)': 'hide()',
|
|
264
314
|
'(focus)': 'show()',
|
|
@@ -307,13 +357,14 @@ class NgpTooltip {
|
|
|
307
357
|
}
|
|
308
358
|
}
|
|
309
359
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
310
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.7", type: NgpTooltip, isStandalone: true, selector: "[ngpTooltip]", host: { attributes: { "role": "tooltip" }, properties: { "style.left.px": "x()", "style.top.px": "y()", "style.--ngp-tooltip-trigger-width.px": "trigger().width()", "style.--ngp-tooltip-transform-origin": "transformOrigin()" } }, exportAs: ["ngpTooltip"], ngImport: i0 }); }
|
|
360
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.7", type: NgpTooltip, isStandalone: true, selector: "[ngpTooltip]", host: { attributes: { "role": "tooltip" }, properties: { "style.left.px": "x()", "style.top.px": "y()", "style.--ngp-tooltip-trigger-width.px": "trigger().width()", "style.--ngp-tooltip-transform-origin": "transformOrigin()" } }, exportAs: ["ngpTooltip"], hostDirectives: [{ directive: i1.NgpExitAnimation }], ngImport: i0 }); }
|
|
311
361
|
}
|
|
312
362
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpTooltip, decorators: [{
|
|
313
363
|
type: Directive,
|
|
314
364
|
args: [{
|
|
315
365
|
selector: '[ngpTooltip]',
|
|
316
366
|
exportAs: 'ngpTooltip',
|
|
367
|
+
hostDirectives: [NgpExitAnimation],
|
|
317
368
|
host: {
|
|
318
369
|
role: 'tooltip',
|
|
319
370
|
'[style.left.px]': 'x()',
|
|
@@ -328,5 +379,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
328
379
|
* Generated bundle index. Do not edit.
|
|
329
380
|
*/
|
|
330
381
|
|
|
331
|
-
export { NgpTooltip, NgpTooltipTrigger, injectTooltipTriggerState, provideTooltipConfig, provideTooltipTriggerState };
|
|
382
|
+
export { NgpTooltip, NgpTooltipContextToken, NgpTooltipTrigger, injectTooltipContext, injectTooltipTriggerState, provideTooltipConfig, provideTooltipContext, provideTooltipTriggerState };
|
|
332
383
|
//# sourceMappingURL=ng-primitives-tooltip.mjs.map
|