@cypress-design/react-accordion 0.4.4 → 1.0.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
@@ -2,8 +2,9 @@
2
2
 
3
3
  var React = require('react');
4
4
  var clsx = require('clsx');
5
+ var constantsAccordion = require('@cypress-design/constants-accordion');
5
6
  var detailsAnimation = require('@cypress-design/details-animation');
6
- var iconsRegistry = require('@cypress-design/icon-registry');
7
+ var reactIcon = require('@cypress-design/react-icon');
7
8
 
8
9
  function _interopNamespaceDefault(e) {
9
10
  var n = Object.create(null);
@@ -23,7 +24,6 @@ function _interopNamespaceDefault(e) {
23
24
  }
24
25
 
25
26
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
- var iconsRegistry__namespace = /*#__PURE__*/_interopNamespaceDefault(iconsRegistry);
27
27
 
28
28
  /******************************************************************************
29
29
  Copyright (c) Microsoft Corporation.
@@ -39,62 +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 */
43
-
44
-
45
- var __assign$1 = function() {
46
- __assign$1 = Object.assign || function __assign(t) {
47
- for (var s, i = 1, n = arguments.length; i < n; i++) {
48
- s = arguments[i];
49
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
50
- }
51
- return t;
52
- };
53
- return __assign$1.apply(this, arguments);
54
- };
55
-
56
- function __rest$1(s, e) {
57
- var t = {};
58
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
59
- t[p] = s[p];
60
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
61
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
62
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
63
- t[p[i]] = s[p[i]];
64
- }
65
- return t;
66
- }
67
-
68
- const CssClasses = {
69
- summary: 'details-none card open:rounded-b-none',
70
- summaryDiv: 'flex flex-row py-[12px] px-[24px] flex-nowrap items-center min-h-[63px]',
71
- summaryColor: 'bg-white',
72
- summaryTitle: 'text-[18px] leading-[28px] font-medium',
73
- summaryTitleColor: 'text-indigo-500 block',
74
- summaryDescription: 'text-[14px] leading-[20px] font-normal block',
75
- summaryDescriptionColor: 'text-gray-700',
76
- icon: 'mr-[24px] flex-shrink-0',
77
- separator: 'w-[1px] h-[40px] bg-gray-100 mr-[16px]',
78
- chevron: 'flex-shrink-0 transition transform rotate-0 open:rotate-180',
79
- contentWrapper: 'border border-gray-100 rounded-b-md border-t-0',
80
- content: 'px-[24px] py-[16px]',
81
- };
82
-
83
- /******************************************************************************
84
- Copyright (c) Microsoft Corporation.
85
-
86
- Permission to use, copy, modify, and/or distribute this software for any
87
- purpose with or without fee is hereby granted.
88
-
89
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
90
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
91
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
92
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
93
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
94
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
95
- PERFORMANCE OF THIS SOFTWARE.
96
- ***************************************************************************** */
97
- /* global Reflect, Promise */
42
+ /* global Reflect, Promise, SuppressedError, Symbol */
98
43
 
99
44
 
100
45
  var __assign = function() {
@@ -118,49 +63,15 @@ function __rest(s, e) {
118
63
  t[p[i]] = s[p[i]];
119
64
  }
120
65
  return t;
121
- }
122
-
123
- var compileReactIconProperties = function (_a) {
124
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
125
- var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
126
- if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) &&
127
- attrName !== 'name') {
128
- // @ts-expect-error the ky of React's SVGProps is too broad and
129
- // breaks here. Since we do not need to check for it. We keep the expect error
130
- newAttributes[attrName] =
131
- attributes[attrName];
132
- }
133
- return newAttributes;
134
- }, {});
135
- var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
136
- __html: body,
137
- }, className: undefined }, filteredAttributes);
138
- if (attributes.className) {
139
- compiledClasses.push(attributes.className);
140
- }
141
- if (compiledClasses.length) {
142
- componentProps.className = compiledClasses.join(' ');
143
- }
144
- return componentProps;
145
- };
146
- var IconChevronDownSmall = function (props) {
147
- var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["8", "16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
148
- var iconBodies = {
149
- "8": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m1 2.5 3 3 3-3\" class=\"icon-dark\"/>",
150
- "16": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m4 6 4 4 4-4\" class=\"icon-dark\"/>"
151
- };
152
- var body = iconBodies[size];
153
- if (!body) {
154
- throw Error("Icon \"chevron-down-small\" is not available in size ".concat(size));
155
- }
156
- return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
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;
157
71
  };
158
72
 
159
-
160
- /* <wind-keep class="filter"> */
161
-
162
73
  var Accordion = function (_a) {
163
- 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"]);
74
+ 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"]);
164
75
  var details = React__namespace.useRef(null);
165
76
  var content = React__namespace.useRef(null);
166
77
  React__namespace.useEffect(function () {
@@ -168,20 +79,20 @@ var Accordion = function (_a) {
168
79
  new detailsAnimation.DetailsAnimation(details.current, content.current);
169
80
  }
170
81
  }, []);
171
- return (React__namespace.createElement("details", __assign$1({}, rest, { className: clsx(rest.className), ref: details }),
172
- React__namespace.createElement("summary", { className: clsx(CssClasses.summary, headingClassName !== null && headingClassName !== void 0 ? headingClassName : CssClasses.summaryColor) },
173
- React__namespace.createElement("span", { className: CssClasses.summaryDiv },
174
- Boolean(iconEl) && React__namespace.createElement("span", { className: CssClasses.icon }, iconEl),
175
- Icon && !iconEl && React__namespace.createElement(Icon, { className: CssClasses.icon }),
176
- (Icon || iconEl) && separator && (React__namespace.createElement("span", { className: CssClasses.separator, role: "separator" })),
82
+ return (React__namespace.createElement("details", __assign({}, rest, { className: clsx(rest.className), ref: details }),
83
+ React__namespace.createElement("summary", { className: clsx(constantsAccordion.CssClasses.summary, headingClassName !== null && headingClassName !== void 0 ? headingClassName : constantsAccordion.CssClasses.summaryColor) },
84
+ React__namespace.createElement("span", { className: constantsAccordion.CssClasses.summaryDiv },
85
+ Boolean(iconEl) && React__namespace.createElement("span", { className: constantsAccordion.CssClasses.icon }, iconEl),
86
+ Icon && !iconEl && React__namespace.createElement(Icon, { className: constantsAccordion.CssClasses.icon }),
87
+ (Icon || iconEl) && separator && (React__namespace.createElement("span", { className: constantsAccordion.CssClasses.separator, role: "separator" })),
177
88
  React__namespace.createElement("span", { className: "flex-grow grow pr-[16px]" },
178
- React__namespace.createElement("span", { className: clsx(titleClassName !== null && titleClassName !== void 0 ? titleClassName : CssClasses.summaryTitleColor, CssClasses.summaryTitle) }, title),
179
- description && (React__namespace.createElement("span", { className: clsx(CssClasses.summaryDescription, descriptionClassName !== null && descriptionClassName !== void 0 ? descriptionClassName : CssClasses.summaryDescriptionColor) }, description))),
180
- React__namespace.createElement(IconChevronDownSmall, { strokeColor: "gray-300", className: clsx('open:icon-dark-gray-500', CssClasses.chevron) }))),
181
- 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)))));
89
+ React__namespace.createElement("span", { className: clsx(titleClassName !== null && titleClassName !== void 0 ? titleClassName : constantsAccordion.CssClasses.summaryTitleColor, constantsAccordion.CssClasses.summaryTitle) }, title),
90
+ description && (React__namespace.createElement("span", { className: clsx(constantsAccordion.CssClasses.summaryDescription, descriptionClassName !== null && descriptionClassName !== void 0 ? descriptionClassName : constantsAccordion.CssClasses.summaryDescriptionColor) }, description))),
91
+ React__namespace.createElement(reactIcon.IconChevronDownSmall, { strokeColor: "gray-300", className: clsx('open:icon-dark-gray-500', constantsAccordion.CssClasses.chevron) }))),
92
+ React__namespace.createElement("div", { ref: content, className: constantsAccordion.CssClasses.contentWrapper }, fullWidthContent ? (React__namespace.createElement(React__namespace.Fragment, null, children)) : (React__namespace.createElement("div", { className: constantsAccordion.CssClasses.content }, children)))));
182
93
  };
183
94
 
184
95
  module.exports = Accordion;
185
96
  //# sourceMappingURL=index.umd.js.map
186
97
 
187
- /* <wind-keep class="flex-grow grow pr-[16px] 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]"> */
98
+ /* <wind-keep class="flex-grow grow pr-[16px] open:icon-dark-gray-500"> */