@aquera/nile-elements 0.0.16 → 0.0.17

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.
Files changed (44) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.css.js +117 -3
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.d.ts +16 -1
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js +225 -20
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/timezones.d.ts +1 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/timezones.js +350 -0
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/timezones.js.map +1 -0
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.css.js +1 -0
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.css.js.map +1 -1
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  12. package/dist/index.cjs.js +1 -1
  13. package/dist/index.esm.js +1 -1
  14. package/dist/index.iife.js +391 -165
  15. package/dist/nile-calendar/index.cjs.js +1 -1
  16. package/dist/nile-calendar/index.esm.js +1 -1
  17. package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
  18. package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
  19. package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
  20. package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
  21. package/dist/nile-calendar/nile-calendar.css.esm.js +119 -5
  22. package/dist/nile-calendar/nile-calendar.esm.js +130 -19
  23. package/dist/nile-calendar/timezones.cjs.js +2 -0
  24. package/dist/nile-calendar/timezones.cjs.js.map +1 -0
  25. package/dist/nile-calendar/timezones.esm.js +1 -0
  26. package/dist/nile-option/nile-option.css.cjs.js +1 -1
  27. package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
  28. package/dist/nile-option/nile-option.css.esm.js +3 -2
  29. package/dist/src/nile-calendar/nile-calendar.css.js +117 -3
  30. package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
  31. package/dist/src/nile-calendar/nile-calendar.d.ts +16 -1
  32. package/dist/src/nile-calendar/nile-calendar.js +225 -20
  33. package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  34. package/dist/src/nile-calendar/timezones.d.ts +1 -0
  35. package/dist/src/nile-calendar/timezones.js +350 -0
  36. package/dist/src/nile-calendar/timezones.js.map +1 -0
  37. package/dist/src/nile-option/nile-option.css.js +1 -0
  38. package/dist/src/nile-option/nile-option.css.js.map +1 -1
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +1 -1
  41. package/src/nile-calendar/nile-calendar.css.ts +117 -3
  42. package/src/nile-calendar/nile-calendar.ts +321 -83
  43. package/src/nile-calendar/timezones.ts +348 -0
  44. package/src/nile-option/nile-option.css.ts +1 -0
@@ -81,8 +81,17 @@ export const styles = css `
81
81
  cursor: pointer;
82
82
  }
83
83
 
84
+ .current-date {
85
+ border: 1px solid #1978b8;
86
+ }
87
+
88
+ .day:hover {
89
+ background-color: #e5e9eb;
90
+ }
91
+
84
92
  .filler {
85
- color: grey;
93
+ color: #7f7f7f;
94
+ pointer-events: none;
86
95
  }
87
96
 
88
97
  .selected-date {
@@ -91,12 +100,15 @@ export const styles = css `
91
100
  background: #a5d3f3;
92
101
  }
93
102
 
103
+ .selected-date:hover {
104
+ background: #a5d3f3;
105
+ }
106
+
94
107
  .calendar-wrapper {
95
108
  background: white;
96
109
  display: flex;
97
110
  justify-content: space-between;
98
111
  width: 365px;
99
- box-shadow: 0px 4px 8px 0px rgba(119, 125, 130, 0.15);
100
112
  }
101
113
 
102
114
  .selected-date,
@@ -148,6 +160,10 @@ export const styles = css `
148
160
  width: 365px;
149
161
  }
150
162
 
163
+ .base__relative {
164
+ width: 446px;
165
+ }
166
+
151
167
  .base__range {
152
168
  padding: 24px;
153
169
  }
@@ -158,6 +174,10 @@ export const styles = css `
158
174
  width: 365px;
159
175
  }
160
176
 
177
+ .calender-input--relative {
178
+ width: 446px;
179
+ }
180
+
161
181
  .from {
162
182
  display: flex;
163
183
  justify-content: space-between;
@@ -181,7 +201,101 @@ export const styles = css `
181
201
  .button-contaner {
182
202
  width: 100%;
183
203
  text-align: right;
184
- padding: 12px 0 0 0;
204
+ padding: 24px 0 0 0;
205
+ }
206
+
207
+ .calendar-config {
208
+ display: flex;
209
+ align-items: center;
210
+ justify-content: space-between;
211
+ margin-bottom: 12px;
212
+ }
213
+
214
+ .calendar-switcher {
215
+ display: flex;
216
+ align-items: flex-start;
217
+ gap: 24px;
218
+ justify-content: space-between;
219
+ border-bottom: 1px solid #e5e9eb;
220
+ }
221
+
222
+ .calendar-switch {
223
+ padding-bottom: 12px;
224
+ cursor: pointer;
225
+ }
226
+
227
+ .calendar-switch__active {
228
+ padding-bottom: 12px;
229
+ border-bottom: 4px solid #005ea6;
230
+ }
231
+
232
+ .unit-container {
233
+ display: flex;
234
+ flex-direction: column;
235
+ width: 446px;
236
+ margin-top: 24px;
237
+ }
238
+
239
+ .time-unit-group {
240
+ display: flex;
241
+ align-items: center;
242
+ margin-bottom: 24px;
243
+ gap: 24px;
244
+ }
245
+
246
+ .time-unit-name {
247
+ width: 54px;
248
+ }
249
+
250
+ .time-unit-name span {
251
+ margin-right: 24px;
252
+ color: var(--color-text-default, #000);
253
+ font-family: Colfax-regular;
254
+ font-size: 14px;
255
+ font-style: normal;
256
+ font-weight: 500;
257
+ line-height: 14px;
258
+ letter-spacing: 0.2px;
259
+ }
260
+
261
+ .time-unit-value {
262
+ display: flex;
263
+ }
264
+
265
+ .time-value {
266
+ display: inline-flex;
267
+ width: 48px;
268
+ height: 32px;
269
+ box-sizing: border-box;
270
+ padding: 5px;
271
+ border: 1px solid #ddd;
272
+ cursor: pointer;
273
+ justify-content: center;
274
+ align-items: center;
275
+ margin-right: 16px;
276
+ border-radius: 4px;
277
+ border: 1px solid #c7ced4;
278
+ background: rgba(255, 255, 255, 0.2);
279
+ }
280
+
281
+ .time-value--selected {
282
+ background: #a5d3f3;
283
+ }
284
+
285
+ .time-value:last-child {
286
+ margin-right: 0;
287
+ }
288
+
289
+ .time-value:hover {
290
+ background: #e5e9eb;
291
+ }
292
+
293
+ .time-value--selected:hover {
294
+ background-color: #a5d3f3;
295
+ }
296
+
297
+ .hidden {
298
+ display: none !important;
185
299
  }
186
300
  `;
187
301
  export default [styles];
@@ -1 +1 @@
1
- {"version":3,"file":"nile-calendar.css.js","sourceRoot":"","sources":["../../../src/nile-calendar/nile-calendar.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+KxB,CAAC;AAEF,eAAe,CAAC,MAAM,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 { css } from 'lit-element';\n\n/**\n * DatePicker CSS\n */\nexport const styles = css`\n :host {\n }\n\n .calendar-container {\n font-family: Colfax-regular;\n width: 365px;\n height: auto;\n text-align: center;\n background: white;\n }\n\n .calendar-container.with-margin {\n margin-right: 20px;\n }\n\n .calendar-header {\n display: flex;\n justify-content: space-between;\n padding: 10px;\n padding: 22px 20px;\n font-size: 14px;\n font-weight: 600;\n line-height: 14px;\n letter-spacing: 0.2px;\n }\n\n .calendar-header__month-navigation {\n cursor: pointer;\n }\n\n .divider {\n width: 100%;\n height: 1px;\n background: #c7ced4;\n }\n\n .day-names {\n font-size: 14px;\n font-weight: 600;\n line-height: 14px;\n letter-spacing: 0.2px;\n height: 50px;\n }\n\n .day-names,\n .days {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n height: auto;\n align-items: center;\n }\n\n .days {\n height: auto;\n }\n\n .day {\n flex-basis: calc(100% / 7);\n box-sizing: border-box;\n width: 48px;\n align-items: center;\n padding: 10px;\n height: 32px;\n margin-top: 6px;\n margin-bottom: 6px;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n }\n\n .filler {\n color: grey;\n }\n\n .selected-date {\n color: white;\n border-radius: 4px;\n background: #a5d3f3;\n }\n\n .calendar-wrapper {\n background: white;\n display: flex;\n justify-content: space-between;\n width: 365px;\n box-shadow: 0px 4px 8px 0px rgba(119, 125, 130, 0.15);\n }\n\n .selected-date,\n .range-start,\n .range-end {\n border-radius: 4px;\n background: #a5d3f3;\n color: white;\n }\n\n .range-start {\n background: #a5d3f3;\n border-radius: 4px 0 0 4px;\n color: white;\n }\n\n .range-end {\n background: #a5d3f3;\n border-radius: 0 4px 4px 0;\n color: white;\n }\n\n .range-middle {\n background: #a5d3f3;\n color: white;\n border-radius: 0;\n }\n\n .day.selected {\n background: #a5d3f3;\n color: white;\n border-radius: 4px;\n }\n\n .day.in-range {\n background: #a5d3f3;\n color: white;\n }\n\n .selected-date {\n color: white;\n border-radius: 4px;\n background: #a5d3f3;\n }\n\n .base {\n background-color: white;\n border-radius: 4px;\n width: 365px;\n }\n\n .base__range {\n padding: 24px;\n }\n\n .calender-input {\n margin-top: 6px;\n padding-bottom: 0px;\n width: 365px;\n }\n\n .from {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n margin-top: 12px;\n }\n\n .manual-input {\n width: 100%;\n }\n\n .manual-input-label {\n color: #7f7f7f;\n font-family: Colfax-regular;\n font-size: 12px;\n font-weight: 500;\n line-height: 12px;\n letter-spacing: 0.2px;\n }\n\n .button-contaner {\n width: 100%;\n text-align: right;\n padding: 12px 0 0 0;\n }\n`;\n\nexport default [styles];\n"]}
1
+ {"version":3,"file":"nile-calendar.css.js","sourceRoot":"","sources":["../../../src/nile-calendar/nile-calendar.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiSxB,CAAC;AAEF,eAAe,CAAC,MAAM,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 { css } from 'lit-element';\n\n/**\n * DatePicker CSS\n */\nexport const styles = css`\n :host {\n }\n\n .calendar-container {\n font-family: Colfax-regular;\n width: 365px;\n height: auto;\n text-align: center;\n background: white;\n }\n\n .calendar-container.with-margin {\n margin-right: 20px;\n }\n\n .calendar-header {\n display: flex;\n justify-content: space-between;\n padding: 10px;\n padding: 22px 20px;\n font-size: 14px;\n font-weight: 600;\n line-height: 14px;\n letter-spacing: 0.2px;\n }\n\n .calendar-header__month-navigation {\n cursor: pointer;\n }\n\n .divider {\n width: 100%;\n height: 1px;\n background: #c7ced4;\n }\n\n .day-names {\n font-size: 14px;\n font-weight: 600;\n line-height: 14px;\n letter-spacing: 0.2px;\n height: 50px;\n }\n\n .day-names,\n .days {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n height: auto;\n align-items: center;\n }\n\n .days {\n height: auto;\n }\n\n .day {\n flex-basis: calc(100% / 7);\n box-sizing: border-box;\n width: 48px;\n align-items: center;\n padding: 10px;\n height: 32px;\n margin-top: 6px;\n margin-bottom: 6px;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n }\n\n .current-date {\n border: 1px solid #1978b8;\n }\n\n .day:hover {\n background-color: #e5e9eb;\n }\n\n .filler {\n color: #7f7f7f;\n pointer-events: none;\n }\n\n .selected-date {\n color: white;\n border-radius: 4px;\n background: #a5d3f3;\n }\n\n .selected-date:hover {\n background: #a5d3f3;\n }\n\n .calendar-wrapper {\n background: white;\n display: flex;\n justify-content: space-between;\n width: 365px;\n }\n\n .selected-date,\n .range-start,\n .range-end {\n border-radius: 4px;\n background: #a5d3f3;\n color: white;\n }\n\n .range-start {\n background: #a5d3f3;\n border-radius: 4px 0 0 4px;\n color: white;\n }\n\n .range-end {\n background: #a5d3f3;\n border-radius: 0 4px 4px 0;\n color: white;\n }\n\n .range-middle {\n background: #a5d3f3;\n color: white;\n border-radius: 0;\n }\n\n .day.selected {\n background: #a5d3f3;\n color: white;\n border-radius: 4px;\n }\n\n .day.in-range {\n background: #a5d3f3;\n color: white;\n }\n\n .selected-date {\n color: white;\n border-radius: 4px;\n background: #a5d3f3;\n }\n\n .base {\n background-color: white;\n border-radius: 4px;\n width: 365px;\n }\n\n .base__relative {\n width: 446px;\n }\n\n .base__range {\n padding: 24px;\n }\n\n .calender-input {\n margin-top: 6px;\n padding-bottom: 0px;\n width: 365px;\n }\n\n .calender-input--relative {\n width: 446px;\n }\n\n .from {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n margin-top: 12px;\n }\n\n .manual-input {\n width: 100%;\n }\n\n .manual-input-label {\n color: #7f7f7f;\n font-family: Colfax-regular;\n font-size: 12px;\n font-weight: 500;\n line-height: 12px;\n letter-spacing: 0.2px;\n }\n\n .button-contaner {\n width: 100%;\n text-align: right;\n padding: 24px 0 0 0;\n }\n\n .calendar-config {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 12px;\n }\n\n .calendar-switcher {\n display: flex;\n align-items: flex-start;\n gap: 24px;\n justify-content: space-between;\n border-bottom: 1px solid #e5e9eb;\n }\n\n .calendar-switch {\n padding-bottom: 12px;\n cursor: pointer;\n }\n\n .calendar-switch__active {\n padding-bottom: 12px;\n border-bottom: 4px solid #005ea6;\n }\n\n .unit-container {\n display: flex;\n flex-direction: column;\n width: 446px;\n margin-top: 24px;\n }\n\n .time-unit-group {\n display: flex;\n align-items: center;\n margin-bottom: 24px;\n gap: 24px;\n }\n\n .time-unit-name {\n width: 54px;\n }\n\n .time-unit-name span {\n margin-right: 24px;\n color: var(--color-text-default, #000);\n font-family: Colfax-regular;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 14px;\n letter-spacing: 0.2px;\n }\n\n .time-unit-value {\n display: flex;\n }\n\n .time-value {\n display: inline-flex;\n width: 48px;\n height: 32px;\n box-sizing: border-box;\n padding: 5px;\n border: 1px solid #ddd;\n cursor: pointer;\n justify-content: center;\n align-items: center;\n margin-right: 16px;\n border-radius: 4px;\n border: 1px solid #c7ced4;\n background: rgba(255, 255, 255, 0.2);\n }\n\n .time-value--selected {\n background: #a5d3f3;\n }\n\n .time-value:last-child {\n margin-right: 0;\n }\n\n .time-value:hover {\n background: #e5e9eb;\n }\n\n .time-value--selected:hover {\n background-color: #a5d3f3;\n }\n\n .hidden {\n display: none !important;\n }\n`;\n\nexport default [styles];\n"]}
@@ -33,6 +33,10 @@ export declare class NileCalendar extends NileElement {
33
33
  endDate: Date | null;
34
34
  isSelectingStart: boolean;
35
35
  range: boolean;
36
+ type: string;
37
+ selectedUnit: string;
38
+ selectedValue: number;
39
+ selectedTimeZone: string;
36
40
  valueChanged(): void;
37
41
  updated(changedProperties: PropertyValues): void;
38
42
  static get observedAttributes(): string[];
@@ -45,6 +49,8 @@ export declare class NileCalendar extends NileElement {
45
49
  private prevMonth;
46
50
  private selectDate;
47
51
  private confimRange;
52
+ convertTZ(date: Date, tzString: any): Date;
53
+ isCurrentDate(day: number, month: number, year: number): boolean;
48
54
  private renderMonth;
49
55
  private formatDate;
50
56
  private formatDateRange;
@@ -57,9 +63,18 @@ export declare class NileCalendar extends NileElement {
57
63
  private parseTime;
58
64
  private handleStartTimeInput;
59
65
  private handleEndTimeInput;
66
+ setType(newType: string): void;
67
+ createRelativePeriod(unit: String, value: number): {
68
+ startDate: Date;
69
+ endDate: Date;
70
+ };
71
+ handleTimeValueClick(unit: string, value: number, event: any): void;
72
+ renderTimeValues(unit: string, values: any[]): TemplateResult<1>[];
73
+ handleDurationChange(event: any): void;
74
+ handleUnitChange(event: any): void;
75
+ handleTimeZoneChange(event: any): void;
60
76
  /**
61
77
  * Render method
62
- * @slot This is a slot test
63
78
  */
64
79
  render(): TemplateResult;
65
80
  }
@@ -12,6 +12,7 @@ import { query } from 'lit/decorators.js';
12
12
  import { watch } from '../internal/watch';
13
13
  import NileElement from '../internal/nile-element';
14
14
  import '../nile-popup';
15
+ import { TIMEZONES } from './timezones';
15
16
  /**
16
17
  * Nile icon component.
17
18
  *
@@ -28,8 +29,10 @@ let NileCalendar = class NileCalendar extends NileElement {
28
29
  this.formattedDate = null;
29
30
  this.startDate = null;
30
31
  this.endDate = null;
31
- this.isSelectingStart = true; // flag to indicate what we're selecting
32
+ this.isSelectingStart = true;
32
33
  this.range = false;
34
+ this.type = 'absolute';
35
+ this.selectedTimeZone = 'local';
33
36
  }
34
37
  /**
35
38
  * The styles for NileCalendar
@@ -189,6 +192,10 @@ let NileCalendar = class NileCalendar extends NileElement {
189
192
  }
190
193
  confimRange() {
191
194
  if (this.startDate && this.endDate) {
195
+ if (this.selectedTimeZone !== 'local') {
196
+ this.startDate = this.convertTZ(this.startDate, this.selectedTimeZone);
197
+ this.endDate = this.convertTZ(this.endDate, this.selectedTimeZone);
198
+ }
192
199
  this.emit('nile-changed', {
193
200
  startDate: this.startDate,
194
201
  endDate: this.endDate,
@@ -202,6 +209,15 @@ let NileCalendar = class NileCalendar extends NileElement {
202
209
  };
203
210
  }
204
211
  }
212
+ convertTZ(date, tzString) {
213
+ return new Date((typeof date === 'string' ? new Date(date) : date).toLocaleString('en-US', { timeZone: tzString }));
214
+ }
215
+ isCurrentDate(day, month, year) {
216
+ const today = new Date();
217
+ return (day === today.getDate() &&
218
+ month + 1 === today.getMonth() + 1 &&
219
+ year === today.getFullYear());
220
+ }
205
221
  renderMonth(year, month, daysArray) {
206
222
  const firstDay = new Date(year, month, 1).getDay();
207
223
  const lastDay = new Date(year, month + 1, 0).getDay();
@@ -242,7 +258,12 @@ let NileCalendar = class NileCalendar extends NileElement {
242
258
  return html `
243
259
  <div class="calendar">
244
260
  <div class="calendar-header">
245
- <nile-icon class="calendar-header__month-navigation" name="arrowleft" color="black" @click="${this.prevMonth}">
261
+ <nile-icon
262
+ class="calendar-header__month-navigation"
263
+ name="arrowleft"
264
+ color="black"
265
+ @click="${this.prevMonth}"
266
+ >
246
267
  </nile-icon>
247
268
  <span
248
269
  >${new Date(year, month).toLocaleString('default', {
@@ -250,7 +271,12 @@ let NileCalendar = class NileCalendar extends NileElement {
250
271
  })}
251
272
  ${year}</span
252
273
  >
253
- <nile-icon class="calendar-header__month-navigation" name="arrowright" color="black" @click="${this.nextMonth}">
274
+ <nile-icon
275
+ class="calendar-header__month-navigation"
276
+ name="arrowright"
277
+ color="black"
278
+ @click="${this.nextMonth}"
279
+ >
254
280
  </nile-icon>
255
281
  </div>
256
282
  <div class="day-names">
@@ -269,7 +295,11 @@ let NileCalendar = class NileCalendar extends NileElement {
269
295
  return html ` <div
270
296
  class="day ${isSelectedDate(day, month, year, isCurrentMonth)} ${isInRange(day, month, year, isCurrentMonth)
271
297
  ? 'in-range'
272
- : ''} ${!isCurrentMonth ? 'filler' : ''}"
298
+ : ''} ${!isCurrentMonth ? 'filler' : ''}
299
+ ${this.isCurrentDate(day, month, year) && isCurrentMonth
300
+ ? 'current-date'
301
+ : ''}
302
+ "
273
303
  @click="${() => {
274
304
  if (isCurrentMonth) {
275
305
  this.selectDate(day, month, year);
@@ -386,34 +416,197 @@ let NileCalendar = class NileCalendar extends NileElement {
386
416
  }
387
417
  this.requestUpdate();
388
418
  }
389
- /* #endregion */
390
- /* #region Methods */
419
+ setType(newType) {
420
+ this.type = newType;
421
+ }
422
+ createRelativePeriod(unit, value) {
423
+ const endTime = new Date();
424
+ const startTime = new Date();
425
+ switch (unit) {
426
+ case 'minutes':
427
+ startTime.setMinutes(startTime.getMinutes() - value);
428
+ break;
429
+ case 'hours':
430
+ startTime.setHours(startTime.getHours() - value);
431
+ break;
432
+ case 'days':
433
+ startTime.setDate(startTime.getDate() - value);
434
+ break;
435
+ case 'weeks':
436
+ startTime.setDate(startTime.getDate() - 7 * value); // Subtract weeks as days
437
+ break;
438
+ case 'months':
439
+ startTime.setMonth(startTime.getMonth() - value);
440
+ break;
441
+ }
442
+ this.startDate = new Date(startTime.getTime());
443
+ this.endDate = new Date(endTime.getTime());
444
+ this.requestUpdate();
445
+ return {
446
+ startDate: this.startDate,
447
+ endDate: this.endDate,
448
+ };
449
+ }
450
+ handleTimeValueClick(unit, value, event) {
451
+ const timestamps = this.createRelativePeriod(unit, value);
452
+ this.selectedUnit = unit;
453
+ this.selectedValue = value;
454
+ this.requestUpdate();
455
+ }
456
+ renderTimeValues(unit, values) {
457
+ return values.map(value => html `
458
+ <div
459
+ class="time-value ${this.selectedUnit === unit &&
460
+ this.selectedValue === value
461
+ ? 'time-value--selected'
462
+ : ''}"
463
+ @click=${(e) => this.handleTimeValueClick(unit, value, e)}
464
+ >
465
+ ${value}
466
+ </div>
467
+ `);
468
+ }
469
+ handleDurationChange(event) {
470
+ this.selectedValue = Number(event.detail.value);
471
+ if (this.selectedUnit && this.selectedValue) {
472
+ this.handleTimeValueClick(this.selectedUnit, this.selectedValue, event);
473
+ }
474
+ }
475
+ handleUnitChange(event) {
476
+ this.selectedUnit = event.detail.value;
477
+ if (this.selectedUnit && this.selectedValue) {
478
+ this.handleTimeValueClick(this.selectedUnit, this.selectedValue, event);
479
+ }
480
+ }
481
+ handleTimeZoneChange(event) {
482
+ this.selectedTimeZone = event.detail.value;
483
+ this.requestUpdate();
484
+ }
391
485
  /**
392
486
  * Render method
393
- * @slot This is a slot test
394
487
  */
395
488
  render() {
489
+ const timeZones = TIMEZONES;
396
490
  const daysArray = this.getDaysArray(this.currentYear, this.currentMonth);
397
491
  const nextMonth = (this.currentMonth + 1) % 12;
398
492
  const nextYear = this.currentMonth === 11 ? this.currentYear + 1 : this.currentYear;
399
493
  const nextMonthDaysArray = this.getDaysArray(nextYear, nextMonth);
400
494
  return html `
495
+ <div
496
+ class="base ${this.range ? 'base__range' : ''} ${this.type ===
497
+ 'relative'
498
+ ? 'base__relative'
499
+ : ''}"
500
+ >
501
+ <div class="calendar-config ${!this.range ? 'hidden' : ''}">
502
+ <div class="calendar-switcher">
503
+ <div
504
+ class="calendar-switch${this.type === 'absolute'
505
+ ? '__active'
506
+ : ''}"
507
+ @click="${() => this.setType('absolute')}"
508
+ >
509
+ Absolute
510
+ </div>
511
+ <div
512
+ class="calendar-switch${this.type === 'relative'
513
+ ? '__active'
514
+ : ''}"
515
+ @click="${() => this.setType('relative')}"
516
+ >
517
+ Relative
518
+ </div>
519
+ </div>
401
520
 
402
- <div class="base ${this.range ? 'base__range' : ''}">
403
- <div class="calendar-wrapper" >
404
- <div class="calendar-container ${this.range ? 'with-margin' : ''}">
405
- ${this.renderMonth(this.currentYear, this.currentMonth, this.getDaysArray(this.currentYear, this.currentMonth))}
521
+ <div class="calendar-timezone">
522
+ <nile-select
523
+ searchEnabled
524
+ hoist
525
+ value=${this.selectedTimeZone}
526
+ @nile-change=${this.handleTimeZoneChange}
527
+ >
528
+ <nile-option value="local">Local Time Zone</nile-option>
529
+ ${timeZones.map(timeZone => html `
530
+ <nile-option value="${timeZone}">${timeZone}</nile-option>
531
+ `)}
532
+ </nile-select>
533
+ </div>
534
+ </div>
535
+
536
+ <div
537
+ class="calendar-wrapper ${this.type !== 'absolute' ? 'hidden' : ''}"
538
+ >
539
+ <div class="calendar-container ${this.range ? 'with-margin' : ''}">
540
+ ${this.renderMonth(this.currentYear, this.currentMonth, this.getDaysArray(this.currentYear, this.currentMonth))}
541
+ </div>
542
+ </div>
543
+
544
+ <div class="unit-container ${this.type !== 'relative' ? 'hidden' : ''}">
545
+ <div class="time-unit-group">
546
+ <div class="time-unit-name"><span>Minutes</span></div>
547
+ <div class="time-unit-value">
548
+ ${this.renderTimeValues('minutes', [1, 3, 5, 15, 30, 45])}
406
549
  </div>
407
- <!-- ${this.range
408
- ? html `
409
- <div class="calendar-container">
410
- ${this.renderMonth(this.currentYear, (this.currentMonth + 1) % 12, this.getDaysArray(this.currentYear, (this.currentMonth + 1) % 12))}
411
- </div>
412
- `
413
- : ''} -->
550
+ </div>
414
551
 
552
+ <div class="time-unit-group">
553
+ <div class="time-unit-name"><span>Hours</span></div>
554
+ <div class="time-unit-value">
555
+ ${this.renderTimeValues('hours', [1, 2, 3, 6, 8, 12])}
556
+ </div>
557
+ </div>
558
+
559
+ <div class="time-unit-group">
560
+ <div class="time-unit-name"><span>Days</span></div>
561
+ <div class="time-unit-value">
562
+ ${this.renderTimeValues('days', [1, 2, 3, 4, 5, 6])}
563
+ </div>
415
564
  </div>
416
- ${this.range
565
+
566
+ <div class="time-unit-group">
567
+ <div class="time-unit-name"><span>Weeks</span></div>
568
+ <div class="time-unit-value">
569
+ ${this.renderTimeValues('weeks', [1, 2, 4, 6])}
570
+ </div>
571
+ </div>
572
+
573
+ <div class="time-unit-group">
574
+ <div class="time-unit-name"><span>Months:</span></div>
575
+ <div class="time-unit-value">
576
+ ${this.renderTimeValues('months', [3, 6, 12, 15])}
577
+ </div>
578
+ </div>
579
+ </div>
580
+
581
+ ${this.range && this.type === 'relative'
582
+ ? html `
583
+ <div class="calender-input calender-input--relative">
584
+ <div class="from">
585
+ <nile-input class="manual-input" label="Duration" value="${this.selectedValue}"
586
+ @nile-input="${this.handleDurationChange}"
587
+ placeholder="Enter Value" ></nile-input>
588
+ <nile-select class="manual-input" label="Unit" value="${this.selectedUnit}"
589
+ @nile-change="${this.handleUnitChange}"
590
+ >
591
+ <nile-option value="minutes"> Minutes </nile-option>
592
+ <nile-option value="hours"> Hours </nile-option>
593
+ <nile-option value="days"> Days </nile-option>
594
+ <nile-option value="weeks"> Weeks </nile-option>
595
+ <nile-option value="months"> Months </nile-option>
596
+ </nile-select>
597
+
598
+ </div>
599
+
600
+ <div class="button-contaner">
601
+ <nile-button class="apply-button" ?disabled="${!this.startDate || !this.endDate}" @click="${this.confimRange}"> Apply</nile-button>
602
+ </div>
603
+
604
+
605
+ </div>
606
+ </div>
607
+ `
608
+ : ''}
609
+ ${this.range && this.type === 'absolute'
417
610
  ? html `
418
611
  <div class="calender-input">
419
612
  <span class="manual-input-label">From </span>
@@ -437,7 +630,7 @@ let NileCalendar = class NileCalendar extends NileElement {
437
630
  </div>
438
631
  `
439
632
  : ''}
440
- </div>
633
+ </div>
441
634
  `;
442
635
  }
443
636
  };
@@ -471,6 +664,18 @@ __decorate([
471
664
  __decorate([
472
665
  property({ type: Boolean })
473
666
  ], NileCalendar.prototype, "range", void 0);
667
+ __decorate([
668
+ property({ type: String })
669
+ ], NileCalendar.prototype, "type", void 0);
670
+ __decorate([
671
+ property({ type: String })
672
+ ], NileCalendar.prototype, "selectedUnit", void 0);
673
+ __decorate([
674
+ property({ type: Number })
675
+ ], NileCalendar.prototype, "selectedValue", void 0);
676
+ __decorate([
677
+ property({ type: String })
678
+ ], NileCalendar.prototype, "selectedTimeZone", void 0);
474
679
  __decorate([
475
680
  watch('value')
476
681
  ], NileCalendar.prototype, "valueChanged", null);