@descope/web-components-ui 1.0.222 → 1.0.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +1145 -739
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1264 -752
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/1000.js +1 -1
- package/dist/umd/1037.js +2 -0
- package/dist/umd/1037.js.LICENSE.txt +5 -0
- package/dist/umd/1419.js +360 -0
- package/dist/umd/1419.js.LICENSE.txt +23 -0
- package/dist/umd/1932.js +310 -0
- package/dist/umd/1932.js.LICENSE.txt +5 -0
- package/dist/umd/1990.js +3 -3
- package/dist/umd/2066.js +2 -0
- package/dist/umd/2066.js.LICENSE.txt +5 -0
- package/dist/umd/262.js +2 -0
- package/dist/umd/262.js.LICENSE.txt +5 -0
- package/dist/umd/2873.js +738 -0
- package/dist/umd/2873.js.LICENSE.txt +21 -0
- package/dist/umd/3003.js +2 -0
- package/dist/umd/3003.js.LICENSE.txt +9 -0
- package/dist/umd/{9515.js → 3092.js} +88 -88
- package/dist/umd/3660.js +17 -0
- package/dist/umd/{1883.js.LICENSE.txt → 3660.js.LICENSE.txt} +1 -11
- package/dist/umd/422.js +1 -1
- package/dist/umd/4222.js +2 -0
- package/dist/umd/{1852.js.LICENSE.txt → 4222.js.LICENSE.txt} +0 -30
- package/dist/umd/4447.js +2 -1
- package/dist/umd/4447.js.LICENSE.txt +5 -0
- package/dist/umd/4567.js +1 -0
- package/dist/umd/4746.js +123 -0
- package/dist/umd/4905.js +2 -0
- package/dist/umd/4905.js.LICENSE.txt +5 -0
- package/dist/umd/5345.js +94 -0
- package/dist/umd/5806.js +1 -1
- package/dist/umd/5977.js +289 -0
- package/dist/umd/5977.js.LICENSE.txt +17 -0
- package/dist/umd/6551.js +1 -0
- package/dist/umd/{7101.js → 6770.js} +5 -5
- package/dist/umd/6770.js.LICENSE.txt +11 -0
- package/dist/umd/7056.js +1 -1
- package/dist/umd/{6116.js → 7514.js} +9 -9
- package/dist/umd/8725.js +2 -2
- package/dist/umd/9189.js +2 -0
- package/dist/umd/9189.js.LICENSE.txt +5 -0
- package/dist/umd/9211.js +2 -2
- package/dist/umd/9437.js +1 -1
- package/dist/umd/9629.js +2 -0
- package/dist/umd/9629.js.LICENSE.txt +5 -0
- package/dist/umd/9671.js +1 -0
- package/dist/umd/9680.js +2 -0
- package/dist/umd/9680.js.LICENSE.txt +5 -0
- package/dist/umd/boolean-fields-descope-checkbox-index-js.js +1 -1
- package/dist/umd/boolean-fields-descope-switch-toggle-index-js.js +1 -1
- package/dist/umd/descope-combo-box-index-js.js +1 -1
- package/dist/umd/descope-grid-descope-grid-selection-column-index-js.js +1 -0
- package/dist/umd/descope-grid-descope-grid-status-column-index-js.js +1 -0
- package/dist/umd/descope-grid-descope-grid-text-column-index-js.js +1 -0
- package/dist/umd/descope-grid-index-js.js +1 -0
- package/dist/umd/descope-modal-index-js.js +1 -0
- package/dist/umd/descope-text-area-index-js.js +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +4 -2
- package/src/components/descope-grid/GridClass.js +226 -0
- package/src/components/descope-grid/descope-grid-selection-column/index.js +68 -0
- package/src/components/descope-grid/descope-grid-status-column/index.js +34 -0
- package/src/components/descope-grid/descope-grid-text-column/index.js +11 -0
- package/src/components/descope-grid/helpers.js +9 -0
- package/src/components/descope-grid/index.js +10 -0
- package/src/components/descope-modal/ModalClass.js +109 -0
- package/src/components/descope-modal/index.js +6 -0
- package/src/index.cjs.js +1 -0
- package/src/index.js +1 -0
- package/src/mixins/createStyleMixin/helpers.js +2 -2
- package/src/mixins/createStyleMixin/index.js +2 -2
- package/src/mixins/portalMixin.js +24 -4
- package/src/theme/components/grid.js +38 -0
- package/src/theme/components/index.js +4 -0
- package/src/theme/components/modal.js +16 -0
- package/dist/umd/1852.js +0 -375
- package/dist/umd/1883.js +0 -289
- package/dist/umd/4767.js +0 -215
- /package/dist/umd/{7101.js.LICENSE.txt → 3092.js.LICENSE.txt} +0 -0
- /package/dist/umd/{4767.js.LICENSE.txt → 4746.js.LICENSE.txt} +0 -0
- /package/dist/umd/{9515.js.LICENSE.txt → 5345.js.LICENSE.txt} +0 -0
- /package/dist/umd/{6116.js.LICENSE.txt → 7514.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { compose } from '../../helpers';
|
|
2
|
+
import { getComponentName } from '../../helpers/componentHelpers';
|
|
3
|
+
import {
|
|
4
|
+
createStyleMixin,
|
|
5
|
+
draggableMixin,
|
|
6
|
+
createProxy,
|
|
7
|
+
componentNameValidationMixin,
|
|
8
|
+
} from '../../mixins';
|
|
9
|
+
|
|
10
|
+
import { isValidDataType } from './helpers';
|
|
11
|
+
|
|
12
|
+
export const componentName = getComponentName('grid');
|
|
13
|
+
|
|
14
|
+
const GridMixin = (superclass) =>
|
|
15
|
+
class GridMixinClass extends superclass {
|
|
16
|
+
#columns;
|
|
17
|
+
|
|
18
|
+
init() {
|
|
19
|
+
super.init?.();
|
|
20
|
+
this.handleColumns();
|
|
21
|
+
this.forwardSelectedItemsChange();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
forwardSelectedItemsChange() {
|
|
25
|
+
this.baseElement.addEventListener('selected-items-changed', (e) => {
|
|
26
|
+
this.dispatchEvent(
|
|
27
|
+
new CustomEvent('selected-items-changed', {
|
|
28
|
+
bubbles: true,
|
|
29
|
+
composed: true,
|
|
30
|
+
detail: e.detail,
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
37
|
+
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
|
38
|
+
|
|
39
|
+
if (attrName === 'columns') {
|
|
40
|
+
this.setColumnsDataFromAttr();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
handleColumns() {
|
|
45
|
+
if (this.columnsAttr) {
|
|
46
|
+
this.setColumnsDataFromAttr();
|
|
47
|
+
} else if (this.children.length) {
|
|
48
|
+
this.setColumnsFromChildren();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setColumnsFromChildren() {
|
|
53
|
+
this.#columns = Array.from(this.children).map((child) => {
|
|
54
|
+
return {
|
|
55
|
+
path: child.getAttribute('path'),
|
|
56
|
+
header: child.getAttribute('header'),
|
|
57
|
+
type: child.localName.match('^descope-grid-(\\w+)-column$')?.[1] || 'text',
|
|
58
|
+
|
|
59
|
+
attrs: ['frozen', 'resizable', 'auto-width', 'status'].reduce((acc, attrName) => {
|
|
60
|
+
const attrVal = child.getAttribute(attrName);
|
|
61
|
+
|
|
62
|
+
if (attrVal) {
|
|
63
|
+
acc[attrName] = attrVal;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return acc;
|
|
67
|
+
}, {}),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get columnsAttr() {
|
|
73
|
+
return this.getAttribute('columns');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setColumnsDataFromAttr() {
|
|
77
|
+
try {
|
|
78
|
+
const data = JSON.parse(this.columnsAttr);
|
|
79
|
+
if (isValidDataType(data)) {
|
|
80
|
+
this.columns = data;
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
// eslint-disable-next-line no-console
|
|
84
|
+
console.error('could not parse data string from attribute "columns" -', e.message);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line class-methods-use-this
|
|
89
|
+
#renderColumn = ({ path, header, type, attrs }) => {
|
|
90
|
+
const colAttrs = Object.entries(attrs)
|
|
91
|
+
.map(([key, value]) => `${key}="${value}"`)
|
|
92
|
+
.join(' ');
|
|
93
|
+
|
|
94
|
+
const tagName = `descope-grid-${type}-column`;
|
|
95
|
+
|
|
96
|
+
return `<${tagName} header="${header}" path="${path}" ${colAttrs}></${tagName}>`;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
get renderColumn() {
|
|
100
|
+
return this.#renderColumn;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
set renderColumn(renderFn) {
|
|
104
|
+
this.#renderColumn = renderFn;
|
|
105
|
+
this.renderColumns();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getColumnsTemplate() {
|
|
109
|
+
return this.#columns?.reduce?.(
|
|
110
|
+
(acc, item) => acc + (this.renderColumn?.(item || {}) || ''),
|
|
111
|
+
''
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
renderColumns() {
|
|
116
|
+
const template = this.getColumnsTemplate();
|
|
117
|
+
if (template) this.innerHTML = template;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
get grid() {
|
|
121
|
+
return this.shadowRoot.querySelector('vaadin-grid');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get data() {
|
|
125
|
+
return this.grid.items;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
set data(data) {
|
|
129
|
+
if (isValidDataType(data) && this.grid.items !== data) {
|
|
130
|
+
this.grid.items = data;
|
|
131
|
+
|
|
132
|
+
if (this.grid.selectedItems) {
|
|
133
|
+
const itemsIds = new Set(
|
|
134
|
+
this.grid.items.map((item) => item[this.uniqueColumnId] ?? item)
|
|
135
|
+
);
|
|
136
|
+
this.grid.selectedItems = this.grid.selectedItems.filter((selectedItem) =>
|
|
137
|
+
itemsIds.has(selectedItem[this.uniqueColumnId] ?? selectedItem)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get columns() {
|
|
144
|
+
return this.#columns;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
set columns(data) {
|
|
148
|
+
this.#columns = data;
|
|
149
|
+
this.renderColumns();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get paths() {
|
|
153
|
+
return this.columns.map((col) => col.path);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get uniqueColumnId() {
|
|
157
|
+
return this.getAttribute('unique-column-id');
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const {
|
|
162
|
+
host,
|
|
163
|
+
headerRow,
|
|
164
|
+
contentRow,
|
|
165
|
+
firstRow,
|
|
166
|
+
sortIndicators,
|
|
167
|
+
activeSortIndicator,
|
|
168
|
+
selectedRow,
|
|
169
|
+
rowSeparator,
|
|
170
|
+
resizeHandle,
|
|
171
|
+
} = {
|
|
172
|
+
host: { selector: () => 'vaadin-grid' },
|
|
173
|
+
headerRow: { selector: () => '::part(header-cell)' },
|
|
174
|
+
contentRow: { selector: () => '::part(cell)' },
|
|
175
|
+
firstRow: { selector: () => '::part(first-header-row-cell)' },
|
|
176
|
+
selectedRow: { selector: () => '::part(selected-row-cell)' },
|
|
177
|
+
sortIndicators: { selector: () => 'vaadin-grid-sorter::part(indicators)' },
|
|
178
|
+
activeSortIndicator: { selector: () => 'vaadin-grid-sorter[direction]' },
|
|
179
|
+
rowSeparator: { selector: () => 'vaadin-grid::part(body-cell)' },
|
|
180
|
+
resizeHandle: { selector: () => '::part(resize-handle)' },
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const GridClass = compose(
|
|
184
|
+
createStyleMixin({ componentNameOverride: getComponentName('input-wrapper') }),
|
|
185
|
+
createStyleMixin({
|
|
186
|
+
mappings: {
|
|
187
|
+
hostWidth: { selector: () => ':host', property: 'width' },
|
|
188
|
+
hostHeight: { selector: () => ':host', property: 'height' },
|
|
189
|
+
hostMinHeight: { selector: () => ':host', property: 'min-height' },
|
|
190
|
+
fontFamily: [{ ...headerRow }, { ...contentRow }],
|
|
191
|
+
fontSize: [{ ...headerRow }, { ...contentRow }],
|
|
192
|
+
fontWeight: { ...contentRow },
|
|
193
|
+
valueTextColor: { ...contentRow, property: 'color' },
|
|
194
|
+
sortIndicatorsColor: { ...sortIndicators, property: 'color' },
|
|
195
|
+
activeSortIndicator: { ...activeSortIndicator, property: 'color' },
|
|
196
|
+
inputBorderColor: { ...host, property: 'border-color' },
|
|
197
|
+
inputBorderWidth: { ...host, property: 'border-width' },
|
|
198
|
+
inputBorderStyle: { ...host, property: 'border-style' },
|
|
199
|
+
inputBorderRadius: { ...host, property: 'border-radius' },
|
|
200
|
+
selectedBackgroundColor: { ...selectedRow, property: 'background-color' },
|
|
201
|
+
selectedTextColor: { ...selectedRow, property: 'color' },
|
|
202
|
+
separatorColor: [
|
|
203
|
+
{ ...firstRow, property: 'border-bottom-color' },
|
|
204
|
+
{ ...rowSeparator, property: 'border-top-color' },
|
|
205
|
+
],
|
|
206
|
+
resizeHandleColor: { ...resizeHandle, property: 'background-color' },
|
|
207
|
+
},
|
|
208
|
+
}),
|
|
209
|
+
draggableMixin,
|
|
210
|
+
componentNameValidationMixin,
|
|
211
|
+
GridMixin
|
|
212
|
+
)(
|
|
213
|
+
createProxy({
|
|
214
|
+
slots: [''],
|
|
215
|
+
wrappedEleName: 'vaadin-grid',
|
|
216
|
+
style: () => `
|
|
217
|
+
vaadin-grid {
|
|
218
|
+
overflow: hidden;
|
|
219
|
+
height: 100%;
|
|
220
|
+
min-height: 300px;
|
|
221
|
+
}
|
|
222
|
+
`,
|
|
223
|
+
excludeAttrsSync: ['columns', 'tabindex'],
|
|
224
|
+
componentName,
|
|
225
|
+
})
|
|
226
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
import { GridSelectionColumn } from '@vaadin/grid/vaadin-grid-selection-column';
|
|
4
|
+
import '../../boolean-fields/descope-checkbox';
|
|
5
|
+
import { getComponentName } from '../../../helpers/componentHelpers';
|
|
6
|
+
|
|
7
|
+
export const componentName = getComponentName('grid-selection-column');
|
|
8
|
+
|
|
9
|
+
const createCheckboxEle = () => {
|
|
10
|
+
const checkbox = document.createElement('descope-checkbox');
|
|
11
|
+
|
|
12
|
+
checkbox.setAttribute('bordered', 'true');
|
|
13
|
+
checkbox.setAttribute('size', 'xs');
|
|
14
|
+
|
|
15
|
+
return checkbox;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getIsAllItemsSelected = (grid) => grid.selectedItems.length === grid.items?.length;
|
|
19
|
+
|
|
20
|
+
export class GridSelectionColumnClass extends GridSelectionColumn {
|
|
21
|
+
onInput(grid) {
|
|
22
|
+
if (grid.selectedItems.length === grid.items?.length) {
|
|
23
|
+
grid.selectedItems = [];
|
|
24
|
+
} else {
|
|
25
|
+
grid.selectedItems = grid.items;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_headerRenderer(cell) {
|
|
30
|
+
const grid = cell.parentNode;
|
|
31
|
+
|
|
32
|
+
let checkbox = cell.querySelector('descope-checkbox');
|
|
33
|
+
if (!checkbox) {
|
|
34
|
+
checkbox = createCheckboxEle();
|
|
35
|
+
|
|
36
|
+
checkbox.addEventListener('input', () => {
|
|
37
|
+
const isAllItemsSelected = getIsAllItemsSelected(grid);
|
|
38
|
+
if (isAllItemsSelected) {
|
|
39
|
+
grid.selectedItems = [];
|
|
40
|
+
} else {
|
|
41
|
+
grid.selectedItems = grid.items;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
cell.appendChild(checkbox);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
checkbox.setAttribute('checked', getIsAllItemsSelected(grid));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_defaultRenderer(cell, col, model) {
|
|
52
|
+
const grid = cell.parentNode;
|
|
53
|
+
|
|
54
|
+
let checkbox = cell.querySelector('descope-checkbox');
|
|
55
|
+
if (!checkbox) {
|
|
56
|
+
checkbox = createCheckboxEle();
|
|
57
|
+
cell.appendChild(checkbox);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
checkbox.onchange = () => {
|
|
61
|
+
checkbox.checked ? grid.selectItem(model.item) : grid.deselectItem(model.item);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
checkbox.setAttribute('checked', model.selected);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
customElements.define(componentName, GridSelectionColumnClass);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
import { GridColumn } from '@vaadin/grid/vaadin-grid-column';
|
|
3
|
+
import { getComponentName } from '../../../helpers/componentHelpers';
|
|
4
|
+
|
|
5
|
+
export const componentName = getComponentName('grid-status-column');
|
|
6
|
+
class GridStatusColumnClass extends GridColumn {
|
|
7
|
+
_defaultRenderer(cell, _col, model) {
|
|
8
|
+
const grid = cell.parentNode;
|
|
9
|
+
const size = grid.getAttribute('size');
|
|
10
|
+
|
|
11
|
+
const contentAttr = this.getAttribute('status');
|
|
12
|
+
if (!contentAttr) {
|
|
13
|
+
cell.innerHTML = model.item[this.path];
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const [active, inactive] = contentAttr.split(',');
|
|
18
|
+
|
|
19
|
+
const label = model.item[this.path] ? active : inactive;
|
|
20
|
+
const mode = model.item[this.path] ? 'success' : 'error';
|
|
21
|
+
|
|
22
|
+
cell.innerHTML = `<descope-button
|
|
23
|
+
st-host-height="2.5em"
|
|
24
|
+
mode="${mode}"
|
|
25
|
+
variant="outline"
|
|
26
|
+
size="${size}">
|
|
27
|
+
${label}
|
|
28
|
+
</descope-button>`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
customElements.define(componentName, GridStatusColumnClass);
|
|
33
|
+
|
|
34
|
+
export { GridStatusColumnClass };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GridColumn } from '@vaadin/grid/vaadin-grid-column';
|
|
2
|
+
import '../../descope-button';
|
|
3
|
+
import { getComponentName } from '../../../helpers/componentHelpers';
|
|
4
|
+
|
|
5
|
+
export const componentName = getComponentName('grid-text-column');
|
|
6
|
+
|
|
7
|
+
class GridTextColumnClass extends GridColumn {}
|
|
8
|
+
|
|
9
|
+
customElements.define(componentName, GridTextColumnClass);
|
|
10
|
+
|
|
11
|
+
export { GridTextColumnClass };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '@vaadin/grid';
|
|
2
|
+
import './descope-grid-text-column';
|
|
3
|
+
import './descope-grid-status-column';
|
|
4
|
+
import './descope-grid-selection-column';
|
|
5
|
+
|
|
6
|
+
import { componentName, GridClass } from './GridClass';
|
|
7
|
+
|
|
8
|
+
customElements.define(componentName, GridClass);
|
|
9
|
+
|
|
10
|
+
export { GridClass };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { compose } from '../../helpers';
|
|
2
|
+
import { forwardAttrs, getComponentName } from '../../helpers/componentHelpers';
|
|
3
|
+
import {
|
|
4
|
+
createStyleMixin,
|
|
5
|
+
draggableMixin,
|
|
6
|
+
createProxy,
|
|
7
|
+
componentNameValidationMixin,
|
|
8
|
+
portalMixin,
|
|
9
|
+
} from '../../mixins';
|
|
10
|
+
|
|
11
|
+
export const componentName = getComponentName('modal');
|
|
12
|
+
|
|
13
|
+
const customMixin = (superclass) =>
|
|
14
|
+
class ModalMixinClass extends superclass {
|
|
15
|
+
get opened() {
|
|
16
|
+
return this.getAttribute('opened') === 'true';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
handleOpened() {
|
|
20
|
+
forwardAttrs(this, this.baseElement, { includeAttrs: ['opened'] });
|
|
21
|
+
if (this.opened) {
|
|
22
|
+
this.style.display = '';
|
|
23
|
+
} else {
|
|
24
|
+
this.style.display = 'none';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
init() {
|
|
29
|
+
super.init?.();
|
|
30
|
+
this.style.display = 'none';
|
|
31
|
+
|
|
32
|
+
// vaadin-dialog might not be loaded in time
|
|
33
|
+
// in order to make sure it's loaded before this block is running
|
|
34
|
+
// we are wrapping it with setTimeout
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
// we want to sync descope-modal content through vaadin-dialog into the overlay
|
|
37
|
+
// so we are adding a slot to the overlay, which allows us to forward the content from
|
|
38
|
+
// vaadin-dialog to vaadin-dialog-overlay
|
|
39
|
+
this.baseElement.shadowRoot
|
|
40
|
+
.querySelector('vaadin-dialog-overlay')
|
|
41
|
+
.appendChild(document.createElement('slot'));
|
|
42
|
+
|
|
43
|
+
this.#overrideOverlaySettings();
|
|
44
|
+
|
|
45
|
+
// we need to always open the modal in `opened=false`
|
|
46
|
+
// to prevent it from rendering outside the dialog
|
|
47
|
+
// first, we have to run `overrideOverlaySettings` to setup
|
|
48
|
+
// the component.
|
|
49
|
+
this.handleOpened();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// the default vaadin behavior is to attach the overlay to the body when opened
|
|
54
|
+
// we do not want that because it's difficult to style the overlay in this way
|
|
55
|
+
// so we override it to open inside the shadow DOM
|
|
56
|
+
#overrideOverlaySettings() {
|
|
57
|
+
const overlay = this.baseElement.shadowRoot.querySelector('vaadin-dialog-overlay');
|
|
58
|
+
|
|
59
|
+
overlay._attachOverlay = () => {
|
|
60
|
+
overlay.bringToFront();
|
|
61
|
+
this.baseElement.setAttribute('style', 'display:flex!important;');
|
|
62
|
+
};
|
|
63
|
+
overlay._detachOverlay = () => {
|
|
64
|
+
this.baseElement.style.display = 'none';
|
|
65
|
+
};
|
|
66
|
+
overlay._enterModalState = () => {};
|
|
67
|
+
|
|
68
|
+
overlay.close = () => false;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const ModalClass = compose(
|
|
73
|
+
createStyleMixin({
|
|
74
|
+
mappings: {
|
|
75
|
+
overlayBackgroundColor: { property: () => ModalClass.cssVarList.overlay.backgroundColor },
|
|
76
|
+
overlayShadow: { property: () => ModalClass.cssVarList.overlay.shadow },
|
|
77
|
+
overlayWidth: { property: () => ModalClass.cssVarList.overlay.width },
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
portalMixin({
|
|
81
|
+
name: 'overlay',
|
|
82
|
+
selector: '',
|
|
83
|
+
mappings: {
|
|
84
|
+
hostDisplay: {
|
|
85
|
+
selector: () => ':host(.descope-modal)',
|
|
86
|
+
property: 'display',
|
|
87
|
+
important: true,
|
|
88
|
+
},
|
|
89
|
+
backgroundColor: { selector: () => '::part(content)', property: 'background-color' },
|
|
90
|
+
width: { selector: () => '::part(overlay)', property: 'width' },
|
|
91
|
+
shadow: { selector: () => '::part(overlay)', property: 'box-shadow' },
|
|
92
|
+
},
|
|
93
|
+
forward: {
|
|
94
|
+
include: false,
|
|
95
|
+
attributes: ['opened'],
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
draggableMixin,
|
|
99
|
+
componentNameValidationMixin,
|
|
100
|
+
customMixin
|
|
101
|
+
)(
|
|
102
|
+
createProxy({
|
|
103
|
+
slots: [''],
|
|
104
|
+
wrappedEleName: 'vaadin-dialog',
|
|
105
|
+
style: () => ``,
|
|
106
|
+
excludeAttrsSync: ['tabindex', 'opened'],
|
|
107
|
+
componentName,
|
|
108
|
+
})
|
|
109
|
+
);
|
package/src/index.cjs.js
CHANGED
|
@@ -29,3 +29,4 @@ export { RecaptchaClass } from './components/descope-recaptcha/RecaptchaClass';
|
|
|
29
29
|
export { UploadFileClass } from './components/descope-upload-file/UploadFileClass';
|
|
30
30
|
export { ButtonSelectionGroupClass } from './components/descope-button-selection-group/ButtonSelectionGroupClass';
|
|
31
31
|
export { ButtonSelectionGroupItemClass } from './components/descope-button-selection-group/descope-button-selection-group-item/ButtonSelectionGroupItemClass';
|
|
32
|
+
export { ModalClass } from './components/descope-modal/ModalClass';
|
package/src/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export * from './components/descope-recaptcha';
|
|
|
24
24
|
export * from './components/descope-upload-file';
|
|
25
25
|
export * from './components/descope-button-selection-group';
|
|
26
26
|
export * from './components/descope-button-selection-group/descope-button-selection-group-item';
|
|
27
|
+
export * from './components/descope-grid';
|
|
27
28
|
|
|
28
29
|
export {
|
|
29
30
|
globalsThemeToStyle,
|
|
@@ -55,11 +55,11 @@ export const createStyle = (componentName, baseSelector, mappings) => {
|
|
|
55
55
|
|
|
56
56
|
const cssVarName = getCssVarName(componentName, attr);
|
|
57
57
|
|
|
58
|
-
attrConfig.forEach(({ selector: relativeSelectorOrSelectorFn, property }) => {
|
|
58
|
+
attrConfig.forEach(({ selector: relativeSelectorOrSelectorFn, property, important }) => {
|
|
59
59
|
style.add(
|
|
60
60
|
createCssSelector(baseSelector, relativeSelectorOrSelectorFn),
|
|
61
61
|
isFunction(property) ? property() : property,
|
|
62
|
-
createCssVarFallback(cssVarName)
|
|
62
|
+
createCssVarFallback(cssVarName) + (important ? '!important' : '')
|
|
63
63
|
);
|
|
64
64
|
});
|
|
65
65
|
});
|
|
@@ -142,10 +142,10 @@ export const createStyleMixin =
|
|
|
142
142
|
(this.#rootElement.classList || this.#rootElement.host.classList).add(className);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
init() {
|
|
145
|
+
async init() {
|
|
146
146
|
super.init?.();
|
|
147
147
|
if (this.shadowRoot.isConnected) {
|
|
148
|
-
this.#rootElement = this.#getRootElement?.(this) || this.shadowRoot;
|
|
148
|
+
this.#rootElement = (await this.#getRootElement?.(this)) || this.shadowRoot;
|
|
149
149
|
|
|
150
150
|
this.#addClassName(componentName);
|
|
151
151
|
|
|
@@ -13,7 +13,27 @@ const DISPLAY_NAME_SEPARATOR = '_';
|
|
|
13
13
|
|
|
14
14
|
const sanitizeSelector = (selector) => selector.replace(/[^\w\s]/gi, '');
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const withWaitForShadowRoot = (getRootElementFn) => (that) =>
|
|
17
|
+
new Promise((res) => {
|
|
18
|
+
const MAX_RETRIES = 20;
|
|
19
|
+
const ele = getRootElementFn(that);
|
|
20
|
+
let counter = 0;
|
|
21
|
+
|
|
22
|
+
const check = () => {
|
|
23
|
+
if (counter > MAX_RETRIES) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error('could not get shadow root for element', ele);
|
|
26
|
+
res(ele);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
counter++;
|
|
31
|
+
|
|
32
|
+
if (!ele.shadowRoot) setTimeout(check);
|
|
33
|
+
else res(ele.shadowRoot);
|
|
34
|
+
};
|
|
35
|
+
check();
|
|
36
|
+
});
|
|
17
37
|
|
|
18
38
|
export const portalMixin =
|
|
19
39
|
({ name, selector, mappings = {}, forward: { attributes = [], include = true } = {} }) =>
|
|
@@ -43,17 +63,17 @@ export const portalMixin =
|
|
|
43
63
|
const baseEle = that.shadowRoot.querySelector(that.baseSelector);
|
|
44
64
|
const portal = selector ? baseEle.shadowRoot.querySelector(selector) : baseEle;
|
|
45
65
|
|
|
46
|
-
return portal
|
|
66
|
+
return portal;
|
|
47
67
|
};
|
|
48
68
|
|
|
49
69
|
super({
|
|
50
|
-
getRootElement,
|
|
70
|
+
getRootElement: withWaitForShadowRoot(getRootElement),
|
|
51
71
|
componentNameSuffix: DISPLAY_NAME_SEPARATOR + eleDisplayName,
|
|
52
72
|
themeSection: PORTAL_THEME_PREFIX + eleDisplayName,
|
|
53
73
|
baseSelector: ':host',
|
|
54
74
|
});
|
|
55
75
|
|
|
56
|
-
this.#portalEle =
|
|
76
|
+
this.#portalEle = getRootElement(this);
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
#handleHoverAttribute() {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import globals from '../globals';
|
|
2
|
+
import { getThemeRefs } from '../../helpers/themeHelpers';
|
|
3
|
+
import { GridClass } from '../../components/descope-grid/GridClass';
|
|
4
|
+
import { refs } from './inputWrapper';
|
|
5
|
+
|
|
6
|
+
const globalRefs = getThemeRefs(globals);
|
|
7
|
+
const vars = GridClass.cssVarList;
|
|
8
|
+
|
|
9
|
+
export const grid = {
|
|
10
|
+
[vars.hostWidth]: '100%',
|
|
11
|
+
[vars.hostHeight]: '100%',
|
|
12
|
+
[vars.hostMinHeight]: '400px',
|
|
13
|
+
|
|
14
|
+
[vars.fontSize]: refs.fontSize,
|
|
15
|
+
[vars.fontFamily]: refs.fontFamily,
|
|
16
|
+
|
|
17
|
+
[vars.sortIndicatorsColor]: globalRefs.colors.primary.main,
|
|
18
|
+
[vars.activeSortIndicator]: globalRefs.colors.primary.main,
|
|
19
|
+
[vars.resizeHandleColor]: globalRefs.colors.surface.main,
|
|
20
|
+
|
|
21
|
+
[vars.inputBorderWidth]: refs.borderWidth,
|
|
22
|
+
[vars.inputBorderStyle]: refs.borderStyle,
|
|
23
|
+
[vars.inputBorderRadius]: refs.borderRadius,
|
|
24
|
+
[vars.inputBorderColor]: 'transparent',
|
|
25
|
+
|
|
26
|
+
[vars.separatorColor]: refs.borderColor,
|
|
27
|
+
|
|
28
|
+
[vars.valueTextColor]: globalRefs.colors.surface.contrast,
|
|
29
|
+
[vars.selectedBackgroundColor]: globalRefs.colors.primary.main,
|
|
30
|
+
[vars.selectedTextColor]: globalRefs.colors.primary.contrast,
|
|
31
|
+
|
|
32
|
+
_bordered: {
|
|
33
|
+
[vars.inputBorderColor]: refs.borderColor,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default grid;
|
|
38
|
+
export { vars };
|
|
@@ -23,6 +23,8 @@ import * as inputWrapper from './inputWrapper';
|
|
|
23
23
|
import * as uploadFile from './uploadFile';
|
|
24
24
|
import * as buttonSelectionGroupItem from './buttonSelectionGroup/buttonSelectionGroupItem';
|
|
25
25
|
import * as buttonSelectionGroup from './buttonSelectionGroup/buttonSelectionGroup';
|
|
26
|
+
import * as modal from './modal';
|
|
27
|
+
import * as grid from './grid';
|
|
26
28
|
|
|
27
29
|
const components = {
|
|
28
30
|
button,
|
|
@@ -51,6 +53,8 @@ const components = {
|
|
|
51
53
|
uploadFile,
|
|
52
54
|
buttonSelectionGroupItem,
|
|
53
55
|
buttonSelectionGroup,
|
|
56
|
+
modal,
|
|
57
|
+
grid,
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
const theme = Object.keys(components).reduce(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModalClass } from '../../components/descope-modal/ModalClass';
|
|
2
|
+
|
|
3
|
+
const compVars = ModalClass.cssVarList;
|
|
4
|
+
|
|
5
|
+
const modal = {
|
|
6
|
+
[compVars.hostWidth]: '400px',
|
|
7
|
+
[compVars.hostHeight]: '400px',
|
|
8
|
+
[compVars.overlayShadow]: 'none',
|
|
9
|
+
[compVars.overlayWidth]: '700px',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default modal;
|
|
13
|
+
|
|
14
|
+
export const vars = {
|
|
15
|
+
...compVars,
|
|
16
|
+
};
|