@3t-transform/threeteeui 0.0.24 → 0.0.25

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 (96) hide show
  1. package/dist/cjs/{index-bc080fb4.js → index-451f61dd.js} +51 -60
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/tttx-button.cjs.entry.js +1 -1
  4. package/dist/cjs/tttx-form.cjs.entry.js +377 -0
  5. package/dist/cjs/tttx-icon.cjs.entry.js +1 -1
  6. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +8 -5
  7. package/dist/cjs/tttx-list.cjs.entry.js +1677 -7
  8. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +1 -1
  9. package/dist/cjs/tttx-standalone-input.cjs.entry.js +2 -1
  10. package/dist/cjs/tttx.cjs.js +2 -2
  11. package/dist/collection/collection-manifest.json +2 -2
  12. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +7 -4
  13. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +35 -0
  14. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +58 -0
  15. package/dist/collection/components/molecules/tttx-form/tttx-form.css +314 -0
  16. package/dist/collection/components/molecules/tttx-form/tttx-form.js +364 -0
  17. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +127 -0
  18. package/dist/collection/components/molecules/tttx-list/tttx-list.css +8 -2
  19. package/dist/collection/components/molecules/tttx-list/tttx-list.js +33 -7
  20. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +46 -14
  21. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +1 -0
  22. package/dist/collection/shared/domsanitiser.options.js +14 -0
  23. package/dist/components/index.d.ts +1 -1
  24. package/dist/components/index.js +1 -1
  25. package/dist/components/{tttx-table.d.ts → tttx-form.d.ts} +4 -4
  26. package/dist/components/tttx-form.js +394 -0
  27. package/dist/components/tttx-keyvalue-block.js +7 -4
  28. package/dist/components/tttx-list.js +1678 -7
  29. package/dist/components/tttx-standalone-input.js +1 -0
  30. package/dist/esm/{index-901bfd55.js → index-0350f122.js} +51 -60
  31. package/dist/esm/loader.js +2 -2
  32. package/dist/esm/tttx-button.entry.js +1 -1
  33. package/dist/esm/tttx-form.entry.js +373 -0
  34. package/dist/esm/tttx-icon.entry.js +1 -1
  35. package/dist/esm/tttx-keyvalue-block.entry.js +8 -5
  36. package/dist/esm/tttx-list.entry.js +1677 -7
  37. package/dist/esm/tttx-loading-spinner.entry.js +1 -1
  38. package/dist/esm/tttx-standalone-input.entry.js +2 -1
  39. package/dist/esm/tttx.js +2 -2
  40. package/dist/tttx/{p-a4077908.entry.js → p-1b015a9d.entry.js} +1 -1
  41. package/dist/tttx/p-4ec3aee3.entry.js +1 -0
  42. package/dist/tttx/p-62869344.js +2 -0
  43. package/dist/tttx/{p-0ae51ec5.entry.js → p-92465671.entry.js} +1 -1
  44. package/dist/tttx/p-a0179cb1.entry.js +1 -0
  45. package/dist/tttx/{p-9a382959.entry.js → p-ae71c5ef.entry.js} +1 -1
  46. package/dist/tttx/p-cd1565e0.entry.js +3 -0
  47. package/dist/tttx/p-f36c611b.entry.js +1 -0
  48. package/dist/tttx/tttx.esm.js +1 -1
  49. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -0
  50. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -0
  51. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +114 -0
  52. package/dist/types/components/molecules/{tttx-table/tttx-table.stories.d.ts → tttx-form/tttx-form.stories.d.ts} +2 -10
  53. package/dist/types/components/molecules/tttx-list/interfaces.d.ts +4 -2
  54. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +3 -1
  55. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +7 -0
  56. package/dist/types/components.d.ts +26 -28
  57. package/dist/types/shared/domsanitiser.options.d.ts +10 -0
  58. package/package.json +1 -1
  59. package/dist/cjs/tttx-table.cjs.entry.js +0 -60
  60. package/dist/collection/components/atoms/tttx-button/test/tttx-button.e2e.js +0 -9
  61. package/dist/collection/components/atoms/tttx-button/test/tttx-button.spec.js +0 -43
  62. package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.e2e.js +0 -9
  63. package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.spec.js +0 -16
  64. package/dist/collection/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.js +0 -164
  65. package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js +0 -64
  66. package/dist/collection/components/molecules/tttx-list/test/tttx-list.spec.js +0 -151
  67. package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.js +0 -9
  68. package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.js +0 -146
  69. package/dist/collection/components/molecules/tttx-table/test/tttx-table.e2e.js +0 -9
  70. package/dist/collection/components/molecules/tttx-table/tttx-table.css +0 -166
  71. package/dist/collection/components/molecules/tttx-table/tttx-table.js +0 -174
  72. package/dist/collection/components/molecules/tttx-table/tttx-table.stories.js +0 -81
  73. package/dist/components/tttx-table.js +0 -85
  74. package/dist/esm/tttx-table.entry.js +0 -56
  75. package/dist/tttx/p-1ec23160.entry.js +0 -1
  76. package/dist/tttx/p-300ff6a8.entry.js +0 -1
  77. package/dist/tttx/p-32ad02d3.entry.js +0 -1
  78. package/dist/tttx/p-80cf5236.entry.js +0 -1
  79. package/dist/tttx/p-a1bd16a1.entry.js +0 -1
  80. package/dist/tttx/p-a6953900.entry.js +0 -1
  81. package/dist/tttx/p-b46e3c59.entry.js +0 -1
  82. package/dist/tttx/p-c290160b.js +0 -2
  83. package/dist/tttx/p-dc179257.entry.js +0 -1
  84. package/dist/tttx/p-e19eb07e.entry.js +0 -1
  85. package/dist/tttx/p-e4341658.entry.js +0 -1
  86. package/dist/types/components/atoms/tttx-button/test/tttx-button.e2e.d.ts +0 -1
  87. package/dist/types/components/atoms/tttx-button/test/tttx-button.spec.d.ts +0 -1
  88. package/dist/types/components/atoms/tttx-icon/test/tttx-icon.e2e.d.ts +0 -1
  89. package/dist/types/components/atoms/tttx-icon/test/tttx-icon.spec.d.ts +0 -1
  90. package/dist/types/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.d.ts +0 -1
  91. package/dist/types/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.d.ts +0 -1
  92. package/dist/types/components/molecules/tttx-list/test/tttx-list.spec.d.ts +0 -1
  93. package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.d.ts +0 -1
  94. package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.d.ts +0 -1
  95. package/dist/types/components/molecules/tttx-table/test/tttx-table.e2e.d.ts +0 -1
  96. package/dist/types/components/molecules/tttx-table/tttx-table.d.ts +0 -15
@@ -1,146 +0,0 @@
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
- });
@@ -1,9 +0,0 @@
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
- });
@@ -1,166 +0,0 @@
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
- }
@@ -1,174 +0,0 @@
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
- }
@@ -1,81 +0,0 @@
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
- };
@@ -1,85 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { d as defineCustomElement$2 } from './tttx-icon2.js';
3
-
4
- const tttxTableCss = "// SPACING $spacing-unit: 4px; // REGULAR $horizontal-spacing: $spacing-unit * 4; $vertical-spacing: $spacing-unit * 2; $base-padding: $vertical-spacing $horizontal-spacing; $base-height: $spacing-unit * 9; $component-spacing: $spacing-unit * 4; // SMALL $horizontal-spacing-sm: $spacing-unit * 2; $vertical-spacing-sm: $spacing-unit * 1; $base-padding-sm: $vertical-spacing-sm $horizontal-spacing-sm; $base-height-sm: $spacing-unit * 7; // COLOURS $grey-0: #212121; $grey-1: #363636; $grey-2: #4c4c4c; $grey-3: #636363; $grey-4: #757575; $grey-5: #9e9e9e; $grey-6: #aeaeae; $grey-7: #c8c8c8; $grey-8: #e3e3e3; $grey-9: #f0f0f0; $white: white; $black: $grey-0; $transparent: transparent; $blue-0: #00187c; $blue-1: #032e8c; $blue-2: #0849a3; $blue-3: #0951a8; $blue-4: #1169ba; $blue-5: #1479c6; $blue-6: #5194d2; $blue-7: #7aacdd; $blue-8: #b9d5ed; $blue-9: #e7f1f9; $red-0: #7c0000; $red-1: #8c0000; $red-2: #a30000; $red-3: #a80000; $red-4: #ba0000; $red-5: #dc0000; $red-6: #d25151; $red-7: #dd7a7a; $red-8: #edc1c1; $red-9: #f9e7e7; $black-1: #e6e6e6; $brand: $blue-0; $accent: $blue-5; $accent-selected: $blue-9; $error: $red-5; $severity-critical: #dc0000; $severity-warning: #f59500; $severity-success: #a2bb31; $severity-info: $accent; $ui-primary: $black; $ui-secondary: $grey-4; $ui-disabled: $grey-2; $ui-placeholder: $grey-5; $ui-background: $grey-9; $ui-sheet: $white; $ui-border: #d5d5d5; // BORDERS $ui-border-radius: 4px; $ui-border-width: 1px; // TYPOGRAPHY $font-size-default: 16px; $font-size-small: 14px; .material-symbols-rounded{font-variation-settings:'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24}.skeleton{animation:skeleton-loading 1s linear infinite alternate;border-radius:4px;width:100%}@keyframes skeleton-loading{0%{background-color:hsl(200, 20%, 80%)}100%{background-color:hsl(200, 20%, 95%)}}:host{display:block}table{box-sizing:border-box;width:100%;border-collapse:collapse;border-spacing:0;border:1px solid #ddd;border-bottom:none}thead tr{height:52px;color:#757575}tbody tr{height:48px;color:#212121}tr{font-family:'Roboto', sans-serif;font-weight:400;font-size:16px;display:flex;align-items:center;border-bottom:1px solid #ddd}.selected{background-color:#F0F0F0}.checked{background-color:#e7f1f9}td,th{min-width:300px;margin-left:16px;display:flex;align-items:left}.skeleton{height:24px;display:block}.align-right{margin-left:auto}";
5
-
6
- const TttxTable$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
- constructor() {
8
- super();
9
- this.__registerHost();
10
- this.__attachShadow();
11
- this.rowSelected = createEvent(this, "rowSelected", 7);
12
- this.headerClicked = createEvent(this, "headerClicked", 7);
13
- this.headers = [];
14
- this.data = [];
15
- this.loading = false;
16
- this.selected = -1;
17
- }
18
- handleKeyDown(ev) {
19
- if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp') {
20
- this.updateSelectedIndex(ev.key);
21
- this.emitRowSelected();
22
- }
23
- }
24
- updateSelectedIndex(key) {
25
- if (this.selected === -1) {
26
- this.selected = 0;
27
- }
28
- else {
29
- const isArrowDown = key === 'ArrowDown';
30
- const isArrowUp = key === 'ArrowUp';
31
- if (isArrowDown && this.selected < this.data.length - 1) {
32
- this.selected++;
33
- }
34
- else if (isArrowUp && this.selected > 0) {
35
- this.selected--;
36
- }
37
- }
38
- }
39
- emitRowSelected() {
40
- this.rowSelected.emit(this.data[this.selected]);
41
- }
42
- rowSelectedHandler(row) {
43
- this.rowSelected.emit(row);
44
- this.selected = this.data.findIndex((item) => item === row);
45
- }
46
- headerClickedHandler(key) {
47
- this.headerClicked.emit(key);
48
- }
49
- render() {
50
- return (h(Host, null, h("table", null, h("thead", null, h("tr", null, this.loading ?
51
- [1, 2, 3].map(() => (h("th", null, h("div", { class: "skeleton" })))) :
52
- this.headers && this.headers.map((header) => (h("th", { scope: "col", onClick: () => this.headerClickedHandler(header.key) }, header.label))))), h("tbody", null, this.loading ?
53
- [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" }))))) :
54
- 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" })))))))))))));
55
- }
56
- static get style() { return tttxTableCss; }
57
- }, [1, "tttx-table", {
58
- "headers": [16],
59
- "data": [16],
60
- "loading": [4],
61
- "selected": [2]
62
- }, [[4, "keydown", "handleKeyDown"]]]);
63
- function defineCustomElement$1() {
64
- if (typeof customElements === "undefined") {
65
- return;
66
- }
67
- const components = ["tttx-table", "tttx-icon"];
68
- components.forEach(tagName => { switch (tagName) {
69
- case "tttx-table":
70
- if (!customElements.get(tagName)) {
71
- customElements.define(tagName, TttxTable$1);
72
- }
73
- break;
74
- case "tttx-icon":
75
- if (!customElements.get(tagName)) {
76
- defineCustomElement$2();
77
- }
78
- break;
79
- } });
80
- }
81
-
82
- const TttxTable = TttxTable$1;
83
- const defineCustomElement = defineCustomElement$1;
84
-
85
- export { TttxTable, defineCustomElement };