@gov-cy/govcy-frontend-renderer 1.8.0 → 1.9.0
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.
|
@@ -1749,6 +1749,92 @@ root: root
|
|
|
1749
1749
|
})();
|
|
1750
1750
|
})();
|
|
1751
1751
|
|
|
1752
|
+
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/details.njk"] = (function() {
|
|
1753
|
+
function root(env, context, frame, runtime, cb) {
|
|
1754
|
+
var lineno = 0;
|
|
1755
|
+
var colno = 0;
|
|
1756
|
+
var output = "";
|
|
1757
|
+
try {
|
|
1758
|
+
var parentTemplate = null;
|
|
1759
|
+
output += "\r\n";
|
|
1760
|
+
var macro_t_1 = runtime.makeMacro(
|
|
1761
|
+
["params"],
|
|
1762
|
+
[],
|
|
1763
|
+
function (l_params, kwargs) {
|
|
1764
|
+
var callerFrame = frame;
|
|
1765
|
+
frame = new runtime.Frame();
|
|
1766
|
+
kwargs = kwargs || {};
|
|
1767
|
+
if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
|
|
1768
|
+
frame.set("caller", kwargs.caller); }
|
|
1769
|
+
frame.set("params", l_params);
|
|
1770
|
+
var t_2 = "";env.getTemplate("utilities/govcyUtilities.njk", false, "elements/details.njk", false, function(t_4,t_3) {
|
|
1771
|
+
if(t_4) { cb(t_4); return; }
|
|
1772
|
+
t_3.getExported(function(t_5,t_3) {
|
|
1773
|
+
if(t_5) { cb(t_5); return; }
|
|
1774
|
+
if(Object.prototype.hasOwnProperty.call(t_3, "govcyLocalizeContent")) {
|
|
1775
|
+
var t_6 = t_3.govcyLocalizeContent;
|
|
1776
|
+
} else {
|
|
1777
|
+
cb(new Error("cannot import 'govcyLocalizeContent'")); return;
|
|
1778
|
+
}
|
|
1779
|
+
context.setVariable("govcyLocalizeContent", t_6);
|
|
1780
|
+
if(Object.prototype.hasOwnProperty.call(t_3, "govcyLangAttribute")) {
|
|
1781
|
+
var t_7 = t_3.govcyLangAttribute;
|
|
1782
|
+
} else {
|
|
1783
|
+
cb(new Error("cannot import 'govcyLangAttribute'")); return;
|
|
1784
|
+
}
|
|
1785
|
+
context.setVariable("govcyLangAttribute", t_7);
|
|
1786
|
+
if(Object.prototype.hasOwnProperty.call(t_3, "govcyElementsFromArray")) {
|
|
1787
|
+
var t_8 = t_3.govcyElementsFromArray;
|
|
1788
|
+
} else {
|
|
1789
|
+
cb(new Error("cannot import 'govcyElementsFromArray'")); return;
|
|
1790
|
+
}
|
|
1791
|
+
context.setVariable("govcyElementsFromArray", t_8);
|
|
1792
|
+
if(runtime.memberLookup((l_params),"summary") && runtime.memberLookup((l_params),"elements")) {
|
|
1793
|
+
t_2 += "\r\n<details ";
|
|
1794
|
+
if(runtime.memberLookup((l_params),"id")) {
|
|
1795
|
+
t_2 += "id=\"";
|
|
1796
|
+
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
|
|
1797
|
+
t_2 += "\" ";
|
|
1798
|
+
;
|
|
1799
|
+
}
|
|
1800
|
+
t_2 += "class=\"govcy-details";
|
|
1801
|
+
if(runtime.memberLookup((l_params),"classes")) {
|
|
1802
|
+
t_2 += " ";
|
|
1803
|
+
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opts.autoescape);
|
|
1804
|
+
;
|
|
1805
|
+
}
|
|
1806
|
+
t_2 += "\"";
|
|
1807
|
+
t_2 += runtime.suppressValue((lineno = 17, colno = 156, runtime.callWrap(t_7, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
1808
|
+
t_2 += ">\r\n <summary class=\"govcy-details__summary\">\r\n <span class=\"govcy-details__summary-text\">";
|
|
1809
|
+
t_2 += runtime.suppressValue((lineno = 19, colno = 73, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"summary"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
1810
|
+
t_2 += "</span>\r\n </summary>\r\n <div class=\"govcy-details__text\">\r\n ";
|
|
1811
|
+
t_2 += runtime.suppressValue((lineno = 22, colno = 33, runtime.callWrap(t_8, "govcyElementsFromArray", context, [runtime.memberLookup((l_params),"elements"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
1812
|
+
t_2 += "\r\n </div>\r\n</details>";
|
|
1813
|
+
;
|
|
1814
|
+
}
|
|
1815
|
+
})});
|
|
1816
|
+
frame = callerFrame;
|
|
1817
|
+
return new runtime.SafeString(t_2);
|
|
1818
|
+
});
|
|
1819
|
+
context.addExport("details");
|
|
1820
|
+
context.setVariable("details", macro_t_1);
|
|
1821
|
+
if(parentTemplate) {
|
|
1822
|
+
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
1823
|
+
} else {
|
|
1824
|
+
cb(null, output);
|
|
1825
|
+
}
|
|
1826
|
+
;
|
|
1827
|
+
} catch (e) {
|
|
1828
|
+
cb(runtime.handleError(e, lineno, colno));
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
return {
|
|
1832
|
+
root: root
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
})();
|
|
1836
|
+
})();
|
|
1837
|
+
|
|
1752
1838
|
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/errorMessage.njk"] = (function() {
|
|
1753
1839
|
function root(env, context, frame, runtime, cb) {
|
|
1754
1840
|
var lineno = 0;
|
|
@@ -1917,8 +2003,14 @@ context.addExport("header", t_9);
|
|
|
1917
2003
|
if(runtime.memberLookup((l_params),"id") && runtime.memberLookup((l_params),"errors")) {
|
|
1918
2004
|
t_2 += "\r\n<div id=\"";
|
|
1919
2005
|
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
|
|
1920
|
-
t_2 += "\" class=\"govcy-alert-error govcy-br-5 govcy-br-danger govcy-p-3
|
|
1921
|
-
|
|
2006
|
+
t_2 += "\" class=\"govcy-alert-error govcy-br-5 govcy-br-danger govcy-p-3";
|
|
2007
|
+
if(runtime.memberLookup((l_params),"classes")) {
|
|
2008
|
+
t_2 += " ";
|
|
2009
|
+
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opts.autoescape);
|
|
2010
|
+
;
|
|
2011
|
+
}
|
|
2012
|
+
t_2 += "\"";
|
|
2013
|
+
t_2 += runtime.suppressValue((lineno = 35, colno = 164, runtime.callWrap(t_7, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
1922
2014
|
t_2 += ">\r\n <h2 role=\"alert\" id=\"";
|
|
1923
2015
|
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
|
|
1924
2016
|
t_2 += "-title\">";
|
|
@@ -6282,7 +6374,7 @@ var output = "";
|
|
|
6282
6374
|
try {
|
|
6283
6375
|
var parentTemplate = null;
|
|
6284
6376
|
var t_1;
|
|
6285
|
-
t_1 = ["label","legend","hint","button","errorMessage","select","textElement","htmlElement","textInput","radios","checkboxes","fileInput","fileView","backLink","tag","table","summaryList","textArea","markdown","panel","datePicker","dateInput","taskList","errorSummary"];
|
|
6377
|
+
t_1 = ["label","legend","hint","button","errorMessage","select","textElement","htmlElement","textInput","radios","checkboxes","fileInput","fileView","backLink","tag","table","summaryList","textArea","markdown","panel","datePicker","dateInput","taskList","errorSummary","details"];
|
|
6286
6378
|
frame.set("macroSimpleBlocks", t_1, true);
|
|
6287
6379
|
if(frame.topLevel) {
|
|
6288
6380
|
context.setVariable("macroSimpleBlocks", t_1);
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{# details
|
|
2
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
3
|
+
@param {string} id The id of the summary. Will escape text. Optional
|
|
4
|
+
@param {object} summary The text displayed inside the `<summary>`. Will escape text. Example `{"en":"Content","el":"Περιεχομένο"}`.
|
|
5
|
+
@param {array} elements if defined, govcy-elements to be rendered inside the panel.
|
|
6
|
+
i.e. `[
|
|
7
|
+
{element:"textElement",params:{text:{en:"Content",el:"Περιεχομένο"}},
|
|
8
|
+
{element:"button",params:{text:{en:"Button 1",el:"Κουμπί 1"},lang:"en",id:"govcy-test-23b"} }
|
|
9
|
+
]`
|
|
10
|
+
@param {string} classes Additional classes to add to the outer `<details>`. Optional
|
|
11
|
+
@returns govcy details html
|
|
12
|
+
#}
|
|
13
|
+
{% macro details(params) -%}
|
|
14
|
+
{#- Import localizer from utilities -#}
|
|
15
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute, govcyElementsFromArray -%}
|
|
16
|
+
{#- summary and elements are mandatory -#}
|
|
17
|
+
{%- if params.summary and params.elements %}
|
|
18
|
+
<details {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-details{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
|
|
19
|
+
<summary class="govcy-details__summary">
|
|
20
|
+
<span class="govcy-details__summary-text">{{ govcyLocalizeContent(params.summary, params.lang) }}</span>
|
|
21
|
+
</summary>
|
|
22
|
+
<div class="govcy-details__text">
|
|
23
|
+
{{ govcyElementsFromArray(params.elements, params.lang) }}
|
|
24
|
+
</div>
|
|
25
|
+
</details>
|
|
26
|
+
{%- endif %}
|
|
27
|
+
{%- endmacro %}
|
package/src/njk/govcyElement.njk
CHANGED
|
@@ -25,7 +25,7 @@ To use:
|
|
|
25
25
|
{%- set macroSimpleBlocks = ['label', 'legend', 'hint', 'button',
|
|
26
26
|
'errorMessage','select','textElement','htmlElement','textInput','radios','checkboxes',
|
|
27
27
|
'fileInput','fileView','backLink','tag','table', 'summaryList', 'textArea','markdown',
|
|
28
|
-
'panel', 'datePicker','dateInput', 'taskList', 'errorSummary'] -%}
|
|
28
|
+
'panel', 'datePicker','dateInput', 'taskList', 'errorSummary', 'details'] -%}
|
|
29
29
|
{%- set macroCallerBlocks = ['formControl','form','fieldset'] -%}
|
|
30
30
|
{%- macro govcyElement(component, params) -%}
|
|
31
31
|
{#- Simple blocks -#}
|