@carbon/ibmdotcom-services 1.33.0-rc.0 → 1.33.1
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/CHANGELOG.md +27 -0
- package/es/internal/vendor/@carbon/ibmdotcom-utilities/utilities/StickyHeader/StickyHeader.js +270 -0
- package/es/internal/vendor/@carbon/ibmdotcom-utilities/utilities/StickyHeader/index.js +7 -0
- package/es/internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings.js +3 -3
- package/lib/internal/vendor/@carbon/ibmdotcom-utilities/utilities/StickyHeader/StickyHeader.js +286 -0
- package/lib/internal/vendor/@carbon/ibmdotcom-utilities/utilities/StickyHeader/index.js +15 -0
- package/lib/internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings.js +3 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.33.1](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/compare/@carbon/ibmdotcom-services@1.33.0...@carbon/ibmdotcom-services@1.33.1) (2022-05-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @carbon/ibmdotcom-services
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.33.0](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/compare/@carbon/ibmdotcom-services@1.33.0-rc.1...@carbon/ibmdotcom-services@1.33.0) (2022-04-25)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @carbon/ibmdotcom-services
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.33.0-rc.1](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/compare/@carbon/ibmdotcom-services@1.33.0-rc.0...@carbon/ibmdotcom-services@1.33.0-rc.1) (2022-04-21)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **vendor:** fix to pull direct source for internal vendor packages ([#8734](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/issues/8734)) ([be94613](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/commit/be94613))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [1.33.0-rc.0](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/compare/@carbon/ibmdotcom-services@1.31.0...@carbon/ibmdotcom-services@1.33.0-rc.0) (2022-04-11)
|
|
7
34
|
|
|
8
35
|
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function _defineProperties(target, props) {
|
|
8
|
+
for (var i = 0; i < props.length; i++) {
|
|
9
|
+
var descriptor = props[i];
|
|
10
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
11
|
+
descriptor.configurable = true;
|
|
12
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
13
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
18
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
19
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
20
|
+
return Constructor;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Copyright IBM Corp. 2016, 2022
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
import { baseFontSize, breakpoints } from '@carbon/layout';
|
|
31
|
+
import ddsSettings from '../settings/settings.js';
|
|
32
|
+
import root from 'window-or-global';
|
|
33
|
+
import settings from 'carbon-components/es/globals/js/settings';
|
|
34
|
+
var prefix = settings.prefix;
|
|
35
|
+
var ddsPrefix = ddsSettings.stablePrefix;
|
|
36
|
+
var gridBreakpoint = parseFloat(breakpoints.lg.width) * baseFontSize;
|
|
37
|
+
|
|
38
|
+
var StickyHeader = /*#__PURE__*/function () {
|
|
39
|
+
function StickyHeader() {
|
|
40
|
+
_classCallCheck(this, StickyHeader);
|
|
41
|
+
|
|
42
|
+
this.ownerDocument = root.document;
|
|
43
|
+
this._banner = undefined;
|
|
44
|
+
this._hasBanner = false;
|
|
45
|
+
this._lastScrollPosition = 0;
|
|
46
|
+
this._leadspaceWithSearch = undefined;
|
|
47
|
+
this._leadspaceSearchBar = undefined;
|
|
48
|
+
this._localeModal = undefined;
|
|
49
|
+
this._masthead = undefined;
|
|
50
|
+
this._mastheadL0 = undefined;
|
|
51
|
+
this._mastheadL1 = undefined;
|
|
52
|
+
this._tableOfContents = undefined;
|
|
53
|
+
this._tableOfContentsInnerBar = undefined;
|
|
54
|
+
this._tableOfContentsLayout = undefined;
|
|
55
|
+
this._throttled = false;
|
|
56
|
+
this._resizeObserver = new ResizeObserver(this._handleResize.bind(this));
|
|
57
|
+
root.addEventListener('scroll', this._throttledHandler.bind(this));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create (if needed) and return the globally-scoped instance of `this`.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
_createClass(StickyHeader, [{
|
|
65
|
+
key: "_validateComponent",
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Compares the tag name of the component provided to what we expect it to be
|
|
69
|
+
*
|
|
70
|
+
* @param {HTMLElement} component The component provided
|
|
71
|
+
* @param {string} expected The lowercase tag name expected
|
|
72
|
+
* @throws {TypeError} Throws error if component tag name doesn't match expected string
|
|
73
|
+
* @returns {boolean} Returns true if component tag name matches expected string
|
|
74
|
+
*/
|
|
75
|
+
value: function _validateComponent(component, expected) {
|
|
76
|
+
var received = component.tagName.toLowerCase();
|
|
77
|
+
|
|
78
|
+
if (received !== expected) {
|
|
79
|
+
throw new TypeError("".concat(expected, " expected, ").concat(received, " provided"));
|
|
80
|
+
} else {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "_tableOfContentsStickyUpdate",
|
|
86
|
+
value: function _tableOfContentsStickyUpdate() {
|
|
87
|
+
var toc = this._tableOfContents;
|
|
88
|
+
var tocRoot = toc.shadowRoot;
|
|
89
|
+
var desktopSelector = ".".concat(ddsPrefix, "-ce--table-of-contents__items-container");
|
|
90
|
+
|
|
91
|
+
if (window.outerWidth > gridBreakpoint) {
|
|
92
|
+
if (toc.layout === 'horizontal') {
|
|
93
|
+
this._tableOfContentsInnerBar = tocRoot.querySelector(".".concat(prefix, "--tableofcontents__navbar"));
|
|
94
|
+
this._tableOfContentsLayout = 'horizontal';
|
|
95
|
+
} else {
|
|
96
|
+
this._tableOfContentsInnerBar = tocRoot.querySelector(desktopSelector);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
this._tableOfContentsInnerBar = tocRoot.querySelector(".".concat(prefix, "--tableofcontents__sidebar"));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "_throttledHandler",
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Rate-limits the scroll event handler
|
|
107
|
+
*/
|
|
108
|
+
value: function _throttledHandler() {
|
|
109
|
+
var _this = this;
|
|
110
|
+
|
|
111
|
+
if (!this._throttled) {
|
|
112
|
+
this._throttled = true;
|
|
113
|
+
|
|
114
|
+
this._handleScroll();
|
|
115
|
+
|
|
116
|
+
setTimeout(function () {
|
|
117
|
+
_this._throttled = false;
|
|
118
|
+
}, 20);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "_handleResize",
|
|
123
|
+
value: function _handleResize() {
|
|
124
|
+
var hasBanner = this._hasBanner,
|
|
125
|
+
masthead = this._masthead,
|
|
126
|
+
toc = this._tableOfContents,
|
|
127
|
+
tocLayout = this._tableOfContentsLayout;
|
|
128
|
+
|
|
129
|
+
if (toc && masthead) {
|
|
130
|
+
this._tableOfContentsStickyUpdate();
|
|
131
|
+
|
|
132
|
+
if (window.innerWidth >= gridBreakpoint && tocLayout !== 'horizontal' && !hasBanner) {
|
|
133
|
+
masthead.style.top = '0';
|
|
134
|
+
} else {
|
|
135
|
+
// This has to happen after the tocStickyUpdate method.
|
|
136
|
+
var tocInner = this._tableOfContentsInnerBar;
|
|
137
|
+
|
|
138
|
+
if (masthead.offsetTop === 0) {
|
|
139
|
+
tocInner.style.top = "".concat(masthead.offsetHeight, "px");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this._handleScroll();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "_handleScroll",
|
|
148
|
+
value: function _handleScroll() {
|
|
149
|
+
var _StickyHeader$global = StickyHeader.global,
|
|
150
|
+
oldY = _StickyHeader$global._lastScrollPosition,
|
|
151
|
+
banner = _StickyHeader$global._banner,
|
|
152
|
+
masthead = _StickyHeader$global._masthead,
|
|
153
|
+
mastheadL0 = _StickyHeader$global._mastheadL0,
|
|
154
|
+
mastheadL1 = _StickyHeader$global._mastheadL1,
|
|
155
|
+
localeModal = _StickyHeader$global._localeModal,
|
|
156
|
+
toc = _StickyHeader$global._tableOfContents,
|
|
157
|
+
tocInner = _StickyHeader$global._tableOfContentsInnerBar;
|
|
158
|
+
if (localeModal && localeModal.hasAttribute('open')) return;
|
|
159
|
+
var newY = window.scrollY;
|
|
160
|
+
this._lastScrollPosition = newY;
|
|
161
|
+
var maxScrollaway = 0;
|
|
162
|
+
var topmostElement = masthead || tocInner;
|
|
163
|
+
|
|
164
|
+
if (masthead && tocInner) {
|
|
165
|
+
var tocIsAtTop = tocInner.getBoundingClientRect().top <= masthead.offsetTop + masthead.offsetHeight + 1;
|
|
166
|
+
var tocShouldStick = toc.layout === 'horizontal' || window.innerWidth < gridBreakpoint;
|
|
167
|
+
|
|
168
|
+
if (tocIsAtTop && (tocShouldStick || mastheadL1)) {
|
|
169
|
+
maxScrollaway += masthead.offsetHeight;
|
|
170
|
+
|
|
171
|
+
if (mastheadL1 && !tocShouldStick) {
|
|
172
|
+
maxScrollaway -= mastheadL1.offsetHeight;
|
|
173
|
+
}
|
|
174
|
+
} else if (mastheadL0 && mastheadL1) {
|
|
175
|
+
maxScrollaway += mastheadL0.offsetHeight;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var cumulativeOffset = Math.max(Math.min(topmostElement.offsetTop + oldY - newY, 0), maxScrollaway * -1);
|
|
179
|
+
|
|
180
|
+
if (banner) {
|
|
181
|
+
cumulativeOffset += Math.max(banner.offsetHeight - newY, 0);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (masthead) {
|
|
185
|
+
masthead.style.transition = 'none';
|
|
186
|
+
masthead.style.top = "".concat(cumulativeOffset, "px");
|
|
187
|
+
cumulativeOffset += masthead.offsetHeight;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (tocInner) {
|
|
191
|
+
tocInner.style.transition = 'none';
|
|
192
|
+
tocInner.style.top = "".concat(cumulativeOffset, "px");
|
|
193
|
+
cumulativeOffset += tocInner.offsetHeight;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "banner",
|
|
199
|
+
set: function set(component) {
|
|
200
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-universal-banner"))) {
|
|
201
|
+
this._banner = component;
|
|
202
|
+
this.hasBanner = true;
|
|
203
|
+
|
|
204
|
+
if (this._masthead) {
|
|
205
|
+
this._masthead.setAttribute('with-banner', '');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "leadspaceWithSearch",
|
|
211
|
+
set: function set(component) {
|
|
212
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-leadspace-with-search"))) {
|
|
213
|
+
this._leadspaceWithSearch = component;
|
|
214
|
+
this._leadspaceWithSearchBar = component.querySelector('dds-search-with-typeahead');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "localeModal",
|
|
219
|
+
set: function set(component) {
|
|
220
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-locale-modal"))) {
|
|
221
|
+
this._localeModal = component;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "masthead",
|
|
226
|
+
set: function set(component) {
|
|
227
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-masthead"))) {
|
|
228
|
+
this._masthead = component;
|
|
229
|
+
if (this._banner) this._masthead.setAttribute('with-banner', '');
|
|
230
|
+
this._mastheadL0 = component.shadowRoot.querySelector(".".concat(prefix, "--masthead__l0"));
|
|
231
|
+
this._mastheadL1 = component.querySelector("".concat(ddsPrefix, "-masthead-l1"));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "tableOfContents",
|
|
236
|
+
set: function set(component) {
|
|
237
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-table-of-contents"))) {
|
|
238
|
+
this._tableOfContents = component;
|
|
239
|
+
|
|
240
|
+
this._tableOfContentsStickyUpdate();
|
|
241
|
+
|
|
242
|
+
this._resizeObserver.observe(this._tableOfContents);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}], [{
|
|
246
|
+
key: "isNecessary",
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* True if dotcom shell is not present on page.
|
|
250
|
+
*
|
|
251
|
+
* @returns {boolean} true/false
|
|
252
|
+
*/
|
|
253
|
+
value: function isNecessary() {
|
|
254
|
+
return Boolean(!root.document.querySelector("".concat(ddsPrefix, "-dotcom-shell-container")));
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
key: "global",
|
|
258
|
+
get: function get() {
|
|
259
|
+
if (!Object.prototype.hasOwnProperty.call(root, 'stickyHeader')) {
|
|
260
|
+
root.stickyHeader = new StickyHeader();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return root.stickyHeader;
|
|
264
|
+
}
|
|
265
|
+
}]);
|
|
266
|
+
|
|
267
|
+
return StickyHeader;
|
|
268
|
+
}();
|
|
269
|
+
|
|
270
|
+
export default StickyHeader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2020,
|
|
2
|
+
* Copyright IBM Corp. 2020, 2022
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
* @exports ibmdotcom.settings
|
|
12
12
|
* @type {object} Settings object
|
|
13
13
|
* @property {string} [prefix=dds]
|
|
14
|
-
* Carbon for IBM.com v1.
|
|
14
|
+
* Carbon for IBM.com v1.33.1',
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
var settings = {
|
|
18
|
-
version: 'Carbon for IBM.com v1.
|
|
18
|
+
version: 'Carbon for IBM.com v1.33.1',
|
|
19
19
|
stablePrefix: 'dds'
|
|
20
20
|
};
|
|
21
21
|
export default settings;
|
package/lib/internal/vendor/@carbon/ibmdotcom-utilities/utilities/StickyHeader/StickyHeader.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _layout = require("@carbon/layout");
|
|
11
|
+
|
|
12
|
+
var _settings = _interopRequireDefault(require("../settings/settings.js"));
|
|
13
|
+
|
|
14
|
+
var _windowOrGlobal = _interopRequireDefault(require("window-or-global"));
|
|
15
|
+
|
|
16
|
+
var _settings2 = _interopRequireDefault(require("carbon-components/umd/globals/js/settings"));
|
|
17
|
+
|
|
18
|
+
function _classCallCheck(instance, Constructor) {
|
|
19
|
+
if (!(instance instanceof Constructor)) {
|
|
20
|
+
throw new TypeError("Cannot call a class as a function");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _defineProperties(target, props) {
|
|
25
|
+
for (var i = 0; i < props.length; i++) {
|
|
26
|
+
var descriptor = props[i];
|
|
27
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
28
|
+
descriptor.configurable = true;
|
|
29
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
30
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
35
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
36
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
37
|
+
return Constructor;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Copyright IBM Corp. 2016, 2022
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
43
|
+
* LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
var prefix = _settings2.default.prefix;
|
|
48
|
+
var ddsPrefix = _settings.default.stablePrefix;
|
|
49
|
+
|
|
50
|
+
var gridBreakpoint = parseFloat(_layout.breakpoints.lg.width) * _layout.baseFontSize;
|
|
51
|
+
|
|
52
|
+
var StickyHeader = /*#__PURE__*/function () {
|
|
53
|
+
function StickyHeader() {
|
|
54
|
+
_classCallCheck(this, StickyHeader);
|
|
55
|
+
|
|
56
|
+
this.ownerDocument = _windowOrGlobal.default.document;
|
|
57
|
+
this._banner = undefined;
|
|
58
|
+
this._hasBanner = false;
|
|
59
|
+
this._lastScrollPosition = 0;
|
|
60
|
+
this._leadspaceWithSearch = undefined;
|
|
61
|
+
this._leadspaceSearchBar = undefined;
|
|
62
|
+
this._localeModal = undefined;
|
|
63
|
+
this._masthead = undefined;
|
|
64
|
+
this._mastheadL0 = undefined;
|
|
65
|
+
this._mastheadL1 = undefined;
|
|
66
|
+
this._tableOfContents = undefined;
|
|
67
|
+
this._tableOfContentsInnerBar = undefined;
|
|
68
|
+
this._tableOfContentsLayout = undefined;
|
|
69
|
+
this._throttled = false;
|
|
70
|
+
this._resizeObserver = new ResizeObserver(this._handleResize.bind(this));
|
|
71
|
+
|
|
72
|
+
_windowOrGlobal.default.addEventListener('scroll', this._throttledHandler.bind(this));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create (if needed) and return the globally-scoped instance of `this`.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
_createClass(StickyHeader, [{
|
|
80
|
+
key: "_validateComponent",
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Compares the tag name of the component provided to what we expect it to be
|
|
84
|
+
*
|
|
85
|
+
* @param {HTMLElement} component The component provided
|
|
86
|
+
* @param {string} expected The lowercase tag name expected
|
|
87
|
+
* @throws {TypeError} Throws error if component tag name doesn't match expected string
|
|
88
|
+
* @returns {boolean} Returns true if component tag name matches expected string
|
|
89
|
+
*/
|
|
90
|
+
value: function _validateComponent(component, expected) {
|
|
91
|
+
var received = component.tagName.toLowerCase();
|
|
92
|
+
|
|
93
|
+
if (received !== expected) {
|
|
94
|
+
throw new TypeError("".concat(expected, " expected, ").concat(received, " provided"));
|
|
95
|
+
} else {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "_tableOfContentsStickyUpdate",
|
|
101
|
+
value: function _tableOfContentsStickyUpdate() {
|
|
102
|
+
var toc = this._tableOfContents;
|
|
103
|
+
var tocRoot = toc.shadowRoot;
|
|
104
|
+
var desktopSelector = ".".concat(ddsPrefix, "-ce--table-of-contents__items-container");
|
|
105
|
+
|
|
106
|
+
if (window.outerWidth > gridBreakpoint) {
|
|
107
|
+
if (toc.layout === 'horizontal') {
|
|
108
|
+
this._tableOfContentsInnerBar = tocRoot.querySelector(".".concat(prefix, "--tableofcontents__navbar"));
|
|
109
|
+
this._tableOfContentsLayout = 'horizontal';
|
|
110
|
+
} else {
|
|
111
|
+
this._tableOfContentsInnerBar = tocRoot.querySelector(desktopSelector);
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
this._tableOfContentsInnerBar = tocRoot.querySelector(".".concat(prefix, "--tableofcontents__sidebar"));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "_throttledHandler",
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Rate-limits the scroll event handler
|
|
122
|
+
*/
|
|
123
|
+
value: function _throttledHandler() {
|
|
124
|
+
var _this = this;
|
|
125
|
+
|
|
126
|
+
if (!this._throttled) {
|
|
127
|
+
this._throttled = true;
|
|
128
|
+
|
|
129
|
+
this._handleScroll();
|
|
130
|
+
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
_this._throttled = false;
|
|
133
|
+
}, 20);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "_handleResize",
|
|
138
|
+
value: function _handleResize() {
|
|
139
|
+
var hasBanner = this._hasBanner,
|
|
140
|
+
masthead = this._masthead,
|
|
141
|
+
toc = this._tableOfContents,
|
|
142
|
+
tocLayout = this._tableOfContentsLayout;
|
|
143
|
+
|
|
144
|
+
if (toc && masthead) {
|
|
145
|
+
this._tableOfContentsStickyUpdate();
|
|
146
|
+
|
|
147
|
+
if (window.innerWidth >= gridBreakpoint && tocLayout !== 'horizontal' && !hasBanner) {
|
|
148
|
+
masthead.style.top = '0';
|
|
149
|
+
} else {
|
|
150
|
+
// This has to happen after the tocStickyUpdate method.
|
|
151
|
+
var tocInner = this._tableOfContentsInnerBar;
|
|
152
|
+
|
|
153
|
+
if (masthead.offsetTop === 0) {
|
|
154
|
+
tocInner.style.top = "".concat(masthead.offsetHeight, "px");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this._handleScroll();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "_handleScroll",
|
|
163
|
+
value: function _handleScroll() {
|
|
164
|
+
var _StickyHeader$global = StickyHeader.global,
|
|
165
|
+
oldY = _StickyHeader$global._lastScrollPosition,
|
|
166
|
+
banner = _StickyHeader$global._banner,
|
|
167
|
+
masthead = _StickyHeader$global._masthead,
|
|
168
|
+
mastheadL0 = _StickyHeader$global._mastheadL0,
|
|
169
|
+
mastheadL1 = _StickyHeader$global._mastheadL1,
|
|
170
|
+
localeModal = _StickyHeader$global._localeModal,
|
|
171
|
+
toc = _StickyHeader$global._tableOfContents,
|
|
172
|
+
tocInner = _StickyHeader$global._tableOfContentsInnerBar;
|
|
173
|
+
if (localeModal && localeModal.hasAttribute('open')) return;
|
|
174
|
+
var newY = window.scrollY;
|
|
175
|
+
this._lastScrollPosition = newY;
|
|
176
|
+
var maxScrollaway = 0;
|
|
177
|
+
var topmostElement = masthead || tocInner;
|
|
178
|
+
|
|
179
|
+
if (masthead && tocInner) {
|
|
180
|
+
var tocIsAtTop = tocInner.getBoundingClientRect().top <= masthead.offsetTop + masthead.offsetHeight + 1;
|
|
181
|
+
var tocShouldStick = toc.layout === 'horizontal' || window.innerWidth < gridBreakpoint;
|
|
182
|
+
|
|
183
|
+
if (tocIsAtTop && (tocShouldStick || mastheadL1)) {
|
|
184
|
+
maxScrollaway += masthead.offsetHeight;
|
|
185
|
+
|
|
186
|
+
if (mastheadL1 && !tocShouldStick) {
|
|
187
|
+
maxScrollaway -= mastheadL1.offsetHeight;
|
|
188
|
+
}
|
|
189
|
+
} else if (mastheadL0 && mastheadL1) {
|
|
190
|
+
maxScrollaway += mastheadL0.offsetHeight;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var cumulativeOffset = Math.max(Math.min(topmostElement.offsetTop + oldY - newY, 0), maxScrollaway * -1);
|
|
194
|
+
|
|
195
|
+
if (banner) {
|
|
196
|
+
cumulativeOffset += Math.max(banner.offsetHeight - newY, 0);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (masthead) {
|
|
200
|
+
masthead.style.transition = 'none';
|
|
201
|
+
masthead.style.top = "".concat(cumulativeOffset, "px");
|
|
202
|
+
cumulativeOffset += masthead.offsetHeight;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (tocInner) {
|
|
206
|
+
tocInner.style.transition = 'none';
|
|
207
|
+
tocInner.style.top = "".concat(cumulativeOffset, "px");
|
|
208
|
+
cumulativeOffset += tocInner.offsetHeight;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "banner",
|
|
214
|
+
set: function set(component) {
|
|
215
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-universal-banner"))) {
|
|
216
|
+
this._banner = component;
|
|
217
|
+
this.hasBanner = true;
|
|
218
|
+
|
|
219
|
+
if (this._masthead) {
|
|
220
|
+
this._masthead.setAttribute('with-banner', '');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "leadspaceWithSearch",
|
|
226
|
+
set: function set(component) {
|
|
227
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-leadspace-with-search"))) {
|
|
228
|
+
this._leadspaceWithSearch = component;
|
|
229
|
+
this._leadspaceWithSearchBar = component.querySelector('dds-search-with-typeahead');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "localeModal",
|
|
234
|
+
set: function set(component) {
|
|
235
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-locale-modal"))) {
|
|
236
|
+
this._localeModal = component;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "masthead",
|
|
241
|
+
set: function set(component) {
|
|
242
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-masthead"))) {
|
|
243
|
+
this._masthead = component;
|
|
244
|
+
if (this._banner) this._masthead.setAttribute('with-banner', '');
|
|
245
|
+
this._mastheadL0 = component.shadowRoot.querySelector(".".concat(prefix, "--masthead__l0"));
|
|
246
|
+
this._mastheadL1 = component.querySelector("".concat(ddsPrefix, "-masthead-l1"));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}, {
|
|
250
|
+
key: "tableOfContents",
|
|
251
|
+
set: function set(component) {
|
|
252
|
+
if (this._validateComponent(component, "".concat(ddsPrefix, "-table-of-contents"))) {
|
|
253
|
+
this._tableOfContents = component;
|
|
254
|
+
|
|
255
|
+
this._tableOfContentsStickyUpdate();
|
|
256
|
+
|
|
257
|
+
this._resizeObserver.observe(this._tableOfContents);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}], [{
|
|
261
|
+
key: "isNecessary",
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* True if dotcom shell is not present on page.
|
|
265
|
+
*
|
|
266
|
+
* @returns {boolean} true/false
|
|
267
|
+
*/
|
|
268
|
+
value: function isNecessary() {
|
|
269
|
+
return Boolean(!_windowOrGlobal.default.document.querySelector("".concat(ddsPrefix, "-dotcom-shell-container")));
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "global",
|
|
273
|
+
get: function get() {
|
|
274
|
+
if (!Object.prototype.hasOwnProperty.call(_windowOrGlobal.default, 'stickyHeader')) {
|
|
275
|
+
_windowOrGlobal.default.stickyHeader = new StickyHeader();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return _windowOrGlobal.default.stickyHeader;
|
|
279
|
+
}
|
|
280
|
+
}]);
|
|
281
|
+
|
|
282
|
+
return StickyHeader;
|
|
283
|
+
}();
|
|
284
|
+
|
|
285
|
+
var _default = StickyHeader;
|
|
286
|
+
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "StickyHeader", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _StickyHeader.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _StickyHeader = _interopRequireDefault(require("./StickyHeader"));
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Copyright IBM Corp. 2020,
|
|
9
|
+
* Copyright IBM Corp. 2020, 2022
|
|
10
10
|
*
|
|
11
11
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
12
12
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -18,11 +18,11 @@ exports.default = void 0;
|
|
|
18
18
|
* @exports ibmdotcom.settings
|
|
19
19
|
* @type {object} Settings object
|
|
20
20
|
* @property {string} [prefix=dds]
|
|
21
|
-
* Carbon for IBM.com v1.
|
|
21
|
+
* Carbon for IBM.com v1.33.1',
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
24
|
var settings = {
|
|
25
|
-
version: 'Carbon for IBM.com v1.
|
|
25
|
+
version: 'Carbon for IBM.com v1.33.1',
|
|
26
26
|
stablePrefix: 'dds'
|
|
27
27
|
};
|
|
28
28
|
var _default = settings;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/ibmdotcom-services",
|
|
3
3
|
"description": "Carbon for IBM.com Services",
|
|
4
|
-
"version": "1.33.
|
|
4
|
+
"version": "1.33.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/runtime": "^7.5.0",
|
|
51
|
-
"@carbon/ibmdotcom-utilities": "1.
|
|
51
|
+
"@carbon/ibmdotcom-utilities": "1.33.1",
|
|
52
52
|
"@carbon/telemetry": "0.1.0",
|
|
53
53
|
"axios": "~0.21.4",
|
|
54
54
|
"marked": "^4.0.10",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"release": {
|
|
102
102
|
"branch": "main"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "41cb43346a36e90df84e7585f4bd0a8e2f6521ed"
|
|
105
105
|
}
|