formio-sfds
Version:
form.io templates for the SF Design System
2 lines (1 loc) • 9.43 kB
JavaScript
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e,i){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var i=[],s=!0,n=!1,o=void 0;try{for(var l,r=e[Symbol.iterator]();!(s=(l=r.next()).done)&&(i.push(l.value),!t||i.length!==t);s=!0);}catch(e){n=!0,o=e}finally{try{s||null==r.return||r.return()}finally{if(n)throw o}}return i}(e,i)||t(e,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){if(e){if("string"==typeof e)return i(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}function s(e,i){var s;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(s=t(e))||i&&e&&"number"==typeof e.length){s&&(e=s);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,r=!0,a=!1;return{s:function(){s=e[Symbol.iterator]()},n:function(){var e=s.next();return r=e.done,e},e:function(e){a=!0,l=e},f:function(){try{r||null==s.return||s.return()}finally{if(a)throw l}}}}var n=[{id:"single-file",title:"Single file upload",form:{components:[{type:"file",storage:"base64",label:"This is the label",description:"This is the description"}]}},{id:"multi-file",title:"Multiple file upload",form:{components:[{type:"file",storage:"base64",label:"This is the label",description:"This is the description",multiple:!0}]}},{id:"checkbox",title:"Checkbox",form:{components:[{type:"checkbox",label:"This is a long label, and it should wrap nicely alongside the checkbox with the description below it.",description:"And this is the description",tooltip:"And this is the tooltip"}]}},{id:"radio",title:"Radio",form:{components:[{type:"radio",label:"This is the label",description:"And this is the description",tooltip:"And this is the tooltip",values:[{label:"Option 1",value:1},{label:"Option 2 (blah)",value:2},{label:"Option 3 (this is some really long text that should wrap nicely, thanks so much)",value:3}]}]}},{id:"selectboxes",title:"Select boxes",form:{components:[{type:"selectboxes",label:"This is the label",description:"And this is the description",tooltip:"And this is the tooltip",values:[{label:"Option 1",value:1},{label:"Option 2 (blah)",value:2},{label:"Option 3 (this is some really long text that should wrap nicely, thanks so much)",value:3}]}]}},{id:"us-state",title:"U.S. state select (custom component)",form:{components:[{type:"state",label:"This is the label",description:"This is the description",tooltip:"And this is the tooltip"}]}},{id:"zip-code",title:"ZIP code",form:{components:[{type:"zip",label:"This is the label",description:"This is the description",tooltip:"And this is the tooltip"}]}},{id:"columns-2",title:"Columns (2)",form:{components:[{type:"columns",columns:[{width:3,components:[{type:"textfield",key:"a",label:"Field 1"}]},{width:3,components:[{type:"textfield",key:"b",label:"Field 2"}]}]}]}},{id:"columns-3",title:"Columns (3)",form:{components:[{type:"columns",columns:[{width:2,components:[{type:"textfield",key:"a",label:"Field 1"}]},{width:2,components:[{type:"textfield",key:"b",label:"Field 2"}]},{width:2,components:[{type:"number",key:"c",label:"Field 3",defaultValue:10}]}]}]}},{id:"address",title:"Address (custom component)",form:{components:[{type:"address",label:"This is the label",description:"This is the description",tooltip:"And this is the tooltip",multiple:!0}]}},{id:"day-default",title:"Day (default)",form:{components:[{type:"day",label:"This is the label",description:"This is the description"}]}},{id:"datetime-date-only",title:"Date (no time)",form:{components:[{type:"datetime",label:"This is the label",description:"This is the description",enableTime:!1}]}},{id:"datetime-default",title:"Date & time",form:{components:[{type:"datetime",label:"This is the label",description:"This is the description"}]}},{id:"datetime-spanish",title:"Date & time (Spanish)",form:{components:[{type:"datetime",label:"This is the label",description:"This is the description"}]},options:{language:"es"}},{id:"datetime-chinese",title:"Date & time (Chinese traditional)",form:{components:[{type:"datetime",label:"This is the label",description:"This is the description"}]},options:{language:"zh-tw"}},{id:"datetime-chinese-simplified",title:"Date & time (Chinese simplified)",form:{components:[{type:"datetime",label:"This is the label",description:"This is the description"}]},options:{language:"zh"}},{id:"datetime-time-only",title:"Time (no date)",form:{components:[{type:"datetime",label:"This is the label",description:"This is the description",enableDate:!1}]}}],o={name:"formio-sfds",version:"6.0.0",description:"form.io templates for the SF Design System",module:"src/index.js",main:"dist/formio-sfds.cjs.js",browser:"dist/formio-sfds.umd.js",style:"dist/formio-sfds.css",scripts:{build:"run-s build-css build-js","build-css":"postcss src/scss/{common,formio-sfds}.scss --ext css --dir dist","build-js":"rollup -c",lint:"run-p 'lint-*'","lint-css":"stylelint src/scss/**/*.scss","lint-js":"standard src",test:"echo 'WARNING: no tests!'","update-translations":"script/get-translations > src/i18n/translations.json",watch:"npm run build-css && run-p 'watch-*'","watch-css":"watchy -w 'src/scss/**/*.scss' -- npm run build-css","watch-js":"rollup -c --watch"},browserslist:["> 1%","ie 11"],repository:"SFDigitalServices/formio-sfds",keywords:["formio","sf-design-system"],author:"San Francisco Digital Services",license:"MIT","@primer/publish":{releaseBranch:"main"},dependencies:{"choices.js":"^9.0.1",flatpickr:"^4.6.3",formiojs:"4.10.4",interpolate:"^0.1.0","rollup-plugin-terser":"^5.3.0","uri-template-lite":"^19.12.0","whatwg-fetch":"^3.0.0"},devDependencies:{"@babel/cli":"^7.10.1","@babel/core":"^7.10.1","@babel/preset-env":"^7.10.2","@csstools/postcss-sass":"^4.0.0","@rollup/plugin-commonjs":"^11.1.0","@rollup/plugin-dsv":"^2.0.1","@rollup/plugin-json":"^4.0.3","@rollup/plugin-node-resolve":"^7.1.3","@rollup/plugin-yaml":"^2.1.1",autoprefixer:"^9.8.0",dotenv:"^8.2.0","google-spreadsheet":"^3.0.11",i18next:"^19.4.5","npm-run-all":"^4.1.5",postcss:"^7.0.31","postcss-cli":"^7.1.1","postcss-import":"^12.0.1","postcss-inline-svg":"^4.1.0","postcss-scss":"^2.1.1","regenerator-runtime":"^0.13.5",rollup:"^2.11.2","rollup-plugin-babel":"^4.4.0","rollup-plugin-jst":"^1.2.0","rollup-plugin-postcss":"^2.9.0","rollup-plugin-svgo":"^1.1.0",sass:"^1.26.5","selector-observer":"^2.1.6","sf-design-system":"^1.3.0",standard:"^14.3.4",stylelint:"^13.5.0","stylelint-config-recommended-scss":"^4.2.0","stylelint-config-standard-scss":"^1.1.0","stylelint-scss":"^3.17.2",watchy:"^0.9.7"}};!function(){var t=window.Formio,i={display:"form",language:"en"},l=window.location,r=l.search,a=l.hash,c=r||(a?a.substr(1):null);if(c){var d,p=s(new URLSearchParams(c).entries());try{for(p.s();!(d=p.n()).done;){var u=e(d.value,2),h=u[0],m=u[1];i[h]=m}}catch(e){p.e(e)}finally{p.f()}}var f,b=s(document.querySelectorAll("[data-package]"));try{for(b.s();!(f=b.n()).done;){var y=f.value;y.textContent=o[y.getAttribute("data-package")]}}catch(e){b.e(e)}finally{b.f()}var g=document.getElementById("form-template"),v=document.getElementById("example-link"),w=[];n.sort((function(e,t){return e.title&&t.title?e.title.localeCompare(t.title):0}));var T,S=s(n);try{for(S.s();!(T=S.n()).done;){var x=T.value,j=v.content.cloneNode(!0).firstElementChild,A=j.querySelector("[slot=link]");A.href="#".concat(x.id),A.textContent=x.title||x.id,v.parentNode.appendChild(j);var k=g.content.cloneNode(!0).firstElementChild;g.parentNode.appendChild(k);try{var C=O(x,k);w.push(C)}catch(e){k.querySelector("form").innerHTML=D(e)}}}catch(e){S.e(e)}finally{S.f()}function O(s,n){var o=s.id,l=s.title,r=s.form;n.id=o,n.querySelector("[slot=title]").innerHTML='<a href="#'.concat(o,'" class="fg-grey-4 no-u">#</a> ').concat(l||o);var a=n.querySelector("[name=data]"),c=function t(i){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];for(var l=0,r=n;l<r.length;l++){var a=r[l];if(a)for(var c=0,d=Object.entries(a);c<d.length;c++){var p=e(d[c],2),u=p[0],h=p[1];i[u]instanceof Object&&h instanceof Object?i[u]=t(i[u],h):i[u]=h}}return i}({},i,s.options);console.warn("options:",c);var d=n.querySelector("form");return t.createForm(d,r,c).then((function(e){var t=a.offsetHeight-a.clientHeight;e.on("change",(function(){a.value=JSON.stringify(e.submission.data,null,2),a.style.height="auto",a.style.height="".concat(a.scrollHeight+t,"px")}))})).catch((function(e){r.innerHTML=D(e)}))}function D(e){return'<div role="alert" class="round-1 fg-red-4 bg-red-1"><pre class="p-1 m-0">'.concat(e.stack,"</pre></div>")}Promise.all(w).then((function(){console.info("%d forms loaded!",w.length);var e=window.location.hash;e&&(document.querySelector(e)&&(window.location=e))}))}()}));