@asante-org/atlascopco-vt-litesitegenerator 3.8.3 → 3.8.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/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useRef, useEffect, useId, useCallback, useMemo, forwardRef, useImperativeHandle } from 'react';
1
+ import React, { useId, useState, useRef, useEffect, useCallback, useMemo, forwardRef, useImperativeHandle } from 'react';
2
2
 
3
3
  function _extends() {
4
4
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -46,12 +46,87 @@ var LsgButton = function (_a) {
46
46
  }, children);
47
47
  };
48
48
 
49
- function bannerClassName(layout, mobileMediaPosition, background, className) {
50
- return ["lsg-banner", "lsg-banner--".concat(layout), "lsg-banner--mobile-media-".concat(mobileMediaPosition),
51
- // In AEM this class arrives on the decoration div instead; the SCSS only
52
- // sets inherited custom properties, so either position works.
53
- background ? "lsg-banner--bg-".concat(background) : "", className].filter(Boolean).join(" ");
49
+ // ─────────────────────────────────────────────────────────────────────────────
50
+ // AEM markup helpers
51
+ //
52
+ // The banner's content region is a parsys in AEM, filled by _cq_template with
53
+ // Group > Title / Text / Button components. These helpers reproduce the HTML
54
+ // those components (and their Sling decoration divs) emit on publish, so the
55
+ // theme CSS written here applies to AEM unchanged. Reference page:
56
+ // /content/vtba/varovac/en (wcmmode=disabled).
57
+ // ─────────────────────────────────────────────────────────────────────────────
58
+ var GRID_COLUMN = "aem-GridColumn aem-GridColumn--default--12";
59
+ /** vtba/components/lsg/structure/group — a responsivegrid with two wrappers. */
60
+ var AemGroup = function (_a) {
61
+ var styleClasses = _a.styleClasses,
62
+ children = _a.children;
63
+ return /*#__PURE__*/React.createElement("div", {
64
+ className: ["lsg-group", styleClasses].filter(Boolean).join(" ")
65
+ }, /*#__PURE__*/React.createElement("div", {
66
+ className: "layout-container-color-wrapper"
67
+ }, /*#__PURE__*/React.createElement("div", {
68
+ className: "layout-container-spacing-wrapper aem-Grid aem-Grid--12 aem-Grid--default--12 "
69
+ }, children)));
70
+ };
71
+ /**
72
+ * AEM decoration class for a grid column: the component's own class, then either
73
+ * its authored style classes or — when none are set — the component name.
74
+ */
75
+ function columnClassName(componentClass, name, styleClass) {
76
+ return "".concat(componentClass, " ").concat(styleClass !== null && styleClass !== void 0 ? styleClass : name, " ").concat(GRID_COLUMN);
54
77
  }
78
+ /** vtba/components/lsg/content/title — type "p" is the pre-title. */
79
+ var AemTitle = function (_a) {
80
+ var Tag = _a.tag,
81
+ colour = _a.colour,
82
+ children = _a.children;
83
+ return /*#__PURE__*/React.createElement("div", {
84
+ className: columnClassName("cmp-lsg-title", "title", colour && "cmp-title__colour-".concat(colour))
85
+ }, /*#__PURE__*/React.createElement(Tag, {
86
+ className: "cmp-title__element".concat(Tag === "p" ? " cmp-title__element--pretitle" : "")
87
+ }, children));
88
+ };
89
+ /** vtba/components/lsg/content/text — core text v2 inside the decoration div. */
90
+ var AemText = function (_a) {
91
+ var id = _a.id,
92
+ colour = _a.colour,
93
+ children = _a.children;
94
+ return /*#__PURE__*/React.createElement("div", {
95
+ className: columnClassName("cmp-lsg-text", "text", colour && "cmp-text__colour-".concat(colour))
96
+ }, /*#__PURE__*/React.createElement("div", {
97
+ id: id,
98
+ className: "cmp-text"
99
+ }, /*#__PURE__*/React.createElement("p", null, children)));
100
+ };
101
+ /** vtba/components/lsg/content/button — the variant is a style class on the decoration div. */
102
+ var AemButton = function (_a) {
103
+ var _b, _c;
104
+ var cta = _a.cta;
105
+ return /*#__PURE__*/React.createElement("div", {
106
+ className: "cmp-lsg-button button--".concat((_b = cta.variant) !== null && _b !== void 0 ? _b : "primary", " ").concat(GRID_COLUMN)
107
+ }, /*#__PURE__*/React.createElement("div", {
108
+ className: "lsg-button-container"
109
+ }, /*#__PURE__*/React.createElement("a", {
110
+ className: "lsg-button",
111
+ href: (_c = cta.href) !== null && _c !== void 0 ? _c : "#",
112
+ target: cta.external ? "_blank" : undefined,
113
+ rel: cta.external ? "noopener noreferrer" : undefined,
114
+ onClick: cta.onClick
115
+ }, /*#__PURE__*/React.createElement("span", {
116
+ className: "lsg-button__text"
117
+ }, cta.label))));
118
+ };
119
+ /** Same extension mapping as BannerModel.getVideoMimeType. */
120
+ function videoMimeType(url) {
121
+ var path = url.split(/[?#]/)[0].toLowerCase();
122
+ if (path.endsWith(".mp4")) return "video/mp4";
123
+ if (path.endsWith(".webm")) return "video/webm";
124
+ if (path.endsWith(".ogg") || path.endsWith(".ogv")) return "video/ogg";
125
+ return undefined;
126
+ }
127
+ // ─────────────────────────────────────────────────────────────────────────────
128
+ // LsgBanner
129
+ // ─────────────────────────────────────────────────────────────────────────────
55
130
  var LsgBanner = function (_a) {
56
131
  var heading = _a.heading,
57
132
  preTitle = _a.preTitle,
@@ -60,10 +135,15 @@ var LsgBanner = function (_a) {
60
135
  copy = _a.copy,
61
136
  ctas = _a.ctas,
62
137
  cta = _a.cta,
138
+ preTitleColour = _a.preTitleColour,
139
+ headingColour = _a.headingColour,
140
+ bodyColour = _a.bodyColour,
63
141
  mediaType = _a.mediaType,
64
142
  imageUrl = _a.imageUrl,
65
143
  _b = _a.imageAlt,
66
144
  imageAlt = _b === void 0 ? "" : _b,
145
+ mediaHref = _a.mediaHref,
146
+ mediaTarget = _a.mediaTarget,
67
147
  videoUrl = _a.videoUrl,
68
148
  videoPoster = _a.videoPoster,
69
149
  _c = _a.videoControls,
@@ -79,65 +159,78 @@ var LsgBanner = function (_a) {
79
159
  _h = _a.mobileMediaPosition,
80
160
  mobileMediaPosition = _h === void 0 ? "top" : _h,
81
161
  background = _a.background,
162
+ accent = _a.accent,
82
163
  _j = _a.headingTag,
83
- headingTag = _j === void 0 ? "h1" : _j,
164
+ headingTag = _j === void 0 ? "h2" : _j,
84
165
  className = _a.className;
166
+ var textId = "text-".concat(useId().replace(/[^a-zA-Z0-9]/g, ""));
85
167
  var resolvedPreTitle = preTitle !== null && preTitle !== void 0 ? preTitle : eyebrow;
86
168
  var resolvedBody = body !== null && body !== void 0 ? body : copy;
87
169
  var actions = ((ctas === null || ctas === void 0 ? void 0 : ctas.length) ? ctas : cta ? [cta] : []).slice(0, 3);
88
170
  var resolvedMediaType = mediaType !== null && mediaType !== void 0 ? mediaType : videoUrl ? "video" : "image";
89
171
  var hasMedia = layout !== "text-only" && (resolvedMediaType === "video" ? Boolean(videoUrl) : Boolean(imageUrl));
90
- var HeadingTag = headingTag;
91
- return /*#__PURE__*/React.createElement("section", {
92
- className: bannerClassName(layout, mobileMediaPosition, background, className),
93
- "data-lsg-is": "banner",
94
- "data-lsg-banner-layout": layout,
95
- "data-lsg-banner-mobile-media": mobileMediaPosition,
96
- "data-lsg-banner-media": hasMedia ? resolvedMediaType : "none"
97
- }, /*#__PURE__*/React.createElement("div", {
98
- className: "lsg-banner__shell"
99
- }, hasMedia && /*#__PURE__*/React.createElement("div", {
100
- className: "lsg-banner__media"
101
- }, resolvedMediaType === "video" && videoUrl ? /*#__PURE__*/React.createElement("video", {
102
- className: "lsg-banner__video",
103
- src: videoUrl,
104
- poster: videoPoster,
105
- controls: videoControls,
106
- autoPlay: videoAutoPlay,
107
- muted: videoMuted,
108
- loop: videoLoop,
109
- playsInline: true,
110
- "aria-label": imageAlt || heading
111
- }) : imageUrl ? /*#__PURE__*/React.createElement("img", {
112
- className: "lsg-banner__image",
172
+ var picture = /*#__PURE__*/React.createElement("picture", {
173
+ className: "lsg-banner__image"
174
+ }, /*#__PURE__*/React.createElement("img", {
113
175
  src: imageUrl,
114
- alt: imageAlt
115
- }) : null), /*#__PURE__*/React.createElement("div", {
116
- className: "lsg-banner__content"
117
- }, resolvedPreTitle && /*#__PURE__*/React.createElement("div", {
118
- className: "lsg-banner__pre-title"
119
- }, /*#__PURE__*/React.createElement("span", {
120
- className: "lsg-banner__pre-title-marker",
121
- "aria-hidden": "true"
122
- }), /*#__PURE__*/React.createElement("span", {
123
- className: "lsg-banner__pre-title-text"
124
- }, resolvedPreTitle)), /*#__PURE__*/React.createElement(HeadingTag, {
125
- className: "lsg-banner__heading"
126
- }, heading), resolvedBody && /*#__PURE__*/React.createElement("div", {
127
- className: "lsg-banner__body"
128
- }, /*#__PURE__*/React.createElement("p", null, resolvedBody)), actions.length > 0 && /*#__PURE__*/React.createElement("div", {
129
- className: "lsg-banner__actions"
130
- }, actions.map(function (action, index) {
131
- var _a, _b;
132
- return /*#__PURE__*/React.createElement(LsgButton, {
133
- key: "".concat(action.label, "-").concat((_a = action.href) !== null && _a !== void 0 ? _a : "button", "-").concat(index),
134
- href: action.href,
135
- external: action.external,
136
- variant: (_b = action.variant) !== null && _b !== void 0 ? _b : "primary",
137
- onClick: action.onClick,
138
- className: "lsg-banner__cta"
139
- }, action.label);
140
- })))));
176
+ alt: imageAlt,
177
+ loading: "lazy"
178
+ }));
179
+ return (
180
+ /*#__PURE__*/
181
+ // The Sling decoration div. Background / accent style-system classes land
182
+ // here in AEM, not on the section.
183
+ React.createElement("div", {
184
+ className: ["banner teaser", background && "lsg-banner--bg-".concat(background), accent && "lsg-banner--accent-".concat(accent), GRID_COLUMN, className].filter(Boolean).join(" ")
185
+ }, /*#__PURE__*/React.createElement("section", {
186
+ className: "lsg-banner lsg-banner--".concat(layout, " lsg-banner--mobile-media-").concat(mobileMediaPosition),
187
+ "data-lsg-is": "banner",
188
+ "data-lsg-banner-layout": layout,
189
+ "data-lsg-banner-mobile-media": mobileMediaPosition,
190
+ "data-lsg-banner-media": hasMedia ? resolvedMediaType : "none"
191
+ }, /*#__PURE__*/React.createElement("div", {
192
+ className: "lsg-banner__shell"
193
+ }, hasMedia && /*#__PURE__*/React.createElement("div", {
194
+ className: "lsg-banner__media"
195
+ }, resolvedMediaType === "video" && videoUrl ? /*#__PURE__*/React.createElement("video", {
196
+ className: "lsg-banner__video",
197
+ poster: videoPoster,
198
+ autoPlay: videoAutoPlay,
199
+ muted: videoMuted,
200
+ loop: videoLoop,
201
+ controls: videoControls,
202
+ playsInline: true,
203
+ "aria-label": imageAlt
204
+ }, /*#__PURE__*/React.createElement("source", {
205
+ src: videoUrl,
206
+ type: videoMimeType(videoUrl)
207
+ })) : mediaHref ? /*#__PURE__*/React.createElement("a", {
208
+ className: "lsg-banner__media-link",
209
+ href: mediaHref,
210
+ target: mediaTarget
211
+ }, picture) : picture), /*#__PURE__*/React.createElement("div", {
212
+ className: "lsg-banner__content"
213
+ }, /*#__PURE__*/React.createElement(AemGroup, {
214
+ styleClasses: "lsg-group-display--flex lsg-group-direction--column lsg-group-gap--16"
215
+ }, resolvedPreTitle && /*#__PURE__*/React.createElement(AemTitle, {
216
+ tag: "p",
217
+ colour: preTitleColour
218
+ }, resolvedPreTitle), /*#__PURE__*/React.createElement(AemTitle, {
219
+ tag: headingTag,
220
+ colour: headingColour
221
+ }, heading)), resolvedBody && /*#__PURE__*/React.createElement(AemGroup, null, /*#__PURE__*/React.createElement(AemText, {
222
+ id: textId,
223
+ colour: bodyColour
224
+ }, resolvedBody)), actions.length > 0 && /*#__PURE__*/React.createElement(AemGroup, {
225
+ styleClasses: "lsg-group-display--flex lsg-group-gap--16"
226
+ }, actions.map(function (action, index) {
227
+ var _a;
228
+ return /*#__PURE__*/React.createElement(AemButton, {
229
+ key: "".concat(action.label, "-").concat((_a = action.href) !== null && _a !== void 0 ? _a : "button", "-").concat(index),
230
+ cta: action
231
+ });
232
+ }))))))
233
+ );
141
234
  };
142
235
 
143
236
  function isSafeUrl$1(url) {