@claspo/components 1.6.3 → 1.7.0-a11y.0
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/SysButtonComponent/SysButtonComponent.js +1 -1
- package/SysCalendarComponent/SysCalendarComponent.js +1 -1
- package/SysCheckboxListComponent/SysCheckboxListComponent.js +1 -1
- package/SysChoiceButtonsComponent/SysChoiceButtonsComponent.js +1 -1
- package/SysConsentComponent/SysConsentComponent.js +1 -1
- package/SysContainerComponent/SysContainerComponent.js +1 -1
- package/SysCountdownTimerComponent/SysCountdownTimerComponent.js +1 -1
- package/SysDateComponent/SysDateComponent.js +1 -1
- package/SysDropdownInputComponent/SysDropdownInputComponent.js +1 -1
- package/SysImageComponent/SysImageComponent.js +1 -1
- package/SysInAppColumnsComponent/SysInAppColumnsComponent.js +1 -1
- package/SysInputComponent/SysInputComponent.js +1 -1
- package/SysPhoneInputComponent/SysPhoneInputComponent.js +1 -1
- package/SysPromoCodeComponent/SysPromoCodeComponent.js +1 -1
- package/SysRadioGroupComponent/SysRadioGroupComponent.js +1 -1
- package/SysSliderComponent/SysSliderComponent.js +1 -1
- package/SysSocialComponent/SysSocialComponent.js +1 -1
- package/SysTextAreaComponent/SysTextAreaComponent.js +1 -1
- package/SysTextComponent/SysTextComponent.js +1 -1
- package/package.json +5 -3
- 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 +87 -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
|
@@ -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 };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import WcElement from '@claspo/renderer/sdk/WcElement';
|
|
2
|
+
|
|
3
|
+
class SysBaseContainerComponent extends WcElement {
|
|
4
|
+
manifest = {
|
|
5
|
+
name: 'SysContainerComponent'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
getComponentName = () => {
|
|
9
|
+
return this.manifest.name;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
super.connectedCallback();
|
|
14
|
+
this.processStyles();
|
|
15
|
+
|
|
16
|
+
this.observeProps((prev, next) => {
|
|
17
|
+
this.applyAutoAdaptiveStyles(next.adaptiveStyles, next.styles);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
super.disconnectedCallback();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
processStyles = () => {
|
|
26
|
+
this.innerHTML += `
|
|
27
|
+
<style>
|
|
28
|
+
[cl-component="${this.getComponentName()}"] {
|
|
29
|
+
position: relative;
|
|
30
|
+
min-width: 50px;
|
|
31
|
+
min-height: 50px;
|
|
32
|
+
}
|
|
33
|
+
</style>`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { SysBaseContainerComponent as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@claspo/renderer/sdk/ManifestUtils';
|
|
2
|
+
|
|
3
|
+
var SysContainerManifest = {
|
|
4
|
+
"name": "SysContainerComponent",
|
|
5
|
+
"componentType": "CONTAINER",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"events": {
|
|
8
|
+
"dispatch": [],
|
|
9
|
+
"listen": []
|
|
10
|
+
},
|
|
11
|
+
"i18nPropPaths": ["handlers,[id],actions,[id],params,link", "handlers,[id],actions,[id],params,customData"],
|
|
12
|
+
"waitForResourcesLoad": true,
|
|
13
|
+
"resourcesPropPaths": [["adaptiveStyles", ":ENV", "styleAttributes", "background"]],
|
|
14
|
+
"syncEnabled": true,
|
|
15
|
+
"stylesImitationEnabled": true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { SysContainerManifest as default };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import SysContainerManifest from './SysContainer.manifest.js';
|
|
2
|
+
import SysBaseContainerComponent from './SysBaseContainerComponent.js';
|
|
3
|
+
import insertHtmlIntoElement from '@claspo/common/dom/insertHtmlIntoElement';
|
|
4
|
+
|
|
5
|
+
class SysContainerComponent extends SysBaseContainerComponent {
|
|
6
|
+
static define = {
|
|
7
|
+
name: 'sys-container',
|
|
8
|
+
model: SysContainerManifest.name,
|
|
9
|
+
manifest: SysContainerManifest
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
manifest = SysContainerManifest;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
this.appendResponsiveStyles();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
this.observeProps((_, next) => {
|
|
21
|
+
if (next.isResponsive) {
|
|
22
|
+
this.updateResponsiveRules(this.getResponsiveStyleElement());
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (this.getProps().isResponsive) {
|
|
27
|
+
this.connectResizeObserver();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
this.resizeObserver?.disconnect();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
connectResizeObserver() {
|
|
37
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
38
|
+
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
|
|
41
|
+
if (entry.contentRect) {
|
|
42
|
+
this.updateResponsiveRules(this.getResponsiveStyleElement());
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
this.resizeObserver.observe(this.getWidgetContainerNode());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
updateResponsiveRules(styleElement) {
|
|
52
|
+
if (!this.getProps().isResponsive) {
|
|
53
|
+
insertHtmlIntoElement({
|
|
54
|
+
element: styleElement,
|
|
55
|
+
html: '',
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const parentNode = this.getWidgetContainerNode();
|
|
61
|
+
const {width, height} = parentNode.getBoundingClientRect();
|
|
62
|
+
|
|
63
|
+
if (height / width > 1.6) {
|
|
64
|
+
styleElement.innerHTML = `[cl-component="${this.getComponentName()}"] {flex-direction: column !important;}`;
|
|
65
|
+
} else {
|
|
66
|
+
styleElement.innerHTML = `[cl-component="${this.getComponentName()}"] {flex-direction: row !important;}`;
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
getResponsiveStyleElement() {
|
|
74
|
+
return [...this.children]
|
|
75
|
+
.find(child => child.getAttribute('name') === 'responsive-styles');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
appendResponsiveStyles() {
|
|
80
|
+
this.innerHTML += `<style name="responsive-styles">
|
|
81
|
+
[cl-component="${this.getComponentName()}"] {}
|
|
82
|
+
</style>`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { SysContainerComponent as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@claspo/renderer/sdk/ManifestUtils';
|
|
2
|
+
|
|
3
|
+
var SysImageManifest = {
|
|
4
|
+
"name": "SysImageComponent",
|
|
5
|
+
"componentType": "IMAGE",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"i18nPropPaths": ["handlers,[id],actions,[id],params,link", "handlers,[id],actions,[id],params,customData", "control,altText"],
|
|
8
|
+
"events": {
|
|
9
|
+
"dispatch": [],
|
|
10
|
+
"listen": []
|
|
11
|
+
},
|
|
12
|
+
"waitForResourcesLoad": true,
|
|
13
|
+
"resourcesPropPaths": [["control", "imageSource", "url"]],
|
|
14
|
+
"syncEnabled": true,
|
|
15
|
+
"stylesImitationEnabled": true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { SysImageManifest as default };
|