@aquera/nile-elements 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/nile-code-editor/extensionSetup.cjs.js +5 -5
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
- package/dist/nile-code-editor/theme.cjs.js +1 -1
- package/dist/nile-code-editor/theme.cjs.js.map +1 -1
- package/dist/nile-code-editor/theme.esm.js +1 -1
- package/dist/nile-form-help-text/index.cjs.js +1 -1
- package/dist/nile-form-help-text/index.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.css.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.css.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.css.esm.js +22 -6
- package/dist/nile-form-help-text/nile-form-help-text.esm.js +20 -16
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/src/nile-code-editor/extensionSetup.js +1 -3
- package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +4 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +24 -2
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +14 -0
- package/dist/src/nile-code-editor/theme.js +14 -0
- package/dist/src/nile-code-editor/theme.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.css.js +22 -6
- package/dist/src/nile-form-help-text/nile-form-help-text.css.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.d.ts +13 -10
- package/dist/src/nile-form-help-text/nile-form-help-text.js +61 -82
- package/dist/src/nile-form-help-text/nile-form-help-text.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.test.js +73 -52
- package/dist/src/nile-form-help-text/nile-form-help-text.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-code-editor/extensionSetup.ts +0 -6
- package/src/nile-code-editor/nile-code-editor.ts +25 -2
- package/src/nile-code-editor/theme.ts +15 -0
- package/src/nile-form-help-text/nile-form-help-text.css.ts +22 -6
- package/src/nile-form-help-text/nile-form-help-text.test.ts +83 -59
- package/src/nile-form-help-text/nile-form-help-text.ts +64 -82
- package/vscode-html-custom-data.json +2 -14
@@ -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
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
expect(
|
17
|
-
|
18
|
-
|
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(
|
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 =
|
24
|
-
const el = await fixture(html `<nile-form-help-text
|
25
|
-
// Simulate
|
26
|
-
const
|
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
|
29
|
-
|
30
|
-
|
31
|
-
expect(textContent).to.
|
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 =
|
39
|
-
const el = await fixture(html `<nile-form-help-text
|
40
|
-
//
|
41
|
-
const
|
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
|
44
|
-
// Collapse
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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;
|
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,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,IAAI,GAAG,CAAC,KAAa,KAAK,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAGpF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAmB,IAAI,CAAA,iEAAiE,CAAC,CAAC;QAClH,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC9C,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAElC,gCAAgC;QAChC,MAAM,WAAW,GAAG,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAC5C,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0EAA0E,EAAE,KAAK,IAAI,EAAE;QACxF,MAAM,EAAE,GAAG,MAAM,OAAO,CAAmB,IAAI,CAAA,iEAAiE,CAAC,CAAC;QAClH,MAAM,cAAc,CAAC,E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AAG,EAAE,CAAC,CAAC;QACpE,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACpE,EAAE,CAAC,wBAAwB,EAAE,CAAC;QAC9B,MAAM,cAAc,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"]}
|