@cypress-design/react-accordion 0.4.3 → 1.0.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
@@ -39,7 +39,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
39
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
40
  PERFORMANCE OF THIS SOFTWARE.
41
41
  ***************************************************************************** */
42
- /* global Reflect, Promise */
42
+ /* global Reflect, Promise, SuppressedError, Symbol */
43
43
 
44
44
 
45
45
  var __assign$1 = function() {
@@ -63,7 +63,12 @@ function __rest$1(s, e) {
63
63
  t[p[i]] = s[p[i]];
64
64
  }
65
65
  return t;
66
- }
66
+ }
67
+
68
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
69
+ var e = new Error(message);
70
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
71
+ };
67
72
 
68
73
  const CssClasses = {
69
74
  summary: 'details-none card open:rounded-b-none',
@@ -94,7 +99,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
94
99
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
95
100
  PERFORMANCE OF THIS SOFTWARE.
96
101
  ***************************************************************************** */
97
- /* global Reflect, Promise */
102
+ /* global Reflect, Promise, SuppressedError, Symbol */
98
103
 
99
104
 
100
105
  var __assign = function() {
@@ -118,20 +123,47 @@ function __rest(s, e) {
118
123
  t[p[i]] = s[p[i]];
119
124
  }
120
125
  return t;
121
- }
126
+ }
127
+
128
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
129
+ var e = new Error(message);
130
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
131
+ };
122
132
 
123
133
  var compileReactIconProperties = function (_a) {
124
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
134
+ var body = _a.body, defs = _a.defs, compiledClasses = _a.compiledClasses, size = _a.size, name = _a.name, alt = _a.alt, attributes = __rest(_a, ["body", "defs", "compiledClasses", "size", "name", "alt"]);
125
135
  var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
126
- if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) && attrName !== 'name') {
136
+ if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) &&
137
+ attrName !== 'name') {
138
+ // @ts-expect-error the ky of React's SVGProps is too broad and
139
+ // breaks here. Since we do not need to check for it. We keep the expect error
127
140
  newAttributes[attrName] =
128
141
  attributes[attrName];
129
142
  }
130
143
  return newAttributes;
131
144
  }, {});
145
+ // eslint-disable-next-line react-hooks/rules-of-hooks
146
+ React__namespace.useEffect(function () {
147
+ var iconFileId = "".concat(name, "_").concat(size);
148
+ if (defs) {
149
+ if (document.querySelector("[data-cy-svg-defs=\"".concat(iconFileId, "\"]"))) {
150
+ return;
151
+ }
152
+ var svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
153
+ svgElement.setAttribute('data-cy-svg-defs', iconFileId);
154
+ svgElement.setAttribute('width', '0');
155
+ svgElement.setAttribute('height', '0');
156
+ svgElement.innerHTML = defs;
157
+ document.body.appendChild(svgElement);
158
+ }
159
+ }, [defs, name, size]);
132
160
  var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
133
- __html: body,
134
- } }, filteredAttributes);
161
+ __html: alt
162
+ ? "<title>".concat(alt.replace(/[><]/g, function (s) {
163
+ return s === '>' ? '&gt;' : '&lt;';
164
+ }), "</title>").concat(body)
165
+ : body,
166
+ }, className: undefined }, filteredAttributes);
135
167
  if (attributes.className) {
136
168
  compiledClasses.push(attributes.className);
137
169
  }
@@ -140,21 +172,27 @@ var compileReactIconProperties = function (_a) {
140
172
  }
141
173
  return componentProps;
142
174
  };
143
- var IconChevronDownSmall = function (props) {
144
- var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["8", "16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
145
- var iconBodies = {
146
- "8": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m1 2.5 3 3 3-3\" class=\"icon-dark\"/>",
147
- "16": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m4 6 4 4 4-4\" class=\"icon-dark\"/>"
148
- };
149
- var body = iconBodies[size];
175
+
176
+ function useIconProps(props, iconBodiesAndDefs, availableSizes, name) {
177
+ var interactiveColorsOnGroup = props.interactiveColorsOnGroup, cleanProps = __rest(props, ["interactiveColorsOnGroup"]);
178
+ var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, cleanProps), { availableSizes: availableSizes, interactiveColorsOnGroup: interactiveColorsOnGroup })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
179
+ var _b = iconBodiesAndDefs[size] || {}, body = _b.body, defs = _b.defs;
150
180
  if (!body) {
151
- throw Error("Icon \"chevron-down-small\" is not available in size ".concat(size));
181
+ throw Error("Icon \"".concat(name, "\" is not available in size ").concat(size));
152
182
  }
153
- return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
154
- };
183
+ return compileReactIconProperties(__assign(__assign({}, cleanProps), { name: name, size: size, body: body, defs: defs, compiledClasses: compiledClasses }));
184
+ }
185
+ var IconChevronDownSmall = function (props) { return React__namespace.createElement('svg', useIconProps(props, {
186
+ "8": {
187
+ "body": "<path d=\"m1 2.5 3 3 3-3\" stroke=\"currentColor\" class=\"icon-dark\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"
188
+ },
189
+ "16": {
190
+ "body": "<path d=\"m4 6 4 4 4-4\" stroke=\"currentColor\" class=\"icon-dark\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"
191
+ }
192
+ }, ["8", "16"], "chevron-down-small")); };
155
193
 
156
194
 
157
- /* <wind-keep class=""> */
195
+ /* <wind-keep class="filter icon-light-secondary icon-dark-secondary"> */
158
196
 
159
197
  var Accordion = function (_a) {
160
198
  var title = _a.title, description = _a.description, Icon = _a.icon, iconEl = _a.iconEl, _b = _a.separator, separator = _b === void 0 ? false : _b, children = _a.children, headingClassName = _a.headingClassName, titleClassName = _a.titleClassName, descriptionClassName = _a.descriptionClassName, fullWidthContent = _a.fullWidthContent, rest = __rest$1(_a, ["title", "description", "icon", "iconEl", "separator", "children", "headingClassName", "titleClassName", "descriptionClassName", "fullWidthContent"]);
@@ -181,4 +219,4 @@ var Accordion = function (_a) {
181
219
  module.exports = Accordion;
182
220
  //# sourceMappingURL=index.umd.js.map
183
221
 
184
- /* <wind-keep class="flex-grow pr-[16px] open:icon-dark-gray-500 details-none card open:rounded-b-none flex flex-row py-[12px] px-[24px] flex-nowrap items-center min-h-[63px] bg-white text-[18px] leading-[28px] font-medium text-indigo-500 block text-[14px] leading-[20px] font-normal text-gray-700 mr-[24px] flex-shrink-0 w-[1px] h-[40px] bg-gray-100 mr-[16px] transition transform rotate-0 open:rotate-180 border border-gray-100 rounded-b-md border-t-0 py-[16px]"> */
222
+ /* <wind-keep class="flex-grow grow pr-[16px] open:icon-dark-gray-500 details-none card open:rounded-b-none flex flex-row py-[12px] px-[24px] flex-nowrap items-center min-h-[63px] bg-white text-[18px] leading-[28px] font-medium text-indigo-500 block text-[14px] leading-[20px] font-normal text-gray-700 mr-[24px] flex-shrink-0 w-[1px] h-[40px] bg-gray-100 mr-[16px] transition transform rotate-0 open:rotate-180 border border-gray-100 rounded-b-md border-t-0 py-[16px]"> */