@aquera/nile-elements 0.1.50-beta-1.0 → 0.1.50
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/README.md +4 -4
- package/demo/index.html +33 -150
- package/dist/axe.min-2720cd56.esm.js +1 -0
- package/dist/axe.min-69d47269.cjs.js +2 -0
- package/dist/axe.min-69d47269.cjs.js.map +1 -0
- package/dist/{fixture-372df3b0.esm.js → fixture-e7023246.esm.js} +1 -1
- package/dist/{fixture-161dee0b.cjs.js → fixture-fe6c932e.cjs.js} +2 -2
- package/dist/fixture-fe6c932e.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +10339 -0
- package/dist/internal/form.cjs.js +1 -1
- package/dist/internal/form.cjs.js.map +1 -1
- package/dist/internal/form.esm.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
- package/dist/nile-auto-complete/index.cjs.js +1 -1
- package/dist/nile-auto-complete/index.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js +17 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.esm.js +29 -8
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.test.esm.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js +1 -1
- package/dist/nile-button/nile-button.test.esm.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-card/nile-card.test.cjs.js +1 -1
- package/dist/nile-card/nile-card.test.esm.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
- package/dist/nile-chip/nile-chip.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.esm.js +1 -0
- package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.test.esm.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.test.esm.js +1 -1
- package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
- package/dist/nile-icon/nile-icon.test.esm.js +1 -1
- package/dist/nile-input/nile-input.test.cjs.js +1 -1
- package/dist/nile-input/nile-input.test.esm.js +1 -1
- package/dist/nile-link/nile-link.test.cjs.js +1 -1
- package/dist/nile-link/nile-link.test.esm.js +1 -1
- package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
- package/dist/nile-loader/nile-loader.test.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.cjs.js +1 -1
- package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.esm.js +1 -1
- package/dist/nile-option/nile-option.esm.js +2 -2
- package/dist/nile-pagination/nile-pagination.cjs.js +1 -1
- package/dist/nile-pagination/nile-pagination.cjs.js.map +1 -1
- package/dist/nile-pagination/nile-pagination.css.cjs.js +1 -1
- package/dist/nile-pagination/nile-pagination.css.cjs.js.map +1 -1
- package/dist/nile-pagination/nile-pagination.css.esm.js +152 -39
- package/dist/nile-pagination/nile-pagination.esm.js +118 -29
- package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.test.esm.js +1 -1
- package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.test.esm.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
- package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.test.esm.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +2 -2
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.test.esm.js +2 -2
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/form.js +2 -2
- package/dist/src/internal/form.js.map +1 -1
- package/dist/src/nile-chip/nile-chip.js +1 -0
- package/dist/src/nile-chip/nile-chip.js.map +1 -1
- package/dist/src/nile-option/nile-option.css.js +1 -1
- package/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/dist/src/nile-option/nile-option.d.ts +1 -5
- package/dist/src/nile-option/nile-option.js +6 -21
- package/dist/src/nile-option/nile-option.js.map +1 -1
- package/dist/src/nile-pagination/nile-pagination.css.js +151 -38
- package/dist/src/nile-pagination/nile-pagination.css.js.map +1 -1
- package/dist/src/nile-pagination/nile-pagination.d.ts +3 -0
- package/dist/src/nile-pagination/nile-pagination.js +167 -40
- package/dist/src/nile-pagination/nile-pagination.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +2 -11
- package/dist/src/nile-select/nile-select.js +18 -37
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/rollup.config.js +27 -39
- package/src/index.ts +1 -3
- package/src/internal/form.ts +2 -2
- package/src/nile-chip/nile-chip.ts +1 -0
- package/src/nile-option/nile-option.css.ts +1 -1
- package/src/nile-option/nile-option.ts +3 -17
- package/src/nile-pagination/nile-pagination.css.ts +151 -38
- package/src/nile-pagination/nile-pagination.ts +188 -46
- package/src/nile-select/nile-select.ts +9 -35
- package/vscode-html-custom-data.json +3 -230
- package/dist/axe.min-2b379f29.cjs.js +0 -12
- package/dist/axe.min-2b379f29.cjs.js.map +0 -1
- package/dist/axe.min-c2cd8733.esm.js +0 -12
- package/dist/fixture-161dee0b.cjs.js.map +0 -1
- package/dist/nile-select/virtual-scroll-helper.cjs.js +0 -2
- package/dist/nile-select/virtual-scroll-helper.cjs.js.map +0 -1
- package/dist/nile-select/virtual-scroll-helper.esm.js +0 -38
- package/dist/nile-virtual-select/index.cjs.js +0 -2
- package/dist/nile-virtual-select/index.cjs.js.map +0 -1
- package/dist/nile-virtual-select/index.esm.js +0 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +0 -2
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +0 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +0 -2
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +0 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +0 -467
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +0 -227
- package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js +0 -2
- package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js.map +0 -1
- package/dist/nile-virtual-select/nile-virtual-select.test.esm.js +0 -49
- package/dist/nile-virtual-select/renderer.cjs.js +0 -2
- package/dist/nile-virtual-select/renderer.cjs.js.map +0 -1
- package/dist/nile-virtual-select/renderer.esm.js +0 -18
- package/dist/nile-virtual-select/search-manager.cjs.js +0 -2
- package/dist/nile-virtual-select/search-manager.cjs.js.map +0 -1
- package/dist/nile-virtual-select/search-manager.esm.js +0 -1
- package/dist/nile-virtual-select/selection-manager.cjs.js +0 -2
- package/dist/nile-virtual-select/selection-manager.cjs.js.map +0 -1
- package/dist/nile-virtual-select/selection-manager.esm.js +0 -1
- package/dist/nile-virtual-select/types.cjs.js +0 -2
- package/dist/nile-virtual-select/types.cjs.js.map +0 -1
- package/dist/nile-virtual-select/types.esm.js +0 -1
- package/dist/src/nile-select/virtual-scroll-helper.d.ts +0 -9
- package/dist/src/nile-select/virtual-scroll-helper.js +0 -51
- package/dist/src/nile-select/virtual-scroll-helper.js.map +0 -1
- package/dist/src/nile-virtual-select/index.d.ts +0 -1
- package/dist/src/nile-virtual-select/index.js +0 -2
- package/dist/src/nile-virtual-select/index.js.map +0 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.d.ts +0 -12
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +0 -479
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +0 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +0 -263
- package/dist/src/nile-virtual-select/nile-virtual-select.js +0 -1183
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +0 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.test.d.ts +0 -7
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js +0 -341
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +0 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +0 -11
- package/dist/src/nile-virtual-select/renderer.js +0 -51
- package/dist/src/nile-virtual-select/renderer.js.map +0 -1
- package/dist/src/nile-virtual-select/search-manager.d.ts +0 -12
- package/dist/src/nile-virtual-select/search-manager.js +0 -40
- package/dist/src/nile-virtual-select/search-manager.js.map +0 -1
- package/dist/src/nile-virtual-select/selection-manager.d.ts +0 -12
- package/dist/src/nile-virtual-select/selection-manager.js +0 -64
- package/dist/src/nile-virtual-select/selection-manager.js.map +0 -1
- package/dist/src/nile-virtual-select/types.d.ts +0 -50
- package/dist/src/nile-virtual-select/types.js +0 -8
- package/dist/src/nile-virtual-select/types.js.map +0 -1
- package/dist/virtualize-a4a40d96.esm.js +0 -22
- package/dist/virtualize-b6a2fbe0.cjs.js +0 -18
- package/dist/virtualize-b6a2fbe0.cjs.js.map +0 -1
- package/src/nile-select/virtual-scroll-helper.ts +0 -56
- package/src/nile-virtual-select/index.ts +0 -1
- package/src/nile-virtual-select/nile-virtual-select.css.ts +0 -481
- package/src/nile-virtual-select/nile-virtual-select.test.ts +0 -414
- package/src/nile-virtual-select/nile-virtual-select.ts +0 -1268
- package/src/nile-virtual-select/renderer.ts +0 -73
- package/src/nile-virtual-select/search-manager.ts +0 -50
- package/src/nile-virtual-select/selection-manager.ts +0 -75
- package/src/nile-virtual-select/types.ts +0 -54
@@ -1,2 +1,2 @@
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["../fixture-161dee0b.cjs.js","lit/static-html.js","lit/html.js","lit/directive-helpers.js","lit","lit/directives/unsafe-html.js","./nile-textarea.cjs.js","tslib","lit/decorators.js","./nile-textarea.css.cjs.js","lit/directives/class-map.js","../internal/default-value.cjs.js","../internal/slot.cjs.js","lit/directives/if-defined.js","lit/directives/live.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js"],function(_export,_context){"use strict";var e,t,a,i,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,_templateObject7,_templateObject8,_templateObject9,_templateObject10;function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function _regeneratorRuntime(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function define(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==_typeof(h)&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function value(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator["return"]&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(_typeof(e)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function reset(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},"catch":function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}return{setters:[function(_fixture002CjsJs){e=_fixture002CjsJs.f;t=_fixture002CjsJs.a;a=_fixture002CjsJs.o;},function(_litStaticHtmlJs){i=_litStaticHtmlJs.html;},function(_litHtmlJs){},function(_litDirectiveHelpersJs){},function(_lit){},function(_litDirectivesUnsafeHtmlJs){},function(_nileTextareaCjsJs){},function(_tslib){},function(_litDecoratorsJs){},function(_nileTextareaCssCjsJs){},function(_litDirectivesClassMapJs){},function(_internalDefaultValueCjsJs){},function(_internalSlotCjsJs){},function(_litDirectivesIfDefinedJs){},function(_litDirectivesLiveJs){},function(_internalWatchCjsJs){},function(_internalNileElementCjsJs){}],execute:function execute(){describe("<nile-textarea>",function(){it("should render the default properties correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var a;return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return e(i(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:a=_context2.sent;t(a.value).to.equal(""),t(a.size).to.equal("medium"),t(a.filled).to.be["false"],t(a.disabled).to.be["false"],t(a.readonly).to.be["false"],t(a.required).to.be["false"];case 4:case"end":return _context2.stop();}},_callee);}))),it("should reflect properties to attributes",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){var a;return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return e(i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["<nile-textarea disabled readonly required></nile-textarea>"]))));case 2:a=_context3.sent;t(a.getAttribute("disabled")).to.equal(""),t(a.getAttribute("readonly")).to.equal(""),t(a.getAttribute("required")).to.equal("");case 4:case"end":return _context3.stop();}},_callee2);}))),it("should emit events correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var _r$shadowRoot$querySe,_r$shadowRoot;var r,s,_yield$a,n,_yield$a2,l,_yield$a3,o,_yield$a4,c;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return e(i(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:r=_context4.sent;s=(_r$shadowRoot$querySe=(_r$shadowRoot=r.shadowRoot)===null||_r$shadowRoot===void 0?void 0:_r$shadowRoot.querySelector("textarea"))!==null&&_r$shadowRoot$querySe!==void 0?_r$shadowRoot$querySe:{};setTimeout(function(){return s.dispatchEvent(new Event("focus"));});_context4.next=7;return a(r,"nile-focus");case 7:_yield$a=_context4.sent;n=_yield$a.detail;t(n.value).to.equal(""),s.value="test",setTimeout(function(){return s.dispatchEvent(new Event("input"));});_context4.next=12;return a(r,"nile-input");case 12:_yield$a2=_context4.sent;l=_yield$a2.detail;t(l.value).to.equal("test"),setTimeout(function(){return s.dispatchEvent(new Event("change"));});_context4.next=17;return a(r,"nile-change");case 17:_yield$a3=_context4.sent;o=_yield$a3.detail;t(o.value).to.equal("test"),setTimeout(function(){return s.dispatchEvent(new Event("blur"));});_context4.next=22;return a(r,"nile-blur");case 22:_yield$a4=_context4.sent;c=_yield$a4.detail;t(c.value).to.equal("test");case 25:case"end":return _context4.stop();}},_callee3);}))),it("should update value property on input event",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(){var _a$shadowRoot$querySe,_a$shadowRoot;var a,r;return _regeneratorRuntime().wrap(function _callee4$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:_context5.next=2;return e(i(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:a=_context5.sent;r=(_a$shadowRoot$querySe=(_a$shadowRoot=a.shadowRoot)===null||_a$shadowRoot===void 0?void 0:_a$shadowRoot.querySelector("textarea"))!==null&&_a$shadowRoot$querySe!==void 0?_a$shadowRoot$querySe:{};r.value="new value",r.dispatchEvent(new Event("input")),t(a.value).to.equal("new value");case 5:case"end":return _context5.stop();}},_callee4);}))),it('should handle the "rows" property correctly',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(){var _a$shadowRoot$querySe2,_a$shadowRoot2;var a,r;return _regeneratorRuntime().wrap(function _callee5$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.next=2;return e(i(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["<nile-textarea rows=\"10\"></nile-textarea>"]))));case 2:a=_context6.sent;r=(_a$shadowRoot$querySe2=(_a$shadowRoot2=a.shadowRoot)===null||_a$shadowRoot2===void 0?void 0:_a$shadowRoot2.querySelector("textarea"))!==null&&_a$shadowRoot$querySe2!==void 0?_a$shadowRoot$querySe2:{};t(r.rows).to.equal(10);case 5:case"end":return _context6.stop();}},_callee5);}))),it('should handle the "resize" property correctly',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(){var _a$shadowRoot$querySe3,_a$shadowRoot3;var a,r;return _regeneratorRuntime().wrap(function _callee6$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:_context7.next=2;return e(i(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["<nile-textarea resize=\"none\"></nile-textarea>"]))));case 2:a=_context7.sent;r=(_a$shadowRoot$querySe3=(_a$shadowRoot3=a.shadowRoot)===null||_a$shadowRoot3===void 0?void 0:_a$shadowRoot3.querySelector(".textarea"))!==null&&_a$shadowRoot$querySe3!==void 0?_a$shadowRoot$querySe3:{};t(r.classList.contains("textarea--resize-none")).to.be["true"];case 5:case"end":return _context7.stop();}},_callee6);}))),it("should select all text when select() is called",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(){var _a$shadowRoot$querySe4,_a$shadowRoot4;var a,r;return _regeneratorRuntime().wrap(function _callee7$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:_context8.next=2;return e(i(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["<nile-textarea value=\"test value\"></nile-textarea>"]))));case 2:a=_context8.sent;a.select();r=(_a$shadowRoot$querySe4=(_a$shadowRoot4=a.shadowRoot)===null||_a$shadowRoot4===void 0?void 0:_a$shadowRoot4.querySelector("textarea"))!==null&&_a$shadowRoot$querySe4!==void 0?_a$shadowRoot$querySe4:{};t(r.selectionStart).to.equal(0),t(r.selectionEnd).to.equal(a.value.length);case 6:case"end":return _context8.stop();}},_callee7);}))),it("should set selection range correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(){var _a$shadowRoot$querySe5,_a$shadowRoot5;var a,r;return _regeneratorRuntime().wrap(function _callee8$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:_context9.next=2;return e(i(_templateObject8||(_templateObject8=_taggedTemplateLiteral(["<nile-textarea value=\"test value\"></nile-textarea>"]))));case 2:a=_context9.sent;a.setSelectionRange(0,4);r=(_a$shadowRoot$querySe5=(_a$shadowRoot5=a.shadowRoot)===null||_a$shadowRoot5===void 0?void 0:_a$shadowRoot5.querySelector("textarea"))!==null&&_a$shadowRoot$querySe5!==void 0?_a$shadowRoot$querySe5:{};t(r.selectionStart).to.equal(0),t(r.selectionEnd).to.equal(4);case 6:case"end":return _context9.stop();}},_callee8);}))),it("should handle non-printable characters",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(){var a,r;return _regeneratorRuntime().wrap(function _callee9$(_context10){while(1)switch(_context10.prev=_context10.next){case 0:_context10.next=2;return e(i(_templateObject9||(_templateObject9=_taggedTemplateLiteral(["<nile-textarea checkNonPrintableChar></nile-textarea>"]))));case 2:a=_context10.sent;a.value="test乇乂丅尺卂";a.handleValueChange();_context10.next=7;return a.updateComplete;case 7:t(a.hasPrintableCharacters).to.be["true"];r=String("乇乂丅尺卂").split("").some(function(e){return-1!=a.markedValue.indexOf(e);});t(r).to.be["true"];case 10:case"end":return _context10.stop();}},_callee9);}))),it("should remove non-printable characters correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(){var a;return _regeneratorRuntime().wrap(function _callee10$(_context11){while(1)switch(_context11.prev=_context11.next){case 0:_context11.next=2;return e(i(_templateObject10||(_templateObject10=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:a=_context11.sent;a.value="test乇乂丅尺卂",a.removeAllNonPrintableCharacters(),t(a.value).to.equal("test");case 4:case"end":return _context11.stop();}},_callee10);})));});}};});
|
1
|
+
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["../fixture-fe6c932e.cjs.js","lit/static-html.js","lit/html.js","lit/directive-helpers.js","lit","lit/directives/unsafe-html.js","./nile-textarea.cjs.js","tslib","lit/decorators.js","./nile-textarea.css.cjs.js","lit/directives/class-map.js","../internal/default-value.cjs.js","../internal/slot.cjs.js","lit/directives/if-defined.js","lit/directives/live.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js"],function(_export,_context){"use strict";var e,t,a,i,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,_templateObject7,_templateObject8,_templateObject9,_templateObject10;function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function _regeneratorRuntime(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function define(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==_typeof(h)&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function value(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator["return"]&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(_typeof(e)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function reset(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},"catch":function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}return{setters:[function(_fixture001CjsJs){e=_fixture001CjsJs.f;t=_fixture001CjsJs.a;a=_fixture001CjsJs.o;},function(_litStaticHtmlJs){i=_litStaticHtmlJs.html;},function(_litHtmlJs){},function(_litDirectiveHelpersJs){},function(_lit){},function(_litDirectivesUnsafeHtmlJs){},function(_nileTextareaCjsJs){},function(_tslib){},function(_litDecoratorsJs){},function(_nileTextareaCssCjsJs){},function(_litDirectivesClassMapJs){},function(_internalDefaultValueCjsJs){},function(_internalSlotCjsJs){},function(_litDirectivesIfDefinedJs){},function(_litDirectivesLiveJs){},function(_internalWatchCjsJs){},function(_internalNileElementCjsJs){}],execute:function execute(){describe("<nile-textarea>",function(){it("should render the default properties correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var a;return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return e(i(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:a=_context2.sent;t(a.value).to.equal(""),t(a.size).to.equal("medium"),t(a.filled).to.be["false"],t(a.disabled).to.be["false"],t(a.readonly).to.be["false"],t(a.required).to.be["false"];case 4:case"end":return _context2.stop();}},_callee);}))),it("should reflect properties to attributes",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){var a;return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return e(i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["<nile-textarea disabled readonly required></nile-textarea>"]))));case 2:a=_context3.sent;t(a.getAttribute("disabled")).to.equal(""),t(a.getAttribute("readonly")).to.equal(""),t(a.getAttribute("required")).to.equal("");case 4:case"end":return _context3.stop();}},_callee2);}))),it("should emit events correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var _r$shadowRoot$querySe,_r$shadowRoot;var r,s,_yield$a,n,_yield$a2,l,_yield$a3,o,_yield$a4,c;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return e(i(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:r=_context4.sent;s=(_r$shadowRoot$querySe=(_r$shadowRoot=r.shadowRoot)===null||_r$shadowRoot===void 0?void 0:_r$shadowRoot.querySelector("textarea"))!==null&&_r$shadowRoot$querySe!==void 0?_r$shadowRoot$querySe:{};setTimeout(function(){return s.dispatchEvent(new Event("focus"));});_context4.next=7;return a(r,"nile-focus");case 7:_yield$a=_context4.sent;n=_yield$a.detail;t(n.value).to.equal(""),s.value="test",setTimeout(function(){return s.dispatchEvent(new Event("input"));});_context4.next=12;return a(r,"nile-input");case 12:_yield$a2=_context4.sent;l=_yield$a2.detail;t(l.value).to.equal("test"),setTimeout(function(){return s.dispatchEvent(new Event("change"));});_context4.next=17;return a(r,"nile-change");case 17:_yield$a3=_context4.sent;o=_yield$a3.detail;t(o.value).to.equal("test"),setTimeout(function(){return s.dispatchEvent(new Event("blur"));});_context4.next=22;return a(r,"nile-blur");case 22:_yield$a4=_context4.sent;c=_yield$a4.detail;t(c.value).to.equal("test");case 25:case"end":return _context4.stop();}},_callee3);}))),it("should update value property on input event",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(){var _a$shadowRoot$querySe,_a$shadowRoot;var a,r;return _regeneratorRuntime().wrap(function _callee4$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:_context5.next=2;return e(i(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:a=_context5.sent;r=(_a$shadowRoot$querySe=(_a$shadowRoot=a.shadowRoot)===null||_a$shadowRoot===void 0?void 0:_a$shadowRoot.querySelector("textarea"))!==null&&_a$shadowRoot$querySe!==void 0?_a$shadowRoot$querySe:{};r.value="new value",r.dispatchEvent(new Event("input")),t(a.value).to.equal("new value");case 5:case"end":return _context5.stop();}},_callee4);}))),it('should handle the "rows" property correctly',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(){var _a$shadowRoot$querySe2,_a$shadowRoot2;var a,r;return _regeneratorRuntime().wrap(function _callee5$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.next=2;return e(i(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["<nile-textarea rows=\"10\"></nile-textarea>"]))));case 2:a=_context6.sent;r=(_a$shadowRoot$querySe2=(_a$shadowRoot2=a.shadowRoot)===null||_a$shadowRoot2===void 0?void 0:_a$shadowRoot2.querySelector("textarea"))!==null&&_a$shadowRoot$querySe2!==void 0?_a$shadowRoot$querySe2:{};t(r.rows).to.equal(10);case 5:case"end":return _context6.stop();}},_callee5);}))),it('should handle the "resize" property correctly',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(){var _a$shadowRoot$querySe3,_a$shadowRoot3;var a,r;return _regeneratorRuntime().wrap(function _callee6$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:_context7.next=2;return e(i(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["<nile-textarea resize=\"none\"></nile-textarea>"]))));case 2:a=_context7.sent;r=(_a$shadowRoot$querySe3=(_a$shadowRoot3=a.shadowRoot)===null||_a$shadowRoot3===void 0?void 0:_a$shadowRoot3.querySelector(".textarea"))!==null&&_a$shadowRoot$querySe3!==void 0?_a$shadowRoot$querySe3:{};t(r.classList.contains("textarea--resize-none")).to.be["true"];case 5:case"end":return _context7.stop();}},_callee6);}))),it("should select all text when select() is called",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(){var _a$shadowRoot$querySe4,_a$shadowRoot4;var a,r;return _regeneratorRuntime().wrap(function _callee7$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:_context8.next=2;return e(i(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["<nile-textarea value=\"test value\"></nile-textarea>"]))));case 2:a=_context8.sent;a.select();r=(_a$shadowRoot$querySe4=(_a$shadowRoot4=a.shadowRoot)===null||_a$shadowRoot4===void 0?void 0:_a$shadowRoot4.querySelector("textarea"))!==null&&_a$shadowRoot$querySe4!==void 0?_a$shadowRoot$querySe4:{};t(r.selectionStart).to.equal(0),t(r.selectionEnd).to.equal(a.value.length);case 6:case"end":return _context8.stop();}},_callee7);}))),it("should set selection range correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(){var _a$shadowRoot$querySe5,_a$shadowRoot5;var a,r;return _regeneratorRuntime().wrap(function _callee8$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:_context9.next=2;return e(i(_templateObject8||(_templateObject8=_taggedTemplateLiteral(["<nile-textarea value=\"test value\"></nile-textarea>"]))));case 2:a=_context9.sent;a.setSelectionRange(0,4);r=(_a$shadowRoot$querySe5=(_a$shadowRoot5=a.shadowRoot)===null||_a$shadowRoot5===void 0?void 0:_a$shadowRoot5.querySelector("textarea"))!==null&&_a$shadowRoot$querySe5!==void 0?_a$shadowRoot$querySe5:{};t(r.selectionStart).to.equal(0),t(r.selectionEnd).to.equal(4);case 6:case"end":return _context9.stop();}},_callee8);}))),it("should handle non-printable characters",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(){var a,r;return _regeneratorRuntime().wrap(function _callee9$(_context10){while(1)switch(_context10.prev=_context10.next){case 0:_context10.next=2;return e(i(_templateObject9||(_templateObject9=_taggedTemplateLiteral(["<nile-textarea checkNonPrintableChar></nile-textarea>"]))));case 2:a=_context10.sent;a.value="test乇乂丅尺卂";a.handleValueChange();_context10.next=7;return a.updateComplete;case 7:t(a.hasPrintableCharacters).to.be["true"];r=String("乇乂丅尺卂").split("").some(function(e){return-1!=a.markedValue.indexOf(e);});t(r).to.be["true"];case 10:case"end":return _context10.stop();}},_callee9);}))),it("should remove non-printable characters correctly",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(){var a;return _regeneratorRuntime().wrap(function _callee10$(_context11){while(1)switch(_context11.prev=_context11.next){case 0:_context11.next=2;return e(i(_templateObject10||(_templateObject10=_taggedTemplateLiteral(["<nile-textarea></nile-textarea>"]))));case 2:a=_context11.sent;a.value="test乇乂丅尺卂",a.removeAllNonPrintableCharacters(),t(a.value).to.equal("test");case 4:case"end":return _context11.stop();}},_callee10);})));});}};});
|
2
2
|
//# sourceMappingURL=nile-textarea.test.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
import{f as e,a as t,o as a}from"../fixture-
|
1
|
+
import{f as e,a as t,o as a}from"../fixture-e7023246.esm.js";import{html as i}from"lit/static-html.js";import"lit/html.js";import"lit/directive-helpers.js";import"lit";import"lit/directives/unsafe-html.js";import"./nile-textarea.esm.js";import"tslib";import"lit/decorators.js";import"./nile-textarea.css.esm.js";import"lit/directives/class-map.js";import"../internal/default-value.esm.js";import"../internal/slot.esm.js";import"lit/directives/if-defined.js";import"lit/directives/live.js";import"../internal/watch.esm.js";import"../internal/nile-element.esm.js";describe("<nile-textarea>",(()=>{it("should render the default properties correctly",(async()=>{const a=await e(i`<nile-textarea></nile-textarea>`);t(a.value).to.equal(""),t(a.size).to.equal("medium"),t(a.filled).to.be.false,t(a.disabled).to.be.false,t(a.readonly).to.be.false,t(a.required).to.be.false})),it("should reflect properties to attributes",(async()=>{const a=await e(i`<nile-textarea disabled readonly required></nile-textarea>`);t(a.getAttribute("disabled")).to.equal(""),t(a.getAttribute("readonly")).to.equal(""),t(a.getAttribute("required")).to.equal("")})),it("should emit events correctly",(async()=>{const r=await e(i`<nile-textarea></nile-textarea>`),s=r.shadowRoot?.querySelector("textarea")??{};setTimeout((()=>s.dispatchEvent(new Event("focus"))));const{detail:n}=await a(r,"nile-focus");t(n.value).to.equal(""),s.value="test",setTimeout((()=>s.dispatchEvent(new Event("input"))));const{detail:l}=await a(r,"nile-input");t(l.value).to.equal("test"),setTimeout((()=>s.dispatchEvent(new Event("change"))));const{detail:o}=await a(r,"nile-change");t(o.value).to.equal("test"),setTimeout((()=>s.dispatchEvent(new Event("blur"))));const{detail:c}=await a(r,"nile-blur");t(c.value).to.equal("test")})),it("should update value property on input event",(async()=>{const a=await e(i`<nile-textarea></nile-textarea>`),r=a.shadowRoot?.querySelector("textarea")??{};r.value="new value",r.dispatchEvent(new Event("input")),t(a.value).to.equal("new value")})),it('should handle the "rows" property correctly',(async()=>{const a=await e(i`<nile-textarea rows="10"></nile-textarea>`),r=a.shadowRoot?.querySelector("textarea")??{};t(r.rows).to.equal(10)})),it('should handle the "resize" property correctly',(async()=>{const a=await e(i`<nile-textarea resize="none"></nile-textarea>`),r=a.shadowRoot?.querySelector(".textarea")??{};t(r.classList.contains("textarea--resize-none")).to.be.true})),it("should select all text when select() is called",(async()=>{const a=await e(i`<nile-textarea value="test value"></nile-textarea>`);a.select();const r=a.shadowRoot?.querySelector("textarea")??{};t(r.selectionStart).to.equal(0),t(r.selectionEnd).to.equal(a.value.length)})),it("should set selection range correctly",(async()=>{const a=await e(i`<nile-textarea value="test value"></nile-textarea>`);a.setSelectionRange(0,4);const r=a.shadowRoot?.querySelector("textarea")??{};t(r.selectionStart).to.equal(0),t(r.selectionEnd).to.equal(4)})),it("should handle non-printable characters",(async()=>{const a=await e(i`<nile-textarea checkNonPrintableChar></nile-textarea>`);a.value="test乇乂丅尺卂",a.handleValueChange(),await a.updateComplete,t(a.hasPrintableCharacters).to.be.true;const r=String("乇乂丅尺卂").split("").some((e=>-1!=a.markedValue.indexOf(e)));t(r).to.be.true})),it("should remove non-printable characters correctly",(async()=>{const a=await e(i`<nile-textarea></nile-textarea>`);a.value="test乇乂丅尺卂",a.removeAllNonPrintableCharacters(),t(a.value).to.equal("test")}))}));
|
package/dist/src/index.d.ts
CHANGED
@@ -16,7 +16,6 @@ export { NileLoader } from './nile-loader';
|
|
16
16
|
export { NileProgressBar } from './nile-progress-bar';
|
17
17
|
export { NileSpinner } from './nile-spinner';
|
18
18
|
export { NileSelect } from './nile-select';
|
19
|
-
export { NileVirtualSelect } from './nile-virtual-select';
|
20
19
|
export { NileOption } from './nile-option';
|
21
20
|
export { NileTag } from './nile-tag';
|
22
21
|
export { NileIconButton } from './nile-icon-button';
|
package/dist/src/index.js
CHANGED
@@ -16,7 +16,6 @@ export { NileLoader } from './nile-loader';
|
|
16
16
|
export { NileProgressBar } from './nile-progress-bar';
|
17
17
|
export { NileSpinner } from './nile-spinner';
|
18
18
|
export { NileSelect } from './nile-select';
|
19
|
-
export { NileVirtualSelect } from './nile-virtual-select';
|
20
19
|
export { NileOption } from './nile-option';
|
21
20
|
export { NileTag } from './nile-tag';
|
22
21
|
export { NileIconButton } from './nile-icon-button';
|
package/dist/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,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AAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { NileButton } from './nile-button';\nexport { NileHeading } from './nile-heading';\nexport { NileIcon } from './nile-icon';\nexport { NileInput } from './nile-input';\nexport { NileSidebar } from './nile-sidebar';\nexport { NileMenu } from './nile-menu';\nexport { NileBadge } from './nile-badge';\nexport { NileDrawer } from './nile-drawer';\nexport { NileCheckbox } from './nile-checkbox';\nexport { NileRadio } from './nile-radio';\nexport { NileRadioGroup } from './nile-radio-group';\nexport { NilePopup } from './nile-popup';\nexport { NileTooltip } from './nile-tooltip';\nexport { NileSlideToggle } from './nile-slide-toggle';\nexport { NileLoader } from './nile-loader';\nexport { NileProgressBar } from './nile-progress-bar';\nexport { NileSpinner } from './nile-spinner';\nexport { NileSelect } from './nile-select';\nexport { NileOption } from './nile-option';\nexport { NileTag } from './nile-tag';\nexport { NileIconButton } from './nile-icon-button';\nexport { NileMenuItem } from './nile-menu-item';\nexport { NileDropdown } from './nile-dropdown';\nexport { NileAutoComplete } from './nile-auto-complete';\nexport { NileChip } from './nile-chip';\nexport { NileTextarea } from './nile-textarea';\nexport { NileDatePicker } from './nile-date-picker';\nexport { NileErrorMessage } from './nile-error-message';\nexport { NileFormErrorMessage } from './nile-form-error-message';\nexport { NileFormHelpText } from './nile-form-help-text';\nexport { NileCalendar } from './nile-calendar';\nexport { NileLink } from './nile-link';\nexport { NileButtonToggleGroup } from './nile-button-toggle-group';\nexport { NileButtonToggle } from './nile-button-toggle';\nexport { NileSwitcher } from './nile-switcher';\nexport { NileContentEditor } from './nile-content-editor';\nexport { NileDialog } from './nile-dialog';\nexport { NileErrorNotification } from './nile-error-notification';\nexport { NileTabGroup } from './nile-tab-group';\nexport { NileTab } from './nile-tab';\nexport { NileTabPanel } from './nile-tab-panel';\nexport { NileCodeEditor } from './nile-code-editor';\nexport { NileToast } from './nile-toast';\nexport { NileBreadcrumb } from './nile-breadcrumb';\nexport { NileBreadcrumbItem } from './nile-breadcrumb-item';\nexport { NileFormGroup } from './nile-form-group';\nexport { NileCard } from './nile-card';\nexport { NilePopover } from './nile-popover';\nexport { NileButtonFilter } from './nile-button-filter';\nexport { NileCircularProgressbar } from './nile-circular-progressbar';\nexport { NileSidebarMenu } from './nile-sidebar-menu';\nexport { NileSidebarMenuItems } from './nile-sidebar-menu-items';\nexport { NileSidebarWrapper } from './nile-sidebar-wrapper';\nexport { NileTableCellItem } from './nile-table-cell-item';\nexport { NileTableRow } from './nile-table-row';\nexport { NileTableBody } from './nile-table-body';\nexport { NileTableHeaderItem } from './nile-table-header-item';\nexport { NileAvatar } from './nile-avatar';\nexport { NilePageHeader } from './nile-page-header';\nexport { NileEmptyState } from './nile-empty-state';\nexport { NileHero } from './nile-hero';\nexport { NileStepperItem } from './nile-stepper-item';\nexport { NileStepper } from './nile-stepper';\nexport { NileHeroHeader } from './nile-hero-header';\nexport { NileVerticalStepperItem } from './nile-vertical-stepper-item';\nexport { NileFormatDate } from './nile-format-date';\nexport { NileSplitPanel } from './nile-split-panel';\nexport { NileTree } from './nile-tree';\nexport { NileTreeItem } from './nile-tree-item';\nexport { NileListItem } from './nile-list-item';\nexport { NileList } from './nile-list';\nexport { NileAccordion } from './nile-accordion';\nexport { NileDivider } from './nile-divider';\nexport { NileTitle } from './nile-title';\nexport { NileSectionMessage } from './nile-section-message';\nexport { NileToolbar } from './nile-toolbar';\nexport { NileInlineEdit } from './nile-inline-edit';\nexport { NileTable } from './nile-table';\nexport { NileFilterChip } from './nile-filter-chip';\nexport {NilePagination } from './nile-pagination';"]}
|
@@ -50,13 +50,13 @@ export class FormControlController {
|
|
50
50
|
this.handleInteraction = this.handleInteraction.bind(this);
|
51
51
|
}
|
52
52
|
hostConnected() {
|
53
|
-
const form = this.options
|
53
|
+
const form = this.options.form(this.host);
|
54
54
|
if (form) {
|
55
55
|
this.attachForm(form);
|
56
56
|
}
|
57
57
|
// Listen for interactions
|
58
58
|
interactions.set(this.host, []);
|
59
|
-
this.options
|
59
|
+
this.options.assumeInteractionOn.forEach(event => {
|
60
60
|
this.host.addEventListener(event, this.handleInteraction);
|
61
61
|
});
|
62
62
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/internal/form.ts"],"names":[],"mappings":"AAIA,EAAE;AACF,gHAAgH;AAChH,oHAAoH;AACpH,uDAAuD;AACvD,EAAE;AACF,MAAM,CAAC,MAAM,eAAe,GAAmD,IAAI,OAAO,EAAE,CAAC;AAE7F,EAAE;AACF,mHAAmH;AACnH,sDAAsD;AACtD,EAAE;AACF,MAAM,uBAAuB,GAA4C,IAAI,OAAO,EAAE,CAAC;AAEvF,EAAE;AACF,gHAAgH;AAChH,6DAA6D;AAC7D,EAAE;AACF,MAAM,sBAAsB,GAA6B,IAAI,OAAO,EAAE,CAAC;AAEvE,EAAE;AACF,uHAAuH;AACvH,EAAE;AACF,MAAM,YAAY,GAAG,IAAI,OAAO,EAA6B,CAAC;AA0B9D,uGAAuG;AACvG,MAAM,OAAO,qBAAqB;IAKhC,YAAY,IAA8C,EAAE,OAA+C;QACzG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG;YACb,IAAI,EAAE,KAAK,CAAC,EAAE;gBACZ,oEAAoE;gBACpE,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;oBACpE,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAA2B,CAAC;oBAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,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AAG,kBAAkB;IACrB,KAAK,EAAE,KAAK;IACZ,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAkB,MAAM,CAAC,MAAM,CAAC;IACnE,GAAG,kBAAkB;IACrB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { NileFormControl } from '../internal/nile-element';\nimport type { NileButton } from '../nile-button';\n\n//\n// We store a WeakMap of forms + controls so we can keep references to all Nile controls within a given form. As\n// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is\n// added and removed from the form's set, respectively.\n//\nexport const formCollections: WeakMap<HTMLFormElement, Set<NileFormControl>> = new WeakMap();\n\n//\n// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and\n// restore the original behavior when they disconnect.\n//\nconst reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();\n\n//\n// We store a Set of controls that users have interacted with. This allows us to determine the interaction state\n// without littering the DOM with additional data attributes.\n//\nconst userInteractedControls: WeakSet<NileFormControl> = new WeakSet();\n\n//\n// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.\n//\nconst interactions = new WeakMap<NileFormControl, string[]>();\n\nexport interface FormControlControllerOptions {\n /** A function that returns the form containing the form control. */\n form: (input: NileFormControl) => HTMLFormElement | null;\n /** A function that returns the form control's name, which will be submitted with the form data. */\n name: (input: NileFormControl) => string;\n /** A function that returns the form control's current value. */\n value: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's default value. */\n defaultValue: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */\n disabled: (input: NileFormControl) => boolean;\n /**\n * A function that maps to the form control's reportValidity() function. When the control is invalid, this will\n * prevent submission and trigger the browser's constraint violation warning.\n */\n reportValidity: (input: NileFormControl) => boolean;\n /** A function that sets the form control's value */\n setValue: (input: NileFormControl, value: unknown) => void;\n /**\n * An array of event names to listen to. When all events in the list are emitted, the control will receive validity\n * states such as user-valid and user-invalid.user interacted validity states. */\n assumeInteractionOn: string[];\n}\n\n/** A reactive controller to allow form controls to participate in form submission, validation, etc. */\nexport class FormControlController implements ReactiveController {\n host: NileFormControl & ReactiveControllerHost;\n form?: HTMLFormElement | null;\n options: FormControlControllerOptions;\n\n constructor(host: ReactiveControllerHost & NileFormControl, options?: Partial<FormControlControllerOptions>) {\n (this.host = host).addController(this);\n this.options = {\n form: input => {\n // If there's a form attribute, use it to find the target form by id\n if (input.hasAttribute('form') && input.getAttribute('form') !== '') {\n const root = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute('form');\n\n if (formId) {\n return root.getElementById(formId) as HTMLFormElement;\n }\n }\n\n return input.closest('form');\n },\n name: input => input.name,\n value: input => input.value,\n defaultValue: input => input.defaultValue,\n disabled: input => input.disabled ?? false,\n reportValidity: input => (typeof input.reportValidity === 'function' ? input.reportValidity() : true),\n setValue: (input, value: string) => (input.value = value),\n assumeInteractionOn: ['nile-input'],\n ...options\n };\n this.handleFormData = this.handleFormData.bind(this);\n this.handleFormSubmit = this.handleFormSubmit.bind(this);\n this.handleFormReset = this.handleFormReset.bind(this);\n this.reportFormValidity = this.reportFormValidity.bind(this);\n this.handleInteraction = this.handleInteraction.bind(this);\n }\n\n hostConnected() {\n const form = this.options?.form(this.host);\n\n if (form) {\n this.attachForm(form);\n }\n\n // Listen for interactions\n interactions.set(this.host, []);\n this.options?.assumeInteractionOn.forEach(event => {\n this.host.addEventListener(event, this.handleInteraction);\n });\n }\n\n hostDisconnected() {\n this.detachForm();\n\n // Clean up interactions\n interactions.delete(this.host);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.removeEventListener(event, this.handleInteraction);\n });\n }\n\n hostUpdated() {\n const form = this.options.form(this.host);\n\n // Detach if the form no longer exists\n if (!form) {\n this.detachForm();\n }\n\n // If the form has changed, reattach it\n if (form && this.form !== form) {\n this.detachForm();\n this.attachForm(form);\n }\n\n if (this.host.hasUpdated) {\n this.setValidity(this.host.validity.valid);\n }\n }\n\n private attachForm(form?: HTMLFormElement) {\n if (form) {\n this.form = form;\n\n // Add this element to the form's collection\n if (formCollections.has(this.form)) {\n formCollections.get(this.form)!.add(this.host);\n } else {\n formCollections.set(this.form, new Set<NileFormControl>([this.host]));\n }\n\n this.form.addEventListener('formdata', this.handleFormData);\n this.form.addEventListener('submit', this.handleFormSubmit);\n this.form.addEventListener('reset', this.handleFormReset);\n\n // Overload the form's reportValidity() method so it looks at nile form controls\n if (!reportValidityOverloads.has(this.form)) {\n reportValidityOverloads.set(this.form, this.form.reportValidity);\n this.form.reportValidity = () => this.reportFormValidity();\n }\n } else {\n this.form = undefined;\n }\n }\n\n private detachForm() {\n if (this.form) {\n // Remove this element from the form's collection\n formCollections.get(this.form)?.delete(this.host);\n\n this.form.removeEventListener('formdata', this.handleFormData);\n this.form.removeEventListener('submit', this.handleFormSubmit);\n this.form.removeEventListener('reset', this.handleFormReset);\n\n // Remove the overload and restore the original method\n if (reportValidityOverloads.has(this.form)) {\n this.form.reportValidity = reportValidityOverloads.get(this.form)!;\n reportValidityOverloads.delete(this.form);\n }\n }\n\n this.form = undefined;\n }\n\n private handleFormData(event: FormDataEvent) {\n const disabled = this.options.disabled(this.host);\n const name = this.options.name(this.host);\n const value = this.options.value(this.host);\n\n // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by\n // injecting the name/value on a temporary button, so we can just skip them here.\n const isButton = this.host.tagName.toLowerCase() === 'nile-button';\n\n if (!disabled && !isButton && typeof name === 'string' && name.length > 0 && typeof value !== 'undefined') {\n if (Array.isArray(value)) {\n (value as unknown[]).forEach(val => {\n event.formData.append(name, (val as string | number | boolean).toString());\n });\n } else {\n event.formData.append(name, (value as string | number | boolean).toString());\n }\n }\n }\n\n private handleFormSubmit(event: Event) {\n const disabled = this.options.disabled(this.host);\n const reportValidity = this.options.reportValidity;\n\n // Update the interacted state for all controls when the form is submitted\n if (this.form && !this.form.noValidate) {\n formCollections.get(this.form)?.forEach(control => {\n this.setUserInteracted(control, true);\n });\n }\n\n if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleFormReset() {\n this.options.setValue(this.host, this.options.defaultValue(this.host));\n this.setUserInteracted(this.host, false);\n interactions.set(this.host, []);\n }\n\n private handleInteraction(event: Event) {\n const emittedEvents = interactions.get(this.host)!;\n\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.options.assumeInteractionOn.length) {\n this.setUserInteracted(this.host, true);\n }\n }\n\n private reportFormValidity() {\n //\n // Nile form controls work hard to act like regular form controls. They support the Constraint Validation API\n // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also\n // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using\n // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.\n //\n // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger\n // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't\n // be necessary once we can use ElementInternals.\n //\n // Note that we're also honoring the form's novalidate attribute.\n //\n if (this.form && !this.form.noValidate) {\n // This seems sloppy, but checking all elements will cover native inputs, Nile inputs, and other custom\n // elements that support the constraint validation API.\n const elements = this.form.querySelectorAll<HTMLInputElement>('*');\n\n for (const element of elements) {\n if (typeof element.reportValidity === 'function') {\n if (!element.reportValidity()) {\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n private setUserInteracted(el: NileFormControl, hasInteracted: boolean) {\n if (hasInteracted) {\n userInteractedControls.add(el);\n } else {\n userInteractedControls.delete(el);\n }\n\n el.requestUpdate();\n }\n\n private doAction(type: 'submit' | 'reset', submitter?: HTMLInputElement | NileButton) {\n if (this.form) {\n const button = document.createElement('button');\n button.type = type;\n button.style.position = 'absolute';\n button.style.width = '0';\n button.style.height = '0';\n button.style.clipPath = 'inset(50%)';\n button.style.overflow = 'hidden';\n button.style.whiteSpace = 'nowrap';\n\n // Pass name, value, and form attributes through to the temporary button\n if (submitter) {\n button.name = submitter.name;\n button.value = submitter.value;\n\n ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {\n if (submitter.hasAttribute(attr)) {\n button.setAttribute(attr, submitter.getAttribute(attr)!);\n }\n });\n }\n\n this.form.append(button);\n button.click();\n button.remove();\n }\n }\n\n /** Returns the associated `<form>` element, if one exists. */\n getForm() {\n return this.form ?? null;\n }\n\n /** Resets the form, restoring all the control to their default value */\n reset(submitter?: HTMLInputElement | NileButton) {\n this.doAction('reset', submitter);\n }\n\n /** Submits the form, triggering validation and form data injection. */\n submit(submitter?: HTMLInputElement | NileButton) {\n // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a\n // native submit button into the form, \"click\" it, then remove it to simulate a standard form submission.\n this.doAction('submit', submitter);\n }\n\n /**\n * Synchronously sets the form control's validity. Call this when you know the future validity but need to update\n * the host element immediately, i.e. before Lit updates the component in the next update.\n */\n setValidity(isValid: boolean) {\n const host = this.host;\n const hasInteracted = Boolean(userInteractedControls.has(host));\n const required = Boolean(host.required);\n\n //\n // We're mapping the following \"states\" to data attributes. In the future, we can use ElementInternals.states to\n // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.\n //\n //\n host.toggleAttribute('data-required', required);\n host.toggleAttribute('data-optional', !required);\n host.toggleAttribute('data-invalid', !isValid);\n host.toggleAttribute('data-valid', isValid);\n host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);\n host.toggleAttribute('data-user-valid', isValid && hasInteracted);\n }\n\n /**\n * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything\n * that affects constraint validation changes so the component receives the correct validity states.\n */\n updateValidity() {\n const host = this.host;\n this.setValidity(host.validity.valid);\n }\n\n /**\n * Dispatches a non-bubbling, cancelable custom event of type `nile-invalid`.\n * If the `nile-invalid` event will be cancelled then the original `invalid`\n * event (which may have been passed as argument) will also be cancelled.\n * If no original `invalid` event has been passed then the `nile-invalid`\n * event will be cancelled before being dispatched.\n */\n emitInvalidEvent(originalInvalidEvent?: Event) {\n const slInvalidEvent = new CustomEvent<Record<PropertyKey, never>>('nile-invalid', {\n bubbles: false,\n composed: false,\n cancelable: true,\n detail: {}\n });\n\n if (!originalInvalidEvent) {\n slInvalidEvent.preventDefault();\n }\n\n if (!this.host.dispatchEvent(slInvalidEvent)) {\n originalInvalidEvent?.preventDefault();\n }\n }\n}\n\n/*\n * Predefined common validity states.\n * All of them are read-only.\n */\n\n// A validity state object that represents `valid`\nexport const validValidityState: ValidityState = Object.freeze({\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false\n});\n\n// A validity state object that represents `value missing`\nexport const valueMissingValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n valueMissing: true\n});\n\n// A validity state object that represents a custom error\nexport const customErrorValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n customError: true\n});\n"]}
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/internal/form.ts"],"names":[],"mappings":"AAIA,EAAE;AACF,gHAAgH;AAChH,oHAAoH;AACpH,uDAAuD;AACvD,EAAE;AACF,MAAM,CAAC,MAAM,eAAe,GAAmD,IAAI,OAAO,EAAE,CAAC;AAE7F,EAAE;AACF,mHAAmH;AACnH,sDAAsD;AACtD,EAAE;AACF,MAAM,uBAAuB,GAA4C,IAAI,OAAO,EAAE,CAAC;AAEvF,EAAE;AACF,gHAAgH;AAChH,6DAA6D;AAC7D,EAAE;AACF,MAAM,sBAAsB,GAA6B,IAAI,OAAO,EAAE,CAAC;AAEvE,EAAE;AACF,uHAAuH;AACvH,EAAE;AACF,MAAM,YAAY,GAA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CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AAEH,kDAAkD;AAClD,MAAM,CAAC,MAAM,kBAAkB,GAAkB,MAAM,CAAC,MAAM,CAAC;IAC7D,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,IAAI;IACX,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAkB,MAAM,CAAC,MAAM,CAAC;IACpE,GAAG,kBAAkB;IACrB,KAAK,EAAE,KAAK;IACZ,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAkB,MAAM,CAAC,MAAM,CAAC;IACnE,GAAG,kBAAkB;IACrB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { NileFormControl } from '../internal/nile-element';\nimport type { NileButton } from '../nile-button';\n\n//\n// We store a WeakMap of forms + controls so we can keep references to all Nile controls within a given form. As\n// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is\n// added and removed from the form's set, respectively.\n//\nexport const formCollections: WeakMap<HTMLFormElement, Set<NileFormControl>> = new WeakMap();\n\n//\n// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and\n// restore the original behavior when they disconnect.\n//\nconst reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();\n\n//\n// We store a Set of controls that users have interacted with. This allows us to determine the interaction state\n// without littering the DOM with additional data attributes.\n//\nconst userInteractedControls: WeakSet<NileFormControl> = new WeakSet();\n\n//\n// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.\n//\nconst interactions = new WeakMap<NileFormControl, string[]>();\n\nexport interface FormControlControllerOptions {\n /** A function that returns the form containing the form control. */\n form: (input: NileFormControl) => HTMLFormElement | null;\n /** A function that returns the form control's name, which will be submitted with the form data. */\n name: (input: NileFormControl) => string;\n /** A function that returns the form control's current value. */\n value: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's default value. */\n defaultValue: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */\n disabled: (input: NileFormControl) => boolean;\n /**\n * A function that maps to the form control's reportValidity() function. When the control is invalid, this will\n * prevent submission and trigger the browser's constraint violation warning.\n */\n reportValidity: (input: NileFormControl) => boolean;\n /** A function that sets the form control's value */\n setValue: (input: NileFormControl, value: unknown) => void;\n /**\n * An array of event names to listen to. When all events in the list are emitted, the control will receive validity\n * states such as user-valid and user-invalid.user interacted validity states. */\n assumeInteractionOn: string[];\n}\n\n/** A reactive controller to allow form controls to participate in form submission, validation, etc. */\nexport class FormControlController implements ReactiveController {\n host: NileFormControl & ReactiveControllerHost;\n form?: HTMLFormElement | null;\n options: FormControlControllerOptions;\n\n constructor(host: ReactiveControllerHost & NileFormControl, options?: Partial<FormControlControllerOptions>) {\n (this.host = host).addController(this);\n this.options = {\n form: input => {\n // If there's a form attribute, use it to find the target form by id\n if (input.hasAttribute('form') && input.getAttribute('form') !== '') {\n const root = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute('form');\n\n if (formId) {\n return root.getElementById(formId) as HTMLFormElement;\n }\n }\n\n return input.closest('form');\n },\n name: input => input.name,\n value: input => input.value,\n defaultValue: input => input.defaultValue,\n disabled: input => input.disabled ?? false,\n reportValidity: input => (typeof input.reportValidity === 'function' ? input.reportValidity() : true),\n setValue: (input, value: string) => (input.value = value),\n assumeInteractionOn: ['nile-input'],\n ...options\n };\n this.handleFormData = this.handleFormData.bind(this);\n this.handleFormSubmit = this.handleFormSubmit.bind(this);\n this.handleFormReset = this.handleFormReset.bind(this);\n this.reportFormValidity = this.reportFormValidity.bind(this);\n this.handleInteraction = this.handleInteraction.bind(this);\n }\n\n hostConnected() {\n const form = this.options.form(this.host);\n\n if (form) {\n this.attachForm(form);\n }\n\n // Listen for interactions\n interactions.set(this.host, []);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.addEventListener(event, this.handleInteraction);\n });\n }\n\n hostDisconnected() {\n this.detachForm();\n\n // Clean up interactions\n interactions.delete(this.host);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.removeEventListener(event, this.handleInteraction);\n });\n }\n\n hostUpdated() {\n const form = this.options.form(this.host);\n\n // Detach if the form no longer exists\n if (!form) {\n this.detachForm();\n }\n\n // If the form has changed, reattach it\n if (form && this.form !== form) {\n this.detachForm();\n this.attachForm(form);\n }\n\n if (this.host.hasUpdated) {\n this.setValidity(this.host.validity.valid);\n }\n }\n\n private attachForm(form?: HTMLFormElement) {\n if (form) {\n this.form = form;\n\n // Add this element to the form's collection\n if (formCollections.has(this.form)) {\n formCollections.get(this.form)!.add(this.host);\n } else {\n formCollections.set(this.form, new Set<NileFormControl>([this.host]));\n }\n\n this.form.addEventListener('formdata', this.handleFormData);\n this.form.addEventListener('submit', this.handleFormSubmit);\n this.form.addEventListener('reset', this.handleFormReset);\n\n // Overload the form's reportValidity() method so it looks at nile form controls\n if (!reportValidityOverloads.has(this.form)) {\n reportValidityOverloads.set(this.form, this.form.reportValidity);\n this.form.reportValidity = () => this.reportFormValidity();\n }\n } else {\n this.form = undefined;\n }\n }\n\n private detachForm() {\n if (this.form) {\n // Remove this element from the form's collection\n formCollections.get(this.form)?.delete(this.host);\n\n this.form.removeEventListener('formdata', this.handleFormData);\n this.form.removeEventListener('submit', this.handleFormSubmit);\n this.form.removeEventListener('reset', this.handleFormReset);\n\n // Remove the overload and restore the original method\n if (reportValidityOverloads.has(this.form)) {\n this.form.reportValidity = reportValidityOverloads.get(this.form)!;\n reportValidityOverloads.delete(this.form);\n }\n }\n\n this.form = undefined;\n }\n\n private handleFormData(event: FormDataEvent) {\n const disabled = this.options.disabled(this.host);\n const name = this.options.name(this.host);\n const value = this.options.value(this.host);\n\n // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by\n // injecting the name/value on a temporary button, so we can just skip them here.\n const isButton = this.host.tagName.toLowerCase() === 'nile-button';\n\n if (!disabled && !isButton && typeof name === 'string' && name.length > 0 && typeof value !== 'undefined') {\n if (Array.isArray(value)) {\n (value as unknown[]).forEach(val => {\n event.formData.append(name, (val as string | number | boolean).toString());\n });\n } else {\n event.formData.append(name, (value as string | number | boolean).toString());\n }\n }\n }\n\n private handleFormSubmit(event: Event) {\n const disabled = this.options.disabled(this.host);\n const reportValidity = this.options.reportValidity;\n\n // Update the interacted state for all controls when the form is submitted\n if (this.form && !this.form.noValidate) {\n formCollections.get(this.form)?.forEach(control => {\n this.setUserInteracted(control, true);\n });\n }\n\n if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleFormReset() {\n this.options.setValue(this.host, this.options.defaultValue(this.host));\n this.setUserInteracted(this.host, false);\n interactions.set(this.host, []);\n }\n\n private handleInteraction(event: Event) {\n const emittedEvents = interactions.get(this.host)!;\n\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.options.assumeInteractionOn.length) {\n this.setUserInteracted(this.host, true);\n }\n }\n\n private reportFormValidity() {\n //\n // Nile form controls work hard to act like regular form controls. They support the Constraint Validation API\n // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also\n // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using\n // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.\n //\n // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger\n // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't\n // be necessary once we can use ElementInternals.\n //\n // Note that we're also honoring the form's novalidate attribute.\n //\n if (this.form && !this.form.noValidate) {\n // This seems sloppy, but checking all elements will cover native inputs, Nile inputs, and other custom\n // elements that support the constraint validation API.\n const elements = this.form.querySelectorAll<HTMLInputElement>('*');\n\n for (const element of elements) {\n if (typeof element.reportValidity === 'function') {\n if (!element.reportValidity()) {\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n private setUserInteracted(el: NileFormControl, hasInteracted: boolean) {\n if (hasInteracted) {\n userInteractedControls.add(el);\n } else {\n userInteractedControls.delete(el);\n }\n\n el.requestUpdate();\n }\n\n private doAction(type: 'submit' | 'reset', submitter?: HTMLInputElement | NileButton) {\n if (this.form) {\n const button = document.createElement('button');\n button.type = type;\n button.style.position = 'absolute';\n button.style.width = '0';\n button.style.height = '0';\n button.style.clipPath = 'inset(50%)';\n button.style.overflow = 'hidden';\n button.style.whiteSpace = 'nowrap';\n\n // Pass name, value, and form attributes through to the temporary button\n if (submitter) {\n button.name = submitter.name;\n button.value = submitter.value;\n\n ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {\n if (submitter.hasAttribute(attr)) {\n button.setAttribute(attr, submitter.getAttribute(attr)!);\n }\n });\n }\n\n this.form.append(button);\n button.click();\n button.remove();\n }\n }\n\n /** Returns the associated `<form>` element, if one exists. */\n getForm() {\n return this.form ?? null;\n }\n\n /** Resets the form, restoring all the control to their default value */\n reset(submitter?: HTMLInputElement | NileButton) {\n this.doAction('reset', submitter);\n }\n\n /** Submits the form, triggering validation and form data injection. */\n submit(submitter?: HTMLInputElement | NileButton) {\n // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a\n // native submit button into the form, \"click\" it, then remove it to simulate a standard form submission.\n this.doAction('submit', submitter);\n }\n\n /**\n * Synchronously sets the form control's validity. Call this when you know the future validity but need to update\n * the host element immediately, i.e. before Lit updates the component in the next update.\n */\n setValidity(isValid: boolean) {\n const host = this.host;\n const hasInteracted = Boolean(userInteractedControls.has(host));\n const required = Boolean(host.required);\n\n //\n // We're mapping the following \"states\" to data attributes. In the future, we can use ElementInternals.states to\n // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.\n //\n //\n host.toggleAttribute('data-required', required);\n host.toggleAttribute('data-optional', !required);\n host.toggleAttribute('data-invalid', !isValid);\n host.toggleAttribute('data-valid', isValid);\n host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);\n host.toggleAttribute('data-user-valid', isValid && hasInteracted);\n }\n\n /**\n * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything\n * that affects constraint validation changes so the component receives the correct validity states.\n */\n updateValidity() {\n const host = this.host;\n this.setValidity(host.validity.valid);\n }\n\n /**\n * Dispatches a non-bubbling, cancelable custom event of type `nile-invalid`.\n * If the `nile-invalid` event will be cancelled then the original `invalid`\n * event (which may have been passed as argument) will also be cancelled.\n * If no original `invalid` event has been passed then the `nile-invalid`\n * event will be cancelled before being dispatched.\n */\n emitInvalidEvent(originalInvalidEvent?: Event) {\n const slInvalidEvent = new CustomEvent<Record<PropertyKey, never>>('nile-invalid', {\n bubbles: false,\n composed: false,\n cancelable: true,\n detail: {}\n });\n\n if (!originalInvalidEvent) {\n slInvalidEvent.preventDefault();\n }\n\n if (!this.host.dispatchEvent(slInvalidEvent)) {\n originalInvalidEvent?.preventDefault();\n }\n }\n}\n\n/*\n * Predefined common validity states.\n * All of them are read-only.\n */\n\n// A validity state object that represents `valid`\nexport const validValidityState: ValidityState = Object.freeze({\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false\n});\n\n// A validity state object that represents `value missing`\nexport const valueMissingValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n valueMissing: true\n});\n\n// A validity state object that represents a custom error\nexport const customErrorValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n customError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QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAyB;AAExB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAA0B;AAE3B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAA6B;AAEF;IAApD,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEV;IAAxD,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAmB;AAE7C;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;gDAA4J;AAE3J;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;oDAA2D;AAxE7E,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAuRpB;;AAED,eAAe,QAAQ,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 {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, query, state, property } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // AUTO-COMPLETE-OPTIONS\n\n /** Virtual scroll in dropdown options. */\n @property({ type: Boolean }) enableVirtualScroll = false;\n\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text', reflect: true }) helpText = '';\n\n @property({ attribute: 'error-message', reflect: true }) errorMessage = '';\n\n @property({ attribute:false}) filterFunction: (item:string,searchedValue:string)=>boolean = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());\n\n @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item;\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has('autoCompleteOptions')) {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n if (changedProperties.has('value')){\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n if (changedProperties.has('tags')){\n this.onTagsChanged();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n pill\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .enableVirtualScroll=${this.enableVirtualScroll}\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .filterFunction=${this.filterFunction}\n .renderItemFunction=${this.renderItemFunction}\n .loading=\"${this.loading}\"\n .value=${this.inputValue}\n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if(event.key === 'Tab'){\n event.preventDefault()\n }\n \n if (\n (event.key === 'Enter' || event.key === 'Tab' ) \n && this.inputValue \n && (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n event.preventDefault()\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n if(\n (event.key === 'Enter'|| event.key === 'Tab' ) \n && this.inputValue \n && (this.noDuplicates || this.tags.includes(this.inputValue))\n ){\n this.emit('nile-duplicates-blocked');\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n onTagsChanged() {\n if (this.noDuplicates)\n this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));\n }\n\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"nile-chip.js","sourceRoot":"","sources":["../../../src/nile-chip/nile-chip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAEL,IAAI,GAIL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,WAAgC,MAAM,0BAA0B,CAAC;AAOjE,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,WAAW;IAAlC;;QAKY,sBAAiB,GAAG,IAAI,iBAAiB,CACxD,IAAI,EACJ,WAAW,EACX,OAAO,CACR,CAAC;QAEO,SAAI,GAAa,EAAE,CAAC;QAEpB,eAAU,GAAW,EAAE,CAAC;QAExB,mBAAc,GAAY,KAAK,CAAC;QAIzC,yEAAyE;QAC5C,YAAO,GAAG,KAAK,CAAC;QAE7C,wEAAwE;QAC3C,UAAK,GAAG,KAAK,CAAC;QAE3C,yEAAyE;QAC5C,YAAO,GAAG,KAAK,CAAC;QAE7C,sCAAsC;QACT,iBAAY,GAAG,KAAK,CAAC;QAElD,oFAAoF;QACxE,UAAK,GAAG,EAAE,CAAC;QAEvB,uDAAuD;QAC1B,oBAAe,GAAG,KAAK,CAAC;QAErD,uDAAuD;QAC1B,cAAS,GAAG,KAAK,CAAC;QAE/C,kEAAkE;QACtD,gBAAW,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,EAAE,CAAC;qDAAiC;AAEhC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6DAAyC;AAExC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCAAmB;AAEhB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAyB;AAExB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAA0B;AAE3B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAA6B;AAEF;IAApD,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEV;IAAxD,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAmB;AAE7C;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;gDAA4J;AAE3J;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;oDAA2D;AAxE7E,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAwRpB;;AAED,eAAe,QAAQ,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 {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, query, state, property } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // AUTO-COMPLETE-OPTIONS\n\n /** Virtual scroll in dropdown options. */\n @property({ type: Boolean }) enableVirtualScroll = false;\n\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text', reflect: true }) helpText = '';\n\n @property({ attribute: 'error-message', reflect: true }) errorMessage = '';\n\n @property({ attribute:false}) filterFunction: (item:string,searchedValue:string)=>boolean = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());\n\n @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item;\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has('autoCompleteOptions')) {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n if (changedProperties.has('value')){\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n if (changedProperties.has('tags')){\n this.onTagsChanged();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n part='base' \n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n pill\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .enableVirtualScroll=${this.enableVirtualScroll}\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .filterFunction=${this.filterFunction}\n .renderItemFunction=${this.renderItemFunction}\n .loading=\"${this.loading}\"\n .value=${this.inputValue}\n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if(event.key === 'Tab'){\n event.preventDefault()\n }\n \n if (\n (event.key === 'Enter' || event.key === 'Tab' ) \n && this.inputValue \n && (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n event.preventDefault()\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n if(\n (event.key === 'Enter'|| event.key === 'Tab' ) \n && this.inputValue \n && (this.noDuplicates || this.tags.includes(this.inputValue))\n ){\n this.emit('nile-duplicates-blocked');\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n onTagsChanged() {\n if (this.noDuplicates)\n this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));\n }\n\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-option.css.js","sourceRoot":"","sources":["../../../src/nile-option/nile-option.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,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';\n\n/**\n * Option_2 CSS\n */\nexport const styles = css`\n :host {\n display: block;\n user-select: none;\n }\n\n :host(:focus) {\n outline: none;\n }\n\n .option {\n position: relative;\n display: flex;\n align-items: center;\n font-size: 1rem;\n font-weight: 400;\n line-height: 1.8;\n letter-spacing: normal;\n color: hsl(240 5.3% 26.1%);\n padding: 6px 0;\n transition: 150ms fill;\n cursor: pointer;\n }\n\n .option--single-select {\n padding:
|
1
|
+
{"version":3,"file":"nile-option.css.js","sourceRoot":"","sources":["../../../src/nile-option/nile-option.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,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';\n\n/**\n * Option_2 CSS\n */\nexport const styles = css`\n :host {\n display: block;\n user-select: none;\n }\n\n :host(:focus) {\n outline: none;\n }\n\n .option {\n position: relative;\n display: flex;\n align-items: center;\n font-size: 1rem;\n font-weight: 400;\n line-height: 1.8;\n letter-spacing: normal;\n color: hsl(240 5.3% 26.1%);\n padding: 6px 0;\n transition: 150ms fill;\n cursor: pointer;\n }\n\n .option--single-select {\n padding: 9px 12px;\n }\n\n .option--hover:not(.option--current):not(.option--disabled) {\n background-color: rgba(0, 94, 166, 0.1);\n color: hsl(0, 0%, 0%);\n }\n\n .option--current,\n .option--current.option--disabled {\n background-color: rgba(0, 94, 166, 0.1);\n color: var(--nile-colors-primary-600);\n opacity: 1;\n }\n\n .option--disabled {\n outline: none;\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .option__label {\n flex: 1 1 auto;\n display: inline-block;\n line-height: 1.4;\n word-break: break-all;\n }\n\n .option .option__check {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n visibility: hidden;\n padding-inline-end: 0.25rem;\n }\n\n .option--selected .option__check {\n visibility: visible;\n }\n\n .option__prefix,\n .option__suffix {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n }\n\n .option__prefix::slotted(*) {\n margin-inline-end: 0.5rem;\n }\n\n .option__suffix::slotted(*) {\n margin-inline-start: 0.5rem;\n }\n\n .option--checkbox{\n pointer-events: none;\n margin-left: 12px;\n margin-right: 12px;\n width:auto;\n }\n\n @media (forced-colors: active) {\n :host(:hover:not([aria-disabled='true'])) .option {\n outline: dashed 1px SelectedItem;\n outline-offset: -1px;\n }\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -36,6 +36,7 @@ export declare class NileOption extends NileElement {
|
|
36
36
|
private cachedTextLabel;
|
37
37
|
defaultSlot: HTMLSlotElement;
|
38
38
|
current: boolean;
|
39
|
+
selected: boolean;
|
39
40
|
hasHover: boolean;
|
40
41
|
hidden: boolean;
|
41
42
|
isMultipleSelect: boolean;
|
@@ -48,10 +49,6 @@ export declare class NileOption extends NileElement {
|
|
48
49
|
showCheckbox: boolean;
|
49
50
|
/** Draws the option in a disabled state, preventing selection. */
|
50
51
|
disabled: boolean;
|
51
|
-
/** Forces the option to display in multiple select mode with checkboxes. */
|
52
|
-
multiple: boolean;
|
53
|
-
/** Indicates whether the option is selected. */
|
54
|
-
selected: boolean;
|
55
52
|
connectedCallback(): void;
|
56
53
|
protected updated(_changedProperties: PropertyValues): void;
|
57
54
|
private handleDefaultSlotChange;
|
@@ -59,7 +56,6 @@ export declare class NileOption extends NileElement {
|
|
59
56
|
private handleMouseLeave;
|
60
57
|
handleDisabledChange(): void;
|
61
58
|
handleSelectedChange(): void;
|
62
|
-
handleMultipleChange(): void;
|
63
59
|
handleValueChange(): void;
|
64
60
|
/** Returns a plain text label based on the option's content. */
|
65
61
|
getTextLabel(): string;
|
@@ -39,6 +39,7 @@ let NileOption = class NileOption extends NileElement {
|
|
39
39
|
constructor() {
|
40
40
|
super(...arguments);
|
41
41
|
this.current = false; // the user has keyed into the option, but hasn't selected it yet (shows a highlight)
|
42
|
+
this.selected = false; // the option is selected and has aria-selected="true"
|
42
43
|
this.hasHover = false; // we need this because Safari doesn't honor :hover styles while dragging
|
43
44
|
this.hidden = false; // the option is hidden
|
44
45
|
this.isMultipleSelect = false;
|
@@ -51,17 +52,13 @@ let NileOption = class NileOption extends NileElement {
|
|
51
52
|
this.showCheckbox = false;
|
52
53
|
/** Draws the option in a disabled state, preventing selection. */
|
53
54
|
this.disabled = false;
|
54
|
-
/** Forces the option to display in multiple select mode with checkboxes. */
|
55
|
-
this.multiple = false;
|
56
|
-
/** Indicates whether the option is selected. */
|
57
|
-
this.selected = false;
|
58
55
|
}
|
59
56
|
connectedCallback() {
|
60
57
|
super.connectedCallback();
|
61
58
|
this.setAttribute('role', 'option');
|
62
59
|
this.setAttribute('aria-selected', 'false');
|
63
|
-
// Find the closest parent 'nile-select'
|
64
|
-
const parentSelect = this.closest('nile-select')
|
60
|
+
// Find the closest parent 'nile-select' element
|
61
|
+
const parentSelect = this.closest('nile-select');
|
65
62
|
// Check if the parent has the 'multiple' attribute
|
66
63
|
if (parentSelect && parentSelect.hasAttribute('multiple')) {
|
67
64
|
let multipleValue = parentSelect.getAttribute('multiple');
|
@@ -72,9 +69,6 @@ let NileOption = class NileOption extends NileElement {
|
|
72
69
|
this.isMultipleSelect = Boolean(multipleValue);
|
73
70
|
}
|
74
71
|
}
|
75
|
-
if (this.multiple) {
|
76
|
-
this.isMultipleSelect = true;
|
77
|
-
}
|
78
72
|
}
|
79
73
|
updated(_changedProperties) {
|
80
74
|
if (_changedProperties.has('showCheckbox')) {
|
@@ -106,9 +100,6 @@ let NileOption = class NileOption extends NileElement {
|
|
106
100
|
handleSelectedChange() {
|
107
101
|
this.setAttribute('aria-selected', this.selected ? 'true' : 'false');
|
108
102
|
}
|
109
|
-
handleMultipleChange() {
|
110
|
-
this.isMultipleSelect = this.multiple;
|
111
|
-
}
|
112
103
|
handleValueChange() {
|
113
104
|
// Ensure the value is a string. This ensures the next line doesn't error and allows framework users to pass numbers
|
114
105
|
// instead of requiring them to cast the value to a string.
|
@@ -172,6 +163,9 @@ __decorate([
|
|
172
163
|
__decorate([
|
173
164
|
state()
|
174
165
|
], NileOption.prototype, "current", void 0);
|
166
|
+
__decorate([
|
167
|
+
state()
|
168
|
+
], NileOption.prototype, "selected", void 0);
|
175
169
|
__decorate([
|
176
170
|
state()
|
177
171
|
], NileOption.prototype, "hasHover", void 0);
|
@@ -190,21 +184,12 @@ __decorate([
|
|
190
184
|
__decorate([
|
191
185
|
property({ type: Boolean, reflect: true })
|
192
186
|
], NileOption.prototype, "disabled", void 0);
|
193
|
-
__decorate([
|
194
|
-
property({ type: Boolean, reflect: true })
|
195
|
-
], NileOption.prototype, "multiple", void 0);
|
196
|
-
__decorate([
|
197
|
-
property({ type: Boolean, reflect: true })
|
198
|
-
], NileOption.prototype, "selected", void 0);
|
199
187
|
__decorate([
|
200
188
|
watch('disabled')
|
201
189
|
], NileOption.prototype, "handleDisabledChange", null);
|
202
190
|
__decorate([
|
203
191
|
watch('selected')
|
204
192
|
], NileOption.prototype, "handleSelectedChange", null);
|
205
|
-
__decorate([
|
206
|
-
watch('multiple')
|
207
|
-
], NileOption.prototype, "handleMultipleChange", null);
|
208
193
|
__decorate([
|
209
194
|
watch('value')
|
210
195
|
], NileOption.prototype, "handleValueChange", null);
|