@digigov/react-modules 1.2.0-rc.32 → 2.0.0-0b806366
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/Faq/Results.js +34 -0
- package/Faq/hooks.d.ts +1 -1
- package/Faq/hooks.js +54 -0
- package/Faq/index.js +191 -163
- package/Faq/slug.js +94 -0
- package/Faq/utils.js +3 -0
- package/FilteredResults/DataTable.js +12 -0
- package/FilteredResults/FilterChips.js +34 -0
- package/FilteredResults/FilterFields.js +13 -0
- package/FilteredResults/hooks.d.ts +1 -1
- package/FilteredResults/hooks.js +78 -0
- package/FilteredResults/index.js +96 -112
- package/index.d.ts +2 -2
- package/index.js +3 -4
- package/lazy.d.ts +17 -0
- package/lazy.js +28 -0
- package/package.json +10 -10
- package/registry.d.ts +14 -0
- package/registry.js +34 -0
- package/Faq/Faq.stories.d.ts +0 -8
- package/Faq/Results/index.js +0 -29
- package/Faq/Results/package.json +0 -6
- package/Faq/Results.js.map +0 -7
- package/Faq/__stories__/Default.d.ts +0 -2
- package/Faq/hooks/index.js +0 -66
- package/Faq/hooks/package.json +0 -6
- package/Faq/hooks.js.map +0 -7
- package/Faq/index.js.map +0 -7
- package/Faq/index.test.d.ts +0 -1
- package/Faq/package.json +0 -6
- package/Faq/slug/index.js +0 -97
- package/Faq/slug/package.json +0 -6
- package/Faq/slug.js.map +0 -7
- package/Faq/splitted.test.d.ts +0 -1
- package/Faq/utils/index.js +0 -8
- package/Faq/utils/package.json +0 -6
- package/Faq/utils.js.map +0 -7
- package/FilteredResults/DataTable/index.js +0 -18
- package/FilteredResults/DataTable/package.json +0 -6
- package/FilteredResults/DataTable.js.map +0 -7
- package/FilteredResults/FilterChips/index.js +0 -52
- package/FilteredResults/FilterChips/package.json +0 -6
- package/FilteredResults/FilterChips.js.map +0 -7
- package/FilteredResults/FilterFields/index.js +0 -11
- package/FilteredResults/FilterFields/package.json +0 -6
- package/FilteredResults/FilterFields.js.map +0 -7
- package/FilteredResults/FilteredResults.stories.d.ts +0 -8
- package/FilteredResults/__stories__/Default.d.ts +0 -2
- package/FilteredResults/hooks/index.js +0 -105
- package/FilteredResults/hooks/package.json +0 -6
- package/FilteredResults/hooks.js.map +0 -7
- package/FilteredResults/index.js.map +0 -7
- package/FilteredResults/index.test.d.ts +0 -1
- package/FilteredResults/package.json +0 -6
- package/FilteredResults/splitted.test.d.ts +0 -1
- package/ReactModules.stories.d.ts +0 -4
- package/cjs/Faq/Results/index.js +0 -58
- package/cjs/Faq/Results.js.map +0 -7
- package/cjs/Faq/hooks/index.js +0 -90
- package/cjs/Faq/hooks.js.map +0 -7
- package/cjs/Faq/index.js +0 -194
- package/cjs/Faq/index.js.map +0 -7
- package/cjs/Faq/slug/index.js +0 -120
- package/cjs/Faq/slug.js.map +0 -7
- package/cjs/Faq/utils/index.js +0 -31
- package/cjs/Faq/utils.js.map +0 -7
- package/cjs/FilteredResults/DataTable/index.js +0 -42
- package/cjs/FilteredResults/DataTable.js.map +0 -7
- package/cjs/FilteredResults/FilterChips/index.js +0 -82
- package/cjs/FilteredResults/FilterChips.js.map +0 -7
- package/cjs/FilteredResults/FilterFields/index.js +0 -44
- package/cjs/FilteredResults/FilterFields.js.map +0 -7
- package/cjs/FilteredResults/hooks/index.js +0 -132
- package/cjs/FilteredResults/hooks.js.map +0 -7
- package/cjs/FilteredResults/index.js +0 -153
- package/cjs/FilteredResults/index.js.map +0 -7
- package/cjs/index.js +0 -24
- package/cjs/index.js.map +0 -7
- package/cjs/lazy.js +0 -44
- package/cjs/lazy.js.map +0 -7
- package/cjs/registry.js +0 -73
- package/cjs/registry.js.map +0 -7
- package/index.js.map +0 -7
- package/lazy/package.json +0 -6
- package/registry/package.json +0 -6
- package/src/lazy.js +0 -11
- package/src/registry.js +0 -43
- /package/{lazy/index.js → src/lazy.ts} +0 -0
- /package/{registry/index.js → src/registry.ts} +0 -0
package/Faq/Results.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import react, { useCallback } from "react";
|
|
2
|
+
import { useFormContext } from "@digigov/form/FormBuilder/index.js";
|
|
3
|
+
import Button from "@digigov/ui/form/Button/index.js";
|
|
4
|
+
import { Heading } from "@digigov/ui/typography/Heading/index.js";
|
|
5
|
+
const Results_Results = /*#__PURE__*/ react.forwardRef(function({ filteredSections, Onclose, activeQa, primarySections }, ref) {
|
|
6
|
+
const { resetField, submit } = useFormContext();
|
|
7
|
+
const handleReset = useCallback((e)=>{
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
10
|
+
urlParams.delete('text');
|
|
11
|
+
urlParams.delete('activeQa');
|
|
12
|
+
window.history.replaceState({}, '', '?' + urlParams.toString());
|
|
13
|
+
resetField('text', {
|
|
14
|
+
defaultValue: ''
|
|
15
|
+
});
|
|
16
|
+
Onclose(activeQa);
|
|
17
|
+
submit();
|
|
18
|
+
}, [
|
|
19
|
+
resetField,
|
|
20
|
+
Onclose,
|
|
21
|
+
submit,
|
|
22
|
+
activeQa
|
|
23
|
+
]);
|
|
24
|
+
return /*#__PURE__*/ react.createElement(Heading, {
|
|
25
|
+
ref: ref,
|
|
26
|
+
size: "sm",
|
|
27
|
+
marginTop: 4
|
|
28
|
+
}, "Αποτελέσματα: ", filteredSections, " από ", primarySections, ".", ' ', /*#__PURE__*/ react.createElement(Button, {
|
|
29
|
+
variant: "link",
|
|
30
|
+
onClick: (e)=>handleReset(e)
|
|
31
|
+
}, "Επαναφορά αναζήτησης"));
|
|
32
|
+
});
|
|
33
|
+
const Faq_Results = Results_Results;
|
|
34
|
+
export { Faq_Results as default };
|
package/Faq/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sectionsConfigType, SectionType } from '
|
|
1
|
+
import { sectionsConfigType, SectionType } from './index.js';
|
|
2
2
|
export declare const useURLParamsSearch: (searchFunc: (params: Record<string, string | undefined>) => void, { navigate, filteredSections, }: {
|
|
3
3
|
navigate: (url: string) => void;
|
|
4
4
|
filteredSections: SectionType[];
|
package/Faq/hooks.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { slug } from "./slug.js";
|
|
3
|
+
const removeAccents = (text)=>text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
4
|
+
const useURLParamsSearch = (searchFunc, { navigate, filteredSections })=>{
|
|
5
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
6
|
+
const currentParams = Object.fromEntries(urlParams.entries());
|
|
7
|
+
const hashId = window.location.hash ? window.location.hash.slice(1) : '';
|
|
8
|
+
const hashExistsInFilteredSections = filteredSections.some((section)=>section.qa.some(({ id, question })=>id === hashId || slug(question) === hashId));
|
|
9
|
+
const search = (params)=>{
|
|
10
|
+
const updatedParams = Object.entries({
|
|
11
|
+
...currentParams,
|
|
12
|
+
...params
|
|
13
|
+
}).filter(([, value])=>Boolean(value)).reduce((acc, [key, value])=>{
|
|
14
|
+
acc[key] = value;
|
|
15
|
+
return acc;
|
|
16
|
+
}, {});
|
|
17
|
+
const newUrl = Object.keys(updatedParams).length ? '?' + new URLSearchParams(updatedParams).toString() : window.location.pathname;
|
|
18
|
+
const finalURL = hashExistsInFilteredSections ? newUrl + `#${hashId}` : newUrl;
|
|
19
|
+
navigate(finalURL);
|
|
20
|
+
return searchFunc(params);
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
search,
|
|
24
|
+
values: {
|
|
25
|
+
text: currentParams.text
|
|
26
|
+
},
|
|
27
|
+
hashId
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const useFaqSearch = (questions)=>{
|
|
31
|
+
const [filteredSections, setFilteredSections] = useState(questions.sections);
|
|
32
|
+
const search = (values)=>{
|
|
33
|
+
if (!values || !values.text?.trim()) return void setFilteredSections(questions.sections);
|
|
34
|
+
const searchValue = values.text.trim();
|
|
35
|
+
const normalizedSearchWord = removeAccents(searchValue.toLowerCase());
|
|
36
|
+
const filteredSections = questions.sections.map((section)=>{
|
|
37
|
+
const filteredQa = section.qa.filter(({ question, answer })=>{
|
|
38
|
+
const normalizedQuestion = removeAccents(question?.toLowerCase() || '');
|
|
39
|
+
const normalizedAnswer = removeAccents(answer?.toLowerCase() || '');
|
|
40
|
+
return normalizedQuestion.includes(normalizedSearchWord) || normalizedAnswer.includes(normalizedSearchWord);
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
...section,
|
|
44
|
+
qa: filteredQa
|
|
45
|
+
};
|
|
46
|
+
}).filter((section)=>section.qa.length > 0);
|
|
47
|
+
setFilteredSections(filteredSections);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
filteredSections,
|
|
51
|
+
search
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export { useFaqSearch, useURLParamsSearch };
|
package/Faq/index.js
CHANGED
|
@@ -1,169 +1,197 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Field } from "@digigov/form/Field";
|
|
3
|
-
import FormBuilder from "@digigov/form/FormBuilder";
|
|
4
|
-
import { FormContext } from "@digigov/form/FormContext";
|
|
5
|
-
import Results from "
|
|
6
|
-
import { createId } from "
|
|
7
|
-
import PageTitleContainer, {
|
|
8
|
-
|
|
9
|
-
} from "@digigov/ui/
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
form.submit();
|
|
45
|
-
}
|
|
46
|
-
}, [autoSubmit, form, previousValues, values]);
|
|
47
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
1
|
+
import react, { useContext, useEffect } from "react";
|
|
2
|
+
import { Field } from "@digigov/form/Field/index.js";
|
|
3
|
+
import FormBuilder from "@digigov/form/FormBuilder/index.js";
|
|
4
|
+
import { FormContext } from "@digigov/form/FormContext.js";
|
|
5
|
+
import Results from "./Results.js";
|
|
6
|
+
import { createId } from "./utils.js";
|
|
7
|
+
import PageTitleContainer, { PageTitleHeading } from "@digigov/ui/app/PageTitleContainer/index.js";
|
|
8
|
+
import { Accordion, AccordionSection, AccordionSectionContent, AccordionSectionSummary, AccordionSectionSummaryHeading } from "@digigov/ui/content/Accordion/index.js";
|
|
9
|
+
import { useAccordion } from "@digigov/ui/content/Accordion/hooks.js";
|
|
10
|
+
import Markdown from "@digigov/ui/content/Markdown/index.js";
|
|
11
|
+
import { SearchButton } from "@digigov/ui/form/SearchContainer/index.js";
|
|
12
|
+
import { Stack } from "@digigov/ui/layouts/index.js";
|
|
13
|
+
import { Aside } from "@digigov/ui/layouts/Basic/Aside/index.js";
|
|
14
|
+
import { Container } from "@digigov/ui/layouts/Basic/Container/index.js";
|
|
15
|
+
import { Main } from "@digigov/ui/layouts/Basic/Main/index.js";
|
|
16
|
+
import Grid from "@digigov/ui/layouts/Grid/index.js";
|
|
17
|
+
import SectionBreak from "@digigov/ui/layouts/SectionBreak/index.js";
|
|
18
|
+
import { BackToTop } from "@digigov/ui/navigation/BackToTopLink/index.js";
|
|
19
|
+
import NavList, { NavListItemAction } from "@digigov/ui/navigation/NavList/index.js";
|
|
20
|
+
import { Heading } from "@digigov/ui/typography/Heading/index.js";
|
|
21
|
+
import Hint from "@digigov/ui/typography/Hint/index.js";
|
|
22
|
+
const FormBuilderSyncValues = ({ values, autoSubmit })=>{
|
|
23
|
+
const form = useContext(FormContext);
|
|
24
|
+
const previousValues = form.getValues();
|
|
25
|
+
useEffect(()=>{
|
|
26
|
+
const mergedObject = {
|
|
27
|
+
...values,
|
|
28
|
+
...previousValues
|
|
29
|
+
};
|
|
30
|
+
let shouldSubmit = false;
|
|
31
|
+
for(const key in mergedObject)if (void 0 !== values[key] && previousValues[key] !== values[key]) {
|
|
32
|
+
shouldSubmit = true;
|
|
33
|
+
previousValues[key] = values[key];
|
|
34
|
+
form.setValue(key, values[key]);
|
|
35
|
+
}
|
|
36
|
+
if (autoSubmit && shouldSubmit) form.submit();
|
|
37
|
+
}, [
|
|
38
|
+
autoSubmit,
|
|
39
|
+
form,
|
|
40
|
+
previousValues,
|
|
41
|
+
values
|
|
42
|
+
]);
|
|
43
|
+
return /*#__PURE__*/ react.createElement(react.Fragment, null);
|
|
48
44
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(acc,
|
|
70
|
-
0
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
45
|
+
const Faq_NavigationList = /*#__PURE__*/ react.forwardRef(function({ title, sections }, ref) {
|
|
46
|
+
return /*#__PURE__*/ react.createElement(NavList, {
|
|
47
|
+
ref: ref,
|
|
48
|
+
layout: "vertical",
|
|
49
|
+
marginBottom: 10
|
|
50
|
+
}, title && /*#__PURE__*/ react.createElement(Heading, {
|
|
51
|
+
size: "md",
|
|
52
|
+
id: "contents",
|
|
53
|
+
marginBottom: 4
|
|
54
|
+
}, title), sections && sections.length > 0 && sections.map(({ id, title }, index)=>/*#__PURE__*/ react.createElement(NavListItemAction, {
|
|
55
|
+
key: index,
|
|
56
|
+
href: `#${createId(id, title)}`
|
|
57
|
+
}, title)));
|
|
58
|
+
});
|
|
59
|
+
const Faq_Faq = /*#__PURE__*/ react.forwardRef(function({ contents, sections, initialSections, submitValues, activeQa, onActiveQa, search }, ref) {
|
|
60
|
+
const { section, currentOpen, onOpen, close } = useAccordion({
|
|
61
|
+
singleOpen: true,
|
|
62
|
+
defaultOpen: 0
|
|
63
|
+
});
|
|
64
|
+
const placement = contents.toc?.placement || 'none';
|
|
65
|
+
const filteredSections = sections.reduce((acc, section)=>acc + (section.qa.length || 0), 0);
|
|
66
|
+
const primarySections = initialSections.sections.reduce((acc, section)=>acc + (section.qa.length || 0), 0);
|
|
67
|
+
const hash = window.location.hash.slice(1);
|
|
68
|
+
const currentId = activeQa ? activeQa : hash;
|
|
69
|
+
useEffect(()=>{
|
|
70
|
+
if (onActiveQa) {
|
|
71
|
+
if (currentOpen && activeQa !== currentOpen) onActiveQa(currentOpen);
|
|
72
|
+
}
|
|
73
|
+
}, [
|
|
74
|
+
activeQa,
|
|
75
|
+
currentOpen,
|
|
76
|
+
onActiveQa
|
|
77
|
+
]);
|
|
78
|
+
useEffect(()=>{
|
|
79
|
+
if (activeQa && activeQa !== currentOpen) onOpen(activeQa);
|
|
80
|
+
}, [
|
|
81
|
+
activeQa,
|
|
82
|
+
currentOpen,
|
|
83
|
+
onOpen
|
|
84
|
+
]);
|
|
85
|
+
useEffect(()=>{
|
|
86
|
+
if (currentId) {
|
|
87
|
+
const element = document.getElementById(currentId);
|
|
88
|
+
if (element) element.scrollIntoView({
|
|
89
|
+
behavior: 'smooth',
|
|
90
|
+
block: 'start'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}, [
|
|
94
|
+
activeQa,
|
|
95
|
+
currentId,
|
|
96
|
+
hash
|
|
97
|
+
]);
|
|
98
|
+
const Onclose = (activeQa)=>{
|
|
99
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
100
|
+
urlParams.delete('text');
|
|
101
|
+
urlParams.delete('activeQa');
|
|
102
|
+
window.history.pushState({}, '', '?' + urlParams.toString());
|
|
103
|
+
onActiveQa('');
|
|
104
|
+
close(activeQa);
|
|
105
|
+
};
|
|
106
|
+
const handleSubmit = (data)=>{
|
|
107
|
+
search(data);
|
|
108
|
+
onActiveQa('');
|
|
109
|
+
close(activeQa);
|
|
110
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
111
|
+
urlParams.delete('activeQa');
|
|
112
|
+
window.history.replaceState({}, '', '?' + urlParams.toString());
|
|
113
|
+
};
|
|
114
|
+
return /*#__PURE__*/ react.createElement(Container, {
|
|
115
|
+
ref: ref
|
|
116
|
+
}, 'none' !== placement && 'left' === placement && /*#__PURE__*/ react.createElement(Aside, {
|
|
117
|
+
sticky: false
|
|
118
|
+
}, /*#__PURE__*/ react.createElement(Faq_NavigationList, {
|
|
119
|
+
title: contents.toc?.title,
|
|
120
|
+
sections: sections
|
|
121
|
+
})), /*#__PURE__*/ react.createElement(Main, null, /*#__PURE__*/ react.createElement(PageTitleContainer, null, /*#__PURE__*/ react.createElement(PageTitleHeading, {
|
|
122
|
+
size: "xl",
|
|
123
|
+
id: "faq"
|
|
124
|
+
}, contents?.title)), 'none' !== placement && 'top' === placement && /*#__PURE__*/ react.createElement(Faq_NavigationList, {
|
|
125
|
+
title: contents?.toc?.title,
|
|
126
|
+
sections: sections
|
|
127
|
+
}), contents.search && /*#__PURE__*/ react.createElement(FormBuilder, {
|
|
128
|
+
onSubmit: handleSubmit,
|
|
129
|
+
initial: {
|
|
130
|
+
text: ''
|
|
131
|
+
}
|
|
132
|
+
}, submitValues && /*#__PURE__*/ react.createElement(FormBuilderSyncValues, {
|
|
133
|
+
values: submitValues,
|
|
134
|
+
autoSubmit: true
|
|
135
|
+
}), /*#__PURE__*/ react.createElement(Stack, {
|
|
136
|
+
direction: "row",
|
|
137
|
+
flexWrap: "nowrap",
|
|
138
|
+
alignItems: "flex-end",
|
|
139
|
+
spacing: 4
|
|
140
|
+
}, /*#__PURE__*/ react.createElement(Grid, {
|
|
141
|
+
container: true,
|
|
142
|
+
style: {
|
|
143
|
+
width: '100%'
|
|
144
|
+
}
|
|
145
|
+
}, /*#__PURE__*/ react.createElement(Field, {
|
|
125
146
|
type: "string",
|
|
126
147
|
key: "text",
|
|
127
148
|
name: "text",
|
|
128
|
-
placeholder: "
|
|
129
|
-
label: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
SearchButton,
|
|
134
|
-
{
|
|
149
|
+
placeholder: "Αναζητήστε σχετικά με την ερώτησή σας",
|
|
150
|
+
label: {
|
|
151
|
+
primary: contents.search.title
|
|
152
|
+
}
|
|
153
|
+
})), /*#__PURE__*/ react.createElement(SearchButton, {
|
|
135
154
|
type: "submit",
|
|
136
|
-
mb: {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
mb: {
|
|
156
|
+
md: 10
|
|
157
|
+
},
|
|
158
|
+
style: {
|
|
159
|
+
minHeight: '2.75rem'
|
|
160
|
+
}
|
|
161
|
+
})), filteredSections !== primarySections && /*#__PURE__*/ react.createElement(Results, {
|
|
162
|
+
filteredSections: filteredSections,
|
|
163
|
+
primarySections: primarySections,
|
|
164
|
+
Onclose: Onclose,
|
|
165
|
+
activeQa: activeQa
|
|
166
|
+
})), /*#__PURE__*/ react.createElement(Grid, null, sections && sections.length > 0 ? sections.map(({ id: sectionId, title, qa }, index)=>/*#__PURE__*/ react.createElement(react.Fragment, {
|
|
167
|
+
key: index
|
|
168
|
+
}, /*#__PURE__*/ react.createElement(Heading, {
|
|
169
|
+
id: createId(sectionId, title),
|
|
170
|
+
size: "lg"
|
|
171
|
+
}, title), /*#__PURE__*/ react.createElement(Accordion, {
|
|
172
|
+
marginBottom: qa && qa.length > 0 ? 12 : 0
|
|
173
|
+
}, qa?.map(({ id, question, answer }, indx)=>/*#__PURE__*/ react.createElement(AccordionSection, {
|
|
174
|
+
key: indx,
|
|
175
|
+
...section(createId(id, question))
|
|
176
|
+
}, /*#__PURE__*/ react.createElement(AccordionSectionSummary, null, /*#__PURE__*/ react.createElement(AccordionSectionSummaryHeading, {
|
|
177
|
+
"aria-controls": createId(id, question)
|
|
178
|
+
}, question)), /*#__PURE__*/ react.createElement(AccordionSectionContent, {
|
|
179
|
+
id: createId(id, question)
|
|
180
|
+
}, /*#__PURE__*/ react.createElement(Markdown, {
|
|
181
|
+
content: answer
|
|
182
|
+
}))))), /*#__PURE__*/ react.createElement(SectionBreak, {
|
|
183
|
+
visible: false
|
|
184
|
+
}))) : /*#__PURE__*/ react.createElement(Hint, {
|
|
185
|
+
marginBottom: 10
|
|
186
|
+
}, "Δεν βρέθηκαν αποτελέσματα.")), /*#__PURE__*/ react.createElement(BackToTop, {
|
|
187
|
+
topLimitId: "contents",
|
|
188
|
+
id: "back-to-top"
|
|
189
|
+
}, "Επιστροφή στα Περιεχόμενα")), 'none' !== placement && 'right' === placement && /*#__PURE__*/ react.createElement(Aside, {
|
|
190
|
+
sticky: false
|
|
191
|
+
}, /*#__PURE__*/ react.createElement(Faq_NavigationList, {
|
|
192
|
+
title: contents?.toc?.title,
|
|
193
|
+
sections: sections
|
|
194
|
+
})));
|
|
163
195
|
});
|
|
164
|
-
|
|
165
|
-
export {
|
|
166
|
-
Faq,
|
|
167
|
-
Faq_default as default
|
|
168
|
-
};
|
|
169
|
-
//# sourceMappingURL=index.js.map
|
|
196
|
+
const Faq = Faq_Faq;
|
|
197
|
+
export { Faq_Faq as Faq, Faq as default };
|
package/Faq/slug.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
function slug(text, maxWidth = 50) {
|
|
2
|
+
const greekToLatinMap = {
|
|
3
|
+
α: 'a',
|
|
4
|
+
β: 'b',
|
|
5
|
+
γ: 'g',
|
|
6
|
+
δ: 'd',
|
|
7
|
+
ε: 'e',
|
|
8
|
+
ζ: 'z',
|
|
9
|
+
η: 'i',
|
|
10
|
+
θ: 'th',
|
|
11
|
+
ι: 'i',
|
|
12
|
+
κ: 'k',
|
|
13
|
+
λ: 'l',
|
|
14
|
+
μ: 'm',
|
|
15
|
+
ν: 'n',
|
|
16
|
+
ξ: 'x',
|
|
17
|
+
ο: 'o',
|
|
18
|
+
π: 'p',
|
|
19
|
+
ρ: 'r',
|
|
20
|
+
σ: 's',
|
|
21
|
+
τ: 't',
|
|
22
|
+
υ: 'y',
|
|
23
|
+
φ: 'f',
|
|
24
|
+
χ: 'ch',
|
|
25
|
+
ψ: 'ps',
|
|
26
|
+
ω: 'o',
|
|
27
|
+
ά: 'a',
|
|
28
|
+
έ: 'e',
|
|
29
|
+
ί: 'i',
|
|
30
|
+
ό: 'o',
|
|
31
|
+
ύ: 'y',
|
|
32
|
+
ή: 'i',
|
|
33
|
+
ώ: 'o',
|
|
34
|
+
ς: 's',
|
|
35
|
+
ϊ: 'i',
|
|
36
|
+
ΰ: 'y',
|
|
37
|
+
ϋ: 'y',
|
|
38
|
+
ΐ: 'i',
|
|
39
|
+
Α: 'A',
|
|
40
|
+
Β: 'B',
|
|
41
|
+
Γ: 'G',
|
|
42
|
+
Δ: 'D',
|
|
43
|
+
Ε: 'E',
|
|
44
|
+
Ζ: 'Z',
|
|
45
|
+
Η: 'I',
|
|
46
|
+
Θ: 'TH',
|
|
47
|
+
Ι: 'I',
|
|
48
|
+
Κ: 'K',
|
|
49
|
+
Λ: 'L',
|
|
50
|
+
Μ: 'M',
|
|
51
|
+
Ν: 'N',
|
|
52
|
+
Ξ: 'X',
|
|
53
|
+
Ο: 'O',
|
|
54
|
+
Π: 'P',
|
|
55
|
+
Ρ: 'R',
|
|
56
|
+
Σ: 'S',
|
|
57
|
+
Τ: 'T',
|
|
58
|
+
Υ: 'Y',
|
|
59
|
+
Φ: 'F',
|
|
60
|
+
Χ: 'CH',
|
|
61
|
+
Ψ: 'PS',
|
|
62
|
+
Ω: 'O',
|
|
63
|
+
Ά: 'A',
|
|
64
|
+
Έ: 'E',
|
|
65
|
+
Ί: 'I',
|
|
66
|
+
Ό: 'O',
|
|
67
|
+
Ύ: 'Y',
|
|
68
|
+
Ή: 'I',
|
|
69
|
+
Ώ: 'O',
|
|
70
|
+
Ϊ: 'I',
|
|
71
|
+
Ϋ: 'Y'
|
|
72
|
+
};
|
|
73
|
+
const latinText = text.split('').map((char)=>greekToLatinMap[char] || char).join('');
|
|
74
|
+
const processedText = latinText.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
|
|
75
|
+
let slug1 = processedText.substring(0, maxWidth);
|
|
76
|
+
const remainingText = processedText.substring(maxWidth);
|
|
77
|
+
slug1 = slug1.replace(/-+$/, '');
|
|
78
|
+
const id = generateIDFromText(remainingText);
|
|
79
|
+
return `${slug1}${id && '-'}${id}`;
|
|
80
|
+
}
|
|
81
|
+
function generateIDFromText(text) {
|
|
82
|
+
if (!text) return '';
|
|
83
|
+
let processedText = text.replace(/-/g, '').replace(/[^a-z0-9]/g, '');
|
|
84
|
+
if (!processedText) processedText = 'default';
|
|
85
|
+
let hash = 0;
|
|
86
|
+
for(let i = 0; i < processedText.length; i++){
|
|
87
|
+
const char = processedText.charCodeAt(i);
|
|
88
|
+
hash = (hash << 5) - hash + char;
|
|
89
|
+
hash &= hash;
|
|
90
|
+
}
|
|
91
|
+
const id = Math.abs(hash).toString(36);
|
|
92
|
+
return id;
|
|
93
|
+
}
|
|
94
|
+
export { slug };
|
package/Faq/utils.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Table, TableBody, TableContainer, TableDataCell, TableHead, TableHeadCell, TableNoDataRow, TableRow } from "@digigov/ui/content/Table/index.js";
|
|
3
|
+
function DataTable({ dataConfig, data }) {
|
|
4
|
+
return /*#__PURE__*/ react.createElement(TableContainer, null, /*#__PURE__*/ react.createElement(Table, null, /*#__PURE__*/ react.createElement(TableHead, null, /*#__PURE__*/ react.createElement(TableRow, null, dataConfig.map((itenConfig)=>/*#__PURE__*/ react.createElement(TableHeadCell, {
|
|
5
|
+
key: itenConfig.key
|
|
6
|
+
}, itenConfig.title)))), /*#__PURE__*/ react.createElement(TableBody, null, data.length > 0 ? data.map((item, index)=>/*#__PURE__*/ react.createElement(TableRow, {
|
|
7
|
+
key: index
|
|
8
|
+
}, dataConfig.map((itemConfig, idx)=>/*#__PURE__*/ react.createElement(TableDataCell, {
|
|
9
|
+
key: idx
|
|
10
|
+
}, itemConfig.displayComponent ? itemConfig.displayComponent(item[itemConfig.key]) : item[itemConfig.key])))) : /*#__PURE__*/ react.createElement(TableNoDataRow, null, "Δεν υπάρχουν αποτελέσματα"))));
|
|
11
|
+
}
|
|
12
|
+
export { DataTable };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { useFormContext, useFormValues } from "@digigov/form/FormBuilder/index.js";
|
|
3
|
+
import { getOptionLabelForSelectValue } from "./hooks.js";
|
|
4
|
+
import { FilterSelectedHeading, FilterSelectedSection } from "@digigov/ui/app/FilterContainer/index.js";
|
|
5
|
+
import { Chip, ChipContainer } from "@digigov/ui/content/Chip/index.js";
|
|
6
|
+
import { Button } from "@digigov/ui/form/Button/index.js";
|
|
7
|
+
const FilterChips = ()=>{
|
|
8
|
+
const { fieldsMap, reset, resetField, submit } = useFormContext();
|
|
9
|
+
const values = useFormValues();
|
|
10
|
+
const enabledFilters = Object.keys(values).filter((v)=>values[v]);
|
|
11
|
+
if (0 === enabledFilters.length) return null;
|
|
12
|
+
return /*#__PURE__*/ react.createElement(FilterSelectedSection, {
|
|
13
|
+
m: 0,
|
|
14
|
+
mb: 6
|
|
15
|
+
}, /*#__PURE__*/ react.createElement(FilterSelectedHeading, {
|
|
16
|
+
mb: 0
|
|
17
|
+
}, /*#__PURE__*/ react.createElement(ChipContainer, null, enabledFilters.map((filterKey)=>/*#__PURE__*/ react.createElement(Chip, {
|
|
18
|
+
mb: 0,
|
|
19
|
+
key: filterKey,
|
|
20
|
+
onDelete: ()=>{
|
|
21
|
+
resetField(filterKey);
|
|
22
|
+
submit();
|
|
23
|
+
}
|
|
24
|
+
}, /*#__PURE__*/ react.createElement("b", null, fieldsMap[filterKey].label?.primary), " ", ': ', getOptionLabelForSelectValue(fieldsMap[filterKey], values[filterKey])))), /*#__PURE__*/ react.createElement(Button, {
|
|
25
|
+
onClick: (e)=>{
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
reset();
|
|
28
|
+
submit();
|
|
29
|
+
},
|
|
30
|
+
variant: "link"
|
|
31
|
+
}, "Επαναφορά Επιλογών")));
|
|
32
|
+
};
|
|
33
|
+
const FilteredResults_FilterChips = FilterChips;
|
|
34
|
+
export { FilterChips, FilteredResults_FilterChips as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import Field from "@digigov/form/Field/index.js";
|
|
3
|
+
import { FilterOptionsSection } from "@digigov/ui/app/FilterContainer/index.js";
|
|
4
|
+
import { Button } from "@digigov/ui/form/Button/index.js";
|
|
5
|
+
const FilterFields = ({ fields, horizontal })=>/*#__PURE__*/ react.createElement(FilterOptionsSection, {
|
|
6
|
+
horizontal: horizontal
|
|
7
|
+
}, fields.map((field)=>/*#__PURE__*/ react.createElement(Field, {
|
|
8
|
+
key: field.key,
|
|
9
|
+
name: field.key
|
|
10
|
+
})), /*#__PURE__*/ react.createElement(Button, {
|
|
11
|
+
type: "submit"
|
|
12
|
+
}, "Αναζήτηση"));
|
|
13
|
+
export { FilterFields };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldSpec } from '@digigov/form/types';
|
|
2
|
-
import { ScalarType } from '
|
|
2
|
+
import { ScalarType } from './index.js';
|
|
3
3
|
export declare function isBooleanString(str: string): boolean;
|
|
4
4
|
export declare function normalizeText(text: string): string;
|
|
5
5
|
export declare const getOptionLabelForSelectValue: (field: any, value: any) => any;
|