react-image-accordion 1.2.2 → 1.3.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/LICENSE +21 -21
- package/README.md +127 -151
- package/dist/index.css +1 -0
- package/dist/index.es.css +1 -0
- package/dist/index.es.js +118 -123
- package/dist/index.js +118 -123
- package/package.json +70 -65
- package/.babelrc.json +0 -15
- package/.storybook/main.js +0 -11
- package/.storybook/preview.js +0 -9
- package/rollup.config.js +0 -39
- package/src/.prettierrc +0 -1
- package/src/components/Accordion/App.css +0 -209
- package/src/components/Accordion/React-image-accordion.js +0 -22
- package/src/components/Accordion/UseImageAccordion.js +0 -131
- package/src/components/Accordion/index.js +0 -2
- package/src/index.js +0 -2
- package/src/stories/MockAccordion.json +0 -66
- package/src/stories/UseImageAccordion.stories.js +0 -20
- package/src/stories/sprite.svg +0 -49
- package/src/svg/bitcoin-svgrepo-com.svg +0 -6
- package/src/svg/chrome-svgrepo-com.svg +0 -6
- package/src/svg/compare-svgrepo-com.svg +0 -6
- package/src/svg/document-check-svgrepo-com.svg +0 -7
- package/src/svg/document-file-with-line-svgrepo-com.svg +0 -6
- package/src/svg/gui-regex-svgrepo-com.svg +0 -6
- package/src/svg/image-svgrepo-com.svg +0 -6
- package/src/svg/npm-svgrepo-com.svg +0 -7
- package/src/svg/twitter-social-tweet-svgrepo-com.svg +0 -6
package/dist/index.js
CHANGED
|
@@ -8,48 +8,70 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
function _iterableToArrayLimit(arr, i) {
|
|
12
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
13
|
+
if (null != _i) {
|
|
14
|
+
var _s,
|
|
15
|
+
_e,
|
|
16
|
+
_x,
|
|
17
|
+
_r,
|
|
18
|
+
_arr = [],
|
|
19
|
+
_n = !0,
|
|
20
|
+
_d = !1;
|
|
21
|
+
try {
|
|
22
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
23
|
+
if (Object(_i) !== _i) return;
|
|
24
|
+
_n = !1;
|
|
25
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
_d = !0, _e = err;
|
|
28
|
+
} finally {
|
|
29
|
+
try {
|
|
30
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
31
|
+
} finally {
|
|
32
|
+
if (_d) throw _e;
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
head.appendChild(style);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (style.styleSheet) {
|
|
32
|
-
style.styleSheet.cssText = css;
|
|
33
|
-
} else {
|
|
34
|
-
style.appendChild(document.createTextNode(css));
|
|
35
|
+
return _arr;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
38
|
+
function _slicedToArray(arr, i) {
|
|
39
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
40
|
+
}
|
|
41
|
+
function _arrayWithHoles(arr) {
|
|
42
|
+
if (Array.isArray(arr)) return arr;
|
|
43
|
+
}
|
|
44
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
45
|
+
if (!o) return;
|
|
46
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
47
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
48
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
49
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
50
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
51
|
+
}
|
|
52
|
+
function _arrayLikeToArray(arr, len) {
|
|
53
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
54
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
55
|
+
return arr2;
|
|
56
|
+
}
|
|
57
|
+
function _nonIterableRest() {
|
|
58
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
59
|
+
}
|
|
37
60
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const ContentSizeFont = ContentSize || [];
|
|
61
|
+
function UseImageAccordion(_ref) {
|
|
62
|
+
var accordionData = _ref.accordionData,
|
|
63
|
+
AccordionWidth = _ref.AccordionWidth,
|
|
64
|
+
AccordionHeight = _ref.AccordionHeight,
|
|
65
|
+
ContentSize = _ref.ContentSize,
|
|
66
|
+
_onClick = _ref.onClick,
|
|
67
|
+
ShowButton = _ref.ShowButton;
|
|
68
|
+
var _useState = React.useState(null),
|
|
69
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
70
|
+
activePanel = _useState2[0],
|
|
71
|
+
setActivePanel = _useState2[1];
|
|
72
|
+
var ContentSizeFont = ContentSize || [];
|
|
51
73
|
function toggleAccordion(panelToActivate) {
|
|
52
|
-
setActivePanel(prevPanel
|
|
74
|
+
setActivePanel(function (prevPanel) {
|
|
53
75
|
if (prevPanel === panelToActivate) {
|
|
54
76
|
return prevPanel;
|
|
55
77
|
} else {
|
|
@@ -57,39 +79,9 @@ function UseImageAccordion({
|
|
|
57
79
|
}
|
|
58
80
|
});
|
|
59
81
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
height: ${AccordionHeight};
|
|
64
|
-
}
|
|
65
|
-
}`;
|
|
66
|
-
const css = `
|
|
67
|
-
@media (max-width: 480px) {
|
|
68
|
-
.ContentSize {
|
|
69
|
-
font-size: ${ContentSizeFont[0] || "0.65rem"};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
@media (min-width: 481px) and (max-width: 768px) {
|
|
73
|
-
.ContentSize {
|
|
74
|
-
font-size: ${ContentSizeFont[1] || "0.8rem"};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
@media (min-width: 769px) and (max-width: 1024px) {
|
|
78
|
-
.ContentSize {
|
|
79
|
-
font-size: ${ContentSizeFont[2] || "1rem"};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
@media (min-width: 1025px) and (max-width: 1200px) {
|
|
83
|
-
.ContentSize {
|
|
84
|
-
font-size: ${ContentSizeFont[3] || "1.2rem"};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
@media (min-width: 1201px) {
|
|
88
|
-
.ContentSize {
|
|
89
|
-
font-size: ${ContentSizeFont[4] || "1.5rem"};
|
|
90
|
-
}
|
|
91
|
-
}`;
|
|
92
|
-
React.useEffect(() => {
|
|
82
|
+
var HeightStyle = "\n @media (min-width: 768px) {\n .AccHeight {\n height: ".concat(AccordionHeight, ";\n }\n }");
|
|
83
|
+
var css = "\n @media (max-width: 480px) {\n .ContentSize {\n font-size: ".concat(ContentSizeFont[0] || "0.65rem", ";\n }\n }\n @media (min-width: 481px) and (max-width: 768px) {\n .ContentSize {\n font-size: ").concat(ContentSizeFont[1] || "0.8rem", ";\n }\n }\n @media (min-width: 769px) and (max-width: 1024px) {\n .ContentSize {\n font-size: ").concat(ContentSizeFont[2] || "1rem", ";\n }\n }\n @media (min-width: 1025px) and (max-width: 1200px) {\n .ContentSize {\n font-size: ").concat(ContentSizeFont[3] || "1.2rem", ";\n }\n }\n @media (min-width: 1201px) {\n .ContentSize {\n font-size: ").concat(ContentSizeFont[4] || "1.5rem", ";\n }\n }");
|
|
84
|
+
React.useEffect(function () {
|
|
93
85
|
setActivePanel(accordionData[0].id);
|
|
94
86
|
}, []);
|
|
95
87
|
if (!accordionData) return null;
|
|
@@ -102,61 +94,64 @@ function UseImageAccordion({
|
|
|
102
94
|
scoped: true
|
|
103
95
|
}, HeightStyle), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
104
96
|
className: "accordionImage AccHeight"
|
|
105
|
-
}, accordionData.map(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
97
|
+
}, accordionData.map(function (item) {
|
|
98
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
99
|
+
key: item.id,
|
|
100
|
+
className: "accordion-panel",
|
|
101
|
+
onClick: function onClick() {
|
|
102
|
+
return toggleAccordion(item.id);
|
|
103
|
+
}
|
|
104
|
+
}, /*#__PURE__*/React__default["default"].createElement("h2", {
|
|
105
|
+
id: item.id
|
|
106
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
107
|
+
type: "button",
|
|
108
|
+
className: "accordion-trigger",
|
|
109
|
+
"aria-controls": "panel1-content",
|
|
110
|
+
"aria-expanded": activePanel === item.id
|
|
111
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
112
|
+
className: "accordion-title",
|
|
113
|
+
id: item.id
|
|
114
|
+
}, item.title), /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
className: "accordion-icon",
|
|
117
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
118
|
+
}, /*#__PURE__*/React__default["default"].createElement("image", {
|
|
119
|
+
href: item.svg
|
|
120
|
+
})))), /*#__PURE__*/React__default["default"].createElement("style", {
|
|
121
|
+
scoped: true
|
|
122
|
+
}, css), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
123
|
+
className: "accordion-content ContentSize",
|
|
124
|
+
style: {
|
|
125
|
+
height: "calc(".concat(AccordionHeight, " - 5rem)")
|
|
126
|
+
},
|
|
127
|
+
id: item.id,
|
|
128
|
+
"aria-labelledby": item.id,
|
|
129
|
+
"aria-hidden": activePanel !== item.id,
|
|
130
|
+
role: "region"
|
|
131
|
+
}, /*#__PURE__*/React__default["default"].createElement("p", null, item.content), ShowButton && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
132
|
+
className: "accordion-Link",
|
|
133
|
+
onClick: function onClick(e) {
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
_onClick({
|
|
136
|
+
id: item.id,
|
|
137
|
+
title: item.title
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, item.title), /*#__PURE__*/React__default["default"].createElement("img", {
|
|
141
|
+
className: "accordion-image",
|
|
142
|
+
src: item.image,
|
|
143
|
+
alt: item.alt
|
|
144
|
+
})));
|
|
145
|
+
}))));
|
|
150
146
|
}
|
|
151
147
|
|
|
152
|
-
|
|
153
|
-
accordionData,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}) => {
|
|
148
|
+
var ReactImageAccordion = function ReactImageAccordion(_ref) {
|
|
149
|
+
var accordionData = _ref.accordionData,
|
|
150
|
+
AccordionWidth = _ref.AccordionWidth,
|
|
151
|
+
AccordionHeight = _ref.AccordionHeight,
|
|
152
|
+
ContentSize = _ref.ContentSize,
|
|
153
|
+
onClick = _ref.onClick,
|
|
154
|
+
ShowButton = _ref.ShowButton;
|
|
160
155
|
return /*#__PURE__*/React__default["default"].createElement(UseImageAccordion, {
|
|
161
156
|
accordionData: accordionData,
|
|
162
157
|
AccordionWidth: AccordionWidth,
|
package/package.json
CHANGED
|
@@ -1,65 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-image-accordion",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Accordion component for React",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.es.js",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@storybook/
|
|
45
|
-
"@storybook/
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
}
|
|
65
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "react-image-accordion",
|
|
3
|
+
"version": "1.3.2",
|
|
4
|
+
"description": "Accordion component for React",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "npm run build-lib",
|
|
15
|
+
"build-lib": "rollup -c",
|
|
16
|
+
"storybook": "storybook dev -p 6006",
|
|
17
|
+
"build-storybook": "storybook build"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/masoud-naji/Accordion.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"react",
|
|
25
|
+
"accordion",
|
|
26
|
+
"react-accordion",
|
|
27
|
+
"accordion-component",
|
|
28
|
+
"react-accordion-component",
|
|
29
|
+
"react-component",
|
|
30
|
+
"accordion-react-component"
|
|
31
|
+
],
|
|
32
|
+
"author": "Masoud Naji",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/masoud-naji/Accordion/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/masoud-naji/Accordion#readme",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/core": "^7.18.2",
|
|
40
|
+
"@babel/preset-env": "^7.21.4",
|
|
41
|
+
"@babel/preset-react": "^7.18.6",
|
|
42
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
44
|
+
"@storybook/addon-actions": "^7.0.7",
|
|
45
|
+
"@storybook/addon-essentials": "^7.0.7",
|
|
46
|
+
"@storybook/addon-interactions": "^7.0.7",
|
|
47
|
+
"@storybook/addon-links": "^7.0.7",
|
|
48
|
+
"@storybook/addon-mdx-gfm": "^7.0.7",
|
|
49
|
+
"@storybook/react": "^7.0.7",
|
|
50
|
+
"@storybook/react-webpack5": "^7.0.7",
|
|
51
|
+
"@storybook/testing-library": "^0.1.0",
|
|
52
|
+
"babel-loader": "^8.2.5",
|
|
53
|
+
"react": "^18.1.0",
|
|
54
|
+
"react-dom": "^18.1.0",
|
|
55
|
+
"rollup": "^2.79.1",
|
|
56
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
57
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
58
|
+
"rollup-plugin-postcss": "^3.1.8",
|
|
59
|
+
"storybook": "^7.0.7"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"react": "^18.1.0",
|
|
63
|
+
"react-dom": "^18.1.0"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@rollup/plugin-terser": "^0.4.1",
|
|
67
|
+
"rollup-plugin-local-resolve": "^1.0.7",
|
|
68
|
+
"rollup-plugin-terser": "^7.0.2"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/.babelrc.json
DELETED
package/.storybook/main.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"stories": ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
3
|
-
"addons": ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions", "@storybook/addon-mdx-gfm"],
|
|
4
|
-
"framework": {
|
|
5
|
-
name: "@storybook/react-webpack5",
|
|
6
|
-
options: {}
|
|
7
|
-
},
|
|
8
|
-
docs: {
|
|
9
|
-
autodocs: true
|
|
10
|
-
}
|
|
11
|
-
};
|
package/.storybook/preview.js
DELETED
package/rollup.config.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import babel from 'rollup-plugin-babel';
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import external from 'rollup-plugin-peer-deps-external';
|
|
4
|
-
import postcss from 'rollup-plugin-postcss';
|
|
5
|
-
import localResolve from 'rollup-plugin-local-resolve';
|
|
6
|
-
// import { terser } from "rollup-plugin-terser";
|
|
7
|
-
|
|
8
|
-
export default [
|
|
9
|
-
{
|
|
10
|
-
input: 'src/index.js',
|
|
11
|
-
output: [
|
|
12
|
-
{
|
|
13
|
-
file: 'dist/index.js',
|
|
14
|
-
format: 'cjs',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
file: 'dist/index.es.js',
|
|
18
|
-
format: 'es',
|
|
19
|
-
exports: 'named',
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
plugins: [
|
|
23
|
-
postcss({
|
|
24
|
-
plugins: []
|
|
25
|
-
}),
|
|
26
|
-
babel({
|
|
27
|
-
exclude: 'node_modules/**',
|
|
28
|
-
presets: ['@babel/preset-react'],
|
|
29
|
-
}),
|
|
30
|
-
external(),
|
|
31
|
-
resolve(),
|
|
32
|
-
localResolve(),
|
|
33
|
-
// terser(),
|
|
34
|
-
],
|
|
35
|
-
watch: {
|
|
36
|
-
include: "src/**",
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
];
|
package/src/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|