@dile/utils 2.0.1
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/LICENSE +7 -0
- package/README.md +3 -0
- package/components/datepicker/calendar.js +3 -0
- package/components/datepicker/datepicker.js +4 -0
- package/components/datepicker/index.js +2 -0
- package/components/datepicker/src/DileCalendar.js +72 -0
- package/components/datepicker/src/DileDatepicker.js +114 -0
- package/components/graph/graph.js +3 -0
- package/components/graph/index.js +1 -0
- package/components/graph/src/DileGraph.js +65 -0
- package/components/html-transform/html-transform.js +3 -0
- package/components/html-transform/src/DileHtmlTransform.js +72 -0
- package/components/media-query/index.js +1 -0
- package/components/media-query/media-query.js +3 -0
- package/components/media-query/src/DileMediaQuery.js +79 -0
- package/components/network/index.js +1 -0
- package/components/network/network.js +3 -0
- package/components/network/src/DileNetwork.js +99 -0
- package/components/smooth-scroll/index.js +3 -0
- package/components/smooth-scroll/smooth-scroll.js +3 -0
- package/components/smooth-scroll/src/DileSmoothScroll.js +22 -0
- package/components/smooth-scroll/src/DileSmoothScrollElementMixin.js +22 -0
- package/components/smooth-scroll/src/DileSmoothScrollMixin.js +24 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2019 EscuelaIT
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { LionCalendar } from '@lion/calendar';
|
|
3
|
+
|
|
4
|
+
export class DileCalendar extends LionCalendar {
|
|
5
|
+
static get styles() {
|
|
6
|
+
return [
|
|
7
|
+
super.styles,
|
|
8
|
+
css`
|
|
9
|
+
.calendar__navigation {
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: var(--dile-calendar-navigation-justify-content, space-between);
|
|
12
|
+
align-items: center;
|
|
13
|
+
margin-top: 0.4rem;
|
|
14
|
+
}
|
|
15
|
+
.calendar__navigation button {
|
|
16
|
+
min-height: auto;
|
|
17
|
+
min-width: 30px;
|
|
18
|
+
}
|
|
19
|
+
.calendar__navigation h2 {
|
|
20
|
+
margin: 0;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
min-height: auto;
|
|
24
|
+
font-size: 0.9rem;
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
@media(min-width: 400px) {
|
|
28
|
+
.calendar__navigation h2 {
|
|
29
|
+
font-size: var(--dile-calendar-navigation-text-size, 1.1rem);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
.calendar__day-button {
|
|
33
|
+
min-width: 26px;
|
|
34
|
+
min-height: 26px;
|
|
35
|
+
background-color: var(--dile-calendar-day-background-color, rgba(90, 90, 90, 0.08));
|
|
36
|
+
color: var(--dile-calendar-day-text-color, #303030);
|
|
37
|
+
border-radius: var(--dile-calendar-day-border-radius, 2px);
|
|
38
|
+
}
|
|
39
|
+
.calendar__day-button[today] {
|
|
40
|
+
background-color: var(--dile-calendar-today-background-color, rgba(90, 90, 90, 0.20));
|
|
41
|
+
}
|
|
42
|
+
.calendar__day-button[next-month], .calendar__day-button[previous-month] {
|
|
43
|
+
color: var(--dile-calendar-out-day-text-color, #777);
|
|
44
|
+
opacity: 0.6;
|
|
45
|
+
}
|
|
46
|
+
.calendar__next-button , .calendar__previous-button{
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
color: var(--dile-calendar-nav-buttons-color, #303030);
|
|
49
|
+
font-size: 1.1em;
|
|
50
|
+
}
|
|
51
|
+
@media(min-width: 350px) {
|
|
52
|
+
.calendar__day-button {
|
|
53
|
+
min-width: var(--dile-calendar-day-size, 28px);
|
|
54
|
+
min-height: var(--dile-calendar-day-size, 28px);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
@media(min-width: 400px) {
|
|
58
|
+
.calendar__day-button {
|
|
59
|
+
min-width: var(--dile-calendar-day-size, 32px);
|
|
60
|
+
min-height: var(--dile-calendar-day-size, 32px);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@media(min-width: 500px) {
|
|
64
|
+
.calendar__day-button {
|
|
65
|
+
min-width: var(--dile-calendar-day-size, 36px);
|
|
66
|
+
min-height: var(--dile-calendar-day-size, 36px);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
import { DileInput } from '@dile/ui/components/input/index.js';
|
|
3
|
+
import '@dile/ui/components/icon/icon.js';
|
|
4
|
+
import { calendarIcon } from '@dile/icons/index.js';
|
|
5
|
+
import '@dile/ui/components/menu-overlay/menu-overlay.js';
|
|
6
|
+
import { formatDate } from '@lion/localize';
|
|
7
|
+
|
|
8
|
+
export class DileDatepicker extends DileInput {
|
|
9
|
+
static get styles() {
|
|
10
|
+
return [
|
|
11
|
+
super.styles,
|
|
12
|
+
css`
|
|
13
|
+
div.container {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: flex-end;
|
|
16
|
+
}
|
|
17
|
+
section.input {
|
|
18
|
+
flex-grow: 1;
|
|
19
|
+
margin-right: 10px;
|
|
20
|
+
}
|
|
21
|
+
dile-icon {
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
--dile-icon-size: var(--dile-datepicker-trigger-size, 36px);
|
|
24
|
+
}
|
|
25
|
+
dile-calendar {
|
|
26
|
+
font-size: var(--dile-datepicker-font-size, 0.9rem);
|
|
27
|
+
}
|
|
28
|
+
dile-menu-overlay {
|
|
29
|
+
--dile-menu-overlay-width: var(--dile-datepicker-width, 280px);
|
|
30
|
+
}
|
|
31
|
+
dile-icon {
|
|
32
|
+
--dile-icon-color: var(--dile-datepicker-trigger-color, #39c);
|
|
33
|
+
}
|
|
34
|
+
dile-icon.trigger-disabled {
|
|
35
|
+
--dile-icon-color: var(--dile-datepicker-trigger-disabled-color, #ccc);
|
|
36
|
+
}
|
|
37
|
+
span {
|
|
38
|
+
display: flex;
|
|
39
|
+
margin-bottom: var(--dile-datepicker-trigger-margin-bottom, 0.2em);
|
|
40
|
+
}
|
|
41
|
+
@media(min-width: 350px) {
|
|
42
|
+
dile-menu-overlay {
|
|
43
|
+
--dile-menu-overlay-width: var(--dile-datepicker-width, 300px);
|
|
44
|
+
--dile-menu-overlay-max-width: var(--dile-datepicker-width, 300px);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
@media(min-width: 450px) {
|
|
48
|
+
dile-menu-overlay {
|
|
49
|
+
--dile-menu-overlay-width: var(--dile-datepicker-width, 320px);
|
|
50
|
+
--dile-menu-overlay-max-width: var(--dile-datepicker-width, 320px);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
@media(min-width: 500px) {
|
|
54
|
+
dile-menu-overlay {
|
|
55
|
+
--dile-menu-overlay-width: var(--dile-datepicker-width, 350px);
|
|
56
|
+
--dile-menu-overlay-max-width: var(--dile-datepicker-width, 350px);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static get properties() {
|
|
63
|
+
return {
|
|
64
|
+
firstDayOfWeek: { type: Number },
|
|
65
|
+
horizontalAlign: { type: String },
|
|
66
|
+
verticalAlign: { type: String },
|
|
67
|
+
moveTop: { type: Number },
|
|
68
|
+
moveLeft: { type: Number },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
constructor() {
|
|
73
|
+
super();
|
|
74
|
+
this.firstDayOfWeek = 0;
|
|
75
|
+
this.horizontalAlign = 'under_right';
|
|
76
|
+
this.verticalAlign = 'center';
|
|
77
|
+
this.moveTop = 0;
|
|
78
|
+
this.moveLeft = 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
render() {
|
|
83
|
+
return html`
|
|
84
|
+
<div class="container">
|
|
85
|
+
<section class="input">
|
|
86
|
+
${super.render()}
|
|
87
|
+
</section>
|
|
88
|
+
<span>
|
|
89
|
+
${this.disabled
|
|
90
|
+
? html`<dile-icon class="trigger-disabled" .icon="${calendarIcon}"></dile-icon>`
|
|
91
|
+
: html`
|
|
92
|
+
<dile-menu-overlay moveTop="${this.moveTop}" moveLeft="${this.moveLeft}" verticalAlign="${this.verticalAlign}" horizontalAlign="${this.horizontalAlign}" id="menu">
|
|
93
|
+
<dile-icon .icon="${calendarIcon}" slot="trigger"></dile-icon>
|
|
94
|
+
<div slot="content" class="calendar">
|
|
95
|
+
<dile-calendar
|
|
96
|
+
class="demo-calendar"
|
|
97
|
+
.firstDayOfWeek="${this.firstDayOfWeek}"
|
|
98
|
+
@user-selected-date-changed=${this.showDate}
|
|
99
|
+
></dile-calendar>
|
|
100
|
+
</div>
|
|
101
|
+
</dile-menu-overlay>
|
|
102
|
+
`
|
|
103
|
+
}
|
|
104
|
+
</span>
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
showDate(e) {
|
|
110
|
+
let date = formatDate(e.detail.selectedDate);
|
|
111
|
+
this.value = date;
|
|
112
|
+
this.shadowRoot.getElementById('menu').close();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileGraph } from './src/DileGraph.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class DileGraph extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return css`
|
|
6
|
+
* {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
.card {
|
|
13
|
+
box-shadow: var(--dile-graph-shadow, 0 4px 8px 0 rgba(0, 0, 0, 0.2));
|
|
14
|
+
padding: var(--dile-graph-padding, 10px);
|
|
15
|
+
border-radius: var(--dile-graph-border-radius, 0);
|
|
16
|
+
background-color: var(--dile-graph-background-color, white);
|
|
17
|
+
transition: 0.3s;
|
|
18
|
+
width: var(--dile-graph-width, 100%);
|
|
19
|
+
}
|
|
20
|
+
.card:hover {
|
|
21
|
+
box-shadow: var(--dile-graph-hover-shadow, 0 8px 16px 0 rgba(0, 0, 0, 0.2));
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
static get properties() {
|
|
26
|
+
return {
|
|
27
|
+
chartType: { type: String },
|
|
28
|
+
labels: { type: Array },
|
|
29
|
+
datasets: { type: Array },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
this.chartType = 'line'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render() {
|
|
39
|
+
return html`
|
|
40
|
+
<div class="card">
|
|
41
|
+
<canvas id="myChart"></canvas>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get config() {
|
|
47
|
+
return {
|
|
48
|
+
type: this.chartType,
|
|
49
|
+
data: this.data,
|
|
50
|
+
options: {}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get data() {
|
|
55
|
+
return {
|
|
56
|
+
labels: this.labels,
|
|
57
|
+
datasets: this.datasets,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
firstUpdated() {
|
|
62
|
+
const ctx = this.renderRoot.querySelector('#myChart').getContext('2d');
|
|
63
|
+
this.myChart = new Chart(ctx, this.config);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
//import { StrBlock } from './StrBlock';
|
|
3
|
+
import linkifyStr from 'linkify-string';
|
|
4
|
+
import * as linkify from 'linkifyjs';
|
|
5
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
6
|
+
|
|
7
|
+
const options = { defaultProtocol: 'https' };
|
|
8
|
+
|
|
9
|
+
export class DileHtmlTransform extends LitElement {
|
|
10
|
+
|
|
11
|
+
static get styles() {
|
|
12
|
+
return css`
|
|
13
|
+
:host {
|
|
14
|
+
display: inline;
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
convertLines: { type: Boolean },
|
|
22
|
+
convertLinks: { type: Boolean },
|
|
23
|
+
text: { type: String },
|
|
24
|
+
init: { type: Boolean },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.init = false;
|
|
31
|
+
this.text = '';
|
|
32
|
+
this.convertLines = false;
|
|
33
|
+
this.convertLinks = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
firstUpdated() {
|
|
37
|
+
this.init = true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
if (!this.init) {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
if (!this.convertLines && !this.convertLinks) {
|
|
45
|
+
return this.text;
|
|
46
|
+
}
|
|
47
|
+
if (!this.convertLinks) {
|
|
48
|
+
return html`${this.convertNewLines(this.text)}`;
|
|
49
|
+
}
|
|
50
|
+
return html`${unsafeHTML(linkifyStr(this.text, this.generateOptions(this.convertLines)))}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
generateOptions(convertLines) {
|
|
54
|
+
let options = {
|
|
55
|
+
nl2br: convertLines,
|
|
56
|
+
};
|
|
57
|
+
return options;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
convertNewLines(str, convertLinks, convertEmails) {
|
|
61
|
+
let breakStr = '(-..#_#..-)';
|
|
62
|
+
str = str.replace(/(?:\r\n|\r|\n)/g, breakStr);
|
|
63
|
+
let arrStr = str.split(breakStr);
|
|
64
|
+
return arrStr.map( (element, index) =>
|
|
65
|
+
html`
|
|
66
|
+
${element != ''
|
|
67
|
+
? html`${element}${index < arrStr.length - 1 ? html`<br>` : ''}`
|
|
68
|
+
: ''
|
|
69
|
+
}
|
|
70
|
+
`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileMediaQuery } from './src/DileMediaQuery.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
|
|
3
|
+
export class DileMediaQuery extends LitElement {
|
|
4
|
+
|
|
5
|
+
static get properties() {
|
|
6
|
+
return {
|
|
7
|
+
/**
|
|
8
|
+
* Media query to be watched by the element.
|
|
9
|
+
*
|
|
10
|
+
* Can be modified at run time by setting a new value.
|
|
11
|
+
*/
|
|
12
|
+
query: { type: String },
|
|
13
|
+
_match: { type: Boolean }
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.boundResizeHandler = this._handleResize.bind(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
updated(changedProperties) {
|
|
23
|
+
if(changedProperties.has('query') && this.query) {
|
|
24
|
+
this.createMatcher();
|
|
25
|
+
this.reviewMediaQuery();
|
|
26
|
+
}
|
|
27
|
+
if(changedProperties.has('_match') && this._match !== undefined) {
|
|
28
|
+
this.dispatchChange()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
createMatcher() {
|
|
33
|
+
this.matcher = window.matchMedia(this.query);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
dispatchChange() {
|
|
37
|
+
this.dispatchEvent(new CustomEvent('dile-media-query-changed', {
|
|
38
|
+
composed: true,
|
|
39
|
+
bubbles: true,
|
|
40
|
+
detail: {
|
|
41
|
+
value: this._match,
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
super.connectedCallback();
|
|
48
|
+
// Check if Visual Viewport API is supported
|
|
49
|
+
if (this.hasVisualViewport()) {
|
|
50
|
+
window.visualViewport.addEventListener('resize', this.boundResizeHandler);
|
|
51
|
+
} else {
|
|
52
|
+
window.addEventListener('resize', this.boundResizeHandler);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
// Remove event listeners
|
|
58
|
+
if (this.hasVisualViewport()) {
|
|
59
|
+
window.visualViewport.removeEventListener('resize', this.boundResizeHandler);
|
|
60
|
+
} else {
|
|
61
|
+
window.removeEventListener('resize', this.boundResizeHandler);
|
|
62
|
+
}
|
|
63
|
+
super.disconnectedCallback();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
hasVisualViewport() {
|
|
67
|
+
return typeof window.visualViewport !== 'undefined'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
reviewMediaQuery() {
|
|
71
|
+
if(this.matcher) {
|
|
72
|
+
this._match = this.matcher.matches
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_handleResize() {
|
|
77
|
+
this.reviewMediaQuery();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileNetwork } from './src/DileNetwork.js';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
import { closeIcon, warningIcon } from "@dile/icons/index.js";
|
|
3
|
+
import '@dile/ui/components/toast/toast-persistent';
|
|
4
|
+
import '@dile/ui/components/icon/icon';
|
|
5
|
+
|
|
6
|
+
export class DileNetwork extends LitElement {
|
|
7
|
+
static get styles() {
|
|
8
|
+
return css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline;
|
|
11
|
+
--dile-toast-persistent-padding: var(--dile-network-toast-padding, 0.65rem);
|
|
12
|
+
--dile-toast-persistent-background-color: var(--dile-network-toast-background-color, #e33);
|
|
13
|
+
}
|
|
14
|
+
.msg {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
.label {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
color: var(--dile-network-label-text-color, #fff);
|
|
23
|
+
}
|
|
24
|
+
.label dile-icon {
|
|
25
|
+
margin-right: 0.5rem;
|
|
26
|
+
--dile-icon-color: var(--dile-network-warning-icon-color, #fff);
|
|
27
|
+
}
|
|
28
|
+
.closeicon {
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
--dile-icon-color: var(--dile-network-close-icon-color, #fff);
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
static get properties() {
|
|
37
|
+
return {
|
|
38
|
+
onLine: {
|
|
39
|
+
attribute: false,
|
|
40
|
+
},
|
|
41
|
+
showOffLineStatus: { type: Boolean },
|
|
42
|
+
offLineLabel: { type: String },
|
|
43
|
+
showCloseIcon: { type: Boolean },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
this.onLine = window.navigator.onLine;
|
|
50
|
+
window.addEventListener("online", () => this.dispatchOnline());
|
|
51
|
+
window.addEventListener("offline", () => this.dispatchOffline());
|
|
52
|
+
this.showOffLineStatus = false;
|
|
53
|
+
this.showCloseIcon = false;
|
|
54
|
+
this.offLineLabel = "Network is offline";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
dispatchOffline() {
|
|
58
|
+
this.onLine = false;
|
|
59
|
+
this.sendEvent();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
dispatchOnline() {
|
|
63
|
+
this.onLine = true;
|
|
64
|
+
this.sendEvent();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
sendEvent() {
|
|
68
|
+
this.dispatchEvent(
|
|
69
|
+
new CustomEvent("dile-network-status", {
|
|
70
|
+
bubbles: true,
|
|
71
|
+
composed: true,
|
|
72
|
+
detail: { onLine: this.onLine },
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
render() {
|
|
78
|
+
return html`${!this.onLine && this.showOffLineStatus ? this.offlineTemplate : ""}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get offlineTemplate() {
|
|
82
|
+
return html`<dile-toast-persistent id="eltoast" openOnInit>
|
|
83
|
+
<div class="msg">
|
|
84
|
+
<span class="label">
|
|
85
|
+
<dile-icon .icon=${warningIcon}></dile-icon>
|
|
86
|
+
${this.offLineLabel}
|
|
87
|
+
</span>
|
|
88
|
+
${this.showCloseIcon
|
|
89
|
+
? html`<span class="closeicon" @click=${this.closeToast}><dile-icon .icon=${closeIcon}></dile-icon></span>`
|
|
90
|
+
: ''
|
|
91
|
+
}
|
|
92
|
+
</div>
|
|
93
|
+
</dile-toast-persistent>`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
closeToast() {
|
|
97
|
+
this.shadowRoot.querySelector('#eltoast').close();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { DileSmoothScrollMixin } from "./DileSmoothScrollMixin.js";
|
|
3
|
+
import { DileSmoothScrollElementMixin } from "./DileSmoothScrollElementMixin.js";
|
|
4
|
+
|
|
5
|
+
export class DileSmoothScroll extends DileSmoothScrollMixin (
|
|
6
|
+
DileSmoothScrollElementMixin(LitElement)
|
|
7
|
+
) {
|
|
8
|
+
static get properties() {
|
|
9
|
+
return {
|
|
10
|
+
scrollToElementOnInit: { type: String },
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
firstUpdated() {
|
|
15
|
+
if (this.scrollToElementOnInit) {
|
|
16
|
+
const el = document.getElementById(this.scrollToElementOnInit);
|
|
17
|
+
if (el) {
|
|
18
|
+
setTimeout(() => this.smoothScrollElementIntoView(el), 500);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const DileSmoothScrollElementMixin = (Superclass) =>
|
|
2
|
+
class extends Superclass {
|
|
3
|
+
smoothElementScrollTop(element) {
|
|
4
|
+
this.smoothElementScroll(element, 0, 0);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
smoothElementScrollBottom(element) {
|
|
8
|
+
this.smoothElementScroll(element, element.scrollHeight, 0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
smoothElementScroll(element, top, left) {
|
|
12
|
+
if (element) {
|
|
13
|
+
element.scroll({ top, left, behavior: "smooth" });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
smoothElementScrollBy(element, top, left) {
|
|
18
|
+
if (element) {
|
|
19
|
+
element.scrollBy({ top, left, behavior: "smooth" });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const DileSmoothScrollMixin = (Superclass) =>
|
|
2
|
+
class extends Superclass {
|
|
3
|
+
smoothScrollToTop() {
|
|
4
|
+
this.smoothScroll(0, 0);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
smoothScrollToBottom() {
|
|
8
|
+
this.smoothScroll(document.body.clientHeight, 0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
smoothScroll(top, left) {
|
|
12
|
+
window.scroll({ top, left, behavior: "smooth" });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
smoothScrollBy(top, left) {
|
|
16
|
+
window.scrollBy({ top, left, behavior: "smooth" });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
smoothScrollElementIntoView(element) {
|
|
20
|
+
if (element && element.scrollIntoView) {
|
|
21
|
+
element.scrollIntoView({ behavior: "smooth" });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dile/utils",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Utility Components of Diverse Uses Based on the Lit Library and Web Components Standard.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Polydile/Components.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"utils"
|
|
15
|
+
],
|
|
16
|
+
"author": "EscuelaIT",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/Polydile/Components/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Polydile/Components#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@dile/ui": "^2.0.1",
|
|
24
|
+
"@lion/calendar": "^0.20.1",
|
|
25
|
+
"@lion/localize": "^0.26.0",
|
|
26
|
+
"linkify-string": "^4.1.3",
|
|
27
|
+
"linkifyjs": "^4.1.3",
|
|
28
|
+
"lit": "^3.1.2"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "840c8bb284fd7504eb8a0eebd31b55f692f7f852"
|
|
34
|
+
}
|