Skip to content

Commit

Permalink
Merge pull request #62 from qld-gov-au/remove-jquery-reference-from-c…
Browse files Browse the repository at this point in the history
…ustom-component-library

Remove jquery reference from custom component library
  • Loading branch information
devonpis authored May 26, 2022
2 parents ae80f10 + 11680f6 commit 9c6d78e
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
framework: "@storybook/html",
staticDirs: ["../lib", "../node_modules/jquery/dist"],
staticDirs: ["../lib"],
core: {
builder: "webpack5",
},
Expand Down
1 change: 0 additions & 1 deletion .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<link href="https://www.qld.gov.au/_qgdesigns/css/qg-main.css?v=0.3.0" rel="stylesheet">
<link href="https://www.qld.gov.au/__data/assets/css_file_folder/0015/110823/qg-components.css?v=0.1.10" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="./jquery.min.js"></script>
<script src="./formio.full.js"></script>
<script src="./premium.min.js"></script>
<link rel="stylesheet" href="./formio.full.min.css">
Expand Down
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"formiojs": "^4.14.2",
"jest": "^27.5.1",
"jest-raw-loader": "^1.0.1",
"jquery": "^3.6.0",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^2.6.0",
"node-sass": "^7.0.1",
Expand Down
1 change: 0 additions & 1 deletion src/examples/DownloadPdf/DownloadPdf.code.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DownloadPdf } from "!!./DownloadPdf";

export const downloadPdfCode = `
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://static.qgov.net.au/formio-qld/v1/v1.x.x-latest/formio-script.min.js"></script>
</head>
<body>
Expand Down
2 changes: 2 additions & 0 deletions src/examples/DownloadPdf/DownloadPdf.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { downloadPdfWizardCode } from "./DownloadPdfWizard.code";

# Download PDF example

This example is still in BETA.

This example using the form.io form action and PdfSubmitButton component to enable PDF generation for the submission.

TODO - document the process of setup the form action in form.io, with the action title needed to be `pdfUrl`
Expand Down
1 change: 0 additions & 1 deletion src/examples/DownloadPdf/DownloadPdfWizard.code.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DownloadPdfWizard } from "!!./DownloadPdfWizard";

export const downloadPdfWizardCode = `
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://static.qgov.net.au/formio-qld/v1/v1.x.x-latest/formio-script.min.js"></script>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion src/examples/SimpleWizard/SimpleWizard.code.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SimpleWizard } from "!!./SimpleWizard";

export const simpleWizardCode = `
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://static.qgov.net.au/formio-qld/v1/v1.x.x-latest/formio-script.min.js"></script>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion src/examples/SingleSignOn/SingleSignOn.code.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SingleSignOn } from "!!./SingleSignOn";

export const singleSignOnCode = `
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://static.qgov.net.au/formio-qld/v1/v1.x.x-latest/formio-script.min.js"></script>
</head>
<body>
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/FormioLoader/FormioLoader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import defaultCreateFormOptions from "../../config/createForm.options";
import defaultCreateFormController from "../../config/createForm.controller";
import { delegateSelector } from "../../utils/delegateSelector";

// plugin function to fix the namespace/project option doesn't pass to Formio.makeRequest/Formio.makeStaticRequest
const requestPluginHandler = (requestArgs, opts) => {
Expand Down Expand Up @@ -124,7 +125,7 @@ const initFormioInstance = (elem, opts) => {
opts.createFormCallback(callbackProps);
} else {
// Force new tab on formlinks
$(elem).on("click", `a`, (e) => {
delegateSelector(elem, "click", "a", (e) => {
e.target.target = "_blank";
});
}
Expand Down
1 change: 0 additions & 1 deletion src/test/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getComponents } from "../utils/getComponents";

global.window.scrollTo = jest.fn();
global.premium = {};
global.$ = require("jquery");

Formio.use({
components: getComponents(components),
Expand Down
24 changes: 24 additions & 0 deletions src/utils/delegateSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const delegateSelector = (elements, event, childSelector, handler) => {
const is = (el, s) => {
return (
el.matches ||
el.matchesSelector ||
el.msMatchesSelector ||
el.mozMatchesSelector ||
el.webkitMatchesSelector ||
el.oMatchesSelector
).call(el, s);
};
const addEvent = (el) => {
el.addEventListener(event, (e) => {
if (is(e.target, childSelector)) {
handler(e);
}
});
};
if (Array.isArray(elements)) {
[].forEach.call(elements, addEvent);
} else {
addEvent(elements);
}
};

0 comments on commit 9c6d78e

Please sign in to comment.