@3t-transform/threeteeui 0.1.5 → 0.1.7
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/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-211819bc.js +6 -0
- package/dist/cjs/dom-9deb26c8.js +75 -0
- package/dist/cjs/index-11cfdabe.js +3297 -0
- package/dist/cjs/{index-906c2757.js → index-451f61dd.js} +3 -102
- package/dist/cjs/loader.cjs.js +19 -4
- package/dist/cjs/shadow-css-bf3843d2.js +389 -0
- package/dist/cjs/{tttx-button_2.cjs.entry.js → tttx-button.cjs.entry.js} +24 -50
- package/dist/cjs/tttx-form.cjs.entry.js +364 -364
- package/dist/cjs/tttx-icon.cjs.entry.js +21 -0
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +57 -57
- package/dist/cjs/tttx-list.cjs.entry.js +76 -46
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +61 -58
- package/dist/cjs/tttx-toolbar.cjs.entry.js +20 -0
- package/dist/cjs/tttx.cjs.js +117 -9
- package/dist/collection/collection-manifest.json +4 -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 +83 -0
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -116
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
- 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-icon/tttx-icon.css +4 -0
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
- package/dist/collection/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.js +216 -0
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +107 -107
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
- package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js +64 -0
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +35 -35
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.spec.js +38 -0
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +58 -58
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.spec.js +214 -0
- package/dist/collection/components/molecules/tttx-form/test/tttx-form.e2e.js +9 -0
- package/dist/collection/components/molecules/tttx-form/test/tttx-form.spec.js +232 -0
- package/dist/collection/components/molecules/tttx-form/tttx-form.css +32 -3
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +364 -364
- package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +127 -127
- package/dist/collection/components/molecules/tttx-list/test/ttttx-list.spec.e2e.js +26 -0
- package/dist/collection/components/molecules/tttx-list/test/tttx-list.spec.js +183 -0
- package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
- package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
- 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 +219 -0
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.css +32 -3
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +627 -572
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +148 -135
- package/dist/collection/components/molecules/tttx-toolbar/test/tttx-toolbar.test.js +0 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.css +30 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +20 -0
- package/dist/collection/components/palette.stories.js +7 -7
- package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
- package/dist/collection/icons.js +2838 -2838
- package/dist/collection/index.js +1 -1
- package/dist/collection/shared/domsanitiser.options.js +14 -14
- package/dist/collection/shared/test/domsanitiser.options.spec.js +23 -0
- package/dist/components/index.d.ts +1 -9
- package/dist/components/index.js +6 -1
- package/dist/components/tttx-button.js +48 -59
- package/dist/components/tttx-form.js +381 -381
- package/dist/components/tttx-icon2.js +29 -29
- package/dist/components/tttx-keyvalue-block.js +74 -74
- package/dist/components/tttx-list.js +98 -68
- package/dist/components/tttx-loading-spinner.js +33 -33
- package/dist/components/tttx-standalone-input.js +108 -102
- package/dist/components/tttx-toolbar.d.ts +11 -0
- package/dist/components/tttx-toolbar.js +36 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-9d54a2f2.js +4 -0
- package/dist/esm/dom-6be6f662.js +73 -0
- package/dist/esm/{index-4010ad69.js → index-0350f122.js} +4 -101
- package/dist/esm/index-dbe25028.js +3262 -0
- package/dist/esm/loader.js +19 -4
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/shadow-css-ed4599f8.js +387 -0
- package/dist/esm/{tttx-button_2.entry.js → tttx-button.entry.js} +25 -50
- package/dist/esm/tttx-form.entry.js +364 -364
- package/dist/esm/tttx-icon.entry.js +17 -0
- package/dist/esm/tttx-keyvalue-block.entry.js +57 -57
- package/dist/esm/tttx-list.entry.js +76 -46
- package/dist/esm/tttx-loading-spinner.entry.js +16 -16
- package/dist/esm/tttx-standalone-input.entry.js +61 -58
- package/dist/esm/tttx-toolbar.entry.js +16 -0
- package/dist/esm/tttx.js +117 -6
- package/dist/tttx/app-globals-0f993ce5.js +3 -0
- package/dist/tttx/css-shim-9d54a2f2.js +4 -0
- package/dist/tttx/dom-6be6f662.js +73 -0
- package/dist/tttx/index-dbe25028.js +3262 -0
- package/dist/tttx/index.esm.js +1 -0
- package/dist/tttx/p-0a85dda4.entry.js +1 -0
- package/dist/tttx/{p-3281444a.entry.js → p-1b015a9d.entry.js} +1 -1
- package/dist/tttx/p-4f3958fa.entry.js +1 -0
- package/dist/tttx/p-5cae1beb.entry.js +1 -0
- package/dist/tttx/p-62869344.js +2 -0
- package/dist/tttx/p-92465671.entry.js +1 -0
- package/dist/tttx/{p-dab7ee1b.entry.js → p-a0179cb1.entry.js} +1 -1
- package/dist/tttx/p-cc6644c9.entry.js +1 -0
- package/dist/tttx/p-cd1565e0.entry.js +3 -0
- package/dist/tttx/shadow-css-ed4599f8.js +387 -0
- package/dist/tttx/tttx-button.entry.js +30 -0
- package/dist/tttx/tttx-form.entry.js +373 -0
- package/dist/tttx/tttx-icon.entry.js +17 -0
- package/dist/tttx/tttx-keyvalue-block.entry.js +63 -0
- package/dist/tttx/tttx-list.entry.js +1730 -0
- package/dist/tttx/tttx-loading-spinner.entry.js +22 -0
- package/dist/tttx/tttx-standalone-input.entry.js +66 -0
- package/dist/tttx/tttx-toolbar.entry.js +16 -0
- package/dist/tttx/tttx.esm.js +129 -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-button/tttx-button.d.ts +10 -13
- package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
- 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-icon/tttx-icon.d.ts +5 -5
- package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
- package/dist/types/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
- package/dist/types/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/test/tttx-form.e2e.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/test/tttx-form.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +114 -114
- package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -13
- package/dist/types/components/molecules/tttx-list/test/ttttx-list.spec.e2e.d.ts +1 -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 +11 -11
- package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
- 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 +56 -53
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +122 -106
- package/dist/types/components/molecules/tttx-toolbar/test/tttx-toolbar.test.d.ts +0 -0
- package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -0
- package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -0
- package/dist/types/components/palette.stories.d.ts +6 -6
- package/dist/types/components.d.ts +21 -0
- package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
- package/dist/types/icons.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/domsanitiser.options.d.ts +10 -10
- package/dist/types/shared/test/domsanitiser.options.spec.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +3 -59
- package/loader/index.d.ts +0 -9
- package/package.json +1 -1
- package/dist/collection/transform-tag-name.js +0 -5
- package/dist/tttx/p-083eeedc.entry.js +0 -1
- package/dist/tttx/p-5687f4ad.js +0 -2
- package/dist/tttx/p-5c9a1626.entry.js +0 -3
- package/dist/tttx/p-931e42c9.entry.js +0 -1
- package/dist/tttx/p-b5c1dd86.entry.js +0 -1
- package/dist/types/transform-tag-name.d.ts +0 -1
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import { withActions } from '@storybook/addon-actions/decorator';
|
|
2
|
-
export default {
|
|
3
|
-
title: 'molecules/Form',
|
|
4
|
-
component: 'tttx-form',
|
|
5
|
-
parameters: {
|
|
6
|
-
actions: {
|
|
7
|
-
handles: ['dataSubmitted', 'dataChanged'],
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
decorators: [withActions],
|
|
11
|
-
};
|
|
12
|
-
const formSchema = {
|
|
13
|
-
properties: {
|
|
14
|
-
title: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
format: 'string',
|
|
17
|
-
form: {
|
|
18
|
-
type: 'text',
|
|
19
|
-
placeholder: 'Mr, Mrs, Dr, Hon Rev',
|
|
20
|
-
label: 'Title',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
forename: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
format: 'string',
|
|
26
|
-
form: {
|
|
27
|
-
type: 'text',
|
|
28
|
-
placeholder: 'John',
|
|
29
|
-
label: 'Forename',
|
|
30
|
-
validation: {
|
|
31
|
-
required: {
|
|
32
|
-
message: 'Please enter your forename',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
surname: {
|
|
38
|
-
type: 'string',
|
|
39
|
-
format: 'string',
|
|
40
|
-
form: {
|
|
41
|
-
type: 'text',
|
|
42
|
-
placeholder: 'Doe',
|
|
43
|
-
label: 'Surname',
|
|
44
|
-
validation: {
|
|
45
|
-
required: {
|
|
46
|
-
message: 'Please enter your surname',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
postcode: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
format: 'string',
|
|
54
|
-
form: {
|
|
55
|
-
type: 'text',
|
|
56
|
-
placeholder: 'AB10',
|
|
57
|
-
label: 'Start of postcode',
|
|
58
|
-
validation: {
|
|
59
|
-
required: {
|
|
60
|
-
message: 'Please enter the beginning of your postcode',
|
|
61
|
-
},
|
|
62
|
-
pattern: {
|
|
63
|
-
pattern: '^([A-Za-z][0-9])$|^([A-Za-z][0-9]{2})$|^([A-Za-z]{2}[0-9])$|^([A-Za-z]{2}[0-9]{2})$|^([A-Za-z][0-9][A-Za-z])$|^([A-Za-z]{2}[0-9][A-Za-z])$|^(GIR|BF|BX|XX)$',
|
|
64
|
-
message: 'Please enter the first half of your postcode. EG: ZZ99',
|
|
65
|
-
},
|
|
66
|
-
maxlength: 4,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
age: {
|
|
71
|
-
type: 'number',
|
|
72
|
-
format: 'number',
|
|
73
|
-
form: {
|
|
74
|
-
type: 'number',
|
|
75
|
-
placeholder: '',
|
|
76
|
-
label: 'Age',
|
|
77
|
-
validation: {
|
|
78
|
-
required: {
|
|
79
|
-
message: 'Please enter your age',
|
|
80
|
-
},
|
|
81
|
-
badInput: {
|
|
82
|
-
message: 'Please enter a number',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
dob: {
|
|
88
|
-
type: 'string',
|
|
89
|
-
format: 'date-time',
|
|
90
|
-
form: {
|
|
91
|
-
type: 'date',
|
|
92
|
-
placeholder: '',
|
|
93
|
-
label: 'Date of birth',
|
|
94
|
-
validation: {
|
|
95
|
-
required: {
|
|
96
|
-
message: 'Please enter your date of birth',
|
|
97
|
-
},
|
|
98
|
-
minmax: {
|
|
99
|
-
min: '1900-01-01',
|
|
100
|
-
max: '2100-12-31',
|
|
101
|
-
message: 'Please enter a date between 1900 and 2100',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
const jsonFormSchema = JSON.stringify(formSchema);
|
|
109
|
-
export const ExampleFormFromJSON = () => `<tttx-form formSchema='${jsonFormSchema}'></tttx-form>`;
|
|
110
|
-
const singleFormItemSchema = {
|
|
111
|
-
properties: {
|
|
112
|
-
input: {
|
|
113
|
-
type: 'string',
|
|
114
|
-
format: 'string',
|
|
115
|
-
form: {
|
|
116
|
-
type: 'text',
|
|
117
|
-
label: 'Input Field',
|
|
118
|
-
validation: {
|
|
119
|
-
required: {
|
|
120
|
-
message: 'Please enter something'
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
export const SingleFormItem = () => `<tttx-form formSchema='${JSON.stringify(singleFormItemSchema)}'></tttx-form>`;
|
|
1
|
+
import { withActions } from '@storybook/addon-actions/decorator';
|
|
2
|
+
export default {
|
|
3
|
+
title: 'molecules/Form',
|
|
4
|
+
component: 'tttx-form',
|
|
5
|
+
parameters: {
|
|
6
|
+
actions: {
|
|
7
|
+
handles: ['dataSubmitted', 'dataChanged'],
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
decorators: [withActions],
|
|
11
|
+
};
|
|
12
|
+
const formSchema = {
|
|
13
|
+
properties: {
|
|
14
|
+
title: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
format: 'string',
|
|
17
|
+
form: {
|
|
18
|
+
type: 'text',
|
|
19
|
+
placeholder: 'Mr, Mrs, Dr, Hon Rev',
|
|
20
|
+
label: 'Title',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
forename: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
format: 'string',
|
|
26
|
+
form: {
|
|
27
|
+
type: 'text',
|
|
28
|
+
placeholder: 'John',
|
|
29
|
+
label: 'Forename',
|
|
30
|
+
validation: {
|
|
31
|
+
required: {
|
|
32
|
+
message: 'Please enter your forename',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
surname: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
format: 'string',
|
|
40
|
+
form: {
|
|
41
|
+
type: 'text',
|
|
42
|
+
placeholder: 'Doe',
|
|
43
|
+
label: 'Surname',
|
|
44
|
+
validation: {
|
|
45
|
+
required: {
|
|
46
|
+
message: 'Please enter your surname',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
postcode: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
format: 'string',
|
|
54
|
+
form: {
|
|
55
|
+
type: 'text',
|
|
56
|
+
placeholder: 'AB10',
|
|
57
|
+
label: 'Start of postcode',
|
|
58
|
+
validation: {
|
|
59
|
+
required: {
|
|
60
|
+
message: 'Please enter the beginning of your postcode',
|
|
61
|
+
},
|
|
62
|
+
pattern: {
|
|
63
|
+
pattern: '^([A-Za-z][0-9])$|^([A-Za-z][0-9]{2})$|^([A-Za-z]{2}[0-9])$|^([A-Za-z]{2}[0-9]{2})$|^([A-Za-z][0-9][A-Za-z])$|^([A-Za-z]{2}[0-9][A-Za-z])$|^(GIR|BF|BX|XX)$',
|
|
64
|
+
message: 'Please enter the first half of your postcode. EG: ZZ99',
|
|
65
|
+
},
|
|
66
|
+
maxlength: 4,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
age: {
|
|
71
|
+
type: 'number',
|
|
72
|
+
format: 'number',
|
|
73
|
+
form: {
|
|
74
|
+
type: 'number',
|
|
75
|
+
placeholder: '',
|
|
76
|
+
label: 'Age',
|
|
77
|
+
validation: {
|
|
78
|
+
required: {
|
|
79
|
+
message: 'Please enter your age',
|
|
80
|
+
},
|
|
81
|
+
badInput: {
|
|
82
|
+
message: 'Please enter a number',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
dob: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
format: 'date-time',
|
|
90
|
+
form: {
|
|
91
|
+
type: 'date',
|
|
92
|
+
placeholder: '',
|
|
93
|
+
label: 'Date of birth',
|
|
94
|
+
validation: {
|
|
95
|
+
required: {
|
|
96
|
+
message: 'Please enter your date of birth',
|
|
97
|
+
},
|
|
98
|
+
minmax: {
|
|
99
|
+
min: '1900-01-01',
|
|
100
|
+
max: '2100-12-31',
|
|
101
|
+
message: 'Please enter a date between 1900 and 2100',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
const jsonFormSchema = JSON.stringify(formSchema);
|
|
109
|
+
export const ExampleFormFromJSON = () => `<tttx-form formSchema='${jsonFormSchema}'></tttx-form>`;
|
|
110
|
+
const singleFormItemSchema = {
|
|
111
|
+
properties: {
|
|
112
|
+
input: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
format: 'string',
|
|
115
|
+
form: {
|
|
116
|
+
type: 'text',
|
|
117
|
+
label: 'Input Field',
|
|
118
|
+
validation: {
|
|
119
|
+
required: {
|
|
120
|
+
message: 'Please enter something'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
export const SingleFormItem = () => `<tttx-form formSchema='${JSON.stringify(singleFormItemSchema)}'></tttx-form>`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
+
describe('tttx-list', () => {
|
|
3
|
+
it('sanitises the html of the element property', async () => {
|
|
4
|
+
const page = await newE2EPage();
|
|
5
|
+
await page.setContent('<tttx-list></tttx-list>');
|
|
6
|
+
await page.$eval('tttx-list', (elm) => {
|
|
7
|
+
elm.data = [{ element: '<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>Test<script>alert(4)</script>' }];
|
|
8
|
+
});
|
|
9
|
+
await page.waitForChanges();
|
|
10
|
+
const element = await page.find('tttx-list');
|
|
11
|
+
expect(element).toEqualHtml(`
|
|
12
|
+
<tttx-list class="hydrated">
|
|
13
|
+
<mock:shadow-root>
|
|
14
|
+
<ul class="list">
|
|
15
|
+
<li class="item">
|
|
16
|
+
<span class="item-content">
|
|
17
|
+
<span><tttx-icon class="hydrated" icon="egg" color="blue"></tttx-icon></span>
|
|
18
|
+
Test
|
|
19
|
+
</span>
|
|
20
|
+
</li>
|
|
21
|
+
</ul>
|
|
22
|
+
</mock:shadow-root>
|
|
23
|
+
</tttx-list>
|
|
24
|
+
`);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { TttxList } from '../tttx-list';
|
|
3
|
+
describe('tttx-list', () => {
|
|
4
|
+
it('renders data using JS objects (with icon, clickable)', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [TttxList],
|
|
7
|
+
html: '<tttx-list></tttx-list>',
|
|
8
|
+
});
|
|
9
|
+
page.rootInstance.data = [{ icon: 'info', element: '<span><tttx-icon icon="egg" color="blue" /></span> Test', clickable: true }];
|
|
10
|
+
await page.waitForChanges();
|
|
11
|
+
expect(page.root).toEqualHtml(`
|
|
12
|
+
<tttx-list>
|
|
13
|
+
<mock:shadow-root>
|
|
14
|
+
<ul class="list">
|
|
15
|
+
<li class="item clickable">
|
|
16
|
+
<span class="item-content">
|
|
17
|
+
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
18
|
+
Test
|
|
19
|
+
</span>
|
|
20
|
+
<tttx-icon class="align-right" icon="info"></tttx-icon>
|
|
21
|
+
</li>
|
|
22
|
+
</ul>
|
|
23
|
+
</mock:shadow-root>
|
|
24
|
+
</tttx-list>
|
|
25
|
+
`);
|
|
26
|
+
});
|
|
27
|
+
it('renders data using JS objects (with icon, clickable:false)', async () => {
|
|
28
|
+
const page = await newSpecPage({
|
|
29
|
+
components: [TttxList],
|
|
30
|
+
html: '<tttx-list></tttx-list>',
|
|
31
|
+
});
|
|
32
|
+
page.rootInstance.data = [{ icon: 'info', element: '<span><tttx-icon icon="egg" color="blue" /></span> Test' }];
|
|
33
|
+
await page.waitForChanges();
|
|
34
|
+
expect(page.root).toEqualHtml(`
|
|
35
|
+
<tttx-list>
|
|
36
|
+
<mock:shadow-root>
|
|
37
|
+
<ul class="list">
|
|
38
|
+
<li class="item">
|
|
39
|
+
<span class="item-content">
|
|
40
|
+
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
41
|
+
Test
|
|
42
|
+
</span>
|
|
43
|
+
<tttx-icon class="align-right" icon="info"></tttx-icon>
|
|
44
|
+
</li>
|
|
45
|
+
</ul>
|
|
46
|
+
</mock:shadow-root>
|
|
47
|
+
</tttx-list>
|
|
48
|
+
`);
|
|
49
|
+
});
|
|
50
|
+
it('renders data using JS objects (without icon, clickable)', async () => {
|
|
51
|
+
const page = await newSpecPage({
|
|
52
|
+
components: [TttxList],
|
|
53
|
+
html: '<tttx-list></tttx-list>',
|
|
54
|
+
});
|
|
55
|
+
page.rootInstance.data = [{ element: '<span><tttx-icon icon="egg" color="blue" /></span> Test', clickable: true }];
|
|
56
|
+
await page.waitForChanges();
|
|
57
|
+
expect(page.root).toEqualHtml(`
|
|
58
|
+
<tttx-list>
|
|
59
|
+
<mock:shadow-root>
|
|
60
|
+
<ul class="list">
|
|
61
|
+
<li class="item clickable">
|
|
62
|
+
<span class="item-content">
|
|
63
|
+
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
64
|
+
Test
|
|
65
|
+
</span>
|
|
66
|
+
</li>
|
|
67
|
+
</ul>
|
|
68
|
+
</mock:shadow-root>
|
|
69
|
+
</tttx-list>
|
|
70
|
+
`);
|
|
71
|
+
});
|
|
72
|
+
it('renders data using JS objects (without icon, clickable:false)', async () => {
|
|
73
|
+
const page = await newSpecPage({
|
|
74
|
+
components: [TttxList],
|
|
75
|
+
html: '<tttx-list></tttx-list>',
|
|
76
|
+
});
|
|
77
|
+
page.rootInstance.data = [{ element: '<span><tttx-icon icon="egg" color="blue" /></span> Test' }];
|
|
78
|
+
await page.waitForChanges();
|
|
79
|
+
expect(page.root).toEqualHtml(`
|
|
80
|
+
<tttx-list>
|
|
81
|
+
<mock:shadow-root>
|
|
82
|
+
<ul class="list">
|
|
83
|
+
<li class="item">
|
|
84
|
+
<span class="item-content">
|
|
85
|
+
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
86
|
+
Test
|
|
87
|
+
</span>
|
|
88
|
+
</li>
|
|
89
|
+
</ul>
|
|
90
|
+
</mock:shadow-root>
|
|
91
|
+
</tttx-list>
|
|
92
|
+
`);
|
|
93
|
+
});
|
|
94
|
+
it('renders data using JSON', async () => {
|
|
95
|
+
const data = '[{ "icon": "info", "element": "<span><tttx-icon icon=\\"egg\\" color=\\"blue\\" /></span> Test", "clickable": true }]';
|
|
96
|
+
const page = await newSpecPage({
|
|
97
|
+
components: [TttxList],
|
|
98
|
+
html: `<tttx-list data='${data}'></tttx-list>`,
|
|
99
|
+
});
|
|
100
|
+
await page.waitForChanges();
|
|
101
|
+
expect(page.root).toEqualHtml(`
|
|
102
|
+
<tttx-list data="[{ "icon": "info", "element": "<span><tttx-icon icon=\\"egg\\" color=\\"blue\\" /></span> Test", "clickable": true }]">
|
|
103
|
+
<mock:shadow-root>
|
|
104
|
+
<ul class="list">
|
|
105
|
+
<li class="item clickable">
|
|
106
|
+
<span class="item-content">
|
|
107
|
+
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
108
|
+
Test
|
|
109
|
+
</span>
|
|
110
|
+
<tttx-icon class="align-right" icon="info"></tttx-icon>
|
|
111
|
+
</li>
|
|
112
|
+
</ul>
|
|
113
|
+
</mock:shadow-root>
|
|
114
|
+
</tttx-list>
|
|
115
|
+
`);
|
|
116
|
+
});
|
|
117
|
+
it('renders nothing when there is no data', async () => {
|
|
118
|
+
const page = await newSpecPage({
|
|
119
|
+
components: [TttxList],
|
|
120
|
+
html: '<tttx-list></tttx-list>',
|
|
121
|
+
});
|
|
122
|
+
page.rootInstance.data = [];
|
|
123
|
+
await page.waitForChanges();
|
|
124
|
+
expect(page.root).toEqualHtml(`
|
|
125
|
+
<tttx-list>
|
|
126
|
+
<mock:shadow-root>
|
|
127
|
+
<ul class="list">
|
|
128
|
+
</ul>
|
|
129
|
+
</mock:shadow-root>
|
|
130
|
+
</tttx-list>
|
|
131
|
+
`);
|
|
132
|
+
});
|
|
133
|
+
it('emits listRowClick event when a clickable row is clicked', async () => {
|
|
134
|
+
const page = await newSpecPage({
|
|
135
|
+
components: [TttxList],
|
|
136
|
+
html: '<tttx-list name="test-list"></tttx-list>',
|
|
137
|
+
});
|
|
138
|
+
const eventSpy = jest.fn();
|
|
139
|
+
page.doc.addEventListener('listRowClick', eventSpy);
|
|
140
|
+
page.rootInstance.data = [
|
|
141
|
+
{ element: '<div>Item 1</div>', clickable: true, rowData: 'Item 1' },
|
|
142
|
+
{ element: '<div>Item 2</div>', clickable: false, rowData: 'Item 2' },
|
|
143
|
+
];
|
|
144
|
+
await page.waitForChanges();
|
|
145
|
+
const clickableItem = page.root.shadowRoot.querySelector('.clickable');
|
|
146
|
+
clickableItem.dispatchEvent(new Event('click'));
|
|
147
|
+
expect(eventSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
148
|
+
detail: { name: 'test-list', data: 'Item 1' },
|
|
149
|
+
}));
|
|
150
|
+
});
|
|
151
|
+
it('does not emit listRowClick event when a non-clickable row is clicked', async () => {
|
|
152
|
+
const page = await newSpecPage({
|
|
153
|
+
components: [TttxList],
|
|
154
|
+
html: '<tttx-list></tttx-list>',
|
|
155
|
+
});
|
|
156
|
+
const eventSpy = jest.fn();
|
|
157
|
+
page.doc.addEventListener('listRowClick', eventSpy);
|
|
158
|
+
page.rootInstance.data = [
|
|
159
|
+
{ element: '<div>Item 1</div>', clickable: true, rowData: 'Item 1' },
|
|
160
|
+
{ element: '<div>Item 2</div>', clickable: false, rowData: 'Item 2' },
|
|
161
|
+
];
|
|
162
|
+
await page.waitForChanges();
|
|
163
|
+
const nonClickableItem = page.root.shadowRoot.querySelector(':not(.clickable)');
|
|
164
|
+
await nonClickableItem.dispatchEvent(new Event('click'));
|
|
165
|
+
expect(eventSpy).not.toHaveBeenCalled();
|
|
166
|
+
});
|
|
167
|
+
it('does not emit listRowClick event when a row without rowData is clicked', async () => {
|
|
168
|
+
const page = await newSpecPage({
|
|
169
|
+
components: [TttxList],
|
|
170
|
+
html: '<tttx-list></tttx-list>',
|
|
171
|
+
});
|
|
172
|
+
const eventSpy = jest.fn();
|
|
173
|
+
page.doc.addEventListener('listRowClick', eventSpy);
|
|
174
|
+
page.rootInstance.data = [
|
|
175
|
+
{ element: '<div>Item 1</div>', clickable: true },
|
|
176
|
+
{ element: '<div>Item 2</div>', clickable: false },
|
|
177
|
+
];
|
|
178
|
+
await page.waitForChanges();
|
|
179
|
+
const nonClickableItem = page.root.shadowRoot.querySelector('.clickable');
|
|
180
|
+
await nonClickableItem.dispatchEvent(new Event('click'));
|
|
181
|
+
expect(eventSpy).not.toHaveBeenCalled();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import { h } from '@stencil/core';
|
|
3
|
-
import * as DOMPurify from 'dompurify';
|
|
4
|
-
import domSanitiserOptions from '../../../shared/domsanitiser.options';
|
|
5
|
-
export class TttxList {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.data = undefined;
|
|
8
|
-
this.name = undefined;
|
|
9
|
-
}
|
|
10
|
-
onRowClickHandler(item) {
|
|
11
|
-
if (!item.clickable || !item.rowData)
|
|
12
|
-
return;
|
|
13
|
-
this.rowClick.emit({ name: this.name, data: item.rowData });
|
|
14
|
-
}
|
|
15
|
-
renderListItem(item) {
|
|
16
|
-
const cleanHTML = DOMPurify.sanitize(item.element, domSanitiserOptions);
|
|
17
|
-
return (h("li", { class: `item ${item.clickable ? 'clickable' : ''}`, onClick: () => {
|
|
18
|
-
this.onRowClickHandler(item);
|
|
19
|
-
} }, item.element && h("span", { class: "item-content", innerHTML: cleanHTML }), item.icon && h("tttx-icon", { class: "align-right ", icon: item.icon })));
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
if (!this.data)
|
|
23
|
-
return;
|
|
24
|
-
if (typeof this.data === 'string') {
|
|
25
|
-
this._data = JSON.parse(this.data);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
this._data = this.data;
|
|
29
|
-
}
|
|
30
|
-
return h("ul", { class: "list" }, this._data.map((item) => this.renderListItem(item)));
|
|
31
|
-
}
|
|
32
|
-
static get is() { return "tttx-list"; }
|
|
33
|
-
static get encapsulation() { return "shadow"; }
|
|
34
|
-
static get originalStyleUrls() {
|
|
35
|
-
return {
|
|
36
|
-
"$": ["tttx-list.scss"]
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
static get styleUrls() {
|
|
40
|
-
return {
|
|
41
|
-
"$": ["tttx-list.css"]
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
static get properties() {
|
|
45
|
-
return {
|
|
46
|
-
"data": {
|
|
47
|
-
"type": "string",
|
|
48
|
-
"mutable": true,
|
|
49
|
-
"complexType": {
|
|
50
|
-
"original": "string | ListItem[]",
|
|
51
|
-
"resolved": "ListItem[] | string",
|
|
52
|
-
"references": {
|
|
53
|
-
"ListItem": {
|
|
54
|
-
"location": "import",
|
|
55
|
-
"path": "./interfaces"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"required": false,
|
|
60
|
-
"optional": false,
|
|
61
|
-
"docs": {
|
|
62
|
-
"tags": [],
|
|
63
|
-
"text": ""
|
|
64
|
-
},
|
|
65
|
-
"attribute": "data",
|
|
66
|
-
"reflect": false
|
|
67
|
-
},
|
|
68
|
-
"name": {
|
|
69
|
-
"type": "string",
|
|
70
|
-
"mutable": false,
|
|
71
|
-
"complexType": {
|
|
72
|
-
"original": "string",
|
|
73
|
-
"resolved": "string",
|
|
74
|
-
"references": {}
|
|
75
|
-
},
|
|
76
|
-
"required": false,
|
|
77
|
-
"optional": false,
|
|
78
|
-
"docs": {
|
|
79
|
-
"tags": [],
|
|
80
|
-
"text": ""
|
|
81
|
-
},
|
|
82
|
-
"attribute": "name",
|
|
83
|
-
"reflect": false
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
static get events() {
|
|
88
|
-
return [{
|
|
89
|
-
"method": "rowClick",
|
|
90
|
-
"name": "listRowClick",
|
|
91
|
-
"bubbles": true,
|
|
92
|
-
"cancelable": true,
|
|
93
|
-
"composed": true,
|
|
94
|
-
"docs": {
|
|
95
|
-
"tags": [],
|
|
96
|
-
"text": ""
|
|
97
|
-
},
|
|
98
|
-
"complexType": {
|
|
99
|
-
"original": "any",
|
|
100
|
-
"resolved": "any",
|
|
101
|
-
"references": {}
|
|
102
|
-
}
|
|
103
|
-
}];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { h } from '@stencil/core';
|
|
3
|
+
import * as DOMPurify from 'dompurify';
|
|
4
|
+
import domSanitiserOptions from '../../../shared/domsanitiser.options';
|
|
5
|
+
export class TttxList {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.data = undefined;
|
|
8
|
+
this.name = undefined;
|
|
9
|
+
}
|
|
10
|
+
onRowClickHandler(item) {
|
|
11
|
+
if (!item.clickable || !item.rowData)
|
|
12
|
+
return;
|
|
13
|
+
this.rowClick.emit({ name: this.name, data: item.rowData });
|
|
14
|
+
}
|
|
15
|
+
renderListItem(item) {
|
|
16
|
+
const cleanHTML = DOMPurify.sanitize(item.element, domSanitiserOptions);
|
|
17
|
+
return (h("li", { class: `item ${item.clickable ? 'clickable' : ''}`, onClick: () => {
|
|
18
|
+
this.onRowClickHandler(item);
|
|
19
|
+
} }, item.element && h("span", { class: "item-content", innerHTML: cleanHTML }), item.icon && h("tttx-icon", { class: "align-right ", icon: item.icon })));
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
if (!this.data)
|
|
23
|
+
return;
|
|
24
|
+
if (typeof this.data === 'string') {
|
|
25
|
+
this._data = JSON.parse(this.data);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this._data = this.data;
|
|
29
|
+
}
|
|
30
|
+
return h("ul", { class: "list" }, this._data.map((item) => this.renderListItem(item)));
|
|
31
|
+
}
|
|
32
|
+
static get is() { return "tttx-list"; }
|
|
33
|
+
static get encapsulation() { return "shadow"; }
|
|
34
|
+
static get originalStyleUrls() {
|
|
35
|
+
return {
|
|
36
|
+
"$": ["tttx-list.scss"]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
static get styleUrls() {
|
|
40
|
+
return {
|
|
41
|
+
"$": ["tttx-list.css"]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
static get properties() {
|
|
45
|
+
return {
|
|
46
|
+
"data": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"mutable": true,
|
|
49
|
+
"complexType": {
|
|
50
|
+
"original": "string | ListItem[]",
|
|
51
|
+
"resolved": "ListItem[] | string",
|
|
52
|
+
"references": {
|
|
53
|
+
"ListItem": {
|
|
54
|
+
"location": "import",
|
|
55
|
+
"path": "./interfaces"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"required": false,
|
|
60
|
+
"optional": false,
|
|
61
|
+
"docs": {
|
|
62
|
+
"tags": [],
|
|
63
|
+
"text": ""
|
|
64
|
+
},
|
|
65
|
+
"attribute": "data",
|
|
66
|
+
"reflect": false
|
|
67
|
+
},
|
|
68
|
+
"name": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"mutable": false,
|
|
71
|
+
"complexType": {
|
|
72
|
+
"original": "string",
|
|
73
|
+
"resolved": "string",
|
|
74
|
+
"references": {}
|
|
75
|
+
},
|
|
76
|
+
"required": false,
|
|
77
|
+
"optional": false,
|
|
78
|
+
"docs": {
|
|
79
|
+
"tags": [],
|
|
80
|
+
"text": ""
|
|
81
|
+
},
|
|
82
|
+
"attribute": "name",
|
|
83
|
+
"reflect": false
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static get events() {
|
|
88
|
+
return [{
|
|
89
|
+
"method": "rowClick",
|
|
90
|
+
"name": "listRowClick",
|
|
91
|
+
"bubbles": true,
|
|
92
|
+
"cancelable": true,
|
|
93
|
+
"composed": true,
|
|
94
|
+
"docs": {
|
|
95
|
+
"tags": [],
|
|
96
|
+
"text": ""
|
|
97
|
+
},
|
|
98
|
+
"complexType": {
|
|
99
|
+
"original": "any",
|
|
100
|
+
"resolved": "any",
|
|
101
|
+
"references": {}
|
|
102
|
+
}
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
105
|
+
}
|