@gov-cy/govcy-frontend-renderer 1.0.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.
- package/LICENSE +21 -0
- package/README.md +447 -0
- package/dist/index.cjs +13133 -0
- package/dist/index.mjs +13130 -0
- package/package.json +53 -0
- package/src/njk/elements/backLink.njk +15 -0
- package/src/njk/elements/button.njk +18 -0
- package/src/njk/elements/checkboxes.njk +143 -0
- package/src/njk/elements/errorMessage.njk +20 -0
- package/src/njk/elements/fieldset.njk +27 -0
- package/src/njk/elements/fileInput.njk +39 -0
- package/src/njk/elements/fileView.njk +34 -0
- package/src/njk/elements/form.njk +24 -0
- package/src/njk/elements/formControl.njk +29 -0
- package/src/njk/elements/hint.njk +12 -0
- package/src/njk/elements/htmlElement.njk +13 -0
- package/src/njk/elements/label.njk +24 -0
- package/src/njk/elements/legend.njk +22 -0
- package/src/njk/elements/radios.njk +182 -0
- package/src/njk/elements/select.njk +59 -0
- package/src/njk/elements/summaryList.njk +149 -0
- package/src/njk/elements/table.njk +134 -0
- package/src/njk/elements/tag.njk +14 -0
- package/src/njk/elements/textArea.njk +75 -0
- package/src/njk/elements/textElement.njk +23 -0
- package/src/njk/elements/textInput.njk +72 -0
- package/src/njk/govcyElement.njk +46 -0
- package/src/njk/layouts/govcyBase.njk +143 -0
- package/src/njk/utilities/govcyUtilities.njk +36 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
{# radio item
|
|
2
|
+
@param {object} params The parent parameters
|
|
3
|
+
@param {boolean} isInline Is the radio inline type? Optional, default is false. Can be true,false
|
|
4
|
+
@param {int} index The index number in the items array
|
|
5
|
+
@param {string} lang The language used. Can be 'en','el'.
|
|
6
|
+
@param {object} item The item object
|
|
7
|
+
i.e.
|
|
8
|
+
item : {
|
|
9
|
+
type: "or",
|
|
10
|
+
altOrText: {en:"If not",el:"Αν όχι"},
|
|
11
|
+
value: "maybe",
|
|
12
|
+
hint: {en:"We want you to be absolutely sure",el:"Θέλουμε να είστε απολύτως σίγουροι"},
|
|
13
|
+
text: {en:"Maybe",el:"Ίσως"}
|
|
14
|
+
}
|
|
15
|
+
@param {string} item.type The item type. Can be empty,'or','and'. Optional, default is empty
|
|
16
|
+
@param {string} item.value The value of the radio.
|
|
17
|
+
@param {object} item.text The label of the radio. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
18
|
+
@param {object} item.hint The hint of the radio. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
19
|
+
@param {object} item.altAndText The and text. Optional, default is `{en:"And",el:"Και"}
|
|
20
|
+
@param {object} item.altOrText The or text. Optional, default is `{en:"Or",el:"Ή"}
|
|
21
|
+
@param {array} item.conditionalElements The conditional elements for this radio item. Optional. This will be an array of elements.
|
|
22
|
+
@param {boolean} item.conditionalHasErrors The conditional elements for this radio item has error. Optional.
|
|
23
|
+
i.e. `[
|
|
24
|
+
{element:"button",params:{text:{en:"Button 1",el:"Κουμπί 1"},lang:"en",id:"govcy-test-23b"} },
|
|
25
|
+
{element:"button",params:{text:{en:"Button 2",el:"Κουμπί 2"},variant:'secondary',lang:"en",id:"govcy-test-23c"} }
|
|
26
|
+
]
|
|
27
|
+
@returns govcy radio item html
|
|
28
|
+
#}
|
|
29
|
+
{%- macro _radioItem(params, item, isInline, index, lang) %}
|
|
30
|
+
{#- Import localizer from utilities -#}
|
|
31
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute, govcyElementsFromArray -%}
|
|
32
|
+
{%- from "./hint.njk" import hint -%}
|
|
33
|
+
{%- from "./label.njk" import label -%}
|
|
34
|
+
{#- set default values -#}
|
|
35
|
+
{%- set isInline = isInline | default(false) -%}
|
|
36
|
+
{#- set language labels -#}
|
|
37
|
+
{#- set 'or' labels -#}
|
|
38
|
+
{%- if item.altOrText -%}
|
|
39
|
+
{%- set orText -%} {{- govcyLocalizeContent(item.altOrText, lang) -}}{%- endset -%}
|
|
40
|
+
{%- else -%}
|
|
41
|
+
{%- set orText -%} {{- govcyLocalizeContent({en:'Or',el:'Ή'}, lang) -}}{%- endset -%}
|
|
42
|
+
{%- endif -%}
|
|
43
|
+
{#- set 'and' labels -#}
|
|
44
|
+
{%- if item.altAndText -%}
|
|
45
|
+
{%- set andText -%} {{- govcyLocalizeContent(item.altAndText, lang) -}}{%- endset -%}
|
|
46
|
+
{%- else -%}
|
|
47
|
+
{%- set andText -%} {{- govcyLocalizeContent({en:'And',el:'Και'}, lang) -}}{%- endset -%}
|
|
48
|
+
{%- endif -%}
|
|
49
|
+
{#- set option id -#}
|
|
50
|
+
{% set optionId = params.id ~ '-option-' ~ index %}
|
|
51
|
+
{#- set hint id -#}
|
|
52
|
+
{%- if item.hint -%}
|
|
53
|
+
{%- set hintId = [optionId, "-hint"] | join -%}
|
|
54
|
+
{%- else -%}
|
|
55
|
+
{%- set hintId = '' -%}
|
|
56
|
+
{%- endif -%}
|
|
57
|
+
{#- set conditional id -#}
|
|
58
|
+
{%- if item.conditionalElements -%}
|
|
59
|
+
{%- set conditionalElementsId = [optionId, "-conditional"] | join -%}
|
|
60
|
+
{%- set conditionalLabel = govcyLocalizeContent({en:"This option expands and has more questions,",el:"Αυτή η επιλογή επεκτείνεται και έχει περισσότερες ερωτήσεις,"}, lang) -%}
|
|
61
|
+
{%- else -%}
|
|
62
|
+
{%- set conditionalElementsId = '' -%}
|
|
63
|
+
{%- set conditionalLabel = '' -%}
|
|
64
|
+
{%- endif -%}
|
|
65
|
+
{# depending on the type, render html and set label#}
|
|
66
|
+
{%- if item.type == 'or' -%}
|
|
67
|
+
<p class="govcy-ml-3 govcy-mb-3{% if isInline %} govcy-d-sm-inline-block govcy-mr-3{% endif %}">{{ orText }}</p>
|
|
68
|
+
{%- set label -%}
|
|
69
|
+
<span class="govcy-visually-hidden-error">{{ orText }}, </span> {{- govcyLocalizeContent(item.text, lang) -}}
|
|
70
|
+
{%- endset -%}
|
|
71
|
+
{%- elif item.type == 'and' -%}
|
|
72
|
+
<p class="govcy-ml-3 govcy-mb-3{% if isInline %} govcy-d-sm-inline-block govcy-mr-3{% endif %}">{{ andText }}</p>
|
|
73
|
+
{%- set label -%}
|
|
74
|
+
<span class="govcy-visually-hidden-error">{{ andText }}, </span> {{- govcyLocalizeContent(item.text, lang) -}}
|
|
75
|
+
{%- endset -%}
|
|
76
|
+
{% else %}
|
|
77
|
+
{%- set label -%}{{- govcyLocalizeContent(item.text, lang) -}}{%- endset -%}
|
|
78
|
+
{%- endif -%}
|
|
79
|
+
{#- render radio -#}
|
|
80
|
+
<div class="govcy-radio{% if isInline %} govcy-d-sm-inline-block{% endif %}">
|
|
81
|
+
<input class="govcy-radio-input" name="{{ params.name }}" value="{{item.value}}" type="radio" id="{{ optionId }}" {% if item.hint%} aria-describedby="{{hintId}}"{% endif %}{% if item.conditionalElements %} data-aria-controls="{{conditionalElementsId}}"{% endif %}>
|
|
82
|
+
<label class="govcy-label" for="{{ optionId }}">{% if item.conditionalElements %} <span class="govcy-visually-hidden">{{conditionalLabel}}</span>{% endif %}{{ label | safe }}</label>
|
|
83
|
+
{#- {% call govcyLabel({label:label, for:optionId, isPrimary:false, isHTML:true, lang:lang}) %}{% endcall %} -#}
|
|
84
|
+
{% call hint({hint:item.hint, id:hintId, lang:lang}) %}{% endcall %}
|
|
85
|
+
</div>
|
|
86
|
+
{#- conditional elements -#}
|
|
87
|
+
{%- if item.conditionalElements %}
|
|
88
|
+
{#- Transform conditional elements, add hideFormControlError -#}
|
|
89
|
+
{%- set updatedConditionalElements = [] -%}
|
|
90
|
+
{%- for element in item.conditionalElements -%}
|
|
91
|
+
{%- set updatedElement = element | merge({
|
|
92
|
+
params: element.params | merge({"hideFormControlError": true})
|
|
93
|
+
}) -%}
|
|
94
|
+
{%- set updatedConditionalElements = updatedConditionalElements.concat([updatedElement]) -%}
|
|
95
|
+
{%- endfor -%}
|
|
96
|
+
<style>
|
|
97
|
+
.govcy-radio__conditional label,
|
|
98
|
+
.govcy-radio__conditional legend {
|
|
99
|
+
font-size: 1rem !important;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
<div class="govcy-form-control{% if item.conditionalHasErrors %} govcy-form-control-error{% else %} govcy-form-control-hint{% endif %} govcy-pl-4 govcy-ml-5 govcy-radio__conditional govcy-radio__conditional--hidden" id="{{conditionalElementsId}}">
|
|
103
|
+
{{ govcyElementsFromArray(updatedConditionalElements, params.lang) }}
|
|
104
|
+
</div>
|
|
105
|
+
{%- endif -%}
|
|
106
|
+
{%- endmacro %}
|
|
107
|
+
{# radio
|
|
108
|
+
@param {object} legend The legend text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
109
|
+
@param {string} id The id prefix for the options. Will escape text.
|
|
110
|
+
@param {string} name The name used in radio. Will escape text.
|
|
111
|
+
@param {string} hint The hint text. Optional. Will escape text
|
|
112
|
+
@param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
|
|
113
|
+
@param {boolean} isInline Are the radios inline type? Optional, default is false. Can be true,false
|
|
114
|
+
@param {string} classes Additional classes to add to the outer fieldset. Optional
|
|
115
|
+
@param {object} error If not empty there is an error message and displays the error variant. Optional, default is ''. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
116
|
+
@param {boolean} hideFormControlError If true, hides the form control error (red line on the left). Mostly used in conditional radio elements. Optional
|
|
117
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
118
|
+
@param {array} items The array of items to turn onto radio
|
|
119
|
+
i.e. `[
|
|
120
|
+
{
|
|
121
|
+
value: "yes",
|
|
122
|
+
text: {en:"Yes",el:"Ναι"}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
value: "no",
|
|
126
|
+
text: {en:"No",el:"Όχι"}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: "or",
|
|
130
|
+
altOrText: {en:"If not",el:"Αν όχι"},
|
|
131
|
+
value: "maybe",
|
|
132
|
+
hint: {en:"We want you to be absolutely sure",el:"Θέλουμε να είστε απολύτως σίγουροι"},
|
|
133
|
+
text: {en:"Maybe",el:"Ίσως"}
|
|
134
|
+
}
|
|
135
|
+
]`
|
|
136
|
+
@returns govcy radios html
|
|
137
|
+
#}
|
|
138
|
+
{% macro radios(params) -%}
|
|
139
|
+
{#- set default values -#}
|
|
140
|
+
{%- set isPageHeading = params.isPageHeading | default(false) -%}
|
|
141
|
+
{%- set isInline = params.isInline | default(false) -%}
|
|
142
|
+
{#- legend, id and name are mandatory -#}
|
|
143
|
+
{%- if params.legend and params.id and params.name -%}
|
|
144
|
+
{%- from "./fieldset.njk" import fieldset -%}
|
|
145
|
+
{%- from "./hint.njk" import hint -%}
|
|
146
|
+
{%- from "./legend.njk" import legend -%}
|
|
147
|
+
{%- from "./errorMessage.njk" import errorMessage -%}
|
|
148
|
+
{%- from "./formControl.njk" import formControl -%}
|
|
149
|
+
{#- set hint id -#}
|
|
150
|
+
{%- if params.hint -%}
|
|
151
|
+
{%- set hintId = [params.id, "-hint"] | join -%}
|
|
152
|
+
{%- else -%}
|
|
153
|
+
{%- set hintId = '' -%}
|
|
154
|
+
{%- endif -%}
|
|
155
|
+
{#- set error id -#}
|
|
156
|
+
{%- if params.error -%}
|
|
157
|
+
{%- set errorId = [params.id, "-error"] | join -%}
|
|
158
|
+
{%- else -%}
|
|
159
|
+
{%- set errorId = '' -%}
|
|
160
|
+
{%- endif -%}
|
|
161
|
+
{# set aria described by #}
|
|
162
|
+
{%- if params.error or params.hint -%}
|
|
163
|
+
{% set ariaDescribedBy = hintId ~ ' ' ~ errorId %}
|
|
164
|
+
{%- else -%}
|
|
165
|
+
{% set ariaDescribedBy = '' %}
|
|
166
|
+
{%- endif -%}
|
|
167
|
+
{% call fieldset({ariaDescribedby:ariaDescribedBy,classes:params.classes, lang:params.lang}) %}
|
|
168
|
+
{% call legend({legend:params.legend, isPageHeading:isPageHeading,lang:params.lang}) %}{% endcall %}
|
|
169
|
+
{% call formControl({isError: false if params.hideFormControlError else params.error}) %}
|
|
170
|
+
{% call hint({hint:params.hint, id:hintId,lang:params.lang}) %}{% endcall %}
|
|
171
|
+
{#- render error message -#}
|
|
172
|
+
{% call errorMessage({message:params.error,id:errorId,lang:params.lang}) %}{% endcall %}
|
|
173
|
+
{# for each item render checkbox item #}
|
|
174
|
+
{%- for item in params.items -%}
|
|
175
|
+
{%- if item -%}
|
|
176
|
+
{{- _radioItem(params, item, isInline, loop.index, params.lang) -}}
|
|
177
|
+
{%- endif -%}
|
|
178
|
+
{%- endfor -%}
|
|
179
|
+
{% endcall %}
|
|
180
|
+
{% endcall %}
|
|
181
|
+
{%- endif -%}
|
|
182
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
{# select
|
|
3
|
+
@param {object} label The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
4
|
+
@param {string} id The id of the select. Will escape text.
|
|
5
|
+
@param {string} name The name of the select. Will escape text.
|
|
6
|
+
@param {array} items The array of items to turn onto select options. Array contains object with `text` and `value`. i.e. `{"text":{en:"Cyprus",el:"Κύπρος"},"value":"cy"}`
|
|
7
|
+
@param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
8
|
+
@param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
|
|
9
|
+
@param {string} classes Additional classes to add to the outer `govcy-form-control` container. Optional
|
|
10
|
+
@param {object} error If not empty there is an error message and displays the error variant. Optional, default is ''. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
11
|
+
@param {boolean} hideFormControlError If true, hides the form control error (red line on the left). Mostly used in conditional radio elements. Optional
|
|
12
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
13
|
+
@returns govcy select html
|
|
14
|
+
#}
|
|
15
|
+
{% macro select(params) -%}
|
|
16
|
+
{#- set default values -#}
|
|
17
|
+
{%- set isPageHeading = params.isPageHeading | default(false) -%}
|
|
18
|
+
{#- legend, id and name are mandatory -#}
|
|
19
|
+
{%- if params.label and params.id and params.name -%}
|
|
20
|
+
{#- Import localizer from utilities -#}
|
|
21
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
22
|
+
{%- from "./hint.njk" import hint -%}
|
|
23
|
+
{%- from "./label.njk" import label -%}
|
|
24
|
+
{%- from "./errorMessage.njk" import errorMessage -%}
|
|
25
|
+
{%- from "./formControl.njk" import formControl -%}
|
|
26
|
+
{#- set hint id -#}
|
|
27
|
+
{%- if params.hint -%}
|
|
28
|
+
{%- set hintId = [params.id, "-hint"] | join -%}
|
|
29
|
+
{%- else -%}
|
|
30
|
+
{%- set hintId = '' -%}
|
|
31
|
+
{%- endif -%}
|
|
32
|
+
{#- set error id -#}
|
|
33
|
+
{%- if params.error -%}
|
|
34
|
+
{%- set errorId = [params.id, "-error"] | join -%}
|
|
35
|
+
{%- else -%}
|
|
36
|
+
{%- set errorId = '' -%}
|
|
37
|
+
{%- endif -%}
|
|
38
|
+
{# set aria described by #}
|
|
39
|
+
{%- if params.error or params.hint -%}
|
|
40
|
+
{% set ariaDescribedBy = hintId ~ ' ' ~ errorId %}
|
|
41
|
+
{%- else -%}
|
|
42
|
+
{% set ariaDescribedBy = '' %}
|
|
43
|
+
{%- endif -%}
|
|
44
|
+
{% call formControl({isError: false if params.hideFormControlError else params.error,classes:params.classes}) %}
|
|
45
|
+
{% call label({label:params.label, id:labelId, for:params.id, isPageHeading:isPageHeading, lang:params.lang}) %}{% endcall %}
|
|
46
|
+
{% call hint({hint:params.hint, id:hintId, lang:params.lang}) %}{% endcall %}
|
|
47
|
+
{#- render error message -#}
|
|
48
|
+
{% call errorMessage({message:params.error,id:errorId,lang:params.lang}) %}{% endcall %}
|
|
49
|
+
<select id="{{ params.id }}" name="{{ params.name }}" class="govcy-select{% if params.error %} govcy-select-error{% endif %}" {%if ariaDescribedBy %} aria-describedby="{{ ariaDescribedBy }}"{% endif%}{{ govcyLangAttribute(params.lang) }}>
|
|
50
|
+
{# for each item render checkbox item #}
|
|
51
|
+
{%- for item in params.items -%}
|
|
52
|
+
{%- if item.text -%}
|
|
53
|
+
<option value="{{ item.value }}">{{ govcyLocalizeContent(item.text, params.lang) }}</option>
|
|
54
|
+
{%- endif -%}
|
|
55
|
+
{%- endfor -%}
|
|
56
|
+
</select>
|
|
57
|
+
{% endcall %}
|
|
58
|
+
{%- endif -%}
|
|
59
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{# summaryList
|
|
2
|
+
@param {string} id The id prefix for the options. Will escape text.
|
|
3
|
+
@param {string} classes Additional classes to add to the outer fieldset. Optional
|
|
4
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
5
|
+
@param {int} entryCount (NOT TO BE USED BY USERS) The count of the entry to be used in a visually hidden text for screen readers when the list is an inner list. (used in https://gov-cy.github.io/govcy-design-system-docs/components/summary_list/#making-arrays-screen-reader-friendly). Optional
|
|
6
|
+
@param {Boolean} isInnerList (NOT TO BE USED BY USERS) Determines if the list is an inner list (used in https://gov-cy.github.io/govcy-design-system-docs/components/summary_list/#showing-complex-information). Optional
|
|
7
|
+
@param {array} items The array of items which contain elements
|
|
8
|
+
@param {string} item.key The item key. Will escape text.
|
|
9
|
+
@param {array} item.value The value. This will be an array of elements.
|
|
10
|
+
i.e. `
|
|
11
|
+
[
|
|
12
|
+
{
|
|
13
|
+
elements: [
|
|
14
|
+
{element:"htmlElement",params:{text:{en:"January",el:"Ιανουάριος"}} }
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
elements: [
|
|
19
|
+
{element:"htmlElement",params:{text:{en:"€85",el:"€85"}} }
|
|
20
|
+
],
|
|
21
|
+
classes: "govcy-text-end",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
elements: [
|
|
25
|
+
{element:"tag",params:{text:{en:"PAYED",el:"ΠΛΗΡΩΘΗΚΕ"}, classes:"govcy-tag-green"} }
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
`
|
|
30
|
+
@param {array} item.actions The array of actions objects.
|
|
31
|
+
i.e. `
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
text:{en:"Change",el:"Αλλαγή"},
|
|
35
|
+
href: "#",
|
|
36
|
+
classes: "govcy-link",
|
|
37
|
+
visuallyHiddenText: {en:"Date of birth",el:"Ημερομηνία γέννησης"}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
text:{en:"Remove",el:"Διαγραφή"},
|
|
41
|
+
href: "#",
|
|
42
|
+
visuallyHiddenText: {en:"Date of birth",el:"Ημερομηνία γέννησης"}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
`
|
|
46
|
+
@returns govcy summaryList html
|
|
47
|
+
#}
|
|
48
|
+
{% macro summaryList(params) -%}
|
|
49
|
+
{#- Import localizer from utilities -#}
|
|
50
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute, govcyElementsFromArray -%}
|
|
51
|
+
<dl {% if params.id %}id="{{ params.id }}" {% endif %}class="{% if not params.isInnerList %}govcy-summary-list{% else %}govcy-summary-list-row-internal{% endif %}{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
|
|
52
|
+
{#- Render visually hidden text for screen readers the entry number -#}
|
|
53
|
+
{%- if params.entryCount -%}
|
|
54
|
+
{%- set entryText = govcyLocalizeContent({en:"Entry",el:"Καταχώρηση"}, params.lang) -%}
|
|
55
|
+
<dt><span class="govcy-visually-hidden">{{ entryText }} {{ params.entryCount}}</span></dt>
|
|
56
|
+
{%- endif -%}
|
|
57
|
+
{%- for item in params.items %}
|
|
58
|
+
{% if not params.isInnerList %}<div class="govcy-summary-list-row">{% endif %}
|
|
59
|
+
{#- KEY -#}
|
|
60
|
+
<dt class="{% if not params.isInnerList %}govcy-summary-list-key{% else %}govcy-summary-list-key-internal{% endif %}">
|
|
61
|
+
{{ govcyLocalizeContent(item.key, params.lang) }}
|
|
62
|
+
{#- Render visually hidden text for screen readers the count of inner entries -#}
|
|
63
|
+
{%- if not params.isInnerList %}{{ _countSummaryListsRenderVisualyHidden(item.value, params.lang) }}{% endif -%}
|
|
64
|
+
</dt>
|
|
65
|
+
{#- VALUE -#}
|
|
66
|
+
<dd class="{% if not params.isInnerList %}govcy-summary-list-value{% else %}govcy-summary-list-value-internal{% endif %}">
|
|
67
|
+
{%- if item.value -%}
|
|
68
|
+
{{ _govcySummayListElementsFromArray(item.value, params.lang) }}
|
|
69
|
+
{%- elif item.actions -%}
|
|
70
|
+
{{ _summaryListActions(item.actions, params.lang) }}
|
|
71
|
+
{%- endif -%}
|
|
72
|
+
</dd>
|
|
73
|
+
{#- ACTIONS -#}
|
|
74
|
+
{%- if item.actions and item.value and not params.isInnerList -%}
|
|
75
|
+
<dd class="govcy-summary-list-actions">
|
|
76
|
+
{{ _summaryListActions(item.actions, params.lang) }}
|
|
77
|
+
</dd>
|
|
78
|
+
{%- endif %}
|
|
79
|
+
{% if not params.isInnerList %}</div>{% endif %}
|
|
80
|
+
{%- endfor %}
|
|
81
|
+
</dl>
|
|
82
|
+
{%- endmacro %}
|
|
83
|
+
{# summary list action item
|
|
84
|
+
@param {array} actions The array of actions objects.
|
|
85
|
+
i.e. `
|
|
86
|
+
[
|
|
87
|
+
{
|
|
88
|
+
text:{en:"Change",el:"Αλλαγή"},
|
|
89
|
+
href: "#",
|
|
90
|
+
visuallyHiddenText: {en:"Date of birth",el:"Ημερομηνία γέννησης"}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
text:{en:"Remove",el:"Διαγραφή"},
|
|
94
|
+
href: "#",
|
|
95
|
+
visuallyHiddenText: {en:"Date of birth",el:"Ημερομηνία γέννησης"}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
`
|
|
99
|
+
@param {string} lang The language used. Can be 'en','el'.
|
|
100
|
+
@returns govcy summary list actions html
|
|
101
|
+
#}
|
|
102
|
+
{%- macro _summaryListActions(actions,lang) %}
|
|
103
|
+
<ul class="list-inline govcy-my-0">
|
|
104
|
+
{%- for action in actions %}
|
|
105
|
+
<li class="list-inline-item">
|
|
106
|
+
{#- render href -#}
|
|
107
|
+
<a href="{% if action.href %}{{ action.href }}{% else %}#{% endif %}">
|
|
108
|
+
{#- render content -#}
|
|
109
|
+
{{ govcyLocalizeContent(action.text, lang) }}
|
|
110
|
+
{#- If visuallyHiddenText is set -#}
|
|
111
|
+
{%- if action.visuallyHiddenText %}
|
|
112
|
+
<span class="govcy-visually-hidden"> {{ govcyLocalizeContent(action.visuallyHiddenText, lang) }}</span>
|
|
113
|
+
{% endif -%}
|
|
114
|
+
</a>
|
|
115
|
+
</li>
|
|
116
|
+
{%- endfor %}
|
|
117
|
+
</ul>
|
|
118
|
+
{%- endmacro %}
|
|
119
|
+
{#- --------------------------------------- -#}
|
|
120
|
+
{#- render govcyElements from an array -#}
|
|
121
|
+
{%- macro _govcySummayListElementsFromArray(elements, lang) %}
|
|
122
|
+
{%- from "../govcyElement.njk" import govcyElement -%}
|
|
123
|
+
{%- set summaryListCount = 0 -%} {# Initialize a counter #}
|
|
124
|
+
{%- for element in elements -%}
|
|
125
|
+
{%- if lang and not element.params.lang -%}
|
|
126
|
+
{%- set params = element.params | merge({lang: lang}) -%}
|
|
127
|
+
{%- else -%}
|
|
128
|
+
{%- set params = element.params -%}
|
|
129
|
+
{%- endif -%}
|
|
130
|
+
{%- if element.element == "summaryList" %}
|
|
131
|
+
{%- set summaryListCount = summaryListCount + 1 -%} {# Increment the counter #}
|
|
132
|
+
{%- set params = params | merge({isInnerList: true}) -%}
|
|
133
|
+
{%- set params = params | merge({entryCount: summaryListCount}) -%}
|
|
134
|
+
{% endif -%}
|
|
135
|
+
{%- call govcyElement(element.element, params) %}{% endcall -%}
|
|
136
|
+
{%- endfor -%}
|
|
137
|
+
{%- endmacro %}
|
|
138
|
+
{#- --------------------------------------- -#}
|
|
139
|
+
{%- macro _countSummaryListsRenderVisualyHidden(elements, lang) -%}
|
|
140
|
+
{%- set totalCount = 0 -%}
|
|
141
|
+
{%- for item in elements -%}
|
|
142
|
+
{%- if item.element == "summaryList" -%}
|
|
143
|
+
{%- set totalCount = totalCount + 1 -%}
|
|
144
|
+
{%- endif -%}
|
|
145
|
+
{%- endfor -%}
|
|
146
|
+
{%- set entriesText = govcyLocalizeContent({en:"Entries",el:"Καταχωρήσεις"}, lang) -%}
|
|
147
|
+
{%- if totalCount > 0 %}<span class="govcy-visually-hidden">{{ totalCount }} {{ entriesText }}</span>{% endif -%}
|
|
148
|
+
{%- endmacro %}
|
|
149
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{# table
|
|
2
|
+
@param {string} id The id prefix for the options. Will escape text.
|
|
3
|
+
@param {string} classes Additional classes to add to the outer fieldset. Optional
|
|
4
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
5
|
+
@param {string} responsiveType The responsive type. Can be 'horisontal','vertical-no-headers', 'vertical-headers'. Optional.
|
|
6
|
+
@param {boolean} firstCellIsHeader Indicates if the first cell is a header. Optional.
|
|
7
|
+
@param {array} head The array of head
|
|
8
|
+
i.e. `
|
|
9
|
+
[
|
|
10
|
+
{
|
|
11
|
+
text:{en:"Month",el:"Μηνας"}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
text:{en:"Amount",el:"Ποσό"},
|
|
15
|
+
classes: "govcy-text-end",
|
|
16
|
+
colspan : 1,
|
|
17
|
+
rowspan : 1
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
text:{en:"Status",el:"Κατάσταση"}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
`
|
|
24
|
+
@param {array} rows The array of rows which contain elements
|
|
25
|
+
i.e. `
|
|
26
|
+
[
|
|
27
|
+
[
|
|
28
|
+
{
|
|
29
|
+
elements: [
|
|
30
|
+
{element:"htmlElement",params:{text:{en:"January",el:"Ιανουάριος"}} }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
elements: [
|
|
35
|
+
{element:"htmlElement",params:{text:{en:"€85",el:"€85"}} }
|
|
36
|
+
],
|
|
37
|
+
classes: "govcy-text-end",
|
|
38
|
+
colspan : 1,
|
|
39
|
+
rowspan : 1
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
elements: [
|
|
43
|
+
{element:"tag",params:{text:{en:"PAYED",el:"ΠΛΗΡΩΘΗΚΕ"}, classes:"govcy-tag-green"} }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
elements: [
|
|
50
|
+
{element:"htmlElement",params:{text:{en:"February",el:"Φεβάριος"}} }
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
elements: [
|
|
55
|
+
{element:"htmlElement",params:{text:{en:"€75",el:"€75"}} }
|
|
56
|
+
],
|
|
57
|
+
classes: "govcy-text-end"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
elements: [
|
|
61
|
+
{element:"tag",params:{text:{en:"PAYED",el:"ΔΕΝ ΠΛΗΡΩΘΗΚΕ"}, classes:"govcy-tag-orange"} }
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
]`
|
|
66
|
+
@returns govcy table html
|
|
67
|
+
#}
|
|
68
|
+
{% macro table(params) -%}
|
|
69
|
+
{#- Import localizer from utilities -#}
|
|
70
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
71
|
+
{%- from "../govcyElement.njk" import govcyElement -%}
|
|
72
|
+
{#- responsiveType horisontal -#}
|
|
73
|
+
{% if params.responsiveType == 'horisontal' %}<div class="govcy-table-responsive">{% endif %}
|
|
74
|
+
<table {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-table{% if params.responsiveType == 'vertical-headers' or params.responsiveType == 'vertical-no-headers' %} govcy-table-responsive-vertical{% endif %}{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
|
|
75
|
+
{#- render head -#}
|
|
76
|
+
{%- if params.head %}
|
|
77
|
+
<thead>
|
|
78
|
+
<tr>
|
|
79
|
+
{%- for head in params.head %}
|
|
80
|
+
<th{{ _cellAttributes(head) | safe }}>
|
|
81
|
+
{{ govcyLocalizeContent(head.text, params.lang) }}
|
|
82
|
+
</th>
|
|
83
|
+
{%- endfor %}
|
|
84
|
+
</tr>
|
|
85
|
+
</thead>
|
|
86
|
+
{%- endif %}
|
|
87
|
+
<tbody>
|
|
88
|
+
{#- render rows -#}
|
|
89
|
+
{%- for row in params.rows %}
|
|
90
|
+
{%- if row %}
|
|
91
|
+
<tr>
|
|
92
|
+
{% for cell in row -%}
|
|
93
|
+
{#- handle firstCellIsHeader -#}
|
|
94
|
+
{%- if loop.first and params.firstCellIsHeader -%}
|
|
95
|
+
<th scope="row"{{ _cellAttributes(cell) | safe }}>
|
|
96
|
+
{#- handle responsiveType == 'vertical-headers' -#}
|
|
97
|
+
{%- if params.responsiveType == 'vertical-headers' %}
|
|
98
|
+
<div class="govcy-d-md-none govcy-fw-bolder govcy-my-2">{{ govcyLocalizeContent(params.head[loop.index0].text, params.lang) }}</div>
|
|
99
|
+
{%- endif %}
|
|
100
|
+
{{ _cellElements(cell.elements,params.lang) }}
|
|
101
|
+
</th>
|
|
102
|
+
{%- else %}
|
|
103
|
+
<td{{ _cellAttributes(cell) | safe }}>
|
|
104
|
+
{%- if params.responsiveType == 'vertical-headers' %}
|
|
105
|
+
<div class="govcy-d-md-none govcy-fw-bolder govcy-my-2">{{ govcyLocalizeContent(params.head[loop.index0].text, params.lang) }}</div>
|
|
106
|
+
{%- endif %}
|
|
107
|
+
{{ _cellElements(cell.elements,params.lang) }}
|
|
108
|
+
</td>
|
|
109
|
+
{%- endif -%}
|
|
110
|
+
{%- endfor %}
|
|
111
|
+
</tr>
|
|
112
|
+
{%- endif -%}
|
|
113
|
+
{%- endfor %}
|
|
114
|
+
</tbody>
|
|
115
|
+
</table>
|
|
116
|
+
{% if params.responsiveType == 'horisontal' %}</div>{% endif %}
|
|
117
|
+
{%- endmacro %}
|
|
118
|
+
|
|
119
|
+
{#- render cell attributes like class colspan or rowspan -#}
|
|
120
|
+
{%- macro _cellAttributes(cell) %}
|
|
121
|
+
{%- if cell.classes %} class="{{ cell.classes }}"{% endif %}{%- if cell.colspan %} colspan="{{ cell.colspan }}"{% endif %}{%- if cell.rowspan %} rowspan="{{ cell.rowspan }}"{% endif %}
|
|
122
|
+
{%- endmacro %}
|
|
123
|
+
|
|
124
|
+
{#- render cell elements -#}
|
|
125
|
+
{%- macro _cellElements(elements, lang) %}
|
|
126
|
+
{%- for element in elements -%}
|
|
127
|
+
{%- if lang and not element.params.lang -%}
|
|
128
|
+
{%- set params = element.params | merge({lang: lang}) -%}
|
|
129
|
+
{%- else -%}
|
|
130
|
+
{%- set params = element.params -%}
|
|
131
|
+
{%- endif -%}
|
|
132
|
+
{%- call govcyElement(element.element, params) %}{% endcall -%}
|
|
133
|
+
{%- endfor -%}
|
|
134
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{# Tag
|
|
2
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
3
|
+
@param {object} text The button text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
4
|
+
@param {string} classes Additional classes to add to the button. Optional
|
|
5
|
+
@returns govcy tag html
|
|
6
|
+
#}
|
|
7
|
+
{% macro tag(params) -%}
|
|
8
|
+
{#- Import localizer from utilities -#}
|
|
9
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
10
|
+
{# text is mandatory #}
|
|
11
|
+
{%- if params.text -%}
|
|
12
|
+
<span class="govcy-tag{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>{{ govcyLocalizeContent(params.text, params.lang) }}</span>
|
|
13
|
+
{%- endif %}
|
|
14
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{# text Area
|
|
2
|
+
@param {object} label The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
3
|
+
@param {string} id The input id. Will escape text
|
|
4
|
+
@param {string} name The input name. Will escape text. Optional
|
|
5
|
+
@param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
6
|
+
@param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
|
|
7
|
+
@param {boolean} isSpellcheck true renders nothing, false renders spellcheck="false"? Optional, default is true. Can be true,false
|
|
8
|
+
@param {string} autocomplete The autocomplete attribute. Optional. Can be email, name, ...
|
|
9
|
+
@param {string} classes Additional classes to add to the outer div. Optional
|
|
10
|
+
@param {object} error If not empty there is an error message and displays the error variant. Optional, default is ''. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
|
|
11
|
+
@param {boolean} hideFormControlError If true, hides the form control error (red line on the left). Mostly used in conditional radio elements. Optional
|
|
12
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
13
|
+
@param {string} rows The rows attribute of the textarea. Optional, default is '5'
|
|
14
|
+
@param {object} characterCount The character count object. Optional. i.e. {"type":"char","max":150}
|
|
15
|
+
@param {string} characterCount.type The character count type. Optional, default is 'char'. Can be 'char' or 'word'
|
|
16
|
+
@param {int} characterCount.max The character count maxchars or maxwords. Default is 100
|
|
17
|
+
@returns govcy text Area
|
|
18
|
+
#}
|
|
19
|
+
{% macro textArea(params) -%}
|
|
20
|
+
{#- Import localizer from utilities -#}
|
|
21
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
22
|
+
{%- from "./formControl.njk" import formControl -%}
|
|
23
|
+
{%- from "./hint.njk" import hint -%}
|
|
24
|
+
{%- from "./label.njk" import label -%}
|
|
25
|
+
{%- from "./errorMessage.njk" import errorMessage -%}
|
|
26
|
+
{#- set default values -#}
|
|
27
|
+
{%- set isPageHeading = params.isPageHeading | default(false) -%}
|
|
28
|
+
{%- set isSpellcheck = params.isSpellcheck | default(false) -%}
|
|
29
|
+
{%- set autocomplete = params.autocomplete | default(false) -%}
|
|
30
|
+
{%- set rows = params.rows | default('5') -%}
|
|
31
|
+
{#- label and id are mandatory -#}
|
|
32
|
+
{%- if params.label and params.id -%}
|
|
33
|
+
{#- set hint label error ids -#}
|
|
34
|
+
{%- set hintId = [params.id, "-hint"] | join -%}
|
|
35
|
+
{%- set labelId = [params.id, "-label"] | join -%}
|
|
36
|
+
{%- set errorId = [params.id, "-error"] | join -%}
|
|
37
|
+
{%- set charactercountId = [params.id, "-char-count"] | join -%}
|
|
38
|
+
{#- set spellcheck to false if not empty -#}
|
|
39
|
+
{%- if isSpellcheck -%}
|
|
40
|
+
{%- set inputSpellcheck = 'spellcheck="true"' -%}
|
|
41
|
+
{%- else -%}
|
|
42
|
+
{%- set inputSpellcheck = 'spellcheck="false"' -%}
|
|
43
|
+
{%- endif -%}
|
|
44
|
+
{#- set autocomplete -#}
|
|
45
|
+
{%- if autocomplete -%}
|
|
46
|
+
{%- set inputAutocomplete %}autocomplete="{{ autocomplete | safe }}"{% endset -%}
|
|
47
|
+
{%- else -%}
|
|
48
|
+
{%- set inputAutocomplete = '' -%}
|
|
49
|
+
{%- endif -%}
|
|
50
|
+
{% call formControl({isError: false if params.hideFormControlError else params.error,classes:params.classes,lang:params.lang}) %}
|
|
51
|
+
{#- render label -#}
|
|
52
|
+
{% call label({label:params.label, id:labelId, for:params.id, isPageHeading:isPageHeading, lang:params.lang}) %}{% endcall %}
|
|
53
|
+
{#- render hint -#}
|
|
54
|
+
{% call hint({hint:params.hint,id:hintId, lang:params.lang}) %}{% endcall %}
|
|
55
|
+
{#- render error message -#}
|
|
56
|
+
{% call errorMessage({message:params.error,id:errorId, lang:params.lang}) %}{% endcall %}
|
|
57
|
+
{#- render input -#}
|
|
58
|
+
<textarea id="{{params.id}}"{% if params.name %} name="{{ params.name }}"{% endif %} rows="{{rows}}" {{ inputSpellcheck | safe }} {{ inputAutocomplete | safe }} class="govcy-text-area{% if params.error %} govcy-text-area-error{% endif %}"{% if params.hint or params.error or params.characterCount%} aria-describedby="{%- if params.characterCount -%}{{charactercountId}}{% endif %}{% if params.hint %} {{hintId}}{% endif %}{% if params.error %} {{errorId}}{% endif %}"{% endif %}></textarea>
|
|
59
|
+
{# character count #}
|
|
60
|
+
{%- if params.characterCount -%}
|
|
61
|
+
{%- set charactercountType = params.characterCount.type | default('char') -%}
|
|
62
|
+
{%- set charactercountMax = params.characterCount.max | default(100) -%}
|
|
63
|
+
{#- set language labels -#}
|
|
64
|
+
{%- set charRemaining = govcyLocalizeContent({en:"You have <span></span> characters remaining",el:"Έχετε <span></span> χαρακτήρες που απομένουν"}, params.lang, true) -%}
|
|
65
|
+
{%- set charExceeding = govcyLocalizeContent({en:"You have entered <span></span> characters more",el:"Έχετε περάσει <span></span> χαρακτήρες περισσότερους"}, params.lang, true) -%}
|
|
66
|
+
{%- set wordRemaining = govcyLocalizeContent({en:"You have <span></span> words remaining",el:"Έχετε <span></span> λέξεις που απομένουν"}, params.lang, true) -%}
|
|
67
|
+
{%- set wordsExceeding = govcyLocalizeContent({en:"You have entered <span></span> words more",el:"Έχετε περάσει <span></span> λέξεις περισσότερες"}, params.lang, true) -%}
|
|
68
|
+
<div id="{{ charactercountId }}" class="govcy-character-count" {%- if charactercountType=='word' -%} data-maxwords{%- else -%} data-maxchars{%- endif -%}="{{ charactercountMax }}">
|
|
69
|
+
<div class="govcy-character-remaining-counter">{%- if charactercountType=='word' -%}{{ wordRemaining | safe }}{%- else -%}{{ charRemaining | safe }}{%- endif -%}</div>
|
|
70
|
+
<div class="govcy-character-more-counter">{%- if charactercountType=='word' -%}{{ wordsExceeding | safe }}{%- else -%}{{ charExceeding | safe }}{%- endif -%}</div>
|
|
71
|
+
</div>
|
|
72
|
+
{%- endif -%}
|
|
73
|
+
{% endcall %}
|
|
74
|
+
{%- endif -%}
|
|
75
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{# textElement
|
|
2
|
+
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
3
|
+
@param {object} text The text. Will escape text, Example `{en:"Content",el:"Περιεχομένο"}`
|
|
4
|
+
@param {string} type The type of the element. Can be `p`,`h1`,`h2`,`h3`,`h4`. Default is `p`
|
|
5
|
+
@param {string} id The elemen't id. Will escape text. Optional
|
|
6
|
+
@param {string} classes Additional classes to add to the outer div. Optional
|
|
7
|
+
@returns html Elements with sanitzed html
|
|
8
|
+
#}
|
|
9
|
+
{% macro textElement(params) -%}
|
|
10
|
+
{# set default values #}
|
|
11
|
+
{%- set textType = params.type | default('p') -%}
|
|
12
|
+
{# text and type are mandatory #}
|
|
13
|
+
{%- if params.text -%}
|
|
14
|
+
{#- Import localizer from utilities -#}
|
|
15
|
+
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
16
|
+
{%- if textType == 'p' or textType == 'h1' or textType == 'h2' or textType == 'h3' or textType == 'h4' -%}
|
|
17
|
+
{%- set textTag = textType -%}
|
|
18
|
+
<{{ textType }}{% if params.id %} id="{{ params.id }}"{% endif %}{% if params.classes %} class="{{ params.classes }}"{% endif %}{{ govcyLangAttribute(params.lang) }}>
|
|
19
|
+
{{ govcyLocalizeContent(params.text, params.lang) }}
|
|
20
|
+
</{{ textType }}>
|
|
21
|
+
{%- endif -%}
|
|
22
|
+
{%- endif -%}
|
|
23
|
+
{%- endmacro %}
|