@aquera/nile-elements 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.d.ts +17 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.js +18 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js +14 -3
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.d.ts +15 -4
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js +111 -51
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +3 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +9 -6
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +31 -18
- package/dist/internal/enum.cjs.js +2 -0
- package/dist/internal/enum.cjs.js.map +1 -0
- package/dist/internal/enum.esm.js +1 -0
- package/dist/nile-content-editor/index.cjs.js +1 -1
- package/dist/nile-content-editor/index.esm.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.cjs.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.cjs.js.map +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.cjs.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.cjs.js.map +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.esm.js +14 -3
- package/dist/nile-content-editor/nile-content-editor.esm.js +13 -12
- package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
- package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
- package/dist/nile-switcher/nile-switcher.esm.js +9 -8
- package/dist/src/internal/enum.d.ts +17 -0
- package/dist/src/internal/enum.js +18 -0
- package/dist/src/internal/enum.js.map +1 -0
- package/dist/src/nile-content-editor/nile-content-editor.css.js +14 -3
- package/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.d.ts +15 -4
- package/dist/src/nile-content-editor/nile-content-editor.js +111 -51
- package/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.d.ts +3 -1
- package/dist/src/nile-switcher/nile-switcher.js +9 -6
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/internal/enum.ts +17 -0
- package/src/nile-content-editor/nile-content-editor.css.ts +14 -3
- package/src/nile-content-editor/nile-content-editor.ts +123 -59
- package/src/nile-switcher/nile-switcher.ts +12 -6
@@ -1,2 +1,2 @@
|
|
1
|
-
System.register(["tslib","../index-cd83c5c8.cjs.js","lit/decorators.js","./nile-switcher.css.cjs.js","../internal/nile-element.cjs.js","lit/directives/choose.js","lit/directives/class-map.js","../property-0f6a51ec.cjs.js","lit"],function(_export,_context){"use strict";var e,i,t,n,r,s,l,o,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,_templateObject7,_templateObject8,_templateObject9,_templateObject10,_templateObject11,a,c,d;function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(obj,key,value){key=_toPropertyKey(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(typeof call==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}return{setters:[function(_tslib){e=_tslib.__decorate;},function(_index001CjsJs){i=_index001CjsJs.x;},function(_litDecoratorsJs){t=_litDecoratorsJs.customElement;},function(_nileSwitcherCssCjsJs){n=_nileSwitcherCssCjsJs.s;},function(_internalNileElementCjsJs){r=_internalNileElementCjsJs.N;},function(_litDirectivesChooseJs){s=_litDirectivesChooseJs.choose;},function(_litDirectivesClassMapJs){l=_litDirectivesClassMapJs.classMap;},function(_property002CjsJs){o=_property002CjsJs.n;},function(_lit){}],execute:function(){!function(e){e.DEFAULT="defaultInput",e.SWITCH="switchInput";}(a||(a={})),function(e){e.DROPDOWN="dropdown",e.TEXT="text",e.CHECKBOX="checkbox",e.TEXTAREA="text-area",e.RADIO="radio",e.CONTENTEDITOR="content-editor";}(c||(c={}));_export("N",d=/*#__PURE__*/function(_r){_inherits(d,_r);var _super=_createSuper(d);function d(){_classCallCheck(this,d);return _super.apply(this,arguments);}_createClass(d,[{key:"connectedCallback",value:function connectedCallback(){_get(_getPrototypeOf(d.prototype),"connectedCallback",this).call(this),this.emit("nile-init");}},{key:"disconnectedCallback",value:function disconnectedCallback(){_get(_getPrototypeOf(d.prototype),"disconnectedCallback",this).call(this),this.emit("nile-destroy");}},{key:"renderNileText",value:function renderNileText(e,t){var _this=this;var n=e.value,r=e.label,s=e.placeholder,l=e.disabled,o=e.required,a=e.errorMessage,c=e.inputType;return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-input\n .value=","\n .label=","\n .disabled=","\n .required=","\n .errorMessage=","\n .placeholder=","\n .error=","\n @nile-input=","\n ></nile-input>"])),n,r,l,o,a,s,!0,function(e){_this.handleChange(e,t,c);});}},{key:"renderDropdown",value:function renderDropdown(e,t){var _this2=this;var n=e.options,r=e.multiple,s=e.placeholder,l=e.disabled,o=e.inputType;return i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["<nile-select\n .placeholder=","\n .disabled=\"","\"\n .multiple=\"","\"\n @nile-change=","\n >\n ","\n </nile-select>"])),s,l,r,function(e){_this2.handleChange(e,t,o);},n===null||n===void 0?void 0:n.map(function(e){return i(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["<nile-option .value=\"","\">"," </nile-option>"])),e,e);}));}},{key:"renderNileTextArea",value:function renderNileTextArea(e,t){var _this3=this;var n=e.value,r=e.disabled,s=e.inputType;return i(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["<nile-textarea\n .value=","\n .disabled=","\n @nile-input=","\n ></nile-textarea>"])),n,r,function(e){_this3.handleChange(e,t,s);});}},{key:"renderNileCheckBox",value:function renderNileCheckBox(e,t){var _this4=this;var n=e.value,r=e.label,s=e.disabled,l=e.inputType;return i(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["<nile-checkbox\n .checked=","\n .label=","\n .disabled=","\n @valueChange=","\n ></nile-checkbox>"])),n,r,s,function(e){_this4.handleChange(e,t,l);});}},{key:"renderNileRadio",value:function renderNileRadio(e,t){var _this5=this;var n=e.options,r=e.value,s=e.disabled,l=e.inputType;return i(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["<nile-radio-group\n .value=","\n .disabled=","\n @change=","\n >\n ","\n </nile-radio-group>"])),r,s,function(e){_this5.handleChange(e,t,l);},n&&n.map(function(e){return i(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["<nile-radio .value=\"","\">"," </nile-radio>"])),e,e);}));}},{key:"renderContentEditor",value:function renderContentEditor(e,t){var _this6=this;var n=e.value,r=e.options,s=e.inputType,l=e.errorMessage,o=e.type;return i(_templateObject8||(_templateObject8=_taggedTemplateLiteral(["<nile-content-editor\n .value=","\n .options=","\n .type =","\n .errorMessage=","\n @nile-change=","\n >\n </nile-radio-group>"])),n,r,o,l,function(e){_this6.handleChange(e,t,s);});}},{key:"handleChange",value:function handleChange(e,i,t){t===c.CHECKBOX?this.nileSwitchConfig[i].value=e.detail.checked:this.nileSwitchConfig[i].value=e.detail.value,e.stopPropagation(),this.emit("nile-change",{config:this.nileSwitchConfig});}},{key:"renderIcon",value:function renderIcon(){var e=this.nileSwitchConfig.toggleSwitch?"stringinput":"header-functions";return i(_templateObject9||(_templateObject9=_taggedTemplateLiteral(["<nile-icon\n size=\"14\"\n class=","\n .name=","\n color=\"#005EA6\"\n @click=","\n ></nile-icon>"])),l({"pointer-cursor":!0,"flex-start":"stringinput"===e}),e,this.toggleField);}},{key:"toggleField",value:function toggleField(){this.nileSwitchConfig=_objectSpread(_objectSpread({},this.nileSwitchConfig),{},{toggleSwitch:!this.nileSwitchConfig.toggleSwitch}),this.emit("nile-switch",{config:this.nileSwitchConfig});}},{key:"singleFieldSwitcher",value:function singleFieldSwitcher(e,t,n,r){var _this7=this;var l=e.inputType,o=t.inputType;return i(_templateObject10||(_templateObject10=_taggedTemplateLiteral(["\n ","\n ","\n "])),n?s(o,[[c.TEXTAREA,function(){return _this7.renderNileTextArea(t,a.SWITCH);}],[c.TEXT,function(){return _this7.renderNileText(t,a.SWITCH);}],[c.CONTENTEDITOR,function(){return _this7.renderContentEditor(t,a.SWITCH);}]],function(){return _this7.renderNileTextArea(t,a.SWITCH);}):s(l,[[c.TEXT,function(){return _this7.renderNileText(e,a.DEFAULT);}],[c.CHECKBOX,function(){return _this7.renderNileCheckBox(e,a.DEFAULT);}],[c.TEXTAREA,function(){return _this7.renderNileTextArea(e,a.DEFAULT);}],[c.RADIO,function(){return _this7.renderNileRadio(e,a.DEFAULT);}],[c.DROPDOWN,function(){return _this7.renderDropdown(_this7.nileSwitchConfig.defaultInput,a.DEFAULT);}],[c.CONTENTEDITOR,function(){return _this7.renderContentEditor(_this7.nileSwitchConfig.defaultInput,a.DEFAULT);}]],function(){return _this7.renderNileText(e,a.DEFAULT);}),r?"":this.renderIcon());}},{key:"render",value:function render(){var _this$nileSwitchConfi=this.nileSwitchConfig,e=_this$nileSwitchConfi.toggleSwitch,t=_this$nileSwitchConfi.defaultInput,n=_this$nileSwitchConfi.switchInput,r=_this$nileSwitchConfi.disable;return i(_templateObject11||(_templateObject11=_taggedTemplateLiteral(["<div class=\"input-container\">\n ","\n </div>"])),this.singleFieldSwitcher(t,n,e,!!r));}}]);return d;}(r));d.styles=n,e([o({type:Object})],d.prototype,"nileSwitchConfig",void 0),_export("N",d=e([t("nile-switcher")],d));}};});
|
1
|
+
System.register(["tslib","../index-cd83c5c8.cjs.js","lit/decorators.js","./nile-switcher.css.cjs.js","../internal/nile-element.cjs.js","lit/directives/choose.js","lit/directives/class-map.js","../property-0f6a51ec.cjs.js","lit"],function(_export,_context){"use strict";var e,i,t,n,r,s,l,o,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,_templateObject7,_templateObject8,_templateObject9,_templateObject10,_templateObject11,a,c,d;function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(obj,key,value){key=_toPropertyKey(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(typeof call==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}return{setters:[function(_tslib){e=_tslib.__decorate;},function(_index001CjsJs){i=_index001CjsJs.x;},function(_litDecoratorsJs){t=_litDecoratorsJs.customElement;},function(_nileSwitcherCssCjsJs){n=_nileSwitcherCssCjsJs.s;},function(_internalNileElementCjsJs){r=_internalNileElementCjsJs.N;},function(_litDirectivesChooseJs){s=_litDirectivesChooseJs.choose;},function(_litDirectivesClassMapJs){l=_litDirectivesClassMapJs.classMap;},function(_property002CjsJs){o=_property002CjsJs.n;},function(_lit){}],execute:function(){!function(e){e.DEFAULT="defaultInput",e.SWITCH="switchInput";}(a||(a={})),function(e){e.DROPDOWN="dropdown",e.TEXT="text",e.CHECKBOX="checkbox",e.TEXTAREA="text-area",e.RADIO="radio",e.CONTENTEDITOR="content-editor";}(c||(c={}));_export("N",d=/*#__PURE__*/function(_r){_inherits(d,_r);var _super=_createSuper(d);function d(){_classCallCheck(this,d);return _super.apply(this,arguments);}_createClass(d,[{key:"connectedCallback",value:function connectedCallback(){_get(_getPrototypeOf(d.prototype),"connectedCallback",this).call(this),this.emit("nile-init");}},{key:"disconnectedCallback",value:function disconnectedCallback(){_get(_getPrototypeOf(d.prototype),"disconnectedCallback",this).call(this),this.emit("nile-destroy");}},{key:"renderNileText",value:function renderNileText(e,t){var _this=this;var n=e.value,r=e.label,s=e.placeholder,l=e.disabled,o=e.required,a=e.errorMessage,c=e.inputType;return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-input\n .value=","\n .label=","\n .disabled=","\n .required=","\n .errorMessage=","\n .placeholder=","\n .error=","\n @nile-input=","\n ></nile-input>"])),n,r,l,o,a,s,!0,function(e){_this.handleChange(e,t,c);});}},{key:"renderDropdown",value:function renderDropdown(e,t){var _this2=this;var n=e.options,r=e.multiple,s=e.placeholder,l=e.disabled,o=e.inputType;return i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["<nile-select\n .placeholder=","\n .disabled=\"","\"\n .multiple=\"","\"\n @nile-change=","\n >\n ","\n </nile-select>"])),s,l,r,function(e){_this2.handleChange(e,t,o);},n===null||n===void 0?void 0:n.map(function(e){return i(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["<nile-option .value=\"","\">"," </nile-option>"])),e,e);}));}},{key:"renderNileTextArea",value:function renderNileTextArea(e,t){var _this3=this;var n=e.value,r=e.disabled,s=e.inputType;return i(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["<nile-textarea\n .value=","\n .disabled=","\n @nile-input=","\n ></nile-textarea>"])),n,r,function(e){_this3.handleChange(e,t,s);});}},{key:"renderNileCheckBox",value:function renderNileCheckBox(e,t){var _this4=this;var n=e.value,r=e.label,s=e.disabled,l=e.inputType;return i(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["<nile-checkbox\n .checked=","\n .label=","\n .disabled=","\n @valueChange=","\n ></nile-checkbox>"])),n,r,s,function(e){_this4.handleChange(e,t,l);});}},{key:"renderNileRadio",value:function renderNileRadio(e,t){var _this5=this;var n=e.options,r=e.value,s=e.disabled,l=e.inputType;return i(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["<nile-radio-group\n .value=","\n .disabled=","\n @change=","\n >\n ","\n </nile-radio-group>"])),r,s,function(e){_this5.handleChange(e,t,l);},n&&n.map(function(e){return i(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["<nile-radio .value=\"","\">"," </nile-radio>"])),e,e);}));}},{key:"renderContentEditor",value:function renderContentEditor(e,t){var _this6=this;var n=e.value,r=e.options,s=e.inputType,l=e.errorMessage,o=e.type,a=e.readonly;return i(_templateObject8||(_templateObject8=_taggedTemplateLiteral(["<nile-content-editor\n .value=","\n .options=","\n .type =","\n .readonly=","\n .errorMessage=","\n @nile-change=","\n >\n </nile-radio-group>"])),n,r,o,a,l,function(e){_this6.handleChange(e,t,s);});}},{key:"handleChange",value:function handleChange(e,i,t){t===c.CHECKBOX?this.nileSwitchConfig[i].value=e.detail.checked:this.nileSwitchConfig[i].value=e.detail.value,e.stopPropagation(),this.emit("nile-change",{config:this.nileSwitchConfig});}},{key:"renderIcon",value:function renderIcon(){var e=this.nileSwitchConfig.toggleSwitch?"stringinput":"header-functions";return i(_templateObject9||(_templateObject9=_taggedTemplateLiteral(["<nile-icon\n size=\"14\"\n class=","\n .name=","\n color=\"#005EA6\"\n @click=","\n ></nile-icon>"])),l({"pointer-cursor":!0,"flex-start":!0}),e,this.toggleField);}},{key:"toggleField",value:function toggleField(){this.nileSwitchConfig.confirmation||(this.nileSwitchConfig=_objectSpread(_objectSpread({},this.nileSwitchConfig),{},{toggleSwitch:!this.nileSwitchConfig.toggleSwitch})),this.emit("nile-switch",{config:this.nileSwitchConfig});}},{key:"singleFieldSwitcher",value:function singleFieldSwitcher(e,t,n,r){var _this7=this;var l=e.inputType,o=t.inputType;return i(_templateObject10||(_templateObject10=_taggedTemplateLiteral(["\n ","\n ","\n "])),n?s(o,[[c.TEXTAREA,function(){return _this7.renderNileTextArea(t,a.SWITCH);}],[c.TEXT,function(){return _this7.renderNileText(t,a.SWITCH);}],[c.CONTENTEDITOR,function(){return _this7.renderContentEditor(t,a.SWITCH);}]],function(){return _this7.renderNileTextArea(t,a.SWITCH);}):s(l,[[c.TEXT,function(){return _this7.renderNileText(e,a.DEFAULT);}],[c.CHECKBOX,function(){return _this7.renderNileCheckBox(e,a.DEFAULT);}],[c.TEXTAREA,function(){return _this7.renderNileTextArea(e,a.DEFAULT);}],[c.RADIO,function(){return _this7.renderNileRadio(e,a.DEFAULT);}],[c.DROPDOWN,function(){return _this7.renderDropdown(_this7.nileSwitchConfig.defaultInput,a.DEFAULT);}],[c.CONTENTEDITOR,function(){return _this7.renderContentEditor(_this7.nileSwitchConfig.defaultInput,a.DEFAULT);}]],function(){return _this7.renderNileText(e,a.DEFAULT);}),r?"":this.renderIcon());}},{key:"render",value:function render(){var _this$nileSwitchConfi=this.nileSwitchConfig,e=_this$nileSwitchConfi.toggleSwitch,t=_this$nileSwitchConfi.defaultInput,n=_this$nileSwitchConfi.switchInput,r=_this$nileSwitchConfi.disable;return i(_templateObject11||(_templateObject11=_taggedTemplateLiteral(["<div class=\"input-container\">\n ","\n </div>"])),this.singleFieldSwitcher(t,n,e,!!r));}}]);return d;}(r));d.styles=n,e([o({type:Object})],d.prototype,"nileSwitchConfig",void 0),_export("N",d=e([t("nile-switcher")],d));}};});
|
2
2
|
//# sourceMappingURL=nile-switcher.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-switcher.cjs.js","sources":["../../../src/nile-switcher/nile-switcher.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, property, TemplateResult } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-switcher.css';\nimport NileElement from '../internal/nile-element';\nimport { CSSResultGroup } from 'lit';\nimport { choose } from 'lit/directives/choose.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/**\n * @summary Allows you to switch between nile elements\n\n * @dependency nile-icon\n * @dependency nile-input\n * @dependency nile-checkbox\n * @dependency nile-dropdown\n * @dependency nile-textarea\n *\n \n * @event nile-change - Emitted when the control's value changes.\n * @event nile-switch - Emitted when the nile component is being switched.\n \n */\n\nexport interface switchconfig {\n [key: string]: any;\n toggleSwitch: boolean;\n disable?: boolean;\n defaultInput: switchInputType;\n switchInput: switchInputType;\n}\n\nexport interface switchInputType {\n inputType:\n | INPUT_TYPE_NAMES.DROPDOWN\n | INPUT_TYPE_NAMES.TEXT\n | INPUT_TYPE_NAMES.CHECKBOX\n | INPUT_TYPE_NAMES.TEXTAREA\n | INPUT_TYPE_NAMES.RADIO\n | INPUT_TYPE_NAMES.CONTENTEDITOR;\n value?: String | boolean;\n label?: String;\n type: string;\n placeholder?: string;\n disabled?: boolean;\n required?: boolean;\n error?: boolean;\n errorMessage?: string;\n options?: Array<any>;\n multiple?: boolean;\n}\n\nexport enum INPUT_TYPE {\n DEFAULT = 'defaultInput',\n SWITCH = 'switchInput',\n}\n\nexport enum INPUT_TYPE_NAMES {\n DROPDOWN = 'dropdown',\n TEXT = 'text',\n CHECKBOX = 'checkbox',\n TEXTAREA = 'text-area',\n RADIO = 'radio',\n CONTENTEDITOR = 'content-editor',\n}\n\n@customElement('nile-switcher')\nexport class NileSwitcher extends NileElement {\n /**\n * The styles for nile switcher\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n static styles: CSSResultGroup = styles;\n @property({ type: Object }) nileSwitchConfig: switchconfig;\n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n renderNileText(Input: switchInputType, inputType: string) {\n const {\n value,\n label,\n placeholder,\n disabled,\n required,\n errorMessage,\n inputType: inputTypeName,\n } = Input;\n return html`<nile-input\n .value=${value}\n .label=${label}\n .disabled=${disabled}\n .required=${required}\n .errorMessage=${errorMessage}\n .placeholder=${placeholder}\n .error=${true}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n ></nile-input>`;\n }\n\n renderDropdown(Input: switchInputType, inputType: string) {\n const {\n options,\n multiple,\n placeholder,\n disabled,\n inputType: inputTypeName,\n } = Input;\n return html`<nile-select\n .placeholder=${placeholder}\n .disabled=\"${disabled}\"\n .multiple=\"${multiple}\"\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n >\n ${options?.map((option: any) => {\n return html`<nile-option .value=\"${option}\">${option} </nile-option>`;\n })}\n </nile-select>`;\n }\n\n renderNileTextArea(Input: switchInputType, inputType: string) {\n const { value, disabled, inputType: inputTypeName } = Input;\n return html`<nile-textarea\n .value=${value}\n .disabled=${disabled}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n ></nile-textarea>`;\n }\n\n renderNileCheckBox(Input: switchInputType, inputType: string) {\n const { value, label, disabled, inputType: inputTypeName } = Input;\n\n return html`<nile-checkbox\n .checked=${value}\n .label=${label}\n .disabled=${disabled}\n @valueChange=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n ></nile-checkbox>`;\n }\n\n renderNileRadio(Input: switchInputType, inputType: string) {\n const { options, value, disabled, inputType: inputTypeName } = Input;\n\n return html`<nile-radio-group\n .value=${value}\n .disabled=${disabled}\n @change=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n >\n ${options &&\n options.map((option: any) => {\n return html`<nile-radio .value=\"${option}\">${option} </nile-radio>`;\n })}\n </nile-radio-group>`;\n }\n\n renderContentEditor(Input: switchInputType, inputType: string) {\n const {\n value,\n options,\n inputType: inputTypeName,\n errorMessage,\n type,\n } = Input;\n return html`<nile-content-editor\n .value=${value}\n .options=${options}\n .type =${type}\n .errorMessage=${errorMessage}\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n >\n </nile-radio-group>`;\n }\n\n handleChange(event: CustomEvent, inputType: string, inputTypeName: string) {\n if (inputTypeName === INPUT_TYPE_NAMES.CHECKBOX) {\n this.nileSwitchConfig[inputType as keyof switchconfig].value =\n event.detail.checked;\n } else {\n this.nileSwitchConfig[inputType as keyof switchconfig].value =\n event.detail.value;\n }\n event.stopPropagation();\n this.emit('nile-change', { config: this.nileSwitchConfig });\n }\n\n renderIcon() {\n const icon = !this.nileSwitchConfig.toggleSwitch\n ? 'header-functions'\n : 'stringinput';\n return html`<nile-icon\n size=\"14\"\n class=${classMap({\n 'pointer-cursor': true,\n 'flex-start': icon === 'stringinput',\n })}\n .name=${icon}\n color=\"#005EA6\"\n @click=${this.toggleField}\n ></nile-icon>`;\n }\n\n toggleField() {\n this.nileSwitchConfig = {\n ...this.nileSwitchConfig,\n toggleSwitch: !this.nileSwitchConfig.toggleSwitch,\n };\n this.emit('nile-switch', { config: this.nileSwitchConfig });\n }\n\n singleFieldSwitcher(\n defaultInput: switchInputType,\n switchInput: switchInputType,\n toggleField: boolean,\n disable: boolean\n ) {\n const defaultInputType = defaultInput.inputType;\n const switchInputType = switchInput.inputType;\n return html`\n ${!toggleField\n ? choose(\n defaultInputType,\n [\n [\n INPUT_TYPE_NAMES.TEXT,\n () => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.CHECKBOX,\n () => this.renderNileCheckBox(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.TEXTAREA,\n () => this.renderNileTextArea(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.RADIO,\n () => this.renderNileRadio(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.DROPDOWN,\n () =>\n this.renderDropdown(\n this.nileSwitchConfig.defaultInput,\n INPUT_TYPE.DEFAULT\n ),\n ],\n [\n INPUT_TYPE_NAMES.CONTENTEDITOR,\n () =>\n this.renderContentEditor(\n this.nileSwitchConfig.defaultInput,\n INPUT_TYPE.DEFAULT\n ),\n ],\n ],\n () => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT)\n )\n : choose(\n switchInputType,\n [\n [\n INPUT_TYPE_NAMES.TEXTAREA,\n () => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH),\n ],\n [\n INPUT_TYPE_NAMES.TEXT,\n () => this.renderNileText(switchInput, INPUT_TYPE.SWITCH),\n ],\n [\n INPUT_TYPE_NAMES.CONTENTEDITOR,\n () => this.renderContentEditor(switchInput, INPUT_TYPE.SWITCH),\n ],\n ],\n\n () => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH)\n )}\n ${!disable ? this.renderIcon() : ''}\n `;\n }\n public render(): TemplateResult {\n const {\n toggleSwitch: toggleField,\n defaultInput,\n switchInput,\n disable,\n } = this.nileSwitchConfig;\n\n return html`<div class=\"input-container\">\n ${this.singleFieldSwitcher(\n defaultInput,\n switchInput,\n toggleField,\n !!disable\n )}\n </div>`;\n }\n}\n\nexport default NileSwitcher;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-switcher': NileSwitcher;\n }\n}\n"],"names":["INPUT_TYPE","DEFAULT","SWITCH","INPUT_TYPE_NAMES","DROPDOWN","TEXT","CHECKBOX","TEXTAREA","RADIO","CONTENTEDITOR","_export","NileSwitcher","connectedCallback","super","this","emit","key","value","disconnectedCallback","renderNileText","Input","inputType","label","placeholder","disabled","required","errorMessage","inputTypeName","html","_templateObject","_taggedTemplateLiteral","e","handleChange","renderDropdown","_this2","options","multiple","_templateObject2","map","option","_templateObject3","renderNileTextArea","_templateObject4","renderNileCheckBox","_templateObject5","renderNileRadio","_templateObject6","_templateObject7","renderContentEditor","_this6","type","_templateObject8","event","nileSwitchConfig","detail","checked","stopPropagation","config","renderIcon","icon","toggleSwitch","_templateObject9","classMap","toggleField","singleFieldSwitcher","defaultInput","switchInput","disable","defaultInputType","switchInputType","_templateObject10","choose","render","_this$nileSwitchConfi","_templateObject11","d","NileElement","styles","__decorate","property","Object","prototype","customElement"],"mappings":"+9KA0DA,CAAA,SAAYA,CACVA,CAAAA,CAAAA,CAAAA,CAAAC,OAAA,CAAA,cAAA,CACAD,EAAAE,MAAA,CAAA,aACD,EAHD,CAAYF,CAAAA,GAAAA,EAGX,CAAA,CAAA,CAAA,CAAA,CAED,SAAYG,CAAAA,CAAAA,CACVA,CAAA,CAAAC,QAAA,CAAA,WACAD,CAAA,CAAAE,IAAA,CAAA,OACAF,CAAA,CAAAG,QAAA,CAAA,WACAH,CAAA,CAAAI,QAAA,CAAA,W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BAAAA,CADyBA,YACzBA,CACAC,CAAAA,CAAAA,qBAAAA,CADYA,WACZA,CACAC,CAAAA,CAAAA,qBAAAA,CADWA,OACXA,CAGF,MAAOvC,CAAAA,CAAI,CAAA8C,iBAAA,GAAAA,iBAAA,CAAA5C,sBAAA,8DACPhB,IAAKkD,CAAAA,mBAAAA,CACLC,CACAC,CAAAA,CAAAA,CACAH,CACEI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAGP,CAAA,WAAAQ,CAAA,GAvP+BC,CAAAA,GAKzBjE,EAAMkE,MAAmBA,CAAAA,CAAAA,CACJC,EAAA,CAA3BC,CAAAA,CAAS,CAAE7B,IAAM8B,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAAyCrE,CAAAsE,CAAAA,SAAAA,CAAA,uBAAA,EANhDtE,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAYmE,EAAA,CADxBI,CAAAA,CAAc,kBACFvE"}
|
1
|
+
{"version":3,"file":"nile-switcher.cjs.js","sources":["../../../src/nile-switcher/nile-switcher.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, property, TemplateResult } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-switcher.css';\nimport NileElement from '../internal/nile-element';\nimport { CSSResultGroup } from 'lit';\nimport { choose } from 'lit/directives/choose.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/**\n * @summary Allows you to switch between nile elements\n\n * @dependency nile-icon\n * @dependency nile-input\n * @dependency nile-checkbox\n * @dependency nile-dropdown\n * @dependency nile-textarea\n *\n \n * @event nile-change - Emitted when the control's value changes.\n * @event nile-switch - Emitted when the nile component is being switched.\n \n */\n\nexport interface switchconfig {\n [key: string]: any;\n toggleSwitch: boolean;\n disable?: boolean;\n confirmation?: boolean;\n defaultInput: switchInputType;\n switchInput: switchInputType;\n}\n\nexport interface switchInputType {\n inputType:\n | INPUT_TYPE_NAMES.DROPDOWN\n | INPUT_TYPE_NAMES.TEXT\n | INPUT_TYPE_NAMES.CHECKBOX\n | INPUT_TYPE_NAMES.TEXTAREA\n | INPUT_TYPE_NAMES.RADIO\n | INPUT_TYPE_NAMES.CONTENTEDITOR;\n value?: String | boolean;\n label?: String;\n readonly?: boolean;\n type?: string;\n placeholder?: string;\n disabled?: boolean;\n required?: boolean;\n error?: boolean;\n errorMessage?: string;\n options?: Array<any>;\n multiple?: boolean;\n}\n\nexport enum INPUT_TYPE {\n DEFAULT = 'defaultInput',\n SWITCH = 'switchInput',\n}\n\nexport enum INPUT_TYPE_NAMES {\n DROPDOWN = 'dropdown',\n TEXT = 'text',\n CHECKBOX = 'checkbox',\n TEXTAREA = 'text-area',\n RADIO = 'radio',\n CONTENTEDITOR = 'content-editor',\n}\n\n@customElement('nile-switcher')\nexport class NileSwitcher extends NileElement {\n /**\n * The styles for nile switcher\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n static styles: CSSResultGroup = styles;\n @property({ type: Object }) nileSwitchConfig: switchconfig;\n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n renderNileText(Input: switchInputType, inputType: string) {\n const {\n value,\n label,\n placeholder,\n disabled,\n required,\n errorMessage,\n inputType: inputTypeName,\n } = Input;\n return html`<nile-input\n .value=${value}\n .label=${label}\n .disabled=${disabled}\n .required=${required}\n .errorMessage=${errorMessage}\n .placeholder=${placeholder}\n .error=${true}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n ></nile-input>`;\n }\n\n renderDropdown(Input: switchInputType, inputType: string) {\n const {\n options,\n multiple,\n placeholder,\n disabled,\n inputType: inputTypeName,\n } = Input;\n return html`<nile-select\n .placeholder=${placeholder}\n .disabled=\"${disabled}\"\n .multiple=\"${multiple}\"\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n >\n ${options?.map((option: any) => {\n return html`<nile-option .value=\"${option}\">${option} </nile-option>`;\n })}\n </nile-select>`;\n }\n\n renderNileTextArea(Input: switchInputType, inputType: string) {\n const { value, disabled, inputType: inputTypeName } = Input;\n return html`<nile-textarea\n .value=${value}\n .disabled=${disabled}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n ></nile-textarea>`;\n }\n\n renderNileCheckBox(Input: switchInputType, inputType: string) {\n const { value, label, disabled, inputType: inputTypeName } = Input;\n\n return html`<nile-checkbox\n .checked=${value}\n .label=${label}\n .disabled=${disabled}\n @valueChange=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n ></nile-checkbox>`;\n }\n\n renderNileRadio(Input: switchInputType, inputType: string) {\n const { options, value, disabled, inputType: inputTypeName } = Input;\n\n return html`<nile-radio-group\n .value=${value}\n .disabled=${disabled}\n @change=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n >\n ${options &&\n options.map((option: any) => {\n return html`<nile-radio .value=\"${option}\">${option} </nile-radio>`;\n })}\n </nile-radio-group>`;\n }\n\n renderContentEditor(Input: switchInputType, inputType: string) {\n const {\n value,\n options,\n inputType: inputTypeName,\n errorMessage,\n type,\n readonly,\n } = Input;\n return html`<nile-content-editor\n .value=${value}\n .options=${options}\n .type =${type}\n .readonly=${readonly}\n .errorMessage=${errorMessage}\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType, inputTypeName);\n }}\n >\n </nile-radio-group>`;\n }\n\n handleChange(event: CustomEvent, inputType: string, inputTypeName: string) {\n if (inputTypeName === INPUT_TYPE_NAMES.CHECKBOX) {\n this.nileSwitchConfig[inputType as keyof switchconfig].value =\n event.detail.checked;\n } else {\n this.nileSwitchConfig[inputType as keyof switchconfig].value =\n event.detail.value;\n }\n event.stopPropagation();\n this.emit('nile-change', { config: this.nileSwitchConfig });\n }\n\n renderIcon() {\n const icon = !this.nileSwitchConfig.toggleSwitch\n ? 'header-functions'\n : 'stringinput';\n return html`<nile-icon\n size=\"14\"\n class=${classMap({\n 'pointer-cursor': true,\n 'flex-start': true,\n })}\n .name=${icon}\n color=\"#005EA6\"\n @click=${this.toggleField}\n ></nile-icon>`;\n }\n\n toggleField() {\n if (!this.nileSwitchConfig.confirmation) {\n this.nileSwitchConfig = {\n ...this.nileSwitchConfig,\n toggleSwitch: !this.nileSwitchConfig.toggleSwitch,\n };\n }\n this.emit('nile-switch', { config: this.nileSwitchConfig });\n }\n\n singleFieldSwitcher(\n defaultInput: switchInputType,\n switchInput: switchInputType,\n toggleField: boolean,\n disable: boolean\n ) {\n const defaultInputType = defaultInput.inputType;\n const switchInputType = switchInput.inputType;\n return html`\n ${!toggleField\n ? choose(\n defaultInputType,\n [\n [\n INPUT_TYPE_NAMES.TEXT,\n () => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.CHECKBOX,\n () => this.renderNileCheckBox(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.TEXTAREA,\n () => this.renderNileTextArea(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.RADIO,\n () => this.renderNileRadio(defaultInput, INPUT_TYPE.DEFAULT),\n ],\n [\n INPUT_TYPE_NAMES.DROPDOWN,\n () =>\n this.renderDropdown(\n this.nileSwitchConfig.defaultInput,\n INPUT_TYPE.DEFAULT\n ),\n ],\n [\n INPUT_TYPE_NAMES.CONTENTEDITOR,\n () =>\n this.renderContentEditor(\n this.nileSwitchConfig.defaultInput,\n INPUT_TYPE.DEFAULT\n ),\n ],\n ],\n () => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT)\n )\n : choose(\n switchInputType,\n [\n [\n INPUT_TYPE_NAMES.TEXTAREA,\n () => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH),\n ],\n [\n INPUT_TYPE_NAMES.TEXT,\n () => this.renderNileText(switchInput, INPUT_TYPE.SWITCH),\n ],\n [\n INPUT_TYPE_NAMES.CONTENTEDITOR,\n () => this.renderContentEditor(switchInput, INPUT_TYPE.SWITCH),\n ],\n ],\n\n () => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH)\n )}\n ${!disable ? this.renderIcon() : ''}\n `;\n }\n public render(): TemplateResult {\n const {\n toggleSwitch: toggleField,\n defaultInput,\n switchInput,\n disable,\n } = this.nileSwitchConfig;\n\n return html`<div class=\"input-container\">\n ${this.singleFieldSwitcher(\n defaultInput,\n switchInput,\n toggleField,\n !!disable\n )}\n </div>`;\n }\n}\n\nexport default NileSwitcher;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-switcher': NileSwitcher;\n }\n}\n"],"names":["INPUT_TYPE","DEFAULT","SWITCH","INPUT_TYPE_NAMES","DROPDOWN","TEXT","CHECKBOX","TEXTAREA","RADIO","CONTENTEDITOR","_export","NileSwitcher","connectedCallback","super","this","emit","key","value","disconnectedCallback","renderNileText","Input","inputType","label","placeholder","disabled","required","errorMessage","inputTypeName","html","_templateObject","_taggedTemplateLiteral","e","handleChange","renderDropdown","_this2","options","multiple","_templateObject2","map","option","_templateObject3","renderNileTextArea","_templateObject4","renderNileCheckBox","_templateObject5","renderNileRadio","_templateObject6","_templateObject7","renderContentEditor","type","readonly","_templateObject8","event","nileSwitchConfig","detail","checked","stopPropagation","config","renderIcon","icon","toggleSwitch","_templateObject9","classMap","toggleField","confirmation","_objectSpread","singleFieldSwitcher","defaultInput","switchInput","disable","defaultInputType","switchInputType","_templateObject10","choose","render","_this$nileSwitchConfi","_templateObject11","d","NileElement","styles","__decorate","property","Object","prototype","customElement"],"mappings":"+9KA4DA,CAAA,SAAYA,CACVA,CAAAA,CAAAA,CAAAA,CAAAC,OAAA,CAAA,cAAA,CACAD,EAAAE,MAAA,CAAA,aACD,EAHD,CAAYF,CAAAA,GAA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AAAA,CAA8B,GAApBvD,IAAK4C,CAAAA,UAAAA,CAAAA,CAAAA,EAErB,CACM,GAAA1C,GAAA,UAAAC,KAAA,UAAAyD,OAAA,CAAAA,CACL,IAAAC,qBAAA,CAKI7D,IAAKuC,CAAAA,gBAAAA,CAJOU,wBAAdH,YAAAA,CACAO,CAAAA,CAAAA,qBAAAA,CADyBA,YACzBA,CACAC,CAAAA,CAAAA,qBAAAA,CADYA,WACZA,CACAC,CAAAA,CAAAA,qBAAAA,CADWA,OACXA,CAGF,MAAOzC,CAAAA,CAAI,CAAAgD,iBAAA,GAAAA,iBAAA,CAAA9C,sBAAA,8DACPhB,IAAKoD,CAAAA,mBAAAA,CACLC,CACAC,CAAAA,CAAAA,CACAL,CACEM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAGP,CAAA,WAAAQ,CAAA,GA3P+BC,CAAAA,GAKzBnE,EAAMoE,MAAmBA,CAAAA,CAAAA,CACJC,EAAA,CAA3BC,CAAAA,CAAS,CAAEhC,IAAMiC,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAAyCvE,CAAAwE,CAAAA,SAAAA,CAAA,uBAAA,EANhDxE,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAYqE,EAAA,CADxBI,CAAAA,CAAc,kBACFzE"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";import{customElement as t}from"lit/decorators.js";import{s as n}from"./nile-switcher.css.esm.js";import{N as r}from"../internal/nile-element.esm.js";import{choose as s}from"lit/directives/choose.js";import{classMap as l}from"lit/directives/class-map.js";import{n as o}from"../property-09139d3c.esm.js";import"lit";var a,
|
1
|
+
import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";import{customElement as t}from"lit/decorators.js";import{s as n}from"./nile-switcher.css.esm.js";import{N as r}from"../internal/nile-element.esm.js";import{choose as s}from"lit/directives/choose.js";import{classMap as l}from"lit/directives/class-map.js";import{n as o}from"../property-09139d3c.esm.js";import"lit";var a,d;!function(e){e.DEFAULT="defaultInput",e.SWITCH="switchInput"}(a||(a={})),function(e){e.DROPDOWN="dropdown",e.TEXT="text",e.CHECKBOX="checkbox",e.TEXTAREA="text-area",e.RADIO="radio",e.CONTENTEDITOR="content-editor"}(d||(d={}));let c=class extends r{connectedCallback(){super.connectedCallback(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}renderNileText(e,t){const{value:n,label:r,placeholder:s,disabled:l,required:o,errorMessage:a,inputType:d}=e;return i`<nile-input
|
2
2
|
.value=${n}
|
3
3
|
.label=${r}
|
4
4
|
.disabled=${l}
|
@@ -6,7 +6,7 @@ import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";
|
|
6
6
|
.errorMessage=${a}
|
7
7
|
.placeholder=${s}
|
8
8
|
.error=${!0}
|
9
|
-
@nile-input=${e=>{this.handleChange(e,t,
|
9
|
+
@nile-input=${e=>{this.handleChange(e,t,d)}}
|
10
10
|
></nile-input>`}renderDropdown(e,t){const{options:n,multiple:r,placeholder:s,disabled:l,inputType:o}=e;return i`<nile-select
|
11
11
|
.placeholder=${s}
|
12
12
|
.disabled="${l}"
|
@@ -29,22 +29,23 @@ import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";
|
|
29
29
|
@change=${e=>{this.handleChange(e,t,l)}}
|
30
30
|
>
|
31
31
|
${n&&n.map((e=>i`<nile-radio .value="${e}">${e} </nile-radio>`))}
|
32
|
-
</nile-radio-group>`}renderContentEditor(e,t){const{value:n,options:r,inputType:s,errorMessage:l,type:o}=e;return i`<nile-content-editor
|
32
|
+
</nile-radio-group>`}renderContentEditor(e,t){const{value:n,options:r,inputType:s,errorMessage:l,type:o,readonly:a}=e;return i`<nile-content-editor
|
33
33
|
.value=${n}
|
34
34
|
.options=${r}
|
35
35
|
.type =${o}
|
36
|
+
.readonly=${a}
|
36
37
|
.errorMessage=${l}
|
37
38
|
@nile-change=${e=>{this.handleChange(e,t,s)}}
|
38
39
|
>
|
39
|
-
</nile-radio-group>`}handleChange(e,i,t){t===
|
40
|
+
</nile-radio-group>`}handleChange(e,i,t){t===d.CHECKBOX?this.nileSwitchConfig[i].value=e.detail.checked:this.nileSwitchConfig[i].value=e.detail.value,e.stopPropagation(),this.emit("nile-change",{config:this.nileSwitchConfig})}renderIcon(){const e=this.nileSwitchConfig.toggleSwitch?"stringinput":"header-functions";return i`<nile-icon
|
40
41
|
size="14"
|
41
|
-
class=${l({"pointer-cursor":!0,"flex-start"
|
42
|
+
class=${l({"pointer-cursor":!0,"flex-start":!0})}
|
42
43
|
.name=${e}
|
43
44
|
color="#005EA6"
|
44
45
|
@click=${this.toggleField}
|
45
|
-
></nile-icon>`}toggleField(){this.nileSwitchConfig={...this.nileSwitchConfig,toggleSwitch:!this.nileSwitchConfig.toggleSwitch},this.emit("nile-switch",{config:this.nileSwitchConfig})}singleFieldSwitcher(e,t,n,r){const l=e.inputType,o=t.inputType;return i`
|
46
|
-
${n?s(o,[[
|
46
|
+
></nile-icon>`}toggleField(){this.nileSwitchConfig.confirmation||(this.nileSwitchConfig={...this.nileSwitchConfig,toggleSwitch:!this.nileSwitchConfig.toggleSwitch}),this.emit("nile-switch",{config:this.nileSwitchConfig})}singleFieldSwitcher(e,t,n,r){const l=e.inputType,o=t.inputType;return i`
|
47
|
+
${n?s(o,[[d.TEXTAREA,()=>this.renderNileTextArea(t,a.SWITCH)],[d.TEXT,()=>this.renderNileText(t,a.SWITCH)],[d.CONTENTEDITOR,()=>this.renderContentEditor(t,a.SWITCH)]],(()=>this.renderNileTextArea(t,a.SWITCH))):s(l,[[d.TEXT,()=>this.renderNileText(e,a.DEFAULT)],[d.CHECKBOX,()=>this.renderNileCheckBox(e,a.DEFAULT)],[d.TEXTAREA,()=>this.renderNileTextArea(e,a.DEFAULT)],[d.RADIO,()=>this.renderNileRadio(e,a.DEFAULT)],[d.DROPDOWN,()=>this.renderDropdown(this.nileSwitchConfig.defaultInput,a.DEFAULT)],[d.CONTENTEDITOR,()=>this.renderContentEditor(this.nileSwitchConfig.defaultInput,a.DEFAULT)]],(()=>this.renderNileText(e,a.DEFAULT)))}
|
47
48
|
${r?"":this.renderIcon()}
|
48
49
|
`}render(){const{toggleSwitch:e,defaultInput:t,switchInput:n,disable:r}=this.nileSwitchConfig;return i`<div class="input-container">
|
49
50
|
${this.singleFieldSwitcher(t,n,e,!!r)}
|
50
|
-
</div>`}};
|
51
|
+
</div>`}};c.styles=n,e([o({type:Object})],c.prototype,"nileSwitchConfig",void 0),c=e([t("nile-switcher")],c);export{c as N};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export declare const KeyCode: {
|
2
|
+
BACKSPACE: string;
|
3
|
+
TAB: string;
|
4
|
+
ENTER: string;
|
5
|
+
SHIFT: string;
|
6
|
+
CTRL: string;
|
7
|
+
ESCAPE: string;
|
8
|
+
SPACE: string;
|
9
|
+
PAGE_UP: string;
|
10
|
+
PAGE_DOWN: string;
|
11
|
+
END: string;
|
12
|
+
HOME: string;
|
13
|
+
ARROW_LEFT: string;
|
14
|
+
ARROW_UP: string;
|
15
|
+
ARROW_RIGHT: string;
|
16
|
+
ARROW_DOWN: string;
|
17
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export const KeyCode = {
|
2
|
+
BACKSPACE: 'Backspace',
|
3
|
+
TAB: 'Tab',
|
4
|
+
ENTER: 'Enter',
|
5
|
+
SHIFT: 'ShiftLeft',
|
6
|
+
CTRL: 'ControlLeft',
|
7
|
+
ESCAPE: 'Escape',
|
8
|
+
SPACE: 'Space',
|
9
|
+
PAGE_UP: 'PageUp',
|
10
|
+
PAGE_DOWN: 'PageDown',
|
11
|
+
END: 'End',
|
12
|
+
HOME: 'Home',
|
13
|
+
ARROW_LEFT: 'ArrowLeft',
|
14
|
+
ARROW_UP: 'ArrowUp',
|
15
|
+
ARROW_RIGHT: 'ArrowRight',
|
16
|
+
ARROW_DOWN: 'ArrowDown',
|
17
|
+
};
|
18
|
+
//# sourceMappingURL=enum.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/internal/enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE,WAAW;IACtB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,UAAU;IACrB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,WAAW;IACvB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;CACxB,CAAC","sourcesContent":["export const KeyCode = {\n BACKSPACE: 'Backspace',\n TAB: 'Tab',\n ENTER: 'Enter',\n SHIFT: 'ShiftLeft', // or 'ShiftRight'\n CTRL: 'ControlLeft', // or 'ControlRight'\n ESCAPE: 'Escape',\n SPACE: 'Space',\n PAGE_UP: 'PageUp',\n PAGE_DOWN: 'PageDown',\n END: 'End',\n HOME: 'Home',\n ARROW_LEFT: 'ArrowLeft',\n ARROW_UP: 'ArrowUp',\n ARROW_RIGHT: 'ArrowRight',\n ARROW_DOWN: 'ArrowDown',\n};\n"]}
|
@@ -12,6 +12,7 @@ export const styles = css `
|
|
12
12
|
:host {
|
13
13
|
width: 100%;
|
14
14
|
box-sizing: border-box;
|
15
|
+
font-size: 14px;
|
15
16
|
}
|
16
17
|
|
17
18
|
.content-editable-wrapper {
|
@@ -47,21 +48,30 @@ export const styles = css `
|
|
47
48
|
border-color: #e5434d;
|
48
49
|
}
|
49
50
|
|
51
|
+
.read-only {
|
52
|
+
cursor: not-allowed;
|
53
|
+
}
|
54
|
+
|
50
55
|
.chips {
|
56
|
+
display: inline;
|
51
57
|
background: #e5e9eb;
|
52
58
|
color: #000;
|
53
59
|
border-radius: 4px;
|
54
60
|
padding: 6px;
|
61
|
+
height: 24px;
|
62
|
+
line-height: 10px;
|
55
63
|
margin-left: 3px;
|
56
|
-
display: inline;
|
57
64
|
letter-spacing: 0.2px;
|
58
65
|
}
|
59
66
|
|
60
67
|
.text-area {
|
61
68
|
height: 120px;
|
62
|
-
white-space: pre-wrap;
|
63
69
|
overflow: scroll;
|
64
|
-
line-height:
|
70
|
+
line-height: 26px;
|
71
|
+
}
|
72
|
+
|
73
|
+
.text-area .chips {
|
74
|
+
padding: 4px 8px;
|
65
75
|
}
|
66
76
|
|
67
77
|
.chip-error {
|
@@ -72,6 +82,7 @@ export const styles = css `
|
|
72
82
|
background-color: #ffffff;
|
73
83
|
border: 1px solid #c7ced4;
|
74
84
|
overflow: auto;
|
85
|
+
max-height: 150px;
|
75
86
|
}
|
76
87
|
|
77
88
|
label {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-content-editor.css.js","sourceRoot":"","sources":["../../../src/nile-content-editor/nile-content-editor.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
1
|
+
{"version":3,"file":"nile-content-editor.css.js","sourceRoot":"","sources":["../../../src/nile-content-editor/nile-content-editor.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit-element';\n\n/**\n * AttributeExpression CSS\n */\nexport const styles = css`\n :host {\n width: 100%;\n box-sizing: border-box;\n font-size: 14px;\n }\n\n .content-editable-wrapper {\n position: relative;\n width: 100%;\n box-sizing: border-box;\n }\n\n .dropdown-position {\n position: relative;\n bottom: 60px;\n }\n .content-editable-input {\n box-sizing: border-box;\n width: 100%;\n padding: 9px;\n border: 1px solid #c7ced4;\n border-radius: 4px;\n overflow-x: auto;\n overflow-anchor: none;\n scrollbar-width: none;\n -ms-overflow-style: none;\n cursor: text;\n white-space: nowrap;\n background-color: #ffffff;\n height: 38px;\n }\n .content-editable-input:focus {\n outline: none;\n }\n\n .error {\n border-color: #e5434d;\n }\n\n .read-only {\n cursor: not-allowed;\n }\n\n .chips {\n display: inline;\n background: #e5e9eb;\n color: #000;\n border-radius: 4px;\n padding: 6px;\n height: 24px;\n line-height: 10px;\n margin-left: 3px;\n letter-spacing: 0.2px;\n }\n\n .text-area {\n height: 120px;\n overflow: scroll;\n line-height: 26px;\n }\n\n .text-area .chips {\n padding: 4px 8px;\n }\n\n .chip-error {\n background: #f3a5aa;\n }\n .nile-options-container {\n box-sizing: border-box;\n background-color: #ffffff;\n border: 1px solid #c7ced4;\n overflow: auto;\n max-height: 150px;\n }\n\n label {\n display: inline-block;\n margin-bottom: 6px;\n font-family: 'colfax-medium';\n }\n\n .asterik {\n color: #e5434d;\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -23,25 +23,36 @@ export declare class NileContentEditor extends NileElement {
|
|
23
23
|
*/
|
24
24
|
value: string;
|
25
25
|
options: Array<any>;
|
26
|
+
filteredOptions: Array<any>;
|
26
27
|
showLabel: boolean;
|
27
28
|
labelText: string;
|
28
29
|
type: string;
|
29
30
|
required: boolean;
|
30
|
-
|
31
|
+
contentEditor: HTMLInputElement;
|
31
32
|
autoOptions: HTMLInputElement;
|
32
|
-
|
33
|
+
openDropdown: boolean;
|
34
|
+
tagIdentifier: string;
|
35
|
+
filteredValue: string;
|
33
36
|
helpText: string;
|
37
|
+
readonly: boolean;
|
34
38
|
errorMessage: string;
|
39
|
+
error: boolean;
|
35
40
|
static styles: CSSResultGroup;
|
36
41
|
connectedCallback(): void;
|
42
|
+
setInitialValues(): void;
|
43
|
+
addOpenListeners(): void;
|
44
|
+
removeOpenListeners(): void;
|
45
|
+
toggleDropdown(value: boolean): void;
|
46
|
+
handleOutsideClick(event: Event): void;
|
37
47
|
handleTypeChange(): void;
|
38
48
|
disconnectedCallback(): void;
|
39
|
-
|
49
|
+
handlePaste(event: ClipboardEvent): void;
|
40
50
|
private handlekeyDown;
|
51
|
+
filterOptions(): void;
|
41
52
|
generateValuesFromHTMLTags(string: any): string;
|
42
53
|
generateHTMLTagsWithValues(string: any): string;
|
43
54
|
emitInputChange(): void;
|
44
|
-
|
55
|
+
insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag: Node): void;
|
45
56
|
handleOptions(option: any): void;
|
46
57
|
renderAutoOptions(): TemplateResult;
|
47
58
|
render(): TemplateResult;
|
@@ -11,6 +11,8 @@ import { styles } from './nile-content-editor.css';
|
|
11
11
|
import { classMap } from 'lit/directives/class-map.js';
|
12
12
|
import NileElement from '../internal/nile-element';
|
13
13
|
import { watch } from '../internal/watch';
|
14
|
+
import { KeyCode } from '../internal/enum';
|
15
|
+
import { live } from 'lit/directives/live.js';
|
14
16
|
/**
|
15
17
|
* Nile icon component.
|
16
18
|
*
|
@@ -33,48 +35,87 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
33
35
|
this.type = 'text|text-area';
|
34
36
|
this.required = true;
|
35
37
|
this.openDropdown = false;
|
38
|
+
this.tagIdentifier = '$';
|
39
|
+
this.filteredValue = '';
|
36
40
|
this.helpText = '';
|
41
|
+
this.readonly = false;
|
37
42
|
this.errorMessage = '';
|
38
|
-
this.
|
39
|
-
const range = document.createRange();
|
40
|
-
const selection = window.getSelection();
|
41
|
-
range.setStart(this.input, this.input.childNodes.length);
|
42
|
-
range.collapse(true);
|
43
|
-
selection?.removeAllRanges();
|
44
|
-
selection?.addRange(range);
|
45
|
-
this.input.focus();
|
46
|
-
};
|
43
|
+
this.error = false;
|
47
44
|
}
|
48
45
|
connectedCallback() {
|
46
|
+
this.handleOutsideClick = this.handleOutsideClick.bind(this);
|
49
47
|
super.connectedCallback();
|
50
48
|
this.emit('nile-init');
|
51
|
-
this.
|
52
|
-
|
53
|
-
|
49
|
+
this.addOpenListeners();
|
50
|
+
this.setInitialValues();
|
51
|
+
}
|
52
|
+
setInitialValues() {
|
53
|
+
this.updateComplete.then(res => {
|
54
|
+
if (res && !!this.value)
|
55
|
+
this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(this.value);
|
54
56
|
});
|
55
57
|
}
|
58
|
+
addOpenListeners() {
|
59
|
+
window.addEventListener('click', this.handleOutsideClick);
|
60
|
+
}
|
61
|
+
removeOpenListeners() {
|
62
|
+
window.removeEventListener('click', this.handleOutsideClick);
|
63
|
+
}
|
64
|
+
toggleDropdown(value) {
|
65
|
+
this.openDropdown = value;
|
66
|
+
}
|
67
|
+
handleOutsideClick(event) {
|
68
|
+
if (event && event.target) {
|
69
|
+
this.toggleDropdown(false);
|
70
|
+
}
|
71
|
+
}
|
56
72
|
handleTypeChange() {
|
57
|
-
this.
|
73
|
+
this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(this.value);
|
58
74
|
}
|
59
75
|
disconnectedCallback() {
|
60
76
|
super.disconnectedCallback();
|
77
|
+
this.removeOpenListeners();
|
61
78
|
this.emit('nile-destroy');
|
62
79
|
}
|
63
|
-
|
64
|
-
|
80
|
+
handlePaste(event) {
|
81
|
+
event.preventDefault();
|
82
|
+
if (event.clipboardData) {
|
83
|
+
let text = event.clipboardData.getData('text/plain');
|
84
|
+
document.execCommand('insertText', false, text);
|
85
|
+
}
|
86
|
+
this.emitInputChange();
|
65
87
|
}
|
66
88
|
handlekeyDown(event) {
|
67
|
-
if (event.code ===
|
89
|
+
if (event.code === KeyCode.ENTER && this.type === 'text') {
|
90
|
+
event.preventDefault();
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
if (event.code === KeyCode.ESCAPE) {
|
68
94
|
event.preventDefault();
|
95
|
+
this.toggleDropdown(false);
|
96
|
+
return;
|
69
97
|
}
|
70
98
|
setTimeout(() => {
|
71
|
-
const value = this.
|
99
|
+
const value = this.contentEditor.innerText;
|
72
100
|
this.emitInputChange();
|
73
|
-
if (value.includes(
|
74
|
-
this.
|
101
|
+
if (value.includes(this.tagIdentifier)) {
|
102
|
+
this.toggleDropdown(true);
|
103
|
+
this.filterOptions();
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
this.toggleDropdown(false);
|
75
107
|
}
|
76
108
|
});
|
77
109
|
}
|
110
|
+
filterOptions() {
|
111
|
+
this.filteredOptions = this.options;
|
112
|
+
if (!!this.options.length && !!this.filteredValue) {
|
113
|
+
this.filteredOptions = this.options.filter(item => item.startsWith(this.filteredValue));
|
114
|
+
}
|
115
|
+
else {
|
116
|
+
this.filteredOptions = this.options;
|
117
|
+
}
|
118
|
+
}
|
78
119
|
generateValuesFromHTMLTags(string) {
|
79
120
|
var pattern = /<span class="chips(?: chip-error)?" contenteditable="false">(.*?)<\/span>/g;
|
80
121
|
var result = string.replace(pattern, (match, option) => {
|
@@ -94,34 +135,40 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
94
135
|
return result;
|
95
136
|
}
|
96
137
|
emitInputChange() {
|
97
|
-
|
98
|
-
|
99
|
-
|
138
|
+
if (this.contentEditor) {
|
139
|
+
let fieldValue = this.contentEditor.innerHTML;
|
140
|
+
if (this.contentEditor.innerText !== '') {
|
141
|
+
fieldValue = this.generateValuesFromHTMLTags(fieldValue);
|
142
|
+
}
|
143
|
+
fieldValue = fieldValue.replace(/ /g, ' ');
|
144
|
+
fieldValue = fieldValue === '<br>' ? '' : fieldValue?.trim();
|
145
|
+
this.emit('nile-change', {
|
146
|
+
value: this.generateValuesFromHTMLTags(fieldValue),
|
147
|
+
});
|
100
148
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
149
|
+
}
|
150
|
+
insertNodes(parentNode, childNodes, autoOptionsTag) {
|
151
|
+
Array.from(childNodes).map((node, index) => {
|
152
|
+
if (node.hasChildNodes()) {
|
153
|
+
this.insertNodes(node, node.childNodes, autoOptionsTag);
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
if (node.nodeValue?.includes(this.tagIdentifier)) {
|
157
|
+
parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(this.tagIdentifier + this.filteredValue, '');
|
158
|
+
parentNode.childNodes[index].after(autoOptionsTag);
|
159
|
+
}
|
160
|
+
}
|
105
161
|
});
|
106
162
|
}
|
107
163
|
handleOptions(option) {
|
108
|
-
this.
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
this.input.lastElementChild.lastChild.previousSibling.nodeValue.replace('$', '');
|
117
|
-
}
|
118
|
-
else {
|
119
|
-
this.input.insertAdjacentHTML('beforeend', autoOptionsTag);
|
120
|
-
if (this.input.lastChild?.previousSibling) {
|
121
|
-
this.input.lastChild.previousSibling.nodeValue =
|
122
|
-
this.input.lastChild.previousSibling.nodeValue.replace('$', '');
|
123
|
-
}
|
124
|
-
}
|
164
|
+
this.toggleDropdown(false);
|
165
|
+
let autoOptionsTag = document.createElement('span');
|
166
|
+
autoOptionsTag.setAttribute('class', 'chips');
|
167
|
+
autoOptionsTag.setAttribute('contentEditable', 'false');
|
168
|
+
autoOptionsTag.innerText = option;
|
169
|
+
this.insertNodes(this.contentEditor, this.contentEditor.childNodes, autoOptionsTag);
|
170
|
+
this.filteredOptions = this.options;
|
171
|
+
this.filteredValue = '';
|
125
172
|
this.emitInputChange();
|
126
173
|
}
|
127
174
|
renderAutoOptions() {
|
@@ -129,10 +176,10 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
129
176
|
class="${classMap({
|
130
177
|
'nile-options-container': true,
|
131
178
|
'dropdown-position': this.type === 'text-area',
|
132
|
-
})}
|
179
|
+
})}"
|
133
180
|
>
|
134
|
-
${this.
|
135
|
-
this.
|
181
|
+
${this.filteredOptions &&
|
182
|
+
this.filteredOptions.map((option) => {
|
136
183
|
return html ` <nile-option
|
137
184
|
.value="${option}"
|
138
185
|
@click="${(event) => {
|
@@ -145,11 +192,13 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
145
192
|
}
|
146
193
|
render() {
|
147
194
|
const hasHelpText = this.helpText ? true : false;
|
195
|
+
const hasError = !!this.error;
|
148
196
|
const hasErrorMessage = !!this.errorMessage;
|
197
|
+
const readonly = !!this.readonly;
|
149
198
|
const type = this.type;
|
150
199
|
return html `
|
151
200
|
<nile-popup
|
152
|
-
.active="${this.openDropdown}"
|
201
|
+
.active="${live(this.openDropdown)}"
|
153
202
|
sync="width"
|
154
203
|
placement="bottom"
|
155
204
|
class=${classMap({
|
@@ -162,17 +211,19 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
162
211
|
${this.showLabel && this.labelText
|
163
212
|
? html `<label class="ods-label">${this.labelText} </label> ${this
|
164
213
|
.required
|
165
|
-
? html `<
|
214
|
+
? html `<sapn class="asterik">*</span>`
|
166
215
|
: ''}`
|
167
216
|
: ''}
|
168
217
|
<div
|
169
|
-
contenteditable="
|
218
|
+
contenteditable="${!readonly}"
|
170
219
|
class=${classMap({
|
171
220
|
'content-editable-input': true,
|
172
|
-
error: hasErrorMessage,
|
221
|
+
error: hasError || hasErrorMessage,
|
222
|
+
'read-only': readonly,
|
173
223
|
'text-area': type === 'text-area' ? true : false,
|
174
224
|
})}
|
175
225
|
@keydown=${this.handlekeyDown}
|
226
|
+
@paste=${this.handlePaste}
|
176
227
|
></div>
|
177
228
|
${hasHelpText
|
178
229
|
? html `
|
@@ -200,6 +251,9 @@ __decorate([
|
|
200
251
|
__decorate([
|
201
252
|
property()
|
202
253
|
], NileContentEditor.prototype, "options", void 0);
|
254
|
+
__decorate([
|
255
|
+
property()
|
256
|
+
], NileContentEditor.prototype, "filteredOptions", void 0);
|
203
257
|
__decorate([
|
204
258
|
property()
|
205
259
|
], NileContentEditor.prototype, "showLabel", void 0);
|
@@ -214,7 +268,7 @@ __decorate([
|
|
214
268
|
], NileContentEditor.prototype, "required", void 0);
|
215
269
|
__decorate([
|
216
270
|
query('.content-editable-input')
|
217
|
-
], NileContentEditor.prototype, "
|
271
|
+
], NileContentEditor.prototype, "contentEditor", void 0);
|
218
272
|
__decorate([
|
219
273
|
query('.nile-options-container')
|
220
274
|
], NileContentEditor.prototype, "autoOptions", void 0);
|
@@ -224,9 +278,15 @@ __decorate([
|
|
224
278
|
__decorate([
|
225
279
|
property({ attribute: 'help-text' })
|
226
280
|
], NileContentEditor.prototype, "helpText", void 0);
|
281
|
+
__decorate([
|
282
|
+
property({ attribute: 'readonly' })
|
283
|
+
], NileContentEditor.prototype, "readonly", void 0);
|
227
284
|
__decorate([
|
228
285
|
property({ attribute: 'error-message' })
|
229
286
|
], NileContentEditor.prototype, "errorMessage", void 0);
|
287
|
+
__decorate([
|
288
|
+
property({ attribute: 'error' })
|
289
|
+
], NileContentEditor.prototype, "error", void 0);
|
230
290
|
__decorate([
|
231
291
|
watch('type', { waitUntilFirstUpdate: true })
|
232
292
|
], NileContentEditor.prototype, "handleTypeChange", null);
|