@gov-cy/govcy-frontend-renderer 1.12.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/dist/govcyCompiledTemplates.browser.js +667 -533
- package/package.json +1 -1
- package/src/njk/elements/checkboxes.njk +5 -2
- package/src/njk/elements/dateInput.njk +18 -15
- package/src/njk/elements/datePicker.njk +2 -1
- package/src/njk/elements/radios.njk +3 -2
- package/src/njk/elements/select.njk +2 -1
- package/src/njk/elements/textArea.njk +4 -1
- package/src/njk/elements/textInput.njk +4 -1
package/package.json
CHANGED
|
@@ -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=""
|
|
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 }}"
|
|
@@ -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
|
-
{#
|
|
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 %}
|
|
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 %}
|