@carbon/icon-helpers 10.39.0 → 10.40.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/es/index.js CHANGED
@@ -1,16 +1,13 @@
1
1
  function ownKeys(object, enumerableOnly) {
2
2
  var keys = Object.keys(object);
3
-
4
3
  if (Object.getOwnPropertySymbols) {
5
4
  var symbols = Object.getOwnPropertySymbols(object);
6
5
  enumerableOnly && (symbols = symbols.filter(function (sym) {
7
6
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
8
7
  })), keys.push.apply(keys, symbols);
9
8
  }
10
-
11
9
  return keys;
12
10
  }
13
-
14
11
  function _objectSpread2(target) {
15
12
  for (var i = 1; i < arguments.length; i++) {
16
13
  var source = null != arguments[i] ? arguments[i] : {};
@@ -20,11 +17,10 @@ function _objectSpread2(target) {
20
17
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21
18
  });
22
19
  }
23
-
24
20
  return target;
25
21
  }
26
-
27
22
  function _defineProperty(obj, key, value) {
23
+ key = _toPropertyKey(key);
28
24
  if (key in obj) {
29
25
  Object.defineProperty(obj, key, {
30
26
  value: value,
@@ -35,35 +31,26 @@ function _defineProperty(obj, key, value) {
35
31
  } else {
36
32
  obj[key] = value;
37
33
  }
38
-
39
34
  return obj;
40
35
  }
41
-
42
36
  function _objectWithoutPropertiesLoose(source, excluded) {
43
37
  if (source == null) return {};
44
38
  var target = {};
45
39
  var sourceKeys = Object.keys(source);
46
40
  var key, i;
47
-
48
41
  for (i = 0; i < sourceKeys.length; i++) {
49
42
  key = sourceKeys[i];
50
43
  if (excluded.indexOf(key) >= 0) continue;
51
44
  target[key] = source[key];
52
45
  }
53
-
54
46
  return target;
55
47
  }
56
-
57
48
  function _objectWithoutProperties(source, excluded) {
58
49
  if (source == null) return {};
59
-
60
50
  var target = _objectWithoutPropertiesLoose(source, excluded);
61
-
62
51
  var key, i;
63
-
64
52
  if (Object.getOwnPropertySymbols) {
65
53
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
66
-
67
54
  for (i = 0; i < sourceSymbolKeys.length; i++) {
68
55
  key = sourceSymbolKeys[i];
69
56
  if (excluded.indexOf(key) >= 0) continue;
@@ -71,19 +58,32 @@ function _objectWithoutProperties(source, excluded) {
71
58
  target[key] = source[key];
72
59
  }
73
60
  }
74
-
75
61
  return target;
76
62
  }
63
+ function _toPrimitive(input, hint) {
64
+ if (typeof input !== "object" || input === null) return input;
65
+ var prim = input[Symbol.toPrimitive];
66
+ if (prim !== undefined) {
67
+ var res = prim.call(input, hint || "default");
68
+ if (typeof res !== "object") return res;
69
+ throw new TypeError("@@toPrimitive must return a primitive value.");
70
+ }
71
+ return (hint === "string" ? String : Number)(input);
72
+ }
73
+ function _toPropertyKey(arg) {
74
+ var key = _toPrimitive(arg, "string");
75
+ return typeof key === "symbol" ? key : String(key);
76
+ }
77
77
 
78
78
  var _excluded = ["width", "height", "viewBox"],
79
- _excluded2 = ["tabindex"];
80
-
79
+ _excluded2 = ["tabindex"];
81
80
  /**
82
81
  * Copyright IBM Corp. 2018, 2023
83
82
  *
84
83
  * This source code is licensed under the Apache-2.0 license found in the
85
84
  * LICENSE file in the root directory of this source tree.
86
85
  */
86
+
87
87
  var defaultAttributes = {
88
88
  // Reference:
89
89
  // https://github.com/IBM/carbon-components-react/issues/1392
@@ -92,34 +92,33 @@ var defaultAttributes = {
92
92
  focusable: 'false',
93
93
  preserveAspectRatio: 'xMidYMid meet'
94
94
  };
95
+
95
96
  /**
96
97
  * Get supplementary HTML attributes for a given <svg> element based on existing
97
98
  * attributes.
98
99
  */
99
-
100
100
  function getAttributes() {
101
101
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
102
- width = _ref.width,
103
- height = _ref.height,
104
- _ref$viewBox = _ref.viewBox,
105
- viewBox = _ref$viewBox === void 0 ? "0 0 ".concat(width, " ").concat(height) : _ref$viewBox,
106
- attributes = _objectWithoutProperties(_ref, _excluded);
107
-
102
+ width = _ref.width,
103
+ height = _ref.height,
104
+ _ref$viewBox = _ref.viewBox,
105
+ viewBox = _ref$viewBox === void 0 ? "0 0 ".concat(width, " ").concat(height) : _ref$viewBox,
106
+ attributes = _objectWithoutProperties(_ref, _excluded);
108
107
  var tabindex = attributes.tabindex,
109
- rest = _objectWithoutProperties(attributes, _excluded2);
110
-
108
+ rest = _objectWithoutProperties(attributes, _excluded2);
111
109
  var iconAttributes = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultAttributes), rest), {}, {
112
110
  width: width,
113
111
  height: height,
114
112
  viewBox: viewBox
115
- }); // TODO: attributes.title assumes that the consumer will implement <title> and
116
- // correctly set `aria-labelledby`.
117
-
113
+ });
118
114
 
115
+ // TODO: attributes.title assumes that the consumer will implement <title> and
116
+ // correctly set `aria-labelledby`.
119
117
  if (iconAttributes['aria-label'] || iconAttributes['aria-labelledby'] || iconAttributes.title) {
120
- iconAttributes.role = 'img'; // Reference:
121
- // https://allyjs.io/tutorials/focusing-in-svg.html
118
+ iconAttributes.role = 'img';
122
119
 
120
+ // Reference:
121
+ // https://allyjs.io/tutorials/focusing-in-svg.html
123
122
  if (tabindex !== undefined && tabindex !== null) {
124
123
  iconAttributes.focusable = 'true';
125
124
  iconAttributes.tabindex = tabindex;
@@ -127,7 +126,6 @@ function getAttributes() {
127
126
  } else {
128
127
  iconAttributes['aria-hidden'] = true;
129
128
  }
130
-
131
129
  return iconAttributes;
132
130
  }
133
131
 
@@ -137,33 +135,29 @@ function getAttributes() {
137
135
  * This source code is licensed under the Apache-2.0 license found in the
138
136
  * LICENSE file in the root directory of this source tree.
139
137
  */
138
+
140
139
  /**
141
140
  * Convert an icon descriptor to a String
142
141
  */
143
-
144
142
  function toString(descriptor) {
145
143
  var _descriptor$elem = descriptor.elem,
146
- elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
147
- _descriptor$attrs = descriptor.attrs,
148
- attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
149
- _descriptor$content = descriptor.content,
150
- content = _descriptor$content === void 0 ? [] : _descriptor$content;
144
+ elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
145
+ _descriptor$attrs = descriptor.attrs,
146
+ attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
147
+ _descriptor$content = descriptor.content,
148
+ content = _descriptor$content === void 0 ? [] : _descriptor$content;
151
149
  var children = content.map(toString).join('');
152
-
153
150
  if (elem !== 'svg') {
154
151
  return "<".concat(elem, " ").concat(formatAttributes(attrs), ">").concat(children, "</").concat(elem, ">");
155
152
  }
156
-
157
153
  return "<".concat(elem, " ").concat(formatAttributes(getAttributes(attrs)), ">").concat(children, "</").concat(elem, ">");
158
154
  }
159
155
  function formatAttributes(attrs) {
160
156
  return Object.keys(attrs).reduce(function (acc, key, index) {
161
157
  var attribute = "".concat(key, "=\"").concat(attrs[key], "\"");
162
-
163
158
  if (index === 0) {
164
159
  return attribute;
165
160
  }
166
-
167
161
  return acc + ' ' + attribute;
168
162
  }, '');
169
163
  }
@@ -174,27 +168,25 @@ function formatAttributes(attrs) {
174
168
  * This source code is licensed under the Apache-2.0 license found in the
175
169
  * LICENSE file in the root directory of this source tree.
176
170
  */
171
+
177
172
  /**
178
173
  * Convert an icon descriptor to a DOM node.
179
174
  */
180
-
181
175
  function toSVG(descriptor) {
182
176
  var _descriptor$elem = descriptor.elem,
183
- elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
184
- _descriptor$attrs = descriptor.attrs,
185
- attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
186
- _descriptor$content = descriptor.content,
187
- content = _descriptor$content === void 0 ? [] : _descriptor$content;
177
+ elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
178
+ _descriptor$attrs = descriptor.attrs,
179
+ attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
180
+ _descriptor$content = descriptor.content,
181
+ content = _descriptor$content === void 0 ? [] : _descriptor$content;
188
182
  var node = document.createElementNS('http://www.w3.org/2000/svg', elem);
189
183
  var attributes = elem !== 'svg' ? attrs : getAttributes(attrs);
190
184
  Object.keys(attributes).forEach(function (key) {
191
185
  node.setAttribute(key, attrs[key]);
192
186
  });
193
-
194
187
  for (var i = 0; i < content.length; i++) {
195
188
  node.appendChild(toSVG(content[i]));
196
189
  }
197
-
198
190
  return node;
199
191
  }
200
192
 
package/lib/index.js CHANGED
@@ -4,17 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function ownKeys(object, enumerableOnly) {
6
6
  var keys = Object.keys(object);
7
-
8
7
  if (Object.getOwnPropertySymbols) {
9
8
  var symbols = Object.getOwnPropertySymbols(object);
10
9
  enumerableOnly && (symbols = symbols.filter(function (sym) {
11
10
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
12
11
  })), keys.push.apply(keys, symbols);
13
12
  }
14
-
15
13
  return keys;
16
14
  }
17
-
18
15
  function _objectSpread2(target) {
19
16
  for (var i = 1; i < arguments.length; i++) {
20
17
  var source = null != arguments[i] ? arguments[i] : {};
@@ -24,11 +21,10 @@ function _objectSpread2(target) {
24
21
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
25
22
  });
26
23
  }
27
-
28
24
  return target;
29
25
  }
30
-
31
26
  function _defineProperty(obj, key, value) {
27
+ key = _toPropertyKey(key);
32
28
  if (key in obj) {
33
29
  Object.defineProperty(obj, key, {
34
30
  value: value,
@@ -39,35 +35,26 @@ function _defineProperty(obj, key, value) {
39
35
  } else {
40
36
  obj[key] = value;
41
37
  }
42
-
43
38
  return obj;
44
39
  }
45
-
46
40
  function _objectWithoutPropertiesLoose(source, excluded) {
47
41
  if (source == null) return {};
48
42
  var target = {};
49
43
  var sourceKeys = Object.keys(source);
50
44
  var key, i;
51
-
52
45
  for (i = 0; i < sourceKeys.length; i++) {
53
46
  key = sourceKeys[i];
54
47
  if (excluded.indexOf(key) >= 0) continue;
55
48
  target[key] = source[key];
56
49
  }
57
-
58
50
  return target;
59
51
  }
60
-
61
52
  function _objectWithoutProperties(source, excluded) {
62
53
  if (source == null) return {};
63
-
64
54
  var target = _objectWithoutPropertiesLoose(source, excluded);
65
-
66
55
  var key, i;
67
-
68
56
  if (Object.getOwnPropertySymbols) {
69
57
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
70
-
71
58
  for (i = 0; i < sourceSymbolKeys.length; i++) {
72
59
  key = sourceSymbolKeys[i];
73
60
  if (excluded.indexOf(key) >= 0) continue;
@@ -75,19 +62,32 @@ function _objectWithoutProperties(source, excluded) {
75
62
  target[key] = source[key];
76
63
  }
77
64
  }
78
-
79
65
  return target;
80
66
  }
67
+ function _toPrimitive(input, hint) {
68
+ if (typeof input !== "object" || input === null) return input;
69
+ var prim = input[Symbol.toPrimitive];
70
+ if (prim !== undefined) {
71
+ var res = prim.call(input, hint || "default");
72
+ if (typeof res !== "object") return res;
73
+ throw new TypeError("@@toPrimitive must return a primitive value.");
74
+ }
75
+ return (hint === "string" ? String : Number)(input);
76
+ }
77
+ function _toPropertyKey(arg) {
78
+ var key = _toPrimitive(arg, "string");
79
+ return typeof key === "symbol" ? key : String(key);
80
+ }
81
81
 
82
82
  var _excluded = ["width", "height", "viewBox"],
83
- _excluded2 = ["tabindex"];
84
-
83
+ _excluded2 = ["tabindex"];
85
84
  /**
86
85
  * Copyright IBM Corp. 2018, 2023
87
86
  *
88
87
  * This source code is licensed under the Apache-2.0 license found in the
89
88
  * LICENSE file in the root directory of this source tree.
90
89
  */
90
+
91
91
  var defaultAttributes = {
92
92
  // Reference:
93
93
  // https://github.com/IBM/carbon-components-react/issues/1392
@@ -96,34 +96,33 @@ var defaultAttributes = {
96
96
  focusable: 'false',
97
97
  preserveAspectRatio: 'xMidYMid meet'
98
98
  };
99
+
99
100
  /**
100
101
  * Get supplementary HTML attributes for a given <svg> element based on existing
101
102
  * attributes.
102
103
  */
103
-
104
104
  function getAttributes() {
105
105
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
106
- width = _ref.width,
107
- height = _ref.height,
108
- _ref$viewBox = _ref.viewBox,
109
- viewBox = _ref$viewBox === void 0 ? "0 0 ".concat(width, " ").concat(height) : _ref$viewBox,
110
- attributes = _objectWithoutProperties(_ref, _excluded);
111
-
106
+ width = _ref.width,
107
+ height = _ref.height,
108
+ _ref$viewBox = _ref.viewBox,
109
+ viewBox = _ref$viewBox === void 0 ? "0 0 ".concat(width, " ").concat(height) : _ref$viewBox,
110
+ attributes = _objectWithoutProperties(_ref, _excluded);
112
111
  var tabindex = attributes.tabindex,
113
- rest = _objectWithoutProperties(attributes, _excluded2);
114
-
112
+ rest = _objectWithoutProperties(attributes, _excluded2);
115
113
  var iconAttributes = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultAttributes), rest), {}, {
116
114
  width: width,
117
115
  height: height,
118
116
  viewBox: viewBox
119
- }); // TODO: attributes.title assumes that the consumer will implement <title> and
120
- // correctly set `aria-labelledby`.
121
-
117
+ });
122
118
 
119
+ // TODO: attributes.title assumes that the consumer will implement <title> and
120
+ // correctly set `aria-labelledby`.
123
121
  if (iconAttributes['aria-label'] || iconAttributes['aria-labelledby'] || iconAttributes.title) {
124
- iconAttributes.role = 'img'; // Reference:
125
- // https://allyjs.io/tutorials/focusing-in-svg.html
122
+ iconAttributes.role = 'img';
126
123
 
124
+ // Reference:
125
+ // https://allyjs.io/tutorials/focusing-in-svg.html
127
126
  if (tabindex !== undefined && tabindex !== null) {
128
127
  iconAttributes.focusable = 'true';
129
128
  iconAttributes.tabindex = tabindex;
@@ -131,7 +130,6 @@ function getAttributes() {
131
130
  } else {
132
131
  iconAttributes['aria-hidden'] = true;
133
132
  }
134
-
135
133
  return iconAttributes;
136
134
  }
137
135
 
@@ -141,33 +139,29 @@ function getAttributes() {
141
139
  * This source code is licensed under the Apache-2.0 license found in the
142
140
  * LICENSE file in the root directory of this source tree.
143
141
  */
142
+
144
143
  /**
145
144
  * Convert an icon descriptor to a String
146
145
  */
147
-
148
146
  function toString(descriptor) {
149
147
  var _descriptor$elem = descriptor.elem,
150
- elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
151
- _descriptor$attrs = descriptor.attrs,
152
- attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
153
- _descriptor$content = descriptor.content,
154
- content = _descriptor$content === void 0 ? [] : _descriptor$content;
148
+ elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
149
+ _descriptor$attrs = descriptor.attrs,
150
+ attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
151
+ _descriptor$content = descriptor.content,
152
+ content = _descriptor$content === void 0 ? [] : _descriptor$content;
155
153
  var children = content.map(toString).join('');
156
-
157
154
  if (elem !== 'svg') {
158
155
  return "<".concat(elem, " ").concat(formatAttributes(attrs), ">").concat(children, "</").concat(elem, ">");
159
156
  }
160
-
161
157
  return "<".concat(elem, " ").concat(formatAttributes(getAttributes(attrs)), ">").concat(children, "</").concat(elem, ">");
162
158
  }
163
159
  function formatAttributes(attrs) {
164
160
  return Object.keys(attrs).reduce(function (acc, key, index) {
165
161
  var attribute = "".concat(key, "=\"").concat(attrs[key], "\"");
166
-
167
162
  if (index === 0) {
168
163
  return attribute;
169
164
  }
170
-
171
165
  return acc + ' ' + attribute;
172
166
  }, '');
173
167
  }
@@ -178,27 +172,25 @@ function formatAttributes(attrs) {
178
172
  * This source code is licensed under the Apache-2.0 license found in the
179
173
  * LICENSE file in the root directory of this source tree.
180
174
  */
175
+
181
176
  /**
182
177
  * Convert an icon descriptor to a DOM node.
183
178
  */
184
-
185
179
  function toSVG(descriptor) {
186
180
  var _descriptor$elem = descriptor.elem,
187
- elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
188
- _descriptor$attrs = descriptor.attrs,
189
- attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
190
- _descriptor$content = descriptor.content,
191
- content = _descriptor$content === void 0 ? [] : _descriptor$content;
181
+ elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
182
+ _descriptor$attrs = descriptor.attrs,
183
+ attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
184
+ _descriptor$content = descriptor.content,
185
+ content = _descriptor$content === void 0 ? [] : _descriptor$content;
192
186
  var node = document.createElementNS('http://www.w3.org/2000/svg', elem);
193
187
  var attributes = elem !== 'svg' ? attrs : getAttributes(attrs);
194
188
  Object.keys(attributes).forEach(function (key) {
195
189
  node.setAttribute(key, attrs[key]);
196
190
  });
197
-
198
191
  for (var i = 0; i < content.length; i++) {
199
192
  node.appendChild(toSVG(content[i]));
200
193
  }
201
-
202
194
  return node;
203
195
  }
204
196
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/icon-helpers",
3
3
  "description": "Helpers used alongside icons for digital and software products using the Carbon Design System",
4
- "version": "10.39.0",
4
+ "version": "10.40.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -33,9 +33,9 @@
33
33
  "clean": "rimraf es lib umd"
34
34
  },
35
35
  "devDependencies": {
36
- "@carbon/cli": "^11.9.0",
37
- "rimraf": "^4.0.0"
36
+ "@carbon/cli": "^11.10.0",
37
+ "rimraf": "^5.0.0"
38
38
  },
39
39
  "sideEffects": false,
40
- "gitHead": "07168bf0272678a04c92cd1e700ac60e66355a95"
40
+ "gitHead": "8fb6526d2f73634b13f3bec63b7112839754092d"
41
41
  }
package/umd/index.js CHANGED
@@ -6,17 +6,14 @@
6
6
 
7
7
  function ownKeys(object, enumerableOnly) {
8
8
  var keys = Object.keys(object);
9
-
10
9
  if (Object.getOwnPropertySymbols) {
11
10
  var symbols = Object.getOwnPropertySymbols(object);
12
11
  enumerableOnly && (symbols = symbols.filter(function (sym) {
13
12
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
14
13
  })), keys.push.apply(keys, symbols);
15
14
  }
16
-
17
15
  return keys;
18
16
  }
19
-
20
17
  function _objectSpread2(target) {
21
18
  for (var i = 1; i < arguments.length; i++) {
22
19
  var source = null != arguments[i] ? arguments[i] : {};
@@ -26,11 +23,10 @@
26
23
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
27
24
  });
28
25
  }
29
-
30
26
  return target;
31
27
  }
32
-
33
28
  function _defineProperty(obj, key, value) {
29
+ key = _toPropertyKey(key);
34
30
  if (key in obj) {
35
31
  Object.defineProperty(obj, key, {
36
32
  value: value,
@@ -41,35 +37,26 @@
41
37
  } else {
42
38
  obj[key] = value;
43
39
  }
44
-
45
40
  return obj;
46
41
  }
47
-
48
42
  function _objectWithoutPropertiesLoose(source, excluded) {
49
43
  if (source == null) return {};
50
44
  var target = {};
51
45
  var sourceKeys = Object.keys(source);
52
46
  var key, i;
53
-
54
47
  for (i = 0; i < sourceKeys.length; i++) {
55
48
  key = sourceKeys[i];
56
49
  if (excluded.indexOf(key) >= 0) continue;
57
50
  target[key] = source[key];
58
51
  }
59
-
60
52
  return target;
61
53
  }
62
-
63
54
  function _objectWithoutProperties(source, excluded) {
64
55
  if (source == null) return {};
65
-
66
56
  var target = _objectWithoutPropertiesLoose(source, excluded);
67
-
68
57
  var key, i;
69
-
70
58
  if (Object.getOwnPropertySymbols) {
71
59
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
72
-
73
60
  for (i = 0; i < sourceSymbolKeys.length; i++) {
74
61
  key = sourceSymbolKeys[i];
75
62
  if (excluded.indexOf(key) >= 0) continue;
@@ -77,19 +64,32 @@
77
64
  target[key] = source[key];
78
65
  }
79
66
  }
80
-
81
67
  return target;
82
68
  }
69
+ function _toPrimitive(input, hint) {
70
+ if (typeof input !== "object" || input === null) return input;
71
+ var prim = input[Symbol.toPrimitive];
72
+ if (prim !== undefined) {
73
+ var res = prim.call(input, hint || "default");
74
+ if (typeof res !== "object") return res;
75
+ throw new TypeError("@@toPrimitive must return a primitive value.");
76
+ }
77
+ return (hint === "string" ? String : Number)(input);
78
+ }
79
+ function _toPropertyKey(arg) {
80
+ var key = _toPrimitive(arg, "string");
81
+ return typeof key === "symbol" ? key : String(key);
82
+ }
83
83
 
84
84
  var _excluded = ["width", "height", "viewBox"],
85
- _excluded2 = ["tabindex"];
86
-
85
+ _excluded2 = ["tabindex"];
87
86
  /**
88
87
  * Copyright IBM Corp. 2018, 2023
89
88
  *
90
89
  * This source code is licensed under the Apache-2.0 license found in the
91
90
  * LICENSE file in the root directory of this source tree.
92
91
  */
92
+
93
93
  var defaultAttributes = {
94
94
  // Reference:
95
95
  // https://github.com/IBM/carbon-components-react/issues/1392
@@ -98,34 +98,33 @@
98
98
  focusable: 'false',
99
99
  preserveAspectRatio: 'xMidYMid meet'
100
100
  };
101
+
101
102
  /**
102
103
  * Get supplementary HTML attributes for a given <svg> element based on existing
103
104
  * attributes.
104
105
  */
105
-
106
106
  function getAttributes() {
107
107
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
108
- width = _ref.width,
109
- height = _ref.height,
110
- _ref$viewBox = _ref.viewBox,
111
- viewBox = _ref$viewBox === void 0 ? "0 0 ".concat(width, " ").concat(height) : _ref$viewBox,
112
- attributes = _objectWithoutProperties(_ref, _excluded);
113
-
108
+ width = _ref.width,
109
+ height = _ref.height,
110
+ _ref$viewBox = _ref.viewBox,
111
+ viewBox = _ref$viewBox === void 0 ? "0 0 ".concat(width, " ").concat(height) : _ref$viewBox,
112
+ attributes = _objectWithoutProperties(_ref, _excluded);
114
113
  var tabindex = attributes.tabindex,
115
- rest = _objectWithoutProperties(attributes, _excluded2);
116
-
114
+ rest = _objectWithoutProperties(attributes, _excluded2);
117
115
  var iconAttributes = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultAttributes), rest), {}, {
118
116
  width: width,
119
117
  height: height,
120
118
  viewBox: viewBox
121
- }); // TODO: attributes.title assumes that the consumer will implement <title> and
122
- // correctly set `aria-labelledby`.
123
-
119
+ });
124
120
 
121
+ // TODO: attributes.title assumes that the consumer will implement <title> and
122
+ // correctly set `aria-labelledby`.
125
123
  if (iconAttributes['aria-label'] || iconAttributes['aria-labelledby'] || iconAttributes.title) {
126
- iconAttributes.role = 'img'; // Reference:
127
- // https://allyjs.io/tutorials/focusing-in-svg.html
124
+ iconAttributes.role = 'img';
128
125
 
126
+ // Reference:
127
+ // https://allyjs.io/tutorials/focusing-in-svg.html
129
128
  if (tabindex !== undefined && tabindex !== null) {
130
129
  iconAttributes.focusable = 'true';
131
130
  iconAttributes.tabindex = tabindex;
@@ -133,7 +132,6 @@
133
132
  } else {
134
133
  iconAttributes['aria-hidden'] = true;
135
134
  }
136
-
137
135
  return iconAttributes;
138
136
  }
139
137
 
@@ -143,33 +141,29 @@
143
141
  * This source code is licensed under the Apache-2.0 license found in the
144
142
  * LICENSE file in the root directory of this source tree.
145
143
  */
144
+
146
145
  /**
147
146
  * Convert an icon descriptor to a String
148
147
  */
149
-
150
148
  function toString(descriptor) {
151
149
  var _descriptor$elem = descriptor.elem,
152
- elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
153
- _descriptor$attrs = descriptor.attrs,
154
- attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
155
- _descriptor$content = descriptor.content,
156
- content = _descriptor$content === void 0 ? [] : _descriptor$content;
150
+ elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
151
+ _descriptor$attrs = descriptor.attrs,
152
+ attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
153
+ _descriptor$content = descriptor.content,
154
+ content = _descriptor$content === void 0 ? [] : _descriptor$content;
157
155
  var children = content.map(toString).join('');
158
-
159
156
  if (elem !== 'svg') {
160
157
  return "<".concat(elem, " ").concat(formatAttributes(attrs), ">").concat(children, "</").concat(elem, ">");
161
158
  }
162
-
163
159
  return "<".concat(elem, " ").concat(formatAttributes(getAttributes(attrs)), ">").concat(children, "</").concat(elem, ">");
164
160
  }
165
161
  function formatAttributes(attrs) {
166
162
  return Object.keys(attrs).reduce(function (acc, key, index) {
167
163
  var attribute = "".concat(key, "=\"").concat(attrs[key], "\"");
168
-
169
164
  if (index === 0) {
170
165
  return attribute;
171
166
  }
172
-
173
167
  return acc + ' ' + attribute;
174
168
  }, '');
175
169
  }
@@ -180,27 +174,25 @@
180
174
  * This source code is licensed under the Apache-2.0 license found in the
181
175
  * LICENSE file in the root directory of this source tree.
182
176
  */
177
+
183
178
  /**
184
179
  * Convert an icon descriptor to a DOM node.
185
180
  */
186
-
187
181
  function toSVG(descriptor) {
188
182
  var _descriptor$elem = descriptor.elem,
189
- elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
190
- _descriptor$attrs = descriptor.attrs,
191
- attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
192
- _descriptor$content = descriptor.content,
193
- content = _descriptor$content === void 0 ? [] : _descriptor$content;
183
+ elem = _descriptor$elem === void 0 ? 'svg' : _descriptor$elem,
184
+ _descriptor$attrs = descriptor.attrs,
185
+ attrs = _descriptor$attrs === void 0 ? {} : _descriptor$attrs,
186
+ _descriptor$content = descriptor.content,
187
+ content = _descriptor$content === void 0 ? [] : _descriptor$content;
194
188
  var node = document.createElementNS('http://www.w3.org/2000/svg', elem);
195
189
  var attributes = elem !== 'svg' ? attrs : getAttributes(attrs);
196
190
  Object.keys(attributes).forEach(function (key) {
197
191
  node.setAttribute(key, attrs[key]);
198
192
  });
199
-
200
193
  for (var i = 0; i < content.length; i++) {
201
194
  node.appendChild(toSVG(content[i]));
202
195
  }
203
-
204
196
  return node;
205
197
  }
206
198