-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide bundled JavaScript UMD export
- Loading branch information
1 parent
ee8fb10
commit a7f590e
Showing
5 changed files
with
199 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import commonJs from '@rollup/plugin-commonjs' | ||
import { nodeResolve } from '@rollup/plugin-node-resolve' | ||
|
||
export default [{ | ||
input: [ | ||
'x-govuk/all.mjs' | ||
], | ||
output: { | ||
dir: 'x-govuk', | ||
format: 'umd', | ||
name: 'GOVUKPrototypeComponents' | ||
}, | ||
plugins: [ | ||
nodeResolve(), | ||
commonJs() | ||
] | ||
}] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Autocomplete from './components/autocomplete/autocomplete.js' | ||
import Edge from './components/edge/edge.js' | ||
import WarnOnUnsavedChanges from './components/warn-on-unsaved-changes/warn-on-unsaved-changes.js' | ||
|
||
function initAll (options) { | ||
// Set the options to an empty object by default if no options are passed. | ||
options = typeof options !== 'undefined' ? options : {} | ||
|
||
// Allow user to initialise components in only certain sections of the page | ||
// Defaults to the entire document if nothing is set. | ||
const scope = typeof options.scope !== 'undefined' ? options.scope : document | ||
|
||
const $autocompletes = scope.querySelectorAll('[data-module="autocomplete"]') | ||
$autocompletes.forEach(function ($autocomplete) { | ||
new Autocomplete($autocomplete).init() | ||
}) | ||
|
||
const $edges = scope.querySelectorAll('[data-module="edge"]') | ||
$edges.forEach(function ($edge) { | ||
new Edge($edge).init() | ||
}) | ||
|
||
const $forms = scope.querySelectorAll('[data-module="warn-on-unsaved-changes"]') | ||
$forms.forEach(function ($form) { | ||
new WarnOnUnsavedChanges($form).init() | ||
}) | ||
} | ||
|
||
export { | ||
initAll, | ||
Autocomplete, | ||
Edge, | ||
WarnOnUnsavedChanges | ||
} |