@gov-cy/govcy-frontend-renderer 1.11.0 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-frontend-renderer",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
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",
@@ -20,6 +20,8 @@
20
20
  @returns govcy checkbox item html
21
21
  #}
22
22
  {%- macro _checkboxItem(params, item, index, lang) %}
23
+ {#- Normalize value as array -#}
24
+ {%- set checkboxValues = [] if params.value is not defined else (params.value if params.value is iterable else [params.value]) -%}
23
25
  {#- Import localizer from utilities -#}
24
26
  {%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
25
27
  {%- from "./hint.njk" import hint -%}
@@ -61,7 +63,7 @@
61
63
  {%- endif -%}
62
64
  {#- render checkbox -#}
63
65
  <div class="govcy-checkbox">
64
- <input class="govcy-checkbox-input" name="{{ params.name }}" value="{{item.value}}" type="checkbox" id="{{ optionId }}" {% if item.hint%} aria-describedby="{{hintId}}"{% endif %}>
66
+ <input class="govcy-checkbox-input" name="{{ params.name }}"{% if item.value in checkboxValues %} checked{% endif %} value="{{item.value}}" type="checkbox" id="{{ optionId }}" {% if item.hint%} aria-describedby="{{hintId}}"{% endif %}>
65
67
  <label class="govcy-label" for="{{ optionId }}">{{ label | safe }}</label>
66
68
  {#- {% call govcyLabel({label:label, for:optionId, isPrimary:false, isHTML:true, lang:lang}) %}{% endcall %} -#}
67
69
  {% call hint({hint:item.hint, id:hintId, lang:lang}) %}{% endcall %}
@@ -70,7 +72,8 @@
70
72
  {# checkbox
71
73
  @param {object} legend The legend text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
72
74
  @param {string} id The id prefix for the options. Will escape text.
73
- @param {string} name The name used in checkbox. Will escape text.
75
+ @param {string} name The name used in checkbox. Will escape text.
76
+ @param {array|string} value The pre-selected values for checkboxes. If a string is passed, it means only one checkbox is selected, otherwise it needs to be an array of strings. Optional
74
77
  @param {string} hint The hint text. Optional. Will escape text
75
78
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
76
79
  @param {string} classes Additional classes to add to the outer fieldset. Optional
@@ -3,6 +3,9 @@
3
3
  @param {object} legend The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
4
4
  @param {string} id The id of the dateInput parts. For example `id_day`, `id_month` and `id_year`. Will escape text.
5
5
  @param {string} name The name of the dateInput parts. For example `name_day`, `name_month` and `name_year` . Will escape text.
6
+ @param {string} dayValue The pre-filled day value. Will escape text. Optional.
7
+ @param {string} monthValue The pre-filled month value. Must be one of 1,2,3,4,5,6,7,8,9,10,11,12. Optional.
8
+ @param {string} yearValue The pre-filled year value. Will escape text. Optional.
6
9
  @param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
7
10
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
8
11
  @param {string} classes Additional classes to add to the outer `govcy-form-control` container. Optional
@@ -73,29 +76,29 @@
73
76
  <div class="govcy-d-flex govcy-flex-wrap"{{ govcyLangAttribute(params.lang) }}>
74
77
  <div class="govcy-d-block govcy-mr-3">
75
78
  <label class="govcy-label govcy-mb-1 govcy-fw-normal govcy-mb-2" for="{{ params.id }}_day">{{ dayLabel }}</label>
76
- <input id="{{ params.id }}_day" name="{{ params.name }}_day" class="govcy-text-input govcy-text-input-char_3{% if params.hasDayError %} govcy-text-input-error{% endif %}" maxlength="2" type="text" pattern="[0-9]*" inputmode="numeric"{% if params.isBirthday %} autocomplete="bday-day"{% endif %}>
79
+ <input id="{{ params.id }}_day" name="{{ params.name }}_day"{% if params.dayValue is defined %} value="{{ params.dayValue | default('') }}"{% endif %} class="govcy-text-input govcy-text-input-char_3{% if params.hasDayError %} govcy-text-input-error{% endif %}" maxlength="2" type="text" pattern="[0-9]*" inputmode="numeric"{% if params.isBirthday %} autocomplete="bday-day"{% endif %}>
77
80
  </div>
78
81
  <div class="govcy-d-block govcy-mr-3">
79
82
  <label class="govcy-label govcy-mb-1 govcy-fw-normal govcy-mb-2" for="{{ params.id }}_month">{{ monthLabel }}</label>
80
83
  <select id="{{ params.id }}_month" name="{{ params.name }}_month" class="govcy-select{% if params.hasMonthError %} govcy-select-error{% endif %}"{% if params.isBirthday %} autocomplete="bday-month"{% endif %}>
81
- <option value="" selected=""></option>
82
- <option value="1">{% if variant=="mobile" %}1{% else %}{{ monthValue1 }}{% endif %}</option>
83
- <option value="2">{% if variant=="mobile" %}2{% else %}{{ monthValue2 }}{% endif %}</option>
84
- <option value="3">{% if variant=="mobile" %}3{% else %}{{ monthValue3 }}{% endif %}</option>
85
- <option value="4">{% if variant=="mobile" %}4{% else %}{{ monthValue4 }}{% endif %}</option>
86
- <option value="5">{% if variant=="mobile" %}5{% else %}{{ monthValue5 }}{% endif %}</option>
87
- <option value="6">{% if variant=="mobile" %}6{% else %}{{ monthValue6 }}{% endif %}</option>
88
- <option value="7">{% if variant=="mobile" %}7{% else %}{{ monthValue7 }}{% endif %}</option>
89
- <option value="8">{% if variant=="mobile" %}8{% else %}{{ monthValue8 }}{% endif %}</option>
90
- <option value="9">{% if variant=="mobile" %}9{% else %}{{ monthValue9 }}{% endif %}</option>
91
- <option value="10">{% if variant=="mobile" %}10{% else %}{{ monthValue10 }}{% endif %}</option>
92
- <option value="11">{% if variant=="mobile" %}11{% else %}{{ monthValue11 }}{% endif %}</option>
93
- <option value="12">{% if variant=="mobile" %}12{% else %}{{ monthValue12 }}{% endif %}</option>
84
+ <option value=""></option>
85
+ <option value="1"{% if params.monthValue == "1" %} selected{% endif %}>{% if variant=="mobile" %}1{% else %}{{ monthValue1 }}{% endif %}</option>
86
+ <option value="2"{% if params.monthValue == "2" %} selected{% endif %}>{% if variant=="mobile" %}2{% else %}{{ monthValue2 }}{% endif %}</option>
87
+ <option value="3"{% if params.monthValue == "3" %} selected{% endif %}>{% if variant=="mobile" %}3{% else %}{{ monthValue3 }}{% endif %}</option>
88
+ <option value="4"{% if params.monthValue == "4" %} selected{% endif %}>{% if variant=="mobile" %}4{% else %}{{ monthValue4 }}{% endif %}</option>
89
+ <option value="5"{% if params.monthValue == "5" %} selected{% endif %}>{% if variant=="mobile" %}5{% else %}{{ monthValue5 }}{% endif %}</option>
90
+ <option value="6"{% if params.monthValue == "6" %} selected{% endif %}>{% if variant=="mobile" %}6{% else %}{{ monthValue6 }}{% endif %}</option>
91
+ <option value="7"{% if params.monthValue == "7" %} selected{% endif %}>{% if variant=="mobile" %}7{% else %}{{ monthValue7 }}{% endif %}</option>
92
+ <option value="8"{% if params.monthValue == "8" %} selected{% endif %}>{% if variant=="mobile" %}8{% else %}{{ monthValue8 }}{% endif %}</option>
93
+ <option value="9"{% if params.monthValue == "9" %} selected{% endif %}>{% if variant=="mobile" %}9{% else %}{{ monthValue9 }}{% endif %}</option>
94
+ <option value="10"{% if params.monthValue == "10" %} selected{% endif %}>{% if variant=="mobile" %}10{% else %}{{ monthValue10 }}{% endif %}</option>
95
+ <option value="11"{% if params.monthValue == "11" %} selected{% endif %}>{% if variant=="mobile" %}11{% else %}{{ monthValue11 }}{% endif %}</option>
96
+ <option value="12"{% if params.monthValue == "12" %} selected{% endif %}>{% if variant=="mobile" %}12{% else %}{{ monthValue12 }}{% endif %}</option>
94
97
  </select>
95
98
  </div>
96
99
  <div class="govcy-d-block govcy-mr-3">
97
100
  <label class="govcy-label govcy-mb-1 govcy-fw-normal govcy-mb-2" for="{{ params.id }}_year">{{ yearLabel }}</label>
98
- <input id="{{ params.id }}_year" name="{{ params.name }}_year" class="govcy-text-input govcy-text-input-char_6{% if params.hasYearError %} govcy-text-input-error{% endif %}" maxlength="4" type="text" pattern="[0-9]*" inputmode="numeric"{% if params.isBirthday %} autocomplete="bday-year"{% endif %}>
101
+ <input id="{{ params.id }}_year" name="{{ params.name }}_year"{% if params.yearValue is defined %} value="{{ params.yearValue | default('') }}"{% endif %} class="govcy-text-input govcy-text-input-char_6{% if params.hasYearError %} govcy-text-input-error{% endif %}" maxlength="4" type="text" pattern="[0-9]*" inputmode="numeric"{% if params.isBirthday %} autocomplete="bday-year"{% endif %}>
99
102
  </div>
100
103
  </div>
101
104
  {% endcall %}
@@ -3,6 +3,7 @@
3
3
  @param {object} label The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
4
4
  @param {string} id The id of the datePicker. Will escape text.
5
5
  @param {string} name The name of the datePicker. Will escape text.
6
+ @param {string} value The value of the input. Will set this value if it is a valid date. The date should be in the format `YYYY-MM-DD`. Optional
6
7
  @param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
7
8
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
8
9
  @param {string} classes Additional classes to add to the outer `govcy-form-control` container. Optional
@@ -47,7 +48,7 @@
47
48
  {% call hint({hint:params.hint, id:hintId, lang:params.lang}) %}{% endcall %}
48
49
  {#- render error message -#}
49
50
  {% call errorMessage({message:params.error,id:errorId,lang:params.lang}) %}{% endcall %}
50
- <div class="govcy-date-picker"{% if params.dataMinDate %} data-min-date="{{ params.dataMinDate }}"{% endif %}{% if params.dataMaxDate %} data-max-date="{{ params.dataMaxDate }}"{% endif %}>
51
+ <div class="govcy-date-picker"{% if params.dataMinDate %} data-min-date="{{ params.dataMinDate }}"{% endif %}{% if params.dataMaxDate %} data-max-date="{{ params.dataMaxDate }}"{% endif %}{% if params.value %} data-default-value="{{ params.value | default('') }}"{% endif %}>
51
52
  <input type="text" class="govcy-text-input {% if params.error %} govcy-text-input-error{% endif %}"
52
53
  id="{{ params.id }}"
53
54
  name="{{ params.name }}"
@@ -0,0 +1,185 @@
1
+ {# progressList
2
+ @param {string} lang The language used. Can be 'en','el'. Optional.
3
+ @param {int} current The current step number.
4
+ @param {int} total The total number of steps.
5
+ @param {array} labels if defined, will render the labels inside the progress list. Optional.
6
+ i.e. `[
7
+ {"text":{"en":"Step 1","el":"Βήμα 1"} },
8
+ {"text":{"en":"Step 2","el":"Βήμα 2"} },
9
+ {"text":{"en":"Step 3","el":"Βήμα 3"} },
10
+ {"text":{"en":"Step 4","el":"Βήμα 4"} },
11
+ {"text":{"en":"Step 5","el":"Βήμα 5"} }
12
+ ]`
13
+ @param {boolean} showSteps. Whether to show the steps or not. Optional, default is false. Can be true,false
14
+ @param {string} completedLabel The completed label text. Optional. Will escape text. Example `{en:"Completed",el:"Ολοκληρώθηκε"}`
15
+ @param {string} notCompletedLabel The not completed label text. Optional. Will escape text. Example `{en:"Not completed",el:"Δεν ολοκληρώθηκε"}`
16
+ @param {string} stepLabel The step label text. Optional. Will escape text. Example `{en:"Step",el:"Βήμα"}`
17
+ @param {string} ofLabel The of label text. Optional. Will escape text. Example `{en:"of",el:"από"}`
18
+ @param {string} id The label id. Will escape text
19
+ @param {string} classes Additional classes to add to the outer div. Optional
20
+ @returns govcy progressList html
21
+ #}
22
+ {% macro progressList(params) -%}
23
+ {#- Import localizer from utilities -#}
24
+ {%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
25
+ {#- set default values -#}
26
+ {%- set showSteps = params.showSteps | default(false) -%}
27
+ {%- set current = params.current | int -%}
28
+ {%- set total = params.total | int -%}
29
+ {#- set completed label -#}
30
+ {%- if params.completedLabel -%}
31
+ {%- set completedLabel -%} {{- govcyLocalizeContent(params.completedLabel, params.lang) -}}{%- endset -%}
32
+ {%- else -%}
33
+ {%- set completedLabel -%} {{- govcyLocalizeContent({en:"Completed",el:"Ολοκληρώθηκε"}, params.lang) -}}{%- endset -%}
34
+ {%- endif -%}
35
+ {#- set not completed label -#}
36
+ {%- if params.notCompletedLabel -%}
37
+ {%- set notCompletedLabel -%} {{- govcyLocalizeContent(params.notCompletedLabel, params.lang) -}}{%- endset -%}
38
+ {%- else -%}
39
+ {%- set notCompletedLabel -%} {{- govcyLocalizeContent({en:"Not completed",el:"Δεν ολοκληρώθηκε"}, params.lang) -}}{%- endset -%}
40
+ {%- endif -%}
41
+ {#- set step label -#}
42
+ {%- if params.stepLabel -%}
43
+ {%- set stepLabel -%} {{- govcyLocalizeContent(params.stepLabel, params.lang) -}}{%- endset -%}
44
+ {%- else -%}
45
+ {%- set stepLabel -%} {{- govcyLocalizeContent({en:"Step",el:"Βήμα"}, params.lang) -}}{%- endset -%}
46
+ {%- endif -%}
47
+ {#- set of label -#}
48
+ {%- if params.ofLabel -%}
49
+ {%- set ofLabel -%} {{- govcyLocalizeContent(params.ofLabel, params.lang) -}}{%- endset -%}
50
+ {%- else -%}
51
+ {%- set ofLabel -%} {{- govcyLocalizeContent({en:"of",el:"από"}, params.lang) -}}{%- endset -%}
52
+ {%- endif -%}
53
+ {#- current and total are mandatory -#}
54
+ {%- if current and total %}
55
+ {#- style to be removed after included in the UDS -#}
56
+ <style>
57
+ .govcy-step-indicator {
58
+ margin-left: 0px;
59
+ margin-right: 0px;
60
+ margin-bottom: .5rem !important;
61
+ }
62
+ .govcy-step-indicator__segments {
63
+ display: flex;
64
+ list-style: none;
65
+ margin: 0px;
66
+ padding: 0px;
67
+ }
68
+
69
+ .govcy-step-indicator__segment {
70
+ flex: 1 1 0%;
71
+ margin-left: 1px;
72
+ margin-right: 1px;
73
+ max-width: 15rem;
74
+ min-height: 0.5rem;
75
+ position: relative;
76
+ }
77
+
78
+ .govcy-step-indicator__segment::after {
79
+ background-color: #A6A8AA;
80
+ content: "";
81
+ display: block;
82
+ height: 0.5rem;
83
+ left: 0px;
84
+ position: absolute;
85
+ right: 0px;
86
+ top: 0px;
87
+ }
88
+ .govcy-step-indicator__segment--complete::after {
89
+ background-color: #254355;
90
+ }
91
+ .govcy-step-indicator__segment--current::after {
92
+ background-color: #1D70B8;
93
+ }
94
+
95
+ /* Label */
96
+ .govcy-step-indicator__label {
97
+ padding-left: 0.5rem;
98
+ padding-right: 0.5rem;
99
+ text-align: center;
100
+ color: #6d6e70;
101
+ line-height:1.1rem;
102
+ margin-top: calc(0.75rem);
103
+ }
104
+
105
+ .govcy-step-indicator__segment--complete .govcy-step-indicator__label {
106
+ color: #254355;
107
+ }
108
+
109
+ .govcy-step-indicator__segment--current .govcy-step-indicator__label {
110
+ color: #1D70B8;
111
+ font-weight: 700;
112
+ }
113
+
114
+ @media (min-width: 0px) {
115
+ .govcy-step-indicator__counter {
116
+ margin-bottom: .5rem !important;
117
+ }
118
+ .govcy-step-indicator__current-counter {
119
+ width: 24px;
120
+ height: 24px;
121
+ border:1px solid #1D70B8;
122
+ background: #1D70B8;
123
+ color:#fff;
124
+ border-radius: 9999px;
125
+ font-weight: 600;
126
+ display:inline-block;
127
+ text-align:center;
128
+ }
129
+ /* Hide label on small screens */
130
+ .govcy-step-indicator__label {
131
+ display:none;
132
+ }
133
+ }
134
+ @media (min-width: 768px) {
135
+ .govcy-step-indicator__counter {
136
+ font-size:20px;
137
+ line-height:19px;
138
+ margin-bottom: .5rem !important;
139
+ }
140
+ .govcy-step-indicator__current-counter {
141
+ border-radius:9999px;
142
+ border:1px solid #1D70B8;
143
+ background: #1D70B8;
144
+ color:#fff;
145
+ padding:10px;
146
+ line-height:19px;
147
+ font-weight:600;
148
+ font-size:20px;
149
+ display:inline-block;
150
+ width:40px;
151
+ height:40px;
152
+ text-align:center;
153
+ }
154
+ /* Show label on big screens */
155
+ .govcy-step-indicator__label {
156
+ display:block;
157
+ }
158
+ }
159
+ </style>
160
+ {%- if showSteps %}
161
+ <div {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-step-indicator{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
162
+ <ol class="govcy-step-indicator__segments">
163
+ {%- for i in range(1, total + 1) %}
164
+ <li class="govcy-step-indicator__segment{% if i < current %} govcy-step-indicator__segment--complete{% endif %}{% if i == current %} govcy-step-indicator__segment--current{% endif %}"{% if i == current %} aria-current="step"{% endif %}>
165
+ {%- if params.steps and params.steps[i - 1] and params.steps[i - 1].text -%}
166
+ <span class="govcy-step-indicator__label">
167
+ {{ govcyLocalizeContent(params.steps[i - 1].text, params.lang) }}
168
+ {%- if i < current %}
169
+ <span class="govcy-visually-hidden">{{ completedLabel }}</span>
170
+ {%- elif i > current %}
171
+ <span class="govcy-visually-hidden">{{ notCompletedLabel }}</span>
172
+ {%- endif %}
173
+ </span>
174
+ {%- endif %}
175
+ </li>
176
+ {%- endfor %}
177
+ </ol>
178
+ </div>
179
+ {%- endif %}
180
+ <div {% if params.id %}id="{{ params.id }}-counter" {% endif %}class="govcy-step-indicator__counter"{{ govcyLangAttribute(params.lang) }}>
181
+ <span class="govcy-visually-hidden">{{ stepLabel }} </span>
182
+ <span class="govcy-step-indicator__current-counter">{{ current }}</span> {{ ofLabel }} {{ total }}
183
+ </div>
184
+ {%- endif %}
185
+ {%- endmacro %}
@@ -78,7 +78,7 @@
78
78
  {%- endif -%}
79
79
  {#- render radio -#}
80
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 %}>
81
+ <input class="govcy-radio-input" name="{{ params.name }}"{% if params.value == item.value %} checked{% endif %} value="{{item.value}}" type="radio" id="{{ optionId }}" {% if item.hint%} aria-describedby="{{hintId}}"{% endif %}{% if item.conditionalElements %} data-aria-controls="{{conditionalElementsId}}"{% endif %}>
82
82
  <label class="govcy-label" for="{{ optionId }}">{% if item.conditionalElements %} <span class="govcy-visually-hidden">{{conditionalLabel}}</span>{% endif %}{{ label | safe }}</label>
83
83
  {#- {% call govcyLabel({label:label, for:optionId, isPrimary:false, isHTML:true, lang:lang}) %}{% endcall %} -#}
84
84
  {% call hint({hint:item.hint, id:hintId, lang:lang}) %}{% endcall %}
@@ -98,10 +98,11 @@
98
98
  </div>
99
99
  {%- endif -%}
100
100
  {%- endmacro %}
101
- {# radio
101
+ {# radios
102
102
  @param {object} legend The legend text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
103
103
  @param {string} id The id prefix for the options. Will escape text.
104
104
  @param {string} name The name used in radio. Will escape text.
105
+ @param {string} value The selected radio option. Optional.
105
106
  @param {string} hint The hint text. Optional. Will escape text
106
107
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
107
108
  @param {boolean} isInline Are the radios inline type? Optional, default is false. Can be true,false
@@ -3,6 +3,7 @@
3
3
  @param {object} label The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
4
4
  @param {string} id The id of the select. Will escape text.
5
5
  @param {string} name The name of the select. Will escape text.
6
+ @param {string} value The value of the input. The matching value in the `items` array will be selected. Optional
6
7
  @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
8
  @param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
8
9
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
@@ -50,7 +51,7 @@
50
51
  {# for each item render checkbox item #}
51
52
  {%- for item in params.items -%}
52
53
  {%- if item.text -%}
53
- <option value="{{ item.value }}">{{ govcyLocalizeContent(item.text, params.lang) }}</option>
54
+ <option value="{{ item.value }}"{% if params.value == item.value %} selected{% endif %}>{{ govcyLocalizeContent(item.text, params.lang) }}</option>
54
55
  {%- endif -%}
55
56
  {%- endfor -%}
56
57
  </select>
@@ -2,6 +2,8 @@
2
2
  @param {object} label The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
3
3
  @param {string} id The input id. Will escape text
4
4
  @param {string} name The input name. Will escape text. Optional
5
+ @param {string} value The value of the input. Whether to escape the value depends on `params.isValueEscaped`. Optional
6
+ @param {string} isValueEscaped Whether the value will be escaped. Optional, default is true.
5
7
  @param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
6
8
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
7
9
  @param {boolean} isSpellcheck true renders nothing, false renders spellcheck="false"? Optional, default is true. Can be true,false
@@ -24,6 +26,7 @@
24
26
  {%- from "./label.njk" import label -%}
25
27
  {%- from "./errorMessage.njk" import errorMessage -%}
26
28
  {#- set default values -#}
29
+ {%- set isValueEscaped = params.isValueEscaped | default(true) -%}
27
30
  {%- set isPageHeading = params.isPageHeading | default(false) -%}
28
31
  {%- set isSpellcheck = params.isSpellcheck | default(false) -%}
29
32
  {%- set autocomplete = params.autocomplete | default(false) -%}
@@ -55,7 +58,7 @@
55
58
  {#- render error message -#}
56
59
  {% call errorMessage({message:params.error,id:errorId, lang:params.lang}) %}{% endcall %}
57
60
  {#- 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>
61
+ <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 %}>{% if params.value is defined %}{{ params.value | default('') if isValueEscaped else params.value | safe }}{% endif %}</textarea>
59
62
  {# character count #}
60
63
  {%- if params.characterCount -%}
61
64
  {%- set charactercountType = params.characterCount.type | default('char') -%}
@@ -2,6 +2,8 @@
2
2
  @param {object} label The label text. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
3
3
  @param {string} id The input id. Will escape text
4
4
  @param {string} name The input name. Will escape text. Optional
5
+ @param {string} value The value of the input. Whether to escape the value depends on `params.isValueEscaped`. Optional
6
+ @param {string} isValueEscaped Whether the value will be escaped. Optional, default is true.
5
7
  @param {object} hint The hint text. Optional. Will escape text. Example `{en:"Content",el:"Περιεχομένο"}`
6
8
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
7
9
  @param {boolean} isSpellcheck true renders nothing, false renders spellcheck="false"? Optional, default is true. Can be true,false
@@ -22,6 +24,7 @@
22
24
  {%- from "./label.njk" import label -%}
23
25
  {%- from "./errorMessage.njk" import errorMessage -%}
24
26
  {#- set default values -#}
27
+ {%- set isValueEscaped = params.isValueEscaped | default(true) -%}
25
28
  {%- set isPageHeading = params.isPageHeading | default(false) -%}
26
29
  {%- set isSpellcheck = params.isSpellcheck | default(false) -%}
27
30
  {%- set type = params.type | default("text") -%}
@@ -66,7 +69,7 @@
66
69
  {#- render error message -#}
67
70
  {% call errorMessage({message:params.error,id:errorId, lang:params.lang}) %}{% endcall %}
68
71
  {#- render input -#}
69
- <input id="{{params.id}}"{% if params.name %} name="{{ params.name }}"{% endif %} {{ inputType | safe }} {{ inputSpellcheck | safe }} {{ inputAutocomplete | safe }} class="govcy-text-input{% if params.fixedWidth %} {{ fixedWidthClass }}{% endif %}{% if params.error %} govcy-text-input-error{% endif %}"{% if params.hint or params.error%} aria-describedby="{% if params.hint %}{{hintId}} {% endif %}{% if params.error %}{{errorId}} {% endif %}"{% endif %}>
72
+ <input id="{{params.id}}"{% if params.value is defined %} value="{{ params.value | default('') if isValueEscaped else params.value | safe }}"{% endif %} {% if params.name %} name="{{ params.name }}"{% endif %} {{ inputType | safe }} {{ inputSpellcheck | safe }} {{ inputAutocomplete | safe }} class="govcy-text-input{% if params.fixedWidth %} {{ fixedWidthClass }}{% endif %}{% if params.error %} govcy-text-input-error{% endif %}"{% if params.hint or params.error%} aria-describedby="{% if params.hint %}{{hintId}} {% endif %}{% if params.error %}{{errorId}} {% endif %}"{% endif %}>
70
73
  {% endcall %}
71
74
  {%- endif -%}
72
75
  {%- endmacro %}
@@ -25,7 +25,8 @@ 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', 'details', 'stepByStepStatic'] -%}
28
+ 'panel', 'datePicker','dateInput', 'taskList', 'errorSummary', 'details', 'stepByStepStatic',
29
+ 'progressList'] -%}
29
30
  {%- set macroCallerBlocks = ['formControl','form','fieldset'] -%}
30
31
  {%- macro govcyElement(component, params) -%}
31
32
  {#- Simple blocks -#}