@ministryofjustice/frontend 5.0.0 → 5.1.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.
Files changed (112) hide show
  1. package/moj/all.bundle.js +1549 -1062
  2. package/moj/all.bundle.js.map +1 -1
  3. package/moj/all.bundle.mjs +1845 -1054
  4. package/moj/all.bundle.mjs.map +1 -1
  5. package/moj/all.mjs +7 -90
  6. package/moj/all.mjs.map +1 -1
  7. package/moj/all.scss +1 -0
  8. package/moj/all.scss.map +1 -1
  9. package/moj/common/index.mjs +57 -0
  10. package/moj/common/index.mjs.map +1 -0
  11. package/moj/common/moj-frontend-version.mjs +14 -0
  12. package/moj/common/moj-frontend-version.mjs.map +1 -0
  13. package/moj/components/add-another/add-another.bundle.js +105 -76
  14. package/moj/components/add-another/add-another.bundle.js.map +1 -1
  15. package/moj/components/add-another/add-another.bundle.mjs +222 -71
  16. package/moj/components/add-another/add-another.bundle.mjs.map +1 -1
  17. package/moj/components/add-another/add-another.mjs +103 -72
  18. package/moj/components/add-another/add-another.mjs.map +1 -1
  19. package/moj/components/alert/alert.bundle.js +115 -191
  20. package/moj/components/alert/alert.bundle.js.map +1 -1
  21. package/moj/components/alert/alert.bundle.mjs +354 -186
  22. package/moj/components/alert/alert.bundle.mjs.map +1 -1
  23. package/moj/components/alert/alert.mjs +55 -140
  24. package/moj/components/alert/alert.mjs.map +1 -1
  25. package/moj/components/button-menu/README.md +3 -1
  26. package/moj/components/button-menu/button-menu.bundle.js +91 -120
  27. package/moj/components/button-menu/button-menu.bundle.js.map +1 -1
  28. package/moj/components/button-menu/button-menu.bundle.mjs +329 -114
  29. package/moj/components/button-menu/button-menu.bundle.mjs.map +1 -1
  30. package/moj/components/button-menu/button-menu.mjs +89 -116
  31. package/moj/components/button-menu/button-menu.mjs.map +1 -1
  32. package/moj/components/date-picker/date-picker.bundle.js +174 -154
  33. package/moj/components/date-picker/date-picker.bundle.js.map +1 -1
  34. package/moj/components/date-picker/date-picker.bundle.mjs +411 -147
  35. package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -1
  36. package/moj/components/date-picker/date-picker.mjs +172 -150
  37. package/moj/components/date-picker/date-picker.mjs.map +1 -1
  38. package/moj/components/filter/template.njk +1 -1
  39. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js +133 -44
  40. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js.map +1 -1
  41. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs +374 -41
  42. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs.map +1 -1
  43. package/moj/components/filter-toggle-button/filter-toggle-button.mjs +131 -40
  44. package/moj/components/filter-toggle-button/filter-toggle-button.mjs.map +1 -1
  45. package/moj/components/form-validator/form-validator.bundle.js +159 -69
  46. package/moj/components/form-validator/form-validator.bundle.js.map +1 -1
  47. package/moj/components/form-validator/form-validator.bundle.mjs +399 -65
  48. package/moj/components/form-validator/form-validator.bundle.mjs.map +1 -1
  49. package/moj/components/form-validator/form-validator.mjs +134 -54
  50. package/moj/components/form-validator/form-validator.mjs.map +1 -1
  51. package/moj/components/multi-file-upload/multi-file-upload.bundle.js +291 -117
  52. package/moj/components/multi-file-upload/multi-file-upload.bundle.js.map +1 -1
  53. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs +527 -109
  54. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs.map +1 -1
  55. package/moj/components/multi-file-upload/multi-file-upload.mjs +288 -101
  56. package/moj/components/multi-file-upload/multi-file-upload.mjs.map +1 -1
  57. package/moj/components/multi-file-upload/template.njk +1 -1
  58. package/moj/components/multi-select/multi-select.bundle.js +106 -41
  59. package/moj/components/multi-select/multi-select.bundle.js.map +1 -1
  60. package/moj/components/multi-select/multi-select.bundle.mjs +346 -37
  61. package/moj/components/multi-select/multi-select.bundle.mjs.map +1 -1
  62. package/moj/components/multi-select/multi-select.mjs +104 -37
  63. package/moj/components/multi-select/multi-select.mjs.map +1 -1
  64. package/moj/components/password-reveal/_password-reveal.scss +3 -1
  65. package/moj/components/password-reveal/_password-reveal.scss.map +1 -1
  66. package/moj/components/password-reveal/password-reveal.bundle.js +32 -29
  67. package/moj/components/password-reveal/password-reveal.bundle.js.map +1 -1
  68. package/moj/components/password-reveal/password-reveal.bundle.mjs +149 -24
  69. package/moj/components/password-reveal/password-reveal.bundle.mjs.map +1 -1
  70. package/moj/components/password-reveal/password-reveal.mjs +30 -25
  71. package/moj/components/password-reveal/password-reveal.mjs.map +1 -1
  72. package/moj/components/rich-text-editor/README.md +4 -3
  73. package/moj/components/rich-text-editor/rich-text-editor.bundle.js +127 -62
  74. package/moj/components/rich-text-editor/rich-text-editor.bundle.js.map +1 -1
  75. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs +367 -58
  76. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs.map +1 -1
  77. package/moj/components/rich-text-editor/rich-text-editor.mjs +125 -58
  78. package/moj/components/rich-text-editor/rich-text-editor.mjs.map +1 -1
  79. package/moj/components/search-toggle/search-toggle.bundle.js +94 -26
  80. package/moj/components/search-toggle/search-toggle.bundle.js.map +1 -1
  81. package/moj/components/search-toggle/search-toggle.bundle.mjs +334 -22
  82. package/moj/components/search-toggle/search-toggle.bundle.mjs.map +1 -1
  83. package/moj/components/search-toggle/search-toggle.mjs +92 -22
  84. package/moj/components/search-toggle/search-toggle.mjs.map +1 -1
  85. package/moj/components/sortable-table/sortable-table.bundle.js +151 -83
  86. package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -1
  87. package/moj/components/sortable-table/sortable-table.bundle.mjs +390 -78
  88. package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -1
  89. package/moj/components/sortable-table/sortable-table.mjs +149 -79
  90. package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
  91. package/moj/core/_all.scss +3 -0
  92. package/moj/core/_all.scss.map +1 -0
  93. package/moj/core/_moj-frontend-properties.scss +7 -0
  94. package/moj/core/_moj-frontend-properties.scss.map +1 -0
  95. package/moj/filters/prototype-kit-13-filters.js +4 -3
  96. package/moj/helpers.bundle.js +22 -77
  97. package/moj/helpers.bundle.js.map +1 -1
  98. package/moj/helpers.bundle.mjs +23 -74
  99. package/moj/helpers.bundle.mjs.map +1 -1
  100. package/moj/helpers.mjs +23 -74
  101. package/moj/helpers.mjs.map +1 -1
  102. package/moj/moj-frontend.min.css +1 -1
  103. package/moj/moj-frontend.min.css.map +1 -1
  104. package/moj/moj-frontend.min.js +1 -1
  105. package/moj/moj-frontend.min.js.map +1 -1
  106. package/package.json +1 -1
  107. package/moj/version.bundle.js +0 -12
  108. package/moj/version.bundle.js.map +0 -1
  109. package/moj/version.bundle.mjs +0 -4
  110. package/moj/version.bundle.mjs.map +0 -1
  111. package/moj/version.mjs +0 -4
  112. package/moj/version.mjs.map +0 -1
package/moj/all.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { createAll } from 'govuk-frontend';
2
+ export { version } from './common/moj-frontend-version.mjs';
1
3
  import { AddAnother } from './components/add-another/add-another.mjs';
2
4
  import { Alert } from './components/alert/alert.mjs';
3
5
  import { ButtonMenu } from './components/button-menu/button-menu.mjs';
@@ -10,107 +12,22 @@ import { PasswordReveal } from './components/password-reveal/password-reveal.mjs
10
12
  import { RichTextEditor } from './components/rich-text-editor/rich-text-editor.mjs';
11
13
  import { SearchToggle } from './components/search-toggle/search-toggle.mjs';
12
14
  import { SortableTable } from './components/sortable-table/sortable-table.mjs';
13
- export { version } from './version.mjs';
14
-
15
- /* eslint-disable no-new */
16
-
17
15
 
18
16
  /**
19
17
  * @param {Config} [config]
20
18
  */
21
19
  function initAll(config) {
22
- // Set the config to an empty object by default if no config is passed.
23
- config = typeof config !== 'undefined' ? config : {};
24
-
25
- // Allow the user to initialise MOJ Frontend in only certain sections of the page
26
- // Defaults to the entire document if nothing is set.
27
- const scope = typeof config.scope !== 'undefined' ? config.scope : document;
28
- const $addAnothers = scope.querySelectorAll('[data-module="moj-add-another"]');
29
- $addAnothers.forEach($addAnother => {
30
- new AddAnother($addAnother);
31
- });
32
- const $multiSelects = scope.querySelectorAll('[data-module="moj-multi-select"]');
33
- $multiSelects.forEach($multiSelect => {
34
- const containerSelector = $multiSelect.getAttribute('data-multi-select-checkbox');
35
- if (!($multiSelect instanceof HTMLElement) || !containerSelector) {
36
- return;
37
- }
38
- new MultiSelect({
39
- container: $multiSelect.querySelector(containerSelector),
40
- checkboxes: $multiSelect.querySelectorAll('tbody .govuk-checkboxes__input'),
41
- id_prefix: $multiSelect.getAttribute('data-multi-select-idprefix')
42
- });
43
- });
44
- const $passwordReveals = scope.querySelectorAll('[data-module="moj-password-reveal"]');
45
- $passwordReveals.forEach($passwordReveal => {
46
- new PasswordReveal($passwordReveal);
47
- });
48
- const $richTextEditors = scope.querySelectorAll('[data-module="moj-rich-text-editor"]');
49
- $richTextEditors.forEach($richTextEditor => {
50
- const options = {
51
- textarea: $richTextEditor
52
- };
53
- const toolbarAttr = $richTextEditor.getAttribute('data-moj-rich-text-editor-toolbar');
54
- if (toolbarAttr) {
55
- const toolbar = toolbarAttr.split(',');
56
- options.toolbar = {};
57
- for (const option of toolbar) {
58
- if (option === 'bold' || option === 'italic' || option === 'underline' || option === 'bullets' || option === 'numbers') {
59
- options.toolbar[option] = true;
60
- }
61
- }
62
- }
63
- new RichTextEditor(options);
64
- });
65
- const $searchToggles = scope.querySelectorAll('[data-module="moj-search-toggle"]');
66
- $searchToggles.forEach($searchToggle => {
67
- new SearchToggle({
68
- toggleButton: {
69
- container: $searchToggle.querySelector('.moj-search-toggle__toggle'),
70
- text: $searchToggle.getAttribute('data-moj-search-toggle-text')
71
- },
72
- search: {
73
- container: $searchToggle.querySelector('.moj-search')
74
- }
75
- });
76
- });
77
- const $sortableTables = scope.querySelectorAll('[data-module="moj-sortable-table"]');
78
- $sortableTables.forEach($table => {
79
- new SortableTable({
80
- table: $table
81
- });
82
- });
83
- const $datePickers = scope.querySelectorAll('[data-module="moj-date-picker"]');
84
- $datePickers.forEach($datePicker => {
85
- new DatePicker($datePicker);
86
- });
87
- const $buttonMenus = scope.querySelectorAll('[data-module="moj-button-menu"]');
88
- $buttonMenus.forEach($buttonmenu => {
89
- new ButtonMenu($buttonmenu);
90
- });
91
- const $alerts = scope.querySelectorAll('[data-module="moj-alert"]');
92
- $alerts.forEach($alert => {
93
- new Alert($alert);
94
- });
20
+ for (const Component of [AddAnother, Alert, ButtonMenu, DatePicker, MultiSelect, PasswordReveal, RichTextEditor, SearchToggle, SortableTable]) {
21
+ createAll(Component, undefined, config);
22
+ }
95
23
  }
96
24
 
97
25
  /**
98
- * @typedef {object} Config
99
- * @property {Element} [scope=document] - Scope to query for components
100
- */
101
-
102
- /**
103
- * Schema for component config
104
- *
105
- * @typedef {object} Schema
106
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
26
+ * @typedef {Parameters<typeof GOVUKFrontend.initAll>[0]} Config
107
27
  */
108
28
 
109
29
  /**
110
- * Schema property for component config
111
- *
112
- * @typedef {object} SchemaProperty
113
- * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
30
+ * @import * as GOVUKFrontend from 'govuk-frontend'
114
31
  */
115
32
 
116
33
  export { AddAnother, Alert, ButtonMenu, DatePicker, MultiSelect, PasswordReveal, RichTextEditor, SearchToggle, SortableTable, initAll };
package/moj/all.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"all.mjs","sources":["../../src/moj/all.mjs"],"sourcesContent":["/* eslint-disable no-new */\n\nimport { AddAnother } from './components/add-another/add-another.mjs'\nimport { Alert } from './components/alert/alert.mjs'\nimport { ButtonMenu } from './components/button-menu/button-menu.mjs'\nimport { DatePicker } from './components/date-picker/date-picker.mjs'\nimport { FilterToggleButton } from './components/filter-toggle-button/filter-toggle-button.mjs'\nimport { FormValidator } from './components/form-validator/form-validator.mjs'\nimport { MultiFileUpload } from './components/multi-file-upload/multi-file-upload.mjs'\nimport { MultiSelect } from './components/multi-select/multi-select.mjs'\nimport { PasswordReveal } from './components/password-reveal/password-reveal.mjs'\nimport { RichTextEditor } from './components/rich-text-editor/rich-text-editor.mjs'\nimport { SearchToggle } from './components/search-toggle/search-toggle.mjs'\nimport { SortableTable } from './components/sortable-table/sortable-table.mjs'\nimport { version } from './version.mjs'\n\n/**\n * @param {Config} [config]\n */\nfunction initAll(config) {\n // Set the config to an empty object by default if no config is passed.\n config = typeof config !== 'undefined' ? config : {}\n\n // Allow the user to initialise MOJ Frontend in only certain sections of the page\n // Defaults to the entire document if nothing is set.\n const scope = typeof config.scope !== 'undefined' ? config.scope : document\n\n const $addAnothers = scope.querySelectorAll('[data-module=\"moj-add-another\"]')\n\n $addAnothers.forEach(($addAnother) => {\n new AddAnother($addAnother)\n })\n\n const $multiSelects = scope.querySelectorAll(\n '[data-module=\"moj-multi-select\"]'\n )\n\n $multiSelects.forEach(($multiSelect) => {\n const containerSelector = $multiSelect.getAttribute(\n 'data-multi-select-checkbox'\n )\n\n if (!($multiSelect instanceof HTMLElement) || !containerSelector) {\n return\n }\n\n new MultiSelect({\n container: $multiSelect.querySelector(containerSelector),\n checkboxes: $multiSelect.querySelectorAll(\n 'tbody .govuk-checkboxes__input'\n ),\n id_prefix: $multiSelect.getAttribute('data-multi-select-idprefix')\n })\n })\n\n const $passwordReveals = scope.querySelectorAll(\n '[data-module=\"moj-password-reveal\"]'\n )\n\n $passwordReveals.forEach(($passwordReveal) => {\n new PasswordReveal($passwordReveal)\n })\n\n const $richTextEditors = scope.querySelectorAll(\n '[data-module=\"moj-rich-text-editor\"]'\n )\n\n $richTextEditors.forEach(($richTextEditor) => {\n const options = {\n textarea: $richTextEditor\n }\n\n const toolbarAttr = $richTextEditor.getAttribute(\n 'data-moj-rich-text-editor-toolbar'\n )\n\n if (toolbarAttr) {\n const toolbar = toolbarAttr.split(',')\n\n options.toolbar = {}\n\n for (const option of toolbar) {\n if (\n option === 'bold' ||\n option === 'italic' ||\n option === 'underline' ||\n option === 'bullets' ||\n option === 'numbers'\n ) {\n options.toolbar[option] = true\n }\n }\n }\n\n new RichTextEditor(options)\n })\n\n const $searchToggles = scope.querySelectorAll(\n '[data-module=\"moj-search-toggle\"]'\n )\n\n $searchToggles.forEach(($searchToggle) => {\n new SearchToggle({\n toggleButton: {\n container: $searchToggle.querySelector('.moj-search-toggle__toggle'),\n text: $searchToggle.getAttribute('data-moj-search-toggle-text')\n },\n search: {\n container: $searchToggle.querySelector('.moj-search')\n }\n })\n })\n\n const $sortableTables = scope.querySelectorAll(\n '[data-module=\"moj-sortable-table\"]'\n )\n\n $sortableTables.forEach(($table) => {\n new SortableTable({\n table: $table\n })\n })\n\n const $datePickers = scope.querySelectorAll('[data-module=\"moj-date-picker\"]')\n\n $datePickers.forEach(($datePicker) => {\n new DatePicker($datePicker)\n })\n\n const $buttonMenus = scope.querySelectorAll('[data-module=\"moj-button-menu\"]')\n\n $buttonMenus.forEach(($buttonmenu) => {\n new ButtonMenu($buttonmenu)\n })\n\n const $alerts = scope.querySelectorAll('[data-module=\"moj-alert\"]')\n $alerts.forEach(($alert) => {\n new Alert($alert)\n })\n}\n\nexport {\n initAll,\n version,\n\n // Components\n AddAnother,\n Alert,\n ButtonMenu,\n DatePicker,\n FilterToggleButton,\n FormValidator,\n MultiFileUpload,\n MultiSelect,\n PasswordReveal,\n RichTextEditor,\n SearchToggle,\n SortableTable\n}\n\n/**\n * @typedef {object} Config\n * @property {Element} [scope=document] - Scope to query for components\n */\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n"],"names":["initAll","config","scope","document","$addAnothers","querySelectorAll","forEach","$addAnother","AddAnother","$multiSelects","$multiSelect","containerSelector","getAttribute","HTMLElement","MultiSelect","container","querySelector","checkboxes","id_prefix","$passwordReveals","$passwordReveal","PasswordReveal","$richTextEditors","$richTextEditor","options","textarea","toolbarAttr","toolbar","split","option","RichTextEditor","$searchToggles","$searchToggle","SearchToggle","toggleButton","text","search","$sortableTables","$table","SortableTable","table","$datePickers","$datePicker","DatePicker","$buttonMenus","$buttonmenu","ButtonMenu","$alerts","$alert","Alert"],"mappings":";;;;;;;;;;;;;;AAAA;;;AAgBA;AACA;AACA;AACA,SAASA,OAAOA,CAACC,MAAM,EAAE;AACvB;EACAA,MAAM,GAAG,OAAOA,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAG,EAAE;;AAEpD;AACA;AACA,EAAA,MAAMC,KAAK,GAAG,OAAOD,MAAM,CAACC,KAAK,KAAK,WAAW,GAAGD,MAAM,CAACC,KAAK,GAAGC,QAAQ;AAE3E,EAAA,MAAMC,YAAY,GAAGF,KAAK,CAACG,gBAAgB,CAAC,iCAAiC,CAAC;AAE9ED,EAAAA,YAAY,CAACE,OAAO,CAAEC,WAAW,IAAK;IACpC,IAAIC,UAAU,CAACD,WAAW,CAAC;AAC7B,GAAC,CAAC;AAEF,EAAA,MAAME,aAAa,GAAGP,KAAK,CAACG,gBAAgB,CAC1C,kCACF,CAAC;AAEDI,EAAAA,aAAa,CAACH,OAAO,CAAEI,YAAY,IAAK;AACtC,IAAA,MAAMC,iBAAiB,GAAGD,YAAY,CAACE,YAAY,CACjD,4BACF,CAAC;IAED,IAAI,EAAEF,YAAY,YAAYG,WAAW,CAAC,IAAI,CAACF,iBAAiB,EAAE;AAChE,MAAA;AACF;AAEA,IAAA,IAAIG,WAAW,CAAC;AACdC,MAAAA,SAAS,EAAEL,YAAY,CAACM,aAAa,CAACL,iBAAiB,CAAC;AACxDM,MAAAA,UAAU,EAAEP,YAAY,CAACL,gBAAgB,CACvC,gCACF,CAAC;AACDa,MAAAA,SAAS,EAAER,YAAY,CAACE,YAAY,CAAC,4BAA4B;AACnE,KAAC,CAAC;AACJ,GAAC,CAAC;AAEF,EAAA,MAAMO,gBAAgB,GAAGjB,KAAK,CAACG,gBAAgB,CAC7C,qCACF,CAAC;AAEDc,EA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aAAa,CAAC,aAAa;AACtD;AACF,KAAC,CAAC;AACJ,GAAC,CAAC;AAEF,EAAA,MAAMqB,eAAe,GAAGnC,KAAK,CAACG,gBAAgB,CAC5C,oCACF,CAAC;AAEDgC,EAAAA,eAAe,CAAC/B,OAAO,CAAEgC,MAAM,IAAK;AAClC,IAAA,IAAIC,aAAa,CAAC;AAChBC,MAAAA,KAAK,EAAEF;AACT,KAAC,CAAC;AACJ,GAAC,CAAC;AAEF,EAAA,MAAMG,YAAY,GAAGvC,KAAK,CAACG,gBAAgB,CAAC,iCAAiC,CAAC;AAE9EoC,EAAAA,YAAY,CAACnC,OAAO,CAAEoC,WAAW,IAAK;IACpC,IAAIC,UAAU,CAACD,WAAW,CAAC;AAC7B,GAAC,CAAC;AAEF,EAAA,MAAME,YAAY,GAAG1C,KAAK,CAACG,gBAAgB,CAAC,iCAAiC,CAAC;AAE9EuC,EAAAA,YAAY,CAACtC,OAAO,CAAEuC,WAAW,IAAK;IACpC,IAAIC,UAAU,CAACD,WAAW,CAAC;AAC7B,GAAC,CAAC;AAEF,EAAA,MAAME,OAAO,GAAG7C,KAAK,CAACG,gBAAgB,CAAC,2BAA2B,CAAC;AACnE0C,EAAAA,OAAO,CAACzC,OAAO,CAAE0C,MAAM,IAAK;IAC1B,IAAIC,KAAK,CAACD,MAAM,CAAC;AACnB,GAAC,CAAC;AACJ;;AAqBA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"all.mjs","sources":["../../src/moj/all.mjs"],"sourcesContent":["import { createAll } from 'govuk-frontend'\n\nimport { version } from './common/moj-frontend-version.mjs'\nimport { AddAnother } from './components/add-another/add-another.mjs'\nimport { Alert } from './components/alert/alert.mjs'\nimport { ButtonMenu } from './components/button-menu/button-menu.mjs'\nimport { DatePicker } from './components/date-picker/date-picker.mjs'\nimport { FilterToggleButton } from './components/filter-toggle-button/filter-toggle-button.mjs'\nimport { FormValidator } from './components/form-validator/form-validator.mjs'\nimport { MultiFileUpload } from './components/multi-file-upload/multi-file-upload.mjs'\nimport { MultiSelect } from './components/multi-select/multi-select.mjs'\nimport { PasswordReveal } from './components/password-reveal/password-reveal.mjs'\nimport { RichTextEditor } from './components/rich-text-editor/rich-text-editor.mjs'\nimport { SearchToggle } from './components/search-toggle/search-toggle.mjs'\nimport { SortableTable } from './components/sortable-table/sortable-table.mjs'\n\n/**\n * @param {Config} [config]\n */\nfunction initAll(config) {\n for (const Component of [\n AddAnother,\n Alert,\n ButtonMenu,\n DatePicker,\n MultiSelect,\n PasswordReveal,\n RichTextEditor,\n SearchToggle,\n SortableTable\n ]) {\n createAll(Component, undefined, config)\n }\n}\n\nexport {\n initAll,\n version,\n\n // Components\n AddAnother,\n Alert,\n ButtonMenu,\n DatePicker,\n FilterToggleButton,\n FormValidator,\n MultiFileUpload,\n MultiSelect,\n PasswordReveal,\n RichTextEditor,\n SearchToggle,\n SortableTable\n}\n\n/**\n * @typedef {Parameters<typeof GOVUKFrontend.initAll>[0]} Config\n */\n\n/**\n * @import * as GOVUKFrontend from 'govuk-frontend'\n */\n"],"names":["initAll","config","Component","AddAnother","Alert","ButtonMenu","DatePicker","MultiSelect","PasswordReveal","RichTextEditor","SearchToggle","SortableTable","createAll","undefined"],"mappings":";;;;;;;;;;;;;;;AAgBA;AACA;AACA;AACA,SAASA,OAAOA,CAACC,MAAM,EAAE;EACvB,KAAK,MAAMC,SAAS,IAAI,CACtBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,cAAc,EACdC,YAAY,EACZC,aAAa,CACd,EAAE;AACDC,IAAAA,SAAS,CAACV,SAAS,EAAEW,SAAS,EAAEZ,MAAM,CAAC;AACzC;AACF;;AAqBA;AACA;AACA;;AAEA;AACA;AACA;;;;"}
package/moj/all.scss CHANGED
@@ -1,4 +1,5 @@
1
1
  @forward "base";
2
+ @forward "core/all";
2
3
  @forward "objects/all";
3
4
  @forward "components/all";
4
5
  @forward "utilities/all";
package/moj/all.scss.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/moj/all.scss"],"names":[],"mappings":"AAAA,eAAe;AACf,sBAAsB;AACtB,yBAAyB;AACzB,wBAAwB","file":"all.scss","sourcesContent":["@forward \"base\";\n@forward \"objects/all\";\n@forward \"components/all\";\n@forward \"utilities/all\";\n"]}
1
+ {"version":3,"sources":["../../src/moj/all.scss"],"names":[],"mappings":"AAAA,eAAe;AACf,mBAAmB;AACnB,sBAAsB;AACtB,yBAAyB;AACzB,wBAAwB","file":"all.scss","sourcesContent":["@forward \"base\";\n@forward \"core/all\";\n@forward \"objects/all\";\n@forward \"components/all\";\n@forward \"utilities/all\";\n"]}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * GOV.UK Frontend helpers
3
+ *
4
+ * @todo Import from GOV.UK Frontend
5
+ */
6
+
7
+ /**
8
+ * Move focus to element
9
+ *
10
+ * Sets tabindex to -1 to make the element programmatically focusable,
11
+ * but removes it on blur as the element doesn't need to be focused again.
12
+ *
13
+ * @template {HTMLElement} FocusElement
14
+ * @param {FocusElement} $element - HTML element
15
+ * @param {object} [options] - Handler options
16
+ * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus
17
+ * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur
18
+ */
19
+ function setFocus($element, options = {}) {
20
+ var _options$onBeforeFocu;
21
+ const isFocusable = $element.getAttribute('tabindex');
22
+ if (!isFocusable) {
23
+ $element.setAttribute('tabindex', '-1');
24
+ }
25
+
26
+ /**
27
+ * Handle element focus
28
+ */
29
+ function onFocus() {
30
+ $element.addEventListener('blur', onBlur, {
31
+ once: true
32
+ });
33
+ }
34
+
35
+ /**
36
+ * Handle element blur
37
+ */
38
+ function onBlur() {
39
+ var _options$onBlur;
40
+ (_options$onBlur = options.onBlur) == null || _options$onBlur.call($element);
41
+ if (!isFocusable) {
42
+ $element.removeAttribute('tabindex');
43
+ }
44
+ }
45
+
46
+ // Add listener to reset element on blur, after focus
47
+ $element.addEventListener('focus', onFocus, {
48
+ once: true
49
+ });
50
+
51
+ // Focus element
52
+ (_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
53
+ $element.focus();
54
+ }
55
+
56
+ export { setFocus };
57
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/moj/common/index.mjs"],"sourcesContent":["/**\n * GOV.UK Frontend helpers\n *\n * @todo Import from GOV.UK Frontend\n */\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n"],"names":["setFocus","$element","options","_options$onBeforeFocu","isFocusable","getAttribute","setAttribute","onFocus","addEventListener","onBlur","once","_options$onBlur","call","removeAttribute","onBeforeFocus","focus"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAQA,CAACC,QAAQ,EAAEC,OAAO,GAAG,EAAE,EAAE;AAAA,EAAA,IAAAC,qBAAA;AAC/C,EAAA,MAAMC,WAAW,GAAGH,QAAQ,CAACI,YAAY,CAAC,UAAU,CAAC;EAErD,IAAI,CAACD,WAAW,EAAE;AAChBH,IAAAA,QAAQ,CAACK,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC;AACzC;;AAEA;AACF;AACA;EACE,SAASC,OAAOA,GAAG;AACjBN,IAAAA,QAAQ,CAACO,gBAAgB,CAAC,MAAM,EAAEC,MAAM,EAAE;AAAEC,MAAAA,IAAI,EAAE;AAAK,KAAC,CAAC;AAC3D;;AAEA;AACF;AACA;EACE,SAASD,MAAMA,GAAG;AAAA,IAAA,IAAAE,eAAA;IAChB,CAAAA,eAAA,GAAAT,OAAO,CAACO,MAAM,KAAdE,IAAAA,IAAAA,eAAA,CAAgBC,IAAI,CAACX,QAAQ,CAAC;IAE9B,IAAI,CAACG,WAAW,EAAE;AAChBH,MAAAA,QAAQ,CAACY,eAAe,CAAC,UAAU,CAAC;AACtC;AACF;;AAEA;AACAZ,EAAAA,QAAQ,CAACO,gBAAgB,CAAC,OAAO,EAAED,OAAO,EAAE;AAAEG,IAAAA,IAAI,EAAE;AAAK,GAAC,CAAC;;AAE3D;EACA,CAAAP,qBAAA,GAAAD,OAAO,CAACY,aAAa,KAArBX,IAAAA,IAAAA,qBAAA,CAAuBS,IAAI,CAACX,QAAQ,CAAC;EACrCA,QAAQ,CAACc,KAAK,EAAE;AAClB;;;;"}
@@ -0,0 +1,14 @@
1
+ /*
2
+ * This variable is automatically overwritten during builds and releases.
3
+ * It doesn't need to be updated manually.
4
+ */
5
+
6
+ /**
7
+ * MoJ Frontend release version
8
+ *
9
+ * {@link https://github.com/ministryofjustice/moj-frontend/releases}
10
+ */
11
+ const version = '5.1.0';
12
+
13
+ export { version };
14
+ //# sourceMappingURL=moj-frontend-version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moj-frontend-version.mjs","sources":["../../../src/moj/common/moj-frontend-version.mjs"],"sourcesContent":["/*\n * This variable is automatically overwritten during builds and releases.\n * It doesn't need to be updated manually.\n */\n\n/**\n * MoJ Frontend release version\n *\n * {@link https://github.com/ministryofjustice/moj-frontend/releases}\n */\nexport const version = 'development'\n"],"names":["version"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO,GAAG;;;;"}
@@ -1,126 +1,155 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}));
5
- })(this, (function (exports) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('govuk-frontend')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'govuk-frontend'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}, global.GOVUKFrontend));
5
+ })(this, (function (exports, govukFrontend) { 'use strict';
6
6
 
7
- class AddAnother {
8
- constructor(container) {
9
- this.container = container;
10
- if (this.container.hasAttribute('data-moj-add-another-init')) {
11
- return this;
12
- }
13
- this.container.setAttribute('data-moj-add-another-init', '');
14
- this.container.addEventListener('click', this.onRemoveButtonClick.bind(this));
15
- this.container.addEventListener('click', this.onAddButtonClick.bind(this));
16
- const buttons = this.container.querySelectorAll('.moj-add-another__add-button, moj-add-another__remove-button');
17
- buttons.forEach(button => {
18
- if (!(button instanceof HTMLButtonElement)) {
7
+ class AddAnother extends govukFrontend.Component {
8
+ /**
9
+ * @param {Element | null} $root - HTML element to use for add another
10
+ */
11
+ constructor($root) {
12
+ super($root);
13
+ this.$root.addEventListener('click', this.onRemoveButtonClick.bind(this));
14
+ this.$root.addEventListener('click', this.onAddButtonClick.bind(this));
15
+ const $buttons = this.$root.querySelectorAll('.moj-add-another__add-button, moj-add-another__remove-button');
16
+ $buttons.forEach($button => {
17
+ if (!($button instanceof HTMLButtonElement)) {
19
18
  return;
20
19
  }
21
- button.type = 'button';
20
+ $button.type = 'button';
22
21
  });
23
22
  }
23
+
24
+ /**
25
+ * @param {MouseEvent} event - Click event
26
+ */
24
27
  onAddButtonClick(event) {
25
- const button = event.target;
26
- if (!button || !(button instanceof HTMLButtonElement) || !button.classList.contains('moj-add-another__add-button')) {
28
+ const $button = event.target;
29
+ if (!$button || !($button instanceof HTMLButtonElement) || !$button.classList.contains('moj-add-another__add-button')) {
27
30
  return;
28
31
  }
29
- const items = this.getItems();
30
- const item = this.getNewItem();
31
- if (!item || !(item instanceof HTMLElement)) {
32
+ const $items = this.getItems();
33
+ const $item = this.getNewItem();
34
+ if (!$item || !($item instanceof HTMLElement)) {
32
35
  return;
33
36
  }
34
- this.updateAttributes(item, items.length);
35
- this.resetItem(item);
36
- const firstItem = items[0];
37
- if (!this.hasRemoveButton(firstItem)) {
38
- this.createRemoveButton(firstItem);
37
+ this.updateAttributes($item, $items.length);
38
+ this.resetItem($item);
39
+ const $firstItem = $items[0];
40
+ if (!this.hasRemoveButton($firstItem)) {
41
+ this.createRemoveButton($firstItem);
39
42
  }
40
- items[items.length - 1].after(item);
41
- const input = item.querySelector('input, textarea, select');
42
- if (input && input instanceof HTMLInputElement) {
43
- input.focus();
43
+ $items[$items.length - 1].after($item);
44
+ const $input = $item.querySelector('input, textarea, select');
45
+ if ($input && $input instanceof HTMLInputElement) {
46
+ $input.focus();
44
47
  }
45
48
  }
46
- hasRemoveButton(item) {
47
- return item.querySelectorAll('.moj-add-another__remove-button').length;
49
+
50
+ /**
51
+ * @param {HTMLElement} $item - Add another item
52
+ */
53
+ hasRemoveButton($item) {
54
+ return $item.querySelectorAll('.moj-add-another__remove-button').length;
48
55
  }
49
56
  getItems() {
50
- if (!this.container) {
57
+ if (!this.$root) {
51
58
  return [];
52
59
  }
53
- const items = Array.from(this.container.querySelectorAll('.moj-add-another__item'));
54
- return items.filter(item => item instanceof HTMLElement);
60
+ const $items = Array.from(this.$root.querySelectorAll('.moj-add-another__item'));
61
+ return $items.filter(item => item instanceof HTMLElement);
55
62
  }
56
63
  getNewItem() {
57
- const items = this.getItems();
58
- const item = items[0].cloneNode(true);
59
- if (!item || !(item instanceof HTMLElement)) {
64
+ const $items = this.getItems();
65
+ const $item = $items[0].cloneNode(true);
66
+ if (!$item || !($item instanceof HTMLElement)) {
60
67
  return;
61
68
  }
62
- if (!this.hasRemoveButton(item)) {
63
- this.createRemoveButton(item);
69
+ if (!this.hasRemoveButton($item)) {
70
+ this.createRemoveButton($item);
64
71
  }
65
- return item;
72
+ return $item;
66
73
  }
67
- updateAttributes(item, index) {
68
- item.querySelectorAll('[data-name]').forEach(el => {
69
- if (!(el instanceof HTMLInputElement)) {
74
+
75
+ /**
76
+ * @param {HTMLElement} $item - Add another item
77
+ * @param {number} index - Add another item index
78
+ */
79
+ updateAttributes($item, index) {
80
+ $item.querySelectorAll('[data-name]').forEach($input => {
81
+ if (!($input instanceof HTMLInputElement)) {
70
82
  return;
71
83
  }
72
- const name = el.getAttribute('data-name') || '';
73
- const id = el.getAttribute('data-id') || '';
74
- const originalId = el.id;
75
- el.name = name.replace(/%index%/, `${index}`);
76
- el.id = id.replace(/%index%/, `${index}`);
77
- const label = el.parentElement.querySelector('label') || el.closest('label') || item.querySelector(`[for="${originalId}"]`);
78
- if (label && label instanceof HTMLLabelElement) {
79
- label.htmlFor = el.id;
84
+ const name = $input.getAttribute('data-name') || '';
85
+ const id = $input.getAttribute('data-id') || '';
86
+ const originalId = $input.id;
87
+ $input.name = name.replace(/%index%/, `${index}`);
88
+ $input.id = id.replace(/%index%/, `${index}`);
89
+ const $label = $input.parentElement.querySelector('label') || $input.closest('label') || $item.querySelector(`[for="${originalId}"]`);
90
+ if ($label && $label instanceof HTMLLabelElement) {
91
+ $label.htmlFor = $input.id;
80
92
  }
81
93
  });
82
94
  }
83
- createRemoveButton(item) {
84
- const button = document.createElement('button');
85
- button.type = 'button';
86
- button.classList.add('govuk-button', 'govuk-button--secondary', 'moj-add-another__remove-button');
87
- button.textContent = 'Remove';
88
- item.append(button);
95
+
96
+ /**
97
+ * @param {HTMLElement} $item - Add another item
98
+ */
99
+ createRemoveButton($item) {
100
+ const $button = document.createElement('button');
101
+ $button.type = 'button';
102
+ $button.classList.add('govuk-button', 'govuk-button--secondary', 'moj-add-another__remove-button');
103
+ $button.textContent = 'Remove';
104
+ $item.append($button);
89
105
  }
90
- resetItem(item) {
91
- item.querySelectorAll('[data-name], [data-id]').forEach(el => {
92
- if (!(el instanceof HTMLInputElement)) {
106
+
107
+ /**
108
+ * @param {HTMLElement} $item - Add another item
109
+ */
110
+ resetItem($item) {
111
+ $item.querySelectorAll('[data-name], [data-id]').forEach($input => {
112
+ if (!($input instanceof HTMLInputElement)) {
93
113
  return;
94
114
  }
95
- if (el.type === 'checkbox' || el.type === 'radio') {
96
- el.checked = false;
115
+ if ($input.type === 'checkbox' || $input.type === 'radio') {
116
+ $input.checked = false;
97
117
  } else {
98
- el.value = '';
118
+ $input.value = '';
99
119
  }
100
120
  });
101
121
  }
122
+
123
+ /**
124
+ * @param {MouseEvent} event - Click event
125
+ */
102
126
  onRemoveButtonClick(event) {
103
- const button = event.target;
104
- if (!button || !(button instanceof HTMLButtonElement) || !button.classList.contains('moj-add-another__remove-button')) {
127
+ const $button = event.target;
128
+ if (!$button || !($button instanceof HTMLButtonElement) || !$button.classList.contains('moj-add-another__remove-button')) {
105
129
  return;
106
130
  }
107
- button.closest('.moj-add-another__item').remove();
108
- const items = this.getItems();
109
- if (items.length === 1) {
110
- items[0].querySelector('.moj-add-another__remove-button').remove();
131
+ $button.closest('.moj-add-another__item').remove();
132
+ const $items = this.getItems();
133
+ if ($items.length === 1) {
134
+ $items[0].querySelector('.moj-add-another__remove-button').remove();
111
135
  }
112
- items.forEach((el, index) => {
113
- this.updateAttributes(el, index);
136
+ $items.forEach(($item, index) => {
137
+ this.updateAttributes($item, index);
114
138
  });
115
139
  this.focusHeading();
116
140
  }
117
141
  focusHeading() {
118
- const heading = this.container.querySelector('.moj-add-another__heading');
119
- if (heading && heading instanceof HTMLElement) {
120
- heading.focus();
142
+ const $heading = this.$root.querySelector('.moj-add-another__heading');
143
+ if ($heading && $heading instanceof HTMLElement) {
144
+ $heading.focus();
121
145
  }
122
146
  }
147
+
148
+ /**
149
+ * Name for the component used when initialising using data-module attributes.
150
+ */
123
151
  }
152
+ AddAnother.moduleName = 'moj-add-another';
124
153
 
125
154
  exports.AddAnother = AddAnother;
126
155
 
@@ -1 +1 @@
1
- {"version":3,"file":"add-another.bundle.js","sources":["../../../../src/moj/components/add-another/add-another.mjs"],"sourcesContent":["export class AddAnother {\n constructor(container) {\n this.container = container\n\n if (this.container.hasAttribute('data-moj-add-another-init')) {\n return this\n }\n\n this.container.setAttribute('data-moj-add-another-init', '')\n\n this.container.addEventListener(\n 'click',\n this.onRemoveButtonClick.bind(this)\n )\n this.container.addEventListener('click', this.onAddButtonClick.bind(this))\n\n const buttons = this.container.querySelectorAll(\n '.moj-add-another__add-button, moj-add-another__remove-button'\n )\n\n buttons.forEach((button) => {\n if (!(button instanceof HTMLButtonElement)) {\n return\n }\n\n button.type = 'button'\n })\n }\n\n onAddButtonClick(event) {\n const button = event.target\n\n if (\n !button ||\n !(button instanceof HTMLButtonElement) ||\n !button.classList.contains('moj-add-another__add-button')\n ) {\n return\n }\n\n const items = this.getItems()\n const item = this.getNewItem()\n\n if (!item || !(item instanceof HTMLElement)) {\n return\n }\n\n this.updateAttributes(item, items.length)\n this.resetItem(item)\n\n const firstItem = items[0]\n if (!this.hasRemoveButton(firstItem)) {\n this.createRemoveButton(firstItem)\n }\n\n items[items.length - 1].after(item)\n\n const input = item.querySelector('input, textarea, select')\n if (input && input instanceof HTMLInputElement) {\n input.focus()\n }\n }\n\n hasRemoveButton(item) {\n return item.querySelectorAll('.moj-add-another__remove-button').length\n }\n\n getItems() {\n if (!this.container) {\n return []\n }\n\n const items = Array.from(\n this.container.querySelectorAll('.moj-add-another__item')\n )\n\n return items.filter((item) => item instanceof HTMLElement)\n }\n\n getNewItem() {\n const items = this.getItems()\n const item = items[0].cloneNode(true)\n\n if (!item || !(item instanceof HTMLElement)) {\n return\n }\n\n if (!this.hasRemoveButton(item)) {\n this.createRemoveButton(item)\n }\n\n return item\n }\n\n updateAttributes(item, index) {\n item.querySelectorAll('[data-name]').forEach((el) => {\n if (!(el instanceof HTMLInputElement)) {\n return\n }\n\n const name = el.getAttribute('data-name') || ''\n const id = el.getAttribute('data-id') || ''\n const originalId = el.id\n\n el.name = name.replace(/%index%/, `${index}`)\n el.id = id.replace(/%index%/, `${index}`)\n\n const label =\n el.parentElement.querySelector('label') ||\n el.closest('label') ||\n item.querySelector(`[for=\"${originalId}\"]`)\n\n if (label && label instanceof HTMLLabelElement) {\n label.htmlFor = el.id\n }\n })\n }\n\n createRemoveButton(item) {\n const button = document.createElement('button')\n button.type = 'button'\n\n button.classList.add(\n 'govuk-button',\n 'govuk-button--secondary',\n 'moj-add-another__remove-button'\n )\n\n button.textContent = 'Remove'\n\n item.append(button)\n }\n\n resetItem(item) {\n item.querySelectorAll('[data-name], [data-id]').forEach((el) => {\n if (!(el instanceof HTMLInputElement)) {\n return\n }\n\n if (el.type === 'checkbox' || el.type === 'radio') {\n el.checked = false\n } else {\n el.value = ''\n }\n })\n }\n\n onRemoveButtonClick(event) {\n const button = event.target\n\n if (\n !button ||\n !(button instanceof HTMLButtonElement) ||\n !button.classList.contains('moj-add-another__remove-button')\n ) {\n return\n }\n\n button.closest('.moj-add-another__item').remove()\n\n const items = this.getItems()\n\n if (items.length === 1) {\n items[0].querySelector('.moj-add-another__remove-button').remove()\n }\n\n items.forEach((el, index) => {\n this.updateAttributes(el, index)\n })\n\n this.focusHeading()\n }\n\n focusHeading() {\n const heading = this.container.querySelector('.moj-add-another__heading')\n\n if (heading && heading instanceof HTMLElement) {\n heading.focus()\n }\n }\n}\n"],"names":["AddAnother","constructor","container","hasAttribute","setAttribute","addEventListener","onRemoveButtonClick","bind","onAddButtonClick","buttons","querySelectorAll","forEach","button","HTMLButtonElement","type","event","target","classList","contains","items","getItems","item","getNewItem","HTMLElement","updateAttributes","length","resetItem","firstItem","hasRemoveButton","createRemoveButton","after","input","querySelector","HTMLInputElement","focus","Array","from","filter","cloneNode","index","el","name","getAttribute","id","originalId","replace","label","parentElement","closest","HTMLLabelElement","htmlFor","document","createElement","add","textContent","append","checked","value","remove","focusHeading","heading"],"mappings":";;;;;;EAAO,MAAMA,UAAU,CAAC;IACtBC,WAAWA,CAACC,SAAS,EAAE;MACrB,IAAI,CAACA,SAAS,GAAGA,SAAS;MAE1B,IAAI,IAAI,CAACA,SAAS,CAACC,YAAY,CAAC,2BAA2B,CAAC,EAAE;EAC5D,MAAA,OAAO,IAAI;EACb;MAEA,IAAI,CAACD,SAAS,CAACE,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC;EAE5D,IAAA,IAAI,CAACF,SAAS,CAACG,gBAAgB,CAC7B,OAAO,EACP,IAAI,CAACC,mBAAmB,CAACC,IAAI,CAAC,IAAI,CACpC,CAAC;EACD,IAAA,IAAI,CAACL,SAAS,CAACG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAACG,gBAAgB,CAACD,IAAI,CAAC,IAAI,CAAC,CAAC;MAE1E,MAAME,OAAO,GAAG,IAAI,CAACP,SAAS,CAACQ,gBAAgB,CAC7C,8DACF,CAAC;EAEDD,IAAAA,OAAO,CAACE,OAAO,CAAEC,MAAM,IAAK;EAC1B,MAAA,IAAI,EAAEA,MAAM,YAAYC,iBAAiB,CAAC,EAAE;EAC1C,QAAA;EACF;QAEAD,MAAM,CAACE,IAAI,GAAG,QAAQ;EACxB,KAAC,CAAC;EACJ;IAEAN,gBAAgBA,CAACO,KAAK,EAAE;EACtB,IAAA,MAAMH,MAAM,GAAGG,KAAK,CAACC,MAAM;EAE3B,IAAA,IACE,CAACJ,MAAM,IACP,EAAEA,MAAM,YAAYC,iBAAiB,CAAC,IACtC,C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CAACU,MAAM,EAAE;EAEjD,IAAA,MAAMvC,KAAK,GAAG,IAAI,CAACC,QAAQ,EAAE;EAE7B,IAAA,IAAID,KAAK,CAACM,MAAM,KAAK,CAAC,EAAE;QACtBN,KAAK,CAAC,CAAC,CAAC,CAACa,aAAa,CAAC,iCAAiC,CAAC,CAAC0B,MAAM,EAAE;EACpE;EAEAvC,IAAAA,KAAK,CAACR,OAAO,CAAC,CAAC6B,EAAE,EAAED,KAAK,KAAK;EAC3B,MAAA,IAAI,CAACf,gBAAgB,CAACgB,EAAE,EAAED,KAAK,CAAC;EAClC,KAAC,CAAC;MAEF,IAAI,CAACoB,YAAY,EAAE;EACrB;EAEAA,EAAAA,YAAYA,GAAG;MACb,MAAMC,OAAO,GAAG,IAAI,CAAC1D,SAAS,CAAC8B,aAAa,CAAC,2BAA2B,CAAC;EAEzE,IAAA,IAAI4B,OAAO,IAAIA,OAAO,YAAYrC,WAAW,EAAE;QAC7CqC,OAAO,CAAC1B,KAAK,EAAE;EACjB;EACF;EACF;;;;;;;;"}
1
+ {"version":3,"file":"add-another.bundle.js","sources":["../../../../src/moj/components/add-another/add-another.mjs"],"sourcesContent":["import { Component } from 'govuk-frontend'\n\nexport class AddAnother extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for add another\n */\n constructor($root) {\n super($root)\n\n this.$root.addEventListener('click', this.onRemoveButtonClick.bind(this))\n this.$root.addEventListener('click', this.onAddButtonClick.bind(this))\n\n const $buttons = this.$root.querySelectorAll(\n '.moj-add-another__add-button, moj-add-another__remove-button'\n )\n\n $buttons.forEach(($button) => {\n if (!($button instanceof HTMLButtonElement)) {\n return\n }\n\n $button.type = 'button'\n })\n }\n\n /**\n * @param {MouseEvent} event - Click event\n */\n onAddButtonClick(event) {\n const $button = event.target\n\n if (\n !$button ||\n !($button instanceof HTMLButtonElement) ||\n !$button.classList.contains('moj-add-another__add-button')\n ) {\n return\n }\n\n const $items = this.getItems()\n const $item = this.getNewItem()\n\n if (!$item || !($item instanceof HTMLElement)) {\n return\n }\n\n this.updateAttributes($item, $items.length)\n this.resetItem($item)\n\n const $firstItem = $items[0]\n if (!this.hasRemoveButton($firstItem)) {\n this.createRemoveButton($firstItem)\n }\n\n $items[$items.length - 1].after($item)\n\n const $input = $item.querySelector('input, textarea, select')\n if ($input && $input instanceof HTMLInputElement) {\n $input.focus()\n }\n }\n\n /**\n * @param {HTMLElement} $item - Add another item\n */\n hasRemoveButton($item) {\n return $item.querySelectorAll('.moj-add-another__remove-button').length\n }\n\n getItems() {\n if (!this.$root) {\n return []\n }\n\n const $items = Array.from(\n this.$root.querySelectorAll('.moj-add-another__item')\n )\n\n return $items.filter((item) => item instanceof HTMLElement)\n }\n\n getNewItem() {\n const $items = this.getItems()\n const $item = $items[0].cloneNode(true)\n\n if (!$item || !($item instanceof HTMLElement)) {\n return\n }\n\n if (!this.hasRemoveButton($item)) {\n this.createRemoveButton($item)\n }\n\n return $item\n }\n\n /**\n * @param {HTMLElement} $item - Add another item\n * @param {number} index - Add another item index\n */\n updateAttributes($item, index) {\n $item.querySelectorAll('[data-name]').forEach(($input) => {\n if (!($input instanceof HTMLInputElement)) {\n return\n }\n\n const name = $input.getAttribute('data-name') || ''\n const id = $input.getAttribute('data-id') || ''\n const originalId = $input.id\n\n $input.name = name.replace(/%index%/, `${index}`)\n $input.id = id.replace(/%index%/, `${index}`)\n\n const $label =\n $input.parentElement.querySelector('label') ||\n $input.closest('label') ||\n $item.querySelector(`[for=\"${originalId}\"]`)\n\n if ($label && $label instanceof HTMLLabelElement) {\n $label.htmlFor = $input.id\n }\n })\n }\n\n /**\n * @param {HTMLElement} $item - Add another item\n */\n createRemoveButton($item) {\n const $button = document.createElement('button')\n $button.type = 'button'\n\n $button.classList.add(\n 'govuk-button',\n 'govuk-button--secondary',\n 'moj-add-another__remove-button'\n )\n\n $button.textContent = 'Remove'\n\n $item.append($button)\n }\n\n /**\n * @param {HTMLElement} $item - Add another item\n */\n resetItem($item) {\n $item.querySelectorAll('[data-name], [data-id]').forEach(($input) => {\n if (!($input instanceof HTMLInputElement)) {\n return\n }\n\n if ($input.type === 'checkbox' || $input.type === 'radio') {\n $input.checked = false\n } else {\n $input.value = ''\n }\n })\n }\n\n /**\n * @param {MouseEvent} event - Click event\n */\n onRemoveButtonClick(event) {\n const $button = event.target\n\n if (\n !$button ||\n !($button instanceof HTMLButtonElement) ||\n !$button.classList.contains('moj-add-another__remove-button')\n ) {\n return\n }\n\n $button.closest('.moj-add-another__item').remove()\n\n const $items = this.getItems()\n\n if ($items.length === 1) {\n $items[0].querySelector('.moj-add-another__remove-button').remove()\n }\n\n $items.forEach(($item, index) => {\n this.updateAttributes($item, index)\n })\n\n this.focusHeading()\n }\n\n focusHeading() {\n const $heading = this.$root.querySelector('.moj-add-another__heading')\n\n if ($heading && $heading instanceof HTMLElement) {\n $heading.focus()\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-add-another'\n}\n"],"names":["AddAnother","Component","constructor","$root","addEventListener","onRemoveButtonClick","bind","onAddButtonClick","$buttons","querySelectorAll","forEach","$button","HTMLButtonElement","type","event","target","classList","contains","$items","getItems","$item","getNewItem","HTMLElement","updateAttributes","length","resetItem","$firstItem","hasRemoveButton","createRemoveButton","after","$input","querySelector","HTMLInputElement","focus","Array","from","filter","item","cloneNode","index","name","getAttribute","id","originalId","replace","$label","parentElement","closest","HTMLLabelElement","htmlFor","document","createElement","add","textContent","append","checked","value","remove","focusHeading","$heading","moduleName"],"mappings":";;;;;;EAEO,MAAMA,UAAU,SAASC,uBAAS,CAAC;EACxC;EACF;EACA;IACEC,WAAWA,CAACC,KAAK,EAAE;MACjB,KAAK,CAACA,KAAK,CAAC;EAEZ,IAAA,IAAI,CAACA,KAAK,CAACC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAACC,mBAAmB,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;EACzE,IAAA,IAAI,CAACH,KAAK,CAACC,gBAAgB,CAAC,OAAO,EAAE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