@aquera/nile-elements 0.1.59-beta-1.1 → 0.1.59

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.
@@ -1,2 +1,2 @@
1
- System.register(["lit","../virtualize-b6a2fbe0.cjs.js","lit/directives/unsafe-html.js","lit/directive.js","lit/async-directive.js","lit/directives/repeat.js"],function(_export,_context){"use strict";var e,t,i,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,s;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);}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[function(_lit){e=_lit.html;},function(_virtualize001CjsJs){t=_virtualize001CjsJs.v;},function(_litDirectivesUnsafeHtmlJs){i=_litDirectivesUnsafeHtmlJs.unsafeHTML;},function(_litDirectiveJs){},function(_litAsyncDirectiveJs){},function(_litDirectivesRepeatJs){}],execute:function execute(){_export("V",s=/*#__PURE__*/function(){function s(){_classCallCheck(this,s);}return _createClass(s,null,[{key:"getVirtualizedContent",value:function getVirtualizedContent(i,r,l,o,a,c,n,d,u,m){return e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div class=\"select__options ","\">\n ","\n </div>"])),r?"select__options__search-enabled":"",d&&!m?e(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <div class=\"select__no-results\">\n ","\n </div>\n "])),u||"No results found"):e(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <div\n class=\"virtualized\"\n >\n ","\n </div>\n "])),s.shouldUseVirtualizer(i)?e(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n ","\n "])),t({items:i,renderItem:function renderItem(e){return s.getItemRenderFunction(e,l,o,a,c,n);},scroller:!0})):e(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n ","\n "])),i.map(function(e){return s.getItemRenderFunction(e,l,o,a,c,n);}))));}},{key:"getItemRenderFunction",value:function getItemRenderFunction(t,_s,r,l,o,a){var c=o||_s,n=a||function(e){return(e===null||e===void 0?void 0:e.value)||e;},d=n(t),u=c(t),m=t.disabled||!1;var v=!1;return v=l?Array.isArray(r)&&r.includes(d):(Array.isArray(r)?r[0]:r)===d,e(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["\n <nile-option \n value="," \n .selected="," \n .multiple=","\n .disabled=","\n .showCheckbox=","\n >\n ","\n </nile-option>\n "])),d,v,l,m,l,i(u));}},{key:"shouldUseVirtualizer",value:function shouldUseVirtualizer(e){return e.length>=50;}}]);}());}};});
1
+ System.register(["lit","../virtualize-b6a2fbe0.cjs.js","lit/directives/unsafe-html.js","lit/directive.js","lit/async-directive.js","lit/directives/repeat.js"],function(_export,_context){"use strict";var e,t,i,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,s;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);}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[function(_lit){e=_lit.html;},function(_virtualize001CjsJs){t=_virtualize001CjsJs.v;},function(_litDirectivesUnsafeHtmlJs){i=_litDirectivesUnsafeHtmlJs.unsafeHTML;},function(_litDirectiveJs){},function(_litAsyncDirectiveJs){},function(_litDirectivesRepeatJs){}],execute:function execute(){_export("V",s=/*#__PURE__*/function(){function s(){_classCallCheck(this,s);}return _createClass(s,null,[{key:"getVirtualizedContent",value:function getVirtualizedContent(i,r,l,o,a,c,n,d,u,v){return e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div class=\"select__options ","\">\n ","\n </div>"])),r?"select__options__search-enabled":"",d&&!v?e(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <div class=\"select__no-results\">\n ","\n </div>\n "])),u||"No results found"):e(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <div\n class=\"virtualized\"\n >\n ","\n </div>\n "])),s.shouldUseVirtualizer(i)?e(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n ","\n "])),t({items:i,renderItem:function renderItem(e){return s.getItemRenderFunction(e,l,o,a,c,n);},scroller:!0})):e(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n ","\n "])),i.map(function(e){return s.getItemRenderFunction(e,l,o,a,c,n);}))));}},{key:"getItemRenderFunction",value:function getItemRenderFunction(t,_s,r,l,o,a){var c=o||_s,n=a||function(e){return(e===null||e===void 0?void 0:e.value)||e;},d=n(t),u=c(t),v=t.disabled||!1;var m=!1;return m=l?Array.isArray(r)&&r.includes(d):(Array.isArray(r)?r[0]:r)===d,e(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["\n <nile-option \n value="," \n .selected="," \n .disabled=","\n .showCheckbox=","\n >\n ","\n </nile-option>\n "])),d,m,v,l,i(u));}},{key:"shouldUseVirtualizer",value:function shouldUseVirtualizer(e){return e.length>=50;}}]);}());}};});
2
2
  //# sourceMappingURL=renderer.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.cjs.js","sources":["../../../src/nile-virtual-select/renderer.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult } from 'lit';\nimport { virtualize } from '@lit-labs/virtualizer/virtualize.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport class VirtualSelectRenderer {\n static getVirtualizedContent(\n data: any[], \n searchEnabled: boolean, \n renderItemFunction: (item: any) => string,\n value: string | string[],\n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string,\n showNoResults?: boolean,\n noResultsMessage?: string,\n optionsLoading?: boolean\n ): TemplateResult {\n return html`\n <div class=\"select__options ${\n searchEnabled ? 'select__options__search-enabled' : ``\n }\">\n ${showNoResults && !optionsLoading\n ? html`\n <div class=\"select__no-results\">\n ${noResultsMessage || 'No results found'}\n </div>\n `\n : html`\n <div\n class=\"virtualized\"\n >\n ${VirtualSelectRenderer.shouldUseVirtualizer(data)\n ? html`\n ${virtualize({\n items: data,\n renderItem: (item: any): TemplateResult =>\n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue),\n scroller: true,\n })}\n `\n : html`\n ${data.map((item: any) => \n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue)\n )}\n `}\n </div>\n `}\n </div>`;\n }\n\n static getItemRenderFunction(\n item: any, \n renderItemFunction: (item: any) => string, \n value: string | string[], \n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string\n ): TemplateResult {\n const displayTextFn = getDisplayText || renderItemFunction;\n const valueFn = getItemValue || ((item: any) => item?.value || item);\n \n const optionValue = valueFn(item);\n const displayText = displayTextFn(item);\n const isDisabled = item.disabled || false;\n \n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.includes(optionValue);\n } else {\n isSelected = (Array.isArray(value) ? value[0] : value) === optionValue;\n }\n \n return html`\n <nile-option \n value=${optionValue} \n .selected=${isSelected} \n .multiple=${multiple}\n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n >\n ${unsafeHTML(displayText)}\n </nile-option>\n `;\n }\n\n /**\n * Determines whether to use virtualizer based on dataset size\n * For small datasets (less than 50 items), use regular rendering for better sizing\n */\n private static shouldUseVirtualizer(data: any[]): boolean {\n return data.length >= 50;\n }\n} \n"],"names":["VirtualSelectRenderer","s","_classCallCheck","_createClass","key","value","getVirtualizedContent","data","searchEnabled","renderItemFunction","multiple","getDisplayText","getItemValue","showNoResults","noResultsMessage","optionsLoading","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","shouldUseVirtualizer","_templateObject4","virtualize","items","renderItem","item","getItemRenderFunction","scroller","_templateObject5","map","displayTextFn","valueFn","optionValue","displayText","isDisabled","disabled","isSelected","Array","isArray","includes","_templateObject6","unsafeHTML","length"],"mappings":"+0DAWaA,C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ACAjB,CAAAA,EAAAA,CACAJ,EACAK,CACAC,CAAAA,CAAAA,CACAC,CAEA,CAAA,CAAA,GAAMmB,CAAAA,CAAgBpB,CAAAA,CAAAA,EAAkBF,GAClCuB,CAAUpB,CAAAA,CAAAA,EAAkBc,SAAAA,CAAcA,QAAAA,CAAAA,CAAAA,SAAAA,CAAAA,iBAAAA,CAAAA,CAAMrB,QAASqB,CAEzDO,EAAAA,CAAAA,CAAAA,CAAcD,CAAQN,CAAAA,CAAAA,CAAAA,CACtBQ,CAAcH,CAAAA,CAAAA,CAAcL,GAC5BS,CAAaT,CAAAA,CAAAA,CAAKU,WAAY,CAEpC,CAAA,GAAIC,CAAAA,GAAa,CAOjB,CAAA,MALEA,CAAAA,CADE3B,CAAAA,CAAAA,CACW4B,KAAMC,CAAAA,OAAAA,CAAQlC,IAAUA,CAAMmC,CAAAA,QAAAA,CAASP,IAEtCK,KAAMC,CAAAA,OAAAA,CAAQlC,GAASA,CAAM,CAAA,CAAA,CAAA,CAAKA,CAAW4B,IAAAA,CAAAA,CAGtDjB,CAAI,CAAAyB,gBAAA,GAAAA,gBAAA,CAAAvB,sBAAA,oMAECe,CAAAA,CACII,CAAAA,CACA3B,CAAAA,CACAyB,CAAAA,CACIzB,CAAAA,CAEdgC,CAAWR,CAAAA,CAAAA,CAAAA,CAGlB,EAMO,GAAA9B,GAAA,wBAAAC,KAAA,8BAAOgB,CAAqBd,CAAAA,CAAAA,CAClC,MAAOA,CAAAA,CAAKoC,CAAAA,MAAAA,EAAU,EACvB"}
1
+ {"version":3,"file":"renderer.cjs.js","sources":["../../../src/nile-virtual-select/renderer.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult } from 'lit';\nimport { virtualize } from '@lit-labs/virtualizer/virtualize.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport class VirtualSelectRenderer {\n static getVirtualizedContent(\n data: any[], \n searchEnabled: boolean, \n renderItemFunction: (item: any) => string,\n value: string | string[],\n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string,\n showNoResults?: boolean,\n noResultsMessage?: string,\n optionsLoading?: boolean\n ): TemplateResult {\n return html`\n <div class=\"select__options ${\n searchEnabled ? 'select__options__search-enabled' : ``\n }\">\n ${showNoResults && !optionsLoading\n ? html`\n <div class=\"select__no-results\">\n ${noResultsMessage || 'No results found'}\n </div>\n `\n : html`\n <div\n class=\"virtualized\"\n >\n ${VirtualSelectRenderer.shouldUseVirtualizer(data)\n ? html`\n ${virtualize({\n items: data,\n renderItem: (item: any): TemplateResult =>\n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue),\n scroller: true,\n })}\n `\n : html`\n ${data.map((item: any) => \n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue)\n )}\n `}\n </div>\n `}\n </div>`;\n }\n\n static getItemRenderFunction(\n item: any, \n renderItemFunction: (item: any) => string, \n value: string | string[], \n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string\n ): TemplateResult {\n const displayTextFn = getDisplayText || renderItemFunction;\n const valueFn = getItemValue || ((item: any) => item?.value || item);\n \n const optionValue = valueFn(item);\n const displayText = displayTextFn(item);\n const isDisabled = item.disabled || false;\n \n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.includes(optionValue);\n } else {\n isSelected = (Array.isArray(value) ? value[0] : value) === optionValue;\n }\n \n return html`\n <nile-option \n value=${optionValue} \n .selected=${isSelected} \n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n >\n ${unsafeHTML(displayText)}\n </nile-option>\n `;\n }\n\n /**\n * Determines whether to use virtualizer based on dataset size\n * For small datasets (less than 50 items), use regular rendering for better sizing\n */\n private static shouldUseVirtualizer(data: any[]): boolean {\n return data.length >= 50;\n }\n} \n"],"names":["VirtualSelectRenderer","s","_classCallCheck","_createClass","key","value","getVirtualizedContent","data","searchEnabled","renderItemFunction","multiple","getDisplayText","getItemValue","showNoResults","noResultsMessage","optionsLoading","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","shouldUseVirtualizer","_templateObject4","virtualize","items","renderItem","item","getItemRenderFunction","scroller","_templateObject5","map","displayTextFn","valueFn","optionValue","displayText","isDisabled","disabled","isSelected","Array","isArray","includes","_templateObject6","unsafeHTML","length"],"mappings":"+0DAWaA,CACX,kCAAAC,EAAA,EAAAC,eAAA,MAAAD,CAAA,UAAAE,YAAA,CAAAF,CAAA,QAAAG,GAAA,yBAAAC,KAAA,CAAA,QAAA,CAAAC,qBAAOA,CACLC,CACAC,CAAAA,CAAAA,CACAC,CACAJ,CAAAA,CAAAA,CACAK,CACAC,CAAAA,CAAAA,CACAC,EACAC,CACAC,CAAAA,CAAAA,CACAC,CAEA,CAAA,CAAA,MAAOC,CAAAA,CAAI,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA,8EAEPV,CAAAA,CAAgB,iCAAoC,CAAA,EAAA,CAElDK,CAAAA,EAAAA,CAAkBE,EAChBC,CAAI,CAAAG,gBAAA,GAAAA,gBAAA,CAAAD,sBAAA,mHAEEJ,CAAoB,EAAA,kBAAA,EAG1BE,CAAI,CAAAI,gBAAA,GAAAA,gBAAA,CAAAF,sBAAA,6IAIElB,CAAsBqB,CAAAA,oBAAAA,CAAqBd,GACzCS,CAAI,CAAAM,gBAAA,GAAAA,gBAAA,CAAAJ,sBAAA,yDACAK,CAAAA,CAAW,CACXC,KAAAA,CAAOjB,CACPkB,CAAAA,UAAAA,CAAaC,QAAbD,CAAAA,UAAAA,CAAaC,CACX1B,QAAAA,CAAAA,CAAAA,CAAsB2B,qBAAsBD,CAAAA,CAAAA,CAAMjB,CAAoBJ,CAAAA,CAAAA,CAAOK,CAAUC,CAAAA,CAAAA,CAAgBC,KACzGgB,QAAU,CAAA,CAAA,CAA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CAAAA,MAAAA,EAAU,EACvB"}
@@ -19,7 +19,6 @@ import{html as e}from"lit";import{v as t}from"../virtualize-a4a40d96.esm.js";imp
19
19
  <nile-option
20
20
  value=${d}
21
21
  .selected=${v}
22
- .multiple=${l}
23
22
  .disabled=${u}
24
23
  .showCheckbox=${l}
25
24
  >
@@ -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?.form(this.host);
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?.assumeInteractionOn.forEach(event => {
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,K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B,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: 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;AAC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AAE,EAAE;SACX,CAAC,CAAC;QAEH,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,cAAc,CAAC,cAAc,EAAE,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC;YAC7C,oBAAoB,EAAE,cAAc,EAAE,CAAC;QACzC,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: true\n});\n"]}
@@ -33,7 +33,7 @@ export const styles = css `
33
33
  }
34
34
 
35
35
  .option--single-select {
36
- padding: 8px 12px;
36
+ padding: 9px 12px;
37
37
  }
38
38
 
39
39
  .option--hover:not(.option--current):not(.option--disabled) {
@@ -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: 8px 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"]}
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"]}
@@ -48,8 +48,6 @@ export declare class NileOption extends NileElement {
48
48
  showCheckbox: boolean;
49
49
  /** Draws the option in a disabled state, preventing selection. */
50
50
  disabled: boolean;
51
- /** Forces the option to display in multiple select mode with checkboxes. */
52
- multiple: boolean;
53
51
  /** Indicates whether the option is selected. */
54
52
  selected: boolean;
55
53
  connectedCallback(): void;
@@ -59,7 +57,6 @@ export declare class NileOption extends NileElement {
59
57
  private handleMouseLeave;
60
58
  handleDisabledChange(): void;
61
59
  handleSelectedChange(): void;
62
- handleMultipleChange(): void;
63
60
  handleValueChange(): void;
64
61
  /** Returns a plain text label based on the option's content. */
65
62
  getTextLabel(): string;
@@ -51,8 +51,6 @@ let NileOption = class NileOption extends NileElement {
51
51
  this.showCheckbox = false;
52
52
  /** Draws the option in a disabled state, preventing selection. */
53
53
  this.disabled = false;
54
- /** Forces the option to display in multiple select mode with checkboxes. */
55
- this.multiple = false;
56
54
  /** Indicates whether the option is selected. */
57
55
  this.selected = false;
58
56
  }
@@ -72,9 +70,6 @@ let NileOption = class NileOption extends NileElement {
72
70
  this.isMultipleSelect = Boolean(multipleValue);
73
71
  }
74
72
  }
75
- if (this.multiple) {
76
- this.isMultipleSelect = true;
77
- }
78
73
  }
79
74
  updated(_changedProperties) {
80
75
  if (_changedProperties.has('showCheckbox')) {
@@ -106,9 +101,6 @@ let NileOption = class NileOption extends NileElement {
106
101
  handleSelectedChange() {
107
102
  this.setAttribute('aria-selected', this.selected ? 'true' : 'false');
108
103
  }
109
- handleMultipleChange() {
110
- this.isMultipleSelect = this.multiple;
111
- }
112
104
  handleValueChange() {
113
105
  // Ensure the value is a string. This ensures the next line doesn't error and allows framework users to pass numbers
114
106
  // instead of requiring them to cast the value to a string.
@@ -190,9 +182,6 @@ __decorate([
190
182
  __decorate([
191
183
  property({ type: Boolean, reflect: true })
192
184
  ], NileOption.prototype, "disabled", void 0);
193
- __decorate([
194
- property({ type: Boolean, reflect: true })
195
- ], NileOption.prototype, "multiple", void 0);
196
185
  __decorate([
197
186
  property({ type: Boolean, reflect: true })
198
187
  ], NileOption.prototype, "selected", void 0);
@@ -202,9 +191,6 @@ __decorate([
202
191
  __decorate([
203
192
  watch('selected')
204
193
  ], NileOption.prototype, "handleSelectedChange", null);
205
- __decorate([
206
- watch('multiple')
207
- ], NileOption.prototype, "handleMultipleChange", null);
208
194
  __decorate([
209
195
  watch('value')
210
196
  ], NileOption.prototype, "handleValue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B;AAGD;IADC,KAAK,CAAC,UAAU,CAAC;sDAGjB;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;mDAed;AAlHU,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAgKtB;;AAED,eAAe,UAAU,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 { LitElement, CSSResultArray, TemplateResult } from 'lit';\nimport { styles } from './nile-option.css';\nimport '../nile-icon';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { html } from 'lit';\nimport { watch } from '../internal/watch';\nimport type { CSSResultGroup, PropertyValues } from 'lit';\nimport NileElement from '../internal/nile-element';\nimport '../nile-checkbox';\n\n/**\n * Nile icon component.\n *\n * @tag nile-option\n *\n */\n\n/**\n * @summary Options define the selectable items within various form controls such as [select](/components/select).\n * @status stable\n *\n * @dependency nile-icon\n *\n * @slot - The option's label.\n * @slot prefix - Used to prepend an icon or similar element to the menu item.\n * @slot suffix - Used to append an icon or similar element to the menu item.\n *\n * @csspart checked-icon - The checked icon, an `<nile-icon>` element.\n * @csspart base - The component's base wrapper.\n * @csspart label - The option's label.\n * @csspart prefix - The container that wraps the prefix.\n * @csspart suffix - The container that wraps the suffix.\n */\n\n@customElement('nile-option')\nexport class NileOption extends NileElement {\n static styles: CSSResultGroup = styles;\n\n private cachedTextLabel: string;\n\n @query('.option__label') defaultSlot: HTMLSlotElement;\n\n @state() current = false; // the user has keyed into the option, but hasn't selected it yet (shows a highlight)\n @state() hasHover = false; // we need this because Safari doesn't honor :hover styles while dragging\n @state() hidden = false; // the option is hidden\n @state() isMultipleSelect = false;\n\n /**\n * The option's value. When selected, the containing form control will receive this value. The value must be unique\n * from other options in the same group. Values may not contain spaces, as spaces are used as delimiters when listing\n * multiple values.\n */\n @property({ reflect: true }) value = '';\n\n @property({ type: Boolean }) showCheckbox: boolean = false;\n\n /** Draws the option in a disabled state, preventing selection. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Forces the option to display in multiple select mode with checkboxes. */\n @property({ type: Boolean, reflect: true }) multiple = false;\n\n /** Indicates whether the option is selected. */\n @property({ type: Boolean, reflect: true }) selected = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'option');\n this.setAttribute('aria-selected', 'false');\n\n // Find the closest parent 'nile-select' or 'nile-virtual-select' element\n const parentSelect = this.closest('nile-select') || this.closest('nile-virtual-select');\n\n // Check if the parent has the 'multiple' attribute\n if (parentSelect && parentSelect.hasAttribute('multiple')) {\n let multipleValue = parentSelect.getAttribute('multiple');\n if (multipleValue !== 'false') {\n if(multipleValue === ''){\n multipleValue = 'true';\n }\n this.isMultipleSelect = Boolean(multipleValue);\n }\n }\n\n if (this.multiple) {\n this.isMultipleSelect = true;\n }\n }\n\n protected updated(_changedProperties: PropertyValues): void {\n if(_changedProperties.has('showCheckbox')) {\n this.isMultipleSelect = this.showCheckbox;\n }\n }\n\n private handleDefaultSlotChange() {\n const textLabel = this.getTextLabel();\n\n // Ignore the first time the label is set\n if (typeof this.cachedTextLabel === 'undefined') {\n this.cachedTextLabel = textLabel;\n return;\n }\n\n // When the label changes, emit a slotchange event so parent controls see it\n if (textLabel !== this.cachedTextLabel) {\n this.cachedTextLabel = textLabel;\n this.emit('slotchange');\n }\n }\n\n private handleMouseEnter() {\n this.hasHover = true;\n }\n\n private handleMouseLeave() {\n this.hasHover = false;\n }\n\n @watch('disabled')\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n @watch('selected')\n handleSelectedChange() {\n this.setAttribute('aria-selected', this.selected ? 'true' : 'false');\n }\n\n @watch('multiple')\n handleMultipleChange() {\n this.isMultipleSelect = this.multiple;\n }\n\n @watch('value')\n handleValueChange() {\n // Ensure the value is a string. This ensures the next line doesn't error and allows framework users to pass numbers\n // instead of requiring them to cast the value to a string.\n if (typeof this.value !== 'string') {\n this.value = String(this.value);\n }\n\n // if (this.value.includes(' ')) {\n // console.error(\n // `Option values cannot include a space. All spaces have been replaced with underscores.`,\n // this\n // );\n // this.value = this.value.replace(/ /g, '_');\n // }\n }\n\n /** Returns a plain text label based on the option's content. */\n getTextLabel() {\n // Search for a label element inside the component\n const labelElement = this.querySelector('label');\n\n // If a label element is found, return its text content\n if (labelElement) {\n return labelElement.textContent?.trim() ?? '';\n }\n\n // If no label element is found, return the existing behavior\n return (this.textContent ?? '').trim();\n }\n\n render() {\n return html`\n ${!this.hidden\n ? html` <div\n part=\"base\"\n class=${classMap({\n option: true,\n 'option--single-select': !this.isMultipleSelect,\n 'option--current': this.selected && !this.isMultipleSelect,\n 'option--disabled': this.disabled,\n 'option--selected': this.selected && !this.isMultipleSelect,\n 'option--hover': this.hasHover,\n })}\n @mouseenter=${this.handleMouseEnter}\n @mouseleave=${this.handleMouseLeave}\n >\n\n ${this.isMultipleSelect ? html`<nile-checkbox class=\"option--checkbox\" .checked=${this.selected}></nile-checkbox>` : ''}\n\n <slot part=\"prefix\" name=\"prefix\" class=\"option__prefix\"></slot>\n <slot\n part=\"label\"\n class=\"option__label\"\n @slotchange=${this.handleDefaultSlotChange}\n ></slot>\n <slot part=\"suffix\" name=\"suffix\" class=\"option__suffix\"></slot>\n </div>`\n : ''}\n `;\n }\n}\n\nexport default NileOption;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-option': NileOption;\n }\n}\n"]}
1
+ {"version":3,"file":"nile-option.js","sourceRoot":"","sources":["../../../src/nile-option/nile-option.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC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AC,gBAAgB,CAAC;+CAA8B;AAE7C;IAAR,KAAK,EAAE;2CAAiB;AAChB;IAAR,KAAK,EAAE;4CAAkB;AACjB;IAAR,KAAK,EAAE;0CAAgB;AACf;IAAR,KAAK,EAAE;oDAA0B;AAOL;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAY;AAEX;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAA+B;AAGf;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAkB;AAGjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAkB;AAqD7D;IADC,KAAK,CAAC,UAAU,CAAC;sDAGjB;AAGD;IADC,KAAK,CAAC,UAAU,CAAC;sDAGjB;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;mDAed;AAtGU,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAoJtB;;AAED,eAAe,UAAU,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 { LitElement, CSSResultArray, TemplateResult } from 'lit';\nimport { styles } from './nile-option.css';\nimport '../nile-icon';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { html } from 'lit';\nimport { watch } from '../internal/watch';\nimport type { CSSResultGroup, PropertyValues } from 'lit';\nimport NileElement from '../internal/nile-element';\nimport '../nile-checkbox';\n\n/**\n * Nile icon component.\n *\n * @tag nile-option\n *\n */\n\n/**\n * @summary Options define the selectable items within various form controls such as [select](/components/select).\n * @status stable\n *\n * @dependency nile-icon\n *\n * @slot - The option's label.\n * @slot prefix - Used to prepend an icon or similar element to the menu item.\n * @slot suffix - Used to append an icon or similar element to the menu item.\n *\n * @csspart checked-icon - The checked icon, an `<nile-icon>` element.\n * @csspart base - The component's base wrapper.\n * @csspart label - The option's label.\n * @csspart prefix - The container that wraps the prefix.\n * @csspart suffix - The container that wraps the suffix.\n */\n\n@customElement('nile-option')\nexport class NileOption extends NileElement {\n static styles: CSSResultGroup = styles;\n\n private cachedTextLabel: string;\n\n @query('.option__label') defaultSlot: HTMLSlotElement;\n\n @state() current = false; // the user has keyed into the option, but hasn't selected it yet (shows a highlight)\n @state() hasHover = false; // we need this because Safari doesn't honor :hover styles while dragging\n @state() hidden = false; // the option is hidden\n @state() isMultipleSelect = false;\n\n /**\n * The option's value. When selected, the containing form control will receive this value. The value must be unique\n * from other options in the same group. Values may not contain spaces, as spaces are used as delimiters when listing\n * multiple values.\n */\n @property({ reflect: true }) value = '';\n\n @property({ type: Boolean }) showCheckbox: boolean = false;\n\n /** Draws the option in a disabled state, preventing selection. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Indicates whether the option is selected. */\n @property({ type: Boolean, reflect: true }) selected = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'option');\n this.setAttribute('aria-selected', 'false');\n\n // Find the closest parent 'nile-select' or 'nile-virtual-select' element\n const parentSelect = this.closest('nile-select') || this.closest('nile-virtual-select');\n\n // Check if the parent has the 'multiple' attribute\n if (parentSelect && parentSelect.hasAttribute('multiple')) {\n let multipleValue = parentSelect.getAttribute('multiple');\n if (multipleValue !== 'false') {\n if(multipleValue === ''){\n multipleValue = 'true';\n }\n this.isMultipleSelect = Boolean(multipleValue);\n }\n }\n }\n\n protected updated(_changedProperties: PropertyValues): void {\n if(_changedProperties.has('showCheckbox')) {\n this.isMultipleSelect = this.showCheckbox;\n }\n }\n\n private handleDefaultSlotChange() {\n const textLabel = this.getTextLabel();\n\n // Ignore the first time the label is set\n if (typeof this.cachedTextLabel === 'undefined') {\n this.cachedTextLabel = textLabel;\n return;\n }\n\n // When the label changes, emit a slotchange event so parent controls see it\n if (textLabel !== this.cachedTextLabel) {\n this.cachedTextLabel = textLabel;\n this.emit('slotchange');\n }\n }\n\n private handleMouseEnter() {\n this.hasHover = true;\n }\n\n private handleMouseLeave() {\n this.hasHover = false;\n }\n\n @watch('disabled')\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n @watch('selected')\n handleSelectedChange() {\n this.setAttribute('aria-selected', this.selected ? 'true' : 'false');\n }\n\n @watch('value')\n handleValueChange() {\n // Ensure the value is a string. This ensures the next line doesn't error and allows framework users to pass numbers\n // instead of requiring them to cast the value to a string.\n if (typeof this.value !== 'string') {\n this.value = String(this.value);\n }\n\n // if (this.value.includes(' ')) {\n // console.error(\n // `Option values cannot include a space. All spaces have been replaced with underscores.`,\n // this\n // );\n // this.value = this.value.replace(/ /g, '_');\n // }\n }\n\n /** Returns a plain text label based on the option's content. */\n getTextLabel() {\n // Search for a label element inside the component\n const labelElement = this.querySelector('label');\n\n // If a label element is found, return its text content\n if (labelElement) {\n return labelElement.textContent?.trim() ?? '';\n }\n\n // If no label element is found, return the existing behavior\n return (this.textContent ?? '').trim();\n }\n\n render() {\n return html`\n ${!this.hidden\n ? html` <div\n part=\"base\"\n class=${classMap({\n option: true,\n 'option--single-select': !this.isMultipleSelect,\n 'option--current': this.selected && !this.isMultipleSelect,\n 'option--disabled': this.disabled,\n 'option--selected': this.selected && !this.isMultipleSelect,\n 'option--hover': this.hasHover,\n })}\n @mouseenter=${this.handleMouseEnter}\n @mouseleave=${this.handleMouseLeave}\n >\n\n ${this.isMultipleSelect ? html`<nile-checkbox class=\"option--checkbox\" .checked=${this.selected}></nile-checkbox>` : ''}\n\n <slot part=\"prefix\" name=\"prefix\" class=\"option__prefix\"></slot>\n <slot\n part=\"label\"\n class=\"option__label\"\n @slotchange=${this.handleDefaultSlotChange}\n ></slot>\n <slot part=\"suffix\" name=\"suffix\" class=\"option__suffix\"></slot>\n </div>`\n : ''}\n `;\n }\n}\n\nexport default NileOption;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-option': NileOption;\n }\n}\n"]}
@@ -53,7 +53,6 @@ export class VirtualSelectRenderer {
53
53
  <nile-option
54
54
  value=${optionValue}
55
55
  .selected=${isSelected}
56
- .multiple=${multiple}
57
56
  .disabled=${isDisabled}
58
57
  .showCheckbox=${multiple}
59
58
  >
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/nile-virtual-select/renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,OAAO,qBAAqB;IAChC,MAAM,CAAC,qBAAqB,CAC1B,IAAW,EACX,aAAsB,EACtB,kBAAyC,EACzC,KAAwB,EACxB,QAAiB,EACjB,cAAsC,EACtC,YAAoC,EACpC,aAAuB,EACvB,gBAAyB,EACzB,cAAwB;QAExB,OAAO,IAAI,CAAA;oCAEP,aAAa,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EACtD;UACI,aAAa,IAAI,CAAC,cAAc;YAChC,CAAC,CAAC,IAAI,CAAA;;kBAEE,gBAAgB,IAAI,kBAAkB;;aAE3C;YACH,CAAC,CAAC,IAAI,CAAA;;;;kBAIE,qBAAqB,CAAC,oBAAoB,CAAC,IAAI,CAAC;gBAChD,CAAC,CAAC,IAAI,CAAA;wBACA,UAAU,CAAC;oBACX,KAAK,EAAE,IAAI;oBACX,UAAU,EAAE,CAAC,IAAS,EAAkB,EAAE,CACxC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CAAC;oBACtH,QAAQ,EAAE,IAAI;iBACf,CAAC;qBACH;gBACH,CAAC,CAAC,IAAI,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MAAM,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult } from 'lit';\nimport { virtualize } from '@lit-labs/virtualizer/virtualize.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport class VirtualSelectRenderer {\n static getVirtualizedContent(\n data: any[], \n searchEnabled: boolean, \n renderItemFunction: (item: any) => string,\n value: string | string[],\n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string,\n showNoResults?: boolean,\n noResultsMessage?: string,\n optionsLoading?: boolean\n ): TemplateResult {\n return html`\n <div class=\"select__options ${\n searchEnabled ? 'select__options__search-enabled' : ``\n }\">\n ${showNoResults && !optionsLoading\n ? html`\n <div class=\"select__no-results\">\n ${noResultsMessage || 'No results found'}\n </div>\n `\n : html`\n <div\n class=\"virtualized\"\n >\n ${VirtualSelectRenderer.shouldUseVirtualizer(data)\n ? html`\n ${virtualize({\n items: data,\n renderItem: (item: any): TemplateResult =>\n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue),\n scroller: true,\n })}\n `\n : html`\n ${data.map((item: any) => \n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue)\n )}\n `}\n </div>\n `}\n </div>`;\n }\n\n static getItemRenderFunction(\n item: any, \n renderItemFunction: (item: any) => string, \n value: string | string[], \n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string\n ): TemplateResult {\n const displayTextFn = getDisplayText || renderItemFunction;\n const valueFn = getItemValue || ((item: any) => item?.value || item);\n \n const optionValue = valueFn(item);\n const displayText = displayTextFn(item);\n const isDisabled = item.disabled || false;\n \n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.includes(optionValue);\n } else {\n isSelected = (Array.isArray(value) ? value[0] : value) === optionValue;\n }\n \n return html`\n <nile-option \n value=${optionValue} \n .selected=${isSelected} \n .multiple=${multiple}\n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n >\n ${unsafeHTML(displayText)}\n </nile-option>\n `;\n }\n\n /**\n * Determines whether to use virtualizer based on dataset size\n * For small datasets (less than 50 items), use regular rendering for better sizing\n */\n private static shouldUseVirtualizer(data: any[]): boolean {\n return data.length >= 50;\n }\n} \n"]}
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/nile-virtual-select/renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,OAAO,qBAAqB;IAChC,MAAM,CAAC,qBAAqB,CAC1B,IAAW,EACX,aAAsB,EACtB,kBAAyC,EACzC,KAAwB,EACxB,QAAiB,EACjB,cAAsC,EACtC,YAAoC,EACpC,aAAuB,EACvB,gBAAyB,EACzB,cAAwB;QAExB,OAAO,IAAI,CAAA;oCAEP,aAAa,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EACtD;UACI,aAAa,IAAI,CAAC,cAAc;YAChC,CAAC,CAAC,IAAI,CAAA;;kBAEE,gBAAgB,IAAI,kBAAkB;;aAE3C;YACH,CAAC,CAAC,IAAI,CAAA;;;;kBAIE,qBAAqB,CAAC,oBAAoB,CAAC,IAAI,CAAC;gBAChD,CAAC,CAAC,IAAI,CAAA;wBACA,UAAU,CAAC;oBACX,KAAK,EAAE,IAAI;oBACX,UAAU,EAAE,CAAC,IAAS,EAAkB,EAAE,CACxC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CAAC;oBACtH,QAAQ,EAAE,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AC,IAAW;QAC7C,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult } from 'lit';\nimport { virtualize } from '@lit-labs/virtualizer/virtualize.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport class VirtualSelectRenderer {\n static getVirtualizedContent(\n data: any[], \n searchEnabled: boolean, \n renderItemFunction: (item: any) => string,\n value: string | string[],\n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string,\n showNoResults?: boolean,\n noResultsMessage?: string,\n optionsLoading?: boolean\n ): TemplateResult {\n return html`\n <div class=\"select__options ${\n searchEnabled ? 'select__options__search-enabled' : ``\n }\">\n ${showNoResults && !optionsLoading\n ? html`\n <div class=\"select__no-results\">\n ${noResultsMessage || 'No results found'}\n </div>\n `\n : html`\n <div\n class=\"virtualized\"\n >\n ${VirtualSelectRenderer.shouldUseVirtualizer(data)\n ? html`\n ${virtualize({\n items: data,\n renderItem: (item: any): TemplateResult =>\n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue),\n scroller: true,\n })}\n `\n : html`\n ${data.map((item: any) => \n VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue)\n )}\n `}\n </div>\n `}\n </div>`;\n }\n\n static getItemRenderFunction(\n item: any, \n renderItemFunction: (item: any) => string, \n value: string | string[], \n multiple: boolean,\n getDisplayText?: (item: any) => string,\n getItemValue?: (item: any) => string\n ): TemplateResult {\n const displayTextFn = getDisplayText || renderItemFunction;\n const valueFn = getItemValue || ((item: any) => item?.value || item);\n \n const optionValue = valueFn(item);\n const displayText = displayTextFn(item);\n const isDisabled = item.disabled || false;\n \n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.includes(optionValue);\n } else {\n isSelected = (Array.isArray(value) ? value[0] : value) === optionValue;\n }\n \n return html`\n <nile-option \n value=${optionValue} \n .selected=${isSelected} \n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n >\n ${unsafeHTML(displayText)}\n </nile-option>\n `;\n }\n\n /**\n * Determines whether to use virtualizer based on dataset size\n * For small datasets (less than 50 items), use regular rendering for better sizing\n */\n private static shouldUseVirtualizer(data: any[]): boolean {\n return data.length >= 50;\n }\n} \n"]}