@omegagrid/calendar 0.7.14 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,7 @@ declare const _default: {
39
39
  MENU_ITEM_HEIGHT: number;
40
40
  COLORPICKER_COLOR_SIZE: number;
41
41
  DEFAULT_NUMBER_FORMAT: string;
42
+ BUTTON_HEIGHT: number;
42
43
  FONT_SIZE: number;
43
44
  HEADER_HEIGHT: number;
44
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAGE"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAGE"}
@@ -64,22 +64,22 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
64
64
  @blur="${this._onInputBlur}"
65
65
  .value="${this.calendar?.formattedDate || ''}">
66
66
  </og-input>
67
- ` : ''}
68
-
69
- <og-button
70
- ?caret="${!this.noCaret}"
71
- color="${this.color}"
72
- id="main"
73
- style="flex: 1; text-align: center;"
74
- @mousedown="${this._onMousedown}">
75
- <div id="content" slot="content">
76
- ${this.calendar?.formattedDate || unsafeHTML('&nbsp;')}
77
- </div>
78
- </og-button>
67
+ ` : html `
68
+ <og-button
69
+ ?caret="${!this.noCaret}"
70
+ color="${this.color}"
71
+ class="main"
72
+ style="flex: 1; text-align: center;"
73
+ @mousedown="${this._onMousedown}">
74
+ <div class="content" slot="content">
75
+ ${this.calendar?.formattedDate || unsafeHTML('&nbsp;')}
76
+ </div>
77
+ </og-button>
78
+ `}
79
79
 
80
80
  ${this.hasCrossButton ? html `
81
81
  <og-button
82
- id="cross"
82
+ class="cross"
83
83
  @mousedown="${() => this.clearValue(true)}"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BAAgB,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` : ''}\n\n\t\t<og-button\n\t\t\t?caret=\"${!this.noCaret}\"\n\t\t\tcolor=\"${this.color}\"\n\t\t\tid=\"main\"\n\t\t\tstyle=\"flex: 1; text-align: center;\" \n\t\t\t@mousedown=\"${this._onMousedown}\">\n\t\t\t<div id=\"content\" slot=\"content\">\n\t\t\t\t${this.calendar?.formattedDate || unsafeHTML('&nbsp;')}\n\t\t\t</div>\n\t\t</og-button>\n\n\t\t${this.hasCrossButton ? html`\n\t\t\t<og-button\n\t\t\t\tid=\"cross\"\n\t\t\t\t@mousedown=\"${() => this.clear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AGd;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}\"\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 +1 @@
1
- {"version":3,"file":"dropdown.style.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,yBAwCjB,CAAC"}
1
+ {"version":3,"file":"dropdown.style.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,yBAuCjB,CAAC"}
@@ -2,21 +2,20 @@ import { css } from "lit";
2
2
  export const style = css `
3
3
  og-input {
4
4
  flex: 1;
5
- border: 1px solid var(--og-accent-color);
5
+ border: none;
6
6
  outline: none;
7
7
  background-color: var(--og-background-color);
8
- border-right-width: 0;
9
8
  color: var(--og-text-color);
10
9
  }
11
10
 
12
- :host([cross]) og-button#main, og-input {
11
+ :host([cross]) og-button.main, og-input {
13
12
  border-top-right-radius: 0;
14
13
  border-bottom-right-radius: 0;
15
14
  }
16
15
 
17
- og-button#cross {
18
- border-top-left-radius: 0;
19
- border-bottom-left-radius: 0;
16
+ og-button.cross {
17
+ border-width: 0;
18
+ border-left-width: 1px;
20
19
  }
21
20
 
22
21
  og-input+og-button {
@@ -24,19 +23,19 @@ export const style = css `
24
23
  max-width: 14px;
25
24
  }
26
25
 
27
- #cross {
26
+ .cross {
28
27
  flex: 0;
29
28
  max-width: 14px;
30
29
  min-width: 14px;
31
30
  border: 1px solid var(--og-accent-color);
32
31
  }
33
32
 
34
- #caption, #placeholder {
33
+ .caption, .placeholder {
35
34
  color: var(--og-text-color-2);
36
35
  opacity: 0.7;
37
36
  }
38
37
 
39
- #content {
38
+ .content {
40
39
  display: flex;
41
40
  }
42
41
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.style.js","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCvB,CAAC","sourcesContent":["import { css } from \"lit\";\n\nexport const style = css`\n\tog-input {\n\t\tflex: 1;\n\t\tborder: 1px solid var(--og-accent-color);\n\t\toutline: none;\n\t\tbackground-color: var(--og-background-color);\n\t\tborder-right-width: 0;\n\t\tcolor: var(--og-text-color);\n\t}\n\n\t:host([cross]) og-button#main, og-input {\n\t\tborder-top-right-radius: 0;\n\t\tborder-bottom-right-radius: 0;\n\t}\n\n\tog-button#cross {\n\t\tborder-top-left-radius: 0;\n\t\tborder-bottom-left-radius: 0;\n\t}\n\n\tog-input+og-button {\n\t\tflex: 0;\n\t\tmax-width: 14px;\n\t}\n\n\t#cross {\n\t\tflex: 0;\n\t\tmax-width: 14px;\n\t\tmin-width: 14px;\n\t\tborder: 1px solid var(--og-accent-color);\n\t}\n\n\t#caption, #placeholder {\n\t\tcolor: var(--og-text-color-2);\n\t\topacity: 0.7;\n\t}\n\n\t#content {\n\t\tdisplay: flex;\n\t}\n`;\n"]}
1
+ {"version":3,"file":"dropdown.style.js","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCvB,CAAC","sourcesContent":["import { css } from \"lit\";\n\nexport const style = css`\n\tog-input {\n\t\tflex: 1;\n\t\tborder: none;\n\t\toutline: none;\n\t\tbackground-color: var(--og-background-color);\n\t\tcolor: var(--og-text-color);\n\t}\n\n\t:host([cross]) og-button.main, og-input {\n\t\tborder-top-right-radius: 0;\n\t\tborder-bottom-right-radius: 0;\n\t}\n\n\tog-button.cross {\n\t\tborder-width: 0;\n\t\tborder-left-width: 1px;\n\t}\n\n\tog-input+og-button {\n\t\tflex: 0;\n\t\tmax-width: 14px;\n\t}\n\n\t.cross {\n\t\tflex: 0;\n\t\tmax-width: 14px;\n\t\tmin-width: 14px;\n\t\tborder: 1px solid var(--og-accent-color);\n\t}\n\n\t.caption, .placeholder {\n\t\tcolor: var(--og-text-color-2);\n\t\topacity: 0.7;\n\t}\n\n\t.content {\n\t\tdisplay: flex;\n\t}\n`;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/calendar",
3
- "version": "0.7.14",
3
+ "version": "0.8.0",
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.7.14",
32
- "@omegagrid/grid": "^0.7.14",
33
- "@omegagrid/grid-core": "^0.7.14",
34
- "@omegagrid/localize": "^0.7.14",
31
+ "@omegagrid/core": "^0.8.0",
32
+ "@omegagrid/grid": "^0.8.0",
33
+ "@omegagrid/grid-core": "^0.8.0",
34
+ "@omegagrid/localize": "^0.8.0",
35
35
  "date-fns": "^3.2.0",
36
36
  "lit": "^3.1.1",
37
37
  "ts-debounce": "^4.0.0"