@omegagrid/calendar 0.10.47 → 0.10.49

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/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './ui';
2
+ export * from './options';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './ui';
2
+ export * from './options';
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC","sourcesContent":["export * from './ui';"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC","sourcesContent":["export * from './ui';\nexport * from './options';"]}
@@ -16,6 +16,7 @@ export declare class CalendarDropdown extends Dropdown {
16
16
  clearValue(dispatchEvent?: boolean): void;
17
17
  _onInputFocus: () => void;
18
18
  parseDate(value: string): Date;
19
+ isWithinBounds(date: Date): boolean;
19
20
  _onInputBlur: () => void;
20
21
  _onInput: () => void;
21
22
  _onInputKeydown: (e: KeyboardEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAsB,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAe,OAAO,EAAE,MAAM,YAAY,CAAC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CAAC,KAAK,EAAE,MAAM;IAIvB,cAAc,CAAC,IAAI,EAAE,IAAI;IAKzB,YAAY,aAQX;IAED,QAAQ,aAGP;IAED,eAAe,GAAI,GAAG,aAAa,UAKlC;IAED,MAAM;IAKN,MAAM,6CAgCJ;CACF"}
@@ -36,7 +36,9 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
36
36
  this.open();
37
37
  };
38
38
  this._onInputBlur = () => {
39
- const newDate = this.parseDate(this.input.value);
39
+ let newDate = this.parseDate(this.input.value);
40
+ if (newDate != null && !this.isWithinBounds(newDate))
41
+ newDate = null;
40
42
  if (newDate == null)
41
43
  this.input.value = '';
42
44
  if (newDate?.getTime() !== __classPrivateFieldGet(this, _CalendarDropdown_value, "f")?.getTime()) {
@@ -46,7 +48,7 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
46
48
  };
47
49
  this._onInput = () => {
48
50
  const newDate = this.parseDate(this.input.value);
49
- if (newDate)
51
+ if (newDate && this.isWithinBounds(newDate))
50
52
  __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").date = newDate;
51
53
  };
52
54
  this._onInputKeydown = (e) => {
@@ -132,6 +134,10 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
132
134
  parseDate(value) {
133
135
  return dates.parse(value, this.calendarOptions.locale);
134
136
  }
137
+ isWithinBounds(date) {
138
+ const { minDate, maxDate } = this.calendarOptions;
139
+ return (!minDate || date >= minDate) && (!maxDate || date <= maxDate);
140
+ }
135
141
  layout() {
136
142
  super.layout();
137
143
  this.calendar?.layout();
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC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,UAAU,CAAC,aAAa,GAAG,IAAI;QAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,aAAa;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IAMD,SAAS,CAAC,KAAa;QACtB,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAuBD,MAAM;QACL,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACzB,CAAC;;;;AA9FM,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,KAAK,CAAC,UAAU,CAAC;+CACL;AA3BD,gBAAgB;IAD5B,aAAa,CAAC,sBAAsB,CAAC;GACzB,gBAAgB,CAmI5B","sourcesContent":["import { Dropdown, Input, 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\";\nimport { unsafeHTML } from \"lit/directives/unsafe-html.js\";\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@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\tawait super.open();\n\t\tif (this.calendar.parentElement != this.dropdown) this.dropdown.appendChild(this.calendar);\n\t\tthis.layout();\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\t_onInputBlur = () => {\n\t\tconst newDate = this.parseDate(this.input.value);\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\t\n\t_onInput = () => {\n\t\tconst newDate = this.parseDate(this.input.value);\n\t\tif (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() {\n\t\tsuper.layout();\n\t\tthis.calendar?.layout();\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\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.calendar?.formattedDate || unsafeHTML('&nbsp;')}\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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AAC,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,KAAK,CAAC,UAAU,CAAC;+CACL;AA3BD,gBAAgB;IAD5B,aAAa,CAAC,sBAAsB,CAAC;GACzB,gBAAgB,CAyI5B","sourcesContent":["import { Dropdown, Input, 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\";\nimport { unsafeHTML } from \"lit/directives/unsafe-html.js\";\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@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\tawait super.open();\n\t\tif (this.calendar.parentElement != this.dropdown) this.dropdown.appendChild(this.calendar);\n\t\tthis.layout();\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() {\n\t\tsuper.layout();\n\t\tthis.calendar?.layout();\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\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.calendar?.formattedDate || unsafeHTML('&nbsp;')}\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/calendar",
3
- "version": "0.10.47",
3
+ "version": "0.10.49",
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.47",
32
- "@omegagrid/grid": "^0.10.47",
33
- "@omegagrid/grid-core": "^0.10.47",
34
- "@omegagrid/localize": "^0.10.47",
31
+ "@omegagrid/core": "^0.10.49",
32
+ "@omegagrid/grid": "^0.10.49",
33
+ "@omegagrid/grid-core": "^0.10.49",
34
+ "@omegagrid/localize": "^0.10.49",
35
35
  "date-fns": "^3.2.0",
36
36
  "lit": "^3.1.1",
37
37
  "ts-debounce": "^4.0.0"