@ngneat/helipopper 12.2.0 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -2
- package/fesm2022/ngneat-helipopper-config.mjs +17 -3
- package/fesm2022/ngneat-helipopper-config.mjs.map +1 -1
- package/fesm2022/ngneat-helipopper.mjs +256 -204
- package/fesm2022/ngneat-helipopper.mjs.map +1 -1
- package/package.json +8 -7
- package/{config/index.d.ts → types/ngneat-helipopper-config.d.ts} +13 -7
- package/{index.d.ts → types/ngneat-helipopper.d.ts} +24 -11
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ If you're using v1 and don't want to migrate, you can find it [here](https://git
|
|
|
35
35
|
✅ Manual Trigger Support<br>
|
|
36
36
|
✅ Text Overflow Support<br>
|
|
37
37
|
✅ Context Menu Support<br>
|
|
38
|
+
✅ Component Bindings via `inputBinding` / `outputBinding` / `twoWayBinding`<br>
|
|
39
|
+
✅ Global Enable / Disable All<br>
|
|
38
40
|
|
|
39
41
|
### Installation
|
|
40
42
|
|
|
@@ -142,6 +144,40 @@ class MyComponent {
|
|
|
142
144
|
<button [tp]="MyComponent">Click Me</button>
|
|
143
145
|
```
|
|
144
146
|
|
|
147
|
+
### Component Bindings
|
|
148
|
+
|
|
149
|
+
Pass reactive Angular bindings (`inputBinding`, `outputBinding`, `twoWayBinding`) to a dynamically created component using the `tpBindings` input:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { inputBinding, signal } from '@angular/core';
|
|
153
|
+
import { MyPopoverComponent } from './my-popover.component';
|
|
154
|
+
|
|
155
|
+
@Component({})
|
|
156
|
+
class HostComponent {
|
|
157
|
+
component = MyPopoverComponent;
|
|
158
|
+
readonly greeting = signal('Hello!');
|
|
159
|
+
readonly bindings = [
|
|
160
|
+
inputBinding('greeting', () => this.greeting()),
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<button [tp]="component" tpVariation="popper" [tpBindings]="bindings">Open</button>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The same `bindings` option is available when creating a tooltip programmatically via `TippyService`:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { inputBinding } from '@angular/core';
|
|
173
|
+
|
|
174
|
+
this.tippyService.create(host, MyPopoverComponent, {
|
|
175
|
+
bindings: [inputBinding('greeting', () => this.greeting())],
|
|
176
|
+
}).subscribe((instance) => { ... });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Host directives can be applied the same way using `tpDirectives` / `directives`.
|
|
180
|
+
|
|
145
181
|
### Text Overflow
|
|
146
182
|
|
|
147
183
|
You can pass the `onlyTextOverflow` input to show the tooltip only when the host overflows its container:
|
|
@@ -293,13 +329,14 @@ tpIsEnabled: boolean;
|
|
|
293
329
|
tpIsVisible: boolean;
|
|
294
330
|
tpClassName: string;
|
|
295
331
|
tpOnlyTextOverflow: boolean;
|
|
332
|
+
tpStaticWidthHost: boolean;
|
|
296
333
|
tpData: any;
|
|
297
334
|
tpUseHostWidth: boolean;
|
|
298
335
|
tpHideOnEscape: boolean;
|
|
299
|
-
tpDetectChangesComponent: boolean;
|
|
300
336
|
tpPopperWidth: number | string;
|
|
301
337
|
tpHost: HTMLElement;
|
|
302
|
-
|
|
338
|
+
tpBindings: Binding[]; // inputBinding / outputBinding / twoWayBinding descriptors
|
|
339
|
+
tpDirectives: DirectiveWithBindings[]; // host directives with optional bindings
|
|
303
340
|
```
|
|
304
341
|
|
|
305
342
|
### Outputs
|
|
@@ -340,6 +377,26 @@ class Component {
|
|
|
340
377
|
}
|
|
341
378
|
```
|
|
342
379
|
|
|
380
|
+
### Enable / Disable All Tooltips
|
|
381
|
+
|
|
382
|
+
`TippyService` exposes `enableAll()` and `disableAll()` methods that globally enable or disable every tooltip managed by the service:
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
class MyComponent {
|
|
386
|
+
private tippyService = inject(TippyService);
|
|
387
|
+
|
|
388
|
+
disableTooltips() {
|
|
389
|
+
this.tippyService.disableAll();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
enableTooltips() {
|
|
393
|
+
this.tippyService.enableAll();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Tooltips that were individually disabled via `[tpIsEnabled]="false"` are not re-enabled by `enableAll()`.
|
|
399
|
+
|
|
343
400
|
## Contributors ✨
|
|
344
401
|
|
|
345
402
|
Thank goes to all these wonderful [people who contributed](https://github.com/ngneat/helipopper/graphs/contributors) ❤️
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InjectionToken, makeEnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { of } from 'rxjs';
|
|
2
3
|
|
|
3
4
|
const tooltipVariation = {
|
|
4
5
|
theme: undefined,
|
|
@@ -27,17 +28,30 @@ function withContextMenuVariation(baseVariation) {
|
|
|
27
28
|
|
|
28
29
|
const TIPPY_LOADER = new InjectionToken(ngDevMode ? 'TIPPY_LOADER' : '');
|
|
29
30
|
const TIPPY_CONFIG = new InjectionToken(ngDevMode ? 'TIPPY_CONFIG' : '');
|
|
31
|
+
const TIPPY_LOADER_COMPONENT = new InjectionToken(ngDevMode ? 'TIPPY_LOADER_COMPONENT' : '');
|
|
32
|
+
const TIPPY_LOADER_TIMING = new InjectionToken(ngDevMode ? 'TIPPY_LOADER_TIMING' : '', { factory: () => of(undefined) });
|
|
30
33
|
|
|
31
34
|
function provideTippyLoader(loader) {
|
|
32
35
|
return makeEnvironmentProviders([{ provide: TIPPY_LOADER, useValue: loader }]);
|
|
33
36
|
}
|
|
34
|
-
function provideTippyConfig(config) {
|
|
35
|
-
return
|
|
37
|
+
function provideTippyConfig(config, ...features) {
|
|
38
|
+
return makeEnvironmentProviders([
|
|
39
|
+
{ provide: TIPPY_CONFIG, useValue: config },
|
|
40
|
+
...features,
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
function withTippyLoaderComponent(component) {
|
|
44
|
+
return makeEnvironmentProviders([
|
|
45
|
+
{ provide: TIPPY_LOADER_COMPONENT, useValue: component },
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
function withTippyLoaderTiming(timing) {
|
|
49
|
+
return makeEnvironmentProviders([{ provide: TIPPY_LOADER_TIMING, useValue: timing }]);
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
/**
|
|
39
53
|
* Generated bundle index. Do not edit.
|
|
40
54
|
*/
|
|
41
55
|
|
|
42
|
-
export { TIPPY_CONFIG, TIPPY_LOADER, popperVariation, provideTippyConfig, provideTippyLoader, tooltipVariation, withContextMenuVariation };
|
|
56
|
+
export { TIPPY_CONFIG, TIPPY_LOADER, TIPPY_LOADER_COMPONENT, TIPPY_LOADER_TIMING, popperVariation, provideTippyConfig, provideTippyLoader, tooltipVariation, withContextMenuVariation, withTippyLoaderComponent, withTippyLoaderTiming };
|
|
43
57
|
//# sourceMappingURL=ngneat-helipopper-config.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngneat-helipopper-config.mjs","sources":["../../../../projects/ngneat/helipopper/config/src/defaults.ts","../../../../projects/ngneat/helipopper/config/src/tippy.types.ts","../../../../projects/ngneat/helipopper/config/src/providers.ts","../../../../projects/ngneat/helipopper/config/src/ngneat-helipopper-config.ts"],"sourcesContent":["import type { TippyProps } from './tippy.types';\n\n// A variation is a set of predefined tippy properties.\ntype Variation = Partial<TippyProps>;\n\nexport const tooltipVariation: Variation = {\n theme: undefined,\n arrow: false,\n animation: 'scale',\n trigger: 'mouseenter focus',\n offset: [0, 5],\n};\n\nexport const popperVariation: Variation = {\n theme: 'light',\n arrow: true,\n offset: [0, 10],\n animation: undefined,\n trigger: 'click',\n interactive: true,\n};\n\nexport function withContextMenuVariation(baseVariation: Variation): Variation {\n return {\n ...baseVariation,\n placement: 'right-start',\n trigger: 'manual',\n arrow: false,\n offset: [0, 0],\n };\n}\n","import type tippy from 'tippy.js';\nimport type { Instance, Props } from 'tippy.js';\nimport { ElementRef, InjectionToken } from '@angular/core';\nimport type { ResolveViewRef, ViewOptions } from '@ngneat/overview';\n\nexport interface CreateOptions extends Partial<TippyProps>, ViewOptions {\n variation: string;\n preserveView: boolean;\n className: string | string[];\n data: any;\n}\n\nexport interface TippyInstance extends Instance {\n data?: any;\n}\n\nexport type TippyProps = Props;\n\nexport interface ExtendedTippyProps extends TippyProps {\n variations: Record<string, Partial<TippyProps>>;\n defaultVariation: keyof ExtendedTippyProps['variations'];\n beforeRender?: (text: string) => string;\n zIndexGetter?(): number;\n}\n\nexport type TippyElement = ElementRef | Element;\n\nexport interface ExtendedTippyInstance<T> extends TippyInstance {\n view: ResolveViewRef<T> | null;\n $viewOptions: ViewOptions;\n context?: ViewOptions['context'];\n}\n\nexport type TippyConfig = Partial<ExtendedTippyProps>;\n\nexport type TippyLoader = () => typeof tippy | Promise<{ default: typeof tippy }>;\n\nexport const TIPPY_LOADER = new InjectionToken<TippyLoader>(\n ngDevMode ? 'TIPPY_LOADER' : '',\n);\n\nexport const TIPPY_CONFIG = new InjectionToken<TippyConfig>(\n ngDevMode ? 'TIPPY_CONFIG' : '',\n);\n","import { makeEnvironmentProviders,
|
|
1
|
+
{"version":3,"file":"ngneat-helipopper-config.mjs","sources":["../../../../projects/ngneat/helipopper/config/src/defaults.ts","../../../../projects/ngneat/helipopper/config/src/tippy.types.ts","../../../../projects/ngneat/helipopper/config/src/providers.ts","../../../../projects/ngneat/helipopper/config/src/ngneat-helipopper-config.ts"],"sourcesContent":["import type { TippyProps } from './tippy.types';\n\n// A variation is a set of predefined tippy properties.\ntype Variation = Partial<TippyProps>;\n\nexport const tooltipVariation: Variation = {\n theme: undefined,\n arrow: false,\n animation: 'scale',\n trigger: 'mouseenter focus',\n offset: [0, 5],\n};\n\nexport const popperVariation: Variation = {\n theme: 'light',\n arrow: true,\n offset: [0, 10],\n animation: undefined,\n trigger: 'click',\n interactive: true,\n};\n\nexport function withContextMenuVariation(baseVariation: Variation): Variation {\n return {\n ...baseVariation,\n placement: 'right-start',\n trigger: 'manual',\n arrow: false,\n offset: [0, 0],\n };\n}\n","import type tippy from 'tippy.js';\nimport type { Instance, Props } from 'tippy.js';\nimport { ElementRef, InjectionToken, Type } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport type { Content, ResolveViewRef, ViewOptions } from '@ngneat/overview';\n\nexport interface CreateOptions extends Partial<TippyProps>, ViewOptions {\n variation: string;\n preserveView: boolean;\n className: string | string[];\n data: any;\n}\n\nexport interface TippyInstance extends Instance {\n data?: any;\n}\n\nexport type TippyProps = Props;\n\nexport interface ExtendedTippyProps extends TippyProps {\n variations: Record<string, Partial<TippyProps>>;\n defaultVariation: keyof ExtendedTippyProps['variations'];\n beforeRender?: (text: string) => string;\n zIndexGetter?(): number;\n}\n\nexport type TippyElement = ElementRef | Element;\n\nexport interface ExtendedTippyInstance<T> extends TippyInstance {\n view: ResolveViewRef<T> | null;\n $viewOptions: ViewOptions;\n context?: ViewOptions['context'];\n}\n\nexport type TippyConfig = Partial<ExtendedTippyProps>;\n\nexport type TippyContent = Content | (() => Promise<Type<any>>);\n\nexport type TippyLoader = () => typeof tippy | Promise<{ default: typeof tippy }>;\n\nexport const TIPPY_LOADER = new InjectionToken<TippyLoader>(\n ngDevMode ? 'TIPPY_LOADER' : '',\n);\n\nexport const TIPPY_CONFIG = new InjectionToken<TippyConfig>(\n ngDevMode ? 'TIPPY_CONFIG' : '',\n);\n\nexport const TIPPY_LOADER_COMPONENT = new InjectionToken<Type<unknown>>(\n ngDevMode ? 'TIPPY_LOADER_COMPONENT' : '',\n);\n\nexport type TippyLoaderTiming = Observable<void>;\n\nexport const TIPPY_LOADER_TIMING = new InjectionToken<TippyLoaderTiming>(\n ngDevMode ? 'TIPPY_LOADER_TIMING' : '',\n { factory: () => of(undefined) },\n);\n","import { EnvironmentProviders, makeEnvironmentProviders, Type } from '@angular/core';\n\nimport {\n TIPPY_CONFIG,\n TIPPY_LOADER,\n TIPPY_LOADER_COMPONENT,\n TIPPY_LOADER_TIMING,\n type TippyLoader,\n type TippyConfig,\n type TippyLoaderTiming,\n} from './tippy.types';\n\nexport function provideTippyLoader(loader: TippyLoader) {\n return makeEnvironmentProviders([{ provide: TIPPY_LOADER, useValue: loader }]);\n}\n\nexport function provideTippyConfig(\n config: TippyConfig,\n ...features: EnvironmentProviders[]\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: TIPPY_CONFIG, useValue: config },\n ...features,\n ]);\n}\n\nexport function withTippyLoaderComponent(component: Type<unknown>): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: TIPPY_LOADER_COMPONENT, useValue: component },\n ]);\n}\n\nexport function withTippyLoaderTiming(timing: TippyLoaderTiming): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: TIPPY_LOADER_TIMING, useValue: timing }]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAKO,MAAM,gBAAgB,GAAc;AACzC,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,SAAS,EAAE,OAAO;AAClB,IAAA,OAAO,EAAE,kBAAkB;AAC3B,IAAA,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;;AAGT,MAAM,eAAe,GAAc;AACxC,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AACf,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,WAAW,EAAE,IAAI;;AAGb,SAAU,wBAAwB,CAAC,aAAwB,EAAA;IAC/D,OAAO;AACL,QAAA,GAAG,aAAa;AAChB,QAAA,SAAS,EAAE,aAAa;AACxB,QAAA,OAAO,EAAE,QAAQ;AACjB,QAAA,KAAK,EAAE,KAAK;AACZ,QA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