@dile/utils 2.6.1 → 2.7.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.
@@ -0,0 +1,4 @@
1
+ import './calendar.js';
2
+ import { DileDatetimepicker } from "./src/DileDatetimepicker.js";
3
+
4
+ window.customElements.define("dile-datetimepicker", DileDatetimepicker);
@@ -93,13 +93,9 @@ export class DileDatepicker extends DileInput {
93
93
  ? html`<dile-icon class="trigger-disabled" .icon="${calendarIcon}"></dile-icon>`
94
94
  : html`
95
95
  <dile-menu-overlay moveTop="${this.moveTop}" moveLeft="${this.moveLeft}" verticalAlign="${this.verticalAlign}" horizontalAlign="${this.horizontalAlign}" id="menu">
96
- <dile-icon .icon="${calendarIcon}" slot="trigger"></dile-icon>
96
+ ${this.iconTemplate}
97
97
  <div slot="content" class="calendar">
98
- <dile-calendar
99
- class="demo-calendar"
100
- .firstDayOfWeek="${this.firstDayOfWeek}"
101
- @user-selected-date-changed=${this.showDate}
102
- ></dile-calendar>
98
+ ${this.contentTemplate}
103
99
  </div>
104
100
  </dile-menu-overlay>
105
101
  `
@@ -114,4 +110,18 @@ export class DileDatepicker extends DileInput {
114
110
  this.value = date;
115
111
  this.shadowRoot.getElementById('menu').close();
116
112
  }
113
+
114
+ get iconTemplate() {
115
+ return html`<dile-icon .icon="${calendarIcon}" slot="trigger"></dile-icon>`
116
+ }
117
+
118
+ get contentTemplate() {
119
+ return html`
120
+ <dile-calendar
121
+ class="demo-calendar"
122
+ .firstDayOfWeek="${this.firstDayOfWeek}"
123
+ @user-selected-date-changed=${this.showDate}
124
+ ></dile-calendar>
125
+ `
126
+ }
117
127
  }
@@ -0,0 +1,94 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { DileDatepicker } from './DileDatepicker';
3
+ import { dateTimeIcon } from '@dile/icons';
4
+ import '@dile/ui/components/time-picker/time-picker.js';
5
+ import { doneIcon } from '@dile/icons';
6
+
7
+ function formatToIsoOnlyDate(date) {
8
+ const pad = n => String(n).padStart(2, '0');
9
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
10
+ }
11
+
12
+ export class DileDatetimepicker extends DileDatepicker {
13
+
14
+ static get styles() {
15
+ return [
16
+ ...super.styles,
17
+ css`
18
+ .overlay-view {
19
+ display: flex;
20
+ flex-direction: column;
21
+ gap: 0.5rem;
22
+ align-items: center;
23
+ }
24
+ .time-area {
25
+ display: flex;
26
+ flex-direction: row;
27
+ gap: 1rem;
28
+ justify-content: center;
29
+ align-items: center;
30
+ margin-bottom: 0.5rem;
31
+ }
32
+ .time-area span {
33
+ display: flex;
34
+ align-items: center;
35
+ }
36
+ .time-area dile-icon {
37
+ --dile-icon-size: var(--dile-datetimepicker-accept-icon-size, 24px);
38
+ --dile-icon-color: var(--dile-datetimepicker-accept-icon-color, var(--dile-on-primary-color, #888));
39
+ --dile-icon-rounded-background-color: var(--dile-datetimepicker-accept-icon-background-color, var(--dile-primary-color, #f4f4f4));
40
+ cursor: pointer;
41
+ }
42
+ dile-time-picker {
43
+ margin-bottom: 0;
44
+ }
45
+ `];
46
+ }
47
+ get iconTemplate() {
48
+ return html`<dile-icon .icon="${dateTimeIcon}" slot="trigger"></dile-icon>`
49
+ }
50
+
51
+ get contentTemplate() {
52
+ return html`
53
+ <div class="overlay-view">
54
+ <dile-calendar
55
+ class="demo-calendar"
56
+ .firstDayOfWeek="${this.firstDayOfWeek}"
57
+ @user-selected-date-changed=${this.showDateHandler}
58
+ ></dile-calendar>
59
+ <div class="time-area">
60
+ <span>
61
+ <dile-time-picker></dile-time-picker>
62
+ </span>
63
+ <dile-icon rounded .icon=${doneIcon} @click=${this.acceptTime}></dile-icon>
64
+ </div>
65
+ </div>
66
+ `
67
+ }
68
+
69
+ get eltime() {
70
+ return this.shadowRoot.querySelector('dile-time-picker');
71
+ }
72
+
73
+ get elmenu() {
74
+ return this.shadowRoot.getElementById('menu');
75
+ }
76
+
77
+ showDateHandler(e) {
78
+ this.showDate(e.detail.selectedDate)
79
+ }
80
+
81
+ showDate(selectedDate) {
82
+ let date = formatToIsoOnlyDate(selectedDate);
83
+ let time = this.eltime.value;
84
+ this.value = `${date} ${time}`;
85
+ this.elmenu.close();
86
+ }
87
+ acceptTime() {
88
+ let date = this.shadowRoot.querySelector('dile-calendar').selectedDate;
89
+ if(!date) {
90
+ date = new Date();
91
+ }
92
+ this.showDate(date);
93
+ }
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/utils",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
4
4
  "description": "Utility Components of Diverse Uses Based on the Lit Library and Web Components Standard.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "homepage": "https://dile-components.com/",
22
22
  "dependencies": {
23
- "@dile/ui": "^2.7.1",
23
+ "@dile/ui": "^2.8.0",
24
24
  "@lion/ui": "^0.11.2",
25
25
  "linkify-string": "^4.1.3",
26
26
  "linkifyjs": "^4.1.3",
@@ -29,5 +29,5 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "260fc2605a66bdb10796e07242fa396081659c2c"
32
+ "gitHead": "23cccd2c6346a026fe4dae9374520e604c620085"
33
33
  }