@claspo/components 1.6.2 → 1.7.0-components-build-perf
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/package.json +6 -4
- package/script/SysButtonComponent/SysButton.manifest.js +126 -0
- package/script/SysButtonComponent/SysButton.styles.js +64 -0
- package/script/SysButtonComponent/SysButtonComponent.js +231 -0
- package/script/SysColumnComponent/SysColumn.manifest.js +17 -0
- package/script/SysColumnComponent/SysColumnComponent.js +107 -0
- package/script/SysColumnsComponent/SysColumns.manifest.js +17 -0
- package/script/SysColumnsComponent/SysColumnsComponent.js +53 -0
- package/script/SysColumnsComponent/getStyleElement.js +23 -0
- package/script/SysContainerComponent/SysBaseContainerComponent.js +41 -0
- package/script/SysContainerComponent/SysContainer.manifest.js +18 -0
- package/script/SysContainerComponent/SysContainerComponent.js +86 -0
- package/script/SysImageComponent/SysImage.manifest.js +18 -0
- package/script/SysImageComponent/SysImageComponent.js +378 -0
- package/script/SysImageComponent/getStyleElement.js +18 -0
- package/script/SysInputComponent/EmailSuggesting.js +252 -0
- package/script/SysInputComponent/InputFormControl.js +136 -0
- package/script/SysInputComponent/SysInput.manifest.js +728 -0
- package/script/SysInputComponent/SysInputComponent.js +84 -0
- package/script/SysInputComponent/emailProvidersList.js +158 -0
- package/script/SysInputComponent/getOverlayStyles.js +220 -0
- package/script/SysInputComponent/getStyleElement.js +69 -0
- package/script/SysInputComponent/inputValidators.js +293 -0
- package/script/SysTextComponent/SysText.manifest.js +29 -0
- package/script/SysTextComponent/SysTextComponent.js +147 -0
- package/script/SysTextComponent/TextRoller.js +298 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claspo/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-components-build-perf",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "rm -rf out",
|
|
7
|
-
"build": "npm run prebuild && webpack",
|
|
7
|
+
"build": "npm run prebuild && webpack && npm run build:script",
|
|
8
8
|
"build:local": "npm run prebuild && USE_LOCAL_SOURCES=1 webpack",
|
|
9
|
+
"build:script": "rollup -c rollup.script.config.js",
|
|
9
10
|
"dev": "npm run prebuild && npx cross-env dev=1 webpack --watch",
|
|
10
11
|
"dev:local": "npm run prebuild && npx cross-env dev=1 USE_LOCAL_SOURCES=1 webpack --watch",
|
|
11
12
|
"test": "jest --no-cache --config jest.config.js",
|
|
@@ -17,8 +18,8 @@
|
|
|
17
18
|
"node": ">=18.16.0"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@claspo/common": "7.1.
|
|
21
|
-
"@claspo/renderer": "18.4.
|
|
21
|
+
"@claspo/common": "7.1.5",
|
|
22
|
+
"@claspo/renderer": "18.4.2"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@babel/core": "^7.27.4",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"jest": "^29.7.0",
|
|
31
32
|
"jest-environment-jsdom": "^30.0.0-beta.3",
|
|
32
33
|
"jsdom": "^26.1.0",
|
|
34
|
+
"rollup": "^4.39.0",
|
|
33
35
|
"webpack": "^5.99.9",
|
|
34
36
|
"webpack-cli": "^6.0.1"
|
|
35
37
|
},
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import '@claspo/renderer/sdk/ManifestUtils';
|
|
2
|
+
import '@claspo/renderer/sdk/ModelStyleUtils';
|
|
3
|
+
|
|
4
|
+
var SysButtonManifest = {
|
|
5
|
+
"name": "SysButtonComponent",
|
|
6
|
+
"componentType": "BUTTON",
|
|
7
|
+
"version": "1.0.0",
|
|
8
|
+
"autoContrast": [{
|
|
9
|
+
"slave": {
|
|
10
|
+
"element": "button",
|
|
11
|
+
"elementProp": "styleAttributes",
|
|
12
|
+
"elementSubProp": "color"
|
|
13
|
+
},
|
|
14
|
+
"master": {
|
|
15
|
+
"element": "button",
|
|
16
|
+
"elementProp": "styleAttributes",
|
|
17
|
+
"elementSubProp": "background"
|
|
18
|
+
},
|
|
19
|
+
"enabledPropPath": ["content", "textContrastEnabled"]
|
|
20
|
+
}],
|
|
21
|
+
'keepGeneralTabOpenUntilInteracted': true,
|
|
22
|
+
"events": {
|
|
23
|
+
"dispatch": [],
|
|
24
|
+
"listen": []
|
|
25
|
+
},
|
|
26
|
+
"i18nPropPaths": ["content,text", "handlers,[id],actions,[id],params,link", "handlers,[id],actions,[id],params,customData"],
|
|
27
|
+
"i18n": {
|
|
28
|
+
"en": {
|
|
29
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "At least one field is required: email or phone number"
|
|
30
|
+
},
|
|
31
|
+
"ru": {
|
|
32
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Хотя бы одно из полей должно быть заполнено: Email или Номер телефона"
|
|
33
|
+
},
|
|
34
|
+
"uk": {
|
|
35
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Хоча б одне з полів має бути заповнене: Email або Номер телефону"
|
|
36
|
+
},
|
|
37
|
+
"es": {
|
|
38
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Necesita, como mínimo, un campo obligatorio: email o número de teléfono"
|
|
39
|
+
},
|
|
40
|
+
"de": {
|
|
41
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Mindestens ein Feld ist erforderlich: E-Mail-Adresse oder Telefonnummer"
|
|
42
|
+
},
|
|
43
|
+
"fr": {
|
|
44
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Au moins un champ est obligatoire : courriel ou numéro de téléphone"
|
|
45
|
+
},
|
|
46
|
+
"it": {
|
|
47
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Almeno un campo è obbligatorio: email o numero di telefono"
|
|
48
|
+
},
|
|
49
|
+
"pt": {
|
|
50
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "É necessário pelo menos um campo: email ou número de telefone"
|
|
51
|
+
},
|
|
52
|
+
"ro": {
|
|
53
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Cel puțin un câmp este obligatoriu: e-mail sau număr de telefon"
|
|
54
|
+
},
|
|
55
|
+
"bg": {
|
|
56
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Изисква се поне едно поле: имейл или телефонен номер"
|
|
57
|
+
},
|
|
58
|
+
"cs": {
|
|
59
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Je vyžadováno alespoň jedno pole: e-mail nebo telefonní číslo"
|
|
60
|
+
},
|
|
61
|
+
"el": {
|
|
62
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Απαιτείται τουλάχιστον ένα πεδίο: ηλεκτρονική διεύθυνση ή τηλέφωνο"
|
|
63
|
+
},
|
|
64
|
+
"nl": {
|
|
65
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Er is minimaal één veld vereist: e-mail of telefoonnummer"
|
|
66
|
+
},
|
|
67
|
+
"pl": {
|
|
68
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Wymagane jest co najmniej jedno pole: adres e-mail lub numer telefonu"
|
|
69
|
+
},
|
|
70
|
+
"sv": {
|
|
71
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Minst ett fält krävs: e-post eller telefonnummer"
|
|
72
|
+
},
|
|
73
|
+
"tr": {
|
|
74
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "En az bir alan gereklidir: e-posta veya telefon numarası"
|
|
75
|
+
},
|
|
76
|
+
"ar": {
|
|
77
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "مطلوب حقل واحد على الأقل: البريد الإلكتروني أو رقم الهاتف"
|
|
78
|
+
},
|
|
79
|
+
"zh": {
|
|
80
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "至少一个字段为必填:电子邮箱或电话号码"
|
|
81
|
+
},
|
|
82
|
+
"da": {
|
|
83
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Mindst ét felt er påkrævet: e-mail eller telefonnummer"
|
|
84
|
+
},
|
|
85
|
+
"he": {
|
|
86
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "נדרש לפחות שדה אחד: אימייל או מספר טלפון"
|
|
87
|
+
},
|
|
88
|
+
"fi": {
|
|
89
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Vähintään yksi kenttä vaaditaan: sähköposti tai puhelinnumero"
|
|
90
|
+
},
|
|
91
|
+
"hi": {
|
|
92
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "कम से कम एक फ़ील्ड आवश्यक है: ईमेल या फ़ोन नंबर"
|
|
93
|
+
},
|
|
94
|
+
"hr": {
|
|
95
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Potrebno je ispuniti barem jedno polje: e-mail ili telefonski broj"
|
|
96
|
+
},
|
|
97
|
+
"hu": {
|
|
98
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Legalább egy mező kitöltése kötelező: e-mail vagy telefonszám."
|
|
99
|
+
},
|
|
100
|
+
"id": {
|
|
101
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Setidaknya satu bidang wajib diisi: email atau nomor telepon"
|
|
102
|
+
},
|
|
103
|
+
"ja": {
|
|
104
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "少なくとも1つのフィールドが必須です:メールアドレスまたは電話番号"
|
|
105
|
+
},
|
|
106
|
+
"ko": {
|
|
107
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "최소 한 칸 필수 입력: 이메일 또는 전화번호"
|
|
108
|
+
},
|
|
109
|
+
"no": {
|
|
110
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Minst ett felt er obligatorisk: e-post eller telefonnummer"
|
|
111
|
+
},
|
|
112
|
+
"sk": {
|
|
113
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Aspoň jedno pole je povinné: e-mail alebo telefónne číslo"
|
|
114
|
+
},
|
|
115
|
+
"sl": {
|
|
116
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Vsaj eno polje je obvezno: e-poštni naslov ali telefonska številka"
|
|
117
|
+
},
|
|
118
|
+
"sr": {
|
|
119
|
+
"control,validation,validationErrors,EMAIL_OR_PHONE_IS_REQUIRED": "Najmanje jedno polje je obavezno: e-pošta ili broj telefona"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"syncEnabled": true,
|
|
123
|
+
"stylesImitationEnabled": true
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export { SysButtonManifest as default };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
let SysButtonStyles = `
|
|
2
|
+
.main-container {
|
|
3
|
+
position: relative;
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: inherit;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
button {
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
text-overflow: ellipsis;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
outline: none;
|
|
15
|
+
min-height: 20px;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
flex-direction: row;
|
|
19
|
+
gap: var(--iconDistanceToText, 15px);
|
|
20
|
+
z-index: 0;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.editable-text {
|
|
25
|
+
display: var(--textDisplay, 'inline');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.input-tooltip {
|
|
29
|
+
visibility: hidden;
|
|
30
|
+
position: absolute;
|
|
31
|
+
right: -10px;
|
|
32
|
+
top: -10px;
|
|
33
|
+
z-index: 1;
|
|
34
|
+
border-radius: 100%;
|
|
35
|
+
width: 20px;
|
|
36
|
+
height: 20px;
|
|
37
|
+
display: flex;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
align-items: center;
|
|
40
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
41
|
+
-webkit-user-select: none; /* Chrome/Safari/Opera */
|
|
42
|
+
-khtml-user-select: none; /* Konqueror */
|
|
43
|
+
-moz-user-select: none; /* Firefox */
|
|
44
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
45
|
+
user-select: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.icon {
|
|
49
|
+
display: var(--iconDisplay, none);
|
|
50
|
+
width: var(--iconSize, 20px);
|
|
51
|
+
height: var(--iconSize, 20px);
|
|
52
|
+
order: var(--iconOrder, -1);
|
|
53
|
+
background: var(--iconURL);
|
|
54
|
+
margin-top: 0px;
|
|
55
|
+
margin-bottom: 0px;
|
|
56
|
+
background-size: cover;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
button.focus-outline-defined:focus {
|
|
60
|
+
outline: var(--clFocusOutline);
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
export { SysButtonStyles as default };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import SysButtonManifest from './SysButton.manifest.js';
|
|
2
|
+
import SysButtonStyles from './SysButton.styles.js';
|
|
3
|
+
import WcElement from '@claspo/renderer/sdk/WcElement';
|
|
4
|
+
import { HandlerTypes } from '@claspo/common/handler/HandlerTypes';
|
|
5
|
+
import SysActionTypes from '@claspo/renderer/action/SysActionTypes';
|
|
6
|
+
import getComponentCountOnView from '@claspo/renderer/sdk/getComponentCountOnView';
|
|
7
|
+
import { setFocusOutline } from '@claspo/renderer/sdk/HtmlStyleUtils';
|
|
8
|
+
import { setInvalidStyle } from '@claspo/renderer/sdk/FormUtils';
|
|
9
|
+
import insertHtmlIntoElement from '@claspo/common/dom/insertHtmlIntoElement';
|
|
10
|
+
|
|
11
|
+
class SysButtonComponent extends WcElement {
|
|
12
|
+
static define = {
|
|
13
|
+
name: 'sys-button',
|
|
14
|
+
model: SysButtonManifest.name,
|
|
15
|
+
manifest: SysButtonManifest
|
|
16
|
+
};
|
|
17
|
+
manifest = SysButtonManifest;
|
|
18
|
+
|
|
19
|
+
invalidListener;
|
|
20
|
+
validListener;
|
|
21
|
+
stylesUpdateObserver;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.getRootElement().innerHTML = `
|
|
27
|
+
<style>${SysButtonStyles}</style>
|
|
28
|
+
<div class="main-container">
|
|
29
|
+
<button cl-element="button">
|
|
30
|
+
<div class="editable-text" cl-inline-edit="content, text"></div>
|
|
31
|
+
</button>
|
|
32
|
+
|
|
33
|
+
<div class="input-tooltip">
|
|
34
|
+
<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
35
|
+
<path d="M1.5 13.0604C1.5 19.4116 6.6481 24.5605 13.0075 24.5605C19.353 24.5605 24.5 19.4107 24.5 13.0604C24.5 6.70865 19.3531 1.55909 13.0075 1.55908C6.64806 1.55908 1.5 6.7077 1.5 13.0604ZM12.9775 17.9668C12.7032 17.9668 12.4807 17.7443 12.4807 17.47C12.4807 17.1956 12.7032 16.9732 12.9775 16.9732C13.2519 16.9732 13.4743 17.1956 13.4743 17.47C13.4743 17.7443 13.2519 17.9668 12.9775 17.9668ZM12.9775 13.4764C12.7032 13.4764 12.4807 13.254 12.4807 12.9796L12.4807 8.48924C12.4807 8.21487 12.7032 7.99245 12.9775 7.99245C13.2519 7.99245 13.4743 8.21487 13.4743 8.48924L13.4743 12.9796C13.4743 13.254 13.2519 13.4764 12.9775 13.4764Z" fill="#FF0000" stroke="white" stroke-width="2"></path>
|
|
36
|
+
</svg>
|
|
37
|
+
</div>
|
|
38
|
+
</div>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
this.stylesUpdateObserver = new MutationObserver(this.mapStyleControlValuesToInnerButtonContent.bind(this));
|
|
44
|
+
this.stylesUpdateObserver.observe(this.getRootElement().querySelector('button'), {
|
|
45
|
+
attributes: true,
|
|
46
|
+
childList: false,
|
|
47
|
+
subtree: false
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const buttonElement = this.getElement('button');
|
|
51
|
+
buttonElement.addEventListener('click', (e) => {
|
|
52
|
+
this.services.trackingService.send(`FormButtonClick_[Name]`);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (this.getProps().handlers) {
|
|
56
|
+
const clickHandler = this.getProps().handlers.find(handler => handler.type === 'CLICK');
|
|
57
|
+
|
|
58
|
+
if (clickHandler && clickHandler.actions) {
|
|
59
|
+
const subscribeContactAction = clickHandler.actions.find(action => action.type === 'SUBSCRIBE_CONTACT');
|
|
60
|
+
const requestAction = clickHandler.actions.find(action => action.type === 'REQUEST');
|
|
61
|
+
|
|
62
|
+
if (subscribeContactAction) {
|
|
63
|
+
this.invalidListener = this.services.eventEmitter.on('SET_SUBSCRIBE_CONTACT_BUTTON_AS_INVALID', () => {
|
|
64
|
+
this.showErrorTooltip('EMAIL_OR_PHONE_IS_REQUIRED');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
this.validListener = this.services.eventEmitter.on('SET_SUBSCRIBE_CONTACT_BUTTON_AS_VALID', () => {
|
|
68
|
+
this.hideErrorTooltip();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (subscribeContactAction || requestAction) {
|
|
73
|
+
this.services.eventEmitter.on('CONTACT_DATA_SUBMIT', () => {
|
|
74
|
+
buttonElement.disabled = true;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.observeProps((prev, next) => {
|
|
81
|
+
this.applyAutoAdaptiveStyles(next.adaptiveStyles, next.styles);
|
|
82
|
+
setFocusOutline(this.getElement('button'));
|
|
83
|
+
this.mapStyleControlValuesToInnerButtonContent();
|
|
84
|
+
|
|
85
|
+
const button = this.getRootElement().querySelector('button');
|
|
86
|
+
this.updateButtonTextNode(next);
|
|
87
|
+
this.createIconNode(button);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
disconnectedCallback() {
|
|
92
|
+
super.disconnectedCallback();
|
|
93
|
+
if (this.invalidListener) {
|
|
94
|
+
this.invalidListener.off();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.validListener) {
|
|
98
|
+
this.validListener.off();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.stylesUpdateObserver?.disconnect();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
hideErrorTooltip() {
|
|
105
|
+
this.getRootElement()
|
|
106
|
+
.querySelector('.input-tooltip')
|
|
107
|
+
.style.visibility = 'hidden';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
updateButtonTextNode(props) {
|
|
111
|
+
const existingEditableTextNode = this.getRootElement().querySelector('.editable-text');
|
|
112
|
+
insertHtmlIntoElement({
|
|
113
|
+
element: existingEditableTextNode,
|
|
114
|
+
html: props.content.text,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
mapStyleControlValuesToInnerButtonContent() {
|
|
119
|
+
const button = this.getRootElement().querySelector('button');
|
|
120
|
+
const editableText = this.getRootElement().querySelector('.editable-text');
|
|
121
|
+
|
|
122
|
+
if (!button || !editableText) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this.mapAlignValueToButtonContent(button);
|
|
127
|
+
|
|
128
|
+
editableText.style.minWidth = '20px';
|
|
129
|
+
editableText.style.width = 'max-content';
|
|
130
|
+
editableText.style.minHeight = button.style.fontSize;
|
|
131
|
+
|
|
132
|
+
// Workaround for inline edit (copying text-related styles, so inline edit looks same)
|
|
133
|
+
editableText.style.textAlign = button.style.textAlign;
|
|
134
|
+
editableText.style.lineHeight = button.style.lineHeight;
|
|
135
|
+
editableText.style.fontWeight = button.style.fontWeight;
|
|
136
|
+
editableText.style.fontSize = button.style.fontSize;
|
|
137
|
+
editableText.style.textShadow = button.style.textShadow;
|
|
138
|
+
editableText.style.textTransform = button.style.textTransform;
|
|
139
|
+
editableText.style.letterSpacing = button.style.letterSpacing;
|
|
140
|
+
editableText.style.fontFamily = button.style.fontFamily;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
mapAlignValueToButtonContent(button) {
|
|
144
|
+
if (button.style.textAlign === 'center') {
|
|
145
|
+
button.style.alignItems = 'center';
|
|
146
|
+
button.style.justifyContent = 'center';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (button.style.textAlign === 'start') {
|
|
150
|
+
button.style.alignItems = button.style.flexDirection === 'column' ? 'flex-start' : 'center';
|
|
151
|
+
button.style.justifyContent = button.style.flexDirection === 'column' ? 'center' : 'flex-start';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (button.style.textAlign === 'end') {
|
|
155
|
+
button.style.alignItems = button.style.flexDirection === 'column' ? 'flex-end' : 'center';
|
|
156
|
+
button.style.justifyContent = button.style.flexDirection === 'column' ? 'center' : 'flex-end';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
createIconNode(button) {
|
|
161
|
+
if (!button.querySelector('.icon')) {
|
|
162
|
+
const iconElement = document.createElement('p');
|
|
163
|
+
iconElement.classList.add('icon');
|
|
164
|
+
button.appendChild(iconElement);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
showErrorTooltip(errorKey) {
|
|
168
|
+
const mainContainerElement = this.getRootElement().querySelector('.main-container');
|
|
169
|
+
const tooltipElement = mainContainerElement.querySelector('.input-tooltip');
|
|
170
|
+
|
|
171
|
+
const componentLanguageMap = this.getTranslationsMap(this.manifest.i18n).translations;
|
|
172
|
+
const targetPropPathKey = Object.keys(componentLanguageMap).find(key => key.includes(errorKey));
|
|
173
|
+
const translatedValue = targetPropPathKey ? componentLanguageMap[targetPropPathKey] : errorKey;
|
|
174
|
+
|
|
175
|
+
setInvalidStyle(mainContainerElement, tooltipElement, translatedValue, this.htmlDocumentObject);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getHandlers() {
|
|
179
|
+
let handlers = (this.getProps().handlers && this.getProps().handlers.length)
|
|
180
|
+
? [...this.getProps().handlers]
|
|
181
|
+
: [];
|
|
182
|
+
const model = this.getModel();
|
|
183
|
+
|
|
184
|
+
if (
|
|
185
|
+
(model?.path?.[0] === undefined)
|
|
186
|
+
|| !this.documentModel
|
|
187
|
+
) {
|
|
188
|
+
return handlers;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const currentView = this.documentModel.getView(model.path[0]);
|
|
192
|
+
|
|
193
|
+
let clickHandler = handlers
|
|
194
|
+
?.find(handler => handler.type === HandlerTypes.CLICK);
|
|
195
|
+
|
|
196
|
+
if (!clickHandler) {
|
|
197
|
+
return handlers;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const hasSubmitAction = clickHandler.actions?.some(a => {
|
|
201
|
+
return [
|
|
202
|
+
SysActionTypes.REQUEST,
|
|
203
|
+
SysActionTypes.SUBSCRIBE_CONTACT,
|
|
204
|
+
].includes(a.type);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const feedbackAndNpsComponentsCount = getComponentCountOnView(currentView, 'SysFeedbackComponent')
|
|
208
|
+
+ getComponentCountOnView(currentView, 'SysNetPromoterScoreComponent');
|
|
209
|
+
|
|
210
|
+
if ((feedbackAndNpsComponentsCount !== 1) || !hasSubmitAction) {
|
|
211
|
+
return handlers;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
clickHandler.actions = clickHandler.actions?.filter(a => {
|
|
215
|
+
return ![
|
|
216
|
+
SysActionTypes.GO_TO_VIEW,
|
|
217
|
+
SysActionTypes.GO_TO_PREVIOUS_VIEW,
|
|
218
|
+
SysActionTypes.GO_TO_NEXT_VIEW,
|
|
219
|
+
].includes(a.type);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
handlers = [
|
|
223
|
+
...handlers.filter(handler => handler.type !== HandlerTypes.CLICK),
|
|
224
|
+
clickHandler
|
|
225
|
+
];
|
|
226
|
+
|
|
227
|
+
return handlers;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export { SysButtonComponent as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import SysContainerManifest from '../SysContainerComponent/SysContainer.manifest.js';
|
|
2
|
+
import '@claspo/renderer/sdk/ModelStyleUtils';
|
|
3
|
+
import '@claspo/renderer/sdk/ManifestUtils';
|
|
4
|
+
|
|
5
|
+
var SysColumnManifest = {
|
|
6
|
+
...SysContainerManifest,
|
|
7
|
+
"name": "SysColumnComponent",
|
|
8
|
+
"componentType": "COLUMN",
|
|
9
|
+
"preventDraggable": false,
|
|
10
|
+
"focusParentOnClick": false,
|
|
11
|
+
"recursiveRemove": true,
|
|
12
|
+
"version": "1.0.0",
|
|
13
|
+
"syncEnabled": true,
|
|
14
|
+
"stylesImitationEnabled": true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { SysColumnManifest as default };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import SysColumnManifest from './SysColumn.manifest.js';
|
|
2
|
+
import SysBaseContainerComponent from '../SysContainerComponent/SysBaseContainerComponent.js';
|
|
3
|
+
import { applySysAttrPrefix } from '@claspo/renderer/renderer/RenderConstants';
|
|
4
|
+
|
|
5
|
+
class SysColumnComponent extends SysBaseContainerComponent {
|
|
6
|
+
static define = {
|
|
7
|
+
name: 'sys-column',
|
|
8
|
+
model: SysColumnManifest.name,
|
|
9
|
+
manifest: SysColumnManifest
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
manifest = SysColumnManifest;
|
|
13
|
+
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
super.connectedCallback();
|
|
16
|
+
this.updateEmptyState();
|
|
17
|
+
this.watchChildren();
|
|
18
|
+
|
|
19
|
+
this.observeEnvironment(() => {
|
|
20
|
+
this.updateResponsiveStyles();
|
|
21
|
+
});
|
|
22
|
+
this.observeProps((prev, next) => {
|
|
23
|
+
this.updateResponsiveStyles();
|
|
24
|
+
this.processSize(next.content?.size);
|
|
25
|
+
});
|
|
26
|
+
this.getParentComponent()?.observeProps(() => {
|
|
27
|
+
this.updateResponsiveStyles();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
this.mutationObserver?.disconnect();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
updateResponsiveStyles() {
|
|
37
|
+
const areColumnsResponsive = this.getParentComponent()?.getProps()?.isResponsive;
|
|
38
|
+
const columnComponents = [...this.shadowRoot.children].filter(el => el.hasAttribute('cl-element'));
|
|
39
|
+
|
|
40
|
+
const hostStyle = this.getHostElement().style;
|
|
41
|
+
|
|
42
|
+
if (columnComponents.length) {
|
|
43
|
+
hostStyle.minWidth = 'min-content';
|
|
44
|
+
} else {
|
|
45
|
+
const hasSomePadding = ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight', 'padding']
|
|
46
|
+
.map(prop => hostStyle[prop])
|
|
47
|
+
.map(value => value && parseFloat(value))
|
|
48
|
+
.some(Boolean);
|
|
49
|
+
|
|
50
|
+
if (hasSomePadding) {
|
|
51
|
+
hostStyle.minWidth = 'min-content';
|
|
52
|
+
} {
|
|
53
|
+
hostStyle.minWidth = '20px';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.getEnvironment() !== 'mobile' || !areColumnsResponsive) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (columnComponents.length) {
|
|
62
|
+
hostStyle.minHeight = 'auto';
|
|
63
|
+
} else if (hostStyle.background.includes('url')) {
|
|
64
|
+
hostStyle.minHeight = '150px';
|
|
65
|
+
} else if (!columnComponents.length) {
|
|
66
|
+
hostStyle.minHeight = '50px';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
updateEmptyState() {
|
|
72
|
+
const elements = Array
|
|
73
|
+
.from(this.getRootElement().children)
|
|
74
|
+
.filter(el => el.tagName !== 'STYLE' && el.tagName !== 'SCRIPT') || [];
|
|
75
|
+
const isEmpty = !elements.length;
|
|
76
|
+
|
|
77
|
+
this.setAttribute(applySysAttrPrefix('empty'), isEmpty);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
watchChildren() {
|
|
81
|
+
const self = this;
|
|
82
|
+
this.mutationObserver = new MutationObserver(function () {
|
|
83
|
+
self.updateEmptyState();
|
|
84
|
+
self.updateResponsiveStyles();
|
|
85
|
+
});
|
|
86
|
+
this.mutationObserver.observe(this.getRootElement(), { childList: true });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
processSize(size) {
|
|
90
|
+
const sizeProperty = 'flexGrow';
|
|
91
|
+
const sizeValue = size ?? this.style[sizeProperty] ?? '1';
|
|
92
|
+
this.style[sizeProperty] = sizeValue;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
processStyles() {
|
|
96
|
+
this.innerHTML += `
|
|
97
|
+
<style>
|
|
98
|
+
[cl-component="${this.getComponentName()}"] {
|
|
99
|
+
position: relative;
|
|
100
|
+
min-width: 50px;
|
|
101
|
+
min-height: 50px;
|
|
102
|
+
}
|
|
103
|
+
</style>`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { SysColumnComponent as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '@claspo/renderer/sdk/ModelStyleUtils';
|
|
2
|
+
|
|
3
|
+
var SysColumnsManifest = {
|
|
4
|
+
"name": "SysColumnsComponent",
|
|
5
|
+
"componentType": "COLUMNS",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"events": {
|
|
8
|
+
"dispatch": [],
|
|
9
|
+
"listen": []
|
|
10
|
+
},
|
|
11
|
+
"waitForResourcesLoad": true,
|
|
12
|
+
"resourcesPropPaths": [["adaptiveStyles", ":ENV", "styleAttributes", "background"]],
|
|
13
|
+
"syncEnabled": true,
|
|
14
|
+
"stylesImitationEnabled": true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { SysColumnsManifest as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import SysColumnsManifest from './SysColumns.manifest.js';
|
|
2
|
+
import WcElement from '@claspo/renderer/sdk/WcElement';
|
|
3
|
+
import getStyleElement from './getStyleElement.js';
|
|
4
|
+
import { applySysAttrPrefix } from '@claspo/renderer/renderer/RenderConstants';
|
|
5
|
+
import MobileDeviceOrientationListener from '@claspo/renderer/renderer/style/MobileDeviceOrientationListener';
|
|
6
|
+
|
|
7
|
+
class SysColumnsComponent extends WcElement {
|
|
8
|
+
static define = {
|
|
9
|
+
name: 'sys-columns',
|
|
10
|
+
model: SysColumnsManifest.name,
|
|
11
|
+
manifest: SysColumnsManifest
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
manifest = SysColumnsManifest;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.getRootElement().innerHTML = `
|
|
20
|
+
${getStyleElement()}
|
|
21
|
+
<div ${applySysAttrPrefix('render-outlet')} class="columns-container"></div>
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
|
|
28
|
+
this.observeProps((prev, next) => {
|
|
29
|
+
this.applyAutoAdaptiveStyles(next.adaptiveStyles, next.styles);
|
|
30
|
+
this.updateResponsiveStyles();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.observeEnvironment((_, env) => {
|
|
34
|
+
this.updateResponsiveStyles();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
this.subscriptions.push(
|
|
38
|
+
this.mobileDeviceOrientationListener.on(MobileDeviceOrientationListener.changeEventName, () => {
|
|
39
|
+
this.updateResponsiveStyles();
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
updateResponsiveStyles() {
|
|
45
|
+
if (this.getProps().isResponsive && this.getEnvironment() === 'mobile' && this.mobileDeviceOrientationListener.isPortrait()) {
|
|
46
|
+
this.getRootElement().querySelector('.columns-container').style.flexDirection = 'column';
|
|
47
|
+
} else {
|
|
48
|
+
this.getRootElement().querySelector('.columns-container').style.flexDirection = 'row';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { SysColumnsComponent as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function getStyleElement() {
|
|
2
|
+
return `
|
|
3
|
+
<style>
|
|
4
|
+
:host {
|
|
5
|
+
position: relative;
|
|
6
|
+
min-width: 50px;
|
|
7
|
+
min-height: 50px;
|
|
8
|
+
display:flex;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.columns-container {
|
|
12
|
+
height: auto;
|
|
13
|
+
min-height: 50px;
|
|
14
|
+
width: 100%;
|
|
15
|
+
min-width: 50px;
|
|
16
|
+
display: flex;
|
|
17
|
+
gap: inherit;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { getStyleElement as default };
|