@omegagrid/calendar 0.10.59 → 0.10.60
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/ui/dropdown.d.ts +3 -0
- package/dist/ui/dropdown.d.ts.map +1 -1
- package/dist/ui/dropdown.js +16 -2
- package/dist/ui/dropdown.js.map +1 -1
- package/dist/ui/dropdown.style.d.ts.map +1 -1
- package/dist/ui/dropdown.style.js +4 -0
- package/dist/ui/dropdown.style.js.map +1 -1
- package/package.json +5 -5
package/dist/ui/dropdown.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare class CalendarDropdown extends Dropdown {
|
|
|
9
9
|
get value(): Date;
|
|
10
10
|
set value(value: Date);
|
|
11
11
|
cross: boolean;
|
|
12
|
+
caption: string;
|
|
13
|
+
placeholder: string;
|
|
12
14
|
input: Input;
|
|
13
15
|
get hasCrossButton(): boolean;
|
|
14
16
|
get calendar(): Calendar;
|
|
@@ -21,6 +23,7 @@ export declare class CalendarDropdown extends Dropdown {
|
|
|
21
23
|
_onInput: () => void;
|
|
22
24
|
_onInputKeydown: (e: KeyboardEvent) => void;
|
|
23
25
|
layout(): void;
|
|
26
|
+
getButtonContentHtml(): import("lit-html").TemplateResult<1>;
|
|
24
27
|
render: () => import("lit-html").TemplateResult<1>;
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=dropdown.d.ts.map
|
|
@@ -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;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
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;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBACa,gBAAiB,SAAQ,QAAQ;;IAE7C,MAAM,CAAC,MAAM,4BAA+B;IAG5C,eAAe,EAAE,OAAO,CAErB;IAGH,WAAW,UAAS;IAGpB,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;IAIb,IAAI,cAAc,YAEjB;IAED,IAAI,QAAQ,aAaX;IAEK,IAAI,CAAC,YAAY,GAAE,MAAa;IAQtC,UAAU,CAAC,aAAa,UAAO;IAM/B,aAAa,aAEZ;IAED,SAAS,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,oBAAoB;IAUpB,MAAM,6CAiCJ;CACF"}
|
package/dist/ui/dropdown.js
CHANGED
|
@@ -21,7 +21,6 @@ import { customElement, property, query } from "lit/decorators.js";
|
|
|
21
21
|
import { initOptions } from "../options";
|
|
22
22
|
import { html } from "lit";
|
|
23
23
|
import { style } from "./dropdown.style";
|
|
24
|
-
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
25
24
|
let CalendarDropdown = class CalendarDropdown extends Dropdown {
|
|
26
25
|
constructor() {
|
|
27
26
|
super(...arguments);
|
|
@@ -64,6 +63,7 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
|
|
|
64
63
|
@focus="${this._onInputFocus}"
|
|
65
64
|
@input="${this._onInput}"
|
|
66
65
|
@blur="${this._onInputBlur}"
|
|
66
|
+
placeholder="${this.placeholder || ''}"
|
|
67
67
|
.value="${this.calendar?.formattedDate || ''}">
|
|
68
68
|
</og-input>
|
|
69
69
|
` : html `
|
|
@@ -74,7 +74,7 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
|
|
|
74
74
|
style="flex: 1; text-align: center;"
|
|
75
75
|
@mousedown="${this._onMousedown}">
|
|
76
76
|
<div class="content" slot="content">
|
|
77
|
-
${this.
|
|
77
|
+
${this.getButtonContentHtml()}
|
|
78
78
|
</div>
|
|
79
79
|
</og-button>
|
|
80
80
|
`}
|
|
@@ -142,6 +142,14 @@ let CalendarDropdown = class CalendarDropdown extends Dropdown {
|
|
|
142
142
|
super.layout();
|
|
143
143
|
this.calendar?.layout();
|
|
144
144
|
}
|
|
145
|
+
getButtonContentHtml() {
|
|
146
|
+
const caption = this.caption ? html `<div class="caption">${this.caption}</div>` : null;
|
|
147
|
+
const placeholder = this.placeholder ? html `<div class="placeholder">${this.placeholder}</div>` : null;
|
|
148
|
+
const formattedDate = this.calendar?.formattedDate;
|
|
149
|
+
return formattedDate ? html `${caption ? html `${caption}:` : ``}<div class="itm">${formattedDate}</div>` : (caption
|
|
150
|
+
? html `${caption}${placeholder ? html `: ${placeholder}` : ``}`
|
|
151
|
+
: (placeholder ? html `${placeholder}` : html ` `));
|
|
152
|
+
}
|
|
145
153
|
};
|
|
146
154
|
_CalendarDropdown_value = new WeakMap();
|
|
147
155
|
_CalendarDropdown_calendar = new WeakMap();
|
|
@@ -158,6 +166,12 @@ __decorate([
|
|
|
158
166
|
__decorate([
|
|
159
167
|
property({ type: Boolean, reflect: true })
|
|
160
168
|
], CalendarDropdown.prototype, "cross", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
property({ type: String })
|
|
171
|
+
], CalendarDropdown.prototype, "caption", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
property({ type: String })
|
|
174
|
+
], CalendarDropdown.prototype, "placeholder", void 0);
|
|
161
175
|
__decorate([
|
|
162
176
|
query('og-input')
|
|
163
177
|
], CalendarDropdown.prototype, "input", void 0);
|
package/dist/ui/dropdown.js.map
CHANGED
|
@@ -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;AACnE,OAAO,EAAE,WAAW,EAAW,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGpD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,QAAQ;IAAvC;;QAKN,oBAAe,GAAY,WAAW,CAAC;YACtC,gBAAgB,EAAE,QAAQ;SAC1B,CAAC,CAAC;QAGH,gBAAW,GAAG,KAAK,CAAC;QAEpB,0CAAa;QAYb,UAAK,GAAG,KAAK,CAAC;QAKd,6CAAoB;QAmCpB,kBAAa,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC,CAAA;QAWD,iBAAY,GAAG,GAAG,EAAE;YACnB,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,OAAO,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAAE,OAAO,GAAG,IAAI,CAAC;YACrE,IAAI,OAAO,IAAI,IAAI;gBAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;Y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EAAE,CAAC;IACzB,CAAC;;;;AApGM,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,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(' ')}\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,EAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtE,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,O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AC,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;;;;AApHM,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,CA0J5B","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\";\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\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\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`: ${placeholder}` : ``}`\n\t\t\t: (placeholder ? html`${placeholder}` : html` `)\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.style.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"dropdown.style.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,yBA2CjB,CAAC"}
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CvB,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\t.content .itm {\n\t\tmargin-left: 2px;\n\t}\n`;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/calendar",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.60",
|
|
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.
|
|
32
|
-
"@omegagrid/grid": "^0.10.
|
|
33
|
-
"@omegagrid/grid-core": "^0.10.
|
|
34
|
-
"@omegagrid/localize": "^0.10.
|
|
31
|
+
"@omegagrid/core": "^0.10.60",
|
|
32
|
+
"@omegagrid/grid": "^0.10.60",
|
|
33
|
+
"@omegagrid/grid-core": "^0.10.60",
|
|
34
|
+
"@omegagrid/localize": "^0.10.60",
|
|
35
35
|
"date-fns": "^3.2.0",
|
|
36
36
|
"lit": "^3.1.1",
|
|
37
37
|
"ts-debounce": "^4.0.0"
|