@omegagrid/calendar 0.10.105 → 0.10.107

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.
@@ -1,28 +1,38 @@
1
- import { Dropdown, Input, LayoutOptions } from "@omegagrid/core";
1
+ import { Dropdown, Input, LayoutOptions, dates } from "@omegagrid/core";
2
2
  import { Options } from "../options";
3
3
  import { Calendar } from "./calendar";
4
+ import { CalendarTime } from "./timeRow";
4
5
  export declare class CalendarDropdown extends Dropdown {
5
6
  #private;
6
7
  static styles: import("lit").CSSResult[];
7
8
  calendarOptions: Options;
8
9
  buttonInput: boolean;
10
+ /** enables time of day (hours and minutes) selection below the calendar; a day pick then keeps the dropdown open, default `false` */
11
+ withTime: boolean;
9
12
  get value(): Date;
10
13
  set value(value: Date);
11
14
  cross: boolean;
12
15
  caption: string;
13
16
  placeholder: string;
14
17
  input: Input;
18
+ get timeHours(): number;
19
+ get timeMinutes(): number;
15
20
  get hasCrossButton(): boolean;
16
21
  get calendar(): Calendar;
22
+ get timeRow(): CalendarTime;
17
23
  open(initialValue?: string): Promise<void>;
24
+ updated(props: Map<string, unknown>): void;
18
25
  clearValue(dispatchEvent?: boolean): void;
19
26
  _onInputFocus: () => void;
20
27
  parseDate(value: string): Date;
21
28
  isWithinBounds(date: Date): boolean;
29
+ get inputDateText(): string;
22
30
  _onInputBlur: () => void;
23
31
  _onInput: () => void;
24
32
  _onInputKeydown: (e: KeyboardEvent) => void;
25
33
  layout(options?: LayoutOptions): void;
34
+ get dateTimeFormatter(): dates.DateFormatterFunction;
35
+ get formattedValue(): string;
26
36
  getButtonContentHtml(): import("lit-html").TemplateResult<1>;
27
37
  render: () => import("lit-html").TemplateResult<1>;
28
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAsB,MAAM,iBA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,qIAAqI;IAErI,QAAQ,UAAS;IAGjB,IACI,KAAK,IACQ,IAAI,CADa;IAClC,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAMpB;IAGD,KAAK,UAAS;IAGd,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,CAAC;IAGpB,KAAK,EAAE,KAAK,CAAC;IASb,IAAI,SAAS,WAAuE;IACpF,IAAI,WAAW,WAA2E;IAO1F,IAAI,cAAc,YAEjB;IAED,IAAI,QAAQ,aAeX;IAED,IAAI,OAAO,iBAkBV;IAEK,IAAI,CAAC,YAAY,GAAE,MAAa;IAQtC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAQnC,UAAU,CAAC,aAAa,UAAO;IAQ/B,aAAa,aAEZ;IAED,SAAS,CAAC,KAAK,EAAE,MAAM;IAIvB,cAAc,CAAC,IAAI,EAAE,IAAI;IAOzB,IAAI,aAAa,WAEhB;IAED,YAAY,aASX;IAED,QAAQ,aAGP;IAED,eAAe,GAAI,GAAG,aAAa,UAKlC;IAED,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa;IAK9B,IAAI,iBAAiB,gCAEpB;IAED,IAAI,cAAc,WAGjB;IAED,oBAAoB;IAUpB,MAAM,6CAiCJ;CACF"}
@@ -15,27 +15,37 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
15
15
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
16
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
17
  };
18
- var _CalendarDropdown_value, _CalendarDropdown_calendar;
18
+ var _CalendarDropdown_instances, _CalendarDropdown_value, _CalendarDropdown_calendar, _CalendarDropdown_timeRow, _CalendarDropdown_pendingHours, _CalendarDropdown_pendingMinutes, _CalendarDropdown_normalizeTime;
19
19
  import { Dropdown, dates, dom, events } from "@omegagrid/core";
20
20
  import { customElement, property, query } from "lit/decorators.js";
21
21
  import { initOptions } from "../options";
22
22
  import { html } from "lit";
23
+ import { set, startOfDay } from "date-fns";
23
24
  import { style } from "./dropdown.style";
24
25
  let CalendarDropdown = class CalendarDropdown extends Dropdown {
25
26
  constructor() {
26
27
  super(...arguments);
28
+ _CalendarDropdown_instances.add(this);
27
29
  this.calendarOptions = initOptions({
28
30
  controlsPosition: 'bottom'
29
31
  });
30
32
  this.buttonInput = false;
33
+ /** enables time of day (hours and minutes) selection below the calendar; a day pick then keeps the dropdown open, default `false` */
34
+ this.withTime = false;
31
35
  _CalendarDropdown_value.set(this, void 0);
32
36
  this.cross = false;
33
37
  _CalendarDropdown_calendar.set(this, void 0);
38
+ _CalendarDropdown_timeRow.set(this, void 0);
39
+ // time of day selected before any date is picked (merged into the next day pick)
40
+ _CalendarDropdown_pendingHours.set(this, 0);
41
+ _CalendarDropdown_pendingMinutes.set(this, 0);
34
42
  this._onInputFocus = () => {
35
43
  this.open();
36
44
  };
37
45
  this._onInputBlur = () => {
38
- let newDate = this.parseDate(this.input.value);
46
+ let newDate = this.parseDate(this.inputDateText);
47
+ if (newDate != null && this.withTime)
48
+ newDate = set(newDate, { hours: this.timeHours, minutes: this.timeMinutes, seconds: 0, milliseconds: 0 });
39
49
  if (newDate != null && !this.isWithinBounds(newDate))
40
50
  newDate = null;
41
51
  if (newDate == null)
@@ -46,7 +56,7 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
46
56
  }
47
57
  };
48
58
  this._onInput = () => {
49
- const newDate = this.parseDate(this.input.value);
59
+ const newDate = this.parseDate(this.inputDateText);
50
60
  if (newDate && this.isWithinBounds(newDate))
51
61
  __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").date = newDate;
52
62
  };
@@ -64,7 +74,7 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
64
74
  @input="${this._onInput}"
65
75
  @blur="${this._onInputBlur}"
66
76
  placeholder="${this.placeholder || ''}"
67
- .value="${this.calendar?.formattedDate || ''}">
77
+ .value="${this.formattedValue || ''}">
68
78
  </og-input>
69
79
  ` : html `
70
80
  <og-button
@@ -93,12 +103,14 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
93
103
  }
94
104
  get value() { return __classPrivateFieldGet(this, _CalendarDropdown_value, "f"); }
95
105
  set value(value) {
96
- __classPrivateFieldSet(this, _CalendarDropdown_value, value, "f");
106
+ __classPrivateFieldSet(this, _CalendarDropdown_value, __classPrivateFieldGet(this, _CalendarDropdown_instances, "m", _CalendarDropdown_normalizeTime).call(this, value), "f");
97
107
  if (__classPrivateFieldGet(this, _CalendarDropdown_calendar, "f")) {
98
- __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").date = value;
108
+ __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").date = __classPrivateFieldGet(this, _CalendarDropdown_value, "f");
99
109
  this.requestUpdate();
100
110
  }
101
111
  }
112
+ get timeHours() { return __classPrivateFieldGet(this, _CalendarDropdown_value, "f") ? __classPrivateFieldGet(this, _CalendarDropdown_value, "f").getHours() : __classPrivateFieldGet(this, _CalendarDropdown_pendingHours, "f"); }
113
+ get timeMinutes() { return __classPrivateFieldGet(this, _CalendarDropdown_value, "f") ? __classPrivateFieldGet(this, _CalendarDropdown_value, "f").getMinutes() : __classPrivateFieldGet(this, _CalendarDropdown_pendingMinutes, "f"); }
102
114
  get hasCrossButton() {
103
115
  return this.cross && __classPrivateFieldGet(this, _CalendarDropdown_value, "f") != null;
104
116
  }
@@ -110,21 +122,56 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
110
122
  __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").options = this.calendarOptions;
111
123
  __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").slot = 'inner-content';
112
124
  __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").addEventListener('change', (e) => {
113
- __classPrivateFieldSet(this, _CalendarDropdown_value, e.value, "f");
114
- this.close();
115
- this.dispatchEvent(new events.ChangeEvent({ value: e.value }));
125
+ __classPrivateFieldSet(this, _CalendarDropdown_value, this.withTime
126
+ ? set(e.value, { hours: this.timeHours, minutes: this.timeMinutes })
127
+ : e.value, "f");
128
+ if (!this.withTime)
129
+ this.close();
130
+ this.dispatchEvent(new events.ChangeEvent({ value: __classPrivateFieldGet(this, _CalendarDropdown_value, "f") }));
116
131
  this.requestUpdate();
117
132
  });
118
133
  return __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f");
119
134
  }
135
+ get timeRow() {
136
+ if (__classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f"))
137
+ return __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f");
138
+ __classPrivateFieldSet(this, _CalendarDropdown_timeRow, dom.createElement('og-calendar-time'), "f");
139
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").slot = 'inner-content';
140
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").style.flex = '0 0 auto'; // the container stretches slotted children by default
141
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").hours = this.timeHours;
142
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").minutes = this.timeMinutes;
143
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").addEventListener('change', (e) => {
144
+ if (__classPrivateFieldGet(this, _CalendarDropdown_value, "f")) {
145
+ __classPrivateFieldSet(this, _CalendarDropdown_value, set(__classPrivateFieldGet(this, _CalendarDropdown_value, "f"), { ...e.value, seconds: 0, milliseconds: 0 }), "f");
146
+ this.dispatchEvent(new events.ChangeEvent({ value: __classPrivateFieldGet(this, _CalendarDropdown_value, "f") }));
147
+ this.requestUpdate();
148
+ }
149
+ else {
150
+ __classPrivateFieldSet(this, _CalendarDropdown_pendingHours, e.value.hours, "f");
151
+ __classPrivateFieldSet(this, _CalendarDropdown_pendingMinutes, e.value.minutes, "f");
152
+ }
153
+ });
154
+ return __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f");
155
+ }
120
156
  async open(initialValue = null) {
121
157
  if (initialValue != null)
122
158
  this.input.value = initialValue;
123
159
  if (this.calendar.parentElement != this.dropdown)
124
160
  this.dropdown.appendChild(this.calendar);
161
+ if (this.withTime && this.timeRow.parentElement != this.dropdown)
162
+ this.dropdown.appendChild(this.timeRow);
125
163
  await super.open();
126
164
  }
165
+ updated(props) {
166
+ super.updated(props);
167
+ if (this.withTime && __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f")) {
168
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").hours = this.timeHours;
169
+ __classPrivateFieldGet(this, _CalendarDropdown_timeRow, "f").minutes = this.timeMinutes;
170
+ }
171
+ }
127
172
  clearValue(dispatchEvent = true) {
173
+ __classPrivateFieldSet(this, _CalendarDropdown_pendingHours, 0, "f");
174
+ __classPrivateFieldSet(this, _CalendarDropdown_pendingMinutes, 0, "f");
128
175
  this.value = null;
129
176
  this.close();
130
177
  if (dispatchEvent)
@@ -135,16 +182,30 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
135
182
  }
136
183
  isWithinBounds(date) {
137
184
  const { minDate, maxDate } = this.calendarOptions;
185
+ if (this.withTime)
186
+ date = startOfDay(date); // bounds are day-granular
138
187
  return (!minDate || date >= minDate) && (!maxDate || date <= maxDate);
139
188
  }
189
+ // with time enabled only the first token is the date, the typed time is ignored (the spinners own the time)
190
+ get inputDateText() {
191
+ return this.withTime ? this.input.value.trim().split(/\s+/)[0] ?? '' : this.input.value;
192
+ }
140
193
  layout(options) {
141
194
  super.layout(options);
142
195
  __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f")?.layout();
143
196
  }
197
+ get dateTimeFormatter() {
198
+ return dates.getDateFormatter(this.calendarOptions.locale, this.calendarOptions.dateFormat + ' HH:mm');
199
+ }
200
+ get formattedValue() {
201
+ if (!this.withTime)
202
+ return this.calendar?.formattedDate;
203
+ return __classPrivateFieldGet(this, _CalendarDropdown_value, "f") ? this.dateTimeFormatter(__classPrivateFieldGet(this, _CalendarDropdown_value, "f")) : '';
204
+ }
144
205
  getButtonContentHtml() {
145
206
  const caption = this.caption ? html `<div class="caption">${this.caption}</div>` : null;
146
207
  const placeholder = this.placeholder ? html `<div class="placeholder">${this.placeholder}</div>` : null;
147
- const formattedDate = this.calendar?.formattedDate;
208
+ const formattedDate = this.formattedValue;
148
209
  return formattedDate ? html `${caption ? html `${caption}:` : ``}<div class="itm">${formattedDate}</div>` : (caption
149
210
  ? html `${caption}${placeholder ? html `:&nbsp;${placeholder}` : ``}`
150
211
  : (placeholder ? html `${placeholder}` : html `&nbsp;`));
@@ -152,6 +213,15 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
152
213
  };
153
214
  _CalendarDropdown_value = new WeakMap();
154
215
  _CalendarDropdown_calendar = new WeakMap();
216
+ _CalendarDropdown_timeRow = new WeakMap();
217
+ _CalendarDropdown_pendingHours = new WeakMap();
218
+ _CalendarDropdown_pendingMinutes = new WeakMap();
219
+ _CalendarDropdown_instances = new WeakSet();
220
+ _CalendarDropdown_normalizeTime = function _CalendarDropdown_normalizeTime(value) {
221
+ if (value == null || !this.withTime)
222
+ return value;
223
+ return set(value, { seconds: 0, milliseconds: 0 });
224
+ };
155
225
  CalendarDropdown.styles = [...Dropdown.styles, style];
156
226
  __decorate([
157
227
  property({ type: Object })
@@ -159,6 +229,9 @@ __decorate([
159
229
  __decorate([
160
230
  property({ type: Boolean })
161
231
  ], CalendarDropdown.prototype, "buttonInput", void 0);
232
+ __decorate([
233
+ property({ type: Boolean })
234
+ ], CalendarDropdown.prototype, "withTime", void 0);
162
235
  __decorate([
163
236
  property({ type: Object, noAccessor: true })
164
237
  ], CalendarDropdown.prototype, "value", null);
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAwB,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;A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;QACnD,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,CAAA,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,oBAAoB,aAAa,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO;YACjH,CAAC,CAAC,IAAI,CAAA,GAAG,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA,UAAU,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YACnE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA,QAAQ,CAAC,CACrD,CAAC;IACH,CAAC;;;;AAnHM,uBAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,AAA9B,CAA+B;AAG5C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yDAGtB;AAGH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;qDACN;AAIpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;6CACT;AAUlC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;+CAC3B;AAGd;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACT;AAGhB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;qDACL;AAGpB;IADC,KAAK,CAAC,UAAU,CAAC;+CACL;AAjCD,gBAAgB;IAD5B,aAAa,CAAC,sBAAsB,CAAC;GACzB,gBAAgB,CAyJ5B","sourcesContent":["import { Dropdown, Input, LayoutOptions, dates, dom, events } from \"@omegagrid/core\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { initOptions, Options } from \"../options\";\nimport { html } from \"lit\";\nimport { style } from \"./dropdown.style\";\nimport { Calendar } from \"./calendar\";\n\n@customElement('og-calendar-dropdown')\nexport class CalendarDropdown extends Dropdown {\n\n\tstatic styles = [...Dropdown.styles, style];\n\n\t@property({type: Object})\n\tcalendarOptions: Options = initOptions({\n\t\tcontrolsPosition: 'bottom'\n\t});\n\n\t@property({type: Boolean})\n\tbuttonInput = false;\n\n\t#value: Date;\n\t@property({type: Object, noAccessor: true})\n\tget value() { return this.#value }\n\tset value(value: Date) {\n\t\tthis.#value = value;\n\t\tif (this.#calendar) {\n\t\t\tthis.#calendar.date = value;\n\t\t\tthis.requestUpdate();\n\t\t}\n\t}\n\n\t@property({type: Boolean, reflect: true})\n\tcross = false;\n\n\t@property({type: String})\n\tcaption: string;\n\n\t@property({type: String})\n\tplaceholder: string;\n\n\t@query('og-input')\n\tinput: Input;\n\n\t#calendar: Calendar;\t\n\n\tget hasCrossButton() {\n\t\treturn this.cross && this.#value != null;\n\t}\n\n\tget calendar() {\n\t\tif (this.#calendar) return this.#calendar;\n\t\tthis.#calendar = dom.createElement<Calendar>('og-calendar');\n\t\tthis.#calendar.date = this.#value;\n\t\tthis.#calendar.options = this.calendarOptions;\n\t\tthis.#calendar.slot = 'inner-content';\n\t\tthis.#calendar.addEventListener('change', (e: events.ChangeEvent<Date>) => {\n\t\t\tthis.#value = e.value;\n\t\t\tthis.close();\n\t\t\tthis.dispatchEvent(new events.ChangeEvent({value: e.value}));\n\t\t\tthis.requestUpdate();\n\t\t});\n\t\treturn this.#calendar;\n\t}\n\n\tasync open(initialValue: string = null) {\n\t\tif (initialValue != null) this.input.value = initialValue;\n\n\t\tif (this.calendar.parentElement != this.dropdown) this.dropdown.appendChild(this.calendar);\n\t\tawait super.open();\n\t}\n\n\tclearValue(dispatchEvent = true) {\n\t\tthis.value = null;\n\t\tthis.close();\n\t\tif (dispatchEvent) this.dispatchEvent(new events.ChangeEvent({value: null}));\n\t}\n\n\t_onInputFocus = () => {\n\t\tthis.open();\n\t}\n\n\tparseDate(value: string) {\n\t\treturn dates.parse(value, this.calendarOptions.locale);\n\t}\n\n\tisWithinBounds(date: Date) {\n\t\tconst { minDate, maxDate } = this.calendarOptions;\n\t\treturn (!minDate || date >= minDate) && (!maxDate || date <= maxDate);\n\t}\n\n\t_onInputBlur = () => {\n\t\tlet newDate = this.parseDate(this.input.value);\n\t\tif (newDate != null && !this.isWithinBounds(newDate)) newDate = null;\n\t\tif (newDate == null) this.input.value = '';\n\t\tif (newDate?.getTime() !== this.#value?.getTime()) {\n\t\t\tthis.#value = newDate;\n\t\t\tthis.dispatchEvent(new events.ChangeEvent({value: this.value}));\n\t\t}\n\t}\n\n\t_onInput = () => {\n\t\tconst newDate = this.parseDate(this.input.value);\n\t\tif (newDate && this.isWithinBounds(newDate)) this.#calendar.date = newDate;\n\t}\n\n\t_onInputKeydown = (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\tthis.input.blur();\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tlayout(options?: LayoutOptions) {\n\t\tsuper.layout(options);\n\t\tthis.#calendar?.layout();\n\t}\n\n\tgetButtonContentHtml() {\n\t\tconst caption = this.caption ? html`<div class=\"caption\">${this.caption}</div>` : null;\n\t\tconst placeholder = this.placeholder ? html`<div class=\"placeholder\">${this.placeholder}</div>` : null;\n\t\tconst formattedDate = this.calendar?.formattedDate;\n\t\treturn formattedDate ? html`${caption ? html`${caption}:` : ``}<div class=\"itm\">${formattedDate}</div>` : (caption\n\t\t\t? html`${caption}${placeholder ? html`:&nbsp;${placeholder}` : ``}`\n\t\t\t: (placeholder ? html`${placeholder}` : html`&nbsp;`)\n\t\t);\n\t}\n\n\trender = () => html`\n\t\t${this.buttonInput ? html`\n\t\t\t<og-input\n\t\t\t\t@keydown=\"${this._onInputKeydown}\"\n\t\t\t\t@focus=\"${this._onInputFocus}\"\n\t\t\t\t@input=\"${this._onInput}\"\n\t\t\t\t@blur=\"${this._onInputBlur}\"\n\t\t\t\tplaceholder=\"${this.placeholder || ''}\"\n\t\t\t\t.value=\"${this.calendar?.formattedDate || ''}\">\n\t\t\t</og-input>\n\t\t` : html`\n\t\t\t<og-button\n\t\t\t\t.caret=\"${this.noCaret ? 'none' : 'down'}\"\n\t\t\t\tcolor=\"${this.color}\"\n\t\t\t\tclass=\"main\"\n\t\t\t\tstyle=\"flex: 1; text-align: center;\" \n\t\t\t\t@mousedown=\"${this._onMousedown}\">\n\t\t\t\t<div class=\"content\" slot=\"content\">\n\t\t\t\t\t${this.getButtonContentHtml()}\n\t\t\t\t</div>\n\t\t\t</og-button>\n\t\t`}\n\n\t\t${this.hasCrossButton ? html`\n\t\t\t<og-button\n\t\t\t\tclass=\"cross\"\n\t\t\t\t@mousedown=\"${() => this.clearValue(true)}\"\n\t\t\t\ticon=\"xmark\"\n\t\t\t\tcolor=\"red\">\n\t\t\t</og-button>\n\t\t` : ``}\n\n\t\t${this.renderDropdown()}\n\t`;\n}\n"]}
1
+ {"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAwB,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAW,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKlC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,QAAQ;IAAvC;;;QAKN,oBAAe,GAAY,WAAW,CAAC;YACtC,gBAAgB,EAAE,QAAQ;SAC1B,CAAC,CAAC;QAGH,gBAAW,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;AAClD,CAAC;AAlDM,uBAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,AAA9B,CAA+B;AAG5C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yDAGtB;AAGH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;qDACN;AAIpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;kDACT;AAIjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;6CACT;AAUlC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;+CAC3B;AAGd;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACT;AAGhB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;qDACL;AAGpB;IADC,KAAK,CAAC,UAAU,CAAC;+CACL;AArCD,gBAAgB;IAD5B,aAAa,CAAC,sBAAsB,CAAC;GACzB,gBAAgB,CA2N5B","sourcesContent":["import { Dropdown, Input, LayoutOptions, dates, dom, events } from \"@omegagrid/core\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { initOptions, Options } from \"../options\";\nimport { html } from \"lit\";\nimport { set, startOfDay } from \"date-fns\";\nimport { style } from \"./dropdown.style\";\nimport { Calendar } from \"./calendar\";\nimport { CalendarTime } from \"./timeRow\";\n\n@customElement('og-calendar-dropdown')\nexport class CalendarDropdown extends Dropdown {\n\n\tstatic styles = [...Dropdown.styles, style];\n\n\t@property({type: Object})\n\tcalendarOptions: Options = initOptions({\n\t\tcontrolsPosition: 'bottom'\n\t});\n\n\t@property({type: Boolean})\n\tbuttonInput = false;\n\n\t/** enables time of day (hours and minutes) selection below the calendar; a day pick then keeps the dropdown open, default `false` */\n\t@property({type: Boolean})\n\twithTime = false;\n\n\t#value: Date;\n\t@property({type: Object, noAccessor: true})\n\tget value() { return this.#value }\n\tset value(value: Date) {\n\t\tthis.#value = this.#normalizeTime(value);\n\t\tif (this.#calendar) {\n\t\t\tthis.#calendar.date = this.#value;\n\t\t\tthis.requestUpdate();\n\t\t}\n\t}\n\n\t@property({type: Boolean, reflect: true})\n\tcross = false;\n\n\t@property({type: String})\n\tcaption: string;\n\n\t@property({type: String})\n\tplaceholder: string;\n\n\t@query('og-input')\n\tinput: Input;\n\n\t#calendar: Calendar;\n\t#timeRow: CalendarTime;\n\n\t// time of day selected before any date is picked (merged into the next day pick)\n\t#pendingHours = 0;\n\t#pendingMinutes = 0;\n\n\tget timeHours() { return this.#value ? this.#value.getHours() : this.#pendingHours }\n\tget timeMinutes() { return this.#value ? this.#value.getMinutes() : this.#pendingMinutes }\n\n\t#normalizeTime(value: Date) {\n\t\tif (value == null || !this.withTime) return value;\n\t\treturn set(value, {seconds: 0, milliseconds: 0});\n\t}\n\n\tget hasCrossButton() {\n\t\treturn this.cross && this.#value != null;\n\t}\n\n\tget calendar() {\n\t\tif (this.#calendar) return this.#calendar;\n\t\tthis.#calendar = dom.createElement<Calendar>('og-calendar');\n\t\tthis.#calendar.date = this.#value;\n\t\tthis.#calendar.options = this.calendarOptions;\n\t\tthis.#calendar.slot = 'inner-content';\n\t\tthis.#calendar.addEventListener('change', (e: events.ChangeEvent<Date>) => {\n\t\t\tthis.#value = this.withTime\n\t\t\t\t? set(e.value, {hours: this.timeHours, minutes: this.timeMinutes})\n\t\t\t\t: e.value;\n\t\t\tif (!this.withTime) this.close();\n\t\t\tthis.dispatchEvent(new events.ChangeEvent({value: this.#value}));\n\t\t\tthis.requestUpdate();\n\t\t});\n\t\treturn this.#calendar;\n\t}\n\n\tget timeRow() {\n\t\tif (this.#timeRow) return this.#timeRow;\n\t\tthis.#timeRow = dom.createElement<CalendarTime>('og-calendar-time');\n\t\tthis.#timeRow.slot = 'inner-content';\n\t\tthis.#timeRow.style.flex = '0 0 auto'; // the container stretches slotted children by default\n\t\tthis.#timeRow.hours = this.timeHours;\n\t\tthis.#timeRow.minutes = this.timeMinutes;\n\t\tthis.#timeRow.addEventListener('change', (e: events.ChangeEvent<{hours: number, minutes: number}>) => {\n\t\t\tif (this.#value) {\n\t\t\t\tthis.#value = set(this.#value, {...e.value, seconds: 0, milliseconds: 0});\n\t\t\t\tthis.dispatchEvent(new events.ChangeEvent({value: this.#value}));\n\t\t\t\tthis.requestUpdate();\n\t\t\t} else {\n\t\t\t\tthis.#pendingHours = e.value.hours;\n\t\t\t\tthis.#pendingMinutes = e.value.minutes;\n\t\t\t}\n\t\t});\n\t\treturn this.#timeRow;\n\t}\n\n\tasync open(initialValue: string = null) {\n\t\tif (initialValue != null) this.input.value = initialValue;\n\n\t\tif (this.calendar.parentElement != this.dropdown) this.dropdown.appendChild(this.calendar);\n\t\tif (this.withTime && this.timeRow.parentElement != this.dropdown) this.dropdown.appendChild(this.timeRow);\n\t\tawait super.open();\n\t}\n\n\tupdated(props: Map<string, unknown>) {\n\t\tsuper.updated(props);\n\t\tif (this.withTime && this.#timeRow) {\n\t\t\tthis.#timeRow.hours = this.timeHours;\n\t\t\tthis.#timeRow.minutes = this.timeMinutes;\n\t\t}\n\t}\n\n\tclearValue(dispatchEvent = true) {\n\t\tthis.#pendingHours = 0;\n\t\tthis.#pendingMinutes = 0;\n\t\tthis.value = null;\n\t\tthis.close();\n\t\tif (dispatchEvent) this.dispatchEvent(new events.ChangeEvent({value: null}));\n\t}\n\n\t_onInputFocus = () => {\n\t\tthis.open();\n\t}\n\n\tparseDate(value: string) {\n\t\treturn dates.parse(value, this.calendarOptions.locale);\n\t}\n\n\tisWithinBounds(date: Date) {\n\t\tconst { minDate, maxDate } = this.calendarOptions;\n\t\tif (this.withTime) date = startOfDay(date); // bounds are day-granular\n\t\treturn (!minDate || date >= minDate) && (!maxDate || date <= maxDate);\n\t}\n\n\t// with time enabled only the first token is the date, the typed time is ignored (the spinners own the time)\n\tget inputDateText() {\n\t\treturn this.withTime ? this.input.value.trim().split(/\\s+/)[0] ?? '' : this.input.value;\n\t}\n\n\t_onInputBlur = () => {\n\t\tlet newDate = this.parseDate(this.inputDateText);\n\t\tif (newDate != null && this.withTime) newDate = set(newDate, {hours: this.timeHours, minutes: this.timeMinutes, seconds: 0, milliseconds: 0});\n\t\tif (newDate != null && !this.isWithinBounds(newDate)) newDate = null;\n\t\tif (newDate == null) this.input.value = '';\n\t\tif (newDate?.getTime() !== this.#value?.getTime()) {\n\t\t\tthis.#value = newDate;\n\t\t\tthis.dispatchEvent(new events.ChangeEvent({value: this.value}));\n\t\t}\n\t}\n\n\t_onInput = () => {\n\t\tconst newDate = this.parseDate(this.inputDateText);\n\t\tif (newDate && this.isWithinBounds(newDate)) this.#calendar.date = newDate;\n\t}\n\n\t_onInputKeydown = (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\tthis.input.blur();\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tlayout(options?: LayoutOptions) {\n\t\tsuper.layout(options);\n\t\tthis.#calendar?.layout();\n\t}\n\n\tget dateTimeFormatter() {\n\t\treturn dates.getDateFormatter(this.calendarOptions.locale, this.calendarOptions.dateFormat + ' HH:mm');\n\t}\n\n\tget formattedValue() {\n\t\tif (!this.withTime) return this.calendar?.formattedDate;\n\t\treturn this.#value ? this.dateTimeFormatter(this.#value) : '';\n\t}\n\n\tgetButtonContentHtml() {\n\t\tconst caption = this.caption ? html`<div class=\"caption\">${this.caption}</div>` : null;\n\t\tconst placeholder = this.placeholder ? html`<div class=\"placeholder\">${this.placeholder}</div>` : null;\n\t\tconst formattedDate = this.formattedValue;\n\t\treturn formattedDate ? html`${caption ? html`${caption}:` : ``}<div class=\"itm\">${formattedDate}</div>` : (caption\n\t\t\t? html`${caption}${placeholder ? html`:&nbsp;${placeholder}` : ``}`\n\t\t\t: (placeholder ? html`${placeholder}` : html`&nbsp;`)\n\t\t);\n\t}\n\n\trender = () => html`\n\t\t${this.buttonInput ? html`\n\t\t\t<og-input\n\t\t\t\t@keydown=\"${this._onInputKeydown}\"\n\t\t\t\t@focus=\"${this._onInputFocus}\"\n\t\t\t\t@input=\"${this._onInput}\"\n\t\t\t\t@blur=\"${this._onInputBlur}\"\n\t\t\t\tplaceholder=\"${this.placeholder || ''}\"\n\t\t\t\t.value=\"${this.formattedValue || ''}\">\n\t\t\t</og-input>\n\t\t` : html`\n\t\t\t<og-button\n\t\t\t\t.caret=\"${this.noCaret ? 'none' : 'down'}\"\n\t\t\t\tcolor=\"${this.color}\"\n\t\t\t\tclass=\"main\"\n\t\t\t\tstyle=\"flex: 1; text-align: center;\" \n\t\t\t\t@mousedown=\"${this._onMousedown}\">\n\t\t\t\t<div class=\"content\" slot=\"content\">\n\t\t\t\t\t${this.getButtonContentHtml()}\n\t\t\t\t</div>\n\t\t\t</og-button>\n\t\t`}\n\n\t\t${this.hasCrossButton ? html`\n\t\t\t<og-button\n\t\t\t\tclass=\"cross\"\n\t\t\t\t@mousedown=\"${() => this.clearValue(true)}\"\n\t\t\t\ticon=\"xmark\"\n\t\t\t\tcolor=\"red\">\n\t\t\t</og-button>\n\t\t` : ``}\n\n\t\t${this.renderDropdown()}\n\t`;\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  export * from './calendar';
2
2
  export * from './dropdown';
3
+ export * from './timeRow';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
package/dist/ui/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './calendar';
2
2
  export * from './dropdown';
3
+ export * from './timeRow';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC","sourcesContent":["export * from './calendar';\nexport * from './dropdown';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["export * from './calendar';\nexport * from './dropdown';\nexport * from './timeRow';\n"]}
@@ -0,0 +1,13 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Time of day (hours and minutes) selection row, used by the calendar dropdown when time selection is enabled.
4
+ * Dispatches a `change` event with `{hours, minutes}` value.
5
+ */
6
+ export declare class CalendarTime extends LitElement {
7
+ #private;
8
+ static styles: import("lit").CSSResult[];
9
+ hours: number;
10
+ minutes: number;
11
+ render: () => import("lit-html").TemplateResult<1>;
12
+ }
13
+ //# sourceMappingURL=timeRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeRow.d.ts","sourceRoot":"","sources":["../../src/ui/timeRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAMvC;;;GAGG;AACH,qBACa,YAAa,SAAQ,UAAU;;IAE3C,MAAM,CAAC,MAAM,4BAAW;IAGxB,KAAK,SAAK;IAGV,OAAO,SAAK;IAWZ,MAAM,6CAqBJ;CACF"}
@@ -0,0 +1,73 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _CalendarTime_onChange;
13
+ import { LitElement, html } from 'lit';
14
+ import { customElement, property } from 'lit/decorators.js';
15
+ import { events } from '@omegagrid/core';
16
+ import { msg } from '@omegagrid/localize';
17
+ import { style } from './timeRow.style';
18
+ /**
19
+ * Time of day (hours and minutes) selection row, used by the calendar dropdown when time selection is enabled.
20
+ * Dispatches a `change` event with `{hours, minutes}` value.
21
+ */
22
+ let CalendarTime = class CalendarTime extends LitElement {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.hours = 0;
26
+ this.minutes = 0;
27
+ _CalendarTime_onChange.set(this, (e) => {
28
+ const target = e.target;
29
+ const value = target.value ?? 0;
30
+ if (target.classList.contains('hours'))
31
+ this.hours = value;
32
+ else
33
+ this.minutes = value;
34
+ this.requestUpdate(); // renders a cleared input back to '00'
35
+ this.dispatchEvent(new events.ChangeEvent({ value: { hours: this.hours, minutes: this.minutes } }));
36
+ });
37
+ this.render = () => html `
38
+ <div class="label">${msg('time')}</div>
39
+ <og-numericinput
40
+ class="hours"
41
+ buttons
42
+ format="00"
43
+ .value="${this.hours}"
44
+ min="0"
45
+ max="23"
46
+ @change="${__classPrivateFieldGet(this, _CalendarTime_onChange, "f")}">
47
+ </og-numericinput>
48
+ <div class="separator">:</div>
49
+ <og-numericinput
50
+ class="minutes"
51
+ buttons
52
+ format="00"
53
+ .value="${this.minutes}"
54
+ min="0"
55
+ max="59"
56
+ @change="${__classPrivateFieldGet(this, _CalendarTime_onChange, "f")}">
57
+ </og-numericinput>
58
+ `;
59
+ }
60
+ };
61
+ _CalendarTime_onChange = new WeakMap();
62
+ CalendarTime.styles = [style];
63
+ __decorate([
64
+ property({ type: Number })
65
+ ], CalendarTime.prototype, "hours", void 0);
66
+ __decorate([
67
+ property({ type: Number })
68
+ ], CalendarTime.prototype, "minutes", void 0);
69
+ CalendarTime = __decorate([
70
+ customElement('og-calendar-time')
71
+ ], CalendarTime);
72
+ export { CalendarTime };
73
+ //# sourceMappingURL=timeRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeRow.js","sourceRoot":"","sources":["../../src/ui/timeRow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAgB,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;GAGG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAKN,UAAK,GAAG,CAAC,CAAC;QAGV,YAAO,GAAG,CAAC,CAAC;QAEZ,iCAAY,CAAC,CAAQ,EAAE,EAAE;YACxB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAsB,CAAC;YACxC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;YAChC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;gBACtD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YAC1B,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,uCAAuC;YAC7D,IAAI,CAAC,aAAa,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAC,EAAC,CAAC,CAAC,CAAC;QACjG,CAAC,EAAA;QAED,WAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;uBACG,GAAG,CAAC,MAAM,CAAC;;;;;aAKrB,IAAI,CAAC,KAAK;;;cAGT,uBAAA,IAAI,8BAAU;;;;;;;aAOf,IAAI,CAAC,OAAO;;;cAGX,uBAAA,IAAI,8BAAU;;EAE1B,CAAC;IACH,CAAC;;;AAvCO,mBAAM,GAAG,CAAC,KAAK,CAAC,AAAV,CAAW;AAGxB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACf;AAGV;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACb;AARA,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CAyCxB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { NumericInput, events } from '@omegagrid/core';\nimport { msg } from '@omegagrid/localize';\nimport { style } from './timeRow.style';\n\n/**\n * Time of day (hours and minutes) selection row, used by the calendar dropdown when time selection is enabled.\n * Dispatches a `change` event with `{hours, minutes}` value.\n */\n@customElement('og-calendar-time')\nexport class CalendarTime extends LitElement {\n\n\tstatic styles = [style];\n\n\t@property({type: Number})\n\thours = 0;\n\n\t@property({type: Number})\n\tminutes = 0;\n\n\t#onChange = (e: Event) => {\n\t\tconst target = e.target as NumericInput;\n\t\tconst value = target.value ?? 0;\n\t\tif (target.classList.contains('hours')) this.hours = value;\n\t\telse this.minutes = value;\n\t\tthis.requestUpdate(); // renders a cleared input back to '00'\n\t\tthis.dispatchEvent(new events.ChangeEvent({value: {hours: this.hours, minutes: this.minutes}}));\n\t}\n\n\trender = () => html`\n\t\t<div class=\"label\">${msg('time')}</div>\n\t\t<og-numericinput\n\t\t\tclass=\"hours\"\n\t\t\tbuttons\n\t\t\tformat=\"00\"\n\t\t\t.value=\"${this.hours}\"\n\t\t\tmin=\"0\"\n\t\t\tmax=\"23\"\n\t\t\t@change=\"${this.#onChange}\">\n\t\t</og-numericinput>\n\t\t<div class=\"separator\">:</div>\n\t\t<og-numericinput\n\t\t\tclass=\"minutes\"\n\t\t\tbuttons\n\t\t\tformat=\"00\"\n\t\t\t.value=\"${this.minutes}\"\n\t\t\tmin=\"0\"\n\t\t\tmax=\"59\"\n\t\t\t@change=\"${this.#onChange}\">\n\t\t</og-numericinput>\n\t`;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const style: import("lit").CSSResult;
2
+ //# sourceMappingURL=timeRow.style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeRow.style.d.ts","sourceRoot":"","sources":["../../src/ui/timeRow.style.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,yBAmCjB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { css } from 'lit';
2
+ import constants from '../constants';
3
+ export const style = css `
4
+ * {
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ :host {
9
+ display: flex;
10
+ flex: 0 0 auto;
11
+ flex-direction: row;
12
+ align-items: center;
13
+ box-sizing: border-box;
14
+ height: ${constants.HEADER_HEIGHT + 4}px;
15
+ border-top: 1px solid var(--og-border-color);
16
+ font-family: var(--og-font-family);
17
+ font-size: var(--og-font-size);
18
+ color: var(--og-text-color);
19
+ padding: 2px 5px;
20
+ background-color: var(--og-background-color);
21
+ }
22
+
23
+ .label {
24
+ flex: 1;
25
+ text-align: right;
26
+ color: var(--og-text-color-2);
27
+ padding-right: 5px;
28
+ }
29
+
30
+ .separator {
31
+ padding: 0 2px;
32
+ }
33
+
34
+ og-numericinput {
35
+ width: 58px;
36
+ height: 100%;
37
+ }
38
+ `;
39
+ //# sourceMappingURL=timeRow.style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeRow.style.js","sourceRoot":"","sources":["../../src/ui/timeRow.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;YAWZ,SAAS,CAAC,aAAa,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;CAwBtC,CAAC","sourcesContent":["import { css } from 'lit';\nimport constants from '../constants';\n\nexport const style = css`\n\t* {\n\t\tbox-sizing: border-box;\n\t}\n\n\t:host {\n\t\tdisplay: flex;\n\t\tflex: 0 0 auto;\n\t\tflex-direction: row;\n\t\talign-items: center;\n\t\tbox-sizing: border-box;\n\t\theight: ${constants.HEADER_HEIGHT + 4}px;\n\t\tborder-top: 1px solid var(--og-border-color);\n\t\tfont-family: var(--og-font-family);\n\t\tfont-size: var(--og-font-size);\n\t\tcolor: var(--og-text-color);\n\t\tpadding: 2px 5px;\n\t\tbackground-color: var(--og-background-color);\n\t}\n\n\t.label {\n\t\tflex: 1;\n\t\ttext-align: right;\n\t\tcolor: var(--og-text-color-2);\n\t\tpadding-right: 5px;\n\t}\n\n\t.separator {\n\t\tpadding: 0 2px;\n\t}\n\n\tog-numericinput {\n\t\twidth: 58px;\n\t\theight: 100%;\n\t}\n`;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/calendar",
3
- "version": "0.10.105",
3
+ "version": "0.10.107",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Calendar component",
6
6
  "main": "./dist/index.js",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@fortawesome/fontawesome-svg-core": "^7.0.1",
31
- "@omegagrid/core": "^0.10.105",
32
- "@omegagrid/grid": "^0.10.105",
33
- "@omegagrid/grid-core": "^0.10.105",
34
- "@omegagrid/localize": "^0.10.105",
31
+ "@omegagrid/core": "^0.10.107",
32
+ "@omegagrid/grid": "^0.10.107",
33
+ "@omegagrid/grid-core": "^0.10.107",
34
+ "@omegagrid/localize": "^0.10.107",
35
35
  "date-fns": "^3.2.0",
36
36
  "lit": "^3.1.1",
37
37
  "ts-debounce": "^4.0.0"