forked from json-schema-form/angular-schema-form-material
-
Notifications
You must be signed in to change notification settings - Fork 0
/
material-decorator.min.js
1 lines (1 loc) · 18.6 KB
/
material-decorator.min.js
1
angular.module("schemaForm").run(["$templateCache",function(e){e.put("decorators/material/actions-trcl.html",'<div class="btn-group schema-form-actions {{form.htmlClass}}" ng-transclude=""></div>'),e.put("decorators/material/actions.html",'<section layout="row" class="btn-group schema-form-actions {{form.htmlClass}}"></section>'),e.put("decorators/material/array.html",'<div class="schema-form-array {{form.htmlClass}}" sf-field-model="sf-new-array" sf-new-array=""><label class="control-label" ng-show="showTitle()">{{ form.title }}</label><md-list class="list-group" sf-field-model="" ui-sortable="form.sortOptions"><md-list-item layout="row" class="list-group-item" sf-field-model="ng-repeat" ng-repeat="item in modelArray track by $index" schema-form-array-items=""><md-button flex="none" flex-order="2" type="button" ng-hide="form.readonly || form.remove === null" ng-click="deleteFromArray($index)" ng-disabled="form.schema.minItems >= modelArray.length" class="md-icon-button" aria-label="More" style="position: relative; z-index: 20;"><md-icon>close</md-icon></md-button></md-list-item></md-list><div class="clearfix" style="padding: 15px;" ng-model="modelArray" schema-validate="form"><div class="help-block" ng-show="(hasError() && errorMessage(schemaError())) || form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div><md-button ng-hide="form.readonly || form.add === null" ng-click="appendToArray()" ng-disabled="form.schema.maxItems <= modelArray.length" type="button" class="btn md-raised md-primary {{ form.style.add || \'btn-default\' }} pull-right"><i class="glyphicon glyphicon-plus"></i> {{ form.add || \'Add\'}}</md-button></div></div>'),e.put("decorators/material/autocomplete.html",'<div class="form-group {{form.htmlClass}} schema-form-select" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}" sf-messages="" sf-layout=""><md-autocomplete flex="" ng-disabled="form.readonly" ng-model="$$value$$" sf-autocomplete="" sf-field-model="replaceAll" schema-validate="form" md-selected-item="$$value$$" md-search-text="searchText" md-selected-item-change="\'todo\';" md-items="item in evalExpr(\'this[\\\'\'+form.optionFilter+\'\\\'](\\\'\'+searchText+\'\\\')\')" md-item-text="item.name" md-floating-label="{{::form.title}}" md-menu-class="autocomplete-custom-template"><md-item-template><span md-highlight-text="searchText">{{item.name}}</span></md-item-template><md-not-found>No matches found</md-not-found></md-autocomplete></div>'),e.put("decorators/material/card-content.html",'<md-card-content class="schema-form-card-content {{form.htmlClass}}"></md-card-content>'),e.put("decorators/material/card.html",'<md-card class="schema-form-card {{form.htmlClass}}"></md-card>'),e.put("decorators/material/checkbox.html",'<div class="checkbox schema-form-checkbox {{::form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}" sf-messages=""><md-checkbox sf-field-model="" sf-changed="form" ng-disabled="form.readonly" schema-validate="form" class="{{::form.fieldHtmlClass}}" name="{{::form.key|sfCamelKey}}" aria-label="{{::form.title}}"><span>{{::form.title}}</span></md-checkbox></div>'),e.put("decorators/material/checkboxes.html",'<div sf-array="form" sf-field-model="" class="form-group schema-form-checkboxes {{::form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}" sf-messages=""><label class="control-label" ng-show="showTitle()">{{::form.title}}</label><div class="checkbox" ng-repeat="val in titleMapValues track by $index"><md-checkbox ng-model="titleMapValues[$index]" sf-changed="form" ng-disabled="::form.readonly" name="{{::form.key|sfCamelKey}}" ng-true-value="true" ng-false-value="false" aria-label="{{::form.title}}">{{::form.titleMap[$index].name}}</md-checkbox></div></div>'),e.put("decorators/material/chips.html",'<div class="form-group schema-form-chips {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}"><md-chips sf-field-model="" readonly="form.readonly" flex="" placeholder="{{::form.title}}"><md-chip-template><strong ng-if="!form.template">{{$chip}}</strong></md-chip-template></md-chips><div ng-messages="ngModel.$error"><div sf-message="" ng-message=""></div></div></div>'),e.put("decorators/material/date.html",'<div class="schema-form-date {{::form.htmlClass}}"><label ng-show="showTitle()" for="{{::form.key|sfCamelKey}}">{{::form.title}}</label><md-datepicker sf-field-model="" sf-changed="form" schema-validate="form" sf-type-parser="form.schema" id="{{::form.key|sfCamelKey}}" ng-show="::form.key" ng-class="::form.fieldHtmlClass" ng-disabled="::form.readonly" md-placeholder="Enter date" sf-messages=""></md-datepicker></div>'),e.put("decorators/material/default.html",'<md-input-container class="schema-form-{{::form.type}} {{::form.htmlClass}}" ng-class="{\'md-input-has-value\': model[\'{{form.key.join(\'\\\'][\\\'\')}}\'], \'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}" sf-messages="" sf-layout=""><label ng-show="showTitle()" for="{{::form.key|sfCamelKey}}">{{::form.title}}</label> <input sf-field-model="" ng-show="::form.key" type="{{::form.type}}" step="any" sf-changed="form" placeholder="{{form.placeholder}}" id="{{::form.key|sfCamelKey}}" ng-class="::form.fieldHtmlClass" sf-type-parser="form.schema" ng-disabled="::form.readonly" schema-validate="form" name="{{::form.key|sfCamelKey}}" aria-describedby="{{::form.key|sfCamelKey}}Status"></md-input-container>'),e.put("decorators/material/fieldset-trcl.html",'<fieldset ng-disabled="form.readonly" class="standard {{form.htmlClass}}" flex=""><legend ng-show="form.title">{{ form.title }}</legend><div ng-transclude=""></div></fieldset>'),e.put("decorators/material/fieldset.html",'<fieldset ng-disabled="form.readonly" class="standard {{form.htmlClass}}" flex=""><legend ng-show="form.title">{{ form.title }}</legend></fieldset>'),e.put("decorators/material/help.html",'<div class="helpvalue schema-form-helpvalue {{form.htmlClass}}" ng-bind-html="form.helpvalue"></div>'),e.put("decorators/material/radio-buttons.html",'<div class="form-group schema-form-radiobuttons {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}" sf-layout="" sf-messages=""><div><label class="control-label" ng-show="showTitle()">{{form.title}}</label></div><section layout="row" layout-sm="column" layout-align="center center"><md-input-container ng-repeat="item in form.titleMap"><md-button type="button" class="group md-raised" sf-field-model="replaceAll" ng-model="$$value$$" sf-changed="form" ng-class="{\'md-primary\': ($$value$$ == item.value)}" ng-disabled="form.readonly" ng-model-options="form.ngModelOptions" schema-validate="form" ng-value="item.value" ng-click="$$value$$ = item.value" name="{{form.key.join(\'.\')}}"><span ng-bind-html="item.name"></span></md-button></md-input-container></section></div>'),e.put("decorators/material/radios-inline.html",'<div class="form-group schema-form-radios-inline {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}" sf-layout="" sf-messages=""><label class="control-label" ng-show="showTitle()">{{form.title}}</label><md-radio-group layout="row" sf-field-model="replaceAll" ng-model="$$value$$" class="{{form.fieldHtmlClass}}" ng-class="{ active: item.value === $$value$$ }" sf-changed="form" schema-validate="form" ng-disabled="form.readonly" name="{{form.key.join(\'.\')}}"><md-radio-button ng-repeat="item in form.titleMap" ng-value="item.value"><span ng-bind-html="item.name"></span></md-radio-button></md-radio-group></div>'),e.put("decorators/material/radios.html",'<div class="form-group schema-form-radios {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}"><label class="control-label" ng-show="showTitle()" aria-label="{{form.title}}" layout="row">{{form.title}} {{form.titleMap | json}}</label><div><md-radio-group sf-field-model="" sf-changed="form" ng-disabled="form.readonly" name="{{form.key.join(\'.\')}}" sf-layout="" sf-messages=""><md-radio-button ng-repeat="item in form.titleMap" ng-value="item.value" class="{{form.fieldHtmlClass}}" sf-field-model="ng-class" ng-class="{ active: item.value === $$value$$ }"><span ng-bind-html="item.name"></span></md-radio-button></md-radio-group></div></div>'),e.put("decorators/material/section.html",'<md-content class="schema-form-section {{::form.htmlClass}}" sf-layout=""></md-content>'),e.put("decorators/material/select.html",'<md-input-container class="form-group {{::form.htmlClass}} schema-form-select" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}" sf-messages="" sf-layout=""><label ng-show="::showTitle()">{{::form.title}}</label><md-select sf-field-model="" schema-validate="form"><md-optgroup ng-repeat-start="(key, opt) in form.getOptions(form, evalExpr) | orderBy:\'group\' as optGroups" ng-if="opt.group && opt.group != optGroups[key-1].group" label="{{::opt.group}}" aria-label="{{::opt.group}}"><md-option ng-repeat="(key, filtered) in form.getOptions(form, evalExpr) | filter: {group: opt.group} | orderBy:\'name\' as opts" ng-value="::filtered.value" aria-label="{{::filtered.name}}">{{::filtered.name}}</md-option></md-optgroup><md-option ng-if="!opt.group" ng-value="::opt.value" ng-repeat-end="">{{::opt.name}}</md-option></md-select></md-input-container>'),e.put("decorators/material/slider.html",'<md-input-container class="schema-form-slider {{form.htmlClass}}"><label ng-show="showTitle()" for="{{::form.key|sfCamelKey}}">{{::form.title}}</label><md-slider sf-field-model="" flex="" id="{{::form.key|sfCamelKey}}" min="0" max="255" aria-label="blue"></md-slider></md-input-container>'),e.put("decorators/material/submit.html",'<section class="schema-form-submit {{form.htmlClass}}" sf-messages=""><md-button class="md-raised {{ form.style || \'md-primary\' }} {{form.fieldHtmlClass}}" type="{{::form.type}}" ng-disabled="form.readonly" aria-label="{{::form.title}}"><md-tooltip ng-if="::form.tip">{{::form.tip}}</md-tooltip>{{::form.title}}</md-button></section>'),e.put("decorators/material/switch.html",'<md-input-container class="schema-form-switch {{::form.htmlClass}}"><md-switch sf-field-model="" sf-changed="form" sf-type-parser="form.schema" sf-messages="" schema-validate="form" id="{{::form.key|sfCamelKey}}" aria-label="{{form.title}}" ng-show="::form.key" ng-class="form.fieldHtmlClass" ng-disabled="::form.readonly"><span ng-show="showTitle()" for="{{::form.key|sfCamelKey}}">{{::form.title}}</span></md-switch></md-input-container>'),e.put("decorators/material/tabarray.html",'<div sf-array="form" ng-init="selected = { tab: 0 }" class="clearfix schema-form-tabarray schema-form-tabarray-{{form.tabType || \'left\'}} {{form.htmlClass}}"><div ng-if="!form.tabType || form.tabType !== \'right\'" ng-class="{\'col-xs-3\': !form.tabType || form.tabType === \'left\'}"><ul class="nav nav-tabs" ng-class="{ \'tabs-left\': !form.tabType || form.tabType === \'left\'}"><li ng-repeat="item in modelArray track by $index" ng-click="$event.preventDefault() || (selected.tab = $index)" ng-class="{active: selected.tab === $index}"><a href="#">{{interp(form.title,{\'$index\':$index, value: item}) || $index}}</a></li><li ng-hide="form.readonly" ng-click="$event.preventDefault() || (selected.tab = appendToArray().length - 1)"><a href="#"><i class="glyphicon glyphicon-plus"></i> {{ form.add || \'Add\'}}</a></li></ul></div><div ng-class="{\'col-xs-9\': !form.tabType || form.tabType === \'left\' || form.tabType === \'right\'}"><div class="tab-content {{form.fieldHtmlClass}}"><div class="tab-pane clearfix" ng-repeat="item in modelArray track by $index" ng-show="selected.tab === $index" ng-class="{active: selected.tab === $index}"><sf-decorator ng-init="arrayIndex = $index" form="copyWithIndex($index)"></sf-decorator><button ng-hide="form.readonly" ng-click="selected.tab = deleteFromArray($index).length - 1" type="button" class="btn {{ form.style.remove || \'btn-default\' }} pull-right"><i class="glyphicon glyphicon-trash"></i> {{ form.remove || \'Remove\'}}</button></div></div></div><div ng-if="form.tabType === \'right\'" class="col-xs-3"><ul class="nav nav-tabs tabs-right"><li ng-repeat="item in modelArray track by $index" ng-click="$event.preventDefault() || (selected.tab = $index)" ng-class="{active: selected.tab === $index}"><a href="#">{{interp(form.title,{\'$index\':$index, value: item}) || $index}}</a></li><li ng-hide="form.readonly" ng-click="$event.preventDefault() || appendToArray()"><a href="#"><i class="glyphicon glyphicon-plus"></i> {{ form.add || \'Add\'}}</a></li></ul></div></div>'),e.put("decorators/material/tabs.html",'<div sf-field-model="" class="schema-form-tabs {{::form.htmlClass}}"><md-tabs md-dynamic-height="" md-selected="selected" md-autoselect="" ng-init="selected = 0"></md-tabs></div>'),e.put("decorators/material/textarea.html",'<md-input-container class="{{::form.htmlClass}} schema-form-textarea" sf-messages="" sf-layout=""><label ng-show="showTitle()" for="{{::form.key|sfCamelKey}}">{{::form.title}}</label> <textarea ng-class="::form.fieldHtmlClass" id="{{::form.key|sfCamelKey}}" sf-changed="form" ng-disabled="::form.readonly" sf-field-model="" schema-validate="form" name="{{::form.key|sfCamelKey}}"></textarea></md-input-container>')}]),function(e,t){"use strict";function a(e,t,a,s,o){function m(e){var t=e.fieldFrag.querySelector("[sf-layout]");e.form.grid&&Object.getOwnPropertyNames(e.form.grid).forEach(function(a,r,l){t.setAttribute(a,e.form.grid[a])})}function i(){var e='<div ng-if="ngModel.$invalid" ng-messages="ngModel.$error"><div sf-message ng-message></div></div>',t=document.createElement("div");return t.innerHTML=e,t.firstChild}function n(e){var t=e.fieldFrag.querySelector("[sf-messages]");if(t&&A){var a=A.cloneNode();t.appendChild(a)}}function d(e){var t=e.fieldFrag.querySelector("textarea"),a=e.form.maxlength||!1;t&&a&&t.setAttribute("md-maxlength",a)}function c(e){var t=e.fieldFrag.querySelector("md-autocomplete"),a=e.form.minLength||1,r=e.form.maxLength||!1,l=e.form.title||e.form.placeholder||e.form.key.slice(-1)[0];t&&(e.form.onChange&&(t.setAttribute("md-selected-item-change","args.form.onChange()"),t.setAttribute("md-search-text-change","args.form.onChange(searchText)")),t.setAttribute("md-min-length",a),r&&t.setAttribute("md-max-length",r),l&&t.setAttribute("md-floating-label",l))}function f(e){var t=e.fieldFrag.querySelector("md-switch");e.form.schema.titleMap&&(t.setAttribute("ng-true-value",e.form.schema.titleMap["true"]),t.setAttribute("ng-false-value",e.form.schema.titleMap["false"]))}function h(e){var t,a,a=e.fieldFrag.querySelector("md-select");if(e.form.selectOptions=[],e.form.getOptions=r,e.form.schema.links&&"object"==typeof e.form.schema.links){var s,o=/({)([^}]*)(})/gm;for(t=0;t<e.form.schema.links.length;t++)s=e.form.schema.links[t],"options"===s.rel&&(e.form.optionSource=s.href.replace(o,"$1$1 model.$2 $3$3"));a.setAttribute("sfm-external-options",e.form.optionSource)}else e.form.selectOptions=l(e.form)}function u(e){var t=e.fieldFrag.querySelector("md-datepicker");if(t){e.form.onChange&&t.setAttribute("ng-change","args.form.onChange(searchText)");var a=e.form.minimum||!1,r=e.form.maximum||!1;a&&t.setAttribute("md-max-date",a),r&&t.setAttribute("md-max-date",r)}}function p(e){if(e.form.tabs&&e.form.tabs.length>0){var t=e.fieldFrag.querySelector("md-tabs");e.form.tabs.forEach(function(a,r){var l=document.createElement("md-tab");l.setAttribute("label","{{"+e.path+".tabs["+r+"].title}}");var s=document.createElement("md-tab-body"),o=e.build(a.items,e.path+".tabs["+r+"].items",e.state);s.appendChild(o),l.appendChild(s),t.appendChild(l)})}}function g(t,a,r){if("string"===a.type&&("date"===a.format||"date-time"===a.format)){var l=e.stdFormObj(t,a,r);return l.key=r.path,l.type="date",r.lookup[s.stringify(r.path)]=l,l}}var b="decorators/material/",y=a.builders.simpleTransclusion,v=a.builders.ngModelOptions,x=a.builders.ngModel,$=a.builders.sfField,k=a.builders.condition,C=a.builders.array,w=a.builders.numeric,m=m,A=i(),T=n,E=h,M=c,S=f,F=u,O=p,j=d,K=[$,x,v,k,m],q=K.concat(T),H=K.concat(C);e.defaults.string.unshift(g),t.defineDecorator("materialDecorator",{actions:{template:b+"actions.html",builder:[$,y,k]},array:{template:b+"array.html",builder:H},autocomplete:{template:b+"autocomplete.html",builder:q.concat(M)},"boolean":{template:b+"checkbox.html",builder:q},button:{template:b+"submit.html",builder:q},checkbox:{template:b+"checkbox.html",builder:q},checkboxes:{template:b+"checkboxes.html",builder:H},date:{template:b+"date.html",builder:q.concat(F)},"default":{template:b+"default.html",builder:q},fieldset:{template:b+"fieldset.html",builder:[$,y,k]},help:{template:b+"help.html",builder:q},number:{template:b+"default.html",builder:q.concat(w)},password:{template:b+"default.html",builder:q},radios:{template:b+"radios.html",builder:q},"radios-inline":{template:b+"radios-inline.html",builder:q},radiobuttons:{template:b+"radio-buttons.html",builder:q},section:{template:b+"section.html",builder:[$,y,k,m]},select:{template:b+"select.html",builder:q.concat(E)},submit:{template:b+"submit.html",builder:q},tabs:{template:b+"tabs.html",builder:[$,O,k]},tabarray:{template:b+"tabarray.html",builder:H},textarea:{template:b+"textarea.html",builder:q.concat(j)},"switch":{template:b+"switch.html",builder:q.concat(S)}})}function r(e,t){return e.optionData?t(e.optionData):e.selectOptions?e.selectOptions:[]}function l(e){var t=[];if(e.titleMap)return e.titleMap;if(e["enum"]&&e["enum"].length)for(i=0;i<e["enum"].length;i++)e["enum"][i]&&e["enum"][i].length&&t.push({name:e["enum"][i],value:e["enum"][i]});return t}function s(e){function t(t,a,r){r.$observe("sfmExternalOptions",function(a){e.get(a).then(function(e){t.form.selectOptions=l(e.data)})})}var a={link:t,restrict:"A"};return a}function o(){return function(e){if(!e)return"";var t,a,r;for(r=e.slice(),a=0;a<r.length;a++)t=r[a].toLowerCase().split(""),a&&t.length&&(t[0]=t[0].toUpperCase()),r[a]=t.join("");return r.join("")}}e.module("schemaForm").config(a).directive("sfmExternalOptions",s).filter("sfCamelKey",o),a.$inject=["schemaFormProvider","schemaFormDecoratorsProvider","sfBuilderProvider","sfPathProvider","$injector"],s.$inject=["$http"]}(angular,void 0),require("../material-decorator-templates.js"),require("./type-parser.js"),require("./material-decorator.js"),angular.module("schemaForm").directive("sfTypeParser",function(){return{restrict:"A",scope:!1,require:"ngModel",link:function(e,t,a,r){var l=e.$watch(a.sfTypeParser,function(e){if(e){var t=-1!==e.type.indexOf("number"),a=-1!==e.type.indexOf("integer"),s=/^[0-9]*$/;(t||a)&&r.$parsers.push(function(e){var a;return t?a=parseFloat(e):s.test(e)&&(a=parseInt(e,10)),console.log("parser",s.test(e),e,a),void 0===a||isNaN(a)?e:a}),l()}})}}});