@aquera/nile-elements 1.3.4-beta-1.3 → 1.3.4-beta-1.5
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/demo/index.html +4 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +219 -213
- package/dist/nile-date-picker/index.cjs.js +1 -1
- package/dist/nile-date-picker/index.esm.js +1 -1
- package/dist/nile-date-picker/nile-date-picker-utils.cjs.js +2 -0
- package/dist/nile-date-picker/nile-date-picker-utils.cjs.js.map +1 -0
- package/dist/nile-date-picker/nile-date-picker-utils.esm.js +1 -0
- package/dist/nile-date-picker/nile-date-picker.cjs.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js.map +1 -1
- package/dist/nile-date-picker/nile-date-picker.esm.js +9 -3
- package/dist/src/nile-date-picker/nile-date-picker-utils.d.ts +7 -0
- package/dist/src/nile-date-picker/nile-date-picker-utils.js +84 -0
- package/dist/src/nile-date-picker/nile-date-picker-utils.js.map +1 -0
- package/dist/src/nile-date-picker/nile-date-picker.d.ts +4 -20
- package/dist/src/nile-date-picker/nile-date-picker.js +42 -135
- package/dist/src/nile-date-picker/nile-date-picker.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-date-picker/nile-date-picker-utils.ts +105 -0
- package/src/nile-date-picker/nile-date-picker.ts +62 -187
- package/vscode-html-custom-data.json +9 -5
|
@@ -9,12 +9,7 @@ import { html, } from 'lit';
|
|
|
9
9
|
import { customElement, query, property } from 'lit/decorators.js';
|
|
10
10
|
import { styles } from './nile-date-picker.css';
|
|
11
11
|
import NileElement from '../internal/nile-element';
|
|
12
|
-
|
|
13
|
-
* Nile icon component.
|
|
14
|
-
*
|
|
15
|
-
* @tag nile-date-picker
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
12
|
+
import { formatDateToFormat, parseRangeFromFormat, normalizeDateRange } from './nile-date-picker-utils';
|
|
18
13
|
let NileDatePicker = class NileDatePicker extends NileElement {
|
|
19
14
|
constructor() {
|
|
20
15
|
super(...arguments);
|
|
@@ -28,101 +23,39 @@ let NileDatePicker = class NileDatePicker extends NileElement {
|
|
|
28
23
|
this.showManualInputs = false;
|
|
29
24
|
this.hideDurationFields = [];
|
|
30
25
|
this.allowedDates = '{}';
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
this.inputFormat = "DD/MM/YYYY";
|
|
26
|
+
this.syncDatePicker = false;
|
|
27
|
+
this.dateFormat = "DD/MM/YYYY";
|
|
28
|
+
this.rangeSeparator = " - ";
|
|
35
29
|
}
|
|
36
|
-
/**
|
|
37
|
-
* The styles for DatePicker
|
|
38
|
-
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
|
39
|
-
*/
|
|
40
30
|
static get styles() {
|
|
41
31
|
return [styles];
|
|
42
32
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const parts = str.split(sep);
|
|
58
|
-
const fmtParts = fmt.split(sep);
|
|
59
|
-
let day = null, month = null, year = null;
|
|
60
|
-
for (let i = 0; i < fmtParts.length; i++) {
|
|
61
|
-
const f = fmtParts[i];
|
|
62
|
-
const v = parts[i];
|
|
63
|
-
if (!v)
|
|
64
|
-
return null;
|
|
65
|
-
if (f === "DD") {
|
|
66
|
-
if (v.length !== 2)
|
|
67
|
-
return null;
|
|
68
|
-
day = Number(v);
|
|
33
|
+
firstUpdated() {
|
|
34
|
+
super.firstUpdated?.(new Map());
|
|
35
|
+
if (!this.syncDatePicker)
|
|
36
|
+
return;
|
|
37
|
+
const input = this.querySelector("nile-input");
|
|
38
|
+
if (!input)
|
|
39
|
+
return;
|
|
40
|
+
input.addEventListener("nile-input", (e) => {
|
|
41
|
+
const text = e.detail.value;
|
|
42
|
+
const { first, second } = parseRangeFromFormat(text, this.dateFormat, this.range, this.rangeSeparator);
|
|
43
|
+
if (!this.range) {
|
|
44
|
+
if (first)
|
|
45
|
+
this.jumpTo(first);
|
|
46
|
+
return;
|
|
69
47
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
month = Number(v) - 1;
|
|
48
|
+
if (first && !second) {
|
|
49
|
+
this.jumpTo(first);
|
|
50
|
+
this.syncRangeCalendar(first, null);
|
|
74
51
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
52
|
+
if (first && second) {
|
|
53
|
+
const [start, end] = normalizeDateRange(first, second);
|
|
54
|
+
if (end)
|
|
55
|
+
this.jumpTo(end);
|
|
56
|
+
this.syncRangeCalendar(start, end);
|
|
79
57
|
}
|
|
80
|
-
}
|
|
81
|
-
if (day == null || month == null || year == null)
|
|
82
|
-
return null;
|
|
83
|
-
const d = new Date(year, month, day);
|
|
84
|
-
if (d.getFullYear() !== year ||
|
|
85
|
-
d.getMonth() !== month ||
|
|
86
|
-
d.getDate() !== day)
|
|
87
|
-
return null;
|
|
88
|
-
return d;
|
|
89
|
-
}
|
|
90
|
-
formatDate(date) {
|
|
91
|
-
if (!date)
|
|
92
|
-
return "";
|
|
93
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
94
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
95
|
-
const year = date.getFullYear();
|
|
96
|
-
switch (this.inputFormat) {
|
|
97
|
-
case "DD/MM/YYYY":
|
|
98
|
-
return `${day}/${month}/${year}`;
|
|
99
|
-
case "MM/DD/YYYY":
|
|
100
|
-
return `${month}/${day}/${year}`;
|
|
101
|
-
case "YYYY/MM/DD":
|
|
102
|
-
return `${year}/${month}/${day}`;
|
|
103
|
-
case "YYYY.MM.DD":
|
|
104
|
-
return `${year}.${month}.${day}`;
|
|
105
|
-
case "DD.MM.YYYY":
|
|
106
|
-
return `${day}.${month}.${year}`;
|
|
107
|
-
default:
|
|
108
|
-
return `${day}/${month}/${year}`;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
parseRange(input) {
|
|
112
|
-
if (!this.range) {
|
|
113
|
-
return { first: this.parseDate(input), second: null };
|
|
114
|
-
}
|
|
115
|
-
const RANGE_SEP = " - ";
|
|
116
|
-
if (!input.includes(RANGE_SEP)) {
|
|
117
|
-
return { first: this.parseDate(input), second: null };
|
|
118
|
-
}
|
|
119
|
-
const [firstRaw, secondRaw] = input.split(RANGE_SEP);
|
|
120
|
-
const first = this.parseDate(firstRaw);
|
|
121
|
-
let second = null;
|
|
122
|
-
if (secondRaw && secondRaw.length >= 10) {
|
|
123
|
-
second = this.parseDate(secondRaw);
|
|
124
|
-
}
|
|
125
|
-
return { first, second };
|
|
58
|
+
});
|
|
126
59
|
}
|
|
127
60
|
jumpTo(date) {
|
|
128
61
|
this.open = true;
|
|
@@ -144,56 +77,29 @@ let NileDatePicker = class NileDatePicker extends NileElement {
|
|
|
144
77
|
cal.startDate = first;
|
|
145
78
|
if (second)
|
|
146
79
|
cal.endDate = second;
|
|
147
|
-
if (first && second && first.getTime() > second.getTime()) {
|
|
148
|
-
cal.startDate = second;
|
|
149
|
-
cal.endDate = first;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
firstUpdated() {
|
|
153
|
-
super.firstUpdated?.(new Map());
|
|
154
|
-
if (!this.jumpToTypedDate)
|
|
155
|
-
return;
|
|
156
|
-
const input = this.querySelector("nile-input");
|
|
157
|
-
if (!input)
|
|
158
|
-
return;
|
|
159
|
-
input.addEventListener("nile-input", (e) => {
|
|
160
|
-
const text = e.detail.value;
|
|
161
|
-
const { first, second } = this.parseRange(text);
|
|
162
|
-
if (!this.range) {
|
|
163
|
-
if (first)
|
|
164
|
-
this.jumpTo(first);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (first && !second) {
|
|
168
|
-
this.jumpTo(first);
|
|
169
|
-
this.syncRangeCalendar(first, null);
|
|
170
|
-
}
|
|
171
|
-
if (first && second) {
|
|
172
|
-
let start = first, end = second;
|
|
173
|
-
if (start.getTime() > end.getTime()) {
|
|
174
|
-
[start, end] = [end, start];
|
|
175
|
-
}
|
|
176
|
-
this.jumpTo(end);
|
|
177
|
-
this.syncRangeCalendar(start, end);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
80
|
}
|
|
181
81
|
render() {
|
|
182
82
|
return html `
|
|
183
83
|
<nile-dropdown .open="${this.open}" part="dd-base" .hoist="${true}" distance="6" exportparts="base">
|
|
184
84
|
<slot slot="trigger" part="trigger" name="trigger"></slot>
|
|
85
|
+
|
|
185
86
|
<nile-calendar
|
|
186
87
|
.hideTypes="${this.hideTypes}"
|
|
187
|
-
|
|
88
|
+
.type="${this.type}"
|
|
188
89
|
value="${this.value}"
|
|
189
90
|
.range="${this.range}"
|
|
91
|
+
|
|
190
92
|
@nile-init="${(e) => e.stopPropagation()}"
|
|
191
93
|
@nile-destroy="${(e) => e.stopPropagation()}"
|
|
192
94
|
@nile-changed="${(e) => e.stopPropagation()}"
|
|
95
|
+
|
|
193
96
|
@nile-change="${this.handleChanged}"
|
|
97
|
+
|
|
194
98
|
.allowedDates="${this.allowedDates}"
|
|
99
|
+
|
|
195
100
|
@nile-type-change="${(e) => { e.stopPropagation(); this.emit('nile-type-change', e.detail); }}"
|
|
196
101
|
@nile-clear="${(e) => { e.stopPropagation(); this.emit('nile-clear'); }}"
|
|
102
|
+
|
|
197
103
|
.hideDurationFields="${this.hideDurationFields}"
|
|
198
104
|
.showManualInputs="${this.showManualInputs}"
|
|
199
105
|
.doubleClickUnselect="${this.doubleClickUnselect}"
|
|
@@ -206,11 +112,10 @@ let NileDatePicker = class NileDatePicker extends NileElement {
|
|
|
206
112
|
event.stopPropagation();
|
|
207
113
|
const detail = event.detail;
|
|
208
114
|
const triggerInput = this.querySelector("nile-input");
|
|
209
|
-
// SINGLE DATE
|
|
210
115
|
if (!this.range) {
|
|
211
116
|
const picked = detail.value;
|
|
212
117
|
if (picked && triggerInput) {
|
|
213
|
-
triggerInput.value =
|
|
118
|
+
triggerInput.value = formatDateToFormat(new Date(picked), this.dateFormat);
|
|
214
119
|
triggerInput.emit("nile-input", { value: triggerInput.value });
|
|
215
120
|
}
|
|
216
121
|
this.emit("nile-changed", detail);
|
|
@@ -218,15 +123,14 @@ let NileDatePicker = class NileDatePicker extends NileElement {
|
|
|
218
123
|
this.dropdown?.hide();
|
|
219
124
|
return;
|
|
220
125
|
}
|
|
221
|
-
// RANGE MODE
|
|
222
126
|
const start = detail.startDate;
|
|
223
127
|
const end = detail.endDate;
|
|
224
128
|
if (triggerInput) {
|
|
225
129
|
let text = "";
|
|
226
130
|
if (start)
|
|
227
|
-
text +=
|
|
131
|
+
text += formatDateToFormat(new Date(start), this.dateFormat);
|
|
228
132
|
if (start && end)
|
|
229
|
-
text += " - " +
|
|
133
|
+
text += " - " + formatDateToFormat(new Date(end), this.dateFormat);
|
|
230
134
|
triggerInput.value = text;
|
|
231
135
|
triggerInput.emit("nile-input", { value: text });
|
|
232
136
|
}
|
|
@@ -278,10 +182,13 @@ __decorate([
|
|
|
278
182
|
], NileDatePicker.prototype, "allowedDates", void 0);
|
|
279
183
|
__decorate([
|
|
280
184
|
property({ type: Boolean, attribute: true, reflect: true })
|
|
281
|
-
], NileDatePicker.prototype, "
|
|
185
|
+
], NileDatePicker.prototype, "syncDatePicker", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: String, attribute: true, reflect: true })
|
|
188
|
+
], NileDatePicker.prototype, "dateFormat", void 0);
|
|
282
189
|
__decorate([
|
|
283
190
|
property({ type: String, attribute: true, reflect: true })
|
|
284
|
-
], NileDatePicker.prototype, "
|
|
191
|
+
], NileDatePicker.prototype, "rangeSeparator", void 0);
|
|
285
192
|
__decorate([
|
|
286
193
|
query('nile-dropdown')
|
|
287
194
|
], NileDatePicker.prototype, "dropdown", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nile-date-picker.js","sourceRoot":"","sources":["../../../src/nile-date-picker/nile-date-picker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAIH,OAAO,EAEL,IAAI,GAGL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAGnD;;;;;GAKG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,WAAW;IAAxC;;QASwB,UAAK,GAAG,KAAK,CAAC;QAEd,cAAS,GAAG,KAAK,CAAC;QAEH,wBAAmB,GAAG,KAAK,CAAC;QAE5B,eAAU,GAAG,KAAK,CAAC;QAElC,SAAI,GAAG,KAAK,CAAC;QAEgB,iBAAY,GAAG,KAAK,CAAC;QAEpC,SAAI,GAA4B,UAAU,CAAC;QAGtF,qBAAgB,GAAG,KAAK,CAAC;QAIzB,uBAAkB,GAAQ,EAAE,CAAC;QAEY,iBAAY,GAAQ,IAAI,CAAC;QAElE,uCAAuC;QACsB,oBAAe,GAAG,KAAK,CAAC;QAErF,sBAAsB;QACsC,gBAAW,GAAG,YAAY,CAAC;IAqPzF,CAAC;IAxRC;;;OAGG;IACI,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAkCD;;;OAGG;IACM,SAAS,CAAC,GAAW;QAC5B,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QAEtB,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC;QAC7B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ;YA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C;AAEb;IAAX,QAAQ,EAAE;6CAAY;AAEvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;0DAChC;AAEY;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAA0B;AAGL;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDAAyB;AAGzB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAA4B;AAG/D;IAAvB,KAAK,CAAC,eAAe,CAAC;gDAAwB;AAvCpC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAyR1B;;AAED,eAAe,cAAc,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n} from 'lit';\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { styles } from './nile-date-picker.css';\nimport NileElement from '../internal/nile-element';\nimport { NileDropdown } from '../nile-dropdown';\n\n/**\n * Nile icon component.\n *\n * @tag nile-date-picker\n *\n */\n@customElement('nile-date-picker')\nexport class NileDatePicker extends NileElement {\n /**\n * The styles for DatePicker\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean }) range = false;\n\n @property({ type: Boolean }) hideTypes = false;\n\n @property({ type: Boolean, reflect: true }) doubleClickUnselect = false;\n\n @property({ type: Boolean, reflect: true }) allowClear = false;\n\n @property({ type: Boolean }) open = false;\n\n @property({ type: Boolean, attribute: 'hide-time-zone' }) hideTimeZone = false;\n\n @property({ type: String, reflect: true }) type :'absolute' | 'relative' = 'absolute';\n\n @property({ type: Boolean, attribute: 'showManualInputs' })\n showManualInputs = false;\n\n @property() value: any;\n @property({ type: Array, attribute: 'hide-duration-fields' })\n hideDurationFields: any = [];\n\n @property({ attribute: 'allowedDates' }) allowedDates: any = '{}';\n\n // Jump to typed date activated by user\n @property({ type: Boolean, attribute: true, reflect: true }) jumpToTypedDate = false;\n\n // Strict input format\n @property({ type: String, attribute: true, reflect: true }) inputFormat = \"DD/MM/YYYY\";\n\n\n @query('nile-dropdown') dropdown: NileDropdown;\n\n /**\n * Render method\n * @slot This is a slot test\n */\n private parseDate(str: string): Date | null {\n if (!str) return null;\n\n const fmt = this.inputFormat; \n const sepMatch = fmt.match(/[^A-Z]/i);\n if (!sepMatch) return null;\n const sep = sepMatch[0];\n\n if (!str.includes(sep)) return null;\n\n const parts = str.split(sep);\n const fmtParts = fmt.split(sep);\n\n let day = null, month = null, year = null;\n\n for (let i = 0; i < fmtParts.length; i++) {\n const f = fmtParts[i];\n const v = parts[i];\n if (!v) return null;\n\n if (f === \"DD\") {\n if (v.length !== 2) return null;\n day = Number(v);\n }\n\n if (f === \"MM\") {\n if (v.length !== 2) return null;\n month = Number(v) - 1;\n }\n\n if (f === \"YYYY\") {\n if (v.length !== 4) return null;\n year = Number(v);\n }\n }\n\n if (day == null || month == null || year == null) return null;\n\n const d = new Date(year, month, day);\n if (\n d.getFullYear() !== year ||\n d.getMonth() !== month ||\n d.getDate() !== day\n ) return null;\n\n return d;\n }\n\n\n private formatDate(date: Date): string {\n if (!date) return \"\";\n \n const day = String(date.getDate()).padStart(2, \"0\");\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const year = date.getFullYear();\n \n switch (this.inputFormat) {\n case \"DD/MM/YYYY\":\n return `${day}/${month}/${year}`;\n case \"MM/DD/YYYY\":\n return `${month}/${day}/${year}`;\n case \"YYYY/MM/DD\":\n return `${year}/${month}/${day}`;\n case \"YYYY.MM.DD\":\n return `${year}.${month}.${day}`;\n case \"DD.MM.YYYY\":\n return `${day}.${month}.${year}`;\n default:\n return `${day}/${month}/${year}`;\n }\n }\n\n private parseRange(input: string) {\n if (!this.range) {\n return { first: this.parseDate(input), second: null };\n }\n\n const RANGE_SEP = \" - \";\n\n if (!input.includes(RANGE_SEP)) {\n return { first: this.parseDate(input), second: null };\n }\n\n const [firstRaw, secondRaw] = input.split(RANGE_SEP);\n\n const first = this.parseDate(firstRaw);\n let second = null;\n\n if (secondRaw && secondRaw.length >= 10) {\n second = this.parseDate(secondRaw);\n }\n\n return { first, second };\n }\n\n private jumpTo(date: Date) {\n this.open = true;\n\n const cal = this.shadowRoot!.querySelector(\"nile-calendar\") as any;\n if (!cal) return;\n\n cal.currentYear = date.getFullYear();\n cal.currentMonth = date.getMonth();\n cal.value = date;\n cal.valueAttribute = date.toISOString();\n }\n\n private syncRangeCalendar(first: Date | null, second: Date | null) {\n const cal = this.shadowRoot!.querySelector(\"nile-calendar\") as any;\n if (!cal) return;\n\n if (!this.range) return; \n\n if (first) cal.startDate = first;\n if (second) cal.endDate = second;\n\n \n if (first && second && first.getTime() > second.getTime()) {\n cal.startDate = second;\n cal.endDate = first;\n }\n }\n firstUpdated() {\n super.firstUpdated?.(new Map());\n\n if (!this.jumpToTypedDate) return;\n\n const input = this.querySelector(\"nile-input\");\n if (!input) return;\n\n input.addEventListener(\"nile-input\", (e: any) => {\n const text = e.detail.value;\n const { first, second } = this.parseRange(text);\n\n if (!this.range) {\n if (first) this.jumpTo(first);\n return;\n }\n\n if (first && !second) {\n this.jumpTo(first);\n this.syncRangeCalendar(first, null);\n }\n\n if (first && second) {\n let start = first, end = second;\n if (start.getTime() > end.getTime()) {\n [start, end] = [end, start];\n }\n\n this.jumpTo(end);\n this.syncRangeCalendar(start, end);\n }\n });\n }\n\n \n render(): TemplateResult {\n return html`\n <nile-dropdown .open=\"${this.open}\" part=\"dd-base\" .hoist=\"${true}\" distance=\"6\" exportparts=\"base\">\n <slot slot=\"trigger\" part=\"trigger\" name=\"trigger\"></slot>\n <nile-calendar\n .hideTypes=\"${this.hideTypes}\"\n \t.type=\"${this.type}\"\n value=\"${this.value}\"\n .range=\"${this.range}\"\n @nile-init=\"${(e:CustomEvent)=>e.stopPropagation()}\"\n @nile-destroy=\"${(e:CustomEvent)=>e.stopPropagation()}\"\n @nile-changed=\"${(e:CustomEvent)=>e.stopPropagation()}\"\n @nile-change=\"${this.handleChanged}\"\n .allowedDates=\"${this.allowedDates}\"\n @nile-type-change=\"${(e:CustomEvent)=>{e.stopPropagation();this.emit('nile-type-change',e.detail)}}\"\n @nile-clear=\"${(e:CustomEvent)=>{e.stopPropagation();this.emit('nile-clear')}}\"\n .hideDurationFields=\"${this.hideDurationFields}\"\n .showManualInputs=\"${this.showManualInputs}\"\n .doubleClickUnselect=\"${this.doubleClickUnselect}\"\n .allowClear=\"${this.allowClear}\"\n ></nile-calendar>\n </nile-dropdown>\n `;\n }\n\n handleChanged(event: CustomEvent) {\n event.stopPropagation();\n \n const detail = event.detail; \n const triggerInput = this.querySelector(\"nile-input\");\n \n // SINGLE DATE\n if (!this.range) {\n const picked = detail.value;\n \n if (picked && triggerInput) {\n triggerInput.value = this.formatDate(new Date(picked));\n triggerInput.emit(\"nile-input\", { value: triggerInput.value });\n }\n \n \n this.emit(\"nile-changed\", detail);\n this.emit(\"nile-change\", detail);\n \n this.dropdown?.hide();\n return;\n }\n \n // RANGE MODE\n const start = detail.startDate;\n const end = detail.endDate;\n \n if (triggerInput) {\n let text = \"\";\n if (start) text += this.formatDate(new Date(start));\n if (start && end) text += \" - \" + this.formatDate(new Date(end));\n \n triggerInput.value = text;\n triggerInput.emit(\"nile-input\", { value: text });\n }\n \n \n this.emit(\"nile-changed\", detail);\n this.emit(\"nile-change\", detail);\n \n this.dropdown?.hide();\n }\n \n \n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n}\n\nexport default NileDatePicker;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-date-picker': NileDatePicker;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nile-date-picker.js","sourceRoot":"","sources":["../../../src/nile-date-picker/nile-date-picker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EACL,IAAI,GAGL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAGnD,OAAO,EAEL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAI3B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,WAAW;IAAxC;;QAKwB,UAAK,GAAG,KAAK,CAAC;QACd,cAAS,GAAG,KAAK,CAAC;QACH,wBAAmB,GAAG,KAAK,CAAC;QAC5B,eAAU,GAAG,KAAK,CAAC;QAClC,SAAI,GAAG,KAAK,CAAC;QACgB,iBAAY,GAAG,KAAK,CAAC;QACpC,SAAI,GAA4B,UAAU,CAAC;QAC1B,qBAAgB,GAAG,KAAK,CAAC;QAGvB,uBAAkB,GAAQ,EAAE,CAAC;QAClD,iBAAY,GAAQ,IAAI,CAAC;QAEL,mBAAc,GAAG,KAAK,CAAC;QACxB,eAAU,GAAG,YAAY,CAAC;QAC5B,mBAAc,GAAG,KAAK,CAAC;IAyInF,CAAC;IA5JQ,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAsBD,YAAY;QACV,KAAK,CAAC,YAAY,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAEhC,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO;QAEjC,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,Y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,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;wDAA0B;AAEzE;IAAX,QAAQ,EAAE;6CAAY;AACuC;IAA7D,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;0DAA8B;AAClD;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAA0B;AAEL;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAAwB;AACxB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAA2B;AAC5B;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAAwB;AAGzD;IAAvB,KAAK,CAAC,eAAe,CAAC;gDAAwB;AAvBpC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA6J1B;;AAED,eAAe,cAAc,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n html,\n CSSResultArray,\n TemplateResult,\n} from 'lit';\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { styles } from './nile-date-picker.css';\nimport NileElement from '../internal/nile-element';\nimport { NileDropdown } from '../nile-dropdown';\n\nimport {\n parseDateFromFormat,\n formatDateToFormat,\n parseRangeFromFormat,\n normalizeDateRange\n} from './nile-date-picker-utils';\n\n\n@customElement('nile-date-picker')\nexport class NileDatePicker extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean }) range = false;\n @property({ type: Boolean }) hideTypes = false;\n @property({ type: Boolean, reflect: true }) doubleClickUnselect = false;\n @property({ type: Boolean, reflect: true }) allowClear = false;\n @property({ type: Boolean }) open = false;\n @property({ type: Boolean, attribute: 'hide-time-zone' }) hideTimeZone = false;\n @property({ type: String, reflect: true }) type: 'absolute' | 'relative' = 'absolute';\n @property({ type: Boolean, attribute: 'showManualInputs' }) showManualInputs = false;\n\n @property() value: any;\n @property({ type: Array, attribute: 'hide-duration-fields' }) hideDurationFields: any = [];\n @property({ attribute: 'allowedDates' }) allowedDates: any = '{}';\n\n @property({ type: Boolean, attribute: true, reflect: true }) syncDatePicker = false;\n @property({ type: String, attribute: true, reflect: true }) dateFormat = \"DD/MM/YYYY\"; \n@property({ type: String, attribute: true, reflect: true }) rangeSeparator = \" - \";\n\n\n @query('nile-dropdown') dropdown: NileDropdown;\n\n firstUpdated() {\n super.firstUpdated?.(new Map());\n\n if (!this.syncDatePicker) return;\n\n const input = this.querySelector(\"nile-input\");\n if (!input) return;\n\n input.addEventListener(\"nile-input\", (e: any) => {\n const text = e.detail.value;\n const { first, second } = parseRangeFromFormat(text, this.dateFormat, this.range, this.rangeSeparator);\n\n if (!this.range) {\n if (first) this.jumpTo(first);\n return;\n }\n\n if (first && !second) {\n this.jumpTo(first);\n this.syncRangeCalendar(first, null);\n }\n\n if (first && second) {\n const [start, end] = normalizeDateRange(first, second);\n if (end) this.jumpTo(end);\n this.syncRangeCalendar(start, end);\n }\n });\n }\n\n private jumpTo(date: Date) {\n this.open = true;\n const cal = this.shadowRoot!.querySelector(\"nile-calendar\") as any;\n if (!cal) return;\n\n cal.currentYear = date.getFullYear();\n cal.currentMonth = date.getMonth();\n cal.value = date;\n cal.valueAttribute = date.toISOString();\n }\n\n\n private syncRangeCalendar(first: Date | null, second: Date | null) {\n const cal = this.shadowRoot!.querySelector(\"nile-calendar\") as any;\n if (!cal) return;\n\n if (!this.range) return;\n\n if (first) cal.startDate = first;\n if (second) cal.endDate = second;\n }\n\n render(): TemplateResult {\n return html`\n <nile-dropdown .open=\"${this.open}\" part=\"dd-base\" .hoist=\"${true}\" distance=\"6\" exportparts=\"base\">\n <slot slot=\"trigger\" part=\"trigger\" name=\"trigger\"></slot>\n\n <nile-calendar\n .hideTypes=\"${this.hideTypes}\"\n .type=\"${this.type}\"\n value=\"${this.value}\"\n .range=\"${this.range}\"\n\n @nile-init=\"${(e: CustomEvent) => e.stopPropagation()}\"\n @nile-destroy=\"${(e: CustomEvent) => e.stopPropagation()}\"\n @nile-changed=\"${(e: CustomEvent) => e.stopPropagation()}\"\n\n @nile-change=\"${this.handleChanged}\"\n\n .allowedDates=\"${this.allowedDates}\"\n\n @nile-type-change=\"${(e: CustomEvent) => { e.stopPropagation(); this.emit('nile-type-change', e.detail); }}\"\n @nile-clear=\"${(e: CustomEvent) => { e.stopPropagation(); this.emit('nile-clear'); }}\"\n\n .hideDurationFields=\"${this.hideDurationFields}\"\n .showManualInputs=\"${this.showManualInputs}\"\n .doubleClickUnselect=\"${this.doubleClickUnselect}\"\n .allowClear=\"${this.allowClear}\"\n ></nile-calendar>\n </nile-dropdown>\n `;\n }\n\n\n handleChanged(event: CustomEvent) {\n event.stopPropagation();\n\n const detail = event.detail;\n const triggerInput = this.querySelector(\"nile-input\");\n\n if (!this.range) {\n const picked = detail.value;\n\n if (picked && triggerInput) {\n triggerInput.value = formatDateToFormat(new Date(picked), this.dateFormat);\n triggerInput.emit(\"nile-input\", { value: triggerInput.value });\n }\n\n this.emit(\"nile-changed\", detail);\n this.emit(\"nile-change\", detail);\n\n this.dropdown?.hide();\n return;\n }\n\n const start = detail.startDate;\n const end = detail.endDate;\n\n if (triggerInput) {\n let text = \"\";\n if (start) text += formatDateToFormat(new Date(start), this.dateFormat);\n if (start && end) text += \" - \" + formatDateToFormat(new Date(end), this.dateFormat);\n\n triggerInput.value = text;\n triggerInput.emit(\"nile-input\", { value: text });\n }\n\n this.emit(\"nile-changed\", detail);\n this.emit(\"nile-change\", detail);\n\n this.dropdown?.hide();\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n}\n\nexport default NileDatePicker;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-date-picker': NileDatePicker;\n }\n}\n"]}
|
package/dist/src/version.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Version utility - placeholders will be replaced during build
|
|
2
|
-
export const NILE_ELEMENTS_VERSION = '1.3.4-beta-1.
|
|
2
|
+
export const NILE_ELEMENTS_VERSION = '1.3.4-beta-1.5';
|
|
3
3
|
export const NILE_VERSION = '1.1.1';
|
|
4
4
|
// Set global versions for runtime access
|
|
5
5
|
if (typeof window !== 'undefined') {
|
package/dist/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,yCAAyC;AACzC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACjC,MAAc,CAAC,mBAAmB,GAAG,qBAAqB,CAAC;IAC3D,MAAc,CAAC,WAAW,GAAG,YAAY,CAAC;IAC3C,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,CAAC;AACzE,CAAC","sourcesContent":["// Version utility - placeholders will be replaced during build\nexport const NILE_ELEMENTS_VERSION = '1.3.4-beta-1.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,yCAAyC;AACzC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACjC,MAAc,CAAC,mBAAmB,GAAG,qBAAqB,CAAC;IAC3D,MAAc,CAAC,WAAW,GAAG,YAAY,CAAC;IAC3C,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,CAAC;AACzE,CAAC","sourcesContent":["// Version utility - placeholders will be replaced during build\nexport const NILE_ELEMENTS_VERSION = '1.3.4-beta-1.5';\nexport const NILE_VERSION = '1.1.1';\n\n// Set global versions for runtime access\nif (typeof window !== 'undefined') {\n (window as any).nileElementsVersion = NILE_ELEMENTS_VERSION;\n (window as any).nileVersion = NILE_VERSION;\n window.process = window.process || { env: { NODE_ENV: 'production' } };\n}\n"]}
|