@cypress-design/react-docmenu 0.2.3 → 0.3.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/dist/index.umd.js CHANGED
@@ -89,7 +89,7 @@ var DocLink = function (_a) {
89
89
  'pl-[16px]': depth >= 0,
90
90
  }) },
91
91
  React__namespace.createElement("a", { className: clsx('group relative inline-block pl-[24px]', {
92
- 'text-indigo-500 dark:text-indigo-200': item.active,
92
+ 'text-indigo-500': item.active,
93
93
  'py-[8px] text-[16px] leading-[24px]': depth < 0,
94
94
  'py-[12px] leading-[20px] text-[14px]': depth >= 0,
95
95
  }), href: item.href },
@@ -142,7 +142,7 @@ function __rest(s, e) {
142
142
  }
143
143
 
144
144
  var compileReactIconProperties = function (_a) {
145
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
145
+ 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
146
  var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
147
147
  if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) &&
148
148
  attrName !== 'name') {
@@ -153,6 +153,20 @@ var compileReactIconProperties = function (_a) {
153
153
  }
154
154
  return newAttributes;
155
155
  }, {});
156
+ React__namespace.useEffect(function () {
157
+ var iconFileId = "".concat(name, "_").concat(size);
158
+ if (defs) {
159
+ if (document.querySelector("[data-cy-svg-defs=\"".concat(iconFileId, "\"]"))) {
160
+ return;
161
+ }
162
+ var svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
163
+ svgElement.setAttribute('data-cy-svg-defs', iconFileId);
164
+ svgElement.setAttribute('width', '0');
165
+ svgElement.setAttribute('height', '0');
166
+ svgElement.innerHTML = defs;
167
+ document.body.appendChild(svgElement);
168
+ }
169
+ }, [defs]);
156
170
  var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
157
171
  __html: body,
158
172
  }, className: undefined }, filteredAttributes);
@@ -164,21 +178,27 @@ var compileReactIconProperties = function (_a) {
164
178
  }
165
179
  return componentProps;
166
180
  };
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];
181
+
182
+ function useIconProps(props, iconBodiesAndDefs, availableSizes, name) {
183
+ var interactiveColorsOnGroup = props.interactiveColorsOnGroup, cleanProps = __rest(props, ["interactiveColorsOnGroup"]);
184
+ var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, cleanProps), { availableSizes: availableSizes, interactiveColorsOnGroup: interactiveColorsOnGroup })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
185
+ var _b = iconBodiesAndDefs[size] || {}, body = _b.body, defs = _b.defs;
174
186
  if (!body) {
175
- throw Error("Icon \"chevron-down-small\" is not available in size ".concat(size));
187
+ throw Error("Icon \"".concat(name, "\" is not available in size ").concat(size));
176
188
  }
177
- return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
178
- };
189
+ return compileReactIconProperties(__assign(__assign({}, cleanProps), { name: name, size: size, body: body, defs: defs, compiledClasses: compiledClasses }));
190
+ }
191
+ var IconChevronDownSmall = function (props) { return React__namespace.createElement('svg', useIconProps(props, {
192
+ "8": {
193
+ "body": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m1 2.5 3 3 3-3\" class=\"icon-dark\"/>"
194
+ },
195
+ "16": {
196
+ "body": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m4 6 4 4 4-4\" class=\"icon-dark\"/>"
197
+ }
198
+ }, ["8", "16"], "chevron-down-small")); };
179
199
 
180
200
 
181
- /* <wind-keep class="filter"> */
201
+ /* <wind-keep class="filter icon-light-secondary icon-dark-secondary"> */
182
202
 
183
203
  const classes = {
184
204
  button: 'flex leading-[24px] py-[10px] items-center relative w-full',
@@ -216,7 +236,7 @@ var DocGroup = function (_a) {
216
236
  var Head = collapsible ? 'button' : group.href ? 'a' : 'div';
217
237
  return (React__namespace.createElement(React__namespace.Fragment, null,
218
238
  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
239
+ 'text-indigo-500': group.active
220
240
  },
221
241
  _b[classes.topButton] = depth === 0,
222
242
  _b[classes.leafButton] = depth,
@@ -254,4 +274,4 @@ var DocMenu = function (_a) {
254
274
  module.exports = DocMenu;
255
275
  //# sourceMappingURL=index.umd.js.map
256
276
 
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]"> */
277
+ /* <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]"> */