@cypress-design/react-docmenu 0.2.3 → 0.3.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/dist/index.umd.js CHANGED
@@ -38,7 +38,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38
38
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39
39
  PERFORMANCE OF THIS SOFTWARE.
40
40
  ***************************************************************************** */
41
- /* global Reflect, Promise */
41
+ /* global Reflect, Promise, SuppressedError, Symbol */
42
42
 
43
43
 
44
44
  var __assign$1 = function() {
@@ -72,7 +72,12 @@ function __spreadArray(to, from, pack) {
72
72
  }
73
73
  }
74
74
  return to.concat(ar || Array.prototype.slice.call(from));
75
- }
75
+ }
76
+
77
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
78
+ var e = new Error(message);
79
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
80
+ };
76
81
 
77
82
  var DocLink = function (_a) {
78
83
  var item = _a.item, collapsible = _a.collapsible, _b = _a.depth, depth = _b === void 0 ? -1 : _b, onActive = _a.onActive;
@@ -84,12 +89,14 @@ var DocLink = function (_a) {
84
89
  if (item.active) {
85
90
  onActive === null || onActive === void 0 ? void 0 : onActive(((_a = activeLIRef === null || activeLIRef === void 0 ? void 0 : activeLIRef.current) === null || _a === void 0 ? void 0 : _a.offsetTop) || 0);
86
91
  }
92
+ // supposed to happen only on mount
93
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
94
  }, []);
88
95
  return (React__namespace.createElement("li", { ref: activeLIRef, className: clsx('list-none p-0', {
89
96
  'pl-[16px]': depth >= 0,
90
97
  }) },
91
98
  React__namespace.createElement("a", { className: clsx('group relative inline-block pl-[24px]', {
92
- 'text-indigo-500 dark:text-indigo-200': item.active,
99
+ 'text-indigo-500': item.active,
93
100
  'py-[8px] text-[16px] leading-[24px]': depth < 0,
94
101
  'py-[12px] leading-[20px] text-[14px]': depth >= 0,
95
102
  }), href: item.href },
@@ -115,7 +122,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
115
122
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
116
123
  PERFORMANCE OF THIS SOFTWARE.
117
124
  ***************************************************************************** */
118
- /* global Reflect, Promise */
125
+ /* global Reflect, Promise, SuppressedError, Symbol */
119
126
 
120
127
 
121
128
  var __assign = function() {
@@ -139,10 +146,15 @@ function __rest(s, e) {
139
146
  t[p[i]] = s[p[i]];
140
147
  }
141
148
  return t;
142
- }
149
+ }
150
+
151
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
152
+ var e = new Error(message);
153
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
154
+ };
143
155
 
144
156
  var compileReactIconProperties = function (_a) {
145
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
157
+ var body = _a.body, defs = _a.defs, compiledClasses = _a.compiledClasses, size = _a.size, name = _a.name, attributes = __rest(_a, ["body", "defs", "compiledClasses", "size", "name"]);
146
158
  var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
147
159
  if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) &&
148
160
  attrName !== 'name') {
@@ -153,6 +165,21 @@ var compileReactIconProperties = function (_a) {
153
165
  }
154
166
  return newAttributes;
155
167
  }, {});
168
+ // eslint-disable-next-line react-hooks/rules-of-hooks
169
+ React__namespace.useEffect(function () {
170
+ var iconFileId = "".concat(name, "_").concat(size);
171
+ if (defs) {
172
+ if (document.querySelector("[data-cy-svg-defs=\"".concat(iconFileId, "\"]"))) {
173
+ return;
174
+ }
175
+ var svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
176
+ svgElement.setAttribute('data-cy-svg-defs', iconFileId);
177
+ svgElement.setAttribute('width', '0');
178
+ svgElement.setAttribute('height', '0');
179
+ svgElement.innerHTML = defs;
180
+ document.body.appendChild(svgElement);
181
+ }
182
+ }, [defs, name, size]);
156
183
  var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
157
184
  __html: body,
158
185
  }, className: undefined }, filteredAttributes);
@@ -164,21 +191,27 @@ var compileReactIconProperties = function (_a) {
164
191
  }
165
192
  return componentProps;
166
193
  };
167
- var IconChevronDownSmall = function (props) {
168
- var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["8", "16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
169
- var iconBodies = {
170
- "8": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m1 2.5 3 3 3-3\" class=\"icon-dark\"/>",
171
- "16": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m4 6 4 4 4-4\" class=\"icon-dark\"/>"
172
- };
173
- var body = iconBodies[size];
194
+
195
+ function useIconProps(props, iconBodiesAndDefs, availableSizes, name) {
196
+ var interactiveColorsOnGroup = props.interactiveColorsOnGroup, cleanProps = __rest(props, ["interactiveColorsOnGroup"]);
197
+ var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, cleanProps), { availableSizes: availableSizes, interactiveColorsOnGroup: interactiveColorsOnGroup })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
198
+ var _b = iconBodiesAndDefs[size] || {}, body = _b.body, defs = _b.defs;
174
199
  if (!body) {
175
- throw Error("Icon \"chevron-down-small\" is not available in size ".concat(size));
200
+ throw Error("Icon \"".concat(name, "\" is not available in size ").concat(size));
176
201
  }
177
- return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
178
- };
202
+ return compileReactIconProperties(__assign(__assign({}, cleanProps), { name: name, size: size, body: body, defs: defs, compiledClasses: compiledClasses }));
203
+ }
204
+ var IconChevronDownSmall = function (props) { return React__namespace.createElement('svg', useIconProps(props, {
205
+ "8": {
206
+ "body": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m1 2.5 3 3 3-3\" class=\"icon-dark\"/>"
207
+ },
208
+ "16": {
209
+ "body": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m4 6 4 4 4-4\" class=\"icon-dark\"/>"
210
+ }
211
+ }, ["8", "16"], "chevron-down-small")); };
179
212
 
180
213
 
181
- /* <wind-keep class="filter"> */
214
+ /* <wind-keep class="filter icon-light-secondary icon-dark-secondary"> */
182
215
 
183
216
  const classes = {
184
217
  button: 'flex leading-[24px] py-[10px] items-center relative w-full',
@@ -193,14 +226,14 @@ var DocGroup = function (_a) {
193
226
  var _e = React__namespace.useState(Array(group.items.length).fill(1)), itemsHeights = _e[0], setItemsHeights = _e[1];
194
227
  React__namespace.useEffect(function () {
195
228
  setHeight === null || setHeight === void 0 ? void 0 : setHeight(open ? itemsHeights.reduce(function (a, b) { return a + b; }, 1) : 1);
196
- }, [itemsHeights, open]);
229
+ }, [itemsHeights, open, setHeight]);
197
230
  var _f = React__namespace.useState(0), activeTop = _f[0], setActiveTop = _f[1];
198
231
  React__namespace.useEffect(function () {
199
232
  var activeItem = group.items.findIndex(function (item) { return 'href' in item && item.active; });
200
233
  if (activeItem >= 0) {
201
234
  setActiveTop(itemsHeights.slice(0, activeItem).reduce(function (a, b) { return a + b; }, 1) * 44);
202
235
  }
203
- }, [itemsHeights]);
236
+ }, [itemsHeights, group.items]);
204
237
  function toggleMenu(open) {
205
238
  if (!collapsible)
206
239
  return;
@@ -216,7 +249,7 @@ var DocGroup = function (_a) {
216
249
  var Head = collapsible ? 'button' : group.href ? 'a' : 'div';
217
250
  return (React__namespace.createElement(React__namespace.Fragment, null,
218
251
  React__namespace.createElement(Head, { onClick: function () { return toggleMenu(!open); }, href: group.href, className: clsx(classes.button, (_b = {
219
- 'text-indigo-500 dark:text-indigo-200': group.active
252
+ 'text-indigo-500': group.active
220
253
  },
221
254
  _b[classes.topButton] = depth === 0,
222
255
  _b[classes.leafButton] = depth,
@@ -254,4 +287,4 @@ var DocMenu = function (_a) {
254
287
  module.exports = DocMenu;
255
288
  //# sourceMappingURL=index.umd.js.map
256
289
 
257
- /* <wind-keep class="list-none p-0 relative pl-[16px] inline-block pl-[24px] text-indigo-500 dark:text-indigo-200 py-[8px] text-[16px] leading-[24px] py-[12px] leading-[20px] text-[14px] absolute w-[4px] z-10 top-[10%] h-[80%] rounded-full hidden group-hover:block bg-gray-300 text-indigo-200 transform transition-transform left-0 rotate-0 -rotate-90 ml-[16px] h-[36px] bg-indigo-500 transition-all duration-300 ml-[6px] mt-[4px] ml-[8px] border-l border-gray-100 flex py-[10px] items-center w-full font-medium pl-[40px]"> */
290
+ /* <wind-keep class="list-none p-0 relative pl-[16px] inline-block pl-[24px] text-indigo-500 py-[8px] text-[16px] leading-[24px] py-[12px] leading-[20px] text-[14px] absolute w-[4px] z-10 top-[10%] h-[80%] rounded-full hidden group-hover:block bg-gray-300 transform transition-transform left-0 rotate-0 -rotate-90 ml-[16px] h-[36px] bg-indigo-500 transition-all duration-300 ml-[6px] mt-[4px] ml-[8px] border-l border-gray-100 flex py-[10px] items-center w-full font-medium pl-[40px]"> */