@aquera/nile-elements 0.1.12 → 0.1.14

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.
Files changed (45) hide show
  1. package/README.md +7 -0
  2. package/dist/nile-code-editor/extensionSetup.cjs.js +5 -5
  3. package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
  4. package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
  5. package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
  6. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
  7. package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
  8. package/dist/nile-code-editor/theme.cjs.js +1 -1
  9. package/dist/nile-code-editor/theme.cjs.js.map +1 -1
  10. package/dist/nile-code-editor/theme.esm.js +1 -1
  11. package/dist/nile-form-help-text/index.cjs.js +1 -1
  12. package/dist/nile-form-help-text/index.esm.js +1 -1
  13. package/dist/nile-form-help-text/nile-form-help-text.cjs.js +1 -1
  14. package/dist/nile-form-help-text/nile-form-help-text.cjs.js.map +1 -1
  15. package/dist/nile-form-help-text/nile-form-help-text.css.cjs.js +1 -1
  16. package/dist/nile-form-help-text/nile-form-help-text.css.cjs.js.map +1 -1
  17. package/dist/nile-form-help-text/nile-form-help-text.css.esm.js +22 -6
  18. package/dist/nile-form-help-text/nile-form-help-text.esm.js +20 -16
  19. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  20. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js.map +1 -1
  21. package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
  22. package/dist/src/nile-code-editor/extensionSetup.js +1 -3
  23. package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
  24. package/dist/src/nile-code-editor/nile-code-editor.d.ts +5 -0
  25. package/dist/src/nile-code-editor/nile-code-editor.js +32 -2
  26. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  27. package/dist/src/nile-code-editor/theme.d.ts +24 -0
  28. package/dist/src/nile-code-editor/theme.js +24 -0
  29. package/dist/src/nile-code-editor/theme.js.map +1 -1
  30. package/dist/src/nile-form-help-text/nile-form-help-text.css.js +22 -6
  31. package/dist/src/nile-form-help-text/nile-form-help-text.css.js.map +1 -1
  32. package/dist/src/nile-form-help-text/nile-form-help-text.d.ts +13 -10
  33. package/dist/src/nile-form-help-text/nile-form-help-text.js +61 -82
  34. package/dist/src/nile-form-help-text/nile-form-help-text.js.map +1 -1
  35. package/dist/src/nile-form-help-text/nile-form-help-text.test.js +73 -52
  36. package/dist/src/nile-form-help-text/nile-form-help-text.test.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +1 -1
  39. package/src/nile-code-editor/extensionSetup.ts +0 -6
  40. package/src/nile-code-editor/nile-code-editor.ts +34 -2
  41. package/src/nile-code-editor/theme.ts +28 -0
  42. package/src/nile-form-help-text/nile-form-help-text.css.ts +22 -6
  43. package/src/nile-form-help-text/nile-form-help-text.test.ts +83 -59
  44. package/src/nile-form-help-text/nile-form-help-text.ts +64 -82
  45. package/vscode-html-custom-data.json +2 -14
@@ -1 +1 @@
1
- {"version":3,"file":"nile-form-help-text.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,UAAU,EAAE,IAAI,EAAiC,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AAEjD;;;;;GAKG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QASwC,eAAU,GAAY,KAAK,CAAC;QAE7B,aAAQ,GAAW,EAAE,CAAC;QAEtB,cAAS,GAAW,EAAE,CAAC;QAEvB,kBAAa,GAAW,EAAE,CAAC;IAoEzE,CAAC;IAl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AAgB,CAAC;AAQhC,SAAS,cAAc,CAAC,QAAe,EAAE,CAAQ;IAC/C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,+CAA+C;IAC/C,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC5D,yEAAyE;QACzE,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC9C,IAAI,EAAE,CAAC;QACT,CAAC;QAED,kEAAkE;QAClE,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,KAAK,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1D,KAAK,EAAE,CAAC;QACV,CAAC;QAED,kCAAkC;QAClC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7C,CAAC;IAED,wDAAwD;IACxD,OAAO,CAAC,CAAC;AACX,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, html, CSSResultArray, TemplateResult} from 'lit';\nimport { customElement, query, property } from 'lit/decorators.js';\nimport {styles} from './nile-form-help-text.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-form-help-text\n *\n */\n@customElement('nile-form-help-text')\nexport class NileFormHelpText extends LitElement {\n /**\n * The styles for FormHelpText\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true }) isExpanded: boolean = false;\n\n @property({ type: String, reflect: true }) fullText: string = '';\n\n @property({ type: Number, reflect: true }) textLimit: number = 47;\n\n @property({ type: String, reflect: true }) displayedText: string = '';\n\n @query('slot') slotElement!: HTMLSlotElement;\n\n connectedCallback() {\n super.connectedCallback();\n requestAnimationFrame(() => {\n this.slotElement?.addEventListener('slotchange', this.handleSlotChange.bind(this));\n });\n }\n\n firstUpdated() {\n this.handleSlotChange();\n }\n\n handleSlotChange() {\n const nodes = this.slotElement.assignedNodes({flatten: true});\n const textContent = nodes.map(node => node.textContent).join('');\n this.fullText = textContent.trim();\n this.updateDisplayedText()\n }\n\n toggleExpanded() {\n this.isExpanded = !this.isExpanded;\n this.updateDisplayedText()\n }\n\n updateDisplayedText() {\n if (this.isExpanded) {\n this.displayedText = this.fullText;\n } else {\n const validConcatNumber=concatSentence(this.fullText, this.textLimit)\n const truncatedText = this.fullText.slice(0, validConcatNumber);\n const ellipsis = this.fullText.length > validConcatNumber ? '...' : '';\n this.displayedText = `${truncatedText}${ellipsis}`;\n }\n }\n\n /* #endregion */\n\n /* #region Methods */\n\n /**\n * Render method\n * @slot This is a slot test\n */\n public render(): TemplateResult {\n const showMoreButton = this.fullText.length > this.textLimit;\n const iconName = this.isExpanded ? 'arrowup' : 'arrowdown';\n\n return html`\n <div class=\"nile-form-help-text\" part=\"container\">\n <slot hidden>${this.fullText}</slot>\n <div part=\"text\">\n <span>${this.displayedText}</span>\n ${showMoreButton ? html`\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=${this.toggleExpanded}\n >${this.isExpanded ? 'View Less' : 'View More'}\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"${iconName}\"></nile-icon>\n </span>\n ` : ''}\n </div>\n </div>\n `;\n }\n}\n\nexport default NileFormHelpText;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-form-help-text': NileFormHelpText;\n }\n}\n\nfunction concatSentence(sentence:string, n:number) {\n if (n < 0 || n > sentence.length) {\n return n;\n }\n\n // Adjust n if it falls in the middle of a word\n if (sentence[n] !== \" \" && n !== 0 && n !== sentence.length) {\n // Move left until the start of the word or the beginning of the sentence\n let left = n;\n while (left > 0 && sentence[left - 1] !== \" \") {\n left--;\n }\n\n // Move right until the end of the word or the end of the sentence\n let right = n;\n while (right < sentence.length && sentence[right] !== \" \") {\n right++;\n }\n\n // Adjust n to the closer boundary\n n = (n - left <= right - n) ? left : right;\n }\n\n // Return the substring from the start to the adjusted n\n return n;\n}\n"]}
1
+ {"version":3,"file":"nile-form-help-text.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,UAAU,EAAE,IAAI,EAAkC,OAAO,EAAiB,MAAM,KAAK,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;;GAKG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QASwC,eAAU,GAAY,KAAK,CAAC;QAEhE,eAAU,GAAY,KAAK,CAAC;IAgFvC,CAAC;IA1FC;;;OAGG;IACI,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAUD,gBAAgB;IAEhB,qBAAqB;IAEX,YAAY,CAAC,kBAAkC;QACvD,IAAI,CAAC,cAAc,GAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClE,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IACnC,C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hC,OAAO,cAAc,CAAC,CAAC,mDAAmD;IAC5E,CAAC;CACF,CAAA;AAlF8C;IAA5C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAG,CAAC;oDAA6B;AAEhE;IAAR,KAAK,EAAE;oDAA6B;AAET;IAA3B,KAAK,CAAC,mBAAmB,CAAC;uDAA+B;AAb/C,gBAAgB;IAD5B,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CA2F5B;;AAED,eAAe,gBAAgB,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, html, CSSResultArray, TemplateResult, nothing, PropertyValues} from 'lit';\nimport { customElement, query, property, state } from 'lit/decorators.js';\nimport {styles} from './nile-form-help-text.css';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/**\n * Nile icon component.\n *\n * @tag nile-form-help-text\n *\n */\n@customElement('nile-form-help-text')\nexport class NileFormHelpText extends LitElement {\n /**\n * The styles for FormHelpText\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true }) isExpanded: boolean = false;\n\n @state() showButton: boolean = false;\n\n @query('.help__text__full') textContainer:HTMLSpanElement;\n\n private resizeObserver:ResizeObserver;\n\n /* #endregion */\n\n /* #region Methods */\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n this.resizeObserver=this.observeWidthChange(this.textContainer);\n }\n\n disconnectedCallback(): void {\n this.resizeObserver.disconnect();\n }\n\n /**\n * Render method\n * @slot This is a slot test\n */\n public render(): TemplateResult {\n const iconName = this.isExpanded ? 'arrowup' : 'arrowdown';\n\n return html`\n <div \n class=\"${classMap({\n 'nile-form-help-text':true,\n \"nile-form-help-text--expanded\":this.isExpanded\n })}\" \n part=\"container\"\n >\n <span\n class=\"${classMap({\n \"help__text__full\":true,\n \"help__text__full--expanded\":this.isExpanded\n })}\"\n >\n <slot @slotchange=\"${this.decideToToggleShowButton}\"></slot>\n </span>\n ${this.showButton?html`\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=${this.toggleExpanded}\n >${this.isExpanded ? 'View Less' : 'View More'}\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"${iconName}\"></nile-icon>\n </span>\n `:nothing}\n </div>\n `;\n }\n\n toggleExpanded() {\n this.isExpanded = !this.isExpanded;\n }\n \n decideToToggleShowButton(){\n if(!this.textContainer) return;\n this.showButton=this.textContainer.clientWidth<this.textContainer.scrollWidth\n }\n\n /**\n * Logs whenever the width of an element changes.\n * @param {HTMLElement} element - The element to observe for width changes.\n */\n observeWidthChange(element:HTMLElement) {\n\n const resizeObserver = new ResizeObserver(entries => {\n for (let entry of entries) {\n const newWidth = entry.contentRect.width;\n if (newWidth) this.decideToToggleShowButton();\n }\n });\n\n resizeObserver.observe(element);\n\n return resizeObserver; // Return observer to allow disconnection if needed\n }\n}\n\nexport default NileFormHelpText;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-form-help-text': NileFormHelpText;\n }\n}"]}
@@ -1,67 +1,88 @@
1
- import { fixture, expect, html } from '@open-wc/testing';
1
+ import { fixture, expect, html, elementUpdated } from '@open-wc/testing';
2
2
  import './nile-form-help-text';
3
+ import { NileFormHelpText } from './nile-form-help-text';
3
4
  const wait = (ms = 50000) => new Promise(resolve => setTimeout(resolve, ms));
4
5
  describe('NileFormHelpText', () => {
5
6
  it('should render with default properties', async () => {
6
- const el = await fixture(html `<nile-form-help-text>This is a very short text</nile-form-help-text>`);
7
- // Check if the displayed text is empty initially (no content in slot)
8
- const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
9
- expect(textContent).to.equal('This is a very short text');
7
+ const el = await fixture(html `<nile-form-help-text>This is a short text</nile-form-help-text>`);
8
+ expect(el).to.be.instanceOf(NileFormHelpText);
9
+ expect(el.isExpanded).to.be.false;
10
+ // Check if text content matches
11
+ const textContent = el?.textContent?.trim();
12
+ expect(textContent).to.equal('This is a short text');
10
13
  });
11
- it('should truncate the text if it exceeds textLimit and show "View More" button', async () => {
12
- const longText = "This is a very long help text that should be truncated and should show a 'View More' button.";
13
- const el = await fixture(html `<nile-form-help-text><span>${longText}</span></nile-form-help-text>`);
14
- // Check if the displayed text is truncated
15
- const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
16
- expect(textContent?.endsWith('...')).to.be.true;
17
- // Check if the "View More" button is visible
18
- const moreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
14
+ it('should not show "View More" button if the text fits within the container', async () => {
15
+ const el = await fixture(html `<nile-form-help-text>This is a short text</nile-form-help-text>`);
16
+ await elementUpdated(el);
17
+ const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
18
+ expect(moreButton).to.be.null;
19
+ expect(el.showButton).to.be.false;
20
+ });
21
+ it('should show "View More" button if the text overflows the container', async () => {
22
+ const longText = 'This is a very long help text that exceeds the container width and should show a "View More" button.';
23
+ const el = await fixture(html `<nile-form-help-text>${longText}</nile-form-help-text>`);
24
+ // Simulate overflow
25
+ const textContainer = el.shadowRoot?.querySelector('.help__text__full');
26
+ Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
27
+ Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
28
+ el.decideToToggleShowButton();
29
+ await elementUpdated(el);
30
+ const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
19
31
  expect(moreButton).to.exist;
20
- expect(moreButton?.textContent).to.include('View More');
32
+ expect(el.showButton).to.be.true;
21
33
  });
22
34
  it('should expand to show full text when "View More" is clicked', async () => {
23
- const longText = "This is a very long help text that should be truncated and should show a 'View More' button.";
24
- const el = await fixture(html `<nile-form-help-text><span>${longText}</span></nile-form-help-text>`);
25
- // Simulate clicking the "View More" button
26
- const moreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
35
+ const longText = 'This is a very long help text that exceeds the container width and should show a "View More" button.';
36
+ const el = await fixture(html `<nile-form-help-text>${longText}</nile-form-help-text>`);
37
+ // Simulate overflow
38
+ const textContainer = el.shadowRoot?.querySelector('.help__text__full');
39
+ Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
40
+ Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
41
+ el.decideToToggleShowButton();
42
+ await elementUpdated(el);
43
+ // Click "View More"
44
+ const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
27
45
  moreButton?.click();
28
- await el.updateComplete;
29
- // Verify that the full text is displayed
30
- const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
31
- expect(textContent).to.equal(longText);
32
- // Check if the "View Less" button is now visible
33
- const lessButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
34
- expect(lessButton).to.exist;
35
- expect(lessButton?.textContent).to.include('View Less');
46
+ await elementUpdated(el);
47
+ expect(el.isExpanded).to.be.true;
48
+ expect(textContainer).to.have.class('help__text__full--expanded');
49
+ expect(moreButton?.textContent).to.include('View Less');
36
50
  });
37
51
  it('should collapse back to truncated text when "View Less" is clicked', async () => {
38
- const longText = "This is a very long help text that should be truncated and should show a 'View More' button.";
39
- const el = await fixture(html `<nile-form-help-text><span>${longText}</span></nile-form-help-text>`);
40
- // Expand the text
41
- const moreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
52
+ const longText = 'This is a very long help text that exceeds the container width and should show a "View More" button.';
53
+ const el = await fixture(html `<nile-form-help-text>${longText}</nile-form-help-text>`);
54
+ // Simulate overflow
55
+ const textContainer = el.shadowRoot?.querySelector('.help__text__full');
56
+ Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
57
+ Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
58
+ el.decideToToggleShowButton();
59
+ await elementUpdated(el);
60
+ // Expand and then collapse
61
+ const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
42
62
  moreButton?.click();
43
- await el.updateComplete;
44
- // Collapse the text by clicking "View Less"
45
- const lessButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
46
- lessButton?.click();
47
- await el.updateComplete;
48
- // Verify that the text is truncated again
49
- const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
50
- expect(textContent?.endsWith('...')).to.be.true;
51
- // Check if the "View More" button is visible again
52
- const viewMoreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
53
- expect(viewMoreButton).to.exist;
54
- expect(viewMoreButton?.textContent).to.include('View More');
55
- });
56
- it('should not show "View More" button when text is within limit', async () => {
57
- const shortText = "Short help text.";
58
- const el = await fixture(html `<nile-form-help-text><span>${shortText}</span></nile-form-help-text>`);
59
- // Check if the displayed text is not truncated
60
- const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
61
- expect(textContent).to.equal(shortText);
62
- // Verify that "View More" button is not rendered
63
- const moreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
64
- expect(moreButton).to.be.null;
63
+ await elementUpdated(el);
64
+ moreButton?.click(); // Collapse
65
+ await elementUpdated(el);
66
+ expect(el.isExpanded).to.be.false;
67
+ expect(textContainer).not.to.have.class('help__text__full--expanded');
68
+ expect(moreButton?.textContent).to.include('View More');
65
69
  });
70
+ // it('should dynamically adjust "View More" visibility on text change', async () => {
71
+ // const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>Initial text</nile-form-help-text>`);
72
+ // await elementUpdated(el);
73
+ // const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;
74
+ // Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
75
+ // Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
76
+ // el.decideToToggleShowButton();
77
+ // await elementUpdated(el);
78
+ // expect(el.showButton).to.be.true;
79
+ // // Change slot content to short text
80
+ // textContainer.textContent = 'Short text';
81
+ // Object.defineProperty(textContainer, 'scrollWidth', { value: 100 });
82
+ // Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
83
+ // el.decideToToggleShowButton();
84
+ // await elementUpdated(el);
85
+ // expect(el.showButton).to.be.false;
86
+ // });
66
87
  });
67
88
  //# sourceMappingURL=nile-form-help-text.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-form-help-text.test.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,uBAAuB,CAAC;AAG/B,MAAM,IAAI,GAAG,CAAC,KAAa,KAAK,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAEpF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,EAAE,GAAqB,MAAM,OAAO,CAAC,IAAI,CAAA,sEAAsE,CAAC,CAAC;QAEvH,sEAAsE;QACtE,MAAM,WAAW,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,sBAAsB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;QAC7F,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,KAAK,IAAI,EAAE;QAC5F,MAAM,QAAQ,GAAG,8FAA8F,CAAC;QAChH,MAAM,EAAE,GAAqB,MAAM,OAAO,CAAC,IAAI,CAAA,8BAA8B,QAAQ,+BAA+B,CAAC,CAAC;QAEtH,2CAA2C;QAC3C,MAAM,WAAW,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,sBAAsB,CAAC,EAAE,WAAW,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,WAAW,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,sBAAsB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;QAC7F,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAExC,iDAAiD;QACjD,MAAM,UAAU,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC;QACrF,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAChC,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, html } from '@open-wc/testing';\nimport './nile-form-help-text';\nimport { NileFormHelpText } from './nile-form-help-text';\n\nconst wait = (ms: number = 50000) => new Promise(resolve => setTimeout(resolve, ms))\n\ndescribe('NileFormHelpText', () => {\n it('should render with default properties', async () => {\n const el: NileFormHelpText = await fixture(html`<nile-form-help-text>This is a very short text</nile-form-help-text>`);\n \n // Check if the displayed text is empty initially (no content in slot)\n const textContent = el.shadowRoot!.querySelector('div>span:first-child')?.textContent?.trim()\n expect(textContent).to.equal('This is a very short text');\n });\n\n it('should truncate the text if it exceeds textLimit and show \"View More\" button', async () => {\n const longText = \"This is a very long help text that should be truncated and should show a 'View More' button.\";\n const el: NileFormHelpText = await fixture(html`<nile-form-help-text><span>${longText}</span></nile-form-help-text>`);\n \n // Check if the displayed text is truncated\n const textContent = el.shadowRoot!.querySelector('div>span:first-child')?.textContent?.trim()\n expect(textContent?.endsWith('...')).to.be.true;\n \n // Check if the \"View More\" button is visible\n const moreButton = el.shadowRoot!.querySelector('.nile-form-help-text__more-button');\n expect(moreButton).to.exist;\n expect(moreButton?.textContent).to.include('View More');\n });\n\n it('should expand to show full text when \"View More\" is clicked', async () => {\n const longText = \"This is a very long help text that should be truncated and should show a 'View More' button.\";\n const el: NileFormHelpText = await fixture(html`<nile-form-help-text><span>${longText}</span></nile-form-help-text>`);\n \n // Simulate clicking the \"View More\" button\n const moreButton = el.shadowRoot!.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n moreButton?.click();\n await el.updateComplete;\n\n // Verify that the full text is displayed\n const textContent = el.shadowRoot!.querySelector('div>span:first-child')?.textContent?.trim()\n expect(textContent).to.equal(longText);\n \n // Check if the \"View Less\" button is now visible\n const lessButton = el.shadowRoot!.querySelector('.nile-form-help-text__more-button');\n expect(lessButton).to.exist;\n expect(lessButton?.textContent).to.include('View Less');\n });\n\n it('should collapse back to truncated text when \"View Less\" is clicked', async () => {\n const longText = \"This is a very long help text that should be truncated and should show a 'View More' button.\";\n const el: NileFormHelpText = await fixture(html`<nile-form-help-text><span>${longText}</span></nile-form-help-text>`);\n \n // Expand the text\n const moreButton = el.shadowRoot!.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n moreButton?.click();\n await el.updateComplete;\n\n // Collapse the text by clicking \"View Less\"\n const lessButton = el.shadowRoot!.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n lessButton?.click();\n await el.updateComplete;\n\n // Verify that the text is truncated again\n const textContent = el.shadowRoot!.querySelector('div>span:first-child')?.textContent?.trim()\n expect(textContent?.endsWith('...')).to.be.true;\n \n // Check if the \"View More\" button is visible again\n const viewMoreButton = el.shadowRoot!.querySelector('.nile-form-help-text__more-button');\n expect(viewMoreButton).to.exist;\n expect(viewMoreButton?.textContent).to.include('View More');\n });\n\n it('should not show \"View More\" button when text is within limit', async () => {\n const shortText = \"Short help text.\";\n const el: NileFormHelpText = await fixture(html`<nile-form-help-text><span>${shortText}</span></nile-form-help-text>`);\n \n // Check if the displayed text is not truncated\n const textContent = el.shadowRoot!.querySelector('div>span:first-child')?.textContent?.trim()\n expect(textContent).to.equal(shortText);\n\n // Verify that \"View More\" button is not rendered\n const moreButton = el.shadowRoot!.querySelector('.nile-form-help-text__more-button');\n expect(moreButton).to.be.null;\n });\n\n});\n"]}
1
+ {"version":3,"file":"nile-form-help-text.test.js","sourceRoot":"","sources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Ac,CAAC,EAAE,CAAC,CAAC;QAEzB,2BAA2B;QAC3B,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,EAAE,aAAa,CAAc,mCAAmC,CAAC,CAAC;QAClG,UAAU,EAAE,KAAK,EAAE,CAAC;QACpB,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW;QAChC,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAClC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACtE,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,sFAAsF;IACtF,+GAA+G;IAC/G,8BAA8B;IAE9B,gGAAgG;IAChG,yEAAyE;IACzE,yEAAyE;IACzE,mCAAmC;IACnC,8BAA8B;IAE9B,sCAAsC;IAEtC,yCAAyC;IACzC,8CAA8C;IAC9C,yEAAyE;IACzE,yEAAyE;IACzE,mCAAmC;IACnC,8BAA8B;IAE9B,uCAAuC;IACvC,MAAM;AACR,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, html, elementUpdated } from '@open-wc/testing';\nimport './nile-form-help-text';\nimport { NileFormHelpText } from './nile-form-help-text';\n\nconst wait = (ms: number = 50000) => new Promise(resolve => setTimeout(resolve, ms))\n\n\ndescribe('NileFormHelpText', () => {\n it('should render with default properties', async () => {\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>This is a short text</nile-form-help-text>`);\n expect(el).to.be.instanceOf(NileFormHelpText);\n expect(el.isExpanded).to.be.false;\n\n // Check if text content matches\n const textContent = el?.textContent?.trim();\n expect(textContent).to.equal('This is a short text');\n });\n\n it('should not show \"View More\" button if the text fits within the container', async () => {\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>This is a short text</nile-form-help-text>`);\n await elementUpdated(el);\n\n const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');\n expect(moreButton).to.be.null;\n expect(el.showButton).to.be.false;\n });\n\n it('should show \"View More\" button if the text overflows the container', async () => {\n const longText = 'This is a very long help text that exceeds the container width and should show a \"View More\" button.';\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>${longText}</nile-form-help-text>`);\n \n // Simulate overflow\n const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n el.decideToToggleShowButton();\n await elementUpdated(el);\n\n const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');\n expect(moreButton).to.exist;\n expect(el.showButton).to.be.true;\n });\n\n it('should expand to show full text when \"View More\" is clicked', async () => {\n const longText = 'This is a very long help text that exceeds the container width and should show a \"View More\" button.';\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>${longText}</nile-form-help-text>`);\n\n // Simulate overflow\n const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n el.decideToToggleShowButton();\n await elementUpdated(el);\n\n // Click \"View More\"\n const moreButton = el.shadowRoot?.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n moreButton?.click();\n await elementUpdated(el);\n\n expect(el.isExpanded).to.be.true;\n expect(textContainer).to.have.class('help__text__full--expanded');\n expect(moreButton?.textContent).to.include('View Less');\n });\n\n it('should collapse back to truncated text when \"View Less\" is clicked', async () => {\n const longText = 'This is a very long help text that exceeds the container width and should show a \"View More\" button.';\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>${longText}</nile-form-help-text>`);\n\n // Simulate overflow\n const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n el.decideToToggleShowButton();\n await elementUpdated(el);\n\n // Expand and then collapse\n const moreButton = el.shadowRoot?.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n moreButton?.click();\n await elementUpdated(el);\n\n moreButton?.click(); // Collapse\n await elementUpdated(el);\n\n expect(el.isExpanded).to.be.false;\n expect(textContainer).not.to.have.class('help__text__full--expanded');\n expect(moreButton?.textContent).to.include('View More');\n });\n\n // it('should dynamically adjust \"View More\" visibility on text change', async () => {\n // const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>Initial text</nile-form-help-text>`);\n // await elementUpdated(el);\n\n // const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n // Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n // Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n // el.decideToToggleShowButton();\n // await elementUpdated(el);\n\n // expect(el.showButton).to.be.true;\n\n // // Change slot content to short text\n // textContainer.textContent = 'Short text';\n // Object.defineProperty(textContainer, 'scrollWidth', { value: 100 });\n // Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n // el.decideToToggleShowButton();\n // await elementUpdated(el);\n\n // expect(el.showButton).to.be.false;\n // });\n});\n"]}