@nysds/nys-unavheader 1.22.3 → 1.23.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/dist/nys-unavheader.d.ts +64 -10
- package/dist/nys-unavheader.js +302 -114
- package/dist/nys-unavheader.js.map +1 -1
- package/package.json +6 -6
package/dist/nys-unavheader.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import "@nysds/nys-alert";
|
|
|
7
7
|
export interface Language {
|
|
8
8
|
code: string;
|
|
9
9
|
label: string;
|
|
10
|
+
nativeText: string;
|
|
11
|
+
disclaimer?: string;
|
|
10
12
|
url?: string;
|
|
11
13
|
}
|
|
12
14
|
/** Detail payload for the `nys-language-select` event fired by `nys-unavheader`. */
|
|
@@ -25,10 +27,16 @@ export type NysUnavheaderSearchSubmitEvent = CustomEvent<NysUnavheaderSearchSubm
|
|
|
25
27
|
* Statewide alert endpoint, read once per page load. Sites don't opt in or out and
|
|
26
28
|
* never author the content, so an alert reads identically everywhere it appears.
|
|
27
29
|
*
|
|
30
|
+
* Which one is read is chosen by the page's `<body data-environment="...">`:
|
|
31
|
+
* `dev` → development, `stage` → stage, anything else (or absent) → production.
|
|
32
|
+
*
|
|
28
33
|
* Production is https://alerts-cta.static-assets.ny.gov/alerts.json.
|
|
29
|
-
*
|
|
34
|
+
* Development is https://alerts-cta-dev.static-assets.ny.gov/alerts.json
|
|
35
|
+
* Stage is https://alerts-cta-stage.static-assets.ny.gov/alerts.json
|
|
30
36
|
*/
|
|
31
37
|
export declare const NYS_ALERT_URL = "https://alerts-cta.static-assets.ny.gov/alerts.json";
|
|
38
|
+
export declare const NYS_ALERT_URL_DEV = "https://alerts-cta-dev.static-assets.ny.gov/alerts.json";
|
|
39
|
+
export declare const NYS_ALERT_URL_STAGE = "https://alerts-cta-stage.static-assets.ny.gov/alerts.json";
|
|
32
40
|
/**
|
|
33
41
|
* Universal NYS header with trust bar, logo, search, and language translation. Required on all NYS sites.
|
|
34
42
|
*
|
|
@@ -63,22 +71,29 @@ export declare const NYS_ALERT_URL = "https://alerts-cta.static-assets.ny.gov/al
|
|
|
63
71
|
* reaches every NYS site with no per-site work. If the endpoint is unreachable or nothing
|
|
64
72
|
* is published, the header renders normally. It takes no children.
|
|
65
73
|
*
|
|
74
|
+
* The endpoint's environment follows `<body data-environment="dev|stage">`,
|
|
75
|
+
* read once when the header connects (it is not watched for later changes);
|
|
76
|
+
* any other value, or none, reads production.
|
|
77
|
+
*
|
|
66
78
|
* @cssprop [--nys-max-width--content] - Overrides the inner content max width across the grid, header, footer, and breadcrumb. Set at a higher level like `:root` to apply to all instances. Takes priority over the size-specific variable.
|
|
67
79
|
* @fires {NysUnavheaderLanguageSelectEvent} nys-language-select - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Smartling redirect.
|
|
68
80
|
* @fires {NysUnavheaderSearchSubmitEvent} nys-search-submit - Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect.
|
|
69
81
|
*
|
|
70
|
-
* @
|
|
82
|
+
* @usage
|
|
71
83
|
* - Place at the top of every public-facing page.
|
|
72
84
|
* - Toggle search (`hideSearch`) and translate (`hideTranslate`) on/off depending on your needs.
|
|
73
85
|
* - Design your page so content below the header can shift down, since a statewide alert can appear at any time and adds height to the header.
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* -
|
|
77
|
-
* - Place anywhere other than the top of the page.
|
|
78
|
-
* - Modify the universal header.
|
|
86
|
+
* - Don't use on back office applications or internal sites that are not public-facing, instead use the `<nys-globalheader>` with the `nysLogo` property applied.
|
|
87
|
+
* - Don't place anywhere other than the top of the page.
|
|
88
|
+
* - Don't modify the universal header.
|
|
79
89
|
*
|
|
80
90
|
* @example Basic
|
|
81
91
|
* ```html
|
|
92
|
+
* <nys-unavheader translateKey="MY_TRANSLATE_KEY"></nys-unavheader>
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @example Basic - Smartling
|
|
96
|
+
* ```html
|
|
82
97
|
* <nys-unavheader></nys-unavheader>
|
|
83
98
|
* ```
|
|
84
99
|
*
|
|
@@ -87,7 +102,7 @@ export declare const NYS_ALERT_URL = "https://alerts-cta.static-assets.ny.gov/al
|
|
|
87
102
|
* <nys-unavheader hideSearch></nys-unavheader>
|
|
88
103
|
* ```
|
|
89
104
|
*
|
|
90
|
-
*
|
|
105
|
+
* @example Hide translate
|
|
91
106
|
* ```html
|
|
92
107
|
* <nys-unavheader hideTranslate></nys-unavheader>
|
|
93
108
|
* ```
|
|
@@ -143,6 +158,8 @@ export declare class NysUnavHeader extends NysElement {
|
|
|
143
158
|
hideSearch: boolean;
|
|
144
159
|
/** The URL endpoint of the search, make sure to include the query param. */
|
|
145
160
|
searchUrl: string;
|
|
161
|
+
/** Localize project key. If provided, the component will load and initialize LocalizeJS automatically. */
|
|
162
|
+
translateKey: string;
|
|
146
163
|
/**
|
|
147
164
|
* Accessible name for the `banner` landmark this header renders.
|
|
148
165
|
* Defaults to `"New York State"`.
|
|
@@ -159,7 +176,7 @@ export declare class NysUnavHeader extends NysElement {
|
|
|
159
176
|
* @default "New York State"
|
|
160
177
|
*/
|
|
161
178
|
landmarkLabel: string;
|
|
162
|
-
/** The list of languages this site can be translated to, default to use
|
|
179
|
+
/** The list of languages this site can be translated to, default to use Localize */
|
|
163
180
|
languages: Language[];
|
|
164
181
|
/**
|
|
165
182
|
* Lifecycle Methods
|
|
@@ -217,7 +234,6 @@ export declare class NysUnavHeader extends NysElement {
|
|
|
217
234
|
* the state onto the inner control, the same way `nys-dropdownmenu` does for its
|
|
218
235
|
* trigger (WCAG 4.1.2).
|
|
219
236
|
*/
|
|
220
|
-
private _syncTranslateTriggerAria;
|
|
221
237
|
/** The language options, in the order they are rendered. */
|
|
222
238
|
private _languageOptions;
|
|
223
239
|
/**
|
|
@@ -232,7 +248,44 @@ export declare class NysUnavHeader extends NysElement {
|
|
|
232
248
|
* -1 is the last option, so "previous from the first" and "End" are the same call.
|
|
233
249
|
*/
|
|
234
250
|
private _focusOption;
|
|
251
|
+
/**
|
|
252
|
+
* Smartling fallback (no `translateKey`)
|
|
253
|
+
* --------------------------------------------------------------------------
|
|
254
|
+
* Instead of client-side translation, each language option is rendered as a
|
|
255
|
+
* real link (`nys-button`'s `href`) to the same URL with the language code
|
|
256
|
+
* prepended as a subdomain label — agency.ny.gov -> es.agency.ny.gov. English
|
|
257
|
+
* strips the label entirely rather than adding "en.", since the untranslated
|
|
258
|
+
* site lives at the bare host.
|
|
259
|
+
*/
|
|
260
|
+
/** Removes a leading language-code subdomain label (e.g. "es.") if present. */
|
|
261
|
+
private _stripLanguagePrefix;
|
|
262
|
+
/** Builds the Smartling redirect URL for `languageCode`, preserving path/query/hash. */
|
|
263
|
+
private _smartlingUrl;
|
|
264
|
+
/**
|
|
265
|
+
* The navigation target for a language option's `href`, or `undefined` when
|
|
266
|
+
* the option isn't a link — Localize handles that case via `setLanguage`
|
|
267
|
+
* from a click on a plain button instead.
|
|
268
|
+
*
|
|
269
|
+
* An explicit per-language `url` always wins, even with a `translateKey`
|
|
270
|
+
* configured. Otherwise: no `translateKey` means Localize can't run at all,
|
|
271
|
+
* so every option is a Smartling subdomain link.
|
|
272
|
+
*/
|
|
273
|
+
private _languageHref;
|
|
274
|
+
private _initGoogletagmanager;
|
|
275
|
+
private _initLocalize;
|
|
235
276
|
private _toggleSearchDropdown;
|
|
277
|
+
/**
|
|
278
|
+
* Shows, replaces, or removes the translation disclaimer banner for the
|
|
279
|
+
* given language code.
|
|
280
|
+
*
|
|
281
|
+
* Called only from `_handleLanguageSelect`, i.e. only as the direct result of
|
|
282
|
+
* a user clicking a language in the dropdown. Deliberately not wired to
|
|
283
|
+
* Localize's own "setLanguage" event, which also fires for reasons that
|
|
284
|
+
* aren't a user picking a language on this page load — restoring a
|
|
285
|
+
* remembered language chief among them — and the disclaimer must not appear
|
|
286
|
+
* unprompted.
|
|
287
|
+
*/
|
|
288
|
+
private _updateTranslateDisclaimer;
|
|
236
289
|
private _handleLanguageSelect;
|
|
237
290
|
/**
|
|
238
291
|
* Keyboard model for the translate menu (APG menu button):
|
|
@@ -295,5 +348,6 @@ export declare class NysUnavHeader extends NysElement {
|
|
|
295
348
|
* #1795 found it — two unnamed banners — so it falls back to the default.
|
|
296
349
|
*/
|
|
297
350
|
private get _landmarkLabel();
|
|
351
|
+
private get _locale();
|
|
298
352
|
render(): import("lit-html").TemplateResult<1>;
|
|
299
353
|
}
|