@gov-cy/govcy-frontend-renderer 1.24.0 → 1.25.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.
@@ -3284,6 +3284,96 @@ root: root
3284
3284
  })();
3285
3285
  })();
3286
3286
 
3287
+ (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/inset.njk"] = (function() {
3288
+ function root(env, context, frame, runtime, cb) {
3289
+ var lineno = 0;
3290
+ var colno = 0;
3291
+ var output = "";
3292
+ try {
3293
+ var parentTemplate = null;
3294
+ output += "\r\n";
3295
+ var macro_t_1 = runtime.makeMacro(
3296
+ ["params"],
3297
+ [],
3298
+ function (l_params, kwargs) {
3299
+ var callerFrame = frame;
3300
+ frame = new runtime.Frame();
3301
+ kwargs = kwargs || {};
3302
+ if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
3303
+ frame.set("caller", kwargs.caller); }
3304
+ frame.set("params", l_params);
3305
+ var t_2 = "";env.getTemplate("utilities/govcyUtilities.njk", false, "elements/inset.njk", false, function(t_4,t_3) {
3306
+ if(t_4) { cb(t_4); return; }
3307
+ t_3.getExported(function(t_5,t_3) {
3308
+ if(t_5) { cb(t_5); return; }
3309
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyLocalizeContent")) {
3310
+ var t_6 = t_3.govcyLocalizeContent;
3311
+ } else {
3312
+ cb(new Error("cannot import 'govcyLocalizeContent'")); return;
3313
+ }
3314
+ context.setVariable("govcyLocalizeContent", t_6);
3315
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyLangAttribute")) {
3316
+ var t_7 = t_3.govcyLangAttribute;
3317
+ } else {
3318
+ cb(new Error("cannot import 'govcyLangAttribute'")); return;
3319
+ }
3320
+ context.setVariable("govcyLangAttribute", t_7);
3321
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyElementsFromArray")) {
3322
+ var t_8 = t_3.govcyElementsFromArray;
3323
+ } else {
3324
+ cb(new Error("cannot import 'govcyElementsFromArray'")); return;
3325
+ }
3326
+ context.setVariable("govcyElementsFromArray", t_8);
3327
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyGetContent")) {
3328
+ var t_9 = t_3.govcyGetContent;
3329
+ } else {
3330
+ cb(new Error("cannot import 'govcyGetContent'")); return;
3331
+ }
3332
+ context.setVariable("govcyGetContent", t_9);
3333
+ if(runtime.memberLookup((l_params),"text")) {
3334
+ t_2 += "\r\n<blockquote ";
3335
+ if(runtime.memberLookup((l_params),"id")) {
3336
+ t_2 += "id=\"";
3337
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
3338
+ t_2 += "\" ";
3339
+ ;
3340
+ }
3341
+ t_2 += "class=\"govcy-inset-text";
3342
+ if(runtime.memberLookup((l_params),"classes")) {
3343
+ t_2 += " ";
3344
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opts.autoescape);
3345
+ ;
3346
+ }
3347
+ t_2 += "\"";
3348
+ t_2 += runtime.suppressValue((lineno = 12, colno = 162, runtime.callWrap(t_7, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3349
+ t_2 += ">\r\n <p>";
3350
+ t_2 += runtime.suppressValue((lineno = 13, colno = 30, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"text"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3351
+ t_2 += "</p>\r\n</blockquote>";
3352
+ ;
3353
+ }
3354
+ })});
3355
+ frame = callerFrame;
3356
+ return new runtime.SafeString(t_2);
3357
+ });
3358
+ context.addExport("inset");
3359
+ context.setVariable("inset", macro_t_1);
3360
+ if(parentTemplate) {
3361
+ parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
3362
+ } else {
3363
+ cb(null, output);
3364
+ }
3365
+ ;
3366
+ } catch (e) {
3367
+ cb(runtime.handleError(e, lineno, colno));
3368
+ }
3369
+ }
3370
+ return {
3371
+ root: root
3372
+ };
3373
+
3374
+ })();
3375
+ })();
3376
+
3287
3377
  (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/label.njk"] = (function() {
3288
3378
  function root(env, context, frame, runtime, cb) {
3289
3379
  var lineno = 0;
@@ -3560,6 +3650,165 @@ root: root
3560
3650
  })();
3561
3651
  })();
3562
3652
 
3653
+ (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/multipleThingsTable.njk"] = (function() {
3654
+ function root(env, context, frame, runtime, cb) {
3655
+ var lineno = 0;
3656
+ var colno = 0;
3657
+ var output = "";
3658
+ try {
3659
+ var parentTemplate = null;
3660
+ output += "\r\n";
3661
+ var macro_t_1 = runtime.makeMacro(
3662
+ ["params"],
3663
+ [],
3664
+ function (l_params, kwargs) {
3665
+ var callerFrame = frame;
3666
+ frame = new runtime.Frame();
3667
+ kwargs = kwargs || {};
3668
+ if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
3669
+ frame.set("caller", kwargs.caller); }
3670
+ frame.set("params", l_params);
3671
+ var t_2 = "";env.getTemplate("utilities/govcyUtilities.njk", false, "elements/multipleThingsTable.njk", false, function(t_4,t_3) {
3672
+ if(t_4) { cb(t_4); return; }
3673
+ t_3.getExported(function(t_5,t_3) {
3674
+ if(t_5) { cb(t_5); return; }
3675
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyLocalizeContent")) {
3676
+ var t_6 = t_3.govcyLocalizeContent;
3677
+ } else {
3678
+ cb(new Error("cannot import 'govcyLocalizeContent'")); return;
3679
+ }
3680
+ context.setVariable("govcyLocalizeContent", t_6);
3681
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyLangAttribute")) {
3682
+ var t_7 = t_3.govcyLangAttribute;
3683
+ } else {
3684
+ cb(new Error("cannot import 'govcyLangAttribute'")); return;
3685
+ }
3686
+ context.setVariable("govcyLangAttribute", t_7);
3687
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyElementsFromArray")) {
3688
+ var t_8 = t_3.govcyElementsFromArray;
3689
+ } else {
3690
+ cb(new Error("cannot import 'govcyElementsFromArray'")); return;
3691
+ }
3692
+ context.setVariable("govcyElementsFromArray", t_8);
3693
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyGetContent")) {
3694
+ var t_9 = t_3.govcyGetContent;
3695
+ } else {
3696
+ cb(new Error("cannot import 'govcyGetContent'")); return;
3697
+ }
3698
+ context.setVariable("govcyGetContent", t_9);
3699
+ if(runtime.memberLookup((l_params),"items") && runtime.memberLookup((runtime.memberLookup((l_params),"items")),"length") > 0) {
3700
+ t_2 += "\r\n <table ";
3701
+ if(runtime.memberLookup((l_params),"id")) {
3702
+ t_2 += "id=\"";
3703
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
3704
+ t_2 += "\" ";
3705
+ ;
3706
+ }
3707
+ t_2 += "class=\"govcy-table govcy-table-responsive-vertical";
3708
+ if(runtime.memberLookup((l_params),"classes")) {
3709
+ t_2 += " ";
3710
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opts.autoescape);
3711
+ ;
3712
+ }
3713
+ t_2 += "\"";
3714
+ t_2 += runtime.suppressValue((lineno = 44, colno = 186, runtime.callWrap(t_7, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3715
+ t_2 += ">\r\n <tbody>";
3716
+ frame = frame.push();
3717
+ var t_12 = runtime.memberLookup((l_params),"items");
3718
+ if(t_12) {t_12 = runtime.fromIterator(t_12);
3719
+ var t_11 = t_12.length;
3720
+ for(var t_10=0; t_10 < t_12.length; t_10++) {
3721
+ var t_13 = t_12[t_10];
3722
+ frame.set("item", t_13);
3723
+ frame.set("loop.index", t_10 + 1);
3724
+ frame.set("loop.index0", t_10);
3725
+ frame.set("loop.revindex", t_11 - t_10);
3726
+ frame.set("loop.revindex0", t_11 - t_10 - 1);
3727
+ frame.set("loop.first", t_10 === 0);
3728
+ frame.set("loop.last", t_10 === t_11 - 1);
3729
+ frame.set("loop.length", t_11);
3730
+ t_2 += "\r\n <tr class=\"govcy-summary-list-row-internal\">\r\n <td>";
3731
+ t_2 += "<span class=\"govcy-visually-hidden\">";
3732
+ t_2 += runtime.suppressValue((lineno = 51, colno = 66, runtime.callWrap(t_9, "govcyGetContent", context, ["common_entry",runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3733
+ t_2 += " ";
3734
+ t_2 += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "loop")),"index"), env.opts.autoescape);
3735
+ t_2 += " </span>";
3736
+ t_2 += runtime.suppressValue((lineno = 53, colno = 35, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((t_13),"text"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3737
+ t_2 += "</td>\r\n <td class=\"govcy-text-sm-start govcy-text-md-end\">\r\n <ul class=\"list-inline govcy-my-0\">";
3738
+ frame = frame.push();
3739
+ var t_16 = runtime.memberLookup((t_13),"actions");
3740
+ if(t_16) {t_16 = runtime.fromIterator(t_16);
3741
+ var t_15 = t_16.length;
3742
+ for(var t_14=0; t_14 < t_16.length; t_14++) {
3743
+ var t_17 = t_16[t_14];
3744
+ frame.set("action", t_17);
3745
+ frame.set("loop.index", t_14 + 1);
3746
+ frame.set("loop.index0", t_14);
3747
+ frame.set("loop.revindex", t_15 - t_14);
3748
+ frame.set("loop.revindex0", t_15 - t_14 - 1);
3749
+ frame.set("loop.first", t_14 === 0);
3750
+ frame.set("loop.last", t_14 === t_15 - 1);
3751
+ frame.set("loop.length", t_15);
3752
+ t_2 += "\r\n <li class=\"list-inline-item";
3753
+ if(runtime.memberLookup((t_17),"classes")) {
3754
+ t_2 += " ";
3755
+ t_2 += runtime.suppressValue(runtime.memberLookup((t_17),"classes"), env.opts.autoescape);
3756
+ ;
3757
+ }
3758
+ t_2 += "\">\r\n <a href=\"";
3759
+ if(runtime.memberLookup((t_17),"href")) {
3760
+ t_2 += runtime.suppressValue(runtime.memberLookup((t_17),"href"), env.opts.autoescape);
3761
+ ;
3762
+ }
3763
+ else {
3764
+ t_2 += "#";
3765
+ ;
3766
+ }
3767
+ t_2 += "\">";
3768
+ t_2 += runtime.suppressValue((lineno = 62, colno = 43, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((t_17),"text"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3769
+ if(runtime.memberLookup((t_17),"visuallyHiddenText")) {
3770
+ t_2 += "<span class=\"govcy-visually-hidden\">";
3771
+ t_2 += runtime.suppressValue((lineno = 65, colno = 79, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((t_17),"visuallyHiddenText"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
3772
+ t_2 += "</span>";
3773
+ ;
3774
+ }
3775
+ t_2 += "</a>\r\n </li>";
3776
+ ;
3777
+ }
3778
+ }
3779
+ frame = frame.pop();
3780
+ t_2 += "\r\n </ul>\r\n </td>\r\n </tr>";
3781
+ ;
3782
+ }
3783
+ }
3784
+ frame = frame.pop();
3785
+ t_2 += "\r\n </tbody>\r\n </table>";
3786
+ ;
3787
+ }
3788
+ })});
3789
+ frame = callerFrame;
3790
+ return new runtime.SafeString(t_2);
3791
+ });
3792
+ context.addExport("multipleThingsTable");
3793
+ context.setVariable("multipleThingsTable", macro_t_1);
3794
+ output += "\r\n";
3795
+ if(parentTemplate) {
3796
+ parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
3797
+ } else {
3798
+ cb(null, output);
3799
+ }
3800
+ ;
3801
+ } catch (e) {
3802
+ cb(runtime.handleError(e, lineno, colno));
3803
+ }
3804
+ }
3805
+ return {
3806
+ root: root
3807
+ };
3808
+
3809
+ })();
3810
+ })();
3811
+
3563
3812
  (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/panel.njk"] = (function() {
3564
3813
  function root(env, context, frame, runtime, cb) {
3565
3814
  var lineno = 0;
@@ -7577,7 +7826,7 @@ var output = "";
7577
7826
  try {
7578
7827
  var parentTemplate = null;
7579
7828
  var t_1;
7580
- 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","stepByStepStatic","progressList","userName","warning"];
7829
+ 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","stepByStepStatic","progressList","userName","warning","multipleThingsTable","inset"];
7581
7830
  frame.set("macroSimpleBlocks", t_1, true);
7582
7831
  if(frame.topLevel) {
7583
7832
  context.setVariable("macroSimpleBlocks", t_1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-frontend-renderer",
3
- "version": "1.24.0",
3
+ "version": "1.25.1",
4
4
  "description": "Render html for design elements of the Unified design system using njk or json template.",
5
5
  "author": "DMRID - DSF Team",
6
6
  "license": "MIT",
@@ -52,5 +52,8 @@
52
52
  "nodemon": "^3.1.4",
53
53
  "puppeteer": "^23.11.1",
54
54
  "rollup": "^4.21.2"
55
+ },
56
+ "overrides": {
57
+ "tar-fs": "^3.1.1"
55
58
  }
56
59
  }
@@ -0,0 +1,17 @@
1
+ {# inset
2
+ @param {string} lang The language used. Can be 'en','el'. Optional.
3
+ @param {string} id The id of the inset. Will escape text. Optional
4
+ @param {object} text The text. Will escape text, Example `{en:"Content",el:"Περιεχομένο"}`
5
+ @param {string} classes Additional classes to add to the outer `<details>`. Optional
6
+ @returns govcy inset html
7
+ #}
8
+ {% macro inset(params) -%}
9
+ {#- Import localizer from utilities -#}
10
+ {%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute, govcyElementsFromArray, govcyGetContent -%}
11
+ {#- text is mandatory -#}
12
+ {%- if params.text %}
13
+ <blockquote {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-inset-text{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
14
+ <p>{{ govcyLocalizeContent(params.text, params.lang) }}</p>
15
+ </blockquote>
16
+ {%- endif %}
17
+ {%- endmacro %}
@@ -0,0 +1,78 @@
1
+ {# multipleThingsTable
2
+ @param {string} lang The language used. Can be 'en','el'. Optional.
3
+ @param {string} id The id of the element. Will escape text. Optional
4
+ @param {string} classes Additional classes to add to the outer `<details>`. Optional
5
+ @param {array} items The array of items which contain elements
6
+ i.e. `[
7
+ {
8
+ "text": { "en": "+35799123456", "el": "+35799123456" },
9
+ "actions": [
10
+ {
11
+ "text": { "en": "Change", "el": "Αλλαγή" },
12
+ "href": "#",
13
+ classes: "govcy-link",
14
+ "visuallyHiddenText": { "en": "+35799123456", "el": "+35799123456" }
15
+ },
16
+ {
17
+ "text": { "en": "Remove", "el": "Διαγραφή" },
18
+ "href": "#",
19
+ "visuallyHiddenText": { "en": "+35799123456", "el": "+35799123456" }
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ "text": { "en": "+35799654321", "el": "+35799654321" },
25
+ "actions": [
26
+ {
27
+ "text": { "en": "Change", "el": "Αλλαγή" },
28
+ "href": "#",
29
+ "visuallyHiddenText": { "en": "+35799654321", "el": "+35799654321" }
30
+ },
31
+ {
32
+ "text": { "en": "Remove", "el": "Διαγραφή" },
33
+ "href": "#",
34
+ "visuallyHiddenText": { "en": "+35799654321", "el": "+35799654321" }
35
+ }
36
+ ]
37
+ }
38
+ ]`
39
+ @returns govcy multipleThingsTable html
40
+ #}
41
+ {% macro multipleThingsTable(params) %}
42
+ {#- Import localizer from utilities -#}
43
+ {%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute, govcyElementsFromArray, govcyGetContent -%}
44
+ {%- if params.items and params.items.length > 0 %}
45
+ <table {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-table govcy-table-responsive-vertical{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
46
+ <tbody>
47
+ {#- Loop through each row in items -#}
48
+ {%- for item in params.items %}
49
+ <tr class="govcy-summary-list-row-internal">
50
+ <td>
51
+ {#- Screen reader hidden label, increments by row index -#}
52
+ <span class="govcy-visually-hidden">{{ govcyGetContent('common_entry', params.lang) }} {{ loop.index }} </span>
53
+ {#- Display the localized text value (later could support govcyElementsFromArray) -#}
54
+ {{ govcyLocalizeContent(item.text, params.lang) -}}
55
+ </td>
56
+ <td class="govcy-text-sm-start govcy-text-md-end">
57
+ <ul class="list-inline govcy-my-0">
58
+ {#- Loop through actions for this row -#}
59
+ {%- for action in item.actions %}
60
+ <li class="list-inline-item{% if action.classes %} {{ action.classes }}{% endif %}">
61
+ <a href="{% if action.href %}{{ action.href }}{% else %}#{% endif %}">
62
+ {#- Visible action text (e.g. Change / Remove) -#}
63
+ {{ govcyLocalizeContent(action.text, params.lang) }}
64
+ {#- Hidden text for accessibility (e.g. +35799123456) -#}
65
+ {%- if action.visuallyHiddenText -%}
66
+ <span class="govcy-visually-hidden">{{ govcyLocalizeContent(action.visuallyHiddenText, params.lang) }}</span>
67
+ {%- endif -%}
68
+ </a>
69
+ </li>
70
+ {%- endfor %}
71
+ </ul>
72
+ </td>
73
+ </tr>
74
+ {%- endfor %}
75
+ </tbody>
76
+ </table>
77
+ {%- endif -%}
78
+ {% endmacro %}
@@ -3,7 +3,7 @@
3
3
  @param {string} id The id of the warning. Will escape text. Optional
4
4
  @param {object} text The text. Will escape text, Example `{en:"Content",el:"Περιεχομένο"}`
5
5
  @param {string} classes Additional classes to add to the outer `<details>`. Optional
6
- @returns govcy details html
6
+ @returns govcy warning html
7
7
  #}
8
8
  {% macro warning(params) -%}
9
9
  {#- Import localizer from utilities -#}
@@ -26,7 +26,7 @@ To use:
26
26
  'errorMessage','select','textElement','htmlElement','textInput','radios','checkboxes',
27
27
  'fileInput','fileView','backLink','tag','table', 'summaryList', 'textArea','markdown',
28
28
  'panel', 'datePicker','dateInput', 'taskList', 'errorSummary', 'details', 'stepByStepStatic',
29
- 'progressList', 'userName', 'warning'] -%}
29
+ 'progressList', 'userName', 'warning','multipleThingsTable', 'inset'] -%}
30
30
  {%- set macroCallerBlocks = ['formControl','form','fieldset'] -%}
31
31
  {%- macro govcyElement(component, params) -%}
32
32
  {#- Simple blocks -#}
@@ -155,6 +155,14 @@ To use this template you need to pass the following data:
155
155
  dl.govcy-summary-list-row-internal:not(:first-of-type) {
156
156
  margin-top: 0.5rem !important;
157
157
  }
158
+
159
+ .list-inline-item:not(:last-child) {
160
+ margin-right: 0 !important;
161
+ }
162
+ .list-inline-item:not(:first-child) {
163
+ margin-left: .5rem;
164
+ }
165
+
158
166
  </style>
159
167
  <title>{% if pageData.title %}{{ govcyLocalizeContent(pageData.title, site.lang) }} - {% endif %}{% if site.title %}{{ govcyLocalizeContent(site.title, site.lang) }} - {% endif %}gov.cy</title>
160
168
  <meta name="description" content="{{ govcyLocalizeContent(site.description, site.lang) }}">