@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,146 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { TttxInput } from '../tttx-standalone-input';
|
|
3
|
+
describe('tttx-standalone-input', () => {
|
|
4
|
+
it('renders', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [TttxInput],
|
|
7
|
+
html: '<tttx-standalone-input />',
|
|
8
|
+
});
|
|
9
|
+
expect(page.root).toEqualHtml(`
|
|
10
|
+
<tttx-standalone-input>
|
|
11
|
+
<label class="inputBlock">
|
|
12
|
+
<span class="optional">
|
|
13
|
+
(optional)
|
|
14
|
+
</span>
|
|
15
|
+
<input class="standalone" type="text">
|
|
16
|
+
<span class="errorBubble">
|
|
17
|
+
<span class="material-symbols-rounded validationicon">
|
|
18
|
+
warning
|
|
19
|
+
</span>
|
|
20
|
+
</span>
|
|
21
|
+
</label>
|
|
22
|
+
</tttx-standalone-input>
|
|
23
|
+
`);
|
|
24
|
+
});
|
|
25
|
+
it('renders the input field with the left icon', async () => {
|
|
26
|
+
const page = await newSpecPage({
|
|
27
|
+
components: [TttxInput],
|
|
28
|
+
html: '<tttx-standalone-input iconleft="info" />',
|
|
29
|
+
});
|
|
30
|
+
expect(page.root).toEqualHtml(`
|
|
31
|
+
<tttx-standalone-input iconleft="info">
|
|
32
|
+
<label class="inputBlock">
|
|
33
|
+
<span class="optional">
|
|
34
|
+
(optional)
|
|
35
|
+
</span>
|
|
36
|
+
<div class="icon-left">
|
|
37
|
+
<tttx-icon color="grey" icon="info"></tttx-icon>
|
|
38
|
+
</div>
|
|
39
|
+
<input class="standalone" type="text">
|
|
40
|
+
<span class="errorBubble">
|
|
41
|
+
<span class="material-symbols-rounded validationicon">
|
|
42
|
+
warning
|
|
43
|
+
</span>
|
|
44
|
+
</span>
|
|
45
|
+
</label>
|
|
46
|
+
</tttx-standalone-input>
|
|
47
|
+
`);
|
|
48
|
+
});
|
|
49
|
+
it('renders the input field with the right icon', async () => {
|
|
50
|
+
const page = await newSpecPage({
|
|
51
|
+
components: [TttxInput],
|
|
52
|
+
html: '<tttx-standalone-input iconright="info" />',
|
|
53
|
+
});
|
|
54
|
+
expect(page.root).toEqualHtml(`
|
|
55
|
+
<tttx-standalone-input iconright="info">
|
|
56
|
+
<label class="inputBlock">
|
|
57
|
+
<span class="optional">
|
|
58
|
+
(optional)
|
|
59
|
+
</span>
|
|
60
|
+
<input class="standalone" type="text">
|
|
61
|
+
<div class="icon-right">
|
|
62
|
+
<tttx-icon color="grey" icon="info"></tttx-icon>
|
|
63
|
+
</div>
|
|
64
|
+
<span class="errorBubble">
|
|
65
|
+
<span class="material-symbols-rounded validationicon">
|
|
66
|
+
warning
|
|
67
|
+
</span>
|
|
68
|
+
</span>
|
|
69
|
+
</label>
|
|
70
|
+
</tttx-standalone-input>
|
|
71
|
+
`);
|
|
72
|
+
});
|
|
73
|
+
it('renders the input field with an error message', async () => {
|
|
74
|
+
const page = await newSpecPage({
|
|
75
|
+
components: [TttxInput],
|
|
76
|
+
html: '<tttx-standalone-input required showerrormsg errormsg="The field is required" />',
|
|
77
|
+
});
|
|
78
|
+
expect(page.root).toEqualHtml(`
|
|
79
|
+
<tttx-standalone-input errormsg="The field is required" required="" showerrormsg="">
|
|
80
|
+
<label class="inputBlock">
|
|
81
|
+
<input class="invalid standalone" required="" type="text">
|
|
82
|
+
<span class="errorBubble visible">
|
|
83
|
+
<span class="material-symbols-rounded validationicon">
|
|
84
|
+
warning
|
|
85
|
+
</span>
|
|
86
|
+
The field is required
|
|
87
|
+
</span>
|
|
88
|
+
</label>
|
|
89
|
+
</tttx-standalone-input>
|
|
90
|
+
`);
|
|
91
|
+
});
|
|
92
|
+
it('can trigger onInput handler', async () => {
|
|
93
|
+
const page = await newSpecPage({
|
|
94
|
+
components: [TttxInput],
|
|
95
|
+
html: '<tttx-standalone-input />',
|
|
96
|
+
});
|
|
97
|
+
const callbackFn = jest.fn();
|
|
98
|
+
page.doc.addEventListener('valueChanged', callbackFn);
|
|
99
|
+
const input = page.root.querySelector('input');
|
|
100
|
+
input.value = 'a';
|
|
101
|
+
const event = new CustomEvent('input', { composed: true, bubbles: true });
|
|
102
|
+
input.dispatchEvent(event);
|
|
103
|
+
expect(callbackFn).toHaveBeenCalled();
|
|
104
|
+
});
|
|
105
|
+
it('can trigger onFocus handler', async () => {
|
|
106
|
+
const page = await newSpecPage({
|
|
107
|
+
components: [TttxInput],
|
|
108
|
+
html: '<tttx-standalone-input />',
|
|
109
|
+
});
|
|
110
|
+
const callbackFn = jest.fn();
|
|
111
|
+
page.doc.addEventListener('focusChanged', callbackFn);
|
|
112
|
+
const input = page.root.querySelector('input');
|
|
113
|
+
input.focus();
|
|
114
|
+
const event = new CustomEvent('focus', { composed: true, bubbles: true });
|
|
115
|
+
input.dispatchEvent(event);
|
|
116
|
+
expect(callbackFn).toHaveBeenCalled();
|
|
117
|
+
});
|
|
118
|
+
it('can trigger onBlur handler', async () => {
|
|
119
|
+
const page = await newSpecPage({
|
|
120
|
+
components: [TttxInput],
|
|
121
|
+
html: '<tttx-standalone-input />',
|
|
122
|
+
});
|
|
123
|
+
const callbackFn = jest.fn();
|
|
124
|
+
page.doc.addEventListener('blurChanged', callbackFn);
|
|
125
|
+
const input = page.root.querySelector('input');
|
|
126
|
+
input.blur();
|
|
127
|
+
const event = new CustomEvent('blur', { composed: true, bubbles: true });
|
|
128
|
+
input.dispatchEvent(event);
|
|
129
|
+
expect(callbackFn).toHaveBeenCalled();
|
|
130
|
+
});
|
|
131
|
+
it('can trigger onInvalid handler', async () => {
|
|
132
|
+
const page = await newSpecPage({
|
|
133
|
+
components: [TttxInput],
|
|
134
|
+
html: '<tttx-standalone-input />',
|
|
135
|
+
});
|
|
136
|
+
const callbackFn = jest.fn();
|
|
137
|
+
page.doc.addEventListener('invalidChanged', callbackFn);
|
|
138
|
+
const input = page.root.querySelector('input');
|
|
139
|
+
// Doesn't work:
|
|
140
|
+
// input.setCustomValidity('required');
|
|
141
|
+
// input.checkValidity();
|
|
142
|
+
const event = new CustomEvent('invalid', { composed: true, bubbles: true });
|
|
143
|
+
input.dispatchEvent(event);
|
|
144
|
+
expect(callbackFn).toHaveBeenCalled();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
+
describe('tttx-table', () => {
|
|
3
|
+
it('renders', async () => {
|
|
4
|
+
const page = await newE2EPage();
|
|
5
|
+
await page.setContent('<tttx-table></tttx-table>');
|
|
6
|
+
const element = await page.find('tttx-table');
|
|
7
|
+
expect(element).toHaveClass('hydrated');
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// SPACING
|
|
2
|
+
$spacing-unit: 4px;
|
|
3
|
+
|
|
4
|
+
// REGULAR
|
|
5
|
+
$horizontal-spacing: $spacing-unit * 4;
|
|
6
|
+
$vertical-spacing: $spacing-unit * 2;
|
|
7
|
+
$base-padding: $vertical-spacing $horizontal-spacing;
|
|
8
|
+
$base-height: $spacing-unit * 9;
|
|
9
|
+
$component-spacing: $spacing-unit * 4;
|
|
10
|
+
|
|
11
|
+
// SMALL
|
|
12
|
+
$horizontal-spacing-sm: $spacing-unit * 2;
|
|
13
|
+
$vertical-spacing-sm: $spacing-unit * 1;
|
|
14
|
+
$base-padding-sm: $vertical-spacing-sm $horizontal-spacing-sm;
|
|
15
|
+
$base-height-sm: $spacing-unit * 7;
|
|
16
|
+
|
|
17
|
+
// COLOURS
|
|
18
|
+
$grey-0: #212121;
|
|
19
|
+
$grey-1: #363636;
|
|
20
|
+
$grey-2: #4c4c4c;
|
|
21
|
+
$grey-3: #636363;
|
|
22
|
+
$grey-4: #757575;
|
|
23
|
+
$grey-5: #9e9e9e;
|
|
24
|
+
$grey-6: #aeaeae;
|
|
25
|
+
$grey-7: #c8c8c8;
|
|
26
|
+
$grey-8: #e3e3e3;
|
|
27
|
+
$grey-9: #f0f0f0;
|
|
28
|
+
|
|
29
|
+
$white: white;
|
|
30
|
+
$black: $grey-0;
|
|
31
|
+
$transparent: transparent;
|
|
32
|
+
|
|
33
|
+
$blue-0: #00187c;
|
|
34
|
+
$blue-1: #032e8c;
|
|
35
|
+
$blue-2: #0849a3;
|
|
36
|
+
$blue-3: #0951a8;
|
|
37
|
+
$blue-4: #1169ba;
|
|
38
|
+
$blue-5: #1479c6;
|
|
39
|
+
$blue-6: #5194d2;
|
|
40
|
+
$blue-7: #7aacdd;
|
|
41
|
+
$blue-8: #b9d5ed;
|
|
42
|
+
$blue-9: #e7f1f9;
|
|
43
|
+
|
|
44
|
+
$red-0: #7c0000;
|
|
45
|
+
$red-1: #8c0000;
|
|
46
|
+
$red-2: #a30000;
|
|
47
|
+
$red-3: #a80000;
|
|
48
|
+
$red-4: #ba0000;
|
|
49
|
+
$red-5: #dc0000;
|
|
50
|
+
$red-6: #d25151;
|
|
51
|
+
$red-7: #dd7a7a;
|
|
52
|
+
$red-8: #edc1c1;
|
|
53
|
+
$red-9: #f9e7e7;
|
|
54
|
+
|
|
55
|
+
$black-1: #e6e6e6;
|
|
56
|
+
|
|
57
|
+
$brand: $blue-0;
|
|
58
|
+
$accent: $blue-5;
|
|
59
|
+
$accent-selected: $blue-9;
|
|
60
|
+
$error: $red-5;
|
|
61
|
+
|
|
62
|
+
$severity-critical: #dc0000;
|
|
63
|
+
$severity-warning: #f59500;
|
|
64
|
+
$severity-success: #a2bb31;
|
|
65
|
+
$severity-info: $accent;
|
|
66
|
+
|
|
67
|
+
$ui-primary: $black;
|
|
68
|
+
$ui-secondary: $grey-4;
|
|
69
|
+
$ui-disabled: $grey-2;
|
|
70
|
+
$ui-placeholder: $grey-5;
|
|
71
|
+
|
|
72
|
+
$ui-background: $grey-9;
|
|
73
|
+
$ui-sheet: $white;
|
|
74
|
+
$ui-border: #d5d5d5;
|
|
75
|
+
|
|
76
|
+
// BORDERS
|
|
77
|
+
$ui-border-radius: 4px;
|
|
78
|
+
$ui-border-width: 1px;
|
|
79
|
+
|
|
80
|
+
// TYPOGRAPHY
|
|
81
|
+
$font-size-default: 16px;
|
|
82
|
+
$font-size-small: 14px;
|
|
83
|
+
|
|
84
|
+
.material-symbols-rounded {
|
|
85
|
+
font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.skeleton {
|
|
89
|
+
animation: skeleton-loading 1s linear infinite alternate;
|
|
90
|
+
border-radius: 4px;
|
|
91
|
+
width: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes skeleton-loading {
|
|
95
|
+
0% {
|
|
96
|
+
background-color: hsl(200, 20%, 80%);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
100% {
|
|
100
|
+
background-color: hsl(200, 20%, 95%);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host {
|
|
105
|
+
display: block;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
table {
|
|
109
|
+
box-sizing: border-box;
|
|
110
|
+
width: 100%;
|
|
111
|
+
border-collapse: collapse;
|
|
112
|
+
border-spacing: 0;
|
|
113
|
+
border: 1px solid #ddd;
|
|
114
|
+
border-bottom: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
thead tr {
|
|
118
|
+
height: 52px;
|
|
119
|
+
color: #757575;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
tbody tr {
|
|
123
|
+
height: 48px;
|
|
124
|
+
color: #212121;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
tr {
|
|
128
|
+
|
|
129
|
+
/* Cell typography */
|
|
130
|
+
font-family: 'Roboto', sans-serif;
|
|
131
|
+
font-weight: 400;
|
|
132
|
+
font-size: 16px;
|
|
133
|
+
|
|
134
|
+
/* center the contents vertically */
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
|
|
138
|
+
/* Border */
|
|
139
|
+
border-bottom: 1px solid #ddd;
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.selected {
|
|
144
|
+
background-color: #F0F0F0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.checked {
|
|
148
|
+
background-color: #e7f1f9;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
td,
|
|
152
|
+
th {
|
|
153
|
+
min-width: 300px;
|
|
154
|
+
margin-left: 16px;
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: left;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.skeleton {
|
|
160
|
+
height: 24px;
|
|
161
|
+
display: block;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.align-right {
|
|
165
|
+
margin-left: auto;
|
|
166
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { Host, h } from '@stencil/core';
|
|
3
|
+
export class TttxTable {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.headers = [];
|
|
6
|
+
this.data = [];
|
|
7
|
+
this.loading = false;
|
|
8
|
+
this.selected = -1;
|
|
9
|
+
}
|
|
10
|
+
handleKeyDown(ev) {
|
|
11
|
+
if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp') {
|
|
12
|
+
this.updateSelectedIndex(ev.key);
|
|
13
|
+
this.emitRowSelected();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
updateSelectedIndex(key) {
|
|
17
|
+
if (this.selected === -1) {
|
|
18
|
+
this.selected = 0;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const isArrowDown = key === 'ArrowDown';
|
|
22
|
+
const isArrowUp = key === 'ArrowUp';
|
|
23
|
+
if (isArrowDown && this.selected < this.data.length - 1) {
|
|
24
|
+
this.selected++;
|
|
25
|
+
}
|
|
26
|
+
else if (isArrowUp && this.selected > 0) {
|
|
27
|
+
this.selected--;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
emitRowSelected() {
|
|
32
|
+
this.rowSelected.emit(this.data[this.selected]);
|
|
33
|
+
}
|
|
34
|
+
rowSelectedHandler(row) {
|
|
35
|
+
this.rowSelected.emit(row);
|
|
36
|
+
this.selected = this.data.findIndex((item) => item === row);
|
|
37
|
+
}
|
|
38
|
+
headerClickedHandler(key) {
|
|
39
|
+
this.headerClicked.emit(key);
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
return (h(Host, null, h("table", null, h("thead", null, h("tr", null, this.loading ?
|
|
43
|
+
[1, 2, 3].map(() => (h("th", null, h("div", { class: "skeleton" })))) :
|
|
44
|
+
this.headers && this.headers.map((header) => (h("th", { scope: "col", onClick: () => this.headerClickedHandler(header.key) }, header.label))))), h("tbody", null, this.loading ?
|
|
45
|
+
[1, 2, 3].map(() => (h("tr", null, h("td", null, h("div", { class: "skeleton" })), h("td", null, h("div", { class: "skeleton" })), h("td", null, h("div", { class: "skeleton" }))))) :
|
|
46
|
+
Object.keys(this.data).map((key, index) => (h("tr", { class: index === this.selected ? 'selected' : '', onClick: () => this.rowSelectedHandler(this.data[key]) }, this.headers.map((header) => (h("td", null, this.data[key][header.key], " ", header.actions && h("tttx-icon", { class: "align-right", icon: "more_vert" }, h("div", { slot: "popover" }, h("tttx-popover-content", { header: "The humble egg", body: "Most arthropods such as insects, vertebrates (excluding live-bearing mammals), and mollusks lay eggs, although some, such as scorpions, do not.", linkcontext: "Wikipedia_egg", linktext: "Learn more about eggs" })))))))))))));
|
|
47
|
+
}
|
|
48
|
+
static get is() { return "tttx-table"; }
|
|
49
|
+
static get encapsulation() { return "shadow"; }
|
|
50
|
+
static get originalStyleUrls() {
|
|
51
|
+
return {
|
|
52
|
+
"$": ["tttx-table.css"]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
static get styleUrls() {
|
|
56
|
+
return {
|
|
57
|
+
"$": ["tttx-table.css"]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
static get properties() {
|
|
61
|
+
return {
|
|
62
|
+
"headers": {
|
|
63
|
+
"type": "unknown",
|
|
64
|
+
"mutable": false,
|
|
65
|
+
"complexType": {
|
|
66
|
+
"original": "any[]",
|
|
67
|
+
"resolved": "any[]",
|
|
68
|
+
"references": {}
|
|
69
|
+
},
|
|
70
|
+
"required": false,
|
|
71
|
+
"optional": false,
|
|
72
|
+
"docs": {
|
|
73
|
+
"tags": [],
|
|
74
|
+
"text": ""
|
|
75
|
+
},
|
|
76
|
+
"defaultValue": "[]"
|
|
77
|
+
},
|
|
78
|
+
"data": {
|
|
79
|
+
"type": "unknown",
|
|
80
|
+
"mutable": false,
|
|
81
|
+
"complexType": {
|
|
82
|
+
"original": "any[]",
|
|
83
|
+
"resolved": "any[]",
|
|
84
|
+
"references": {}
|
|
85
|
+
},
|
|
86
|
+
"required": false,
|
|
87
|
+
"optional": false,
|
|
88
|
+
"docs": {
|
|
89
|
+
"tags": [],
|
|
90
|
+
"text": ""
|
|
91
|
+
},
|
|
92
|
+
"defaultValue": "[]"
|
|
93
|
+
},
|
|
94
|
+
"loading": {
|
|
95
|
+
"type": "boolean",
|
|
96
|
+
"mutable": false,
|
|
97
|
+
"complexType": {
|
|
98
|
+
"original": "boolean",
|
|
99
|
+
"resolved": "boolean",
|
|
100
|
+
"references": {}
|
|
101
|
+
},
|
|
102
|
+
"required": false,
|
|
103
|
+
"optional": false,
|
|
104
|
+
"docs": {
|
|
105
|
+
"tags": [],
|
|
106
|
+
"text": ""
|
|
107
|
+
},
|
|
108
|
+
"attribute": "loading",
|
|
109
|
+
"reflect": false,
|
|
110
|
+
"defaultValue": "false"
|
|
111
|
+
},
|
|
112
|
+
"selected": {
|
|
113
|
+
"type": "number",
|
|
114
|
+
"mutable": false,
|
|
115
|
+
"complexType": {
|
|
116
|
+
"original": "number",
|
|
117
|
+
"resolved": "number",
|
|
118
|
+
"references": {}
|
|
119
|
+
},
|
|
120
|
+
"required": false,
|
|
121
|
+
"optional": false,
|
|
122
|
+
"docs": {
|
|
123
|
+
"tags": [],
|
|
124
|
+
"text": ""
|
|
125
|
+
},
|
|
126
|
+
"attribute": "selected",
|
|
127
|
+
"reflect": false,
|
|
128
|
+
"defaultValue": "-1"
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
static get events() {
|
|
133
|
+
return [{
|
|
134
|
+
"method": "rowSelected",
|
|
135
|
+
"name": "rowSelected",
|
|
136
|
+
"bubbles": true,
|
|
137
|
+
"cancelable": true,
|
|
138
|
+
"composed": true,
|
|
139
|
+
"docs": {
|
|
140
|
+
"tags": [],
|
|
141
|
+
"text": ""
|
|
142
|
+
},
|
|
143
|
+
"complexType": {
|
|
144
|
+
"original": "any",
|
|
145
|
+
"resolved": "any",
|
|
146
|
+
"references": {}
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
"method": "headerClicked",
|
|
150
|
+
"name": "headerClicked",
|
|
151
|
+
"bubbles": true,
|
|
152
|
+
"cancelable": true,
|
|
153
|
+
"composed": true,
|
|
154
|
+
"docs": {
|
|
155
|
+
"tags": [],
|
|
156
|
+
"text": ""
|
|
157
|
+
},
|
|
158
|
+
"complexType": {
|
|
159
|
+
"original": "any",
|
|
160
|
+
"resolved": "any",
|
|
161
|
+
"references": {}
|
|
162
|
+
}
|
|
163
|
+
}];
|
|
164
|
+
}
|
|
165
|
+
static get listeners() {
|
|
166
|
+
return [{
|
|
167
|
+
"name": "keydown",
|
|
168
|
+
"method": "handleKeyDown",
|
|
169
|
+
"target": "document",
|
|
170
|
+
"capture": false,
|
|
171
|
+
"passive": false
|
|
172
|
+
}];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { withActions } from '@storybook/addon-actions/decorator';
|
|
2
|
+
const templateData = [
|
|
3
|
+
{ name: 'John', age: 25, faveColor: 'blue' },
|
|
4
|
+
{ name: 'Jane', age: 30, faveColor: 'green' },
|
|
5
|
+
{ name: 'Bob', age: 40, faveColor: 'red' },
|
|
6
|
+
];
|
|
7
|
+
const templateHeaders = [
|
|
8
|
+
{
|
|
9
|
+
key: 'name',
|
|
10
|
+
label: 'Name'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
key: 'age',
|
|
14
|
+
label: 'Age'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: 'faveColor',
|
|
18
|
+
label: '',
|
|
19
|
+
actions: [
|
|
20
|
+
{
|
|
21
|
+
label: 'Edit',
|
|
22
|
+
icon: 'edit',
|
|
23
|
+
action: 'edit'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: 'Delete',
|
|
27
|
+
icon: 'delete',
|
|
28
|
+
action: 'delete'
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
export default {
|
|
34
|
+
title: 'Molecules/Table',
|
|
35
|
+
component: 'tttx-table',
|
|
36
|
+
argTypes: {
|
|
37
|
+
loading: {
|
|
38
|
+
control: { type: 'boolean' },
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
parameters: {
|
|
42
|
+
actions: {
|
|
43
|
+
handles: ['rowSelected', 'headerClicked'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
decorators: [withActions],
|
|
47
|
+
};
|
|
48
|
+
const TemplateTable = ({ headers, data, loading, selected }) => `
|
|
49
|
+
|
|
50
|
+
<tttx-table
|
|
51
|
+
id="table"
|
|
52
|
+
></tttx-table>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
if (!table) {
|
|
56
|
+
const table = document.getElementById('table');
|
|
57
|
+
}
|
|
58
|
+
table.headers = ${JSON.stringify(headers)};
|
|
59
|
+
table.data = ${JSON.stringify(data)};
|
|
60
|
+
table.loading = ${loading};
|
|
61
|
+
table.selected = ${selected};
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
`;
|
|
65
|
+
export const BasicTable = TemplateTable.bind({});
|
|
66
|
+
BasicTable.args = {
|
|
67
|
+
headers: templateHeaders,
|
|
68
|
+
data: templateData
|
|
69
|
+
};
|
|
70
|
+
export const TablePreSelected = TemplateTable.bind({});
|
|
71
|
+
TablePreSelected.args = {
|
|
72
|
+
headers: templateHeaders,
|
|
73
|
+
data: templateData,
|
|
74
|
+
selected: 1
|
|
75
|
+
};
|
|
76
|
+
export const TableLoading = TemplateTable.bind({});
|
|
77
|
+
TableLoading.args = {
|
|
78
|
+
headers: templateHeaders,
|
|
79
|
+
data: templateData,
|
|
80
|
+
loading: true
|
|
81
|
+
};
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
export { TttxButton as TttxButton } from '../types/components/atoms/tttx-button/tttx-button';
|
|
3
3
|
export { TttxIcon as TttxIcon } from '../types/components/atoms/tttx-icon/tttx-icon';
|
|
4
4
|
export { TttxKeyvalueBlock as TttxKeyvalueBlock } from '../types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block';
|
|
5
|
+
export { TttxList as TttxList } from '../types/components/molecules/tttx-list/tttx-list';
|
|
5
6
|
export { TttxLoadingSpinner as TttxLoadingSpinner } from '../types/components/atoms/tttx-loading-spinner/tttx-loading-spinner';
|
|
6
7
|
export { TttxInput as TttxStandaloneInput } from '../types/components/molecules/tttx-standalone-input/tttx-standalone-input';
|
|
8
|
+
export { TttxTable as TttxTable } from '../types/components/molecules/tttx-table/tttx-table';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Used to manually set the base path where assets can be found.
|
|
@@ -17,15 +19,6 @@ export { TttxInput as TttxStandaloneInput } from '../types/components/molecules/
|
|
|
17
19
|
*/
|
|
18
20
|
export declare const setAssetPath: (path: string) => void;
|
|
19
21
|
|
|
20
|
-
/**
|
|
21
|
-
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
22
|
-
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
23
|
-
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
24
|
-
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
25
|
-
* will result in the same behavior.
|
|
26
|
-
*/
|
|
27
|
-
export declare const setNonce: (nonce: string) => void
|
|
28
|
-
|
|
29
22
|
export interface SetPlatformOptions {
|
|
30
23
|
raf?: (c: FrameRequestCallback) => number;
|
|
31
24
|
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { setAssetPath,
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
2
2
|
export { TttxButton, defineCustomElement as defineCustomElementTttxButton } from './tttx-button.js';
|
|
3
3
|
export { TttxIcon, defineCustomElement as defineCustomElementTttxIcon } from './tttx-icon.js';
|
|
4
4
|
export { TttxKeyvalueBlock, defineCustomElement as defineCustomElementTttxKeyvalueBlock } from './tttx-keyvalue-block.js';
|
|
5
|
+
export { TttxList, defineCustomElement as defineCustomElementTttxList } from './tttx-list.js';
|
|
5
6
|
export { TttxLoadingSpinner, defineCustomElement as defineCustomElementTttxLoadingSpinner } from './tttx-loading-spinner.js';
|
|
6
7
|
export { TttxStandaloneInput, defineCustomElement as defineCustomElementTttxStandaloneInput } from './tttx-standalone-input.js';
|
|
8
|
+
export { TttxTable, defineCustomElement as defineCustomElementTttxTable } from './tttx-table.js';
|
|
@@ -29,20 +29,17 @@ const TttxKeyvalueBlock$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
29
29
|
for (let i = 0; i < values.length; i++) {
|
|
30
30
|
const value = values[i];
|
|
31
31
|
if (this.horizontal) {
|
|
32
|
-
elements.push(h("div", null, h("dt", { class:
|
|
32
|
+
elements.push(h("div", null, h("dt", { class: "mainTitle" }, value.title), h("dt", { class: "subTitle" }, value.subTitle), h("dd", null, value.data)));
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
elements.push(h("dt", { class:
|
|
36
|
-
elements.push(h("dt", { class:
|
|
35
|
+
elements.push(h("dt", { class: "mainTitle" }, value.title));
|
|
36
|
+
elements.push(h("dt", { class: "subTitle" }, value.subTitle));
|
|
37
37
|
elements.push(h("dd", null, value.data));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return elements;
|
|
41
41
|
}
|
|
42
42
|
render() {
|
|
43
|
-
if (!this.keyvalues) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
43
|
let values;
|
|
47
44
|
if (typeof this.keyvalues === 'string') {
|
|
48
45
|
values = JSON.parse(this.keyvalues);
|
|
@@ -57,7 +54,7 @@ const TttxKeyvalueBlock$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
57
54
|
else {
|
|
58
55
|
elements = this.renderSingleElements(values);
|
|
59
56
|
}
|
|
60
|
-
return (h(Host, null, h("dl", { class: this.horizontal ?
|
|
57
|
+
return (h(Host, null, h("dl", { class: this.horizontal ? "horizontal" : null }, elements)));
|
|
61
58
|
}
|
|
62
59
|
static get style() { return tttxKeyvalueBlockCss; }
|
|
63
60
|
}, [1, "tttx-keyvalue-block", {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface TttxList extends Components.TttxList, HTMLElement {}
|
|
4
|
+
export const TttxList: {
|
|
5
|
+
prototype: TttxList;
|
|
6
|
+
new (): TttxList;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|