@carbon/ibmdotcom-utilities 2.0.0-beta.0 → 2.0.0-rc.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.
Files changed (33) hide show
  1. package/LICENSE +201 -0
  2. package/es/utilities/StickyHeader/StickyHeader.js +21 -17
  3. package/es/utilities/featureflag/featureflag.js +1 -1
  4. package/es/utilities/focuswrap/focuswrap.js +2 -2
  5. package/es/utilities/formatVideoCaption/formatVideoCaption.js +2 -1
  6. package/es/utilities/index.js +1 -1
  7. package/es/utilities/ipcinfoCookie/ipcinfoCookie.js +1 -1
  8. package/es/utilities/markdownToHtml/markdownToHtml.js +2 -2
  9. package/es/utilities/parseAspectRatio/parseAspectRatio.js +1 -1
  10. package/es/utilities/removeHtmlTagEntities/removeHtmlTagEntities.js +1 -1
  11. package/es/utilities/settings/settings.js +6 -4
  12. package/lib/utilities/StickyHeader/StickyHeader.js +22 -19
  13. package/lib/utilities/altlangs/altlangs.js +1 -2
  14. package/lib/utilities/calculateTotalWidth/calculateTotalWidth.js +1 -2
  15. package/lib/utilities/decodeString/decodeString.js +1 -2
  16. package/lib/utilities/escaperegexp/escaperegexp.js +1 -2
  17. package/lib/utilities/featureflag/featureflag.js +2 -3
  18. package/lib/utilities/focuswrap/focuswrap.js +3 -4
  19. package/lib/utilities/formatVideoCaption/formatVideoCaption.js +2 -1
  20. package/lib/utilities/ipcinfoCookie/ipcinfoCookie.js +2 -3
  21. package/lib/utilities/loadNonLatinPlex/loadNonLatinPlex.js +1 -2
  22. package/lib/utilities/markdownToHtml/markdownToHtml.js +3 -4
  23. package/lib/utilities/parseAspectRatio/parseAspectRatio.js +2 -3
  24. package/lib/utilities/removeHtmlTagEntities/removeHtmlTagEntities.js +2 -3
  25. package/lib/utilities/sameHeight/sameHeight.js +1 -2
  26. package/lib/utilities/serialize/serialize.js +1 -2
  27. package/lib/utilities/settings/settings.js +7 -6
  28. package/lib/utilities/smoothScroll/smoothScroll.js +1 -2
  29. package/lib/utilities/stripHTML/stripHTML.js +1 -2
  30. package/lib/utilities/uniqueid/uniqueid.js +1 -2
  31. package/package.json +6 -5
  32. package/umd/ibmdotcom-utilities.js +18 -53
  33. package/umd/ibmdotcom-utilities.min.js +1 -1
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2019 IBM Corp.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -12,11 +12,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
12
12
  */
13
13
 
14
14
  import { baseFontSize, breakpoints } from '@carbon/layout';
15
- import ddsSettings from '../settings/settings.js';
16
15
  import root from 'window-or-global';
17
- import settings from 'carbon-components/es/globals/js/settings.js';
18
- var prefix = settings.prefix;
19
- var ddsPrefix = ddsSettings.stablePrefix;
16
+ import settings from '../settings/settings.js';
17
+ var prefix = settings.prefix,
18
+ c4dPrefix = settings.stablePrefix;
20
19
  var gridBreakpoint = parseFloat(breakpoints.lg.width) * baseFontSize;
21
20
  var StickyHeader = /*#__PURE__*/function () {
22
21
  function StickyHeader() {
@@ -73,7 +72,7 @@ var StickyHeader = /*#__PURE__*/function () {
73
72
  value: function _tableOfContentsStickyUpdate() {
74
73
  var toc = this._tableOfContents;
75
74
  var tocRoot = toc.shadowRoot;
76
- var desktopSelector = ".".concat(ddsPrefix, "-ce--table-of-contents__items-container");
75
+ var desktopSelector = ".".concat(c4dPrefix, "-ce--table-of-contents__items-container");
77
76
  if (window.innerWidth > gridBreakpoint) {
78
77
  if (toc.layout === 'horizontal') {
79
78
  this._tableOfContentsInnerBar = tocRoot.querySelector(".".concat(prefix, "--tableofcontents__navbar"));
@@ -88,49 +87,54 @@ var StickyHeader = /*#__PURE__*/function () {
88
87
  }, {
89
88
  key: "banner",
90
89
  set: function set(component) {
91
- if (this._validateComponent(component, "".concat(ddsPrefix, "-universal-banner"))) {
90
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-global-banner"))) {
92
91
  this._banner = component;
93
92
  this.hasBanner = true;
94
93
  if (this._masthead) {
95
94
  this._masthead.setAttribute('with-banner', '');
96
95
  }
96
+ this._calculateCumulativeHeight();
97
97
  }
98
98
  }
99
99
  }, {
100
100
  key: "leadspaceWithSearch",
101
101
  set: function set(component) {
102
- if (this._validateComponent(component, "".concat(ddsPrefix, "-leadspace-with-search"))) {
102
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-leadspace-with-search"))) {
103
103
  this._leadspaceWithSearch = component;
104
104
  var leadspaceSearchBar = component.shadowRoot.querySelector(".".concat(prefix, "--search-container"));
105
105
  this._leadspaceSearchBar = leadspaceSearchBar;
106
- this._leadspaceWithSearchInput = component.querySelector("".concat(ddsPrefix, "-search-with-typeahead"));
106
+ this._leadspaceWithSearchInput = component.querySelector("".concat(c4dPrefix, "-search-with-typeahead"));
107
107
  this._leadspaceWithSearchStickyThreshold = parseInt(window.getComputedStyle(leadspaceSearchBar).paddingBottom) - 16;
108
+ this._calculateCumulativeHeight();
108
109
  }
109
110
  }
110
111
  }, {
111
112
  key: "localeModal",
112
113
  set: function set(component) {
113
- if (this._validateComponent(component, "".concat(ddsPrefix, "-locale-modal"))) {
114
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-locale-modal"))) {
114
115
  this._localeModal = component;
116
+ this._calculateCumulativeHeight();
115
117
  }
116
118
  }
117
119
  }, {
118
120
  key: "masthead",
119
121
  set: function set(component) {
120
- if (this._validateComponent(component, "".concat(ddsPrefix, "-masthead"))) {
122
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-masthead"))) {
121
123
  this._masthead = component;
122
124
  if (this._banner) this._masthead.setAttribute('with-banner', '');
123
125
  this._mastheadL0 = component.shadowRoot.querySelector(".".concat(prefix, "--masthead__l0"));
124
- this._mastheadL1 = component.querySelector("".concat(ddsPrefix, "-masthead-l1"));
126
+ this._mastheadL1 = component.querySelector("".concat(c4dPrefix, "-masthead-l1"));
127
+ this._calculateCumulativeHeight();
125
128
  }
126
129
  }
127
130
  }, {
128
131
  key: "tableOfContents",
129
132
  set: function set(component) {
130
- if (this._validateComponent(component, "".concat(ddsPrefix, "-table-of-contents"))) {
133
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-table-of-contents"))) {
131
134
  this._tableOfContents = component;
132
135
  this._tableOfContentsStickyUpdate();
133
136
  this._resizeObserver.observe(this._tableOfContents);
137
+ this._calculateCumulativeHeight();
134
138
  }
135
139
  }
136
140
 
@@ -143,7 +147,7 @@ var StickyHeader = /*#__PURE__*/function () {
143
147
  var _this = this;
144
148
  if (!this._throttled) {
145
149
  this._throttled = true;
146
- this._handleScroll();
150
+ this._calculateCumulativeHeight();
147
151
  setTimeout(function () {
148
152
  _this._throttled = false;
149
153
  }, 20);
@@ -168,15 +172,15 @@ var StickyHeader = /*#__PURE__*/function () {
168
172
  tocInner.style.top = "".concat(masthead.offsetHeight, "px");
169
173
  }
170
174
  }
171
- this._handleScroll();
175
+ this._calculateCumulativeHeight();
172
176
  }
173
177
  if (leadspaceSearchBar) {
174
178
  this._leadspaceWithSearchStickyThreshold = parseInt(window.getComputedStyle(leadspaceSearchBar).paddingBottom) - 16;
175
179
  }
176
180
  }
177
181
  }, {
178
- key: "_handleScroll",
179
- value: function _handleScroll() {
182
+ key: "_calculateCumulativeHeight",
183
+ value: function _calculateCumulativeHeight() {
180
184
  var _StickyHeader$global = StickyHeader.global,
181
185
  oldY = _StickyHeader$global._lastScrollPosition,
182
186
  banner = _StickyHeader$global._banner,
@@ -309,7 +313,7 @@ var StickyHeader = /*#__PURE__*/function () {
309
313
  }, {
310
314
  key: "customPropertyName",
311
315
  get: function get() {
312
- return "--".concat(ddsPrefix, "-sticky-header-height");
316
+ return "--".concat(c4dPrefix, "-sticky-header-height");
313
317
  }
314
318
  }]);
315
319
  return StickyHeader;
@@ -13,7 +13,7 @@
13
13
  * @private
14
14
  * @returns {object} JSX object
15
15
  *
16
- * return featureFlag(DDS_FEATURE_NAME, <div>hello world</div>);
16
+ * return featureFlag(C4D_FEATURE_NAME, <div>hello world</div>);
17
17
  */
18
18
  function featureFlag(flag, jsx) {
19
19
  return flag ? jsx : null;
@@ -20,11 +20,11 @@ import on from 'carbon-components/es/globals/js/misc/on.js';
20
20
  * @param {Element[]} sentinelNodes
21
21
  * The focus sentinel nodes.
22
22
  * If these nodes gets focus, we see it as focus went out of the `element`.
23
- * @param {string} [eventRequestFocusWrap=dds-request-focus-wrap] The event name.
23
+ * @param {string} [eventRequestFocusWrap=cds-request-focus-wrap] The event name.
24
24
  * @returns {Function} The handle to remove the event handler.
25
25
  */
26
26
  function focuswrap(element, sentinelNodes) {
27
- var eventRequestFocusWrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'dds-request-focus-wrap';
27
+ var eventRequestFocusWrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'cds-request-focus-wrap';
28
28
  return on(element, 'focusout', function handleFocusout(event) {
29
29
  var _event$currentTarget$, _event$currentTarget$2;
30
30
  var target = event.target,
@@ -36,10 +36,11 @@ export function formatVideoCaption() {
36
36
  export function formatVideoDuration() {
37
37
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
38
38
  duration = _ref2.duration;
39
+ var hours = Math.floor((duration !== null && duration !== void 0 ? duration : 0) / (1000 * 60 * 60) % 24);
39
40
  var minutes = Math.floor((duration !== null && duration !== void 0 ? duration : 0) / 60000);
40
41
  var seconds = Math.floor((duration !== null && duration !== void 0 ? duration : 0) / 1000 % 60);
41
42
  var fillSeconds = Array.from({
42
43
  length: 2 - String(seconds).length + 1
43
44
  }).join('0');
44
- return duration == null ? duration : "".concat(minutes, ":").concat(fillSeconds).concat(seconds);
45
+ return duration == null ? duration : hours ? "".concat(hours, ":").concat(minutes, " hr") : "".concat(minutes, ":").concat(fillSeconds).concat(seconds, " min");
45
46
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2021
2
+ * Copyright IBM Corp. 2016, 2023
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.
@@ -5,7 +5,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  /**
8
- * Copyright IBM Corp. 2020, 2022
8
+ * Copyright IBM Corp. 2020, 2023
9
9
  *
10
10
  * This source code is licensed under the Apache-2.0 license found in the
11
11
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2020, 2022
2
+ * Copyright IBM Corp. 2020, 2023
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.
@@ -7,7 +7,7 @@
7
7
 
8
8
  import DOMPurify from 'isomorphic-dompurify';
9
9
  import { marked } from 'marked';
10
- import settings from 'carbon-components/es/globals/js/settings.js';
10
+ import settings from '../settings/settings.js';
11
11
  import striptags from 'striptags';
12
12
  var prefix = settings.prefix;
13
13
  var _cleanStringRegex = /\n|\s{2,}|&;/g;
@@ -1,6 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
  /**
3
- * Copyright IBM Corp. 2016, 2022
3
+ * Copyright IBM Corp. 2016, 2023
4
4
  *
5
5
  * This source code is licensed under the Apache-2.0 license found in the
6
6
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2020, 2022
2
+ * Copyright IBM Corp. 2020, 2023
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.
@@ -10,11 +10,13 @@
10
10
  *
11
11
  * @exports ibmdotcom.settings
12
12
  * @type {object} Settings object
13
- * @property {string} [prefix=dds]
14
- * Carbon for IBM.com v1.49.0',
13
+ * @property {string} [stablePrefix=c4d] stable prefix
14
+ * @property {string} [prefix=cds] core Carbon prefix
15
+ * Carbon for IBM.com v2.0.0',
15
16
  */
16
17
  var settings = {
17
- version: 'Carbon for IBM.com v1.49.0',
18
- stablePrefix: 'dds'
18
+ version: 'Carbon for IBM.com v2.0.0',
19
+ stablePrefix: 'c4d',
20
+ prefix: 'cds'
19
21
  };
20
22
  export default settings;
@@ -5,9 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _layout = require("@carbon/layout");
8
- var _settings = _interopRequireDefault(require("../settings/settings.js"));
9
8
  var _windowOrGlobal = _interopRequireDefault(require("window-or-global"));
10
- var _settings2 = _interopRequireDefault(require("carbon-components/es/globals/js/settings.js"));
9
+ var _settings = _interopRequireDefault(require("../settings/settings.js"));
11
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
11
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
12
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -20,8 +19,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
20
19
  * This source code is licensed under the Apache-2.0 license found in the
21
20
  * LICENSE file in the root directory of this source tree.
22
21
  */
23
- var prefix = _settings2.default.prefix;
24
- var ddsPrefix = _settings.default.stablePrefix;
22
+ var prefix = _settings.default.prefix,
23
+ c4dPrefix = _settings.default.stablePrefix;
25
24
  var gridBreakpoint = parseFloat(_layout.breakpoints.lg.width) * _layout.baseFontSize;
26
25
  var StickyHeader = /*#__PURE__*/function () {
27
26
  function StickyHeader() {
@@ -78,7 +77,7 @@ var StickyHeader = /*#__PURE__*/function () {
78
77
  value: function _tableOfContentsStickyUpdate() {
79
78
  var toc = this._tableOfContents;
80
79
  var tocRoot = toc.shadowRoot;
81
- var desktopSelector = ".".concat(ddsPrefix, "-ce--table-of-contents__items-container");
80
+ var desktopSelector = ".".concat(c4dPrefix, "-ce--table-of-contents__items-container");
82
81
  if (window.innerWidth > gridBreakpoint) {
83
82
  if (toc.layout === 'horizontal') {
84
83
  this._tableOfContentsInnerBar = tocRoot.querySelector(".".concat(prefix, "--tableofcontents__navbar"));
@@ -93,49 +92,54 @@ var StickyHeader = /*#__PURE__*/function () {
93
92
  }, {
94
93
  key: "banner",
95
94
  set: function set(component) {
96
- if (this._validateComponent(component, "".concat(ddsPrefix, "-universal-banner"))) {
95
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-global-banner"))) {
97
96
  this._banner = component;
98
97
  this.hasBanner = true;
99
98
  if (this._masthead) {
100
99
  this._masthead.setAttribute('with-banner', '');
101
100
  }
101
+ this._calculateCumulativeHeight();
102
102
  }
103
103
  }
104
104
  }, {
105
105
  key: "leadspaceWithSearch",
106
106
  set: function set(component) {
107
- if (this._validateComponent(component, "".concat(ddsPrefix, "-leadspace-with-search"))) {
107
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-leadspace-with-search"))) {
108
108
  this._leadspaceWithSearch = component;
109
109
  var leadspaceSearchBar = component.shadowRoot.querySelector(".".concat(prefix, "--search-container"));
110
110
  this._leadspaceSearchBar = leadspaceSearchBar;
111
- this._leadspaceWithSearchInput = component.querySelector("".concat(ddsPrefix, "-search-with-typeahead"));
111
+ this._leadspaceWithSearchInput = component.querySelector("".concat(c4dPrefix, "-search-with-typeahead"));
112
112
  this._leadspaceWithSearchStickyThreshold = parseInt(window.getComputedStyle(leadspaceSearchBar).paddingBottom) - 16;
113
+ this._calculateCumulativeHeight();
113
114
  }
114
115
  }
115
116
  }, {
116
117
  key: "localeModal",
117
118
  set: function set(component) {
118
- if (this._validateComponent(component, "".concat(ddsPrefix, "-locale-modal"))) {
119
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-locale-modal"))) {
119
120
  this._localeModal = component;
121
+ this._calculateCumulativeHeight();
120
122
  }
121
123
  }
122
124
  }, {
123
125
  key: "masthead",
124
126
  set: function set(component) {
125
- if (this._validateComponent(component, "".concat(ddsPrefix, "-masthead"))) {
127
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-masthead"))) {
126
128
  this._masthead = component;
127
129
  if (this._banner) this._masthead.setAttribute('with-banner', '');
128
130
  this._mastheadL0 = component.shadowRoot.querySelector(".".concat(prefix, "--masthead__l0"));
129
- this._mastheadL1 = component.querySelector("".concat(ddsPrefix, "-masthead-l1"));
131
+ this._mastheadL1 = component.querySelector("".concat(c4dPrefix, "-masthead-l1"));
132
+ this._calculateCumulativeHeight();
130
133
  }
131
134
  }
132
135
  }, {
133
136
  key: "tableOfContents",
134
137
  set: function set(component) {
135
- if (this._validateComponent(component, "".concat(ddsPrefix, "-table-of-contents"))) {
138
+ if (this._validateComponent(component, "".concat(c4dPrefix, "-table-of-contents"))) {
136
139
  this._tableOfContents = component;
137
140
  this._tableOfContentsStickyUpdate();
138
141
  this._resizeObserver.observe(this._tableOfContents);
142
+ this._calculateCumulativeHeight();
139
143
  }
140
144
  }
141
145
 
@@ -148,7 +152,7 @@ var StickyHeader = /*#__PURE__*/function () {
148
152
  var _this = this;
149
153
  if (!this._throttled) {
150
154
  this._throttled = true;
151
- this._handleScroll();
155
+ this._calculateCumulativeHeight();
152
156
  setTimeout(function () {
153
157
  _this._throttled = false;
154
158
  }, 20);
@@ -173,15 +177,15 @@ var StickyHeader = /*#__PURE__*/function () {
173
177
  tocInner.style.top = "".concat(masthead.offsetHeight, "px");
174
178
  }
175
179
  }
176
- this._handleScroll();
180
+ this._calculateCumulativeHeight();
177
181
  }
178
182
  if (leadspaceSearchBar) {
179
183
  this._leadspaceWithSearchStickyThreshold = parseInt(window.getComputedStyle(leadspaceSearchBar).paddingBottom) - 16;
180
184
  }
181
185
  }
182
186
  }, {
183
- key: "_handleScroll",
184
- value: function _handleScroll() {
187
+ key: "_calculateCumulativeHeight",
188
+ value: function _calculateCumulativeHeight() {
185
189
  var _StickyHeader$global = StickyHeader.global,
186
190
  oldY = _StickyHeader$global._lastScrollPosition,
187
191
  banner = _StickyHeader$global._banner,
@@ -314,10 +318,9 @@ var StickyHeader = /*#__PURE__*/function () {
314
318
  }, {
315
319
  key: "customPropertyName",
316
320
  get: function get() {
317
- return "--".concat(ddsPrefix, "-sticky-header-height");
321
+ return "--".concat(c4dPrefix, "-sticky-header-height");
318
322
  }
319
323
  }]);
320
324
  return StickyHeader;
321
325
  }();
322
- var _default = StickyHeader;
323
- exports.default = _default;
326
+ var _default = exports.default = StickyHeader;
@@ -37,5 +37,4 @@ function altlangs() {
37
37
  }
38
38
  return langs;
39
39
  }
40
- var _default = altlangs;
41
- exports.default = _default;
40
+ var _default = exports.default = altlangs;
@@ -31,5 +31,4 @@ function calculateTotalWidth(elements) {
31
31
  });
32
32
  return totalWidth;
33
33
  }
34
- var _default = calculateTotalWidth;
35
- exports.default = _default;
34
+ var _default = exports.default = calculateTotalWidth;
@@ -29,5 +29,4 @@ function decodeString(str) {
29
29
  div.innerHTML = str;
30
30
  return div.textContent;
31
31
  }
32
- var _default = decodeString;
33
- exports.default = _default;
32
+ var _default = exports.default = decodeString;
@@ -26,5 +26,4 @@ exports.default = void 0;
26
26
  function escapeRegExp(str) {
27
27
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
28
28
  }
29
- var _default = escapeRegExp;
30
- exports.default = _default;
29
+ var _default = exports.default = escapeRegExp;
@@ -19,10 +19,9 @@ exports.default = void 0;
19
19
  * @private
20
20
  * @returns {object} JSX object
21
21
  *
22
- * return featureFlag(DDS_FEATURE_NAME, <div>hello world</div>);
22
+ * return featureFlag(C4D_FEATURE_NAME, <div>hello world</div>);
23
23
  */
24
24
  function featureFlag(flag, jsx) {
25
25
  return flag ? jsx : null;
26
26
  }
27
- var _default = featureFlag;
28
- exports.default = _default;
27
+ var _default = exports.default = featureFlag;
@@ -24,11 +24,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /**
24
24
  * @param {Element[]} sentinelNodes
25
25
  * The focus sentinel nodes.
26
26
  * If these nodes gets focus, we see it as focus went out of the `element`.
27
- * @param {string} [eventRequestFocusWrap=dds-request-focus-wrap] The event name.
27
+ * @param {string} [eventRequestFocusWrap=cds-request-focus-wrap] The event name.
28
28
  * @returns {Function} The handle to remove the event handler.
29
29
  */
30
30
  function focuswrap(element, sentinelNodes) {
31
- var eventRequestFocusWrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'dds-request-focus-wrap';
31
+ var eventRequestFocusWrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'cds-request-focus-wrap';
32
32
  return (0, _on.default)(element, 'focusout', function handleFocusout(event) {
33
33
  var _event$currentTarget$, _event$currentTarget$2;
34
34
  var target = event.target,
@@ -60,5 +60,4 @@ function focuswrap(element, sentinelNodes) {
60
60
  }
61
61
  });
62
62
  }
63
- var _default = focuswrap;
64
- exports.default = _default;
63
+ var _default = exports.default = focuswrap;