@cypress-design/react-accordion 1.0.0 → 1.0.2
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/.turbo/turbo-build.log +3 -1
- package/CHANGELOG.md +15 -0
- package/dist/index.es.mjs +7 -117
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +8 -118
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/rollup.config.mjs +5 -1
package/dist/index.umd.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
5
|
var detailsAnimation = require('@cypress-design/details-animation');
|
|
6
|
-
var
|
|
6
|
+
var reactIcon = require('@cypress-design/react-icon');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
var n = Object.create(null);
|
|
@@ -23,7 +23,6 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
-
var iconsRegistry__namespace = /*#__PURE__*/_interopNamespaceDefault(iconsRegistry);
|
|
27
26
|
|
|
28
27
|
/******************************************************************************
|
|
29
28
|
Copyright (c) Microsoft Corporation.
|
|
@@ -42,18 +41,18 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
42
41
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
var __assign
|
|
46
|
-
__assign
|
|
44
|
+
var __assign = function() {
|
|
45
|
+
__assign = Object.assign || function __assign(t) {
|
|
47
46
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
48
47
|
s = arguments[i];
|
|
49
48
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
50
49
|
}
|
|
51
50
|
return t;
|
|
52
51
|
};
|
|
53
|
-
return __assign
|
|
52
|
+
return __assign.apply(this, arguments);
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
function __rest
|
|
55
|
+
function __rest(s, e) {
|
|
57
56
|
var t = {};
|
|
58
57
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
59
58
|
t[p] = s[p];
|
|
@@ -85,117 +84,8 @@ const CssClasses = {
|
|
|
85
84
|
content: 'px-[24px] py-[16px]',
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
/******************************************************************************
|
|
89
|
-
Copyright (c) Microsoft Corporation.
|
|
90
|
-
|
|
91
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
92
|
-
purpose with or without fee is hereby granted.
|
|
93
|
-
|
|
94
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
95
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
96
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
97
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
98
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
99
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
100
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
101
|
-
***************************************************************************** */
|
|
102
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var __assign = function() {
|
|
106
|
-
__assign = Object.assign || function __assign(t) {
|
|
107
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
108
|
-
s = arguments[i];
|
|
109
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
110
|
-
}
|
|
111
|
-
return t;
|
|
112
|
-
};
|
|
113
|
-
return __assign.apply(this, arguments);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
function __rest(s, e) {
|
|
117
|
-
var t = {};
|
|
118
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
119
|
-
t[p] = s[p];
|
|
120
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
121
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
122
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
123
|
-
t[p[i]] = s[p[i]];
|
|
124
|
-
}
|
|
125
|
-
return t;
|
|
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
|
-
};
|
|
132
|
-
|
|
133
|
-
var compileReactIconProperties = function (_a) {
|
|
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"]);
|
|
135
|
-
var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
|
|
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
|
|
140
|
-
newAttributes[attrName] =
|
|
141
|
-
attributes[attrName];
|
|
142
|
-
}
|
|
143
|
-
return newAttributes;
|
|
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]);
|
|
160
|
-
var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
|
|
161
|
-
__html: alt
|
|
162
|
-
? "<title>".concat(alt.replace(/[><]/g, function (s) {
|
|
163
|
-
return s === '>' ? '>' : '<';
|
|
164
|
-
}), "</title>").concat(body)
|
|
165
|
-
: body,
|
|
166
|
-
}, className: undefined }, filteredAttributes);
|
|
167
|
-
if (attributes.className) {
|
|
168
|
-
compiledClasses.push(attributes.className);
|
|
169
|
-
}
|
|
170
|
-
if (compiledClasses.length) {
|
|
171
|
-
componentProps.className = compiledClasses.join(' ');
|
|
172
|
-
}
|
|
173
|
-
return componentProps;
|
|
174
|
-
};
|
|
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;
|
|
180
|
-
if (!body) {
|
|
181
|
-
throw Error("Icon \"".concat(name, "\" is not available in size ").concat(size));
|
|
182
|
-
}
|
|
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")); };
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/* <wind-keep class="filter icon-light-secondary icon-dark-secondary"> */
|
|
196
|
-
|
|
197
87
|
var Accordion = function (_a) {
|
|
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
|
|
88
|
+
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(_a, ["title", "description", "icon", "iconEl", "separator", "children", "headingClassName", "titleClassName", "descriptionClassName", "fullWidthContent"]);
|
|
199
89
|
var details = React__namespace.useRef(null);
|
|
200
90
|
var content = React__namespace.useRef(null);
|
|
201
91
|
React__namespace.useEffect(function () {
|
|
@@ -203,7 +93,7 @@ var Accordion = function (_a) {
|
|
|
203
93
|
new detailsAnimation.DetailsAnimation(details.current, content.current);
|
|
204
94
|
}
|
|
205
95
|
}, []);
|
|
206
|
-
return (React__namespace.createElement("details", __assign
|
|
96
|
+
return (React__namespace.createElement("details", __assign({}, rest, { className: clsx(rest.className), ref: details }),
|
|
207
97
|
React__namespace.createElement("summary", { className: clsx(CssClasses.summary, headingClassName !== null && headingClassName !== void 0 ? headingClassName : CssClasses.summaryColor) },
|
|
208
98
|
React__namespace.createElement("span", { className: CssClasses.summaryDiv },
|
|
209
99
|
Boolean(iconEl) && React__namespace.createElement("span", { className: CssClasses.icon }, iconEl),
|
|
@@ -212,7 +102,7 @@ var Accordion = function (_a) {
|
|
|
212
102
|
React__namespace.createElement("span", { className: "flex-grow grow pr-[16px]" },
|
|
213
103
|
React__namespace.createElement("span", { className: clsx(titleClassName !== null && titleClassName !== void 0 ? titleClassName : CssClasses.summaryTitleColor, CssClasses.summaryTitle) }, title),
|
|
214
104
|
description && (React__namespace.createElement("span", { className: clsx(CssClasses.summaryDescription, descriptionClassName !== null && descriptionClassName !== void 0 ? descriptionClassName : CssClasses.summaryDescriptionColor) }, description))),
|
|
215
|
-
React__namespace.createElement(IconChevronDownSmall, { strokeColor: "gray-300", className: clsx('open:icon-dark-gray-500', CssClasses.chevron) }))),
|
|
105
|
+
React__namespace.createElement(reactIcon.IconChevronDownSmall, { strokeColor: "gray-300", className: clsx('open:icon-dark-gray-500', CssClasses.chevron) }))),
|
|
216
106
|
React__namespace.createElement("div", { ref: content, className: CssClasses.contentWrapper }, fullWidthContent ? (React__namespace.createElement(React__namespace.Fragment, null, children)) : (React__namespace.createElement("div", { className: CssClasses.content }, children)))));
|
|
217
107
|
};
|
|
218
108
|
|