@omegagrid/calendar 0.4.46

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.
@@ -0,0 +1,45 @@
1
+ /// <reference types="color" />
2
+ declare const _default: {
3
+ PREFIX: string;
4
+ DEFAULT_ACCENT_COLOR: string;
5
+ DEFAULT_ACCENT_COLOR_2: import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<any> | {
6
+ [key: string]: any;
7
+ }> | {
8
+ [key: string]: any;
9
+ }> | {
10
+ [key: string]: any;
11
+ }> | {
12
+ [key: string]: any;
13
+ }> | {
14
+ [key: string]: any;
15
+ }> | {
16
+ [key: string]: any;
17
+ }> | {
18
+ [key: string]: any;
19
+ }> | {
20
+ [key: string]: any;
21
+ }> | {
22
+ [key: string]: any;
23
+ }> | {
24
+ [key: string]: any;
25
+ }> | {
26
+ [key: string]: any;
27
+ }>;
28
+ SIZER_SIZE: number;
29
+ SLIDER_SIZE: number;
30
+ SLIDER_MIN_LENGTH: number;
31
+ EXPANDER_SIZE: number;
32
+ LIST_ITEM_HEIGHT: number;
33
+ LIST_RENDERING_TRESHOLD: number;
34
+ LIST_AUTOSCROLL_TRESHOLD: number;
35
+ LIST_AUTOSCROLL_DELAY: number;
36
+ DEFAULT_TEXT_HIGHLIGHT_COLOR: string;
37
+ TOOLTIP_MARGIN: number;
38
+ MENU_ITEM_HEIGHT: number;
39
+ COLORPICKER_COLOR_SIZE: number;
40
+ DEFAULT_NUMBER_FORMAT: string;
41
+ FONT_SIZE: number;
42
+ HEADER_HEIGHT: number;
43
+ };
44
+ export default _default;
45
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAGE"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@omegagrid/core");
4
+ exports.default = {
5
+ HEADER_HEIGHT: 22,
6
+ ...core_1.constants
7
+ };
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;AAAA,0CAA6D;AAE7D,kBAAe;IACd,aAAa,EAAE,EAAE;IACjB,GAAG,gBAAa;CAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ui';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ui"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB"}
@@ -0,0 +1,11 @@
1
+ import { CommonOptions, VerticalPosition } from "@omegagrid/core";
2
+ import type { Day } from "date-fns";
3
+ export type Options = {
4
+ minDate: Date;
5
+ maxDate: Date;
6
+ weekStart: Day;
7
+ todayButton: boolean;
8
+ controlsPosition: VerticalPosition;
9
+ } & CommonOptions;
10
+ export declare function initOptions(options?: Partial<Options>, origOptions?: Options): Options;
11
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAGpC,MAAM,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAA;CAClC,GAAG,aAAa,CAAA;AAUjB,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAE,OAAc,GAAG,OAAO,CAY5F"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initOptions = void 0;
4
+ const core_1 = require("@omegagrid/core");
5
+ const date_fns_1 = require("date-fns");
6
+ const DEFAULT_OPTIONS = {
7
+ minDate: new Date(1900, 0, 1, 0, 0, 0),
8
+ maxDate: new Date(2100, 11, 31, 0, 0, 0),
9
+ weekStart: 1, // Monday
10
+ todayButton: true,
11
+ controlsPosition: 'top'
12
+ };
13
+ function initOptions(options, origOptions = null) {
14
+ const opts = {
15
+ ...(0, core_1.initCommonOptions)(options, origOptions),
16
+ ...DEFAULT_OPTIONS,
17
+ ...origOptions,
18
+ ...options,
19
+ };
20
+ opts.minDate = (0, date_fns_1.startOfWeek)(opts.minDate, { weekStartsOn: opts.weekStart });
21
+ opts.maxDate = (0, date_fns_1.endOfWeek)(opts.maxDate, { weekStartsOn: opts.weekStart });
22
+ return opts;
23
+ }
24
+ exports.initOptions = initOptions;
25
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AAAA,0CAAqF;AAErF,uCAAkD;AAUlD,MAAM,eAAe,GAAqB;IACzC,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxC,SAAS,EAAE,CAAC,EAAE,SAAS;IACvB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAEF,SAAgB,WAAW,CAAC,OAA0B,EAAE,cAAuB,IAAI;IAClF,MAAM,IAAI,GAAG;QACZ,GAAG,IAAA,wBAAiB,EAAC,OAAO,EAAE,WAAW,CAAC;QAC1C,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC;IAEF,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,OAAO,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IAEzE,OAAO,IAAI,CAAC;AACb,CAAC;AAZD,kCAYC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { DropdownList, Layout, OmegaComponent } from '@omegagrid/core';
2
+ import { Grid } from '@omegagrid/grid';
3
+ import { Options } from '../options';
4
+ export declare class Calendar extends OmegaComponent implements Layout {
5
+ #private;
6
+ static styles: import("lit").CSSResult[];
7
+ body: HTMLDivElement;
8
+ options: Options;
9
+ date: Date;
10
+ year: number;
11
+ month: number;
12
+ monthDropdown: DropdownList;
13
+ yearDropdown: DropdownList;
14
+ get dateFormatter(): (date: Date) => string;
15
+ get formattedDate(): string;
16
+ willUpdate(props: Map<string, unknown>): void;
17
+ connectedCallback(): void;
18
+ disconnectedCallback(): void;
19
+ updateBody(): void;
20
+ get grid(): Grid;
21
+ layout(): void;
22
+ goto(date?: Date): void;
23
+ updated(props: Map<string, unknown>): void;
24
+ updateDate(date: Date, dispatchEvent?: boolean): void;
25
+ gotoCurrentSelection(): void;
26
+ addYear(offset: number): void;
27
+ addMonth(offset: number): void;
28
+ renderControls: () => import("lit-html").TemplateResult<1>;
29
+ render: () => Iterable<string | import("lit-html/directive").DirectiveResult<typeof import("lit-html/directives/cache").CacheDirective>>;
30
+ }
31
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/ui/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAK3F,OAAO,EAAwB,IAAI,EAAyB,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAQlD,qBACa,QAAS,SAAQ,cAAe,YAAW,MAAM;;IAE7D,MAAM,CAAC,MAAM,4BAAW;IAGxB,IAAI,EAAE,cAAc,CAAC;IAGrB,OAAO,EAAE,OAAO,CAAC;IAGjB,IAAI,OAA0B;IAG9B,IAAI,SAA8B;IAGlC,KAAK,SAA+B;IAGpC,aAAa,EAAE,YAAY,CAAC;IAG5B,YAAY,EAAE,YAAY,CAAC;IAG3B,IAAI,aAAa,2BAKhB;IAED,IAAI,aAAa,WAGhB;IAMD,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAMtC,iBAAiB;IAKjB,oBAAoB;IASpB,UAAU;IASV,IAAI,IAAI,SAaP;IAED,MAAM;IAIN,IAAI,CAAC,IAAI,GAAE,IAAW;IAyDtB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAcnC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,UAAO;IAsB3C,oBAAoB;IAIpB,OAAO,CAAC,MAAM,EAAE,MAAM;IAQtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAavB,cAAc,6CA+Eb;IAED,MAAM,mIAMC;CAEP"}
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14
+ if (kind === "m") throw new TypeError("Private method is not writable");
15
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
16
+ 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");
17
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
18
+ };
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ var _Calendar_instances, _Calendar_dateFormatter, _Calendar_dispatchChangeEvent, _Calendar_calculateColumnWidth, _Calendar_calculateRowHeight, _Calendar_grid, _Calendar_gridInitialized, _Calendar_month, _Calendar_renderer, _Calendar_getSourceData, _Calendar_onSelect, _Calendar_onRender, _Calendar_onSelectChange;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.Calendar = void 0;
25
+ const core_1 = require("@omegagrid/core");
26
+ const lit_1 = require("lit");
27
+ const decorators_js_1 = require("lit/decorators.js");
28
+ const join_js_1 = require("lit/directives/join.js");
29
+ const calendar_style_1 = require("./calendar.style");
30
+ const grid_1 = require("@omegagrid/grid");
31
+ const options_1 = require("../options");
32
+ const utils_1 = require("../utils");
33
+ const date_fns_1 = require("date-fns");
34
+ const guard_js_1 = require("lit/directives/guard.js");
35
+ const cache_js_1 = require("lit/directives/cache.js");
36
+ const localize_1 = require("@omegagrid/localize");
37
+ const constants_1 = __importDefault(require("../constants"));
38
+ let Calendar = class Calendar extends core_1.OmegaComponent {
39
+ constructor() {
40
+ super(...arguments);
41
+ _Calendar_instances.add(this);
42
+ this.date = (0, date_fns_1.startOfDay)(new Date());
43
+ this.year = (new Date()).getFullYear();
44
+ this.month = (new Date()).getMonth() + 1;
45
+ _Calendar_dateFormatter.set(this, void 0);
46
+ _Calendar_dispatchChangeEvent.set(this, () => this.dispatchEvent(new core_1.events.ChangeEvent({ value: this.date })));
47
+ _Calendar_calculateColumnWidth.set(this, () => this.body.clientWidth / 7);
48
+ _Calendar_calculateRowHeight.set(this, () => (this.body.clientHeight - constants_1.default.HEADER_HEIGHT) / 6);
49
+ _Calendar_grid.set(this, void 0);
50
+ _Calendar_gridInitialized.set(this, false);
51
+ _Calendar_month.set(this, void 0);
52
+ _Calendar_renderer.set(this, (div, cell) => {
53
+ const date = (0, utils_1.getDate)(cell.r, cell.c, this.options);
54
+ div.innerHTML = (0, date_fns_1.format)(date, 'd');
55
+ div.style.textAlign = 'center';
56
+ if (__classPrivateFieldGet(this, _Calendar_month, "f") == null) {
57
+ __classPrivateFieldSet(this, _Calendar_month, (date.getMonth() + (date.getDate() < 10 ? 0 : 1)) % 12, "f");
58
+ this.month = __classPrivateFieldGet(this, _Calendar_month, "f") + 1;
59
+ this.year = date.getFullYear();
60
+ }
61
+ if (__classPrivateFieldGet(this, _Calendar_month, "f") == date.getMonth()) {
62
+ div.style.backgroundColor = 'initial';
63
+ }
64
+ else {
65
+ div.style.backgroundColor = 'var(--og-background-color-3)';
66
+ }
67
+ return div;
68
+ });
69
+ _Calendar_onSelect.set(this, (e) => {
70
+ if (e.selection.activeCell) {
71
+ this.updateDate((0, utils_1.getDate)(e.selection.range.r1, e.selection.range.c1, this.options));
72
+ }
73
+ });
74
+ _Calendar_onRender.set(this, () => __classPrivateFieldSet(this, _Calendar_month, null, "f"));
75
+ _Calendar_onSelectChange.set(this, async () => {
76
+ this.month = this.monthDropdown.value;
77
+ this.year = this.yearDropdown.value;
78
+ await this.updateComplete;
79
+ this.gotoCurrentSelection();
80
+ });
81
+ this.renderControls = () => (0, lit_1.html) `
82
+ <div class="header">
83
+ ${this.date ? (0, lit_1.html) `
84
+ <og-button
85
+ class="date"
86
+ color="transparent"
87
+ .text="${this.formattedDate}"
88
+ @click="${() => this.goto(this.date)}">
89
+ </og-button>
90
+ ` : ''}
91
+
92
+ ${this.options.todayButton ? (0, lit_1.html) `
93
+ <og-button
94
+ style="flex: 1; text-align: center"
95
+ class="today"
96
+ color="transparent"
97
+ .text="${(0, localize_1.msg)('today')}"
98
+ @click="${() => this.updateDate(new Date())}">
99
+ </og-button>
100
+ ` : (0, lit_1.html) `
101
+ <div style="flex: 1"></div>
102
+ `}
103
+
104
+ ${(0, guard_js_1.guard)([this.month], () => {
105
+ var _a;
106
+ return (0, lit_1.html) `
107
+ <og-button
108
+ class="left"
109
+ icon="caret-left"
110
+ color="accent"
111
+ @click="${() => this.addMonth(-1)}">
112
+ </og-button>
113
+
114
+ <og-dropdown-list
115
+ noCaret
116
+ class="month"
117
+ color="accent"
118
+ style="width: 60px; text-align: center"
119
+ @change="${__classPrivateFieldGet(this, _Calendar_onSelectChange, "f")}"
120
+ .value="${(_a = this.month) === null || _a === void 0 ? void 0 : _a.toString()}"
121
+ .items="${(0, utils_1.getMonthNames)(this.options).map((name, i) => ({ key: (i + 1).toString(), value: name }))}">
122
+ </og-dropdown-list>
123
+
124
+ <og-button
125
+ class="right"
126
+ icon="caret-right"
127
+ color="accent"
128
+ @click="${() => this.addMonth(1)}">
129
+ </og-button>
130
+ `;
131
+ })}
132
+
133
+ ${(0, guard_js_1.guard)([this.year], () => (0, lit_1.html) `
134
+ <og-button
135
+ class="left"
136
+ icon="caret-left"
137
+ color="accent"
138
+ style="margin-left: 10px"
139
+ @click="${() => this.addYear(-1)}">
140
+ </og-button>
141
+
142
+ <og-dropdown-list
143
+ noCaret
144
+ width="45"
145
+ class="year"
146
+ color="accent"
147
+ style="width: 35px; text-align: center"
148
+ alignment="left"
149
+ @change="${__classPrivateFieldGet(this, _Calendar_onSelectChange, "f")}"
150
+ .value="${this.year.toString()}"
151
+ .items="${(0, utils_1.getYears)(this.options).map(y => ({ key: y.toString(), value: y.toString() }))}">
152
+ </og-dropdown-list>
153
+
154
+ <og-button
155
+ class="right"
156
+ icon="caret-right"
157
+ color="accent"
158
+ style="margin-right: 5px"
159
+ @click="${() => this.addYear(1)}">
160
+ </og-button>
161
+ `)}
162
+ </div>
163
+ `;
164
+ this.render = () => (0, join_js_1.join)(this.options.controlsPosition != 'top' ? [
165
+ (0, cache_js_1.cache)((0, lit_1.html) `<div class="body"></div>`),
166
+ this.renderControls()
167
+ ] : [
168
+ this.renderControls(),
169
+ (0, cache_js_1.cache)((0, lit_1.html) `<div class="body"></div>`)
170
+ ], '');
171
+ }
172
+ get dateFormatter() {
173
+ if (!__classPrivateFieldGet(this, _Calendar_dateFormatter, "f")) {
174
+ __classPrivateFieldSet(this, _Calendar_dateFormatter, core_1.dates.getDateFormatter(this.options.locale), "f");
175
+ }
176
+ return __classPrivateFieldGet(this, _Calendar_dateFormatter, "f");
177
+ }
178
+ get formattedDate() {
179
+ if (!this.date)
180
+ return '';
181
+ return this.dateFormatter(this.date);
182
+ }
183
+ willUpdate(props) {
184
+ if (props.has('options') || !this.options) {
185
+ this.options = (0, options_1.initOptions)(this.options);
186
+ }
187
+ }
188
+ connectedCallback() {
189
+ super.connectedCallback();
190
+ this.updateBody();
191
+ }
192
+ disconnectedCallback() {
193
+ if (this.body)
194
+ core_1.dom.empty(this.body);
195
+ __classPrivateFieldSet(this, _Calendar_grid, null, "f");
196
+ }
197
+ updateBody() {
198
+ if (!this.body)
199
+ return;
200
+ if (this.body.firstElementChild != this.grid) {
201
+ core_1.dom.empty(this.body);
202
+ this.grid.setSourceData(__classPrivateFieldGet(this, _Calendar_instances, "m", _Calendar_getSourceData).call(this));
203
+ this.body.appendChild(this.grid);
204
+ }
205
+ }
206
+ get grid() {
207
+ if (__classPrivateFieldGet(this, _Calendar_grid, "f"))
208
+ return __classPrivateFieldGet(this, _Calendar_grid, "f");
209
+ __classPrivateFieldSet(this, _Calendar_grid, core_1.dom.createElement('og-grid'), "f");
210
+ core_1.dom.setInset(__classPrivateFieldGet(this, _Calendar_grid, "f"), 0);
211
+ __classPrivateFieldGet(this, _Calendar_grid, "f").addEventListener('grid.select', __classPrivateFieldGet(this, _Calendar_onSelect, "f"));
212
+ __classPrivateFieldGet(this, _Calendar_grid, "f").addEventListener('grid.render', __classPrivateFieldGet(this, _Calendar_onRender, "f"));
213
+ __classPrivateFieldGet(this, _Calendar_grid, "f").addEventListener('grid.init', () => {
214
+ var _a;
215
+ const coords = (0, utils_1.getCellCoordsByDate)(this.date, this.options);
216
+ (_a = this.grid) === null || _a === void 0 ? void 0 : _a.selecting.select(new grid_1.CellRange(coords.column, coords.row));
217
+ this.goto();
218
+ __classPrivateFieldSet(this, _Calendar_gridInitialized, true, "f");
219
+ });
220
+ return __classPrivateFieldGet(this, _Calendar_grid, "f");
221
+ }
222
+ layout() {
223
+ this.grid.layout();
224
+ }
225
+ goto(date = null) {
226
+ var _a;
227
+ __classPrivateFieldSet(this, _Calendar_month, null, "f");
228
+ date = (_a = date !== null && date !== void 0 ? date : this.date) !== null && _a !== void 0 ? _a : new Date();
229
+ this.year = date.getFullYear();
230
+ this.month = date.getMonth() + 1;
231
+ __classPrivateFieldGet(this, _Calendar_grid, "f").rendering.scrollTo((0, utils_1.getWeekOffset)(date, this.options), 0);
232
+ }
233
+ updated(props) {
234
+ var _a, _b;
235
+ this.updateBody();
236
+ if (props.has('options')) {
237
+ (_a = this.grid) === null || _a === void 0 ? void 0 : _a.setSourceData(__classPrivateFieldGet(this, _Calendar_instances, "m", _Calendar_getSourceData).call(this));
238
+ }
239
+ if (props.has('date') && __classPrivateFieldGet(this, _Calendar_gridInitialized, "f")) {
240
+ const coords = (0, utils_1.getCellCoordsByDate)(this.date, this.options);
241
+ (_b = this.grid) === null || _b === void 0 ? void 0 : _b.selecting.select(new grid_1.CellRange(coords.column, coords.row));
242
+ this.goto();
243
+ }
244
+ }
245
+ updateDate(date, dispatchEvent = true) {
246
+ date = (0, date_fns_1.startOfDay)(date);
247
+ if ((0, date_fns_1.isEqual)(date, this.date))
248
+ return;
249
+ this.date = date;
250
+ if (dispatchEvent)
251
+ __classPrivateFieldGet(this, _Calendar_dispatchChangeEvent, "f").call(this);
252
+ }
253
+ gotoCurrentSelection() {
254
+ this.goto(new Date(this.year, this.month - 1, 1, 0, 0, 0));
255
+ }
256
+ addYear(offset) {
257
+ this.year = Math.max(this.options.minDate.getFullYear(), Math.min(this.options.maxDate.getFullYear(), this.year + offset));
258
+ this.gotoCurrentSelection();
259
+ }
260
+ addMonth(offset) {
261
+ if (this.month + offset > 12) {
262
+ this.month = 1;
263
+ this.addYear(1);
264
+ }
265
+ else if (this.month + offset < 1) {
266
+ this.month = 12;
267
+ this.addYear(-1);
268
+ }
269
+ else {
270
+ this.month += offset;
271
+ this.gotoCurrentSelection();
272
+ }
273
+ }
274
+ };
275
+ exports.Calendar = Calendar;
276
+ _Calendar_dateFormatter = new WeakMap();
277
+ _Calendar_dispatchChangeEvent = new WeakMap();
278
+ _Calendar_calculateColumnWidth = new WeakMap();
279
+ _Calendar_calculateRowHeight = new WeakMap();
280
+ _Calendar_grid = new WeakMap();
281
+ _Calendar_gridInitialized = new WeakMap();
282
+ _Calendar_month = new WeakMap();
283
+ _Calendar_renderer = new WeakMap();
284
+ _Calendar_onSelect = new WeakMap();
285
+ _Calendar_onRender = new WeakMap();
286
+ _Calendar_onSelectChange = new WeakMap();
287
+ _Calendar_instances = new WeakSet();
288
+ _Calendar_getSourceData = function _Calendar_getSourceData() {
289
+ return {
290
+ columns: (0, utils_1.getWeekDays)(this.options).map(day => ({
291
+ renderer: __classPrivateFieldGet(this, _Calendar_renderer, "f"),
292
+ header: [{ label: day, height: constants_1.default.HEADER_HEIGHT }]
293
+ })),
294
+ options: {
295
+ rows: (0, utils_1.getNumberOfWeeks)(this.options),
296
+ rowHeight: __classPrivateFieldGet(this, _Calendar_calculateRowHeight, "f").call(this),
297
+ columnWidth: __classPrivateFieldGet(this, _Calendar_calculateColumnWidth, "f").call(this),
298
+ colLetters: false,
299
+ rowNumbers: false,
300
+ rowResize: false,
301
+ columnResize: false,
302
+ autofill: false,
303
+ cellCache: false,
304
+ singleCellModel: true,
305
+ selecting: {
306
+ enabled: true,
307
+ multiSelect: false,
308
+ },
309
+ scrolling: {
310
+ verticalOverscroll: false,
311
+ horizontalOverscroll: false,
312
+ }
313
+ }
314
+ };
315
+ };
316
+ Calendar.styles = [calendar_style_1.style];
317
+ __decorate([
318
+ (0, decorators_js_1.query)('.body')
319
+ ], Calendar.prototype, "body", void 0);
320
+ __decorate([
321
+ (0, decorators_js_1.property)({ type: Object })
322
+ ], Calendar.prototype, "options", void 0);
323
+ __decorate([
324
+ (0, decorators_js_1.property)({ type: Object })
325
+ ], Calendar.prototype, "date", void 0);
326
+ __decorate([
327
+ (0, decorators_js_1.property)({ type: Number })
328
+ ], Calendar.prototype, "year", void 0);
329
+ __decorate([
330
+ (0, decorators_js_1.property)({ type: Number })
331
+ ], Calendar.prototype, "month", void 0);
332
+ __decorate([
333
+ (0, decorators_js_1.query)('og-dropdown-list.month')
334
+ ], Calendar.prototype, "monthDropdown", void 0);
335
+ __decorate([
336
+ (0, decorators_js_1.query)('og-dropdown-list.year')
337
+ ], Calendar.prototype, "yearDropdown", void 0);
338
+ exports.Calendar = Calendar = __decorate([
339
+ (0, decorators_js_1.customElement)('og-calendar')
340
+ ], Calendar);
341
+ //# sourceMappingURL=calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/ui/calendar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA2F;AAC3F,6BAA2B;AAC3B,qDAAmE;AACnE,oDAA8C;AAC9C,qDAAyC;AACzC,0CAAoF;AACpF,wCAAkD;AAClD,oCAA+H;AAC/H,uCAAuD;AACvD,sDAAgD;AAChD,sDAAgD;AAChD,kDAA0C;AA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IAAA,qBAAK,EAAC,OAAO,CAAC;sCACM;AAGrB;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yCACR;AAGjB;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;sCACK;AAG9B;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;sCACS;AAGlC;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;uCACW;AAGpC;IADC,IAAA,qBAAK,EAAC,wBAAwB,CAAC;+CACJ;AAG5B;IADC,IAAA,qBAAK,EAAC,uBAAuB,CAAC;8CACJ;mBAvBf,QAAQ;IADpB,IAAA,6BAAa,EAAC,aAAa,CAAC;GAChB,QAAQ,CAySpB"}
@@ -0,0 +1,2 @@
1
+ export declare const style: import("lit").CSSResult;
2
+ //# sourceMappingURL=calendar.style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.style.d.ts","sourceRoot":"","sources":["../../src/ui/calendar.style.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,yBA4CjB,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.style = void 0;
7
+ const lit_1 = require("lit");
8
+ const constants_1 = __importDefault(require("../constants"));
9
+ exports.style = (0, lit_1.css) `
10
+ * {
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ :host {
15
+ display: flex;
16
+ flex-direction: column;
17
+ font-family: var(--og-font-family);
18
+ font-size: var(--og-font-size);
19
+ min-height: 200px;
20
+ min-width: 280px;
21
+ }
22
+
23
+ .header {
24
+ flex: 0 0 ${constants_1.default.HEADER_HEIGHT}px;
25
+ background: var(--og-accent-color);
26
+ color: #ffffff;
27
+ display: flex;
28
+ flex-direction: row;
29
+ }
30
+
31
+ .body {
32
+ flex: 1;
33
+ overflow: hidden;
34
+ position: relative;
35
+ }
36
+
37
+ og-grid {
38
+ width: 100%;
39
+ height: 100%;
40
+ }
41
+
42
+ og-button {
43
+ padding-left: 10px;
44
+ padding-right: 10px;
45
+ }
46
+
47
+ og-button.left, og-button.right {
48
+ width: 10px;
49
+ padding-left: 2px;
50
+ padding-right: 2px;
51
+ }
52
+
53
+ `;
54
+ //# sourceMappingURL=calendar.style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.style.js","sourceRoot":"","sources":["../../src/ui/calendar.style.ts"],"names":[],"mappings":";;;;;;AAAA,6BAA0B;AAC1B,6DAAqC;AAExB,QAAA,KAAK,GAAG,IAAA,SAAG,EAAA;;;;;;;;;;;;;;;cAeV,mBAAS,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BpC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Dropdown } from "@omegagrid/core";
2
+ import { Options } from "../options";
3
+ import { Calendar } from "./calendar";
4
+ export declare class CalendarDropdown extends Dropdown {
5
+ #private;
6
+ static styles: import("lit").CSSResult[];
7
+ calendarOptions: Options;
8
+ get value(): Date;
9
+ set value(value: Date);
10
+ cross: boolean;
11
+ get hasCrossButton(): boolean;
12
+ get calendar(): Calendar;
13
+ open(): Promise<void>;
14
+ clearValue(dispatchEvent?: boolean): void;
15
+ render: () => import("lit-html").TemplateResult<1>;
16
+ }
17
+ //# sourceMappingURL=dropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAe,OAAO,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,qBACa,gBAAiB,SAAQ,QAAQ;;IAE7C,MAAM,CAAC,MAAM,4BAA+B;IAG5C,eAAe,EAAE,OAAO,CAErB;IAGH,IACI,KAAK,IACQ,IAAI,CADa;IAClC,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAMpB;IAGD,KAAK,UAAS;IAId,IAAI,cAAc,YAEjB;IAED,IAAI,QAAQ,aAaX;IAEK,IAAI;IAMV,UAAU,CAAC,aAAa,UAAO;IAM/B,MAAM,6CAsBJ;CACF"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14
+ if (kind === "m") throw new TypeError("Private method is not writable");
15
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
16
+ 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");
17
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
18
+ };
19
+ var _CalendarDropdown_value, _CalendarDropdown_calendar;
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.CalendarDropdown = void 0;
22
+ const core_1 = require("@omegagrid/core");
23
+ const decorators_js_1 = require("lit/decorators.js");
24
+ const options_1 = require("../options");
25
+ const lit_1 = require("lit");
26
+ const dropdown_style_1 = require("./dropdown.style");
27
+ const unsafe_html_js_1 = require("lit/directives/unsafe-html.js");
28
+ let CalendarDropdown = class CalendarDropdown extends core_1.Dropdown {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.calendarOptions = (0, options_1.initOptions)({
32
+ controlsPosition: 'bottom'
33
+ });
34
+ _CalendarDropdown_value.set(this, void 0);
35
+ this.cross = false;
36
+ _CalendarDropdown_calendar.set(this, void 0);
37
+ this.render = () => {
38
+ var _a;
39
+ return (0, lit_1.html) `
40
+ <og-button
41
+ caret
42
+ color="${this.color}"
43
+ id="main"
44
+ style="flex: 1"
45
+ @mousedown="${this._onMousedown}">
46
+ <div id="content" slot="content">
47
+ ${((_a = this.calendar) === null || _a === void 0 ? void 0 : _a.formattedDate) || (0, unsafe_html_js_1.unsafeHTML)('&nbsp;')}
48
+ </div>
49
+ </og-button>
50
+
51
+ ${this.hasCrossButton ? (0, lit_1.html) `
52
+ <og-button
53
+ id="cross"
54
+ @mousedown="${() => this.clearValue(true)}"
55
+ icon="xmark"
56
+ color="red">
57
+ </og-button>
58
+ ` : ``}
59
+
60
+ ${this.renderDropdown()}
61
+ `;
62
+ };
63
+ }
64
+ get value() { return __classPrivateFieldGet(this, _CalendarDropdown_value, "f"); }
65
+ set value(value) {
66
+ __classPrivateFieldSet(this, _CalendarDropdown_value, value, "f");
67
+ if (__classPrivateFieldGet(this, _CalendarDropdown_calendar, "f")) {
68
+ __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").date = value;
69
+ this.requestUpdate();
70
+ }
71
+ }
72
+ get hasCrossButton() {
73
+ return this.cross && __classPrivateFieldGet(this, _CalendarDropdown_value, "f") != null;
74
+ }
75
+ get calendar() {
76
+ if (__classPrivateFieldGet(this, _CalendarDropdown_calendar, "f"))
77
+ return __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f");
78
+ __classPrivateFieldSet(this, _CalendarDropdown_calendar, core_1.dom.createElement('og-calendar'), "f");
79
+ __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").date = __classPrivateFieldGet(this, _CalendarDropdown_value, "f");
80
+ __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").options = this.calendarOptions;
81
+ __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").slot = 'inner-content';
82
+ __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f").addEventListener('change', (e) => {
83
+ __classPrivateFieldSet(this, _CalendarDropdown_value, e.value, "f");
84
+ // this.close();
85
+ this.dispatchEvent(new core_1.events.ChangeEvent({ value: e.value }));
86
+ this.requestUpdate();
87
+ });
88
+ return __classPrivateFieldGet(this, _CalendarDropdown_calendar, "f");
89
+ }
90
+ async open() {
91
+ await super.open();
92
+ if (this.calendar.parentElement != this.dropdown)
93
+ this.dropdown.appendChild(this.calendar);
94
+ this.layout();
95
+ }
96
+ clearValue(dispatchEvent = true) {
97
+ this.value = null;
98
+ this.close();
99
+ if (dispatchEvent)
100
+ this.dispatchEvent(new core_1.events.ChangeEvent({ value: null }));
101
+ }
102
+ };
103
+ exports.CalendarDropdown = CalendarDropdown;
104
+ _CalendarDropdown_value = new WeakMap();
105
+ _CalendarDropdown_calendar = new WeakMap();
106
+ CalendarDropdown.styles = [...core_1.Dropdown.styles, dropdown_style_1.style];
107
+ __decorate([
108
+ (0, decorators_js_1.property)({ type: Object })
109
+ ], CalendarDropdown.prototype, "calendarOptions", void 0);
110
+ __decorate([
111
+ (0, decorators_js_1.property)({ type: Object, noAccessor: true })
112
+ ], CalendarDropdown.prototype, "value", null);
113
+ __decorate([
114
+ (0, decorators_js_1.property)({ type: Boolean })
115
+ ], CalendarDropdown.prototype, "cross", void 0);
116
+ exports.CalendarDropdown = CalendarDropdown = __decorate([
117
+ (0, decorators_js_1.customElement)('og-calendar-dropdown')
118
+ ], CalendarDropdown);
119
+ //# sourceMappingURL=dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,0CAAwD;AACxD,qDAA4D;AAC5D,wCAAkD;AAClD,6BAA2B;AAC3B,qDAAyC;AAEzC,kEAA2D;AAGpD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,eAAQ;IAAvC;;QAKN,oBAAe,GAAY,IAAA,qBAAW,EAAC;YACtC,gBAAgB,EAAE,QAAQ;SAC1B,CAAC,CAAC;QAEH,0CAAa;QAYb,UAAK,GAAG,KAAK,CAAC;QAEd,6CAAoB;QAiCpB,WAAM,GAAG,GAAG,EAAE;;YAAC,OAAA,IAAA,UAAI,EAAA;;;YAGR,IAAI,CAAC,KAAK;;;iBAGL,IAAI,CAAC,YAAY;;MAE5B,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,aAAa,KAAI,IAAA,2BAAU,EAAC,QAAQ,CAAC;;;;IAItD,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAA,UAAI,EAAA;;;kBAGZ,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;;;;GAI1C,CAAC,CAAC,CAAC,EAAE;;IAEJ,IAAI,CAAC,cAAc,EAAE;EACvB,CAAA;SAAA,CAAC;IACH,CAAC;IApEA,IAAI,KAAK,KAAK,OAAO,uBAAA,IAAI,+BAAO,CAAA,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,KAAW;QACpB,uBAAA,IAAI,2BAAU,KAAK,MAAA,CAAC;QACpB,IAAI,uBAAA,IAAI,kCAAU,EAAE,CAAC;YACpB,uBAAA,IAAI,kCAAU,CAAC,IAAI,GAAG,KAAK,CAAC;YAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;QACtB,CAAC;IACF,CAAC;IAOD,IA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;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,aAAM,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;;AAtDW,4CAAgB;;;AAErB,uBAAM,GAAG,CAAC,GAAG,eAAQ,CAAC,MAAM,EAAE,sBAAK,CAAC,AAA9B,CAA+B;AAG5C;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yDAGtB;AAIH;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;6CACT;AAUlC;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;+CACZ;2BArBF,gBAAgB;IAD5B,IAAA,6BAAa,EAAC,sBAAsB,CAAC;GACzB,gBAAgB,CA+E5B"}
@@ -0,0 +1,2 @@
1
+ export declare const style: import("lit").CSSResult;
2
+ //# sourceMappingURL=dropdown.style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown.style.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,yBA8BjB,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.style = void 0;
4
+ const lit_1 = require("lit");
5
+ exports.style = (0, lit_1.css) `
6
+ og-input {
7
+ flex: 1;
8
+ border: 1px solid var(--og-accent-color);
9
+ outline: none;
10
+ background-color: var(--og-background-color);
11
+ border-right-width: 0;
12
+ color: var(--og-text-color);
13
+ }
14
+
15
+ og-input+og-button {
16
+ flex: 0;
17
+ max-width: 14px;
18
+ }
19
+
20
+ #cross {
21
+ flex: 0;
22
+ max-width: 14px;
23
+ min-width: 14px;
24
+ border: 1px solid var(--og-accent-color);
25
+ }
26
+
27
+ #caption, #placeholder {
28
+ color: var(--og-text-color-2);
29
+ opacity: 0.7;
30
+ }
31
+
32
+ #content {
33
+ display: flex;
34
+ }
35
+ `;
36
+ //# sourceMappingURL=dropdown.style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown.style.js","sourceRoot":"","sources":["../../src/ui/dropdown.style.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAEb,QAAA,KAAK,GAAG,IAAA,SAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './calendar';
2
+ export * from './dropdown';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./calendar"), exports);
18
+ __exportStar(require("./dropdown"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B"}
@@ -0,0 +1,12 @@
1
+ import { Options } from "./options";
2
+ export declare function getNumberOfWeeks(options: Options): number;
3
+ export declare function getWeekDays(options: Options): string[];
4
+ export declare function getDate(row: number, column: number, options: Options): Date;
5
+ export declare function getYears(options: Options): number[];
6
+ export declare function getMonthNames(options: Options): string[];
7
+ export declare function getWeekOffset(date: Date, options: Options): number;
8
+ export declare function getCellCoordsByDate(date: Date, options: Options): {
9
+ row: number;
10
+ column: number;
11
+ };
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,UAEhD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,YAK3C;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,QAEpE;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,YAMxC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,YAI7C;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,UAEzD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;;;EAK/D"}
package/dist/utils.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCellCoordsByDate = exports.getWeekOffset = exports.getMonthNames = exports.getYears = exports.getDate = exports.getWeekDays = exports.getNumberOfWeeks = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ const core_1 = require("@omegagrid/core");
6
+ function getNumberOfWeeks(options) {
7
+ return Math.ceil((0, date_fns_1.differenceInDays)(options.maxDate, options.minDate) / 7);
8
+ }
9
+ exports.getNumberOfWeeks = getNumberOfWeeks;
10
+ function getWeekDays(options) {
11
+ return (0, date_fns_1.eachDayOfInterval)({
12
+ start: (0, date_fns_1.startOfWeek)(new Date(), { weekStartsOn: options.weekStart }),
13
+ end: (0, date_fns_1.endOfWeek)(new Date(), { weekStartsOn: options.weekStart }),
14
+ }).map(date => (0, date_fns_1.format)(date, 'cccccc', { locale: core_1.dates.getDateLocale(options.locale) }));
15
+ }
16
+ exports.getWeekDays = getWeekDays;
17
+ function getDate(row, column, options) {
18
+ return (0, date_fns_1.add)(options.minDate, { days: row * 7 + column });
19
+ }
20
+ exports.getDate = getDate;
21
+ function getYears(options) {
22
+ const years = [];
23
+ for (let i = options.minDate.getFullYear(); i <= options.maxDate.getFullYear(); i++) {
24
+ years.push(i);
25
+ }
26
+ return years;
27
+ }
28
+ exports.getYears = getYears;
29
+ function getMonthNames(options) {
30
+ return [...(new Array(12)).keys()].map(i => (0, date_fns_1.format)(new Date(2000, i, 1), 'LLLL', {
31
+ locale: core_1.dates.getDateLocale(options.locale)
32
+ }));
33
+ }
34
+ exports.getMonthNames = getMonthNames;
35
+ function getWeekOffset(date, options) {
36
+ return Math.floor((0, date_fns_1.differenceInDays)((0, date_fns_1.startOfMonth)(date), options.minDate) / 7);
37
+ }
38
+ exports.getWeekOffset = getWeekOffset;
39
+ function getCellCoordsByDate(date, options) {
40
+ return {
41
+ row: Math.floor((0, date_fns_1.differenceInDays)(date, options.minDate) / 7),
42
+ column: (0, date_fns_1.differenceInDays)(date, options.minDate) % 7
43
+ };
44
+ }
45
+ exports.getCellCoordsByDate = getCellCoordsByDate;
46
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAkH;AAElH,0CAAwC;AAExC,SAAgB,gBAAgB,CAAC,OAAgB;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAA,2BAAgB,EAAC,OAAO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,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,iBAAM,EAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE;QAChF,MAAM,EAAE,YAAK,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;KAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,sCAIC;AAED,SAAgB,aAAa,CAAC,IAAU,EAAE,OAAgB;IACzD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,2BAAgB,EAAC,IAAA,uBAAY,EAAC,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC;AAFD,sCAEC;AAED,SAAgB,mBAAmB,CAAC,IAAU,EAAE,OAAgB;IAC/D,OAAO;QACN,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAA,2BAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5D,MAAM,EAAE,IAAA,2BAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACnD,CAAC;AACH,CAAC;AALD,kDAKC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@omegagrid/calendar",
3
+ "version": "0.4.46",
4
+ "license": "UNLICENSED",
5
+ "description": "Calendar component",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "./dist/**/*"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/cechi/omegagrid.git"
14
+ },
15
+ "bugs": "https://github.com/cechi/omegagrid/issues",
16
+ "author": {
17
+ "name": "Petr Čechura",
18
+ "email": "p.cechura@gmail.com",
19
+ "url": "https://cechura.eu"
20
+ },
21
+ "scripts": {
22
+ "watch": "tsc --watch",
23
+ "build": "tsc",
24
+ "test": "jest --passWithNoTests",
25
+ "lint": "eslint **/src/**/*.ts",
26
+ "_prepack": "yarn build",
27
+ "_prepublish": "yarn test && yarn lint"
28
+ },
29
+ "dependencies": {
30
+ "@fortawesome/fontawesome-svg-core": "6.4.2",
31
+ "@omegagrid/core": "^0.5.4",
32
+ "@omegagrid/grid": "^0.5.4",
33
+ "@omegagrid/grid-core": "^0.5.4",
34
+ "@omegagrid/localize": "^0.5.4",
35
+ "@riovir/wc-fontawesome": "^0.1.9",
36
+ "date-fns": "^3.2.0",
37
+ "lit": "^3.1.1",
38
+ "ts-debounce": "^4.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/jest": "^29.5.11",
42
+ "@types/node": "^20.11.5",
43
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
44
+ "@typescript-eslint/parser": "^7.16.0",
45
+ "eslint": "^8.56.0",
46
+ "jest": "^29.7.0",
47
+ "jest-environment-jsdom": "^29.7.0",
48
+ "ts-jest": "^29.1.1",
49
+ "ts-node": "^10.9.2",
50
+ "typescript": "5.3.2"
51
+ }
52
+ }