@ecodev/natural 55.1.0 → 55.2.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.
@@ -1,5 +1,6 @@
1
1
  import { Literal } from '../types/types';
2
2
  import type { ReadonlyDeep } from 'type-fest';
3
+ import { PaginationInput, Sorting } from './query-variable-manager';
3
4
  /**
4
5
  * Very basic formatting to get only date, without time and ignoring entirely the timezone
5
6
  *
@@ -57,3 +58,15 @@ export declare function mergeOverrideArray(destValue: any, source: any): any;
57
58
  */
58
59
  export declare function copyToClipboard(document: Document, text: string): void;
59
60
  export declare function deepFreeze<T extends Literal>(o: T): ReadonlyDeep<T>;
61
+ /**
62
+ * Return a valid PaginationInput from whatever is available from data. Invalid properties/types will be dropped.
63
+ */
64
+ export declare function validatePagination(data: unknown): PaginationInput | null;
65
+ /**
66
+ * Return a valid Sortings from whatever is available from data. Invalid properties/types will be dropped.
67
+ */
68
+ export declare function validateSorting(data: unknown): Array<Sorting> | null;
69
+ /**
70
+ * Return valid columns from whatever is available from data. Invalid properties/types will be dropped.
71
+ */
72
+ export declare function validateColumns(data: unknown): string[] | null;
@@ -6,7 +6,7 @@ import * as i0 from "@angular/core";
6
6
  /**
7
7
  * Usage :
8
8
  *
9
- * <mat-tab-group mat-stretch-tabs="false" [naturalLinkableTab]="!isPanel">
9
+ * <mat-tab-group [naturalLinkableTab]="!isPanel">
10
10
  * <mat-tab label="Third 1">third 1</mat-tab> // First tab doesn't need id. This keeps url clean on default one
11
11
  * <mat-tab label="Third 2" id="third2">Third 2</mat-tab>
12
12
  * ...
@@ -18,6 +18,24 @@ export type NaturalSeoBasic = Robots & {
18
18
  * If given will be used as page description, otherwise fallback on default value
19
19
  */
20
20
  description?: string;
21
+ /**
22
+ * List of parameters included in the canonical tag's url
23
+ */
24
+ canonicalQueryParamsWhitelist?: string[];
25
+ };
26
+ export declare type NaturalLinkDefinition = {
27
+ charset?: string;
28
+ crossorigin?: string;
29
+ href?: string;
30
+ hreflang?: string;
31
+ media?: string;
32
+ rel?: string;
33
+ rev?: string;
34
+ sizes?: string;
35
+ target?: string;
36
+ type?: string;
37
+ } & {
38
+ [prop: string]: string;
21
39
  };
22
40
  /**
23
41
  * Typically used for a "dynamic" page where a single object is resolved. So a detail page, such
@@ -56,15 +74,15 @@ export interface NaturalSeoConfig {
56
74
  /**
57
75
  * The name of the application that will always appear in the page title
58
76
  */
59
- applicationName: string;
77
+ readonly applicationName: string;
60
78
  /**
61
79
  * Default value for description meta that is used for pages without value
62
80
  */
63
- defaultDescription?: string;
81
+ readonly defaultDescription?: string;
64
82
  /**
65
83
  * Default value for robots meta that is used for pages without value
66
84
  */
67
- defaultRobots?: string;
85
+ readonly defaultRobots?: string;
68
86
  /**
69
87
  * If given, the callback will be called for each route and must return a string that will
70
88
  * be inserted between the page title and the application name.
@@ -72,7 +90,12 @@ export interface NaturalSeoConfig {
72
90
  * It should be used to complete the title with info that are often, but not necessarily always,
73
91
  * available throughout the entire application. Typically used for the site/state in OKpilot.
74
92
  */
75
- extraPart?: (routeData: Data) => string;
93
+ readonly extraPart?: (routeData: Data) => string;
94
+ /**
95
+ * Used to generate alternative tags
96
+ * <link rel="alternate" hreflang="en" href="https://www.example.com/en/page">
97
+ */
98
+ readonly languages?: Readonly<string[]>;
76
99
  }
77
100
  export declare const NATURAL_SEO_CONFIG: InjectionToken<NaturalSeoConfig>;
78
101
  export declare function stripTags(str: string): string;
@@ -95,8 +118,10 @@ export declare class NaturalSeoService {
95
118
  private readonly router;
96
119
  private readonly titleService;
97
120
  private readonly metaTagService;
121
+ private readonly document;
122
+ private locale;
98
123
  private routeData?;
99
- constructor(config: NaturalSeoConfig, router: Router, titleService: Title, metaTagService: Meta);
124
+ constructor(config: NaturalSeoConfig, router: Router, titleService: Title, metaTagService: Meta, document: Document, locale: string);
100
125
  /**
101
126
  * Update the SEO with given info. The extra part and app name will be appended automatically.
102
127
  *
@@ -107,8 +132,28 @@ export declare class NaturalSeoService {
107
132
  * needed. For those cases the Component can inject this service and update the SEO directly.
108
133
  */
109
134
  update(seo: NaturalSeoBasic): void;
135
+ updateAlternates(urlParts: {
136
+ url: string;
137
+ params: string;
138
+ }): void;
139
+ private getUrlParts;
140
+ /**
141
+ * Add language between domain and uri https://example.com/fr/folder/page
142
+ * @param urlParts
143
+ * @param language
144
+ * @private
145
+ */
146
+ private getUrl;
147
+ private addLanguageSegment;
110
148
  private join;
111
149
  private updateTag;
150
+ private updateLinkTag;
151
+ /**
152
+ * Parse tag to create a selector
153
+ * @param definition
154
+ * @return {string} selector to use in querySelector
155
+ */
156
+ private _parseSelector;
112
157
  /**
113
158
  * Returns the data from the most deep/specific activated route
114
159
  */
@@ -25,7 +25,7 @@ export declare class NaturalPanelsService {
25
25
  /**
26
26
  * Stream that emits when all open dialog have finished closing
27
27
  */
28
- afterAllClosed: Subject<void>;
28
+ readonly afterAllClosed: Subject<void>;
29
29
  /**
30
30
  * Cache for panels counter. Works more like an ID.
31
31
  * Is used to give an unique identifier to multiple similar panels configurations
@@ -19,7 +19,7 @@ export declare class NaturalDropdownContainerComponent extends BasePortalOutlet
19
19
  /** Current state of the panel animation. */
20
20
  panelAnimationState: 'void' | 'enter';
21
21
  /** Emits whenever an animation on the menu completes. */
22
- private animationDone;
22
+ private readonly animationDone;
23
23
  private focusTrap;
24
24
  private elementFocusedBeforeDialogWasOpened;
25
25
  constructor(elementRef: ElementRef<HTMLElement>, focusTrapFactory: ConfigurableFocusTrapFactory, data: NaturalDropdownContainerData);
@@ -14,7 +14,7 @@ export interface FacetSelectorConfiguration {
14
14
  export declare class FacetSelectorComponent implements DropdownComponent {
15
15
  data: NaturalDropdownData<FacetSelectorConfiguration>;
16
16
  protected dropdownRef: NaturalDropdownRef;
17
- renderedValue: BehaviorSubject<string>;
17
+ readonly renderedValue: BehaviorSubject<string>;
18
18
  facets: NaturalSearchFacets;
19
19
  selection: Facet | null;
20
20
  constructor(data: NaturalDropdownData<FacetSelectorConfiguration>, dropdownRef: NaturalDropdownRef);
@@ -89,7 +89,7 @@ export declare class NaturalSelectComponent<TService extends NaturalAbstractMode
89
89
  /**
90
90
  * Init search options
91
91
  */
92
- private variablesManager;
92
+ private readonly variablesManager;
93
93
  /**
94
94
  * Whether the value can be changed
95
95
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodev/natural",
3
- "version": "55.1.0",
3
+ "version": "55.2.0",
4
4
  "license": "MIT",
5
5
  "repository": "github:Ecodev/natural",
6
6
  "sideEffects": false,