@gov-cy/govcy-frontend-renderer 1.1.1 → 1.2.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.
|
@@ -2157,6 +2157,175 @@ root: root
|
|
|
2157
2157
|
})();
|
|
2158
2158
|
})();
|
|
2159
2159
|
|
|
2160
|
+
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/panel.njk"] = (function() {
|
|
2161
|
+
function root(env, context, frame, runtime, cb) {
|
|
2162
|
+
var lineno = 0;
|
|
2163
|
+
var colno = 0;
|
|
2164
|
+
var output = "";
|
|
2165
|
+
try {
|
|
2166
|
+
var parentTemplate = null;
|
|
2167
|
+
output += "\r\n";
|
|
2168
|
+
var macro_t_1 = runtime.makeMacro(
|
|
2169
|
+
["params"],
|
|
2170
|
+
[],
|
|
2171
|
+
function (l_params, kwargs) {
|
|
2172
|
+
var callerFrame = frame;
|
|
2173
|
+
frame = new runtime.Frame();
|
|
2174
|
+
kwargs = kwargs || {};
|
|
2175
|
+
if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
|
|
2176
|
+
frame.set("caller", kwargs.caller); }
|
|
2177
|
+
frame.set("params", l_params);
|
|
2178
|
+
var t_2 = "";env.getTemplate("utilities/govcyUtilities.njk", false, "elements/panel.njk", false, function(t_4,t_3) {
|
|
2179
|
+
if(t_4) { cb(t_4); return; }
|
|
2180
|
+
t_3.getExported(function(t_5,t_3) {
|
|
2181
|
+
if(t_5) { cb(t_5); return; }
|
|
2182
|
+
if(Object.prototype.hasOwnProperty.call(t_3, "govcyLocalizeContent")) {
|
|
2183
|
+
var t_6 = t_3.govcyLocalizeContent;
|
|
2184
|
+
} else {
|
|
2185
|
+
cb(new Error("cannot import 'govcyLocalizeContent'")); return;
|
|
2186
|
+
}
|
|
2187
|
+
context.setVariable("govcyLocalizeContent", t_6);
|
|
2188
|
+
if(Object.prototype.hasOwnProperty.call(t_3, "govcyLangAttribute")) {
|
|
2189
|
+
var t_7 = t_3.govcyLangAttribute;
|
|
2190
|
+
} else {
|
|
2191
|
+
cb(new Error("cannot import 'govcyLangAttribute'")); return;
|
|
2192
|
+
}
|
|
2193
|
+
context.setVariable("govcyLangAttribute", t_7);
|
|
2194
|
+
var t_8;
|
|
2195
|
+
t_8 = env.getFilter("default").call(context, runtime.memberLookup((l_params),"background"),"govcy-bg-success");
|
|
2196
|
+
frame.set("background", t_8, true);
|
|
2197
|
+
if(frame.topLevel) {
|
|
2198
|
+
context.setVariable("background", t_8);
|
|
2199
|
+
}
|
|
2200
|
+
if(frame.topLevel) {
|
|
2201
|
+
context.addExport("background", t_8);
|
|
2202
|
+
}
|
|
2203
|
+
t_2 += "<div ";
|
|
2204
|
+
if(runtime.memberLookup((l_params),"id")) {
|
|
2205
|
+
t_2 += "id=\"";
|
|
2206
|
+
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
|
|
2207
|
+
t_2 += "\" ";
|
|
2208
|
+
;
|
|
2209
|
+
}
|
|
2210
|
+
t_2 += "class=\"govcy-alert-completed-notification";
|
|
2211
|
+
if(runtime.memberLookup((l_params),"classes")) {
|
|
2212
|
+
t_2 += " ";
|
|
2213
|
+
t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opts.autoescape);
|
|
2214
|
+
;
|
|
2215
|
+
}
|
|
2216
|
+
t_2 += "\"";
|
|
2217
|
+
t_2 += runtime.suppressValue((lineno = 20, colno = 173, runtime.callWrap(t_7, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
2218
|
+
t_2 += ">\r\n <div class=\"govcy-alert-completed-notification-body ";
|
|
2219
|
+
t_2 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "background"), env.opts.autoescape);
|
|
2220
|
+
t_2 += "\">";
|
|
2221
|
+
if(runtime.memberLookup((l_params),"header")) {
|
|
2222
|
+
t_2 += "<h1>";
|
|
2223
|
+
t_2 += runtime.suppressValue((lineno = 22, colno = 59, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"header"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
2224
|
+
t_2 += "</h1>";
|
|
2225
|
+
;
|
|
2226
|
+
}
|
|
2227
|
+
if(runtime.memberLookup((l_params),"body")) {
|
|
2228
|
+
t_2 += "<p>";
|
|
2229
|
+
t_2 += runtime.suppressValue((lineno = 23, colno = 56, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"body"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
2230
|
+
t_2 += "</p>";
|
|
2231
|
+
;
|
|
2232
|
+
}
|
|
2233
|
+
if(runtime.memberLookup((l_params),"referenceNumber")) {
|
|
2234
|
+
t_2 += "<p class=\"govcy-fw-bold\">";
|
|
2235
|
+
t_2 += runtime.suppressValue((lineno = 24, colno = 89, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"referenceNumber"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
2236
|
+
t_2 += "</p>";
|
|
2237
|
+
;
|
|
2238
|
+
}
|
|
2239
|
+
env.getTemplate("govcyElement.njk", false, "elements/panel.njk", false, function(t_10,t_9) {
|
|
2240
|
+
if(t_10) { cb(t_10); return; }
|
|
2241
|
+
t_9.getExported(function(t_11,t_9) {
|
|
2242
|
+
if(t_11) { cb(t_11); return; }
|
|
2243
|
+
if(Object.prototype.hasOwnProperty.call(t_9, "govcyElement")) {
|
|
2244
|
+
var t_12 = t_9.govcyElement;
|
|
2245
|
+
} else {
|
|
2246
|
+
cb(new Error("cannot import 'govcyElement'")); return;
|
|
2247
|
+
}
|
|
2248
|
+
context.setVariable("govcyElement", t_12);
|
|
2249
|
+
frame = frame.push();
|
|
2250
|
+
var t_15 = runtime.memberLookup((l_params),"elements");
|
|
2251
|
+
if(t_15) {t_15 = runtime.fromIterator(t_15);
|
|
2252
|
+
var t_14 = t_15.length;
|
|
2253
|
+
for(var t_13=0; t_13 < t_15.length; t_13++) {
|
|
2254
|
+
var t_16 = t_15[t_13];
|
|
2255
|
+
frame.set("element", t_16);
|
|
2256
|
+
frame.set("loop.index", t_13 + 1);
|
|
2257
|
+
frame.set("loop.index0", t_13);
|
|
2258
|
+
frame.set("loop.revindex", t_14 - t_13);
|
|
2259
|
+
frame.set("loop.revindex0", t_14 - t_13 - 1);
|
|
2260
|
+
frame.set("loop.first", t_13 === 0);
|
|
2261
|
+
frame.set("loop.last", t_13 === t_14 - 1);
|
|
2262
|
+
frame.set("loop.length", t_14);
|
|
2263
|
+
if(runtime.memberLookup((l_params),"lang") && !runtime.memberLookup((runtime.memberLookup((t_16),"params")),"lang")) {
|
|
2264
|
+
var t_17;
|
|
2265
|
+
t_17 = env.getFilter("merge").call(context, runtime.memberLookup((t_16),"params"),{"lang": runtime.memberLookup((l_params),"lang")});
|
|
2266
|
+
frame.set("paramsIn", t_17, true);
|
|
2267
|
+
if(frame.topLevel) {
|
|
2268
|
+
context.setVariable("paramsIn", t_17);
|
|
2269
|
+
}
|
|
2270
|
+
if(frame.topLevel) {
|
|
2271
|
+
context.addExport("paramsIn", t_17);
|
|
2272
|
+
}
|
|
2273
|
+
;
|
|
2274
|
+
}
|
|
2275
|
+
else {
|
|
2276
|
+
var t_18;
|
|
2277
|
+
t_18 = runtime.memberLookup((t_16),"params");
|
|
2278
|
+
frame.set("paramsIn", t_18, true);
|
|
2279
|
+
if(frame.topLevel) {
|
|
2280
|
+
context.setVariable("paramsIn", t_18);
|
|
2281
|
+
}
|
|
2282
|
+
if(frame.topLevel) {
|
|
2283
|
+
context.addExport("paramsIn", t_18);
|
|
2284
|
+
}
|
|
2285
|
+
;
|
|
2286
|
+
}
|
|
2287
|
+
t_2 += runtime.suppressValue((lineno = 35, colno = 33, runtime.callWrap(t_12, "govcyElement", context, [runtime.memberLookup((t_16),"element"),runtime.contextOrFrameLookup(context, frame, "paramsIn"),runtime.makeKeywordArgs({"caller": (function (){var macro_t_19 = runtime.makeMacro(
|
|
2288
|
+
[],
|
|
2289
|
+
[],
|
|
2290
|
+
function (kwargs) {
|
|
2291
|
+
var callerFrame = frame;
|
|
2292
|
+
frame = frame.push(true);
|
|
2293
|
+
kwargs = kwargs || {};
|
|
2294
|
+
if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
|
|
2295
|
+
frame.set("caller", kwargs.caller); }
|
|
2296
|
+
var t_20 = "";;
|
|
2297
|
+
frame = frame.pop();
|
|
2298
|
+
return new runtime.SafeString(t_20);
|
|
2299
|
+
});
|
|
2300
|
+
return macro_t_19;})()})])), env.opts.autoescape);
|
|
2301
|
+
;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
frame = frame.pop();
|
|
2305
|
+
t_2 += "</div> \r\n</div>";
|
|
2306
|
+
})})})});
|
|
2307
|
+
frame = callerFrame;
|
|
2308
|
+
return new runtime.SafeString(t_2);
|
|
2309
|
+
});
|
|
2310
|
+
context.addExport("panel");
|
|
2311
|
+
context.setVariable("panel", macro_t_1);
|
|
2312
|
+
if(parentTemplate) {
|
|
2313
|
+
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
2314
|
+
} else {
|
|
2315
|
+
cb(null, output);
|
|
2316
|
+
}
|
|
2317
|
+
;
|
|
2318
|
+
} catch (e) {
|
|
2319
|
+
cb(runtime.handleError(e, lineno, colno));
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
return {
|
|
2323
|
+
root: root
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
})();
|
|
2327
|
+
})();
|
|
2328
|
+
|
|
2160
2329
|
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/radios.njk"] = (function() {
|
|
2161
2330
|
function root(env, context, frame, runtime, cb) {
|
|
2162
2331
|
var lineno = 0;
|
|
@@ -4918,7 +5087,7 @@ var output = "";
|
|
|
4918
5087
|
try {
|
|
4919
5088
|
var parentTemplate = null;
|
|
4920
5089
|
var t_1;
|
|
4921
|
-
t_1 = ["label","legend","hint","button","errorMessage","select","textElement","htmlElement","textInput","radios","checkboxes","fileInput","fileView","backLink","tag","table","summaryList","textArea","markdown"];
|
|
5090
|
+
t_1 = ["label","legend","hint","button","errorMessage","select","textElement","htmlElement","textInput","radios","checkboxes","fileInput","fileView","backLink","tag","table","summaryList","textArea","markdown","panel"];
|
|
4922
5091
|
frame.set("macroSimpleBlocks", t_1, true);
|
|
4923
5092
|
if(frame.topLevel) {
|
|
4924
5093
|
context.setVariable("macroSimpleBlocks", t_1);
|
|
@@ -4966,7 +5135,7 @@ if(t_10) { cb(t_10); return; }
|
|
|
4966
5135
|
t_9.getExported(function(t_11,t_9) {
|
|
4967
5136
|
if(t_11) { cb(t_11); return; }
|
|
4968
5137
|
frame.set("comp", t_9);
|
|
4969
|
-
t_4 += runtime.suppressValue((lineno =
|
|
5138
|
+
t_4 += runtime.suppressValue((lineno = 34, colno = 22, runtime.callWrap(runtime.memberLookup((t_9),t_8), "comp[\"c\"]", context, [l_params])), env.opts.autoescape);
|
|
4970
5139
|
})});
|
|
4971
5140
|
}
|
|
4972
5141
|
;
|
|
@@ -4993,7 +5162,7 @@ if(t_17) { cb(t_17); return; }
|
|
|
4993
5162
|
t_16.getExported(function(t_18,t_16) {
|
|
4994
5163
|
if(t_18) { cb(t_18); return; }
|
|
4995
5164
|
frame.set("compm", t_16);
|
|
4996
|
-
t_4 += runtime.suppressValue((lineno =
|
|
5165
|
+
t_4 += runtime.suppressValue((lineno = 41, colno = 29, runtime.callWrap(runtime.memberLookup((t_16),t_15), "compm[\"c\"]", context, [l_params,runtime.makeKeywordArgs({"caller": (function (){var macro_t_19 = runtime.makeMacro(
|
|
4997
5166
|
[],
|
|
4998
5167
|
[],
|
|
4999
5168
|
function (kwargs) {
|
|
@@ -5002,7 +5171,7 @@ frame = frame.push(true);
|
|
|
5002
5171
|
kwargs = kwargs || {};
|
|
5003
5172
|
if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
|
|
5004
5173
|
frame.set("caller", kwargs.caller); }
|
|
5005
|
-
var t_20 = "";t_20 += runtime.suppressValue((lineno =
|
|
5174
|
+
var t_20 = "";t_20 += runtime.suppressValue((lineno = 42, colno = 25, runtime.callWrap(runtime.contextOrFrameLookup(context, frame, "caller"), "caller", context, [])), env.opts.autoescape);
|
|
5006
5175
|
;
|
|
5007
5176
|
frame = frame.pop();
|
|
5008
5177
|
return new runtime.SafeString(t_20);
|
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{# panel
|
|
2
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
3
|
+
@param {object} header if defined, will rendered the `<h1>` inside the panel. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
4
|
+
@param {object} body if defined, will rendered the body in a `<p>` inside the panel. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
5
|
+
@param {object} referenceNumber if defined, will rendered the reference number in a `<p>` inside the panel. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
6
|
+
@param {array} elements if defined, govcy-elements to be rendered inside the panel.
|
|
7
|
+
i.e. `[
|
|
8
|
+
{element:"button",params:{text:{en:"Button 1",el:"Κουμπί 1"},lang:"en",id:"govcy-test-23b"} },
|
|
9
|
+
{element:"button",params:{text:{en:"Button 2",el:"Κουμπί 2"},variant:'secondary',lang:"en",id:"govcy-test-23c"} },
|
|
10
|
+
]`
|
|
11
|
+
@param {string} id The label id. Will escape text
|
|
12
|
+
@param {string} background The background class of the panel. Default is `govcy-bg-success`. Will escape text
|
|
13
|
+
@param {string} classes Additional classes to add to the outer div. Optional
|
|
14
|
+
@returns govcy panel html
|
|
15
|
+
#}
|
|
16
|
+
{% macro panel(params) -%}
|
|
17
|
+
{#- Import localizer from utilities -#}
|
|
18
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
19
|
+
{# set default values #}
|
|
20
|
+
{%- set background = params.background | default("govcy-bg-success") -%}
|
|
21
|
+
<div {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-alert-completed-notification{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
|
|
22
|
+
<div class="govcy-alert-completed-notification-body {{ background }}">
|
|
23
|
+
{%- if params.header -%}<h1>{{ govcyLocalizeContent(params.header, params.lang) }}</h1>{%- endif -%}
|
|
24
|
+
{%- if params.body -%}<p>{{ govcyLocalizeContent(params.body, params.lang) }}</p>{%- endif -%}
|
|
25
|
+
{%- if params.referenceNumber -%}<p class="govcy-fw-bold">{{ govcyLocalizeContent(params.referenceNumber, params.lang) }}</p>{%- endif -%}
|
|
26
|
+
{#- Import localizer from utilities -#}
|
|
27
|
+
{%- from "../govcyElement.njk" import govcyElement -%}
|
|
28
|
+
{#- handle elements if defined -#}
|
|
29
|
+
{%- for element in params.elements -%}
|
|
30
|
+
{#- if lang is defined in the element, merge it with the lang of the panel -#}
|
|
31
|
+
{%- if params.lang and not element.params.lang -%}
|
|
32
|
+
{%- set paramsIn = element.params | merge({lang: params.lang}) -%}
|
|
33
|
+
{%- else -%}
|
|
34
|
+
{%- set paramsIn = element.params -%}
|
|
35
|
+
{%- endif -%}
|
|
36
|
+
{%- call govcyElement(element.element, paramsIn) %}{% endcall -%}
|
|
37
|
+
{%- endfor -%}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
{%- endmacro %}
|
package/src/njk/govcyElement.njk
CHANGED
|
@@ -24,7 +24,8 @@ To use:
|
|
|
24
24
|
#}
|
|
25
25
|
{%- set macroSimpleBlocks = ['label', 'legend', 'hint', 'button',
|
|
26
26
|
'errorMessage','select','textElement','htmlElement','textInput','radios','checkboxes',
|
|
27
|
-
'fileInput','fileView','backLink','tag','table', 'summaryList', 'textArea','markdown'
|
|
27
|
+
'fileInput','fileView','backLink','tag','table', 'summaryList', 'textArea','markdown',
|
|
28
|
+
'panel'] -%}
|
|
28
29
|
{%- set macroCallerBlocks = ['formControl','form','fieldset'] -%}
|
|
29
30
|
{%- macro govcyElement(component, params) -%}
|
|
30
31
|
{#- Simple blocks -#}
|