@lidofinance/ui-faq 0.38.0 → 0.39.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/README.md +69 -72
- package/dist/index.cjs +241 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +18 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.js → index.mjs} +93 -92
- package/dist/index.mjs.map +1 -0
- package/package.json +11 -15
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,113 +10,110 @@ FAQ UI components and parse utils.
|
|
|
10
10
|
yarn add @lidofinance/faq
|
|
11
11
|
|
|
12
12
|
# and additional
|
|
13
|
-
yarn add
|
|
13
|
+
yarn add styled-components@^5.3.5
|
|
14
14
|
|
|
15
15
|
# and warehouse packages
|
|
16
|
-
yarn add @lidofinance/analytics-matomo@^0.
|
|
16
|
+
yarn add @lidofinance/analytics-matomo@^0.39.0 @lidofinance/next-ui-primitives@^0.39.0
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Using
|
|
20
20
|
|
|
21
|
-
There is SSR example (using `getStaticProps`), but also you can use `
|
|
21
|
+
There is SSR example (using `getStaticProps`), but also you can use `parseFAQ` on client side inside any client component
|
|
22
22
|
|
|
23
23
|
```tsx
|
|
24
24
|
import { FC } from 'react';
|
|
25
25
|
import { GetStaticProps } from 'next';
|
|
26
26
|
import Head from 'next/head';
|
|
27
|
-
import { FaqAccordion, getFAQ, FAQItem, PageFAQ } from '@lidofinance/ui-faq';
|
|
28
|
-
import { serverAxios } from 'utilsApi';
|
|
29
27
|
|
|
28
|
+
import { parseFAQ, PageFAQ, isPageFAQ } from '@lidofinance/ui-faq';
|
|
29
|
+
// Your implementation
|
|
30
|
+
import { fetchFAQ } from '../utilsApi/get-faq';
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
// 15 minutes
|
|
33
|
+
const FAQ_REVALIDATE_SECS = 900;
|
|
34
|
+
|
|
35
|
+
type IndexPageProps = {
|
|
36
|
+
pageFAQ: PageFAQ | null;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
const IndexPage: FC<ExampleProps> = ({
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const IndexPage: FC<ExampleProps> = ({ pageFAQ }) => {
|
|
40
|
+
if (!pageFAQ || !isPageFAQ(pageFAQ)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<FaqAccordion
|
|
47
|
+
faqList={pageFAQ.faq}
|
|
48
|
+
/>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
38
52
|
|
|
39
53
|
export default IndexPage;
|
|
40
54
|
|
|
41
|
-
export const getStaticProps: GetStaticProps<
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
export const getStaticProps: GetStaticProps<IndexPageProps> = async () => {
|
|
56
|
+
// FAQ
|
|
57
|
+
let pageFAQ: PageFAQ | null = null;
|
|
44
58
|
|
|
45
59
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// memoryCacheConfig default is undefined
|
|
52
|
-
memoryCacheConfig: { max: 100, ttl: 6 * 100 * 1000 },
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// or custom axios and without cache
|
|
56
|
-
// const pages = await getFAQ(serverRuntimeConfig.faqContentUrl, {
|
|
57
|
-
// axiosInstance: clientAxios,
|
|
58
|
-
// cache: false,
|
|
59
|
-
// });
|
|
60
|
-
|
|
61
|
-
// or use internal FAQ pkg axios and use cache
|
|
62
|
-
// const pages = await getFAQ(serverRuntimeConfig.faqContentUrl);
|
|
63
|
-
|
|
64
|
-
// bacause `getFAQ` returns data for all pages
|
|
65
|
-
foundPage = pages.find(
|
|
66
|
-
(page: PageFAQ) => page['identification'] === pageIdentification,
|
|
67
|
-
);
|
|
60
|
+
// Your implementation
|
|
61
|
+
const rawFaqData = await fetchFAQ();
|
|
62
|
+
if (rawFaqData) {
|
|
63
|
+
pageFAQ = await parseFAQ(rawFaqData);
|
|
64
|
+
}
|
|
68
65
|
} catch {
|
|
69
|
-
|
|
66
|
+
console.warn('FAQ not available on index page!');
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
return {
|
|
73
70
|
props: {
|
|
74
|
-
|
|
71
|
+
// We can't use `undefined` with `pageFAQ`.
|
|
72
|
+
// Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.
|
|
73
|
+
pageFAQ: pageFAQ || null,
|
|
75
74
|
},
|
|
75
|
+
revalidate: FAQ_REVALIDATE_SECS,
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
### Matomo analytics
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
Let's make with [matomo analytics](https://www.npmjs.com/package/@lidofinance/analytics-matomo)!
|
|
83
83
|
|
|
84
84
|
```tsx
|
|
85
85
|
// See: @lidofinance/analytics-matomo
|
|
86
|
-
import {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
setFoundPage(
|
|
106
|
-
pages.find(
|
|
107
|
-
(page: PageFAQ) => page['identification'] === pageIdentification,
|
|
108
|
-
),
|
|
109
|
-
);
|
|
110
|
-
} catch {
|
|
111
|
-
// noop
|
|
112
|
-
}
|
|
113
|
-
})();
|
|
114
|
-
}, []);
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<FaqAccordion faqList={faqList} matomoEventMap={matomoEventMap} />
|
|
118
|
-
)
|
|
86
|
+
import { trackEvent } from '@lidofinance/analytics-matomo';
|
|
87
|
+
import { FAQAccordionOnLinkClickProps } from '@lidofinance/ui-faq';
|
|
88
|
+
|
|
89
|
+
type FaqAccordionOnLinkClickFactoryProps = FAQAccordionOnLinkClickProps & { pageId: string };
|
|
90
|
+
|
|
91
|
+
// It is just example - you are not limited by your imagination!
|
|
92
|
+
const faqAccordionOnLinkClick = ({
|
|
93
|
+
pageId,
|
|
94
|
+
questionId,
|
|
95
|
+
question,
|
|
96
|
+
linkContent,
|
|
97
|
+
}: FaqAccordionOnLinkClickFactoryProps) => {
|
|
98
|
+
const actionEvent = `Push «${linkContent}» in FAQ ${question}`;
|
|
99
|
+
// Make event like `<project_name>_faq_<page_id>_<question_id>_<link_content>`
|
|
100
|
+
// The `link_content` may be with ' ' - space
|
|
101
|
+
const nameEvent =
|
|
102
|
+
`eth_widget_faq_${pageId}_${questionId}_${linkContent}`.replace(' ', '_');
|
|
103
|
+
trackEvent('Project_Name', actionEvent, nameEvent);
|
|
119
104
|
};
|
|
120
105
|
|
|
121
|
-
|
|
106
|
+
// See above...
|
|
107
|
+
const IndexPage: FC<ExampleProps> = ({ pageFAQ }) => (
|
|
108
|
+
<FaqAccordion
|
|
109
|
+
faqList={pageFAQ.faq}
|
|
110
|
+
onLinkClick={(props) => {
|
|
111
|
+
faqAccordionOnLinkClick({
|
|
112
|
+
pageId: pageFAQ.pageIdentification,
|
|
113
|
+
...props,
|
|
114
|
+
});
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
// See above...
|
|
122
119
|
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
var $kYlmR$reactjsxruntime = require("react/jsx-runtime");
|
|
2
|
+
require("react");
|
|
3
|
+
var $kYlmR$reactmarkdown = require("react-markdown");
|
|
4
|
+
var $kYlmR$lidofinancenextuiprimitives = require("@lidofinance/next-ui-primitives");
|
|
5
|
+
var $kYlmR$lidofinancelidoui = require("@lidofinance/lido-ui");
|
|
6
|
+
var $kYlmR$unified = require("unified");
|
|
7
|
+
var $kYlmR$remarkparse = require("remark-parse");
|
|
8
|
+
var $kYlmR$remarkstringify = require("remark-stringify");
|
|
9
|
+
var $kYlmR$remarkfrontmatter = require("remark-frontmatter");
|
|
10
|
+
var $kYlmR$remarkdirective = require("remark-directive");
|
|
11
|
+
var $kYlmR$jsyaml = require("js-yaml");
|
|
12
|
+
var $kYlmR$styledcomponents = require("styled-components");
|
|
13
|
+
|
|
14
|
+
function $parcel$exportWildcard(dest, source) {
|
|
15
|
+
Object.keys(source).forEach(function(key) {
|
|
16
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Object.defineProperty(dest, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return source[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return dest;
|
|
29
|
+
}
|
|
30
|
+
function $parcel$interopDefault(a) {
|
|
31
|
+
return a && a.__esModule ? a.default : a;
|
|
32
|
+
}
|
|
33
|
+
function $parcel$export(e, n, v, s) {
|
|
34
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
35
|
+
}
|
|
36
|
+
var $f7b7c1c67ffcdf17$exports = {};
|
|
37
|
+
var $a881501f027f3670$exports = {};
|
|
38
|
+
var $ef3e036bc155ea2a$exports = {};
|
|
39
|
+
|
|
40
|
+
$parcel$export($ef3e036bc155ea2a$exports, "FaqAccordion", function () { return $ef3e036bc155ea2a$export$821fcbaf011feac1; });
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var $ede1995d728b96db$exports = {};
|
|
47
|
+
var $2bee130dc59dcfdf$exports = {};
|
|
48
|
+
|
|
49
|
+
$parcel$export($2bee130dc59dcfdf$exports, "isPageFAQ", function () { return $2bee130dc59dcfdf$export$5c49e5abe2bae48e; });
|
|
50
|
+
$parcel$export($2bee130dc59dcfdf$exports, "parseYamlFileWithMdContent", function () { return $2bee130dc59dcfdf$export$dd386c14013925ba; });
|
|
51
|
+
$parcel$export($2bee130dc59dcfdf$exports, "parseFAQ", function () { return $2bee130dc59dcfdf$export$e5978f0aa7bca26d; });
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var $b20fab9f6843ccb5$exports = {};
|
|
58
|
+
var $0eb3a7b79d4adb59$exports = {};
|
|
59
|
+
|
|
60
|
+
$parcel$export($0eb3a7b79d4adb59$exports, "getFrontmatter", function () { return $0eb3a7b79d4adb59$export$6e7a2400c9873c8e; });
|
|
61
|
+
|
|
62
|
+
const $0eb3a7b79d4adb59$export$6e7a2400c9873c8e = ()=>(tree, file)=>{
|
|
63
|
+
const node = tree.children[0];
|
|
64
|
+
if (node?.type === "yaml") {
|
|
65
|
+
const data = (0, ($parcel$interopDefault($kYlmR$jsyaml))).load(node.value);
|
|
66
|
+
file.data.frontmatter = data;
|
|
67
|
+
tree.children.splice(0, 1);
|
|
68
|
+
} else file.data.frontmatter = {};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
var $db842ad7982003fc$exports = {};
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
$parcel$exportWildcard($b20fab9f6843ccb5$exports, $0eb3a7b79d4adb59$exports);
|
|
76
|
+
$parcel$exportWildcard($b20fab9f6843ccb5$exports, $db842ad7982003fc$exports);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const $2bee130dc59dcfdf$export$5c49e5abe2bae48e = (obj)=>{
|
|
80
|
+
return "pageIdentification" in obj && "faq" in obj;
|
|
81
|
+
};
|
|
82
|
+
const $2bee130dc59dcfdf$export$dd386c14013925ba = async (md, remarkPlugins)=>{
|
|
83
|
+
const file = await (0, $kYlmR$unified.unified)().use((0, ($parcel$interopDefault($kYlmR$remarkparse)))).use((0, ($parcel$interopDefault($kYlmR$remarkstringify)))).use(remarkPlugins || []).process(md);
|
|
84
|
+
return {
|
|
85
|
+
content: String(file),
|
|
86
|
+
data: file.data
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const $2bee130dc59dcfdf$export$e5978f0aa7bca26d = async (rawFaqData)=>{
|
|
90
|
+
// Temporary solution
|
|
91
|
+
// The CMS, while generating md, adds an '\_' between the text and
|
|
92
|
+
// the link, which is then replaced by 'nbsp;' (non-breaking space)
|
|
93
|
+
// and interferes correct content display
|
|
94
|
+
// To fix this, we replace '\_' with ' '
|
|
95
|
+
const fixedFileContent = rawFaqData.replace(/\\_\[/gm, " [").replace(/\)\\_/gm, ") ");
|
|
96
|
+
const { data: data } = await $2bee130dc59dcfdf$export$dd386c14013925ba(fixedFileContent, [
|
|
97
|
+
(0, ($parcel$interopDefault($kYlmR$remarkdirective))),
|
|
98
|
+
[
|
|
99
|
+
(0, ($parcel$interopDefault($kYlmR$remarkfrontmatter))),
|
|
100
|
+
[
|
|
101
|
+
"yaml"
|
|
102
|
+
]
|
|
103
|
+
],
|
|
104
|
+
(0, $0eb3a7b79d4adb59$export$6e7a2400c9873c8e)
|
|
105
|
+
]);
|
|
106
|
+
return data?.frontmatter ?? null;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
var $3a3234fbb7a8ecd0$exports = {};
|
|
112
|
+
|
|
113
|
+
$parcel$export($3a3234fbb7a8ecd0$exports, "reactToText", function () { return $3a3234fbb7a8ecd0$export$2aa32c726a36291a; });
|
|
114
|
+
const $3a3234fbb7a8ecd0$export$2aa32c726a36291a = (node)=>{
|
|
115
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") return node.toString();
|
|
116
|
+
if (!node) return "";
|
|
117
|
+
if (Array.isArray(node)) return node.map((entry)=>$3a3234fbb7a8ecd0$export$2aa32c726a36291a(entry)).join("");
|
|
118
|
+
// Because ReactNode includes {} in its union we need to jump through a few hoops
|
|
119
|
+
const props = node.props ? node.props : {};
|
|
120
|
+
if (!props || !props.children) return "";
|
|
121
|
+
return $3a3234fbb7a8ecd0$export$2aa32c726a36291a(props.children);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
$parcel$exportWildcard($ede1995d728b96db$exports, $2bee130dc59dcfdf$exports);
|
|
126
|
+
$parcel$exportWildcard($ede1995d728b96db$exports, $b20fab9f6843ccb5$exports);
|
|
127
|
+
$parcel$exportWildcard($ede1995d728b96db$exports, $3a3234fbb7a8ecd0$exports);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
var $575e329a1ea0a66a$exports = {};
|
|
131
|
+
|
|
132
|
+
$parcel$export($575e329a1ea0a66a$exports, "FaqItem", function () { return $575e329a1ea0a66a$export$eb463a824a473e05; });
|
|
133
|
+
// Styled Components v5 has issues with ESM modules:
|
|
134
|
+
// https://github.com/styled-components/styled-components/issues/115
|
|
135
|
+
// https://github.com/rollup/rollup/issues/4438
|
|
136
|
+
// It can be solved by using Styled Components v6, which is in beta ATM
|
|
137
|
+
// But it will be better to stop using styled-components at all.
|
|
138
|
+
// This is a temporary workaround, which seems to work well.
|
|
139
|
+
|
|
140
|
+
// @ts-expect-error Property 'default' does not exist on type 'StyledInterface'.
|
|
141
|
+
const $5d648c97ee518736$var$styled = (0, ($parcel$interopDefault($kYlmR$styledcomponents))).default || (0, ($parcel$interopDefault($kYlmR$styledcomponents)));
|
|
142
|
+
var $5d648c97ee518736$export$2e2bcd8739ae039 = $5d648c97ee518736$var$styled;
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const $575e329a1ea0a66a$export$eb463a824a473e05 = (0, $5d648c97ee518736$export$2e2bcd8739ae039).div`
|
|
146
|
+
p {
|
|
147
|
+
margin: 0 0 1.6em;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:is(p, ul) + p,
|
|
151
|
+
p + :is(ul, ol) {
|
|
152
|
+
margin-top: -1.6em;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:is(ul, ol) > li {
|
|
156
|
+
margin-top: 0;
|
|
157
|
+
margin-bottom: 0;
|
|
158
|
+
|
|
159
|
+
& > p {
|
|
160
|
+
margin-top: 0;
|
|
161
|
+
margin-bottom: 0;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
a {
|
|
166
|
+
text-decoration: none;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
const $ef3e036bc155ea2a$export$821fcbaf011feac1 = ({ faqList: faqList, onLinkClick: onLinkClick, onQuestionOpenOrClose: onQuestionOpenOrClose })=>{
|
|
172
|
+
if (!faqList) return null;
|
|
173
|
+
return /*#__PURE__*/ (0, $kYlmR$reactjsxruntime.jsx)((0, $kYlmR$reactjsxruntime.Fragment), {
|
|
174
|
+
children: faqList?.map(({ questionId: questionId, question: question, answer: answer }, index)=>/*#__PURE__*/ (0, $kYlmR$reactjsxruntime.jsx)((0, $kYlmR$lidofinancelidoui.Accordion), {
|
|
175
|
+
defaultExpanded: index === 0,
|
|
176
|
+
summary: String(question),
|
|
177
|
+
onClick: ()=>{
|
|
178
|
+
onQuestionOpenOrClose?.({
|
|
179
|
+
questionId: questionId,
|
|
180
|
+
question: question,
|
|
181
|
+
answer: answer,
|
|
182
|
+
accordionIndex: index
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
children: /*#__PURE__*/ (0, $kYlmR$reactjsxruntime.jsx)((0, $575e329a1ea0a66a$export$eb463a824a473e05), {
|
|
186
|
+
children: /*#__PURE__*/ (0, $kYlmR$reactjsxruntime.jsx)((0, ($parcel$interopDefault($kYlmR$reactmarkdown))), {
|
|
187
|
+
components: {
|
|
188
|
+
a: ({ children: children, href: href, ...rest })=>{
|
|
189
|
+
const linkContent = (0, $3a3234fbb7a8ecd0$export$2aa32c726a36291a)(children);
|
|
190
|
+
return /*#__PURE__*/ (0, $kYlmR$reactjsxruntime.jsx)((0, $kYlmR$lidofinancenextuiprimitives.LidoLink), {
|
|
191
|
+
...rest,
|
|
192
|
+
href: href ?? "#",
|
|
193
|
+
onClick: ()=>{
|
|
194
|
+
onLinkClick?.({
|
|
195
|
+
questionId: questionId,
|
|
196
|
+
question: question,
|
|
197
|
+
answer: answer,
|
|
198
|
+
accordionIndex: index,
|
|
199
|
+
linkContent: linkContent,
|
|
200
|
+
linkHref: href
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
children: linkContent
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
children: answer
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
}, question))
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
var $b8f9c2a69e2ee636$exports = {};
|
|
217
|
+
|
|
218
|
+
$parcel$export($b8f9c2a69e2ee636$exports, "isFAQItem", function () { return $b8f9c2a69e2ee636$export$cfc7e514f00a6e18; });
|
|
219
|
+
$parcel$export($b8f9c2a69e2ee636$exports, "isFAQAccordionProps", function () { return $b8f9c2a69e2ee636$export$e9472c8e1e3c866b; });
|
|
220
|
+
const $b8f9c2a69e2ee636$export$cfc7e514f00a6e18 = (obj)=>{
|
|
221
|
+
return "answer" in obj && "question" in obj;
|
|
222
|
+
};
|
|
223
|
+
const $b8f9c2a69e2ee636$export$e9472c8e1e3c866b = (obj)=>{
|
|
224
|
+
return Array.isArray(obj.faqList);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
$parcel$exportWildcard($a881501f027f3670$exports, $ef3e036bc155ea2a$exports);
|
|
229
|
+
$parcel$exportWildcard($a881501f027f3670$exports, $575e329a1ea0a66a$exports);
|
|
230
|
+
$parcel$exportWildcard($a881501f027f3670$exports, $b8f9c2a69e2ee636$exports);
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
$parcel$exportWildcard($f7b7c1c67ffcdf17$exports, $a881501f027f3670$exports);
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
$parcel$exportWildcard(module.exports, $f7b7c1c67ffcdf17$exports);
|
|
238
|
+
$parcel$exportWildcard(module.exports, $ede1995d728b96db$exports);
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AOKO,MAAM,4CAAiB,IAAM,CAAC,MAAY;QAC/C,MAAM,OAAO,KAAK,QAAQ,CAAC,EAAE;QAE7B,IAAI,MAAM,SAAS,QAAQ;YACzB,MAAM,OAAO,CAAA,GAAA,uCAAG,EAAE,KAAK,KAAK;YAC5B,KAAK,KAAK,cAAc;YACxB,KAAK,SAAS,OAAO,GAAG;QAC1B,OACE,KAAK,KAAK,cAAc,CAAC;IAE7B;;;;;;;;;;AFJO,MAAM,4CAAY,CAAC;IACxB,OAAO,wBAAwB,OAAO,SAAS;AACjD;AAEO,MAAM,4CAA6B,OACxC,IACA;IAEA,MAAM,OAAO,MAAM,CAAA,GAAA,sBAAM,IACtB,IAAI,CAAA,GAAA,4CAAU,GACd,IAAI,CAAA,GAAA,gDAAc,GAClB,IAAI,iBAAiB,EAAE,EACvB,QAAQ;IAEX,OAAO;QAAE,SAAS,OAAO;QAAO,MAAM,KAAK;IAAK;AAClD;AAEO,MAAM,4CAAW,OAAO;IAC7B,qBAAqB;IACrB,kEAAkE;IAClE,mEAAmE;IACnE,yCAAyC;IACzC,wCAAwC;IACxC,MAAM,mBAAmB,WAAW,QAAQ,WAAW,MAAM,QAAQ,WAAW;IAEhF,MAAM,QAAE,IAAI,EAAE,GAAG,MAAM,0CAA2B,kBAAkB;QAClE,CAAA,GAAA,gDAAc;QACd;YAAC,CAAA,GAAA,kDAAgB;YAAG;gBAAC;aAAO;SAAC;QAC7B,CAAA,GAAA,yCAAa;KACd;IACD,OAAO,MAAM,e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U,EAAE;gCAEhC,qBACE,gCAAC,CAAA,GAAA,2CAAO;oCACL,GAAG,IAAI;oCACR,MAAM,QAAQ;oCACd,SAAS;wCACP,cAAc;wDACZ;sDACA;oDACA;4CACA,gBAAgB;yDAChB;4CACA,UAAU;wCACZ;oCACF;8CAEC;;4BAGP;wBACF;kCAEC;;;eAvCA;;AA8Cf;;;;;;;;ASvCO,MAAM,4CAAY,CAAC;IACxB,OAAO,YAAY,OAAO,cAAc;AAC1C;AAEO,MAAM,4CAAsB,CAAC;IAClC,OAAO,MAAM,QAAQ,IAAI;AAC3B;;","sources":["packages/ui/faq/src/index.ts","packages/ui/faq/src/components/index.ts","packages/ui/faq/src/components/faqAccordion/index.tsx","packages/ui/faq/src/components/faqAccordion/faqAccordion.tsx","packages/ui/faq/src/utils/index.ts","packages/ui/faq/src/utils/parse.ts","packages/ui/faq/src/utils/remarkPlugins/index.ts","packages/ui/faq/src/utils/remarkPlugins/getFrontmatter.ts","packages/ui/faq/src/utils/remarkPlugins/type.ts","packages/ui/faq/src/utils/react-to-text.ts","packages/ui/faq/src/components/faqAccordion/styles.tsx","packages/ui/faq/styledComponentsWrapper.ts","packages/ui/faq/src/components/faqAccordion/types.ts"],"sourcesContent":["export * from './components'\nexport * from './utils'\n","export * from './faqAccordion'\n","export * from './faqAccordion'\nexport * from './styles'\nexport * from './types'\n","import React, { FC } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport { LidoLink } from '@lidofinance/next-ui-primitives'\nimport { Accordion } from '@lidofinance/lido-ui'\n\nimport { reactToText } from '../../utils'\n\nimport { FAQAccordionProps } from './types'\nimport { FaqItem } from './styles'\n\nexport const FaqAccordion: FC<FAQAccordionProps> = ({ faqList, onLinkClick, onQuestionOpenOrClose }) => {\n if (!faqList) return null\n\n return (\n <>\n {faqList?.map(({ questionId, question, answer }, index) => (\n <Accordion\n key={question}\n defaultExpanded={index === 0}\n summary={String(question)}\n onClick={() => {\n onQuestionOpenOrClose?.({\n questionId,\n question,\n answer,\n accordionIndex: index,\n })\n }}\n >\n <FaqItem>\n <ReactMarkdown\n components={{\n a: ({ children, href, ...rest }) => {\n const linkContent = reactToText(children)\n\n return (\n <LidoLink\n {...rest}\n href={href ?? '#'}\n onClick={() => {\n onLinkClick?.({\n questionId,\n question,\n answer,\n accordionIndex: index,\n linkContent,\n linkHref: href,\n })\n }}\n >\n {linkContent}\n </LidoLink>\n )\n },\n }}\n >\n {answer}\n </ReactMarkdown>\n </FaqItem>\n </Accordion>\n ))}\n </>\n )\n}\n","export * from './parse'\nexport * from './remarkPlugins'\nexport * from './react-to-text'\n","import { unified, PluggableList } from 'unified'\nimport remarkParse from 'remark-parse'\nimport remarkStringify from 'remark-stringify'\nimport remarkFrontmatter from 'remark-frontmatter'\nimport remarkDirective from 'remark-directive'\n\nimport { FAQItem } from '../components'\nimport { getFrontmatter } from './remarkPlugins'\n\nexport type PageFAQ = { pageIdentification: string; faq: FAQItem[] }\n\nexport const isPageFAQ = (obj: PageFAQ): obj is PageFAQ => {\n return 'pageIdentification' in obj && 'faq' in obj\n}\n\nexport const parseYamlFileWithMdContent = async (\n md: string,\n remarkPlugins?: PluggableList,\n): Promise<{ content: string; data: Record<string, any> }> => {\n const file = await unified()\n .use(remarkParse)\n .use(remarkStringify)\n .use(remarkPlugins || [])\n .process(md)\n\n return { content: String(file), data: file.data }\n}\n\nexport const parseFAQ = async (rawFaqData: string): Promise<PageFAQ | null> => {\n // Temporary solution\n // The CMS, while generating md, adds an '\\_' between the text and\n // the link, which is then replaced by 'nbsp;' (non-breaking space)\n // and interferes correct content display\n // To fix this, we replace '\\_' with ' '\n const fixedFileContent = rawFaqData.replace(/\\\\_\\[/gm, ' [').replace(/\\)\\\\_/gm, ') ')\n\n const { data } = await parseYamlFileWithMdContent(fixedFileContent, [\n remarkDirective,\n [remarkFrontmatter, ['yaml']],\n getFrontmatter,\n ])\n return data?.frontmatter ?? null\n}\n","export * from './getFrontmatter'\nexport * from './type'\n","import yaml from 'js-yaml'\n\nimport { Tree, VFileWithOutput } from './type'\n\n// eslint-disable-next-line unicorn/consistent-function-scoping\nexport const getFrontmatter = () => (tree: Tree, file: VFileWithOutput<null>) => {\n const node = tree.children[0]\n\n if (node?.type === 'yaml') {\n const data = yaml.load(node.value)\n file.data.frontmatter = data\n tree.children.splice(0, 1)\n } else {\n file.data.frontmatter = {}\n }\n}\n","import { Root, Parent, Content } from 'mdast'\nimport { VFileWithOutput } from 'unified'\n\nexport type Tree = Root\n\nexport type Node = Parent\n\nexport type { Content, VFileWithOutput }\n","import React from 'react'\n\nexport const reactToText = (node: React.ReactNode | object): string => {\n if (typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean') {\n return node.toString()\n }\n\n if (!node) {\n return ''\n }\n\n if (Array.isArray(node)) {\n return node.map((entry) => reactToText(entry)).join('')\n }\n\n // Because ReactNode includes {} in its union we need to jump through a few hoops\n const props: { children?: React.ReactNode } = (node as any).props ? (node as any).props : {}\n\n if (!props || !props.children) {\n return ''\n }\n\n return reactToText(props.children)\n}\n","import styled from '../../../styledComponentsWrapper'\n\nexport const FaqItem = styled.div`\n p {\n margin: 0 0 1.6em;\n }\n\n :is(p, ul) + p,\n p + :is(ul, ol) {\n margin-top: -1.6em;\n }\n\n :is(ul, ol) > li {\n margin-top: 0;\n margin-bottom: 0;\n\n & > p {\n margin-top: 0;\n margin-bottom: 0;\n }\n }\n\n a {\n text-decoration: none;\n }\n`\n","// Styled Components v5 has issues with ESM modules:\n// https://github.com/styled-components/styled-components/issues/115\n// https://github.com/rollup/rollup/issues/4438\n// It can be solved by using Styled Components v6, which is in beta ATM\n// But it will be better to stop using styled-components at all.\n// This is a temporary workaround, which seems to work well.\n\nimport _styled, { StyledInterface } from 'styled-components'\n\n// @ts-expect-error Property 'default' does not exist on type 'StyledInterface'.\nconst styled: StyledInterface = _styled.default || _styled\n\nexport * from 'styled-components'\nexport default styled\n","export type FAQItem = {\n answer: string\n question: string\n questionId: string\n}\n\nexport type FAQAccordionOnActionProps = {\n questionId: string\n question: string\n answer: string\n accordionIndex: number\n}\n\nexport type FAQAccordionOnLinkClickProps = FAQAccordionOnActionProps & {\n linkContent: string\n linkHref?: string | undefined\n}\n\nexport type FAQAccordionProps = {\n faqList?: FAQItem[] | undefined\n onLinkClick?: (props: FAQAccordionOnLinkClickProps) => void | undefined\n onQuestionOpenOrClose?: (props: FAQAccordionOnActionProps) => void | undefined\n}\n\nexport const isFAQItem = (obj: FAQItem): obj is FAQItem => {\n return 'answer' in obj && 'question' in obj\n}\n\nexport const isFAQAccordionProps = (obj: any): obj is FAQAccordionProps => {\n return Array.isArray(obj.faqList)\n}\n"],"names":[],"version":3,"file":"index.cjs.map"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { Root, Parent, Content } from "mdast";
|
|
2
|
+
import { VFileWithOutput, PluggableList } from "unified";
|
|
3
|
+
import React, { FC } from "react";
|
|
4
|
+
export type Tree = Root;
|
|
5
|
+
export type Node = Parent;
|
|
6
|
+
export { Content, VFileWithOutput };
|
|
7
|
+
export const getFrontmatter: () => (tree: Tree, file: VFileWithOutput<null>) => void;
|
|
8
|
+
export type PageFAQ = {
|
|
9
|
+
pageIdentification: string;
|
|
10
|
+
faq: FAQItem[];
|
|
11
|
+
};
|
|
12
|
+
export const isPageFAQ: (obj: PageFAQ) => obj is PageFAQ;
|
|
13
|
+
export const parseYamlFileWithMdContent: (md: string, remarkPlugins?: PluggableList) => Promise<{
|
|
14
|
+
content: string;
|
|
15
|
+
data: Record<string, any>;
|
|
16
|
+
}>;
|
|
17
|
+
export const parseFAQ: (rawFaqData: string) => Promise<PageFAQ | null>;
|
|
18
|
+
export const reactToText: (node: React.ReactNode | object) => string;
|
|
5
19
|
export type FAQItem = {
|
|
6
20
|
answer: string;
|
|
7
21
|
question: string;
|
|
@@ -27,20 +41,5 @@ export const isFAQAccordionProps: (obj: any) => obj is FAQAccordionProps;
|
|
|
27
41
|
export * from 'styled-components';
|
|
28
42
|
export const FaqItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
29
43
|
export const FaqAccordion: FC<FAQAccordionProps>;
|
|
30
|
-
export const parseYamlFileWithMdContent: (md: string, remarkPlugins?: PluggableList) => Promise<{
|
|
31
|
-
content: string;
|
|
32
|
-
data: Record<string, any>;
|
|
33
|
-
}>;
|
|
34
|
-
export type PageFAQ = {
|
|
35
|
-
identification: string;
|
|
36
|
-
faq: FAQItem[];
|
|
37
|
-
};
|
|
38
|
-
export const isPageFAQ: (obj: PageFAQ) => obj is PageFAQ;
|
|
39
|
-
export type GetFaqOptionsProps = {
|
|
40
|
-
axiosInstance: Axios;
|
|
41
|
-
cache?: boolean;
|
|
42
|
-
memoryCacheConfig?: MemoryConfig | undefined;
|
|
43
|
-
};
|
|
44
|
-
export const getFAQ: (faqUrl: string, { axiosInstance, cache, memoryCacheConfig }?: GetFaqOptionsProps) => Promise<PageFAQ[]>;
|
|
45
44
|
|
|
46
45
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;AAGA,mBAAmB,IAAI,CAAA;AAEvB,mBAAmB,MAAM,CAAA;AAEzB,OAAY,EAAE,OAAO,EAAE,eAAe,EAAE,CAAA;ACFxC,OAAO,MAAM,6BAA8B,IAAI,QAAQ,gBAAgB,IAAI,CAAC,SAU3E,CAAA;AEND,sBAAsB;IAAE,kBAAkB,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,EAAE,CAAA;CAAE,CAAA;AAEpE,OAAO,MAAM,iBAAkB,OAAO,mBAErC,CAAA;AAED,OAAO,MAAM,iCACP,MAAM,kBACM,aAAa,KAC5B,QAAQ;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,CAQxD,CAAA;AAED,OAAO,MAAM,uBAA8B,MAAM,KAAG,QAAQ,OAAO,GAAG,IAAI,CAczE,CAAA;ACxCD,OAAO,MAAM,oBAAqB,MAAM,SAAS,GAAG,MAAM,KAAG,MAqB5D,CAAA;AEvBD,sBAAsB;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wCAAwC;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,2CAA2C,yBAAyB,GAAG;IACrE,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED,gCAAgC;IAC9B,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,IAAI,GAAG,SAAS,CAAA;IACvE,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,GAAG,SAAS,CAAA;CAC/E,CAAA;AAED,OAAO,MAAM,iBAAkB,OAAO,mBAErC,CAAA;AAED,OAAO,MAAM,2BAA4B,GAAG,6BAE3C,CAAA;AClBD,cAAc,mBAAmB,CAAA;ACVjC,OAAO,MAAM,gHAuBZ,CAAA;ACfD,OAAO,MAAM,cAAc,GAAG,iBAAiB,CAqD9C,CAAA","sources":["packages/ui/faq/src/src/utils/remarkPlugins/type.ts","packages/ui/faq/src/src/utils/remarkPlugins/getFrontmatter.ts","packages/ui/faq/src/src/utils/remarkPlugins/index.ts","packages/ui/faq/src/src/utils/parse.ts","packages/ui/faq/src/src/utils/react-to-text.ts","packages/ui/faq/src/src/utils/index.ts","packages/ui/faq/src/src/components/faqAccordion/types.ts","packages/ui/faq/src/styledComponentsWrapper.ts","packages/ui/faq/src/src/components/faqAccordion/styles.tsx","packages/ui/faq/src/src/components/faqAccordion/faqAccordion.tsx","packages/ui/faq/src/src/components/faqAccordion/index.tsx","packages/ui/faq/src/src/components/index.ts","packages/ui/faq/src/src/index.ts","packages/ui/faq/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,"export * from './components'\nexport * from './utils'\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import {jsx as $loPuo$jsx, Fragment as $loPuo$Fragment} from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import $loPuo$reactmarkdown from "react-markdown";
|
|
4
|
-
import $loPuo$reacttotext from "react-to-text";
|
|
5
4
|
import {LidoLink as $loPuo$LidoLink} from "@lidofinance/next-ui-primitives";
|
|
6
|
-
import
|
|
7
|
-
import $loPuo$styledcomponents from "styled-components";
|
|
8
|
-
import $loPuo$axios from "axios";
|
|
9
|
-
import {caching as $loPuo$caching} from "cache-manager";
|
|
5
|
+
import {Accordion as $loPuo$Accordion} from "@lidofinance/lido-ui";
|
|
10
6
|
import {unified as $loPuo$unified} from "unified";
|
|
11
7
|
import $loPuo$remarkparse from "remark-parse";
|
|
12
8
|
import $loPuo$remarkstringify from "remark-stringify";
|
|
13
9
|
import $loPuo$remarkfrontmatter from "remark-frontmatter";
|
|
14
10
|
import $loPuo$remarkdirective from "remark-directive";
|
|
15
11
|
import $loPuo$jsyaml from "js-yaml";
|
|
12
|
+
import $loPuo$styledcomponents from "styled-components";
|
|
16
13
|
|
|
17
14
|
function $parcel$exportWildcard(dest, source) {
|
|
18
15
|
Object.keys(source).forEach(function(key) {
|
|
@@ -43,6 +40,89 @@ $parcel$export($17df517d232bb386$exports, "FaqAccordion", function () { return $
|
|
|
43
40
|
|
|
44
41
|
|
|
45
42
|
|
|
43
|
+
var $4d7a07a404732d40$exports = {};
|
|
44
|
+
var $e7fcb4b1f2b4d678$exports = {};
|
|
45
|
+
|
|
46
|
+
$parcel$export($e7fcb4b1f2b4d678$exports, "isPageFAQ", function () { return $e7fcb4b1f2b4d678$export$5c49e5abe2bae48e; });
|
|
47
|
+
$parcel$export($e7fcb4b1f2b4d678$exports, "parseYamlFileWithMdContent", function () { return $e7fcb4b1f2b4d678$export$dd386c14013925ba; });
|
|
48
|
+
$parcel$export($e7fcb4b1f2b4d678$exports, "parseFAQ", function () { return $e7fcb4b1f2b4d678$export$e5978f0aa7bca26d; });
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
var $49d80f346be91bc9$exports = {};
|
|
55
|
+
var $9f620ec94f086a5a$exports = {};
|
|
56
|
+
|
|
57
|
+
$parcel$export($9f620ec94f086a5a$exports, "getFrontmatter", function () { return $9f620ec94f086a5a$export$6e7a2400c9873c8e; });
|
|
58
|
+
|
|
59
|
+
const $9f620ec94f086a5a$export$6e7a2400c9873c8e = ()=>(tree, file)=>{
|
|
60
|
+
const node = tree.children[0];
|
|
61
|
+
if (node?.type === "yaml") {
|
|
62
|
+
const data = (0, $loPuo$jsyaml).load(node.value);
|
|
63
|
+
file.data.frontmatter = data;
|
|
64
|
+
tree.children.splice(0, 1);
|
|
65
|
+
} else file.data.frontmatter = {};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
var $10bb8ab2e7ba83c1$exports = {};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
$parcel$exportWildcard($49d80f346be91bc9$exports, $9f620ec94f086a5a$exports);
|
|
73
|
+
$parcel$exportWildcard($49d80f346be91bc9$exports, $10bb8ab2e7ba83c1$exports);
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const $e7fcb4b1f2b4d678$export$5c49e5abe2bae48e = (obj)=>{
|
|
77
|
+
return "pageIdentification" in obj && "faq" in obj;
|
|
78
|
+
};
|
|
79
|
+
const $e7fcb4b1f2b4d678$export$dd386c14013925ba = async (md, remarkPlugins)=>{
|
|
80
|
+
const file = await (0, $loPuo$unified)().use((0, $loPuo$remarkparse)).use((0, $loPuo$remarkstringify)).use(remarkPlugins || []).process(md);
|
|
81
|
+
return {
|
|
82
|
+
content: String(file),
|
|
83
|
+
data: file.data
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const $e7fcb4b1f2b4d678$export$e5978f0aa7bca26d = async (rawFaqData)=>{
|
|
87
|
+
// Temporary solution
|
|
88
|
+
// The CMS, while generating md, adds an '\_' between the text and
|
|
89
|
+
// the link, which is then replaced by 'nbsp;' (non-breaking space)
|
|
90
|
+
// and interferes correct content display
|
|
91
|
+
// To fix this, we replace '\_' with ' '
|
|
92
|
+
const fixedFileContent = rawFaqData.replace(/\\_\[/gm, " [").replace(/\)\\_/gm, ") ");
|
|
93
|
+
const { data: data } = await $e7fcb4b1f2b4d678$export$dd386c14013925ba(fixedFileContent, [
|
|
94
|
+
(0, $loPuo$remarkdirective),
|
|
95
|
+
[
|
|
96
|
+
(0, $loPuo$remarkfrontmatter),
|
|
97
|
+
[
|
|
98
|
+
"yaml"
|
|
99
|
+
]
|
|
100
|
+
],
|
|
101
|
+
(0, $9f620ec94f086a5a$export$6e7a2400c9873c8e)
|
|
102
|
+
]);
|
|
103
|
+
return data?.frontmatter ?? null;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
var $b58c0ffda2d4a943$exports = {};
|
|
109
|
+
|
|
110
|
+
$parcel$export($b58c0ffda2d4a943$exports, "reactToText", function () { return $b58c0ffda2d4a943$export$2aa32c726a36291a; });
|
|
111
|
+
const $b58c0ffda2d4a943$export$2aa32c726a36291a = (node)=>{
|
|
112
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") return node.toString();
|
|
113
|
+
if (!node) return "";
|
|
114
|
+
if (Array.isArray(node)) return node.map((entry)=>$b58c0ffda2d4a943$export$2aa32c726a36291a(entry)).join("");
|
|
115
|
+
// Because ReactNode includes {} in its union we need to jump through a few hoops
|
|
116
|
+
const props = node.props ? node.props : {};
|
|
117
|
+
if (!props || !props.children) return "";
|
|
118
|
+
return $b58c0ffda2d4a943$export$2aa32c726a36291a(props.children);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
$parcel$exportWildcard($4d7a07a404732d40$exports, $e7fcb4b1f2b4d678$exports);
|
|
123
|
+
$parcel$exportWildcard($4d7a07a404732d40$exports, $49d80f346be91bc9$exports);
|
|
124
|
+
$parcel$exportWildcard($4d7a07a404732d40$exports, $b58c0ffda2d4a943$exports);
|
|
125
|
+
|
|
46
126
|
|
|
47
127
|
var $b871f2fb17bf3607$exports = {};
|
|
48
128
|
|
|
@@ -85,9 +165,10 @@ const $b871f2fb17bf3607$export$eb463a824a473e05 = (0, $f7fa192b95611bbe$export$2
|
|
|
85
165
|
`;
|
|
86
166
|
|
|
87
167
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
168
|
+
const $17df517d232bb386$export$821fcbaf011feac1 = ({ faqList: faqList, onLinkClick: onLinkClick, onQuestionOpenOrClose: onQuestionOpenOrClose })=>{
|
|
169
|
+
if (!faqList) return null;
|
|
170
|
+
return /*#__PURE__*/ (0, $loPuo$jsx)((0, $loPuo$Fragment), {
|
|
171
|
+
children: faqList?.map(({ questionId: questionId, question: question, answer: answer }, index)=>/*#__PURE__*/ (0, $loPuo$jsx)((0, $loPuo$Accordion), {
|
|
91
172
|
defaultExpanded: index === 0,
|
|
92
173
|
summary: String(question),
|
|
93
174
|
onClick: ()=>{
|
|
@@ -102,7 +183,7 @@ const $17df517d232bb386$export$821fcbaf011feac1 = ({ faqList: faqList, onLinkCli
|
|
|
102
183
|
children: /*#__PURE__*/ (0, $loPuo$jsx)((0, $loPuo$reactmarkdown), {
|
|
103
184
|
components: {
|
|
104
185
|
a: ({ children: children, href: href, ...rest })=>{
|
|
105
|
-
const linkContent = (0, $
|
|
186
|
+
const linkContent = (0, $b58c0ffda2d4a943$export$2aa32c726a36291a)(children);
|
|
106
187
|
return /*#__PURE__*/ (0, $loPuo$jsx)((0, $loPuo$LidoLink), {
|
|
107
188
|
...rest,
|
|
108
189
|
href: href ?? "#",
|
|
@@ -125,6 +206,7 @@ const $17df517d232bb386$export$821fcbaf011feac1 = ({ faqList: faqList, onLinkCli
|
|
|
125
206
|
})
|
|
126
207
|
}, question))
|
|
127
208
|
});
|
|
209
|
+
};
|
|
128
210
|
|
|
129
211
|
|
|
130
212
|
|
|
@@ -148,89 +230,8 @@ $parcel$exportWildcard($49bd0fe341d564cb$exports, $30e3952008c9e88b$exports);
|
|
|
148
230
|
$parcel$exportWildcard($4e053a1b8b64ce9e$exports, $49bd0fe341d564cb$exports);
|
|
149
231
|
|
|
150
232
|
|
|
151
|
-
var $4d7a07a404732d40$exports = {};
|
|
152
|
-
|
|
153
|
-
$parcel$export($4d7a07a404732d40$exports, "parseYamlFileWithMdContent", function () { return $4d7a07a404732d40$export$dd386c14013925ba; });
|
|
154
|
-
$parcel$export($4d7a07a404732d40$exports, "isPageFAQ", function () { return $4d7a07a404732d40$export$5c49e5abe2bae48e; });
|
|
155
|
-
$parcel$export($4d7a07a404732d40$exports, "getFAQ", function () { return $4d7a07a404732d40$export$24d135d299ddf6e6; });
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const $9f620ec94f086a5a$export$6e7a2400c9873c8e = ()=>(tree, file)=>{
|
|
165
|
-
const node = tree.children[0];
|
|
166
|
-
if (node?.type === "yaml") {
|
|
167
|
-
const data = (0, $loPuo$jsyaml).load(node.value);
|
|
168
|
-
file.data.frontmatter = data;
|
|
169
|
-
tree.children.splice(0, 1);
|
|
170
|
-
} else file.data.frontmatter = {};
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const $4d7a07a404732d40$var$ttlMs = 600000 /* 10 minutes */ ;
|
|
179
|
-
const $4d7a07a404732d40$var$memoryCacheConfigDefault = {
|
|
180
|
-
max: 100,
|
|
181
|
-
ttl: $4d7a07a404732d40$var$ttlMs
|
|
182
|
-
};
|
|
183
|
-
let $4d7a07a404732d40$var$memoryCache;
|
|
184
|
-
const $4d7a07a404732d40$var$getMemoryCacheInstance = async (memoryCacheConfig = $4d7a07a404732d40$var$memoryCacheConfigDefault)=>{
|
|
185
|
-
$4d7a07a404732d40$var$memoryCache ??= await (0, $loPuo$caching)("memory", memoryCacheConfig);
|
|
186
|
-
return $4d7a07a404732d40$var$memoryCache;
|
|
187
|
-
};
|
|
188
|
-
const $4d7a07a404732d40$export$dd386c14013925ba = async (md, remarkPlugins)=>{
|
|
189
|
-
const file = await (0, $loPuo$unified)().use((0, $loPuo$remarkparse)).use((0, $loPuo$remarkstringify)).use(remarkPlugins || []).process(md);
|
|
190
|
-
return {
|
|
191
|
-
content: String(file),
|
|
192
|
-
data: file.data
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
const $4d7a07a404732d40$export$5c49e5abe2bae48e = (obj)=>{
|
|
196
|
-
return "identification" in obj && "faq" in obj;
|
|
197
|
-
};
|
|
198
|
-
const $4d7a07a404732d40$var$faqOptionsDefault = {
|
|
199
|
-
axiosInstance: (0, $loPuo$axios),
|
|
200
|
-
cache: true
|
|
201
|
-
};
|
|
202
|
-
const $4d7a07a404732d40$export$24d135d299ddf6e6 = async (faqUrl, { axiosInstance: axiosInstance, cache: cache, memoryCacheConfig: memoryCacheConfig } = $4d7a07a404732d40$var$faqOptionsDefault)=>{
|
|
203
|
-
let memoryCacheInstance;
|
|
204
|
-
let rawFaqData;
|
|
205
|
-
if (cache) {
|
|
206
|
-
memoryCacheInstance = await $4d7a07a404732d40$var$getMemoryCacheInstance(memoryCacheConfig);
|
|
207
|
-
rawFaqData = await memoryCacheInstance.get(faqUrl);
|
|
208
|
-
}
|
|
209
|
-
if (!rawFaqData) {
|
|
210
|
-
rawFaqData = (await axiosInstance.get(faqUrl)).data;
|
|
211
|
-
if (cache && memoryCacheInstance) await memoryCacheInstance.set(faqUrl, rawFaqData, $4d7a07a404732d40$var$ttlMs);
|
|
212
|
-
}
|
|
213
|
-
// Temporary solution
|
|
214
|
-
// The CMS, while generating md, adds an '\_' between the text and
|
|
215
|
-
// the link, which is then replaced by 'nbsp;' (non-breaking space)
|
|
216
|
-
// and interferes correct content display
|
|
217
|
-
// To fix this, we replace '\_' with ' '
|
|
218
|
-
const fixedFileContent = rawFaqData.replace(/\\_\[/gm, " [").replace(/\)\\_/gm, ") ");
|
|
219
|
-
const { data: data } = await $4d7a07a404732d40$export$dd386c14013925ba(fixedFileContent, [
|
|
220
|
-
(0, $loPuo$remarkdirective),
|
|
221
|
-
[
|
|
222
|
-
(0, $loPuo$remarkfrontmatter),
|
|
223
|
-
[
|
|
224
|
-
"yaml"
|
|
225
|
-
]
|
|
226
|
-
],
|
|
227
|
-
(0, $9f620ec94f086a5a$export$6e7a2400c9873c8e)
|
|
228
|
-
]);
|
|
229
|
-
return data?.frontmatter?.pages ?? [];
|
|
230
|
-
};
|
|
231
|
-
|
|
232
233
|
|
|
233
234
|
|
|
234
235
|
|
|
235
|
-
export {$17df517d232bb386$export$821fcbaf011feac1 as FaqAccordion, $b871f2fb17bf3607$export$eb463a824a473e05 as FaqItem, $30e3952008c9e88b$export$cfc7e514f00a6e18 as isFAQItem, $30e3952008c9e88b$export$e9472c8e1e3c866b as isFAQAccordionProps, $
|
|
236
|
-
//# sourceMappingURL=index.
|
|
236
|
+
export {$17df517d232bb386$export$821fcbaf011feac1 as FaqAccordion, $b871f2fb17bf3607$export$eb463a824a473e05 as FaqItem, $30e3952008c9e88b$export$cfc7e514f00a6e18 as isFAQItem, $30e3952008c9e88b$export$e9472c8e1e3c866b as isFAQAccordionProps, $e7fcb4b1f2b4d678$export$5c49e5abe2bae48e as isPageFAQ, $e7fcb4b1f2b4d678$export$dd386c14013925ba as parseYamlFileWithMdContent, $e7fcb4b1f2b4d678$export$e5978f0aa7bca26d as parseFAQ, $9f620ec94f086a5a$export$6e7a2400c9873c8e as getFrontmatter, $b58c0ffda2d4a943$export$2aa32c726a36291a as reactToText};
|
|
237
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AOKO,MAAM,4CAAiB,IAAM,CAAC,MAAY;QAC/C,MAAM,OAAO,KAAK,QAAQ,CAAC,EAAE;QAE7B,IAAI,MAAM,SAAS,QAAQ;YACzB,MAAM,OAAO,CAAA,GAAA,aAAG,EAAE,KAAK,KAAK;YAC5B,KAAK,KAAK,cAAc;YACxB,KAAK,SAAS,OAAO,GAAG;QAC1B,OACE,KAAK,KAAK,cAAc,CAAC;IAE7B;;;;;;;;;;AFJO,MAAM,4CAAY,CAAC;IACxB,OAAO,wBAAwB,OAAO,SAAS;AACjD;AAEO,MAAM,4CAA6B,OACxC,IACA;IAEA,MAAM,OAAO,MAAM,CAAA,GAAA,cAAM,IACtB,IAAI,CAAA,GAAA,kBAAU,GACd,IAAI,CAAA,GAAA,sBAAc,GAClB,IAAI,iBAAiB,EAAE,EACvB,QAAQ;IAEX,OAAO;QAAE,SAAS,OAAO;QAAO,MAAM,KAAK;IAAK;AAClD;AAEO,MAAM,4CAAW,OAAO;IAC7B,qBAAqB;IACrB,kEAAkE;IAClE,mEAAmE;IACnE,yCAAyC;IACzC,wCAAwC;IACxC,MAAM,mBAAmB,WAAW,QAAQ,WAAW,MAAM,QAAQ,WAAW;IAEhF,MAAM,QAAE,IAAI,EAAE,GAAG,MAAM,0CAA2B,kBAAkB;QAClE,CAAA,GAAA,sBAAc;QACd;YAAC,CAAA,GAAA,wBAAgB;YAAG;gBAAC;aAAO;SAAC;QAC7B,CAAA,GAAA,yCAAa;KACd;IACD,OA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GAAA,yCAAU,EAAE;gCAEhC,qBACE,gBAAC,CAAA,GAAA,eAAO;oCACL,GAAG,IAAI;oCACR,MAAM,QAAQ;oCACd,SAAS;wCACP,cAAc;wDACZ;sDACA;oDACA;4CACA,gBAAgB;yDAChB;4CACA,UAAU;wCACZ;oCACF;8CAEC;;4BAGP;wBACF;kCAEC;;;eAvCA;;AA8Cf;;;;;;;;ASvCO,MAAM,4CAAY,CAAC;IACxB,OAAO,YAAY,OAAO,cAAc;AAC1C;AAEO,MAAM,4CAAsB,CAAC;IAClC,OAAO,MAAM,QAAQ,IAAI;AAC3B;;","sources":["packages/ui/faq/src/index.ts","packages/ui/faq/src/components/index.ts","packages/ui/faq/src/components/faqAccordion/index.tsx","packages/ui/faq/src/components/faqAccordion/faqAccordion.tsx","packages/ui/faq/src/utils/index.ts","packages/ui/faq/src/utils/parse.ts","packages/ui/faq/src/utils/remarkPlugins/index.ts","packages/ui/faq/src/utils/remarkPlugins/getFrontmatter.ts","packages/ui/faq/src/utils/remarkPlugins/type.ts","packages/ui/faq/src/utils/react-to-text.ts","packages/ui/faq/src/components/faqAccordion/styles.tsx","packages/ui/faq/styledComponentsWrapper.ts","packages/ui/faq/src/components/faqAccordion/types.ts"],"sourcesContent":["export * from './components'\nexport * from './utils'\n","export * from './faqAccordion'\n","export * from './faqAccordion'\nexport * from './styles'\nexport * from './types'\n","import React, { FC } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport { LidoLink } from '@lidofinance/next-ui-primitives'\nimport { Accordion } from '@lidofinance/lido-ui'\n\nimport { reactToText } from '../../utils'\n\nimport { FAQAccordionProps } from './types'\nimport { FaqItem } from './styles'\n\nexport const FaqAccordion: FC<FAQAccordionProps> = ({ faqList, onLinkClick, onQuestionOpenOrClose }) => {\n if (!faqList) return null\n\n return (\n <>\n {faqList?.map(({ questionId, question, answer }, index) => (\n <Accordion\n key={question}\n defaultExpanded={index === 0}\n summary={String(question)}\n onClick={() => {\n onQuestionOpenOrClose?.({\n questionId,\n question,\n answer,\n accordionIndex: index,\n })\n }}\n >\n <FaqItem>\n <ReactMarkdown\n components={{\n a: ({ children, href, ...rest }) => {\n const linkContent = reactToText(children)\n\n return (\n <LidoLink\n {...rest}\n href={href ?? '#'}\n onClick={() => {\n onLinkClick?.({\n questionId,\n question,\n answer,\n accordionIndex: index,\n linkContent,\n linkHref: href,\n })\n }}\n >\n {linkContent}\n </LidoLink>\n )\n },\n }}\n >\n {answer}\n </ReactMarkdown>\n </FaqItem>\n </Accordion>\n ))}\n </>\n )\n}\n","export * from './parse'\nexport * from './remarkPlugins'\nexport * from './react-to-text'\n","import { unified, PluggableList } from 'unified'\nimport remarkParse from 'remark-parse'\nimport remarkStringify from 'remark-stringify'\nimport remarkFrontmatter from 'remark-frontmatter'\nimport remarkDirective from 'remark-directive'\n\nimport { FAQItem } from '../components'\nimport { getFrontmatter } from './remarkPlugins'\n\nexport type PageFAQ = { pageIdentification: string; faq: FAQItem[] }\n\nexport const isPageFAQ = (obj: PageFAQ): obj is PageFAQ => {\n return 'pageIdentification' in obj && 'faq' in obj\n}\n\nexport const parseYamlFileWithMdContent = async (\n md: string,\n remarkPlugins?: PluggableList,\n): Promise<{ content: string; data: Record<string, any> }> => {\n const file = await unified()\n .use(remarkParse)\n .use(remarkStringify)\n .use(remarkPlugins || [])\n .process(md)\n\n return { content: String(file), data: file.data }\n}\n\nexport const parseFAQ = async (rawFaqData: string): Promise<PageFAQ | null> => {\n // Temporary solution\n // The CMS, while generating md, adds an '\\_' between the text and\n // the link, which is then replaced by 'nbsp;' (non-breaking space)\n // and interferes correct content display\n // To fix this, we replace '\\_' with ' '\n const fixedFileContent = rawFaqData.replace(/\\\\_\\[/gm, ' [').replace(/\\)\\\\_/gm, ') ')\n\n const { data } = await parseYamlFileWithMdContent(fixedFileContent, [\n remarkDirective,\n [remarkFrontmatter, ['yaml']],\n getFrontmatter,\n ])\n return data?.frontmatter ?? null\n}\n","export * from './getFrontmatter'\nexport * from './type'\n","import yaml from 'js-yaml'\n\nimport { Tree, VFileWithOutput } from './type'\n\n// eslint-disable-next-line unicorn/consistent-function-scoping\nexport const getFrontmatter = () => (tree: Tree, file: VFileWithOutput<null>) => {\n const node = tree.children[0]\n\n if (node?.type === 'yaml') {\n const data = yaml.load(node.value)\n file.data.frontmatter = data\n tree.children.splice(0, 1)\n } else {\n file.data.frontmatter = {}\n }\n}\n","import { Root, Parent, Content } from 'mdast'\nimport { VFileWithOutput } from 'unified'\n\nexport type Tree = Root\n\nexport type Node = Parent\n\nexport type { Content, VFileWithOutput }\n","import React from 'react'\n\nexport const reactToText = (node: React.ReactNode | object): string => {\n if (typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean') {\n return node.toString()\n }\n\n if (!node) {\n return ''\n }\n\n if (Array.isArray(node)) {\n return node.map((entry) => reactToText(entry)).join('')\n }\n\n // Because ReactNode includes {} in its union we need to jump through a few hoops\n const props: { children?: React.ReactNode } = (node as any).props ? (node as any).props : {}\n\n if (!props || !props.children) {\n return ''\n }\n\n return reactToText(props.children)\n}\n","import styled from '../../../styledComponentsWrapper'\n\nexport const FaqItem = styled.div`\n p {\n margin: 0 0 1.6em;\n }\n\n :is(p, ul) + p,\n p + :is(ul, ol) {\n margin-top: -1.6em;\n }\n\n :is(ul, ol) > li {\n margin-top: 0;\n margin-bottom: 0;\n\n & > p {\n margin-top: 0;\n margin-bottom: 0;\n }\n }\n\n a {\n text-decoration: none;\n }\n`\n","// Styled Components v5 has issues with ESM modules:\n// https://github.com/styled-components/styled-components/issues/115\n// https://github.com/rollup/rollup/issues/4438\n// It can be solved by using Styled Components v6, which is in beta ATM\n// But it will be better to stop using styled-components at all.\n// This is a temporary workaround, which seems to work well.\n\nimport _styled, { StyledInterface } from 'styled-components'\n\n// @ts-expect-error Property 'default' does not exist on type 'StyledInterface'.\nconst styled: StyledInterface = _styled.default || _styled\n\nexport * from 'styled-components'\nexport default styled\n","export type FAQItem = {\n answer: string\n question: string\n questionId: string\n}\n\nexport type FAQAccordionOnActionProps = {\n questionId: string\n question: string\n answer: string\n accordionIndex: number\n}\n\nexport type FAQAccordionOnLinkClickProps = FAQAccordionOnActionProps & {\n linkContent: string\n linkHref?: string | undefined\n}\n\nexport type FAQAccordionProps = {\n faqList?: FAQItem[] | undefined\n onLinkClick?: (props: FAQAccordionOnLinkClickProps) => void | undefined\n onQuestionOpenOrClose?: (props: FAQAccordionOnActionProps) => void | undefined\n}\n\nexport const isFAQItem = (obj: FAQItem): obj is FAQItem => {\n return 'answer' in obj && 'question' in obj\n}\n\nexport const isFAQAccordionProps = (obj: any): obj is FAQAccordionProps => {\n return Array.isArray(obj.faqList)\n}\n"],"names":[],"version":3,"file":"index.mjs.map"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://github.com/lidofinance/warehouse/issues"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.39.1",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
"node": ">= 16",
|
|
16
16
|
"browsers": "> 0.5%, last 2 versions, not dead"
|
|
17
17
|
},
|
|
18
|
-
"type": "module",
|
|
19
18
|
"source": "./src/index.ts",
|
|
20
|
-
"
|
|
19
|
+
"main": "dist/index.cjs",
|
|
20
|
+
"module": "dist/index.mjs",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"import": "./dist/index.
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
@@ -31,31 +32,26 @@
|
|
|
31
32
|
"types": "tsc --noEmit"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
|
-
"@lidofinance/
|
|
35
|
-
"@lidofinance/next-ui-primitives": "~0.38.0",
|
|
36
|
-
"axios": "^1.5.0",
|
|
37
|
-
"cache-manager": "^5.2.3",
|
|
35
|
+
"@lidofinance/next-ui-primitives": "~0.39.1",
|
|
38
36
|
"react": "17 || 18",
|
|
39
37
|
"styled-components": "^5.3.5"
|
|
40
38
|
},
|
|
41
39
|
"devDependencies": {
|
|
42
|
-
"@lidofinance/config-prettier": "~0.
|
|
43
|
-
"@lidofinance/lido-ui": "
|
|
44
|
-
"@lidofinance/next-ui-primitives": "~0.
|
|
40
|
+
"@lidofinance/config-prettier": "~0.39.1",
|
|
41
|
+
"@lidofinance/lido-ui": "3.14.1",
|
|
42
|
+
"@lidofinance/next-ui-primitives": "~0.39.1",
|
|
45
43
|
"@storybook/react": "^7.0.7",
|
|
46
44
|
"@types/js-yaml": "^4.0.5",
|
|
47
45
|
"@types/mdast": "^3.0.11",
|
|
48
46
|
"@types/react": "^18.0.25",
|
|
49
47
|
"@types/styled-components": "^5.1.26",
|
|
50
|
-
"
|
|
51
|
-
"cache-manager": "^5.2.3",
|
|
52
|
-
"react-to-text": "^2.0.1"
|
|
48
|
+
"react-markdown": "^8.0.7"
|
|
53
49
|
},
|
|
54
50
|
"dependencies": {
|
|
51
|
+
"@lidofinance/lido-ui": "3.14.1",
|
|
55
52
|
"js-yaml": "^4.1.0",
|
|
56
53
|
"mdast": "^3.0.0",
|
|
57
54
|
"react-markdown": "^8.0.7",
|
|
58
|
-
"react-to-text": "^2.0.1",
|
|
59
55
|
"remark-directive": "^2.0.1",
|
|
60
56
|
"remark-frontmatter": "^4.0.1",
|
|
61
57
|
"remark-parse": "^10.0.2",
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AKAA,oDAAoD;AACpD,oEAAoE;AACpE,+CAA+C;AAC/C,uEAAuE;AACvE,gEAAgE;AAChE,4DAA4D;;AAI5D,gFAAgF;AAChF,MAAM,+BAA0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A,GAAA,sBAAc;QACd;YAAC,CAAA,GAAA,wBAAgB;YAAG;gBAAC;aAAO;SAAC;QAC7B,CAAA,GAAA,yCAAa;KACd;IACD,OAAO,MAAM,aAAa,SAAS,EAAE;AACvC;;","sources":["packages/ui/faq/src/index.ts","packages/ui/faq/src/components/index.ts","packages/ui/faq/src/components/faqAccordion/index.tsx","packages/ui/faq/src/components/faqAccordion/faqAccordion.tsx","packages/ui/faq/src/components/faqAccordion/styles.tsx","packages/ui/faq/styledComponentsWrapper.ts","packages/ui/faq/src/components/faqAccordion/types.ts","packages/ui/faq/src/utils/index.ts","packages/ui/faq/src/utils/remarkPlugins/index.ts","packages/ui/faq/src/utils/remarkPlugins/getFrontmatter.ts","packages/ui/faq/src/utils/remarkPlugins/type.ts"],"sourcesContent":["export * from './components'\nexport * from './utils'\n","export * from './faqAccordion'\n","export * from './faqAccordion'\nexport * from './styles'\nexport * from './types'\n","import React, { FC } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport reactToText from 'react-to-text'\nimport { LidoLink } from '@lidofinance/next-ui-primitives'\nimport * as LidoUI from '@lidofinance/lido-ui'\nconst { Accordion } = LidoUI\n\nimport { FAQAccordionProps } from './types'\nimport { FaqItem } from './styles'\n\nexport const FaqAccordion: FC<FAQAccordionProps> = ({ faqList, onLinkClick, onQuestionOpenOrClose }) => (\n <>\n {faqList?.map(({ questionId, question, answer }, index) => (\n <Accordion\n key={question}\n defaultExpanded={index === 0}\n summary={String(question)}\n onClick={() => {\n onQuestionOpenOrClose?.({\n questionId,\n question,\n answer,\n accordionIndex: index,\n })\n }}\n >\n <FaqItem>\n <ReactMarkdown\n components={{\n a: ({ children, href, ...rest }) => {\n const linkContent = reactToText(children)\n\n return (\n <LidoLink\n {...rest}\n href={href ?? '#'}\n onClick={() => {\n onLinkClick?.({\n questionId,\n question,\n answer,\n accordionIndex: index,\n linkContent,\n linkHref: href,\n })\n }}\n >\n {linkContent}\n </LidoLink>\n )\n },\n }}\n >\n {answer}\n </ReactMarkdown>\n </FaqItem>\n </Accordion>\n ))}\n </>\n)\n","import styled from '../../../styledComponentsWrapper'\n\nexport const FaqItem = styled.div`\n p {\n margin: 0 0 1.6em;\n }\n\n :is(p, ul) + p,\n p + :is(ul, ol) {\n margin-top: -1.6em;\n }\n\n :is(ul, ol) > li {\n margin-top: 0;\n margin-bottom: 0;\n\n & > p {\n margin-top: 0;\n margin-bottom: 0;\n }\n }\n\n a {\n text-decoration: none;\n }\n`\n","// Styled Components v5 has issues with ESM modules:\n// https://github.com/styled-components/styled-components/issues/115\n// https://github.com/rollup/rollup/issues/4438\n// It can be solved by using Styled Components v6, which is in beta ATM\n// But it will be better to stop using styled-components at all.\n// This is a temporary workaround, which seems to work well.\n\nimport _styled, { StyledInterface } from 'styled-components'\n\n// @ts-expect-error Property 'default' does not exist on type 'StyledInterface'.\nconst styled: StyledInterface = _styled.default || _styled\n\nexport * from 'styled-components'\nexport default styled\n","export type FAQItem = {\n answer: string\n question: string\n questionId: string\n}\n\nexport type FAQAccordionOnActionProps = {\n questionId: string\n question: string\n answer: string\n accordionIndex: number\n}\n\nexport type FAQAccordionOnLinkClickProps = FAQAccordionOnActionProps & {\n linkContent: string\n linkHref?: string | undefined\n}\n\nexport type FAQAccordionProps = {\n faqList?: FAQItem[] | undefined\n onLinkClick?: (props: FAQAccordionOnLinkClickProps) => void | undefined\n onQuestionOpenOrClose?: (props: FAQAccordionOnActionProps) => void | undefined\n}\n\nexport const isFAQItem = (obj: FAQItem): obj is FAQItem => {\n return 'answer' in obj && 'question' in obj\n}\n\nexport const isFAQAccordionProps = (obj: any): obj is FAQAccordionProps => {\n return Array.isArray(obj.faqList)\n}\n","import axios, { Axios } from 'axios'\nimport { caching, MemoryCache, MemoryConfig } from 'cache-manager'\nimport { unified, PluggableList } from 'unified'\nimport remarkParse from 'remark-parse'\nimport remarkStringify from 'remark-stringify'\nimport remarkFrontmatter from 'remark-frontmatter'\nimport remarkDirective from 'remark-directive'\n\nimport { FAQItem } from '../components'\nimport { getFrontmatter } from './remarkPlugins'\n\nconst ttlMs = 6 * 100 * 1000 /* 10 minutes */\nconst memoryCacheConfigDefault = { max: 100, ttl: ttlMs }\nlet memoryCache: MemoryCache\n\nconst getMemoryCacheInstance = async (memoryCacheConfig: MemoryConfig = memoryCacheConfigDefault) => {\n memoryCache ??= await caching('memory', memoryCacheConfig)\n\n return memoryCache\n}\n\nexport const parseYamlFileWithMdContent = async (\n md: string,\n remarkPlugins?: PluggableList,\n): Promise<{ content: string; data: Record<string, any> }> => {\n const file = await unified()\n .use(remarkParse)\n .use(remarkStringify)\n .use(remarkPlugins || [])\n .process(md)\n\n return { content: String(file), data: file.data }\n}\n\nexport type PageFAQ = { identification: string; faq: FAQItem[] }\n\nexport const isPageFAQ = (obj: PageFAQ): obj is PageFAQ => {\n return 'identification' in obj && 'faq' in obj\n}\n\nexport type GetFaqOptionsProps = {\n axiosInstance: Axios\n cache?: boolean\n memoryCacheConfig?: MemoryConfig | undefined\n}\n\nconst faqOptionsDefault: GetFaqOptionsProps = { axiosInstance: axios, cache: true }\n\nexport const getFAQ = async (\n faqUrl: string,\n { axiosInstance, cache, memoryCacheConfig } = faqOptionsDefault,\n): Promise<PageFAQ[]> => {\n let memoryCacheInstance: MemoryCache | undefined\n let rawFaqData: string | undefined\n\n if (cache) {\n memoryCacheInstance = await getMemoryCacheInstance(memoryCacheConfig)\n rawFaqData = await memoryCacheInstance.get(faqUrl)\n }\n\n if (!rawFaqData) {\n rawFaqData = (await axiosInstance.get(faqUrl)).data as string\n\n if (cache && memoryCacheInstance) {\n await memoryCacheInstance.set(faqUrl, rawFaqData, ttlMs)\n }\n }\n\n // Temporary solution\n // The CMS, while generating md, adds an '\\_' between the text and\n // the link, which is then replaced by 'nbsp;' (non-breaking space)\n // and interferes correct content display\n // To fix this, we replace '\\_' with ' '\n const fixedFileContent = rawFaqData.replace(/\\\\_\\[/gm, ' [').replace(/\\)\\\\_/gm, ') ')\n\n const { data } = await parseYamlFileWithMdContent(fixedFileContent, [\n remarkDirective,\n [remarkFrontmatter, ['yaml']],\n getFrontmatter,\n ])\n return data?.frontmatter?.pages ?? []\n}\n","export * from './getFrontmatter'\nexport * from './type'\n","import yaml from 'js-yaml'\n\nimport { Tree, VFileWithOutput } from './type'\n\n// eslint-disable-next-line unicorn/consistent-function-scoping\nexport const getFrontmatter = () => (tree: Tree, file: VFileWithOutput<null>) => {\n const node = tree.children[0]\n\n if (node?.type === 'yaml') {\n const data = yaml.load(node.value)\n file.data.frontmatter = data\n tree.children.splice(0, 1)\n } else {\n file.data.frontmatter = {}\n }\n}\n","import { Root, Parent, Content } from 'mdast'\nimport { VFileWithOutput } from 'unified'\n\nexport type Tree = Root\n\nexport type Node = Parent\n\nexport type { Content, VFileWithOutput }\n"],"names":[],"version":3,"file":"index.js.map"}
|