@3t-transform/threeteeui 0.0.23 → 0.0.24
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/dist/cjs/{index-2943e8f8.js → index-bc080fb4.js} +64 -89
- package/dist/cjs/loader.cjs.js +3 -4
- package/dist/cjs/tttx-button.cjs.entry.js +1 -1
- package/dist/cjs/tttx-icon.cjs.entry.js +1 -1
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +5 -8
- package/dist/cjs/tttx-list.cjs.entry.js +34 -0
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +1 -1
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +1 -2
- package/dist/cjs/tttx-table.cjs.entry.js +60 -0
- package/dist/cjs/tttx.cjs.js +3 -7
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/atoms/tttx-button/test/tttx-button.e2e.js +9 -0
- package/dist/collection/components/atoms/tttx-button/test/tttx-button.spec.js +43 -0
- package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.e2e.js +9 -0
- package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.spec.js +16 -0
- package/dist/collection/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.js +164 -0
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +4 -7
- package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js +64 -0
- package/dist/collection/components/molecules/tttx-list/test/tttx-list.spec.js +151 -0
- package/dist/collection/components/molecules/tttx-list/tttx-list.css +53 -0
- package/dist/collection/components/molecules/tttx-list/tttx-list.js +79 -0
- package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +39 -0
- package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.js +9 -0
- package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.js +146 -0
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +0 -1
- package/dist/collection/components/molecules/tttx-table/test/tttx-table.e2e.js +9 -0
- package/dist/collection/components/molecules/tttx-table/tttx-table.css +166 -0
- package/dist/collection/components/molecules/tttx-table/tttx-table.js +174 -0
- package/dist/collection/components/molecules/tttx-table/tttx-table.stories.js +81 -0
- package/dist/components/index.d.ts +2 -9
- package/dist/components/index.js +3 -1
- package/dist/components/tttx-keyvalue-block.js +4 -7
- package/dist/components/tttx-list.d.ts +11 -0
- package/dist/components/tttx-list.js +56 -0
- package/dist/components/tttx-standalone-input.js +0 -1
- package/dist/components/tttx-table.d.ts +11 -0
- package/dist/components/tttx-table.js +85 -0
- package/dist/esm/{index-058a3cd0.js → index-901bfd55.js} +65 -89
- package/dist/esm/loader.js +3 -4
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/tttx-button.entry.js +1 -1
- package/dist/esm/tttx-icon.entry.js +1 -1
- package/dist/esm/tttx-keyvalue-block.entry.js +5 -8
- package/dist/esm/tttx-list.entry.js +30 -0
- package/dist/esm/tttx-loading-spinner.entry.js +1 -1
- package/dist/esm/tttx-standalone-input.entry.js +1 -2
- package/dist/esm/tttx-table.entry.js +56 -0
- package/dist/esm/tttx.js +3 -4
- package/dist/tttx/{p-046868d9.entry.js → p-0ae51ec5.entry.js} +1 -1
- package/dist/tttx/p-1ec23160.entry.js +1 -0
- package/dist/tttx/p-300ff6a8.entry.js +1 -0
- package/dist/tttx/p-32ad02d3.entry.js +1 -0
- package/dist/tttx/p-80cf5236.entry.js +1 -0
- package/dist/tttx/{p-495cf4b3.entry.js → p-9a382959.entry.js} +1 -1
- package/dist/tttx/p-a1bd16a1.entry.js +1 -0
- package/dist/tttx/{p-1adb2b75.entry.js → p-a4077908.entry.js} +1 -1
- package/dist/tttx/p-a6953900.entry.js +1 -0
- package/dist/tttx/p-b46e3c59.entry.js +1 -0
- package/dist/tttx/p-c290160b.js +2 -0
- package/dist/tttx/p-dc179257.entry.js +1 -0
- package/dist/tttx/p-e19eb07e.entry.js +1 -0
- package/dist/tttx/p-e4341658.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/atoms/tttx-button/test/tttx-button.e2e.d.ts +1 -0
- package/dist/types/components/atoms/tttx-button/test/tttx-button.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-icon/test/tttx-icon.e2e.d.ts +1 -0
- package/dist/types/components/atoms/tttx-icon/test/tttx-icon.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-list/interfaces.d.ts +4 -0
- package/dist/types/components/molecules/tttx-list/test/tttx-list.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +9 -0
- package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +7 -0
- package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.d.ts +1 -0
- package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +6 -6
- package/dist/types/components/molecules/tttx-table/test/tttx-table.e2e.d.ts +1 -0
- package/dist/types/components/molecules/tttx-table/tttx-table.d.ts +15 -0
- package/dist/types/components/molecules/tttx-table/tttx-table.stories.d.ts +21 -0
- package/dist/types/components.d.ts +48 -0
- package/dist/types/stencil-public-runtime.d.ts +3 -59
- package/loader/index.d.ts +0 -9
- package/package.json +2 -1
- package/readme.md +20 -0
- package/dist/tttx/p-a4d9929a.entry.js +0 -1
- package/dist/tttx/p-ad637dde.entry.js +0 -1
- package/dist/tttx/p-bbb7dbf7.js +0 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { TttxKeyvalueBlock } from '../tttx-keyvalue-block';
|
|
3
|
+
describe('tttx-keyvalue-block', () => {
|
|
4
|
+
it('renders multiple key value pairs', async () => {
|
|
5
|
+
const keyValuePair = {
|
|
6
|
+
'Name': 'John Doe',
|
|
7
|
+
'Date of birth': '14 Jan 1981',
|
|
8
|
+
'Start of postcode': 'AB10'
|
|
9
|
+
};
|
|
10
|
+
const page = await newSpecPage({
|
|
11
|
+
components: [TttxKeyvalueBlock],
|
|
12
|
+
html: `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValuePair)}' />`
|
|
13
|
+
});
|
|
14
|
+
await page.waitForChanges();
|
|
15
|
+
expect(page.root).toEqualHtml(`
|
|
16
|
+
<tttx-keyvalue-block keyvalues='{"Name":"John Doe","Date of birth":"14 Jan 1981","Start of postcode":"AB10"}'>
|
|
17
|
+
<mock:shadow-root>
|
|
18
|
+
<dl>
|
|
19
|
+
<dt>
|
|
20
|
+
Name
|
|
21
|
+
</dt>
|
|
22
|
+
<dd>
|
|
23
|
+
John Doe
|
|
24
|
+
</dd>
|
|
25
|
+
<dt>
|
|
26
|
+
Date of birth
|
|
27
|
+
</dt>
|
|
28
|
+
<dd>
|
|
29
|
+
14 Jan 1981
|
|
30
|
+
</dd>
|
|
31
|
+
<dt>
|
|
32
|
+
Start of postcode
|
|
33
|
+
</dt>
|
|
34
|
+
<dd>
|
|
35
|
+
AB10
|
|
36
|
+
</dd>
|
|
37
|
+
</dl>
|
|
38
|
+
</mock:shadow-root>
|
|
39
|
+
</tttx-keyvalue-block>
|
|
40
|
+
`);
|
|
41
|
+
});
|
|
42
|
+
it('renders an array of key value subtitles', async () => {
|
|
43
|
+
const keyValueArray = [
|
|
44
|
+
{ title: "title", subTitle: "sub", data: "data" },
|
|
45
|
+
{ title: "title2", subTitle: "sub2", data: "data2" }
|
|
46
|
+
];
|
|
47
|
+
const page = await newSpecPage({
|
|
48
|
+
components: [TttxKeyvalueBlock],
|
|
49
|
+
html: `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValueArray)}' />`
|
|
50
|
+
});
|
|
51
|
+
await page.waitForChanges();
|
|
52
|
+
expect(page.root).toEqualHtml(`
|
|
53
|
+
<tttx-keyvalue-block keyvalues='[{"title":"title","subTitle":"sub","data":"data"},{"title":"title2","subTitle":"sub2","data":"data2"}]'>
|
|
54
|
+
<mock:shadow-root>
|
|
55
|
+
<dl>
|
|
56
|
+
<dt class="mainTitle">
|
|
57
|
+
title
|
|
58
|
+
</dt>
|
|
59
|
+
<dt class="subTitle">
|
|
60
|
+
sub
|
|
61
|
+
</dt>
|
|
62
|
+
<dd>
|
|
63
|
+
data
|
|
64
|
+
</dd>
|
|
65
|
+
<dt class="mainTitle">
|
|
66
|
+
title2
|
|
67
|
+
</dt>
|
|
68
|
+
<dt class="subTitle">
|
|
69
|
+
sub2
|
|
70
|
+
</dt>
|
|
71
|
+
<dd>
|
|
72
|
+
data2
|
|
73
|
+
</dd>
|
|
74
|
+
</dl>
|
|
75
|
+
</mock:shadow-root>
|
|
76
|
+
</tttx-keyvalue-block>
|
|
77
|
+
`);
|
|
78
|
+
});
|
|
79
|
+
it('renders multiple horizontal key value pairs', async () => {
|
|
80
|
+
const keyValuePair = {
|
|
81
|
+
'Name': 'John Doe',
|
|
82
|
+
'Date of birth': '14 Jan 1981',
|
|
83
|
+
'Start of postcode': 'AB10'
|
|
84
|
+
};
|
|
85
|
+
const page = await newSpecPage({
|
|
86
|
+
components: [TttxKeyvalueBlock],
|
|
87
|
+
html: `<tttx-keyvalue-block horizontal="true" keyvalues='${JSON.stringify(keyValuePair)}' />`
|
|
88
|
+
});
|
|
89
|
+
await page.waitForChanges();
|
|
90
|
+
expect(page.root).toEqualHtml(`
|
|
91
|
+
<tttx-keyvalue-block horizontal="true" keyvalues='{"Name":"John Doe","Date of birth":"14 Jan 1981","Start of postcode":"AB10"}'>
|
|
92
|
+
<mock:shadow-root>
|
|
93
|
+
<dl class="horizontal">
|
|
94
|
+
<div>
|
|
95
|
+
<dt>
|
|
96
|
+
Name
|
|
97
|
+
</dt>
|
|
98
|
+
<dd>
|
|
99
|
+
John Doe
|
|
100
|
+
</dd>
|
|
101
|
+
</div>
|
|
102
|
+
<div>
|
|
103
|
+
<dt>
|
|
104
|
+
Date of birth
|
|
105
|
+
</dt>
|
|
106
|
+
<dd>
|
|
107
|
+
14 Jan 1981
|
|
108
|
+
</dd>
|
|
109
|
+
</div>
|
|
110
|
+
<div>
|
|
111
|
+
<dt>
|
|
112
|
+
Start of postcode
|
|
113
|
+
</dt>
|
|
114
|
+
<dd>
|
|
115
|
+
AB10
|
|
116
|
+
</dd>
|
|
117
|
+
</div>
|
|
118
|
+
</dl>
|
|
119
|
+
</mock:shadow-root>
|
|
120
|
+
</tttx-keyvalue-block>
|
|
121
|
+
`);
|
|
122
|
+
});
|
|
123
|
+
it('renders an array of horizontal key value subtitles', async () => {
|
|
124
|
+
const keyValueArray = [
|
|
125
|
+
{ title: "title", subTitle: "sub", data: "data" },
|
|
126
|
+
{ title: "title2", subTitle: "sub2", data: "data2" }
|
|
127
|
+
];
|
|
128
|
+
const page = await newSpecPage({
|
|
129
|
+
components: [TttxKeyvalueBlock],
|
|
130
|
+
html: `<tttx-keyvalue-block horizontal="true" keyvalues='${JSON.stringify(keyValueArray)}' />`
|
|
131
|
+
});
|
|
132
|
+
await page.waitForChanges();
|
|
133
|
+
expect(page.root).toEqualHtml(`
|
|
134
|
+
<tttx-keyvalue-block horizontal="true" keyvalues='[{"title":"title","subTitle":"sub","data":"data"},{"title":"title2","subTitle":"sub2","data":"data2"}]'>
|
|
135
|
+
<mock:shadow-root>
|
|
136
|
+
<dl class="horizontal">
|
|
137
|
+
<div>
|
|
138
|
+
<dt class="mainTitle">
|
|
139
|
+
title
|
|
140
|
+
</dt>
|
|
141
|
+
<dt class="subTitle">
|
|
142
|
+
sub
|
|
143
|
+
</dt>
|
|
144
|
+
<dd>
|
|
145
|
+
data
|
|
146
|
+
</dd>
|
|
147
|
+
</div>
|
|
148
|
+
<div>
|
|
149
|
+
<dt class="mainTitle">
|
|
150
|
+
title2
|
|
151
|
+
</dt>
|
|
152
|
+
<dt class="subTitle">
|
|
153
|
+
sub2
|
|
154
|
+
</dt>
|
|
155
|
+
<dd>
|
|
156
|
+
data2
|
|
157
|
+
</dd>
|
|
158
|
+
</div>
|
|
159
|
+
</dl>
|
|
160
|
+
</mock:shadow-root>
|
|
161
|
+
</tttx-keyvalue-block>
|
|
162
|
+
`);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -24,20 +24,17 @@ export class TttxKeyvalueBlock {
|
|
|
24
24
|
for (let i = 0; i < values.length; i++) {
|
|
25
25
|
const value = values[i];
|
|
26
26
|
if (this.horizontal) {
|
|
27
|
-
elements.push(h("div", null, h("dt", { class:
|
|
27
|
+
elements.push(h("div", null, h("dt", { class: "mainTitle" }, value.title), h("dt", { class: "subTitle" }, value.subTitle), h("dd", null, value.data)));
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
elements.push(h("dt", { class:
|
|
31
|
-
elements.push(h("dt", { class:
|
|
30
|
+
elements.push(h("dt", { class: "mainTitle" }, value.title));
|
|
31
|
+
elements.push(h("dt", { class: "subTitle" }, value.subTitle));
|
|
32
32
|
elements.push(h("dd", null, value.data));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return elements;
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
|
-
if (!this.keyvalues) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
38
|
let values;
|
|
42
39
|
if (typeof this.keyvalues === 'string') {
|
|
43
40
|
values = JSON.parse(this.keyvalues);
|
|
@@ -52,7 +49,7 @@ export class TttxKeyvalueBlock {
|
|
|
52
49
|
else {
|
|
53
50
|
elements = this.renderSingleElements(values);
|
|
54
51
|
}
|
|
55
|
-
return (h(Host, null, h("dl", { class: this.horizontal ?
|
|
52
|
+
return (h(Host, null, h("dl", { class: this.horizontal ? "horizontal" : null }, elements)));
|
|
56
53
|
}
|
|
57
54
|
static get is() { return "tttx-keyvalue-block"; }
|
|
58
55
|
static get encapsulation() { return "shadow"; }
|
package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { TttxLoadingSpinner } from '../tttx-loading-spinner';
|
|
3
|
+
describe('tttx-loading-spinner', () => {
|
|
4
|
+
it('renders the loading text when the loading message prop is set to true', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [TttxLoadingSpinner],
|
|
7
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
8
|
+
});
|
|
9
|
+
page.rootInstance.loadingMessage = true;
|
|
10
|
+
await page.waitForChanges();
|
|
11
|
+
expect(page.root).toEqualHtml(`
|
|
12
|
+
<tttx-loading-spinner>
|
|
13
|
+
<mock:shadow-root>
|
|
14
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div><div class='loading-text'>Loading, please wait...</div></div>
|
|
15
|
+
</mock:shadow-root>
|
|
16
|
+
</tttx-loading-spinner>
|
|
17
|
+
`);
|
|
18
|
+
});
|
|
19
|
+
it('renders without the loading text when the loading message prop is set to false', async () => {
|
|
20
|
+
const page = await newSpecPage({
|
|
21
|
+
components: [TttxLoadingSpinner],
|
|
22
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
23
|
+
});
|
|
24
|
+
page.rootInstance.loadingMessage = false;
|
|
25
|
+
await page.waitForChanges();
|
|
26
|
+
expect(page.root).toEqualHtml(`
|
|
27
|
+
<tttx-loading-spinner>
|
|
28
|
+
<mock:shadow-root>
|
|
29
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div></div>
|
|
30
|
+
</mock:shadow-root>
|
|
31
|
+
</tttx-loading-spinner>
|
|
32
|
+
`);
|
|
33
|
+
});
|
|
34
|
+
it('renders the small spinner when the size prop is set to small', async () => {
|
|
35
|
+
const page = await newSpecPage({
|
|
36
|
+
components: [TttxLoadingSpinner],
|
|
37
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
38
|
+
});
|
|
39
|
+
page.rootInstance.size = 'small';
|
|
40
|
+
await page.waitForChanges();
|
|
41
|
+
expect(page.root).toEqualHtml(`
|
|
42
|
+
<tttx-loading-spinner>
|
|
43
|
+
<mock:shadow-root>
|
|
44
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner small'></span></div></div>
|
|
45
|
+
</mock:shadow-root>
|
|
46
|
+
</tttx-loading-spinner>
|
|
47
|
+
`);
|
|
48
|
+
});
|
|
49
|
+
it('renders the large spinner when the size prop is set to large', async () => {
|
|
50
|
+
const page = await newSpecPage({
|
|
51
|
+
components: [TttxLoadingSpinner],
|
|
52
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
53
|
+
});
|
|
54
|
+
page.rootInstance.size = 'large';
|
|
55
|
+
await page.waitForChanges();
|
|
56
|
+
expect(page.root).toEqualHtml(`
|
|
57
|
+
<tttx-loading-spinner>
|
|
58
|
+
<mock:shadow-root>
|
|
59
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div></div>
|
|
60
|
+
</mock:shadow-root>
|
|
61
|
+
</tttx-loading-spinner>
|
|
62
|
+
`);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { TttxList } from '../tttx-list';
|
|
3
|
+
describe('tttx-list', () => {
|
|
4
|
+
it('renders a spinner before loading in data', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [TttxList],
|
|
7
|
+
html: '<tttx-list name=\'before-load\' />',
|
|
8
|
+
});
|
|
9
|
+
expect(page.root).toEqualHtml(`
|
|
10
|
+
<tttx-list name='before-load'>
|
|
11
|
+
<mock:shadow-root>
|
|
12
|
+
<div class="list-item-container" tabindex="0">
|
|
13
|
+
</div>
|
|
14
|
+
<div class="load-indicator"><tttx-loading-spinner size='large' /></div>
|
|
15
|
+
</mock:shadow-root>
|
|
16
|
+
</tttx-list>
|
|
17
|
+
`);
|
|
18
|
+
});
|
|
19
|
+
it('renders a No Data message if not loading and empty', async () => {
|
|
20
|
+
const page = await newSpecPage({
|
|
21
|
+
components: [TttxList],
|
|
22
|
+
html: '<tttx-list name=\'empty-list\' />',
|
|
23
|
+
});
|
|
24
|
+
page.doc.dispatchEvent(new CustomEvent('listPageLoad', {
|
|
25
|
+
detail: {
|
|
26
|
+
name: 'empty-list',
|
|
27
|
+
lastPage: true,
|
|
28
|
+
items: []
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
await page.waitForChanges();
|
|
32
|
+
expect(page.root).toEqualHtml(`
|
|
33
|
+
<tttx-list name="empty-list">
|
|
34
|
+
<mock:shadow-root>
|
|
35
|
+
<div class="list-item-container" tabindex="0">
|
|
36
|
+
No data to display
|
|
37
|
+
</div>
|
|
38
|
+
</mock:shadow-root>
|
|
39
|
+
</tttx-list>
|
|
40
|
+
`);
|
|
41
|
+
});
|
|
42
|
+
it('renders a simple list template when no template is provided', async () => {
|
|
43
|
+
const page = await newSpecPage({
|
|
44
|
+
components: [TttxList],
|
|
45
|
+
html: '<tttx-list name=\'simple-list\' />',
|
|
46
|
+
});
|
|
47
|
+
page.doc.dispatchEvent(new CustomEvent('listPageLoad', {
|
|
48
|
+
detail: {
|
|
49
|
+
name: 'simple-list',
|
|
50
|
+
lastPage: true,
|
|
51
|
+
items: [
|
|
52
|
+
{ text: 'A row with only text' },
|
|
53
|
+
{ text: 'A row with text and an icon', icon: 'settings' },
|
|
54
|
+
{ text: 'A row with text and a coloured icon', icon: 'warning', iconColor: '#ff0000' }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
await page.waitForChanges();
|
|
59
|
+
expect(page.root).toEqualHtml(`
|
|
60
|
+
<tttx-list name="simple-list">
|
|
61
|
+
<mock:shadow-root>
|
|
62
|
+
<div class="list-item-container" tabindex="0">
|
|
63
|
+
<div class="tttx-list__row">
|
|
64
|
+
<div class="generic-template__content">
|
|
65
|
+
A row with only text
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="tttx-list__row">
|
|
69
|
+
<div class="generic-template__content">
|
|
70
|
+
<span class="material-symbols-rounded">settings</span>A row with text and an icon
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="tttx-list__row">
|
|
74
|
+
<div class="generic-template__content">
|
|
75
|
+
<span class="material-symbols-rounded" style="color: #ff0000;">warning</span>A row with text and a coloured icon
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</mock:shadow-root>
|
|
80
|
+
</tttx-list>
|
|
81
|
+
`);
|
|
82
|
+
});
|
|
83
|
+
it('dispatches an event when clicking a row', async () => {
|
|
84
|
+
const page = await newSpecPage({
|
|
85
|
+
components: [TttxList],
|
|
86
|
+
html: '<tttx-list name=\'clickable-list\' />',
|
|
87
|
+
});
|
|
88
|
+
page.doc.dispatchEvent(new CustomEvent('listPageLoad', {
|
|
89
|
+
detail: {
|
|
90
|
+
name: 'clickable-list',
|
|
91
|
+
lastPage: true,
|
|
92
|
+
items: [
|
|
93
|
+
{ text: 'A row with only text' },
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
await page.waitForChanges();
|
|
98
|
+
});
|
|
99
|
+
it('clears the list data when receiving a listClearDataCache event', async () => {
|
|
100
|
+
const page = await newSpecPage({
|
|
101
|
+
components: [TttxList],
|
|
102
|
+
html: '<tttx-list name=\'clearable-list\' />',
|
|
103
|
+
});
|
|
104
|
+
page.doc.dispatchEvent(new CustomEvent('listPageLoad', {
|
|
105
|
+
detail: {
|
|
106
|
+
name: 'clearable-list',
|
|
107
|
+
lastPage: true,
|
|
108
|
+
items: [
|
|
109
|
+
{ text: 'A row with only text' },
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
await page.waitForChanges();
|
|
114
|
+
expect(page.root).toEqualHtml(`
|
|
115
|
+
<tttx-list name="clearable-list">
|
|
116
|
+
<mock:shadow-root>
|
|
117
|
+
<div class="list-item-container" tabindex="0">
|
|
118
|
+
<div class="tttx-list__row">
|
|
119
|
+
<div class="generic-template__content">
|
|
120
|
+
A row with only text
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
</mock:shadow-root>
|
|
125
|
+
</tttx-list>
|
|
126
|
+
`);
|
|
127
|
+
page.doc.dispatchEvent(new CustomEvent('listClearDataCache', {
|
|
128
|
+
detail: {
|
|
129
|
+
name: 'clearable-list'
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
await page.waitForChanges();
|
|
133
|
+
expect(page.root).toEqualHtml(`
|
|
134
|
+
<tttx-list name="clearable-list">
|
|
135
|
+
<mock:shadow-root>
|
|
136
|
+
<div class="list-item-container" tabindex="0">
|
|
137
|
+
No data to display
|
|
138
|
+
</div>
|
|
139
|
+
</mock:shadow-root>
|
|
140
|
+
</tttx-list>
|
|
141
|
+
`);
|
|
142
|
+
});
|
|
143
|
+
// describe('when selectable', () => {
|
|
144
|
+
// it('renders rows with a checkbox', () => {
|
|
145
|
+
// });
|
|
146
|
+
// it('responds with the selected row data when a listActionSelectedEvent event is dispatched', () => {
|
|
147
|
+
// });
|
|
148
|
+
// it('removes selected rows when listActionSelectedEvent instructs it to', () => {
|
|
149
|
+
// });
|
|
150
|
+
// });
|
|
151
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.material-symbols-rounded {
|
|
2
|
+
font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.material-symbols-rounded {
|
|
6
|
+
font-family: "Material Symbols Rounded", sans-serif;
|
|
7
|
+
font-weight: 400;
|
|
8
|
+
font-style: normal;
|
|
9
|
+
font-size: 24px;
|
|
10
|
+
line-height: 1;
|
|
11
|
+
letter-spacing: normal;
|
|
12
|
+
text-transform: none;
|
|
13
|
+
display: inline-block;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
word-wrap: normal;
|
|
16
|
+
direction: ltr;
|
|
17
|
+
text-rendering: optimizeLegibility;
|
|
18
|
+
-webkit-font-smoothing: antialiased;
|
|
19
|
+
color: #9e9e9e;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.list {
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.item {
|
|
33
|
+
list-style: none;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
border-bottom: 1px solid #d5d5d5;
|
|
37
|
+
height: 36px;
|
|
38
|
+
/* center the contents vertically */
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
.item:first-of-type {
|
|
43
|
+
border-top: 1px solid #d5d5d5;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.align-right {
|
|
47
|
+
margin-left: auto;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.item-content {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { h } from '@stencil/core';
|
|
3
|
+
export class TttxList {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.data = undefined;
|
|
6
|
+
}
|
|
7
|
+
renderListItem(item) {
|
|
8
|
+
// Onclick should return some row data. May need to rethink how we handle data, since we don't want to return a template
|
|
9
|
+
// Alternatively, could return some sort of row id/index instead
|
|
10
|
+
return h("li", { class: "item", onClick: () => { this.listSelectedEvent.emit({}); } }, item.element && h("span", { class: "item-content", innerHTML: item.element }), item.chevron && h("tttx-icon", { class: "align-right", icon: "chevron_right" }));
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
if (!this.data)
|
|
14
|
+
return;
|
|
15
|
+
if (typeof this.data === 'string') {
|
|
16
|
+
this._data = JSON.parse(this.data);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this._data = this.data;
|
|
20
|
+
}
|
|
21
|
+
return (h("ul", { class: "list" }, this._data && this._data.map((item) => this.renderListItem(item))));
|
|
22
|
+
}
|
|
23
|
+
static get is() { return "tttx-list"; }
|
|
24
|
+
static get encapsulation() { return "shadow"; }
|
|
25
|
+
static get originalStyleUrls() {
|
|
26
|
+
return {
|
|
27
|
+
"$": ["tttx-list.scss"]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
static get styleUrls() {
|
|
31
|
+
return {
|
|
32
|
+
"$": ["tttx-list.css"]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
static get properties() {
|
|
36
|
+
return {
|
|
37
|
+
"data": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"mutable": false,
|
|
40
|
+
"complexType": {
|
|
41
|
+
"original": "string | ListItem[]",
|
|
42
|
+
"resolved": "ListItem[] | string",
|
|
43
|
+
"references": {
|
|
44
|
+
"ListItem": {
|
|
45
|
+
"location": "import",
|
|
46
|
+
"path": "./interfaces"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": false,
|
|
51
|
+
"optional": false,
|
|
52
|
+
"docs": {
|
|
53
|
+
"tags": [],
|
|
54
|
+
"text": ""
|
|
55
|
+
},
|
|
56
|
+
"attribute": "data",
|
|
57
|
+
"reflect": false
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
static get events() {
|
|
62
|
+
return [{
|
|
63
|
+
"method": "listSelectedEvent",
|
|
64
|
+
"name": "listItemClick",
|
|
65
|
+
"bubbles": true,
|
|
66
|
+
"cancelable": true,
|
|
67
|
+
"composed": true,
|
|
68
|
+
"docs": {
|
|
69
|
+
"tags": [],
|
|
70
|
+
"text": ""
|
|
71
|
+
},
|
|
72
|
+
"complexType": {
|
|
73
|
+
"original": "any",
|
|
74
|
+
"resolved": "any",
|
|
75
|
+
"references": {}
|
|
76
|
+
}
|
|
77
|
+
}];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
title: 'molecules/List',
|
|
3
|
+
component: 'tttx-list',
|
|
4
|
+
};
|
|
5
|
+
const TemplateStringList = ({ data }) => `
|
|
6
|
+
<tttx-list
|
|
7
|
+
data='${JSON.stringify(data)}'
|
|
8
|
+
id='list'
|
|
9
|
+
></tttx-list>
|
|
10
|
+
`;
|
|
11
|
+
export const BasicStringList = TemplateStringList.bind({});
|
|
12
|
+
BasicStringList.args = {
|
|
13
|
+
data: [
|
|
14
|
+
{ chevron: true, element: '<span><tttx-icon icon="egg" /></span> Demulon 1,000,000' },
|
|
15
|
+
{ chevron: true, element: '<span><tttx-icon icon="egg" color="red" /></span> Patrick' },
|
|
16
|
+
{ chevron: true, element: '<span><tttx-icon icon="add" /></span> Lee' },
|
|
17
|
+
{ chevron: false, element: '<span><tttx-icon icon="egg" /></span> Ben' },
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
const TemplateObjectList = ({ data }) => `
|
|
21
|
+
<tttx-list
|
|
22
|
+
id='list'
|
|
23
|
+
></tttx-list>
|
|
24
|
+
<script>
|
|
25
|
+
if(!list) {
|
|
26
|
+
const list = document.getElementId('list');
|
|
27
|
+
}
|
|
28
|
+
list.data = ${JSON.stringify(data)};
|
|
29
|
+
</script>
|
|
30
|
+
`;
|
|
31
|
+
export const BasicObjectList = TemplateObjectList.bind({});
|
|
32
|
+
BasicObjectList.args = {
|
|
33
|
+
data: [
|
|
34
|
+
{ chevron: true, element: '<span><tttx-icon icon="egg" /></span> Demulon 1,000,000' },
|
|
35
|
+
{ chevron: true, element: '<span><tttx-icon icon="egg" color="red" /></span> Patrick' },
|
|
36
|
+
{ chevron: true, element: '<span><tttx-icon icon="add" /></span> Lee' },
|
|
37
|
+
{ chevron: true, element: '<span><tttx-icon icon="egg" /></span> Ben' },
|
|
38
|
+
]
|
|
39
|
+
};
|
package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
+
describe('tttx-standalone-input', () => {
|
|
3
|
+
it('renders', async () => {
|
|
4
|
+
const page = await newE2EPage();
|
|
5
|
+
await page.setContent('<tttx-standalone-input></tttx-standalone-input>');
|
|
6
|
+
const element = await page.find('tttx-standalone-input');
|
|
7
|
+
expect(element).toHaveClass('hydrated');
|
|
8
|
+
});
|
|
9
|
+
});
|