@cypress-design/react-docmenu 0.2.2 → 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
@@ -38,6 +38,8 @@ 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 */
42
+
41
43
 
42
44
  var __assign$1 = function() {
43
45
  __assign$1 = Object.assign || function __assign(t) {
@@ -87,7 +89,7 @@ var DocLink = function (_a) {
87
89
  'pl-[16px]': depth >= 0,
88
90
  }) },
89
91
  React__namespace.createElement("a", { className: clsx('group relative inline-block pl-[24px]', {
90
- 'text-indigo-500 dark:text-indigo-200': item.active,
92
+ 'text-indigo-500': item.active,
91
93
  'py-[8px] text-[16px] leading-[24px]': depth < 0,
92
94
  'py-[12px] leading-[20px] text-[14px]': depth >= 0,
93
95
  }), href: item.href },
@@ -113,6 +115,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
113
115
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
114
116
  PERFORMANCE OF THIS SOFTWARE.
115
117
  ***************************************************************************** */
118
+ /* global Reflect, Promise */
119
+
116
120
 
117
121
  var __assign = function() {
118
122
  __assign = Object.assign || function __assign(t) {
@@ -138,17 +142,34 @@ function __rest(s, e) {
138
142
  }
139
143
 
140
144
  var compileReactIconProperties = function (_a) {
141
- 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"]);
142
146
  var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
143
- if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) && attrName !== 'name') {
147
+ if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) &&
148
+ attrName !== 'name') {
149
+ // @ts-expect-error the ky of React's SVGProps is too broad and
150
+ // breaks here. Since we do not need to check for it. We keep the expect error
144
151
  newAttributes[attrName] =
145
152
  attributes[attrName];
146
153
  }
147
154
  return newAttributes;
148
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]);
149
170
  var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
150
171
  __html: body,
151
- } }, filteredAttributes);
172
+ }, className: undefined }, filteredAttributes);
152
173
  if (attributes.className) {
153
174
  compiledClasses.push(attributes.className);
154
175
  }
@@ -157,21 +178,27 @@ var compileReactIconProperties = function (_a) {
157
178
  }
158
179
  return componentProps;
159
180
  };
160
- var IconChevronDownSmall = function (props) {
161
- var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["8", "16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
162
- var iconBodies = {
163
- "8": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m1 2.5 3 3 3-3\" class=\"icon-dark\"/>",
164
- "16": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m4 6 4 4 4-4\" class=\"icon-dark\"/>"
165
- };
166
- 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;
167
186
  if (!body) {
168
- 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));
169
188
  }
170
- return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
171
- };
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")); };
172
199
 
173
200
 
174
- /* <wind-keep class=""> */
201
+ /* <wind-keep class="filter icon-light-secondary icon-dark-secondary"> */
175
202
 
176
203
  const classes = {
177
204
  button: 'flex leading-[24px] py-[10px] items-center relative w-full',
@@ -209,7 +236,7 @@ var DocGroup = function (_a) {
209
236
  var Head = collapsible ? 'button' : group.href ? 'a' : 'div';
210
237
  return (React__namespace.createElement(React__namespace.Fragment, null,
211
238
  React__namespace.createElement(Head, { onClick: function () { return toggleMenu(!open); }, href: group.href, className: clsx(classes.button, (_b = {
212
- 'text-indigo-500 dark:text-indigo-200': group.active
239
+ 'text-indigo-500': group.active
213
240
  },
214
241
  _b[classes.topButton] = depth === 0,
215
242
  _b[classes.leafButton] = depth,
@@ -247,4 +274,4 @@ var DocMenu = function (_a) {
247
274
  module.exports = DocMenu;
248
275
  //# sourceMappingURL=index.umd.js.map
249
276
 
250
- /* <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 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]"> */