@design.estate/dees-catalog 1.0.231 → 1.0.233
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_bundle/bundle.js +243 -181
- package/dist_bundle/bundle.js.map +3 -3
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/dees-form.demo.js +15 -2
- package/dist_ts_web/elements/dees-input-dropdown.d.ts +5 -2
- package/dist_ts_web/elements/dees-input-dropdown.demo.js +9 -1
- package/dist_ts_web/elements/dees-input-dropdown.js +221 -89
- package/dist_ts_web/elements/dees-input-text.js +3 -2
- package/dist_ts_web/elements/dees-windowlayer.js +3 -1
- package/dist_watch/bundle.js +3653 -3901
- package/dist_watch/bundle.js.map +4 -4
- package/package.json +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/dees-form.demo.ts +14 -1
- package/ts_web/elements/dees-input-dropdown.demo.ts +16 -0
- package/ts_web/elements/dees-input-dropdown.ts +229 -96
- package/ts_web/elements/dees-input-text.ts +2 -1
- package/ts_web/elements/dees-windowlayer.ts +2 -0
package/package.json
CHANGED
|
@@ -20,9 +20,22 @@ export const demoFunc = () => html`
|
|
|
20
20
|
form.setStatus('success', 'authenticated!');
|
|
21
21
|
}}
|
|
22
22
|
>
|
|
23
|
+
<dees-input-dropdown
|
|
24
|
+
.label=${'title'}
|
|
25
|
+
.options=${[
|
|
26
|
+
{ option: 'option 1', key: 'option1' },
|
|
27
|
+
{ option: 'option 2', key: 'option2' },
|
|
28
|
+
{ option: 'option 3', key: 'option3' },
|
|
29
|
+
]}
|
|
30
|
+
></dees-input-dropdown>
|
|
23
31
|
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
|
24
32
|
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
|
25
|
-
<dees-input-text
|
|
33
|
+
<dees-input-text
|
|
34
|
+
.required="${true}"
|
|
35
|
+
key="hello3"
|
|
36
|
+
label="a password"
|
|
37
|
+
isPasswordBool
|
|
38
|
+
></dees-input-text>
|
|
26
39
|
<dees-input-checkbox
|
|
27
40
|
.required="${true}"
|
|
28
41
|
key="hello3"
|
|
@@ -8,4 +8,20 @@ export const demoFunc = () => html`
|
|
|
8
8
|
{option: 'option 3', key: 'option3'}
|
|
9
9
|
]}
|
|
10
10
|
></dees-input-dropdown>
|
|
11
|
+
<dees-input-dropdown
|
|
12
|
+
.enableSearch=${false}
|
|
13
|
+
.options=${[
|
|
14
|
+
{option: 'option 1', key: 'option1'},
|
|
15
|
+
{option: 'option 2', key: 'option2'},
|
|
16
|
+
{option: 'option 3', key: 'option3'}
|
|
17
|
+
]}
|
|
18
|
+
></dees-input-dropdown>
|
|
19
|
+
<div style="height: 300px"></div>
|
|
20
|
+
<dees-input-dropdown
|
|
21
|
+
.options=${[
|
|
22
|
+
{option: 'option 1', key: 'option1'},
|
|
23
|
+
{option: 'option 2', key: 'option2'},
|
|
24
|
+
{option: 'option 3', key: 'option3'}
|
|
25
|
+
]}
|
|
26
|
+
></dees-input-dropdown>
|
|
11
27
|
`
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
customElement,
|
|
3
|
+
DeesElement,
|
|
4
|
+
type TemplateResult,
|
|
5
|
+
property,
|
|
6
|
+
state,
|
|
7
|
+
html,
|
|
8
|
+
css,
|
|
9
|
+
cssManager,
|
|
10
|
+
type CSSResult,
|
|
11
|
+
} from '@design.estate/dees-element';
|
|
2
12
|
import * as domtools from '@design.estate/dees-domtools';
|
|
3
13
|
import { demoFunc } from './dees-input-dropdown.demo.js';
|
|
14
|
+
import { DeesWindowLayer } from './dees-windowlayer.js';
|
|
4
15
|
|
|
5
16
|
declare global {
|
|
6
17
|
interface HTMLElementTagNameMap {
|
|
@@ -10,7 +21,7 @@ declare global {
|
|
|
10
21
|
|
|
11
22
|
@customElement('dees-input-dropdown')
|
|
12
23
|
export class DeesInputDropdown extends DeesElement {
|
|
13
|
-
public static demo = demoFunc
|
|
24
|
+
public static demo = demoFunc;
|
|
14
25
|
|
|
15
26
|
// INSTANCE
|
|
16
27
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
|
@@ -25,144 +36,266 @@ export class DeesInputDropdown extends DeesElement {
|
|
|
25
36
|
public key: string;
|
|
26
37
|
|
|
27
38
|
@property()
|
|
28
|
-
public options: {option: string
|
|
39
|
+
public options: { option: string; key: string; payload?: any }[] = [];
|
|
29
40
|
|
|
30
41
|
@property()
|
|
31
|
-
public selectedOption: {option: string
|
|
32
|
-
key: null,
|
|
33
|
-
option: null,
|
|
34
|
-
payload: null
|
|
35
|
-
};
|
|
42
|
+
public selectedOption: { option: string; key: string; payload?: any } = null;
|
|
36
43
|
|
|
37
44
|
@property({
|
|
38
|
-
type: Boolean
|
|
45
|
+
type: Boolean,
|
|
39
46
|
})
|
|
40
47
|
public required: boolean = false;
|
|
41
48
|
|
|
42
49
|
@property({
|
|
43
|
-
type: Boolean
|
|
50
|
+
type: Boolean,
|
|
51
|
+
})
|
|
52
|
+
public enableSearch: boolean = true;
|
|
53
|
+
|
|
54
|
+
@property({
|
|
55
|
+
type: Boolean,
|
|
44
56
|
})
|
|
45
57
|
public disabled: boolean = false;
|
|
46
58
|
|
|
59
|
+
@state()
|
|
60
|
+
public opensToTop: boolean = false;
|
|
61
|
+
|
|
47
62
|
public static styles = [
|
|
48
63
|
cssManager.defaultStyles,
|
|
49
64
|
css`
|
|
50
65
|
* {
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
}
|
|
53
68
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
:host {
|
|
70
|
+
font-family: Roboto;
|
|
71
|
+
position: relative;
|
|
72
|
+
display: block;
|
|
73
|
+
color: ${cssManager.bdTheme('#222', '#fff')};
|
|
74
|
+
margin-bottom: 24px;
|
|
75
|
+
}
|
|
60
76
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
.maincontainer {
|
|
78
|
+
display: block;
|
|
79
|
+
}
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
.label {
|
|
82
|
+
font-size: 14px;
|
|
83
|
+
margin-bottom: 4px;
|
|
84
|
+
}
|
|
69
85
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
.selectedBox {
|
|
87
|
+
user-select: none;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
position: relative;
|
|
90
|
+
max-width: 420px;
|
|
91
|
+
height: 40px;
|
|
92
|
+
line-height: 40px;
|
|
93
|
+
padding: 0px 8px;
|
|
94
|
+
background: ${cssManager.bdTheme('#fafafa', '#222')};
|
|
95
|
+
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
|
96
|
+
border-radius: 3px;
|
|
97
|
+
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
|
98
|
+
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #333')};
|
|
99
|
+
transition: all 0.2s ease;
|
|
100
|
+
}
|
|
84
101
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
102
|
+
.accentTop {
|
|
103
|
+
border-top: 1px solid #e4002b;
|
|
104
|
+
}
|
|
89
105
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
cursor: pointer;
|
|
94
|
-
transition: all 0.2s ease;
|
|
95
|
-
opacity: 0;
|
|
96
|
-
position: absolute;
|
|
97
|
-
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
|
98
|
-
max-width: 420px;
|
|
99
|
-
box-shadow: 0px 0px 5px rgba(0,0,0,0.2);
|
|
100
|
-
min-height: 40px;
|
|
101
|
-
z-index: 100;
|
|
102
|
-
border-radius: 3px;
|
|
103
|
-
padding: 4px;
|
|
104
|
-
transform: scale(0.99,0.99);
|
|
105
|
-
}
|
|
106
|
+
.accentBottom {
|
|
107
|
+
border-bottom: 1px solid #e4002b;
|
|
108
|
+
}
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
.selectionBox {
|
|
111
|
+
will-change: transform;
|
|
112
|
+
pointer-events: none;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
transition: all 0.2s ease;
|
|
115
|
+
opacity: 0;
|
|
116
|
+
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
|
117
|
+
max-width: 420px;
|
|
118
|
+
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
|
119
|
+
min-height: 40px;
|
|
120
|
+
border-radius: 3px;
|
|
121
|
+
padding: 4px;
|
|
122
|
+
transform: scale(0.99, 0.99);
|
|
123
|
+
position: absolute;
|
|
124
|
+
}
|
|
112
125
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
126
|
+
.selectionBox.show {
|
|
127
|
+
pointer-events: all;
|
|
128
|
+
opacity: 1;
|
|
129
|
+
transform: scale(1, 1);
|
|
130
|
+
}
|
|
119
131
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
.option {
|
|
133
|
+
transition: all 0.1s;
|
|
134
|
+
line-height: 40px;
|
|
135
|
+
padding: 0px 4px;
|
|
136
|
+
border-radius: 3px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.option:hover {
|
|
140
|
+
color: #fff;
|
|
141
|
+
padding-left: 8px;
|
|
142
|
+
background: #0277bd;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.search {
|
|
146
|
+
padding: 8px;
|
|
147
|
+
}
|
|
148
|
+
.search input {
|
|
149
|
+
display: block;
|
|
150
|
+
width: 80%;
|
|
151
|
+
background: none;
|
|
152
|
+
border: none;
|
|
153
|
+
height: 24px;
|
|
154
|
+
color: inherit;
|
|
155
|
+
text-align: center;
|
|
156
|
+
font-size: 12px;
|
|
157
|
+
font-weight: 600;
|
|
158
|
+
background: ${cssManager.bdTheme('#00000010', '#ffffff08')};
|
|
159
|
+
border-radius: 16px;
|
|
160
|
+
margin: auto;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.search input:focus {
|
|
164
|
+
border: none;
|
|
165
|
+
outline: none;
|
|
166
|
+
}
|
|
167
|
+
`,
|
|
168
|
+
];
|
|
127
169
|
|
|
128
170
|
public render(): TemplateResult {
|
|
129
171
|
return html`
|
|
130
172
|
<div class="maincontainer">
|
|
131
|
-
|
|
132
|
-
${this.selectedOption?.option}
|
|
133
|
-
</div>
|
|
173
|
+
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
|
134
174
|
<div class="selectionBox">
|
|
135
|
-
${this.
|
|
175
|
+
${this.enableSearch && !this.opensToTop
|
|
176
|
+
? html`
|
|
177
|
+
<div class="search">
|
|
178
|
+
<input type="text" placeholder="Search" />
|
|
179
|
+
</div>
|
|
180
|
+
`
|
|
181
|
+
: null}
|
|
182
|
+
${this.options.map((option) => {
|
|
136
183
|
return html`
|
|
137
|
-
<div
|
|
138
|
-
|
|
184
|
+
<div
|
|
185
|
+
class="option"
|
|
186
|
+
@click=${() => {
|
|
187
|
+
this.updateSelection(option);
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
${option.option}
|
|
191
|
+
</div>
|
|
192
|
+
`;
|
|
139
193
|
})}
|
|
194
|
+
${this.enableSearch && this.opensToTop
|
|
195
|
+
? html`
|
|
196
|
+
<div class="search">
|
|
197
|
+
<input type="text" placeholder="Search" />
|
|
198
|
+
</div>
|
|
199
|
+
`
|
|
200
|
+
: null}
|
|
201
|
+
</div>
|
|
202
|
+
<div
|
|
203
|
+
class="selectedBox"
|
|
204
|
+
@click="${(event) => {
|
|
205
|
+
if (!this.isElevated) {
|
|
206
|
+
this.toggleSelectionBox();
|
|
207
|
+
} else {
|
|
208
|
+
this.updateSelection(this.selectedOption);
|
|
209
|
+
}
|
|
210
|
+
}}"
|
|
211
|
+
>
|
|
212
|
+
${this.selectedOption?.option}
|
|
140
213
|
</div>
|
|
141
214
|
</div>
|
|
142
215
|
`;
|
|
143
216
|
}
|
|
144
217
|
|
|
145
218
|
firstUpdated() {
|
|
146
|
-
this.selectedOption = this.options[0] || null;
|
|
219
|
+
this.selectedOption = this.selectedOption || this.options[0] || null;
|
|
147
220
|
}
|
|
148
221
|
|
|
149
222
|
public async updateSelection(selectedOption) {
|
|
150
223
|
this.selectedOption = selectedOption;
|
|
151
224
|
|
|
152
|
-
this.dispatchEvent(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
225
|
+
this.dispatchEvent(
|
|
226
|
+
new CustomEvent('selectedOption', {
|
|
227
|
+
detail: selectedOption,
|
|
228
|
+
bubbles: true,
|
|
229
|
+
})
|
|
230
|
+
);
|
|
231
|
+
if (this.isElevated) {
|
|
232
|
+
this.toggleSelectionBox();
|
|
233
|
+
}
|
|
157
234
|
this.changeSubject.next(this);
|
|
158
235
|
}
|
|
159
236
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
237
|
+
private isElevated: boolean = false;
|
|
238
|
+
private windowOverlay: DeesWindowLayer;
|
|
239
|
+
public async toggleSelectionBox() {
|
|
240
|
+
const domtoolsInstance = await this.domtoolsPromise;
|
|
241
|
+
const selectedBox: HTMLElement = this.shadowRoot.querySelector('.selectedBox');
|
|
242
|
+
const selectionBox: HTMLElement = this.shadowRoot.querySelector('.selectionBox');
|
|
243
|
+
if (!this.isElevated) {
|
|
244
|
+
this.windowOverlay = await DeesWindowLayer.createAndShow({
|
|
245
|
+
blur: false,
|
|
246
|
+
});
|
|
247
|
+
const elevatedDropdown = new DeesInputDropdown();
|
|
248
|
+
elevatedDropdown.isElevated = true;
|
|
249
|
+
elevatedDropdown.label = this.label;
|
|
250
|
+
elevatedDropdown.enableSearch = this.enableSearch;
|
|
251
|
+
elevatedDropdown.required = this.required;
|
|
252
|
+
elevatedDropdown.disabled = this.disabled;
|
|
253
|
+
elevatedDropdown.style.position = 'fixed';
|
|
254
|
+
elevatedDropdown.style.top = this.getBoundingClientRect().top + 'px';
|
|
255
|
+
elevatedDropdown.style.left = this.getBoundingClientRect().left + 'px';
|
|
256
|
+
elevatedDropdown.style.width = this.clientWidth + 'px';
|
|
257
|
+
elevatedDropdown.options = this.options;
|
|
258
|
+
elevatedDropdown.selectedOption = this.selectedOption;
|
|
259
|
+
console.log(elevatedDropdown.selectedOption);
|
|
260
|
+
this.windowOverlay.appendChild(elevatedDropdown);
|
|
261
|
+
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
|
262
|
+
elevatedDropdown.toggleSelectionBox();
|
|
263
|
+
const destroyOverlay = async () => {
|
|
264
|
+
(elevatedDropdown.shadowRoot.querySelector('.selectionBox') as HTMLElement).style.opacity =
|
|
265
|
+
'0';
|
|
266
|
+
elevatedDropdown.removeEventListener('selectedOption', handleSelection);
|
|
267
|
+
this.windowOverlay.removeEventListener('clicked', destroyOverlay);
|
|
268
|
+
this.windowOverlay.destroy();
|
|
269
|
+
};
|
|
270
|
+
const handleSelection = async (event) => {
|
|
271
|
+
await this.updateSelection(elevatedDropdown.selectedOption);
|
|
272
|
+
destroyOverlay();
|
|
273
|
+
};
|
|
274
|
+
elevatedDropdown.addEventListener('selectedOption', handleSelection);
|
|
275
|
+
this.windowOverlay.addEventListener('clicked', destroyOverlay);
|
|
276
|
+
} else {
|
|
277
|
+
if (!selectionBox.classList.contains('show')) {
|
|
278
|
+
selectionBox.style.width = selectedBox.clientWidth + 'px';
|
|
279
|
+
selectionBox.classList.add('show');
|
|
280
|
+
const spaceData = selectedBox.getBoundingClientRect();
|
|
281
|
+
if (300 > window.innerHeight - spaceData.bottom) {
|
|
282
|
+
this.opensToTop = true;
|
|
283
|
+
selectedBox.classList.add('accentTop');
|
|
284
|
+
selectionBox.style.bottom = selectedBox.clientHeight + 2 + 'px';
|
|
285
|
+
} else {
|
|
286
|
+
selectedBox.classList.add('accentBottom');
|
|
287
|
+
this.opensToTop = false;
|
|
288
|
+
const labelOffset = this.label ? 24 : 0;
|
|
289
|
+
selectionBox.style.top = selectedBox.clientHeight + labelOffset + 'px';
|
|
290
|
+
}
|
|
291
|
+
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
|
292
|
+
const searchInput = selectionBox.querySelector('input');
|
|
293
|
+
searchInput.focus();
|
|
294
|
+
} else {
|
|
295
|
+
selectedBox.style.pointerEvents = 'none';
|
|
296
|
+
selectionBox.classList.remove('show');
|
|
297
|
+
selectedBox.style.opacity = '0';
|
|
298
|
+
}
|
|
299
|
+
}
|
|
167
300
|
}
|
|
168
301
|
}
|
|
@@ -143,6 +143,7 @@ export class DeesInputText extends DeesElement {
|
|
|
143
143
|
border-radius: 7px;
|
|
144
144
|
padding: 4px 0px;
|
|
145
145
|
width: 40px;
|
|
146
|
+
z-index: 3;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
.showPassword:hover {
|
|
@@ -169,7 +170,7 @@ export class DeesInputText extends DeesElement {
|
|
|
169
170
|
return html`
|
|
170
171
|
<style>
|
|
171
172
|
input {
|
|
172
|
-
font-family: ${this.isPasswordBool ? 'monospace' : '
|
|
173
|
+
font-family: ${this.isPasswordBool ? 'monospace' : 'Roboto'};
|
|
173
174
|
letter-spacing: ${this.isPasswordBool ? '1px' : 'normal'};
|
|
174
175
|
color: ${this.goBright ? '#333' : '#ccc'};
|
|
175
176
|
}
|
|
@@ -67,11 +67,13 @@ export class DeesWindowLayer extends DeesElement {
|
|
|
67
67
|
z-index: 200;
|
|
68
68
|
}
|
|
69
69
|
.slotContent {
|
|
70
|
+
position: fixed;
|
|
70
71
|
height: 100vh;
|
|
71
72
|
width: 100vw;
|
|
72
73
|
display: flex;
|
|
73
74
|
justify-content: center;
|
|
74
75
|
align-items: center;
|
|
76
|
+
z-index: 201;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
.visible {
|