@lrnwebcomponents/hax-body-behaviors
Advanced tools
Comparing version 2.0.10 to 2.1.0
{ | ||
"schema_version": "1.0.0", | ||
"functions": [ | ||
{ | ||
"name": "HAXElement", | ||
"description": "Super class element partial. This mixes the HAXWiring capabilities into the element itself.\nUse this in instances where you want direct access to all the functions in the element itself\n ", | ||
"summary": "", | ||
"sourceRange": { | ||
"file": "lib/HAXWiring.js", | ||
"start": { | ||
"line": 1046, | ||
"column": 26 | ||
}, | ||
"end": { | ||
"line": 1153, | ||
"column": 1 | ||
} | ||
}, | ||
"privacy": "public", | ||
"params": [] | ||
} | ||
], | ||
"classes": [ | ||
{ | ||
"description": "Object to validate HAX", | ||
"description": "Object to validate HAX schema. Can be used in and out of element contexts", | ||
"summary": "", | ||
@@ -25,4 +45,272 @@ "path": "lib/HAXWiring.js", | ||
"name": "HAXWiring" | ||
}, | ||
{ | ||
"description": "", | ||
"summary": "", | ||
"path": "lib/HAXWiring.js", | ||
"properties": [], | ||
"methods": [ | ||
{ | ||
"name": "setHaxProperties", | ||
"description": "Setter to bridge private haxProperties setter.\nThis is to then be implemented by the ready state of whatever is supplying the\nproperties in order to be able to bubble up the properties for a tag.", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1069, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1086, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "props" | ||
}, | ||
{ | ||
"name": "tag", | ||
"defaultValue": "\"\"" | ||
}, | ||
{ | ||
"name": "context", | ||
"defaultValue": "this" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "setup", | ||
"description": "Setter to bridge private haxProperties setter.\nThis is to then be implemented by the ready state of whatever is supplying the\nproperties in order to be able to bubble up the properties for a tag.", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1092, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1094, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "props" | ||
}, | ||
{ | ||
"name": "tag", | ||
"defaultValue": "\"\"" | ||
}, | ||
{ | ||
"name": "context", | ||
"defaultValue": "this" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "_haxStoreReady", | ||
"description": "Private function to fire off props when ready", | ||
"privacy": "protected", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1098, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1100, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "e" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "validateSetting", | ||
"description": "Validate settings object.", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1104, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1106, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "setting" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "getHaxProperties", | ||
"description": "Match convention for set.", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1110, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1112, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [] | ||
}, | ||
{ | ||
"name": "getHaxJSONSchema", | ||
"description": "Convert haxProperties structure to a simple json-schema.\nThis allows for complex form building systems based on this data.\ntype is configure or advanced", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1118, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1120, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "type" | ||
}, | ||
{ | ||
"name": "haxProperties" | ||
}, | ||
{ | ||
"name": "target", | ||
"defaultValue": "this" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "postProcessgetHaxJSONSchema", | ||
"description": "Default postProcessgetHaxJSONSchema to be overridden.", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1124, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1126, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "schema" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "_getHaxJSONSchemaProperty", | ||
"description": "Internal helper for getHaxJSONSchema to buiild the properties object\ncorrectly with support for recursive nesting thx to objects / arrays.", | ||
"privacy": "protected", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1131, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1133, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "settings" | ||
}, | ||
{ | ||
"name": "target" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "getHaxJSONSchemaType", | ||
"description": "Convert input method to schedma type", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1137, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1139, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [ | ||
{ | ||
"name": "inputMethod" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "validHAXPropertyInputMethod", | ||
"description": "List valid input methods.", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1143, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1145, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [] | ||
}, | ||
{ | ||
"name": "prototypeHaxProperties", | ||
"description": "Return a haxProperties prototype / example structure", | ||
"privacy": "public", | ||
"sourceRange": { | ||
"start": { | ||
"line": 1149, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1151, | ||
"column": 5 | ||
} | ||
}, | ||
"metadata": {}, | ||
"params": [] | ||
} | ||
], | ||
"staticMethods": [], | ||
"demos": [], | ||
"metadata": {}, | ||
"sourceRange": { | ||
"start": { | ||
"line": 1047, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 1152, | ||
"column": 3 | ||
} | ||
}, | ||
"privacy": "public", | ||
"superclass": "SuperClass" | ||
} | ||
] | ||
} |
@@ -65,4 +65,8 @@ const gulp = require("gulp"); | ||
// properties available to the custom element for data binding | ||
static get properties() { | ||
return ${props}; | ||
static get properties() { | ||
let props = ${props}; | ||
if (super.properties) { | ||
props = Object.assign(props, super.properties); | ||
} | ||
return props; | ||
}`; | ||
@@ -69,0 +73,0 @@ } |
@@ -1,1 +0,1 @@ | ||
define(["exports","./lib/HAXWiring.js"],function(_exports,_HAXWiring){"use strict";Object.defineProperty(_exports,"__esModule",{value:!0});Object.defineProperty(_exports,"HAXWiring",{enumerable:!0,get:function get(){return _HAXWiring.HAXWiring}})}); | ||
define(["exports","./lib/HAXWiring.js"],function(_exports,_HAXWiring){"use strict";Object.defineProperty(_exports,"__esModule",{value:!0});Object.defineProperty(_exports,"HAXWiring",{enumerable:!0,get:function get(){return _HAXWiring.HAXWiring}});Object.defineProperty(_exports,"HAXElement",{enumerable:!0,get:function get(){return _HAXWiring.HAXElement}})}); |
/** | ||
* Copyright 2018 The Pennsylvania State University | ||
* @license Apache-2.0, see License.md for full text. | ||
*/import{HAXWiring}from"./lib/HAXWiring.js";export{HAXWiring}; | ||
*/import{HAXWiring,HAXElement}from"./lib/HAXWiring.js";export{HAXWiring,HAXElement}; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
import { HAXWiring } from "./lib/HAXWiring.js"; | ||
export { HAXWiring }; | ||
import { HAXWiring, HAXElement } from "./lib/HAXWiring.js"; | ||
export { HAXWiring, HAXElement }; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@polymer/polymer/lib/legacy/polymer.dom.js")):"function"==typeof define&&define.amd?define(["exports","@polymer/polymer/lib/legacy/polymer.dom.js"],t):t((e=e||self).HaxBodyBehaviors={},e.polymer_dom_js)}(this,function(e,t){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=function e(){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.haxProperties={canScale:!1,canPosition:!1,canEditSource:!1,settings:{quick:[],configure:[],advanced:[]},wipeSlot:{}},this.setup=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;return"undefined"!==i(r.tagName)&&(t=r.tagName.toLowerCase()),window.addEventListener("hax-store-ready",r._haxStoreReady.bind(r)),"undefined"!==i(window.HaxStore)&&null!=window.HaxStore.instance&&window.HaxStore.ready?r.setHaxProperties(e,t,o,!0):r.setHaxProperties(e,t,o,!1)},this._haxStoreReady=function(e){if(e.detail&&"undefined"!==i(r.tagName)&&"undefined"!==i(r.haxProperties)){var t=r.tagName,o=r.haxProperties,a=r;if(""!=t&&"undefined"===i(window.HaxStore)){var n=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:o,polymer:!1}});a.dispatchEvent(n)}else if(""!=t&&"undefined"===i(window.HaxStore.instance.elementList[t.toLowerCase()])){var d=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:o}});a.dispatchEvent(d)}else if("undefined"!==i(r.tagName)&&"undefined"===i(window.HaxStore.instance.elementList[r.tagName.toLowerCase()])){var s=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:r.tagName.toLowerCase(),properties:o}});a.dispatchEvent(s)}}},this.setHaxProperties=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:document,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("undefined"===i(e.api)&&(e.api="1"),"1"==e.api){if("undefined"===i(e.canPosition)&&(e.canPosition=!0),"undefined"===i(e.canScale)&&(e.canScale=!0),"undefined"===i(e.canEditSource)&&(e.canEditSource=!1),"undefined"===i(e.gizmo)&&(e.gizmo=!1),"undefined"!==i(e.settings)){"undefined"===i(e.settings.quick)&&(e.settings.quick=[]);for(var n=0;n<e.settings.quick.length;n++)e.settings.quick[n]=r.validateSetting(e.settings.quick[n]),e.settings.quick[n]||e.settings.quick.splice(n,1);"undefined"===i(e.settings.configure)&&(e.settings.configure=[]);for(var d=0;d<e.settings.configure.length;d++)e.settings.configure[d]=r.validateSetting(e.settings.configure[d]),e.settings.configure[d]||e.settings.configure.splice(d,1);"undefined"===i(e.settings.advanced)&&(e.settings.advanced=[]);for(var s=0;s<e.settings.advanced.length;s++)e.settings.advanced[s]=r.validateSetting(e.settings.advanced[s]),e.settings.advanced[s]||e.settings.advanced.splice(s,1);e.settings.advanced.push({attribute:"class",title:"Classes",description:"CSS classes applied manually to the element",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"style",title:"Styles",description:"Custom CSS styles as applied to the element",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"prefix",title:"Schema: prefix",description:"Schema prefixes",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"typeof",title:"Schema: TypeOf",description:"typeof definition for Schema usage",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"property",title:"Schema: Property",description:"typeof definition for Schema usage",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"resource",title:"Schema: Resource ID",description:"Schema resource identifier",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"id",title:"ID",description:"element ID, only set this if you know why",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"slot",title:"slot",description:"DOM slot area",inputMethod:"textfield"})}if("undefined"===i(e.saveOptions)&&(e.saveOptions={wipeSlot:!1}),a)if(""!=t&&"undefined"===i(window.HaxStore)){var p=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:e,polymer:!1}});o.dispatchEvent(p)}else if(""!=t){var u=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:e}});o.dispatchEvent(u)}else if("undefined"!==i(r.tagName)){var l=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:r.tagName.toLowerCase(),properties:e}});o.dispatchEvent(l)}else console.warn("".concat(t," missed our checks and has an issue in implementation with HAX"));""===t&&("function"==typeof r._setHaxProperties?r._setHaxProperties(e):r.haxProperties=e)}else console.warn("This is't a valid usage of hax API. See hax-body-behaviors/lib/HAXWiring.js for more details on how to implement the API. Most likely your hax item just was placed in an iframe as a fallback as opposed to a custom element.")},this.validateSetting=function(e){return("undefined"!==i(e.property)||"undefined"!==i(e.slot)||"undefined"!==i(e.attribute))&&("undefined"===i(e.title)&&("undefined"===i(e.attribute)?e.title=e.property:e.title=e.attribute),"undefined"===i(e.description)&&(e.description=""),"undefined"===i(e.inputMethod)&&(e.inputMethod="textfield"),"undefined"===i(e.type)&&(e.type="settings"),"undefined"===i(e.icon)&&(e.icon="android"),"undefined"===i(e.options)&&(e.options={}),"undefined"===i(e.required)&&(e.required=!1),"undefined"===i(e.validation)&&(e.validation=".*"),"undefined"===i(e.validationType)&&(e.validationType=""),"undefined"!==i(e.slot)&&("undefined"===i(e.slotWrapper)&&(e.slotWrapper="span"),"undefined"===i(e.slotAttributes)&&(e.slotAttributes={})),e)},this.getHaxProperties=function(){return r.haxProperties},this.getHaxJSONSchema=function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;"undefined"===i(e)&&(e="configure"),"undefined"===i(t)&&(t=o.haxProperties);var a=t.settings[e],n={$schema:"http://json-schema.org/schema#",title:"HAX "+e+" form schema",type:"object",properties:{}};return n.properties=o._getHaxJSONSchemaProperty(a,o),n=o.postProcessgetHaxJSONSchema(n)},this.postProcessgetHaxJSONSchema=function(e){return e},this._getHaxJSONSchemaProperty=function(e,r){var o={};for(var a in e)if(e.hasOwnProperty(a))if("undefined"!==i(e[a].property))switch(o[e[a].property]={title:e[a].title,type:r.getHaxJSONSchemaType(e[a].inputMethod)},"undefined"!==i(r[e[a].property])&&(o[e[a].property].value=r[e[a].property]),"url"==e[a].validationType&&(o[e[a].property].format="uri"),"datepicker"==e[a].inputMethod&&(o[e[a].property].format="date-time"),".*"!=e[a].validation&&(o[e[a].property].pattern=e[a].validation),e[a].inputMethod){case"number":o[e[a].property].component={name:"paper-input",valueProperty:"value",properties:{required:e[a].required},attributes:{type:"number"}};break;case"select":var n=[];for(var d in e[a].options){var s=[{alt:e[a].options[d],value:d}];n.push(s)}o[e[a].property].component={name:"simple-picker",valueProperty:"value",properties:{required:e[a].required,options:n}};break;case"textarea":o[e[a].property].component={name:"paper-textarea",valueProperty:"value",properties:{required:e[a].required},attributes:{"auto-validate":"auto-validate","char-counter":"char-counter"}};break;case"code-editor":o[e[a].property].component={name:"code-editor",valueProperty:"value",properties:{title:e[a].title,theme:"hc-black",mode:"html",className:"hax-code-editor"}};break;case"array":o[e[a].property].items={type:"object",properties:r._getHaxJSONSchemaProperty(e[a].properties,r)};break;case"textfield":o[e[a].property].component={name:"paper-input",valueProperty:"value",properties:{required:e[a].required},attributes:{"auto-validate":"auto-validate"}};break;case"alt":o[e[a].property].component={name:"paper-input-flagged",valueProperty:"value",properties:{required:e[a].required},attributes:{"auto-validate":"auto-validate"}};break;case"colorpicker":o[e[a].property].component={name:"simple-colors-picker",valueProperty:"value",properties:{required:e[a].required,label:e[a].title}};break;case"iconpicker":o[e[a].property].component={name:"simple-icon-picker",valueProperty:"value",properties:{required:e[a].required,hideOptionLabels:!0,label:e[a].title}};var p=void 0!==e[a].options&&null!==e[a].options?e[a].options:[];o[e[a].property].component.properties.icons=p;break;case"datepicker":o[e[a].property].component={name:"app-datepicker",valueProperty:"date",properties:{required:e[a].required,autoUpdateDate:!0}};break;case"haxupload":o[e[a].property].component={name:"hax-upload-field",valueProperty:"value",properties:{formDataName:"file-upload"}}}else if("undefined"!==i(e[a].attribute))switch(o[e[a].attribute]={title:e[a].title,type:r.getHaxJSONSchemaType(e[a].inputMethod)},"class"===e[a].attribute?o[e[a].attribute].value=r.className:"style"===e[a].attribute?o[e[a].attribute].value=r.style.cssText:"undefined"!==i(r.attributes[e[a].attribute])&&(o[e[a].attribute].value=r.getAttribute(e[a].attribute)),"href"!=a&&"src"!=a||(o[e[a].attribute].format="uri"),"url"==e[a].validationType&&(o[e[a].attribute].format="uri"),"datepicker"==e[a].inputMethod&&(o[e[a].attribute].format="date-time"),".*"!=e[a].validation&&(o[e[a].attribute].pattern=e[a].validation),e[a].inputMethod){case"number":o[e[a].attribute].component={name:"paper-input",valueProperty:"value",properties:{required:e[a].required},attributes:{type:"number"}};break;case"select":var u=[];for(var d in e[a].options){var l=[{alt:e[a].options[d],value:d}];u.push(l)}o[e[a].attribute].component={name:"simple-picker",valueProperty:"value",properties:{required:e[a].required,options:u}};break;case"textarea":o[e[a].attribute].component={name:"paper-textarea",valueProperty:"value",properties:{required:e[a].required},attributes:{"auto-validate":"auto-validate","char-counter":"char-counter"}};break;case"code-editor":o[e[a].attribute].component={name:"code-editor",valueProperty:"value",properties:{title:e[a].title,readOnly:!1,theme:"hc-black",mode:"html",className:"hax-code-editor"}};break;case"textfield":o[e[a].attribute].component={name:"paper-input",valueProperty:"value",properties:{required:e[a].required},attributes:{"auto-validate":"auto-validate"}};break;case"alt":o[e[a].attribute].component={name:"paper-input-flagged",valueProperty:"value",properties:{required:e[a].required},attributes:{"auto-validate":"auto-validate"}};break;case"colorpicker":o[e[a].attribute].component={name:"simple-colors-picker",valueProperty:"value",properties:{required:e[a].required}};break;case"haxupload":o[e[a].attribute].component={name:"hax-upload-field",valueProperty:"value",properties:{formDataName:"file-upload"}}}else{o[e[a].slot]={title:e[a].title,type:r.getHaxJSONSchemaType(e[a].inputMethod),value:"",component:{name:"code-editor",valueProperty:"value",properties:{title:e[a].title,theme:"hc-black",mode:"html",className:"hax-code-editor"}}};var c="";for(var h in t.dom(r).childNodes)"undefined"!==i(t.dom(r).childNodes[h])&&(1===t.dom(r).childNodes[h].nodeType?e[a].slot===t.dom(r).childNodes[h].slot&&(c+=t.dom(r).childNodes[h].innerHTML):1!==t.dom(r).childNodes[h].nodeType&&"undefined"!==i(t.dom(r).childNodes[h].textContent)&&""!==t.dom(r).childNodes[h].textContent&&(c+=t.dom(r).childNodes[h].textContent));o[e[a].slot].component.slot="<template>"+c.trim()+"</template>"}return o},this.getHaxJSONSchemaType=function(e){if(r.validHAXPropertyInputMethod().includes(e))switch(e){case"flipboolean":case"boolean":return"boolean";case"number":return"number";case"select":case"textarea":case"colorpicker":case"iconpicker":case"datepicker":case"haxupload":case"textfield":case"alt":return"string";case"array":return"array";default:return"string"}},this.validHAXPropertyInputMethod=function(){return["flipboolean","boolean","select","textfield","textarea","datepicker","haxupload","colorpicker","iconpicker","alt","number","code-editor","array"]},this.prototypeHaxProperties=function(){return{api:"1",canScale:!0,canPosition:!0,canEditSource:!1,gizmo:{title:"Tag name",description:"A description",icon:"av:play-circle-filled",color:"blue",groups:["Content"],handles:[{type:"data",url:"src"}],meta:{author:""}},settings:{quick:[{property:"title",title:"Title",inputMethod:"textfield",icon:"android"},{property:"primaryColor",title:"Primary color",inputMethod:"colorpicker",icon:"color"}],configure:[{slot:"",title:"Inner content",description:"The slotted content that lives inside the tag",inputMethod:"textfield",icon:"android",required:!0,validationType:"text"},{slot:"button",title:"Button content",description:"The content that can override the button",inputMethod:"textfield",icon:"android",required:!0,validationType:"text"},{property:"title",title:"Title",description:"",inputMethod:"textfield",icon:"android",required:!0,validationType:"text"},{property:"primaryColor",title:"Title",description:"",inputMethod:"textfield",icon:"android",required:!1,validation:".*",validationType:"text"}],advanced:[{property:"secondaryColor",title:"Secondary color",description:"An optional secondary color used in certain edge cases.",inputMethod:"colorpicker",icon:"color"},{property:"endPoint",title:"API endpoint",description:"An optional endpoint to hit and load in more data dymaically.",inputMethod:"textfield",icon:"android",validation:"[a-z0-9]",validationType:"url"}]},saveOptions:{wipeSlot:!1,unsetAttributes:["end-point","secondary-color"]}}}};window.HAXWiring=new r,window.HAXBehaviors=window.HAXBehaviors||{},window.HAXBehaviors.PropertiesBehaviors={properties:{haxProperties:window.HAXWiring.haxProperties},setHaxProperties:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;return""==t&&"undefined"!==i(this.tagName)&&(t=this.tagName.toLowerCase()),window.addEventListener("hax-store-ready",this._haxStoreReady.bind(this)),"undefined"!==i(window.HaxStore)&&null!=window.HaxStore.instance&&window.HaxStore.ready?window.HAXWiring.setHaxProperties(e,t,r,!0):window.HAXWiring.setHaxProperties(e,t,r,!1)},_haxStoreReady:function(e){return window.HAXWiring._haxStoreReady(e)},validateSetting:function(e){return window.HAXWiring.validateSetting(e)},getHaxProperties:function(){return this.haxProperties},getHaxJSONSchema:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;return window.HAXWiring.getHaxJSONSchema(e,t,i)},postProcessgetHaxJSONSchema:function(e){return window.HAXWiring.postProcessgetHaxJSONSchema(e)},_getHaxJSONSchemaProperty:function(e,t){return window.HAXWiring._getHaxJSONSchemaProperty(e,t)},getHaxJSONSchemaType:function(e){return window.HAXWiring.getHaxJSONSchemaType(e)},validHAXPropertyInputMethod:function(){return window.HAXWiring.validHAXPropertyInputMethod()},prototypeHaxProperties:function(){return window.HAXWiring.prototypeHaxProperties()}},e.HAXWiring=r,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@polymer/polymer/lib/legacy/polymer.dom.js")):"function"==typeof define&&define.amd?define(["exports","@polymer/polymer/lib/legacy/polymer.dom.js"],t):t((e=e||self).HaxBodyBehaviors={},e.polymer_dom_js)}(this,function(e,t){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e,t,i){return(p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=n(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(i):o.value}})(e,t,i||e)}var d=function e(){var o=this;r(this,e),this.haxProperties={canScale:!1,canPosition:!1,canEditSource:!1,settings:{quick:[],configure:[],advanced:[]},wipeSlot:{}},this.setup=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return"undefined"!==i(o.tagName)&&(t=o.tagName.toLowerCase()),window.addEventListener("hax-store-ready",o._haxStoreReady.bind(o)),"undefined"!==i(window.HaxStore)&&null!=window.HaxStore.instance&&window.HaxStore.ready?o.setHaxProperties(e,t,r,!0):o.setHaxProperties(e,t,r,!1)},this._haxStoreReady=function(e){if(e.detail&&"undefined"!==i(o.tagName)&&"undefined"!==i(o.haxProperties)){var t=o.tagName,r=o.haxProperties,n=o;if(""!=t&&"undefined"===i(window.HaxStore)){var a=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:r,polymer:!1}});n.dispatchEvent(a)}else if(""!=t&&"undefined"===i(window.HaxStore.instance.elementList[t.toLowerCase()])){var s=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:r}});n.dispatchEvent(s)}else if("undefined"!==i(o.tagName)&&"undefined"===i(window.HaxStore.instance.elementList[o.tagName.toLowerCase()])){var p=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:o.tagName.toLowerCase(),properties:r}});n.dispatchEvent(p)}}},this.setHaxProperties=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:document,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("undefined"===i(e.api)&&(e.api="1"),"1"==e.api){if("undefined"===i(e.canPosition)&&(e.canPosition=!0),"undefined"===i(e.canScale)&&(e.canScale=!0),"undefined"===i(e.canEditSource)&&(e.canEditSource=!1),"undefined"===i(e.gizmo)&&(e.gizmo=!1),"undefined"!==i(e.settings)){"undefined"===i(e.settings.quick)&&(e.settings.quick=[]);for(var a=0;a<e.settings.quick.length;a++)e.settings.quick[a]=o.validateSetting(e.settings.quick[a]),e.settings.quick[a]||e.settings.quick.splice(a,1);"undefined"===i(e.settings.configure)&&(e.settings.configure=[]);for(var s=0;s<e.settings.configure.length;s++)e.settings.configure[s]=o.validateSetting(e.settings.configure[s]),e.settings.configure[s]||e.settings.configure.splice(s,1);"undefined"===i(e.settings.advanced)&&(e.settings.advanced=[]);for(var p=0;p<e.settings.advanced.length;p++)e.settings.advanced[p]=o.validateSetting(e.settings.advanced[p]),e.settings.advanced[p]||e.settings.advanced.splice(p,1);e.settings.advanced.push({attribute:"class",title:"Classes",description:"CSS classes applied manually to the element",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"style",title:"Styles",description:"Custom CSS styles as applied to the element",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"prefix",title:"Schema: prefix",description:"Schema prefixes",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"typeof",title:"Schema: TypeOf",description:"typeof definition for Schema usage",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"property",title:"Schema: Property",description:"typeof definition for Schema usage",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"resource",title:"Schema: Resource ID",description:"Schema resource identifier",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"id",title:"ID",description:"element ID, only set this if you know why",inputMethod:"textfield"}),e.settings.advanced.push({attribute:"slot",title:"slot",description:"DOM slot area",inputMethod:"textfield"})}if("undefined"===i(e.saveOptions)&&(e.saveOptions={wipeSlot:!1}),n)if(""!=t&&"undefined"===i(window.HaxStore)){var d=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:e,polymer:!1}});r.dispatchEvent(d)}else if(""!=t){var u=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:t.toLowerCase(),properties:e}});r.dispatchEvent(u)}else if("undefined"!==i(o.tagName)){var l=new CustomEvent("hax-register-properties",{bubbles:!0,composed:!0,cancelable:!0,detail:{tag:o.tagName.toLowerCase(),properties:e}});r.dispatchEvent(l)}else console.warn("".concat(t," missed our checks and has an issue in implementation with HAX"));""===t&&("function"==typeof o._setHaxProperties?o._setHaxProperties(e):o.haxProperties=e)}else console.warn("This is't a valid usage of hax API. See hax-body-behaviors/lib/HAXWiring.js for more details on how to implement the API. Most likely your hax item just was placed in an iframe as a fallback as opposed to a custom element.")},this.validateSetting=function(e){return("undefined"!==i(e.property)||"undefined"!==i(e.slot)||"undefined"!==i(e.attribute))&&("undefined"===i(e.title)&&("undefined"===i(e.attribute)?e.title=e.property:e.title=e.attribute),"undefined"===i(e.description)&&(e.description=""),"undefined"===i(e.inputMethod)&&(e.inputMethod="textfield"),"undefined"===i(e.type)&&(e.type="settings"),"undefined"===i(e.icon)&&(e.icon="android"),"undefined"===i(e.options)&&(e.options={}),"undefined"===i(e.required)&&(e.required=!1),"undefined"===i(e.validation)&&(e.validation=".*"),"undefined"===i(e.validationType)&&(e.validationType=""),"undefined"!==i(e.slot)&&("undefined"===i(e.slotWrapper)&&(e.slotWrapper="span"),"undefined"===i(e.slotAttributes)&&(e.slotAttributes={})),e)},this.getHaxProperties=function(){return o.haxProperties},this.getHaxJSONSchema=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;"undefined"===i(e)&&(e="configure"),"undefined"===i(t)&&(t=r.haxProperties);var n=t.settings[e],a={$schema:"http://json-schema.org/schema#",title:"HAX "+e+" form schema",type:"object",properties:{}};return a.properties=r._getHaxJSONSchemaProperty(n,r),a=r.postProcessgetHaxJSONSchema(a)},this.postProcessgetHaxJSONSchema=function(e){return e},this._getHaxJSONSchemaProperty=function(e,r){var o={};for(var n in e)if(e.hasOwnProperty(n))if("undefined"!==i(e[n].property))switch(o[e[n].property]={title:e[n].title,type:r.getHaxJSONSchemaType(e[n].inputMethod)},"undefined"!==i(r[e[n].property])&&(o[e[n].property].value=r[e[n].property]),"url"==e[n].validationType&&(o[e[n].property].format="uri"),"datepicker"==e[n].inputMethod&&(o[e[n].property].format="date-time"),".*"!=e[n].validation&&(o[e[n].property].pattern=e[n].validation),e[n].inputMethod){case"number":o[e[n].property].component={name:"paper-input",valueProperty:"value",properties:{required:e[n].required},attributes:{type:"number"}};break;case"select":var a=[];for(var s in e[n].options){var p=[{alt:e[n].options[s],value:s}];a.push(p)}o[e[n].property].component={name:"simple-picker",valueProperty:"value",properties:{required:e[n].required,options:a}};break;case"textarea":o[e[n].property].component={name:"paper-textarea",valueProperty:"value",properties:{required:e[n].required},attributes:{"auto-validate":"auto-validate","char-counter":"char-counter"}};break;case"code-editor":o[e[n].property].component={name:"code-editor",valueProperty:"value",properties:{title:e[n].title,theme:"hc-black",mode:"html",className:"hax-code-editor"}};break;case"array":o[e[n].property].items={type:"object",properties:r._getHaxJSONSchemaProperty(e[n].properties,r)};break;case"textfield":o[e[n].property].component={name:"paper-input",valueProperty:"value",properties:{required:e[n].required},attributes:{"auto-validate":"auto-validate"}};break;case"alt":o[e[n].property].component={name:"paper-input-flagged",valueProperty:"value",properties:{required:e[n].required},attributes:{"auto-validate":"auto-validate"}};break;case"colorpicker":o[e[n].property].component={name:"simple-colors-picker",valueProperty:"value",properties:{required:e[n].required,label:e[n].title}};break;case"iconpicker":o[e[n].property].component={name:"simple-icon-picker",valueProperty:"value",properties:{required:e[n].required,hideOptionLabels:!0,label:e[n].title}};var d=void 0!==e[n].options&&null!==e[n].options?e[n].options:[];o[e[n].property].component.properties.icons=d;break;case"datepicker":o[e[n].property].component={name:"app-datepicker",valueProperty:"date",properties:{required:e[n].required,autoUpdateDate:!0}};break;case"haxupload":o[e[n].property].component={name:"hax-upload-field",valueProperty:"value",properties:{formDataName:"file-upload"}}}else if("undefined"!==i(e[n].attribute))switch(o[e[n].attribute]={title:e[n].title,type:r.getHaxJSONSchemaType(e[n].inputMethod)},"class"===e[n].attribute?o[e[n].attribute].value=r.className:"style"===e[n].attribute?o[e[n].attribute].value=r.style.cssText:"undefined"!==i(r.attributes[e[n].attribute])&&(o[e[n].attribute].value=r.getAttribute(e[n].attribute)),"href"!=n&&"src"!=n||(o[e[n].attribute].format="uri"),"url"==e[n].validationType&&(o[e[n].attribute].format="uri"),"datepicker"==e[n].inputMethod&&(o[e[n].attribute].format="date-time"),".*"!=e[n].validation&&(o[e[n].attribute].pattern=e[n].validation),e[n].inputMethod){case"number":o[e[n].attribute].component={name:"paper-input",valueProperty:"value",properties:{required:e[n].required},attributes:{type:"number"}};break;case"select":var u=[];for(var s in e[n].options){var l=[{alt:e[n].options[s],value:s}];u.push(l)}o[e[n].attribute].component={name:"simple-picker",valueProperty:"value",properties:{required:e[n].required,options:u}};break;case"textarea":o[e[n].attribute].component={name:"paper-textarea",valueProperty:"value",properties:{required:e[n].required},attributes:{"auto-validate":"auto-validate","char-counter":"char-counter"}};break;case"code-editor":o[e[n].attribute].component={name:"code-editor",valueProperty:"value",properties:{title:e[n].title,readOnly:!1,theme:"hc-black",mode:"html",className:"hax-code-editor"}};break;case"textfield":o[e[n].attribute].component={name:"paper-input",valueProperty:"value",properties:{required:e[n].required},attributes:{"auto-validate":"auto-validate"}};break;case"alt":o[e[n].attribute].component={name:"paper-input-flagged",valueProperty:"value",properties:{required:e[n].required},attributes:{"auto-validate":"auto-validate"}};break;case"colorpicker":o[e[n].attribute].component={name:"simple-colors-picker",valueProperty:"value",properties:{required:e[n].required}};break;case"haxupload":o[e[n].attribute].component={name:"hax-upload-field",valueProperty:"value",properties:{formDataName:"file-upload"}}}else{o[e[n].slot]={title:e[n].title,type:r.getHaxJSONSchemaType(e[n].inputMethod),value:"",component:{name:"code-editor",valueProperty:"value",properties:{title:e[n].title,theme:"hc-black",mode:"html",className:"hax-code-editor"}}};var c="";for(var h in t.dom(r).childNodes)"undefined"!==i(t.dom(r).childNodes[h])&&(1===t.dom(r).childNodes[h].nodeType?e[n].slot===t.dom(r).childNodes[h].slot&&(c+=t.dom(r).childNodes[h].innerHTML):1!==t.dom(r).childNodes[h].nodeType&&"undefined"!==i(t.dom(r).childNodes[h].textContent)&&""!==t.dom(r).childNodes[h].textContent&&(c+=t.dom(r).childNodes[h].textContent));o[e[n].slot].component.slot="<template>"+c.trim()+"</template>"}return o},this.getHaxJSONSchemaType=function(e){if(o.validHAXPropertyInputMethod().includes(e))switch(e){case"flipboolean":case"boolean":return"boolean";case"number":return"number";case"select":case"textarea":case"colorpicker":case"iconpicker":case"datepicker":case"haxupload":case"textfield":case"alt":return"string";case"array":return"array";default:return"string"}},this.validHAXPropertyInputMethod=function(){return["flipboolean","boolean","select","textfield","textarea","datepicker","haxupload","colorpicker","iconpicker","alt","number","code-editor","array"]},this.prototypeHaxProperties=function(){return{api:"1",canScale:!0,canPosition:!0,canEditSource:!1,gizmo:{title:"Tag name",description:"A description",icon:"av:play-circle-filled",color:"blue",groups:["Content"],handles:[{type:"data",url:"src"}],meta:{author:""}},settings:{quick:[{property:"title",title:"Title",inputMethod:"textfield",icon:"android"},{property:"primaryColor",title:"Primary color",inputMethod:"colorpicker",icon:"color"}],configure:[{slot:"",title:"Inner content",description:"The slotted content that lives inside the tag",inputMethod:"textfield",icon:"android",required:!0,validationType:"text"},{slot:"button",title:"Button content",description:"The content that can override the button",inputMethod:"textfield",icon:"android",required:!0,validationType:"text"},{property:"title",title:"Title",description:"",inputMethod:"textfield",icon:"android",required:!0,validationType:"text"},{property:"primaryColor",title:"Title",description:"",inputMethod:"textfield",icon:"android",required:!1,validation:".*",validationType:"text"}],advanced:[{property:"secondaryColor",title:"Secondary color",description:"An optional secondary color used in certain edge cases.",inputMethod:"colorpicker",icon:"color"},{property:"endPoint",title:"API endpoint",description:"An optional endpoint to hit and load in more data dymaically.",inputMethod:"textfield",icon:"android",validation:"[a-z0-9]",validationType:"url"}]},saveOptions:{wipeSlot:!1,unsetAttributes:["end-point","secondary-color"]}}}};window.HAXWiring=new d,window.HAXBehaviors=window.HAXBehaviors||{},window.HAXBehaviors.PropertiesBehaviors={properties:{haxProperties:window.HAXWiring.haxProperties},setHaxProperties:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;return""==t&&"undefined"!==i(this.tagName)&&(t=this.tagName.toLowerCase()),window.addEventListener("hax-store-ready",this._haxStoreReady.bind(this)),"undefined"!==i(window.HaxStore)&&null!=window.HaxStore.instance&&window.HaxStore.ready?window.HAXWiring.setHaxProperties(e,t,r,!0):window.HAXWiring.setHaxProperties(e,t,r,!1)},_haxStoreReady:function(e){return window.HAXWiring._haxStoreReady(e)},validateSetting:function(e){return window.HAXWiring.validateSetting(e)},getHaxProperties:function(){return this.haxProperties},getHaxJSONSchema:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;return window.HAXWiring.getHaxJSONSchema(e,t,i)},postProcessgetHaxJSONSchema:function(e){return window.HAXWiring.postProcessgetHaxJSONSchema(e)},_getHaxJSONSchemaProperty:function(e,t){return window.HAXWiring._getHaxJSONSchemaProperty(e,t)},getHaxJSONSchemaType:function(e){return window.HAXWiring.getHaxJSONSchemaType(e)},validHAXPropertyInputMethod:function(){return window.HAXWiring.validHAXPropertyInputMethod()},prototypeHaxProperties:function(){return window.HAXWiring.prototypeHaxProperties()}},e.HAXWiring=d,e.HAXElement=function(e){return function(t){function u(){var e;return r(this,u),(e=s(this,n(u).call(this))).HAXWiring=new d,e}var l,c,h;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(u,e),l=u,h=[{key:"properties",get:function(){var e={haxProperties:window.HAXWiring.haxProperties};return p(n(u),"properties",this)&&(e=Object.assign(e,p(n(u),"properties",this))),e}}],(c=[{key:"setHaxProperties",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;return""==t&&"undefined"!==i(this.tagName)&&(t=this.tagName.toLowerCase()),window.addEventListener("hax-store-ready",this._haxStoreReady.bind(this)),"undefined"!==i(window.HaxStore)&&null!=window.HaxStore.instance&&window.HaxStore.ready?this.HAXWiring.setHaxProperties(e,t,r,!0):this.HAXWiring.setHaxProperties(e,t,r,!1)}},{key:"setup",value:function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2],this.HAXWiring.setup(e,"",this)}},{key:"_haxStoreReady",value:function(e){return this.HAXWiring._haxStoreReady(e)}},{key:"validateSetting",value:function(e){return this.HAXWiring.validateSetting(e)}},{key:"getHaxProperties",value:function(){return this.haxProperties}},{key:"getHaxJSONSchema",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;return this.HAXWiring.getHaxJSONSchema(e,t,i)}},{key:"postProcessgetHaxJSONSchema",value:function(e){return this.HAXWiring.postProcessgetHaxJSONSchema(e)}},{key:"_getHaxJSONSchemaProperty",value:function(e,t){return this.HAXWiring._getHaxJSONSchemaProperty(e,t)}},{key:"getHaxJSONSchemaType",value:function(e){return this.HAXWiring.getHaxJSONSchemaType(e)}},{key:"validHAXPropertyInputMethod",value:function(){return this.HAXWiring.validHAXPropertyInputMethod()}},{key:"prototypeHaxProperties",value:function(){return this.HAXWiring.prototypeHaxProperties()}}])&&o(l.prototype,c),h&&o(l,h),u}()},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=hax-body-behaviors.umd.js.map |
@@ -134,5 +134,10 @@ /** | ||
* | ||
* `preProcessHaxInsertContent` - If an element needs to ensure it cleans up data | ||
* during the conversion from preview to being inserted. This function passes in | ||
* the details object for creating an element from HAX schema. Examples could be | ||
* objects that contain focus which may cause issues when doing a pure clone as the | ||
* reference is being garbage collected on save (see grid-plate). | ||
*/ | ||
/** | ||
* Object to validate HAX | ||
* Object to validate HAX schema. Can be used in and out of element contexts | ||
*/ | ||
@@ -354,4 +359,6 @@ export class HAXWiring { | ||
}); | ||
// we need to support slot in the UI but actually shift it around under the hood | ||
// this is so that shadow roots don't get mad when previewing | ||
props.settings.advanced.push({ | ||
attribute: "slot", | ||
attribute: "data-hax-slot", | ||
title: "slot", | ||
@@ -476,2 +483,6 @@ description: "DOM slot area", | ||
} | ||
// ensure there's required set | ||
if (typeof setting.disabled === typeof undefined) { | ||
setting.disabled = false; | ||
} | ||
// ensure there's validation or make it anything if none set | ||
@@ -566,3 +577,4 @@ if (typeof setting.validation === typeof undefined) { | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -590,3 +602,4 @@ attributes: { | ||
required: settings[value].required, | ||
options: options | ||
options: options, | ||
disabled: settings[value].disabled | ||
} | ||
@@ -600,3 +613,4 @@ }; | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -614,3 +628,3 @@ attributes: { | ||
properties: { | ||
//editorValue: settings[value].value, | ||
editorValue: settings[value].value, | ||
title: settings[value].title, | ||
@@ -637,3 +651,4 @@ theme: "hc-black", | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -650,3 +665,4 @@ attributes: { | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -664,3 +680,4 @@ attributes: { | ||
required: settings[value].required, | ||
label: settings[value].title | ||
label: settings[value].title, | ||
disabled: settings[value].disabled | ||
} | ||
@@ -676,3 +693,4 @@ }; | ||
hideOptionLabels: true, | ||
label: settings[value].title | ||
label: settings[value].title, | ||
disabled: settings[value].disabled | ||
} | ||
@@ -696,3 +714,4 @@ }; | ||
required: settings[value].required, | ||
autoUpdateDate: true | ||
autoUpdateDate: true, | ||
disabled: settings[value].disabled | ||
} | ||
@@ -706,3 +725,5 @@ }; | ||
properties: { | ||
formDataName: "file-upload" | ||
formDataName: "file-upload", | ||
disabled: settings[value].disabled, | ||
required: settings[value].required | ||
} | ||
@@ -750,3 +771,4 @@ }; | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -774,2 +796,3 @@ attributes: { | ||
required: settings[value].required, | ||
disabled: settings[value].disabled, | ||
options: options | ||
@@ -784,3 +807,4 @@ } | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -798,3 +822,3 @@ attributes: { | ||
properties: { | ||
//editorValue: props[settings[value].attribute].value, | ||
editorValue: props[settings[value].attribute].value, | ||
title: settings[value].title, | ||
@@ -813,3 +837,4 @@ readOnly: false, | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -826,3 +851,4 @@ attributes: { | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
}, | ||
@@ -839,3 +865,4 @@ attributes: { | ||
properties: { | ||
required: settings[value].required | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
} | ||
@@ -849,3 +876,5 @@ }; | ||
properties: { | ||
formDataName: "file-upload" | ||
formDataName: "file-upload", | ||
required: settings[value].required, | ||
disabled: settings[value].disabled | ||
} | ||
@@ -865,3 +894,3 @@ }; | ||
properties: { | ||
//editorValue: settings[value].value, | ||
editorValue: settings[value].value, | ||
title: settings[value].title, | ||
@@ -894,4 +923,6 @@ theme: "hc-black", | ||
} | ||
props[settings[value].slot].component.slot = | ||
"<template>" + slot.trim() + "</template>"; | ||
// @todo verify this stuff actually works | ||
props[ | ||
settings[value].slot | ||
].component.properties.editorValue = slot.trim(); | ||
} | ||
@@ -1066,2 +1097,117 @@ } | ||
} | ||
/** | ||
* Super class element partial. This mixes the HAXWiring capabilities into the element itself. | ||
* Use this in instances where you want direct access to all the functions in the element itself | ||
*/ | ||
export const HAXElement = function(SuperClass) { | ||
return class extends SuperClass { | ||
constructor() { | ||
super(); | ||
this.HAXWiring = new HAXWiring(); | ||
} | ||
static get properties() { | ||
let props = { | ||
/** | ||
* haxProperties | ||
*/ | ||
haxProperties: window.HAXWiring.haxProperties | ||
}; | ||
if (super.properties) { | ||
props = Object.assign(props, super.properties); | ||
} | ||
return props; | ||
} | ||
/** | ||
* Setter to bridge private haxProperties setter. | ||
* This is to then be implemented by the ready state of whatever is supplying the | ||
* properties in order to be able to bubble up the properties for a tag. | ||
*/ | ||
setHaxProperties(props, tag = "", context = this) { | ||
if (tag == "" && typeof this.tagName !== typeof undefined) { | ||
tag = this.tagName.toLowerCase(); | ||
} | ||
window.addEventListener( | ||
"hax-store-ready", | ||
this._haxStoreReady.bind(this) | ||
); | ||
if ( | ||
typeof window.HaxStore !== typeof undefined && | ||
window.HaxStore.instance != null && | ||
window.HaxStore.ready | ||
) { | ||
return this.HAXWiring.setHaxProperties(props, tag, context, true); | ||
} else { | ||
return this.HAXWiring.setHaxProperties(props, tag, context, false); | ||
} | ||
} | ||
/** | ||
* Setter to bridge private haxProperties setter. | ||
* This is to then be implemented by the ready state of whatever is supplying the | ||
* properties in order to be able to bubble up the properties for a tag. | ||
*/ | ||
setup(props, tag = "", context = this) { | ||
return this.HAXWiring.setup(props, (tag = ""), (context = this)); | ||
} | ||
/** | ||
* Private function to fire off props when ready | ||
*/ | ||
_haxStoreReady(e) { | ||
return this.HAXWiring._haxStoreReady(e); | ||
} | ||
/** | ||
* Validate settings object. | ||
*/ | ||
validateSetting(setting) { | ||
return this.HAXWiring.validateSetting(setting); | ||
} | ||
/** | ||
* Match convention for set. | ||
*/ | ||
getHaxProperties() { | ||
return this.haxProperties; | ||
} | ||
/** | ||
* Convert haxProperties structure to a simple json-schema. | ||
* This allows for complex form building systems based on this data. | ||
* type is configure or advanced | ||
*/ | ||
getHaxJSONSchema(type, haxProperties, target = this) { | ||
return this.HAXWiring.getHaxJSONSchema(type, haxProperties, target); | ||
} | ||
/** | ||
* Default postProcessgetHaxJSONSchema to be overridden. | ||
*/ | ||
postProcessgetHaxJSONSchema(schema) { | ||
return this.HAXWiring.postProcessgetHaxJSONSchema(schema); | ||
} | ||
/** | ||
* Internal helper for getHaxJSONSchema to buiild the properties object | ||
* correctly with support for recursive nesting thx to objects / arrays. | ||
*/ | ||
_getHaxJSONSchemaProperty(settings, target) { | ||
return this.HAXWiring._getHaxJSONSchemaProperty(settings, target); | ||
} | ||
/** | ||
* Convert input method to schedma type | ||
*/ | ||
getHaxJSONSchemaType(inputMethod) { | ||
return this.HAXWiring.getHaxJSONSchemaType(inputMethod); | ||
} | ||
/** | ||
* List valid input methods. | ||
*/ | ||
validHAXPropertyInputMethod() { | ||
return this.HAXWiring.validHAXPropertyInputMethod(); | ||
} | ||
/** | ||
* Return a haxProperties prototype / example structure | ||
*/ | ||
prototypeHaxProperties() { | ||
return this.HAXWiring.prototypeHaxProperties(); | ||
} | ||
}; | ||
}; | ||
// LEGACY. This is a Polymer 1.x syntax element "behavior" | ||
// This has been replaced with HAXElement, a super class which can be used to wrap classes | ||
// invoke an instance so we can support behaviors as well | ||
@@ -1068,0 +1214,0 @@ window.HAXWiring = new HAXWiring(); |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "2.0.10", | ||
"version": "2.1.0", | ||
"description": "Wire any element up to HAX", | ||
@@ -43,6 +43,6 @@ "repository": { | ||
"@lrnwebcomponents/deduping-fix": "^2.0.9", | ||
"@lrnwebcomponents/storybook-utilities": "^2.0.10", | ||
"@lrnwebcomponents/storybook-utilities": "^2.1.0", | ||
"@polymer/iron-component-page": "github:PolymerElements/iron-component-page", | ||
"@polymer/iron-demo-helpers": "^3.1.0", | ||
"@webcomponents/webcomponentsjs": "^2.2.9", | ||
"@webcomponents/webcomponentsjs": "2.2.10", | ||
"concurrently": "4.1.0", | ||
@@ -52,3 +52,3 @@ "gulp-babel": "8.0.0", | ||
"lodash": "4.17.11", | ||
"polymer-cli": "1.9.8", | ||
"polymer-cli": "1.9.9", | ||
"wct-browser-legacy": "1.0.2" | ||
@@ -60,3 +60,3 @@ }, | ||
}, | ||
"gitHead": "8571f08ce381877be732c2b5407233bcc3c58d99" | ||
"gitHead": "38a0c3ad00e8447837037bde2dc1172273a3a311" | ||
} |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
import { HAXWiring } from "./lib/HAXWiring.js"; | ||
export { HAXWiring }; | ||
import { HAXWiring, HAXElement } from "./lib/HAXWiring.js"; | ||
export { HAXWiring, HAXElement }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192691
1907